Repository navigation
Description
Problem
Assigning a node to a collection from the CLI costs three or more calls, when the backend already supports doing it in one.
Today an agent must: look up or create the collection node, get its id, then relationship create --from <node> --type member_of --to <collection-id>. Per collection, per node. That write cost is a real argument against using collections at all — it pushed an external agent toward a tags: array field instead, since an array is one property on the record.
The one-call path already exists
CollectionService::add_to_collection_by_path(node_id, collection_path) (packages/core/src/services/collection_service.rs:525) takes a string path, and:
- resolves the path via
resolve_path(:389), which batch-fetches existing collections in one query - creates any missing segments, wiring the
member_ofchain between them ("hr:policy:vacation"→vacation -member_of-> policy -member_of-> hr) - creates the node's own
member_ofedge to the leaf
No ids, no pre-existence check, no per-segment calls. member_of needs no schema declaration either — it is one of the four native edges (models/schema.rs:56), so collection's empty relationships array is not a blocker.
And node creation already wires it up: ops/node_ops.rs:166 calls add_to_collection_by_path during create, as does :309 for update. The op layer takes a collection path today.
Where it stops
nodespace node create exposes only --type, --content, --parent:
Usage: nodespace node create [OPTIONS] --type <NODE_TYPE> --content <CONTENT>
--content <CONTENT> Content (plain text or markdown)
--parent <PARENT> Parent node ID (omit to create a root node)
There is no --collection. Meanwhile the same concept is already a CLI flag elsewhere:
import file --collection "docs:rust"(cli/src/commands/import.rs:27)import dir --collection …(:51)search --collection <path>(cli/src/commands/search.rs:31)
So the CLI accepts collection paths for import and search, and the op behind node create accepts one too — but the create verb does not surface it. The capability exists end to end and is missing exactly one flag.
Impact
This is a discoverability and cost problem for external agents specifically. An agent weighing "collection vs tags array" counts calls: one property write versus a lookup-create-link dance per topic. That comparison currently favours the array, and it is an artefact of the missing flag rather than of the model. With --collection, the collection path is cheaper than the array — one flag, no JSON quoting.
It also removes the main practical objection to the guidance that durable groupings should be collections rather than array fields.
Acceptance criteria
-
node create --collection <path>assigns the new node to the collection, creating missing segments, in one call - Repeatable, so a node can join several collections in one create
- Same flag on
node update, matching the op support already present atops/node_ops.rs:309 - Path syntax matches
import/searchexactly (:-delimited hierarchy) — one syntax across every verb that takes a collection path -
--collectionand any id-based form are mutually exclusive, assearchalready does with--collection/--collection-id - Failure to resolve or link surfaces as an error rather than a silently uncollected node
- Skill guidance shows collection assignment at create time, so the one-call form is what an agent copies — the source of truth is
packages/agent/src/skill_rules.rsandpackages/skill/, not the generated reference - The cost comparison in the schema-design guidance is updated: with this flag, a collection is not meaningfully more expensive to write than an array element
Context
Raised after an external agent chose a tags array over collections, citing per-node write cost. The cost it was avoiding is largely this missing flag. Related: the schema-design guidance issue covering when a grouping should be a collection rather than an array field.
Activity
malibio commentedon Sep 8, 2026
Frontend baseline: 233 test files passed, 4900 tests passed (Duration 78.08s).
Add --collection to node create/update, and teach it as the one-call …