lgtm-specs 0.0.6 β†’ 0.0.7

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 (47) hide show
  1. package/README.md +3 -2
  2. package/VERSION +1 -1
  3. package/agents/README.md +21 -4
  4. package/agents/modes/README.md +2 -0
  5. package/agents/modes/build/README.md +11 -0
  6. package/agents/modes/build/code.md +43 -0
  7. package/agents/modes/build/delivery.md +9 -0
  8. package/agents/modes/build/panel.md +30 -0
  9. package/agents/modes/build/panel_consensus.md +71 -0
  10. package/agents/modes/build/plan.md +28 -0
  11. package/agents/modes/build.md +10 -123
  12. package/agents/modes/hack/README.md +9 -0
  13. package/agents/modes/hack/code.md +42 -0
  14. package/agents/modes/hack/delivery.md +6 -0
  15. package/agents/modes/hack/plan.md +29 -0
  16. package/agents/modes/hack.md +5 -63
  17. package/agents/modes/review/README.md +9 -0
  18. package/agents/modes/review/audit.md +33 -0
  19. package/agents/modes/review/plan.md +24 -0
  20. package/agents/modes/review/synthesize.md +18 -0
  21. package/agents/modes/review.md +6 -46
  22. package/agents/roles/{builder.md β†’ implementer.md} +44 -17
  23. package/agents/roles/lead.md +40 -13
  24. package/agents/roles/planner.md +37 -14
  25. package/agents/roles/reviewer/OUTPUT_FORMAT.md +11 -1
  26. package/agents/roles/reviewer/logic.md +7 -1
  27. package/agents/roles/reviewer/performance.md +5 -0
  28. package/agents/roles/reviewer/quality.md +9 -3
  29. package/agents/roles/reviewer/security.md +5 -0
  30. package/agents/roles/reviewer/test.md +7 -1
  31. package/docs/adr/0005-agent-specialization.md +7 -5
  32. package/docs/adr/0007-operating-modes-and-gates.md +5 -3
  33. package/docs/adr/0009-modularizing-modes-into-reusable-flows.md +545 -0
  34. package/docs/adr/README.md +1 -0
  35. package/docs/agent_architecture.md +33 -25
  36. package/docs/context_lifecycle.md +44 -21
  37. package/docs/meta/collaborative_dynamics.md +2 -2
  38. package/docs/meta/domains/git/02-commits.md +2 -1
  39. package/integrate/README.md +8 -2
  40. package/integrate/agent_builder.md +24 -3
  41. package/integrate/artifacts.md +176 -33
  42. package/integrate/context_limits.md +7 -7
  43. package/integrate/example_flow.md +41 -15
  44. package/integrate/input_packets.md +189 -0
  45. package/integrate/model_resolver.md +44 -0
  46. package/integrate/versioning.md +7 -7
  47. package/package.json +1 -1
package/README.md CHANGED
@@ -30,7 +30,8 @@ Start here:
30
30
 
31
31
  ## Workflows
32
32
 
33
- LGTM runs as operating modes that orchestrate a specialist team (Lead, Explorer, Counsel, Planner, Builder, Reviewers).
33
+ LGTM runs as operating modes that orchestrate a specialist team (Lead, Explorer, Counsel, Planner, Implementer,
34
+ Reviewers).
34
35
 
35
36
  Modes:
36
37
 
@@ -44,7 +45,7 @@ Core roles:
44
45
  - πŸ—ΊοΈ [Explorer](agents/roles/explorer.md): maps the target repo.
45
46
  - βš–οΈ [Counsel](agents/roles/counsel.md): selects minimal relevant rule paths.
46
47
  - πŸ“ [Planner](agents/roles/planner.md): produces an execution/audit plan.
47
- - πŸ—οΈ [Builder](agents/roles/builder.md): implements and produces proof.
48
+ - πŸ—οΈ [Implementer](agents/roles/implementer.md): implements and produces proof.
48
49
  - πŸ”¬ [Reviewers](agents/roles/reviewer/README.md): audit from specialized perspectives.
49
50
 
50
51
  Start here:
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
package/agents/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  This directory defines the LGTM agent contracts:
4
4
 
5
5
  - Modes (workflows): `@Build`, `@Hack`, `@Review`
6
- - Roles (workers): `@Lead`, `@Planner`, `@Counsel`, `@Builder`, `@Explorer`, `@Librarian`, `@Reviewer*`
6
+ - Roles (workers): `@Lead`, `@Planner`, `@Counsel`, `@Implementer`, `@Explorer`, `@Librarian`, `@Reviewer*`
7
7
 
8
8
  Files under `agents/` are runtime-consumed contracts optimized for parsing and prompt injection.
9
9
  For a human-facing overview, see [Agent Architecture](../docs/agent_architecture.md).
@@ -20,7 +20,7 @@ For a human-facing overview, see [Agent Architecture](../docs/agent_architecture
20
20
  - [@Planner](roles/planner.md): Execution/audit plan author.
21
21
  - [@Counsel](roles/counsel.md): Rule/policy selection (paths + reasons).
22
22
  - [@Explorer](roles/explorer.md): Codebase mapping and policy discovery (Context Map).
23
- - [@Builder](roles/builder.md): Implementation + required proof (inner loop).
23
+ - [@Implementer](roles/implementer.md): Implementation + required proof (inner loop).
24
24
  - [@Librarian](roles/librarian.md): External documentation/spec research with citations.
25
25
 
26
26
  ## Review Panel
@@ -47,7 +47,24 @@ agents/
47
47
  β”‚ β”œβ”€β”€ README.md
48
48
  β”‚ β”œβ”€β”€ build.md
49
49
  β”‚ β”œβ”€β”€ hack.md
50
- β”‚ └── review.md
50
+ β”‚ β”œβ”€β”€ review.md
51
+ β”‚ β”œβ”€β”€ build/
52
+ β”‚ β”‚ β”œβ”€β”€ README.md
53
+ β”‚ β”‚ β”œβ”€β”€ plan.md
54
+ β”‚ β”‚ β”œβ”€β”€ code.md
55
+ β”‚ β”‚ β”œβ”€β”€ panel.md
56
+ β”‚ β”‚ β”œβ”€β”€ panel_consensus.md
57
+ β”‚ β”‚ └── delivery.md
58
+ β”‚ β”œβ”€β”€ hack/
59
+ β”‚ β”‚ β”œβ”€β”€ README.md
60
+ β”‚ β”‚ β”œβ”€β”€ plan.md
61
+ β”‚ β”‚ β”œβ”€β”€ code.md
62
+ β”‚ β”‚ └── delivery.md
63
+ β”‚ └── review/
64
+ β”‚ β”œβ”€β”€ README.md
65
+ β”‚ β”œβ”€β”€ plan.md
66
+ β”‚ β”œβ”€β”€ audit.md
67
+ β”‚ └── synthesize.md
51
68
  β”œβ”€β”€ templates/
52
69
  β”‚ β”œβ”€β”€ README.md
53
70
  β”‚ β”œβ”€β”€ role.md
@@ -57,7 +74,7 @@ agents/
57
74
  β”œβ”€β”€ planner.md
58
75
  β”œβ”€β”€ counsel.md
59
76
  β”œβ”€β”€ explorer.md
60
- β”œβ”€β”€ builder.md
77
+ β”œβ”€β”€ implementer.md
61
78
  β”œβ”€β”€ librarian.md
62
79
  └── reviewer/
63
80
  β”œβ”€β”€ BASE.md
@@ -2,6 +2,8 @@
2
2
 
3
3
  Mode specs define the canonical orchestration workflows for the LGTM workforce.
4
4
 
5
+ Each mode may compose its `<Workflow>` from non-invocable fragments stored under `agents/modes/<mode>/`.
6
+
5
7
  ## Index
6
8
 
7
9
  - [@Build](build.md): High-assurance engineering workflow.
@@ -0,0 +1,11 @@
1
+ # @Build Fragments
2
+
3
+ Non-invocable workflow fragments composed by `agents/modes/build.md` via `{{flow_build_*}}` placeholders.
4
+
5
+ ## Index
6
+
7
+ - [plan.md](plan.md): Phase 1 (clarify, plan, sign-off)
8
+ - [code.md](code.md): Phase 2 (execute + lite gate)
9
+ - [panel.md](panel.md): Phase 3 (full panel barrier)
10
+ - [panel_consensus.md](panel_consensus.md): Phase 3 (resolve + remediate loop)
11
+ - [delivery.md](delivery.md): Phase 4 (squash + PR hygiene)
@@ -0,0 +1,43 @@
1
+ ## Execute (The Heavy Loop)
2
+
3
+ For each Task (Plan step or remediation task):
4
+
5
+ - Unit of work:
6
+ - The runtime MUST dispatch exactly one Task at a time.
7
+ - `@Implementer` MUST produce exactly one primary atomic commit for that Task.
8
+ - Review remediation MAY add fixup commit(s) targeting that primary commit (no additional Tasks).
9
+
10
+ - Optimization (optional): tools MAY reuse the same `@Implementer` session/thread across Tasks to reduce context cost.
11
+ This does not change the unit of work: one invocation = one Task = one primary atomic commit.
12
+
13
+ 1. **Build**: Call `@Implementer` with `(Task, Files, Requirements, Verification)`.
14
+ - _Constraint_: `Files` MUST be explicit in the Task definition (from the Plan step, or from `@Lead` when
15
+ dispatching remediation tasks). If missing, `@Lead` routes back to `@Planner` to repair/derive the file list.
16
+ - _Constraint_: Verification is mandatory. The proof level is defined per step (tests and/or other evidence).
17
+ - _Timeout_: 20 minutes per attempt (default; runtime may override).
18
+ - _On Timeout_: Re-assign once; if it times out again, treat as a reject and re-plan or abort.
19
+ 2. **Micro-Audit**: Call `@Reviewer-Lite` on the diff.
20
+ - _Scope_: Fast sanity gate (obvious correctness breakage + basic style/tooling + commit message). Deep specialist
21
+ review happens in Phase 3.
22
+ - _Input_: Provide `User Request` + (`Diff` or `Diff Command`).
23
+ Include `Base Ref` whenever the runtime has git metadata (e.g., PR merge target).
24
+ Include `Head Ref` when available.
25
+ Include the atomic `Commit Message` when available.
26
+ - _Gate_: One Lite decision per primary atomic commit.
27
+ - No Lite roundtrip.
28
+ - Fixup remediation does not trigger a new Lite decision.
29
+ - _Timeout_: 5 minutes per attempt.
30
+ - _On Timeout_: Re-assign once. If it still times out, `@Lead` must either abort or proceed with an explicit risk
31
+ rationale (record in artifacts).
32
+ - _On Reject_: The runtime records the Lite artifact and the commit SHA. `@Implementer` MUST respond with a
33
+ disposition for every finding in that Lite artifact (single assessment packet) using `finding_id` (`1..N` in the
34
+ injected findings packet) and a short rationale for any dispute.
35
+ - If all findings are `accept`: `@Implementer` fixes using fixup commits (target the original commit):
36
+ `git commit --fixup <sha>`.
37
+ - If any finding is `dispute`: `@Lead` arbitrates at that commit (no Lite roundtrip).
38
+ - The runtime MUST batch all disputed findings for the commit into the minimum number of arbitration packets to
39
+ `@Lead`, subject to context limits.
40
+ - `@Lead` returns a decision per `finding_id` (`uphold` -> Implementer fixes using fixup commits; `override` ->
41
+ explicit risk rationale).
42
+ - After all findings are resolved (fixed or overridden), proceed after required verification passes (no Lite
43
+ re-review).
@@ -0,0 +1,9 @@
1
+ ## Delivery
2
+
3
+ 1. **Squash (Runtime)**: `@Lead` instructs the runtime to consolidate history.
4
+ - Squash "fixup", "wip", or "address comments" commits into the relevant atomic feature commits.
5
+ - Ensure the final history reflects the _story_ of the change, not the _process_ of the review.
6
+ 2. **Finalize**: Produce the Production-Ready PR.
7
+ - **PR Hygiene**: Title/body explain intent, risks, and verification evidence; mark Draft vs Ready explicitly.
8
+ - **Merge Plan**: State merge strategy expectations (squash vs merge-commit vs rebase) per repo policy.
9
+ - **Last Check**: Re-run required verification before marking ready.
@@ -0,0 +1,30 @@
1
+ ## Panel Audit (The Jury)
2
+
3
+ 1. **Verify**: Ensure required verification passes (including integration tests when required).
4
+ 2. **Audit (Round 1: Full Panel)**: Call the **Full Review Panel** in parallel.
5
+ - Mandatory: [Logic](../../roles/reviewer/logic.md), [Quality](../../roles/reviewer/quality.md),
6
+ [Test](../../roles/reviewer/test.md).
7
+ - Conditional: [Security](../../roles/reviewer/security.md) when `@Lead` marks the work security-sensitive (or
8
+ `@Counsel` selected `#security` rules).
9
+ - Conditional: [Performance](../../roles/reviewer/performance.md) when `@Lead` marks the work perf-sensitive (or
10
+ `@Counsel` selected `#efficiency` rules).
11
+ - **Redundancy**: Run **N** independent invocations per Specialist role (default: 2; configurable).
12
+ - _Goal_: Reduce false negatives by auditing the same area multiple times.
13
+ - _Provider Diversity_: The runtime MUST attempt provider-first diversity across the redundant invocations.
14
+ - Provider is derived from the `model_id` prefix before `/`.
15
+ - For invocation 2+: exclude previously used providers; if not possible, exclude previously used `model_id`
16
+ values.
17
+ - If diversification is not possible, it MAY reuse the same model but MUST record this in artifacts.
18
+ - _Configuration (Optional)_: Tools MAY allow users to configure redundancy per role (e.g., `logic=2`,
19
+ `security=3`) and provider allow/deny lists.
20
+ - _Runtime Limits_: If the runtime cannot run the configured redundancy (resource/budget constraints), it MAY run
21
+ a single invocation per role but MUST:
22
+ - record `redundancy_mode=reduced` in artifacts, and
23
+ - surface the reduced-redundancy state in the final report.
24
+ - _Artifacts_: When any Specialist role is invoked redundantly (per-role invocation count > 1), the runtime MUST
25
+ record `redundancy_mode` and `diversity_result` on the panel timeline entry.
26
+ - _Input (each invocation)_: Provide `User Request` + (`Diff` or `Diff Command`).
27
+ Include `Base Ref` whenever the runtime has git metadata (e.g., PR merge target).
28
+ Include `Head Ref` when available.
29
+ - _Barrier_: The runtime MUST wait for all invoked reviewers to return (`lgtm` | `reject` | `timeout` | `error`) and
30
+ persist the round artifacts before any remediation begins.
@@ -0,0 +1,71 @@
1
+ ## Panel Consensus (Resolve + Remediate)
2
+
3
+ This flow assumes the panel audit barrier has completed (all invoked reviewers returned and round artifacts are
4
+ persisted).
5
+
6
+ 1. **Assess (After Barrier)**: If any reviewer status is not `lgtm`, call `@Implementer` to
7
+ produce a per-finding assessment.
8
+ - _Routing_: The runtime injects a **single consolidated** findings packet into `@Implementer` once per round.
9
+ `@Lead` is not in the high-bandwidth reviewer<->implementer loop except for arbitration and remediation dispatch.
10
+ - _Dedup (Recommended)_: Before invoking `@Implementer`, the runtime SHOULD deduplicate equivalent findings across
11
+ redundant invocations of the same Specialist role.
12
+ - Preserve provenance by retaining the underlying `finding_id` values.
13
+ - `@Implementer` MAY apply one disposition to a deduplicated group by using `finding_ids` in the assessment artifact.
14
+ - _Output_: Provide dispositions that cover every finding in the injected packet.
15
+ - Cite either `finding_id` (`1..N`) or a `finding_ids` group for a deduplicated set.
16
+ - The runtime MUST persist this assessment and use it to route disputes.
17
+ 2. **Dispute Routing (Targeted)**: For disputed findings, the runtime sends the finding(s) + Implementer rationale back
18
+ to the originating reviewer for one-step reassessment and records the outcome.
19
+ - _Batching (Required)_: The runtime MUST batch all disputed findings for the same originating reviewer invocation
20
+ into a single reassessment call.
21
+ - _Reviewer Response Contract_: The reviewer responds using the standard reviewer output format:
22
+ - `LGTM` withdraws all disputed findings in the reassessment packet.
23
+ - Otherwise, the reviewer outputs a top-level bullet list where each bullet starts with `<finding_id>:` and then
24
+ either `LGTM` (withdraw) or the maintained/revised finding text.
25
+ - If the reviewer does not withdraw and Implementer still disputes, the runtime MUST batch all still-contested
26
+ `finding_id` values for the round into the minimum number of arbitration packets to `@Lead`, subject to context
27
+ limits.
28
+ - Prefer a single packet when feasible.
29
+ - Use stable ordering by ascending `finding_id`.
30
+ - `@Lead` returns a decision per `finding_id`; the ruling is final for that finding and recorded.
31
+ 3. **Remediate**: `@Lead` converts accepted findings (and upheld disputes) into remediation Tasks.
32
+ - _Planner (Conditional)_: If remediation requires multi-step coordination or re-architecture, `@Lead` calls
33
+ `@Planner`; otherwise `@Lead` may dispatch Tasks directly to `@Implementer`.
34
+ - _Task Shape_: Every remediation Task MUST include explicit `Files` and `Verification`.
35
+ - If either is missing, `@Lead` MUST route to `@Planner` to repair/derive.
36
+ - Each remediation Task MUST complete Phase 2 (Build + Micro-Audit) before re-entering the panel. Micro-Audit is
37
+ complete only when: the Lite decision is recorded; any reject is resolved (fixed or arbitrated); and required
38
+ verification passes.
39
+ 4. **Re-Audit (Selective Rounds)**: Re-run only Specialist roles that still have open issues (most recent status !=
40
+ `lgtm`) and any newly-required specialists.
41
+ - _Role Status_: When a role has multiple reviewer invocations in the most recent round, treat the role as closed
42
+ only if **all** invocations for that role returned status `lgtm`.
43
+ - If any invocation is `reject|timeout|error`, treat the role as still open and re-run it.
44
+ - _Diff Scope_: Prefer incremental diffs since the previous panel round for selective rounds.
45
+ - _prev_head_: Use the `Head Ref` recorded in the previous panel timeline entry.
46
+ - _Redundancy_: When a Specialist role is re-run, apply the configured per-role redundancy count
47
+ (e.g., `logic=2`, `security=3`) unless the runtime is explicitly running in reduced-redundancy mode.
48
+ - If reduced redundancy is used, the runtime MUST record `redundancy_mode=reduced`.
49
+ 5. **Final Consensus (Full Panel)**: Once all selective reviewers have status `lgtm` and disputes are resolved, run a
50
+ final full panel round including every Specialist role invoked in any prior Phase 3 round
51
+ (Round 1 + any newly-added specialists).
52
+ - _Diff Scope_: Use the cumulative diff (`Base Ref...Head Ref`).
53
+ - If any reviewer rejects, repeat steps 1-5.
54
+ - _Invariant_: Phase 3 may only conclude immediately after a successful final full-panel round
55
+ (do not conclude after a selective round).
56
+ 6. **Gate**: Unanimous Approval Required.
57
+ - _Loop_: Max 10 panel rounds (selective + final both count).
58
+ - _Timeout_: 10 minutes per reviewer invocation per attempt.
59
+ - _On Timeout_: Re-assign each timed-out reviewer once. If it still times out, treat as a reject for that round.
60
+ - _Compress_: After each round, keep a compact "Resolved / Remaining" summary; do not carry full prior transcripts.
61
+ - _Deadlock Escape_:
62
+ - If the disputed finding-signature set is unchanged across 2 consecutive rounds, `@Lead` must either trigger
63
+ arbitration or abort.
64
+ - **Majority Consensus (Non-Critical)**: If the change is clearly non-critical-path (no Auth, Payments,
65
+ Cryptography/Secrets, DB schema, or Public API touch points per `@Explorer`), `@Lead` may accept majority
66
+ approval of the invoked panel, overriding strict unanimity with a risk rationale.
67
+ - _Override_: If needed, `@Lead` may override with an explicit risk rationale.
68
+ - _Guardrail_: If overriding a security- or test-related rejection, `@Lead` must surface the residual risk and get
69
+ explicit user acknowledgement.
70
+ - _After Max_: If still not unanimous after 10 panel rounds, `@Lead` must either abort (recommended)
71
+ or override with an explicit risk rationale.
@@ -0,0 +1,28 @@
1
+ ## Clarify & Plan (The Blueprint)
2
+
3
+ 1. **Orchestrate**: `@Lead` assesses the request and engages `@Explorer` to map the codebase.
4
+ 2. **Compliance**: `@Lead` consults `@Counsel` for Rules and Policies.
5
+ - **Policy (Always)**: The runtime resolves the active Policy (local policy if present; otherwise default) and
6
+ injects it into downstream agents. Policy rules are always active.
7
+ - **Inject (Dynamic)**: `@Lead` instructs the Runtime to load/hydrate rule content and inject
8
+ `{{injected_rules}}`.
9
+ - `@Planner`: plan-level rules/policies.
10
+ - `@Implementer`: step-scoped rules per Task (always include the active Policy rules).
11
+ - Reviewers: review-scope rules/policies for `@Plan-Reviewer`, `@Reviewer-Lite`, and the specialist panel.
12
+ 3. **Draft**: `@Planner` creates the **Execution Plan**.
13
+ - _Input_: User Request + Map + Rules.
14
+ - _Constraint_: The plan phase is task planning only.
15
+ - If an architecture decision is required, it MUST appear as an explicit Task (often an ADR update) to be executed
16
+ by `@Implementer` under the normal build loop.
17
+ 4. **Plan Review**: Call **two** independent `@Plan-Reviewer` instances.
18
+ - _Gate_: Must have unanimous approval to proceed.
19
+ - _Loop_: Max 3 revision cycles.
20
+ - _Timeout_: 5 minutes per reviewer per attempt (default; runtime may override).
21
+ - _On Timeout_: Re-assign each timed-out reviewer once. If it still times out, treat as a reject for that cycle.
22
+ - _On Reject_: `@Lead` digests reviewer feedback, decides legitimacy, and asks `@Planner` to revise the plan.
23
+ - Planner revisions SHOULD include a "Plan Review Response" with `accept|dispute` per finding.
24
+ - Plan review does not have dispute routing; disputed plan findings are resolved by `@Lead` arbitration/override.
25
+ - _After Max_: If still not unanimously approved after 3 cycles, `@Lead` must either abort (recommended) or
26
+ arbitrate/override by authoring a revised plan with an explicit risk rationale.
27
+ 5. **Gate**: Present Plan to User. **WAIT for Sign-off**.
28
+ - _Constraint_: Do not proceed to Build until Plan is explicitly approved.
@@ -21,10 +21,10 @@ SafetyProfile:
21
21
  Team:
22
22
 
23
23
  - **Manager**: **[@Lead](../roles/lead.md)**.
24
- - **Architect**: **[@Planner](../roles/planner.md)**.
24
+ - **Planner**: **[@Planner](../roles/planner.md)**.
25
25
  - **Compliance**: **[@Counsel](../roles/counsel.md)**.
26
26
  - **Researcher**: **[@Librarian](../roles/librarian.md)** (Optional).
27
- - **Maker**: **[@Builder](../roles/builder.md)**.
27
+ - **Maker**: **[@Implementer](../roles/implementer.md)**.
28
28
  - **Cartographer**: **[@Explorer](../roles/explorer.md)**.
29
29
  - **Plan Reviewer**: **[@Plan-Reviewer](../roles/reviewer/plan.md)**.
30
30
  - **Micro-Critic**: **[@Reviewer-Lite](../roles/reviewer/lite.md)**.
@@ -45,133 +45,20 @@ Team:
45
45
  </OutputFormat>
46
46
 
47
47
  <Workflow>
48
- ## Phase 1: Clarify & Design (The Blueprint)
49
- 1. **Orchestrate**: `@Lead` assesses the request and engages `@Explorer` to map the codebase.
50
- 2. **Compliance**: `@Lead` consults `@Counsel` for Rules and Policies.
51
- * **Policy (Always)**: The runtime resolves the active Policy (local policy if present; otherwise default) and
52
- injects it into downstream agents. Policy rules are always active.
53
- * **Inject (Dynamic)**: `@Lead` instructs the Runtime to load/hydrate rule content and inject
54
- `{{injected_rules}}`.
55
- - `@Planner`: plan-level rules/policies.
56
- - `@Builder`: step-scoped rules per Task (always include the active Policy rules).
57
- - Reviewers: review-scope rules/policies for `@Plan-Reviewer`, `@Reviewer-Lite`, and the specialist panel.
58
- 3. **Draft**: `@Planner` creates the **Execution Plan**.
59
- * *Input*: User Request + Map + Rules.
60
- 4. **Plan Review**: Call **two** independent `@Plan-Reviewer` instances.
61
- * *Gate*: Must have unanimous approval to proceed.
62
- * *Loop*: Max 3 revision cycles.
63
- * *Timeout*: 5 minutes per reviewer per attempt (default; runtime may override).
64
- * *On Timeout*: Re-assign each timed-out reviewer once. If it still times out, treat as a reject for that cycle.
65
- * *On Reject*: `@Lead` digests reviewer feedback, decides legitimacy, and asks `@Planner` to revise the plan.
66
- * *After Max*: If still not unanimously approved after 3 cycles, `@Lead` must either abort (recommended) or
67
- arbitrate/override by authoring a revised plan with an explicit risk rationale.
68
- 5. **Gate**: Present Plan to User. **WAIT for Sign-off**.
69
- * *Constraint*: Do not proceed to Build until Plan is explicitly approved.
70
-
71
- ## Phase 2: Execute (The Heavy Loop)
72
-
73
- For each Task in the Plan:
74
-
75
- 1. **Build**: Call `@Builder` with `(Task, Files, Requirements, Verification)`.
76
- - _Constraint_: `Files` MUST come from the Plan step. If missing, `@Lead` routes back to `@Planner` to repair the
77
- plan.
78
- - _Constraint_: Verification is mandatory. The proof level is defined per step (tests and/or other evidence).
79
- - _Timeout_: 20 minutes per attempt (default; runtime may override).
80
- - _On Timeout_: Re-assign once; if it times out again, treat as a reject and re-plan or abort.
81
- 2. **Micro-Audit**: Call `@Reviewer-Lite` on the diff.
82
- - _Scope_: Fast sanity gate (obvious correctness breakage + basic style/tooling + commit message). Deep specialist
83
- review happens in Phase 3.
84
- - _Input_: Provide `User Request` + (`Diff` or `Diff Command`).
85
- Include `Base Ref` whenever the runtime has git metadata (e.g., PR merge target).
86
- Include `Head Ref` when available.
87
- Include the atomic `Commit Message` when available.
88
- - _Gate_: One Lite decision per atomic commit (no Lite roundtrip).
89
- - _Timeout_: 5 minutes per attempt.
90
- - _On Timeout_: Re-assign once. If it still times out, `@Lead` must either abort or proceed with an explicit risk
91
- rationale (record in artifacts).
92
- - _On Reject_: The runtime records the Lite artifact and the commit SHA. `@Builder` MUST respond with a disposition
93
- per finding using `finding_id` (`<invocation_id>:<bullet_index>`) and a short rationale for any dispute.
94
- - `bullet_index` is the 1-based index of the top-level bullet in the stored reviewer artifact.
95
- - If all findings are `accept`: `@Builder` fixes by amending the same commit (`git commit --amend`) when the commit
96
- is not pushed/shared. If the commit is already pushed/shared, use fixup commits and squash later.
97
- - If any finding is `dispute`: `@Lead` arbitrates at that commit (no Lite roundtrip). `@Lead` either upholds the
98
- finding (Builder must fix using the same commit strategy: amend when not pushed/shared; otherwise fixup + squash)
99
- or overrides with an explicit risk rationale.
100
- - After all findings are resolved (fixed or overridden), proceed after required verification passes (no Lite
101
- re-review).
102
-
103
- ## Phase 3: Consensus (The Jury)
104
-
105
- 1. **Verify**: Ensure required verification passes (including integration tests when required).
106
- 2. **Audit (Round 1: Full Panel)**: Call the **Full Review Panel** in parallel.
107
- - Mandatory: [Logic](../roles/reviewer/logic.md), [Quality](../roles/reviewer/quality.md),
108
- [Test](../roles/reviewer/test.md).
109
- - Conditional: [Security](../roles/reviewer/security.md) when `@Lead` marks the work security-sensitive (or
110
- `@Counsel` selected `#security` rules).
111
- - Conditional: [Performance](../roles/reviewer/performance.md) when `@Lead` marks the work perf-sensitive (or
112
- `@Counsel` selected `#efficiency` rules).
113
- - _Input (each)_: Provide `User Request` + (`Diff` or `Diff Command`).
114
- Include `Base Ref` whenever the runtime has git metadata (e.g., PR merge target).
115
- Include `Head Ref` when available.
116
- - _Barrier_: The runtime MUST wait for all invoked reviewers to return (`LGTM` | `reject` | `timeout` | `error`) and
117
- persist the round artifacts before any remediation begins.
118
- 3. **Assess (After Barrier)**: After the barrier in Step 2, if any reviewer is not `LGTM`, call `@Builder` to produce a
119
- per-finding assessment.
120
- - _Output_: For each finding bullet, mark `accept` or `dispute`, citing `finding_id`
121
- (`<invocation_id>:<bullet_index>`).
122
- - `bullet_index` is the 1-based index of the top-level bullet in the stored reviewer artifact.
123
- - The runtime MUST persist this assessment and use it to route disputes.
124
- 4. **Dispute Routing (Targeted)**: For each disputed finding, the runtime sends the finding + Builder rationale back to
125
- the originating reviewer for one-step reassessment (`withdraw` | `maintain` | `revise`) and records the outcome.
126
- - If the reviewer maintains and Builder still disputes, `@Lead` arbitrates once; the ruling is final and recorded.
127
- 5. **Remediate**: `@Lead` converts accepted findings (and upheld disputes) into remediation Tasks.
128
- - _Planner (Conditional)_: If remediation requires multi-step coordination or re-architecture, `@Lead` calls
129
- `@Planner`; otherwise `@Lead` may dispatch Tasks directly to `@Builder`.
130
- - Each remediation Task MUST complete Phase 2 (Build + Micro-Audit) before re-entering the panel. Micro-Audit is
131
- complete only when: the Lite decision is recorded; any reject is resolved (fixed or arbitrated); and required
132
- verification passes.
133
- 6. **Re-Audit (Selective Rounds)**: Re-run only reviewers who still have open issues (most recent status != `LGTM`) and
134
- any newly-required specialists.
135
- - _Diff Scope_: Prefer incremental diffs since the previous panel round for selective rounds.
136
- - _prev_head_: Use the `Head Ref` recorded in the previous panel timeline entry.
137
- 7. **Final Consensus (Full Panel)**: Once all selective reviewers are `LGTM` and disputes are resolved, run a final full
138
- panel round including every reviewer invoked in any prior Phase 3 round (Round 1 + any newly-added specialists).
139
- - _Diff Scope_: Use the cumulative diff (`Base Ref...Head Ref`).
140
- - If any reviewer rejects, repeat steps 3-7.
141
- - _Invariant_: Phase 3 may only conclude immediately after a successful final full-panel round (do not conclude after
142
- a selective round).
143
- 8. **Gate**: Unanimous Approval Required.
144
- - _Loop_: Max 10 panel rounds (selective + final both count).
145
- - _Timeout_: 10 minutes per reviewer per attempt.
146
- - _On Timeout_: Re-assign each timed-out reviewer once. If it still times out, treat as a reject for that round.
147
- - _Compress_: After each round, keep a compact "Resolved / Remaining" summary; do not carry full prior transcripts.
148
- - _Deadlock Escape_:
149
- - If the panel stalls for 2 consecutive rounds, `@Lead` must either trigger arbitration or abort.
150
- - **Majority Consensus (Non-Critical)**: If the change is clearly non-critical-path (no Auth, Payments,
151
- Cryptography/Secrets, DB schema, or Public API touch points per `@Explorer`), `@Lead` may accept majority
152
- approval of the invoked panel, overriding strict unanimity with a risk rationale.
153
- - _Override_: If needed, `@Lead` may override with an explicit risk rationale.
154
- - _Guardrail_: If overriding a security- or test-related rejection, `@Lead` must surface the residual risk and get
155
- explicit user acknowledgement.
156
- - _After Max_: If still not unanimous after 10 panel rounds, `@Lead` must either abort (recommended) or override with
157
- an explicit risk rationale.
158
-
159
- ## Phase 4: Delivery
160
-
161
- 1. **Squash (Runtime)**: `@Lead` instructs the runtime to consolidate history.
162
- - Squash "fixup", "wip", or "address comments" commits into the relevant atomic feature commits.
163
- - Ensure the final history reflects the _story_ of the change, not the _process_ of the review.
164
- 2. **Finalize**: Produce the Production-Ready PR.
165
- - **PR Hygiene**: Title/body explain intent, risks, and verification evidence; mark Draft vs Ready explicitly.
166
- - **Merge Plan**: State merge strategy expectations (squash vs merge-commit vs rebase) per repo policy.
167
- - **Last Check**: Re-run required verification before marking ready.
48
+ {{flow_build_plan}}
49
+ {{flow_build_code}}
50
+ {{flow_build_panel}}
51
+ {{flow_build_panel_consensus}}
52
+ {{flow_build_delivery}}
168
53
 
169
54
  </Workflow>
170
55
 
171
56
  <Constraints>
172
57
  **Hard Blocks**:
173
58
  - [ ] Do not proceed to Phase 2 until the Plan is explicitly approved by the user.
174
- - [ ] Every `@Builder` task MUST include `Files` and `Verification` from the Plan (repair the plan if missing).
59
+ - [ ] Every code-producing `@Implementer` task MUST include explicit `Files` and `Verification` (from the Plan step or
60
+ from `@Lead` when dispatching remediation tasks). If either is missing, route to `@Planner` to repair/derive.
61
+ - Assessment-only Tasks (triage/disposition only) may omit `Files`/`Verification`.
175
62
  - [ ] Never skip required verification.
176
63
  - [ ] Unanimous approval is required by default; any override MUST include an explicit risk rationale.
177
64
  </Constraints>
@@ -0,0 +1,9 @@
1
+ # @Hack Fragments
2
+
3
+ Non-invocable workflow fragments composed by `agents/modes/hack.md` via `{{flow_hack_*}}` placeholders.
4
+
5
+ ## Index
6
+
7
+ - [plan.md](plan.md): Phase 1 (sketch)
8
+ - [code.md](code.md): Phase 2 (fast loop + lite gate)
9
+ - [delivery.md](delivery.md): Phase 3 (draft PR/branch)
@@ -0,0 +1,42 @@
1
+ ## Code (The Fast Loop)
2
+
3
+ For each Task (plan step or a single task when planning is skipped):
4
+
5
+ - Unit of work:
6
+ - The runtime MUST dispatch exactly one Task at a time.
7
+ - `@Implementer` MUST produce exactly one primary atomic commit for that Task.
8
+ - Review remediation MAY add fixup commit(s) targeting that primary commit (no additional Tasks).
9
+
10
+ - Optimization (optional): tools MAY reuse the same `@Implementer` session/thread across Tasks to reduce context cost.
11
+ This does not change the unit of work: one invocation = one Task = one primary atomic commit.
12
+
13
+ 1. **Build**: Call `@Implementer` with `(Task, Files, Requirements, Verification)`.
14
+ - _Constraint_: No mandatory TDD or Unit Tests in `@Hack`.
15
+ - _Note_: If the user requests tests, include them in the plan.
16
+ - _Timeout_: 15 minutes.
17
+ - _On Timeout_: Re-assign once; if it times out again, abort or invoke `@Planner` to split the task and retry.
18
+ 2. **Check**: Call `@Reviewer-Lite`.
19
+ - _Scope_: Release blockers only (obvious correctness breakage, basic style/tooling, commit message, docs/index).
20
+ - _Input_: Provide `User Request` + (`Diff` or `Diff Command`).
21
+ Include `Base Ref` whenever the runtime has git metadata (e.g., PR merge target).
22
+ Include `Head Ref` when available.
23
+ Include the atomic `Commit Message` when available.
24
+ - _Gate_: One Lite decision per primary atomic commit.
25
+ - No Lite roundtrip.
26
+ - Fixup remediation does not trigger a new Lite decision.
27
+ - _Timeout_: 5 minutes per attempt.
28
+ - _On Timeout_: Re-assign once. If it still times out, proceed as prototype or abort.
29
+ - _On Reject_: The runtime records the Lite artifact and the commit SHA. `@Implementer` MUST respond with a
30
+ disposition for every finding in that Lite artifact (single assessment packet) using `finding_id` (`1..N` in the
31
+ injected findings packet) and a short rationale for any dispute.
32
+ - If all findings are `accept`: `@Implementer` fixes using fixup commits (target the original commit):
33
+ `git commit --fixup <sha>`.
34
+ - If any finding is `dispute`: `@Lead` arbitrates immediately for that commit (no Lite roundtrip, no debate).
35
+ - The runtime MUST batch all disputed findings for the commit into the minimum number of arbitration packets to
36
+ `@Lead`, subject to context limits.
37
+ - `@Lead` returns a decision per `finding_id` (`uphold` -> fix; `override` -> proceed).
38
+ - If fix: Implementer uses fixup commits targeting that commit.
39
+ - After all findings are resolved (fixed or arbitrated), proceed.
40
+ - _Fail_: If still rejected, `@Lead` may proceed only when the remaining findings are strictly non-runtime-impacting
41
+ hygiene (commit message wording, docs/index, formatting) and the user explicitly accepts the residual risk (record
42
+ in artifacts). Otherwise abort or invoke `@Planner` to re-scope.
@@ -0,0 +1,6 @@
1
+ ## Delivery
2
+
3
+ - **Finalize**: Produce a Draft PR or Experimental Branch.
4
+ - **Note**: Explicitly label as "Prototype / Not Production Ready".
5
+ - Prefer a Draft PR and a title prefix like `[Hack]` or `[Prototype]`.
6
+ - **Graduation**: To ship as production code, rerun the work under `@Build` (do not merge a Hack prototype silently).
@@ -0,0 +1,29 @@
1
+ ## Sketch
2
+
3
+ 1. **Map**: `@Lead` engages `@Explorer` to identify likely touched files and risks.
4
+ 2. **Risk Gate (Advisory)**: If `@Explorer` indicates critical-path scope (Auth, Payments, Cryptography/Secrets, DB
5
+ schema, Public API), `@Lead` warns the user and recommends switching to `@Build`.
6
+ - _Constraint_: Do not auto-escalate or switch modes; run `@Hack` as selected.
7
+ 3. **Policy (Always)**: `@Lead` instructs the Runtime to resolve the active Policy (local policy if present; otherwise
8
+ default) and inject it into downstream agents.
9
+ 4. **Rules (Optional)**: If the user requests stricter compliance, `@Lead` consults `@Counsel` and instructs the Runtime
10
+ to load/hydrate selected rule content and inject `{{injected_rules}}`.
11
+ - `@Planner`: plan-level rules/policies.
12
+ - `@Plan-Reviewer`: review-scope rules/policies (when invoked).
13
+ - `@Implementer`: step-scoped rules per Task (always include the active Policy rules).
14
+ - `@Reviewer-Lite`: review-scope rules/policies.
15
+ 5. **Plan (Optional)**: `@Planner` creates a short "Sketch Plan" (atomic steps).
16
+ - Each step MUST include: Action, Files, Verification, and Requirements as rule IDs (may be empty).
17
+ - For trivial changes (single-file, low-risk), `@Lead` may skip `@Planner` and proceed with a single Implementer task.
18
+ - If skipping `@Planner`, `@Lead` MUST still provide `@Implementer` with `(Task, Files, Requirements, Verification)`.
19
+ - If `@Counsel` ran, `@Lead` MUST include all Counsel-selected rule IDs in `Requirements` for the single task.
20
+ - If the user requests plan review, do not skip `@Planner`.
21
+ 6. **Plan Review**: Optional (only when a Plan exists). `@Lead` may call `@Plan-Reviewer` (0-1) based on scope
22
+ (e.g., multi-step/multi-file) or if the user requests it.
23
+ - _Timeout (Default)_: 5 minutes per attempt (if called).
24
+ - _On Timeout_: Proceed without plan review.
25
+ - _On Reject_: `@Lead` digests feedback and asks `@Planner` to revise once.
26
+ - Planner revisions SHOULD include a "Plan Review Response" with `accept|dispute` per finding.
27
+ - Plan review does not have dispute routing; disputed plan findings are resolved by `@Lead` arbitration/override.
28
+ - Re-review: re-invoke the same `@Plan-Reviewer` once on the revised plan.
29
+ - If it still rejects, proceed as a prototype or abort.
@@ -29,8 +29,8 @@ Team:
29
29
  - **Cartographer**: **[@Explorer](../roles/explorer.md)**.
30
30
  - **Compliance**: **[@Counsel](../roles/counsel.md)** (Optional).
31
31
  - **Researcher**: **[@Librarian](../roles/librarian.md)** (Optional).
32
- - **Architect**: **[@Planner](../roles/planner.md)** (Optional; Sketch/Plan).
33
- - **Maker**: **[@Builder](../roles/builder.md)** (Fast Mode).
32
+ - **Planner**: **[@Planner](../roles/planner.md)** (Optional; Sketch/Plan).
33
+ - **Maker**: **[@Implementer](../roles/implementer.md)** (Fast Mode).
34
34
  - **Plan Reviewer**: **[@Plan-Reviewer](../roles/reviewer/plan.md)** (Optional).
35
35
  - **Critic**: **[@Reviewer-Lite](../roles/reviewer/lite.md)**.
36
36
  </Meta>
@@ -49,67 +49,9 @@ Team:
49
49
  </OutputFormat>
50
50
 
51
51
  <Workflow>
52
- ## Phase 1: Sketch
53
- 1. **Map**: `@Lead` engages `@Explorer` to identify likely touched files and risks.
54
- 2. **Risk Gate (Advisory)**: If `@Explorer` indicates critical-path scope (Auth, Payments, Cryptography/Secrets, DB
55
- schema, Public API), `@Lead` warns the user and recommends switching to `@Build`.
56
- - _Constraint_: Do not auto-escalate or switch modes; run `@Hack` as selected.
57
- 3. **Policy (Always)**: `@Lead` instructs the Runtime to resolve the active Policy (local policy if present; otherwise
58
- default) and inject it into downstream agents.
59
- 4. **Rules (Optional)**: If the user requests stricter compliance, `@Lead` consults `@Counsel` and instructs the Runtime
60
- to load/hydrate selected rule content and inject `{{injected_rules}}`.
61
- - `@Planner`: plan-level rules/policies.
62
- - `@Plan-Reviewer`: review-scope rules/policies (when invoked).
63
- - `@Builder`: step-scoped rules per Task (always include the active Policy rules).
64
- - `@Reviewer-Lite`: review-scope rules/policies.
65
- 5. **Plan (Optional)**: `@Planner` creates a short "Sketch Plan" (atomic steps).
66
- - Each step MUST include: Action, Files, Verification, and Requirements as rule IDs (may be empty).
67
- - For trivial changes (single-file, low-risk), `@Lead` may skip `@Planner` and proceed with a single Builder task.
68
- - If skipping `@Planner`, `@Lead` MUST still provide `@Builder` with `(Task, Files, Requirements, Verification)`.
69
- - If `@Counsel` ran, `@Lead` MUST include all Counsel-selected rule IDs in `Requirements` for the single task.
70
- - If the user requests plan review, do not skip `@Planner`.
71
- 6. **Plan Review**: Optional (only when a Plan exists). `@Lead` may call `@Plan-Reviewer` (0-1) based on scope
72
- (e.g., multi-step/multi-file) or if the user requests it.
73
- * *Timeout (Default)*: 5 minutes per attempt (if called).
74
- * *On Timeout*: Proceed without plan review.
75
- * *On Reject*: `@Lead` digests feedback and asks `@Planner` to revise once. If it still rejects, proceed as a
76
- prototype or abort.
77
-
78
- ## Phase 2: Code (The Fast Loop)
79
-
80
- 1. **Build**: Call `@Builder` with `(Task, Files, Requirements, Verification)`.
81
- - _Constraint_: No mandatory TDD or Unit Tests in `@Hack`.
82
- - _Note_: If the user requests tests, include them in the plan.
83
- - _Timeout_: 15 minutes.
84
- - _On Timeout_: Re-assign once; if it times out again, abort or invoke `@Planner` to split the task and retry.
85
- 2. **Check**: Call `@Reviewer-Lite`.
86
- - _Scope_: Release blockers only (obvious correctness breakage, basic style/tooling, commit message, docs/index).
87
- - _Input_: Provide `User Request` + (`Diff` or `Diff Command`).
88
- Include `Base Ref` whenever the runtime has git metadata (e.g., PR merge target).
89
- Include `Head Ref` when available.
90
- Include the atomic `Commit Message` when available.
91
- - _Gate_: One Lite decision per atomic commit (no Lite roundtrip).
92
- - _Timeout_: 5 minutes per attempt.
93
- - _On Timeout_: Re-assign once. If it still times out, proceed as prototype or abort.
94
- - _On Reject_: The runtime records the Lite artifact and the commit SHA. `@Builder` MUST respond with a disposition
95
- per finding using `finding_id` (`<invocation_id>:<bullet_index>`) and a short rationale for any dispute.
96
- - `bullet_index` is the 1-based index of the top-level bullet in the stored reviewer artifact.
97
- - If all findings are `accept`: `@Builder` fixes by amending the same commit (`git commit --amend`) when the commit
98
- is not pushed/shared. If the commit is already pushed/shared, use fixup commits and squash later.
99
- - If any finding is `dispute`: `@Lead` arbitrates immediately for that commit (no Lite roundtrip, no debate) and
100
- decides fix vs proceed.
101
- - If fix: Builder uses the same commit strategy (amend when not pushed/shared; otherwise fixup + squash later).
102
- - After all findings are resolved (fixed or arbitrated), proceed.
103
- - _Fail_: If still rejected, `@Lead` may proceed only when the remaining findings are strictly non-runtime-impacting
104
- hygiene (commit message wording, docs/index, formatting) and the user explicitly accepts the residual risk (record
105
- in artifacts). Otherwise abort or invoke `@Planner` to re-scope.
106
-
107
- ## Phase 3: Delivery
108
-
109
- - **Finalize**: Produce a Draft PR or Experimental Branch.
110
- - **Note**: Explicitly label as "Prototype / Not Production Ready".
111
- - Prefer a Draft PR and a title prefix like `[Hack]` or `[Prototype]`.
112
- - **Graduation**: To ship as production code, rerun the work under `@Build` (do not merge a Hack prototype silently).
52
+ {{flow_hack_plan}}
53
+ {{flow_hack_code}}
54
+ {{flow_hack_delivery}}
113
55
 
114
56
  </Workflow>
115
57
 
@@ -0,0 +1,9 @@
1
+ # @Review Fragments
2
+
3
+ Non-invocable workflow fragments composed by `agents/modes/review.md` via `{{flow_review_*}}` placeholders.
4
+
5
+ ## Index
6
+
7
+ - [plan.md](plan.md): Phases 1-2 (map + optional audit plan)
8
+ - [audit.md](audit.md): Phase 3 (panel audit barrier)
9
+ - [synthesize.md](synthesize.md): Phase 4 (synthesize + report)