@eyeauras/insight-cli 0.5.8 → 0.6.0

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 (125) hide show
  1. package/.cli-package-build.json +1 -1
  2. package/SKILL.md +1 -1
  3. package/dist/src/artifacts.d.ts +1 -1
  4. package/dist/src/artifacts.js +3 -3
  5. package/dist/src/cli.js +74 -15
  6. package/dist/src/contexts.d.ts +120 -10
  7. package/dist/src/contexts.js +510 -107
  8. package/dist/src/legacy-migration.d.ts +37 -0
  9. package/dist/src/legacy-migration.js +237 -0
  10. package/dist/src/lifecycle.d.ts +16 -5
  11. package/dist/src/lifecycle.js +43 -6
  12. package/dist/src/merge.d.ts +1 -1
  13. package/dist/src/merge.js +2 -2
  14. package/dist/src/model.d.ts +5 -0
  15. package/dist/src/model.js +2 -0
  16. package/dist/src/native-inputs.js +12 -2
  17. package/dist/src/native-merge-patches.d.ts +6 -0
  18. package/dist/src/native-merge-patches.js +100 -0
  19. package/dist/src/persistent-client.d.ts +8 -2
  20. package/dist/src/persistent-client.js +30 -8
  21. package/dist/src/projects.js +5 -4
  22. package/dist/src/research.d.ts +77 -14
  23. package/dist/src/research.js +99 -123
  24. package/dist/src/sdk-files.js +3 -3
  25. package/dist/src/server.d.ts +5 -1
  26. package/dist/src/server.js +46 -6
  27. package/dist/src/storage-gc.d.ts +23 -0
  28. package/dist/src/storage-gc.js +358 -0
  29. package/dist/src/sync-policy.js +4 -2
  30. package/dist/src/version-tracking.js +2 -1
  31. package/dist/src/workspace.d.ts +35 -2
  32. package/dist/src/workspace.js +91 -7
  33. package/package.json +1 -1
  34. package/references/native/APACHE-2.0.txt +202 -0
  35. package/references/native/HeadlessProgramMergeManager.java +86 -0
  36. package/references/native/InsightGuiMain.java +1 -0
  37. package/references/native/InsightHeadlessMain.java +1 -0
  38. package/references/native/InsightInitialImport.java +1 -1
  39. package/references/native/InsightNativeCheckout.java +214 -0
  40. package/references/native/InsightNativeFingerprint.java +14 -0
  41. package/references/native/InsightNativeMigration.java +147 -0
  42. package/references/native/InsightNativeRead.java +57 -0
  43. package/references/native/InsightNativeView.java +29 -0
  44. package/references/native/InsightOfflineAuthenticator.java +20 -0
  45. package/references/native/InsightSdkFiles.java +4 -0
  46. package/references/native/InsightSnapshotFields.java +17 -11
  47. package/references/native/InsightSnapshotInspect.java +4 -2
  48. package/references/native/NATIVE-MERGE-NOTICE.txt +15 -0
  49. package/references/persistent-client.mjs +30 -8
  50. package/references/persistent.md +47 -7
  51. package/references/recovery.md +50 -12
  52. package/references/research.md +25 -22
  53. package/references/setup.md +13 -3
  54. package/skill-bundle/insight-artifacts/SKILL.md +1 -1
  55. package/skill-bundle/insight-artifacts/references/recovery.md +50 -12
  56. package/skill-bundle/insight-binary/SKILL.md +1 -1
  57. package/skill-bundle/insight-capture/SKILL.md +1 -1
  58. package/skill-bundle/insight-cli/SKILL.md +1 -1
  59. package/skill-bundle/insight-cli/references/persistent-client.mjs +30 -8
  60. package/skill-bundle/insight-cli/references/persistent.md +47 -7
  61. package/skill-bundle/insight-cli/references/recovery.md +50 -12
  62. package/skill-bundle/insight-cli/references/setup.md +13 -3
  63. package/skill-bundle/insight-die/SKILL.md +1 -1
  64. package/skill-bundle/insight-dnspy/SKILL.md +1 -1
  65. package/skill-bundle/insight-dotnet-dump/SKILL.md +1 -1
  66. package/skill-bundle/insight-dotnet-stack/SKILL.md +1 -1
  67. package/skill-bundle/insight-dotnet-trace/SKILL.md +1 -1
  68. package/skill-bundle/insight-frida/SKILL.md +1 -1
  69. package/skill-bundle/insight-ghidra/SKILL.md +8 -1
  70. package/skill-bundle/insight-ghidra/references/persistent-client.mjs +30 -8
  71. package/skill-bundle/insight-ghidra/references/persistent.md +47 -7
  72. package/skill-bundle/insight-ghidra/references/recovery.md +50 -12
  73. package/skill-bundle/insight-ghidra/references/research.md +25 -22
  74. package/skill-bundle/insight-ghidra/references/setup.md +13 -3
  75. package/skill-bundle/insight-ilspy/SKILL.md +1 -1
  76. package/skill-bundle/insight-interop/SKILL.md +1 -1
  77. package/skill-bundle/insight-lldb/SKILL.md +1 -1
  78. package/skill-bundle/insight-llvm/SKILL.md +1 -1
  79. package/skill-bundle/insight-managed-heap/SKILL.md +1 -1
  80. package/skill-bundle/insight-managed-metadata/SKILL.md +1 -1
  81. package/skill-bundle/insight-mitmproxy/SKILL.md +1 -1
  82. package/skill-bundle/insight-overview/SKILL.md +1 -1
  83. package/skill-bundle/insight-procmon/SKILL.md +1 -1
  84. package/skill-bundle/insight-re/SKILL.md +1 -1
  85. package/skill-bundle/insight-re/references/persistent-client.mjs +30 -8
  86. package/skill-bundle/insight-re/references/persistent.md +47 -7
  87. package/skill-bundle/insight-re/references/recovery.md +50 -12
  88. package/skill-bundle/insight-sevenzip/SKILL.md +1 -1
  89. package/skill-bundle/insight-strace/SKILL.md +1 -1
  90. package/skill-bundle/insight-tshark/SKILL.md +1 -1
  91. package/skill-bundle/insight-windbg/SKILL.md +1 -1
  92. package/skill-bundle/manifest.json +1 -1
  93. package/skills/insight-artifacts/SKILL.md +1 -1
  94. package/skills/insight-artifacts/references/recovery.md +50 -12
  95. package/skills/insight-binary/SKILL.md +1 -1
  96. package/skills/insight-capture/SKILL.md +1 -1
  97. package/skills/insight-die/SKILL.md +1 -1
  98. package/skills/insight-dnspy/SKILL.md +1 -1
  99. package/skills/insight-dotnet-dump/SKILL.md +1 -1
  100. package/skills/insight-dotnet-stack/SKILL.md +1 -1
  101. package/skills/insight-dotnet-trace/SKILL.md +1 -1
  102. package/skills/insight-frida/SKILL.md +1 -1
  103. package/skills/insight-ghidra/SKILL.md +8 -1
  104. package/skills/insight-ghidra/references/persistent-client.mjs +30 -8
  105. package/skills/insight-ghidra/references/persistent.md +47 -7
  106. package/skills/insight-ghidra/references/recovery.md +50 -12
  107. package/skills/insight-ghidra/references/research.md +25 -22
  108. package/skills/insight-ghidra/references/setup.md +13 -3
  109. package/skills/insight-ilspy/SKILL.md +1 -1
  110. package/skills/insight-interop/SKILL.md +1 -1
  111. package/skills/insight-lldb/SKILL.md +1 -1
  112. package/skills/insight-llvm/SKILL.md +1 -1
  113. package/skills/insight-managed-heap/SKILL.md +1 -1
  114. package/skills/insight-managed-metadata/SKILL.md +1 -1
  115. package/skills/insight-mitmproxy/SKILL.md +1 -1
  116. package/skills/insight-overview/SKILL.md +1 -1
  117. package/skills/insight-procmon/SKILL.md +1 -1
  118. package/skills/insight-re/SKILL.md +1 -1
  119. package/skills/insight-re/references/persistent-client.mjs +30 -8
  120. package/skills/insight-re/references/persistent.md +47 -7
  121. package/skills/insight-re/references/recovery.md +50 -12
  122. package/skills/insight-sevenzip/SKILL.md +1 -1
  123. package/skills/insight-strace/SKILL.md +1 -1
  124. package/skills/insight-tshark/SKILL.md +1 -1
  125. package/skills/insight-windbg/SKILL.md +1 -1
@@ -10,12 +10,24 @@ export class InsightCommandError extends Error {
10
10
  }
11
11
  export class InsightTransportError extends Error {
12
12
  dispatched;
13
- constructor(message, dispatched) {
13
+ termination;
14
+ constructor(message, dispatched, termination) {
14
15
  super(message);
15
16
  this.dispatched = dispatched;
17
+ this.termination = termination;
16
18
  this.name = 'InsightTransportError';
17
19
  }
18
20
  }
21
+ const transportDiagnostics = [
22
+ ['host_incompatible', 'Host build/protocol mismatch or closing.', 'Factory rejected the host build/protocol or it is closing.'],
23
+ ['host_incompatible', 'Host build mismatch.', 'Factory rejected the host build.'],
24
+ ['host_incompatible', 'Existing host build mismatch or closing.', 'Factory rejected the host build or it is closing.'],
25
+ ['host_closing', 'Host is closing; no command was sent.', 'Factory reports that the host is closing.'],
26
+ ['host_startup_timeout', 'CLI host startup timed out; no command was sent.', 'Factory host startup timed out.'],
27
+ ['invalid_rpc_launch', 'The --json-rpc transport must be started without a CLI command.', 'Start the JSON-RPC transport without CLI command or profile flags.'],
28
+ ['host_build_invalid', 'CLI host could not validate its build.', 'Factory could not validate the installed build.'],
29
+ ['ipc_disconnected', 'IPC invocation failed; command outcome may be unknown. No replay was attempted.', 'Factory lost the IPC invocation; the command outcome may be unknown.']
30
+ ];
19
31
  /** A thin client of Factory's existing stream, with no reconnect or command replay. */
20
32
  export async function connectInsight(options) {
21
33
  const child = spawn(options.executable, [...(options.arguments ?? []), '--json-rpc'], { cwd: options.cwd, env: options.env, stdio: ['pipe', 'pipe', 'pipe'], shell: false });
@@ -23,15 +35,23 @@ export async function connectInsight(options) {
23
35
  let buffer = '', bytes = 0, sequence = 0, accepting = true, failed = false, ended = false;
24
36
  let closePromise, tail = Promise.resolve();
25
37
  const pending = new Map();
26
- // Drain diagnostics without retaining arbitrary stderr, paths, tokens or unbounded output.
27
- child.stderr.resume();
38
+ // Classify fixed transport diagnostics through a bounded window; never expose raw stderr.
39
+ const diagnosticDecoder = new StringDecoder('utf8');
40
+ let diagnosticWindow = '', recognizedDiagnostic;
41
+ let termination;
42
+ child.stderr.on('data', (chunk) => {
43
+ const text = diagnosticWindow + diagnosticDecoder.write(chunk);
44
+ recognizedDiagnostic ??= transportDiagnostics.find(([, message]) => text.includes(message));
45
+ diagnosticWindow = text.slice(-512);
46
+ });
47
+ const transportError = (message, dispatched) => new InsightTransportError(message + (recognizedDiagnostic ? ' ' + recognizedDiagnostic[2] : '') + (termination ? ' (' + (termination.signal ? 'signal ' + termination.signal : 'exit ' + termination.exitCode) + ').' : ''), dispatched, termination);
28
48
  const fail = (message) => {
29
49
  if (failed)
30
50
  return;
31
51
  failed = true;
32
52
  accepting = false;
33
53
  for (const p of pending.values())
34
- p.reject(new InsightTransportError(message, true));
54
+ p.reject(transportError(message, true));
35
55
  pending.clear();
36
56
  child.stdin.destroy();
37
57
  child.stdout.destroy();
@@ -43,12 +63,14 @@ export async function connectInsight(options) {
43
63
  const exited = new Promise((resolve, reject) => {
44
64
  child.once('close', (code, signal) => {
45
65
  ended = true;
66
+ diagnosticWindow = '';
67
+ termination = Object.freeze({ exitCode: code, signal, ...(recognizedDiagnostic ? { reason: recognizedDiagnostic[0] } : {}) });
46
68
  if (code !== 0 || signal || pending.size || buffer.trim()) {
47
69
  fail('Persistent CLI closed without a complete acknowledged response.');
48
- reject(new InsightTransportError('Persistent CLI transport ended unexpectedly.', false));
70
+ reject(transportError('Persistent CLI transport ended unexpectedly.', false));
49
71
  }
50
72
  else if (failed)
51
- reject(new InsightTransportError('Persistent CLI transport failed.', false));
73
+ reject(transportError('Persistent CLI transport failed.', false));
52
74
  else
53
75
  resolve();
54
76
  });
@@ -97,11 +119,11 @@ export async function connectInsight(options) {
97
119
  if (!Array.isArray(argv) || argv.length > 512 || argv.some(x => typeof x !== 'string' || x.includes('\0')) || Buffer.byteLength(JSON.stringify(argv)) > 1024 ** 2)
98
120
  return Promise.reject(new TypeError('argv must be a bounded array of strings without NUL.'));
99
121
  if (!accepting || failed || ended)
100
- return Promise.reject(new InsightTransportError('Persistent CLI connection is closed.', false));
122
+ return Promise.reject(transportError('Persistent CLI connection is closed.', false));
101
123
  const args = [...argv];
102
124
  const request = tail.then(() => {
103
125
  if (failed || ended)
104
- throw new InsightTransportError('Persistent CLI connection was lost before dispatch.', false);
126
+ throw transportError('Persistent CLI connection was lost before dispatch.', false);
105
127
  const id = ++sequence;
106
128
  return new Promise((resolve, reject) => {
107
129
  pending.set(id, { resolve, reject });
@@ -246,18 +246,19 @@ export class Projects {
246
246
  if (observed.id !== snapshot.id || current.generation !== execution.generation)
247
247
  fail('unknown', 'Export output cannot establish the retained outcome.');
248
248
  const result = { ...selected, state: 'exported', output, sha256: snapshot.sha256, size: snapshot.size };
249
- this.workspace.completeSavedRequest(selected, request.id, current.generation, { workingSnapshot: snapshot }, result);
249
+ this.workspace.completeSavedRequest(selected, request.id, current.generation, { workingSnapshot: execution.workingSnapshot ?? snapshot }, result);
250
250
  return result;
251
251
  }
252
252
  await this.newOutput(output);
253
253
  const backend = await this.backend();
254
254
  await backend.open(selected);
255
- const snapshot = await backend.saved(selected), context = this.workspace.context(selected);
256
- this.workspace.startRequest(request.id, { kind: 'export', generation: context.generation, snapshot, output });
255
+ const view = await backend.saved(selected), context = this.workspace.context(selected);
256
+ const snapshot = backend.snapshotFile ? await this.workspace.captureSnapshot(await backend.snapshotFile(view)) : view;
257
+ this.workspace.startRequest(request.id, { kind: 'export', generation: context.generation, snapshot, workingSnapshot: view, output });
257
258
  try {
258
259
  await this.exportArtifact(snapshot, output);
259
260
  const result = { ...selected, state: 'exported', output, sha256: snapshot.sha256, size: snapshot.size };
260
- this.workspace.completeSavedRequest(selected, request.id, context.generation, { workingSnapshot: snapshot }, result);
261
+ this.workspace.completeSavedRequest(selected, request.id, context.generation, { workingSnapshot: view }, result);
261
262
  return result;
262
263
  }
263
264
  catch (error) {
@@ -1,12 +1,71 @@
1
1
  import { type FunctionInspectionOptions } from './function-inspection.js';
2
2
  import { type AnchorRequest } from './string-anchors.js';
3
3
  import type { Artifact } from './artifacts.js';
4
- import type { GhidraContext, Scope, ScalarChange, Publication, DebuggerState, GhidraLoadSettings } from './workspace.js';
4
+ import type { GhidraContext, Scope, ScalarChange, Publication, DebuggerState, GhidraLoadSettings, NativeCheckout } from './workspace.js';
5
5
  import { Workspace } from './workspace.js';
6
6
  import type { ToolMode } from './contexts.js';
7
7
  import type { ScriptPage } from './scripts.js';
8
8
  import { type ReferenceRequest } from './code-references.js';
9
9
  export interface ResearchBackend {
10
+ snapshotFile?(snapshot: Artifact): Promise<string>;
11
+ readonly nativeEngine?: 'native-checkout-v1';
12
+ migrate?(target: string | undefined, dryRun: boolean): Promise<unknown>;
13
+ collect?(dryRun: boolean): Promise<unknown>;
14
+ releaseUnchanged?(scope: Scope): Promise<boolean>;
15
+ updateNative?(scope: Scope, request: string): Promise<{
16
+ state: 'ready' | 'empty';
17
+ revision: number;
18
+ snapshot: Artifact;
19
+ sharedSnapshot: Artifact;
20
+ receivedChanges: number;
21
+ nativeMergeInvocations: number;
22
+ } | {
23
+ state: 'conflict';
24
+ revision: number;
25
+ conflict: string;
26
+ }>;
27
+ recoverUpdate?(scope: Scope, request: string): Promise<{
28
+ state: 'ready' | 'empty';
29
+ revision: number;
30
+ snapshot: Artifact;
31
+ sharedSnapshot: Artifact;
32
+ receivedChanges: number;
33
+ nativeMergeInvocations: number;
34
+ } | {
35
+ state: 'conflict';
36
+ revision: number;
37
+ conflict: string;
38
+ } | {
39
+ state: 'unknown';
40
+ }>;
41
+ publishNative?(publication: Publication): Promise<{
42
+ state: 'published';
43
+ revision: number;
44
+ snapshot?: Artifact;
45
+ } | {
46
+ state: 'conflict';
47
+ applied: 0;
48
+ conflict?: string;
49
+ }>;
50
+ dropNative?(scope: Scope): Promise<void>;
51
+ finishEmptyNative?(scope: Scope): Promise<void>;
52
+ recoverEmptyNative?(scope: Scope, request: string): Promise<{
53
+ state: 'verified';
54
+ revision: number;
55
+ } | {
56
+ state: 'unknown';
57
+ }>;
58
+ discardNative?(scope: Scope, request: string): Promise<{
59
+ baseRevision: number;
60
+ retainedKeepFile: string;
61
+ }>;
62
+ recoverDiscardNative?(scope: Scope, request: string, original: NativeCheckout): Promise<{
63
+ state: 'verified';
64
+ baseRevision: number;
65
+ retainedKeepFile: string;
66
+ } | {
67
+ state: 'unknown';
68
+ }>;
10
69
  inlineScript?(scope: Scope, parameters: Record<string, unknown>, requestId: string): Promise<{
11
70
  response: Record<string, unknown>;
12
71
  safe: boolean;
@@ -41,17 +100,10 @@ export interface ResearchBackend {
41
100
  dependency: string;
42
101
  exists: boolean;
43
102
  }>>;
44
- candidate?(target: string, snapshot: Artifact, changes: ScalarChange[]): Promise<Artifact>;
45
- publish?(publication: Publication): Promise<{
46
- state: 'published';
47
- revision: number;
48
- } | {
49
- state: 'conflict';
50
- applied: 0;
51
- }>;
52
103
  recover?(publication: Publication): Promise<{
53
104
  state: 'verified';
54
105
  revision: number;
106
+ snapshot?: Artifact;
55
107
  } | {
56
108
  state: 'unknown';
57
109
  }>;
@@ -84,19 +136,20 @@ export declare class Research {
84
136
  }[];
85
137
  externalRequestsTruncated: boolean;
86
138
  ghidra: {
87
- syncPolicy: import("./workspace.js").SyncPolicy;
88
- state: "opening" | "ready" | "stopped" | "needs_recovery";
89
- baseRevision: string | undefined;
90
139
  sharedRevision: string | undefined;
91
140
  pendingChanges: number;
92
141
  mergeState: string;
93
- conflicts: {
142
+ conflicts: ({
94
143
  address: string;
95
144
  field: "function.name" | "comment.eol" | "comment.pre" | "comment.post" | "comment.plate" | "comment.repeatable";
96
145
  original: string | null;
97
146
  local: string | null;
98
147
  shared: string | null;
99
- }[];
148
+ } | {
149
+ request: string;
150
+ message: string;
151
+ engine: string;
152
+ })[];
100
153
  unresolvedRequests: {
101
154
  operation: string;
102
155
  state: import("./workspace.js").RequestState;
@@ -104,6 +157,16 @@ export declare class Research {
104
157
  detail?: {} | undefined;
105
158
  id: string;
106
159
  }[];
160
+ checkout?: {
161
+ id: number;
162
+ fileId: string;
163
+ baseRevision: string | undefined;
164
+ state: "active" | "verified" | "dropped";
165
+ } | undefined;
166
+ syncPolicy: import("./workspace.js").SyncPolicy;
167
+ state: "opening" | "ready" | "stopped" | "needs_recovery";
168
+ baseRevision: string | undefined;
169
+ engine: string;
107
170
  };
108
171
  session: string;
109
172
  target: string;
@@ -3,8 +3,7 @@ import { functionResult, functionFailure } from './function-results.js';
3
3
  import { inspectFunctions } from './function-inspection.js';
4
4
  import { entryRequest } from './function-entries.js';
5
5
  import { inspectAnchors } from './string-anchors.js';
6
- import { fail, id, object, text, digest } from './model.js';
7
- import { fieldKey, scalarMerge, scalarRefresh } from './merge.js';
6
+ import { fail, id, object, text, digest, fieldKey } from './model.js';
8
7
  import { verifyMutation } from './mutation-effects.js';
9
8
  import { transferResult } from './cross-results.js';
10
9
  import { CliError } from '@eyeauras/cli-factory';
@@ -97,10 +96,11 @@ export class Research {
97
96
  const external = this.workspace.unresolvedSessionAdministration(selected.session, selected.target);
98
97
  return { ...selected, externalRequests: external.map(request => ({ ...(request.callerId ? { requestId: request.callerId } : {}), operation: request.operation, state: request.state })), externalRequestsTruncated: external.length === 100,
99
98
  ghidra: { syncPolicy: context.syncPolicy ?? { publish: 'manual', refresh: 'manual' }, state: unresolved.length ? 'needs_recovery' : context.state, baseRevision: revision(context.baseRevision),
99
+ engine: context.nativeCheckout ? 'ghidra-native' : 'uninitialized-or-legacy', ...(context.nativeCheckout ? { checkout: { id: context.nativeCheckout.checkoutId, fileId: context.nativeCheckout.fileId, baseRevision: revision(context.nativeCheckout.baseVersion), state: context.nativeCheckout.state } } : {}),
100
100
  sharedRevision: revision(model.sharedRevision), pendingChanges: count(context),
101
101
  mergeState: model.state === 'unknown' ? 'unknown' : 'idle',
102
- conflicts: context.scalars.filter(change => change.conflict).map(change => ({ address: publicAddress(change.address), field: change.field,
103
- original: change.original, local: change.local, shared: change.conflict.shared })),
102
+ conflicts: [...(context.nativeCheckout?.conflict ? [{ engine: 'ghidra-native', ...context.nativeCheckout.conflict }] : []), ...context.scalars.filter(change => change.conflict).map(change => ({ address: publicAddress(change.address), field: change.field,
103
+ original: change.original, local: change.local, shared: change.conflict.shared }))],
104
104
  unresolvedRequests: unresolved.map(request => ({ id: request.id, ...(request.result ? { detail: request.result } : {}), ...(request.callerId ? { requestId: request.callerId } : {}), operation: request.operation, state: request.state })) } };
105
105
  }
106
106
  async abandon(selected, requestId, acknowledged) {
@@ -108,6 +108,8 @@ export class Research {
108
108
  if (!acknowledged)
109
109
  fail('invalid', 'Explicit --acknowledge-unknown-effects is required.');
110
110
  const context = this.workspace.context(selected), requests = this.workspace.unresolved(selected);
111
+ if (context.nativeCheckout)
112
+ fail('unsupported', 'A native unknown program outcome must be reconciled on its original project; detached snapshot rollback is disabled.');
111
113
  const request = this.workspace.scopedRequest(selected, requestId);
112
114
  if (request?.state === 'failed' && object(request.result ?? {}).state === 'abandoned')
113
115
  return request.result;
@@ -134,7 +136,7 @@ export class Research {
134
136
  const retained = (state) => ({ session: reserved.context.session, target, state, ...(callerId ? { requestId: callerId } : {}) });
135
137
  const next = [['sessions', 'status', reserved.context.session, '--target', target], ['ghidra', 'open', '--session', reserved.context.session, '--target', target]];
136
138
  const openingFailure = (error, state) => new CliError(error instanceof CliError ? error.message : 'Ghidra open did not complete; the context is retained for reconciliation.', {
137
- code: error instanceof CliError ? error.code : 'coordinator.unknown', result: { ...retained(state), ...(error instanceof CliError && error.result && typeof error.result === 'object' ? { detail: error.result } : {}) }, next
139
+ code: error instanceof CliError ? error.code : 'coordinator.unknown', result: { ...retained(state), ...(error instanceof CliError && error.result && typeof error.result === 'object' ? { detail: error.result } : {}) }, next: error instanceof CliError && error.code === 'coordinator.migration' ? [['ghidra', 'migrate', '--target', target, '--dry-run'], ['ghidra', 'migrate', '--target', target], ...next] : next
138
140
  });
139
141
  return this.ordered(reserved.context, async () => {
140
142
  if (this.workspace.request(reserved.request.id).state === 'applied')
@@ -176,9 +178,10 @@ export class Research {
176
178
  return result;
177
179
  }
178
180
  catch (error) {
179
- const result = retained('unknown');
180
- this.workspace.recordRequest(request.id, 'unknown', result);
181
- throw openingFailure(error, 'unknown');
181
+ const migration = error instanceof CliError && error.code === 'coordinator.migration';
182
+ const result = { ...retained(migration ? 'blocked' : 'unknown'), ...(migration ? { reason: 'explicit_native_migration_required', detail: error.message } : {}) };
183
+ this.workspace.recordRequest(request.id, migration ? 'failed' : 'unknown', result);
184
+ throw openingFailure(error, migration ? 'blocked' : 'unknown');
182
185
  }
183
186
  });
184
187
  }
@@ -399,6 +402,8 @@ export class Research {
399
402
  // Restore before starting this mutation; other uncertain effects still block the context.
400
403
  await backend.open(selected);
401
404
  const before = this.workspace.context(selected);
405
+ if (resolution && before.nativeCheckout)
406
+ fail('unsupported', 'Native conflicts require Ghidra resolver decisions; the legacy scalar resolution option cannot choose a native winner.');
402
407
  const previous = before.scalars.find(change => change.address === at && change.field === field);
403
408
  let observed;
404
409
  if (field === 'function.name') {
@@ -487,7 +492,9 @@ export class Research {
487
492
  const observed = await backend.recover(active);
488
493
  if (observed.state === 'verified')
489
494
  this.workspace.finishPublication(active.id, observed.revision, { session: active.session, target: active.target,
490
- state: 'merged', sharedRevision: revision(observed.revision), applied: active.scalars.length + (active.complexChanges?.length ?? Number(active.complex)), pendingChanges: 0 });
495
+ state: 'merged', sharedRevision: revision(observed.revision), applied: active.scalars.length + (active.complexChanges?.length ?? Number(active.complex)), pendingChanges: 0 }, observed.snapshot);
496
+ if (observed.state === 'verified' && backend.dropNative)
497
+ await backend.dropNative(active);
491
498
  }
492
499
  }
493
500
  for (const request of this.workspace.unresolved(selected)) {
@@ -500,13 +507,36 @@ export class Research {
500
507
  if (!String(error.code).endsWith('.notFound'))
501
508
  throw error;
502
509
  }
503
- if (!publication)
510
+ if (!publication) {
511
+ const empty = await backend.recoverEmptyNative?.(selected, request.id);
512
+ if (empty?.state === 'verified') {
513
+ const current = this.workspace.context(selected);
514
+ this.workspace.completeSavedRequest(selected, request.id, current.generation, {}, { ...selected, state: 'empty', applied: 0, pendingChanges: 0, sharedRevision: revision(empty.revision), engine: 'ghidra-native' });
515
+ continue;
516
+ }
517
+ if (backend.nativeEngine) {
518
+ const update = await backend.recoverUpdate?.(selected, request.id);
519
+ if (!update || update.state === 'unknown')
520
+ continue;
521
+ }
504
522
  this.workspace.recordRequest(request.id, 'failed', { ...selected, state: 'not_published', applied: 0 });
523
+ }
505
524
  continue;
506
525
  }
507
526
  if (request.operation === 'ghidra.refresh') {
508
- // A refresh stages a detached candidate; context/result commit together, before install.
509
- this.workspace.recordRequest(request.id, 'failed', { ...selected, state: 'not_updated', receivedChanges: 0 });
527
+ // Native Update may have changed the saved checkout. An interrupted result cannot be declared not_updated.
528
+ if (backend.nativeEngine) {
529
+ const update = await backend.recoverUpdate?.(selected, request.id);
530
+ if (!update || update.state === 'unknown')
531
+ continue;
532
+ const context = this.workspace.context(selected);
533
+ if (update.state === 'conflict')
534
+ this.workspace.recordRequest(request.id, 'failed', { ...selected, state: 'conflict', receivedChanges: 0, preservedLocalChanges: count(context), conflicts: [{ engine: 'ghidra', message: update.conflict }] });
535
+ else
536
+ this.workspace.completeSavedRequest(selected, request.id, context.generation, {}, { ...selected, state: 'updated', engine: 'ghidra-native', sharedRevision: revision(update.revision), receivedChanges: update.receivedChanges, preservedLocalChanges: count(context), nativeMergeInvocations: update.nativeMergeInvocations, conflicts: [] });
537
+ }
538
+ else
539
+ this.workspace.recordRequest(request.id, 'failed', { ...selected, state: 'not_updated', receivedChanges: 0 });
510
540
  continue;
511
541
  }
512
542
  if (request.operation === 'ghidra.open') {
@@ -528,6 +558,15 @@ export class Research {
528
558
  continue;
529
559
  }
530
560
  const execution = request.execution === undefined ? undefined : object(request.execution);
561
+ if (execution?.kind === 'native-discard') {
562
+ const discarded = await backend.recoverDiscardNative?.(selected, request.id, execution.checkout);
563
+ if (discarded?.state === 'verified') {
564
+ const current = this.workspace.context(selected);
565
+ this.workspace.completeSavedRequest(selected, request.id, current.generation, {}, { ...selected, state: 'discarded', discardedChanges: Number(execution.discardedChanges), pendingChanges: 0,
566
+ baseRevision: revision(discarded.baseRevision), ...(discarded.retainedKeepFile ? { retainedKeepFile: discarded.retainedKeepFile } : {}) });
567
+ }
568
+ continue;
569
+ }
531
570
  if (execution?.kind === 'discard') {
532
571
  try {
533
572
  const current = this.workspace.context(selected), base = execution.baseSnapshot, discarded = execution.discardedSnapshot;
@@ -584,7 +623,7 @@ export class Research {
584
623
  const observed = await this.workspace.artifacts.capture(text(execution.output, 4096), 'snapshot'), current = this.workspace.context(selected);
585
624
  if (observed.id !== snapshot.id || current.generation !== execution.generation)
586
625
  continue;
587
- this.workspace.completeSavedRequest(selected, request.id, current.generation, { workingSnapshot: snapshot }, { ...selected, state: 'exported', output: execution.output, sha256: snapshot.sha256, size: snapshot.size });
626
+ this.workspace.completeSavedRequest(selected, request.id, current.generation, { workingSnapshot: execution.workingSnapshot ?? snapshot }, { ...selected, state: 'exported', output: execution.output, sha256: snapshot.sha256, size: snapshot.size });
588
627
  }
589
628
  catch { /* Partial or changed output cannot prove an export and is never overwritten. */ }
590
629
  continue;
@@ -685,80 +724,56 @@ export class Research {
685
724
  if (reserved.replay && request.state !== 'accepted') {
686
725
  if (request.state === 'applied')
687
726
  return request.result;
688
- if (request.state === 'failed')
689
- fail('conflict', 'This merge retained its original failed result.', request.result);
690
- fail('unknown', 'This merge has an unresolved outcome; its intent must be reconciled.', request.result);
727
+ fail(request.state === 'failed' ? 'conflict' : 'unknown', 'This merge retains its recorded outcome; it is never checked in blindly again.', request.result);
691
728
  }
692
729
  if (this.workspace.activePublication(selected.target) || this.workspace.model(selected.target).state === 'unknown')
693
- fail('blocked', 'Shared model has an unresolved publication; preserve all private work until reconciliation.');
730
+ fail('blocked', 'Shared publication is unresolved; retain every working copy.');
694
731
  backend ??= await this.backend();
732
+ if (backend.nativeEngine !== 'native-checkout-v1' || !backend.updateNative || !backend.publishNative || !backend.dropNative || !backend.finishEmptyNative)
733
+ fail('configuration', 'The primary CLI requires native checkout/Update/check-in; scalar fallback is disabled.');
695
734
  await backend.open(selected);
696
- if (!backend.latest || !backend.fields || !backend.candidate || !backend.publish)
697
- fail('configuration', 'Selected backend lacks the verified publication contract.');
698
- let context = this.workspace.context(selected);
699
- if (context.complexChanges.length && context.workingSnapshot) {
700
- const scalars = await this.savedScalars(context, backend, context.workingSnapshot);
701
- if (digest(scalars) !== digest(context.scalars))
702
- context = this.workspace.saveContext(selected, context.generation, { scalars });
703
- }
704
- if (!context.baseRevision || !context.baseSnapshot || !context.workingSnapshot)
705
- fail('binding', 'Private context has no saved comparison base.');
706
- this.workspace.startRequest(request.id);
735
+ if (this.workspace.context(selected).debugger?.connected)
736
+ fail('busy', 'Stop the live debugger before handing its native project to Update/check-in.');
737
+ this.workspace.startRequest(request.id, { kind: 'native-merge' });
707
738
  let publication;
708
739
  try {
709
- if (!count(context)) {
710
- const result = { ...selected, state: 'empty', applied: 0, pendingChanges: 0 };
711
- this.workspace.recordRequest(request.id, 'applied', result);
712
- return result;
713
- }
714
- const shared = await backend.latest(selected.target);
715
- this.workspace.observeShared(selected.target, shared.revision, shared.snapshot);
716
- const original = await backend.fields(context.baseSnapshot, context.scalars), current = await backend.fields(shared.snapshot, context.scalars);
717
- const comparisons = Object.fromEntries(context.scalars.map(change => {
718
- const key = fieldKey(change), before = original[key], after = current[key];
719
- if (!before || !after)
720
- fail('partial', 'Saved comparison omitted a pending field.');
721
- return [key, { value: after.value, compatible: after.exists && before.exists && (change.dependency ?? before.dependency) === after.dependency }];
722
- }));
723
- const plan = scalarMerge(context.scalars, context.complexChanges.length > 0, context.baseRevision, shared.revision, comparisons);
724
- if (plan.state === 'conflict') {
725
- const conflicts = [...plan.conflicts.map(conflict => ({ ...conflict, address: publicAddress(conflict.address) })),
726
- ...(context.complexChanges.length && context.baseRevision !== shared.revision ? [{ field: 'program', reason: 'complex_divergence',
727
- originalRevision: revision(context.baseRevision), sharedRevision: revision(shared.revision), local: 'retained saved private state' }] : [])];
728
- const scalars = context.scalars.map(change => {
729
- const conflict = plan.conflicts.find(item => fieldKey(item) === fieldKey(change));
730
- return conflict ? { ...change, conflict: { shared: conflict.shared } } : change;
731
- });
732
- this.workspace.saveContext(selected, context.generation, { scalars });
733
- const result = { ...selected, state: 'conflict', applied: 0, sharedRevision: revision(shared.revision), pendingChanges: count(context), conflicts };
740
+ const update = await backend.updateNative(selected, request.id), context = this.workspace.context(selected);
741
+ if (update.state === 'conflict') {
742
+ const result = { ...selected, state: 'conflict', applied: 0, pendingChanges: count(context), conflicts: [{ engine: 'ghidra', message: update.conflict }] };
734
743
  this.workspace.recordRequest(request.id, 'failed', result);
735
- fail('conflict', 'Merge conflicts preserve all local work; nothing was published.', result);
744
+ fail('conflict', 'Native conflict preserves the original working copy and checkout.', result);
736
745
  }
737
- if (plan.state === 'already_shared') {
738
- const result = { ...selected, state: 'merged', applied: 0, sharedRevision: revision(shared.revision), pendingChanges: 0 };
739
- this.workspace.completeSavedRequest(selected, request.id, context.generation, { baseRevision: shared.revision, baseSnapshot: shared.snapshot,
740
- workingSnapshot: shared.snapshot, viewEpoch: (context.viewEpoch ?? 0) + 1, scalars: [], complexChanges: [] }, result);
746
+ if (update.state === 'empty') {
747
+ await backend.finishEmptyNative(selected);
748
+ const current = this.workspace.context(selected);
749
+ const result = { ...selected, state: count(context) ? 'merged' : 'empty', applied: 0, pendingChanges: 0, sharedRevision: revision(update.revision), engine: 'ghidra-native' };
750
+ this.workspace.completeSavedRequest(selected, request.id, current.generation, {}, result);
741
751
  return result;
742
752
  }
743
- const snapshot = plan.fullSnapshot ? context.workingSnapshot : await backend.candidate(selected.target, shared.snapshot, plan.apply);
744
- publication = this.workspace.beginPublication(selected, request.id, shared.revision, snapshot);
753
+ if (update.revision < (this.workspace.model(selected.target).sharedRevision ?? 1)) {
754
+ const result = { ...selected, state: 'conflict', reason: 'shared_changed', applied: 0, pendingChanges: count(context) };
755
+ this.workspace.recordRequest(request.id, 'failed', result);
756
+ fail('conflict', 'Another context observed a newer server version; retain this checkout and perform a new native Update.', result);
757
+ }
758
+ publication = this.workspace.beginPublication(selected, request.id, update.revision, update.snapshot);
745
759
  publication = this.workspace.publicationIntent(publication.id);
746
- const published = await backend.publish(publication);
760
+ const published = await backend.publishNative(publication);
747
761
  if (published.state === 'conflict') {
748
- const result = { ...selected, state: 'conflict', reason: 'shared_changed', applied: 0, pendingChanges: count(context) };
762
+ const result = { ...selected, state: 'conflict', reason: 'shared_changed', applied: 0, pendingChanges: count(context), conflicts: [{ engine: 'ghidra', message: published.conflict ?? 'Shared head changed' }] };
749
763
  this.workspace.rejectPublication(publication.id, result);
750
- fail('conflict', 'Shared base changed before publication; all local work was retained.', result);
764
+ fail('conflict', 'Native check-in was refused; local work remains retained.', result);
751
765
  }
752
- const result = { ...selected, state: 'merged', sharedRevision: revision(published.revision), applied: count(context), pendingChanges: 0 };
753
- this.workspace.finishPublication(publication.id, published.revision, result);
766
+ const result = { ...selected, state: 'merged', sharedRevision: revision(published.revision), applied: count(context), pendingChanges: 0, engine: 'ghidra-native' };
767
+ this.workspace.finishPublication(publication.id, published.revision, result, published.snapshot);
768
+ await backend.dropNative(selected);
754
769
  return result;
755
770
  }
756
771
  catch (error) {
757
772
  const state = this.workspace.request(request.id).state;
758
773
  if (state !== 'applied' && state !== 'failed') {
759
774
  if (publication && ['commit_intent', 'unknown'].includes(this.workspace.publication(publication.id).state))
760
- this.workspace.unknownPublication(publication.id, { state: 'unknown' });
761
- this.workspace.recordRequest(request.id, 'unknown', { ...selected, state: 'unknown' });
775
+ this.workspace.unknownPublication(publication.id, { state: 'unknown', engine: 'ghidra-native' });
776
+ this.workspace.recordRequest(request.id, 'unknown', { ...selected, state: 'unknown', engine: 'ghidra-native' });
762
777
  }
763
778
  throw error;
764
779
  }
@@ -771,71 +786,32 @@ export class Research {
771
786
  if (reserved.replay && request.state !== 'accepted') {
772
787
  if (request.state === 'applied')
773
788
  return request.result;
774
- fail('unknown', 'Refresh retains an unresolved result; its saved state must be reconciled.', request.result);
789
+ fail(request.state === 'failed' ? 'conflict' : 'unknown', 'Native Update retains its recorded outcome; its saved checkout is preserved.', request.result);
775
790
  }
776
791
  if (this.workspace.activePublication(selected.target) || this.workspace.model(selected.target).state === 'unknown')
777
- fail('blocked', 'Shared publication outcome must be reconciled before receiving its version.');
792
+ fail('blocked', 'Shared publication requires reconciliation before Update.');
778
793
  const backend = await this.backend();
794
+ if (backend.nativeEngine !== 'native-checkout-v1' || !backend.updateNative)
795
+ fail('configuration', 'Native Update is required; scalar refresh fallback is disabled.');
779
796
  await backend.open(selected);
780
- if (!backend.latest || !backend.fields || !backend.candidate)
781
- fail('configuration', 'Selected backend lacks the verified refresh contract.');
782
- const context = this.workspace.context(selected);
783
- if (!context.baseSnapshot || !context.baseRevision || !context.workingSnapshot)
784
- fail('binding', 'Context lacks saved private and base state.');
785
- this.workspace.startRequest(request.id);
797
+ if (this.workspace.context(selected).debugger?.connected)
798
+ fail('busy', 'Stop the live debugger before handing its native project to Update.');
799
+ this.workspace.startRequest(request.id, { kind: 'native-update' });
786
800
  try {
787
- const shared = await backend.latest(selected.target);
788
- this.workspace.observeShared(selected.target, shared.revision, shared.snapshot);
789
- const publications = this.workspace.publishedSince(selected.target, context.baseRevision);
790
- const fields = new Map(context.scalars.map(change => [fieldKey(change), change]));
791
- for (const publication of publications)
792
- for (const change of publication.scalars)
793
- fields.set(fieldKey(change), change);
794
- const selectors = [...fields.values()];
795
- const original = await backend.fields(context.baseSnapshot, selectors), working = await backend.fields(context.workingSnapshot, selectors), current = await backend.fields(shared.snapshot, selectors);
796
- const local = context.complexChanges.length ? await this.savedScalars(context, backend, context.workingSnapshot) : context.scalars.map(change => ({ ...change }));
797
- // An opaque operation may have touched an incoming scalar too: retain that actual value.
798
- if (context.complexChanges.length)
799
- for (const change of selectors) {
800
- const key = fieldKey(change), before = original[key], privateValue = working[key];
801
- if (before && privateValue && before.value !== privateValue.value && !local.some(item => fieldKey(item) === key))
802
- local.push({ address: change.address, field: change.field, original: before.value, local: privateValue.value, dependency: before.dependency, ...(!privateValue.exists ? { removed: true } : {}) });
803
- }
804
- const incoming = [], comparisons = {};
805
- for (const selector of selectors) {
806
- const key = fieldKey(selector), before = original[key], privateValue = working[key], after = current[key];
807
- if (!before || !privateValue || !after)
808
- fail('partial', 'Refresh comparison omitted an incoming or local field.');
809
- comparisons[key] = { value: after.value, compatible: before.exists && privateValue.exists && after.exists &&
810
- before.dependency === after.dependency && privateValue.dependency === after.dependency };
811
- incoming.push({ address: selector.address, field: selector.field, original: before.value, local: after.value });
812
- }
813
- const plan = scalarRefresh(local, incoming, comparisons);
814
- const changed = plan.receive.filter(change => working[fieldKey(change)]?.value !== change.local);
815
- const dependencyConflict = local.some(change => !comparisons[fieldKey(change)]?.compatible);
816
- const preserveWhole = context.complexChanges.length > 0 || dependencyConflict;
817
- let snapshot = context.workingSnapshot;
818
- if (preserveWhole) {
819
- if (changed.length)
820
- snapshot = await backend.candidate(selected.target, context.workingSnapshot, changed);
801
+ const update = await backend.updateNative(selected, request.id), context = this.workspace.context(selected);
802
+ if (update.state === 'conflict') {
803
+ const result = { ...selected, state: 'conflict', receivedChanges: 0, preservedLocalChanges: count(context), conflicts: [{ engine: 'ghidra', message: update.conflict }] };
804
+ this.workspace.recordRequest(request.id, 'failed', result);
805
+ fail('conflict', 'Native Update requires a decision; saved private work and ancestry are preserved.', result);
821
806
  }
822
- else
823
- snapshot = plan.preserve.length ? await backend.candidate(selected.target, shared.snapshot, plan.preserve) : shared.snapshot;
824
- const complexConflict = preserveWhole && shared.revision !== context.baseRevision;
825
- const conflicts = [...plan.conflicts.map(conflict => ({ ...conflict, address: publicAddress(conflict.address) })),
826
- ...(complexConflict ? [{ field: 'program', reason: 'complex_divergence', originalRevision: revision(context.baseRevision),
827
- sharedRevision: revision(shared.revision), local: 'retained saved private state' }] : [])];
828
- const receivedProgram = !preserveWhole && shared.revision !== context.baseRevision &&
829
- (publications.some(publication => publication.complex) || publications.length !== shared.revision - context.baseRevision);
830
- const result = { ...selected, state: conflicts.length ? 'conflict' : 'updated', sharedRevision: revision(shared.revision),
831
- receivedChanges: changed.length + Number(receivedProgram), preservedLocalChanges: plan.preserve.length + context.complexChanges.length, conflicts };
832
- this.workspace.completeSavedRequest(selected, request.id, context.generation, { workingSnapshot: snapshot, viewEpoch: (context.viewEpoch ?? 0) + 1,
833
- scalars: plan.preserve, ...(!preserveWhole ? { baseRevision: shared.revision, baseSnapshot: shared.snapshot } : {}) }, result);
807
+ const result = { ...selected, state: 'updated', engine: 'ghidra-native', sharedRevision: revision(update.revision), receivedChanges: update.receivedChanges,
808
+ preservedLocalChanges: count(context), nativeMergeInvocations: update.nativeMergeInvocations, conflicts: [] };
809
+ this.workspace.completeSavedRequest(selected, request.id, context.generation, {}, result);
834
810
  return result;
835
811
  }
836
812
  catch (error) {
837
- if (this.workspace.request(request.id).state !== 'applied')
838
- this.workspace.recordRequest(request.id, 'unknown', { ...selected, state: 'unknown' });
813
+ if (!['applied', 'failed'].includes(this.workspace.request(request.id).state))
814
+ this.workspace.recordRequest(request.id, 'unknown', { ...selected, state: 'unknown', engine: 'ghidra-native' });
839
815
  throw error;
840
816
  }
841
817
  }));
@@ -45,7 +45,7 @@ export class SdkFiles {
45
45
  fail('configuration', 'Native SDK file workflows are unavailable.');
46
46
  await backend.open(selected);
47
47
  const snapshot = await backend.saved(selected);
48
- return { ...selected, value: await backend.sdkFile('exporters', { snapshot: await this.workspace.artifacts.verify(snapshot) }) };
48
+ return { ...selected, value: await backend.sdkFile('exporters', { snapshot: (backend.snapshotFile ? await backend.snapshotFile(snapshot) : await this.workspace.artifacts.verify(snapshot)) }) };
49
49
  });
50
50
  }
51
51
  async copy(files, directory, recovery = false) {
@@ -121,7 +121,7 @@ export class SdkFiles {
121
121
  if (!backend.sdkFile)
122
122
  fail('configuration', 'Native function databases are unavailable.');
123
123
  await backend.open(selected);
124
- const snapshot = await backend.saved(selected), value = await backend.sdkFile(operation, { ...p, database: await this.workspace.artifacts.verify(artifact), snapshot: await this.workspace.artifacts.verify(snapshot) });
124
+ const snapshot = await backend.saved(selected), value = await backend.sdkFile(operation, { ...p, database: await this.workspace.artifacts.verify(artifact), snapshot: (backend.snapshotFile ? await backend.snapshotFile(snapshot) : await this.workspace.artifacts.verify(snapshot)) });
125
125
  return { ...selected, databaseSha256: artifact.sha256, sourceSnapshotSha256: snapshot.sha256, value };
126
126
  });
127
127
  }
@@ -177,7 +177,7 @@ export class SdkFiles {
177
177
  this.workspace.startRequest(request.id, { kind: 'sdk-file', operation, snapshot, generation: current.generation });
178
178
  try {
179
179
  const filename = operation === 'archive-export' ? 'types.gdt' : operation === 'fid-build' ? 'database.fidb' : operation === 'bsim-build' ? 'database.mv.db' : 'program.out';
180
- const value = await backend.sdkFile(operation, { ...parameters, request_id: request.id, receipt: join(stage, 'native-result.json'), snapshot: await this.workspace.artifacts.verify(snapshot), output: join(outputs, filename) });
180
+ const value = await backend.sdkFile(operation, { ...parameters, request_id: request.id, receipt: join(stage, 'native-result.json'), snapshot: (backend.snapshotFile ? await backend.snapshotFile(snapshot) : await this.workspace.artifacts.verify(snapshot)), output: join(outputs, filename) });
181
181
  if (value.state !== 'exported')
182
182
  fail('partial', 'Native exporter did not establish a completed output.');
183
183
  const completed = await this.completedOutput(stage, request.id, operation), files = completed.files;