Repository navigation
feat(decide): typed decisions — the LLM node's decide interface, Laya-ready (schema v30) - #18
Merged
Merged
Conversation
…-ready (schema v30)
The hub spec splits the LLM node into generate (prose) and decide
(judgements: choice, score, yes/no). This is the decide half, built so
the decision model can be swapped in per question without touching
callers.
- src/decide.py: versioned question registry (worth_remembering@v1,
test_passes@v1, is_duplicate@v1, route_rung@v1); decide() returns a
Decision or None (fail open); every call logged to the new `decisions`
table (input, answer, backend, confidence, latency, later outcome via
record_outcome) and as a `decision` ledger row; policy file
(~/.engram/policy.json, ENGRAM_POLICY_PATH) pins backend + threshold
per question@vN — a pointer change, reversible
- backends: haiku (bootstrap; task=decide → claude-haiku-5-5 under the
Anthropic provider, ENGRAM_LLM_DECIDE_MODEL overrides; strict-JSON
prompt, tolerant parse) and laya (Convai Innovations' local decision
model, optional extra [laya]; Router(default=…, device, models),
predict(state, {name: noul|choice|score spec}, model=…); reads
noul/choice/score/probabilities/answer_confidence/low_confidence
defensively; failure or missing package falls back to haiku)
- consumers: memory_auto_extract screens candidates with
worth_remembering (screen=True on the MCP/digest path; no backend →
nothing dropped; kept candidates carry decision_id); skill-validation
llm_judge grading is test_passes
- CLI: engram decide ask | stats | bench | export | policy | outcome.
bench re-runs recent inputs on both backends → latency p50/p95 +
agreement, the measured gate (policy max_latency_ms=300) for promotion
and for the request path; export writes the JSONL fine-tuning set
labelled by outcome when present, else by the answer taken
- schema v30 migration + fresh DDL (decisions + 2 indexes)
Tests: tests/test_decide.py (registry/policy, haiku JSON + bare yes/no +
choice parsing, logging + ledger, laya pinned/threshold/choice/failure/
missing, outcomes/stats/export, bench, both consumers), v30 migration.
Existing extraction and validation tests pass unchanged; the full suite
(1520) makes zero real LLM calls (timed, log grepped). ruff clean,
pyright 0 errors, Cloak 0 errors. docs/COMMANDS.md regenerated.
Retraining loop + outcome signals + the VM latency gate: #17.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`engram decide <id>` already exists — the inbox approval command, the single proposal→execution path (ADR-0007). Python 3.12's argparse rejects the duplicate subparser (3.9 silently allowed it, which is why it passed locally); CI caught it through the docs/COMMANDS.md freshness check. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Summary
The hub spec's LLM node has two interfaces: generate (prose; shipped in #16 on Anthropic) and decide (judgements: choice, score, yes/no). This is the decide half, built so the decision model (Laya) can take over per question without touching callers. Follow-ups are tracked in #17.
What the spec asked for, and where it is
src/decide.pyregistry:worth_remembering@v1,test_passes@v1,is_duplicate@v1,route_rung@v1decisionstable (schema v30) +record_outcome(); onedecisionledger row per callhaikubackend through the shared LLM layer;task=decideresolves toclaude-haiku-5-5under the Anthropic providerlayabackend:Router(default="multilingual", …).predict(state, {name: noul|choice|score spec}, model=…); readsnoul/choice/score/probabilities/answer_confidence/low_confidence; any failure falls back to haiku~/.engram/policy.jsonpins backend + threshold perquestion@vN;engram decide policy --set worth_remembering@v1=layaengram decide benchreports both backends' p50/p95 and agreement; policymax_latency_ms(300) is the gateengram decide exportwrites the JSONL set labelled by outcome when present, else by the answer takenConsumers wired now:
memory_auto_extractscreens each candidate withworth_remembering(fail open: no backend, no drops; kept candidates carrydecision_id), and thellm_judgegrader in skill validation istest_passes.Verification
tests/test_decide.py(19): registry and policy; haiku JSON, bare yes/no and choice parsing; logging and ledger; laya pinned, threshold, choice shape, failure fallback, missing package; outcomes, stats, export; bench; both consumersdocs/COMMANDS.mdregeneratedbench, confirm the answer-dict keys against the installed version (Decision model (Laya): retraining loop, outcome signals, and the request-path gate #17)🤖 Generated with Claude Code