@mrciphersmith/keryx 0.4.54 → 0.4.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -38,7 +38,7 @@ import {
38
38
  utimesSync,
39
39
  writeFileSync
40
40
  } from "fs";
41
- import { access, chmod, mkdir, readFile, rename, rm, stat, utimes, writeFile } from "fs/promises";
41
+ import { access, chmod, link, mkdir, readFile, rename, rm, stat, utimes, writeFile } from "fs/promises";
42
42
  import path from "path";
43
43
  async function pathExists(filePath) {
44
44
  try {
@@ -81,6 +81,27 @@ async function writeFileAtomic(filePath, content, options = {}) {
81
81
  throw error;
82
82
  }
83
83
  }
84
+ async function writeFileAtomicIfAbsent(filePath, content) {
85
+ const dir = path.dirname(filePath);
86
+ await mkdir(dir, { recursive: true });
87
+ const tmp = path.join(dir, `.${path.basename(filePath)}.${process.pid}.${Date.now()}.${randomUUID()}.tmp`);
88
+ try {
89
+ await writeFile(tmp, content, "utf8");
90
+ try {
91
+ await link(tmp, filePath);
92
+ return "written";
93
+ } catch (error) {
94
+ if (!isAlreadyExistsError(error))
95
+ throw error;
96
+ }
97
+ const existing = await readFile(filePath, "utf8");
98
+ if (existing !== content)
99
+ throw new Error(`refusing to replace ${path.basename(filePath)}: it exists with different content`);
100
+ return "exists";
101
+ } finally {
102
+ await rm(tmp, { force: true }).catch(() => {});
103
+ }
104
+ }
84
105
  async function withFileLock(lockPath, fn, options = {}) {
85
106
  const timeoutMs = options.timeoutMs ?? 5000;
86
107
  const retryMs = options.retryMs ?? 25;
@@ -30426,6 +30447,23 @@ async function collectReviewers(projectRoot, deps = {}) {
30426
30447
  return { bundled, bundledSource, project };
30427
30448
  }
30428
30449
 
30450
+ // src/review/conform-state.ts
30451
+ init_redact();
30452
+ // src/review/jev-risk.ts
30453
+ var TEST_INFIX_RE = /\.(test|spec)\./;
30454
+ var TEST_DIR_RE = /(^|\/)(__tests__|tests?)\//;
30455
+ function isTestFilePath(path) {
30456
+ return TEST_INFIX_RE.test(path) || TEST_DIR_RE.test(path);
30457
+ }
30458
+ var DIMENSION_INSTRUCTIONS = {
30459
+ security: "Given the deterministic facts and the hunk above, how likely is this change SECURITY-SENSITIVE \u2014 it touches " + "authentication, authorization/permissions, cryptography, secrets, input validation, or a trust boundary?",
30460
+ "data-migration": "Given the deterministic facts and the hunk above, how likely is this change to affect DATA or a MIGRATION \u2014 a " + "schema change, a data migration, or the shape of stored/persisted data?",
30461
+ "public-api": "Given the deterministic facts and the hunk above, how likely is this change to alter a PUBLIC API or CONTRACT \u2014 " + "an exported function/type signature, a wire format, a CLI flag, or anything a caller outside this hunk depends on \u2014 in a way that breaks a caller?",
30462
+ concurrency: "Given the deterministic facts and the hunk above, how likely is this change to touch CONCURRENCY \u2014 locking, " + "async ordering, shared mutable state, or a race condition?",
30463
+ "error-handling": "Given the deterministic facts and the hunk above, how likely is this change to alter ERROR HANDLING \u2014 how a " + "failure is caught, reported, retried, or recovered from?"
30464
+ };
30465
+ var IMPACT_TEMPLATE = "A high-risk hunk with no test in the same diff exercising its module is the shape of change most likely to " + "regress silently: nobody but a careful human reviewer will notice before it ships.";
30466
+
30429
30467
  // src/review/jev-select.ts
30430
30468
  var CORE_MANDATORY_REVIEWER_IDS = [
30431
30469
  "review-logic",
@@ -31219,8 +31257,8 @@ var BUNDLED_PATH_GATES = {
31219
31257
  "review-flow-graph": (f) => /(^|\/)(src\/core\/flow|src\/graph|src\/shared\/flow)\//.test(f),
31220
31258
  "review-testing-practices": (f) => TEST_FILE.test(f) || /\.msw\.ts$/.test(f),
31221
31259
  "review-frontend-conventions": (f) => FRONTEND_EXT.test(f) || /\.stories\.tsx$/.test(f) || CODE_FILE.test(f),
31222
- "review-layout": (f) => /\.(tsx|jsx|css|scss)$/.test(f),
31223
- "review-ui-ux": (f) => /\.(tsx|jsx|vue|svelte|html|css|scss)$/.test(f)
31260
+ "review-layout": (f) => !isTestFilePath(f) && /\.(tsx|jsx|css|scss)$/.test(f),
31261
+ "review-ui-ux": (f) => !isTestFilePath(f) && /\.(tsx|jsx|vue|svelte|html|css|scss)$/.test(f)
31224
31262
  };
31225
31263
  var RISK_PATH_GATES = Object.fromEntries(Object.entries(BUNDLED_PATH_GATES).filter(([name]) => name !== "review-testing-practices" && name !== "review-frontend-conventions" && name !== "review-ui-ux"));
31226
31264
  async function decideRoundDepth(root, request, input) {
@@ -31831,23 +31869,6 @@ function projectRootOfPackage(packageDir) {
31831
31869
  return found !== resolved ? found : path55.resolve(resolved, "..", "..", "..");
31832
31870
  }
31833
31871
 
31834
- // src/review/conform-state.ts
31835
- init_redact();
31836
- // src/review/jev-risk.ts
31837
- var TEST_INFIX_RE = /\.(test|spec)\./;
31838
- var TEST_DIR_RE = /(^|\/)(__tests__|tests?)\//;
31839
- function isTestFilePath(path) {
31840
- return TEST_INFIX_RE.test(path) || TEST_DIR_RE.test(path);
31841
- }
31842
- var DIMENSION_INSTRUCTIONS = {
31843
- security: "Given the deterministic facts and the hunk above, how likely is this change SECURITY-SENSITIVE \u2014 it touches " + "authentication, authorization/permissions, cryptography, secrets, input validation, or a trust boundary?",
31844
- "data-migration": "Given the deterministic facts and the hunk above, how likely is this change to affect DATA or a MIGRATION \u2014 a " + "schema change, a data migration, or the shape of stored/persisted data?",
31845
- "public-api": "Given the deterministic facts and the hunk above, how likely is this change to alter a PUBLIC API or CONTRACT \u2014 " + "an exported function/type signature, a wire format, a CLI flag, or anything a caller outside this hunk depends on \u2014 in a way that breaks a caller?",
31846
- concurrency: "Given the deterministic facts and the hunk above, how likely is this change to touch CONCURRENCY \u2014 locking, " + "async ordering, shared mutable state, or a race condition?",
31847
- "error-handling": "Given the deterministic facts and the hunk above, how likely is this change to alter ERROR HANDLING \u2014 how a " + "failure is caught, reported, retried, or recovered from?"
31848
- };
31849
- var IMPACT_TEMPLATE = "A high-risk hunk with no test in the same diff exercising its module is the shape of change most likely to " + "regress silently: nobody but a careful human reviewer will notice before it ships.";
31850
-
31851
31872
  // src/review/slice-routing.ts
31852
31873
  var ALWAYS_ROLE = "review-logic";
31853
31874
  var REGRESSION_ROLE = "review-regression";
@@ -48001,9 +48022,9 @@ ${safeSeeds.content}`;
48001
48022
  const diffFile = `${input.kind}.${shortHash}.diff.txt`;
48002
48023
  const flowFile = `${input.kind}.${shortHash}.flow.json`;
48003
48024
  const seedsFile = `${input.kind}.${shortHash}.seeds.json`;
48004
- await writeFileAtomic(path150.join(evidenceDir, diffFile), safeDiff.content);
48005
- await writeFileAtomic(path150.join(evidenceDir, flowFile), safeFlow.content);
48006
- await writeFileAtomic(path150.join(evidenceDir, seedsFile), safeSeeds.content);
48025
+ await writeFileAtomicIfAbsent(path150.join(evidenceDir, diffFile), safeDiff.content);
48026
+ await writeFileAtomicIfAbsent(path150.join(evidenceDir, flowFile), safeFlow.content);
48027
+ await writeFileAtomicIfAbsent(path150.join(evidenceDir, seedsFile), safeSeeds.content);
48007
48028
  const observedAt = now().toISOString();
48008
48029
  const relBase = `./.metaproject/workspaces/${input.workspaceId}/machine-evidence`;
48009
48030
  const evidence = [
@@ -48013,7 +48034,7 @@ ${safeSeeds.content}`;
48013
48034
  ];
48014
48035
  if (floor.notice !== undefined) {
48015
48036
  const noticeFile = `${input.kind}.${shortHash}.redaction.md`;
48016
- await writeFileAtomic(path150.join(evidenceDir, noticeFile), floor.notice);
48037
+ await writeFileAtomicIfAbsent(path150.join(evidenceDir, noticeFile), floor.notice);
48017
48038
  evidence.push({ kind: REDACTION_NOTICE_KIND, uri: `${relBase}/${noticeFile}`, revision: sha2567(floor.notice), observedAt });
48018
48039
  }
48019
48040
  return {