Skip to content

Commit 7339fbf

Browse files
fix: compare review diagrams against target baseline (#39)
* feat: auto-detect depth_level from committed baseline When depth_level input is empty (new default), the action reads metadata.depth_level from the committed .codeboarding/analysis.json: - sync mode: from the working-tree checkout - review mode: from the PR base SHA via git show Falls back to 2 when no baseline exists or the field is missing. An explicit depth_level input always overrides auto-detection. * fix: compare review diagrams against target baseline Amp-Thread-ID: https://ampcode.com/threads/T-019ed0f0-d9f9-75da-a034-cbfda2dcd6d1 Co-authored-by: Amp <amp@ampcode.com> * fix: recreate broken cached uv venv before install Amp-Thread-ID: https://ampcode.com/threads/T-019ed0f0-d9f9-75da-a034-cbfda2dcd6d1 Co-authored-by: Amp <amp@ampcode.com> * fix: stop caching uv virtualenv Amp-Thread-ID: https://ampcode.com/threads/T-019ed0f0-d9f9-75da-a034-cbfda2dcd6d1 Co-authored-by: Amp <amp@ampcode.com> * Small changes in wording so it is clearer. * fix: move engine adapter imports to module scope Amp-Thread-ID: https://ampcode.com/threads/T-019edb41-a138-74fd-8544-fb4699a065bf Co-authored-by: Amp <amp@ampcode.com> --------- Co-authored-by: Amp <amp@ampcode.com>
1 parent d00f04a commit 7339fbf

9 files changed

Lines changed: 362 additions & 124 deletions

README.md

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

33
One action, two modes: architecture review on every pull request, and a versioned, always-current architecture baseline on your main branch.
44

5-
- **`mode: review`** (the default) — CodeBoarding analyzes your architecture before and after a change, comments on the PR with an inline Mermaid diagram and hosted webview link, and uploads the PR-head `analysis.json` plus base-commit metadata as a GitHub Actions artifact. It never commits generated files to the PR branch. Runs on `pull_request` and `issue_comment`.
5+
- **`mode: review`** (the default) — CodeBoarding analyzes your architecture on the target branch and PR branch, comments on the PR with an inline Mermaid diagram and hosted webview link, and uploads the PR-head `analysis.json` plus target-branch metadata as a GitHub Actions artifact. It never commits generated files to the PR branch. Runs on `pull_request` and `issue_comment`.
66
- **`mode: sync`** — CodeBoarding keeps your architecture analysis versioned and current on your branch: on every push it commits the `analysis.json` baseline, `static_analysis.pkl` cache pair, health report, and readable markdown (`.codeboarding/*.md`), so reviews diff against your current architecture and your architecture has real git history. Runs on `push`, `workflow_dispatch`, and `schedule`. See [sync mode](#keep-your-architecture-versioned-sync-mode).
77

88
Both modes run the [CodeBoarding](https://github.com/CodeBoarding/CodeBoarding) engine in CI: static analysis combined with LLM reasoning. They are designed to be used together — [sync mode keeps the baseline fresh that review mode diffs against](#how-the-two-modes-work-together) — but each works on its own.
@@ -20,10 +20,10 @@ Both modes run the [CodeBoarding](https://github.com/CodeBoarding/CodeBoarding)
2020

2121
## What review mode does
2222

23-
- Builds or reuses a baseline architecture analysis for the PR base.
23+
- Builds or reuses a baseline architecture analysis for the target branch tip the PR is opened against.
2424
- Runs incremental analysis on the PR head, then diffs components and relationships.
2525
- Posts a sticky PR comment with an inline Mermaid map. Green is added, yellow is modified, red (dashed) is deleted, for both nodes and edges.
26-
- Uploads the PR-head `analysis.json` plus base-commit metadata as a GitHub Actions artifact and links the hosted webview to that artifact instead of committing generated files to the PR branch.
26+
- Uploads the PR-head `analysis.json` plus target-branch metadata as a GitHub Actions artifact and links the hosted webview to that artifact instead of committing generated files to the PR branch.
2727

2828
A PR comment looks like this:
2929

@@ -234,7 +234,9 @@ Behavior worth knowing:
234234

235235
### How the two modes work together
236236

237-
Sync mode keeps the committed `.codeboarding/analysis.json` baseline fresh on main. Review mode reuses that committed baseline for the PR base, so PR reviews diff against your *current* main architecture and run incrementally instead of rebuilding a base from scratch — faster and cheaper per PR.
237+
Sync mode keeps the committed `.codeboarding/analysis.json` baseline fresh on main. Review mode reuses that committed baseline from the target branch tip, so PR reviews diff against your *current* main architecture and run incrementally instead of rebuilding the target analysis from scratch — faster and cheaper per PR.
238+
239+
For fork PRs, review mode compares the PR branch against the fork's branch with the same name as the PR target branch. For example, a PR opened into `upstream/main` from `alice:feature` compares `alice:main` to `alice:feature` when `alice:main` exists. If the fork comparison branch has no committed `.codeboarding/analysis.json`, review mode uses an empty baseline and renders the PR architecture as newly added instead of silently comparing against upstream's baseline.
238240

239241
Leave `depth_level` empty unless you are choosing the depth for a first run or an intentional `force_full` rebuild. After a baseline exists, the committed `analysis.json` records the depth the engine should continue using, so review and sync mode do not need duplicate depth-selection logic.
240242

@@ -272,7 +274,7 @@ Review mode does not need `contents: write`: PR-specific generated files are sto
272274
| `comment_header` | review | `Architecture review` | Heading for the PR comment. |
273275
| `trigger_command` | review | `/codeboarding` | Slash command for trusted on-demand runs. |
274276
| `cta_base_url` | review | empty | Click-proxy base URL: deep-links the editor link into VS Code/Cursor and adds a "get the extension" link (tracks owner/repo/pr). Empty links to the extension listing instead (GitHub strips `vscode:`/`cursor:` from comments). |
275-
| `webview_base_url` | review | `https://app.codeboarding.org` | Hosted webview base URL. The PR comment links to an artifact-backed head-vs-base architecture diff. Set empty to disable the browser link. |
277+
| `webview_base_url` | review | `https://app.codeboarding.org` | Hosted webview base URL. The PR comment links to an artifact-backed head-vs-comparison-branch architecture diff. Set empty to disable the browser link. |
276278
| `output_dir` | sync | `.codeboarding` | Directory the rendered docs and analysis metadata are committed to. Owned by the action: pre-existing top-level `.md` files in it are deleted on every run. |
277279
| `output_format` | sync | `.md` | Output format. Only `.md` is supported. |
278280
| `target_branch` | sync | `${{ github.ref_name }}` | Branch the generated docs are pushed to. |
@@ -287,7 +289,7 @@ Review mode does not need `contents: write`: PR-specific generated files are sto
287289
| `diagram_md` | review | Path to the generated Mermaid markdown block on the runner. |
288290
| `n_changed` | review | Number of changed components, counted recursively. |
289291
| `truncated` | review | `true` when the graph was reduced to fit GitHub Mermaid limits. |
290-
| `review_artifact_url` | review | GitHub Actions artifact URL containing the PR-head `analysis.json` and base-commit metadata. |
292+
| `review_artifact_url` | review | GitHub Actions artifact URL containing the PR-head `analysis.json` and comparison-branch metadata. |
291293
| `analysis_mode` | sync | `full` or `incremental`: whether the run rebuilt the analysis from scratch or reused the committed baseline. |
292294
| `files_written` | sync | The generated files written for the docs commit. |
293295
| `committed` | sync | `true` when a docs commit was pushed to `target_branch`; `false` when sync mode ran but had nothing to commit (or the push failed open). Empty only if sync mode did not run. |

0 commit comments

Comments
 (0)