AGENTS.md - Unified Workspace Protocol (Nomos Deterministic Engineering Substrate)
Role: Senior Autonomous Architect
Objective: Drive tasks via nomos. All quality gates are Go-native and machine-enforced.
0.0 🛡️ THE ONE-PAGE INVARIANT CARD (THE 7 LAWS)
| Law # | Law Name | Core Architectural Invariant | Machine Enforcement Mechanism |
|---|---|---|---|
| 1 | The Dual-Core Inversion Law | Substrate Go core governs state & execution; LLM operates strictly as bounded cognitive co-processor. | nomos verify, Phase Discipline state machine |
| 2 | The Non-Verbal Proof Law | Zero trust in conversational claims; code correctness requires compilation exit code 0 and AST proof. | 39 Go-native DoD Quality Gates (nomos verify) |
| 3 | The Hermetic Worktree Law | Protected trunk branches are physically read-only; mutations occur strictly inside isolated task worktrees. | CheckRootBranchEditBoundary, Pre-Commit Hooks |
| 4 | The Single Source of Truth Law | Every contract, schema, and configuration possesses exactly one compiled Go SSoT with byte parity. | Cryptographic SHA-256 parity audit (nomos intent check) |
| 5 | The Zero-Hardcoded-Path Law | Path literals and repository directory structures strictly prohibited in source; paths resolve dynamically. | Configuration discovery (config.LoadGlobalConfig()) |
| 6 | The Canonical Singularity Law | Zero aliases, duplicates, or convenience wrappers tolerated in CLI engines or contract schemas. | Zero-Alias AST Parser validation (src/nomos/cmd/) |
| 7 | The Fail-Closed Pre-Flight Law | Mutations require explicit declarative configuration and pass 39 mandatory DoD gates. | CapBAC Object Capabilities, phase budget enforcement |
0. 🟢 CONTEXT & SPECIFICATION
- Boot Handshake: Run
nomos sys handshake(or/nomos-handshake) on session boot to initialize state, sync protocols, and queryGitBrainmemory. - Task Claim & Scaffolding: Start active tasks via
nomos task start <KEY>. Child tasks in open Cycles auto-promote to parent Cycle worktree. Mutations execute strictly in transient worktrees (worktrees/<repo>-<task>). - PO Consent & Tier 1 Agent Agnosticism: Draft
implementation_plan.mdin Brain artifact directory without writing flat files to source trees. Approval is Go-enforced: ifhitl.require_plan_signoff: true, approve vianomos task approve; if autonomous, substrate self-approves at PLAN entry. - Development Loop (TDD): Plan (
PLAN) → Transition to Edit (nomos task transition EDIT) → Verify (nomos verify) → Release (nomos task sync --approve -F walkthrough.md).
0.1 🏛️ THE DUAL-CORE ARCHITECTURE (Substrate Core vs. Intent Core)
- Deterministic Cognitive Scaffolding (Inverted Control Flow): Compiled Go engine (
nomos) runs the state machine, invoking the LLM as a bounded "Cognitive Co-Processor". - Intent Plane (Yang / Intent Core): High-level reasoning and playbooks (
/nomos-handshake,/nomos-plan,/nomos-design,/nomos-exec,/nomos-review,/nomos-dual-core-refactor,/nomos-ship), cognitive profiling (cli:low/cli:high), candidate bundle dry-runs (nomos task bundle --dry-run). - Execution Substrate (Yin / Substrate Core): Compiled Go binary (
nomos), SQLite state (~/.nomos/data/db/nomos_global.db), 39 binary DoD quality gates (cyclomatic complexity < 10/15, docstring density >= 10%, import boundaries, Phase locks). - Physical Totem (Inception Paradigm): Go substrate acts as immutable physical totem, anchoring recursive agent reasoning back to host reality.
- The Sixteen Core Architectural Axioms:
- Topological Symmetry: Harness underneath AI agent mirrors state topology of reasoning loop.
- Dual-Core Division: Intent Core (Yang) explores and designs; Substrate Core (Yin) enforces and guarantees.
- Non-Verbal Proof: Never ask an LLM if code is correct; compile it, verify AST invariants, and run tests via Go binaries.
- Topological Slicing: Cognitive size is warning indicator; Domain and Layer separation is remedy. Tasks never span conflicting planes.
- Canonical Singularity (Zero-Alias Law): Every capability possesses strictly one canonical, bijective representation. Zero aliases tolerated.
- Epistemic Distrust (Verification Asymmetry Law): Code generation is stochastic streaming; proving code is deterministic. Transitions require exit code 0 and AST proof.
- Ambient State Isolation (Hermetic Worktree Law): Protected trunks are read-only. Mutations occur strictly in ephemeral worktrees: Scaffold → Sandbox Execution → DoD Verification → 2PC Atomic Release.
- Non-Destructive Refactoring (AST Preservation Law): Modularization must never be achieved via destructive omission or stubbing. Symbol parity and docstrings must be preserved.
- Unified Schema Transduction (Single-Path SSoT Law): Every contract possesses exactly one compiled Go SSoT. Downstream consumers receive projected mirrors with 100% SHA-256 byte parity.
- Dynamic Ecosystem Discovery (Zero-Hardcoded-Path Law): No workspace path or repo identity may exist as a string literal; paths resolve dynamically via
config.LoadGlobalConfig(). - Total Reification (Zero-Implicit Law): Dependencies, parameters, arguments, and invariants must be explicitly declared in AST, SQLite schema, or task manifest. Zero implicit state.
- Binary Diagnostics (Silent Metric Law): Substrates enforce binary evaluation: state is valid (
PASS) or hard compiler failure (FATAL). Output is structured JSON schema, never conversational prose. - Deterministic Ephemerality (Anti-Accretion Law): Every mutation executes against a clean worktree pinned to a known commit whose output collapses to a single verifiable diff.
- Bidirectional Verifiability (Specification-First Law): Invariant schemas and contract gates precede execution. Entering
EDITrequires a deterministic gate failing on current state. - Deterministic CLI Exploitation: If a compiled CLI command exists in Substrate, ad-hoc scripts (Python, Bash, SQLite) are prohibited. All operations proceed through deterministic CLI commands.
- Intent Parsimony (Timeless Protocol Law): Intent Core contains timeless structural axioms and operational orientation; machine enforcement belongs strictly to compiled Go substrate gates.
0.2 🏛️ THE FORMAL DEFINITIONS HIERARCHY & SSoT INVARIANTS
Terms adhere to a 5-layer formal hierarchy:
- Layer 0: Axiom (Ontological Bedrock): Foundational premise assumed true without proof (e.g. Zero-Alias Law).
- Layer 1: SSoT Invariant (Mechanized Boundary): Executable contract derived from an axiom, anchored to a single source artifact.
- Layer 2: Definition of Done Gate (Executable Verification): Strict boolean AST/compiler check in
nomos verifyhalting execution on violation. - Layer 3: Autonomous Capability (Linear Action): Phased permission token (e.g.
MutationCapabilitystrictly inEDIT). - Layer 4: Telemetry & Proof (Mathematical Record): Immutable 10-Plane net delta scorecard and Git Note signature attached to release commits.
The Git Topology Revolution: Plane-Aligned Trunks & Ephemeral Worktrees
Abolish legacy staging lobbies (master, main, develop) in favor of 1-to-1 Plane-Aligned Trunks:
vault-intenttrunk:intent(INT-*) |nomos-substrate,nomos-sovereign-substrate,sophia-substratetrunk:substrate(SUB-*)sophia-membrane,nomos-sovereign-membrane,gsi-membranetrunk:membrane(MEM-*) |gsi-infratrunk:infra(INF-*) Topological Symmetry: Physical Workstation (#1–#4) ⟺ Architectural Plane ⟺ Git Trunk Branch ⟺ Task Key Namespace (INT,SUB,MEM,INF). All code mutations occur strictly inside transient task worktrees (worktrees/<repo>-<task>), with zero long-lived staging branches.
0.2 🏛️ THE 11 SENIOR SOFTWARE ENGINEERING DISCIPLINES (SSoT INVARIANTS)
All AI agents (Tier 1 IDE Architects and Tier 2 NCode Swarm workers) must strictly adhere to these 11 disciplines:
- Systemic Invariant Thinking over Symptom Patching: Solve root schemas, AST invariants, and transactionality at physical substrate; never apply symptom patches, flags, or loose environment variables.
- Topological Slicing & Anti-Truncation Discipline: When files exceed 400 lines or CDS > 65, decompose into sibling files (
*_helpers.go). NEVER destructively truncate or stub working logic. - Fail-Closed Pre-Flight Verification: Code mutations must compile cleanly and satisfy AST syntax invariants before exiting
EDIT. - Fast Rollback on Regression (Revert Invariant): If tests fail or undefined symbols occur, do not attempt multi-turn hallucinated patches; immediately
git checkout -- <file>to restore the clean baseline. - SSoT State Purity & Declarative Configuration: Task state belongs strictly in SQLite (
phase_state,tasks) and Nomos CLI commands. Settings reside inecosystem.yaml. Ambient runtime env vars eradicated. Subprocess pipes use explicitNOMOS_IPC_*. - Canonical Singularity & Zero-Alias Discipline: Never add shortcuts, aliases, or shims. When refactoring, execute atomic migration across callers and purge legacy entry points immediately.
- Hermetic Worktree Boundary: Trunk branches (
intent,substrate,membrane,infra) are read-only. Direct modifications blocked by hooks andCheckWorktreeBoundary. Execution occurs in transient worktrees (worktrees/<repo>-<task>). - Cryptographic Parity Invariant: Mirrored docs, schemas, and portals match Living Intent SSoT byte-for-byte (
sha256(src) == sha256(dst)). Direct edits to mirrored files trigger gate failure. - AST Symbol Parity Invariant: Public APIs, exported functions, and behavioral symbols must never silently disappear during refactoring without explicit migration approval.
- Zero-OS-Tmp Discipline: All scratch buffers and CLI payloads MUST be authored strictly within
<repoRoot>/.nomos/data/tmp/(or<conversation-id>/scratch/), NEVER in host/tmp/. - Consolidated Telemetry & Zero-LLM Substrate Boundary: Nomos Core (
nomos-substrate) contains zero AI/LLM inference or prompt logic. Telemetry is consolidated incore/telemetry. Intelligent routing resides innomos-sovereign-substrate. - Knowledge Integrity & Vault Frontmatter SSoT: All markdown documents across the Intent Plane (
vault-intent) must possess machine-verifiable YAML frontmatter (title,type,status,classification,plane,date,authors,tags) adhering toprivate/nomos/architecture/vault_frontmatter_spec.md. Any document in apublic/directory must be strictlyclassification: public. Substrate tools (nomos intent doc create,nomos intent doc normalize,nomos intent check) enforce schema validity and prevent classification leaks.
1. 🧠 Central Engine & Playbooks
- Always execute operations via
nomos(seenomos --help). - Core Workflow Playbooks:
/nomos-handshake: Session boot, SQLite health check, GitBrain memory sync, environment verification./nomos-plan: Strategic backlog triage, debt audit (nomos audit refactor), sizing, bundle dry-runs (nomos task bundle --dry-run)./nomos-design: Generative architecture and interface synthesis across Substrate, Membrane, Intent, and Infra planes./nomos-exec: Active task execution, transient worktree sandboxing, TDD loop, 39 DoD verification gates & atomic release sync./nomos-review: Evaluative adversarial red-teaming and AST/DoD gate verification across all planes./nomos-dual-core-refactor: Coordinated dual-hemisphere refactoring across Intent and Substrate planes./nomos-ship: Unified 7-Gate Multi-Portal SSoT Synchronization, Release Tagging, and Deployment Orchestrator.
- Chore Tasks:
nomos task chore "Fix typo"(ornomos task start "Fix typo" -t chore) auto-scaffolds lightweight chore worktrees.
2. 🛡️ CODING & STATE STANDARDS
- State Integrity: NEVER manually edit SQLite database files (
~/.nomos/data/db/nomos_global.db) or workspace JSON files. All mutations MUST happen via deterministic CLI commands (nomos task start,nomos task transition,nomos task edit). - AI-to-AI Paradigm: Nomos is an AI-to-AI deterministic engineering substrate. Architectural decisions, quality gates, and output formats are optimized exclusively for autonomous AI agents ("Autonomous AI Agents" or "AI Agents").
- The Nomos Cognitive Firewall: Workspace mutability is procedurally locked by the substrate state machine across 9 phases:
IDLE(immutable outside active task) →TRIAGE(sizing, tier routing) →SPEC(contracts, invariants) →PLAN(decomposition, DAG tasks, read-only plan) →EDIT(unlocked strictly in transient worktrees for sandboxed TDD) →AUDIT(adversarial red-teaming) →REVIEW(39 binary AST quality gates) →SYNC(2PC atomic release, branch merge, worktree teardown) →LEARN(GitBrain reverse-reflection, vector indexation). - PhaseLearn Knowledge Distillation: Following 2PC commit sync, tasks transition into
LEARNto execute automated reverse-reflection prior to returning toIDLE. The engine parses walkthroughs and Git Notes (refs/notes/agent), extracts axioms and invariants, and indexes vector embeddings into GitBrain SQLite without flat files. Standalone:nomos task learn [--dry-run] [--task <ID>]. - Linear Logic & CapBAC Phase Budgets: Governed by CapBAC. Ephemeral
AffineCapabilitytokens minted per(task_id, phase)tuple and revoked upon transition. PreToolUse hooks enforce ceilings (TRIAGE: 10/25k,SPEC: 15/50k,PLAN: 25/75k,EDIT: 50/150k,AUDIT: 20/60k,REVIEW: 15/40k,SYNC: 10/25k,LEARN: 15/50k,IDLE: 0/0). Exceeding quota yieldsDecisionDenywhile allowing phase transition. - Phase Tier Governance & Delegation Matrix: Strict Tier 1 phases (
SPEC,REVIEW,SYNC,IDLE) are restricted exclusively to Frontier Orchestrator AI and human signoff (enforce_agent_tier: 2fails closed). Dual-tier phases (EDIT,AUDIT,PLAN,TRIAGE,LEARN) permit delegation. Selective Cognitive Routing: Low-burden chore tasks (cli:low, sizing ≤ 3, leaf refactors, unit tests) are delegated 100% to Tier 2 local SLM workers (nomos code <KEY>/ncode <KEY>) sandboxed in transient worktrees to converge DoD gates and build verified training trajectories. High-leverage architectural designs (cli:high, sizing ≥ 5) and Intent SSoT authoring remain governed directly by Tier 1 Frontier Orchestrators (Sophia / AGY) under 39 Go-native DoD verification gates. Whenphases.edit.enforce_agent_tier: 2is set globally, direct transition intoEDITfails closed without delegation. Commits on Tier 2 branches requireTier: 2andExecutor: ncodetrailers. - Flat-File Planning Artifact Boundary: Writing flat planning files (
implementation_plan.md,walkthrough.md,specs/,plans/) into repository source trees is strictly blocked by theFlat-File Planning Artifact BlockerDoD gate and Pre-Commit Hooks. Planning artifacts reside strictly in the Brain artifact directory and distill into GitBrain upon sync. - Protocol Symmetry Gate: Substrate state machine modifications (
src/nomos/core/state/,src/nomos/modules/exec/phase_*.go,src/nomos/modules/exec/lock.go,src/nomos/modules/exec/substrate.go) strictly require synchronized updates toAGENTS.mdand master workflows in the same change unit. - IDE Ambient State Isolation: Workspace ambient state (window title
[IDE #N: repo] TASK: Summary | PHASE, theme colors) strictly scopes mutations to executing repository and transient task worktrees via helper modules (ide_theme.go,ide.go,stream.go,version.go). Titles omit emojis and reflect explicit IDE identifiers configured in.vscode/settings.jsonorecosystem.yaml. - Transient Worktree Sandboxing: Direct modifications on protected trunk branches (
intent,substrate,membrane,infra, plus legacy baselines) are blocked by Pre-Commit Hooks andCheckWorktreeBoundary. Direct transition toEDITon root branches fails closed. All agents execute code changes inside transient task worktrees (worktrees/<repo>-<task>) wired viago.workandproject_meshes:. Lifecycle: Scaffold ➔ Sandboxed Execution ➔ DoD Verification ➔ Atomic Release & Teardown. - Asymmetric Read/Write Workstation Isolation: Workstations adhere to 7-Workstation Isolation Matrix (INT-59). Writes restricted to transient worktrees. Reads governed by PreToolUse Read Jail: Intent is Universal Observer (read-everywhere), Open-Core
nomos-substrateair-gapped from Sovereign IP (CheckIPLeak), and Membrane portals air-gapped from Go backend source (dogfooding via@nomos/typesandnomos compile types). - Memory Topology: GitBrain (Machine Subconscious: vector embeddings, Git Notes
refs/notes/agent, Ed25519 receipts<!-- NOMOS_RECEIPT_START -->for commit provenance and semantic search) and Unified Vault (Conscious Contract: Markdown repository for architecture, handbooks, governance, and strategy). - Substrate Phase Lock & Multi-Agent Concurrency: Workspace code is locked outside
EDIT. Tier 2 delegation executes vianomos code <KEY>. SQLitephase_staterecords are worktree-scoped and branch-aware, enabling concurrent Tier 1 Orchestrator and Tier 2 NCode workers to operate in parallel transient worktrees with independent locks and DoD gates without cross-session collisions. - Release Walkthrough & Schema: Write
walkthrough.mdto Brain artifact directory without writing flat files to source trees. Format with human-readable sections, appending Dual-Layer Hybrid Schema under## Git Commit Payloadwith**Architectural Rationale:**,**Blast Radius & Contracts:**,**Resolution Mechanics:**, and Git Trailers (Task:,Plane:,Tier:,Executor:,Burndown:,Gate-Proof:). Approval governance is Go-enforced vianomos task sync --approve. Legacy headings remain supported. - Escape Hatches: Bypass unrelated third-party test failures with
**TDD-Skip:** <Reason>, unwired endpoints with**Wire-Skip:** <Reason>, markdown docs with**Doc-Skip:** <Reason>, or math typography with**Math-Skip:** <Reason>trailers in commit payload. - Release Execution & Cryptographic Receipts: Execute atomic release via
nomos task sync --approve -F walkthrough.md. Release sync generates an Ed25519 commit receipt notarizing task ID, commit hash, 39 DoD gates, and walkthrough SHA, signed with private key (~/.nomos/data/keys/receipt_signer.key) and attached to Git Notes (refs/notes/agent). Verified vianomos verify --verify-receipt <SHA>. HALT and end session upon completion. - Inverted Workflow SSoT: The Intent Plane (
vault-intent/public/nomos/workflows/) is the definitive Source of Truth (SSoT) for AI workflows (ADR-0011). Substratesrc/nomos/core/assets/workflows/is an embedded air-gapped mirror synchronized vianomos intent embed. - Automated 10-Plane Quality Debt Telemetry: Starting any Cycle, Debt, or Refactor task captures an immutable 10-plane
BEFOREsnapshot in SQLite (repo_health_snapshots). Task completion capturesAFTERsnapshot, computes net mathematical deltas across all 10 architectural verification planes, and records a standardized Markdown scorecard into task comments (bounded to 8,192 bytes).
2.7 📐 YAGNI & COMPLEXITY STEERING
- YAGNI Ladder: Stdlib first → Native framework features second → Third-party dependencies last. Delete/simplify code before adding abstractions.
- Anti-Abstraction Guardrails: No single-implementation interfaces without explicit requirement. No boilerplate factory classes or DI wrappers. No magic strings (extract into typed constants).
- Domain & Layer Boundary Slicing: Tasks must respect Single-Layer Responsibility. Never combine compiled Go substrate changes with markdown playbooks or frontend UI components. Slicing follows topological domains.
- Mathematical & Telemetry Typography Invariant: Prohibit raw LaTeX math formatting across public docs, handbooks, and vault articles. Standardize universally on native UTF-8 Unicode characters (
→,←,Δ,≤,≥,±,×,≠,≈,dup). Enforced by automatedYang Markdown Math Anti-Regression Gateinnomos verify. Mirrored files with SSoT provenance banners are validated exclusively by cryptographic SHA-256 parity (nomos intent check) and exempted from source lint checks. - Zero-Alias Invariant Directive: Command structures in compiled Go engine (
src/nomos/cmd/) MUST NOT define.Aliases. All capabilities organized under canonical domain nouns. AST verification fails closed on any non-empty alias slice or unwhitelisted root command. - Conciseness Directive: Deliver code-first modifications with at most three lines of unrequested explanation.
2.8 🛡️ QUALITY DEBT & DOCSTRINGS
- Fix on the Fly: Resolve lint, formatting, and docstring warnings on modified files immediately. Orchestrator AI is prohibited from bypassing debt into
quality_debt.json. - No Boilerplate Comments: Never generate fake or copy-pasted comments to bypass comment density gates. All docstrings must be genuine, descriptive, and multi-line (>= 3 lines).
- Quality Debt Registration: Log non-trivial legacy debt by scaffolding a backlog tracking task:
nomos task create "Resolve Quality Debt: <File/Reason>" -F .nomos/data/tmp/task.md --burden 2 --label "priority:low,type:bug,cli:low".
2.9 🧠 SWARM DELEGATION & OPEN-CORE BOUNDARIES
- Tier 2 Delegation: When
enforce_agent_tier: 2is configured inecosystem.yaml, Tier 1 Orchestrator delegates execution vianomos code <KEY>orncode <KEY>. - Open-Core Boundary: Swarm execution, NCode workers, and multi-agent coordination logic are strictly proprietary Sovereign features. Never leak Sovereign-tier code into open-source
nomos. - Tooling & Dependencies: Always add new CLI dependencies or tools to
shell.nixbuildInputsfor reproducible agent environments. - Stack Conventions:
- Backend: Procedural Go standard library, shallow abstractions, deterministic validation.
- Frontend: Declarative compile-time frameworks (Svelte) and headless primitives.
3. 🛠️ CORE CAPABILITIES SUMMARY
- nomos task:
start,plan,transition,sync,learn,list,view,bundle,reset,create,chore,status - nomos verify: Runs machine-enforced Definition of Done checks (TDD, Security, Dead Code, Phase Discipline, Protocol Symmetry, Zero-Alias Invariant, Magic Strings), rapid AST file pre-flight (
-f,-q), and Ed25519 commit receipt verification (--verify-receipt <SHA>) - nomos audit:
complexity,duplication,refactor,dead-code,imports,wires,magic-strings,entropy - nomos intent:
compile,sync,check,reflect,doc,docs,embed,context - nomos schema:
show,cli,sync,lattice - nomos memory:
search,index,save,status - nomos sys:
health,hygiene,backup,workstation,daemon,handshake - nomos release:
cut,tag,ship,changelog,show,pending - Core Playbooks:
/nomos-handshake,/nomos-plan,/nomos-design,/nomos-exec,/nomos-review,/nomos-dual-core-refactor,/nomos-ship