rungate 0.7.0 → 0.8.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 (63) hide show
  1. package/hooks/ActionVerificationGate.hook.ts +96 -0
  2. package/hooks/AgentBriefGuard.hook.ts +38 -0
  3. package/hooks/AgentVerdictCapture.hook.ts +87 -0
  4. package/hooks/AutoVerifyGate.hook.ts +79 -0
  5. package/hooks/BashToolGuard.hook.ts +65 -0
  6. package/hooks/BashWriteGuard.hook.ts +60 -0
  7. package/hooks/CommitEnforcement.hook.ts +130 -0
  8. package/hooks/DocHygiene.hook.ts +148 -0
  9. package/hooks/GateEnforcement.hook.ts +58 -0
  10. package/hooks/GateResultProtection.hook.ts +69 -0
  11. package/hooks/HarnessAFKGate.hook.ts +85 -0
  12. package/hooks/HookCurrency.hook.ts +99 -0
  13. package/hooks/IssueCloseGuard.hook.ts +149 -0
  14. package/hooks/MergeGuard.hook.ts +58 -0
  15. package/hooks/PostCompact.hook.ts +60 -0
  16. package/hooks/ProjectStateSync.hook.ts +103 -0
  17. package/hooks/SkillGuard.hook.ts +69 -0
  18. package/hooks/SpecConformityTrigger.hook.ts +43 -0
  19. package/hooks/SpecSCGuard.hook.ts +123 -0
  20. package/hooks/StaleTTLCleanup.hook.ts +141 -0
  21. package/hooks/TaskCompleted.hook.ts +51 -0
  22. package/hooks/TeamInit.hook.ts +85 -0
  23. package/hooks/TestSuiteGuard.hook.ts +70 -0
  24. package/hooks/TestSuiteRelease.hook.ts +85 -0
  25. package/hooks/TopLevelCdGuard.hook.ts +108 -0
  26. package/hooks/VerifyPhaseLock.hook.ts +84 -0
  27. package/hooks/WorkflowStateGuard.hook.ts +40 -0
  28. package/hooks/lib/agent-config.json +9 -0
  29. package/hooks/lib/agentDetection.ts +201 -0
  30. package/hooks/lib/comment-template.ts +86 -0
  31. package/hooks/lib/findWorkflow.ts +101 -0
  32. package/hooks/lib/parseStdin.ts +37 -0
  33. package/hooks/lib/paths.ts +111 -0
  34. package/hooks/lib/utils.ts +338 -0
  35. package/lib/affected-tests.ts +29 -0
  36. package/lib/bash-write-guard.ts +373 -0
  37. package/lib/branch-cleanup.ts +279 -7
  38. package/lib/config-trackable.ts +9 -0
  39. package/lib/distribution-currency.ts +55 -5
  40. package/lib/failure-intake.ts +7 -1
  41. package/lib/gate-enforcement.ts +222 -28
  42. package/lib/gate-names.ts +72 -0
  43. package/lib/gate-result-protection.ts +427 -0
  44. package/lib/intake-sources.ts +380 -0
  45. package/lib/late-env-spawn.ts +331 -0
  46. package/lib/launch-base.ts +128 -5
  47. package/lib/paths.ts +96 -3
  48. package/lib/phase2-decomposition.ts +1 -1
  49. package/lib/published-artifact.ts +162 -18
  50. package/lib/sc-id-cross-tree.ts +84 -8
  51. package/lib/scaffold/ai-review-findings.ts +7 -1
  52. package/lib/scaffold/ai-review-step.ts +861 -116
  53. package/lib/scaffold/defaults.ts +82 -1
  54. package/lib/scaffold/steps.ts +436 -44
  55. package/lib/security-verdict.ts +1 -1
  56. package/lib/shell-path-interpolation.ts +594 -0
  57. package/lib/text-dependents.ts +875 -0
  58. package/lib/workflow-security.ts +29 -0
  59. package/lib/workflow-taint.ts +732 -0
  60. package/lib/worktree-cleanup.ts +65 -38
  61. package/lib/worktree-repo.ts +32 -2
  62. package/package.json +3 -1
  63. package/scripts/check-installed-hook-currency.ts +825 -0
@@ -43,7 +43,36 @@ export interface HookRegistration {
43
43
  scope: "project" | "user";
44
44
  matcher?: string;
45
45
  description: string;
46
- deployToConsumers?: boolean;
46
+ /**
47
+ * Whether a scaffolded consumer project receives this hook (#1047).
48
+ *
49
+ * Required, and for the same reason `scope` is. Before #1047 this was
50
+ * optional and `deployHooksToConsumers` tested it with `!== true`, so
51
+ * "decided no" and "nobody looked" were one value — `undefined` — and all
52
+ * twenty entries held it. The deployment path built for SC-472 was wired
53
+ * into three scaffold modules and reached zero hooks on every run that has
54
+ * ever happened, and the run reported success, because zero deployed is
55
+ * what a project wanting no hooks also looks like.
56
+ *
57
+ * An optional field cannot carry that decision: the next hook added would
58
+ * default to `false` silently, which is the state this issue was filed
59
+ * about. `test/hook-traceability.test.ts` AC-10 refuses an entry that omits
60
+ * it, so the fourth position a new hook has to touch now has an answer that
61
+ * someone wrote down.
62
+ */
63
+ deployToConsumers: boolean;
64
+ /**
65
+ * Why a `deployToConsumers: false` entry does not travel. Required when it
66
+ * is false (#1047 AC-11), mirroring `disabledReason` below.
67
+ *
68
+ * Two different facts hide under `false`, and the reason is the only place
69
+ * they are told apart: a hook about THIS repository's shared checkout,
70
+ * worktree pool or swarm, which no consumer should ever receive; and a hook
71
+ * coupled to something a consumer does not have yet — specs, an issue
72
+ * tracker, a gate salt — which ships in the tarball and is registered once
73
+ * the project has the thing it guards.
74
+ */
75
+ notDeployedReason?: string;
47
76
  /**
48
77
  * Why an `enabled: false` entry is off. Required when it is (#479 SC-1662).
49
78
  *
@@ -128,6 +157,7 @@ export function buildDefaultHooks(): HookRegistration[] {
128
157
  hookFor: "PreToolUse",
129
158
  command: "bun ${RUNGATE_HOOKS_DIR}/BashToolGuard.hook.ts",
130
159
  enabled: true,
160
+ deployToConsumers: true,
131
161
  scope: "user",
132
162
  matcher: "Bash",
133
163
  description: "Blocks cat/head/tail file reading — agents must use the Read tool",
@@ -137,15 +167,34 @@ export function buildDefaultHooks(): HookRegistration[] {
137
167
  hookFor: "PreToolUse",
138
168
  command: "bun ${RUNGATE_HOOKS_DIR}/TestSuiteGuard.hook.ts",
139
169
  enabled: true,
170
+ deployToConsumers: true,
140
171
  scope: "user",
141
172
  matcher: "Bash",
142
173
  description: "Blocks a third full test suite run in one session — forces targeted tests",
143
174
  },
175
+ {
176
+ // Paired with TestSuiteGuard above, and added here by #1047 because the
177
+ // pair is one mechanism. The guard takes a concurrency slot; this hands
178
+ // it back when the suite exits. A greenfield project given the guard
179
+ // alone gets every slot held for the full 420s TTL after a run that
180
+ // finished in 190 — strictly worse than receiving neither, and the
181
+ // classification pass that set `deployToConsumers` on the guard is what
182
+ // made the one-sidedness visible.
183
+ name: "TestSuiteRelease",
184
+ hookFor: "PostToolUse",
185
+ command: "bun ${RUNGATE_HOOKS_DIR}/TestSuiteRelease.hook.ts",
186
+ enabled: true,
187
+ deployToConsumers: true,
188
+ scope: "user",
189
+ matcher: "Bash",
190
+ description: "Hands a full suite its concurrency slot back when it finishes (#67)",
191
+ },
144
192
  {
145
193
  name: "AgentBriefGuard",
146
194
  hookFor: "PreToolUse",
147
195
  command: "bun ${RUNGATE_HOOKS_DIR}/AgentBriefGuard.hook.ts",
148
196
  enabled: true,
197
+ deployToConsumers: true,
149
198
  scope: "project",
150
199
  matcher: "Agent",
151
200
  description: "Validates agent brief templates and enforces the ship-active marker",
@@ -155,6 +204,7 @@ export function buildDefaultHooks(): HookRegistration[] {
155
204
  hookFor: "SubagentStop",
156
205
  command: "bun ${RUNGATE_HOOKS_DIR}/AgentVerdictCapture.hook.ts",
157
206
  enabled: true,
207
+ deployToConsumers: true,
158
208
  scope: "user",
159
209
  description: "Captures agent verdicts and writes them to workflow-state.json",
160
210
  },
@@ -163,6 +213,7 @@ export function buildDefaultHooks(): HookRegistration[] {
163
213
  hookFor: "PostToolUse",
164
214
  command: "bun ${RUNGATE_HOOKS_DIR}/AutoVerifyGate.hook.ts",
165
215
  enabled: true,
216
+ deployToConsumers: true,
166
217
  scope: "user",
167
218
  matcher: "Agent",
168
219
  description: "Nudges the DA to run the verify gate after an agent completes",
@@ -172,6 +223,7 @@ export function buildDefaultHooks(): HookRegistration[] {
172
223
  hookFor: "PostToolUse",
173
224
  command: "bun ${RUNGATE_HOOKS_DIR}/CommitEnforcement.hook.ts",
174
225
  enabled: true,
226
+ deployToConsumers: true,
175
227
  scope: "user",
176
228
  matcher: "Agent",
177
229
  description: "Detects uncommitted changes left behind in agent worktrees",
@@ -181,6 +233,7 @@ export function buildDefaultHooks(): HookRegistration[] {
181
233
  hookFor: "PreToolUse",
182
234
  command: "bun ${RUNGATE_HOOKS_DIR}/GateEnforcement.hook.ts",
183
235
  enabled: true,
236
+ deployToConsumers: true,
184
237
  scope: "user",
185
238
  matcher: ".*",
186
239
  description: "Nags on gate failures and blocks Skill calls after max strikes",
@@ -190,14 +243,42 @@ export function buildDefaultHooks(): HookRegistration[] {
190
243
  hookFor: "PostCompact",
191
244
  command: "bun ${RUNGATE_HOOKS_DIR}/PostCompact.hook.ts",
192
245
  enabled: true,
246
+ deployToConsumers: true,
193
247
  scope: "user",
194
248
  description: "Re-injects critical rules after context window compaction",
195
249
  },
196
250
  {
251
+ // NOT deployed, and the description below is why the first pass got it
252
+ // wrong: it says "stale workflow-state.json and ship-active files", and
253
+ // the hook's first screen agrees. The branch deletion is sixty lines
254
+ // down behind an `await import`. See `notDeployedReason` on this entry
255
+ // in `.claude/rungate/hooks.json` for the full reading and for the two
256
+ // things that would have to change before it could be reconsidered.
257
+ //
258
+ // Short form: at every SessionStart it runs
259
+ // `cleanupStaleBranches({maxAgeDays: 7})`, which issues
260
+ // `git push origin --delete` per stale branch, gated by an open-PR
261
+ // check that `lib/branch-cleanup.ts` USED to default to the slug
262
+ // `hornjason/pai-harness` — so on a consumer the guard asked about THIS
263
+ // repository and could never say stop. A classification made by reading
264
+ // a hook's header is not a classification; follow the dynamic imports.
265
+ //
266
+ // #1079 closed the slug half: the slug is resolved from the project's
267
+ // own `origin` and an unresolvable one REFUSES the delete, and the arm
268
+ // is disarmed unless `RUNGATE_BRANCH_CLEANUP=1`. That is necessary and
269
+ // not sufficient — the worktree, scratch-dir and orphan-reaper arms of
270
+ // this same hook have never been separately cleared for consumer use.
197
271
  name: "StaleTTLCleanup",
198
272
  hookFor: "SessionStart",
199
273
  command: "bun ${RUNGATE_HOOKS_DIR}/StaleTTLCleanup.hook.ts",
200
274
  enabled: true,
275
+ deployToConsumers: false,
276
+ notDeployedReason:
277
+ "HARNESS-ONLY. Can delete remote branches at SessionStart via cleanupStaleBranches. " +
278
+ "#1079 removed the slug default that made the open-PR guard ask about THIS repository " +
279
+ "on a consumer, and disarmed the arm behind RUNGATE_BRANCH_CLEANUP — necessary, not " +
280
+ "sufficient. Its worktree, scratch-dir and orphan-reaper arms have never been cleared " +
281
+ "for consumer use and need their own reading. See the registry entry.",
201
282
  scope: "user",
202
283
  description: "Cleans up stale workflow-state.json and ship-active files",
203
284
  },