Skip to content

Let a harness ask NodeSpace whether a repo write is allowed #3708

Closed as not planned

Description

@malibio

Overview

Harness hooks can refuse a tool call but need a verdict from somewhere. Plays fire on graph events and a repo write is not one. This adds a nodespace gate check command that answers "may this session edit files in the project right now?" by evaluating the rules, so every harness integration asks the same question and the rules live in one place.

Problem Statement

  • The process is enforced only on graph writes. A plan cannot be approved before its spec, and a planned task cannot start without lineage, but an agent can edit the repository with no claimed task and no approved spec.
  • A skill is advice. The implementing skill tells an agent to claim a task first. Nothing refuses the edit if it does not.
  • Each harness would otherwise hold its own copy of the rule. A hook that decides for itself would drift from the Plays.

Proposed Solution

  • nodespace gate check takes the session (NODESPACE_SESSION), the action kind (repo_write) and the target paths, and returns allow or deny, a reason written for the agent, and the name of the rule that decided.
  • Evaluation reuses the dry run from ADR-094 §9 rather than adding a second rule matcher. ADR-097 §2 decides this (design B); a new action-attempt trigger kind is deferred until a rule must name a path.
  • Advisory by default. A rule that would deny returns allow with a "would have denied" note and is counted. Enforcement is switched on per rule, without editing the Play. The would-deny count is the shadow-period report.
  • Recorded override. A person can allow a specific denied edit or task with nodespace gate allow <task> --reason "...", recorded on the task. This is a convention: core has no access control, so nothing stops an agent running it. The gate catches mistakes and drift; it is not a defence against an agent set on bypassing it.

Documentation

  • ADR-097 - the gate this issue builds
  • ADR-094 §9 (dry run), §6 (claiming by version)
  • ADR-093 §5 (harness plugins)
  • ADR-095 (where per-rule enforcement could live)
  • playbook-engine.md "Dry run of a write" - the conditions-only mode the check reuses, and how it differs from workflow state (which evaluates a node as it stands)
  • agent-session.md and ADR-032 - launched sessions and their variables
  • playbook-system.md - rule classes, dry run
  • ADR-060 (invariant rules)
  • Updates: packages/skill/references/cli.md, architecture/playbook-engine.md

Architecture Impact

Extends the dry run (ADR-094 §9, done) to a question that is not a property change. Changes a consequence stated in ADR-094 ("Nothing forces an agent to act on what it read") and adds a second reason for in-turn refusal beside ADR-093 §5; both are recorded by ADR-097 (Proposed, on docs main). Accept it before starting.

Acceptance Criteria

  • nodespace gate check returns a verdict (allow or deny), a reason, and the deciding rule
  • A session with no NodeSpace session, or one not tied to a project, is allowed
  • Reads, nodespace commands, and writes outside the project folder are never denied
  • Rules ship advisory. An advisory rule that would deny returns allow with a "would have denied" note and increments a count the user can read (nodespace gate report)
  • A rule can be switched to enforcing per rule, without editing the Play; the setting's home is decided and recorded
  • A deny reason states that the edit was not made, names the next nodespace command, names the skill to follow, and tells the agent not to retry the same edit
  • nodespace gate allow overrides a specific denial with a reason, recorded on the task
  • The CLI help and docs state that override and approval are conventions, not access control, and that a check is a prediction
  • A task already in_progress is evaluated correctly: the dry run of "this task is in in_progress" does not become a no-op for transition-triggered rules (test with a task whose spec is later unapproved)
  • If the daemon cannot be reached or the check times out, the verdict is allow and the output says the check did not run
  • The measured time of a check is recorded in the issue before it closes
  • references/cli.md documents the commands; bun run skill:check passes
  • Code passes bun run quality:fix
  • Tests pass (bun run test:changed)

Technical Specifications

Reference Files

  • packages/core/src/services/node_service/invariants.rs (the one invariant execution loop, with a conditions-only mode)
  • packages/core/src/playbook/workflow_state.rs
  • packages/core/src/playbook/core_plays.rs
  • packages/cli/src/commands/ (new gate.rs; session.rs for session handling) and the daemon's gRPC surface
  • packages/agent/src/pty/session.rs (NODESPACE_SESSION, NODESPACE_LAUNCHED_FOR)

Implementation Details

  • Resolve the session's task: NODESPACE_LAUNCHED_FOR for launched sessions; otherwise the task that session started. "No claimed task at all" is answered by the command before any rule runs.
  • Override and approval: ADR-092 says approval is the user's, enforced only by seeded skills telling an agent to leave specs in draft and ask. There is no mechanism to reuse. Do not claim the agent cannot override; restricting who may approve is access control and belongs in nodespace-sync.
  • Fail-open on timeout or unreachable daemon is deliberate: a broken gate must not stop work.
  • Shipping a CLI input/output change needs skill-guidance criteria in this same issue (above).

Dependencies

Related Issues

Non-Goals

  • Covering shell commands that write files
  • Any rule logic in the harness hook
  • A new trigger kind for action attempts

Activity

  1. self-assigned this
    on Oct 10, 2026
  2. malibio commented on Oct 10, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 5873 passed (324 files)

  3. malibio commented on Oct 11, 2026

    @malibio
    CollaboratorAuthor

    Closing as deprecated. The harness-facing gate command is not being built: enforcement is the claim write itself (the seeded invariant refuses moving a task to in_progress without an approved spec), and the version check tells a session its task changed. Related: #3711 and #3712 depend on this and need revisiting.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions