@lmzhen/dsh-evolution-merge 0.30.18 → 0.30.19
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/README.md +21 -4
- package/data/minhash_params.json +1063 -0
- package/lib/index.js +7313 -3272
- package/lib/types/adapters/channel.d.ts +1 -0
- package/lib/types/adapters/channel.js +15 -1
- package/lib/types/adapters/engine-screen.d.ts +1 -1
- package/lib/types/adapters/engine-screen.js +5 -2
- package/lib/types/adapters/model-runner.d.ts +0 -5
- package/lib/types/adapters/model-runner.js +8 -2
- package/lib/types/adapters/model.js +2 -1
- package/lib/types/adapters/select.js +12 -8
- package/lib/types/approve-command.d.ts +12 -1
- package/lib/types/approve-command.js +39 -6
- package/lib/types/authoring-flow.d.ts +16 -0
- package/lib/types/authoring-flow.js +37 -13
- package/lib/types/channel-port.d.ts +3 -1
- package/lib/types/channel-port.js +8 -3
- package/lib/types/command-defs.d.ts +5 -0
- package/lib/types/command-defs.js +33 -0
- package/lib/types/command-surface.d.ts +1 -1
- package/lib/types/command-surface.js +10 -43
- package/lib/types/commands.d.ts +3 -4
- package/lib/types/commands.js +33 -72
- package/lib/types/commit-assembly.d.ts +14 -1
- package/lib/types/commit-assembly.js +65 -9
- package/lib/types/commit-execute.d.ts +7 -1
- package/lib/types/commit-execute.js +54 -22
- package/lib/types/commit-plan.d.ts +7 -1
- package/lib/types/commit-plan.js +4 -0
- package/lib/types/commit-receipt.d.ts +3 -0
- package/lib/types/contracts.d.ts +43 -0
- package/lib/types/doctor.d.ts +11 -1
- package/lib/types/doctor.js +81 -27
- package/lib/types/domain/authoring-manifest.d.ts +26 -0
- package/lib/types/domain/authoring-manifest.js +43 -0
- package/lib/types/domain/engine-criteria.d.ts +10 -0
- package/lib/types/domain/engine-criteria.js +11 -0
- package/lib/types/domain/engine-input.d.ts +10 -0
- package/lib/types/domain/engine-input.js +26 -0
- package/lib/types/domain/errors.d.ts +15 -1
- package/lib/types/domain/errors.js +23 -4
- package/lib/types/domain/evidence-hash.d.ts +3 -0
- package/lib/types/domain/evidence-hash.js +14 -0
- package/lib/types/domain/failure-route.d.ts +14 -0
- package/lib/types/domain/failure-route.js +12 -0
- package/lib/types/domain/live-facts.d.ts +31 -0
- package/lib/types/domain/live-facts.js +54 -0
- package/lib/types/domain/merge-limits.d.ts +18 -0
- package/lib/types/domain/merge-limits.js +22 -0
- package/lib/types/domain/merge-report.d.ts +41 -0
- package/lib/types/domain/merge-report.js +2 -0
- package/lib/types/domain/merge-snapshot.d.ts +99 -0
- package/lib/types/domain/merge-snapshot.js +82 -0
- package/lib/types/domain/pair-ledger.d.ts +34 -0
- package/lib/types/domain/pair-ledger.js +96 -0
- package/lib/types/domain/pre-1b-backup.d.ts +43 -0
- package/lib/types/domain/pre-1b-backup.js +140 -0
- package/lib/types/domain/provider-key.d.ts +2 -0
- package/lib/types/domain/provider-key.js +11 -0
- package/lib/types/domain/read-probe.d.ts +5 -0
- package/lib/types/domain/read-probe.js +11 -0
- package/lib/types/domain/reconcile.d.ts +47 -0
- package/lib/types/domain/reconcile.js +178 -0
- package/lib/types/domain/resolve-pair.d.ts +2 -9
- package/lib/types/domain/resolve-pair.js +2 -15
- package/lib/types/domain/row-v4.d.ts +148 -0
- package/lib/types/domain/row-v4.js +159 -0
- package/lib/types/domain/run-coordinator.d.ts +51 -0
- package/lib/types/domain/run-coordinator.js +45 -0
- package/lib/types/domain/schema4.d.ts +53 -0
- package/lib/types/domain/schema4.js +129 -0
- package/lib/types/domain/selection-policy.d.ts +14 -0
- package/lib/types/domain/selection-policy.js +6 -0
- package/lib/types/domain/skipped-expiry.d.ts +5 -0
- package/lib/types/domain/skipped-expiry.js +16 -0
- package/lib/types/domain/stage-aggregate.d.ts +96 -0
- package/lib/types/domain/stage-aggregate.js +293 -0
- package/lib/types/domain/staging-index.d.ts +1 -0
- package/lib/types/domain/state-bootstrap.d.ts +43 -0
- package/lib/types/domain/state-bootstrap.js +267 -0
- package/lib/types/domain/state-v3.d.ts +3 -14
- package/lib/types/domain/state-v3.js +3 -79
- package/lib/types/domain/undo-journal.d.ts +19 -0
- package/lib/types/domain/undo-journal.js +20 -0
- package/lib/types/domain/undo-receipt.d.ts +18 -0
- package/lib/types/domain/undo-receipt.js +22 -0
- package/lib/types/domain/validation-plan.d.ts +65 -0
- package/lib/types/domain/validation-plan.js +49 -0
- package/lib/types/facts.d.ts +3 -1
- package/lib/types/facts.js +13 -16
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +181 -68
- package/lib/types/merge-command.d.ts +3 -1
- package/lib/types/merge-command.js +10 -6
- package/lib/types/merge-routes.d.ts +10 -5
- package/lib/types/merge-routes.js +72 -7
- package/lib/types/merge-tool.d.ts +1 -1
- package/lib/types/merge-tool.js +2 -2
- package/lib/types/metrics.js +1 -1
- package/lib/types/new-child-authoring.d.ts +2 -0
- package/lib/types/new-child-authoring.js +57 -10
- package/lib/types/params.d.ts +2 -4
- package/lib/types/params.js +13 -0
- package/lib/types/pending-actions.d.ts +2 -2
- package/lib/types/pending-actions.js +4 -4
- package/lib/types/prompts.d.ts +2 -4
- package/lib/types/prompts.js +21 -8
- package/lib/types/read-commands.d.ts +3 -3
- package/lib/types/read-commands.js +19 -28
- package/lib/types/recovery-coordinator.d.ts +34 -0
- package/lib/types/recovery-coordinator.js +84 -0
- package/lib/types/recovery-projection.d.ts +31 -0
- package/lib/types/recovery-projection.js +96 -0
- package/lib/types/resume-command.d.ts +5 -1
- package/lib/types/resume-command.js +46 -13
- package/lib/types/revision.d.ts +17 -0
- package/lib/types/revision.js +39 -3
- package/lib/types/round2-outcome.d.ts +2 -1
- package/lib/types/round2-outcome.js +59 -11
- package/lib/types/run-shell.d.ts +16 -2
- package/lib/types/run-shell.js +49 -5
- package/lib/types/runtime.d.ts +0 -5
- package/lib/types/runtime.js +274 -89
- package/lib/types/scan-command.d.ts +1 -0
- package/lib/types/scan-command.js +2 -0
- package/lib/types/scan-ports.d.ts +18 -0
- package/lib/types/scan-ports.js +49 -23
- package/lib/types/scan-run.d.ts +17 -0
- package/lib/types/scan-run.js +143 -48
- package/lib/types/stage-tool-registry.d.ts +7 -0
- package/lib/types/stage-tool-registry.js +12 -1
- package/lib/types/state.d.ts +5 -5
- package/lib/types/state.js +22 -69
- package/lib/types/status.d.ts +6 -1
- package/lib/types/status.js +47 -0
- package/lib/types/surface/body.d.ts +4 -0
- package/lib/types/surface/body.js +16 -0
- package/lib/types/surface/merge-view.d.ts +14 -0
- package/lib/types/surface/merge-view.js +126 -0
- package/lib/types/undo-operation.d.ts +24 -0
- package/lib/types/undo-operation.js +135 -0
- package/lib/types/wire.d.ts +22 -3
- package/package.json +6 -4
package/lib/types/run-shell.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { writeMergeReport } from "./report.js";
|
|
2
|
+
import { writeRunMeta } from "./domain/run-coordinator.js";
|
|
2
3
|
function emptyDraft(reason) {
|
|
3
4
|
return {
|
|
4
5
|
stopReason: 'failed',
|
|
@@ -8,23 +9,45 @@ function emptyDraft(reason) {
|
|
|
8
9
|
notes: [reason],
|
|
9
10
|
};
|
|
10
11
|
}
|
|
12
|
+
export async function retryMergeReport(io, home, report) {
|
|
13
|
+
return await writeMergeReport(io, home, report);
|
|
14
|
+
}
|
|
11
15
|
export async function withMergeRun(options) {
|
|
12
16
|
const handle = await options.registry.begin('merge', {
|
|
13
17
|
command: options.command,
|
|
14
|
-
mergeStatus: 'running',
|
|
15
18
|
...(options.total === undefined ? {} : { total: options.total }),
|
|
19
|
+
...(options.parentRunId === undefined ? {} : { parentRunId: options.parentRunId }),
|
|
16
20
|
});
|
|
17
21
|
const startedAt = handle.startedAt;
|
|
18
22
|
const stage = (name, progress) => options.registry.stage(handle.id, name, progress);
|
|
19
23
|
await stage('screening', options.total === undefined ? undefined : { done: 0, total: options.total });
|
|
24
|
+
await writeRunMeta(options.io, options.home, { version: 1, runId: handle.id, ...(options.parentRunId === undefined ? {} : { parentRunId: options.parentRunId }), ...(options.pairKey === undefined ? {} : { pairKey: options.pairKey }), pairCount: options.pairCount ?? (options.pairKey === undefined ? 0 : 1), phase: 'running', approval: options.approval.mergeApproval ? 'pending' : 'approved', createdAt: new Date(startedAt).toISOString(), updatedAt: new Date(options.now()).toISOString() });
|
|
20
25
|
const finish = async () => {
|
|
21
26
|
let draft;
|
|
27
|
+
const runController = new AbortController();
|
|
28
|
+
const onAbort = () => { runController.abort(); };
|
|
29
|
+
handle.signal.addEventListener('abort', onAbort, { once: true });
|
|
30
|
+
let timer;
|
|
31
|
+
const timeoutMinutes = options.timeoutMinutes;
|
|
32
|
+
const timeout = timeoutMinutes === undefined || timeoutMinutes <= 0 ? undefined : new Promise((_, reject) => {
|
|
33
|
+
timer = setTimeout(() => {
|
|
34
|
+
runController.abort();
|
|
35
|
+
reject(new Error('merge run timed out after ' + String(timeoutMinutes) + ' minutes'));
|
|
36
|
+
}, timeoutMinutes * 60_000);
|
|
37
|
+
});
|
|
22
38
|
try {
|
|
23
|
-
draft =
|
|
39
|
+
draft = timeout === undefined
|
|
40
|
+
? await options.body({ runId: handle.id, startedAt, signal: runController.signal, stage })
|
|
41
|
+
: await Promise.race([options.body({ runId: handle.id, startedAt, signal: runController.signal, stage }), timeout]);
|
|
24
42
|
}
|
|
25
43
|
catch (error) {
|
|
26
44
|
draft = emptyDraft('run body failed: ' + (error instanceof Error ? error.message : String(error)));
|
|
27
45
|
}
|
|
46
|
+
finally {
|
|
47
|
+
if (timer !== undefined)
|
|
48
|
+
clearTimeout(timer);
|
|
49
|
+
handle.signal.removeEventListener('abort', onAbort);
|
|
50
|
+
}
|
|
28
51
|
const report = {
|
|
29
52
|
schemaVersion: 2,
|
|
30
53
|
runId: handle.id,
|
|
@@ -39,6 +62,13 @@ export async function withMergeRun(options) {
|
|
|
39
62
|
totals: draft.totals,
|
|
40
63
|
notes: draft.notes,
|
|
41
64
|
...(draft.remaining === undefined ? {} : { remaining: draft.remaining }),
|
|
65
|
+
...(draft.reportOnly === undefined ? {} : { reportOnly: draft.reportOnly }),
|
|
66
|
+
...(draft.validationFailures === undefined ? {} : { validationFailures: draft.validationFailures }),
|
|
67
|
+
...(draft.archived === undefined ? {} : { archived: draft.archived }),
|
|
68
|
+
...(draft.commit === undefined ? {} : { commit: draft.commit }),
|
|
69
|
+
...(draft.usage === undefined ? {} : { usage: draft.usage }),
|
|
70
|
+
...(draft.timing === undefined ? {} : { timing: draft.timing }),
|
|
71
|
+
...(draft.criteria === undefined ? {} : { criteria: draft.criteria }),
|
|
42
72
|
};
|
|
43
73
|
let reportPath;
|
|
44
74
|
try {
|
|
@@ -48,14 +78,28 @@ export async function withMergeRun(options) {
|
|
|
48
78
|
await options.registry.settle(handle.id, { state: 'failed', failure: 'report write failed: ' + (error instanceof Error ? error.message : String(error)) });
|
|
49
79
|
return { ok: false, runId: handle.id, message: 'report write failed' };
|
|
50
80
|
}
|
|
81
|
+
try {
|
|
82
|
+
await draft.finalize?.();
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
await options.registry.settle(handle.id, { state: 'failed', resultRef: reportPath, failure: 'post-report finalize failed: ' + (error instanceof Error ? error.message : String(error)) });
|
|
86
|
+
return { ok: false, runId: handle.id, message: 'post-report finalize failed', reportPath };
|
|
87
|
+
}
|
|
51
88
|
const runState = report.stopReason === 'completed'
|
|
52
89
|
? 'succeeded'
|
|
53
90
|
: report.stopReason === 'cancelled'
|
|
54
91
|
? 'cancelled'
|
|
55
92
|
: 'failed';
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
93
|
+
await options.registry.settle(handle.id, { state: runState, resultRef: reportPath, ...(runState === 'failed' ? { failure: 'merge ' + report.stopReason } : {}) });
|
|
94
|
+
// FR-RUN-04: awaiting-approval is a fact about THIS run, not about the approval mode.
|
|
95
|
+
// Only a completed scan/pair that actually left pending rows is waiting for a human;
|
|
96
|
+
// a failed/cancelled run (or one that produced nothing to approve) settled long ago,
|
|
97
|
+
// and approve/resume are themselves the answer to a pending window.
|
|
98
|
+
const awaiting = options.approval.mergeApproval
|
|
99
|
+
&& (options.command === 'scan' || options.command === 'pair')
|
|
100
|
+
&& report.stopReason === 'completed'
|
|
101
|
+
&& report.totals.pending > 0;
|
|
102
|
+
await writeRunMeta(options.io, options.home, { version: 1, runId: handle.id, ...(options.parentRunId === undefined ? {} : { parentRunId: options.parentRunId }), ...(options.pairKey === undefined ? {} : { pairKey: options.pairKey }), pairCount: options.pairCount ?? (options.pairKey === undefined ? 0 : 1), phase: awaiting ? 'awaiting-approval' : 'settled', approval: awaiting ? 'pending' : 'approved', stopReason: report.stopReason, reportRef: reportPath, createdAt: new Date(startedAt).toISOString(), updatedAt: new Date(options.now()).toISOString() });
|
|
59
103
|
if (report.stopReason === 'completed')
|
|
60
104
|
return { ok: true, runId: handle.id, reportPath, report };
|
|
61
105
|
return { ok: false, runId: handle.id, message: 'merge ' + report.stopReason, reportPath };
|
package/lib/types/runtime.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The merge command runtime: cards -> screening -> channel ports -> scan/approve.
|
|
3
|
-
* Plugin wiring supplies the channel, model and library; this module keeps the orchestration
|
|
4
|
-
* out of apply() and makes the mutating verbs testable with fakes.
|
|
5
|
-
*/
|
|
6
1
|
import { SkillLibrary, type EvolutionIoLike, type UnitTransaction } from '@lmzhen/dsh-evolution-core';
|
|
7
2
|
import { type MergeCandidate } from './contracts.ts';
|
|
8
3
|
import type { MergeParams } from './params.ts';
|