@ricsam/r5d-worker 0.0.100 → 0.0.103
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 +16 -3
- package/dist/cjs/main.cjs +390 -322
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/project-mirror-fetch-policy.cjs +48 -7
- package/dist/cjs/project-mirror-refs-token.cjs +36 -2
- package/dist/cjs/project-worktrees.cjs +49 -32
- package/dist/cjs/working-tree-mirror.cjs +347 -99
- package/dist/cjs/workspace-git-sync.cjs +189 -28
- package/dist/cjs/workspace-merge-projection.cjs +5 -19
- package/dist/cjs/workspace-mutation-gate.cjs +35 -0
- package/dist/cjs/workspace-projection-ledger.cjs +81 -0
- package/dist/cjs/workspace-sync-coalescer.cjs +58 -0
- package/dist/mjs/main.mjs +395 -324
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/project-mirror-fetch-policy.mjs +46 -6
- package/dist/mjs/project-mirror-refs-token.mjs +30 -1
- package/dist/mjs/project-worktrees.mjs +52 -33
- package/dist/mjs/working-tree-mirror.mjs +347 -99
- package/dist/mjs/workspace-git-sync.mjs +189 -28
- package/dist/mjs/workspace-merge-projection.mjs +5 -19
- package/dist/mjs/workspace-mutation-gate.mjs +35 -0
- package/dist/mjs/workspace-projection-ledger.mjs +57 -0
- package/dist/mjs/workspace-sync-coalescer.mjs +34 -0
- package/dist/types/main.d.ts +29 -17
- package/dist/types/project-mirror-fetch-policy.d.ts +70 -15
- package/dist/types/project-mirror-refs-token.d.ts +34 -0
- package/dist/types/project-worktrees.d.ts +26 -8
- package/dist/types/working-tree-mirror.d.ts +56 -11
- package/dist/types/workspace-git-sync.d.ts +41 -4
- package/dist/types/workspace-mutation-gate.d.ts +24 -3
- package/dist/types/workspace-projection-ledger.d.ts +59 -0
- package/dist/types/workspace-sync-coalescer.d.ts +28 -0
- package/package.json +1 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export type WorkspaceProjectionLedgerMount = {
|
|
2
|
+
id: string;
|
|
3
|
+
/** Durable logical incarnation; a re-created branch never matches its predecessor's record. */
|
|
4
|
+
hydrationIncarnationKey: string;
|
|
5
|
+
mutationToken?: () => string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Remembers, per mount incarnation, the visible-mutation token observed when
|
|
9
|
+
* the mount was last projected into the outer clone by a completed cycle,
|
|
10
|
+
* together with that cycle's result.
|
|
11
|
+
*
|
|
12
|
+
* Two decisions read it. A cycle skips mirroring a mount whose token is
|
|
13
|
+
* unchanged, because its outer subtree already carries those bytes. A
|
|
14
|
+
* request that targets a project checkout is answered with the previous
|
|
15
|
+
* cycle's result, without running a cycle, when no mount's token moved since
|
|
16
|
+
* that cycle. Both are cross-cycle skips only; the within-cycle busy and
|
|
17
|
+
* token re-checks in the sync engine stay as they are.
|
|
18
|
+
*
|
|
19
|
+
* The ledger is reset whenever something other than a recorded visible
|
|
20
|
+
* mutation can change checkout bytes: workspace configuration, canonical
|
|
21
|
+
* reset, outer remediation, branch creation or deletion, and any cycle that
|
|
22
|
+
* failed or ended in a conflict.
|
|
23
|
+
*/
|
|
24
|
+
export declare class WorkspaceProjectionLedger<Result extends {
|
|
25
|
+
outcome: string;
|
|
26
|
+
}> {
|
|
27
|
+
private readonly projectedTokens;
|
|
28
|
+
private lastCycle;
|
|
29
|
+
private static recordKey;
|
|
30
|
+
get lastCycleResult(): Result | null;
|
|
31
|
+
lastProjectedToken(mount: {
|
|
32
|
+
id: string;
|
|
33
|
+
hydrationIncarnationKey: string;
|
|
34
|
+
}): string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Record a completed cycle. `projectedMutationTokens` names the token each
|
|
37
|
+
* active mount carried when the cycle projected it; a mount absent from it
|
|
38
|
+
* keeps its earlier record. Any outcome that leaves the outer clone without
|
|
39
|
+
* a trustworthy projection clears the ledger.
|
|
40
|
+
*/
|
|
41
|
+
recordCycle(input: {
|
|
42
|
+
result: Result;
|
|
43
|
+
mounts: readonly WorkspaceProjectionLedgerMount[];
|
|
44
|
+
projectedMutationTokens: Readonly<Record<string, string>> | undefined;
|
|
45
|
+
}): void;
|
|
46
|
+
reset(): void;
|
|
47
|
+
/**
|
|
48
|
+
* The previous cycle's result when every request targets a configured
|
|
49
|
+
* mount and no mount's token moved since its recorded projection. A request
|
|
50
|
+
* without a target (a workspace-rooted command may touch any checkout), a
|
|
51
|
+
* mount without a token (a pending deletion), or pending deletion work all
|
|
52
|
+
* require a real cycle.
|
|
53
|
+
*/
|
|
54
|
+
answerFromLastCycle(input: {
|
|
55
|
+
targetMountIds: ReadonlyArray<string | null>;
|
|
56
|
+
mounts: readonly WorkspaceProjectionLedgerMount[];
|
|
57
|
+
pendingDeletions: boolean;
|
|
58
|
+
}): Result | null;
|
|
59
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batches ordinary workspace synchronization requests into one exclusive
|
|
3
|
+
* cycle each. A request that arrives while a batch is queued but not yet
|
|
4
|
+
* running joins that batch; a request that arrives while a batch is running
|
|
5
|
+
* opens the next one, because the running cycle may have selected its mounts
|
|
6
|
+
* before the request's command finished. Every request in a batch receives
|
|
7
|
+
* the same settlement, and the caller fans that out per attempt.
|
|
8
|
+
*
|
|
9
|
+
* Before this, every finished command queued its own full cycle behind every
|
|
10
|
+
* earlier one, so queue time grew without bound under a steady arrival rate
|
|
11
|
+
* even though each cycle finished in seconds.
|
|
12
|
+
*/
|
|
13
|
+
export declare class WorkspaceSyncCoalescer<Request, Settlement> {
|
|
14
|
+
private readonly options;
|
|
15
|
+
private pendingBatch;
|
|
16
|
+
private batchesStarted;
|
|
17
|
+
constructor(options: {
|
|
18
|
+
/** The exclusive sync lease; the batch body runs inside it. */
|
|
19
|
+
runExclusive: <T>(operation: () => Promise<T>) => Promise<T>;
|
|
20
|
+
/** Runs (or answers without running) one cycle for the whole batch. */
|
|
21
|
+
runBatch: (requests: readonly Request[]) => Promise<Settlement>;
|
|
22
|
+
});
|
|
23
|
+
/** Requests attached to the batch that has not started yet. */
|
|
24
|
+
get queuedRequestCount(): number;
|
|
25
|
+
/** Batches whose body has been entered, whether or not they ran a cycle. */
|
|
26
|
+
get startedBatchCount(): number;
|
|
27
|
+
request(request: Request): Promise<Settlement>;
|
|
28
|
+
}
|