@tekmidian/pai 0.55.0 → 0.56.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.
@@ -2520,6 +2520,53 @@ function renderReport(c, prefix, r, cwd = "") {
2520
2520
  if (r.notes) out.push(`${prefix}${c("bold", "notes")} ${shortText(r.notes, 120)}`);
2521
2521
  return out;
2522
2522
  }
2523
+ /** A summary that names its own deletion — the path is expected to be gone. */
2524
+ const DELETED_RE = /\b(delete|deleted|deleting|remove|removed|removing)\b/i;
2525
+ /**
2526
+ * Check every path a report's `changed` list claims against the filesystem:
2527
+ * it must exist (mtime at or after `startMs`, the run's start) unless its
2528
+ * summary says it was deleted, in which case it must be absent. Mechanical
2529
+ * only — counts, row totals and other free-text claims are not checked (a
2530
+ * worker's R report is trusted as written; a 2026-09-23 report claimed "181
2531
+ * rows saved" while it had written 31, and only its listed paths are
2532
+ * something the filesystem can confirm or refute).
2533
+ */
2534
+ function verifyReportChanges(changed, cwd, startMs) {
2535
+ const failures = [];
2536
+ for (const ch of changed ?? []) {
2537
+ const raw = (ch.path ?? "").trim();
2538
+ if (!raw) continue;
2539
+ const abs = isAbsolute(raw) ? raw : resolve(cwd, raw);
2540
+ let mtimeMs;
2541
+ try {
2542
+ mtimeMs = statSync(abs).mtimeMs;
2543
+ } catch {
2544
+ mtimeMs = null;
2545
+ }
2546
+ if (DELETED_RE.test(ch.summary ?? "")) {
2547
+ if (mtimeMs !== null) failures.push({
2548
+ path: raw,
2549
+ reason: "not-deleted"
2550
+ });
2551
+ } else if (mtimeMs === null) failures.push({
2552
+ path: raw,
2553
+ reason: "missing"
2554
+ });
2555
+ else if (mtimeMs < startMs) failures.push({
2556
+ path: raw,
2557
+ reason: "stale"
2558
+ });
2559
+ }
2560
+ return {
2561
+ ok: failures.length === 0,
2562
+ failures
2563
+ };
2564
+ }
2565
+ /** The one-line note appended to a report/ledger when verify fails. */
2566
+ function verifyFailNote(v) {
2567
+ const paths = v.failures.map((f) => f.path).slice(0, 5).join(", ");
2568
+ return `verify: ${v.failures.length} claimed change${v.failures.length === 1 ? "" : "s"} not confirmed: ${paths}`;
2569
+ }
2523
2570
  /** repo-relative display of a changed path when it lies under cwd. */
2524
2571
  function relShort(p, cwd) {
2525
2572
  if (!cwd) return p;
@@ -2952,7 +2999,7 @@ async function runWorker(opts) {
2952
2999
  const logDir = workersLogDir(config);
2953
3000
  mkdirSync(logDir, { recursive: true });
2954
3001
  if (opts.className === "plan" && !opts._planner) {
2955
- const { runPlanner } = await import("./planner-C2wWnZrZ.mjs");
3002
+ const { runPlanner } = await import("./planner-ye7wrrfB.mjs");
2956
3003
  return runPlanner(opts);
2957
3004
  }
2958
3005
  const parent = launchParent(opts.parent);
@@ -3561,6 +3608,20 @@ async function executeRun(a) {
3561
3608
  } catch {}
3562
3609
  }
3563
3610
  }
3611
+ if (headless && ctx.resultReport?.changed?.length) {
3612
+ const verify = verifyReportChanges(ctx.resultReport.changed, worktree?.dir ?? cwd, t0);
3613
+ if (!verify.ok) {
3614
+ status.reportValid = false;
3615
+ const note = verifyFailNote(verify);
3616
+ status.last = shortText(note, 90);
3617
+ ctx.resultReport.notes = ctx.resultReport.notes ? `${ctx.resultReport.notes} — ${note}` : note;
3618
+ appendLedger(ledger, "REPORT-UNVERIFIED", {
3619
+ id: wid,
3620
+ failures: verify.failures.length,
3621
+ paths: verify.failures.map((f) => f.path).slice(0, 5).join(",")
3622
+ });
3623
+ }
3624
+ }
3564
3625
  saveStatus(logDir, status);
3565
3626
  appendLedger(ledger, "WORKER-END", {
3566
3627
  id: wid,
@@ -3833,6 +3894,20 @@ async function executeCodexRun(a) {
3833
3894
  status.rc = rc;
3834
3895
  status.secs = secs;
3835
3896
  status.last = shortText(report?.notes ?? finalText, 90) || (ok ? "done" : "failed");
3897
+ if (report?.changed?.length) {
3898
+ const verify = verifyReportChanges(report.changed, worktree?.dir ?? cwd, t0);
3899
+ if (!verify.ok) {
3900
+ status.reportValid = false;
3901
+ const note = verifyFailNote(verify);
3902
+ status.last = shortText(note, 90);
3903
+ report.notes = report.notes ? `${report.notes} — ${note}` : note;
3904
+ appendLedger(ledger, "REPORT-UNVERIFIED", {
3905
+ id: wid,
3906
+ failures: verify.failures.length,
3907
+ paths: verify.failures.map((f) => f.path).slice(0, 5).join(",")
3908
+ });
3909
+ }
3910
+ }
3836
3911
  saveStatus(logDir, status);
3837
3912
  appendLedger(ledger, "WORKER-END", {
3838
3913
  id: wid,
@@ -4000,4 +4075,4 @@ function resultFromOutput(out) {
4000
4075
 
4001
4076
  //#endregion
4002
4077
  export { contextLabel as A, saveStatus as B, mergeWorker as C, UNLABELED as D, ledgerSummary as E, loadStatus as F, shortText as G, waitForTerminalStatus as H, loadStatuses as I, describeMcp as K, newWorkerId as L, elapsedOf as M, isChatPane as N, ageOf as O, isLive as P, nowStamp as R, discardWorker as S, appendLedger as T, longInlinePromptHint as U, setWorkerLabel as V, parseRunnerArgs as W, itermUuid as _, projectLaunchConfig as a, sessionTag as b, handoffFromInside as c, workerDepth as d, checkPaneForWorker as f, itermForClaudeSession as g, currentTabKey as h, usageContextTokens as i, contextPercent as j, alive as k, readInbox as l, openPaneForWorker as m, runWorker as n, parseWorkerReport as o, openFollowPane as p, expandMcpNames as q, testProvider as r, renderReport as s, printResult as t, sayToWorker as u, resolveSession as v, worktreesDir as w, workerInScope as x, sessionMapPath as y, ownsPid as z };
4003
- //# sourceMappingURL=run-DkTrZejF.mjs.map
4078
+ //# sourceMappingURL=run-CqRvXGjd.mjs.map