Anti-Stub Invariants, Empirical Verification, and Contract Boundaries Specification
Role: Autonomous Open-Core Software Architect
Objective: Codify machine-enforced invariants prohibiting trivial constant-return stubs in Definition of Done (DoD) quality gates, mandating dynamic asset discovery in bilateral parity audits, and formalizing Contract Boundaries across hemispheres and substrate domains.
1. Context & Problem Statement#
During the initial bootstrap of the Gen 4 substrate (nomos-v4), an insidious class of architectural defect emerged: False Positive Verification ("Green-Check Syndrome").
The Trivial Constant Return Loophole: The AST anti-shim validator originally checked only whether functions had zero statements (
len(Body.List) == 0) or containedpanic("todo"). Consequently, verification gates returning a single literal statement:return &GateResult{GateName: g.Name(), Passed: true, Message: "..."}, nilwere evaluated as having 1 valid statement. These stubs passed
nomos verifycleanly while performing zero actual checks.The Vacuous Parity Audit:
workspace.CheckBilateralParity(sourceRoot, targetRoot)invokedCheckAssetParity(sourceRoot, targetRoot, nil). Passingnilresulted inTotalAssets: 0, Mismatches: 0, Passed: true, yielding false confidence of "Zero Drift" when no assets were actually compared.Unimplemented Contract Boundary Gates: ADR-0066 declared Contract Boundaries (
contracts.contracts,contracts.membrane,contracts.infra), but substrate gate implementations were missing or unported, creating a contract governance blind spot.
2. Invariant Contracts#
INV-STUB-001: Gate Non-Triviality Invariant (Law 2: Non-Verbal Proof)#
Any function implementing the verify.Gate interface (Evaluate(*VerifyContext) (*GateResult, error)) is strictly prohibited from returning a static literal &GateResult{Passed: true} or nil error without executing substantive inspection logic (e.g. AST traversal, filesystem walk, configuration inspection, or subprocess execution).
- Enforcement:
AntiShimGateinspects gate ASTs. Functions whose body consists solely of a singleast.ReturnStmtyieldingPassed: trueare rejected withERR_TRIVIAL_PASS_SHIM.
INV-PARITY-002: Empirical Asset Discovery Invariant (Law 4: SSoT)#
Any bilateral or cross-hemisphere parity check executed via workspace.CheckAssetParity must discover and audit canonical assets.
- If
TotalAssets == 0, the parity audit fails closed withERR_ZERO_ASSETS_DISCOVERED. - Canonical assets dynamically discovered must include:
- The canonical root
./AGENTS.md. - All CUE contracts under
intent/contracts/cue/*.cue. - Ambient lifecycle hook manifests and scripts under
.agents/hooks.jsonand.agents/scripts/. - Repository configuration manifests (
nomos.yaml).
- The canonical root
INV-CONTRACT-003: Contract Boundaries Invariant (ADR-0066 & Law 7)#
Contract Boundaries govern the interfaces between Intent, Substrate Core, Membrane, and Infra. Each boundary defined in nomos.yaml binds to a registered substrate gate:
contracts.contracts:ContractSchemaGate(Cell 4_2). Audits CUE schemas vs Go DTOs.contracts.infra:InfraPortIngressGate(Cell 5_2). Audits sourceos.Getenvusages vs environment declarations (.env.example) and port configurations.contracts.membrane:UIAntiMaskSentinelGate(Cell 7_1). Audits UI component bindings and eliminates defensive fallback masks. When a boundary is declaredenabled: falseinnomos.yaml(e.g. open-core boundary omitting UI membrane), the corresponding gate must emit an explicit skip result rather than failing or silently returning an unverified pass.
3. Table-Driven Protocol Compliance Vectors#
| Compliance Vector | Invariant | Target Substrate Gate | Expected Failure / Outcome |
|---|---|---|---|
TC-AGT-07 |
Law 2 (Non-Verbal Proof) | AntiShimGate |
Rejects trivial constant return stubs with ERR_TRIVIAL_PASS_SHIM |
TC-AGT-08 |
Law 5 (Zero-Hardcoded-Path) | ForbiddenLiteralsGate |
Rejects forbidden literal paths with ERR_FORBIDDEN_LITERAL |
TC-AGT-09 |
Law 4 (SSoT) | CheckBilateralParity |
Rejects zero-asset parity audits with ERR_ZERO_ASSETS_DISCOVERED |
Nomos