audit-tools 0.32.58 → 0.32.60

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 (137) hide show
  1. package/dist/audit/cli/charterDeltaPrompt.d.ts.map +1 -1
  2. package/dist/audit/cli/charterDeltaPrompt.js +19 -1
  3. package/dist/audit/cli/charterDeltaPrompt.js.map +1 -1
  4. package/dist/audit/cli/dispatch/tierRouting.d.ts +8 -0
  5. package/dist/audit/cli/dispatch/tierRouting.d.ts.map +1 -1
  6. package/dist/audit/cli/dispatch/tierRouting.js +1 -1
  7. package/dist/audit/cli/dispatch/tierRouting.js.map +1 -1
  8. package/dist/audit/cli/dispatch/tokenUsageObservation.d.ts +91 -0
  9. package/dist/audit/cli/dispatch/tokenUsageObservation.d.ts.map +1 -0
  10. package/dist/audit/cli/dispatch/tokenUsageObservation.js +210 -0
  11. package/dist/audit/cli/dispatch/tokenUsageObservation.js.map +1 -0
  12. package/dist/audit/cli/dispatch.d.ts.map +1 -1
  13. package/dist/audit/cli/dispatch.js +21 -9
  14. package/dist/audit/cli/dispatch.js.map +1 -1
  15. package/dist/audit/cli/mergeAndIngestCommand.d.ts.map +1 -1
  16. package/dist/audit/cli/mergeAndIngestCommand.js +62 -4
  17. package/dist/audit/cli/mergeAndIngestCommand.js.map +1 -1
  18. package/dist/audit/cli/nextStepCommand.d.ts.map +1 -1
  19. package/dist/audit/cli/nextStepCommand.js +7 -4
  20. package/dist/audit/cli/nextStepCommand.js.map +1 -1
  21. package/dist/audit/cli/prompts.d.ts.map +1 -1
  22. package/dist/audit/cli/prompts.js +12 -0
  23. package/dist/audit/cli/prompts.js.map +1 -1
  24. package/dist/audit/cli/providerConfirmationStep.d.ts +10 -1
  25. package/dist/audit/cli/providerConfirmationStep.d.ts.map +1 -1
  26. package/dist/audit/cli/providerConfirmationStep.js +49 -0
  27. package/dist/audit/cli/providerConfirmationStep.js.map +1 -1
  28. package/dist/audit/cli/rollingAuditDispatch.d.ts.map +1 -1
  29. package/dist/audit/cli/rollingAuditDispatch.js +17 -1
  30. package/dist/audit/cli/rollingAuditDispatch.js.map +1 -1
  31. package/dist/audit/contracts/workerSchemas.d.ts +36 -0
  32. package/dist/audit/contracts/workerSchemas.d.ts.map +1 -1
  33. package/dist/audit/orchestrator/charterExtractionExecutor.d.ts.map +1 -1
  34. package/dist/audit/orchestrator/charterExtractionExecutor.js +11 -6
  35. package/dist/audit/orchestrator/charterExtractionExecutor.js.map +1 -1
  36. package/dist/audit/orchestrator/rollingDispatch.d.ts.map +1 -1
  37. package/dist/audit/orchestrator/rollingDispatch.js +2 -0
  38. package/dist/audit/orchestrator/rollingDispatch.js.map +1 -1
  39. package/dist/audit/quota/index.d.ts +4 -4
  40. package/dist/audit/types/activeDispatch.d.ts +8 -0
  41. package/dist/audit/types/activeDispatch.d.ts.map +1 -1
  42. package/dist/audit/types.d.ts +30 -0
  43. package/dist/audit/types.d.ts.map +1 -1
  44. package/dist/audit/types.js +19 -0
  45. package/dist/audit/types.js.map +1 -1
  46. package/dist/audit/validation/auditResults.d.ts.map +1 -1
  47. package/dist/audit/validation/auditResults.js +40 -0
  48. package/dist/audit/validation/auditResults.js.map +1 -1
  49. package/dist/remediate/index.d.ts.map +1 -1
  50. package/dist/remediate/index.js +24 -0
  51. package/dist/remediate/index.js.map +1 -1
  52. package/dist/remediate/riskSignal.d.ts +12 -0
  53. package/dist/remediate/riskSignal.d.ts.map +1 -1
  54. package/dist/remediate/riskSignal.js +55 -1
  55. package/dist/remediate/riskSignal.js.map +1 -1
  56. package/dist/remediate/steps/contractPipeline.d.ts +19 -0
  57. package/dist/remediate/steps/contractPipeline.d.ts.map +1 -1
  58. package/dist/remediate/steps/contractPipeline.js +49 -11
  59. package/dist/remediate/steps/contractPipeline.js.map +1 -1
  60. package/dist/remediate/steps/dispatch/acceptNode.d.ts +1 -1
  61. package/dist/remediate/steps/dispatch/acceptNode.d.ts.map +1 -1
  62. package/dist/remediate/steps/dispatch/acceptNode.js +13 -6
  63. package/dist/remediate/steps/dispatch/acceptNode.js.map +1 -1
  64. package/dist/remediate/steps/nextStep.d.ts +23 -0
  65. package/dist/remediate/steps/nextStep.d.ts.map +1 -1
  66. package/dist/remediate/steps/nextStep.js +58 -20
  67. package/dist/remediate/steps/nextStep.js.map +1 -1
  68. package/dist/shared/dispatch/admissionLoop.d.ts +8 -6
  69. package/dist/shared/dispatch/admissionLoop.d.ts.map +1 -1
  70. package/dist/shared/dispatch/admissionLoop.js +13 -7
  71. package/dist/shared/dispatch/admissionLoop.js.map +1 -1
  72. package/dist/shared/dispatch/providerLaunchFinalize.d.ts +7 -3
  73. package/dist/shared/dispatch/providerLaunchFinalize.d.ts.map +1 -1
  74. package/dist/shared/dispatch/providerLaunchFinalize.js +52 -6
  75. package/dist/shared/dispatch/providerLaunchFinalize.js.map +1 -1
  76. package/dist/shared/dispatch/rollingDispatch.d.ts +97 -1
  77. package/dist/shared/dispatch/rollingDispatch.d.ts.map +1 -1
  78. package/dist/shared/dispatch/rollingDispatch.js +231 -80
  79. package/dist/shared/dispatch/rollingDispatch.js.map +1 -1
  80. package/dist/shared/dispatch/unifiedRolling.d.ts +23 -0
  81. package/dist/shared/dispatch/unifiedRolling.d.ts.map +1 -1
  82. package/dist/shared/dispatch/unifiedRolling.js +2 -0
  83. package/dist/shared/dispatch/unifiedRolling.js.map +1 -1
  84. package/dist/shared/friction/stepBoundaryCapture.d.ts +87 -1
  85. package/dist/shared/friction/stepBoundaryCapture.d.ts.map +1 -1
  86. package/dist/shared/friction/stepBoundaryCapture.js +117 -0
  87. package/dist/shared/friction/stepBoundaryCapture.js.map +1 -1
  88. package/dist/shared/friction/triage.d.ts.map +1 -1
  89. package/dist/shared/friction/triage.js +0 -0
  90. package/dist/shared/friction/triage.js.map +1 -1
  91. package/dist/shared/index.d.ts +9 -7
  92. package/dist/shared/index.d.ts.map +1 -1
  93. package/dist/shared/index.js +5 -5
  94. package/dist/shared/index.js.map +1 -1
  95. package/dist/shared/loopCorePaths.d.ts.map +1 -1
  96. package/dist/shared/loopCorePaths.js +0 -1
  97. package/dist/shared/loopCorePaths.js.map +1 -1
  98. package/dist/shared/providers/providerConfirmation.d.ts +43 -1
  99. package/dist/shared/providers/providerConfirmation.d.ts.map +1 -1
  100. package/dist/shared/providers/providerConfirmation.js +28 -0
  101. package/dist/shared/providers/providerConfirmation.js.map +1 -1
  102. package/dist/shared/quota/accountId.d.ts +54 -0
  103. package/dist/shared/quota/accountId.d.ts.map +1 -0
  104. package/dist/shared/quota/accountId.js +96 -0
  105. package/dist/shared/quota/accountId.js.map +1 -0
  106. package/dist/shared/quota/apiPool.d.ts.map +1 -1
  107. package/dist/shared/quota/apiPool.js +29 -1
  108. package/dist/shared/quota/apiPool.js.map +1 -1
  109. package/dist/shared/quota/capacity.d.ts +2 -2
  110. package/dist/shared/quota/errorParsing.d.ts +31 -0
  111. package/dist/shared/quota/errorParsing.d.ts.map +1 -1
  112. package/dist/shared/quota/errorParsing.js +115 -0
  113. package/dist/shared/quota/errorParsing.js.map +1 -1
  114. package/dist/shared/quota/hostSessionQuotaSource.d.ts +15 -2
  115. package/dist/shared/quota/hostSessionQuotaSource.d.ts.map +1 -1
  116. package/dist/shared/quota/hostSessionQuotaSource.js +12 -8
  117. package/dist/shared/quota/hostSessionQuotaSource.js.map +1 -1
  118. package/dist/shared/quota/scheduler.d.ts +70 -11
  119. package/dist/shared/quota/scheduler.d.ts.map +1 -1
  120. package/dist/shared/quota/scheduler.js +86 -18
  121. package/dist/shared/quota/scheduler.js.map +1 -1
  122. package/dist/shared/quota/state.d.ts +72 -0
  123. package/dist/shared/quota/state.d.ts.map +1 -1
  124. package/dist/shared/quota/state.js +108 -0
  125. package/dist/shared/quota/state.js.map +1 -1
  126. package/dist/shared/types/rollingDispatch.d.ts +50 -1
  127. package/dist/shared/types/rollingDispatch.d.ts.map +1 -1
  128. package/docs/audit-pkg/contracts.md +6 -8
  129. package/docs/audit-pkg/product.md +4 -3
  130. package/docs/audit-pkg/release.md +1 -1
  131. package/package.json +1 -1
  132. package/schemas/audit_result.schema.json +16 -0
  133. package/schemas/audit_results.schema.json +16 -0
  134. package/dist/remediate/steps/leanFastPath.d.ts +0 -32
  135. package/dist/remediate/steps/leanFastPath.d.ts.map +0 -1
  136. package/dist/remediate/steps/leanFastPath.js +0 -103
  137. package/dist/remediate/steps/leanFastPath.js.map +0 -1
@@ -2,7 +2,7 @@ import { existsSync, statSync } from "node:fs";
2
2
  import { mkdir, readFile, rename } from "node:fs/promises";
3
3
  import { dirname, join, resolve } from "node:path";
4
4
  import { StateStore } from "../state/store.js";
5
- import { readOptionalJsonFile, readValidatedSessionConfig, stagedAndUntracked, writeJsonFile, writeTextFile, buildAuditDeliverablePair, formatValidationIssues, isRecord, withFsRetry, RunLogger, DISPATCH_PROMPT_HANDOFF_NOTE, renderHostScratchNote, hostScratchDir, renderQuotaCoverageNudge, renderTokenBudgetView, coerceJsonObjectArg, driveRolling, resolveLedgerBudgets, setQuotaStateDir, detectHostDispatchWall, reconcileAdmissionLeasesFromQuotaFile, buildQuotaPausedTerminal, interpretFreeFormIntent, advance, decideFrictionTriage, buildFrictionTriageBlock, planHybridDispatch, readSettledPools, addSettledPool, sourceByPoolId, classifyProvider, selectDispatchDriver, renderDispatchDriverInstruction, HostSessionQuotaSource, buildProviderModelKey, captureStepBoundaryFriction, captureCostDriftFriction, LENSES, SEVERITIES, resolveHostProviderName, resolveConversationHostProvider, resolveHostDispatchCapability as sharedResolveHostDispatchCapability, resolveRollingEngineFlag, shouldDemotePrimaryInProcess, DEFAULT_CONTEXT_TOKENS } from "audit-tools/shared";
5
+ import { readOptionalJsonFile, readValidatedSessionConfig, stagedAndUntracked, writeJsonFile, writeTextFile, buildAuditDeliverablePair, formatValidationIssues, isRecord, withFsRetry, RunLogger, DISPATCH_PROMPT_HANDOFF_NOTE, renderHostScratchNote, hostScratchDir, renderQuotaCoverageNudge, renderTokenBudgetView, coerceJsonObjectArg, driveRolling, resolveLedgerBudgets, setQuotaStateDir, detectHostDispatchWall, reconcileAdmissionLeasesFromQuotaFile, buildQuotaPausedTerminal, interpretFreeFormIntent, advance, decideFrictionTriage, buildFrictionTriageBlock, planHybridDispatch, readSettledPools, addSettledPool, sourceByPoolId, classifyProvider, selectDispatchDriver, renderDispatchDriverInstruction, HostSessionQuotaSource, buildProviderModelKey, captureStepBoundaryFriction, captureCostDriftFriction, captureCreditExhaustionFriction, captureQuotaUnclassifiedFriction, LENSES, SEVERITIES, resolveHostProviderName, resolveConversationHostProvider, resolveHostDispatchCapability as sharedResolveHostDispatchCapability, resolveRollingEngineFlag, shouldDemotePrimaryInProcess, DEFAULT_CONTEXT_TOKENS } from "audit-tools/shared";
6
6
  import { readRemediationAccessMemory, computeBlockContinuityScores } from "../state/accessMemory.js";
7
7
  import { applyPlanPipeline, buildCoverageLedger } from "../phases/plan.js";
8
8
  import { groundExtractedFindings } from "../phases/grounding.js";
@@ -23,14 +23,13 @@ import { deduplicateCrossLensFindings, fixupBlocksAfterDedup, } from "../dedup/c
23
23
  import { checkAffectedFileIntegrity } from "../utils/fileIntegrity.js";
24
24
  import { resolveIntakeStep } from "./intakeResolver.js";
25
25
  import { runToolOwnedFinalGate, applyCoarseReblock, readFinalGateSidecar, writeFinalGateSidecar, } from "./finalGate.js";
26
- import { buildNextContractPipelineStep, shouldEnterContractPipeline, writePathASeedFromFindings, } from "./contractPipeline.js";
27
- import { buildLeanExtractedPlan, interpretLeanLightReviewVerdict, LEAN_LIGHT_REVIEW_SCHEMA_VERSION, } from "./leanFastPath.js";
26
+ import { buildNextContractPipelineStep, shouldEnterContractPipeline, writePathASeedFromFindings, buildLeanExtractedPlan, } from "./contractPipeline.js";
28
27
  import { contractArtifactExists, contractPipelineDir, } from "../contractPipeline/artifactStore.js";
29
28
  import { buildReviewRequest, applyReviewResolution, } from "../review/reviewGate.js";
30
29
  import { buildAutonomousReviewDecision } from "../review/autonomousGate.js";
31
30
  import { runFindingFilterPass } from "../findingFilter.js";
32
31
  import { intakePaths, isIntakeReady, readIntakeArtifacts, resolveManifestSources, } from "../intake.js";
33
- import { ensureIntakeRiskSignal, readIntakeRiskSignal, writeIntakeRiskSignal, escalateRiskSignal, findingRiskEvidence, distinctAffectedFiles, } from "../riskSignal.js";
32
+ import { ensureIntakeRiskSignal, readIntakeRiskSignal, writeIntakeRiskSignal, escalateRiskSignal, findingRiskEvidence, distinctAffectedFiles, interpretLeanLightReviewVerdict, LEAN_LIGHT_REVIEW_SCHEMA_VERSION, } from "../riskSignal.js";
34
33
  import { ambiguityReviewPrompt, clarificationPrompt, collectIntakeClarificationsPrompt, collectStartingPointPrompt, loaderCommand, reviewApprovalPrompt, synthesizeIntakePrompt, triagePrompt, } from "./prompts.js";
35
34
  // Single-sourced prose renders of the canonical lens / severity vocabularies
36
35
  // (`audit-tools/shared` `LENSES` / `SEVERITIES`) for the intent-checkpoint
@@ -535,6 +534,8 @@ export async function driveRollingDispatch(levels, options) {
535
534
  dispatchPacket: async (packet, slot) => options.dispatchNode(blockById.get(packet.payload.block_id), slot),
536
535
  ...(options.root !== undefined ? { root: options.root } : {}),
537
536
  ...(options.onCostDrift ? { onCostDrift: options.onCostDrift } : {}),
537
+ ...(options.onCreditExhausted ? { onCreditExhausted: options.onCreditExhausted } : {}),
538
+ ...(options.onQuotaUnclassified ? { onQuotaUnclassified: options.onQuotaUnclassified } : {}),
538
539
  // Single-flight (CE-001) is enforced by the unified driver.
539
540
  rebuildBetweenLevels: options.rebuildSharedBetweenLevels,
540
541
  // Host-session escalation: feed recordLimit (write) at the rate_limited observation
@@ -760,10 +761,13 @@ export async function driveRollingImplementDispatch(options) {
760
761
  verify_passed: accept.verifyPassed,
761
762
  merged: accept.merged,
762
763
  });
763
- // Release the claim ONLY on a terminal accept. A `rate_limited` worker re-queues
764
- // (still owned work — keep the claim so a peer can't grab it mid-retry); success /
765
- // error / timeout is terminal → free it through the shared registry (token-checked).
766
- if (result.outcome !== "rate_limited") {
764
+ // Release the claim ONLY on a terminal accept. A `rate_limited`,
765
+ // `credit_exhausted`, or `quota_unclassified` worker re-queues (still owned
766
+ // work — keep the claim so a peer can't grab it mid-retry); success / error /
767
+ // timeout is terminal → free it through the shared registry (token-checked).
768
+ if (result.outcome !== "rate_limited" &&
769
+ result.outcome !== "credit_exhausted" &&
770
+ result.outcome !== "quota_unclassified") {
767
771
  await releaseNodeClaim(registry, claimTokens, block.block_id);
768
772
  }
769
773
  return result;
@@ -794,6 +798,21 @@ export async function driveRollingImplementDispatch(options) {
794
798
  onCostDrift: (info) => {
795
799
  captureCostDriftFriction(artifactsDir, runId, info, "remediate-code");
796
800
  },
801
+ // Credit exhaustion: a pool out of prepaid usage credits (no reset timer,
802
+ // distinct from a rate limit) has already been permanently excluded from
803
+ // this run's admissible set by the engine; surface it as reviewable
804
+ // friction so the operator knows to top up credits.
805
+ onCreditExhausted: (info) => {
806
+ captureCreditExhaustionFriction(artifactsDir, runId, info, "remediate-code");
807
+ },
808
+ // Quota-unclassified harvest (Slice A2b): a pool death whose text was
809
+ // quota-suspicious but matched no precise pattern degraded conservatively
810
+ // (re-queued, never permanently excluded); surface the verbatim
811
+ // (secret-scrubbed) text as reviewable friction so the operator can
812
+ // classify it and improve errorParsing.ts's pattern set.
813
+ onQuotaUnclassified: (info) => {
814
+ captureQuotaUnclassifiedFriction(artifactsDir, runId, info, "remediate-code");
815
+ },
797
816
  });
798
817
  // Piece D — persist the rolling engine's partial-completion terminal onto state
799
818
  // BEFORE the merge, so the merge can SKIP-block the quota_paused stranded nodes
@@ -1350,22 +1369,39 @@ async function buildImplementDispatchStep(ctx) {
1350
1369
  registry: hybridClaimRegistry,
1351
1370
  sourceByPoolId: sourceByPoolId(confirmedPools),
1352
1371
  });
1353
- // DC-4: a backend pool whose node rate-limited is exhausted → settle it
1354
- // (cross-cycle) so the next cycle routes its share to the host pool.
1355
- const rateLimited = new Set(inProcessOutcome.nodes.filter((n) => n.outcome === "rate_limited").map((n) => n.block_id));
1356
- const exhaustedPools = new Set(partition.inProcess.filter((a) => rateLimited.has(a.nodeId)).map((a) => a.poolId));
1372
+ // DC-4: a backend pool whose node rate-limited, credit-exhausted, OR
1373
+ // returned a quota_unclassified death → settle it (cross-cycle) so the next
1374
+ // cycle routes its share to the host pool. This partition spans multiple
1375
+ // cycles, each with its own fresh in-process dispatcher (a fresh in-memory
1376
+ // exhaustedPoolIds AND pausedPoolResetAt), so the rolling engine's own
1377
+ // reversible pause evaporates at the cycle boundary — without settling here,
1378
+ // credit_exhausted (no reset timer) and a chronically-quota_unclassified pool
1379
+ // alike would be RE-OFFERED next cycle and re-die on the same pool. Settling
1380
+ // in the hybrid path is the cross-cycle analog of the rolling path's pause.
1381
+ // NOTE: the verbatim-message harvest (captureQuotaUnclassifiedFriction /
1382
+ // captureCreditExhaustionFriction) rides the rolling engine's hooks, which
1383
+ // this direct-Promise.all partition does not invoke; here every settled node
1384
+ // still surfaces as a quota_escalation friction (below), but without the
1385
+ // verbatim text. Threading verbatim capture into executeInProcessPartition is
1386
+ // a documented follow-up (affects credit_exhausted identically — not new to A2b).
1387
+ const settledOutcomeBlocks = new Set(inProcessOutcome.nodes
1388
+ .filter((n) => n.outcome === "rate_limited" ||
1389
+ n.outcome === "credit_exhausted" ||
1390
+ n.outcome === "quota_unclassified")
1391
+ .map((n) => n.block_id));
1392
+ const exhaustedPools = new Set(partition.inProcess.filter((a) => settledOutcomeBlocks.has(a.nodeId)).map((a) => a.poolId));
1357
1393
  for (const poolId of exhaustedPools) {
1358
1394
  await partition.coordinator.settlePool(poolId);
1359
1395
  }
1360
- // Surface each rate-limited node as reviewable friction (not just the
1361
- // settle side-effect above). The shared step-boundary chokepoint dedupes
1362
- // on {eventType, runId, discriminator}, so a chronically-exhausted backend
1363
- // pool re-hitting the same block_id across cycles collapses to one record.
1364
- for (const blockId of rateLimited) {
1396
+ // Surface each settled node as reviewable friction (not just the settle
1397
+ // side-effect above). The shared step-boundary chokepoint dedupes on
1398
+ // {eventType, runId, discriminator}, so a chronically-exhausted backend pool
1399
+ // re-hitting the same block_id across cycles collapses to one record.
1400
+ for (const blockId of settledOutcomeBlocks) {
1365
1401
  void captureStepBoundaryFriction(artifactsDir, runId, {
1366
1402
  eventType: "quota_escalation",
1367
1403
  discriminator: blockId,
1368
- note: "A-8 hybrid in-process node rate-limited; its backend pool was settled for this run.",
1404
+ note: "A-8 hybrid in-process node rate-limited / credit-exhausted / quota-unclassified; its backend pool was settled for this run.",
1369
1405
  severity: "high",
1370
1406
  category: "trap",
1371
1407
  area: "dispatch/quota",
@@ -2185,8 +2221,10 @@ async function handleReadyIntakeContractPipeline(root, artifactsDir, options) {
2185
2221
  }
2186
2222
  // Persist the filter dispositions so coverage is built over the originals.
2187
2223
  await persistReviewFilterDispositions(artifactsDir, originals, filter);
2188
- // Lean path = the `low` risk tier's realization (D-68 — leanFastPath folded
2189
- // into the self-scaling dial). A run skips the heavy contract DESIGN loop and
2224
+ // Lean path = the `low` risk tier's realization (D-68 — the standalone lean
2225
+ // fast-path folded into the self-scaling dial; its two mechanisms now live in
2226
+ // `riskSignal.ts` (light-review) + `contractPipeline.ts` (lean plan builder)).
2227
+ // A run skips the heavy contract DESIGN loop and
2190
2228
  // synthesizes the extracted plan directly IFF its effective risk tier is `low`;
2191
2229
  // the plan→implement→close machinery (per-node verify-before-merge + the final
2192
2230
  // whole-repo gate) is the retained safety net. Runs only here — on Path A