@haposoft/cafekit 0.16.0-rc.7 → 0.16.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 (299) hide show
  1. package/README.md +116 -27
  2. package/bin/__tests__/codex-hooks-ownership.test.js +239 -0
  3. package/bin/__tests__/codex-hooks.test.js +295 -0
  4. package/bin/__tests__/codex-native.test.js +2289 -34
  5. package/bin/__tests__/develop-contract.test.js +400 -23
  6. package/bin/__tests__/installer-safety.test.js +3 -3
  7. package/bin/__tests__/optional-skill-inventory.test.js +249 -0
  8. package/bin/__tests__/output-styles.test.js +214 -0
  9. package/bin/__tests__/package-inventory.test.js +2131 -16
  10. package/bin/__tests__/runtime-schema.test.js +111 -0
  11. package/bin/__tests__/secret-output-guardrail.test.js +122 -0
  12. package/bin/__tests__/skill-routing-source.test.js +172 -0
  13. package/bin/__tests__/specs-v2-execution-closeout.test.js +1 -1
  14. package/bin/install.js +10 -0
  15. package/bin/lib/codex-install.js +170 -5
  16. package/bin/lib/context.js +14 -0
  17. package/bin/lib/i18n.js +12 -6
  18. package/bin/lib/skill-deps.js +5 -5
  19. package/bin/phases/claude-runtime.js +23 -0
  20. package/bin/phases/claude-settings.js +8 -0
  21. package/bin/phases/codex-hooks.js +156 -0
  22. package/bin/phases/codex-runtime.js +29 -38
  23. package/bin/phases/copy-payload.js +8 -2
  24. package/bin/phases/select-skill-bundles.js +96 -0
  25. package/bin/phases/skill-inventory.js +71 -0
  26. package/bin/phases/skills-setup.js +9 -2
  27. package/bin/phases/write-metadata.js +8 -5
  28. package/package.json +8 -2
  29. package/src/claude/CLAUDE.md +3 -3
  30. package/src/claude/agents/brainstormer.md +52 -69
  31. package/src/claude/agents/code-auditor.md +32 -14
  32. package/src/claude/agents/debugger.md +35 -20
  33. package/src/claude/agents/deployer.md +12 -5
  34. package/src/claude/agents/docs-keeper.md +11 -1
  35. package/src/claude/agents/implementer.md +25 -13
  36. package/src/claude/agents/inspector.md +6 -3
  37. package/src/claude/agents/project-manager.md +1 -1
  38. package/src/claude/agents/researcher.md +26 -55
  39. package/src/claude/agents/spec-maker.md +24 -13
  40. package/src/claude/agents/strategist.md +52 -0
  41. package/src/claude/agents/test-runner.md +117 -132
  42. package/src/claude/agents/ui-ux-designer.md +1 -1
  43. package/src/claude/hooks/__tests__/fixtures/statusline-default.golden +1 -0
  44. package/src/claude/hooks/__tests__/precompact.test.js +158 -0
  45. package/src/claude/hooks/__tests__/spec-gate.test.js +87 -4
  46. package/src/claude/hooks/__tests__/state.test.js +254 -3
  47. package/src/claude/hooks/__tests__/statusline.test.js +196 -0
  48. package/src/claude/hooks/agent.cjs +1 -1
  49. package/src/claude/hooks/docs-sync.cjs +12 -10
  50. package/src/claude/hooks/inspect-block.cjs +1 -1
  51. package/src/claude/hooks/lib/config.cjs +3 -0
  52. package/src/claude/hooks/lib/hook-state-dir.cjs +39 -0
  53. package/src/claude/hooks/lib/secret-keywords.cjs +42 -0
  54. package/src/claude/hooks/precompact.cjs +105 -0
  55. package/src/claude/hooks/rules.cjs +1 -1
  56. package/src/claude/hooks/secret-output-guardrail.cjs +43 -0
  57. package/src/claude/hooks/session.cjs +27 -1
  58. package/src/claude/hooks/spec-gate.cjs +3 -3
  59. package/src/claude/hooks/spec-state.cjs +32 -5
  60. package/src/claude/hooks/state.cjs +1 -1
  61. package/src/claude/hooks/task-scaffold-guard.cjs +1 -1
  62. package/src/claude/hooks/usage.cjs +1 -1
  63. package/src/claude/migration-manifest.json +29 -15
  64. package/src/claude/output-styles/coding-level-0-eli5.md +103 -0
  65. package/src/claude/output-styles/coding-level-1-junior.md +124 -0
  66. package/src/claude/output-styles/coding-level-2-mid.md +146 -0
  67. package/src/claude/output-styles/coding-level-3-senior.md +148 -0
  68. package/src/claude/output-styles/coding-level-4-lead.md +159 -0
  69. package/src/claude/output-styles/coding-level-5-god.md +91 -0
  70. package/src/claude/references/debugger/core-philosophy.md +5 -3
  71. package/src/claude/references/debugger/frontend-verification.md +2 -2
  72. package/src/claude/references/debugger/log-ci-analysis.md +13 -1
  73. package/src/claude/references/debugger/parallel-agent-hydration.md +19 -34
  74. package/src/claude/references/debugger/performance-diagnostics.md +2 -2
  75. package/src/claude/references/debugger/root-cause-tracing.md +37 -6
  76. package/src/claude/references/debugger/side-effect-gate.md +3 -1
  77. package/src/claude/references/debugger/verification-protocol.md +13 -12
  78. package/src/claude/rules/orchestrator.md +7 -1
  79. package/src/claude/rules/process-management.md +39 -0
  80. package/src/claude/rules/review-audit-self-decision.md +48 -0
  81. package/src/claude/rules/skill-domain-routing.md +26 -24
  82. package/src/claude/rules/skill-workflow-routing.md +22 -14
  83. package/src/claude/rules/workflow.md +3 -3
  84. package/src/claude/runtime.json +1 -0
  85. package/src/claude/runtime.schema.json +205 -0
  86. package/src/claude/scripts/generate-skill-catalog.cjs +156 -122
  87. package/src/claude/scripts/provenance.cjs +18 -5
  88. package/src/claude/scripts/spec-receipt.cjs +76 -21
  89. package/src/claude/scripts/spec-resolver.cjs +144 -4
  90. package/src/claude/scripts/workflow-policy.cjs +1 -1
  91. package/src/claude/settings/settings.json +16 -0
  92. package/src/claude/skills/agent-browser/SKILL.md +1 -1
  93. package/src/claude/skills/ai-multimodal/SKILL.md +1 -1
  94. package/src/claude/skills/brainstorm/SKILL.md +193 -172
  95. package/src/claude/skills/brainstorm/references/question-framework.md +105 -167
  96. package/src/claude/skills/chrome-devtools/SKILL.md +1 -1
  97. package/src/claude/skills/code-review/SKILL.md +43 -25
  98. package/src/claude/skills/code-review/references/spec-compliance-review.md +3 -4
  99. package/src/claude/skills/code-review/references/verification-gate.md +1 -1
  100. package/src/claude/skills/debug/SKILL.md +48 -19
  101. package/src/claude/skills/delegate/SKILL.md +1 -1
  102. package/src/claude/skills/develop/SKILL.md +92 -65
  103. package/src/claude/skills/develop/references/parallel-waves.md +36 -63
  104. package/src/claude/skills/develop/references/quality-gate.md +31 -4
  105. package/src/claude/skills/develop/references/subagent-patterns.md +21 -7
  106. package/src/claude/skills/docs/SKILL.md +42 -23
  107. package/src/claude/skills/docs/references/init-workflow.md +4 -4
  108. package/src/claude/skills/docs/references/reconstruct-workflow.md +6 -6
  109. package/src/claude/skills/docs/references/standard-docs-workflow.md +6 -2
  110. package/src/claude/skills/docs/references/summarize-workflow.md +2 -2
  111. package/src/claude/skills/docs/references/update-workflow.md +9 -7
  112. package/src/claude/skills/docs/templates/requirements-as-is.md +1 -1
  113. package/src/claude/skills/docx/SKILL.md +1 -1
  114. package/src/claude/skills/git/SKILL.md +1 -1
  115. package/src/claude/skills/git/references/commit-protocols.md +1 -1
  116. package/src/claude/skills/git/references/finish-branch.md +1 -1
  117. package/src/claude/skills/hotfix/SKILL.md +159 -170
  118. package/src/claude/skills/hotfix/references/diagnosis-protocol.md +14 -9
  119. package/src/claude/skills/hotfix/references/parallel-patterns.md +27 -13
  120. package/src/claude/skills/hotfix/references/prevention-gate.md +5 -0
  121. package/src/claude/skills/hotfix/references/review-cycle.md +21 -15
  122. package/src/claude/skills/hotfix/references/workflow-specialized.md +53 -21
  123. package/src/claude/skills/inspect/SKILL.md +55 -46
  124. package/src/claude/skills/inspect/references/internal-inspection.md +21 -5
  125. package/src/claude/skills/loop/SKILL.md +114 -0
  126. package/src/claude/skills/loop/references/bounded-loop-protocol.md +104 -0
  127. package/src/claude/skills/loop/references/metric-and-guard-contract.md +76 -0
  128. package/src/claude/skills/pdf/SKILL.md +1 -1
  129. package/src/claude/skills/pptx/SKILL.md +1 -1
  130. package/src/claude/skills/question/SKILL.md +16 -13
  131. package/src/claude/skills/research/SKILL.md +70 -43
  132. package/src/claude/skills/route/SKILL.md +94 -0
  133. package/src/claude/skills/route/references/agent-timing.md +46 -0
  134. package/src/claude/skills/route/references/chaining-patterns.md +53 -0
  135. package/src/claude/skills/route/references/task-taxonomy.md +48 -0
  136. package/src/claude/skills/specs/SKILL.md +48 -57
  137. package/src/claude/skills/specs/references/review.md +26 -8
  138. package/src/claude/skills/specs/references/templates.md +76 -31
  139. package/src/claude/skills/specs/templates/requirements-init.md +1 -1
  140. package/src/claude/skills/specs/templates/research.md +2 -2
  141. package/src/claude/skills/sync/SKILL.md +6 -6
  142. package/src/claude/skills/sync/references/sync-protocols.md +1 -1
  143. package/src/claude/skills/test/SKILL.md +120 -120
  144. package/src/claude/skills/test/references/execution-strategy.md +208 -361
  145. package/src/claude/skills/test/references/failure-triage.md +55 -121
  146. package/src/claude/skills/test/references/test-memory.md +20 -34
  147. package/src/claude/skills/ui-ux-pro-max/SKILL.md +1 -1
  148. package/src/claude/skills/web-testing/SKILL.md +1 -1
  149. package/src/claude/skills/xlsx/SKILL.md +1 -1
  150. package/src/claude/status.cjs +135 -33
  151. package/src/codex/AGENTS.md +14 -4
  152. package/src/codex/hooks/docs-sync.cjs +8 -3
  153. package/src/codex/hooks/lib/hook-context.cjs +18 -4
  154. package/src/codex/hooks/rules.cjs +29 -1
  155. package/src/codex/hooks/secret-output-guardrail.cjs +30 -0
  156. package/src/codex/hooks/spec-gate.cjs +3 -8
  157. package/src/codex/hooks/spec-state.cjs +34 -5
  158. package/src/codex/hooks.json +5 -0
  159. package/src/codex/runtime.json +2 -0
  160. package/src/common/.env.example +1 -1
  161. package/src/claude/skills/backend-development/SKILL.md +0 -101
  162. package/src/claude/skills/backend-development/references/backend-api-design.md +0 -495
  163. package/src/claude/skills/backend-development/references/backend-architecture.md +0 -454
  164. package/src/claude/skills/backend-development/references/backend-authentication.md +0 -338
  165. package/src/claude/skills/backend-development/references/backend-code-quality.md +0 -659
  166. package/src/claude/skills/backend-development/references/backend-debugging.md +0 -904
  167. package/src/claude/skills/backend-development/references/backend-devops.md +0 -491
  168. package/src/claude/skills/backend-development/references/backend-mindset.md +0 -387
  169. package/src/claude/skills/backend-development/references/backend-performance.md +0 -397
  170. package/src/claude/skills/backend-development/references/backend-security.md +0 -342
  171. package/src/claude/skills/backend-development/references/backend-technologies.md +0 -256
  172. package/src/claude/skills/backend-development/references/backend-testing.md +0 -429
  173. package/src/claude/skills/devops/.env.example +0 -76
  174. package/src/claude/skills/devops/SKILL.md +0 -102
  175. package/src/claude/skills/devops/references/browser-rendering.md +0 -305
  176. package/src/claude/skills/devops/references/cloudflare-d1-kv.md +0 -123
  177. package/src/claude/skills/devops/references/cloudflare-platform.md +0 -271
  178. package/src/claude/skills/devops/references/cloudflare-r2-storage.md +0 -280
  179. package/src/claude/skills/devops/references/cloudflare-workers-advanced.md +0 -312
  180. package/src/claude/skills/devops/references/cloudflare-workers-apis.md +0 -309
  181. package/src/claude/skills/devops/references/cloudflare-workers-basics.md +0 -418
  182. package/src/claude/skills/devops/references/docker-basics.md +0 -297
  183. package/src/claude/skills/devops/references/docker-compose.md +0 -292
  184. package/src/claude/skills/devops/references/gcloud-platform.md +0 -297
  185. package/src/claude/skills/devops/references/gcloud-services.md +0 -304
  186. package/src/claude/skills/devops/references/kubernetes-basics.md +0 -95
  187. package/src/claude/skills/devops/references/kubernetes-helm-advanced.md +0 -70
  188. package/src/claude/skills/devops/references/kubernetes-helm.md +0 -81
  189. package/src/claude/skills/devops/references/kubernetes-kubectl.md +0 -74
  190. package/src/claude/skills/devops/references/kubernetes-security-advanced.md +0 -94
  191. package/src/claude/skills/devops/references/kubernetes-security.md +0 -89
  192. package/src/claude/skills/devops/references/kubernetes-troubleshooting-advanced.md +0 -74
  193. package/src/claude/skills/devops/references/kubernetes-troubleshooting.md +0 -49
  194. package/src/claude/skills/devops/references/kubernetes-workflows-advanced.md +0 -75
  195. package/src/claude/skills/devops/references/kubernetes-workflows.md +0 -76
  196. package/src/claude/skills/devops/scripts/cloudflare_deploy.py +0 -269
  197. package/src/claude/skills/devops/scripts/docker_optimize.py +0 -332
  198. package/src/claude/skills/devops/scripts/requirements.txt +0 -20
  199. package/src/claude/skills/devops/scripts/tests/requirements.txt +0 -3
  200. package/src/claude/skills/devops/scripts/tests/test_cloudflare_deploy.py +0 -285
  201. package/src/claude/skills/devops/scripts/tests/test_docker_optimize.py +0 -436
  202. package/src/claude/skills/frontend-design/SKILL.md +0 -135
  203. package/src/claude/skills/frontend-design/references/ai-multimodal-overview.md +0 -165
  204. package/src/claude/skills/frontend-design/references/analysis-best-practices.md +0 -80
  205. package/src/claude/skills/frontend-design/references/analysis-prompts.md +0 -141
  206. package/src/claude/skills/frontend-design/references/analysis-techniques.md +0 -118
  207. package/src/claude/skills/frontend-design/references/animejs.md +0 -396
  208. package/src/claude/skills/frontend-design/references/anti-slop-rules.md +0 -103
  209. package/src/claude/skills/frontend-design/references/asset-generation.md +0 -337
  210. package/src/claude/skills/frontend-design/references/bento-motion-engine.md +0 -142
  211. package/src/claude/skills/frontend-design/references/design-extraction-overview.md +0 -71
  212. package/src/claude/skills/frontend-design/references/extraction-best-practices.md +0 -141
  213. package/src/claude/skills/frontend-design/references/extraction-output-templates.md +0 -162
  214. package/src/claude/skills/frontend-design/references/extraction-prompts.md +0 -127
  215. package/src/claude/skills/frontend-design/references/magicui-components.md +0 -129
  216. package/src/claude/skills/frontend-design/references/performance-guardrails.md +0 -169
  217. package/src/claude/skills/frontend-design/references/premium-design-patterns.md +0 -93
  218. package/src/claude/skills/frontend-design/references/redesign-audit-checklist.md +0 -114
  219. package/src/claude/skills/frontend-design/references/technical-accessibility.md +0 -119
  220. package/src/claude/skills/frontend-design/references/technical-best-practices.md +0 -97
  221. package/src/claude/skills/frontend-design/references/technical-optimization.md +0 -44
  222. package/src/claude/skills/frontend-design/references/technical-overview.md +0 -90
  223. package/src/claude/skills/frontend-design/references/technical-workflows.md +0 -150
  224. package/src/claude/skills/frontend-design/references/visual-analysis-overview.md +0 -95
  225. package/src/claude/skills/frontend-design/references/workflow-3d.md +0 -102
  226. package/src/claude/skills/frontend-design/references/workflow-describe.md +0 -87
  227. package/src/claude/skills/frontend-design/references/workflow-immersive.md +0 -87
  228. package/src/claude/skills/frontend-design/references/workflow-quick.md +0 -57
  229. package/src/claude/skills/frontend-design/references/workflow-screenshot.md +0 -63
  230. package/src/claude/skills/frontend-design/references/workflow-video.md +0 -74
  231. package/src/claude/skills/frontend-development/SKILL.md +0 -406
  232. package/src/claude/skills/frontend-development/resources/common-patterns.md +0 -331
  233. package/src/claude/skills/frontend-development/resources/complete-examples.md +0 -872
  234. package/src/claude/skills/frontend-development/resources/component-patterns.md +0 -502
  235. package/src/claude/skills/frontend-development/resources/data-fetching.md +0 -767
  236. package/src/claude/skills/frontend-development/resources/file-organization.md +0 -502
  237. package/src/claude/skills/frontend-development/resources/loading-and-error-states.md +0 -501
  238. package/src/claude/skills/frontend-development/resources/performance.md +0 -406
  239. package/src/claude/skills/frontend-development/resources/routing-guide.md +0 -364
  240. package/src/claude/skills/frontend-development/resources/styling-guide.md +0 -428
  241. package/src/claude/skills/frontend-development/resources/typescript-standards.md +0 -418
  242. package/src/claude/skills/mobile-development/SKILL.md +0 -218
  243. package/src/claude/skills/mobile-development/references/mobile-android.md +0 -604
  244. package/src/claude/skills/mobile-development/references/mobile-best-practices.md +0 -544
  245. package/src/claude/skills/mobile-development/references/mobile-debugging.md +0 -1089
  246. package/src/claude/skills/mobile-development/references/mobile-frameworks.md +0 -465
  247. package/src/claude/skills/mobile-development/references/mobile-ios.md +0 -496
  248. package/src/claude/skills/mobile-development/references/mobile-mindset.md +0 -542
  249. package/src/claude/skills/react-best-practices/AGENTS.md +0 -2249
  250. package/src/claude/skills/react-best-practices/README.md +0 -123
  251. package/src/claude/skills/react-best-practices/SKILL.md +0 -128
  252. package/src/claude/skills/react-best-practices/metadata.json +0 -15
  253. package/src/claude/skills/react-best-practices/rules/_sections.md +0 -46
  254. package/src/claude/skills/react-best-practices/rules/_template.md +0 -28
  255. package/src/claude/skills/react-best-practices/rules/advanced-event-handler-refs.md +0 -55
  256. package/src/claude/skills/react-best-practices/rules/advanced-use-latest.md +0 -49
  257. package/src/claude/skills/react-best-practices/rules/async-api-routes.md +0 -38
  258. package/src/claude/skills/react-best-practices/rules/async-defer-await.md +0 -80
  259. package/src/claude/skills/react-best-practices/rules/async-dependencies.md +0 -36
  260. package/src/claude/skills/react-best-practices/rules/async-parallel.md +0 -28
  261. package/src/claude/skills/react-best-practices/rules/async-suspense-boundaries.md +0 -99
  262. package/src/claude/skills/react-best-practices/rules/bundle-barrel-imports.md +0 -59
  263. package/src/claude/skills/react-best-practices/rules/bundle-conditional.md +0 -31
  264. package/src/claude/skills/react-best-practices/rules/bundle-defer-third-party.md +0 -49
  265. package/src/claude/skills/react-best-practices/rules/bundle-dynamic-imports.md +0 -35
  266. package/src/claude/skills/react-best-practices/rules/bundle-preload.md +0 -50
  267. package/src/claude/skills/react-best-practices/rules/client-event-listeners.md +0 -74
  268. package/src/claude/skills/react-best-practices/rules/client-swr-dedup.md +0 -56
  269. package/src/claude/skills/react-best-practices/rules/js-batch-dom-css.md +0 -82
  270. package/src/claude/skills/react-best-practices/rules/js-cache-function-results.md +0 -80
  271. package/src/claude/skills/react-best-practices/rules/js-cache-property-access.md +0 -28
  272. package/src/claude/skills/react-best-practices/rules/js-cache-storage.md +0 -70
  273. package/src/claude/skills/react-best-practices/rules/js-combine-iterations.md +0 -32
  274. package/src/claude/skills/react-best-practices/rules/js-early-exit.md +0 -50
  275. package/src/claude/skills/react-best-practices/rules/js-hoist-regexp.md +0 -45
  276. package/src/claude/skills/react-best-practices/rules/js-index-maps.md +0 -37
  277. package/src/claude/skills/react-best-practices/rules/js-length-check-first.md +0 -49
  278. package/src/claude/skills/react-best-practices/rules/js-min-max-loop.md +0 -82
  279. package/src/claude/skills/react-best-practices/rules/js-set-map-lookups.md +0 -24
  280. package/src/claude/skills/react-best-practices/rules/js-tosorted-immutable.md +0 -57
  281. package/src/claude/skills/react-best-practices/rules/rendering-activity.md +0 -26
  282. package/src/claude/skills/react-best-practices/rules/rendering-animate-svg-wrapper.md +0 -47
  283. package/src/claude/skills/react-best-practices/rules/rendering-conditional-render.md +0 -40
  284. package/src/claude/skills/react-best-practices/rules/rendering-content-visibility.md +0 -38
  285. package/src/claude/skills/react-best-practices/rules/rendering-hoist-jsx.md +0 -46
  286. package/src/claude/skills/react-best-practices/rules/rendering-hydration-no-flicker.md +0 -82
  287. package/src/claude/skills/react-best-practices/rules/rendering-svg-precision.md +0 -28
  288. package/src/claude/skills/react-best-practices/rules/rerender-defer-reads.md +0 -39
  289. package/src/claude/skills/react-best-practices/rules/rerender-dependencies.md +0 -45
  290. package/src/claude/skills/react-best-practices/rules/rerender-derived-state.md +0 -29
  291. package/src/claude/skills/react-best-practices/rules/rerender-functional-setstate.md +0 -74
  292. package/src/claude/skills/react-best-practices/rules/rerender-lazy-state-init.md +0 -58
  293. package/src/claude/skills/react-best-practices/rules/rerender-memo.md +0 -44
  294. package/src/claude/skills/react-best-practices/rules/rerender-transitions.md +0 -40
  295. package/src/claude/skills/react-best-practices/rules/server-after-nonblocking.md +0 -73
  296. package/src/claude/skills/react-best-practices/rules/server-cache-lru.md +0 -41
  297. package/src/claude/skills/react-best-practices/rules/server-cache-react.md +0 -26
  298. package/src/claude/skills/react-best-practices/rules/server-parallel-fetching.md +0 -79
  299. package/src/claude/skills/react-best-practices/rules/server-serialization.md +0 -38
@@ -4,16 +4,16 @@ How to handle code review results after a fix is implemented. Ensures quality wi
4
4
 
5
5
  ## Default Review Handling
6
6
 
7
- The agent reviews its own fix using `hapo:code-review` and decides automatically. Every review returns exactly one verdict: `PASS | FAIL | BLOCKED`.
7
+ The agent reviews its own fix using `cf:code-review` and applies the verdict. Every review returns exactly one verdict from the shared surface: `PASS | PASS_WITH_WARNINGS | FAIL | BLOCKED`. The definition of `PASS` defers to `cf:code-review`; Fix never redefines it with local severity thresholds.
8
8
 
9
9
  ```
10
10
  attempt = 0
11
11
  LOOP:
12
- 1. Trigger hapo:code-review → receives: verdict and severity-classified findings
12
+ 1. Trigger cf:code-review → receives: verdict and severity-classified findings
13
13
 
14
14
  2. Evaluate:
15
- IF verdict == PASS (no Critical, no High, at most one Medium):
16
- → ACCEPT. Log: "✓ Review PASS — auto-approved"
15
+ IF verdict == PASS:
16
+ → ACCEPT. Log: "✓ Review PASS"
17
17
  → Proceed to Step 6 (Finalize)
18
18
 
19
19
  ELSE IF verdict == BLOCKED:
@@ -21,29 +21,33 @@ LOOP:
21
21
  → Present the blocker and required execution proof, permission, environment,
22
22
  or user-owned decision to the user.
23
23
 
24
- ELSE IF verdict == FAIL AND attempt < 3:
25
- → AUTO-REMEDIATE the reported findings
24
+ ELSE IF (verdict == FAIL OR verdict == PASS_WITH_WARNINGS) AND attempt < 3:
25
+ → REMEDIATE the reported findings (or pause for the user when the
26
+ Required User Pause conditions below apply)
26
27
  → Re-run verification (typecheck + lint + test)
27
28
  → attempt += 1
28
29
  → GOTO LOOP
29
30
 
30
- ELSE IF verdict == FAIL AND attempt >= 3:
31
+ ELSE IF attempt >= 3:
31
32
  → HALT. Present findings to user:
32
- "3 auto-fix cycles exhausted. [N] blocking findings remain."
33
- Options: "Fix manually" | "Approve with known issues" | "Abort"
33
+ "3 auto-fix cycles exhausted. [N] findings remain."
34
+ Options: "Revise scope and re-review" | "Stop incomplete" | "Abort"
34
35
  ```
35
36
 
36
- `BLOCKED` is terminal for this review cycle. Only `FAIL` may enter remediation retry; never retry a blocked review unchanged.
37
+ `BLOCKED` is terminal for this review cycle. Only `FAIL` and `PASS_WITH_WARNINGS` enter remediation retry; neither verdict can enter
38
+ finalization through user approval. If the user changes scope or accepts a
39
+ different contract, update the review target and obtain a fresh literal `PASS`.
40
+ A blocked review is never retried unchanged.
37
41
 
38
42
  ## Required User Pause
39
43
 
40
44
  When the fix touches production-critical code, changes public contracts, introduces a behavior change, or the user explicitly requests review control:
41
45
 
42
- 1. Run `hapo:code-review` → collect verdict + severity findings
46
+ 1. Run `cf:code-review` → collect verdict + severity findings
43
47
  2. Present a structured summary to user:
44
48
  ```
45
49
  ┌──────────────────────────────────┐
46
- │ Review Verdict: [PASS | FAIL | BLOCKED] │
50
+ │ Review Verdict: [verdict] │
47
51
  ├──────────────────────────────────┤
48
52
  │ Critical: [list or "none"] │
49
53
  │ High: [list or "none"] │
@@ -53,9 +57,11 @@ When the fix touches production-critical code, changes public contracts, introdu
53
57
  ```
54
58
  3. Ask user for direction:
55
59
  - If verdict is `BLOCKED` → resolve the blocker; do not retry this review cycle unchanged.
56
- - If verdict is `FAIL` with Critical or High findings → "Fix blocking findings" | "Fix all" | "Approve anyway" | "Abort"
57
- - If verdict is `FAIL` with only Medium/Low findings → "Approve" | "Address findings" | "Abort"
58
- 4. Execute user's choice. Max 3 remediation cycles for `FAIL`; `BLOCKED` never enters this retry limit.
60
+ - If verdict is `FAIL` with Critical or High findings → "Fix blocking findings" | "Fix all" | "Revise scope" | "Abort"
61
+ - If verdict is `FAIL` or `PASS_WITH_WARNINGS` with only Medium/Low findings → "Address findings" | "Revise scope" | "Stop incomplete"
62
+ 4. Execute the user's remediation or scope decision, then re-run verification
63
+ and review. Max 3 remediation cycles for `FAIL` and `PASS_WITH_WARNINGS`;
64
+ only a fresh literal `PASS` enters finalization. `BLOCKED` never enters this retry limit.
59
65
 
60
66
  ## When To Pause vs Continue
61
67
 
@@ -1,6 +1,9 @@
1
1
  # Specialized Workflows
2
2
 
3
- Targeted procedures for common bug categories. Use these as supplements to the main 6-step process (they don't replace it).
3
+ Targeted procedures for common bug categories. Load only the matching section
4
+ after the main workflow has scouted the affected area. Each overlay adds a
5
+ category-specific baseline and completion proof; it never replaces diagnosis,
6
+ the bounded repair frame, or the side-effect gate.
4
7
 
5
8
  ---
6
9
 
@@ -8,14 +11,20 @@ Targeted procedures for common bug categories. Use these as supplements to the m
8
11
 
9
12
  When GitHub Actions or CI/CD is failing:
10
13
 
11
- 1. **Identify the failing job:** `gh run list --status failure -L 5`
12
- 2. **Pull the failure log:** `gh run view <ID> --log-failed`
14
+ 1. **Baseline:** identify the exact failing workflow, job, step, commit, runner,
15
+ and attempt. Preserve the failing command and log excerpt.
16
+ 2. **Inspect safely:** use the project-native CI surface; for GitHub Actions,
17
+ `gh run list --status failure -L 5` and `gh run view <ID> --log-failed` are
18
+ examples, not permission to rerun, cancel, or mutate remote state.
13
19
  3. **Common traps:**
14
20
  - Environment setup step failed silently (DB container didn't start, npm ci cache corrupted)
15
21
  - Secrets/env vars missing in the CI environment
16
22
  - Version mismatch between local Node/Python and CI runner
17
23
  - Flaky tests (passes locally, fails on CI) — check for timezone, file ordering, or race conditions
18
- 4. **Fix pattern:** Reproduce locally first. Never push blind fixes to CI.
24
+ 4. **Proof:** reproduce locally when parity is available, run the affected job
25
+ command, and verify workflow/config syntax. A local pass is not CI proof; if
26
+ a remote rerun is not authorized, report it as unverified. Never push blind
27
+ fixes to CI.
19
28
 
20
29
  ---
21
30
 
@@ -23,11 +32,15 @@ When GitHub Actions or CI/CD is failing:
23
32
 
24
33
  When unit/integration/e2e tests are failing:
25
34
 
26
- 1. **Isolate:** Run the failing test alone: `npx jest --testPathPattern=<file> --verbose`
27
- 2. **Check for pollution:** Does it pass alone but fail in suite? → Test order dependency or shared state leaking
28
- 3. **Check for staleness:** Did the implementation change but the test assertions were not updated?
29
- 4. **Snapshot drift:** If snapshot tests fail, review the diff carefully — is it an intentional change or a regression?
30
- 5. **Flaky async:** Replace arbitrary sleeps with condition-based waits: wait for observable state, DOM condition, network completion, queue drain, or explicit event instead of fixed timeouts.
35
+ 1. **Baseline:** record runner, exact failing command, test name, seed/shard,
36
+ environment, and assertion output. Use the repository's runner rather than
37
+ assuming Jest.
38
+ 2. **Isolate:** run the smallest native selector that preserves the failure.
39
+ 3. **Check for pollution:** Does it pass alone but fail in suite? → Test order dependency or shared state leaking.
40
+ 4. **Check for staleness:** Did implementation behavior intentionally change, or is the assertion exposing a regression? Never weaken the assertion merely to turn the suite green.
41
+ 5. **Snapshot drift:** Review the semantic diff; regenerate only when the changed output is accepted behavior.
42
+ 6. **Flaky async:** Replace arbitrary sleeps with condition-based waits for observable state, DOM condition, network completion, queue drain, or an explicit event.
43
+ 7. **Proof:** show fail-before/pass-after for the regression selector, then run the owning suite and any shared-state/order-sensitive suite.
31
44
 
32
45
  ---
33
46
 
@@ -35,13 +48,17 @@ When unit/integration/e2e tests are failing:
35
48
 
36
49
  When `tsc` is throwing type errors:
37
50
 
38
- 1. **Never** suppress with `any`, `@ts-ignore`, or `as unknown as X` — these are band-aids that rot
39
- 2. **Trace the type chain:** Where was the type originally defined? Follow the generic flow
40
- 3. **Common roots:**
51
+ 1. **Baseline:** record the exact compiler command, diagnostic code, source
52
+ location, and affected type relationship.
53
+ 2. **Never** suppress with `any`, `@ts-ignore`, or `as unknown as X` unless the
54
+ public contract itself explicitly requires an unsafe boundary and the risk is called out.
55
+ 3. **Trace the type chain:** Where was the type originally defined? Follow the generic flow.
56
+ 4. **Common roots:**
41
57
  - Library update changed return types → check CHANGELOG/migration guide
42
58
  - Missing null check → add proper narrowing
43
59
  - Generic type inference failure → provide explicit type argument
44
- 4. **Fix pattern:** Fix the type definition at the source, not at the consumption point
60
+ 5. **Fix pattern:** Fix the owned contract at its source. Do not "fix all" unrelated pre-existing diagnostics outside the blast radius.
61
+ 6. **Proof:** rerun the exact failing compiler command plus tests covering runtime narrowing or serialization behavior affected by the type change.
45
62
 
46
63
  ---
47
64
 
@@ -49,10 +66,17 @@ When `tsc` is throwing type errors:
49
66
 
50
67
  When the interface is broken, misaligned, or not rendering:
51
68
 
52
- 1. **Capture visual evidence:** Use `pushd skills/chrome-devtools/scripts && node screenshot.js --url <url> && popd`
53
- 2. **Check ARIA structure:** `pushd skills/chrome-devtools/scripts && node aria-snapshot.js --url <url> && popd` — reveals hidden overlays, z-index battles
54
- 3. **Check console errors:** `pushd skills/chrome-devtools/scripts && node console.js --url <url> && popd` — catches JS crashes preventing render
55
- 4. **Run frontend verification:** collect screenshot, console, network, accessibility, responsive, and interaction evidence before/after the fix.
69
+ 1. **Baseline:** capture the failing route, viewport, theme, browser/runtime,
70
+ interaction sequence, screenshot, console, and relevant network state with
71
+ the available project/browser tooling.
72
+ 2. **Inspect structure:** compare DOM/ARIA and computed layout at the failing
73
+ element; visual similarity alone does not prove interaction behavior.
74
+ 3. **Trace runtime state:** preserve console errors, hydration warnings, failed
75
+ requests, and state transitions that explain the symptom.
76
+ 4. **Proof:** repeat the exact interaction and compare before/after at the
77
+ failing viewport, then test affected responsive states, keyboard/accessibility
78
+ behavior, console, and network. If the host cannot perform visual interaction,
79
+ report it as unverified instead of inferring a pass from static code.
56
80
  5. **Common traps:**
57
81
  - CSS specificity wars (use browser DevTools or ARIA snapshot to verify computed styles)
58
82
  - Hydration mismatch in SSR frameworks (server HTML differs from client render)
@@ -65,10 +89,18 @@ When the interface is broken, misaligned, or not rendering:
65
89
 
66
90
  When investigating production or server-side log errors:
67
91
 
68
- 1. **Pull wide context:** `tail -n 200 <logfile>` — don't just look at the last error line
69
- 2. **Timestamp correlation:** Cross-reference error timestamps across multiple log sources (app, DB, reverse proxy)
70
- 3. **Pattern recognition:** Is it a single occurrence or repeated? Use `grep -c` to count
71
- 4. **Common traps:**
92
+ 1. **Baseline:** preserve the source, environment, time range, timezone,
93
+ request/trace/job ID, exact error, and surrounding events. Do not expose
94
+ secrets or personal data in reports.
95
+ 2. **Correlate:** normalize timestamps and cross-reference relevant app, DB,
96
+ proxy, queue, or provider logs. Ordering is evidence, not automatic causation.
97
+ 3. **Measure:** establish frequency, first/last occurrence, affected cohort, and
98
+ whether the error is isolated or load-dependent using the available native tools.
99
+ 4. **Proof:** replay a safe deterministic trigger when possible, confirm the
100
+ expected state transition and absence of the same correlated error, then
101
+ verify metrics/alerts or report live recurrence as unverified when observation
102
+ time is insufficient.
103
+ 5. **Common traps:**
72
104
  - Silent exception swallowing upstream (the real error was caught and logged as a warning 50 lines earlier)
73
105
  - Database connection pool exhaustion (errors appear random but correlate with connection count)
74
106
  - Memory leaks (errors start appearing after extended uptime, not immediately)
@@ -1,21 +1,24 @@
1
1
  ---
2
- name: hapo:inspect
3
- description: "Fast codebase discovery using parallel agents. Use for file discovery, task context gathering, quick searches across directories. Supports internal Explore agents."
2
+ name: cf:scout
3
+ description: "Fast scoped codebase discovery using local search first and user-permitted Explore delegation only for broad independent scopes. Use for file discovery, task context, entrypoints, call paths, and blast radius."
4
4
  user-invocable: true
5
- when_to_use: "Invoke for fast parallel codebase discovery and file location."
5
+ when_to_use: "Invoke for fast scoped codebase discovery and file location."
6
6
  category: discovery
7
- keywords: [discovery, search, explore, context]
7
+ keywords: [scout, inspect, discovery, search, context]
8
8
  argument-hint: "[search-target]"
9
9
  metadata:
10
10
  author: haposoft
11
11
  version: "2.1.0"
12
12
  ---
13
- # Inspect
13
+ # Scout
14
14
 
15
- Fast, token-efficient codebase discovery using parallel agents to find files needed for tasks.
15
+ Fast, token-efficient codebase discovery that uses focused local search by default
16
+ and delegates only when parallel scouting has a concrete benefit.
16
17
 
17
18
  ## Arguments
18
- - Default: Inspect using built-in Explore subagents in parallel (`./references/internal-inspection.md`)
19
+ - Default: Scout the named target with local `rg` and targeted reads. For a
20
+ genuinely broad scope, use the conditional delegation route in
21
+ `./references/internal-inspection.md`.
19
22
 
20
23
  ## When to Use
21
24
 
@@ -30,24 +33,29 @@ Before scanning:
30
33
  2. Apply the built-in no-scan lists below.
31
34
  3. Prefer file-type or glob hints whenever possible.
32
35
 
33
- **When scope is too broad:** use a **2-phase approach** — lightweight Structure Scout first, then parallel agents on real sub-scopes.
36
+ **When scope is too broad:** use a **2-phase approach** — lightweight structure
37
+ mapping first, then parallel agents only when the Delegation Gate is open.
34
38
 
35
- ### Phase 1 — Structure Scout (Single Agent, Run First)
39
+ ### Phase 1 — Structure Map
36
40
 
37
- Spawn **one scout** to map top-level layout before dividing work:
41
+ Map the top-level layout in the main agent. A single Explore agent may do this
42
+ only when the Delegation Gate below is already open:
38
43
  1. List immediate children of the scope root (dirs + key config; monorepo markers)
39
44
  2. Rough file count per discovered directory
40
45
  3. Return a division plan of 1–10 logical sub-scopes (path/glob, est. files, focus)
41
46
 
42
- Wait for Scout before Phase 2.
47
+ Complete the structure map before Phase 2.
43
48
 
44
- ### Phase 2 — Parallel Explore Agents (Based on Scout Results)
49
+ ### Phase 2 — Conditional Parallel Explore
45
50
 
46
- 1. Follow Scout's plan; merge scopes < 10 files; split scopes > 100 files
47
- 2. Spawn parallel Explore agents, one per sub-scope
48
- 3. Aggregate into the Inspect Report; offer deeper follow-up on specific areas
51
+ 1. Follow the structure map; merge scopes < 10 files; split scopes > 100 files
52
+ 2. If the Delegation Gate is open, spawn Explore agents on distinct sub-scopes;
53
+ otherwise scout the sub-scopes sequentially in the main agent
54
+ 3. Aggregate into the Scout Report; offer deeper follow-up on specific areas
49
55
 
50
- **Fallback to AskUserQuestion:** if Scout is ambiguous (flat layout, < 3 areas), offer 2–4 concrete scopes from findings, then re-invoke with the chosen scope.
56
+ **Fallback to AskUserQuestion:** if the structure map still leaves multiple
57
+ plausible targets and the choice would materially change the scan, offer 2–4
58
+ concrete scopes from findings, then continue with the selected scope.
51
59
 
52
60
  ## Built-in No-Scan Guidance
53
61
 
@@ -63,50 +71,51 @@ Wait for Scout before Phase 2.
63
71
 
64
72
  ### 1. Analyze Task
65
73
  - Parse search targets; identify directories, patterns, file types
66
- - Determine SCALE of subagents
74
+ - Estimate scan size and whether the work divides into independent scopes
67
75
 
68
- **SCALE Calculation:**
69
- ```
70
- SCALE = ceil(estimated_files_to_scan / 50)
71
- ```
76
+ ### 2. Choose The Smallest Route
72
77
 
73
- - Min SCALE = 1; Max SCALE = 10
74
- - SCALE 1-2: focused (< 100 files)
75
- - SCALE 3-5: medium
76
- - SCALE 6-10: large (internal Explore agents)
78
+ | Condition | Route |
79
+ |---|---|
80
+ | Named files/directories or focused scope (about 50 files or fewer) | Main-agent `rg` plus targeted reads; do not delegate |
81
+ | Medium scope that still fits one coherent search | Main-agent scouting; narrow before considering delegation |
82
+ | Broad scope with two or more independent areas | Structure map, then evaluate the Delegation Gate |
77
83
 
78
- ### 2. Divide and Conquer
79
- - Split into logical segments; assign distinct directories/patterns; no overlap
84
+ Do not use the file estimate alone to justify agents. A focused 100-file search
85
+ may still be cheaper locally; a smaller cross-system search may justify two
86
+ independent scopes.
80
87
 
81
- ### 3. Register Inspect Tasks
82
- - **Skip if:** Agent count ≤ 2
83
- - `TaskList` first; if none, `TaskCreate` per agent with scope metadata
84
- - See `./references/internal-inspection.md` for patterns
88
+ ### 3. Delegation Gate
85
89
 
86
- ### 4. Choose Mode
90
+ Delegate only when all are true:
87
91
 
88
- | Condition | Mode |
89
- |---|---|
90
- | Always | Internal Explore agents |
92
+ - The user explicitly requested or permitted subagents, delegation, or parallel work.
93
+ - The active runtime exposes an Explore/delegation capability.
94
+ - At least two non-overlapping scopes have useful independent work.
91
95
 
92
- Load: **Internal** `./references/internal-inspection.md`.
96
+ If any condition is false, continue in the main agent with scoped `rg`, file
97
+ listing, and targeted reads. Do not ask for delegation merely to complete an
98
+ ordinary focused scout.
93
99
 
94
- ### 5. Spawn Parallel Agents
100
+ ### 4. Divide And Scout
95
101
 
96
- Dispatch native Explore agents with breadth medium/very-thorough + the Scope Gate above. Details: `./references/internal-inspection.md`.
102
+ For local scouting, search the shortlisted scopes sequentially and stop when the
103
+ question is answered. For delegated scouting, load
104
+ `./references/internal-inspection.md`, split by logical boundaries, and ensure
105
+ no overlap.
97
106
 
98
- - `TaskUpdate` each task to `in_progress` before spawn
99
- - Prompt each subagent with exact directories/files; each has < 200K context
100
- - Agent count follows resources + file volume; each returns a summary to the main agent
107
+ - Skip task registration for two or fewer agents.
108
+ - For three or more agents, use the live task/plan surface when available.
109
+ - Prompt each agent with exact directories/files and a read-only boundary.
101
110
 
102
- ### 6. Collect Results
111
+ ### 5. Collect Results
103
112
  - Timeout: 3 minutes per agent (skip non-responders; log in report)
104
- - `TaskUpdate` completed tasks; aggregate; list unresolved questions at end
113
+ - Update live task/plan state when one was used; aggregate; list unresolved questions at end
105
114
 
106
115
  ## Report Format
107
116
 
108
117
  ```markdown
109
- # Inspect Report
118
+ # Scout Report
110
119
 
111
120
  ## Relevant Files
112
121
  - `path/to/file.ts` - Brief description
@@ -121,7 +130,7 @@ Dispatch native Explore agents with breadth medium/very-thorough + the Scope Gat
121
130
 
122
131
  ## Rules
123
132
 
124
- - Keep scope narrow. Do not use `hapo:inspect` as a runtime policy engine.
133
+ - Keep scope narrow. Do not use `cf:scout` as a runtime policy engine.
125
134
  - Prefer listing files first, then reading only the shortlisted files.
126
135
  - Never encourage scanning ignored/generated/sensitive areas from the no-scan list.
127
136
  - Keep reports concise and actionable.
@@ -130,4 +139,4 @@ Dispatch native Explore agents with breadth medium/very-thorough + the Scope Gat
130
139
 
131
140
  ## References
132
141
 
133
- - `./references/internal-inspection.md` - Using Explore subagents
142
+ - `./references/internal-inspection.md` - Conditional Explore delegation
@@ -1,6 +1,19 @@
1
- # Internal Discovery with Explore Subagents
1
+ # Conditional Discovery with Explore Subagents
2
2
 
3
- Dispatch native Explore agents with breadth medium/very-thorough + the Scope Gate in `SKILL.md`. Use when SCALE ≥ 6 or external tools are unavailable.
3
+ Use native Explore agents only after the `SKILL.md` Delegation Gate passes.
4
+ Focused discovery stays in the main agent even when Explore is available.
5
+
6
+ ## Delegation Preconditions
7
+
8
+ All are required:
9
+
10
+ 1. The user explicitly requested or permitted delegation or parallel agents.
11
+ 2. The active runtime exposes an Explore/delegation capability.
12
+ 3. The structure map identifies at least two distinct, non-overlapping scopes
13
+ with useful independent work.
14
+
15
+ If any precondition fails, use scoped `rg`, file listing, and targeted reads in
16
+ the main agent. Do not request extra authority for an ordinary focused scout.
4
17
 
5
18
  ## Agent Tool Configuration
6
19
 
@@ -26,7 +39,9 @@ Report format:
26
39
 
27
40
  ## Spawning Strategy
28
41
 
29
- Split by logical dirs (`src/`, `lib/`, `tests/`, `config/`, `api/`, `types/`). Spawn all in one call; distinct scopes; no overlap.
42
+ Split by logical dirs (`src/`, `lib/`, `tests/`, `config/`, `api/`, `types/`).
43
+ Spawn agents concurrently only when the runtime supports it; keep scopes
44
+ distinct and non-overlapping.
30
45
 
31
46
  **Example** (auth): A1 `src/auth/, middleware/`; A2 `api/, routes/`; A3 `tests/`; A4 `lib/, utils/`; A5 `config/`; A6 `types/`.
32
47
 
@@ -37,7 +52,9 @@ Split by logical dirs (`src/`, `lib/`, `tests/`, `config/`, `api/`, `types/`). S
37
52
  | ≤ 2 | No (overhead) |
38
53
  | ≥ 3 | Yes |
39
54
 
40
- `TaskList` → reuse or `TaskCreate` per agent (`agentType: Explore`, scope, scale, agentIndex, totalAgents, toolMode: internal). Lifecycle: pending → in_progress before spawn → completed on return (timeout: keep in_progress + error metadata).
55
+ Use the live task or plan surface when available. Record scope and ownership
56
+ before spawn, then completion or timeout after collection. Do not create task
57
+ state solely for one or two short probes.
41
58
 
42
59
  ## Timeout, Aggregation, Reading
43
60
 
@@ -51,4 +68,3 @@ Start from concrete directories (not repo root); prefer scoped globs; skip `NO_S
51
68
  ## Output Contract
52
69
 
53
70
  Return: file paths, brief description per file, notable relationships/patterns, unresolved questions.
54
-
@@ -0,0 +1,114 @@
1
+ ---
2
+ name: cf:loop
3
+ description: "Run an explicit, bounded optimization loop against a numeric metric while a separate correctness guard protects the result."
4
+ user-invocable: true
5
+ when_to_use: "Use only when the user explicitly requests measurable iterative optimization and supplies a safe Metric and Guard contract."
6
+ category: utilities
7
+ keywords: [loop, optimization, benchmark, metric, experiment]
8
+ argument-hint: "<goal>"
9
+ metadata:
10
+ author: haposoft
11
+ version: "1.0.0"
12
+ ---
13
+ # Loop — bounded metric optimization
14
+
15
+ Loop is explicit-only. Never auto-route ordinary implementation, debugging, or
16
+ research into Loop. It optimizes one numeric outcome under a separate correctness
17
+ Guard; it does not guarantee improvement or replace Test/Review.
18
+
19
+ Live-agent adherence to this written contract is `[UNPROVEN]` without a host run.
20
+ The safety boundary is cooperative: commands must already be trusted by the user
21
+ or repository. No instruction-only workflow can contain a malicious executable
22
+ without an OS sandbox.
23
+
24
+ ## 1. Preflight before mutation
25
+
26
+ Load `references/metric-and-guard-contract.md` and freeze every field before any
27
+ worktree, process, patch, or file mutation:
28
+
29
+ - Goal and canonical repository root.
30
+ - Scope: contained regular tracked text paths; symlink, untracked, binary, and
31
+ submodule policy. Default is reject each unsupported kind.
32
+ - Pinned base OID plus primary tracked/untracked status. Reject dirty in-scope
33
+ state; record but never import or clean out-of-scope dirt.
34
+ - Metric argv, unit, `higher|lower`, sample count, IEEE-754 binary64 numeric and
35
+ rounding policy, fixed aggregation/noise rule, minimum delta, timeout, and
36
+ reproducible baseline environment.
37
+ - Distinct immutable Guard argv and timeout for code mutation. Metric and Guard
38
+ may not be the same command or validate the same sole outcome.
39
+ - Frozen positive iteration and wall-clock budgets; explicit success,
40
+ no-improvement, drift, failure, timeout, and cancellation stops.
41
+ - Unique run identity, exact disposable root, ownership marker, upfront cleanup
42
+ consent, handoff mode/destination, retention, and cleanup owner.
43
+
44
+ Missing, ambiguous, unsafe, or non-reproducible input returns `BLOCKED` without
45
+ mutation. A subjective score, a metric that can be edited by the loop, or code
46
+ mutation without a distinct Guard is ineligible.
47
+
48
+ ## 2. Establish isolation and baseline
49
+
50
+ Load `references/bounded-loop-protocol.md`. Create a never-reused canonical temp
51
+ root and ownership marker, then add a detached Git worktree at the pinned OID.
52
+ Do not create a branch or commit. Necessary common-Git-dir worktree metadata is
53
+ the only allowed primary-repository metadata effect; primary worktree bytes,
54
+ index, branch, and refs remain untouched.
55
+
56
+ Screen each trusted command as an argv vector and run it with `cwd` fixed to the
57
+ canonical detached root. The executable is a separately approved external
58
+ realpath; only path-valued target arguments must resolve inside the detached
59
+ root. Never use `eval`, `sh -c`, `bash -c`, `zsh -c`,
60
+ `cmd /c`, PowerShell `-Command`, inline interpreter code, Git `-C`, `--git-dir`,
61
+ `--work-tree`, destructive Git operations, path traversal, or an absolute target
62
+ outside the detached root. Use a minimal fixed environment and redact secrets.
63
+
64
+ Capture the complete detached-worktree tracked/untracked manifest before and
65
+ after every Metric and Guard run, subtracting only an exact immutable cache
66
+ allowlist frozen at preflight. Any other oracle mutation is drift. Establish
67
+ baseline samples on pinned bytes before allowing a candidate.
68
+
69
+ ## 3. Iterate one attributable change
70
+
71
+ For every iteration:
72
+
73
+ 1. Create a fresh unique detached worktree from pinned base and apply only the
74
+ accepted-best patch, if one exists. Never restore in place.
75
+ 2. Make exactly one bounded hypothesis change inside Scope. Multiple unrelated
76
+ changes are forbidden. Reject unexpected,
77
+ untracked, binary, symlink, submodule, or out-of-scope bytes.
78
+ 3. Fingerprint candidate bytes, run Metric samples, fingerprint again, then run
79
+ Guard on those identical bytes and fingerprint once more.
80
+ 4. Reject on nonzero exit, timeout, malformed/non-finite/multi-value output,
81
+ oracle mutation, Guard failure, or any source/environment/contract drift.
82
+ 5. Accept only when Guard passes and improvement over current best is strictly
83
+ greater than both the frozen minimum delta and calculated noise threshold.
84
+ Record the candidate as a base-bound accepted-best patch; otherwise discard
85
+ only that iteration's owned disposable environment.
86
+
87
+ Do not edit Metric, Guard, tests, benchmarks, datasets, budgets, or thresholds
88
+ to win; their frozen digests are revalidated before every candidate.
89
+ Stop at the first budget, cancellation, drift, ownership, cleanup, or repeated
90
+ no-improvement condition named in preflight.
91
+
92
+ ## 4. Failure and process ownership
93
+
94
+ Launch every command in an isolated process group on POSIX or Job Object on
95
+ Windows. If the runtime cannot terminate the whole process tree, refuse to run.
96
+ On timeout/cancel, terminate, escalate to kill, reap, and verify quiescence before
97
+ cleanup. Never reuse a timed-out path. If descendants, path ownership, or cleanup
98
+ is uncertain, retain exact residue and return `BLOCKED`; never use
99
+ `git reset --hard`, `git clean`, broad deletion, or unrelated recovery.
100
+
101
+ ## 5. Handoff
102
+
103
+ Return baseline, best value/noise, the exact keep formula, accepted/rejected
104
+ iteration ledger, Guard evidence, stop reason, remaining limits, and live-proof
105
+ status. A successful handoff is a redacted tracked-text patch bound to base OID,
106
+ complete scoped file manifest, and lowercase SHA-256. Reject secret-bearing,
107
+ untracked, binary, incomplete, or stale output unless a separately approved
108
+ bundle contract exists.
109
+
110
+ Use only the preflight-selected handoff mode: inline ephemeral patch, or an exact
111
+ user-approved path outside the primary worktree with retention and cleanup owner.
112
+ Never apply, commit, push, merge, cherry-pick, deploy, publish, or write an
113
+ artifact into the primary worktree implicitly. The user reviews and explicitly
114
+ authorizes any later application through the normal Develop/Test/Review flow.
@@ -0,0 +1,104 @@
1
+ # Bounded Loop protocol
2
+
3
+ This is a cooperative instruction contract, not a sandbox or a production
4
+ runtime. Live-agent adherence remains `[UNPROVEN]` until separately observed.
5
+
6
+ ## Run identity and filesystem boundary
7
+
8
+ 1. Resolve the repository root and pinned base OID without changing checkout.
9
+ 2. Capture primary tracked and untracked status. Reject any dirty path that is
10
+ inside Scope; never import, stash, clean, or overwrite primary dirt.
11
+ 3. Create a unique temp directory using the platform's secure temp API. Resolve
12
+ its lexical and canonical path, require it outside the repository, and refuse
13
+ a symlink, pre-existing reused run path, broad root, or ownership ambiguity.
14
+ 4. Write an ownership marker containing a random run ID, base OID, canonical
15
+ root, and creation time. Acquire one exclusive run lock; contention blocks.
16
+ 5. With upfront consent for this exact path, use `git worktree add --detach`
17
+ against the pinned OID. Do not use `-b`, create refs, or commit.
18
+
19
+ Every later path must be a lexical and canonical descendant of the owned root.
20
+ Reject `..`, symlink traversal, mount redirection, absolute external targets,
21
+ submodules, and paths that changed identity after validation.
22
+
23
+ ## Command trust and screening
24
+
25
+ Commands are supplied or already owned by the trusted repository/user. Record
26
+ the separately trusted/allowlisted executable realpath (which may be outside the
27
+ worktree), argv, fixed cwd, timeout, output limit, and allowlisted
28
+ environment before execution. Do not pass secrets; redact credentials, tokens,
29
+ cookies, authorization headers, PII, and secret-looking patch lines from reports.
30
+
31
+ Refuse general shell evaluation, inline code flags, Git external targeting
32
+ (`-C`, `--git-dir`, `--work-tree`), destructive Git (`reset --hard`, `clean`,
33
+ branch/ref deletion), recursive deletion, privilege escalation, deploy/publish,
34
+ and any path-valued target argument that resolves outside the detached root,
35
+ including response/config/output targets. Do not apply the target-path rule to
36
+ the separately approved executable itself. A trusted script file may run through
37
+ its declared interpreter, but inline `-c`, `-e`, `--eval`, and equivalent dynamic
38
+ code are forbidden.
39
+
40
+ This screening reduces mistakes; it cannot contain arbitrary side effects from
41
+ a malicious or compromised executable. If that threat is material, return
42
+ `BLOCKED` and require an OS sandbox outside this skill's scope.
43
+
44
+ ## Iteration lifecycle
45
+
46
+ - Revalidate base OID, primary status, contract digests, lock, ownership marker,
47
+ and canonical roots before every iteration.
48
+ - Build a new never-reused detached worktree from pinned base plus the current
49
+ accepted-best tracked-text patch. Do not repair a rejected candidate in place.
50
+ - Capture a complete Scope manifest of path, type, mode, size, and SHA-256 before
51
+ mutation; lstat paths and reject symlink/type/identity changes.
52
+ - Permit one hypothesis patch. Its post-change manifest must be contained in
53
+ Scope and attributable to that hypothesis.
54
+ - Capture the complete detached-worktree tracked/untracked fingerprint around
55
+ every Metric and Guard command. Subtract only exact immutable cache paths
56
+ frozen at preflight; every other oracle-created file or byte/mode/type/path
57
+ change, inside or outside Scope, rejects the candidate as drift.
58
+ - Record command exit/signal/timeout, bounded redacted output, raw finite samples,
59
+ median/noise, Guard verdict, patch digest, and keep/discard reason.
60
+
61
+ Parallel iterations are forbidden: one run, one lock, one candidate at a time.
62
+ An external source/base/contract change stops the run; it never triggers an
63
+ automatic rebase, new baseline, threshold change, or wider Scope.
64
+
65
+ ## Process-tree timeout and cancellation
66
+
67
+ Spawn a new process group on POSIX or Job Object on Windows. On timeout or user
68
+ cancellation, stop scheduling, terminate the whole tree, wait the frozen grace
69
+ period, escalate to kill, reap, and verify no owned descendant remains. The run
70
+ path is permanently retired after timeout.
71
+
72
+ If the platform cannot own/observe descendants, termination fails, a process
73
+ survives, or quiescence cannot be proven, do not clean. Preserve the exact path,
74
+ PID/process evidence, and ownership marker; return `BLOCKED` for operator action.
75
+
76
+ ## Cleanup and recovery
77
+
78
+ Clean only a canonical path whose run ID, lock, marker, base OID, and inode/path
79
+ identity still match the run and whose process tree is quiescent. Release the
80
+ detached worktree through Git, then remove only that exact temp root using the
81
+ pre-approved cleanup action. Never broaden a glob or follow a symlink.
82
+
83
+ No `git reset --hard`, `git clean`, force checkout, stash, branch deletion,
84
+ primary-index edit, or unrelated recovery is permitted. Cleanup uncertainty is
85
+ a retained residue plus `BLOCKED`, not a reason to become more destructive.
86
+
87
+ ## Patch handoff
88
+
89
+ Default handoff supports tracked regular UTF-8 text files only. Generate a
90
+ reviewable unified patch against the pinned base, then bind:
91
+
92
+ - `base_oid`;
93
+ - sorted complete Scope manifest before/after with file SHA-256;
94
+ - patch byte length and lowercase SHA-256;
95
+ - Metric/Guard contract digests and evidence;
96
+ - accepted/rejected iteration ledger and stop reason;
97
+ - secret/redaction scan result;
98
+ - mode: inline ephemeral, or exact approved external path;
99
+ - creation time, retention/expiry, cleanup owner, and application authority.
100
+
101
+ Reject missing/untracked/binary/symlink/submodule/secret-bearing/incomplete or
102
+ stale patch bytes. Never store the artifact in the primary worktree implicitly.
103
+ Never apply or commit it. A later authorized workflow revalidates base, patch,
104
+ tests, review, and current repository state before application.