@lannguyensi/harness 0.59.1 → 0.60.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/CHANGELOG.md +51 -1
- package/README.md +1 -1
- package/dist/cli/apply/apply.d.ts +20 -0
- package/dist/cli/apply/apply.js +13 -7
- package/dist/cli/apply/apply.js.map +1 -1
- package/dist/cli/apply/install-codex-config.d.ts +113 -2
- package/dist/cli/apply/install-codex-config.js +651 -69
- package/dist/cli/apply/install-codex-config.js.map +1 -1
- package/dist/cli/approve/understanding.js +34 -28
- package/dist/cli/approve/understanding.js.map +1 -1
- package/dist/cli/doctor/format.js +22 -0
- package/dist/cli/doctor/format.js.map +1 -1
- package/dist/cli/doctor/index.js +60 -31
- package/dist/cli/doctor/index.js.map +1 -1
- package/dist/cli/doctor/types.d.ts +17 -0
- package/dist/cli/dry-run.js +7 -0
- package/dist/cli/dry-run.js.map +1 -1
- package/dist/cli/index.js +46 -144
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/pack/auto-approve-path.js +25 -11
- package/dist/cli/pack/auto-approve-path.js.map +1 -1
- package/dist/cli/pack/hook-codex-post-tool-use.js +2 -2
- package/dist/cli/pack/hook-codex-post-tool-use.js.map +1 -1
- package/dist/cli/pack/hook-codex-pre-tool-use.js +32 -5
- package/dist/cli/pack/hook-codex-pre-tool-use.js.map +1 -1
- package/dist/cli/pack/hook-post-merge-gate-record.d.ts +7 -0
- package/dist/cli/pack/hook-post-merge-gate-record.js +39 -2
- package/dist/cli/pack/hook-post-merge-gate-record.js.map +1 -1
- package/dist/cli/pack/hook-post-tool-use.js +2 -2
- package/dist/cli/pack/hook-post-tool-use.js.map +1 -1
- package/dist/cli/pack/hook-pre-tool-use.js +60 -15
- package/dist/cli/pack/hook-pre-tool-use.js.map +1 -1
- package/dist/cli/policy/intercept.js +5 -1
- package/dist/cli/policy/intercept.js.map +1 -1
- package/dist/cli/record/index.d.ts +11 -2
- package/dist/cli/record/index.js +18 -5
- package/dist/cli/record/index.js.map +1 -1
- package/dist/cli/session-start/branch-check.d.ts +3 -29
- package/dist/cli/session-start/branch-check.js +7 -37
- package/dist/cli/session-start/branch-check.js.map +1 -1
- package/dist/cli/session-start/index.d.ts +16 -30
- package/dist/cli/session-start/index.js +72 -26
- package/dist/cli/session-start/index.js.map +1 -1
- package/dist/cli/session-start/shared-options.d.ts +92 -0
- package/dist/cli/session-start/shared-options.js +109 -0
- package/dist/cli/session-start/shared-options.js.map +1 -0
- package/dist/cli/session-start/stale-base-check.d.ts +3 -28
- package/dist/cli/session-start/stale-base-check.js +7 -37
- package/dist/cli/session-start/stale-base-check.js.map +1 -1
- package/dist/cli/session-start/toolchain-parity.d.ts +5 -21
- package/dist/cli/session-start/toolchain-parity.js +6 -38
- package/dist/cli/session-start/toolchain-parity.js.map +1 -1
- package/dist/cli/smoke/index.d.ts +1 -1
- package/dist/cli/smoke/index.js +8 -11
- package/dist/cli/smoke/index.js.map +1 -1
- package/dist/policy-packs/builtin/post-merge-gate-runtime.d.ts +11 -0
- package/dist/policy-packs/builtin/post-merge-gate-runtime.js +11 -0
- package/dist/policy-packs/builtin/post-merge-gate-runtime.js.map +1 -1
- package/dist/policy-packs/builtin/solution-acceptance-runtime.js +1 -1
- package/dist/policy-packs/builtin/solution-acceptance-runtime.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution/expiry-reason.d.ts +36 -0
- package/dist/policy-packs/builtin/understanding-before-execution/expiry-reason.js +73 -0
- package/dist/policy-packs/builtin/understanding-before-execution/expiry-reason.js.map +1 -0
- package/dist/policy-packs/builtin/understanding-before-execution/index.d.ts +3 -2
- package/dist/policy-packs/builtin/understanding-before-execution/index.js +5 -2
- package/dist/policy-packs/builtin/understanding-before-execution/index.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution/markers.js +1 -0
- package/dist/policy-packs/builtin/understanding-before-execution/markers.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.d.ts +205 -1
- package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.js +360 -3
- package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.d.ts +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.js +2 -2
- package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution/task-markers.d.ts +36 -0
- package/dist/policy-packs/builtin/understanding-before-execution/task-markers.js +50 -0
- package/dist/policy-packs/builtin/understanding-before-execution/task-markers.js.map +1 -1
- package/dist/runtime/bash-prefix-parse.js +319 -126
- package/dist/runtime/bash-prefix-parse.js.map +1 -1
- package/dist/runtime/intercept.d.ts +38 -0
- package/dist/runtime/intercept.js +224 -5
- package/dist/runtime/intercept.js.map +1 -1
- package/dist/runtime/read-only-bash.js +11 -1
- package/dist/runtime/read-only-bash.js.map +1 -1
- package/dist/runtime/shell-word.d.ts +16 -1
- package/dist/runtime/shell-word.js +82 -1
- package/dist/runtime/shell-word.js.map +1 -1
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ import * as fs from "node:fs";
|
|
|
14
14
|
import * as path from "node:path";
|
|
15
15
|
import { atomicWriteFile } from "../../../io/atomic-write.js";
|
|
16
16
|
import { safeJsonParse } from "../../../io/safe-json-parse.js";
|
|
17
|
+
import { sha256Hex } from "../../../runtime/approval-signing.js";
|
|
17
18
|
const DEFAULT_REPORTS_DIRNAME = ".understanding-gate";
|
|
18
19
|
const REPORTS_SUBDIR = "reports";
|
|
19
20
|
/**
|
|
@@ -86,6 +87,8 @@ function readPersistedReport(filePath, mtimeMs) {
|
|
|
86
87
|
sessionId: typeof obj["sessionId"] === "string" ? obj["sessionId"] : null,
|
|
87
88
|
approvalStatus: typeof obj["approvalStatus"] === "string" ? obj["approvalStatus"] : null,
|
|
88
89
|
approvedAt: typeof obj["approvedAt"] === "string" ? obj["approvedAt"] : null,
|
|
90
|
+
expiredBy: typeof obj["expiredBy"] === "string" ? obj["expiredBy"] : null,
|
|
91
|
+
expiredAt: typeof obj["expiredAt"] === "string" ? obj["expiredAt"] : null,
|
|
89
92
|
createdAt,
|
|
90
93
|
createdAtMs,
|
|
91
94
|
};
|
|
@@ -265,7 +268,7 @@ const DETAIL_VALUE_MAX_LENGTH = 120;
|
|
|
265
268
|
* forge extra `reason:`-looking lines) are replaced with a space and
|
|
266
269
|
* the result is capped so one field cannot blow out the surface.
|
|
267
270
|
*/
|
|
268
|
-
function sanitizeDetailValue(value) {
|
|
271
|
+
export function sanitizeDetailValue(value) {
|
|
269
272
|
// Deliberately strips C0/DEL control characters (including newline,
|
|
270
273
|
// which could otherwise forge an extra `reason:`-looking stderr line).
|
|
271
274
|
const flattened = value.replace(/[\x00-\x1f\x7f]/g, " ");
|
|
@@ -292,7 +295,7 @@ function sanitizeDetailValue(value) {
|
|
|
292
295
|
* best-effort cleanup so a missing report dir or unrelated I/O issue
|
|
293
296
|
* does not escalate into a session-breaking hook failure.
|
|
294
297
|
*/
|
|
295
|
-
export function expirePersistedReport(reportsDir, sessionId, now = new Date()) {
|
|
298
|
+
export function expirePersistedReport(reportsDir, sessionId, now = new Date(), trigger) {
|
|
296
299
|
const reports = listPersistedReports(reportsDir);
|
|
297
300
|
if (reports.length === 0) {
|
|
298
301
|
return { ok: false, reason: `no reports under ${reportsDir}` };
|
|
@@ -327,6 +330,13 @@ export function expirePersistedReport(reportsDir, sessionId, now = new Date()) {
|
|
|
327
330
|
const previousStatus = typeof parsed["approvalStatus"] === "string" ? parsed["approvalStatus"] : null;
|
|
328
331
|
parsed["approvalStatus"] = "expired";
|
|
329
332
|
parsed["expiredAt"] = now.toISOString();
|
|
333
|
+
if (trigger !== undefined && trigger !== "") {
|
|
334
|
+
parsed["expiredBy"] = trigger;
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
// No event to record: drop a stale one from an earlier expiry.
|
|
338
|
+
delete parsed["expiredBy"];
|
|
339
|
+
}
|
|
330
340
|
try {
|
|
331
341
|
atomicWriteFile(latest.filePath, `${JSON.stringify(parsed, null, 2)}\n`);
|
|
332
342
|
}
|
|
@@ -374,9 +384,11 @@ export function checkPersistedReport(reportsDir, sessionId) {
|
|
|
374
384
|
}
|
|
375
385
|
const safeFileName = sanitizeDetailValue(path.basename(latest.filePath));
|
|
376
386
|
if (latest.approvalStatus !== "approved") {
|
|
387
|
+
const boundaryExpiry = describeBoundaryExpiry(latest);
|
|
388
|
+
const expirySuffix = boundaryExpiry !== undefined ? `; ${boundaryExpiry}` : "";
|
|
377
389
|
return {
|
|
378
390
|
claimsApproved: false,
|
|
379
|
-
detail: `latest report ${safeFileName} has approvalStatus=${sanitizeDetailValue(latest.approvalStatus ?? "<missing>")}`,
|
|
391
|
+
detail: `latest report ${safeFileName} has approvalStatus=${sanitizeDetailValue(latest.approvalStatus ?? "<missing>")}${expirySuffix}`,
|
|
380
392
|
report: latest,
|
|
381
393
|
};
|
|
382
394
|
}
|
|
@@ -390,4 +402,349 @@ export function checkPersistedReport(reportsDir, sessionId) {
|
|
|
390
402
|
report: latest,
|
|
391
403
|
};
|
|
392
404
|
}
|
|
405
|
+
/**
|
|
406
|
+
* `approval expired because <event> at <time>` for a report a PostToolUse
|
|
407
|
+
* boundary expired (`expirePersistedReport` stamps `expiredBy` and
|
|
408
|
+
* `expiredAt`), `undefined` for any other report, including an older one or
|
|
409
|
+
* one a package producer wrote that carries no `expiredBy`. Both values come
|
|
410
|
+
* from a JSON file the gated agent can write, so both pass
|
|
411
|
+
* `sanitizeDetailValue`.
|
|
412
|
+
*/
|
|
413
|
+
export function describeBoundaryExpiry(report) {
|
|
414
|
+
if (report.approvalStatus !== "expired")
|
|
415
|
+
return undefined;
|
|
416
|
+
if (report.expiredBy === null || report.expiredBy === "")
|
|
417
|
+
return undefined;
|
|
418
|
+
const when = report.expiredAt !== null && report.expiredAt !== ""
|
|
419
|
+
? ` at ${sanitizeDetailValue(report.expiredAt)}`
|
|
420
|
+
: "";
|
|
421
|
+
return `approval expired because ${sanitizeDetailValue(report.expiredBy)}${when}`;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Report fields the approval and expiry lifecycles rewrite. They are left
|
|
425
|
+
* out of {@link canonicalReportHash}: `rewriteReportApproved` flips
|
|
426
|
+
* `approvalStatus`/`approvedAt`/`approvedBy`, may stamp `sessionId`, and
|
|
427
|
+
* drops `expiredAt`/`expiredBy`; `expirePersistedReport` later sets
|
|
428
|
+
* `approvalStatus`/`expiredAt`/`expiredBy` again. The hash must survive all
|
|
429
|
+
* of that for an untouched report, so it covers only the content the
|
|
430
|
+
* operator actually reviewed.
|
|
431
|
+
*/
|
|
432
|
+
const LIFECYCLE_REPORT_FIELDS = new Set([
|
|
433
|
+
"approvalStatus",
|
|
434
|
+
"approvedAt",
|
|
435
|
+
"approvedBy",
|
|
436
|
+
"expiredAt",
|
|
437
|
+
"expiredBy",
|
|
438
|
+
"sessionId",
|
|
439
|
+
]);
|
|
440
|
+
/**
|
|
441
|
+
* Deepest array/object nesting {@link canonicalReportHash} serialises (the
|
|
442
|
+
* report object itself is level 1). `sortKeysDeep` and `JSON.stringify`
|
|
443
|
+
* recurse once per level, and any agent-written `*.json` file in the reports
|
|
444
|
+
* directory reaches them through the gate-read scan, so without a bound a
|
|
445
|
+
* file nested a few thousand levels deep overflows the stack and the hook
|
|
446
|
+
* process dies instead of deciding. A real report nests a handful of levels.
|
|
447
|
+
*/
|
|
448
|
+
const MAX_CANONICAL_REPORT_DEPTH = 64;
|
|
449
|
+
/**
|
|
450
|
+
* Largest report file, in bytes, the canonical hash reads from disk (1 MiB).
|
|
451
|
+
* Every `*.json` entry of the reports directory reaches the hash through the
|
|
452
|
+
* gate-read scan, and the agent can write that directory, so without a bound
|
|
453
|
+
* a planted file of a few hundred megabytes made the hook run out of heap or
|
|
454
|
+
* past its time budget instead of deciding (a hook that dies or overruns is a
|
|
455
|
+
* non-blocking error for the runtime). A real report is a few kilobytes, far
|
|
456
|
+
* below the cap. A file over the cap matches nothing at gate read, and both
|
|
457
|
+
* producers refuse to approve such a report.
|
|
458
|
+
*/
|
|
459
|
+
export const MAX_HASHED_REPORT_BYTES = 1024 * 1024;
|
|
460
|
+
/**
|
|
461
|
+
* Iterative walk over the arrays and objects of `value` (the value itself is
|
|
462
|
+
* level 1) that stops at the first one nested deeper than `max` levels.
|
|
463
|
+
* Iterative, so the walk itself cannot overflow the stack. Only arrays and
|
|
464
|
+
* objects are pushed: a scalar child (string, number, boolean, null) cannot
|
|
465
|
+
* nest, so a wide array of scalars costs no stack slot per element, and
|
|
466
|
+
* `visited` counts the root plus the containers below it. Exported for tests.
|
|
467
|
+
*/
|
|
468
|
+
export function walkContainerDepth(value, max) {
|
|
469
|
+
const nodes = [value];
|
|
470
|
+
const depths = [1];
|
|
471
|
+
let visited = 0;
|
|
472
|
+
while (nodes.length > 0) {
|
|
473
|
+
const node = nodes.pop();
|
|
474
|
+
const depth = depths.pop() ?? 1;
|
|
475
|
+
visited += 1;
|
|
476
|
+
if (node === null || typeof node !== "object")
|
|
477
|
+
continue;
|
|
478
|
+
if (depth > max)
|
|
479
|
+
return { tooDeep: true, visited };
|
|
480
|
+
for (const child of Array.isArray(node) ? node : Object.values(node)) {
|
|
481
|
+
if (child !== null && typeof child === "object") {
|
|
482
|
+
nodes.push(child);
|
|
483
|
+
depths.push(depth + 1);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return { tooDeep: false, visited };
|
|
488
|
+
}
|
|
489
|
+
/** True when `value` nests arrays/objects deeper than `max` levels. */
|
|
490
|
+
function nestsDeeperThan(value, max) {
|
|
491
|
+
return walkContainerDepth(value, max).tooDeep;
|
|
492
|
+
}
|
|
493
|
+
function sortKeysDeep(value) {
|
|
494
|
+
if (Array.isArray(value))
|
|
495
|
+
return value.map(sortKeysDeep);
|
|
496
|
+
if (value !== null && typeof value === "object") {
|
|
497
|
+
const entries = Object.entries(value)
|
|
498
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
499
|
+
.map(([k, v]) => [k, sortKeysDeep(v)]);
|
|
500
|
+
// `Object.fromEntries` defines own properties, so a report key named
|
|
501
|
+
// `__proto__` stays data instead of re-parenting the copy.
|
|
502
|
+
return Object.fromEntries(entries);
|
|
503
|
+
}
|
|
504
|
+
return value;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* The hash an approval marker signs as its `reportContentHash`, and the one
|
|
508
|
+
* the gate recomputes at read time (task fa423e9b): sha256 over a key-sorted
|
|
509
|
+
* JSON serialisation of the parsed report with the lifecycle fields in
|
|
510
|
+
* `LIFECYCLE_REPORT_FIELDS` removed. A raw-bytes hash cannot do this job: the
|
|
511
|
+
* producers hash before `rewriteReportApproved` re-serialises the file and
|
|
512
|
+
* `expirePersistedReport` rewrites it again, so the raw bytes of an untouched
|
|
513
|
+
* report never match what the marker signed. One function on purpose, shared
|
|
514
|
+
* by both producers (`harness approve understanding`, the auto-approval path)
|
|
515
|
+
* and the verifier.
|
|
516
|
+
*
|
|
517
|
+
* Total: returns null instead of throwing for a report nested deeper than
|
|
518
|
+
* `MAX_CANONICAL_REPORT_DEPTH`. The verifier counts such a file as one that
|
|
519
|
+
* matches nothing; both producers refuse to approve such a report, so no
|
|
520
|
+
* marker is ever signed without a content binding because of it. Report
|
|
521
|
+
* files reach it only after {@link readReportFileBounded} bounded their type
|
|
522
|
+
* and size (the gate-read scan and `harness approve understanding` through
|
|
523
|
+
* {@link hashReportFile}, the auto-approval path directly).
|
|
524
|
+
*/
|
|
525
|
+
export function canonicalReportHash(report) {
|
|
526
|
+
// `Object.fromEntries` (not `kept[key] = value`): a report key named
|
|
527
|
+
// `__proto__` must stay hashed data, not re-parent the copy and vanish.
|
|
528
|
+
const kept = Object.fromEntries(Object.entries(report).filter(([key]) => !LIFECYCLE_REPORT_FIELDS.has(key)));
|
|
529
|
+
if (nestsDeeperThan(kept, MAX_CANONICAL_REPORT_DEPTH))
|
|
530
|
+
return null;
|
|
531
|
+
return sha256Hex(JSON.stringify(sortKeysDeep(kept)));
|
|
532
|
+
}
|
|
533
|
+
function errorCode(err) {
|
|
534
|
+
const code = err?.code;
|
|
535
|
+
return typeof code === "string" ? code : String(err);
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Read a report file for hashing, bounded by type and size. This is the one
|
|
539
|
+
* read every canonical report hash goes through: the gate-read scan (via
|
|
540
|
+
* {@link hashReportFile}) and both producers. The path is opened once,
|
|
541
|
+
* read-only and non-blocking (`O_NONBLOCK`: opening a FIFO with no writer
|
|
542
|
+
* returns at once instead of waiting for one); its type and size come from
|
|
543
|
+
* `fstat` on that descriptor, and the content is read through the same
|
|
544
|
+
* descriptor, so nothing can be swapped in between (no separate stat of the
|
|
545
|
+
* path, which a symlink flipped to a FIFO used to race). Refused without
|
|
546
|
+
* reading: anything that is not a regular file, and a file larger than
|
|
547
|
+
* `MAX_HASHED_REPORT_BYTES`. The read stops one byte past the fstat size
|
|
548
|
+
* (never more than the cap plus one byte); a file that grows into that byte
|
|
549
|
+
* while being read is refused too. The descriptor is always closed. Never
|
|
550
|
+
* throws.
|
|
551
|
+
*/
|
|
552
|
+
export function readReportFileBounded(filePath) {
|
|
553
|
+
let fd;
|
|
554
|
+
try {
|
|
555
|
+
fd = fs.openSync(filePath, fs.constants.O_RDONLY | fs.constants.O_NONBLOCK);
|
|
556
|
+
}
|
|
557
|
+
catch (err) {
|
|
558
|
+
return { ok: false, reason: "unreadable", detail: `could not be opened (${errorCode(err)})` };
|
|
559
|
+
}
|
|
560
|
+
try {
|
|
561
|
+
const stat = fs.fstatSync(fd);
|
|
562
|
+
if (!stat.isFile())
|
|
563
|
+
return { ok: false, reason: "not-regular", detail: "not a regular file" };
|
|
564
|
+
if (stat.size > MAX_HASHED_REPORT_BYTES) {
|
|
565
|
+
return {
|
|
566
|
+
ok: false,
|
|
567
|
+
reason: "too-large",
|
|
568
|
+
detail: `${stat.size} bytes, over the ${MAX_HASHED_REPORT_BYTES}-byte cap for hashing its content`,
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
const buf = Buffer.allocUnsafe(stat.size + 1);
|
|
572
|
+
let total = 0;
|
|
573
|
+
while (total < buf.length) {
|
|
574
|
+
const n = fs.readSync(fd, buf, total, buf.length - total, null);
|
|
575
|
+
if (n === 0)
|
|
576
|
+
break;
|
|
577
|
+
total += n;
|
|
578
|
+
}
|
|
579
|
+
if (total > stat.size)
|
|
580
|
+
return { ok: false, reason: "grew", detail: "grew while being read" };
|
|
581
|
+
return { ok: true, raw: buf.toString("utf8", 0, total) };
|
|
582
|
+
}
|
|
583
|
+
catch (err) {
|
|
584
|
+
return { ok: false, reason: "unreadable", detail: `could not be read (${errorCode(err)})` };
|
|
585
|
+
}
|
|
586
|
+
finally {
|
|
587
|
+
try {
|
|
588
|
+
fs.closeSync(fd);
|
|
589
|
+
}
|
|
590
|
+
catch {
|
|
591
|
+
// Already gone; nothing left to release.
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Canonical hash of the report file at `filePath`, read through
|
|
597
|
+
* {@link readReportFileBounded}, or why it has none: not a regular file, over
|
|
598
|
+
* `MAX_HASHED_REPORT_BYTES`, unreadable, grown while read, not a JSON object,
|
|
599
|
+
* or nested too deeply. `harness approve understanding` refuses a report on
|
|
600
|
+
* any of these (the `detail` is its message); the gate-read scan counts such
|
|
601
|
+
* a file as one that matches nothing. Never throws.
|
|
602
|
+
*/
|
|
603
|
+
export function hashReportFile(filePath) {
|
|
604
|
+
const read = readReportFileBounded(filePath);
|
|
605
|
+
if (!read.ok)
|
|
606
|
+
return read;
|
|
607
|
+
const parsed = safeJsonParse(read.raw);
|
|
608
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
609
|
+
return { ok: false, reason: "not-json-object", detail: "not a JSON object" };
|
|
610
|
+
}
|
|
611
|
+
const hash = canonicalReportHash(parsed);
|
|
612
|
+
if (hash === null) {
|
|
613
|
+
return { ok: false, reason: "too-deep", detail: "nested too deeply to hash its content" };
|
|
614
|
+
}
|
|
615
|
+
return { ok: true, hash };
|
|
616
|
+
}
|
|
617
|
+
/** Canonical hash of the report file at `filePath` ({@link hashReportFile}); null when it has none. */
|
|
618
|
+
export function canonicalReportHashOfFile(filePath) {
|
|
619
|
+
const hashed = hashReportFile(filePath);
|
|
620
|
+
return hashed.ok ? hashed.hash : null;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Hash every `*.json` entry of `dir` (any session, any `approvalStatus`)
|
|
624
|
+
* through {@link canonicalReportHashOfFile} and report which of the `wanted`
|
|
625
|
+
* hashes occur. Stops as soon as every wanted hash was found. Every entry
|
|
626
|
+
* counts as a report file; one that is not a regular file, is larger than
|
|
627
|
+
* `MAX_HASHED_REPORT_BYTES`, cannot be opened or read, grows while read, is
|
|
628
|
+
* not a JSON object, or nests too deeply matches nothing. The cost is linear
|
|
629
|
+
* in the number and size of the report files (each read at most up to the
|
|
630
|
+
* cap), and the usual allow path scans nearly all of them: the directory
|
|
631
|
+
* listing comes back in name order and report names start with a timestamp,
|
|
632
|
+
* so the approved (newest) report tends to come last.
|
|
633
|
+
*/
|
|
634
|
+
function scanReportHashes(dir, wanted) {
|
|
635
|
+
const scan = { files: 0, matched: new Set() };
|
|
636
|
+
let names;
|
|
637
|
+
try {
|
|
638
|
+
names = fs.readdirSync(dir);
|
|
639
|
+
}
|
|
640
|
+
catch {
|
|
641
|
+
return scan;
|
|
642
|
+
}
|
|
643
|
+
for (const name of names) {
|
|
644
|
+
if (!name.endsWith(".json"))
|
|
645
|
+
continue;
|
|
646
|
+
const full = path.join(dir, name);
|
|
647
|
+
scan.files += 1;
|
|
648
|
+
const hash = canonicalReportHashOfFile(full);
|
|
649
|
+
if (hash !== null && wanted.has(hash)) {
|
|
650
|
+
scan.matched.add(hash);
|
|
651
|
+
if (scan.matched.size === wanted.size)
|
|
652
|
+
break;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return scan;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Gate-read cross-check of a matched approval marker against the persisted
|
|
659
|
+
* reports (task fa423e9b). Both PreToolUse hooks call it after
|
|
660
|
+
* `checkOperatorApprovalMarkers` matched, through `verifyMatchedMarkerReport`.
|
|
661
|
+
*
|
|
662
|
+
* Rule: a marker with a non-null signed `reportContentHash` is valid iff at
|
|
663
|
+
* least one parseable report file in `reportsDir` (any session, any
|
|
664
|
+
* `approvalStatus`) has a canonical hash equal to it. The hash already
|
|
665
|
+
* leaves the lifecycle fields out, so approving, expiring or re-approving
|
|
666
|
+
* the report never changes it. The signed hash therefore proves one thing:
|
|
667
|
+
* the content the operator approved is still on disk unmodified. Editing
|
|
668
|
+
* that file (in place, by swap, by symlink, by an unparseable rewrite)
|
|
669
|
+
* removes the only match and the marker stops opening the gate. Comparing
|
|
670
|
+
* against the session's newest approved report instead would deny
|
|
671
|
+
* legitimate approvals (a newer report approved for the same claim, two
|
|
672
|
+
* sessions on one claim) and would let a swap pass by moving the swapped
|
|
673
|
+
* report out of the selection.
|
|
674
|
+
*
|
|
675
|
+
* Bounded input: only a regular file of at most `MAX_HASHED_REPORT_BYTES`
|
|
676
|
+
* (1 MiB) that parses as a JSON object nested at most 64 levels deep has a
|
|
677
|
+
* canonical hash, read through {@link readReportFileBounded} (opened
|
|
678
|
+
* non-blocking, typed and sized by `fstat` on the open descriptor, read
|
|
679
|
+
* through it). Every other `*.json` entry (a FIFO, a directory, a device, a
|
|
680
|
+
* symlink to one of them, a file over the cap, an unreadable, unparseable or
|
|
681
|
+
* too deeply nested file) still counts as a report file but matches nothing,
|
|
682
|
+
* so it can neither open the gate nor make the scan block, run out of
|
|
683
|
+
* memory or die instead of deciding.
|
|
684
|
+
*
|
|
685
|
+
* Residuals: (1) the check proves only that some file carries the approved
|
|
686
|
+
* content. Any regular `*.json` file within the size cap whose content
|
|
687
|
+
* equals it keeps a match, whether it was kept before the edit (a copy) or
|
|
688
|
+
* re-created after it (the agent wrote that content, so it can write it
|
|
689
|
+
* again), and the marker still opens the gate. (2) A reports directory that
|
|
690
|
+
* is empty, unreadable or holds no `*.json` entry at all (every report
|
|
691
|
+
* deleted, the directory made unreadable, the reports renamed) falls back to
|
|
692
|
+
* the "no report file" allow, the same as before this check existed. The
|
|
693
|
+
* marker and the operator's approval itself are untouched in both cases;
|
|
694
|
+
* only the audit trail loses its claim to be the approved content. (3) The
|
|
695
|
+
* cap bounds each file, not their number: the scan time grows with the
|
|
696
|
+
* total volume of report files, so an agent that plants hundreds of
|
|
697
|
+
* megabytes of files just under the cap can still push one scan past the
|
|
698
|
+
* hook's time budget, which the runtime treats as a non-blocking error (the
|
|
699
|
+
* same allow as before this check existed).
|
|
700
|
+
*
|
|
701
|
+
* Removing the approved report while other report files remain is a deny:
|
|
702
|
+
* nothing on disk carries the signed content any more. `harness gc --apply`
|
|
703
|
+
* can do that legitimately: it ages approved reports out by their createdAt
|
|
704
|
+
* but markers by their file mtime, so a report written long before its
|
|
705
|
+
* approval can go while the marker stays. Re-approving recovers.
|
|
706
|
+
*
|
|
707
|
+
* `primary` is the marker that satisfied the gate (task-scoped first),
|
|
708
|
+
* `fallback` a session marker that matched behind a task marker. The
|
|
709
|
+
* fallback is consulted only when the primary fails the check, so a task
|
|
710
|
+
* marker signed for another report does not hide a session marker that
|
|
711
|
+
* verifies. Unchanged behaviour: a null hash on the accepted marker (no
|
|
712
|
+
* report resolved, or `--force` over a report the producer could not hash:
|
|
713
|
+
* too deeply nested or over the size cap) and a reports directory with no
|
|
714
|
+
* `*.json` entry at all both allow. A forced approval of a hashable report
|
|
715
|
+
* signs its hash and is checked like any other.
|
|
716
|
+
*
|
|
717
|
+
* The `detail` is the block reason. It names the failing marker kind and the
|
|
718
|
+
* one-command fix, which is also the single migration step for a marker
|
|
719
|
+
* written before the canonical hash existed. It carries no report-derived
|
|
720
|
+
* value, so nothing in it needs sanitising.
|
|
721
|
+
*/
|
|
722
|
+
export function verifyApprovedReportHash(reportsDir, primary, fallback = null) {
|
|
723
|
+
if (primary.reportContentHash === null)
|
|
724
|
+
return { ok: true, kind: primary.kind };
|
|
725
|
+
if (fallback !== null && fallback.reportContentHash === null) {
|
|
726
|
+
return { ok: true, kind: fallback.kind };
|
|
727
|
+
}
|
|
728
|
+
const wanted = new Set([primary.reportContentHash]);
|
|
729
|
+
if (fallback !== null && fallback.reportContentHash !== null) {
|
|
730
|
+
wanted.add(fallback.reportContentHash);
|
|
731
|
+
}
|
|
732
|
+
const scan = scanReportHashes(reportsDir, wanted);
|
|
733
|
+
if (scan.files === 0 || scan.matched.has(primary.reportContentHash)) {
|
|
734
|
+
return { ok: true, kind: primary.kind };
|
|
735
|
+
}
|
|
736
|
+
if (fallback !== null &&
|
|
737
|
+
fallback.reportContentHash !== null &&
|
|
738
|
+
scan.matched.has(fallback.reportContentHash)) {
|
|
739
|
+
return { ok: true, kind: fallback.kind };
|
|
740
|
+
}
|
|
741
|
+
const kinds = fallback !== null
|
|
742
|
+
? `${primary.kind} and ${fallback.kind} approval markers were`
|
|
743
|
+
: `${primary.kind} approval marker was`;
|
|
744
|
+
return {
|
|
745
|
+
ok: false,
|
|
746
|
+
detail: `no report in the reports directory matches the content the ${kinds} signed for ` +
|
|
747
|
+
`(the approved report was changed or removed after approval); re-run \`harness approve understanding\``,
|
|
748
|
+
};
|
|
749
|
+
}
|
|
393
750
|
//# sourceMappingURL=persisted-reports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persisted-reports.js","sourceRoot":"","sources":["../../../../src/policy-packs/builtin/understanding-before-execution/persisted-reports.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,yEAAyE;AACzE,2EAA2E;AAC3E,uEAAuE;AACvE,kCAAkC;AAClC,EAAE;AACF,0EAA0E;AAC1E,+DAA+D;AAC/D,wEAAwE;AACxE,2EAA2E;AAC3E,kEAAkE;AA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AM,GAAG,0BAA0B,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC9D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,cAAc,EAAE,KAAK;YACrB,MAAM,EAAE,gCAAgC,SAAS,KAAK,OAAO,CAAC,MAAM,gCAAgC;YACpG,MAAM,EAAE,IAAI;SACb,CAAC;IACJ,CAAC;IACD,MAAM,YAAY,GAAG,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IACzE,IAAI,MAAM,CAAC,cAAc,KAAK,UAAU,EAAE,CAAC;QACzC,OAAO;YACL,cAAc,EAAE,KAAK;YACrB,MAAM,EAAE,iBAAiB,YAAY,uBACnC,mBAAmB,CAAC,MAAM,CAAC,cAAc,IAAI,WAAW,CAC1D,EAAE;YACF,MAAM,EAAE,MAAM;SACf,CAAC;IACJ,CAAC;IACD,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACzF,OAAO;QACL,cAAc,EAAE,IAAI;QACpB,MAAM,EACJ,GAAG,iCAAiC,YAAY,YAAY,OAAO;YACnE,0BAA0B,cAAc,CAAC,CAAC,CAAC,iBAAiB,cAAc,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG;YACrF,gFAAgF;YAChF,6EAA6E;QAC/E,MAAM,EAAE,MAAM;KACf,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"persisted-reports.js","sourceRoot":"","sources":["../../../../src/policy-packs/builtin/understanding-before-execution/persisted-reports.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,yEAAyE;AACzE,2EAA2E;AAC3E,uEAAuE;AACvE,kCAAkC;AAClC,EAAE;AACF,0EAA0E;AAC1E,+DAA+D;AAC/D,wEAAwE;AACxE,2EAA2E;AAC3E,kEAAkE;AAClE,mBAAmB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C,iBAAiB,KAAK,IAAI;QACnC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAC5C,CAAC;QACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC3C,CAAC;IACD,MAAM,KAAK,GACT,QAAQ,KAAK,IAAI;QACf,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,QAAQ,QAAQ,CAAC,IAAI,wBAAwB;QAC9D,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,sBAAsB,CAAC;IAC5C,OAAO;QACL,EAAE,EAAE,KAAK;QACT,MAAM,EACJ,8DAA8D,KAAK,cAAc;YACjF,uGAAuG;KAC1G,CAAC;AACJ,CAAC"}
|
package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.d.ts
CHANGED
|
@@ -113,7 +113,7 @@ export interface ApplyPostToolUseExpiryResult {
|
|
|
113
113
|
* side effects exactly so both runtimes share one clearing
|
|
114
114
|
* implementation (task a1348c89).
|
|
115
115
|
*/
|
|
116
|
-
export declare function applyPostToolUseExpiry(generatedDir: string, sessionId: string, toolInput: unknown, toolNameMatched: boolean, reportsDir: string, now?: Date): ApplyPostToolUseExpiryResult;
|
|
116
|
+
export declare function applyPostToolUseExpiry(generatedDir: string, sessionId: string, toolInput: unknown, toolNameMatched: boolean, reportsDir: string, now?: Date, trigger?: string): ApplyPostToolUseExpiryResult;
|
|
117
117
|
/**
|
|
118
118
|
* Compose the stderr diagnostic line for a matched-and-applied PostToolUse
|
|
119
119
|
* expiry. Shared by `harness pack hook post-tool-use` (Claude) and
|
|
@@ -149,7 +149,7 @@ export function matchPostToolUseBoundary(toolName, toolInput, lifecycle, bashToo
|
|
|
149
149
|
* side effects exactly so both runtimes share one clearing
|
|
150
150
|
* implementation (task a1348c89).
|
|
151
151
|
*/
|
|
152
|
-
export function applyPostToolUseExpiry(generatedDir, sessionId, toolInput, toolNameMatched, reportsDir, now) {
|
|
152
|
+
export function applyPostToolUseExpiry(generatedDir, sessionId, toolInput, toolNameMatched, reportsDir, now, trigger) {
|
|
153
153
|
const markerPath = approvalMarkerPathFor(generatedDir, sessionId);
|
|
154
154
|
const wasMarkerPresent = fs.existsSync(markerPath);
|
|
155
155
|
clearApprovalMarker(generatedDir, sessionId);
|
|
@@ -176,7 +176,7 @@ export function applyPostToolUseExpiry(generatedDir, sessionId, toolInput, toolN
|
|
|
176
176
|
// 7402301d the report can no longer satisfy the gate on its own, so
|
|
177
177
|
// this now exists so the audit record agrees with the cleared marker.
|
|
178
178
|
// Best-effort.
|
|
179
|
-
const reportExpiry = expirePersistedReport(reportsDir, sessionId, now);
|
|
179
|
+
const reportExpiry = expirePersistedReport(reportsDir, sessionId, now, trigger);
|
|
180
180
|
return {
|
|
181
181
|
wasMarkerPresent,
|
|
182
182
|
taskMarkerCleared,
|
package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-tool-use-boundary.js","sourceRoot":"","sources":["../../../../src/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,+EAA+E;AAC/E,2EAA2E;AAC3E,uEAAuE;AACvE,kCAAkC;AAElC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,eAAe,EACf,8BAA8B,GAC/B,MAAM,gDAAgD,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAEvF,wEAAwE;AACxE,wEAAw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,SAAkB,EAClB,eAAwB,EACxB,UAAkB,EAClB,GAAU;
|
|
1
|
+
{"version":3,"file":"post-tool-use-boundary.js","sourceRoot":"","sources":["../../../../src/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,+EAA+E;AAC/E,2EAA2E;AAC3E,uEAAuE;AACvE,kCAAkC;AAElC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,eAAe,EACf,8BAA8B,GAC/B,MAAM,gDAAgD,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAEvF,wEAAwE;AACxE,wEAAwE;AACxE,gEAAgE;AAChE,uEAAuE;AACvE,mEAAmE;AACnE,uEAAuE;AACvE,qEAAqE;AACrE,oEAAoE;AACpE,uEAAuE;AACvE,qEAAqE;AACrE,4BAA4B;AAC5B,wEAAwE;AAExE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAgB,EAChB,QAA2B;IAE3B,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IACrC,OAAO,qBAAqB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAChF,CAAC;AAED;;;kCAGkC;AAClC,MAAM,UA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YAAY,WAAW,sCAAsC,SAAS,GAAG,QAAQ,GAAG,UAAU,EAAE,CAAC;AAChI,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ApprovalMarker, type CheckApprovalMarkerOptions, type MarkerCheck } from "./markers.js";
|
|
2
|
+
import { type ApprovalMarkerKind } from "./persisted-reports.js";
|
|
2
3
|
export declare const APPROVAL_MARKER_TASK_PREFIX = "task-";
|
|
3
4
|
/** Filesystem path of a per-task approval marker. */
|
|
4
5
|
export declare function taskApprovalMarkerPathFor(generatedDir: string, taskId: string): string;
|
|
@@ -82,6 +83,23 @@ export interface OperatorMarkerApproval {
|
|
|
82
83
|
detail: string;
|
|
83
84
|
/** Task-scoped check detail, for callers that trace the fall-through. */
|
|
84
85
|
taskCheckDetail: string;
|
|
86
|
+
/**
|
|
87
|
+
* The matched marker's signed `reportContentHash`; null when no marker
|
|
88
|
+
* matched or the matched marker binds no report. The gate-read
|
|
89
|
+
* cross-check (`verifyApprovedReportHash`) consumes it.
|
|
90
|
+
*/
|
|
91
|
+
reportContentHash: string | null;
|
|
92
|
+
/**
|
|
93
|
+
* A session marker that ALSO matched behind a matched task marker whose
|
|
94
|
+
* signed hash is non-null (null otherwise). The gate-read cross-check
|
|
95
|
+
* falls back to it when the task marker's report content is gone: a task
|
|
96
|
+
* marker is not bound to a session, so it can be signed for another
|
|
97
|
+
* session's report while this session's own marker still verifies.
|
|
98
|
+
*/
|
|
99
|
+
sessionFallback: {
|
|
100
|
+
detail: string;
|
|
101
|
+
reportContentHash: string | null;
|
|
102
|
+
} | null;
|
|
85
103
|
/**
|
|
86
104
|
* True when EITHER the task-scoped or the session-scoped marker
|
|
87
105
|
* existed but aged past `approval_lifecycle.max_age` (task 6e888423).
|
|
@@ -126,3 +144,21 @@ export declare function checkOperatorApprovalMarkers(generatedDir: string, sessi
|
|
|
126
144
|
} | null): OperatorMarkerApproval;
|
|
127
145
|
/** Clear a specific task-scoped marker. Used by the post-tool-use hook. */
|
|
128
146
|
export declare function clearTaskApprovalMarker(generatedDir: string, taskId: string): void;
|
|
147
|
+
export type MatchedMarkerReportCheck = {
|
|
148
|
+
ok: true;
|
|
149
|
+
source: ApprovalMarkerKind;
|
|
150
|
+
detail: string;
|
|
151
|
+
} | {
|
|
152
|
+
ok: false;
|
|
153
|
+
detail: string;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Gate-read report cross-check for a matched operator marker, shared by the
|
|
157
|
+
* Claude and Codex PreToolUse hooks (task fa423e9b). Applies
|
|
158
|
+
* `verifyApprovedReportHash` to the matched marker and, when that fails and
|
|
159
|
+
* a session marker matched behind a task marker, to the session marker, so
|
|
160
|
+
* the verdict never depends on which marker the check order happened to
|
|
161
|
+
* pick. On success `source`/`detail` describe the marker that verified; on
|
|
162
|
+
* failure `detail` is the block reason.
|
|
163
|
+
*/
|
|
164
|
+
export declare function verifyMatchedMarkerReport(reportsDir: string, markers: OperatorMarkerApproval): MatchedMarkerReportCheck;
|
|
@@ -10,6 +10,7 @@ import { signMarker } from "../../../runtime/approval-signing.js";
|
|
|
10
10
|
import { readActiveClaim } from "./active-claim.js";
|
|
11
11
|
import { parseApprovalLifecycle } from "./lifecycle.js";
|
|
12
12
|
import { APPROVAL_MARKER_DIRNAME, checkApprovalMarker, } from "./markers.js";
|
|
13
|
+
import { verifyApprovedReportHash, } from "./persisted-reports.js";
|
|
13
14
|
// Task-scoped approval markers (harness/1ee26e77). When the operator
|
|
14
15
|
// passes `--task <id>` to `harness approve understanding`, a second
|
|
15
16
|
// marker file is written next to the session marker, keyed by the
|
|
@@ -166,11 +167,30 @@ export function checkOperatorApprovalMarkers(generatedDir, sessionId, packConfig
|
|
|
166
167
|
const ageOpts = lifecycle.maxAgeMs !== undefined ? { maxAgeMs: lifecycle.maxAgeMs } : {};
|
|
167
168
|
const taskMarker = checkActiveClaimApprovalMarker(generatedDir, ageOpts);
|
|
168
169
|
if (taskMarker.matched) {
|
|
170
|
+
const taskHash = taskMarker.marker?.reportContentHash ?? null;
|
|
171
|
+
// Only a task marker that binds a report can fail the gate-read hash
|
|
172
|
+
// check, so only then is the session marker read as its fallback.
|
|
173
|
+
const sessionFallback = taskHash === null
|
|
174
|
+
? null
|
|
175
|
+
: (() => {
|
|
176
|
+
const fallback = checkSessionApprovalMarker(generatedDir, sessionId, {
|
|
177
|
+
...ageOpts,
|
|
178
|
+
taskBinding: !lifecycle.legacyMode,
|
|
179
|
+
});
|
|
180
|
+
return fallback.matched
|
|
181
|
+
? {
|
|
182
|
+
detail: fallback.detail,
|
|
183
|
+
reportContentHash: fallback.marker?.reportContentHash ?? null,
|
|
184
|
+
}
|
|
185
|
+
: null;
|
|
186
|
+
})();
|
|
169
187
|
return {
|
|
170
188
|
matched: true,
|
|
171
189
|
source: "task",
|
|
172
190
|
detail: taskMarker.detail,
|
|
173
191
|
taskCheckDetail: taskMarker.detail,
|
|
192
|
+
reportContentHash: taskHash,
|
|
193
|
+
sessionFallback,
|
|
174
194
|
expired: false,
|
|
175
195
|
forged: false,
|
|
176
196
|
sessionBindingRefused: false,
|
|
@@ -186,6 +206,8 @@ export function checkOperatorApprovalMarkers(generatedDir, sessionId, packConfig
|
|
|
186
206
|
source: "session",
|
|
187
207
|
detail: sessionMarker.detail,
|
|
188
208
|
taskCheckDetail: taskMarker.detail,
|
|
209
|
+
reportContentHash: sessionMarker.marker?.reportContentHash ?? null,
|
|
210
|
+
sessionFallback: null,
|
|
189
211
|
expired: false,
|
|
190
212
|
forged: false,
|
|
191
213
|
sessionBindingRefused: false,
|
|
@@ -196,6 +218,8 @@ export function checkOperatorApprovalMarkers(generatedDir, sessionId, packConfig
|
|
|
196
218
|
source: null,
|
|
197
219
|
detail: sessionMarker.detail,
|
|
198
220
|
taskCheckDetail: taskMarker.detail,
|
|
221
|
+
reportContentHash: null,
|
|
222
|
+
sessionFallback: null,
|
|
199
223
|
// `expired` is computed ONLY on this non-matched path, preserving the
|
|
200
224
|
// "false when matched is true" invariant (task 6e888423 review):
|
|
201
225
|
// e.g. a FRESH session marker (matched:true, returned above) must not
|
|
@@ -222,4 +246,30 @@ export function clearTaskApprovalMarker(generatedDir, taskId) {
|
|
|
222
246
|
/* already gone */
|
|
223
247
|
}
|
|
224
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Gate-read report cross-check for a matched operator marker, shared by the
|
|
251
|
+
* Claude and Codex PreToolUse hooks (task fa423e9b). Applies
|
|
252
|
+
* `verifyApprovedReportHash` to the matched marker and, when that fails and
|
|
253
|
+
* a session marker matched behind a task marker, to the session marker, so
|
|
254
|
+
* the verdict never depends on which marker the check order happened to
|
|
255
|
+
* pick. On success `source`/`detail` describe the marker that verified; on
|
|
256
|
+
* failure `detail` is the block reason.
|
|
257
|
+
*/
|
|
258
|
+
export function verifyMatchedMarkerReport(reportsDir, markers) {
|
|
259
|
+
const source = markers.source === "task" ? "task" : "session";
|
|
260
|
+
const primary = {
|
|
261
|
+
kind: source,
|
|
262
|
+
reportContentHash: markers.reportContentHash,
|
|
263
|
+
};
|
|
264
|
+
const fallback = markers.sessionFallback === null
|
|
265
|
+
? null
|
|
266
|
+
: { kind: "session", reportContentHash: markers.sessionFallback.reportContentHash };
|
|
267
|
+
const verdict = verifyApprovedReportHash(reportsDir, primary, fallback);
|
|
268
|
+
if (!verdict.ok)
|
|
269
|
+
return verdict;
|
|
270
|
+
if (verdict.kind === primary.kind || markers.sessionFallback === null) {
|
|
271
|
+
return { ok: true, source: verdict.kind, detail: markers.detail };
|
|
272
|
+
}
|
|
273
|
+
return { ok: true, source: "session", detail: markers.sessionFallback.detail };
|
|
274
|
+
}
|
|
225
275
|
//# sourceMappingURL=task-markers.js.map
|