Project Topology, Root Governance & Configuration Specification

SpecOps enforces an opinionated, deterministic repository layout, configuration schema, and living governance constitution governed by ADR-0001, ADR-0008, and ADR-0022.


1. Canonical Repository & Directory Topology

Every SpecOps-managed repository partitions project management specifications, technical documentation, runtime state, and isolated agent workspaces into strict directory hierarchies:


<repo-root>/
├── AGENTS.md                        # Living Agent Operating Manual & System Constitution
├── specops.toml                     # Root Project Management & Architecture Manifest
├── pyproject.toml                   # Python workspace & [tool.importlinter] contracts
├── uv.lock                          # Immutable dependency lockfile (ADR-0011)
├── .specops/                        # Local profile state & installed adapter metadata
├── .worktrees/                      # Isolated git worktrees for concurrent task execution
│   └── <task-id>/                   # Dedicated worker checkout on feat/<task-id>
├── spikes/                          # Time-boxed architectural spike sandboxes
├── docs/
│   ├── index.md                     # Documentation portal landing page
│   ├── operating-manual.md          # Auto-synced mirror of root AGENTS.md
│   ├── tutorials/                   # Diataxis learning-oriented onboarding guides
│   ├── how-to/                      # Diataxis goal-oriented operational recipes
│   ├── reference/                   # Diataxis information-oriented technical specs
│   │   └── specs/                   # Authoritative domain & schema specifications
│   ├── explanation/                 # Diataxis understanding-oriented architecture deep-dives
│   ├── .spec-ops/                   # Ephemeral & local runtime telemetry/coordination state
│   │   ├── events/                  # Append-only JSONL domain event streams
│   │   ├── locks/                   # Advisory file locks (e.g., MERGE_LOCK, claim locks)
│   │   ├── backups/                 # Pre-migration & reconciliation state snapshots
│   │   └── tmp/                     # Scratch verification artifacts & transient outputs
│   └── project/                     # Version-locked PMaC specifications (ADR-0001)
│       ├── SECURITY.md              # Vulnerability disclosure & zero-trust agent policy
│       ├── adrs/                    # Architectural Decision Records & REGISTRY.md
│       │   ├── draft/
│       │   ├── accepted/
│       │   └── deprecated/
│       ├── product/                 # Product Requirements Documents (PRDs)
│       │   ├── idea/
│       │   ├── shaped/
│       │   ├── accepted/
│       │   └── shipped/
│       ├── user_stories/            # Executable Gherkin BDD stories & PERSONAS.md
│       │   ├── draft/
│       │   ├── accepted/
│       │   └── deprecated/
│       └── backlog/                 # Engineering tasks, PRIORITY.md, & ROADMAP.md
│           ├── proposed/
│           ├── refined/
│           └── complete/
└── src/
    └── <package>/                   # Bounded context implementation packages (ADR-0007)

Directory Responsibilities & Invariants

Path Classification Purpose & Governance Invariants
docs/project/{adrs,product,user_stories,backlog} Version-Locked PMaC Stores all requirements, personas, ADRs, BDD stories, and tasks as Markdown with YAML frontmatter (ADR-0001). Shared backlog files under docs/project/backlog/ must never be modified directly on feature branches (ADR-0005).
docs/{tutorials,how-to,reference,explanation} Diataxis Quadrants Enforced by DocsAuditor (src/spec_ops/docs/auditor.py). Every documentation file outside docs/project/ must reside in one of the four approved quadrants or in ALLOWED_ROOT_FILES (index.md, operating-manual.md).
docs/.spec-ops/{events,locks,backups,tmp} Runtime Telemetry & Locks Houses local event sourcing logs (events/), concurrency coordination locks (locks/), rollback snapshots (backups/), and scratch files (tmp/). Ignored by Diataxis quadrant audits.
.worktrees/ Isolated Execution Dedicated git worktree checkouts created during spec-ops queue claim or multi-agent orchestration so parallel workers never contend on the working tree (ADR-0005).
.specops/ Profile Metadata Stores active profile selections, constitution hashes, and local scaffold state.
spikes/ Architectural Spikes Isolated exploratory prototypes governed by spike graduation rules before production domain integration.

2. `specops.toml` Configuration Specification

The configuration loader (src/spec_ops/config/loader.py) searches upward from the current working directory to the .git boundary for specops.toml (or fallback filenames .specops.toml, pmac.toml, .pmac.toml) and deserializes it into SpecOpsConfig (src/spec_ops/config/models.py).

2.1 `[project]` — `ProjectSettings`

Defines repository identity, PMaC specification root, and static site build destination.

Key Type Default Description
name str "MyProject" Human-readable project name rendered in CLI banners, TUI headers, and generated documentation.
repo str "" Canonical repository URL or slug used for provenance links.
docs_dir str "docs/project" Relative path from repository root to the PMaC specification directory (SpecOpsConfig.project_docs_dir).
site_output str "dist/site" Default output path for compiled static documentation assets.

2.2 `[architecture]` — `ArchitectureSettings` & `ComponentConfig`

Controls source file modularity thresholds, Just-In-Time (JIT) backlog buffer limits, and structural component mappings enforced by uv run spec-ops health (ADR-0002).

Key Type Default Description
file_length_limit int 500 Hard maximum line count per source file; violations fail spec-ops health and preflight gates.
file_warning_threshold int 400 Proactive warning threshold signaling that a module is approaching decomposition limits.
buffer_target int 10 Target number of ready-to-claim tasks maintained in docs/project/backlog/refined/.
buffer_warning_threshold int 6 Minimum refined task count before spec-ops health emits a JIT refinement starvation warning.
components list[ComponentConfig] [] Array of inline tables ({ id, name, path, description }) mapping logical components to source directories.

2.3 `[architecture.layers]`, `[architecture.independent_contexts]`, & Import-Linter Contracts

SpecOps enforces acyclic Bounded Context dependencies (ADR-0007) via load_architectural_contract (src/spec_ops/core/layer_contracts.py), which merges rules from pyproject.toml ([tool.importlinter]) and specops.toml into an ArchitecturalContract:

  1. [architecture.layers] (specops.toml): Maps bounded context short names to integer layer ranks (0 = lowest foundation layer such as config; higher integers = outer presentation/orchestration layers such as cli = 6, app = 5). Lower layers are strictly forbidden from importing higher layers.
  2. [architecture.independent_contexts] (specops.toml): Defines pairs = [["visualizer", "tui"], ...] specifying sibling contexts that must remain mutually decoupled in both directions.
  3. [[tool.importlinter.contracts]] (pyproject.toml):

2.4 `[vertical_slices]` — `SliceConfig`

Configures how PRDs are decomposed into thin vertical task slices (slices = [...]). If omitted, loader.py supplies DEFAULT_SLICES (spike, domain, api, ui, test).

Key Type Default Description
type str "feature" Canonical slice identifier (spike, domain, api, ui, test).
name str "" Display label for the vertical slice category.
prefix str "" Optional task title prefix (e.g., "SPIKE:").
requires_adr bool False When true, tasks of this slice type require an accompanying ADR reference before completion.
description str "" Optional guidance describing what belongs in this vertical slice.

2.5 `[quality]` — `QualitySettings`

Defines verification gates enforced during task preflight and completion (ADR-0003, ADR-0006, ADR-0011).

Key Type Default Description
testing_style str "blackbox-frontdoor" Verification posture enforcing public interface testing without private mock backdoors.
require_bdd bool True Requires executable Gherkin scenarios for accepted user stories.
enforce_lockfile bool True Enforces lockfile synchronization (uv lock --check) during preflight.
preflight list[str] ["pytest"] Ordered shell commands executed by the preflight verification runner.

2.6 `[execution]` & `[execution.sandbox]` — `ExecutionSettings` & `SandboxSettings`

Governs autonomous worker dispatch, branch naming, worktree isolation, and command sandboxing (ADR-0005, ADR-0012).

Section / Key Type Default Description
execution.agent_command str "agy -p '{prompt}'" Template command invoked to spawn an implementation worker ({prompt} placeholder interpolated).
execution.reviewer_command str "" Optional command template for automated adversarial code review agents.
execution.agent_max_attempts int 3 Maximum retry attempts before a failing task is halted or escalated.
execution.git_branch_prefix str "feat/" Branch prefix created for isolated task worktrees (e.g., feat/TASK-0260).
execution.backlog_isolation bool True Prevents worker branches from directly mutating shared docs/project/backlog/ files.
execution.enable_review bool True Requires architectural review hold prior to branch integration.
execution.target_agents list[str] [] Target AI coding assistants for which adapter rules/skills are scaffolded.
execution.sandbox.enabled bool False (True when [execution.sandbox] table present) Enables process-level command allowlisting and optional network isolation.
execution.sandbox.allowed_commands list[str] ["uv", "git", "pytest", "ruff"] Executables permitted inside the worker execution sandbox.
execution.sandbox.isolate_network bool False Restricts outbound network access during sandboxed worker runs.

2.7 `[documentation]` — `DocumentationSettings`

Configures the Diataxis documentation engine and drift auditor (ADR-0008).

Key Type Default Description
docs_dir str "docs" Root directory for Diataxis technical documentation (SpecOpsConfig.docs_dir).
allowed_directories list[str] [] Additional top-level subdirectories under docs/ permitted alongside the four Diataxis quadrants.
ignored_directories list[str] [] Subdirectories under docs/ skipped during structural and snippet audits (alias: ignored_dirs).
allowed_root_files list[str] [] Additional filenames permitted directly in docs/ root alongside index.md and operating-manual.md.
ignored_root_files list[str] [] Root files in docs/ ignored by the Diataxis structure checker.

2.8 `[security]`, `[security.licenses]`, & `[security.compliance]`

Configures supply-chain guardrails, secret scanning, SPDX license policies, cryptographic commit signing, and dual-custody review gates (ADR-0010, ADR-0011, ADR-0012, ADR-0016).

Section / Key Type Default Description
security.secret_scanning bool True Enables regex pattern and Shannon entropy scanning for hardcoded credentials.
security.lockfile_immutability bool True Forbids unauthorized modifications to uv.lock or package-lock.json.
security.enforce_lockfile bool True Enforces lockfile consistency checks during security health audits.
security.sandbox_enabled bool True Requires autonomous workers to execute under command interceptor guardrails.
security.allowed_commands list[str] ["pytest", "git", "uv"] Allowlisted binaries enforced by the security command interceptor.
security.reporting_contact str "security@example.com" Primary security contact email synchronized into docs/project/SECURITY.md.
security.pgp_fingerprint str "ABCD 1234 ... SPEC OPS1" PGP key fingerprint for encrypted vulnerability disclosures.
security.licenses.profile str "permissive" License policy tier (permissive, weak-copyleft, strict).
security.licenses.allowed list[str] [] Explicit SPDX license identifiers allowed in the dependency tree (fallback key: allowed_licenses).
security.compliance.require_signed_commits bool False Requires cryptographic SSH/GPG signatures on all task commits (SpecOpsConfig.require_signed_commits).
security.compliance.dual_custody bool False Enforces human architect sign-off (spec-ops review sign) before spec-ops queue complete.
security.compliance.allowed_signers_file str ".ssh/allowed_signers" Path to the SSH allowed signers file used for cryptographic signature verification.
security.compliance.authorized_signers list[str] [] Authorized human reviewer identities ("Name ") permitted to sign off on review holds.

2.9 Complete `specops.toml` Reference Example


[project]
name = "SpecOps"
repo = "https://github.com/example/spec-ops"
docs_dir = "docs/project"
site_output = "dist/site"

[architecture]
file_length_limit = 500
file_warning_threshold = 400
buffer_target = 10
buffer_warning_threshold = 6
components = [{ id = "core", name = "Core Engine", path = "src" }]

[architecture.layers]
cli = 6
app = 5
visualizer = 4
tui = 4
worker = 3
backlog = 2
core = 1
config = 0

[architecture.independent_contexts]
pairs = [["visualizer", "tui"]]

[vertical_slices]
slices = [
  { type = "spike", name = "Architectural Spike", prefix = "SPIKE:", requires_adr = true },
  { type = "domain", name = "Domain Model & State Handlers" },
  { type = "test", name = "Blackbox Frontdoor Test Suite" }
]

[quality]
testing_style = "blackbox-frontdoor"
require_bdd = true
enforce_lockfile = true
preflight = ["uv run pytest"]

[execution]
agent_command = "agy --dangerously-skip-permissions -p {prompt}"
agent_max_attempts = 3
git_branch_prefix = "feat/"
backlog_isolation = true
enable_review = true

[execution.sandbox]
enabled = true
allowed_commands = ["uv", "git", "pytest", "ruff"]
isolate_network = false

[documentation]
docs_dir = "docs"
allowed_directories = []
ignored_directories = []

[security]
secret_scanning = true
lockfile_immutability = true
enforce_lockfile = true
sandbox_enabled = true
allowed_commands = ["pytest", "git", "uv"]
reporting_contact = "security@example.com"
pgp_fingerprint = "ABCD 1234 EF56 7890 ABCD 1234 EF56 7890 SPEC OPS1"

[security.licenses]
profile = "permissive"
allowed = ["MIT", "Apache-2.0", "BSD-3-Clause", "ISC", "Python-2.0"]

[security.compliance]
require_signed_commits = true
dual_custody = true
allowed_signers_file = ".ssh/allowed_signers"
authorized_signers = ["Ty Evans <tyler@poorlythoughtout.com>"]

3. Root Governance Documents

3.1 `AGENTS.md` Living Constitution (`ADR-0022`)

Root AGENTS.md serves as the authoritative operating manual for human architects and autonomous coding agents. It is dynamically synthesized from specops.toml and active architectural profiles via src/spec_ops/scaffold/agents_md.py and src/spec_ops/scaffold/constitution_sync.py.

Structural Sections

  1. Hard Invariants: Non-negotiable numerical and architectural constraints derived directly from specops.toml (e.g., <500 line limit, <400 line warning, blackbox frontdoor verification, strict backlog isolation, UV workspace management, PMaC frontmatter, executable BDD stories, DDD bounded contexts, Hypothesis + Mutmut >=80% kill score, supply-chain security, and dual-custody cryptographic signing).
  2. Security & Supply-Chain Hard Invariants: Zero-trust restrictions forbidding hardcoded credentials, unapproved lockfile mutations, and non-allowlisted shell commands.
  3. Custom Invariants Preservation Block: Project-specific operational protocols enclosed in HTML comment markers: ``markdown ### Custom Project Invariant Project-specific rules preserved across constitution regenerations. ` When sync_constitution() regenerates AGENTS.md, extract_custom_invariants() parses all text between and and re-injects it losslessly via wrap_custom_invariants()`.
  4. Design Principles, Project Structure & Diataxis Directives: Navigation tables mapping docs/project/ and docs/{tutorials,how-to,reference,explanation}/.
  5. Definition of Ready (DoR): Seven-point gate governing when a task can transition into docs/project/backlog/refined/ (complete frontmatter, linked PRD/Persona/ADRs, executable frontdoor Gherkin, Hypothesis properties identified, Mutmut scope >=80%, INVEST vertical slice validation, existing docs reviewed).
  6. Definition of Done (DoD): Ten-point gate governing integration into main (100% pytest frontdoor pass rate, pytest-bdd acceptance pass, Hypothesis property pass, >=80% Mutmut score, spec-ops health clean, uv lock --check clean, spec-ops docs build clean, atomic backlog progression, SpecOps-Task commit trailers, and dual-custody signed_off_by verification).
  7. Task Execution Workflow: Six-step lifecycle from task selection in PRIORITY.md through preflight verification, review hold (spec-ops review ), human sign-off (spec-ops review sign --identity ), and atomic completion (spec-ops queue complete ).

Synchronization & Drift Commands


# Verify that AGENTS.md matches specops.toml and active profiles (CI gate)
uv run spec-ops constitution check

# Regenerate AGENTS.md and docs/operating-manual.md while preserving custom invariants
uv run spec-ops constitution sync

During uv run spec-ops docs build, sync_operating_manual() automatically mirrors root AGENTS.md to docs/operating-manual.md (rewriting relative ](docs/ links to ]().

3.2 `docs/project/SECURITY.md` Policy Specification

docs/project/SECURITY.md codifies the repository's vulnerability management and autonomous worker containment contract (ADR-0010, ADR-0012):

  1. Vulnerability Disclosure Policy & Workflows: Mandates private reporting, 24-hour acknowledgment / 72-hour triage SLAs, and coordinated disclosure developed in private security worktrees.
  2. Reporting Contacts & Incident Management: Publishes the primary security contact (security.reporting_contact from specops.toml) and incident escalation address.
  3. PGP Key Fingerprint: Publishes security.pgp_fingerprint and key server (keys.openpgp.org) for encrypted vulnerability reports.
  4. Autonomous Worker Execution Restrictions: Explicitly binds coding agents to three zero-trust guardrails enforced by uv run spec-ops health --security:

4. What Can and Cannot Be Tracked in Root Configuration & Governance Files

To preserve security, determinism, and branch isolation across multi-agent workflows, SpecOps enforces strict boundaries on what belongs in root configuration and governance files:

Allowed (Must Be Tracked) Forbidden (Must Never Be Tracked)
Declarative project thresholds, directory paths, and layer ranks in specops.toml. Raw API keys, tokens, private SSH/PGP keys, or credentials in specops.toml or AGENTS.md (ADR-0010).
Public signer identities ("Name ") and .ssh/allowed_signers public key mappings in [security.compliance]. Dynamic task status, active worker claims, or ephemeral queue state inside specops.toml or AGENTS.md.
Project-wide architectural invariants inside ... in AGENTS.md. Manual edits to generated sections of AGENTS.md outside the custom invariants markers (will be flagged as constitution drift by spec-ops constitution check and overwritten by spec-ops constitution sync).
Bounded context dependency contracts in pyproject.toml ([tool.importlinter]) and specops.toml ([architecture.layers]). Unapproved dependency mutations in pyproject.toml or uv.lock on worker task branches (ADR-0011, ADR-0018).
Public vulnerability disclosure contacts and PGP fingerprints in docs/project/SECURITY.md. Ephemeral runtime locks (docs/.spec-ops/locks/), scratch test artifacts (docs/.spec-ops/tmp/), or .worktrees/ checkouts in git commits.