Skip to content

fix(refs): name the settled diff in the plain-ref refusal and issue its replacement refs - #5037

Merged
thymikee merged 1 commit into
callstack:mainfrom
strzhao:forge/settle-ref-replacements
Nov 23, 2026
Merged

thymikee merged 1 commit into
callstack:mainfrom
strzhao:forge/settle-ref-replacements

Conversation

@strzhao

@strzhao strzhao commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The #4571 follow-up slice: when a plain ref is refused because a --settle diff replaced the ref frame, the refusal names the settled diff as the replacement and issues replacement refs from the settle-diff frame (#4853's "replacement ref, ready to copy" standard). Explicit non-goal: ref-lifetime semantics — whether refs the diff left unchanged stay valid stays open on the issue. Command-surface change: new refusal text and additive error details; ADR 0014 amended. The frame value now records a bounded issuance origin; only the settle path passes settle-diff, so find, audit, replay divergence, and ambiguity refusals keep their shape. No heuristics: the list is exactly the settle frame's issued scope, pinned to the frame epoch; origin is diagnostic only — no admission or ref-lifetime change.

Before / after

fill @e3 … --settle; press @e4, @e4 from the earlier snapshot, settle frame scope {e34, e7}, epoch s531735 — real strings from the new tests:

before: Ref @e4 needs a complete snapshot — the current frame only authorizes its emitted refs
        hint: Capture a fresh interactive snapshot (snapshot -i) or use a stable selector, then retry.
after:  Ref @e4 needs a complete snapshot — a settled diff replaced the ref frame and only authorizes its issued refs
        hint: Retry with one of the refs the settled diff issued: @e34~s531735, @e7~s531735 — or capture a fresh interactive snapshot (snapshot -i).
        details: replacedBy "settle-diff"; replacementRefs ["@e34~s531735", "@e7~s531735"]

A no-ref settle frame keeps the recapture guidance; a refused body in scope keeps the existing suggestedRef refusal verbatim.

Validation

Head 5d948cc on upstream main 0d38f89.

  • Focused unit-core: 35 passed; broader daemon core/execution/sessions: 2,865 passed; command-output + kernel: 560 passed. pnpm tsc -b, pnpm format: pass.
  • pnpm check:affected --run: format, lint, typecheck pass; the local layering stage fails on pre-existing drift — detach control at the pinned base gives byte-identical violation lists, zero PR-introduced findings; eager-closure budgets fail identically at head and base, the known upstream-branch false positive.
  • No device run: refusal payloads and issuance provenance only.

Refs #4571

🤖 Generated with Claude Code

…ts replacement refs

After `fill @e3 … --settle; press @e4` with @E4 taken from the earlier full
snapshot, the plain-ref refusal offered nothing: the agent could not tell
that a settled diff replaced the frame and paid a full `snapshot -i` every
time (callstack#4571, the most common agent-blocking error in the dogfood data).

The frame value now records which publication minted it. `RefFrameOrigin`
(`complete` | `settle-diff` | `partial`) is set at issuance through the same
factories; every partial publication flows through one choke point
(`markSessionPartialRefsIssued`), and only the settle path
(`issueSettleRefs`) passes `settle-diff`, so find, audit, replay divergence,
and ambiguity issuances keep their refusal shape unchanged. Origin is
diagnostic only: no admission decision and no ref lifetime changes — whether
refs a diff left unchanged stay valid stays open for maintainers on callstack#4571.

When the refusing frame is settle-diff and the refused plain ref is not one
of its issued refs, the refusal:

- names the settled diff as the replacement in the message (and says when
  the diff issued no refs),
- carries `details.replacedBy: "settle-diff"` and
  `details.replacementRefs`, each issued ref pinned to the frame epoch in
  the ready-to-copy `@eN~s<epoch>` form (callstack#4853 paste-ready standard; the
  frame already authorized exactly these bodies, so printing them issues
  nothing new),
- offers the same refs in the hint with the fresh-snapshot escape.

The exact-emitted-ref suggestion keeps precedence when the refused body is
itself in scope. ADR 0014 amended (dated subsection beside the refusal
contract it extends).

Co-Authored-By: Claude Code <noreply@anthropic.com>
@strzhao
strzhao force-pushed the forge/settle-ref-replacements branch from 03426a6 to 5d948cc Compare November 23, 2026 16:38
@thymikee

Copy link
Copy Markdown
Member

Thanks for the clear fix. The PR is ready at 5d948cc: the change reads correctly and the 16 passing checks cover it. The only check that did not pass is Body rules, which was cancelled with no output. It lints PR title and body metadata, which this diff does not touch, so please re-run it before merge. No conflicts. Not verified here: unit tests, typecheck and layering were not re-run locally, and the Body rules job could not be inspected. No device run is needed, since the change alters refusal text and frame provenance, not dispatch, capture or admission.

Not blocking, and fine to take or leave: (1) a plain-ref read after a settle, such as get text @e4, is refused by unissuedRefReadError in session-snapshot.ts without replacedBy or replacementRefs, so every refusal caused by a settle-diff frame could share one helper, or this could be a follow-up issue; (2) replacementRefs is the whole settle scope, printed uncapped and unlabeled in interaction-ref-policy.ts, so would a cap on the hint list read better after a settle onto a new screen (not measured here); (3) the REF_FRAME_REASONS comment in ref-frame.ts feeds the generated reason row in error-reasons.md and does not mention details.replacementRefs; (4) the narration comments repeated across the touched files could shrink to the type-level doc on RefFrameOrigin, the ADR amendment is dated 2026-11-24, and the empty-scope refusal branch cannot fire in production.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 23, 2026
@thymikee
thymikee merged commit b3acd23 into callstack:main Nov 23, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants