@punks/cli 4.0.1 → 4.0.3

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 (172) hide show
  1. package/dist/BASELINE_CHANGELOG.md +34 -0
  2. package/dist/CHANGELOG.md +24 -0
  3. package/dist/baseline/scaffold-baseline/baseline.json +5 -5
  4. package/dist/baseline/scaffold-baseline/data/catalog/lint-assets.json +10 -4
  5. package/dist/baseline/scaffold-baseline/data/catalog/packs.json +2 -3
  6. package/dist/baseline/scaffold-baseline/data/catalog/skills.json +8 -8
  7. package/dist/baseline/scaffold-baseline/data/hooks/format-edited-file.mjs +602 -101
  8. package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.d.ts +11 -0
  9. package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.mjs +103 -0
  10. package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.test.ts +144 -0
  11. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/adapters/claude.mjs +1 -0
  12. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/adapters/codex.mjs +1 -0
  13. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/adapters/cursor.mjs +1 -0
  14. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/adapters/opencode.mjs +1 -0
  15. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/contract.ts +24 -33
  16. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/core.mjs +4 -0
  17. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/core.test.ts +61 -0
  18. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/lint-feedback.test.ts +123 -0
  19. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/test-fixtures/claude/actions.json +1 -0
  20. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/test-fixtures/codex/actions.json +2 -1
  21. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/test-fixtures/cursor/projection.json +1 -0
  22. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/test-fixtures/opencode/projection.json +1 -0
  23. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/docs-onboarding/SKILL.md +2 -2
  24. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/SKILL.md +32 -32
  25. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/assets/SPEC-TEMPLATE.md +7 -7
  26. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/references/readiness.md +14 -13
  27. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/references/spec-quality-bar.md +26 -19
  28. package/dist/baseline/scaffold-baseline/skills/agnostic/quality/autoreview/SKILL.md +2 -2
  29. package/dist/baseline/scaffold-baseline/skills/agnostic/quality/autoreview/scripts/autoreview +3 -0
  30. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/brainstorm/SKILL.md +12 -0
  31. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/requirements-grill/SKILL.md +2 -1
  32. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/EXAMPLES.md +9 -9
  33. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/REFERENCE.md +43 -55
  34. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/SKILL.md +68 -63
  35. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/concepts/backlog-model.md +26 -29
  36. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/concepts/story-shape.md +5 -5
  37. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/providers/azure-devops-create-payload.md +1 -1
  38. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/providers/github-projects-create-payload.md +2 -2
  39. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/providers/linear-create-payload.md +1 -1
  40. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/providers/monday-create-payload.md +2 -2
  41. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/business-projection.md +19 -24
  42. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/delivery-status.md +17 -13
  43. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/fog-intake.md +45 -48
  44. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/functional-projection.md +16 -21
  45. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/normalization.md +14 -14
  46. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/project-context.md +32 -27
  47. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/providers/github.md +105 -150
  48. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/providers/linear.md +111 -181
  49. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/technical-projection.md +51 -47
  50. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/scripts/validate-task-blocker-graph.mjs +49 -35
  51. package/dist/baseline/scaffold-baseline/skills/agnostic/research/parallel-research/DURABLE-REPORT.md +5 -12
  52. package/dist/baseline/scaffold-baseline/skills/agnostic/research/parallel-research/SKILL.md +7 -8
  53. package/dist/baseline/scaffold-baseline/skills/agnostic/security/architect-pipeline/SKILL.md +97 -0
  54. package/dist/baseline/scaffold-baseline/skills/agnostic/security/architect-pipeline/agents/openai.yaml +4 -0
  55. package/dist/baseline/scaffold-baseline/skills/agnostic/security/architect-pipeline/references/infrastructure-deployment.md +29 -0
  56. package/dist/baseline/scaffold-baseline/skills/agnostic/security/architect-pipeline/references/security-by-design.md +22 -0
  57. package/dist/baseline/scaffold-baseline/skills/agnostic/security/security-best-practices/references/javascript-typescript-vue-web-frontend-security.md +1 -1
  58. package/dist/baseline/scaffold-baseline/skills/frameworks/expo/eas-update-insights/references/update-insights-schema.md +2 -6
  59. package/dist/baseline/scaffold-baseline/skills/frameworks/expo/expo-skill-eval/SKILL.md +6 -7
  60. package/dist/baseline/scaffold-baseline/skills/frameworks/pulumi/provider-upgrade/SKILL.md +10 -7
  61. package/dist/baseline/scaffold-baseline/skills/frameworks/pulumi/pulumi-best-practices/SKILL.md +19 -53
  62. package/dist/baseline/scaffold-baseline/skills/frameworks/pulumi/pulumi-component/SKILL.md +36 -88
  63. package/dist/baseline/scaffold-baseline/skills/frameworks/tanstack-query/tanstack-query/references/best-practices.md +7 -1
  64. package/dist/baseline/scaffold-baseline/skills/frameworks/tanstack-query/tanstack-query/templates/devtools-setup.tsx +4 -0
  65. package/dist/baseline/scaffold-baseline/skills/frameworks/trpc/tanstack-query/references/best-practices.md +7 -1
  66. package/dist/baseline/scaffold-baseline/skills/frameworks/trpc/tanstack-query/templates/devtools-setup.tsx +4 -0
  67. package/dist/baseline/scaffold-baseline/skills/languages/typescript/quality-types/SKILL.md +1 -3
  68. package/dist/baseline/scaffold-baseline/skills/phases/business-finder/SKILL.md +29 -16
  69. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/router.md +10 -8
  70. package/dist/baseline/scaffold-baseline/skills/phases/design-phase/phases/backlog.md +26 -17
  71. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/AUTHORING-HANDOFF.md +51 -261
  72. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/SKILL.md +22 -25
  73. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/ensure-fog.md +13 -23
  74. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/grilling.md +40 -0
  75. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/handback.md +11 -18
  76. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/prototype.md +13 -21
  77. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/reconcile.md +21 -35
  78. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/research.md +13 -18
  79. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/return-target.md +14 -25
  80. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/router.md +22 -56
  81. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/references/entrypoint-contract.md +25 -26
  82. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/references/root-routing.md +12 -20
  83. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/references/runtime-handoff.md +17 -39
  84. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/references/state-graph.md +27 -49
  85. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/scripts/finder-contract.mjs +40 -359
  86. package/dist/baseline/scaffold-baseline/skills/phases/functional-finder/SKILL.md +29 -62
  87. package/dist/baseline/scaffold-baseline/skills/phases/requirements-phase/SKILL.md +49 -13
  88. package/dist/baseline/scaffold-baseline.json +5 -5
  89. package/dist/baseline/scaffold-baseline.tgz +0 -0
  90. package/dist/data/hooks/format-edited-file.d.mts +21 -0
  91. package/dist/data/hooks/format-edited-file.mjs +588 -98
  92. package/dist/data/scripts/commit-gate-runner.mjs +103 -0
  93. package/dist/data/scripts/harness-projection/adapters/claude.mjs +1 -0
  94. package/dist/data/scripts/harness-projection/adapters/codex.mjs +1 -0
  95. package/dist/data/scripts/harness-projection/adapters/cursor.mjs +1 -0
  96. package/dist/data/scripts/harness-projection/adapters/opencode.mjs +1 -0
  97. package/dist/data/scripts/harness-projection/core.mjs +4 -0
  98. package/dist/data/scripts/harness-projection/test-fixtures/claude/actions.json +1 -0
  99. package/dist/data/scripts/harness-projection/test-fixtures/codex/actions.json +2 -1
  100. package/dist/data/scripts/harness-projection/test-fixtures/cursor/projection.json +1 -0
  101. package/dist/data/scripts/harness-projection/test-fixtures/opencode/projection.json +1 -0
  102. package/dist/index.js +73 -58
  103. package/dist/skills/agnostic/docs/docs-onboarding/SKILL.md +2 -2
  104. package/dist/skills/agnostic/planning/create-spec/SKILL.md +32 -32
  105. package/dist/skills/agnostic/planning/create-spec/assets/SPEC-TEMPLATE.md +7 -7
  106. package/dist/skills/agnostic/planning/create-spec/references/readiness.md +14 -13
  107. package/dist/skills/agnostic/planning/create-spec/references/spec-quality-bar.md +26 -19
  108. package/dist/skills/agnostic/quality/autoreview/SKILL.md +2 -2
  109. package/dist/skills/agnostic/quality/autoreview/scripts/autoreview +3 -0
  110. package/dist/skills/agnostic/requirements/brainstorm/SKILL.md +12 -0
  111. package/dist/skills/agnostic/requirements/requirements-grill/SKILL.md +2 -1
  112. package/dist/skills/agnostic/requirements/write-backlog/EXAMPLES.md +9 -9
  113. package/dist/skills/agnostic/requirements/write-backlog/REFERENCE.md +43 -55
  114. package/dist/skills/agnostic/requirements/write-backlog/SKILL.md +68 -63
  115. package/dist/skills/agnostic/requirements/write-backlog/assets/concepts/backlog-model.md +26 -29
  116. package/dist/skills/agnostic/requirements/write-backlog/assets/concepts/story-shape.md +5 -5
  117. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/azure-devops-create-payload.md +1 -1
  118. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/github-projects-create-payload.md +2 -2
  119. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/linear-create-payload.md +1 -1
  120. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/monday-create-payload.md +2 -2
  121. package/dist/skills/agnostic/requirements/write-backlog/references/business-projection.md +19 -24
  122. package/dist/skills/agnostic/requirements/write-backlog/references/delivery-status.md +17 -13
  123. package/dist/skills/agnostic/requirements/write-backlog/references/fog-intake.md +45 -48
  124. package/dist/skills/agnostic/requirements/write-backlog/references/functional-projection.md +16 -21
  125. package/dist/skills/agnostic/requirements/write-backlog/references/normalization.md +14 -14
  126. package/dist/skills/agnostic/requirements/write-backlog/references/project-context.md +32 -27
  127. package/dist/skills/agnostic/requirements/write-backlog/references/providers/github.md +97 -142
  128. package/dist/skills/agnostic/requirements/write-backlog/references/providers/linear.md +106 -176
  129. package/dist/skills/agnostic/requirements/write-backlog/references/technical-projection.md +51 -47
  130. package/dist/skills/agnostic/requirements/write-backlog/scripts/validate-task-blocker-graph.mjs +55 -31
  131. package/dist/skills/agnostic/research/parallel-research/DURABLE-REPORT.md +5 -12
  132. package/dist/skills/agnostic/research/parallel-research/SKILL.md +7 -8
  133. package/dist/skills/agnostic/security/architect-pipeline/SKILL.md +97 -0
  134. package/dist/skills/agnostic/security/architect-pipeline/agents/openai.yaml +4 -0
  135. package/dist/skills/agnostic/security/architect-pipeline/references/infrastructure-deployment.md +29 -0
  136. package/dist/skills/agnostic/security/architect-pipeline/references/security-by-design.md +22 -0
  137. package/dist/skills/frameworks/pulumi/provider-upgrade/SKILL.md +10 -7
  138. package/dist/skills/frameworks/pulumi/pulumi-best-practices/SKILL.md +10 -42
  139. package/dist/skills/frameworks/pulumi/pulumi-component/SKILL.md +18 -58
  140. package/dist/skills/phases/business-finder/SKILL.md +29 -16
  141. package/dist/skills/phases/delivery-phase/phases/router.md +10 -8
  142. package/dist/skills/phases/design-phase/phases/backlog.md +26 -17
  143. package/dist/skills/phases/finder-phase/AUTHORING-HANDOFF.md +51 -261
  144. package/dist/skills/phases/finder-phase/SKILL.md +22 -25
  145. package/dist/skills/phases/finder-phase/phases/ensure-fog.md +13 -23
  146. package/dist/skills/phases/finder-phase/phases/grilling.md +40 -0
  147. package/dist/skills/phases/finder-phase/phases/handback.md +11 -18
  148. package/dist/skills/phases/finder-phase/phases/prototype.md +13 -21
  149. package/dist/skills/phases/finder-phase/phases/reconcile.md +21 -35
  150. package/dist/skills/phases/finder-phase/phases/research.md +13 -18
  151. package/dist/skills/phases/finder-phase/phases/return-target.md +14 -25
  152. package/dist/skills/phases/finder-phase/phases/router.md +22 -56
  153. package/dist/skills/phases/finder-phase/references/entrypoint-contract.md +25 -26
  154. package/dist/skills/phases/finder-phase/references/root-routing.md +12 -20
  155. package/dist/skills/phases/finder-phase/references/runtime-handoff.md +17 -39
  156. package/dist/skills/phases/finder-phase/references/state-graph.md +27 -49
  157. package/dist/skills/phases/finder-phase/scripts/finder-contract.mjs +44 -357
  158. package/dist/skills/phases/functional-finder/SKILL.md +29 -62
  159. package/dist/skills/phases/requirements-phase/SKILL.md +49 -13
  160. package/package.json +7 -5
  161. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/adopt-business-path.md +0 -52
  162. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/business-grilling.md +0 -68
  163. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/functional-grilling.md +0 -53
  164. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/technical-grilling.md +0 -67
  165. package/dist/baseline/scaffold-baseline/skills/phases/technical-finder/SKILL.md +0 -74
  166. package/dist/baseline/scaffold-baseline/skills/phases/technical-finder/agents/openai.yaml +0 -2
  167. package/dist/skills/phases/finder-phase/phases/adopt-business-path.md +0 -52
  168. package/dist/skills/phases/finder-phase/phases/business-grilling.md +0 -68
  169. package/dist/skills/phases/finder-phase/phases/functional-grilling.md +0 -53
  170. package/dist/skills/phases/finder-phase/phases/technical-grilling.md +0 -67
  171. package/dist/skills/phases/technical-finder/SKILL.md +0 -74
  172. package/dist/skills/phases/technical-finder/agents/openai.yaml +0 -2
@@ -1,10 +1,8 @@
1
1
  # Runtime Handoff
2
2
 
3
3
  Store the current record at
4
- `.devpunks/finder-phase/handoffs/<durable-wiki-fog-id>.md`. Before provider
5
- creation, allocate that durable wiki identity once and use it for every retry.
6
- After exact provider readback, add the stable provider Fog identity without
7
- replacing the wiki identity.
4
+ `.devpunks/finder-phase/handoffs/<durable-wiki-fog-id>.md`. Allocate the durable
5
+ wiki identity once before provider creation and retain it across retries.
8
6
 
9
7
  ```text
10
8
  Phase:
@@ -17,46 +15,26 @@ UI Evidence:
17
15
  Next suggested route:
18
16
  Blockers:
19
17
  Resume identity:
20
-
21
- Finder target depth:
22
18
  Durable wiki Fog identity:
23
19
  Provider Fog identity:
24
20
  Provider snapshot identity:
21
+ Immutable original intake lens:
25
22
  Selected gate or outcome:
26
- Stage child identities:
27
- Immutable resolution pointers:
28
- Business path identities:
29
- Business path decision:
30
- Intended projection:
31
- Exact readback identities:
32
- Business hierarchy readback:
33
- Functional Story placement readback:
34
- Technical Task graph readback:
35
- Technical Task graph validator result:
36
- Support evidence:
37
- Checkpoint or blocker:
23
+ Generic Grilling child identities:
24
+ Support child identities and supported-child relations:
25
+ Immutable evidence or verdict pointers:
26
+ Projection ceiling:
27
+ Intended optional projection:
28
+ Exact optional projection readback:
29
+ Unresolved decisions:
38
30
  Last verified at:
39
31
  ```
40
32
 
41
- Discover by exact durable wiki or provider Fog identity. Conflicting valid
42
- records for one identity are `human_steering_required`. `Suggested route` is
43
- advisory; the router always recomputes from fresh evidence.
44
-
45
- `Finder state` is the workflow-specific domain-state field. `UI Evidence` is
46
- optional and records any retained `$show-me` artifact. `Next suggested route`
47
- is advisory.
48
-
49
- Each gate updates only fields it proves. Preserve prior exact identities and
50
- immutable pointers. Record checkpoint, blocked, skip, target-return, and
51
- `human_steering_required` outcomes before stopping.
33
+ Discover the handoff by exact durable wiki or provider Fog identity. Conflicting
34
+ valid records for one identity route to `human_steering_required`. Current
35
+ evidence may supersede `Next suggested route`.
52
36
 
53
- Business hierarchy readback names the exact Product Area, Initiative, and Epic
54
- identities plus exact parent membership. Functional Story placement readback
55
- names the Story, parent Epic, contextual `V*` milestone, exact milestone
56
- membership, and exact Fog and source links. Technical Task graph readback names
57
- each Task, its parent Story, the same `V*` milestone as that Story, and the exact
58
- provider snapshot. Technical Task graph validator result preserves the
59
- successful `write-backlog/validate-task-blocker-graph` result over every
60
- reachable Story and Task, the resolved milestone-order readback, and its bound
61
- provider snapshot identity. It covers every returned Task and outgoing edge;
62
- connected blockers may live under other Stories or Epics.
37
+ Each gate updates only the fields it proves. Preserve prior exact identities,
38
+ the immutable original intake lens, and retained evidence pointers. Record every
39
+ blocked, skipped, checkpoint, bounded-return, and human-steering outcome before
40
+ stopping.
@@ -1,60 +1,38 @@
1
1
  # Finder State Graph
2
2
 
3
- ## Evidence Authority
3
+ ## Evidence authority
4
4
 
5
- 1. Current direct provider, repository, and wiki evidence.
6
- 2. Fresh workflow-native artifacts and immutable resolution pointers.
7
- 3. Valid committed runtime handoff.
8
- 4. Suggested route.
5
+ 1. Current direct evidence: exact provider objects, relations, immutable
6
+ evidence, and the human's current decision.
7
+ 2. Fresh workflow-native artifacts within the current Fog scope.
8
+ 3. A committed runtime handoff consistent with current evidence.
9
+ 4. A suggested route, which is advisory only.
9
10
 
10
- The first admissible signal wins. Stale, invalid, ambiguous, or out-of-scope
11
- evidence cannot satisfy a gate.
11
+ Stale, out-of-scope, ambiguous, or conflicting evidence satisfies no positive
12
+ guard. Recompute from this order on every entry and cold resume.
12
13
 
13
14
  ## Topology
14
15
 
15
16
  ```text
16
17
  ensure-fog
17
- -> (business-grilling <-> research | prototype) | adopt-business-path
18
- -> reconcile
19
- -> return-target [Business]
20
- -> functional-grilling <-> research | prototype
21
- -> reconcile
22
- -> return-target [Functional]
23
- -> technical-grilling per Story <-> research | prototype
24
- -> reconcile
25
- -> return-target [Technical]
26
-
27
- any identity or authority conflict -> handback -> human_steering_required
28
- scope boundary expansion -> scope-expansion-checkpoint -> router re-entry
18
+ -> grilling <-> research | prototype
19
+ -> optional reconcile
20
+ -> bounded return
21
+
22
+ identity, lens, selection, or ceiling conflict
23
+ -> handback -> human_steering_required
29
24
  ```
30
25
 
31
- `adopt-business-path` is available only for Functional or Technical depth when
32
- the human supplies exact provider readback for one Product Area -> Initiative
33
- -> Epic path and accepts `reuse-unchanged`. It creates the required Business
34
- child and immutable resolution without a Business grill, then rejoins normal
35
- reconciliation.
36
-
37
- `return-target` is successful return from this invocation, not Fog completion.
38
- The Fog remains open until separate production evidence covers all accepted
39
- resulting Stories and Tasks.
40
-
41
- ## State Evidence
42
-
43
- For each stage, record `missing`, `active`, `accepted`, or `invalid`; its exact
44
- child identity; immutable resolution pointer; supported-by relations; intended
45
- semantic projection; and exact provider readback. Accepted state without an
46
- exact child identity or immutable pointer is an authority conflict. Business
47
- completion requires exactly one valid Business child from the fresh complete
48
- direct-child collection and exact Product Area -> Initiative -> Epic identity
49
- and hierarchy readback. Functional completion requires each Story's exact
50
- parent Epic, contextual `V*` milestone membership, and Fog/source links. Every
51
- selected Technical Story must equal the distinct projected Story of one
52
- selected accepted Functional child. Technical completion also requires every
53
- Task to retain its Story milestone and the exact successful result of
54
- `write-backlog`'s provider-neutral validator over the full reachable Task
55
- graph, resolved milestone order, and current provider snapshot. The result must
56
- cover every projected Task and outgoing edge. It rejects future-iteration,
57
- self, missing-target, duplicate, and cyclic edges while preserving valid
58
- same-or-earlier-milestone blockers across Stories and Epics. Invalid stage
59
- evidence routes to that stage again. Accepted evidence without readback routes
60
- to reconciliation.
26
+ One Fog retains its immutable original Business or Functional intake lens.
27
+ Generic Grilling children have no fixed count and no staged ordering. Research
28
+ and Prototype are direct Fog children linked to the Grilling child they support.
29
+
30
+ The wrapper decides whether optional structure is useful and supplies the
31
+ ceiling. Business permits Product Area and Initiative. Functional permits that
32
+ Business structure plus Epic. Missing or unresolved optional projection never
33
+ invalidates an otherwise valid Fog return.
34
+
35
+ Historical Business, Functional, or Technical Stage fields remain read-only
36
+ compatibility evidence and are not a current gate, prerequisite, or migration
37
+ trigger. On bounded return the Fog remains open; delivery evidence owns later
38
+ completion truth.
@@ -1,383 +1,64 @@
1
- const DEPTHS = ["Business", "Functional", "Technical"];
2
- const CONFLICT_IDENTITIES = ["ambiguous", "duplicate", "conflict"];
3
- const isStableIdentity = (value) => typeof value === "string" && value.trim().length > 0;
1
+ const LENSES = ["Business", "Functional"];
2
+ const CONFLICTS = ["ambiguous", "conflict", "duplicate"];
4
3
 
5
- const hasExactBusinessProjection = (child) =>
6
- isStableIdentity(child?.projectedProductArea) &&
7
- isStableIdentity(child.projectedInitiative) &&
8
- isStableIdentity(child.projectedEpic) &&
9
- child.hierarchyReadback === "exact";
4
+ const conflicts = (value) => CONFLICTS.includes(value);
5
+ const stable = (value) => typeof value === "string" && value.trim().length > 0;
10
6
 
11
- const businessChildCollectionConflicts = (children) => {
12
- if (!Array.isArray(children)) return false;
13
- return (
14
- children.length > 1 ||
15
- children.some(
16
- (child) =>
17
- !child ||
18
- child.identity !== "exact" ||
19
- (child.status === "accepted" &&
20
- child.scope === "in-scope" &&
21
- child.projection === "read-back" &&
22
- !hasExactBusinessProjection(child)),
23
- )
24
- );
25
- };
26
-
27
- const deriveBusinessStageRoute = (state) => {
28
- if (!Array.isArray(state.businessChildren)) {
29
- return state.business === "accepted" ? "human-steering" : "business-grilling";
30
- }
31
- if (state.businessChildren.length === 0) {
32
- return state.business === "accepted" ? "human-steering" : "business-grilling";
33
- }
34
-
35
- const [child] = state.businessChildren;
36
- if (child.status !== "accepted" || child.scope !== "in-scope") {
37
- return "business-grilling";
38
- }
39
- if (child.resolution !== "immutable") return "human-steering";
40
- if (child.projection !== "read-back") return "reconcile";
41
- if (!hasExactBusinessProjection(child)) return "human-steering";
42
- return "ready";
43
- };
44
-
45
- const childCollectionConflicts = (children, foreignKey) => {
46
- if (!Array.isArray(children)) return false;
47
-
48
- const seen = new Set();
7
+ const childConflict = (children) => {
8
+ if (!Array.isArray(children)) return true;
9
+ const ids = new Set();
49
10
  for (const child of children) {
50
- if (!child || CONFLICT_IDENTITIES.includes(child.identity)) return true;
51
- const key = child[foreignKey];
52
- if (!isStableIdentity(key)) return true;
53
- if (seen.has(key)) return true;
54
- seen.add(key);
55
- }
56
-
57
- return false;
58
- };
59
-
60
- const functionalProjectionConflicts = (children, businessChildren) => {
61
- if (!Array.isArray(children)) return false;
62
-
63
- const projectedEpic = businessChildren?.[0]?.projectedEpic;
64
- const stories = new Set();
65
- for (const child of children) {
66
- if (
67
- child?.status !== "accepted" ||
68
- child.scope !== "in-scope" ||
69
- child.projection !== "read-back"
70
- ) {
71
- continue;
72
- }
73
- if (
74
- !isStableIdentity(projectedEpic) ||
75
- !isStableIdentity(child.projectedStory) ||
76
- child.projectedStoryParentEpic !== projectedEpic ||
77
- !isStableIdentity(child.projectedStoryMilestone) ||
78
- child.projectedStoryMilestoneKind !== "V*" ||
79
- child.projectedStoryFogLink !== "exact" ||
80
- child.projectedStorySourceLink !== "exact" ||
81
- child.projectedStoryMembershipReadback !== "exact"
82
- ) {
11
+ if (!child || child.identity !== "exact" || !stable(child.id) || ids.has(child.id)) {
83
12
  return true;
84
13
  }
85
- if (stories.has(child.projectedStory)) return true;
86
- stories.add(child.projectedStory);
14
+ ids.add(child.id);
87
15
  }
88
16
  return false;
89
17
  };
90
18
 
91
- const hasExactWriterTaskGraphValidation = (state, projectedTasks) => {
92
- const validation = state.taskGraphValidation;
93
- const result = validation?.result;
94
- if (
95
- !isStableIdentity(state.providerSnapshotIdentity) ||
96
- validation?.validator !== "write-backlog/validate-task-blocker-graph" ||
97
- validation.scope !== "full-reachable" ||
98
- validation.milestoneOrderReadback !== "exact" ||
99
- validation.providerSnapshotIdentity !== state.providerSnapshotIdentity ||
100
- result?.ok !== true ||
101
- !Array.isArray(result.taskIds) ||
102
- !Array.isArray(result.edges)
103
- ) {
104
- return false;
105
- }
106
-
107
- const validatedTaskIds = new Set();
108
- for (const taskId of result.taskIds) {
109
- if (!isStableIdentity(taskId) || validatedTaskIds.has(taskId)) return false;
110
- validatedTaskIds.add(taskId);
111
- }
112
-
113
- const validatedEdges = new Set();
114
- for (const edge of result.edges) {
115
- if (
116
- !isStableIdentity(edge?.blockedTaskId) ||
117
- !isStableIdentity(edge.blockingTaskId) ||
118
- !validatedTaskIds.has(edge.blockedTaskId) ||
119
- !validatedTaskIds.has(edge.blockingTaskId)
120
- ) {
121
- return false;
122
- }
123
- const key = `${edge.blockedTaskId}\u0000${edge.blockingTaskId}`;
124
- if (validatedEdges.has(key)) return false;
125
- validatedEdges.add(key);
126
- }
127
-
128
- const projectedTaskIds = new Set(projectedTasks.map((task) => task.id));
129
- const projectedEdges = new Set();
130
- for (const task of projectedTasks) {
131
- if (!validatedTaskIds.has(task.id)) return false;
132
- for (const blockingTaskId of task.blockedBy) {
133
- if (!validatedTaskIds.has(blockingTaskId)) return false;
134
- projectedEdges.add(`${task.id}\u0000${blockingTaskId}`);
135
- }
136
- }
137
- if ([...projectedEdges].some((edge) => !validatedEdges.has(edge))) {
138
- return false;
139
- }
140
- if (
141
- [...validatedEdges].some((edge) => {
142
- const [blockedTaskId] = edge.split("\u0000");
143
- return projectedTaskIds.has(blockedTaskId) && !projectedEdges.has(edge);
144
- })
145
- ) {
146
- return false;
147
- }
148
-
149
- return true;
150
- };
151
-
152
- const technicalProjectionConflicts = (state) => {
153
- const children = state.technicalChildren;
154
- const functionalChildren = state.functionalChildren;
155
- if (!Array.isArray(children)) return false;
156
-
157
- const storyMilestones = new Map(
158
- (Array.isArray(functionalChildren) ? functionalChildren : [])
159
- .filter(
160
- (child) =>
161
- child?.status === "accepted" &&
162
- child.scope === "in-scope" &&
163
- child.projection === "read-back" &&
164
- isStableIdentity(child.projectedStory) &&
165
- isStableIdentity(child.projectedStoryMilestone),
166
- )
167
- .map((child) => [child.projectedStory, child.projectedStoryMilestone]),
168
- );
169
- const taskIds = new Set();
170
- const tasks = [];
171
- for (const child of children) {
172
- if (
173
- child?.status !== "accepted" ||
174
- child.scope !== "in-scope" ||
175
- child.projection !== "read-back"
176
- ) {
177
- continue;
178
- }
179
- const storyMilestone = storyMilestones.get(child.story);
180
- if (
181
- !isStableIdentity(storyMilestone) ||
182
- child.taskGraphReadback !== "exact" ||
183
- !Array.isArray(child.projectedTasks) ||
184
- child.projectedTasks.length !== child.taskIntentCount
185
- ) {
186
- return true;
187
- }
188
- for (const task of child.projectedTasks) {
189
- if (
190
- !task ||
191
- !isStableIdentity(task.id) ||
192
- task.story !== child.story ||
193
- task.milestone !== storyMilestone ||
194
- task.readback !== "exact" ||
195
- !Array.isArray(task.blockedBy) ||
196
- task.blockedBy.some((identity) => !isStableIdentity(identity)) ||
197
- taskIds.has(task.id)
198
- ) {
199
- return true;
200
- }
201
- taskIds.add(task.id);
202
- tasks.push(task);
203
- }
204
- }
205
- if (tasks.length === 0) return false;
206
-
207
- for (const task of tasks) {
208
- if (
209
- new Set(task.blockedBy).size !== task.blockedBy.length ||
210
- task.blockedBy.includes(task.id)
211
- ) {
212
- return true;
213
- }
214
- }
215
- return !hasExactWriterTaskGraphValidation(state, tasks);
216
- };
217
-
218
- const technicalSelectionConflicts = ({
219
- selectedStoryIntents,
220
- selectedStories,
221
- functionalChildren,
222
- }) => {
223
- if (!Array.isArray(selectedStories) || selectedStories.length === 0) {
224
- return false;
225
- }
226
-
227
- const selectedIntents = new Set(Array.isArray(selectedStoryIntents) ? selectedStoryIntents : []);
228
- const selectedFunctionalChildren = (
229
- Array.isArray(functionalChildren) ? functionalChildren : []
230
- ).filter(
231
- (child) =>
232
- selectedIntents.has(child.storyIntent) &&
233
- child.status === "accepted" &&
234
- child.scope === "in-scope" &&
235
- child.projection === "read-back",
236
- );
237
-
238
- return (
239
- new Set(selectedStories).size !== selectedStories.length ||
240
- selectedStories.some(
241
- (story) =>
242
- !isStableIdentity(story) ||
243
- selectedFunctionalChildren.filter((child) => child.projectedStory === story).length !== 1,
244
- )
245
- );
246
- };
247
-
248
- const deriveChildStageRoute = ({
249
- selected,
250
- children,
251
- foreignKey,
252
- grillingRoute,
253
- validateAcceptedChild = () => true,
254
- }) => {
255
- if (!Array.isArray(selected)) return grillingRoute;
256
- if (selected.length === 0) return grillingRoute;
257
- if (new Set(selected).size !== selected.length) return "human-steering";
258
-
259
- const matchesBySelected = selected.map((selectedIdentity) =>
260
- (Array.isArray(children) ? children : []).filter(
261
- (child) => child[foreignKey] === selectedIdentity,
262
- ),
263
- );
264
-
265
- if (
266
- matchesBySelected.some(
267
- (matches) =>
268
- matches.length > 1 || matches.some((child) => CONFLICT_IDENTITIES.includes(child.identity)),
269
- )
270
- ) {
271
- return "human-steering";
272
- }
19
+ export const deriveFinderRoute = (state) => {
20
+ if (!LENSES.includes(state.targetLens)) return "human-steering";
21
+ if (state.humanSteering === "required") return "human-steering";
22
+ if (conflicts(state.fogIdentity)) return "human-steering";
23
+ if (state.fogIdentity !== "exact") return "ensure-fog";
24
+ if (!LENSES.includes(state.intakeLens)) return "human-steering";
273
25
 
26
+ if (childConflict(state.grillingChildren)) return "human-steering";
27
+ if (state.selection?.decision === "ambiguous") return "human-steering";
274
28
  if (
275
- matchesBySelected
276
- .filter(
277
- (matches) =>
278
- matches.length === 1 &&
279
- matches[0].status === "accepted" &&
280
- matches[0].scope === "in-scope",
281
- )
282
- .some(
283
- ([child]) =>
284
- child.identity !== "exact" ||
285
- child.resolution !== "immutable" ||
286
- !validateAcceptedChild(child),
287
- )
29
+ state.selection?.decision === "reuse" &&
30
+ !state.grillingChildren?.some((child) => child.id === state.selection.childId)
288
31
  ) {
289
32
  return "human-steering";
290
33
  }
291
34
 
292
- if (
293
- matchesBySelected
294
- .filter(
295
- (matches) =>
296
- matches.length === 1 &&
297
- matches[0].status === "accepted" &&
298
- matches[0].scope === "in-scope",
299
- )
300
- .some(([child]) => child.projection !== "read-back")
301
- ) {
302
- return "reconcile";
303
- }
304
-
305
- if (
306
- matchesBySelected.some(
307
- (matches) =>
308
- matches.length !== 1 || matches[0].status !== "accepted" || matches[0].scope !== "in-scope",
309
- )
310
- ) {
311
- return grillingRoute;
312
- }
313
-
314
- return "ready";
315
- };
316
-
317
- export const deriveFinderRoute = (state) => {
318
- if (!DEPTHS.includes(state.targetDepth)) return "human-steering";
319
- if (state.humanSteering === "required") return "human-steering";
320
- if (CONFLICT_IDENTITIES.includes(state.fogIdentity)) {
321
- return "human-steering";
322
- }
323
- if (
324
- businessChildCollectionConflicts(state.businessChildren) ||
325
- childCollectionConflicts(state.functionalChildren, "storyIntent") ||
326
- childCollectionConflicts(state.technicalChildren, "story") ||
327
- functionalProjectionConflicts(state.functionalChildren, state.businessChildren) ||
328
- technicalProjectionConflicts(state)
329
- ) {
35
+ if (state.support?.decision === "ambiguous") return "human-steering";
36
+ if (["requested", "pending"].includes(state.support?.status)) {
330
37
  return "human-steering";
331
38
  }
332
- if (state.fogIdentity !== "exact") return "ensure-fog";
333
- if (CONFLICT_IDENTITIES.includes(state.businessIdentity)) {
39
+ if (state.support?.status === "unresolved") {
40
+ if (!state.grillingChildren?.some((child) => child.id === state.support.supports)) {
41
+ return "human-steering";
42
+ }
43
+ if (state.support.kind === "Research") return "research";
44
+ if (state.support.kind === "Prototype") return "prototype";
334
45
  return "human-steering";
335
46
  }
336
- if (state.acceptedEvidence === "conflict") return "human-steering";
337
- if (state.scopeExpansion === "approval-required") {
338
- return "scope-expansion-checkpoint";
339
- }
340
- if (state.support === "research") return "research";
341
- if (state.support === "prototype") return "prototype";
342
- if (state.businessEvidenceScope === "out-of-scope") {
343
- return "business-grilling";
344
- }
345
- if (state.business !== "accepted") {
47
+
48
+ if (state.projection?.status === "ambiguous") return "human-steering";
49
+ if (["pending", "read-back"].includes(state.projection?.status)) {
50
+ const ceiling =
51
+ state.targetLens === "Business"
52
+ ? new Set(["ProductArea", "Initiative"])
53
+ : new Set(["ProductArea", "Initiative", "Epic"]);
346
54
  if (
347
- state.targetDepth !== "Business" &&
348
- state.business === "missing" &&
349
- state.businessPathIdentity === "exact" &&
350
- state.businessPathDecision === "reuse-unchanged"
55
+ !Array.isArray(state.projection.kinds) ||
56
+ state.projection.kinds.some((kind) => !ceiling.has(kind))
351
57
  ) {
352
- return "adopt-business-path";
58
+ return "human-steering";
353
59
  }
354
- return "business-grilling";
355
60
  }
356
- const businessRoute = deriveBusinessStageRoute(state);
357
- if (businessRoute !== "ready") return businessRoute;
358
- if (state.targetDepth === "Business") return "return-target";
359
-
360
- const functionalRoute = deriveChildStageRoute({
361
- selected: state.selectedStoryIntents,
362
- children: state.functionalChildren,
363
- foreignKey: "storyIntent",
364
- grillingRoute: "functional-grilling",
365
- });
366
- if (functionalRoute !== "ready") return functionalRoute;
367
- if (state.targetDepth === "Functional") return "return-target";
368
- if (technicalSelectionConflicts(state)) return "human-steering";
369
-
370
- const technicalRoute = deriveChildStageRoute({
371
- selected: state.selectedStories,
372
- children: state.technicalChildren,
373
- foreignKey: "story",
374
- grillingRoute: "technical-grilling",
375
- validateAcceptedChild: (child) =>
376
- child.specReadiness === "agent-ready" &&
377
- child.stableBlob === "verified" &&
378
- Number.isInteger(child.taskIntentCount) &&
379
- child.taskIntentCount > 0,
380
- });
381
- if (technicalRoute !== "ready") return technicalRoute;
382
- return "return-target";
61
+ if (state.projection?.status === "pending") return "reconcile";
62
+ if (state.boundedResult === "ready") return "return-target";
63
+ return "grilling";
383
64
  };