cool-workflow 0.1.78

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 (193) hide show
  1. package/.claude-plugin/plugin.json +20 -0
  2. package/.codex-plugin/mcp.json +10 -0
  3. package/.codex-plugin/plugin.json +38 -0
  4. package/.mcp.json +10 -0
  5. package/LICENSE +24 -0
  6. package/README.md +638 -0
  7. package/apps/architecture-review/app.json +51 -0
  8. package/apps/architecture-review/workflow.js +116 -0
  9. package/apps/end-to-end-golden-path/app.json +30 -0
  10. package/apps/end-to-end-golden-path/workflow.js +33 -0
  11. package/apps/pr-review-fix-ci/app.json +59 -0
  12. package/apps/pr-review-fix-ci/workflow.js +90 -0
  13. package/apps/release-cut/app.json +54 -0
  14. package/apps/release-cut/workflow.js +82 -0
  15. package/apps/research-synthesis/app.json +50 -0
  16. package/apps/research-synthesis/workflow.js +76 -0
  17. package/apps/workflow-app-framework-demo/app.json +29 -0
  18. package/apps/workflow-app-framework-demo/workflow.js +44 -0
  19. package/dist/agent-config.js +223 -0
  20. package/dist/candidate-scoring.js +715 -0
  21. package/dist/capability-core.js +630 -0
  22. package/dist/capability-dispatcher.js +86 -0
  23. package/dist/capability-registry.js +523 -0
  24. package/dist/cli.js +1276 -0
  25. package/dist/collaboration.js +727 -0
  26. package/dist/commit.js +570 -0
  27. package/dist/contract-migration.js +234 -0
  28. package/dist/coordinator.js +1163 -0
  29. package/dist/daemon.js +44 -0
  30. package/dist/dispatch.js +201 -0
  31. package/dist/drive.js +503 -0
  32. package/dist/error-feedback.js +415 -0
  33. package/dist/evidence-grounding.js +179 -0
  34. package/dist/evidence-reasoning.js +733 -0
  35. package/dist/execution-backend.js +1279 -0
  36. package/dist/harness.js +61 -0
  37. package/dist/mcp-server.js +1615 -0
  38. package/dist/multi-agent-eval.js +857 -0
  39. package/dist/multi-agent-host.js +764 -0
  40. package/dist/multi-agent-operator-ux.js +537 -0
  41. package/dist/multi-agent-trust.js +366 -0
  42. package/dist/multi-agent.js +1173 -0
  43. package/dist/node-snapshot.js +270 -0
  44. package/dist/observability.js +922 -0
  45. package/dist/operator-ux.js +971 -0
  46. package/dist/orchestrator/audit-operations.js +182 -0
  47. package/dist/orchestrator/candidate-operations.js +117 -0
  48. package/dist/orchestrator/cli-options.js +288 -0
  49. package/dist/orchestrator/collaboration-operations.js +86 -0
  50. package/dist/orchestrator/feedback-operations.js +81 -0
  51. package/dist/orchestrator/host-operations.js +78 -0
  52. package/dist/orchestrator/lifecycle-operations.js +462 -0
  53. package/dist/orchestrator/migration-operations.js +44 -0
  54. package/dist/orchestrator/multi-agent-operations.js +362 -0
  55. package/dist/orchestrator/report.js +369 -0
  56. package/dist/orchestrator/topology-operations.js +84 -0
  57. package/dist/orchestrator.js +874 -0
  58. package/dist/pipeline-contract.js +92 -0
  59. package/dist/pipeline-runner.js +285 -0
  60. package/dist/reclamation.js +882 -0
  61. package/dist/result-normalize.js +194 -0
  62. package/dist/run-export.js +64 -0
  63. package/dist/run-registry.js +1347 -0
  64. package/dist/run-state-schema.js +67 -0
  65. package/dist/sandbox-profile.js +471 -0
  66. package/dist/scheduler.js +266 -0
  67. package/dist/scheduling.js +184 -0
  68. package/dist/schema-validate.js +98 -0
  69. package/dist/state-explosion.js +1213 -0
  70. package/dist/state-migrations.js +463 -0
  71. package/dist/state-node.js +301 -0
  72. package/dist/state.js +308 -0
  73. package/dist/telemetry-attestation.js +156 -0
  74. package/dist/telemetry-ledger.js +145 -0
  75. package/dist/topology.js +527 -0
  76. package/dist/triggers.js +159 -0
  77. package/dist/trust-audit.js +475 -0
  78. package/dist/types/blackboard.js +2 -0
  79. package/dist/types/boundary.js +29 -0
  80. package/dist/types/candidate.js +2 -0
  81. package/dist/types/collaboration.js +2 -0
  82. package/dist/types/core.js +2 -0
  83. package/dist/types/drive.js +10 -0
  84. package/dist/types/error-feedback.js +2 -0
  85. package/dist/types/evidence-reasoning.js +2 -0
  86. package/dist/types/execution-backend.js +2 -0
  87. package/dist/types/multi-agent.js +2 -0
  88. package/dist/types/observability.js +2 -0
  89. package/dist/types/pipeline.js +2 -0
  90. package/dist/types/reclamation.js +8 -0
  91. package/dist/types/result.js +2 -0
  92. package/dist/types/run-registry.js +2 -0
  93. package/dist/types/run.js +2 -0
  94. package/dist/types/sandbox.js +2 -0
  95. package/dist/types/schedule.js +2 -0
  96. package/dist/types/state-node.js +2 -0
  97. package/dist/types/topology.js +2 -0
  98. package/dist/types/trust.js +2 -0
  99. package/dist/types/workbench.js +2 -0
  100. package/dist/types/worker.js +2 -0
  101. package/dist/types/workflow-app.js +2 -0
  102. package/dist/types.js +43 -0
  103. package/dist/verifier-registry.js +46 -0
  104. package/dist/verifier.js +78 -0
  105. package/dist/version.js +8 -0
  106. package/dist/workbench-host.js +172 -0
  107. package/dist/workbench.js +190 -0
  108. package/dist/worker-isolation.js +1028 -0
  109. package/dist/workflow-api.js +98 -0
  110. package/dist/workflow-app-framework.js +626 -0
  111. package/docs/agent-delegation-drive.7.md +190 -0
  112. package/docs/agent-framework.md +176 -0
  113. package/docs/candidate-scoring.7.md +106 -0
  114. package/docs/canonical-workflow-apps.7.md +137 -0
  115. package/docs/capability-topology-registry.7.md +168 -0
  116. package/docs/cli-mcp-parity.7.md +373 -0
  117. package/docs/contract-migration-tooling.7.md +123 -0
  118. package/docs/control-plane-scheduling.7.md +110 -0
  119. package/docs/coordinator-blackboard.7.md +183 -0
  120. package/docs/dogfood/architecture-review-cool-workflow.md +16 -0
  121. package/docs/dogfood-one-real-repo.7.md +168 -0
  122. package/docs/durable-state-and-locking.7.md +107 -0
  123. package/docs/end-to-end-golden-path.7.md +117 -0
  124. package/docs/error-feedback.7.md +153 -0
  125. package/docs/evidence-adoption-reasoning-chain.7.md +270 -0
  126. package/docs/execution-backends.7.md +300 -0
  127. package/docs/getting-started.md +99 -0
  128. package/docs/index.md +41 -0
  129. package/docs/mcp-app-surface.7.md +235 -0
  130. package/docs/multi-agent-cli-mcp-surface.7.md +265 -0
  131. package/docs/multi-agent-eval-replay-harness.7.md +302 -0
  132. package/docs/multi-agent-operator-ux.7.md +314 -0
  133. package/docs/multi-agent-runtime-core.7.md +231 -0
  134. package/docs/multi-agent-topologies.7.md +103 -0
  135. package/docs/multi-agent-trust-policy-audit.7.md +154 -0
  136. package/docs/node-snapshot-diff-replay.7.md +135 -0
  137. package/docs/observability-cost-accounting.7.md +194 -0
  138. package/docs/operator-ux.7.md +180 -0
  139. package/docs/pipeline-runner.7.md +136 -0
  140. package/docs/project-index.md +261 -0
  141. package/docs/real-execution-backends.7.md +142 -0
  142. package/docs/release-and-migration.7.md +280 -0
  143. package/docs/release-tooling.7.md +159 -0
  144. package/docs/routines.md +48 -0
  145. package/docs/run-registry-control-plane.7.md +312 -0
  146. package/docs/run-retention-reclamation.7.md +191 -0
  147. package/docs/sandbox-profiles.7.md +137 -0
  148. package/docs/scheduled-tasks.md +80 -0
  149. package/docs/security-trust-hardening.7.md +117 -0
  150. package/docs/state-explosion-management.7.md +264 -0
  151. package/docs/state-node.7.md +96 -0
  152. package/docs/team-collaboration.7.md +207 -0
  153. package/docs/unix-principles.md +192 -0
  154. package/docs/verifier-gated-commit.7.md +140 -0
  155. package/docs/web-desktop-workbench.7.md +215 -0
  156. package/docs/worker-isolation.7.md +167 -0
  157. package/docs/workflow-app-framework.7.md +274 -0
  158. package/manifest/README.md +43 -0
  159. package/manifest/plugin.manifest.json +316 -0
  160. package/manifest/pricing.policy.json +14 -0
  161. package/package.json +79 -0
  162. package/scripts/agents/claude-p-agent.js +104 -0
  163. package/scripts/agents/claude-p-agent.sh +9 -0
  164. package/scripts/agents/cw-attest-keygen.js +55 -0
  165. package/scripts/agents/cw-attest-wrap.js +143 -0
  166. package/scripts/block-unapproved-tag.sh +39 -0
  167. package/scripts/bump-version.js +249 -0
  168. package/scripts/canonical-apps.js +171 -0
  169. package/scripts/cw.js +4 -0
  170. package/scripts/dist-drift-check.js +79 -0
  171. package/scripts/dogfood-architecture-review.js +237 -0
  172. package/scripts/dogfood-release.js +624 -0
  173. package/scripts/forward-ref-docs.js +73 -0
  174. package/scripts/gen-manifests.js +232 -0
  175. package/scripts/golden-path.js +300 -0
  176. package/scripts/mcp-server.js +4 -0
  177. package/scripts/new-feature.js +121 -0
  178. package/scripts/parity-check.js +213 -0
  179. package/scripts/release-check.js +118 -0
  180. package/scripts/release-flow.js +272 -0
  181. package/scripts/release-gate.sh +85 -0
  182. package/scripts/sync-project-index.js +387 -0
  183. package/scripts/validate-run-state-schema.js +126 -0
  184. package/scripts/verify-container-selfref.js +64 -0
  185. package/scripts/version-sync-check.js +237 -0
  186. package/skills/cool-workflow/SKILL.md +162 -0
  187. package/skills/cool-workflow/references/commands.md +282 -0
  188. package/tsconfig.json +16 -0
  189. package/ui/workbench/app.css +76 -0
  190. package/ui/workbench/app.js +159 -0
  191. package/ui/workbench/index.html +32 -0
  192. package/workflows/architecture-review.workflow.js +84 -0
  193. package/workflows/research-synthesis.workflow.js +47 -0
@@ -0,0 +1,207 @@
1
+ # Team Collaboration
2
+
3
+ CW v0.1.32 adds Team Collaboration: a host-attested actor, append-only approvals,
4
+ rejections, comments, and handoffs, and a review gate that STACKS ON the verifier
5
+ gate. Before v0.1.32 there was no review/approval/comment/handoff/identity concept
6
+ anywhere; the foundations already existed — trust-audit recorded every decision
7
+ with an `actor`, candidate selection carried `selectedBy`, role policies existed,
8
+ and commits were verifier-gated. This release adds the human-decision layer ON TOP
9
+ of those mechanisms, without changing them and without taking ownership of source
10
+ truth.
11
+
12
+ The design follows the same base-system discipline as
13
+ [Security / Trust Hardening](security-trust-hardening.7.md) and the
14
+ [Verifier-Gated Commit](verifier-gated-commit.7.md):
15
+
16
+ - the per-run `.cw/runs/<id>/state.json` is the SINGLE source of truth
17
+ - collaboration records are an APPEND-ONLY log, never mutated in place
18
+ - identity is ATTESTED provenance, never authenticated; CW is not an auth server
19
+ - the review gate is POLICY layered on the verifier MECHANISM — never a bypass
20
+ - fail closed: missing authority, ambiguous role, or self-approval is a denial
21
+ - policy (required approvals, authorized roles, self-approval) is data, not kernel
22
+ - backward compatible; every collaboration field is additive and optional
23
+
24
+ ## Identity is attested, not authenticated
25
+
26
+ An `Actor` is host-attested provenance, not an authenticated principal. CW records
27
+ WHO acted; it does not verify a password, a token, or a signature — that is a host
28
+ trust-boundary concern. `normalizeActor` maps an actor input to one of three
29
+ provenances: `host-attested` (the host vouched, `--attested`), `operator-recorded`
30
+ (supplied unverified), or `unattributed` (no identity supplied). An absent identity
31
+ becomes the explicit `unattributed` actor — `{ kind: "unattributed", id:
32
+ "unattributed", attested: false }` — never a fabricated one. Spoofing is recorded
33
+ honestly as whatever provenance the host attested, not hidden. This extends the
34
+ existing trust-audit `actor` string and the v0.1.29/v0.1.31 attestation pattern.
35
+
36
+ ## Approvals and rejections are append-only and provenance-linked
37
+
38
+ `approve` and `reject` append an `ApprovalRecord` to `run.collaboration.approvals`.
39
+ Each record carries the actor, the decision, the durable target it attaches to, an
40
+ optional rationale, the role the actor claims, and `auditEventIds` linking it to a
41
+ `collaboration.approval`/`collaboration.rejection` event in the trust-audit log —
42
+ exactly as `candidate.selection` records both a `CandidateSelection` and an audit
43
+ event. The approved artifact (candidate/commit/selection) is NEVER edited in place:
44
+ "who approved what" is a provenance link, not a field overwrite. A correction is a
45
+ NEW record carrying `supersedes` (git-style); the superseded record stays in the
46
+ log, no longer counts, and the original is unchanged.
47
+
48
+ A target is one of `run | task | candidate | selection | commit | node`. "Who
49
+ approved which candidate/commit" is answered by filtering the append-only records
50
+ by target.
51
+
52
+ ## The review gate stacks on the verifier gate
53
+
54
+ The verifier-gated commit is the MECHANISM (see
55
+ [Verifier-Gated Commit](verifier-gated-commit.7.md)): `resolveCommitGate` accepts a
56
+ commit only when a verified verifier node, a scored+verified candidate, and a
57
+ complete acceptance rationale are present. A review gate is POLICY layered on top.
58
+ `reviewGateErrors` runs INSIDE `resolveCommitGate`, AFTER the verifier checks, and
59
+ can only ADD errors — required approvals from authorized roles — never remove the
60
+ verifier's. The same call guards candidate selection in `selectCandidate`.
61
+
62
+ Data flow for a gated commit:
63
+
64
+ 1. `resolveCommitGate` resolves the candidate/selection and runs every verifier
65
+ check; if any fail the commit is blocked as before.
66
+ 2. If a `ReviewGatePolicy` applies to `commit` (or `selection`), `reviewGateErrors`
67
+ derives the review state over the approvals targeting the commit AND its
68
+ underlying selection/candidate (you approve the candidate; the commit honors it).
69
+ 3. If the review state is not `approved`, a single `review-gate-missing-approvals`
70
+ StateNodeError is appended, listing exactly which approvals are missing.
71
+ `commitState` throws `CommitGateError`, recorded as append-only feedback.
72
+ 4. Only when BOTH gates pass is the commit written — and it is stamped with a
73
+ `CommitReviewProvenance` recording WHO approved the very artifact that shipped.
74
+
75
+ Because the review errors are appended after the verifier errors and never replace
76
+ them, an approval can never turn an unverified result into a committed one: an
77
+ approved-but-unverified candidate is still blocked by the verifier gate.
78
+
79
+ ## Fail closed on authority and quorum
80
+
81
+ `deriveReviewState` is a pure, deterministic projection of the append-only records
82
+ plus a policy. It counts ONLY approvals that are, all at once: from an attested
83
+ identity (when `requireAttestedActor`), from a role in `authorizedRoles` (or `*`),
84
+ and not a self-approval (when `allowSelfApproval` is false; "self" is the
85
+ candidate's producing worker and its selector). Distinct counted approvers must
86
+ reach `requiredApprovals`. Anything short is not auto-passed; the status is:
87
+
88
+ - `approved` — requirement met (or the target is not gated)
89
+ - `pending` — gated, no blocking reject, fewer than required counted approvals
90
+ - `blocked` — recorded approvals exist but none count (authority/self)
91
+ - `unattributed` — the only recorded approvals are from unattributed actors
92
+ - `rejected` — an authorized, attested reject is a blocking veto
93
+
94
+ Every disqualified approval is surfaced with its reason (`unattributed`,
95
+ `unauthorized-role`, `self-approval`, `superseded`), so a reader can audit why an
96
+ approval did not count. A target requiring N approvals with fewer recorded is
97
+ BLOCKED, and the block records exactly what is missing.
98
+
99
+ ## Comments and handoffs are state, not chat
100
+
101
+ A `comment` appends a `CommentRecord` to a durable target with an actor, a thread
102
+ id, and an audit link; threads are ordered by `createdAt` and never edited in
103
+ place. A `handoff` appends a `HandoffRecord` — an explicit ownership transfer with
104
+ a from-actor, a to-actor, and a reason — and the current owner of a run/task is
105
+ DERIVED from the latest handoff, never an overwritten field. There is no side
106
+ channel: the collaboration IS the durable, inspectable state, consistent with CW's
107
+ no-hidden-dashboard-database rule.
108
+
109
+ ## Policy as data, kept out of the kernel
110
+
111
+ `review policy <run-id>` writes a `ReviewGatePolicy` to `run.collaboration.policy`:
112
+ `requiredApprovals` (0 = no gate), `authorizedRoles` (`*` = any), `allowSelfApproval`,
113
+ `requireAttestedActor`, and `appliesTo` (target kinds). The default — absent policy
114
+ or `requiredApprovals: 0` — requires no approvals, so pre-v0.1.32 runs and any run
115
+ without a policy behave exactly as before. The policy is data; the kernel only
116
+ enforces the mechanism.
117
+
118
+ ## One source, every surface
119
+
120
+ Each collaboration verb is declared once in `src/capability-registry.ts`, so
121
+ `cw <cmd> --json` is schema-identical to `cw_<cmd>` and passes the parity gate. The
122
+ read-only `review status` and `comment list` are byte-for-byte identical across CLI
123
+ and MCP (the payload-identity probe strips only ISO timestamps; the only
124
+ now-derived field in a review report is `generatedAt`). The v0.1.30 Workbench
125
+ renders the review timeline and per-target approval state read-only as a sixth
126
+ panel, embedding the `review status` payload verbatim. The v0.1.31 metrics report
127
+ adds derived approval-rate, time-to-approval, handoff-count, and reviewer-count,
128
+ all from recorded timestamps — deterministic over a fixed snapshot.
129
+
130
+ ## Commands
131
+
132
+ ```
133
+ cw review policy <run-id> --requiredApprovals N --authorizedRoles a,b --appliesTo commit,selection [--allowSelfApproval] [--requireAttestedActor]
134
+ cw approve <kind> <run-id> <target-id> --actor <id> --role <role> --attested [--rationale <text>]
135
+ cw reject <kind> <run-id> <target-id> --actor <id> --role <role> --attested [--rationale <text>]
136
+ cw comment add <kind> <run-id> <target-id> --actor <id> --body <text>
137
+ cw comment list <run-id> [--json]
138
+ cw handoff <kind> <run-id> [target-id] --from <id> --to <id> --reason <text>
139
+ cw review status <run-id> [--json]
140
+ ```
141
+
142
+ `<kind>` is one of `run | task | candidate | selection | commit | node`. Approve a
143
+ candidate (or selection), then commit `--candidate`/`--selection`; the commit gate
144
+ honors the candidate's approvals and records who approved the shipped commit.
145
+
146
+ CW is the base system. Workflow apps are userland. Collaboration adds the human
147
+ decision as durable, attested, append-only state — never a hidden dashboard, never
148
+ a bypass of the verifier gate.
149
+
150
+ ## Release Tooling (v0.1.33)
151
+
152
+ the per-tag mechanical surfaces (version bump across 17 surfaces, feature scaffold, and the forward-reference docs) become deterministic scripts, with a de-duplicated release gate. See release-tooling(7).
153
+
154
+ ## Real Execution Backend Integrations (v0.1.34)
155
+
156
+ container/remote/ci backends really execute (docker/podman run, remote/CI POST-and-poll) under the sandbox contract, with byte-stable evidence vs node and fail-closed refusal when a runtime/endpoint is unavailable. See real-execution-backends(7).
157
+
158
+ ## Node Snapshot / Diff / Replay (v0.1.35)
159
+
160
+ per-node snapshot, structural diff, and isolated deterministic replay over StateNode, reusing the v0.1.23 eval harness; fail-closed on source drift (valid|stale|absent). See node-snapshot-diff-replay(7).
161
+
162
+ ## Contract Migration Tooling (v0.1.36)
163
+
164
+ first-class declared migration registry (run-state + workflow-app) with per-edge compatibility proofs, fail-closed reachability, and a round-trip/non-destruction prover. See contract-migration-tooling(7).
165
+
166
+ ## Control-Plane Scheduling (v0.1.37)
167
+
168
+ priority + concurrency limits + lease lifecycle + retry/backoff + fail-closed park over the v0.1.28 Run Registry queue; policy-as-data, deterministic. See control-plane-scheduling(7).
169
+
170
+ ## Agent Delegation Drive (v0.1.38)
171
+
172
+ spawn an external agent process per worker, capture result.md + attestation, auto-drive plan->dispatch->fulfill->accept->commit
173
+
174
+ ## Run Retention & Provable Reclamation (v0.1.39)
175
+
176
+ tiered, append-only, cryptographically-verifiable run reclamation: seal the audit skeleton, free the reconstructable bulk, prove it
177
+
178
+ ## Durable State & Locking (v0.1.40)
179
+
180
+ atomic temp->rename writes + fsync-durability for authoritative stores; portable stale-stealing file lock serializing the cross-process read-modify-write stores
181
+
182
+ ## Self-Audit Hardening & Pure-Router Decomposition (v0.1.41)
183
+
184
+ evidence grounding + durable audit append + symlink-hardened containment + deterministic worker ids + recursive redaction; BackendRegistry self-describing drivers (no per-id switches); orchestrator god-object decomposed into per-domain operation modules (pure loadRun->delegate router)
185
+
186
+ ## Robust Result Ingest (v0.1.42)
187
+
188
+ capture findings/evidence from any reasonable agent shape (alt keys + prose), CW derives grounded evidence itself, warn on empty capture — closes the v0.1.41 live-drive 'accepted with 0 captured' failure
189
+
190
+ ## No-False-Green Gate & Launch Prep (v0.1.43)
191
+
192
+ Hard gate blocking empty-capture verifier-gated commits, plus quickstart and launch-prep docs.
193
+
194
+ ## Release-Gate Determinism & Agents Vendor (v0.1.44)
195
+
196
+ Release-readiness checks now validate the committed blob (`git show HEAD:<path>`) instead of the mutable working tree — eliminating false-red/false-green from concurrent working-tree writes (iCloud/Spotlight/editor). Adds the `agents` vendor manifest target: a generated `.agents/plugins/cool-workflow/` adapter giving any non-Claude AI agent one common interface to CW.
197
+
198
+ ## P1-P2 Fixes & CI Content Surfaces (v0.1.49)
199
+
200
+ Migration DAG with reversible edges (v0.1.45), capability auto-discovery (v0.1.46), vendor-adapter registry (v0.1.47), state auto-compaction and P2 fixes (v0.1.48), plus CI content-surface determinism hardening (v0.1.49).
201
+ 0.1.51
202
+
203
+ 0.1.76
204
+
205
+ 0.1.77
206
+
207
+ 0.1.78
@@ -0,0 +1,192 @@
1
+ # Unix-Inspired Workflow Principles
2
+
3
+ CW borrows a small set of durable systems ideas and applies them to agent
4
+ workflow engineering. These are design principles, not platform claims.
5
+
6
+ ## 1. Everything Is State
7
+
8
+ Every meaningful workflow event should be represented as inspectable state.
9
+
10
+ CW already stores:
11
+
12
+ - workflow runs in `.cw/runs/<run-id>/state.json`
13
+ - task prompts in `.cw/runs/<run-id>/tasks/`
14
+ - dispatch manifests in `.cw/runs/<run-id>/dispatches/`
15
+ - result envelopes in `.cw/runs/<run-id>/results/`
16
+ - state snapshots in `.cw/runs/<run-id>/commits/`
17
+ - schedules in `.cw/schedules/tasks.json`
18
+ - routine trigger events in `.cw/routines/`
19
+ - candidate scoring records in `.cw/runs/<run-id>/candidates/`
20
+ - commit gate failures in `.cw/runs/<run-id>/feedback/`
21
+ - sandbox profile selections in worker, dispatch, feedback, and report state
22
+ - workflow app identity and version in `.cw/runs/<run-id>/state.json`
23
+ - canonical app matrix run state in temporary `.cw/runs/<run-id>/` workspaces
24
+ - golden path proof artifacts in temporary `.cw/runs/<run-id>/` workspaces
25
+ - operator summaries derived from state without mutating run files
26
+ - MCP app-surface smoke runs driven through stdio JSON-RPC
27
+
28
+ The practical rule is:
29
+
30
+ ```text
31
+ prompt, task, dispatch, result, error, verifier decision, schedule, trigger
32
+ = state that can be inspected, replayed, snapshotted, or compared
33
+ ```
34
+
35
+ This keeps the runtime deterministic and keeps agent work auditable.
36
+
37
+ ## 2. Small Kernel, Composable Userland
38
+
39
+ CW should keep the kernel small. The kernel owns state transitions and stable
40
+ contracts; workflow apps own domain behavior.
41
+
42
+ Core system calls:
43
+
44
+ ```text
45
+ plan()
46
+ dispatch()
47
+ recordResult()
48
+ verify()
49
+ commit()
50
+ report()
51
+ sandbox()
52
+ schedule()
53
+ trigger()
54
+ ```
55
+
56
+ The kernel should avoid hard-coded business logic. New behavior should usually
57
+ enter as:
58
+
59
+ - a workflow app
60
+ - a workflow app manifest under `apps/<app-id>/app.json`
61
+ - a verifier
62
+ - a scheduler policy
63
+ - a routine trigger
64
+ - an external worker
65
+
66
+ Workflow App framework v0.1.9 makes this split concrete. The runner is the base
67
+ system. Apps are userland: versioned, validated, inspectable definitions that
68
+ can be listed, shown, validated, initialized, packaged, planned, and reported
69
+ without depending on hidden runner internals.
70
+
71
+ The v0.1.12 Operator UX layer is userland over state. It renders `status`,
72
+ `graph`, `report --show`, and resource summaries without owning core
73
+ transitions.
74
+
75
+ The v0.1.13 MCP app surface is the same discipline applied to agent hosts: a
76
+ small JSON tool bridge over the base runtime, old names preserved, read-only
77
+ inspection separated from mutation, and every mutation persisted to the run.
78
+
79
+ The v0.1.13 canonical apps are maintained userland:
80
+
81
+ ```text
82
+ architecture-review
83
+ pr-review-fix-ci
84
+ release-cut
85
+ research-synthesis
86
+ ```
87
+
88
+ They keep domain prompts, inputs, evidence gates, and sandbox hints in app
89
+ directories instead of in runner internals.
90
+
91
+ The v0.1.10 `end-to-end-golden-path` app is intentionally boring userland. It
92
+ has one readonly worker task and exists to prove that the base system pipes are
93
+ connected.
94
+
95
+ ## 3. Pipelines Over Monoliths
96
+
97
+ CW favors explicit data flow over hidden orchestration.
98
+
99
+ The standard pipeline is:
100
+
101
+ ```text
102
+ workflow definition
103
+ -> app contract validation
104
+ -> validated input
105
+ -> task files
106
+ -> dispatch manifest
107
+ -> worker result
108
+ -> result envelope
109
+ -> verifier gate
110
+ -> verifier-gated commit or explicit checkpoint
111
+ -> report
112
+ ```
113
+
114
+ Each stage should have a readable artifact. If a stage fails, its error output
115
+ should become input for the next correction step instead of disappearing into a
116
+ black box.
117
+
118
+ Operator views follow the same rule: console summaries point to plain files,
119
+ while `--json` and `--format json` preserve scriptable output.
120
+
121
+ The release golden path is the regression form of this rule:
122
+
123
+ ```text
124
+ npm run golden-path
125
+ ```
126
+
127
+ It exercises the public CLI and then inspects state files for app metadata,
128
+ dispatch, worker manifest, result node, verifier node, candidate score, ranking,
129
+ selection, verifier-gated commit, report, and absence of ErrorFeedback.
130
+
131
+ The canonical app matrix is the userland regression form:
132
+
133
+ ```text
134
+ npm run canonical-apps
135
+ ```
136
+
137
+ It validates and plans every maintained app without running full workers for
138
+ each app.
139
+
140
+ ## 4. Isolated Workers
141
+
142
+ Workers should be isolated by scope, state, and output.
143
+
144
+ Useful isolation layers:
145
+
146
+ - separate task prompts
147
+ - separate result files
148
+ - separate run directories
149
+ - separate workspace or sandbox directories for risky work
150
+ - separate score/evidence records for competing candidates
151
+ - named sandbox profiles for read/write/execute/network/env policy
152
+
153
+ Worker failure should not corrupt the workflow kernel. A failed worker is a
154
+ state transition, not a process-wide failure.
155
+
156
+ Sandbox Profiles keep policy explicit. CW stores the profile id and resolved
157
+ policy in durable state, validates paths, and accepts or rejects worker output
158
+ against the write policy. The agent host remains responsible for OS-level file
159
+ access, command execution, network access, and environment filtering.
160
+
161
+ ## 5. Verifier-Gated Commits
162
+
163
+ CW should not merge every generated answer back into the main workflow state.
164
+ Generated work should pass through evidence and verifier gates first.
165
+
166
+ The preferred merge rule is:
167
+
168
+ ```text
169
+ only verified state becomes committed state
170
+ ```
171
+
172
+ For competing branches, the shape is:
173
+
174
+ ```text
175
+ candidate workers -> score records -> verifier-gated selection
176
+ -> verifier-gated commit()
177
+ ```
178
+
179
+ Non-gated snapshots are checkpoints. They are allowed as audit and resume
180
+ records, but reports and commit records must not present them as verifier-gated
181
+ committed state.
182
+
183
+ ## 6. Practical Operating Rule
184
+
185
+ ```text
186
+ The kernel provides deterministic pipes.
187
+ Workers explore in isolation.
188
+ Verifiers decide what may be committed.
189
+ Hosts enforce runtime sandbox policy.
190
+ ```
191
+
192
+ This keeps CW small, inspectable, and extensible.
@@ -0,0 +1,140 @@
1
+ # VERIFIER-GATED-COMMIT(7)
2
+
3
+ ## NAME
4
+
5
+ Verifier-Gated Commit - commit only state that passed an evidence-backed verifier
6
+
7
+ ## SYNOPSIS
8
+
9
+ ```text
10
+ node dist/cli.js commit <run-id> --verifier <node-id> --reason "verified result"
11
+ node dist/cli.js commit <run-id> --candidate <candidate-id> --reason "promote selected candidate"
12
+ node dist/cli.js commit <run-id> --selection <selection-id> --reason "promote selected candidate"
13
+ node dist/cli.js commit <run-id> --allow-unverified-checkpoint --reason "operator checkpoint"
14
+ ```
15
+
16
+ ```ts
17
+ import { commitState } from "./commit";
18
+
19
+ commitState(run, {
20
+ reason: "verified result",
21
+ verifierNodeId: `${run.id}:verifier:task-one`,
22
+ verifierGated: true
23
+ });
24
+ ```
25
+
26
+ ## DESCRIPTION
27
+
28
+ Verifier-Gated Commit is the CW rule that separates committed state from
29
+ ordinary checkpoints:
30
+
31
+ ```text
32
+ only verified state becomes committed state
33
+ ```
34
+
35
+ A verifier-gated commit requires one of these inputs:
36
+
37
+ - a `verifier` state node with `verified` status and evidence
38
+ - a verified candidate selection that references such a verifier node
39
+ - a selected candidate whose selection references such a verifier node
40
+
41
+ The verifier gate is authoritative. Candidate scores are evidence for operator
42
+ choice, not authority to commit state.
43
+
44
+ ## CHECKPOINTS
45
+
46
+ CW still writes internal snapshots for planning, dispatch, result recording, and
47
+ operator checkpoints. These records are checkpoints. They are useful for audit,
48
+ resume, and rollback, but they are not verifier-gated committed state.
49
+
50
+ Checkpoint records have:
51
+
52
+ ```json
53
+ {
54
+ "verifierGated": false,
55
+ "checkpoint": true
56
+ }
57
+ ```
58
+
59
+ Checkpoint state nodes use `kind: "commit"` and `status: "completed"`. A
60
+ verifier-gated commit state node uses `status: "committed"`.
61
+
62
+ ## COMMIT RECORDS
63
+
64
+ A verifier-gated commit records gate metadata in the commit JSON and state node:
65
+
66
+ ```json
67
+ {
68
+ "verifierGated": true,
69
+ "checkpoint": false,
70
+ "verifierNodeId": "run:verifier:task",
71
+ "candidateId": "candidate-one",
72
+ "selectionId": "selection-candidate-one-...",
73
+ "evidence": []
74
+ }
75
+ ```
76
+
77
+ The `candidateId` and `selectionId` fields are present when the commit promotes
78
+ a candidate or candidate selection. The `evidence` field is copied from the
79
+ verifier node.
80
+
81
+ ## FILES
82
+
83
+ ```text
84
+ .cw/runs/<run-id>/state.json
85
+ .cw/runs/<run-id>/commits/<commit-id>.json
86
+ .cw/runs/<run-id>/nodes/<commit-node-id>.json
87
+ .cw/runs/<run-id>/feedback/<feedback-id>.json
88
+ .cw/runs/<run-id>/report.md
89
+ ```
90
+
91
+ Every blocked commit attempt records an `error` state node and an ErrorFeedback
92
+ record before the command exits.
93
+
94
+ ## FAILURE MODES
95
+
96
+ The commit gate fails closed.
97
+
98
+ Common feedback codes:
99
+
100
+ ```text
101
+ commit-verifier-required
102
+ commit-verifier-not-found
103
+ commit-verifier-wrong-kind
104
+ commit-verifier-not-verified
105
+ commit-verifier-missing-evidence
106
+ commit-candidate-not-found
107
+ commit-candidate-not-selectable
108
+ commit-candidate-unscored
109
+ commit-candidate-not-verified
110
+ commit-candidate-selection-missing
111
+ commit-selection-not-found
112
+ commit-selection-node-missing
113
+ commit-selection-not-verified
114
+ commit-verifier-linkage-mismatch
115
+ ```
116
+
117
+ Use `cw.js feedback list <run-id>` and `cw.js node graph <run-id>` to inspect
118
+ the failed transition.
119
+
120
+ ## CANDIDATES
121
+
122
+ A candidate can become committed state only after selection passes the verifier
123
+ gate. Rejected, failed, unscored, unselected, or unverified candidates are
124
+ blocked.
125
+
126
+ The normal candidate path is:
127
+
128
+ ```text
129
+ candidate record -> score record -> verified selection -> verifier-gated commit
130
+ ```
131
+
132
+ ## COMPATIBILITY
133
+
134
+ Verifier-Gated Commit is introduced in CW v0.1.7. It adds optional fields to
135
+ commit records and keeps older run state readable.
136
+
137
+ Programmatic snapshots that do not request a verifier gate remain checkpoints.
138
+ The CLI `commit` command is stricter: a plain manual commit fails closed unless
139
+ the operator passes `--allow-unverified-checkpoint`.
140
+ 0.1.51