openplanr 1.16.2 → 1.17.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.
- package/dist/cli/commands/operate.d.ts.map +1 -1
- package/dist/cli/commands/operate.js +185 -6
- package/dist/cli/commands/operate.js.map +1 -1
- package/dist/services/operate/advisors.d.ts +46 -1
- package/dist/services/operate/advisors.d.ts.map +1 -1
- package/dist/services/operate/advisors.js +124 -13
- package/dist/services/operate/advisors.js.map +1 -1
- package/dist/services/operate/artifacts.d.ts +27 -1
- package/dist/services/operate/artifacts.d.ts.map +1 -1
- package/dist/services/operate/artifacts.js +103 -1
- package/dist/services/operate/artifacts.js.map +1 -1
- package/dist/services/operate/cadence.d.ts +50 -0
- package/dist/services/operate/cadence.d.ts.map +1 -0
- package/dist/services/operate/cadence.js +56 -0
- package/dist/services/operate/cadence.js.map +1 -0
- package/dist/services/operate/citation-resolution.d.ts +101 -0
- package/dist/services/operate/citation-resolution.d.ts.map +1 -0
- package/dist/services/operate/citation-resolution.js +308 -0
- package/dist/services/operate/citation-resolution.js.map +1 -0
- package/dist/services/operate/config.d.ts +67 -1
- package/dist/services/operate/config.d.ts.map +1 -1
- package/dist/services/operate/config.js +158 -9
- package/dist/services/operate/config.js.map +1 -1
- package/dist/services/operate/decision-brief.d.ts +148 -0
- package/dist/services/operate/decision-brief.d.ts.map +1 -0
- package/dist/services/operate/decision-brief.js +194 -0
- package/dist/services/operate/decision-brief.js.map +1 -0
- package/dist/services/operate/doctor.d.ts.map +1 -1
- package/dist/services/operate/doctor.js +151 -3
- package/dist/services/operate/doctor.js.map +1 -1
- package/dist/services/operate/engine.d.ts +66 -2
- package/dist/services/operate/engine.d.ts.map +1 -1
- package/dist/services/operate/engine.js +219 -7
- package/dist/services/operate/engine.js.map +1 -1
- package/dist/services/operate/event-store.d.ts +35 -1
- package/dist/services/operate/event-store.d.ts.map +1 -1
- package/dist/services/operate/event-store.js +142 -29
- package/dist/services/operate/event-store.js.map +1 -1
- package/dist/services/operate/evidence-cache.d.ts +25 -1
- package/dist/services/operate/evidence-cache.d.ts.map +1 -1
- package/dist/services/operate/evidence-cache.js +62 -1
- package/dist/services/operate/evidence-cache.js.map +1 -1
- package/dist/services/operate/evidence.d.ts +20 -1
- package/dist/services/operate/evidence.d.ts.map +1 -1
- package/dist/services/operate/evidence.js +119 -0
- package/dist/services/operate/evidence.js.map +1 -1
- package/dist/services/operate/index.d.ts.map +1 -1
- package/dist/services/operate/index.js +72 -5
- package/dist/services/operate/index.js.map +1 -1
- package/dist/services/operate/interaction/action-service.d.ts +17 -0
- package/dist/services/operate/interaction/action-service.d.ts.map +1 -1
- package/dist/services/operate/interaction/action-service.js +19 -0
- package/dist/services/operate/interaction/action-service.js.map +1 -1
- package/dist/services/operate/journal.d.ts.map +1 -1
- package/dist/services/operate/journal.js +11 -5
- package/dist/services/operate/journal.js.map +1 -1
- package/dist/services/operate/maintenance.d.ts.map +1 -1
- package/dist/services/operate/maintenance.js +9 -2
- package/dist/services/operate/maintenance.js.map +1 -1
- package/dist/services/operate/migration.d.ts +68 -0
- package/dist/services/operate/migration.d.ts.map +1 -0
- package/dist/services/operate/migration.js +235 -0
- package/dist/services/operate/migration.js.map +1 -0
- package/dist/services/operate/mission-dispatch.d.ts +193 -0
- package/dist/services/operate/mission-dispatch.d.ts.map +1 -0
- package/dist/services/operate/mission-dispatch.js +444 -0
- package/dist/services/operate/mission-dispatch.js.map +1 -0
- package/dist/services/operate/projection-persistence.d.ts +6 -0
- package/dist/services/operate/projection-persistence.d.ts.map +1 -1
- package/dist/services/operate/projection-persistence.js +87 -11
- package/dist/services/operate/projection-persistence.js.map +1 -1
- package/dist/services/operate/projection.d.ts +26 -1
- package/dist/services/operate/projection.d.ts.map +1 -1
- package/dist/services/operate/projection.js +62 -0
- package/dist/services/operate/projection.js.map +1 -1
- package/dist/services/operate/protocol.d.ts +46 -2
- package/dist/services/operate/protocol.d.ts.map +1 -1
- package/dist/services/operate/protocol.js +57 -5
- package/dist/services/operate/protocol.js.map +1 -1
- package/dist/services/operate/read-only-providers.d.ts +37 -0
- package/dist/services/operate/read-only-providers.d.ts.map +1 -1
- package/dist/services/operate/read-only-providers.js +130 -0
- package/dist/services/operate/read-only-providers.js.map +1 -1
- package/dist/services/operate/reports.d.ts +13 -0
- package/dist/services/operate/reports.d.ts.map +1 -1
- package/dist/services/operate/reports.js +217 -1
- package/dist/services/operate/reports.js.map +1 -1
- package/dist/services/operate/routes.d.ts.map +1 -1
- package/dist/services/operate/routes.js +79 -5
- package/dist/services/operate/routes.js.map +1 -1
- package/dist/services/operate/types.d.ts +120 -4
- package/dist/services/operate/types.d.ts.map +1 -1
- package/dist/services/operate/types.js +13 -0
- package/dist/services/operate/types.js.map +1 -1
- package/dist/services/operate/workspace.d.ts +7 -0
- package/dist/services/operate/workspace.d.ts.map +1 -1
- package/dist/services/operate/workspace.js +14 -5
- package/dist/services/operate/workspace.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { access, mkdir, readdir, readFile, rename, rm, unlink, writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
import { canonicalize } from './canonical.js';
|
|
5
|
+
import { OperatingEventStore } from './event-store.js';
|
|
6
|
+
import { applyJournalTransaction, prepareJournalTransaction, recoverOperatingTransactions, } from './journal.js';
|
|
7
|
+
import { assertOperatingArtifact, resolveOperatingPipelineRoot } from './protocol.js';
|
|
8
|
+
import { OperateError } from './types.js';
|
|
9
|
+
import { ensureOperatingDirectories, resolveOperatingPaths } from './workspace.js';
|
|
10
|
+
const STATE_EVENTS = '.planr/operate/.state/events.jsonl';
|
|
11
|
+
const STATE_RECORDS = '.planr/operate/.state/records.jsonl';
|
|
12
|
+
const STATE_CHECKPOINT = '.planr/operate/.state/checkpoint.json';
|
|
13
|
+
const MIGRATION_TRANSFORM_MODULE = ['lib', 'operate', 'records-migration.mjs'];
|
|
14
|
+
let cachedTransform;
|
|
15
|
+
/**
|
|
16
|
+
* Load the records-container transform directly from the installed pipeline. The
|
|
17
|
+
* v1.3 storage layout is only reachable when the pipeline ships this module, so
|
|
18
|
+
* we fail closed with a named error rather than degrade silently.
|
|
19
|
+
*/
|
|
20
|
+
async function loadRecordsMigration() {
|
|
21
|
+
const root = resolveOperatingPipelineRoot();
|
|
22
|
+
if (!root) {
|
|
23
|
+
throw new OperateError('E_PIPELINE_NOT_INSTALLED', 'The v1.3 storage-layout migration requires the installed pipeline package.', {
|
|
24
|
+
recovery: 'Run `npm install -g openplanr@latest` (without `--omit=optional`), then re-run.',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
cachedTransform ??= import(pathToFileURL(path.join(root, ...MIGRATION_TRANSFORM_MODULE)).href).then((value) => value);
|
|
28
|
+
return cachedTransform;
|
|
29
|
+
}
|
|
30
|
+
async function fileExists(target) {
|
|
31
|
+
return access(target).then(() => true, () => false);
|
|
32
|
+
}
|
|
33
|
+
function legacyEventsPath(operateRoot) {
|
|
34
|
+
return path.join(operateRoot, 'events.jsonl');
|
|
35
|
+
}
|
|
36
|
+
function legacyCheckpointPath(operateRoot) {
|
|
37
|
+
return path.join(operateRoot, 'checkpoints', 'current.json');
|
|
38
|
+
}
|
|
39
|
+
function legacyRecordsDir(operateRoot) {
|
|
40
|
+
return path.join(operateRoot, 'records', 'sha256');
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Detect which storage layout is on disk. `.state/` (or its events log) means the
|
|
44
|
+
* project is already on v1.3; any SPEC-002 internal without `.state/` means v1.2.
|
|
45
|
+
*/
|
|
46
|
+
export async function detectOperatingStorageLayout(projectRoot, options = {}) {
|
|
47
|
+
const paths = resolveOperatingPaths(projectRoot, options);
|
|
48
|
+
if ((await fileExists(paths.state)) || (await fileExists(paths.events)))
|
|
49
|
+
return 'v1.3';
|
|
50
|
+
if ((await fileExists(legacyEventsPath(paths.root))) ||
|
|
51
|
+
(await fileExists(legacyRecordsDir(paths.root))) ||
|
|
52
|
+
(await fileExists(legacyCheckpointPath(paths.root)))) {
|
|
53
|
+
return 'v1.2';
|
|
54
|
+
}
|
|
55
|
+
return 'absent';
|
|
56
|
+
}
|
|
57
|
+
async function readLegacyRecords(operateRoot) {
|
|
58
|
+
const recordsDir = legacyRecordsDir(operateRoot);
|
|
59
|
+
const records = [];
|
|
60
|
+
for (const prefix of await readdir(recordsDir).catch(() => [])) {
|
|
61
|
+
if (!/^[a-f0-9]{2}$/.test(prefix))
|
|
62
|
+
continue;
|
|
63
|
+
for (const name of await readdir(path.join(recordsDir, prefix)).catch(() => [])) {
|
|
64
|
+
if (!/^[a-f0-9]{62}\.json$/.test(name))
|
|
65
|
+
continue;
|
|
66
|
+
const raw = await readFile(path.join(recordsDir, prefix, name), 'utf8');
|
|
67
|
+
records.push(JSON.parse(raw));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return records.sort((left, right) => left.digest.localeCompare(right.digest));
|
|
71
|
+
}
|
|
72
|
+
async function removeLegacyLayout(operateRoot) {
|
|
73
|
+
await unlink(legacyEventsPath(operateRoot)).catch(() => undefined);
|
|
74
|
+
await rm(path.join(operateRoot, 'checkpoints'), { recursive: true, force: true });
|
|
75
|
+
await rm(path.join(operateRoot, 'records'), { recursive: true, force: true });
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Idempotent, journal-safe SPEC-002 -> v1.3 migration. Writes the `.state/`
|
|
79
|
+
* internals through the write-ahead journal first (so a crash mid-migration
|
|
80
|
+
* unwinds cleanly), then removes the SPEC-002 tree only after the journal
|
|
81
|
+
* commits. A crash between commit and cleanup leaves a resolvable `.state/`
|
|
82
|
+
* project whose stale SPEC-002 residue is removed on the next open.
|
|
83
|
+
*/
|
|
84
|
+
export async function applyStorageLayoutMigration(input) {
|
|
85
|
+
const layout = await detectOperatingStorageLayout(input.projectRoot, {
|
|
86
|
+
localRoot: input.localRoot,
|
|
87
|
+
});
|
|
88
|
+
if (layout === 'v1.3') {
|
|
89
|
+
const paths = resolveOperatingPaths(input.projectRoot, { localRoot: input.localRoot });
|
|
90
|
+
const legacyPresent = (await fileExists(legacyEventsPath(paths.root))) ||
|
|
91
|
+
(await fileExists(legacyRecordsDir(paths.root))) ||
|
|
92
|
+
(await fileExists(legacyCheckpointPath(paths.root)));
|
|
93
|
+
if (!legacyPresent) {
|
|
94
|
+
// Fully migrated (or a prior interrupted migration already reconciled):
|
|
95
|
+
// there is no SPEC-002 backup left to reconcile against.
|
|
96
|
+
return { migrated: false, layout };
|
|
97
|
+
}
|
|
98
|
+
// `.state/` and the SPEC-002 backup coexist, so a migration was interrupted.
|
|
99
|
+
// Roll back any non-terminal migration transaction FIRST: a crash mid-
|
|
100
|
+
// promotion leaves a partial `.state/` that detects as v1.3 while the SPEC-002
|
|
101
|
+
// backup is still the only complete copy. Removing the backup against that
|
|
102
|
+
// partial view (the previous behavior) destroyed the unpromoted records.
|
|
103
|
+
// Recovery reverts the partial `.state/` writes byte-exact before we decide.
|
|
104
|
+
await recoverOperatingTransactions(input.projectRoot, { localRoot: input.localRoot });
|
|
105
|
+
if (await fileExists(paths.events)) {
|
|
106
|
+
// The event log survived recovery, so the v1.3 view is committed and
|
|
107
|
+
// durable (a crash between commit and cleanup). The residue is safe to drop.
|
|
108
|
+
await removeLegacyLayout(paths.root);
|
|
109
|
+
return { migrated: false, layout };
|
|
110
|
+
}
|
|
111
|
+
// Recovery reverted a partial promotion; discard the now-empty `.state/`
|
|
112
|
+
// residue and re-migrate from the intact SPEC-002 backup.
|
|
113
|
+
await rm(paths.state, { recursive: true, force: true });
|
|
114
|
+
return applyStorageLayoutMigration(input);
|
|
115
|
+
}
|
|
116
|
+
if (layout === 'absent')
|
|
117
|
+
return { migrated: false, layout };
|
|
118
|
+
const paths = resolveOperatingPaths(input.projectRoot, { localRoot: input.localRoot });
|
|
119
|
+
const store = new OperatingEventStore(input.projectRoot, { localRoot: input.localRoot });
|
|
120
|
+
const head = (await store.replay()).eventHead;
|
|
121
|
+
const legacyRecords = await readLegacyRecords(paths.root);
|
|
122
|
+
const transform = await loadRecordsMigration();
|
|
123
|
+
const { lines, migrationRecord } = transform.migrateRecordsDirectoryToJsonl(legacyRecords, {
|
|
124
|
+
eventCount: head.sequence,
|
|
125
|
+
...(input.now ? { migratedAt: input.now } : {}),
|
|
126
|
+
});
|
|
127
|
+
// Validate the transform output against the published Protocol v1.3 contract.
|
|
128
|
+
await assertOperatingArtifact('operating-migration-record', migrationRecord);
|
|
129
|
+
const previewDigest = migrationRecord.previewDigest;
|
|
130
|
+
const migrationId = migrationRecord.id;
|
|
131
|
+
const eventsBytes = await readFile(legacyEventsPath(paths.root), 'utf8').catch((error) => {
|
|
132
|
+
if (error.code === 'ENOENT')
|
|
133
|
+
return '';
|
|
134
|
+
throw error;
|
|
135
|
+
});
|
|
136
|
+
const checkpointBytes = await readFile(legacyCheckpointPath(paths.root), 'utf8').catch((error) => {
|
|
137
|
+
if (error.code === 'ENOENT')
|
|
138
|
+
return null;
|
|
139
|
+
throw error;
|
|
140
|
+
});
|
|
141
|
+
await ensureOperatingDirectories(input.projectRoot, { localRoot: input.localRoot });
|
|
142
|
+
const writes = [
|
|
143
|
+
{ relativePath: STATE_EVENTS, content: eventsBytes, operation: 'create' },
|
|
144
|
+
{
|
|
145
|
+
relativePath: STATE_RECORDS,
|
|
146
|
+
content: lines.length > 0 ? `${lines.join('\n')}\n` : '',
|
|
147
|
+
operation: 'create',
|
|
148
|
+
},
|
|
149
|
+
...(checkpointBytes !== null
|
|
150
|
+
? [{ relativePath: STATE_CHECKPOINT, content: checkpointBytes, operation: 'create' }]
|
|
151
|
+
: []),
|
|
152
|
+
];
|
|
153
|
+
const transaction = await prepareJournalTransaction(input.projectRoot, {
|
|
154
|
+
writes,
|
|
155
|
+
eventHead: head,
|
|
156
|
+
previewDigest,
|
|
157
|
+
localRoot: input.localRoot,
|
|
158
|
+
transactionId: `TXN-${migrationId}`,
|
|
159
|
+
now: input.now,
|
|
160
|
+
});
|
|
161
|
+
await applyJournalTransaction(input.projectRoot, transaction, { currentEventHead: head });
|
|
162
|
+
// The `.state/` view is committed; the SPEC-002 tree is now safe to remove.
|
|
163
|
+
await removeLegacyLayout(paths.root);
|
|
164
|
+
return { migrated: true, layout, recordCount: legacyRecords.length, migrationId };
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Automatic-on-open entry point. Any mutating operate action calls this before
|
|
168
|
+
* it proceeds; it is a fast no-op for a v1.3 or uninitialized project and only
|
|
169
|
+
* migrates a genuine SPEC-002-layout project. When the pipeline transform is
|
|
170
|
+
* unavailable the layout is left untouched — the mutation fails downstream with
|
|
171
|
+
* the standard pipeline-required error rather than half-migrating.
|
|
172
|
+
*/
|
|
173
|
+
export async function migrateOperatingStorageLayoutOnOpen(projectRoot, options = {}) {
|
|
174
|
+
const layout = await detectOperatingStorageLayout(projectRoot, options);
|
|
175
|
+
if (layout === 'v1.2' && !resolveOperatingPipelineRoot()) {
|
|
176
|
+
return { migrated: false, layout };
|
|
177
|
+
}
|
|
178
|
+
return applyStorageLayoutMigration({ projectRoot, localRoot: options.localRoot });
|
|
179
|
+
}
|
|
180
|
+
/** Read-only inspection of what an automatic migration would do. */
|
|
181
|
+
export async function inspectStorageLayoutMigration(input) {
|
|
182
|
+
const layout = await detectOperatingStorageLayout(input.projectRoot, {
|
|
183
|
+
localRoot: input.localRoot,
|
|
184
|
+
});
|
|
185
|
+
const recordCount = layout === 'v1.2'
|
|
186
|
+
? (await readLegacyRecords(resolveOperatingPaths(input.projectRoot, input).root)).length
|
|
187
|
+
: 0;
|
|
188
|
+
return { migrated: false, layout, recordCount };
|
|
189
|
+
}
|
|
190
|
+
async function atomicWrite(target, content) {
|
|
191
|
+
await mkdir(path.dirname(target), { recursive: true, mode: 0o700 });
|
|
192
|
+
const temporary = `${target}.${process.pid}.tmp`;
|
|
193
|
+
await writeFile(temporary, content, { mode: 0o600 });
|
|
194
|
+
await rename(temporary, target);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Byte-exact inverse: rebuild the SPEC-002 layout from the v1.3 `.state/` view.
|
|
198
|
+
* Restores `records/sha256/<pp>/<rest>.json` from `records.jsonl` via the
|
|
199
|
+
* pipeline's `reconstructDirectoryLayoutFromJsonl`, copies the events log and
|
|
200
|
+
* checkpoint back to their SPEC-002 locations, and removes `.state/`.
|
|
201
|
+
*/
|
|
202
|
+
export async function rollbackStorageLayoutMigration(input) {
|
|
203
|
+
const paths = resolveOperatingPaths(input.projectRoot, { localRoot: input.localRoot });
|
|
204
|
+
if (!(await fileExists(paths.state))) {
|
|
205
|
+
return {
|
|
206
|
+
migrated: false,
|
|
207
|
+
layout: await detectOperatingStorageLayout(input.projectRoot, input),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const transform = await loadRecordsMigration();
|
|
211
|
+
const recordsRaw = await readFile(paths.records, 'utf8').catch((error) => {
|
|
212
|
+
if (error.code === 'ENOENT')
|
|
213
|
+
return '';
|
|
214
|
+
throw error;
|
|
215
|
+
});
|
|
216
|
+
const lines = recordsRaw.split('\n').filter((line) => line.trim().length > 0);
|
|
217
|
+
const layout = transform.reconstructDirectoryLayoutFromJsonl(lines);
|
|
218
|
+
const recordsDir = legacyRecordsDir(paths.root);
|
|
219
|
+
for (const [prefix, bucket] of layout) {
|
|
220
|
+
for (const [rest, record] of bucket) {
|
|
221
|
+
// The SPEC-002 per-file record body is the canonical operating-record with
|
|
222
|
+
// no trailing newline, so the restored bytes match the original exactly.
|
|
223
|
+
await atomicWrite(path.join(recordsDir, prefix, `${rest}.json`), canonicalize(record));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const eventsBytes = await readFile(paths.events, 'utf8').catch(() => '');
|
|
227
|
+
await atomicWrite(legacyEventsPath(paths.root), eventsBytes);
|
|
228
|
+
const checkpointBytes = await readFile(paths.checkpoint, 'utf8').catch(() => null);
|
|
229
|
+
if (checkpointBytes !== null) {
|
|
230
|
+
await atomicWrite(legacyCheckpointPath(paths.root), checkpointBytes);
|
|
231
|
+
}
|
|
232
|
+
await rm(paths.state, { recursive: true, force: true });
|
|
233
|
+
return { migrated: true, layout: 'v1.2', recordCount: lines.length };
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.js","sourceRoot":"","sources":["../../../src/services/operate/migration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACnG,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EACL,uBAAuB,EAEvB,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,EAAE,YAAY,EAAyD,MAAM,YAAY,CAAC;AACjG,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAmBnF,MAAM,YAAY,GAAG,oCAAoC,CAAC;AAC1D,MAAM,aAAa,GAAG,qCAAqC,CAAC;AAC5D,MAAM,gBAAgB,GAAG,uCAAuC,CAAC;AACjE,MAAM,0BAA0B,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,uBAAuB,CAAC,CAAC;AAe/E,IAAI,eAAyD,CAAC;AAE9D;;;;GAIG;AACH,KAAK,UAAU,oBAAoB;IACjC,MAAM,IAAI,GAAG,4BAA4B,EAAE,CAAC;IAC5C,IAAI,CAAC,IAAI,EAAE,CAA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GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACnF,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;QAC7B,MAAM,WAAW,CAAC,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC,CAAC;IACvE,CAAC;IACD,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { type OperatingEvidenceIndexItem, type OperatingRoleId, type OperatingSensitivity } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Bounded, read-only native mission dispatch (FR2 / E-002).
|
|
4
|
+
*
|
|
5
|
+
* This module owns the two enforcement guarantees the pack path never needed:
|
|
6
|
+
*
|
|
7
|
+
* 1. A native advisory lens receives EXACTLY the Protocol v1.3 read-only tool
|
|
8
|
+
* grant — glob, file read, content search, and read-only git history —
|
|
9
|
+
* confined to its declared, sensitivity-ceiling-narrowed roots. No write,
|
|
10
|
+
* execute, network, or environment capability exists on the surface at all,
|
|
11
|
+
* so a mission agent physically cannot mutate, shell out, egress, or read
|
|
12
|
+
* ambient process state.
|
|
13
|
+
* 2. The sensitivity ceiling is enforced at READ time: even inside a granted
|
|
14
|
+
* root, a file above the role's ceiling is refused. This preserves the
|
|
15
|
+
* pack-era filter-before-handoff guarantee under agent-driven reads.
|
|
16
|
+
*
|
|
17
|
+
* It also owns the per-role dispatch-mode resolution (FR4 / E-004): the derived
|
|
18
|
+
* registry default (`mission`), the per-project `dispatchModeOverrides`, and the
|
|
19
|
+
* FR2-vs-FR4 reconciliation that routes non-enforcing runtimes to the structured
|
|
20
|
+
* provider path. The new mission honeytoken suite exercises every refusal here;
|
|
21
|
+
* the SPEC-002 empty-tool suite continues to govern the pack path unchanged.
|
|
22
|
+
*/
|
|
23
|
+
export type OperatingDispatchMode = 'pack' | 'mission';
|
|
24
|
+
/**
|
|
25
|
+
* The effective isolation a role's dispatch resolves to. Mirrors the isolation
|
|
26
|
+
* vocabulary the pipeline's v1.3 adapter handoff emits so OpenPlanr and the
|
|
27
|
+
* published contract cannot drift:
|
|
28
|
+
* - `enforced-empty-tools` — the v1.2 pack path (empty-tool brief);
|
|
29
|
+
* - `enforced-read-only-bounded` — a native mission lens with the bounded
|
|
30
|
+
* read-only grant, on a runtime that
|
|
31
|
+
* natively enforces tool isolation;
|
|
32
|
+
* - `fail-closed-structured-provider` — mission requested but the runtime
|
|
33
|
+
* cannot enforce the boundary, so the role
|
|
34
|
+
* falls back to the structured provider.
|
|
35
|
+
*/
|
|
36
|
+
export type OperatingDispatchIsolation = 'enforced-empty-tools' | 'enforced-read-only-bounded' | 'fail-closed-structured-provider';
|
|
37
|
+
export interface OperatingDispatchModeResolution {
|
|
38
|
+
roleId: OperatingRoleId;
|
|
39
|
+
/** The configured mode: registry default, overridden by dispatchModeOverrides. */
|
|
40
|
+
mode: OperatingDispatchMode;
|
|
41
|
+
/** The effective isolation after the FR2/FR4 reconciliation. */
|
|
42
|
+
isolation: OperatingDispatchIsolation;
|
|
43
|
+
/** True only when a native, bounded read-only lens is actually dispatched. */
|
|
44
|
+
native: boolean;
|
|
45
|
+
/** Audit note explaining why this isolation was chosen (recorded in provenance). */
|
|
46
|
+
reconciliation: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The bounded read-only capability set for a mission-mode lens. Kept in lockstep
|
|
50
|
+
* with the pipeline's `MISSION_READ_ONLY_TOOLS`: no write, execute, network, or
|
|
51
|
+
* environment tool is present, so a grant assembled from it can never authorize
|
|
52
|
+
* a mutating or escaping action.
|
|
53
|
+
*/
|
|
54
|
+
export declare const MISSION_READ_ONLY_TOOLS: readonly ["file-read", "glob", "content-search", "git-log", "git-show", "git-diff", "git-blame"];
|
|
55
|
+
export type MissionReadOnlyTool = (typeof MISSION_READ_ONLY_TOOLS)[number];
|
|
56
|
+
/**
|
|
57
|
+
* The registry default dispatch mode for a role. The v1.3 role registry carries
|
|
58
|
+
* a `dispatchMode` field; while it is still published without one every role
|
|
59
|
+
* defaults to `mission`, and only a role explicitly marked `pack` opts out —
|
|
60
|
+
* exactly the pipeline's own `role?.dispatchMode ?? 'mission'` convention.
|
|
61
|
+
*/
|
|
62
|
+
export declare function operatingRegistryDispatchMode(role: {
|
|
63
|
+
dispatchMode?: unknown;
|
|
64
|
+
}): OperatingDispatchMode;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the given runtime natively enforces the mission read-only boundary.
|
|
67
|
+
* `claude-code` enforces; `codex` and `cursor` are advisory and do not.
|
|
68
|
+
*/
|
|
69
|
+
export declare function operatingRuntimeEnforcesBoundedReadOnly(runtime: string | undefined): Promise<boolean>;
|
|
70
|
+
/**
|
|
71
|
+
* Resolve one role's effective dispatch isolation.
|
|
72
|
+
*
|
|
73
|
+
* FR4 states Codex SHOULD dispatch natively, but FR2's fail-closed rule
|
|
74
|
+
* overrides it: a runtime whose tool isolation is only advisory (`codex`,
|
|
75
|
+
* `cursor`) cannot guarantee the bounded read-only boundary, so it routes to the
|
|
76
|
+
* structured provider path until its isolation is enforceable. Only a runtime
|
|
77
|
+
* that natively enforces tool isolation (`toolIsolation === 'enforced'`, i.e.
|
|
78
|
+
* `claude-code`) hosting a native-isolated adapter receives a native mission
|
|
79
|
+
* lens; every other combination fails closed here. This is the exact FR2/FR4
|
|
80
|
+
* reconciliation the spec calls out, recorded in the returned `reconciliation`
|
|
81
|
+
* so it appears in the dispatch provenance.
|
|
82
|
+
*/
|
|
83
|
+
export declare function resolveOperatingDispatchMode(input: {
|
|
84
|
+
roleId: OperatingRoleId;
|
|
85
|
+
registryDefault: OperatingDispatchMode;
|
|
86
|
+
override?: OperatingDispatchMode;
|
|
87
|
+
runtimeEnforcesBoundedReadOnly: boolean;
|
|
88
|
+
adapterNativeCapable: boolean;
|
|
89
|
+
}): OperatingDispatchModeResolution;
|
|
90
|
+
/**
|
|
91
|
+
* Narrow a role's declared read roots by DENY-LISTING any root that contains an
|
|
92
|
+
* evidence item above the role's sensitivity ceiling, so no above-ceiling file
|
|
93
|
+
* is readable even inside a granted root. Pass the FULL (pre-ceiling-filter)
|
|
94
|
+
* evidence index: the narrowing needs to see the above-ceiling items the packet
|
|
95
|
+
* index itself excludes. Combined with the read-time ceiling check on the
|
|
96
|
+
* bounded reader, this is the belt-and-suspenders that preserves the pack-era
|
|
97
|
+
* filter-before-handoff guarantee under agent-driven reads.
|
|
98
|
+
*/
|
|
99
|
+
export declare function narrowMissionRootsToCeiling(input: {
|
|
100
|
+
declaredRoots: readonly string[];
|
|
101
|
+
evidenceIndex: readonly OperatingEvidenceIndexItem[];
|
|
102
|
+
ceiling: OperatingSensitivity;
|
|
103
|
+
}): string[];
|
|
104
|
+
export interface MissionReadBoundary {
|
|
105
|
+
/**
|
|
106
|
+
* Absolute, resolved read roots (already sensitivity-ceiling-narrowed). A read
|
|
107
|
+
* target must resolve inside one of these or it is refused as a root escape.
|
|
108
|
+
*/
|
|
109
|
+
roots: readonly string[];
|
|
110
|
+
/** The role's sensitivity ceiling, enforced at read time. */
|
|
111
|
+
ceiling: OperatingSensitivity;
|
|
112
|
+
/**
|
|
113
|
+
* The sensitivity of a resolved absolute path. In production this is built
|
|
114
|
+
* from the ceiling-filtered evidence index; an in-root path with no explicit
|
|
115
|
+
* classification falls back to `defaultSensitivity`.
|
|
116
|
+
*/
|
|
117
|
+
sensitivityByPath?: ReadonlyMap<string, OperatingSensitivity>;
|
|
118
|
+
/**
|
|
119
|
+
* Sensitivity assumed for an in-root path with no explicit classification.
|
|
120
|
+
* Defaults to the ceiling itself (readable) because the ceiling-filtered index
|
|
121
|
+
* and root narrowing already exclude above-ceiling material; individual
|
|
122
|
+
* above-ceiling files are still refused by the read-time check below.
|
|
123
|
+
*/
|
|
124
|
+
defaultSensitivity?: OperatingSensitivity;
|
|
125
|
+
/** Repository root for read-only git tools. Defaults to the first read root. */
|
|
126
|
+
repositoryRoot?: string;
|
|
127
|
+
}
|
|
128
|
+
export type MissionToolRequest = {
|
|
129
|
+
tool: 'file-read';
|
|
130
|
+
path: string;
|
|
131
|
+
} | {
|
|
132
|
+
tool: 'glob';
|
|
133
|
+
pattern?: string;
|
|
134
|
+
root?: string;
|
|
135
|
+
} | {
|
|
136
|
+
tool: 'content-search';
|
|
137
|
+
query: string;
|
|
138
|
+
root?: string;
|
|
139
|
+
} | {
|
|
140
|
+
tool: 'git-log' | 'git-show' | 'git-diff' | 'git-blame';
|
|
141
|
+
args?: string[];
|
|
142
|
+
path?: string;
|
|
143
|
+
} | {
|
|
144
|
+
tool: string;
|
|
145
|
+
[key: string]: unknown;
|
|
146
|
+
};
|
|
147
|
+
export type MissionToolResult = {
|
|
148
|
+
tool: 'file-read';
|
|
149
|
+
path: string;
|
|
150
|
+
content: string;
|
|
151
|
+
} | {
|
|
152
|
+
tool: 'glob';
|
|
153
|
+
matches: string[];
|
|
154
|
+
} | {
|
|
155
|
+
tool: 'content-search';
|
|
156
|
+
matches: Array<{
|
|
157
|
+
path: string;
|
|
158
|
+
line: number;
|
|
159
|
+
text: string;
|
|
160
|
+
}>;
|
|
161
|
+
} | {
|
|
162
|
+
tool: 'git-log' | 'git-show' | 'git-diff' | 'git-blame';
|
|
163
|
+
output: string;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* The single audited entry point for a mission lens's tool use. Every request is
|
|
167
|
+
* checked against the bounded read-only grant BEFORE any filesystem or git
|
|
168
|
+
* access: a tool outside the grant (write, execute, network, environment, or any
|
|
169
|
+
* unknown surface) is refused, a target outside the declared roots is refused as
|
|
170
|
+
* a path escape, and a target above the sensitivity ceiling is refused at read
|
|
171
|
+
* time. There is deliberately no write/execute/network/environment tool to
|
|
172
|
+
* invoke — those channels do not exist on this surface at all.
|
|
173
|
+
*/
|
|
174
|
+
export declare function invokeMissionTool(boundary: MissionReadBoundary, request: MissionToolRequest): Promise<MissionToolResult>;
|
|
175
|
+
/**
|
|
176
|
+
* The concrete callable tool surface handed to an in-process native harness:
|
|
177
|
+
* exactly the read-only tools, each bound to this boundary. There is no write,
|
|
178
|
+
* execute, network, or environment callable on the returned object, so a harness
|
|
179
|
+
* that walks it can never reach a mutating or escaping capability.
|
|
180
|
+
*/
|
|
181
|
+
export declare function createMissionToolset(boundary: MissionReadBoundary): Record<MissionReadOnlyTool, (request: Omit<MissionToolRequest, 'tool'>) => Promise<MissionToolResult>>;
|
|
182
|
+
/**
|
|
183
|
+
* Fan a per-item dispatch out in parallel where the adapter reports
|
|
184
|
+
* `parallelDispatch: true`, sequentially otherwise. Results are always returned
|
|
185
|
+
* in the SAME order as `items`, so the caller can restore registry order and the
|
|
186
|
+
* reduced events are byte-identical across parallel and sequential dispatch.
|
|
187
|
+
*/
|
|
188
|
+
export declare function runMissionDispatchFanOut<Item, Result>(input: {
|
|
189
|
+
items: readonly Item[];
|
|
190
|
+
parallel: boolean;
|
|
191
|
+
run: (item: Item) => Promise<Result>;
|
|
192
|
+
}): Promise<Result[]>;
|
|
193
|
+
//# sourceMappingURL=mission-dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mission-dispatch.d.ts","sourceRoot":"","sources":["../../../src/services/operate/mission-dispatch.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,SAAS,CAAC;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,0BAA0B,GAClC,sBAAsB,GACtB,4BAA4B,GAC5B,iCAAiC,CAAC;AAEtC,MAAM,WAAW,+BAA+B;IAC9C,MAAM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