@aiwg/cli 2026.11.0 → 2026.11.1

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 (89) hide show
  1. package/agentic/code/providers/flue/README.md +2 -1
  2. package/dist/src/artifacts/cli.js +3 -2
  3. package/dist/src/artifacts/discover-facets.js +2 -0
  4. package/dist/src/artifacts/discover-session-facets.js +14 -0
  5. package/dist/src/artifacts/fortemi-core-query-adapter.js +4 -4
  6. package/dist/src/artifacts/framework-capabilities.js +7 -3
  7. package/dist/src/artifacts/index-builder.js +2 -3
  8. package/dist/src/artifacts/query-engine-discover-output.js +3 -3
  9. package/dist/src/artifacts/query-engine-discover.js +61 -14
  10. package/dist/src/artifacts/query-engine-entries.js +52 -9
  11. package/dist/src/artifacts/query-engine-installation.js +27 -0
  12. package/dist/src/artifacts/query-engine-rules.js +1 -2
  13. package/dist/src/artifacts/query-engine-scoring.js +33 -31
  14. package/dist/src/artifacts/query-engine-show-card.js +6 -2
  15. package/dist/src/artifacts/query-engine-show.js +2 -2
  16. package/dist/src/artifacts/relations.js +17 -10
  17. package/dist/src/cli/handlers/checkpoint.js +143 -0
  18. package/dist/src/cli/handlers/help.js +1 -0
  19. package/dist/src/cli/handlers/index.js +4 -2
  20. package/dist/src/cli/handlers/models-resource-sample.js +7 -3
  21. package/dist/src/cli/handlers/ralph-launcher.js +1 -1
  22. package/dist/src/cli/handlers/script-runner.js +2 -1
  23. package/dist/src/cli/handlers/steward-signing.js +44 -0
  24. package/dist/src/cli/handlers/steward.js +5 -0
  25. package/dist/src/cli/handlers/use-provider-results.js +17 -0
  26. package/dist/src/cli/handlers/use.js +9 -15
  27. package/dist/src/cli/router.js +12 -2
  28. package/dist/src/cli/user-scope-mirror.js +3 -1
  29. package/dist/src/config/aiwg-config.js +5 -1
  30. package/dist/src/config/cli.js +1 -0
  31. package/dist/src/config/delivery-validation.js +21 -0
  32. package/dist/src/config/host-resource-report.d.mts +1 -1
  33. package/dist/src/config/host-resource-report.mjs +23 -4
  34. package/dist/src/config/host-resource-runtime.d.mts +8 -0
  35. package/dist/src/config/host-resource-runtime.mjs +67 -24
  36. package/dist/src/config/index-graph-overrides.js +4 -0
  37. package/dist/src/config/worker-attribution.d.mts +7 -0
  38. package/dist/src/config/worker-attribution.mjs +44 -0
  39. package/dist/src/delivery/git.js +62 -0
  40. package/dist/src/delivery/pr.js +149 -0
  41. package/dist/src/delivery/tracker.js +33 -0
  42. package/dist/src/discovery/interview.js +1 -1
  43. package/dist/src/extensions/claude-hooks-installer.js +1 -0
  44. package/dist/src/extensions/loader.js +2 -1
  45. package/dist/src/issues/cli.js +12 -3
  46. package/dist/src/issues/external-cli.js +76 -0
  47. package/dist/src/issues/live.js +18 -1
  48. package/dist/src/issues/tracker-policy.js +17 -0
  49. package/dist/src/mcp/tools/worker-invoke.mjs +2 -1
  50. package/dist/src/mcp/tools/worker-stdin-runtime.mjs +12 -0
  51. package/dist/src/models/conductor-data-policy.d.mts +3 -2
  52. package/dist/src/models/conductor-data-policy.mjs +94 -5
  53. package/dist/src/models/worker-plan.js +3 -3
  54. package/dist/src/models/worker-selection-policy.js +2 -1
  55. package/dist/src/providers/deployment-lock.js +77 -0
  56. package/dist/src/providers/deployment-ownership.d.mts +12 -2
  57. package/dist/src/providers/deployment-ownership.mjs +115 -21
  58. package/dist/src/providers/deployment-preservation.d.mts +2 -1
  59. package/dist/src/providers/deployment-preservation.mjs +3 -0
  60. package/dist/src/providers/provider-definitions.js +4 -0
  61. package/dist/src/serve/worker-invocation-preparation.js +3 -1
  62. package/dist/src/serve/worker-invocation.js +2 -0
  63. package/dist/src/skills/run.js +5 -0
  64. package/dist/src/smiths/hook-bridge/codex-translator.js +3 -1
  65. package/dist/src/smiths/hook-bridge/hermes-translator.js +3 -1
  66. package/dist/src/smiths/hook-bridge/prompt-discovery-gaps.js +6 -0
  67. package/package.json +4 -2
  68. package/schemas/models/model-config-compatibility.v1.schema.json +4 -0
  69. package/tools/agents/deploy-agents.mjs +15 -0
  70. package/tools/agents/providers/base-contract.mjs +7 -1
  71. package/tools/agents/providers/base-inventory.mjs +35 -13
  72. package/tools/agents/providers/base.mjs +1 -1
  73. package/tools/agents/providers/conductor-data-guard.mjs +35 -11
  74. package/tools/agents/providers/muse-hooks.mjs +4 -0
  75. package/tools/agents/providers/muse-prompt-discovery.mjs +22 -0
  76. package/tools/agents/providers/provider-prepare-coordinator.mjs +15 -10
  77. package/tools/agents/providers/rule-delivery-surface.mjs +6 -3
  78. package/tools/agents/providers/rule-deployment-commit.mjs +10 -0
  79. package/tools/agents/providers/stale-artifact-prune.mjs +9 -8
  80. package/tools/ralph-external/lib/worker-capture.mjs +157 -0
  81. package/tools/ralph-external/lib/worker-health.mjs +3 -0
  82. package/tools/ralph-external/lib/worker-invocation-processes.mjs +9 -6
  83. package/tools/ralph-external/lib/worker-launch-cli.mjs +10 -1
  84. package/tools/ralph-external/lib/worker-process-identity.mjs +30 -0
  85. package/tools/ralph-external/lib/worker-retry-evidence.mjs +87 -6
  86. package/tools/ralph-external/lib/worker-termination.mjs +56 -6
  87. package/tools/ralph-external/process-monitor.mjs +12 -18
  88. package/tools/ralph-external/session-launcher.mjs +43 -29
  89. package/vscode-extension/schemas/aiwg.config.v1.json +15 -0
@@ -54,6 +54,7 @@ import path from 'node:path';
54
54
  import { randomUUID } from 'node:crypto';
55
55
  import { importImpl } from '../../_resolve-impl.mjs';
56
56
  import { stripJsonComments } from './base.mjs';
57
+ import { promptDiscoveryHook, deployPromptDiscovery } from './muse-prompt-discovery.mjs';
57
58
  import { resolveMuseXdgSkillsDir, museXdgSkillsDirRemediation } from './muse-paths.mjs';
58
59
 
59
60
  const { assertConfigDestination, writeConfigAtomic, writeConfigTransaction } = await importImpl(import.meta.url, 'mcp/config-file.mjs');
@@ -219,6 +220,7 @@ export const AIWG_MANAGED_HOOKS = [
219
220
  '`aiwg refresh --dry-run --quiet --provider muse > /dev/null`), or run `aiwg use --provider muse --no-hooks` ' +
220
221
  'to stop AIWG managing hooks for this project.',
221
222
  },
223
+ promptDiscoveryHook,
222
224
  ];
223
225
 
224
226
  /** Canonical group payloads keyed by hook id, for merge/prune identity. */
@@ -444,6 +446,8 @@ export function deployMuseHooks(targetDir, opts = {}) {
444
446
  return { hooksPath, changed, plan, wrote: false };
445
447
  }
446
448
 
449
+ assertMuseDirNotSymlink(path.dirname(hooksPath));
450
+ deployPromptDiscovery(targetDir);
447
451
  if (!changed) {
448
452
  log(`Muse hooks: ${hooksPath} already current; nothing to do.`);
449
453
  return { hooksPath, changed: false, plan: [], wrote: false };
@@ -0,0 +1,22 @@
1
+ // Deploy the shared prompt discovery hook for Muse's additionalContext contract.
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ export const promptDiscoveryHook = {
7
+ id: 'aiwg-prompt-discovery',
8
+ event: 'UserPromptSubmit',
9
+ group: { matcher: '*', hooks: [{ type: 'command', command: 'node .muse/hooks/aiwg-prompt-discovery.cjs', timeout: 2 }] },
10
+ reason: 'Discover the top three AIWG capabilities and inject next steps on each substantive prompt; bounded and fail open.',
11
+ removal: 'Set AIWG_PROMPT_DISCOVERY=0, or remove this group from .muse/hooks.json.',
12
+ };
13
+
14
+ export function deployPromptDiscovery(targetDir) {
15
+ const directory = path.join(targetDir, '.muse', 'hooks');
16
+ if (fs.existsSync(directory) && fs.lstatSync(directory).isSymbolicLink()) {
17
+ throw new Error('Refusing to deploy prompt discovery through a symlinked .muse/hooks directory.');
18
+ }
19
+ fs.mkdirSync(directory, { recursive: true });
20
+ fs.copyFileSync(fileURLToPath(new URL('../../../agentic/code/addons/aiwg-hooks/hooks/aiwg-prompt-discovery.cjs', import.meta.url)),
21
+ path.join(directory, 'aiwg-prompt-discovery.cjs'));
22
+ }
@@ -15,6 +15,7 @@ import {
15
15
  } from './rule-delivery.mjs';
16
16
 
17
17
  const { trackTemporaryDirectory } = await importImpl(import.meta.url, 'utils/temporary-directory.js');
18
+ const { acquireProviderDeploymentLock } = await importImpl(import.meta.url, 'providers/deployment-lock.js');
18
19
  const { signalChild } = await importImpl(import.meta.url, 'process/signal-child.mjs');
19
20
  const DEFAULT_WORKER = fileURLToPath(new URL('./provider-prepare-worker.mjs', import.meta.url));
20
21
  const CHECKOUT_NEEDS_TS_TRANSFORM = !fs.existsSync(fileURLToPath(new URL('../../../dist/src', import.meta.url)));
@@ -183,12 +184,16 @@ export async function prepareProviderDeployments({
183
184
  const activeChildren = new Set();
184
185
  let pool;
185
186
  let poolDescriptor;
187
+ let releaseLock;
186
188
  try {
189
+ // Workers stage only; retain the shared lease through ordered promotion
190
+ // and finalization so another project cannot invalidate their snapshots.
191
+ releaseLock = await acquireProviderDeploymentLock();
187
192
  pool = transaction.createPool(srcRoot);
188
193
  poolDescriptor = transaction.describePool(pool);
189
194
  } catch (error) {
190
- if (pool) transaction.disposePool(pool);
191
- removeSession();
195
+ try { if (pool) transaction.disposePool(pool); removeSession(); }
196
+ finally { await releaseLock?.(); }
192
197
  throw error;
193
198
  }
194
199
  const prepared = new Array(jobs.length);
@@ -209,10 +214,12 @@ export async function prepareProviderDeployments({
209
214
  const cleanup = async () => {
210
215
  if (closed) return;
211
216
  closed = true;
212
- await stopChildren();
213
- for (const item of prepared) if (item?.plan && !item.committed) transaction.disposePlan(item.plan);
214
- transaction.disposePool(pool);
215
- removeSession();
217
+ try {
218
+ await stopChildren();
219
+ for (const item of prepared) if (item?.plan && !item.committed) transaction.disposePlan(item.plan);
220
+ transaction.disposePool(pool);
221
+ removeSession();
222
+ } finally { await releaseLock(); }
216
223
  };
217
224
  const prepareOne = async (index, attempt = 0) => {
218
225
  // Never start a worker once the session is closed: it would outlive
@@ -243,6 +250,7 @@ export async function prepareProviderDeployments({
243
250
  }
244
251
  return {
245
252
  get providers() { return jobs.map(job => job.provider); },
253
+ run(work) { return releaseLock.run(work); },
246
254
  async commit(index) {
247
255
  if (closed) throw new Error('Provider preparation session is closed');
248
256
  if (index !== nextCommit) throw new Error(`Provider plans must commit in order: expected ${nextCommit}, received ${index}`);
@@ -256,11 +264,8 @@ export async function prepareProviderDeployments({
256
264
  report = transaction.commit(item.plan);
257
265
  }
258
266
  item.committed = true;
259
- nextCommit++;
260
267
  return report;
261
- } catch (error) {
262
- throw error;
263
- }
268
+ } finally { nextCommit++; }
264
269
  },
265
270
  async dispose() { await cleanup(); },
266
271
  };
@@ -19,6 +19,7 @@ import { inlineStartup, nativePathLoader, ruleDirectory } from './rule-projectio
19
19
  export const { parseRuleFrontmatter, inferRuleActivation, readCoreBody, validateCoreSet, formatRuleFrontmatterError } = await importImpl(import.meta.url, 'rules/activation.mjs');
20
20
  export const { resolveDeployVersion } = await importImpl(import.meta.url, 'providers/deploy-version.mjs');
21
21
  export const { trackTemporaryDirectory } = await importImpl(import.meta.url, 'utils/temporary-directory.js');
22
+ const { outputDigest } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
22
23
  export const { loadRulePinConfigs, installedRuleCapabilities, resolveRulePins } = await importImpl(import.meta.url, 'rules/pins.mjs');
23
24
  export const { guardRulesInlineBudget } = await importImpl(import.meta.url, 'rules/inline-budget.mjs');
24
25
  export const { userConfigFile } = await importImpl(import.meta.url, 'config/user-config-dir.mjs');
@@ -222,9 +223,11 @@ export function finishBindings(opts, provider) {
222
223
  const prior = priorSidecar && JSON.parse(priorSidecar.toString()).managed?.[path.basename(file)];
223
224
  // Check the pre-deploy claim too: a helper may have rewritten its sidecar
224
225
  // or overwritten an edit that preservation will restore after binding.
225
- const editedBefore = prior && priorBytes && prior.hash !== `sha256:${contentHash(priorBytes)}`;
226
- const emitted = opts.ownershipBefore && (!priorBytes || !priorBytes.equals(Buffer.from(content)));
227
- const editedNow = (record || provider.name === 'flue') && record?.hash !== `sha256:${contentHash(content)}`;
226
+ // Snapshot entries may be digests rather than bytes (#3846).
227
+ const contentDigest = `sha256:${contentHash(content)}`;
228
+ const editedBefore = prior && priorBytes && prior.hash !== outputDigest(priorBytes);
229
+ const emitted = opts.ownershipBefore && (!priorBytes || outputDigest(priorBytes) !== contentDigest);
230
+ const editedNow = (record || provider.name === 'flue') && record?.hash !== contentDigest;
228
231
  if (editedBefore || !emitted && editedNow) {
229
232
  console.warn(`${provider.name}: keeping operator-edited binding target ${opts.logicalOutputPath?.(file) || file}`);
230
233
  continue;
@@ -3,6 +3,7 @@ import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import { importImpl } from '../../_resolve-impl.mjs';
5
5
  const { refreshSettingsDigests } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
6
+ const { withProviderDeploymentLock } = await importImpl(import.meta.url, 'providers/deployment-lock.js');
6
7
  import {
7
8
  contentHash,
8
9
  deploySkillsWithKernelRouting,
@@ -130,6 +131,15 @@ export function commitRuleDeploymentPlan(plan) {
130
131
 
131
132
  /** Stage and commit serially for existing provider callers. */
132
133
  export async function deployWithRuleDelivery(original, provider, deploy) {
134
+ const shared = [...Object.values(provider.paths), provider.kernelSkillsPath].some(dir => dir && path.isAbsolute(dir))
135
+ || (provider.name === 'codex' && (original.deployCommands || original.commandsOnly || original.deploySkills || original.skillsOnly));
136
+ if (shared && !original.ruleDelivery && !globalThis[PREPARATION_HOOK] && !original.dryRun && !original.previewReport) {
137
+ return withProviderDeploymentLock(() => deployWithRuleDeliveryUnlocked(original, provider, deploy));
138
+ }
139
+ return deployWithRuleDeliveryUnlocked(original, provider, deploy);
140
+ }
141
+
142
+ async function deployWithRuleDeliveryUnlocked(original, provider, deploy) {
133
143
  // Kernel source passes share the same selected rule set. Deploy their
134
144
  // skills directly; the final source projects rules and bindings across the
135
145
  // complete destination. Full passes retain staging for bound flow skills
@@ -1,7 +1,7 @@
1
1
  /** Preserve projector-owned rules while pruning stale legacy flat artifacts. */
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
- import { computeAllArtifactBasenames, computeAllSkillNames, pruneStaleAiwgFiles, resolveAiwgRoot } from './base.mjs';
4
+ import { computeArtifactInventory, computeAllSkillNames, pruneStaleAiwgFiles, resolveAiwgRoot } from './base.mjs';
5
5
 
6
6
  /**
7
7
  * After a deploy, prune AIWG-managed flat artifacts (agents/commands/rules)
@@ -12,10 +12,10 @@ import { computeAllArtifactBasenames, computeAllSkillNames, pruneStaleAiwgFiles,
12
12
  * or `--source` under `<aiwgRoot>/agentic/code`). Project-local bundle
13
13
  * deploys (`--source <bundle>`) are skipped so a bundle's just-deployed
14
14
  * artifacts are never mistaken for stale framework files.
15
- * - `pruneStaleAiwgFiles` itself only removes files carrying an AIWG
16
- * ownership signal (sidecar entry or `aiwg:managed` marker) AND whose
17
- * stem is absent from the global, mode-independent source set, so
18
- * user-authored files and sibling-framework artifacts always survive.
15
+ * - `pruneStaleAiwgFiles` itself only removes files whose AIWG
16
+ * receipt hash matches their bytes AND whose recorded owners no longer
17
+ * ship the stem. Without bundle identity, it uses the global source set.
18
+ * Any still-shipping recorded owner protects a shared path.
19
19
  * - Aggregate-file paths (e.g. `AGENTS.md`) and unset paths are skipped.
20
20
  *
21
21
  * @param {object} provider loaded provider module
@@ -103,8 +103,8 @@ export function pruneStaleAiwgArtifacts(provider, target, srcRoot, opts, explici
103
103
  if (!relPath) continue; // type not file-deployed by provider
104
104
  if (relPath.endsWith('.md')) continue; // aggregate file (e.g. AGENTS.md)
105
105
 
106
- const desired = computeAllArtifactBasenames(srcRoot, type);
107
- if (!desired) continue; // no global desired set → skip
106
+ const inventory = computeArtifactInventory(srcRoot, type);
107
+ if (!inventory) continue; // no global desired set → skip
108
108
 
109
109
  const destDir = path.isAbsolute(relPath) ? relPath : path.join(target, relPath);
110
110
  // Activation projection owns its complete selected rule set, including extensions.
@@ -113,7 +113,8 @@ export function pruneStaleAiwgArtifacts(provider, target, srcRoot, opts, explici
113
113
  const receipt = path.join(destDir, '.aiwg-manifest.json');
114
114
  if (fs.existsSync(receipt) && JSON.parse(fs.readFileSync(receipt, 'utf8')).delivery) continue;
115
115
  }
116
- const removed = pruneStaleAiwgFiles(destDir, desired, {
116
+ const removed = pruneStaleAiwgFiles(destDir, inventory.stems, {
117
+ ownerStems: inventory.ownerStems,
117
118
  dryRun: opts.dryRun,
118
119
  verbose: opts.verbose,
119
120
  // Retire wrappers whose source skill no longer ships (#2511). Only the
@@ -0,0 +1,157 @@
1
+ // Preserve one-shot attempt captures as read-only snapshots bound to the terminal run record.
2
+ import { constants } from 'node:fs';
3
+ import { mkdir, open, readdir, lstat } from 'node:fs/promises';
4
+ import { createHash } from 'node:crypto';
5
+ import { join, dirname, basename } from 'node:path';
6
+ import { withWorkerPath } from './worker-inputs.mjs';
7
+ import { importImpl } from '../../_resolve-impl.mjs';
8
+
9
+ const hash = bytes => `sha256:${createHash('sha256').update(bytes).digest('hex')}`;
10
+ const reservationPath = filename => `${filename}.launch-owner`;
11
+ const directoryPath = runDir => join(dirname(runDir), `.captures-${basename(runDir)}`);
12
+ const fileFlags = constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK;
13
+ const directoryFlags = constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW;
14
+ const sameFile = (a, b) => a.dev === b.dev && a.ino === b.ino;
15
+
16
+ export async function assertWorkerCapturePathsAvailable(paths, inspect, { runDir, writableRoots }) {
17
+ const { realBeneath } = await importImpl(import.meta.url, 'serve/worker-invocation-paths.js');
18
+ for (const root of writableRoots) {
19
+ if (await realBeneath(root, directoryPath(runDir))) throw new Error('Sealed captures must be outside worker-writable roots');
20
+ }
21
+ const filenames = Object.values(paths);
22
+ if (filenames.some(filename => filenames.includes(reservationPath(filename)))) {
23
+ throw new Error('Worker output paths collide with capture reservations');
24
+ }
25
+ for (const filename of filenames) {
26
+ // A removed live capture still belongs to the attempt whose snapshot survives beside its run directory.
27
+ if (await inspect(directoryPath(dirname(filename)), 'directory')) throw new Error('Worker output path belongs to an earlier attempt capture directory');
28
+ if (await inspect(reservationPath(filename), 'output')) throw new Error('Worker output path belongs to an earlier attempt');
29
+ }
30
+ }
31
+
32
+ async function ownedFile(filename, operation) {
33
+ return withWorkerPath(filename, async target => {
34
+ const handle = await open(target, fileFlags);
35
+ try {
36
+ const stat = await handle.stat({ bigint: true });
37
+ if (!stat.isFile() || stat.nlink !== 1n || stat.uid !== BigInt(process.getuid())) throw new Error('Capture must be an owned unaliased regular file');
38
+ const result = await operation(handle, stat);
39
+ const after = await handle.stat({ bigint: true });
40
+ if (stat.size !== after.size || stat.mtimeNs !== after.mtimeNs || stat.ctimeNs !== after.ctimeNs
41
+ || !sameFile(after, await lstat(target, { bigint: true }))) {
42
+ throw new Error('Capture changed while sealing or verifying');
43
+ }
44
+ return result;
45
+ } finally { await handle.close(); }
46
+ });
47
+ }
48
+
49
+ async function digestFile(filename, expectedMode) {
50
+ return ownedFile(filename, async (handle, stat) => {
51
+ if (expectedMode !== undefined && Number(stat.mode & 0o777n) !== expectedMode) throw new Error('Sealed capture is not read-only');
52
+ const digest = createHash('sha256');
53
+ for await (const chunk of handle.createReadStream({ autoClose: false, start: 0 })) digest.update(chunk);
54
+ return { digest: `sha256:${digest.digest('hex')}`, byteLength: Number(stat.size) };
55
+ });
56
+ }
57
+
58
+ export class WorkerCaptureOwner {
59
+ constructor({ runDir, paths, captures, inspect, invocationId }) {
60
+ Object.assign(this, { runDir, paths, captures, inspect, invocationId });
61
+ this.directory = directoryPath(runDir);
62
+ this.sources = { ...Object.fromEntries(Object.entries(paths).map(([key, value]) => [`output-${key}`, value])),
63
+ ...Object.fromEntries(Object.entries(captures).map(([key, value]) => [`capture-${key}`, value])) };
64
+ }
65
+
66
+ writer(writeRecord, publishSeal = writeRecord) {
67
+ this.publishSeal = publishSeal;
68
+ return async (runDir, name, value, inspect) => {
69
+ if (name === 'invocation.json') {
70
+ // Exclusive even if a conductor has deleted the old mutable run directory.
71
+ await withWorkerPath(this.directory, target => mkdir(target, { mode: 0o700 }));
72
+ this.started = true;
73
+ value.captureDirectory = this.directory;
74
+ this.invocationRecord = value;
75
+ }
76
+ if (name === 'exit.json') this.result = value;
77
+ return writeRecord(runDir, name, value, inspect);
78
+ };
79
+ }
80
+
81
+ async reserveOutput(filename) {
82
+ if (Object.values(this.paths).includes(filename)) {
83
+ const marker = reservationPath(filename);
84
+ await this.inspect(marker, 'output');
85
+ const handle = await withWorkerPath(marker, target => open(target,
86
+ constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600));
87
+ try { await handle.writeFile(JSON.stringify({ invocationId: this.invocationId, runDir: this.runDir })); await handle.sync(); }
88
+ finally { await handle.close(); }
89
+ }
90
+ }
91
+
92
+ async finish() {
93
+ if (!this.started) return;
94
+ const files = [];
95
+ for (const [name, source] of Object.entries(this.sources)) {
96
+ const path = join(this.directory, name);
97
+ if (!await this.inspect(source, 'file')) { files.push({ source, path, missing: true }); continue; }
98
+ const recorded = await ownedFile(source, async (input, stat) => {
99
+ const output = await withWorkerPath(path, target => open(target,
100
+ constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600));
101
+ const digest = createHash('sha256');
102
+ try {
103
+ for await (const chunk of input.createReadStream({ autoClose: false, start: 0 })) {
104
+ digest.update(chunk); await output.writeFile(chunk);
105
+ }
106
+ await output.chmod(0o400); await output.sync();
107
+ return { digest: `sha256:${digest.digest('hex')}`, byteLength: Number(stat.size) };
108
+ } finally { await output.close(); }
109
+ });
110
+ files.push({ source, path, ...recorded });
111
+ }
112
+ await withWorkerPath(this.directory, async target => {
113
+ const directory = await open(target, directoryFlags);
114
+ try { await directory.chmod(0o500); await directory.sync(); } finally { await directory.close(); }
115
+ });
116
+ // A capture-setup exception can precede exit.json; retain its seal in the invocation record.
117
+ const record = this.result ?? this.invocationRecord;
118
+ record.captureSeal = { directory: this.directory, sealedAt: new Date().toISOString(), files,
119
+ digest: hash(JSON.stringify(files)) };
120
+ await this.publishSeal(this.runDir, this.result ? 'exit.json' : 'invocation.json', record, this.inspect);
121
+ }
122
+ }
123
+
124
+ export async function verifyWorkerCaptureSeal(runDir, invocation, exit, inspect) {
125
+ // Pre-sealing launcher records remain readable; every new invocation declares its capture directory.
126
+ if (invocation.captureDirectory === undefined && exit.captureSeal === undefined) return;
127
+ const seal = exit.captureSeal;
128
+ if (invocation.captureDirectory !== directoryPath(runDir) || seal?.directory !== invocation.captureDirectory
129
+ || !Array.isArray(seal.files) || seal.digest !== hash(JSON.stringify(seal.files))) throw new Error('Capture seal is missing or invalid');
130
+ const expected = { ...Object.fromEntries(Object.entries(invocation.paths).map(([key, value]) => [`output-${key}`, value])),
131
+ ...Object.fromEntries(Object.entries(invocation.captures).map(([key, value]) => [`capture-${key}`, value])) };
132
+ if (seal.files.length !== Object.keys(expected).length) throw new Error('Capture seal omits attempt paths');
133
+ await withWorkerPath(seal.directory, async target => {
134
+ const directory = await open(target, directoryFlags);
135
+ try {
136
+ const stat = await directory.stat();
137
+ if (stat.uid !== process.getuid() || (stat.mode & 0o777) !== 0o500) throw new Error('Capture directory is not sealed read-only');
138
+ const names = (await readdir(target)).sort();
139
+ const present = seal.files.filter(file => !file.missing).map(file => Object.keys(expected).find(name => file.path === join(seal.directory, name))).sort();
140
+ if (JSON.stringify(names) !== JSON.stringify(present)) throw new Error('Sealed capture directory entries changed');
141
+ } finally { await directory.close(); }
142
+ });
143
+ const seen = new Set();
144
+ for (const file of seal.files) {
145
+ const name = Object.keys(expected).find(key => file.path === join(seal.directory, key));
146
+ if (!name || seen.has(name) || file.source !== expected[name]) throw new Error('Capture seal path binding mismatch');
147
+ seen.add(name);
148
+ if (file.missing) {
149
+ if (await inspect(file.source, 'file')) throw new Error('Previously missing capture has changed');
150
+ continue;
151
+ }
152
+ for (const [filename, mode] of [[file.path, 0o400], [file.source, undefined]]) {
153
+ const actual = await digestFile(filename, mode);
154
+ if (actual.digest !== file.digest || actual.byteLength !== file.byteLength) throw new Error(`Capture digest mismatch: ${filename}`);
155
+ }
156
+ }
157
+ }
@@ -126,6 +126,7 @@ export function createWorkerHealthObserver(options = {}) {
126
126
  let sequence = 0, generation = options.observerGeneration ?? 0, steps = null, total = 0, lastCheck = started, maxGap = 0;
127
127
  let observed = null, activity = null, progress = null, heartbeat = null, handshakeAt = null, stalledAt = null;
128
128
  let state = 'launching', handshake = 'unobserved', confidence = 'unobserved', reasonCode = 'AWAITING_HANDSHAKE';
129
+ let terminationMissing = null;
129
130
  let termination = 'running', transitionCount = 0, live = null, disconnected = false, finalized = false;
130
131
  let terminal = null, fatalFailure = false, cpuTimeMs = null, contentDigest = options.contentDigest ?? null;
131
132
  const unavailable = new Set(profile.handshake === 'semantic' ? [] : ['semantic-start']);
@@ -350,6 +351,7 @@ export function createWorkerHealthObserver(options = {}) {
350
351
  if (finalized) return snapshot();
351
352
  for (const [id, cursor] of buffers) if (cursor.bytes.length || cursor.discarding) gap('MALFORMED_FRAME', { id });
352
353
  finalized = true; observed = now(); termination = result.termination ?? 'uncertain';
354
+ terminationMissing = result.terminationMissing ?? null;
353
355
  if (termination !== 'confirmed' || disconnected) {
354
356
  termination = 'uncertain';
355
357
  if (result.signal || result.exitCode != null && result.exitCode !== 0) transition(handshakeAt === null ? 'failed-to-start' : 'crashed', 'CRASH');
@@ -375,6 +377,7 @@ export function createWorkerHealthObserver(options = {}) {
375
377
  return Math.max(1, Math.min(...pending) - time);
376
378
  },
377
379
  evidence() { return { invocationId: binding.invocationId, sequence, observerGeneration: generation,
380
+ ...(terminationMissing ? { terminationMissing } : {}),
378
381
  lastWorkerHeartbeatAt: utc(heartbeat), cpuTimeMs, steps: windows.stepEnforcement === 'unavailable' ? null : steps,
379
382
  gaps: gaps.map(item => ({ ...item })), events: events.map(item => ({ ...item })) }; },
380
383
  };
@@ -5,6 +5,7 @@ import { classifyUnreadableWorkerProcess, readProcCgroup } from './worker-invoca
5
5
  import { importImpl } from '../../_resolve-impl.mjs';
6
6
  const { WORKER_INVOCATION_MARKER } = await importImpl(import.meta.url, 'config/worker-invocation-marker.mjs');
7
7
  export { WORKER_INVOCATION_MARKER };
8
+ const { workerAttributionEnvironment } = await importImpl(import.meta.url, 'config/worker-attribution.mjs');
8
9
 
9
10
  function startedBeforeWorker(fs, path, startTicks) {
10
11
  if (typeof startTicks !== 'string' || !/^\d+$/.test(startTicks)) return false;
@@ -23,14 +24,16 @@ function startedBeforeWorker(fs, path, startTicks) {
23
24
  finally { if (fd !== undefined) fs.closeSync(fd); }
24
25
  }
25
26
 
26
- export function buildWorkerInvocationEnvironment(envNames, invocationId, inherited = process.env) {
27
+ export function buildWorkerInvocationEnvironment(envNames, invocationId, inherited = process.env, attribution) {
27
28
  if (typeof invocationId !== 'string' || !invocationId || invocationId.includes('\0')) {
28
29
  throw new Error('Worker environment requires a non-empty NUL-free invocation ID');
29
30
  }
30
- const names = [...new Set([...envNames, WORKER_INVOCATION_MARKER])];
31
+ const markers = attribution ? workerAttributionEnvironment(invocationId, attribution.cwd, attribution.selected.group)
32
+ : { [WORKER_INVOCATION_MARKER]: invocationId };
33
+ const names = [...new Set([...envNames, ...Object.keys(markers)])];
31
34
  const env = Object.fromEntries(envNames.filter(name => inherited[name] !== undefined)
32
35
  .map(name => [name, inherited[name]]));
33
- return { env: { ...env, [WORKER_INVOCATION_MARKER]: invocationId }, envNames: names };
36
+ return { env: { ...env, ...markers }, envNames: names };
34
37
  }
35
38
 
36
39
  export function scanWorkerInvocationProcesses({ invocationId, startTicks, uid = process.getuid?.(),
@@ -98,12 +101,12 @@ export function scanWorkerInvocationProcesses({ invocationId, startTicks, uid =
98
101
  // failures and unreadable/missing start times still cannot prove absence.
99
102
  if (gone(error)) continue;
100
103
  if (!sameUid) {
101
- uncertain = unknown('unreadable same-uid process environment or ownership');
104
+ uncertain = { ...unknown('unreadable same-uid process environment or ownership'), retryable: true };
102
105
  continue;
103
106
  }
104
107
  if (!workerKnown) {
105
108
  if (!startedBeforeWorker(fs, path, startTicks)) {
106
- uncertain = unknown('unreadable same-uid process environment or ownership');
109
+ uncertain = { ...unknown('unreadable same-uid process environment or ownership'), retryable: true };
107
110
  }
108
111
  continue;
109
112
  }
@@ -117,7 +120,7 @@ export function scanWorkerInvocationProcesses({ invocationId, startTicks, uid =
117
120
  workerCgroup: resolvedWorkerCgroup, selfCgroup: resolvedSelfCgroup,
118
121
  now, deadline, ...(maxAncestryDepth === undefined ? {} : { maxDepth: maxAncestryDepth }) });
119
122
  if (verdict === 'possible-descendant') {
120
- uncertain = unknown('unreadable same-uid process links to the worker (ancestry, session, group or cgroup)');
123
+ uncertain = { ...unknown('unreadable same-uid process links to the worker (ancestry, session, group or cgroup)'), retryable: true };
121
124
  }
122
125
  } finally { if (fd !== undefined) fs.closeSync(fd); }
123
126
  }
@@ -13,6 +13,7 @@ export function parseWorkerLaunchArgs(args) {
13
13
  seen.add(flag);
14
14
  if (flag === '--launch-worker') continue;
15
15
  if (flag === '--check-descendants') { result.checkDescendants = true; continue; }
16
+ if (flag === '--retry-correction') continue;
16
17
  if (flag === '--allow-degraded-worker') { result.allowDegraded = true; continue; }
17
18
  // A run directory declares a retry; its launcher ID is derived before validation.
18
19
  const key = { '--invocation': 'invocationPath', '--run-dir': 'runDir',
@@ -25,13 +26,21 @@ export function parseWorkerLaunchArgs(args) {
25
26
  else result[key] = value;
26
27
  }
27
28
  if (!seen.has('--launch-worker') || !result.invocationPath || !result.runDir) {
28
- throw new Error('Usage: ralph-external --launch-worker --invocation FILE --run-dir DIR [--allow-degraded-worker] [--check-descendants] [--retry-of-run-dir DIR [--retry-of ID]]');
29
+ throw new Error('Usage: ralph-external --launch-worker --invocation FILE --run-dir DIR [--allow-degraded-worker] [--check-descendants] [--retry-of-run-dir DIR [--retry-of ID] [--retry-correction]]');
30
+ }
31
+ // #3857: reject relative paths here, naming the flag, before any launch work.
32
+ for (const [flag, value] of [['--invocation', result.invocationPath], ['--run-dir', result.runDir], ['--retry-of-run-dir', retryOfRunDir]]) {
33
+ if (value !== undefined && !isAbsolute(value)) {
34
+ throw new Error(`${flag} must be an absolute path; relative paths are not resolved against cwd.`);
35
+ }
29
36
  }
30
37
  if (retryOfInvocationId !== undefined && retryOfRunDir === undefined) {
31
38
  throw new Error('--retry-of and --retry-of-run-dir must be supplied together when an explicit ID is used');
32
39
  }
33
40
  if (result.checkDescendants && retryOfRunDir === undefined) throw new Error('--check-descendants requires --retry-of-run-dir');
41
+ if (seen.has('--retry-correction') && retryOfRunDir === undefined) throw new Error('--retry-correction requires --retry-of-run-dir');
34
42
  if (retryOfRunDir !== undefined) result.retryOf = { runDir: retryOfRunDir, ...(retryOfInvocationId === undefined ? {} : { invocationId: retryOfInvocationId }) };
43
+ if (seen.has('--retry-correction')) result.retryOf.correction = true;
35
44
  return result;
36
45
  }
37
46
 
@@ -0,0 +1,30 @@
1
+ // Retain kernel birth identity when an exited child has already lost its executable link.
2
+ import { readFileSync, readlinkSync } from 'node:fs';
3
+ import { hostname } from 'node:os';
4
+
5
+ export function sampleWorkerProcIdentity(pid, { procRoot = '/proc', platform = process.platform,
6
+ host = hostname(), fs = { readFileSync, readlinkSync } } = {}) {
7
+ if (platform !== 'linux' || !Number.isSafeInteger(pid) || pid <= 0) return null;
8
+ try {
9
+ const parse = text => text.slice(text.lastIndexOf(')') + 2).trim().split(/\s+/);
10
+ const fields = parse(fs.readFileSync(`${procRoot}/${pid}/stat`, 'utf8'));
11
+ const uid = Number(/^Uid:\s+(\d+)/m.exec(fs.readFileSync(`${procRoot}/${pid}/status`, 'utf8'))?.[1]);
12
+ const bootId = fs.readFileSync(`${procRoot}/sys/kernel/random/boot_id`, 'utf8').trim();
13
+ if (!Number.isSafeInteger(uid) || !bootId || !/^\d+$/.test(fields[19] ?? '')) return null;
14
+ let executable;
15
+ try { executable = fs.readlinkSync(`${procRoot}/${pid}/exe`); }
16
+ catch (error) {
17
+ if (!['ENOENT', 'ESRCH'].includes(error.code)) return null;
18
+ // exit_mm removes /exe before wait() reaps the child. Its readable
19
+ // stat/status still prove birth, ownership and group, but grant no
20
+ // executable claim. Re-read stat to reject disappearance/PID reuse
21
+ // and any live process (including a transient exec failure).
22
+ const exited = parse(fs.readFileSync(`${procRoot}/${pid}/stat`, 'utf8'));
23
+ if (exited[0] !== 'Z' || [1, 2, 3, 19].some(index => exited[index] !== fields[index])) return null;
24
+ executable = null;
25
+ }
26
+ return { pid, pgid: Number(fields[2]), uid, parentPid: Number(fields[1]), sessionId: Number(fields[3]),
27
+ host, bootId, startTicks: fields[19], executable, state: executable === null ? 'Z' : fields[0],
28
+ cpuTicks: Number(fields[11]) + Number(fields[12]) + Number(fields[13]) + Number(fields[14]) };
29
+ } catch { return null; }
30
+ }
@@ -1,8 +1,10 @@
1
1
  // Authenticate predecessor records and optionally recheck owned descendant absence.
2
- import { join } from 'node:path';
2
+ import { dirname, join, resolve } from 'node:path';
3
3
  import { importImpl } from '../../_resolve-impl.mjs';
4
- import { lstat } from 'node:fs/promises';
5
- import { boundedPrivateRead } from './worker-inputs.mjs';
4
+ import { lstat, readdir, realpath } from 'node:fs/promises';
5
+ import { boundedPrivateRead, withWorkerPath } from './worker-inputs.mjs';
6
+ import { resolveRetryReference } from './worker-launch-cli.mjs';
7
+ import { verifyWorkerCaptureSeal } from './worker-capture.mjs';
6
8
  import { realBeneath, stableTaskChainDigest, assertStopBeforeRetry, publishWorkerRecord, UNBOUND_RETRY_EVIDENCE_CODE } from '../session-launcher.mjs';
7
9
  import { recheckWorkerTermination } from './worker-termination.mjs';
8
10
 
@@ -16,7 +18,15 @@ async function matchesLegacyTask(record, plan) {
16
18
  brief: record.prompt.path, workdir: record.cwd, final_output: record.paths.final });
17
19
  }
18
20
 
19
- export async function verifyRetryPredecessor(retryOf, { newInvocationPath, inspect, workerWritableRoots, checkDescendants = false } = {}) {
21
+ async function matchesTaskIdentity(record, plan) {
22
+ if (!record.prompt?.digest || !record.selected?.group || !await sameWorkspace(record.cwd, plan.request.workdir)) return false;
23
+ const oldPlan = { ...plan, request: { ...plan.request, group: record.selected.group },
24
+ invocation: { briefDigest: record.prompt.digest } };
25
+ const digest = await stableTaskChainDigest(oldPlan.request, oldPlan.invocation.briefDigest);
26
+ return (record.taskBindingDigest ?? record.taskDigest) === digest || await matchesLegacyTask(record, oldPlan);
27
+ }
28
+
29
+ export async function verifyRetryPredecessor(retryOf, { newInvocationPath, inspect, workerWritableRoots, checkDescendants = false, onVerified } = {}) {
20
30
  const fail = (reason) => {
21
31
  const error = new Error(`Retry predecessor evidence refused: ${reason}`);
22
32
  error.code = UNBOUND_RETRY_EVIDENCE_CODE;
@@ -68,6 +78,9 @@ export async function verifyRetryPredecessor(retryOf, { newInvocationPath, inspe
68
78
  fail('invocation.json identity does not match retryOf (or is not launcher-written)');
69
79
  }
70
80
  if (exitRecord?.invocationId !== prevId) fail('exit.json identity does not match retryOf');
81
+ let bindingDigest, correction;
82
+ try { await verifyWorkerCaptureSeal(prevRunDir, invocationRecord, exitRecord, inspect); }
83
+ catch (error) { fail(`capture seal verification failed (${error.message})`); }
71
84
  if (newInvocationPath !== undefined) {
72
85
  // #2915 review 4 (finding 4): the SAME stable task-chain identity
73
86
  // `launchOneWorker` publishes — role/task/group plus the brief CONTENT
@@ -79,7 +92,18 @@ export async function verifyRetryPredecessor(retryOf, { newInvocationPath, inspe
79
92
  newPlan = JSON.parse(newPlanBytes.toString('utf8'));
80
93
  newTaskDigest = await stableTaskChainDigest(newPlan.request, newPlan.invocation?.briefDigest ?? null);
81
94
  } catch { fail('new attempt plan is missing or invalid; cannot bind the retry to a task'); }
82
- if (invocationRecord.taskDigest !== newTaskDigest && !await matchesLegacyTask(invocationRecord, newPlan)) fail('predecessor task does not match the new attempt (task-chain binding)');
95
+ bindingDigest = newTaskDigest;
96
+ if ((invocationRecord.taskBindingDigest ?? invocationRecord.taskDigest) !== newTaskDigest && !await matchesLegacyTask(invocationRecord, newPlan)) {
97
+ if (retryOf.correction !== true) fail('predecessor task does not match the new attempt (task-chain binding); use --retry-correction for an explicit brief/group correction');
98
+ if (!await matchesTaskIdentity(invocationRecord, newPlan)) {
99
+ fail('correction must retain the predecessor role, task and workspace (task-chain binding)');
100
+ }
101
+ const { qualificationDigest } = await importImpl(import.meta.url, 'models/qualification-digest.mjs');
102
+ correction = {
103
+ oldBriefDigest: invocationRecord.prompt.digest, newBriefDigest: newPlan.invocation.briefDigest,
104
+ oldGroupDigest: qualificationDigest(invocationRecord.selected.group), newGroupDigest: qualificationDigest(newPlan.request.group),
105
+ };
106
+ }
83
107
  }
84
108
  if (exitRecord.termination !== 'confirmed') {
85
109
  let evidence = null;
@@ -88,16 +112,73 @@ export async function verifyRetryPredecessor(retryOf, { newInvocationPath, inspe
88
112
  const processRecord = JSON.parse((await boundedPrivateRead(join(prevRunDir, 'process.json'), 65536, inspect, true, true)).toString('utf8'));
89
113
  evidence = await recheckWorkerTermination({ processRecord, exitRecord });
90
114
  } catch (error) { evidence = { confirmed: false, missing: `readable, private launcher process.json (${error.message})` }; }
115
+ exitRecord = { ...exitRecord, terminationMissing: evidence.missing ?? null,
116
+ ...(exitRecord.healthEvidence ? { healthEvidence: { ...exitRecord.healthEvidence, terminationMissing: evidence.missing ?? null } } : {}) };
91
117
  if (evidence.confirmed) {
92
118
  exitRecord = { ...exitRecord, termination: 'confirmed', descendants: 'none',
93
119
  ...(exitRecord.health ? { health: { ...exitRecord.health, termination: 'confirmed' } } : {}) };
94
- await publishWorkerRecord(prevRunDir, 'exit.json', exitRecord, inspect);
95
120
  }
121
+ await publishWorkerRecord(prevRunDir, 'exit.json', exitRecord, inspect);
96
122
  }
97
123
  if (exitRecord.termination !== 'confirmed') {
98
124
  assertStopBeforeRetry(exitRecord, { expectedInvocationId: prevId, runDir: prevRunDir, missing: evidence?.missing });
99
125
  }
100
126
  }
101
127
  assertStopBeforeRetry(exitRecord, { expectedInvocationId: prevId });
128
+ onVerified?.({ previousAttemptId: prevId, taskDigest: invocationRecord.taskDigest,
129
+ taskBindingDigest: bindingDigest, ...(correction ? { retryCorrection: correction } : {}) });
102
130
  return exitRecord;
103
131
  }
132
+
133
+ async function sameWorkspace(left, right) {
134
+ if (typeof left !== 'string' || typeof right !== 'string') return false;
135
+ try { return await realpath(left) === await realpath(right); }
136
+ catch (error) { if (error.code === 'ENOENT') return false; throw error; }
137
+ }
138
+
139
+ // Existing capture siblings are the durable inventory, including captures from
140
+ // older launchers. Brief and group changes cannot hide an open task predecessor.
141
+ async function assertNoOpenPredecessor({ runDir, captureRoot, saved, inspect, retryOf, workerWritableRoots }) {
142
+ const taskDigest = await stableTaskChainDigest(saved.request, saved.invocation.briefDigest);
143
+ const roots = new Set([dirname(runDir), ...(captureRoot ? [captureRoot] : []), ...(retryOf ? [dirname(retryOf.runDir)] : [])]);
144
+ for (const root of roots) {
145
+ if (!await inspect(root, 'directory')) continue;
146
+ const entries = await withWorkerPath(root, target => readdir(target, { withFileTypes: true }));
147
+ for (const entry of entries) {
148
+ if (!entry.isDirectory()) continue;
149
+ const previousDir = join(root, entry.name);
150
+ if (resolve(previousDir) === resolve(runDir)) continue;
151
+ const filename = join(previousDir, 'invocation.json');
152
+ if (!await inspect(filename, 'file')) continue;
153
+ const record = JSON.parse((await boundedPrivateRead(filename, 1048576, inspect, true, true)).toString('utf8'));
154
+ if (record.origin !== 'launcher' || ((record.taskBindingDigest ?? record.taskDigest) !== taskDigest
155
+ && !await matchesTaskIdentity(record, saved))) continue;
156
+ try {
157
+ // Reuse the authenticated owned-stop loader, including missing exits.
158
+ await verifyRetryPredecessor({ invocationId: record.invocationId, runDir: previousDir }, { inspect, workerWritableRoots });
159
+ } catch (cause) {
160
+ const error = new Error(`Worker launch refused: open predecessor ${record.invocationId} at ${previousDir}; termination is not confirmed. Retry with --retry-of-run-dir and owned-stop proof.`, { cause });
161
+ error.code = 'OPEN_TASK_PREDECESSOR';
162
+ error.previousAttemptId = record.invocationId;
163
+ error.runDir = previousDir;
164
+ throw error;
165
+ }
166
+ }
167
+ }
168
+ }
169
+
170
+ export async function prepareWorkerRetry(options, { saved, inspect, workerWritableRoots }) {
171
+ let evidence = null;
172
+ const retryOf = options.retryOf === undefined ? undefined : await resolveRetryReference(options.retryOf, { inspect });
173
+ if (retryOf !== undefined) {
174
+ await verifyRetryPredecessor(retryOf, { newInvocationPath: options.invocationPath, inspect, workerWritableRoots,
175
+ checkDescendants: options.checkDescendants, onVerified: value => { evidence = value; } });
176
+ }
177
+ await assertNoOpenPredecessor({ ...options, saved, inspect, retryOf, workerWritableRoots });
178
+ return evidence;
179
+ }
180
+
181
+ export function workerRetryRecordFields(evidence) {
182
+ return { ...(evidence ? { taskBindingDigest: evidence.taskBindingDigest,
183
+ ...(evidence.retryCorrection ? { retryCorrection: evidence.retryCorrection } : {}) } : {}) };
184
+ }