Skip to content

Declare context paths on a schema, derive a node's skills from the node and the queries it matches, and return a versioned context read #3557

Closed

Description

@malibio

Overview

With skills attachable to nodes and a read that follows paths, two things are still decided by the caller: which paths count as a node's context, and which skills apply to it. This issue makes both data. A schema declares its context paths, and a node's skills are derived from the node: those attached to it, the saved queries it currently matches, and the nodes its context paths reach. One command then returns the next piece of work with everything an agent needs, and a version lets a client tell when any of it changed.

Problem Statement

  • Context is whatever the caller asks for. Reading a task with its spec, plan and project means the caller knows those paths. A plugin, a skill and a launched session would each restate them, and a team could not change what a task's context is in one place.
  • A queue's procedure is lost on pick-up. A procedure skill is attached to the "Ready tasks" query, but a task that has been started no longer matches it. A later session reading that task gets no procedure. Skills have to follow the node, not the route an agent took to it.
  • Two calls where one would do. An agent runs a queue, then reads the item it picked. Only a skill's wording tells it to make the second call.
  • No way to tell that something changed. A session working on a task cannot cheaply learn that the task, its spec or its procedure moved on.

Proposed Solution

  • Context paths on a schema. A schema declares the relationship paths from a node of its type to the nodes that govern it. They resolve through the extends chain and are the default paths a context read follows. A user can add or remove paths on any schema, core ones included.
  • Applicable skills. A context read returns the skills attached to the node, every saved query the node currently matches, and every node its context paths reach.
  • Run with context. Running a saved query can return each item with its context and applicable skills, in one output.
  • A version on the read. A context read returns a version that changes when the node, anything it returned, or the node's applicable skills change.

None of it knows a type or a workflow.

Documentation

  • ADR-094 §2 (context paths), §4 (a node's skills are derived from the node), §7 (a read has a version); Consequences - membership costs a query per queue with skills attached; Build order step 4
  • ADR-093 §3 - what an agent receives with an item; §5 - the plugin compares the read's version during a turn
  • ADR-072 - a user's edit to seeded content is kept; context paths are a seeded aspect of a core schema
  • ADR-078 - resolution through extends
  • Relationship paths and Schema management
  • Node type sequence - the schema node gains a declaration
  • Updates: components/schema-management.md (context paths), components/node-types.md (the schema sheet), architecture/prompt-skill-system.md (applicable skills), packages/skill/references/cli.md and SKILL.md

Architecture Impact

Implements ADR-094 §2, §4 and §7. Context paths on a core schema are user-editable, which is new: until now a user could extend a core type but not change something NodeSpace seeded on it. ADR-094 decides this and ADR-072's rules apply to it as a seeded aspect.

Acceptance Criteria

Context paths

  • A schema declares a list of context paths, each a RelationshipPath validated against the schemas when saved; an invalid path is refused with a message naming it
  • A subtype's context paths are its ancestors' plus its own
  • A user can add and remove context paths on a user-defined schema and on a core schema, through the schema update the CLI and the built-in agent already use
  • A user's change to a core schema's context paths survives a restart and a later seed (ADR-072)
  • A context read with no paths given follows the type's context paths; paths given explicitly are followed in addition
  • The wire SchemaNode carries the paths and TypeScript is regenerated

Applicable skills

  • A context read returns the skills attached to the node, the skills attached to each saved query the node currently matches, and the skills attached to each node its context paths reach; each skill appears once, with what it was reached through
  • Query membership is evaluated only for saved queries that have at least one skill attached
  • A node that stops matching a query stops carrying that query's skills on the next read, and one that starts matching begins to: a test moves a node between two queries with skills attached by changing a field
  • A saved query that uses a relative date or run-time narrowing is evaluated for membership as stored
  • The rule contains no node type by name; the user-defined workflow fixture from the skill-link work passes with query membership added

Run with context

  • Running a saved query with context returns each item with its governing nodes and applicable skills in one output; a limit applies to items
  • A skill shared by several returned items is output once

Version

  • A context read returns a version; reading again with nothing changed returns the same version
  • The version changes when the node changes, when a node the read returned changes, when an attached skill's content changes, and when the set of applicable skills changes
  • The version does not change when an unrelated node changes
  • A client can ask for the version alone, without the content

General

  • The built-in agent has the context read and run-with-context as tools, in the tool registry with their CLI commands
  • references/cli.md and SKILL.md document the context read, run with context, and the version; bun run skill:check passes
  • Docs updated as listed under Documentation
  • Code passes bun run quality:fix
  • Tests pass (bun run test:changed)

Technical Specifications

Reference Files

  • packages/nodespace-types/src/schema.rs - SchemaNode; packages/nodespace-types/src/relationship_path.rs
  • packages/core/src/schema/mod.rs, packages/core/src/schema/extends_chain.rs - schema create and update, chain resolution
  • packages/core/src/playbook/selectors.rs - selects_node, which already answers "does this saved query match this node"
  • packages/core/src/services/query_service/mod.rs - query execution
  • packages/core/src/ops/skill_ops.rs - rendering a skill for its reader
  • packages/core/src/services/node_service/mod.rs - seed reconciliation and the per-aspect modified flags
  • The read-with-paths operation and the attached_to relationship added by the skill-link work

Implementation Details

  • Derive the version from stored state (ids and versions of everything returned), not from a counter.
  • A path walk in SQL uses a correlated subquery, not a JOIN in a recursive CTE.
  • Keep the membership check a per-node evaluation of each query that has a skill attached; do not materialise membership.
  • Resolve types through the registry, never a literal node_type comparison.

Dependencies

Related Issues

Non-Goals

  • Seeding context paths on task, spec or plan, and seeding any queue or skill link
  • Recording which session is working on a node

Activity

  1. malibio commented on Oct 5, 2026

    @malibio
    CollaboratorAuthor

    Note from #3558 (merged in #3572): pending seed updates are recorded per seeded node and aspect by seed reconciliation, but core schemas are created when missing and never reconciled afterwards. So a shipped change to a schema's context paths has no kept-versus-shipped case to record yet. When context paths land here, reconciling them (with a user-modified flag) is what lets a user's edited context paths be put to them through the same pending table, CLI (nodespace seed ...) and Settings page. That acceptance criterion of #3558 was left unmet for this reason.

  2. malibio commented on Oct 5, 2026

    @malibio
    CollaboratorAuthor

    Baseline — Frontend: 320 test files passed, 5797 tests passed

  3. self-assigned this
    on Oct 5, 2026
  4. malibio commented on Oct 5, 2026

    @malibio
    CollaboratorAuthor

    Node type sequence — classification: this changes the schema meta-type (kind: meta-type, no schema of its own; flat properties on the schema node). It gains one declaration, contextPaths (a list of RelationshipPath), stored in the schema node's properties and carried on the wire SchemaNode as contextPaths. No field, relationship, structural rule or subtype of any other core type changes, and no core schema is seeded with a path. State placement: the paths are names of relationships (a walk), not node ids, so they are a declaration on the schema and not edges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions