@hassangameryt/freeflow 0.5.0 → 0.7.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 (301) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +2 -2
  3. package/.codex-plugin/plugin.json +4 -5
  4. package/README.md +141 -163
  5. package/capabilities/cognitive-routing/SKILL.md +387 -0
  6. package/capabilities/context-virtualization/SKILL.md +103 -0
  7. package/capabilities/conversation-history/SKILL.md +53 -0
  8. package/command-surface.json +6 -37
  9. package/hooks/freeflow-runtime-context.mjs +50 -541
  10. package/hooks/hooks.json +1 -26
  11. package/hooks/tests/check-runtime-context-hook.sh +114 -308
  12. package/package.json +27 -17
  13. package/pi-extension/dist/cognitive-routing/commands.js +96 -0
  14. package/pi-extension/dist/cognitive-routing/config.js +232 -0
  15. package/pi-extension/dist/cognitive-routing/controller.js +1292 -0
  16. package/pi-extension/dist/cognitive-routing/history.js +451 -0
  17. package/pi-extension/dist/cognitive-routing/host.js +188 -0
  18. package/pi-extension/dist/cognitive-routing/pi-routing-session.js +414 -0
  19. package/pi-extension/dist/cognitive-routing/pi-session-control.js +320 -0
  20. package/pi-extension/dist/cognitive-routing/runtime.js +43 -0
  21. package/pi-extension/dist/cognitive-routing/tool.js +212 -0
  22. package/pi-extension/dist/cognitive-routing/types.js +6 -0
  23. package/pi-extension/dist/context-virtualization/commands.js +89 -0
  24. package/pi-extension/dist/context-virtualization/projector.js +42 -0
  25. package/pi-extension/dist/context-virtualization/runtime.js +356 -0
  26. package/pi-extension/dist/context-virtualization/state.js +57 -0
  27. package/pi-extension/dist/context-virtualization/types.js +10 -0
  28. package/pi-extension/dist/conversation-history/passages.js +66 -0
  29. package/pi-extension/dist/conversation-history/ranking.js +105 -0
  30. package/pi-extension/dist/conversation-history/runtime.js +226 -0
  31. package/pi-extension/dist/conversation-history/search.js +56 -0
  32. package/pi-extension/dist/conversation-history/types.js +1 -0
  33. package/pi-extension/dist/freeflow-context/resolver.js +120 -0
  34. package/pi-extension/dist/freeflow-context/runtime.js +80 -0
  35. package/pi-extension/dist/freeflow-context/source-projector.js +95 -0
  36. package/pi-extension/dist/freeflow-context/tool.js +308 -0
  37. package/pi-extension/dist/freeflow-context/types.js +12 -0
  38. package/pi-extension/dist/freeflow-context/visibility.js +28 -0
  39. package/pi-extension/dist/index.js +564 -129
  40. package/pi-extension/dist/runtime/runtime-context.js +357 -470
  41. package/pi-extension/dist/runtime/runtime-identity.js +5 -0
  42. package/pi-extension/dist/settings/settings-tui.js +78 -0
  43. package/pi-extension/dist/settings/settings-ui.js +572 -826
  44. package/pi-extension/dist/ui/text-component.js +57 -0
  45. package/pi-extension/src/cognitive-routing/commands.ts +129 -0
  46. package/pi-extension/src/cognitive-routing/config.ts +303 -0
  47. package/pi-extension/src/cognitive-routing/controller.ts +1628 -0
  48. package/pi-extension/src/cognitive-routing/history.ts +650 -0
  49. package/pi-extension/src/cognitive-routing/host.ts +266 -0
  50. package/pi-extension/src/cognitive-routing/pi-routing-session.ts +538 -0
  51. package/pi-extension/src/cognitive-routing/pi-session-control.ts +444 -0
  52. package/pi-extension/src/cognitive-routing/runtime.ts +57 -0
  53. package/pi-extension/src/cognitive-routing/tool.ts +273 -0
  54. package/pi-extension/src/cognitive-routing/types.ts +89 -0
  55. package/pi-extension/src/context-virtualization/commands.ts +111 -0
  56. package/pi-extension/src/context-virtualization/projector.ts +62 -0
  57. package/pi-extension/src/context-virtualization/runtime.ts +406 -0
  58. package/pi-extension/src/context-virtualization/state.ts +79 -0
  59. package/pi-extension/src/context-virtualization/types.ts +92 -0
  60. package/pi-extension/src/conversation-history/passages.ts +81 -0
  61. package/pi-extension/src/conversation-history/ranking.ts +155 -0
  62. package/pi-extension/src/conversation-history/runtime.ts +250 -0
  63. package/pi-extension/src/conversation-history/search.ts +79 -0
  64. package/pi-extension/src/conversation-history/types.ts +31 -0
  65. package/pi-extension/src/freeflow-context/resolver.ts +139 -0
  66. package/pi-extension/src/freeflow-context/runtime.ts +100 -0
  67. package/pi-extension/src/freeflow-context/source-projector.ts +106 -0
  68. package/pi-extension/src/freeflow-context/tool.ts +360 -0
  69. package/pi-extension/src/freeflow-context/types.ts +70 -0
  70. package/pi-extension/src/freeflow-context/visibility.ts +53 -0
  71. package/pi-extension/src/index.ts +597 -135
  72. package/pi-extension/src/runtime/runtime-context.ts +373 -491
  73. package/pi-extension/src/runtime/runtime-identity.ts +8 -0
  74. package/pi-extension/src/settings/settings-tui.ts +93 -0
  75. package/pi-extension/src/settings/settings-ui.ts +679 -910
  76. package/pi-extension/src/ui/text-component.ts +66 -0
  77. package/pi-extension/tests/cognitive-routing/commands.test.js +134 -0
  78. package/pi-extension/tests/cognitive-routing/controller.test.js +1128 -0
  79. package/pi-extension/tests/cognitive-routing/extension-lifecycle.test.js +1142 -0
  80. package/pi-extension/tests/cognitive-routing/history.test.js +274 -0
  81. package/pi-extension/tests/cognitive-routing/host-fixture.js +4 -0
  82. package/pi-extension/tests/cognitive-routing/host-identity.test.js +63 -0
  83. package/pi-extension/tests/cognitive-routing/pi-normal-lifecycle.test.js +434 -0
  84. package/pi-extension/tests/cognitive-routing/pi-session-control.test.js +174 -0
  85. package/pi-extension/tests/cognitive-routing/pi-session-history.test.js +91 -0
  86. package/pi-extension/tests/cognitive-routing/profile-resolution.test.js +279 -0
  87. package/pi-extension/tests/cognitive-routing/tool.test.js +230 -0
  88. package/pi-extension/tests/context-virtualization/extension.test.js +749 -0
  89. package/pi-extension/tests/context-virtualization/projector.test.js +110 -0
  90. package/pi-extension/tests/context-virtualization/runtime.test.js +216 -0
  91. package/pi-extension/tests/conversation-history/runtime.test.js +98 -0
  92. package/pi-extension/tests/conversation-history/search.test.js +97 -0
  93. package/pi-extension/tests/integration/mode-free-core.test.js +218 -0
  94. package/pi-extension/tests/integration/pi-extension.test.js +532 -3701
  95. package/pi-extension/tests/integration/prompt-architecture.test.js +350 -0
  96. package/pi-extension/tests/integration/unaffected-regressions.test.js +411 -0
  97. package/runtime/prompts/cognitive-routing.md +10 -0
  98. package/runtime/prompts/context-virtualization.md +3 -0
  99. package/runtime/prompts/conversation-history.md +3 -0
  100. package/runtime/prompts/core.md +84 -0
  101. package/runtime/prompts/interaction-contract.md +11 -0
  102. package/skills/action-selection/SKILL.md +140 -0
  103. package/skills/action-selection/references/trajectory-stalls.md +71 -0
  104. package/skills/bypass/SKILL.md +109 -38
  105. package/skills/commit-work/SKILL.md +94 -55
  106. package/skills/commit-work/references/git-state-edges.md +94 -0
  107. package/skills/commit-work/references/simple-push.md +92 -0
  108. package/skills/commit-work/references/staging-decisions.md +79 -46
  109. package/skills/decision-gate/SKILL.md +80 -22
  110. package/skills/design-for-depth/SKILL.md +206 -60
  111. package/skills/design-for-depth/references/design-pressure-signals.md +108 -240
  112. package/skills/design-for-depth/references/interface-design-loop.md +77 -97
  113. package/skills/design-for-depth/references/module-and-dependency-design.md +147 -0
  114. package/skills/design-for-depth/references/software-design-philosophy.md +128 -174
  115. package/skills/design-for-depth/references/state-and-failure-boundaries.md +136 -0
  116. package/skills/diagnose-failure/SKILL.md +200 -48
  117. package/skills/diagnose-failure/references/diagnostic-loop-catalog.md +18 -6
  118. package/skills/diagnose-failure/references/{flaky-and-performance.md → flaky-and-performance-diagnosis.md} +13 -5
  119. package/skills/discuss/SKILL.md +119 -65
  120. package/skills/discuss/references/discussion-continuity.md +123 -0
  121. package/skills/evaluate-skill/SKILL.md +166 -52
  122. package/skills/evaluate-skill/references/{definition-schema.md → evaluation-definition-schema.md} +43 -3
  123. package/skills/evaluate-skill/references/evaluation-design.md +56 -30
  124. package/skills/evaluate-skill/references/execution-and-evidence.md +8 -3
  125. package/skills/evaluate-skill/references/review-and-revision.md +62 -21
  126. package/skills/evaluate-skill/scripts/lib/definitions.mjs +114 -3
  127. package/skills/evaluate-skill/scripts/lib/grade-interaction.mjs +156 -1
  128. package/skills/evaluate-skill/scripts/lib/grade.mjs +9 -1
  129. package/skills/evaluate-skill/scripts/lib/pi.mjs +147 -32
  130. package/skills/evaluate-skill/scripts/lib/rpc.mjs +4 -4
  131. package/skills/evaluate-skill/scripts/lib/runner.mjs +36 -14
  132. package/skills/evaluate-skill/scripts/lib/sandbox.mjs +92 -0
  133. package/skills/evaluate-skill/scripts/pi-guard.mjs +1 -1
  134. package/skills/evaluate-skill/scripts/pi-observer.mjs +66 -0
  135. package/skills/evaluate-skill/scripts/skill-eval.mjs +6 -5
  136. package/skills/execute-work/SKILL.md +99 -57
  137. package/skills/execute-work/references/code-practices.md +4 -4
  138. package/skills/execute-work/references/execute-work-edges.md +62 -0
  139. package/skills/finish-branch/SKILL.md +2 -2
  140. package/skills/finish-branch/references/integration-options.md +1 -1
  141. package/skills/handoff/SKILL.md +3 -3
  142. package/skills/launch-work/SKILL.md +1 -1
  143. package/skills/launch-work/references/launch-readiness.md +2 -2
  144. package/skills/migration-work/SKILL.md +2 -2
  145. package/skills/migration-work/references/migration-lifecycle.md +1 -1
  146. package/skills/release-work/SKILL.md +1 -1
  147. package/skills/release-work/references/release-evidence.md +1 -1
  148. package/skills/review-artifact/SKILL.md +129 -66
  149. package/skills/review-artifact/references/adjudicate-artifact-review.md +101 -0
  150. package/skills/review-artifact/references/independent-artifact-reviewer-contract.md +159 -0
  151. package/skills/review-work/SKILL.md +113 -68
  152. package/skills/review-work/references/adjudicate-work-review.md +97 -0
  153. package/skills/review-work/references/independent-work-reviewer-contract.md +139 -0
  154. package/skills/review-work/references/security-risk-lens.md +18 -16
  155. package/skills/setup-freeflow/SKILL.md +16 -17
  156. package/skills/setup-freeflow/references/activation-contract.md +24 -30
  157. package/skills/setup-freeflow/references/host-setup.md +6 -7
  158. package/skills/simplify-code/SKILL.md +97 -39
  159. package/skills/simplify-code/references/simplification-patterns.md +1 -1
  160. package/skills/tdd/SKILL.md +100 -53
  161. package/skills/tdd/references/test-design.md +3 -3
  162. package/skills/track-work/SKILL.md +195 -58
  163. package/skills/track-work/references/working-record-format.md +515 -0
  164. package/skills/track-work/scripts/lib/document.mjs +713 -0
  165. package/skills/track-work/scripts/lib/format.mjs +166 -0
  166. package/skills/track-work/scripts/lib/store.mjs +233 -0
  167. package/skills/track-work/scripts/lib/transitions.mjs +790 -0
  168. package/skills/track-work/scripts/lib/views.mjs +40 -0
  169. package/skills/track-work/scripts/working-record.mjs +316 -0
  170. package/skills/verify-work/SKILL.md +57 -19
  171. package/skills/verify-work/references/browser-runtime-evidence.md +2 -2
  172. package/skills/verify-work/references/integration-evidence.md +1 -7
  173. package/skills/verify-work/references/performance-evidence.md +2 -2
  174. package/skills/workflow/SKILL.md +137 -55
  175. package/skills/workflow/references/domain-skill-composition.md +26 -40
  176. package/skills/write-plan/SKILL.md +1 -1
  177. package/skills/write-skill/SKILL.md +218 -61
  178. package/skills/write-skill/references/activation-boundaries.md +63 -21
  179. package/skills/write-skill/references/agent-first-instructions.md +61 -27
  180. package/skills/write-skill/references/progressive-disclosure.md +97 -33
  181. package/skills/write-skill/references/skill-dependency-graphs.md +190 -0
  182. package/capabilities/output-router/SKILL.md +0 -206
  183. package/capabilities/output-router/references/safety-policy.md +0 -40
  184. package/capabilities/output-router/references/setup.md +0 -110
  185. package/pi-extension/dist/output-router/host-producer-identification.js +0 -232
  186. package/pi-extension/dist/output-router/native-safety-net.js +0 -216
  187. package/pi-extension/dist/output-router/observed-tool-routing.js +0 -122
  188. package/pi-extension/dist/output-router/renderers.js +0 -1023
  189. package/pi-extension/dist/output-router/router-tools.js +0 -554
  190. package/pi-extension/dist/output-router/schemas.js +0 -383
  191. package/pi-extension/dist/output-router/status.js +0 -744
  192. package/pi-extension/dist/output-router/utils.js +0 -502
  193. package/pi-extension/src/output-router/host-producer-identification.ts +0 -256
  194. package/pi-extension/src/output-router/native-safety-net.ts +0 -248
  195. package/pi-extension/src/output-router/observed-tool-routing.ts +0 -134
  196. package/pi-extension/src/output-router/renderers.ts +0 -1108
  197. package/pi-extension/src/output-router/router-tools.ts +0 -579
  198. package/pi-extension/src/output-router/schemas.ts +0 -387
  199. package/pi-extension/src/output-router/status.ts +0 -791
  200. package/pi-extension/src/output-router/utils.ts +0 -554
  201. package/pi-extension/tests/output-router/observed-producers.test.js +0 -132
  202. package/pi-extension/tests/output-router/search.test.js +0 -722
  203. package/router/dist/benchmarks/benchmark-harness.d.ts +0 -35
  204. package/router/dist/benchmarks/benchmark-harness.js +0 -92
  205. package/router/dist/benchmarks/benchmarks.d.ts +0 -109
  206. package/router/dist/benchmarks/benchmarks.js +0 -979
  207. package/router/dist/benchmarks/codex-qa-benchmarks.d.ts +0 -95
  208. package/router/dist/benchmarks/codex-qa-benchmarks.js +0 -500
  209. package/router/dist/benchmarks/command-benchmarks.d.ts +0 -143
  210. package/router/dist/benchmarks/command-benchmarks.js +0 -698
  211. package/router/dist/benchmarks/context-mode-normalized-benchmarks.d.ts +0 -82
  212. package/router/dist/benchmarks/context-mode-normalized-benchmarks.js +0 -773
  213. package/router/dist/benchmarks/context-mode-real-deep-benchmark.d.ts +0 -132
  214. package/router/dist/benchmarks/context-mode-real-deep-benchmark.js +0 -1380
  215. package/router/dist/benchmarks/context-saving-baseline.d.ts +0 -60
  216. package/router/dist/benchmarks/context-saving-baseline.js +0 -470
  217. package/router/dist/benchmarks/index-benchmarks.d.ts +0 -103
  218. package/router/dist/benchmarks/index-benchmarks.js +0 -862
  219. package/router/dist/benchmarks/storage-policy-benchmarks.d.ts +0 -101
  220. package/router/dist/benchmarks/storage-policy-benchmarks.js +0 -618
  221. package/router/dist/benchmarks/vault-index-benchmarks.d.ts +0 -56
  222. package/router/dist/benchmarks/vault-index-benchmarks.js +0 -322
  223. package/router/dist/config/config.d.ts +0 -103
  224. package/router/dist/config/config.js +0 -632
  225. package/router/dist/config/router-contract.d.ts +0 -10
  226. package/router/dist/config/router-contract.js +0 -54
  227. package/router/dist/config/schema.d.ts +0 -27
  228. package/router/dist/config/schema.js +0 -648
  229. package/router/dist/config/types.d.ts +0 -573
  230. package/router/dist/config/types.js +0 -41
  231. package/router/dist/evidence/bounded-evidence.d.ts +0 -40
  232. package/router/dist/evidence/bounded-evidence.js +0 -323
  233. package/router/dist/evidence/evidence-range-selector.d.ts +0 -24
  234. package/router/dist/evidence/evidence-range-selector.js +0 -232
  235. package/router/dist/evidence/evidence-search.d.ts +0 -27
  236. package/router/dist/evidence/evidence-search.js +0 -490
  237. package/router/dist/evidence/evidence.d.ts +0 -38
  238. package/router/dist/evidence/evidence.js +0 -200
  239. package/router/dist/evidence/failure-contracts.d.ts +0 -37
  240. package/router/dist/evidence/failure-contracts.js +0 -166
  241. package/router/dist/evidence/line-ranges.d.ts +0 -24
  242. package/router/dist/evidence/line-ranges.js +0 -22
  243. package/router/dist/experiments/local-index.d.ts +0 -64
  244. package/router/dist/experiments/local-index.js +0 -581
  245. package/router/dist/index.d.ts +0 -30
  246. package/router/dist/index.js +0 -32
  247. package/router/dist/local/local-traversal.d.ts +0 -18
  248. package/router/dist/local/local-traversal.js +0 -334
  249. package/router/dist/processing/engine.d.ts +0 -132
  250. package/router/dist/processing/engine.js +0 -533
  251. package/router/dist/processing/reducers.d.ts +0 -280
  252. package/router/dist/processing/reducers.js +0 -1673
  253. package/router/dist/processing/renderers.d.ts +0 -31
  254. package/router/dist/processing/renderers.js +0 -195
  255. package/router/dist/processing/scripts.d.ts +0 -91
  256. package/router/dist/processing/scripts.js +0 -386
  257. package/router/dist/repo/repo-traversal.d.ts +0 -18
  258. package/router/dist/repo/repo-traversal.js +0 -245
  259. package/router/dist/routing/observed-reducers.d.ts +0 -41
  260. package/router/dist/routing/observed-reducers.js +0 -661
  261. package/router/dist/routing/observed-routing.d.ts +0 -26
  262. package/router/dist/routing/observed-routing.js +0 -378
  263. package/router/dist/routing/parsers.d.ts +0 -16
  264. package/router/dist/routing/parsers.js +0 -521
  265. package/router/dist/routing/run-filters.d.ts +0 -60
  266. package/router/dist/routing/run-filters.js +0 -238
  267. package/router/dist/routing/run-reducers.d.ts +0 -49
  268. package/router/dist/routing/run-reducers.js +0 -122
  269. package/router/dist/sandbox/adapter-roots.d.ts +0 -46
  270. package/router/dist/sandbox/adapter-roots.js +0 -66
  271. package/router/dist/sandbox/eryx-python-adapter.d.ts +0 -13
  272. package/router/dist/sandbox/eryx-python-adapter.js +0 -868
  273. package/router/dist/sandbox/jq-wasm-adapter.d.ts +0 -9
  274. package/router/dist/sandbox/jq-wasm-adapter.js +0 -429
  275. package/router/dist/sandbox/quickjs-wasi-adapter.d.ts +0 -13
  276. package/router/dist/sandbox/quickjs-wasi-adapter.js +0 -384
  277. package/router/dist/sandbox/script-sandbox.d.ts +0 -134
  278. package/router/dist/sandbox/script-sandbox.js +0 -337
  279. package/router/dist/setup/script-transform-adapters.d.ts +0 -32
  280. package/router/dist/setup/script-transform-adapters.js +0 -278
  281. package/router/dist/tools/batch.d.ts +0 -33
  282. package/router/dist/tools/batch.js +0 -586
  283. package/router/dist/tools/run.d.ts +0 -62
  284. package/router/dist/tools/run.js +0 -1304
  285. package/router/dist/tools/search.d.ts +0 -66
  286. package/router/dist/tools/search.js +0 -1364
  287. package/router/dist/transform/engine.d.ts +0 -168
  288. package/router/dist/transform/engine.js +0 -2072
  289. package/router/dist/vault/vault-index.d.ts +0 -125
  290. package/router/dist/vault/vault-index.js +0 -416
  291. package/router/dist/vault/vault.d.ts +0 -138
  292. package/router/dist/vault/vault.js +0 -630
  293. package/runtime/interaction-contract.md +0 -16
  294. package/skills/discuss/references/checkpoints.md +0 -66
  295. package/skills/execute-work/references/execution-loop.md +0 -77
  296. package/skills/mode-contract/SKILL.md +0 -104
  297. package/skills/review-artifact/references/reviewer-prompt.md +0 -148
  298. package/skills/review-work/references/reviewer-prompt.md +0 -134
  299. package/skills/track-work/references/working-record-schema.md +0 -378
  300. package/skills/workflow/references/workflow-loop.md +0 -92
  301. /package/skills/handoff/references/{templates.md → handoff-templates.md} +0 -0
@@ -1,314 +1,182 @@
1
1
  # Design Pressure Signals
2
2
 
3
- Use this reference when reviewing code, artifacts, or work for shallow modules and complexity spread.
3
+ Read this when observed coordination could change the next route and an equivalent design-route classification is not already supported.
4
4
 
5
- The goal is not to find every smell. The goal is to notice pressure that changes the next route.
5
+ Do not count smells. Identify the pressure that changes the next action, or conclude that none does.
6
6
 
7
- ## Quick Classifier
7
+ ## Classify The Evidence
8
8
 
9
9
  Ask:
10
10
 
11
- 1. What is the module?
12
- 2. What is the interface?
13
- 3. What details are callers forced to know?
14
- 4. What decision is likely to change?
15
- 5. Where would that decision be localized?
16
- 6. Would solving this now fit the approved scope?
11
+ 1. What caller outcome and interface are affected?
12
+ 2. What facts must callers know or coordinate?
13
+ 3. Did the current change add to that knowledge?
14
+ 4. What policy, dependency, state transition, or failure behavior is spreading?
15
+ 5. Is the cause supported?
16
+ 6. Can the issue be resolved inside accepted scope and authority?
17
17
 
18
- Then classify:
18
+ Choose the narrowest supported route:
19
19
 
20
- - **Continue:** no design pressure that changes the next action.
21
- - **Local fix:** improve within current module/interface.
22
- - **Plan revision:** slice boundary or verification path is wrong.
23
- - **Discuss or revise a Spec:** behavior, scope, or acceptance is unclear.
24
- - **Owner decision:** public API, compatibility, security, privacy, billing, data loss, permissions, migration, or hard-to-reverse architecture.
25
- - **Deferred deepening:** real design pressure, but not worth solving in this scope.
20
+ - **Continue:** current boundary remains sound.
21
+ - **Local correction:** defect remains within one module and contract.
22
+ - **Diagnosis:** failure is repeated or unexplained and cause is unsupported.
23
+ - **Spec or Plan revision:** behavior, acceptance, or execution boundary is incomplete.
24
+ - **User decision:** resolving pressure changes a user-owned outcome.
25
+ - **Learning:** evidence cannot distinguish viable boundaries.
26
+ - **Deepening:** supported information-hiding improvement fits accepted scope.
27
+ - **Deferred deepening:** pressure is real but not worth resolving now.
26
28
 
27
- ## Signals And What They Usually Mean
29
+ ## Change Amplification
28
30
 
29
- ### Shotgun Surgery
31
+ Pressure exists when one policy change requires unrelated edits across callers.
30
32
 
31
- Signal: one concept requires many unrelated edits.
32
-
33
- Examples:
34
-
35
- - retry policy added to every route;
36
- - permission check copied into API, UI, and job worker;
37
- - billing grace-period logic repeated in webhook, email, and dashboard;
38
- - cache freshness flags threaded through callers.
39
-
40
- Likely issue: a likely-changing decision is not hidden behind a module.
41
-
42
- Route:
43
-
44
- - If behavior or scope is unsettled: Discuss or revise the owning Spec.
45
- - If behavior is settled but slice spreads edits: plan revision or refactor candidate.
46
-
47
- ### Caller Choreography
48
-
49
- Signal: callers must perform steps in the right order.
50
-
51
- Examples:
33
+ Example:
52
34
 
53
35
  ```text
54
- open connection -> set retry -> register cleanup -> call provider -> translate error -> log metric
36
+ Changing retry policy requires edits in API routes, workers,
37
+ UI state, and tests.
55
38
  ```
56
39
 
57
- Likely issue: interface exposes implementation sequence.
40
+ Name the decision causing the edits. Do not merely move the same choreography into one helper.
41
+
42
+ ## Caller Protocol Growth
58
43
 
59
- Better interface asks for outcome:
44
+ Pressure exists when callers must perform internal lifecycle steps:
60
45
 
61
46
  ```text
62
- deliverNotification(invitation)
47
+ configure -> open -> retry -> translate error -> clean up -> publish evidence
63
48
  ```
64
49
 
65
- while the module owns retry, fallback, logging, cleanup, and provider errors.
66
-
67
- ### Scattered Policy
68
-
69
- Signal: product or operational rules appear in many places.
70
-
71
- Examples:
72
-
73
- - billing downgrade timing in UI, webhook, worker, and tests;
74
- - notification fallback rules in every route;
75
- - authorization rules in frontend and backend separately;
76
- - migration compatibility gates inside individual callers.
77
-
78
- Likely issue: policy is not localized.
79
-
80
- Stop if changing it would alter product, security, privacy, billing, permissions, public API, compatibility, or data-loss behavior.
81
-
82
- ### Test Knows Too Much
83
-
84
- Signal: tests assert implementation sequencing instead of behavior.
85
-
86
- Examples:
87
-
88
- - tests assert `sendEmail` then `logFailure` then `sendSms` in every route;
89
- - tests mock five helpers to verify one user-visible behavior;
90
- - tests duplicate retry counts and provider error types;
91
- - tests need private methods or internal state.
92
-
93
- Likely issue: the production interface is not the right test seam.
94
-
95
- Do not automatically add mocks. Ask whether the module interface should own the behavior.
96
-
97
- ### Missing Failure Contract
98
-
99
- Signal: the happy path is planned, but failure modes, observers, state writes, fail-open/closed/degrade/escalate/retry behavior, recovery, or proof are left to each caller or implementer.
100
-
101
- Likely issue: failure behavior is part of the interface but has not been designed.
102
-
103
- Route:
104
-
105
- - If behavior changes product, security, privacy, billing, permissions, public API, compatibility, or data loss: owner decision.
106
- - If behavior is within scope but scattered: plan/spec revision or refactor candidate.
107
- - If proof is missing: verification gap before completion claims.
108
-
109
- ### Caller-Knowledge Growth
110
-
111
- Signal: each fix adds another flag, state, path, ordering rule, retry instruction, cleanup step, or recovery fact that callers and tests must know.
112
-
113
- Likely issue: the interface is growing with the implementation instead of hiding it.
114
-
115
- Route:
116
-
117
- - stop adding contract detail;
118
- - inventory caller knowledge;
119
- - design materially different outcome-level interfaces;
120
- - use a learning slice if evidence cannot choose between them.
121
-
122
- ### Contract-Surface Explosion
123
-
124
- Signal: an internal lifecycle becomes a public protocol of attempts, manifests, orphan states, retry links, grade modes, cache identities, or integrity steps.
125
-
126
- Likely issue: caller-owned outcome and internal protocol have been confused.
127
-
128
- Ask whether one operation can own the complete success/failure unit and publish diagnostics without exposing recovery choreography.
129
-
130
- ### Tests Legitimize Machinery
131
-
132
- Signal: test count grows quickly, but most new tests protect states and mechanisms introduced by recent patches rather than accepted behavior.
50
+ Related signals:
133
51
 
134
- Likely issue: passing tests are making accidental complexity look required.
52
+ - every correction adds another state or flag;
53
+ - recovery steps become ordinary caller behavior;
54
+ - callers depend on paths, filenames, provider errors, or queue names;
55
+ - a complete outcome becomes a public protocol of attempts and temporary states.
135
56
 
136
- Every architecture-bearing test should name its accepted requirement or measured failure. If deleting the mechanism also deletes its tests without weakening acceptance, the tests do not justify it.
57
+ Ask whether one operation can own the complete success and failure unit while publishing diagnostics separately.
137
58
 
138
- ### Scope And Remaining-Work Growth
59
+ ## Scattered Policy
139
60
 
140
- Signal: completed slices increase the estimated remaining work, pull deferred capabilities into scope, require an unplanned subsystem, or invalidate earlier evidence.
141
-
142
- Likely issue: the milestone or plan has been invalidated even if each local change remains technically in scope.
143
-
144
- Return the evidence and options to Workflow: keep, simplify, split, defer, revise the owning Plan or Spec, or stop for owner direction.
145
-
146
- ### Edge-Case Patch Stream
147
-
148
- Signal: each review pass finds another special case.
149
-
150
- Examples:
151
-
152
- - “also handle null phone”; then “also handle email bounce”; then “also handle duplicate invite”; then “also handle retry telemetry.”
153
-
154
- Likely issue: review is exposing missing behavior ownership, not isolated bugs.
155
-
156
- Route:
157
-
158
- - classify findings;
159
- - respect the review cap;
160
- - diagnose only when related findings suggest an unclear shared cause in discussion, source truth, the Spec or Plan, module shape, or reviewer context.
161
-
162
- ### Pass-Through Wrapper
163
-
164
- Signal: a module mostly renames another call.
61
+ Pressure exists when one product or operational decision is encoded in several places.
165
62
 
166
63
  Example:
167
64
 
168
- ```ts
169
- function sendTeamInviteEmail(email, subject, options) {
170
- return sendEmail(email, subject, options);
171
- }
65
+ ```text
66
+ billing transition timing appears separately in webhook,
67
+ dashboard, email, and worker behavior.
172
68
  ```
173
69
 
174
- Likely issue: shallow wrapper.
175
-
176
- Options:
177
-
178
- - delete it if it hides nothing;
179
- - deepen it by moving real policy behind it;
180
- - keep it only when it expresses a stable domain or compatibility interface with a source-backed reason to exist.
181
-
182
- ### Leaky Interface
183
-
184
- Signal: callers know provider/database/cache internals.
185
-
186
- Examples:
187
-
188
- - callers catch Stripe-specific errors;
189
- - UI code knows database enum transitions;
190
- - API callers pass cache invalidation flags;
191
- - tests assert internal queue names.
192
-
193
- Likely issue: implementation detail leaked through interface.
70
+ Do not centralize behavior until the policy is accepted. When it is user-owned or conflicting, stop for a decision.
194
71
 
195
- Route to design if leakage blocks safe change or verification.
72
+ ## Unowned State Or Failure
196
73
 
197
- ### God Module
74
+ Pressure exists when no module owns:
198
75
 
199
- Signal: one file owns unrelated responsibilities.
76
+ - canonical state and its visibility point;
77
+ - forbidden partial outcomes;
78
+ - retry, degradation, or escalation;
79
+ - cancellation and reconciliation;
80
+ - recovery after partial completion;
81
+ - evidence proving the final state.
200
82
 
201
- Examples:
83
+ Do not design architecture around an invented failure policy.
202
84
 
203
- - route file validates input, applies policy, calls providers, logs metrics, and formats UI copy;
204
- - workflow module owns routing, vaulting, parsing, rendering, and config mutation.
85
+ ## Contract-Surface Growth
205
86
 
206
- Likely issue: missing internal modules or seams.
87
+ Pressure exists when each patch adds public:
207
88
 
208
- Do not split by file type alone. Split around hidden decisions and interfaces.
89
+ - flags;
90
+ - temporary states;
91
+ - manifest fields;
92
+ - retry links;
93
+ - recovery instructions;
94
+ - provider-specific errors;
95
+ - cache or integrity controls.
209
96
 
210
- ### Speculative Seam
97
+ Ask whether callers own those facts or are being forced to understand internal protocol.
211
98
 
212
- Signal: interface/adapters/factory exist for only imagined future variation.
99
+ ## Distorted Tests
213
100
 
214
- Examples:
101
+ Pressure exists when tests:
215
102
 
216
- - `PaymentProviderAdapterFactoryRegistry` when only Stripe exists and no migration is planned;
217
- - strategies for every small formatting function;
218
- - generic repository around a single simple query.
103
+ - reproduce caller choreography;
104
+ - mock many helpers to verify one outcome;
105
+ - depend on private lifecycle states;
106
+ - protect machinery introduced by recent patches;
107
+ - prove rejection without checking forbidden writes;
108
+ - make provider mechanics look like domain requirements.
219
109
 
220
- Likely issue: indirection without leverage.
110
+ Do not automatically add mocks or test-only seams. First inspect whether the production boundary owns the complete behavior.
221
111
 
222
- Use the variation test: one adapter is hypothetical; two adapters or known upcoming variation justify a seam better.
112
+ An intentional internal test is not a defect merely because it observes internals.
223
113
 
224
- ### Premature Artifact Detail
114
+ ## Edge-Case Patch Streams
225
115
 
226
- Signal: spec or plan chooses exact classes, factories, tables, or algorithms before evidence exists.
116
+ Pressure exists when related fixes repeatedly add conditions, states, or caller rules.
227
117
 
228
- Likely issue: artifact is hiding uncertainty as implementation detail.
229
-
230
- Better:
231
-
232
- ```text
233
- Tentative: likely need a policy-owning module if retry/fallback rules spread.
234
- Open: whether provider variation is real in this scope.
235
- Stop: revisit plan if slice requires touching every caller.
236
- ```
237
-
238
- ## Before / After Examples
239
-
240
- ### Notification Retry
241
-
242
- Bad direction:
118
+ Example:
243
119
 
244
120
  ```text
245
- Add retryCount to each route that sends notifications.
121
+ handle missing contact
122
+ -> handle fallback
123
+ -> handle duplicate delivery
124
+ -> handle retry telemetry
125
+ -> expose another state to callers
246
126
  ```
247
127
 
248
- Pressure:
128
+ Do not infer architecture from finding count alone. Diagnose whether the cases share one missing contract, state owner, or failure unit.
249
129
 
250
- - callers know retry policy;
251
- - fallback and telemetry are duplicated;
252
- - tests assert provider sequencing;
253
- - adding another provider touches every caller.
130
+ ## Scope Growth
254
131
 
255
- Better direction:
132
+ Pressure exists when a bounded result unexpectedly:
256
133
 
257
- ```text
258
- Introduce a notification delivery module whose interface accepts the notification intent and owns retry, fallback, provider errors, and telemetry.
259
- ```
134
+ - requires a subsystem;
135
+ - expands remaining work;
136
+ - pulls deferred capabilities into scope;
137
+ - invalidates earlier evidence;
138
+ - requires unrelated callers to change.
260
139
 
261
- Still ask owner decisions before changing user-visible delivery semantics.
140
+ Return the evidence. The correct route may be simplify, split, revise an artifact, learn, defer, or stop.
262
141
 
263
- ### Billing Grace Period
142
+ ## Common Interface Mismatches
264
143
 
265
- Bad direction:
144
+ ### Pass-through wrapper
266
145
 
267
- ```text
268
- Patch webhook to downgrade immediately, update email text, adjust dashboard copy.
269
- ```
146
+ Renames a call without hiding policy or provider behavior.
270
147
 
271
- Pressure:
148
+ Keep only when it preserves a real domain, compatibility, or observation boundary.
272
149
 
273
- - billing policy spread across systems;
274
- - likely source-truth conflict with docs/tests;
275
- - user-owned billing behavior.
150
+ ### Leaky interface
276
151
 
277
- Better direction:
152
+ Callers know infrastructure-specific details.
278
153
 
279
- ```text
280
- Stop at the decision gate. Decide billing policy first. Then localize policy behind a billing-state transition module if implementation spreads.
281
- ```
154
+ ### God module
282
155
 
283
- ### Cache Freshness
156
+ Unrelated decisions are collected behind one interface.
284
157
 
285
- Bad direction:
158
+ ### Speculative seam
286
159
 
287
- ```text
288
- Thread forceRefresh through every caller.
289
- ```
160
+ Indirection exists only for imagined variation.
290
161
 
291
- Pressure:
162
+ ### Dependency cycle
292
163
 
293
- - callers know cache invalidation policy;
294
- - tests must set timing flags;
295
- - source truth may allow caching.
164
+ Modules cannot change independently because their responsibilities point at each other.
296
165
 
297
- Better direction:
166
+ ### Premature artifact detail
298
167
 
299
- ```text
300
- Discuss the expected freshness boundary. If source truth supports it, hide invalidation and freshness rules behind a cache-aware read interface.
301
- ```
168
+ A Spec or Plan freezes classes, factories, tables, or algorithms before evidence supports the boundary.
302
169
 
303
170
  ## False Positives
304
171
 
305
- Do not overreact when:
172
+ Do not escalate when:
306
173
 
307
- - a small repeated pattern is stable and local;
308
- - a one-off script does not need long-term depth;
309
- - a wrapper exists for public compatibility;
174
+ - stable repetition remains small and local;
310
175
  - broad edits are mechanical and source-backed;
311
- - tests inspect internals only for an internal module whose interface is intentionally internal;
312
- - deeper design would expand scope beyond the user's goal.
176
+ - a one-off script does not need long-term abstraction;
177
+ - a wrapper preserves a real compatibility contract;
178
+ - an isolated condition is wrong but the interface remains sound;
179
+ - an internal test intentionally verifies an internal module;
180
+ - resolving the pressure would exceed the user’s goal without blocking it.
313
181
 
314
- When in doubt, classify as deferred design pressure rather than silently refactoring.
182
+ Stop once the route is classified. Return evidence and classification; do not redesign automatically.
@@ -1,156 +1,136 @@
1
1
  # Interface Design Loop
2
2
 
3
- Use this when structural pressure makes the current interface suspect. The goal is to choose an outcome-level module shape, not add detail to the first plausible design.
3
+ Read this before comparing materially different interfaces or settling an important correctness boundary where ownership is consequential.
4
4
 
5
- ## 1. Frame The Outcome
5
+ Use only evidence and criteria capable of distinguishing viable boundaries. Do not emit a full checklist unless the artifact itself requires one.
6
6
 
7
- State:
7
+ ## 1. Frame The Complete Outcome
8
+
9
+ Orient broadly enough to state:
8
10
 
9
11
  - caller and complete outcome;
10
12
  - source-backed behavior and non-goals;
11
13
  - decisions the caller genuinely owns;
12
14
  - dependencies and current constraints;
13
- - why the current seam is under pressure.
14
-
15
- Do not begin from existing flags, storage paths, or lifecycle states. Those may be symptoms of the current shape.
15
+ - material state and failure boundaries;
16
+ - why the current seam requires attention.
16
17
 
17
- ## 2. Choose The Failure Unit
18
+ Do not begin from existing flags, storage paths, classes, or temporary states. They may be symptoms of the current design.
18
19
 
19
- Name the atomic unit before designing retries or resume:
20
+ ## 2. Define The Failure Unit
20
21
 
21
- - operation;
22
- - slice;
23
- - comparison;
24
- - session;
25
- - published result;
26
- - another outcome specific to the domain.
22
+ Name the coherent outcome treated as one success, failure, and recovery boundary.
27
23
 
28
- Define:
24
+ Define material:
29
25
 
30
- - terminal states;
31
- - observers;
32
- - state or evidence written;
26
+ - terminal states and observers;
27
+ - canonical and diagnostic state;
28
+ - evidence written;
33
29
  - forbidden partial outcomes;
34
- - safe restart unit;
35
- - recovery proof;
36
- - whether partial reuse is a requirement or only an optimization.
37
-
38
- When authority, integrity, canonical persistence, or proof validity materially affects correctness, also define:
30
+ - safe restart and recovery;
31
+ - required proof;
32
+ - whether partial reuse is required or merely an optimization.
39
33
 
40
- - trust anchor and which actors can replace it;
41
- - mutable state and canonical versus diagnostic records;
42
- - authority or capability binding and replay scope;
43
- - commit and visibility point;
44
- - behavior when cancellation, integrity failure, or reconciliation failure occurs after an awaited or committed boundary.
34
+ When correctness materially depends on canonical state, partial effects, atomic visibility, concurrency, cancellation, retries, recovery, reconciliation, or evidence of the final outcome, read [State And Failure Boundaries](state-and-failure-boundaries.md).
45
35
 
46
- Retry, resume, caching, continuation, and partial reuse are separate capabilities. Durability does not automatically require them.
36
+ ## 3. Inventory Material Caller Knowledge
47
37
 
48
- ## 3. Inventory Caller Knowledge
38
+ List only facts callers must know and that could affect the boundary:
49
39
 
50
- List every fact a caller, test, reviewer, or future agent must know to use the module correctly:
51
-
52
- ```text
53
- commands / methods
54
- parameters and flags
55
- ordering
56
- states and transitions
57
- paths and filenames
58
- roles and ownership
59
- retries and cleanup
60
- configuration
61
- errors and failure semantics
62
- compatibility and migration
63
- cost and performance expectations
64
- recovery
65
- ```
40
+ - operations and inputs;
41
+ - caller-owned decisions;
42
+ - ordering and lifecycle states;
43
+ - configuration and provider details;
44
+ - dependencies;
45
+ - errors and failure semantics;
46
+ - compatibility and migration;
47
+ - recovery, cost, and performance expectations.
66
48
 
67
49
  For each fact ask:
68
50
 
69
- - Does the caller own this decision?
70
- - Could the module own it instead?
51
+ - Does the caller own it?
52
+ - Could the module own it?
71
53
  - Is it stable enough to expose?
72
54
  - Would changing it force surrounding edits?
73
- - Did a recent fix or review add this knowledge?
74
-
75
- A growing list is direct evidence of a shallow interface.
76
55
 
77
- ## 4. Classify Maturity
56
+ The goal is not zero interface knowledge. It is the smallest honest contract.
78
57
 
79
- Classify proposed capabilities:
58
+ ## 4. Classify Capability Maturity
80
59
 
81
- - **Trust:** needed to know the outcome is valid.
82
- - **Safety:** prevents damage, leakage, or runaway work.
83
- - **Efficiency:** saves time, requests, or money.
84
- - **Scale:** supports concurrency or volume.
85
- - **Portability:** supports additional hosts, providers, or environments.
60
+ Separate:
86
61
 
87
- Required trust and safety cannot be deferred merely to simplify the design. Efficiency, scale, and portability need accepted requirements or observed pressure.
62
+ - required trust and safety;
63
+ - accepted efficiency or scale;
64
+ - demonstrated portability;
65
+ - speculative flexibility.
88
66
 
89
- ## 5. Design It Twice
67
+ Do not defer required correctness to obtain a simpler-looking interface. Do not promote hypothetical efficiency, scale, or portability into present architecture.
90
68
 
91
- Produce two or three materially different interfaces. Change seam placement or ownership, not only names.
69
+ ## 5. Produce Alternatives Only When Real
92
70
 
93
- Useful design constraints:
71
+ When materially different ownership choices remain viable, design two or three interfaces that change seam placement—not only terminology.
94
72
 
95
- - **Outcome-first:** caller asks for one complete result; module owns sequencing.
96
- - **Minimal contract:** expose the fewest stable decisions possible.
97
- - **Common-case:** make the primary caller path trivial while preserving failure honesty.
98
- - **Real variation:** design around two concrete adapters or environments when variation actually exists.
73
+ For each show:
99
74
 
100
- For each design show:
101
-
102
- 1. interface and usage;
75
+ 1. ordinary caller usage;
103
76
  2. caller-owned decisions;
104
77
  3. hidden internal protocol;
105
- 4. failure unit and behavior;
106
- 5. dependency/adapters strategy;
107
- 6. evidence needed to trust it;
108
- 7. costs and limitations.
78
+ 4. failure unit and observable behavior;
79
+ 5. dependency and adapter strategy;
80
+ 6. evidence needed;
81
+ 7. material cost or limitation.
82
+
83
+ When module decomposition, cohesion, dependency direction, cycles, layering, policy-versus-infrastructure ownership, or change propagation materially affects the design, read [Module And Dependency Design](module-and-dependency-design.md).
109
84
 
110
- Do not force multiple designs when the change is local, reversible, and source-backed.
85
+ Do not manufacture alternatives for a local, reversible, source-backed choice.
111
86
 
112
- ## 6. Compare
87
+ ## 6. Compare On Discriminating Criteria
113
88
 
114
- Compare designs by:
89
+ Use only criteria that could change the recommendation:
115
90
 
116
- - depth: behavior gained per interface fact;
117
- - locality: where future changes land;
91
+ - behavior per interface fact;
92
+ - locality of likely change;
93
+ - cohesion and ownership clarity;
118
94
  - correct-use ergonomics;
119
95
  - misuse and hidden-decision risk;
120
- - failure behavior and recoverability;
121
- - contract stability when callers depend on observable details;
122
- - test surface quality;
96
+ - dependency direction;
97
+ - failure honesty and recovery;
98
+ - contract stability;
99
+ - test surface;
123
100
  - reversibility;
124
101
  - maturity fit;
125
102
  - implementation and evidence cost.
126
103
 
127
- Prefer the design that removes concepts and coordination, not the one that centralizes the same choreography behind more terminology.
104
+ Prefer the boundary that removes concepts and coordination, not one that centralizes the same protocol behind additional terminology.
128
105
 
129
106
  ## 7. Learn Before Freezing
130
107
 
131
- If evidence cannot distinguish the designs, define one bounded learning slice:
108
+ When evidence cannot distinguish viable boundaries, define one bounded learning slice:
132
109
 
133
110
  ```text
134
111
  Question:
135
- Competing designs:
136
- Prototype boundary:
137
- Evidence to capture:
138
- Time / cost boundary:
112
+ Competing boundaries:
113
+ Smallest prototype or observation:
114
+ Evidence required:
115
+ Time or cost boundary:
139
116
  Discard-or-promote rule:
140
117
  Return condition:
141
118
  ```
142
119
 
143
- The experiment should answer the design question, not quietly implement the whole subsystem.
120
+ The learning slice answers the design question. It does not quietly implement the whole subsystem.
144
121
 
145
- ## 8. Return To Workflow
122
+ ## 8. Return The Supported Boundary
146
123
 
147
- Return the structural evidence, compared designs, recommendation, unresolved owner decisions, and one narrow route:
124
+ Return:
148
125
 
149
- - continue with the selected interface;
150
- - discuss or ask an owner decision;
151
- - revise the owning Spec or Plan;
152
- - run the bounded learning slice;
153
- - propose a bounded deepening slice;
154
- - defer or stop because no worthwhile safe design fits the current scope.
126
+ - structural evidence;
127
+ - selected boundary and hidden decision;
128
+ - caller-owned contract;
129
+ - module and dependency implications;
130
+ - failure unit and material failure behavior;
131
+ - rejected alternatives and discriminating reason, when alternatives were real;
132
+ - unresolved user-owned decisions;
133
+ - assumptions and required evidence;
134
+ - narrowest next route.
155
135
 
156
- Do not edit merely because one design is recommended. Recommendation is direction; Workflow owns selection and approval boundaries.
136
+ Stop once a boundary is supported or a bounded learning question is identified. Recommendation does not authorize implementation.