Repository navigation
Fix narrated-call false positive and schema-recovery/recency-injector starvation (closes #2261) - #2266
Conversation
The own-line admission accepted a tool name immediately followed by
`{` at the start of a line, reasoning that a narrated call writes its
arguments flush against the name while documentation puts a space
there. That distinction doesn't hold for a model's own report of a
completed write inside fenced JSON — ordinary formatting omits the
space too (`create_node{"content":"Buy milk"}`), and every existing
regression test for the own-line case used the spaced form, so this
false positive went undetected. Removed the admission; only an
explicit marker (call:, tool:, >>>) is now accepted.
Found in a post-merge audit of #2257 (#2261).
`append_schemas_named_in_query` (an unbounded lexical backstop for schemas the embedding debounce hasn't indexed yet) and the recently- created-schema injector in local_agent_service.rs both write into WorkspaceContext.relevant_schemas, but the injector computed its remaining budget from the vector's post-append length. A turn naming several existing schemas by name could exhaust that budget before the injector ever ran, silently dropping a type the user had just created in the same turn — even though semantic search itself found nothing. Added semantic_schema_count to WorkspaceContext, captured before the lexical append runs, so the injector's budget is computed against what semantic retrieval actually returned rather than a total blind to who wrote what. Found in a post-merge audit of #2257 (#2261).
Missed by the earlier grep for WorkspaceContext literals, which only covered context_ops.rs — this construction lives in an integration test in a different crate.
Review Type: Initial ReviewRequirements Check (issue #2261)
All five stated acceptance criteria are met by the diff. Code Review Findings🟢 Finding 1 — narrated-call detector: fix is correct, tradeoff is real but well-reasoned
Removing the I checked for other call sites depending on the removed branch — One soft note, not a blocker: the fix intentionally narrows detection to explicit markers, so a narrated call with no marker and no space (e.g. a model literally writing 🟢 Finding 2 — semantic_schema_count capture point and injector fix: correct
Traced the full Checked every On the hydration step (
🟡 Test quality: the new context_ops.rs regression test is real but narrow — doesn't exercise the actual starvation path end-to-end
This test is not tautological — it does pin a real invariant ( But it stops one level short of the bug described in the issue and in this PR's own commit message. The actual failure mode is: recency injector fails to inject a schema it should have, because There is no test anywhere in this diff (searched 🟢 Stale comment fix: accurate
The replacement comment correctly states the injector is now "Budgeted against Nitpicks
Recommendation: APPROVEBoth fixes are correctly targeted at the root causes identified in issue #2261, the reasoning in the code comments and commit messages is unusually thorough and self-auditing (including the third commit fixing the author's own missed call site), and all five acceptance criteria are satisfied. The one substantive gap — the new regression test for Finding 2 pins an arithmetic invariant rather than the end-to-end injector behavior — is a real but non-blocking test-quality improvement, not a correctness issue in the shipped code; the fix itself is independently verified correct by tracing the full data flow. Nothing here should hold up merge. |
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.
Pragmatic Code Review — PR #2266Review Type: Initial review (no prior reviews or comments on this PR — all three commits reviewed in full) Requirements Check (issue #2261 acceptance criteria)
The issue's three explicitly-deferred lower-severity items (Node Creation target resolution, the double Code Review Findings🟢 Finding 1 — Removing the own-line admission does not regress any detected shape (verified)The brief asked whether any other call site or test relied on
Zero positive assertions depended on the removed disjunct, and Nit: the detector is now unreachable for any unmarked brace shape, so 🟢 Finding 2 —
|
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval).
Both fixes are correct and minimal. Verified: no positive narrated-call detection case relied on the removed own-line branch (all use parens, markers, or the quoted JSON name key); semantic_schema_count is captured at the correct point with all seven WorkspaceContext construction sites across the workspace updated; the corrected comment is accurate.
One non-blocking follow-up — the new regression test lexical_append_does_not_retroactively_inflate_the_semantic_count asserts a test-local against a constant rather than pinning the production invariant, so reverting local_agent_service.rs:2334 would leave the suite green. Full findings in the preceding comment.
Two items from the pragmatic-code-review of this PR: - The prior regression test for the starvation fix pinned arithmetic correctness (semantic_schema_count is captured before, and stays untouched by, the lexical append) but never drove the actual injector code path in local_agent_service.rs. Added lexical_backstop_does_not_starve_the_recency_injector, which creates six schemas (five named outright in the query, one not), asserts the unnamed one still reaches the rendered context, and was confirmed to fail against the pre-fix `relevant_schemas.len()` budget before being checked in against the fix. - Clarified semantic_schema_count's doc comment: it is an upper bound on the true final semantic-sourced count, not always exact, since hydration can drop a retrieval hit that no longer resolves in the full schema corpus. Noted the error direction is harmless (more conservative, never the starvation this field prevents). Skipped: cross-referencing MAX_SCHEMAS (local_agent_service.rs) and MAX_SEMANTIC_SCHEMAS (context_ops.rs), which the review flagged as sharing a value (5) with no shared definition. Each constant is already independently justified in its own doc comment for its own call site; a cross-reference would guard against a coincidence, not a defect — not worth the coupling for a one-line nit.
Address-Review SummaryAddressed the findings from the initial pragmatic-code-review. ✅ Addressed
⏭️ Skipped
Verification
Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: Both changes are additive and low-risk — one new test (verified against both the buggy and fixed code paths to confirm it actually pins the regression) and one doc-comment clarification with no logic change. No production code paths were modified; The PR is ready for merge, pending the user's decision. |
Summary
Two findings from a post-merge audit of #2257 (filed as #2261), both root-caused independently rather than accepted at face value:
Narrated-tool-call detector discards a correct answer.
looks_like_narrated_tool_call's own-line admission accepted a tool name immediately followed by{at the start of a line, on the theory that a narrated call writes its arguments flush against the name while documentation puts a space there. That distinction doesn't hold for a model's own honest report of a completed write inside fenced JSON — ordinary formatting omits the space too (create_node{"content":"Buy milk"}), and every existing regression test for the own-line case used the spaced form, so this false positive went undetected through three prior review passes. Removed the admission entirely; only an explicit marker (call:,tool:,>>>) is now accepted.Lexical schema backstop can starve the recency injector.
append_schemas_named_in_query(an unbounded lexical backstop recovering schemas the ~30s embedding debounce hasn't indexed yet) andlocal_agent_service.rs's recently-created-schema injector both write intoWorkspaceContext.relevant_schemas, but the injector computed its remaining budget from the vector's post-append length. A turn naming several existing schemas by name could exhaust that budget before the injector ever ran, silently dropping a type the user just created in the same turn — even when semantic search itself found nothing. Addedsemantic_schema_counttoWorkspaceContext, captured before the lexical append runs, so the injector's budget reflects what semantic retrieval actually returned rather than a total blind to who wrote what.Test plan
cargo test -p nodespace-agent --lib narrated_tool_call— 13/13 pass, including new unspaced-fenced-JSON regression casescargo test -p nodespace-core --lib context_ops— 40/40 pass, including newlexical_append_does_not_retroactively_inflate_the_semantic_countcargo test -p nodespace-core --lib— 1199/1199 passcargo test -p nodespace-daemon --lib— 162/162 passcargo test -p nodespace-agent --lib— 577 pass, 1 pre-existing ignoredbun run quality:fix— clean, no unrelated reformattingbun run test:all— 227/227 frontend files, all Rust suites 0 failed (one run hit the knowncore-plugins.test.ts5s-timeout flake under machine load; documented in Narrated-call detector still discards a correct answer, and the schema-recovery backstop can starve the recency injector #2261's baseline comment, not a regression — passed clean on retry)scripts/test-gate.ts), includingcargo test -p nodespace-appTauri-seam integration testsCloses #2261.
🤖 Generated with Claude Code