Decide external-model degrade strategy for constrained decoding (#10) - #16
Merged
Merged
Conversation
Adds docs/adr/0001-external-model-decoding-strategy.md, the written decision issue #10 asked for. Per call site: - Gate.label/1 (closed 3-word vocabulary) -> Option B: provider structured output / tool-use enum. A real guarantee, not best-effort, so no new degraded tier is needed there; falls back to classify_lexically/1 exactly as the local path does today. - Turn.extract/4 and Turn.query/4 (open-ended Prolog) -> Option A: strong system prompt + bounded validate-and-retry against the existing Clause parser (split/1, rejection/1). No provider primitive can constrain arbitrary Prolog, so this is the new "best-effort external, retry-validated" tier the issue anticipated. Also decides where the retry loop lives (Turn/Gate, behind a new Model.constrained?/0 capability query — not inside Model or a backend module, keeping the #9 seam free of Prolog-specific logic), how the weakened guarantee is surfaced (a `syntax_guaranteed` handshake field and a new `prolog_retry_exhausted` error code, both additive per PROTOCOL.md's own versioning rule), and what happens to the unqualified GBNF-guarantee claims in README.md and Manifold.Clause's moduledoc. No code changes: this is the design decision itself. Implementation is follow-up work, as #10 specifies. README gets a one-paragraph pointer to the ADR under "Status / next steps" so it's discoverable. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J2hHjE9kH28XhE5Ksj7YES
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.
Adds docs/adr/0001-external-model-decoding-strategy.md, the written decision
issue #10 asked for.
Per call site:
output / tool-use enum. A real guarantee, not best-effort, so no new
degraded tier is needed there; falls back to classify_lexically/1 exactly
as the local path does today.
system prompt + bounded validate-and-retry against the existing Clause
parser (split/1, rejection/1). No provider primitive can constrain
arbitrary Prolog, so this is the new "best-effort external,
retry-validated" tier the issue anticipated.
Also decides where the retry loop lives (Turn/Gate, behind a new
Model.constrained?/0 capability query — not inside Model or a backend
module, keeping the #9 seam free of Prolog-specific logic), how the
weakened guarantee is surfaced (a
syntax_guaranteedhandshake field and anew
prolog_retry_exhaustederror code, both additive per PROTOCOL.md's ownversioning rule), and what happens to the unqualified GBNF-guarantee claims
in README.md and Manifold.Clause's moduledoc.
No code changes: this is the design decision itself. Implementation is
follow-up work, as #10 specifies. README gets a one-paragraph pointer to the
ADR under "Status / next steps" so it's discoverable.
Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01J2hHjE9kH28XhE5Ksj7YES