Nomos Developer Documentation
llms.txt ↗
NON-VERBAL PROOF · 42 DETERMINISTIC GATES · 7 LAWS

42 Quality Gates & ERR_* Dictionary

Paste any ERR_* diagnostic code, protocol vector (TC-AGT-*), or gate ID (G-01..G-42) emitted by nomos verify to inspect its invariant, failure trigger, and remediation.

42/42 gates · 9 ERR codes
01 · FAIL-CLOSED DIAGNOSTICS & PROTOCOL VECTORS

Canonical ERR_* Error Lookup

ERR_TRUNK_LOCKED
TC-AGT-01 LAW 3 Interactive Lab ->

Trigger: Direct git commit or file mutation attempted on protected trunk branch (main).

Remediation: Provision an isolated worktree via nomos task chore "<title>" or nomos task start <KEY> --edit.

Enforced by: G-01 · G-02
ERR_CANONICAL_VIOLATION
TC-AGT-02 LAW 6 Interactive Lab ->

Trigger: Non-canonical task key prefix (outside INT-<N> / SUB-<N>) or duplicate CLI alias detected.

Remediation: Use canonical INT-<N> or SUB-<N> task identifiers and remove duplicate wrapper aliases.

Enforced by: G-07 · G-18
ERR_DIRECT_DB_ACCESS_FORBIDDEN
TC-AGT-03 LAW 1 Interactive Lab ->

Trigger: Agent or script attempted raw sqlite3 queries or direct mutation of internal .db files.

Remediation: Interact strictly through encapsulated CLI commands (nomos task and nomos mem).

Enforced by: G-05 · G-13
ERR_CROSS_PLANE_MUTATION
TC-AGT-06 LAW 7 Interactive Lab ->

Trigger: Single task commit mutated both Intent specifications (intent/) and Substrate code (substrate/).

Remediation: Split work across twinned INT-<N> and SUB-<N> tasks via nomos task pair so each commit stays single-plane.

Enforced by: G-15
ERR_TRIVIAL_PASS_SHIM
TC-AGT-07 LAW 2 Interactive Lab ->

Trigger: Gate function or test assertion returns a constant literal true/nil shim without AST or state evaluation.

Remediation: Replace placeholder stub returns with concrete logic and table-driven assertions, then run nomos verify.

Enforced by: G-12 · G-20 · G-41
ERR_FORBIDDEN_LITERAL
TC-AGT-08 LAW 5 Interactive Lab ->

Trigger: Hardcoded workstation path literal, environment secret, or magic string detected in source.

Remediation: Resolve paths dynamically through config discovery and replace magic literals with typed constants.

Enforced by: G-16 · G-35
ERR_ZERO_ASSETS_DISCOVERED
TC-AGT-09 LAW 4 Interactive Lab ->

Trigger: Schema parity or asset walker matched 0 files (vacuous pass trap) or detected SHA-256 byte drift.

Remediation: Verify discovery globs match compiled Go SSoT structs and regenerate reflected JSON Schemas.

Enforced by: G-17 · G-36 · G-40
ERR_CAPBAC_PREFLIGHT
VEC-LAW-07 LAW 7 Interactive Lab ->

Trigger: Write or sync attempted outside an active EDIT/REVIEW capability lease or without walkthrough proof.

Remediation: Run nomos handshake to inspect active phase status and transition cleanly via nomos task edit or sync.

Enforced by: G-04 · G-14
02 · COMPLETE INVARIANT MATRIX

All 42 Matching Quality Gates

G-25 AST & Code Quality

Complexity Audit

Cyclomatic Complexity <= 15

Parses the Go AST to compute cyclomatic complexity per function. Flags deeply nested conditionals, switch cases, and high-cyclomatic logic hotspots.

Fix: Function cyclomatic complexity exceeds threshold (default <= 15). Decompose complex functions into smaller private helpers.
$ nomos verify Law 2 Lab ->
G-27 AST & Code Quality

Comment Density Check

Docstring Density >= 10%

Enforces genuine, descriptive multi-line documentation above exported functions, types, and variables. Boilerplate copy-pasted comments are rejected.

Fix: Docstrings must be multi-line (>= 3 lines) placed directly above func, type, const, or var declarations (counted at 100%).
$ nomos verify Law 2 Lab ->
G-21 AST & Code Quality

Boy Scout Docstring Check

100% Exported Symbol Docs

Verifies that every newly added exported type, interface, method, or package-level function includes comprehensive Go docstrings before merging.

Fix: Ensure all newly added functions or types in modified files have Go docstrings.
$ nomos verify Law 2 Lab ->
G-16 AST & Code Quality

AST Magic String Detector

Zero Raw String Literals in APIs

Scans the AST for raw string literals passed into critical domain APIs and state transitions, requiring strongly-typed constants instead.

Fix: Replace raw strings with strongly-typed domain constants when calling critical functions.
$ nomos verify Law 2 Lab ->
G-23 AST & Code Quality

Anti-OOP Abstraction Check

>= 2 Implementations per Interface

Enforces YAGNI by rejecting single-implementation interfaces and premature dependency injection wrappers. Shallow procedural code is prioritized.

Fix: Remove single-implementation interfaces. Abstract interfaces must have >= 2 concrete implementations to justify complexity.
$ nomos verify Law 6 Lab ->
G-26 AST & Code Quality

Goroutine Lifecycle Check

Zero Orphaned Goroutines

Audits concurrent channel operations, context cancellation propagation, and sync.WaitGroup counters to prevent memory leaks and zombie routines.

Fix: Audit unclosed channels, goroutines context cancellation, or unmatched sync.WaitGroup calls.
$ nomos verify Law 2 Lab ->
G-28 AST & Code Quality

Coupling Analysis Check

Zero Cyclic Package Imports

Measures afferent and efferent package coupling across internal modules, preventing circular dependencies and spaghetti architectures.

Fix: Check for cyclic package imports using nomos verify output and remove cyclic dependencies.
$ nomos verify Law 2 Lab ->
G-30 AST & Code Quality

Duplicate Struct Check

Zero Redundant Model Declarations

Prevents copy-pasted model declarations across disparate subpackages by requiring shared model structs in core packages.

Fix: Consolidate duplicate model structures into shared utility files to avoid redundant definitions.
$ nomos verify Law 6 Lab ->
G-32 AST & Code Quality

DRY Candidate Audit

Sliding Window Duplication Audit

Runs sliding-window AST comparison across staged files to surface multi-line structural duplicates before code reaches the repository trunk.

Fix: Review duplication candidates in verify output. Consolidate matching code blocks into shared utilities.
$ nomos verify Law 6 Lab ->
G-12 AST & Code Quality

Go Format & Vet

Strict go fmt & go vet Compliant

Executes compiler-grade format and vet checks in sub-50ms to ensure 100% canonical Go syntax across all modified source trees.

Fix: Run go fmt ./... && go vet ./... to format and vet Go files.
$ go fmt ./... && go vet ./... Law 2 Lab ->
G-04 Phase Discipline & OS

Phase Discipline Check

Cryptographic Phase State Machine

Enforces the 6-phase lifecycle (IDLE -> PLAN -> EDIT -> REVIEW -> SYNC -> LEARN). Source code is read-only in PLAN and locked until Human PO authorization.

Fix: Run nomos task review <KEY> before syncing code.
$ nomos task review <KEY> Law 1 Lab ->
G-05 Phase Discipline & OS

Protocol Symmetry Gate

Substrate ⇄ AGENTS.md Invariant Sync

Asserts the Axiom of Topological Symmetry: whenever substrate Go logic mutates, AGENTS.md protocols must be synchronized.

Fix: Substrate state machine was modified, but AGENTS.md was not synchronized. Run nomos handshake to sync.
$ nomos handshake Law 1 Lab ->
G-06 Phase Discipline & OS

Asset Synchronization Gate

CLI Engine ⇄ Playbook Symmetry

Prevents drift between compiled Go CLI subcommands and master markdown workflow documentation in src/nomos/core/assets.

Fix: CLI Engine logic was mutated, but master workflows in src/nomos/core/assets were not updated.
$ nomos handshake Law 6 Lab ->
G-07 Phase Discipline & OS

Task ID Validation Gate

100% Commits Bound to SQLite Task

Enforces that every Git commit and worktree mutation is bound to an active, valid Task ID registered in SQLite (nomos_global.db).

Fix: Every commit must be bound to a valid Task ID registered in SQLite. Run nomos task create to register missing tasks.
$ nomos task list Law 1 Lab ->
G-08 Phase Discipline & OS

Data Integrity Gate

Zero Direct Database/JSON Mutations

Blocks autonomous agents from directly tampering with internal SQLite database files or task state JSON outside deterministic CLI boundaries.

Fix: Database and task state files cannot be modified manually. Use nomos task commands to modify state.
$ nomos task update <KEY> Law 7 Lab ->
G-33 Phase Discipline & OS

Workflow Determinism Audit

100% Deterministic Playbook Shells

Scans workflow playbooks to ensure only valid, deterministic CLI commands are declared inside executable bash blocks.

Fix: Run nomos verify to inspect playbook drift. Non-nomos commands must use console or text code fences.
$ nomos verify Law 1 Lab ->
G-14 Phase Discipline & OS

Open Core Architecture Check

Air-Gapped Sovereign Boundaries

Protects open-source repositories from accidental leakage of proprietary Tier 2 Nomos Code, Swarm, or Cockpit enterprise modules.

Fix: Remove any hardcoded dependencies or paths pointing to enterprise modules (e.g. swarm, cockpit).
$ nomos verify Law 5 Lab ->
G-17 Phase Discipline & OS

Contract-First Gate

Strict Interface Contracts (contracts.yaml)

Validates that Go function signatures, parameters, and return types conform strictly to interface specifications declared in contracts.yaml.

Fix: Ensure Go signatures match interface rules in contracts.yaml.
$ nomos verify Law 4 Lab ->
G-01 Sandboxing & GitOps

Blast Radius Constraint

Chore Tasks <= 3 Files Modified

Limits chore tasks to a tight blast radius of 3 files. Larger architectural mutations must be declared as structured Tasks or Cycles.

Fix: Chore tasks cannot modify more than 3 files. Break down the task into smaller tasks.
$ nomos task create "<Title>" Law 3 Lab ->
G-11 Sandboxing & GitOps

CrossRepoWorktreeGate

Upstream go.work Worktrees Synced First

Asserts that all upstream dependent repositories linked via go.work have their task branches verified and committed prior to downstream merging.

Fix: Ensure that all upstream repositories linked via go.work have their worktrees committed and pushed first.
$ nomos task sync <KEY> -F <walkthrough> Law 3 Lab ->
G-02 Sandboxing & GitOps

Stash Audit Guard

Zero Dirty WIP Stashes on Trunk

Scans the root repository for uncommitted WIP stashes, preventing dirty state leaks from polluting hermetic worktree sandboxes.

Fix: A WIP stash was found in the root repository. If it belongs to you, pop it. Otherwise, clean the root.
$ git stash pop Law 3 Lab ->
G-37 Sandboxing & GitOps

Broken Wire & Zombie Agent Detector

Circuit Breaker: Max 5 Consecutive Fails

Monitors task execution telemetry. Trips circuit breaker if an agent loops with 5 consecutive verification failures or remains dormant for > 12h.

Fix: Task has been dormant for >12 hours or circuit breaker tripped due to 5 consecutive verify failures. Re-evaluate strategy.
$ nomos task abort <KEY> Law 1 Lab ->
G-38 Sandboxing & GitOps

Dependency Drift Gate

Zero Multi-Repo Upstream Lag

Asserts that hermetic worktrees across sibling repositories are rebased on the latest trunk commit, preventing merge skew.

Fix: Cross-repo dependency worktrees are lagging behind upstream. Run git fetch origin && git rebase in the affected repository.
$ git rebase origin/main Law 3 Lab ->
G-15 Sandboxing & GitOps

Path Hardcoding Blocker

Zero Absolute / System Paths in Code

Blocks hardcoded host system or hidden workspace directory paths in application source code, requiring standard path discovery helpers.

Fix: Replace hardcoded path string literals with standard helpers from config/paths.go.
$ nomos verify Law 5 Lab ->
G-36 Sandboxing & GitOps

Generated Code Blocker

Zero Manual Edits to Generated Files

Protects compiler-generated protobuf, OpenAPI, and mock files from manual edits, requiring generation pipeline re-runs.

Fix: Do not manually edit generated files. If you must, bypass with Gen-Skip: <Reason> in commit message.
$ nomos verify Law 4 Lab ->
G-13 Security & Secrets

Security Audit

Zero High/Critical AST Vulnerabilities

Executes static security analysis to detect dynamic DOM XSS sinks, SQL injections, insecure deserialization, and hardcoded tokens.

Fix: Review findings or bypass offline environment validation via environment override: NOMOS_BYPASS_TOKEN=OVERRIDE.
$ nomos verify Law 7 Lab ->
G-09 Security & Secrets

Secret in Local Config Gate

Zero Cloud Credentials in Workspaces

Scans repository workspace files for accidental API keys, tokens, or private secrets, requiring centralized storage in environment variables.

Fix: Forbidden cloud credentials found in local files. Move secrets to environment variables.
$ git rm -f --cached <secret-file> Law 7 Lab ->
G-10 Security & Secrets

Git Identity Gate

Canonical Author & GPG Identity

Verifies that commit author name and email are valid and configured, blocking placeholder test identities like Test User or [email protected].

Fix: Active commit author cannot be a placeholder test identity. Configure a valid author via git config user.name and user.email.
$ git config user.name "Your Name" Law 7 Lab ->
G-18 Security & Secrets

Legacy Code Blocker

Zero Banned Packages (banned_imports.json)

Blocks deprecated runtime libraries, unmaintained dependencies, and forbidden third-party frameworks listed in banned_imports.json.

Fix: Remove banned packages or legacy imports listed in banned_imports.json.
$ nomos verify Law 7 Lab ->
G-19 Testing & Hygiene

Go Tests

100% Unit Test Pass Rate

Executes unit tests across all modified Go packages to guarantee zero behavioral regressions before merge approval.

Fix: Run unit tests via go test ./... and resolve any test failures.
$ go test ./... Law 2 Lab ->
G-20 Testing & Hygiene

TDD Coverage Check

Inner-Loop TDD: Test Before Fix

Asserts that every modified logic unit has an accompanying test case in the change unit. Prevents untestable production code.

Fix: Add corresponding unit tests for your changes, or bypass using **TDD-Skip:** <Reason> in commit message.
$ nomos verify Law 2 Lab ->
G-22 Testing & Hygiene

Doc Drift Check

Zero Public API / CLI Spec Drift

Detects public function and CLI command signature changes, asserting that target documentation markdown files are updated in the same change unit.

Fix: Update target documentation markdown files for public API signature updates, or add **Doc-Skip:** <Reason> trailer.
$ nomos verify Law 2 Lab ->
G-34 Testing & Hygiene

Dead Code Detector

Zero Unreferenced Exported Symbols

Scans package symbols to detect newly introduced functions, constants, or types that have no caller references anywhere in the repository tree.

Fix: Ensure exported functions, constants, or types are referenced elsewhere, or bypass with a dead_code quality debt entry.
$ nomos verify Law 2 Lab ->
G-24 Testing & Hygiene

Refactor Checks

Complexity Hotspot Thresholds

Evaluates structural refactoring debt and hotspot scores, ensuring large files are split into cohesive single-responsibility units.

Fix: Run nomos verify locally to check duplication report. Consolidate duplicate blocks or use quality_debt bypasses.
$ nomos verify Law 2 Lab ->
G-29 Testing & Hygiene

Churn-vs-Complexity Audit

Hotspot Risk Score <= 500

Multiplies Git commit churn frequency by cyclomatic complexity to identify high-risk files that demand immediate decomposition.

Fix: Refactor highly complex, frequently modified files to reduce risk hotspots.
$ nomos verify Law 2 Lab ->
G-31 Testing & Hygiene

Cross-Repo SSoT Gate

Zero Cross-Module Struct Redundancy

Detects redundant struct declarations across go.work sibling modules, requiring shared SDK types from upstream nomos core packages.

Fix: Import shared SDK types from upstream nomos packages instead of declaring duplicate structs across repositories.
$ nomos verify Law 4 Lab ->
G-35 Testing & Hygiene

Config Drift Detector

100% Env Variables in .env.example

Scans os.Getenv and process.env calls across the codebase to verify all accessed environment variables are documented in .env.example.

Fix: Ensure that all environment variables accessed in the codebase are defined in .env.example.
$ nomos verify Law 5 Lab ->
G-03 Testing & Hygiene

System Health Doctor

Pristine Database & Hook Integrity

Audits SQLite database schemas, active locks, and Git pre-commit hooks, automatically repairing local environment anomalies.

Fix: Run nomos status (or nomos handshake) to diagnose and self-heal local database locks and git hooks.
$ nomos status Law 7 Lab ->
G-39 Testing & Hygiene

Metric Parity Auditor

SSoT Parity Between Handbooks & Dispatches

Verifies that empirical benchmarks and performance numbers cited in Living Vault handbooks match verified raw dispatch records with byte-exact consistency.

Fix: Ensure empirical claims in handbook documentation match the metrics recorded in dispatches.
$ nomos verify Law 2 Lab ->
G-40 Testing & Hygiene

Bilateral Seam Parity Auditor

Zero Byte Parity Drift Across Hemispheres

Audits bidirectional Universal Seams between Intent and Substrate hemispheres, enforcing cryptographic byte parity on all compiled contract schemas.

Fix: Execute nomos verify to identify and reconcile broken contract links or cross-plane drift.
$ nomos verify Law 4 Lab ->
G-41 AST & Code Quality

Dynamic Polyglot Tree-sitter Gate

Polyglot Tree-sitter AST Syntax & Boundary Proof

Employs WebAssembly-compiled Tree-sitter grammars to perform concrete AST syntactic parsing and boundary checking across Go, Python, TypeScript, and Rust.

Fix: Resolve AST syntax errors or circular module dependencies in your polyglot source files.
$ nomos verify Law 2 Lab ->
G-42 Security & Secrets

CapBAC Capability Lease Gate

Cryptographic Task Leases & Self-Healing Git Defense

Validates non-forgible Capability-Based Access Control (CapBAC) object leases on every task worktree and automatically verifies self-healing pre-commit defense hooks.

Fix: Execute nomos handshake to synchronize CapBAC token leases and re-install defense hooks.
$ nomos handshake Law 7 Lab ->
Ask Sophia Docs & Specs Sophia AI · Grounded Nomos Architecture & Docs Concierge