Skip to content

Skill guidance: teach relationships, collections, and document decomposition — agents invent flat fields for what the graph models natively #2383

Closed

Description

@malibio

Four skill-documentation defects, all found by watching external agents with no prior NodeSpace knowledge work against a real install. Grouped because they edit the same two files and should ship as one pass.

Source of truth: packages/agent/src/skill_rules.rs (generates both the local-agent imperative form and references/cli.md) and packages/skill/SKILL.md. The published NodeSpaceAI/nodespace-skill repo is a generated target — a hand edit there is overwritten on the next release.

The common root: an agent's default is to invent a flat field for something the graph already models natively, and the skill does not claim that ground. In every case below the agent reasoned carefully, read the docs, and still produced the wrong shape — because the documentation's examples and errors taught a different model than its prose. Agents pattern-match on worked examples and on error messages far more strongly than on descriptive statements; a capability documented in prose but absent from every example is, in practice, undiscovered.


1. Person-shaped fields should be relationships

An agent designing an ADR schema modelled sign-off as deciders: array — a text array of names — rather than a relationship to person, which already existed as a schema and was unused. It only reconsidered when asked directly, then produced a correct decided_by → person relationship with sound reasoning:

A text[] array of names has no integrity. "M. Alibio", "m…" are three different deciders to a query engine. That gets worse over time, and there's no rename path — you'd rewrite every ADR.

The model can reach the right answer. It did not reach it unprompted.

The rule exists and does not fire. skill_rules.rs:117-121:

pub const RELATIONSHIP_VS_FIELD: SchemaRule = SchemaRule {
    id: "relationship-vs-field",
    imperative: "RELATIONSHIPS: Use relationships (not fields) when a field references another node type.",
    prose: "**Relationships vs. fields:** use a relationship (not a field) when a value references another node type.",
};

Two reasons it fails:

  • It presumes the recognition it needs to teach. "When a value references another node type" only helps once you have noticed that deciders IS a reference. A person's name does not look like a node reference — it looks like text, and array of text is a natural encoding of "who signed off". Spotting that a human-sounding attribute is really an entity is the hard step, and the rule starts after it.

  • It has no examples, unlike its neighbours. TARGET_TYPE_MUST_EXIST and UNIQUE_FIELD_FLAGS both carry concrete ones. UNIQUE_FIELD_FLAGS also demonstrates the pattern that works — teaching recognition from the user's own words: "each ticket should have a unique key" → flag key unique.

  • Teach the recognition step: a field naming a person, team, project or any other entity is a reference, even when it reads naturally as text

  • Concrete examples in the UNIQUE_FIELD_FLAGS style, driven by user phrasing — "who signed off" → decided_by → person, "who it's assigned to" → assignee → person, "which project it affects" → affects_project → project

  • Name the false friends explicitly: deciders, assignee, owner, author, reviewer, reported_by, members

  • Say why, briefly: a name string has no integrity, no reverse lookup, no rename path

  • State the escape hatch so the rule is not over-applied — free text is legitimate for one-off external parties who will never be nodes

  • Apply to the sibling imperative (local-agent) form too, since both ship from one definition


2. Collections ARE the tagging and grouping mechanism

The same agent modelled topic areas as tags: array and did not consider collections until asked.

This is not a trade-off to present. NodeSpace has one mechanism for tagging and for structured grouping, and it is collections. A flat label (storage) and a nested path (docs:rust) are the same mechanism at different depths. An agent declaring a tags: array field is not choosing a lighter option — it is building a parallel, invisible reimplementation of a built-in system. Invisible literally: array values appear in no UI, while member_of is a native edge whose kind has "their own UI affordances" (references/cli.md:230).

Collections also carry a description, are renamed once instead of across every member, nest, and need no schema change to join.

The existing collection guidance is actively wrong. SKILL.md:244-249:

Use a relationship with --type member_of against the collection node. If the collection doesn't exist as a node yet, ask the user to create it first.

CollectionService::resolve_path (collection_service.rs:389) creates missing collections automatically, including every segment of a nested path. The skill tells the agent to interrupt the user for something the system does silently — the most expensive path and an unnecessary stop.

Collection paths are never explained. --collection <path> appears four times in references/cli.md (:179, :413, :439, :447) with examples like "docs:rust", and nothing says : denotes hierarchy, that missing segments auto-create, or that the node joins the leaf.

member_of's no-declaration status is documented far from where it is needed. cli.md:230 states it correctly, under relationships. An agent that had just been rejected for an undeclared targetType, then saw collection's empty relationships array, concluded membership needed a schema update first — a correct prose rule losing to a stronger inference from an error message.

  • State that collections are the tagging and grouping mechanism — flat labels and hierarchical paths as one system, not two options
  • Prefer a distinct rule in skill_rules.rs (a GROUPING_IS_COLLECTIONS sibling) over a clause inside RELATIONSHIP_VS_FIELD, so each rule teaches one recognition
  • Name the false friends: tags, categories, topics, labels, areas, groups
  • The escape hatch stays reachable — a user who asks for a plain tags field gets one without argument
  • Fix SKILL.md:244-249: stop telling the agent to have the user pre-create collections
  • Explain collection path syntax once, properly, rather than implying it through four flag descriptions
  • State member_of's no-declaration status where collections are discussed, not only under relationships
  • State that a node has one parent but many collections — membership and hierarchy are different axes, and the skill never says so
  • Once node create --collection <path> exists (tracked separately), make the one-call form the primary documented example

3. Documents should decompose into child nodes

An agent authored a ~40-line ADR — headings, prose, nested bullets — and stored the whole document as one node's content. The intended shape is a root node with ## Context, ## Decision, ## Consequences as children: NodeSpace is one-node-per-block with hierarchy as first-class edges. Nothing rejected it; the create succeeded and queries returned it.

Its own reconstruction, all verified:

  • Every node create example is a one-liner. Eight of them (SKILL.md:182, :194, :207, :211, …), all short single-line content. Nothing demonstrates a multi-block document, so the working template becomes "one node, one line" — and scaling up means making the line longer, not decomposing.

  • "Content is markdown" reads as permission. SKILL.md:24: "Store prose, code blocks, lists — whatever fits the note." That is about a single node's content being markdown-formatted, but nothing rules out the other reading.

  • import file is filed under "Bulk import from markdown" (SKILL.md:263), documented as "Top-level headings become root nodes, sub-headings become children" — exactly the decomposition wanted. The agent had already written the body to a markdown file and cat'd it into --content instead:

    The capability was documented, I'd read it, and I still didn't reach for it — because it's filed under "Bulk import from markdown", and I'd classified my task as "create one ADR," which didn't feel like bulk anything.

  • Nothing pushes back — no validation notices headings in content and asks whether children were meant.

  • Add a worked example of authoring a structured document: root plus one child per section

  • State the boundary as a one-line rule — "if it has headings, it is a tree, not a node"

  • Reframe import file as the normal path for any multi-section content, including a single document just authored, not only bulk/migration

  • Revisit SKILL.md:24's "whatever fits the note" — it is the sentence that licenses a document in one node

  • Show the intended shape for document-like entities (ADR, spec, plan) in Common Agent Tasks, which agents use as a template menu

  • Cover both the --content and --params-file paths, since a long body naturally arrives via a file


4. Property shape in --json output

Node properties are namespaced under the schema id on the wire (properties.task.status), while the skill's only properties example is {} (SKILL.md:304) and the --json shape is never described (references/cli.md:12 says only that the flag exists). An agent parsing --json wrote n['properties'].get('status'), got nothing, and nearly reported "1 task, status unknown" as a fact about the user's data.

The CLI-side fix is tracked separately — --json should emit the flat API shape the existing flatten_properties_for_api already defines, so nesting is never observable from the CLI. This item is only the documentation half, and its content depends on that landing.

  • Once the CLI emits the flat shape, SKILL.md's node example shows a populated properties object reflecting it, not {}
  • references/cli.md describes the --json output shape rather than only stating the flag exists
  • If the CLI fix is deferred, document the nesting and the --filters asymmetry as an interim measure — but prefer fixing the CLI

Verification

The failure mode here is guidance that reads correctly and does not change behaviour, so wording changes must be tested rather than assumed.

  • Cold agent, no prior NodeSpace knowledge, asked to design a schema for a document-like type: produces relationships for entity-shaped fields and does not invent a tags array for topic areas
  • Cold agent asked to "organize these notes by topic": reaches for collections with paths, does not stop to ask the user to pre-create them
  • Cold agent asked to author an ADR or spec: produces a root plus child sections, not one node containing a document
  • Re-test end to end rather than assuming a wording change lands — every failure here was a rule that existed in prose and did not fire

Context

All four from real external Claude Code sessions on a clean v0.2.7 install. Consolidated from what were separate issues: they edit the same two files, share a root cause, and are verified in a single pass.

Activity

  1. added
    documentation
    on Sep 7, 2026
  2. malibio commented on Sep 7, 2026

    @malibio
    CollaboratorAuthor

    A second instance of the same recognition gap, from the same session: grouping fields vs collections.

    The agent designed the ADR schema with tags: array and did not consider modelling topics as collection nodes until the user raised it. Its own assessment afterwards:

    The honest tradeoff is write cost versus queryability, same shape as the deciders question — and I gave you the array there without flagging the alternative, which was the weaker call given I'd just argued the opposite way for deciders.

    The decisive factor it did not have: member_of is one of the four native edges (models/schema.rs:56) and, per references/cli.md:230, these have "their own UI affordances". A collection appears in the sidebar and is navigable; a tag string has no UI anywhere. So for a durable topic area the user would browse, a collection is not merely better-modelled — it is the only option that surfaces in the product. That is a stronger argument than queryability alone and is not stated anywhere an agent would encounter while designing a schema.

    A related false alarm worth fixing alongside it. The agent also warned it had not verified that collection membership works, because collection's schema shows "relationships": []:

    the skill docs describe organizing into a collection via relationship create --type member_of, but I have not verified that the Collection schema actually declares a member_of relationship — and per the supersedes error, relationships must be declared on a schema before use.

    It works fine — core_schemas.rs:587 says // member_of is a native edge, not schema-defined, and cli.md:230 documents the exemption explicitly. But the agent had just been rejected for an undeclared targetType, generalised that rule, saw an empty relationships array, and concluded the documented path was unverified. A correct prose rule lost to a stronger inference from an error message.

    Suggested additions to RELATIONSHIP_VS_FIELD (or a sibling rule):

    • Teach the grouping recognition too: a field holding topics, categories, areas or labels may want to be collection membership, not an array — with the sidebar/navigability point as the reason
    • State the boundary: durable groupings the user would browse → collection; incidental high-cardinality labels → array. Both are legitimate, for different lifespans
    • Surface the four native edges (member_of, has_child, mentions, has_role) at schema-design time, not only in the CLI reference — an agent designing a schema needs to know these exist and need no declaration, precisely because the declaration rule it just learned does not apply to them
  3. malibio commented on Sep 7, 2026

    @malibio
    CollaboratorAuthor

    Sharpening the grouping half: it should be stated as a default, not a trade-off.

    My earlier comment framed collections vs. a tags array as "here is when each wins". That is too weak, and it reproduces the failure — an agent that weighs it each time is an agent that will keep inventing tags: array, which is exactly what happened in the observed session.

    The rule to encode:

    Grouping, tagging, categorising or labelling is done with collections. Declare a string-array field for it only when the user explicitly prefers one, or the labels are genuinely throwaway and would never be browsed.

    Collections are the built-in mechanism and win on every axis: navigable in the product (member_of is a native edge whose kind has "their own UI affordances", cli.md:230), a real node that can carry a description and be renamed once instead of across every member, hierarchical ("docs:rust" nests, an array is flat), and requiring no schema change to join. Once node create --collection <path> lands, not more expensive to write either — one flag versus --property tags='["a","b"]' with its JSON quoting.

    So the schema-design rule should steer an agent away from declaring a tags-shaped field at all, rather than helping it choose. An agent should have to justify not using a collection, not the reverse. The escape hatch stays real — a user who asks for a tags field gets one — but it is the exception.

    This is the same shape as the deciders case this issue already covers: the agent's default was to invent a scalar/array field for something the graph models natively. Person-shaped fields → relationships; grouping-shaped fields → collections. Both are recognition rules, and both need to be defaults rather than considerations.

    Concretely for skill_rules.rs: the false-friend field-name list should cover grouping names too — tags, categories, topics, labels, areas, groups — alongside the person-shaped ones (deciders, assignee, owner, …). Both lists exist to catch a field name that reads as plain data but is really something the graph already models.

  4. malibio commented on Sep 7, 2026

    @malibio
    CollaboratorAuthor

    Refining my previous comment once more, per the user: collections replace tags and structured grouping. Not "are preferred over" — they are the mechanism, and there is no separate tagging feature to choose against.

    That changes what the rule should say. "Collections vs. a tags array" invites the agent to design a tagging system and pick an implementation. The accurate framing is that one already exists and spans both cases: a flat label (storage) and a nested path (docs:rust) are the same mechanism at different depths.

    So an agent declaring a tags: array field is not choosing a lighter-weight option — it is building a parallel, invisible reimplementation of a built-in system. Invisible literally: array values appear in no UI, while collection membership is navigable (member_of is a native edge whose kind has "their own UI affordances", cli.md:230).

    For skill_rules.rs, that argues for a distinct rule rather than a clause inside RELATIONSHIP_VS_FIELD — something like a GROUPING_IS_COLLECTIONS sibling:

    GROUPING: Nodes are tagged and grouped with collections, not with fields. A flat label and a nested hierarchy are the same mechanism — storage, docs:rust. Do not declare tags, categories, topics, labels, areas or groups as array fields; that reimplements collections without their UI. Declare one only if the user explicitly asks for a plain-text field.

    Keeping it separate from the relationship rule also keeps each one teaching a single recognition:

    • person/entity-shaped field → relationship
    • grouping-shaped field → collection

    Both catch the same class of mistake — a field name that reads as ordinary data but names something the graph already models — but they resolve to different mechanisms and are better learned apart.

  5. changed the title [-]Schema-design guidance doesn't teach agents that person-shaped fields should be relationships[/-] [+]Skill guidance: teach relationships, collections, and document decomposition — agents invent flat fields for what the graph models natively[/+] on Sep 7, 2026
  6. mstomar125 commented on Sep 8, 2026

    @mstomar125
    Contributor

    Items 2 (collections) and 4 (JSON property shape) were already fixed by #2450 and #2423 before this issue was picked up.

    Items 1 (relationship recognition) and 3 (document decomposition) fixed in #2466: worked examples + a false-friends list added to references/cli.md's schema section, and a decomposition worked example + reframed bulk-import guidance added for structured documents. SKILL.md itself only got the minimal fix (dropped a bad assignee: text example, added a cross-reference) since its body was already at ~4992/5000 of its enforced token budget before this PR — the substantive detail lives in cli.md instead (no cap).

    Scope note: #2466 only updates the markdown skill (cli.md's prose form, consumed by external PTY agents) for item 1. The parallel imperative form in packages/agent/src/skill_rules.rs::RELATIONSHIP_VS_FIELD — what the in-app local agent reads — is untouched (packages/agent boundary). Filed #2467 as a fast-follow for that half.

    Closing this issue as done for the markdown-skill side; #2467 tracks the remaining in-app-agent half.

  7. added a commit that references this issue on Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    aidocumentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions