harness-everything 0.7.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.github/workflows/ci.yml +12 -2
  4. package/AGENTS.md +36 -33
  5. package/CHANGELOG.md +23 -0
  6. package/README.md +9 -8
  7. package/benchmarks/results/reviews/pr142-verification.json +95 -0
  8. package/ci/action-gate.test.js +1 -1
  9. package/ci/doc-capability-consistency.test.js +3 -0
  10. package/ci/invariant-routing.test.js +105 -34
  11. package/ci/mechanism-2af-worktree-isolation.test.js +152 -0
  12. package/ci/mechanism-2ag-router-worktree-contract.test.js +44 -0
  13. package/ci/mechanism-2ah-workflow-lifecycle.test.js +140 -0
  14. package/ci/openai-plugin-package.test.js +14 -7
  15. package/ci/workflow-execution-contract.test.js +60 -0
  16. package/docs/architecture.md +112 -106
  17. package/docs/mechanism-first-skill-mesh.md +93 -99
  18. package/docs/openai-plugin.md +1 -1
  19. package/docs/philosophy.md +40 -30
  20. package/docs/platform-capabilities.md +10 -2
  21. package/docs/reviews/pr-142-issue-131.md +89 -0
  22. package/docs/routing.md +68 -103
  23. package/docs/workflow-runtime.md +109 -0
  24. package/fable-mode/CONTRACT-FORMAT.md +3 -1
  25. package/fable-mode/SKILL.md +1 -1
  26. package/fable-mode/execution-guardrails/SKILL.md +1 -1
  27. package/fable-mode/fable-haiku/SKILL.md +1 -1
  28. package/fable-mode/fable-opus/SKILL.md +1 -1
  29. package/fable-mode/fable-sonnet/SKILL.md +1 -1
  30. package/fable-mode/scripts/workflow-plan-consumer.js +3 -1
  31. package/harness-everything/SKILL.md +17 -23
  32. package/harness-everything/references/triage-and-tiers.md +81 -98
  33. package/harness-everything/scripts/kernel-router-core.js +263 -0
  34. package/harness-everything/scripts/kernel-router.js +97 -212
  35. package/harness-everything/scripts/router-contract-core.js +612 -0
  36. package/harness-everything/scripts/router-contract.js +21 -581
  37. package/hooks/hooks.json +22 -1
  38. package/hooks/scripts/contract-test.js +24 -2
  39. package/hooks/scripts/lib/workflow-isolation.js +102 -0
  40. package/hooks/scripts/lib/workflow-runtime.js +102 -0
  41. package/hooks/scripts/state-persist.js +1 -0
  42. package/hooks/scripts/workflow-disposition.js +97 -0
  43. package/hooks/scripts/workflow-gate.js +53 -0
  44. package/hooks/scripts/workflow-stop-gate.js +44 -0
  45. package/opencode-plugin/plugin.json +1 -1
  46. package/package.json +2 -2
  47. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  48. package/plugins/harness-everything/hooks/hooks.json +20 -1
  49. package/plugins/harness-everything/hooks/scripts/contract-test.js +24 -2
  50. package/plugins/harness-everything/hooks/scripts/lib/workflow-isolation.js +102 -0
  51. package/plugins/harness-everything/hooks/scripts/lib/workflow-runtime.js +102 -0
  52. package/plugins/harness-everything/hooks/scripts/state-persist.js +1 -0
  53. package/plugins/harness-everything/hooks/scripts/workflow-disposition.js +97 -0
  54. package/plugins/harness-everything/hooks/scripts/workflow-gate.js +53 -0
  55. package/plugins/harness-everything/hooks/scripts/workflow-stop-gate.js +44 -0
  56. package/plugins/harness-everything/plugin.json +1 -1
  57. package/plugins/harness-everything/scripts/lib/advisory-text.js +53 -54
  58. package/plugins/harness-everything/skills/fable-mode/CONTRACT-FORMAT.md +3 -1
  59. package/plugins/harness-everything/skills/fable-mode/SKILL.md +1 -1
  60. package/plugins/harness-everything/skills/fable-mode/execution-guardrails/SKILL.md +1 -1
  61. package/plugins/harness-everything/skills/fable-mode/fable-haiku/SKILL.md +1 -1
  62. package/plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md +1 -1
  63. package/plugins/harness-everything/skills/fable-mode/fable-sonnet/SKILL.md +1 -1
  64. package/plugins/harness-everything/skills/fable-mode/scripts/workflow-plan-consumer.js +3 -1
  65. package/plugins/harness-everything/skills/harness-everything/SKILL.md +17 -23
  66. package/plugins/harness-everything/skills/harness-everything/references/triage-and-tiers.md +81 -98
  67. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router-core.js +263 -0
  68. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router.js +97 -212
  69. package/plugins/harness-everything/skills/harness-everything/scripts/router-contract-core.js +612 -0
  70. package/plugins/harness-everything/skills/harness-everything/scripts/router-contract.js +21 -581
  71. package/plugins/harness-everything/skills/using-git-worktrees/SKILL.md +14 -16
  72. package/plugins/harness-everything/skills/using-git-worktrees/references/workflow-details.md +44 -85
  73. package/scripts/lib/advisory-text.js +53 -54
  74. package/using-git-worktrees/SKILL.md +14 -16
  75. package/using-git-worktrees/references/workflow-details.md +44 -85
@@ -1,141 +1,154 @@
1
1
  # Harness Architecture
2
2
 
3
- This document describes the internal architecture, lifecycle, and integration boundaries of the Harness behavior layer. The current cross-platform claim boundary is centralized in [platform-capabilities.md](platform-capabilities.md); host sections here must remain consistent with it.
4
-
5
- ---
3
+ This document describes Harness runtime architecture and integration boundaries. Current host capability/evidence claims are centralized in [platform-capabilities.md](platform-capabilities.md); package wiring is not live-host proof.
6
4
 
7
5
  ## Architectural Overview
8
6
 
9
- Harness is a **system supervisor**, not a universal workflow engine. Skills remain independently useful, while runtime mechanisms establish a small cross-cutting contract around software work.
7
+ Harness is a **behavior and workflow supervisor**, not one universal fixed workflow. The router chooses the smallest sufficient execution topology; once selected, that topology becomes a lifecycle contract. The model retains freedom over reasoning, tools, and implementation technique inside the contract.
10
8
 
11
- The architecture follows a mechanism-first skill mesh with a **minimal kernel**:
9
+ The minimal kernel establishes:
12
10
 
13
- - classify scope before mutation,
14
- - require evidence before completion claims,
15
- - stop repeated same-signature micro-retries and re-plan,
16
- - leave domain skill selection, ordering, planning style, and delegation to the agent.
11
+ - scope/tier before mutation,
12
+ - a selected workflow topology when task evidence supports one,
13
+ - applicability evaluation for every suggested skill before omission,
14
+ - objective evidence before completion,
15
+ - bounded re-plan/recovery after repeated failure,
16
+ - explicit blocked/degraded/escape state instead of silent workflow deletion.
17
17
 
18
- > **Do not enforce workflow order. Enforce workflow invariants.**
18
+ > **Mandatory applicable workflow; flexible reasoning/implementation inside it.**
19
+ >
20
+ > A suggested skill can be `not-applicable` after evaluating its real flow. A selected topology cannot be replaced with a direct path merely because the model is confident. Escape is only for genuinely uncovered workflow scope and requires evidence.
19
21
 
20
- This is intentionally different from the older design where Tier 2 implied a fixed TDD/checklist pipeline and Tier 3 implied a mandatory Fable/multi-agent pipeline.
22
+ This avoids both extremes: the old universal Tier-2/Tier-3 pipeline and a purely advisory system where the model can rationalize away verification, staging, documentation, or other applicable obligations.
21
23
 
22
24
  ```mermaid
23
25
  flowchart TD
24
- subgraph User_Session [User Session]
25
- U([User Request]) --> Boot[bootstrap.js: Session Start / restore]
26
- end
27
-
28
- subgraph Kernel [Harness Kernel]
29
- Boot --> Preflight[Environment / integration discovery]
30
- Preflight --> KR[kernel-router.js]
31
- KR --> TR[tier-router.js<br/>classifier + guide discovery]
32
- TR --> Inv[Inject minimal invariants]
33
- Inv --> Choice[Agent chooses useful skills / tactics]
34
- end
35
-
36
- subgraph Execution [Agent-Controlled Execution]
37
- Choice --> Tools[Tool calls / edits / tests]
38
- Tools --> Evidence{Evidence supports completion?}
39
- Evidence -- Yes --> Done[Evidence-backed completion]
40
- Evidence -- No --> Retry[Diagnose / iterate]
41
- end
42
-
43
- subgraph Defense [Runtime Boundaries]
44
- Retry --> CB{Same-signature failure x3?}
45
- CB -- No --> Tools
46
- CB -- Yes --> ZO[zoom-out / fresh diagnosis]
47
- ZO --> Tools
48
- end
49
-
50
- subgraph Learning [Optional Learning / State]
51
- Done --> Record[Record / self-evolve when useful]
52
- end
53
-
54
- style Kernel fill:#eceff1,stroke:#37474f,stroke-width:2px,color:#000000
55
- style Defense fill:#fff9c4,stroke:#fbc02d,stroke-width:2px,color:#000000
56
- style Learning fill:#e3f2fd,stroke:#1e88e5,stroke-width:2px,color:#000000
26
+ U([User Request]) --> B[Session bootstrap / environment]
27
+ B --> K[kernel-router.js]
28
+ K --> T[tier-router.js<br/>classification + task shape]
29
+ T --> P[Structured workflow plan]
30
+ P --> A{Strategy selected?}
31
+ A -- No / deferred --> D[Preserve invariants<br/>choose smallest justified workflow]
32
+ A -- Yes --> C[ACTIVE workflow contract]
33
+ C --> S{Suggested skills?}
34
+ S -- Yes --> E[Read SKILL.md<br/>resolve applicability]
35
+ S -- No --> X[Execute topology]
36
+ E --> X
37
+ X --> V{Required stage/check resolved?}
38
+ V -- Yes --> Done[Evidence-backed completion]
39
+ V -- No --> R[Diagnose / bounded re-plan]
40
+ R --> X
41
+ R -- topology cannot cover scope --> Esc[Evidence-backed escape<br/>uncovered scope only]
57
42
  ```
58
43
 
59
44
  ### Router responsibilities
60
45
 
61
- `kernel-router.js` is the public runtime entry point. It delegates heuristic classification and dynamic guide/skill discovery to `tier-router.js`, then converts the result into the Harness contract:
46
+ `kernel-router.js` is the public runtime entry. It consumes the structured classifier contract and exposes:
62
47
 
63
- - recommended Tier + rationale,
48
+ - tier + rationale,
49
+ - selected/deferred execution strategy,
64
50
  - required invariants,
65
- - advisory skill suggestions.
51
+ - suggested skills that require applicability evaluation,
52
+ - the visible routing checkpoint,
53
+ - a workflow execution contract.
66
54
 
67
- The kernel deliberately suppresses the old fixed `BASE EXECUTION LOOP` wording so that a host selecting `tdd`, `security-review`, `repo-docs`, or another peer skill cannot accidentally replace or bypass the cross-cutting Harness contract.
55
+ The router does not tell the model *how* to solve each stage. It decides what lifecycle shape is required. `direct-single`, `iterative-single`, `fable-staged`, `fable-parallel`, and `fable-multi-agent-workspace` remain deliberately small, non-overlapping topology choices.
68
56
 
69
- `harness-everything` remains the public/manual skill entry point for routing, debugging, and re-routing. `install-cognitive-os` remains the explanatory/manual entry point for the Discover → Think → Try → Summarize → Record policy. Automatic correctness must not depend on either one winning host peer-skill selection first.
57
+ ### Skill applicability vs. topology execution
70
58
 
71
- ---
59
+ Router suggestions remain useful domain/workflow knowledge, not a universal sequence. Before omission, the agent reads the complete `SKILL.md` entry and evaluates `USE FOR`, `DO NOT USE FOR`, workflow/basic flow, and hard rules. Name/description/router-summary or “routine task” is insufficient evidence.
72
60
 
73
- ## Integration Touchpoints
61
+ The selected topology is stronger. Once selected, it must be entered and resolved unless the runtime records a permitted workflow escape with uncovered scope + evidence. Covered obligations survive the escape.
74
62
 
75
- Harness aligns to each host's real capabilities. Enforcement strength is platform-specific; shared skill text does not prove mechanism parity.
63
+ ### Runtime workflow state
76
64
 
77
- ### Self-healing and placement
65
+ On host paths that can persist it, `kernel-router.js` records session-scoped `workflow-run.json` with the selected strategy and lifecycle state. Prompt text is not persisted; only a content hash is retained for correlation.
78
66
 
79
- `harness-everything/scripts/self-heal.js` audits supported integration touchpoints and can re-run the idempotent installer to repair missing pieces. If a user intentionally removed an integration, respect that choice.
67
+ For selected Fable topologies on Claude:
80
68
 
81
- A platform's native files stay where that platform expects them. Harness-owned runtime state converges under the platform's `harness-everything/` state directory, while skills remain in each platform's native skill location. `manifest.json` records installed artifacts so uninstall can remove only Harness-owned files.
69
+ - `workflow-gate.js` checks supported shell/direct mutation, actual direct/patch targets, and registered Git worktree isolation before major-workflow mutation; Fable also requires a run bound to the workflow/session identity;
70
+ - Fable owns stage contracts, `dependsOn`/`writeSet`, validated execution batches, objective per-stage checks, synthesis, cold verification, and bounded re-plans;
71
+ - `workflow-stop-gate.js` rejects completion while correlated stage contracts remain unresolved;
72
+ - `workflow-disposition.js` starts/replans within budget, records blockers, and permits only declared-stage evidence-backed escape (`workflow-uncovered-scope` or `host-capability-unavailable`). Covered obligations, isolation, and independent verification survive escape. See [runtime transitions and limitations](workflow-runtime.md).
82
73
 
83
- ### Runtime state vs. skill content
74
+ Other topologies use their own applicable mechanisms: loop budgets, regular verification stop-gates, action gates, and task-specific skills. Mechanism coverage is not assumed identical across hosts.
75
+
76
+ ## Integration Touchpoints
84
77
 
85
- Runtime state includes hook metadata, circuit-breaker counters, handoff/verification timestamps, and WAL-style session state. Skill content is separate and independently discoverable. This separation lets a domain skill remain useful even when a host does not support Harness runtime hooks.
78
+ Harness aligns to each host's actual lifecycle/tool APIs. Shared skill text defines a contract; only supported host mechanisms can mechanically block or observe particular transitions.
86
79
 
87
- ---
80
+ ### Runtime state vs. skill content
88
81
 
89
- ## Host Adapters
82
+ Runtime state includes hook metadata, workflow lifecycle, circuit-breaker counters, handoff/verification evidence, and WAL-style session state. Skill content is independently discoverable and remains useful on instruction-only surfaces.
90
83
 
91
- ### 1. Claude Code — hook-enforced
84
+ ### Claude Code — hook-enforced mechanisms
92
85
 
93
86
  The installer configures native lifecycle hooks and project skills.
94
87
 
95
- - `SessionStart`: `bootstrap.js` restores prior state and audits integrations.
96
- - `UserPromptSubmit`: `kernel-router.js` establishes routing + invariants before peer/domain skill execution.
97
- - `PreToolUse`: circuit breaker, boundary/depth/context guards, and subagent scope guards can block supported tool calls.
98
- - `PostToolUse`: records outcomes/state and tracks repeated failures.
99
- - `Stop`: `stop-gate.js` prevents an edit batch from being claimed complete without successful verification evidence.
88
+ - `SessionStart`: bootstrap/restoration.
89
+ - `UserPromptSubmit`: kernel routing + active workflow contract.
90
+ - `PreToolUse`: workflow bypass gate, action gate, rule-of-3, boundary/depth/context guards, subagent scope guard.
91
+ - `PostToolUse`: outcomes, state, repeated-failure evidence, stage checks.
92
+ - `Stop`: action-gate audit, selected-Fable completion gate, and ordinary verify-before-claim stop gate.
93
+
94
+ These hooks make some lifecycle obligations mechanically enforceable. They still do not prove a real session loaded/fired them; live evidence remains separate.
95
+
96
+ ### OpenCode — plugin enforcement, scoped live verification
100
97
 
101
- The prompt hook is intentionally lightweight: it does **not** prescribe TODO/TDD/Fable order. It gives the model the rails and lets the model orchestrate itself.
98
+ The retained [OpenCode evidence](../benchmarks/results/live-host/opencode-2026-09-16/README.md) supports **project-scope `.js` loading and edit/verification state on OpenCode 1.18.31 (macOS)**. The final snapshot is **post-reset**. Hard-lock is an **interactive observation** with **no retained blocked-tool trace**; reflection was **operator-seeded** and then agent-rewritten. Global scope, npm-package installation, and other OpenCode versions remain unverified.
102
99
 
103
- ### 2. OpenCode — plugin enforcement, scoped live verification
100
+ This evidence does not establish the new mandatory-workflow lifecycle on OpenCode. That requires its own adapter/evidence before parity is claimed.
104
101
 
105
- `opencode-plugin/` maps supported enforcement behavior to OpenCode's real plugin API with deterministic mechanism coverage. Partial live-host evidence supports project-scope `.js` loading and edit/verification state on OpenCode 1.18.31 (macOS): [retained evidence](../benchmarks/results/live-host/opencode-2026-09-16/README.md). The final snapshot is post-reset (`hardLock: false`, `count: 1`), not a full enforcement history. Hard lock is only an interactive observation with no retained blocked-tool trace. Reflection was operator-seeded, then agent-rewritten; state-file deletion is an agent-controlled reset, not durable hard enforcement. This does not establish behavioral effectiveness. `.mjs` auto-discovery is broken on this host version (issue #127). Global scope, npm-package installation, and other host versions remain unverified.
102
+ ### Cursor — skills plus advisory rules
106
103
 
107
- ### 3. Cursor — skills plus advisory rules
104
+ Cursor receives project skills and advisory rules. The semantic workflow contract can be stated, but unsupported lifecycle transitions are not mechanically enforced.
108
105
 
109
- The current installer uses `.cursor/skills/` plus `.cursorrules`. Cursor’s documented skill and plugin surfaces are separate from Harness runtime hooks; routing/verification/retry boundaries remain self-directed unless a compatible mechanism is independently verified.
106
+ ### GitHub Copilot agent surfaces — skills plus advisory instructions
110
107
 
111
- ### 4. GitHub Copilot agent surfaces — skills plus advisory instructions
108
+ Copilot receives Agent Skills/repository instructions. No Harness-specific live hook-enforcement claim is made from repository text alone.
112
109
 
113
- The current installer uses `.github/skills/` plus `.github/copilot-instructions.md`. GitHub’s Agent Skills paths are documented, but no Harness-specific plugin or live session is verified here.
110
+ ### Codex / local OpenAI plugin
114
111
 
115
- ### 5. Codex — local OpenAI plugin plus advisory installer path
112
+ Codex has multiple distinct Harness surfaces:
116
113
 
117
- Codex has two distinct Harness integration surfaces and documentation must keep them separate:
114
+ - The general `--codex` installer writes repo-scoped `.agents/skills/` plus `AGENTS.md`; when consumed only as instructions, workflow enforcement is advisory/instruction-governed.
115
+ - The **Codex / local OpenAI plugin** under `plugins/harness-everything/` packages canonical skills plus session/prompt/supported-tool/subagent/stop hooks. The package includes workflow-gate adapters, but this is mechanism/package evidence until a live Codex session proves loading/firing.
116
+ - The public OpenAI **Skills-only** artifact excludes local `.codex-plugin` lifecycle hooks; it carries reusable workflow knowledge, not local hard gates.
118
117
 
119
- - The general `--codex` installer path writes Codex-facing skills/instructions such as `AGENTS.md`; where the host only consumes those instructions, that path is advisory.
120
- - The packaged local OpenAI plugin under `plugins/harness-everything/` includes `.codex-plugin/plugin.json`, all 26 canonical skills, and lifecycle hooks for `SessionStart`, `UserPromptSubmit`, supported local `PreToolUse` / `PostToolUse`, `SubagentStart` / `SubagentStop`, and `Stop`. Those hooks inject the compact session policy, run the invariant-first kernel, track supported edits and verification, and surface subagent scope changes.
118
+ Do not infer Claude parity from package similarity.
121
119
 
122
- The local plugin therefore has **mechanism-tested local enforcement** for the packaged event/tool mappings. This is package evidence, not a live-host claim; the host's hook review/trust flow and a fresh session are still required. Do not infer broader Claude parity for events or tools that are not listed in the package.
120
+ ### Continue.dev — rules documented, standalone discovery uncertain
123
121
 
124
- The public OpenAI **Skills-only** submission is narrower again: it ships reusable skills and referenced assets, not the local `.codex-plugin` lifecycle hooks. Public reviewer/listing claims must describe skill/workflow behavior rather than local hook enforcement. See [openai-plugin.md](openai-plugin.md).
122
+ Continue uses native rule files; standalone skill discovery remains separately bounded by the capability matrix.
125
123
 
126
- ### 6. Continue.dev — rules documented, skill discovery unknown
124
+ ### Hermes Agent — trusted skills plus advisory context
127
125
 
128
- The installer writes `.continue/rules/harness.md` with the platform's native rules format and retains `.continue/skills/` as an adapter candidate. The reviewed official Continue documentation does not establish standalone `SKILL.md` discovery, so no skill-loading or hard-gate parity is claimed.
126
+ Hermes uses trusted project/global skill surfaces plus advisory context. Trust/loading and lifecycle enforcement remain host-specific.
129
127
 
130
- ### 7. Hermes Agent — trusted skills plus advisory context
128
+ ## Fable Execution Architecture
131
129
 
132
- The installer writes `.hermes.md` for explicit project coverage and can install trusted project skills under `.agents/skills/` plus global skills under `~/.hermes/skills/`. Project skill loading remains subject to Hermes trust; no hard-gate parity is claimed.
130
+ Fable is the execution owner for selected `fable-*` topologies.
133
131
 
134
- ---
132
+ ```mermaid
133
+ flowchart TD
134
+ P[Selected Fable plan] --> M[Stage map<br/>dependsOn + writeSet]
135
+ M --> B{Validated batch?}
136
+ B -- No --> Block[Blocked / re-plan]
137
+ B -- Yes --> W[Named workers]
138
+ W --> C[Objective stage checks]
139
+ C --> S[Synthesis barrier]
140
+ S --> V{Verification pass?}
141
+ V -- Yes --> D[Delivery evidence]
142
+ V -- No --> R{Re-plan budget remains?}
143
+ R -- Yes --> M
144
+ R -- No --> Block
145
+ ```
146
+
147
+ The orchestrator controls lifecycle and completion; workers do not create peer-to-peer meshes or widen their own write scope. The model remains creative inside each bounded stage, while stage existence/checks/termination are contract state.
135
148
 
136
149
  ## Cognitive OS and Skill Mesh
137
150
 
138
- The Cognitive OS is a policy layer, not a parent skill that every domain skill must call.
151
+ The Cognitive OS remains a reasoning policy:
139
152
 
140
153
  ```mermaid
141
154
  flowchart LR
@@ -148,32 +161,25 @@ flowchart LR
148
161
  Z --> T
149
162
  ```
150
163
 
151
- A domain skill may have its own lifecycle — for example RED/GREEN/REFACTOR inside `tdd` — without being forced into a global sequence. The only shared obligations are the kernel invariants.
152
-
153
- This separation solves the peer-skill routing problem: a strong host may correctly decide that a task primarily needs `tdd` or `security-review`; that choice is allowed. What it cannot silently erase is the routing/evidence/retry contract established by the runtime.
154
-
155
- ---
156
-
157
- ## Security Model & Data Locality
158
-
159
- Harness runs with a local-first, zero-trust model:
164
+ A domain skill may define RED/GREEN/REFACTOR or another local lifecycle. The selected Harness topology supplies the outer execution contract; domain skills supply tactics/stages when applicable.
160
165
 
161
- 1. **No Harness telemetry:** runtime scripts do not upload project code or state as a Harness service.
162
- 2. **Credential protection:** scripts do not require storing user secrets; interactive credentials remain human-controlled.
163
- 3. **Small hook surface:** hook scripts are local Node.js programs and should stay fast and auditable.
164
- 4. **Explicit enforcement labels:** unsupported/advisory behavior must not be documented as hard enforcement.
165
- 5. **Deterministic regression:** mechanism and routing behavior is tested with executable CI gates rather than inferred from documentation.
166
+ ## Security and Data Locality
166
167
 
167
- ---
168
+ 1. **No Harness telemetry service:** project code/state is not uploaded by Harness runtime scripts.
169
+ 2. **Credential protection:** credentials remain human/host controlled.
170
+ 3. **Small mechanism surface:** hooks should remain fast and auditable.
171
+ 4. **Explicit enforcement labels:** instruction, mechanism, and live evidence are distinct.
172
+ 5. **Deterministic regression:** workflow/routing/hook contracts are executable CI gates.
173
+ 6. **No silent widening:** workflow escape cannot widen authorization, permissions, or external side effects.
168
174
 
169
175
  ## Validation Boundary
170
176
 
171
- Static configuration is not enough to claim that a host behaves correctly. Validation is layered:
177
+ Validation is layered:
172
178
 
173
- - syntax/reference/manifest checks prove package integrity,
174
- - `ci/invariant-routing.test.js` proves the kernel contract and documentation invariants,
175
- - `ci/doc-capability-consistency.test.js` prevents current platform capability claims from drifting apart,
176
- - mechanism tests prove supported hook/plugin behavior,
177
- - live host sessions are required before promoting a source/mechanism-tested adapter to live host enforcement.
179
+ - syntax/reference/package checks prove package integrity;
180
+ - routing tests prove plan and workflow-contract semantics;
181
+ - mechanism tests prove supported hook/plugin behavior;
182
+ - live-host evidence proves a specific host actually loaded/fired the mechanism;
183
+ - paired behavioral evaluation (#71) is required before claiming the new lifecycle improves outcomes.
178
184
 
179
- The architecture and its Mermaid diagrams are part of that contract. Runtime changes that alter orchestration must update these documents in the same change.
185
+ The architecture diagrams are part of the contract. A runtime orchestration change must update these docs and tests in the same change.
@@ -1,165 +1,159 @@
1
1
  # Mechanism-First Skill Mesh
2
2
 
3
- Harness is not intended to be a rigid workflow engine. Its skills should remain independently useful, while still coordinating through lightweight mechanisms that help the model and the software engineer work together with less drift, fewer loops, and better evidence.
3
+ Harness coordinates independently useful skills through a small workflow runtime. It does **not** make every skill part of one universal DAG, but it also does not leave selected execution topology to model discretion.
4
4
 
5
- The preferred shape is a **mechanism-first skill mesh**: skills are autonomous, coordination is explicit, and enforcement happens at narrow decision points through scripts, hooks, exit codes, and compact return values. Platform-specific enforcement claims follow [platform-capabilities.md](platform-capabilities.md).
5
+ The preferred shape is:
6
6
 
7
- ---
7
+ > **mandatory applicable workflow + local skill autonomy + narrow runtime mechanisms**
8
+
9
+ Platform-specific enforcement claims remain bounded by [platform-capabilities.md](platform-capabilities.md).
8
10
 
9
11
  ## Design Intent
10
12
 
11
- Harness exists to improve engineering collaboration, not to replace model judgment with a fixed state machine.
13
+ Each skill remains understandable/executable on its own, while the kernel provides an outer lifecycle contract.
12
14
 
13
- Each skill should be able to answer four questions on its own:
15
+ A skill should answer:
14
16
 
15
- 1. **When should I activate?** The trigger should be clear without requiring another skill to interpret it.
16
- 2. **What do I protect?** The skill should describe the failure mode it prevents or the engineering habit it reinforces.
17
- 3. **What mechanism do I expose?** When possible, the skill should provide a script, command, checklist primitive, verifier, or return-value contract that makes its guidance concrete.
18
- 4. **What should I hand to nearby skills?** The skill may recommend a next skill, but it should not require a global handoff template to remain useful.
17
+ 1. **When should I activate?** Clear `USE FOR` / `DO NOT USE FOR` applicability.
18
+ 2. **What do I protect?** The failure mode or engineering discipline it addresses.
19
+ 3. **What workflow/mechanism do I expose?** A local flow, verifier, script, gate, or stable result when useful.
20
+ 4. **What evidence means I am done?** A check, artifact, or explicit blocked state.
19
21
 
20
- This keeps the system composable: `tdd` can run alone, `verification-loop` can run alone, `todo-driven-workflow` can run alone, and `harness-everything` can route among them when the task benefits from orchestration.
22
+ The router may surface several skills. Those suggestions must be evaluated from their actual `SKILL.md` flows before omission. They are **not** automatically all executed. Separately, the router selects one smallest sufficient outer topology. **The selected topology is mandatory for the run.**
21
23
 
22
- ---
24
+ ## Why Not One Global Skill Sequence?
23
25
 
24
- ## Why Not a Single Handoff Block?
26
+ A universal TODO/TDD/Fable sequence would:
25
27
 
26
- A universal handoff block makes workflow state easy to parse, but it also has costs:
28
+ - add prompt/runtime overhead to small tasks;
29
+ - confuse domain skills with orchestration topology;
30
+ - suppress useful model judgment inside stages;
31
+ - fail poorly on hosts that cannot enforce the same lifecycle APIs.
27
32
 
28
- - It encourages every platform and model to speak in the same rigid shape, even when a natural response would be clearer.
29
- - It can turn skills into a centralized workflow runner instead of a federation of local engineering disciplines.
30
- - It can make the model optimize for satisfying the template rather than making the best next engineering move.
31
- - It adds prompt weight on platforms where the mechanism cannot actually enforce the block.
33
+ So Harness separates **topology** from **capabilities/domain skills**:
32
34
 
33
- Harness should avoid mandatory global handoff text. Local skills may still use concise reports when they need them, but the mesh should not depend on one universal response format.
35
+ ```text
36
+ tier / task shape
37
+ +
38
+ selected execution topology
39
+ +
40
+ applicable skills/capabilities
41
+ +
42
+ required invariants/gates
43
+ ```
34
44
 
35
- ---
45
+ The topology is the lifecycle contract. Skills are resolved for applicability within/around that contract.
36
46
 
37
47
  ## Mechanisms Over Prose
38
48
 
39
- LLMs are highly sensitive to tool results, command outputs, exit codes, and short structured decisions. Harness should prefer those signals over long textual handoffs.
49
+ Prefer short structured state, tool results, exit codes, and objective evidence over stronger prompt wording.
40
50
 
41
- Good mechanism outputs are:
42
-
43
- - **Short:** the result should be easy for the model to keep in active attention.
44
- - **Actionable:** the output should name the next constraint, gate, or recommended skill.
45
- - **Non-authoritarian:** the mechanism should guide the model without stealing all judgment from it.
46
- - **Portable:** hook-capable platforms can run the mechanism automatically; hook-less platforms can call the same script explicitly.
47
-
48
- Example shape:
51
+ Example:
49
52
 
50
53
  ```text
51
54
  HARNESS_DECISION
52
55
  tier: 2
53
- required: route-before-execution, verify-before-claim, re-plan-after-repeat-failure
54
- suggest: todo-driven-workflow, verification-loop
55
- reason: user requested code changes
56
+ strategy: iterative-single
57
+ workflow_state: active
58
+ required: route-before-execution, objective-verification, loop-budget
59
+ suggest: tdd, verification-loop
60
+ suggestion_policy: evaluate-applicability
61
+ escape_policy: workflow-uncovered-scope-only
56
62
  ```
57
63
 
58
- This is not a handoff block. It is a compact mechanical signal. The model remains free to decide how to present the work, explain trade-offs, and collaborate with the engineer.
59
-
60
- ---
64
+ This says what must happen without prescribing private reasoning or exact implementation tactics.
61
65
 
62
- ## Skill Autonomy Contract
66
+ Good mechanisms are:
63
67
 
64
- Every skill in the mesh should remain useful when loaded directly.
68
+ - **short** enough to remain salient;
69
+ - **actionable** with an explicit next state;
70
+ - **failable** when a requirement is unmet;
71
+ - **bounded** by host capability/evidence;
72
+ - **non-prescriptive about HOW** unless a safety/contract requirement needs it.
65
73
 
66
- Recommended contract:
74
+ ## Skill Autonomy Contract
67
75
 
68
- - **Independent trigger:** the skill description should identify the problem or situation that activates it.
69
- - **Local workflow:** the skill should contain enough guidance to execute without reading the whole Harness ecosystem.
70
- - **Mechanism hook:** if a script can make the skill more reliable, expose it as an optional or required command.
71
- - **Neighbor links:** when another skill is commonly needed, recommend it by name and explain why.
72
- - **Exit discipline:** if the skill reaches a blocking state, it should say what evidence is missing or what human decision is needed.
76
+ Every skill should retain:
73
77
 
74
- This contract keeps skills interoperable without requiring central ownership of every task path.
78
+ - an independent trigger;
79
+ - a local workflow;
80
+ - objective/failable checks where possible;
81
+ - explicit neighbor links rather than hidden dependencies;
82
+ - blocked/exit discipline.
75
83
 
76
- ---
84
+ Read-before-omission exists so the agent can inspect this local contract without loading the entire ecosystem. If the skill flow applies, follow it; reading a skill is not permission to discard an applicable discipline because the model believes it already knows the answer.
77
85
 
78
86
  ## Coordination Patterns
79
87
 
80
- Harness should coordinate skills through small, composable patterns.
81
-
82
88
  ### Router Decision
83
89
 
84
- `harness-everything/scripts/kernel-router.js` is the public invariant-first runtime entry point. It delegates classification and guide discovery to `tier-router.js`, then returns the recommended tier, rationale, required invariants, and advisory skill suggestions. It intentionally does not emit a mandatory global execution pipeline.
90
+ `harness-everything/scripts/kernel-router.js` emits tier, strategy, invariants, skill suggestions, and an execution contract.
85
91
 
86
- ### Checklist State
92
+ - Suggested skills: read and resolve applicability (`use`, `not-applicable`, `unresolved/unavailable`).
93
+ - Selected topology: execute to resolution (`active` → verified/satisfied, blocked, or explicit evidence-backed escape).
87
94
 
88
- `todo-driven-workflow` may own explicit task decomposition state when that helps a Tier 2 or Tier 3 task. It is a suggested tactic, not a universal prerequisite, and the model may use native host TODO tracking or a Markdown checklist instead.
95
+ Names/descriptions/router summaries or “routine task” judgements cannot resolve applicability by themselves.
96
+
97
+ ### Fable Stage Contracts
98
+
99
+ For `fable-*` strategies, Fable owns stage lifecycle: `dependsOn`, `writeSet`, validated batches, objective checks, synthesis, cold verification, and bounded re-planning. The parent cannot replace a selected Fable topology with direct editing on hook-capable paths that package the workflow gate.
89
100
 
90
101
  ### Verification Gate
91
102
 
92
- `verification-loop` and `verify-gate.js` provide reusable verification mechanisms. Hosts with a compatible stop/completion hook can invoke verification mechanically; instruction-only hosts can call the same verifier explicitly before final delivery.
103
+ `verification-loop`, `verify-gate.js`, ordinary stop-gates, and Fable stage evidence provide objective completion signals. Verification is not an optional courtesy when selected/applicable workflow state requires it.
93
104
 
94
105
  ### Recovery Gate
95
106
 
96
- `rule-of-3` and `zoom-out` coordinate through failure signatures and recovery instructions where the host exposes the required lifecycle/tool hooks. On hosts without those hooks, `zoom-out` remains usable as an explicit recovery discipline, but the automatic failure counter must not be implied.
107
+ Rule-of-3 stops repeated same-signature micro-retries and requires a new diagnosis. Fable verification failures return to bounded re-planning; budget exhaustion becomes blocked instead of endless iteration.
97
108
 
98
- ### Skill Suggestion
109
+ ### Action Gate
99
110
 
100
- `self-evolve` and generated skills feed the router through manifest metadata. The router should surface likely skills, but the model keeps final responsibility for selecting what actually applies.
111
+ Irreversible/external side effects are orthogonal to topology and require their pre-action gate where supported. Workflow escape never widens permissions or bypasses action approval.
101
112
 
102
- ---
113
+ ### Self-Evolve
103
114
 
104
- ## Platform Strategy
115
+ Learning should consume verified lifecycle evidence (escape, re-plan, recovery, recurrence), not operate as a side door around the active workflow.
105
116
 
106
- Harness should use the strongest mechanism each installation surface actually provides.
117
+ ## Platform Strategy
107
118
 
108
- | Platform class | Preferred coordination style | Enforcement level |
119
+ | Platform class | Workflow contract | Mechanical enforcement |
109
120
  | --- | --- | --- |
110
- | Hook/plugin-capable surfaces | Hooks/plugins run routers, guards, trackers, or completion gates automatically | Mechanical injection/blocking is possible for the mechanisms actually packaged |
111
- | CLI/tool-capable but hook-less surfaces | The model explicitly calls Harness scripts at decision points | Mechanism-guided, not automatically enforced |
112
- | Prompt-only surfaces | Advisory instructions include command snippets and decision rules | Self-regulated by the model |
113
-
114
- One host may expose more than one surface. Codex is the important example: the general `--codex` installer path is instruction/advisory oriented, while the **local OpenAI plugin** packages session, prompt, supported-tool, subagent, and stop hooks for mechanism-tested runtime enforcement. The public OpenAI **Skills-only** submission does not include those local lifecycle hooks.
115
-
116
- OpenCode is plugin-capable and has mechanism coverage, but live plugin loading remains unverified. Claude Code has the broadest currently verified Harness lifecycle-hook surface.
117
-
118
- ---
119
-
120
- ## Guidance for Instruction-Only / Hook-Less Paths
121
-
122
- Do not recreate hooks with a rigid universal handoff template. Instead, make mechanisms easy to call.
121
+ | Hook/plugin-capable | Same selected-workflow contract | Supported transitions can be blocked/observed by packaged mechanisms |
122
+ | CLI/tool-capable without lifecycle hooks | Same contract stated/called explicitly | Instruction/mechanism guided; no automatic blocking claim |
123
+ | Prompt-only | Same semantic obligations | Self-regulated only |
123
124
 
124
- Implemented today, both wired into `bin/cli.js` and referenced by name in the advisory text each platform's installer writes (`scripts/lib/advisory-text.js`):
125
+ Contract semantics and enforcement evidence are separate. Claude currently packages the broadest Harness lifecycle surface. The local OpenAI/Codex plugin packages supported adapters but requires live-host evidence before parity claims. The public OpenAI Skills-only artifact carries skill/workflow knowledge without local lifecycle hooks. OpenCode has its own plugin path and evidence boundaries.
125
126
 
126
- - `npx github:dyphn1/Harness-everything next "<prompt>"`: runs the Harness routing path and prints the recommended tier, invariant contract, and matching knowledge/skill suggestions.
127
- - `npx github:dyphn1/Harness-everything verify`: wraps `verify-gate.js`, running the target project's own lint/test scripts and exiting non-zero on failure. This is the explicit hook-less verification path; it is not equivalent to claiming that a host automatically runs a `Stop` hook.
127
+ ## Hook-Less Paths
128
128
 
129
- Both resolve their target scripts relative to the CLI's own package install, not the caller's cwd, so they work the same way regardless of which platform-specific directory (`.codex/skills/`, `.cursor/skills/`, `.github/skills/`, ...) a copy of the `harness-everything` skill also happens to be sitting in — a fixed relative path like `harness-everything/scripts/tier-router.js` would silently point at nothing depending on which platform installed it.
129
+ Two explicit commands provide high-signal state without pretending hooks exist:
130
130
 
131
- Not yet implemented — still aspirational, do not reference these as if they exist until they're built:
132
-
133
- - `harness recover`: summarize repeated failure signatures and recommend `zoom-out` when needed. Hook-less paths do not collect failure signatures the way the Claude Code `PostToolUse` mechanism does, so there is no reliable state to summarize yet.
134
- - `harness skills`: list installed, generated, and matching skills for the current workspace.
135
-
136
- These commands let instruction-only Codex installs, Cursor, Copilot, Continue, and Hermes receive high-signal mechanical feedback without forcing them into a single scripted conversation shape.
131
+ ```bash
132
+ npx github:dyphn1/Harness-everything next "<prompt>"
133
+ npx github:dyphn1/Harness-everything verify
134
+ ```
137
135
 
138
- ---
136
+ `next` emits the routing/workflow contract. `verify` runs the explicit verification path. Instruction-only hosts must treat these requirements as real even though the host cannot mechanically prevent skipping them.
139
137
 
140
138
  ## Anti-Goals
141
139
 
142
140
  Harness should not become:
143
141
 
144
- - A centralized DAG runner where every skill depends on one global workflow file.
145
- - A mandatory response-template system that suppresses useful model variation.
146
- - A command-only framework where skills cannot be understood by reading `SKILL.md`.
147
- - A hidden daemon that performs broad actions without visible evidence.
148
- - A platform-specific product that only works well when Claude Code hooks are available.
149
-
150
- The mesh should remain local, legible, and cooperative.
151
-
152
- ---
142
+ - one global DAG containing every skill;
143
+ - a mandatory response-template system;
144
+ - a command-only framework whose skills are unreadable without runtime code;
145
+ - a hidden daemon with broad authority;
146
+ - a system that claims cross-host hard enforcement from package text;
147
+ - a recommendation system where selected workflows can be rationalized away.
153
148
 
154
149
  ## Practical Authoring Rules
155
150
 
156
- When adding or revising a skill:
157
-
158
- 1. Keep the skill independently executable.
159
- 2. Add a script only when a mechanism can make the behavior more reliable than prose.
160
- 3. Keep script output compact and stable enough for models to react to.
161
- 4. Prefer gates at natural decision points: before editing, after repeated failure, before final delivery, and before persistence.
162
- 5. Let the model choose wording and presentation unless the skill truly needs a specific artifact format.
163
- 6. Document neighboring skills as recommendations, not hidden dependencies, unless the dependency is required for safety.
151
+ 1. Keep skills independently understandable/executable.
152
+ 2. Put applicability/basic flow in `SKILL.md`; deep detail belongs in references.
153
+ 3. Add mechanisms when they make behavior more reliable than prose.
154
+ 4. Make checks failable and evidence-based.
155
+ 5. Put gates at real transition boundaries: before mutation/side effects, after repeated failure, before completion, before persistence.
156
+ 6. Let the model choose HOW inside the contract.
157
+ 7. Treat workflow escape as a measured coverage gap, not convenience.
164
158
 
165
- The result should feel like an engineering co-pilot with good reflexes: autonomous where creativity matters, constrained where repeated mistakes are expensive, and explicit whenever evidence is needed.
159
+ The result should feel like a capable engineer operating inside explicit lifecycle obligations rather than either a scripted automaton or an unconstrained model that can skip its own process.
@@ -28,7 +28,7 @@ flowchart TD
28
28
  X[Stop hook] --> V
29
29
  ```
30
30
 
31
- The local OpenAI adapter enforces cross-cutting invariants through the lifecycle events that it packages. Tier-specific skills remain advisory; the model may choose, combine, reorder, or skip them. Tool enforcement is limited to the host tool names declared in `hooks/hooks.json`.
31
+ The local OpenAI adapter enforces cross-cutting invariants through the lifecycle events that it packages. Suggested skills require applicability evaluation; the selected topology is mandatory with scoped, evidence-backed escape. The [workflow runtime](workflow-runtime.md) documents pending/running/satisfied/blocked state, Fable entry, worktree isolation, completion evidence, and degradation limits. Tool enforcement is limited to the host tool names declared in `hooks/hooks.json`.
32
32
 
33
33
  ## Package layout
34
34