Skip to content

fix(synthesis): only record rejected alternatives the input shows - #567

Merged
davesheffer merged 8 commits into
mainfrom
fix/synth-grounded-alternatives
Oct 29, 2026
Merged

davesheffer merged 8 commits into
mainfrom
fix/synth-grounded-alternatives

Conversation

@davesheffer

Copy link
Copy Markdown
Owner

Problem

In an audit of synthesized decisions on 30 merged open-source PRs, about two thirds of the confirmed errors sat in alternatives_rejected: with no guidance on that field, the model filled it with plausible options nobody considered. Those invented alternatives also seed draft tripwires (draftTripwires). Drafts whose commit body narrates earlier iterations (a squashed commit list or a PR description) had a second failure: they read a superseded proposal, or a review request the diff already satisfied, as the final state.

Change

  • alternatives_rejected now has a description: list only alternatives the input shows were considered and not taken (named in the commit/PR text, or code the diff replaces with a different approach to the same goal, not the defect being fixed); use [] otherwise.
  • commitPrompt ends with short evidence rules: the DIFF and STRUCTURED CHANGES are the merged state, a later dated message overrides an earlier proposal, a partial DIFF does not contradict text about code it does not show, a bug fixed during review is not a rejected alternative, and reasons are attributed only to someone the text shows giving them.

Prompt text only. No new provider or API path (con_2ce3f2a547); drafts stay advisory.

Evaluation

60 merged PRs: 30 open-source, 30 from private agent-authored repos. Gold design points extracted per PR; each draft judged by an adjudicating judge that must quote the input for every error it confirms. Only paired, same-run comparisons are reported, since re-judging identical drafts moves totals a lot.

Open-source (30) Private (30)
Commit-only drafts, confirmed errors 24 → 12 8 → 5
Commit-only drafts, design points conveyed 44.5 → 46.5 (of 165) 79.5 → 80.0 (of 185)

On the private set the error mix shifted: fabricated 6 → 0, contradicted 2 → 5 (small counts; 95% CI of the error ratio [0.17, 1.40]).

Drafts that also saw the PR description and review thread (not what the product feeds today; #563 adds the description): errors 40 → 9 open-source, 9 → 3 private. An ablation in one judge run isolated the evidence rules on those drafts: schema description alone vs. description plus rules, open-source errors 14 → 5 (contradicted claims 9 → 4), design points 133 → 129. On the private set the counts were too small to separate (2 → 4).

Smoke re-check of the final wording on 6 open-source PRs (same judge run for both arms): commit-only errors 11 → 2, design points 11.0 → 12.5 of 39; with PR context, errors 5 → 3, design points 35.0 → 34.5. Six PRs only confirm the direction, not the size.

Compatibility with open PRs

Trial-merged with #563 and #564 locally: only append conflicts (CHANGELOG, test imports, one synthBits line between #563 and #564 themselves). Combined tree: tsc --noEmit exit 0; provider, synthesis, cliproviders, ensemble, provider-selection, pr-context, integration-externals, private-capture, provider-exec: 137 pass, 0 fail, 1 pre-existing skip. Under #564 the new field description is rendered as plain words, which the new prompt test still covers.

Verification

  • npx tsc --noEmit: exit 0.
  • provider, synthesis, cliproviders, ensemble, provider-selection: 88/88.
  • New test asserts the rules and the alternatives contract reach the prompt, on both the normal and the large-diff path. With the rules removed from commitPrompt it fails.
  • An independent review returned ship-with-fixes; all six findings are fixed in the last commit.

🤖 Generated with Claude Code

davesheffer and others added 6 commits October 29, 2026 14:55
…hema (#561)

About 1 in 5 claude-cli commit drafts came back as the pasted JSON Schema
itself rather than an answer. decisionDraftFromText found no decision or
context, and draftDecisionSafe silently wrote the heuristic draft instead.
Concurrency was not the cause: sequential runs failed the same way.

- jsonInstruction describes each key in plain words and asks for the
  filled-in object, so there is no schema left to echo.
- Unusable output throws UnusableOutputError with a classified reason
  (echoed the schema / no JSON object / missing fields), never the raw text.
- The safe wrappers take one more sample on that error only; timeouts and
  CLI failures are not retried.
- syncCommit returns fallbackReason; backfill flags each fallen-back commit
  and counts them apart from the commits the significance gate sent to the
  heuristic, and sync prints the reason.

Live check on 90 claude-cli drafts at 4 workers: 17 fallbacks before, 0 after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The decision schema gave alternatives_rejected no guidance, so drafts
filled it with plausible but invented options; those also scaffold
tripwires. Describe the field: list only alternatives named in the
commit/PR text or visible as removed/replaced code, say where each came
from, use [] when none, and never list the old behaviour being fixed.

Measured on 30 merged OSS PRs (blinded judge with the diff): commit-only
drafts went from 58 to 34 errors, conveyed design points 53 -> 55;
alternatives listed 50 -> 12.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…print it

Review follow-up for #561. The post-commit hook runs sync quietly, so the
printed reason never reached the path where the fallback was seen. The
decision's synth: evidence now carries fallback=<kind> (echoed-schema,
no-json, empty, missing-fields or provider-error), which hunch review shows.

The --deep ensemble keeps the first worker's cause in its error message. It
stays a plain Error so the safe wrapper does not re-run every sample.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Commit and PR text can narrate superseded proposals and review requests
the diff already satisfied; most contradicted claims in PR-context drafts
came from reading those as the final state. Add evidence rules to the
commit prompt: follow the diff where text disagrees, a later message
overrides an earlier proposal, no review state, a bug fixed in review is
not a rejected alternative, keep attribution direction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- alternatives_rejected: count only code the diff replaces with a different
  approach to the same goal, not the defect being fixed; drop the per-entry
  provenance note, which broke exact-string dedup and fed tripwire symbols.
- The DIFF and STRUCTURED CHANGES are the merged state; a partial DIFF does
  not contradict text about code it does not show (large-diff path).
- Drop the oldest-to-newest claim: a squashed commit list may run either way.
- CHANGELOG claims only what commit drafts receive today.
- Test that the rules and the alternatives contract reach the prompt,
  including on the large-diff path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hunch Ready Ready Preview Oct 29, 2026 5:06pm UTC

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Hunch — Engineering Memory Guard

⛔ Invariants directly in scope

  • [warning] The agent hook must never block an edit on failure: any error exits 0 and never denies; after the event is recognized it emits at most one 'grounding unavailable' context line, unrecognized input emits nothing — con_03a0b94b2e
    • in: src/cli/index.ts
    • A hook crash must not break the user's edit flow — but silence made dead wiring look like the model forgetting Hunch (2026-09-12 diagnosis); one context line keeps the edit flowing and the failure visible

ℹ️ Nothing here is a direct, high-confidence, non-stale blocking invariant — not blocking this PR.

🧠 Hunch · engineering memory · run hunch why <file> for the full reasoning.

📜 Hunch Constitution — 2 policy receipt(s)

  • ✅ pol_01cf084e1e satisfied — symbol:renderAdoptedDoc does not reach symbol:writeFileAtomic
    • receipt: sha1:2eeef87cee0a3c7ae9d8ba0385143e277febb4e9
  • ✅ pol_3f3aee11ad satisfied — symbol:src/store/db.ts:openDb does not reach external:better-sqlite3
    • receipt: sha1:5ae1acc4eac0c3d777224c1c44861ec718bb4d93

…k-retry

# Conflicts:
#	src/synthesis/synthesize.ts
…to fix/synth-grounded-alternatives

# Conflicts:
#	CHANGELOG.md
#	test/provider.test.ts
@davesheffer
davesheffer merged commit 3805386 into main Oct 29, 2026
14 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 29, 2026
@davesheffer
davesheffer deleted the fix/synth-grounded-alternatives branch November 3, 2026 03:23

This branch was successfully deployed

1 active deployment
Preview — 0c3451b2 Deployed Oct 29, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant