audit-tools 0.50.3 → 0.50.6

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 (77) hide show
  1. package/dist/audit/cli/auditStep.d.ts +30 -0
  2. package/dist/audit/cli/auditStep.d.ts.map +1 -1
  3. package/dist/audit/cli/auditStep.js +50 -0
  4. package/dist/audit/cli/auditStep.js.map +1 -1
  5. package/dist/audit/cli/foldTransaction.d.ts +103 -0
  6. package/dist/audit/cli/foldTransaction.d.ts.map +1 -0
  7. package/dist/audit/cli/foldTransaction.js +243 -0
  8. package/dist/audit/cli/foldTransaction.js.map +1 -0
  9. package/dist/audit/cli/nextStepHelpers.d.ts +109 -28
  10. package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
  11. package/dist/audit/cli/nextStepHelpers.js +645 -560
  12. package/dist/audit/cli/nextStepHelpers.js.map +1 -1
  13. package/dist/audit/cli/reviewRun.d.ts +15 -3
  14. package/dist/audit/cli/reviewRun.d.ts.map +1 -1
  15. package/dist/audit/cli/reviewRun.js +39 -13
  16. package/dist/audit/cli/reviewRun.js.map +1 -1
  17. package/dist/audit/orchestrator/advance.d.ts +38 -36
  18. package/dist/audit/orchestrator/advance.d.ts.map +1 -1
  19. package/dist/audit/orchestrator/advance.js +126 -82
  20. package/dist/audit/orchestrator/advance.js.map +1 -1
  21. package/dist/audit/orchestrator/advanceTypes.d.ts +23 -0
  22. package/dist/audit/orchestrator/advanceTypes.d.ts.map +1 -1
  23. package/dist/audit/orchestrator/autoFixExecutor.d.ts.map +1 -1
  24. package/dist/audit/orchestrator/autoFixExecutor.js +10 -8
  25. package/dist/audit/orchestrator/autoFixExecutor.js.map +1 -1
  26. package/dist/audit/orchestrator/designReviewSnapshot.d.ts +8 -2
  27. package/dist/audit/orchestrator/designReviewSnapshot.d.ts.map +1 -1
  28. package/dist/audit/orchestrator/designReviewSnapshot.js +12 -6
  29. package/dist/audit/orchestrator/designReviewSnapshot.js.map +1 -1
  30. package/dist/audit/orchestrator/executorRunners.d.ts.map +1 -1
  31. package/dist/audit/orchestrator/executorRunners.js +1 -1
  32. package/dist/audit/orchestrator/executorRunners.js.map +1 -1
  33. package/dist/audit/orchestrator/executors.d.ts.map +1 -1
  34. package/dist/audit/orchestrator/executors.js +1 -1
  35. package/dist/audit/orchestrator/executors.js.map +1 -1
  36. package/dist/audit/orchestrator/hostInputPause.d.ts +0 -33
  37. package/dist/audit/orchestrator/hostInputPause.d.ts.map +1 -1
  38. package/dist/audit/orchestrator/hostInputPause.js +6 -64
  39. package/dist/audit/orchestrator/hostInputPause.js.map +1 -1
  40. package/dist/audit/orchestrator/localCommands.d.ts +9 -4
  41. package/dist/audit/orchestrator/localCommands.d.ts.map +1 -1
  42. package/dist/audit/orchestrator/localCommands.js +19 -7
  43. package/dist/audit/orchestrator/localCommands.js.map +1 -1
  44. package/dist/audit/orchestrator/obligationPolicy.d.ts +90 -0
  45. package/dist/audit/orchestrator/obligationPolicy.d.ts.map +1 -0
  46. package/dist/audit/orchestrator/obligationPolicy.js +228 -0
  47. package/dist/audit/orchestrator/obligationPolicy.js.map +1 -0
  48. package/dist/audit/orchestrator/reviewPackets.d.ts.map +1 -1
  49. package/dist/audit/orchestrator/reviewPackets.js +4 -6
  50. package/dist/audit/orchestrator/reviewPackets.js.map +1 -1
  51. package/dist/audit/orchestrator/selectiveDeepening/shared.d.ts +0 -1
  52. package/dist/audit/orchestrator/selectiveDeepening/shared.d.ts.map +1 -1
  53. package/dist/audit/orchestrator/selectiveDeepening/shared.js +5 -6
  54. package/dist/audit/orchestrator/selectiveDeepening/shared.js.map +1 -1
  55. package/dist/audit/orchestrator/syntaxResolutionExecutor.d.ts +1 -1
  56. package/dist/audit/orchestrator/syntaxResolutionExecutor.d.ts.map +1 -1
  57. package/dist/audit/orchestrator/syntaxResolutionExecutor.js +7 -7
  58. package/dist/audit/orchestrator/syntaxResolutionExecutor.js.map +1 -1
  59. package/dist/audit/orchestrator/systemicChallengeExecutor.d.ts +4 -3
  60. package/dist/audit/orchestrator/systemicChallengeExecutor.d.ts.map +1 -1
  61. package/dist/audit/orchestrator/systemicChallengeExecutor.js +56 -9
  62. package/dist/audit/orchestrator/systemicChallengeExecutor.js.map +1 -1
  63. package/dist/audit/systemic/secondOrderAdversaryPrompt.d.ts +3 -2
  64. package/dist/audit/systemic/secondOrderAdversaryPrompt.d.ts.map +1 -1
  65. package/dist/audit/systemic/secondOrderAdversaryPrompt.js +8 -6
  66. package/dist/audit/systemic/secondOrderAdversaryPrompt.js.map +1 -1
  67. package/dist/audit/systemic/systemicChallengeLoop.d.ts +8 -4
  68. package/dist/audit/systemic/systemicChallengeLoop.d.ts.map +1 -1
  69. package/dist/audit/systemic/systemicChallengeLoop.js +9 -5
  70. package/dist/audit/systemic/systemicChallengeLoop.js.map +1 -1
  71. package/dist/audit/types/systemicChallenge.d.ts +35 -7
  72. package/dist/audit/types/systemicChallenge.d.ts.map +1 -1
  73. package/dist/shared/engine/obligationEngine.d.ts +45 -11
  74. package/dist/shared/engine/obligationEngine.d.ts.map +1 -1
  75. package/dist/shared/engine/obligationEngine.js +41 -7
  76. package/dist/shared/engine/obligationEngine.js.map +1 -1
  77. package/package.json +2 -2
@@ -1,3 +1,4 @@
1
+ import { RunLogger } from "audit-tools/shared";
1
2
  import type { AdvanceAuditResult } from "../orchestrator/advanceTypes.js";
2
3
  import type { ArtifactBundle } from "../io/artifacts.js";
3
4
  import type { EdgeReasoningResults } from "../orchestrator/edgeReasoning.js";
@@ -28,6 +29,8 @@ export interface RunAuditStepOptions {
28
29
  charterDeltaSubmissionPath?: string;
29
30
  clarificationAnswersPath?: string;
30
31
  systemicChallengePath?: string;
32
+ /** Fold-computed content hash of the staged systemic-challenge submission. */
33
+ systemicChallengeSubmissionHash?: string;
31
34
  /**
32
35
  * Already-validated edge-reasoning rewrites. Parsed + shape-checked by the
33
36
  * caller (`handleGraphEnrichmentBranch` tolerant-unwraps or quarantines the
@@ -41,6 +44,33 @@ export interface RunAuditStepOptions {
41
44
  runLog?: boolean;
42
45
  }
43
46
  export declare function runAuditStep(options: RunAuditStepOptions): Promise<AdvanceAuditResult>;
47
+ /**
48
+ * The ONE artifact-tree hold, exported for the unified `next-step` fold.
49
+ *
50
+ * `nextStepHelpers.ts` is banned (import-boundary contract) from importing
51
+ * `withFileLock` or the locking `runAuditStep`; this wrapper is its sanctioned
52
+ * entry to the lock, and the dynamic lock-count acceptance test keeps it
53
+ * honest — one deterministic fold acquires the artifact-tree lock exactly
54
+ * once, through here.
55
+ */
56
+ export declare function withArtifactTreeHold<T>(artifactsDir: string, runLogger: RunLogger | undefined, fn: () => Promise<T>): Promise<T>;
57
+ /**
58
+ * The LOCK-FREE, PERSIST-FREE bounded step — the fold's entry point.
59
+ *
60
+ * `withFileLock` is non-reentrant (an exclusive `wx` create), so a fold that
61
+ * holds the artifact-tree lock for its whole drain cannot call {@link
62
+ * runAuditStep}: the wrapper's second acquisition would deadlock into a
63
+ * deterministic `FileLockTimeoutError`. The fold therefore calls this, and owns
64
+ * the one hold and the one persist itself.
65
+ *
66
+ * It takes the bundle rather than loading one, because under persist-once the
67
+ * fold's own state is not on disk yet and a reload would silently roll it back.
68
+ *
69
+ * The wrapper/core split is not new here — `executeAdvance` was already split
70
+ * out "so the claim path can execute this UNLOCKED". This is that seam, named
71
+ * and exported so the fold cannot reach the locking half by accident.
72
+ */
73
+ export declare function runAuditStepUnlocked(options: RunAuditStepOptions, bundle: ArtifactBundle, runLogger?: RunLogger): Promise<AdvanceAuditResult>;
44
74
  /**
45
75
  * The CLI batch lane's half of the S7 grounding contract (docs-16): overwrite
46
76
  * every finding's `grounding` with the TOOL's own re-check before the payload
@@ -1 +1 @@
1
- {"version":3,"file":"auditStep.d.ts","sourceRoot":"","sources":["../../../src/audit/cli/auditStep.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM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EAAE,SAAS,OAAO,EAAE,GAC1B,OAAO,CAAC,IAAI,CAAC,CAYf;AAED,wBAAsB,uBAAuB,CAAC,OAAO,EAAE;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB;;;;;;;;;;;;;;;;;;;;GA8CA"}
@@ -1,3 +1,4 @@
1
+ import { access } from "node:fs/promises";
1
2
  import { basename, join } from "node:path";
2
3
  import { artifactTreeLockPath, createMemoizedSourceReader, readJsonFile, RunLogger, verifyFindingGrounding, withFileLock, CharterSubmissionSchema, CharterDeltaSubmissionSchema, ClarificationAnswersSubmissionSchema, SystemicChallengeSubmissionSchema, } from "audit-tools/shared";
3
4
  import { loadArtifactBundle, writeCoreArtifacts, } from "../io/artifacts.js";
@@ -9,6 +10,7 @@ import { sizeIndexFromManifest } from "../orchestrator/reviewPackets.js";
9
10
  import { partitionOrphanedAuditResults } from "../orchestrator/resultIngestion.js";
10
11
  import { validateAuditResults, formatAuditResultIssues, } from "../validation/auditResults.js";
11
12
  import { formatAuditResultValidationError } from "./workerResult.js";
13
+ import { laneSubmissionPath } from "./laneSubmissions.js";
12
14
  import { looksLikeCliFlag, listBatchResultFiles } from "./args.js";
13
15
  import { buildLineIndex } from "./lineIndex.js";
14
16
  export async function runAuditStep(options) {
@@ -21,6 +23,41 @@ export async function runAuditStep(options) {
21
23
  // lock only covers local artifact derivation and result ingestion.
22
24
  return await withFileLock(lockPath, () => runAuditStepLocked(options, runLogger), undefined, runLogger);
23
25
  }
26
+ /**
27
+ * The ONE artifact-tree hold, exported for the unified `next-step` fold.
28
+ *
29
+ * `nextStepHelpers.ts` is banned (import-boundary contract) from importing
30
+ * `withFileLock` or the locking `runAuditStep`; this wrapper is its sanctioned
31
+ * entry to the lock, and the dynamic lock-count acceptance test keeps it
32
+ * honest — one deterministic fold acquires the artifact-tree lock exactly
33
+ * once, through here.
34
+ */
35
+ export async function withArtifactTreeHold(artifactsDir, runLogger, fn) {
36
+ return await withFileLock(artifactTreeLockPath(artifactsDir), fn, undefined, runLogger);
37
+ }
38
+ /**
39
+ * The LOCK-FREE, PERSIST-FREE bounded step — the fold's entry point.
40
+ *
41
+ * `withFileLock` is non-reentrant (an exclusive `wx` create), so a fold that
42
+ * holds the artifact-tree lock for its whole drain cannot call {@link
43
+ * runAuditStep}: the wrapper's second acquisition would deadlock into a
44
+ * deterministic `FileLockTimeoutError`. The fold therefore calls this, and owns
45
+ * the one hold and the one persist itself.
46
+ *
47
+ * It takes the bundle rather than loading one, because under persist-once the
48
+ * fold's own state is not on disk yet and a reload would silently roll it back.
49
+ *
50
+ * The wrapper/core split is not new here — `executeAdvance` was already split
51
+ * out "so the claim path can execute this UNLOCKED". This is that seam, named
52
+ * and exported so the fold cannot reach the locking half by accident.
53
+ */
54
+ export async function runAuditStepUnlocked(options, bundle, runLogger) {
55
+ const logger = runLogger ??
56
+ new RunLogger(join(options.artifactsDir, "run.log.jsonl"), {
57
+ enabled: options.runLog ?? true,
58
+ });
59
+ return await executeAdvance(options, bundle, logger);
60
+ }
24
61
  async function runAuditStepLocked(options, runLogger) {
25
62
  const bundle = await loadArtifactBundle(options.artifactsDir);
26
63
  const result = await executeAdvance(options, bundle, runLogger);
@@ -136,12 +173,25 @@ async function executeAdvance(options, bundle, runLogger) {
136
173
  charterDeltaSubmission,
137
174
  clarificationAnswers,
138
175
  systemicChallenge,
176
+ systemicChallengeSubmissionHash: options.systemicChallengeSubmissionHash,
139
177
  edgeReasoningResults: options.edgeReasoningResults,
140
178
  analyzers: options.analyzers,
141
179
  graphLlmEdgeReasoning: options.graphLlmEdgeReasoning,
142
180
  externalAcquisition: options.externalAcquisition,
143
181
  since: options.since,
144
182
  preferredExecutor: options.preferredExecutor,
183
+ // The plan-draw classification's lane probe: pure presence, never a read
184
+ // or a consume — a pending submission is a boundary the unforced draw
185
+ // halts at (see AdvanceAuditOptions.submissionProbe).
186
+ submissionProbe: async (lane) => {
187
+ try {
188
+ await access(laneSubmissionPath(options.artifactsDir, lane));
189
+ return true;
190
+ }
191
+ catch {
192
+ return false;
193
+ }
194
+ },
145
195
  runLogger,
146
196
  });
147
197
  return result;
@@ -1 +1 @@
1
- {"version":3,"file":"auditStep.js","sourceRoot":"","sources":["../../../src/audit/cli/auditStep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,YAAY,EACZ,SAAS,EACT,sBAAsB,EACtB,YAAY,EACZ,uBAAuB,EACvB,4BAA4B,EAC5B,oCAAoC,EACpC,iCAAiC,GAClC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,EAAE,8BAA8B,EAAE,MAAM,8CAA8C,CAAC;AAE9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AA2ChD,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAA4B;IAE5B,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,eAAe,CAAC,EAAE;QAC3E,OAAO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ACjB,CAAC;QACJ,CAAC,CAAC,IAAI,CAAC;IAET,MAAM,MAAM,GACV,IAAI,EAAE,cAAc;QACpB,CAAC,MAAM,kBAAkB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;IACnD,MAAM,KAAK,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAExC,OAAO;QACL,UAAU;QACV,MAAM;QACN,WAAW,EAAE,KAAK;QAClB,mBAAmB,EACjB,IAAI,EAAE,mBAAmB,IAAI,QAAQ,CAAC,mBAAmB;QAC3D,iBAAiB,EACf,IAAI,EAAE,iBAAiB,IAAI,2BAA2B;QACxD,aAAa,EAAE,IAAI,EAAE,aAAa,IAAI,KAAK;QAC3C,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,IAAI,EAAE;QAChD,gBAAgB,EACd,YAAY,UAAU,CAAC,MAAM,qBAAqB,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,OAAO,CAAC,QAAQ,GAAG;YAChH,CAAC,IAAI;gBACH,CAAC,CAAC,KAAK,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,gBAAgB,EAAE;gBACtF,CAAC,CAAC,EAAE,CAAC;QACT,gBAAgB,EACd,KAAK,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,mBAAmB;KACpE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * The `next-step` fold's TRANSACTION — the mechanics of ONE CORE WRITE BOUNDARY
3
+ * under ONE artifact-tree hold (CX-02 landings 2 and 3).
4
+ *
5
+ * What is deferred to the commit:
6
+ * - the single authoritative core-artifact write (the fold's carried bundle,
7
+ * pruned — the bundle is always the FULL accumulated bundle, never partial,
8
+ * because pruning treats a missing key as an intent to delete);
9
+ * - design-review snapshot writes (state-critical: a snapshot lost between
10
+ * fold and commit silently marks a completed pass satisfied);
11
+ * - consumed-submission deletions and their `accepted` ledger events (an
12
+ * accepted event recorded before the core commit double-records when a crash
13
+ * replays the fold).
14
+ *
15
+ * What stays immediate, deliberately: quarantine moves and their `rejected`
16
+ * ledger events (the quarantine happened; the bound path is empty, so a replay
17
+ * cannot re-consume), the `steps/deterministic-progress.json` marker protocol
18
+ * (its value is being visible MID-fold), handoff/observability writes, and the
19
+ * durable analyzer consent/settings stores (idempotent merges outside the
20
+ * artifact tree).
21
+ *
22
+ * Staging (landing 3's decided replacement for unlink deferral): a submission
23
+ * is RENAMED into `submission-staging/` before it is parsed or applied, so
24
+ * recovery can tell a consumption was in flight. On commit an APPLIED staged
25
+ * file is deleted (its effect is on disk); an UN-applied one is restored to
26
+ * its bound path for the retry. A crash between the core write and the staged
27
+ * cleanup can therefore restore an ALREADY-FOLDED submission — iterative-fold
28
+ * executors guard that window with a content-hash register and ignore a
29
+ * duplicate (see `runSystemicChallengeExecutor`).
30
+ */
31
+ import { type ArtifactBundle } from "../io/artifacts.js";
32
+ import { type DesignReviewSnapshot } from "../orchestrator/designReviewSnapshot.js";
33
+ export declare function submissionStagingDir(artifactsDir: string): string;
34
+ /** One staged (consumption-in-flight) host submission. */
35
+ export interface StagedSubmission {
36
+ lane: string;
37
+ boundPath: string;
38
+ stagingPath: string;
39
+ /** sha256 of the staged bytes — the iterative-fold duplicate-guard identity. */
40
+ contentHash: string;
41
+ /** True once the fold has landed the submission's effect on the carried bundle. */
42
+ applied: boolean;
43
+ /** Optional message for the deferred `accepted` ledger event. */
44
+ acceptedMessage?: string;
45
+ }
46
+ /** The fold's pending side effects, committed once at the boundary. */
47
+ export interface FoldTransaction {
48
+ staged: StagedSubmission[];
49
+ pendingSnapshots: DesignReviewSnapshot[];
50
+ }
51
+ export declare function createFoldTransaction(): FoldTransaction;
52
+ /**
53
+ * Move a refused submission to `<artifactsDir>/quarantine/` rather than
54
+ * deleting it. Falls back to copy+unlink if `rename` fails (e.g. a cross-device
55
+ * artifacts mount) so the content is never lost. The quarantined file is named
56
+ * for its LANE — the bound path is a digest, which tells an operator nothing.
57
+ */
58
+ export declare function quarantineSubmissionFile(artifactsDir: string, filePath: string, lane: string): Promise<string>;
59
+ export type StageResult = {
60
+ status: "absent";
61
+ } | {
62
+ status: "staged";
63
+ staged: StagedSubmission;
64
+ };
65
+ /**
66
+ * Stage one lane's bound submission: rename it into the staging directory
67
+ * BEFORE anything parses or applies it. Registered on the transaction as
68
+ * un-applied; `markSubmissionApplied` flips it once its effect is on the
69
+ * carried bundle.
70
+ */
71
+ export declare function stageLaneSubmission(tx: FoldTransaction, artifactsDir: string, lane: string): Promise<StageResult>;
72
+ /**
73
+ * Mark a staged submission APPLIED: its effect now rides the carried bundle,
74
+ * so the commit deletes it and records its `accepted` event. A submission a
75
+ * gate QUARANTINED must instead be dropped from the register (the quarantine
76
+ * moved the file; there is nothing left to delete or restore).
77
+ */
78
+ export declare function markSubmissionApplied(tx: FoldTransaction, stagingPath: string, acceptedMessage?: string): void;
79
+ /**
80
+ * Fold-start recovery sweep, run under the hold BEFORE the bundle loads: a
81
+ * file still in staging means a previous fold crashed mid-consumption. Restore
82
+ * it to its bound path so the fold re-consumes it; if the host has meanwhile
83
+ * resubmitted over the bound path, quarantine the staged copy instead (the
84
+ * newer submission supersedes the one the crashed fold held) and record the
85
+ * refusal so the supersession is on the ledger, not silent.
86
+ */
87
+ export declare function recoverStagedSubmissions(artifactsDir: string): Promise<void>;
88
+ /**
89
+ * THE commit — the fold's one core write boundary, run on EVERY fold exit
90
+ * including the throw path. Order is load-bearing:
91
+ * 1. the core artifacts (one authoritative pruned write of the carried bundle);
92
+ * 2. the design-review snapshots (state-critical companions of that bundle);
93
+ * 3. applied staged submissions: delete + `accepted` ledger event — only now,
94
+ * so a crash before (1) leaves the submission restorable and event-free;
95
+ * 4. un-applied staged submissions: restore to their bound paths for the retry.
96
+ *
97
+ * Each deferred entry leaves the transaction the moment it completes, because
98
+ * the throw path re-runs commitFold on the SAME transaction: a re-entry after
99
+ * a mid-loop I/O error must RESUME at the failed entry, never re-record an
100
+ * `accepted` event the first attempt already appended.
101
+ */
102
+ export declare function commitFold(artifactsDir: string, bundle: ArtifactBundle, tx: FoldTransaction): Promise<void>;
103
+ //# sourceMappingURL=foldTransaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foldTransaction.d.ts","sourceRoot":"","sources":["../../../src/audit/cli/foldTransaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAaH,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,yCAAyC,CAAC;AAKjD,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEjE;AAeD,0DAA0D;AAC1D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,WAAW,EAAE,MAAM,CAAC;IACpB,mFAAmF;IACnF,OAAO,EAAE,OAAO,CAAC;IACjB,iEAAiE;IACjE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,gBAAgB,EAAE,oBAAoB,EAAE,CAAC;CAC1C;AAED,wBAAgB,qBAAqB,IAAI,eAAe,CAEvD;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CAiBjB;AAcD,MAAM,MAAM,WAAW,GACnB;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,GACpB;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAEnD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,eAAe,EACnB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,WAAW,CAAC,CA8BtB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,eAAe,EACnB,WAAW,EAAE,MAAM,EACnB,eAAe,CAAC,EAAE,MAAM,GACvB,IAAI,CASN;AAOD;;;;;;;GAOG;AACH,wBAAsB,wBAAwB,CAC5C,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAqCf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,UAAU,CAC9B,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,cAAc,EACtB,EAAE,EAAE,eAAe,GAClB,OAAO,CAAC,IAAI,CAAC,CAuBf"}
@@ -0,0 +1,243 @@
1
+ /**
2
+ * The `next-step` fold's TRANSACTION — the mechanics of ONE CORE WRITE BOUNDARY
3
+ * under ONE artifact-tree hold (CX-02 landings 2 and 3).
4
+ *
5
+ * What is deferred to the commit:
6
+ * - the single authoritative core-artifact write (the fold's carried bundle,
7
+ * pruned — the bundle is always the FULL accumulated bundle, never partial,
8
+ * because pruning treats a missing key as an intent to delete);
9
+ * - design-review snapshot writes (state-critical: a snapshot lost between
10
+ * fold and commit silently marks a completed pass satisfied);
11
+ * - consumed-submission deletions and their `accepted` ledger events (an
12
+ * accepted event recorded before the core commit double-records when a crash
13
+ * replays the fold).
14
+ *
15
+ * What stays immediate, deliberately: quarantine moves and their `rejected`
16
+ * ledger events (the quarantine happened; the bound path is empty, so a replay
17
+ * cannot re-consume), the `steps/deterministic-progress.json` marker protocol
18
+ * (its value is being visible MID-fold), handoff/observability writes, and the
19
+ * durable analyzer consent/settings stores (idempotent merges outside the
20
+ * artifact tree).
21
+ *
22
+ * Staging (landing 3's decided replacement for unlink deferral): a submission
23
+ * is RENAMED into `submission-staging/` before it is parsed or applied, so
24
+ * recovery can tell a consumption was in flight. On commit an APPLIED staged
25
+ * file is deleted (its effect is on disk); an UN-applied one is restored to
26
+ * its bound path for the retry. A crash between the core write and the staged
27
+ * cleanup can therefore restore an ALREADY-FOLDED submission — iterative-fold
28
+ * executors guard that window with a content-hash register and ignore a
29
+ * duplicate (see `runSystemicChallengeExecutor`).
30
+ */
31
+ import { mkdir, readFile, readdir, rename, stat, unlink, writeFile, } from "node:fs/promises";
32
+ import { join } from "node:path";
33
+ import { hashContent, isFileMissingError } from "audit-tools/shared";
34
+ import { writeCoreArtifacts } from "../io/artifacts.js";
35
+ import { writeDesignReviewSnapshot, } from "../orchestrator/designReviewSnapshot.js";
36
+ import { laneSubmissionPath, recordLaneOutcome } from "./laneSubmissions.js";
37
+ const STAGING_DIRNAME = "submission-staging";
38
+ export function submissionStagingDir(artifactsDir) {
39
+ return join(artifactsDir, STAGING_DIRNAME);
40
+ }
41
+ function stagedFileName(lane) {
42
+ return `${encodeURIComponent(lane)}.json`;
43
+ }
44
+ function laneFromStagedFileName(fileName) {
45
+ if (!fileName.endsWith(".json"))
46
+ return null;
47
+ try {
48
+ return decodeURIComponent(fileName.slice(0, -".json".length));
49
+ }
50
+ catch {
51
+ return null;
52
+ }
53
+ }
54
+ export function createFoldTransaction() {
55
+ return { staged: [], pendingSnapshots: [] };
56
+ }
57
+ /**
58
+ * Move a refused submission to `<artifactsDir>/quarantine/` rather than
59
+ * deleting it. Falls back to copy+unlink if `rename` fails (e.g. a cross-device
60
+ * artifacts mount) so the content is never lost. The quarantined file is named
61
+ * for its LANE — the bound path is a digest, which tells an operator nothing.
62
+ */
63
+ export async function quarantineSubmissionFile(artifactsDir, filePath, lane) {
64
+ const quarantineDir = join(artifactsDir, "quarantine");
65
+ await mkdir(quarantineDir, { recursive: true });
66
+ const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
67
+ const quarantinePath = join(quarantineDir, `${lane}.${timestamp}.json`);
68
+ try {
69
+ await rename(filePath, quarantinePath);
70
+ }
71
+ catch {
72
+ try {
73
+ const content = await readFile(filePath, "utf8");
74
+ await writeFile(quarantinePath, content, "utf8");
75
+ }
76
+ catch {
77
+ // Best-effort: nothing left to quarantine if even the read failed.
78
+ }
79
+ await unlink(filePath).catch(() => { });
80
+ }
81
+ return quarantinePath;
82
+ }
83
+ /** Rename with a copy+unlink fallback for cross-device artifact mounts. */
84
+ async function moveFile(from, to) {
85
+ try {
86
+ await rename(from, to);
87
+ }
88
+ catch (error) {
89
+ if (isFileMissingError(error))
90
+ throw error;
91
+ const content = await readFile(from);
92
+ await writeFile(to, content);
93
+ await unlink(from).catch(() => { });
94
+ }
95
+ }
96
+ /**
97
+ * Stage one lane's bound submission: rename it into the staging directory
98
+ * BEFORE anything parses or applies it. Registered on the transaction as
99
+ * un-applied; `markSubmissionApplied` flips it once its effect is on the
100
+ * carried bundle.
101
+ */
102
+ export async function stageLaneSubmission(tx, artifactsDir, lane) {
103
+ const boundPath = laneSubmissionPath(artifactsDir, lane);
104
+ const stagingPath = join(submissionStagingDir(artifactsDir), stagedFileName(lane));
105
+ // Probe the bound path BEFORE creating anything: every gate polls its lane
106
+ // on every pass, so the absent case must stay a pure read — an unconditional
107
+ // mkdir turns the poll into a write (EACCES on an unwritable artifacts root,
108
+ // a planted directory on a writable one).
109
+ try {
110
+ await stat(boundPath);
111
+ }
112
+ catch (error) {
113
+ if (isFileMissingError(error))
114
+ return { status: "absent" };
115
+ throw error;
116
+ }
117
+ await mkdir(submissionStagingDir(artifactsDir), { recursive: true });
118
+ try {
119
+ await moveFile(boundPath, stagingPath);
120
+ }
121
+ catch (error) {
122
+ if (isFileMissingError(error))
123
+ return { status: "absent" };
124
+ throw error;
125
+ }
126
+ const bytes = await readFile(stagingPath);
127
+ const staged = {
128
+ lane,
129
+ boundPath,
130
+ stagingPath,
131
+ contentHash: hashContent(bytes),
132
+ applied: false,
133
+ };
134
+ tx.staged.push(staged);
135
+ return { status: "staged", staged };
136
+ }
137
+ /**
138
+ * Mark a staged submission APPLIED: its effect now rides the carried bundle,
139
+ * so the commit deletes it and records its `accepted` event. A submission a
140
+ * gate QUARANTINED must instead be dropped from the register (the quarantine
141
+ * moved the file; there is nothing left to delete or restore).
142
+ */
143
+ export function markSubmissionApplied(tx, stagingPath, acceptedMessage) {
144
+ const entry = tx.staged.find((s) => s.stagingPath === stagingPath);
145
+ if (!entry) {
146
+ throw new Error(`markSubmissionApplied: no staged submission at ${stagingPath} — a gate applied a submission the transaction never staged`);
147
+ }
148
+ entry.applied = true;
149
+ if (acceptedMessage !== undefined)
150
+ entry.acceptedMessage = acceptedMessage;
151
+ }
152
+ // A quarantined staged file needs no explicit drop from the register: the
153
+ // quarantine MOVED it, and the commit's restore of an un-applied entry treats
154
+ // a missing staging file as already-handled (see commitFold). One lifecycle,
155
+ // no second bookkeeping call a gate could forget.
156
+ /**
157
+ * Fold-start recovery sweep, run under the hold BEFORE the bundle loads: a
158
+ * file still in staging means a previous fold crashed mid-consumption. Restore
159
+ * it to its bound path so the fold re-consumes it; if the host has meanwhile
160
+ * resubmitted over the bound path, quarantine the staged copy instead (the
161
+ * newer submission supersedes the one the crashed fold held) and record the
162
+ * refusal so the supersession is on the ledger, not silent.
163
+ */
164
+ export async function recoverStagedSubmissions(artifactsDir) {
165
+ let entries;
166
+ try {
167
+ entries = await readdir(submissionStagingDir(artifactsDir));
168
+ }
169
+ catch (error) {
170
+ if (isFileMissingError(error))
171
+ return;
172
+ throw error;
173
+ }
174
+ for (const fileName of entries) {
175
+ const lane = laneFromStagedFileName(fileName);
176
+ if (lane === null)
177
+ continue;
178
+ const stagingPath = join(submissionStagingDir(artifactsDir), fileName);
179
+ const boundPath = laneSubmissionPath(artifactsDir, lane);
180
+ let boundOccupied = true;
181
+ try {
182
+ await readFile(boundPath);
183
+ }
184
+ catch (error) {
185
+ if (!isFileMissingError(error))
186
+ throw error;
187
+ boundOccupied = false;
188
+ }
189
+ if (boundOccupied) {
190
+ const quarantinePath = await quarantineSubmissionFile(artifactsDir, stagingPath, lane);
191
+ await recordLaneOutcome(artifactsDir, lane, {
192
+ kind: "rejected",
193
+ issueCode: "submission_rejected",
194
+ message: `a crashed fold held this submission staged while a newer one arrived at the bound path; ` +
195
+ `the staged copy is quarantined at ${quarantinePath} and the newer submission is consumed instead`,
196
+ });
197
+ continue;
198
+ }
199
+ await moveFile(stagingPath, boundPath);
200
+ }
201
+ }
202
+ /**
203
+ * THE commit — the fold's one core write boundary, run on EVERY fold exit
204
+ * including the throw path. Order is load-bearing:
205
+ * 1. the core artifacts (one authoritative pruned write of the carried bundle);
206
+ * 2. the design-review snapshots (state-critical companions of that bundle);
207
+ * 3. applied staged submissions: delete + `accepted` ledger event — only now,
208
+ * so a crash before (1) leaves the submission restorable and event-free;
209
+ * 4. un-applied staged submissions: restore to their bound paths for the retry.
210
+ *
211
+ * Each deferred entry leaves the transaction the moment it completes, because
212
+ * the throw path re-runs commitFold on the SAME transaction: a re-entry after
213
+ * a mid-loop I/O error must RESUME at the failed entry, never re-record an
214
+ * `accepted` event the first attempt already appended.
215
+ */
216
+ export async function commitFold(artifactsDir, bundle, tx) {
217
+ await writeCoreArtifacts(artifactsDir, bundle, { prune: true });
218
+ while (tx.pendingSnapshots.length > 0) {
219
+ await writeDesignReviewSnapshot(artifactsDir, tx.pendingSnapshots[0]);
220
+ tx.pendingSnapshots.shift();
221
+ }
222
+ while (tx.staged.length > 0) {
223
+ const staged = tx.staged[0];
224
+ if (staged.applied) {
225
+ await unlink(staged.stagingPath).catch(() => { });
226
+ await recordLaneOutcome(artifactsDir, staged.lane, {
227
+ kind: "accepted",
228
+ ...(staged.acceptedMessage ? { message: staged.acceptedMessage } : {}),
229
+ });
230
+ }
231
+ else {
232
+ try {
233
+ await moveFile(staged.stagingPath, staged.boundPath);
234
+ }
235
+ catch (error) {
236
+ if (!isFileMissingError(error))
237
+ throw error;
238
+ }
239
+ }
240
+ tx.staged.shift();
241
+ }
242
+ }
243
+ //# sourceMappingURL=foldTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foldTransaction.js","sourceRoot":"","sources":["../../../src/audit/cli/foldTransaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EACL,KAAK,EACL,QAAQ,EACR,OAAO,EACP,MAAM,EACN,IAAI,EACJ,MAAM,EACN,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAuB,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EACL,yBAAyB,GAE1B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE7E,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAE7C,MAAM,UAAU,oBAAoB,CAAC,YAAoB;IACvD,OAAO,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC;AAC5C,CAAC;AAED,SAAS,sBAAsB,CAAC,QAAgB;IAC9C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7C,IAAI,CAAC;QACH,OAAO,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAChE,CAAC;IAAC,MAAM,CAAC;QACP,OAA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