Repository navigation
Stop create_schema from copying an unrelated retrieved schema's fields onto a new type - #1859
Conversation
…s onto a new type (closes #1846) The RELEVANT ENTITY TYPES context block was being consumed as a field template: creating a new type while an unrelated schema was in context (e.g. equipment_item) copied that schema's fields verbatim onto the new type. A prose-only fix (a new Schema Creation skill rule) measured zero effect against a live isolated daemon; putting the anti-copy instruction inline in the block's header, at both render sites that show it (the resident workspace context and Stage-2 routing's candidate metadata, which was a second, previously-unguarded copy of the same text), measured a real reduction from contaminated on every trial to clean on 4 of 5. Both sites now share one RELEVANT_ENTITY_TYPES_HEADER constant so they can't drift apart again. Added minProperties to eval scenario 8c so it can no longer score green on an empty record. Filed #1858 to track closing the remaining probabilistic gap with a routing-aware context assembly. Co-Authored-By: Claude <[email protected]>
Code Review SummaryThis is a well-executed, evidence-driven bug fix for #1846 ( Verification performed (not just read)
FindingsCritical IssuesNone. Suggested Improvements
Nitpicks
Acceptance Criteria — Issue #1846
RecommendationAPPROVE. This is a net-positive, well-scoped fix backed by real measurement discipline (live isolated daemon, purged DB, 5 independent trials, explicit before/after) rather than assumption — exactly the standard this workstream has been building toward per ADR-064. The requested dedup from prior review feedback is genuinely implemented with a non-tautological regression test, not merely claimed. The two items above are minor and don't block merge: the eval-score restatement is a documentation completeness nit, and the |
malibio
left a comment
There was a problem hiding this comment.
Review recommendation: APPROVE (self-approval blocked by GitHub — PR author and reviewing account are the same user). Full findings posted above.
…ve status Per PR #1859 review feedback: this rule was measured on its own to have zero effect on the #1846 contamination it targets, and is kept as defense-in-depth rather than as part of the measured 4/5 structural fix. Doc comment makes that explicit so a future reader of skill_rules.rs in isolation doesn't credit it with the improvement RELEVANT_ENTITY_TYPES_HEADER actually produced. Also restated the aggregate bun run eval:agent score (8/12) directly in the PR body, per the same review's request to check off issue #1846's acceptance criterion 4 with an explicit number rather than only a cross-reference to the issue thread. Co-Authored-By: Claude <[email protected]>
Addressed review feedbackAddressed (2):
Skipped (2, both nitpicks the reviewer explicitly flagged as non-blocking):
All tests re-verified after the changes: Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: Both addressed items were documentation/doc-comment additions (a PR body edit and an 9-line doc comment) with zero logic changes — no new functionality, no architectural changes, nothing that alters the behavior the prior review already verified. The two skipped items were nitpicks the reviewer itself marked as not blocking and not requiring action now. Ready for an independent human approval and merge. |
… use (#1857) (#1861) * Give resolve_query's sub-prompt the enum values it tells the model to use The sub-prompt instructs the model to map "a status word to an enum/status field", but rendered fields as `name (type)` — so an enum arrived as `condition (enum)` with its legal values nowhere in sight. The model had to invent one, and an invented value yields a filter matching nothing, which reads exactly like a request that legitimately had no match. This is the same no-referent shape as the guidance that told the model to populate `properties` from field metadata the prompt never carried: the instruction names something the prompt does not supply, and the failure is silent. Rendered through `EntityFieldDescriptor` rather than a local spelling, so this is the third call site on one renderer instead of a fourth hand-written one. `from_schema_field` becomes public to allow it. The notation now also matches the entity block the model sees elsewhere in the same conversation. The test asserts on the prompt text, not the tool's return value — the return value is well-formed whether or not the model guessed. Verified by mutation: against the old renderer the prompt shows `- condition (enum)` and the test fails. Eval: 6/12 with this change, and 6/12 on an unmodified build of the same commit — identical failures scenario for scenario, so this is neutral on the matrix. Note that baseline is down from the 10/12 measured before #1859 landed; scenario 6 (this change's target) fails in both arms for want of a resolve_query call at all, so the fix cannot be scored by the matrix today. Worth a look at whether #1859 regressed schema creation — 4, 8b and 8c all fail on rejected schemas or unpersisted properties, which is that area. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01AvsJJC6NgtJuNz8fTYA163 * Address review: keep write-time obligations out of the filter sub-prompt Reusing `render()` wholesale carried ", required" into `resolve_query`'s prompt. Reproduced before fixing: a required field rendered as `- replacement_cost: number, required`. That is not cosmetic. `required` has exactly one definition in front of this model — the node-creation guidance's "MUST be included in the properties map" — which is an obligation on a *write*. This sub-call is a lone user message with no system prompt and no tools, so the word arrives with no definition at all, and a model applying the one it knows would filter on a field the request never mentioned. That matches nothing, which is indistinguishable from a genuinely empty result: the same silent failure this PR set out to remove, reintroduced from the other side. Split `render_shape` (name, type, enum values) from `render` (that plus required-ness). The entity block keeps `render` — required-ness is exactly what it should say when the model is about to create a node. Read and filter prompts get `render_shape`. Both still share one renderer, so the convergence this PR is about is intact. Pinned by assertion rather than left to inspection: the fixture's number field is now required, so the test proves the suffix is suppressed rather than merely absent. Mutation-verified — restoring `.render()` fails it. Also corrected a comment claiming this notation "matches the entity block the model sees elsewhere in the same conversation." There is no same conversation; this is an isolated sub-call. The maintenance argument for convergence carries the change on its own. Reviewer's other findings needed no code change: `pub` is correct (`pub(crate)` cannot work across crates), the notation is coherent with the surrounding prompt, and the CapturingEngine/FixedJsonEngine duplication is worth consolidating at a third double, not a second. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01AvsJJC6NgtJuNz8fTYA163 --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Summary
create_schemawas copying a semantically-retrieved unrelated schema's fields onto a brand-new type (e.g.album_trackergettingequipment_item'sis_returned/replacement_cost), because theRELEVANT ENTITY TYPEScontext block is the only field metadata the model sees on a creation turn and was being consumed as a copyable template.packages/core/src/ops/context_ops.rs) and Stage-2 routing's candidate metadata (packages/agent/src/local_agent/routing.rs) — the latter was a second, previously-unguarded copy of the same text that was reinforcing the contamination even after the first site alone was fixed. Both now share oneRELEVANT_ENTITY_TYPES_HEADERconstant so they can't drift apart again (with a test asserting the routing.rs site uses the exact constant).minProperties: 1to eval scenario 8c so it can no longer score green on an empty record.Measured result (isolated daemon, purged DB,
gemma-4-e4b-q4km, n_ctx 32768, 5 independent trials): 4 of 5 clean (sensible fields likegenre/artist), 1 of 5 still contaminated. This is a real, measured reduction, not a categorical fix — consistent with ADR-064's finding that prompt/context-level interventions are probabilistic on this locked 4B model. Filed #1858 to track closing the remaining gap with a routing-aware context assembly (a larger architectural change, since context is assembled before Stage 2 routing runs today).bun run eval:agentscore (full 12-scenario matrix, post-fix, both render sites patched): 8/12 passed. Scenarios 8a/8b (schema creation) pass; scenario 8c (create_nodefor the first custom type) now callscreate_nodeat all — a behavior change from pre-fix runs where it called no tool — but still failsminProperties(a distinct, pre-existing gap from #1841: properties aren't reliably persisted, not a #1846 regression). The 4 failing scenarios (4, 6, 8c, and one of 8d/8e depending on the run) are consistent across before/after runs and are not newly introduced by this PR — see the issue thread for the full before/after/after2/after3 run comparison.Full investigation, both fix attempts, and the measurement methodology are documented on #1846.
Closes #1846
Test plan
cargo test -p nodespace-core --lib context_ops— 30 passedcargo test -p nodespace-agent --lib routing— 32 passed (incl. newschema_metadata_section_uses_the_shared_header)cargo test -p nodespace-agent --lib— 383 passedcargo test -p nodespace-core --lib— 1061 passedbun run test:all— full suite passed (frontend, Rust workspace, e2e, scripts)bun run quality:fix— cleangemma-4-e4b-q4kmdaemon: 5 independent trials of the equipment→album repro (4/5 clean, 1/5 contaminated — documented in code comments and issue)🤖 Generated with Claude Code
https://claude.ai/code/session_01DkqjrfV1G6kugsEjvyU9wU