auditor-lambda 0.2.6 → 0.2.9

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 (125) hide show
  1. package/README.md +29 -7
  2. package/audit-code-wrapper-lib.mjs +1605 -330
  3. package/dist/adapters/eslint.js +9 -5
  4. package/dist/cli.d.ts +42 -1
  5. package/dist/cli.js +192 -80
  6. package/dist/coverage.d.ts +2 -2
  7. package/dist/coverage.js +5 -5
  8. package/dist/extractors/bucketing.d.ts +4 -0
  9. package/dist/extractors/bucketing.js +6 -2
  10. package/dist/extractors/disposition.d.ts +4 -0
  11. package/dist/extractors/disposition.js +15 -2
  12. package/dist/extractors/fileInventory.js +24 -28
  13. package/dist/extractors/flows.d.ts +5 -0
  14. package/dist/extractors/flows.js +25 -39
  15. package/dist/extractors/pathPatterns.d.ts +13 -3
  16. package/dist/extractors/pathPatterns.js +116 -53
  17. package/dist/extractors/risk.js +7 -1
  18. package/dist/extractors/surfaces.d.ts +4 -0
  19. package/dist/extractors/surfaces.js +11 -11
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +2 -1
  22. package/dist/io/artifacts.d.ts +59 -44
  23. package/dist/io/artifacts.js +80 -120
  24. package/dist/io/json.d.ts +2 -0
  25. package/dist/io/json.js +65 -19
  26. package/dist/io/runArtifacts.d.ts +2 -1
  27. package/dist/io/runArtifacts.js +44 -7
  28. package/dist/mcp/server.d.ts +1 -0
  29. package/dist/mcp/server.js +579 -0
  30. package/dist/orchestrator/advance.js +84 -56
  31. package/dist/orchestrator/dependencyMap.js +9 -13
  32. package/dist/orchestrator/executors.js +7 -2
  33. package/dist/orchestrator/flowCoverage.js +11 -5
  34. package/dist/orchestrator/flowPlanning.d.ts +7 -2
  35. package/dist/orchestrator/flowPlanning.js +46 -21
  36. package/dist/orchestrator/flowRequeue.js +29 -9
  37. package/dist/orchestrator/internalExecutors.d.ts +2 -1
  38. package/dist/orchestrator/internalExecutors.js +130 -69
  39. package/dist/orchestrator/planning.js +25 -3
  40. package/dist/orchestrator/requeue.js +20 -5
  41. package/dist/orchestrator/resultIngestion.js +5 -6
  42. package/dist/orchestrator/runtimeValidation.d.ts +7 -2
  43. package/dist/orchestrator/runtimeValidation.js +61 -49
  44. package/dist/orchestrator/runtimeValidationUpdate.js +2 -4
  45. package/dist/orchestrator/state.js +18 -13
  46. package/dist/orchestrator/taskBuilder.d.ts +4 -2
  47. package/dist/orchestrator/taskBuilder.js +153 -52
  48. package/dist/orchestrator/trivialAudit.js +8 -5
  49. package/dist/orchestrator/unitBuilder.d.ts +3 -1
  50. package/dist/orchestrator/unitBuilder.js +24 -16
  51. package/dist/prompts/renderWorkerPrompt.d.ts +1 -1
  52. package/dist/prompts/renderWorkerPrompt.js +19 -10
  53. package/dist/providers/claudeCodeProvider.d.ts +4 -1
  54. package/dist/providers/claudeCodeProvider.js +8 -5
  55. package/dist/providers/localSubprocessProvider.d.ts +4 -0
  56. package/dist/providers/localSubprocessProvider.js +7 -2
  57. package/dist/providers/spawnLoggedCommand.d.ts +9 -1
  58. package/dist/providers/spawnLoggedCommand.js +77 -29
  59. package/dist/reporting/mergeFindings.js +0 -11
  60. package/dist/reporting/synthesis.d.ts +26 -21
  61. package/dist/reporting/synthesis.js +97 -61
  62. package/dist/reporting/workBlocks.d.ts +12 -3
  63. package/dist/reporting/workBlocks.js +124 -70
  64. package/dist/supervisor/operatorHandoff.js +48 -18
  65. package/dist/supervisor/runLedger.d.ts +1 -1
  66. package/dist/supervisor/runLedger.js +112 -5
  67. package/dist/supervisor/sessionConfig.js +10 -10
  68. package/dist/types/externalAnalyzer.d.ts +3 -0
  69. package/dist/types/flowCoverage.d.ts +5 -1
  70. package/dist/types/flowCoverage.js +5 -1
  71. package/dist/types/flows.d.ts +6 -0
  72. package/dist/types/flows.js +1 -1
  73. package/dist/types/runLedger.d.ts +5 -1
  74. package/dist/types/runLedger.js +6 -1
  75. package/dist/types/runtimeValidation.d.ts +13 -3
  76. package/dist/types/runtimeValidation.js +16 -1
  77. package/dist/types/sessionConfig.d.ts +15 -2
  78. package/dist/types/sessionConfig.js +15 -1
  79. package/dist/types/surfaces.d.ts +4 -1
  80. package/dist/types/surfaces.js +1 -1
  81. package/dist/types/workerSession.d.ts +9 -0
  82. package/dist/types/workerSession.js +5 -1
  83. package/dist/types.d.ts +4 -7
  84. package/dist/validation/artifacts.d.ts +1 -1
  85. package/dist/validation/artifacts.js +33 -20
  86. package/dist/validation/auditResults.d.ts +2 -2
  87. package/dist/validation/auditResults.js +71 -114
  88. package/dist/validation/basic.d.ts +9 -1
  89. package/dist/validation/basic.js +40 -3
  90. package/dist/validation/sessionConfig.d.ts +4 -2
  91. package/dist/validation/sessionConfig.js +62 -15
  92. package/docs/agent-integrations.md +67 -38
  93. package/docs/artifacts.md +16 -56
  94. package/docs/bootstrap-install.md +60 -30
  95. package/docs/contract.md +22 -205
  96. package/docs/next-steps.md +76 -44
  97. package/docs/packaging.md +27 -3
  98. package/docs/product-direction.md +22 -0
  99. package/docs/production-launch-bar.md +4 -2
  100. package/docs/production-readiness.md +9 -5
  101. package/docs/releasing.md +98 -0
  102. package/docs/remediation-baseline.md +75 -0
  103. package/docs/run-flow.md +23 -11
  104. package/docs/session-config.md +50 -5
  105. package/docs/supervisor.md +7 -0
  106. package/docs/workflow-refactor-brief.md +177 -0
  107. package/package.json +4 -1
  108. package/schemas/audit_result.schema.json +8 -7
  109. package/schemas/audit_task.schema.json +3 -1
  110. package/schemas/coverage_matrix.schema.json +3 -3
  111. package/schemas/critical_flows.schema.json +6 -2
  112. package/schemas/file_disposition.schema.json +2 -2
  113. package/schemas/finding.schema.json +9 -4
  114. package/schemas/flow_coverage.schema.json +2 -2
  115. package/schemas/repo_manifest.schema.json +4 -4
  116. package/schemas/risk_register.schema.json +2 -2
  117. package/schemas/runtime_validation_report.schema.json +3 -3
  118. package/schemas/runtime_validation_tasks.schema.json +8 -2
  119. package/schemas/surface_manifest.schema.json +6 -3
  120. package/schemas/unit_manifest.schema.json +3 -2
  121. package/skills/audit-code/SKILL.md +16 -2
  122. package/skills/audit-code/audit-code.prompt.md +5 -8
  123. package/schemas/merged_findings.schema.json +0 -19
  124. package/schemas/root_cause_clusters.schema.json +0 -28
  125. package/schemas/synthesis_report.schema.json +0 -61
@@ -0,0 +1,98 @@
1
+ # Releasing
2
+
3
+ This repository publishes to npm through GitHub Actions Trusted Publishing.
4
+
5
+ The canonical workflow is:
6
+
7
+ `/.github/workflows/publish-package.yml`
8
+
9
+ That workflow already:
10
+
11
+ - runs on GitHub-hosted runners
12
+ - requests `id-token: write` for npm OIDC exchange
13
+ - pins Node `22.14.0`
14
+ - upgrades npm to `>=11.5.1`
15
+ - runs `npm run verify:release` before any publish attempt
16
+ - previews the packed tarball with `npm pack --dry-run` before any live publish attempt
17
+ - defaults semver prerelease versions to the `next` dist-tag unless manual dispatch overrides it
18
+ - uploads npm debug logs when a publish-path step fails
19
+
20
+ ## One-time npm setup
21
+
22
+ Before the first live publish, configure npm itself to trust this repository:
23
+
24
+ 1. confirm the intended npm owner already controls `auditor-lambda`
25
+ 2. in the npm package settings, add a GitHub Actions trusted publisher for:
26
+ - owner or organization: `OhOkThisIsFine`
27
+ - repository: `auditor-lambda`
28
+ - workflow filename: `publish-package.yml`
29
+ 3. keep the workflow filename stable after that, or update the npm trusted publisher entry before renaming it
30
+ 4. after the first successful trusted publish, consider enabling npm's setting that requires 2FA and disallows legacy publish tokens
31
+
32
+ ## Release preflight
33
+
34
+ From the repository root:
35
+
36
+ ```bash
37
+ npm ci
38
+ npm run verify:release
39
+ npm publish --dry-run
40
+ ```
41
+
42
+ The local dry run is still valuable even though the real publish happens in GitHub Actions. It proves the packed artifact, lifecycle hooks, and publish metadata before you spend a release on a broken workflow run.
43
+
44
+ ## Supported Node lines
45
+
46
+ Routine CI currently exercises the repository on Node `20` and Node `22`.
47
+
48
+ Release and publish workflows stay pinned to Node `22.14.0` because that is the line this repository uses for npm Trusted Publishing and release smoke verification.
49
+
50
+ ## GitHub release paths
51
+
52
+ ### Manual dry run
53
+
54
+ Use GitHub Actions `workflow_dispatch` when you want to prove the exact publish workflow without uploading a package.
55
+
56
+ Recommended inputs:
57
+
58
+ - `dry_run=true`
59
+ - `publish_tag=auto`
60
+
61
+ `publish_tag=auto` resolves like this:
62
+
63
+ - stable versions publish to `latest`
64
+ - semver prerelease versions publish to `next`
65
+
66
+ ### Manual live publish
67
+
68
+ Use `workflow_dispatch` with:
69
+
70
+ - `dry_run=false`
71
+ - `publish_tag=auto` unless you intentionally need a different dist-tag
72
+
73
+ This is the safest path for the first trusted-publishing release because it lets you prove the workflow before tying it to a GitHub Release event.
74
+
75
+ ### Release-driven publish
76
+
77
+ After the manual path is proven, publishing a GitHub Release will trigger the same workflow and publish the package.
78
+
79
+ ## Workflow troubleshooting
80
+
81
+ If a GitHub Actions run fails:
82
+
83
+ 1. download the uploaded `*-npm-logs` artifact from the failed run
84
+ 2. rerun `npm ci` and `npm run verify:release` locally from the same commit
85
+ 3. for publish failures, rerun `publish-package.yml` with `dry_run=true` before retrying a live publish
86
+ 4. if publish still fails, confirm npm Trusted Publishing is still configured for `publish-package.yml`
87
+
88
+ ## Post-publish checks
89
+
90
+ After a live publish, verify the result from a clean shell:
91
+
92
+ ```bash
93
+ npm view auditor-lambda version
94
+ npm view auditor-lambda dist-tags --json
95
+ npm audit signatures
96
+ ```
97
+
98
+ Also confirm that the npm package page shows the expected version and provenance information.
@@ -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.
@@ -98,6 +114,8 @@ No extra config is required.
98
114
 
99
115
  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.
100
116
 
117
+ This remains the safest fallback default while the semantic-review workflow is being realigned.
118
+
101
119
  ### `claude_code`
102
120
 
103
121
  ```json
@@ -116,7 +134,9 @@ Fields:
116
134
  - `command`: optional override for the Claude Code executable
117
135
  - `extra_args`: optional extra arguments appended before the built-in permission-skipping flag
118
136
 
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.
137
+ Current implementation support only.
138
+
139
+ 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
140
 
121
141
  ### `opencode`
122
142
 
@@ -136,7 +156,9 @@ Fields:
136
156
  - `command`: optional override for the OpenCode executable
137
157
  - `extra_args`: optional additional arguments for `opencode run ...`
138
158
 
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.
159
+ Current implementation support only.
160
+
161
+ 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
162
 
141
163
  ### `subprocess_template`
142
164
 
@@ -157,6 +179,7 @@ Fields:
157
179
  - `env`: optional environment-variable overlay
158
180
 
159
181
  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`.
182
+ Activate it explicitly with `audit-code --provider subprocess-template`.
160
183
 
161
184
  ### `vscode_task`
162
185
 
@@ -172,6 +195,7 @@ When you use this bridge for provider-assisted review, the launched process shou
172
195
  ```
173
196
 
174
197
  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.
198
+ Activate it explicitly with `audit-code --provider vscode-task`.
175
199
 
176
200
  ## Template placeholders
177
201
 
@@ -215,6 +239,9 @@ This adapter is intentionally thin. It uses the same template expansion model as
215
239
  }
216
240
  ```
217
241
 
242
+ Use this only when you intentionally want backend fallback routing.
243
+ It is not the canonical semantic-review path.
244
+
218
245
  ### Delegate worker runs into Claude Code
219
246
 
220
247
  ```json
@@ -224,6 +251,12 @@ This adapter is intentionally thin. It uses the same template expansion model as
224
251
  }
225
252
  ```
226
253
 
254
+ Then start the backend bridge explicitly:
255
+
256
+ ```bash
257
+ audit-code --provider claude-code
258
+ ```
259
+
227
260
  ### Delegate worker runs into OpenCode
228
261
 
229
262
  ```json
@@ -233,6 +266,12 @@ This adapter is intentionally thin. It uses the same template expansion model as
233
266
  }
234
267
  ```
235
268
 
269
+ Then start the backend bridge explicitly:
270
+
271
+ ```bash
272
+ audit-code --provider opencode
273
+ ```
274
+
236
275
  ### Use a generic bash launcher bridge
237
276
 
238
277
  ```json
@@ -245,6 +284,12 @@ This adapter is intentionally thin. It uses the same template expansion model as
245
284
  }
246
285
  ```
247
286
 
287
+ Then start the backend bridge explicitly:
288
+
289
+ ```bash
290
+ audit-code --provider subprocess-template
291
+ ```
292
+
248
293
  ## Antigravity note
249
294
 
250
295
  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.6",
3
+ "version": "0.2.9",
4
4
  "private": false,
5
5
  "description": "Portable hybrid code-auditing framework for arbitrary repositories.",
6
6
  "type": "module",
@@ -39,6 +39,9 @@
39
39
  "type": "git",
40
40
  "url": "git+https://github.com/OhOkThisIsFine/auditor-lambda.git"
41
41
  },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
42
45
  "homepage": "https://github.com/OhOkThisIsFine/auditor-lambda#readme",
43
46
  "bugs": {
44
47
  "url": "https://github.com/OhOkThisIsFine/auditor-lambda/issues"
@@ -8,7 +8,7 @@
8
8
  "unit_id",
9
9
  "pass_id",
10
10
  "lens",
11
- "reviewed_ranges",
11
+ "file_coverage",
12
12
  "findings"
13
13
  ],
14
14
  "$defs": {
@@ -20,19 +20,20 @@
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
- "reviewed_ranges": {
28
+ "file_coverage": {
26
29
  "type": "array",
27
30
  "minItems": 1,
28
31
  "items": {
29
32
  "type": "object",
30
- "required": ["path", "start", "end", "line_count"],
33
+ "required": ["path", "total_lines"],
31
34
  "properties": {
32
35
  "path": { "type": "string" },
33
- "start": { "type": "integer" },
34
- "end": { "type": "integer" },
35
- "line_count": { "type": "integer", "minimum": 1 }
36
+ "total_lines": { "type": "integer", "minimum": 1 }
36
37
  },
37
38
  "additionalProperties": false
38
39
  }
@@ -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": {