@wjarka/cezarion 0.17.0-dev.3031 → 0.17.0-pr1973.3036

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 (44) hide show
  1. package/dist/ci-wait/tools.d.ts +4 -4
  2. package/dist/delegation/destroy-holders.d.ts +2 -0
  3. package/dist/delegation/destroy-holders.js +167 -0
  4. package/dist/delegation/destroy-holders.js.map +1 -0
  5. package/dist/delegation/idle-test-app.js +58 -20
  6. package/dist/delegation/idle-test-app.js.map +1 -1
  7. package/dist/delegation/mount-boundary.d.ts +16 -0
  8. package/dist/delegation/mount-boundary.js +126 -0
  9. package/dist/delegation/mount-boundary.js.map +1 -0
  10. package/dist/delegation/process-liveness.d.ts +3 -0
  11. package/dist/delegation/process-liveness.js +5 -0
  12. package/dist/delegation/process-liveness.js.map +1 -1
  13. package/dist/delegation/service.d.ts +1 -3
  14. package/dist/delegation/service.js +117 -24
  15. package/dist/delegation/service.js.map +1 -1
  16. package/dist/delegation/windows-workspace-identity.d.ts +10 -0
  17. package/dist/delegation/windows-workspace-identity.js +37 -0
  18. package/dist/delegation/windows-workspace-identity.js.map +1 -1
  19. package/dist/delegation/workspace.d.ts +3 -1
  20. package/dist/delegation/workspace.js +324 -29
  21. package/dist/delegation/workspace.js.map +1 -1
  22. package/dist/git-worktree-release.d.ts +1 -1
  23. package/dist/git-worktree-release.js +2 -2
  24. package/dist/git-worktree-release.js.map +1 -1
  25. package/dist/runs/private-worker-file.d.ts +5 -0
  26. package/dist/runs/private-worker-file.js +51 -0
  27. package/dist/runs/private-worker-file.js.map +1 -0
  28. package/dist/runs/store.d.ts +48 -48
  29. package/dist/runs/store.js +47 -87
  30. package/dist/runs/store.js.map +1 -1
  31. package/dist/runs/windows-worker-evidence.d.ts +9 -0
  32. package/dist/runs/windows-worker-evidence.js +71 -0
  33. package/dist/runs/windows-worker-evidence.js.map +1 -0
  34. package/dist/runs/worker-execution.js +17 -1
  35. package/dist/runs/worker-execution.js.map +1 -1
  36. package/dist/server/server.d.ts +1200 -1200
  37. package/dist/workflows/continuation-admission.d.ts +48 -48
  38. package/dist/workflows/run.d.ts +1 -3
  39. package/dist/workflows/run.js +6 -7
  40. package/dist/workflows/run.js.map +1 -1
  41. package/package.json +3 -3
  42. package/scripts/test-fallback-sandbox.mjs +39 -0
  43. package/scripts/windows-workspace-identity.cs +219 -10
  44. package/scripts/windows-workspace-identity.ps1 +6 -0
@@ -1 +1 @@
1
- {"version":3,"file":"git-worktree-release.js","sourceRoot":"","sources":["../src/git-worktree-release.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAsB,MAAM,2BAA2B,CAAC;AACrF,OAAO,EAAE,cAAc,EAA8B,MAAM,mBAAmB,CAAC;AAG/E;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,IAAoE,EACpE,KAAa,EACb,QAAgB,EAChB,YAAoB,EACpB,MAAe,EACf,IAA4B;IAE5B,MAAM,cAAc,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE;QACnD,GAAG,IAAI;QACP,YAAY,EAAE,KAAK,IAAI,EAAE;YACvB,MAAM,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YAC9D,MAAM,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC;QAC/B,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,+GAA+G;AAC/G,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,IAAoE,EACpE,QAAgB,EAChB,SAA0B,EAC1B,aAA0B,EAC1B,YAAyB,EACzB,MAAsB;IAEtB,OAAO,oBAAoB,CAAC,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,IAAI,EAAE;QACzE,MAAM,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC/E,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC"}
1
+ {"version":3,"file":"git-worktree-release.js","sourceRoot":"","sources":["../src/git-worktree-release.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAsB,MAAM,2BAA2B,CAAC;AACrF,OAAO,EAAE,cAAc,EAA8B,MAAM,mBAAmB,CAAC;AAG/E;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,IAAoE,EACpE,KAAa,EACb,QAAgB,EAChB,YAAoB,EACpB,MAAe,EACf,IAA4B;IAE5B,MAAM,cAAc,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE;QACnD,GAAG,IAAI;QACP,YAAY,EAAE,KAAK,IAAI,EAAE;YACvB,MAAM,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YAC9D,MAAM,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC;QAC/B,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,+GAA+G;AAC/G,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,IAAoE,EACpE,QAAgB,EAChB,SAA0B,EAC1B,aAA0B,EAC1B,YAAyB,EACzB,MAAsB,EACtB,WAAiC;IAEjC,OAAO,oBAAoB,CAAC,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,IAAI,EAAE;QACzE,MAAM,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC/E,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare function executionEvidenceAbsent(dataDir: string, id: string, path: string): boolean;
2
+ /** Read a bounded POSIX private record without following its final component. */
3
+ export declare function readPrivateWorkerFile(path: string, cap: number): string;
4
+ /** Publish a complete private record after validating the prior directory entry. */
5
+ export declare function replacePrivateWorkerFile(path: string, content: string, fresh?: boolean): void;
@@ -0,0 +1,51 @@
1
+ import { closeSync, constants, existsSync, fstatSync, fsyncSync, lstatSync, openSync, readSync, renameSync, rmSync, writeFileSync } from 'node:fs';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { isWindowsWorkerEvidence, windowsEvidenceAbsent } from './windows-worker-evidence.js';
4
+ export function executionEvidenceAbsent(dataDir, id, path) {
5
+ return isWindowsWorkerEvidence ? windowsEvidenceAbsent(dataDir, id, 'execution') : !existsSync(path);
6
+ }
7
+ /** Read a bounded POSIX private record without following its final component. */
8
+ export function readPrivateWorkerFile(path, cap) {
9
+ const fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
10
+ try {
11
+ const info = fstatSync(fd);
12
+ if (!info.isFile() || info.size > cap || (info.mode & 0o077))
13
+ throw new Error('Unsafe private worker record');
14
+ const buffer = Buffer.alloc(cap + 1);
15
+ const count = readSync(fd, buffer, 0, buffer.length, 0);
16
+ if (count > cap)
17
+ throw new Error('Oversized private worker record');
18
+ return buffer.subarray(0, count).toString('utf8');
19
+ }
20
+ finally {
21
+ closeSync(fd);
22
+ }
23
+ }
24
+ /** Publish a complete private record after validating the prior directory entry. */
25
+ export function replacePrivateWorkerFile(path, content, fresh = false) {
26
+ try {
27
+ const existing = lstatSync(path);
28
+ if (fresh || !existing.isFile() || existing.isSymbolicLink())
29
+ throw new Error('Unsafe private worker record');
30
+ }
31
+ catch (error) {
32
+ if (error.code !== 'ENOENT')
33
+ throw error;
34
+ }
35
+ const temporary = `${path}.${randomUUID()}.tmp`;
36
+ const fd = openSync(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
37
+ try {
38
+ writeFileSync(fd, content);
39
+ fsyncSync(fd);
40
+ }
41
+ finally {
42
+ closeSync(fd);
43
+ }
44
+ try {
45
+ renameSync(temporary, path);
46
+ }
47
+ finally {
48
+ rmSync(temporary, { force: true });
49
+ }
50
+ }
51
+ //# sourceMappingURL=private-worker-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private-worker-file.js","sourceRoot":"","sources":["../../src/runs/private-worker-file.ts"],"names":[],"mappings":"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"}
@@ -1484,6 +1484,30 @@ export declare function parseRunRecords(raw: unknown): z.ZodSafeParseResult<{
1484
1484
  deadline: string;
1485
1485
  seconds: number;
1486
1486
  note?: string | undefined;
1487
+ } | {
1488
+ id: string;
1489
+ source: "agent" | "cezar";
1490
+ via: "ask-line" | "budget" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "no-wait" | "schedule-wakeup";
1491
+ registeredAt: string;
1492
+ phase: "cancelled" | "delivered" | "open" | "resolved";
1493
+ resolvedAt?: string | undefined;
1494
+ deliveredAt?: string | undefined;
1495
+ cancelledAt?: string | undefined;
1496
+ turnId: string;
1497
+ kind: "process";
1498
+ deadline: string;
1499
+ timeoutSeconds: number;
1500
+ pid: number;
1501
+ startToken?: string | undefined;
1502
+ exitFile?: string | undefined;
1503
+ note?: string | undefined;
1504
+ result?: {
1505
+ outcome: "deadline" | "error" | "exit_file" | "exited";
1506
+ observedAt: string;
1507
+ exitCode?: number | undefined;
1508
+ exitFileNote?: "not-an-exit-code" | undefined;
1509
+ diagnostic?: string | undefined;
1510
+ } | undefined;
1487
1511
  } | {
1488
1512
  id: string;
1489
1513
  source: "agent" | "cezar";
@@ -1544,30 +1568,6 @@ export declare function parseRunRecords(raw: unknown): z.ZodSafeParseResult<{
1544
1568
  reason: "outcome" | "timeout";
1545
1569
  } | undefined;
1546
1570
  wakeInputId?: string | undefined;
1547
- } | {
1548
- id: string;
1549
- source: "agent" | "cezar";
1550
- via: "ask-line" | "budget" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "no-wait" | "schedule-wakeup";
1551
- registeredAt: string;
1552
- phase: "cancelled" | "delivered" | "open" | "resolved";
1553
- resolvedAt?: string | undefined;
1554
- deliveredAt?: string | undefined;
1555
- cancelledAt?: string | undefined;
1556
- turnId: string;
1557
- kind: "process";
1558
- deadline: string;
1559
- timeoutSeconds: number;
1560
- pid: number;
1561
- startToken?: string | undefined;
1562
- exitFile?: string | undefined;
1563
- note?: string | undefined;
1564
- result?: {
1565
- outcome: "deadline" | "error" | "exit_file" | "exited";
1566
- observedAt: string;
1567
- exitCode?: number | undefined;
1568
- exitFileNote?: "not-an-exit-code" | undefined;
1569
- diagnostic?: string | undefined;
1570
- } | undefined;
1571
1571
  })[] | undefined;
1572
1572
  lastWaits?: ({
1573
1573
  prUrl: string;
@@ -1621,6 +1621,30 @@ export declare function parseRunRecords(raw: unknown): z.ZodSafeParseResult<{
1621
1621
  deadline: string;
1622
1622
  seconds: number;
1623
1623
  note?: string | undefined;
1624
+ } | {
1625
+ id: string;
1626
+ source: "agent" | "cezar";
1627
+ via: "ask-line" | "budget" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "no-wait" | "schedule-wakeup";
1628
+ registeredAt: string;
1629
+ phase: "cancelled" | "delivered" | "open" | "resolved";
1630
+ resolvedAt?: string | undefined;
1631
+ deliveredAt?: string | undefined;
1632
+ cancelledAt?: string | undefined;
1633
+ turnId: string;
1634
+ kind: "process";
1635
+ deadline: string;
1636
+ timeoutSeconds: number;
1637
+ pid: number;
1638
+ startToken?: string | undefined;
1639
+ exitFile?: string | undefined;
1640
+ note?: string | undefined;
1641
+ result?: {
1642
+ outcome: "deadline" | "error" | "exit_file" | "exited";
1643
+ observedAt: string;
1644
+ exitCode?: number | undefined;
1645
+ exitFileNote?: "not-an-exit-code" | undefined;
1646
+ diagnostic?: string | undefined;
1647
+ } | undefined;
1624
1648
  } | {
1625
1649
  id: string;
1626
1650
  source: "agent" | "cezar";
@@ -1681,30 +1705,6 @@ export declare function parseRunRecords(raw: unknown): z.ZodSafeParseResult<{
1681
1705
  reason: "outcome" | "timeout";
1682
1706
  } | undefined;
1683
1707
  wakeInputId?: string | undefined;
1684
- } | {
1685
- id: string;
1686
- source: "agent" | "cezar";
1687
- via: "ask-line" | "budget" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "no-wait" | "schedule-wakeup";
1688
- registeredAt: string;
1689
- phase: "cancelled" | "delivered" | "open" | "resolved";
1690
- resolvedAt?: string | undefined;
1691
- deliveredAt?: string | undefined;
1692
- cancelledAt?: string | undefined;
1693
- turnId: string;
1694
- kind: "process";
1695
- deadline: string;
1696
- timeoutSeconds: number;
1697
- pid: number;
1698
- startToken?: string | undefined;
1699
- exitFile?: string | undefined;
1700
- note?: string | undefined;
1701
- result?: {
1702
- outcome: "deadline" | "error" | "exit_file" | "exited";
1703
- observedAt: string;
1704
- exitCode?: number | undefined;
1705
- exitFileNote?: "not-an-exit-code" | undefined;
1706
- diagnostic?: string | undefined;
1707
- } | undefined;
1708
1708
  })[] | undefined;
1709
1709
  previewServers?: {
1710
1710
  port: number;
@@ -2,11 +2,13 @@ import { defined } from '../core/defined.js';
2
2
  import { autosaveCleanupBlocker, clearAutosaveCleanup } from '../autosave-cleanup.js';
3
3
  import { EventEmitter } from 'node:events';
4
4
  import { workerEvidenceRunIds, workerExecutionSchema } from './worker-execution.js';
5
+ import { isWindowsWorkerEvidence, readWindowsEvidence, removeWindowsEvidence, windowsEvidencePath, writeWindowsEvidence } from './windows-worker-evidence.js';
6
+ import { executionEvidenceAbsent, readPrivateWorkerFile, replacePrivateWorkerFile } from './private-worker-file.js';
5
7
  import { agentTmpDirLocations, agentTmpDirMayExist, agentTmpDirOwnershipProven, removeAgentTmpDir } from './agent-tmpdir.js';
6
8
  import { removeArtifacts } from '../artifacts/lifecycle.js';
7
9
  import { randomUUID, createHash } from 'node:crypto';
8
10
  import { isDeepStrictEqual } from 'node:util';
9
- import { appendFileSync, closeSync, constants, fstatSync, fsyncSync, lstatSync, openSync, readSync, realpathSync, readdirSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
11
+ import { appendFileSync, closeSync, constants, fstatSync, fsyncSync, lstatSync, openSync, realpathSync, readdirSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
10
12
  import { join, resolve } from 'node:path';
11
13
  import { z } from 'zod';
12
14
  import { ciWaitSchema } from '../contract/index.js';
@@ -3879,28 +3881,27 @@ export class RunStore extends EventEmitter {
3879
3881
  }
3880
3882
  /** Private process-generation evidence; never part of run JSON or SSE. */
3881
3883
  identityPath(id) {
3884
+ if (isWindowsWorkerEvidence)
3885
+ return windowsEvidencePath(this.dataDir, id, 'identity');
3882
3886
  return this.executionPath(id).replace(/\.execution\.json$/, '.identity.json');
3883
3887
  }
3884
3888
  readWorkerIdentity(id) {
3885
3889
  try {
3886
- const fd = openSync(this.identityPath(id), constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
3887
- try {
3888
- const info = fstatSync(fd);
3889
- if (!info.isFile() || info.size > 16384 || (info.mode & 0o077))
3890
- return undefined;
3891
- const buffer = Buffer.alloc(16385);
3892
- const count = readSync(fd, buffer, 0, buffer.length, 0);
3893
- return workerExecutionIdentitySchema.parse(JSON.parse(buffer.subarray(0, count).toString('utf8')));
3894
- }
3895
- finally {
3896
- closeSync(fd);
3890
+ if (isWindowsWorkerEvidence) {
3891
+ const content = readWindowsEvidence(this.dataDir, id, 'identity', 16384);
3892
+ return content === undefined ? undefined : workerExecutionIdentitySchema.parse(JSON.parse(content));
3897
3893
  }
3894
+ return workerExecutionIdentitySchema.parse(JSON.parse(readPrivateWorkerFile(this.identityPath(id), 16384)));
3898
3895
  }
3899
3896
  catch {
3900
3897
  return undefined;
3901
3898
  }
3902
3899
  }
3903
3900
  writeWorkerIdentity(id, identity) {
3901
+ if (isWindowsWorkerEvidence) {
3902
+ writeWindowsEvidence(this.dataDir, id, 'identity', JSON.stringify(identity), true);
3903
+ return;
3904
+ }
3904
3905
  // Immutable acceptance evidence. An orphan from failed index publication cannot be adopted.
3905
3906
  const fd = openSync(this.identityPath(id), constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
3906
3907
  try {
@@ -3917,54 +3918,28 @@ export class RunStore extends EventEmitter {
3917
3918
  mkdirSync(dir, { recursive: true });
3918
3919
  if (lstatSync(dir).isSymbolicLink() || realpathSync(dir) !== resolve(dir))
3919
3920
  throw new Error('Unsafe execution directory');
3921
+ if (isWindowsWorkerEvidence)
3922
+ return windowsEvidencePath(this.dataDir, id, 'execution');
3920
3923
  return join(dir, `${id}.execution.json`);
3921
3924
  }
3922
3925
  readWorkerExecution(id) {
3923
3926
  try {
3924
- const path = this.executionPath(id);
3925
- const fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
3926
- try {
3927
- const info = fstatSync(fd);
3928
- if (!info.isFile() || info.size > 16384 || (info.mode & 0o077))
3929
- return undefined;
3930
- const buffer = Buffer.alloc(16385);
3931
- const count = readSync(fd, buffer, 0, buffer.length, 0);
3932
- return workerExecutionSchema.parse(JSON.parse(buffer.subarray(0, count).toString('utf8')));
3933
- }
3934
- finally {
3935
- closeSync(fd);
3927
+ if (isWindowsWorkerEvidence) {
3928
+ const content = readWindowsEvidence(this.dataDir, id, 'execution', 16384);
3929
+ return content === undefined ? undefined : workerExecutionSchema.parse(JSON.parse(content));
3936
3930
  }
3931
+ return workerExecutionSchema.parse(JSON.parse(readPrivateWorkerFile(this.executionPath(id), 16384)));
3937
3932
  }
3938
3933
  catch {
3939
3934
  return undefined;
3940
3935
  }
3941
3936
  }
3942
3937
  writeWorkerExecution(id, proof, fresh = false) {
3943
- const path = this.executionPath(id);
3944
- try {
3945
- const existing = lstatSync(path);
3946
- if (fresh || !existing.isFile() || existing.isSymbolicLink())
3947
- throw new Error('Unsafe execution checkpoint');
3948
- }
3949
- catch (error) {
3950
- if (error.code !== 'ENOENT')
3951
- throw error;
3952
- }
3953
- const temporary = `${path}.${randomUUID()}.tmp`;
3954
- const fd = openSync(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
3955
- try {
3956
- writeFileSync(fd, JSON.stringify(proof));
3957
- fsyncSync(fd);
3958
- }
3959
- finally {
3960
- closeSync(fd);
3961
- }
3962
- try {
3963
- renameSync(temporary, path);
3964
- }
3965
- finally {
3966
- rmSync(temporary, { force: true });
3938
+ if (isWindowsWorkerEvidence) {
3939
+ writeWindowsEvidence(this.dataDir, id, 'execution', JSON.stringify(proof), fresh);
3940
+ return;
3967
3941
  }
3942
+ replacePrivateWorkerFile(this.executionPath(id), JSON.stringify(proof), fresh);
3968
3943
  }
3969
3944
  /** Complete execution is not permission to reuse/delete persistent resources (#738).
3970
3945
  * Synchronous, fresh and generation/resource fenced; callers hold admission off across awaits. */
@@ -4057,56 +4032,34 @@ export class RunStore extends EventEmitter {
4057
4032
  }
4058
4033
  /** Private process record (#469): which processes a generation spawned, never part of run JSON or SSE. */
4059
4034
  processesPath(id) {
4035
+ if (isWindowsWorkerEvidence)
4036
+ return windowsEvidencePath(this.dataDir, id, 'processes');
4060
4037
  return this.executionPath(id).replace(/\.execution\.json$/, '.processes.json');
4061
4038
  }
4062
4039
  /** Tri-state: only ENOENT is `absent` (legacy, scan-only). A present record that is unreadable,
4063
4040
  * wrongly permissioned, malformed or of another generation is `unknown`: never finalized or reaped. */
4064
4041
  readWorkerProcesses(id, generation) {
4065
4042
  try {
4066
- const fd = openSync(this.processesPath(id), constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
4067
- try {
4068
- const info = fstatSync(fd);
4069
- if (!info.isFile() || info.size > 8192 || (info.mode & 0o077))
4070
- return 'unknown';
4071
- const buffer = Buffer.alloc(8193);
4072
- const count = readSync(fd, buffer, 0, buffer.length, 0);
4073
- const record = workerProcessRecordSchema.parse(JSON.parse(buffer.subarray(0, count).toString('utf8')));
4043
+ if (isWindowsWorkerEvidence) {
4044
+ const content = readWindowsEvidence(this.dataDir, id, 'processes', 8192);
4045
+ if (content === undefined)
4046
+ return 'absent';
4047
+ const record = workerProcessRecordSchema.parse(JSON.parse(content));
4074
4048
  return record.generation === generation ? record : 'unknown';
4075
4049
  }
4076
- finally {
4077
- closeSync(fd);
4078
- }
4050
+ const record = workerProcessRecordSchema.parse(JSON.parse(readPrivateWorkerFile(this.processesPath(id), 8192)));
4051
+ return record.generation === generation ? record : 'unknown';
4079
4052
  }
4080
4053
  catch (error) {
4081
4054
  return error.code === 'ENOENT' ? 'absent' : 'unknown';
4082
4055
  }
4083
4056
  }
4084
4057
  writeWorkerProcesses(id, record) {
4085
- const path = this.processesPath(id);
4086
- try {
4087
- const existing = lstatSync(path);
4088
- if (!existing.isFile() || existing.isSymbolicLink())
4089
- throw new Error('Unsafe process record');
4090
- }
4091
- catch (error) {
4092
- if (error.code !== 'ENOENT')
4093
- throw error;
4094
- }
4095
- const temporary = `${path}.${randomUUID()}.tmp`;
4096
- const fd = openSync(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
4097
- try {
4098
- writeFileSync(fd, JSON.stringify(workerProcessRecordSchema.parse(record)));
4099
- fsyncSync(fd);
4100
- }
4101
- finally {
4102
- closeSync(fd);
4103
- }
4104
- try {
4105
- renameSync(temporary, path);
4106
- }
4107
- finally {
4108
- rmSync(temporary, { force: true });
4058
+ if (isWindowsWorkerEvidence) {
4059
+ writeWindowsEvidence(this.dataDir, id, 'processes', JSON.stringify(workerProcessRecordSchema.parse(record)));
4060
+ return;
4109
4061
  }
4062
+ replacePrivateWorkerFile(this.processesPath(id), JSON.stringify(workerProcessRecordSchema.parse(record)));
4110
4063
  }
4111
4064
  /** Bound to the current generation. Past the cap the record never drops an entry: the
4112
4065
  * working-directory scan is the remaining evidence. */
@@ -4201,7 +4154,7 @@ export class RunStore extends EventEmitter {
4201
4154
  if (receipt.deletion)
4202
4155
  return receipt.deletion.revision === result.revision &&
4203
4156
  receipt.deletion.resourceId === workspace.resourceId && receipt.deletion.phase === 'pending' &&
4204
- (proof ? proof.phase === 'complete' && proof.generation === receipt.deletion.generation : !existsSync(this.executionPath(id)));
4157
+ (proof ? proof.phase === 'complete' && proof.generation === receipt.deletion.generation : executionEvidenceAbsent(this.dataDir, id, this.executionPath(id)));
4205
4158
  return proof?.phase === 'complete';
4206
4159
  }
4207
4160
  canDeleteRun(id) {
@@ -4261,9 +4214,16 @@ export class RunStore extends EventEmitter {
4261
4214
  if (agentTmpDirMayExist(this.dataDir, id))
4262
4215
  return false;
4263
4216
  // Private process/account evidence is now replaced by the exact parent receipt.
4264
- rmSync(this.identityPath(id), { force: true });
4265
- rmSync(this.processesPath(id), { force: true });
4266
- rmSync(this.executionPath(id), { force: true });
4217
+ if (isWindowsWorkerEvidence) {
4218
+ removeWindowsEvidence(this.dataDir, id, 'identity');
4219
+ removeWindowsEvidence(this.dataDir, id, 'processes');
4220
+ removeWindowsEvidence(this.dataDir, id, 'execution');
4221
+ }
4222
+ else {
4223
+ rmSync(this.identityPath(id), { force: true });
4224
+ rmSync(this.processesPath(id), { force: true });
4225
+ rmSync(this.executionPath(id), { force: true });
4226
+ }
4267
4227
  const retained = this.readWorkerResult(parent.id, id);
4268
4228
  this.commitWorkerResult(parent.id, { ...retained, observedAt: new Date().toISOString(),
4269
4229
  diff: retained.diff.state === 'available' ? { ...retained.diff, snapshotId: randomUUID() } : retained.diff,