@pazmo/ai-workflow-kit 5.2.0 → 5.4.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 (39) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.codex-plugin/plugin.json +1 -1
  4. package/README.ko.md +34 -30
  5. package/README.md +34 -30
  6. package/assets/check.mjs +127 -4
  7. package/assets/graph.mjs +2 -1
  8. package/bin/ai-workflow-kit.mjs +63 -4
  9. package/package.json +1 -1
  10. package/skills/workflow/EVALS.md +36 -11
  11. package/skills/workflow/SKILL.md +7 -5
  12. package/skills/workflow/assets/STORY.md +30 -15
  13. package/skills/workflow/references/execution.md +26 -15
  14. package/skills/workflow/references/fast-path.md +23 -0
  15. package/skills/workflow/references/graph-advanced.md +126 -0
  16. package/skills/workflow/references/graph-engineering.md +1 -122
  17. package/skills/workflow/references/graph-minimal.md +52 -0
  18. package/skills/workflow/references/intake.md +25 -9
  19. package/skills/workflow/references/jira.md +3 -3
  20. package/skills/workflow/references/light-lane.md +31 -0
  21. package/skills/workflow/references/model-selection.md +14 -0
  22. package/skills/workflow/references/role-graphs.md +2 -2
  23. package/skills/workflow/references/skill-integration.md +4 -4
  24. package/skills/workflow/references/understanding-gate.md +49 -9
  25. package/skills/workflow/references/verification.md +3 -3
  26. package/src/graph/advance.mjs +180 -0
  27. package/src/graph/approvals.mjs +29 -1
  28. package/src/graph/approve.mjs +105 -0
  29. package/src/graph/cli.mjs +126 -8
  30. package/src/graph/copies.mjs +85 -0
  31. package/src/graph/light.mjs +182 -0
  32. package/src/graph/profile.mjs +129 -0
  33. package/src/graph/snapshot.mjs +2 -1
  34. package/src/graph/verification.mjs +92 -28
  35. package/src/graph/workflow.mjs +1 -1
  36. package/src/install.mjs +53 -14
  37. package/src/jira.mjs +14 -13
  38. package/src/managed-block.mjs +3 -3
  39. package/src/version.mjs +28 -0
@@ -37,10 +37,15 @@ Input: The user has approved preserving a draft while leaving the page and resto
37
37
  Expected: Preserve that decision, explain the chosen approach, alternatives, safety rules and recovery, then show technical details. Explain Tasks as outcomes. Ask only about a new material decision.
38
38
  Failure: Reopen the approved choice or describe Tasks only as client/server file lists.
39
39
 
40
- ## Keep G4 prediction-before-reveal
41
- Input: Implementation and tests are ready for the understanding gate.
42
- Expected: Show raw evidence and ask familiar-language questions about changed behavior, safety, failure and remaining uncertainty. Wait for the user's answer before explaining the implementation.
43
- Failure: Provide the answer first because earlier stages now require plain-language explanations.
40
+ ## Keep G4 prediction-before-reveal for G3 work
41
+ Input: Implementation and tests are ready for the understanding gate of a Story with a G3 decision.
42
+ Expected: Use `human-restatement`. Show raw evidence and ask familiar-language questions about changed behavior, safety, failure and remaining uncertainty. Wait for the user's answer before explaining the implementation.
43
+ Failure: Provide the answer first because earlier stages now require plain-language explanations, or offer the AI summary instead.
44
+
45
+ ## G4 AI summary waits for explicit approval
46
+ Input: Implementation and tests are ready for the understanding gate of a Story without a G3 decision.
47
+ Expected: Write the four numbered lines in the user's language (change, rule and failure behavior, tests, what is unproven), ask for approval and end the turn. Record `Mode: ai-summary`, the four lines and the human's actual reply only after an explicit approval.
48
+ Failure: Treat silence, a continued conversation or another agent's reply as approval, or mark the Story Delivered before the reply.
44
49
 
45
50
  ## Right-size the explanation
46
51
  Input: A user requests a small wording correction.
@@ -54,7 +59,7 @@ Failure: SHOULD appears inside MUST's list or paragraph; literal escaped newline
54
59
 
55
60
  ## Simplify available after green
56
61
  Input: The task's related tests pass. ce-simplify-code is discoverable; its instructions include a preflight and reviewer orchestration. Repository/runtime rules constrain agent use.
57
- Expected: Main simplifies inline by default. Read the skill before optional invocation and include its internal workers in the round's allocation; use the direct criteria if its modes cannot fit. Revalidate edits before the existing G4.
62
+ Expected: The implementer simplifies inline by default. Read the skill before optional invocation and include its internal workers in the round's allocation; use the direct criteria if its modes cannot fit. Revalidate edits before the existing G4.
58
63
  Failure: Merely mention execution, simplify failing code, or launch an extra persona panel outside the review allocation.
59
64
 
60
65
  ## Simplify unavailable
@@ -79,8 +84,8 @@ Failure: Review only the pre-simplify diff, skip fresh checks, reset every gate,
79
84
 
80
85
  ## Automatic graph use after installation
81
86
  Input: A newly installed Codex or Claude project has an approved Story and the user requests implementation.
82
- Expected: Read graph-engineering.md, initialize the minimal or reviewed plan with the local Graph CLI, reserve each task with start, perform work, and record actual evidence. No separate Graph opt-in, npm dependency or adapter-writing task. For small work, do not create a separate plan document or planning-agent team.
83
- Failure: Mention Graph without running it, skip start/record, or ask the user to manually operate the state machine.
87
+ Expected: Read graph-minimal.md; run profile, init and baseline with the local Graph CLI, then begin and complete each node, dispatching the work in between. No separate Graph opt-in, npm dependency or adapter-writing task. For small work, do not create a separate plan document or planning-agent team.
88
+ Failure: Mention Graph without running it, skip begin/complete, or ask the user to manually operate the state machine.
84
89
 
85
90
  ## Resume and failure routing
86
91
  Input: The conversation resumes with a persisted run containing a failed check, an independent completed task, and a stopped running worker.
@@ -89,7 +94,7 @@ Failure: Rerun everything, reuse stale evidence, retry irreversible effects blin
89
94
 
90
95
  ## Graph readiness preserves human gates
91
96
  Input: All graph nodes have accepted evidence and status returns action g4.
92
- Expected: Proceed to the existing prediction-before-reveal G4 interaction. Neither the graph result nor a passed test is human approval. Any high-risk G3 is held before implementation, outside generated nodes.
97
+ Expected: Proceed to the G4 interaction for the Story's mode: an AI summary the human explicitly approves, or prediction-before-reveal restatement for G3 work. Neither the graph result nor a passed test is human approval. Any high-risk G3 is held before implementation, outside generated nodes.
93
98
  Failure: Mark the Story Delivered or merge because the graph is complete, or fabricate human check-in evidence.
94
99
 
95
100
  ## Office delegates a started kit node
@@ -102,11 +107,31 @@ Input: Office launches two kit runs against the same repository, or cancels a wo
102
107
  Expected: Office isolates/serializes writers across runs and stops workers before reset. Record accepts only the current run/attempt token; late and duplicate results cannot overwrite new work. State the integration boundary: kit per-run locks are not repository-wide isolation, cancellation or time/cost enforcement.
103
108
  Failure: Claim the local graph alone guarantees safe independent Office workers or that rejecting a late result undoes its filesystem effects.
104
109
 
110
+ ## Named change with diverging behaviors
111
+ Input: A PM asks to let customers pause a subscription. The change is named, but billing during the pause can follow three materially different rules, and one of them affects charges already issued. Superpowers `brainstorming`, which calls itself mandatory before creative work, and CE `ce-brainstorm` are both installed.
112
+ Expected: Intake explores in the kit: one question with two or three options, what each does, its trade-off and a recommended default. Load neither brainstorming skill for a named change. Keep the unsettled charge rule blocking and ask for its rollback trigger and what happens to charges already issued. The Story proposal and the user's G1 remain the only requirements source and approval.
113
+ Failure: Start Superpowers `brainstorming` and its plan-and-execute chain, call `ce-brainstorm` for a named change, ask about each option separately, or label the unsettled charge rule `ASSUMED` or a non-blocking note.
114
+
115
+ ## Open idea before any concrete change
116
+ Input: One request states only a goal: renewals keep failing, figure out what to build. Another user says they do not know what to build. A third request names a concrete change. A fourth project has the same open goal without CE installed.
117
+ Expected: Decide from the request before loading a skill. For the open goal and the unsure user, announce in one line that `ce-brainstorm` will explore and that the user can switch to direct scoping, then pass the caller-owned exploration instruction; decisions, alternatives considered and open questions return to intake. The named change stays in intake. Without CE, intake explores directly and reports the fallback.
118
+ Failure: Let `ce-brainstorm` write or commit a separate spec, invoke a planning or implementation skill, or show its next-step menu, which can offer `lfg` with a PR and a push. Load it silently or for a named change, or install CE.
119
+
120
+ ## Caller-owned planning
121
+ Input: The team lead receives a Story with G1 recorded. Superpowers `writing-plans` ends with an Execution Handoff offering subagent-driven or inline execution, and its plan header names an execution sub-skill. CE `ce-plan` is also installed.
122
+ Expected: Invoke `superpowers:writing-plans` with the caller-owned plan instruction from skill-integration.md. Return the plan path, self-review result and unresolved decisions as blockers. Skip the Execution Handoff and name this workflow's graph as the executor in the plan header. Reuse an existing plan; a small reversible task may use the kit's minimal plan. Use `ce-plan` only when the user or host selects CE planning.
123
+ Failure: Start `executing-plans` or `subagent-driven-development`, leave an execution sub-skill as the plan's executor, default to `ce-plan`, or treat the plan's self-review as G3.
124
+
105
125
  ## Focused implementation returns to its caller
106
126
  Input: Developer receives only Task A of a project plan; CE and Superpowers are both installed. G1 already covers this work.
107
127
  Expected: Read skill-integration.md and the applicable Superpowers focused skill. Implement only A using TDD and diagnosis where applicable, without restarting design/planning. Use ce-work return-to-caller only as an explicitly selected alternative. Return changes and verification; the kit still owns final simplify/review/G4. Do not re-plan settled requirements or execute Tasks B/C.
108
128
  Failure: Invoke bare ce-work with the full project plan, enter shipping/babysitting, or start Superpowers design approvals and another implementer/reviewer hierarchy.
109
129
 
130
+ ## Superpowers review inside the allocation
131
+ Input: A normal review round has an allocation of three workers. Superpowers `requesting-code-review` dispatches one reviewer per filled template; CE `ce-code-review` is also installed and would add persona, validator and report workers.
132
+ Expected: Fill one template per bounded assignment (correctness and security, tests and runtime evidence, maintainability and performance), give each only its diff, requirements and evidence, and count each as one worker. Main aggregates and returns fixes to the Developer. Use `ce-code-review mode:agent` only when the user or host selects it and its fan-out fits the allocation; otherwise review directly within the allocation.
133
+ Failure: Default to `ce-code-review`, launch it beyond the allocation and hope, call one whole-diff template three reviews, let a reviewer re-delegate, or apply fixes from a read-only review.
134
+
110
135
  ## Completed review still needs fixes
111
136
  Input: ce-code-review mode:agent returns status complete, verdict Ready with fixes, and an unresolved material finding; actionable_findings is empty because the finding needs verification.
112
137
  Expected: Read findings, coverage and testing gaps; do not pass the review node. Return the concrete issue to the Developer or unresolved decision to the host, then review/reverify the affected new revision.
@@ -149,8 +174,8 @@ Expected: Graph status becomes stale for the edit; reset/review/reverify. Review
149
174
  Failure: Accept stale evidence or claim the runner proves semantic adequacy of every assertion.
150
175
 
151
176
  ## Adaptive review allocation
152
- Input: Normal code review has three available worker slots; simplify would start five workers and CE review would add merger/report/validator leaves. Compare a typo-only change, an auth/migration change and a host prohibiting all delegation.
153
- Expected: Main simplifies/aggregates; allocate three bounded review assignments for normal work, 0–1 for the typo, and increase to 4–5 only for named uncovered risks when permitted. Count internal workers in the same round; reviewers do not re-delegate. Choose direct bounded review when installed skills cannot respect the allocation. Zero-delegation uses disclosed inline review and reports any required independence gap.
154
- Failure: Treat three as mandatory/minimum, confuse Graph ready width or mode:agent with a dispatch cap, or report self-review as independent.
177
+ Input: Normal code review; simplify would start five workers and CE review would add merger/report/validator leaves. Compare a typo-only change, an auth/migration change with G3 and a host prohibiting all delegation.
178
+ Expected: The implementer simplifies while green and main aggregates; allocate one mid-tier reviewer for normal work, 0–1 for the typo, and two main-model reviewers for the G3 change. Count internal workers in the same round; reviewers do not re-delegate. Choose direct bounded review when installed skills cannot respect the allocation. Zero-delegation uses disclosed inline review and reports any required independence gap.
179
+ Failure: Dispatch a panel of reviewers by default, confuse Graph ready width or mode:agent with a dispatch cap, or report self-review as independent.
155
180
 
156
181
  These scenarios require observing the consuming agent's actual behavior. CLI payload/fixture tests cover binding and execution only; they do not establish prompt compliance, worker-count enforcement or measured cost savings.
@@ -14,19 +14,21 @@ Before model dispatch, apply `references/model-selection.md` using the host's av
14
14
 
15
15
  ## Non-negotiable gates
16
16
 
17
+ Every change except the direct lane in `references/fast-path.md` (one stated behavior, nothing to decide, light-lane rules hold):
18
+
17
19
  - Do not plan implementation or edit production code before the Story is `Approved` and G1 is recorded.
18
- - Do not declare delivery complete or merge a non-trivial change before G4 passes.
20
+ - Do not declare delivery complete or merge non-trivial changes before G4 passes.
19
21
  - Requirements have one source of truth; copies must not diverge.
20
22
 
21
23
  ## Explain before asking
22
24
 
23
- Before G1/G3, explain the problem, change, safety rule and verification plainly. Keep G4 prediction-before-reveal intact.
25
+ Before G1/G3, explain the problem, change, safety rule and verification plainly. G4: `ai-summary`; `human-restatement` for G3 Stories.
24
26
 
25
27
  ## Route by current state
26
28
 
27
- 1. **No approved Story:** read `references/intake.md` and `references/domain-risks.md`. Use `assets/STORY.md`; ask only missing behavior questions and obtain G1.
28
- 2. **Approved, not implemented:** read `references/execution.md` and `references/graph-engineering.md`. Automatically initialize/resume the installed Graph CLI; use the minimal plan for small work. Read `references/domain-risks.md` for relevant risks. Create a Task only when one PR is not reviewable.
29
- 3. **Implemented or `finish`:** complete pending checks in `references/execution.md`, then follow `references/understanding-gate.md` for G4.
29
+ 1. **No approved Story:** follow `references/fast-path.md` steps 1–2. Risk lenses: `references/domain-risks.md`; open ideas and question rules: `references/intake.md`.
30
+ 2. **Approved, not implemented:** `references/fast-path.md` steps 3–5, both lanes. G3, custom plans or roles: `references/execution.md`, `references/graph-minimal.md`, `references/light-lane.md`.
31
+ 3. **Implemented or `finish`:** `references/fast-path.md` step 6; `human-restatement` per `references/understanding-gate.md`.
30
32
  4. **`status`:** run the existing graph's `status` command; report stage, blocking decision, evidence and next action. Without a run, report the Story stage.
31
33
 
32
34
  Use the user's language. State assumptions, evidence limits and human-owned decisions.
@@ -1,30 +1,45 @@
1
1
  # Story: <observable outcome>
2
- Status: Draft
3
- Owner: <human owner>
4
- Understanding gate (G1): <pending>
5
- Understanding gate (G4): <pending>
6
2
 
7
3
  ## Goal
8
- <In a few plain-language sentences: what goes wrong today, what the person can do after the change, what must remain safe, and how we will check it. Put technical detail below; label assumptions.>
4
+ 1. As-is: <what happens today and why it is a problem>
5
+ 2. To-be: <what happens after the change>
6
+ 3. Unchanged: <what must stay exactly as it is>
9
7
 
10
8
  ## Domain
11
- - Terms: <term = meaning>
12
- - Invariant: <must always / never happen>
9
+ - Terms:
10
+ 1. <term> = <meaning; code identifiers are fine>
11
+ - Invariant:
12
+ 1. <must always / never happen>
13
+
14
+ ## Decisions
15
+ - D1. ASSUMED: <decision title>
16
+ 1. <the decided value or rule>
17
+ 2. <a different consequence or action, only if there is one>
18
+ - OPEN BLOCKING: <remove before approval, or omit>
13
19
 
14
20
  ## MUST
15
- - M1. <observable success behavior>
16
- - M2. <observable failure/negative behavior>
21
+ - M1. <condition or case>
22
+ 1. <result A + result B that happen together>
23
+ - M2. <condition or case>
24
+ 1. <result>
17
25
 
18
26
  ## SHOULD
19
- - S1. <useful, non-blocking behavior>
27
+ - S1. <title> (<purpose>)
28
+ 1. <action>
20
29
 
21
30
  ## OUT
22
- - O1. <explicit exclusion>
23
-
24
- ## Decisions
25
- - D1. <human decision or ASSUMED: safe default>
26
- - OPEN BLOCKING: <remove before approval, or omit>
31
+ - O1. <excluded area>
32
+ 1. <excluded item>
33
+ 2. <another excluded item>
34
+ - O2. <single excluded item>
27
35
 
28
36
  ## Verify
29
37
  - V1 [M1]. <input/action → observable result>
30
38
  - V2 [M2]. <failure/retry → state remains valid>
39
+
40
+ ---
41
+ Status: Draft
42
+ Owner: <human owner>
43
+ Lane: <light | standard>
44
+ Understanding gate (G1): <pending>
45
+ Understanding gate (G4): <pending>
@@ -2,16 +2,28 @@
2
2
 
3
3
  ## Assigned graph work
4
4
 
5
- If a host such as Agent Office delegates a started kit node, use its run/token and perform only the assigned role's procedure below. Return evidence and feedback to that graph; do not restart the entire workflow. Office coordinates roles and communication, while the kit continues to govern the work graph. See `graph-engineering.md` for dispatch boundaries.
5
+ If a host such as Agent Office delegates a started kit node, use its run/token and perform only the assigned role's procedure below. Return evidence and feedback to that graph; do not restart the entire workflow. Office coordinates roles and communication, while the kit continues to govern the work graph. See `graph-advanced.md` for dispatch boundaries.
6
6
 
7
7
  ## Stage integration
8
8
 
9
9
  Read `skill-integration.md` before selecting skills. Prefer Superpowers focused planning/implementation/review/verification skills and CE learning capture; CE planning, simplify and review modes are explicit alternatives. Keep one workflow owner. Existing approvals and the assigned role/task bound each invocation. Use the same evidence requirements with a disclosed direct fallback when a compatible skill is unavailable.
10
10
 
11
+ ## Orchestration
12
+
13
+ The main session keeps the Story, G1, the plan and the G4 summary. Code reading and writing go to subagents, on the tiers in `model-selection.md`:
14
+
15
+ - **Implementation:** a mid-tier subagent. Its brief is the Story's MUST/Verify, the `begin` brief and the intake map. It writes the tests and code and returns a short summary. The main session reads that summary, `git diff --stat` and the check results, not the code.
16
+ - **Review:** one mid-tier subagent with the Story's MUST/Verify and the diff; two main-model reviewers for a Story that needs G3.
17
+ - **Escalation:** after two failed attempts on the same node, the main model takes over.
18
+ - Codex, or any host without subagents, does the same steps in the main session.
19
+
20
+ **Test volume:** one focused test per Verify item, and a second only for a distinct failure path in its MUST. Add no tests for behavior the Story does not change unless an Invariant names it.
21
+
11
22
  ## Size first
12
23
 
13
- - **Small/reversible:** one reviewable outcome, local effect. Record `Plan source: N/A — small and reversible`; use test-first implementation and review.
14
- - **Normal:** use `superpowers:writing-plans` under the caller-owned contract → Superpowers focused TDD/diagnosis → inline simplification → bounded review with `superpowers:requesting-code-review` or direct review when compatible skills are available; simplify only after related tests pass. Apply the shared review allocation in `skill-integration.md` (default 3, adaptive 0–5). Otherwise perform equivalent repository-grounded stages directly.
24
+ - **Light lane** (`Lane: light`): follow `light-lane.md`. Record `Plan source: N/A — small and reversible`.
25
+ - **Standard, one outcome:** the built-in minimal plan. The Story's MUST/Verify, the `begin` brief and the intake map are the implementer's spec; write no plan document. Record `Plan source: N/A — minimal plan`.
26
+ - **Normal:** several dependent outcomes. Use `superpowers:writing-plans` under the caller-owned contract → Superpowers focused TDD/diagnosis → inline simplification → bounded review with `superpowers:requesting-code-review` or direct review when compatible skills are available; simplify only after related tests pass. Apply the shared review allocation in `skill-integration.md` (default 1). Otherwise perform equivalent repository-grounded stages directly.
15
27
  - **High-risk/hard to reverse:** add G3. Present the key design decision, alternatives, invariant, rollback/recovery path, and evidence plan; end the turn for human approval before work. Save that decision to `docs/understanding/<slug>-plan.md` and record `Understanding gate (G3): <artifact> · <YYYY-MM-DD> · Check-in: accepted`.
16
28
 
17
29
  High-risk signals: money/payment, authentication/authorization, concurrency, destructive migration, sensitive data, data loss, and irreversible external side effects.
@@ -22,7 +34,7 @@ Lead with the human-visible change and the reason for the chosen approach. Then
22
34
 
23
35
  Use one concrete scenario rather than a list of framework names. Explain each proposed Task by the behavior it delivers and how it connects to the next Task, not just the repository or layer it touches. Keep already-approved decisions visible without asking for them again; ask only for a new material decision. This explanation belongs to the existing plan and G3 checkpoint, not an extra document or gate.
24
36
 
25
- This is pre-implementation explanation. It does not reveal the implementation answer during G4; follow that gate's prediction-before-reveal sequence.
37
+ This is pre-implementation explanation, not G4. At G4, follow `understanding-gate.md` for the Story's mode: `ai-summary` by default, `human-restatement` (prediction before reveal) for G3 work.
26
38
 
27
39
  ## Task rule
28
40
 
@@ -32,14 +44,13 @@ Create Tasks only when the approved Story cannot be reviewed as one PR. Each Tas
32
44
 
33
45
  For user-authorized optional Jira publication after G1, follow `jira.md`. Without a connector or authorized target, produce a preview only; the Story remains canonical.
34
46
 
35
- 1. Read the approved Story, relevant code, tests, repository instructions, and prior learnings.
36
- 2. Make a plan that maps every M/V ID to code and evidence. Use `verification.md` for a runnable project recipe; assert the actual user path and failure cases, rather than treating exit 0 from a no-op as behavioral proof. Do not create a second requirement source.
37
- Automatically initialize/resume the installed graph as described in `graph-engineering.md`. Use `-` for small work; otherwise supply the reviewed task DAG. The CLI adds final review and fresh verification. Complete any required G3 before implementation nodes run.
38
- 3. Use compatible `superpowers:test-driven-development` for implementation and `superpowers:systematic-debugging` for unexplained failures. For new behavior or a bug fix, demonstrate RED before production code, then GREEN after the minimum change. Proceed when related tests pass.
39
- 4. Refactor while green: main performs the simplification pass below. Use `ce-simplify-code` only when its actual dispatch fits the same round's allocation; otherwise apply the criteria directly.
40
- 5. Review the final diff against the Story, failure paths and testing limits. Allocate reviewers before dispatch using `skill-integration.md`; use compatible `superpowers:requesting-code-review` or direct review, and bounded `ce-code-review mode:agent` only when the user or host selects it. Resolve material findings and state independence/coverage limits. Do not apply fixes from a read-only review assignment.
41
- 6. Apply compatible `superpowers:verification-before-completion`, using Graph `verify` on the current started token to execute the configured checks. Pstack recipe material defines the user journeys; SP governs fresh execution and evidence inspection. Read receipts and raw logs from that same execution; do not run a second verification pass solely to satisfy both names. Revalidate affected behavior after simplify/review edits before G4. If review edits affect previously simplified code, recheck only the affected scope; do not restart the whole pipeline automatically. Broaden tests when impact warrants it; never claim old results cover new edits.
42
- 7. Record the verified evidence in the graph, run its `status` command, and require `action: g4` before continuing to `understanding-gate.md`; passing tests alone are not completion.
47
+ 1. Read the approved Story and the intake map. Open code only to settle a specific question; the implementer reads the code.
48
+ 2. Choose the plan by size above and set up the run with `go` as `fast-path.md` describes; several outcomes supply the reviewed task DAG (`graph-advanced.md`). Fix a wrong detected profile with `verification.md`: assert the actual user path and failure cases, rather than treating exit 0 from a no-op as behavioral proof. Do not create a second requirement source. Complete any required G3 before implementation nodes run.
49
+ 3. `begin` each implementation node and dispatch the implementer (Orchestration above). It uses compatible `superpowers:test-driven-development`, and `superpowers:systematic-debugging` for unexplained failures. For new behavior or a bug fix it demonstrates RED before production code, then GREEN after the minimum change. Then `complete` the node; its checks decide.
50
+ 4. Refactor while green: the implementer performs the simplification pass below. Use `ce-simplify-code` only when its actual dispatch fits the same round's allocation; otherwise apply the criteria directly.
51
+ 5. Review the final diff against the Story, failure paths and testing limits with one reviewer (`skill-integration.md`): compatible `superpowers:requesting-code-review` or direct review, and bounded `ce-code-review mode:agent` only when the user or host selects it. Record its findings with `complete --verdict … --notes …`. Do not apply fixes from a read-only review assignment.
52
+ 6. Apply compatible `superpowers:verification-before-completion` through `complete` on `workflow-verify`: it executes the configured checks, or reuses passing receipts for unchanged code. On a failure, read the receipt and raw log it names. Do not run a second verification pass solely to satisfy both names, and never claim old results cover new edits.
53
+ 7. Require `next: g4` before continuing to `understanding-gate.md`; passing tests alone are not completion.
43
54
 
44
55
  ## Simplification pass
45
56
 
@@ -47,7 +58,7 @@ For user-authorized optional Jira publication after G1, follow `jira.md`. Withou
47
58
  - Limit scope to the current task's changed code and necessary related seams. Avoid unrelated refactoring, new abstractions or packages, and edits made just to fill a diff.
48
59
  - Reduce duplication, unnecessary state, branches and complexity to improve understanding. Fewer lines or replacing `for` with a stream is not evidence of improvement; chaining operations does not necessarily reduce traversals. Check actual iteration and evaluation behavior before claiming efficiency.
49
60
  - Preserve behavior, result order, side effects, domain boundaries, failure handling and safety checks. A proposal that changes them belongs to the existing design or scope-change process, not a silent simplification.
50
- - Main simplifies inline by default. Any simplify workers consume the shared review allocation in `skill-integration.md`; select only skill modes that fit host limits.
61
+ - The implementer simplifies inline by default. Any simplify workers consume the shared review allocation in `skill-integration.md`; select only skill modes that fit host limits.
51
62
  - Include changes (or no-change outcome), review scope and fresh checks briefly in existing review/verification evidence. Add no separate approval gate, mandatory document or Jira Task.
52
63
 
53
64
 
@@ -57,9 +68,9 @@ Graph execution is installed and used automatically after G1. Small changes use
57
68
 
58
69
  Planning is repository-grounded planning → review → deterministic validation. Research code, tests and risks as needed; do not require separate analyzer, advocate or mediator agents. Reuse an existing plan, whichever skill produced it. The host performs agent/tool work and the installed CLI owns readiness, evidence records and recovery; never create a second nested orchestration pipeline for the same task.
59
70
 
60
- The execution graph does not replace human gates. G1 still approves scope before planning/implementation, G3 still protects high-risk choices, and G4 still requires prediction-before-reveal. Superpowers focused skills and CE stage skills provide node behavior as mapped in `skill-integration.md`; the graph owns dependency and retry structure rather than copying those skills.
71
+ The execution graph does not replace human gates. G1 still approves scope before planning/implementation, G3 still protects high-risk choices, and G4 still requires the human's own decision: explicit approval of the AI summary, or prediction-before-reveal restatement for G3 work. Superpowers focused skills and CE stage skills provide node behavior as mapped in `skill-integration.md`; the graph owns dependency and retry structure rather than copying those skills.
61
72
 
62
- After each node, explicitly evaluate and record its evidence. Route failed checks to `fix`, changed assumptions to `replan`, and unresolved human decisions to `human`. For fixes within an unchanged plan, reset the earliest affected node and its descendants, preserving independent completed work. Changed plans/requirements require a new validated run; do not transplant stale evidence. Three attempts exhaust the run's retry allowance. Never silently create a new run to evade a stop. See `graph-engineering.md` for the executable protocol.
73
+ After each node, explicitly evaluate and record its evidence. Route failed checks to `fix`, changed assumptions to `replan`, and unresolved human decisions to `human`. For fixes within an unchanged plan, reset the earliest affected node and its descendants, preserving independent completed work. Changed plans/requirements require a new validated run; do not transplant stale evidence. Three attempts exhaust the run's retry allowance. Never silently create a new run to evade a stop. See `graph-minimal.md` for the executable protocol.
63
74
 
64
75
  ## Capture verified learning
65
76
 
@@ -0,0 +1,23 @@
1
+ # Fast path (for the model; terse)
2
+
3
+ MAIN = G1, G4, joins. Outside DIRECT, never read code, test logs or kit source in main. Never edit code or run formatters in main (an edit after `complete implement` reruns every check); a style nit is a note. Read only CLI JSON, subagent summaries, `git diff --stat`. CLI = `node .ai-workflow/bin/graph.mjs`; its JSON is compact, never tail it. Pipe other long output to `| tail -20`. Never sleep or poll; results arrive by themselves. Chain dependent CLI calls with `&&` in one Bash call. No subagents on this host: do steps 1, 3 and 4 in main, same order.
4
+
5
+ DIRECT: when the request names one behavior and its place and leaves nothing to decide (`graph.mjs copies` finds no copy with it; nothing to assume or ask) and the light-lane rules of the step 1 footer hold: no Story, gates or subagents. Main reads at most 8 files, edits, adds one focused test per stated behavior, runs those and existing tests of changed classes once, then reports: change, test, what was not run. Anything to decide: step 1.
6
+
7
+ 1. STORY: one Agent `model: opus` gets the request and these rules. It explores first (at most 12 tool calls: code path, callers, tests, config, contracts), writes `docs/stories/<slug>.md` from `../assets/STORY.md`, and returns at most 10 lines (Goal, MUST titles, ASSUMED, OUT) plus a map of at most 15 lines (`file:line` refs, current behavior, test command):
8
+ - Goal: `1. As-is:` `2. To-be:` `3. Unchanged:`. To-be removes the pain the request names, manual or night-time work included; never put what that needs into OUT (make it MUST, or `OPEN BLOCKING`). Whoever drafts the Story first runs `graph.mjs copies <files or folders the change touches>` and follows its `rule` for parallel copies, never ASSUMED one copy into OUT; D1 is `Copies:` the list and the decision. Domain: numbered Terms, Invariant.
9
+ - Decisions above MUST: `ASSUMED` defaults come from the code: change where the request's text or area already is, branching on values that code already receives; a new signal or place says why. `OPEN BLOCKING` only for behavior a human must choose (money, migration, auth: never `ASSUMED`; see `domain-risks.md`).
10
+ - MUST/SHOULD/OUT: every request sentence maps to a MUST, or to OUT with why; title line, nested numbers; results that happen together: one line joined by `+`.
11
+ - Verify: `V# [M#]` success and failure.
12
+ - Footer after `---`: Status, Owner, `Lane: light` only if reversible + one module + no external contract + no persistent data + not high-risk; else `Lane: standard`.
13
+ - At most three blocking questions, two rounds; more, or an open idea: `intake.md`.
14
+ 2. G1: show the Story path and its Decisions lines, then explain in the user's language in at most five lines: today, after, unchanged, how we check. Ask. END THE TURN. Only an explicit approval counts. Then, in one message, one Bash call: save the reply with a heredoc to `.ai-workflow/approvals/<slug>-g1-reply.md` `&& graph.mjs approve G1 <story> --response <reply> && graph.mjs go <story> .ai-workflow/runs/<slug>.json --scope <module or path>…` (light lane: `light` instead of `go`). Never edit Status or gate lines. The brief's `checks` are the exact commands; never open `verification.json`.
15
+ 3. IMPLEMENT: one Agent, `model: sonnet`. Give it the Story MUST and Verify, the brief JSON, the run path and the map. Its rules: test-first; one focused test per Verify item, a second only for a distinct failure path; run a new test RED once only when it compiles against existing code; never the full suite; never write a test runner; never change build or test config to run a test; if tests cannot run, say so. It finishes with `graph.mjs complete <run> implement --tests <its test classes or files and the existing tests of classes it changed>` (light: `graph.mjs check <run> --tests …`): that is its GREEN run. On `status: failed` it fixes from `failing.tail` and runs `complete` again, at most twice; a failure only in an untouched test existed before: drop it from `--tests` and say so. It returns at most 15 lines: files, `V# → test` per Verify item, the last `complete` JSON.
16
+ 4. REVIEW: one Agent `model: sonnet`, read-only (no builds or tests; at most 8 tool calls). Give it the Story path, the implementer's report and `<slug>`. It reads `git diff`, writes findings to `.ai-workflow/evidence/review-1.md` (at most 15 lines) and, on pass, four Korean lines to `.ai-workflow/approvals/<slug>-g4-summary.md`: `1. 사용자가 겪는 변화` `2. 지킨 규칙과 실패할 때 동작` `3. 확인한 테스트` `4. 확인하지 못한 것`. Verdict `fix` only when a MUST or Verify item is unmet or behavior is wrong; anything else is a note.
17
+ - Pass: one Bash call: `graph.mjs complete <run> workflow-review --verdict pass --notes .ai-workflow/evidence/review-1.md && graph.mjs complete <run> workflow-verify && cat <summary>`. Light: `graph.mjs review <run> --verdict pass --notes … && cat <summary>`.
18
+ - Fix: `--verdict fix` alone; the implementer fixes only the listed findings and runs `complete implement`; then the pass call without a new reviewer (one round); main writes the summary, and anything not fixed goes to line 4.
19
+ - Still failing after two attempts: implement again with `model: opus`.
20
+ 5. VERIFY reuses passing receipts; expect `next: g4`. Light: no verify step.
21
+ 6. G4: show the four lines as written. Ask. END THE TURN. Only an explicit approval counts; on a correction, fix the line and ask again. Then one Bash call: save the reply to `.ai-workflow/approvals/<slug>-g4-reply.md` `&& graph.mjs approve G4 <run> --summary <summary> --response <reply>`. Report its result.
22
+
23
+ Other cases: `next: human|replan` → ask the human. `stop` → report, no new run. High-risk (G3) or several dependent outcomes → `execution.md`. Roles → `role-graphs.md`.
@@ -0,0 +1,126 @@
1
+ # Graph: advanced use
2
+
3
+ The standard path is [fast-path.md](fast-path.md) and [graph-minimal.md](graph-minimal.md): `approve G1`, `go`, `complete` per node, `approve G4`. This page covers custom plans, roles, the lower-level start/verify/record protocol, routing details and the programmatic API.
4
+
5
+ Use the installed Graph CLI automatically after G1; no user opt-in, extra npm install, API key or custom JavaScript adapter is needed. The host (Codex/Claude) executes agent and tool work. The local CLI checks dependencies, persists results and tells the host what to do next. It does not launch models. Its verification runner executes only checks selected by ID from the repository-owned verification profile, using argv without a shell. Treat that profile as executable project code; host permissions still apply.
6
+
7
+ Read `skill-integration.md` when selecting Superpowers or CE for a graph node. Each selected skill implements only that stage; its own completion or shipping workflow cannot replace the kit's remaining gates.
8
+
9
+ ## Roles and graph ownership
10
+
11
+ The kit supplies graph construction, deterministic validation, dependency scheduling, joins, evidence and failure routing in both standalone use and Agent Office. Office assigns people-like roles, launches agents, carries messages and displays progress; it uses kit readiness/results rather than implementing a competing graph state machine. Office does not disable the kit graph.
12
+
13
+ A role is not necessarily one node. A Developer may perform several implementation nodes; a Reviewer may inspect several independent areas. Function nodes perform deterministic checks without an agent. Split nodes only for a meaningful dependency, distinct evidence or recovery boundary.
14
+
15
+ For a delegated node, the dispatch must identify the kit run, node, started token, role, task description, approved Story constraints, allowed access and direct dependency outputs. The assigned agent applies the relevant procedure and returns summary, evidence and explicit evaluation to that same run. It must not initialize a new delivery graph, repeat G1/G4, spawn an unbounded team or implement changes inside a read-only review assignment. Missing scope or inputs must be reported to the dispatcher rather than invented. The kit graph is already active: executing its assigned node is graph use.
16
+
17
+ For a separate role objective, use the durable `init-role` entrypoint in [role-graphs.md](role-graphs.md). It supplies PM, team-lead, developer and reviewer flows without appending the whole delivery envelope. PM intake before G1 remains non-implementation work and cannot authorize production edits. The optional generic API is still available for custom graphs, with the different guarantees listed below.
18
+
19
+ Role-local execution and host enforcement are compatible. An agent performs its assigned kit flow; Office uses that flow's identity and results to dispatch work and accept its outcome. Office also applies host-owned permissions, cancellation and global budgets. It must not reimplement the role's workflow rules or treat a worker's "done" message as proof of graph completion. If a role uses a separate graph, link its run to the Office assignment and target revision; its completion is only that role's outcome, not completion of the whole delivery. This describes the integration contract, not an adapter already shipped by the kit.
20
+
21
+ Link messages to run/node/attempt and the requirement, question, decision, artifact or finding they concern. A review failure goes back through the kit's corrective route to the responsible implementation node. Only the overall delivery owner presents G4 after final evidence, using the actual user's response. Role completion is not project completion.
22
+
23
+ One controller owns each persisted kit run through the CLI. Its file is authoritative for local transitions; Office owns the shared goal, acceptance criteria, assignments, collaboration and integration. Office may index local progress but must not independently advance a copy. The CLI file store is not a finished Office adapter. Locking and write exclusion apply within that run, not across separate runs or processes editing the same repository. Office must isolate independent writers or serialize them and enforce any overall time/cost/cancellation limits. The kit's three-attempt bound does not implement an Office-wide budget or process cancellation.
24
+
25
+ ## Initialize or resume
26
+
27
+ Read the approved Story, relevant code/tests and prior learnings. Complete required G3 before implementation. Reuse repository-grounded planning/review already performed by Compound skills; do not repeat it with a fixed team of analyzers, advocates and mediators.
28
+
29
+ Read [verification.md](verification.md) to configure real checks and bound G1/G3 records before initialization. New runs use v3. Legacy v1/v2 runs are read-only and return `upgrade-required`; stop old workers, inspect side effects, and create a new run with fresh review/checks without evading attempt limits.
30
+
31
+ Use a stable run path for the Story, such as `.ai-workflow/runs/<slug>.json`. If it exists, run `status`; never replace it to escape a failure. For a small/reversible change, use the built-in plan:
32
+
33
+ ```bash
34
+ node .ai-workflow/bin/graph.mjs init - .ai-workflow/runs/<slug>.json docs/<story>.md
35
+ node .ai-workflow/bin/graph.mjs status .ai-workflow/runs/<slug>.json
36
+ ```
37
+
38
+ The minimal plan is `implement → workflow-review → workflow-verify`. Implementation includes test-first work, related GREEN tests and bounded simplification. Final review checks the diff; verification supplies fresh checks after any fixes. No separate plan document is needed for small work.
39
+
40
+ For independently meaningful outcomes, write a reviewed JSON plan (HOW only; Story M/V IDs remain canonical):
41
+
42
+ ```json
43
+ {
44
+ "id": "coupon-change",
45
+ "nodes": [
46
+ { "id": "model", "description": "Represent the approved coupon rules", "access": "write", "covers": ["M1"], "verify": "Exercise allowed and rejected model transitions" },
47
+ { "id": "api", "description": "Expose the approved behavior", "access": "write", "covers": ["V1"], "verify": "Check the Story's API success and failure cases" }
48
+ ],
49
+ "edges": [{ "from": "model", "to": "api" }]
50
+ }
51
+ ```
52
+
53
+ Every Story M/V ID must be covered and unknown IDs are rejected. `description`, `verify`, `covers` and `access` are required per task. Use the actual Story IDs, not these example IDs. Run `init <plan.json> <run.json> <story.md>`; it deterministically validates references/cycles and appends mandatory final review/verification. Never put human approval inside generated nodes.
54
+
55
+ ## Execute ready work
56
+
57
+ 1. Read the JSON status and its `action`. Apply [model-selection.md](model-selection.md) before dispatch using the cached host catalog. Give each worker only its task, Story constraints, relevant files and `input.dependencies`; do not send the whole run/history. Read evidence files by reference as needed.
58
+ 2. Reserve each ready task before starting work:
59
+
60
+ `node .ai-workflow/bin/graph.mjs start <run.json> <node-id> <ready-token>`
61
+
62
+ Use the returned `started.token` for the result record. Start durably counts the attempt and marks it running, preventing duplicate dispatch and overlapping writers. Execute only reserved tasks. They include a token for that unique run, exact attempt and dependency state. One host controller owns the run. Read-only tasks may run concurrently within the host's limits; write tasks are exclusive. A read node must not edit code: fail it with `fix` and reset the earliest implementation node when changes are needed.
63
+ 3. Save actual observations to a new, nonempty project-relative evidence file per attempt. Include changed files, commands, exit codes, review findings and verification limits as applicable. Do not overwrite evidence from completed independent work. Long logs remain files, not copied model context.
64
+ 4. Write a result JSON with the started task's token:
65
+
66
+ ```json
67
+ {
68
+ "token": "copy started.token from start",
69
+ "output": { "summary": "Describe the observable result", "evidence": ["docs/understanding/coupon-model-attempt-1.md"] },
70
+ "evaluation": { "passed": true }
71
+ }
72
+ ```
73
+
74
+ ```bash
75
+ node .ai-workflow/bin/graph.mjs record <run.json> <node-id> <result.json>
76
+ ```
77
+
78
+ A failed result uses `"evaluation": { "passed": false, "action": "fix", "feedback": "Specific failed expectation and affected task" }`. Evaluation is mandatory. An omitted value, empty evidence, premature node or stale token cannot complete a task. Implementation/review observations remain host judgments. Final verification and Developer self-check additionally require runner-issued successful receipts covering every assigned V ID. Execute `node .ai-workflow/bin/graph.mjs verify <run.json> <node-id> <started-token> <check-id>` for each required check, inspect the returned exit status and raw logs, then record. `passed: true` cannot override a failed/missing execution. Runner CLI exit 0 means the execution was collected; inspect `verification.passed`, not just CLI exit status. CLI exit 0 means the record was accepted, including a failure record: inspect `action` and `failed`.
79
+
80
+ ## Route the next action
81
+
82
+ | Action | Host behavior |
83
+ |---|---|
84
+ | `execute` | Perform ready tasks and record their results. Fetch fresh status after each completion. |
85
+ | `wait` | Wait for running workers; do not dispatch them again. After an interrupted session, inspect their side effects and explicitly reset stopped workers. |
86
+ | `fix` | Identify the earliest affected task; reset it before doing corrective work, then rerun it and invalidated descendants. Independent results stay recorded. |
87
+ | `replan` | Correct the plan; validate it into a new run and retain the old run as evidence. Scope changes use the existing human gate. |
88
+ | `human` | Surface the unresolved decision and wait. After resolution, use a new run reflecting it. |
89
+ | `stop` | Report exhausted attempts and evidence. Do not restart under a new filename without an explicit decision to continue. |
90
+ | `question` | Transport the pending question; submit the matching answer and continue with `resumed.token`. See `role-graphs.md`. An answer is not approval. |
91
+ | `role-complete` | Return the role's native outcome and evidence to the caller. This does not finish delivery. |
92
+ | `stale` | Code changed after review/check start. Inspect changes and reset the earliest affected node; rerun invalidated descendants. Status never rewrites saved state. |
93
+ | `upgrade-required` | Legacy run is inspectable only; follow the migration note above. |
94
+ | `g4` | Follow `understanding-gate.md`; this is readiness, not approval or delivery. |
95
+
96
+ ```bash
97
+ node .ai-workflow/bin/graph.mjs reset <run.json> <earliest-affected-node> "What will be corrected and why"
98
+ ```
99
+
100
+ Reset the implementation node when a review requires code edits; resetting only the reviewer would retain invalid implementation evidence. Stop any affected running workers before reset; reset invalidates their old tokens. Reset preserves attempt counts; three attempts is the per-node limit. No automatic repeated side effects or unrestricted retry loop. Changing graph content or Story requirements invalidates the run; progress/gate metadata may change without invalidating requirements. New plans conservatively start fresh instead of guessing which old outputs remain valid.
101
+
102
+ Writes use an exclusive `.lock` and atomic file replacement. After a crashed CLI process, inspect the lock's owner and the run before manually removing a stale lock. Never delete a live writer's lock. Avoid simultaneous install/remove and execution. Updates/removal preserve run and evidence files; keep those separate from the managed `.ai-workflow/graph/` runtime.
103
+
104
+ ## Programmatic API (optional)
105
+
106
+ After init, import from `./.ai-workflow/graph/index.mjs`. Consumers who install the npm package as a dependency can also import `@pazmo/ai-workflow-kit/src/graph/index.mjs`.
107
+
108
+ `executeTaskGraph({ graph, runNode, evaluateNode, context, runState, maxConcurrency })` requires explicit evaluation results. Default concurrency is 1; a higher positive integer allows overlapping nodes marked `access: 'read'`. Writers and undeclared-access nodes run exclusively. A newly ready node starts as soon as a slot becomes available; joins wait only for their dependencies. `waves` records dispatch batches, not global barriers.
109
+
110
+ Node input is `{ context, dependencies }`, copied to avoid shared mutation. Persisted states carry a graph fingerprint; changed plans and unknown/unevaluated statuses are rejected. Interrupted `running` nodes require an explicit `resetAffectedSubgraph` after checking external side effects. This in-process API does not persist checkpoints or approve gates; use the installed CLI for the durable host workflow.
111
+
112
+ The generic API is not the delivery CLI's policy API. Choose the interface by its actual guarantees:
113
+
114
+ | Responsibility | Generic API | Delivery CLI | Host |
115
+ |---|---|---|---|
116
+ | Dependency readiness, read concurrency, exclusive writers | Within one execution | Within one run | Isolate or serialize work across runs |
117
+ | Attempts | Counts starts; no built-in cap | Maximum three starts per node | Enforce global time, cost and attempt budgets |
118
+ | `human` / `replan` evaluation | Records the action; independent work can continue | Routes to the decision; no further start until resolved in a new run | Stop affected processes and obtain the decision |
119
+ | Evidence and persistence | Returns state and explicit evaluation; no evidence-file checks or checkpoint store | Binds actual snapshots, runner receipts and evidence hashes; persists run changes | Judge assertion adequacy and external/environment boundaries |
120
+ | User approval and tool permissions | Not provided | Checks approval records, not identity; does not intercept tools | Own actual approval events and execution permissions |
121
+
122
+ Do not assume `executeTaskGraph` or `resetAffectedSubgraph` enforces the delivery CLI's retry or human-decision rules. Office integration must first identify its actual dispatch, storage, cancellation and result-application boundary. If it needs shared delivery transitions, extract only the necessary rules from the CLI when connecting that consumer; do not duplicate the rules in Office or invent an unused public API in advance.
123
+
124
+ `access: 'read'` describes product-code access, not a filesystem sandbox. Review evidence and test-generated files may still require designated output paths. Host enforcement must distinguish these from product edits. Multiple developer processes alone do not provide safe parallel implementation: the host must manage workspace isolation, integration and verification of the combined result.
125
+
126
+ `createPlanningGraph()` supplies `planner → review → validate-graph`. Planner/review callbacks return task graphs; the last node executes built-in deterministic validation rather than an LLM callback. Research and extra review roles are chosen for the work, not required by the graph.
@@ -1,124 +1,3 @@
1
1
  # Graph execution
2
2
 
3
- Use the installed Graph CLI automatically after G1; no user opt-in, extra npm install, API key or custom JavaScript adapter is needed. The host (Codex/Claude) executes agent and tool work. The local CLI checks dependencies, persists results and tells the host what to do next. It does not launch models. Its verification runner executes only checks selected by ID from the repository-owned verification profile, using argv without a shell. Treat that profile as executable project code; host permissions still apply.
4
-
5
- Read `skill-integration.md` when selecting Superpowers or CE for a graph node. Each selected skill implements only that stage; its own completion or shipping workflow cannot replace the kit's remaining gates.
6
-
7
- ## Roles and graph ownership
8
-
9
- The kit supplies graph construction, deterministic validation, dependency scheduling, joins, evidence and failure routing in both standalone use and Agent Office. Office assigns people-like roles, launches agents, carries messages and displays progress; it uses kit readiness/results rather than implementing a competing graph state machine. Office does not disable the kit graph.
10
-
11
- A role is not necessarily one node. A Developer may perform several implementation nodes; a Reviewer may inspect several independent areas. Function nodes perform deterministic checks without an agent. Split nodes only for a meaningful dependency, distinct evidence or recovery boundary.
12
-
13
- For a delegated node, the dispatch must identify the kit run, node, started token, role, task description, approved Story constraints, allowed access and direct dependency outputs. The assigned agent applies the relevant procedure and returns summary, evidence and explicit evaluation to that same run. It must not initialize a new delivery graph, repeat G1/G4, spawn an unbounded team or implement changes inside a read-only review assignment. Missing scope or inputs must be reported to the dispatcher rather than invented. The kit graph is already active: executing its assigned node is graph use.
14
-
15
- For a separate role objective, use the durable `init-role` entrypoint in [role-graphs.md](role-graphs.md). It supplies PM, team-lead, developer and reviewer flows without appending the whole delivery envelope. PM intake before G1 remains non-implementation work and cannot authorize production edits. The optional generic API is still available for custom graphs, with the different guarantees listed below.
16
-
17
- Role-local execution and host enforcement are compatible. An agent performs its assigned kit flow; Office uses that flow's identity and results to dispatch work and accept its outcome. Office also applies host-owned permissions, cancellation and global budgets. It must not reimplement the role's workflow rules or treat a worker's "done" message as proof of graph completion. If a role uses a separate graph, link its run to the Office assignment and target revision; its completion is only that role's outcome, not completion of the whole delivery. This describes the integration contract, not an adapter already shipped by the kit.
18
-
19
- Link messages to run/node/attempt and the requirement, question, decision, artifact or finding they concern. A review failure goes back through the kit's corrective route to the responsible implementation node. Only the overall delivery owner presents G4 after final evidence, using the actual user's response. Role completion is not project completion.
20
-
21
- One controller owns each persisted kit run through the CLI. Its file is authoritative for local transitions; Office owns the shared goal, acceptance criteria, assignments, collaboration and integration. Office may index local progress but must not independently advance a copy. The CLI file store is not a finished Office adapter. Locking and write exclusion apply within that run, not across separate runs or processes editing the same repository. Office must isolate independent writers or serialize them and enforce any overall time/cost/cancellation limits. The kit's three-attempt bound does not implement an Office-wide budget or process cancellation.
22
-
23
- ## Initialize or resume
24
-
25
- Read the approved Story, relevant code/tests and prior learnings. Complete required G3 before implementation. Reuse repository-grounded planning/review already performed by Compound skills; do not repeat it with a fixed team of analyzers, advocates and mediators.
26
-
27
- Read [verification.md](verification.md) to configure real checks and bound G1/G3 records before initialization. New runs use v3. Legacy v1/v2 runs are read-only and return `upgrade-required`; stop old workers, inspect side effects, and create a new run with fresh review/checks without evading attempt limits.
28
-
29
- Use a stable run path for the Story, such as `.ai-workflow/runs/<slug>.json`. If it exists, run `status`; never replace it to escape a failure. For a small/reversible change, use the built-in plan:
30
-
31
- ```bash
32
- node .ai-workflow/bin/graph.mjs init - .ai-workflow/runs/<slug>.json docs/<story>.md
33
- node .ai-workflow/bin/graph.mjs status .ai-workflow/runs/<slug>.json
34
- ```
35
-
36
- The minimal plan is `implement → workflow-review → workflow-verify`. Implementation includes test-first work, related GREEN tests and bounded simplification. Final review checks the diff; verification supplies fresh checks after any fixes. No separate plan document is needed for small work.
37
-
38
- For independently meaningful outcomes, write a reviewed JSON plan (HOW only; Story M/V IDs remain canonical):
39
-
40
- ```json
41
- {
42
- "id": "coupon-change",
43
- "nodes": [
44
- { "id": "model", "description": "Represent the approved coupon rules", "access": "write", "covers": ["M1"], "verify": "Exercise allowed and rejected model transitions" },
45
- { "id": "api", "description": "Expose the approved behavior", "access": "write", "covers": ["V1"], "verify": "Check the Story's API success and failure cases" }
46
- ],
47
- "edges": [{ "from": "model", "to": "api" }]
48
- }
49
- ```
50
-
51
- Every Story M/V ID must be covered and unknown IDs are rejected. `description`, `verify`, `covers` and `access` are required per task. Use the actual Story IDs, not these example IDs. Run `init <plan.json> <run.json> <story.md>`; it deterministically validates references/cycles and appends mandatory final review/verification. Never put human approval inside generated nodes.
52
-
53
- ## Execute ready work
54
-
55
- 1. Read the JSON status and its `action`. Apply [model-selection.md](model-selection.md) before dispatch using the cached host catalog. Give each worker only its task, Story constraints, relevant files and `input.dependencies`; do not send the whole run/history. Read evidence files by reference as needed.
56
- 2. Reserve each ready task before starting work:
57
-
58
- `node .ai-workflow/bin/graph.mjs start <run.json> <node-id> <ready-token>`
59
-
60
- Use the returned `started.token` for the result record. Start durably counts the attempt and marks it running, preventing duplicate dispatch and overlapping writers. Execute only reserved tasks. They include a token for that unique run, exact attempt and dependency state. One host controller owns the run. Read-only tasks may run concurrently within the host's limits; write tasks are exclusive. A read node must not edit code: fail it with `fix` and reset the earliest implementation node when changes are needed.
61
- 3. Save actual observations to a new, nonempty project-relative evidence file per attempt. Include changed files, commands, exit codes, review findings and verification limits as applicable. Do not overwrite evidence from completed independent work. Long logs remain files, not copied model context.
62
- 4. Write a result JSON with the started task's token:
63
-
64
- ```json
65
- {
66
- "token": "copy started.token from start",
67
- "output": { "summary": "Describe the observable result", "evidence": ["docs/understanding/coupon-model-attempt-1.md"] },
68
- "evaluation": { "passed": true }
69
- }
70
- ```
71
-
72
- ```bash
73
- node .ai-workflow/bin/graph.mjs record <run.json> <node-id> <result.json>
74
- ```
75
-
76
- A failed result uses `"evaluation": { "passed": false, "action": "fix", "feedback": "Specific failed expectation and affected task" }`. Evaluation is mandatory. An omitted value, empty evidence, premature node or stale token cannot complete a task. Implementation/review observations remain host judgments. Final verification and Developer self-check additionally require runner-issued successful receipts covering every assigned V ID. Execute `node .ai-workflow/bin/graph.mjs verify <run.json> <node-id> <started-token> <check-id>` for each required check, inspect the returned exit status and raw logs, then record. `passed: true` cannot override a failed/missing execution. Runner CLI exit 0 means the execution was collected; inspect `verification.passed`, not just CLI exit status. CLI exit 0 means the record was accepted, including a failure record: inspect `action` and `failed`.
77
-
78
- ## Route the next action
79
-
80
- | Action | Host behavior |
81
- |---|---|
82
- | `execute` | Perform ready tasks and record their results. Fetch fresh status after each completion. |
83
- | `wait` | Wait for running workers; do not dispatch them again. After an interrupted session, inspect their side effects and explicitly reset stopped workers. |
84
- | `fix` | Identify the earliest affected task; reset it before doing corrective work, then rerun it and invalidated descendants. Independent results stay recorded. |
85
- | `replan` | Correct the plan; validate it into a new run and retain the old run as evidence. Scope changes use the existing human gate. |
86
- | `human` | Surface the unresolved decision and wait. After resolution, use a new run reflecting it. |
87
- | `stop` | Report exhausted attempts and evidence. Do not restart under a new filename without an explicit decision to continue. |
88
- | `question` | Transport the pending question; submit the matching answer and continue with `resumed.token`. See `role-graphs.md`. An answer is not approval. |
89
- | `role-complete` | Return the role's native outcome and evidence to the caller. This does not finish delivery. |
90
- | `stale` | Code changed after review/check start. Inspect changes and reset the earliest affected node; rerun invalidated descendants. Status never rewrites saved state. |
91
- | `upgrade-required` | Legacy run is inspectable only; follow the migration note above. |
92
- | `g4` | Follow `understanding-gate.md`; this is readiness, not approval or delivery. |
93
-
94
- ```bash
95
- node .ai-workflow/bin/graph.mjs reset <run.json> <earliest-affected-node> "What will be corrected and why"
96
- ```
97
-
98
- Reset the implementation node when a review requires code edits; resetting only the reviewer would retain invalid implementation evidence. Stop any affected running workers before reset; reset invalidates their old tokens. Reset preserves attempt counts; three attempts is the per-node limit. No automatic repeated side effects or unrestricted retry loop. Changing graph content or Story requirements invalidates the run; progress/gate metadata may change without invalidating requirements. New plans conservatively start fresh instead of guessing which old outputs remain valid.
99
-
100
- Writes use an exclusive `.lock` and atomic file replacement. After a crashed CLI process, inspect the lock's owner and the run before manually removing a stale lock. Never delete a live writer's lock. Avoid simultaneous install/remove and execution. Updates/removal preserve run and evidence files; keep those separate from the managed `.ai-workflow/graph/` runtime.
101
-
102
- ## Programmatic API (optional)
103
-
104
- After init, import from `./.ai-workflow/graph/index.mjs`. Consumers who install the npm package as a dependency can also import `@pazmo/ai-workflow-kit/src/graph/index.mjs`.
105
-
106
- `executeTaskGraph({ graph, runNode, evaluateNode, context, runState, maxConcurrency })` requires explicit evaluation results. Default concurrency is 1; a higher positive integer allows overlapping nodes marked `access: 'read'`. Writers and undeclared-access nodes run exclusively. A newly ready node starts as soon as a slot becomes available; joins wait only for their dependencies. `waves` records dispatch batches, not global barriers.
107
-
108
- Node input is `{ context, dependencies }`, copied to avoid shared mutation. Persisted states carry a graph fingerprint; changed plans and unknown/unevaluated statuses are rejected. Interrupted `running` nodes require an explicit `resetAffectedSubgraph` after checking external side effects. This in-process API does not persist checkpoints or approve gates; use the installed CLI for the durable host workflow.
109
-
110
- The generic API is not the delivery CLI's policy API. Choose the interface by its actual guarantees:
111
-
112
- | Responsibility | Generic API | Delivery CLI | Host |
113
- |---|---|---|---|
114
- | Dependency readiness, read concurrency, exclusive writers | Within one execution | Within one run | Isolate or serialize work across runs |
115
- | Attempts | Counts starts; no built-in cap | Maximum three starts per node | Enforce global time, cost and attempt budgets |
116
- | `human` / `replan` evaluation | Records the action; independent work can continue | Routes to the decision; no further start until resolved in a new run | Stop affected processes and obtain the decision |
117
- | Evidence and persistence | Returns state and explicit evaluation; no evidence-file checks or checkpoint store | Binds actual snapshots, runner receipts and evidence hashes; persists run changes | Judge assertion adequacy and external/environment boundaries |
118
- | User approval and tool permissions | Not provided | Checks approval records, not identity; does not intercept tools | Own actual approval events and execution permissions |
119
-
120
- Do not assume `executeTaskGraph` or `resetAffectedSubgraph` enforces the delivery CLI's retry or human-decision rules. Office integration must first identify its actual dispatch, storage, cancellation and result-application boundary. If it needs shared delivery transitions, extract only the necessary rules from the CLI when connecting that consumer; do not duplicate the rules in Office or invent an unused public API in advance.
121
-
122
- `access: 'read'` describes product-code access, not a filesystem sandbox. Review evidence and test-generated files may still require designated output paths. Host enforcement must distinguish these from product edits. Multiple developer processes alone do not provide safe parallel implementation: the host must manage workspace isolation, integration and verification of the combined result.
123
-
124
- `createPlanningGraph()` supplies `planner → review → validate-graph`. Planner/review callbacks return task graphs; the last node executes built-in deterministic validation rather than an LLM callback. Research and extra review roles are chosen for the work, not required by the graph.
3
+ Standard lane: [graph-minimal.md](graph-minimal.md). Custom plans, roles, the start/verify/record protocol and the API: [graph-advanced.md](graph-advanced.md).