Skip to content

fix(refinery): add Merge Bookkeeping section binding metadata to close#10

Open
eric-jones wants to merge 1 commit into
mainfrom
topic/refinery-merge-bookkeeping
Open

fix(refinery): add Merge Bookkeeping section binding metadata to close#10
eric-jones wants to merge 1 commit into
mainfrom
topic/refinery-merge-bookkeeping

Conversation

@eric-jones
Copy link
Copy Markdown
Owner

Fork-PR for review. Upstream: gastownhall#1935 (OPEN). Verification gap (substring-only tests); follow-up bead gc-rm0ha.49 schedules L5c rerun.

@eric-jones eric-jones force-pushed the topic/refinery-merge-bookkeeping branch from a1c7d73 to bbf1c97 Compare May 20, 2026 16:07
@eric-jones eric-jones force-pushed the topic/refinery-merge-bookkeeping branch 3 times, most recently from 7833908 to ba91ee3 Compare May 22, 2026 08:18
The refinery prompt had no "Merge Flow" quick reference paralleling its
"Rejection Flow" section. On a no-remote test rig (no `origin` configured),
the LLM refinery agent saw the formula's `merge-push` step assumed a
remote (`git fetch origin`, `git push origin $TARGET`) and bypassed it
entirely — using `git merge --ff-only temp` from the refinery's worktree
and then running only `gc bd close $WORK --reason "Merged to main at <sha>.
No remote; no push step."`. The `gc bd update --set-metadata merged_sha=...
merged_target=...` write that gastownhall#1886 chained into the close was skipped
along with everything else in the merge-push step. Closed work beads
ended up with `merged_sha=null` and `merged_target=null`, losing the
forensic breadcrumb tying a closed bead to its merge commit.

Reproduced on validate-l5-20260510-v4 (gascity local/integration
4d656c14): the cleanly-merged second L5c bead `vl2vr-le9` closed with
`metadata.merged_sha=null` and `metadata.merged_target=null` even though
main HEAD shows the merge commit `055fa36`. The refinery agent's
transcript shows it ran `git merge --ff-only gc-nux-03afa35551bd`
followed directly by `gc bd close vl2vr-le9 --reason="Merged...; No
remote; no push step."` — no metadata write between the merge and the
close.

This walks back the validation note on stg-a1st, which was filed as
fixed by gastownhall#1886 but only proven for L5a / L5b (where every merge was a
merge-commit, exercising the chained close). The L5c-shape case (one FF
merge + one rejection in the same iteration, on a no-remote rig)
exposed that the chain isn't sufficient when the LLM bypasses the
formula's merge-push flow upstream of the chain.

## What changed

- `examples/gastown/packs/gastown/agents/refinery/prompt.template.md` —
  added a new "Merge Bookkeeping" section after "Merge Strategy". Names
  two non-negotiable obligations on every merge: (a) `merged_sha` /
  `merged_target` MUST be written via `gc bd update --set-metadata`
  before `gc bd close`, regardless of remote presence or merge shape;
  (b) use `git update-ref refs/heads/$TARGET <sha>` (per the formula),
  not `git checkout $TARGET; git merge --ff-only temp`. Explicitly
  states that on rigs without a remote, the metadata write and the
  close still run — the local merge happened, the bead records it.

- `examples/gastown/gastown_test.go` —
  `TestRefineryPromptMergeBookkeepingBindsMetadataToClose` asserts the
  new section's load-bearing phrases are present, in order.

Surface: refinery merge metadata via `gc bd update --set-metadata`
(canonical bd CLI), shown in canonical agent prompt template; not
direct Dolt edits.

Fixes: stg-a1st (FF-shape merge + no-remote rig regression)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Upstream-PR: gastownhall#1935
@eric-jones eric-jones force-pushed the topic/refinery-merge-bookkeeping branch from ba91ee3 to a02594d Compare May 23, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant