@tyroneross/build-loop 0.36.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/.agents/plugins/marketplace.json +2 -2
  2. package/.claude-plugin/marketplace.json +3 -3
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/.codex-plugin/plugin.json +1 -1
  5. package/.cursor/rules/build-loop-surface.mdc +12 -11
  6. package/.cursor/rules/skill-index.mdc +33 -0
  7. package/AGENTS.md +213 -34
  8. package/README.md +99 -31
  9. package/agents/advisor.md +4 -4
  10. package/agents/alignment-checker.md +2 -2
  11. package/agents/architecture-scout.md +4 -4
  12. package/agents/build-orchestrator.md +38 -36
  13. package/agents/database-assessor.md +11 -5
  14. package/agents/design-contract-specialist.md +8 -8
  15. package/agents/fact-checker.md +13 -3
  16. package/agents/fix-critique.md +2 -2
  17. package/agents/independent-auditor.md +60 -7
  18. package/agents/leak-scanner.md +82 -0
  19. package/agents/overfitting-reviewer.md +2 -2
  20. package/agents/plan-critic.md +1 -1
  21. package/agents/promotion-reviewer.md +5 -5
  22. package/agents/retrospective-synthesizer.md +138 -35
  23. package/agents/scope-auditor.md +82 -11
  24. package/agents/security-reviewer.md +56 -2
  25. package/agents/self-improvement-architect.md +17 -3
  26. package/agents/transcript-pattern-miner.md +5 -5
  27. package/agents/ui-validator.md +1 -1
  28. package/bin/build-loop-debugger.js +143 -0
  29. package/bin/build-loop-install.js +1 -4
  30. package/bin/build-loop-load-probe.js +345 -0
  31. package/codex-skills/build-loop/SKILL.md +28 -6
  32. package/commands/feedback.md +37 -0
  33. package/dist/src/interactive-verifier.d.ts +1 -14
  34. package/dist/src/interactive-verifier.d.ts.map +1 -1
  35. package/dist/src/interactive-verifier.js +6 -113
  36. package/dist/src/interactive-verifier.js.map +1 -1
  37. package/dist/src/quality.d.ts +5 -0
  38. package/dist/src/quality.d.ts.map +1 -0
  39. package/dist/src/quality.js +81 -0
  40. package/dist/src/quality.js.map +1 -0
  41. package/dist/src/storage.d.ts.map +1 -1
  42. package/dist/src/storage.js +37 -3
  43. package/dist/src/storage.js.map +1 -1
  44. package/docs/agent-surface-policy.md +35 -31
  45. package/docs/memory-setup.md +19 -0
  46. package/hooks/git/pre-push +65 -4
  47. package/hooks/hooks.json +95 -38
  48. package/hooks/pre-commit +20 -1
  49. package/hooks/pre-edit-rally-point.sh +10 -3
  50. package/hooks/session-start-codex-hook-trust.sh +30 -0
  51. package/hooks/session-start-git-hooks.sh +3 -1
  52. package/hooks/session-start-rally-point.sh +52 -4
  53. package/hooks/session-start-worktree-gc.sh +47 -94
  54. package/hooks/stop-transcript-sweep.sh +173 -0
  55. package/hooks/test_closeout.sh +14 -2
  56. package/package.json +8 -7
  57. package/scripts/README.md +1 -1
  58. package/scripts/_paths.py +65 -0
  59. package/scripts/groundwork_exchange.py +1012 -0
  60. package/scripts/install_memory.py +33 -1
  61. package/scripts/lessons_index/ingest.py +13 -2
  62. package/scripts/lessons_index/query.py +36 -13
  63. package/scripts/memory_context/__init__.py +108 -14
  64. package/scripts/memory_graph/__init__.py +5 -1
  65. package/scripts/project_resolver.py +42 -36
  66. package/scripts/sync_plugin_cache.py +37 -2
  67. package/skills/agent-rally-point/SKILL.md +46 -0
  68. package/skills/api-registry-bridge/SKILL.md +1 -1
  69. package/skills/architecture/dead/SKILL.md +1 -1
  70. package/skills/architecture/impact/SKILL.md +1 -1
  71. package/skills/architecture/review/SKILL.md +1 -1
  72. package/skills/architecture/rules/SKILL.md +3 -3
  73. package/skills/architecture/scan/SKILL.md +1 -1
  74. package/skills/architecture/trace/SKILL.md +1 -1
  75. package/skills/attribution-standard/SKILL.md +6 -6
  76. package/skills/auto-decision-capture/SKILL.md +31 -2
  77. package/skills/auto-finding-capture/SKILL.md +28 -1
  78. package/skills/build-loop/SKILL.md +131 -23
  79. package/skills/build-loop/fallbacks.md +16 -21
  80. package/skills/build-loop/phases/ui-validation.md +2 -2
  81. package/skills/build-loop/references/advisor-dispatch-ladder.md +1 -1
  82. package/skills/build-loop/references/apple-native-planning.md +1 -1
  83. package/skills/build-loop/references/autonomous-and-per-commit-modes.md +11 -5
  84. package/skills/build-loop/references/autonomy-dashboard.md +115 -0
  85. package/skills/build-loop/references/capability-routing.md +24 -2
  86. package/skills/build-loop/references/coordination.md +24 -6
  87. package/skills/build-loop/references/experiment-results-template.md +15 -3
  88. package/skills/build-loop/references/leadership.md +1 -1
  89. package/skills/build-loop/references/memory.md +14 -3
  90. package/skills/build-loop/references/modular-systems-pack.md +8 -0
  91. package/skills/build-loop/references/output-style.md +86 -0
  92. package/skills/build-loop/references/phase-1-assess.md +102 -2
  93. package/skills/build-loop/references/phase-2-plan.md +9 -1
  94. package/skills/build-loop/references/phase-3-execute.md +5 -2
  95. package/skills/build-loop/references/phase-4-review.md +85 -8
  96. package/skills/build-loop/references/phase-5-iterate.md +76 -8
  97. package/skills/build-loop/references/phase-6-learn.md +10 -17
  98. package/skills/build-loop/references/privileged-request-broker.md +254 -0
  99. package/skills/build-loop/references/resource-aware-execution.md +183 -0
  100. package/skills/build-loop/references/self-recursive-dev.md +2 -2
  101. package/skills/build-loop/references/status-output-format.md +207 -0
  102. package/skills/build-loop/references/verify-dispatch.md +56 -2
  103. package/skills/building-with-deepagents/SKILL.md +1 -1
  104. package/skills/claim-scope/SKILL.md +185 -0
  105. package/skills/color-engine/SKILL.md +103 -0
  106. package/skills/color-engine/_core.py +464 -0
  107. package/skills/color-engine/color_engine.py +175 -0
  108. package/skills/cost-rca/SKILL.md +61 -0
  109. package/skills/data-plane-worktrees/SKILL.md +139 -0
  110. package/skills/data-plane-worktrees/agents/openai.yaml +4 -0
  111. package/skills/database-practice/SKILL.md +200 -0
  112. package/skills/database-practice/references/diagnostic-queries.sql +126 -0
  113. package/skills/database-practice/references/vector-and-graph-tuning.md +208 -0
  114. package/skills/database-practice/scripts/db_table_map.py +1244 -0
  115. package/skills/database-practice/scripts/test_db_table_map.py +514 -0
  116. package/skills/debug-loop/SKILL.md +36 -6
  117. package/skills/debugging-memory/SKILL.md +32 -430
  118. package/skills/debugging-memory/references/pattern-extraction.md +4 -4
  119. package/skills/debugging-memory/references/search.md +32 -120
  120. package/skills/debugging-memory/references/store.md +32 -126
  121. package/skills/debugging-memory/references/subagent-integration.md +1 -1
  122. package/skills/decision-queue/SKILL.md +251 -0
  123. package/skills/decision-queue/assets/template.html +1242 -0
  124. package/skills/decision-queue/references/example-large-queue-batching.md +164 -0
  125. package/skills/decision-queue/scripts/regen_template_constants.py +160 -0
  126. package/skills/defenseclaw-bridge/SKILL.md +2 -2
  127. package/skills/defenseclaw-bridge/references/dc-config-mapping.md +2 -9
  128. package/skills/drain-proposals/SKILL.md +53 -0
  129. package/skills/focused-loop-builder/SKILL.md +31 -0
  130. package/skills/focused-loop-builder/references/spec-format.md +27 -0
  131. package/skills/handoff/SKILL.md +169 -8
  132. package/skills/ibr-bridge/SKILL.md +4 -1
  133. package/skills/knowledge/SKILL.md +26 -14
  134. package/skills/knowledge/references/review-mode.md +2 -3
  135. package/skills/knowledge/templates/madr-minimal.md +1 -1
  136. package/skills/mcp-builder/SKILL.md +1 -1
  137. package/skills/model-bakeoff/SKILL.md +48 -10
  138. package/skills/model-tiering/SKILL.md +92 -31
  139. package/skills/native-ax-driver/SKILL.md +38 -5
  140. package/skills/native-ax-driver/scripts/native_driver.py +278 -22
  141. package/skills/native-ax-driver/scripts/test_native_driver.py +227 -0
  142. package/skills/optimize/SKILL.md +1 -1
  143. package/skills/plugin-builder/SKILL.md +48 -1
  144. package/skills/plugin-builder/references/build-loop-phase-guidance.md +3 -4
  145. package/skills/plugin-builder/references/distribution.md +13 -2
  146. package/skills/plugin-builder/references/plugin-hygiene-lessons.md +2 -2
  147. package/skills/plugin-tests/SKILL.md +2 -2
  148. package/skills/recursive-retrospective/SKILL.md +1 -1
  149. package/skills/repo-closeout/SKILL.md +17 -0
  150. package/skills/repo-closeout/agents/openai.yaml +4 -0
  151. package/skills/repo-maintenance/SKILL.md +179 -0
  152. package/skills/repo-maintenance/agents/openai.yaml +4 -0
  153. package/skills/repo-maintenance/references/pre-public-hygiene.md +134 -0
  154. package/skills/repo-maintenance/references/repository-taxonomy.md +161 -0
  155. package/skills/repo-maintenance/references/safety-protocol.md +106 -0
  156. package/skills/repo-maintenance/references/stack-profiles.md +138 -0
  157. package/skills/repo-maintenance/scripts/audit_repo_maintenance.py +1198 -0
  158. package/skills/repo-maintenance/scripts/test_audit_repo_maintenance.py +506 -0
  159. package/skills/repository-intelligence/SKILL.md +189 -0
  160. package/skills/repository-intelligence/agents/openai.yaml +4 -0
  161. package/skills/repository-intelligence/references/assessment-rubric.md +88 -0
  162. package/skills/repository-intelligence/scripts/repository_inventory.py +347 -0
  163. package/skills/research/SKILL.md +12 -2
  164. package/skills/root-cause-analysis/SKILL.md +1 -1
  165. package/skills/runtime-parity-verification/SKILL.md +36 -1
  166. package/skills/security-methodology/SKILL.md +23 -10
  167. package/skills/security-methodology/references/agentic-handoff-templates.md +220 -0
  168. package/skills/security-methodology/references/cross-source-matrix.md +1 -1
  169. package/skills/security-methodology/references/owasp-agentic-top-10.md +1 -1
  170. package/skills/security-scan/SKILL.md +55 -15
  171. package/skills/self-improve/SKILL.md +70 -50
  172. package/skills/silent-assumptions/SKILL.md +341 -0
  173. package/skills/silent-assumptions/references/elicitation-detectors.md +342 -0
  174. package/skills/spec-writing/SKILL.md +128 -24
  175. package/skills/spec-writing/scripts/check_checklist.py +114 -15
  176. package/skills/ui-design/SKILL.md +6 -4
  177. package/skills/ui-design/references/color-engine.md +132 -0
  178. package/skills/ui-design/references/design-preferences-from-owned-apps.md +8 -8
  179. package/skills/ui-design/references/ui-guidance-sources.md +1 -1
  180. package/skills/ui-design/references/universal-design-principles.alt.md +2 -2
  181. package/plugin-artifacts/codex/.codex-plugin/plugin.json +0 -41
  182. package/plugin-artifacts/codex/AGENTS.md +0 -560
  183. package/plugin-artifacts/codex/BUILD-ARTIFACT.md +0 -5
  184. package/plugin-artifacts/codex/LICENSE +0 -202
  185. package/plugin-artifacts/codex/README.md +0 -313
  186. package/plugin-artifacts/codex/assets/build-loop-plugin-icon.png +0 -0
  187. package/plugin-artifacts/codex/docs/agent-surface-policy.md +0 -63
  188. package/plugin-artifacts/codex/references/advisor-dispatch-ladder.md +0 -62
  189. package/plugin-artifacts/codex/references/agent-role-taxonomy.md +0 -135
  190. package/plugin-artifacts/codex/references/autonomous-and-per-commit-modes.md +0 -161
  191. package/plugin-artifacts/codex/references/autonomy-config.md +0 -231
  192. package/plugin-artifacts/codex/references/backlog-system.md +0 -285
  193. package/plugin-artifacts/codex/references/capability-routing.md +0 -231
  194. package/plugin-artifacts/codex/references/codex-subagents.md +0 -106
  195. package/plugin-artifacts/codex/references/coordination-file-template.md +0 -181
  196. package/plugin-artifacts/codex/references/coordination-rules.md +0 -552
  197. package/plugin-artifacts/codex/references/dogfood-reload-checkpoint.md +0 -112
  198. package/plugin-artifacts/codex/references/halt-and-ask-protocol.md +0 -102
  199. package/plugin-artifacts/codex/references/implementer-envelope-schema.md +0 -302
  200. package/plugin-artifacts/codex/references/intent-capability-pack.md +0 -257
  201. package/plugin-artifacts/codex/references/intent-exploration-prompts.md +0 -96
  202. package/plugin-artifacts/codex/references/leadership.md +0 -72
  203. package/plugin-artifacts/codex/references/memory-systems.md +0 -261
  204. package/plugin-artifacts/codex/references/memory.md +0 -313
  205. package/plugin-artifacts/codex/references/model-tier-mapping.md +0 -296
  206. package/plugin-artifacts/codex/references/modular-systems-pack.md +0 -96
  207. package/plugin-artifacts/codex/references/phase-1-assess.md +0 -249
  208. package/plugin-artifacts/codex/references/phase-2-plan.md +0 -86
  209. package/plugin-artifacts/codex/references/phase-3-execute.md +0 -49
  210. package/plugin-artifacts/codex/references/phase-4-review.md +0 -341
  211. package/plugin-artifacts/codex/references/phase-5-iterate.md +0 -72
  212. package/plugin-artifacts/codex/references/phase-6-learn.md +0 -58
  213. package/plugin-artifacts/codex/references/recent-design-structures.md +0 -274
  214. package/plugin-artifacts/codex/references/research-trigger-policy.md +0 -140
  215. package/plugin-artifacts/codex/references/runtime-smoke-triggers.md +0 -42
  216. package/plugin-artifacts/codex/references/self-review.md +0 -234
  217. package/plugin-artifacts/codex/references/single-writer-commit-protocol.md +0 -90
  218. package/plugin-artifacts/codex/references/task-capture-policy.md +0 -68
  219. package/plugin-artifacts/codex/references/ui-io-contract.md +0 -116
  220. package/plugin-artifacts/codex/references/ui-spotcheck-protocol.md +0 -65
  221. package/plugin-artifacts/codex/references/verify-dispatch.md +0 -85
  222. package/plugin-artifacts/codex/skills/build-loop/SKILL.md +0 -381
  223. package/plugin-artifacts/codex/skills/build-loop/detect-plugins.mjs +0 -82
  224. package/plugin-artifacts/codex/skills/build-loop/eval-guide.md +0 -65
  225. package/plugin-artifacts/codex/skills/build-loop/fallbacks.md +0 -549
  226. package/plugin-artifacts/codex/skills/build-loop/phases/fact-check.md +0 -42
  227. package/plugin-artifacts/codex/skills/build-loop/phases/ui-validation.md +0 -267
  228. package/plugin-artifacts/codex/skills/build-loop/references/advisor-dispatch-ladder.md +0 -62
  229. package/plugin-artifacts/codex/skills/build-loop/references/apple-native-planning.md +0 -439
  230. package/plugin-artifacts/codex/skills/build-loop/references/autonomous-and-per-commit-modes.md +0 -161
  231. package/plugin-artifacts/codex/skills/build-loop/references/capability-routing.md +0 -231
  232. package/plugin-artifacts/codex/skills/build-loop/references/codex-subagents.md +0 -106
  233. package/plugin-artifacts/codex/skills/build-loop/references/coordination.md +0 -161
  234. package/plugin-artifacts/codex/skills/build-loop/references/correction-aware-capture.md +0 -177
  235. package/plugin-artifacts/codex/skills/build-loop/references/experiment-results-template.md +0 -101
  236. package/plugin-artifacts/codex/skills/build-loop/references/independent-auditor.md +0 -72
  237. package/plugin-artifacts/codex/skills/build-loop/references/intent-capability-pack.md +0 -257
  238. package/plugin-artifacts/codex/skills/build-loop/references/intent-exploration-prompts.md +0 -96
  239. package/plugin-artifacts/codex/skills/build-loop/references/leadership.md +0 -72
  240. package/plugin-artifacts/codex/skills/build-loop/references/memory.md +0 -313
  241. package/plugin-artifacts/codex/skills/build-loop/references/modular-systems-pack.md +0 -96
  242. package/plugin-artifacts/codex/skills/build-loop/references/output-style.md +0 -222
  243. package/plugin-artifacts/codex/skills/build-loop/references/pay-it-forward-arch.md +0 -98
  244. package/plugin-artifacts/codex/skills/build-loop/references/phase-1-assess.md +0 -249
  245. package/plugin-artifacts/codex/skills/build-loop/references/phase-2-plan.md +0 -86
  246. package/plugin-artifacts/codex/skills/build-loop/references/phase-3-execute.md +0 -49
  247. package/plugin-artifacts/codex/skills/build-loop/references/phase-4-review.md +0 -341
  248. package/plugin-artifacts/codex/skills/build-loop/references/phase-5-iterate.md +0 -72
  249. package/plugin-artifacts/codex/skills/build-loop/references/phase-6-learn.md +0 -58
  250. package/plugin-artifacts/codex/skills/build-loop/references/recent-design-structures.md +0 -274
  251. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/ASSESSMENT.md +0 -85
  252. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/STANDALONE_TEST_RUN.md +0 -149
  253. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/01-simple-bugfix.md +0 -32
  254. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/02-ui-build-with-iteration.md +0 -48
  255. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/03-multi-failure-escalation.md +0 -60
  256. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/04-ui-build-ibr-absent.md +0 -51
  257. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/05-refactor-navgator-absent.md +0 -71
  258. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/scenarios/06-recurring-bug-debugger-absent.md +0 -52
  259. package/plugin-artifacts/codex/skills/build-loop/references/refactor-history/trace-comparison.md +0 -202
  260. package/plugin-artifacts/codex/skills/build-loop/references/self-recursive-dev.md +0 -77
  261. package/plugin-artifacts/codex/skills/build-loop/references/self-review.md +0 -234
  262. package/plugin-artifacts/codex/skills/build-loop/references/ui-io-contract.md +0 -116
  263. package/plugin-artifacts/codex/skills/build-loop/references/verify-dispatch.md +0 -85
  264. package/plugin-artifacts/codex/skills/build-loop/scanners/audit-design-rules.mjs +0 -476
  265. package/plugin-artifacts/codex/skills/build-loop/scanners/require-visual-evidence.mjs +0 -239
  266. package/plugin-artifacts/codex/skills/build-loop/templates/backlog-item.md +0 -35
  267. package/plugin-artifacts/codex/skills/build-loop/templates/codex-worker-prompt.md +0 -100
  268. package/plugin-artifacts/codex/skills/build-loop/templates/ui-subagent-prompt.md +0 -179
  269. package/plugin-artifacts/codex/skills/build-loop/templates/ux-fix-plan.md +0 -40
  270. package/scripts/build_codex_plugin_artifact.py +0 -321
@@ -35,6 +35,41 @@ This is stronger than "did it render" (which UI validators check). It is also st
35
35
  5. **Encode it as a per-repo smoke** (a script that returns non-zero on divergence). **Validate the smoke is real**: confirm it returns non-zero on a known-broken state, not just zero on green — a check that cannot fail is worthless.
36
36
  6. **Gate on it**: run the smoke before any "done" claim. Never substitute compile-green, a passing unit test, or a screenshot.
37
37
 
38
+ ## Doc ↔ interface parity (documented CLIs, tools & flows)
39
+
40
+ A second parity gap, same shape: the **documented interface diverges from the
41
+ runtime interface**, and the CLI **silently accepts malformed input**. A green
42
+ unit-test suite over the core logic structurally **cannot** catch either — tests
43
+ exercise the functions, not the CLI surface or the commands the docs tell a user
44
+ to run. A tool/CLI/flow is not "done" until:
45
+
46
+ 1. **Every command in a flow doc runs against the live CLI.** Extract each
47
+ documented command (fenced shell blocks in the flow's `.md`) and validate its
48
+ subcommand + every `--flag` against the real interface — `--help` for a
49
+ Python/argparse CLI (side-effect-free), the parsed-flags list in source for a
50
+ node CLI. A documented flag/subcommand that doesn't exist is a FAIL. (This is
51
+ the "doc says `--params`, the CLI never had it" defect.)
52
+ 2. **Every CLI boundary rejects malformed input.** Feed each command a typo'd
53
+ sub-argument / unknown enum value and assert a **nonzero exit with an error** —
54
+ never a deadlock, never a silent default substitution. (A typo'd argument that
55
+ auto-creates a junk record and hangs the loop, or a bad value silently swapped
56
+ for a default, both ship a tool the user can't trust.)
57
+
58
+ **Validate the check the same way step 5 demands** — mutate the real files (a
59
+ bogus doc flag; a disabled validator) and confirm the check FAILS; a check that
60
+ can't fail is worthless. A subtle trap seen in practice: input-validation cases
61
+ that run against an **absent** state file pass even with validation disabled,
62
+ because the missing-file crash also exits nonzero — the oracle confounds
63
+ "rejected" with "crashed." Run the malformed-input cases against a **real, valid**
64
+ state so a reject is the ONLY cause of a nonzero exit.
65
+
66
+ **Reusable exemplar:** groundwork `designer/conformance/flow_cli_check.py` — scans
67
+ `references/*.md` + `SKILL.md`, validates every documented `python3 -m …` / `node
68
+ …` command against the live CLI, feeds each a malformed value, and
69
+ `--selftest`-mutation-proves it bites. Wired to fire via `scripts/check.sh` →
70
+ `npm test` + a committed `.githooks/pre-push` (a check that only runs when recalled
71
+ is dormant — put it in the gate).
72
+
38
73
  ## Anti-patterns (each one shipped a real bug)
39
74
 
40
75
  - "Build is green, committed — done." → compile ≠ runtime; never exercised the flow.
@@ -45,7 +80,7 @@ This is stronger than "did it render" (which UI validators check). It is also st
45
80
  ## Build-loop integration
46
81
 
47
82
  - **Phase 4 Review sub-step B / Phase 5 Iterate**: when `uiTarget != null` OR the diff touches a user-visible flow, a runtime parity check is **required**. The existing drivers do the probing — web: `ui-validator`; macOS: `native-ax-driver` / IBR `scan_macos`; iOS: `idb`. THIS skill adds the missing step: **cross-check the probe against source-of-truth**, and keep a validated per-repo smoke.
48
- - **Phase 4 sub-step G (`verification-before-completion`)**: for app/UI changes, "confirm output" includes the runtime parity smoke, not only test/build/lint.
83
+ - **Phase 4 sub-step G (`verification-before-completion`)**: for app/UI changes, "confirm output" includes the runtime parity smoke, not only test/build/lint. For a **CLI / tool / documented-flow** change, it also includes the doc↔interface parity smoke (every documented command runs; every boundary rejects malformed input), likewise validated by mutation.
49
84
  - The `verify` skill ("run the app and observe behavior") is the manual counterpart; this skill is the automatable, source-of-truth-anchored form.
50
85
 
51
86
  Origin lesson: build-loop-memory `lessons/2026-06-08-pattern-runtime-ui-source-of-truth-parity-verification.md` (easy-terminal launch/no-pane bug — UI projection diverged from daemon, missed across a whole UI pass because verification was compile-green + screenshot-only).
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: build-loop:security-methodology
3
- description: "Use when a build crosses a security boundary (auth, authz, secrets handling, network exposure, persistence of sensitive data) or when Phase 1 Assess flags `triggers.riskSurfaceChange: true`. Provides the threat-modeling and scoped-permission methodology for build-loop's security-reviewer agent."
3
+ description: "Threat-modeling and scoped-permission methodology for judgment-level security review, consumed by the security-reviewer agent. Use when the user asks to \"threat model this\" or \"review this for security issues\" beyond an automated scan, or a build touches auth/authz/secrets/network exposure. Not for the deterministic automated scan (use `security-scan`)."
4
4
  version: 0.1.0
5
5
  user-invocable: false
6
6
  ---
@@ -56,24 +56,21 @@ If you're grading a diff (as `security-reviewer` does):
56
56
  - Model theft (LLM10) at the deployment level. Agent-builder-style apps don't host weights.
57
57
  - CBRN, environmental, IP, obscene, and violent content from NIST 600-1 — those are policy/legal concerns, not engineering. They're referenced for completeness in `nist-600-1-mapping.md` but not deeply mapped.
58
58
  - The full MITRE ATLAS taxonomy. ATLAS has 16 tactics and 84 techniques as of v5.1.0 (Nov 2025) plus 14 agentic additions (Feb 2026). Re-authoring it would duplicate the project; the starter file points at the source.
59
- - Adversarial test corpora. Red-team corpora are out of build-loop's scope per `~/dev/research/topics/product-dev/product-dev.agentic-systems-original-synthesis.md` recommendation #4.
59
+ - Adversarial test corpora. Red-team corpora are out of build-loop's scope per "Agentic Systems — Original Synthesis" (private research note — substance summarized here) recommendation #4.
60
60
 
61
61
  ## Where these references come from
62
62
 
63
63
  This skill packages and cross-maps four authoritative sources. Each reference file inside `references/` cites its own source. The canonical research file with full citation, retrieval dates, source tier, and the original cross-source matrix lives at:
64
64
 
65
- - `~/dev/research/topics/product-dev/product-dev.agentic-systems-security-references.md` — the verified canon. T1 sources throughout (OWASP project pages, NIST publication, MITRE ATLAS, Cisco DefenseClaw repo).
65
+ - "Agentic Systems — Security References" (private research note substance summarized here) — the verified canon. T1 sources throughout (OWASP project pages, NIST publication, MITRE ATLAS, Cisco DefenseClaw repo).
66
66
 
67
67
  The companion **gap analysis** that motivated shipping these artifacts inside build-loop:
68
68
 
69
- - `~/dev/research/topics/product-dev/product-dev.agentic-systems-original-synthesis.md` — recommendations table (security-related: #4 red-team playbook, #10 cost-budget enforcement, plus the new "govern/inspect/prove" recommendation).
69
+ - "Agentic Systems — Original Synthesis" (private research note substance summarized here) — recommendations table (security-related: #4 red-team playbook, #10 cost-budget enforcement, plus the new "govern/inspect/prove" recommendation).
70
70
 
71
- The agent-builder methodology that this skill cross-references when classifying agentic risks (autonomy ladder A0–A4, permission tiers T0–T5, role decomposition):
71
+ The agent-builder methodology that this skill cross-references when classifying agentic risks (autonomy ladder A0–A4, permission tiers T0–T5, role decomposition) — "Agentic Product Development — Synthesis" (agent-builder plugin methodology, file 13; private research note — substance summarized here) and its companion "15 template files" set (`tool-contract.md`, `agent-manifest.md`, `guardrail.md`, `system-boundary.md`, `flow-topology.md`, `role-card.md` are the security-relevant subset; private, not shipped in this repo).
72
72
 
73
- - `~/dev/git-folder/agent-builder/plugin/references/methodology/13-agentic-product-dev-synthesis.md` — single canonical synthesis, A0–A4 autonomy ladder.
74
- - `~/dev/git-folder/agent-builder/plugin/references/templates/agentic-handoff/` — 15 template files; the security-relevant subset is `tool-contract.md`, `agent-manifest.md`, `guardrail.md`, `system-boundary.md`, `flow-topology.md`, `role-card.md`.
75
-
76
- If the agent-builder plugin is not installed locally, the research-folder pointer above is sufficient — file 13's substance is reproduced in the addendum-v2 research file (`~/dev/research/topics/product-dev/product-dev.agentic-systems-template-pack-addendum-v2.md`).
73
+ **Working fallback (always available, no external plugin required):** `references/agentic-handoff-templates.md` — vendored into this repo so the skill has a real fallback on a fresh install. It reproduces the permission-tier table, the A0–A4 ladder, the default role-decomposition table, and the machine-readable YAML templates (role-card, tool-contract, guardrail, system-boundary, flow-topology, agent-output-contract) directly, with provenance notes. If the agent-builder plugin is installed locally, prefer its live templates; otherwise this file is the canon.
77
74
 
78
75
  ## Relationship to other build-loop skills
79
76
 
@@ -94,6 +91,9 @@ Phase 1 Assess sets the flag when any of these are introduced or modified:
94
91
  - An auth, authz, identity, or permission boundary change (LLM07, ASI03, A01).
95
92
  - An external API call introduced by the build (LLM05, ASI04, A06, A10).
96
93
  - Handling of new user data classes — PII, financial, health, credentials, regulated records (LLM06, NIST Data Privacy).
94
+ - A lifecycle-hook registration or editor/agent auto-load surface — `.claude/settings.json`, `.codex/hooks.json`, `.cursor/hooks.json`, `hooks/*.json`, githooks, launchd/cron plists (ASI02, A06 supply chain).
95
+ - An installer or provisioner path — anything that downloads, chmods, or executes a binary, or builds source, reachable from a hook or startup path (A06, ATLAS supply chain).
96
+ - Code that interpolates stored or descriptor-supplied strings into shell commands or into model context — prompt-to-shell and prompt-to-context render paths (LLM01, ASI05, A03).
97
97
 
98
98
  The orchestrator scans the goal text for keywords matching these classes and inspects the planned file set. Either signal flips the trigger; the trigger is sticky for the rest of the build.
99
99
 
@@ -106,9 +106,22 @@ The orchestrator scans the goal text for keywords matching these classes and ins
106
106
 
107
107
  ## Required sweeps for app+DB security passes (LO-5) + risk-presentation default (SC-1)
108
108
 
109
- **Two sweeps are REQUIRED, not optional, whenever a pass covers an app that has both HTTP routes and a database** — access-control review and data-integrity review are different lenses and neither is a superset of the other (proven both ways, atomize-ai 2026-06-30: an OWASP/access-control review missed a destructive `onDelete: Cascade`; a schema/secrets DB-RCA missed 4 unauthenticated mutation routes + a fail-open auth bug).
109
+ **Two sweeps are REQUIRED, not optional, whenever a pass covers an app that has both HTTP routes and a database** — access-control review and data-integrity review are different lenses and neither is a superset of the other (proven both ways in a private-app stress test on 2026-06-30: an OWASP/access-control review missed a destructive `onDelete: Cascade`; a schema/secrets DB-RCA missed 4 unauthenticated mutation routes + a fail-open auth bug).
110
110
 
111
111
  1. **Route-auth enumeration** — walk **every** `app/api/**/route.ts` (or the framework equivalent) handler; confirm each mutating/DDL endpoint has an auth guard, AND that the guard **fails closed** when its secret env is unset (the `token !== process.env.X` bypass when `X` is undefined → `undefined !== undefined` is false → passes). Owned by `security-reviewer` (OWASP A01). Do not sample — enumerate.
112
112
  2. **Destructive-FK / data-integrity sweep** — grep the schema for `onDelete: Cascade` (and `SetNull`), missing FK indexes, and merge/delete paths that destroy rather than reassign. Owned by `database-assessor`. A cascade that silently deletes user data is a security/integrity finding even when every route is authed.
113
113
 
114
+ ## Repo-trust audit sweep (from the Lattice audit of agent-rally-point, issue #52)
115
+
116
+ An independent external audit found 3 Critical findings in agent-rally-point that this canon's OWASP/ATLAS grading never surfaced. The gap was the lens, not the frameworks. When a build touches any of the three new trigger signals above — hook registrations, installers, or string-to-shell/context render paths — the review MUST also run these four checks:
117
+
118
+ 1. **Trust-on-clone.** Ask what executes or gains authority when someone merely opens or trusts the repo: auto-loaded hooks, provisioners reachable from startup, tracked binaries, symlinks, SVG payloads, git bundles. Grade the repo as an attack vector, not just the diff.
119
+ 2. **Doc-claims vs implementation.** Extract security and behavior claims from docs ("does not install hooks", "proves the plan is safe", "the gate blocks X") and grade each against code. Fact-checking rendered data does not cover this; claims need their own pass.
120
+ 3. **False security boundaries.** For every gate, approval flow, or "blocked" message: name what it actually interposes on. A control that observes an event stream but cannot stop the child process is telemetry, not a boundary.
121
+ 4. **Render-path tracing.** Follow stored, descriptor-supplied, or peer-authored strings to every point where they become shell text or model context. Each such path needs quoting/allowlisting plus an adversarial test that proves a hostile string is rejected or neutralized.
122
+
123
+ Report structure for these findings, borrowed from the exemplar (`gh issue view 52 -R tyroneross/agent-rally-point`): stable per-project finding IDs, severity, file:line citation for every claim, a per-finding required fix, plus two honesty sections — "positive containment observations" (explicitly scoped as not offsetting findings) and "unreviewed surface" (what the review skipped and why). The unreviewed-surface section is mandatory; a review that doesn't state its blind spots overstates its coverage.
124
+
125
+ Assume at least two untrusted actors when grading multi-agent or shared-repo tooling: a second contributor to the repo, and a same-UID local process. "Single operator on one Mac" is a deployment fact, not a threat model — write the actual trust model down.
126
+
114
127
  **Risk-presentation default (SC-1 — bounded-risk user posture).** Lead every security finding with a **blast-radius verdict** (who/what is reachable, and from where — public vs. private-and-unpushed vs. inert-behind-a-schema-gate). When exposure is **proven contained**, present hardening (rotation, revokes, extra gates) as **recommended-but-deferrable**, not a hard blocker. Hard-gate ONLY when the blast radius is **unbounded, public, or unproven**. Rationale: this operator gates hardening on demonstrated blast radius, not on the existence of a risk — forcing rotation when exposure is provably private wastes cycles. This is a *presentation/gating* default, never a reason to skip a sweep or under-report a finding. See user-preference `feedback_security_blast_radius_first`.
@@ -0,0 +1,220 @@
1
+ <!-- SPDX-FileCopyrightText: 2025-2026 Tyrone Ross, Jr <46267523+tyroneross@users.noreply.github.com> | SPDX-License-Identifier: Apache-2.0 -->
2
+
3
+ # Agentic system handoff — permission tiers, autonomy ladder, role decomposition
4
+
5
+ Vendored substance from the agent-builder methodology (private research note — substance summarized here). This file exists so `skills/security-methodology/SKILL.md` has a working fallback on a fresh install where the `agent-builder` plugin is not present: rather than pointing at a second maintainer-only path, the load-bearing tables and templates are reproduced directly below.
6
+
7
+ ## Permission tiers (T0–T5)
8
+
9
+ Used when classifying what a tool or agent action is allowed to do, and what approval it requires by default.
10
+
11
+ | Tier | Capability | Examples | Default approval |
12
+ |---|---|---|---|
13
+ | T0 | No tool access | Draft text only | No approval |
14
+ | T1 | Read-only local context | Read project docs, inspect state | No approval if data is in scope |
15
+ | T2 | Read external systems | Search docs, query CRM, read GitHub issues | Approval depends on data sensitivity |
16
+ | T3 | Write reversible changes | Create draft, stage file, update non-public record | Usually preview or undo required |
17
+ | T4 | External communication | Send email, post Slack, create ticket, comment on PR | Human approval required |
18
+ | T5 | Irreversible or high-impact action | Delete data, deploy production, spend money, change permissions | Strong human approval required |
19
+
20
+ ## Autonomy ladder (A0–A4)
21
+
22
+ The canonical 5-level ladder (v2; supersedes an earlier 6-level A0–A5 variant that split "draft only" into two levels).
23
+
24
+ | Level | Name | Agent may do | Approval required for |
25
+ |---|---|---|---|
26
+ | A0 | Draft only | Summarize, classify, draft, critique, recommend. | Any decision, write action, external call, or implementation. |
27
+ | A1 | Reversible decisions | Choose low-risk defaults, mark assumptions, proceed on reversible choices. | Low-reversibility decisions, sensitive data, external services, paid resources. |
28
+ | A2 | Bounded execution | Implement approved P0 scope in a sandbox, run tests, update local files, report. | Deployment, paid services, destructive actions, secrets, external communications. |
29
+ | A3 | Controlled production action | Execute approved production tasks under guardrails and audit. | Migrations, deletion, permission changes, user-impacting changes, policy changes. |
30
+ | A4 | Autonomous operation | Monitor and optimize within explicit policy, budgets, and rollback limits. | Material scope, policy, data, architecture, or cost changes. |
31
+
32
+ Rationale: excessive agency — an LLM-based system performing damaging actions because it has too much functionality, permission, or autonomy — is one of the clearest agentic-system risk classes (OWASP LLM08, `genai.owasp.org/llmrisk2023-24/llm08-excessive-agency/`).
33
+
34
+ ### Default autonomy by phase
35
+
36
+ | Phase | Default autonomy | Rationale |
37
+ |---|---|---|
38
+ | Sparse intake | A1 | The agent may infer obvious defaults but must log assumptions. |
39
+ | Product spec generation | A1 | Product intent and scope require human validation. |
40
+ | UX and requirements draft | A1-A2 | Drafts allowed; P0 scope reviewed. |
41
+ | Architecture decisions | A0-A1 | Lower-reversibility; ADRs required. |
42
+ | Data and permissions | A0-A1 | Sensitive data and retention need explicit constraints. |
43
+ | Coding | A2 | Safe after approved handoff and sandbox boundaries. |
44
+ | Testing and evaluation | A2 | Run tests, lint, report evidence. |
45
+ | Deployment | A0-A2 | Depends on environment, user impact, rollback, approvals. |
46
+ | Production operation | A0-A3 | Requires governance, monitoring, incident response, override. |
47
+
48
+ ### Ask-before policy
49
+
50
+ An agent must ask before:
51
+
52
+ - Storing personal, financial, medical, legal, confidential, regulated, or credential-like data.
53
+ - Selecting a paid external service or creating recurring operational cost.
54
+ - Introducing distributed services, microservices, irreversible migrations, or complex infrastructure.
55
+ - Removing, weakening, or redefining a P0 requirement.
56
+ - Deploying to a user-facing or production-like environment.
57
+ - Executing delete, overwrite, migration, permission, or credential actions.
58
+ - Taking actions that affect money, health, legal status, security posture, customer communications, or contractual commitments.
59
+
60
+ ## Default agent role decomposition
61
+
62
+ | Agent | Primary job | Key inputs | Key outputs | Default autonomy |
63
+ |---|---|---|---|---|
64
+ | Intake / Triage Agent | Convert sparse human input into normalized product primitives. | Intake answers, prior project context, examples. | Product primitives, confidence map, open questions. | A1 |
65
+ | Product Strategy Agent | Define user outcomes, North Star, scope, non-goals, and success metrics. | Product primitives, user context, constraints. | Product brief, outcome map, scope recommendation. | A1 |
66
+ | User / JTBD Agent | Infer jobs, pains, workflow triggers, success moments, and user constraints. | Intake, interviews, examples, archetypes. | Persona and JTBD brief, pain/opportunity map. | A1 |
67
+ | Requirements Agent | Convert goals into epics, stories, requirements, acceptance criteria, and test hooks. | Product brief, user context, UX constraints. | Requirements doc, story map, acceptance criteria. | A1-A2 |
68
+ | UX Blueprint Agent | Define flows, screens, navigation, content intent, empty states, and error states. | Personas, requirements, design constraints. | UX blueprint, screen inventory, flow specs. | A1-A2 |
69
+ | Architecture Agent | Recommend technical architecture and major architectural decision records. | Requirements, quality attributes, constraints, decision criteria. | Architecture recommendation, ADRs, implementation plan. | A0-A1 |
70
+ | Data / Integration Agent | Define entities, permissions, integrations, lifecycle, and data-handling assumptions. | Requirements, target systems, security constraints. | Data semantics, integration specs, permission map. | A0-A1 |
71
+ | Security / Compliance Agent | Identify sensitive data, misuse risks, guardrails, approval boundaries, and policy constraints. | Data spec, architecture, domain context. | Risk register, security checklist, ask-before rules. | A0 |
72
+ | Spec Review Agent | Check ambiguity, traceability, scope, assumptions, risk, and handoff readiness. | Full draft pack. | Spec lint result, traceability gaps, revision requests. | A1 |
73
+ | Coding Agent | Build implementation, tests, docs, setup, and local run instructions. | Approved handoff pack, repository, build plan. | Working code, tests, README, completion report. | A2 |
74
+ | QA / Evaluation Agent | Verify behavior against requirements, tests, and quality bars. | Code, requirements, test plan, traces. | Test results, defect log, traceability report. | A2 |
75
+ | Release / Completion Agent | Package output, known limitations, next iteration, and learning updates. | QA results, implementation notes, unresolved risks. | Release notes, known limitations, next-step plan. | A1-A2 |
76
+
77
+ ## Machine-readable templates
78
+
79
+ ### System boundary
80
+
81
+ ```yaml
82
+ system_boundary:
83
+ agent_system_name:
84
+ primary_mission:
85
+ users_served:
86
+ in_scope_tasks:
87
+ out_of_scope_tasks:
88
+ external_tools:
89
+ external_agents:
90
+ human_roles:
91
+ data_sources:
92
+ systems_of_record:
93
+ actions_that_change_the_world:
94
+ ```
95
+
96
+ ### Flow topology
97
+
98
+ ```yaml
99
+ flow_topology:
100
+ pattern: "sequential | parallel | router | orchestrator_worker | evaluator_optimizer | interactive | hybrid"
101
+ why_this_pattern:
102
+ state_owner:
103
+ stop_condition:
104
+ retry_policy:
105
+ human_checkpoint_policy:
106
+ parallel_branches:
107
+ - branch_name:
108
+ input:
109
+ output:
110
+ merge_rule:
111
+ feedback_loops:
112
+ - evaluator:
113
+ criterion:
114
+ max_iterations:
115
+ escalation:
116
+ ```
117
+
118
+ ### Role-card (agent-manifest equivalent)
119
+
120
+ ```yaml
121
+ agent_id: "AGENT-001"
122
+ name: "<Agent name>"
123
+ mission: "<One-sentence mission>"
124
+ primary_outputs:
125
+ - "<artifact>"
126
+ input_artifacts:
127
+ - "<file or object>"
128
+ allowed_decisions:
129
+ - "<decision this agent may make>"
130
+ must_escalate:
131
+ - "<decision requiring human or orchestrator approval>"
132
+ forbidden_actions:
133
+ - "<action>"
134
+ tools_allowed:
135
+ - tool_name: "<tool>"
136
+ permission: "read | write | execute | approve-required"
137
+ quality_bar:
138
+ - "<acceptance criterion for this agent's work>"
139
+ completion_signal: "<what marks this agent's work complete>"
140
+ ```
141
+
142
+ ### Tool contract
143
+
144
+ ```yaml
145
+ tool_contract:
146
+ tool_name:
147
+ purpose:
148
+ owner:
149
+ type: "function | MCP | hosted | shell | browser | external_api | agent"
150
+ input_schema:
151
+ output_schema:
152
+ allowed_actions:
153
+ forbidden_actions:
154
+ permission_tier:
155
+ auth_scope:
156
+ data_access_scope:
157
+ rate_limits:
158
+ timeout:
159
+ side_effects:
160
+ requires_human_approval:
161
+ approval_preview_fields:
162
+ rollback_strategy:
163
+ audit_log_fields:
164
+ failure_modes:
165
+ test_cases:
166
+ ```
167
+
168
+ MCP tools expose external systems with unique names, input schemas, optional output schemas, and annotations; the MCP spec emphasizes input validation, access controls, rate limits, output sanitization, user confirmation for sensitive operations, timeouts, and usage logging (`modelcontextprotocol.io/specification/2025-11-25/server/tools`).
169
+
170
+ ### Guardrail
171
+
172
+ ```yaml
173
+ guardrail_id: "GR-001"
174
+ name: "Sensitive Data Storage Guardrail"
175
+ applies_to:
176
+ - "Data Agent"
177
+ - "Coding Agent"
178
+ trigger:
179
+ - "Artifact mentions PII, financial data, health data, legal data, credentials, or regulated records."
180
+ check:
181
+ - "Is storage necessary for P0 workflow?"
182
+ - "Is retention defined?"
183
+ - "Are permissions defined?"
184
+ action:
185
+ - "If missing, block build handoff and create OQ."
186
+ severity: "high"
187
+ escalation: "human approval required"
188
+ ```
189
+
190
+ ### Agent output contract
191
+
192
+ ```yaml
193
+ agent_output:
194
+ agent_id: "<agent>"
195
+ task_id: "<task>"
196
+ status: "complete | partial | blocked | failed"
197
+ artifacts_created:
198
+ - "<artifact_id>@<version>"
199
+ decisions_made:
200
+ - "DEC-001"
201
+ assumptions_added:
202
+ - "ASSUMP-001"
203
+ risks_added:
204
+ - "RISK-001"
205
+ tests_or_checks_run:
206
+ - "CHECK-001"
207
+ blockers:
208
+ - "<blocker or none>"
209
+ confidence: "low | medium | high"
210
+ next_recommended_agent: "<agent or none>"
211
+ ```
212
+
213
+ ## Provenance
214
+
215
+ This file reproduces the load-bearing tables and YAML templates from two private research notes (not shipped in this repo, not required to use this file):
216
+
217
+ - "Agentic Product Development — Synthesis" (agent-builder plugin methodology, file 13) — role-card pattern, canonical A0–A4 autonomy ladder, permission-tier framing.
218
+ - "Addendum v2: LLM-Readable Templates for Building Effective AI Agentic Systems" (private research note) — the T0–T5 permission-tier table, the A0–A4 revision, default-agent-role-decomposition table, and the machine-readable YAML templates above, transcribed verbatim from that note's §"Tool permissions and autonomy", §"Agent autonomy model — A0–A4", §"Default agent role decomposition", and §"Machine-readable templates to merge into ProductPilot".
219
+
220
+ Both notes cite Anthropic, OpenAI Agents SDK, LangGraph, MCP spec, and OWASP LLM08 as their T1/T2 sources for the underlying claims (excessive agency, context engineering, tool-as-contract, durable state); this file does not re-verify those citations independently — treat table content here as a working reference, not a substitute for reading the primary sources when precision on a specific claim matters.
@@ -6,7 +6,7 @@ Single decision table mapping each risk class to its OWASP LLM ID, OWASP Agentic
6
6
 
7
7
  **Use.** This is the load-bearing artifact of the security-methodology skill. The `security-reviewer` agent cites a row from this matrix in every finding. The `defenseclaw-bridge` skill maps from this matrix to DefenseClaw config rows.
8
8
 
9
- **Source.** Adapted from `~/dev/research/topics/product-dev/product-dev.agentic-systems-security-references.md` §"Cross-source map: where each risk lives". The research file is the canonical citation trail; this file is the build-loop-internal copy.
9
+ **Source.** Adapted from "Agentic Systems — Security References" (private research note — substance summarized here), §"Cross-source map: where each risk lives". This file is the build-loop-internal copy; it does not depend on the research note being present.
10
10
 
11
11
  ## Reading conventions
12
12
 
@@ -154,4 +154,4 @@ Three of the top four risks — **ASI02** (Tool Misuse), **ASI03** (Privilege Ab
154
154
  ## Verification status
155
155
 
156
156
  - ✅ ASI01–ASI10 verified (T1, OWASP GenAI Security Project release page; secondary confirmation via Aikido enumeration of the 2026 list).
157
- - The agent system that drove this skill's creation flipped ASI02–ASI06 from `[INFERRED]` to verified during this build — see `~/dev/research/topics/product-dev/product-dev.agentic-systems-security-references.md` §Verification status for the trail.
157
+ - The agent system that drove this skill's creation flipped ASI02–ASI06 from `[INFERRED]` to verified during this build — see "Agentic Systems — Security References" (private research note — substance summarized here), §Verification status, for the trail.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: build-loop:security-scan
3
- description: "Run before any feature push, during Phase 2 planning, or whenever an agent wants a security pass. Executes a deterministic, model-independent OWASP scanner (scripts/security_scan.py) over the repo — catches the common greppable classes: secrets in source, secrets/tokens in logs, SQL/command/eval injection, public mutating endpoints without rate limiting, missing security headers, prompt-injection sinks — and maps each finding to OWASP Web/LLM/Agentic IDs. The judgment layer (authz logic, tenant scoping, tool-permission scope, agent goal-drift) escalates to the security-reviewer agent + the security-methodology canon."
4
- version: 0.1.0
3
+ description: "Run a deterministic, model-independent OWASP scan for secrets, injection, auth gaps, and unsafe AI tool calls, mapped to OWASP Web/LLM/Agentic IDs. Use before any push or deployment, or whenever an automated security pass is wanted. Not for business-rule/judgment-level review (use `security-methodology` + the security-reviewer agent)."
4
+ version: 0.2.0
5
5
  user-invocable: false
6
6
  ---
7
7
 
@@ -18,38 +18,78 @@ This skill RUNS: a stdlib-only Python scanner, no model, no network, no Fable de
18
18
  ## When to run
19
19
 
20
20
  1. **Before any feature push (always-on gate).** `scripts/hooks/pre_bash_dispatch.sh` routes `git push` through the scanner and HARD-BLOCKS the push on HIGH+ findings (mirrors the commit auditor). Invoke it explicitly too when pushing outside a build-loop project.
21
- 2. **During Phase 2 planning.** Run it over the files/area you're about to change to surface existing security debt before adding to it.
22
- 3. **Whenever any agent wants a security pass.** It's a plain script any orchestrator or agent can call it (agent-callable; not a user-facing slash command, so `user-invocable: false`).
21
+ 2. **Before any DEPLOYMENT (always-on gate).** `git push` is only one way code reaches users. The same hook classifies the command with `deployment_policy.is_deploy_like()` and full-scans before `vercel deploy`, `wrangler deploy`, `wrangler pages deploy`, `flyctl deploy`, `railway up`, `render deploy`, `supabase functions deploy`, `eas submit`, `fastlane`, `kubectl apply`, `helm`, `terraform apply`, `pulumi up`, `gcloud`/`aws`/`sam`/`cdk` deploys, `gh workflow run`, `gh release create`, and `npm publish`. A deploy ships the whole tree, so this path never uses `--diff` — every file gets every check.
22
+ 3. **During Phase 2 planning.** Run it over the files/area you're about to change to surface existing security debt before adding to it.
23
+ 4. **Whenever any agent wants a security pass.** It's a plain script — any orchestrator or agent can call it (agent-callable; not a user-facing slash command, so `user-invocable: false`).
24
+
25
+ ## Coverage model — deep on the change, sweep everywhere else
26
+
27
+ `--diff` alone scans only what changed, which leaves the rest of the app unchecked on every ship. `--spot-check` closes that without making the gate unusable:
28
+
29
+ - **Changed files → every check, fully enforced.** A HIGH here blocks.
30
+ - **Unchanged files → the high-confidence subset** (secrets, secret-in-logs, injection, object-level authz, auth guards, client-exposed keys, token hygiene, CORS), tagged `scope: "spot"` and reported as **advisory**. Only a CRITICAL among them blocks.
31
+
32
+ The asymmetry is deliberate. Blocking a ship on a stranger's years-old MEDIUM is how a gate becomes something people route around; a CRITICAL in any file is a reason not to ship regardless of who wrote it. The absence-of-control checks (rate limiting, headers, prompt hygiene, mass assignment) are excluded from the sweep — they fire on almost every older file and would bury the signal.
33
+
34
+ The pre-push hook passes `--spot-check` automatically. The report header names the sweep and the summary separates advisory from blocking counts, so widened scope is visible rather than implied.
23
35
 
24
36
  ## Run it
25
37
 
26
38
  ```
27
- python3 "${CLAUDE_PLUGIN_ROOT}/scripts/security_scan.py" --path <repo> [--fail-on {low,medium,high,critical}] [--json]
39
+ python3 "${CLAUDE_PLUGIN_ROOT}/scripts/security_scan.py" --path <repo> [--fail-on {low,medium,high,critical}] [--json] [--diff <ref>] [--spot-check] [--exclude <glob>] [--tracked-only]
28
40
  ```
29
41
 
30
42
  - **Exit 0** = nothing at/above threshold · **Exit 1** = found something at/above threshold (this is what gates the pre-push hook).
31
43
  - Default threshold is **HIGH**. `--json` emits machine output.
32
- - Suppress a *confirmed* false positive with an inline `// nosec: <reason>` (JS/TS) or `# nosec: <reason>` (Python/shell) on the flagged line.
44
+ - **`--diff <ref>`** (opt-in) scopes the scan to files changed in `<ref>..HEAD` — scan what's being pushed, not the whole tree, so pre-existing unrelated debt doesn't block an unrelated push. Fail-safe: a bad ref / non-git path falls back to a full scan (never scans less than intended); an empty range scans nothing (exit 0). Delta discovery uses `git diff --name-only -z --relative` so non-ASCII/quoted filenames and subdirectory `--path` roots are handled correctly; a belt-and-braces guard also full-scans if the delta named changed files but the walk matched none. The pre-push hook derives `<ref>` from the upstream tracking branch (`@{u}`), and applies it **only to a plain current-branch → tracking push**: any refspec (`origin main:release`), non-tracking remote (`git push backup main`), or whole-repo flag (`--mirror`/`--all`/`--tags`) omits `--diff` and full-scans (fail-safe: never scan less than intended). No upstream → whole-repo scan.
45
+ - The named set is the UNION of `git diff --name-only <ref>..HEAD` and `git log --name-only <ref>..HEAD`. The second is load-bearing: `git diff` compares the two endpoint trees, so a file added in one commit and removed in a later one inside the same range is named by neither — yet `git push` ships its blob. Before 2026-09-05 such a file surfaced only as an advisory SPOT finding, so `commit a secret, then git rm --cached it` cleared the gate on the very push carrying it.
46
+ - **Scope limitation (working-tree vs pushed blob):** `--diff` names files, then reads each one's **current working-tree content**, not the exact pushed blobs. So a secret whose file still exists is caught, but one dirty-edited out of the working tree before the push still escapes. Shared with the pre-delta whole-tree gate. A future follow-up could read blobs directly (per-commit `git show`); tracked as backlog, not yet implemented.
47
+ - **`--exclude <glob>`** (opt-in, repeatable) skips any file whose repo-relative path matches the fnmatch glob, in both full and `--diff` mode. The hook reads these from `.build-loop/config.json` → `securityScan.excludeGlobs` (best-effort; absent = no-op). The report always names the active globs and the count of files they removed, and a bare `*`/`**` (or a glob removing >50% of candidates) emits a stderr warning — an over-broad glob cannot silently bypass the whole scan unnoticed.
48
+ - **`--tracked-only`** (opt-in) drops UNTRACKED files from the candidate set. The **push** gate passes it, because a push ships committed content only; the **deploy** gate does not, because `vercel deploy` and friends upload the working tree, where an untracked file genuinely ships. Named failure (2026-09-05): 54 of the 57 HIGH findings that hard-blocked a push lived in untracked `.designdoc/*.html` mockups that could never reach the remote.
49
+ - With neither `--diff` nor `--exclude`, behavior is unchanged (whole-tree, git-tracked files).
50
+ - Suppress a *confirmed* false positive with an inline `// nosec: <reason>` (JS/TS), `# nosec: <reason>` (Python/shell), or bandit's `# nosec B608` on the flagged line. A bare `# nosec` (no colon, no ID) does not suppress.
51
+ - **Suppression is LINE-scoped, not check-scoped.** `suppressed()` receives only the line, never a check id, so either spelling silences *every* check on that line — a bandit ID is a marker, not a scope. `AWS = "AKIA…" # nosec B608` silences the hardcoded-secret finding even though B608 is bandit's SQL-injection test. `# nosec:` with nothing after the colon also suppresses, so the reason is a convention the pattern does not enforce. Accepted IDs are `B1xx`–`B7xx`, bandit's own range.
33
52
 
34
53
  ## What it catches (DET layer — the greppable 80/20)
35
54
 
55
+ Checks A–G live in `scripts/security_scan.py`; the API and AI-boundary checks H–N live in `scripts/security_checks_api.py`. Shared primitives are in `scripts/security_common.py`.
56
+
57
+ ### Content classes (A–G)
58
+
36
59
  | Check | Severity | OWASP |
37
60
  |---|---|---|
38
- | Hardcoded provider keys / PEM private keys / `SECRET=…literal`; git-tracked `.env`/`.dev.vars` | HIGH | A07 / LLM06 |
39
- | **Secret-in-logs** — `console/print` of a token/secret var or a token-labeled response body | HIGH | A09 / LLM06 |
40
- | SQL built via string interpolation; `eval`/`new Function`; `child_process.exec`+concat; `shell=True`; `innerHTML=`/`dangerouslySetInnerHTML` with a var | HIGH | A03 / LLM05 / ASI05 |
41
- | `fetch`/`requests` with a non-constant URL (SSRF) | MEDIUM | A10 |
42
- | Public POST/PUT/PATCH/DELETE endpoint that emails/writes-DB with no rate-limit keyword | MEDIUM | A06 / LLM10 |
43
- | Missing `_headers`/CSP at the project level | LOW | A02 |
44
- | User/tool input concatenated into a `*prompt`/`system` var; wildcard tool perms (`tools:["*"]`) | MEDIUM | LLM01 / LLM06 / ASI02 |
61
+ | A · Hardcoded provider keys / PEM private keys / `SECRET=…literal`; git-tracked `.env`/`.dev.vars` | HIGH | A07 / LLM06 |
62
+ | B · **Secret-in-logs** — `console/print` of a token/secret var or a token-labeled response body | HIGH | A09 / LLM06 |
63
+ | C · SQL built via string interpolation; `eval`/`new Function`; `child_process.exec`+concat; `shell=True`; `innerHTML=`/`dangerouslySetInnerHTML` with a var | HIGH | A03 / LLM05 / ASI05 |
64
+ | D · `fetch`/`requests` with a non-constant URL (SSRF) | MEDIUM | A10 |
65
+ | E · Public POST/PUT/PATCH/DELETE endpoint that emails/writes-DB with no rate-limit keyword | MEDIUM | A06 / LLM10 |
66
+ | F · Missing `_headers`/CSP at the project level | LOW | A02 |
67
+ | G · User/tool input concatenated into a `*prompt`/`system` var; wildcard tool perms (`tools:["*"]`) | MEDIUM | LLM01 / LLM06 / ASI02 |
68
+
69
+ ### Authorization and boundary classes (H–N)
70
+
71
+ | Check | Severity | OWASP |
72
+ |---|---|---|
73
+ | H · **Broken object-level authorization** — handler queries the data store with a request-supplied id and no owner/tenant predicate. CRITICAL when the handler mutates | CRITICAL / HIGH | A01 |
74
+ | I · Mutating route with no auth reference at all; **fail-open env comparison** (`token !== process.env.X` with no assertion that `X` is set — unset env means the check passes for everyone) | CRITICAL / HIGH | A01 / A07 |
75
+ | J · Privileged key behind a client-exposed prefix (`NEXT_PUBLIC_`, `VITE_`, `EXPO_PUBLIC_`, …) — service-role keys, provider API keys, signing secrets. Publishable/anon/DSN identifiers are allowlisted | CRITICAL / HIGH | A07 / LLM06 |
76
+ | K · JWT `alg: none`, decode-without-verify, `verify_signature: False`; session cookie missing `httpOnly`/`secure`/`sameSite`; auth token in `localStorage` | CRITICAL–MEDIUM | A02 / A07 |
77
+ | L · `Access-Control-Allow-Origin: *` or reflected origin, HIGH when paired with `Allow-Credentials: true` | HIGH / MEDIUM | A05 / A01 |
78
+ | M · Request body spread into a DB write with no schema validation (mass assignment — caller sets `role`, `tenant_id`, `is_admin`); mutating route reading a body with no validation library present | HIGH / MEDIUM | A03 / A04 |
79
+ | N · Model call with no output-token cap (HIGH when also untimed inside a loop); model output into an interpreter/shell/SQL/HTML sink; vector retrieval with no tenant/ACL filter; model-proposed tool calls dispatched with no authorization layer | HIGH / MEDIUM | LLM02 / LLM04 / LLM08 / ASI02 / ASI05 / ASI06 |
80
+
81
+ Every H–N check requires **two** signals before it emits: a handler or sink match *and* the absence of the corresponding control. A gate that hard-blocks deploys cannot afford a noisy check, so single-signal heuristics are excluded even where they would catch more.
45
82
 
46
83
  ## What it does NOT catch — escalate to the JUDGE layer
47
84
 
48
- The scanner is the deterministic 80/20. For the judgment risks data-ownership/authz logic, RAG/tenant scoping, tool-permission scope vs task need, agent goal-drift, approval gates before destructive actions, supply-chain trust load `Skill("build-loop:security-methodology")`, and when the change crosses a security boundary dispatch the `security-reviewer` agent. Scanner findings and agent findings both cite the same `references/cross-source-matrix.md` rows, so they compose into one report.
85
+ The scanner grades structure, not intent. It sees that a query has an owner predicate; it cannot see whether that predicate is the *right* one. Escalate for: business-rule and workflow authorization, property-level field permissions, whether a tenant boundary is correctly designed, RAG corpus partitioning, tool-permission scope versus actual task need, agent goal-drift, approval gates before destructive actions, and supply-chain trust. Load `Skill("build-loop:security-methodology")`, and when the change crosses a security boundary dispatch the `security-reviewer` agent. Scanner findings and agent findings both cite the same `references/cross-source-matrix.md` rows, so they compose into one report.
49
86
 
50
87
  ## Interpreting findings
51
88
 
52
- - **HIGH** → fix before push (the gate blocks). If it's a genuine false positive, annotate with `// nosec: <reason>`; if you must ship anyway, `BUILD_LOOP_HOOKS=off` bypasses the gate for that command (use sparingly, it's logged in the diff intent).
89
+ - **CRITICAL** → blocks in every scope, including a spot finding in a file you did not touch. These are the shapes where shipping is the wrong move regardless of authorship: an unscoped mutating query, a fail-open auth guard, a service-role key in the client bundle, `alg: none`.
90
+ - **HIGH** → fix before push (the gate blocks) when the finding is in a changed file. Advisory when it comes from the spot sweep. If it's a genuine false positive, annotate with `// nosec: <reason>` or `# nosec B###`; if you must ship anyway, `BUILD_LOOP_HOOKS=off` bypasses the gate for that command (use sparingly, it's logged in the diff intent).
53
91
  - **MEDIUM / LOW** → advisory. Route to `.build-loop/backlog/` rather than blocking. Rate-limiting and headers gaps live here.
54
92
 
93
+ Findings carry `scope: "deep" | "spot"` in JSON output, and `--json` `summary` reports `spot_total` and `blocking_total` alongside the severity counts.
94
+
55
95
  Sources for every ID: `skills/security-methodology/references/owasp-{web,llm,agentic}-top-10.md` (current as of OWASP Web 2025 RC1, LLM v2.0 2025, Agentic 2026). The scanner is the enforcement arm; the methodology skill is the citation trail.