@ricsam/r5d-worker 0.0.74 → 0.0.76

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.
Files changed (32) hide show
  1. package/README.md +6 -4
  2. package/dist/cjs/main.cjs +1031 -976
  3. package/dist/cjs/package.json +1 -1
  4. package/dist/cjs/project-workspace-state.cjs +777 -0
  5. package/dist/cjs/project-worktrees.cjs +559 -0
  6. package/dist/cjs/working-tree-mirror.cjs +225 -0
  7. package/dist/cjs/workspace-git-sync.cjs +565 -0
  8. package/dist/cjs/workspace-incident-state.cjs +2 -38
  9. package/dist/mjs/main.mjs +1048 -987
  10. package/dist/mjs/package.json +1 -1
  11. package/dist/mjs/project-workspace-state.mjs +745 -0
  12. package/dist/mjs/project-worktrees.mjs +513 -0
  13. package/dist/mjs/working-tree-mirror.mjs +190 -0
  14. package/dist/mjs/workspace-git-sync.mjs +524 -0
  15. package/dist/mjs/workspace-incident-state.mjs +1 -35
  16. package/dist/types/main.d.ts +35 -55
  17. package/dist/types/project-workspace-state.d.ts +144 -0
  18. package/dist/types/project-worktrees.d.ts +112 -0
  19. package/dist/types/working-tree-mirror.d.ts +24 -0
  20. package/dist/types/workspace-git-sync.d.ts +97 -0
  21. package/dist/types/workspace-incident-state.d.ts +0 -17
  22. package/dist/types/workspace-mutation-gate.d.ts +3 -3
  23. package/package.json +1 -1
  24. package/dist/cjs/workspace-convergence.cjs +0 -280
  25. package/dist/cjs/workspace-manifest-admission.cjs +0 -60
  26. package/dist/cjs/workspace-sync.cjs +0 -2469
  27. package/dist/mjs/workspace-convergence.mjs +0 -236
  28. package/dist/mjs/workspace-manifest-admission.mjs +0 -26
  29. package/dist/mjs/workspace-sync.mjs +0 -2417
  30. package/dist/types/workspace-convergence.d.ts +0 -93
  31. package/dist/types/workspace-manifest-admission.d.ts +0 -22
  32. package/dist/types/workspace-sync.d.ts +0 -167
@@ -1,93 +0,0 @@
1
- export declare const WORKSPACE_PUBLICATION_QUIET_MS = 5000;
2
- export declare const WORKSPACE_IDLE_SAFETY_SCAN_MS = 60000;
3
- export type WorkspacePublicationState = "idle" | "scheduled" | "preparing" | "submitting" | "blocked";
4
- export type WorkspaceConvergenceSnapshot = {
5
- localHead: string | null;
6
- desiredCanonicalHead: string | null;
7
- dirtyGeneration: number;
8
- publishedGeneration: number;
9
- publicationState: WorkspacePublicationState;
10
- };
11
- export type ExplicitWorkspacePublication<TTrigger> = {
12
- requestId: string;
13
- trigger: TTrigger;
14
- };
15
- export type WorkspaceManifestRevisionToken = {
16
- sequence: number;
17
- revision: string;
18
- };
19
- export declare class WorkspaceManifestRevisionFence {
20
- private sequence;
21
- private requestedRevision;
22
- private completedRevision;
23
- begin(revision: string): WorkspaceManifestRevisionToken;
24
- isCurrent(token: WorkspaceManifestRevisionToken): boolean;
25
- complete(token: WorkspaceManifestRevisionToken): boolean;
26
- readyRevision(): string | null;
27
- }
28
- export declare function workspacePublicationTelemetry(input: {
29
- requestedAt: number;
30
- prepareStartedAt: number;
31
- synchronizeStartedAt: number;
32
- finishedAt: number;
33
- }): {
34
- totalMs: number;
35
- queueMs: number;
36
- prepareMs: number;
37
- synchronizeMs: number;
38
- };
39
- export declare function workspacePublicationIncidentAction(requestId: string | undefined): "defer_automatic" | "request_terminal_authority";
40
- export declare class ExplicitWorkspacePublicationQueue<TTrigger> {
41
- private scheduled;
42
- private readonly queued;
43
- schedule(publication: ExplicitWorkspacePublication<TTrigger>, pendingRequestId?: string): boolean;
44
- hasScheduled(): boolean;
45
- consumeScheduled(requestId: string): void;
46
- enqueue(publication: ExplicitWorkspacePublication<TTrigger>, pendingRequestId?: string): void;
47
- next(): ExplicitWorkspacePublication<TTrigger> | undefined;
48
- }
49
- type PersistedWorkspaceConvergenceState = Omit<WorkspaceConvergenceSnapshot, "publicationState"> & {
50
- visibleBaselineHead: string | null;
51
- };
52
- export declare function readWorkspaceConvergenceState(statePath: string): PersistedWorkspaceConvergenceState;
53
- export declare class WorkspaceConvergenceState {
54
- private readonly statePath;
55
- private state;
56
- private publicationState;
57
- constructor(statePath: string);
58
- snapshot(): WorkspaceConvergenceSnapshot;
59
- visibleBaselineHead(): string | null;
60
- setLocalHead(localHead: string | null): void;
61
- setVisibleBaselineHead(visibleBaselineHead: string | null): void;
62
- observeCanonicalHead(canonicalHead: string | null): boolean;
63
- markDirty(): number;
64
- schedule(): void;
65
- beginPreparing(): void;
66
- beginSubmitting(): void;
67
- defer(): void;
68
- block(): void;
69
- releaseBlock(): void;
70
- observeIncidentState(blocked: boolean): void;
71
- resetTransientPublicationState(): void;
72
- complete(input: {
73
- generation: number;
74
- canonicalHead: string | null;
75
- published: boolean;
76
- }): void;
77
- private persist;
78
- }
79
- export declare function processWorkspaceConvergenceState(statePath: string): WorkspaceConvergenceState;
80
- export declare function workspaceBootstrapEstablishesVisibleBaseline(input: {
81
- hydrated: boolean;
82
- firstBootstrap: boolean;
83
- incidentActive: boolean;
84
- currentLocalHead: string | null;
85
- currentVisibleBaselineHead: string | null;
86
- }): boolean;
87
- export declare function waitForWorkspacePublicationOnShutdown(input: {
88
- snapshot: () => WorkspaceConvergenceSnapshot;
89
- forcePublication: () => void;
90
- timeoutMs?: number;
91
- pollMs?: number;
92
- }): Promise<"settled" | "blocked" | "timed_out">;
93
- export {};
@@ -1,22 +0,0 @@
1
- export type WorkspaceManifestCheckout = {
2
- projectId: string;
3
- checkoutPathSegments: [namespace: string, project: string];
4
- branches: string[];
5
- };
6
- export type WorkspaceManifestFilesystemState = {
7
- firstBootstrap: boolean;
8
- missingCheckouts: Array<{
9
- projectId: string;
10
- branchName: string;
11
- }>;
12
- };
13
- /**
14
- * Inspects manifest-related filesystem state without reserving visible paths.
15
- * Missing checkouts are target-specific pending work and hydrate
16
- * opportunistically without delaying unrelated targets or running commands.
17
- */
18
- export declare function inspectWorkspaceManifestFilesystem(input: {
19
- projectsRoot: string;
20
- workspaceShadowRoot: string;
21
- projects: WorkspaceManifestCheckout[];
22
- }): WorkspaceManifestFilesystemState;
@@ -1,167 +0,0 @@
1
- import { type CheckoutPathSegments } from "./managed-paths";
2
- import { type WorkspaceMutationLease } from "./workspace-mutation-gate";
3
- export declare const WORKSPACE_BRANCH = "main";
4
- export declare const WORKSPACE_INTENT_REF_PREFIX = "refs/r5d/workspace-intents/";
5
- export declare const WORKSPACE_PUBLICATION_REF_PREFIX = "refs/r5d/workspace-publications/";
6
- export declare const MAX_WORKSPACE_SYNC_DIFF_BYTES: number;
7
- export type WorkspaceProjectManifestEntry = {
8
- projectId: string;
9
- checkoutPathSegments: CheckoutPathSegments;
10
- projectPath: string;
11
- repoHttpUrl: string | null;
12
- repoAuthHeader: string | null;
13
- defaultBranch: string;
14
- branches: string[];
15
- canonicalCheckouts: Array<{
16
- branchName: string;
17
- scaffoldCommitHash: string;
18
- }>;
19
- };
20
- export type WorkspaceSyncTrigger = {
21
- type: "connect" | "inbound_head" | "write" | "edit" | "shell_inline" | "process_terminal" | "process_cancel" | "periodic" | "manual" | "remediation" | "remediation_confirm" | "remediation_reset";
22
- sessionId?: string;
23
- processRunId?: string;
24
- toolCallId?: string;
25
- projectId?: string;
26
- branchName?: string;
27
- /**
28
- * Restricts this synchronization to the exact canonical resolver checkout
29
- * identified by projectId/branchName. Ordinary synchronization never reads
30
- * or writes canonical resolver checkout subtrees.
31
- */
32
- canonicalCheckoutOnly?: boolean;
33
- detail?: string;
34
- };
35
- export type WorkspaceSyncOutcome = "no_change" | "candidate_ready" | "published" | "updated" | "conflict_reset" | "large_diff_blocked" | "conflict_blocked" | "reset" | "failed";
36
- export type WorkspaceSyncResult = {
37
- type: "workspace_sync";
38
- attemptId: string;
39
- workerLabel: string;
40
- trigger: WorkspaceSyncTrigger;
41
- outcome: WorkspaceSyncOutcome;
42
- startingHead: string | null;
43
- expectedHead?: string | null;
44
- candidateHead?: string;
45
- quarantineRef?: string;
46
- publishedHead?: string;
47
- rebaseCount: number;
48
- diffSizeBytes: number;
49
- gitStatus: string;
50
- affectedProjects: string[];
51
- affectedPaths: string[];
52
- discardedPaths: string[];
53
- localChangesDiscarded: boolean;
54
- dirtyGeneration?: number;
55
- sampledCanonicalCheckoutTreeHash?: string;
56
- telemetry?: {
57
- totalMs: number;
58
- queueMs: number;
59
- prepareMs: number;
60
- synchronizeMs: number;
61
- };
62
- error?: string;
63
- };
64
- export type WorkspaceSyncInput = {
65
- attemptId?: string;
66
- workerLabel: string;
67
- remoteUrl: string;
68
- authHeader?: string;
69
- projectsRoot: string;
70
- plansRoot: string;
71
- shadowRoot: string;
72
- projects: WorkspaceProjectManifestEntry[];
73
- trigger: WorkspaceSyncTrigger;
74
- /**
75
- * Server-issued, attempt-scoped destination for candidate object uploads.
76
- * Workers never publish the canonical workspace branch directly.
77
- */
78
- quarantineRef?: string;
79
- /** Exact canonical head fenced by publication authority. */
80
- expectedCanonicalHead?: string | null;
81
- /** Elected incident candidate pinned only while preparing remediation. */
82
- expectedIncidentCandidateHead?: string;
83
- /**
84
- * Commit whose tree the visible workspace most recently reflected.
85
- * Exact remediation may advance the disposable shadow checkout without
86
- * hydrating visible files. A later visible snapshot must therefore rebuild
87
- * its delta from this durable baseline before rebasing onto canonical main.
88
- */
89
- visibleBaselineHead?: string | null;
90
- confirmedLargeDiff?: boolean;
91
- confirmationReason?: string;
92
- resetToCanonical?: boolean;
93
- skipVisibleMirror?: boolean;
94
- newVisibleCheckouts?: Array<{
95
- projectId: string;
96
- branchName: string;
97
- }>;
98
- };
99
- export declare function encodeWorkspaceBranch(branchName: string): string;
100
- /**
101
- * Treat canonical resolver checkouts as a separate synchronization authority.
102
- * Generic workspace scans omit them; an explicitly scoped request contains
103
- * exactly one resolver checkout and no sibling branches.
104
- */
105
- export declare function workspaceProjectsForSync(projects: readonly WorkspaceProjectManifestEntry[], trigger: WorkspaceSyncTrigger): WorkspaceProjectManifestEntry[];
106
- export declare function workspaceProjectBranchRelativePath(projectId: string, branchName: string): string;
107
- export declare function workspacePlansRelativePath(projectId: string, branchName: string): string;
108
- export declare const WORKSPACE_NATIVE_PLANS_RELATIVE_PATH = "workspace-plans";
109
- export declare function visibleProjectBranchPath(projectsRoot: string, manifest: WorkspaceProjectManifestEntry, branchName: string): string;
110
- type GitlinkEntry = {
111
- filePath: string;
112
- objectId: string;
113
- };
114
- type VisibleHydrationEntry = {
115
- kind: "blob";
116
- mode: "100644" | "100755" | "120000";
117
- objectId: string;
118
- } | {
119
- kind: "gitlink";
120
- objectId: string;
121
- };
122
- type VisibleHydrationPreimage = Map<string, VisibleHydrationEntry>;
123
- type VisibleHydrationPreimages = Map<string, VisibleHydrationPreimage | null>;
124
- type GitlinkProjection = {
125
- entries: GitlinkEntry[];
126
- opaqueRoots: string[];
127
- visiblePreimages?: VisibleHydrationPreimages;
128
- };
129
- export declare function assertCanonicalCheckoutIndexMatchesWorktree(checkoutPath: string): void;
130
- export declare function mirrorVisibleWorkspaceToShadow(input: WorkspaceSyncInput, excludedCheckouts?: ReadonlySet<string>): GitlinkProjection;
131
- export declare function mirrorShadowWorkspaceToVisible(input: WorkspaceSyncInput, opaqueWorkspaceRoots?: readonly string[], hydrationPreimages?: VisibleHydrationPreimages): void;
132
- export declare function assertWorkspaceQuarantineRef(quarantineRef: string): void;
133
- export declare function synchronizeWorkspace(rawInput: WorkspaceSyncInput): Promise<WorkspaceSyncResult>;
134
- export type WorkspaceHeadConvergenceResult = {
135
- localHead: string | null;
136
- canonicalHead: string | null;
137
- localChanges: boolean;
138
- hydrated: boolean;
139
- hydrationConflicts: string[];
140
- };
141
- /**
142
- * Fetches the newest canonical head without treating an inbound overlap as an
143
- * incident. A busy caller passes hydrateVisible=false, which updates only the
144
- * remote-tracking ref. An idle caller may hydrate only after proving that its
145
- * visible tree still matches the local workspace head.
146
- */
147
- export declare function convergeWorkspaceHead(rawInput: WorkspaceSyncInput, options: {
148
- hydrateVisible: boolean;
149
- }): Promise<WorkspaceHeadConvergenceResult>;
150
- /** Returns a local-only fingerprint. Unlike the legacy periodic observation it
151
- * deliberately ignores whether origin/main has advanced. */
152
- export declare function calculateWorkspaceLocalDiffFingerprint(rawInput: WorkspaceSyncInput): string;
153
- export declare function calculateWorkspaceDiffFingerprint(rawInput: WorkspaceSyncInput): string;
154
- export declare class WorkspaceSyncSingleFlight {
155
- private readonly mutationGate;
156
- private queue;
157
- private enqueue;
158
- run(input: WorkspaceSyncInput): Promise<WorkspaceSyncResult>;
159
- runPrepared(prepare: () => WorkspaceSyncInput): Promise<WorkspaceSyncResult>;
160
- fingerprint(input: WorkspaceSyncInput): Promise<string>;
161
- fingerprintPrepared(prepare: () => WorkspaceSyncInput): Promise<string>;
162
- runExclusive<T>(operation: () => Promise<T> | T): Promise<T>;
163
- runMutation<T>(operation: () => Promise<T> | T): Promise<T>;
164
- acquireMutation(): Promise<WorkspaceMutationLease>;
165
- afterCurrent(): Promise<void>;
166
- }
167
- export {};