@eyeauras/insight-cli 0.6.4 → 0.7.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 (116) hide show
  1. package/.cli-package-build.json +1 -1
  2. package/SKILL.md +9 -7
  3. package/dist/src/activity-audit.d.ts +123 -0
  4. package/dist/src/activity-audit.js +310 -0
  5. package/dist/src/audit-commands.d.ts +10 -0
  6. package/dist/src/audit-commands.js +85 -0
  7. package/dist/src/audit-retention.d.ts +38 -0
  8. package/dist/src/audit-retention.js +106 -0
  9. package/dist/src/cli.js +11 -3
  10. package/dist/src/contexts.d.ts +29 -8
  11. package/dist/src/contexts.js +455 -90
  12. package/dist/src/cross-peer.d.ts +20 -0
  13. package/dist/src/cross-peer.js +53 -0
  14. package/dist/src/debugger-results.d.ts +2 -1
  15. package/dist/src/debugger-results.js +9 -4
  16. package/dist/src/debugger.js +3 -2
  17. package/dist/src/diagnostic-error.d.ts +12 -0
  18. package/dist/src/diagnostic-error.js +82 -0
  19. package/dist/src/internal-timing.d.ts +8 -2
  20. package/dist/src/internal-timing.js +50 -7
  21. package/dist/src/lifecycle.d.ts +1 -1
  22. package/dist/src/native-merge-patches.js +20 -2
  23. package/dist/src/research.d.ts +11 -3
  24. package/dist/src/research.js +31 -4
  25. package/dist/src/storage-gc.js +429 -196
  26. package/dist/src/tool-runtime/run.js +24 -11
  27. package/dist/src/tool-runtime/supervisor.js +51 -9
  28. package/dist/src/transport.js +19 -10
  29. package/dist/src/workspace.d.ts +45 -1
  30. package/dist/src/workspace.js +135 -7
  31. package/package.json +1 -1
  32. package/references/agent-setup.md +11 -3
  33. package/references/debugger.md +5 -3
  34. package/references/extensions-and-sync.md +7 -6
  35. package/references/managed-runtime.md +4 -3
  36. package/references/native/InsightNativeCheckout.java +174 -15
  37. package/references/native/NATIVE-MERGE-NOTICE.txt +5 -1
  38. package/references/native-workflows.md +5 -3
  39. package/references/query-semantics.md +3 -2
  40. package/references/recovery.md +6 -0
  41. package/references/research.md +33 -2
  42. package/references/setup.md +9 -2
  43. package/skill-bundle/insight-artifacts/SKILL.md +1 -1
  44. package/skill-bundle/insight-artifacts/references/recovery.md +6 -0
  45. package/skill-bundle/insight-binary/SKILL.md +1 -1
  46. package/skill-bundle/insight-capture/SKILL.md +1 -1
  47. package/skill-bundle/insight-cli/SKILL.md +9 -7
  48. package/skill-bundle/insight-cli/references/agent-setup.md +11 -3
  49. package/skill-bundle/insight-cli/references/managed-runtime.md +4 -3
  50. package/skill-bundle/insight-cli/references/recovery.md +6 -0
  51. package/skill-bundle/insight-cli/references/setup.md +9 -2
  52. package/skill-bundle/insight-die/SKILL.md +1 -1
  53. package/skill-bundle/insight-dnspy/SKILL.md +1 -1
  54. package/skill-bundle/insight-dotnet-dump/SKILL.md +1 -1
  55. package/skill-bundle/insight-dotnet-stack/SKILL.md +1 -1
  56. package/skill-bundle/insight-dotnet-trace/SKILL.md +1 -1
  57. package/skill-bundle/insight-frida/SKILL.md +1 -1
  58. package/skill-bundle/insight-ghidra/SKILL.md +4 -3
  59. package/skill-bundle/insight-ghidra/references/debugger.md +5 -3
  60. package/skill-bundle/insight-ghidra/references/extensions-and-sync.md +7 -6
  61. package/skill-bundle/insight-ghidra/references/managed-runtime.md +4 -3
  62. package/skill-bundle/insight-ghidra/references/native-workflows.md +5 -3
  63. package/skill-bundle/insight-ghidra/references/query-semantics.md +3 -2
  64. package/skill-bundle/insight-ghidra/references/recovery.md +6 -0
  65. package/skill-bundle/insight-ghidra/references/research.md +33 -2
  66. package/skill-bundle/insight-ghidra/references/setup.md +9 -2
  67. package/skill-bundle/insight-ilspy/SKILL.md +1 -1
  68. package/skill-bundle/insight-interop/SKILL.md +1 -1
  69. package/skill-bundle/insight-lldb/SKILL.md +1 -1
  70. package/skill-bundle/insight-llvm/SKILL.md +1 -1
  71. package/skill-bundle/insight-managed-heap/SKILL.md +1 -1
  72. package/skill-bundle/insight-managed-metadata/SKILL.md +1 -1
  73. package/skill-bundle/insight-mitmproxy/SKILL.md +1 -1
  74. package/skill-bundle/insight-overview/SKILL.md +1 -1
  75. package/skill-bundle/insight-procmon/SKILL.md +1 -1
  76. package/skill-bundle/insight-re/SKILL.md +7 -1
  77. package/skill-bundle/insight-re/references/recovery.md +6 -0
  78. package/skill-bundle/insight-sevenzip/SKILL.md +1 -1
  79. package/skill-bundle/insight-strace/SKILL.md +1 -1
  80. package/skill-bundle/insight-tshark/SKILL.md +1 -1
  81. package/skill-bundle/insight-windbg/SKILL.md +1 -1
  82. package/skill-bundle/manifest.json +1 -1
  83. package/skills/insight-artifacts/SKILL.md +1 -1
  84. package/skills/insight-artifacts/references/recovery.md +6 -0
  85. package/skills/insight-binary/SKILL.md +1 -1
  86. package/skills/insight-capture/SKILL.md +1 -1
  87. package/skills/insight-die/SKILL.md +1 -1
  88. package/skills/insight-dnspy/SKILL.md +1 -1
  89. package/skills/insight-dotnet-dump/SKILL.md +1 -1
  90. package/skills/insight-dotnet-stack/SKILL.md +1 -1
  91. package/skills/insight-dotnet-trace/SKILL.md +1 -1
  92. package/skills/insight-frida/SKILL.md +1 -1
  93. package/skills/insight-ghidra/SKILL.md +4 -3
  94. package/skills/insight-ghidra/references/debugger.md +5 -3
  95. package/skills/insight-ghidra/references/extensions-and-sync.md +7 -6
  96. package/skills/insight-ghidra/references/managed-runtime.md +4 -3
  97. package/skills/insight-ghidra/references/native-workflows.md +5 -3
  98. package/skills/insight-ghidra/references/query-semantics.md +3 -2
  99. package/skills/insight-ghidra/references/recovery.md +6 -0
  100. package/skills/insight-ghidra/references/research.md +33 -2
  101. package/skills/insight-ghidra/references/setup.md +9 -2
  102. package/skills/insight-ilspy/SKILL.md +1 -1
  103. package/skills/insight-interop/SKILL.md +1 -1
  104. package/skills/insight-lldb/SKILL.md +1 -1
  105. package/skills/insight-llvm/SKILL.md +1 -1
  106. package/skills/insight-managed-heap/SKILL.md +1 -1
  107. package/skills/insight-managed-metadata/SKILL.md +1 -1
  108. package/skills/insight-mitmproxy/SKILL.md +1 -1
  109. package/skills/insight-overview/SKILL.md +1 -1
  110. package/skills/insight-procmon/SKILL.md +1 -1
  111. package/skills/insight-re/SKILL.md +7 -1
  112. package/skills/insight-re/references/recovery.md +6 -0
  113. package/skills/insight-sevenzip/SKILL.md +1 -1
  114. package/skills/insight-strace/SKILL.md +1 -1
  115. package/skills/insight-tshark/SKILL.md +1 -1
  116. package/skills/insight-windbg/SKILL.md +1 -1
@@ -0,0 +1,106 @@
1
+ import { CliError } from '@eyeauras/cli-factory';
2
+ export const auditLimits = { events: 20000, days: 30, eventBytes: 4096, databaseBytes: 16 * 1024 * 1024, sweepIntervalMs: 5 * 60000 };
3
+ export function auditUnavailable() { throw new CliError('Audit history is unavailable or incompatible; preserve its files. No history was reset.', { code: 'audit.unavailable' }); }
4
+ export function auditPolicy(input) {
5
+ const policy = { events: input.events, days: input.days, databaseBytes: input.databaseBytes ?? auditLimits.databaseBytes };
6
+ if (!Number.isSafeInteger(policy.events) || policy.events < 4 || policy.events > auditLimits.events || !Number.isSafeInteger(policy.days) || policy.days < 1 || policy.days > auditLimits.days || !Number.isSafeInteger(policy.databaseBytes) || policy.databaseBytes < 256 * 1024 || policy.databaseBytes > auditLimits.databaseBytes)
7
+ auditUnavailable();
8
+ return policy;
9
+ }
10
+ const keys = ['retentionEvents', 'retentionDays', 'retentionBytes', 'lastSweepMs', 'gcRuns', 'lastGcRemoved'];
11
+ function set(db, key, value) { if (!Number.isSafeInteger(value) || value < 0)
12
+ auditUnavailable(); db.prepare('INSERT OR REPLACE INTO metadata(key,value) VALUES(?,?)').run(key, String(value)); }
13
+ /** Called only in the owned schema initialization/upgrade transaction. Never overwrite unknown metadata. */
14
+ export function initializeRetention(db, policy, now) {
15
+ for (const key of keys)
16
+ if (db.prepare('SELECT value FROM metadata WHERE key=?').get(key))
17
+ auditUnavailable();
18
+ db.exec("ALTER TABLE events ADD COLUMN writer_version INTEGER NOT NULL DEFAULT 1; CREATE TRIGGER audit_writer_v2 BEFORE INSERT ON events WHEN NEW.writer_version IS NOT 2 BEGIN SELECT RAISE(ABORT,'Incompatible audit writer'); END;");
19
+ for (const [key, value] of Object.entries({ retentionEvents: policy.events, retentionDays: policy.days, retentionBytes: policy.databaseBytes, lastSweepMs: now, gcRuns: 0, lastGcRemoved: 0 }))
20
+ set(db, key, value);
21
+ db.exec('PRAGMA user_version=2');
22
+ }
23
+ export function retentionState(db) {
24
+ if (!db.prepare("SELECT name FROM sqlite_master WHERE type='trigger' AND name='audit_writer_v2'").get())
25
+ auditUnavailable();
26
+ const rows = db.prepare("SELECT key,value FROM metadata WHERE key IN ('retentionEvents','retentionDays','retentionBytes','lastSweepMs','gcRuns','lastGcRemoved')").all(), values = {};
27
+ for (const row of rows) {
28
+ if (typeof row.key !== 'string' || typeof row.value !== 'string' || !/^\d+$/.test(row.value) || !Number.isSafeInteger(Number(row.value)))
29
+ auditUnavailable();
30
+ values[row.key] = Number(row.value);
31
+ }
32
+ if (keys.some(key => values[key] === undefined))
33
+ auditUnavailable();
34
+ return { policy: auditPolicy({ events: values.retentionEvents, days: values.retentionDays, databaseBytes: values.retentionBytes }), lastSweepMs: values.lastSweepMs, runs: values.gcRuns, lastRemoved: values.lastGcRemoved };
35
+ }
36
+ export function auditStorageMode(db) { return { autoVacuum: Number(db.prepare('PRAGMA auto_vacuum').get()?.auto_vacuum), journalMode: String(db.prepare('PRAGMA journal_mode').get()?.journal_mode) }; }
37
+ export function requireAuditStorageMode(db) { const mode = auditStorageMode(db); if (mode.autoVacuum !== 1 || mode.journalMode !== 'delete')
38
+ auditUnavailable(); }
39
+ const writerWait = new Int32Array(new SharedArrayBuffer(4));
40
+ /** Retry only a definitely unacquired auxiliary DB lock, never INSERT, COMMIT or a tool action. */
41
+ export function acquireAuditWriter(db) {
42
+ const deadline = performance.now() + 3000;
43
+ let attempt = 0;
44
+ try {
45
+ for (;;) {
46
+ const remaining = deadline - performance.now();
47
+ db.exec('PRAGMA busy_timeout=' + Math.max(0, Math.min(50, Math.ceil(remaining))));
48
+ try {
49
+ db.exec('BEGIN IMMEDIATE');
50
+ return;
51
+ }
52
+ catch (error) {
53
+ let busy = false;
54
+ try {
55
+ const e = error;
56
+ busy = e?.code === 'ERR_SQLITE_ERROR' && typeof e.errcode === 'number' && Number.isSafeInteger(e.errcode) && e.errcode > 0 && [5, 6].includes(e.errcode & 255);
57
+ }
58
+ catch { }
59
+ if (!busy || performance.now() >= deadline)
60
+ throw error;
61
+ // SQLite's long busy-handler backoff can repeatedly miss short free intervals.
62
+ // Restart it with a bounded jitter so a continuous producer cannot monopolize admission.
63
+ Atomics.wait(writerWait, 0, 0, Math.max(0, Math.min(5 + (process.pid + attempt++ * 13) % 21, deadline - performance.now())));
64
+ }
65
+ }
66
+ }
67
+ finally {
68
+ db.exec('PRAGMA busy_timeout=3000');
69
+ }
70
+ }
71
+ export function liveAuditBytes(db) { return (Number(db.prepare('PRAGMA page_count').get()?.page_count) - Number(db.prepare('PRAGMA freelist_count').get()?.freelist_count)) * Number(db.prepare('PRAGMA page_size').get()?.page_size); }
72
+ function count(db) { return Number(db.prepare('SELECT count(*) count FROM events').get().count); }
73
+ /** The caller holds BEGIN IMMEDIATE. Summary insertion is direct, never another append/GC call. */
74
+ export function collectAudit(db, now, incoming, pruned, state, summary) {
75
+ const policy = state.policy, eventsBefore = count(db), liveBytesBefore = liveAuditBytes(db), periodic = now < state.lastSweepMs || now - state.lastSweepMs >= auditLimits.sweepIntervalMs;
76
+ const reserve = 128 * 1024, eventPressure = eventsBefore > policy.events || periodic && eventsBefore + 1 > policy.events, bytePressure = liveBytesBefore > policy.databaseBytes || periodic && liveBytesBefore + reserve > policy.databaseBytes;
77
+ if (!periodic && !eventPressure && !bytePressure)
78
+ return;
79
+ const expiredEvents = Number(db.prepare('DELETE FROM events WHERE at_ms<? AND seq<>?').run(now - policy.days * 86400000, incoming).changes);
80
+ let removed = expiredEvents;
81
+ const targetEvents = Math.max(2, Math.floor(policy.events * 0.8));
82
+ const drop = (n) => Number(db.prepare('DELETE FROM events WHERE seq IN (SELECT seq FROM events WHERE seq<>? ORDER BY seq LIMIT ?)').run(incoming, n).changes);
83
+ if (eventPressure)
84
+ removed += drop(Math.max(0, count(db) - (targetEvents - 1))); // reserve the GC record itself
85
+ const trimBytes = bytePressure || liveAuditBytes(db) + reserve > policy.databaseBytes;
86
+ if (trimBytes) {
87
+ const targetBytes = Math.min(Math.floor(policy.databaseBytes * 0.75), policy.databaseBytes - reserve);
88
+ while (liveAuditBytes(db) > targetBytes) {
89
+ const changed = drop(Math.max(1, Math.ceil(count(db) * 0.1)));
90
+ if (!changed)
91
+ auditUnavailable();
92
+ removed += changed;
93
+ }
94
+ }
95
+ // Account for the maintenance event even if the original pressure was only age.
96
+ if (count(db) + 1 > policy.events)
97
+ removed += drop(Math.max(0, count(db) - (targetEvents - 1)));
98
+ const eventsAfter = count(db) + 1, liveBytesAfterPrune = liveAuditBytes(db);
99
+ set(db, 'prunedEvents', pruned + removed);
100
+ set(db, 'lastSweepMs', now);
101
+ set(db, 'gcRuns', state.runs + 1);
102
+ set(db, 'lastGcRemoved', removed);
103
+ summary({ automatic: true, state: 'complete', outcome: 'success', gcTrigger: eventPressure && trimBytes ? 'multiple' : eventPressure ? 'event-limit' : trimBytes ? 'byte-limit' : 'periodic', removedEvents: removed, expiredEvents, eventsBefore, eventsAfter, liveBytesBefore, liveBytesAfterPrune });
104
+ if (count(db) > policy.events || liveAuditBytes(db) > policy.databaseBytes)
105
+ auditUnavailable();
106
+ }
package/dist/src/cli.js CHANGED
@@ -57,6 +57,7 @@ import { codeReferenceCommands } from './code-references.js';
57
57
  import { stringAnchorCommands } from './string-anchors.js';
58
58
  import { contextDiagnosticCommands } from './context-diagnostics.js';
59
59
  import { traceCommand } from './internal-timing.js';
60
+ import { ActivityAudit } from './audit-commands.js';
60
61
  import { timedBackend } from './timed-backend.js';
61
62
  import { readInitialProgress } from './initial-progress.js';
62
63
  const bindingFields = ['java', 'ghidraHome', 'mcpJar', 'mcpJarSha256', 'server', 'repository', 'readerUser', 'publisherUser', 'maxContexts', 'debuggerPython', 'windbgDir', 'archiveUrl'];
@@ -328,13 +329,15 @@ function scopedFailures(entry, owner, parents = []) {
328
329
  catch {
329
330
  throw error;
330
331
  }
332
+ if (selected.session === 'new')
333
+ throw error;
331
334
  if (!(error instanceof CliError))
332
335
  throw error;
333
336
  const result = error.result && typeof error.result === 'object' && !Array.isArray(error.result) ? error.result : {};
334
337
  throw new CliError(error.message, { code: error.code, exitCode: error.exitCode, next: error.next, result: { ...result, ...selected } });
335
338
  }
336
339
  };
337
- return path[1] === 'open' || input.options.session && input.options.target ? traceCommand(join(analysisDirectory(c), 'workspace'), name, execute) : execute();
340
+ return path[1] === 'open' || input.options.session && input.options.target ? traceCommand(join(analysisDirectory(c), 'workspace'), name, execute, { session: input.options.session, target: input.options.target }) : execute();
338
341
  } } : {}) };
339
342
  }
340
343
  export function createDefinition(options = {}) {
@@ -462,7 +465,7 @@ export function createDefinition(options = {}) {
462
465
  }, { permission: Permission.Update, options: [{ flags: '--initial-import-seconds <seconds>', description: 'Initial import/analysis: 1–86400 seconds' },
463
466
  { flags: '--save-seconds <seconds>', description: 'Native save/export: 1–3600 seconds' }] })
464
467
  ]),
465
- command('abandon', 'Retain an uncertain program attempt and resume its previous saved view', ({ options: o }, c) => owner.selected(c).research.abandon(scope(o), id(o.requestId), Boolean(o.acknowledgeUnknownEffects)), { permission: 'Destructive', options: [...scoped, { flags: '--request-id <id>', description: 'Original unresolved request ID from sessions status', required: true }, { flags: '--acknowledge-unknown-effects', description: 'Acknowledge that the abandoned effect remains unknown; no script is replayed' }] }),
468
+ command('abandon', 'Retain an uncertain legacy detached program attempt and resume its previous saved view', ({ options: o }, c) => owner.selected(c).research.abandon(scope(o), id(o.requestId), Boolean(o.acknowledgeUnknownEffects)), { permission: 'Destructive', options: [...scoped, { flags: '--request-id <id>', description: 'Original unresolved request ID from sessions status', required: true }, { flags: '--acknowledge-unknown-effects', description: 'Acknowledge that the abandoned effect remains unknown; no script is replayed' }] }),
466
469
  command('refresh', 'Receive safe shared changes while retaining local conflicts', ({ options: o }, c) => owner.selected(c).research.refresh(scope(o), o.requestId === undefined ? undefined : id(o.requestId)), { permission: Permission.Update, options: [...scoped, request] }),
467
470
  command('merge', 'Publish the complete selected context or retain every conflict', ({ options: o }, c) => owner.selected(c).research.merge(scope(o), o.requestId === undefined ? undefined : id(o.requestId)), { permission: Permission.Update, options: [...scoped, request] }),
468
471
  command('open [input]', 'Start independent work or continue a context', async ({ args, options: o }, c) => {
@@ -581,6 +584,11 @@ export function createDefinition(options = {}) {
581
584
  const commands = definition.commands?.map(entry => entry.name === 'ghidra' ?
582
585
  scopedFailures({ ...entry, children: extendQueries(extendQueries(extendQueries(entry.children ?? [], queryCommands(c => owner.selected(c).research)), mutationCommands(c => owner.selected(c).research)), [...codeReferenceCommands(c => owner.selected(c).research), ...stringAnchorCommands(c => owner.selected(c).research), ...contextDiagnosticCommands(c => owner.selected(c).research, c => owner.selected(c).workspace), ...sdkCommands(c => owner.selected(c).research), ...sdkFileCommands(c => owner.selected(c).sdkFiles), ...trackingCommands(c => owner.selected(c).tracking), ...crossCommands(c => owner.selected(c).research), ...administrationCommands(c => owner.selected(c).administration, options.backend ? undefined : async (c) => { const status = await new RuntimeManager(c).status(); return status.state === 'not_ready' ? { ...status.server, connected: false, state: 'runtime_not_ready', missing: status.missing } : undefined; }),
583
586
  ...extensionCommands(c => new Extensions(join(analysisDirectory(c), 'workspace'))), ...extensionInventoryCommands(c => owner.selected(c).backend), ...pluginCommands(c => owner.selected(c).ui), ...synchronizationCommands(c => owner.selected(c).synchronization), ...utilityCommands(), ...runtimeCommands((c, action, quiescent) => owner.runtime(c, action, quiescent)), ...lifecycleCommands(c => owner.selected(c).lifecycle, c => new RuntimeManager(c).status()), ...projectCommands(c => owner.selected(c).projects), ...uiCommands(c => owner.selected(c).ui), ...debuggerCommands(c => owner.selected(c).debugger), ...archiveCommands(c => owner.selected(c).archive)]) }, owner) : entry);
584
- return { ...definition, commands: [...(commands ?? []).map(e => storage.wrap(e)), storage.commands()] };
587
+ const audit = new ActivityAudit(), auth = definition.auth;
588
+ return { ...definition, auth: { ...auth,
589
+ login: (c, o) => audit.run(c, 'auth login', { args: {}, options: {} }, () => auth.login(c, o)),
590
+ status: c => audit.run(c, 'auth status', { args: {}, options: {} }, () => auth.status(c)),
591
+ logout: c => audit.run(c, 'auth logout', { args: {}, options: {} }, () => auth.logout(c)),
592
+ }, commands: [...[...(commands ?? []).map(e => storage.wrap(e)), storage.commands()].map(e => audit.wrap(e)), audit.commands()] };
585
593
  }
586
594
  export const createInsightCli = (options = {}) => createCli(createDefinition(options));
@@ -86,6 +86,14 @@ export declare class GhidraContexts {
86
86
  private initialModel;
87
87
  private model;
88
88
  private privateCopy;
89
+ private pristineNative;
90
+ /** A completed discard replaces its checkout inside the same root, retaining its process and backup receipts. */
91
+ private discardedPristine;
92
+ /**
93
+ * Opening a checkout lets Ghidra rewrite its saved buffers before any caller runs. A proved pristine initial or
94
+ * replacement checkout captures those bytes as its new receipt and a no-work state of that shared version.
95
+ */
96
+ private recordOpened;
89
97
  private createNative;
90
98
  updateNative(scope: Scope, request: string): Promise<{
91
99
  state: "conflict";
@@ -137,11 +145,13 @@ export declare class GhidraContexts {
137
145
  applied?: undefined;
138
146
  conflict?: undefined;
139
147
  }>;
140
- dropNative(scope: Scope): Promise<void>;
141
- finishEmptyNative(scope: Scope): Promise<void>;
148
+ dropNative(scope: Scope, request?: string): Promise<void>;
149
+ /** A lost release reply can mean undoCheckout succeeded. Only independent ownership readback permits reopening. */
150
+ private retainNative;
151
+ finishEmptyNative(scope: Scope, request?: string): Promise<void>;
142
152
  /** Close and GC drop a working copy only when Ghidra itself reports no private change. */
143
153
  releaseUnchanged(scope: Scope): Promise<boolean>;
144
- /** A missing current receipt means no worker was ever started; any other missing receipt is unproved. */
154
+ /** Absence of the ready receipt alone says nothing about an interrupted first start. */
145
155
  private neverStartedOrClosed;
146
156
  /** A pending checkout intent may own a server checkout, so it is never treated as detached work. */
147
157
  detachedStopped(scope: Scope): Promise<boolean>;
@@ -178,6 +188,7 @@ export declare class GhidraContexts {
178
188
  retainedKeepFile: string;
179
189
  state: "verified";
180
190
  }>;
191
+ private nativeKeepName;
181
192
  private applyNativeDiscard;
182
193
  open(scope: Scope, request?: string): Promise<GhidraContext>;
183
194
  private retireUnresponsive;
@@ -203,6 +214,7 @@ export declare class GhidraContexts {
203
214
  snapshotFile(snapshot: Artifact): Promise<string>;
204
215
  private removePeer;
205
216
  private reconcilePeers;
217
+ private completePeer;
206
218
  private withPeer;
207
219
  pair(selected: Scope, other: Scope, snapshot: Artifact, operation: string, parameters: Record<string, unknown>): Promise<unknown>;
208
220
  transfer(selected: Scope, source: Artifact, dryRun: boolean): Promise<unknown>;
@@ -221,13 +233,15 @@ export declare class GhidraContexts {
221
233
  debuggerSelect(scope: Scope, trace: string): Promise<void>;
222
234
  debuggerLaunch(scope: Scope, p: Record<string, unknown>, request: string): Promise<unknown>;
223
235
  projectOutcome(requestId: string, expected: Record<string, unknown>): Promise<Record<string, unknown> | undefined>;
236
+ debuggerMetadata(snapshot: Artifact): Promise<string>;
224
237
  private debuggerMetadataChanges;
225
238
  close(scope: Scope): Promise<void>;
226
- /**
227
- * The worker that last used a context root. A start records process.json first and current.json only once its
228
- * program is open, so a failed start leaves an older current receipt. It is superseded only by a receipt of the
229
- * same context and root, and only after the older worker is proved gone.
230
- */
239
+ private workerEnded;
240
+ private retainStartedWorker;
241
+ private workerShape;
242
+ private workerReceipt;
243
+ /** Discover interrupted starts independently of the ready pointer. Every other retained root must
244
+ * be verifiably ended; no live or ambiguous start is adopted or overwritten by a replacement. */
231
245
  private lastWorker;
232
246
  closed(scope: Scope): Promise<boolean>;
233
247
  latest(targetId: string): Promise<{
@@ -246,9 +260,16 @@ export declare class GhidraContexts {
246
260
  state: 'verified';
247
261
  revision: number;
248
262
  snapshot: Artifact;
263
+ } | {
264
+ state: 'refused';
265
+ revision: number;
266
+ snapshot: Artifact;
267
+ conflict: string;
249
268
  } | {
250
269
  state: 'unknown';
251
270
  }>;
271
+ /** Only the completed head-race branch before checkin() has this journal shape. */
272
+ private recoverNativeRefusal;
252
273
  recoverModel(targetId: string): Promise<boolean>;
253
274
  dispose(): Promise<void>;
254
275
  private inventory;