Repository navigation
Fix find_skills reading skill node properties flat instead of hoisted properties.skill.* - #1893
Conversation
…sted properties.skill.* shape (closes #1867) `skill` has a registered core schema (ADR-030), so NodeService hoists its schema-defined fields under properties.skill.* on write, same as task under properties.task.*. find_skills read description/tool_whitelist/ node_types flat, so every seeded skill's tool_whitelist came back empty regardless of retrieval score — stage2_tools's permitted set was always empty, silently falling back to the full tool surface (minus resolve_query, which requires routed guidance) on every turn. Routing looked like it was working (a skill name still surfaced in routed_skills logs) while never actually scoping the tool surface or supplying resolve_query's entity-type guidance. Verified live: toolsOffered now correctly reflects each routed skill's whitelist, and resolve_query reaches the offered surface when Graph Editing routes and clears the mutating-skill score bar (previously never observed in 9/9 pre-fix runs). Scenario 6 still doesn't pass end-to-end — the model doesn't call the now-offered tool — but that's a separate model-behavior gap now that the tool is actually reachable. Co-Authored-By: Claude <[email protected]>
malibio
left a comment
There was a problem hiding this comment.
Code Review Summary
Small, well-scoped fix for a real and impactful bug. find_skills read description/tool_whitelist/node_types flat off node.properties, but skill is a core-schema type (ADR-030) whose fields NodeService hoists to properties.skill.* on write — confirmed directly against normalize_flat_properties_to_namespace (crud.rs:1681) and its own test reseed_replaces_skill_tier_node_with_real_schema_fields (node_service/mod.rs:5087), which asserts exactly this shape. The practical effect (every seeded skill's tool_whitelist reading empty → stage2_tools falling back to the full, resolve_query-excluded tool surface on every turn while still looking like routing worked) is a legitimate, high-value fix — this is a correctness bug in a hot path, not a cosmetic one.
The fallback pattern (properties.get("skill").unwrap_or(properties)) mirrors the existing, established task-property lookup in behaviors/mod.rs:681 almost exactly, so it's consistent with codebase convention rather than inventing a new one. Extraction into SkillProperties::from_node_properties is a clean, minimal refactor — same behavior for the two properties that already worked correctly plus the fix, with no unrelated churn. Diff is atomic (single file, single concern). Net positive; recommend approval with one non-blocking edge case flagged below and a question about the "verified live" claim's evidentiary weight.
Findings
Critical Issues
None.
Suggested Improvements
-
packages/core/src/ops/skill_ops.rs—SkillProperties::from_node_properties, theunwrap_orfallback has a silent-failure edge case.properties.get("skill").unwrap_or(properties)only substitutes the flat top level when the"skill"key is absent (None). Ifproperties.skillis present but explicitlynull(or any non-object scalar),Option::unwrap_orstill returnsSome(&Value::Null), soskill_propsbecomesValue::Null, and every subsequent.get(...)on it returnsNone— silently discarding any flat data that might exist alongside it, rather than falling back to it. I verified this empirically:{"skill": null, "description": "x", "tool_whitelist": [...]}decodes to emptydescription/tool_whitelist, not the flat values. I traced whether this is reachable throughNodeService's real write path (normalize_flat_properties_to_namespace,crud.rs:1681) and confirmed it is not — hoisting always either leaves an already-namespaced object alone or inserts a fresh{}object under the type key, nevernull. So this can only arise from a hand-constructed or raw-store-written node with a malformedskill: nullproperty, which is an edge case the PR's own doc comment already scopes as "predates hoisting or constructed directly." Given that, this is a robustness nit, not a live bug:.get("skill").filter(|v| v.is_object()).unwrap_or(properties)would close it for near-zero cost and match the "belt and suspenders" spirit already invested in this helper, but I would not block on it. -
Same flat-vs-hoisted risk may exist elsewhere but wasn't audited exhaustively in this PR. I grepped for other direct
node.properties.get(...)reads outsidebehaviors/mod.rs(which already has the correcttask/fallback pattern) and foundProjectNodeBehavior::validate(behaviors/mod.rs:810) readsnode.properties.get("project")with no flat fallback at all — ifprojectis also a core schema with hoisted fields, a node "constructed directly" (e.g., in tests, or any raw-write path) with flatprojectproperties would fail this validation's type checks silently (they'd just find nothing and skip validation, since the checks areif let Some(...)). This is out of scope for this PR (different file, different type, not touched by the diff), but since the PR explicitly frames this as a general "flat vs. hoisted" class of bug, it's worth a follow-up issue to sweep for other instances rather than treating this fix as fully closing the class. Worth noting as a candidate for the same follow-up issue being filed for the resolve_query invocation gap. -
The "verified live" claim is understated in what it can and can't prove, but the PR is appropriately honest about this. The PR correctly does not claim any automated test covers the live daemon+model path — the unit tests are pure
SkillPropertiesdecoding tests, and the "verified live" evidence is a manual trace-file comparison (toolsOfferedcontainingresolve_querypost-fix vs. never pre-fix across preserved runs). That's reasonable substantiation for a bug whose blast radius is "wrong data reaches a live routing decision," and re-deriving it from first principles (the hoisting code + its own test) independently corroborates the root cause without needing to trust the trace-file comparison alone. No action needed here — flagging only because the review was asked to assess it specifically: the claim is adequately supported by the combination of (a) an independently reproducible root cause in the hoisting code, and (b) the before/after trace diff, even though neither alone is a regression test that runs in CI.
Nitpicks
- Nit:
packages/core/src/ops/skill_ops.rs—SkillPropertiesdoesn't deriveDebug/PartialEq; the tests instead assert on individual fields (props.description,props.tool_whitelist, ...). Deriving both would let the three new tests collapse to a singleassert_eq!(props, SkillProperties { ... })per case, marginally more readable and future-diff-friendly. Not worth a revision on its own. - Nit: the doc comment on
SkillProperties::from_node_propertiesis long (13 lines) relative to the method it documents (20 lines) — informative and clearly explains the "why," but could be trimmed to the hoisting fact + the one-line rationale for the fallback without losing anything a future reader needs.
Issue #1867 acceptance criteria assessment
Of the four criteria:
- "Determine whether
resolve_queryis offered at all on the scoped path" — answered: it wasn't, becausetool_whitelistalways decoded empty regardless of score. - "Distinguish withheld vs. offered-but-not-chosen" — answered: this PR establishes it was withheld (a data bug), not a model preference problem, for the specific case of skill-scoped routing.
- "Fix so an indirect-target update resolves before it mutates" — the property-read fix is a necessary precondition (the skill's tool whitelist and entity-type guidance now actually reach the model), but the PR's own text confirms the model still doesn't reliably call
resolve_queryeven once correctly offered (it hallucinates a node id instead) — so this criterion is only partially satisfied. The literal wording ("fix so an indirect-target update resolves before it mutates") is not yet true end-to-end. - "Scenario 6 passes across repeated runs" — explicitly not met, and the PR description says so plainly rather than glossing over it.
Given that, closing #1867 outright with this PR would be premature — criteria 1 and 2 are cleanly answered, but 3 and 4 are not met, and the remaining gap is a distinct, non-trivial problem (model guidance/behavior, not data plumbing) that deserves its own issue rather than being silently absorbed as "close enough." The PR title/body already frame this correctly (they describe the fix as necessary-but-not-sufficient and mention filing a follow-up), so the right process action is: merge this PR as the incremental, root-caused fix it is, but do not close #1867 — either keep it open re-scoped to the remaining model-behavior gap, or close it only once the follow-up issue exists and is linked, so the "scenario 6 passes" criterion has a tracked owner. If the follow-up issue doesn't exist yet at merge time, that should happen before or immediately after merge, not left implicit.
Verification performed
cargo test -p nodespace-core --lib— 1079 passed, 0 failed (matches PR's stated test plan).cargo test -p nodespace-core --lib ops::skill_ops— all 9 tests (3 new + 6 pre-existing) pass in isolation.cargo clippy -p nodespace-core --lib— clean, no warnings.- Cross-checked the hoisting mechanism directly (
normalize_flat_properties_to_namespace,crud.rs:1681) and its existing regression test (node_service/mod.rs:5087) to independently confirm the root-cause claim rather than taking the PR description at face value. - Empirically reproduced the
unwrap_orfallback'snull-key edge case with a throwaway probe test (not committed) to confirm the exact failure mode described above, then traced whetherNodeService's real write path can ever produce that shape (it cannot). - Grepped for other flat
node.properties.get(...)reads to check for the same bug class elsewhere; found one candidate (ProjectNodeBehavior, out of scope for this PR).
…to ProjectNodeBehavior, derive PartialEq for terser tests
- skill_ops.rs: `properties.get("skill").unwrap_or(properties)` treated a
present-but-null "skill" key as "the namespace exists," silently
discarding flat data instead of falling back to it. Guard with
`.filter(|v| v.is_object())`. Not reachable through NodeService's real
write path, but closes the gap for a hand-constructed or raw-written
node. Derived Debug/PartialEq on SkillProperties so the three existing
tests assert on the whole struct instead of field-by-field, and added
a test for the null-key case.
- behaviors/mod.rs: ProjectNodeBehavior::validate had the identical bug
class find_skills did — `project` is a schema-typed node type hoisted
under properties.project.* the same way, but the validator read it
flat with no fallback at all, so a project node with unhoisted flat
properties silently skipped all status/priority/date validation rather
than checking the flat data. Fixed with the same nested-first/
flat-fallback pattern already used for `task` in this file (with the
null-guard from the skill_ops.rs fix, which the existing task lookup
lacks — left that one alone since it's explicitly scoped as a
backward-compat fallback for a narrower path). Added a regression test.
Skipped (reviewer flagged, not applied):
- Trimming SkillProperties's doc comment further — already tightened it
while adding the null-guard; the remaining length carries the "why",
not restating the "what".
Addresses reviewer recommendations from PR #1893 review.
Co-Authored-By: Claude <[email protected]>
Addressed review feedback
Process action takenFiled #1894 for the remaining model-behavior gap (tool now offered, model still doesn't call it) per the reviewer's recommendation not to close #1867 outright. Commented on #1867 with the full acceptance-criteria breakdown and linked #1894. Verification
Re-Review DecisionNO RE-REVIEW NEEDED. All changes are straightforward, low-risk, and directly match patterns already established in the file (the |
Summary
find_skillsreaddescription/tool_whitelist/node_typesfromnode.propertiesflat, butskillhas a registered core schema (ADR-030), soNodeServicehoists its schema-defined fields underproperties.skill.*on write — the same namespacingtaskgets underproperties.task.*.tool_whitelistcame back empty regardless of retrieval score, sostage2_tools'spermittedset was always empty and every turn silently fell back to the full tool surface (minusresolve_query, which requires routed guidance and is excluded on that fallback path). Routing looked like it was working — a skill name still showed up inrouted_skillslogs — while never actually scoping the tool surface or supplyingresolve_query's entity-type guidance.properties.skillfirst, falling back to the flat top level for a node that predates hoisting or is constructed directly (matching the existingtask-property lookup pattern inbehaviors/mod.rs). Extracted into a smallSkillProperties::from_node_propertieshelper with direct unit-test coverage (hoisted shape, flat fallback, missing-entirely defaults).Investigation (closes #1867)
#1867 asked whether
resolve_queryis withheld even on the scoped routing path where it should be offered. Traced throughrouting::tools_with_available_guidance→skill_ops::find_skills, confirmed live against a purged/isolated daemon withRUST_LOG=debug, and cross-checked against the preserved trace files from #1862's investigation (toolsOfferednever containedresolve_queryin 9/9 runs, even the 8/9 where Graph Editing routed first).Root cause: the flat-property read above. Verified live post-fix:
toolsOfferednow correctly reflects each routed skill's actual whitelist, andresolve_queryreaches the offered surface when Graph Editing routes and clears the mutating-skill score bar — something never observed pre-fix.Scenario 6 in the agent-matrix eval still doesn't pass end-to-end: with
resolve_querynow actually offered, the model still doesn't call it (it hallucinates a node id and claims success instead). That's a separate, model-guidance problem now that the tool is reachable — filing as a follow-up rather than expanding this fix's scope.Test plan
cargo test -p nodespace-core --lib ops::skill_ops— new unit tests forSkillProperties::from_node_properties(hoisted shape, flat fallback, empty)cargo test -p nodespace-agent -p nodespace-core --lib— 1079 + 401 passed, no regressionsgemma-4-e4b-q4km,RUST_LOG=debug, confirmedtoolsOfferedincludesresolve_querywhen Graph Editing routes (previously never observed)bun run quality:fix— cleanbun run test:allvia pre-push gate — passed (one pre-existing timestamp-equality flake reproduced transiently under load, confirmed unrelated by isolated re-run, cleared on retry)🤖 Generated with Claude Code
https://claude.ai/code/session_01DkqjrfV1G6kugsEjvyU9wU