Skip to content

Commit cf66577

Browse files
brovattenclaude
andauthored
fix: drop [skip ci] from bot commits so merges trigger sync; guard the loop without it (#31)
* fix: drop [skip ci] from bot commits so merges trigger sync; guard the loop without it The review bot's PR-branch commit message ('… update architecture analysis [skip ci]') leaks through squash-merges: GitHub folds it into the merge commit, and the [skip ci] then skips every push-triggered workflow on the merge — the sync run that should refresh the baseline from the *merged* code, release-please, and CI. So the committed baseline never reflects what actually merged. Fix: drop [skip ci] from both bot commit messages (review head-analysis and sync baseline), and replace its loop-prevention role with mechanisms that don't leak: - sync workflow paths-ignore (already present) — the primary guard; - a new action-side guard: sync skips a push whose head commit is authored by codeboarding[bot], so it never re-analyzes its own baseline commit even if a consumer omits paths-ignore; - the review commit now also skips on a timestamp-only diff (matching sync), so a synchronize-triggered re-run can't re-commit a fresh generated_at forever. Net: a merge to main reliably triggers a fresh incremental sync (and release-please fires again), while the regen loop stays closed. Docs updated to match. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: also ignore commit_hash in the review no-op-commit check Adversarial review caught that the timestamp-only skip didn't actually close the synchronize loop: analysis.json's metadata.commit_hash tracks the analyzed head SHA, so a synchronize re-run (whose head is our previous bot commit) changes it even when the architecture is identical — the diff stayed non-empty and re-committed forever. Ignore commit_hash too. Verified on real pretty-printed analysis.json: volatile-only diffs now skip, real component changes still commit (they live on different lines, so -I doesn't mask them). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 3168018 commit cf66577

3 files changed

Lines changed: 41 additions & 12 deletions

File tree

‎.github/workflows/codeboarding-sync.yml‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ name: CodeBoarding sync
1212
on:
1313
push:
1414
branches: [main]
15-
# Don't re-trigger on the files this workflow itself commits. Deliberately
16-
# NOT '.codeboarding/**': that would also swallow pushes that only edit the
17-
# user-authored .codeboarding/.codeboardingignore, which changes analysis
18-
# scope and should regenerate the baseline.
15+
# Loop guard: don't re-trigger on the files this workflow itself commits.
16+
# Deliberately NOT '.codeboarding/**': that would also swallow pushes that
17+
# only edit the user-authored .codeboarding/.codeboardingignore, which
18+
# changes analysis scope and should regenerate the baseline. The action also
19+
# skips re-analyzing its own bot commit as a backstop; the bot commit uses no
20+
# [skip ci] (that would leak through squash-merges and skip real merges).
1921
paths-ignore:
2022
- '.codeboarding/*.md'
2123
- '.codeboarding/analysis.json'

‎README.md‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,11 @@ name: CodeBoarding sync
170170
on:
171171
push:
172172
branches: [main]
173-
# Don't re-trigger on the files this workflow itself commits. Listed
174-
# explicitly (not '.codeboarding/**') so that editing your own
175-
# .codeboarding/.codeboardingignore still regenerates the docs.
173+
# Loop guard: don't re-trigger on the files this workflow itself commits.
174+
# Listed explicitly (not '.codeboarding/**') so that editing your own
175+
# .codeboarding/.codeboardingignore still regenerates the docs. (The action
176+
# also skips re-analyzing its own bot commit as a backstop, and deliberately
177+
# does NOT use [skip ci] — that would leak through squash-merges.)
176178
paths-ignore:
177179
- '.codeboarding/*.md'
178180
- '.codeboarding/analysis.json'
@@ -204,7 +206,7 @@ Behavior worth knowing:
204206
- The first run on a branch is a full analysis; subsequent runs reuse the committed baseline and run incrementally when they can (the `analysis_mode` output tells you which happened).
205207
- The commit is skipped when nothing meaningful changed (an empty diff, or only `generated_at`/timestamp fields). The push retries a few times with fetch+rebase and fails open, so a race with another push never fails your CI.
206208
- Tag pushes are skipped. `pull_request` events soft-skip in sync mode, so a mistakenly shared workflow can never push docs from a PR run.
207-
- The default `commit_message` ends in `[skip ci]`; keep the `paths-ignore` list above anyway, in case you customize the message or use a push token whose commits trigger workflows.
209+
- The bot commit carries **no `[skip ci]`** — on a squash-merge that marker leaks into the merge commit and would skip the very sync run (and release tooling, CI) the merge should trigger. The regen loop is instead prevented by the `paths-ignore` list above **and** by the action skipping re-analysis of its own bot commit, so a merge to `main` reliably triggers a fresh incremental sync.
208210
- `output_dir` is owned by the action: pre-existing top-level markdown files in it are deleted on every run (stale component pages must not linger). Don't point it at a directory with hand-written docs.
209211

210212
### How the two modes work together
@@ -251,7 +253,7 @@ Be aware that `contents: write` is repo-wide — GitHub does not scope it to a b
251253
| `output_format` | sync | `.md` | Output format. Only `.md` is supported. |
252254
| `target_branch` | sync | `${{ github.ref_name }}` | Branch the generated docs are pushed to. |
253255
| `write_architecture_md` | sync | `true` | Also write `docs/development/architecture.md`: all rendered pages concatenated, `overview.md` first. |
254-
| `commit_message` | sync | `chore(codeboarding): sync architecture baseline [skip ci]` | Commit message for the generated docs. |
256+
| `commit_message` | sync | `chore(codeboarding): sync architecture baseline` | Commit message for the generated docs. No `[skip ci]` (it would leak through squash-merges); the regen loop is guarded by `paths-ignore` + the action's own bot-commit check. |
255257
| `force_full` | sync | `false` | Ignore any committed baseline and run a full analysis from scratch. Use to rebuild a stale or corrupt baseline (e.g. from a `workflow_dispatch`). |
256258

257259
## Outputs

‎action.yml‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ inputs:
9191
required: false
9292
default: 'true'
9393
commit_message:
94-
description: 'Sync mode: commit message for the generated docs.'
94+
description: 'Sync mode: commit message for the generated docs. Deliberately carries no "[skip ci]" — the regen loop is prevented by the workflow''s paths-ignore plus the action''s own bot-commit guard, so the marker is unneeded and (via squash-merge) would skip the workflows real merges should run.'
9595
required: false
96-
default: 'chore(codeboarding): sync architecture baseline [skip ci]'
96+
default: 'chore(codeboarding): sync architecture baseline'
9797
force_full:
9898
description: 'Sync mode: ignore any committed baseline and run a full analysis from scratch. Use to rebuild a stale or corrupt baseline (the manual escape hatch that replaces the old refresh-baseline workflow).'
9999
required: false
@@ -161,6 +161,7 @@ runs:
161161
OUTPUT_FORMAT: ${{ inputs.output_format }}
162162
WRITE_ARCH: ${{ inputs.write_architecture_md }}
163163
DEPTH: ${{ inputs.depth_level }}
164+
HEAD_AUTHOR_EMAIL: ${{ github.event.head_commit.author.email }}
164165
run: |
165166
set -uo pipefail
166167
skip() { echo "::notice::$1 Skipping."; echo "skip=true" >> "$GITHUB_OUTPUT"; exit 0; }
@@ -189,6 +190,15 @@ runs:
189190
if [ "$EVENT" = "push" ] && [ "$REF_TYPE" = "tag" ]; then
190191
skip "Sync mode runs on branch pushes, not tag pushes."
191192
fi
193+
# Regen-loop guard: never re-analyze our OWN baseline commit. Sync
194+
# commits as codeboarding[bot]; if a push's head commit is ours, skip.
195+
# This holds even if a consumer omits the workflow's paths-ignore (the
196+
# primary guard), and replaces the old "[skip ci]" marker — which
197+
# leaked into squash-merge commit messages and wrongly skipped the
198+
# workflows real merges should run (sync itself, release tooling, CI).
199+
if [ "$EVENT" = "push" ] && [ "$HEAD_AUTHOR_EMAIL" = "codeboarding[bot]@users.noreply.github.com" ]; then
200+
skip "Push head commit is CodeBoarding's own baseline commit; not re-analyzing (loop guard)."
201+
fi
192202
case "$OUTPUT_FORMAT" in
193203
.md) ;;
194204
*) echo "::error::output_format must be .md."; exit 1 ;;
@@ -915,10 +925,25 @@ runs:
915925
echo "ready=true" >> "$GITHUB_OUTPUT" # already committed at this SHA → webview can read it
916926
exit 0
917927
fi
928+
# Same architecture, only volatile metadata differs: don't commit. The
929+
# ignored fields must cover EVERY per-run field, or the loop below stays
930+
# open: generated_at and the health timestamp, AND commit_hash — which
931+
# tracks the analyzed head SHA, so on a synchronize re-run (whose head IS
932+
# our previous bot commit) it changes even when the architecture didn't.
933+
# The bot commit carries no "[skip ci]" (it would leak through squash-
934+
# merges and skip real merges' workflows), so without ignoring all three
935+
# a synchronize-triggered re-run would re-commit a fresh SHA/timestamp
936+
# forever. ready=true: the analysis already committed serves the webview.
937+
if git diff --cached --quiet -I '"generated_at"' -I '"timestamp"' -I '"commit_hash"'; then
938+
git reset -q
939+
echo "::notice::Head analysis differs only in volatile metadata (timestamps/commit_hash); nothing to commit."
940+
echo "ready=true" >> "$GITHUB_OUTPUT"
941+
exit 0
942+
fi
918943
919944
git config user.name "codeboarding[bot]"
920945
git config user.email "codeboarding[bot]@users.noreply.github.com"
921-
git commit -m "chore(codeboarding): update architecture analysis [skip ci]" >/dev/null
946+
git commit -m "chore(codeboarding): update architecture analysis" >/dev/null
922947
923948
# Push to the PR head branch. The checkout used persist-credentials:false, so
924949
# authenticate the push explicitly with the workflow token (same-repo only).

0 commit comments

Comments
 (0)