fix(context-recovery): look up <branch>-reviews.jsonl with the canonical slug form, not the raw branch (#1127)#1851
Conversation
…cal slug form, not the raw branch (garrytan#1127) The Context Recovery preamble block reported "REVIEWS: N entries" by probing `$_PROJ/${_BRANCH}-reviews.jsonl`, where `$_BRANCH` is the raw `git branch --show-current`. But gstack-review-log (writer) and gstack-review-read (reader) both name that file with the *sanitized* slug form from `gstack-slug` (`$BRANCH`, restricted to [a-zA-Z0-9._-]). For any slashed branch — the conventional `feat/*`, `fix/*`, `chore/*` — the two disagree (`feat/foo` → `feat/foo` vs `featfoo`), so the review count for the current branch was never found. ($_BRANCH is also not even defined inside this self-contained block, so the lookup was doubly fragile.) Route the review lookup through `$BRANCH` (already in scope from the block's `eval gstack-slug`), matching how reviews are actually written and read. The timeline.jsonl greps keep using raw `$_BRANCH`, because timeline records the raw branch in its `branch` field — documented inline in the generator so the two forms don't get conflated again. Deliberately scoped: this converges the one remaining straggler onto the existing canonical sanitizer (gstack-slug). It does not change gstack-slug's output form, so there is no on-disk migration and no conflict with the in-flight gstack-slug work. Changing the canonical form itself (strip → dash for readability, per the issue) is an orthogonal, migration-bearing decision left to the maintainer. Edited the source-of-truth generator (scripts/resolvers/preamble/generate-context-recovery.ts); regenerated all SKILL.md via `bun run gen:skill-docs` (idempotent). Added test/regression-1127-context-recovery-branch-form.test.ts pinning both halves. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
❌ This pull request has been removed from the merge queue because required statuses are not defined in
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
Independently reviewed against current
Collision check: no competing open PR (#1621 also touches the context-recovery block but only its slug-derivation, unrelated to the reviews-filename form). Regression test |
|
/trunk merge |
|
These look ready from my side — the branch is clean/mergeable and an independent review confirmed the fix is correct and complete. The only red check is the Trunk merge-queue gate, which from what I can tell just needs a maintainer to enqueue it (no code/test failure). @garrytan whenever you have a moment, could these be added to the merge queue? Happy to rebase if anything is needed. Thanks! |
Summary
The Context Recovery preamble block (present in every skill) reports
REVIEWS: N entriesby probing$_PROJ/${_BRANCH}-reviews.jsonl, where$_BRANCHis the rawgit branch --show-current. Butgstack-review-log(writer) andgstack-review-read(reader) both name that file with the sanitized slug form fromgstack-slug($BRANCH, restricted to[a-zA-Z0-9._-]).For any slashed branch — the conventional
feat/*,fix/*,chore/*— the two forms disagree (feat/foo→feat/foovsfeatfoo), so the current branch's review count was never found. ($_BRANCHisn't even defined inside this self-contained block, making the lookup doubly fragile.)Closes #1127.
Audit of every
*-reviews.jsonlaccessbin/gstack-review-log$BRANCHviagstack-slug(strip)bin/gstack-review-read$BRANCHviagstack-slug(strip)ship/SKILL.md.tmpl$BRANCHviagstack-slug(strip)$_BRANCHspecialist-stats,retro,artifacts-init*globSo on current
mainthe writers and reader already agree on thegstack-slugform — the Context Recovery existence check was the sole straggler.Fix
Route the review lookup through
$BRANCH(already in scope from the block'seval gstack-slug), matching how reviews are written and read. Thetimeline.jsonlgreps keep using raw$_BRANCH— timeline records the raw branch in itsbranchfield — and the generator now documents the two-form convention inline so they don't get conflated again.Edited the source-of-truth generator
scripts/resolvers/preamble/generate-context-recovery.ts; regenerated all SKILL.md viabun run gen:skill-docs(idempotent — the per-skill diff is exactly the one review line).Scope
Deliberately converges the one remaining straggler onto the existing canonical sanitizer (
gstack-slug). It does not changegstack-slug's output form, so there's no on-disk migration and no conflict with the in-flightgstack-slugPRs. Changing the canonical form itself (strip → dash for readability, as the issue suggests) is an orthogonal, migration-bearing decision left to the maintainer — now a one-line change in a single function.Tests
test/regression-1127-context-recovery-branch-form.test.tspins both halves (reviews →$BRANCH, timeline greps →$_BRANCH) for bothclaudeandcodexhosts. Green together withpreamble-compose,review-log,gen-skill-docs,gen-skill-docs-idempotency,audit-compliance— 415 tests, 0 fail.🤖 Generated with Claude Code