Skip to content

Commit 5ea3fba

Browse files
feat(review): compare against the merge base and reuse the PR's last analysis (#81)
* feat(review): compare against the merge base and reuse the PR's last analysis Reviews compared the head with the event's base branch tip, which moves whenever anyone else pushes. Commits landing on the base after a branch forked were reported as that pull request's changes, and reported backwards, as removals. Reviews now resolve the merge base, the same anchor GitHub's own "Files changed" tab uses, and the comment says how far behind the branch is instead. Each review also seeds its head analysis from this pull request's own previous run, so a run covers only the commits pushed since it, and takes the merge base's analysis from cache rather than recomputing it. Sync mode publishes that base entry as a by-product of the baseline it already computes, so the first pull request to fork from a commit does not pay for it either. Cached state is re-derived from the merge base whenever the pinned CodeBoarding version, .codeboardingignore, the configured depth, or the merge base changes, and state produced while analyzing a fork lives in a namespace trusted runs never restore from. Every cache step is best effort: a miss falls back to today's behaviour. /codeboarding refresh re-seeds from the base and /codeboarding full forces a full analysis, for when a run needs to ignore what came before. tests/test_merge_base_contract.py pins the merge base behaviour against a real git history and is marked protected; AGENTS.md records that no agent may weaken a protected test without explicit human consent. Existing users reconfigure nothing: same inputs, same permissions, and pull_request workflows keep working as they are. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(review): make the analysis caches reachable and the fallback visible Four defects found in review of the previous commit. actions/cache derives its lookup version from the literal path strings, so saving state under .../cb-cache/out/chain could never be restored from .../cb-cache/chain. Every run would have missed and silently redone the full analysis while appearing to be wired up. Saves and restores now use one path per cache, and a test parses action.yml to keep it that way. When the compare API could not be reached, the review fell back to the base branch tip and said so only in the log, quietly producing the comparison this feature exists to avoid. The call is now retried once, and an unresolved merge base is stated in the review comment and recorded in the artifact metadata. The cache identity ignored model selection, so changing model, agent_model, parsing_model, or the provider reused an analysis produced by the previous one and applied the new model only to the delta. Those inputs are now part of the identity. /codeboarding refresh and /codeboarding full recomputed the analysis and then saved it under the key already holding the state they were asked to discard. Cache entries are immutable, so the save was dropped and the next run restored the pre-refresh analysis. Forced runs now save under their own generation key, still found by the same prefix. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(review): restore the pull request chain by prefix Giving forced refreshes their own generation key was not enough. The restore still asked for the plain head-sha key first, and an exact match outranks every prefix match, so the next run at that head returned the entry the refresh had replaced and the refresh was undone again. What a run needs is this pull request's newest analysis, which is what the prefix already selects, so the head-sha key is only there to keep saves unique. The restore now looks up by prefix alone. The base cache keeps its exact lookup, where an exact hit means the merge base's own analysis and a prefix hit is only a warm seed; a test pins both intents. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * docs: describe the merge_base_sha output in plain terms The old wording trailed off ("Commit the review compared the pull request head against") and read as a fragment in the Actions marketplace listing, where output descriptions are surfaced verbatim. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat(review): ship the merge-base analysis in the review artifact The artifact carried only the head graph, so a reader could not reproduce the comparison without resolving the merge base itself. The nearest thing available to it, the baseline committed on the default branch, is the branch tip rather than the merge base, which would drift from what the review actually measured and reintroduce the very bug this branch removes, one layer up. The artifact is also the only channel a reader outside the run has: the Actions cache has no download API, so state kept there can never serve the webview. base_analysis.json now sits beside analysis.json, and metadata.json already names the commit it belongs to. Copying it costs no analysis: the base graph is either restored from cache or produced by a catch-up that finds nothing changed. Retention drops to 30 days, since each run now carries its own copy of the base graph and only a pull request's latest artifact is ever read. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * docs: write down the artifact and cache naming The key shapes existed only in cache-keys.sh, so nothing explained why an artifact is named for its run while a cache key carries the pull request, the merge base and the config digest: one is scoped to a run and found by listing, the other is shared across runs and found by name. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * docs: correct and simplify the storage strategy The document still described a v1 world: it claimed sync commits health_report.json, which install-sync.sh in fact deletes; it omitted fingerprint.json, which sync does commit and which drives change detection; and it explained a pkl-seeding fallback through engine_adapter.py, a script the v2 flow no longer has. It also split the same material across a decision list, a summary table and a "now vs later" section. Rewritten around the three stores and what each is for, with the part that kept being asked in review added: how a review picks its base and head graphs, what each costs, and what changes between a pull request's first run and every run after it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(review): report the merge base under the name the webview reads The webview resolves a pull request's base as `base_commit_sha || pr_base_sha || base_sha` and then fetches the committed analysis at that ref. The action emitted the merge base as merge_base_sha, which is in none of those positions, so the chain fell through to base_sha, the branch tip. The webview would have kept comparing against a base this review never used, reproducing on the hosted side the exact drift the merge base removes here. The value now also ships as pr_base_sha, which is what the webview already documents that field to mean, so a deployed webview picks up the correct base without any change on its side. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * docs: list what metadata.json actually contains The layout block named the fields in a comment without saying what any of them mean, which left the two that matter unexplained: why the merge base is published twice, and that base_sha is the branch tip rather than the commit anything was compared against. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(review): rebuild at the configured depth, and never diff across two bases Three defects found in review. Every escalation to a full analysis passed the baseline's realized depth_level, while Core resolves depth from depth_cap. On a baseline that stopped short of its cap, and this repository's own is depth_level 1 under depth_cap 2, a full run rebuilt at the smaller value and the configured depth was lost for good, taking any component that only exists deeper with it. That applied to /codeboarding full, to a run Core asks to escalate, and to sync's force_full. All of them now use the cap. A restored chain was accepted after checking only its depth, so a run whose base cache had gone missing regenerated the base and diffed a head grown from the previous base against it. Two runs of the engine over one commit need not name components identically, so that reports additions and removals for code nobody touched. The chain now records a digest of the base it grew from and is discarded unless it matches. The base cache entry was documented as shared by every pull request with that merge base. It is not: a cache entry is visible only to the ref that wrote it and to the default branch, so an automatic pull_request run's entry serves only that pull request. Sync, running on the base branch, is what actually warms everybody. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(sync): read the artifact manifest without mapfile mapfile needs bash 4 and macOS ships bash 3.2, so install-sync.sh aborted with "mapfile: command not found" on a developer machine and its test had been failing there for everyone. A read loop does the same job everywhere. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> (cherry picked from commit ae62df2) * fix(sync): publish the baseline under both commits it describes Sync published its analysis under one key, the baseline commit it creates. A pull request opened in the window between a change landing on the branch and sync committing its baseline has the earlier commit as its merge base, so it missed that key and paid for a catch-up every run. That window is the common case on an active branch, not an edge case. The same state is valid for both commits: sync analyzed the earlier tree, and the baseline commit differs from it only in .codeboarding files, which the fingerprint does not cover. Both keys are now published. deliver-sync.sh had no tests, which is how the outputs the cache depends on went unchecked. It now runs against a real local remote, no network needed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 999c6e2 commit 5ea3fba

15 files changed

Lines changed: 1524 additions & 92 deletions

‎.github/workflows/codeboarding.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: CodeBoarding review
22

33
on:
44
pull_request:
5-
# Generate once, when the PR becomes reviewable, not on every push, so we
6-
# don't spend an LLM job per commit. Add `synchronize` to re-run on each
7-
# push, or refresh anytime with /codeboarding. 'closed' only cancels an
8-
# in-flight review (see concurrency), it doesn't start one.
5+
# Generate once, when the PR becomes reviewable. Reusing this PR's previous
6+
# analysis makes per-push runs affordable, so `synchronize` is a reasonable
7+
# addition now; /codeboarding still refreshes on demand. 'closed' only
8+
# cancels an in-flight review (see concurrency), it doesn't start one.
99
types: [opened, reopened, ready_for_review, closed]
1010
issue_comment:
1111
types: [created]

AGENT.md renamed to AGENTS.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# AGENT.md — CodeBoarding-action
1+
# AGENTS.md — CodeBoarding-action
22

33
This repo is a GitHub Action with two modes, selected by the `mode` input:
44

@@ -15,6 +15,27 @@ pinned to a release in `action.yml`. `scripts/engine_adapter.py` is the CLI
1515
adapter into it (no analysis logic lives there). Engine changes reach users only
1616
when that pin is bumped *and* a new action release ships.
1717

18+
## Protected tests
19+
20+
Some tests encode a behavioural contract that is expensive to rediscover once
21+
lost. They are marked with a `PROTECTED TEST` header naming what they protect.
22+
23+
**No agent, assistant, or automated tool may edit, weaken, skip, rename or
24+
delete a protected test — not even to make a build pass. Only a human may
25+
change one, and only after explicitly saying so in that conversation.** A
26+
request to "fix the failing tests" is not that consent.
27+
28+
When a protected test fails, the behaviour it describes regressed. Fix the code.
29+
If you believe the test itself is wrong, stop and say so, then wait for a human
30+
to decide.
31+
32+
Protected tests:
33+
34+
- `tests/test_merge_base_contract.py` — a review compares a pull request against
35+
its merge base, never against the base branch tip. Comparing against the tip
36+
attributes other people's commits to the pull request and reports them
37+
backwards, as removals.
38+
1839
## Releases
1940

2041
Consumers reference a moving major tag (`uses: CodeBoarding/CodeBoarding-action@v1`),

‎README.md‎

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
One GitHub Action with two modes:
44

5-
- **`review`** (default) compares a pull request's exact base and head commits, posts an inline Mermaid architecture diff, and uploads the head `analysis.json` as a workflow artifact.
5+
- **`review`** (default) compares a pull request's head with its merge base, posts an inline Mermaid architecture diff, and uploads both analyses as a workflow artifact.
66
- **`sync`** updates the versioned analysis state used by future incremental runs. It can push directly or open one rolling PR for protected branches.
77

88
The action is a thin wrapper around the [CodeBoarding](https://github.com/CodeBoarding/CodeBoarding) CLI. Analysis logic and provider defaults live in Core, not in this repository.
@@ -44,10 +44,34 @@ jobs:
4444
4545
Automatic runs update one sticky **CodeBoarding review** comment. A trusted repository owner, member, or collaborator can comment `/codeboarding` to analyze the current PR head again, including on fork PRs; every command creates a new result comment.
4646

47-
The action checks out and analyzes the exact PR head SHA, but compares it with the exact upstream base SHA from the event. It does not commit generated files to either branch.
47+
| Command | What it does |
48+
|---|---|
49+
| `/codeboarding` | Analyzes the current head, reusing this PR's previous analysis when one is available. |
50+
| `/codeboarding refresh` | Ignores that previous analysis and re-derives the head from the merge base. |
51+
| `/codeboarding full` | Forces a from-scratch full analysis of the head. |
52+
53+
The action checks out and analyzes the exact PR head SHA, and compares it with the PR's **merge base** — the commit the branch forked from, which is what GitHub's own "Files changed" tab uses. Commits pushed to the base branch after the fork point are therefore not reported as this PR's changes; the comment notes how far behind the branch is instead. It does not commit generated files to either branch.
4854

4955
Automatic fork runs are skipped because the `pull_request` event does not receive hosted OIDC credentials. A trusted `/codeboarding` command runs the released action code from the base repository and checks the fork's source into a separate analysis directory; it never executes an action definition from the fork with privileged credentials.
5056

57+
The uploaded artifact holds both sides of the comparison, so a reader can reproduce it without resolving the merge base again:
58+
59+
| File | Contents |
60+
|---|---|
61+
| `analysis.json` | the head analysis, at `head_sha` |
62+
| `base_analysis.json` | the analysis it was compared against, at `merge_base_sha` |
63+
| `metadata.json` | both SHAs, `merge_base_resolved`, `seed_source`, `chain_depth`, PR number |
64+
65+
Artifacts are kept 30 days. Reading the default branch's committed baseline instead of `base_analysis.json` would drift from the merge base in exactly the way described above.
66+
67+
### Reused analysis
68+
69+
Each review seeds the head analysis from this pull request's own previous run, so a run only covers the commits pushed since it. With no previous run, it seeds from the merge base's analysis. `sync` mode publishes that entry on the base branch, where every pull request can restore it; an entry a review run computes for itself is scoped to that pull request. Both live in the GitHub Actions cache, and state is re-derived from the merge base whenever the pinned CodeBoarding version, `.codeboardingignore`, the configured analysis depth, or the merge base itself changes. State produced while analyzing a fork is namespaced separately and is never restored by a run on this repository's own code.
70+
71+
Caching is best-effort: a cache miss, an unavailable cache service, or a GitHub Enterprise Server without one falls back to analyzing the merge base directly, exactly as before.
72+
73+
Actions cache entries are scoped to the ref that wrote them. Automatic `pull_request` runs therefore reuse each other's analysis and the shared base entry, while a `/codeboarding` command — which runs on the default branch ref — reuses the base entry but not a chain built by automatic runs, so it costs one base-seeded incremental. The action also accepts `pull_request_target`, which runs on the base branch ref and lets both share one chain; that trigger has its own trade-offs (a PR that adds this workflow will not run it until merged, and the fork gate becomes load-bearing), so `pull_request` remains the recommended default.
74+
5175
## Authentication and providers
5276

5377
With no LLM inputs, the action uses CodeBoarding's hosted OpenRouter tier. It mints short-lived GitHub OIDC credentials per request, so the job needs `id-token: write` and no stored LLM secret.
@@ -197,6 +221,8 @@ The `/codeboarding` command, comment heading, Mermaid direction (`LR`), hosted w
197221
| `n_changed` | review | Number of changed components. |
198222
| `truncated` | review | Whether the graph was reduced to fit GitHub limits. |
199223
| `review_artifact_url` | review | URL of the uploaded head analysis. |
224+
| `seed_source` | review | `pr-chain` when the head grew from this PR's previous analysis, `base` otherwise. |
225+
| `merge_base_sha` | review | Merge base used as the comparison baseline. |
200226
| `analysis_mode` | sync | `incremental` or `full`. |
201227
| `files_written` | sync | Number of persisted analysis artifacts produced. |
202228
| `committed` | sync | Whether a baseline commit was delivered. |

‎action.yml‎

Lines changed: 112 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ outputs:
6262
review_artifact_url:
6363
description: 'URL of the uploaded review analysis artifact.'
6464
value: ${{ steps.upload_review_artifact_dotcom.outputs.artifact-url }}
65+
seed_source:
66+
description: 'Which state the review head analysis grew from: pr-chain or base.'
67+
value: ${{ steps.review_analyze.outputs.seed_source }}
68+
merge_base_sha:
69+
description: 'Merge base used as the review comparison baseline.'
70+
value: ${{ steps.guard.outputs.merge_base_sha }}
6571
analysis_mode:
6672
description: 'Whether sync used incremental or full analysis.'
6773
value: ${{ steps.sync_analyze.outputs.analysis_mode }}
@@ -102,6 +108,7 @@ runs:
102108
EVENT_PR_NUMBER: ${{ github.event.pull_request.number }}
103109
PULL_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
104110
PULL_BASE_SHA: ${{ github.event.pull_request.base.sha }}
111+
PULL_BASE_REF: ${{ github.event.pull_request.base.ref }}
105112
PULL_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
106113
PULL_BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
107114
REPOSITORY: ${{ github.repository }}
@@ -166,6 +173,50 @@ runs:
166173
LICENSE_KEY: ${{ inputs.license_key }}
167174
run: "$GITHUB_ACTION_PATH/scripts/action/configure-auth.sh"
168175

176+
- name: Resolve analysis cache keys
177+
id: cache_keys
178+
if: steps.guard.outputs.skip != 'true'
179+
continue-on-error: true
180+
shell: bash
181+
env:
182+
CHECKOUT_DIR: ${{ github.workspace }}/.codeboarding-target
183+
MERGE_BASE_SHA: ${{ steps.guard.outputs.merge_base_sha }}
184+
PR_NUMBER: ${{ steps.guard.outputs.pr_number }}
185+
HEAD_SHA: ${{ steps.guard.outputs.head_sha }}
186+
HEAD_REPO: ${{ steps.guard.outputs.head_repo }}
187+
IS_FORK: ${{ steps.guard.outputs.is_fork }}
188+
SEED_MODE: ${{ steps.guard.outputs.seed_mode }}
189+
LLM_PROVIDER: ${{ inputs.llm_provider }}
190+
MODEL: ${{ inputs.model }}
191+
AGENT_MODEL_INPUT: ${{ inputs.agent_model }}
192+
PARSING_MODEL_INPUT: ${{ inputs.parsing_model }}
193+
run: "$GITHUB_ACTION_PATH/scripts/action/cache-keys.sh"
194+
195+
# An exact key is this merge base's own analysis; the prefix falls back to
196+
# the newest baseline any run produced, which still warm-starts the catch-up.
197+
- name: Restore base analysis
198+
id: base_cache
199+
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review' && steps.cache_keys.outputs.base_key != ''
200+
continue-on-error: true
201+
uses: actions/cache/restore@v4
202+
with:
203+
path: ${{ runner.temp }}/cb-cache/base
204+
key: ${{ steps.cache_keys.outputs.base_key }}
205+
restore-keys: ${{ steps.cache_keys.outputs.base_restore_keys }}
206+
207+
# Looked up by prefix alone, because what a run must continue from is this
208+
# pull request's newest analysis. An exact head-sha key would outrank a
209+
# newer generation saved for the same head, so the entry a forced refresh
210+
# replaced would win and undo the refresh.
211+
- name: Restore pull request analysis
212+
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review' && steps.guard.outputs.seed_mode == 'chain' && steps.cache_keys.outputs.chain_key != ''
213+
continue-on-error: true
214+
uses: actions/cache/restore@v4
215+
with:
216+
path: ${{ runner.temp }}/cb-cache/chain
217+
key: ${{ steps.cache_keys.outputs.chain_restore_keys }}
218+
restore-keys: ${{ steps.cache_keys.outputs.chain_restore_keys }}
219+
169220
- name: Analyze baseline
170221
id: sync_analyze
171222
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'sync'
@@ -174,6 +225,7 @@ runs:
174225
ACTION_PATH: ${{ github.action_path }}
175226
ANALYSIS_KIND: sync
176227
CHECKOUT_DIR: ${{ github.workspace }}/.codeboarding-target
228+
CACHE_OUT_DIR: ${{ runner.temp }}/cb-cache
177229
FORCE_FULL: ${{ inputs.force_full }}
178230
MODEL: ${{ inputs.model }}
179231
AGENT_MODEL_INPUT: ${{ inputs.agent_model }}
@@ -199,6 +251,26 @@ runs:
199251
REPOSITORY: ${{ github.repository }}
200252
run: "$GITHUB_ACTION_PATH/scripts/action/deliver-sync.sh"
201253

254+
# Keyed by the commit pull requests will branch from, so their merge base
255+
# hits this entry exactly and they skip the base analysis entirely.
256+
- name: Save baseline analysis
257+
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'sync' && steps.sync_commit.outputs.baseline_sha != '' && steps.cache_keys.outputs.base_key_prefix != ''
258+
continue-on-error: true
259+
uses: actions/cache/save@v4
260+
with:
261+
path: ${{ runner.temp }}/cb-cache/base
262+
key: ${{ steps.cache_keys.outputs.base_key_prefix }}${{ steps.sync_commit.outputs.baseline_sha }}
263+
264+
# The same state under the commit that was analyzed. A pull request branched
265+
# before this run's baseline commit landed has that commit as its merge base.
266+
- name: Save baseline analysis for the analyzed commit
267+
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'sync' && steps.sync_commit.outputs.analyzed_sha != '' && steps.sync_commit.outputs.analyzed_sha != steps.sync_commit.outputs.baseline_sha && steps.cache_keys.outputs.base_key_prefix != ''
268+
continue-on-error: true
269+
uses: actions/cache/save@v4
270+
with:
271+
path: ${{ runner.temp }}/cb-cache/base
272+
key: ${{ steps.cache_keys.outputs.base_key_prefix }}${{ steps.sync_commit.outputs.analyzed_sha }}
273+
202274
- name: Write sync summary
203275
if: always() && steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'sync'
204276
shell: bash
@@ -218,16 +290,44 @@ runs:
218290
ACTION_PATH: ${{ github.action_path }}
219291
ANALYSIS_KIND: review
220292
CHECKOUT_DIR: ${{ github.workspace }}/.codeboarding-target
221-
REVIEW_BASE_SHA: ${{ steps.guard.outputs.base_sha }}
293+
REVIEW_BASE_SHA: ${{ steps.guard.outputs.merge_base_sha }}
222294
REVIEW_HEAD_SHA: ${{ steps.guard.outputs.head_sha }}
223295
REVIEW_BASE_REPO: ${{ steps.guard.outputs.base_repo }}
296+
PR_NUMBER: ${{ steps.guard.outputs.pr_number }}
297+
SEED_MODE: ${{ steps.guard.outputs.seed_mode }}
298+
CACHE_BASE_DIR: ${{ runner.temp }}/cb-cache/base
299+
CACHE_BASE_HIT: ${{ steps.base_cache.outputs.cache-hit }}
300+
CACHE_CHAIN_DIR: ${{ runner.temp }}/cb-cache/chain
301+
CACHE_OUT_DIR: ${{ runner.temp }}/cb-cache
302+
ENGINE_VERSION: ${{ steps.cache_keys.outputs.engine_version }}
303+
CFG_HASH: ${{ steps.cache_keys.outputs.cfg_hash }}
224304
GIT_TOKEN: ${{ inputs.github_token }}
225305
GITHUB_SERVER_URL: ${{ github.server_url }}
226306
MODEL: ${{ inputs.model }}
227307
AGENT_MODEL_INPUT: ${{ inputs.agent_model }}
228308
PARSING_MODEL_INPUT: ${{ inputs.parsing_model }}
229309
run: '"$GITHUB_ACTION_PATH/scripts/action/with-auth.sh" "$GITHUB_ACTION_PATH/scripts/action/analyze.sh"'
230310

311+
# Saved before the review is rendered: the analysis is the expensive part, so
312+
# a later rendering or posting failure must not throw it away.
313+
- name: Save pull request analysis
314+
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review' && steps.cache_keys.outputs.chain_key != ''
315+
continue-on-error: true
316+
uses: actions/cache/save@v4
317+
with:
318+
path: ${{ runner.temp }}/cb-cache/chain
319+
key: ${{ steps.cache_keys.outputs.chain_key }}
320+
321+
# Only trusted runs publish a base entry: it is restorable repository-wide,
322+
# so a fork's run must never be able to place state there.
323+
- name: Save base analysis
324+
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review' && steps.review_analyze.outputs.save_base == 'true' && steps.guard.outputs.is_fork != 'true' && steps.cache_keys.outputs.base_key != ''
325+
continue-on-error: true
326+
uses: actions/cache/save@v4
327+
with:
328+
path: ${{ runner.temp }}/cb-cache/base
329+
key: ${{ steps.cache_keys.outputs.base_key }}
330+
231331
- name: Render review diagram
232332
id: review_render
233333
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review'
@@ -244,10 +344,15 @@ runs:
244344
shell: bash
245345
env:
246346
ANALYSIS_PATH: ${{ steps.review_analyze.outputs.analysis_path }}
347+
BASE_ANALYSIS_PATH: ${{ steps.review_analyze.outputs.base_analysis_path }}
247348
ANALYSIS_MODE: ${{ steps.review_analyze.outputs.analysis_mode }}
248349
BASE_SHA: ${{ steps.guard.outputs.base_sha }}
350+
MERGE_BASE_SHA: ${{ steps.guard.outputs.merge_base_sha }}
351+
MERGE_BASE_RESOLVED: ${{ steps.guard.outputs.merge_base_resolved }}
249352
HEAD_SHA: ${{ steps.guard.outputs.head_sha }}
250353
PR_NUMBER: ${{ steps.guard.outputs.pr_number }}
354+
SEED_SOURCE: ${{ steps.review_analyze.outputs.seed_source }}
355+
CHAIN_DEPTH: ${{ steps.review_analyze.outputs.chain_depth }}
251356
run: "$GITHUB_ACTION_PATH/scripts/action/build-review-artifact.sh"
252357

253358
- name: Upload review artifact
@@ -258,6 +363,9 @@ runs:
258363
name: codeboarding-review-${{ github.run_id }}-${{ github.run_attempt }}
259364
path: ${{ steps.review_artifact.outputs.artifact_dir }}
260365
if-no-files-found: error
366+
# Each run carries its own copy of the base graph, and the webview only
367+
# ever reads a pull request's latest artifact, so value drops off fast.
368+
retention-days: 30
261369

262370
- name: Build review comment
263371
id: review_body
@@ -268,6 +376,9 @@ runs:
268376
N_CHANGED: ${{ steps.review_render.outputs.n_changed }}
269377
ARTIFACT_URL: ${{ steps.upload_review_artifact_dotcom.outputs.artifact-url }}
270378
PR_NUMBER: ${{ steps.guard.outputs.pr_number }}
379+
BEHIND_BY: ${{ steps.guard.outputs.behind_by }}
380+
BASE_REF: ${{ steps.guard.outputs.base_ref }}
381+
MERGE_BASE_RESOLVED: ${{ steps.guard.outputs.merge_base_resolved }}
271382
run: "$GITHUB_ACTION_PATH/scripts/action/build-review-comment.sh"
272383

273384
- name: Post review comment

0 commit comments

Comments
 (0)