@hecer/yoke 1.9.0 → 1.11.0

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 (153) hide show
  1. package/.claude-plugin/plugin.json +13 -13
  2. package/.codex-plugin/plugin.json +7 -7
  3. package/CHANGELOG.md +398 -358
  4. package/README.md +915 -913
  5. package/TODOS.md +5 -5
  6. package/agents/docs.toml +6 -6
  7. package/agents/implementer.toml +6 -6
  8. package/agents/reviewer.toml +6 -6
  9. package/agents/security.toml +6 -6
  10. package/bench/README.md +86 -86
  11. package/bench/RESULTS.md +35 -35
  12. package/bench/output-compaction.mjs +65 -65
  13. package/bench/result-schema.mjs +12 -12
  14. package/bench/results/claude-2026-07-27T18-03-26.json +50 -50
  15. package/bench/results/codex-unavailable-1785175418318.json +15 -15
  16. package/bench/results/gemini-2026-07-27T18-03-44.json +46 -46
  17. package/bench/run-matrix.mjs +26 -26
  18. package/bench/run.mjs +106 -106
  19. package/canon/AGENTS.md +30 -30
  20. package/canon/context/DECISIONS.md +4 -4
  21. package/canon/context/GLOSSARY.md +11 -11
  22. package/canon/context/KNOWLEDGE.md +4 -4
  23. package/canon/context/PROJECT.md +15 -15
  24. package/canon/loop/loop-spec.md +65 -65
  25. package/canon/loop/prd.schema.md +46 -40
  26. package/canon/manifest.yaml +59 -59
  27. package/canon/policy/gates.md +7 -7
  28. package/canon/policy/roles.md +9 -9
  29. package/canon/skills/ATTRIBUTION.md +99 -99
  30. package/canon/skills/authoring-prd/SKILL.md +56 -56
  31. package/canon/skills/brainstorming/SKILL.md +164 -164
  32. package/canon/skills/codebase-design/DEEPENING.md +15 -15
  33. package/canon/skills/codebase-design/DESIGN-IT-TWICE.md +12 -12
  34. package/canon/skills/codebase-design/SKILL.md +39 -39
  35. package/canon/skills/dispatching-parallel-agents/SKILL.md +182 -182
  36. package/canon/skills/document-release/SKILL.md +302 -302
  37. package/canon/skills/domain-modeling/ADR-FORMAT.md +19 -19
  38. package/canon/skills/domain-modeling/CONTEXT-FORMAT.md +39 -39
  39. package/canon/skills/domain-modeling/SKILL.md +35 -35
  40. package/canon/skills/executing-plans/SKILL.md +70 -70
  41. package/canon/skills/finishing-a-development-branch/SKILL.md +200 -200
  42. package/canon/skills/health/SKILL.md +177 -177
  43. package/canon/skills/maintaining-context/SKILL.md +34 -34
  44. package/canon/skills/minimal-code/SKILL.md +21 -21
  45. package/canon/skills/no-ai-slop/SKILL.md +103 -103
  46. package/canon/skills/no-ai-slop/eval.md +43 -43
  47. package/canon/skills/plan-ceo-review/SKILL.md +541 -541
  48. package/canon/skills/plan-eng-review/SKILL.md +362 -362
  49. package/canon/skills/receiving-code-review/SKILL.md +213 -213
  50. package/canon/skills/requesting-code-review/SKILL.md +105 -105
  51. package/canon/skills/resolving-merge-conflicts/SKILL.md +18 -18
  52. package/canon/skills/retro/SKILL.md +397 -397
  53. package/canon/skills/review/SKILL.md +246 -246
  54. package/canon/skills/ship/SKILL.md +691 -691
  55. package/canon/skills/subagent-driven-development/SKILL.md +277 -277
  56. package/canon/skills/systematic-debugging/SKILL.md +296 -296
  57. package/canon/skills/tdd/SKILL.md +371 -371
  58. package/canon/skills/unslop-ui/SKILL.md +34 -34
  59. package/canon/skills/using-git-worktrees/SKILL.md +218 -218
  60. package/canon/skills/verification-before-completion/SKILL.md +139 -139
  61. package/canon/skills/visual-verification/SKILL.md +54 -54
  62. package/canon/skills/workflow/SKILL.md +22 -22
  63. package/canon/skills/writing-for-agents/SKILL-MECHANICS.md +27 -27
  64. package/canon/skills/writing-for-agents/SKILL.md +42 -42
  65. package/canon/skills/writing-plans/SKILL.md +152 -152
  66. package/canon/skills/writing-skills/SKILL.md +655 -655
  67. package/canon/skills/yoke-retrofit/SKILL.md +26 -26
  68. package/canon/skills/yoke-workflow/SKILL.md +20 -20
  69. package/canon/tools/codex-rtk-hook.mjs +35 -35
  70. package/canon/tools/gemini-rtk-hook.mjs +25 -25
  71. package/canon/tools/graphify.md +3 -3
  72. package/canon/tools/playwright-mcp.md +3 -3
  73. package/canon/tools/rtk.md +7 -7
  74. package/canon/tools/serena.md +6 -6
  75. package/dist/agents/contracts.js +1 -1
  76. package/dist/agents/host.js +4 -0
  77. package/dist/agents/process-incarnation.js +1 -1
  78. package/dist/agents/process.js +74 -6
  79. package/dist/agents/providers.js +13 -0
  80. package/dist/agents/supervision.js +153 -0
  81. package/dist/agents/telemetry.js +33 -0
  82. package/dist/agents/windows-launch.js +80 -0
  83. package/dist/canon/manifest.js +1 -1
  84. package/dist/change/inbox.js +21 -5
  85. package/dist/cli.js +19 -10
  86. package/dist/dashboard/discovery.js +73 -0
  87. package/dist/dashboard/page.js +122 -28
  88. package/dist/dashboard/panels.js +91 -15
  89. package/dist/goals/command.js +4 -2
  90. package/dist/loop/claims.js +1 -1
  91. package/dist/loop/decision.js +2 -2
  92. package/dist/loop/git.js +12 -4
  93. package/dist/loop/loop.js +8 -4
  94. package/dist/loop/parallel-adapters.js +2 -3
  95. package/dist/loop/parallel-command.js +5 -0
  96. package/dist/loop/prd.js +3 -1
  97. package/dist/loop/reporter.js +4 -1
  98. package/dist/loop/run-command.js +11 -2
  99. package/dist/loop/runner.js +22 -26
  100. package/dist/loop/watchdog.js +87 -11
  101. package/dist/loop/worker.js +5 -3
  102. package/dist/prd/assess.js +145 -0
  103. package/dist/prd/command.js +76 -38
  104. package/dist/quality/types.js +1 -1
  105. package/dist/retrofit/config.js +11 -0
  106. package/dist/retrofit/plan.js +2 -0
  107. package/dist/retrofit/planners/claude.js +14 -14
  108. package/dist/retrofit/planners/qwen.js +73 -0
  109. package/dist/retrofit/preserve.js +2 -2
  110. package/dist/retrofit/skill-actions.js +1 -0
  111. package/dist/review/command.js +1 -1
  112. package/dist/routing/assessment.js +1 -1
  113. package/dist/routing/capability.js +25 -13
  114. package/dist/routing/contracts.js +60 -0
  115. package/dist/routing/planning.js +12 -0
  116. package/dist/routing/router.js +51 -16
  117. package/dist/setup/command.js +11 -3
  118. package/docs/BATCH-PLANNING-VALIDATION.md +67 -0
  119. package/docs/CAPABILITY-ROUTING.md +78 -50
  120. package/docs/DASHBOARD-EVOLUTION.md +33 -0
  121. package/docs/MIGRATING-TO-1.0.md +33 -33
  122. package/docs/MIGRATING-TO-1.1.md +27 -27
  123. package/docs/MIGRATING-TO-1.4.md +70 -70
  124. package/docs/PRODUCT-DIRECTION-2026-09-05.md +218 -200
  125. package/docs/PUBLISHING.md +114 -114
  126. package/docs/VERIFIED-PROJECTS-VALIDATION.md +29 -29
  127. package/docs/VERIFIED-PROJECTS.md +167 -167
  128. package/docs/WINDOWS-RUNNER-VALIDATION.md +104 -0
  129. package/docs/assets/yoke-logo.png +0 -0
  130. package/docs/community-outreach-2026-08-20.md +85 -0
  131. package/docs/launch-copy-2026-08-21.md +193 -0
  132. package/docs/superpowers/plans/2026-06-28-baustein-e-context-layer.md +981 -981
  133. package/docs/superpowers/plans/2026-06-29-baustein-f-routing.md +258 -258
  134. package/docs/superpowers/plans/2026-06-29-baustein-g-loop-observability.md +1006 -1006
  135. package/docs/superpowers/plans/2026-06-29-baustein-h-loop-robustness.md +374 -374
  136. package/docs/superpowers/plans/2026-06-30-baustein-i-visual-design-verification.md +450 -450
  137. package/docs/superpowers/plans/2026-07-02-baustein-k-zero-to-100-bootstrap.md +1024 -1024
  138. package/docs/superpowers/plans/2026-07-02-baustein-m-flow-smoke-proofs.md +574 -574
  139. package/docs/superpowers/plans/2026-08-13-gauntlet-quality-loop.md +537 -537
  140. package/docs/superpowers/plans/2026-08-16-artifact-backed-output-compaction.md +329 -329
  141. package/docs/superpowers/plans/2026-09-05-verified-projects.md +83 -83
  142. package/docs/superpowers/specs/2026-06-28-baustein-e-context-layer-design.md +146 -146
  143. package/docs/superpowers/specs/2026-06-29-baustein-f-routing-design.md +106 -106
  144. package/docs/superpowers/specs/2026-06-29-baustein-g-loop-observability-design.md +186 -186
  145. package/docs/superpowers/specs/2026-06-29-baustein-h-loop-robustness-design.md +113 -113
  146. package/docs/superpowers/specs/2026-06-30-baustein-i-visual-design-verification-design.md +98 -98
  147. package/docs/superpowers/specs/2026-07-02-baustein-k-zero-to-100-bootstrap-design.md +200 -200
  148. package/docs/superpowers/specs/2026-07-02-baustein-m-flow-smoke-proofs-design.md +155 -155
  149. package/docs/superpowers/specs/2026-08-13-gauntlet-quality-loop-design.md +422 -422
  150. package/docs/superpowers/specs/2026-08-16-artifact-backed-output-compaction-design.md +166 -166
  151. package/gemini-extension.json +6 -6
  152. package/hooks/hooks.json +19 -19
  153. package/package.json +87 -87
@@ -1,106 +1,106 @@
1
- # Baustein F — Skill Routing/Precedence + Review-Family Consolidation
2
-
3
- **Status:** Design approved 2026-06-29
4
- **Component:** Yoke (🐂)
5
- **Relates to:** [[harness-build-progress]], [[readme-always-update]]
6
-
7
- ## Problem & Goal
8
-
9
- The dev.to skills-stack article's #1 warning is **auto-invocation chaos**: when superpowers
10
- (aggressive "1% chance → you MUST invoke") and gstack roles ("proactively suggest") are both
11
- installed, overlapping skills compete on the same triggers, causing random/redundant selection.
12
- Yoke's `canon/manifest.yaml` distinguishes `kind: methodology|role` but emits **no precedence or
13
- routing** — nothing tells an agent which skill is canonical when several match.
14
-
15
- The collision is concentrated in the review family. From the actual descriptions:
16
-
17
- | Skill | Phase / angle | Status |
18
- |---|---|---|
19
- | `plan-eng-review` | plan-time, architecture | distinct ✓ |
20
- | `plan-ceo-review` | plan-time, product/scope | distinct ✓ |
21
- | `review` | **pre-merge, diff safety/structure** | collides ⚠ |
22
- | `eng-review` (14-line stub) | **pre-merge, architecture/edge-cases/tests** | collides ⚠ |
23
- | `requesting-code-review` | protocol: request a review | distinct ✓ |
24
- | `receiving-code-review` | protocol: handle feedback | distinct ✓ |
25
-
26
- The one real overlap is `eng-review` ↔ `review` — both "review the change before merge."
27
-
28
- **Goal:** emit an explicit routing/precedence into every agent so auto-invocation resolves
29
- deterministically, and collapse the `eng-review`/`review` overlap into one canonical pre-merge
30
- review skill.
31
-
32
- ## Key Decisions (locked)
33
-
34
- | Decision | Choice |
35
- |---|---|
36
- | Routing location | Authored prose section in `canon/AGENTS.md` (injected verbatim into all 3 agents) — NOT a new manifest field or generator |
37
- | Precedence rule | Methodology (HOW) before role (perspective); process before implementation |
38
- | Review collision | Fold `eng-review`'s checklist into `review`; **remove `eng-review`**; `review` becomes the single canonical pre-merge code review |
39
- | Description hygiene | Sharpen the remaining review-family descriptions so triggers are phase-distinct, non-overlapping |
40
- | Skill count | Canon 25 → **24** |
41
- | README | Update the skills catalog (Roles 8→7, total 25→24) — **mandatory deliverable** |
42
- | Out of scope (YAGNI) | No NLP trigger-collision validator (too fragile); no `priority` manifest field + generator (the `kind` distinction + authored prose suffices) |
43
-
44
- ## Architecture
45
-
46
- ### 1. Routing section in `canon/AGENTS.md`
47
- A new "Skill routing & precedence" section appended to the baseline (which already covers
48
- quality-first/stop-the-line/role-separation). It states three things:
49
-
50
- 1. **Precedence** — methodology skills decide *how* to work and take precedence over role skills
51
- (which add a perspective). Process before implementation.
52
- 2. **Canonical entrypoint per concern** — a small map, especially the review family:
53
- - Plan-time architecture review → `plan-eng-review`
54
- - Plan-time product/scope review → `plan-ceo-review`
55
- - **Pre-merge code review → `review`** (the single canonical one)
56
- - Requesting a review (dispatch a reviewer) → `requesting-code-review`
57
- - Handling review feedback → `receiving-code-review`
58
- - Build flow / order of operations → `workflow`
59
- 3. **Arbitration rule** — "These skills declare their own triggers aggressively; when several
60
- match the same task, this precedence + the most-specific-entrypoint rule decides. Don't run
61
- two skills that serve the same concern."
62
-
63
- `canon/AGENTS.md` is copied verbatim by the Claude/Codex/Gemini planners and imported by the
64
- generated `CLAUDE.md`/`GEMINI.md`, so this reaches all three agents with no generator change.
65
-
66
- ### 2. Review-family consolidation
67
- - **`review`** absorbs `eng-review`'s checklist: in addition to diff safety (SQL, trust
68
- boundaries, side effects), it now also covers architecture fit, edge cases, test coverage, and
69
- performance — the engineering-manager angle. One canonical pre-merge review.
70
- - **`eng-review` removed**: delete `canon/skills/eng-review/` and its `manifest.yaml` entry.
71
- - **Descriptions sharpened**: each review-family skill's description names its phase explicitly
72
- so triggers don't overlap (plan-time vs pre-merge vs protocol).
73
-
74
- ### 3. Manifest + validator
75
- - Remove the `eng-review` entry from `canon/manifest.yaml`.
76
- - `validateCanon` must stay green (it validates that each listed skill has a dir + frontmatter;
77
- removing the entry + dir keeps it consistent). No validator code change required unless a test
78
- hard-codes the skill list.
79
-
80
- ### 4. README (mandatory)
81
- Update the skills catalog: remove the `eng-review` row, move its purpose into the `review` row,
82
- change the Roles count 8→7 and the total 25→24. Per the standing rule, the README must reflect
83
- what shipped.
84
-
85
- ## Data flow (how routing reaches an agent)
86
- ```
87
- canon/AGENTS.md (routing section)
88
- └─ planClaude → AGENTS.md + CLAUDE.md (@AGENTS.md import) → Claude reads precedence
89
- └─ planCodex → AGENTS.md (Codex reads it natively) → Codex reads precedence
90
- └─ planGemini → GEMINI.md + .gemini/settings (AGENTS.md ctx) → Gemini reads precedence
91
- ```
92
-
93
- ## Testing
94
- - `tests/canon/real-canon.test.ts`: assert `eng-review` is NOT in the manifest; assert
95
- `canon/AGENTS.md` contains the routing section (e.g. a stable heading + the "Pre-merge code
96
- review → `review`" line); `validateCanon('canon')` stays zero-error.
97
- - `tests/retrofit/plan-dispatch.test.ts` (or planners tests): the emitted skill set no longer
98
- includes `eng-review`; total skill count reflects 24. Adjust any hard-coded count.
99
- - `review` skill still validates (frontmatter intact after the checklist merge).
100
- - Full suite green; `tsc` clean.
101
-
102
- ## Non-goals (YAGNI)
103
- - No automated trigger-collision detection.
104
- - No new manifest `priority` field or routing generator.
105
- - No change to plan-ceo-review / plan-eng-review / requesting- / receiving-code-review bodies
106
- beyond description sharpening.
1
+ # Baustein F — Skill Routing/Precedence + Review-Family Consolidation
2
+
3
+ **Status:** Design approved 2026-06-29
4
+ **Component:** Yoke (🐂)
5
+ **Relates to:** [[harness-build-progress]], [[readme-always-update]]
6
+
7
+ ## Problem & Goal
8
+
9
+ The dev.to skills-stack article's #1 warning is **auto-invocation chaos**: when superpowers
10
+ (aggressive "1% chance → you MUST invoke") and gstack roles ("proactively suggest") are both
11
+ installed, overlapping skills compete on the same triggers, causing random/redundant selection.
12
+ Yoke's `canon/manifest.yaml` distinguishes `kind: methodology|role` but emits **no precedence or
13
+ routing** — nothing tells an agent which skill is canonical when several match.
14
+
15
+ The collision is concentrated in the review family. From the actual descriptions:
16
+
17
+ | Skill | Phase / angle | Status |
18
+ |---|---|---|
19
+ | `plan-eng-review` | plan-time, architecture | distinct ✓ |
20
+ | `plan-ceo-review` | plan-time, product/scope | distinct ✓ |
21
+ | `review` | **pre-merge, diff safety/structure** | collides ⚠ |
22
+ | `eng-review` (14-line stub) | **pre-merge, architecture/edge-cases/tests** | collides ⚠ |
23
+ | `requesting-code-review` | protocol: request a review | distinct ✓ |
24
+ | `receiving-code-review` | protocol: handle feedback | distinct ✓ |
25
+
26
+ The one real overlap is `eng-review` ↔ `review` — both "review the change before merge."
27
+
28
+ **Goal:** emit an explicit routing/precedence into every agent so auto-invocation resolves
29
+ deterministically, and collapse the `eng-review`/`review` overlap into one canonical pre-merge
30
+ review skill.
31
+
32
+ ## Key Decisions (locked)
33
+
34
+ | Decision | Choice |
35
+ |---|---|
36
+ | Routing location | Authored prose section in `canon/AGENTS.md` (injected verbatim into all 3 agents) — NOT a new manifest field or generator |
37
+ | Precedence rule | Methodology (HOW) before role (perspective); process before implementation |
38
+ | Review collision | Fold `eng-review`'s checklist into `review`; **remove `eng-review`**; `review` becomes the single canonical pre-merge code review |
39
+ | Description hygiene | Sharpen the remaining review-family descriptions so triggers are phase-distinct, non-overlapping |
40
+ | Skill count | Canon 25 → **24** |
41
+ | README | Update the skills catalog (Roles 8→7, total 25→24) — **mandatory deliverable** |
42
+ | Out of scope (YAGNI) | No NLP trigger-collision validator (too fragile); no `priority` manifest field + generator (the `kind` distinction + authored prose suffices) |
43
+
44
+ ## Architecture
45
+
46
+ ### 1. Routing section in `canon/AGENTS.md`
47
+ A new "Skill routing & precedence" section appended to the baseline (which already covers
48
+ quality-first/stop-the-line/role-separation). It states three things:
49
+
50
+ 1. **Precedence** — methodology skills decide *how* to work and take precedence over role skills
51
+ (which add a perspective). Process before implementation.
52
+ 2. **Canonical entrypoint per concern** — a small map, especially the review family:
53
+ - Plan-time architecture review → `plan-eng-review`
54
+ - Plan-time product/scope review → `plan-ceo-review`
55
+ - **Pre-merge code review → `review`** (the single canonical one)
56
+ - Requesting a review (dispatch a reviewer) → `requesting-code-review`
57
+ - Handling review feedback → `receiving-code-review`
58
+ - Build flow / order of operations → `workflow`
59
+ 3. **Arbitration rule** — "These skills declare their own triggers aggressively; when several
60
+ match the same task, this precedence + the most-specific-entrypoint rule decides. Don't run
61
+ two skills that serve the same concern."
62
+
63
+ `canon/AGENTS.md` is copied verbatim by the Claude/Codex/Gemini planners and imported by the
64
+ generated `CLAUDE.md`/`GEMINI.md`, so this reaches all three agents with no generator change.
65
+
66
+ ### 2. Review-family consolidation
67
+ - **`review`** absorbs `eng-review`'s checklist: in addition to diff safety (SQL, trust
68
+ boundaries, side effects), it now also covers architecture fit, edge cases, test coverage, and
69
+ performance — the engineering-manager angle. One canonical pre-merge review.
70
+ - **`eng-review` removed**: delete `canon/skills/eng-review/` and its `manifest.yaml` entry.
71
+ - **Descriptions sharpened**: each review-family skill's description names its phase explicitly
72
+ so triggers don't overlap (plan-time vs pre-merge vs protocol).
73
+
74
+ ### 3. Manifest + validator
75
+ - Remove the `eng-review` entry from `canon/manifest.yaml`.
76
+ - `validateCanon` must stay green (it validates that each listed skill has a dir + frontmatter;
77
+ removing the entry + dir keeps it consistent). No validator code change required unless a test
78
+ hard-codes the skill list.
79
+
80
+ ### 4. README (mandatory)
81
+ Update the skills catalog: remove the `eng-review` row, move its purpose into the `review` row,
82
+ change the Roles count 8→7 and the total 25→24. Per the standing rule, the README must reflect
83
+ what shipped.
84
+
85
+ ## Data flow (how routing reaches an agent)
86
+ ```
87
+ canon/AGENTS.md (routing section)
88
+ └─ planClaude → AGENTS.md + CLAUDE.md (@AGENTS.md import) → Claude reads precedence
89
+ └─ planCodex → AGENTS.md (Codex reads it natively) → Codex reads precedence
90
+ └─ planGemini → GEMINI.md + .gemini/settings (AGENTS.md ctx) → Gemini reads precedence
91
+ ```
92
+
93
+ ## Testing
94
+ - `tests/canon/real-canon.test.ts`: assert `eng-review` is NOT in the manifest; assert
95
+ `canon/AGENTS.md` contains the routing section (e.g. a stable heading + the "Pre-merge code
96
+ review → `review`" line); `validateCanon('canon')` stays zero-error.
97
+ - `tests/retrofit/plan-dispatch.test.ts` (or planners tests): the emitted skill set no longer
98
+ includes `eng-review`; total skill count reflects 24. Adjust any hard-coded count.
99
+ - `review` skill still validates (frontmatter intact after the checklist merge).
100
+ - Full suite green; `tsc` clean.
101
+
102
+ ## Non-goals (YAGNI)
103
+ - No automated trigger-collision detection.
104
+ - No new manifest `priority` field or routing generator.
105
+ - No change to plan-ceo-review / plan-eng-review / requesting- / receiving-code-review bodies
106
+ beyond description sharpening.
@@ -1,186 +1,186 @@
1
- # Baustein G — Loop Observability (heartbeat, timeout, live feedback)
2
-
3
- **Status:** Design approved 2026-06-29
4
- **Component:** Yoke (🐂)
5
- **Relates to:** [[harness-loop-technique]], [[harness-build-progress]]
6
-
7
- ## Problem & Goal
8
-
9
- A real incident: the autonomous loop ran on a downstream project (NewMarket) and sat
10
- **blocked for ~5 hours, completely invisibly**. A story failed its verify gate, the loop
11
- correctly returned `blocked` and stopped — but that outcome was printed to the stdout of a
12
- detached background command and never surfaced. The user saw "running forever," couldn't tell
13
- progress from a hang, and `yoke loop status` only reported the PRD count (`18/45`), not *why*
14
- nothing was advancing.
15
-
16
- Two gaps caused this:
17
- 1. **No durable, queryable run state.** `blocked` (and its reason) lived only in transient
18
- stdout. There was no artifact to glance at.
19
- 2. **No agent-run timeout.** A genuinely hung nested agent (`claude -p`) would wedge the loop
20
- indefinitely — only `verify` had a timeout, not the implementation run.
21
-
22
- **Timeout must not punish slow-but-working agents.** A fixed *total-runtime* timeout cannot tell
23
- "hung" from "working, just slow" and would kill a legitimately long story. So G uses an
24
- **inactivity (idle) timeout**, not a wall-clock one: it measures time since the agent's *last
25
- sign of life* (its last output byte), not total duration. An agent that keeps emitting output
26
- runs for an unbounded time; only true silence is treated as a hang. The same output stream that
27
- gives the user live feedback IS the liveness signal — feedback and hang-detection are one.
28
-
29
- **Goal:** make the loop observable and self-limiting. The loop continuously reports where it
30
- is (which story, which phase, why blocked) through **token-free, harness-side channels**, and
31
- a per-iteration timeout breaks true hangs.
32
-
33
- **Design principle — maximize free feedback.** All feedback added here is produced by the loop
34
- driver (Node: console + local files), never by an agent. It costs **zero agent tokens**. The
35
- only token cost in the loop remains the nested agent runs themselves, which G does not change.
36
- So we deliberately make local feedback dense and frequent.
37
-
38
- ## Key Decisions (locked)
39
-
40
- | Decision | Choice |
41
- |---|---|
42
- | Scope | Heartbeat status file + `yoke loop status` upgrade + agent-run timeout + blocked-leftover reporting + live console narration + append log |
43
- | Timeout kind | **Idle (no-output) timeout**, NOT total runtime. Resets on every output byte; only true silence counts. Total runtime is unbounded while the agent keeps producing output. |
44
- | Timeout on expiry | Kill the child → treated as a normal failure → `blocked` → loop stops (consistent with runner-fail / verify-fail / review-reject). No silent skip. |
45
- | Timeout default | 20 minutes of **silence**; `--timeout=<minutes>` flag > `config.loop.timeoutMinutes` > default. `0` disables. |
46
- | Timeout mechanism | A small watchdog wrapper (`src/loop/watchdog.ts`) runs the agent as a child, forwards stdio (prompt in, output live out), and kills on idle expiry. Keeps `runLoop`/runner synchronous — no async ripple. |
47
- | Feedback channels | Console narration + `.yoke/loop-status.json` (current state) + `.yoke/loop.log` (append-only timeline). All Node-side, 0 tokens. |
48
- | Backwards-compat | No status file → `yoke loop status` behaves exactly as today. Reporter is injectable and defaults to a real impl; existing `runLoop` tests pass a no-op. |
49
- | Out of scope (YAGNI) | No token metering of nested agents (technically not exposable), no log streaming server, no web dashboard. |
50
-
51
- ## Architecture
52
-
53
- All new surface lives in the `loop/` subsystem.
54
-
55
- ### 1. `src/loop/reporter.ts` (new) — status types + reporter + reader
56
- ```ts
57
- type LoopState = 'running' | 'blocked' | 'complete' | 'cap-reached'
58
- type LoopPhase = 'implementing' | 'verifying' | 'reviewing' | 'committing'
59
-
60
- interface LoopStatus {
61
- state: LoopState
62
- phase?: LoopPhase // only meaningful while state === 'running'
63
- story?: string
64
- storyTitle?: string
65
- reason?: string // populated on 'blocked'
66
- iteration: number
67
- progress: { passed: number; total: number }
68
- startedAt: string // ISO — when the current story/iteration began
69
- updatedAt: string // ISO — last heartbeat write
70
- }
71
-
72
- interface LoopReporter {
73
- storyStart(story, iteration, progress): void // → state:running, phase:implementing
74
- phase(phase: LoopPhase): void // → updates phase + updatedAt
75
- blocked(reason: string): void // → state:blocked
76
- complete(progress): void // → state:complete
77
- capReached(progress): void // → state:cap-reached
78
- }
79
-
80
- makeReporter(dir, opts?: { quiet?: boolean }, now?: () => Date): LoopReporter
81
- readStatus(dir): LoopStatus | null
82
- ```
83
- The default `makeReporter` writes three places on every event:
84
- - **`.yoke/loop-status.json`** — the single current `LoopStatus` (overwritten atomically: temp file + rename).
85
- - **`.yoke/loop.log`** — appends one line: `<ISO> <state/phase> <story> <detail>`.
86
- - **console** — a human line (suppressed when `quiet`): e.g.
87
- - `▶ S6-seed-rich (19/45) — implementing…`
88
- - ` ✓ verified` / ` ✓ reviewed` / ` ✓ committed → 20/45`
89
- - `■ blocked on S6-seed-rich: verify failed (working tree left dirty — clean before restart)`
90
-
91
- `now` is injectable for deterministic tests. Timestamps use the Node runtime (`Date`),
92
- which is available (the loop is not a Workflow script).
93
-
94
- ### 2. `src/loop/loop.ts` — drive the reporter
95
- `runLoop` takes an optional `reporter: LoopReporter` in `LoopOptions` (default: a no-op so the
96
- existing tests are untouched; `run-command` injects the real one). At each boundary it calls:
97
- `storyStart` before dispatch → `phase('verifying')` before verify → `phase('reviewing')` before
98
- review → `phase('committing')` before commit → `complete`/`capReached`/`blocked` at terminal
99
- returns. The **blocked** call's reason is enriched: if the working tree is dirty
100
- (`opts.git.isClean(targetDir) === false`) after a block, append
101
- `" (working tree has uncommitted changes from the blocked story — review/clean before re-running)"`.
102
- This is the S5 leftover case made explicit.
103
-
104
- ### 3. `src/loop/watchdog.ts` (new) — idle-timeout wrapper
105
- A tiny standalone CLI: `node watchdog.js --idle-ms=<N> -- <command> [args...]`.
106
- - Spawns `<command>` with piped stdio. Forwards its own stdin to the child (so the prompt still
107
- reaches `claude -p`) and the child's stdout/stderr to its own (so live output still reaches
108
- the user — the feedback channel).
109
- - Maintains an idle timer reset on **every** stdout/stderr chunk. On expiry it kills the child
110
- (SIGTERM, then SIGKILL after a short grace; on win32 `taskkill /pid /t /f` for the tree) and
111
- exits **124** (timeout convention). Otherwise it exits with the child's own exit code.
112
- - `--idle-ms=0` means no watchdog (spawn-through with no timer).
113
- All the async/stream complexity lives here, isolated and unit-testable. Nothing else in the
114
- loop becomes async.
115
-
116
- ### 4. `src/loop/runner.ts` — run the agent through the watchdog
117
- `Invocation` gains an optional `idleTimeoutMs?: number`. When set (>0), `runCli` runs the agent
118
- **through the watchdog**: `node <dist>/loop/watchdog.js --idle-ms=<N> -- <command> <args...>`,
119
- with the prompt still piped via stdin. `execSync` blocks on the watchdog (runner stays
120
- synchronous). A watchdog exit of 124 (or any non-zero) is caught as today →
121
- `{ success: false, summary: 'no output for Nm — treated as hung' }` → the loop blocks. When
122
- `idleTimeoutMs` is unset/0, the agent runs directly as before. `makeRunner`/`makeReviewRunner`
123
- accept and thread `idleTimeoutMs`; the reviewer run uses the same budget.
124
-
125
- ### 5. `src/loop/run-command.ts` — wire + upgrade `loop status`
126
- - `runLoopCommand` resolves the idle timeout (`--timeout` flag > `config.loop.timeoutMinutes` >
127
- default 20 minutes; `0` disables), builds the real `makeReporter(targetDir)`, builds runners
128
- with the resolved `idleTimeoutMs`, and passes the reporter into `runLoop`.
129
- - `loopStatus(targetDir)` reads `readStatus(targetDir)`. If present, it renders state + phase +
130
- story + title + reason + iteration + a relative `updatedAt`, and — when `state==='running'`
131
- and `updatedAt` is older than the timeout — a `possibly stuck (no update in Nm)` hint. If
132
- absent, it falls back to today's `enabled + PRD progress` output verbatim.
133
-
134
- ### 6. `src/retrofit/config.ts` — optional config field
135
- `loop.timeoutMinutes?: number` (idle minutes) added to the schema (optional, backwards-compatible).
136
-
137
- ### 7. `src/cli.ts` — flag + gitignore note
138
- Parse `--timeout=<minutes>` on `yoke loop run`. `.yoke/loop-status.json` and `.yoke/loop.log`
139
- are runtime artifacts — ensure the retrofit gitignore covers them (or document that they are
140
- local-only). They must NOT block the clean-tree gate: the loop writes them under `.yoke/`,
141
- which retrofit already gitignores for `worktrees`/`backup`; extend that to these two files.
142
-
143
- ## Data flow (one iteration)
144
- ```
145
- storyStart(S6) ─► [console ▶ / status running:implementing / log]
146
- runner(idle-watchdog) ─► phase(verifying) ─► verify ─► phase(reviewing) ─► [review]
147
- ─► phase(committing) ─► appendDecision ─► savePrd(passes) ─► commitAll
148
- ─► [console ✓ committed → 20/45]
149
- on any failure ─► blocked(reason + leftover-hint) ─► [console ■ / status blocked / log] ─► return
150
- ```
151
-
152
- ## Error handling
153
- - Status writes are best-effort and atomic (temp + rename); a write failure never aborts the
154
- loop (wrapped, logged to console, swallowed) — observability must not break execution.
155
- - Timeout kills the child and surfaces as `blocked`; the clean-tree gate + leftover hint guard
156
- the restart.
157
- - `readStatus` on a missing/corrupt file returns `null` → `loop status` falls back gracefully.
158
-
159
- ## Testing (subagent-driven TDD, like A–F)
160
- - **reporter.ts:** status round-trip (write→read); missing file → null; each event sets the
161
- right state/phase; `loop.log` appends one line per event; `quiet` suppresses console;
162
- injected `now` makes timestamps deterministic; atomic write leaves no temp file behind.
163
- - **loop.ts:** reporter receives `storyStart`/`phase`/`complete` in order on success;
164
- `blocked` with reason on a failed verify; leftover hint appended when `git.isClean` is false
165
- on block; existing loop tests still pass with the default no-op reporter.
166
- - **watchdog.ts:** wrapping a child that keeps emitting output past the idle window is **not**
167
- killed (proves slow-but-working survives); wrapping a silent child that outputs nothing is
168
- killed after the idle window and exits 124; a fast child passes its exit code through; stdin
169
- is forwarded to the child; `--idle-ms=0` never kills. (Use tiny `node -e` children with short
170
- idle windows for deterministic, fast tests.)
171
- - **runner.ts:** when `idleTimeoutMs>0` the invocation runs through the watchdog wrapper (assert
172
- the built command); when unset/0 it runs the agent directly; resolution order flag>config>20.
173
- - **run-command.ts:** `loopStatus` renders state+phase+reason when a status file exists; falls
174
- back to PRD-only when absent; `--timeout` parsed and forwarded.
175
- - **config.ts:** `timeoutMinutes` accepted and optional.
176
-
177
- ## What this would have done for the incident
178
- `yoke loop status .` →
179
- ```
180
- Loop: BLOCKED on S5-segment-schemas "All 9 segment attribute schemas…"
181
- phase: verifying · iteration 19 · 18/45 · last update 5h ago
182
- reason: story did not verify (working tree has uncommitted changes — clean before restart)
183
- ```
184
- …instead of `18/45`. And a true hang (no agent output at all) would self-terminate after 20
185
- minutes of silence as `blocked` — while a genuinely slow story that keeps streaming progress
186
- runs as long as it needs.
1
+ # Baustein G — Loop Observability (heartbeat, timeout, live feedback)
2
+
3
+ **Status:** Design approved 2026-06-29
4
+ **Component:** Yoke (🐂)
5
+ **Relates to:** [[harness-loop-technique]], [[harness-build-progress]]
6
+
7
+ ## Problem & Goal
8
+
9
+ A real incident: the autonomous loop ran on a downstream project (NewMarket) and sat
10
+ **blocked for ~5 hours, completely invisibly**. A story failed its verify gate, the loop
11
+ correctly returned `blocked` and stopped — but that outcome was printed to the stdout of a
12
+ detached background command and never surfaced. The user saw "running forever," couldn't tell
13
+ progress from a hang, and `yoke loop status` only reported the PRD count (`18/45`), not *why*
14
+ nothing was advancing.
15
+
16
+ Two gaps caused this:
17
+ 1. **No durable, queryable run state.** `blocked` (and its reason) lived only in transient
18
+ stdout. There was no artifact to glance at.
19
+ 2. **No agent-run timeout.** A genuinely hung nested agent (`claude -p`) would wedge the loop
20
+ indefinitely — only `verify` had a timeout, not the implementation run.
21
+
22
+ **Timeout must not punish slow-but-working agents.** A fixed *total-runtime* timeout cannot tell
23
+ "hung" from "working, just slow" and would kill a legitimately long story. So G uses an
24
+ **inactivity (idle) timeout**, not a wall-clock one: it measures time since the agent's *last
25
+ sign of life* (its last output byte), not total duration. An agent that keeps emitting output
26
+ runs for an unbounded time; only true silence is treated as a hang. The same output stream that
27
+ gives the user live feedback IS the liveness signal — feedback and hang-detection are one.
28
+
29
+ **Goal:** make the loop observable and self-limiting. The loop continuously reports where it
30
+ is (which story, which phase, why blocked) through **token-free, harness-side channels**, and
31
+ a per-iteration timeout breaks true hangs.
32
+
33
+ **Design principle — maximize free feedback.** All feedback added here is produced by the loop
34
+ driver (Node: console + local files), never by an agent. It costs **zero agent tokens**. The
35
+ only token cost in the loop remains the nested agent runs themselves, which G does not change.
36
+ So we deliberately make local feedback dense and frequent.
37
+
38
+ ## Key Decisions (locked)
39
+
40
+ | Decision | Choice |
41
+ |---|---|
42
+ | Scope | Heartbeat status file + `yoke loop status` upgrade + agent-run timeout + blocked-leftover reporting + live console narration + append log |
43
+ | Timeout kind | **Idle (no-output) timeout**, NOT total runtime. Resets on every output byte; only true silence counts. Total runtime is unbounded while the agent keeps producing output. |
44
+ | Timeout on expiry | Kill the child → treated as a normal failure → `blocked` → loop stops (consistent with runner-fail / verify-fail / review-reject). No silent skip. |
45
+ | Timeout default | 20 minutes of **silence**; `--timeout=<minutes>` flag > `config.loop.timeoutMinutes` > default. `0` disables. |
46
+ | Timeout mechanism | A small watchdog wrapper (`src/loop/watchdog.ts`) runs the agent as a child, forwards stdio (prompt in, output live out), and kills on idle expiry. Keeps `runLoop`/runner synchronous — no async ripple. |
47
+ | Feedback channels | Console narration + `.yoke/loop-status.json` (current state) + `.yoke/loop.log` (append-only timeline). All Node-side, 0 tokens. |
48
+ | Backwards-compat | No status file → `yoke loop status` behaves exactly as today. Reporter is injectable and defaults to a real impl; existing `runLoop` tests pass a no-op. |
49
+ | Out of scope (YAGNI) | No token metering of nested agents (technically not exposable), no log streaming server, no web dashboard. |
50
+
51
+ ## Architecture
52
+
53
+ All new surface lives in the `loop/` subsystem.
54
+
55
+ ### 1. `src/loop/reporter.ts` (new) — status types + reporter + reader
56
+ ```ts
57
+ type LoopState = 'running' | 'blocked' | 'complete' | 'cap-reached'
58
+ type LoopPhase = 'implementing' | 'verifying' | 'reviewing' | 'committing'
59
+
60
+ interface LoopStatus {
61
+ state: LoopState
62
+ phase?: LoopPhase // only meaningful while state === 'running'
63
+ story?: string
64
+ storyTitle?: string
65
+ reason?: string // populated on 'blocked'
66
+ iteration: number
67
+ progress: { passed: number; total: number }
68
+ startedAt: string // ISO — when the current story/iteration began
69
+ updatedAt: string // ISO — last heartbeat write
70
+ }
71
+
72
+ interface LoopReporter {
73
+ storyStart(story, iteration, progress): void // → state:running, phase:implementing
74
+ phase(phase: LoopPhase): void // → updates phase + updatedAt
75
+ blocked(reason: string): void // → state:blocked
76
+ complete(progress): void // → state:complete
77
+ capReached(progress): void // → state:cap-reached
78
+ }
79
+
80
+ makeReporter(dir, opts?: { quiet?: boolean }, now?: () => Date): LoopReporter
81
+ readStatus(dir): LoopStatus | null
82
+ ```
83
+ The default `makeReporter` writes three places on every event:
84
+ - **`.yoke/loop-status.json`** — the single current `LoopStatus` (overwritten atomically: temp file + rename).
85
+ - **`.yoke/loop.log`** — appends one line: `<ISO> <state/phase> <story> <detail>`.
86
+ - **console** — a human line (suppressed when `quiet`): e.g.
87
+ - `▶ S6-seed-rich (19/45) — implementing…`
88
+ - ` ✓ verified` / ` ✓ reviewed` / ` ✓ committed → 20/45`
89
+ - `■ blocked on S6-seed-rich: verify failed (working tree left dirty — clean before restart)`
90
+
91
+ `now` is injectable for deterministic tests. Timestamps use the Node runtime (`Date`),
92
+ which is available (the loop is not a Workflow script).
93
+
94
+ ### 2. `src/loop/loop.ts` — drive the reporter
95
+ `runLoop` takes an optional `reporter: LoopReporter` in `LoopOptions` (default: a no-op so the
96
+ existing tests are untouched; `run-command` injects the real one). At each boundary it calls:
97
+ `storyStart` before dispatch → `phase('verifying')` before verify → `phase('reviewing')` before
98
+ review → `phase('committing')` before commit → `complete`/`capReached`/`blocked` at terminal
99
+ returns. The **blocked** call's reason is enriched: if the working tree is dirty
100
+ (`opts.git.isClean(targetDir) === false`) after a block, append
101
+ `" (working tree has uncommitted changes from the blocked story — review/clean before re-running)"`.
102
+ This is the S5 leftover case made explicit.
103
+
104
+ ### 3. `src/loop/watchdog.ts` (new) — idle-timeout wrapper
105
+ A tiny standalone CLI: `node watchdog.js --idle-ms=<N> -- <command> [args...]`.
106
+ - Spawns `<command>` with piped stdio. Forwards its own stdin to the child (so the prompt still
107
+ reaches `claude -p`) and the child's stdout/stderr to its own (so live output still reaches
108
+ the user — the feedback channel).
109
+ - Maintains an idle timer reset on **every** stdout/stderr chunk. On expiry it kills the child
110
+ (SIGTERM, then SIGKILL after a short grace; on win32 `taskkill /pid /t /f` for the tree) and
111
+ exits **124** (timeout convention). Otherwise it exits with the child's own exit code.
112
+ - `--idle-ms=0` means no watchdog (spawn-through with no timer).
113
+ All the async/stream complexity lives here, isolated and unit-testable. Nothing else in the
114
+ loop becomes async.
115
+
116
+ ### 4. `src/loop/runner.ts` — run the agent through the watchdog
117
+ `Invocation` gains an optional `idleTimeoutMs?: number`. When set (>0), `runCli` runs the agent
118
+ **through the watchdog**: `node <dist>/loop/watchdog.js --idle-ms=<N> -- <command> <args...>`,
119
+ with the prompt still piped via stdin. `execSync` blocks on the watchdog (runner stays
120
+ synchronous). A watchdog exit of 124 (or any non-zero) is caught as today →
121
+ `{ success: false, summary: 'no output for Nm — treated as hung' }` → the loop blocks. When
122
+ `idleTimeoutMs` is unset/0, the agent runs directly as before. `makeRunner`/`makeReviewRunner`
123
+ accept and thread `idleTimeoutMs`; the reviewer run uses the same budget.
124
+
125
+ ### 5. `src/loop/run-command.ts` — wire + upgrade `loop status`
126
+ - `runLoopCommand` resolves the idle timeout (`--timeout` flag > `config.loop.timeoutMinutes` >
127
+ default 20 minutes; `0` disables), builds the real `makeReporter(targetDir)`, builds runners
128
+ with the resolved `idleTimeoutMs`, and passes the reporter into `runLoop`.
129
+ - `loopStatus(targetDir)` reads `readStatus(targetDir)`. If present, it renders state + phase +
130
+ story + title + reason + iteration + a relative `updatedAt`, and — when `state==='running'`
131
+ and `updatedAt` is older than the timeout — a `possibly stuck (no update in Nm)` hint. If
132
+ absent, it falls back to today's `enabled + PRD progress` output verbatim.
133
+
134
+ ### 6. `src/retrofit/config.ts` — optional config field
135
+ `loop.timeoutMinutes?: number` (idle minutes) added to the schema (optional, backwards-compatible).
136
+
137
+ ### 7. `src/cli.ts` — flag + gitignore note
138
+ Parse `--timeout=<minutes>` on `yoke loop run`. `.yoke/loop-status.json` and `.yoke/loop.log`
139
+ are runtime artifacts — ensure the retrofit gitignore covers them (or document that they are
140
+ local-only). They must NOT block the clean-tree gate: the loop writes them under `.yoke/`,
141
+ which retrofit already gitignores for `worktrees`/`backup`; extend that to these two files.
142
+
143
+ ## Data flow (one iteration)
144
+ ```
145
+ storyStart(S6) ─► [console ▶ / status running:implementing / log]
146
+ runner(idle-watchdog) ─► phase(verifying) ─► verify ─► phase(reviewing) ─► [review]
147
+ ─► phase(committing) ─► appendDecision ─► savePrd(passes) ─► commitAll
148
+ ─► [console ✓ committed → 20/45]
149
+ on any failure ─► blocked(reason + leftover-hint) ─► [console ■ / status blocked / log] ─► return
150
+ ```
151
+
152
+ ## Error handling
153
+ - Status writes are best-effort and atomic (temp + rename); a write failure never aborts the
154
+ loop (wrapped, logged to console, swallowed) — observability must not break execution.
155
+ - Timeout kills the child and surfaces as `blocked`; the clean-tree gate + leftover hint guard
156
+ the restart.
157
+ - `readStatus` on a missing/corrupt file returns `null` → `loop status` falls back gracefully.
158
+
159
+ ## Testing (subagent-driven TDD, like A–F)
160
+ - **reporter.ts:** status round-trip (write→read); missing file → null; each event sets the
161
+ right state/phase; `loop.log` appends one line per event; `quiet` suppresses console;
162
+ injected `now` makes timestamps deterministic; atomic write leaves no temp file behind.
163
+ - **loop.ts:** reporter receives `storyStart`/`phase`/`complete` in order on success;
164
+ `blocked` with reason on a failed verify; leftover hint appended when `git.isClean` is false
165
+ on block; existing loop tests still pass with the default no-op reporter.
166
+ - **watchdog.ts:** wrapping a child that keeps emitting output past the idle window is **not**
167
+ killed (proves slow-but-working survives); wrapping a silent child that outputs nothing is
168
+ killed after the idle window and exits 124; a fast child passes its exit code through; stdin
169
+ is forwarded to the child; `--idle-ms=0` never kills. (Use tiny `node -e` children with short
170
+ idle windows for deterministic, fast tests.)
171
+ - **runner.ts:** when `idleTimeoutMs>0` the invocation runs through the watchdog wrapper (assert
172
+ the built command); when unset/0 it runs the agent directly; resolution order flag>config>20.
173
+ - **run-command.ts:** `loopStatus` renders state+phase+reason when a status file exists; falls
174
+ back to PRD-only when absent; `--timeout` parsed and forwarded.
175
+ - **config.ts:** `timeoutMinutes` accepted and optional.
176
+
177
+ ## What this would have done for the incident
178
+ `yoke loop status .` →
179
+ ```
180
+ Loop: BLOCKED on S5-segment-schemas "All 9 segment attribute schemas…"
181
+ phase: verifying · iteration 19 · 18/45 · last update 5h ago
182
+ reason: story did not verify (working tree has uncommitted changes — clean before restart)
183
+ ```
184
+ …instead of `18/45`. And a true hang (no agent output at all) would self-terminate after 20
185
+ minutes of silence as `blocked` — while a genuinely slow story that keeps streaming progress
186
+ runs as long as it needs.