@lmzhen/dsh-evolution-merge 0.46.0 → 0.48.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/index.js +248 -1224
- package/lib/types/adapters/engine-screen.d.ts +0 -3
- package/lib/types/authoring-flow.d.ts +5 -0
- package/lib/types/authoring-flow.js +17 -10
- package/lib/types/commit-execute.js +1 -22
- package/lib/types/contracts.d.ts +0 -1
- package/lib/types/contracts.js +0 -1
- package/lib/types/doctor.d.ts +0 -1
- package/lib/types/doctor.js +2 -31
- package/lib/types/domain/consistency.d.ts +0 -1
- package/lib/types/domain/consistency.js +2 -11
- package/lib/types/domain/merge-limits.d.ts +0 -10
- package/lib/types/domain/merge-limits.js +0 -3
- package/lib/types/domain/merge-snapshot.js +4 -6
- package/lib/types/domain/pair-ledger.d.ts +0 -1
- package/lib/types/domain/row-v3.d.ts +0 -45
- package/lib/types/domain/row-v3.js +0 -68
- package/lib/types/domain/row.d.ts +2 -84
- package/lib/types/domain/row.js +1 -110
- package/lib/types/domain/run-coordinator.d.ts +0 -24
- package/lib/types/domain/run-coordinator.js +0 -1
- package/lib/types/domain/stage-aggregate.d.ts +0 -42
- package/lib/types/domain/stage-aggregate.js +1 -116
- package/lib/types/domain/state.d.ts +1 -53
- package/lib/types/domain/state.js +0 -55
- package/lib/types/domain/undo-journal.d.ts +4 -4
- package/lib/types/domain/undo-journal.js +5 -7
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.js +0 -6
- package/lib/types/merge-routes.d.ts +5 -21
- package/lib/types/merge-routes.js +53 -93
- package/lib/types/new-child-authoring.js +4 -10
- package/lib/types/prompts.d.ts +0 -1
- package/lib/types/prompts.js +0 -1
- package/lib/types/read-commands.d.ts +0 -1
- package/lib/types/read-commands.js +0 -4
- package/lib/types/recovery-projection.js +0 -3
- package/lib/types/round2-outcome.js +15 -37
- package/lib/types/scan-run.js +0 -3
- package/lib/types/skipped.d.ts +1 -2
- package/lib/types/skipped.js +0 -8
- package/lib/types/staging.d.ts +0 -2
- package/lib/types/staging.js +0 -9
- package/lib/types/state.d.ts +1 -39
- package/lib/types/state.js +2 -78
- package/lib/types/surface/merge-view.d.ts +1 -2
- package/lib/types/surface/merge-view.js +1 -2
- package/lib/types/undo-operation.js +0 -9
- package/lib/types/unit-protocol.d.ts +6 -0
- package/lib/types/unit-protocol.js +72 -102
- package/package.json +4 -4
- package/lib/types/commit-recovery.d.ts +0 -14
- package/lib/types/commit-recovery.js +0 -96
- package/lib/types/coordinator.d.ts +0 -77
- package/lib/types/coordinator.js +0 -137
- package/lib/types/domain/commit-journal-store.d.ts +0 -6
- package/lib/types/domain/commit-journal-store.js +0 -26
- package/lib/types/domain/commit-journal.d.ts +0 -16
- package/lib/types/domain/commit-journal.js +0 -26
- package/lib/types/domain/indexes.d.ts +0 -21
- package/lib/types/domain/indexes.js +0 -15
- package/lib/types/domain/merge-report.d.ts +0 -41
- package/lib/types/domain/merge-report.js +0 -2
- package/lib/types/domain/pair-index-store.d.ts +0 -6
- package/lib/types/domain/pair-index-store.js +0 -25
- package/lib/types/domain/pair-index.d.ts +0 -9
- package/lib/types/domain/pair-index.js +0 -28
- package/lib/types/domain/resolve-pair.d.ts +0 -4
- package/lib/types/domain/resolve-pair.js +0 -4
- package/lib/types/domain/row-tx.d.ts +0 -27
- package/lib/types/domain/row-tx.js +0 -31
- package/lib/types/domain/run-record.d.ts +0 -45
- package/lib/types/domain/run-record.js +0 -24
- package/lib/types/domain/state-v3.d.ts +0 -4
- package/lib/types/domain/state-v3.js +0 -4
- package/lib/types/facts.d.ts +0 -26
- package/lib/types/facts.js +0 -65
- package/lib/types/metrics.d.ts +0 -16
- package/lib/types/metrics.js +0 -27
- package/lib/types/wire-projection.d.ts +0 -36
- package/lib/types/wire-projection.js +0 -77
package/lib/types/metrics.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { countsOf } from "./facts.js";
|
|
2
|
-
export const MERGE_METRIC_NAMES = [
|
|
3
|
-
'merge_queue_depth',
|
|
4
|
-
'merge_run_total',
|
|
5
|
-
'merge_run_duration_ms',
|
|
6
|
-
'merge_lock_wait_ms',
|
|
7
|
-
'merge_claim_conflict_total',
|
|
8
|
-
'merge_recovery_fail_total',
|
|
9
|
-
];
|
|
10
|
-
export function buildMergeMetrics(rows, runs, counters = {}) {
|
|
11
|
-
const counts = countsOf(rows);
|
|
12
|
-
const samples = [];
|
|
13
|
-
for (const queue of ['verify', 'pending', 'fuse', 'skipped'])
|
|
14
|
-
samples.push({ name: 'merge_queue_depth', labels: { queue, kind: 'active' }, value: counts.active[queue] });
|
|
15
|
-
samples.push({ name: 'merge_queue_depth', labels: { queue: 'pending', kind: 'expired' }, value: counts.expired });
|
|
16
|
-
for (const run of runs) {
|
|
17
|
-
const state = run.state;
|
|
18
|
-
samples.push({ name: 'merge_run_total', labels: { state }, value: 1 });
|
|
19
|
-
if (run.endedAt !== undefined)
|
|
20
|
-
samples.push({ name: 'merge_run_duration_ms', labels: { state }, value: Math.max(0, run.endedAt - run.startedAt) });
|
|
21
|
-
}
|
|
22
|
-
samples.push({ name: 'merge_lock_wait_ms', labels: {}, value: counters.lockWaitMs ?? 0 });
|
|
23
|
-
samples.push({ name: 'merge_claim_conflict_total', labels: {}, value: counters.claimConflict ?? 0 });
|
|
24
|
-
samples.push({ name: 'merge_recovery_fail_total', labels: {}, value: counters.recoveryFail ?? 0 });
|
|
25
|
-
return samples;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=metrics.js.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/** G5-4 wire projections from merge rows to the frozen envelopes. */
|
|
2
|
-
import type { RunRecord } from '@lmzhen/dsh-evolution-core';
|
|
3
|
-
import type { MergeRow } from './contracts.ts';
|
|
4
|
-
import type { BodyView, DoctorView, HistoryView, MergeCounts, QueueId, QueuePage, RowFact, RunView, RunsView } from './wire.ts';
|
|
5
|
-
/** Host-owned row actions; client only renders/copies them. */
|
|
6
|
-
export declare function actionRefs(row: MergeRow): RowFact['actions'];
|
|
7
|
-
export declare function toRowFact(row: MergeRow, actions?: RowFact['actions']): RowFact;
|
|
8
|
-
export declare function toQueuePage(rows: readonly MergeRow[], queue: QueueId, expiredOnly: boolean, readAt: number, limit?: number): QueuePage;
|
|
9
|
-
export declare function toRunsView(runs: readonly RunRecord[], readAt: number): RunsView;
|
|
10
|
-
export interface DoctorSourceFact {
|
|
11
|
-
readonly key: string;
|
|
12
|
-
readonly status: 'ok' | 'warn' | 'fail' | 'unknown';
|
|
13
|
-
readonly count?: number;
|
|
14
|
-
readonly detail?: string;
|
|
15
|
-
}
|
|
16
|
-
export declare function toDoctorView(input: {
|
|
17
|
-
readonly readAt: number;
|
|
18
|
-
readonly counts: MergeCounts;
|
|
19
|
-
readonly latestRun?: RunView;
|
|
20
|
-
readonly approval: {
|
|
21
|
-
mergeApproval: boolean;
|
|
22
|
-
writeApproval?: boolean;
|
|
23
|
-
};
|
|
24
|
-
readonly staging: DoctorView['staging'];
|
|
25
|
-
readonly rows: readonly DoctorSourceFact[];
|
|
26
|
-
}): DoctorView;
|
|
27
|
-
export declare function toBodyView(name: string, side: 'live' | 'archive', text: string, readAt: number): BodyView;
|
|
28
|
-
export declare function toHistoryView(items: readonly {
|
|
29
|
-
name: string;
|
|
30
|
-
kind: 'merged' | 'deleted' | 'split' | 'other';
|
|
31
|
-
reason: string;
|
|
32
|
-
lastVersion: number;
|
|
33
|
-
archivedAt: string | number | null;
|
|
34
|
-
sourceRunId?: string;
|
|
35
|
-
}[], readAt: number): HistoryView;
|
|
36
|
-
//# sourceMappingURL=wire-projection.d.ts.map
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { countsOf, toRunView } from "./facts.js";
|
|
2
|
-
const queueOf = (row) => row.state === 'approved' ? 'fuse' : row.queue;
|
|
3
|
-
const expiredOf = (row) => row.expired !== undefined;
|
|
4
|
-
/** Host-owned row actions; client only renders/copies them. */
|
|
5
|
-
export function actionRefs(row) {
|
|
6
|
-
const base = '/evolution merge ';
|
|
7
|
-
const disabled = row.expired === undefined ? undefined : 'expired';
|
|
8
|
-
const action = (id, confirm = false, enabled = true) => ({ id, command: base + id + ' ' + row.id, confirm, enabled, ...(enabled ? {} : { disabledReason: disabled ?? 'invalid' }) });
|
|
9
|
-
if (row.state === 'pending' && row.expired !== undefined)
|
|
10
|
-
return [{ id: 'discard', command: base + 'discard ' + row.id, confirm: true, enabled: true }, { id: 'pair', command: base + 'pair ' + row.a + ' ' + row.b, confirm: true, enabled: true }];
|
|
11
|
-
if (row.state === 'pending')
|
|
12
|
-
return [action('approve'), action('reject', true), action('discard', true)];
|
|
13
|
-
if (row.state === 'approved' || row.state === 'fuse') {
|
|
14
|
-
if (row.failure !== undefined && row.failure.retryable === false)
|
|
15
|
-
return [{ id: 'pair', command: base + 'pair ' + row.a + ' ' + row.b, confirm: true, enabled: true }, action('discard', true)];
|
|
16
|
-
return [{ id: 'retry-resume', command: base + 'resume --retry ' + row.id, confirm: true, enabled: true }, action('discard', true), action('status')];
|
|
17
|
-
}
|
|
18
|
-
if (row.state === 'skipped')
|
|
19
|
-
return [action('restore', true)];
|
|
20
|
-
if (row.state === 'verify')
|
|
21
|
-
return [{ id: 'retry-candidates', command: base + 'candidates --retry ' + row.id, confirm: false, enabled: true }];
|
|
22
|
-
return [action('pair')];
|
|
23
|
-
}
|
|
24
|
-
export function toRowFact(row, actions = actionRefs(row)) {
|
|
25
|
-
return {
|
|
26
|
-
id: row.id,
|
|
27
|
-
state: row.state,
|
|
28
|
-
queue: queueOf(row),
|
|
29
|
-
...(row.state === 'verify' ? { verifySubState: 'queued' } : {}),
|
|
30
|
-
a: row.a,
|
|
31
|
-
b: row.b,
|
|
32
|
-
...(row.target === undefined ? {} : { target: { requested: row.target.requested, ...(row.target.actual === undefined ? {} : { actual: row.target.actual }), ...(row.target.created === undefined ? {} : { created: row.target.created }) } }),
|
|
33
|
-
...(row.state === 'pending' ? { summary: { a: null, b: null, rationale: row.decision?.rationale ?? null } } : {}),
|
|
34
|
-
...(row.reason === undefined ? {} : { reason: row.reason }),
|
|
35
|
-
...(row.state === 'skipped' ? { origin: row.origin ?? 'system' } : {}),
|
|
36
|
-
...(row.failure === undefined ? {} : { failure: { stage: row.failure.stage === 'screening' ? 'screening' : row.failure.stage === 'decide' ? 'decide' : row.failure.stage === 'author' ? 'author' : row.failure.stage === 'validate' ? 'validate' : 'commit', code: row.failure.code, retryable: row.failure.retryable, retryFrom: row.failure.retryFrom } }),
|
|
37
|
-
...(row.stagingRef === undefined ? {} : { staging: { state: 'kept', ...(row.stagingExpiresAt === undefined ? {} : { expiresAt: row.stagingExpiresAt }) } }),
|
|
38
|
-
...(row.expired === undefined ? {} : { expired: { kind: row.expired, at: Date.parse(row.updatedAt) } }),
|
|
39
|
-
...(row.attempts === undefined ? {} : { attempts: row.attempts }),
|
|
40
|
-
...(row.decision?.confidence === undefined ? {} : { confidence: row.decision.confidence }),
|
|
41
|
-
...(row.state === 'skipped' && row.stagingExpiresAt !== undefined ? { expiresAt: row.stagingExpiresAt } : {}),
|
|
42
|
-
createdAt: Date.parse(row.createdAt),
|
|
43
|
-
updatedAt: Date.parse(row.updatedAt),
|
|
44
|
-
actions,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
export function toQueuePage(rows, queue, expiredOnly, readAt, limit = 50) {
|
|
48
|
-
const filtered = rows.filter(row => queueOf(row) === queue && (expiredOnly ? expiredOf(row) : !expiredOf(row)));
|
|
49
|
-
const page = filtered.slice(0, Math.max(0, Math.min(200, limit)));
|
|
50
|
-
const counts = countsOf(rows);
|
|
51
|
-
return { wireVersion: 1, readAt, queue, expiredOnly, counts, rows: page.map(row => toRowFact(row)), ...(filtered.length > page.length ? { nextCursor: String(page.length) } : {}), notes: [] };
|
|
52
|
-
}
|
|
53
|
-
export function toRunsView(runs, readAt) {
|
|
54
|
-
const ordered = [...runs].sort((a, b) => b.startedAt - a.startedAt).slice(0, 50);
|
|
55
|
-
return { wireVersion: 1, readAt, runs: ordered.map(run => toRunView(run, readAt)) };
|
|
56
|
-
}
|
|
57
|
-
export function toDoctorView(input) {
|
|
58
|
-
return {
|
|
59
|
-
wireVersion: 1,
|
|
60
|
-
readAt: input.readAt,
|
|
61
|
-
counts: input.counts,
|
|
62
|
-
...(input.latestRun === undefined ? {} : { latestRun: input.latestRun }),
|
|
63
|
-
staging: input.staging,
|
|
64
|
-
approval: input.approval,
|
|
65
|
-
rows: input.rows.map(row => ({ key: row.key, status: row.status, ...(row.count === undefined ? {} : { count: row.count }), ...(row.detail === undefined ? {} : { detail: row.detail }) })),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
export function toBodyView(name, side, text, readAt) {
|
|
69
|
-
return { wireVersion: 1, readAt, name, side, text, markdown: true, truncated: false, totalBytes: Buffer.byteLength(text, 'utf8') };
|
|
70
|
-
}
|
|
71
|
-
export function toHistoryView(items, readAt) {
|
|
72
|
-
return { wireVersion: 1, readAt, items: items.map(item => {
|
|
73
|
-
const parsed = item.archivedAt === null ? null : typeof item.archivedAt === 'number' ? item.archivedAt : Date.parse(item.archivedAt);
|
|
74
|
-
return { name: item.name, kind: item.kind, reason: item.reason, lastVersion: item.lastVersion, archivedAt: parsed === null || Number.isFinite(parsed) ? parsed : null, ...(item.sourceRunId === undefined ? {} : { sourceRunId: item.sourceRunId }) };
|
|
75
|
-
}) };
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=wire-projection.js.map
|