audit-tools 0.46.0 β†’ 0.48.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 (106) hide show
  1. package/README.md +36 -16
  2. package/dispatch/merge-results.mjs +3 -3
  3. package/dispatch/validate-result.mjs +3 -3
  4. package/dist/audit/cli/cleanupCommand.d.ts.map +1 -1
  5. package/dist/audit/cli/cleanupCommand.js +7 -1
  6. package/dist/audit/cli/cleanupCommand.js.map +1 -1
  7. package/dist/audit/cli/nextStepCommand.d.ts +12 -0
  8. package/dist/audit/cli/nextStepCommand.d.ts.map +1 -1
  9. package/dist/audit/cli/nextStepCommand.js +15 -6
  10. package/dist/audit/cli/nextStepCommand.js.map +1 -1
  11. package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
  12. package/dist/audit/cli/nextStepHelpers.js +28 -2
  13. package/dist/audit/cli/nextStepHelpers.js.map +1 -1
  14. package/dist/audit/cli/sampleRunCommand.d.ts +215 -0
  15. package/dist/audit/cli/sampleRunCommand.d.ts.map +1 -1
  16. package/dist/audit/cli/sampleRunCommand.js +48 -2
  17. package/dist/audit/cli/sampleRunCommand.js.map +1 -1
  18. package/dist/audit/orchestrator/acquisitionExecutor.d.ts +2 -2
  19. package/dist/audit/orchestrator/acquisitionExecutor.d.ts.map +1 -1
  20. package/dist/audit/orchestrator/acquisitionExecutor.js.map +1 -1
  21. package/dist/audit/orchestrator/designReviewPrompt.d.ts.map +1 -1
  22. package/dist/audit/orchestrator/designReviewPrompt.js +7 -0
  23. package/dist/audit/orchestrator/designReviewPrompt.js.map +1 -1
  24. package/dist/audit/orchestrator/hostInputPause.d.ts +8 -2
  25. package/dist/audit/orchestrator/hostInputPause.d.ts.map +1 -1
  26. package/dist/audit/orchestrator/hostInputPause.js.map +1 -1
  27. package/dist/audit/orchestrator/intentInterpreter.d.ts +15 -18
  28. package/dist/audit/orchestrator/intentInterpreter.d.ts.map +1 -1
  29. package/dist/audit/orchestrator/intentInterpreter.js +12 -26
  30. package/dist/audit/orchestrator/intentInterpreter.js.map +1 -1
  31. package/dist/remediate/intake.js +1 -1
  32. package/dist/remediate/intake.js.map +1 -1
  33. package/dist/remediate/phases/close.d.ts +8 -0
  34. package/dist/remediate/phases/close.d.ts.map +1 -1
  35. package/dist/remediate/phases/close.js +11 -12
  36. package/dist/remediate/phases/close.js.map +1 -1
  37. package/dist/remediate/review/autonomousGate.d.ts +3 -7
  38. package/dist/remediate/review/autonomousGate.d.ts.map +1 -1
  39. package/dist/remediate/review/autonomousGate.js +10 -24
  40. package/dist/remediate/review/autonomousGate.js.map +1 -1
  41. package/dist/remediate/riskSignal.d.ts +8 -20
  42. package/dist/remediate/riskSignal.d.ts.map +1 -1
  43. package/dist/remediate/riskSignal.js +21 -76
  44. package/dist/remediate/riskSignal.js.map +1 -1
  45. package/dist/remediate/state/accessMemory.d.ts +2 -3
  46. package/dist/remediate/state/accessMemory.d.ts.map +1 -1
  47. package/dist/remediate/state/accessMemory.js +3 -6
  48. package/dist/remediate/state/accessMemory.js.map +1 -1
  49. package/dist/remediate/state/store.d.ts +6 -7
  50. package/dist/remediate/state/store.d.ts.map +1 -1
  51. package/dist/remediate/state/store.js.map +1 -1
  52. package/dist/remediate/state/types.d.ts +2 -84
  53. package/dist/remediate/state/types.d.ts.map +1 -1
  54. package/dist/remediate/state/types.js +1 -39
  55. package/dist/remediate/state/types.js.map +1 -1
  56. package/dist/remediate/steps/contractPipeline.d.ts +0 -19
  57. package/dist/remediate/steps/contractPipeline.d.ts.map +1 -1
  58. package/dist/remediate/steps/contractPipeline.js +75 -63
  59. package/dist/remediate/steps/contractPipeline.js.map +1 -1
  60. package/dist/remediate/steps/dispatch/hostHandoff.d.ts.map +1 -1
  61. package/dist/remediate/steps/dispatch/hostHandoff.js +0 -2
  62. package/dist/remediate/steps/dispatch/hostHandoff.js.map +1 -1
  63. package/dist/remediate/steps/nextStep.d.ts +16 -7
  64. package/dist/remediate/steps/nextStep.d.ts.map +1 -1
  65. package/dist/remediate/steps/nextStep.js +171 -210
  66. package/dist/remediate/steps/nextStep.js.map +1 -1
  67. package/dist/remediate/steps/stepUtils.d.ts +10 -2
  68. package/dist/remediate/steps/stepUtils.d.ts.map +1 -1
  69. package/dist/remediate/steps/stepUtils.js +13 -3
  70. package/dist/remediate/steps/stepUtils.js.map +1 -1
  71. package/dist/remediate/steps/types.d.ts +1 -1
  72. package/dist/remediate/steps/types.d.ts.map +1 -1
  73. package/dist/remediate/steps/types.js.map +1 -1
  74. package/dist/remediate/validation/artifacts.d.ts.map +1 -1
  75. package/dist/remediate/validation/artifacts.js +1 -16
  76. package/dist/remediate/validation/artifacts.js.map +1 -1
  77. package/dist/remediate/validation/remediationState.d.ts +0 -1
  78. package/dist/remediate/validation/remediationState.d.ts.map +1 -1
  79. package/dist/remediate/validation/remediationState.js +0 -51
  80. package/dist/remediate/validation/remediationState.js.map +1 -1
  81. package/dist/shared/analyzerPolicy.d.ts +18 -6
  82. package/dist/shared/analyzerPolicy.d.ts.map +1 -1
  83. package/dist/shared/analyzerPolicy.js +15 -3
  84. package/dist/shared/analyzerPolicy.js.map +1 -1
  85. package/dist/shared/analyzers/acquisitionEngine.d.ts +14 -8
  86. package/dist/shared/analyzers/acquisitionEngine.d.ts.map +1 -1
  87. package/dist/shared/analyzers/acquisitionEngine.js +3 -4
  88. package/dist/shared/analyzers/acquisitionEngine.js.map +1 -1
  89. package/dist/shared/index.d.ts +2 -0
  90. package/dist/shared/index.d.ts.map +1 -1
  91. package/dist/shared/index.js +1 -0
  92. package/dist/shared/index.js.map +1 -1
  93. package/dist/shared/intent/constraintClauses.d.ts +31 -0
  94. package/dist/shared/intent/constraintClauses.d.ts.map +1 -0
  95. package/dist/shared/intent/constraintClauses.js +37 -0
  96. package/dist/shared/intent/constraintClauses.js.map +1 -0
  97. package/docs/audit-pkg/operator-guide.md +7 -4
  98. package/package.json +5 -2
  99. package/scripts/audit/postinstall.mjs +4 -2
  100. package/scripts/postinstall.mjs +1 -1
  101. package/scripts/remediate/postinstall.mjs +3 -1
  102. package/scripts/shared/install-host-assets.mjs +7 -3
  103. package/wrapper/audit-code-wrapper-build.mjs +3 -3
  104. package/wrapper/audit-code-wrapper-install-hosts.mjs +3 -3
  105. package/wrapper/audit-code-wrapper-lib.mjs +1 -0
  106. package/wrapper/remediate-code-wrapper-install-hosts.mjs +3 -3
@@ -63,23 +63,44 @@ const ARTIFACT_TO_PHASE = {
63
63
  const CONTRACT_STEP_KIND = "contract_pipeline";
64
64
  const PRE_IMPLEMENTATION_PHASE_ORDER = CONTRACT_PIPELINE_PHASE_ORDER.filter((phase) => phase !== "closing");
65
65
  /**
66
- * Granularity collapse group (T1 slice 4b). The framing phases β€” goal, context,
67
- * decomposition β€” are ONE coherent act of authoring (scope the change top-down):
68
- * they carry no adversarial judgment and no deterministic derivation interleaves
69
- * them, so for low-complexity work they fold into a single round-trip producing
70
- * all three artifacts instead of three gated steps. The group deliberately STOPS
71
- * at decomposition (before module_contract_drafting): keeping the decomposition→
72
- * drafting boundary lets the slice-4a escalate-on-evidence intercept inspect the
73
- * fresh decomposition and raise the tier β€” un-collapsing every remaining phase β€”
74
- * before any contract is drafted or the per-module wave fans out. Collapse is
66
+ * Granularity collapse GROUPS (T1 slice 4b). Each group is a run of CONSECUTIVE
67
+ * phases that folds into ONE round-trip at the `collapsed` granularity β€” i.e.
68
+ * only at the `low` tier (see `roundTripGranularityForTier`). Collapse is
75
69
  * best-effort: any member artifact the worker omits or writes malformed is
76
70
  * re-emitted as its own fine-grained step by `nextMissingContractPhase`, so no
77
- * work is ever lost. See `roundTripGranularityForTier`.
78
- */
79
- const FRAMING_COLLAPSE_GROUP = [
80
- "goal_normalization",
81
- "context_collection",
82
- "decomposition",
71
+ * work is ever lost.
72
+ *
73
+ * These are the ONLY two safe groups, and the gaps between them are not
74
+ * oversights β€” each is a property worth more than the round-trip it would save.
75
+ * The full per-phase map is `docs/reviews/low-tier-phase-cost-2026-08-25.md`;
76
+ * the boundaries that matter here:
77
+ *
78
+ * - The framing group STOPS at `decomposition`. Keeping the decomposition→
79
+ * drafting boundary lets the slice-4a escalate-on-evidence intercept read
80
+ * the fresh decomposition and raise the tier β€” un-collapsing everything
81
+ * after it β€” before any contract is drafted or the module wave fans out.
82
+ * - `critique`, `critic` and `judge` are independent-adversary phases and can
83
+ * never join a group with what they review. Collapsing critic+judge is the
84
+ * sharpest case: the judge verdict is the SOLE admission to implementation
85
+ * planning, so one worker emitting both artifacts could write zero
86
+ * counterexamples plus `approved` and let the loop certify its own exit.
87
+ * - `implementation_planning` is the phase `judgeRepairGate` protects, and its
88
+ * scaffold is built from the judge's accepted counterexamples, which do not
89
+ * exist at judge-render time.
90
+ *
91
+ * A collapsed section carries exactly what its fine-grained step would have
92
+ * carried β€” see `collapsedSectionExtra`.
93
+ */
94
+ const COLLAPSE_GROUPS = [
95
+ // Framing: scope the change top-down. One coherent authoring act, no
96
+ // adversarial judgment, no deterministic derivation interleaved.
97
+ ["goal_normalization", "context_collection", "decomposition"],
98
+ // Authoring tail: the test/validator plan and the author's OWN coverage
99
+ // self-assessment. `assessment` is deliberately not an independent-critic
100
+ // phase, and `contract_assessment_report` already depends on
101
+ // `test_validator_plan` β€” the same later-reads-earlier shape the framing
102
+ // group relies on. The critic reviews both afterwards, unchanged.
103
+ ["test_validator_plan", "assessment"],
83
104
  ];
84
105
  // ── Bounded-loop caps ─────────────────────────────────────────────────────────
85
106
  /**
@@ -1297,8 +1318,25 @@ function writeContractBlockedStep(ctx, params) {
1297
1318
  * overrides the per-section "stop after writing" lines so they are not read as
1298
1319
  * three separate stop points.
1299
1320
  */
1300
- function writeCollapsedFramingStep(ctx, phases) {
1301
- const sections = phases.map((phase) => ({
1321
+ /**
1322
+ * The extra section a collapsed member carries, mirroring the gate that would
1323
+ * have claimed that phase on its own β€” so collapsing changes the number of
1324
+ * round-trips and nothing else about what the worker is told.
1325
+ *
1326
+ * This is load-bearing, not tidiness. `collapsedRoundTripGate` is registered
1327
+ * BEFORE `scaffoldedPhaseGate`, so without this a group containing
1328
+ * `test_validator_plan` would silently drop the S3 skeleton the worker is
1329
+ * supposed to fill in, and the collapse would quietly make that phase HARDER
1330
+ * rather than cheaper.
1331
+ */
1332
+ async function collapsedSectionExtra(phase, artifactsDir) {
1333
+ if (phase === "test_validator_plan" || phase === "implementation_planning") {
1334
+ return await buildScaffoldSection(phase, artifactsDir);
1335
+ }
1336
+ return await buildReReviewSection(phase, artifactsDir);
1337
+ }
1338
+ async function writeCollapsedRoundTripStep(ctx, phases) {
1339
+ const sections = await Promise.all(phases.map(async (phase) => ({
1302
1340
  phase,
1303
1341
  rendered: renderContractPipelinePrompt({
1304
1342
  role: phase,
@@ -1308,7 +1346,8 @@ function writeCollapsedFramingStep(ctx, phases) {
1308
1346
  pathASeedPath: ctx.pathASeedPath,
1309
1347
  adversarialDepth: ctx.adversarialDepth,
1310
1348
  }),
1311
- }));
1349
+ extra: await collapsedSectionExtra(phase, ctx.artifactsDir),
1350
+ })));
1312
1351
  const outputPaths = sections.map((s) => s.rendered.outputPath);
1313
1352
  const header = `# Collapsed Authoring Round-Trip β€” ${phases.length} Phases
1314
1353
 
@@ -1320,11 +1359,13 @@ If you cannot complete a section (an artifact would be malformed), write the one
1320
1359
 
1321
1360
  Artifacts to produce (in order):
1322
1361
  ${outputPaths.map((p, i) => `${i + 1}. \`${p}\` (${phases[i]})`).join("\n")}`;
1323
- const body = sections.map((s) => `\n---\n\n${s.rendered.prompt}`).join("\n");
1362
+ const body = sections
1363
+ .map((s) => `\n---\n\n${s.extra ? `${s.rendered.prompt}\n${s.extra}` : s.rendered.prompt}`)
1364
+ .join("\n");
1324
1365
  return writeContractPromptStep(ctx, {
1325
1366
  prompt: `${header}\n${body}`,
1326
1367
  outputPath: outputPaths[outputPaths.length - 1],
1327
- stopCondition: `Stop after writing all ${phases.length} collapsed-framing artifacts (${phases.join(", ")}) and running next-step once.`,
1368
+ stopCondition: `Stop after writing all ${phases.length} collapsed artifacts (${phases.join(", ")}) and running next-step once.`,
1328
1369
  });
1329
1370
  }
1330
1371
  /**
@@ -1420,8 +1461,8 @@ async function writeContractStepPlan(ctx, plan) {
1420
1461
  return await writeContractBlockedStep(ctx, plan);
1421
1462
  case "module_wave":
1422
1463
  return await writeParallelModuleWaveStep(ctx, plan.phase);
1423
- case "collapsed_framing":
1424
- return await writeCollapsedFramingStep(ctx, plan.phases);
1464
+ case "collapsed_round_trip":
1465
+ return await writeCollapsedRoundTripStep(ctx, plan.phases);
1425
1466
  case "rederive":
1426
1467
  // A deterministic artifact was just written; the frontier moved, so the
1427
1468
  // whole walk re-runs against the new state rather than guessing the phase.
@@ -2563,25 +2604,27 @@ const phaseCutCritiqueGate = async (ctx) => {
2563
2604
  };
2564
2605
  };
2565
2606
  /**
2566
- * Granularity collapse (T1 slice 4b): for low-complexity work, fold the framing
2567
- * suffix [nextPhase..decomposition] into ONE round-trip producing several
2607
+ * Granularity collapse (T1 slice 4b): for low-complexity work, fold the suffix
2608
+ * [nextPhase .. end of its group] into ONE round-trip producing several
2568
2609
  * artifacts, instead of one gated step per phase. Reads the POST-escalation
2569
2610
  * riskSignal (the escalate-on-evidence intercept may have already raised the
2570
2611
  * tier), so the dial is never frozen at run start β€” `fine` for medium/high keeps
2571
- * full per-phase isolation. Only collapses a genuine multi-phase suffix.
2612
+ * full per-phase isolation. Only collapses a genuine multi-phase suffix, so a
2613
+ * lone trailing member falls through to its ordinary per-phase step.
2572
2614
  */
2573
- const collapsedFramingGate = (ctx) => {
2615
+ const collapsedRoundTripGate = (ctx) => {
2574
2616
  const phase = ctx.nextPhase;
2575
2617
  if (phase === null ||
2576
- roundTripGranularityForTier(ctx.riskSignal?.tier) !== "collapsed" ||
2577
- !FRAMING_COLLAPSE_GROUP.includes(phase)) {
2618
+ roundTripGranularityForTier(ctx.riskSignal?.tier) !== "collapsed") {
2578
2619
  return null;
2579
2620
  }
2580
- const startIdx = FRAMING_COLLAPSE_GROUP.indexOf(phase);
2581
- const suffix = FRAMING_COLLAPSE_GROUP.slice(startIdx);
2621
+ const group = COLLAPSE_GROUPS.find((g) => g.includes(phase));
2622
+ if (!group)
2623
+ return null;
2624
+ const suffix = group.slice(group.indexOf(phase));
2582
2625
  if (suffix.length <= 1)
2583
2626
  return null;
2584
- return { via: "collapsed_framing", phases: [...suffix] };
2627
+ return { via: "collapsed_round_trip", phases: [...suffix] };
2585
2628
  };
2586
2629
  /**
2587
2630
  * Skeleton-scaffolded phases (S3): the tool pre-fills structure/ids from the
@@ -2646,7 +2689,7 @@ const CONTRACT_PIPELINE_GATES = {
2646
2689
  pre_critic_structural: preCriticStructuralGate,
2647
2690
  parallel_module_wave: parallelModuleWaveGate,
2648
2691
  phase_cut_critique: phaseCutCritiqueGate,
2649
- collapsed_framing_round_trip: collapsedFramingGate,
2692
+ collapsed_round_trip: collapsedRoundTripGate,
2650
2693
  scaffolded_phase: scaffoldedPhaseGate,
2651
2694
  };
2652
2695
  /**
@@ -3319,35 +3362,4 @@ export async function readContractPipelinePlanningOutputs(artifactsDir) {
3319
3362
  ].sort((left, right) => compareCodeUnits(left.path, right.path)),
3320
3363
  };
3321
3364
  }
3322
- // ── Lean-path extracted plan (the `low` risk tier's plan emission) ────────────
3323
- //
3324
- // The heavy pipeline above derives its `extracted-plan.json` from the adversarial
3325
- // DAG (`source: "contract_pipeline"`). The `low` risk tier skips that design loop
3326
- // (its findings are a handful of concrete, already-grounded fixes) and emits this
3327
- // lean sibling instead, tagged `source: "lean_fast_path"` so the two producers are
3328
- // distinguished at the artifact level. Both rejoin the SAME plan→implement→close
3329
- // machinery β€” `normalizeExtractedPlan` synthesizes one block per finding and
3330
- // `applyPlanPipeline` merges blocks sharing a file + splits by context budget, so
3331
- // block derivation is single-sourced, not reimplemented here. The retained safety
3332
- // net (grounding re-pass, affected-file hash snapshot, per-node verify-before-merge,
3333
- // final whole-repo gate) still runs; only the adversarial DESIGN loop + obligation
3334
- // derivation are dropped. (Relocated from the retired `steps/leanFastPath.ts` β€” DD-21.)
3335
- /** Source tag stamped on a lean-fast-path extracted plan (distinguishes it from `contract_pipeline`). */
3336
- export const LEAN_FAST_PATH_SOURCE = "lean_fast_path";
3337
- /**
3338
- * Build the lean extracted plan from the approved findings. Blocks are
3339
- * intentionally omitted: `normalizeExtractedPlan` synthesizes one block per
3340
- * finding and `applyPlanPipeline` then merges blocks sharing a file + splits by
3341
- * context budget β€” the same deterministic block derivation the contract pipeline
3342
- * feeds into, single-sourced rather than reimplemented here.
3343
- */
3344
- export function buildLeanExtractedPlan(findings, planId) {
3345
- return {
3346
- plan_id: planId,
3347
- findings,
3348
- project_type: "unknown",
3349
- source: LEAN_FAST_PATH_SOURCE,
3350
- candidate_closing_actions: ["none"],
3351
- };
3352
- }
3353
3365
  //# sourceMappingURL=contractPipeline.js.map