Repository navigation
Fix resolve_query no_match against a node whose property does contain the value - #1910
Conversation
… the value (closes #1908) Two independent defects in exec_resolve_query's decomposition step, both diagnosed by driving the real locked model (gemma-4-e4b-q4km) against the issue's exact repro: 1. The decomposition prompt didn't distinguish "what identifies the node" from "what the request wants to change it to". For "The 2400 one came back — set it to returned", the model filtered on the target update state (status: returned) instead of the identifying value (2400), finding nothing since no node has that status yet. The prompt now explicitly separates identifying values from update targets and warns against filtering on the latter. 2. Separately, nothing coerced a decomposed filter's value to match its target field's declared schema type. A numeric field's value emitted as a JSON string (`"2400"` instead of `2400`) silently fails to match a stored number, since SQLite's json_extract preserves the stored value's real type and `2400 = '2400'` is false. coerce_filter_value_to_field_type now normalizes stringified numbers against number fields before the query runs. Verified live: 2/2 runs resolve correctly post-fix vs. 0/2 pre-fix on the real model, closing the gap the test suite's own doc comment flagged (every existing test stubbed the engine, so real decomposition accuracy was untested by cargo test). Added a live #[ignore]-gated regression test alongside a mocked regression test for the type-coercion defect. Co-Authored-By: Claude <[email protected]>
Code Review: PR #1910 — Fix
|
Code Review SummaryRecommendation: APPROVE (with one follow-up issue to file) Two genuinely independent defects, correctly diagnosed, fixed at the right layer, in a single atomic commit touching one file. The standout quality signal here is that both defects were verified against the real locked model rather than reasoned about — that is exactly the right rigor for a class of bug (silent I independently verified the core mechanism claim rather than taking the diff's word for it: The doc comment's stated mechanism is accurate. I also verified the new mocked test actually guards the defect — removing only the FindingsCritical IssuesNone. Section A — Scope of
|
malibio
left a comment
There was a problem hiding this comment.
Recommendation: APPROVE (formal approval blocked — GitHub does not permit approving one's own PR; recording as a review comment).
Two independently-verified defects, fixed at the right layer, single atomic commit. Verified the SQLite type-mismatch mechanism directly and confirmed the new mocked regression test genuinely fails without the coercion. Full review posted as a PR comment — one doc-comment correction requested (the boolean case is reachable, not proven-safe) and a follow-up issue to file; neither blocks merge.
…coverage Both from pragmatic-code-review on PR #1910: 1. coerce_filter_value_to_field_type now also normalizes a stringified boolean ("true") to a JSON boolean for boolean-typed fields, matching the same silent json_extract type-mismatch mechanism as the number case — verified via the same isolated-revert method (reverting the boolean branch alone reproduces the failure the new mocked test targets). 2. The live-model test now covers three phrasings in one model load: the issue's paraphrased-identifier repro plus the pre-existing dollar-amount and relative-date phrasings, confirming the prompt rewrite doesn't regress cases with no identify-vs-update-target ambiguity. Live-running surfaced a real, pre-existing (not a regression) ambiguity in "next Friday" — the model consistently reads it as the Friday of the following calendar week rather than the coming Friday. The test now seeds both candidate dates so the assertion targets prompt-following rather than a specific calendar interpretation. Verified live: all three phrasings resolve correctly (2/2 clean runs for the original repro plus dollar-amount and relative-date, both previously untested against a real model). Co-Authored-By: Claude <[email protected]>
Code Review: PR #1910 — Fix
|
Address-review follow-upBoth Important findings from the initial reviews were addressed in commit
The reviews additionally recommended filing a follow-up issue for the structural fix (JSON-schema-constrained decomposition output, to replace per-type coercion patching) and for the string→number reverse-direction case on text/enum fields. Filed as #1915 — intentionally out of scope for this PR per both reviews ("not a quick patch; a proper investigation" needing its own live-model validation). Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: The follow-up commit was already re-reviewed (APPROVE) before this comment. No further code changes were made — only filing the tracked follow-up issue, which is documentation/process, not a code change requiring review. PR is ready for merge (author's call). |
…ompt (closes #1915) (#1945) The decomposition sub-prompt named a field's declared type (`name: type`) but never told the model how to encode a value it maps onto that field, so a small model reading digits or booleans out of prose could emit the wrong JSON type — the exact silent-mismatch failure #1908/#1910 patched per-type via coerce_filter_value_to_field_type. Per the issue's own "cheaper to try first" proposal, add an explicit JSON-encoding hint (number/boolean/text/enum) to each field line in exec_resolve_query's prompt, scoped locally rather than to the shared render_shape() renderer per the issue's scope decision. Live-model validation against the locked Gemma 4 E4B model confirms the reverse-direction case (a numeric-looking value identifying a text field) now resolves correctly. Co-authored-by: Claude <[email protected]>
Summary
resolve_queryreturnedno_matchfor a bare-value query ("the 2400 one") against a node that does have a matching property (replacement_cost: 2400). Live-diagnosed against the real locked model (gemma-4-e4b-q4km) rather than guessed at — the mocked test suite hardcodes engine responses, so this path was previously unverified bycargo test(its own doc comment flags this gap).Two independent defects, both found by driving
exec_resolve_query's real decomposition prompt against the model:1. Decomposition prompt didn't separate "identify" from "update target". For
"The 2400 one came back — set it to returned", the model emitted a filter on the target update state (status: returned) instead of the identifying value (2400) — finding nothing, since no node has that status yet (it's stillchecked_out). The prompt now explicitly tells the model to filter only on what currently identifies the node, never on what the request wants to change it to, with a worked example matching this exact ambiguity.2. No coercion between a filter's JSON type and its target field's declared schema type. Even after decomposition names the right field, the model isn't constrained to encode a numeric value as a JSON number — it can emit
"2400"(string) instead of2400. SQLite'sjson_extractpreserves the stored value's real type, so= '2400'against a stored number silently matches nothing (verified directly against sqlite3:json_extract('{"a":2400}','$.a') = '2400'→0,= 2400→1).coerce_filter_value_to_field_typenow normalizes a stringified number against anumber-typed field before the query runs.Verification
Live, in-process GGUF (
gemma-4-E4B-it-Q4_K_M), drivingexec_resolve_query's real prompt (not the eval harness, not a stub):replacement_cost: 2400Both defects were confirmed independently — reverting each fix in isolation reproduces the failure the corresponding test targets.
What changed
packages/agent/src/local_agent/tools.rscoerce_filter_value_to_field_type: normalizes a JSON-string numeric value to a JSON number when the target field is schema-typednumber, before the filter reachesrun_node_query.resolve_query_coerces_stringified_number_to_match_numeric_field).#[ignore]-gated live-model regression test (live_paraphrased_identifier_resolves_against_real_model) that closes the real-model-accuracy gap the suite's own doc comment flagged — run explicitly withE2E_MODEL=~/.nodespace/models/gemma-4-E4B-it-Q4_K_M.gguf cargo test -p nodespace-agent --lib resolve_query_integration::live_paraphrased_identifier_resolves_against_real_model -- --ignored --nocapture.Test plan
cargo test -p nodespace-agent --lib resolve_query— 25 passed, 1 ignored (the new live test)cargo test --workspace(full Rust workspace, excluding the Tauri app) — all crates pass, 0 failuresbun run test— 171 files / 4108 tests passed (matches baseline)bun run test:scripts— 77 passedbun run test:skill— 20 passedbun run quality:fix— clean, no lint/format issues in the changed fileCloses #1908
🤖 Generated with Claude Code
https://claude.ai/code/session_012qFMbS5rEGLQL6CCkg6Xjs