Repository navigation
Record skill, schema and operation selection as named decisions, with a measured Gemma baseline - #2842
Conversation
Both selections existed only as emergent properties of whatever tool call the model emitted, so neither could be scored except through end-to-end scenario pass/fail — which ADR-056 states "describe[s] the harness as much as the model". Both of that ADR's own E4B failures are decision failures. Adds local_agent::decisions: a DecisionRecord carrying the candidate set alongside the outcome (an outcome alone is not scoreable — whether calling search_nodes was right depends on what else was offered), and emits one structured log line per decision per round. No gate, no threshold, no behaviour change. ADR-038 warns against "inventing a third number"; the candidate sets recorded are the ones the pipeline already computed and the outcomes are the ones the model already produced. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Scrapes the two "Agent decision" log lines into [decision ...] markers and parses them onto TurnRecord, so a fixture can score the selections directly instead of inferring them from end-to-end pass/fail. decision_candidates is emitted LAST on each log line: tracing leaves a string field unquoted when it can, and a comma-separated list of names cannot be delimited by anything shorter than the line end. routed_skills is ordered that way for the same reason, and a scrape that assumed otherwise silently matched nothing. Absent markers parse to undefined rather than [], so a results file from a build predating them stays distinguishable from a turn that genuinely made no decision. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Scores schema and operation selection directly rather than inferring them from end-to-end pass/fail. Each scenario asserts on ONE decision, so a failure says which of the two went wrong instead of collapsing both into one verdict. Scenarios run against a workspace carrying two overlapping types, because a decision is only scoreable when there was something to decide between: a single-schema workspace makes every schema selection trivially correct and measures nothing. The setup turns that build it are marked `setup` so a failure there is not counted many times downstream. Covers ADR-056's two recorded E4B decision failures, the disambiguation shape where several types plausibly match the wording, and the case where the right answer is to call no tool at all. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Two runs were spent measuring the fixture rather than the model. The cause was assertions naming exact type ids: create_schema derives the id from the MODEL's phrasing, so "companies we sell to" became company_sold_to and the assertion on `company` failed as a naming mismatch wearing a decision error's clothes. Schema expectations now assert the property being scored — did it stay on the retrieved menu, and which of two candidates did it pick — rather than an id the fixture cannot predict. Also drops core seeded types from the fixture entirely. Measured directly: "How many projects do we have?" records `selected=project [off-menu] candidates=` because parse_and_filter_non_core_schemas strips core types from candidates. That is unconstrained generation, not a selection, and scoring it would measure the is_core filter. Adds [routing ms], capturing Stage-1's own latency — one generative pass for a 3-way structural choice, measured at 1.5-1.7s. Kept separate from turn latency because a decision-model comparison turns on cost and accuracy independently. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The two decisions recorded so far sit downstream of the layer where the observed failures actually happen. Stage-1 retrieval matches an embedding of the message against skill descriptions (ADR-064 rule 3); by the time tool descriptions matter, stage2_tools has already scoped the surface. A type-definition request routed to Node Creation never sees create_schema at all, so the turn reads as a wrong-tool failure when retrieval was what went wrong — and the two have different fixes. Records every retrieved candidate, including below-bar ones: "retrieved but scored under its blast-radius bar" and "never retrieved" are different failures, and a list filtered to gate-clearers cannot tell them apart. Adds three instance-vs-type scenarios. A schema IS a node, so the boundary is abstraction level rather than kind of thing, and it carries the larger blast radius — a spurious type definition is worse than a spurious record. Both skill descriptions already encode the distinction and retrieval still misrouted the indirect phrasing during development, so these score embedding similarity, not instruction quality. One scenario was reworded after the contamination guard rejected it for sharing five consecutive words with create_schema's own description. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Both the log scrape and the results parser matched `selected` as a non-whitespace run, so "Schema Creation" arrived as "Schema". tracing quotes a string field when it contains a space, and skill names do — tool names and type ids never do, which is why this was invisible until skill routing was recorded. Regression tests on both sides use a verbatim live daemon line. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The code-reference ratchet blocked the push: two module doc comments linked ADR-056 and ADR-038 as relative paths into nodespace-docs. CLAUDE.md's documentation standard is to reference decisions by ADR number and describe the constraint directly, which is also what keeps a code comment from going stale when a doc moves. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Pragmatic Code Review — PR #2842Review Type: Initial Review SummaryThis is a genuinely good change, and unusually so for instrumentation. It does the hard part right: it records the candidate set alongside the outcome, which is the difference between a log line and a scoreable decision. The The behaviour-neutrality claim holds. I traced every call site: the three Discipline worth calling out: the PR reports a 0/3 category in its own description and then correctly diagnoses it as not schema selection (the model resolved no node id, called no tool) and routes it to #2841 rather than tuning the fixture until it went green. That is the instrumentation working as intended on its first use, and it is the strongest evidence that the seam was worth building. Verification performed (not taken on faith):
Requirements Check — Issue #2802
Exceeded scope, justifiably: the issue asked for two decisions; this delivers three. The added Findings🟡 Important📁 The doc comment states the selection is "the top gate-clearing candidate: the one whose whitelist leads Those two are not the same predicate, and the codebase already knows it.
This is the third consumer, broken the same way. Tracing the mechanism end to end:
The consequence is not hypothetical for this PR specifically: it lands on exactly the scenarios this fixture was built to score. Every schema scenario names its type outright by construction — It also puts a latent false-negative in Principle: DRY over a safety invariant. Suggested fix (one line, plus a regression test mirroring Better still, expose the rule from One nuance to decide alongside the fix: the tool-less candidate arguably should still appear in 🟢 Suggestions📁
📁 The skill decision emits only when 📁 The PR is right that The residual risk is that the contract is asserted in three places (Rust emitter comment, Worth noting a latent edge the current format cannot express: a skill name containing a literal 📁 The design choice is correct and I'd defend it: enumerating both arms so a new Two judgment calls to confirm rather than change:
📁 This runs once per ReAct round over at most 📁 The header says "scores the two selections the agent makes per round" and lists only Nitpicks
RecommendationAPPROVE — this is comfortably net-positive and should land. The architecture is sound, the behaviour-neutrality claim verifies, test coverage is strong on both sides of the language boundary, and the code-comment quality is genuinely above average for this kind of plumbing. The 🟡 🤖 Automated pragmatic-code-review |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
record_skill took the first gate-clearing candidate, which is not the same predicate as "the candidate whose whitelist leads stage2_tools". A schema-typed retrieval hit carries tools: [] and the lexical backstop pins it at confidence 1.0 — above any cosine-derived score a real skill can reach — so on every turn naming a schema outright it sorted first and was recorded as the skill that led. It leads nothing: it contributes no tool to the offered surface. That is most of the decision eval's schema scenarios by construction, so the defect corrupted the first numbers this instrumentation produced, on exactly the cases it was built to measure. routing.rs already held this invariant for two other consumers, both of which had been separately broken the same way. Rather than re-deriving it a third time, leading_tool_bearing_candidate is now exposed there, next to top_tool_bearing_score and the doc comment explaining why the rule is one named thing rather than a coincidence between call sites. The tool-less candidate still appears in `candidates` — it was genuinely retrieved, and "retrieved but contributed nothing" is worth seeing. Regression test verified against the unfixed code: it reports the schema hit as the winner without the fix, and the real skill with it. Also from review: refreshed three docstrings still describing "the two selections" after the skill decision was added, asserted the Skill wire name, and documented why the empty-oneOf branch is retained rather than dead. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Address Review SummaryCommit: ✅ Addressed🟡 The finding was correct and the mechanism verified end to end:
Fixed via the reviewer's second suggestion rather than the one-line predicate change: The tool-less candidate still appears in Regression test verified against the unfixed code, not just asserted: reverting the fix makes Also added 🟢 Stale docstrings — three files still said "the two selections" after the skill decision landed: 🟢 🟢 Unused ⏭️ Skipped, with reasoning🟢 Emit the skill decision next to 🟢 Emitter→scrape→parse round-trip test for the marker format — genuinely worth having; the format is asserted in three places and enforced in none. Skipped as scope creep for this PR: it needs a test harness that runs the Rust emitter and the TS parser together, which does not exist today. The three-way contract is at least documented at each site now. Worth its own issue. 🟢 Latent: a skill name containing Nitpick: Nitpick: Verification
Does the recorded baseline need re-measuring?No — checked rather than assumed. The concern was that the baseline on #2802 was measured with the buggy Classification noteReviewer marked this 🟡 Important rather than 🔴 Critical, correctly: nothing gates on the record, so no agent behaviour was affected. But it corrupted the first output of instrumentation whose entire purpose is producing trustworthy numbers, on exactly the scenarios it was built to score — which is why it was worth fixing before merge rather than as follow-up. |
Pragmatic Code Review — PR #2842 (Re-Review)Review Type: Re-Review Previous Review Disposition
Every skipped item carries an explicit justification in the address-review comment, and I agree with four of the five. The exception is a factual correction, noted as a nit below rather than as a finding, since the outcome is unchanged:
The Verification PerformedNot taken on faith — every claim in the address-review comment was independently re-run:
Assessment of the FixThe chosen fix is better than the one I suggested, and for the right reason. I offered a one-line predicate change as the minimum and Correctness of Is Docstrings are accurate. I checked each claim against the code: "three consumers have now been written against this predicate, and the two that re-derived it were both wrong in the same way" matches Findings🔴 CriticalNone. 🟡 ImportantNone. 🟢 Suggestions📁 This is the residual of my original "or better still, have both call it" suggestion, and I want to be precise that it is not a correctness defect in this PR — the record is right on every input that can occur today. The filter expression The observable divergence is tie behaviour, and it is worth understanding rather than just noting:
So on a tie, Two things would close this cheaply, neither blocking:
Principle: two functions holding the same predicate by coincidence is exactly the drift risk this file was written to eliminate; and where a doc comment claims equivalence to a sibling, the ways it is not equivalent should be the part that is written down. 📁 The two added tests are well-chosen and both genuinely pin the fix (verified above). Two cases remain uncovered:
Neither is a gap in the fix — both are cheap additions to a test module that is otherwise thorough. Nitpicks
Was the Baseline Correctly Left Un-remeasured?Yes, and the reasoning is the right kind — checked rather than assumed. The claim is that all 30 recorded skill decisions across 3 reps contain zero tool-less candidates, so the defect had no opportunity to mislabel anything and the recorded numbers stand. That is the correct test to run: the bug can only alter a record on a turn where a tool-less candidate was actually retrieved and cleared. Verifying its absence in the captured data is strictly stronger than re-running, and it also explains why the original review's concern about RecommendationAPPROVE — merge. The 🟡 was real, the fix is complete, and it is the better of the two options I offered rather than the cheaper one. The regression tests were verified to fail without the fix — I re-ran that myself rather than accepting the claim, and both new tests fail on the reverted code with the reported output. No behaviour outside The remaining 🟢 — one predicate still written twice, with an unstated tie difference — is a genuine but minor follow-up on an invariant that is now more centralised than before this commit, not less. It does not warrant holding the PR. 🤖 Automated pragmatic-code-review (re-review) |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
The re-review's 🟢: after the last commit the predicate `clears_score_gate(c) && !c.tools.is_empty()` was still written out twice, in top_tool_bearing_score and leading_tool_bearing_candidate. That is the shape this file's own history warns about — the rule has drifted between call sites three times — so it is now one named function, is_tool_bearing_contender, that both filter on. Documents the tie divergence the re-review found, which the previous docstring glossed: top_tool_bearing_score returns a score and its consumers admit every candidate matching it, so ties all contribute; leading_tool_bearing_candidate returns one candidate because DecisionRecord has no shape for "these two tied". Stable for a given input order, but not a modelled preference between equals. Adds the two untested edges the re-review named: all candidates tool-less (the likeliest real shape of the bug just fixed, and distinct from the empty-slice case), and a tie (asserting one of the tied top scorers wins, never a lesser one — the property that matters, rather than which name max_by happens to yield). Reconciles a docstring the re-review flagged as overstated: it claimed the backstop fires on "most of the schema scenarios", while the recorded baseline observed 0 of 30. Now states the trigger condition and the observed zero separately — reachable-in-principle and observed-in-practice are different claims, and only the first justifies the guard. bun.lock: the re-review correctly caught that the previous justification for leaving the configVersion delta was wrong — it came from a branch commit here, not from a rebase. Tested restoring it: `bun install` re-removes the line on this Bun version, so it would churn back on every install. Left as-is, now for a reason that holds. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Closes #2802.
Makes the three selections an agent turn performs — which skill, which schema, which operation — named, recorded, and scoreable, instead of leaving them implicit inside Gemma's generative pass.
Why
Both of ADR-056's recorded E4B failures are decision failures, not generation failures — a wrong operation, and a turn that stopped after the read without the write. Neither was separable from the scenario result containing it, and that ADR says plainly that the existing matrix scores "describe the harness as much as the model." There was no way to ask "how often does the agent pick the right schema?" except by inference from end-to-end pass/fail.
This does not change who decides. The model still makes every call exactly as before; removing this code would change no behaviour. What it adds is a record of what was on offer and what was chosen.
What's here
local_agent::decisions— aDecisionRecordcarrying the candidate set alongside the outcome. An outcome alone is not scoreable: whether callingsearch_nodeswas right depends on what else was offered.skillis upstream of the other two and is not a model decision at all — it is deterministic retrieval plus a score bar — but it constrains them, so a turn routed to Node Creation never seescreate_schemaand reads as a wrong-tool failure when retrieval was what went wrong.TurnRecord.decisions, parsed per ReAct round.bun run eval:decisions— a fixture scoring each decision independently, so a failure names which of the three went wrong.routingMs) — the wall-clock of one generative pass whose entire output is a 3-way structural choice.Not a third gate
ADR-038 establishes two independently-sourced gates and warns explicitly against "inventing a third number." Nothing here gates, filters, or rejects. The candidate sets recorded are the ones the pipeline already computed (
stage2_tools, the retrieved schema metadata,find_skills' own output); the outcomes are the ones the model already produced. The existing score bars are untouched.Measured baseline
3 reps, purged database between each,
gemma-4-e4b-q4km, on this branch rebased onto currentmain:Zero variance — every scenario passed 3/3 or failed 0/3. An earlier run against pre-#2815 code produced identical category scores, which is reassuring rather than coincidental: the failure is upstream of anything that fix touched.
All three schema failures are one failure, and it is not schema selection. Candidates were offered and the model called no tool at all, asking for a node ID instead:
It could not resolve the name "Northwind" to a node. That is a lookup, not a judgment — tracked as its own design problem in #2841, which this PR does not attempt.
What the instrumentation caught while being built
delivery jobvs the registereddelivery_job) — a format error, invisible in end-to-end scoring.Review notes
decisions.rsis the substance; the rest is plumbing and fixture.decision_candidatesis emitted last on each log line because tracing leaves string fields unquoted and a comma-separated list of names cannot be delimited by anything shorter than the line end —routed_skillsis ordered that way for the same reason. A commit here fixes the mirror of that bug:selectedwas matched as a non-whitespace run, truncating "Schema Creation" to "Schema".create_schemaderives ids from the model's phrasing ("companies we sell to" →company_sold_to), so an assertion namingcompanyfails as a naming mismatch wearing a decision error's clothes. Two full 3-rep runs were spent learning that.--between-runsis load-bearing. Without it rep 1's created schemas persist into reps 2-3 and the reps stop being independent observations.🤖 Generated with Claude Code