Lab Notes • Mission lifecycle of the Dark Gravity experiment

The Autonomous Project Lifecycle:
From Backlog Issue to Living C4 Architecture

The lifecycle I am experimenting with: issue ingestion by outbound polling, Spec-Driven Development with Spec-Kit, durable Hatchet DAGs in gVisor sandboxes, and generated C4 documentation. It describes the intended design and what I am testing; limitations and failed runs belong in the lab notebook.

30–60s
Outbound Polling (0 Webhooks)
7 Steps
Spec-Kit SDD Governance
≤ 30 MiB
gVisor Sandbox RAM Target
Zeroize
Secret RAM Zeroization
≥ 8.0/10
LLM Judge Threshold (configured)
< 5%
Orphan Symbol Rate (OSR gate target)

4 Specialized Agent Personas & 4 HITL Governance Vertices

Dark Gravity combines specialized agent bounded contexts with strict human oversight. Autonomous agents formulate specs and surgically write code, but a human keeps the final decision over budgets and merges.

🤖
Intelligence Context

Rustant — Product Owner & Planner Agent

Governs the intelligence domain. Queries R2R GraphRAG to synthesize architectural context, executes the 7-step Spec-Kit planning pipeline, formulates atomic tasks with parallel markers, and performs early SAST security reviews.

Hatchet: rustant:plan Spec-Kit CLI R2R GraphRAG crates/factory-application
⚡
Execution Context

ZeroClaw — Developer & Code Surgery Agent

Governs code implementation inside ephemeral gVisor micro-sandboxes. Applies Tree-sitter AST mutations via native ADK-Rust (avoiding subprocess latency), runs cargo test suites, and enforces forensic memory zeroization.

Hatchet: zeroclaw:execute ADK-Rust AST Surgery gVisor runsc RAM ≤ 30 MiB
🛡️
Remediation Context

DevOps Agent — Self-Healing & Sentry Triage

Governs the Aethelgard auto-remediation loop and production crash triage. Polls Sentry REST APIs every 15 minutes, maps exception stack traces via R2R GraphRAG, and auto-dispatches hotfix DAGs for verified anomalies.

Aethelgard 3-Retry Loop Deadlock SHA-256 Trip Sentry Closed-Loop KEDA Autoscaling
📚
Infrastructure & Memory Context

DocAgent — C4 Models & OpenWiki Living Memory

Governs living corporate memory. Following PR merges, triggers deepwiki-rs Tree-sitter AST delta indexing, syncs dependency graphs to pgvector, auto-renders C4 Level 1–3 Mermaid diagrams, and validates the < 5% OSR quality gate.

Superpowers Engine deepwiki-rs AST Parser C4 Model Generator OSR Gate < 5%

The 4 Human-in-the-Loop (HITL) Checkpoints

Branch protection and review gates are designed to prevent agents from merging code on their own. The human steers intent and keeps the veto.

HITL Vertex 1

Strategic Injection

Human Product Owner: Authors high-level business Epics or issues in Jira, GitHub, or GitLab, tagged with autonomous-mission. The human defines why and what value is required.

HITL Vertex 2

Sprint Mobilization

Human Tech Lead: Reviews the generated Spec-Kit artifacts (spec.md, plan.md, tasks.md) and approves the sprint. Prevents runaway token and compute spending.

HITL Vertex 3

Exception Override

Human System Architect: Ideally no intervention during active loops. Alerts fire only if Aethelgard hits the 3-retry limit or a spend velocity trip trips to Agent-Stuck. The architect untangles the edge case.

HITL Vertex 4

Categorical Scrutiny

Human Senior Reviewer: Conducts final code review on remote Pull/Merge Requests. Agents are physically forbidden from auto-merging. Human validates architecture and business logic before manual merge.

The Complete 6-Phase Autonomous Mission Pipeline

Trace a feature from initial issue discovery through mathematical specification, durable Hatchet sub-workflows, sandboxed code surgery, and post-merge living knowledge graphs.

sequenceDiagram autonumber actor HumanPO as Human PO (Vertex 1) participant Git as Git Platform (Jira/GitHub/GitLab) participant Poller as GitPlatformPoller (Outbound 30-60s) participant Kafka as Confluent Kafka (mission-input) participant Hatchet as Hatchet DAG Engine participant Rustant as Rustant (PO Agent) participant R2R as R2R GraphRAG & pgvector participant Bridge as Superspec Bridge participant ZeroClaw as ZeroClaw (Dev Agent) participant Sandbox as gVisor Sandbox (RAM <= 30MiB) actor TechLead as Senior Reviewer (Vertex 4) participant DocAgent as DocAgent (Superpowers) participant DeepWiki as deepwiki-rs & OpenWiki Note over HumanPO,Git: Phase 1: Ingestion & NHI Security HumanPO->>Git: Creates Issue tagged "autonomous-mission" Poller->>Git: Outbound HTTPS Polling (No Webhooks) Git-->>Poller: Returns Issue + Resource Constraints Poller->>Poller: Signs W3C Ed25519 VC (did:factory:dark-gravity) Poller->>Kafka: Publishes MissionInput payload Kafka->>Hatchet: Triggers "develop-task" 6-Phase DAG Note over Hatchet,R2R: Phase 2: Spec-Driven Development (SDD) Hatchet->>Rustant: Dispatches rustant:plan Rustant->>R2R: Queries AST & semantic codebase graph Rustant->>Rustant: Executes Spec-Kit (/specify, /clarify, /plan, /tasks) Rustant->>Git: Commits specs/NNN-feature/ (spec, plan, tasks) Note over Hatchet,Sandbox: Phase 3 & 4: Durable Execution & Aethelgard Loop Hatchet->>Bridge: Bridges tasks.md into durable sub-steps Bridge->>ZeroClaw: Dispatches atomic task (T001 -> T002...) ZeroClaw->>Sandbox: Provisions gVisor runsc container (RAM <= 30 MiB) ZeroClaw->>Sandbox: Executes ADK-Rust AST surgery & cargo test Sandbox->>Sandbox: Zeroizes in-memory secrets on completion ZeroClaw->>Hatchet: Checkpoints BridgeState to MinIO S3 & Postgres Note over ZeroClaw,Hatchet: SAST LLM Judge evaluates score >= 8.0/10 Note over Hatchet,TechLead: Phase 5: GitOps Delivery & HITL Gate Hatchet->>Git: Opens Remote PR targeting main (Closes #ID) Note over Git,TechLead: Interactive comments (@darkgravity /refine, /status) TechLead->>Git: Manual Human Review & Merge (Vertex 4) Note over Git,DeepWiki: Phase 6: Living Knowledge & C4 Diagrams Git->>DeepWiki: Post-merge triggers deepwiki-rs AST scan DeepWiki->>R2R: Upserts depends_on delta edges to pgvector DeepWiki->>DocAgent: Wakes DocAgent with Superpowers engine DocAgent->>DocAgent: Verifies Orphan Symbol Rate (OSR Gate < 5%) DocAgent->>Git: Auto-renders C4 Diagrams & commits OKF Wiki

The Six Specialized Stages of Dark Gravity

Each phase implements hardened security primitives, bounded contexts, and deterministic contracts. Explore the technical mechanics behind each operational stage.

Phase 1: Ingestion & Cryptographic Identity

Air-Gapped Outbound Polling & W3C Non-Human Identity (NHI) Signing

To achieve a zero-trust, air-gapped perimeter, Dark Gravity firmly rejects all open inbound webhooks. Inbound HTTP ports create external attack surfaces and dependency on external proxy tunnels (such as ngrok or Cloudflare Tunnels). Instead, the native Rust GitPlatformPoller daemon (factory-cli poller) queries Jira, GitHub, and GitLab APIs via outbound HTTPS requests every 30 to 60 seconds.

Cryptographic Ingestion Workflow

  • Target Discovery: Scans for issues carrying the mandatory autonomous-mission or dark-gravity label.
  • Resource Constraint Extraction: Parses hardware directives like [RESOURCE_LIMIT: RAM <= 30Mi, CPU <= 250m] directly from issue descriptions.
  • Ed25519 W3C VC Generation: Signs mission provenance with an Ed25519 keypair from HashiCorp Vault representing Non-Human Identity (did:factory:dark-gravity-euskadi).
  • Kafka Event Bus: Serializes payload to MissionInput and publishes to the mission-input topic in Confluent Kafka.

Verifiable Credential Token (JWS)

{ "@context": ["https://www.w3.org/2018/credentials/v1"], "id": "urn:uuid:8b3401fa-9df2-43ce-9a3b-741c09ab7d21", "type": ["VerifiableCredential", "AutonomousMissionClaim"], "issuer": "did:factory:dark-gravity-euskadi", "issuanceDate": "2026-10-12T12:00:00Z", "credentialSubject": { "issue_id": "GH-156", "repository": "lgcorzo/rust_CACD_autonomous_factory", "resource_caps": { "ram_mib": 30, "cpu_m": 250 }, "vault_jit_ttl_secs": 300 }, "proof": { "type": "Ed25519Signature2020", "jws": "eyJhbGciOiJFZERTQ..." } }
Phase 2: Spec-Driven Development

The 7-Step Spec-Kit Slash-Command Pipeline & Causal Governance

Dark Gravity completely replaces free-form LLM code generation with Spec-Driven Development (SDD). Before a single byte of code is written in a sandbox, the Product Owner Agent (Rustant) queries R2R GraphRAG for architectural context and runs a deterministic Spec-Kit pipeline through the spec_kit_tool MCP endpoint.

1. /speckit-constitution

Enforces sovereign principles: Zero Trust, mTLS 1.3, gVisor resource caps, and anti-loop safeguards.

2. /speckit-specify

Combines R2R context with issue intent to create spec.md: defining what and why without stack pollution.

3. /speckit-clarify

Runs up to 5 automated Q&A cycles against edge cases before architecture begins, eliminating requirements ambiguity.

4. /speckit-plan

Outputs technical blueprints (plan.md, research.md, contracts/), pinning crates and interfaces.

5. /speckit-tasks

Decomposes plan into atomic, dependency-ordered tasks (tasks.md) with [P] parallel flags.

6. /speckit-taskstoissues

Converts tasks into tracked backlog sub-issues with injected hardware clamping markers.

7. Semantica-AGI Conflict Check

Validates generated plan against organizational ontology to catch architectural contradictions before sandbox ignition.

Phase 3: Durable Orchestration

Superspec Bridging, Hatchet Long-Term DAG & Crash Checkpoints

The speckit-superpowers-bridge (Superspec) parses Spec-Kit tasks.md into structured domain entities and maps them into Hatchet's durable develop-task sub-workflows. Hatchet provides at-least-once, durable execution semantics; how well this holds up in the lab is one of the things being tested.

S3 Checkpoint State Recovery

As the Developer Agent completes each atomic task (e.g. T001, T002), execution snapshots (BridgeState) are flushed to MinIO S3 in the dg-factory-checkpoints bucket and CloudNativePG PostgreSQL. If a worker pod crashes or is terminated due to memory bounds, Hatchet restarts execution exactly at the first pending task without repeating completed AST code surgery or wasting LLM tokens.

// Hatchet develop-task checkpoint representation pub struct StepCheckpoint { pub mission_id: String, pub step_index: u32, pub task_id: String, // e.g. "T002" pub diff_sha256: String, // AST mutation hash pub memory_state_bytes: u64, pub tokens_spent: u32, pub status: StepStatus, // Completed | InProgress | Blocked pub s3_snapshot_uri: String, // s3://dg-factory-checkpoints/... }
Phase 4: Sandboxing & Validation

gVisor Micro-Sandboxing, AST Surgery & Aethelgard Circuit Breaker

Execution occurs exclusively in ephemeral gVisor (runsc) user-space sandboxes configured with target limits of RAM ≤ 30 MiB and CPU ≤ 250m. AST code mutations are executed via native ADK-Rust, followed by test and security gates.

1. ADK-Rust AST Surgery

Tree-sitter AST search-and-replace algorithm applies localized mutations directly to Rust files without external subprocess overhead or regex hallucinations.

2. In-Memory Secret Zeroization

All JIT tokens and credentials derive #[derive(Zeroize, ZeroizeOnDrop)], so they are overwritten in memory when dropped. Timing figures from micro-benchmarks are not treated as production guarantees.

3. SAST LLM-as-a-Judge

Heterogeneous frontier models score patches. Scores < 8.0/10 or detected vulnerabilities trigger the Aethelgard loop (max 3 retries) or freeze to Agent-Stuck.

Phase 5: Delivery & Directives

GitOps Atomic Delivery & Interactive Pull Request Steering

Approved patches are committed atomically via REST APIs directly to feature branches (specs/NNN-<feature>) and open Pull/Merge Requests targeting main. Human developers interactively steer the bot on PR threads via command directives.

Interactive Directives (@darkgravity)

  • @darkgravity /status — Queries factory health, DAG step, and token spend.
  • @darkgravity /refine <prompt> — Triggers ZeroClaw to apply localized AST edits.
  • @darkgravity /spec <prompt> — Instructs Rustant to re-evaluate Spec-Kit spec.md.
  • @darkgravity /validate — Reruns cargo test suite and SAST security check.
  • @darkgravity /retry — Restarts the Aethelgard remediation loop.

Low-Noise PR Protocol

The poller places an immediate "eyes" (👀) reaction upon comment detection to acknowledge receipt without posting spam comments. It strictly ignores self-authored bot accounts to prevent infinite loops, and posts a single comprehensive summary when the directive finishes.

Strict Manual Merge Policy: Agents are physically forbidden from merging to main. Merge authority rests solely with the human Senior Reviewer (HITL Vertex 4).
Phase 6: Living Knowledge & C4

Tree-sitter AST GraphRAG, Living C4 Models & Open Knowledge Format (OKF)

When a PR is merged into main, the autonomous lifecycle doesn't end: it automatically updates living corporate memory. The deepwiki-rs daemon parses AST diffs, updates R2R GraphRAG in pgvector, and dispatches the Documentation Agent (DocAgent) using the Superpowers framework to regenerate C4 architecture diagrams and OpenWiki documentation.

DocAgent Superpowers Pipeline

  1. writing-plans: Decomposes wiki updates into 2–5 min atomic tasks.
  2. dispatching-parallel-agents: Spawns isolated subagents per wiki page.
  3. subagent-driven-development: Loads only targeted R2R sub-graphs.
  4. verification-before-completion: Enforces OSR < 5% gate.
  5. requesting-code-review: Validates C4 Mermaid syntax and Markdown.
  6. finishing-a-development-branch: Commits pages and packages EU R&D grants.

Google Open Knowledge Format (OKF)

--- type: architecture_node mission_id: "GH-156-outbound-polling" title: "Zero-Trust Outbound Ingestion Daemon" date: "2026-10-12T12:00:00Z" status: verified tags: ["poller", "nhi", "ed25519", "kafka"] last_verified_commit: "9f3c8a1b" source_path: "crates/factory-infrastructure/src/poller.rs" --- # Outbound Ingestion Daemon [[architecture/overview]] | [[security/zero-trust]]

Automated C4 Architecture Models (Levels 1–3)

The C4 model (Context, Container, Component, Code) provides four progressive levels of architectural abstraction. Dark Gravity's DocAgent queries depends_on edges in R2R GraphRAG to generate and maintain these diagrams automatically in Mermaid syntax.

C4 Model • Level 1: System Context

Shows the Dark Gravity software factory as a black-box system, surrounded by human users, external source control systems, identity providers, and telemetry sinks.

graph TD classDef person fill:#0284c7,stroke:#38bdf8,stroke-width:2px,color:#fff; classDef system fill:#1e293b,stroke:#00f0ff,stroke-width:2px,color:#fff; classDef external fill:#1e1b4b,stroke:#818cf8,stroke-width:1px,color:#cbd5e1; PO["Human Product Owner
(Business Strategy & Epics)"]:::person LEAD["Human Tech Lead & Senior Reviewer
(Sprint & PR Merge Scrutiny)"]:::person subgraph FACTORY["Dark Gravity CA/CD Autonomous Software Factory"] DG["Autonomous Agent Factory
[Rust, Hatchet, gVisor, R2R]
Consumes issues, verifies code, updates living docs"]:::system end GIT["Git Platforms
[Jira, GitHub, GitLab]
Outbound polling & remote PRs"]:::external VAULT["HashiCorp Vault
[Ed25519 NHI & 5-min JIT Tokens]"]:::external SENTRY["Sentry Crash Monitor
[Production Telemetry & Stacktraces]"]:::external COMPLIANCE["EU R&D Grant Registry
[Hazitek & SPRI Grant Telemetry]"]:::external PO -->|"1. Submits Epics with autonomous-mission"| GIT DG -->|"2. Outbound HTTPS polling (30-60s)"| GIT DG -->|"3. Ephemeral credentials request"| VAULT DG -->|"4. Polls errors (every 15 min)"| SENTRY DG -->|"5. Opens Remote Pull Requests"| GIT LEAD -->|"6. Reviews and manually merges PRs"| GIT DG -->|"7. Packages audit telemetry & reports"| COMPLIANCE
C4 Model • Level 2: Container Topology

Expands the factory into its high-level runtime containers: the 5-crate Rust workspace, Hatchet DAG engine, Kafka event mesh, pgvector R2R memory, MinIO storage, and gVisor sandboxes.

graph TB classDef rust fill:#0f172a,stroke:#f97316,stroke-width:2px,color:#fff; classDef k8s fill:#111827,stroke:#00f0ff,stroke-width:2px,color:#fff; classDef storage fill:#1e1b4b,stroke:#a855f7,stroke-width:2px,color:#fff; classDef darknet fill:#064e3b,stroke:#10b981,stroke-width:2px,color:#fff; subgraph K8S_CLUSTER["Kubernetes Control Plane & Namespaces"] subgraph NS_AGENTS["ns / agents"] CLI["factory-cli daemon
[Rust Binary Entrypoint]"]:::rust APP["factory-application
[Rustant & ZeroClaw Workers]"]:::rust end subgraph NS_ORCH["ns / orchestrators"] HATCHET["Hatchet Workflow Engine
[Durable 6-Phase DAG]"]:::k8s end subgraph NS_EVENTS["ns / confluent"] KAFKA["Apache Kafka (KRaft)
[mission-input & agent-thought]"]:::k8s end subgraph NS_SANDBOX["ns / development"] GVISOR["gVisor runsc Micro-Sandbox
[RAM <= 30MiB, CPU <= 250m]"]:::k8s end subgraph NS_STORAGE["ns / storage & knowledge"] PG["CloudNativePG Postgres 16
[Hatchet State & DAG Ledger]"]:::storage PGV["pgvector R2R GraphRAG
[AST Embeddings & Dependency Graph]"]:::storage MINIO["MinIO Sovereign S3
[dg-factory-checkpoints & Artifacts]"]:::storage end subgraph NS_OVERLAY["ns / openziti"] ZITI["OpenZiti mTLS 1.3 Overlay
[Zero-Inbound Dark Mesh]"]:::darknet end end CLI -->|"Publishes Ingested Tasks"| KAFKA KAFKA -->|"Triggers Workflow"| HATCHET HATCHET -->|"Dispatches Durable Steps"| APP APP -->|"Spawns Ephemeral Execution"| GVISOR APP -->|"Snapshots Step State"| MINIO HATCHET -->|"Persists Run State"| PG APP -->|"Semantic Code Retrieval"| PGV APP -.->|"Encrypted Traffic"| ZITI
C4 Model • Level 3: Component Architecture

Zooms into the internal components of factory-application, factory-infrastructure, and deepwiki-rs.

graph LR classDef comp fill:#111827,stroke:#00f0ff,stroke-width:1px,color:#fff; classDef helper fill:#1e1b4b,stroke:#a855f7,stroke-width:1px,color:#cbd5e1; subgraph INFRA["crates/factory-infrastructure"] POLLER["GitPlatformPoller
(30-60s Outbound Polling)"]:::comp VAULT_CLI["VaultClient
(Ed25519 JIT Tokens)"]:::comp KAFKA_PROD["KafkaProducer
(Transactional Events)"]:::comp R2R_CLI["R2rClient
(Knowledge Graph Interface)"]:::comp end subgraph APPLICATION["crates/factory-application"] DAG["HatchetMissionWorkflow
(6-Phase Orchestrator)"]:::comp RUSTANT["RustantAgent
(Spec-Kit Planner)"]:::comp BRIDGE["SuperspecBridge
(tasks.md to DAG Mapper)"]:::comp ZEROCLAW["ZeroClawAgent
(ADK-Rust AST Surgery)"]:::comp AETHELGARD["AethelgardLoop
(3-Retry & Deadlock Breaker)"]:::comp DOCS["DocAgent
(Superpowers Engine)"]:::comp end subgraph KNOWLEDGE["deepwiki-rs AST Engine"] TS["Tree-sitter Parser
(Rust AST Delta Extractor)"]:::helper GRAPH["SymbolGraphEngine
(depends_on Edge Calculator)"]:::helper end POLLER --> VAULT_CLI POLLER --> KAFKA_PROD KAFKA_PROD --> DAG DAG --> RUSTANT RUSTANT --> R2R_CLI RUSTANT --> BRIDGE BRIDGE --> ZEROCLAW ZEROCLAW --> AETHELGARD DAG --> DOCS DOCS --> TS TS --> GRAPH

Factory Lifecycle Quality Gates Matrix

A side-by-side comparative summary of each lifecycle phase, its core technology stack, isolation boundary, and gating success criteria.

Phase Core Mechanism Security & Isolation Quality & Progression Gate
1. Ingestion Outbound HTTPS Polling (30–60s) via GitPlatformPoller No public inbound ports (design goal); W3C Ed25519 VC signing (did:factory) ✔ Pass: Tagged autonomous-mission & resource limit block extracted
2. Planning 7-step Spec-Kit pipeline (/speckit-*) + R2R GraphRAG Semantica-AGI ontological conflict check; mTLS 1.3 ✔ Pass: spec.md, plan.md, tasks.md committed to specs/NNN-*
3. Execution Superspec Bridge + ADK-Rust AST surgery gVisor (runsc) sandboxes (target RAM ≤ 30 MiB, CPU ≤ 250m) ✔ Pass: Task executed with MinIO S3 BridgeState checkpoint
4. Validation Logical tests + SAST LLM-as-a-Judge (security_review) Heterogeneous model routing via LiteLLM; secret zeroization on drop ✔ Pass: all tests pass + review score ≥ 8.0/10.0 (max 3 retries)
5. Delivery Remote feature branch creation & atomic PR/MR opening Outbound API egress only; low-noise 👀 reactions ✔ Pass: PR opened linking Closes #ID; manual human merge (Vertex 4)
6. Memory deepwiki-rs AST delta scan + DocAgent Superpowers Google OKF YAML frontmatter; MinIO audit packaging ✔ Pass: OSR < 5% gate verified; C4 diagrams & Hazitek/SPRI reports filed