@hearsay-tools/squawk 0.19.0-dev.9162 → 0.19.0-dev.9168
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/dist/delegation/routes.d.ts +78 -78
- package/dist/delegation/workspace-removal.d.ts +1 -1
- package/dist/delegation/workspace-removal.js +1 -1
- package/dist/delegation/workspace-removal.js.map +1 -1
- package/dist/features/hosts/routes.d.ts +44 -44
- package/dist/features/webhooks/routes.d.ts +38 -38
- package/dist/git-command.d.ts +11 -0
- package/dist/git-command.js +14 -0
- package/dist/git-command.js.map +1 -1
- package/dist/git-worktree-claims.d.ts +96 -0
- package/dist/git-worktree-claims.js +219 -0
- package/dist/git-worktree-claims.js.map +1 -0
- package/dist/git-worktree-lock.d.ts +4 -3
- package/dist/git-worktree-lock.js +220 -66
- package/dist/git-worktree-lock.js.map +1 -1
- package/dist/server/models-routes.d.ts +12 -12
- package/dist/server/providers-routes.d.ts +58 -58
- package/dist/server/runners-routes.d.ts +10 -10
- package/dist/server/workspace-live-routes.d.ts +5 -5
- package/dist/server/workspace-routes.d.ts +85 -85
- package/package.json +4 -4
- package/web/dist/assets/{accounts-section-m_1ntZJh.js → accounts-section-Bnr89jmC.js} +1 -1
- package/web/dist/assets/{activity-motion-DDqgr8eF.js → activity-motion-BW0tAmYF.js} +1 -1
- package/web/dist/assets/{activity-route-BlEZZxyI.js → activity-route-C2zP5vVV.js} +1 -1
- package/web/dist/assets/{agent-config-section-wICtFVks.js → agent-config-section-CwK_izpU.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-BC9Ypg0g.js → agent-defaults-section-RyEogH0g.js} +1 -1
- package/web/dist/assets/{appearance-fkDdWPlG.js → appearance-DvoRcoRX.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-B6kX09p-.js → archive-on-merge-field-DWPtF9dh.js} +1 -1
- package/web/dist/assets/ask-card-D-om0EtP.js +9 -0
- package/web/dist/assets/{automations-route-BfOpJjLK.js → automations-route-DfGE4xWT.js} +1 -1
- package/web/dist/assets/{commit-list-StLehTiQ.js → commit-list-CPJLP4DU.js} +1 -1
- package/web/dist/assets/{diff-DEw-tkVq.js → diff-BQJN6jzN.js} +2 -2
- package/web/dist/assets/{diff-controls-CSO8HgZ0.js → diff-controls-AsSX7gfO.js} +1 -1
- package/web/dist/assets/{diff-view-BcU4Rnuo.js → diff-view-BW5bbiaq.js} +1 -1
- package/web/dist/assets/{discard-changes-dialog-BEsdWdyJ.js → discard-changes-dialog-Bv4yc0N1.js} +1 -1
- package/web/dist/assets/{file-preview-_4nAs_Ai.js → file-preview-CnrFxbea.js} +1 -1
- package/web/dist/assets/{git-toolbar-DXnIUFi1.js → git-toolbar-C7iolhIi.js} +1 -1
- package/web/dist/assets/{github-g-Ykk4uE.js → github-DGElvfMU.js} +1 -1
- package/web/dist/assets/{global-activity-route-OsAvUny-.js → global-activity-route-Dijwg4OL.js} +1 -1
- package/web/dist/assets/index-BVRdRJAN.css +1 -0
- package/web/dist/assets/{index-Dp7K74Jw.js → index-DPfg7xSB.js} +4 -4
- package/web/dist/assets/{markdown-BB-PN03o.js → markdown-Cljq4S1h.js} +1 -1
- package/web/dist/assets/{option-select-Bmm4ktgQ.js → option-select-BcTkv-7t.js} +1 -1
- package/web/dist/assets/{preferences-section-dKDCZSWD.js → preferences-section-CEKXGhEj.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-DBbCXW1b.js → preview-pane-connected-CKRBfx7t.js} +1 -1
- package/web/dist/assets/{project-location-DJjcFmsE.js → project-location-hufc_p8y.js} +1 -1
- package/web/dist/assets/{projects-section-CVFyzORg.js → projects-section-vOFZ4lbx.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-Jj1YbCwG.js → prompt-templates-section-Caash2nq.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-Czl9yS5W.js → remote-settings-notice-fNgh5LdN.js} +1 -1
- package/web/dist/assets/{repo-git-C9N9wa5l.js → repo-git-5MK_RAR6.js} +1 -1
- package/web/dist/assets/{report-reader-Ci4sWoe1.js → report-reader-CK1WDtEH.js} +1 -1
- package/web/dist/assets/{reports-CQPRtR5G.js → reports-B-GImLAo.js} +1 -1
- package/web/dist/assets/{resources-section-lLpdP6MD.js → resources-section-ApF3gXrw.js} +1 -1
- package/web/dist/assets/{review-notes-drafts-BjXqp0gY.js → review-notes-drafts-BdjEFs1G.js} +1 -1
- package/web/dist/assets/{review-panel-B4dp-Rol.js → review-panel-D4zmYH8O.js} +1 -1
- package/web/dist/assets/{review-strip-BE71YjB6.js → review-strip-BpHXklAn.js} +1 -1
- package/web/dist/assets/{run-header-DvbVw3uo.js → run-header-BUe92WWr.js} +1 -1
- package/web/dist/assets/{select-CYo1lo6a.js → select-CwDhRDtw.js} +1 -1
- package/web/dist/assets/{session-context-section-B_NEOGby.js → session-context-section-C87jx7RB.js} +1 -1
- package/web/dist/assets/{settings-agent-picker-DeAST7qR.js → settings-agent-picker-Dk8yJ57U.js} +1 -1
- package/web/dist/assets/{settings-save-bar-Dd3bTznK.js → settings-save-bar-cu8BKCGT.js} +1 -1
- package/web/dist/assets/{settings-shell-Bt7NYun7.js → settings-shell-mhQfQKf1.js} +1 -1
- package/web/dist/assets/{sidebar-section-DdrFJBTL.js → sidebar-section-DOQ5N1L6.js} +1 -1
- package/web/dist/assets/{skills-DNCuhhKf.js → skills-DXJ1gQBD.js} +1 -1
- package/web/dist/assets/{task-changes-CdAzeh9M.js → task-changes-D9Sdmpmw.js} +1 -1
- package/web/dist/assets/{task-commits-CzZJZj2x.js → task-commits-A0UIqxpL.js} +1 -1
- package/web/dist/assets/{task-file-scope-BuFeMG6a.js → task-file-scope-ID220XKo.js} +1 -1
- package/web/dist/assets/{task-files-BFdMVAb3.js → task-files-Id2tuAAG.js} +1 -1
- package/web/dist/assets/{task-github-item-Dv0Uflz7.js → task-github-item-YKUcwp2o.js} +1 -1
- package/web/dist/assets/task-thread-A_vkygGX.js +2 -0
- package/web/dist/assets/{task-thread-a6CXLxwn.css → task-thread-BObu0KsD.css} +1 -1
- package/web/dist/assets/{thread-state-DqBwIoCM.js → thread-state-6-BzRrJ_.js} +1 -1
- package/web/dist/assets/{use-finish-run-CFEVvqeg.js → use-finish-run-DO-nnAaa.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-BYN578_s.js → use-hand-to-agent-state-CADaL8U8.js} +1 -1
- package/web/dist/assets/use-path-bases-CFAmFn_E.js +1 -0
- package/web/dist/assets/{workflows-IT5WTfLr.js → workflows-DOLG-Rns.js} +1 -1
- package/web/dist/assets/{workspace-tools-D_opTe6D.js → workspace-tools-DTCJVDTE.js} +1 -1
- package/web/dist/assets/{worktrees-section-B8ycJMoK.js → worktrees-section-BOHDbywt.js} +1 -1
- package/web/dist/index.html +2 -2
- package/dist/git-worktree-lock-helper.d.ts +0 -30
- package/dist/git-worktree-lock-helper.js +0 -300
- package/dist/git-worktree-lock-helper.js.map +0 -1
- package/web/dist/assets/ask-card-Cue5EajQ.js +0 -9
- package/web/dist/assets/index-D_WkVdwL.css +0 -1
- package/web/dist/assets/task-thread-C98mqSie.js +0 -2
- package/web/dist/assets/use-path-bases-B238cLk1.js +0 -1
|
@@ -100,18 +100,6 @@ export interface ProjectWebhooksRouteDeps {
|
|
|
100
100
|
export declare function createProjectWebhooksRoutes(deps: ProjectWebhooksRouteDeps): import("hono/hono-base").HonoBase<ProjectApiEnv, {
|
|
101
101
|
"/projects/:projectId/webhook/test": {
|
|
102
102
|
$post: {
|
|
103
|
-
output: {
|
|
104
|
-
error: string;
|
|
105
|
-
code?: "no-boot-project" | undefined;
|
|
106
|
-
};
|
|
107
|
-
outputFormat: "json";
|
|
108
|
-
status: 404 | 409;
|
|
109
|
-
input: {
|
|
110
|
-
param: {
|
|
111
|
-
projectId: string;
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
} | {
|
|
115
103
|
output: {
|
|
116
104
|
error: string;
|
|
117
105
|
};
|
|
@@ -136,33 +124,23 @@ export declare function createProjectWebhooksRoutes(deps: ProjectWebhooksRouteDe
|
|
|
136
124
|
projectId: string;
|
|
137
125
|
};
|
|
138
126
|
};
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
} & {
|
|
142
|
-
"/projects/:projectId/webhooks": {
|
|
143
|
-
$post: {
|
|
127
|
+
} | {
|
|
144
128
|
output: {
|
|
145
129
|
error: string;
|
|
146
130
|
code?: "no-boot-project" | undefined;
|
|
147
131
|
};
|
|
148
132
|
outputFormat: "json";
|
|
149
|
-
status:
|
|
133
|
+
status: 404 | 409;
|
|
150
134
|
input: {
|
|
151
|
-
json: {
|
|
152
|
-
name: string;
|
|
153
|
-
description?: string | undefined;
|
|
154
|
-
url: string;
|
|
155
|
-
token?: string | undefined;
|
|
156
|
-
tasks?: boolean | undefined;
|
|
157
|
-
triggers?: ("cancelled" | "done" | "failed" | "needs-you" | "running" | "waiting-ci" | "waiting-other" | "waiting-timer" | "waiting-workers")[] | undefined;
|
|
158
|
-
agent?: boolean | undefined;
|
|
159
|
-
};
|
|
160
|
-
} & {
|
|
161
135
|
param: {
|
|
162
136
|
projectId: string;
|
|
163
137
|
};
|
|
164
138
|
};
|
|
165
|
-
}
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
} & {
|
|
142
|
+
"/projects/:projectId/webhooks": {
|
|
143
|
+
$post: {
|
|
166
144
|
output: {
|
|
167
145
|
project: {
|
|
168
146
|
id: string;
|
|
@@ -221,6 +199,28 @@ export declare function createProjectWebhooksRoutes(deps: ProjectWebhooksRouteDe
|
|
|
221
199
|
projectId: string;
|
|
222
200
|
};
|
|
223
201
|
};
|
|
202
|
+
} | {
|
|
203
|
+
output: {
|
|
204
|
+
error: string;
|
|
205
|
+
code?: "no-boot-project" | undefined;
|
|
206
|
+
};
|
|
207
|
+
outputFormat: "json";
|
|
208
|
+
status: 400 | 404 | 409 | 500;
|
|
209
|
+
input: {
|
|
210
|
+
json: {
|
|
211
|
+
name: string;
|
|
212
|
+
description?: string | undefined;
|
|
213
|
+
url: string;
|
|
214
|
+
token?: string | undefined;
|
|
215
|
+
tasks?: boolean | undefined;
|
|
216
|
+
triggers?: ("cancelled" | "done" | "failed" | "needs-you" | "running" | "waiting-ci" | "waiting-other" | "waiting-timer" | "waiting-workers")[] | undefined;
|
|
217
|
+
agent?: boolean | undefined;
|
|
218
|
+
};
|
|
219
|
+
} & {
|
|
220
|
+
param: {
|
|
221
|
+
projectId: string;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
224
|
};
|
|
225
225
|
};
|
|
226
226
|
} & {
|
|
@@ -420,13 +420,10 @@ export declare function createProjectWebhooksRoutes(deps: ProjectWebhooksRouteDe
|
|
|
420
420
|
};
|
|
421
421
|
} | {
|
|
422
422
|
output: {
|
|
423
|
-
|
|
424
|
-
status?: number | undefined;
|
|
425
|
-
error?: string | undefined;
|
|
426
|
-
dryRun?: boolean | undefined;
|
|
423
|
+
error: string;
|
|
427
424
|
};
|
|
428
425
|
outputFormat: "json";
|
|
429
|
-
status:
|
|
426
|
+
status: 404;
|
|
430
427
|
input: {
|
|
431
428
|
param: {
|
|
432
429
|
projectId: string;
|
|
@@ -435,11 +432,13 @@ export declare function createProjectWebhooksRoutes(deps: ProjectWebhooksRouteDe
|
|
|
435
432
|
};
|
|
436
433
|
} | {
|
|
437
434
|
output: {
|
|
438
|
-
|
|
439
|
-
|
|
435
|
+
ok: boolean;
|
|
436
|
+
status?: number | undefined;
|
|
437
|
+
error?: string | undefined;
|
|
438
|
+
dryRun?: boolean | undefined;
|
|
440
439
|
};
|
|
441
440
|
outputFormat: "json";
|
|
442
|
-
status:
|
|
441
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
443
442
|
input: {
|
|
444
443
|
param: {
|
|
445
444
|
projectId: string;
|
|
@@ -449,9 +448,10 @@ export declare function createProjectWebhooksRoutes(deps: ProjectWebhooksRouteDe
|
|
|
449
448
|
} | {
|
|
450
449
|
output: {
|
|
451
450
|
error: string;
|
|
451
|
+
code?: "no-boot-project" | undefined;
|
|
452
452
|
};
|
|
453
453
|
outputFormat: "json";
|
|
454
|
-
status: 404;
|
|
454
|
+
status: 404 | 409;
|
|
455
455
|
input: {
|
|
456
456
|
param: {
|
|
457
457
|
projectId: string;
|
package/dist/git-command.d.ts
CHANGED
|
@@ -44,5 +44,16 @@ export type SpawnGitOptions = Omit<SpawnOptions, 'env'> & GitEnvOptions;
|
|
|
44
44
|
/** Start git for a caller that reads its streams or owns its lifetime. */
|
|
45
45
|
export declare function spawnGit(args: readonly string[], options: Omit<SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>, 'env'> & GitEnvOptions): ChildProcessByStdio<null, Readable, Readable>;
|
|
46
46
|
export declare function spawnGit(args: readonly string[], options?: SpawnGitOptions): ChildProcess;
|
|
47
|
+
/**
|
|
48
|
+
* Start git, POSIX only, as the leader of a new process group (its PID is the group id), held at
|
|
49
|
+
* a gate: git runs only after the caller ends the pipe at `stdio[3]` with a line. The worktree
|
|
50
|
+
* mutation lock records the group before it opens the gate (ADR 0076).
|
|
51
|
+
*/
|
|
52
|
+
export declare function spawnGatedGit(args: readonly string[], options: {
|
|
53
|
+
cwd: string;
|
|
54
|
+
stdin: number | 'ignore';
|
|
55
|
+
stdout: number;
|
|
56
|
+
stderr: number;
|
|
57
|
+
}): ChildProcess;
|
|
47
58
|
/** Run git in `cwd`, never throw — degradation is the caller's policy. */
|
|
48
59
|
export declare function git(cwd: string, args: string[], options?: GitOptions): Promise<GitResult>;
|
package/dist/git-command.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { execFile, execFileSync, spawn, } from 'node:child_process';
|
|
2
|
+
import { spawnDetached } from './detached-process.js';
|
|
2
3
|
const MAX_BUFFER_MIB = 32;
|
|
3
4
|
/** The reason a caller reports when `overflow` is true. */
|
|
4
5
|
export const GIT_OVERFLOW_REASON = `the diff is too large: git output is over the ${MAX_BUFFER_MIB} MiB limit`;
|
|
@@ -41,6 +42,19 @@ export function gitSync(args, options = {}) {
|
|
|
41
42
|
export function spawnGit(args, options = {}) {
|
|
42
43
|
return spawn('git', args, withGitEnv(options));
|
|
43
44
|
}
|
|
45
|
+
/** sh holds git at this gate until its caller writes a line to fd 3. A caller that dies first
|
|
46
|
+
* closes the pipe: `read` fails, sh exits 125, and git never starts. */
|
|
47
|
+
const GIT_GATE = 'IFS= read -r go <&3 || exit 125; exec 3<&-; exec git "$@"';
|
|
48
|
+
/**
|
|
49
|
+
* Start git, POSIX only, as the leader of a new process group (its PID is the group id), held at
|
|
50
|
+
* a gate: git runs only after the caller ends the pipe at `stdio[3]` with a line. The worktree
|
|
51
|
+
* mutation lock records the group before it opens the gate (ADR 0076).
|
|
52
|
+
*/
|
|
53
|
+
export function spawnGatedGit(args, options) {
|
|
54
|
+
return spawnDetached('/bin/sh', ['-c', GIT_GATE, 'git', ...args], {
|
|
55
|
+
cwd: options.cwd, env: gitEnv(), stdio: [options.stdin, options.stdout, options.stderr, 'pipe'],
|
|
56
|
+
});
|
|
57
|
+
}
|
|
44
58
|
/** Run git in `cwd`, never throw — degradation is the caller's policy. */
|
|
45
59
|
export function git(cwd, args, options = {}) {
|
|
46
60
|
return new Promise((resolve) => {
|
package/dist/git-command.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-command.js","sourceRoot":"","sources":["../src/git-command.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAAE,YAAY,EAAE,KAAK,GAG9B,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"git-command.js","sourceRoot":"","sources":["../src/git-command.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAAE,YAAY,EAAE,KAAK,GAG9B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAiBtD,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,2DAA2D;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,iDAAiD,cAAc,YAA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;YACE,GAAG;YACH,QAAQ,EAAE,MAAM;YAChB,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,cAAc,GAAG,IAAI,GAAG,IAAI;YAC5D,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;SACzB,EACD,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC;YAC/B,EAAE,EAAE,CAAC,GAAG;YACR,MAAM,EAAE,MAAM,IAAI,EAAE;YACpB,MAAM,EAAE,MAAM,IAAI,EAAE;YACpB,QAAQ,EAAE,GAAG,EAAE,IAAI,KAAK,mCAAmC;SAC5D,CAAC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { type RecordedProcess } from './core/process-stat.ts';
|
|
2
|
+
/** What a claim says about its owner, so a waiter that times out can name who holds the lock. */
|
|
3
|
+
export type MutationLabel = {
|
|
4
|
+
operation: string;
|
|
5
|
+
owner?: string;
|
|
6
|
+
};
|
|
7
|
+
/** The claim a timed-out waiter names: the one whose turn it is. */
|
|
8
|
+
export type MutationHolder = {
|
|
9
|
+
pid: number;
|
|
10
|
+
operation?: string;
|
|
11
|
+
owner?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A claim held for a process group (ADR 0076): live while any member of group `pid` lives. Keepers
|
|
15
|
+
* before ADR 0076 wrote this shape for themselves; a caller writes it when it leaves a timed-out
|
|
16
|
+
* command's surviving children behind.
|
|
17
|
+
*/
|
|
18
|
+
type GroupClaim = {
|
|
19
|
+
pid: number;
|
|
20
|
+
ticket: number;
|
|
21
|
+
gitRunning: boolean;
|
|
22
|
+
operation?: string;
|
|
23
|
+
owner?: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A claim held by its caller (ADR 0076): live while process `caller` lives (the same process when
|
|
27
|
+
* `start` matches), or while a member of `group`, the running Git command's process group, lives.
|
|
28
|
+
* It has no `pid`, so a version that knows only group claims refuses it instead of reclaiming it.
|
|
29
|
+
*/
|
|
30
|
+
type CallerClaim = {
|
|
31
|
+
caller: number;
|
|
32
|
+
start?: string;
|
|
33
|
+
ticket: number;
|
|
34
|
+
gitRunning: boolean;
|
|
35
|
+
group?: number;
|
|
36
|
+
operation?: string;
|
|
37
|
+
owner?: string;
|
|
38
|
+
};
|
|
39
|
+
type Claim = GroupClaim | CallerClaim;
|
|
40
|
+
/** How a reader tests processes: `probe` is `kill(pid, 0)` (`-pgid` for a group); `processLive` says
|
|
41
|
+
* whether one recorded process incarnation still runs. */
|
|
42
|
+
export type ClaimHost = {
|
|
43
|
+
platform: NodeJS.Platform;
|
|
44
|
+
probe: (pid: number) => void;
|
|
45
|
+
processLive: (process: RecordedProcess) => boolean;
|
|
46
|
+
};
|
|
47
|
+
export declare const processHost: ClaimHost;
|
|
48
|
+
/** Whether `kill(pid, 0)` leaves the process (or `-pgid`, the group) possibly alive: only ESRCH proves it gone. */
|
|
49
|
+
export declare function mayExist(probe: (pid: number) => void, pid: number): boolean;
|
|
50
|
+
/** The files a claim's Git commands write beside it: `.json` claim, `.in`, `.out` and `.err`. */
|
|
51
|
+
export declare function claimFiles(path: string): {
|
|
52
|
+
in: string;
|
|
53
|
+
out: string;
|
|
54
|
+
err: string;
|
|
55
|
+
};
|
|
56
|
+
export declare function readMutationClaim(path: string, host: ClaimHost): Promise<Claim | undefined>;
|
|
57
|
+
/** How the queue tells time: tests pass a clock that moves only when it sleeps. */
|
|
58
|
+
export type ClaimClock = {
|
|
59
|
+
now: () => number;
|
|
60
|
+
sleep: (ms: number) => Promise<void>;
|
|
61
|
+
};
|
|
62
|
+
/** The longest any wait may last, its queue share included. */
|
|
63
|
+
export declare const MAX_QUEUED_WAIT_MS = 600000;
|
|
64
|
+
/** The wait budget for a claim with `ahead` claims queued before it: the base, plus `perClaimMs` for each, at most 10 min. */
|
|
65
|
+
export declare function queuedWaitBudget(waitMs: number, perClaimMs: number, ahead: number): number;
|
|
66
|
+
/** What a held claim says about the command it runs now: `group` is that command's process group. */
|
|
67
|
+
export type ClaimState = {
|
|
68
|
+
gitRunning: boolean;
|
|
69
|
+
group?: number;
|
|
70
|
+
};
|
|
71
|
+
/** A claim this process holds: its turn has come. */
|
|
72
|
+
export interface HeldClaim {
|
|
73
|
+
path: string;
|
|
74
|
+
/** Publish the running command's state; the caller opens a command's gate only after this resolves. */
|
|
75
|
+
write(state: ClaimState): Promise<void>;
|
|
76
|
+
/** Leave the claim to `group`: it stays until every member of that group is gone. */
|
|
77
|
+
leaveToGroup(group: number): Promise<void>;
|
|
78
|
+
/** Withdraw the claim and the files its commands wrote. */
|
|
79
|
+
release(): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Queue for the worktree mutation lock whose claims live in `directory`, and wait for this claim's
|
|
83
|
+
* turn. `waitMs` and `perClaimMs` are already checked; a timeout withdraws the claim.
|
|
84
|
+
*/
|
|
85
|
+
export declare function acquireMutationClaim(directory: string, options: {
|
|
86
|
+
waitMs: number;
|
|
87
|
+
perClaimMs: number;
|
|
88
|
+
label?: MutationLabel;
|
|
89
|
+
host?: ClaimHost;
|
|
90
|
+
clock?: ClaimClock;
|
|
91
|
+
}): Promise<{
|
|
92
|
+
claim: HeldClaim;
|
|
93
|
+
} | {
|
|
94
|
+
holder: MutationHolder;
|
|
95
|
+
}>;
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { processStartToken, recordedProcessLive } from './core/process-stat.js';
|
|
5
|
+
export const processHost = { platform: process.platform, probe: pid => { process.kill(pid, 0); }, processLive: recordedProcessLive };
|
|
6
|
+
/** Whether `kill(pid, 0)` leaves the process (or `-pgid`, the group) possibly alive: only ESRCH proves it gone. */
|
|
7
|
+
export function mayExist(probe, pid) {
|
|
8
|
+
try {
|
|
9
|
+
probe(pid);
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
return error.code !== 'ESRCH';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const safeId = (value, min) => Number.isSafeInteger(value) && value >= min;
|
|
17
|
+
async function readClaimFile(path) {
|
|
18
|
+
let value;
|
|
19
|
+
try {
|
|
20
|
+
value = JSON.parse(await fs.readFile(path, 'utf8'));
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (error.code === 'ENOENT')
|
|
24
|
+
return;
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
const valid = safeId(value.ticket, 0) && ('caller' in value
|
|
28
|
+
? safeId(value.caller, 1) && (value.group === undefined || safeId(value.group, 1))
|
|
29
|
+
: safeId(value.pid, 1));
|
|
30
|
+
if (!valid)
|
|
31
|
+
throw new Error('invalid worktree mutation claim');
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
/** The files a claim's Git commands write beside it: `.json` claim, `.in`, `.out` and `.err`. */
|
|
35
|
+
export function claimFiles(path) {
|
|
36
|
+
const stem = path.slice(0, -'.json'.length);
|
|
37
|
+
return { in: `${stem}.in`, out: `${stem}.out`, err: `${stem}.err` };
|
|
38
|
+
}
|
|
39
|
+
/** Remove a claim no process can still act for, and the files its Git commands wrote. Each
|
|
40
|
+
* claimant owns a unique filename, so this cannot remove a new owner's claim (the ABA race of one shared lockfile). */
|
|
41
|
+
async function discardClaim(path) {
|
|
42
|
+
const files = claimFiles(path);
|
|
43
|
+
await Promise.all([path, `${path}.tmp`, files.in, files.out, files.err].map(file => fs.unlink(file).catch(() => undefined)));
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
/** A group claim: on POSIX only ESRCH from the group probe proves every member gone. */
|
|
47
|
+
async function readGroupClaim(path, value, host) {
|
|
48
|
+
// POSIX group lifetime survives the death of its leader: Git and its children inherit the
|
|
49
|
+
// group. Do not replace this kernel probe with a PID/ps snapshot (forks can race it).
|
|
50
|
+
if (host.platform !== 'win32')
|
|
51
|
+
return mayExist(host.probe, -value.pid) ? value : discardClaim(path);
|
|
52
|
+
if (mayExist(host.probe, value.pid))
|
|
53
|
+
return value;
|
|
54
|
+
// Re-read AFTER death is established. The first idle snapshot may predate a last command's
|
|
55
|
+
// busy publication and spawn. The unique filename cannot now be updated by its dead owner.
|
|
56
|
+
const final = await readClaimFile(path);
|
|
57
|
+
if (!final)
|
|
58
|
+
return;
|
|
59
|
+
if ('pid' in final && final.pid === value.pid && final.gitRunning === false)
|
|
60
|
+
return discardClaim(path);
|
|
61
|
+
throw new Error('cannot prove a dead worktree keeper has no surviving Git children on Windows');
|
|
62
|
+
}
|
|
63
|
+
/** A live PID with another start is a new process that reused it, such as a restarted container's PID 1. */
|
|
64
|
+
const callerAlive = (claim, host) => host.processLive({ pid: claim.caller, ...(claim.start === undefined ? {} : { startToken: claim.start }) });
|
|
65
|
+
export async function readMutationClaim(path, host) {
|
|
66
|
+
const value = await readClaimFile(path);
|
|
67
|
+
if (!value)
|
|
68
|
+
return;
|
|
69
|
+
if (!('caller' in value))
|
|
70
|
+
return readGroupClaim(path, value, host);
|
|
71
|
+
if (callerAlive(value, host))
|
|
72
|
+
return value;
|
|
73
|
+
// Re-read AFTER the caller's death is established: a dead caller can no longer change its claim,
|
|
74
|
+
// and the first snapshot may predate the group it recorded for a Git command, or its rewrite
|
|
75
|
+
// into a group claim for a timed-out command's children.
|
|
76
|
+
const final = await readClaimFile(path);
|
|
77
|
+
if (!final)
|
|
78
|
+
return;
|
|
79
|
+
if (!('caller' in final))
|
|
80
|
+
return readGroupClaim(path, final, host);
|
|
81
|
+
if (host.platform === 'win32') {
|
|
82
|
+
if (final.gitRunning)
|
|
83
|
+
throw new Error('cannot prove a dead worktree mutation caller has no surviving Git children on Windows');
|
|
84
|
+
return discardClaim(path);
|
|
85
|
+
}
|
|
86
|
+
// A caller opens a command's gate only after recording its group: with none recorded, no Git
|
|
87
|
+
// it started can be running.
|
|
88
|
+
return final.group !== undefined && mayExist(host.probe, -final.group) ? final : discardClaim(path);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Lamport bakery: choose a ticket above every visible ticket.
|
|
92
|
+
* Atomic rename keeps readers from observing partial JSON.
|
|
93
|
+
*/
|
|
94
|
+
async function selectTicket(directory, name, read) {
|
|
95
|
+
let ticket = 1;
|
|
96
|
+
for (const entry of await fs.readdir(directory)) {
|
|
97
|
+
if (!entry.endsWith('.json') || entry === name)
|
|
98
|
+
continue;
|
|
99
|
+
const claim = await read(entry);
|
|
100
|
+
if (claim)
|
|
101
|
+
ticket = Math.max(ticket, claim.ticket + 1);
|
|
102
|
+
}
|
|
103
|
+
return ticket;
|
|
104
|
+
}
|
|
105
|
+
/** A peer holds the turn while it is still choosing or holds a smaller (ticket, name) pair. */
|
|
106
|
+
function hasPriority(claim, ticket, entry, name) {
|
|
107
|
+
return claim.ticket === 0 || claim.ticket < ticket || (claim.ticket === ticket && entry < name);
|
|
108
|
+
}
|
|
109
|
+
/** The blocker whose turn it is: the smallest (ticket, name) pair; a peer still choosing (ticket 0) only when no other blocks. */
|
|
110
|
+
function turnHolder(blockers) {
|
|
111
|
+
const order = (value) => value.claim.ticket === 0 ? Number.MAX_SAFE_INTEGER : value.claim.ticket;
|
|
112
|
+
const first = blockers.reduce((best, next) => order(next) - order(best) < 0 || (order(next) === order(best) && next.entry < best.entry) ? next : best);
|
|
113
|
+
const { operation, owner } = first.claim;
|
|
114
|
+
const pid = 'caller' in first.claim ? first.claim.caller : first.claim.pid;
|
|
115
|
+
return { pid, ...(typeof operation === 'string' ? { operation } : {}), ...(typeof owner === 'string' ? { owner } : {}) };
|
|
116
|
+
}
|
|
117
|
+
const realClock = { now: () => Date.now(), sleep: ms => new Promise(resolve => setTimeout(resolve, ms)) };
|
|
118
|
+
/** Wait for choosing peers and smaller (ticket, name) pairs, or give up naming the claim whose turn it is. */
|
|
119
|
+
async function waitForTurn(directory, name, ticket, options) {
|
|
120
|
+
for (;;) {
|
|
121
|
+
const late = options.clock.now() >= options.deadline;
|
|
122
|
+
const blockers = [];
|
|
123
|
+
for (const entry of await fs.readdir(directory)) {
|
|
124
|
+
if (!entry.endsWith('.json') || entry === name)
|
|
125
|
+
continue;
|
|
126
|
+
const claim = await options.read(entry);
|
|
127
|
+
if (claim && hasPriority(claim, ticket, entry, name))
|
|
128
|
+
blockers.push({ claim, entry });
|
|
129
|
+
// Before the deadline one blocker is enough; past it, read them all to name the right one.
|
|
130
|
+
if (blockers.length && !late)
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
const [head, ...rest] = blockers;
|
|
134
|
+
if (!head)
|
|
135
|
+
return { turn: 'ready' };
|
|
136
|
+
if (late)
|
|
137
|
+
return { turn: 'timeout', holder: turnHolder([head, ...rest]) };
|
|
138
|
+
await options.clock.sleep(25);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** The claims queued ahead of a ticket: those that can block it, a peer still choosing included.
|
|
142
|
+
* A peer that published a higher ticket before this count is behind it and does not count. */
|
|
143
|
+
async function claimsAhead(directory, name, ticket, read) {
|
|
144
|
+
let ahead = 0;
|
|
145
|
+
for (const entry of await fs.readdir(directory)) {
|
|
146
|
+
if (!entry.endsWith('.json') || entry === name)
|
|
147
|
+
continue;
|
|
148
|
+
const claim = await read(entry);
|
|
149
|
+
if (claim && hasPriority(claim, ticket, entry, name))
|
|
150
|
+
ahead += 1;
|
|
151
|
+
}
|
|
152
|
+
return ahead;
|
|
153
|
+
}
|
|
154
|
+
/** The longest any wait may last, its queue share included. */
|
|
155
|
+
export const MAX_QUEUED_WAIT_MS = 600_000;
|
|
156
|
+
/** The wait budget for a claim with `ahead` claims queued before it: the base, plus `perClaimMs` for each, at most 10 min. */
|
|
157
|
+
export function queuedWaitBudget(waitMs, perClaimMs, ahead) {
|
|
158
|
+
return Math.max(waitMs, Math.min(MAX_QUEUED_WAIT_MS, waitMs + perClaimMs * ahead));
|
|
159
|
+
}
|
|
160
|
+
/** A label as a claim stores it: a non-empty `operation` and an optional `owner`, each at most 80 characters. */
|
|
161
|
+
function claimLabel(label) {
|
|
162
|
+
if (!label)
|
|
163
|
+
return undefined;
|
|
164
|
+
if (typeof label.operation !== 'string' || !label.operation || (label.owner !== undefined && typeof label.owner !== 'string'))
|
|
165
|
+
throw new Error('invalid worktree mutation label');
|
|
166
|
+
return { operation: label.operation.slice(0, 80), ...(label.owner ? { owner: label.owner.slice(0, 80) } : {}) };
|
|
167
|
+
}
|
|
168
|
+
/** This process's own start, read once; `null` until then. */
|
|
169
|
+
let ownStart = null;
|
|
170
|
+
/**
|
|
171
|
+
* Queue for the worktree mutation lock whose claims live in `directory`, and wait for this claim's
|
|
172
|
+
* turn. `waitMs` and `perClaimMs` are already checked; a timeout withdraws the claim.
|
|
173
|
+
*/
|
|
174
|
+
export async function acquireMutationClaim(directory, options) {
|
|
175
|
+
const host = options.host ?? processHost;
|
|
176
|
+
const clock = options.clock ?? realClock;
|
|
177
|
+
const label = claimLabel(options.label);
|
|
178
|
+
if (ownStart === null)
|
|
179
|
+
ownStart = processStartToken(process.pid);
|
|
180
|
+
const start = ownStart;
|
|
181
|
+
const name = `${process.pid}-${randomUUID()}.json`;
|
|
182
|
+
const path = join(directory, name);
|
|
183
|
+
const temporary = `${path}.tmp`;
|
|
184
|
+
let ticket = 0;
|
|
185
|
+
const writeClaim = async (claim) => {
|
|
186
|
+
await fs.writeFile(temporary, JSON.stringify(claim), { mode: 0o600 });
|
|
187
|
+
await fs.rename(temporary, path);
|
|
188
|
+
};
|
|
189
|
+
const write = (state) => writeClaim({ caller: process.pid, ...(start ? { start } : {}), ticket, ...state, ...label });
|
|
190
|
+
const release = async () => { await discardClaim(path); };
|
|
191
|
+
const read = (entry) => readMutationClaim(join(directory, entry), host);
|
|
192
|
+
await fs.mkdir(directory, { recursive: true });
|
|
193
|
+
try {
|
|
194
|
+
// Lamport bakery: publish "choosing" atomically, then choose a ticket above every visible ticket.
|
|
195
|
+
await write({ gitRunning: false });
|
|
196
|
+
ticket = await selectTicket(directory, name, read);
|
|
197
|
+
await write({ gitRunning: false });
|
|
198
|
+
const budget = queuedWaitBudget(options.waitMs, options.perClaimMs, await claimsAhead(directory, name, ticket, read));
|
|
199
|
+
const turn = await waitForTurn(directory, name, ticket, { read, deadline: clock.now() + budget, clock });
|
|
200
|
+
if (turn.turn === 'timeout') {
|
|
201
|
+
// Withdraw ONLY this queued claim; no mutation was admitted.
|
|
202
|
+
await release();
|
|
203
|
+
return { holder: turn.holder };
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
await release();
|
|
208
|
+
throw error;
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
claim: {
|
|
212
|
+
path,
|
|
213
|
+
write,
|
|
214
|
+
leaveToGroup: group => writeClaim({ pid: group, ticket, gitRunning: true, ...label }),
|
|
215
|
+
release,
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=git-worktree-claims.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-worktree-claims.js","sourceRoot":"","sources":["../src/git-worktree-claims.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAwB,MAAM,wBAAwB,CAAC;AA6BtG,MAAM,CAAC,MAAM,WAAW,GAAc,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,WA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GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,CAAC;YACrF,OAAO;SACR;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type MutationHolder, type MutationLabel } from './git-worktree-
|
|
1
|
+
import { type MutationHolder, type MutationLabel } from './git-worktree-claims.ts';
|
|
2
2
|
export type { MutationHolder, MutationLabel };
|
|
3
3
|
/** `timedOut` is set when git was killed at the command's `timeout`; `childrenRunning` when Git
|
|
4
4
|
* children it started may still be running, which also holds the lock claim until they are gone. */
|
|
@@ -28,7 +28,8 @@ export type WorktreeMutationOptions = {
|
|
|
28
28
|
label?: MutationLabel;
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
|
-
* Serialize mutations by canonical Git common directory
|
|
32
|
-
* Git
|
|
31
|
+
* Serialize mutations by canonical Git common directory (ADR 0003, ADR 0076). The caller holds the
|
|
32
|
+
* claim itself; each Git command runs in its own process group, recorded in the claim before git
|
|
33
|
+
* starts, so the claim outlives a caller that dies while its git still runs.
|
|
33
34
|
*/
|
|
34
35
|
export declare function withWorktreeMutation<T>(repoRoot: string, operation: (git: WorktreeGit) => Promise<T>, options?: WorktreeMutationOptions): Promise<T>;
|