Skip to content

Remove a node property from the CLI (node update --unset-property) - #4400

Merged
mstomar125 merged 2 commits into
mainfrom
issue-4390-unset-property
Nov 27, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-4390-unset-property

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

What

node update --property key=null stores a null and the key stays, because properties are deep-merged. There was no way to remove a key from the CLI.

  • New unset_properties (repeated string) on UpdateNodeRequest (field 11) and BatchUpdateItem (field 6); NodeUpdate/UpdateNodeInput carry it. Core removes the keys right after the properties patch is merged and before validation, on every update path (prepare_update for the version-checked update and dry run, update_node_unchecked, the two _in_tx paths, bulk_update), so validation, the version check and the NodeUpdated event (the removal shows as a change with no new value) are those of any other update. The key is removed from every type bucket the node holds, so an inherited field in its declaring ancestor's bucket goes too.
  • CLI: node update --unset-property <key> (repeatable) and unset_properties (array of keys) per item in node batch-update --updates. The same key in --unset-property and --property/--properties is refused. Help text and packages/skill/references/cli.md (regenerated) document both.
  • relationship delete --type --from --to already exists on main (over DeleteRelationship); no code change. I added the missing tests: delete removes the edge, the reverse name (blocked_by) no longer lists it, and deleting an edge that is not there succeeds with deleted: false (documented behaviour, the command reports "no-op").

Decisions: an unset of a key the node does not hold is a no-op, not an error (so a cleanup over many nodes can be re-run). _-prefixed keys, empty keys and any key on a schema node are refused with a clear error. A required field cannot be removed (validation refuses it).

New CLI against an old daemon (release compatibility)

proto3 ignores a field the old daemon does not know, so an old daemon would silently do nothing for an unset-only update. The CLI therefore reads the node back (the update response, and the existing post-batch read-back for batch-update) and fails with " still has '': the daemon did not remove it. A daemon older than this CLI ignores --unset-property; update NodeSpace..." when a requested key is still there. For batch-update the other items have already been written by then (the error comes after the batch). An old CLI against a new daemon is unaffected (the field is simply never sent). --dry-run with --unset-property on an old daemon would predict as if nothing were unset.

Tests and mutation checks

  • core unset_property_test (10): key removed and no null in storage, ops path, absent key no-op, patch+unset in one write at one version bump, OCC conflict, required field refused, _/empty keys refused, event reports the removal, unchecked update, bulk update. an_unset_removes_the_key_on_every_write_path runs all five internal paths including the inherited field.
  • CLI unit (4) and integration (5, in-process daemon): round trip through node update, absent key, set+unset conflict, batch per-item unset, malformed unset_properties, relationship delete (+ reverse edge, + missing edge).
  • Mutations, each failing the named test: helper not removing (7 core tests), each of the five update-path call sites (unchecked, unchecked_in_tx, in_tx via the all-paths test, prepare_update, bulk), _ guard, empty-key guard, is_empty ignoring unset, CLI never sending the field, batch parse dropping it, daemon update and batch handlers ignoring the field (this is the old-daemon behaviour, and it fails the CLI round trip), the CLI old-daemon check for update, the batch old-daemon helper, the set+unset conflict check.
  • Surviving mutation: removing the call that applies the batch old-daemon check in batch_update (the helper itself is unit tested, the three-line wiring is not).

quality:fix clean (unrelated webview_bridge_tests.rs reformat reverted), gen:types (one optional field in node-update.ts), skill:gen, test:changed passed.

The agent crate only gains ..Default::default() on its UpdateNodeInput literals (owner sign-off for this batch).

Closes #4390

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Follow-up commit c51d381 addresses review:

  • An unset of keys the node does not hold is now a real no-op on update_node (the path the CLI and daemon use): no write, no version bump, no NodeUpdated event, so a re-run over many nodes does not churn them. A stale version still conflicts and _/empty keys are still refused. Other internal paths set properties_changed only when a key was removed (they still write; they are not reachable from the CLI). Test now asserts version and no event; mutations (shortcut off, shortcut ignoring version, validation before shortcut off) each fail it.
  • New test: unsetting a system field is refused (naming field and type), value kept; mutating the system-field guard fails it.

Sync pull path (read only, nodespace-sync origin/main apply.rs): apply_node_upsert_inner writes the cloud row with ns.update_node(id, ver, NodeUpdate { properties: Some(...) }) (a seeded root goes through bulk_update), and core's update_node deep-merges properties per type namespace (deep_merge_namespaced_properties). So a key REMOVED in the cloud row stays on every other device's local row: the removal does not propagate through a pull. Worse, a device that kept the stale key can push it back. A future cleanup done by unset on one device will not clear other devices until Sync applies pulled properties by replacing them (or applies the removal). Not changed here.

mstomar125 and others added 2 commits November 27, 2026 07:46
… batch unset_properties

A properties patch only merges, so null left the key in place. UpdateNode and
BatchUpdateItem carry unset_properties; core removes the keys after the patch
merges, on every update path, so validation, the version check and events are
those of any other update. The CLI checks the node it gets back and fails when
an older daemon ignored the field.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…field

update_node returns the node unchanged, with no write, version bump or event,
when the update only unsets keys the node does not hold (a stale version still
conflicts, a refused key is still refused). The other paths mark the
properties changed only when a key was removed.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@mstomar125
mstomar125 force-pushed the issue-4390-unset-property branch from c51d381 to 4a5f21c Compare November 27, 2026 06:46
@mstomar125
mstomar125 merged commit 12e8e1c into main Nov 27, 2026
@mstomar125
mstomar125 deleted the issue-4390-unset-property branch November 27, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The CLI cannot remove a property or delete a relationship: --property key=null stores a null and relationship has no delete

1 participant