@hassangameryt/freeflow 0.6.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 (122) 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 +39 -55
  5. package/capabilities/cognitive-routing/SKILL.md +288 -130
  6. package/command-surface.json +0 -24
  7. package/hooks/freeflow-runtime-context.mjs +42 -477
  8. package/hooks/hooks.json +1 -26
  9. package/hooks/tests/check-runtime-context-hook.sh +108 -319
  10. package/package.json +4 -2
  11. package/pi-extension/dist/cognitive-routing/commands.js +3 -3
  12. package/pi-extension/dist/cognitive-routing/config.js +16 -20
  13. package/pi-extension/dist/cognitive-routing/controller.js +478 -48
  14. package/pi-extension/dist/cognitive-routing/history.js +12 -0
  15. package/pi-extension/dist/cognitive-routing/host.js +74 -12
  16. package/pi-extension/dist/cognitive-routing/pi-routing-session.js +414 -0
  17. package/pi-extension/dist/cognitive-routing/pi-session-control.js +320 -0
  18. package/pi-extension/dist/cognitive-routing/tool.js +1 -0
  19. package/pi-extension/dist/cognitive-routing/types.js +1 -1
  20. package/pi-extension/dist/index.js +236 -219
  21. package/pi-extension/dist/runtime/runtime-context.js +126 -286
  22. package/pi-extension/dist/settings/settings-ui.js +52 -336
  23. package/pi-extension/src/cognitive-routing/commands.ts +15 -5
  24. package/pi-extension/src/cognitive-routing/config.ts +16 -20
  25. package/pi-extension/src/cognitive-routing/controller.ts +561 -51
  26. package/pi-extension/src/cognitive-routing/history.ts +12 -0
  27. package/pi-extension/src/cognitive-routing/host.ts +110 -16
  28. package/pi-extension/src/cognitive-routing/pi-routing-session.ts +538 -0
  29. package/pi-extension/src/cognitive-routing/pi-session-control.ts +444 -0
  30. package/pi-extension/src/cognitive-routing/tool.ts +1 -0
  31. package/pi-extension/src/cognitive-routing/types.ts +1 -1
  32. package/pi-extension/src/index.ts +249 -239
  33. package/pi-extension/src/runtime/runtime-context.ts +129 -305
  34. package/pi-extension/src/settings/settings-ui.ts +53 -371
  35. package/pi-extension/tests/cognitive-routing/commands.test.js +1 -1
  36. package/pi-extension/tests/cognitive-routing/controller.test.js +69 -40
  37. package/pi-extension/tests/cognitive-routing/extension-lifecycle.test.js +128 -57
  38. package/pi-extension/tests/cognitive-routing/pi-normal-lifecycle.test.js +434 -0
  39. package/pi-extension/tests/cognitive-routing/pi-session-control.test.js +174 -0
  40. package/pi-extension/tests/cognitive-routing/pi-session-history.test.js +91 -0
  41. package/pi-extension/tests/cognitive-routing/profile-resolution.test.js +47 -4
  42. package/pi-extension/tests/integration/mode-free-core.test.js +218 -0
  43. package/pi-extension/tests/integration/pi-extension.test.js +430 -2478
  44. package/pi-extension/tests/integration/prompt-architecture.test.js +124 -79
  45. package/pi-extension/tests/integration/unaffected-regressions.test.js +411 -0
  46. package/runtime/prompts/cognitive-routing.md +5 -4
  47. package/runtime/prompts/conversation-history.md +1 -1
  48. package/runtime/prompts/core.md +77 -6
  49. package/runtime/prompts/interaction-contract.md +6 -2
  50. package/skills/action-selection/SKILL.md +93 -44
  51. package/skills/action-selection/references/trajectory-stalls.md +71 -0
  52. package/skills/bypass/SKILL.md +109 -39
  53. package/skills/commit-work/SKILL.md +94 -55
  54. package/skills/commit-work/references/git-state-edges.md +94 -0
  55. package/skills/commit-work/references/simple-push.md +92 -0
  56. package/skills/commit-work/references/staging-decisions.md +79 -46
  57. package/skills/decision-gate/SKILL.md +80 -22
  58. package/skills/design-for-depth/SKILL.md +208 -43
  59. package/skills/design-for-depth/references/design-pressure-signals.md +108 -240
  60. package/skills/design-for-depth/references/interface-design-loop.md +77 -97
  61. package/skills/design-for-depth/references/module-and-dependency-design.md +147 -0
  62. package/skills/design-for-depth/references/software-design-philosophy.md +127 -173
  63. package/skills/design-for-depth/references/state-and-failure-boundaries.md +136 -0
  64. package/skills/diagnose-failure/SKILL.md +198 -52
  65. package/skills/diagnose-failure/references/diagnostic-loop-catalog.md +19 -5
  66. package/skills/diagnose-failure/references/flaky-and-performance-diagnosis.md +13 -5
  67. package/skills/discuss/SKILL.md +118 -76
  68. package/skills/discuss/references/discussion-continuity.md +84 -32
  69. package/skills/evaluate-skill/SKILL.md +166 -52
  70. package/skills/evaluate-skill/references/evaluation-definition-schema.md +2 -2
  71. package/skills/evaluate-skill/references/evaluation-design.md +56 -30
  72. package/skills/evaluate-skill/references/execution-and-evidence.md +1 -1
  73. package/skills/evaluate-skill/references/review-and-revision.md +62 -21
  74. package/skills/execute-work/SKILL.md +98 -59
  75. package/skills/execute-work/references/code-practices.md +4 -4
  76. package/skills/execute-work/references/execute-work-edges.md +42 -22
  77. package/skills/review-artifact/SKILL.md +132 -71
  78. package/skills/review-artifact/references/adjudicate-artifact-review.md +101 -0
  79. package/skills/review-artifact/references/independent-artifact-reviewer-contract.md +52 -41
  80. package/skills/review-work/SKILL.md +115 -72
  81. package/skills/review-work/references/adjudicate-work-review.md +97 -0
  82. package/skills/review-work/references/independent-work-reviewer-contract.md +40 -35
  83. package/skills/review-work/references/security-risk-lens.md +17 -15
  84. package/skills/setup-freeflow/SKILL.md +14 -17
  85. package/skills/setup-freeflow/references/activation-contract.md +24 -30
  86. package/skills/setup-freeflow/references/host-setup.md +6 -7
  87. package/skills/simplify-code/SKILL.md +97 -39
  88. package/skills/simplify-code/references/simplification-patterns.md +1 -1
  89. package/skills/tdd/SKILL.md +108 -41
  90. package/skills/tdd/references/test-design.md +1 -1
  91. package/skills/track-work/SKILL.md +133 -300
  92. package/skills/track-work/references/working-record-format.md +515 -0
  93. package/skills/track-work/scripts/lib/document.mjs +713 -0
  94. package/skills/track-work/scripts/lib/format.mjs +166 -0
  95. package/skills/track-work/scripts/lib/store.mjs +233 -0
  96. package/skills/track-work/scripts/lib/transitions.mjs +790 -0
  97. package/skills/track-work/scripts/lib/views.mjs +27 -430
  98. package/skills/track-work/scripts/working-record.mjs +292 -98
  99. package/skills/verify-work/SKILL.md +46 -20
  100. package/skills/verify-work/references/browser-runtime-evidence.md +1 -1
  101. package/skills/verify-work/references/integration-evidence.md +1 -7
  102. package/skills/verify-work/references/performance-evidence.md +1 -1
  103. package/skills/workflow/SKILL.md +110 -80
  104. package/skills/workflow/references/domain-skill-composition.md +24 -18
  105. package/skills/write-skill/SKILL.md +218 -62
  106. package/skills/write-skill/references/activation-boundaries.md +63 -21
  107. package/skills/write-skill/references/agent-first-instructions.md +61 -27
  108. package/skills/write-skill/references/progressive-disclosure.md +91 -41
  109. package/skills/write-skill/references/skill-dependency-graphs.md +190 -0
  110. package/runtime/prompts/skills.md +0 -65
  111. package/skills/mode-contract/SKILL.md +0 -104
  112. package/skills/track-work/scripts/lib/codec.mjs +0 -570
  113. package/skills/track-work/scripts/lib/commands.mjs +0 -568
  114. package/skills/track-work/scripts/lib/contract.mjs +0 -303
  115. package/skills/track-work/scripts/lib/model.mjs +0 -506
  116. package/skills/track-work/scripts/lib/operations.mjs +0 -965
  117. package/skills/track-work/scripts/lib/record-store.mjs +0 -264
  118. package/skills/track-work/scripts/lib/result.mjs +0 -37
  119. package/skills/track-work/scripts/lib/rewrites.mjs +0 -740
  120. package/skills/track-work/scripts/lib/schema.mjs +0 -277
  121. package/skills/track-work/scripts/lib/source-inventory.mjs +0 -162
  122. package/skills/track-work/scripts/lib/workspace.mjs +0 -134
@@ -1,48 +1,106 @@
1
1
  ---
2
- name: decision-gate
3
- description: Use when proceeding would silently choose for the user, conflict with existing code, tests, docs, or requirements, or take a materially different path from what was requested or agreed.
2
+ name: "decision-gate"
3
+ description: "Use when proceeding would silently choose a consequential outcome for the user, or when accepted sources conflict in a way that leaves one material choice blocking the next action."
4
4
  ---
5
5
 
6
6
  # Decision Gate
7
7
 
8
- Stop before making a decision that belongs to the user or quietly changing the agreed path.
8
+ Resolve one known blocking decision without making it for the user.
9
9
 
10
- The [Interaction Contract](../../runtime/prompts/interaction-contract.md) governs whether the user is asking, proposing, reasoning, or authorizing action. Decision Gate begins only after one blocking choice or conflict is clear. When the problem or alternatives still need broader exploration, read [Discuss](../discuss/SKILL.md) instead.
10
+ A **blocking decision** is a choice whose realistic answers materially change the accepted outcome, scope, behavior, risk, persistence, compatibility, evidence boundary, or next safe action.
11
11
 
12
- ## Stop Here
12
+ Decision Gate is not general discussion, factual investigation, or an approval checkpoint for routine work. It begins only when one blocking choice or source conflict is clear enough to resolve with one direct question.
13
13
 
14
- Use the gate when:
14
+ The [Interaction Contract](../../runtime/prompts/interaction-contract.md) governs whether the user is asking, proposing, deciding, or authorizing action. [Workflow](../workflow/SKILL.md) owns authority and routing.
15
15
 
16
- - the user must choose product behavior, scope, priorities, public interfaces, compatibility, permissions, security, privacy, billing, data-loss behavior, migration direction, or another hard-to-reverse outcome;
17
- - the request conflicts with existing code, tests, docs, policies, requirements, or established behavior;
18
- - the proposed action would materially change what was requested or agreed, including its evidence quality, risk, cost, persistence, or user-visible result;
19
- - new evidence exposes one known user choice or source conflict that must be resolved before proceeding.
16
+ ## Enter With One Decision
20
17
 
21
- Do not use the gate for facts that can be inspected, harmless local choices, or reversible implementation details that preserve the accepted outcome.
18
+ Use Decision Gate only when:
22
19
 
23
- ## Inspect Before Asking
20
+ - the requested or accepted path is known;
21
+ - one unresolved choice or material source conflict can be stated precisely;
22
+ - available evidence and established source precedence do not already settle it;
23
+ - different realistic answers would materially change what follows;
24
+ - proceeding would silently decide for the user or override accepted source truth.
24
25
 
25
- Inspect code, tests, docs, policies, logs, repository state, or current external sources when they can answer the factual part of the problem.
26
+ Do not use Decision Gate for:
26
27
 
27
- Ask the user only for a choice that remains theirs. If you cannot state the decision and meaningful alternatives clearly, the option space is not ready for a gate; use Discuss.
28
+ - facts available through focused passive inspection;
29
+ - reversible implementation details that preserve the accepted outcome;
30
+ - ordinary authorization for one clear additional action;
31
+ - preferences that do not affect the result or its acceptance;
32
+ - hypothetical edge cases without supported reachability or consequence;
33
+ - broad or unsettled option spaces that still require exploration.
34
+
35
+ Use [Discuss](../discuss/SKILL.md) when the problem, alternatives, assumptions, or direction are not yet bounded enough for one decision.
36
+
37
+ When several decisions appear, ask only the earliest one whose answer determines whether the others remain relevant. Do not turn the gate into an interview.
38
+
39
+ ## Resolve Facts Before Asking
40
+
41
+ Inspect the smallest existing evidence that can settle the factual part: the current request, accepted decisions, code, tests, documentation, Specs, policies, ADRs, repository state, supplied artifacts, and current primary sources when relevant.
42
+
43
+ Do not ask the user to choose between factual claims whose truth can be established from available evidence.
44
+
45
+ When accepted sources appear to conflict:
46
+
47
+ 1. state each source's exact claim and applicable scope;
48
+ 2. determine whether each is current, accepted, draft, historical, generated, or advisory;
49
+ 3. apply repository-defined precedence or maintenance policy when one exists;
50
+ 4. identify the observable consequence of following each claim.
51
+
52
+ A difference is material only when applicable sources make incompatible claims and selecting between them changes the accepted result or next safe action.
53
+
54
+ Do not invent a universal hierarchy: code is not automatically correct because it runs, tests are not automatically requirements because they fail, documentation is not automatically stale because implementation differs, and task memory does not override live accepted source truth.
55
+
56
+ If established precedence resolves the conflict, return the supported result to Workflow without asking a decision question. Updating an inconsistent source belongs to its owning activity and requires its own authority.
57
+
58
+ If responsible framing requires new active evidence, return the exact claim, proposed observer, expected evidence, and stop condition to Workflow. Decision Gate does not run an experiment merely to make its question easier.
28
59
 
29
60
  ## Ask One Direct Question
30
61
 
31
- State:
62
+ State proportionately:
32
63
 
33
- 1. what was requested or previously agreed;
34
- 2. the conflicting evidence, missing choice, or materially different path;
64
+ 1. the requested or previously accepted path;
65
+ 2. the exact missing choice or conflicting evidence;
35
66
  3. why it changes the next action;
36
- 4. the meaningful options and tradeoffs;
67
+ 4. the realistic options and material tradeoffs;
37
68
  5. a recommendation when evidence supports one;
38
69
  6. one direct question that resolves the block.
39
70
 
71
+ Frame the choice around the outcome the user owns, not ordinary implementation mechanics. Do not ask which file to change when the real decision is which behavior or contract should govern.
72
+
73
+ Do not manufacture a menu. Omit dominated, unsafe, unavailable, or hypothetical options. A direct yes-or-no question is appropriate when one supported deviation needs a decision. Include preserving the current behavior, waiting, or stopping only when each is real.
74
+
75
+ Recommend plainly when one path is better supported. State its principal tradeoff and what evidence or changed priority would alter the recommendation. A recommendation is not the user's decision.
76
+
40
77
  Then stop. Do not perform the blocked action in the same response.
41
78
 
42
- Urgency, approval to continue, reviewer confidence, or existing practice does not resolve an unnamed decision or conflict.
79
+ Urgency, prior effort, reviewer confidence, common practice, or general approval to continue does not resolve an unnamed decision or source conflict.
80
+
81
+ ## Interpret And Return The Decision
82
+
83
+ Treat an explicit choice as resolving only the decision that was asked. A question, criticism, hypothesis, preference, conditional answer, or request for more information is not automatically a decision; respond to its substance and keep the blocked action stopped.
84
+
85
+ Route narrowly:
86
+
87
+ - explicit choice with a clear covered path → Workflow;
88
+ - answer that reopens alternatives or assumptions → Discuss;
89
+ - unresolved factual evidence → Workflow and the appropriate evidence owner;
90
+ - defer, preserve, or stop → return that outcome without forcing progress.
91
+
92
+ A resolved decision may complete the missing intent for a still-valid request. It does not authorize unrelated effects or another outcome by implication.
93
+
94
+ Return to Workflow with:
95
+
96
+ - the exact decision and who or what established it;
97
+ - the selected outcome and important exclusions;
98
+ - material consequences and affected source truth;
99
+ - remaining uncertainty or revisit condition;
100
+ - the authority state of the next action.
43
101
 
44
- ## Exit
102
+ When losing the decision or its rationale could cause later misalignment, Workflow may route [Track Work](../track-work/SKILL.md) to preserve it. Decision Gate does not mutate task memory itself.
45
103
 
46
- Exit when the choice is explicit, the conflict is resolved, and remaining uncertainty would not change the next safe action.
104
+ Do not broaden the answer, reinterpret it as approval for a different path, or continue past another separately controlled boundary.
47
105
 
48
- Preserve the decision accurately for the work that depends on it. Do not broaden the decision or treat it as approval for a different path.
106
+ Stop when one direct question has been asked and no answer exists, the answer does not resolve the material block, the appropriate decision owner is unavailable, or active evidence is required before a responsible choice can be framed. A supported wait, deferment, preservation boundary, or stop is a valid result.
@@ -1,87 +1,252 @@
1
1
  ---
2
2
  name: design-for-depth
3
- description: Use when working with software design—especially boundaries, interfaces, ownership, state, and failure behavior.
3
+ description: Use during coding and software design to keep boundaries, interfaces, ownership, state, dependencies, and failure behavior simple and proportionate.
4
4
  ---
5
5
 
6
6
  # Design For Depth
7
7
 
8
- Reduce coordination by hiding internal decisions behind small, stable, outcome-level interfaces.
8
+ Reduce coordination by hiding coherent, likely-changing decisions behind small, stable, outcome-level interfaces.
9
9
 
10
- A **module** is anything with an interface and implementation. A **caller** is anything that uses or coordinates the module through its interface, such as application code, another service, a script, a test, a tool, or an agent. Its **interface** is every fact callers must know to use it correctly: inputs, decisions, states, ordering, errors, side effects, configuration, timing, and failure behavior. **Depth** is useful behavior and hidden complexity per unit of interface knowledge.
10
+ A **module** is anything with an interface and implementation. A **caller** is anything that uses it. The **interface** is every fact callers must know to use it correctly: operations, inputs, decisions, states, ordering, errors, side effects, dependencies, configuration, timing, and recovery.
11
11
 
12
- A **seam** is a boundary where behavior, dependencies, or observation can change without forcing surrounding edits. An **adapter** is a concrete implementation supplied at that seam. Add a seam for real variation or a required testing or observation boundary—not imagined flexibility.
12
+ **Depth** is useful coherent behavior and hidden complexity per unit of caller knowledge.
13
13
 
14
- Use this as a compositional lens, not a mandatory phase or permission to refactor.
14
+ Use this as a compositional lens under the active activity. It is not a mandatory phase, authority source, architecture owner, or reason to refactor.
15
15
 
16
- ## Compose The Lens Early
16
+ ## Orient Broadly, Deepen Narrowly
17
17
 
18
- Use this lens during design-bearing discussion before core boundaries settle. Use it while writing a Spec or Plan when ownership, interfaces, state, or failure behavior shapes the contract. Keep it available during execution, TDD, and review when the work must preserve those decisions or exposes new coordination.
18
+ Use breadth of understanding before depth of intervention.
19
19
 
20
- Feedback may also route here after [Diagnose Failure](../diagnose-failure/SKILL.md) establishes structural ownership, interface, state, or failure-unit pressure. Ordinary bugs, failed tests, or finding count do not prove bad design.
20
+ Before deepening a design, understand only the material breadth:
21
21
 
22
- Do not force this lens onto a local change whose interface remains sound. Do not use architecture language to hide product decisions or turn reversible implementation detail into ceremony.
22
+ - complete caller outcome;
23
+ - caller-owned decisions;
24
+ - existing interface and dependencies;
25
+ - canonical state and visible transitions;
26
+ - success, failure, and recovery boundary;
27
+ - current constraints and accepted non-goals;
28
+ - evidence capable of changing the design route.
23
29
 
24
- ## Start With Outcome And Failure
30
+ Then deepen only the decision, seam, state boundary, or failure unit whose ownership could materially change the result.
25
31
 
26
- Before choosing classes, services, states, or adapters, establish:
32
+ Do not broaden the task merely to complete the survey. Do not discuss every design topic, inspect every dependency, generate every alternative, or design the whole system.
27
33
 
28
- - the complete outcome callers need and the decisions they genuinely own;
29
- - the coordination or likely-changing policy the module can hide;
30
- - visible success and the **failure unit**—the smallest outcome treated as one success, failure, and recovery boundary;
31
- - failure observers, state or evidence written, forbidden partial outcomes, response policy (stop, fail closed/open, degrade, retry, or escalate), safe restart, recovery, and required proof.
34
+ ## Start Shallow
32
35
 
33
- These form the **failure contract**. Failure behavior is part of the interface even when its mechanism remains private.
36
+ For any coding or design task, ask:
34
37
 
35
- When the boundary changes product behavior, public interfaces, compatibility, permissions, security, privacy, billing, data loss, migration direction, or another user-owned outcome, use [Decision Gate](../decision-gate/SKILL.md). This lens surfaces the decision; it does not make it silently.
38
+ 1. What complete outcome is changing?
39
+ 2. What must callers currently know or coordinate?
40
+ 3. Does this change add caller knowledge, spread policy, alter dependency direction, or change state or failure ownership?
41
+ 4. Would keeping the current boundary make correct use or the next likely change materially harder?
36
42
 
37
- ## Hide Coordination
43
+ When the change is local, source-backed, reversible, and leaves the interface, dependencies, state, and failure unit sound:
38
44
 
39
- Prefer interfaces where callers ask for an outcome and the module owns internal protocol.
45
+ - apply this lens silently;
46
+ - preserve accepted behavior;
47
+ - do not load references;
48
+ - do not present architectural alternatives;
49
+ - do not widen the task.
40
50
 
41
- Before exposing a flag, state, path, filename, ordering rule, retry, timing behavior, or error, ask:
51
+ A large mechanical change may need no design escalation. A one-line change may require it when permissions, canonical state, public behavior, compatibility, or consequential failure changes.
42
52
 
43
- - Does the caller own this choice?
53
+ An abstraction is not required merely because code is duplicated, tests are awkward, or another design is imaginable.
54
+
55
+ ## Enter Early Or Re-enter From Evidence
56
+
57
+ Use this lens early when ownership, interface, state, dependency, or failure decisions could harden into caller contracts before implementation.
58
+
59
+ Early design may support:
60
+
61
+ - discussion;
62
+ - a Spec or Plan;
63
+ - an API or module boundary;
64
+ - a state transition;
65
+ - a consequential integration;
66
+ - test-seam selection.
67
+
68
+ During implementation, testing, and review, preserve a supported boundary without reopening it merely because this lens remains in context.
69
+
70
+ Re-enter later only when direct evidence shows:
71
+
72
+ - caller coordination growing;
73
+ - policy or state spreading;
74
+ - repeated patches adding flags or lifecycle knowledge;
75
+ - tests reproducing internal choreography;
76
+ - dependencies or failures crossing unclear ownership;
77
+ - prior boundary assumptions becoming false.
78
+
79
+ When repeated or unexplained failure lacks a supported cause, use [Diagnose Failure](../diagnose-failure/SKILL.md) first. Diagnosis owns causal investigation. This lens consumes supported structural evidence without recreating the diagnosis.
80
+
81
+ ## Establish The Outcome And Failure Unit
82
+
83
+ Before choosing classes, services, packages, adapters, or states, name:
84
+
85
+ - caller and complete outcome;
86
+ - caller-visible success and failure;
87
+ - decisions the caller genuinely owns;
88
+ - coordination or likely-changing policy the module could hide;
89
+ - the **failure unit**: the coherent outcome treated as one success, failure, and recovery boundary.
90
+
91
+ When the boundary has side effects, can leave partial state, or makes failure materially consequential, establish its **failure contract**:
92
+
93
+ - who observes failure;
94
+ - canonical and diagnostic state written;
95
+ - forbidden partial outcomes;
96
+ - stop, fail-open, fail-closed, degrade, retry, or escalation behavior;
97
+ - cancellation and concurrency behavior when relevant;
98
+ - safe restart, recovery, and reconciliation;
99
+ - evidence required to prove the outcome.
100
+
101
+ Failure behavior is part of the interface even when its mechanism remains private.
102
+
103
+ Depth is not breadth. A deep module owns one coherent decision or failure unit. It does not collect unrelated responsibilities merely to reduce method count.
104
+
105
+ Use [Decision Gate](../decision-gate/SKILL.md) when the boundary changes product behavior, public interfaces, compatibility, permissions, security, privacy, billing, data-loss behavior, migration direction, or another user-owned outcome.
106
+
107
+ ## Hide Coordination And Likely-Changing Decisions
108
+
109
+ Prefer interfaces where callers request an outcome and the module owns its internal protocol.
110
+
111
+ Before exposing a flag, path, state, ordering rule, retry, provider detail, timing behavior, dependency choice, or recovery step, ask:
112
+
113
+ - Does the caller genuinely own this choice?
44
114
  - Does exposing it make correct use easier?
45
- - Is it stable enough to become a contract?
115
+ - Is it stable enough to become a supported contract?
116
+ - Which surrounding edits would occur if it changed?
46
117
  - Could one outcome-level operation hide it?
47
118
 
48
- Keep caller-owned outcomes and decisions public. Keep internal sequencing, storage, cleanup, provider mechanics, integrity publication, and optimization private unless correct use requires caller control.
119
+ Keep public:
49
120
 
50
- Read [software design philosophy](references/software-design-philosophy.md) when structural pressure is supported but the likely-changing decision or missing information-hiding boundary cannot yet be named.
121
+ - caller-owned outcomes and decisions;
122
+ - stable invariants;
123
+ - necessary inputs;
124
+ - observable success and failure semantics;
125
+ - information required for correct recovery.
126
+
127
+ Keep private unless callers genuinely control them:
128
+
129
+ - sequencing;
130
+ - storage layout;
131
+ - provider mechanics;
132
+ - retries and cleanup;
133
+ - temporary states;
134
+ - cache and optimization machinery;
135
+ - diagnostic implementation;
136
+ - dependency construction.
137
+
138
+ A **seam** is a boundary where behavior, dependencies, or observation can change without forcing surrounding edits. An **enabling point** is where an adapter, test implementation, clock, probe, provider, or migration path enters that seam.
139
+
140
+ Add a seam for demonstrated variation, a known migration, a required observation boundary, or a dependency that must be controlled in tests—not imagined flexibility.
51
141
 
52
142
  ## Recognize Structural Pressure
53
143
 
54
- Structural pressure appears when caller knowledge, duplicated policy, lifecycle choreography, test-only exposure, or unowned failure behavior spreads across a boundary, or a bounded outcome requires an unplanned subsystem because no current seam owns it.
144
+ Structural pressure is evidence that the current boundary is increasing coordination or hiding no useful decision.
145
+
146
+ Pressure may appear as:
147
+
148
+ - change amplification across unrelated callers;
149
+ - caller lifecycle choreography;
150
+ - scattered policy;
151
+ - unowned canonical state or failure behavior;
152
+ - growing flags, temporary states, retries, or recovery rules;
153
+ - tests coupled to machinery rather than accepted behavior;
154
+ - infrastructure details leaking into policy;
155
+ - edge-case patches revealing one shared contract gap;
156
+ - a bounded result unexpectedly requiring a subsystem.
157
+
158
+ Ordinary bugs, failed tests, duplicate code, broad mechanical edits, finding count, and personal design preference do not prove structural pressure.
159
+
160
+ When observed coordination could change the next route, read [Design Pressure Signals](references/design-pressure-signals.md). Skip it only when an equivalent route classification is already supported.
161
+
162
+ When structural pressure is supported but the likely-changing decision or missing information-hiding boundary cannot yet be named, read [Software Design Philosophy](references/software-design-philosophy.md).
163
+
164
+ Read the narrowest reference whose condition matches the current question. Read another only if its distinct question remains afterward.
165
+
166
+ ## Choose The Required Design Depth
167
+
168
+ Read [Interface Design Loop](references/interface-design-loop.md) before:
169
+
170
+ - comparing materially different interfaces;
171
+ - selecting consequential ownership;
172
+ - freezing an important correctness boundary;
173
+ - choosing among real seam placements.
174
+
175
+ Read [State And Failure Boundaries](references/state-and-failure-boundaries.md) when correctness materially depends on:
176
+
177
+ - canonical state;
178
+ - partial effects;
179
+ - atomic visibility;
180
+ - concurrency or cancellation;
181
+ - idempotency and retries;
182
+ - recovery or reconciliation;
183
+ - failure evidence.
184
+
185
+ Read [Module And Dependency Design](references/module-and-dependency-design.md) when the question materially concerns:
186
+
187
+ - module decomposition;
188
+ - cohesion and conceptual integrity;
189
+ - dependency direction;
190
+ - cycles or layering;
191
+ - policy versus infrastructure;
192
+ - shared ownership;
193
+ - ports and adapters.
194
+
195
+ Several references may apply to one consequential boundary. Read them one at a time and only while each distinct condition remains.
196
+
197
+ ## Test Through The Intended Interface
55
198
 
56
- Read [design pressure signals](references/design-pressure-signals.md) when that evidence may change the next route. The reference owns the detailed classifier and examples; the signals justify design attention, not automatic refactoring.
199
+ The intended interface is the normal behavior and test surface.
57
200
 
58
- Diagnose repeated or unexplained failure before redesigning. Direct design work is appropriate when structural pressure is already observable or an important boundary must be chosen before implementation.
201
+ Question the design before adding test machinery when callers or tests must:
59
202
 
60
- ## Shape The Interface
203
+ - bypass the intended interface;
204
+ - reproduce lifecycle choreography;
205
+ - mock many internals to verify one outcome;
206
+ - depend on private temporary states;
207
+ - know dependency construction callers should not own.
61
208
 
62
- Before comparing materially different interfaces, read [the interface design loop](references/interface-design-loop.md) when structural pressure or an important pre-implementation correctness boundary makes ownership consequential, especially when authority, canonical state, atomic visibility, replay, cancellation, or post-commit recovery affects correctness.
209
+ Do not redesign merely because an internal test observes internals. The problem is external callers requiring knowledge the module should hide.
63
210
 
64
- The reference owns the complete comparison method. Prefer the interface that removes caller knowledge, localizes likely change, makes correct use easy, preserves honest failure and recovery, and costs proportionate evidence.
211
+ Architecture-bearing tests should protect:
65
212
 
66
- Do not force multiple designs for an obvious local choice. When evidence cannot distinguish viable seams, use the reference's bounded learning route rather than quietly implementing the whole subsystem.
213
+ - accepted behavior;
214
+ - visible failure;
215
+ - state invariants;
216
+ - forbidden partial outcomes;
217
+ - settled recovery behavior;
218
+ - a real dependency or observation seam.
67
219
 
68
- ## Tests And Evidence
220
+ Tests that protect only accidental machinery do not justify that machinery.
69
221
 
70
- The intended interface is the normal test surface. If tests must bypass it, reproduce caller choreography, or mock many owned internals, question the module shape before adding test machinery.
222
+ Exploratory code can produce design evidence. It does not become production architecture without deliberate selection, authorized implementation, and verification at the required boundary.
71
223
 
72
- Architecture-bearing tests should protect accepted behavior, observed failure, or a settled failure contract. Tests that exist only to protect unnecessary machinery do not justify that machinery.
224
+ ## Return The Narrowest Supported Route
73
225
 
74
- Exploratory code may produce design evidence. It does not become production architecture without deliberate selection through [Workflow](../workflow/SKILL.md), implementation as an authorized slice, and verification at the required boundary.
226
+ Return a changed ownership, scope, authority, or route boundary through [Workflow](../workflow/SKILL.md). Otherwise return to the active activity with:
75
227
 
76
- ## Boundary Examples
228
+ - structural evidence;
229
+ - affected caller outcome;
230
+ - interface, module, dependency, state, and failure unit involved;
231
+ - likely-changing or currently unowned decision;
232
+ - materially different alternatives only when real;
233
+ - recommendation and assumptions;
234
+ - unresolved user-owned decisions;
235
+ - evidence still required;
236
+ - narrowest route.
77
237
 
78
- - A core operation is being discussed, but partial failure is unspecified → define the failure unit and surface any owner decision before settling the interface.
79
- - Every caller coordinates retry, storage, cleanup, and error translation → consider an outcome-level module that owns the protocol.
80
- - One isolated condition is wrong while callers and the interface remain valid → make a local correction; do not redesign.
81
- - Related failures repeatedly add shared states and caller rules → diagnose the common cause, then use this lens only when structural pressure is supported.
238
+ Possible routes include:
82
239
 
83
- ## Return The Route
240
+ - continue with the current boundary;
241
+ - make a local correction;
242
+ - diagnose an unsupported cause;
243
+ - revise a Spec or Plan;
244
+ - use [Simplify Code](../simplify-code/SKILL.md) for behavior-preserving reduction;
245
+ - run a bounded learning slice;
246
+ - propose bounded deepening;
247
+ - defer supported design pressure;
248
+ - stop for owner direction.
84
249
 
85
- Return the structural evidence, affected boundary, materially different options when needed, recommendation, and unresolved owner decisions to Workflow. Recommend the narrowest route: continue, run a learning slice, revise a Spec or Plan, use Decision Gate, propose a bounded deepening slice, defer, or stop.
250
+ A design recommendation does not authorize implementation.
86
251
 
87
- A design recommendation does not authorize implementation. Do not expose speculative variation, broaden accepted scope, or refactor merely because a deeper design is possible. Freeze a supported design boundary instead of pursuing architectural completeness.
252
+ Freeze a supported boundary instead of pursuing architectural completeness. Retain the decision, not perpetual design activity.