ushman-ledger 0.3.0 → 1.2.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.
- package/AGENTS.md +11 -7
- package/CHANGELOG.md +8 -12
- package/README.md +28 -57
- package/dist/archive-journal.d.ts +29 -18
- package/dist/archive-journal.d.ts.map +1 -1
- package/dist/archive-journal.js +17 -17
- package/dist/blobs.js +3 -3
- package/dist/builders.d.ts +79 -358
- package/dist/builders.d.ts.map +1 -1
- package/dist/builders.js +15 -60
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +227 -52
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +104 -4
- package/dist/handle.d.ts +4 -2
- package/dist/handle.d.ts.map +1 -1
- package/dist/handle.js +20 -15
- package/dist/helpers.d.ts +7 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +38 -0
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/lab-min.d.ts +7 -7
- package/dist/lab-min.d.ts.map +1 -1
- package/dist/lab-min.js +7 -9
- package/dist/list.d.ts +104 -303
- package/dist/list.d.ts.map +1 -1
- package/dist/note.d.ts +20 -0
- package/dist/note.d.ts.map +1 -1
- package/dist/note.js +5 -0
- package/dist/patch-resolver.d.ts +27 -0
- package/dist/patch-resolver.d.ts.map +1 -0
- package/dist/patch-resolver.js +184 -0
- package/dist/read-index.d.ts +45 -57
- package/dist/read-index.d.ts.map +1 -1
- package/dist/read-index.js +16 -34
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +19 -130
- package/dist/recovery.d.ts +19 -8
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +13 -13
- package/dist/render/migration-log.d.ts +3 -0
- package/dist/render/migration-log.d.ts.map +1 -0
- package/dist/render/migration-log.js +72 -0
- package/dist/render/retro.d.ts.map +1 -1
- package/dist/render/retro.js +41 -25
- package/dist/render/workspace-narrative.d.ts +6 -0
- package/dist/render/workspace-narrative.d.ts.map +1 -0
- package/dist/render/workspace-narrative.js +69 -0
- package/dist/schema/entry-core.d.ts +110 -0
- package/dist/schema/entry-core.d.ts.map +1 -0
- package/dist/schema/entry-core.js +143 -0
- package/dist/schema/entry-migrations.d.ts +3 -0
- package/dist/schema/entry-migrations.d.ts.map +1 -0
- package/dist/schema/entry-migrations.js +48 -0
- package/dist/schema/entry-read.d.ts +694 -0
- package/dist/schema/entry-read.d.ts.map +1 -0
- package/dist/schema/entry-read.js +92 -0
- package/dist/schema/entry-write.d.ts +865 -0
- package/dist/schema/entry-write.d.ts.map +1 -0
- package/dist/schema/entry-write.js +105 -0
- package/dist/schema/entry.d.ts +6 -3295
- package/dist/schema/entry.d.ts.map +1 -1
- package/dist/schema/entry.js +10 -619
- package/dist/schema/manifest.d.ts +28 -41
- package/dist/schema/manifest.d.ts.map +1 -1
- package/dist/schema/manifest.js +20 -24
- package/dist/schema/note.d.ts +3 -9
- package/dist/schema/note.d.ts.map +1 -1
- package/dist/schema/note.js +13 -2
- package/dist/storage/filesystem.d.ts +2 -1
- package/dist/storage/filesystem.d.ts.map +1 -1
- package/dist/storage/filesystem.js +6 -4
- package/dist/storage/lock-reclaimer.d.ts +2 -0
- package/dist/storage/lock-reclaimer.d.ts.map +1 -0
- package/dist/storage/lock-reclaimer.js +45 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -4
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
export declare const LedgerSchemaVersion: "ushman-ledger-entry/v1";
|
|
3
|
+
export declare const LEDGER_PHASES: readonly ["capture", "intake", "seed", "vendor-extract", "cleanup", "parity", "characterize", "equiv", "analyze", "recover", "ship", "migration"];
|
|
4
|
+
export declare const LEDGER_KINDS: readonly ["tool-invocation", "agent-patch", "operator-patch", "operator-decision", "validator-result", "runtime-event", "note", "correction", "strip-decision-reverted", "change-log"];
|
|
5
|
+
export declare const OPERATOR_DECISION_ACTIONS: readonly ["bypass-doctor", "skip-check", "override-strip-decision", "override-ship-state", "manual-parity-assertion", "ledger-hand-edit", "escalation"];
|
|
6
|
+
export declare const NonEmptyTrimmedStringSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
7
|
+
export declare const WorkspaceRelativePathSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.CheckAction<string, "Expected a normalized workspace-relative path.">]>;
|
|
8
|
+
export declare const LedgerPhaseSchema: v.PicklistSchema<readonly ["capture", "intake", "seed", "vendor-extract", "cleanup", "parity", "characterize", "equiv", "analyze", "recover", "ship", "migration"], undefined>;
|
|
9
|
+
export declare const LedgerKindSchema: v.PicklistSchema<readonly ["tool-invocation", "agent-patch", "operator-patch", "operator-decision", "validator-result", "runtime-event", "note", "correction", "strip-decision-reverted", "change-log"], undefined>;
|
|
10
|
+
export declare const OperatorDecisionActionSchema: v.PicklistSchema<readonly ["bypass-doctor", "skip-check", "override-strip-decision", "override-ship-state", "manual-parity-assertion", "ledger-hand-edit", "escalation"], undefined>;
|
|
11
|
+
export declare const ChangeLogSubkindSchema: v.PicklistSchema<readonly ["pre-change-checkpoint", "semantic-cleanup", "vendor-extract", "decomposition", "rollback", "hotfix", "smoke"], undefined>;
|
|
12
|
+
export declare const ChangeLogSmokeResultSchema: v.PicklistSchema<readonly ["pass", "fail", "partial", "not-run"], undefined>;
|
|
13
|
+
export declare const ChangeLogParityStatusSchema: v.PicklistSchema<readonly ["green", "yellow", "red", "not-run"], undefined>;
|
|
14
|
+
export declare const EmitterSchema: v.ObjectSchema<{
|
|
15
|
+
readonly tool: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
16
|
+
readonly user: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
17
|
+
readonly version: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
18
|
+
}, undefined>;
|
|
19
|
+
export declare const LedgerLinksSchema: v.ObjectWithRestSchema<{
|
|
20
|
+
readonly affectedFiles: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.CheckAction<string, "Expected a normalized workspace-relative path.">]>, undefined>, undefined>;
|
|
21
|
+
readonly blobs: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
22
|
+
readonly briefId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
23
|
+
readonly correctsLedgerId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
24
|
+
readonly gitRef: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
25
|
+
readonly idempotencyKey: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
26
|
+
readonly stripDecisionId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
27
|
+
readonly supersedesLedgerId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
28
|
+
readonly validatorVerdictId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
29
|
+
}, v.UnknownSchema, undefined>;
|
|
30
|
+
export declare const ledgerEntryBaseEntries: {
|
|
31
|
+
details: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
32
|
+
emitter: v.ObjectSchema<{
|
|
33
|
+
readonly tool: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
34
|
+
readonly user: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
35
|
+
readonly version: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
36
|
+
}, undefined>;
|
|
37
|
+
id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
38
|
+
links: v.OptionalSchema<v.ObjectWithRestSchema<{
|
|
39
|
+
readonly affectedFiles: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.CheckAction<string, "Expected a normalized workspace-relative path.">]>, undefined>, undefined>;
|
|
40
|
+
readonly blobs: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
41
|
+
readonly briefId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
42
|
+
readonly correctsLedgerId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
43
|
+
readonly gitRef: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
44
|
+
readonly idempotencyKey: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
45
|
+
readonly stripDecisionId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
46
|
+
readonly supersedesLedgerId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
47
|
+
readonly validatorVerdictId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
48
|
+
}, v.UnknownSchema, undefined>, {}>;
|
|
49
|
+
phase: v.PicklistSchema<readonly ["capture", "intake", "seed", "vendor-extract", "cleanup", "parity", "characterize", "equiv", "analyze", "recover", "ship", "migration"], undefined>;
|
|
50
|
+
prevEntryId: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
51
|
+
schemaVersion: v.LiteralSchema<"ushman-ledger-entry/v1", undefined>;
|
|
52
|
+
summary: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
53
|
+
ts: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, undefined>]>;
|
|
54
|
+
};
|
|
55
|
+
export declare const recordEntryBaseEntries: {
|
|
56
|
+
details: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
57
|
+
emitter: v.ObjectSchema<{
|
|
58
|
+
readonly tool: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
59
|
+
readonly user: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
60
|
+
readonly version: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
61
|
+
}, undefined>;
|
|
62
|
+
idempotencyKey: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
63
|
+
links: v.OptionalSchema<v.ObjectWithRestSchema<{
|
|
64
|
+
readonly affectedFiles: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.CheckAction<string, "Expected a normalized workspace-relative path.">]>, undefined>, undefined>;
|
|
65
|
+
readonly blobs: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
66
|
+
readonly briefId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
67
|
+
readonly correctsLedgerId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
68
|
+
readonly gitRef: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
69
|
+
readonly idempotencyKey: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
70
|
+
readonly stripDecisionId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
71
|
+
readonly supersedesLedgerId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
72
|
+
readonly validatorVerdictId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
73
|
+
}, v.UnknownSchema, undefined>, undefined>;
|
|
74
|
+
phase: v.PicklistSchema<readonly ["capture", "intake", "seed", "vendor-extract", "cleanup", "parity", "characterize", "equiv", "analyze", "recover", "ship", "migration"], undefined>;
|
|
75
|
+
summary: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
76
|
+
};
|
|
77
|
+
export declare const AgentPatchDiffSchema: v.ObjectSchema<{
|
|
78
|
+
readonly addedLines: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
79
|
+
readonly blobSha256: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "Expected a lowercase SHA-256 hex digest.">]>;
|
|
80
|
+
readonly bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
81
|
+
readonly removedLines: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
82
|
+
}, undefined>;
|
|
83
|
+
export declare const OperatorDecisionPayloadSchema: v.ObjectSchema<{
|
|
84
|
+
readonly action: v.PicklistSchema<readonly ["bypass-doctor", "skip-check", "override-strip-decision", "override-ship-state", "manual-parity-assertion", "ledger-hand-edit", "escalation"], undefined>;
|
|
85
|
+
readonly checkId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
86
|
+
readonly rationale: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
87
|
+
}, undefined>;
|
|
88
|
+
export declare const StripDecisionRevertedPayloadSchema: v.ObjectSchema<{
|
|
89
|
+
readonly invalidatedStages: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["intake", "seed", "vendor-extract", "cleanup", "parity", "characterize"], undefined>, undefined>, undefined>;
|
|
90
|
+
readonly rationale: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
91
|
+
readonly stripDecisionId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
92
|
+
}, undefined>;
|
|
93
|
+
export declare const ChangeLogFileChangeSchema: v.ObjectSchema<{
|
|
94
|
+
readonly added: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
95
|
+
readonly path: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.CheckAction<string, "Expected a normalized workspace-relative path.">]>;
|
|
96
|
+
readonly removed: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
97
|
+
}, undefined>;
|
|
98
|
+
export type AgentPatchDiff = v.InferOutput<typeof AgentPatchDiffSchema>;
|
|
99
|
+
export type ChangeLogFileChange = v.InferOutput<typeof ChangeLogFileChangeSchema>;
|
|
100
|
+
export type ChangeLogParityStatus = v.InferOutput<typeof ChangeLogParityStatusSchema>;
|
|
101
|
+
export type ChangeLogSmokeResult = v.InferOutput<typeof ChangeLogSmokeResultSchema>;
|
|
102
|
+
export type ChangeLogSubkind = v.InferOutput<typeof ChangeLogSubkindSchema>;
|
|
103
|
+
export type LedgerKind = v.InferOutput<typeof LedgerKindSchema>;
|
|
104
|
+
export type LedgerLinks = v.InferOutput<typeof LedgerLinksSchema>;
|
|
105
|
+
export type LedgerPhase = v.InferOutput<typeof LedgerPhaseSchema>;
|
|
106
|
+
export type OperatorDecisionAction = v.InferOutput<typeof OperatorDecisionActionSchema>;
|
|
107
|
+
export type OperatorDecisionPayload = v.InferOutput<typeof OperatorDecisionPayloadSchema>;
|
|
108
|
+
export type StripDecisionRevertedPayload = v.InferOutput<typeof StripDecisionRevertedPayloadSchema>;
|
|
109
|
+
export type WorkspaceRelativePath = v.InferOutput<typeof WorkspaceRelativePathSchema>;
|
|
110
|
+
//# sourceMappingURL=entry-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-core.d.ts","sourceRoot":"","sources":["../../src/schema/entry-core.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,eAAO,MAAM,mBAAmB,EAAG,wBAAiC,CAAC;AAErE,eAAO,MAAM,aAAa,mJAahB,CAAC;AAEX,eAAO,MAAM,YAAY,wLAWf,CAAC;AAEX,eAAO,MAAM,yBAAyB,yJAQ5B,CAAC;AAiDX,eAAO,MAAM,2BAA2B,+GAA+C,CAAC;AAExF,eAAO,MAAM,2BAA2B,0KAIvC,CAAC;AAIF,eAAO,MAAM,iBAAiB,gLAA4B,CAAC;AAC3D,eAAO,MAAM,gBAAgB,qNAA2B,CAAC;AACzD,eAAO,MAAM,4BAA4B,sLAAwC,CAAC;AAElF,eAAO,MAAM,sBAAsB,uJAAkC,CAAC;AACtE,eAAO,MAAM,0BAA0B,8EAAuC,CAAC;AAC/E,eAAO,MAAM,2BAA2B,6EAAyC,CAAC;AAElF,eAAO,MAAM,aAAa;;;;aAIxB,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;8BAa7B,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;CAUlC,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;CAOlC,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;aAK/B,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;aAIxC,CAAC;AAEH,eAAO,MAAM,kCAAkC;;;;aAI7C,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;aAIpC,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACxE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAClF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,2BAA2B,CAAC,CAAC;AACtF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,0BAA0B,CAAC,CAAC;AACpF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC5E,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAClE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAClE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,4BAA4B,CAAC,CAAC;AACxF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAC1F,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kCAAkC,CAAC,CAAC;AACpG,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import * as v from 'valibot';
|
|
3
|
+
export const LedgerSchemaVersion = 'ushman-ledger-entry/v1';
|
|
4
|
+
export const LEDGER_PHASES = [
|
|
5
|
+
'capture',
|
|
6
|
+
'intake',
|
|
7
|
+
'seed',
|
|
8
|
+
'vendor-extract',
|
|
9
|
+
'cleanup',
|
|
10
|
+
'parity',
|
|
11
|
+
'characterize',
|
|
12
|
+
'equiv',
|
|
13
|
+
'analyze',
|
|
14
|
+
'recover',
|
|
15
|
+
'ship',
|
|
16
|
+
'migration',
|
|
17
|
+
];
|
|
18
|
+
export const LEDGER_KINDS = [
|
|
19
|
+
'tool-invocation',
|
|
20
|
+
'agent-patch',
|
|
21
|
+
'operator-patch',
|
|
22
|
+
'operator-decision',
|
|
23
|
+
'validator-result',
|
|
24
|
+
'runtime-event',
|
|
25
|
+
'note',
|
|
26
|
+
'correction',
|
|
27
|
+
'strip-decision-reverted',
|
|
28
|
+
'change-log',
|
|
29
|
+
];
|
|
30
|
+
export const OPERATOR_DECISION_ACTIONS = [
|
|
31
|
+
'bypass-doctor',
|
|
32
|
+
'skip-check',
|
|
33
|
+
'override-strip-decision',
|
|
34
|
+
'override-ship-state',
|
|
35
|
+
'manual-parity-assertion',
|
|
36
|
+
'ledger-hand-edit',
|
|
37
|
+
'escalation',
|
|
38
|
+
];
|
|
39
|
+
const STRIP_DECISION_INVALIDATED_STAGES = [
|
|
40
|
+
'intake',
|
|
41
|
+
'seed',
|
|
42
|
+
'vendor-extract',
|
|
43
|
+
'cleanup',
|
|
44
|
+
'parity',
|
|
45
|
+
'characterize',
|
|
46
|
+
];
|
|
47
|
+
const CHANGE_LOG_SUBKINDS = [
|
|
48
|
+
'pre-change-checkpoint',
|
|
49
|
+
'semantic-cleanup',
|
|
50
|
+
'vendor-extract',
|
|
51
|
+
'decomposition',
|
|
52
|
+
'rollback',
|
|
53
|
+
'hotfix',
|
|
54
|
+
'smoke',
|
|
55
|
+
];
|
|
56
|
+
const CHANGE_LOG_SMOKE_RESULTS = ['pass', 'fail', 'partial', 'not-run'];
|
|
57
|
+
const CHANGE_LOG_PARITY_STATUSES = ['green', 'yellow', 'red', 'not-run'];
|
|
58
|
+
const SHA256_HEX_PATTERN = /^[a-f0-9]{64}$/u;
|
|
59
|
+
const WINDOWS_ABSOLUTE_PATH_PATTERN = /^[a-z]:[\\/]/iu;
|
|
60
|
+
const normalizeWorkspaceRelativePath = (value) => value.replaceAll('\\', '/');
|
|
61
|
+
const isNormalizedWorkspaceRelativePath = (value) => {
|
|
62
|
+
const normalized = normalizeWorkspaceRelativePath(value);
|
|
63
|
+
if (normalized.startsWith('/') || WINDOWS_ABSOLUTE_PATH_PATTERN.test(value)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (normalized.startsWith('./') ||
|
|
67
|
+
normalized.endsWith('/') ||
|
|
68
|
+
normalized.includes('//') ||
|
|
69
|
+
normalized === '.' ||
|
|
70
|
+
normalized === '..') {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (path.posix.normalize(normalized) !== normalized) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return !normalized.split('/').includes('..');
|
|
77
|
+
};
|
|
78
|
+
export const NonEmptyTrimmedStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));
|
|
79
|
+
export const WorkspaceRelativePathSchema = v.pipe(v.string(), v.minLength(1), v.check(isNormalizedWorkspaceRelativePath, 'Expected a normalized workspace-relative path.'));
|
|
80
|
+
const SHA256HexSchema = v.pipe(v.string(), v.regex(SHA256_HEX_PATTERN, 'Expected a lowercase SHA-256 hex digest.'));
|
|
81
|
+
export const LedgerPhaseSchema = v.picklist(LEDGER_PHASES);
|
|
82
|
+
export const LedgerKindSchema = v.picklist(LEDGER_KINDS);
|
|
83
|
+
export const OperatorDecisionActionSchema = v.picklist(OPERATOR_DECISION_ACTIONS);
|
|
84
|
+
const StripDecisionInvalidatedStageSchema = v.picklist(STRIP_DECISION_INVALIDATED_STAGES);
|
|
85
|
+
export const ChangeLogSubkindSchema = v.picklist(CHANGE_LOG_SUBKINDS);
|
|
86
|
+
export const ChangeLogSmokeResultSchema = v.picklist(CHANGE_LOG_SMOKE_RESULTS);
|
|
87
|
+
export const ChangeLogParityStatusSchema = v.picklist(CHANGE_LOG_PARITY_STATUSES);
|
|
88
|
+
export const EmitterSchema = v.object({
|
|
89
|
+
tool: NonEmptyTrimmedStringSchema,
|
|
90
|
+
user: v.optional(NonEmptyTrimmedStringSchema),
|
|
91
|
+
version: NonEmptyTrimmedStringSchema,
|
|
92
|
+
});
|
|
93
|
+
export const LedgerLinksSchema = v.objectWithRest({
|
|
94
|
+
affectedFiles: v.optional(v.array(WorkspaceRelativePathSchema)),
|
|
95
|
+
blobs: v.optional(v.array(v.string())),
|
|
96
|
+
briefId: v.optional(v.string()),
|
|
97
|
+
correctsLedgerId: v.optional(v.string()),
|
|
98
|
+
gitRef: v.optional(v.string()),
|
|
99
|
+
idempotencyKey: v.optional(v.string()),
|
|
100
|
+
stripDecisionId: v.optional(v.string()),
|
|
101
|
+
supersedesLedgerId: v.optional(v.string()),
|
|
102
|
+
validatorVerdictId: v.optional(v.string()),
|
|
103
|
+
}, v.unknown());
|
|
104
|
+
export const ledgerEntryBaseEntries = {
|
|
105
|
+
details: v.optional(v.record(v.string(), v.unknown())),
|
|
106
|
+
emitter: EmitterSchema,
|
|
107
|
+
id: NonEmptyTrimmedStringSchema,
|
|
108
|
+
links: v.optional(LedgerLinksSchema, {}),
|
|
109
|
+
phase: LedgerPhaseSchema,
|
|
110
|
+
prevEntryId: v.nullable(NonEmptyTrimmedStringSchema),
|
|
111
|
+
schemaVersion: v.literal(LedgerSchemaVersion),
|
|
112
|
+
summary: NonEmptyTrimmedStringSchema,
|
|
113
|
+
ts: v.pipe(v.string(), v.isoTimestamp()),
|
|
114
|
+
};
|
|
115
|
+
export const recordEntryBaseEntries = {
|
|
116
|
+
details: v.optional(v.record(v.string(), v.unknown())),
|
|
117
|
+
emitter: EmitterSchema,
|
|
118
|
+
idempotencyKey: v.optional(NonEmptyTrimmedStringSchema),
|
|
119
|
+
links: v.optional(LedgerLinksSchema),
|
|
120
|
+
phase: LedgerPhaseSchema,
|
|
121
|
+
summary: NonEmptyTrimmedStringSchema,
|
|
122
|
+
};
|
|
123
|
+
export const AgentPatchDiffSchema = v.object({
|
|
124
|
+
addedLines: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
125
|
+
blobSha256: SHA256HexSchema,
|
|
126
|
+
bytes: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
127
|
+
removedLines: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
128
|
+
});
|
|
129
|
+
export const OperatorDecisionPayloadSchema = v.object({
|
|
130
|
+
action: OperatorDecisionActionSchema,
|
|
131
|
+
checkId: v.optional(NonEmptyTrimmedStringSchema),
|
|
132
|
+
rationale: NonEmptyTrimmedStringSchema,
|
|
133
|
+
});
|
|
134
|
+
export const StripDecisionRevertedPayloadSchema = v.object({
|
|
135
|
+
invalidatedStages: v.optional(v.array(StripDecisionInvalidatedStageSchema)),
|
|
136
|
+
rationale: NonEmptyTrimmedStringSchema,
|
|
137
|
+
stripDecisionId: NonEmptyTrimmedStringSchema,
|
|
138
|
+
});
|
|
139
|
+
export const ChangeLogFileChangeSchema = v.object({
|
|
140
|
+
added: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0))),
|
|
141
|
+
path: WorkspaceRelativePathSchema,
|
|
142
|
+
removed: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0))),
|
|
143
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-migrations.d.ts","sourceRoot":"","sources":["../../src/schema/entry-migrations.ts"],"names":[],"mappings":"AAoDA,eAAO,MAAM,uBAAuB,GAAI,OAAO,OAAO,YAA8B,CAAC;AAErF,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,YAA8B,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
2
|
+
const migrateOperatorDecision = (input) => {
|
|
3
|
+
if (input.kind !== 'operator-decision' || isRecord(input.payload)) {
|
|
4
|
+
return input;
|
|
5
|
+
}
|
|
6
|
+
const action = input.action;
|
|
7
|
+
const rationale = input.rationale;
|
|
8
|
+
if (typeof action !== 'string' || typeof rationale !== 'string') {
|
|
9
|
+
return input;
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
...input,
|
|
13
|
+
payload: {
|
|
14
|
+
action,
|
|
15
|
+
checkId: typeof input.checkId === 'string' ? input.checkId : undefined,
|
|
16
|
+
rationale,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const migrateValidatorResult = (input) => {
|
|
21
|
+
if (input.kind !== 'validator-result' || typeof input.verdict === 'string') {
|
|
22
|
+
return input;
|
|
23
|
+
}
|
|
24
|
+
if (typeof input.status !== 'string') {
|
|
25
|
+
return input;
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
...input,
|
|
29
|
+
verdict: input.status,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const migrateChangeLog = (input) => {
|
|
33
|
+
if (input.kind !== 'change-log' || Array.isArray(input.filesChanged)) {
|
|
34
|
+
return input;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
...input,
|
|
38
|
+
filesChanged: [],
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
const migrateLedgerInput = (input) => {
|
|
42
|
+
if (!isRecord(input)) {
|
|
43
|
+
return input;
|
|
44
|
+
}
|
|
45
|
+
return migrateChangeLog(migrateValidatorResult(migrateOperatorDecision({ ...input })));
|
|
46
|
+
};
|
|
47
|
+
export const migrateLedgerEntryInput = (input) => migrateLedgerInput(input);
|
|
48
|
+
export const migrateLedgerRecordInput = (input) => migrateLedgerInput(input);
|