lgtm-specs 0.0.4

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 (212) hide show
  1. package/.claude/settings.local.json +14 -0
  2. package/.gemini/README.md +8 -0
  3. package/.gemini/config.yaml +20 -0
  4. package/.gemini/styleguide.md +35 -0
  5. package/.github/workflows/README.md +5 -0
  6. package/.github/workflows/release.yml +52 -0
  7. package/.github/workflows/validate.yml +27 -0
  8. package/.prettierignore +4 -0
  9. package/.prettierrc +1 -0
  10. package/AGENTS.md +151 -0
  11. package/README.md +98 -0
  12. package/VERSION +1 -0
  13. package/agents/README.md +73 -0
  14. package/agents/modes/README.md +9 -0
  15. package/agents/modes/build.md +88 -0
  16. package/agents/modes/hack.md +76 -0
  17. package/agents/modes/review.md +79 -0
  18. package/agents/roles/builder.md +75 -0
  19. package/agents/roles/counsel.md +96 -0
  20. package/agents/roles/explorer.md +77 -0
  21. package/agents/roles/lead.md +76 -0
  22. package/agents/roles/librarian.md +63 -0
  23. package/agents/roles/planner.md +75 -0
  24. package/agents/roles/reviewer/BASE.md +9 -0
  25. package/agents/roles/reviewer/OUTPUT_FORMAT.md +4 -0
  26. package/agents/roles/reviewer/README.md +48 -0
  27. package/agents/roles/reviewer/lite.md +51 -0
  28. package/agents/roles/reviewer/logic.md +48 -0
  29. package/agents/roles/reviewer/performance.md +45 -0
  30. package/agents/roles/reviewer/plan.md +52 -0
  31. package/agents/roles/reviewer/quality.md +49 -0
  32. package/agents/roles/reviewer/security.md +47 -0
  33. package/agents/roles/reviewer/test.md +48 -0
  34. package/agents/templates/README.md +6 -0
  35. package/agents/templates/mode.md +33 -0
  36. package/agents/templates/role.md +73 -0
  37. package/contribute/README.md +24 -0
  38. package/contribute/add-agent.md +29 -0
  39. package/contribute/add-ci.md +31 -0
  40. package/contribute/add-constitution.md +17 -0
  41. package/contribute/add-law.md +20 -0
  42. package/contribute/add-policy.md +27 -0
  43. package/contribute/checklist.md +42 -0
  44. package/contribute/maintenance.md +19 -0
  45. package/contribute/update-models.md +47 -0
  46. package/docs/README.md +13 -0
  47. package/docs/adr/0001-knowledge-engineering-workflow.md +22 -0
  48. package/docs/adr/0002-rule-hierarchy.md +25 -0
  49. package/docs/adr/0003-atomic-knowledge-graph.md +21 -0
  50. package/docs/adr/0004-identification-schema.md +22 -0
  51. package/docs/adr/0005-agent-specialization.md +39 -0
  52. package/docs/adr/0006-git-workflow-integrity.md +34 -0
  53. package/docs/adr/0007-operating-modes-and-gates.md +54 -0
  54. package/docs/adr/0008-rules-vs-workflows-boundary.md +64 -0
  55. package/docs/adr/README.md +14 -0
  56. package/docs/agent_architecture.md +164 -0
  57. package/docs/context_lifecycle.md +228 -0
  58. package/docs/engineering_principles.md +128 -0
  59. package/docs/local_policies.md +59 -0
  60. package/docs/meta/collaborative_dynamics.md +142 -0
  61. package/docs/meta/domains/README.md +8 -0
  62. package/docs/meta/domains/bitcoin/01-units.md +21 -0
  63. package/docs/meta/domains/bitcoin/02-broadcast-cancellation.md +20 -0
  64. package/docs/meta/domains/bitcoin/03-fee-rates-rounding.md +21 -0
  65. package/docs/meta/domains/bitcoin/04-confirmations-reorgs.md +20 -0
  66. package/docs/meta/domains/bitcoin/05-address-gap-limit.md +16 -0
  67. package/docs/meta/domains/bitcoin/06-relay-policy.md +27 -0
  68. package/docs/meta/domains/bitcoin/README.md +12 -0
  69. package/docs/meta/domains/git/01-workflow.md +89 -0
  70. package/docs/meta/domains/git/02-commits.md +57 -0
  71. package/docs/meta/domains/git/03-collaboration.md +40 -0
  72. package/docs/meta/domains/git/04-integrity.md +26 -0
  73. package/docs/meta/domains/git/05-configuration.md +209 -0
  74. package/docs/meta/domains/git/06-advanced.md +130 -0
  75. package/docs/meta/domains/git/README.md +29 -0
  76. package/docs/meta/industry_best_practices.md +555 -0
  77. package/docs/meta/languages/README.md +8 -0
  78. package/docs/meta/languages/go/01-concurrency.md +37 -0
  79. package/docs/meta/languages/go/02-api-design.md +30 -0
  80. package/docs/meta/languages/go/03-resilience.md +27 -0
  81. package/docs/meta/languages/go/04-errors.md +27 -0
  82. package/docs/meta/languages/go/05-performance.md +18 -0
  83. package/docs/meta/languages/go/06-safety.md +18 -0
  84. package/docs/meta/languages/go/07-testing.md +44 -0
  85. package/docs/meta/languages/go/08-config-layout.md +23 -0
  86. package/docs/meta/languages/go/README.md +14 -0
  87. package/docs/meta/languages/typescript/01-strictness.md +19 -0
  88. package/docs/meta/languages/typescript/02-immutability.md +15 -0
  89. package/docs/meta/languages/typescript/03-async.md +18 -0
  90. package/docs/meta/languages/typescript/04-design.md +19 -0
  91. package/docs/meta/languages/typescript/05-control-flow.md +11 -0
  92. package/docs/meta/languages/typescript/README.md +11 -0
  93. package/docs/meta/workflow.md +68 -0
  94. package/docs/philosophy.md +36 -0
  95. package/integrate/README.md +459 -0
  96. package/integrate/versioning.md +41 -0
  97. package/models/README.md +68 -0
  98. package/models/registry.yaml +55 -0
  99. package/package.json +11 -0
  100. package/rules/README.md +57 -0
  101. package/rules/RULE-00000-EXAMPLE.md +29 -0
  102. package/rules/constitution/CONS-00001-srp.md +40 -0
  103. package/rules/constitution/CONS-00002-ocp.md +43 -0
  104. package/rules/constitution/CONS-00003-lsp.md +44 -0
  105. package/rules/constitution/CONS-00004-isp.md +46 -0
  106. package/rules/constitution/CONS-00005-dip.md +37 -0
  107. package/rules/constitution/CONS-00006-dry.md +45 -0
  108. package/rules/constitution/CONS-00007-demeter.md +35 -0
  109. package/rules/constitution/CONS-00008-composition.md +44 -0
  110. package/rules/constitution/CONS-00009-deep-modules.md +39 -0
  111. package/rules/constitution/CONS-00010-kiss.md +47 -0
  112. package/rules/constitution/CONS-00011-yagni.md +49 -0
  113. package/rules/constitution/CONS-00012-cognitive-limits.md +28 -0
  114. package/rules/constitution/CONS-00013-boy-scout.md +27 -0
  115. package/rules/constitution/CONS-00014-broken-windows.md +35 -0
  116. package/rules/constitution/CONS-00015-safety.md +46 -0
  117. package/rules/constitution/CONS-00016-cqs.md +39 -0
  118. package/rules/constitution/CONS-00017-postel.md +35 -0
  119. package/rules/constitution/CONS-00018-cap.md +35 -0
  120. package/rules/constitution/CONS-00019-fallacies.md +37 -0
  121. package/rules/constitution/CONS-00020-shift-left.md +28 -0
  122. package/rules/constitution/CONS-00021-congruence.md +28 -0
  123. package/rules/constitution/CONS-00022-orthogonality.md +40 -0
  124. package/rules/constitution/CONS-00023-determinism.md +38 -0
  125. package/rules/constitution/CONS-00024-security.md +42 -0
  126. package/rules/constitution/CONS-00025-efficiency.md +38 -0
  127. package/rules/constitution/CONS-00026-resilience.md +41 -0
  128. package/rules/constitution/CONS-00027-transparency.md +40 -0
  129. package/rules/constitution/CONS-00028-evolvability.md +36 -0
  130. package/rules/constitution/CONS-00029-operability.md +36 -0
  131. package/rules/constitution/CONS-00030-rework-cycle.md +27 -0
  132. package/rules/constitution/CONS-00031-checklist.md +28 -0
  133. package/rules/constitution/CONS-00032-documentation.md +39 -0
  134. package/rules/constitution/README.md +52 -0
  135. package/rules/laws/README.md +15 -0
  136. package/rules/laws/bitcoin/BTC-00001-amounts-as-satoshis.md +39 -0
  137. package/rules/laws/bitcoin/BTC-00002-broadcast-not-cancelable.md +36 -0
  138. package/rules/laws/bitcoin/BTC-00003-fee-rate-math-rounding.md +37 -0
  139. package/rules/laws/bitcoin/BTC-00004-confirmations-and-reorgs.md +40 -0
  140. package/rules/laws/bitcoin/BTC-00005-address-gap-limit.md +37 -0
  141. package/rules/laws/bitcoin/BTC-00006-relay-is-policy-dependent.md +36 -0
  142. package/rules/laws/bitcoin/BTC-00007-dust-policy.md +36 -0
  143. package/rules/laws/bitcoin/BTC-00008-min-relay-fee.md +36 -0
  144. package/rules/laws/bitcoin/BTC-00009-feefilter.md +36 -0
  145. package/rules/laws/bitcoin/README.md +29 -0
  146. package/rules/laws/default.md +30 -0
  147. package/rules/laws/git/GIT-00001-atomic-commit.md +29 -0
  148. package/rules/laws/git/GIT-00002-imperative-subject.md +27 -0
  149. package/rules/laws/git/GIT-00003-formatting-50-72.md +28 -0
  150. package/rules/laws/git/GIT-00004-trunk-based.md +28 -0
  151. package/rules/laws/git/GIT-00005-public-immutability.md +26 -0
  152. package/rules/laws/git/GIT-00006-signing.md +27 -0
  153. package/rules/laws/git/GIT-00007-reviewer-capital.md +26 -0
  154. package/rules/laws/git/GIT-00008-patch-series.md +28 -0
  155. package/rules/laws/git/GIT-00009-branch-naming.md +28 -0
  156. package/rules/laws/git/GIT-00010-pr-hygiene.md +51 -0
  157. package/rules/laws/git/GIT-00011-merge-method.md +35 -0
  158. package/rules/laws/git/GIT-00012-conflict-resolution.md +35 -0
  159. package/rules/laws/git/GIT-00013-ignore-standards.md +38 -0
  160. package/rules/laws/git/GIT-00014-lfs-large-binaries.md +37 -0
  161. package/rules/laws/git/GIT-00015-git-hooks.md +35 -0
  162. package/rules/laws/git/GIT-00016-branch-protection.md +34 -0
  163. package/rules/laws/git/GIT-00017-secrets-management.md +34 -0
  164. package/rules/laws/git/GIT-00018-ci-enforcement.md +33 -0
  165. package/rules/laws/git/GIT-00019-review-checklist.md +39 -0
  166. package/rules/laws/git/GIT-00020-issue-references.md +34 -0
  167. package/rules/laws/git/GIT-00021-partial-staging.md +38 -0
  168. package/rules/laws/git/GIT-00022-feature-flags.md +33 -0
  169. package/rules/laws/git/GIT-00023-breaking-changes.md +41 -0
  170. package/rules/laws/git/GIT-00024-dependency-management.md +44 -0
  171. package/rules/laws/git/GIT-00025-large-repository-optimization.md +54 -0
  172. package/rules/laws/git/README.md +31 -0
  173. package/rules/laws/go/GO-00001-actor-model.md +51 -0
  174. package/rules/laws/go/GO-00002-api-design.md +37 -0
  175. package/rules/laws/go/GO-00003-error-handling.md +43 -0
  176. package/rules/laws/go/GO-00004-context.md +45 -0
  177. package/rules/laws/go/GO-00005-performance.md +40 -0
  178. package/rules/laws/go/GO-00006-packages.md +29 -0
  179. package/rules/laws/go/GO-00007-circuit-breakers.md +43 -0
  180. package/rules/laws/go/GO-00008-safety.md +39 -0
  181. package/rules/laws/go/GO-00009-table-driven-test.md +48 -0
  182. package/rules/laws/go/GO-00010-escape-analysis.md +37 -0
  183. package/rules/laws/go/GO-00011-retry.md +45 -0
  184. package/rules/laws/go/GO-00012-rate-limiting.md +42 -0
  185. package/rules/laws/go/GO-00013-io-buffering.md +43 -0
  186. package/rules/laws/go/GO-00014-memory-layout.md +41 -0
  187. package/rules/laws/go/GO-00015-aaa-pattern.md +49 -0
  188. package/rules/laws/go/GO-00016-test-libraries.md +35 -0
  189. package/rules/laws/go/GO-00017-comments.md +37 -0
  190. package/rules/laws/go/GO-00018-test-isolation.md +38 -0
  191. package/rules/laws/go/GO-00019-test-comments.md +36 -0
  192. package/rules/laws/go/GO-00020-mocking.md +36 -0
  193. package/rules/laws/go/GO-00021-configuration.md +36 -0
  194. package/rules/laws/go/GO-00022-observability.md +34 -0
  195. package/rules/laws/go/GO-00023-dependency-management.md +28 -0
  196. package/rules/laws/go/GO-00024-project-layout.md +30 -0
  197. package/rules/laws/go/GO-00025-concurrency-patterns.md +39 -0
  198. package/rules/laws/go/README.md +45 -0
  199. package/rules/laws/typescript/README.md +14 -0
  200. package/rules/laws/typescript/TS-00001-no-any.md +39 -0
  201. package/rules/laws/typescript/TS-00002-immutability.md +36 -0
  202. package/rules/laws/typescript/TS-00003-async.md +35 -0
  203. package/rules/laws/typescript/TS-00004-strict-null.md +38 -0
  204. package/rules/laws/typescript/TS-00005-unions.md +35 -0
  205. package/rules/laws/typescript/TS-00006-interface.md +38 -0
  206. package/rules/laws/typescript/TS-00007-generics.md +38 -0
  207. package/rules/laws/typescript/TS-00008-modules.md +28 -0
  208. package/rules/policies/README.md +12 -0
  209. package/rules/policies/default.md +28 -0
  210. package/scripts/README.md +45 -0
  211. package/scripts/generate_release_notes.py +376 -0
  212. package/scripts/validate_specs.py +730 -0
package/docs/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # Docs
2
+
3
+ This directory contains human-facing documentation that explains the design and sources behind the LGTM knowledge graph.
4
+
5
+ ## Index
6
+
7
+ - [Agent Architecture](agent_architecture.md): Workforce philosophy, roles, and mode diagrams.
8
+ - [Context Lifecycle](context_lifecycle.md): Context artifacts, prompt construction, and injection flow.
9
+ - [Local Policies](local_policies.md): Consumer-repo policy layout and generation prompts.
10
+ - [Engineering Principles](engineering_principles.md): Quality dimensions and first principles.
11
+ - [Philosophy](philosophy.md): Project principles and framing.
12
+ - [Meta (Languages)](meta/languages/README.md): Source material used to derive Laws.
13
+ - [ADRs](adr/README.md): Architectural decisions.
@@ -0,0 +1,22 @@
1
+ # 1. The Knowledge Engineering Workflow
2
+
3
+ Date: 2026-01-30
4
+ Status: Accepted
5
+
6
+ ## Context
7
+
8
+ Standard AI "Knowledge Bases" are often hallucinations—collections of vague, unverified text that models ignore or misinterpret. To build a "Senior Engineer" agent, we need Ground Truth that is factually correct and intellectually rigorous.
9
+
10
+ ## Decision
11
+
12
+ We adopt a strict **Knowledge Engineering Workflow** (Research -> Synthesis -> Codification).
13
+
14
+ 1. **Research First**: No rule is written without citation. We verify primary sources (papers, books) before synthesis.
15
+ 2. **Adversarial Review**: We explicitly critique our own drafts for overlaps and gaps.
16
+ 3. **No Magic**: We reject "common wisdom" if it cannot be defined mechanistically.
17
+
18
+ ## Consequences
19
+
20
+ - **High Latency**: The Research phase is time-intensive. We prioritize depth over breadth.
21
+ - **High Authority**: Agents can cite sources ("According to Conway's Law...") with confidence.
22
+ - **Traceability**: Every rule links back to its intellectual lineage.
@@ -0,0 +1,25 @@
1
+ # 2. The Rule Hierarchy
2
+
3
+ Date: 2026-01-30
4
+ Status: Accepted
5
+
6
+ ## Context
7
+
8
+ Engineering rules vary in scope. "Don't use global state" is universal. "Don't use `any`" is TypeScript-specific. "Use 2 spaces" is repo-specific. Flattening these confuses the agent context.
9
+
10
+ ## Decision
11
+
12
+ We implement a three-tier hierarchy:
13
+
14
+ 1. **Constitution (Universal)**: Immutable truths derived from Systems Theory and Computer Science. (Prefix: `CONS`).
15
+ 2. **Laws (Domain)**: Technology-specific implementations of the Constitution. (Prefix: `TS`, `GO`, `GIT`).
16
+ 3. **Policies (Project)**: Local configuration and preferences.
17
+
18
+ ## Consequences
19
+
20
+ - **Separation of Concerns**: We can update Universal Rules without breaking specific Language Rules.
21
+ - **Context Efficiency**: A Python agent loads `Constitution + Python Laws`, ignoring `TypeScript Laws`.
22
+
23
+ ## Notes
24
+
25
+ This ADR defines the hierarchy only. Domain-specific operational policies (e.g., Git merge strategy and commit signing) belong in their own ADRs and meta docs (e.g., `docs/adr/0006-git-workflow-integrity.md`, `docs/meta/domains/git/`).
@@ -0,0 +1,21 @@
1
+ # 3. The Atomic Knowledge Graph (Zettelkasten)
2
+
3
+ Date: 2026-01-30
4
+ Status: Accepted
5
+
6
+ ## Context
7
+
8
+ LLMs suffer from "Lost in the Middle" phenomenon when fed massive markdown files. Monolithic docs make it hard to inject precise context (e.g., "Only tell me about Safety").
9
+
10
+ ## Decision
11
+
12
+ We adopt a **Zettelkasten** architecture.
13
+
14
+ 1. **Atomicity**: One Rule = One File.
15
+ 2. **Connectivity**: Files reference each other via `Related` links, forming a graph.
16
+ 3. **Machine-First**: The structure is optimized for Retrieval Augmented Generation (RAG). The Metadata header allows precise filtering.
17
+
18
+ ## Consequences
19
+
20
+ - **File Explosion**: We will have hundreds of small files.
21
+ - **High Precision**: We can inject exactly `CONS-00015` and `CONS-00020` into a prompt, maximizing token efficiency and attention.
@@ -0,0 +1,22 @@
1
+ # 4. The Identification Schema
2
+
3
+ Date: 2026-01-30
4
+ Status: Accepted
5
+
6
+ ## Context
7
+
8
+ We need a stable, scalable way to reference rules. Names change ("Simplicity" -> "Parsimony"), but references must persist.
9
+
10
+ ## Decision
11
+
12
+ We use a **5-digit ID Schema** with semantic prefixes.
13
+
14
+ - Format: `[PREFIX]-[00000]-[slug].md`
15
+ - Example: `CONS-00001-srp.md`
16
+ - Capacity: 99,999 rules per category.
17
+
18
+ ## Consequences
19
+
20
+ - **Scalability**: Sufficient for any foreseeable future.
21
+ - **Sortability**: Files sort logically on the filesystem.
22
+ - **Stability**: Renaming a file's "slug" does not break the ID linkage (though text links need updates).
@@ -0,0 +1,39 @@
1
+ # 5. Context-Aware Agent Specialization
2
+
3
+ Date: 2026-01-30
4
+ Status: Accepted
5
+
6
+ ## Context
7
+
8
+ Standard coding agents suffer from two failures: "Context Overload" (loading 100 pages of rules) and "Implementation Myopia" (writing code without verifying it works).
9
+
10
+ ## Decision
11
+
12
+ We adopt a specialized **Engineering Team Architecture** based on **Dynamic Injection** and **Role Verification**.
13
+
14
+ ### 1. Dynamic Context Injection
15
+
16
+ - **Agnosticism**: Worker agents (`@Builder`, `@Reviewer`) do NOT have hardcoded access to the Knowledge Graph.
17
+ - **Injection**: The `@Lead` (via `@Counsel`) selects a minimal subset of relevant rules and instructs the Runtime to
18
+ hydrate and inject rule content into the worker's prompt.
19
+ - **Benefit**: This maximizes token efficiency and attention. The agent focuses on the specific constraints of the task.
20
+
21
+ ### 2. The "Senior Builder" Pattern
22
+
23
+ - **Responsibility**: The `@Builder` agent is responsible for the entire "Inner Loop": Implementation AND Verification.
24
+ - **Requirement**: A task is not done until it is coded _and_ proven (via Unit/Integration tests). We do not have a separate "Prover" agent that cleans up after the Builder.
25
+
26
+ ### 3. The "Review Panel" Pattern
27
+
28
+ - **Adversarial Audit**: We treat code review as a multi-perspective consensus process.
29
+ - **Specialization**: Instead of one general reviewer, we invoke specialized personas based on the task context:
30
+ - `@Reviewer-Logic`: Correctness & Soundness.
31
+ - `@Reviewer-Quality`: Maintainability & Standards.
32
+ - `@Reviewer-Test`: Test quality & Coverage.
33
+ - `@Reviewer-Security`: (Conditional) Vulnerability audit.
34
+ - `@Reviewer-Performance`: (Conditional) Efficiency audit.
35
+
36
+ ## Consequences
37
+
38
+ - **Higher Quality**: Code is verified twice (by Builder, then by Panel).
39
+ - **Focused Execution**: Agents only see what they need to know.
@@ -0,0 +1,34 @@
1
+ # 6. Git Workflow & Integrity Policy
2
+
3
+ Date: 2026-02-03
4
+ Status: Accepted
5
+
6
+ ## Context
7
+
8
+ Git is the backbone of collaboration for LGTM agents and humans. Without a single, explicit policy, teams drift between merge strategies and integrity practices, which makes audit, rollback, and incident response unreliable.
9
+
10
+ Git hosting platforms (e.g., GitHub) expose multiple merge methods, and local history rewriting is easy. We need to define what is allowed on `main` and what is allowed on feature branches.
11
+
12
+ ## Decision
13
+
14
+ We adopt the following Git workflow and integrity policy for repositories managed by LGTM agents:
15
+
16
+ 1. **Trunk-Based Workflow**: `main` is the only long-lived branch. Work happens on short-lived feature branches.
17
+ 2. **Merge Strategy (Main)**: Changes land on `main` via merge commits. We preserve the commit series rather than flattening it.
18
+ - Disable squash merging and rebase merging on the hosting platform, unless the repository’s local policy
19
+ (`.lgtm/policies/README.md`) explicitly permits them.
20
+ - Never rebase `main`.
21
+ 3. **Rebase Strategy (Feature Branches)**: Feature branches may be rebased onto `main` to keep their history reviewable.
22
+ - Rebase only branches you own (no one else has pulled).
23
+ - If a rebased branch was already pushed, update it with `git push --force-with-lease`.
24
+ 4. **History Integrity**: Never force-push shared branches (`main`).
25
+ 5. **Cryptographic Identity**: Commits on `main` must be signed (GPG or SSH). Feature branch commits must be signed.
26
+ - Enforce via branch protection: require signed commits on `main`.
27
+ 6. **Automation**: Local Git hooks are allowed as fast feedback, but CI is the authoritative gate for merges.
28
+
29
+ ## Consequences
30
+
31
+ - **Auditability**: `main` retains the full patch series for each change, improving review quality, reverts, and `git bisect`.
32
+ - **Non-Linear History**: `main` history will not be perfectly linear (merge commits are expected).
33
+ - **Operational Discipline**: Feature-branch rebases require care (ownership rules, `--force-with-lease`).
34
+ - **Setup Cost**: Requiring signatures increases developer setup overhead, but improves authorship verification and supply-chain integrity.
@@ -0,0 +1,54 @@
1
+ # ADR-0007: Operating Modes and Safety Gates
2
+
3
+ Date: 2026-02-04
4
+ Status: Accepted
5
+
6
+ ## Context
7
+
8
+ The LGTM system defines specialized Roles (Lead/Planner/Counsel/Builder/Reviewer/etc.) and top-level Operating Modes (`@Build`, `@Hack`, `@Review`).
9
+
10
+ We observed spec drift and ambiguity when orchestration rules were duplicated across:
11
+
12
+ - Mode specs (`agents/modes/*.md`)
13
+ - Role specs (especially `agents/roles/lead.md`)
14
+ - Narrative docs ([docs/agent_architecture.md](../agent_architecture.md))
15
+
16
+ We also need a principled policy for when a user requests `@Hack` on critical paths.
17
+
18
+ ## Decision
19
+
20
+ ### 1) Source of truth
21
+
22
+ - **Mode specs** (`agents/modes/build.md`, `agents/modes/hack.md`, `agents/modes/review.md`) are the canonical orchestration definitions.
23
+ - **Role specs** (`agents/roles/**`) define contracts (inputs/outputs/constraints) and selection logic, but must not redefine full end-to-end orchestration.
24
+ - **Architecture docs** ([docs/agent_architecture.md](../agent_architecture.md)) explain roles and workflows and link to canonical mode/role specs.
25
+
26
+ ### 2) Hack on critical paths
27
+
28
+ If the user selects `@Hack`, the system must not override the mode.
29
+
30
+ There is no automatic escalation within Hack. If the user chooses this mode, the workflow runs as-is.
31
+
32
+ ### 3) Planning is default-on
33
+
34
+ `@Planner` runs by default in all modes:
35
+
36
+ - In `@Build` and `@Hack`, it produces an execution plan.
37
+ - In `@Review`, it produces an audit plan.
38
+
39
+ Exception:
40
+
41
+ - In `@Review`, tools MAY skip planning for trivial, low-risk diffs (after generated-file exclusion) and proceed directly
42
+ to audit using a default specialist set.
43
+
44
+ ### 4) Plan review count is mode-dependent
45
+
46
+ - `@Build`: two independent plan reviewers.
47
+ - `@Hack`: 0-1 plan reviewers based on risk and scope.
48
+ - `@Review`: at least 1 plan reviewer when planning runs.
49
+
50
+ ## Consequences
51
+
52
+ - Reduced spec drift by clearly assigning ownership.
53
+ - Maintains user mode intent without automatic escalation in `@Hack`.
54
+ - Keeps worker agents agnostic: reviewers do not retrieve rules; they receive injected requirements.
@@ -0,0 +1,64 @@
1
+ # ADR-0008: Rules vs Workflows Boundary
2
+
3
+ Date: 2026-02-10
4
+ Status: Accepted
5
+
6
+ ## Context
7
+
8
+ This repository contains two kinds of specifications that can look similar at a glance:
9
+
10
+ - Atomic rules in `rules/**` (Constitution/Laws/Policies)
11
+ - Procedural workflows in `agents/**` (Modes and Roles)
12
+
13
+ During review, we observed drift risk when:
14
+
15
+ - normative engineering requirements were written into role workflows (bypassing `@Counsel` selection), and
16
+ - orchestration/tooling details were written into atomic rules (polluting the Zettelkasten).
17
+
18
+ We need a crisp boundary so contributors know where new knowledge belongs.
19
+
20
+ ## Decision
21
+
22
+ We define three layers with distinct responsibilities.
23
+
24
+ ### 1) Atomic Rules (`rules/**`): "What must be true"
25
+
26
+ Atomic rules are normative constraints that can be selected and injected dynamically.
27
+
28
+ - Content: `## Definition`, `## Requirements`, `## Anti-Patterns`, `## Examples`
29
+ - Properties: stable, reusable, domain-scoped via tags, source-cited via `docs/meta/**`
30
+ - Usage: selected by `@Counsel` and injected into downstream agents via `{{injected_rules}}`
31
+
32
+ Rule of thumb:
33
+
34
+ - If it is a timeless principle you would want to cite independently, it is a rule.
35
+ - If it needs a source, tags, and examples to avoid ambiguity, it is a rule.
36
+
37
+ ### 2) Role Specs (`agents/roles/**`): "How this worker operates"
38
+
39
+ Role specs are procedural prompt contracts for a single worker.
40
+
41
+ - Content: inputs, outputs, workflow steps, boundaries, and how to apply injected rules
42
+ - Properties: role-specific, tool-agnostic where possible, minimal heuristics as fallback
43
+
44
+ Role workflows MUST NOT embed broad normative guidance that should be injected as rules.
45
+ If a role needs a norm (e.g., "tests should document the scenario"), that norm should live in `rules/**` and be injected.
46
+
47
+ Role workflows MAY include:
48
+
49
+ - ordering constraints (e.g., "load diff via Diff Command when Diff is omitted")
50
+ - output contracts (format, evidence requirements)
51
+ - focus boundaries (what to ignore)
52
+
53
+ ### 3) Mode Specs (`agents/modes/**`): "How roles are orchestrated"
54
+
55
+ Mode specs define end-to-end orchestration: which roles run, gates/loops, escalation/arbitration, and delivery.
56
+
57
+ - Canonical orchestration lives in mode specs.
58
+ - Roles must not redefine mode orchestration.
59
+
60
+ ## Consequences
61
+
62
+ - Reduced drift: norms live in one place (`rules/**`) and are injected selectively.
63
+ - Cleaner prompts: role specs stay procedural; rules stay normative.
64
+ - Better tooling: integration can shape inputs per role (diff scoping, rule filtering) without rewriting principles.
@@ -0,0 +1,14 @@
1
+ # Architecture Decision Records (ADR)
2
+
3
+ This directory documents the meta-architectural decisions for the `lgtm-specs` repository.
4
+
5
+ ## Index
6
+
7
+ - [ADR-0001: The Knowledge Engineering Workflow](0001-knowledge-engineering-workflow.md)
8
+ - [ADR-0002: The Rule Hierarchy](0002-rule-hierarchy.md)
9
+ - [ADR-0003: The Atomic Knowledge Graph (Zettelkasten)](0003-atomic-knowledge-graph.md)
10
+ - [ADR-0004: The Identification Schema](0004-identification-schema.md)
11
+ - [ADR-0005: Context-Aware Agent Specialization](0005-agent-specialization.md)
12
+ - [ADR-0006: Git Workflow & Integrity Policy](0006-git-workflow-integrity.md)
13
+ - [ADR-0007: Operating Modes and Safety Gates](0007-operating-modes-and-gates.md)
14
+ - [ADR-0008: Rules vs Workflows Boundary](0008-rules-vs-workflows-boundary.md)
@@ -0,0 +1,164 @@
1
+ # Agent Architecture
2
+
3
+ This document defines the **Cognitive Architecture** and **Organizational Structure** of the LGTM autonomous workforce. It is derived from the principles of [Collaborative Dynamics](meta/collaborative_dynamics.md).
4
+
5
+ ---
6
+
7
+ # 1. Philosophy: Agents as Staff Engineers
8
+
9
+ We do not build "Chatbots" that respond to prompts. We build **Autonomous Engineers** that execute workflows.
10
+
11
+ - **Role-Based**: Agents have distinct identities, responsibilities, and constraints.
12
+ - **Context-Aware**: Agents do not load the entire universe. They receive precise, dynamically injected context relevant to their immediate task.
13
+ - **Adversarial**: Quality is achieved through consensus, not individual brilliance. Builders build; Reviewers critique.
14
+
15
+ ---
16
+
17
+ # 2. The Professional Engineering Team
18
+
19
+ We organize agents into a high-performance **Engineering Team** optimized for velocity and rigor.
20
+
21
+ | Badge | Role | Capability | Responsibility |
22
+ | :---- | :------------ | :--------- | :---------------------------------------------------------------------------------------------------------- |
23
+ | 🧠 | **Lead** | reasoning | **Orchestrator**. Analyzes requests, consults Counsel, decomposes tasks, and manages the lifecycle. |
24
+ | 🗺️ | **Planner** | reasoning | **Architect**. Designs the execution plan or audit plan. |
25
+ | ⚖️ | **Counsel** | data | **Legal**. Retrieval system that selects the correct Laws/Rules for the context. |
26
+ | 🔨 | **Builder** | coding | **Maker**. Implements the code and the required proof (tests and/or other evidence). Owns the "Inner Loop." |
27
+ | 🔍 | **Explorer** | fast | **Cartographer**. Maps the codebase structure and finds existing patterns. |
28
+ | 📚 | **Librarian** | docs | **Researcher**. External knowledge and library references. |
29
+ | 👮 | **Reviewer** | reasoning | **Gatekeeper**. A panel of specialists who audit code against specific rules. |
30
+
31
+ Notes:
32
+
33
+ - The Review Panel includes sub-roles with different capabilities (e.g., `reviewer/lite` uses `fast`, `reviewer/security` uses `security`).
34
+
35
+ ---
36
+
37
+ # 3. Core Dynamics
38
+
39
+ ## 3.1 Dynamic Context Injection
40
+
41
+ Agents are **Agnostic**. They do not know domain- or language-specific rules (or repo-local policies) by default.
42
+
43
+ 1. **Lead** calls **Counsel** to scan the Knowledge Graph indices.
44
+ 2. **Counsel** selects specific atomic rules (e.g., `GO-00001`, `CONS-00015`).
45
+ 3. **Lead** instructs the **Runtime** to retrieve/hydrate rule content and inject it into the **Planner**, **Builder**,
46
+ and any **Reviewers** invoked by the selected Mode.
47
+
48
+ - **Benefit**: Maximizes token efficiency and attention focus.
49
+
50
+ ## 3.2 The Consensus Protocol
51
+
52
+ Code is never accepted on the first draft.
53
+
54
+ - **Plan Gate (Build)**: Execution plans are reviewed by two independent plan reviewers.
55
+ - **Micro-Review**: Every atomic commit is audited by the **Reviewer-Lite** (Fast Track).
56
+ - **Panel Gate (Build)**: The final PR is audited by the specialist **Review Panel** (Deep Track).
57
+ - **Veto Power**: If _any_ Reviewer rejects the change, the Builder enters a **Self-Correction Loop**.
58
+
59
+ ## 3.3 The "Senior Builder" Pattern
60
+
61
+ We do not use a separate "QA" agent to clean up messes.
62
+
63
+ - **Ownership**: The Builder is responsible for **Proving** their code works.
64
+ - **Requirement**: In `@Build`, tasks are incomplete without the required proof (often unit tests). In `@Hack`, tests are optional.
65
+
66
+ ---
67
+
68
+ # 4. The Workflows (Operating Modes)
69
+
70
+ LGTM exposes three top-level workflows ("Agents" / Modes). Each Mode orchestrates the Roles.
71
+
72
+ Note: The diagrams below are illustrative. The canonical workflow definitions and loop limits live in `agents/modes/*.md`.
73
+
74
+ ## 4.1 @Build (Production)
75
+
76
+ - **Goal**: High-assurance changes.
77
+ - **Properties**: Plan sign-off gate, two plan reviewers, micro-review on each atomic diff, full review panel before delivery.
78
+ - **Spec**: [`agents/modes/build.md`](../agents/modes/build.md)
79
+
80
+ ```mermaid
81
+ flowchart TD
82
+ U[User Request] --> L[Lead]
83
+ L --> E[Explorer]
84
+ E --> L
85
+ L --> C[Counsel]
86
+ C --> L
87
+ L --> P[Planner]
88
+
89
+ P --> PR1[Plan Reviewer 1]
90
+ P --> PR2[Plan Reviewer 2]
91
+ PR1 --> G1{Plan Approved}
92
+ PR2 --> G1
93
+ G1 -->|no| P
94
+ G1 -->|yes| UG[User Signoff]
95
+
96
+ UG --> B[Builder]
97
+ B --> RL[Reviewer Lite]
98
+ RL -->|reject| B
99
+ RL -->|pass| NEXT{More tasks?}
100
+ NEXT -->|yes| B
101
+ NEXT -->|no| PANEL[Review Panel]
102
+ PANEL -->|reject| B
103
+ PANEL -->|approve| DONE[Deliver PR]
104
+ PANEL -->|deadlock| ARB[Lead Arbitration]
105
+ ```
106
+
107
+ ## 4.2 @Hack (Prototype)
108
+
109
+ - **Goal**: Rapid experiments and lightweight changes.
110
+ - **Properties**: Sketch plan (`@Planner`) with optional plan review; micro-review on atomic diffs.
111
+ - **Critical Paths**: Hack remains allowed. No automatic escalation.
112
+ - **Spec**: [`agents/modes/hack.md`](../agents/modes/hack.md)
113
+
114
+ ```mermaid
115
+ flowchart TD
116
+ U[User Request] --> L[Lead]
117
+ L --> E[Explorer]
118
+ E --> L
119
+ L -->|optional| C[Counsel]
120
+ C --> L
121
+ L --> P[Planner]
122
+ P -->|optional| PR[Plan Reviewer]
123
+ PR -->|revise| P
124
+ PR -->|approve| B[Builder]
125
+ P -->|skip| B
126
+ B --> RL[Reviewer Lite]
127
+ RL -->|reject| B
128
+ RL -->|approve| DONE[Draft Branch]
129
+ ```
130
+
131
+ ## 4.3 @Review (Audit)
132
+
133
+ - **Goal**: Read-only critique and analysis.
134
+ - **Properties**: Default-on planning (`@Planner`) with a trivial-diff exception; plan review when planning runs; inject rules
135
+ into reviewers; execute reviewers in parallel; synthesize findings.
136
+ - **Spec**: [`agents/modes/review.md`](../agents/modes/review.md)
137
+
138
+ ```mermaid
139
+ flowchart TD
140
+ U[Target Scope] --> L[Lead]
141
+ L --> E[Explorer]
142
+ E --> L
143
+ L --> C[Counsel]
144
+ C --> L
145
+ L --> T{Trivial?}
146
+ T -->|yes| R[Review Panel Parallel]
147
+ T -->|no| P[Planner Audit Plan]
148
+ P -->|min 1| PR[Plan Reviewer]
149
+ PR -->|approve| R
150
+ PR -->|reject| P
151
+ R --> REP[Report]
152
+ ```
153
+
154
+ ## 4.4 Role Specs
155
+
156
+ The canonical contracts for each role live under `agents/roles/`.
157
+
158
+ - Lead: [`agents/roles/lead.md`](../agents/roles/lead.md)
159
+ - Planner: [`agents/roles/planner.md`](../agents/roles/planner.md)
160
+ - Counsel: [`agents/roles/counsel.md`](../agents/roles/counsel.md)
161
+ - Builder: [`agents/roles/builder.md`](../agents/roles/builder.md)
162
+ - Explorer: [`agents/roles/explorer.md`](../agents/roles/explorer.md)
163
+ - Librarian: [`agents/roles/librarian.md`](../agents/roles/librarian.md)
164
+ - Review Panel: [`agents/roles/reviewer/README.md`](../agents/roles/reviewer/README.md)