lgtm-specs 0.0.7 → 0.0.8

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 (176) hide show
  1. package/AGENTS.md +9 -7
  2. package/README.md +19 -8
  3. package/VERSION +1 -1
  4. package/agents/README.md +11 -85
  5. package/agents/flows/README.md +19 -0
  6. package/agents/flows/audit/README.md +16 -0
  7. package/agents/flows/audit/build_consensus.md +9 -0
  8. package/agents/flows/audit/build_panel.md +7 -0
  9. package/agents/flows/audit/review_panel.md +7 -0
  10. package/agents/flows/audit/review_synthesize.md +8 -0
  11. package/agents/flows/build/README.md +15 -0
  12. package/agents/flows/build/delivery_production.md +7 -0
  13. package/agents/flows/build/delivery_prototype.md +7 -0
  14. package/agents/flows/build/execute_fast.md +9 -0
  15. package/agents/flows/build/execute_high_assurance.md +9 -0
  16. package/agents/flows/investigate/README.md +11 -0
  17. package/agents/flows/investigate/hooks.md +10 -0
  18. package/agents/flows/plan/README.md +13 -0
  19. package/agents/flows/plan/build.md +9 -0
  20. package/agents/flows/plan/hack.md +13 -0
  21. package/agents/flows/plan/review.md +10 -0
  22. package/agents/modes/README.md +5 -1
  23. package/agents/modes/build.md +64 -35
  24. package/agents/modes/hack.md +55 -33
  25. package/agents/modes/review.md +51 -26
  26. package/agents/roles/README.md +14 -0
  27. package/agents/roles/counsel/README.md +11 -0
  28. package/agents/roles/counsel/default.md +50 -0
  29. package/agents/roles/counsel/role.yaml +28 -0
  30. package/agents/roles/explorer/README.md +11 -0
  31. package/agents/roles/explorer/default.md +42 -0
  32. package/agents/roles/explorer/role.yaml +28 -0
  33. package/agents/roles/implementer/README.md +12 -0
  34. package/agents/roles/implementer/init.md +35 -0
  35. package/agents/roles/implementer/resolve.md +2 -0
  36. package/agents/roles/implementer/role.yaml +37 -0
  37. package/agents/roles/investigator/README.md +13 -0
  38. package/agents/roles/investigator/init.md +31 -0
  39. package/agents/roles/investigator/resolve.md +2 -0
  40. package/agents/roles/investigator/role.yaml +43 -0
  41. package/agents/roles/investigator/worker.md +41 -0
  42. package/agents/roles/lead/README.md +12 -0
  43. package/agents/roles/lead/arbitrator.md +33 -0
  44. package/agents/roles/lead/orchestrator.md +23 -0
  45. package/agents/roles/lead/role.yaml +36 -0
  46. package/agents/roles/librarian/README.md +11 -0
  47. package/agents/roles/librarian/default.md +39 -0
  48. package/agents/roles/librarian/role.yaml +28 -0
  49. package/agents/roles/planner/README.md +12 -0
  50. package/agents/roles/planner/init.md +36 -0
  51. package/agents/roles/planner/resolve.md +2 -0
  52. package/agents/roles/planner/role.yaml +36 -0
  53. package/agents/roles/reviewer/README.md +13 -42
  54. package/agents/roles/reviewer/auditor.md +31 -0
  55. package/agents/roles/reviewer/lite.md +39 -47
  56. package/agents/roles/reviewer/logic.md +33 -47
  57. package/agents/roles/reviewer/performance.md +31 -43
  58. package/agents/roles/reviewer/plan.md +34 -44
  59. package/agents/roles/reviewer/quality.md +36 -48
  60. package/agents/roles/reviewer/reassess.md +1 -0
  61. package/agents/roles/reviewer/role.yaml +85 -0
  62. package/agents/roles/reviewer/security.md +31 -45
  63. package/agents/roles/reviewer/test.md +34 -47
  64. package/agents/templates/README.md +3 -1
  65. package/agents/templates/flow.md +14 -0
  66. package/agents/templates/mode.md +59 -23
  67. package/agents/templates/role.md +82 -65
  68. package/docs/README.md +1 -1
  69. package/docs/adr/0005-agent-specialization.md +3 -3
  70. package/docs/adr/0007-operating-modes-and-gates.md +11 -7
  71. package/docs/adr/0009-modularizing-modes-into-reusable-flows.md +108 -87
  72. package/docs/adr/0010-hierarchical-stage-managers.md +731 -0
  73. package/docs/adr/0011-investigation-flow-fixed-five-panel.md +482 -0
  74. package/docs/adr/0012-roles-modes-flows-layered-architecture.md +243 -0
  75. package/docs/adr/0013-yaml-sidecar-contracts-for-agent-metadata.md +148 -0
  76. package/docs/adr/0014-roles-are-prompts-modes-flows-are-specs.md +110 -0
  77. package/docs/adr/0015-runtime-owned-state-manager-owned-stage-outcomes.md +215 -0
  78. package/docs/adr/0016-manager-centric-stage-profiles.md +181 -0
  79. package/docs/adr/README.md +22 -1
  80. package/docs/agent_architecture.md +50 -41
  81. package/docs/context_lifecycle.md +73 -46
  82. package/docs/contribute/add-agent.md +23 -21
  83. package/docs/contribute/checklist.md +7 -3
  84. package/docs/contribute/update-models.md +30 -60
  85. package/docs/contribute/verification.md +7 -2
  86. package/docs/engineering_principles.md +7 -0
  87. package/docs/meta/README.md +11 -0
  88. package/docs/meta/domains/git/01-workflow.md +1 -1
  89. package/docs/meta/languages/typescript/03-async.md +1 -1
  90. package/docs/meta/workflow.md +1 -1
  91. package/docs/philosophy.md +11 -2
  92. package/integrate/README.md +92 -64
  93. package/integrate/agent_builder.md +209 -150
  94. package/integrate/agent_schema.yaml +105 -0
  95. package/integrate/artifacts.md +275 -97
  96. package/integrate/context_injection.md +9 -1
  97. package/integrate/context_limits.md +49 -31
  98. package/integrate/counsel_contract.md +9 -13
  99. package/integrate/example_flow.md +121 -48
  100. package/integrate/implementation_reference.md +140 -0
  101. package/integrate/input_packets/README.md +19 -0
  102. package/integrate/input_packets/conventions.md +111 -0
  103. package/integrate/input_packets/core_packets.md +346 -0
  104. package/integrate/input_packets/investigation.md +287 -0
  105. package/integrate/input_packets/routing.md +53 -0
  106. package/integrate/input_packets/stage_decisions.md +258 -0
  107. package/integrate/input_packets.md +35 -173
  108. package/integrate/model_resolver.md +85 -27
  109. package/integrate/test_vectors/build/lead_orchestrator.md +33 -0
  110. package/integrate/test_vectors/fixtures/README.md +10 -0
  111. package/integrate/test_vectors/fixtures/mock_indices.md +1 -0
  112. package/integrate/test_vectors/fixtures/mock_injected_rules_full.md +29 -0
  113. package/integrate/test_vectors/fixtures/mock_injected_rules_trimmed.md +15 -0
  114. package/integrate/test_vectors/fixtures/mock_review_feedback.md +2 -0
  115. package/integrate/test_vectors/hack/lead_orchestrator.md +31 -0
  116. package/integrate/test_vectors/review/lead_orchestrator.md +31 -0
  117. package/integrate/test_vectors/shared/README.md +26 -0
  118. package/integrate/test_vectors/shared/counsel_default.md +52 -0
  119. package/integrate/test_vectors/shared/explorer_default.md +44 -0
  120. package/integrate/test_vectors/shared/implementer_init.md +65 -0
  121. package/integrate/test_vectors/shared/implementer_resolve.md +6 -0
  122. package/integrate/test_vectors/shared/investigator_init.md +33 -0
  123. package/integrate/test_vectors/shared/investigator_resolve.md +6 -0
  124. package/integrate/test_vectors/shared/investigator_worker.md +57 -0
  125. package/integrate/test_vectors/shared/lead_arbitrator.md +35 -0
  126. package/integrate/test_vectors/shared/librarian_default.md +41 -0
  127. package/integrate/test_vectors/shared/planner_init.md +52 -0
  128. package/integrate/test_vectors/shared/planner_resolve.md +6 -0
  129. package/integrate/test_vectors/shared/reviewer_auditor.md +33 -0
  130. package/integrate/test_vectors/shared/reviewer_lite.md +59 -0
  131. package/integrate/test_vectors/shared/reviewer_logic.md +56 -0
  132. package/integrate/test_vectors/shared/reviewer_performance.md +54 -0
  133. package/integrate/test_vectors/shared/reviewer_plan.md +58 -0
  134. package/integrate/test_vectors/shared/reviewer_quality.md +59 -0
  135. package/integrate/test_vectors/shared/reviewer_reassess.md +3 -0
  136. package/integrate/test_vectors/shared/reviewer_security.md +54 -0
  137. package/integrate/test_vectors/shared/reviewer_test.md +57 -0
  138. package/integrate/test_vectors.md +86 -0
  139. package/integrate/versioning.md +8 -8
  140. package/models/README.md +19 -68
  141. package/models/registry.yaml +6 -6
  142. package/package.json +7 -2
  143. package/rules/constitution/CONS-00027-transparency.md +9 -0
  144. package/rules/constitution/CONS-00032-documentation.md +8 -2
  145. package/rules/laws/go/GO-00017-comments.md +4 -1
  146. package/rules/laws/go/GO-00022-observability.md +6 -1
  147. package/rules/laws/go/GO-00023-dependency-management.md +1 -1
  148. package/rules/laws/typescript/TS-00003-async.md +1 -1
  149. package/rules/policies/default.md +7 -0
  150. package/scripts/README.md +49 -1
  151. package/scripts/compose_mode_workflow.py +144 -0
  152. package/scripts/generate_test_vectors.py +307 -0
  153. package/scripts/render_prompt.py +225 -0
  154. package/scripts/validate_specs.py +463 -53
  155. package/agents/modes/build/README.md +0 -11
  156. package/agents/modes/build/code.md +0 -43
  157. package/agents/modes/build/delivery.md +0 -9
  158. package/agents/modes/build/panel.md +0 -30
  159. package/agents/modes/build/panel_consensus.md +0 -71
  160. package/agents/modes/build/plan.md +0 -28
  161. package/agents/modes/hack/README.md +0 -9
  162. package/agents/modes/hack/code.md +0 -42
  163. package/agents/modes/hack/delivery.md +0 -6
  164. package/agents/modes/hack/plan.md +0 -29
  165. package/agents/modes/review/README.md +0 -9
  166. package/agents/modes/review/audit.md +0 -33
  167. package/agents/modes/review/plan.md +0 -24
  168. package/agents/modes/review/synthesize.md +0 -18
  169. package/agents/roles/counsel.md +0 -96
  170. package/agents/roles/explorer.md +0 -77
  171. package/agents/roles/implementer.md +0 -122
  172. package/agents/roles/lead.md +0 -122
  173. package/agents/roles/librarian.md +0 -63
  174. package/agents/roles/planner.md +0 -98
  175. package/agents/roles/reviewer/BASE.md +0 -10
  176. package/agents/roles/reviewer/OUTPUT_FORMAT.md +0 -17
package/AGENTS.md CHANGED
@@ -20,7 +20,7 @@ bun run check
20
20
  What this runs:
21
21
 
22
22
  ```bash
23
- # Validation (graph structure, indexing, capability registry, VERSION sync)
23
+ # Validation (graph structure, indexing, role contracts, VERSION sync)
24
24
  bun run validate
25
25
  # or:
26
26
  python3 scripts/validate_specs.py
@@ -113,6 +113,8 @@ Tags and writing:
113
113
  Indexing:
114
114
 
115
115
  - Every directory with content MUST have a `README.md` indexing its files.
116
+ - Exception: role prompt-chunk directories (`agents/roles/<role>/prompts/<profile>/`) may contain prompt templates
117
+ without a profile-local `README.md` when indexed by `agents/roles/<role>/README.md`.
116
118
  - Any new file must be added to the parent directory index `README.md`.
117
119
 
118
120
  ### 2.2 Agent Specs (`agents/**`)
@@ -120,12 +122,12 @@ Indexing:
120
122
  Contracts (external tools parse these; see `integrate/README.md`):
121
123
 
122
124
  - Do not remove placeholders like `{{injected_rules}}` / `{{indices}}`.
123
- - Modes require: `<Meta>`, `<Role>`, `<Workflow>`.
124
- - Roles require: `<Meta>`, `<Role>`, `<Input>`, `<Objective>`, `<OutputFormat>`, `<Workflow>`.
125
- - `<Meta>` key lines must start at column 1; role specs must include `Capability: <id>`.
126
- - `Capability` must exist as a key in `models/registry.yaml`.
127
-
128
- Valid capability IDs: `reasoning`, `coding`, `data`, `fast`, `security`, `docs`, `general`.
125
+ - Modes are pure Markdown specs (no role prompt section tags) and compose flows via `{{flow_*}}`.
126
+ - Roles are directory contracts: `agents/roles/<role>/role.yaml` + profile-scoped
127
+ `agents/roles/<role>/<profile>.md` (or `prompts/<profile>/*.md`) templates.
128
+ - Prompt templates are plain Markdown (no role prompt section tags).
129
+ - Role contracts must include `model_tier: critical|standard|economy`, profile `compose`/`allowed_injections`, and
130
+ optional profile `rule_render`/`rule_scope` per `integrate/agent_schema.yaml`.
129
131
 
130
132
  ### 2.3 Python Tooling (`scripts/**/*.py`)
131
133
 
package/README.md CHANGED
@@ -31,7 +31,9 @@ Start here:
31
31
  ## Workflows
32
32
 
33
33
  LGTM runs as operating modes that orchestrate a specialist team (Lead, Explorer, Counsel, Planner, Implementer,
34
- Reviewers).
34
+ Reviewer, Investigator).
35
+
36
+ Modes are thin entrypoints composed from reusable flow contracts under `agents/flows/**`.
35
37
 
36
38
  Modes:
37
39
 
@@ -41,12 +43,17 @@ Modes:
41
43
 
42
44
  Core roles:
43
45
 
44
- - 🧠 [Lead](agents/roles/lead.md): orchestrates and arbitrates.
45
- - 🗺️ [Explorer](agents/roles/explorer.md): maps the target repo.
46
- - ⚖️ [Counsel](agents/roles/counsel.md): selects minimal relevant rule paths.
47
- - 📐 [Planner](agents/roles/planner.md): produces an execution/audit plan.
48
- - 🏗️ [Implementer](agents/roles/implementer.md): implements and produces proof.
49
- - 🔬 [Reviewers](agents/roles/reviewer/README.md): audit from specialized perspectives.
46
+ - 🧠 [Lead (orchestrator profile)](agents/roles/lead/role.yaml): orchestrates workflows and synthesis.
47
+ - 🧭 [Lead (arbitrator profile)](agents/roles/lead/role.yaml): arbitrates disputed findings.
48
+ - 🗺️ [Explorer](agents/roles/explorer/role.yaml): maps the target repo.
49
+ - ⚖️ [Counsel](agents/roles/counsel/role.yaml): selects minimal relevant rule paths.
50
+ - 🗂️ [Planner](agents/roles/planner/role.yaml): owns plan-stage drafting, revisions, and planning decisions.
51
+ - 🧱 [Implementer](agents/roles/implementer/role.yaml): owns build-stage implementation, remediation, and decisions.
52
+ - 🛡️ [Reviewer (auditor + specialist lenses)](agents/roles/reviewer/README.md): runs panel gates,
53
+ report synthesis, and lens-based audits.
54
+ - 🔎 [Investigator](agents/roles/investigator/role.yaml): owns investigation-stage decisions and fixed-slot worker
55
+ analysis.
56
+ - 📚 [Librarian](agents/roles/librarian/role.yaml): optional external source lookup.
50
57
 
51
58
  Start here:
52
59
 
@@ -88,7 +95,11 @@ You are implementing integration for the LGTM specs repo (yyforyongyu/lgtm-specs
88
95
  Goal: wire this repo into a coding tool so it can run the LGTM agent workflows.
89
96
 
90
97
  Read and follow `integrate/README.md` exactly, including:
91
- - Parsing `agents/**/*.md` and honoring placeholders like `{{injected_rules}}`.
98
+ - Parsing role contracts under `agents/roles/**/role.yaml` and composing role prompts from
99
+ profile-scoped templates under `agents/roles/**/<profile>.md` (or `agents/roles/**/prompts/<profile>/*.md`), plus
100
+ composing mode contracts from `agents/modes/*.md`:
101
+ - inject `Lead Stage Contract` to `lead/orchestrator`,
102
+ - compose `Workflow Contract (Runtime Reference)` from `agents/flows/**` for runtime routing/policy.
92
103
  - Running Counsel and enforcing its JSON output schema.
93
104
  - Hydrating rule paths into rule content and injecting role-appropriate subsets per reviewer.
94
105
  - Resolving models using `models/registry.yaml` in list order (preference order) with deterministic availability checks.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
package/agents/README.md CHANGED
@@ -1,90 +1,16 @@
1
1
  # Agent Workforce
2
2
 
3
- This directory defines the LGTM agent contracts:
3
+ This directory contains LGTM agent specifications: invocable role contracts plus non-invocable mode/flow orchestration
4
+ specs. Treat this README as a top-level signpost and use subfolder indexes for details.
4
5
 
5
- - Modes (workflows): `@Build`, `@Hack`, `@Review`
6
- - Roles (workers): `@Lead`, `@Planner`, `@Counsel`, `@Implementer`, `@Explorer`, `@Librarian`, `@Reviewer*`
6
+ Current architecture uses a stage-owner model: `lead/orchestrator` delegates to stage-owner profiles
7
+ (`planner/init`, `implementer/init`, `reviewer/auditor`, `investigator/init`) while runtime owns transition mechanics.
8
+ For implementation contracts and routing matrices, start at `integrate/README.md`.
7
9
 
8
- Files under `agents/` are runtime-consumed contracts optimized for parsing and prompt injection.
9
- For a human-facing overview, see [Agent Architecture](../docs/agent_architecture.md).
10
+ ## Index
10
11
 
11
- ## Operating Modes
12
-
13
- - [@Build](modes/build.md): Production engineering; strict planning + verification + consensus gates.
14
- - [@Hack](modes/hack.md): Rapid prototyping; lighter gates; produce a draft branch/PR.
15
- - [@Review](modes/review.md): Read-only audit; produce an evidence-backed report.
16
-
17
- ## Roles
18
-
19
- - [@Lead](roles/lead.md): Orchestrator and arbitrator.
20
- - [@Planner](roles/planner.md): Execution/audit plan author.
21
- - [@Counsel](roles/counsel.md): Rule/policy selection (paths + reasons).
22
- - [@Explorer](roles/explorer.md): Codebase mapping and policy discovery (Context Map).
23
- - [@Implementer](roles/implementer.md): Implementation + required proof (inner loop).
24
- - [@Librarian](roles/librarian.md): External documentation/spec research with citations.
25
-
26
- ## Review Panel
27
-
28
- - [@Reviewer](roles/reviewer/README.md): Panel index (specialists).
29
- - [@Plan-Reviewer](roles/reviewer/plan.md): Plan critique (feasibility/alignment).
30
- - [@Reviewer-Lite](roles/reviewer/lite.md): Atomic diff sanity gate (fast).
31
- - [@Reviewer-Logic](roles/reviewer/logic.md): Correctness audit.
32
- - [@Reviewer-Quality](roles/reviewer/quality.md): Maintainability + docs audit.
33
- - [@Reviewer-Test](roles/reviewer/test.md): Test coverage + rigor audit.
34
- - [@Reviewer-Security](roles/reviewer/security.md): Trust boundary + safety audit.
35
- - [@Reviewer-Performance](roles/reviewer/performance.md): Efficiency + resource usage audit.
36
-
37
- ## Templates (For Maintainers)
38
-
39
- - Role template: [templates/role.md](templates/role.md)
40
- - Mode template: [templates/mode.md](templates/mode.md)
41
-
42
- ## Directory Structure
43
-
44
- ```text
45
- agents/
46
- ├── modes/
47
- │ ├── README.md
48
- │ ├── build.md
49
- │ ├── hack.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
68
- ├── templates/
69
- │ ├── README.md
70
- │ ├── role.md
71
- │ └── mode.md
72
- └── roles/
73
- ├── lead.md
74
- ├── planner.md
75
- ├── counsel.md
76
- ├── explorer.md
77
- ├── implementer.md
78
- ├── librarian.md
79
- └── reviewer/
80
- ├── BASE.md
81
- ├── OUTPUT_FORMAT.md
82
- ├── README.md
83
- ├── plan.md
84
- ├── lite.md
85
- ├── logic.md
86
- ├── quality.md
87
- ├── security.md
88
- ├── performance.md
89
- └── test.md
90
- ```
12
+ - [modes/README.md](modes/README.md)
13
+ - [flows/README.md](flows/README.md)
14
+ - [roles/README.md](roles/README.md)
15
+ - [templates/README.md](templates/README.md)
16
+ - [../integrate/README.md](../integrate/README.md)
@@ -0,0 +1,19 @@
1
+ # Reusable Flows
2
+
3
+ Non-invocable orchestration contracts composed by mode specs.
4
+
5
+ Flow contracts describe lead-visible stage transitions only (handoff -> expected outcome -> next decision).
6
+ Role behavior details and runtime mechanics stay authoritative in `agents/roles/**` and `integrate/**`.
7
+
8
+ Placeholder contract:
9
+
10
+ - `{{flow_<family>_<variant>}}` -> `agents/flows/<family>/<variant>.md`
11
+ - families: `plan`, `build`, `audit`, `investigate`
12
+
13
+ ## Index
14
+
15
+ - [plan/README.md](plan/README.md): planning flow contracts
16
+ - [build/README.md](build/README.md): implementation and delivery flow contracts
17
+ - [audit/README.md](audit/README.md): review-panel and synthesis flow contracts
18
+ - [investigate/README.md](investigate/README.md): shared investigation hook contracts
19
+ - [../roles/README.md](../roles/README.md): role/profile contract index
@@ -0,0 +1,16 @@
1
+ # Audit Flow Contracts
2
+
3
+ Panel/synthesis contracts keyed by `{{flow_audit_<variant>}}`.
4
+
5
+ These flows define lead-visible audit-stage handoffs to [@Reviewer](/agents/roles/reviewer/role.yaml),
6
+ plus synthesis/escalation decisions by [@Lead](/agents/roles/lead/role.yaml).
7
+
8
+ ## Index
9
+
10
+ - [build_panel.md](build_panel.md): build-mode full panel barrier
11
+ - [build_consensus.md](build_consensus.md): build-mode resolve/remediate consensus loop
12
+ - [review_panel.md](review_panel.md): review-mode panel execution
13
+ - [review_synthesize.md](review_synthesize.md): review-mode synthesis/reporting
14
+ - [/agents/roles/reviewer/README.md](/agents/roles/reviewer/README.md): reviewer role profiles
15
+ - [/agents/roles/implementer/README.md](/agents/roles/implementer/README.md): implementer role contract
16
+ - [/agents/roles/planner/README.md](/agents/roles/planner/README.md): planner role contract
@@ -0,0 +1,9 @@
1
+ ## Panel Consensus (Build)
2
+
3
+ Runtime delta over mode `Lead Stage Contract`:
4
+
5
+ 1. Interpret each audit-stage outcome into remediation dispatch, arbitration dispatch, or gate-close action.
6
+ 2. On remediation action, route to [@Implementer](/agents/roles/implementer/role.yaml) (`init`) then schedule the next
7
+ panel-audit pass.
8
+ 3. On dispute action, route to [@Lead](/agents/roles/lead/role.yaml) (`arbitrator`) then return to panel audit.
9
+ 4. Close gate only on explicit approval, allowed override, or terminal abort outcome.
@@ -0,0 +1,7 @@
1
+ ## Panel Audit (Build)
2
+
3
+ Runtime delta over mode `Lead Stage Contract`:
4
+
5
+ 1. Enforce panel round barrier before accepting audit-stage outcome payloads.
6
+ 2. Persist panel artifacts and accepted audit-stage decision payload for consensus routing.
7
+ 3. Carry scoped diff/context evidence refs forward for remediation and re-audit continuity.
@@ -0,0 +1,7 @@
1
+ ## Panel Audit (Review)
2
+
3
+ Runtime delta over mode `Lead Stage Contract`:
4
+
5
+ 1. Include approved audit-plan refs in reviewer/auditor packets when present.
6
+ 2. Enforce audit round barrier and persist panel artifacts before synthesis transition.
7
+ 3. If stage outcome escalates disputed findings, schedule arbitration before final synthesis.
@@ -0,0 +1,8 @@
1
+ ## Synthesize & Report (Review)
2
+
3
+ Runtime delta over mode `Lead Stage Contract`:
4
+
5
+ 1. Synthesis consumes persisted panel artifacts and finding-provenance mappings.
6
+ 2. Clarification pass is one bounded follow-up turn through [@Reviewer](/agents/roles/reviewer/role.yaml)
7
+ (`auditor`) before finalization.
8
+ 3. Final report output must include severity grouping, evidence references, and residual-risk notes.
@@ -0,0 +1,15 @@
1
+ # Build Flow Contracts
2
+
3
+ Implementation/delivery contracts keyed by `{{flow_build_<variant>}}`.
4
+
5
+ These flows define lead-visible build-stage handoffs to [@Implementer](/agents/roles/implementer/role.yaml),
6
+ escalation paths, and delivery closure expectations.
7
+
8
+ ## Index
9
+
10
+ - [execute_high_assurance.md](execute_high_assurance.md): `@Build` execution loop
11
+ - [execute_fast.md](execute_fast.md): `@Hack` fast execution loop
12
+ - [delivery_production.md](delivery_production.md): production delivery closure
13
+ - [delivery_prototype.md](delivery_prototype.md): prototype delivery closure
14
+ - [/agents/roles/implementer/README.md](/agents/roles/implementer/README.md): implementer role contract
15
+ - [/agents/roles/planner/README.md](/agents/roles/planner/README.md): planner role contract
@@ -0,0 +1,7 @@
1
+ ## Delivery
2
+
3
+ Runtime delta over mode `Lead Stage Contract`:
4
+
5
+ 1. Assemble delivery evidence from final stage outcomes, verification results, and approved/overridden findings.
6
+ 2. Finalize output only when gate-approval/allowed-override conditions are satisfied.
7
+ 3. If unresolved required rejects remain without allowed override, emit blocked status (not success).
@@ -0,0 +1,7 @@
1
+ ## Delivery
2
+
3
+ Runtime delta over mode `Lead Stage Contract`:
4
+
5
+ 1. Finalize as draft/experimental output and label it `Prototype / Not Production Ready`.
6
+ 2. Prefer explicit prototype signaling in branch/PR metadata (for example `[Hack]` / `[Prototype]`).
7
+ 3. Production graduation path requires rerun under `@Build` rather than silent direct merge.
@@ -0,0 +1,9 @@
1
+ ## Execute (Fast)
2
+
3
+ Runtime delta over mode `Lead Stage Contract`:
4
+
5
+ 1. Execute as lightweight task loop with direct-task or planned-task entries.
6
+ 2. Permit immediate remediation chaining from accepted build-stage outcomes without planner re-entry,
7
+ unless scope repair is explicitly required.
8
+ 3. Persist each accepted build-stage outcome before next dispatch.
9
+ 4. Route escalations to [@Lead](/agents/roles/lead/role.yaml) (`arbitrator`) and stop on terminal outcomes.
@@ -0,0 +1,9 @@
1
+ ## Execute (High Assurance)
2
+
3
+ Runtime delta over mode `Lead Stage Contract`:
4
+
5
+ 1. Execute as per-task loop: one build-stage packet per approved plan step/remediation unit.
6
+ 2. Persist each accepted build-stage outcome before dispatching the next task/remediation unit.
7
+ 3. If escalation is emitted, route to [@Lead](/agents/roles/lead/role.yaml) (`arbitrator`) and block further dispatch
8
+ until arbitration outcome is recorded.
9
+ 4. Stop loop on terminal abort/escalation outcomes; otherwise continue until no open tasks remain.
@@ -0,0 +1,11 @@
1
+ # Investigate Flow Contracts
2
+
3
+ Shared investigation contracts keyed by `{{flow_investigate_<variant>}}`.
4
+
5
+ Investigation stays stage-owner mediated: [@Investigator](/agents/roles/investigator/role.yaml) coordinates
6
+ analysis runs and returns stage outcomes under runtime transition policy.
7
+
8
+ ## Index
9
+
10
+ - [hooks.md](hooks.md): shared invocation/return constraints for investigation flow
11
+ - [/agents/roles/investigator/README.md](/agents/roles/investigator/README.md): investigator role profiles
@@ -0,0 +1,10 @@
1
+ ## Investigation Hooks (Shared Contract)
2
+
3
+ 1. Treat investigation as analysis-only and stage-owner mediated.
4
+ 2. [@Investigator](/agents/roles/investigator/role.yaml) (`init`) owns worker dispatch, synthesis, and return/terminal
5
+ stage outcome decisions.
6
+ 3. [@Investigator](/agents/roles/investigator/role.yaml) (`worker`) outputs analysis only
7
+ (`findings/hypotheses/options`), never final compliance verdicts.
8
+ 4. Transition-edge IDs, worker-slot configuration, invocation-source policy, and auto-edge policy are runtime
9
+ contracts in
10
+ `/integrate/input_packets/README.md` and `/integrate/README.md`.
@@ -0,0 +1,13 @@
1
+ # Plan Flow Contracts
2
+
3
+ Shared planning contracts keyed by `{{flow_plan_<variant>}}`.
4
+
5
+ These flows keep [@Lead](/agents/roles/lead/role.yaml) at cross-stage control and define plan-stage
6
+ handoff/outcome checkpoints via [@Planner](/agents/roles/planner/role.yaml).
7
+
8
+ ## Index
9
+
10
+ - [build.md](build.md): high-assurance plan flow for `@Build`
11
+ - [hack.md](hack.md): lightweight sketch flow for `@Hack`
12
+ - [review.md](review.md): audit planning flow for `@Review`
13
+ - [/agents/roles/planner/README.md](/agents/roles/planner/README.md): planner role contract
@@ -0,0 +1,9 @@
1
+ ## Clarify & Plan (Build)
2
+
3
+ Runtime delta over mode `Lead Stage Contract`:
4
+
5
+ 1. Plan sign-off gate is runtime-enforced before execution handoff.
6
+ 2. Waiver path requires persisted waiver rationale/residual-risk notes before routing to
7
+ [@Implementer](/agents/roles/implementer/role.yaml) (`init`).
8
+ 3. Planner outcomes map to transitions: `approve_plan -> execution`, `revise_plan -> planner continuation`,
9
+ `abort -> terminal`, escalation path -> [@Lead](/agents/roles/lead/role.yaml) (`arbitrator`).
@@ -0,0 +1,13 @@
1
+ ## Sketch (Hack)
2
+
3
+ Runtime delta over mode `Lead Stage Contract`:
4
+
5
+ 1. If critical-path scope is detected and the user still keeps `@Hack`, persist explicit risk acknowledgement.
6
+ 2. Planning remains optional at runtime: trivial scope can route directly to
7
+ [@Implementer](/agents/roles/implementer/role.yaml) (`init`), planned scope routes to
8
+ [@Planner](/agents/roles/planner/role.yaml) (`init`).
9
+ 3. Planned-path outcomes map to transitions: `approve_plan -> implementer/init`,
10
+ `revise_plan -> planner continuation`, `abort -> terminal`, escalation path ->
11
+ [@Lead](/agents/roles/lead/role.yaml) (`arbitrator`).
12
+ 4. If stricter compliance was requested, persist selected [@Counsel](/agents/roles/counsel/role.yaml)
13
+ rule-set references in runtime artifacts.
@@ -0,0 +1,10 @@
1
+ ## Map & Plan (Review)
2
+
3
+ Runtime delta over mode `Lead Stage Contract`:
4
+
5
+ 1. Runtime triage gate decides trivial fast-path (direct audit) vs planned path.
6
+ 2. Planned-path outcomes map to transitions: `approve_plan -> reviewer/auditor`,
7
+ `revise_plan -> planner continuation`, `abort -> terminal`, escalation path ->
8
+ [@Lead](/agents/roles/lead/role.yaml) (`arbitrator`).
9
+ 3. When routing to [@Reviewer](/agents/roles/reviewer/role.yaml) (`auditor`), attach approved audit-plan
10
+ references when available.
@@ -2,7 +2,11 @@
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>/`.
5
+ Each mode defines:
6
+
7
+ - `Lead Stage Contract`: compact lead-visible handoff/outcome map injected into `lead/orchestrator`.
8
+ - `Workflow Contract (Runtime Reference)`: runtime sequencing reference composed from non-invocable
9
+ flow contracts under `agents/flows/**` using `{{flow_<family>_<variant>}}` placeholders.
6
10
 
7
11
  ## Index
8
12
 
@@ -1,10 +1,15 @@
1
1
  # Mode: @Build
2
2
 
3
- <Meta>
4
- Type: High-Assurance Engineering Workflow.
5
- Brain: Uses **[@Lead](../roles/lead.md)** for arbitration and orchestration decisions.
3
+ ## Type
6
4
 
7
- Trigger:
5
+ High-Assurance Engineering Workflow.
6
+
7
+ ## Brain
8
+
9
+ Uses **[@Lead](../roles/lead/role.yaml)** with profile `orchestrator` for orchestration and profile `arbitrator` for
10
+ dispute rulings.
11
+
12
+ ## Trigger
8
13
 
9
14
  - New Feature implementation.
10
15
  - Refactoring critical paths (Auth, Payments, Cryptography).
@@ -13,52 +18,76 @@ Trigger:
13
18
  - "Production Ready" work.
14
19
  - (For rapid prototypes, use **[@Hack](hack.md)** instead).
15
20
 
16
- SafetyProfile:
21
+ ## Safety Profile
17
22
 
18
23
  - Strict gates (plan sign-off, verification, and panel review).
19
24
  - Overrides allowed only with explicit risk rationale.
20
25
 
21
- Team:
26
+ ## Coordination Model
27
+
28
+ - `@Lead` (`orchestrator`) owns cross-stage decomposition, stage-owner handoff, and final synthesis.
29
+ - Stage owners (`planner|implementer|reviewer/auditor|investigator`) own stage-local loops and decision payloads.
30
+ - `@Lead` (`arbitrator`) handles disputed findings/plan decisions escalated from stage loops.
31
+
32
+ ## Delegation Boundary
33
+
34
+ - `@Build` routes only across stage owners (`planner/init`, `implementer/init`, `reviewer/auditor`,
35
+ `investigator/init`).
36
+ - Stage-owner internals (worker choice, panel composition, remediation loops) stay in role contracts and runtime
37
+ packet policy.
22
38
 
23
- - **Manager**: **[@Lead](../roles/lead.md)**.
24
- - **Planner**: **[@Planner](../roles/planner.md)**.
25
- - **Compliance**: **[@Counsel](../roles/counsel.md)**.
26
- - **Researcher**: **[@Librarian](../roles/librarian.md)** (Optional).
27
- - **Maker**: **[@Implementer](../roles/implementer.md)**.
28
- - **Cartographer**: **[@Explorer](../roles/explorer.md)**.
29
- - **Plan Reviewer**: **[@Plan-Reviewer](../roles/reviewer/plan.md)**.
30
- - **Micro-Critic**: **[@Reviewer-Lite](../roles/reviewer/lite.md)**.
31
- - **Critics**: **[@Reviewer](../roles/reviewer/README.md)** (Panel).
32
- </Meta>
39
+ ## Goal
33
40
 
34
- <Role>
35
- **Goal**: Ship Features, Refactors, and Production Code.
36
- </Role>
41
+ Ship Features, Refactors, and Production Code.
42
+
43
+ ## Lead Stage Contract
44
+
45
+ 1. Scope with `@Explorer`; route rule selection/application through `@Counsel` when needed.
46
+ 2. Delegate planning to `planner/init`; expect `approve_plan|revise_plan|abort|escalate` stage outcomes.
47
+ 3. Require explicit user sign-off on approved plans unless the user explicitly waives review.
48
+ 4. Delegate each approved task/remediation unit to `implementer/init` and consume build-stage outcomes.
49
+ 5. Delegate the audit gate to `reviewer/auditor` and consume audit-stage outcomes.
50
+ 6. When audit returns actionable findings, route remediation to `implementer/init` and then re-enter audit.
51
+ 7. Route disputed findings/decisions to `lead/arbitrator` only when escalated by a stage outcome.
52
+ 8. Invoke `investigator/init` only when a stage outcome requests investigation under runtime transition policy.
53
+ 9. Finalize only on audit gate approval, explicit allowed override, or terminal abort.
54
+
55
+ ## Output Contract
37
56
 
38
- <OutputFormat>
39
57
  **Result**: Markdown with:
40
58
 
41
59
  - **PR/Commit**: PR URL or commit hash.
42
60
  - **Verification**: Commands run and outcomes.
43
61
  - **Notes**: Overrides/arbitrations (if any) and residual risk.
44
62
 
45
- </OutputFormat>
63
+ ## Workflow Contract (Runtime Reference)
64
+
65
+ Runtime-owned sequencing reference for packet routing and transition policy.
66
+ This section is not injected as lead model context.
67
+
68
+ Follow these flow contracts in order; each role emits only role-local decisions/artifacts.
69
+
70
+ {{flow_plan_build}}
71
+ {{flow_build_execute_high_assurance}}
72
+ {{flow_audit_build_panel}}
73
+ {{flow_audit_build_consensus}}
74
+ {{flow_investigate_hooks}}
75
+ {{flow_build_delivery_production}}
46
76
 
47
- <Workflow>
48
- {{flow_build_plan}}
49
- {{flow_build_code}}
50
- {{flow_build_panel}}
51
- {{flow_build_panel_consensus}}
52
- {{flow_build_delivery}}
77
+ ## Constraints
53
78
 
54
- </Workflow>
79
+ Mode-level constraints for lead and stage owners:
55
80
 
56
- <Constraints>
57
- **Hard Blocks**:
58
- - [ ] Do not proceed to Phase 2 until the Plan is explicitly approved by the user.
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`.
81
+ - [ ] Do not proceed to Phase 2 until the Plan is explicitly approved, unless the user explicitly waives review;
82
+ record waiver rationale before proceeding.
83
+ - [ ] Every code-producing implementer task MUST include explicit `Files` and `Verification`
84
+ (from the plan step or from `@Lead`/implementer remediation dispatch).
85
+ If either is missing, route to `planner/init` for repair/derivation.
86
+ - [ ] Assessment/disposition routing is owned by `implementer/init`; it may dispatch remediation without re-entering
87
+ a separate assessment role.
62
88
  - [ ] Never skip required verification.
89
+ - [ ] Reviewer packets SHOULD default to scoped `Diff`/`Context Snippets`; use `Diff Command` only as fallback.
63
90
  - [ ] Unanimous approval is required by default; any override MUST include an explicit risk rationale.
64
- </Constraints>
91
+ - [ ] Investigation flow is analysis-only. Implementation remains `implementer/init`; certification remains
92
+ reviewer/audit gates.
93
+ - [ ] Keep this mode contract stable; invocation-specific details belong in per-step context.