Skip to content

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

Closed

Description

@malibio

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_of chain between them ("hr:policy:vacation" → vacation -member_of-> policy -member_of-> hr)
  • creates the node's own member_of edge 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 at ops/node_ops.rs:309
  • Path syntax matches import/search exactly (:-delimited hierarchy) — one syntax across every verb that takes a collection path
  • --collection and any id-based form are mutually exclusive, as search already 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.rs and packages/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

  1. added
    enhancement
    on Sep 7, 2026
  2. malibio commented on Sep 8, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 233 test files passed, 4900 tests passed (Duration 78.08s).

  3. self-assigned this
    on Sep 8, 2026
  4. added a commit that references this issue on Sep 8, 2026
    6098e64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backendenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions