Repository navigation
Get search_nodes' in operator an array — and correct what #2182 attributed it to - #2183
Conversation
…t hid why Adds `repair_scalar_in_operator_values` to the tool-argument repair set: when a filter carries `operator: "in"` and a scalar string `value`, the string is split into the array the operator requires. Joins the existing repairs at the single entry point, so it reaches both the parse boundary and the execution backstop, and participates in `canonical_args` so a malformed call and its repaired retry share one identity. Two corrections to #2182's framing, both measured rather than argued: A scalar `in` value is NOT a silent zero-result. `QueryService` rejects it outright ("In requires array value"), so the turn fails loudly. Pinned by a new test in query_service_test.rs, because that distinction decides how much machinery the defect justifies. Production's schema is NOT being ignored. Two ablation arms differing in only the `value` declaration, 3 reps each, byte-identical within each arm: production's type union (naming `array`) emits `["cut","soak"]`; the bare `type = "string"` the corpus case actually carries emits `"cut,soak"`. The issue's evidence came from a corpus case asking for a string. The repair stays as a backstop — measured converting real model output on the failing arm — not as the fix for a standing production failure. Getting there needed two fixes to the measurement itself, both kept: - The golden runner printed only repaired arguments, so an emission that production quietly fixed was indistinguishable from a clean one — the exact distinction the arms turn on. It now prints `[emitted, before repair: …]` when repair changed something. - `canonical_args` re-listed the repair set by hand instead of calling the shared entry point, so a repair added later reached execution but silently not the identity. It now goes through `repair_parsed_tool_arguments`. Also records both lessons in the ablation README, including that the first arm built for this failed to reach its own question (the model answered with a keyword query and no filters at all, 3/3) and that reading such an arm as a pass is the trap. Refs #2182 Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
Pragmatic Code Review — PR #2183Review Type: Initial Review SummaryThis is a strong, unusually honest PR. It does the thing that most PRs closing a bug report don't: it went and measured the report's premises, found two of them wrong, and wrote that down at the sites where someone would otherwise re-derive the wrong conclusion. Both corrections check out against the source. I verified the two load-bearing empirical claims independently:
I also mechanically verified the ablation isolation, which is the part most likely to be self-graded generously. It holds:
Every other diff hunk is Tests: The engineering is good and the measurement discipline is better than the issue it's answering. I have one finding that I think is a genuine correctness bug in the doc comment's central safety argument, and it's worth fixing before merge because the comment is what a future maintainer will trust instead of re-deriving. Requirements Check
📝 On the empirical bar: the task framing asks whether 3/3 vs 0/3 clears the project's "single runs are not decision-grade" standard. I think it does, and the standard is being applied correctly. That standard (README.toml:53-58) is about scored tallies — 6 vs 7 out of 12 — where a one-rep difference is noise. This is a categorically different observation: a byte-identical structural shape, 3/3 in each arm, with zero overlap between arms and a plausible mechanism. That's a saturated result, not a close one. The PR is also appropriately bounded about what it does not establish — Code Review Findings🟡 Important: The "needs no user-data denylist" claim is false, and the code is more exposed than its comment says📁 The doc comment makes a specific safety argument to justify being narrower than its sibling:
I ran the repair's exact logic against that shape: A user's stored string value is silently rewritten into an array, inside a write tool. Note the irony: the sibling The test at Recommendation: constrain by structural slot rather than by key presence. The malformation only ever occurs inside a fn repair_scalar_in_operator_values(args: &mut serde_json::Value) {
// Only `filters` is a structural slot; `field_values`/`content` are user data.
if let serde_json::Value::Object(obj) = args {
if let Some(filters) = obj.get_mut("filters") {
repair_in_filters(filters);
}
}
}Then add the currently-missing negative test: a Engineering principle: Fail-safe defaults / allowlist over denylist. A transform on user data should be scoped to slots where the model's structure lives, not gated on a key name a user can collide with. The deeper issue is that the comment asserts a safety property the code doesn't have — a future maintainer extending this will trust the comment, and comments that overstate guarantees are more dangerous than absent ones. 🟡 Important: Comma-splitting corrupts legitimate values containing commas — real, and not acknowledged📁
This turns a filter that would have matched one vendor into one matching two non-existent ones — and unlike the defect being fixed, this failure is genuinely silent, since The doc comment is thorough about trailing commas and whitespace but never names this tradeoff. Given how carefully everything else here is caveated, I read that as an oversight rather than a dodge. I want to be clear this is bounded, which is why it's 🟡 and not 🔴: the corpus's enum values are snake_case ( Recommendation: minimally, name the tradeoff in the doc comment — that a comma inside a single intended value is unrecoverable here, and the repair accepts that because Engineering principle: Make the tradeoff explicit at the decision site. A lossy transform is fine when chosen deliberately; the failure is when a future reader can't tell whether the loss was considered. 🟢 Suggestion:
|
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: REQUEST CHANGES (posted as a comment — GitHub blocks self-review verdicts). Full findings in the review comment above.
Blocking, narrowly, on one finding: repair_scalar_in_operator_values' doc comment claims it "needs no user-data denylist" because content/field_values hold no operator sibling. field_values is a free-form user-defined-schema object, so a user type with fields named operator and value puts user data squarely in range — verified: {"field_values":{"operator":"in","value":"Acme Corp, Ltd"}} is rewritten to ["Acme Corp","Ltd"] inside a write tool. Scope to the filters slot and add the negative test that's currently missing.
Everything else is above bar — the measurement discipline, the arm isolation (verified mechanically), and the runner's emitted-vs-repaired split are all good work.
Review of #2183 caught a real bug behind a comment I wrote. The repair keyed on `operator == "in"` and recursed everywhere, and the doc comment claimed that needed no user-data denylist because `content`/`field_values` carry no `operator` sibling. They can: `field_values` holds the fields of a USER-DEFINED schema and `create_schema` reserves no field names, so a type with fields named `operator` and `value` hits the shape exactly. Verified against the real function before changing it: before: {"field_values":{"operator":"in","value":"Acme Corp, Ltd"}} after : {"field_values":{"operator":"in","value":["Acme Corp","Ltd"]}} Stored user data silently rewritten, inside a write tool, with no error. Fixed by inverting to an allowlist: the entry point descends only into `filters`, the one parameter whose contents are the model's structural choices rather than the user's data. That is the shape `repair_spliced_object_values`' own comment recommends when a denylist would otherwise have to grow — a tool added later with a free-text parameter is out of range automatically instead of in range until someone remembers to exclude it. The existing negative test looked like it covered this but its entries carried no `operator` key, so it asserted a property the code did not have. Replaced with one that reproduces the real shape, plus coverage that a bare filter-shaped object at the top level is out of range and that the `filters` slot still works. Also from review, all three the same class of "state the thing that is true": - Name the comma-splitting tradeoff. A stored value legitimately containing a comma ("Acme, Inc.") is split into members matching nothing, and that failure is SILENT where the one being repaired is loud. Accepted with reasons stated, not left unmentioned in an otherwise heavily-caveated comment. - Record the divergence in goldens/dev-unseen-schema.toml, which still declares `value` as a bare string. Left as-is rather than corrected: changing it changes what the model sees and invalidates that case's own #2122 results. Verified notes-only via --check (model-visible input byte-identical). - Note that canonical_args feeds the PERSISTED write guard, so changing the repair set is not a pure refactor — identities recorded before a change do not match those computed after it. Refs #2182 Co-Authored-By: Claude <[email protected]>
Review nit: the comment argued a single-member `in` should be wrapped because it is "still an array by the schema's own declaration". That is the weaker reason. The one that actually retires the concern — whether the wrap masks a model that meant `equals` and wrote `in` — is that IN (x) and = x select the same rows, so the wrap cannot change the result set whichever operator was intended. Refs #2182 Co-Authored-By: Claude <[email protected]>
Address-review summaryAll five findings addressed. Commits 🟡 #1 — "needs no user-data denylist" claim was false — FIXEDYou were right, and I verified it against the real function before changing anything rather than reasoning about it: Stored user data silently rewritten, inside a write tool, with no error. Fixed by inverting to an allowlist, per your recommendation: the entry point ( Doc comment rewritten to record the false claim and why it was false, so the next person doesn't re-derive it. Test gap fixed too. You correctly identified that 🟡 #2 — comma-splitting tradeoff unacknowledged — FIXED (comment, the option you said you'd accept alone)Named it explicitly in Took the comment-only option rather than the enum-gating one — gating on "known-enum" needs schema knowledge the repair doesn't have at that point, and would be more machinery than the bounded risk justifies. 🟢 #3 —
|
Pragmatic Code Review — Re-Review (delta
|
| count | |
|---|---|
| Findings in original review | 5 (1 blocking 🟡, 1 🟡, 3 🟢) |
| Properly addressed | 5 |
| Not addressed / partially addressed | 0 |
| New issues introduced by the delta | 0 blocking (1 🟢 nit) |
Delta is 162 insertions / 30 deletions across two files. Nothing outside the review's scope was touched.
The test-weakening question (the author's own flag)
The author asked to be checked on this specifically, so I did not take the summary at face value. I extracted the old implementation verbatim from 9e982446 and the new one from HEAD into a standalone differential harness and ran every test payload — old form and new form — through both. This is evidence, not a reading of the diff.
Q1: Does the new negative test reproduce the vulnerability, and would it fail against the OLD implementation?
Yes, conclusively. in_operator_repair_never_touches_user_authored_field_values asserts v == original. Under the old code:
in : {"field_values":{"nested":{"operator":"in","value":"a,b"},
"operator":"in","value":"Acme Corp, Ltd"},...}
OLD : {"field_values":{"nested":{"operator":"in","value":["a","b"]},
"operator":"in","value":["Acme Corp","Ltd"]},...} changed=true
NEW : (byte-identical to input) changed=false
The assertion is false under OLD on both the top-level and nested field — a genuine regression test, not a tautology.
Q2: Were the two rewritten tests weakened to fit the implementation?
This is where I expected to find the problem. Honest answer: no — but with a real, acknowledged loss of a property, correctly compensated.
in_operator_values_are_trimmed_and_single_values_are_wrapped previously fed bare filter-shaped objects, which are deliberately out of range now:
OLD test form (bare object) under NEW: "cut, soak , shipped"
OLD : {"operator":"in","value":["cut","soak","shipped"]} changed=true
NEW : {"operator":"in","value":"cut, soak , shipped"} changed=false
The old test could not have passed unchanged — the rewrite was forced, not opportunistic. All three cases survive verbatim with identical expected outputs; only the wrapping envelope changed. Zero assertions dropped or loosened, and the closure is arguably stronger because it exercises the real entry point rather than a shape production never produces.
For in_operator_repair_leaves_everything_else_untouched, the only removal is a comment stating the now-falsified denylist claim. The payload is unchanged and produces changed=false under both versions — it never discriminated them, and its coverage is genuinely unaltered.
One property genuinely was lost: the old bare-object cases incidentally proved the repair worked on a filter item regardless of where it sat. The new scoping makes that untrue by design. The compensating assertion — "the slot that IS in range still works" — is present. Net: coverage stronger, not weaker.
Q3: Does scoping to filters miss a real path?
Enumerated all 15 def_* tool definitions and extracted every filter-shaped parameter:
search_nodes—filters, top-level, array of filter items. Covered.search_semantic—property_filters, a flat{"status":"done"}map with nooperatorkey by schema. Never in range of the old repair either. Not a regression.resolve_query— exposes onlyrequestandnode_typeto the model; nofiltersparameter reaches it. Its filters come from an internal sub-LLM decomposition, which never passed through the repair pipeline before or after this PR. Neither newly covered nor newly missed (see 🟢 below).- Other 12 tools — no filter parameter.
Also probed adversarial shapes: filters nested under another key, top-level args as an array, and filters as a bare object. The last is handled (the walker matches Value::Object as well as Value::Array). The first two are out of range but correspond to no declared schema and wouldn't deserialize into AgentFilterItem anyway.
Conclusion: filters is always top-level for the one tool that declares it. No real path is lost.
Per-finding verification
🟡 #1 — denylist claim — PROPERLY ADDRESSED ✅ (agent_loop.rs:497-503, :512-535)
True allowlist: entry point does as_object_mut() → get_mut("filters") → delegate. A tool added later with a free-text parameter is out of range by default. It is the exact inversion repair_spliced_object_values' own comment recommends — the codebase now practices what one of its comments preaches. The doc comment records the false claim and why it was false rather than silently deleting it, so the next person tempted by the shape-keyed version finds the counterexample instead of re-deriving it. I verified the corrected comment does not repeat the previous round's failure mode: every claim in it is checkable and checks out.
🟡 #2 — comma tradeoff — PROPERLY ADDRESSED ✅ (agent_loop.rs:549-561)
States the loss, correctly identifies the asymmetry (silent here vs. loud for the repaired bug), gives three grounds for acceptance, and names the revisit condition. Declining enum-gating is well-reasoned — the repair genuinely has no schema knowledge at that point. Note the allowlist from #1 materially shrinks this risk rather than just documenting it; one change retired two findings.
🟢 #3 — golden divergence — PROPERLY ADDRESSED ✅ (dev-unseen-schema.toml:54-75)
I verified the notes-only claim independently rather than trusting --check: git diff --numstat shows 22 0, and a structural comparison stripping the notes block confirms all other content byte-identical. Cross-checked against golden/case.rs:368, which documents notes as excluded from normalize() and not fed to the model. No re-measurement is owed.
🟢 #4 — canonical_args reasoning — PROPERLY ADDRESSED ✅ (agent_loop.rs:140-148)
Added at the code, not just the PR body — better than what I asked for. Bounds the blast radius honestly and lands the point that matters: a real consequence a future repair inherits, not a pure refactor.
🟢 #5 — one-element wrap — PROPERLY ADDRESSED ✅ (agent_loop.rs:472-477)
New Findings
🟢 Nit: stale schema-conformance wording in a test doc comment — 📁 agent_loop.rs:7720-7721
Finding #5 replaced the weaker argument in the production comment, but the test comment still carries the old spelling. Cosmetic; since #5's whole point was that this is the weaker argument, leaving it in the test comment is a small inconsistency a future reader could pick up from the wrong place.
🟢 Observation (not a finding): resolve_query's decomposition filters bypass the repair pipeline — 📁 tools.rs:2094-2118
Surfaced while auditing Q3. Explicitly not a regression from this PR — equally uncovered at 9e982446. Two mitigations make it low-priority: the decomposition prompt only ever instructs equals and date operators, never in; and unparseable filters are dropped with a tracing::warn! rather than failing the turn. Follow-up issue at most.
Verification Performed
| check | result |
|---|---|
cargo test -p nodespace-agent --lib |
529 passed, 0 failed, 1 ignored — matches the author's claim |
| Differential old-vs-new harness (16 payloads) | New negative test fails under OLD, passes under NEW |
Golden --numstat + structural non-notes comparison |
22 0; non-notes content byte-identical |
Tool-schema audit, all 15 def_* functions |
filters declared by search_nodes only, always top-level |
| Repair call-site audit | 4 call sites, all funnel through repair_parsed_tool_arguments |
Recommendation
APPROVE
Both blocking items landed, and the fix for 🟡 #1 is better than the one I proposed — the allowlist closes the user-data exposure and shrinks the surface of 🟡 #2 as a side effect.
On the question the author raised against himself: I went looking for a weakened test and did not find one. The rewrite was forced by the scoping — the old payloads provably cannot pass under the new implementation — and every assertion survived intact with identical expected values. The new negative test demonstrably fails against the pre-fix code, which is what makes it a regression test rather than decoration. The one property that could not be retained is correctly compensated by the explicit "the slot that IS in range still works" assertion, which is precisely the guard against scoping silently disabling the repair.
Raising the concern rather than letting the summary stand on its own was the right instinct, and it checks out.
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review): APPROVE — posted as a comment since GitHub blocks self-approval. All 5 findings from the initial review verified properly addressed, 0 outstanding. Differential harness confirms the new negative test fails against the pre-fix implementation, so it is a genuine regression test; the rewritten tests were forced by the scoping change, not weakened. Full verification in the review comment above.
Re-review nit: the production doc comment swapped schema-conformance for the semantic argument (IN (x) and = x select the same rows), but the test comment still carried the weaker spelling. Since the point of that swap was that schema-conformance is the weaker reason, leaving it here let a reader pick it up from the wrong place. Refs #2182 Co-Authored-By: Claude <[email protected]>
|
Both optional items from the re-review are handled:
Pre-push gate green on Not merging — that's your call. |
Closes #2182.
What the measurement found — two corrections to the issue's framing
I traced and then measured before choosing a fix, and both of the issue's central claims turned out to be wrong. Recording that rather than quietly building around it, because each one changes what the right fix is.
1. A scalar
invalue is not a silent zero-result — it fails loudlyThe issue argues a bad filter is worse than a bad write because it "returns zero results, indistinguishable from a genuinely empty result". It doesn't. At
packages/core/src/services/query_service/mod.rs:454:A non-array
invalue is anErr, propagating asOpsError::Internal("execute_query failed: In requires array value")and surfacing to the model as a tool error. The turn fails visibly; nothing hides insidedev-empty-result-query. Pinned by a new test (test_property_filter_in_rejects_a_scalar_value) because the distinction decides how much machinery the defect justifies.2. Production's schema is not being ignored — it's what makes
inworkThe issue says the model ignores both the
arraytype union and the "Use array for 'in' operator" description. Two ablation arms differing in only that declaration, 3 reps each, byte-identical within each arm:valuedeclared asin-operator-array-elicitedarray"value":["cut","soak"]✅ 3/3in-operator-string-declaredtype = "string""value":"cut,soak"❌ 3/3The declaration is the cause. Production already carries the union. The issue's evidence came from
goldens/dev-unseen-schema.toml, which declaresvalueas a baretype = "string"— so"cut,soak"there was the model complying with the schema in front of it, not defying it. The defect was in the measurement corpus, not the shipping schema.This also means the acceptance criterion "
inreceives an array, measured at ≥3 reps ondev-unseen-schema(currently 0/3)" rests on a case that cannot answer it. Measured against production's declaration, it is already 3/3.A third finding: the first arm never reached its own question
Built faithfully to the issue's repro (production's
valuedeclaration, the issue's user message "What releases do we have open?"), the model answered 3/3 with:No filters at all — so no
in, novalue, nothing measured. That reads as a pass if you only check "did the turn look right". The arm is kept (in-operator-array.toml) with that recorded as its result, and the elicited arm changes only the user message so a multi-value filter is actually reachable. It also means the issue's reported"cut,soak"came from a prompt that pushed the model toward filters first — consistent with the third, uncommitted-filter-rulearm.What this changes
repair_scalar_in_operator_values(agent_loop.rs) — when a filter carriesoperator: "in"and a scalar stringvalue, the string is split into the array the operator requires. It joins the existing repair set at the single entry point, so it reaches both the parse boundary and the execution backstop, and participates incanonical_argsso a malformed call and its repaired retry share one identity.It is deliberately framed as a backstop, not the mechanism. The declaration is what produces the right shape; this exists because a declaration is not a guarantee and the downstream contract is strict. It is measured converting real model output on the failing arm, 3/3 — not a hand-written fixture — so it isn't speculative, but it is not credited with recovering a case that was not failing.
It's also narrower than its siblings: keying on
operator == "in"means it needs no user-data denylist, sincecontentandfield_valuescarry nooperatorsibling and are therefore never in range.Two fixes to the measurement apparatus, both of which were prerequisites for the finding above and are worth keeping:
[emitted, before repair: …]when repair changed something. Without this the control arm and the elicited arm would have produced the same line.canonical_argsre-listed the repair set by hand instead of callingrepair_parsed_tool_arguments, despite that function's own doc calling itself "the one place the set of malformations is listed". A repair added later reached execution but silently not the identity, so the two sides would disagree about whether a call and its retry were the same call. Now routed through the shared entry point.Comments corrected at both sites.
tools.rs's note besidevaluenow records that forinthe union is what works, so nobody narrows it later on the theory that the model ignores it.Ablation README gains the two generalisable lessons: an arm can fail to reach its own question, and repaired output is not emitted output.
Acceptance criteria
inreceives an array, measured at ≥3 reps — 3/3 with production's declaration (in-operator-array-elicited), and 3/3 after repair even with the failing declaration (in-operator-string-declared). Measured on a case that actually elicits aninfilter, sincedev-unseen-schemaas committed does not — see above.dev-status-change-enumdoes not regress — guaranteed by construction rather than by measurement: the fix changes zero prompt bytes and zero tool-schema bytes, so that case's input is byte-identical. This is the specific reason the parse-boundary repair was chosen over the prose and schema-reshaping options, given the issue's own record of a generically-worded rule making that case worse.exec_search_nodesandQueryServicealready expect. No parameter added, removed, or renamed.Testing
bun run test:all— all suitesok, zero failures; frontend at baseline (227 files / 4789 tests)bun run quality:fix— clean (0 errors, 0 warnings, clippy-D warningspasses)IN ()), 2 on the runner's emitted/repaired reporting, 1 on the downstream rejection🤖 Generated with Claude Code
https://claude.ai/code/session_01TDtMcV2chVWTDbMFerp5Vs