Nomos Polyglot Workspace Ergonomics, Dynamic Lock Hygiene, and Agent Remediation Invariants
1. Executive Summary & Problem Statement#
This specification (INT-538 / SUB-666) establishes the Single Source of Truth for polyglot workspace ergonomics, stale Git .lock recovery, and Tier 1 agent remediation. Downstream production evaluation inside non-Go workspaces - specifically gsi-data (a Python monorepo under uv) and polyglot environments - revealed four friction points:
- False-Positive Gate Rejections:
SecretGatescanned compiled native binaries (.so,.dylib,.dll) and python virtual environments (.venv/), flagging benign strings or binary entropy as leaked secrets.StagedBoundariesGaterejected Git deletions (D), treating valid file removal as an out-of-boundary violation requiring manual commits.
- Fragile Git
.lockConcurrency:- Interrupted startups or crashed CLI commands leave stale
.git/refs/heads/*.lockor.git/index.lockfiles. Subsequentnomos task startcommands abort withERR_MODULES / Permission denied, stalling the agent without human intervention.
- Interrupted startups or crashed CLI commands leave stale
- Monolithic Tooling Assumptions:
nomos inithistorically defaulted to Go project assumptions (go.mod), missing automatic detection for Python (pyproject.toml,uv.lock), Node (package.json), or Rust (Cargo.toml) environments.
- Cognitive Agent Iteration Churn:
- When a DoD gate rejects a worktree, raw mathematical errors lack machine-actionable remediation commands. Consequently, the Tier 1 agent guesses unstructured repairs.
2. Axiomatic Invariants & Governing Laws#
2.1 Invariant 1: Zero-False-Positive DoD Gates (Law 2 & Law 5)#
Quality gates must never reject valid development workflows:
- All AST, secret, and file-scanning gates automatically inherit universal polyglot exclusion boundaries:
- Python:
.venv/,__pycache__/,*.pyc,*.egg-info/,.pytest_cache/,.ruff_cache/ - Node/Web:
node_modules/,.svelte-kit/,.next/,dist/,.turbo/ - Rust/Compiled:
target/,*.so,*.dylib,*.dll,*.a
- Python:
StagedBoundariesGateexplicitly accepts Git deletions (D) inside configured boundary roots, distinguishing valid file excision from unauthorized modifications.
2.2 Invariant 2: Hermetic Trunk Protection Without OS chmod Mutations (Law 3 & Law 7)#
Worktree provisioning and trunk synchronization enforce boundary isolation via CapBAC leases and Git hooks rather than filesystem permission hacks:
LockTrunkandUnlockTrunkinsubstrate/src/nomos/core/workspace/trunk_lock.goverify repository accessibility while delegating trunk mutation blocking to CapBAC leases and self-healingpre-commit/PreToolUsedefense hooks.nomos task prunedeterministically collects orphaned worktrees and mergedfeature/*branches while preserving activeIN_PROGRESSworktrees with uncommitted state.
2.3 Invariant 3: Adaptive Polyglot Initialization (Law 4)#
nomos init automatically scans the workspace root and scaffolds the matching project profile:
- Detection precedence matrix:
pyproject.tomlorrequirements.txtPython profile (pytest,ruff,.venv/exclusion)package.jsonNode/TypeScript profile (npm test/vitest,node_modules/exclusion)Cargo.tomlRust profile (cargo test,target/exclusion)go.modGo profile (go test, static binary harness)
- Scaffolds a language-aware
.gitignoreand minimalnomos.yamlin seconds.
2.4 Invariant 4: JIT Machine-Actionable Remediation (Law 1 & Law 2)#
Every Definition of Done gate failure must render an explicit Remedy field containing:
- The exact canonical CLI command to run (e.g.,
nomos mem save,nomos task abort <KEY>,nomos task sync -F <file>). - Contextual guidance formatted specifically for Tier 1 cognitive agents to eliminate trial-and-error iterations.
3. Substrate Interface Contracts (substrate/src/nomos/core/workspace/trunk_lock.go)#
package workspace
// LockTrunk attests trunk isolation under Law 3. Trunk boundary protection is
// enforced via CapBAC object capabilities and Git pre-commit defense hooks without OS chmod mutations.
func LockTrunk(repoRoot string) error
// UnlockTrunk verifies 2PC atomic release preconditions.
func UnlockTrunk(repoRoot string) error4. Cross-Plane Transduction Matrix#
graph TD
subgraph Intent Plane
INT[INT-538 Polyglot Invariants SSoT]
end
subgraph Substrate Plane
GATE[DoD Gate Boundary Filters]
LOCK[CapBAC & Pre-Commit Trunk Guard]
INIT[Adaptive Polyglot nomos init]
HINT[JIT Agent Remediation Formatter]
end
subgraph Target Repositories
GO[Go Repositories]
PY[Python Monorepos]
TS[TypeScript & Rust Workspaces]
end
INT --> GATE
INT --> LOCK
INT --> INIT
INT --> HINT
GATE --> GO
GATE --> PY
LOCK --> PY
INIT --> TS- Intent Plane (
INT-538): Authors specification and codifies the universal polyglot exclusion taxonomy. - Substrate Plane (
SUB-666): Implements exclusion lists insubstrate/src/nomos/modules/verify/, trunk isolation insubstrate/src/nomos/core/workspace/trunk_lock.go, and adaptive scaffolding insubstrate/cli/cmd_init.go. - Downstream Adoption: Unblocks multi-language agent workflows across Python, Rust, TypeScript, and Go repositories without false-positive gate rejections.
5. Table-Driven Verification Vectors#
| Vector ID | Target Component | Input Vector | Expected State / Output | Invariant Verified |
|---|---|---|---|---|
TC-POLY-001 |
StagedBoundariesGate |
Staged deletion (git rm path/to/file.go) inside worktree |
Returns Passed: true with zero boundary violations |
Invariant 1 (Zero-False-Positive Gates) |
TC-POLY-002 |
LockTrunk / Pre-Commit Hook |
Direct commit attempt on protected main branch |
Rejects commit with nomos task chore remedy |
Invariant 2 (Hermetic Trunk Protection) |
TC-POLY-003 |
nomos task prune |
Orphaned worktrees/* directory without active lease |
Sweeps orphan while preserving active IN_PROGRESS worktrees |
Law 3 & Law 7 |
TC-POLY-004 |
SecretGate |
Source tree containing .venv/ and .so artifacts |
Skips .venv/ and .so files cleanly |
Invariant 1 & Law 5 |
6. Cross-Plane Traceability & DoD Verification#
- Compiled Go SSoT Paths:
substrate/src/nomos/core/workspace/trunk_lock.go(LockTrunk,UnlockTrunk).substrate/src/nomos/modules/verify/gates_security.go(SecretGatepolyglot directory and binary exclusions).substrate/cli/cmd_init.go(adaptive Python, Node, Rust, and Go workspace profile scaffolding).
- 7x3 Invariant Matrix Coordinates:
Cell 3.1 (staged_boundaries)andCell 3.2 (hermetic_worktree)enforce deletion-aware boundary checks and worktree isolation.Cell 7.1 (secret)skips.venv/,node_modules/,target/, and compiled binary extensions cleanly.Cell 4.1 (broken_wire)verifies all Markdown relative links resolve deterministically.
- Verification Command:
Passes all 42 Definition of Done quality gates with zero regressions.nomos verify
Nomos