crysk 0.3.3 → 0.5.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 (116) hide show
  1. package/README.md +26 -17
  2. package/config/models/anthropic.json +1 -1
  3. package/dist/SKILL-dsnffnfp.md +140 -0
  4. package/dist/SKILL-gnrbph72.md +140 -0
  5. package/dist/SKILL-k4k0zn1w.md +143 -0
  6. package/dist/SKILL-kq0xejn3.md +553 -0
  7. package/dist/SKILL-qaqsbygw.md +66 -0
  8. package/dist/SKILL-vhb4c3vv.md +553 -0
  9. package/dist/SKILL-vws0aqb8.md +553 -0
  10. package/dist/SKILL-xpf6kmdw.md +74 -0
  11. package/dist/ci-admission-0ken6ehx.md +128 -0
  12. package/dist/ci-admission-t0f5qwth.md +128 -0
  13. package/dist/cli.js +3366 -1680
  14. package/dist/index.js +1884 -947
  15. package/dist/opencode-ci-ac5zksdn.md +106 -0
  16. package/dist/workflow-4pkyck01.yml +160 -0
  17. package/package.json +2 -2
  18. package/prompts/default/PROVENANCE.md +1 -0
  19. package/skills/crysk/SKILL.md +16 -16
  20. package/skills/crysk-ci-setup/SKILL.md +42 -39
  21. package/skills/crysk-ci-setup/assets/workflow.yml +31 -22
  22. package/skills/crysk-ci-setup/references/ci-admission.md +2 -2
  23. package/skills/crysk-ci-setup/references/opencode-ci.md +53 -88
  24. package/skills/crysk-loop/SKILL.md +20 -9
  25. package/skills/crysk-pr/SKILL.md +1 -1
  26. package/src/asset-manifest.ts +0 -4
  27. package/src/assets.ts +2 -2
  28. package/src/ci/admission-ledger.ts +4 -0
  29. package/src/ci/classify-error.ts +21 -24
  30. package/src/ci/cli-record.ts +53 -1
  31. package/src/ci/crysk-secrets.ts +409 -0
  32. package/src/ci/gates.ts +31 -42
  33. package/src/ci/outcome.ts +421 -330
  34. package/src/ci/platform-config.ts +127 -0
  35. package/src/ci/platform-report.ts +935 -0
  36. package/src/ci/platform-trace.ts +551 -0
  37. package/src/ci/platform.ts +465 -0
  38. package/src/ci/publish.ts +19 -6
  39. package/src/ci/reporter.ts +9 -7
  40. package/src/ci/review-admission.ts +8 -4
  41. package/src/ci/review-levels.ts +8 -7
  42. package/src/ci/run.ts +88 -0
  43. package/src/ci/setup.ts +547 -109
  44. package/src/ci/trace-bundle.ts +1282 -0
  45. package/src/ci/trace-transcripts.ts +415 -0
  46. package/src/ci/trigger.ts +176 -33
  47. package/src/cli.ts +11 -3
  48. package/src/commands/ci-setup-questions.ts +3 -3
  49. package/src/commands/ci-setup.ts +152 -6
  50. package/src/commands/config.ts +3 -0
  51. package/src/commands/doctor.ts +15 -6
  52. package/src/compare/loop.ts +9 -1
  53. package/src/compare/martian-adapter.ts +1 -1
  54. package/src/config/config.ts +16 -3
  55. package/src/diversity/clustering.ts +0 -1
  56. package/src/diversity/identity.ts +4 -5
  57. package/src/diversity/pipeline-integration.ts +1 -9
  58. package/src/doctor.ts +3 -3
  59. package/src/execution/attempt-evidence.ts +10 -5
  60. package/src/execution/claude-session-trace.ts +480 -0
  61. package/src/execution/contracts.ts +21 -4
  62. package/src/execution/harness.ts +105 -8
  63. package/src/execution/model-fallback.ts +239 -0
  64. package/src/execution/usage-normalized.ts +6 -4
  65. package/src/home-preflight.ts +1 -1
  66. package/src/index.ts +1 -1
  67. package/src/model/catalog.ts +13 -37
  68. package/src/model/free-discovery.ts +117 -8
  69. package/src/model/model-name.ts +404 -0
  70. package/src/model/provider-capabilities.ts +22 -7
  71. package/src/model/routing.ts +346 -467
  72. package/src/pr/admission.ts +71 -11
  73. package/src/pr/ci-admission-gate.ts +2 -1
  74. package/src/pr/finding-state-record.ts +58 -0
  75. package/src/pr/gate-record.ts +22 -0
  76. package/src/pr/inline.ts +3 -0
  77. package/src/pr/plan.ts +20 -4
  78. package/src/pr/posting.ts +4 -0
  79. package/src/pr/pr-status.ts +27 -7
  80. package/src/pr/pr.ts +39 -8
  81. package/src/pr/preflight.ts +44 -2
  82. package/src/pr/publish-outcome.ts +11 -3
  83. package/src/pr/review-pr.ts +20 -4
  84. package/src/pr/target.ts +12 -3
  85. package/src/production-runtime.ts +760 -331
  86. package/src/rereview/classify.ts +4 -0
  87. package/src/rereview/prepare.ts +47 -22
  88. package/src/rereview/state.ts +34 -8
  89. package/src/review/pipeline.ts +277 -101
  90. package/src/review/preflight.ts +201 -294
  91. package/src/review/report.ts +60 -40
  92. package/src/review/review.ts +20 -3
  93. package/src/review/route-preflight.ts +79 -11
  94. package/src/review/run.ts +28 -6
  95. package/src/review/scout.ts +1 -1
  96. package/src/review/spec.ts +3 -3
  97. package/src/review/step-runner.ts +70 -1
  98. package/src/runner-authority.ts +127 -9
  99. package/src/security/binding-policy.ts +1 -2
  100. package/src/security/claude-credential.ts +355 -0
  101. package/src/security/credential-broker.ts +56 -40
  102. package/src/security/evidence-redaction.ts +179 -4
  103. package/src/security/opencode-secret-manifest.ts +114 -0
  104. package/src/security/published-text.ts +161 -0
  105. package/src/security/redact.ts +45 -0
  106. package/src/system-tools.ts +48 -21
  107. package/src/transport-registry.ts +12 -2
  108. package/src/transports/claude-code-cli.ts +21 -2
  109. package/src/transports/opencode-sdk.ts +11 -9
  110. package/src/transports/opencode-server.ts +7 -10
  111. package/src/triage/triage.ts +2 -1
  112. package/src/ui/config-edit.ts +9 -20
  113. package/src/ui/config.ts +32 -27
  114. package/src/ui/plan.ts +76 -47
  115. package/src/updater.ts +10 -7
  116. package/prompts/default/deep-review-lifecycle.md +0 -362
@@ -107,6 +107,10 @@ export interface PriorRecord {
107
107
  channel: FindingChannel;
108
108
  locs: readonly string[];
109
109
  claim: string;
110
+ // The fingerprint of the claim as first written, which is what the posted
111
+ // marker carries. `claim` here may be its published form, so hashing it would
112
+ // not match. Absent when the prior has no claim to fingerprint.
113
+ c?: string;
110
114
  triage: PriorTriage | null;
111
115
  // Case B rule 7b: any new reply on the prior thread, including tags
112
116
  // other than a newly-applied `applied` (that one is rule 7).
@@ -4,7 +4,7 @@
4
4
  // The case machine itself stays in rereview/plan.ts.
5
5
 
6
6
  import { normalizePath } from "#compare/compare";
7
- import { claimFingerprint } from "#pr/preflight";
7
+ import { claimFingerprint, parseFindingMarker } from "#pr/preflight";
8
8
  import type { Severity } from "#review/findings";
9
9
  import { parseFindingCommentBadge } from "#review/report";
10
10
  import {
@@ -617,20 +617,20 @@ export function priorsFromStateFindings(
617
617
  channel: finding.channel,
618
618
  locs: finding.locs,
619
619
  claim: finding.claim,
620
+ c: finding.c,
620
621
  triage: null,
621
622
  newThreadReply: false,
622
623
  }));
623
624
  }
624
625
 
625
626
  // #206's fix: the fallback that runs whenever the previous summary's
626
- // `pr-hero-state` block cannot supply priors — missing, unparseable, or (the
627
- // ROUTINE case, not a rare one: a FIRST review never writes a state block at
628
- // all, see `postInlineFindings`'s `framing === undefined` branch in
629
- // src/pr/pr.ts) simply absent because this is the PR's second review. It
630
- // used to hardcode `sev: "WARNING"` / `tier: "advisory"` / `claim: ""` for
631
- // EVERY prior here — silently downgrading a live BLOCKER to a warning on
632
- // every second review of every PR, and collapsing every claim-less row onto
633
- // `claimFingerprint("")`'s shared constant.
627
+ // `pr-hero-state` block cannot supply priors — missing or unparseable. Before
628
+ // 2026-11-04 a FIRST review never wrote a state block, so this was the
629
+ // routine path of every second review; summaries posted before then still
630
+ // reach it. It used to hardcode `sev: "WARNING"` / `tier: "advisory"` /
631
+ // `claim: ""` for EVERY prior here — silently downgrading a live BLOCKER to a
632
+ // warning on every second review of every PR, and collapsing every claim-less
633
+ // row onto `claimFingerprint("")`'s shared constant.
634
634
  //
635
635
  // `body` is the posted comment's raw text (the marker line alone carries no
636
636
  // sev/tier/claim — `findingMarker` signs only the claim's fingerprint, never
@@ -651,6 +651,7 @@ export function priorsFromPostedMarkers(
651
651
  ): PriorRecord[] {
652
652
  return posted.map((item, i) => {
653
653
  const recovered = parseFindingCommentBadge(item.body);
654
+ const c = recovered === null ? undefined : parseFindingMarker(item.body)?.c;
654
655
  return {
655
656
  id: `R${String(i + 1).padStart(3, "0")}`,
656
657
  sev: recovered?.sev ?? SEVERITY_UNRECOVERABLE,
@@ -658,6 +659,7 @@ export function priorsFromPostedMarkers(
658
659
  channel: item.channel,
659
660
  locs: [`${item.path}:${item.line}`],
660
661
  claim: recovered?.claim ?? "",
662
+ ...(c === undefined ? {} : { c }),
661
663
  triage: null,
662
664
  newThreadReply: false,
663
665
  };
@@ -750,13 +752,18 @@ export interface PostedForPrior {
750
752
  // triage tag or a thread left open; an over-match puts a "✅ RESOLVED ·
751
753
  // verified gone" reply on a still-live finding.
752
754
  export function bindPriorsToPosted<T extends PostedForPrior>(
753
- priors: readonly { id: string; locs: readonly string[]; claim: string }[],
755
+ priors: readonly {
756
+ id: string;
757
+ locs: readonly string[];
758
+ claim: string;
759
+ c?: string;
760
+ }[],
754
761
  posted: readonly T[],
755
762
  window: number = IDENTITY_LINE_WINDOW,
756
763
  ): Map<string, T> {
757
764
  interface Pair {
758
765
  priorId: string;
759
- claim: string;
766
+ fingerprint: string | undefined;
760
767
  row: T;
761
768
  distance: number;
762
769
  }
@@ -767,7 +774,12 @@ export function bindPriorsToPosted<T extends PostedForPrior>(
767
774
  for (const row of posted) {
768
775
  const distance = anchorDistance(identity, row, window);
769
776
  if (distance === null) continue;
770
- pairs.push({ priorId: prior.id, claim: prior.claim, row, distance });
777
+ pairs.push({
778
+ priorId: prior.id,
779
+ fingerprint: priorFingerprint(prior),
780
+ row,
781
+ distance,
782
+ });
771
783
  }
772
784
  }
773
785
 
@@ -804,7 +816,7 @@ export function bindPriorsToPosted<T extends PostedForPrior>(
804
816
  let changed = false;
805
817
  const proposals: Pair[] = [];
806
818
  for (const [priorId, group] of byPrior) {
807
- const winner = resolvePriorTie(group, group[0]?.claim ?? "");
819
+ const winner = resolvePriorTie(group, group[0]?.fingerprint);
808
820
  if (winner === undefined) {
809
821
  disqualified.add(priorId);
810
822
  changed = true;
@@ -869,16 +881,25 @@ function anchorDistance(
869
881
  return best;
870
882
  }
871
883
 
884
+ // What a prior's marker should carry. No claim, no fingerprint:
885
+ // `claimFingerprint("")` is a real constant hash (`e3b0c44298fc`) that every
886
+ // empty-claim prior shares, so consulting it would hand a whole tied set to
887
+ // whichever row came first. A stored `c` wins because the stored claim may be
888
+ // its published form, which the posted marker never hashed.
889
+ function priorFingerprint(prior: {
890
+ claim: string;
891
+ c?: string;
892
+ }): string | undefined {
893
+ if (prior.claim.trim().length === 0) return undefined;
894
+ return prior.c ?? claimFingerprint(prior.claim);
895
+ }
896
+
872
897
  function resolvePriorTie<T extends PostedForPrior>(
873
898
  tied: readonly { row: T; distance: number }[],
874
- claim: string,
899
+ fingerprint: string | undefined,
875
900
  ): T | undefined {
876
901
  if (tied.length === 1) return tied[0]?.row;
877
- // No claim, no tie-break: `claimFingerprint("")` is a real constant hash
878
- // (`e3b0c44298fc`) that every empty-claim prior shares, so consulting it
879
- // here would hand the whole tied set to whichever row came first.
880
- if (claim.trim().length === 0) return undefined;
881
- const fingerprint = claimFingerprint(claim);
902
+ if (fingerprint === undefined) return undefined;
882
903
  const matching = tied.filter((c) => c.row.marker.c === fingerprint);
883
904
  return matching.length === 1 ? matching[0]?.row : undefined;
884
905
  }
@@ -890,13 +911,17 @@ function resolvePriorTie<T extends PostedForPrior>(
890
911
  // claim-less prior shares), and anything short of exactly one match leaves the
891
912
  // comment to nobody.
892
913
  function resolveRowTie<T extends PostedForPrior>(
893
- contenders: readonly { priorId: string; claim: string; row: T }[],
914
+ contenders: readonly {
915
+ priorId: string;
916
+ fingerprint: string | undefined;
917
+ row: T;
918
+ }[],
894
919
  ): { priorId: string; row: T } | undefined {
895
920
  if (contenders.length === 1) return contenders[0];
896
921
  const matching = contenders.filter(
897
922
  (contender) =>
898
- contender.claim.trim().length > 0 &&
899
- contender.row.marker.c === claimFingerprint(contender.claim),
923
+ contender.fingerprint !== undefined &&
924
+ contender.row.marker.c === contender.fingerprint,
900
925
  );
901
926
  return matching.length === 1 ? matching[0] : undefined;
902
927
  }
@@ -27,6 +27,7 @@ import {
27
27
  } from "#review/findings";
28
28
  import { isSafetyProtected } from "#review/materiality-gate";
29
29
  import { findMarker, MARKER_BRAND_PATTERN, MARKER_OPEN } from "../brand";
30
+ import { redactSecrets, wasRedacted } from "../security/published-text";
30
31
  import {
31
32
  type FindingChannel,
32
33
  type GateStatus,
@@ -125,9 +126,14 @@ export function renderStateBlock(
125
126
  sev: f.sev,
126
127
  tier: f.tier,
127
128
  channel: f.channel,
129
+ // Stays as written, unlike the claim below. A location is the identity the
130
+ // engine compares, and a redacted one never pairs with its finding again,
131
+ // so a blocking row could never be released.
128
132
  locs: f.locs,
129
133
  c: f.c,
130
- claim: f.claim,
134
+ // The block sits in the comment's raw source, so a secret here is still
135
+ // public. `c` keeps the fingerprint of the original claim.
136
+ claim: redactSecrets(f.claim),
131
137
  })),
132
138
  };
133
139
  if (reviews !== undefined && Number.isInteger(reviews) && reviews >= 1) {
@@ -270,10 +276,16 @@ function lastEvictableIndex(
270
276
  }
271
277
 
272
278
  function encodeStateJson(value: unknown): string {
273
- return JSON.stringify(value)
274
- .replaceAll("\u2028", "\\u2028")
275
- .replaceAll("\u2029", "\\u2029")
276
- .replaceAll("-->", "--\\u003e");
279
+ return (
280
+ JSON.stringify(value)
281
+ .replaceAll("\u2028", "\\u2028")
282
+ .replaceAll("\u2029", "\\u2029")
283
+ // No angle bracket at all: a claim or path must not spell a marker that a
284
+ // parser finds first, and GitHub also ends a comment at `--!>`, not only
285
+ // at `-->`. JSON.parse reads the escapes back to the same text.
286
+ .replaceAll("<", "\\u003c")
287
+ .replaceAll(">", "\\u003e")
288
+ );
277
289
  }
278
290
 
279
291
  function asStateFindings(parsed: unknown): StateFinding[] | null {
@@ -447,7 +459,9 @@ export function assembleLive(input: {
447
459
  tier: gatePrior.tier,
448
460
  channel: gatePrior.channel,
449
461
  locs: row.locs,
450
- c: liveFingerprint(gatePrior.id, gatePrior.claim),
462
+ // The stored fingerprint when there is one: the stored claim may be
463
+ // sanitized, and the posted marker hashed the original.
464
+ c: gatePrior.c ?? liveFingerprint(gatePrior.id, gatePrior.claim),
451
465
  claim: gatePrior.claim,
452
466
  status: persisted,
453
467
  });
@@ -718,10 +732,16 @@ function gatePairing(
718
732
  // would turn the gate green on a finding the guard exists to keep blocking.
719
733
  // A blank claim counts as unknown: the badge reader writes an unrecovered
720
734
  // claim as "" (rereview/prepare.ts), and the guard cannot read safety content
721
- // that is not there.
735
+ // that is not there. A redacted claim counts the same way, since the word that
736
+ // made it a safety finding may be the part that was removed.
722
737
  function isReleasable(row: GateRow | undefined): boolean {
723
738
  const claim = row?.claim;
724
- if (row === undefined || claim === undefined || claim.trim().length === 0) {
739
+ if (
740
+ row === undefined ||
741
+ claim === undefined ||
742
+ claim.trim().length === 0 ||
743
+ wasRedacted(claim)
744
+ ) {
725
745
  return false;
726
746
  }
727
747
  const paths = [...identityFromLocs(row.locs).keys()];
@@ -807,6 +827,8 @@ export interface MergedState {
807
827
  rows: LiveFinding[];
808
828
  hw: number;
809
829
  dropped: number;
830
+ // The stable id each `fresh` finding ended up with, by index.
831
+ freshIds: (string | undefined)[];
810
832
  }
811
833
 
812
834
  // Visible body the state block must leave room for. The PATCH body is longer
@@ -857,6 +879,7 @@ export function mergeStateFindings(input: MergeStateInput): MergedState {
857
879
  }
858
880
  }
859
881
  const touched = new Set<string>();
882
+ const freshIds: (string | undefined)[] = input.fresh.map(() => undefined);
860
883
 
861
884
  const pairs = pairBlockingSurvivors(
862
885
  input.fresh,
@@ -905,6 +928,7 @@ export function mergeStateFindings(input: MergeStateInput): MergedState {
905
928
  status: prior.status,
906
929
  };
907
930
  touched.add(prior.id);
931
+ freshIds[s] = prior.id;
908
932
  continue;
909
933
  }
910
934
  // WHY an unpaired survivor appends: a blocking survivor with no matching row
@@ -925,6 +949,7 @@ export function mergeStateFindings(input: MergeStateInput): MergedState {
925
949
  status: "unconfirmed",
926
950
  });
927
951
  touched.add(id);
952
+ freshIds[s] = id;
928
953
  }
929
954
 
930
955
  const capped = capLiveFindings(rows, "", input.headSha, input.stateBudget, {
@@ -936,6 +961,7 @@ export function mergeStateFindings(input: MergeStateInput): MergedState {
936
961
  rows: capped.kept,
937
962
  hw,
938
963
  dropped: capped.droppedUnconfirmed + capped.droppedCarried,
964
+ freshIds,
939
965
  };
940
966
  }
941
967