feat(proposal-engine): grounding contract — fabrication as a type error - #549
Merged
Conversation
North Star adoption #2 of the NOOA typed-return pattern (after MENTOR #22). The winniio-proposal golden rule ("every client claim traces to a verbatim source, or it does not go in") becomes a typed contract instead of a prose discipline. - corpus.py: SourceCorpus.contains() — verbatim (whitespace-normalized, case-preserved) presence in a NAMED client source, with a substantive-quote floor so a stopword can't ground a claim. - appendix.py: parse_appendix(rows, corpus) -> GroundedProposal. A quote not verbatim in its named source raises UngroundedClaim; bad field/stage/source raises MalformedRow. to_markdown() renders the canonical appendix table unchanged. - smile.py: the six SMILE stages as a validated Literal. - api.py: thin FastAPI gate POST /appendix/validate (roadmap tier 3), optional [api] extra — core contract has no web dependency. Honest boundary (zero-gaslight), pinned in test_boundary.py: the contract proves presence, not faithful representation — a recombined fragment (dropped negation) still grounds; the human roast remains the misquotation backstop. What it kills cold is pure invention. PredictStrategy only (typed returns, no code execution). ruff + mypy clean, 26/26 pytest. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013wjiUfG6WqrvCFDrATiC9H
Self-roast of PR #549 flagged the real usability risk: exact-substring matching would reject legitimate grounded quotes an LLM retyped with different punctuation/case, and a gate that rejects real claims gets disabled. _normalize now folds typographic punctuation (curly quotes, em/en dashes, ellipsis, nbsp), collapses whitespace, and casefolds before comparison. Forgiving on form, strict on substance — invented text still grounds in no source under any normalization. +3 tests (case, smart-quotes/dashes, invention-still-rejected). GROUNDING.md documents the loosening and the still-unmeasured real-transcript false-reject rate (fast-follow). ruff + mypy clean, 29/29. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013wjiUfG6WqrvCFDrATiC9H
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
North Star adoption #2 of the NOOA typed-return pattern (after MENTOR #22). The winniio-proposal golden rule — "every client claim traces to a verbatim source, or it does not go in" — becomes a typed contract instead of prose discipline.
parse_appendix(rows, corpus)grounds every appendix row against the client's own words:UngroundedClaim— quote not verbatim-present in the source it names ⇒ fabrication is a parse error.MalformedRow— missing field, bad type, unknown source, or a SMILE stage outside the canonical six.Why
Same shape that made a fabricated axiom a type error in MENTOR's judge, applied to proposals. PredictStrategy only — typed returns, no model-written code executed (the security-cleared NOOA mode; CodeAct stays quarantined).
Files (12)
src/proposal_engine/—corpus.py(verbatim grounding + substantive-quote floor),appendix.py(the contract +to_markdown()canonical table),smile.py(6 stages as a Literal),api.py(thin FastAPI gatePOST /appendix/validate, optional[api]extra — core has no web dep).tests/— contract, boundary, api.GROUNDING.md,.gitignore.Honest boundary (zero-gaslight)
The contract proves a quote is present, not faithfully represented — a recombined fragment (dropped negation) still grounds. Pinned in
tests/test_boundary.py; the human roast remains the misquotation backstop. What it kills cold is pure invention.Gates
✅ ruff clean · ✅ mypy clean · ✅ 26/26 pytest (contract + boundary + api).
Deliberately not built (KISS)
No auth, persistence, GraphQL, A2A, or vector DB. The generation loop stays in the
winniio-proposalskill — this package is the gate that loop must pass before a proposal ships.🤖 Generated with Claude Code