@ricsam/r5d-worker 0.0.137 → 0.0.139
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 +4 -94
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/main.mjs +46 -7543
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/personal/action-scheduler.mjs +31 -0
- package/dist/mjs/personal/client.mjs +215 -0
- package/dist/mjs/personal/runtime.mjs +359 -0
- package/dist/mjs/personal/tcp.mjs +217 -0
- package/dist/mjs/runtime/adapter.mjs +42 -0
- package/dist/mjs/runtime/client.mjs +95 -0
- package/dist/mjs/runtime/daemon.mjs +131 -0
- package/dist/mjs/runtime/executor.mjs +436 -0
- package/dist/mjs/runtime/index.mjs +15 -0
- package/dist/mjs/runtime/protocol.mjs +139 -0
- package/dist/mjs/runtime/pty-host.mjs +156 -0
- package/dist/mjs/runtime/pty.mjs +127 -0
- package/dist/mjs/runtime/releases/artifacts.mjs +201 -0
- package/dist/mjs/runtime/releases/grants.mjs +93 -0
- package/dist/mjs/runtime/releases/main.mjs +101 -0
- package/dist/mjs/runtime/releases/manager.mjs +541 -0
- package/dist/mjs/runtime/releases/process.mjs +88 -0
- package/dist/mjs/runtime/releases/retirement.mjs +18 -0
- package/dist/mjs/runtime/releases/rpc-client.mjs +184 -0
- package/dist/mjs/runtime/releases/rpc-main.mjs +213 -0
- package/dist/mjs/runtime/releases/rpc-protocol.mjs +103 -0
- package/dist/mjs/runtime/storage.mjs +156 -0
- package/dist/mjs/runtime/workspace/artifacts.mjs +121 -0
- package/dist/mjs/runtime/workspace/authority.mjs +1355 -0
- package/dist/mjs/runtime/workspace/contracts.mjs +60 -0
- package/dist/mjs/runtime/workspace/file-write.mjs +23 -0
- package/dist/mjs/runtime/workspace/files.mjs +308 -0
- package/dist/mjs/runtime/workspace/http-body.mjs +45 -0
- package/dist/mjs/runtime/workspace/storage-client.mjs +59 -0
- package/dist/mjs/runtime/workspace/storage-wire.mjs +53 -0
- package/dist/types/main.d.ts +0 -1167
- package/dist/types/personal/action-scheduler.d.ts +23 -0
- package/dist/types/personal/client.d.ts +14 -0
- package/dist/types/personal/runtime.d.ts +121 -0
- package/dist/types/personal/tcp.d.ts +14 -0
- package/dist/types/runtime/client.d.ts +3 -1
- package/dist/types/runtime/executor.d.ts +6 -1
- package/dist/types/runtime/protocol.d.ts +176 -4
- package/dist/types/runtime/pty.d.ts +1 -0
- package/dist/types/runtime/releases/artifacts.d.ts +51 -0
- package/dist/types/runtime/releases/grants.d.ts +16 -0
- package/dist/types/runtime/releases/manager.d.ts +145 -0
- package/dist/types/runtime/releases/process.d.ts +14 -0
- package/dist/types/runtime/releases/retirement.d.ts +15 -0
- package/dist/types/runtime/releases/rpc-client.d.ts +52 -0
- package/dist/types/runtime/releases/rpc-main.d.ts +10 -0
- package/dist/types/runtime/releases/rpc-protocol.d.ts +1139 -0
- package/dist/types/runtime/workspace/artifacts.d.ts +30 -0
- package/dist/types/runtime/workspace/authority.d.ts +338 -0
- package/dist/types/runtime/workspace/contracts.d.ts +86 -0
- package/dist/types/runtime/workspace/file-write.d.ts +14 -0
- package/dist/types/runtime/workspace/files.d.ts +21 -0
- package/dist/types/runtime/workspace/http-body.d.ts +9 -0
- package/dist/types/runtime/workspace/storage-client.d.ts +23 -0
- package/dist/types/runtime/workspace/storage-wire.d.ts +138 -0
- package/package.json +8 -6
- package/dist/cjs/atomic-rename.cjs +0 -303
- package/dist/cjs/browser-upload.cjs +0 -73
- package/dist/cjs/cli-update.cjs +0 -108
- package/dist/cjs/command-launcher.cjs +0 -423
- package/dist/cjs/control-command-policy.cjs +0 -177
- package/dist/cjs/git-blob-hash.cjs +0 -41
- package/dist/cjs/git-identity.cjs +0 -39
- package/dist/cjs/git-process-environment.cjs +0 -133
- package/dist/cjs/inline-output.cjs +0 -62
- package/dist/cjs/main.cjs +0 -7517
- package/dist/cjs/managed-paths.cjs +0 -215
- package/dist/cjs/plan-lint.cjs +0 -165
- package/dist/cjs/plan-parser.cjs +0 -127
- package/dist/cjs/plan-paths.cjs +0 -53
- package/dist/cjs/port-forward-client.cjs +0 -206
- package/dist/cjs/process-tree.cjs +0 -117
- package/dist/cjs/project-checkout-garbage.cjs +0 -219
- package/dist/cjs/project-mirror-fetch-policy.cjs +0 -82
- package/dist/cjs/project-mirror-refs-token.cjs +0 -85
- package/dist/cjs/project-workspace-state.cjs +0 -972
- package/dist/cjs/project-worktrees.cjs +0 -1713
- package/dist/cjs/pty-output-coalescer.cjs +0 -87
- package/dist/cjs/recovery-journal-protocol.cjs +0 -56
- package/dist/cjs/recovery-journal-runtime.cjs +0 -133
- package/dist/cjs/recovery-journal-thread.cjs +0 -9
- package/dist/cjs/recovery-journal.cjs +0 -742
- package/dist/cjs/recovery-output-window.cjs +0 -77
- package/dist/cjs/recovery-protocol.cjs +0 -31
- package/dist/cjs/recovery-store.cjs +0 -252
- package/dist/cjs/registry-auth.cjs +0 -310
- package/dist/cjs/repository-transition-policy.cjs +0 -49
- package/dist/cjs/runtime-version.cjs +0 -88
- package/dist/cjs/session-file-mutations.cjs +0 -61
- package/dist/cjs/supervisor.cjs +0 -147
- package/dist/cjs/three-way-merge.cjs +0 -346
- package/dist/cjs/working-tree-mirror.cjs +0 -1872
- package/dist/cjs/workspace-automatic-sync-policy.cjs +0 -79
- package/dist/cjs/workspace-branch-incarnation-policy.cjs +0 -37
- package/dist/cjs/workspace-command-sync-policy.cjs +0 -112
- package/dist/cjs/workspace-command-targets.cjs +0 -63
- package/dist/cjs/workspace-filesystem-executor-thread.cjs +0 -36
- package/dist/cjs/workspace-filesystem-executor.cjs +0 -327
- package/dist/cjs/workspace-filesystem-job-types.cjs +0 -144
- package/dist/cjs/workspace-filesystem-jobs.cjs +0 -59
- package/dist/cjs/workspace-git-sync.cjs +0 -3595
- package/dist/cjs/workspace-hydration-ledger.cjs +0 -83
- package/dist/cjs/workspace-hydration-merge.cjs +0 -448
- package/dist/cjs/workspace-hydration-recovery-state.cjs +0 -53
- package/dist/cjs/workspace-incident-state.cjs +0 -37
- package/dist/cjs/workspace-merge-projection.cjs +0 -628
- package/dist/cjs/workspace-mount-boundary.cjs +0 -71
- package/dist/cjs/workspace-mount-hold-fence.cjs +0 -120
- package/dist/cjs/workspace-mutation-gate.cjs +0 -127
- package/dist/cjs/workspace-path-move.cjs +0 -195
- package/dist/cjs/workspace-preserve-only-policy.cjs +0 -36
- package/dist/cjs/workspace-project-config-policy.cjs +0 -53
- package/dist/cjs/workspace-projection-ledger.cjs +0 -81
- package/dist/cjs/workspace-publication-evidence.cjs +0 -46
- package/dist/cjs/workspace-sync-coalescer.cjs +0 -58
- package/dist/mjs/atomic-rename.mjs +0 -261
- package/dist/mjs/browser-upload.mjs +0 -42
- package/dist/mjs/command-launcher.mjs +0 -393
- package/dist/mjs/control-command-policy.mjs +0 -146
- package/dist/mjs/git-blob-hash.mjs +0 -16
- package/dist/mjs/git-identity.mjs +0 -15
- package/dist/mjs/git-process-environment.mjs +0 -105
- package/dist/mjs/inline-output.mjs +0 -37
- package/dist/mjs/managed-paths.mjs +0 -174
- package/dist/mjs/plan-lint.mjs +0 -129
- package/dist/mjs/plan-parser.mjs +0 -94
- package/dist/mjs/plan-paths.mjs +0 -25
- package/dist/mjs/port-forward-client.mjs +0 -172
- package/dist/mjs/project-checkout-garbage.mjs +0 -178
- package/dist/mjs/project-mirror-fetch-policy.mjs +0 -56
- package/dist/mjs/project-mirror-refs-token.mjs +0 -53
- package/dist/mjs/project-workspace-state.mjs +0 -937
- package/dist/mjs/project-worktrees.mjs +0 -1657
- package/dist/mjs/pty-output-coalescer.mjs +0 -61
- package/dist/mjs/recovery-journal-protocol.mjs +0 -30
- package/dist/mjs/recovery-journal-runtime.mjs +0 -112
- package/dist/mjs/recovery-journal-thread.mjs +0 -8
- package/dist/mjs/recovery-journal.mjs +0 -694
- package/dist/mjs/recovery-output-window.mjs +0 -53
- package/dist/mjs/recovery-protocol.mjs +0 -6
- package/dist/mjs/recovery-store.mjs +0 -217
- package/dist/mjs/registry-auth.mjs +0 -269
- package/dist/mjs/repository-transition-policy.mjs +0 -22
- package/dist/mjs/runtime-version.mjs +0 -54
- package/dist/mjs/session-file-mutations.mjs +0 -37
- package/dist/mjs/supervisor.mjs +0 -114
- package/dist/mjs/three-way-merge.mjs +0 -318
- package/dist/mjs/working-tree-mirror.mjs +0 -1817
- package/dist/mjs/workspace-automatic-sync-policy.mjs +0 -48
- package/dist/mjs/workspace-branch-incarnation-policy.mjs +0 -13
- package/dist/mjs/workspace-command-sync-policy.mjs +0 -84
- package/dist/mjs/workspace-command-targets.mjs +0 -37
- package/dist/mjs/workspace-filesystem-executor-thread.mjs +0 -38
- package/dist/mjs/workspace-filesystem-executor.mjs +0 -287
- package/dist/mjs/workspace-filesystem-job-types.mjs +0 -116
- package/dist/mjs/workspace-filesystem-jobs.mjs +0 -55
- package/dist/mjs/workspace-git-sync.mjs +0 -3553
- package/dist/mjs/workspace-hydration-ledger.mjs +0 -58
- package/dist/mjs/workspace-hydration-merge.mjs +0 -414
- package/dist/mjs/workspace-hydration-recovery-state.mjs +0 -29
- package/dist/mjs/workspace-incident-state.mjs +0 -12
- package/dist/mjs/workspace-merge-projection.mjs +0 -594
- package/dist/mjs/workspace-mount-boundary.mjs +0 -37
- package/dist/mjs/workspace-mount-hold-fence.mjs +0 -95
- package/dist/mjs/workspace-mutation-gate.mjs +0 -103
- package/dist/mjs/workspace-path-move.mjs +0 -160
- package/dist/mjs/workspace-preserve-only-policy.mjs +0 -11
- package/dist/mjs/workspace-project-config-policy.mjs +0 -27
- package/dist/mjs/workspace-projection-ledger.mjs +0 -57
- package/dist/mjs/workspace-publication-evidence.mjs +0 -21
- package/dist/mjs/workspace-sync-coalescer.mjs +0 -34
- package/dist/types/atomic-rename.d.ts +0 -78
- package/dist/types/browser-upload.d.ts +0 -7
- package/dist/types/command-launcher.d.ts +0 -104
- package/dist/types/control-command-policy.d.ts +0 -53
- package/dist/types/git-blob-hash.d.ts +0 -10
- package/dist/types/git-identity.d.ts +0 -9
- package/dist/types/git-process-environment.d.ts +0 -9
- package/dist/types/inline-output.d.ts +0 -3
- package/dist/types/managed-paths.d.ts +0 -19
- package/dist/types/plan-lint.d.ts +0 -16
- package/dist/types/plan-parser.d.ts +0 -38
- package/dist/types/plan-paths.d.ts +0 -36
- package/dist/types/port-forward-client.d.ts +0 -8
- package/dist/types/project-checkout-garbage.d.ts +0 -86
- package/dist/types/project-mirror-fetch-policy.d.ts +0 -84
- package/dist/types/project-mirror-refs-token.d.ts +0 -53
- package/dist/types/project-workspace-state.d.ts +0 -188
- package/dist/types/project-worktrees.d.ts +0 -397
- package/dist/types/pty-output-coalescer.d.ts +0 -20
- package/dist/types/recovery-journal-protocol.d.ts +0 -35
- package/dist/types/recovery-journal-runtime.d.ts +0 -12
- package/dist/types/recovery-journal-stall-fixture.d.ts +0 -1
- package/dist/types/recovery-journal-thread.d.ts +0 -1
- package/dist/types/recovery-journal.d.ts +0 -248
- package/dist/types/recovery-output-window.d.ts +0 -19
- package/dist/types/recovery-protocol.d.ts +0 -59
- package/dist/types/recovery-store.d.ts +0 -52
- package/dist/types/registry-auth.d.ts +0 -47
- package/dist/types/repository-transition-policy.d.ts +0 -26
- package/dist/types/runtime-version.d.ts +0 -1
- package/dist/types/session-file-mutations.d.ts +0 -22
- package/dist/types/supervisor-daemonized-fixture.d.ts +0 -1
- package/dist/types/supervisor-launcher-cleanup-fixture.d.ts +0 -1
- package/dist/types/supervisor-signal-fixture.d.ts +0 -1
- package/dist/types/supervisor.d.ts +0 -23
- package/dist/types/three-way-merge.d.ts +0 -77
- package/dist/types/working-tree-mirror.d.ts +0 -424
- package/dist/types/workspace-automatic-sync-policy.d.ts +0 -57
- package/dist/types/workspace-branch-incarnation-policy.d.ts +0 -14
- package/dist/types/workspace-command-sync-policy.d.ts +0 -57
- package/dist/types/workspace-command-targets.d.ts +0 -37
- package/dist/types/workspace-filesystem-executor-thread.d.ts +0 -1
- package/dist/types/workspace-filesystem-executor.d.ts +0 -123
- package/dist/types/workspace-filesystem-job-types.d.ts +0 -302
- package/dist/types/workspace-filesystem-jobs.d.ts +0 -7
- package/dist/types/workspace-git-sync.d.ts +0 -514
- package/dist/types/workspace-hydration-ledger.d.ts +0 -76
- package/dist/types/workspace-hydration-merge.d.ts +0 -103
- package/dist/types/workspace-hydration-recovery-state.d.ts +0 -10
- package/dist/types/workspace-incident-state.d.ts +0 -19
- package/dist/types/workspace-merge-projection.d.ts +0 -69
- package/dist/types/workspace-mount-boundary.d.ts +0 -10
- package/dist/types/workspace-mount-hold-fence.d.ts +0 -42
- package/dist/types/workspace-mutation-gate.d.ts +0 -42
- package/dist/types/workspace-path-move.d.ts +0 -21
- package/dist/types/workspace-preserve-only-policy.d.ts +0 -15
- package/dist/types/workspace-project-config-policy.d.ts +0 -48
- package/dist/types/workspace-projection-ledger.d.ts +0 -59
- package/dist/types/workspace-publication-evidence.d.ts +0 -17
- package/dist/types/workspace-sync-coalescer.d.ts +0 -28
- /package/dist/types/{credential-authority-lock-fixture.d.ts → runtime/releases/main.d.ts} +0 -0
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import type { WorkerOperationRecovery, WorkerOutputOffsets } from "./recovery-protocol";
|
|
2
|
-
/**
|
|
3
|
-
* The control-thread side of the worker's durable recovery journal.
|
|
4
|
-
*
|
|
5
|
-
* The SQLite store (WAL, `synchronous=FULL`) lives on the journal thread;
|
|
6
|
-
* this facade owns one ordered channel of store operations and the ordered
|
|
7
|
-
* delivery of the messages those operations make durable. Its invariants:
|
|
8
|
-
*
|
|
9
|
-
* - order: every entry is applied in append order, one durable commit per
|
|
10
|
-
* batch, so an `unknown` appended after a `record` applies after it, and an
|
|
11
|
-
* `admit` of a later request commits after the `record` of an earlier one;
|
|
12
|
-
* - commit before send: a keyed message is written to the socket only after
|
|
13
|
-
* the batch holding its `record` committed, in append order, so a terminal
|
|
14
|
-
* never leaves before the output recorded ahead of it and a response is
|
|
15
|
-
* never acknowledged before it is durable;
|
|
16
|
-
* - commit before effects: `admit` resolves after its commit; handlers run
|
|
17
|
-
* after it;
|
|
18
|
-
* - bounded: everything the facade retains (entries waiting for the thread,
|
|
19
|
-
* entries in the batch being committed, and committed messages not yet
|
|
20
|
-
* drained to the socket) is charged to one general budget of entries and
|
|
21
|
-
* bytes, reserved atomically before anything is queued and released only
|
|
22
|
-
* when the item is actually done; unknown marks, acknowledgements and
|
|
23
|
-
* handshake reads use a separate reserved control budget. Output producers
|
|
24
|
-
* and admissions wait for budget in bounded waiting rooms; a result that
|
|
25
|
-
* cannot be buffered is never sent early: its operation is marked unknown,
|
|
26
|
-
* which is exactly what a crash would have left;
|
|
27
|
-
* - fail closed: a thread exit, a failed batch, or an exhausted control budget
|
|
28
|
-
* fails every pending and future entry and reports once; the store is never
|
|
29
|
-
* re-opened in-process.
|
|
30
|
-
*/
|
|
31
|
-
type Message = {
|
|
32
|
-
type: string;
|
|
33
|
-
[key: string]: unknown;
|
|
34
|
-
};
|
|
35
|
-
export declare const WORKER_RECOVERY_JOURNAL_MAX_BATCH_ENTRIES = 256;
|
|
36
|
-
export declare const WORKER_RECOVERY_JOURNAL_MAX_PENDING_ENTRIES = 4096;
|
|
37
|
-
export declare const WORKER_RECOVERY_JOURNAL_MAX_PENDING_BYTES: number;
|
|
38
|
-
export declare const WORKER_RECOVERY_JOURNAL_MAX_CONTROL_ENTRIES = 2048;
|
|
39
|
-
export declare const WORKER_RECOVERY_JOURNAL_MAX_CONTROL_BYTES: number;
|
|
40
|
-
export declare const WORKER_RECOVERY_JOURNAL_MAX_ENTRY_BYTES: number;
|
|
41
|
-
export declare const WORKER_RECOVERY_JOURNAL_OUTPUT_CHUNK_CHARACTERS: number;
|
|
42
|
-
export declare const WORKER_RECOVERY_JOURNAL_MAX_WAITING_ADMISSIONS = 512;
|
|
43
|
-
export declare const WORKER_RECOVERY_JOURNAL_MAX_WAITING_OUTPUT = 1024;
|
|
44
|
-
export declare const WORKER_RECOVERY_JOURNAL_MAX_WAITING_BYTES: number;
|
|
45
|
-
export declare const WORKER_RECOVERY_JOURNAL_REPLAY_PAGE_FRAMES = 32;
|
|
46
|
-
export declare class WorkerRecoveryJournalError extends Error {
|
|
47
|
-
readonly name: string;
|
|
48
|
-
}
|
|
49
|
-
/** The journal is intact but its bounded waiting room is full; the caller must not queue more. */
|
|
50
|
-
export declare class WorkerRecoveryJournalBusyError extends WorkerRecoveryJournalError {
|
|
51
|
-
readonly name = "WorkerRecoveryJournalBusyError";
|
|
52
|
-
}
|
|
53
|
-
export type WorkerRecoveryJournalAdmission = {
|
|
54
|
-
admission: "new" | "duplicate" | "unknown" | "conflict";
|
|
55
|
-
response: Message | undefined;
|
|
56
|
-
cancelled: boolean;
|
|
57
|
-
};
|
|
58
|
-
export type WorkerRecoveryJournalRecoveryState = {
|
|
59
|
-
operations: WorkerOperationRecovery[];
|
|
60
|
-
cursors: WorkerOutputOffsets[];
|
|
61
|
-
responses: Message[];
|
|
62
|
-
terminals: Message[];
|
|
63
|
-
};
|
|
64
|
-
export type WorkerRecoveryJournalStatus = {
|
|
65
|
-
/** Entries waiting for the thread plus entries in the batch being committed. */
|
|
66
|
-
pendingEntries: number;
|
|
67
|
-
/** General budget in use: pending entries and undelivered messages, in entries and bytes. */
|
|
68
|
-
retainedEntries: number;
|
|
69
|
-
retainedBytes: number;
|
|
70
|
-
controlEntries: number;
|
|
71
|
-
controlBytes: number;
|
|
72
|
-
waitingAdmissions: number;
|
|
73
|
-
waitingOutput: number;
|
|
74
|
-
/** Payload bytes held by requests and output chunks waiting for budget. */
|
|
75
|
-
waitingBytes: number;
|
|
76
|
-
/** Bytes of store replies (handshake state, output pages) the caller has not consumed yet. */
|
|
77
|
-
retainedReplyBytes: number;
|
|
78
|
-
committedSeq: number;
|
|
79
|
-
appendedSeq: number;
|
|
80
|
-
undelivered: number;
|
|
81
|
-
failed: string | null;
|
|
82
|
-
};
|
|
83
|
-
export type WorkerRecoveryJournalOptions = {
|
|
84
|
-
filename: string;
|
|
85
|
-
threadModulePath?: string;
|
|
86
|
-
/** Extra `workerData` for the thread module (test fixtures only). */
|
|
87
|
-
threadWorkerData?: Record<string, unknown>;
|
|
88
|
-
log?: (line: string) => void;
|
|
89
|
-
maxBatchEntries?: number;
|
|
90
|
-
maxPendingEntries?: number;
|
|
91
|
-
maxPendingBytes?: number;
|
|
92
|
-
maxControlEntries?: number;
|
|
93
|
-
maxControlBytes?: number;
|
|
94
|
-
maxEntryBytes?: number;
|
|
95
|
-
maxWaitingAdmissions?: number;
|
|
96
|
-
maxWaitingOutput?: number;
|
|
97
|
-
maxWaitingBytes?: number;
|
|
98
|
-
};
|
|
99
|
-
export declare class WorkerRecoveryJournal {
|
|
100
|
-
readonly ledgerId: string;
|
|
101
|
-
private readonly worker;
|
|
102
|
-
private readonly log;
|
|
103
|
-
private readonly maxBatchEntries;
|
|
104
|
-
private readonly maxEntryBytes;
|
|
105
|
-
private readonly maxWaitingAdmissions;
|
|
106
|
-
private readonly maxWaitingOutput;
|
|
107
|
-
private readonly maxWaitingBytes;
|
|
108
|
-
private waitingBytes;
|
|
109
|
-
private retainedReplyBytes;
|
|
110
|
-
private readonly general;
|
|
111
|
-
private readonly control;
|
|
112
|
-
private nextSeq;
|
|
113
|
-
private committedSeq;
|
|
114
|
-
private readonly pending;
|
|
115
|
-
private inFlight;
|
|
116
|
-
private nextBatchId;
|
|
117
|
-
private readonly waiters;
|
|
118
|
-
private readonly outbound;
|
|
119
|
-
private deliveryPaused;
|
|
120
|
-
private replayCoveredSeq;
|
|
121
|
-
private failure;
|
|
122
|
-
private closed;
|
|
123
|
-
private readonly pendingAdmissions;
|
|
124
|
-
private readonly activeOperations;
|
|
125
|
-
private readonly cancelledRequestIds;
|
|
126
|
-
private readonly unknownRequestIds;
|
|
127
|
-
private readonly unknownRunIds;
|
|
128
|
-
private readonly coalescedControl;
|
|
129
|
-
private readonly flushWaiters;
|
|
130
|
-
/** Delivers one committed message in order; returns false when the transport declined it (the pumps re-send). */
|
|
131
|
-
deliver: ((message: Message) => boolean) | undefined;
|
|
132
|
-
/** Invoked once when the journal fails closed. */
|
|
133
|
-
onFailure: ((error: Error) => void) | undefined;
|
|
134
|
-
private constructor();
|
|
135
|
-
/** Start the journal thread, open the store there (its crash recovery runs there) and return once it is ready. */
|
|
136
|
-
static open(options: WorkerRecoveryJournalOptions): Promise<WorkerRecoveryJournal>;
|
|
137
|
-
status(): WorkerRecoveryJournalStatus;
|
|
138
|
-
/**
|
|
139
|
-
* Durably admit an inbound operation; resolves after the commit. Waits for
|
|
140
|
-
* general budget in a bounded waiting room; when that room is full the
|
|
141
|
-
* admission is refused at once (WorkerRecoveryJournalBusyError) so the
|
|
142
|
-
* message is neither acknowledged nor retained.
|
|
143
|
-
*/
|
|
144
|
-
admit(message: Message & {
|
|
145
|
-
requestId: string;
|
|
146
|
-
}): Promise<WorkerRecoveryJournalAdmission>;
|
|
147
|
-
/**
|
|
148
|
-
* Re-admit an unknown branch deletion. Like `admit`, the request is a
|
|
149
|
-
* pending admission from before the await, so a session cancellation that
|
|
150
|
-
* lands while the disk is slow snapshots it and the handler's recheck after
|
|
151
|
-
* the await refuses to rerun the deletion.
|
|
152
|
-
*/
|
|
153
|
-
readmitUnknownBranchDeletion(requestId: string, sessionId: string | undefined): Promise<boolean>;
|
|
154
|
-
/**
|
|
155
|
-
* Queue an outbound message. Keyed messages are recorded (when the store
|
|
156
|
-
* records their type) and delivered in order after their commit; other
|
|
157
|
-
* messages are delivered at once. Returns false when the message was not
|
|
158
|
-
* queued: its operation is already unknown, or the budget cannot hold it,
|
|
159
|
-
* in which case the operation is marked unknown so it is neither
|
|
160
|
-
* acknowledged early nor sent later.
|
|
161
|
-
*/
|
|
162
|
-
send(message: Message): boolean;
|
|
163
|
-
/** Commit and deliver a result before an intentional runtime restart fences unfinished operations. */
|
|
164
|
-
sendAndFlush(message: Message): Promise<void>;
|
|
165
|
-
/**
|
|
166
|
-
* Queue an output frame, split into bounded records, waiting for budget so
|
|
167
|
-
* a stalled journal throttles the producer (and through the pipe, the
|
|
168
|
-
* child) instead of growing memory.
|
|
169
|
-
*/
|
|
170
|
-
sendOutput(frame: Message & {
|
|
171
|
-
type: "exec_output";
|
|
172
|
-
runId: string;
|
|
173
|
-
stream: "stdout" | "stderr";
|
|
174
|
-
data: string;
|
|
175
|
-
}): Promise<void>;
|
|
176
|
-
/**
|
|
177
|
-
* Reserve general budget atomically, waiting in the bounded room of `kind`
|
|
178
|
-
* when it does not fit now. The waiting room is bounded in count and in
|
|
179
|
-
* payload bytes (the message a waiting admission holds is charged before it
|
|
180
|
-
* waits), and an entry that could never fit the general budget is refused
|
|
181
|
-
* at once rather than parked at the head of the queue.
|
|
182
|
-
*/
|
|
183
|
-
private reserveGeneral;
|
|
184
|
-
/** Reserve for the head waiter inside this synchronous call, so no continuation can outrun the accounting. */
|
|
185
|
-
private wakeWaiters;
|
|
186
|
-
private enqueueRecord;
|
|
187
|
-
private refuse;
|
|
188
|
-
private trackRecorded;
|
|
189
|
-
/**
|
|
190
|
-
* Mark an operation unknown: never sent again (undelivered messages for it
|
|
191
|
-
* are dropped now, and the durable mark keeps replay from resurrecting it).
|
|
192
|
-
* Coalesced per id; uses the reserved control budget.
|
|
193
|
-
*/
|
|
194
|
-
unknown(requestId: string): void;
|
|
195
|
-
unknownRun(runId: string): void;
|
|
196
|
-
acknowledgeResult(requestId: string): void;
|
|
197
|
-
/** Monotonic per stream: a later acknowledgement replaces a pending earlier one. */
|
|
198
|
-
acknowledgeOutput(runId: string, stream: "stdout" | "stderr", offset: number): void;
|
|
199
|
-
acknowledgeTerminal(runId: string): void;
|
|
200
|
-
/**
|
|
201
|
-
* Snapshot every admitted and pending operation of the session as cancelled
|
|
202
|
-
* (the handlers check `isRequestCancelled` at their fences) and append the
|
|
203
|
-
* durable cancellation, which the thread applies after every admission
|
|
204
|
-
* appended before it. Resolves after the commit.
|
|
205
|
-
*/
|
|
206
|
-
cancelSession(sessionId: string): Promise<void>;
|
|
207
|
-
isRequestCancelled(requestId: string): boolean;
|
|
208
|
-
/** Every operation admitted or awaiting admission in this process that has not completed, for the runtime fence and lease expiry. */
|
|
209
|
-
activeAndPendingOperations(): WorkerOperationRecovery[];
|
|
210
|
-
/**
|
|
211
|
-
* The handshake read. One entry, so it sees exactly the entries appended
|
|
212
|
-
* before it and none after: the replay boundary. Callers pause delivery
|
|
213
|
-
* before appending it and resume after the handshake, so every keyed
|
|
214
|
-
* message committed before the mark is replayed once (from the store) and
|
|
215
|
-
* nothing committed after it can enter the replay of responses, operations
|
|
216
|
-
* or terminals; output pages that follow may re-send frames the pump would
|
|
217
|
-
* re-send anyway, which the server's offset cursors absorb.
|
|
218
|
-
*/
|
|
219
|
-
recoveryState(requests: string[]): Promise<WorkerRecoveryJournalRecoveryState>;
|
|
220
|
-
private retainedStateBytes;
|
|
221
|
-
/** Output replay, one bounded page at a time; a page is accounted until the consumer asks for the next one. */
|
|
222
|
-
outputReplay(offsets: WorkerOutputOffsets[] | undefined, pageFrames?: number): AsyncGenerator<Message[]>;
|
|
223
|
-
terminals(): Promise<Message[]>;
|
|
224
|
-
/** Delivery of committed keyed messages is held (in order) while a handshake replays from the store. */
|
|
225
|
-
pauseDelivery(): void;
|
|
226
|
-
resumeDelivery(): void;
|
|
227
|
-
/** Resolves once every entry appended so far is committed (or the journal failed). */
|
|
228
|
-
flush(): Promise<void>;
|
|
229
|
-
close(): void;
|
|
230
|
-
private assertOpen;
|
|
231
|
-
/** Control entries are tiny and idempotent per key: a pending one is updated in place instead of queued again. */
|
|
232
|
-
private appendControl;
|
|
233
|
-
/** A control-budget entry whose result the caller awaits; rejects when the budget is exhausted. */
|
|
234
|
-
private appendControlOrThrow;
|
|
235
|
-
private lastAppended;
|
|
236
|
-
/** Queue an entry whose budget was already reserved from `budget`. */
|
|
237
|
-
private append;
|
|
238
|
-
private dispatch;
|
|
239
|
-
private onReply;
|
|
240
|
-
private dropOutbound;
|
|
241
|
-
private releaseOutbound;
|
|
242
|
-
private deliverReady;
|
|
243
|
-
private fail;
|
|
244
|
-
private failEntries;
|
|
245
|
-
}
|
|
246
|
-
/** The packaged thread module lives next to this module with the same extension (.ts in source, .cjs/.mjs in the package). */
|
|
247
|
-
export declare function workerRecoveryJournalThreadModulePath(): string;
|
|
248
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { WorkerOutputOffsets } from "./recovery-protocol";
|
|
2
|
-
export type WorkerOutputFrame = {
|
|
3
|
-
type: "exec_output";
|
|
4
|
-
runId: string;
|
|
5
|
-
stream: "stdout" | "stderr";
|
|
6
|
-
offset: number;
|
|
7
|
-
data: string;
|
|
8
|
-
};
|
|
9
|
-
/** Bound outstanding application bytes, including data already buffered by the server's socket. */
|
|
10
|
-
export declare class WorkerOutputWindow {
|
|
11
|
-
private readonly windowBytes;
|
|
12
|
-
private sent;
|
|
13
|
-
private acknowledged;
|
|
14
|
-
private outstanding;
|
|
15
|
-
constructor(windowBytes?: number);
|
|
16
|
-
reset(cursors: WorkerOutputOffsets[]): void;
|
|
17
|
-
send(frame: WorkerOutputFrame, send: (frame: WorkerOutputFrame) => boolean, bufferedAmount?: number): boolean;
|
|
18
|
-
acknowledge(runId: string, stream: "stdout" | "stderr", offset: number): void;
|
|
19
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/** The application protocol survives replacement of its WebSocket transport. */
|
|
2
|
-
export declare const WORKER_RESUMABLE_PROTOCOL: 1;
|
|
3
|
-
export declare const WORKER_RECOVERY_TIMEOUT_MS: number;
|
|
4
|
-
export type WorkerOperationRecovery = {
|
|
5
|
-
requestId: string;
|
|
6
|
-
runId?: string;
|
|
7
|
-
sessionId?: string;
|
|
8
|
-
requestType?: string;
|
|
9
|
-
state: "accepted" | "preparing" | "running" | "completed" | "unknown";
|
|
10
|
-
};
|
|
11
|
-
export type WorkerOutputOffsets = {
|
|
12
|
-
runId: string;
|
|
13
|
-
stdoutBytes: number;
|
|
14
|
-
stderrBytes: number;
|
|
15
|
-
};
|
|
16
|
-
export type WorkerRecoveryServerMessage = {
|
|
17
|
-
type: "recovery_request";
|
|
18
|
-
recoveryId: string;
|
|
19
|
-
requests: string[];
|
|
20
|
-
outputOffsets: WorkerOutputOffsets[];
|
|
21
|
-
} | {
|
|
22
|
-
type: "recovery_ready";
|
|
23
|
-
recoveryId: string;
|
|
24
|
-
leaseMs: number;
|
|
25
|
-
} | {
|
|
26
|
-
type: "operation_result_ack";
|
|
27
|
-
requestId: string;
|
|
28
|
-
} | {
|
|
29
|
-
type: "exec_output_ack";
|
|
30
|
-
runId: string;
|
|
31
|
-
stream: "stdout" | "stderr";
|
|
32
|
-
nextOffset: number;
|
|
33
|
-
} | {
|
|
34
|
-
type: "worker_execution_lease";
|
|
35
|
-
leaseMs: number;
|
|
36
|
-
} | {
|
|
37
|
-
type: "cancel_session";
|
|
38
|
-
sessionId: string;
|
|
39
|
-
cancellationId: string;
|
|
40
|
-
};
|
|
41
|
-
export type WorkerRecoveryClientMessage = {
|
|
42
|
-
type: "recovery_state";
|
|
43
|
-
recoveryId: string;
|
|
44
|
-
runtimeId: string;
|
|
45
|
-
ledgerId: string;
|
|
46
|
-
operations: WorkerOperationRecovery[];
|
|
47
|
-
} | {
|
|
48
|
-
type: "recovery_complete";
|
|
49
|
-
recoveryId: string;
|
|
50
|
-
} | {
|
|
51
|
-
type: "operation_received";
|
|
52
|
-
requestId: string;
|
|
53
|
-
} | {
|
|
54
|
-
type: "operation_completed";
|
|
55
|
-
requestId: string;
|
|
56
|
-
} | {
|
|
57
|
-
type: "cancel_session_ack";
|
|
58
|
-
cancellationId: string;
|
|
59
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { WorkerOperationRecovery, WorkerOutputOffsets } from "./recovery-protocol";
|
|
2
|
-
type Message = {
|
|
3
|
-
type: string;
|
|
4
|
-
[key: string]: unknown;
|
|
5
|
-
};
|
|
6
|
-
/** Stable semantic identity, independent of JSON key order and transport request aliases. */
|
|
7
|
-
export declare function workerOperationDigest(message: Message): string;
|
|
8
|
-
/** The receipt is committed before a handler can mutate anything. Unknown crash outcomes never replay effects. */
|
|
9
|
-
export declare class WorkerRecoveryStore {
|
|
10
|
-
private readonly db;
|
|
11
|
-
readonly ledgerId: string;
|
|
12
|
-
constructor(filename: string);
|
|
13
|
-
close(): void;
|
|
14
|
-
/**
|
|
15
|
-
* Run several store operations as one durable commit (one FULL fsync).
|
|
16
|
-
* Operations that open their own transaction nest as savepoints. A throw
|
|
17
|
-
* rolls the whole group back; callers treat that as a journal failure.
|
|
18
|
-
*/
|
|
19
|
-
batch<T>(operations: () => T): T;
|
|
20
|
-
private row;
|
|
21
|
-
admit(message: Message & {
|
|
22
|
-
requestId: string;
|
|
23
|
-
}): "new" | "duplicate" | "unknown" | "conflict";
|
|
24
|
-
isUnknown(requestId: string): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Re-admit an operation whose crash outcome is unknown so it can run again
|
|
27
|
-
* and record a result. Only a branch deletion qualifies: it is idempotent
|
|
28
|
-
* for its exact incarnation (durable tombstone plus incarnation preflight),
|
|
29
|
-
* so a rerun converges on the same outcome. Every other unknown operation
|
|
30
|
-
* keeps the no-replay invariant.
|
|
31
|
-
*/
|
|
32
|
-
readmitUnknownBranchDeletion(requestId: string): boolean;
|
|
33
|
-
unknown(requestId: string): void;
|
|
34
|
-
unknownRun(runId: string): void;
|
|
35
|
-
record(message: Message): Message;
|
|
36
|
-
operations(): WorkerOperationRecovery[];
|
|
37
|
-
response(requestId: string): Message | undefined;
|
|
38
|
-
responses(requestIds: string[]): Message[];
|
|
39
|
-
lengths(runId: string): {
|
|
40
|
-
stdoutBytes: number;
|
|
41
|
-
stderrBytes: number;
|
|
42
|
-
};
|
|
43
|
-
outputCursors(): WorkerOutputOffsets[];
|
|
44
|
-
output(offsets?: WorkerOutputOffsets[]): Generator<Message>;
|
|
45
|
-
terminals(): Message[];
|
|
46
|
-
acknowledgeOutput(runId: string, stream: "stdout" | "stderr", offset: number): void;
|
|
47
|
-
acknowledgeResult(requestId: string): void;
|
|
48
|
-
acknowledgeTerminal(runId: string): void;
|
|
49
|
-
cancelSession(sessionId: string): void;
|
|
50
|
-
isRequestCancelled(requestId: string): boolean;
|
|
51
|
-
}
|
|
52
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export declare const APP_MANAGED_GITHUB_REGISTRY: "ghcr.io";
|
|
2
|
-
export type GitHubRegistryCredential = {
|
|
3
|
-
registry: typeof APP_MANAGED_GITHUB_REGISTRY;
|
|
4
|
-
username: string;
|
|
5
|
-
token: string;
|
|
6
|
-
};
|
|
7
|
-
export declare class RegistryAuthConfigurationError extends Error {
|
|
8
|
-
constructor(cause: unknown);
|
|
9
|
-
}
|
|
10
|
-
export declare function registryAuthHasAppManagedGitHubCredential(filePath: string): boolean;
|
|
11
|
-
type DirectoryFsyncDependencies = {
|
|
12
|
-
platform: NodeJS.Platform;
|
|
13
|
-
open: (directory: string) => number;
|
|
14
|
-
fsync: (descriptor: number) => void;
|
|
15
|
-
close: (descriptor: number) => void;
|
|
16
|
-
};
|
|
17
|
-
declare function fsyncDirectory(directory: string, dependencies?: DirectoryFsyncDependencies): void;
|
|
18
|
-
export type PrivateAuthFileUpdate = {
|
|
19
|
-
filePath: string;
|
|
20
|
-
content: string | null;
|
|
21
|
-
allowSymlinkRemoval?: boolean;
|
|
22
|
-
};
|
|
23
|
-
export type PreparedPrivateAuthFileGeneration = {
|
|
24
|
-
readonly changed: boolean;
|
|
25
|
-
commit(beforeMutation?: (filePath: string, index: number) => void): void;
|
|
26
|
-
discard(): void;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Validate and fsync every replacement before exposing the first new auth
|
|
30
|
-
* byte. Cross-file publication is necessarily sequential, so callers must
|
|
31
|
-
* fence/terminate the previous process generation before commit and treat any
|
|
32
|
-
* commit error as a fatal partial-generation boundary.
|
|
33
|
-
*/
|
|
34
|
-
export declare function preparePrivateAuthFileGeneration(updates: readonly PrivateAuthFileUpdate[]): PreparedPrivateAuthFileGeneration;
|
|
35
|
-
export declare function planGitHubRegistryAuthFiles(filePaths: readonly string[], credential: GitHubRegistryCredential | null): PrivateAuthFileUpdate[];
|
|
36
|
-
/**
|
|
37
|
-
* Authoritatively replace the app-owned ghcr.io entry while retaining every
|
|
38
|
-
* unrelated Docker/containers auth entry and top-level setting.
|
|
39
|
-
*/
|
|
40
|
-
export declare function updateGitHubRegistryAuthFile(filePath: string, credential: GitHubRegistryCredential | null): void;
|
|
41
|
-
export declare function configureGitHubRegistryAuthFiles(filePaths: readonly string[], credential: GitHubRegistryCredential | null): void;
|
|
42
|
-
export declare const registryAuthTestHarness: {
|
|
43
|
-
fsyncDirectory: typeof fsyncDirectory;
|
|
44
|
-
atomicReplacePrivateFile(filePath: string, content: string, beforeRename?: () => void): void;
|
|
45
|
-
configureFiles(filePaths: readonly string[], credential: GitHubRegistryCredential | null, beforeRename: (filePath: string, index: number) => void): void;
|
|
46
|
-
};
|
|
47
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export type WorkerRepositoryTransitionState = {
|
|
2
|
-
repositoryTransitionId: string | null;
|
|
3
|
-
executionDisabled: boolean;
|
|
4
|
-
mirrorWritesDisabled: boolean;
|
|
5
|
-
};
|
|
6
|
-
export type LastEnabledRepositoryTransition = {
|
|
7
|
-
known: boolean;
|
|
8
|
-
transitionId: string | null;
|
|
9
|
-
};
|
|
10
|
-
export declare function assertRepositoryTransitionState(project: WorkerRepositoryTransitionState & {
|
|
11
|
-
projectId: string;
|
|
12
|
-
}): void;
|
|
13
|
-
/** Disabled repositories retain their local state but expose no execution root. */
|
|
14
|
-
export declare function assertRepositoryExecutionEnabled(project: Pick<WorkerRepositoryTransitionState, "executionDisabled"> & {
|
|
15
|
-
projectId: string;
|
|
16
|
-
}): void;
|
|
17
|
-
/** Every hidden-mirror ref mutation, including deletion, uses this fence. */
|
|
18
|
-
export declare function repositoryMirrorWritesAllowed(project: Pick<WorkerRepositoryTransitionState, "executionDisabled" | "mirrorWritesDisabled"> | undefined): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* A disabled snapshot never consumes the reseed obligation. Missing durable
|
|
21
|
-
* history is treated conservatively after restart and reseeded once enabled.
|
|
22
|
-
*/
|
|
23
|
-
export declare function enabledRepositoryTransitionRequiresReseed(input: {
|
|
24
|
-
project: Pick<WorkerRepositoryTransitionState, "repositoryTransitionId" | "executionDisabled">;
|
|
25
|
-
lastEnabled: LastEnabledRepositoryTransition;
|
|
26
|
-
}): boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const WORKER_RUNTIME_VERSION: string;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File mutations (write, edit, plan updates) run on the asynchronous
|
|
3
|
-
* filesystem API, so a write can still be in flight when a session is
|
|
4
|
-
* stopped. A Stop acknowledges cleanup only after every mutation that had
|
|
5
|
-
* already started for the session has actually settled; mutations that were
|
|
6
|
-
* still queued re-check the session's cancellation immediately before their
|
|
7
|
-
* first write and never start. The tracker records the former; the admission
|
|
8
|
-
* fence inside each mutation's queue callback provides the latter.
|
|
9
|
-
*/
|
|
10
|
-
export declare class SessionFileMutationTracker {
|
|
11
|
-
private readonly inFlight;
|
|
12
|
-
/** Register a started mutation; it is forgotten when it settles, however it settles. */
|
|
13
|
-
track<T>(sessionId: string, mutation: Promise<T>): Promise<T>;
|
|
14
|
-
count(sessionId: string): number;
|
|
15
|
-
/**
|
|
16
|
-
* Resolves once every mutation tracked for the session at the time of the
|
|
17
|
-
* call has settled. Mutations started later are not joined: the session's
|
|
18
|
-
* cancellation marker, recorded before this is awaited, makes their
|
|
19
|
-
* admission recheck refuse them.
|
|
20
|
-
*/
|
|
21
|
-
settled(sessionId: string): Promise<void>;
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type KillableSubprocess } from "./process-tree";
|
|
2
|
-
export declare const WORKER_RUNTIME_ENV = "R5D_WORKER_INTERNAL_RUNTIME";
|
|
3
|
-
export declare const WORKER_RELOAD_EXIT_CODE = 75;
|
|
4
|
-
export declare const WORKER_RECONNECT_EXIT_CODE = 76;
|
|
5
|
-
export declare const WORKER_CREDENTIAL_RESTART_EXIT_CODE = 77;
|
|
6
|
-
export declare const WORKER_RECONNECT_DELAY_MS = 2000;
|
|
7
|
-
export declare const WORKER_RECONNECT_JITTER_MS = 3000;
|
|
8
|
-
export declare const WORKER_RECONNECT_MAX_DELAY_MS = 30000;
|
|
9
|
-
type RuntimeProcess = KillableSubprocess;
|
|
10
|
-
export type RuntimeSpawner = (argv: string[], options: {
|
|
11
|
-
stdin: "inherit";
|
|
12
|
-
stdout: "inherit";
|
|
13
|
-
stderr: "inherit";
|
|
14
|
-
detached: true;
|
|
15
|
-
env: Record<string, string | undefined>;
|
|
16
|
-
}) => RuntimeProcess;
|
|
17
|
-
export type RuntimeDelay = (delayMs: number) => Promise<void>;
|
|
18
|
-
export type RuntimeReaper = (runtime: RuntimeProcess) => Promise<void>;
|
|
19
|
-
export type RuntimeReconnectDelay = () => number;
|
|
20
|
-
export declare function workerReconnectDelayMs(random?: () => number, attempt?: number): number;
|
|
21
|
-
export declare function isRetryableWorkerServerStatus(status: number): boolean;
|
|
22
|
-
export declare function superviseWorkerRuntime(argv: string[], env?: Record<string, string | undefined>, spawnRuntime?: RuntimeSpawner, waitBeforeReconnect?: RuntimeDelay, reapCredentialRuntime?: RuntimeReaper, reconnectDelay?: RuntimeReconnectDelay): Promise<number>;
|
|
23
|
-
export {};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure three-way line merge (classic diff3) for merge hydration.
|
|
3
|
-
*
|
|
4
|
-
* The verdict is deliberately conservative: a false conflict only pins a
|
|
5
|
-
* mount for a cycle, while a false clean silently loses one side's edit. Git
|
|
6
|
-
* picks one of possibly many minimal diffs per side and its verdict depends on
|
|
7
|
-
* which, so instead of trusting one alignment this merge only treats a base
|
|
8
|
-
* line as stable when every minimal diff agrees on it, and only accepts an
|
|
9
|
-
* identical change from both sides when its alignment is unique. That keeps
|
|
10
|
-
* the clean verdict a subset of `git merge-file`'s for every minimal diff Git
|
|
11
|
-
* could choose, and clean output byte-identical to `git merge-file -p ours
|
|
12
|
-
* base theirs`; the differential test enforces both.
|
|
13
|
-
*/
|
|
14
|
-
export type ThreeWayMergeOptions = {
|
|
15
|
-
/** Sides with more lines than this are not merged (conflict). */
|
|
16
|
-
maxLines?: number;
|
|
17
|
-
/** Two-way diffs with more line edits than this are not merged (conflict); bounds the O((N+M)D) diff. */
|
|
18
|
-
maxEditDistance?: number;
|
|
19
|
-
/** Bound on the banded (lines × edits) alignment analysis per side; beyond it the merge conflicts. */
|
|
20
|
-
maxAlignmentCells?: number;
|
|
21
|
-
/** Bound on the diagonal visits one two-way diff may spend; beyond it the merge conflicts. */
|
|
22
|
-
maxDiffWork?: number;
|
|
23
|
-
};
|
|
24
|
-
export type ThreeWayMergeResult = {
|
|
25
|
-
kind: "clean";
|
|
26
|
-
content: Buffer;
|
|
27
|
-
} | {
|
|
28
|
-
kind: "conflict";
|
|
29
|
-
conflicts: number;
|
|
30
|
-
};
|
|
31
|
-
/** A changed region of a two-way diff: `a[aStart, aEnd)` was replaced by `b[bStart, bEnd)`. */
|
|
32
|
-
export type DiffHunk = {
|
|
33
|
-
aStart: number;
|
|
34
|
-
aEnd: number;
|
|
35
|
-
bStart: number;
|
|
36
|
-
bEnd: number;
|
|
37
|
-
};
|
|
38
|
-
/** What every minimal diff of a side against the base agrees on, per base line. */
|
|
39
|
-
export type SideAlignment = {
|
|
40
|
-
/** Base line -> the side line it is matched to in every minimal diff, or -1. */
|
|
41
|
-
certain: Int32Array;
|
|
42
|
-
/** 1 where minimal diffs disagree: matched to different side lines, or matched in some and deleted in others. */
|
|
43
|
-
ambiguous: Uint8Array;
|
|
44
|
-
};
|
|
45
|
-
type LineSequence = ArrayLike<number>;
|
|
46
|
-
/** Git's `buffer_is_binary`: a NUL byte within the first 8000 bytes. */
|
|
47
|
-
export declare function isBinaryContent(content: Buffer): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Minimal line diff `a` -> `b` as ordered, non-touching hunks, or null when
|
|
50
|
-
* the edit distance exceeds `maxEditDistance`. Divide and conquer on the
|
|
51
|
-
* middle snake keeps memory linear; the explicit stack keeps deep, lopsided
|
|
52
|
-
* splits off the call stack. The merge only needs the edit distance from it,
|
|
53
|
-
* the hunks are one of the minimal diffs.
|
|
54
|
-
*/
|
|
55
|
-
export declare function diffLines(a: LineSequence, b: LineSequence, options?: {
|
|
56
|
-
maxEditDistance?: number;
|
|
57
|
-
maxWork?: number;
|
|
58
|
-
}): DiffHunk[] | null;
|
|
59
|
-
/**
|
|
60
|
-
* Classifies every base line by what all minimal diffs `a` -> `b` agree on,
|
|
61
|
-
* given the length of their common subsequence.
|
|
62
|
-
*
|
|
63
|
-
* A minimal diff crosses from base line i to i + 1 either by deleting line i
|
|
64
|
-
* or by matching it to some b[j]; the crossing is on a minimal diff exactly
|
|
65
|
-
* when prefix LCS + suffix LCS (+ 1 for a match) reaches `lcsLength`. Both
|
|
66
|
-
* tables are only needed on the diagonal band any minimal diff stays within,
|
|
67
|
-
* so the cost is (lines × edits): suffix rows are checkpointed every √N rows
|
|
68
|
-
* and recomputed per block, prefix rows roll forward. Returns null once the
|
|
69
|
-
* band exceeds `maxCells`, which the caller treats as a conflict.
|
|
70
|
-
*/
|
|
71
|
-
export declare function analyzeAlignment(a: LineSequence, b: LineSequence, lcsLength: number, maxCells: number): SideAlignment | null;
|
|
72
|
-
export declare function mergeThreeWay(base: Buffer, ours: Buffer, theirs: Buffer, options?: ThreeWayMergeOptions): ThreeWayMergeResult;
|
|
73
|
-
export declare const threeWayMergeTestHarness: {
|
|
74
|
-
diffLines: typeof diffLines;
|
|
75
|
-
analyzeAlignment: typeof analyzeAlignment;
|
|
76
|
-
};
|
|
77
|
-
export {};
|