@eyeauras/insight-cli 0.6.3 → 0.6.6
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.
- package/.cli-package-build.json +1 -1
- package/SKILL.md +9 -7
- package/dist/src/cli.js +1 -1
- package/dist/src/contexts.d.ts +32 -8
- package/dist/src/contexts.js +532 -92
- package/dist/src/cross-peer.d.ts +20 -0
- package/dist/src/cross-peer.js +53 -0
- package/dist/src/debugger-results.d.ts +2 -1
- package/dist/src/debugger-results.js +9 -4
- package/dist/src/debugger.js +3 -2
- package/dist/src/lifecycle.d.ts +2 -0
- package/dist/src/lifecycle.js +49 -2
- package/dist/src/native-merge-patches.js +20 -2
- package/dist/src/research.d.ts +14 -2
- package/dist/src/research.js +31 -4
- package/dist/src/storage-gc.js +244 -44
- package/dist/src/tool-runtime/run.js +24 -11
- package/dist/src/tool-runtime/supervisor.js +51 -9
- package/dist/src/workspace.d.ts +47 -1
- package/dist/src/workspace.js +128 -13
- package/package.json +1 -1
- package/references/agent-setup.md +11 -3
- package/references/debugger.md +5 -3
- package/references/extensions-and-sync.md +7 -6
- package/references/managed-runtime.md +4 -3
- package/references/native/InsightNativeCheckout.java +203 -16
- package/references/native/NATIVE-MERGE-NOTICE.txt +5 -1
- package/references/native-workflows.md +5 -3
- package/references/query-semantics.md +3 -2
- package/references/recovery.md +6 -0
- package/references/setup.md +9 -2
- package/skill-bundle/insight-artifacts/SKILL.md +1 -1
- package/skill-bundle/insight-artifacts/references/recovery.md +6 -0
- package/skill-bundle/insight-binary/SKILL.md +1 -1
- package/skill-bundle/insight-capture/SKILL.md +1 -1
- package/skill-bundle/insight-cli/SKILL.md +9 -7
- package/skill-bundle/insight-cli/references/agent-setup.md +11 -3
- package/skill-bundle/insight-cli/references/managed-runtime.md +4 -3
- package/skill-bundle/insight-cli/references/recovery.md +6 -0
- package/skill-bundle/insight-cli/references/setup.md +9 -2
- package/skill-bundle/insight-die/SKILL.md +1 -1
- package/skill-bundle/insight-dnspy/SKILL.md +1 -1
- package/skill-bundle/insight-dotnet-dump/SKILL.md +1 -1
- package/skill-bundle/insight-dotnet-stack/SKILL.md +1 -1
- package/skill-bundle/insight-dotnet-trace/SKILL.md +1 -1
- package/skill-bundle/insight-frida/SKILL.md +1 -1
- package/skill-bundle/insight-ghidra/SKILL.md +4 -3
- package/skill-bundle/insight-ghidra/references/debugger.md +5 -3
- package/skill-bundle/insight-ghidra/references/extensions-and-sync.md +7 -6
- package/skill-bundle/insight-ghidra/references/managed-runtime.md +4 -3
- package/skill-bundle/insight-ghidra/references/native-workflows.md +5 -3
- package/skill-bundle/insight-ghidra/references/query-semantics.md +3 -2
- package/skill-bundle/insight-ghidra/references/recovery.md +6 -0
- package/skill-bundle/insight-ghidra/references/setup.md +9 -2
- package/skill-bundle/insight-ilspy/SKILL.md +1 -1
- package/skill-bundle/insight-interop/SKILL.md +1 -1
- package/skill-bundle/insight-lldb/SKILL.md +1 -1
- package/skill-bundle/insight-llvm/SKILL.md +1 -1
- package/skill-bundle/insight-managed-heap/SKILL.md +1 -1
- package/skill-bundle/insight-managed-metadata/SKILL.md +1 -1
- package/skill-bundle/insight-mitmproxy/SKILL.md +1 -1
- package/skill-bundle/insight-overview/SKILL.md +1 -1
- package/skill-bundle/insight-procmon/SKILL.md +1 -1
- package/skill-bundle/insight-re/SKILL.md +1 -1
- package/skill-bundle/insight-re/references/recovery.md +6 -0
- package/skill-bundle/insight-sevenzip/SKILL.md +1 -1
- package/skill-bundle/insight-strace/SKILL.md +1 -1
- package/skill-bundle/insight-tshark/SKILL.md +1 -1
- package/skill-bundle/insight-windbg/SKILL.md +1 -1
- package/skill-bundle/manifest.json +1 -1
- package/skills/insight-artifacts/SKILL.md +1 -1
- package/skills/insight-artifacts/references/recovery.md +6 -0
- package/skills/insight-binary/SKILL.md +1 -1
- package/skills/insight-capture/SKILL.md +1 -1
- package/skills/insight-die/SKILL.md +1 -1
- package/skills/insight-dnspy/SKILL.md +1 -1
- package/skills/insight-dotnet-dump/SKILL.md +1 -1
- package/skills/insight-dotnet-stack/SKILL.md +1 -1
- package/skills/insight-dotnet-trace/SKILL.md +1 -1
- package/skills/insight-frida/SKILL.md +1 -1
- package/skills/insight-ghidra/SKILL.md +4 -3
- package/skills/insight-ghidra/references/debugger.md +5 -3
- package/skills/insight-ghidra/references/extensions-and-sync.md +7 -6
- package/skills/insight-ghidra/references/managed-runtime.md +4 -3
- package/skills/insight-ghidra/references/native-workflows.md +5 -3
- package/skills/insight-ghidra/references/query-semantics.md +3 -2
- package/skills/insight-ghidra/references/recovery.md +6 -0
- package/skills/insight-ghidra/references/setup.md +9 -2
- package/skills/insight-ilspy/SKILL.md +1 -1
- package/skills/insight-interop/SKILL.md +1 -1
- package/skills/insight-lldb/SKILL.md +1 -1
- package/skills/insight-llvm/SKILL.md +1 -1
- package/skills/insight-managed-heap/SKILL.md +1 -1
- package/skills/insight-managed-metadata/SKILL.md +1 -1
- package/skills/insight-mitmproxy/SKILL.md +1 -1
- package/skills/insight-overview/SKILL.md +1 -1
- package/skills/insight-procmon/SKILL.md +1 -1
- package/skills/insight-re/SKILL.md +1 -1
- package/skills/insight-re/references/recovery.md +6 -0
- package/skills/insight-sevenzip/SKILL.md +1 -1
- package/skills/insight-strace/SKILL.md +1 -1
- package/skills/insight-tshark/SKILL.md +1 -1
- package/skills/insight-windbg/SKILL.md +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface PeerOwner {
|
|
2
|
+
target: string;
|
|
3
|
+
context?: string;
|
|
4
|
+
}
|
|
5
|
+
interface PeerReceipt extends PeerOwner {
|
|
6
|
+
path: string;
|
|
7
|
+
state: 'preparing' | 'closed';
|
|
8
|
+
}
|
|
9
|
+
type PeerStage = {
|
|
10
|
+
folder: string;
|
|
11
|
+
reason: string;
|
|
12
|
+
} | {
|
|
13
|
+
folder: string;
|
|
14
|
+
receipt: PeerReceipt;
|
|
15
|
+
input?: string;
|
|
16
|
+
};
|
|
17
|
+
/** Only the generated input of an exactly owned stage is disposable; its receipt stays. */
|
|
18
|
+
export declare function peerStage(root: string, name: string, owner: PeerOwner): Promise<PeerStage>;
|
|
19
|
+
export declare function peerStages(root: string, owner: PeerOwner): Promise<PeerStage[]>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { lstat, readFile, readdir, realpath } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
const peerName = /^__insight_peer_[a-f0-9]{32}$/;
|
|
4
|
+
const missing = (error) => error.code === 'ENOENT';
|
|
5
|
+
/** Only the generated input of an exactly owned stage is disposable; its receipt stays. */
|
|
6
|
+
export async function peerStage(root, name, owner) {
|
|
7
|
+
const parent = join(root, 'cross-peer'), folder = join(parent, name), keep = (reason) => ({ folder, reason });
|
|
8
|
+
if (!peerName.test(name))
|
|
9
|
+
return keep('Unrecognized cross-target stage.');
|
|
10
|
+
try {
|
|
11
|
+
const parentStat = await lstat(parent), stageStat = await lstat(folder);
|
|
12
|
+
if (parentStat.isSymbolicLink() || !parentStat.isDirectory() || stageStat.isSymbolicLink() || !stageStat.isDirectory() ||
|
|
13
|
+
await realpath(folder) !== join(await realpath(root), 'cross-peer', name))
|
|
14
|
+
return keep('Cross-target stage left its owned directory or is a link.');
|
|
15
|
+
let input;
|
|
16
|
+
for (const entry of await readdir(folder, { withFileTypes: true })) {
|
|
17
|
+
if (!['receipt.json', 'input.gzf'].includes(entry.name))
|
|
18
|
+
return keep('Cross-target stage holds unrecognized files.');
|
|
19
|
+
if (!entry.isFile())
|
|
20
|
+
return keep('Cross-target stage holds links or special entries.');
|
|
21
|
+
if (entry.name === 'input.gzf')
|
|
22
|
+
input = join(folder, entry.name);
|
|
23
|
+
}
|
|
24
|
+
const receipt = JSON.parse(await readFile(join(folder, 'receipt.json'), 'utf8'));
|
|
25
|
+
if (!receipt || typeof receipt !== 'object' || !owner.context || receipt.path !== '/' + name || receipt.target !== owner.target || receipt.context !== owner.context)
|
|
26
|
+
return keep('Cross-target cleanup receipt belongs to another context or is malformed.');
|
|
27
|
+
if (receipt.state !== 'closed' && receipt.state !== 'preparing')
|
|
28
|
+
return keep('Unknown cross-target cleanup stage.');
|
|
29
|
+
return { folder, receipt, ...(input ? { input } : {}) };
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (missing(error) || error instanceof SyntaxError)
|
|
33
|
+
return keep('Cross-target cleanup receipt or stage is missing or malformed.');
|
|
34
|
+
return keep('Cross-target stage could not be verified: ' + String(error.code ?? 'unavailable'));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export async function peerStages(root, owner) {
|
|
38
|
+
const parent = join(root, 'cross-peer');
|
|
39
|
+
try {
|
|
40
|
+
const st = await lstat(parent);
|
|
41
|
+
if (st.isSymbolicLink() || !st.isDirectory())
|
|
42
|
+
return [{ folder: parent, reason: 'Cross-target stage inventory is a link or special entry.' }];
|
|
43
|
+
const stages = [];
|
|
44
|
+
for (const name of await readdir(parent))
|
|
45
|
+
stages.push(await peerStage(root, name, owner));
|
|
46
|
+
return stages;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (missing(error))
|
|
50
|
+
return [];
|
|
51
|
+
return [{ folder: parent, reason: 'Cross-target stage inventory could not be verified: ' + String(error.code ?? 'unavailable') }];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ResearchBackend } from './research.js';
|
|
2
2
|
import type { Artifact } from './artifacts.js';
|
|
3
3
|
export declare function debuggerExecutionSettled(operation: string, before: Record<string, unknown>, after: Record<string, unknown>): boolean;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function debuggerMetadataFingerprint(raw: unknown): string;
|
|
5
|
+
export declare function debuggerProgramMetadata(backend: Pick<ResearchBackend, 'inspect' | 'debuggerMetadata'>, snapshot: Artifact): Promise<string | undefined>;
|
|
5
6
|
export declare function debuggerResult(operation: string, p: Record<string, unknown>, raw: unknown): Record<string, unknown> | Record<string, unknown>[];
|
|
@@ -12,15 +12,20 @@ export function debuggerExecutionSettled(operation, before, after) {
|
|
|
12
12
|
return after.execution_state === 'RUNNING' || after.execution_state === 'STOPPED' && advanced;
|
|
13
13
|
return after.execution_state === 'STOPPED' && (operation !== 'step' || advanced);
|
|
14
14
|
}
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
return undefined;
|
|
18
|
-
const value = object(await backend.inspect(snapshot, { kind: 'debugger_bookmarks' }));
|
|
15
|
+
export function debuggerMetadataFingerprint(raw) {
|
|
16
|
+
const value = object(raw);
|
|
19
17
|
if (typeof value.fingerprint !== 'string' || !/^[a-f0-9]{64}$/.test(value.fingerprint))
|
|
20
18
|
fail('partial', 'Debugger program metadata inspection is incomplete.');
|
|
21
19
|
count(value.count);
|
|
22
20
|
return value.fingerprint;
|
|
23
21
|
}
|
|
22
|
+
export async function debuggerProgramMetadata(backend, snapshot) {
|
|
23
|
+
if (backend.debuggerMetadata)
|
|
24
|
+
return backend.debuggerMetadata(snapshot);
|
|
25
|
+
if (!backend.inspect)
|
|
26
|
+
return undefined;
|
|
27
|
+
return debuggerMetadataFingerprint(await backend.inspect(snapshot, { kind: 'debugger_bookmarks' }));
|
|
28
|
+
}
|
|
24
29
|
export function debuggerResult(operation, p, raw) {
|
|
25
30
|
if (['launch_offers', 'traces', 'modules', 'list_breakpoints', 'stack_trace'].includes(operation)) {
|
|
26
31
|
const rows = array(raw);
|
package/dist/src/debugger.js
CHANGED
|
@@ -65,8 +65,9 @@ export class Debugger {
|
|
|
65
65
|
let value;
|
|
66
66
|
if (operation !== 'traces')
|
|
67
67
|
value = debuggerResult(operation, p, await backend.debuggerCall(selected, operation, Object.fromEntries(Object.entries(p).filter(([key]) => !['limit', 'offset'].includes(key)))));
|
|
68
|
-
const
|
|
69
|
-
const
|
|
68
|
+
const current = this.workspace.context(selected), beforeMetadata = current.workingSnapshot ? await metadata(backend, current.workingSnapshot) : undefined;
|
|
69
|
+
const saved = await backend.debuggerSaved(selected), snapshot = await backend.saved(selected);
|
|
70
|
+
const changed = beforeMetadata !== undefined && beforeMetadata !== await metadata(backend, snapshot);
|
|
70
71
|
const complexChanges = changed ? [...current.complexChanges, 'debugger-metadata-' + randomUUID()] : current.complexChanges;
|
|
71
72
|
this.workspace.saveContext(selected, current.generation, { debugger: saved, workingSnapshot: snapshot, complexChanges });
|
|
72
73
|
if (operation === 'traces')
|
package/dist/src/lifecycle.d.ts
CHANGED
|
@@ -59,6 +59,8 @@ export declare class Lifecycle {
|
|
|
59
59
|
discard(selected: Scope, callerId?: string): Promise<unknown>;
|
|
60
60
|
/** Gives up detached work that has no native continuation. Nothing is replayed or published; a journal keeps its identity. */
|
|
61
61
|
discardLegacy(selected: Scope, acknowledged: boolean, callerId?: string): Promise<unknown>;
|
|
62
|
+
/** Gives up a native checkout whose project no longer exists. Only its exact server checkout is ended. */
|
|
63
|
+
discardMissing(selected: Scope, acknowledged: boolean, callerId?: string): Promise<unknown>;
|
|
62
64
|
saveAll(session: string, callerId?: string): Promise<unknown>;
|
|
63
65
|
}
|
|
64
66
|
export declare function lifecycleCommands(service: (context: CommandContext) => Lifecycle, runtimeStatus?: (context: CommandContext) => Promise<unknown>): CommandDefinition[];
|
package/dist/src/lifecycle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { command, Permission, CliError } from '@eyeauras/cli-factory';
|
|
2
2
|
import { scope } from './research.js';
|
|
3
|
-
import { legacyDiscardOperation } from './workspace.js';
|
|
3
|
+
import { legacyDiscardOperation, missingDiscardOperation } from './workspace.js';
|
|
4
4
|
import { id, fail, object, digest } from './model.js';
|
|
5
5
|
import { selectedOptions } from './arguments.js';
|
|
6
6
|
import { mkdir } from 'node:fs/promises';
|
|
@@ -183,6 +183,52 @@ export class Lifecycle {
|
|
|
183
183
|
discardedRequests: unresolved.map(pending => pending.callerId ?? pending.id), ...(current.workingSnapshot ? { discardedSha256: current.workingSnapshot.sha256 } : {}), pendingChanges: 0 });
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
|
+
/** Gives up a native checkout whose project no longer exists. Only its exact server checkout is ended. */
|
|
187
|
+
async discardMissing(selected, acknowledged, callerId) {
|
|
188
|
+
if (!acknowledged)
|
|
189
|
+
fail('invalid', 'Explicit --acknowledge-lost-work is required.');
|
|
190
|
+
const reserved = this.workspace.reserveRequest(selected, missingDiscardOperation, {}, callerId);
|
|
191
|
+
return this.research.ordered(selected, async () => {
|
|
192
|
+
const request = this.workspace.request(reserved.request.id);
|
|
193
|
+
if (request.state === 'applied')
|
|
194
|
+
return request.result;
|
|
195
|
+
// Ending the recorded checkout is idempotent, so an interrupted run is simply repeated.
|
|
196
|
+
if (!['accepted', 'running'].includes(request.state))
|
|
197
|
+
fail('unknown', 'Missing checkout discard did not complete; repeat it with a new request.', request.result);
|
|
198
|
+
const current = this.workspace.context(selected), backend = await this.backend();
|
|
199
|
+
let checkout;
|
|
200
|
+
try {
|
|
201
|
+
if (this.workspace.activePublication(selected.target))
|
|
202
|
+
fail('blocked', 'Publication must be reconciled before discarding a missing checkout.');
|
|
203
|
+
if (this.workspace.model(selected.target).state !== 'ready')
|
|
204
|
+
fail('blocked', 'Initial publication of this model must be reconciled before discarding a missing checkout.');
|
|
205
|
+
if (current.debugger?.connected)
|
|
206
|
+
fail('busy', 'Close the live debugger context before discarding it.');
|
|
207
|
+
if (this.workspace.checkoutReferenced(current))
|
|
208
|
+
fail('blocked', 'An unresolved operation in another context references this checkout.');
|
|
209
|
+
if (!backend.missingCheckout || !backend.abandonMissing)
|
|
210
|
+
fail('unsupported', 'The selected backend cannot give up a missing native checkout.');
|
|
211
|
+
checkout = await backend.missingCheckout(selected);
|
|
212
|
+
if (request.state === 'accepted')
|
|
213
|
+
await backend.abandonMissing(selected, true);
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
// Nothing was changed, so a refused intent must not block a restored project.
|
|
217
|
+
if (request.state === 'accepted')
|
|
218
|
+
this.workspace.recordRequest(request.id, 'failed', { ...selected, state: 'not_discarded' });
|
|
219
|
+
throw error;
|
|
220
|
+
}
|
|
221
|
+
const unresolved = this.workspace.unfinished(selected).filter(pending => pending.id !== request.id);
|
|
222
|
+
const root = join(this.workspace.directory, 'native-discards', selected.target);
|
|
223
|
+
await mkdir(root, { recursive: true, mode: 0o700 });
|
|
224
|
+
await migrationDurable(join(root, current.id + '-' + request.id + '.json'), { schema: 1, request: request.id, original: current, unresolved });
|
|
225
|
+
if (request.state === 'accepted')
|
|
226
|
+
this.workspace.startRequest(request.id, { kind: 'missing-discard', generation: current.generation, checkout });
|
|
227
|
+
await backend.abandonMissing(selected, false);
|
|
228
|
+
return this.workspace.discardMissing(selected, request.id, current.generation, { ...selected, state: 'discarded', discardedChanges: current.scalars.length + current.complexChanges.length,
|
|
229
|
+
discardedRequests: unresolved.map(pending => pending.callerId ?? pending.id), checkoutId: checkout.checkoutId, pendingChanges: 0 });
|
|
230
|
+
});
|
|
231
|
+
}
|
|
186
232
|
async saveAll(session, callerId) {
|
|
187
233
|
this.workspace.session(session);
|
|
188
234
|
const reserved = this.workspace.reserveAdministration('session.ghidra.save', { session }, callerId), request = this.workspace.administration(reserved.request.id);
|
|
@@ -226,7 +272,8 @@ export class Lifecycle {
|
|
|
226
272
|
export function lifecycleCommands(service, runtimeStatus) {
|
|
227
273
|
return [command('changes', 'Manage unpublished edits in the selected context', [
|
|
228
274
|
command('discard', 'Retain native keep data, discard private edits and check out the current server version', ({ options: o }, c) => service(c).discard(scope(o), o.requestId === undefined ? undefined : id(o.requestId)), { permission: 'Destructive', options: [...selectedOptions, { flags: '--request-id <id>', description: 'Retrieve the same local discard result' }] }),
|
|
229
|
-
command('discard-legacy', 'Give up detached work of an older engine; gc then reclaims it and the next open starts a native checkout', ({ options: o }, c) => service(c).discardLegacy(scope(o), Boolean(o.acknowledgeLostWork), o.requestId === undefined ? undefined : id(o.requestId)), { permission: 'Destructive', options: [...selectedOptions, { flags: '--acknowledge-lost-work', description: 'Accept that unpublished edits and unknown outcomes of this context are dropped' }, { flags: '--request-id <id>', description: 'Retrieve the same discard result' }] })
|
|
275
|
+
command('discard-legacy', 'Give up detached work of an older engine; gc then reclaims it and the next open starts a native checkout', ({ options: o }, c) => service(c).discardLegacy(scope(o), Boolean(o.acknowledgeLostWork), o.requestId === undefined ? undefined : id(o.requestId)), { permission: 'Destructive', options: [...selectedOptions, { flags: '--acknowledge-lost-work', description: 'Accept that unpublished edits and unknown outcomes of this context are dropped' }, { flags: '--request-id <id>', description: 'Retrieve the same discard result' }] }),
|
|
276
|
+
command('discard-missing', 'Give up a native checkout whose project directory no longer exists and end its server checkout; the next open starts a new one', ({ options: o }, c) => service(c).discardMissing(scope(o), Boolean(o.acknowledgeLostWork), o.requestId === undefined ? undefined : id(o.requestId)), { permission: 'Destructive', options: [...selectedOptions, { flags: '--acknowledge-lost-work', description: 'Accept that unpublished edits and unknown outcomes of this context are lost' }, { flags: '--request-id <id>', description: 'Retrieve the same discard result' }] })
|
|
230
277
|
]),
|
|
231
278
|
command('save-all', 'Save every Ghidra context in the explicit session; outcomes are per context', ({ options: o }, c) => service(c).saveAll(id(o.session), o.requestId === undefined ? undefined : id(o.requestId)), { permission: Permission.Update, options: [{ flags: '--session <id>', description: 'Explicit session whose contexts are saved', required: true }, { flags: '--request-id <id>', description: 'Retrieve the recorded session save outcomes' }] }),
|
|
232
279
|
command('status', 'Inspect the installed runtime, or verify a selected context', ({ options: o }, c) => {
|
|
@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import * as zip from 'yauzl';
|
|
4
4
|
import { fail } from './model.js';
|
|
5
|
-
/** Version-pinned upstream display/entry adapters
|
|
5
|
+
/** Version-pinned upstream display/entry adapters and native compatibility fixes.
|
|
6
6
|
* Ghidra still creates/orders every resolver. No coordinator object merge lives here. */
|
|
7
7
|
const pins = [
|
|
8
8
|
['Features/Base', 'ghidra/app/merge/listing/ListingMergeManager.java', '3b6ce2e22fd414d6cc63ce2a3be6c533f13524b9513767b932f6da8f2d9326d6'],
|
|
@@ -61,8 +61,26 @@ export async function nativeMergeSources(home) {
|
|
|
61
61
|
for (const method of ['setListingViewsToEntireProgram', 'emptyListingViewForPrograms'])
|
|
62
62
|
source = replace(source, 'private void ' + method + '() {', 'private void ' + method + '() {\n\t\tif (mergePanel == null) return;');
|
|
63
63
|
}
|
|
64
|
-
else if (name.endsWith('/GhidraFileData.java'))
|
|
64
|
+
else if (name.endsWith('/GhidraFileData.java')) {
|
|
65
65
|
source = replace(source, 'if (SystemUtilities.isInHeadlessMode()) {', 'if (false /* Insight native headless merge adapter installed */) {', 2);
|
|
66
|
+
source = replace(source, 'DomainObject latestObj = null; // TODO: Is there some way to leverage the buffer file we already copied into tmpItem? Missing required change set', 'boolean mergeChanged = true;\n\t\t\t\tDomainObject latestObj = null; // TODO: Is there some way to leverage the buffer file we already copied into tmpItem? Missing required change set');
|
|
67
|
+
source = replace(source, 'mergeObj.save("Merge with version " + mergeVer, monitor);', `// A native merge can leave the latest-version result unchanged, even when
|
|
68
|
+
// the source checkout has local saves (e.g. Ghidra's open-time rewrite).
|
|
69
|
+
// save() otherwise skips it, leaving no cumulative change files for
|
|
70
|
+
// updateCheckoutFrom. Let the native save create those files, without
|
|
71
|
+
// adding an edit or synthesizing a change set.
|
|
72
|
+
mergeChanged = ((DomainObjectAdapterDB) mergeObj).getDBHandle().isChanged();
|
|
73
|
+
((DomainObjectAdapterDB) mergeObj).setChanged(true);
|
|
74
|
+
mergeObj.save("Merge with version " + mergeVer, monitor);`);
|
|
75
|
+
source = replace(source, 'tmpItem = null; // update removes temporary file if successful', `tmpItem = null; // update removes temporary file if successful
|
|
76
|
+
if (!mergeChanged) {
|
|
77
|
+
// The native result had no buffer changes relative to mergeVer.
|
|
78
|
+
// Record its new local version as clean, keeping the same checkout
|
|
79
|
+
// and the exact version merged, even if the server advances again.
|
|
80
|
+
folderItem.setCheckout(checkoutId, folderItem.isCheckedOutExclusive(), mergeVer,
|
|
81
|
+
folderItem.getCurrentVersion());
|
|
82
|
+
}`);
|
|
83
|
+
}
|
|
66
84
|
else if (name.endsWith('/ProgramContextMergeManager.java'))
|
|
67
85
|
source = replace(source, 'mergePanel.setTopComponent(conflictInfoPanel);', 'if (mergePanel != null) mergePanel.setTopComponent(conflictInfoPanel);');
|
|
68
86
|
else if (name.endsWith('/ExternalFunctionMerger.java'))
|
package/dist/src/research.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ export interface ResearchBackend {
|
|
|
13
13
|
collect?(dryRun: boolean): Promise<unknown>;
|
|
14
14
|
releaseUnchanged?(scope: Scope): Promise<boolean>;
|
|
15
15
|
detachedStopped?(scope: Scope): Promise<boolean>;
|
|
16
|
+
/** Proves that the checkout's project is gone and nothing of it runs; returns the receipt it proved. */
|
|
17
|
+
missingCheckout?(scope: Scope): Promise<NativeCheckout>;
|
|
18
|
+
/** Ends exactly that checkout on its server, or with check only proves that it could. Repeating it is safe. */
|
|
19
|
+
abandonMissing?(scope: Scope, check: boolean): Promise<void>;
|
|
16
20
|
updateNative?(scope: Scope, request: string): Promise<{
|
|
17
21
|
state: 'ready' | 'empty';
|
|
18
22
|
revision: number;
|
|
@@ -48,8 +52,8 @@ export interface ResearchBackend {
|
|
|
48
52
|
applied: 0;
|
|
49
53
|
conflict?: string;
|
|
50
54
|
}>;
|
|
51
|
-
dropNative?(scope: Scope): Promise<void>;
|
|
52
|
-
finishEmptyNative?(scope: Scope): Promise<void>;
|
|
55
|
+
dropNative?(scope: Scope, request?: string): Promise<void>;
|
|
56
|
+
finishEmptyNative?(scope: Scope, request?: string): Promise<void>;
|
|
53
57
|
recoverEmptyNative?(scope: Scope, request: string): Promise<{
|
|
54
58
|
state: 'verified';
|
|
55
59
|
revision: number;
|
|
@@ -105,9 +109,16 @@ export interface ResearchBackend {
|
|
|
105
109
|
state: 'verified';
|
|
106
110
|
revision: number;
|
|
107
111
|
snapshot?: Artifact;
|
|
112
|
+
} | {
|
|
113
|
+
state: 'refused';
|
|
114
|
+
revision: number;
|
|
115
|
+
snapshot: Artifact;
|
|
116
|
+
conflict: string;
|
|
108
117
|
} | {
|
|
109
118
|
state: 'unknown';
|
|
110
119
|
}>;
|
|
120
|
+
/** Immutable debugger metadata witness; native checkout receipts cannot reconstruct older buffers. */
|
|
121
|
+
debuggerMetadata?(snapshot: Artifact): Promise<string>;
|
|
111
122
|
recoverModel?(target: string): Promise<boolean>;
|
|
112
123
|
scripts?(scope: Scope, filter: string, limit: number, offset: number): Promise<ScriptPage>;
|
|
113
124
|
inspect?(snapshot: Artifact, parameters: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
@@ -127,6 +138,7 @@ export declare class Research {
|
|
|
127
138
|
private readonly backend;
|
|
128
139
|
private readonly tasks;
|
|
129
140
|
constructor(workspace: Workspace, backend: () => Promise<ResearchBackend>, tasks?: Map<string, Promise<unknown>>);
|
|
141
|
+
private retainedDisposal;
|
|
130
142
|
ordered<T>(selected: Scope, action: () => Promise<T>): Promise<T>;
|
|
131
143
|
boundary<T>(selected: Scope, action: () => Promise<T>): Promise<T>;
|
|
132
144
|
status(selected: Scope): {
|
package/dist/src/research.js
CHANGED
|
@@ -68,6 +68,15 @@ export class Research {
|
|
|
68
68
|
this.backend = backend;
|
|
69
69
|
this.tasks = tasks;
|
|
70
70
|
}
|
|
71
|
+
retainedDisposal(selected, request, error) {
|
|
72
|
+
if (!error || typeof error !== 'object')
|
|
73
|
+
return;
|
|
74
|
+
const failure = error, proof = failure.result?.retention, current = this.workspace.context(selected), outcome = this.workspace.request(request);
|
|
75
|
+
if (failure.code === 'coordinator.conflict' && failure.result?.state === 'retained' && proof?.schema === 1 && proof.source === 'native-release-status' &&
|
|
76
|
+
proof.request === request && proof.snapshot?.id === current.workingSnapshot?.id && outcome.context === current.id && outcome.state === 'failed' && digest(outcome.result) === digest(failure.result) &&
|
|
77
|
+
proof.checkout && current.nativeCheckout?.state === 'active' && digest(proof.checkout) === digest(current.nativeCheckout))
|
|
78
|
+
return failure.result;
|
|
79
|
+
}
|
|
71
80
|
async ordered(selected, action) {
|
|
72
81
|
const key = this.workspace.context(selected).id, previous = this.tasks.get(key);
|
|
73
82
|
const task = timed('facade.queue', 'research', async () => { await previous?.catch(() => { }); }).then(action);
|
|
@@ -248,12 +257,15 @@ export class Research {
|
|
|
248
257
|
}
|
|
249
258
|
const backend = await this.backend();
|
|
250
259
|
await backend.open(source);
|
|
251
|
-
const
|
|
260
|
+
const sourceView = await backend.saved(source);
|
|
261
|
+
if (sourceView.kind === 'native' && !backend.snapshotFile)
|
|
262
|
+
fail('configuration', 'Selected backend cannot retain an immutable documentation source.');
|
|
263
|
+
const sourceSnapshot = sourceView.kind === 'native' ? await this.workspace.captureSnapshot(await backend.snapshotFile(sourceView)) : sourceView;
|
|
252
264
|
await backend.open(selected);
|
|
253
265
|
if (!backend.transfer || !backend.transferCheck)
|
|
254
266
|
fail('configuration', 'Selected backend cannot verify documentation transfer.');
|
|
255
267
|
const context = this.workspace.context(selected);
|
|
256
|
-
this.workspace.startRequest(request.id, { kind: 'transfer', generation: context.generation, workingSnapshot: context.workingSnapshot, source, sourceSnapshot, dryRun });
|
|
268
|
+
this.workspace.startRequest(request.id, { kind: 'transfer', generation: context.generation, workingSnapshot: context.workingSnapshot, source, sourceView, sourceSnapshot, dryRun });
|
|
257
269
|
try {
|
|
258
270
|
const value = transferResult(await backend.transfer(selected, sourceSnapshot, dryRun), dryRun);
|
|
259
271
|
const snapshot = await backend.saved(selected);
|
|
@@ -495,6 +507,10 @@ export class Research {
|
|
|
495
507
|
state: 'merged', sharedRevision: revision(observed.revision), applied: active.scalars.length + (active.complexChanges?.length ?? Number(active.complex)), pendingChanges: 0 }, observed.snapshot);
|
|
496
508
|
if (observed.state === 'verified' && backend.dropNative)
|
|
497
509
|
await backend.dropNative(active);
|
|
510
|
+
if (observed.state === 'refused')
|
|
511
|
+
this.workspace.finishRefusedPublication(active.id, observed.revision, observed.snapshot, { session: active.session, target: active.target, state: 'conflict', reason: 'shared_changed', applied: 0,
|
|
512
|
+
pendingChanges: active.scalars.length + (active.complexChanges?.length ?? Number(active.complex)),
|
|
513
|
+
conflicts: [{ engine: 'ghidra', message: observed.conflict }], reconciled: true });
|
|
498
514
|
}
|
|
499
515
|
}
|
|
500
516
|
for (const request of this.workspace.unresolved(selected)) {
|
|
@@ -508,7 +524,16 @@ export class Research {
|
|
|
508
524
|
throw error;
|
|
509
525
|
}
|
|
510
526
|
if (!publication) {
|
|
511
|
-
|
|
527
|
+
let empty;
|
|
528
|
+
try {
|
|
529
|
+
empty = await backend.recoverEmptyNative?.(selected, request.id);
|
|
530
|
+
}
|
|
531
|
+
catch (error) {
|
|
532
|
+
const retained = this.retainedDisposal(selected, request.id, error);
|
|
533
|
+
if (!retained)
|
|
534
|
+
throw error;
|
|
535
|
+
continue;
|
|
536
|
+
}
|
|
512
537
|
if (empty?.state === 'verified') {
|
|
513
538
|
const current = this.workspace.context(selected);
|
|
514
539
|
this.workspace.completeSavedRequest(selected, request.id, current.generation, {}, { ...selected, state: 'empty', applied: 0, pendingChanges: 0, sharedRevision: revision(empty.revision), engine: 'ghidra-native' });
|
|
@@ -744,7 +769,7 @@ export class Research {
|
|
|
744
769
|
fail('conflict', 'Native conflict preserves the original working copy and checkout.', result);
|
|
745
770
|
}
|
|
746
771
|
if (update.state === 'empty') {
|
|
747
|
-
await backend.finishEmptyNative(selected);
|
|
772
|
+
await backend.finishEmptyNative(selected, request.id);
|
|
748
773
|
const current = this.workspace.context(selected);
|
|
749
774
|
const result = { ...selected, state: count(context) ? 'merged' : 'empty', applied: 0, pendingChanges: 0, sharedRevision: revision(update.revision), engine: 'ghidra-native' };
|
|
750
775
|
this.workspace.completeSavedRequest(selected, request.id, current.generation, {}, result);
|
|
@@ -771,6 +796,8 @@ export class Research {
|
|
|
771
796
|
catch (error) {
|
|
772
797
|
const state = this.workspace.request(request.id).state;
|
|
773
798
|
if (state !== 'applied' && state !== 'failed') {
|
|
799
|
+
// Proved empty-disposal retention already committed its terminal request atomically above.
|
|
800
|
+
// An uncertain release or any publication still follows the unknown-outcome path below.
|
|
774
801
|
if (publication && ['commit_intent', 'unknown'].includes(this.workspace.publication(publication.id).state))
|
|
775
802
|
this.workspace.unknownPublication(publication.id, { state: 'unknown', engine: 'ghidra-native' });
|
|
776
803
|
this.workspace.recordRequest(request.id, 'unknown', { ...selected, state: 'unknown', engine: 'ghidra-native' });
|