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
@@ -0,0 +1,14 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(grep:*)",
5
+ "WebSearch",
6
+ "WebFetch(domain:opencode.ai)",
7
+ "WebFetch(domain:github.com)",
8
+ "WebFetch(domain:models.dev)",
9
+ "WebFetch(domain:raw.githubusercontent.com)",
10
+ "Bash(gh api:*)",
11
+ "WebFetch(domain:docs.claude.com)"
12
+ ]
13
+ }
14
+ }
@@ -0,0 +1,8 @@
1
+ # Gemini Review
2
+
3
+ This directory configures Gemini-based code review tools.
4
+
5
+ ## Index
6
+
7
+ - `styleguide.md`: Review guidance for this repository.
8
+ - `config.yaml`: Focus areas and include/exclude patterns.
@@ -0,0 +1,20 @@
1
+ review_focus:
2
+ - correctness
3
+ - maintainability
4
+ - security
5
+ - documentation
6
+
7
+ include_patterns:
8
+ - "AGENTS.md"
9
+ - "README.md"
10
+ - "VERSION"
11
+ - "agents/**"
12
+ - "contribute/**"
13
+ - "docs/**"
14
+ - "integrate/**"
15
+ - "models/**"
16
+ - "rules/**"
17
+ - "scripts/**"
18
+
19
+ exclude_patterns:
20
+ - "ideas/**"
@@ -0,0 +1,35 @@
1
+ # Code Review Style Guide (lgtm-specs)
2
+
3
+ This repository is a specification Knowledge Graph. Review changes as **spec edits**, not application code.
4
+
5
+ ## Review Focus
6
+
7
+ 1. **Integrity**
8
+ - Links are repo-relative and targets exist.
9
+ - New directories have an index `README.md`.
10
+ - New nodes are indexed in the correct parent index.
11
+
12
+ Reference: [Definition of Done](../contribute/checklist.md).
13
+
14
+ 2. **Rule Template Compliance** (`rules/`)
15
+ - Each atomic rule has: `Source`, `Tags`, `Related`.
16
+ - Contains: Definition, Requirements, Anti-Patterns, Examples.
17
+ - Examples include both **Bad** and **Good** snippets.
18
+
19
+ Reference: [Rule Template](../rules/RULE-00000-EXAMPLE.md) and [Definition of Done](../contribute/checklist.md).
20
+
21
+ 3. **Agent Contracts** (`agents/`, `integrate/`)
22
+ - Do not break placeholder contracts (e.g., `{{injected_rules}}`).
23
+ - Model capability IDs must match `models/registry.yaml` keys.
24
+
25
+ Reference: [Integration Protocol](../integrate/README.md).
26
+
27
+ 4. **Noise Control**
28
+ - Report only current issues.
29
+ - Do not state "fixed", "resolved", or "already addressed".
30
+ - Prefer concrete, actionable findings.
31
+
32
+ ## Output Format
33
+
34
+ - Use a short list of issues.
35
+ - Each issue includes the file path and what to change.
@@ -0,0 +1,5 @@
1
+ # Workflows
2
+
3
+ ## Index
4
+
5
+ - `validate.yml`: Runs repository validation checks.
@@ -0,0 +1,52 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ contents: write
10
+
11
+ jobs:
12
+ release:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Checkout
16
+ uses: actions/checkout@v4
17
+ with:
18
+ fetch-depth: 0
19
+
20
+ - name: Setup Python
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: "3.11"
24
+
25
+ - name: Setup Bun
26
+ uses: oven-sh/setup-bun@v2
27
+ with:
28
+ bun-version: latest
29
+
30
+ - name: Bun check
31
+ run: bun run check
32
+
33
+ - name: Verify tag matches VERSION
34
+ shell: bash
35
+ run: |
36
+ set -euo pipefail
37
+ ver="$(cat VERSION)"
38
+ tag="${GITHUB_REF_NAME}"
39
+ if [[ "v${ver}" != "${tag}" ]]; then
40
+ echo "ERROR: Tag ${tag} does not match VERSION ${ver}" >&2
41
+ exit 1
42
+ fi
43
+
44
+ - name: Generate release notes
45
+ env:
46
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47
+ run: python3 scripts/generate_release_notes.py --output release-notes.md
48
+
49
+ - name: Create GitHub release
50
+ uses: softprops/action-gh-release@v2
51
+ with:
52
+ body_path: release-notes.md
@@ -0,0 +1,27 @@
1
+ name: Validate Specs
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ jobs:
10
+ validate:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v4
15
+
16
+ - name: Setup Python
17
+ uses: actions/setup-python@v5
18
+ with:
19
+ python-version: "3.11"
20
+
21
+ - name: Setup Bun
22
+ uses: oven-sh/setup-bun@v2
23
+ with:
24
+ bun-version: latest
25
+
26
+ - name: Bun check
27
+ run: bun run check
@@ -0,0 +1,4 @@
1
+ .git/
2
+ ideas/
3
+ tmp/
4
+ .temp/
package/.prettierrc ADDED
@@ -0,0 +1 @@
1
+ {}
package/AGENTS.md ADDED
@@ -0,0 +1,151 @@
1
+ # Agent Instructions (lgtm-specs)
2
+
3
+ This repository (`lgtm-specs`) is a versioned **Knowledge Graph** of specs (rules + agent prompts). Treat changes as spec
4
+ edits, not application code.
5
+
6
+ Repo-local assistant instructions:
7
+
8
+ - Cursor: none (`.cursor/rules/` and `.cursorrules` do not exist)
9
+ - Copilot: none (`.github/copilot-instructions.md` does not exist)
10
+ - Gemini review tooling: see `.gemini/styleguide.md` (optional)
11
+
12
+ ## 1. Build / Lint / Test
13
+
14
+ CI parity (recommended):
15
+
16
+ ```bash
17
+ bun run check
18
+ ```
19
+
20
+ What this runs:
21
+
22
+ ```bash
23
+ # Validation (graph structure, indexing, capability registry, VERSION sync)
24
+ bun run validate
25
+ # or:
26
+ python3 scripts/validate_specs.py
27
+
28
+ # Formatting (Prettier)
29
+ bun run format
30
+ bun run format:check
31
+ ```
32
+
33
+ Single-file "test" (fast feedback):
34
+
35
+ ```bash
36
+ FILE="rules/constitution/CONS-00027-transparency.md"
37
+
38
+ # Format only this file
39
+ bunx prettier --check "$FILE"
40
+ bunx prettier --write "$FILE"
41
+
42
+ # Minimal structure checks (exists, indexed, required headers/keys)
43
+ test -f "$FILE" && echo "OK: exists"
44
+ grep -q "$(basename "$FILE")" "$(dirname "$FILE")/README.md" && echo "OK: indexed"
45
+
46
+ for key in Source Tags Related; do
47
+ grep -q "^\\*\\*$key\\*\\*:" "$FILE" && echo "OK: $key"
48
+ done
49
+
50
+ for hdr in "## Definition" "## Requirements" "## Anti-Patterns" "## Examples"; do
51
+ grep -q "$hdr" "$FILE" && echo "OK: $hdr"
52
+ done
53
+
54
+ for ex in Bad Good; do
55
+ grep -q "\\*\\*$ex:\\*\\*" "$FILE" && echo "OK: $ex example"
56
+ done
57
+ ```
58
+
59
+ Optional (network-dependent) external URL validation:
60
+
61
+ ```bash
62
+ python3 scripts/validate_specs.py --check-urls
63
+ python3 scripts/validate_specs.py --check-urls --url-timeout 12
64
+ python3 scripts/validate_specs.py --check-urls --url-ignore "https://example.com/badge.svg"
65
+ ```
66
+
67
+ Optional warnings baseline (temporary migrations only):
68
+
69
+ ```bash
70
+ python3 scripts/validate_specs.py --write-baseline scripts/validate_baseline.txt
71
+ python3 scripts/validate_specs.py --baseline scripts/validate_baseline.txt
72
+ ```
73
+
74
+ ID collision check:
75
+
76
+ ```bash
77
+ git grep -n "CONS-00033" || echo "ID available"
78
+ ```
79
+
80
+ ## 2. Code Style Guidelines
81
+
82
+ ### 2.1 Specs (Markdown)
83
+
84
+ Naming:
85
+
86
+ - Constitution: `rules/constitution/CONS-00000-slug.md`
87
+ - Laws: `rules/laws/<domain>/<DOMAIN>-00000-slug.md` (e.g., `GO-00000-...md`, `TS-00000-...md`)
88
+ - Policies: `rules/policies/default.md` or `rules/policies/<project>-policy.md`
89
+
90
+ Atomic rule requirements (see `rules/RULE-00000-EXAMPLE.md`):
91
+
92
+ - H1 title: `# Name (ID)`
93
+ - Metadata lines: `**Source**:`, `**Tags**:`, `**Related**:`
94
+ - Sections: `## Definition`, `## Requirements`, `## Anti-Patterns`, `## Examples`
95
+ - Examples: both `**Bad:**` and `**Good:**` (multi-line; prefer fenced blocks)
96
+
97
+ Citations and links:
98
+
99
+ - Source-of-truth material lives in `docs/meta/**`; do not invent citations.
100
+ - Use repo-root-relative links (`/rules/...`, `/docs/...`) and ensure targets exist.
101
+ - `**Source**` links into `docs/meta/**` should include an anchor (`#...`).
102
+
103
+ Tags and writing:
104
+
105
+ - Include at least one dimension tag: `#structural`, `#behavioral`, `#runtime`, `#operational`.
106
+ - Keep specs skimmable; avoid filler; keep lines <= 120 chars.
107
+ - Run `bun run format` before finalizing Markdown edits.
108
+
109
+ Indexing:
110
+
111
+ - Every directory with content MUST have a `README.md` indexing its files.
112
+ - Any new file must be added to the parent directory index `README.md`.
113
+
114
+ ### 2.2 Agent Specs (`agents/**`)
115
+
116
+ Contracts (external tools parse these; see `integrate/README.md`):
117
+
118
+ - Do not remove placeholders like `{{injected_rules}}` / `{{indices}}`.
119
+ - Modes require: `<Meta>`, `<Role>`, `<Workflow>`.
120
+ - Roles require: `<Meta>`, `<Role>`, `<Input>`, `<Objective>`, `<OutputFormat>`, `<Workflow>`.
121
+ - `<Meta>` key lines must start at column 1; role specs must include `Capability: <id>`.
122
+ - `Capability` must exist as a key in `models/registry.yaml`.
123
+
124
+ Valid capability IDs: `reasoning`, `coding`, `data`, `fast`, `security`, `docs`, `general`.
125
+
126
+ ### 2.3 Python Tooling (`scripts/**/*.py`)
127
+
128
+ - Dependencies: standard library only; keep CI-compatible (Python 3.11+).
129
+ - Imports: `from __future__ import annotations` first; then stdlib imports, grouped and alphabetized.
130
+ - Types: annotate public functions; prefer builtin generics (`list[str]`, `dict[str, ...]`).
131
+ - Naming: `snake_case` (func/var), `PascalCase` (class), `SCREAMING_SNAKE_CASE` (constants).
132
+ - Error handling: print failures to stderr; return non-zero exit codes; keep messages deterministic.
133
+ - Determinism: stable ordering (sort sets/dicts); avoid timestamps/randomness unless required.
134
+
135
+ ## 3. Definition of Done
136
+
137
+ - `bun run check` passes (validator + prettier check).
138
+ - IDs are unique (use `git grep -n "<ID>"`).
139
+ - New/changed files are indexed (parent `README.md` updated).
140
+ - Rule files include required metadata/sections and both Bad/Good examples.
141
+ - Internal links resolve; `**Source**` links into `docs/meta/**` include anchors.
142
+ - Integration changes preserve placeholders and keep `VERSION` in sync with `integrate/README.md`.
143
+
144
+ ## 4. Handy Commands
145
+
146
+ ```bash
147
+ git status && git diff --name-only
148
+ git log -n 20 --oneline
149
+ git grep -l "error handling" rules/
150
+ ls rules/constitution/CONS-*.md
151
+ ```
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # LGTM Specifications
2
+
3
+ [![Validate Specs](https://github.com/yyforyongyu/lgtm-specs/actions/workflows/validate.yml/badge.svg?branch=main)](https://github.com/yyforyongyu/lgtm-specs/actions/workflows/validate.yml?query=branch%3Amain) [![Version](https://img.shields.io/github/v/tag/yyforyongyu/lgtm-specs?sort=semver)](https://github.com/yyforyongyu/lgtm-specs/releases)
4
+
5
+ LGTM Specifications is a versioned knowledge graph of engineering standards (Rules) and an autonomous workforce (Agents) used by tools to plan, build, and audit changes with high assurance.
6
+
7
+ ## Knowledge
8
+
9
+ We turn industry best practices and internal standards into atomic, enforceable rules:
10
+
11
+ 1. Source material lives in `docs/meta/**`.
12
+ 2. Atomic rules live in `rules/**` and cite their sources.
13
+ 3. Runtimes inject only the relevant rules for a given task (tag/domain based) instead of loading the entire graph.
14
+
15
+ Start here:
16
+
17
+ - [Rules Index](rules/README.md)
18
+ - [Docs Index](docs/README.md)
19
+
20
+ ## Workflows
21
+
22
+ LGTM runs as a set of operating modes that orchestrate a specialist team (Lead, Explorer, Counsel, Planner, Builder, Reviewer panel).
23
+
24
+ Modes:
25
+
26
+ - `@Build`: production changes (rules + plan + proof + specialist review).
27
+ - `@Hack`: fast iteration (lighter gates).
28
+ - `@Review`: read-only audit.
29
+
30
+ Core roles:
31
+
32
+ - Lead orchestrates and arbitrates.
33
+ - Explorer maps the target repo.
34
+ - Counsel selects minimal relevant rule paths.
35
+ - Planner produces an execution/audit plan.
36
+ - Builder implements and produces proof.
37
+ - Reviewers audit from specialized perspectives.
38
+
39
+ Start here:
40
+
41
+ - [Agent Architecture](docs/agent_architecture.md)
42
+ - [Agents Index](agents/README.md)
43
+
44
+ ## Integrating
45
+
46
+ Tools consume this repo as a read-only spec database.
47
+
48
+ Start here:
49
+
50
+ - [Integration Protocol](integrate/README.md)
51
+
52
+ Copy/paste prompt for a tool/LLM implementing the integration:
53
+
54
+ ```text
55
+ You are implementing integration for the LGTM specs repo (yyforyongyu/lgtm-specs).
56
+
57
+ Goal: wire this repo into a coding tool so it can run the LGTM agent workflows.
58
+
59
+ Read and follow `integrate/README.md` exactly, including:
60
+ - Parsing `agents/**/*.md` and honoring placeholders like `{{injected_rules}}`.
61
+ - Running Counsel and enforcing its JSON output schema.
62
+ - Hydrating rule paths into rule content and injecting role-appropriate subsets per reviewer.
63
+ - Resolving models using `models/registry.yaml` in list order (preference order) with deterministic availability checks.
64
+
65
+ Output:
66
+ 1) a concise implementation checklist,
67
+ 2) the minimal data structures you will use (schemas),
68
+ 3) pseudocode for: index loading -> counsel -> rule hydration -> per-agent injection -> execution.
69
+ ```
70
+
71
+ ## Contributing
72
+
73
+ Contributions should preserve atomicity, indexing, and link integrity.
74
+
75
+ Start here:
76
+
77
+ - [Contribution Guide](contribute/README.md)
78
+ - [Definition of Done Checklist](contribute/checklist.md)
79
+ - Local checks: `bun run check` (runs spec validation + `prettier --check`).
80
+
81
+ Copy/paste prompt for an LLM starting a contribution:
82
+
83
+ ```text
84
+ You are contributing to the LGTM specs repo (yyforyongyu/lgtm-specs).
85
+
86
+ Read `contribute/README.md` and `contribute/checklist.md` and follow them strictly.
87
+ Run `bun run check` before finalizing your changes.
88
+
89
+ Constraints:
90
+ - One rule per file; follow the rule template used in this repo.
91
+ - Add new files to the parent directory index README(s).
92
+ - Use repo-relative links only and ensure every link target exists.
93
+
94
+ Task:
95
+ 1) identify the smallest set of atomic rule/doc changes needed for the request,
96
+ 2) propose exact file edits,
97
+ 3) run `python3 scripts/validate_specs.py` and report any failures.
98
+ ```
package/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.4
@@ -0,0 +1,73 @@
1
+ # Agent Workforce
2
+
3
+ This directory defines the LGTM agent contracts:
4
+
5
+ - Modes (workflows): `@Build`, `@Hack`, `@Review`
6
+ - Roles (workers): `@Lead`, `@Planner`, `@Counsel`, `@Builder`, `@Explorer`, `@Librarian`, `@Reviewer*`
7
+
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
+
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
+ - [@Builder](roles/builder.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
+ ├── templates/
52
+ │ ├── README.md
53
+ │ ├── role.md
54
+ │ └── mode.md
55
+ └── roles/
56
+ ├── lead.md
57
+ ├── planner.md
58
+ ├── counsel.md
59
+ ├── explorer.md
60
+ ├── builder.md
61
+ ├── librarian.md
62
+ └── reviewer/
63
+ ├── BASE.md
64
+ ├── OUTPUT_FORMAT.md
65
+ ├── README.md
66
+ ├── plan.md
67
+ ├── lite.md
68
+ ├── logic.md
69
+ ├── quality.md
70
+ ├── security.md
71
+ ├── performance.md
72
+ └── test.md
73
+ ```
@@ -0,0 +1,9 @@
1
+ # Operating Modes
2
+
3
+ Mode specs define the canonical orchestration workflows for the LGTM workforce.
4
+
5
+ ## Index
6
+
7
+ - [@Build](build.md): High-assurance engineering workflow.
8
+ - [@Hack](hack.md): Rapid prototyping workflow.
9
+ - [@Review](review.md): Read-only audit workflow.
@@ -0,0 +1,88 @@
1
+ # Mode: @Build
2
+
3
+ <Meta>
4
+ Type: High-Assurance Engineering Workflow.
5
+ Brain: Uses **[@Lead](../roles/lead.md)** for arbitration and orchestration decisions.
6
+
7
+ Trigger:
8
+
9
+ - New Feature implementation.
10
+ - Refactoring critical paths (Auth, Payments, Cryptography).
11
+ - Public API changes.
12
+ - Database Schema migrations.
13
+ - "Production Ready" work.
14
+
15
+ Team:
16
+
17
+ - **Manager**: **[@Lead](../roles/lead.md)**.
18
+ - **Architect**: **[@Planner](../roles/planner.md)**.
19
+ - **Compliance**: **[@Counsel](../roles/counsel.md)**.
20
+ - **Researcher**: **[@Librarian](../roles/librarian.md)** (Optional).
21
+ - **Maker**: **[@Builder](../roles/builder.md)**.
22
+ - **Cartographer**: **[@Explorer](../roles/explorer.md)**.
23
+ - **Plan Reviewer**: **[@Plan-Reviewer](../roles/reviewer/plan.md)**.
24
+ - **Micro-Critic**: **[@Reviewer-Lite](../roles/reviewer/lite.md)**.
25
+ - **Critics**: **[@Reviewer](../roles/reviewer/README.md)** (Panel).
26
+ </Meta>
27
+
28
+ <Role>
29
+ **Goal**: Ship Features, Refactors, and Production Code.
30
+ </Role>
31
+
32
+ <Workflow>
33
+ ## Phase 1: Clarify & Design (The Blueprint)
34
+ 1. **Orchestrate**: `@Lead` assesses the request and engages `@Explorer` to map the codebase.
35
+ 2. **Compliance**: `@Lead` consults `@Counsel` for Rules and Policies.
36
+ * **Inject**: `@Lead` instructs the Runtime to load/hydrate rule content and inject `{{injected_rules}}` into
37
+ `@Planner` and all reviewers used in this mode (`@Plan-Reviewer`, `@Reviewer-Lite`, Panel).
38
+ 3. **Draft**: `@Planner` creates the **Execution Plan**.
39
+ * *Input*: User Request + Map + Rules.
40
+ 4. **Plan Review**: Call **two** independent `@Plan-Reviewer` instances.
41
+ * *Gate*: Must have unanimous approval to proceed.
42
+ * *Loop*: Max 3 revision cycles.
43
+ * *Timeout*: 5 minutes per reviewer per cycle (default; runtime may override).
44
+ * *On Timeout*: Re-assign each timed-out reviewer once. If it still times out, treat as a reject for that cycle.
45
+ * *On Reject*: `@Lead` digests reviewer feedback, decides legitimacy, and asks `@Planner` to revise the plan.
46
+ * *After Max*: If still not unanimously approved after 3 cycles, `@Lead` must either abort (recommended) or
47
+ arbitrate/override by authoring a revised plan with an explicit risk rationale.
48
+ 5. **Gate**: Present Plan to User. **WAIT for Sign-off**.
49
+ * *Constraint*: Do not proceed to Build until Plan is explicitly approved.
50
+
51
+ ## Phase 2: Execute (The Heavy Loop)
52
+
53
+ For each Task in the Plan:
54
+
55
+ 1. **Build**: Call `@Builder` with `(Task, Rules, Verification)`.
56
+ - _Constraint_: Verification is mandatory. The proof level is defined per step (tests and/or other evidence).
57
+ 2. **Micro-Audit**: Call `@Reviewer-Lite` on the diff.
58
+ - _Scope_: Fast sanity gate (obvious correctness breakage + basic style/tooling + commit message); deep specialist review happens in Phase 3.
59
+ - _Input_: Include the PR merge target as `Base Ref` and the atomic `Commit Message` when available.
60
+ - _Retry_: Max 3 attempts.
61
+ - _Timeout_: 5 minutes per attempt.
62
+ - _On Timeout_: Treat as a reject and retry.
63
+ - _On Reject_: `@Lead` digests feedback, decides legitimacy, and asks `@Builder` to address it.
64
+ - _Fail_: If 3 retries fail, `@Lead` calls `@Planner` to re-plan or overrides with rationale.
65
+
66
+ ## Phase 3: Consensus (The Jury)
67
+
68
+ 1. **Verify**: Ensure required verification passes (including integration tests when required).
69
+ 2. **Audit**: Call the **Full Review Panel**.
70
+ - Mandatory: `Logic`, `Quality`, `Test`.
71
+ - Conditional: `Security` (if tagged), `Performance` (if tagged).
72
+ 3. **Gate**: Unanimous Approval Required.
73
+ - _Loop_: Max 10 review->fix cycles.
74
+ - _Timeout_: 10 minutes per reviewer per cycle.
75
+ - _On Timeout_: Re-assign each timed-out reviewer once. If it still times out, treat as a reject for that cycle.
76
+ - _Clarify_: If a finding is contested or unclear, `@Lead` asks the specific reviewer to justify or withdraw it (one round-trip max) before planning fixes.
77
+ - _Cycle_: On each rejection, `@Lead` digests the panel feedback and calls `@Planner` to produce a remediation todo list. `@Builder` executes tasks one at a time, then the panel re-reviews.
78
+ - _Compress_: After each cycle, keep a compact "Resolved / Remaining" summary; do not carry full prior transcripts into later cycles.
79
+ - _Arbitration (Conditional)_: If reviewers deadlock/contradict, runtime injects the minimum Tier 2 contested diff and
80
+ full contested rules into `@Lead`; `@Lead` judges citing rule IDs and diff evidence.
81
+ - _Override_: If needed, `@Lead` may override with an explicit risk rationale.
82
+ - _After Max_: If still not unanimous after 10 cycles, `@Lead` must either abort (recommended) or override with an explicit risk rationale.
83
+
84
+ ## Phase 4: Delivery
85
+
86
+ - **Finalize**: Produce the Production-Ready PR.
87
+
88
+ </Workflow>
@@ -0,0 +1,76 @@
1
+ # Mode: @Hack
2
+
3
+ <Meta>
4
+ Type: Rapid Prototyping Workflow.
5
+ Brain: Uses **[@Lead](../roles/lead.md)** for orchestration.
6
+
7
+ Trigger:
8
+
9
+ - "Try this idea out".
10
+ - "Quick prototype".
11
+ - Single-file logic patches (non-critical).
12
+ - UI/Text tweaks.
13
+ - Documentation updates.
14
+
15
+ SafetyProfile:
16
+ Do not auto-escalate or switch modes; run `@Hack` as selected.
17
+
18
+ Critical-path heuristics (informational only)
19
+
20
+ - Authentication / Authorization (auth, login, permissions)
21
+ - Billing / Payments / Ledger
22
+ - Cryptography / Secrets
23
+ - Database Schema (migrations, schema files)
24
+ - Public API Contracts
25
+
26
+ Team:
27
+
28
+ - **Manager**: **[@Lead](../roles/lead.md)** (Gatekeeper).
29
+ - **Cartographer**: **[@Explorer](../roles/explorer.md)**.
30
+ - **Compliance**: **[@Counsel](../roles/counsel.md)** (Optional).
31
+ - **Researcher**: **[@Librarian](../roles/librarian.md)** (Optional).
32
+ - **Architect**: **[@Planner](../roles/planner.md)** (Sketch/Plan).
33
+ - **Maker**: **[@Builder](../roles/builder.md)** (Fast Mode).
34
+ - **Plan Reviewer**: **[@Plan-Reviewer](../roles/reviewer/plan.md)** (Optional).
35
+ - **Critic**: **[@Reviewer-Lite](../roles/reviewer/lite.md)**.
36
+ </Meta>
37
+
38
+ <Role>
39
+ **Goal**: PoCs, Experiments, Non-Critical Fixes.
40
+ </Role>
41
+
42
+ <Workflow>
43
+ ## Phase 1: Sketch
44
+ 1. **Map**: `@Lead` engages `@Explorer` to identify likely touched files and risks.
45
+ 2. **Plan**: `@Planner` creates a short "Sketch Plan" (atomic steps + files).
46
+ 3. **Rules (Optional)**: If the user requests stricter compliance, `@Lead` consults `@Counsel` and instructs the Runtime
47
+ to hydrate and inject `{{injected_rules}}`.
48
+ 4. **Plan Review**: Optional. `@Lead` may call `@Plan-Reviewer` (0-1) based on scope (e.g., multi-step/multi-file) or
49
+ if the user requests it.
50
+ * *Timeout (Default)*: 5 minutes if called.
51
+ * *On Timeout*: Proceed without plan review.
52
+
53
+ ## Phase 2: Code (The Fast Loop)
54
+
55
+ 1. **Build**: Call `@Builder`.
56
+ - _Constraint_: No mandatory TDD or Unit Tests in `@Hack`.
57
+ - _Note_: If the user requests tests, include them in the plan.
58
+ 2. **Check**: Call `@Reviewer-Lite` (Format + Basic Logic).
59
+ - _Scope_: Sanity checks only (no deep architecture review).
60
+ - _Input_: Pass the PR merge target as `Base Ref` and the atomic `Commit Message` when available.
61
+ - _If REJECT_: `@Lead` digests feedback and asks `@Builder` to address it.
62
+ - _Retry_: Max 3 attempts.
63
+ - _Timeout_: 5 minutes per attempt.
64
+ - _Fail_: If 3 retries fail, `@Lead` decides to proceed (as a prototype) or abort.
65
+
66
+ ## Phase 3: Delivery
67
+
68
+ - **Finalize**: Produce a Draft PR or Experimental Branch.
69
+ - **Note**: Explicitly label as "Prototype / Not Production Ready".
70
+
71
+ </Workflow>
72
+
73
+ <Constraints>
74
+ **Hard Blocks**:
75
+ - [ ] Do not auto-escalate or switch modes; run `@Hack` as selected.
76
+ </Constraints>