@lmzhen/dsh-evolution-core 0.41.0 → 0.42.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/lib/composition/index.js +2 -2
- package/lib/{composition-Da8NfRI7.js → composition-CVafrlEw.js} +2 -2
- package/lib/guards-3f02mnf2.js +29 -0
- package/lib/http-routes.js +205 -1
- package/lib/index.js +3587 -15048
- package/lib/mutations-jUuOPaCn.js +718 -0
- package/lib/platform/index.js +2 -2
- package/lib/{platform-CFp373_0.js → platform-B06_h8t-.js} +4 -1
- package/lib/runtime/plugin.js +2 -2
- package/lib/{session-projection-CXUNPkq9.js → session-projection-EB7mUOlJ.js} +63 -63
- package/lib/skill-health-BLGZTIv8.js +3773 -0
- package/lib/skill-history-_Cssts5o.js +1912 -0
- package/lib/skills.js +4067 -0
- package/lib/subagent/index.js +1 -1
- package/lib/types/home-fence.d.ts +7 -0
- package/lib/types/home-fence.js +58 -3
- package/lib/types/index.d.ts +1 -18
- package/lib/types/index.js +1 -18
- package/lib/types/io.js +1 -1
- package/lib/types/mutation-authority.d.ts +14 -37
- package/lib/types/mutation-authority.js +16 -103
- package/lib/types/mutation-storage-adapter.js +9 -6
- package/lib/types/mutation-unit.d.ts +14 -0
- package/lib/types/mutation-unit.js +30 -10
- package/lib/types/opt-in.js +1 -1
- package/lib/types/platform/index.d.ts +8 -1
- package/lib/types/platform/index.js +3 -0
- package/lib/types/review-channel.js +3 -1
- package/lib/types/review-context.js +3 -1
- package/lib/types/run-registry.d.ts +2 -24
- package/lib/types/scope.js +1 -1
- package/lib/types/signals.d.ts +1 -1
- package/lib/types/skill-store.d.ts +7 -1
- package/lib/types/skill-store.js +43 -80
- package/lib/types/skills.d.ts +11 -0
- package/lib/types/skills.js +11 -0
- package/lib/types/subagent/types.d.ts +3 -3
- package/lib/types/tree-lock.js +4 -1
- package/lib/types/unit-claim.d.ts +8 -0
- package/lib/types/unit-claim.js +3 -0
- package/lib/types/unit-journal.d.ts +3 -1
- package/lib/types/unit-journal.js +12 -3
- package/lib/types/unit-storage.d.ts +1 -0
- package/lib/types/write-gates.d.ts +1 -1
- package/lib/types/write-gates.js +3 -1
- package/lib/types/write.d.ts +11 -0
- package/lib/types/write.js +11 -0
- package/lib/write.js +357 -0
- package/package.json +16 -4
- package/lib/http-routes-_anZVlPf.js +0 -233
- package/lib/types/unit-backend.d.ts +0 -5
- package/lib/types/unit-backend.js +0 -55
- package/lib/types/unit-transaction.d.ts +0 -225
- package/lib/types/unit-transaction.js +0 -501
- package/lib/{ensure-C5Mo1dbB.js → ensure-BjToTMMj.js} +1 -1
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export function skillLibraryUnitBackend(skills) {
|
|
2
|
-
return {
|
|
3
|
-
async readSkill(name) { return await skills.read(name); },
|
|
4
|
-
async readSupportFile(name, path) {
|
|
5
|
-
const probe = skills.readSupportFile;
|
|
6
|
-
return typeof probe === 'function' ? await probe.call(skills, name, path) : null;
|
|
7
|
-
},
|
|
8
|
-
async commit(plan, onPhase, signal, assertFence) {
|
|
9
|
-
const result = await skills.commitMerge({
|
|
10
|
-
...(plan.runId === undefined ? {} : { runId: plan.runId }),
|
|
11
|
-
...(plan.unitId === undefined ? {} : { unitId: plan.unitId }),
|
|
12
|
-
target: plan.target,
|
|
13
|
-
targetExists: plan.targetExists,
|
|
14
|
-
sources: plan.sources,
|
|
15
|
-
body: plan.body,
|
|
16
|
-
supportFiles: plan.supportFiles,
|
|
17
|
-
expectedTargetBody: plan.expectedTargetBody,
|
|
18
|
-
expectedSourceBodies: plan.expectedSourceBodies,
|
|
19
|
-
origin: plan.origin,
|
|
20
|
-
summary: plan.summary,
|
|
21
|
-
...(plan.skillLimits === undefined ? {} : { limits: plan.skillLimits }),
|
|
22
|
-
...(plan.targetRevision === undefined ? {} : { targetRevision: plan.targetRevision }),
|
|
23
|
-
...(plan.sourceRevisions === undefined ? {} : { sourceRevisions: plan.sourceRevisions }),
|
|
24
|
-
...(plan.supportDigest === undefined ? {} : { supportDigest: plan.supportDigest }),
|
|
25
|
-
...(onPhase === undefined ? {} : { onPhase }),
|
|
26
|
-
...(signal === undefined ? {} : { signal }),
|
|
27
|
-
...(assertFence === undefined ? {} : { assertFence }),
|
|
28
|
-
});
|
|
29
|
-
return { ok: result.ok, message: result.message, ...(result.code === undefined ? {} : { code: result.code }), ...(result.archived === undefined ? {} : { archived: result.archived }), ...(result.mutations === undefined ? {} : { mutations: result.mutations }) };
|
|
30
|
-
},
|
|
31
|
-
async restoreTarget(name, body) {
|
|
32
|
-
if (body === null) {
|
|
33
|
-
await skills.archive(name, { reason: 'unit-rollback' });
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const result = await skills.update(name, body);
|
|
37
|
-
if (!result.ok)
|
|
38
|
-
throw new Error(result.message);
|
|
39
|
-
},
|
|
40
|
-
async restoreSupportFile(name, path, content) {
|
|
41
|
-
const result = content === null ? await skills.removeSupportFile(name, path) : await skills.writeSupportFile(name, path, content);
|
|
42
|
-
if (!result.ok)
|
|
43
|
-
throw new Error(result.message);
|
|
44
|
-
},
|
|
45
|
-
async restoreSource(name, body) {
|
|
46
|
-
const restored = await skills.restoreFromArchive(name);
|
|
47
|
-
if (restored.ok)
|
|
48
|
-
return;
|
|
49
|
-
const result = await skills.update(name, body);
|
|
50
|
-
if (!result.ok)
|
|
51
|
-
throw new Error(result.message);
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=unit-backend.js.map
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import type { EvolutionIoLike } from "./io.ts";
|
|
2
|
-
import type { HomeFence } from './home-fence.ts';
|
|
3
|
-
import { type UnitEvidenceRecord } from "./unit-storage.ts";
|
|
4
|
-
import { type UnitJournalPhase } from "./unit-journal.ts";
|
|
5
|
-
export interface UnitSupportFile {
|
|
6
|
-
readonly path: string;
|
|
7
|
-
readonly content: string;
|
|
8
|
-
}
|
|
9
|
-
export interface UnitPlan {
|
|
10
|
-
readonly runId: string;
|
|
11
|
-
/** Filled by the transaction before the backend write; history records it. */
|
|
12
|
-
readonly unitId?: string;
|
|
13
|
-
readonly pairKey: string;
|
|
14
|
-
readonly target: string;
|
|
15
|
-
readonly targetExists: boolean;
|
|
16
|
-
readonly sources: readonly string[];
|
|
17
|
-
readonly body: string;
|
|
18
|
-
readonly supportFiles: readonly UnitSupportFile[];
|
|
19
|
-
readonly expectedTargetBody: string | null;
|
|
20
|
-
readonly expectedSourceBodies: readonly {
|
|
21
|
-
name: string;
|
|
22
|
-
body: string;
|
|
23
|
-
}[];
|
|
24
|
-
readonly origin: "foreground" | "subagent" | "background_review";
|
|
25
|
-
readonly summary: string;
|
|
26
|
-
readonly skillLimits?: import("./limits.ts").SkillLimits;
|
|
27
|
-
readonly limitsDigest?: string;
|
|
28
|
-
readonly validationPlan?: {
|
|
29
|
-
readonly planVersion: 1;
|
|
30
|
-
readonly stageDigest: string;
|
|
31
|
-
readonly revision: string;
|
|
32
|
-
};
|
|
33
|
-
readonly targetRevision?: {
|
|
34
|
-
readonly kind: 'absent';
|
|
35
|
-
} | {
|
|
36
|
-
readonly kind: 'present';
|
|
37
|
-
readonly sha256: string;
|
|
38
|
-
};
|
|
39
|
-
readonly sourceRevisions?: Readonly<Record<string, {
|
|
40
|
-
readonly kind: 'absent';
|
|
41
|
-
} | {
|
|
42
|
-
readonly kind: 'present';
|
|
43
|
-
readonly sha256: string;
|
|
44
|
-
}>>;
|
|
45
|
-
readonly supportDigest?: string;
|
|
46
|
-
}
|
|
47
|
-
export interface UnitCommitResult {
|
|
48
|
-
readonly ok: boolean;
|
|
49
|
-
readonly message: string;
|
|
50
|
-
/** Typed backend refusal (revision CAS); absent means a generic commit failure. */
|
|
51
|
-
readonly code?: UnitErrorCode;
|
|
52
|
-
readonly archived?: readonly string[];
|
|
53
|
-
readonly mutations?: number;
|
|
54
|
-
}
|
|
55
|
-
export interface UnitBackend {
|
|
56
|
-
readSkill(name: string): Promise<string | null>;
|
|
57
|
-
readSupportFile(name: string, path: string): Promise<string | null>;
|
|
58
|
-
commit(plan: UnitPlan, onPhase?: (phase: "target-pending" | "target-applied" | "target-written" | "source-archiving" | "sources-archived" | "support-pending" | "unit-written", detail?: {
|
|
59
|
-
source?: string;
|
|
60
|
-
}) => void | Promise<void>, signal?: AbortSignal, assertFence?: () => Promise<boolean>): Promise<UnitCommitResult>;
|
|
61
|
-
restoreTarget(name: string, body: string | null): Promise<void>;
|
|
62
|
-
restoreSource(name: string, body: string): Promise<void>;
|
|
63
|
-
restoreSupportFile?(name: string, path: string, content: string | null): Promise<void>;
|
|
64
|
-
}
|
|
65
|
-
export interface UnitClaim {
|
|
66
|
-
release(): Promise<void>;
|
|
67
|
-
}
|
|
68
|
-
export interface UnitClaimPort {
|
|
69
|
-
acquire(target: string, runId: string): Promise<UnitClaim>;
|
|
70
|
-
}
|
|
71
|
-
export interface UnitTransactionOptions {
|
|
72
|
-
readonly io: EvolutionIoLike;
|
|
73
|
-
readonly home: string;
|
|
74
|
-
readonly backend: UnitBackend;
|
|
75
|
-
readonly claim: UnitClaimPort;
|
|
76
|
-
readonly now?: () => number;
|
|
77
|
-
readonly waitMs?: number;
|
|
78
|
-
/** Gate/fault-injection seam: called after each journal phase is durable. */
|
|
79
|
-
readonly onPhase?: (phase: UnitJournalPhase) => void | Promise<void>;
|
|
80
|
-
/** Gate instrumentation: tree fence then target claim. */
|
|
81
|
-
readonly onLock?: (lock: "tree" | "claim") => void;
|
|
82
|
-
/** One home fence owned by authority; when set, UnitTransactions must not acquire tree-lock itself. */
|
|
83
|
-
readonly fence?: HomeFence;
|
|
84
|
-
/** Optional run liveness gate: false means the run is terminal and must not commit. */
|
|
85
|
-
readonly isActive?: (runId: string) => boolean | Promise<boolean>;
|
|
86
|
-
}
|
|
87
|
-
export type UnitErrorCode = "unit-plan-missing" | "unit-conflict" | "unit-committed" | "unit-prepare-failed" | "unit-commit-failed" | "unit-claim-failed" | "unit-fence-failed" | "unit-run-inactive" | "unit-rollback-blocked" | "target-changed" | "source-changed" | "support-changed";
|
|
88
|
-
export interface UnitFailure {
|
|
89
|
-
readonly ok: false;
|
|
90
|
-
readonly code: UnitErrorCode;
|
|
91
|
-
readonly message: string;
|
|
92
|
-
}
|
|
93
|
-
export interface UnitPrepared {
|
|
94
|
-
readonly unitId: string;
|
|
95
|
-
readonly planDigest: string;
|
|
96
|
-
}
|
|
97
|
-
export interface UnitTransaction {
|
|
98
|
-
prepare(plan: UnitPlan): Promise<{
|
|
99
|
-
ok: true;
|
|
100
|
-
prepared: UnitPrepared;
|
|
101
|
-
} | UnitFailure>;
|
|
102
|
-
commit(prepared: UnitPrepared, options?: {
|
|
103
|
-
signal?: AbortSignal;
|
|
104
|
-
}): Promise<{
|
|
105
|
-
ok: true;
|
|
106
|
-
evidence: UnitEvidenceRecord;
|
|
107
|
-
} | UnitFailure>;
|
|
108
|
-
verify(ref: {
|
|
109
|
-
unitId: string;
|
|
110
|
-
} | {
|
|
111
|
-
runId: string;
|
|
112
|
-
}): Promise<UnitEvidenceRecord | UnitEvidenceRecord[] | null>;
|
|
113
|
-
rollback(ref: {
|
|
114
|
-
unitId: string;
|
|
115
|
-
reason: string;
|
|
116
|
-
}): Promise<{
|
|
117
|
-
ok: true;
|
|
118
|
-
evidence: UnitEvidenceRecord;
|
|
119
|
-
} | UnitFailure>;
|
|
120
|
-
finalize(unitId: string): Promise<{
|
|
121
|
-
ok: true;
|
|
122
|
-
evidence: UnitEvidenceRecord;
|
|
123
|
-
} | UnitFailure>;
|
|
124
|
-
rollForward(unitId: string): Promise<{
|
|
125
|
-
ok: true;
|
|
126
|
-
evidence: UnitEvidenceRecord;
|
|
127
|
-
} | UnitFailure>;
|
|
128
|
-
cancel(unitId: string, reason: string): Promise<{
|
|
129
|
-
ok: boolean;
|
|
130
|
-
phase: UnitJournalPhase | "none";
|
|
131
|
-
}>;
|
|
132
|
-
}
|
|
133
|
-
export declare function unitEvidenceDigest(evidence: UnitEvidenceRecord): string;
|
|
134
|
-
export declare class UnitTransactions implements UnitTransaction {
|
|
135
|
-
private readonly options;
|
|
136
|
-
private readonly prepared;
|
|
137
|
-
private readonly commits;
|
|
138
|
-
private readonly now;
|
|
139
|
-
constructor(options: UnitTransactionOptions);
|
|
140
|
-
private unitId;
|
|
141
|
-
private snapshot;
|
|
142
|
-
prepare(plan: UnitPlan): Promise<{
|
|
143
|
-
ok: true;
|
|
144
|
-
prepared: {
|
|
145
|
-
unitId: string;
|
|
146
|
-
planDigest: string;
|
|
147
|
-
};
|
|
148
|
-
code?: never;
|
|
149
|
-
message?: never;
|
|
150
|
-
} | {
|
|
151
|
-
ok: false;
|
|
152
|
-
code: "unit-conflict";
|
|
153
|
-
message: string;
|
|
154
|
-
prepared?: never;
|
|
155
|
-
}>;
|
|
156
|
-
commit(prepared: UnitPrepared, options?: {
|
|
157
|
-
signal?: AbortSignal;
|
|
158
|
-
}): Promise<{
|
|
159
|
-
ok: true;
|
|
160
|
-
evidence: UnitEvidenceRecord;
|
|
161
|
-
} | UnitFailure>;
|
|
162
|
-
private commitOnce;
|
|
163
|
-
verify(ref: {
|
|
164
|
-
unitId: string;
|
|
165
|
-
} | {
|
|
166
|
-
runId: string;
|
|
167
|
-
}): Promise<UnitEvidenceRecord | UnitEvidenceRecord[] | null>;
|
|
168
|
-
finalize(unitId: string): Promise<{
|
|
169
|
-
ok: true;
|
|
170
|
-
evidence: UnitEvidenceRecord;
|
|
171
|
-
code?: never;
|
|
172
|
-
message?: never;
|
|
173
|
-
} | {
|
|
174
|
-
ok: false;
|
|
175
|
-
code: "unit-rollback-blocked";
|
|
176
|
-
message: string;
|
|
177
|
-
evidence?: never;
|
|
178
|
-
}>;
|
|
179
|
-
rollForward(unitId: string): Promise<{
|
|
180
|
-
ok: true;
|
|
181
|
-
evidence: UnitEvidenceRecord;
|
|
182
|
-
code?: never;
|
|
183
|
-
message?: never;
|
|
184
|
-
} | {
|
|
185
|
-
ok: false;
|
|
186
|
-
code: "unit-rollback-blocked";
|
|
187
|
-
message: string;
|
|
188
|
-
evidence?: never;
|
|
189
|
-
}>;
|
|
190
|
-
rollback(ref: {
|
|
191
|
-
unitId: string;
|
|
192
|
-
reason: string;
|
|
193
|
-
}): Promise<{
|
|
194
|
-
ok: false;
|
|
195
|
-
code: "unit-committed";
|
|
196
|
-
message: string;
|
|
197
|
-
evidence?: never;
|
|
198
|
-
} | {
|
|
199
|
-
ok: false;
|
|
200
|
-
code: "unit-rollback-blocked";
|
|
201
|
-
message: string;
|
|
202
|
-
evidence?: never;
|
|
203
|
-
} | {
|
|
204
|
-
ok: false;
|
|
205
|
-
code: "unit-fence-failed";
|
|
206
|
-
message: string;
|
|
207
|
-
evidence?: never;
|
|
208
|
-
} | {
|
|
209
|
-
ok: true;
|
|
210
|
-
evidence: UnitEvidenceRecord;
|
|
211
|
-
code?: never;
|
|
212
|
-
message?: never;
|
|
213
|
-
}>;
|
|
214
|
-
cancel(unitId: string, reason: string): Promise<{
|
|
215
|
-
ok: boolean;
|
|
216
|
-
phase: "none";
|
|
217
|
-
} | {
|
|
218
|
-
ok: boolean;
|
|
219
|
-
phase: "target-pending" | "target-written" | "source-archiving" | "sources-archived";
|
|
220
|
-
} | {
|
|
221
|
-
ok: boolean;
|
|
222
|
-
phase: "failed" | "prepared" | "unit-written" | "committed" | "support-pending" | "rolled-back";
|
|
223
|
-
}>;
|
|
224
|
-
}
|
|
225
|
-
//# sourceMappingURL=unit-transaction.d.ts.map
|