codex-orchestrator 0.1.47 → 0.1.48

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 (156) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/src/config/schema.d.ts +5 -1
  3. package/dist/src/config/schema.d.ts.map +1 -1
  4. package/dist/src/config/schema.js +16 -0
  5. package/dist/src/config/schema.js.map +1 -1
  6. package/dist/src/runner/command-utils.d.ts.map +1 -1
  7. package/dist/src/runner/command-utils.js +1 -0
  8. package/dist/src/runner/command-utils.js.map +1 -1
  9. package/dist/src/runner/local-execution-session.d.ts.map +1 -1
  10. package/dist/src/runner/local-execution-session.js +5 -2
  11. package/dist/src/runner/local-execution-session.js.map +1 -1
  12. package/dist/src/runner/mission-activation.d.ts +29 -0
  13. package/dist/src/runner/mission-activation.d.ts.map +1 -0
  14. package/dist/src/runner/mission-activation.js +54 -0
  15. package/dist/src/runner/mission-activation.js.map +1 -0
  16. package/dist/src/runner/mission-agent-broker.d.ts +53 -0
  17. package/dist/src/runner/mission-agent-broker.d.ts.map +1 -0
  18. package/dist/src/runner/mission-agent-broker.js +182 -0
  19. package/dist/src/runner/mission-agent-broker.js.map +1 -0
  20. package/dist/src/runner/mission-cancellation.d.ts +77 -0
  21. package/dist/src/runner/mission-cancellation.d.ts.map +1 -0
  22. package/dist/src/runner/mission-cancellation.js +180 -0
  23. package/dist/src/runner/mission-cancellation.js.map +1 -0
  24. package/dist/src/runner/mission-canonical-path.d.ts +34 -0
  25. package/dist/src/runner/mission-canonical-path.d.ts.map +1 -0
  26. package/dist/src/runner/mission-canonical-path.js +121 -0
  27. package/dist/src/runner/mission-canonical-path.js.map +1 -0
  28. package/dist/src/runner/mission-capability-kernel.d.ts +34 -0
  29. package/dist/src/runner/mission-capability-kernel.d.ts.map +1 -0
  30. package/dist/src/runner/mission-capability-kernel.js +158 -0
  31. package/dist/src/runner/mission-capability-kernel.js.map +1 -0
  32. package/dist/src/runner/mission-check-policy.d.ts +17 -0
  33. package/dist/src/runner/mission-check-policy.d.ts.map +1 -0
  34. package/dist/src/runner/mission-check-policy.js +31 -0
  35. package/dist/src/runner/mission-check-policy.js.map +1 -0
  36. package/dist/src/runner/mission-coordinator-lock.d.ts +16 -0
  37. package/dist/src/runner/mission-coordinator-lock.d.ts.map +1 -0
  38. package/dist/src/runner/mission-coordinator-lock.js +170 -0
  39. package/dist/src/runner/mission-coordinator-lock.js.map +1 -0
  40. package/dist/src/runner/mission-deployment.d.ts +21 -0
  41. package/dist/src/runner/mission-deployment.d.ts.map +1 -0
  42. package/dist/src/runner/mission-deployment.js +108 -0
  43. package/dist/src/runner/mission-deployment.js.map +1 -0
  44. package/dist/src/runner/mission-evaluation.d.ts +61 -0
  45. package/dist/src/runner/mission-evaluation.d.ts.map +1 -0
  46. package/dist/src/runner/mission-evaluation.js +183 -0
  47. package/dist/src/runner/mission-evaluation.js.map +1 -0
  48. package/dist/src/runner/mission-executor-probe.d.ts +10 -0
  49. package/dist/src/runner/mission-executor-probe.d.ts.map +1 -0
  50. package/dist/src/runner/mission-executor-probe.js +180 -0
  51. package/dist/src/runner/mission-executor-probe.js.map +1 -0
  52. package/dist/src/runner/mission-git-contracts.d.ts +75 -0
  53. package/dist/src/runner/mission-git-contracts.d.ts.map +1 -0
  54. package/dist/src/runner/mission-git-contracts.js +201 -0
  55. package/dist/src/runner/mission-git-contracts.js.map +1 -0
  56. package/dist/src/runner/mission-git-runtime-owner-ref.d.ts +13 -0
  57. package/dist/src/runner/mission-git-runtime-owner-ref.d.ts.map +1 -0
  58. package/dist/src/runner/mission-git-runtime-owner-ref.js +111 -0
  59. package/dist/src/runner/mission-git-runtime-owner-ref.js.map +1 -0
  60. package/dist/src/runner/mission-git-transaction.d.ts +97 -0
  61. package/dist/src/runner/mission-git-transaction.d.ts.map +1 -0
  62. package/dist/src/runner/mission-git-transaction.js +1009 -0
  63. package/dist/src/runner/mission-git-transaction.js.map +1 -0
  64. package/dist/src/runner/mission-identifiers.d.ts +31 -0
  65. package/dist/src/runner/mission-identifiers.d.ts.map +1 -0
  66. package/dist/src/runner/mission-identifiers.js +75 -0
  67. package/dist/src/runner/mission-identifiers.js.map +1 -0
  68. package/dist/src/runner/mission-input-snapshot.d.ts +21 -0
  69. package/dist/src/runner/mission-input-snapshot.d.ts.map +1 -0
  70. package/dist/src/runner/mission-input-snapshot.js +63 -0
  71. package/dist/src/runner/mission-input-snapshot.js.map +1 -0
  72. package/dist/src/runner/mission-ownership.d.ts +38 -0
  73. package/dist/src/runner/mission-ownership.d.ts.map +1 -0
  74. package/dist/src/runner/mission-ownership.js +88 -0
  75. package/dist/src/runner/mission-ownership.js.map +1 -0
  76. package/dist/src/runner/mission-patch-audit.d.ts +21 -0
  77. package/dist/src/runner/mission-patch-audit.d.ts.map +1 -0
  78. package/dist/src/runner/mission-patch-audit.js +186 -0
  79. package/dist/src/runner/mission-patch-audit.js.map +1 -0
  80. package/dist/src/runner/mission-path-language.d.ts +6 -0
  81. package/dist/src/runner/mission-path-language.d.ts.map +1 -0
  82. package/dist/src/runner/mission-path-language.js +106 -0
  83. package/dist/src/runner/mission-path-language.js.map +1 -0
  84. package/dist/src/runner/mission-permit-authority.d.ts +26 -0
  85. package/dist/src/runner/mission-permit-authority.d.ts.map +1 -0
  86. package/dist/src/runner/mission-permit-authority.js +145 -0
  87. package/dist/src/runner/mission-permit-authority.js.map +1 -0
  88. package/dist/src/runner/mission-plan-parent-coordinator.d.ts +87 -0
  89. package/dist/src/runner/mission-plan-parent-coordinator.d.ts.map +1 -0
  90. package/dist/src/runner/mission-plan-parent-coordinator.js +412 -0
  91. package/dist/src/runner/mission-plan-parent-coordinator.js.map +1 -0
  92. package/dist/src/runner/mission-plan-parent.d.ts +154 -0
  93. package/dist/src/runner/mission-plan-parent.d.ts.map +1 -0
  94. package/dist/src/runner/mission-plan-parent.js +583 -0
  95. package/dist/src/runner/mission-plan-parent.js.map +1 -0
  96. package/dist/src/runner/mission-process-executor.d.ts +25 -0
  97. package/dist/src/runner/mission-process-executor.d.ts.map +1 -0
  98. package/dist/src/runner/mission-process-executor.js +182 -0
  99. package/dist/src/runner/mission-process-executor.js.map +1 -0
  100. package/dist/src/runner/mission-quarantine-patch-executor.d.ts +29 -0
  101. package/dist/src/runner/mission-quarantine-patch-executor.d.ts.map +1 -0
  102. package/dist/src/runner/mission-quarantine-patch-executor.js +121 -0
  103. package/dist/src/runner/mission-quarantine-patch-executor.js.map +1 -0
  104. package/dist/src/runner/mission-repository-executor.d.ts +54 -0
  105. package/dist/src/runner/mission-repository-executor.d.ts.map +1 -0
  106. package/dist/src/runner/mission-repository-executor.js +192 -0
  107. package/dist/src/runner/mission-repository-executor.js.map +1 -0
  108. package/dist/src/runner/mission-repository-observer.d.ts +8 -0
  109. package/dist/src/runner/mission-repository-observer.d.ts.map +1 -0
  110. package/dist/src/runner/mission-repository-observer.js +24 -0
  111. package/dist/src/runner/mission-repository-observer.js.map +1 -0
  112. package/dist/src/runner/mission-reservations.d.ts +15 -0
  113. package/dist/src/runner/mission-reservations.d.ts.map +1 -0
  114. package/dist/src/runner/mission-reservations.js +116 -0
  115. package/dist/src/runner/mission-reservations.js.map +1 -0
  116. package/dist/src/runner/mission-resolution-loop.d.ts +172 -0
  117. package/dist/src/runner/mission-resolution-loop.d.ts.map +1 -0
  118. package/dist/src/runner/mission-resolution-loop.js +318 -0
  119. package/dist/src/runner/mission-resolution-loop.js.map +1 -0
  120. package/dist/src/runner/mission-runtime-owner.d.ts +36 -0
  121. package/dist/src/runner/mission-runtime-owner.d.ts.map +1 -0
  122. package/dist/src/runner/mission-runtime-owner.js +174 -0
  123. package/dist/src/runner/mission-runtime-owner.js.map +1 -0
  124. package/dist/src/runner/mission-safe-executor.d.ts +96 -0
  125. package/dist/src/runner/mission-safe-executor.d.ts.map +1 -0
  126. package/dist/src/runner/mission-safe-executor.js +288 -0
  127. package/dist/src/runner/mission-safe-executor.js.map +1 -0
  128. package/dist/src/runner/mission-sandbox.d.ts +16 -0
  129. package/dist/src/runner/mission-sandbox.d.ts.map +1 -0
  130. package/dist/src/runner/mission-sandbox.js +91 -0
  131. package/dist/src/runner/mission-sandbox.js.map +1 -0
  132. package/dist/src/runner/mission-scheduler.d.ts +57 -0
  133. package/dist/src/runner/mission-scheduler.d.ts.map +1 -0
  134. package/dist/src/runner/mission-scheduler.js +205 -0
  135. package/dist/src/runner/mission-scheduler.js.map +1 -0
  136. package/dist/src/runner/mission-scope-expansion.d.ts +47 -0
  137. package/dist/src/runner/mission-scope-expansion.d.ts.map +1 -0
  138. package/dist/src/runner/mission-scope-expansion.js +147 -0
  139. package/dist/src/runner/mission-scope-expansion.js.map +1 -0
  140. package/dist/src/runner/mission-state-machine.d.ts +118 -0
  141. package/dist/src/runner/mission-state-machine.d.ts.map +1 -0
  142. package/dist/src/runner/mission-state-machine.js +316 -0
  143. package/dist/src/runner/mission-state-machine.js.map +1 -0
  144. package/dist/src/runner/mission-state-store.d.ts +70 -0
  145. package/dist/src/runner/mission-state-store.d.ts.map +1 -0
  146. package/dist/src/runner/mission-state-store.js +856 -0
  147. package/dist/src/runner/mission-state-store.js.map +1 -0
  148. package/dist/src/runner/rework-policy.d.ts +2 -1
  149. package/dist/src/runner/rework-policy.d.ts.map +1 -1
  150. package/dist/src/runner/rework-policy.js +3 -0
  151. package/dist/src/runner/rework-policy.js.map +1 -1
  152. package/dist/src/setup/project-config.d.ts.map +1 -1
  153. package/dist/src/setup/project-config.js +5 -0
  154. package/dist/src/setup/project-config.js.map +1 -1
  155. package/docs/deep-dive.md +25 -16
  156. package/package.json +1 -1
@@ -0,0 +1,121 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { constants } from 'node:fs';
3
+ import { lstat, open, realpath, stat } from 'node:fs/promises';
4
+ import { isAbsolute, join, relative } from 'node:path';
5
+ import { globMatches, normalizePath } from '../path-policy.js';
6
+ import { missionPathDenied } from './mission-path-language.js';
7
+ export async function readCanonicalText(input) {
8
+ const normalized = assertRepositoryRelativePath(input.path);
9
+ if (!input.grantedPaths.some((pattern) => globMatches(pattern, normalized))) {
10
+ throw new Error(`Mission observation path is outside granted scope: ${input.path}.`);
11
+ }
12
+ const inspected = await inspectCanonicalFile({
13
+ root: input.root,
14
+ path: input.path,
15
+ deniedPaths: input.deniedPaths,
16
+ maxBytes: input.maxBytes,
17
+ missing: 'reject',
18
+ });
19
+ if (!inspected)
20
+ throw new Error(`Mission observation file is missing: ${input.path}.`);
21
+ if (inspected.content.includes(0)) {
22
+ throw new Error(`Mission observation refuses binary file: ${input.path}.`);
23
+ }
24
+ return { text: inspected.content.toString('utf8'), identity: inspected.identity };
25
+ }
26
+ export async function inspectCanonicalFile(input, dependencies = {}) {
27
+ const normalized = assertRepositoryRelativePath(input.path);
28
+ if (missionPathDenied(normalized, input.deniedPaths)) {
29
+ throw new Error(`Mission canonical path is denied: ${normalized}.`);
30
+ }
31
+ const canonicalRoot = await realpath(input.root);
32
+ let current = canonicalRoot;
33
+ for (const segment of normalized.split('/')) {
34
+ current = join(current, segment);
35
+ let info;
36
+ try {
37
+ info = await lstat(current);
38
+ }
39
+ catch (error) {
40
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT'
41
+ && input.missing !== 'reject')
42
+ return undefined;
43
+ throw error;
44
+ }
45
+ if (info.isSymbolicLink()) {
46
+ throw new Error(`Mission canonical path refuses symbolic link: ${normalized}.`);
47
+ }
48
+ }
49
+ const canonicalTarget = await realpath(current);
50
+ const canonicalRelative = normalizePath(relative(canonicalRoot, canonicalTarget));
51
+ if (canonicalRelative.startsWith('../') || canonicalRelative === '..' || isAbsolute(canonicalRelative)) {
52
+ throw new Error(`Mission canonical path escapes repository root: ${normalized}.`);
53
+ }
54
+ if (missionPathDenied(canonicalRelative, input.deniedPaths)) {
55
+ throw new Error(`Mission canonical path is denied: ${canonicalRelative}.`);
56
+ }
57
+ const expected = await stat(canonicalTarget, { bigint: true });
58
+ assertRegularSingleLink(expected, normalized);
59
+ const handle = await open(current, constants.O_RDONLY | constants.O_NOFOLLOW);
60
+ try {
61
+ const opened = await handle.stat({ bigint: true });
62
+ assertSameIdentity(expected, opened, normalized);
63
+ assertStableMetadata(expected, opened, normalized);
64
+ assertRegularSingleLink(opened, normalized);
65
+ const maxBytes = input.maxBytes ?? 64 * 1024 * 1024;
66
+ if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0 || opened.size > BigInt(maxBytes)) {
67
+ throw new Error(`Mission canonical path size limit exceeded: ${opened.size} > ${maxBytes}.`);
68
+ }
69
+ await dependencies.beforeRead?.();
70
+ const content = await handle.readFile();
71
+ const after = await handle.stat({ bigint: true });
72
+ assertSameIdentity(opened, after, normalized);
73
+ assertStableMetadata(opened, after, normalized);
74
+ assertRegularSingleLink(after, normalized);
75
+ if (after.size !== BigInt(content.byteLength)) {
76
+ throw new Error(`Mission canonical path changed length during read: ${normalized}.`);
77
+ }
78
+ return {
79
+ content,
80
+ identity: {
81
+ repositoryPath: canonicalRelative,
82
+ canonicalPath: canonicalTarget,
83
+ dev: Number(after.dev),
84
+ ino: Number(after.ino),
85
+ mode: Number(after.mode),
86
+ size: Number(after.size),
87
+ mtimeMs: Number(after.mtimeNs) / 1_000_000,
88
+ sha256: createHash('sha256').update(content).digest('hex'),
89
+ },
90
+ };
91
+ }
92
+ finally {
93
+ await handle.close();
94
+ }
95
+ }
96
+ function assertRepositoryRelativePath(path) {
97
+ const normalized = normalizePath(path);
98
+ if (isAbsolute(path) || normalized.length === 0
99
+ || normalized.split('/').some((segment) => segment.length === 0 || segment === '..')) {
100
+ throw new Error('Mission canonical path must be repository-relative without empty segments.');
101
+ }
102
+ return normalized;
103
+ }
104
+ function assertRegularSingleLink(info, path) {
105
+ if (!info.isFile() || (typeof info.nlink === 'bigint' ? info.nlink !== 1n : info.nlink !== 1)) {
106
+ throw new Error(`Mission canonical path refuses non-regular or hard-linked file: ${path}.`);
107
+ }
108
+ }
109
+ function assertSameIdentity(expected, actual, path) {
110
+ if (expected.dev !== actual.dev || expected.ino !== actual.ino) {
111
+ throw new Error(`Mission canonical path changed during authorization: ${path}.`);
112
+ }
113
+ }
114
+ function assertStableMetadata(expected, actual, path) {
115
+ if (expected.mode !== actual.mode || expected.nlink !== actual.nlink
116
+ || expected.size !== actual.size || expected.mtimeNs !== actual.mtimeNs
117
+ || expected.ctimeNs !== actual.ctimeNs) {
118
+ throw new Error(`Mission canonical path changed during read: ${path}.`);
119
+ }
120
+ }
121
+ //# sourceMappingURL=mission-canonical-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission-canonical-path.js","sourceRoot":"","sources":["../../../src/runner/mission-canonical-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAiB/D,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,KAMvC;IACC,MAAM,UAAU,GAAG,4BAA4B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5D,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC;QAC5E,MAAM,IAAI,KAAK,CAAC,sDAAsD,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;IACvF,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC;QAC3C,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,IAAI,EAAE,KAAK,CAAC,IAAI;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CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC;QAC/D,MAAM,IAAI,KAAK,CAAC,wDAAwD,IAAI,GAAG,CAAC,CAAC;IACnF,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAC3B,QAMC,EACD,MAMC,EACD,IAAY;IAEZ,IAAI,QAAQ,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,IAAI,QAAQ,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK;WAC/D,QAAQ,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,IAAI,QAAQ,CAAC,OAAO,KAAK,MAAM,CAAC,OAAO;WACpE,QAAQ,CAAC,OAAO,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,+CAA+C,IAAI,GAAG,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC"}
@@ -0,0 +1,34 @@
1
+ export type MissionSandboxBackend = 'macos-sandbox' | 'linux-bwrap';
2
+ export type MissionCapability = 'git-status' | 'read-file' | 'validate-patch';
3
+ export declare const missionGitStatusArgv: readonly ["/usr/bin/git", "-c", "core.fsmonitor=false", "-c", "core.untrackedCache=false", "-c", "core.hooksPath=/dev/null", "status", "--porcelain=v1", "--untracked-files=all"];
4
+ export interface MissionCapabilityProbeInput {
5
+ platform: NodeJS.Platform;
6
+ commands: ReadonlySet<string>;
7
+ }
8
+ export interface MissionCapabilityProbeResult {
9
+ prerequisitesAvailable: boolean;
10
+ backend?: MissionSandboxBackend;
11
+ missing: string[];
12
+ }
13
+ export interface MissionCapabilityRequest {
14
+ missionId: string;
15
+ actionKey: string;
16
+ capability: MissionCapability;
17
+ argv: string[];
18
+ requestedPaths: string[];
19
+ grantedPaths: string[];
20
+ inputSnapshot: string;
21
+ fencingEpoch: number;
22
+ expiresAt: string;
23
+ readPath?: string;
24
+ maxReadBytes?: number;
25
+ }
26
+ export interface MissionCapabilityPermit extends MissionCapabilityRequest {
27
+ network: 'deny';
28
+ workspace: 'read-only';
29
+ }
30
+ export declare function missionCapabilityPermitFingerprint(permit: MissionCapabilityPermit): string;
31
+ export declare function discoverMissionExecutorPrerequisites(input: MissionCapabilityProbeInput): MissionCapabilityProbeResult;
32
+ export declare function authorizeMissionCapability(request: MissionCapabilityRequest): MissionCapabilityPermit;
33
+ export declare function scrubMissionExecutorEnv(source: NodeJS.ProcessEnv, allowedKeys: string[]): Record<string, string>;
34
+ //# sourceMappingURL=mission-capability-kernel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission-capability-kernel.d.ts","sourceRoot":"","sources":["../../../src/runner/mission-capability-kernel.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,qBAAqB,GAAG,eAAe,GAAG,aAAa,CAAC;AACpE,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAE9E,eAAO,MAAM,oBAAoB,mLAMvB,CAAC;AAEX,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,4BAA4B;IAC3C,sBAAsB,EAAE,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,uBAAwB,SAAQ,wBAAwB;IACvE,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,WAAW,CAAC;CACxB;AAED,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,uBAAuB,GAAG,MAAM,CAkB1F;AAOD,wBAAgB,oCAAoC,CAClD,KAAK,EAAE,2BAA2B,GACjC,4BAA4B,CA4B9B;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,wBAAwB,GAChC,uBAAuB,CAoDzB;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,CAAC,UAAU,EACzB,WAAW,EAAE,MAAM,EAAE,GACpB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAYxB"}
@@ -0,0 +1,158 @@
1
+ import { basename } from 'node:path';
2
+ import { createHash } from 'node:crypto';
3
+ import { uniqueSortedPaths } from '../path-policy.js';
4
+ import { assertMissionPathPattern, scopePatternContainedBy } from './mission-path-language.js';
5
+ export const missionGitStatusArgv = [
6
+ '/usr/bin/git',
7
+ '-c', 'core.fsmonitor=false',
8
+ '-c', 'core.untrackedCache=false',
9
+ '-c', 'core.hooksPath=/dev/null',
10
+ 'status', '--porcelain=v1', '--untracked-files=all',
11
+ ];
12
+ export function missionCapabilityPermitFingerprint(permit) {
13
+ const canonical = JSON.stringify([
14
+ 'mission-capability-permit-v1',
15
+ permit.missionId,
16
+ permit.actionKey,
17
+ permit.capability,
18
+ permit.argv,
19
+ permit.requestedPaths,
20
+ permit.grantedPaths,
21
+ permit.inputSnapshot,
22
+ permit.fencingEpoch,
23
+ permit.expiresAt,
24
+ permit.readPath ?? null,
25
+ permit.maxReadBytes ?? null,
26
+ permit.network,
27
+ permit.workspace,
28
+ ]);
29
+ return `sha256:${createHash('sha256').update(canonical).digest('hex')}`;
30
+ }
31
+ const secretPath = /(^|\/)(?:\.env(?:\..*)?|\.git(?:\/|$)|id_(?:rsa|ed25519)(?:\.pub)?$)/iu;
32
+ const safeEnvironmentKeys = new Set([
33
+ 'CI', 'LANG', 'LC_ALL', 'LC_CTYPE', 'NO_COLOR', 'PATH', 'TERM', 'TZ',
34
+ ]);
35
+ export function discoverMissionExecutorPrerequisites(input) {
36
+ if (input.platform === 'darwin') {
37
+ const missing = [
38
+ input.commands.has('/usr/bin/sandbox-exec') ? undefined : 'sandbox-exec',
39
+ input.commands.has('/usr/bin/git') ? undefined : 'git',
40
+ ].filter((value) => value !== undefined);
41
+ return {
42
+ prerequisitesAvailable: missing.length === 0,
43
+ backend: missing.length === 0 ? 'macos-sandbox' : undefined,
44
+ missing,
45
+ };
46
+ }
47
+ if (input.platform === 'linux') {
48
+ const hasBwrap = [...input.commands].some((command) => basename(command) === 'bwrap');
49
+ const hasGit = [...input.commands].some((command) => basename(command) === 'git');
50
+ const missing = [hasBwrap ? undefined : 'bwrap', hasGit ? undefined : 'git']
51
+ .filter((value) => value !== undefined);
52
+ return {
53
+ prerequisitesAvailable: missing.length === 0,
54
+ backend: missing.length === 0 ? 'linux-bwrap' : undefined,
55
+ missing,
56
+ };
57
+ }
58
+ return {
59
+ prerequisitesAvailable: false,
60
+ backend: undefined,
61
+ missing: [`unsupported-platform:${input.platform}`],
62
+ };
63
+ }
64
+ export function authorizeMissionCapability(request) {
65
+ requireText(request.missionId, 'missionId');
66
+ requireText(request.actionKey, 'actionKey');
67
+ requireText(request.inputSnapshot, 'inputSnapshot');
68
+ if (!Number.isSafeInteger(request.fencingEpoch) || request.fencingEpoch <= 0) {
69
+ throw new Error('Mission capability fencingEpoch must be a positive integer.');
70
+ }
71
+ if (!Number.isFinite(Date.parse(request.expiresAt))) {
72
+ throw new Error('Mission capability expiresAt must be an ISO timestamp.');
73
+ }
74
+ assertAllowedArgv(request.capability, request.argv);
75
+ const grantedPaths = normalizeScope(request.grantedPaths, 'granted');
76
+ const requestedPaths = normalizeScope(request.requestedPaths, 'requested');
77
+ if (request.capability === 'read-file') {
78
+ if (typeof request.readPath !== 'string' || request.readPath.includes('*')
79
+ || requestedPaths.length !== 1 || requestedPaths[0] !== request.readPath
80
+ || !Number.isSafeInteger(request.maxReadBytes) || request.maxReadBytes <= 0
81
+ || request.maxReadBytes > 1024 * 1024) {
82
+ throw new Error('Mission read-file requires one concrete readPath and maxReadBytes up to 1048576.');
83
+ }
84
+ }
85
+ else if (request.readPath !== undefined || request.maxReadBytes !== undefined) {
86
+ throw new Error(`Mission capability ${request.capability} forbids read-file inputs.`);
87
+ }
88
+ if (request.capability === 'git-status'
89
+ && (requestedPaths.length !== 1 || requestedPaths[0] !== '**')) {
90
+ throw new Error('Mission capability git-status requires explicit whole-repository scope.');
91
+ }
92
+ for (const path of requestedPaths) {
93
+ if (secretPath.test(path)) {
94
+ throw new Error(`Mission capability requested secret path: ${path}.`);
95
+ }
96
+ if (!grantedPaths.some((grant) => scopePatternContainedBy(path, grant))) {
97
+ throw new Error(`Mission capability path is outside granted scope: ${path}.`);
98
+ }
99
+ }
100
+ return {
101
+ missionId: request.missionId,
102
+ actionKey: request.actionKey,
103
+ capability: request.capability,
104
+ argv: [...request.argv],
105
+ requestedPaths,
106
+ grantedPaths,
107
+ inputSnapshot: request.inputSnapshot,
108
+ fencingEpoch: request.fencingEpoch,
109
+ expiresAt: request.expiresAt,
110
+ ...(request.capability === 'read-file' ? {
111
+ readPath: request.readPath,
112
+ maxReadBytes: request.maxReadBytes,
113
+ } : {}),
114
+ network: 'deny',
115
+ workspace: 'read-only',
116
+ };
117
+ }
118
+ export function scrubMissionExecutorEnv(source, allowedKeys) {
119
+ const result = {};
120
+ for (const key of [...new Set(allowedKeys)].sort()) {
121
+ if (!safeEnvironmentKeys.has(key)) {
122
+ continue;
123
+ }
124
+ const value = source[key];
125
+ if (value !== undefined) {
126
+ result[key] = value;
127
+ }
128
+ }
129
+ return result;
130
+ }
131
+ function assertAllowedArgv(capability, argv) {
132
+ const expected = {
133
+ 'git-status': [[]],
134
+ 'read-file': [[]],
135
+ 'validate-patch': [[]],
136
+ };
137
+ const normalized = argv.map((value, index) => index === 0 ? basename(value) : value);
138
+ if (!expected[capability].some((candidate) => arraysEqual(candidate, normalized))) {
139
+ throw new Error(`Mission capability ${capability} requires allowlisted argv.`);
140
+ }
141
+ }
142
+ function normalizeScope(paths, kind) {
143
+ const normalized = uniqueSortedPaths(paths);
144
+ if (normalized.length === 0) {
145
+ throw new Error(`Mission capability ${kind} scope must contain repository-relative globs.`);
146
+ }
147
+ normalized.forEach((path) => assertMissionPathPattern(path, `Mission capability ${kind} scope`));
148
+ return normalized;
149
+ }
150
+ function arraysEqual(left, right) {
151
+ return left.length === right.length && left.every((value, index) => value === right[index]);
152
+ }
153
+ function requireText(value, field) {
154
+ if (value.trim().length === 0) {
155
+ throw new Error(`Mission capability ${field} must be non-empty.`);
156
+ }
157
+ }
158
+ //# sourceMappingURL=mission-capability-kernel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission-capability-kernel.js","sourceRoot":"","sources":["../../../src/runner/mission-capability-kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAK/F,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,cAAc;IACd,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE,2BAA2B;IACjC,IAAI,EAAE,0BAA0B;IAChC,QAAQ,EAAE,gBAAgB,EAAE,uBAAuB;CAC3C,CAAC;AAgCX,MAAM,UAAU,kCAAkC,CAAC,MAA+B;IAChF,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAC/B,8BAA8B;QAC9B,MAAM,CAAC,SAAS;QAChB,MAAM,CAAC,SAAS;QAChB,MAAM,CAAC,UAAU;QACjB,MAAM,CAAC,IAAI;QACX,M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wBAAwB,CAAC,IAAI,EAAE,sBAAsB,IAAI,QAAQ,CAAC,CAAC,CAAC;IACjG,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,WAAW,CAAC,IAAc,EAAE,KAAe;IAClD,OAAO,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9F,CAAC;AAED,SAAS,WAAW,CAAC,KAAa,EAAE,KAAa;IAC/C,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,qBAAqB,CAAC,CAAC;IACpE,CAAC;AACH,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { type MissionCapability } from './mission-capability-kernel.js';
2
+ export interface RunnerOwnedMissionCheck {
3
+ executable: string;
4
+ args: string[];
5
+ capability: MissionCapability;
6
+ }
7
+ export type MissionCheckClassification = {
8
+ kind: 'legacy-shell';
9
+ reason: 'string-command-has-no-enforced-argv-contract';
10
+ } | {
11
+ kind: 'safe-runner-argv';
12
+ executable: string;
13
+ args: string[];
14
+ capability: MissionCapability;
15
+ };
16
+ export declare function classifyMissionCheck(check: string | RunnerOwnedMissionCheck): MissionCheckClassification;
17
+ //# sourceMappingURL=mission-check-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission-check-policy.d.ts","sourceRoot":"","sources":["../../../src/runner/mission-check-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,gCAAgC,CAAC;AAExC,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,UAAU,EAAE,iBAAiB,CAAC;CAC/B;AAED,MAAM,MAAM,0BAA0B,GAClC;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,8CAA8C,CAAA;CAAE,GAChF;IACE,IAAI,EAAE,kBAAkB,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,UAAU,EAAE,iBAAiB,CAAC;CAC/B,CAAC;AAEN,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,uBAAuB,GACtC,0BAA0B,CA4B5B"}
@@ -0,0 +1,31 @@
1
+ import { authorizeMissionCapability, missionGitStatusArgv, } from './mission-capability-kernel.js';
2
+ export function classifyMissionCheck(check) {
3
+ if (typeof check === 'string') {
4
+ return {
5
+ kind: 'legacy-shell',
6
+ reason: 'string-command-has-no-enforced-argv-contract',
7
+ };
8
+ }
9
+ authorizeMissionCapability({
10
+ missionId: 'classification-probe',
11
+ actionKey: 'classification-probe',
12
+ capability: check.capability,
13
+ argv: [],
14
+ requestedPaths: ['**'],
15
+ grantedPaths: ['**'],
16
+ inputSnapshot: 'classification-probe',
17
+ fencingEpoch: 1,
18
+ expiresAt: '2099-01-01T00:00:00.000Z',
19
+ });
20
+ if (check.capability !== 'git-status'
21
+ || [check.executable, ...check.args].join('\0') !== missionGitStatusArgv.join('\0')) {
22
+ throw new Error(`Mission capability ${check.capability} requires allowlisted argv.`);
23
+ }
24
+ return {
25
+ kind: 'safe-runner-argv',
26
+ executable: check.executable,
27
+ args: [...check.args],
28
+ capability: check.capability,
29
+ };
30
+ }
31
+ //# sourceMappingURL=mission-check-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission-check-policy.js","sourceRoot":"","sources":["../../../src/runner/mission-check-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GAErB,MAAM,gCAAgC,CAAC;AAiBxC,MAAM,UAAU,oBAAoB,CAClC,KAAuC;IAEvC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO;YACL,IAAI,EAAE,cAAc;YACpB,MAAM,EAAE,8CAA8C;SACvD,CAAC;IACJ,CAAC;IACD,0BAA0B,CAAC;QACzB,SAAS,EAAE,sBAAsB;QACjC,SAAS,EAAE,sBAAsB;QACjC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,IAAI,EAAE,EAAE;QACR,cAAc,EAAE,CAAC,IAAI,CAAC;QACtB,YAAY,EAAE,CAAC,IAAI,CAAC;QACpB,aAAa,EAAE,sBAAsB;QACrC,YAAY,EAAE,CAAC;QACf,SAAS,EAAE,0BAA0B;KACtC,CAAC,CAAC;IACH,IAAI,KAAK,CAAC,UAAU,KAAK,YAAY;WAChC,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACtF,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,CAAC,UAAU,6BAA6B,CAAC,CAAC;IACvF,CAAC;IACD,OAAO;QACL,IAAI,EAAE,kBAAkB;QACxB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC;QACrB,UAAU,EAAE,KAAK,CAAC,UAAU;KAC7B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ export interface MissionCoordinatorLockInput {
2
+ targetRoot: string;
3
+ stateDir: string;
4
+ hostId: string;
5
+ bootNonce: string;
6
+ pid?: number;
7
+ now?: Date;
8
+ isProcessAlive?: (pid: number) => boolean;
9
+ waitTimeoutMs?: number;
10
+ }
11
+ export interface MissionCoordinatorLock {
12
+ metadataPath: string;
13
+ release(): Promise<void>;
14
+ }
15
+ export declare function acquireMissionCoordinatorLock(input: MissionCoordinatorLockInput): Promise<MissionCoordinatorLock>;
16
+ //# sourceMappingURL=mission-coordinator-lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission-coordinator-lock.d.ts","sourceRoot":"","sources":["../../../src/runner/mission-coordinator-lock.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IAC1C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAWD,wBAAsB,6BAA6B,CACjD,KAAK,EAAE,2BAA2B,GACjC,OAAO,CAAC,sBAAsB,CAAC,CAwFjC"}
@@ -0,0 +1,170 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ export async function acquireMissionCoordinatorLock(input) {
5
+ const lockDirectory = join(input.targetRoot, input.stateDir, 'mission-coordinator.lock');
6
+ const metadataPath = join(lockDirectory, 'owner.json');
7
+ const token = randomUUID();
8
+ const owner = {
9
+ version: 1,
10
+ token,
11
+ hostId: requireText(input.hostId, 'hostId'),
12
+ bootNonce: requireText(input.bootNonce, 'bootNonce'),
13
+ pid: input.pid ?? process.pid,
14
+ acquiredAt: (input.now ?? new Date()).toISOString(),
15
+ };
16
+ if (!Number.isSafeInteger(owner.pid) || owner.pid <= 0) {
17
+ throw new Error('Mission coordinator pid must be a positive integer.');
18
+ }
19
+ const alive = input.isProcessAlive ?? defaultProcessAlive;
20
+ let reclaimGuardPath;
21
+ const waitTimeoutMs = input.waitTimeoutMs ?? 0;
22
+ if (!Number.isSafeInteger(waitTimeoutMs) || waitTimeoutMs < 0) {
23
+ throw new Error('Mission coordinator waitTimeoutMs must be a non-negative integer.');
24
+ }
25
+ const deadline = Date.now() + waitTimeoutMs;
26
+ await mkdir(join(input.targetRoot, input.stateDir), { recursive: true });
27
+ while (true) {
28
+ const candidateDirectory = `${lockDirectory}.candidate.${token}.${randomUUID()}`;
29
+ try {
30
+ await mkdir(candidateDirectory);
31
+ try {
32
+ await writeFile(join(candidateDirectory, 'owner.json'), `${JSON.stringify(owner)}\n`, {
33
+ encoding: 'utf8',
34
+ flag: 'wx',
35
+ mode: 0o600,
36
+ });
37
+ await rename(candidateDirectory, lockDirectory);
38
+ }
39
+ catch (error) {
40
+ await rm(candidateDirectory, { recursive: true, force: true });
41
+ throw error;
42
+ }
43
+ if (reclaimGuardPath) {
44
+ await rm(reclaimGuardPath, { recursive: true, force: true });
45
+ }
46
+ return {
47
+ metadataPath,
48
+ release: () => releaseLock(lockDirectory, metadataPath, token),
49
+ };
50
+ }
51
+ catch (error) {
52
+ if (!isCode(error, 'EEXIST') && !isCode(error, 'ENOTEMPTY')) {
53
+ throw error;
54
+ }
55
+ let existing;
56
+ try {
57
+ existing = await readLockOwner(metadataPath);
58
+ }
59
+ catch (readError) {
60
+ if (isCode(readError, 'ENOENT')) {
61
+ await delay(5);
62
+ continue;
63
+ }
64
+ throw readError;
65
+ }
66
+ if (existing.hostId !== owner.hostId) {
67
+ throw new Error(`Mission coordinator lock belongs to a different host: ${existing.hostId}.`);
68
+ }
69
+ const ownerStillAlive = existing.pid === owner.pid
70
+ ? existing.bootNonce === owner.bootNonce
71
+ : alive(existing.pid);
72
+ if (ownerStillAlive) {
73
+ if (Date.now() < deadline) {
74
+ await delay(10);
75
+ continue;
76
+ }
77
+ throw new Error(`Mission coordinator lock is already owned by pid ${existing.pid}.`);
78
+ }
79
+ const stalePath = `${lockDirectory}.stale.${existing.token}`;
80
+ try {
81
+ await rename(lockDirectory, stalePath);
82
+ }
83
+ catch (renameError) {
84
+ if (isCode(renameError, 'ENOENT')) {
85
+ continue;
86
+ }
87
+ if (isCode(renameError, 'EEXIST') || isCode(renameError, 'ENOTEMPTY')) {
88
+ throw new Error(`Mission coordinator stale reclaim guard already exists for token ${existing.token}.`);
89
+ }
90
+ throw renameError;
91
+ }
92
+ reclaimGuardPath = stalePath;
93
+ }
94
+ }
95
+ }
96
+ async function releaseLock(lockDirectory, metadataPath, token) {
97
+ let current;
98
+ try {
99
+ current = await readLockOwner(metadataPath);
100
+ }
101
+ catch (error) {
102
+ if (isCode(error, 'ENOENT')) {
103
+ return;
104
+ }
105
+ throw error;
106
+ }
107
+ if (current.token !== token) {
108
+ return;
109
+ }
110
+ const releasePath = `${lockDirectory}.release.${token}`;
111
+ try {
112
+ await rename(lockDirectory, releasePath);
113
+ }
114
+ catch (error) {
115
+ if (isCode(error, 'ENOENT')) {
116
+ return;
117
+ }
118
+ throw error;
119
+ }
120
+ await rm(releasePath, { recursive: true, force: true });
121
+ }
122
+ async function readLockOwner(path) {
123
+ let parsed;
124
+ try {
125
+ parsed = JSON.parse(await readFile(path, 'utf8'));
126
+ }
127
+ catch (error) {
128
+ if (isCode(error, 'ENOENT')) {
129
+ throw error;
130
+ }
131
+ throw new Error('Mission coordinator lock metadata is invalid and cannot be reclaimed safely.');
132
+ }
133
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
134
+ throw new Error('Mission coordinator lock metadata is invalid and cannot be reclaimed safely.');
135
+ }
136
+ const record = parsed;
137
+ const exact = ['version', 'token', 'hostId', 'bootNonce', 'pid', 'acquiredAt'];
138
+ if (Object.keys(record).length !== exact.length || exact.some((key) => !(key in record))
139
+ || record.version !== 1
140
+ || typeof record.token !== 'string' || record.token.length === 0
141
+ || typeof record.hostId !== 'string' || record.hostId.length === 0
142
+ || typeof record.bootNonce !== 'string' || record.bootNonce.length === 0
143
+ || !Number.isSafeInteger(record.pid) || record.pid <= 0
144
+ || typeof record.acquiredAt !== 'string' || !Number.isFinite(Date.parse(record.acquiredAt))) {
145
+ throw new Error('Mission coordinator lock metadata is invalid and cannot be reclaimed safely.');
146
+ }
147
+ return record;
148
+ }
149
+ function defaultProcessAlive(pid) {
150
+ try {
151
+ process.kill(pid, 0);
152
+ return true;
153
+ }
154
+ catch (error) {
155
+ return error instanceof Error && 'code' in error && error.code === 'EPERM';
156
+ }
157
+ }
158
+ function requireText(value, field) {
159
+ if (value.trim().length === 0) {
160
+ throw new Error(`Mission coordinator ${field} must be non-empty.`);
161
+ }
162
+ return value;
163
+ }
164
+ function isCode(error, code) {
165
+ return error instanceof Error && 'code' in error && error.code === code;
166
+ }
167
+ function delay(ms) {
168
+ return new Promise((resolve) => setTimeout(resolve, ms));
169
+ }
170
+ //# sourceMappingURL=mission-coordinator-lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission-coordinator-lock.js","sourceRoot":"","sources":["../../../src/runner/mission-coordinator-lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA2BjC,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,KAAkC;IAElC,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAC;IACzF,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC;IAC3B,MAAM,KAAK,GAAc;QACvB,OAAO,EAAE,CAAC;QACV,KAAK;QACL,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC;QAC3C,SAAS,EAAE,WAAW,CAAC,KAAK,CAAC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,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,uBAAuB,KAAK,qBAAqB,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,MAAM,CAAC,KAAc,EAAE,IAAY;IAC1C,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;AAC1E,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,21 @@
1
+ export interface MissionDeploymentRecord {
2
+ version: 1;
3
+ repository: string;
4
+ deploymentId: string;
5
+ hostId: string;
6
+ serviceId: string;
7
+ githubAppInstallationId: string;
8
+ credentialGeneration: string;
9
+ compatibilityEpoch: number;
10
+ priorCredentialRevokedAt: string;
11
+ priorTokenExpiresAt: string;
12
+ takeoverGraceUntil: string;
13
+ takeoverNotBefore: string;
14
+ approvedByCommit: string;
15
+ }
16
+ export declare function canonicalMissionDeploymentRecord(record: MissionDeploymentRecord): string;
17
+ export declare function parseMissionDeploymentRecord(content: string): MissionDeploymentRecord;
18
+ export declare function missionDeploymentRecordHash(record: MissionDeploymentRecord): string;
19
+ export declare function takeoverNotBefore(record: Pick<MissionDeploymentRecord, 'priorTokenExpiresAt' | 'takeoverGraceUntil'>): string;
20
+ export declare function assertMissionDeploymentRecord(value: unknown): asserts value is MissionDeploymentRecord;
21
+ //# sourceMappingURL=mission-deployment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission-deployment.d.ts","sourceRoot":"","sources":["../../../src/runner/mission-deployment.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,uBAAuB,EAAE,MAAM,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,wBAAwB,EAAE,MAAM,CAAC;IACjC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAkBD,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,uBAAuB,GAAG,MAAM,CAGxF;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,uBAAuB,CAarF;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,uBAAuB,GAAG,MAAM,CAInF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAC9C,uBAAuB,EACvB,qBAAqB,GAAG,oBAAoB,CAC3C,GAAG,MAAM,CAIT;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,uBAAuB,CA8CtG"}