auditor-lambda 0.1.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 (199) hide show
  1. package/README.md +173 -0
  2. package/audit-code-wrapper-lib.mjs +905 -0
  3. package/audit-code.mjs +13 -0
  4. package/dist/adapters/coverageSummary.d.ts +8 -0
  5. package/dist/adapters/coverageSummary.js +13 -0
  6. package/dist/adapters/eslint.d.ts +13 -0
  7. package/dist/adapters/eslint.js +21 -0
  8. package/dist/adapters/normalizeExternal.d.ts +12 -0
  9. package/dist/adapters/normalizeExternal.js +19 -0
  10. package/dist/adapters/npmAudit.d.ts +15 -0
  11. package/dist/adapters/npmAudit.js +12 -0
  12. package/dist/adapters/semgrep.d.ts +22 -0
  13. package/dist/adapters/semgrep.js +14 -0
  14. package/dist/cli.d.ts +1 -0
  15. package/dist/cli.js +724 -0
  16. package/dist/coverage.d.ts +11 -0
  17. package/dist/coverage.js +102 -0
  18. package/dist/extractors/bucketing.d.ts +7 -0
  19. package/dist/extractors/bucketing.js +72 -0
  20. package/dist/extractors/disposition.d.ts +4 -0
  21. package/dist/extractors/disposition.js +41 -0
  22. package/dist/extractors/fileInventory.d.ts +7 -0
  23. package/dist/extractors/fileInventory.js +44 -0
  24. package/dist/extractors/flows.d.ts +5 -0
  25. package/dist/extractors/flows.js +125 -0
  26. package/dist/extractors/fsIntake.d.ts +8 -0
  27. package/dist/extractors/fsIntake.js +66 -0
  28. package/dist/extractors/graph.d.ts +4 -0
  29. package/dist/extractors/graph.js +46 -0
  30. package/dist/extractors/ignore.d.ts +1 -0
  31. package/dist/extractors/ignore.js +17 -0
  32. package/dist/extractors/risk.d.ts +5 -0
  33. package/dist/extractors/risk.js +45 -0
  34. package/dist/extractors/surfaces.d.ts +4 -0
  35. package/dist/extractors/surfaces.js +40 -0
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.js +1 -0
  38. package/dist/io/artifacts.d.ts +38 -0
  39. package/dist/io/artifacts.js +100 -0
  40. package/dist/io/json.d.ts +8 -0
  41. package/dist/io/json.js +96 -0
  42. package/dist/io/runArtifacts.d.ts +14 -0
  43. package/dist/io/runArtifacts.js +37 -0
  44. package/dist/orchestrator/advance.d.ts +24 -0
  45. package/dist/orchestrator/advance.js +104 -0
  46. package/dist/orchestrator/artifactMetadata.d.ts +4 -0
  47. package/dist/orchestrator/artifactMetadata.js +111 -0
  48. package/dist/orchestrator/autoFixExecutor.d.ts +3 -0
  49. package/dist/orchestrator/autoFixExecutor.js +63 -0
  50. package/dist/orchestrator/chunking.d.ts +5 -0
  51. package/dist/orchestrator/chunking.js +13 -0
  52. package/dist/orchestrator/dependencyMap.d.ts +1 -0
  53. package/dist/orchestrator/dependencyMap.js +82 -0
  54. package/dist/orchestrator/executors.d.ts +6 -0
  55. package/dist/orchestrator/executors.js +52 -0
  56. package/dist/orchestrator/flowCoverage.d.ts +4 -0
  57. package/dist/orchestrator/flowCoverage.js +44 -0
  58. package/dist/orchestrator/flowPlanning.d.ts +3 -0
  59. package/dist/orchestrator/flowPlanning.js +42 -0
  60. package/dist/orchestrator/flowRequeue.d.ts +5 -0
  61. package/dist/orchestrator/flowRequeue.js +58 -0
  62. package/dist/orchestrator/internalExecutors.d.ts +16 -0
  63. package/dist/orchestrator/internalExecutors.js +212 -0
  64. package/dist/orchestrator/nextStep.d.ts +9 -0
  65. package/dist/orchestrator/nextStep.js +44 -0
  66. package/dist/orchestrator/planning.d.ts +4 -0
  67. package/dist/orchestrator/planning.js +62 -0
  68. package/dist/orchestrator/requeue.d.ts +3 -0
  69. package/dist/orchestrator/requeue.js +25 -0
  70. package/dist/orchestrator/requeueCommand.d.ts +10 -0
  71. package/dist/orchestrator/requeueCommand.js +27 -0
  72. package/dist/orchestrator/resultIngestion.d.ts +2 -0
  73. package/dist/orchestrator/resultIngestion.js +13 -0
  74. package/dist/orchestrator/runtimeValidation.d.ts +7 -0
  75. package/dist/orchestrator/runtimeValidation.js +103 -0
  76. package/dist/orchestrator/runtimeValidationUpdate.d.ts +2 -0
  77. package/dist/orchestrator/runtimeValidationUpdate.js +52 -0
  78. package/dist/orchestrator/staleness.d.ts +2 -0
  79. package/dist/orchestrator/staleness.js +83 -0
  80. package/dist/orchestrator/state.d.ts +3 -0
  81. package/dist/orchestrator/state.js +85 -0
  82. package/dist/orchestrator/syntaxResolutionExecutor.d.ts +3 -0
  83. package/dist/orchestrator/syntaxResolutionExecutor.js +99 -0
  84. package/dist/orchestrator/taskBuilder.d.ts +12 -0
  85. package/dist/orchestrator/taskBuilder.js +154 -0
  86. package/dist/orchestrator/unitBuilder.d.ts +3 -0
  87. package/dist/orchestrator/unitBuilder.js +145 -0
  88. package/dist/orchestrator.d.ts +6 -0
  89. package/dist/orchestrator.js +33 -0
  90. package/dist/prompts/renderWorkerPrompt.d.ts +2 -0
  91. package/dist/prompts/renderWorkerPrompt.js +19 -0
  92. package/dist/providers/claudeCodeProvider.d.ts +8 -0
  93. package/dist/providers/claudeCodeProvider.js +20 -0
  94. package/dist/providers/index.d.ts +7 -0
  95. package/dist/providers/index.js +77 -0
  96. package/dist/providers/localSubprocessProvider.d.ts +5 -0
  97. package/dist/providers/localSubprocessProvider.js +13 -0
  98. package/dist/providers/opencodeProvider.d.ts +8 -0
  99. package/dist/providers/opencodeProvider.js +15 -0
  100. package/dist/providers/spawnLoggedCommand.d.ts +2 -0
  101. package/dist/providers/spawnLoggedCommand.js +48 -0
  102. package/dist/providers/subprocessTemplateProvider.d.ts +8 -0
  103. package/dist/providers/subprocessTemplateProvider.js +41 -0
  104. package/dist/providers/types.d.ts +22 -0
  105. package/dist/providers/types.js +1 -0
  106. package/dist/providers/vscodeTaskProvider.d.ts +8 -0
  107. package/dist/providers/vscodeTaskProvider.js +14 -0
  108. package/dist/reporting/mergeFindings.d.ts +4 -0
  109. package/dist/reporting/mergeFindings.js +136 -0
  110. package/dist/reporting/rootCause.d.ts +11 -0
  111. package/dist/reporting/rootCause.js +69 -0
  112. package/dist/reporting/synthesis.d.ts +21 -0
  113. package/dist/reporting/synthesis.js +55 -0
  114. package/dist/supervisor/operatorHandoff.d.ts +37 -0
  115. package/dist/supervisor/operatorHandoff.js +144 -0
  116. package/dist/supervisor/runLedger.d.ts +3 -0
  117. package/dist/supervisor/runLedger.js +17 -0
  118. package/dist/supervisor/sessionConfig.d.ts +4 -0
  119. package/dist/supervisor/sessionConfig.js +26 -0
  120. package/dist/types/artifactMetadata.d.ts +8 -0
  121. package/dist/types/artifactMetadata.js +1 -0
  122. package/dist/types/auditState.d.ts +14 -0
  123. package/dist/types/auditState.js +1 -0
  124. package/dist/types/disposition.d.ts +9 -0
  125. package/dist/types/disposition.js +1 -0
  126. package/dist/types/externalAnalyzer.d.ts +16 -0
  127. package/dist/types/externalAnalyzer.js +1 -0
  128. package/dist/types/flowCoverage.d.ts +11 -0
  129. package/dist/types/flowCoverage.js +1 -0
  130. package/dist/types/flows.d.ts +11 -0
  131. package/dist/types/flows.js +1 -0
  132. package/dist/types/graph.d.ts +18 -0
  133. package/dist/types/graph.js +1 -0
  134. package/dist/types/risk.d.ts +9 -0
  135. package/dist/types/risk.js +1 -0
  136. package/dist/types/runLedger.d.ts +13 -0
  137. package/dist/types/runLedger.js +1 -0
  138. package/dist/types/runtimeValidation.d.ts +22 -0
  139. package/dist/types/runtimeValidation.js +1 -0
  140. package/dist/types/sessionConfig.d.ts +27 -0
  141. package/dist/types/sessionConfig.js +1 -0
  142. package/dist/types/surfaces.d.ts +11 -0
  143. package/dist/types/surfaces.js +1 -0
  144. package/dist/types/workerResult.d.ts +13 -0
  145. package/dist/types/workerResult.js +1 -0
  146. package/dist/types/workerSession.d.ts +13 -0
  147. package/dist/types/workerSession.js +1 -0
  148. package/dist/types.d.ts +104 -0
  149. package/dist/types.js +1 -0
  150. package/dist/validation/artifacts.d.ts +3 -0
  151. package/dist/validation/artifacts.js +191 -0
  152. package/dist/validation/basic.d.ts +5 -0
  153. package/dist/validation/basic.js +9 -0
  154. package/dist/validation/sessionConfig.d.ts +6 -0
  155. package/dist/validation/sessionConfig.js +139 -0
  156. package/docs/agent-integrations.md +237 -0
  157. package/docs/agent-roles.md +69 -0
  158. package/docs/architecture.md +90 -0
  159. package/docs/artifacts.md +69 -0
  160. package/docs/bootstrap-install.md +79 -0
  161. package/docs/contract.md +140 -0
  162. package/docs/github-copilot.md +50 -0
  163. package/docs/model-selection.md +86 -0
  164. package/docs/next-steps.md +161 -0
  165. package/docs/packaging.md +88 -0
  166. package/docs/pipeline.md +152 -0
  167. package/docs/product-direction.md +111 -0
  168. package/docs/production-launch-bar.md +83 -0
  169. package/docs/production-readiness.md +52 -0
  170. package/docs/repo-layout.md +30 -0
  171. package/docs/run-flow.md +49 -0
  172. package/docs/session-config.md +232 -0
  173. package/docs/supervisor.md +83 -0
  174. package/docs/usage.md +172 -0
  175. package/docs/windows-setup.md +146 -0
  176. package/package.json +56 -0
  177. package/schemas/audit-code-v1alpha1.schema.json +191 -0
  178. package/schemas/audit_result.schema.json +48 -0
  179. package/schemas/audit_state.schema.json +36 -0
  180. package/schemas/audit_task.schema.json +49 -0
  181. package/schemas/blind_spot_register.schema.json +40 -0
  182. package/schemas/coverage_matrix.schema.json +50 -0
  183. package/schemas/critical_flows.schema.json +38 -0
  184. package/schemas/external_analyzer_results.schema.json +31 -0
  185. package/schemas/file_disposition.schema.json +33 -0
  186. package/schemas/finding.schema.json +62 -0
  187. package/schemas/flow_coverage.schema.json +44 -0
  188. package/schemas/graph_bundle.schema.json +55 -0
  189. package/schemas/merged_findings.schema.json +14 -0
  190. package/schemas/repo_manifest.schema.json +37 -0
  191. package/schemas/risk_register.schema.json +30 -0
  192. package/schemas/root_cause_clusters.schema.json +31 -0
  193. package/schemas/runtime_validation_report.schema.json +34 -0
  194. package/schemas/runtime_validation_tasks.schema.json +36 -0
  195. package/schemas/surface_manifest.schema.json +32 -0
  196. package/schemas/synthesis_report.schema.json +61 -0
  197. package/schemas/unit_manifest.schema.json +36 -0
  198. package/skills/audit-code/SKILL.md +54 -0
  199. package/skills/audit-code/audit-code.prompt.md +66 -0
@@ -0,0 +1,237 @@
1
+ # Agent integrations
2
+
3
+ This document explains how `auditor-lambda` fits into AI coding agent workflows across editors and provider surfaces.
4
+
5
+ ## Primary product contract
6
+
7
+ The canonical product surface is the in-conversation `/audit-code` skill.
8
+
9
+ The repo-local backend fallback is the zero-argument wrapper:
10
+
11
+ Normal product usage should:
12
+
13
+ - use the current conversation or editor context as the working context
14
+ - avoid manual `--root`, provider flags, and model selection in normal use
15
+ - let the supervisor advance the audit automatically until it completes or no further automatic progress is possible
16
+
17
+ ## Conversation-first setup
18
+
19
+ The canonical prompt asset is:
20
+
21
+ `skills/audit-code/audit-code.prompt.md`
22
+
23
+ The preferred bootstrap path is:
24
+
25
+ ```bash
26
+ audit-code install
27
+ ```
28
+
29
+ That installs repo-local `/audit-code` surfaces for VS Code / Copilot, OpenCode, Claude Code, and compatibility instruction files such as `AGENTS.md` and `CLAUDE.md`.
30
+ It also writes `.audit-code/install/GETTING-STARTED.md` with dedicated quick-start sections for VS Code, OpenCode, Claude Code, Claude Desktop, and Antigravity.
31
+
32
+ Use one of these supported ways to obtain the raw prompt asset directly when you need prompt import instead:
33
+
34
+ 1. install the package and run `audit-code prompt-path`
35
+ 2. check out the repository and read the file directly from `skills/audit-code/audit-code.prompt.md`
36
+
37
+ Import that prompt into your editor or conversation environment, or use the bootstrap installer above, then use `/audit-code` in conversation.
38
+
39
+ ## Editor guidance
40
+
41
+ ### ChatGPT project conversations
42
+
43
+ This is the intended product surface.
44
+
45
+ Use `/audit-code` in conversation, treat the active conversation model as the default model, and treat project files plus attached repository context as the default context.
46
+
47
+ ### GitHub Copilot
48
+
49
+ Use `audit-code install` from the target repository root.
50
+
51
+ That writes `.github/prompts/audit-code.prompt.md` and `.github/copilot-instructions.md` so the repository carries the canonical `/audit-code` instructions instead of relying on manual copy-paste.
52
+ The generated prompt file explicitly sets `agent: agent` so `/audit-code` lands in the tool-capable Copilot agent flow.
53
+
54
+ The narrower `audit-code install-host --host copilot` alias still exists, but it is no longer the preferred setup path.
55
+
56
+ ### OpenCode
57
+
58
+ Use `audit-code install` from the target repository root.
59
+
60
+ That writes `.opencode/commands/audit-code.md` plus `AGENTS.md` and compatibility skills so `/audit-code` is available in the repository with no extra provider flags.
61
+ The generated OpenCode command now sets `agent: build` and keeps the current model selection, which makes the slash command behave more like the intended autonomous editing flow.
62
+ The generated `.audit-code/install/GETTING-STARTED.md` file also includes an OpenCode-specific quick start so the repo-local command path is obvious after bootstrap.
63
+
64
+ ### Claude Code
65
+
66
+ Use `audit-code install` from the target repository root.
67
+
68
+ That writes `.claude/commands/audit-code.md`, `CLAUDE.md`, and compatibility skills so `/audit-code` is available in the repository with no extra provider flags.
69
+ The generated `.audit-code/install/GETTING-STARTED.md` file also includes a Claude Code-specific quick start so the repo-local command path is obvious after bootstrap.
70
+
71
+ ### VS Code
72
+
73
+ Run `audit-code install` from the target repository root, then open `.audit-code/install/GETTING-STARTED.md` if you want the exact repo-local path that bootstrap created for VS Code chat surfaces.
74
+
75
+ The expected happy path is still to invoke `/audit-code` from chat, not to start from the backend CLI.
76
+
77
+ ### Claude Desktop
78
+
79
+ Run `audit-code install` from the target repository root, then open `.audit-code/install/GETTING-STARTED.md`.
80
+
81
+ There is no verified project-local slash-command install surface for Claude Desktop in this repository today, so the intended path is:
82
+
83
+ 1. import `.audit-code/install/audit-code.prompt.md` into Claude Desktop's prompt or instruction surface
84
+ 2. invoke `/audit-code` conversationally inside Claude Desktop
85
+
86
+ ### Antigravity
87
+
88
+ Run `audit-code install` from the target repository root, then open `.audit-code/install/GETTING-STARTED.md`.
89
+
90
+ There is no verified repo-local slash-command install surface for Antigravity in this repository today, so the intended path is:
91
+
92
+ 1. import `.audit-code/install/audit-code.prompt.md` into Antigravity's prompt or instruction surface when available
93
+ 2. invoke `/audit-code` conversationally inside Antigravity
94
+ 3. fall back to `audit-code` from an Antigravity-managed terminal only when you intentionally need the repo-local backend wrapper
95
+
96
+ ### Similar manual-import hosts
97
+
98
+ Use the same installed prompt asset and repo-local guide pattern as Claude Desktop and Antigravity.
99
+
100
+ The backend CLI remains optional fallback infrastructure.
101
+
102
+ ## Repo-local backend fallback
103
+
104
+ From the target repository root:
105
+
106
+ ```bash
107
+ audit-code
108
+ ```
109
+
110
+ Use the backend wrapper only when you intentionally need the repo-local fallback, automation harness, or provider-adapter workflow.
111
+
112
+ ## What the wrapper actually does
113
+
114
+ `audit-code` is the stable backend entrypoint.
115
+
116
+ It:
117
+
118
+ - defaults artifacts to `<repo-root>/.audit-artifacts`
119
+ - persists audit continuity there
120
+ - calls `run-to-completion` by default
121
+ - creates fresh worker runs behind the scenes
122
+ - returns a stable top-level JSON contract with `contract_version: "audit-code/v1alpha1"`
123
+
124
+ ## Minimal repo-local flow
125
+
126
+ From the target repository root:
127
+
128
+ ```bash
129
+ audit-code
130
+ ```
131
+
132
+ Inspect the returned JSON and continue invoking the same entrypoint until either:
133
+
134
+ - `next_likely_step === null`
135
+
136
+ Terminal interpretation:
137
+
138
+ - `audit_state.status === "complete"` means the audit finished end to end.
139
+ - `audit_state.status === "blocked"` means the wrapper exhausted automatic work and the remaining review needs imported results or an interactive provider.
140
+
141
+ When additional evidence exists, pass it into the same wrapper:
142
+
143
+ ```bash
144
+ audit-code --results /path/to/audit_results.json
145
+ audit-code --updates /path/to/runtime_validation_report.json
146
+ audit-code --external-analyzer-results /path/to/external_analyzer_results.json
147
+ ```
148
+
149
+ Each response also refreshes `.audit-artifacts/operator-handoff.json` and `.audit-artifacts/operator-handoff.md` so operators can see the pending obligations, suggested import paths, and session-config continuation hint without reconstructing the state manually.
150
+
151
+ Everything below is backend fallback guidance, not the primary product path.
152
+
153
+ ## Provider matrix
154
+
155
+ ### local-subprocess
156
+
157
+ Use when you want the supervisor to stay entirely local.
158
+
159
+ This requires no external agent CLI. The supervisor launches fresh worker subprocesses that call the bounded `worker-run` entrypoint for deterministic stages.
160
+
161
+ When the remaining work is genuinely audit-task review, `local-subprocess` stops in a terminal blocked handoff instead of pretending more automatic progress is available.
162
+
163
+ This is the safest default backend when the repository is already available locally.
164
+
165
+ ### claude-code
166
+
167
+ Use when Claude Code is installed and authenticated on the machine.
168
+
169
+ The built-in adapter launches a fresh Claude Code print-mode session for each worker run.
170
+
171
+ Recommended when you want the audit supervisor to delegate bounded tasks into Claude Code without manually driving each step.
172
+
173
+ ### opencode
174
+
175
+ Use when OpenCode is installed and authenticated on the machine.
176
+
177
+ The built-in adapter launches a fresh `opencode run ...` session for each worker run.
178
+
179
+ Recommended when OpenCode is the preferred local agent surface.
180
+
181
+ ### subprocess-template
182
+
183
+ Use when you need a generic bridge.
184
+
185
+ This is the escape hatch for editors, launchers, or agent shells that do not yet have a dedicated provider adapter. The supervisor renders a templated command and executes it as a fresh worker run.
186
+
187
+ ### vscode-task
188
+
189
+ Use when you already have a repository-local or machine-local task bridge and want the supervisor to call that bridge through a command template.
190
+
191
+ Treat this as an advanced backend adapter rather than the default path.
192
+
193
+ ### Claude Code
194
+
195
+ Use the repo-local `audit-code` wrapper from the target repository root, or set `provider` to `claude-code` in `.audit-artifacts/session-config.json` so the supervisor delegates bounded worker runs into Claude Code.
196
+
197
+ ### OpenCode
198
+
199
+ Use the same repo-local `audit-code` wrapper, or set `provider` to `opencode` so the supervisor delegates bounded worker runs into OpenCode.
200
+
201
+ ### VS Code
202
+
203
+ Run `audit-code install` once from the target repository root, then use `/audit-code` from chat.
204
+
205
+ The backend fallback is still available from the integrated terminal and should keep `local-subprocess` unless you specifically need a task bridge.
206
+
207
+ If you already have a launcher or task surface that should own fresh worker windows, use `vscode-task` or `subprocess-template`.
208
+
209
+ ### Google Antigravity
210
+
211
+ No dedicated Antigravity provider adapter is shipped today.
212
+
213
+ Current recommended usage is one of these:
214
+
215
+ - use the skill-first conversational contract as the primary surface
216
+ - run `audit-code install` first so compatibility files are present
217
+ - run `audit-code` from an Antigravity-managed terminal with `local-subprocess`
218
+ - use `subprocess-template` if you have a reliable Antigravity-side launcher bridge
219
+
220
+ That keeps the product usable in Antigravity now without pretending that a native adapter already exists.
221
+
222
+ ## Model-selection rule
223
+
224
+ The product direction remains skill-first:
225
+
226
+ - in conversation, use the active conversation model by default
227
+ - for backend CLI delegation, let the chosen provider own its own model-selection behavior unless explicitly configured otherwise
228
+
229
+ ## Practical recommendation
230
+
231
+ For a polished operator experience today:
232
+
233
+ 1. treat `/audit-code` as the canonical user-facing contract
234
+ 2. use `audit-code install` first, and fall back to `audit-code prompt-path` only for hosts that still require manual prompt import
235
+ 3. use `audit-code` as the repo-local backend fallback
236
+ 4. prefer `local-subprocess` unless you need interactive review to continue through agent tasks
237
+ 5. use `subprocess-template` only when integrating a non-native editor or launcher surface
@@ -0,0 +1,69 @@
1
+ # Agent roles
2
+
3
+ ## Principles
4
+
5
+ Each agent should consume bounded artifacts and return structured outputs. Agents should not invent process rules.
6
+
7
+ ## Roles
8
+
9
+ ### intake-normalizer
10
+
11
+ - validates repository intake artifacts
12
+ - flags suspicious exclusions
13
+ - confirms stack profile
14
+
15
+ ### structural-mapper
16
+
17
+ - reviews extracted units, surfaces, and graph artifacts
18
+ - resolves ambiguous file classifications
19
+ - flags missing boundaries
20
+
21
+ ### blind-spot-mapper
22
+
23
+ - identifies repo-specific blind spots tools may miss
24
+ - flags hidden operational or security-critical surfaces
25
+ - proposes additional lenses or dynamic checks
26
+
27
+ ### correctness-auditor
28
+
29
+ - checks whether code behavior appears to match intent
30
+ - focuses on edge cases, defaults, assumptions, and branch handling
31
+
32
+ ### architecture-auditor
33
+
34
+ - inspects layering, boundaries, coupling, abstraction fit, and dependency direction
35
+
36
+ ### security-auditor
37
+
38
+ - inspects trust boundaries, auth/authz, validation, secret handling, risky sinks, and exploitability
39
+
40
+ ### reliability-auditor
41
+
42
+ - inspects retries, timeouts, idempotency, partial failures, crash consistency, and concurrency risk
43
+
44
+ ### performance-auditor
45
+
46
+ - inspects hot paths, repeated work, query inefficiency, algorithmic issues, memory pressure, and scalability risk
47
+
48
+ ### data-integrity-auditor
49
+
50
+ - inspects invariants, migrations, transactional boundaries, schema drift, consistency, and race conditions
51
+
52
+ ### test-auditor
53
+
54
+ - inspects test adequacy, missing negative-path coverage, brittle tests, and false confidence
55
+
56
+ ### operability-auditor
57
+
58
+ - inspects logging, metrics, tracing, debuggability, startup validation, and runtime observability
59
+
60
+ ### cross-cutting-auditor
61
+
62
+ - audits repo-wide themes such as auth, retries, migrations, config validation, feature flags, and secrets flow
63
+
64
+ ### synthesizer
65
+
66
+ - merges duplicate findings
67
+ - clusters root causes
68
+ - prioritizes fixes
69
+ - identifies quick wins vs structural work
@@ -0,0 +1,90 @@
1
+ # Architecture
2
+
3
+ ## Objective
4
+
5
+ `auditor-lambda` is a portable code-auditing framework for arbitrary repositories. It separates deterministic extraction from bounded LLM judgment so that large or mixed-language codebases can be audited systematically.
6
+
7
+ ## Design principles
8
+
9
+ 1. Tool outputs first
10
+ 2. Artifact-driven orchestration
11
+ 3. Bounded LLM tasks
12
+ 4. Explicit coverage accounting
13
+ 5. Multi-pass review for critical code
14
+ 6. Strict schemas for interoperability
15
+
16
+ ## System layers
17
+
18
+ ### 1. Intake
19
+
20
+ - file discovery
21
+ - stack detection
22
+ - ignore handling
23
+ - normalization
24
+
25
+ ### 2. Extractors
26
+
27
+ - service and package detection
28
+ - route, job, command, workflow extraction
29
+ - file bucketing
30
+ - graph extraction
31
+
32
+ ### 3. Mechanical analyzers
33
+
34
+ - lint
35
+ - typecheck
36
+ - tests
37
+ - test coverage
38
+ - secret scanning
39
+ - dependency scanning
40
+ - static security scanning
41
+ - complexity and duplication metrics
42
+
43
+ ### 4. Orchestrator
44
+
45
+ - builds audit units
46
+ - assigns passes and lenses
47
+ - chunks large files
48
+ - tracks line coverage and pass overlap
49
+ - requeues uncovered ranges
50
+
51
+ ### 5. LLM agents
52
+
53
+ - ambiguous classification
54
+ - blind-spot mapping
55
+ - per-lens audits
56
+ - cross-cutting audits
57
+ - synthesis
58
+
59
+ ### 6. Validation
60
+
61
+ - targeted runtime checks
62
+ - startup/config probes
63
+ - adversarial repros
64
+
65
+ ### 7. Reporting
66
+
67
+ - normalized findings
68
+ - coverage matrices
69
+ - root-cause clustering
70
+ - remediation planning
71
+
72
+ ## Core pipeline
73
+
74
+ 1. Intake and normalize repository
75
+ 2. Extract structure and graph artifacts
76
+ 3. Run mechanical analyzers
77
+ 4. Build audit units and risk register
78
+ 5. Run blind-spot mapping
79
+ 6. Run lens-based unit audits
80
+ 7. Run cross-cutting audits
81
+ 8. Run dynamic validation on targeted cases
82
+ 9. Verify file and line coverage
83
+ 10. Synthesize findings and remediation plan
84
+
85
+ ## Portability rules
86
+
87
+ - Tool-specific collectors should write into tool-agnostic JSON artifacts.
88
+ - LLM prompts should consume artifacts, not raw repos by default.
89
+ - All review work should be attributable to files, line ranges, lenses, and passes.
90
+ - Coverage gaps should be machine-detectable.
@@ -0,0 +1,69 @@
1
+ # Core artifacts
2
+
3
+ These JSON artifacts are the stable contract between deterministic tooling and LLM audit passes.
4
+
5
+ ## Core files
6
+
7
+ - `repo_manifest.json`
8
+ - `file_disposition.json`
9
+ - `unit_manifest.json`
10
+ - `graph_bundle.json`
11
+ - `surface_manifest.json`
12
+ - `critical_flows.json`
13
+ - `flow_coverage.json`
14
+ - `risk_register.json`
15
+ - `coverage_matrix.json`
16
+ - `runtime_validation_tasks.json`
17
+ - `runtime_validation_report.json`
18
+ - `external_analyzer_results.json`
19
+ - `audit_results.json`
20
+ - `requeue_tasks.json`
21
+ - `merged_findings.json`
22
+ - `root_cause_clusters.json`
23
+ - `synthesis_report.json`
24
+
25
+ ## Design rule
26
+
27
+ Tool-specific collectors should write into these normalized formats so that the agent layer can remain portable across runtimes.
28
+
29
+ ## Coverage rule
30
+
31
+ Coverage is not based only on test instrumentation. It is based on explicit audit accounting:
32
+
33
+ - file classification
34
+ - file disposition
35
+ - unit assignment
36
+ - required lenses
37
+ - reviewed source ranges
38
+ - completed passes
39
+ - requeue targets for missing review
40
+ - critical-flow coverage state
41
+
42
+ ## Excluded artifact behavior
43
+
44
+ Files marked as generated, vendor, binary, doc-only, or explicitly excluded should remain visible in manifests and disposition tracking, but should not receive normal audit-unit assignment or requeue tasks.
45
+
46
+ ## Critical flow role
47
+
48
+ `critical_flows.json` is intended to bridge deterministic planning and higher-order semantic review. It gives LLM agents a bounded way to inspect important end-to-end paths without reading the entire repository at once.
49
+
50
+ `flow_coverage.json` tracks whether those important paths have received the intended lenses, which allows the planner to treat critical-flow review as a first-class coverage requirement rather than a loose advisory layer.
51
+
52
+ ## Runtime validation role
53
+
54
+ `runtime_validation_tasks.json` turns unresolved high-risk units and incomplete critical flows into explicit dynamic follow-up work.
55
+
56
+ `runtime_validation_report.json` is where evidence from those checks should land so that later synthesis can distinguish confirmed, not-confirmed, and inconclusive concerns.
57
+
58
+ ## External analyzer role
59
+
60
+ `external_analyzer_results.json` is the normalized landing zone for third-party tools such as SAST analyzers, coverage summaries, lint diagnostics, dependency scanners, and similar sources. Downstream prompts should prefer this normalized form over raw tool-native payloads.
61
+
62
+ External analyzer results now also influence:
63
+
64
+ - risk scoring
65
+ - required lenses in coverage
66
+ - task priority
67
+ - dedicated analyzer follow-up tasks
68
+ - requeue priority
69
+ - synthesis evidence and summaries
@@ -0,0 +1,79 @@
1
+ # Bootstrap install
2
+
3
+ The intended setup flow is a single bootstrap step from the target repository root:
4
+
5
+ ```bash
6
+ audit-code install
7
+ ```
8
+
9
+ That command installs the repo-local `/audit-code` surfaces we can automate today.
10
+
11
+ ## What it writes
12
+
13
+ Installed command surfaces:
14
+
15
+ - `.github/prompts/audit-code.prompt.md` for VS Code chat prompt files, with `agent: agent`
16
+ - `.opencode/commands/audit-code.md` for OpenCode custom commands, with `agent: build`
17
+ - `.claude/commands/audit-code.md` for Claude Code custom slash commands
18
+
19
+ Installed always-on compatibility surfaces:
20
+
21
+ - `.github/copilot-instructions.md`
22
+ - `AGENTS.md`
23
+ - `CLAUDE.md`
24
+
25
+ Installed repo-local canonical assets:
26
+
27
+ - `.audit-code/install/audit-code.prompt.md`
28
+ - `.audit-code/install/SKILL.md`
29
+ - `.audit-code/install/GETTING-STARTED.md`
30
+
31
+ The generated `GETTING-STARTED.md` now includes dedicated quick-start sections for:
32
+
33
+ - VS Code
34
+ - OpenCode
35
+ - Claude Code
36
+ - Claude Desktop
37
+ - Antigravity
38
+
39
+ Installed compatibility skill bundles:
40
+
41
+ - `.opencode/skills/audit-code/*`
42
+ - `.claude/skills/audit-code/*`
43
+ - `.agents/skills/audit-code/*`
44
+
45
+ ## Goal
46
+
47
+ After bootstrap, the user should be able to open a supported conversation surface in the repository and invoke:
48
+
49
+ ```text
50
+ /audit-code
51
+ ```
52
+
53
+ without supplying extra root paths, provider flags, or model-selection arguments.
54
+
55
+ ## What is fully automated today
56
+
57
+ - VS Code and GitHub Copilot repo-local prompt surfaces
58
+ - OpenCode project command surfaces
59
+ - Claude Code project command surfaces
60
+ - tool-agnostic compatibility instruction files for hosts that honor `AGENTS.md` or `CLAUDE.md`
61
+
62
+ ## What is not fully automated today
63
+
64
+ - Claude Desktop does not currently have a verified project-local slash-command install surface in this repository
65
+ - Antigravity does not currently have a verified repo-local slash-command install surface in this repository
66
+
67
+ For those hosts, the bootstrap command still installs compatibility assets, but the final `/audit-code` discovery behavior remains host-dependent.
68
+
69
+ Use `.audit-code/install/GETTING-STARTED.md` as the low-guess repo-local handoff for those manual prompt-import paths and for the exact VS Code, OpenCode, and Claude Code bootstrap surfaces that were generated.
70
+
71
+ ## Narrow compatibility alias
72
+
73
+ The older host-specific helper still exists:
74
+
75
+ ```bash
76
+ audit-code install-host --host copilot
77
+ ```
78
+
79
+ Use it only when you intentionally want the smaller Copilot-only install path instead of the default bootstrap.
@@ -0,0 +1,140 @@
1
+ # audit-code response contract
2
+
3
+ This document describes the backend fallback JSON response contract for the `audit-code` wrapper.
4
+
5
+ The canonical product remains `/audit-code` in conversation.
6
+
7
+ ## Backend fallback commands
8
+
9
+ Repo-local fallback command from the target repository root:
10
+
11
+ ```bash
12
+ audit-code
13
+ ```
14
+
15
+ Installed helper for locating the packaged conversation prompt asset:
16
+
17
+ ```bash
18
+ audit-code prompt-path
19
+ ```
20
+
21
+ Installed helper for validating the current backend artifact bundle:
22
+
23
+ ```bash
24
+ audit-code validate
25
+ ```
26
+
27
+ Repository-local wrapper equivalent:
28
+
29
+ ```bash
30
+ node audit-code.mjs
31
+ ```
32
+
33
+ ## Contract version
34
+
35
+ Every canonical wrapper response includes:
36
+
37
+ ```text
38
+ contract_version: audit-code/v1alpha1
39
+ ```
40
+
41
+ Consumers should verify this value before assuming the response shape.
42
+
43
+ ## Source of truth
44
+
45
+ The versioned JSON schema is:
46
+
47
+ ```text
48
+ schemas/audit-code-v1alpha1.schema.json
49
+ ```
50
+
51
+ Product tests validate live wrapper output against that schema.
52
+
53
+ ## Reproducible installed-command smoke check
54
+
55
+ From the repository root:
56
+
57
+ ```bash
58
+ npm install
59
+ npm run build
60
+ npm link
61
+ npm run smoke:linked-audit-code
62
+ ```
63
+
64
+ This exercises the installed backend fallback command end-to-end and validates the emitted JSON against the versioned schema.
65
+
66
+ ## Top-level fields
67
+
68
+ The current v1alpha1 contract includes these top-level fields:
69
+
70
+ - `contract_version`
71
+ - `audit_state`
72
+ - `selected_obligation`
73
+ - `selected_executor`
74
+ - `progress_made`
75
+ - `artifacts_written`
76
+ - `progress_summary`
77
+ - `next_likely_step`
78
+ - `handoff`
79
+
80
+ `handoff` is a companion operator-context object. It includes:
81
+
82
+ - current top-level status
83
+ - repo and artifacts paths
84
+ - pending obligations
85
+ - suggested evidence-import paths and commands when manual continuation is required
86
+ - stable paths to companion handoff files under `.audit-artifacts`
87
+
88
+ ## Terminal states
89
+
90
+ Consumers should continue invoking the same wrapper until:
91
+
92
+ 1. `next_likely_step == null`
93
+
94
+ Terminal interpretation:
95
+
96
+ - `audit_state.status == "complete"` means the audit finished end to end.
97
+ - `audit_state.status == "blocked"` means no further automatic progress is available and the remaining work needs imported results or an interactive provider.
98
+ - `progress_made` tells you whether the current invocation wrote additional artifacts before it reached that terminal state.
99
+
100
+ When the wrapper emits a response, it also refreshes:
101
+
102
+ - `.audit-artifacts/operator-handoff.json`
103
+ - `.audit-artifacts/operator-handoff.md`
104
+
105
+ Those files mirror the structured `handoff` guidance in machine-readable and human-readable forms.
106
+
107
+ ## Audit state shape
108
+
109
+ `audit_state` includes:
110
+
111
+ - `status`
112
+ - `obligations`
113
+ - optional `last_executor`
114
+ - optional `last_obligation`
115
+ - optional `blockers`
116
+
117
+ `status` is one of:
118
+
119
+ - `not_started`
120
+ - `active`
121
+ - `blocked`
122
+ - `complete`
123
+
124
+ Each obligation includes:
125
+
126
+ - `id`
127
+ - `state`
128
+ - optional `reason`
129
+
130
+ Obligation `state` is one of:
131
+
132
+ - `missing`
133
+ - `present`
134
+ - `stale`
135
+ - `blocked`
136
+ - `satisfied`
137
+
138
+ ## Compatibility note
139
+
140
+ This contract is versioned as `v1alpha1` deliberately. It is stable enough for current product use, but it should still be treated as pre-v1.