@abelxiaoxing/cadence 2.0.22 → 2.0.23

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.
@@ -3,37 +3,20 @@
3
3
  import path from "node:path";
4
4
 
5
5
  // src/task-store.ts
6
- import { spawnSync } from "node:child_process";
7
- import { createHash, randomUUID } from "node:crypto";
6
+ import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
8
7
  import {
9
- closeSync,
10
- constants,
11
- fstatSync,
12
- fsyncSync,
13
- lstatSync,
14
- mkdirSync,
15
- openSync,
8
+ closeSync as closeSync3,
9
+ fsyncSync as fsyncSync2,
10
+ openSync as openSync3,
16
11
  readdirSync,
17
- readSync,
18
- realpathSync,
19
12
  renameSync,
20
- unlinkSync,
21
- writeFileSync
13
+ unlinkSync as unlinkSync2,
14
+ writeFileSync as writeFileSync2
22
15
  } from "node:fs";
23
- import { homedir, hostname } from "node:os";
24
- import {
25
- dirname,
26
- isAbsolute,
27
- join,
28
- parse,
29
- relative,
30
- resolve,
31
- sep
32
- } from "node:path";
16
+ import { hostname as hostname2 } from "node:os";
17
+ import { join as join3 } from "node:path";
33
18
 
34
- // src/task-types.ts
35
- var TASK_SCHEMA = "cadence-workflow-assistant/1";
36
- var MAX_RECORD_BYTES = 128 * 1024;
19
+ // src/data-shapes.ts
37
20
  function object(value) {
38
21
  return value !== null && typeof value === "object" && !Array.isArray(value);
39
22
  }
@@ -43,6 +26,9 @@ function boundedString(value, max) {
43
26
  function validId(value) {
44
27
  return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(value);
45
28
  }
29
+ // src/task-types.ts
30
+ var TASK_SCHEMA = "cadence-workflow-assistant/1";
31
+ var MAX_RECORD_BYTES = 128 * 1024;
46
32
  function decodeCheck(value) {
47
33
  if (!object(value) || !boundedString(value.name, 128) || !value.name.trim() || !boundedString(value.command, 4096) || !value.command.trim() || !Number.isInteger(value.timeoutMs) || Number(value.timeoutMs) < 100 || Number(value.timeoutMs) > 1200000)
48
34
  throw new Error("Invalid check definition");
@@ -111,7 +97,29 @@ function diagnosticText(value, maximum = 4096, secrets = []) {
111
97
  return bytes.toString("utf8").replace(/\ufffd$/, "") + marker;
112
98
  }
113
99
 
114
- // src/task-store.ts
100
+ // src/workspace.ts
101
+ import { spawnSync } from "node:child_process";
102
+ import { createHash } from "node:crypto";
103
+ import {
104
+ closeSync,
105
+ constants,
106
+ fstatSync,
107
+ lstatSync,
108
+ mkdirSync,
109
+ openSync,
110
+ readSync,
111
+ realpathSync
112
+ } from "node:fs";
113
+ import { homedir } from "node:os";
114
+ import {
115
+ dirname,
116
+ isAbsolute,
117
+ join,
118
+ parse,
119
+ relative,
120
+ resolve,
121
+ sep
122
+ } from "node:path";
115
123
  function parseRecord(data) {
116
124
  try {
117
125
  return JSON.parse(data.toString("utf8"));
@@ -247,13 +255,6 @@ function defaultStateHome() {
247
255
  throw new Error("State home must be absolute");
248
256
  return candidate ?? join(homedir(), process.platform === "win32" ? "AppData/Local" : ".local/state");
249
257
  }
250
- function recordText(record) {
251
- return `${JSON.stringify(record, null, 2)}
252
- `;
253
- }
254
- function contentIdentity(text) {
255
- return createHash("sha256").update(text).digest("hex");
256
- }
257
258
  function canonicalAmbientRoot(path) {
258
259
  const full = resolve(path);
259
260
  try {
@@ -293,29 +294,39 @@ function effectiveWorkspace(requested, stateHome, _home) {
293
294
  throw new Error("Choose a project outside Cadence private state; no default workspace was created");
294
295
  return { workspace: requested, redirected: false };
295
296
  }
296
-
297
- class TaskStore {
297
+ // src/service/checkout-lock.ts
298
+ import { randomUUID } from "node:crypto";
299
+ import {
300
+ closeSync as closeSync2,
301
+ fsyncSync,
302
+ lstatSync as lstatSync2,
303
+ openSync as openSync2,
304
+ realpathSync as realpathSync2,
305
+ unlinkSync,
306
+ writeFileSync
307
+ } from "node:fs";
308
+ import { hostname } from "node:os";
309
+ import { dirname as dirname2, join as join2 } from "node:path";
310
+ class CheckoutStore {
298
311
  root;
299
- tasks;
300
312
  privateRoot;
301
313
  constructor(root, stateHome = defaultStateHome()) {
302
- this.root = realpathSync(root);
314
+ this.root = realpathSync2(root);
303
315
  if (privateWorkspace(this.root, stateHome))
304
316
  throw new Error("Private state cannot be a workspace");
305
- this.tasks = join(this.root, ".cadence", "assistant", "tasks");
306
317
  this.privateRoot = privateRootFor(this.root, stateHome);
307
318
  if (contains(this.root, this.privateRoot))
308
319
  throw new Error("Private state home must be outside the working copy");
309
320
  }
310
321
  get lockPath() {
311
- return join(this.privateRoot, "checkout.lock");
322
+ return join2(this.privateRoot, "checkout.lock");
312
323
  }
313
324
  inspectPrivate() {
314
- const namespace = dirname(this.privateRoot);
325
+ const namespace = dirname2(this.privateRoot);
315
326
  for (const path of [namespace, this.privateRoot]) {
316
327
  if (!safeDirectory(path))
317
328
  continue;
318
- const st = lstatSync(path);
329
+ const st = lstatSync2(path);
319
330
  if (process.platform !== "win32" && ((st.mode & 63) !== 0 || process.getuid && st.uid !== process.getuid()))
320
331
  throw new Error("Private state permissions refused");
321
332
  }
@@ -325,7 +336,7 @@ class TaskStore {
325
336
  if (!safeDirectory(this.privateRoot))
326
337
  return;
327
338
  try {
328
- const st = lstatSync(path);
339
+ const st = lstatSync2(path);
329
340
  if (!st.isFile() || st.isSymbolicLink() || st.nlink !== 1 || st.size > max || process.platform !== "win32" && ((st.mode & 63) !== 0 || process.getuid && st.uid !== process.getuid()))
330
341
  throw new Error("Unsafe private state file");
331
342
  } catch (error) {
@@ -356,7 +367,7 @@ class TaskStore {
356
367
  };
357
368
  let fd;
358
369
  try {
359
- fd = retryWindowsFileOperation(() => openSync(this.lockPath, "wx", 384));
370
+ fd = retryWindowsFileOperation(() => openSync2(this.lockPath, "wx", 384));
360
371
  } catch {
361
372
  throw new Error("Checkout busy or unresolved lock; inspect and explicitly recover only a dead owner");
362
373
  }
@@ -364,7 +375,7 @@ class TaskStore {
364
375
  writeFileSync(fd, JSON.stringify(lock));
365
376
  fsyncSync(fd);
366
377
  } finally {
367
- closeSync(fd);
378
+ closeSync2(fd);
368
379
  }
369
380
  return lock;
370
381
  }
@@ -378,8 +389,24 @@ class TaskStore {
378
389
  this.assertOwner(lock);
379
390
  retryWindowsFileOperation(() => unlinkSync(this.lockPath), () => this.assertOwner(lock));
380
391
  }
392
+ }
393
+
394
+ // src/task-store.ts
395
+ function recordText(record) {
396
+ return `${JSON.stringify(record, null, 2)}
397
+ `;
398
+ }
399
+ function contentIdentity(text) {
400
+ return createHash2("sha256").update(text).digest("hex");
401
+ }
402
+ class TaskStore extends CheckoutStore {
403
+ tasks;
404
+ constructor(root, stateHome = defaultStateHome()) {
405
+ super(root, stateHome);
406
+ this.tasks = join3(this.root, ".cadence", "assistant", "tasks");
407
+ }
381
408
  recover(expected, acknowledgeEscapedProcesses) {
382
- if (!acknowledgeEscapedProcesses || expected.host !== hostname())
409
+ if (!acknowledgeEscapedProcesses || expected.host !== hostname2())
383
410
  throw new Error("Recovery requires informed local-owner confirmation");
384
411
  this.assertOwner(expected);
385
412
  try {
@@ -388,7 +415,7 @@ class TaskStore {
388
415
  if (!object(error) || error.code !== "ESRCH")
389
416
  throw new Error("Owner status unknown");
390
417
  this.assertOwner(expected);
391
- unlinkSync(this.lockPath);
418
+ unlinkSync2(this.lockPath);
392
419
  return;
393
420
  }
394
421
  throw new Error("Owner is live; stop it first");
@@ -399,10 +426,10 @@ class TaskStore {
399
426
  loadSnapshot(id) {
400
427
  if (!validId(id))
401
428
  throw new Error("Invalid task id");
402
- const directory = join(this.tasks, id);
429
+ const directory = join3(this.tasks, id);
403
430
  if (safeDirectory(directory) && readdirSync(directory).some((name) => name !== "task.json"))
404
431
  throw new Error("Unknown task directory content; preserved without reset");
405
- const data = readBounded(join(this.tasks, id, "task.json"), MAX_RECORD_BYTES);
432
+ const data = readBounded(join3(this.tasks, id, "task.json"), MAX_RECORD_BYTES);
406
433
  if (!data)
407
434
  return;
408
435
  const record = decodeTask(parseRecord(data));
@@ -431,7 +458,7 @@ class TaskStore {
431
458
  if (Buffer.byteLength(text) > MAX_RECORD_BYTES)
432
459
  throw new Error("Task record limit");
433
460
  const lock = held ?? this.acquire();
434
- if (lock.pid !== process.pid || lock.host !== hostname())
461
+ if (lock.pid !== process.pid || lock.host !== hostname2())
435
462
  throw new Error("Not the lock owner");
436
463
  try {
437
464
  this.assertOwner(lock);
@@ -440,25 +467,25 @@ class TaskStore {
440
467
  throw new Error("Revision conflict");
441
468
  if (current?.identity !== expectedIdentity)
442
469
  throw new Error("Task content changed; reopen it");
443
- const dir = join(this.tasks, next.id);
470
+ const dir = join3(this.tasks, next.id);
444
471
  safeDirectory(dir, true);
445
472
  if (!current && readdirSync(dir).length)
446
473
  throw new Error("Unknown task directory");
447
- const temporary = join(dir, `task.${randomUUID()}.tmp`);
448
- const fd = openSync(temporary, "wx", 384);
474
+ const temporary = join3(dir, `task.${randomUUID2()}.tmp`);
475
+ const fd = openSync3(temporary, "wx", 384);
449
476
  try {
450
- writeFileSync(fd, text);
451
- fsyncSync(fd);
477
+ writeFileSync2(fd, text);
478
+ fsyncSync2(fd);
452
479
  } finally {
453
- closeSync(fd);
480
+ closeSync3(fd);
454
481
  }
455
482
  this.assertOwner(lock);
456
- const latest = readBounded(join(dir, "task.json"), MAX_RECORD_BYTES);
483
+ const latest = readBounded(join3(dir, "task.json"), MAX_RECORD_BYTES);
457
484
  if ((latest ? contentIdentity(latest) : undefined) !== expectedIdentity)
458
485
  throw new Error("Task content changed; replacement preserved without overwrite");
459
- retryWindowsFileOperation(() => renameSync(temporary, join(dir, "task.json")), () => {
486
+ retryWindowsFileOperation(() => renameSync(temporary, join3(dir, "task.json")), () => {
460
487
  this.assertOwner(lock);
461
- const now = readBounded(join(dir, "task.json"), MAX_RECORD_BYTES);
488
+ const now = readBounded(join3(dir, "task.json"), MAX_RECORD_BYTES);
462
489
  if ((now ? contentIdentity(now) : undefined) !== expectedIdentity)
463
490
  throw new Error("Task content changed; replacement preserved without overwrite");
464
491
  });
@@ -469,7 +496,7 @@ class TaskStore {
469
496
  }
470
497
  }
471
498
  checks() {
472
- const data = readBounded(join(this.root, ".cadence", "assistant", "config.json"), 32768);
499
+ const data = readBounded(join3(this.root, ".cadence", "assistant", "config.json"), 32768);
473
500
  if (!data)
474
501
  return [];
475
502
  const value = parseRecord(data);
@@ -483,16 +510,16 @@ class TaskStore {
483
510
  readLog(name) {
484
511
  if (!/^[a-f0-9-]{36}\.log$/.test(name))
485
512
  throw new Error("Invalid diagnostic name");
486
- this.inspectPrivateFile(join(this.privateRoot, name), 65536);
487
- const data = readBounded(join(this.privateRoot, name), 65536);
513
+ this.inspectPrivateFile(join3(this.privateRoot, name), 65536);
514
+ const data = readBounded(join3(this.privateRoot, name), 65536);
488
515
  return data ? diagnosticText(data.toString("utf8"), 65536) : "Private diagnostic unavailable";
489
516
  }
490
517
  writeLog(lock, output) {
491
- if (lock.pid !== process.pid || lock.host !== hostname())
518
+ if (lock.pid !== process.pid || lock.host !== hostname2())
492
519
  throw new Error("Not the lock owner");
493
520
  this.assertOwner(lock);
494
- const name = `${randomUUID()}.log`;
495
- writeFileSync(join(this.privateRoot, name), diagnosticText(output, 65536), {
521
+ const name = `${randomUUID2()}.log`;
522
+ writeFileSync2(join3(this.privateRoot, name), diagnosticText(output, 65536), {
496
523
  flag: "wx",
497
524
  mode: 384
498
525
  });
@@ -500,6 +527,7 @@ class TaskStore {
500
527
  }
501
528
  }
502
529
  var TASK_CONFIG_SCHEMA = "cadence-assistant-checks/1";
530
+ var stores = new WeakMap;
503
531
 
504
532
  // src/operator-tools.ts
505
533
  var observed = (cwd) => resolveWorkspace(effectiveWorkspace(cwd).workspace);
@@ -0,0 +1,142 @@
1
+ /** Existing checkout lock identity and original filesystem semantics, without task CRUD. */
2
+ import { randomUUID } from "node:crypto";
3
+ import {
4
+ closeSync,
5
+ fsyncSync,
6
+ lstatSync,
7
+ openSync,
8
+ realpathSync,
9
+ unlinkSync,
10
+ writeFileSync,
11
+ } from "node:fs";
12
+ import { hostname } from "node:os";
13
+ import { dirname, join } from "node:path";
14
+ import { object, validId } from "../data-shapes.ts";
15
+ import {
16
+ absent,
17
+ contains,
18
+ defaultStateHome,
19
+ parseRecord,
20
+ privateRootFor,
21
+ privateWorkspace,
22
+ readBounded,
23
+ retryWindowsFileOperation,
24
+ safeDirectory,
25
+ } from "../workspace.ts";
26
+ export interface CheckoutLock {
27
+ schema: "cadence-assistant-lock/1";
28
+ token: string;
29
+ pid: number;
30
+ host: string;
31
+ runId: string;
32
+ root: string;
33
+ }
34
+ export class CheckoutStore {
35
+ readonly root: string;
36
+ readonly privateRoot: string;
37
+ constructor(root: string, stateHome = defaultStateHome()) {
38
+ this.root = realpathSync(root);
39
+ if (privateWorkspace(this.root, stateHome))
40
+ throw new Error("Private state cannot be a workspace");
41
+ this.privateRoot = privateRootFor(this.root, stateHome);
42
+ if (contains(this.root, this.privateRoot))
43
+ throw new Error("Private state home must be outside the working copy");
44
+ }
45
+ get lockPath(): string {
46
+ return join(this.privateRoot, "checkout.lock");
47
+ }
48
+ private inspectPrivate(): void {
49
+ const namespace = dirname(this.privateRoot);
50
+ for (const path of [namespace, this.privateRoot]) {
51
+ if (!safeDirectory(path)) continue;
52
+ const st = lstatSync(path);
53
+ if (
54
+ process.platform !== "win32" &&
55
+ ((st.mode & 0o077) !== 0 ||
56
+ (process.getuid && st.uid !== process.getuid()))
57
+ )
58
+ throw new Error("Private state permissions refused");
59
+ }
60
+ }
61
+ protected inspectPrivateFile(path: string, max: number): void {
62
+ this.inspectPrivate();
63
+ if (!safeDirectory(this.privateRoot)) return;
64
+ try {
65
+ const st = lstatSync(path);
66
+ if (
67
+ !st.isFile() ||
68
+ st.isSymbolicLink() ||
69
+ st.nlink !== 1 ||
70
+ st.size > max ||
71
+ (process.platform !== "win32" &&
72
+ ((st.mode & 0o077) !== 0 ||
73
+ (process.getuid && st.uid !== process.getuid())))
74
+ )
75
+ throw new Error("Unsafe private state file");
76
+ } catch (error) {
77
+ if (!absent(error)) throw error;
78
+ }
79
+ }
80
+ inspectLock(): CheckoutLock | undefined {
81
+ this.inspectPrivateFile(this.lockPath, 8192);
82
+ const data = readBounded(this.lockPath, 8192);
83
+ if (!data) return undefined;
84
+ const lock: unknown = parseRecord(data);
85
+ if (
86
+ !object(lock) ||
87
+ lock.schema !== "cadence-assistant-lock/1" ||
88
+ lock.root !== this.root ||
89
+ typeof lock.token !== "string" ||
90
+ !validId(lock.token) ||
91
+ typeof lock.runId !== "string" ||
92
+ !validId(lock.runId) ||
93
+ typeof lock.host !== "string" ||
94
+ !Number.isInteger(lock.pid) ||
95
+ Number(lock.pid) < 1
96
+ )
97
+ throw new Error("Unknown or corrupt coordination lock");
98
+ return lock as unknown as CheckoutLock;
99
+ }
100
+ acquire(): CheckoutLock {
101
+ this.inspectPrivate();
102
+ safeDirectory(this.privateRoot, true);
103
+ const lock: CheckoutLock = {
104
+ schema: "cadence-assistant-lock/1",
105
+ token: randomUUID(),
106
+ runId: randomUUID(),
107
+ pid: process.pid,
108
+ host: hostname(),
109
+ root: this.root,
110
+ };
111
+ let fd: number;
112
+ try {
113
+ fd = retryWindowsFileOperation(() =>
114
+ openSync(this.lockPath, "wx", 0o600),
115
+ );
116
+ } catch {
117
+ throw new Error(
118
+ "Checkout busy or unresolved lock; inspect and explicitly recover only a dead owner",
119
+ );
120
+ }
121
+ try {
122
+ writeFileSync(fd, JSON.stringify(lock));
123
+ fsyncSync(fd);
124
+ } finally {
125
+ closeSync(fd);
126
+ }
127
+ return lock;
128
+ }
129
+ assertOwner(lock: CheckoutLock): void {
130
+ if (JSON.stringify(this.inspectLock()) !== JSON.stringify(lock))
131
+ throw new Error("Coordination lock changed");
132
+ }
133
+ release(lock: CheckoutLock): void {
134
+ if (lock.pid !== process.pid || lock.host !== hostname())
135
+ throw new Error("Only the owning process may release a lock");
136
+ this.assertOwner(lock);
137
+ retryWindowsFileOperation(
138
+ () => unlinkSync(this.lockPath),
139
+ () => this.assertOwner(lock),
140
+ );
141
+ }
142
+ }
@@ -19,6 +19,7 @@ import {
19
19
  decodeWorkflowRequest,
20
20
  decodeWorkflowResponse,
21
21
  decodeWorkflowRun,
22
+ WORKFLOW_LIMITS,
22
23
  type WorkflowProposal,
23
24
  type WorkflowRequest,
24
25
  type WorkflowResponse,
@@ -67,6 +68,7 @@ export interface WorkflowLink {
67
68
  export type WorkbenchRead =
68
69
  | { kind: "cadence-conversation"; id: string }
69
70
  | { kind: "workflow-active" }
71
+ | { kind: "workflow-history"; after: string | null; scan?: string }
70
72
  | { kind: "workflow-detail"; id: string; stepId: string }
71
73
  | { kind: "workflow-transcript"; id: string; stepId: string }
72
74
  | { kind: "workflow"; id: string }
@@ -120,13 +122,6 @@ export type WorkbenchCommand =
120
122
  epoch: string;
121
123
  request: WorkflowRequest;
122
124
  }
123
- | {
124
- kind: "link-task";
125
- commandId: string;
126
- epoch: string;
127
- taskId: string;
128
- conversationId: string;
129
- }
130
125
  | {
131
126
  kind: "send";
132
127
  commandId: string;
@@ -183,6 +178,12 @@ export interface FileEntry {
183
178
  directory: boolean;
184
179
  }
185
180
  export type WorkbenchResult =
181
+ | { kind: "workflow-history-progress"; after: string | null; scan: string }
182
+ | {
183
+ kind: "workflow-history";
184
+ entries: { id: string; run: WorkflowRun | null }[];
185
+ next: string | null;
186
+ }
186
187
  | {
187
188
  kind: "workflow-transcript";
188
189
  runId: string;
@@ -251,6 +252,15 @@ export function decodeWorkbenchRead(v: unknown): WorkbenchRead {
251
252
  const o = closed(v, ["kind", "id"]);
252
253
  return { kind, id: decodeId(o.id) };
253
254
  }
255
+ case "workflow-history": {
256
+ const continued = Object.hasOwn(v as object, "scan");
257
+ const o = closed(v, ["kind", "after", ...(continued ? ["scan"] : [])]);
258
+ return {
259
+ kind,
260
+ after: nullable(o.after, decodeId),
261
+ ...(continued ? { scan: decodeId(o.scan) } : {}),
262
+ };
263
+ }
254
264
  case "workflow-active":
255
265
  closed(v, ["kind"]);
256
266
  return { kind };
@@ -366,22 +376,7 @@ export function decodeWorkbenchCommand(v: unknown): WorkbenchCommand {
366
376
  request: decodeWorkflowRequest(o.request),
367
377
  };
368
378
  }
369
- if (kind === "link-task") {
370
- const o = closed(v, [
371
- "kind",
372
- "commandId",
373
- "epoch",
374
- "taskId",
375
- "conversationId",
376
- ]);
377
- return {
378
- kind,
379
- commandId: decodeId(o.commandId),
380
- epoch: decodeId(o.epoch),
381
- taskId: decodeId(o.taskId),
382
- conversationId: decodeId(o.conversationId),
383
- };
384
- }
379
+
385
380
  if (kind === "send") {
386
381
  const o = closed(v, [
387
382
  "kind",
@@ -492,6 +487,31 @@ export function decodeWorkbenchResult(v: unknown): WorkbenchResult {
492
487
  const o = closed(v, ["kind", "state"]);
493
488
  return { kind: k, state: decodeCadenceConversation(o.state) };
494
489
  }
490
+ if (k === "workflow-history-progress") {
491
+ const o = closed(v, ["kind", "after", "scan"]);
492
+ return {
493
+ kind: k,
494
+ after: nullable(o.after, decodeId),
495
+ scan: decodeId(o.scan),
496
+ };
497
+ }
498
+ if (k === "workflow-history") {
499
+ const o = closed(v, ["kind", "entries", "next"]);
500
+ const entries = list(o.entries, WORKFLOW_LIMITS.historyPage, (v) => {
501
+ const e = closed(v, ["id", "run"]);
502
+ const id = decodeId(e.id),
503
+ run = nullable(e.run, decodeWorkflowRun);
504
+ if (run && run.id !== id) throw new ContractError("invalid");
505
+ return { id, run };
506
+ });
507
+ const next = nullable(o.next, decodeId);
508
+ if (
509
+ new Set(entries.map((e) => e.id)).size !== entries.length ||
510
+ (next !== null && next !== entries.at(-1)?.id)
511
+ )
512
+ throw new ContractError("invalid");
513
+ return { kind: k, entries, next };
514
+ }
495
515
  if (k === "workflow-active") {
496
516
  const linked =
497
517
  v !== null && typeof v === "object" && Object.hasOwn(v, "links");
@@ -19,7 +19,11 @@ export const WORKFLOW_LIMITS = {
19
19
  checks: 16,
20
20
  repairs: 2,
21
21
  bytes: 256 * 1024,
22
- runs: 200,
22
+ // Read budgets, never a lifetime cap on retained runs.
23
+ historyScanEntries: 200,
24
+ historyPage: 20,
25
+ historyScans: 16,
26
+ historyIdleMs: 120000,
23
27
  durationMs: 90 * 60 * 1000,
24
28
  } as const;
25
29
  export interface WorkflowCheck {
@@ -3,12 +3,11 @@ import { opendirSync } from "node:fs";
3
3
  import { hostname } from "node:os";
4
4
  import { dirname, isAbsolute, join, relative, sep } from "node:path";
5
5
  import {
6
- type CheckoutLock,
7
6
  canonicalAmbientRoot,
8
7
  defaultStateHome,
9
8
  resolveWorkspace,
10
- TaskStore,
11
- } from "../task-store.ts";
9
+ } from "../workspace.ts";
10
+ import { type CheckoutLock, CheckoutStore } from "./checkout-lock.ts";
12
11
  import {
13
12
  ContractError,
14
13
  closed,
@@ -247,7 +246,7 @@ export type CoordinationStatus =
247
246
  * task creation, stale reclaim or accepting execution route lives here.
248
247
  */
249
248
  export class ServiceCoordination {
250
- private readonly project?: TaskStore;
249
+ private readonly project?: CheckoutStore;
251
250
  readonly files: PrivateFiles;
252
251
  readonly registryDirectory: string;
253
252
  readonly stateHome: string;
@@ -256,7 +255,7 @@ export class ServiceCoordination {
256
255
  this.project =
257
256
  workspace === null
258
257
  ? undefined
259
- : new TaskStore(resolveWorkspace(workspace).root, stateHome);
258
+ : new CheckoutStore(resolveWorkspace(workspace).root, stateHome);
260
259
  this.stateHome = this.project
261
260
  ? dirname(dirname(this.project.privateRoot))
262
261
  : canonicalAmbientRoot(stateHome ?? defaultStateHome());
@@ -264,7 +263,7 @@ export class ServiceCoordination {
264
263
  this.files = new PrivateFiles(namespace);
265
264
  this.registryDirectory = join(namespace, "service-registry-v1");
266
265
  }
267
- get store(): TaskStore {
266
+ get store(): CheckoutStore {
268
267
  if (!this.project) throw new ContractError("forbidden");
269
268
  return this.project;
270
269
  }
@@ -1079,7 +1078,7 @@ export class ServiceCoordination {
1079
1078
  }
1080
1079
 
1081
1080
  /** Held only by the original owner. Raw-byte AND inode/time identities supplement
1082
- * TaskStore's semantic lock assertion, including whitespace-only interference. */
1081
+ * CheckoutStore's semantic lock assertion, including whitespace-only interference. */
1083
1082
  export class OwnerLease {
1084
1083
  private released = false;
1085
1084
  constructor(
@@ -14,7 +14,8 @@ import {
14
14
  writeFileSync,
15
15
  } from "node:fs";
16
16
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
17
- import { retryWindowsFileOperation, safeDirectory } from "../task-store.ts";
17
+ import { retryWindowsFileOperation, safeDirectory } from "../workspace.ts";
18
+
18
19
  import { ContractError, parseWireJson } from "./contracts/core.ts";
19
20
 
20
21
  export const METADATA_BYTES = 16 * 1024;