@eyeauras/insight-cli 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cli-package-build.json +1 -1
- package/SKILL.md +1 -1
- package/dist/src/activity-audit.d.ts +7 -0
- package/dist/src/activity-audit.js +14 -4
- package/dist/src/analysis-storage.d.ts +5 -1
- package/dist/src/analysis-storage.js +9 -2
- package/dist/src/audit-retention.d.ts +8 -2
- package/dist/src/audit-retention.js +68 -7
- package/dist/src/cli.js +21 -5
- package/dist/src/context-diagnostics.d.ts +1 -1
- package/dist/src/context-diagnostics.js +10 -2
- package/dist/src/contexts.d.ts +118 -10
- package/dist/src/contexts.js +851 -199
- package/dist/src/debugger.js +2 -1
- package/dist/src/diagnostic-error.js +1 -1
- package/dist/src/inline-script.js +3 -4
- package/dist/src/lifecycle.d.ts +11 -0
- package/dist/src/lifecycle.js +34 -6
- package/dist/src/native-inputs.d.ts +6 -0
- package/dist/src/native-inputs.js +30 -6
- package/dist/src/native-queries.js +1 -6
- package/dist/src/native-service.d.ts +40 -0
- package/dist/src/native-service.js +406 -0
- package/dist/src/research.d.ts +29 -1
- package/dist/src/research.js +106 -27
- package/dist/src/server.d.ts +38 -1
- package/dist/src/server.js +160 -12
- package/dist/src/storage-gc.js +1 -1
- package/dist/src/sync-policy.js +2 -1
- package/dist/src/timed-backend.js +8 -0
- package/dist/src/timing-report.d.ts +32 -0
- package/dist/src/timing-report.js +74 -0
- package/dist/src/tool-runtime/identity.js +86 -1
- package/dist/src/tool-runtime/supervisor.js +6 -5
- package/dist/src/transport.d.ts +35 -0
- package/dist/src/transport.js +77 -7
- package/dist/src/unresolved-guidance.d.ts +46 -0
- package/dist/src/unresolved-guidance.js +55 -0
- package/dist/src/windbg.d.ts +1 -1
- package/dist/src/work/backup.d.ts +66 -0
- package/dist/src/work/backup.js +434 -0
- package/dist/src/work/commands.d.ts +5 -0
- package/dist/src/work/commands.js +277 -0
- package/dist/src/work/dashboard.d.ts +12 -0
- package/dist/src/work/dashboard.js +103 -0
- package/dist/src/work/model.d.ts +131 -0
- package/dist/src/work/model.js +124 -0
- package/dist/src/work/store.d.ts +368 -0
- package/dist/src/work/store.js +1050 -0
- package/dist/src/work/timing.d.ts +26 -0
- package/dist/src/work/timing.js +80 -0
- package/dist/src/worker-lease.d.ts +17 -0
- package/dist/src/worker-lease.js +50 -0
- package/dist/src/workspace.d.ts +5 -9
- package/dist/src/workspace.js +20 -41
- package/package.json +1 -1
- package/references/native/InsightHeadlessMain.java +9 -2
- package/references/native/InsightNativeCheckout.java +113 -43
- package/references/native/InsightNativeFingerprint.java +28 -1
- package/references/native/InsightNativeRead.java +32 -9
- package/references/native/InsightNativeService.java +43 -0
- package/references/native/InsightNativeView.java +17 -6
- package/references/native/InsightOwnedScripts.java +170 -0
- package/references/native/InsightWorkerLease.java +132 -0
- package/references/recovery.md +68 -3
- package/references/research.md +38 -4
- package/references/setup.md +5 -1
- package/references/work-tracking.md +203 -0
- package/runtime/toolbox.json +1 -0
- package/skill-bundle/insight-artifacts/SKILL.md +1 -1
- package/skill-bundle/insight-artifacts/references/recovery.md +68 -3
- 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 +1 -1
- package/skill-bundle/insight-cli/references/recovery.md +68 -3
- package/skill-bundle/insight-cli/references/setup.md +5 -1
- 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 +1 -1
- package/skill-bundle/insight-ghidra/references/recovery.md +68 -3
- package/skill-bundle/insight-ghidra/references/research.md +38 -4
- package/skill-bundle/insight-ghidra/references/setup.md +5 -1
- 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 +5 -1
- package/skill-bundle/insight-re/references/recovery.md +68 -3
- package/skill-bundle/insight-re/references/work-tracking.md +203 -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 +68 -3
- 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 +1 -1
- package/skills/insight-ghidra/references/recovery.md +68 -3
- package/skills/insight-ghidra/references/research.md +38 -4
- package/skills/insight-ghidra/references/setup.md +5 -1
- 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 +5 -1
- package/skills/insight-re/references/recovery.md +68 -3
- package/skills/insight-re/references/work-tracking.md +203 -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,124 @@
|
|
|
1
|
+
import { CliError } from '@eyeauras/cli-factory';
|
|
2
|
+
import { digest, stable } from '../model.js';
|
|
3
|
+
export { digest, stable };
|
|
4
|
+
export function fail(code, message, result) {
|
|
5
|
+
throw new CliError(message, { code: 'work.' + code, ...(result === undefined ? {} : { result }) });
|
|
6
|
+
}
|
|
7
|
+
export function string(value, max = 512) {
|
|
8
|
+
if (typeof value !== 'string' || !value.trim() || value.length > max || /[\u0000-\u001f]/.test(value))
|
|
9
|
+
fail('invalid', 'Expected a bounded non-empty single-line string.');
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
export function identifier(value) {
|
|
13
|
+
const result = string(value, 128);
|
|
14
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/.test(result))
|
|
15
|
+
fail('invalid', 'Malformed work/project/worker ID.');
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
export function integer(value, min, max) {
|
|
19
|
+
if (typeof value !== 'number' && (typeof value !== 'string' || !value.trim()))
|
|
20
|
+
fail('invalid', 'Expected a number.');
|
|
21
|
+
const n = Number(value);
|
|
22
|
+
if (!Number.isSafeInteger(n) || n < min || n > max)
|
|
23
|
+
fail('invalid', `Expected integer ${min}..${max}.`);
|
|
24
|
+
return n;
|
|
25
|
+
}
|
|
26
|
+
export function object(value) {
|
|
27
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
28
|
+
fail('invalid', 'Expected a JSON object.');
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
export function array(value, max) {
|
|
32
|
+
if (!Array.isArray(value) || value.length > max)
|
|
33
|
+
fail('invalid', `Expected an array of at most ${max} entries.`);
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
/** A caller label may have outcomes from several restored incarnations. Never choose one silently. */
|
|
37
|
+
export function archivedOutcomes(value) {
|
|
38
|
+
const record = object(value);
|
|
39
|
+
if (record.kind !== 'request-history-set')
|
|
40
|
+
return [record];
|
|
41
|
+
const records = array(record.histories, 100_000_000).map(object);
|
|
42
|
+
if (!records.length || records.some(row => row.kind === 'request-history-set'))
|
|
43
|
+
fail('backup', 'Malformed historical request set.');
|
|
44
|
+
return records;
|
|
45
|
+
}
|
|
46
|
+
export function sha(value) {
|
|
47
|
+
const result = string(value, 64).toLowerCase();
|
|
48
|
+
if (!/^[a-f0-9]{64}$/.test(result))
|
|
49
|
+
fail('invalid', 'Expected a full SHA-256.');
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
export function rva(value) {
|
|
53
|
+
if (typeof value === 'string' && !/^0x[0-9a-f]+$/i.test(value))
|
|
54
|
+
fail('invalid', 'String RVAs require 0x-prefixed hexadecimal.');
|
|
55
|
+
return integer(value, 0, 0xffffffff);
|
|
56
|
+
}
|
|
57
|
+
export function functionIdentity(binarySha, at) {
|
|
58
|
+
return `fn:${binarySha}:${at.toString(16).padStart(8, '0')}`;
|
|
59
|
+
}
|
|
60
|
+
export function definition(value, binarySha) {
|
|
61
|
+
const entry = object(value), at = rva(entry.rva), risk = entry.risk ?? 'unknown';
|
|
62
|
+
if (!['normal', 'high', 'unknown'].includes(String(risk)))
|
|
63
|
+
fail('invalid', 'Unknown risk classification.');
|
|
64
|
+
const resources = array(entry.resources ?? [], 64).map(x => string(x, 256));
|
|
65
|
+
if (resources.some(x => !/^[-a-zA-Z0-9_:.\/]+$/.test(x)))
|
|
66
|
+
fail('invalid', 'Malformed ownership resource key.');
|
|
67
|
+
return { id: functionIdentity(binarySha, at), rva: at, name: string(entry.name), risk: risk,
|
|
68
|
+
resources: [...new Set(resources)].sort(), stage: 'discovered', version: 1,
|
|
69
|
+
definition: { ...entry, rva: at }, accepted1to1: false };
|
|
70
|
+
}
|
|
71
|
+
export const passportTextFields = ['signature', 'abi', 'inputs', 'outputs', 'memoryEffects', 'errors', 'threading', 'nondeterminism', 'recheck'];
|
|
72
|
+
export const passportListFields = ['unknowns', 'dependencies', 'observations', 'inferences', 'rejectedIdeas'];
|
|
73
|
+
/** Validates a passport and names the failing field path, e.g. functions[2].contract.inputs. */
|
|
74
|
+
export function passport(value, at = 'contract') {
|
|
75
|
+
const result = object(value);
|
|
76
|
+
const check = (field, expected, action) => {
|
|
77
|
+
try {
|
|
78
|
+
action();
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
fail('invalid', `Passport field ${field} must be ${expected}.`, { field, expected, textFields: passportTextFields, listFields: passportListFields });
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
for (const key of passportTextFields)
|
|
85
|
+
check(`${at}.${key}`, 'a non-empty single-line string of at most 8000 characters (not an array)', () => string(result[key], 8000));
|
|
86
|
+
for (const key of passportListFields) {
|
|
87
|
+
check(`${at}.${key}`, 'an array of at most 200 strings', () => array(result[key], 200));
|
|
88
|
+
result[key].forEach((x, i) => check(`${at}.${key}[${i}]`, 'a non-empty single-line string of at most 4000 characters', () => string(x, 4000)));
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
/** Derived review status of the current package: none, approved, rejected or stale (review of an older
|
|
93
|
+
* source, or a package retained under an older definition revision after `revise-definition`). */
|
|
94
|
+
export function reviewState(fn) {
|
|
95
|
+
if (!fn.review)
|
|
96
|
+
return 'none';
|
|
97
|
+
if (fn.reviewRequired || fn.invalidated)
|
|
98
|
+
return 'stale';
|
|
99
|
+
if (!fn.source || fn.review.sourceSha256 !== fn.source.sha256)
|
|
100
|
+
return 'stale';
|
|
101
|
+
if (fn.review.contractSha256 !== undefined && fn.review.contractSha256 !== fn.contract?.sha256)
|
|
102
|
+
return 'stale';
|
|
103
|
+
if (typeof fn.definitionRevision === 'number' && typeof fn.packageDefinitionRevision === 'number' && fn.packageDefinitionRevision < fn.definitionRevision)
|
|
104
|
+
return 'stale';
|
|
105
|
+
return fn.review.approved === true ? 'approved' : 'rejected';
|
|
106
|
+
}
|
|
107
|
+
/** Opaque convenience handle for one lease: task, worker, fence and epoch. Not a secret or authentication. */
|
|
108
|
+
export function leaseToken(task) {
|
|
109
|
+
return 'wl1.' + Buffer.from(stable({ t: task.id, w: task.worker, f: task.fence, e: task.epoch })).toString('base64url');
|
|
110
|
+
}
|
|
111
|
+
export function parseLease(value) {
|
|
112
|
+
const text = string(value, 1024);
|
|
113
|
+
if (!text.startsWith('wl1.'))
|
|
114
|
+
fail('invalid', 'Lease token must come from work claim or work next.');
|
|
115
|
+
let raw;
|
|
116
|
+
try {
|
|
117
|
+
raw = JSON.parse(Buffer.from(text.slice(4), 'base64url').toString('utf8'));
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
fail('invalid', 'Malformed lease token.');
|
|
121
|
+
}
|
|
122
|
+
const r = object(raw);
|
|
123
|
+
return { task: identifier(r.t), worker: identifier(r.w), fence: integer(r.f, 1, Number.MAX_SAFE_INTEGER), ...(r.e === undefined ? {} : { epoch: identifier(r.e) }) };
|
|
124
|
+
}
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import { type Workspace } from '../workspace.js';
|
|
3
|
+
import { type Attachment, type Project, type Snapshot, type Task, type WorkFunction } from './model.js';
|
|
4
|
+
export declare const workTableColumns: {
|
|
5
|
+
readonly projects: readonly ["id", "data"];
|
|
6
|
+
readonly functions: readonly ["project", "id", "rva", "stage", "data"];
|
|
7
|
+
readonly tasks: readonly ["id", "project", "status", "data"];
|
|
8
|
+
readonly locks: readonly ["project", "resource", "task"];
|
|
9
|
+
readonly events: readonly ["seq", "project", "revision", "kind", "data"];
|
|
10
|
+
readonly receipts: readonly ["id", "result"];
|
|
11
|
+
readonly graph_nodes: readonly ["project", "id", "data"];
|
|
12
|
+
readonly graph_edges: readonly ["project", "id", "data"];
|
|
13
|
+
readonly function_versions: readonly ["project", "id", "version", "data", "reason", "at", "request"];
|
|
14
|
+
readonly archived_requests: readonly ["caller_id", "data"];
|
|
15
|
+
readonly function_resources: readonly ["project", "function_id", "resource", "evidence_edge"];
|
|
16
|
+
};
|
|
17
|
+
/** Edge kinds whose source exclusively reserves the target; everything else is a read dependency. */
|
|
18
|
+
export declare const exclusiveEdgeKinds: string[];
|
|
19
|
+
export declare const workSchema = "\n PRAGMA busy_timeout=5000; PRAGMA journal_mode=WAL; PRAGMA synchronous=FULL; PRAGMA foreign_keys=ON;\n CREATE TABLE IF NOT EXISTS projects(id TEXT PRIMARY KEY,data TEXT NOT NULL);\n CREATE TABLE IF NOT EXISTS functions(project TEXT NOT NULL REFERENCES projects(id),id TEXT NOT NULL,\n rva INTEGER NOT NULL,stage TEXT NOT NULL,data TEXT NOT NULL,PRIMARY KEY(project,id));\n CREATE INDEX IF NOT EXISTS function_frontier ON functions(project,stage,rva);\n CREATE TABLE IF NOT EXISTS tasks(id TEXT PRIMARY KEY,project TEXT NOT NULL REFERENCES projects(id),\n status TEXT NOT NULL,data TEXT NOT NULL);\n CREATE INDEX IF NOT EXISTS task_project ON tasks(project,status);\n CREATE TABLE IF NOT EXISTS locks(project TEXT NOT NULL,resource TEXT NOT NULL,task TEXT NOT NULL REFERENCES tasks(id),\n PRIMARY KEY(project,resource));\n CREATE TABLE IF NOT EXISTS events(seq INTEGER PRIMARY KEY AUTOINCREMENT,project TEXT NOT NULL,\n revision INTEGER NOT NULL,kind TEXT NOT NULL,data TEXT NOT NULL);\n CREATE INDEX IF NOT EXISTS work_clock_by_task ON events(project,json_extract(data,'$.task'),seq)\n WHERE kind IN ('task.claimed','reconstruction.submitted','review.submitted');\n CREATE INDEX IF NOT EXISTS work_package_events ON events(project,json_extract(data,'$.request'))\n WHERE kind IN ('reconstruction.submitted','review.submitted');\n CREATE TABLE IF NOT EXISTS receipts(id TEXT PRIMARY KEY,result TEXT NOT NULL);\n CREATE TABLE IF NOT EXISTS graph_nodes(project TEXT NOT NULL REFERENCES projects(id),id TEXT NOT NULL,data TEXT NOT NULL,PRIMARY KEY(project,id));\n CREATE TABLE IF NOT EXISTS graph_edges(project TEXT NOT NULL REFERENCES projects(id),id TEXT NOT NULL,data TEXT NOT NULL,PRIMARY KEY(project,id));\n CREATE TABLE IF NOT EXISTS work_metadata(key TEXT PRIMARY KEY,value TEXT NOT NULL);\n CREATE TABLE IF NOT EXISTS function_versions(project TEXT NOT NULL,id TEXT NOT NULL,version INTEGER NOT NULL,\n data TEXT NOT NULL,reason TEXT NOT NULL,at INTEGER NOT NULL,request TEXT,PRIMARY KEY(project,id,version),\n FOREIGN KEY(project,id) REFERENCES functions(project,id));\n CREATE TABLE IF NOT EXISTS archived_requests(caller_id TEXT PRIMARY KEY,data TEXT NOT NULL);\n CREATE TABLE IF NOT EXISTS function_resources(project TEXT NOT NULL,function_id TEXT NOT NULL,resource TEXT NOT NULL,evidence_edge TEXT NOT NULL,\n PRIMARY KEY(project,function_id,resource,evidence_edge),FOREIGN KEY(project,function_id) REFERENCES functions(project,id));\n CREATE TRIGGER IF NOT EXISTS work_versions_no_update BEFORE UPDATE ON function_versions BEGIN SELECT RAISE(ABORT,'immutable work version'); END;\n CREATE TRIGGER IF NOT EXISTS work_versions_no_delete BEFORE DELETE ON function_versions BEGIN SELECT RAISE(ABORT,'immutable work version'); END;\n";
|
|
20
|
+
/** Fast profile-owned workflow data. Native Ghidra publication remains in Research/Workspace. */
|
|
21
|
+
export declare class WorkStore {
|
|
22
|
+
readonly workspace: Workspace;
|
|
23
|
+
private readonly clock;
|
|
24
|
+
readonly db: DatabaseSync;
|
|
25
|
+
readonly incarnation: string;
|
|
26
|
+
private currentRequest?;
|
|
27
|
+
constructor(workspace: Workspace, clock?: () => number, readOnly?: boolean);
|
|
28
|
+
private reconcileWriterScopes;
|
|
29
|
+
close(): void;
|
|
30
|
+
private tx;
|
|
31
|
+
private project;
|
|
32
|
+
private putProject;
|
|
33
|
+
private function;
|
|
34
|
+
private recordVersion;
|
|
35
|
+
private putFunction;
|
|
36
|
+
private task;
|
|
37
|
+
private putTask;
|
|
38
|
+
private event;
|
|
39
|
+
/** An explicit epoch must match; omission is allowed. Restore already cancels every old assignment. */
|
|
40
|
+
private checkEpoch;
|
|
41
|
+
private cancelled;
|
|
42
|
+
private planning;
|
|
43
|
+
private lease;
|
|
44
|
+
private invalidateTasks;
|
|
45
|
+
/**
|
|
46
|
+
* Only a writer edge reserves its target exclusively. Calls/reads are read dependencies: they are
|
|
47
|
+
* visible in handoff and invalidate packages of their endpoints when new, but never lock.
|
|
48
|
+
*/
|
|
49
|
+
private retainGraphResources;
|
|
50
|
+
/** Exclusive keys from retained writer edges; older rows derived from other edge kinds are ignored. */
|
|
51
|
+
private derivedResources;
|
|
52
|
+
/** Retained packages (with source) of the given functions become invalid; packages without source are untouched. */
|
|
53
|
+
private invalidatePackages;
|
|
54
|
+
reviseDefinition(projectId: string, functionId: string, expectedVersion: number, input: unknown, artifact: Attachment, epoch?: string): {
|
|
55
|
+
function: string;
|
|
56
|
+
version: number;
|
|
57
|
+
definitionRevision: number | undefined;
|
|
58
|
+
changed: boolean;
|
|
59
|
+
revision: number;
|
|
60
|
+
definitionSha256?: undefined;
|
|
61
|
+
cancelledTasks?: undefined;
|
|
62
|
+
accepted1to1?: undefined;
|
|
63
|
+
} | {
|
|
64
|
+
function: string;
|
|
65
|
+
version: number;
|
|
66
|
+
definitionRevision: number;
|
|
67
|
+
definitionSha256: string;
|
|
68
|
+
changed: boolean;
|
|
69
|
+
cancelledTasks: number;
|
|
70
|
+
revision: number;
|
|
71
|
+
accepted1to1: boolean;
|
|
72
|
+
};
|
|
73
|
+
history(projectId: string, functionId: string, after: number, limit: number): {
|
|
74
|
+
project: string;
|
|
75
|
+
function: string;
|
|
76
|
+
items: {
|
|
77
|
+
version: number;
|
|
78
|
+
data: WorkFunction;
|
|
79
|
+
reason: string;
|
|
80
|
+
at: number;
|
|
81
|
+
request: string | null;
|
|
82
|
+
}[];
|
|
83
|
+
nextAfterVersion: number | null;
|
|
84
|
+
historyScope: string;
|
|
85
|
+
};
|
|
86
|
+
/** Explicitly withdraw a current approval without inventing a definition/source change. */
|
|
87
|
+
reopenReview(projectId: string, functionId: string, sourceSha256: string, expectedVersion: number, reason: string, epoch?: string): {
|
|
88
|
+
function: string;
|
|
89
|
+
sourceSha256: string;
|
|
90
|
+
contractSha256: string;
|
|
91
|
+
version: number;
|
|
92
|
+
reviewState: "none" | "rejected" | "stale" | "approved";
|
|
93
|
+
revision: number;
|
|
94
|
+
accepted1to1: boolean;
|
|
95
|
+
};
|
|
96
|
+
/** One local transaction is replayed only from its durable receipt, never from an external effect. */
|
|
97
|
+
assertCurrentRequestId(requestId: string): void;
|
|
98
|
+
mutate<T>(operation: string, input: unknown, requestId: string, action: () => T): T;
|
|
99
|
+
create(projectId: string, targetId: string, name: string): {
|
|
100
|
+
project: Project;
|
|
101
|
+
strict1to1: string;
|
|
102
|
+
};
|
|
103
|
+
importInventory(projectId: string, input: unknown, artifact: Attachment, epoch?: string): {
|
|
104
|
+
project: string;
|
|
105
|
+
revision: number;
|
|
106
|
+
added: number;
|
|
107
|
+
inventoryComplete: boolean;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* "Has unknowns" is not "needs rework". A partial package returns to the reconstruct lane only when
|
|
111
|
+
* it has no source, was invalidated by new evidence/definition, or a reviewer rejected it. Partial
|
|
112
|
+
* packages with current source go to review; an approval records the review but keeps them partial.
|
|
113
|
+
*/
|
|
114
|
+
private static needsRework;
|
|
115
|
+
private static reviewable;
|
|
116
|
+
private static readonly reworkSql;
|
|
117
|
+
plan(projectId: string, expectedRevision: number, count: number, kind: 'reconstruct' | 'review', selected?: string[], afterRva?: number, epoch?: string, excludeAuthor?: string): {
|
|
118
|
+
task: Task;
|
|
119
|
+
revision: number;
|
|
120
|
+
};
|
|
121
|
+
claim(taskId: string, worker: string, ttl: number): {
|
|
122
|
+
task: Task;
|
|
123
|
+
revision: number;
|
|
124
|
+
lease: string;
|
|
125
|
+
};
|
|
126
|
+
/** Plan and claim one slice atomically at the current state; no observed revision is needed. */
|
|
127
|
+
next(projectId: string, worker: string, count: number, kind: 'reconstruct' | 'review', ttl: number, epoch?: string, selected?: string[]): {
|
|
128
|
+
task: Task;
|
|
129
|
+
revision: number;
|
|
130
|
+
lease: string;
|
|
131
|
+
};
|
|
132
|
+
heartbeat(taskId: string, worker: string, fence: number, ttl: number, epoch?: string): {
|
|
133
|
+
task: Task;
|
|
134
|
+
revision: number;
|
|
135
|
+
};
|
|
136
|
+
release(taskId: string, worker: string, fence: number, epoch?: string): {
|
|
137
|
+
task: Task;
|
|
138
|
+
revision: number;
|
|
139
|
+
};
|
|
140
|
+
cancel(taskId: string, expectedRevision: number, reason: string, epoch?: string): {
|
|
141
|
+
task: Task;
|
|
142
|
+
revision: number;
|
|
143
|
+
};
|
|
144
|
+
submit(taskId: string, worker: string, fence: number, entries: {
|
|
145
|
+
id: string;
|
|
146
|
+
source: Attachment;
|
|
147
|
+
contract: Attachment;
|
|
148
|
+
passport: unknown;
|
|
149
|
+
}[], epoch?: string): {
|
|
150
|
+
task: Task;
|
|
151
|
+
revision: number;
|
|
152
|
+
accepted1to1: boolean;
|
|
153
|
+
};
|
|
154
|
+
review(taskId: string, worker: string, fence: number, decisions: {
|
|
155
|
+
id: string;
|
|
156
|
+
sourceSha256: string;
|
|
157
|
+
approved: boolean;
|
|
158
|
+
note: Attachment;
|
|
159
|
+
}[], epoch?: string): {
|
|
160
|
+
task: Task;
|
|
161
|
+
revision: number;
|
|
162
|
+
accepted1to1: boolean;
|
|
163
|
+
};
|
|
164
|
+
compare(projectId: string, functionId: string, sourceSha: string, original: unknown, reconstruction: unknown, artifacts: Attachment[], layout: Attachment, epoch?: string): {
|
|
165
|
+
cases: number;
|
|
166
|
+
mismatches: number;
|
|
167
|
+
firstMismatchInputs: unknown[];
|
|
168
|
+
artifacts: Attachment[];
|
|
169
|
+
layout: Attachment;
|
|
170
|
+
sourceSha256: string;
|
|
171
|
+
level: string;
|
|
172
|
+
origin: string;
|
|
173
|
+
accepted1to1: boolean;
|
|
174
|
+
project: string;
|
|
175
|
+
revision: number;
|
|
176
|
+
};
|
|
177
|
+
certify(): never;
|
|
178
|
+
importGraph(projectId: string, input: unknown, artifact: Attachment, epoch?: string): {
|
|
179
|
+
graphComplete: boolean;
|
|
180
|
+
impact: string;
|
|
181
|
+
affectedFunctionIds: {
|
|
182
|
+
ids: string[];
|
|
183
|
+
truncated: boolean;
|
|
184
|
+
};
|
|
185
|
+
invalidatedPackageIds: {
|
|
186
|
+
ids: string[];
|
|
187
|
+
truncated: boolean;
|
|
188
|
+
};
|
|
189
|
+
cancelledTaskIds: {
|
|
190
|
+
ids: string[];
|
|
191
|
+
truncated: boolean;
|
|
192
|
+
};
|
|
193
|
+
project: string;
|
|
194
|
+
revision: number;
|
|
195
|
+
nodes: number;
|
|
196
|
+
edges: number;
|
|
197
|
+
changed: number;
|
|
198
|
+
affectedFunctions: number;
|
|
199
|
+
invalidatedPackages: number;
|
|
200
|
+
cancelledTasks: number;
|
|
201
|
+
};
|
|
202
|
+
timing(projectId: string, selected?: string[]): {
|
|
203
|
+
rows: {
|
|
204
|
+
function: string;
|
|
205
|
+
authorTask: string;
|
|
206
|
+
authorStatus: "queued" | "cancelled" | "leased" | "submitted";
|
|
207
|
+
reviewTask: string | null;
|
|
208
|
+
authorMs: number | null;
|
|
209
|
+
waitForCompletedReviewMs: number | null;
|
|
210
|
+
reviewMs: number | null;
|
|
211
|
+
toDecisionMs: number | null;
|
|
212
|
+
approved: boolean | null;
|
|
213
|
+
decisionAt: number | null;
|
|
214
|
+
firstApprovalAt: number | null;
|
|
215
|
+
}[];
|
|
216
|
+
queue: Record<string, import("node:sqlite").SQLOutputValue>[];
|
|
217
|
+
selectedTasks: number;
|
|
218
|
+
batchToDecisionMs: number | null;
|
|
219
|
+
byFunction: {
|
|
220
|
+
[k: string]: {
|
|
221
|
+
firstVerdict: boolean;
|
|
222
|
+
firstDecisionAt: number;
|
|
223
|
+
firstApprovalAt: number | null;
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
project: {
|
|
227
|
+
id: string;
|
|
228
|
+
target: string;
|
|
229
|
+
binarySha256: string;
|
|
230
|
+
epoch: string | undefined;
|
|
231
|
+
revision: number;
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
context(projectId: string): {
|
|
235
|
+
id: string;
|
|
236
|
+
target: string;
|
|
237
|
+
binarySha256: string;
|
|
238
|
+
epoch: string | undefined;
|
|
239
|
+
revision: number;
|
|
240
|
+
};
|
|
241
|
+
projects(): Project[];
|
|
242
|
+
request(callerId: string): {
|
|
243
|
+
historical: boolean;
|
|
244
|
+
leaseAuthorization: string;
|
|
245
|
+
ambiguous?: undefined;
|
|
246
|
+
histories?: undefined;
|
|
247
|
+
request?: undefined;
|
|
248
|
+
receipt?: undefined;
|
|
249
|
+
} | {
|
|
250
|
+
historical: boolean;
|
|
251
|
+
leaseAuthorization: string;
|
|
252
|
+
ambiguous: boolean;
|
|
253
|
+
histories: Record<string, unknown>[];
|
|
254
|
+
request?: undefined;
|
|
255
|
+
receipt?: undefined;
|
|
256
|
+
} | {
|
|
257
|
+
request: import("../workspace.js").AdministrationRequest;
|
|
258
|
+
receipt: any;
|
|
259
|
+
historical?: undefined;
|
|
260
|
+
leaseAuthorization?: undefined;
|
|
261
|
+
ambiguous?: undefined;
|
|
262
|
+
histories?: undefined;
|
|
263
|
+
};
|
|
264
|
+
events(projectId: string, after: number, limit: number): {
|
|
265
|
+
project: string;
|
|
266
|
+
revision: number;
|
|
267
|
+
items: {
|
|
268
|
+
data: any;
|
|
269
|
+
}[];
|
|
270
|
+
nextAfter: number | null;
|
|
271
|
+
};
|
|
272
|
+
/** Synchronous streamed projection holds one consistent read snapshot without buffering the inventory. */
|
|
273
|
+
export(projectId: string, path: string): {
|
|
274
|
+
path: string;
|
|
275
|
+
project: string;
|
|
276
|
+
revision: number;
|
|
277
|
+
records: number;
|
|
278
|
+
sha256: string;
|
|
279
|
+
artifacts: string;
|
|
280
|
+
};
|
|
281
|
+
graph(projectId: string, after: string, limit: number, kind: 'nodes' | 'edges'): {
|
|
282
|
+
project: string;
|
|
283
|
+
revision: number;
|
|
284
|
+
items: any[];
|
|
285
|
+
nextAfter: string | null;
|
|
286
|
+
complete: boolean;
|
|
287
|
+
};
|
|
288
|
+
handoff(taskId: string): {
|
|
289
|
+
project: Project;
|
|
290
|
+
task: Task;
|
|
291
|
+
functions: WorkFunction[];
|
|
292
|
+
instructions: string[];
|
|
293
|
+
};
|
|
294
|
+
snapshot(projectId: string, limit?: number): Snapshot;
|
|
295
|
+
/** Full work metadata only: native contexts/configuration are deliberately outside this snapshot. */
|
|
296
|
+
writeBackupState(path: string, observe: (value: unknown) => void): {
|
|
297
|
+
sha256: string;
|
|
298
|
+
size: number;
|
|
299
|
+
records: number;
|
|
300
|
+
counts: Record<string, number>;
|
|
301
|
+
requestCount: number;
|
|
302
|
+
incarnation: string;
|
|
303
|
+
};
|
|
304
|
+
restoreState(stage: DatabaseSync, targets: Map<string, string>, origin: {
|
|
305
|
+
incarnation: string;
|
|
306
|
+
manifest: Attachment;
|
|
307
|
+
state: Attachment;
|
|
308
|
+
}): {
|
|
309
|
+
projects: {
|
|
310
|
+
id: string;
|
|
311
|
+
target: string;
|
|
312
|
+
revision: number;
|
|
313
|
+
planningRevision: number | undefined;
|
|
314
|
+
epoch: string | undefined;
|
|
315
|
+
}[];
|
|
316
|
+
restoredProjects: number;
|
|
317
|
+
projectsComplete: boolean;
|
|
318
|
+
projectSummaryLimit: number;
|
|
319
|
+
cancelledTasks: number;
|
|
320
|
+
origin: {
|
|
321
|
+
incarnation: string;
|
|
322
|
+
manifest: Attachment;
|
|
323
|
+
state: Attachment;
|
|
324
|
+
};
|
|
325
|
+
epoch: string;
|
|
326
|
+
accepted1to1: number;
|
|
327
|
+
scope: string;
|
|
328
|
+
};
|
|
329
|
+
functions(projectId: string, after: number, limit: number): {
|
|
330
|
+
project: string;
|
|
331
|
+
revision: number;
|
|
332
|
+
items: {
|
|
333
|
+
reviewState: "none" | "rejected" | "stale" | "approved";
|
|
334
|
+
id: string;
|
|
335
|
+
rva: number;
|
|
336
|
+
name: string;
|
|
337
|
+
risk: "normal" | "high" | "unknown";
|
|
338
|
+
resources: string[];
|
|
339
|
+
stage: import("./model.js").Stage;
|
|
340
|
+
version: number;
|
|
341
|
+
definition: Record<string, unknown>;
|
|
342
|
+
definitionRevision?: number;
|
|
343
|
+
definitionSha256?: string;
|
|
344
|
+
packageDefinitionRevision?: number;
|
|
345
|
+
invalidated?: {
|
|
346
|
+
reason: string;
|
|
347
|
+
at: number;
|
|
348
|
+
request?: string;
|
|
349
|
+
};
|
|
350
|
+
author?: string;
|
|
351
|
+
source?: Attachment;
|
|
352
|
+
contract?: Attachment;
|
|
353
|
+
passport?: Record<string, unknown>;
|
|
354
|
+
comparison?: Record<string, unknown>;
|
|
355
|
+
review?: Record<string, unknown>;
|
|
356
|
+
reviewRequired?: {
|
|
357
|
+
reason: string;
|
|
358
|
+
at: number;
|
|
359
|
+
sourceSha256: string;
|
|
360
|
+
contractSha256: string;
|
|
361
|
+
request?: string;
|
|
362
|
+
};
|
|
363
|
+
accepted1to1: false;
|
|
364
|
+
}[];
|
|
365
|
+
nextAfterRva: number | null | undefined;
|
|
366
|
+
consistency: string;
|
|
367
|
+
};
|
|
368
|
+
}
|