@brucewaynedecoy/make-docs 2.0.4 → 2.0.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/dist/{backup-CM7RL2Q7.js → backup-P5NUPAJL.js} +4 -4
- package/dist/{chunk-M7DMFIKU.js → chunk-2WC74W66.js} +224 -20
- package/dist/chunk-2WC74W66.js.map +1 -0
- package/dist/{chunk-OR5ZVGLG.js → chunk-B7QF7XZT.js} +151 -5
- package/dist/chunk-B7QF7XZT.js.map +1 -0
- package/dist/{chunk-LV3CBXZB.js → chunk-DNPFQB24.js} +3 -3
- package/dist/{chunk-52FTNVXS.js → chunk-EF47XIIR.js} +8977 -2891
- package/dist/chunk-EF47XIIR.js.map +1 -0
- package/dist/{chunk-GERMRLJ2.js → chunk-KFYUB4AX.js} +6 -4
- package/dist/chunk-KFYUB4AX.js.map +1 -0
- package/dist/{chunk-ADVNSMA7.js → chunk-LK6BLVZA.js} +3 -3
- package/dist/{chunk-65QWMODG.js → chunk-PI7W5QDB.js} +3 -3
- package/dist/{chunk-65QWMODG.js.map → chunk-PI7W5QDB.js.map} +1 -1
- package/dist/{chunk-YVSASZMT.js → chunk-SFKYGFUV.js} +277 -79
- package/dist/chunk-SFKYGFUV.js.map +1 -0
- package/dist/{chunk-J5QDGRZ7.js → chunk-TDB6UW4M.js} +116 -37
- package/dist/chunk-TDB6UW4M.js.map +1 -0
- package/dist/{chunk-7R2PPKTB.js → chunk-XFFESINU.js} +2 -2
- package/dist/index.js +408 -86
- package/dist/index.js.map +1 -1
- package/dist/registry-44WLX4F5.js +50 -0
- package/dist/registry-44WLX4F5.js.map +1 -0
- package/dist/{self-36ULRIJ6.js → self-WRWI5XNE.js} +10 -10
- package/dist/server-FYRDPOBR.js +1117 -0
- package/dist/server-FYRDPOBR.js.map +1 -0
- package/dist/{setup-system-JI36YJ6D.js → setup-system-XX6NSVXZ.js} +263 -40
- package/dist/setup-system-XX6NSVXZ.js.map +1 -0
- package/dist/{skills-command-IGDVLNKY.js → skills-command-YAQP24JM.js} +17 -7
- package/dist/skills-command-YAQP24JM.js.map +1 -0
- package/dist/{uninstall-VBGMQQLA.js → uninstall-3YJKZ6UF.js} +9 -9
- package/dist/virtual_make-docs-first-party-skills-5TYTCD5U.js +11 -0
- package/dist/virtual_make-docs-first-party-skills-5TYTCD5U.js.map +1 -0
- package/package.json +5 -5
- package/skill-registry.json +24 -8
- package/skill-registry.schema.json +2 -1
- package/template/.make-docs/system/contracts/system-resource-contract.md +16 -0
- package/template/.make-docs/system-resources.catalog.json +415 -0
- package/template/.make-docs/system-resources.schema.json +25 -0
- package/dist/chunk-52FTNVXS.js.map +0 -1
- package/dist/chunk-GERMRLJ2.js.map +0 -1
- package/dist/chunk-J5QDGRZ7.js.map +0 -1
- package/dist/chunk-M7DMFIKU.js.map +0 -1
- package/dist/chunk-OR5ZVGLG.js.map +0 -1
- package/dist/chunk-YVSASZMT.js.map +0 -1
- package/dist/server-H754TA4Q.js +0 -512
- package/dist/server-H754TA4Q.js.map +0 -1
- package/dist/setup-system-JI36YJ6D.js.map +0 -1
- package/dist/skills-command-IGDVLNKY.js.map +0 -1
- package/dist/virtual_make-docs-first-party-skills-H3FC47C2.js +0 -11
- package/dist/virtual_make-docs-first-party-skills-H3FC47C2.js.map +0 -1
- /package/dist/{backup-CM7RL2Q7.js.map → backup-P5NUPAJL.js.map} +0 -0
- /package/dist/{chunk-LV3CBXZB.js.map → chunk-DNPFQB24.js.map} +0 -0
- /package/dist/{chunk-ADVNSMA7.js.map → chunk-LK6BLVZA.js.map} +0 -0
- /package/dist/{chunk-7R2PPKTB.js.map → chunk-XFFESINU.js.map} +0 -0
- /package/dist/{self-36ULRIJ6.js.map → self-WRWI5XNE.js.map} +0 -0
- /package/dist/{uninstall-VBGMQQLA.js.map → uninstall-3YJKZ6UF.js.map} +0 -0
|
@@ -3,8 +3,10 @@ import {
|
|
|
3
3
|
NO_ACCESS,
|
|
4
4
|
fingerprintEntry,
|
|
5
5
|
getFirstPartyHarnessAdapter,
|
|
6
|
+
isRedactedMcpNativeValue,
|
|
7
|
+
redactMcpNativeValue,
|
|
6
8
|
validateHarnessMethodSelection
|
|
7
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2WC74W66.js";
|
|
8
10
|
import {
|
|
9
11
|
CURRENT_STORE_SCHEMA_VERSION,
|
|
10
12
|
GLOBAL_CONFIG_FILE,
|
|
@@ -30,7 +32,15 @@ import {
|
|
|
30
32
|
resolveStoreRoot,
|
|
31
33
|
validateInstallationStoreRoot,
|
|
32
34
|
withInstallationDatabase
|
|
33
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-SFKYGFUV.js";
|
|
36
|
+
|
|
37
|
+
// src/operations/types.ts
|
|
38
|
+
var OperationError = class extends Error {
|
|
39
|
+
constructor(message) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.name = "OperationError";
|
|
42
|
+
}
|
|
43
|
+
};
|
|
34
44
|
|
|
35
45
|
// src/store/global-config.ts
|
|
36
46
|
import { existsSync, readFileSync } from "fs";
|
|
@@ -186,11 +196,13 @@ function normalizeGlobalConfig(raw, configPath, warnings) {
|
|
|
186
196
|
warnings
|
|
187
197
|
);
|
|
188
198
|
if (!accessCeiling) continue;
|
|
199
|
+
const mcpConnection = normalizeMcpConnection(intent.mcpConnection, harness);
|
|
189
200
|
settings.harnesses[harness] = {
|
|
190
201
|
...intent,
|
|
191
202
|
selected,
|
|
192
203
|
maximumMethod,
|
|
193
|
-
accessCeiling
|
|
204
|
+
accessCeiling,
|
|
205
|
+
...mcpConnection ? { mcpConnection } : { mcpConnection: void 0 }
|
|
194
206
|
};
|
|
195
207
|
}
|
|
196
208
|
}
|
|
@@ -201,6 +213,18 @@ function normalizeGlobalConfig(raw, configPath, warnings) {
|
|
|
201
213
|
settings
|
|
202
214
|
};
|
|
203
215
|
}
|
|
216
|
+
function normalizeMcpConnection(value, owner) {
|
|
217
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
218
|
+
const record2 = value;
|
|
219
|
+
if (typeof record2.id !== "string" || !/^[0-9a-f-]{36}$/.test(record2.id) || typeof record2.keySha256 !== "string" || !/^[a-f0-9]{64}$/.test(record2.keySha256) || typeof record2.active !== "boolean" || record2.method !== "mcp" || record2.owner !== owner) return null;
|
|
220
|
+
return {
|
|
221
|
+
id: record2.id,
|
|
222
|
+
keySha256: record2.keySha256,
|
|
223
|
+
active: record2.active,
|
|
224
|
+
method: "mcp",
|
|
225
|
+
owner
|
|
226
|
+
};
|
|
227
|
+
}
|
|
204
228
|
function normalizeHarnessAccessCeiling(value, fallback, configPath, harness, warnings) {
|
|
205
229
|
if (value === void 0) return { ...fallback };
|
|
206
230
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
@@ -256,14 +280,15 @@ function resolveProjectIdentity(repoRoot) {
|
|
|
256
280
|
import path3 from "path";
|
|
257
281
|
function recordHarnessIntegrationReceipt(targetRoot, storeRoot, receipt) {
|
|
258
282
|
assertHarnessIntegrationReceipt(receipt);
|
|
283
|
+
const durableReceipt = redactHarnessIntegrationReceipt(receipt);
|
|
259
284
|
const currentId = currentReceiptRecordId(
|
|
260
285
|
receipt.scope,
|
|
261
286
|
receipt.harnessId,
|
|
262
287
|
receipt.connectionMethod
|
|
263
288
|
);
|
|
264
289
|
if (receipt.scope === "project") {
|
|
265
|
-
recordMigrationState(targetRoot, "receipt", receipt.operationId,
|
|
266
|
-
recordMigrationState(targetRoot, "receipt", currentId,
|
|
290
|
+
recordMigrationState(targetRoot, "receipt", receipt.operationId, durableReceipt, storeRoot);
|
|
291
|
+
recordMigrationState(targetRoot, "receipt", currentId, durableReceipt, storeRoot);
|
|
267
292
|
return;
|
|
268
293
|
}
|
|
269
294
|
const recordId = machineReceiptRecordId(receipt.operationId);
|
|
@@ -271,10 +296,21 @@ function recordHarnessIntegrationReceipt(targetRoot, storeRoot, receipt) {
|
|
|
271
296
|
const write = db.prepare(
|
|
272
297
|
"INSERT INTO tool_operations (operation_id,operation,status,pid,hostname,metadata_json,started_at,finished_at) VALUES (?,?,'completed',?,?,?,?,?) ON CONFLICT(operation_id) DO UPDATE SET status='completed',metadata_json=excluded.metadata_json,finished_at=excluded.finished_at"
|
|
273
298
|
);
|
|
274
|
-
write.run(recordId, "setup.system.receipt", process.pid, platform.hostname, JSON.stringify(
|
|
275
|
-
write.run(currentId, "setup.system.receipt-current", process.pid, platform.hostname, JSON.stringify(
|
|
299
|
+
write.run(recordId, "setup.system.receipt", process.pid, platform.hostname, JSON.stringify(durableReceipt), receipt.verifiedAt, receipt.verifiedAt);
|
|
300
|
+
write.run(currentId, "setup.system.receipt-current", process.pid, platform.hostname, JSON.stringify(durableReceipt), receipt.verifiedAt, receipt.verifiedAt);
|
|
276
301
|
}, { storeRoot });
|
|
277
302
|
}
|
|
303
|
+
function redactHarnessIntegrationReceipt(receipt) {
|
|
304
|
+
if (receipt.connectionMethod !== "mcp") return receipt;
|
|
305
|
+
return {
|
|
306
|
+
...receipt,
|
|
307
|
+
entries: receipt.entries.map((entry) => ({
|
|
308
|
+
...entry,
|
|
309
|
+
beforeValue: redactMcpNativeValue(entry.beforeValue),
|
|
310
|
+
value: redactMcpNativeValue(entry.value)
|
|
311
|
+
}))
|
|
312
|
+
};
|
|
313
|
+
}
|
|
278
314
|
function readCurrentHarnessIntegrationReceipt(targetRoot, storeRoot, scope, harnessId, connectionMethod) {
|
|
279
315
|
const currentId = currentReceiptRecordId(scope, harnessId, connectionMethod);
|
|
280
316
|
if (scope === "project") {
|
|
@@ -318,7 +354,7 @@ function isHarnessIntegrationReceipt(value) {
|
|
|
318
354
|
function isStoredHarnessIntegrationReceipt(value) {
|
|
319
355
|
if (!isRecord(value)) return false;
|
|
320
356
|
const adapter = typeof value.harnessId === "string" ? getFirstPartyHarnessAdapter(value.harnessId) : void 0;
|
|
321
|
-
return (value.schemaVersion === 1 || value.schemaVersion === 2) && isSafeId(value.operationId) && adapter !== void 0 && value.adapterId === adapter.id && Number.isSafeInteger(value.adapterVersion) && Number(value.adapterVersion) > 0 && (value.connectionMethod === "mcp" || value.connectionMethod === "command-rules" || value.connectionMethod === "permission-rules") && (value.scope === "machine" || value.scope === "project") && (value.schemaVersion === 1 ? isExecutable(value.executable) : value.executable === void 0) && isSafeId(value.appliedVersion) && isTimestamp(value.verifiedAt) && Array.isArray(value.entries) && value.entries.length > 0 && value.entries.every(isReceiptEntry) && (value.result === "verified" || value.result === "failed" || value.result === "partial") && (value.verificationResult === "passed" || value.verificationResult === "failed" || value.verificationResult === "blocked") && (value.driftState === "current" || value.driftState === "missing" || value.driftState === "drifted" || value.driftState === "unsupported" || value.driftState === "blocked") && (value.recoveryStatus === "complete" || value.recoveryStatus === "incomplete" || value.recoveryStatus === "recovery-required");
|
|
357
|
+
return (value.schemaVersion === 1 || value.schemaVersion === 2) && isSafeId(value.operationId) && adapter !== void 0 && value.adapterId === adapter.id && Number.isSafeInteger(value.adapterVersion) && Number(value.adapterVersion) > 0 && (value.connectionMethod === "mcp" || value.connectionMethod === "command-rules" || value.connectionMethod === "permission-rules") && (value.scope === "machine" || value.scope === "project") && (value.schemaVersion === 1 ? isExecutable(value.executable) : value.executable === void 0) && isSafeId(value.appliedVersion) && isTimestamp(value.verifiedAt) && Array.isArray(value.entries) && value.entries.length > 0 && value.entries.every((entry) => isReceiptEntry(entry, value.connectionMethod)) && (value.result === "verified" || value.result === "failed" || value.result === "partial") && (value.verificationResult === "passed" || value.verificationResult === "failed" || value.verificationResult === "blocked") && (value.driftState === "current" || value.driftState === "missing" || value.driftState === "drifted" || value.driftState === "unsupported" || value.driftState === "blocked") && (value.recoveryStatus === "complete" || value.recoveryStatus === "incomplete" || value.recoveryStatus === "recovery-required");
|
|
322
358
|
}
|
|
323
359
|
function isExecutable(value) {
|
|
324
360
|
if (!isRecord(value)) return false;
|
|
@@ -328,8 +364,9 @@ function isExecutable(value) {
|
|
|
328
364
|
path3.resolve(String(value.packageRoot), String(value.binRelativePath))
|
|
329
365
|
);
|
|
330
366
|
}
|
|
331
|
-
function isReceiptEntry(value) {
|
|
332
|
-
|
|
367
|
+
function isReceiptEntry(value, method) {
|
|
368
|
+
const matches = (entry, fingerprint) => fingerprint === fingerprintEntry(entry) || method === "mcp" && isRedactedMcpNativeValue(entry) && isSha256(fingerprint);
|
|
369
|
+
return isRecord(value) && isSafeNativePath(value.path) && isSafeId(value.entryId) && value.ownership === "make-docs" && isNullableSha256(value.beforeEntryFingerprint) && isNullableSha256(value.beforeFileFingerprint) && isNativeValueOrNull(value.beforeValue) && isSha256(value.entryFingerprint) && isSha256(value.fileFingerprint) && isNativeValue(value.value) && matches(value.value, value.entryFingerprint) && (value.beforeValue === null ? value.beforeEntryFingerprint === null : matches(value.beforeValue, value.beforeEntryFingerprint));
|
|
333
370
|
}
|
|
334
371
|
function isSafeNativePath(value) {
|
|
335
372
|
if (typeof value !== "string" || value.length === 0 || /[\r\n\0]/.test(value)) return false;
|
|
@@ -407,6 +444,7 @@ function prepareHarnessSystemOperation(input) {
|
|
|
407
444
|
input.plan.connectionMethod
|
|
408
445
|
) : null;
|
|
409
446
|
assertReviewedPlan(input.plan, input.adapterId, input.harnessId, ownershipReceipt);
|
|
447
|
+
const durablePlan = redactHarnessPlan(input.plan);
|
|
410
448
|
if (!input.appliedVersion.trim()) throw new Error("Machine setup needs an applied version.");
|
|
411
449
|
if (!Number.isFinite(Date.parse(input.verifiedAt))) {
|
|
412
450
|
throw new Error("Machine setup needs a valid verification time.");
|
|
@@ -419,11 +457,11 @@ function prepareHarnessSystemOperation(input) {
|
|
|
419
457
|
harnessId: input.harnessId,
|
|
420
458
|
connectionMethod: input.plan.connectionMethod,
|
|
421
459
|
targetRoot,
|
|
422
|
-
plan:
|
|
423
|
-
planFingerprint: fingerprintJson(
|
|
460
|
+
plan: durablePlan,
|
|
461
|
+
planFingerprint: fingerprintJson(durablePlan),
|
|
424
462
|
appliedVersion: input.appliedVersion,
|
|
425
463
|
verifiedAt: input.verifiedAt,
|
|
426
|
-
ownershipReceipt
|
|
464
|
+
ownershipReceipt: ownershipReceipt ? redactHarnessIntegrationReceipt(ownershipReceipt) : null
|
|
427
465
|
};
|
|
428
466
|
const savedJson = JSON.stringify(pending);
|
|
429
467
|
withInstallationDatabase(targetRoot, (db) => {
|
|
@@ -481,7 +519,8 @@ function completeHarnessSystemOperation(targetRootInput, storeRootInput, pending
|
|
|
481
519
|
const targetRoot = canonicalInstallationPath(targetRootInput);
|
|
482
520
|
const storeRoot = validateInstallationStoreRoot(targetRoot, storeRootInput);
|
|
483
521
|
const exact = validatePending(pending, pending.operationId, targetRoot);
|
|
484
|
-
|
|
522
|
+
const durableReceipt = redactHarnessIntegrationReceipt(receipt);
|
|
523
|
+
assertReceiptMatchesPlan(durableReceipt, exact);
|
|
485
524
|
const pendingJson = JSON.stringify(exact);
|
|
486
525
|
withInstallationDatabase(targetRoot, (db) => {
|
|
487
526
|
db.exec("BEGIN IMMEDIATE");
|
|
@@ -490,7 +529,7 @@ function completeHarnessSystemOperation(targetRootInput, storeRootInput, pending
|
|
|
490
529
|
const storedReceipt = db.prepare(
|
|
491
530
|
"SELECT metadata_json FROM tool_operations WHERE operation_id=? AND operation='setup.system.receipt' AND status='completed'"
|
|
492
531
|
).get(`harness-receipt:${exact.operationId}`);
|
|
493
|
-
if (!storedReceipt || storedReceipt.metadata_json !== JSON.stringify(
|
|
532
|
+
if (!storedReceipt || storedReceipt.metadata_json !== JSON.stringify(durableReceipt)) {
|
|
494
533
|
throw new Error(
|
|
495
534
|
`Machine setup ${exact.operationId} has no exact verified Store receipt. Keep it pending for recovery.`
|
|
496
535
|
);
|
|
@@ -498,7 +537,7 @@ function completeHarnessSystemOperation(targetRootInput, storeRootInput, pending
|
|
|
498
537
|
const result = db.prepare(
|
|
499
538
|
"UPDATE tool_operations SET status='completed',metadata_json=?,finished_at=? WHERE operation_id=? AND operation=? AND status='pending' AND metadata_json=?"
|
|
500
539
|
).run(
|
|
501
|
-
JSON.stringify({ ...exact, receiptOperationId:
|
|
540
|
+
JSON.stringify({ ...exact, receiptOperationId: durableReceipt.operationId }),
|
|
502
541
|
receipt.verifiedAt,
|
|
503
542
|
exact.operationId,
|
|
504
543
|
OPERATION,
|
|
@@ -512,10 +551,40 @@ function completeHarnessSystemOperation(targetRootInput, storeRootInput, pending
|
|
|
512
551
|
}
|
|
513
552
|
}, { storeRoot });
|
|
514
553
|
}
|
|
554
|
+
function failHarnessSystemOperation(targetRootInput, storeRootInput, pending, failure) {
|
|
555
|
+
if (!failure.reason.trim() || failure.changeOutcome !== "none" && failure.changeOutcome !== "unknown") {
|
|
556
|
+
throw new Error("Machine setup failure needs a reason and a known change outcome.");
|
|
557
|
+
}
|
|
558
|
+
const targetRoot = canonicalInstallationPath(targetRootInput);
|
|
559
|
+
const storeRoot = validateInstallationStoreRoot(targetRoot, storeRootInput);
|
|
560
|
+
const exact = validatePending(pending, pending.operationId, targetRoot);
|
|
561
|
+
const pendingJson = JSON.stringify(exact);
|
|
562
|
+
withInstallationDatabase(targetRoot, (db) => {
|
|
563
|
+
db.exec("BEGIN IMMEDIATE");
|
|
564
|
+
try {
|
|
565
|
+
assertNoOtherStoreWork(db, targetRoot, exact.operationId);
|
|
566
|
+
const finishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
567
|
+
const result = db.prepare(
|
|
568
|
+
"UPDATE tool_operations SET status='failed',metadata_json=?,finished_at=? WHERE operation_id=? AND operation=? AND status='pending' AND metadata_json=?"
|
|
569
|
+
).run(
|
|
570
|
+
JSON.stringify({ ...exact, failure: { ...failure, failedAt: finishedAt } }),
|
|
571
|
+
finishedAt,
|
|
572
|
+
exact.operationId,
|
|
573
|
+
OPERATION,
|
|
574
|
+
pendingJson
|
|
575
|
+
);
|
|
576
|
+
if (result.changes !== 1) throw changedPending(exact.operationId);
|
|
577
|
+
db.exec("COMMIT");
|
|
578
|
+
} catch (error) {
|
|
579
|
+
db.exec("ROLLBACK");
|
|
580
|
+
throw error;
|
|
581
|
+
}
|
|
582
|
+
}, { storeRoot });
|
|
583
|
+
}
|
|
515
584
|
function validatePending(value, rowOperationId, expectedTargetRoot) {
|
|
516
585
|
if (!value || typeof value !== "object") throw invalidPending(rowOperationId);
|
|
517
586
|
const pending = value;
|
|
518
|
-
if (pending.schemaVersion !== 1 || pending.kind !== OPERATION || pending.operationId !== rowOperationId || typeof pending.adapterId !== "string" || pending.harnessId !== "codex" && pending.harnessId !== "claude-code" || typeof pending.targetRoot !== "string" || canonicalInstallationPath(pending.targetRoot) !== expectedTargetRoot || !pending.plan || typeof pending.plan !== "object" || typeof pending.planFingerprint !== "string" || typeof pending.appliedVersion !== "string" || !pending.appliedVersion.trim() || typeof pending.verifiedAt !== "string" || !Number.isFinite(Date.parse(pending.verifiedAt))) {
|
|
587
|
+
if (pending.schemaVersion !== 1 || pending.kind !== OPERATION || pending.operationId !== rowOperationId || typeof pending.adapterId !== "string" || pending.harnessId !== "codex" && pending.harnessId !== "claude-code" && pending.harnessId !== "github-copilot" || typeof pending.targetRoot !== "string" || canonicalInstallationPath(pending.targetRoot) !== expectedTargetRoot || !pending.plan || typeof pending.plan !== "object" || typeof pending.planFingerprint !== "string" || typeof pending.appliedVersion !== "string" || !pending.appliedVersion.trim() || typeof pending.verifiedAt !== "string" || !Number.isFinite(Date.parse(pending.verifiedAt))) {
|
|
519
588
|
throw invalidPending(rowOperationId);
|
|
520
589
|
}
|
|
521
590
|
if (pending.ownershipReceipt !== null && typeof pending.ownershipReceipt !== "object") {
|
|
@@ -536,7 +605,7 @@ function assertReviewedPlan(plan, adapterId, harnessId, ownershipReceipt) {
|
|
|
536
605
|
if (plan.schemaVersion !== 1 || plan.kind !== "apply" || plan.adapterId !== adapterId || plan.harnessId !== harnessId || plan.scope !== "machine" || !path4.isAbsolute(plan.root) || path4.normalize(plan.root) !== plan.root || !/^[0-9a-f]{64}$/.test(plan.reviewFingerprint) || plan.state === "blocked" || plan.state === "unsupported" || !Array.isArray(plan.changes) || plan.changes.length === 0) {
|
|
537
606
|
throw new Error("Machine setup needs one exact reviewed machine harness plan.");
|
|
538
607
|
}
|
|
539
|
-
for (const change of plan.changes) assertReviewedChange(plan.root, change);
|
|
608
|
+
for (const change of plan.changes) assertReviewedChange(plan.root, change, plan.connectionMethod);
|
|
540
609
|
if (plan.state === "drifted") {
|
|
541
610
|
assertReceiptOwnedDrift(plan, ownershipReceipt);
|
|
542
611
|
} else if (ownershipReceipt !== null) {
|
|
@@ -550,7 +619,7 @@ function assertReceiptOwnedDrift(plan, receipt) {
|
|
|
550
619
|
for (let index = 0; index < plan.changes.length; index++) {
|
|
551
620
|
const change = plan.changes[index];
|
|
552
621
|
const entry = receipt.entries[index];
|
|
553
|
-
if (change.action !== "update" || change.ownership !== "make-docs-owned" || change.blockedReason || entry.ownership !== "make-docs" || entry.path !== change.path || entry.entryId !== change.entryId || entry.entryFingerprint !== change.beforeEntryFingerprint || JSON.stringify(entry.value) !== JSON.stringify(change.beforeEntryValue) ||
|
|
622
|
+
if (change.action !== "update" || change.ownership !== "make-docs-owned" || change.blockedReason || entry.ownership !== "make-docs" || entry.path !== change.path || entry.entryId !== change.entryId || entry.entryFingerprint !== change.beforeEntryFingerprint || JSON.stringify(redactMcpNativeValue(entry.value)) !== JSON.stringify(redactMcpNativeValue(change.beforeEntryValue)) || !entryMatches(entry.value, entry.entryFingerprint, plan.connectionMethod)) {
|
|
554
623
|
throw new Error(
|
|
555
624
|
`Drift repair target ${change.path} is not the exact receipt-owned native entry.`
|
|
556
625
|
);
|
|
@@ -563,15 +632,23 @@ function assertDurableOwnershipReceipt(db, pending) {
|
|
|
563
632
|
const row = db.prepare(
|
|
564
633
|
"SELECT metadata_json FROM tool_operations WHERE operation_id=? AND operation='setup.system.receipt' AND status='completed'"
|
|
565
634
|
).get(`harness-receipt:${receipt.operationId}`);
|
|
566
|
-
|
|
635
|
+
let savedReceipt = null;
|
|
636
|
+
if (row) {
|
|
637
|
+
try {
|
|
638
|
+
savedReceipt = JSON.parse(row.metadata_json);
|
|
639
|
+
} catch {
|
|
640
|
+
savedReceipt = null;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
if (!isHarnessIntegrationReceipt(savedReceipt) || JSON.stringify(redactHarnessIntegrationReceipt(savedReceipt)) !== JSON.stringify(receipt)) {
|
|
567
644
|
throw new Error(
|
|
568
645
|
`Pending machine setup ${pending.operationId} lost its exact ownership receipt. Preserve it for manual recovery.`
|
|
569
646
|
);
|
|
570
647
|
}
|
|
571
648
|
}
|
|
572
|
-
function assertReviewedChange(root, change) {
|
|
649
|
+
function assertReviewedChange(root, change, method) {
|
|
573
650
|
const resolved = path4.resolve(root, change.path);
|
|
574
|
-
if (!change.path || path4.isAbsolute(change.path) || resolved !== root && !resolved.startsWith(`${root}${path4.sep}`) || !(/* @__PURE__ */ new Set(["create", "update", "remove", "none"])).has(change.action) || !(/* @__PURE__ */ new Set(["missing", "make-docs-owned", "unverified"])).has(change.ownership) || change.blockedReason || !isFingerprint(change.beforeFileFingerprint, true) || !isFingerprint(change.afterFileFingerprint, false) || !entryMatches(change.beforeEntryValue, change.beforeEntryFingerprint) || change.afterEntryValue === null || !entryMatches(change.afterEntryValue, change.afterEntryFingerprint)) {
|
|
651
|
+
if (!change.path || path4.isAbsolute(change.path) || resolved !== root && !resolved.startsWith(`${root}${path4.sep}`) || !(/* @__PURE__ */ new Set(["create", "update", "remove", "none"])).has(change.action) || !(/* @__PURE__ */ new Set(["missing", "make-docs-owned", "unverified"])).has(change.ownership) || change.blockedReason || !isFingerprint(change.beforeFileFingerprint, true) || !isFingerprint(change.afterFileFingerprint, false) || !entryMatches(change.beforeEntryValue, change.beforeEntryFingerprint, method) || change.afterEntryValue === null || !entryMatches(change.afterEntryValue, change.afterEntryFingerprint, method)) {
|
|
575
652
|
throw new Error(`Machine setup has an unsafe or incomplete reviewed change: ${change.path}.`);
|
|
576
653
|
}
|
|
577
654
|
}
|
|
@@ -583,7 +660,7 @@ function assertReceiptMatchesPlan(receipt, pending) {
|
|
|
583
660
|
for (let index = 0; index < plan.changes.length; index++) {
|
|
584
661
|
const change = plan.changes[index];
|
|
585
662
|
const entry = receipt.entries[index];
|
|
586
|
-
if (entry.path !== change.path || entry.entryId !== change.entryId || entry.ownership !== "make-docs" || entry.beforeEntryFingerprint !== change.beforeEntryFingerprint || entry.beforeFileFingerprint !== change.beforeFileFingerprint || JSON.stringify(entry.beforeValue) !== JSON.stringify(change.beforeEntryValue) || entry.entryFingerprint !== change.afterEntryFingerprint || entry.fileFingerprint !== change.afterFileFingerprint || JSON.stringify(entry.value) !== JSON.stringify(change.afterEntryValue) ||
|
|
663
|
+
if (entry.path !== change.path || entry.entryId !== change.entryId || entry.ownership !== "make-docs" || entry.beforeEntryFingerprint !== change.beforeEntryFingerprint || entry.beforeFileFingerprint !== change.beforeFileFingerprint || JSON.stringify(entry.beforeValue) !== JSON.stringify(change.beforeEntryValue) || entry.entryFingerprint !== change.afterEntryFingerprint || entry.fileFingerprint !== change.afterFileFingerprint || JSON.stringify(entry.value) !== JSON.stringify(change.afterEntryValue) || !entryMatches(entry.value, entry.entryFingerprint, pending.connectionMethod)) {
|
|
587
664
|
throw new Error(`Machine setup receipt changed reviewed target ${change.path}.`);
|
|
588
665
|
}
|
|
589
666
|
}
|
|
@@ -609,8 +686,19 @@ function assertNoOtherStoreWork(db, targetRoot, ownOperationId) {
|
|
|
609
686
|
);
|
|
610
687
|
}
|
|
611
688
|
}
|
|
612
|
-
function entryMatches(value, fingerprint) {
|
|
613
|
-
return value === null ? fingerprint === null : fingerprint === fingerprintEntry(value);
|
|
689
|
+
function entryMatches(value, fingerprint, method) {
|
|
690
|
+
return value === null ? fingerprint === null : fingerprint === fingerprintEntry(value) || method === "mcp" && isRedactedMcpNativeValue(value) && isFingerprint(fingerprint, false);
|
|
691
|
+
}
|
|
692
|
+
function redactHarnessPlan(plan) {
|
|
693
|
+
if (plan.connectionMethod !== "mcp") return plan;
|
|
694
|
+
return {
|
|
695
|
+
...plan,
|
|
696
|
+
changes: plan.changes.map((change) => ({
|
|
697
|
+
...change,
|
|
698
|
+
beforeEntryValue: redactMcpNativeValue(change.beforeEntryValue),
|
|
699
|
+
afterEntryValue: redactMcpNativeValue(change.afterEntryValue)
|
|
700
|
+
}))
|
|
701
|
+
};
|
|
614
702
|
}
|
|
615
703
|
function isFingerprint(value, allowNull) {
|
|
616
704
|
return allowNull && value === null || typeof value === "string" && /^[0-9a-f]{64}$/.test(value);
|
|
@@ -1003,16 +1091,6 @@ function listWorkEvidence(db, filter) {
|
|
|
1003
1091
|
|
|
1004
1092
|
// src/store/lifecycle-runs.ts
|
|
1005
1093
|
import { createHash as createHash2 } from "crypto";
|
|
1006
|
-
|
|
1007
|
-
// src/operations/types.ts
|
|
1008
|
-
var OperationError = class extends Error {
|
|
1009
|
-
constructor(message) {
|
|
1010
|
-
super(message);
|
|
1011
|
-
this.name = "OperationError";
|
|
1012
|
-
}
|
|
1013
|
-
};
|
|
1014
|
-
|
|
1015
|
-
// src/store/lifecycle-runs.ts
|
|
1016
1094
|
var LIFECYCLE_STAGES = [
|
|
1017
1095
|
"design",
|
|
1018
1096
|
"plan",
|
|
@@ -1570,6 +1648,7 @@ export {
|
|
|
1570
1648
|
readCurrentHarnessIntegrationReceipt,
|
|
1571
1649
|
prepareHarnessSystemOperation,
|
|
1572
1650
|
readPendingHarnessSystemOperation,
|
|
1573
|
-
completeHarnessSystemOperation
|
|
1651
|
+
completeHarnessSystemOperation,
|
|
1652
|
+
failHarnessSystemOperation
|
|
1574
1653
|
};
|
|
1575
|
-
//# sourceMappingURL=chunk-
|
|
1654
|
+
//# sourceMappingURL=chunk-TDB6UW4M.js.map
|