Skip to main content
AI coding tools tend to cause two kinds of accidents in complex repositories: editing application code before requirements are confirmed or during verification, and writing files into the wrong directory or corrupting state files when multiple branches and tasks coexist. Native manages these risks through a clear division of responsibilities: the Agent interprets requirements, runs platform checks, and assesses edit impact; the Runtime and Hook Guard enforce task ownership, stage write boundaries, formal state protection, and archive transactions in the background. These protections stay active automatically—you do not need to toggle or maintain them with manual commands.

Task ownership and temporarily stepping out of the workflow

A single repository can enable both Native and Classic, but each individual change belongs to one workflow. The current workspace selection is stored in .comet/current-change.json, and the Hook Router reads ownership before invoking that workflow’s Guard.
  • Automatic ownership: When the current workspace has exactly one active change and no explicit selection, Comet associates writes with that task automatically.
  • Multiple active tasks or ambiguous ownership: Comet pauses and lists candidates for you to choose instead of guessing a default.
  • Switch the active task: Tell the Agent in chat “Switch to <change-name>”, and the Agent updates workspace ownership in the background.
  • Make temporary edits unrelated to Comet: Tell the Agent in chat “I need to make a quick unrelated edit outside the current Comet task”, and the Agent clears the workspace selection in the background (via comet native select --none):
    • The setting applies across sessions in the same workspace, allowing ordinary project code edits and pausing passive resume probing;
    • Formal workflow directories and state files remain protected even while unselected;
    • When you are ready to return, tell the Agent to continue the original task to restore ownership.

Seven write-interception protections in Hook Guard

On Agent platforms that support Hooks, every file-write tool call passes through Hook Guard first. When a write is blocked, the Guard returns an explicit reason and actionable next step so the Agent can self-correct. Beyond basic stage gating, the Guard blocks six additional classes of common misoperations.

1. Stage-based code write boundaries

2. Six path and ownership misoperation guards

  1. Block manual edits to Runtime control files: Direct edits to .comet/current-change.json, workspace runtime state directories, or a change’s comet-state.yaml, verification.md, and capability-association.yaml are rejected immediately.
  2. Block unregistered formal files and wrong artifact roots: Creating changes/<name>/brief.md manually without registering the change, or writing into a misconfigured .comet/comet/changes/ path outside the project’s native.artifact_root (default docs, corresponding to the active directory docs/comet/changes/), is intercepted with the correct registration step or target path.
  3. Protect published project Specs: Editing published specs/<capability>/spec.md directly is blocked; the Guard directs edits into the current change’s draft Spec so they merge cleanly during Archive.
  4. Block mixing formal requirements and code in a single write: A single write call that modifies both brief.md/specs/ and application source code or ordinary documents is rejected so requirement updates and implementation remain separate steps.
  5. Block cross-change miswrites: Attempting to edit formal files belonging to another active change (or an unregistered change) prompts you to switch tasks first or open a dedicated worktree for the new requirement.
  6. Prevent miswrites during shared planning and after worktree handoff: When multiple active changes share a planning branch, code edits are blocked until a dedicated Build worktree is prepared; once a change hands off to its new worktree (executionCwd), writes to the old planning directory are intercepted and redirected to the new path.

Document write policy and Hook boundaries

Hook Guard uses two settings in .comet/config.yaml to control allowed writes outside Build (see Native configuration for full fields and YAML examples):
  • Non-Build write policy (native.document_writes): walkthrough.html and .comet/config.yaml are always allowed regardless of this setting. Default allow permits ordinary document edits outside the artifact root and preserves manual edits during Verify and Archive so the Agent can inspect the diff and assess impact without blindly wiping approvals or verification records. Setting revert causes Hook Guard to block ordinary document writes outside the artifact root in non-Build stages and strictly block application code writes during Verify and Archive.
  • Custom Hook allowlist (hook.allow_paths): Allows project-specific scripts to write to designated project-relative directories and their subpaths (paths outside the project root are allowed by default). .comet/, the Native artifact root, and the Classic artifact root cannot be bypassed via the allowlist; if a single write touches both an allowlisted path and a protected path, the protected target is still blocked.

Hook security boundary

Hook Guard intercepts only file-write tool calls exposed by the Agent platform—it is not an operating-system sandbox. Files saved directly in an external editor, written by third-party background processes, or modified through unexposed platform channels do not trigger Hooks. In addition, some Agent platforms require explicitly enabling or trusting Hooks in settings; installing a plugin alone does not guarantee Hooks are active. For this reason, diff verification in Verify and candidate/workspace checks in Archive remain the final line of defense.

Lock-free workflow design and concurrency isolation

  • Commands run directly via platform tools: Builds, tests, and static checks run directly through Agent platform tools. The Runtime does not host these processes or track command PIDs and stop receipts.
  • Single writer and worktree isolation: Only one writer updates state in a workspace at a time, while parallel tasks are physically isolated in separate Git worktrees.
  • No workflow file locks: Native creates no workflow process locks or file locks when writing state, and does not rely on historical PIDs to judge liveness or require manual lock cleanup. Recovery after interruptions relies on unfinished transaction records (storage locks for shared plugin and installation directories are diagnosed separately via comet doctor --lock-file).

Read-only ambient resume probe (comet resume-probe)

When you open a new session and say something like “continue that change” or “finish running verification”, the read-only comet resume-probe checks whether the current workspace has a recoverable active task without changing the selected change or switching Git branches. The probe combines semantic confirmation with clause-level negation detection to minimize false triggers:
  • Ask for confirmation on semantic matches: In a new session, if you mention something related to an existing task without naming the change or explicitly asking to continue it, the probe asks you to confirm whether to resume—even when only one active task exists in the workspace—instead of silently entering the workflow.
  • Detects negated clauses: It splits sentences on punctuation and conjunctions like “but” / “however”. If a change name or resume verb appears inside a negated clause (such as “don’t resume auth-fix, just answer a question first”), it will not treat the prompt as a resume request.
  • Distinguishes declining a new workflow from resuming an old task: Saying “don’t start a new workflow, continue the previous one” is still recognized as resuming the existing task.
  • Explicit opt-out phrases: Phrases like “without comet”, “just explain”, or “answer only” bypass workflow routing immediately.
  • Configuration switch: Set ambient_resume: false in .comet/config.yaml (or ask the Agent to clear task selection) to disable passive probing.

Transaction protection and offline diagnostics

Both Archive and artifact root migrations are protected by transaction logs so recovery after a power loss or crash resumes from recorded progress without repeating completed steps. For routine checks, just ask the Agent. If you want to inspect the workspace yourself in a terminal, run these read-only diagnostic commands (they do not modify any state):
Switching or clearing task selection is normally handled by the Agent via comet native select; the commands below are provided for offline terminal troubleshooting:
For step-by-step troubleshooting by failure mode, see Native task recovery.
Last modified on December 1, 2026