auditor-lambda 0.2.8 → 0.2.10

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 (104) hide show
  1. package/README.md +6 -0
  2. package/audit-code-wrapper-lib.mjs +1 -1
  3. package/dist/adapters/eslint.js +9 -5
  4. package/dist/cli.d.ts +42 -1
  5. package/dist/cli.js +234 -63
  6. package/dist/extractors/bucketing.d.ts +4 -0
  7. package/dist/extractors/bucketing.js +6 -2
  8. package/dist/extractors/disposition.d.ts +4 -0
  9. package/dist/extractors/disposition.js +6 -2
  10. package/dist/extractors/fileInventory.js +24 -28
  11. package/dist/extractors/flows.d.ts +5 -0
  12. package/dist/extractors/flows.js +18 -38
  13. package/dist/extractors/pathPatterns.d.ts +10 -3
  14. package/dist/extractors/pathPatterns.js +109 -61
  15. package/dist/extractors/surfaces.d.ts +4 -0
  16. package/dist/extractors/surfaces.js +11 -11
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +2 -1
  19. package/dist/io/artifacts.d.ts +55 -40
  20. package/dist/io/artifacts.js +73 -110
  21. package/dist/io/json.js +52 -21
  22. package/dist/io/runArtifacts.d.ts +1 -1
  23. package/dist/io/runArtifacts.js +26 -3
  24. package/dist/orchestrator/advance.js +83 -62
  25. package/dist/orchestrator/autoFixExecutor.js +32 -15
  26. package/dist/orchestrator/flowCoverage.js +11 -5
  27. package/dist/orchestrator/flowPlanning.d.ts +7 -2
  28. package/dist/orchestrator/flowPlanning.js +46 -21
  29. package/dist/orchestrator/flowRequeue.js +28 -8
  30. package/dist/orchestrator/internalExecutors.js +12 -8
  31. package/dist/orchestrator/localCommands.d.ts +14 -0
  32. package/dist/orchestrator/localCommands.js +124 -0
  33. package/dist/orchestrator/planning.js +25 -3
  34. package/dist/orchestrator/requeue.js +11 -1
  35. package/dist/orchestrator/syntaxResolutionExecutor.js +60 -59
  36. package/dist/orchestrator/taskBuilder.d.ts +4 -2
  37. package/dist/orchestrator/taskBuilder.js +153 -52
  38. package/dist/orchestrator/unitBuilder.d.ts +3 -1
  39. package/dist/orchestrator/unitBuilder.js +24 -16
  40. package/dist/prompts/renderWorkerPrompt.d.ts +1 -1
  41. package/dist/prompts/renderWorkerPrompt.js +16 -8
  42. package/dist/providers/claudeCodeProvider.d.ts +4 -1
  43. package/dist/providers/claudeCodeProvider.js +8 -5
  44. package/dist/providers/localSubprocessProvider.d.ts +4 -0
  45. package/dist/providers/localSubprocessProvider.js +7 -2
  46. package/dist/providers/spawnLoggedCommand.d.ts +9 -1
  47. package/dist/providers/spawnLoggedCommand.js +77 -29
  48. package/dist/reporting/synthesis.d.ts +2 -0
  49. package/dist/reporting/synthesis.js +12 -9
  50. package/dist/supervisor/operatorHandoff.d.ts +1 -1
  51. package/dist/supervisor/operatorHandoff.js +56 -18
  52. package/dist/supervisor/runLedger.d.ts +1 -1
  53. package/dist/supervisor/runLedger.js +112 -5
  54. package/dist/supervisor/sessionConfig.js +10 -10
  55. package/dist/types/externalAnalyzer.d.ts +3 -0
  56. package/dist/types/flowCoverage.d.ts +5 -1
  57. package/dist/types/flowCoverage.js +5 -1
  58. package/dist/types/flows.d.ts +5 -1
  59. package/dist/types/flows.js +1 -1
  60. package/dist/types/runLedger.d.ts +5 -1
  61. package/dist/types/runLedger.js +6 -1
  62. package/dist/types/runtimeValidation.d.ts +12 -3
  63. package/dist/types/runtimeValidation.js +16 -1
  64. package/dist/types/sessionConfig.d.ts +15 -2
  65. package/dist/types/sessionConfig.js +15 -1
  66. package/dist/types/surfaces.d.ts +4 -1
  67. package/dist/types/surfaces.js +1 -1
  68. package/dist/types/workerSession.d.ts +9 -0
  69. package/dist/types/workerSession.js +5 -1
  70. package/dist/validation/artifacts.d.ts +1 -1
  71. package/dist/validation/artifacts.js +33 -20
  72. package/dist/validation/auditResults.d.ts +2 -2
  73. package/dist/validation/auditResults.js +7 -15
  74. package/dist/validation/basic.d.ts +9 -1
  75. package/dist/validation/basic.js +40 -3
  76. package/dist/validation/sessionConfig.d.ts +4 -2
  77. package/dist/validation/sessionConfig.js +62 -15
  78. package/docs/agent-integrations.md +31 -11
  79. package/docs/next-steps.md +21 -4
  80. package/docs/packaging.md +14 -0
  81. package/docs/product-direction.md +22 -0
  82. package/docs/production-launch-bar.md +2 -0
  83. package/docs/releasing.md +17 -0
  84. package/docs/remediation-baseline.md +75 -0
  85. package/docs/run-flow.md +23 -11
  86. package/docs/session-config.md +53 -6
  87. package/docs/supervisor.md +7 -0
  88. package/docs/workflow-refactor-brief.md +177 -0
  89. package/package.json +1 -1
  90. package/schemas/audit-code-v1alpha1.schema.json +1 -0
  91. package/schemas/audit_result.schema.json +4 -1
  92. package/schemas/audit_task.schema.json +3 -1
  93. package/schemas/coverage_matrix.schema.json +3 -3
  94. package/schemas/critical_flows.schema.json +6 -2
  95. package/schemas/file_disposition.schema.json +2 -2
  96. package/schemas/finding.schema.json +9 -4
  97. package/schemas/flow_coverage.schema.json +2 -2
  98. package/schemas/repo_manifest.schema.json +4 -4
  99. package/schemas/risk_register.schema.json +2 -2
  100. package/schemas/runtime_validation_report.schema.json +2 -2
  101. package/schemas/runtime_validation_tasks.schema.json +8 -2
  102. package/schemas/surface_manifest.schema.json +6 -3
  103. package/schemas/unit_manifest.schema.json +3 -2
  104. package/skills/audit-code/SKILL.md +5 -0
@@ -0,0 +1,75 @@
1
+ # Remediation Baseline
2
+
3
+ This document preserves the remediation work that is already in the source tree so the stale audit state can be discarded safely before a fresh rerun.
4
+
5
+ ## Safe reset boundary
6
+
7
+ After reviewing this document and [docs/workflow-refactor-brief.md](/C:/Code/auditor-lambda/docs/workflow-refactor-brief.md), it is safe to delete:
8
+
9
+ - `.audit-artifacts/`
10
+ - `audit-report.md`
11
+
12
+ Those files describe a stale audit run and should not be used as the primary workflow driver for the next implementation pass.
13
+
14
+ The source tree and tests are the durable baseline to keep.
15
+
16
+ ## Remediation already landed in the source tree
17
+
18
+ The current worktree already includes substantial remediation across the main audited areas.
19
+
20
+ - Fixtures and workflows were hardened across `tests/fixtures/simple-app/...`, `.github/workflows/...`, `scripts/smoke-linked-audit-code.mjs`, `scripts/smoke-packaged-audit-code.mjs`, and the related release/operator docs.
21
+ - Extractor path handling and classification behavior were tightened in `src/extractors/...` with dedicated regressions in `tests/extractors-remediation.test.mjs`.
22
+ - Schema-contract and validation coverage were improved across `schemas/...`, `tests/helpers/jsonSchemaAssert.mjs`, `src/validation/...`, `tests/schema-contracts.test.mjs`, and `tests/validation-remediation.test.mjs`.
23
+ - Orchestrator behavior was hardened in `src/orchestrator/...` with focused regressions in `tests/orchestrator-remediation.test.mjs` and `tests/orchestration.test.mjs`.
24
+ - Supervisor and provider behavior were improved in `src/supervisor/...`, `src/providers/...`, and their companion tests.
25
+ - CLI and IO behavior were tightened in `src/cli.ts`, `src/index.ts`, `src/io/...`, and the related remediation tests.
26
+ - Reporting and synthesis behavior were improved in `src/reporting/...` with `tests/reporting-remediation.test.mjs`.
27
+ - The generated repo-local install payload was refreshed so `.audit-code/install/claude-desktop/...` now matches the current `dist/`, `schemas/`, and `skills/audit-code` source of truth, and `.audit-code/install/manifest.json` now points `source_prompt_path` at the repo-local prompt asset instead of a machine-specific global npm path.
28
+
29
+ ## Verification already performed
30
+
31
+ The following verification was already recorded against the current remediation tree.
32
+
33
+ - `npm test` passed on 2026-04-22 with 106 passing tests.
34
+ - `npm run build` passed in the targeted remediation passes below.
35
+ - `node --test --test-isolation=none tests/validation-remediation.test.mjs tests/validate-command.test.mjs tests/field-trial-remediation.test.mjs tests/provider-auto-resolution.test.mjs tests/supervisor-remediation.test.mjs` passed.
36
+ - `node --test --test-isolation=none tests/cli-remediation.test.mjs tests/validate-command.test.mjs` passed.
37
+ - `node --test --test-isolation=none tests/extractors-remediation.test.mjs` passed.
38
+ - `node --test --test-isolation=none tests/io-remediation.test.mjs tests/cli-remediation.test.mjs tests/validate-command.test.mjs tests/staleness.test.mjs` passed.
39
+ - `node --test --test-isolation=none tests/adapters-remediation.test.mjs tests/reporting-remediation.test.mjs tests/field-trial-remediation.test.mjs` passed.
40
+ - `node --test --test-isolation=none tests/orchestration.test.mjs tests/orchestrator-remediation.test.mjs tests/reporting-remediation.test.mjs` passed.
41
+ - The manually repaired install payload now has hash parity between the committed Claude Desktop bundle and the canonical repo `dist/`, `schemas/`, and `skills/audit-code` files.
42
+
43
+ ## Environment limits observed during verification
44
+
45
+ The current sandbox still hits `spawn EPERM` for subprocess-heavy wrapper/provider coverage.
46
+
47
+ That means:
48
+
49
+ - broader wrapper/provider integration checks remain environment-limited here
50
+ - the stale audit rerun should not be treated as authoritative
51
+ - the workflow refactor should be completed before a fresh audit is attempted
52
+
53
+ ## Release status
54
+
55
+ Do not cut a release tag, push a release branch, or publish from the current stale audit state.
56
+
57
+ The correct order is:
58
+
59
+ 1. preserve the source changes already made
60
+ 2. refactor the workflow
61
+ 3. delete the stale audit state
62
+ 4. rerun the audit from a clean slate
63
+ 5. only then decide whether a release is ready
64
+
65
+ ## Fresh rerun checklist
66
+
67
+ When the workflow refactor is complete, the next context should:
68
+
69
+ 1. keep the current source and doc changes
70
+ 2. delete `.audit-artifacts/`
71
+ 3. delete `audit-report.md`
72
+ 4. run `npm run build`
73
+ 5. run the most relevant regression tests for the refactor
74
+ 6. start a fresh `/audit-code` run
75
+ 7. treat the new audit output as the release gate
package/docs/run-flow.md CHANGED
@@ -4,20 +4,29 @@ The canonical product route is `/audit-code` in conversation.
4
4
 
5
5
  This document describes the backend execution flow that supports that conversational route and the repo-local fallback wrapper.
6
6
 
7
- ## Current backend execution path
7
+ ## Intended review-dispatch path
8
8
 
9
9
  1. Build or import a repository manifest.
10
- 2. Build audit units from the repository manifest.
11
- 3. Initialize a coverage matrix from the file list.
12
- 4. Apply unit-to-file coverage requirements.
13
- 5. Build initial audit tasks.
14
- 6. Dispatch those tasks to LLM agents or other runtimes.
10
+ 2. Build units, flows, and other deterministic structure artifacts.
11
+ 3. Determine which files require which lenses.
12
+ 4. Partition unresolved file/lens obligations into non-overlapping review blocks.
13
+ 5. Hand one review block at a time to the active conversation agent.
14
+ 6. Let the active agent decide whether it wants to use subagents in parallel.
15
15
  7. Ingest structured audit results.
16
- 8. Apply reviewed ranges and completed lenses to the coverage matrix.
17
- 9. Build requeue tasks for missing lenses or uncovered ranges.
16
+ 8. Mark completed file/lens coverage in the coverage matrix.
17
+ 9. Build requeue only for still-missing coverage.
18
18
  10. Repeat until coverage rules are satisfied.
19
19
  11. Synthesize findings into merged outputs.
20
20
 
21
+ ## Current implementation note
22
+
23
+ The current TypeScript backend still has workflow drift:
24
+
25
+ - planning is still mostly unit-first rather than lens-block-first
26
+ - explicit backend providers can still end up owning semantic review in fallback mode
27
+
28
+ That drift is being tracked explicitly in [docs/workflow-refactor-brief.md](/C:/Code/auditor-lambda/docs/workflow-refactor-brief.md).
29
+
21
30
  ## Current backend capability
22
31
 
23
32
  The current TypeScript implementation already covers:
@@ -27,23 +36,26 @@ The current TypeScript implementation already covers:
27
36
  - reviewed-range ingestion from audit results
28
37
  - runtime validation update ingestion
29
38
  - synthesis and completion tracking
30
- - backend provider handoff for interactive or assisted review
39
+ - backend provider handoff for fallback or compatibility review flows
31
40
 
32
41
  ## Product interpretation
33
42
 
34
43
  - the conversation route should hide this state machine behind `/audit-code`
35
44
  - the repo-local `audit-code` wrapper is fallback infrastructure for operators and local harnesses
36
45
  - provider adapters and artifact plumbing are backend details, not the primary product story
46
+ - the active conversation agent should own semantic review by default
37
47
  - when fallback execution blocks, the wrapper should still leave behind explicit operator handoff files and suggested evidence-import paths
38
48
 
39
49
  ## Next backend implementation steps
40
50
 
41
51
  The next backend-focused work should support the conversation route more directly by:
42
52
 
43
- - reducing operator friction when the backend reaches a blocked handoff
44
- - improving continuation when interactive providers are configured
53
+ - realigning review planning around non-overlapping lens blocks
54
+ - moving semantic-review ownership back to the active conversation agent
55
+ - keeping backend provider bridges explicitly secondary
45
56
  - keeping evidence import and runtime-update handoff paths explicit and easier to follow
46
57
 
47
58
  Broader product priorities are tracked in:
48
59
 
60
+ - `docs/workflow-refactor-brief.md`
49
61
  - `docs/next-steps.md`
@@ -1,9 +1,14 @@
1
1
  # session-config
2
2
 
3
- This file only applies to the backend fallback CLI.
3
+ This file only applies to explicit backend fallback workflows.
4
4
 
5
5
  The canonical `/audit-code` conversation route should not require users to touch it.
6
6
 
7
+ It does not define who owns semantic review in the canonical conversation flow, and it is not enough by itself to transfer semantic review away from the active conversation agent.
8
+
9
+ In the intended product workflow, the active conversation agent owns review tasks and any subagent fan-out.
10
+ Use this file only when you intentionally need backend fallback behavior or an explicit compatibility bridge.
11
+
7
12
  Backend provider configuration lives at:
8
13
 
9
14
  ```text
@@ -35,8 +40,7 @@ audit-code validate
35
40
  "provider": "local-subprocess",
36
41
  "timeout_ms": 1800000,
37
42
  "ui_mode": "headless",
38
- "agent_task_batch_size": 4,
39
- "parallel_workers": 2
43
+ "agent_task_batch_size": 1
40
44
  }
41
45
  ```
42
46
 
@@ -51,6 +55,12 @@ Supported values:
51
55
  - `opencode`
52
56
  - `vscode-task`
53
57
 
58
+ Current implementation note:
59
+
60
+ - `claude-code`, `opencode`, `subprocess-template`, and `vscode-task` are backend compatibility bridges
61
+ - they are not the intended default owner of semantic review when the active conversation agent can handle the work directly
62
+ - to activate one of those bridges for semantic review, re-run the wrapper with an explicit `--provider <name>` flag
63
+
54
64
  ### `timeout_ms`
55
65
 
56
66
  Worker-run timeout in milliseconds.
@@ -70,10 +80,16 @@ How many audit tasks to include in one provider-assisted review batch.
70
80
 
71
81
  When this is greater than `1`, the generated worker prompt points at `current-tasks.json` / `pending-audit-tasks.json` and expects one `AuditResult` per assigned task.
72
82
 
83
+ The intended default review granularity remains one review block per task.
84
+
73
85
  ### `parallel_workers`
74
86
 
75
87
  How many provider-assisted review batches to launch in parallel when the selected provider supports it.
76
88
 
89
+ This setting only applies to explicit backend bridge launches.
90
+
91
+ It should not be treated as the source of truth for in-conversation subagent parallelism, which belongs to the active conversation agent or host runtime.
92
+
77
93
  ## Auto provider mode
78
94
 
79
95
  `auto` is an explicit opt-in mode.
@@ -96,7 +112,11 @@ This keeps the current default stable while still allowing best-effort cross-edi
96
112
 
97
113
  No extra config is required.
98
114
 
99
- This mode covers deterministic worker runs locally and stops in a terminal blocked state once the remaining work requires imported audit results or an interactive provider.
115
+ This mode covers deterministic audit execution locally and stops in a terminal blocked state once the remaining work requires imported audit results or an interactive provider.
116
+
117
+ When the active conversation agent reviews multiple task batches before ingestion, prefer `audit-code --batch-results <dir>` over ad hoc artifact edits.
118
+
119
+ This remains the safest fallback default while the semantic-review workflow is being realigned.
100
120
 
101
121
  ### `claude_code`
102
122
 
@@ -116,7 +136,9 @@ Fields:
116
136
  - `command`: optional override for the Claude Code executable
117
137
  - `extra_args`: optional extra arguments appended before the built-in permission-skipping flag
118
138
 
119
- When audit-task review is pending, the generated provider prompt now asks Claude Code to write structured `AuditResult[]` output and then run the bounded worker command so the same `audit-code` invocation can keep advancing.
139
+ Current implementation support only.
140
+
141
+ Use this only when you intentionally want the backend fallback CLI to bridge review into an external Claude Code process, together with `audit-code --provider claude-code`.
120
142
 
121
143
  ### `opencode`
122
144
 
@@ -136,7 +158,9 @@ Fields:
136
158
  - `command`: optional override for the OpenCode executable
137
159
  - `extra_args`: optional additional arguments for `opencode run ...`
138
160
 
139
- When audit-task review is pending, the generated provider prompt now asks OpenCode to write structured `AuditResult[]` output and then run the bounded worker command so the same `audit-code` invocation can keep advancing.
161
+ Current implementation support only.
162
+
163
+ Use this only when you intentionally want the backend fallback CLI to bridge review into an external OpenCode process, together with `audit-code --provider opencode`.
140
164
 
141
165
  ### `subprocess_template`
142
166
 
@@ -157,6 +181,7 @@ Fields:
157
181
  - `env`: optional environment-variable overlay
158
182
 
159
183
  When you use this bridge for provider-assisted review, the launched process should write structured audit results to `task.audit_results_path` and then execute `task.worker_command`.
184
+ Activate it explicitly with `audit-code --provider subprocess-template`.
160
185
 
161
186
  ### `vscode_task`
162
187
 
@@ -172,6 +197,7 @@ When you use this bridge for provider-assisted review, the launched process shou
172
197
  ```
173
198
 
174
199
  This adapter is intentionally thin. It uses the same template expansion model as `subprocess-template`, but is named separately so the operator intent is explicit.
200
+ Activate it explicitly with `audit-code --provider vscode-task`.
175
201
 
176
202
  ## Template placeholders
177
203
 
@@ -215,6 +241,9 @@ This adapter is intentionally thin. It uses the same template expansion model as
215
241
  }
216
242
  ```
217
243
 
244
+ Use this only when you intentionally want backend fallback routing.
245
+ It is not the canonical semantic-review path.
246
+
218
247
  ### Delegate worker runs into Claude Code
219
248
 
220
249
  ```json
@@ -224,6 +253,12 @@ This adapter is intentionally thin. It uses the same template expansion model as
224
253
  }
225
254
  ```
226
255
 
256
+ Then start the backend bridge explicitly:
257
+
258
+ ```bash
259
+ audit-code --provider claude-code
260
+ ```
261
+
227
262
  ### Delegate worker runs into OpenCode
228
263
 
229
264
  ```json
@@ -233,6 +268,12 @@ This adapter is intentionally thin. It uses the same template expansion model as
233
268
  }
234
269
  ```
235
270
 
271
+ Then start the backend bridge explicitly:
272
+
273
+ ```bash
274
+ audit-code --provider opencode
275
+ ```
276
+
236
277
  ### Use a generic bash launcher bridge
237
278
 
238
279
  ```json
@@ -245,6 +286,12 @@ This adapter is intentionally thin. It uses the same template expansion model as
245
286
  }
246
287
  ```
247
288
 
289
+ Then start the backend bridge explicitly:
290
+
291
+ ```bash
292
+ audit-code --provider subprocess-template
293
+ ```
294
+
248
295
  ## Antigravity note
249
296
 
250
297
  A dedicated Antigravity adapter is not currently shipped.
@@ -6,6 +6,9 @@ The primary product contract is `/audit-code` in conversation.
6
6
 
7
7
  Everything here is fallback and implementation detail guidance for the repo-local backend surface.
8
8
 
9
+ In the intended workflow, the active conversation agent owns semantic review.
10
+ Provider adapters are compatibility bridges for backend fallback mode, not the default review owner.
11
+
9
12
  ## Repo-local backend surface
10
13
 
11
14
  From the target repository root:
@@ -55,6 +58,9 @@ audit-code --provider subprocess-template
55
58
  audit-code --provider vscode-task
56
59
  ```
57
60
 
61
+ Those `--provider` invocations are the explicit bridge handoff point.
62
+ Without an explicit `--provider` flag, the backend keeps semantic review with the active conversation agent and uses `local-subprocess` only for deterministic worker steps.
63
+
58
64
  ## Auto resolution rule
59
65
 
60
66
  When `provider` is set to `auto`, the backend resolves in this order:
@@ -81,3 +87,4 @@ See:
81
87
  ## Note
82
88
 
83
89
  Provider adapters are backend integrations, not the primary product concept.
90
+ Session config defines bridge settings, but the explicit `--provider` flag is what opts the backend into owning semantic-review dispatch.
@@ -0,0 +1,177 @@
1
+ # Workflow Refactor Brief
2
+
3
+ This document is the handoff for the next context window.
4
+
5
+ Use it as the source of truth for the workflow refactor before running a fresh audit again.
6
+
7
+ ## Why this refactor is needed
8
+
9
+ The current implementation still advances deterministic audit state correctly, but the semantic-review phase has drifted away from the intended product behavior.
10
+
11
+ The key symptom is that the backend can currently treat `provider` selection as the owner of review work, which is how the recent rerun ended up trying to use `claude-code` from `.audit-artifacts/session-config.json`.
12
+
13
+ That is not the intended workflow.
14
+
15
+ ## Intended workflow
16
+
17
+ The intended `/audit-code` workflow is:
18
+
19
+ 1. The active conversation agent owns semantic review work.
20
+ 2. Deterministic planning computes which files need which lenses.
21
+ 3. Pending review is partitioned into non-overlapping review blocks, preferably grouped by lens.
22
+ 4. One dispatched review task should correspond to one review block.
23
+ 5. `agent_task_batch_size` should stay `1` by default.
24
+ 6. If the active conversation agent can delegate to subagents in parallel, that fan-out belongs to the host agent runtime, not to the backend session config.
25
+ 7. Backend provider adapters are fallback compatibility bridges only. They should not be the default review owner.
26
+
27
+ ## Current implementation drift
28
+
29
+ The current code differs from that model in several important ways.
30
+
31
+ ### 1. Review ownership is provider-mediated
32
+
33
+ Today, the `agent` executor in the backend fallback path is still routed through `createFreshSessionProvider()` and may spawn an external CLI such as `claude` or `opencode`.
34
+
35
+ Relevant files:
36
+
37
+ - [src/cli.ts](/C:/Code/auditor-lambda/src/cli.ts:771)
38
+ - [src/providers/index.ts](/C:/Code/auditor-lambda/src/providers/index.ts:37)
39
+ - [src/providers/claudeCodeProvider.ts](/C:/Code/auditor-lambda/src/providers/claudeCodeProvider.ts:12)
40
+ - [src/providers/opencodeProvider.ts](/C:/Code/auditor-lambda/src/providers/opencodeProvider.ts)
41
+ - [src/providers/spawnLoggedCommand.ts](/C:/Code/auditor-lambda/src/providers/spawnLoggedCommand.ts:24)
42
+
43
+ ### 2. Task planning is unit-first, not lens-first
44
+
45
+ `buildChunkedAuditTasks()` currently creates tasks as `unit x lens`, then optionally splits oversized files into separate per-lens tasks.
46
+
47
+ Relevant files:
48
+
49
+ - [src/orchestrator/taskBuilder.ts](/C:/Code/auditor-lambda/src/orchestrator/taskBuilder.ts:101)
50
+ - [src/orchestrator/unitBuilder.ts](/C:/Code/auditor-lambda/src/orchestrator/unitBuilder.ts:130)
51
+
52
+ ### 3. Required lenses are unioned at the unit level
53
+
54
+ The planner derives `required_lenses` for a unit, then applies that whole union to every file in the unit.
55
+
56
+ That means the task count grows with `units x required_lenses`, not with a deliberately partitioned set of file/lens review blocks.
57
+
58
+ Relevant files:
59
+
60
+ - [src/orchestrator/unitBuilder.ts](/C:/Code/auditor-lambda/src/orchestrator/unitBuilder.ts:153)
61
+ - [src/orchestrator/planning.ts](/C:/Code/auditor-lambda/src/orchestrator/planning.ts:63)
62
+ - [src/coverage.ts](/C:/Code/auditor-lambda/src/coverage.ts:29)
63
+
64
+ ### 4. Flow augmentation adds overlapping review tasks
65
+
66
+ After the base unit tasks are built, the planner adds extra flow-aware tasks rather than repartitioning the pending review set into one global non-overlapping dispatch plan.
67
+
68
+ Relevant file:
69
+
70
+ - [src/orchestrator/flowPlanning.ts](/C:/Code/auditor-lambda/src/orchestrator/flowPlanning.ts:9)
71
+
72
+ ### 5. `parallel_workers` means subprocess fan-out, not agent-owned parallelism
73
+
74
+ The current `parallel_workers` setting only controls how many external provider worker runs the backend fallback CLI launches.
75
+
76
+ It does not represent, and should not limit, the active conversation agent's own ability to use subagents.
77
+
78
+ Relevant files:
79
+
80
+ - [src/cli.ts](/C:/Code/auditor-lambda/src/cli.ts:83)
81
+ - [src/cli.ts](/C:/Code/auditor-lambda/src/cli.ts:960)
82
+
83
+ ## Evidence from the current stale audit
84
+
85
+ The current stale audit run produced:
86
+
87
+ - `91` units
88
+ - average `3.26` required lenses per unit
89
+ - `333` audit tasks total
90
+ - `294` regular unit-lens tasks
91
+ - `10` large-file split tasks
92
+ - `29` flow tasks
93
+
94
+ That fan-out is consistent with the current unit-first planner, not with the intended lens-block dispatch model.
95
+
96
+ ## Refactor goals
97
+
98
+ The next implementation pass should do the following.
99
+
100
+ ### A. Make the active conversation agent the semantic-review owner
101
+
102
+ The `agent` executor should represent review work owned by the current conversation or host agent session.
103
+
104
+ Target behavior:
105
+
106
+ - normal `/audit-code` usage does not require `provider: "claude-code"` or `provider: "opencode"`
107
+ - session-config should not be the normal way to choose a second LLM for review
108
+ - backend provider bridges remain available only for explicit fallback workflows
109
+
110
+ ### B. Plan review work at the file/lens level
111
+
112
+ Coverage should still know which files require which lenses, but dispatch planning should work from unresolved `(file, lens)` obligations rather than from unit-wide lens unions.
113
+
114
+ Target behavior:
115
+
116
+ - each review block should have explicit `file_paths`
117
+ - each review block should represent one lens
118
+ - review blocks in the same dispatch wave should be file-disjoint unless overlap is intentionally justified
119
+
120
+ ### C. Partition pending review into non-overlapping blocks
121
+
122
+ Replace the current unit-first task planner with a lens-aware block planner.
123
+
124
+ Target behavior:
125
+
126
+ - no combinatorial `unit x lens` explosion unless that is genuinely the smallest valid partition
127
+ - large-file splitting may remain, but it should happen inside the lens-block planner
128
+ - critical-flow context should influence block construction without blindly adding overlapping tasks on top
129
+
130
+ ### D. Keep result ingestion deterministic
131
+
132
+ The current ingestion model is mostly sound and should be preserved.
133
+
134
+ Relevant files:
135
+
136
+ - [src/orchestrator/resultIngestion.ts](/C:/Code/auditor-lambda/src/orchestrator/resultIngestion.ts)
137
+ - [src/coverage.ts](/C:/Code/auditor-lambda/src/coverage.ts:42)
138
+
139
+ ### E. Reframe session-config as backend fallback only
140
+
141
+ `session-config.json` should continue to configure backend fallback bridges, but it should not be treated as the owner of semantic-review orchestration in the canonical workflow.
142
+
143
+ `parallel_workers` should either:
144
+
145
+ - become a legacy fallback-only knob, or
146
+ - be removed from the semantic-review mental model entirely
147
+
148
+ ## Acceptance criteria
149
+
150
+ The refactor should be treated as done only when all of the following are true.
151
+
152
+ - Starting `/audit-code` in a conversation does not rely on an external `claude-code` or `opencode` subprocess to own semantic review.
153
+ - The backend fallback still supports deterministic stages and explicit compatibility bridges.
154
+ - The default dispatch granularity for semantic review remains one review block per task.
155
+ - Pending review tasks are planned as lens-aware, non-overlapping file blocks.
156
+ - `parallel_workers` no longer defines the default semantic-review parallelism model.
157
+ - The next fresh audit can be run from a clean slate without inheriting the current stale provider-mediated task queue.
158
+
159
+ ## Suggested implementation order
160
+
161
+ 1. Refactor the review-ownership model in [src/cli.ts](/C:/Code/auditor-lambda/src/cli.ts), [src/providers/index.ts](/C:/Code/auditor-lambda/src/providers/index.ts), and related supervisor docs.
162
+ 2. Replace the current task planner in [src/orchestrator/taskBuilder.ts](/C:/Code/auditor-lambda/src/orchestrator/taskBuilder.ts) with a lens-block planner.
163
+ 3. Rework flow-aware planning in [src/orchestrator/flowPlanning.ts](/C:/Code/auditor-lambda/src/orchestrator/flowPlanning.ts) so it participates in block construction instead of layering overlapping tasks afterward.
164
+ 4. Update docs and tests.
165
+ 5. Delete the stale audit state and rerun the audit from scratch.
166
+
167
+ ## Clean rerun after refactor
168
+
169
+ Once the refactor is in place, the next context should:
170
+
171
+ 1. keep the source changes and documentation already in the worktree
172
+ 2. delete `.audit-artifacts/`
173
+ 3. delete `audit-report.md`
174
+ 4. run the workflow again from a clean state
175
+ 5. treat the new audit output as authoritative
176
+
177
+ For the remediation baseline that should survive the stale audit reset, see [docs/remediation-baseline.md](/C:/Code/auditor-lambda/docs/remediation-baseline.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auditor-lambda",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "private": false,
5
5
  "description": "Portable hybrid code-auditing framework for arbitrary repositories.",
6
6
  "type": "module",
@@ -131,6 +131,7 @@
131
131
  "type": "string",
132
132
  "enum": [
133
133
  "--results",
134
+ "--batch-results",
134
135
  "--updates",
135
136
  "--external-analyzer-results"
136
137
  ]
@@ -20,7 +20,10 @@
20
20
  "task_id": { "type": "string" },
21
21
  "unit_id": { "type": "string" },
22
22
  "pass_id": { "type": "string" },
23
- "lens": { "type": "string" },
23
+ "lens": {
24
+ "type": "string",
25
+ "enum": ["correctness", "architecture", "maintainability", "security", "reliability", "performance", "data_integrity", "tests", "operability", "config_deployment"]
26
+ },
24
27
  "agent_role": { "type": "string" },
25
28
  "file_coverage": {
26
29
  "type": "array",
@@ -21,6 +21,7 @@
21
21
  },
22
22
  "file_paths": {
23
23
  "type": "array",
24
+ "minItems": 1,
24
25
  "items": { "type": "string" }
25
26
  },
26
27
  "line_ranges": {
@@ -44,7 +45,7 @@
44
45
  "mechanical_results_ref": { "type": "string" },
45
46
  "risk_register_ref": { "type": "string" }
46
47
  },
47
- "additionalProperties": true
48
+ "additionalProperties": { "type": "string" }
48
49
  },
49
50
  "rationale": { "type": "string" },
50
51
  "priority": {
@@ -53,6 +54,7 @@
53
54
  },
54
55
  "tags": {
55
56
  "type": "array",
57
+ "minItems": 1,
56
58
  "items": { "type": "string" }
57
59
  },
58
60
  "status": {
@@ -9,7 +9,7 @@
9
9
  "type": "array",
10
10
  "items": {
11
11
  "type": "object",
12
- "required": ["path", "classification_status", "audit_status"],
12
+ "required": ["path", "unit_ids", "classification_status", "audit_status", "required_lenses", "completed_lenses"],
13
13
  "properties": {
14
14
  "path": { "type": "string" },
15
15
  "unit_ids": {
@@ -39,9 +39,9 @@
39
39
  }
40
40
  }
41
41
  },
42
- "additionalProperties": true
42
+ "additionalProperties": false
43
43
  }
44
44
  }
45
45
  },
46
- "additionalProperties": true
46
+ "additionalProperties": false
47
47
  }
@@ -31,11 +31,15 @@
31
31
  "notes": {
32
32
  "type": "array",
33
33
  "items": { "type": "string" }
34
+ },
35
+ "confidence": {
36
+ "type": "string",
37
+ "enum": ["high", "low"]
34
38
  }
35
39
  },
36
- "additionalProperties": true
40
+ "additionalProperties": false
37
41
  }
38
42
  }
39
43
  },
40
- "additionalProperties": true
44
+ "additionalProperties": false
41
45
  }
@@ -25,9 +25,9 @@
25
25
  },
26
26
  "reason": { "type": "string" }
27
27
  },
28
- "additionalProperties": true
28
+ "additionalProperties": false
29
29
  }
30
30
  }
31
31
  },
32
- "additionalProperties": true
32
+ "additionalProperties": false
33
33
  }
@@ -11,7 +11,8 @@
11
11
  "confidence",
12
12
  "lens",
13
13
  "affected_files",
14
- "summary"
14
+ "summary",
15
+ "evidence"
15
16
  ],
16
17
  "properties": {
17
18
  "id": { "type": "string" },
@@ -54,13 +55,14 @@
54
55
  "summary": { "type": "string" },
55
56
  "affected_files": {
56
57
  "type": "array",
58
+ "minItems": 1,
57
59
  "items": {
58
60
  "type": "object",
59
61
  "required": ["path"],
60
62
  "properties": {
61
63
  "path": { "type": "string" },
62
- "line_start": { "type": "integer" },
63
- "line_end": { "type": "integer" },
64
+ "line_start": { "type": "integer", "minimum": 1 },
65
+ "line_end": { "type": "integer", "minimum": 1 },
64
66
  "symbol": { "type": "string" }
65
67
  },
66
68
  "additionalProperties": false
@@ -70,17 +72,20 @@
70
72
  "likelihood": { "type": "string" },
71
73
  "evidence": {
72
74
  "type": "array",
75
+ "minItems": 1,
73
76
  "items": { "type": "string" }
74
77
  },
75
78
  "reproduction": {
76
79
  "type": "array",
80
+ "minItems": 1,
77
81
  "items": { "type": "string" }
78
82
  },
79
83
  "systemic": { "type": "boolean" },
80
84
  "related_findings": {
81
85
  "type": "array",
86
+ "minItems": 1,
82
87
  "items": { "type": "string" }
83
88
  }
84
89
  },
85
- "additionalProperties": true
90
+ "additionalProperties": false
86
91
  }