tamperward 2.39.8 → 2.39.10

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.
Files changed (2) hide show
  1. package/dist/cli/index.js +163 -127
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -769,6 +769,28 @@ function inspectResolved(abs) {
769
769
  function textOf2(e) {
770
770
  return e.content == null ? null : e.content.toString("utf8");
771
771
  }
772
+ function notARegularFile(e) {
773
+ switch (e.kind) {
774
+ case "symlink":
775
+ return `is a symbolic link to ${escapeControl(e.detail)}`;
776
+ case "directory":
777
+ return "is a directory";
778
+ case "irregular":
779
+ return `is a ${e.detail}`;
780
+ case "oversize":
781
+ return `is ${e.detail}, above the ${READ_CAP / (1024 * 1024)} MiB the gate reads`;
782
+ default:
783
+ return `cannot be read (${e.detail})`;
784
+ }
785
+ }
786
+ function readStateFile(abs) {
787
+ const e = inspectPath(abs);
788
+ if (e.kind === "absent") return null;
789
+ if (e.kind === "file") return textOf2(e) ?? "";
790
+ throw new StateFileError(
791
+ `${abs} ${notARegularFile(e)}; the gate reads its session state only as a regular file \u2014 remove what stands there so the state can be re-established`
792
+ );
793
+ }
772
794
  function describe(e, shown) {
773
795
  switch (e.kind) {
774
796
  case "symlink":
@@ -809,7 +831,7 @@ function unjudgeableProtected(cwd, policy, changes) {
809
831
  }
810
832
  return out3;
811
833
  }
812
- var READ_CAP, NO_META, O_READ;
834
+ var READ_CAP, NO_META, O_READ, StateFileError;
813
835
  var init_disk = __esm({
814
836
  "src/disk.ts"() {
815
837
  "use strict";
@@ -818,6 +840,8 @@ var init_disk = __esm({
818
840
  READ_CAP = 64 * 1024 * 1024;
819
841
  NO_META = { mode: 0, size: 0, mtimeMs: 0 };
820
842
  O_READ = constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0);
843
+ StateFileError = class extends Error {
844
+ };
821
845
  }
822
846
  });
823
847
 
@@ -10697,7 +10721,6 @@ var init_engine = __esm({
10697
10721
  });
10698
10722
 
10699
10723
  // src/policy-load.ts
10700
- import { readFileSync as readFileSync5, existsSync as existsSync5 } from "node:fs";
10701
10724
  import { isAbsolute as isAbsolute7, join as join8, posix as posix3 } from "node:path";
10702
10725
  function normalizeVersion(v, where = POLICY_FILE) {
10703
10726
  if (v === void 0 || v === null) return 1;
@@ -10870,9 +10893,14 @@ function parseOrThrow(src, where) {
10870
10893
  return parsePolicy(raw, where);
10871
10894
  }
10872
10895
  function loadPolicy(cwd = process.cwd()) {
10873
- const path = join8(repoRoot(cwd), POLICY_FILE);
10874
- if (!existsSync5(path)) return defaultPolicy();
10875
- return parseOrThrow(readFileSync5(path, "utf8"), POLICY_FILE);
10896
+ const entry = inspectPath(join8(repoRoot(cwd), POLICY_FILE));
10897
+ if (entry.kind === "absent") return defaultPolicy();
10898
+ if (entry.kind !== "file") {
10899
+ throw new PolicyError(
10900
+ `${POLICY_FILE} ${notARegularFile(entry)}; the policy is read only as a regular file at the repository root \u2014 put one there (no symbolic link, FIFO, socket, device or directory) or remove it`
10901
+ );
10902
+ }
10903
+ return parseOrThrow(textOf2(entry) ?? "", POLICY_FILE);
10876
10904
  }
10877
10905
  function loadPolicyAt(rev2, cwd) {
10878
10906
  const src = fileAt(rev2, POLICY_FILE, { cwd: cwd === void 0 ? void 0 : repoRoot(cwd) });
@@ -10886,6 +10914,7 @@ var init_policy_load = __esm({
10886
10914
  init_lazy_deps();
10887
10915
  init_policy();
10888
10916
  init_build();
10917
+ init_disk();
10889
10918
  init_narrow();
10890
10919
  init_repo_context();
10891
10920
  PolicyError = class extends Error {
@@ -10900,7 +10929,7 @@ var init_policy_load = __esm({
10900
10929
 
10901
10930
  // src/signoff.ts
10902
10931
  import { createHash as createHash3 } from "node:crypto";
10903
- import { appendFileSync, closeSync as closeSync2, constants as constants3, fstatSync as fstatSync2, lstatSync as lstatSync3, mkdirSync, openSync as openSync2, readFileSync as readFileSync6 } from "node:fs";
10932
+ import { appendFileSync, closeSync as closeSync2, constants as constants3, fstatSync as fstatSync2, lstatSync as lstatSync3, mkdirSync, openSync as openSync2, readFileSync as readFileSync5 } from "node:fs";
10904
10933
  import { dirname as dirname2, join as join9, posix as posix4 } from "node:path";
10905
10934
  function compactOobToken(want, head) {
10906
10935
  const normalizedHead = head.trim().toLowerCase();
@@ -10983,7 +11012,7 @@ function readLedger(cwd, policy) {
10983
11012
  const fd = openLedger(rel, path, constants3.O_RDONLY);
10984
11013
  let text;
10985
11014
  try {
10986
- text = readFileSync6(fd, "utf8");
11015
+ text = readFileSync5(fd, "utf8");
10987
11016
  } finally {
10988
11017
  closeSync2(fd);
10989
11018
  }
@@ -11534,7 +11563,7 @@ var init_deny = __esm({
11534
11563
  });
11535
11564
 
11536
11565
  // src/session.ts
11537
- import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync7, renameSync, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
11566
+ import { mkdirSync as mkdirSync2, renameSync, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
11538
11567
  import { dirname as dirname3, join as join10 } from "node:path";
11539
11568
  function writeBaseline(p, sha3) {
11540
11569
  mkdirSync2(dirname3(p), { recursive: true });
@@ -11559,13 +11588,8 @@ function turnBaseline(cwd, sessionId) {
11559
11588
  if (!sessionId) return null;
11560
11589
  const p = baselinePath(cwd, sessionId);
11561
11590
  if (!p) return null;
11562
- try {
11563
- if (existsSync6(p)) {
11564
- const v = readFileSync7(p, "utf8").trim();
11565
- if (SHA.test(v)) return v;
11566
- }
11567
- } catch {
11568
- }
11591
+ const v = readStateFile(p)?.trim();
11592
+ if (v !== void 0 && SHA.test(v)) return v;
11569
11593
  const head = headSha(cwd);
11570
11594
  if (!head) return null;
11571
11595
  try {
@@ -11589,6 +11613,7 @@ var UNSAFE, SHA, BaselineWriteError;
11589
11613
  var init_session = __esm({
11590
11614
  "src/session.ts"() {
11591
11615
  "use strict";
11616
+ init_disk();
11592
11617
  init_build();
11593
11618
  UNSAFE = /[^A-Za-z0-9_-]/g;
11594
11619
  SHA = /^[0-9a-f]{40}$/;
@@ -11604,7 +11629,7 @@ var init_session = __esm({
11604
11629
 
11605
11630
  // src/effect.ts
11606
11631
  import { createHash as createHash4 } from "node:crypto";
11607
- import { existsSync as existsSync7, lstatSync as lstatSync4, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync8, renameSync as renameSync2, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
11632
+ import { lstatSync as lstatSync4, mkdirSync as mkdirSync3, readdirSync, renameSync as renameSync2, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
11608
11633
  import { join as join11 } from "node:path";
11609
11634
  function ptreeFrom(value) {
11610
11635
  if (!isRecord(value)) return null;
@@ -11696,9 +11721,11 @@ function driftBetween(expected, current) {
11696
11721
  return { changed, deleted, added };
11697
11722
  }
11698
11723
  function loadTree(p) {
11699
- if (!p || !existsSync7(p)) return null;
11724
+ if (!p) return null;
11725
+ const text = readStateFile(p);
11726
+ if (text === null) return null;
11700
11727
  try {
11701
- return ptreeFrom(JSON.parse(readFileSync8(p, "utf8")));
11728
+ return ptreeFrom(JSON.parse(text));
11702
11729
  } catch {
11703
11730
  return null;
11704
11731
  }
@@ -11751,7 +11778,7 @@ var init_effect = __esm({
11751
11778
  });
11752
11779
 
11753
11780
  // src/cli/watch.ts
11754
- import { appendFileSync as appendFileSync3, lstatSync as lstatSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync9, readdirSync as readdirSync2, watch, writeFileSync as writeFileSync4 } from "node:fs";
11781
+ import { appendFileSync as appendFileSync3, lstatSync as lstatSync5, mkdirSync as mkdirSync4, readdirSync as readdirSync2, watch, writeFileSync as writeFileSync4 } from "node:fs";
11755
11782
  import { join as join12 } from "node:path";
11756
11783
  import { createHash as createHash5 } from "node:crypto";
11757
11784
  function snap(abs) {
@@ -11769,8 +11796,10 @@ function watcherHealthPath(log) {
11769
11796
  return `${log}.health.json`;
11770
11797
  }
11771
11798
  function readWatcherHealth(log) {
11799
+ const text = readStateFile(watcherHealthPath(log));
11800
+ if (text === null) return null;
11772
11801
  try {
11773
- const value = JSON.parse(readFileSync9(watcherHealthPath(log), "utf8"));
11802
+ const value = JSON.parse(text);
11774
11803
  if (!isRecord(value)) return null;
11775
11804
  const { state, backend, pid, started_at } = value;
11776
11805
  if (value.version !== 1 || typeof pid !== "number" || typeof started_at !== "string") return null;
@@ -11804,7 +11833,13 @@ function pidAlive(pid) {
11804
11833
  }
11805
11834
  }
11806
11835
  function watcherTelemetry(log) {
11807
- const health = readWatcherHealth(log);
11836
+ let health;
11837
+ try {
11838
+ health = readWatcherHealth(log);
11839
+ } catch (e) {
11840
+ if (!(e instanceof StateFileError)) throw e;
11841
+ return { state: "unavailable", health: null, reason: e.message };
11842
+ }
11808
11843
  if (!health) return { state: "unavailable", health: null, reason: "no health record" };
11809
11844
  if (health.state === "stopped")
11810
11845
  return { state: "unavailable", health, reason: "observer stopped" };
@@ -12298,7 +12333,7 @@ var init_fs_events = __esm({
12298
12333
 
12299
12334
  // src/cli/audit.ts
12300
12335
  import { createHash as createHash6, randomBytes } from "node:crypto";
12301
- import { appendFileSync as appendFileSync4, closeSync as closeSync4, existsSync as existsSync8, mkdirSync as mkdirSync5, openSync as openSync4, readSync as readSync3 } from "node:fs";
12336
+ import { appendFileSync as appendFileSync4, closeSync as closeSync4, existsSync as existsSync5, mkdirSync as mkdirSync5, openSync as openSync4, readSync as readSync3 } from "node:fs";
12302
12337
  import { dirname as dirname4, isAbsolute as isAbsolute8, join as join13, resolve as resolve4 } from "node:path";
12303
12338
  function sessionHash(sessionId) {
12304
12339
  if (!sessionId) return void 0;
@@ -12557,7 +12592,7 @@ function runStats(opts = {}) {
12557
12592
  const file = opts.file ? isAbsolute8(opts.file) ? opts.file : resolve4(cwd, opts.file) : configured && configured !== "auto" ? isAbsolute8(configured) ? configured : resolve4(cwd, configured) : defaultAuditPath(cwd);
12558
12593
  const cutoff = opts.since ? parseSince(opts.since) : null;
12559
12594
  if (!file) throw new Error("stats needs --file outside a Git repository");
12560
- if (!existsSync8(file)) {
12595
+ if (!existsSync5(file)) {
12561
12596
  if (explicitFile) throw new Error(`audit file not found: ${file}`);
12562
12597
  const empty2 = summarizeAudit([]);
12563
12598
  process.stdout.write(opts.json ? JSON.stringify(empty2) + "\n" : renderAuditStats(empty2));
@@ -12596,14 +12631,14 @@ var init_audit = __esm({
12596
12631
  });
12597
12632
 
12598
12633
  // src/cli/hook.ts
12599
- import { readFileSync as readFileSync10, appendFileSync as appendFileSync5, writeFileSync as writeFileSync5, existsSync as existsSync9 } from "node:fs";
12634
+ import { readFileSync as readFileSync6, appendFileSync as appendFileSync5, writeFileSync as writeFileSync5, existsSync as existsSync6 } from "node:fs";
12600
12635
  import { createHash as createHash7 } from "node:crypto";
12601
12636
  function setSnapshotCache(cache3) {
12602
12637
  snapshotCache = cache3;
12603
12638
  }
12604
12639
  function readStdin() {
12605
12640
  try {
12606
- return readFileSync10(0, "utf8");
12641
+ return readFileSync6(0, "utf8");
12607
12642
  } catch (e) {
12608
12643
  throw new HookInputError(`cannot read the hook payload on stdin: ${e instanceof Error ? e.message : String(e)}`);
12609
12644
  }
@@ -12893,10 +12928,11 @@ function turnTransientBlocks(cwd, sessionId, policy, changes) {
12893
12928
  recordObserverHealth(cwd, sessionId, telemetry.state, telemetry.reason);
12894
12929
  }
12895
12930
  const cp = cursorPath(cwd, sessionId);
12896
- if (!existsSync9(log)) return none;
12931
+ if (!existsSync6(log)) return none;
12897
12932
  let offset = 0;
12898
- if (cp && existsSync9(cp)) {
12899
- const n2 = Number(readFileSync10(cp, "utf8"));
12933
+ const cursorText = cp ? readStateFile(cp) : null;
12934
+ if (cursorText !== null) {
12935
+ const n2 = Number(cursorText);
12900
12936
  offset = Number.isFinite(n2) ? n2 : 0;
12901
12937
  }
12902
12938
  const drained = drainEvents(log, offset);
@@ -13170,13 +13206,13 @@ var init_ptree_cache = __esm({
13170
13206
  });
13171
13207
 
13172
13208
  // src/cli/hook-service.ts
13173
- import { chmodSync, existsSync as existsSync10, lstatSync as lstatSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync11, rmSync as rmSync4, writeFileSync as writeFileSync6 } from "node:fs";
13209
+ import { chmodSync, existsSync as existsSync7, lstatSync as lstatSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync7, rmSync as rmSync4, writeFileSync as writeFileSync6 } from "node:fs";
13174
13210
  import { createConnection as createConnection2, createServer } from "node:net";
13175
13211
  import { realpathSync as realpathSync4 } from "node:fs";
13176
13212
  import { sep } from "node:path";
13177
13213
  function readServiceState(paths) {
13178
13214
  try {
13179
- const v = JSON.parse(readFileSync11(paths.state, "utf8"));
13215
+ const v = JSON.parse(readFileSync7(paths.state, "utf8"));
13180
13216
  if (!isRecord(v)) return null;
13181
13217
  const { pid, version, root, started_at } = v;
13182
13218
  if (typeof pid !== "number" || typeof version !== "string" || typeof root !== "string" || typeof started_at !== "string") return null;
@@ -13258,7 +13294,7 @@ function removeQuietly(p) {
13258
13294
  }
13259
13295
  }
13260
13296
  function ensurePrivateDir(dir, uid) {
13261
- if (!existsSync10(dir)) mkdirSync6(dir, { recursive: true, mode: 448 });
13297
+ if (!existsSync7(dir)) mkdirSync6(dir, { recursive: true, mode: 448 });
13262
13298
  const st = lstatSync7(dir);
13263
13299
  if (!st.isDirectory()) throw new Error(`${dir} is not a directory`);
13264
13300
  if (st.uid !== uid) throw new Error(`${dir} is owned by uid ${st.uid}, not ${uid}; refusing to serve from it`);
@@ -13455,7 +13491,7 @@ async function stopHookService(paths, expectedRoot) {
13455
13491
  process.kill(st.pid, "SIGTERM");
13456
13492
  } catch {
13457
13493
  }
13458
- const gone = () => !pidAlive2(st.pid) || !existsSync10(paths.socket);
13494
+ const gone = () => !pidAlive2(st.pid) || !existsSync7(paths.socket);
13459
13495
  const until = Date.now() + STOP_WAIT_MS;
13460
13496
  while (!gone() && Date.now() < until) sleepSync(50);
13461
13497
  if (!gone()) throw new Error(`hook service pid ${st.pid} did not exit within ${STOP_WAIT_MS / 1e3}s`);
@@ -13737,7 +13773,7 @@ var init_safe_write = __esm({
13737
13773
  // src/cli/init.ts
13738
13774
  import { execFileSync as execFileSync6 } from "node:child_process";
13739
13775
  import { createHash as createHash8 } from "node:crypto";
13740
- import { existsSync as existsSync11, mkdirSync as mkdirSync7, readFileSync as readFileSync12, realpathSync as realpathSync5 } from "node:fs";
13776
+ import { existsSync as existsSync8, mkdirSync as mkdirSync7, readFileSync as readFileSync8, realpathSync as realpathSync5 } from "node:fs";
13741
13777
  import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute9, join as join15, relative as relative4, resolve as resolve6 } from "node:path";
13742
13778
  function gitConfig(cwd, key2) {
13743
13779
  try {
@@ -13831,34 +13867,34 @@ function verifierCandidates(cwd) {
13831
13867
  if (!candidates.includes(command)) candidates.push(command);
13832
13868
  };
13833
13869
  try {
13834
- const pkg = JSON.parse(readFileSync12(join15(cwd, "package.json"), "utf8"));
13870
+ const pkg = JSON.parse(readFileSync8(join15(cwd, "package.json"), "utf8"));
13835
13871
  const test = isRecord(pkg) && isRecord(pkg.scripts) ? pkg.scripts.test : void 0;
13836
13872
  if (typeof test === "string" && test.trim() !== "" && !/error:\s*no test specified/i.test(test)) add("npm test");
13837
13873
  } catch {
13838
13874
  }
13839
13875
  try {
13840
- const pyproject = readFileSync12(join15(cwd, "pyproject.toml"), "utf8");
13876
+ const pyproject = readFileSync8(join15(cwd, "pyproject.toml"), "utf8");
13841
13877
  if (/^\s*\[tool\.pytest(?:\.ini_options)?\]\s*$/m.test(pyproject)) add("pytest");
13842
13878
  } catch {
13843
13879
  }
13844
- if (existsSync11(join15(cwd, "pytest.ini"))) add("pytest");
13880
+ if (existsSync8(join15(cwd, "pytest.ini"))) add("pytest");
13845
13881
  try {
13846
- const setupCfg = readFileSync12(join15(cwd, "setup.cfg"), "utf8");
13882
+ const setupCfg = readFileSync8(join15(cwd, "setup.cfg"), "utf8");
13847
13883
  if (/^\s*\[tool:pytest\]\s*$/m.test(setupCfg)) add("pytest");
13848
13884
  } catch {
13849
13885
  }
13850
13886
  try {
13851
- const tox = readFileSync12(join15(cwd, "tox.ini"), "utf8");
13887
+ const tox = readFileSync8(join15(cwd, "tox.ini"), "utf8");
13852
13888
  if (/^\s*\[tox\]\s*$/m.test(tox)) add("tox");
13853
13889
  } catch {
13854
13890
  }
13855
13891
  try {
13856
- const cargo = readFileSync12(join15(cwd, "Cargo.toml"), "utf8");
13892
+ const cargo = readFileSync8(join15(cwd, "Cargo.toml"), "utf8");
13857
13893
  if (/^\s*\[(?:package|workspace)\]\s*(?:#.*)?$/m.test(cargo)) add("cargo test");
13858
13894
  } catch {
13859
13895
  }
13860
13896
  try {
13861
- const goMod = readFileSync12(join15(cwd, "go.mod"), "utf8");
13897
+ const goMod = readFileSync8(join15(cwd, "go.mod"), "utf8");
13862
13898
  if (/^\s*module\s+\S+\s*(?:\/\/.*)?$/m.test(goMod)) add("go test ./...");
13863
13899
  } catch {
13864
13900
  }
@@ -13901,7 +13937,7 @@ function planPolicy(cwd) {
13901
13937
  const path = join15(cwd, POLICY_FILE);
13902
13938
  const refused = refuseNonRegular(path);
13903
13939
  if (refused) return { item: "policy", path: POLICY_FILE, status: "error", detail: refused };
13904
- if (existsSync11(path)) {
13940
+ if (existsSync8(path)) {
13905
13941
  try {
13906
13942
  loadPolicy(cwd);
13907
13943
  } catch (e) {
@@ -13920,7 +13956,7 @@ function planPolicy(cwd) {
13920
13956
  function planGitignore(cwd) {
13921
13957
  const rel = ".gitignore";
13922
13958
  const path = join15(cwd, rel);
13923
- if (!existsSync11(join15(cwd, "node_modules"))) return null;
13959
+ if (!existsSync8(join15(cwd, "node_modules"))) return null;
13924
13960
  let existing = "";
13925
13961
  let kind;
13926
13962
  try {
@@ -13930,7 +13966,7 @@ function planGitignore(cwd) {
13930
13966
  }
13931
13967
  const refused = refuseNonRegular(path);
13932
13968
  if (refused) return { item: "gitignore", path: rel, status: "error", detail: refused };
13933
- if (kind === "file") existing = readFileSync12(path, "utf8");
13969
+ if (kind === "file") existing = readFileSync8(path, "utf8");
13934
13970
  try {
13935
13971
  const tracked = execFileSync6("git", ["ls-files", "--cached", "--", "node_modules"], {
13936
13972
  cwd,
@@ -13985,10 +14021,10 @@ function planClaudeHooks(cwd) {
13985
14021
  const refused = refuseNonRegular(path);
13986
14022
  if (refused) return { item: "agent", path: rel, status: "error", detail: refused };
13987
14023
  let settings = {};
13988
- if (existsSync11(path)) {
14024
+ if (existsSync8(path)) {
13989
14025
  let parsed;
13990
14026
  try {
13991
- parsed = JSON.parse(readFileSync12(path, "utf8"));
14027
+ parsed = JSON.parse(readFileSync8(path, "utf8"));
13992
14028
  } catch {
13993
14029
  return {
13994
14030
  item: "agent",
@@ -14037,7 +14073,7 @@ function planClaudeHooks(cwd) {
14037
14073
  return {
14038
14074
  item: "agent",
14039
14075
  path: rel,
14040
- status: existsSync11(path) ? "update" : "create",
14076
+ status: existsSync8(path) ? "update" : "create",
14041
14077
  detail: [
14042
14078
  needPre && "wire PreToolUse deny",
14043
14079
  needStop && "wire Stop sweep",
@@ -14081,7 +14117,7 @@ function hooksDir(cwd) {
14081
14117
  if (out3) return resolve6(cwd, out3);
14082
14118
  } catch {
14083
14119
  }
14084
- return existsSync11(join15(cwd, ".git")) ? join15(cwd, ".git", "hooks") : null;
14120
+ return existsSync8(join15(cwd, ".git")) ? join15(cwd, ".git", "hooks") : null;
14085
14121
  }
14086
14122
  function display(cwd, path) {
14087
14123
  const rel = relative4(cwd, path);
@@ -14108,11 +14144,11 @@ function planPreCommit(cwd) {
14108
14144
  const skip = (detail) => ({ item: "pre-commit", path: "(none)", status: "skip", detail });
14109
14145
  let path;
14110
14146
  let note;
14111
- if (existsSync11(join15(cwd, ".husky"))) {
14147
+ if (existsSync8(join15(cwd, ".husky"))) {
14112
14148
  path = join15(cwd, ".husky", "pre-commit");
14113
14149
  note = "husky";
14114
14150
  } else {
14115
- const managed = MANAGED_HOOKS.find((m) => m.configs.some((c) => existsSync11(join15(cwd, c))));
14151
+ const managed = MANAGED_HOOKS.find((m) => m.configs.some((c) => existsSync8(join15(cwd, c))));
14116
14152
  if (managed) {
14117
14153
  return skip(`${managed.name} manages this repository's hooks and regenerates them on install, so a line in the hooks directory would not last \u2014 ${managed.hint}`);
14118
14154
  }
@@ -14130,7 +14166,7 @@ function planPreCommit(cwd) {
14130
14166
  const rel = display(cwd, path);
14131
14167
  const refused = refuseNonRegular(path);
14132
14168
  if (refused) return { item: "pre-commit", path: rel, status: "error", detail: refused };
14133
- const existing = existsSync11(path) ? readFileSync12(path, "utf8") : null;
14169
+ const existing = existsSync8(path) ? readFileSync8(path, "utf8") : null;
14134
14170
  const hookMode = () => existingMode(path, 493) | 73;
14135
14171
  if (existing === null) {
14136
14172
  return {
@@ -14221,7 +14257,7 @@ function planCodeowners(cwd) {
14221
14257
  const path = join15(cwd, existingRel ?? rel);
14222
14258
  const refused = refuseNonRegular(path);
14223
14259
  if (refused) return { item: "codeowners", path: existingRel ?? rel, status: "error", detail: refused };
14224
- const existing = existingRel ? readFileSync12(path, "utf8") : null;
14260
+ const existing = existingRel ? readFileSync8(path, "utf8") : null;
14225
14261
  const missing = CODEOWNERS_PATHS.filter((p) => existing === null || !coveredBy(existing, p));
14226
14262
  if (existingRel !== void 0 && missing.length === 0) {
14227
14263
  return { item: "codeowners", path: existingRel, status: "ok", detail: "gate paths already have code owners" };
@@ -14261,7 +14297,7 @@ function planWorkflow(cwd, force) {
14261
14297
  };
14262
14298
  const refused = refuseNonRegular(path);
14263
14299
  if (refused) return { item: "ci", path: rel, status: "error", detail: refused };
14264
- if (!existsSync11(path)) {
14300
+ if (!existsSync8(path)) {
14265
14301
  return {
14266
14302
  item: "ci",
14267
14303
  path: rel,
@@ -14272,7 +14308,7 @@ function planWorkflow(cwd, force) {
14272
14308
  }
14273
14309
  let src;
14274
14310
  try {
14275
- src = readFileSync12(path, "utf8");
14311
+ src = readFileSync8(path, "utf8");
14276
14312
  } catch {
14277
14313
  return { item: "ci", path: rel, status: "error", detail: "exists but cannot be read \u2014 refusing to overwrite" };
14278
14314
  }
@@ -14619,10 +14655,10 @@ var init_fingerprint = __esm({
14619
14655
  // src/dependency-env.ts
14620
14656
  import { createHash as createHash10 } from "node:crypto";
14621
14657
  import {
14622
- existsSync as existsSync12,
14658
+ existsSync as existsSync9,
14623
14659
  lstatSync as lstatSync9,
14624
14660
  readdirSync as readdirSync3,
14625
- readFileSync as readFileSync13,
14661
+ readFileSync as readFileSync9,
14626
14662
  readlinkSync as readlinkSync2,
14627
14663
  realpathSync as realpathSync6,
14628
14664
  statSync as statSync3
@@ -14680,7 +14716,7 @@ function fingerprintRoot(root, cwd, h) {
14680
14716
  st = statSync3(path);
14681
14717
  if (!st.isFile()) throw new Error("not a regular file");
14682
14718
  h.update(label + "\0external-file\0" + path + "\0" + String(st.mode) + "\0");
14683
- h.update(readFileSync13(path));
14719
+ h.update(readFileSync9(path));
14684
14720
  h.update("\0");
14685
14721
  } catch (e) {
14686
14722
  throw new Unattestable(
@@ -14714,7 +14750,7 @@ function fingerprintRoot(root, cwd, h) {
14714
14750
  h.update(rel + "\0" + ident.kind + "\0" + String(ident.mode) + "\0");
14715
14751
  if (ident.kind === "file") {
14716
14752
  try {
14717
- h.update(readFileSync13(path));
14753
+ h.update(readFileSync9(path));
14718
14754
  h.update("\0");
14719
14755
  } catch (e) {
14720
14756
  throw new Unattestable(
@@ -14773,7 +14809,7 @@ function snapshot(roots, probes, cwd) {
14773
14809
  const h = createHash10("sha256");
14774
14810
  for (const probe of probes) {
14775
14811
  h.update(
14776
- "probe\0" + probe.kind + "\0" + probe.path + "\0" + (existsSync12(probe.path) ? "present" : "absent") + "\0"
14812
+ "probe\0" + probe.kind + "\0" + probe.path + "\0" + (existsSync9(probe.path) ? "present" : "absent") + "\0"
14777
14813
  );
14778
14814
  }
14779
14815
  for (const root of roots) fingerprintRoot(root, cwd, h);
@@ -14832,7 +14868,7 @@ function resolveExecutable(token, cwd, env) {
14832
14868
  if (token.includes("/") || token.includes("\\")) {
14833
14869
  const path = isAbsolute10(token) ? token : resolve7(cwd, token);
14834
14870
  try {
14835
- return existsSync12(path) ? realpathSync6(path) : null;
14871
+ return existsSync9(path) ? realpathSync6(path) : null;
14836
14872
  } catch {
14837
14873
  return null;
14838
14874
  }
@@ -14840,7 +14876,7 @@ function resolveExecutable(token, cwd, env) {
14840
14876
  for (const entry of (env.PATH ?? "").split(delimiter).filter(Boolean)) {
14841
14877
  const candidate = resolve7(entry, token);
14842
14878
  try {
14843
- if (existsSync12(candidate) && statSync3(candidate).isFile()) return realpathSync6(candidate);
14879
+ if (existsSync9(candidate) && statSync3(candidate).isFile()) return realpathSync6(candidate);
14844
14880
  } catch {
14845
14881
  }
14846
14882
  }
@@ -14863,7 +14899,7 @@ function inferredVenvFromToken(token, cwd) {
14863
14899
  const parentName = basename4(parent).toLowerCase();
14864
14900
  if (parentName !== "bin" && parentName !== "scripts") return null;
14865
14901
  const root = dirname6(parent);
14866
- return existsSync12(join16(root, "pyvenv.cfg")) ? root : null;
14902
+ return existsSync9(join16(root, "pyvenv.cfg")) ? root : null;
14867
14903
  }
14868
14904
  function unsupportedEcosystem(command, token) {
14869
14905
  const name = token ? basename4(token).toLowerCase() : "";
@@ -14879,13 +14915,13 @@ function inferredVenv(executable) {
14879
14915
  const parentName = basename4(parent).toLowerCase();
14880
14916
  if (parentName !== "bin" && parentName !== "scripts") return null;
14881
14917
  const root = dirname6(parent);
14882
- return existsSync12(join16(root, "pyvenv.cfg")) ? root : null;
14918
+ return existsSync9(join16(root, "pyvenv.cfg")) ? root : null;
14883
14919
  }
14884
14920
  function venvProblem(root) {
14885
14921
  const cfg = join16(root, "pyvenv.cfg");
14886
- if (!existsSync12(cfg)) return "VIRTUAL_ENV " + JSON.stringify(root) + " has no pyvenv.cfg";
14922
+ if (!existsSync9(cfg)) return "VIRTUAL_ENV " + JSON.stringify(root) + " has no pyvenv.cfg";
14887
14923
  try {
14888
- const body = readFileSync13(cfg, "utf8");
14924
+ const body = readFileSync9(cfg, "utf8");
14889
14925
  if (/^\s*include-system-site-packages\s*=\s*true\s*$/im.test(body)) {
14890
14926
  return "Python environment " + JSON.stringify(root) + " enables system site-packages; those external package roots are not bounded";
14891
14927
  }
@@ -14910,7 +14946,7 @@ function discoverDependencyEnvironment(cwdInput, command, env = process.env) {
14910
14946
  };
14911
14947
  try {
14912
14948
  const nodeModules = join16(cwd, "node_modules");
14913
- if (existsSync12(nodeModules)) addRoot("node_modules", nodeModules);
14949
+ if (existsSync9(nodeModules)) addRoot("node_modules", nodeModules);
14914
14950
  else probes.push({ kind: "node_modules", path: nodeModules });
14915
14951
  const token = firstExecutable(command);
14916
14952
  const executable = resolveExecutable(token, cwd, env);
@@ -14922,7 +14958,7 @@ function discoverDependencyEnvironment(cwdInput, command, env = process.env) {
14922
14958
  venv = resolve7(env.VIRTUAL_ENV);
14923
14959
  } else {
14924
14960
  venv = inferredVenv(executable) ?? inferredVenvFromToken(token, cwd);
14925
- if (!venv && /(?:^|\s)uv\s+run(?:\s|$)/.test(command) && existsSync12(join16(cwd, ".venv", "pyvenv.cfg"))) {
14961
+ if (!venv && /(?:^|\s)uv\s+run(?:\s|$)/.test(command) && existsSync9(join16(cwd, ".venv", "pyvenv.cfg"))) {
14926
14962
  venv = join16(cwd, ".venv");
14927
14963
  }
14928
14964
  }
@@ -15401,7 +15437,7 @@ if (child) {
15401
15437
  // src/verifier-backend.ts
15402
15438
  import { createHash as createHash11, randomUUID } from "node:crypto";
15403
15439
  import { spawnSync as spawnSync2 } from "node:child_process";
15404
- import { accessSync as accessSync2, constants as constants4, readFileSync as readFileSync14, realpathSync as realpathSync7, statSync as statSync4 } from "node:fs";
15440
+ import { accessSync as accessSync2, constants as constants4, readFileSync as readFileSync10, realpathSync as realpathSync7, statSync as statSync4 } from "node:fs";
15405
15441
  import { delimiter as delimiter2, dirname as dirname7, join as join18, resolve as resolve8 } from "node:path";
15406
15442
  function identity() {
15407
15443
  const uid = typeof process.getuid === "function" ? process.getuid() : null;
@@ -15446,7 +15482,7 @@ function findExecutable(name) {
15446
15482
  return null;
15447
15483
  }
15448
15484
  function fileSha256(path) {
15449
- return createHash11("sha256").update(readFileSync14(path)).digest("hex");
15485
+ return createHash11("sha256").update(readFileSync10(path)).digest("hex");
15450
15486
  }
15451
15487
  function engineClientEnv() {
15452
15488
  return {
@@ -15880,7 +15916,7 @@ var init_verifier_backend = __esm({
15880
15916
  // src/verification-state.ts
15881
15917
  import { execFileSync as execFileSync8 } from "node:child_process";
15882
15918
  import { createHash as createHash12 } from "node:crypto";
15883
- import { mkdirSync as mkdirSync8, readFileSync as readFileSync15, rmSync as rmSync7, writeFileSync as writeFileSync9 } from "node:fs";
15919
+ import { mkdirSync as mkdirSync8, readFileSync as readFileSync11, rmSync as rmSync7, writeFileSync as writeFileSync9 } from "node:fs";
15884
15920
  import { dirname as dirname8, join as join19 } from "node:path";
15885
15921
  function git2(args, cwd) {
15886
15922
  return execFileSync8("git", args, {
@@ -15939,7 +15975,7 @@ function interventionWiring(cwd) {
15939
15975
  return sources.map(([source, path]) => {
15940
15976
  let parsed;
15941
15977
  try {
15942
- parsed = JSON.parse(readFileSync15(path, "utf8"));
15978
+ parsed = JSON.parse(readFileSync11(path, "utf8"));
15943
15979
  } catch {
15944
15980
  return { source, present: false };
15945
15981
  }
@@ -16092,7 +16128,7 @@ function readVerificationRecord(cwd) {
16092
16128
  if (!path) return null;
16093
16129
  let raw;
16094
16130
  try {
16095
- raw = readFileSync15(path, "utf8");
16131
+ raw = readFileSync11(path, "utf8");
16096
16132
  } catch {
16097
16133
  return null;
16098
16134
  }
@@ -16141,7 +16177,7 @@ function readVerifyingMarker(cwd) {
16141
16177
  if (!path) return null;
16142
16178
  let parsed;
16143
16179
  try {
16144
- parsed = JSON.parse(readFileSync15(path, "utf8"));
16180
+ parsed = JSON.parse(readFileSync11(path, "utf8"));
16145
16181
  } catch {
16146
16182
  return null;
16147
16183
  }
@@ -16505,7 +16541,7 @@ var init_verification_receipt = __esm({
16505
16541
  // src/cli/verify.ts
16506
16542
  import { execFileSync as execFileSync9, spawnSync as spawnSync3 } from "node:child_process";
16507
16543
  import { createHash as createHash14 } from "node:crypto";
16508
- import { chmodSync as chmodSync2, cpSync, lstatSync as lstatSync10, mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync3, readFileSync as readFileSync16, readlinkSync as readlinkSync3, rmSync as rmSync9, symlinkSync, writeFileSync as writeFileSync11, existsSync as existsSync13 } from "node:fs";
16544
+ import { chmodSync as chmodSync2, cpSync, lstatSync as lstatSync10, mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync3, readFileSync as readFileSync12, readlinkSync as readlinkSync3, rmSync as rmSync9, symlinkSync, writeFileSync as writeFileSync11, existsSync as existsSync10 } from "node:fs";
16509
16545
  import { tmpdir as tmpdir4 } from "node:os";
16510
16546
  import { dirname as dirname10, isAbsolute as isAbsolute11, join as join21, relative as relative6, resolve as resolve9, sep as sep4 } from "node:path";
16511
16547
  function oracleAssuranceReport() {
@@ -16701,7 +16737,7 @@ function probeFilesystemCaseSensitivity(dir) {
16701
16737
  const lower = join21(dir, ".tw-case-probe-a");
16702
16738
  try {
16703
16739
  writeFileSync11(upper, "", { flag: "wx" });
16704
- return !existsSync13(lower);
16740
+ return !existsSync10(lower);
16705
16741
  } finally {
16706
16742
  rmSync9(upper, { force: true });
16707
16743
  }
@@ -16765,7 +16801,7 @@ function overlayDigest(dest, paths) {
16765
16801
  try {
16766
16802
  const st = lstatSync10(p);
16767
16803
  h.update(String(st.mode));
16768
- h.update(st.isSymbolicLink() ? readlinkSync3(p) : readFileSync16(p));
16804
+ h.update(st.isSymbolicLink() ? readlinkSync3(p) : readFileSync12(p));
16769
16805
  } catch {
16770
16806
  h.update("<gone>");
16771
16807
  }
@@ -17579,7 +17615,7 @@ var init_verify = __esm({
17579
17615
  // src/cli/run.ts
17580
17616
  import { execFileSync as execFileSync10, spawn, spawnSync as spawnSync4 } from "node:child_process";
17581
17617
  import { randomBytes as randomBytes3 } from "node:crypto";
17582
- import { accessSync as accessSync3, constants as fsConstants, mkdtempSync as mkdtempSync4, readdirSync as readdirSync4, readFileSync as readFileSync17, readlinkSync as readlinkSync4, realpathSync as realpathSync8, rmSync as rmSync10, statSync as statSync5, writeFileSync as writeFileSync12 } from "node:fs";
17618
+ import { accessSync as accessSync3, constants as fsConstants, mkdtempSync as mkdtempSync4, readdirSync as readdirSync4, readFileSync as readFileSync13, readlinkSync as readlinkSync4, realpathSync as realpathSync8, rmSync as rmSync10, statSync as statSync5, writeFileSync as writeFileSync12 } from "node:fs";
17583
17619
  import { tmpdir as tmpdir5 } from "node:os";
17584
17620
  import { dirname as dirname11, join as join22, resolve as resolve10 } from "node:path";
17585
17621
  function authoritativeRunLifecyclePlatform(platform = process.platform) {
@@ -17733,7 +17769,7 @@ function runAgentSupervised(argv, cwd, budgetSecs, linuxPythonCandidates, lifecy
17733
17769
  }
17734
17770
  let state = {};
17735
17771
  try {
17736
- state = JSON.parse(readFileSync17(resultFile, "utf8"));
17772
+ state = JSON.parse(readFileSync13(resultFile, "utf8"));
17737
17773
  } catch {
17738
17774
  return {
17739
17775
  exit: 1,
@@ -17777,7 +17813,7 @@ function observerExited(pid) {
17777
17813
  if (!pidAlive4(pid)) return true;
17778
17814
  if (process.platform !== "linux") return false;
17779
17815
  try {
17780
- const stat = readFileSync17(`/proc/${pid}/stat`, "utf8");
17816
+ const stat = readFileSync13(`/proc/${pid}/stat`, "utf8");
17781
17817
  const state = stat.slice(stat.lastIndexOf(")") + 2).split(" ")[0];
17782
17818
  return state === "Z" || state === "X";
17783
17819
  } catch (e) {
@@ -17899,7 +17935,7 @@ function git4(args, cwd) {
17899
17935
  }
17900
17936
  function nowTicks() {
17901
17937
  try {
17902
- return Math.floor(parseFloat(readFileSync17("/proc/uptime", "utf8").split(" ")[0]) * 100);
17938
+ return Math.floor(parseFloat(readFileSync13("/proc/uptime", "utf8").split(" ")[0]) * 100);
17903
17939
  } catch {
17904
17940
  return Number.POSITIVE_INFINITY;
17905
17941
  }
@@ -17922,7 +17958,7 @@ function survivorsHoldingTree(cwd, spawnedAfterTicks) {
17922
17958
  const n2 = Number(pid);
17923
17959
  if (n2 === process.pid) continue;
17924
17960
  try {
17925
- const stat = readFileSync17(`/proc/${pid}/stat`, "utf8");
17961
+ const stat = readFileSync13(`/proc/${pid}/stat`, "utf8");
17926
17962
  const startTicks = Number(stat.slice(stat.lastIndexOf(")") + 2).split(" ")[19]);
17927
17963
  if (!Number.isFinite(startTicks) || startTicks < spawnedAfterTicks) continue;
17928
17964
  } catch {
@@ -18495,7 +18531,7 @@ raise SystemExit(0)
18495
18531
 
18496
18532
  // src/cli/doctor.ts
18497
18533
  import { execFileSync as execFileSync11 } from "node:child_process";
18498
- import { existsSync as existsSync14, readFileSync as readFileSync18, readdirSync as readdirSync5 } from "node:fs";
18534
+ import { existsSync as existsSync11, readFileSync as readFileSync14, readdirSync as readdirSync5 } from "node:fs";
18499
18535
  import { join as join23, resolve as resolve11 } from "node:path";
18500
18536
  function lifecyclePlatformCheck(platform = process.platform, linuxPython = platform === "linux" ? trustedLinuxPython() : null) {
18501
18537
  if (platform === "linux") {
@@ -18551,10 +18587,10 @@ function wiringState(status, authority) {
18551
18587
  return authority ? "BROKEN" : "WARN";
18552
18588
  }
18553
18589
  function pinsInFile(path) {
18554
- if (!existsSync14(path)) return [];
18590
+ if (!existsSync11(path)) return [];
18555
18591
  let src = "";
18556
18592
  try {
18557
- src = readFileSync18(path, "utf8");
18593
+ src = readFileSync14(path, "utf8");
18558
18594
  } catch {
18559
18595
  return [];
18560
18596
  }
@@ -18575,13 +18611,13 @@ function workflowPermissionCheck(cwd, workflowRels = [".github/workflows/tamperw
18575
18611
  const warnings = [];
18576
18612
  for (const rel of workflowRels) {
18577
18613
  const path = resolve11(cwd, rel);
18578
- if (!existsSync14(path)) {
18614
+ if (!existsSync11(path)) {
18579
18615
  broken.push(`${rel} is missing`);
18580
18616
  continue;
18581
18617
  }
18582
18618
  let doc;
18583
18619
  try {
18584
- doc = yaml.parse(readFileSync18(path, "utf8"));
18620
+ doc = yaml.parse(readFileSync14(path, "utf8"));
18585
18621
  } catch (e) {
18586
18622
  broken.push(`${rel} is not valid YAML (${e instanceof Error ? e.message : String(e)})`);
18587
18623
  continue;
@@ -18980,7 +19016,7 @@ function diagnose(opts = {}) {
18980
19016
  } else {
18981
19017
  const workflowDirRel = ".github/workflows";
18982
19018
  const workflowDir = resolve11(cwd, workflowDirRel);
18983
- if (!existsSync14(workflowDir)) {
19019
+ if (!existsSync11(workflowDir)) {
18984
19020
  return fail("ci-verifier", `${workflowDirRel}: workflow directory does not exist`);
18985
19021
  }
18986
19022
  let entries;
@@ -19000,12 +19036,12 @@ function diagnose(opts = {}) {
19000
19036
  const authorityWorkflows = [];
19001
19037
  for (const workflowRel of workflowRels) {
19002
19038
  const workflowPath = resolve11(cwd, workflowRel);
19003
- if (!existsSync14(workflowPath)) {
19039
+ if (!existsSync11(workflowPath)) {
19004
19040
  return fail("ci-verifier", `${workflowRel}: workflow does not exist`);
19005
19041
  }
19006
19042
  let doc;
19007
19043
  try {
19008
- doc = yaml.parse(readFileSync18(workflowPath, "utf8"));
19044
+ doc = yaml.parse(readFileSync14(workflowPath, "utf8"));
19009
19045
  } catch (e) {
19010
19046
  return fail(
19011
19047
  "ci-verifier",
@@ -19316,9 +19352,9 @@ var init_status2 = __esm({
19316
19352
  // src/cli/trace-verify.ts
19317
19353
  import { execFileSync as execFileSync12, spawnSync as spawnSync5 } from "node:child_process";
19318
19354
  import {
19319
- existsSync as existsSync15,
19355
+ existsSync as existsSync12,
19320
19356
  mkdtempSync as mkdtempSync5,
19321
- readFileSync as readFileSync19,
19357
+ readFileSync as readFileSync15,
19322
19358
  readdirSync as readdirSync6,
19323
19359
  realpathSync as realpathSync9,
19324
19360
  rmSync as rmSync11,
@@ -19575,7 +19611,7 @@ function materializeBase(base, cwd, dest) {
19575
19611
  }
19576
19612
  const hostModules = join24(cwd, "node_modules");
19577
19613
  const tracedModules = join24(dest, "node_modules");
19578
- if (existsSync15(hostModules) && !existsSync15(tracedModules)) {
19614
+ if (existsSync12(hostModules) && !existsSync12(tracedModules)) {
19579
19615
  symlinkSync2(resolve12(hostModules), tracedModules, "dir");
19580
19616
  }
19581
19617
  }
@@ -19632,7 +19668,7 @@ function straceOnce(root, command, budget) {
19632
19668
  }
19633
19669
  );
19634
19670
  const logs = traced.error ? [] : traceFiles(prefix);
19635
- const accesses = logs.flatMap((path) => parseStraceFileAccess(readFileSync19(path, "utf8"), TRACE_ROOT));
19671
+ const accesses = logs.flatMap((path) => parseStraceFileAccess(readFileSync15(path, "utf8"), TRACE_ROOT));
19636
19672
  const raw = {
19637
19673
  spawnError: traced.error ? traced.error.message : null,
19638
19674
  status: traced.status,
@@ -19887,7 +19923,7 @@ var init_immutable = __esm({
19887
19923
  });
19888
19924
 
19889
19925
  // src/runtimes.ts
19890
- import { existsSync as existsSync16, readFileSync as readFileSync20 } from "node:fs";
19926
+ import { existsSync as existsSync13, readFileSync as readFileSync16 } from "node:fs";
19891
19927
  import { join as join25 } from "node:path";
19892
19928
  function isRecord6(x) {
19893
19929
  return typeof x === "object" && x !== null && !Array.isArray(x);
@@ -19917,8 +19953,8 @@ function claudeSettingsBeyondTamperward(cwd) {
19917
19953
  const path = join25(cwd, ".claude", "settings.json");
19918
19954
  let raw;
19919
19955
  try {
19920
- if (!existsSync16(path)) return false;
19921
- raw = readFileSync20(path, "utf8");
19956
+ if (!existsSync13(path)) return false;
19957
+ raw = readFileSync16(path, "utf8");
19922
19958
  } catch {
19923
19959
  return false;
19924
19960
  }
@@ -19944,7 +19980,7 @@ function detectRuntimes(cwd) {
19944
19980
  for (const rt of KNOWN_RUNTIMES) {
19945
19981
  const marker = rt.markers.find((m) => {
19946
19982
  try {
19947
- return existsSync16(join25(cwd, m));
19983
+ return existsSync13(join25(cwd, m));
19948
19984
  } catch {
19949
19985
  return false;
19950
19986
  }
@@ -20969,7 +21005,7 @@ var init_adapter3 = __esm({
20969
21005
 
20970
21006
  // src/adapters/copilot-sdk/changes.ts
20971
21007
  import { execFileSync as execFileSync13 } from "node:child_process";
20972
- import { mkdtempSync as mkdtempSync6, writeFileSync as writeFileSync13, readFileSync as readFileSync21, rmSync as rmSync12, existsSync as existsSync17, realpathSync as realpathSync10 } from "node:fs";
21008
+ import { mkdtempSync as mkdtempSync6, writeFileSync as writeFileSync13, readFileSync as readFileSync17, rmSync as rmSync12, existsSync as existsSync14, realpathSync as realpathSync10 } from "node:fs";
20973
21009
  import { tmpdir as tmpdir7 } from "node:os";
20974
21010
  import { basename as basename5, dirname as dirname12, isAbsolute as isAbsolute16, relative as relative11, resolve as resolve15, join as join26 } from "node:path";
20975
21011
  function asStr4(v) {
@@ -20988,7 +21024,7 @@ function canonicalContainedTarget(abs, root) {
20988
21024
  }
20989
21025
  let dir = abs;
20990
21026
  const tail = [];
20991
- while (!existsSync17(dir)) {
21027
+ while (!existsSync14(dir)) {
20992
21028
  const parent = dirname12(dir);
20993
21029
  if (parent === dir) break;
20994
21030
  tail.unshift(basename5(dir));
@@ -21063,7 +21099,7 @@ function reconstructAfterViaGit(rawDiff, display2, before, isCreate) {
21063
21099
  if (statPath !== TARGET) throw new Error(`write diff reconstructs a different file (${statPath}) than the bound target`);
21064
21100
  git8(["--check"]);
21065
21101
  git8([]);
21066
- return op === "delete" ? null : readFileSync21(targetPath, "utf8");
21102
+ return op === "delete" ? null : readFileSync17(targetPath, "utf8");
21067
21103
  } catch (e) {
21068
21104
  throw new Error(`could not reconstruct the write to ${display2} from its diff via git apply: ${e instanceof Error ? e.message : String(e)}`);
21069
21105
  } finally {
@@ -21816,7 +21852,7 @@ var init_runtime_qualification = __esm({
21816
21852
 
21817
21853
  // src/cli/runtime.ts
21818
21854
  import { execFileSync as execFileSync14 } from "node:child_process";
21819
- import { existsSync as existsSync18, mkdirSync as mkdirSync11, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "node:fs";
21855
+ import { existsSync as existsSync15, mkdirSync as mkdirSync11, readFileSync as readFileSync18, writeFileSync as writeFileSync14 } from "node:fs";
21820
21856
  import { join as join27, dirname as dirname13 } from "node:path";
21821
21857
  function storePath(cwd) {
21822
21858
  const dir = gitDir(cwd);
@@ -21824,9 +21860,9 @@ function storePath(cwd) {
21824
21860
  }
21825
21861
  function readStore(cwd) {
21826
21862
  const path = storePath(cwd);
21827
- if (!path || !existsSync18(path)) return null;
21863
+ if (!path || !existsSync15(path)) return null;
21828
21864
  try {
21829
- const parsed = JSON.parse(readFileSync22(path, "utf8"));
21865
+ const parsed = JSON.parse(readFileSync18(path, "utf8"));
21830
21866
  if (parsed && typeof parsed === "object" && parsed.records && typeof parsed.records === "object") return parsed;
21831
21867
  } catch {
21832
21868
  return null;
@@ -21995,9 +22031,9 @@ function resolveHookConfigHash(canonicalId, cwd) {
21995
22031
  "github-copilot-cli": join27(cwd, ".github", "hooks", "tamperward.json")
21996
22032
  };
21997
22033
  const file = files[canonicalId];
21998
- if (!file || !existsSync18(file)) return null;
22034
+ if (!file || !existsSync15(file)) return null;
21999
22035
  try {
22000
- const raw = readFileSync22(file, "utf8");
22036
+ const raw = readFileSync18(file, "utf8");
22001
22037
  let hooks = raw;
22002
22038
  try {
22003
22039
  const parsed = JSON.parse(raw);
@@ -22276,7 +22312,7 @@ var init_runtime = __esm({
22276
22312
 
22277
22313
  // src/cli/onboard.ts
22278
22314
  import { execFileSync as execFileSync15 } from "node:child_process";
22279
- import { lstatSync as lstatSync11, mkdtempSync as mkdtempSync7, readFileSync as readFileSync23, realpathSync as realpathSync11, rmSync as rmSync13 } from "node:fs";
22315
+ import { lstatSync as lstatSync11, mkdtempSync as mkdtempSync7, readFileSync as readFileSync19, realpathSync as realpathSync11, rmSync as rmSync13 } from "node:fs";
22280
22316
  import { tmpdir as tmpdir8 } from "node:os";
22281
22317
  import { join as join28, relative as relative12, resolve as resolve16, sep as sep6 } from "node:path";
22282
22318
  import { createInterface } from "node:readline";
@@ -22349,7 +22385,7 @@ function writeVerifyCommand(cwd, command) {
22349
22385
  return `${POLICY_FILE} is not a regular file; refusing to follow or replace a symlink or special file`;
22350
22386
  }
22351
22387
  const mode = existingMode(path, 420);
22352
- const original = kind === "file" ? readFileSync23(path, "utf8") : null;
22388
+ const original = kind === "file" ? readFileSync19(path, "utf8") : null;
22353
22389
  let next;
22354
22390
  try {
22355
22391
  const doc = parseDocument(original && original.trim() ? original : "version: 1\n");
@@ -23004,7 +23040,7 @@ var init_capture = __esm({
23004
23040
 
23005
23041
  // src/research/manifest.ts
23006
23042
  import { createHash as createHash16 } from "node:crypto";
23007
- import { readFileSync as readFileSync24 } from "node:fs";
23043
+ import { readFileSync as readFileSync20 } from "node:fs";
23008
23044
  import { dirname as dirname14, resolve as resolve18 } from "node:path";
23009
23045
  function taskFrom(raw, index, manifestDir) {
23010
23046
  const where = `task #${index + 1}`;
@@ -23038,7 +23074,7 @@ function readManifest(path) {
23038
23074
  const abs = resolve18(path);
23039
23075
  let bytes;
23040
23076
  try {
23041
- bytes = readFileSync24(abs);
23077
+ bytes = readFileSync20(abs);
23042
23078
  } catch (e) {
23043
23079
  throw new ResearchError(`cannot read task manifest ${abs}: ${e instanceof Error ? e.message : String(e)}`);
23044
23080
  }
@@ -23457,7 +23493,7 @@ var init_record = __esm({
23457
23493
  // src/research/run.ts
23458
23494
  import { randomUUID as randomUUID2 } from "node:crypto";
23459
23495
  import { execFileSync as execFileSync16 } from "node:child_process";
23460
- import { closeSync as closeSync5, existsSync as existsSync19, linkSync, mkdirSync as mkdirSync12, openSync as openSync5, readFileSync as readFileSync25, renameSync as renameSync4, rmSync as rmSync14, unlinkSync, writeFileSync as writeFileSync15, writeSync } from "node:fs";
23496
+ import { closeSync as closeSync5, existsSync as existsSync16, linkSync, mkdirSync as mkdirSync12, openSync as openSync5, readFileSync as readFileSync21, renameSync as renameSync4, rmSync as rmSync14, unlinkSync, writeFileSync as writeFileSync15, writeSync } from "node:fs";
23461
23497
  import { hostname } from "node:os";
23462
23498
  import { join as join29, resolve as resolve19 } from "node:path";
23463
23499
  function git7(args, cwd) {
@@ -23471,7 +23507,7 @@ function researchLockPath(ledger) {
23471
23507
  }
23472
23508
  function readLockOwner(path) {
23473
23509
  try {
23474
- const parsed = JSON.parse(readFileSync25(path, "utf8"));
23510
+ const parsed = JSON.parse(readFileSync21(path, "utf8"));
23475
23511
  if (!isRecord(parsed) || typeof parsed.pid !== "number" || !Number.isInteger(parsed.pid) || parsed.pid <= 0) return null;
23476
23512
  if (typeof parsed.host !== "string" || typeof parsed.started_at !== "string" || typeof parsed.token !== "string") return null;
23477
23513
  return { pid: parsed.pid, host: parsed.host, started_at: parsed.started_at, token: parsed.token };
@@ -23494,7 +23530,7 @@ function lockHolder(path) {
23494
23530
  function acquireResearchLock(ledger, breakStaleLock = false) {
23495
23531
  mkdirSync12(ledger, { recursive: true });
23496
23532
  const path = researchLockPath(ledger);
23497
- if (breakStaleLock && existsSync19(path)) {
23533
+ if (breakStaleLock && existsSync16(path)) {
23498
23534
  const owner2 = readLockOwner(path);
23499
23535
  if (!owner2) {
23500
23536
  throw new ResearchError(`research output ${ledger} has an unreadable lock at ${path}; verify no run is active, then remove it deliberately`);
@@ -23556,7 +23592,7 @@ function acquireResearchLock(ledger, breakStaleLock = false) {
23556
23592
  if (released) return;
23557
23593
  released = true;
23558
23594
  try {
23559
- if (readFileSync25(path, "utf8") === text) unlinkSync(path);
23595
+ if (readFileSync21(path, "utf8") === text) unlinkSync(path);
23560
23596
  } catch {
23561
23597
  }
23562
23598
  }
@@ -23565,7 +23601,7 @@ function acquireResearchLock(ledger, breakStaleLock = false) {
23565
23601
  function resumableRecord(path, expected) {
23566
23602
  let raw;
23567
23603
  try {
23568
- raw = JSON.parse(readFileSync25(path, "utf8"));
23604
+ raw = JSON.parse(readFileSync21(path, "utf8"));
23569
23605
  } catch (e) {
23570
23606
  throw new ResearchError(`ledger record ${path} is malformed (${errorMessage(e).split("\n")[0]}); remove it to regenerate the pair, or use a new --out`);
23571
23607
  }
@@ -23867,7 +23903,7 @@ function runResearch(opts) {
23867
23903
  try {
23868
23904
  for (let pair = 1; pair <= pairs; pair++) {
23869
23905
  const path = pairRecordPath(ledger, task.id, pair);
23870
- if (!existsSync19(path)) continue;
23906
+ if (!existsSync16(path)) continue;
23871
23907
  const existing = resumableRecord(path, {
23872
23908
  task: task.id,
23873
23909
  pair,
@@ -23987,7 +24023,7 @@ var init_run2 = __esm({
23987
24023
  });
23988
24024
 
23989
24025
  // src/research/ledger-files.ts
23990
- import { closeSync as closeSync6, constants as constants5, fstatSync as fstatSync3, lstatSync as lstatSync12, openSync as openSync6, readFileSync as readFileSync26, readdirSync as readdirSync7, realpathSync as realpathSync12 } from "node:fs";
24026
+ import { closeSync as closeSync6, constants as constants5, fstatSync as fstatSync3, lstatSync as lstatSync12, openSync as openSync6, readFileSync as readFileSync22, readdirSync as readdirSync7, realpathSync as realpathSync12 } from "node:fs";
23991
24027
  import { join as join30, resolve as resolve20 } from "node:path";
23992
24028
  function lstatOrNull(path) {
23993
24029
  try {
@@ -24030,7 +24066,7 @@ function readRegularFile(path, realPairsDir, name) {
24030
24066
  if (!opened.isFile() || !sameInode || opened.nlink !== 1) {
24031
24067
  throw new ResearchError(`ledger record ${path} changed between listing and reading; refusing to read it`);
24032
24068
  }
24033
- return readFileSync26(fd);
24069
+ return readFileSync22(fd);
24034
24070
  } finally {
24035
24071
  closeSync6(fd);
24036
24072
  }
@@ -24203,7 +24239,7 @@ var init_summarize = __esm({
24203
24239
 
24204
24240
  // src/research/init.ts
24205
24241
  import { createHash as createHash17 } from "node:crypto";
24206
- import { existsSync as existsSync20, mkdirSync as mkdirSync13, readFileSync as readFileSync27, writeFileSync as writeFileSync16 } from "node:fs";
24242
+ import { existsSync as existsSync17, mkdirSync as mkdirSync13, readFileSync as readFileSync23, writeFileSync as writeFileSync16 } from "node:fs";
24207
24243
  import { basename as basename6, dirname as dirname15, resolve as resolve21 } from "node:path";
24208
24244
  function idFrom(repo) {
24209
24245
  const clean = repo.replace(/[\\/]$/, "").split(/[\\/]/).pop() || "task";
@@ -24215,7 +24251,7 @@ function createResearchManifest(opts) {
24215
24251
  if (!opts.prompt) throw new ResearchError("research init requires --prompt");
24216
24252
  if (!opts.verifyCommand) throw new ResearchError("research init requires --verify-command");
24217
24253
  const out3 = resolve21(opts.out);
24218
- if (existsSync20(out3)) throw new ResearchError(`research init refuses to overwrite ${out3}; choose a new path`);
24254
+ if (existsSync17(out3)) throw new ResearchError(`research init refuses to overwrite ${out3}; choose a new path`);
24219
24255
  const id = opts.id ?? idFrom(opts.repo);
24220
24256
  if (!/^[A-Za-z0-9._-]+$/.test(id)) throw new ResearchError(`research init id must match [A-Za-z0-9._-] (got "${id}")`);
24221
24257
  if (opts.verifyBudget !== void 0 && (!Number.isFinite(opts.verifyBudget) || opts.verifyBudget <= 0)) {
@@ -24255,7 +24291,7 @@ function runResearchInit(opts) {
24255
24291
  }
24256
24292
  }
24257
24293
  function requireHash(path) {
24258
- return createHash17("sha256").update(readFileSync27(path)).digest("hex");
24294
+ return createHash17("sha256").update(readFileSync23(path)).digest("hex");
24259
24295
  }
24260
24296
  var init_init2 = __esm({
24261
24297
  "src/research/init.ts"() {
@@ -24323,7 +24359,7 @@ var init_report2 = __esm({
24323
24359
  import { createHash as createHash18 } from "node:crypto";
24324
24360
  import { isDeepStrictEqual } from "node:util";
24325
24361
  import { gzipSync, gunzipSync } from "node:zlib";
24326
- import { mkdirSync as mkdirSync14, readFileSync as readFileSync28, writeFileSync as writeFileSync17 } from "node:fs";
24362
+ import { mkdirSync as mkdirSync14, readFileSync as readFileSync24, writeFileSync as writeFileSync17 } from "node:fs";
24327
24363
  import { dirname as dirname16, resolve as resolve22 } from "node:path";
24328
24364
  function octal(value, width) {
24329
24365
  return value.toString(8).padStart(width - 1, "0") + "\0";
@@ -24429,7 +24465,7 @@ function jsonBytes(value) {
24429
24465
  function validateResearchBundle(path) {
24430
24466
  let files;
24431
24467
  try {
24432
- files = parseTar(gunzipSync(readFileSync28(resolve22(path))));
24468
+ files = parseTar(gunzipSync(readFileSync24(resolve22(path))));
24433
24469
  } catch (e) {
24434
24470
  throw new ResearchError(`cannot read research bundle ${path}: ${e instanceof Error ? e.message : String(e)}`);
24435
24471
  }
@@ -24499,7 +24535,7 @@ function createResearchBundle(opts) {
24499
24535
  const { records, entries } = packagedRecords(ledger);
24500
24536
  const summary = summarizeRecords(records);
24501
24537
  if (opts.manifest) {
24502
- const manifest = readFileSync28(resolve22(opts.manifest));
24538
+ const manifest = readFileSync24(resolve22(opts.manifest));
24503
24539
  const sha3 = createHash18("sha256").update(manifest).digest("hex");
24504
24540
  if (sha3 !== summary.manifest_sha256) throw new ResearchError(`manifest sha256 ${sha3} does not match ledger ${summary.manifest_sha256}`);
24505
24541
  entries.push({ name: "manifest.json", bytes: manifest });
@@ -24670,7 +24706,7 @@ var init_research = __esm({
24670
24706
  });
24671
24707
 
24672
24708
  // src/cli/receipt.ts
24673
- import { appendFileSync as appendFileSync6, readFileSync as readFileSync29, writeFileSync as writeFileSync18 } from "node:fs";
24709
+ import { appendFileSync as appendFileSync6, readFileSync as readFileSync25, writeFileSync as writeFileSync18 } from "node:fs";
24674
24710
  function parseReceipt(args) {
24675
24711
  const [sub, ...rest] = args;
24676
24712
  const exportOpts = {};
@@ -24797,7 +24833,7 @@ function ciAdjudicate(cwd, opts) {
24797
24833
  if (opts.ciResult !== void 0) {
24798
24834
  let doc;
24799
24835
  try {
24800
- doc = JSON.parse(readFileSync29(opts.ciResult, "utf8"));
24836
+ doc = JSON.parse(readFileSync25(opts.ciResult, "utf8"));
24801
24837
  } catch (e) {
24802
24838
  return {
24803
24839
  ci: { verdict: "CANNOT_VERIFY", binding, binding_error: `unreadable CI verify result: ${e instanceof Error ? e.message : String(e)}` },
@@ -24943,7 +24979,7 @@ function loadClaimedReceipt(path) {
24943
24979
  }
24944
24980
  let raw;
24945
24981
  try {
24946
- raw = readFileSync29(path, "utf8");
24982
+ raw = readFileSync25(path, "utf8");
24947
24983
  } catch (e) {
24948
24984
  return { disposition: "MALFORMED", detail: `receipt file could not be read (${e instanceof Error ? e.message : String(e)})` };
24949
24985
  }
@@ -25804,7 +25840,7 @@ var init_main = __esm({
25804
25840
  // src/cli/index.ts
25805
25841
  init_hook_client();
25806
25842
  init_exit();
25807
- import { readFileSync as readFileSync30 } from "node:fs";
25843
+ import { readFileSync as readFileSync26 } from "node:fs";
25808
25844
  function loadMain() {
25809
25845
  return Promise.resolve().then(() => (init_main(), main_exports));
25810
25846
  }
@@ -25817,7 +25853,7 @@ async function launch(argv) {
25817
25853
  if (kind && hookServiceEnabled()) {
25818
25854
  let raw = null;
25819
25855
  try {
25820
- raw = readFileSync30(0, "utf8");
25856
+ raw = readFileSync26(0, "utf8");
25821
25857
  } catch {
25822
25858
  raw = null;
25823
25859
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tamperward",
3
- "version": "2.39.8",
3
+ "version": "2.39.10",
4
4
  "description": "The deterministic agent-integrity gate. One ruleset, evaluated on the actual diff/commands as a verdict, enforced everywhere a change can be made.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "hexrift",