# sasanksai/harness-writer architecture

> Architecture diagram of the GitHub repository sasanksai/harness-writer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sasanksai/harness-writer
- Repository: https://github.com/sasanksai/harness-writer

## Overview

#### Purpose and entry points

`harness-writer` is a Claude Code plugin/skill that converts a user mission into a generated, persistent “lane”: documents, state, and an `.mjs` execution engine that a later Claude session can operate. It authors the lane but deliberately does not start execution.

Primary entry points are the Claude Code skill instructions in `SKILL.md` and plugin metadata in `.claude-plugin/plugin.json` and `.claude-plugin/marketplace.json`.

#### Skill authoring pipeline

The central control flow is a 12-step authoring procedure: scope a mission, create a work plan and lane artifacts, perform adversarial review, fix findings, then distill lessons into the skill’s doctrine. `SKILL.md` defines this procedure and its non-negotiable red lines.

Generated output is expected to include `PLAN.md`, `CLAUDE.md`, `HARNESS.md`, `PROMPT.md`, a `harness/` runtime, and persisted `state/`. These are templates/specifications rather than committed example lanes.

#### Generated harness runtime

The runtime template is `references/mjs-template.mjs`. It defines the per-task tick lifecycle: rubric-first planning, implementation, blind verification, one repair attempt, and a final drift guard.

The intended runtime boundary is Claude Code’s dynamic Workflow environment and model routing: Fable handles supervision/driver/guard work, Sonnet handles implementation and research, and Opus independently verifies results. The repository itself does not contain a deployed service or long-running application.

#### Three-ring orchestration model

The architecture separates responsibility across nested loops:

1. Mission loop: human plus Fable manages phases, triage, and retrospectives.
2. Driver loop: Fable gates work, invokes one tick, persists state, commits locally, and schedules continuation.
3. Tick loop: the `.mjs` engine performs one task through plan, implement, verify, repair, and guard stages.

The generated driver protocol is constrained so state has a single writer, while shell gating is pure-read. The ring-to-playbook binding strategy is documented in `references/skill-rings.md`.

#### Reliability and safety gates

The harness doctrine requires fail-closed behavior: preflight checks, dependency-DAG validation, exit-code-based blind verification, failure-to-repair enqueueing, permanent regression checks, and circuit-breaker escalation after repeated failure. These mechanisms prevent self-grading, retry storms, silent bypasses, and mission drift.

Their canonical specification is `references/self-repair.md`, with supporting rationale in `references/design-principles.md`.

#### Doctrine, templates, and evidence boundary

`references/doc-templates.md` provides the canonical skeletons for generated lane documents, keeping generated artifacts structurally consistent. `references/design-principles.md` holds the underlying engineering doctrine used by the authoring skill.

Claims incorporated into that doctrine are source-gated: `references/sources.md` is the evidence ledger, and `references/CHANGELOG.md` records doctrine changes and corrections. This makes source verification and post-run learning explicit inputs to future harness generation.

Main entry points: [`SKILL.md`](https://github.com/sasanksai/harness-writer/blob/main/SKILL.md) (Skill instructions), [`references/mjs-template.mjs`](https://github.com/sasanksai/harness-writer/blob/main/references/mjs-template.mjs) (Tick lifecycle), [`references/skill-rings.md`](https://github.com/sasanksai/harness-writer/blob/main/references/skill-rings.md) (Ring playbook), [`references/design-principles.md`](https://github.com/sasanksai/harness-writer/blob/main/references/design-principles.md) (Design principles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Plugin Authoring"]
  node_plugin_metadata["Plugin metadata<br/>Claude plugin manifest<br/>[plugin.json]"]
  node_marketplace_metadata["Marketplace metadata<br/>plugin registry manifest<br/>[marketplace.json]"]
  node_skill["Skill instructions<br/>authoring procedure<br/>[SKILL.md]"]
  node_doc_templates["Document templates<br/>generated-lane schemas<br/>[doc-templates.md]"]
  node_design_principles["Design principles<br/>engineering doctrine"]
  node_evidence_ledger["Evidence ledger<br/>source gate<br/>[sources.md]"]
  node_doctrine_changelog["Doctrine changelog<br/>learning record<br/>[CHANGELOG.md]"]
  node_rings_playbook["Ring playbook<br/>orchestration binding<br/>[skill-rings.md]"]
  node_repair_spec["Self-repair specification<br/>reliability protocol<br/>[self-repair.md]"]
end

subgraph group_lane["Generated Persistent Lane"]
  node_lane_documents["Lane documents"]
  node_lane_state[("Persisted state<br/>single-writer state")]
  node_harness_runtime{{"Harness runtime<br/>per-task .mjs engine<br/>[mjs-template.mjs]"}}
end

subgraph group_runtime["Execution Model"]
  node_mission_loop(("Mission loop<br/>human + Fable supervision"))
  node_driver_loop(("Driver loop<br/>Fable orchestration"))
  node_tick_loop(("Tick lifecycle<br/>task execution stages<br/>[mjs-template.mjs]"))
  node_workflow_environment["Claude Code Workflow<br/>dynamic execution environment"]
end

node_plugin_metadata -->|"registers"| node_skill
node_marketplace_metadata -->|"publishes"| node_plugin_metadata
node_skill -->|"uses"| node_doc_templates
node_skill -->|"applies"| node_design_principles
node_skill -->|"binds rings through"| node_rings_playbook
node_skill -->|"enforces"| node_repair_spec
node_evidence_ledger -->|"source-gates claims"| node_design_principles
node_doctrine_changelog -->|"updates"| node_design_principles
node_skill -->|"authors"| node_lane_documents
node_skill -->|"generates from template"| node_harness_runtime
node_skill -->|"specifies"| node_lane_state
node_mission_loop -->|"manages"| node_driver_loop
node_driver_loop -->|"invokes one task"| node_tick_loop
node_driver_loop -->|"sole writer"| node_lane_state
node_tick_loop -->|"implemented by"| node_harness_runtime
node_workflow_environment -->|"runs Fable supervision"| node_driver_loop
node_workflow_environment -->|"routes models by stage"| node_tick_loop
node_repair_spec -->|"governs repair and guard"| node_tick_loop
node_rings_playbook -.->|"defines responsibilities"| node_mission_loop
node_rings_playbook -.->|"defines responsibilities"| node_driver_loop

click node_plugin_metadata "https://github.com/sasanksai/harness-writer/blob/main/.claude-plugin/plugin.json"
click node_marketplace_metadata "https://github.com/sasanksai/harness-writer/blob/main/.claude-plugin/marketplace.json"
click node_skill "https://github.com/sasanksai/harness-writer/blob/main/SKILL.md"
click node_doc_templates "https://github.com/sasanksai/harness-writer/blob/main/references/doc-templates.md"
click node_design_principles "https://github.com/sasanksai/harness-writer/blob/main/references/design-principles.md"
click node_evidence_ledger "https://github.com/sasanksai/harness-writer/blob/main/references/sources.md"
click node_doctrine_changelog "https://github.com/sasanksai/harness-writer/blob/main/references/CHANGELOG.md"
click node_rings_playbook "https://github.com/sasanksai/harness-writer/blob/main/references/skill-rings.md"
click node_repair_spec "https://github.com/sasanksai/harness-writer/blob/main/references/self-repair.md"
click node_harness_runtime "https://github.com/sasanksai/harness-writer/blob/main/references/mjs-template.mjs"
click node_tick_loop "https://github.com/sasanksai/harness-writer/blob/main/references/mjs-template.mjs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_plugin_metadata,node_marketplace_metadata,node_skill,node_doc_templates,node_design_principles,node_evidence_ledger,node_doctrine_changelog,node_rings_playbook,node_repair_spec toneBlue
class node_lane_documents,node_lane_state,node_harness_runtime toneAmber
class node_mission_loop,node_driver_loop,node_tick_loop,node_workflow_environment toneMint
```

## Components

### Plugin Authoring

Claude Code skill and its doctrine sources.

- [Plugin metadata](https://github.com/sasanksai/harness-writer/blob/main/.claude-plugin/plugin.json): Claude plugin manifest · `.claude-plugin/plugin.json`
- [Marketplace metadata](https://github.com/sasanksai/harness-writer/blob/main/.claude-plugin/marketplace.json): plugin registry manifest · `.claude-plugin/marketplace.json`
- [Skill instructions](https://github.com/sasanksai/harness-writer/blob/main/SKILL.md): authoring procedure · Defines the 12-step workflow and non-negotiable red lines. · `SKILL.md`
- [Document templates](https://github.com/sasanksai/harness-writer/blob/main/references/doc-templates.md): generated-lane schemas · Canonical skeletons for lane documents. · `references/doc-templates.md`
- [Design principles](https://github.com/sasanksai/harness-writer/blob/main/references/design-principles.md): engineering doctrine · `references/design-principles.md`
- [Evidence ledger](https://github.com/sasanksai/harness-writer/blob/main/references/sources.md): source gate · Verifies claims admitted into doctrine. · `references/sources.md`
- [Doctrine changelog](https://github.com/sasanksai/harness-writer/blob/main/references/CHANGELOG.md): learning record · `references/CHANGELOG.md`
- [Ring playbook](https://github.com/sasanksai/harness-writer/blob/main/references/skill-rings.md): orchestration binding · Maps responsibilities to mission, driver, and tick rings. · `references/skill-rings.md`
- [Self-repair specification](https://github.com/sasanksai/harness-writer/blob/main/references/self-repair.md): reliability protocol · Defines fail-closed checks, repair, regressions, and escalation. · `references/self-repair.md`

### Generated Persistent Lane

Artifacts authored for a later Claude session.

- **Lane documents**: PLAN · CLAUDE · HARNESS · PROMPT · Persistent mission plan, operating instructions, protocol, and prompt.
- **Persisted state**: single-writer state · Driver-owned state for continuation and recovery.
- [Harness runtime](https://github.com/sasanksai/harness-writer/blob/main/references/mjs-template.mjs): per-task .mjs engine · Generated tick engine; authored but not started by this skill. · `references/mjs-template.mjs`

### Execution Model

Nested orchestration and per-task runtime.

- **Mission loop**: human + Fable supervision · Manages phases, triage, and retrospectives.
- **Driver loop**: Fable orchestration · Gates work, invokes one tick, writes state, commits, and schedules continuation.
- [Tick lifecycle](https://github.com/sasanksai/harness-writer/blob/main/references/mjs-template.mjs): task execution stages · Rubric plan, implementation, blind verification, repair, and drift guard. · `references/mjs-template.mjs`
- **Claude Code Workflow**: dynamic execution environment · Routes Fable for supervision, Sonnet for work, and Opus for independent verification.

## Connections

- Plugin metadata → Skill instructions: registers
- Marketplace metadata → Plugin metadata: publishes
- Skill instructions → Document templates: uses
- Skill instructions → Design principles: applies
- Skill instructions → Ring playbook: binds rings through
- Skill instructions → Self-repair specification: enforces
- Evidence ledger → Design principles: source-gates claims
- Doctrine changelog → Design principles: updates
- Skill instructions → Lane documents: authors
- Skill instructions → Harness runtime: generates from template
- Skill instructions → Persisted state: specifies
- Mission loop → Driver loop: manages
- Driver loop → Tick lifecycle: invokes one task
- Driver loop → Persisted state: sole writer
- Tick lifecycle → Harness runtime: implemented by
- Claude Code Workflow → Driver loop: runs Fable supervision
- Claude Code Workflow → Tick lifecycle: routes models by stage
- Self-repair specification → Tick lifecycle: governs repair and guard
- Ring playbook → Mission loop: defines responsibilities
- Ring playbook → Driver loop: defines responsibilities
