Repository navigation
Emit flat node properties from the CLI (closes #2381) - #2423
Conversation
Pragmatic Code Review — PR #2423Type: Initial Review (no prior reviews) SummaryThis is a genuinely good change. The diagnosis is right, the framing is right, and the resistance to the easy fix (documenting the leak) is exactly the right instinct — the issue is a real correctness bug, not a docs gap, and the PR treats it as one. The flattening logic is a faithful mirror of Two findings block merge. Both are completeness, which the issue explicitly calls out as the one thing that must not be left half-done:
Neither is a flaw in the flattening rules as written. Both are paths the change didn't reach. Findings🔴 Critical1.
|
| # | Criterion | Status |
|---|---|---|
| 1 | Nesting not observable anywhere on the CLI surface | ❌ relationship get --json (finding #1) |
| 2 | All read paths apply the flat contract, incl. "any other command emitting a node" | ❌ relationship get (finding #1) |
| 3 | Both human-readable and --json covered |
✅ output.rs:69-78 and :148 |
| 4 | jq '.properties.foo' works with no second parse |
✅ |
| 5 | _-prefixed internals absent |
✅ both branches, tested |
| 6 | Storage stays namespaced, no change at rest | ✅ asserted in the integration test |
| 7 | Input and output agree on bare field names | ✅ for scalar fields; --property is not readable back (finding #2) |
| 8 | SKILL.md shows populated flat properties |
✅ SKILL.md:298-316 |
| 9 | references/cli.md documents the --json shape |
|
| 10 | Verified against a core type and a user-defined type | ✅ task + venue, end-to-end against the real stack |
| 11 | Nothing left half-done | ❌ findings #1 and #2 |
What's good
Worth stating plainly, because the parts that are right are the hard parts:
- The diagnosis is the contribution. Recognizing this as a broken contract rather than a docs gap — and refusing to document the nesting, which would have enshrined it — is the judgment call the whole issue turned on.
- The integration test asserts both halves at once. Storage nested and output flat, in one test, against the real service stack. A test that only checked the output would pass if someone "fixed" this by flattening at rest, which the issue explains is unsafe (colliding
_seed/skillnamespaces). This test would catch that. - Every test comment says why, not what.
node_to_json_flattens_namespaced_properties_to_bare_field_namesexplains the "status unknown" failure mode it prevents. That's the difference between a test that survives a refactor and one that gets deleted as noise. - The duplication decision was made deliberately and documented at both sites, rather than happening by accident. My objection in Desktop shell with resizable panels #3 is only that documentation isn't enforcement — not that the call was wrong.
1adef8a3is exactly the right instinct: the fallback branch's object-drop looked suspicious, and rather than hand-waving, it pinned the adjacent behavior with a test. It just stopped one layer short of the write path, which is where the actual gap turned out to be.- Commit messages and PR body are unusually good — they explain reasoning, not just changes, and pre-empt most of the questions a reviewer would ask.
Recommendation
REQUEST CHANGES, on findings #1 and #2 — both are the same failure mode as the bug being fixed, in paths this change didn't reach, and the issue is explicit that partial completion is the one unacceptable outcome.
Finding #1 is the harder blocker and I'd fix it in rel_ops.rs where a real Node is in hand — the canonical helper applies directly there, so it costs no new duplication.
Finding #2 can reasonably ship as a follow-up issue if the docs guarantee is corrected here; what shouldn't ship is a documented promise of completeness alongside a path that silently drops a field.
Findings #3 and #4 are worth doing in this PR (both are small). #5–#8 are optional.
Also: 1adef8a3 is local-only — push it before merge, or the reviewed state isn't the merged state.
malibio
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES
(Posted as a comment because GitHub rejects --request-changes on a self-authored PR.)
Full review: #2423 (comment)
The fix itself is correct and the diagnosis is the valuable part — treating this as a broken contract rather than a docs gap was the right call, and the integration test asserting both halves at once (storage nested / output flat) is the right shape of test. Clippy clean, all 10 unit tests pass.
Two blockers, both completeness — which the issue singles out as the one unacceptable outcome:
-
🔴
relationship get --jsonstill emits the nested shape. It bypassesoutput.rsentirely, serializing rawNodestructs atpackages/core/src/ops/rel_ops.rs:383-386. It is a first-class documented read path (references/cli.md:237-259), andSKILL.md:146explicitly recommends it as the follow-up toquery. Best fixed at the source inrel_ops.rs, where a realNodeis in hand — the canonical helper applies directly there, so the duplication argument that justifies the CLI mirror does not apply. -
🔴 An object-valued property never reaches the type namespace on write, so it is silently dropped from output.
create_nodeonly fetches schema fields fornode_type == "task"(crud.rs:98-139); every other type normalizes withNone, so any object-valued property is misclassified as a namespace and hoisted beside the type key, where the flattener never looks. The codebase already names this hazard verbatim atpackages/agent/src/skill_pipeline.rs:482-487— "the normalizer misclassifies parameter_schema (an object) as a dormant namespace ... so flatten_properties_for_api later silently drops it." No built-in type loses data today (toolpre-namespaces;schemais object-free), but a user-definedobjectfield would. The concern is that this PR tightens the output contract to promise completeness while the write path can't deliver it — turning a visible-but-wrong shape into an invisible omission.
Also flagged: nothing enforces that the two flattening implementations stay in step (they agree today — I checked line by line), and references/cli.md:14-16 omits node children, node batch-get, and node set-status from its list of node-emitting commands.
On the two items raised for scrutiny: widening node_to_json to pub is fine (consistent with the module's existing pub helpers and lib.rs's stated purpose), and keeping flattenTypeKeyedProperties in scripts/eval/ does hold up against CLAUDE.md — NS_BIN points at a binary the harness doesn't build, and preflight.ts:149 already treats stale builds as a live condition, so that's input tolerance at a trust boundary rather than a product compat shim.
One housekeeping note: 1adef8a3 is local-only and not yet pushed.
Review of #2423 found the change incomplete in two places. `relationship get` still leaked `properties.<schema-id>.<field>`. My claim that output.rs is the funnel every node-emitting command passes through was wrong: this path prints `related_nodes_json`, which rel_ops.rs builds with a plain `to_value(Node)` — properties exactly as stored. It is a documented read path that SKILL.md recommends as the follow-up to `query`, so an agent following the skill's own advice landed on the one command still leaking. Fixed at the source via `nodes_to_typed_values`, which fixes every consumer of GetRelatedNodes rather than just the CLI, and pinned by a new test. The flattening logic was duplicated between output.rs and convert.rs, whose own docs declare it the "SOLE authority ... Do NOT re-implement". The two agreed, but nothing kept them in step and divergence would surface as a wrong answer rather than a red test. Extracted the rule as `flatten_namespaced_properties` in nodespace-types; both callers now share one body while keeping their own input types (Node vs the CLI's JSON-encoded string). Also from the review: - cli.md claimed properties are complete, which the write path cannot deliver: create_node only resolves schema fields for `task`, so for other types `normalize_flat_properties_to_namespace` misclassifies an object-valued property as a namespace and hoists it out of the type key, where the flattener never looks. That is a pre-existing write-path bug (already documented at skill_pipeline.rs:482) and out of scope here, but the docs must not promise what it breaks — noted the gap instead. - Replaced the enumerated command list with the general rule; it was already missing `node children`, `node batch-get` and `node set-status`. - Repointed a duplicate-fixture test at the untested fallback branch. - Explained the unreachable match arm in `has_properties`. Kept `flattenTypeKeyedProperties` in scripts/eval — the review agreed the stale-NS_BIN argument holds. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_018rQHweNGgEiuYpA5NZNwea
Review feedback addressedAll findings from the review are in 🔴 Addressed#1 — Fixed at the source via #2 — object-valued properties dropped on write. Confirmed, including the reviewer's read of This is a pre-existing write-path bug, not one this PR introduces, and fixing 🟡 Addressed#3 — nothing kept the two implementations in step. Extracted #4 — enumerated command list. Replaced with the general rule (it was already missing 🟢 Addressed#5 Documented the unreachable #6 ( Verification
Housekeeping: 🤖 Generated with Claude Code |
|
Filed the write-path bug from finding #2 as #2430. I checked the size before filing rather than defaulting to "out of scope": the obvious fix (resolve schema fields for all types, not just Happy to pick #2430 up next if you'd like it prioritized — your call on sequencing. |
Code Review Summary — RE-REVIEW (round 2)Review Type: Re-review, scoped to Previous Review Summary
The two headline fixes are real, and I verified them rather than trusting the claims:
Layering is fine. On the error-handling change in Findings🔴 Critical📁 Two problems, both from the same root: the docs assert one uniform node shape that the code no longer delivers. (a) "and objects on // crud.rs:649 and again at :779
let normalized_properties = Self::normalize_flat_properties_to_namespace(
&updated.node_type,
&properties,
None, // Schema fields are fetched later if needed
);With (b) The generalized "Every command that emits a node returns objects of this shape" is now wrong for the command this PR just changed. And for Note the previous round narrowed this sentence from a correct enumeration to an incorrect universal, so the doc got less accurate on exactly the point this PR is about. Per the project's own standard the fix is not to reference an issue but to state the behavior: either say 🟡 Improvement📁 The comment justifies the change purely as de-nesting properties ("A plain I checked the blast radius and it is genuinely small — this is why this is 🟡 and not 🔴. The op has exactly two production callers:
There is no frontend or Tauri consumer: The agent tool's lookups do degrade for Two things worth doing: (1) extend the comment to say what else the call brings — the promotion, the reshape, the 🟢 NitsNit: 📁 Nit: 📁 Verdict: REQUEST CHANGESThe engineering in this round is strong. Both headline fixes are correct, the extraction is provably behavior-preserving, the new integration test is a real guard (I confirmed it red against the old code), the error-handling change is a net improvement, and the deferral of the write-path bug is the right call for atomicity. The blast radius of the What blocks is documentation correctness, and it blocks because of what this PR is for. The entire change exists so that an agent reading Fix 🔴 (a) and (b); 🟡 is a comment expansion plus a one-word agent-tool fix or a filed issue. Neither requires touching the code this round got right. |
malibio
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES (posted as a comment — GitHub rejects --request-changes on a self-authored PR).
Re-review of b06ca679..HEAD is posted in full at #2423 (comment)
Previous round: 5 of 6 recommendations addressed, 1 deliberately deferred (correctly). 3 new findings (1 🔴, 1 🟡, 1 🟢).
Verified rather than assumed:
- The
rel_ops.rsfix is real and the new test is a real guard — I revertedrel_ops.rsto the oldto_value(Node)body andrelationship_get_emits_flat_propertiesfailed (left: Null, right: "high"). Restored; worktree clean. flatten_namespaced_propertiesis provably behavior-preserving vs the original private body on every branch, including the non-object early return and the namespace-key-holds-a-scalar case.- No frontend or Tauri consumer of
GetRelatedNodesexists (the relationship viewer uses the untouchedget_node_relationships), so that risk does not materialize. Theunwrap_or(json!(null))→OpsError::Internalchange is a net improvement. - Layering is fine;
pubinnodespace-typesis the right home and visibility. Clippy clean,cargo test -p nodespace-cligreen.
🔴 What blocks — packages/skill/references/cli.md:37-41, both halves of the same failure mode this PR exists to eliminate:
- "objects on
taskare unaffected" is false.node updatepassesschema_fields: Nonefor every type (crud.rs:649and:779), so the classifier atcrud.rs:1704hoists object-valued properties out of the namespace on tasks too — and it is CLI-reachable vianode update <task-id> --property billing='{"city":"Berlin"}'. An agent told tasks are safe, then losing an object on a task, is worse off than with no caveat. - "Every command that emits a node returns objects of this shape" is now wrong for the command this PR just fixed.
node get/query/searchemit snake_case via the CLI'snode_to_json;relationship getnow passesnodes_to_typed_valuesoutput straight through — camelCase (nodeType,createdAt) plus an injecteduri, and forschemanodes nonodeType/title/propertiesat all. That branch is reachable via the universalmentionsedge.
Round 2 narrowed this sentence from a correct enumeration to an incorrect universal, so the doc got less accurate on exactly the point at issue. A breaking shape change is free under the zero-users rule; an inaccurate description of it is not.
🟡 rel_ops.rs:382-388 — the comment justifies the change as de-nesting only, but nodes_to_typed_values also promotes typed fields, reshapes schema via SchemaNode::from_node, and injects uri. Small blast radius, but tools.rs:2999 silently loses title and type for schema nodes. Expand the comment; fix or file the agent-tool lookup.
The engineering this round is strong and none of the code that landed needs reverting — the fixes are documentation-side.
Re-review feedback addressed —
|
Code Review Summary — RE-REVIEW (round 3)Review Type: Re-review, scoped to Previous Review Summary
Three of the four items are done properly and I verified each rather than trusting the claim:
What I did to verify: built throwaway probe tests against the real crates that ran One process note before the findings: Findings🔴 Critical📁 The doc comment justifies dropping the promoted fields "since let status: TaskStatus = props.get("status").and_then(|v| v.as_str())
.and_then(|s| s.parse().ok())
.unwrap_or_default(); // → TaskStatus::Openso a task with no stored
The principle is no lossy transformation on a read path. Dropping a key is only safe when it is provably a duplicate, and 🟡 Improvements📁 The doc comment says only the keys the CLI shape defines are re-keyed, but the lists were not derived from the structs. Enumerating
An allowlist of the keys the CLI shape defines is more robust than a denylist of the ones it doesn't, because it fails closed when a new typed field is promoted — a denylist silently leaks it. Principle: derive the mapping from the type, don't hand-maintain a parallel list (DRY / single source of truth). Worth a comment naming 📁
The consequence if it ever did fire is a silent full passthrough: camelCase keys, a leaked 🟢 NitNit: 📁 The re-keying makes this true for generic, I think the passthrough decision itself is right — Verdict: REQUEST CHANGESThe round-3 work is directionally right and the analysis behind it is honest — 🔴(a)'s rescoped caveat is now exactly accurate (I checked all six write call sites), the What blocks is that the re-keying is incomplete in the same failure mode the PR exists to close. The uncommitted |
malibio
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES (round 3 re-review — posted as a comment because GitHub rejects --request-changes on a self-authored PR).
Full review: #2423 (comment)
Round 3 addressed all four round-2 items and three are correct — the rescoped object-valued caveat is now exactly accurate (verified against all six normalize_flat_properties_to_namespace call sites in crud.rs and bulk.rs), the rel_ops.rs comment and both nits are done, and the tools.rs nodeType fix is a genuine bug fix with the right key.
What blocks: the new related_node_to_json re-keying is incomplete in the same failure mode the PR exists to close.
- 🔴
output.rs:167-173—DROPPEDtreats all six promoted task fields as duplicates ofproperties, but only the fiveOptionones are protected byskip_serializing_if.statusis synthesized bytask_node_to_value'sunwrap_or_default(), so a task with no stored status serializes"status": "open"withproperties: {}— and the drop loses it entirely. Verified against the real crates:relationship getreturns that task with no status at all, whilenode getreports"open". Same non-Optionshape forai-chat'sstatus. - 🟡
output.rs:151-155, 167-173— the key lists don't match the structs:parentId/rootId/beforeSiblingIdare not fields of any node shape and can never fire;mentionedInis missing and does occur, leaving one camelCase key in an otherwise snake_case object;ai-chat'sprovider/model/messagespass through duplicated at the top level. - 🟡
output.rs:135-139— thefields/schemaVersionschema heuristic is a coincidence, not an invariant (fieldsis not inRESERVED_CORE_PROPERTIES). It happens not to false-positive only because flattening puts a user-definedfieldsunderproperties.!obj.contains_key("nodeType")identifiesSchemaNodepositively. - 🟢
cli.md:14-15— "Every command that emits a node returns objects of this shape" still has a known exception: a passed-throughschemanode keeps camelCase timestamps, auri, and nonode_type/title/properties.
Note: packages/cli/src/output.rs has uncommitted changes in the worktree (timestamped after bc74023e) that appear to be exactly this fix — a CLI_KEYS allowlist folding promoted fields back under properties with stored values winning, plus mentionedIn. If that is the intended fix, committing it resolves the 🔴 and the first 🟡; please add a test for the bare-status task, since that is the case that broke and nothing pins it.
Round 3 feedback addressed —
|
Pragmatic Code Review — PR #2423 (Round 4)Type: Re-review Previous Review Summary
Counts: 4 addressed / 0 unaddressed / 1 new 🟡 + 1 new 🟢. Verification methodI did not take the summary on trust. I enumerated what
I also confirmed via What I confirmed correctThe
The allowlist is the right architecture, not just a working one. The drop-list was a denylist over an open set — anything new defaults to leaking.
The Findings🟡 Improvement1.
|
malibio
left a comment
There was a problem hiding this comment.
Round 4 re-review verdict: 🟡 REQUEST CHANGES (posted as a comment — GitHub rejects --request-changes on a self-authored PR).
All four round-3 findings are addressed, and I verified each independently rather than on trust: I enumerated the real key sets emitted by all four node_to_typed_value branches and piped those payloads through related_node_to_json. The CLI_KEYS allowlist is complete, the stored-value-wins precedence is the correct direction (it matches what node get reports, since promoted dueDate is lossily normalized while properties is verbatim), messages is correctly folded with no duplication, and the !contains_key("nodeType") discriminator is structurally sound — SchemaNode has no node_type field at all. The round-3 🔴 is genuinely fixed, and fixed structurally. Clippy clean, 52/52 CLI tests pass.
One blocking finding, in documentation rather than code:
🟡 packages/skill/references/cli.md:16-21 — the new schema exception clause says the payload comes back as (name, fields, relationships), but SchemaNode has no name field; that field belongs to SchemaField. The actual shape is id, content, version, createdAt, modifiedAt, isCore, schemaVersion, description, fields, relationships, uri. Two related details are also wrong in the same sentence: those keys are camelCase (the surrounding text says parse snake_case names 'and nothing else'), and uri survives on this one path because the early return precedes the uri drop.
That is the same defect class this PR exists to eliminate — a documented shape that does not match the emitted shape — so it should not ship in the commit that fixes the others. It is a one-sentence edit, no code or test changes.
🟢 Optional: title/mentions/mentioned_in are relationship get-only, since NodeData has no such proto fields. Passing them through is the right call; cli.md already discloses title and could mention the other two.
Full review with the verification tables: #2423 (comment)
Round 4 feedback addressed —
|
Storage nests a node's properties under its schema id
(`{"task": {"status": "open"}}`), and the CLI was passing that shape
straight through `--json`. A consumer reading `.properties.status` got
`None` and could report "status unknown" about real data.
The nesting is a storage concern that was never meant to cross the API
boundary: `flatten_properties_for_api` in nodespace-types already defines
the flat contract the frontend receives, and `output.rs`'s own comments
promise `jq '.properties.foo'` works without a second parse. Writes
(`--property status=…`) and filters (`{"property":"status"}`) already take
bare field names, so only reads leaked.
Flatten in `output.rs`, which every node-emitting command funnels through
(`node get`, `query`, `search`, `schema`, and the batch path), covering
both `--json` and human-readable output. `_`-prefixed internals
(`_schema_version`, sibling namespaces like `_seed`) and dormant
namespaces from a previous type change are dropped, matching the frontend.
The logic is mirrored rather than reused because the CLI only ever holds
the gRPC `NodeData`, whose `properties` is a JSON-encoded string, while
the canonical helper takes a `Node`.
Storage is unchanged — a seeded node's `_seed` and `skill` namespaces
coexist at rest, which a flat bag could not represent.
Docs: SKILL.md's node example showed `"properties": {}`, which reads as a
flat bag and taught the wrong shape; it now shows populated flat
properties. references/cli.md documented only that `--json` exists, so it
now specifies the node shape. Its "namespace prefixes" note conflated
schema-authoring field prefixes with runtime nesting and is clarified.
scripts/eval unwraps the nested shape defensively; that is now a no-op
against a current build but is kept and documented, since NS_BIN is
overridable and defaults to a prebuilt binary that can predate this change.
Tests: six unit tests over the flattening rules, plus an end-to-end
integration test asserting storage stays nested while CLI output is flat,
for a core type and a user-defined type.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_018rQHweNGgEiuYpA5NZNwea
The fallback branch drops nested objects because, with no namespace for the node's type, a nested object can only be another type's namespace. Inside the type namespace the opposite holds: an object there is a real schema-defined field value (schemas support "object" fields) and must survive intact. The primary branch already did this; the case was untested. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_018rQHweNGgEiuYpA5NZNwea
Review of #2423 found the change incomplete in two places. `relationship get` still leaked `properties.<schema-id>.<field>`. My claim that output.rs is the funnel every node-emitting command passes through was wrong: this path prints `related_nodes_json`, which rel_ops.rs builds with a plain `to_value(Node)` — properties exactly as stored. It is a documented read path that SKILL.md recommends as the follow-up to `query`, so an agent following the skill's own advice landed on the one command still leaking. Fixed at the source via `nodes_to_typed_values`, which fixes every consumer of GetRelatedNodes rather than just the CLI, and pinned by a new test. The flattening logic was duplicated between output.rs and convert.rs, whose own docs declare it the "SOLE authority ... Do NOT re-implement". The two agreed, but nothing kept them in step and divergence would surface as a wrong answer rather than a red test. Extracted the rule as `flatten_namespaced_properties` in nodespace-types; both callers now share one body while keeping their own input types (Node vs the CLI's JSON-encoded string). Also from the review: - cli.md claimed properties are complete, which the write path cannot deliver: create_node only resolves schema fields for `task`, so for other types `normalize_flat_properties_to_namespace` misclassifies an object-valued property as a namespace and hoists it out of the type key, where the flattener never looks. That is a pre-existing write-path bug (already documented at skill_pipeline.rs:482) and out of scope here, but the docs must not promise what it breaks — noted the gap instead. - Replaced the enumerated command list with the general rule; it was already missing `node children`, `node batch-get` and `node set-status`. - Repointed a duplicate-fixture test at the untested fallback branch. - Explained the unreachable match arm in `has_properties`. Kept `flattenTypeKeyedProperties` in scripts/eval — the review agreed the stale-NS_BIN argument holds. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_018rQHweNGgEiuYpA5NZNwea
Round 2 fixed the last leaking command and then, in the same commit, made two documentation claims that the code does not satisfy — the same failure mode this PR exists to eliminate. Both are now fixed properly rather than documented around. `relationship get` emitted a different node shape from every other command. Routing it through `nodes_to_typed_values` removed the property nesting but left the frontend's wire shape: camelCase keys, an injected `uri`, and promoted type fields. So a consumer had to know which command it called before it could read `node_type` — two shapes on one surface, which is the same defect as two property layouts. The CLI now re-keys these nodes into its own snake_case shape (`output::related_node_to_json`), dropping the `uri` and the promoted duplicates that `properties` already carries. `schema` nodes pass through untouched: `SchemaNode::from_node` has already dropped `nodeType`/`title`/`properties`, and a half-mapped node that looks like the CLI shape but is missing its fields would be worse than an honest passthrough. The generalized "every command that emits a node" sentence is therefore true again. The object-valued-property caveat was scoped wrong. It named `task` as safe, but both `node update` call sites (crud.rs:649, :779) pass `None` for schema fields regardless of type, so an object property is hoisted out of the type namespace for `task` too — and it is CLI-reachable, since `parse_property` JSON-parses the value. An agent told tasks were safe and then losing one would be worse off than with no caveat at all. Now scoped to what actually breaks: update for every type, create for every type but `task`. Also from the review: - Expanded the rel_ops.rs comment to name the promotion, the `schema` reshape and the `uri`, so nobody "simplifies" it back to a plain `to_value` on the assumption the shapes are equivalent. - Fixed a pre-existing bug found next door: the agent's get_related_nodes tool read `node_type`, but `Node` serializes camelCase, so that lookup never matched and every node's type was reported to the model as empty. - Noted nodespace-cli as a third consumer in the nodespace-types crate doc, and recorded that the flattening rule governs human-readable CLI output too, since both modes share one call into it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_018rQHweNGgEiuYpA5NZNwea
Round 3's re-keying dropped promoted typed fields on the assumption that `properties` always carries the same value. It does not: `status` is not an `Option` on `TaskNode`, so `task_node_to_value` synthesizes it via `unwrap_or_default()` and serializes "open" even when nothing was stored. Dropping it lost the field outright — `relationship get` reported no status where `node get` reported "open". The other five promoted fields are `skip_serializing_if = "Option::is_none"` and so were safe, which is why this hid behind them. Promoted fields are now folded back under `properties`, with a stored value winning over the promoted copy. That keeps one shape without discarding anything, and generalizes past the hardcoded key list: `ai-chat`'s `provider`/`model`/`messages` were also passing through duplicated at the top level. The rename list was checked against the structs rather than guessed. `parentId`/`rootId`/`beforeSiblingId` are fields of no node shape and could never fire; `mentionedIn` is real and was missing, so it survived as the one camelCase key in an otherwise snake_case object. The `schema` passthrough now keys off the ABSENCE of `nodeType`, which every node shape carries and `SchemaNode` does not. Keying off `fields` was discriminating on a coincidence — `fields` is not a reserved property name, so a user-defined type may declare one. Documented the one real exception to the uniform shape: a `schema` node reached through `relationship get` comes back in the schema's own shape, and `schema get` is the right way to read schemas. Tests: the bare-status task that broke, `mentionedIn` re-keying, and a user type with a `fields` property that must still be re-keyed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_018rQHweNGgEiuYpA5NZNwea
The exception clause added last round got three details wrong while fixing a fourth. It named a `name` key that does not exist — `SchemaNode` has no such field; `name` belongs to `SchemaField`. It implied snake_case, but `SchemaNode` is `rename_all = "camelCase"`. And it omitted that `uri` survives on this path, because the passthrough returns before the `uri` drop. Every claim in the replacement was checked against real output from `node_to_typed_value` piped through `related_node_to_json`, rather than read off the struct: keys are `isCore`, `schemaVersion`, `description`, `fields`, `relationships` plus `uri`, with no `node_type` and no `properties`. Also disclosed `mentions`/`mentioned_in` alongside `title` as keys `relationship get` may carry that `node_get` cannot, since `NodeData` has no such fields. Recorded in `output.rs` that those three entries in `CLI_KEYS` are forward-looking rather than live: every store construction site leaves `mentions`/`mentioned_in` empty and both are `skip_serializing_if = "Vec::is_empty"`, so only `title` occurs in practice. They stay listed so that if the daemon ever populates them they remain top-level instead of being misfiled as stored properties. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_018rQHweNGgEiuYpA5NZNwea
a3bba4d to
920ee8d
Compare
Problem
Storage nests a node's properties under its schema id. The CLI passed that shape straight through
--json:A consumer reading
.properties.statusgotNone— and could report "status unknown" about real data. The reporting agent caught it only becausestatusisrequiredwith a default, so a task cannot legitimately lack one.Why this is a bug, not a docs gap
The flat contract already exists and is already intended:
flatten_properties_for_api(nodespace-types/src/convert.rs) defines it, and the frontend gets it vianode_to_typed_value.output.rs's own comments promisejq '.properties.foo'works with no second parse — bare.--property status=…) and filters ({"property":"status"}) already take bare names.Only reads leaked, so the CLI was half-flat: bare on input, nested on output. Documenting the nesting would have enshrined the leak.
Fix
Flatten in
output.rs, which every node-emitting command funnels through —node get,query,search,schema, and the batch path — covering both--jsonand human-readable output._-prefixed internals (_schema_version, and sibling namespaces like_seed) and dormant namespaces from a previous type change are dropped, matching the frontend contract.The logic is mirrored rather than reused: the CLI only ever holds the gRPC
NodeData, whosepropertiesis a JSON-encoded string, while the canonical helper takes aNode. Both sites cross-reference each other.Storage is unchanged. A seeded node's
_seedandskillnamespaces coexist at rest, which a flat bag could not represent.Docs
SKILL.md— the onlypropertiesexample was{}, which reads as a flat bag and taught the wrong shape. Now shows populated flat properties.references/cli.md— documented only that--jsonexists; now specifies the node shape.cli.md's "namespace prefixes" note conflated schema-authoring field-name prefixes with runtime nesting, reinforcing the wrong inference. Clarified.A downstream consumer
scripts/eval/graph.tsreadsnodespace --jsonand unwraps the nested shape. That is now a no-op against a current build, but it is kept and documented rather than deleted:NS_BINis overridable and defaults to a prebuilttarget/release/nodespacethat can predate this change — the stale-binary casepreflight.tsalready warns about. Failing to unwrap an older binary's output would silently zeropopulatedCountand red-line correct writes. This is input tolerance at a test harness's trust boundary, not a compatibility shim in the product.Testing
_-prefixed internals hidden, sibling_seednamespaces, dormant namespaces, user-defined types, already-flat passthrough.task) and a user-defined type (venue).bun run test:allgreen, matching baseline exactly (232 files / 4863 frontend tests, 0 new failures).quality:fixclean; clippy passes with-D warnings.Closes #2381
🤖 Generated with Claude Code
https://claude.ai/code/session_018rQHweNGgEiuYpA5NZNwea