Skip to content

fix(localization): authenticate and replay terminal evidence#331

Open
zzet wants to merge 5 commits into
mainfrom
fix/localization-terminal-evidence-replay-minimal-indexed
Open

fix(localization): authenticate and replay terminal evidence#331
zzet wants to merge 5 commits into
mainfrom
fix/localization-terminal-evidence-replay-minimal-indexed

Conversation

@zzet

@zzet zzet commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • replay terminal localization evidence deterministically after answer_ready
  • authenticate one-shot terminal receipts against the session, tool-use ID, and tool name; reject forged, stale, and replayed receipts
  • distinguish advisory and hard terminal markers so trusted, sufficient evidence can stop graph navigation without blocking unrelated tools
  • preserve primary implementation candidates before relation interleaving, filter unrelated relation rows, and recover unique complementary evidence
  • render one ordered LOCALIZATION tuple list so FILES, SYMBOLS, and EVIDENCE retain the same positional identity
  • add a non-terminal localized completion for a strictly qualified single implementation result, telling the model that localization is complete while keeping coding, build, test, and navigation tools available
  • add focused event, hook, receipt, recovery, replay, ordering, stale-context, continuation, and race coverage

Validation

Current head:

  • go test -p=1 ./internal/... -count=1
  • go test ./internal/mcp ./internal/hooks -count=1
  • go test -race ./internal/mcp ./internal/hooks -run '(Localization|Terminal|Recovery|Refinement|AnswerReady|Digest|Localized)' -count=1
  • go vet ./internal/mcp ./internal/hooks
  • golangci-lint run
  • git diff --check

All commands passed. In particular, the event/hook tests that previously failed are green.

Measured N=1 benchmark

Run label: terminal-replay-v14-restored-sweep-n1-055f35e2

Measured executable SHA-256: 055f35e2db651f4f155ded051f11d5166598739a703ba9429a8a7b00c3ee5e2a

Metric Result Acceptance Status
File hit 26/28 = 92.9% >=94% fail by 1 task
Symbol hit 22/28 = 78.6% >=81% fail by 1 task
Median cost $0.114334 <=$0.089 fail
Median tokens 63,602 <=77k pass
Cross-check 3/28 = 10.7% <35% pass
Evidence 28/28 = 100% pass

Compared with the previous full PR measurement:

Metric Previous Current Change
File hit 24/28 26/28 +2 tasks
Symbol hit 20/28 22/28 +2 tasks
Median cost $0.118095 $0.114334 -$0.003761
Median tokens 63,052 63,602 +550
Cross-check 8/28 3/28 -5 tasks

This table is the last completed benchmark, not a benchmark of the current head. The current head contains the measured implementation, behavior-neutral lint cleanups, and the behavioral follow-up described below. Its executable is therefore not byte-for-byte the measured binary.

Non-blocking single-result follow-up

The current head deliberately does not broaden answer_ready. When the existing sufficiency check passes and the bounded direct result contains exactly one hydrated production callable, with no quoted-literal or artifact-terminal path involved, explore now emits:

  • state: localized
  • terminal: false
  • enforceable: false
  • required action: continue_task

The instruction says that the indexed localization pass is complete for the request, that its bounded evidence contains exactly one supported primary production implementation candidate and no competing direct candidate, and that the model should continue the requested coding work with that result.

This state is never armed as a terminal session state, publishes no authentication receipt, creates no hook marker, and does not gate another tool. Search, read, relations, trace, analysis, edit, change, refactor, shell builds, and tests remain available. The session state also normalizes any attempted future localized arm back to open as defense in depth.

Multiple candidates, uncertain/refinement results, quoted-literal recall, artifact terminality, and existing hard-terminal flows retain their prior behavior.

This follow-up is not benchmarked yet. It is intended to reduce unnecessary model distrust through truthful wording without blocking real coding sessions; no cost or acceptance improvement is claimed for the new head until another N=1 run is completed.

Remaining acceptance work

Based on the last measured binary, accuracy is one task short in both dimensions. The smallest general correction is to preserve the enclosing production constructor/initializer as the primary owner when a task-aligned compact literal appears in a registration call; this directly addresses the remaining humanizer-1059 miss without widening generic recovery.

Cost remains the largest measured gap. The earlier projection based on broadening answer_ready is intentionally superseded by the non-blocking design above because hard terminality is unsuitable for real coding sessions. The next benchmark must determine how often the wording alone avoids redundant localization calls and whether a further non-terminal confidence signal is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant