Skip to content

Add --collection to node create/update, and teach it as the one-call form - #2450

Merged
malibio merged 2 commits into
mainfrom
issue-2392-node-create-collection
Sep 8, 2026
Merged

malibio merged 2 commits into
mainfrom
issue-2392-node-create-collection

Conversation

@malibio

@malibio malibio commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Closes #2392.

The gap

CollectionService::add_to_collection_by_path already resolved a :-delimited path, created every missing segment, wired the member_of chain and linked the node — in one call. ops/node_ops.rs already called it during both create and update. nodespace node create just never surfaced it, so filing a node cost a lookup, a create and a link. That per-node write cost is what pushed an external agent toward a tags array instead of collections, and it was an artefact of one missing flag rather than of the model.

CLI

  • node create --collection <path> and node update --collection <path> — repeatable, :-delimited, the same syntax import and search already take.
  • --collection-id (also repeatable) as the ID-based form, mutually exclusive with --collection via clap conflicts_with, mirroring how search pairs the two. The ops layer rejects the pair independently, so a non-CLI caller (daemon, Tauri, local agent) can't slip past the parser.
  • node update --remove-collection-id. Removal stays ID-only because remove_from_collection is ID-only — a path-based removal would need different semantics (resolving a leaf, and creating it as a side effect of a removal).
  • --collection alone now makes an update meaningful; no --content/--property required.
  • A collection that fails to resolve or link fails the command. The node is never left silently uncollected.

Plumbing

The singular collection fields become repeated across the proto, ops inputs/outputs, the daemon handlers and the Tauri commands. The local agent's create_node tool gains a collection parameter accepting either a string or an array — an in-app agent told to pass a collection at create time needs a parameter to pass it in, and a model asked for "one or more" reliably sends both shapes.

Guidance — both sources of truth

Per the CLI guidance rule, this ships in skill_rules.rs and packages/skill/, not the generated reference.

  • ORG_NEEDS_EXISTING_COLLECTION told agents to have the user pre-create a collection that resolve_path creates automatically — the most expensive path and an unnecessary stop. Deleted outright (no #[deprecated]), replaced by COLLECTION_AT_CREATE_TIME, which leads with the one-call form.
  • New GROUPING_IS_COLLECTIONS schema rule carries the updated cost comparison: a collection is one argument on the create call, the same cost as one array element, so there is no cheap-versus-thorough tradeoff left to weigh — only durability differences (UI visibility, rename-once, nesting, no schema change to join).
  • Both are wired into skill_pipeline.rs (organization_guidance and schema_creation_guidance), with tests pinning that they actually reach the seeded markdown rather than sitting unused in a rules array. The regenerated prompt-assembly goldens are the independent confirmation: their diff is exactly the new guidance text and the new tool parameter.
  • SKILL.md's collection section now shows node create --collection as the primary example, replacing the post-hoc relationship create --type member_of recipe.

One judgment call worth reviewing

Adding guidance pushed SKILL.md over its 5000-token cap. I first moved the Shared Workspaces section into references/, then reverted that: shipping a new reference file means registering it in four AGENTS shims lists and changing publish tests that pin "exactly SKILL.md and references/cli.md today". A half-registered reference would ship a SKILL.md pointing at a file external agents don't have — worse than the status quo. Instead I compressed Shared Workspaces in place, keeping every claim. It now sits at 4992/5000 tokens and 305/500 lines — tight, so the next guidance addition will need to earn its space the same way.

Tests

  • 4 CLI integration tests: repeatable paths with auto-created nested segments, update add/remove, error-on-unresolvable, and parser-level mutual exclusivity.
  • 3 local-agent tool tests: one-call filing, the array form, and that collection is not swept into field_values by the flat-extras scan (which would silently store the path as a property instead of creating a membership).
  • 2 skill-pipeline wiring tests.

test:all green, matching the pre-change baseline exactly (frontend 233 files / 4900 tests). cargo clippy --all-targets clean with zero warnings across all four changed crates. The full pre-push gate passed.

Deliberately out of scope

Issue #2383 owns the broader guidance rewrite (person-shaped fields, false-friend naming, document decomposition). This PR takes only its "once node create --collection exists, make the one-call form the primary documented example" item, which is an acceptance criterion here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KwcVcLdvBUjSkUFmtFNiTY

malibio and others added 2 commits September 8, 2026 09:37
…form (closes #2392)

The op layer already assigned a node to a collection by path during create
and update, and CollectionService::add_to_collection_by_path resolved that
path, created every missing segment and wired the member_of chain in one
call. `nodespace node create` never surfaced it, so filing a node cost a
lookup, a create and a link — a per-node write cost that argues for a `tags`
array over the built-in grouping mechanism. That comparison was an artefact
of the missing flag.

CLI:
- `node create --collection <path>` and `node update --collection <path>`,
  repeatable, `:`-delimited exactly as `import` and `search` already take.
- `--collection-id` (also repeatable) as the ID-based form, mutually
  exclusive with `--collection` via clap `conflicts_with`, mirroring how
  `search` pairs `--collection` / `--collection-id`. The ops layer rejects
  the pair as well, so a non-CLI caller cannot slip past the parser.
- `node update --remove-collection-id`, and `--collection` alone is now
  enough to make an update meaningful (no `--content`/`--property` needed).
- A collection that fails to resolve or link fails the command; the node is
  never left silently uncollected.

Plumbing: the singular collection fields become repeated across proto, ops
inputs/outputs, the daemon handlers and the local agent's create_node tool,
which gains a `collection` parameter accepting a string or an array — an
in-app agent told to pass a collection at create time needs a parameter to
pass it in.

Guidance (both sources of truth, per the CLI guidance rule):
- skill_rules.rs: ORG_NEEDS_EXISTING_COLLECTION told agents to have the user
  pre-create a collection that resolve_path creates automatically. Replaced
  by COLLECTION_AT_CREATE_TIME, which leads with the one-call form; added
  GROUPING_IS_COLLECTIONS carrying the updated cost comparison — a collection
  is one argument on the create call, the same cost as one array element, so
  the only remaining differences are durability ones.
- Both are wired into skill_pipeline.rs (organization_guidance and
  schema_creation_guidance) and rendered into the shipped skill, with tests
  pinning that they actually reach the seeded markdown rather than sitting
  in the rules array unused.
- SKILL.md's collection section now shows `node create --collection` as the
  primary example instead of a post-hoc `relationship create --type
  member_of`. The Shared Workspaces section was compressed to stay inside the
  file's 500-line / 5000-token budget without dropping any of its claims.

Tests: four CLI integration tests (repeatable paths with auto-created nested
segments, update add/remove, error-on-unresolvable, parser-level mutual
exclusivity), three local-agent tool tests (one-call filing, array form, and
that `collection` is not swept into field_values by the flat-extras scan),
and two skill-pipeline wiring tests. Prompt-assembly goldens regenerated —
the diff is exactly the new guidance and the new tool parameter.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KwcVcLdvBUjSkUFmtFNiTY
`add_to_collections` takes paths; the removal field took ids under an
identical suffix. A caller writing `remove_from_collections: ["docs:rust"]`
by symmetry matched no edge and got `Ok(())` back — the membership survived
while the call reported success. Renamed to `remove_from_collection_ids`,
with the reason recorded on the proto field so the asymmetry is not
"corrected" back into a silent no-op, and a test pinning it.

Also from review: the create path's comment claimed a failure leaves no
silently uncollected node, without saying the node itself stays persisted
along with any collections already joined — it now describes what actually
happens. The `node.ts` @example blocks still named the pre-repeated singular
fields, and now show both forms with the paths-vs-ids distinction.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KwcVcLdvBUjSkUFmtFNiTY
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.

node create/update has no --collection flag, though the op layer already assigns by path in one call

1 participant