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,58 +1,68 @@
1
1
  # Harness Philosophy
2
2
 
3
- Harness is built on a single, core belief: **AI coding models are highly capable, but they struggle with self-regulation, attention drift, and environment awareness.**
3
+ Harness is built on a simple observation: **strong AI coding models reason well, but can still self-authorize away process obligations when they believe the task is already clear.**
4
4
 
5
- Instead of replacing the model or restricting it with heavy, opinionated frameworks that stifle creativity, Harness acts as a **behavioral layer** — reusable skills plus the strongest lightweight runtime mechanisms each supported installation surface actually provides.
5
+ Harness therefore separates reasoning freedom from workflow reliability. It does not prescribe the model's chain of thought or force one giant pipeline. Instead, it establishes the smallest applicable lifecycle contract and lets the model choose how to satisfy it.
6
6
 
7
- The current mechanism/enforcement boundary is platform-specific; see [Platform Capability Matrix](platform-capabilities.md). A skill-only or instruction-only install must not be described as if it automatically runs lifecycle hooks.
7
+ The mechanism/enforcement boundary remains platform-specific; see [Platform Capability Matrix](platform-capabilities.md). A semantic contract can be mandatory even when an instruction-only host cannot mechanically block every violation, so contract strength and host enforcement evidence must be reported separately.
8
8
 
9
- ---
9
+ ## Core Philosophy: Constrain Lifecycle, Not Reasoning
10
10
 
11
- ## The Core Philosophy: Intervene Only When Necessary
11
+ 1. **Reasoning autonomy remains high.** The model chooses implementation technique, tools, decomposition details, and tactics inside the selected workflow.
12
+ 2. **Applicable workflow is mandatory.** Once routing selects a topology, it must be executed to resolution. Model confidence, “simple”, “routine”, and “already clear” are not escape conditions.
13
+ 3. **Skill applicability is explicit.** Router-suggested skills are read/evaluated before omission. A suggestion can be `not-applicable` when its actual flow does not match; a selected topology is stronger and cannot simply be skipped.
14
+ 4. **Escape is conditional, not default.** If the selected workflow genuinely cannot represent part of the task, record the uncovered scope and evidence, then allow model-defined handling only for that uncovered portion.
15
+ 5. **Mechanisms beat stronger wording.** Important lifecycle transitions should use structured state, objective evidence, hooks/plugins, exit codes, and completion gates where the host supports them rather than escalating `MUST`/`CRITICAL` prose.
12
16
 
13
- Many AI development frameworks attempt to fully control the model's execution flow. They use rigid DAGs, forced chains, or complex state machines. While this works for trivial, repetitive tasks, it can suppress useful model judgment on complex, novel engineering work.
17
+ This principle can be summarized as:
14
18
 
15
- Harness takes the opposite approach:
19
+ > **Mandatory applicable workflow; flexible reasoning/implementation inside it; evidence-backed escape only where the workflow does not cover the task.**
16
20
 
17
- 1. **Model Autonomy is Paramount:** The model should have freedom to explore, choose useful skills/tools, and design its solution inside a small set of cross-cutting invariants.
18
- 2. **Context-Driven Guidance:** Harness uses high-context, low-friction signals — skills, rules, local checks, and hooks/plugins where the host supports and packages them — rather than one rigid global execution path.
19
- 3. **Reactive Guardrails:** On integration surfaces that expose the required lifecycle/tool hooks, Harness can stay quiet until a boundary is violated or a repeated failure is detected. On advisory surfaces, the same principles remain guidance rather than automatic blocking.
20
- 4. **Behavior-First, Not Prompt-First:** Harness is not a collection of magic prompts. Its skills remain independently useful, while supported runtime adapters can react to real tool/session outcomes and workspace conditions.
21
+ The goal is not to make the model less capable. It is to prevent capability/confidence from silently deleting engineering obligations such as verification, bounded re-planning, stage checks, documentation checks, or safety gates when those obligations are applicable.
21
22
 
22
- ---
23
+ ## Why This Is Not a Rigid Global Pipeline
23
24
 
24
- ## The 4 Pillars of AI Model Guidance
25
+ Harness still rejects a universal `TODO → TDD → Fable → verification` sequence.
25
26
 
26
- To keep agents aligned and productive, Harness operates across four distinct domains. The **principle** applies everywhere; whether it is injected or enforced automatically depends on the selected host surface.
27
+ The router chooses the **smallest sufficient topology**:
27
28
 
28
- ### 1. Environment Alignment (Discovery over Assumption)
29
+ - `direct-single` for bounded one-pass work;
30
+ - `iterative-single` for ordinary bounded reason/act work with objective verification;
31
+ - `fable-staged` for dependent multi-stage work;
32
+ - `fable-parallel` only for validated independent workstreams;
33
+ - `fable-multi-agent-workspace` when persistent roles/handoffs/memory are materially needed.
29
34
 
30
- AI models often hallucinate terminal environments or make incorrect assumptions about the host operating system, shell, or package manager — especially on Windows or mixed-shell setups.
35
+ Domain skills remain conditional on applicability. The contract says “execute the selected lifecycle”, not “execute every skill in the repository.”
31
36
 
32
- Harness requires environment assumptions to be discovered rather than guessed. On surfaces that package a session-start/preflight hook, that context can be injected automatically. On instruction/skill-only paths, the agent must discover it explicitly before relying on shell-specific commands.
37
+ ## The 4 Pillars of AI Model Guidance
33
38
 
34
- ### 2. Guardrails (The Circuit Breakers)
39
+ ### 1. Environment Alignment — Discovery over Assumption
35
40
 
36
- When a model gets stuck on a subtle bug or compiler error, its natural tendency is to make micro-adjustments repeatedly.
41
+ Discover OS, shell, package/runtime context, repository boundaries, and available host capabilities before relying on them. On surfaces that package preflight/session hooks this can be injected automatically; instruction-only hosts must do it explicitly.
37
42
 
38
- The Harness recovery invariant is to stop same-signature micro-retries and re-plan after repeated failure. On hosts where the Rule-of-3 mechanism is actually packaged, a circuit breaker can track failures and block further mutation until a `zoom-out` diagnosis is performed. On other surfaces, `zoom-out` remains a reusable recovery discipline but there is no claim that an automatic counter/blocker exists.
43
+ ### 2. Guardrails — Lifecycle Boundaries
39
44
 
40
- ### 3. Context Preservation (Anti-Bloat Protection)
45
+ Circuit breakers, action gates, workflow gates, scope guards, and completion gates protect specific transitions. They should remain narrow and evidence-driven. On integration surfaces that expose the required lifecycle/tool hooks, Harness can mechanically block supported violations; elsewhere the same contract is instruction-governed and must not be mislabeled hard enforcement.
41
46
 
42
- As sessions grow, models can read too broadly or produce oversized output, degrading active context.
47
+ ### 3. Context Preservation — Progressive Disclosure
43
48
 
44
- Harness uses narrow reads, explicit scope, compact evidence, and — where a compatible runtime adapter exists — boundary mechanisms that can react mechanically. Skill-only surfaces still receive the discipline, but not an imaginary background daemon or hook.
49
+ Load the smallest useful context. Read a suggested skill's complete entry before deciding applicability, but do not load the entire skill tree or every optional deep reference. Machine-visible workflow state should carry lifecycle facts instead of repeating large prompt blocks.
45
50
 
46
- ### 4. Self-Evolution (Continuous Workspace Memory)
51
+ ### 4. Self-Evolution — Learn from Workflow Evidence
47
52
 
48
- When a complex issue is resolved, Harness can turn the verified lesson into durable workspace knowledge through `self-evolve`: a concise rule or a reusable generated skill, when persistence is actually justified.
53
+ `self-evolve` should learn from verified recovery and workflow gaps: escape events, repeated replans, verifier fail→pass transitions, and recurrence outcomes. It should improve future coverage rather than granting a shortcut around the current workflow. Durable learning remains distinct from runtime session state.
49
54
 
50
- This long-term learning path is distinct from **runtime session state** such as WAL/checkpoint files. Runtime state exists only on integrations that package the corresponding state hooks; reusable rules/skills are project artifacts and can outlive a single host session.
55
+ ## Mechanism-First Cooperation
51
56
 
52
- ---
57
+ Harness prefers a compact control loop:
53
58
 
54
- ## A Non-Intrusive Cognitive Amplifier
59
+ ```text
60
+ route -> select workflow -> execute -> verify
61
+ | fail -> bounded re-plan
62
+ | uncovered -> evidence-backed escape
63
+ | pass -> complete
64
+ ```
55
65
 
56
- Harness does not require a heavy daemon or a proprietary service. The repository's mechanisms and skill content operate locally in the developer/host environment, while each platform gets only the enforcement strength its real integration supports.
66
+ This leaves creativity where stronger models benefit from it while making lifecycle obligations observable and testable.
57
67
 
58
- For skill-level coordination, see [Mechanism-First Skill Mesh](mechanism-first-skill-mesh.md). For the exact current platform/install/evidence boundary, see [Platform Capability Matrix](platform-capabilities.md).
68
+ For skill-level coordination, see [Mechanism-First Skill Mesh](mechanism-first-skill-mesh.md). For current installation/enforcement/evidence status, see [Platform Capability Matrix](platform-capabilities.md).
@@ -17,6 +17,12 @@ Statuses are intentionally explicit:
17
17
 
18
18
  All `liveHostVerification` rows except OpenCode are `Unknown`. OpenCode's row is `Partial`: retained evidence supports project-scope `.js` loading and edit/verification state on OpenCode 1.18.31 (macOS), not durable hard enforcement. No fresh artifacts exist yet for the other surfaces, managed-workspace import, or public OpenAI approval.
19
19
 
20
+ ### Routing contract vs. host evidence
21
+
22
+ The repository routing contract uses **mandatory applicable workflow / conditional scoped escape**. Each suggested skill still requires reading its complete `SKILL.md` entry/basic flow before omission; the selected topology must resolve its applicable lifecycle obligations. A name, description, router summary, tier label, or generic “routine task” judgement is not enough skip evidence; unreadable suggestions are `unresolved/unavailable`, not silent skips.
23
+
24
+ This is a **repository/agent contract**, not an automatic upgrade to any platform row below. A hook can prove that the contract was injected into a session; it does not prove the model actually read every suggested skill. Instruction-only surfaces can carry the same rule without mechanically enforcing it. Promoting this behavior to live-host compliance requires retained host/session evidence under the #82 compatibility program. The Claude and local OpenAI packages now carry workflow entry/completion gates, but this package/mechanism change does not upgrade `platform-compatibility.json` live-host status values. See [workflow runtime](workflow-runtime.md) for scope, worktree isolation, and failure behavior. OpenCode and instruction-only/public Skills-only surfaces do not acquire equivalent runtime gating. Shell inspection is not a filesystem sandbox; absent hooks, agent-writable state, and indirect script effects remain limits.
25
+
20
26
  ## Current capability summary
21
27
 
22
28
  | Platform surface | Standalone skills | Plugin support | Hooks/lifecycle | Project scope | Global scope | Current evidence boundary |
@@ -47,14 +53,16 @@ The general installer’s target paths are tested independently from host discov
47
53
 
48
54
  These targets apply to both default link mode and explicit `--copy` mode. A canonical store is only a deduplication detail; it cannot make an unsupported host path supported. Install/uninstall tests also protect user-owned files and cover Linux, Windows, and macOS round-trip fixtures.
49
55
 
56
+ The advisory installer text generated for Codex/Cursor/Copilot/Continue/Hermes carries the same read-before-skip rule. That proves only what Harness writes, not that the host/model complied with it.
57
+
50
58
  ## Codex / local OpenAI plugin boundary
51
59
 
52
60
  Codex has two paths that must not be collapsed:
53
61
 
54
- 1. The general `--codex` installer writes advisory `AGENTS.md` plus repo-scoped skills under `.agents/skills/`.
62
+ 1. The general `--codex` installer writes advisory `AGENTS.md` plus repo-scoped skills under `.agents/skills/`. Its generated instructions require reading/evaluating every router-suggested skill before omission, but this remains instruction-governed.
55
63
  2. The local OpenAI plugin at `plugins/harness-everything/` packages the skills plus lifecycle hooks for session start, prompt routing, supported local tool calls, subagent lifecycle, and stop verification. Those hooks are mechanically checked, but no live plugin/session artifact is committed.
56
64
 
57
- The package is tested at the mechanism layer and remains subject to the host’s hook review/trust flow. A fresh host session is still required before claiming that a particular ChatGPT/Codex installation loaded and fired the hooks.
65
+ The package is tested at the mechanism layer and remains subject to the host’s hook review/trust flow. A fresh host session is still required before claiming that a particular ChatGPT/Codex installation loaded and fired the hooks or that the model followed read-before-skip.
58
66
 
59
67
  The public OpenAI Skills-only plugin is narrower again. Its ZIP contains the packaged `skills/` tree and referenced files, but not the local `.codex-plugin` lifecycle hooks. Public submission readiness is therefore a package/form contract, not evidence of public-directory approval or live hook execution.
60
68
 
@@ -0,0 +1,89 @@
1
+ # PR #142 / issue #131 completion review
2
+
3
+ This review covers the implementation in the commit containing this report,
4
+ starting from PR head `8b99baec44745e171f078fe9eb3dac6fd812b5c8`. It evaluates
5
+ Harness engineering and the latest #131 decision, including mandatory mutation
6
+ isolation. It is not a measured agent-performance benchmark.
7
+
8
+ ## Findings resolved
9
+
10
+ | Original gap | Delivered behavior | Regression evidence |
11
+ | --- | --- | --- |
12
+ | Escape changed the whole workflow state and skipped isolation | Stage-scoped escape; isolation survives legacy escape and blocked states | `mechanism-2af-worktree-isolation.test.js`, `mechanism-2ah-workflow-lifecycle.test.js` |
13
+ | Only cwd was checked | Registered linked checkout of the bound repo; direct/patch targets, move destinations, traversal, and links checked | `mechanism-2af-worktree-isolation.test.js` |
14
+ | Windows runner used 8.3 paths while Git reported long names | Native physical-path resolution equates both spellings without relaxing isolation | Windows path regression and worktree suites |
15
+ | Read-only shell prefixes accepted writes | Reject redirects, substitutions, chained commands and dangerous options; require isolated cwd for mutation/unknown commands | `mechanism-2af-worktree-isolation.test.js` |
16
+ | Next prompt erased unresolved obligations | Stable workflow identity across steering prompts; stronger route requires replan | `mechanism-2ah-workflow-lifecycle.test.js` |
17
+ | Same strategy/timestamp loosely matched any Fable run | Exact workflow, session and run correlation | `mechanism-2ah-workflow-lifecycle.test.js` |
18
+ | Entry gate blocked its own bootstrap path | One bounded stage-specification file and trusted start controller; state/source writes remain gated | `mechanism-2ah-workflow-lifecycle.test.js` |
19
+ | Stop trusted directory contents and pass labels | Expected manifest stages, correlated exit-zero evidence, worker attribution and fresh verifier required | `mechanism-2ah-workflow-lifecycle.test.js` |
20
+ | Stop retry silently passed unresolved work | Retry records blocked; no satisfied state without required evidence | `mechanism-2ah-workflow-lifecycle.test.js` |
21
+ | Failures could not recover cleanly | Observed fail-to-pass checks; explicit bounded replan; retained prior run evidence | `mechanism-2ah-workflow-lifecycle.test.js` |
22
+ | Runtime policy scraped human-readable output | Kernel imports the structured core result; complete invariants persist with the plan | routing tests and lifecycle tests |
23
+ | Current documents contradicted the PR | README, platform matrix, routing, architecture, Fable/worktree references and mirrors aligned | consistency/capability/reference gates |
24
+ | Existing CI selected the first matching hook group | Action-gate regression finds its actual adapter among shared tool matchers | `ci/action-gate.test.js` |
25
+
26
+ The first added isolation regression run failed 16 assertions against the PR
27
+ baseline, then passed after repair. The baseline's four failing GitHub CI jobs
28
+ also reported the action-gate matcher defect. The initial local checkout lacked
29
+ dependencies, producing a separate CRLF-fixture setup failure; `npm ci` resolved
30
+ that environment prerequisite.
31
+
32
+ ## Verification
33
+
34
+ Local environment: Windows, PowerShell, Node.js 24.15.0, npm 11.12.1. Work was
35
+ performed in an isolated linked worktree; the primary checkout remained clean.
36
+
37
+ All 14 required gate categories passed: `npm test`, mutations, mechanism,
38
+ consistency, repository contract, capability docs, references, release,
39
+ collision, positive skill routing, routing invariants, OpenAI package/runtime,
40
+ public submission, and platform compatibility. Failed checks were corrected and
41
+ the affected gates rerun. The final `npm test` includes **44 mechanism suites**.
42
+
43
+ The new lifecycle suite exercises **50 assertions against source and the same
44
+ 50 against the packaged OpenAI layout**, using actual child processes, Git
45
+ repositories, worktrees, controller commands and hook payloads. Host payloads
46
+ are fixtures: these are deterministic mechanism tests, not live agent sessions.
47
+
48
+ Waza passed 30 canonical/nested skill readiness checks, 26 routing-spec checks,
49
+ and token validation (57 successful commands). Positive routing covered 34
50
+ cases across 26 direct skills and classified four nested skills.
51
+
52
+ Build/types/lint have no separate project scripts; repository syntax and
53
+ consistency gates apply. No coverage percentage is claimed. The security scanner
54
+ reported 12 pre-existing documentation/test-pattern matches, including its own
55
+ patterns and an explicitly fake token fixture; changed production code added no
56
+ scanner findings. `npm ci` reported zero dependency vulnerabilities. Diff review
57
+ and `git diff --check` passed. See the retained [gate summary](../../benchmarks/results/reviews/pr142-verification.json).
58
+
59
+ Remote CI is a separate evidence layer. Its result must be read at the final PR
60
+ head; this local record does not assert a future GitHub Actions outcome.
61
+
62
+ ## Reassessment
63
+
64
+ Scores are review judgments about engineering readiness, each out of 100.
65
+ Each row has four equally weighted criteria (25 points each), with the observed
66
+ deductions shown. They are not success probabilities or benchmark results.
67
+
68
+ | Dimension | Criteria scores | Total | Remaining deductions |
69
+ | --- | --- | ---: | --- |
70
+ | Contract coherence | entry 22, transitions 23, scoped exceptions 24, docs 23 | 92 | Skill applicability and iterative budgets still partly rely on executor compliance |
71
+ | Mutation safety | worktree identity 23, targets 23, shell handling 17, state trust 12 | 75 | Arbitrary script effects need a host sandbox; runtime state is agent-writable |
72
+ | Deterministic verification | gate breadth 25, negative cases 24, package parity 24, evidence checks 18 | 91 | Host-shaped fixtures cannot establish real host behavior or semantic check quality |
73
+ | Operation and maintenance | entry/recovery 22, modularity 21, distribution 23, diagnostics/migration 18 | 84 | Manual stage setup, missing-metadata blocks and legacy-state repair add operator work |
74
+
75
+ Equal-weight engineering score: **85.5/100** (approximately **86/100**).
76
+ The system now has substantially stronger tested lifecycle and isolation
77
+ contracts. It is suitable for further host validation with explicit boundaries.
78
+
79
+ **Live-host reliability of these new gates remains unverified. Behavioral gain
80
+ from this PR remains unmeasured.** Neither receives an invented effectiveness
81
+ score. Older retained OpenCode evidence and older behavioral cases cannot prove
82
+ this workflow change. This review does not claim superiority over other skill
83
+ collections, reduced token cost, or improved task success rates.
84
+
85
+ The next evidence needed is a retained Claude/Codex session showing routing,
86
+ entry, mutation denial/allow, numeric stage results, worker correlation and Stop
87
+ resolution; then paired same-model/same-task behavioral runs. OpenCode needs its
88
+ own adapter before parity can be claimed. See [runtime limits](../workflow-runtime.md)
89
+ and [platform capabilities](../platform-capabilities.md).
package/docs/routing.md CHANGED
@@ -1,22 +1,26 @@
1
1
  # Harness Routing & Task Triage
2
2
 
3
- Harness classifies software work into three tiers to prevent both over-engineering and under-planning. **The tier is a scope recommendation, not a workflow pipeline.**
3
+ Harness classifies software work and selects the smallest sufficient execution topology. **A tier is a scope/risk signal, not a fixed skill sequence. A selected topology is an execution contract, not an optional suggestion.**
4
4
 
5
- The current architecture follows one rule:
5
+ The current architecture follows two coupled rules:
6
6
 
7
- > **Do not enforce workflow order. Enforce workflow invariants.**
7
+ > **Mandatory applicable workflow; flexible reasoning/implementation inside it.**
8
+ >
9
+ > **Skill applicability is evaluated explicitly; workflow escape is exception-only and evidence-backed.**
8
10
 
9
- A strong model should be free to decide how to complete the task. Harness protects only the small set of behaviors that must not disappear when the host chooses a peer/domain skill directly.
11
+ A strong model remains free to decide *how* to perform the work. It may not decide that an applicable selected lifecycle can be skipped because the task feels simple or already understood.
10
12
 
11
13
  ## Kernel invariants
12
14
 
13
- For software/project work, Harness establishes three mandatory rails before mutation:
15
+ For software/project work, Harness establishes mandatory rails before mutation:
14
16
 
15
- 1. **Route before execution** — establish task scope/tier.
17
+ 1. **Route before execution** — establish scope/tier and the smallest justified topology.
16
18
  2. **Verify before claim** — completion requires objective evidence appropriate to the change.
17
19
  3. **Re-plan after repeated failure** — after three same-signature failures, stop micro-retrying and use a fresh diagnosis / `zoom-out`.
20
+ 4. **Evaluate before omission** — read every suggested skill's complete `SKILL.md` entry before deciding applicability.
21
+ 5. **Resolve selected workflow** - successful completion requires `satisfied`; `blocked` is a reportable incomplete outcome. Escape covers only a declared stage and preserves other obligations.
18
22
 
19
- Skill selection, ordering, planning style, and delegation remain agent decisions unless the user or an authoritative project contract explicitly requires them.
23
+ The model owns tools, implementation technique, reasoning, and decomposition details inside those rails.
20
24
 
21
25
  ## Public routing path
22
26
 
@@ -24,9 +28,10 @@ Skill selection, ordering, planning style, and delegation remain agent decisions
24
28
  kernel-router.js
25
29
  ├─ delegates classification / guide discovery → tier-router.js
26
30
  ├─ preserves tier + rationale + dynamic-skill recommendations
27
- ├─ suppresses legacy fixed-pipeline wording
28
- ├─ emits required invariants
29
- └─ emits advisory skill suggestions
31
+ ├─ emits required invariants + structured workflow plan
32
+ ├─ requires applicability evaluation for suggested skills
33
+ ├─ activates the selected workflow execution contract
34
+ └─ exposes explicit blocked/degraded/escape state instead of silent downgrade
30
35
  ```
31
36
 
32
37
  Use:
@@ -37,13 +42,29 @@ node harness-everything/scripts/kernel-router.js "<prompt>"
37
42
  npx github:dyphn1/Harness-everything next "<prompt>"
38
43
  ```
39
44
 
40
- On a host where `UserPromptSubmit` is wired, reuse the hook output instead of running it twice.
45
+ On a host where `UserPromptSubmit` is wired, reuse that hook output instead of running it twice.
41
46
 
42
- ## Non-software bypass
47
+ ## Suggested skills vs. selected workflow
43
48
 
44
- General Q&A, translation, ordinary web search, and non-software writing bypass Harness routing. The model should answer directly and naturally.
49
+ These are intentionally different concepts.
45
50
 
46
- A software prompt that already says "use TDD", "security review", `repo-docs`, or another skill **does not bypass the kernel**. Host skill routing and Harness routing are different layers: the kernel establishes cross-cutting invariants; the host/model selects useful expertise.
51
+ For **every suggested skill**:
52
+
53
+ 1. Resolve/read the complete `SKILL.md` entry.
54
+ 2. Evaluate `USE FOR`, `DO NOT USE FOR`, workflow/basic flow, and hard rules.
55
+ 3. Read extra material only when the entry explicitly requires it for applicability.
56
+ 4. Resolve the suggestion as `use`, `not-applicable`, or `unresolved/unavailable`.
57
+
58
+ A name, description, router summary, tier label, or generic “routine/common task” judgement is not sufficient evidence for `not-applicable`.
59
+
60
+ For the **selected workflow topology**:
61
+
62
+ - enter it and execute it to resolution;
63
+ - do not silently replace it with a weaker/direct path because the model is confident;
64
+ - preserve objective checks, stage contracts, synthesis barriers, re-plan limits, and other obligations selected by the plan;
65
+ - use escape only for genuinely uncovered workflow scope, recording reason + uncovered scope + evidence.
66
+
67
+ This prevents two opposite failures: forcing every task through one giant pipeline, and allowing a model to rationalize away the entire engineering lifecycle.
47
68
 
48
69
  ## Three-tier recommendation model
49
70
 
@@ -51,121 +72,65 @@ A software prompt that already says "use TDD", "security review", `repo-docs`, o
51
72
  flowchart TD
52
73
  U([User Request]) --> S{Software / project work?}
53
74
  S -- No --> B[Bypass Harness]
54
- S -- Yes --> K[Harness Kernel<br/>scope + invariants]
55
- K --> T{Tier recommendation}
56
- T -- Tier 1 --> A[Agent self-orchestrates]
57
- T -- Tier 2 --> A
58
- T -- Tier 3 --> A
59
- A --> E[Execute selected tactics / skills]
60
- E --> V{Evidence supports completion?}
61
- V -- Yes --> D([Done])
62
- V -- No --> R[Diagnose and iterate]
63
- R --> F{Same failure x3?}
64
- F -- No --> E
65
- F -- Yes --> Z[Zoom out / re-plan]
66
- Z --> E
75
+ S -- Yes --> K[Kernel: classify + select topology]
76
+ K --> W{Strategy selected?}
77
+ W -- Deferred --> D[Keep invariants<br/>choose smallest justified workflow]
78
+ W -- Selected --> A[ACTIVE workflow contract]
79
+ A --> E[Execute with model-chosen tactics]
80
+ E --> V{Workflow obligations resolved?}
81
+ V -- Yes --> Done([Evidence-backed completion])
82
+ V -- No --> X[Diagnose / re-plan / satisfy missing stage]
83
+ X --> E
67
84
  ```
68
85
 
69
86
  ### Tier 1 — Trivial
70
87
 
71
- Typical triggers: typos, narrow single-file edits, straightforward cleanup, code explanation, simple Git operations.
72
-
73
- Guidance:
74
- - prefer direct execution,
75
- - avoid large plans/delegation,
76
- - load a focused skill only when it adds value,
77
- - still gather enough evidence to support the completion claim.
88
+ Typical triggers: typo/docs correction, narrow local edit, bounded explanation, straightforward Git operation. Usually selects `direct-single`; keep overhead minimal while still satisfying applicable verification/safety rails.
78
89
 
79
90
  ### Tier 2 — Standard
80
91
 
81
- Typical triggers: normal feature work, bug fixes, multi-file changes, security review, focused benchmark/evaluation.
82
-
83
- Possible suggestions:
84
- - `todo-driven-workflow` when explicit progress tracking helps,
85
- - `tdd` when executable behavioral tests are a useful design/verification tool,
86
- - `verification-loop` when systematic build/lint/test/diff selection helps,
87
- - `security-review` for trust/input/auth/secrets/network boundaries,
88
- - `using-git-worktrees` where isolation reduces workspace risk,
89
- - `eval-harness` for quantitative scoring.
92
+ Typical triggers: normal feature work, bug fixes, multi-file changes, focused benchmark/review. Usually selects `iterative-single`: bounded reason/act work plus objective verification. Focused skills such as `tdd`, `verification-loop`, `security-review`, `using-git-worktrees`, and `eval-harness` may be surfaced and must be resolved for applicability.
90
93
 
91
- None of those imply a universal `TODO → TDD → verification-loop` sequence.
94
+ No universal `TODO → TDD → verification-loop` order is implied. But when a skill is applicable, reading it does not grant permission to ignore its flow.
92
95
 
93
96
  ### Tier 3 — Macro
94
97
 
95
- Typical triggers: repository-wide refactors, architecture/migration work, large ambiguous requirements, broad documentation/system design, or work that may benefit from delegation.
96
-
97
- Possible suggestions:
98
- - `fable-mode` / `fable-discipline` for deliberate macro planning,
99
- - `multi-agent-workspace` for bounded delegation,
100
- - `repo-docs` for project-level documentation,
101
- - `grill-with-docs`, `to-spec`, and `to-tickets` when design decisions/specs/issues genuinely help.
102
-
103
- Tier 3 does **not** automatically mean multi-agent. If one capable agent can complete the work safely and efficiently, direct execution is valid.
98
+ Typical triggers: repository-wide refactors, architecture/migration work, broad synthesis, or bounded delegation. The router may select `fable-staged`, `fable-parallel`, or `fable-multi-agent-workspace`.
104
99
 
105
- ## Classifier tuning
100
+ A selected Fable topology is mandatory for that run. `fable-parallel` dispatches only validated independent batches; `fable-staged` preserves ordered stage contracts; workspace mode preserves durable handoffs/roles while Fable owns staged execution.
106
101
 
107
- `tier-router.js` reads keyword/guide tables from `harness-everything/scripts/routing-keywords.json`. Edit that data to tune Tier 2/3 signals or knowledge-guide matches without changing classifier code.
108
-
109
- The classifier remains heuristic:
110
- - its recommendation is the default, not an order,
111
- - a clear task reading may override it,
112
- - explicit user intent wins,
113
- - when overriding a materially different tier, record the reason briefly.
102
+ Tier 3 does **not** automatically mean multi-agent. The smallest sufficient topology still wins.
114
103
 
115
104
  ## Pre-action `actionGate`
116
105
 
117
- The router may predict that a request needs `workflowPlan.actionGate`, but the Phase 5 enforcement hook deliberately **re-classifies the exact tool payload**. A missing or incorrect router prediction therefore cannot authorize a destructive command.
106
+ `workflowPlan.actionGate` is orthogonal to topology. The executable hook re-classifies the exact tool payload, so an incorrect router hint cannot authorize a destructive/external side effect.
118
107
 
119
- The executable policy lives in `hooks/scripts/action-gate-rules.json`. A missing or invalid table activates built-in safety defaults and reports the degradation. A valid empty table remains empty so the CI negative control can detect accidental policy erasure.
108
+ Policy lives in `hooks/scripts/action-gate-rules.json`. Matched actions are handled according to host capability and configured policy; approved/executed payload identity is audited. `HARNESS_ACTION_GATE_POLICY=always-ask` forces Claude's ask path where supported. Unsupported host behavior must remain visible rather than being described as equivalent hard enforcement.
120
109
 
121
- | Exact tool action | Harness result | Audit disposition before execution |
122
- |---|---|---|
123
- | Safe unmatched command such as `git status` | allow/no decision | no gate record |
124
- | Matched command on Claude Code (default policy) | no decision: the session's permission mode, rules and auto-mode classifier decide | `deferred-to-host` |
125
- | Matched command on Claude Code with `HARNESS_ACTION_GATE_POLICY=always-ask` | `permissionDecision: "ask"` | `pending-approval` |
126
- | Matched command on a host without Harness-verified ask semantics | block with exit 2 | `rejected` |
127
- | Payload reaches `PostToolUse` | continue | `executed` with exact payload SHA-256 |
128
- | Payload reaches `PostToolUseFailure` | continue | `executed` + failed execution outcome |
129
- | Deferred or pending payload never executes before `Stop` | no execution | `rejected` |
130
- | Hook internal error | Claude: no decision plus a `systemMessage` warning (`always-ask`: `ask`); other/unverified host: exit 2 | host decides on Claude; fail closed elsewhere |
110
+ ## Workflow lifecycle gates
131
111
 
132
- `rm -rf` and `Remove-Item -Recurse -Force` are exempt only when every parsed target is inside the OS temp directory, the current session scratch directory, or an explicitly supplied Harness scratch directory. An uncertain target is gated conservatively.
112
+ The [workflow runtime contract](workflow-runtime.md) defines the executable boundary:
133
113
 
134
- ```mermaid
135
- flowchart TD
136
- P[PreToolUse exact payload] --> C{Matches action-gate rule?}
137
- C -- No --> A[Allow without gate record]
138
- C -- Yes --> X{Scratch-only destructive delete?}
139
- X -- Yes --> A
140
- X -- No --> H{Host has a native permission flow?}
141
- H -- Claude Code --> Y{always-ask policy?}
142
- Y -- No --> D[No decision: the permission mode decides<br/>record deferred-to-host + payload hash]
143
- Y -- Yes --> Q[Emit permissionDecision: ask<br/>record pending-approval + payload hash]
144
- H -- No / unknown --> B[Exit 2 block<br/>record rejected]
145
- D --> U{Did the exact tool payload execute?}
146
- Q --> U
147
- U -- PostToolUse --> E[record executed]
148
- U -- PostToolUseFailure --> F[record executed + failure]
149
- U -- no execution by Stop --> R[record rejected]
150
- ```
114
+ - `workflow-gate.js` checks shell/direct mutation, correlated Fable entry, and major-workflow Git isolation.
115
+ - `workflow-stop-gate.js` checks manifest stage membership and observed verification evidence before `satisfied`.
116
+ - `workflow-disposition.js` starts/replans the run, records a scoped stage escape, or reports `blocked`.
151
117
 
152
- On Claude Code the gate returns no decision by default. The [hooks reference](https://code.claude.com/docs/en/hooks) says a hook's `ask` "also forces a permission prompt in auto mode: the classifier can still deny the tool call, but it can't approve the call silently". A forced `ask` would therefore override the permission mode the user picked (#107).
118
+ A follow-up prompt cannot erase unresolved obligations. Start from the router's displayed session stage-specification path; source mutation waits for entry and isolation. Replan is bounded. Escape requires `workflow-uncovered-scope` or `host-capability-unavailable`, a stage id, uncovered scope, and evidence. It never waives isolation or independent verification.
153
119
 
154
- With no decision, the normal permission flow applies:
120
+ Direct/iterative verification milestones are checked, while semantic check quality and iteration budgeting remain executor obligations. Shell inspection does not contain arbitrary script side effects. Package/mechanism tests do not prove host loading or behavioral compliance; #82 owns retained live evidence.
155
121
 
156
- - Manual and `acceptEdits` prompt unless a rule or the mode already allows the command.
157
- - Auto mode lets the classifier decide.
158
- - `dontAsk` denies anything that is not pre-approved.
159
- - Deny rules apply in every mode.
122
+ ## Cognitive OS relationship
160
123
 
161
- Set `HARNESS_ACTION_GATE_POLICY=always-ask` to have Harness force its own prompt instead. Either way the gate classifies and audits every matched payload.
124
+ `install-cognitive-os` remains the explanatory/manual entry point for Discover → Think → Try → Summarize → Record. It is a reasoning policy, not a peer skill that must be selected before domain work. The selected workflow contract governs lifecycle obligations; the model retains freedom inside it.
162
125
 
163
- The deterministic suite verifies two things: the deferred result for every known `permission_mode` value, and the `ask` JSON under `always-ask`. That is **mechanism evidence only** until preserved live evidence exists.
126
+ ## Enforcement strength
164
127
 
165
- ## Cognitive OS relationship
128
+ A contract can be semantically mandatory even when a host cannot mechanically enforce every transition. Keep those claims separate:
166
129
 
167
- `install-cognitive-os` remains the canonical explanatory/manual entry point for Discover → Think → Try → Summarize → Record. It is **not** required to win peer-skill selection before domain work begins. The runtime kernel establishes the smaller invariant contract independently; domain skills provide their own tactics inside that contract.
130
+ - **contract:** what the agent is required to do;
131
+ - **mechanism:** which transitions a packaged hook/plugin can block or observe;
132
+ - **live evidence:** whether a real host actually loaded/fired that mechanism.
168
133
 
169
- ## Enforcement strength
134
+ Instruction-only integrations receive the same workflow contract as guidance, but must not be labeled hard-enforced. Kernel emission alone does not prove model compliance. #82 owns host-specific retained evidence.
170
135
 
171
- A lifecycle hook can mechanically inject/guard supported invariants. Instruction-only integrations can only advise the model. Do not label advisory behavior as hard enforcement, and do not infer cross-host parity from shared skill text alone.
136
+ Do not infer cross-host parity from shared runtime code or passing package tests.
@@ -0,0 +1,109 @@
1
+ # Selected workflow runtime
2
+
3
+ The selected applicable topology is mandatory. This contract governs lifecycle
4
+ obligations; agents still choose tools, reasoning, and implementation inside it.
5
+ Skill suggestions require individual applicability evaluation, not one universal
6
+ skill sequence. Git mutation isolation and durable multi-agent workspace state
7
+ are separate concerns.
8
+
9
+ ## State and entry
10
+
11
+ `UserPromptSubmit` records `workflow-run.json` in the bound workspace's global
12
+ Harness session state. It includes a unique `workflowId`, complete plan, prompt
13
+ hash (no prompt text), revision count, and scoped exceptions. Unresolved work
14
+ survives follow-up/status prompts; a weaker route cannot erase it. A stronger
15
+ route blocks mutation until an explicit replan. A new task after `satisfied`
16
+ gets a new identity. Invalid recorded state fails closed with a diagnostic.
17
+
18
+ ```text
19
+ pending -> running -> satisfied
20
+ | (only after required evidence)
21
+ -> blocked -> start/replan (within budget)
22
+ ```
23
+
24
+ `blocked` is a reportable incomplete outcome, never successful completion.
25
+ `deferred` means no topology has been selected. Legacy `active`/`escaped` records
26
+ remain subject to isolation and cannot supply a correlated run implicitly.
27
+
28
+ For Fable, write a stage array in the exact `workflow-stages.json` path displayed
29
+ by the router. This one file is allowed as runtime bootstrap data before entry;
30
+ the exception does not authorize changing workflow state or source artifacts.
31
+ Use the [stage schema](../fable-mode/CONTRACT-FORMAT.md); each stage needs an
32
+ objective `checkCommand` and `passCondition`. If the plan requires independent
33
+ verification, declare a read-only `fable-verifier` stage depending on every
34
+ other stage. Then run the displayed controller with the host session id:
35
+
36
+ ```text
37
+ node "<hooks>/workflow-disposition.js" start --session-id "<session>"
38
+ ```
39
+
40
+ The controller prepares the existing Fable consumer's run at the **bound** state
41
+ root, even when tool execution has moved to a linked worktree. The run records
42
+ both `workflowId` and `sessionId`; matching only strategy or creation time is
43
+ insufficient. `start` creates contracts, not agents. Fable retains ownership of
44
+ worker dispatch, dependency/write-set scheduling, and synthesis.
45
+
46
+ ## Isolation boundary
47
+
48
+ Before Tier 3 or Fable source/artifact mutation, the gate verifies a registered
49
+ linked Git worktree with the same common Git directory as the bound repository.
50
+ It checks the tool's execution directory and actual Edit/Write/apply_patch paths,
51
+ including move destinations, relative traversal, and symlink/junction resolution.
52
+ Unknown direct targets, Git metadata, and nested repositories are rejected.
53
+ Read-only discovery and a literal `git worktree add` transition remain available
54
+ before entry. Prefer an already-ignored path or sibling path for setup; never
55
+ edit the primary tree's ignore file just to establish mandatory isolation.
56
+
57
+ Shell recognition is conservative: redirects, substitutions, chained commands,
58
+ and side-effect options are not accepted as read-only. Mutation-capable shell
59
+ execution requires an isolated working-directory field, with explicit outside
60
+ paths and directory changes rejected. **This is not a filesystem sandbox**:
61
+ arbitrary scripts, aliases/configuration, indirect variable paths, and races can
62
+ have effects a hook cannot infer. OS/host sandboxing is needed to contain them.
63
+ Agent-writable state is also not tamper-proof. These mechanisms prevent tested
64
+ bypasses; they do not establish durable containment against a malicious agent.
65
+
66
+ ## Escape, replan, and completion
67
+
68
+ Escape names one stage in the correlated run and records the uncovered scope,
69
+ evidence, and `workflow-uncovered-scope` or `host-capability-unavailable` reason:
70
+
71
+ ```text
72
+ node "<hooks>/workflow-disposition.js" escape --session-id "<session>" --stage-id "<stage>" --reason-code workflow-uncovered-scope --scope "<uncovered scope>" --evidence "<evidence>"
73
+ node "<hooks>/workflow-disposition.js" block --session-id "<session>" --evidence "<blocker>"
74
+ ```
75
+
76
+ An escape never resolves the whole run, waives isolation, or removes independent
77
+ verification. Covered stages remain mandatory. Unavailable required verification
78
+ means blocked. The controller permits the initial run plus the plan's
79
+ `maxRevisionRounds` replans; exhaustion stays blocked. Previous run evidence is
80
+ retained, but cannot satisfy a replacement run.
81
+
82
+ `contract-test.js` records exact check commands, observed worker/session identity,
83
+ numeric exit code, and run/plan/stage evidence. A failed check can recover on a
84
+ later observed pass. A dependent check cannot pass before its prerequisites.
85
+ Stop enumerates the manifest's expected stages, so deleting a contract does not
86
+ make the run complete. A `pass` label without matching exit-zero evidence fails.
87
+ The independent verifier must have a distinct observed identity and evidence
88
+ after the latest mutation/check. This proves attribution, not reasoning quality.
89
+
90
+ Unresolved Stop exits 2. If the host marks a Stop retry, the contract becomes
91
+ `blocked` with diagnostics instead of looping indefinitely or recording success.
92
+ Direct/iterative routes use observed edit/verification milestones; iteration
93
+ counting and semantic check quality remain executor obligations, not proven by
94
+ these gates. Broad verification-command recognition is a heuristic.
95
+
96
+ ## Host evidence
97
+
98
+ Claude's manifest carries the shell/direct-mutation and Stop hooks. The local
99
+ OpenAI package carries the same runtime for its declared `Bash|apply_patch`
100
+ surface. Package tests exercise both layouts. Missing worker/exit metadata keeps
101
+ Fable completion unresolved; it must be reported as degraded/blocked, not passed.
102
+ Manual CLI routing without a session cannot persist lifecycle state.
103
+
104
+ OpenCode and instruction-only/public Skills-only surfaces do not gain these
105
+ runtime gates from this change. An absent/disabled hook or deleted state cannot
106
+ be detected as an active contract by that same hook. No host compatibility status
107
+ is upgraded: see [platform capabilities](platform-capabilities.md). Live hook
108
+ loading, enforced host transitions, and behavioral improvement need separately
109
+ retained host traces and paired evaluations.
@@ -59,7 +59,9 @@ Rules:
59
59
 
60
60
  ## Workflow-plan consumer
61
61
 
62
- Before dispatch, write the router contract and stage array to files and run:
62
+ For a session with an active mandatory workflow, write the stage array to the router-displayed `workflow-stages.json` path and invoke its `workflow-disposition.js start --session-id <id>` command. This binds the run to the active `workflowId` and bound workspace even after entering a linked worktree. Every required stage needs an objective check, and an independent plan needs a read-only `fable-verifier` stage depending on all other stages. Stage results need observed worker identities and numeric exit codes; missing metadata is blocked/degraded, not success.
63
+
64
+ For standalone use without an active session contract, write the router contract and stage array to files and run:
63
65
 
64
66
  ```bash
65
67
  node fable-mode/scripts/workflow-plan-consumer.js \
@@ -4,7 +4,7 @@ description: "Stage large, multi-source or multi-session tasks through a written
4
4
  license: Apache-2.0
5
5
  metadata:
6
6
  author: Miya Daniel
7
- version: 0.4.0
7
+ version: 0.8.1
8
8
  ---
9
9
 
10
10
  # Fable Mode (v3)