test(contract): spec-refiner must route ANY non-empty Ambiguities to awaiting_human #11
Reference in New Issue
Block a user
Delete Branch "test/spec-refiner-ambiguity-routing"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Contract: wiki/concepts/spec-refiner-contract.md AC line ~122 — any non-empty
## Ambiguitiessection routes the row tophase=awaiting_humanand opens ahuman_issue.Bug:
src/damascus/phases.py:74guards onre.search(r"\?\s*$", _section(text, "Ambiguities"))— the section must end in?to trigger. A section that lists an ambiguity without a trailing question mark falls through tophase=build, the human never sees the issue.Gap note: wiki/queries/damascus-orchestrator/spec-refiner-ambiguity-routing-drift-2026-06-24.md (with Option A: drop the
?check, replace with non-empty section check; 5-min fix).Companion contract test: PR #10 (
test/spec-refiner-prompts-row-constraints) covers the file_scope/budget_cycles aspect of the same spec-refiner contract. This PR covers the ambiguity-routing aspect.Companion E2E test: the contract test passes when the fix lands (structural); an E2E test in
tests/e2e/will pass when the runtime behavior is right (behavioral). The E2E is out of scope for this PR — would need a synthetic ambiguous spec + a live cycle run.Source-grep gotcha: the bug pattern uses
re.escape(r"\?\s*$")so the literal 6 chars\?\s*$in source match character-for-character. Withoutre.escape(), raw-string regex interprets\?as literal?(no backslash),\sas whitespace class (no\stext),\$as literal$(no backslash) — and the test passes on broken code (false negative).Status: RED on
main— the test fails today, goes green on the Option A fix. Marked RED-in-main per the judgment-call inreferences/contract-test-pattern.md: the visible-in-CI failure is the to-do item for the next PR-author.Scope: one file, +56 lines, one test function. No source change. Reviewable in 2 min.
Self-review (heartbeat, 2026-06-24 07:08)
Diff: one file, +56 lines, one test function in
tests/contract/test_contracts_match_source.py. Branchtest/spec-refiner-ambiguity-routingoff main, no source change.Why this PR exists:
The spec-refiner contract (
wiki/concepts/spec-refiner-contract.mdAC line ~122) says any non-empty## Ambiguitiessection routes the row tophase='awaiting_human'and opens ahuman_issue. The currentphases.py:74implementation requires the section to end in?. These don't match. A spec whose Ambiguities section lists a question without trailing?falls through tophase='build', the human never sees the issue, and the build phase either guesses or crashes.RED-on-broken-code verification:
Test correctly goes RED today, GREEN on the Option A fix from the gap note.
Source-grep gotcha (2026-06-24 skill pitfall): the bug pattern uses
re.escape()so the literal\?\s*$in source matches character-for-character. Raw-string regex interprets\?as literal?,\sas whitespace class,\$as literal$— and would false-pass on broken code. Verified end-to-end on the related PR #10 (file_scope/budget_cycles contract) before applying the same pattern here.Companion work:
test/spec-refiner-prompts-row-constraints) covers the file_scope/budget_cycles aspect of the same contract. Both PRs together cover both contract-drift bugs identified in the spec-refiner contract.wiki/queries/damascus-orchestrator/spec-refiner-ambiguity-routing-drift-2026-06-24.md— has the 3 options + recommendation (Option A: drop the?check, ~5 min).What's NOT in this PR:
_section()). Pair-up recommendation in the gap note.Merge recommendation: ship — 1 file, +56 lines, test is RED on broken code as verified, fix is documented in the gap note. The fix PR (when written) takes 5 min and goes green on this same test.
Closing this PR — superseded by PR #12.
PR #12 (
fix(spec): route any non-empty Ambiguities section to awaiting_human) was branched off the tip of PR #11 (bb96bdb) and includes the same test from this PR plus the 1-line source fix inphases.py:74. Verified:git diff bb96bdb..abc8f4a -- tests/contract/test_contracts_match_source.pyreturns 0 lines — byte-identical test file.Recommended merge order: PR #12 first (carries test + fix as one commit on top of main). PR #11 would be a no-op duplicate after that.
The contract test that lives in both PRs is the structural counterpart to the spec-refiner-contract.md §3 ("any non-empty
## Ambiguitiessection triggers awaiting_human"). The 1-line fix removes the?-terminator check that was silently swallowing list-style ambiguities and routing them tobuild. Verified RED on broken (with the bug pattern literal re-introduced) and GREEN on the fix. See gap notewiki/queries/damascus-orchestrator/spec-refiner-ambiguity-routing-drift-2026-06-24.mdfor the full trace.Closing this so the inbox stays clean. PR #12 has the full test+fix as a single PR; merging it carries both.
Pull request closed