You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5ea3fba
Browse filesBrowse the repository at this point in the historyBrowse 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>
Copy file name to clipboardExpand all lines: README.md
+28-2Lines changed: 28 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
One GitHub Action with two modes:
4
4
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.
6
6
-**`sync`** updates the versioned analysis state used by future incremental runs. It can push directly or open one rolling PR for protected branches.
7
7
8
8
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:
44
44
45
45
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.
46
46
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.
48
54
49
55
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.
50
56
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
+
51
75
## Authentication and providers
52
76
53
77
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
197
221
| `n_changed` | review | Number of changed components. |
198
222
| `truncated` | review | Whether the graph was reduced to fit GitHub limits. |
199
223
| `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. |
200
226
| `analysis_mode` | sync | `incremental` or `full`. |
201
227
| `files_written` | sync | Number of persisted analysis artifacts produced. |
202
228
| `committed` | sync | Whether a baseline commit was delivered. |
0 commit comments