crysk 0.3.3 → 0.4.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.
Files changed (42) hide show
  1. package/dist/SKILL-dsnffnfp.md +140 -0
  2. package/dist/SKILL-gnrbph72.md +140 -0
  3. package/dist/SKILL-kq0xejn3.md +553 -0
  4. package/dist/SKILL-qaqsbygw.md +66 -0
  5. package/dist/SKILL-vws0aqb8.md +553 -0
  6. package/dist/ci-admission-t0f5qwth.md +128 -0
  7. package/dist/cli.js +408 -155
  8. package/dist/index.js +151 -20
  9. package/package.json +2 -2
  10. package/skills/crysk-ci-setup/SKILL.md +1 -1
  11. package/skills/crysk-ci-setup/references/ci-admission.md +1 -1
  12. package/skills/crysk-loop/SKILL.md +19 -8
  13. package/skills/crysk-pr/SKILL.md +1 -1
  14. package/src/assets.ts +2 -2
  15. package/src/ci/gates.ts +9 -6
  16. package/src/ci/platform-config.ts +127 -0
  17. package/src/ci/platform-report.ts +702 -0
  18. package/src/ci/platform.ts +449 -0
  19. package/src/ci/reporter.ts +9 -7
  20. package/src/ci/review-admission.ts +8 -4
  21. package/src/ci/setup.ts +112 -9
  22. package/src/compare/loop.ts +9 -1
  23. package/src/compare/martian-adapter.ts +1 -1
  24. package/src/index.ts +1 -1
  25. package/src/pr/admission.ts +53 -11
  26. package/src/pr/ci-admission-gate.ts +2 -1
  27. package/src/pr/finding-state-record.ts +58 -0
  28. package/src/pr/gate-record.ts +22 -0
  29. package/src/pr/inline.ts +3 -0
  30. package/src/pr/posting.ts +4 -0
  31. package/src/pr/pr-status.ts +27 -7
  32. package/src/pr/pr.ts +39 -8
  33. package/src/pr/preflight.ts +43 -1
  34. package/src/pr/publish-outcome.ts +10 -2
  35. package/src/pr/review-pr.ts +5 -3
  36. package/src/rereview/classify.ts +4 -0
  37. package/src/rereview/prepare.ts +47 -22
  38. package/src/rereview/state.ts +34 -8
  39. package/src/review/report.ts +34 -14
  40. package/src/security/published-text.ts +161 -0
  41. package/src/triage/triage.ts +2 -1
  42. package/src/updater.ts +1 -1
package/dist/index.js CHANGED
@@ -2262,6 +2262,101 @@ var init_post_floor = __esm(() => {
2262
2262
  ];
2263
2263
  });
2264
2264
 
2265
+ // src/security/published-text.ts
2266
+ function isSecretValue(name, separator, raw) {
2267
+ const quoted = raw.startsWith('"') || raw.startsWith("'");
2268
+ const value = quoted ? raw.slice(1, -1) : raw;
2269
+ if (value.length < 6 || /^[\d_,.]+$/.test(value) || value.includes("$")) {
2270
+ return false;
2271
+ }
2272
+ if (separator === ":" && /^\d+-\d+$/.test(value))
2273
+ return false;
2274
+ const colon = separator.includes(":");
2275
+ if (!quoted) {
2276
+ if (!colon && separator !== "=")
2277
+ return false;
2278
+ if (/[.()[\]{}<>]/.test(value))
2279
+ return false;
2280
+ if (colon && /^[A-Z][a-z]/.test(value))
2281
+ return false;
2282
+ }
2283
+ if (/\d/.test(value))
2284
+ return true;
2285
+ if (!/pass(?:word|wd)$/i.test(name) || /pass(?:word|wd)/i.test(value)) {
2286
+ return false;
2287
+ }
2288
+ return quoted || !colon || name === name.toUpperCase();
2289
+ }
2290
+ function redactPrivateKeys(text) {
2291
+ if (!text.includes("PRIVATE KEY"))
2292
+ return text;
2293
+ let out = "";
2294
+ let from = 0;
2295
+ let noMoreEnds = false;
2296
+ PEM_BEGIN.lastIndex = 0;
2297
+ for (;; ) {
2298
+ const begin = PEM_BEGIN.exec(text);
2299
+ if (begin === null)
2300
+ break;
2301
+ let to = PEM_BEGIN.lastIndex;
2302
+ let closed = false;
2303
+ if (!noMoreEnds) {
2304
+ PEM_END.lastIndex = to;
2305
+ closed = PEM_END.test(text);
2306
+ if (closed)
2307
+ to = PEM_END.lastIndex;
2308
+ else
2309
+ noMoreEnds = true;
2310
+ }
2311
+ if (!closed) {
2312
+ PEM_BODY.lastIndex = to;
2313
+ PEM_BODY.test(text);
2314
+ to = PEM_BODY.lastIndex;
2315
+ }
2316
+ out += text.slice(from, begin.index) + REDACTED2;
2317
+ from = to;
2318
+ PEM_BEGIN.lastIndex = to;
2319
+ }
2320
+ return out + text.slice(from);
2321
+ }
2322
+ function redactSecrets(text) {
2323
+ let out = redactPrivateKeys(text);
2324
+ for (const shape of SECRET_SHAPES)
2325
+ out = out.replace(shape, REDACTED2);
2326
+ return out.replace(URL_CREDENTIALS, `$1${REDACTED2}@`).replace(SECRET_ASSIGNMENT, (match, quote, name, separator, raw) => isSecretValue(name, separator, raw) ? `${quote}${name}${quote}${separator}${REDACTED2}` : match);
2327
+ }
2328
+ function wasRedacted(text) {
2329
+ return text.includes(REDACTED2);
2330
+ }
2331
+ function defuseMarkup(text) {
2332
+ return text.replace(/(?<![A-Za-z0-9/])@(?!\u200b)/g, `@${ZERO_WIDTH_SPACE}`).replace(/&(?=#|commat)/gi, `&${ZERO_WIDTH_SPACE}`).replaceAll("![", `!${ZERO_WIDTH_SPACE}[`).replace(/<(?=[a-zA-Z/!?])/g, `<${ZERO_WIDTH_SPACE}`).replaceAll("-->", `--${ZERO_WIDTH_SPACE}>`);
2333
+ }
2334
+ function publishedText(text) {
2335
+ return defuseMarkup(redactSecrets(text));
2336
+ }
2337
+ var REDACTED2 = "[REDACTED]", ZERO_WIDTH_SPACE = "\u200B", SECRET_SHAPES, URL_CREDENTIALS, SECRET_ASSIGNMENT, PEM_BEGIN, PEM_END, PEM_BODY;
2338
+ var init_published_text = __esm(() => {
2339
+ SECRET_SHAPES = [
2340
+ /(?<![A-Za-z0-9])gh[pousr]_[A-Za-z0-9_]{20,}/g,
2341
+ /(?<![A-Za-z0-9])github_pat_[A-Za-z0-9_]{20,}/g,
2342
+ /(?<![A-Za-z0-9])glpat-[A-Za-z0-9_-]{20,}/g,
2343
+ /(?<![A-Za-z0-9])(?:AKIA|ASIA)[A-Z0-9]{16}\b/g,
2344
+ /(?<![A-Za-z0-9])sk-(?:ant|proj|svcacct|admin)-[A-Za-z0-9_-]{16,}/g,
2345
+ /(?<![A-Za-z0-9])sk-[A-Za-z0-9]{32,}/g,
2346
+ /(?<![A-Za-z0-9])[sr]k_(?:live|test)_[A-Za-z0-9]{16,}/g,
2347
+ /(?<![A-Za-z0-9])xox[abeoprs]-[A-Za-z0-9-]{10,}/g,
2348
+ /(?<![A-Za-z0-9])AIza[A-Za-z0-9_-]{35}/g,
2349
+ /(?<![A-Za-z0-9])npm_[A-Za-z0-9]{36}\b/g,
2350
+ /(?<![A-Za-z0-9])eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}/g,
2351
+ /(?<![A-Za-z0-9])Bearer\s+(?=[A-Za-z0-9._~+/=-]{0,512}\d)[A-Za-z0-9._~+/=-]{20,}/gi
2352
+ ];
2353
+ URL_CREDENTIALS = /(?<![A-Za-z0-9+.-])([a-z][a-z0-9+.-]{0,30}:\/\/)(?:[^\s/?#${<]{0,256}:[^\s/?#${<]{1,256}|[^\s/?#${<:@]{20,256})@/gi;
2354
+ SECRET_ASSIGNMENT = /(?<![A-Za-z0-9_-])(["']?)((?:[A-Za-z0-9_-]{0,40}[_-])?(?:password|passwd|secret|token|api[_-]?key|private[_-]?key|credentials?)(?:[_-][A-Za-z0-9_-]{0,40})?)\1(\s*[=:](?![=:])\s*)("[^"\n]{1,256}"|'[^'\n]{1,256}'|[^\s"',;]{1,256})/gi;
2355
+ PEM_BEGIN = /-----BEGIN [A-Z0-9 ]{0,40}PRIVATE KEY(?: BLOCK)?-----/g;
2356
+ PEM_END = /-----END [A-Z0-9 ]{0,40}PRIVATE KEY(?: BLOCK)?-----/g;
2357
+ PEM_BODY = /(?:\s*[A-Za-z0-9+/=]{16,})*/y;
2358
+ });
2359
+
2265
2360
  // src/triage/triage.ts
2266
2361
  function triageBadge(fields) {
2267
2362
  const badge = TRIAGE_BADGE[fields.tag];
@@ -2278,7 +2373,7 @@ function renderTriageReplyBody(fields, reasoning) {
2278
2373
  const head = `${triageMarker(fields)}
2279
2374
 
2280
2375
  ${triageBadge(fields)}`;
2281
- const prose = reasoning.trim();
2376
+ const prose = publishedText(reasoning.trim());
2282
2377
  return prose.length === 0 ? `${head}
2283
2378
  ` : `${head}
2284
2379
 
@@ -2356,6 +2451,7 @@ function parseTriageMarker(body) {
2356
2451
  var TRIAGE_MARKER_PREFIX, TRIAGE_TAGS, TRIAGE_ACTORS, TRIAGE_VERDICTS, FULL_SHA, ADJUDICATED_TAGS, TRIAGE_BADGE;
2357
2452
  var init_triage = __esm(() => {
2358
2453
  init_brand();
2454
+ init_published_text();
2359
2455
  TRIAGE_MARKER_PREFIX = `${MARKER_OPEN}triage `;
2360
2456
  TRIAGE_TAGS = new Set([
2361
2457
  "applied",
@@ -2439,7 +2535,7 @@ var workflow_default = "./workflow-w1g9szna.yml";
2439
2535
  var init_workflow = () => {};
2440
2536
 
2441
2537
  // skills/crysk-ci-setup/references/ci-admission.md
2442
- var ci_admission_default = "./ci-admission-a6d0wk1c.md";
2538
+ var ci_admission_default = "./ci-admission-t0f5qwth.md";
2443
2539
  var init_ci_admission = () => {};
2444
2540
 
2445
2541
  // skills/crysk-ci-setup/references/opencode-ci.md
@@ -2447,7 +2543,7 @@ var opencode_ci_default = "./opencode-ci-7b0be64p.md";
2447
2543
  var init_opencode_ci = () => {};
2448
2544
 
2449
2545
  // skills/crysk-ci-setup/SKILL.md
2450
- var SKILL_default2 = "./SKILL-2h445snn.md";
2546
+ var SKILL_default2 = "./SKILL-dsnffnfp.md";
2451
2547
  var init_SKILL2 = () => {};
2452
2548
 
2453
2549
  // skills/crysk-loop/adjudicator.md
@@ -2455,11 +2551,11 @@ var adjudicator_default = "./adjudicator-dtg2axnh.md";
2455
2551
  var init_adjudicator = () => {};
2456
2552
 
2457
2553
  // skills/crysk-loop/SKILL.md
2458
- var SKILL_default3 = "./SKILL-yz6wk92g.md";
2554
+ var SKILL_default3 = "./SKILL-vws0aqb8.md";
2459
2555
  var init_SKILL3 = () => {};
2460
2556
 
2461
2557
  // skills/crysk-pr/SKILL.md
2462
- var SKILL_default4 = "./SKILL-7q35wcaz.md";
2558
+ var SKILL_default4 = "./SKILL-qaqsbygw.md";
2463
2559
  var init_SKILL4 = () => {};
2464
2560
 
2465
2561
  // src/asset-manifest.ts
@@ -2541,7 +2637,7 @@ function resolveVersion() {
2541
2637
  }
2542
2638
  }
2543
2639
  } catch {}
2544
- return "0.3.3";
2640
+ return "0.4.0";
2545
2641
  }
2546
2642
  function resolveEngineAssets() {
2547
2643
  const mode = detectAssetMode();
@@ -6677,18 +6773,36 @@ function latestStatusInContext(statuses, context) {
6677
6773
  }
6678
6774
  return latest;
6679
6775
  }
6776
+ function manualReviewHoldDescription(label, sha) {
6777
+ return clipStatusDescription(`${STATUS_CONTEXT}: waiting for a manual review (${label}); carried from ${sha.slice(0, 7)} \u2014 /pr-hero review or /pr-hero override`);
6778
+ }
6779
+ function isManualReviewHold(status) {
6780
+ return status.state === "pending" && MANUAL_REVIEW_HOLD.test(status.description ?? "");
6781
+ }
6782
+ function heldVerdictSha(status) {
6783
+ if (!isManualReviewHold(status))
6784
+ return null;
6785
+ const description = status.description ?? "";
6786
+ const match = HELD_VERDICT.exec(description);
6787
+ if (match === null)
6788
+ return null;
6789
+ const [, label, sha] = match;
6790
+ return manualReviewHoldDescription(label, sha) === description ? sha : null;
6791
+ }
6680
6792
  function isInFlightCommitStatus(statuses, nowMs, ttlMs = IN_FLIGHT_TTL_MS, contexts = [COMMIT_STATUS_CONTEXT]) {
6681
6793
  return contexts.some((context) => {
6682
6794
  const latest = latestStatusInContext(statuses, context);
6683
6795
  if (latest === null || latest.state !== "pending")
6684
6796
  return false;
6797
+ if (isManualReviewHold(latest))
6798
+ return false;
6685
6799
  const createdMs = Date.parse(latest.created_at);
6686
6800
  if (Number.isNaN(createdMs))
6687
6801
  return false;
6688
6802
  return nowMs - createdMs < ttlMs;
6689
6803
  });
6690
6804
  }
6691
- var PR_COMMENT_MARKER_PREFIX, PR_REREVIEW_CLOSED_MARKER_PREFIX, PR_COMMENT_COVERAGE_PARTIAL_TOKEN = "coverage=partial", PR_FINDING_MARKER_PREFIX, COMMIT_STATUS_CONTEXT, LOCAL_COMMIT_STATUS_CONTEXT, RUN_STATUS_CONTEXTS, IN_FLIGHT_TTL_MS, COMMIT_STATUS_TIMEOUT_MS = 15000, CANCELLATION_COMMIT_STATUS_TIMEOUT_MS = 5000, COMMIT_STATUS_DESCRIPTION_MAX = 140;
6805
+ var PR_COMMENT_MARKER_PREFIX, PR_REREVIEW_CLOSED_MARKER_PREFIX, PR_COMMENT_COVERAGE_PARTIAL_TOKEN = "coverage=partial", PR_FINDING_MARKER_PREFIX, COMMIT_STATUS_CONTEXT, LOCAL_COMMIT_STATUS_CONTEXT, RUN_STATUS_CONTEXTS, IN_FLIGHT_TTL_MS, COMMIT_STATUS_TIMEOUT_MS = 15000, CANCELLATION_COMMIT_STATUS_TIMEOUT_MS = 5000, COMMIT_STATUS_DESCRIPTION_MAX = 140, MANUAL_REVIEW_HOLD, HELD_VERDICT;
6692
6806
  var init_preflight3 = __esm(() => {
6693
6807
  init_publish();
6694
6808
  init_preflight2();
@@ -6705,6 +6819,8 @@ var init_preflight3 = __esm(() => {
6705
6819
  LOCAL_COMMIT_STATUS_CONTEXT
6706
6820
  ];
6707
6821
  IN_FLIGHT_TTL_MS = 90 * 60 * 1000;
6822
+ MANUAL_REVIEW_HOLD = /^crysk: waiting for a manual review \(/;
6823
+ HELD_VERDICT = /^crysk: waiting for a manual review \((.+)\); carried from ([0-9a-f]{7}) \u2014 /;
6708
6824
  });
6709
6825
 
6710
6826
  // src/diversity/errors.ts
@@ -7755,6 +7871,7 @@ init_preflight3();
7755
7871
  init_findings();
7756
7872
  init_materiality_gate();
7757
7873
  init_brand();
7874
+ init_published_text();
7758
7875
  var PR_STATE_MARKER_PREFIX = `${MARKER_OPEN}state `;
7759
7876
  var GITHUB_ISSUE_COMMENT_MAX = 65536;
7760
7877
  var STATE_HEADER = new RegExp(`^<!-- ${MARKER_BRAND_PATTERN}-state v=1 head=([0-9a-f]{40}) -->`);
@@ -7810,7 +7927,7 @@ function renderStateBlock(headSha, findings, reviews, hw) {
7810
7927
  channel: f.channel,
7811
7928
  locs: f.locs,
7812
7929
  c: f.c,
7813
- claim: f.claim
7930
+ claim: redactSecrets(f.claim)
7814
7931
  }))
7815
7932
  };
7816
7933
  if (reviews !== undefined && Number.isInteger(reviews) && reviews >= 1) {
@@ -7891,7 +8008,7 @@ function lastEvictableIndex(entries, status, protectedIds) {
7891
8008
  return -1;
7892
8009
  }
7893
8010
  function encodeStateJson(value) {
7894
- return JSON.stringify(value).replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029").replaceAll("-->", "--\\u003e");
8011
+ return JSON.stringify(value).replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029").replaceAll("<", "\\u003c").replaceAll(">", "\\u003e");
7895
8012
  }
7896
8013
  function asStateFindings(parsed) {
7897
8014
  if (typeof parsed !== "object" || parsed === null)
@@ -8005,7 +8122,7 @@ function assembleLive(input) {
8005
8122
  tier: gatePrior.tier,
8006
8123
  channel: gatePrior.channel,
8007
8124
  locs: row.locs,
8008
- c: liveFingerprint(gatePrior.id, gatePrior.claim),
8125
+ c: gatePrior.c ?? liveFingerprint(gatePrior.id, gatePrior.claim),
8009
8126
  claim: gatePrior.claim,
8010
8127
  status: persisted
8011
8128
  });
@@ -8098,7 +8215,7 @@ function gatePairing(survivors, rows) {
8098
8215
  }
8099
8216
  function isReleasable(row) {
8100
8217
  const claim = row?.claim;
8101
- if (row === undefined || claim === undefined || claim.trim().length === 0) {
8218
+ if (row === undefined || claim === undefined || claim.trim().length === 0 || wasRedacted(claim)) {
8102
8219
  return false;
8103
8220
  }
8104
8221
  const paths = [...identityFromLocs(row.locs).keys()];
@@ -8156,6 +8273,9 @@ function mergeStateFindings(input) {
8156
8273
  }
8157
8274
  }
8158
8275
  const touched = new Set;
8276
+ const freshIds = input.fresh.map(() => {
8277
+ return;
8278
+ });
8159
8279
  const pairs = pairBlockingSurvivors(input.fresh, rows.map((row) => ({ tier: row.tier, locs: row.locs })));
8160
8280
  const rowOfSurvivor = new Map(pairs.map((p) => [p.survivor, p.row]));
8161
8281
  const takenRows = new Set(pairs.map((p) => p.row));
@@ -8190,6 +8310,7 @@ function mergeStateFindings(input) {
8190
8310
  status: prior.status
8191
8311
  };
8192
8312
  touched.add(prior.id);
8313
+ freshIds[s] = prior.id;
8193
8314
  continue;
8194
8315
  }
8195
8316
  hw += 1;
@@ -8206,6 +8327,7 @@ function mergeStateFindings(input) {
8206
8327
  status: "unconfirmed"
8207
8328
  });
8208
8329
  touched.add(id);
8330
+ freshIds[s] = id;
8209
8331
  }
8210
8332
  const capped = capLiveFindings(rows, "", input.headSha, input.stateBudget, {
8211
8333
  reviews: input.reviews,
@@ -8215,7 +8337,8 @@ function mergeStateFindings(input) {
8215
8337
  return {
8216
8338
  rows: capped.kept,
8217
8339
  hw,
8218
- dropped: capped.droppedUnconfirmed + capped.droppedCarried
8340
+ dropped: capped.droppedUnconfirmed + capped.droppedCarried,
8341
+ freshIds
8219
8342
  };
8220
8343
  }
8221
8344
  function droppedStateNote(count) {
@@ -19847,6 +19970,7 @@ init_preflight2();
19847
19970
  init_preflight3();
19848
19971
  init_findings();
19849
19972
  init_brand();
19973
+ init_published_text();
19850
19974
  var USD_PER_AGENT_BASE = 1.2;
19851
19975
  var USD_PER_CHANGED_LINE = 0.00021;
19852
19976
  var USD_PER_FILE = 0.008;
@@ -20126,7 +20250,7 @@ function liveFindingLines(rereview) {
20126
20250
  for (const row of listed) {
20127
20251
  const loc = row.locs[0] ?? row.id;
20128
20252
  const badge = row.sev === SEVERITY_UNRECOVERABLE ? "\u26A0\uFE0F severity unavailable" : severityEmoji(row.sev);
20129
- out.push(`- \`${row.status}\` ${badge} \`${loc}\` \u2014 ${liveClaimText(row.claim)} (${row.id})`);
20253
+ out.push(`- \`${row.status}\` ${badge} ${code(loc)} \u2014 ${liveClaimText(row.claim)} (${row.id})`);
20130
20254
  }
20131
20255
  out.push("");
20132
20256
  }
@@ -20263,7 +20387,7 @@ function refuterLabel(verdict) {
20263
20387
  }
20264
20388
  function findingLocationLine(finding, headSha, webUrl, linkLocation) {
20265
20389
  const loc = code(`${finding.path}:${finding.line}`);
20266
- const linked = linkLocation && webUrl !== undefined ? `[${loc}](${blobUrl(webUrl, headSha, finding.path, `L${finding.line}`)})` : loc;
20390
+ const linked = linkLocation && webUrl !== undefined && isLinkablePath(finding.path) ? `[${loc}](${blobUrl(webUrl, headSha, finding.path, `L${finding.line}`)})` : loc;
20267
20391
  return typeof finding.symbol === "string" && finding.symbol.length > 0 ? `${linked} \u2014 ${oneLine2(finding.symbol)}` : linked;
20268
20392
  }
20269
20393
  function tierExplanationLines(finding) {
@@ -20290,7 +20414,7 @@ function tierExplanationLines(finding) {
20290
20414
  }
20291
20415
  var MATERIALITY_REASON_MAX = 280;
20292
20416
  function materialityReason(reason) {
20293
- const flat = oneLine2(reason).replaceAll("<!--", "<!\u2010\u2010").replaceAll("-->", "\u2010\u2010>").replaceAll("@", "@\u200B");
20417
+ const flat = oneLine2(reason);
20294
20418
  return flat.length <= MATERIALITY_REASON_MAX ? flat : `${flat.slice(0, MATERIALITY_REASON_MAX - 1).trimEnd()}\u2026`;
20295
20419
  }
20296
20420
  function promptToFixBlock(finding) {
@@ -20299,7 +20423,7 @@ function promptToFixBlock(finding) {
20299
20423
  "<details><summary>Prompt to fix with AI</summary>",
20300
20424
  "",
20301
20425
  "```",
20302
- `Fix this issue in ${finding.path} at line ${finding.line}:`,
20426
+ `Fix this issue in ${oneLine2(finding.path)} at line ${finding.line}:`,
20303
20427
  "",
20304
20428
  oneLine2(finding.claim),
20305
20429
  "```",
@@ -20408,7 +20532,7 @@ function renderRef(ref, headSha, webUrl) {
20408
20532
  if (webUrl === undefined)
20409
20533
  return code(ref);
20410
20534
  const parsed = parseRefAnchor(ref);
20411
- if (parsed === null)
20535
+ if (parsed === null || !isLinkablePath(parsed.path))
20412
20536
  return code(ref);
20413
20537
  const fragment = parsed.end === undefined ? `L${parsed.start}` : `L${parsed.start}-L${parsed.end}`;
20414
20538
  const url = blobUrl(webUrl, headSha, parsed.path, fragment);
@@ -20433,8 +20557,14 @@ function parseRefAnchor(ref) {
20433
20557
  prose: ref.trim().slice(anchor.length).trim()
20434
20558
  };
20435
20559
  }
20560
+ function isLinkablePath(path) {
20561
+ return redactSecrets(path) === path;
20562
+ }
20563
+ function encodeBlobPath(path) {
20564
+ return path.toWellFormed().split("/").map(encodeURIComponent).join("/").replaceAll("(", "%28").replaceAll(")", "%29");
20565
+ }
20436
20566
  function blobUrl(webUrl, sha, path, fragment) {
20437
- return `${webUrl}/blob/${sha}/${path}#${fragment}`;
20567
+ return `${webUrl}/blob/${sha}/${encodeBlobPath(path)}#${fragment}`;
20438
20568
  }
20439
20569
  function runLines(doc, meta) {
20440
20570
  const { files, insertions, deletions } = meta.diffStat;
@@ -20574,7 +20704,7 @@ function code(text) {
20574
20704
  return `\`${oneLine2(text).replaceAll("`", "'")}\``;
20575
20705
  }
20576
20706
  function oneLine2(text) {
20577
- return text.replace(/\s+/g, " ").trim();
20707
+ return publishedText(text.replace(/\s+/g, " ").trim());
20578
20708
  }
20579
20709
  function usd(amount) {
20580
20710
  return `$${amount.toFixed(2)}`;
@@ -20624,7 +20754,7 @@ function envelopeModel(options, agentFiles) {
20624
20754
  // src/index.ts
20625
20755
  init_spec();
20626
20756
  var ENGINE_NAME = "pr-hero";
20627
- var ENGINE_VERSION = "0.3.3";
20757
+ var ENGINE_VERSION = "0.4.0";
20628
20758
  export {
20629
20759
  ACTIVE_CHILD_PROCS,
20630
20760
  ACTIVE_SERVER_CLOSERS,
@@ -20735,6 +20865,7 @@ export {
20735
20865
  isCausallyExempt,
20736
20866
  isCiEnvironment,
20737
20867
  isFullCommitId,
20868
+ isLinkablePath,
20738
20869
  isMeasuredJudgeRoute,
20739
20870
  isModelAlias,
20740
20871
  isNotCausedByPr,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crysk",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -67,7 +67,7 @@
67
67
  "review": "bun run src/cli.ts",
68
68
  "fixture-eval": "bun run scripts/fixture-eval.ts",
69
69
  "refuter-probe": "bun run scripts/refuter-probe.ts",
70
- "check": "biome check src test"
70
+ "check": "biome check src test benchmarks"
71
71
  },
72
72
  "dependencies": {
73
73
  "@opencode-ai/sdk": "1.18.25"
@@ -23,7 +23,7 @@ Load when the user asks to:
23
23
  - **No install needed:** run every Crysk command as `npx -y crysk <command>` (Node is enough; the package brings its own Bun). A global `crysk` on PATH is the same command. CI itself needs no local CLI at all: the workflow runs the action. `npx -y crysk skills install` installs the Crysk, triage, and CI-setup skills into every detected coding agent, with no TTY and no MCP or launchd registration (neither is needed for the CI loop, and npx's temporary cache refuses them).
24
24
  - **Deterministic scaffolding:** Run `npx -y crysk setup --ci` (or `npx -y crysk ci init`) with the interview's flags. It writes the one workflow file, `.github/workflows/crysk.yml` (a repo that already has `pr-hero.yml` keeps it: `--force` rewrites it in place, and setup refuses to add a second file beside it). Do not fabricate it from memory. Fallback: copy `assets/workflow.yml`. Never scaffold a `pr-hero-force.yml`; it is retired.
25
25
  - **`fetch-depth: 0` is mandatory** on `actions/checkout@v4`.
26
- - **Gate mode:** the `crysk` commit status is the required check (the legacy `pr-hero` status is no longer posted). The scaffold writes `mode: gate` explicitly: blocking findings, a size or spend-ceiling skip, and a crash set it red. Every review rule that skips a push (low-risk delta, once per PR, `/crysk stop`, the attempt budget used up, `manual_only`) carries the last verdict; answered blocking findings turn a carried red green, marked unverified. `mode: advisory` keeps it green for a finished review. The job's exit code stays `0` on findings either way, so do not gate on the job.
26
+ - **Gate mode:** the `crysk` commit status is the required check (the legacy `pr-hero` status is no longer posted). The scaffold writes `mode: gate` explicitly: blocking findings, a size or spend-ceiling skip, and a crash set it red. Every review rule that skips a push (low-risk delta, once per PR, `/crysk stop`, the attempt budget used up, `manual_only`) carries the last verdict; answered blocking findings turn a carried red green, marked unverified. Under the attempt budget used up or `manual_only`, that green is held `pending` instead, so a push past the budget or under `manual_only` never turns green without a `/crysk review` or a `/crysk override`. `mode: advisory` keeps it green for a finished review. The job's exit code stays `0` on findings either way, so do not gate on the job.
27
27
  - **Required permissions:** `contents: read`, `pull-requests: write`, `issues: write`, `statuses: write`, **`checks: write`**, **`actions: read`** (the admission gate lists past runs; a private repo 403s without it). Template in `assets/workflow.yml` includes all six.
28
28
  - **Retrigger is a PR comment: `gh pr comment <n> --body "/crysk review"`.** GitHub Actions runs the review on the runner with `--force`. The comment must be exactly `/crysk review` (or `/crysk review --full`; `/pr-hero review` on a workflow scaffolded before the rename, see the `/crysk` vs `/pr-hero` bullet), and its author needs write access; the action refuses anyone else. Do not run `crysk review --force` locally when the review should happen in CI. `gh run rerun` on a skipped run re-evaluates the gates and does not force. In this repo a comment run checks out the PR head commit before `uses: ./`, so it runs the PR's own engine, not the default branch's.
29
29
  - **`/crysk recheck` re-reviews the head and asks the CI adjudicator to rule on pending dismissals.** It is `/crysk review` plus `--adjudicate`, with the same permission check and reaction; refused on fork pull requests. See `docs/github-actions.md` ("Rechecking a dismissal").
@@ -67,7 +67,7 @@ Materiality gate: `materiality_gate: true` (opt-in; setup never writes it) sends
67
67
  |---|---|
68
68
  | Review runs | Normal pipeline |
69
69
  | **Skipped** | Push did not justify spend (same head, low score, docs-only delta, etc.) — **not** “clean” |
70
- | **Automatic reviews done** | Budget exhausted or `manual_only` — the gate keeps the last verdict, answered findings turn a red green (marked unverified), and `/crysk review` runs another round |
70
+ | **Automatic reviews done** | Budget exhausted or `manual_only` — a red verdict carries; a green one, or a red whose blocking findings are all answered, is held `pending` until `/crysk review` runs another round or `/crysk override` merges it unverified |
71
71
 
72
72
  Skipped and automatic-reviews-done posts include admission metadata in the step summary. The automatic-reviews-done
73
73
  comment explains the end of the budget by the repository's rules (policy, attempts used, last reviewed head) and how to
@@ -75,15 +75,21 @@ attempt budget used up, `/crysk stop`, `once_per_pr`, a low-risk or below-thresh
75
75
  `fixes unverified`, on the next push when every blocking finding's newest reply, from your
76
76
  write-access account, is `applied` at the head it was posted on or a `dismissed` the adjudicator
77
77
  upheld. Nobody verifies those fixes, so `applied` must mean you fixed it and ran the tests. The
78
- gate reads the replies when the push arrives: **reply first, then push.**
78
+ gate reads the replies when the push arrives: **reply first, then push.** The exception: under the
79
+ attempt budget used up or `manual_only`, no later push is reviewed on its own, so where the gate
80
+ would turn green it holds the head `pending` instead ("crysk: waiting for a manual review"), and
81
+ a maintainer decides between `/crysk review` and `/crysk override`.
79
82
 
80
83
  **`/crysk override` is a maintainer's, and only for what answers cannot unlock.** Never post it,
81
- and never ask for it because the review budget ran out. Ask a maintainer for it only when:
84
+ and never ask for it because the review budget ran out, except to answer a manual-review hold. Ask
85
+ a maintainer for it only when:
82
86
  - the CI review itself is broken (every hunter failing, credit or credentials, `PRH-HUNTERS-FAILED`):
83
87
  stop the loop and report what is failing, never route around it;
84
88
  - a `deferred` or `misclassified` finding should merge unfixed: it names a real defect, so
85
89
  accepting it is the maintainer's call;
86
- - a partial review keeps failing on the same hunters and their route cannot be fixed.
90
+ - a partial review keeps failing on the same hunters and their route cannot be fixed;
91
+ - the gate holds the head for a manual review (budget used up or `manual_only`) and the
92
+ unreviewed delta does not justify another paid review: the maintainer picks review or override.
87
93
 
88
94
  `deferred` and `misclassified` never leave the gate count, whatever any adjudicator says: they are
89
95
  for findings that are real (or real at another severity), so the gate stays red until a fix or a
@@ -113,7 +119,7 @@ Later review passes hunt only the push delta. Once the real defects from pass 1
113
119
  1. **Never patch code to appease a contrived or over-severitied finding.**
114
120
  - If the claimed bug requires an impossible precondition, contradicts an intentional invariant, or is already guarded: tag it `dismissed` with cited code and use `/crysk recheck` so the CI adjudicator clears it **without** a code change or a new push.
115
121
  - If the observation is technically true but trivial, stylistic, pre-existing, or inflated to blocking: tag it `misclassified` or `deferred`. Never rewrite working code just to avoid asking for `/crysk override`.
116
- 2. **Do not auto-force past `ci_max_attempts` on routine fix-ups.** The repository's `ci_max_attempts` (default `2`) exists specifically to stop diminishing-returns re-reviews, and the PR gets an "automatic reviews are done" comment when it runs out. The gate then carries the last verdict: answer every blocking finding (`applied` with the fix in the tree, or `dismissed` + `/crysk recheck`) **before** you push, and that push turns a carried red green, marked `fixes unverified`. If the commits since `report.head` only applied straightforward fixes for already-triaged findings, do not post `/crysk review`: stop the loop and tell the user the PR finished its review passes and is ready to merge, with the fixes unverified by a review. No override is needed.
122
+ 2. **Do not auto-force past `ci_max_attempts` on routine fix-ups.** The repository's `ci_max_attempts` (default `2`) exists specifically to stop diminishing-returns re-reviews, and the PR gets an "automatic reviews are done" comment when it runs out. A red then still carries: answer every blocking finding (`applied` with the fix in the tree, or `dismissed` + `/crysk recheck`) **before** you push. Where the gate would turn green, it holds the head `pending` for a manual review instead, and `crysk status` answers `override-or-fix`. If the commits since `report.head` only applied straightforward fixes for already-triaged findings, do not post `/crysk review`: stop the loop and tell the user the PR finished its review passes and waits for a maintainer's `/crysk review` (to verify the fixes) or `/crysk override` (to merge them unverified).
117
123
  3. **Stop and recommend merge when only diminishing-returns items remain.** On `override-or-fix` (or pass 2+ when every real bug is fixed and the only remaining red-gate items are `deferred`, `misclassified`, or a contrived finding whose dismissal the adjudicator did not uphold), **do not cave in and edit the code**. Exit the loop, list the remaining finding(s) with a one-line explanation of why they are contrived/out-of-scope, and tell the user the PR is ready to `/crysk override` and merge.
118
124
  4. **Stop automatic reviews BEFORE the push that should not be reviewed.** When you decide no further review pass is needed but you still have fixes to push, post `gh pr comment <n> --body "/crysk stop"` **first**, then `git push`. CI admission reads the stop on that push and skips the review, carrying the last verdict (a carried red turns green, marked `fixes unverified`, when every blocking finding was answered before that push; otherwise it stays red). The stop stays in force for every later push until someone comments `/crysk review` or `/crysk recheck`. It counts only from a user with write access, starts no workflow run, and costs $0. Never push first and try to stop the review afterwards: nothing cancels a review that already started.
119
125
 
@@ -121,7 +127,7 @@ Later review passes hunt only the push delta. Once the real defects from pass 1
121
127
 
122
128
  The opposite happens when a repository's workflow policy (`once_per_pr`, `thresholded`, `risk_aware` below the score floor, `ci_max_attempts` exhausted, or the size gate) suppresses an automatic review on a push that **genuinely changed load-bearing code**:
123
129
  - Under `once_per_pr`, `thresholded`, or `risk_aware`, a skipped push can inherit a carried `success` status from `report.head`, so `next_action` reads `"done"` even though `report.head !== head` (the commits `report.head..head` were never reviewed).
124
- - Under `ci_max_attempts` or `manual_only`, the push carries the last verdict the same way, or a `fixes unverified` green once every blocking finding is answered. Under the size or spend-ceiling gate, the automatic run is blocked and the head is red. Either way `report.head !== head`.
130
+ - Under `ci_max_attempts` or `manual_only`, a red carries the same way, and a green is held `pending` ("crysk: waiting for a manual review"), so `next_action` reads `"override-or-fix"`. Under the size or spend-ceiling gate, the automatic run is blocked and the head is red. Either way `report.head !== head`.
125
131
 
126
132
  Whenever `report.head !== head`, inspect `git diff <report.head>..<head>`:
127
133
  - If that unreviewed delta introduced **new business logic, state-machine or concurrency changes, auth/security/isolation edits, or a non-trivial refactor** (for example, fixing a finding required redesigning a function rather than adding a guard), an extra review **is** justified:
@@ -187,8 +193,13 @@ read that file instead.
187
193
  (`comment_id` is null: a summary-only row, or one never posted inline). Commit and `git push` the fix, then immediately run step 0 with `--wait` so the next review verifies it. A thread-less finding cannot be answered with `triage reply`, so fix it or ask a maintainer for `/crysk override`.
188
194
  - `recheck`: blocking findings are answered `dismissed` (with no pending code fixes to push) and the CI adjudicator has not ruled on
189
195
  them on this head (or ruled `inconclusive`). Comment `gh pr comment <n> --body "/crysk recheck"`, then immediately run step 0 with `--wait` and follow "Closing a dismissal" below.
190
- - `override-or-fix`: the gate is red and nothing is left for `triage` or `recheck`. Read the
191
- `reason` and act on the case it names; never override it yourself:
196
+ - `override-or-fix`: the gate is red (or held for a manual review) and nothing is left for
197
+ `triage` or `recheck`. Read the `reason` and act on the case it names; never override it yourself:
198
+ - the gate holds the head for a manual review (the gate description starts "crysk: waiting for
199
+ a manual review"): inspect `git diff <report.head>..<head>` as in "Requesting or suggesting
200
+ another review" above. A load-bearing delta justifies `/crysk review` (within the forced-run
201
+ bound), then step 0 with `--wait`; otherwise exit the loop and tell the maintainer the PR
202
+ waits for `/crysk review` or `/crysk override`;
192
203
  - the head was size- or budget-skipped (the gate description starts "crysk skipped the
193
204
  review", or "pr-hero skipped the review" on a status an older action wrote): comment `/crysk review`, then run step 0 with `--wait`;
194
205
  - the review is "partial again" with the same hunters failing: fix the failing hunter's route
@@ -200,7 +211,7 @@ read that file instead.
200
211
  description): read that description and act on what it says; when it names nothing you can
201
212
  fix, ask a maintainer.
202
213
  - `done`: nothing is owed on this head. The gate passed (or an override unlocked it) and every
203
- finding posted on this head has a reply. A `fixes unverified` green (the `reason` says no review
214
+ finding posted on this head has a reply. When `findings` lists rows with `comment_id: null` (the `reason` says they "live only in the summary comment"), they are outside-diff findings with no thread: read each one in the summary, fix what is real before you report the PR ready, and name the rest in your report. A `fixes unverified` green (the `reason` says no review
204
215
  verified it) is done too: report the PR ready to merge and say the fixes were not verified by a review. Before exiting, check whether `report.head && report.head !== head` (a green status carried over an unreviewed push under `once_per_pr`, `thresholded`, or `risk_aware`): if `git diff <report.head>..<head>` contains non-trivial logic or risky changes ("Requesting or suggesting another review" above), recommend `/crysk review` naming those changes; otherwise exit the loop and report that the PR is ready to merge.
205
216
 
206
217
  **Bound the forced runs.** `/crysk review` and `/crysk recheck` each run a full paid review
@@ -61,6 +61,6 @@ When `crysk` is active on the repository, **never stop right after `gh pr create
61
61
  `--wait` holds automatically during the 3-minute startup grace window while `gate.state` is `"none"` (waiting for GitHub Actions to pick up the new PR), continues polling every 15s while `gate.state` is `"pending"`, and returns as soon as the review settles.
62
62
 
63
63
  2. **Route on `next_action`:**
64
- - **`next_action === "done"`:** Check whether `report.head` is non-null and `report.head !== head` (a green status carried forward over an unreviewed push under `once_per_pr`, `thresholded`, or `risk_aware`). If so and `git diff <report.head>..<head>` contains non-trivial logic or risky changes, explicitly recommend running `/crysk review` to the user naming those changes. Otherwise, the review passed the gate with zero untriaged findings: report the PR URL and clean review summary to the user.
64
+ - **`next_action === "done"`:** First, if `findings` lists rows with `comment_id: null` (the `reason` says they "live only in the summary comment"), read each one in the PR's summary comment: an outside-diff finding has no thread, so `done` does not mean it was answered. Fix the real ones or hand off to `crysk-loop`; never report the PR ready without naming them. Then check whether `report.head` is non-null and `report.head !== head` (a green status carried forward over an unreviewed push under `once_per_pr`, `thresholded`, or `risk_aware`). If so and `git diff <report.head>..<head>` contains non-trivial logic or risky changes, explicitly recommend running `/crysk review` to the user naming those changes. Otherwise, the review passed the gate with zero untriaged findings: report the PR URL and clean review summary to the user.
65
65
  - **`next_action !== "done"` (`"triage"`, `"fix"`, `"recheck"`, `"review"`, `"override-or-fix"`):**
66
66
  Immediately load the `crysk-loop` skill (`skills/crysk-loop/SKILL.md`) and run its autonomous loop (`while (next_action !== "done")`) to judge findings, reply, push verified fixes, and wait for re-review until the PR is ready to merge.
package/src/assets.ts CHANGED
@@ -74,7 +74,7 @@ function resolveVersion(): string {
74
74
  // Ignore read errors
75
75
  }
76
76
 
77
- return "0.3.3";
77
+ return "0.4.0";
78
78
  }
79
79
 
80
80
  export function resolveEngineAssets(): EngineAssets {
@@ -142,7 +142,7 @@ export function isNpxCacheInvocation(invocation: SelfInvocation): boolean {
142
142
  // run this engine has ever written — before and after a change that alters
143
143
  // what every agent reads — reports the same engine. That is not a cosmetic gap. The Cal.com Martian
144
144
  // baseline is ratified as valid ACROSS engine versions on the condition that
145
- // the frontier is annotated (docs/martian-bench.md), and an artifact whose
145
+ // the frontier is annotated (benchmarks/martian/README.md), and an artifact whose
146
146
  // engine field cannot change cannot annotate anything.
147
147
  //
148
148
  // The revision is the git commit, which moves on its own and needs nobody to
package/src/ci/gates.ts CHANGED
@@ -65,7 +65,7 @@ import type { CiMode } from "#pr/preflight";
65
65
  import type { Finding, FindingsDocument } from "#review/findings";
66
66
  import type { PrCommentDelta } from "#review/report";
67
67
  import type { SizeGateVerdict } from "#review/size-gate";
68
- import { MARKER_OPEN } from "../brand";
68
+ import { commandHint, MARKER_OPEN } from "../brand";
69
69
  import { CliUsageError } from "../errors";
70
70
  import { envBillsMetered } from "../execution/usage-normalized";
71
71
  import { ciForceReviewHintLine } from "./force-comment";
@@ -83,6 +83,7 @@ import {
83
83
  } from "./review-admission";
84
84
  import type { CiReviewPolicyMode } from "./review-policy";
85
85
  import type { DeltaRiskAssessment } from "./review-risk";
86
+ import { OVERRIDE_COMMAND } from "./trigger";
86
87
 
87
88
  function usd(amount: number): string {
88
89
  return `$${amount.toFixed(2)}`;
@@ -697,8 +698,8 @@ function buildCoverageSkipComment(
697
698
 
698
699
  // budget-exhausted-carry S10: the comment a PR gets once no automatic review is left. It says so, explains
699
700
  // it by the repository's own rules, says what the gate does with the next pushes, and how to ask for more.
700
- // WHY no "override" here: an exhausted budget carries the last verdict (S2), and answered findings unlock a
701
- // carried red (S3), so nothing in this situation needs a human to unlock the gate.
701
+ // Stage 2 #12: no review reads those pushes, so the gate holds a green instead of carrying it, and the
702
+ // override is how a human merges a head no review verified.
702
703
  function buildManualRequiredComment(data: ManualRequiredSummary): string {
703
704
  const manualOnly = data.admissionReason === "manual-only-policy";
704
705
  const rules = [
@@ -724,9 +725,11 @@ function buildManualRequiredComment(data: ManualRequiredSummary): string {
724
725
  "",
725
726
  ...rules,
726
727
  "",
727
- "What the gate does with the next pushes: it keeps the last review's verdict. A red verdict turns " +
728
- "green, marked unverified, once every blocking finding has a reply from someone with write access: " +
729
- "`applied`, or a `dismissed` the CI adjudicator upheld. Reply before you push: the gate reads the " +
728
+ "What the gate does with the next pushes: no review reads them, so it never turns green on its own. " +
729
+ "A red verdict stays red while a blocking finding is unanswered. A green verdict, or a red one whose " +
730
+ "blocking findings all have a reply from someone with write access (`applied`, or a `dismissed` the " +
731
+ "CI adjudicator upheld), waits as `pending` until a review verifies the head or " +
732
+ `${commandHint(OVERRIDE_COMMAND)} merges it unverified. Reply before you push: the gate reads the ` +
730
733
  "replies when the push arrives.",
731
734
  "",
732
735
  "The existing review comment still describes the last head Crysk reviewed.",