ushman-ledger 0.3.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 (101) hide show
  1. package/AGENTS.md +41 -0
  2. package/CHANGELOG.md +23 -0
  3. package/LICENSE.md +21 -0
  4. package/README.md +233 -0
  5. package/dist/archive-journal.d.ts +63 -0
  6. package/dist/archive-journal.d.ts.map +1 -0
  7. package/dist/archive-journal.js +220 -0
  8. package/dist/archive.d.ts +30 -0
  9. package/dist/archive.d.ts.map +1 -0
  10. package/dist/archive.js +117 -0
  11. package/dist/async.d.ts +2 -0
  12. package/dist/async.d.ts.map +1 -0
  13. package/dist/async.js +20 -0
  14. package/dist/blobs.d.ts +10 -0
  15. package/dist/blobs.d.ts.map +1 -0
  16. package/dist/blobs.js +58 -0
  17. package/dist/builders.d.ts +465 -0
  18. package/dist/builders.d.ts.map +1 -0
  19. package/dist/builders.js +73 -0
  20. package/dist/candidate-paths.d.ts +3 -0
  21. package/dist/candidate-paths.d.ts.map +1 -0
  22. package/dist/candidate-paths.js +11 -0
  23. package/dist/cli.d.ts +15 -0
  24. package/dist/cli.d.ts.map +1 -0
  25. package/dist/cli.js +562 -0
  26. package/dist/coverage.d.ts +8 -0
  27. package/dist/coverage.d.ts.map +1 -0
  28. package/dist/coverage.js +128 -0
  29. package/dist/doctor.d.ts +9 -0
  30. package/dist/doctor.d.ts.map +1 -0
  31. package/dist/doctor.js +172 -0
  32. package/dist/handle.d.ts +28 -0
  33. package/dist/handle.d.ts.map +1 -0
  34. package/dist/handle.js +90 -0
  35. package/dist/index.d.ts +11 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +9 -0
  38. package/dist/json.d.ts +4 -0
  39. package/dist/json.d.ts.map +1 -0
  40. package/dist/json.js +25 -0
  41. package/dist/lab-min.d.ts +9 -0
  42. package/dist/lab-min.d.ts.map +1 -0
  43. package/dist/lab-min.js +23 -0
  44. package/dist/list.d.ts +582 -0
  45. package/dist/list.d.ts.map +1 -0
  46. package/dist/list.js +139 -0
  47. package/dist/manifest-update.d.ts +13 -0
  48. package/dist/manifest-update.d.ts.map +1 -0
  49. package/dist/manifest-update.js +43 -0
  50. package/dist/note.d.ts +13 -0
  51. package/dist/note.d.ts.map +1 -0
  52. package/dist/note.js +15 -0
  53. package/dist/patch-metadata.d.ts +37 -0
  54. package/dist/patch-metadata.d.ts.map +1 -0
  55. package/dist/patch-metadata.js +300 -0
  56. package/dist/read-index.d.ts +114 -0
  57. package/dist/read-index.d.ts.map +1 -0
  58. package/dist/read-index.js +210 -0
  59. package/dist/record.d.ts +25 -0
  60. package/dist/record.d.ts.map +1 -0
  61. package/dist/record.js +268 -0
  62. package/dist/recovery.d.ts +39 -0
  63. package/dist/recovery.d.ts.map +1 -0
  64. package/dist/recovery.js +189 -0
  65. package/dist/render/analytics-summary.d.ts +58 -0
  66. package/dist/render/analytics-summary.d.ts.map +1 -0
  67. package/dist/render/analytics-summary.js +151 -0
  68. package/dist/render/dependency-graph.d.ts +3 -0
  69. package/dist/render/dependency-graph.d.ts.map +1 -0
  70. package/dist/render/dependency-graph.js +18 -0
  71. package/dist/render/jsonl.d.ts +3 -0
  72. package/dist/render/jsonl.d.ts.map +1 -0
  73. package/dist/render/jsonl.js +8 -0
  74. package/dist/render/retro.d.ts +6 -0
  75. package/dist/render/retro.d.ts.map +1 -0
  76. package/dist/render/retro.js +124 -0
  77. package/dist/render/timeline-html.d.ts +3 -0
  78. package/dist/render/timeline-html.d.ts.map +1 -0
  79. package/dist/render/timeline-html.js +37 -0
  80. package/dist/schema/entry.d.ts +3298 -0
  81. package/dist/schema/entry.d.ts.map +1 -0
  82. package/dist/schema/entry.js +619 -0
  83. package/dist/schema/manifest.d.ts +42 -0
  84. package/dist/schema/manifest.d.ts.map +1 -0
  85. package/dist/schema/manifest.js +27 -0
  86. package/dist/schema/note.d.ts +10 -0
  87. package/dist/schema/note.d.ts.map +1 -0
  88. package/dist/schema/note.js +2 -0
  89. package/dist/storage/filesystem.d.ts +35 -0
  90. package/dist/storage/filesystem.d.ts.map +1 -0
  91. package/dist/storage/filesystem.js +258 -0
  92. package/dist/storage/lock.d.ts +18 -0
  93. package/dist/storage/lock.d.ts.map +1 -0
  94. package/dist/storage/lock.js +224 -0
  95. package/dist/uuid.d.ts +7 -0
  96. package/dist/uuid.d.ts.map +1 -0
  97. package/dist/uuid.js +25 -0
  98. package/dist/version.d.ts +2 -0
  99. package/dist/version.d.ts.map +1 -0
  100. package/dist/version.js +1 -0
  101. package/package.json +73 -0
@@ -0,0 +1,117 @@
1
+ import { cp, mkdir, mkdtemp, rm } from 'node:fs/promises';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ import { create as createTar } from 'tar';
5
+ import { createArchiveManifest, verifyArchiveFile, writeArchiveManifestFile, writePendingArchive, } from "./archive-journal.js";
6
+ import { runLedgerDoctor } from "./doctor.js";
7
+ import { updateManifestForArchive } from "./manifest-update.js";
8
+ import { reconcileLedgerStateUnderLock } from "./recovery.js";
9
+ import { readManifest, resolveLedgerPaths, saveManifest } from "./storage/filesystem.js";
10
+ import { acquireLock } from "./storage/lock.js";
11
+ const archiveTestHooks = new Map();
12
+ const resolveWorkspaceKey = (workspaceRoot) => path.resolve(workspaceRoot);
13
+ const getArchiveTestHooks = (workspaceRoot) => archiveTestHooks.get(resolveWorkspaceKey(workspaceRoot));
14
+ export const setArchiveTestHooks = (workspaceRoot, hooks) => {
15
+ const key = resolveWorkspaceKey(workspaceRoot);
16
+ if (!hooks) {
17
+ archiveTestHooks.delete(key);
18
+ return;
19
+ }
20
+ archiveTestHooks.set(key, hooks);
21
+ };
22
+ const shouldIncludeArchivedPath = (sourcePath) => {
23
+ const baseName = path.basename(sourcePath);
24
+ return !baseName.endsWith('.lock') && !baseName.includes('.tmp.');
25
+ };
26
+ const createArchiveTarFile = async ({ hooks, outPath, stagingRoot, }) => {
27
+ if (hooks?.createTar) {
28
+ await hooks.createTar({ outPath, stagingRoot });
29
+ return;
30
+ }
31
+ await createTar({
32
+ cwd: stagingRoot,
33
+ file: outPath,
34
+ gzip: true,
35
+ }, ['ledger', 'archive-manifest.json']);
36
+ };
37
+ export const archiveLedger = async (workspaceRoot, outPath) => {
38
+ const paths = resolveLedgerPaths(workspaceRoot);
39
+ const resolvedOutPath = path.resolve(outPath);
40
+ if (resolvedOutPath === paths.root || resolvedOutPath.startsWith(`${paths.root}${path.sep}`)) {
41
+ throw new Error('Archive output path must be outside the ledger directory.');
42
+ }
43
+ const lock = await acquireLock(paths.manifestLockFile);
44
+ try {
45
+ const preparedState = await reconcileLedgerStateUnderLock(workspaceRoot);
46
+ const doctor = await runLedgerDoctor(workspaceRoot, { state: preparedState });
47
+ if (!doctor.ok) {
48
+ throw new Error(`Refusing to archive unhealthy ledger:\n${doctor.issues.join('\n')}`);
49
+ }
50
+ const stagingRoot = await mkdtemp(path.join(os.tmpdir(), 'ushman-ledger-archive-'));
51
+ try {
52
+ const ledgerCopyRoot = path.join(stagingRoot, 'ledger');
53
+ await cp(paths.root, ledgerCopyRoot, {
54
+ filter: shouldIncludeArchivedPath,
55
+ recursive: true,
56
+ });
57
+ const archiveManifest = await createArchiveManifest(ledgerCopyRoot);
58
+ await writeArchiveManifestFile({
59
+ archiveManifest,
60
+ stagingRoot,
61
+ });
62
+ const createdAt = new Date().toISOString();
63
+ const hooks = getArchiveTestHooks(workspaceRoot);
64
+ const pendingArchivePath = await writePendingArchive({
65
+ archiveManifest,
66
+ createdAt,
67
+ outPath: resolvedOutPath,
68
+ workspaceRoot,
69
+ });
70
+ await hooks?.afterPendingArchiveWrite?.({
71
+ archiveManifest,
72
+ outPath: resolvedOutPath,
73
+ pendingArchivePath,
74
+ });
75
+ await mkdir(path.dirname(resolvedOutPath), { recursive: true });
76
+ await createArchiveTarFile({
77
+ hooks,
78
+ outPath: resolvedOutPath,
79
+ stagingRoot,
80
+ });
81
+ await hooks?.afterTarCreate?.({
82
+ archiveManifest,
83
+ outPath: resolvedOutPath,
84
+ });
85
+ await verifyArchiveFile({
86
+ archivePath: resolvedOutPath,
87
+ expectedArchiveManifest: archiveManifest,
88
+ });
89
+ await hooks?.afterArchiveVerify?.({
90
+ archiveManifest,
91
+ outPath: resolvedOutPath,
92
+ });
93
+ await lock.assertOwnership();
94
+ const currentManifest = await readManifest(workspaceRoot);
95
+ await saveManifest(workspaceRoot, updateManifestForArchive({
96
+ archive: {
97
+ createdAt,
98
+ integrityHash: archiveManifest.integrityHash,
99
+ outPath: resolvedOutPath,
100
+ },
101
+ manifest: currentManifest,
102
+ }));
103
+ await hooks?.afterManifestSave?.({
104
+ archiveManifest,
105
+ outPath: resolvedOutPath,
106
+ });
107
+ await rm(pendingArchivePath, { force: true });
108
+ return { integrityHash: archiveManifest.integrityHash };
109
+ }
110
+ finally {
111
+ await rm(stagingRoot, { force: true, recursive: true });
112
+ }
113
+ }
114
+ finally {
115
+ await lock.release();
116
+ }
117
+ };
@@ -0,0 +1,2 @@
1
+ export declare const mapWithConcurrencyLimit: <Input, Output>(items: readonly Input[], limit: number, mapper: (item: Input, index: number) => Promise<Output>) => Promise<Output[]>;
2
+ //# sourceMappingURL=async.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../src/async.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,GAAU,KAAK,EAAE,MAAM,EACvD,OAAO,SAAS,KAAK,EAAE,EACvB,OAAO,MAAM,EACb,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,KACxD,OAAO,CAAC,MAAM,EAAE,CAwBlB,CAAC"}
package/dist/async.js ADDED
@@ -0,0 +1,20 @@
1
+ export const mapWithConcurrencyLimit = async (items, limit, mapper) => {
2
+ if (items.length === 0) {
3
+ return [];
4
+ }
5
+ const normalizedLimit = Math.max(1, Math.trunc(limit));
6
+ const results = new Array(items.length);
7
+ let nextIndex = 0;
8
+ const workerCount = Math.min(normalizedLimit, items.length);
9
+ await Promise.all(Array.from({ length: workerCount }, async () => {
10
+ while (true) {
11
+ const currentIndex = nextIndex;
12
+ if (currentIndex >= items.length) {
13
+ return;
14
+ }
15
+ nextIndex += 1;
16
+ results[currentIndex] = await mapper(items[currentIndex], currentIndex);
17
+ }
18
+ }));
19
+ return results;
20
+ };
@@ -0,0 +1,10 @@
1
+ export type StoredPatchBlob = {
2
+ readonly addedLines: number;
3
+ readonly blobSha256: string;
4
+ readonly bytes: number;
5
+ readonly removedLines: number;
6
+ };
7
+ export declare const storePatchBlob: (workspaceRoot: string, patchText: string) => Promise<StoredPatchBlob>;
8
+ export declare const storePatchBlobFromFile: (workspaceRoot: string, patchPath: string) => Promise<StoredPatchBlob>;
9
+ export declare const resolveBlobPath: (workspaceRoot: string, sha256: string) => string;
10
+ //# sourceMappingURL=blobs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blobs.d.ts","sourceRoot":"","sources":["../src/blobs.ts"],"names":[],"mappings":"AAiCA,MAAM,MAAM,eAAe,GAAG;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAU,eAAe,MAAM,EAAE,WAAW,MAAM,KAAG,OAAO,CAAC,eAAe,CAsBtG,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAU,eAAe,MAAM,EAAE,WAAW,MAAM,KAAG,OAAO,CAAC,eAAe,CAE9G,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,eAAe,MAAM,EAAE,QAAQ,MAAM,WAAyC,CAAC"}
package/dist/blobs.js ADDED
@@ -0,0 +1,58 @@
1
+ import { mkdir, readFile, stat } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { sha256File, sha256Hex } from "./json.js";
4
+ import { resolveLedgerPaths, writeAtomicTextFile } from "./storage/filesystem.js";
5
+ const countPatchLines = (patchText) => {
6
+ let addedLines = 0;
7
+ let removedLines = 0;
8
+ let insideHunk = false;
9
+ for (const line of patchText.split(/\r?\n/u)) {
10
+ if (line.startsWith('@@')) {
11
+ insideHunk = true;
12
+ continue;
13
+ }
14
+ if (!insideHunk || line.startsWith('+++') || line.startsWith('---')) {
15
+ continue;
16
+ }
17
+ if (line.startsWith('+')) {
18
+ addedLines += 1;
19
+ continue;
20
+ }
21
+ if (line.startsWith('-')) {
22
+ removedLines += 1;
23
+ }
24
+ }
25
+ return { addedLines, removedLines };
26
+ };
27
+ const buildBlobPath = (workspaceRoot, sha256) => {
28
+ const paths = resolveLedgerPaths(workspaceRoot);
29
+ return path.join(paths.blobsDir, sha256.slice(0, 2), `${sha256}.patch`);
30
+ };
31
+ export const storePatchBlob = async (workspaceRoot, patchText) => {
32
+ const bytes = Buffer.byteLength(patchText, 'utf8');
33
+ const blobSha256 = sha256Hex(patchText);
34
+ const blobPath = buildBlobPath(workspaceRoot, blobSha256);
35
+ let shouldWrite = true;
36
+ try {
37
+ await stat(blobPath);
38
+ shouldWrite = (await sha256File(blobPath)) !== blobSha256;
39
+ }
40
+ catch (error) {
41
+ if (error.code !== 'ENOENT') {
42
+ throw error;
43
+ }
44
+ }
45
+ if (shouldWrite) {
46
+ await mkdir(path.dirname(blobPath), { recursive: true });
47
+ await writeAtomicTextFile(blobPath, patchText);
48
+ }
49
+ return {
50
+ ...countPatchLines(patchText),
51
+ blobSha256,
52
+ bytes,
53
+ };
54
+ };
55
+ export const storePatchBlobFromFile = async (workspaceRoot, patchPath) => {
56
+ return storePatchBlob(workspaceRoot, await readFile(patchPath, 'utf8'));
57
+ };
58
+ export const resolveBlobPath = (workspaceRoot, sha256) => buildBlobPath(workspaceRoot, sha256);
@@ -0,0 +1,465 @@
1
+ import { type LedgerRecord } from './schema/entry.ts';
2
+ type BuildRecordInput<TRecord extends LedgerRecord> = Omit<TRecord, 'kind'> & {
3
+ readonly kind?: TRecord['kind'];
4
+ };
5
+ /** Build an `agent-patch` record, deriving structured payload fields later if only `diffPath` is supplied. */
6
+ export declare const buildAgentPatchRecord: (input: BuildRecordInput<Extract<LedgerRecord, {
7
+ kind: "agent-patch";
8
+ }>>) => {
9
+ emitter: {
10
+ tool: string;
11
+ version: string;
12
+ user?: string | undefined;
13
+ };
14
+ phase: "seed" | "capture" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize" | "equiv" | "analyze" | "recover" | "ship" | "migration";
15
+ summary: string;
16
+ rationale: string;
17
+ agent: {
18
+ name: string;
19
+ sessionId?: string | undefined;
20
+ };
21
+ kind: "agent-patch";
22
+ details?: Record<string, unknown> | undefined;
23
+ idempotencyKey?: string | undefined;
24
+ links?: {
25
+ [x: string]: unknown;
26
+ affectedFiles?: string[] | undefined;
27
+ blobs?: string[] | undefined;
28
+ briefId?: string | undefined;
29
+ correctsLedgerId?: string | undefined;
30
+ gitRef?: string | undefined;
31
+ idempotencyKey?: string | undefined;
32
+ stripDecisionId?: string | undefined;
33
+ supersedesLedgerId?: string | undefined;
34
+ validatorVerdictId?: string | undefined;
35
+ } | undefined;
36
+ diff?: {
37
+ addedLines: number;
38
+ blobSha256: string;
39
+ bytes: number;
40
+ removedLines: number;
41
+ } | undefined;
42
+ diffPath?: string | undefined;
43
+ payload?: {
44
+ diff?: string | undefined;
45
+ diffSha256?: string | undefined;
46
+ fileSha256After?: Record<string, string> | undefined;
47
+ fileSha256Before?: Record<string, string> | undefined;
48
+ hunks?: {
49
+ endLine: number;
50
+ path: string;
51
+ startLine: number;
52
+ }[] | undefined;
53
+ touchedPaths?: string[] | undefined;
54
+ } | undefined;
55
+ };
56
+ /** Build an `operator-patch` record, deriving structured payload fields later if only `diffPath` is supplied. */
57
+ export declare const buildOperatorPatchRecord: (input: BuildRecordInput<Extract<LedgerRecord, {
58
+ kind: "operator-patch";
59
+ }>>) => {
60
+ emitter: {
61
+ tool: string;
62
+ version: string;
63
+ user?: string | undefined;
64
+ };
65
+ phase: "seed" | "capture" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize" | "equiv" | "analyze" | "recover" | "ship" | "migration";
66
+ summary: string;
67
+ rationale: string;
68
+ kind: "operator-patch";
69
+ operator: {
70
+ name: string;
71
+ };
72
+ details?: Record<string, unknown> | undefined;
73
+ idempotencyKey?: string | undefined;
74
+ links?: {
75
+ [x: string]: unknown;
76
+ affectedFiles?: string[] | undefined;
77
+ blobs?: string[] | undefined;
78
+ briefId?: string | undefined;
79
+ correctsLedgerId?: string | undefined;
80
+ gitRef?: string | undefined;
81
+ idempotencyKey?: string | undefined;
82
+ stripDecisionId?: string | undefined;
83
+ supersedesLedgerId?: string | undefined;
84
+ validatorVerdictId?: string | undefined;
85
+ } | undefined;
86
+ diff?: {
87
+ addedLines: number;
88
+ blobSha256: string;
89
+ bytes: number;
90
+ removedLines: number;
91
+ } | undefined;
92
+ diffPath?: string | undefined;
93
+ payload?: {
94
+ diff?: string | undefined;
95
+ diffSha256?: string | undefined;
96
+ fileSha256After?: Record<string, string> | undefined;
97
+ fileSha256Before?: Record<string, string> | undefined;
98
+ hunks?: {
99
+ endLine: number;
100
+ path: string;
101
+ startLine: number;
102
+ }[] | undefined;
103
+ touchedPaths?: string[] | undefined;
104
+ } | undefined;
105
+ };
106
+ /** Build a `stage-transition` record with a validated structured payload. */
107
+ export declare const buildStageTransitionRecord: (input: BuildRecordInput<Extract<LedgerRecord, {
108
+ kind: "stage-transition";
109
+ }>>) => {
110
+ emitter: {
111
+ tool: string;
112
+ version: string;
113
+ user?: string | undefined;
114
+ };
115
+ phase: "seed" | "capture" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize" | "equiv" | "analyze" | "recover" | "ship" | "migration";
116
+ summary: string;
117
+ kind: "stage-transition";
118
+ payload: {
119
+ endedAt: string;
120
+ exitCode: number;
121
+ stage: "seed" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize";
122
+ startedAt: string;
123
+ doctorBaselineId?: string | undefined;
124
+ };
125
+ details?: Record<string, unknown> | undefined;
126
+ idempotencyKey?: string | undefined;
127
+ links?: {
128
+ [x: string]: unknown;
129
+ affectedFiles?: string[] | undefined;
130
+ blobs?: string[] | undefined;
131
+ briefId?: string | undefined;
132
+ correctsLedgerId?: string | undefined;
133
+ gitRef?: string | undefined;
134
+ idempotencyKey?: string | undefined;
135
+ stripDecisionId?: string | undefined;
136
+ supersedesLedgerId?: string | undefined;
137
+ validatorVerdictId?: string | undefined;
138
+ } | undefined;
139
+ };
140
+ /** Build an `operator-decision` record using the required structured payload shape. */
141
+ export declare const buildOperatorDecisionRecord: (input: BuildRecordInput<Extract<LedgerRecord, {
142
+ kind: "operator-decision";
143
+ }>>) => {
144
+ emitter: {
145
+ tool: string;
146
+ version: string;
147
+ user?: string | undefined;
148
+ };
149
+ phase: "seed" | "capture" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize" | "equiv" | "analyze" | "recover" | "ship" | "migration";
150
+ summary: string;
151
+ kind: "operator-decision";
152
+ payload: {
153
+ action: "bypass-doctor" | "skip-check" | "override-strip-decision" | "override-ship-state" | "manual-parity-assertion" | "ledger-hand-edit" | "escalation";
154
+ rationale: string;
155
+ checkId?: string | undefined;
156
+ };
157
+ details?: Record<string, unknown> | undefined;
158
+ idempotencyKey?: string | undefined;
159
+ links?: {
160
+ [x: string]: unknown;
161
+ affectedFiles?: string[] | undefined;
162
+ blobs?: string[] | undefined;
163
+ briefId?: string | undefined;
164
+ correctsLedgerId?: string | undefined;
165
+ gitRef?: string | undefined;
166
+ idempotencyKey?: string | undefined;
167
+ stripDecisionId?: string | undefined;
168
+ supersedesLedgerId?: string | undefined;
169
+ validatorVerdictId?: string | undefined;
170
+ } | undefined;
171
+ };
172
+ /** Build a `validator-result` record and synthesize `payload.id` only when the caller omits it. */
173
+ export declare const buildValidatorResultRecord: (input: BuildRecordInput<Extract<LedgerRecord, {
174
+ kind: "validator-result";
175
+ }>>) => {
176
+ emitter: {
177
+ tool: string;
178
+ version: string;
179
+ user?: string | undefined;
180
+ };
181
+ phase: "seed" | "capture" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize" | "equiv" | "analyze" | "recover" | "ship" | "migration";
182
+ summary: string;
183
+ kind: "validator-result";
184
+ validator: "parity" | "characterize" | "equiv" | "verify" | "doctor";
185
+ verdict: "green" | "yellow" | "red";
186
+ details?: Record<string, unknown> | undefined;
187
+ idempotencyKey?: string | undefined;
188
+ links?: {
189
+ [x: string]: unknown;
190
+ affectedFiles?: string[] | undefined;
191
+ blobs?: string[] | undefined;
192
+ briefId?: string | undefined;
193
+ correctsLedgerId?: string | undefined;
194
+ gitRef?: string | undefined;
195
+ idempotencyKey?: string | undefined;
196
+ stripDecisionId?: string | undefined;
197
+ supersedesLedgerId?: string | undefined;
198
+ validatorVerdictId?: string | undefined;
199
+ } | undefined;
200
+ metrics?: Record<string, unknown> | undefined;
201
+ payload?: {
202
+ id?: string | undefined;
203
+ } | undefined;
204
+ resultPath?: string | undefined;
205
+ };
206
+ /** Build a `correction` record with validated linkage fields. */
207
+ export declare const buildCorrectionRecord: (input: BuildRecordInput<Extract<LedgerRecord, {
208
+ kind: "correction";
209
+ }>>) => {
210
+ emitter: {
211
+ tool: string;
212
+ version: string;
213
+ user?: string | undefined;
214
+ };
215
+ phase: "seed" | "capture" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize" | "equiv" | "analyze" | "recover" | "ship" | "migration";
216
+ summary: string;
217
+ kind: "correction";
218
+ rationale: string;
219
+ details?: Record<string, unknown> | undefined;
220
+ idempotencyKey?: string | undefined;
221
+ links?: {
222
+ [x: string]: unknown;
223
+ affectedFiles?: string[] | undefined;
224
+ blobs?: string[] | undefined;
225
+ briefId?: string | undefined;
226
+ correctsLedgerId?: string | undefined;
227
+ gitRef?: string | undefined;
228
+ idempotencyKey?: string | undefined;
229
+ stripDecisionId?: string | undefined;
230
+ supersedesLedgerId?: string | undefined;
231
+ validatorVerdictId?: string | undefined;
232
+ } | undefined;
233
+ payload?: {
234
+ correctsValidatorResultId?: string | undefined;
235
+ } | undefined;
236
+ };
237
+ /** Build a `strip-decision-reverted` record. */
238
+ export declare const buildStripDecisionRevertedRecord: (input: BuildRecordInput<Extract<LedgerRecord, {
239
+ kind: "strip-decision-reverted";
240
+ }>>) => {
241
+ emitter: {
242
+ tool: string;
243
+ version: string;
244
+ user?: string | undefined;
245
+ };
246
+ phase: "seed" | "capture" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize" | "equiv" | "analyze" | "recover" | "ship" | "migration";
247
+ summary: string;
248
+ kind: "strip-decision-reverted";
249
+ payload: {
250
+ rationale: string;
251
+ stripDecisionId: string;
252
+ invalidatedStages?: ("seed" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize")[] | undefined;
253
+ };
254
+ details?: Record<string, unknown> | undefined;
255
+ idempotencyKey?: string | undefined;
256
+ links?: {
257
+ [x: string]: unknown;
258
+ affectedFiles?: string[] | undefined;
259
+ blobs?: string[] | undefined;
260
+ briefId?: string | undefined;
261
+ correctsLedgerId?: string | undefined;
262
+ gitRef?: string | undefined;
263
+ idempotencyKey?: string | undefined;
264
+ stripDecisionId?: string | undefined;
265
+ supersedesLedgerId?: string | undefined;
266
+ validatorVerdictId?: string | undefined;
267
+ } | undefined;
268
+ };
269
+ /** Build a `descope-brief` record. */
270
+ export declare const buildDescopeBriefRecord: (input: BuildRecordInput<Extract<LedgerRecord, {
271
+ kind: "descope-brief";
272
+ }>>) => {
273
+ emitter: {
274
+ tool: string;
275
+ version: string;
276
+ user?: string | undefined;
277
+ };
278
+ phase: "seed" | "capture" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize" | "equiv" | "analyze" | "recover" | "ship" | "migration";
279
+ summary: string;
280
+ kind: "descope-brief";
281
+ payload: {
282
+ briefId: string;
283
+ reason?: string | undefined;
284
+ round?: number | undefined;
285
+ stripDecisionIds?: string[] | undefined;
286
+ };
287
+ details?: Record<string, unknown> | undefined;
288
+ idempotencyKey?: string | undefined;
289
+ links?: {
290
+ [x: string]: unknown;
291
+ affectedFiles?: string[] | undefined;
292
+ blobs?: string[] | undefined;
293
+ briefId?: string | undefined;
294
+ correctsLedgerId?: string | undefined;
295
+ gitRef?: string | undefined;
296
+ idempotencyKey?: string | undefined;
297
+ stripDecisionId?: string | undefined;
298
+ supersedesLedgerId?: string | undefined;
299
+ validatorVerdictId?: string | undefined;
300
+ } | undefined;
301
+ };
302
+ /** Build a `merge-return` record. */
303
+ export declare const buildMergeReturnRecord: (input: BuildRecordInput<Extract<LedgerRecord, {
304
+ kind: "merge-return";
305
+ }>>) => {
306
+ emitter: {
307
+ tool: string;
308
+ version: string;
309
+ user?: string | undefined;
310
+ };
311
+ phase: "seed" | "capture" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize" | "equiv" | "analyze" | "recover" | "ship" | "migration";
312
+ summary: string;
313
+ kind: "merge-return";
314
+ payload: {
315
+ returnId: string;
316
+ briefId?: string | undefined;
317
+ source?: string | undefined;
318
+ };
319
+ details?: Record<string, unknown> | undefined;
320
+ idempotencyKey?: string | undefined;
321
+ links?: {
322
+ [x: string]: unknown;
323
+ affectedFiles?: string[] | undefined;
324
+ blobs?: string[] | undefined;
325
+ briefId?: string | undefined;
326
+ correctsLedgerId?: string | undefined;
327
+ gitRef?: string | undefined;
328
+ idempotencyKey?: string | undefined;
329
+ stripDecisionId?: string | undefined;
330
+ supersedesLedgerId?: string | undefined;
331
+ validatorVerdictId?: string | undefined;
332
+ } | undefined;
333
+ };
334
+ /** Build a `merge-return-rejected` record. */
335
+ export declare const buildMergeReturnRejectedRecord: (input: BuildRecordInput<Extract<LedgerRecord, {
336
+ kind: "merge-return-rejected";
337
+ }>>) => {
338
+ emitter: {
339
+ tool: string;
340
+ version: string;
341
+ user?: string | undefined;
342
+ };
343
+ phase: "seed" | "capture" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize" | "equiv" | "analyze" | "recover" | "ship" | "migration";
344
+ summary: string;
345
+ kind: "merge-return-rejected";
346
+ payload: {
347
+ returnId: string;
348
+ reason: string;
349
+ briefId?: string | undefined;
350
+ source?: string | undefined;
351
+ };
352
+ details?: Record<string, unknown> | undefined;
353
+ idempotencyKey?: string | undefined;
354
+ links?: {
355
+ [x: string]: unknown;
356
+ affectedFiles?: string[] | undefined;
357
+ blobs?: string[] | undefined;
358
+ briefId?: string | undefined;
359
+ correctsLedgerId?: string | undefined;
360
+ gitRef?: string | undefined;
361
+ idempotencyKey?: string | undefined;
362
+ stripDecisionId?: string | undefined;
363
+ supersedesLedgerId?: string | undefined;
364
+ validatorVerdictId?: string | undefined;
365
+ } | undefined;
366
+ };
367
+ /** Build a `revert` record. */
368
+ export declare const buildRevertRecord: (input: BuildRecordInput<Extract<LedgerRecord, {
369
+ kind: "revert";
370
+ }>>) => {
371
+ emitter: {
372
+ tool: string;
373
+ version: string;
374
+ user?: string | undefined;
375
+ };
376
+ phase: "seed" | "capture" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize" | "equiv" | "analyze" | "recover" | "ship" | "migration";
377
+ summary: string;
378
+ kind: "revert";
379
+ payload: {
380
+ reason: string;
381
+ targetEntryId?: string | undefined;
382
+ };
383
+ details?: Record<string, unknown> | undefined;
384
+ idempotencyKey?: string | undefined;
385
+ links?: {
386
+ [x: string]: unknown;
387
+ affectedFiles?: string[] | undefined;
388
+ blobs?: string[] | undefined;
389
+ briefId?: string | undefined;
390
+ correctsLedgerId?: string | undefined;
391
+ gitRef?: string | undefined;
392
+ idempotencyKey?: string | undefined;
393
+ stripDecisionId?: string | undefined;
394
+ supersedesLedgerId?: string | undefined;
395
+ validatorVerdictId?: string | undefined;
396
+ } | undefined;
397
+ };
398
+ /** Build a `rollback` record. */
399
+ export declare const buildRollbackRecord: (input: BuildRecordInput<Extract<LedgerRecord, {
400
+ kind: "rollback";
401
+ }>>) => {
402
+ emitter: {
403
+ tool: string;
404
+ version: string;
405
+ user?: string | undefined;
406
+ };
407
+ phase: "seed" | "capture" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize" | "equiv" | "analyze" | "recover" | "ship" | "migration";
408
+ summary: string;
409
+ kind: "rollback";
410
+ payload: {
411
+ reason: string;
412
+ targetEntryId?: string | undefined;
413
+ targetStage?: "seed" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize" | undefined;
414
+ };
415
+ details?: Record<string, unknown> | undefined;
416
+ idempotencyKey?: string | undefined;
417
+ links?: {
418
+ [x: string]: unknown;
419
+ affectedFiles?: string[] | undefined;
420
+ blobs?: string[] | undefined;
421
+ briefId?: string | undefined;
422
+ correctsLedgerId?: string | undefined;
423
+ gitRef?: string | undefined;
424
+ idempotencyKey?: string | undefined;
425
+ stripDecisionId?: string | undefined;
426
+ supersedesLedgerId?: string | undefined;
427
+ validatorVerdictId?: string | undefined;
428
+ } | undefined;
429
+ };
430
+ /** Build a `rework.test_retired` record. */
431
+ export declare const buildReworkTestRetiredRecord: (input: BuildRecordInput<Extract<LedgerRecord, {
432
+ kind: "rework.test_retired";
433
+ }>>) => {
434
+ emitter: {
435
+ tool: string;
436
+ version: string;
437
+ user?: string | undefined;
438
+ };
439
+ phase: "seed" | "capture" | "intake" | "vendor-extract" | "cleanup" | "parity" | "characterize" | "equiv" | "analyze" | "recover" | "ship" | "migration";
440
+ summary: string;
441
+ kind: "rework.test_retired";
442
+ payload: {
443
+ removedBy: "operator" | "descope" | "decompose";
444
+ removedTestPath: string;
445
+ removedTestSymbols: string[];
446
+ sourceSymbolDeletedFrom: string;
447
+ briefId?: string | undefined;
448
+ };
449
+ details?: Record<string, unknown> | undefined;
450
+ idempotencyKey?: string | undefined;
451
+ links?: {
452
+ [x: string]: unknown;
453
+ affectedFiles?: string[] | undefined;
454
+ blobs?: string[] | undefined;
455
+ briefId?: string | undefined;
456
+ correctsLedgerId?: string | undefined;
457
+ gitRef?: string | undefined;
458
+ idempotencyKey?: string | undefined;
459
+ stripDecisionId?: string | undefined;
460
+ supersedesLedgerId?: string | undefined;
461
+ validatorVerdictId?: string | undefined;
462
+ } | undefined;
463
+ };
464
+ export {};
465
+ //# sourceMappingURL=builders.d.ts.map