Summary
Distinct from (and complementary to) the gateway policy gate shipped 2026-07-25 (crates/ledgerr-mcp/src/gateway_policy.rs), which checks tool calls after an LLM emits them. This issue is about constrained generation in the inference sense: forcing an LLM's token generation to conform to a formal grammar (e.g. via xgrammar or similar grammar-constrained decoding) so that syntactically invalid or out-of-vocabulary CLIF/DSL output is structurally impossible to produce, not just caught after the fact.
Context
- Term clarified by the operator 2026-07-25: "constrained generation," not "constraint generation" — this is the xgrammar/grammar-constrained-decoding layer at LLM inference time.
- ledgrrr already has a local-model story to hook this into:
crates/ledgerr-host has local-llm/mistralrs-llm features (Phi-4 GGUF), and the Justfile has windows-ai-* recipes for Microsoft Foundry Local. PRD-10's desktop-agent controller also has a "local CPU model runtime" slot that's currently configured: false (crates/ledgerr-desktop-agent/src/status.rs).
- Depends on the CLIF AST / grammar work (see companion issue) existing first — you need a formal grammar to constrain against before you can wire constrained decoding to it.
Scope (not yet designed)
- Which local inference runtime(s) this needs to integrate with (mistralrs, Foundry Local, others) and whether each has/needs grammar-constrained decoding support.
- Whether the constraint grammar is derived automatically from the CLIF AST (Rust types → grammar) or hand-maintained in parallel.
- Where this sits relative to the gateway policy gate — likely front-loads correctness (LLM literally cannot emit invalid CLIF), with the gateway gate remaining as defense-in-depth for any non-constrained client (e.g. Claude Desktop via MCP, which isn't running through ledgrrr's own local inference stack).
Related
- Roadmap:
docs/superpowers/plans/2026-07-25-ledgrrr-integration-roadmap.md, subsystem 5.
- Companion issues: CLIF AST/interpreter, RDF/triple-store knowledge graph.
Summary
Distinct from (and complementary to) the gateway policy gate shipped 2026-07-25 (
crates/ledgerr-mcp/src/gateway_policy.rs), which checks tool calls after an LLM emits them. This issue is about constrained generation in the inference sense: forcing an LLM's token generation to conform to a formal grammar (e.g. via xgrammar or similar grammar-constrained decoding) so that syntactically invalid or out-of-vocabulary CLIF/DSL output is structurally impossible to produce, not just caught after the fact.Context
crates/ledgerr-hosthaslocal-llm/mistralrs-llmfeatures (Phi-4 GGUF), and the Justfile haswindows-ai-*recipes for Microsoft Foundry Local. PRD-10's desktop-agent controller also has a "local CPU model runtime" slot that's currentlyconfigured: false(crates/ledgerr-desktop-agent/src/status.rs).Scope (not yet designed)
Related
docs/superpowers/plans/2026-07-25-ledgrrr-integration-roadmap.md, subsystem 5.