@punks/cli 4.0.2 → 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 (156) hide show
  1. package/dist/BASELINE_CHANGELOG.md +24 -0
  2. package/dist/CHANGELOG.md +17 -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 +0 -1
  6. package/dist/baseline/scaffold-baseline/data/catalog/skills.json +0 -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/security/security-best-practices/references/javascript-typescript-vue-web-frontend-security.md +1 -1
  52. package/dist/baseline/scaffold-baseline/skills/frameworks/expo/eas-update-insights/references/update-insights-schema.md +2 -6
  53. package/dist/baseline/scaffold-baseline/skills/frameworks/expo/expo-skill-eval/SKILL.md +6 -7
  54. package/dist/baseline/scaffold-baseline/skills/frameworks/pulumi/pulumi-best-practices/SKILL.md +1 -3
  55. package/dist/baseline/scaffold-baseline/skills/frameworks/pulumi/pulumi-component/SKILL.md +2 -14
  56. package/dist/baseline/scaffold-baseline/skills/frameworks/tanstack-query/tanstack-query/references/best-practices.md +7 -1
  57. package/dist/baseline/scaffold-baseline/skills/frameworks/tanstack-query/tanstack-query/templates/devtools-setup.tsx +4 -0
  58. package/dist/baseline/scaffold-baseline/skills/frameworks/trpc/tanstack-query/references/best-practices.md +7 -1
  59. package/dist/baseline/scaffold-baseline/skills/frameworks/trpc/tanstack-query/templates/devtools-setup.tsx +4 -0
  60. package/dist/baseline/scaffold-baseline/skills/languages/typescript/quality-types/SKILL.md +1 -3
  61. package/dist/baseline/scaffold-baseline/skills/phases/business-finder/SKILL.md +29 -16
  62. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/router.md +10 -8
  63. package/dist/baseline/scaffold-baseline/skills/phases/design-phase/phases/backlog.md +26 -17
  64. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/AUTHORING-HANDOFF.md +51 -261
  65. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/SKILL.md +22 -25
  66. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/ensure-fog.md +13 -23
  67. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/grilling.md +40 -0
  68. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/handback.md +11 -18
  69. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/prototype.md +13 -21
  70. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/reconcile.md +21 -35
  71. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/research.md +13 -18
  72. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/return-target.md +14 -25
  73. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/router.md +22 -56
  74. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/references/entrypoint-contract.md +25 -26
  75. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/references/root-routing.md +12 -20
  76. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/references/runtime-handoff.md +17 -39
  77. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/references/state-graph.md +27 -49
  78. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/scripts/finder-contract.mjs +40 -359
  79. package/dist/baseline/scaffold-baseline/skills/phases/functional-finder/SKILL.md +29 -62
  80. package/dist/baseline/scaffold-baseline/skills/phases/requirements-phase/SKILL.md +49 -13
  81. package/dist/baseline/scaffold-baseline.json +5 -5
  82. package/dist/baseline/scaffold-baseline.tgz +0 -0
  83. package/dist/data/hooks/format-edited-file.d.mts +21 -0
  84. package/dist/data/hooks/format-edited-file.mjs +588 -98
  85. package/dist/data/scripts/commit-gate-runner.mjs +103 -0
  86. package/dist/data/scripts/harness-projection/adapters/claude.mjs +1 -0
  87. package/dist/data/scripts/harness-projection/adapters/codex.mjs +1 -0
  88. package/dist/data/scripts/harness-projection/adapters/cursor.mjs +1 -0
  89. package/dist/data/scripts/harness-projection/adapters/opencode.mjs +1 -0
  90. package/dist/data/scripts/harness-projection/core.mjs +4 -0
  91. package/dist/data/scripts/harness-projection/test-fixtures/claude/actions.json +1 -0
  92. package/dist/data/scripts/harness-projection/test-fixtures/codex/actions.json +2 -1
  93. package/dist/data/scripts/harness-projection/test-fixtures/cursor/projection.json +1 -0
  94. package/dist/data/scripts/harness-projection/test-fixtures/opencode/projection.json +1 -0
  95. package/dist/index.js +73 -58
  96. package/dist/skills/agnostic/docs/docs-onboarding/SKILL.md +2 -2
  97. package/dist/skills/agnostic/planning/create-spec/SKILL.md +32 -32
  98. package/dist/skills/agnostic/planning/create-spec/assets/SPEC-TEMPLATE.md +7 -7
  99. package/dist/skills/agnostic/planning/create-spec/references/readiness.md +14 -13
  100. package/dist/skills/agnostic/planning/create-spec/references/spec-quality-bar.md +26 -19
  101. package/dist/skills/agnostic/quality/autoreview/SKILL.md +2 -2
  102. package/dist/skills/agnostic/quality/autoreview/scripts/autoreview +3 -0
  103. package/dist/skills/agnostic/requirements/brainstorm/SKILL.md +12 -0
  104. package/dist/skills/agnostic/requirements/requirements-grill/SKILL.md +2 -1
  105. package/dist/skills/agnostic/requirements/write-backlog/EXAMPLES.md +9 -9
  106. package/dist/skills/agnostic/requirements/write-backlog/REFERENCE.md +43 -55
  107. package/dist/skills/agnostic/requirements/write-backlog/SKILL.md +68 -63
  108. package/dist/skills/agnostic/requirements/write-backlog/assets/concepts/backlog-model.md +26 -29
  109. package/dist/skills/agnostic/requirements/write-backlog/assets/concepts/story-shape.md +5 -5
  110. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/azure-devops-create-payload.md +1 -1
  111. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/github-projects-create-payload.md +2 -2
  112. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/linear-create-payload.md +1 -1
  113. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/monday-create-payload.md +2 -2
  114. package/dist/skills/agnostic/requirements/write-backlog/references/business-projection.md +19 -24
  115. package/dist/skills/agnostic/requirements/write-backlog/references/delivery-status.md +17 -13
  116. package/dist/skills/agnostic/requirements/write-backlog/references/fog-intake.md +45 -48
  117. package/dist/skills/agnostic/requirements/write-backlog/references/functional-projection.md +16 -21
  118. package/dist/skills/agnostic/requirements/write-backlog/references/normalization.md +14 -14
  119. package/dist/skills/agnostic/requirements/write-backlog/references/project-context.md +32 -27
  120. package/dist/skills/agnostic/requirements/write-backlog/references/providers/github.md +97 -142
  121. package/dist/skills/agnostic/requirements/write-backlog/references/providers/linear.md +106 -176
  122. package/dist/skills/agnostic/requirements/write-backlog/references/technical-projection.md +51 -47
  123. package/dist/skills/agnostic/requirements/write-backlog/scripts/validate-task-blocker-graph.mjs +55 -31
  124. package/dist/skills/phases/business-finder/SKILL.md +29 -16
  125. package/dist/skills/phases/delivery-phase/phases/router.md +10 -8
  126. package/dist/skills/phases/design-phase/phases/backlog.md +26 -17
  127. package/dist/skills/phases/finder-phase/AUTHORING-HANDOFF.md +51 -261
  128. package/dist/skills/phases/finder-phase/SKILL.md +22 -25
  129. package/dist/skills/phases/finder-phase/phases/ensure-fog.md +13 -23
  130. package/dist/skills/phases/finder-phase/phases/grilling.md +40 -0
  131. package/dist/skills/phases/finder-phase/phases/handback.md +11 -18
  132. package/dist/skills/phases/finder-phase/phases/prototype.md +13 -21
  133. package/dist/skills/phases/finder-phase/phases/reconcile.md +21 -35
  134. package/dist/skills/phases/finder-phase/phases/research.md +13 -18
  135. package/dist/skills/phases/finder-phase/phases/return-target.md +14 -25
  136. package/dist/skills/phases/finder-phase/phases/router.md +22 -56
  137. package/dist/skills/phases/finder-phase/references/entrypoint-contract.md +25 -26
  138. package/dist/skills/phases/finder-phase/references/root-routing.md +12 -20
  139. package/dist/skills/phases/finder-phase/references/runtime-handoff.md +17 -39
  140. package/dist/skills/phases/finder-phase/references/state-graph.md +27 -49
  141. package/dist/skills/phases/finder-phase/scripts/finder-contract.mjs +44 -357
  142. package/dist/skills/phases/functional-finder/SKILL.md +29 -62
  143. package/dist/skills/phases/requirements-phase/SKILL.md +49 -13
  144. package/package.json +7 -5
  145. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/adopt-business-path.md +0 -52
  146. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/business-grilling.md +0 -68
  147. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/functional-grilling.md +0 -53
  148. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/technical-grilling.md +0 -67
  149. package/dist/baseline/scaffold-baseline/skills/phases/technical-finder/SKILL.md +0 -74
  150. package/dist/baseline/scaffold-baseline/skills/phases/technical-finder/agents/openai.yaml +0 -2
  151. package/dist/skills/phases/finder-phase/phases/adopt-business-path.md +0 -52
  152. package/dist/skills/phases/finder-phase/phases/business-grilling.md +0 -68
  153. package/dist/skills/phases/finder-phase/phases/functional-grilling.md +0 -53
  154. package/dist/skills/phases/finder-phase/phases/technical-grilling.md +0 -67
  155. package/dist/skills/phases/technical-finder/SKILL.md +0 -74
  156. package/dist/skills/phases/technical-finder/agents/openai.yaml +0 -2
@@ -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,70 @@
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
- );
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";
264
25
 
26
+ if (childConflict(state.grillingChildren)) return "human-steering";
27
+ if (state.selection?.decision === "ambiguous") return "human-steering";
265
28
  if (
266
- matchesBySelected.some(
267
- (matches) =>
268
- matches.length > 1 || matches.some((child) => CONFLICT_IDENTITIES.includes(child.identity)),
29
+ state.selection?.decision === "reuse" &&
30
+ !state.grillingChildren?.some(
31
+ (child) => child.id === state.selection.childId,
269
32
  )
270
33
  ) {
271
34
  return "human-steering";
272
35
  }
273
36
 
274
- 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
- )
288
- ) {
37
+ if (state.support?.decision === "ambiguous") return "human-steering";
38
+ if (["requested", "pending"].includes(state.support?.status)) {
289
39
  return "human-steering";
290
40
  }
291
-
292
- if (
293
- matchesBySelected
294
- .filter(
295
- (matches) =>
296
- matches.length === 1 &&
297
- matches[0].status === "accepted" &&
298
- matches[0].scope === "in-scope",
41
+ if (state.support?.status === "unresolved") {
42
+ if (
43
+ !state.grillingChildren?.some(
44
+ (child) => child.id === state.support.supports,
299
45
  )
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
- ) {
330
- return "human-steering";
331
- }
332
- if (state.fogIdentity !== "exact") return "ensure-fog";
333
- if (CONFLICT_IDENTITIES.includes(state.businessIdentity)) {
46
+ ) {
47
+ return "human-steering";
48
+ }
49
+ if (state.support.kind === "Research") return "research";
50
+ if (state.support.kind === "Prototype") return "prototype";
334
51
  return "human-steering";
335
52
  }
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") {
53
+
54
+ if (state.projection?.status === "ambiguous") return "human-steering";
55
+ if (["pending", "read-back"].includes(state.projection?.status)) {
56
+ const ceiling =
57
+ state.targetLens === "Business"
58
+ ? new Set(["ProductArea", "Initiative"])
59
+ : new Set(["ProductArea", "Initiative", "Epic"]);
346
60
  if (
347
- state.targetDepth !== "Business" &&
348
- state.business === "missing" &&
349
- state.businessPathIdentity === "exact" &&
350
- state.businessPathDecision === "reuse-unchanged"
61
+ !Array.isArray(state.projection.kinds) ||
62
+ state.projection.kinds.some((kind) => !ceiling.has(kind))
351
63
  ) {
352
- return "adopt-business-path";
64
+ return "human-steering";
353
65
  }
354
- return "business-grilling";
355
66
  }
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";
67
+ if (state.projection?.status === "pending") return "reconcile";
68
+ if (state.boundedResult === "ready") return "return-target";
69
+ return "grilling";
383
70
  };
@@ -1,78 +1,45 @@
1
1
  ---
2
2
  name: functional-finder
3
- description: Define shippable product behavior through cumulative Business and Functional grilling.
3
+ description: Develop uncertain product behavior nontechnically and optionally project structure through Epic.
4
4
  disable-model-invocation: true
5
5
  ---
6
6
 
7
7
  # Functional Finder
8
8
 
9
- Human entrypoint for a technical or proficient nontechnical user. Use precise
10
- project language. Define product behavior one level below Business scope and
11
- stop before engineering design or Task decomposition.
9
+ Explicit human entrypoint for a functional colleague. It includes every
10
+ Business Finder capability and adds nontechnical product-behavior guidance.
11
+ It does not require Business Finder to have run first.
12
12
 
13
- ## Inputs
13
+ ## Intake profile
14
14
 
15
- - one product-behavior request
16
- - optional stable provider or durable wiki Fog identity
17
- - optional exact accepted Business child and Product Area -> Initiative -> Epic
18
- path
19
- - product context, constraints, dependencies, and milestone preference supplied
20
- by the human
15
+ Capture the Business profile plus actor, trigger, workflow, observable result,
16
+ applicable domain rules, visible alternate and failure paths, acceptance
17
+ signals, boundaries, known product dependencies, technical handoff questions,
18
+ and target `V*` milestone context. Unknown values remain explicit.
21
19
 
22
- ## Composition
23
-
24
- Directly compose [the Finder engine](../finder-phase/SKILL.md) with target
25
- depth: `Functional`. This is cumulative Business and Functional depth over one
26
- Fog; this adapter supplies only its audience, presentation, and return profile.
27
-
28
- Reuse a fresh accepted Business child. When none exists, an exact existing
29
- Product Area -> Initiative -> Epic path from provider readback plus the
30
- human's explicit `reuse-unchanged` decision takes the fast path without
31
- changing business scope. Its Business-path adoption gate creates the required
32
- Business child and immutable resolution without a Business grill. Otherwise
33
- let the engine complete Business grilling
34
- before Functional grilling. When accepted lower-stage evidence needs repair,
35
- the engine may enrich existing Business structures before it continues. The
36
- engine's
37
- [Functional gate](../finder-phase/phases/functional-grilling.md) composes atomic
38
- `$grilling` and resolves one Functional child per accepted Story intent.
39
-
40
- ## Presentation
20
+ This profile does not require architecture, APIs, data models, component
21
+ boundaries, code structure, Tasks, commands, workers, or implementation design.
41
22
 
42
- Before grilling, use the smallest authoritative `$show-me` view to show the
43
- current Business path, relevant existing Stories and `V*` milestones, and the
44
- requested product behavior. Continue to use `$show-me` at each decision about:
23
+ Use `$wait-what` when terminology or behavior does not land. Use `$show-me` at
24
+ each decision about the observable workflow, an alternate or failure path, a
25
+ product dependency, milestone context, and final Epic projection. Presentation
26
+ informs the human and grants no mutation authority.
45
27
 
46
- - the observable workflow
47
- - the Story split and Story boundaries
48
- - an alternate path or failure path
49
- - a product dependency
50
- - the milestone iteration
51
- - the final Story write
52
-
53
- When terminology or behavior does not land, use `$wait-what`: pause, repitch in
54
- plain language with accepted project terms, and ask again. Preserve the user's
55
- language when it already matches those terms.
56
-
57
- ## Functional depth
58
-
59
- For each proposed Story, settle the actor, trigger, observable workflow and
60
- result, applicable business rules, visible alternate or failure paths,
61
- product-level edge cases, acceptance signals, Story boundaries, known product
62
- dependencies, and unresolved engineering questions.
28
+ ## Composition
63
29
 
64
- Assign exactly one contextual `V*` milestone to each Story. Reuse a fitting
65
- existing `V*` milestone before proposing a new one. Show and obtain approval
66
- before moving accepted work to another milestone.
30
+ Compose [the shared Finder engine](../finder-phase/SKILL.md) with immutable
31
+ intake lens `Functional`, this presentation profile, and projection ceiling
32
+ `Epic`. The engine alone owns the Fog lifecycle, generic support work, resume
33
+ routing, and durable handoff.
67
34
 
68
- After immutable Functional evidence is accepted, hand semantic projection
69
- intent to `$write-backlog`. It is the physical mutation authority and must
70
- write and read back exactly one Story per accepted Functional child.
35
+ Optional structure may reuse, enrich, or create Product Areas, Initiatives,
36
+ and Epics through `$write-backlog`. The ceiling is Epic: Functional Finder
37
+ never projects Stories or Tasks. Skipping projection, or returning an
38
+ unresolved projection, never blocks a valid Fog result.
71
39
 
72
- ## Return
40
+ ## Bounded return
73
41
 
74
- Return the exact Fog identity, accepted Business child identity and resolution
75
- pointer, selected Functional child identities and resolution pointers, the
76
- resolved Product Area -> Initiative -> Epic path, exact Story provider
77
- identities and readback, milestone membership, unresolved decisions, and the
78
- durable Finder handoff. Stop at the engine's `target_depth_reached` outcome.
42
+ Return the exact Fog identity, immutable Functional intake lens, generic
43
+ support work and evidence, optional exact Product Area, Initiative, and Epic
44
+ readback, unresolved decisions, and durable Finder handoff. Return control
45
+ without asserting that the Fog is resolved or complete.