crysk 0.4.0 → 0.5.1

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 (98) hide show
  1. package/README.md +26 -17
  2. package/config/models/anthropic.json +1 -1
  3. package/dist/SKILL-k4k0zn1w.md +143 -0
  4. package/dist/SKILL-vhb4c3vv.md +553 -0
  5. package/dist/SKILL-xpf6kmdw.md +74 -0
  6. package/dist/ci-admission-0ken6ehx.md +128 -0
  7. package/dist/cli.js +3056 -1623
  8. package/dist/index.js +1744 -938
  9. package/dist/opencode-ci-ac5zksdn.md +106 -0
  10. package/dist/workflow-4pkyck01.yml +160 -0
  11. package/package.json +1 -1
  12. package/prompts/default/PROVENANCE.md +1 -0
  13. package/skills/crysk/SKILL.md +16 -16
  14. package/skills/crysk-ci-setup/SKILL.md +41 -38
  15. package/skills/crysk-ci-setup/assets/workflow.yml +31 -22
  16. package/skills/crysk-ci-setup/references/ci-admission.md +1 -1
  17. package/skills/crysk-ci-setup/references/opencode-ci.md +53 -88
  18. package/skills/crysk-loop/SKILL.md +1 -1
  19. package/src/asset-manifest.ts +0 -4
  20. package/src/assets.ts +1 -1
  21. package/src/ci/admission-ledger.ts +4 -0
  22. package/src/ci/classify-error.ts +21 -24
  23. package/src/ci/cli-record.ts +53 -1
  24. package/src/ci/crysk-secrets.ts +409 -0
  25. package/src/ci/force-comment.ts +14 -1
  26. package/src/ci/gates.ts +86 -57
  27. package/src/ci/outcome.ts +421 -330
  28. package/src/ci/platform-config.ts +2 -2
  29. package/src/ci/platform-estimate.ts +111 -0
  30. package/src/ci/platform-report.ts +274 -41
  31. package/src/ci/platform-trace.ts +581 -0
  32. package/src/ci/platform.ts +58 -12
  33. package/src/ci/publish.ts +19 -6
  34. package/src/ci/reporter.ts +14 -4
  35. package/src/ci/review-levels.ts +8 -7
  36. package/src/ci/run.ts +88 -0
  37. package/src/ci/setup.ts +485 -118
  38. package/src/ci/trace-bundle.ts +1486 -0
  39. package/src/ci/trace-transcripts.ts +480 -0
  40. package/src/ci/trigger.ts +176 -33
  41. package/src/cli.ts +11 -3
  42. package/src/commands/ci-setup-questions.ts +3 -3
  43. package/src/commands/ci-setup.ts +152 -6
  44. package/src/commands/config.ts +3 -0
  45. package/src/commands/doctor.ts +15 -6
  46. package/src/config/config.ts +16 -3
  47. package/src/diversity/clustering.ts +0 -1
  48. package/src/diversity/identity.ts +4 -5
  49. package/src/diversity/pipeline-integration.ts +1 -9
  50. package/src/doctor.ts +3 -3
  51. package/src/execution/attempt-evidence.ts +10 -5
  52. package/src/execution/claude-session-trace.ts +480 -0
  53. package/src/execution/contracts.ts +21 -4
  54. package/src/execution/harness.ts +105 -8
  55. package/src/execution/model-fallback.ts +239 -0
  56. package/src/execution/usage-normalized.ts +6 -4
  57. package/src/home-preflight.ts +1 -1
  58. package/src/index.ts +1 -1
  59. package/src/model/catalog.ts +13 -37
  60. package/src/model/free-discovery.ts +117 -8
  61. package/src/model/model-name.ts +404 -0
  62. package/src/model/provider-capabilities.ts +22 -7
  63. package/src/model/routing.ts +346 -467
  64. package/src/pr/admission.ts +18 -0
  65. package/src/pr/ci-admission-gate.ts +2 -0
  66. package/src/pr/discovery.ts +18 -0
  67. package/src/pr/plan.ts +55 -5
  68. package/src/pr/preflight.ts +1 -1
  69. package/src/pr/publish-outcome.ts +1 -1
  70. package/src/pr/review-pr.ts +26 -1
  71. package/src/pr/target.ts +63 -11
  72. package/src/production-runtime.ts +760 -331
  73. package/src/review/pipeline.ts +277 -101
  74. package/src/review/preflight.ts +201 -294
  75. package/src/review/report.ts +30 -26
  76. package/src/review/review.ts +20 -3
  77. package/src/review/route-preflight.ts +79 -11
  78. package/src/review/run.ts +44 -6
  79. package/src/review/scout.ts +1 -1
  80. package/src/review/spec.ts +3 -3
  81. package/src/review/step-runner.ts +70 -1
  82. package/src/runner-authority.ts +127 -9
  83. package/src/security/binding-policy.ts +1 -2
  84. package/src/security/claude-credential.ts +355 -0
  85. package/src/security/credential-broker.ts +56 -40
  86. package/src/security/evidence-redaction.ts +179 -4
  87. package/src/security/opencode-secret-manifest.ts +114 -0
  88. package/src/security/redact.ts +45 -0
  89. package/src/system-tools.ts +48 -21
  90. package/src/transport-registry.ts +12 -2
  91. package/src/transports/claude-code-cli.ts +21 -2
  92. package/src/transports/opencode-sdk.ts +11 -9
  93. package/src/transports/opencode-server.ts +7 -10
  94. package/src/ui/config-edit.ts +9 -20
  95. package/src/ui/config.ts +32 -27
  96. package/src/ui/plan.ts +84 -50
  97. package/src/updater.ts +10 -7
  98. package/prompts/default/deep-review-lifecycle.md +0 -362
package/src/ci/outcome.ts CHANGED
@@ -30,31 +30,32 @@ import type { CredentialProjectionFailureClass } from "../security/credential-br
30
30
 
31
31
  export type Owner = "config" | "provider" | "pr-hero" | "unclassified";
32
32
  export type OutcomeContext = "action" | "local";
33
- // An owner is fixed, or depends on the context (PRH-RUNTIME-UNAVAILABLE).
33
+ // An owner is fixed, or depends on the context (CRYSK-RUNTIME-UNAVAILABLE).
34
34
  type OwnerRule = Owner | Readonly<Record<OutcomeContext, Owner>>;
35
35
 
36
36
  type CapabilityIssue =
37
37
  | "binary_unresolved"
38
38
  | "sdk_unavailable"
39
39
  | "version_unsupported";
40
- type RouteReason =
41
- | "unmapped"
42
- | "ambiguous"
43
- | "spend-disabled"
44
- | "multiple-opencode-providers";
45
40
 
46
41
  export type ErrorClass =
47
42
  | {
48
43
  kind: "trigger";
49
- check: "no-credential" | "routing-missing" | "pr-unresolved";
44
+ check: "no-credential" | "removed-input" | "pr-unresolved";
50
45
  }
51
46
  | {
52
47
  kind: "config-parse";
53
- source: "routing" | "repo-config" | "person-config" | "extra-hunters";
48
+ // `models-input` and `credentials-input`: the setup step's reading of the
49
+ // `models` and `credentials` inputs (D1), never the CLI's.
50
+ source:
51
+ | "models-input"
52
+ | "credentials-input"
53
+ | "repo-config"
54
+ | "person-config"
55
+ | "extra-hunters";
54
56
  }
55
57
  | { kind: "prompt-set" }
56
58
  | { kind: "gotchas"; reason: "empty" | "placeholder" }
57
- | { kind: "route"; reason: RouteReason }
58
59
  | {
59
60
  kind: "credential";
60
61
  failureClass: CredentialProjectionFailureClass | "env-absent";
@@ -71,30 +72,28 @@ export type ErrorClass =
71
72
  type GithubClass = Extract<ErrorClass, { kind: "github" }>;
72
73
 
73
74
  export const ERROR_CODES = [
74
- "PRH-CRED-MISSING",
75
- "PRH-CRED-UNUSABLE",
76
- "PRH-CRED-REJECTED",
77
- "PRH-ROUTING-MISSING",
78
- "PRH-ROUTING-INVALID",
79
- "PRH-ROUTE-UNRESOLVABLE",
80
- "PRH-MODEL-UNAVAILABLE",
81
- "PRH-PROMPTSET-INVALID",
82
- "PRH-GOTCHAS-MISSING",
83
- "PRH-CONFIG-INVALID",
84
- "PRH-TOKEN-PERMISSION",
85
- "PRH-GITHUB-TOKEN-INVALID",
86
- "PRH-GITHUB-UNAVAILABLE",
87
- "PRH-PR-UNRESOLVED",
88
- "PRH-STATUS-WRITE-FAILED",
89
- "PRH-RUNTIME-UNAVAILABLE",
90
- "PRH-INSTALL-FAILED",
91
- "PRH-PROVIDER-LIMITED",
92
- "PRH-PROVIDER-UNAVAILABLE",
93
- "PRH-PROVIDER-REFUSED",
94
- "PRH-ENGINE-DEFECT",
95
- "PRH-HUNTERS-FAILED",
96
- "PRH-UNCLASSIFIED",
97
- "PRH-CANCELLED",
75
+ "CRYSK-CRED-MISSING",
76
+ "CRYSK-INPUT-REMOVED",
77
+ "CRYSK-CRED-UNUSABLE",
78
+ "CRYSK-CRED-REJECTED",
79
+ "CRYSK-MODEL-UNAVAILABLE",
80
+ "CRYSK-PROMPTSET-INVALID",
81
+ "CRYSK-GOTCHAS-MISSING",
82
+ "CRYSK-CONFIG-INVALID",
83
+ "CRYSK-TOKEN-PERMISSION",
84
+ "CRYSK-GITHUB-TOKEN-INVALID",
85
+ "CRYSK-GITHUB-UNAVAILABLE",
86
+ "CRYSK-PR-UNRESOLVED",
87
+ "CRYSK-STATUS-WRITE-FAILED",
88
+ "CRYSK-RUNTIME-UNAVAILABLE",
89
+ "CRYSK-INSTALL-FAILED",
90
+ "CRYSK-PROVIDER-LIMITED",
91
+ "CRYSK-PROVIDER-UNAVAILABLE",
92
+ "CRYSK-PROVIDER-REFUSED",
93
+ "CRYSK-ENGINE-DEFECT",
94
+ "CRYSK-HUNTERS-FAILED",
95
+ "CRYSK-UNCLASSIFIED",
96
+ "CRYSK-CANCELLED",
98
97
  ] as const;
99
98
 
100
99
  export type ErrorCode = (typeof ERROR_CODES)[number];
@@ -103,14 +102,14 @@ interface CatalogVariant {
103
102
  // Replaces the entry's `what` for this sub-class.
104
103
  readonly what?: string;
105
104
  // Replaces `what` when no model is given, so the sentence never names a placeholder
106
- // (PRH-MODEL-UNAVAILABLE's every_hunter variant). Filled like `what`.
105
+ // (CRYSK-MODEL-UNAVAILABLE's every_hunter variant). Filled like `what`.
107
106
  readonly whatWithoutModel?: string;
108
107
  // Replaces the entry's owner for this sub-class.
109
108
  readonly owner?: OwnerRule;
110
109
  readonly why: string;
111
110
  // A list of fix lines, or a function of the params when the steps depend on
112
- // them (the backend: missing_subscription_record, and PRH-CRED-MISSING's
113
- // routing variable).
111
+ // them (the backend: missing_subscription_record, and CRYSK-CRED-MISSING's
112
+ // route).
114
113
  readonly fixes:
115
114
  | readonly string[]
116
115
  | ((params: ErrorParams) => readonly string[]);
@@ -134,7 +133,7 @@ export interface CatalogEntry {
134
133
  // placeholder ("The this step step failed"). Filled like `what`.
135
134
  readonly whatWithoutStep?: string;
136
135
  // "default" is always present. Keys "action" / "local" select by context
137
- // (PRH-RUNTIME-UNAVAILABLE); other keys are the failure's sub-class
136
+ // (CRYSK-RUNTIME-UNAVAILABLE); other keys are the failure's sub-class
138
137
  // (credential failureClass, route reason, GitHub status family), chosen by
139
138
  // renderError or by the caller through renderCode.
140
139
  readonly variants: Readonly<Record<string, CatalogVariant>>;
@@ -150,7 +149,7 @@ export interface ErrorParams {
150
149
  runId?: string;
151
150
  runUrl?: string;
152
151
  detail?: string;
153
- // The model a provider does not serve, when the record names it (PRH-MODEL-UNAVAILABLE).
152
+ // The model a provider does not serve, when the record names it (CRYSK-MODEL-UNAVAILABLE).
154
153
  model?: string;
155
154
  }
156
155
 
@@ -175,6 +174,7 @@ export interface TriggerRecord {
175
174
  | "denied"
176
175
  | "unverifiable"
177
176
  | "no-credentials"
177
+ | "removed-inputs"
178
178
  | "override";
179
179
  cls?: ErrorClass;
180
180
  params: ErrorParams;
@@ -194,7 +194,7 @@ export interface TriggerRecord {
194
194
  }
195
195
 
196
196
  // The record the setup step writes to `setup.json` in the outcome directory when a
197
- // routing or OpenCode auth input is malformed (odd/tasks/agent-first-ci.md, A1).
197
+ // models or OpenCode auth input is malformed (odd/tasks/agent-first-ci.md, A1).
198
198
  // The publisher reads it back, so the failure is named instead of reported as a
199
199
  // generic install failure. `detail` is a fixed phrase per failure site that names
200
200
  // the input which is wrong; it never carries that input's content.
@@ -214,6 +214,12 @@ export const CLI_RECORD_FILE = "cli.json";
214
214
  // pending landed. The cancel settle overwrites only the pending with exactly this time.
215
215
  export const PENDING_AT_FILE = "pending-at";
216
216
 
217
+ // The run directory the CLI created, written by recordRunDir (src/ci/cli-record.ts)
218
+ // as soon as it exists. The run step's `run_dir` output is empty when every hunter
219
+ // failed, on a fatal error and on a cancelled job, and the trace step
220
+ // (src/ci/platform-trace.ts) still needs the files of exactly those runs.
221
+ export const RUN_DIR_FILE = "run-dir";
222
+
217
223
  // The URL of this run's attempt, or undefined outside GitHub Actions. The CLI's pending names
218
224
  // it as its target_url, and the cancel settle compares a pending with it (SB3 follow-up), so
219
225
  // the CLI and the publisher share this one builder: they cannot disagree on the URL. An attempt
@@ -237,14 +243,22 @@ export function actionsRunUrl(
237
243
  // would hide a writer's bug, the same rule as parseRecordClass below. The config
238
244
  // classes are the ones a throw site names (T2d-1). The person layer is not one of
239
245
  // them: its catalog text names the repo file, so the record would send the reader
240
- // to the wrong file.
246
+ // to the wrong file. The two credential classes are admission's refusals
247
+ // (CredentialRefusalError, security/claude-credential.ts): a Claude route with no
248
+ // credential (CRYSK-CRED-MISSING, the trigger's own class for it) and an OpenCode
249
+ // route with no auth record (CRYSK-CRED-UNUSABLE, the class its first step would
250
+ // have failed with).
241
251
  export type CliErrorClass =
242
252
  | { kind: "unknown" }
243
- | { kind: "route"; reason: "unmapped" | "ambiguous" | "spend-disabled" }
253
+ | { kind: "trigger"; check: "no-credential" }
254
+ | {
255
+ kind: "credential";
256
+ failureClass: "missing_provider_record" | "missing_subscription_record";
257
+ }
244
258
  | { kind: "capability"; issue: "sdk_unavailable" | "version_unsupported" }
245
259
  | {
246
260
  kind: "config-parse";
247
- source: "routing" | "repo-config" | "extra-hunters";
261
+ source: "repo-config" | "extra-hunters";
248
262
  }
249
263
  | { kind: "prompt-set" }
250
264
  | { kind: "gotchas"; reason: "empty" | "placeholder" }
@@ -281,7 +295,8 @@ export interface CliRecord {
281
295
  head_sha?: string;
282
296
  // Only for outcome "error".
283
297
  cls?: CliErrorClass;
284
- // Only for outcome "error", and the writer does not set it today.
298
+ // Only for outcome "error": the params the failing throw site named, when it named
299
+ // any (a credential refusal's backend, provider, model and secret).
285
300
  params?: ErrorParams;
286
301
  // Only for outcome "reviewed". The review was delivered, but the CLI's final status
287
302
  // write on head_sha failed, so the head's required check is still pending. The
@@ -405,6 +420,7 @@ const TRIGGER_DECISIONS: readonly TriggerRecord["decision"][] = [
405
420
  "denied",
406
421
  "unverifiable",
407
422
  "no-credentials",
423
+ "removed-inputs",
408
424
  "override",
409
425
  ];
410
426
  // A GitHub login, with the bound and characters of the trigger's check (GITHUB_LOGIN in
@@ -422,6 +438,7 @@ const RECORD_PARAM_KEYS: readonly string[] = [
422
438
  "runId",
423
439
  "runUrl",
424
440
  "detail",
441
+ "model",
425
442
  ];
426
443
  const SHA_PATTERN = /^[0-9a-f]{40}([0-9a-f]{24})?$/;
427
444
 
@@ -453,8 +470,11 @@ function parseRecordParams(value: unknown): ErrorParams | undefined {
453
470
  // a writer's bug, the same rule as parseRecordClass below.
454
471
  function parseSetupClass(value: unknown): ErrorClass | undefined {
455
472
  if (!isRecordObject(value)) return undefined;
456
- if (value.kind === "config-parse" && value.source === "routing") {
457
- return { kind: "config-parse", source: "routing" };
473
+ if (
474
+ value.kind === "config-parse" &&
475
+ (value.source === "models-input" || value.source === "credentials-input")
476
+ ) {
477
+ return { kind: "config-parse", source: value.source };
458
478
  }
459
479
  if (
460
480
  value.kind === "credential" &&
@@ -606,13 +626,17 @@ const CLI_HEAD_PATTERN = /^[0-9a-f]{40}$/;
606
626
  function parseCliClass(value: unknown): CliErrorClass | undefined {
607
627
  if (!isRecordObject(value)) return undefined;
608
628
  if (value.kind === "unknown") return { kind: "unknown" };
609
- if (value.kind === "route") {
629
+ if (value.kind === "trigger") {
630
+ return value.check === "no-credential"
631
+ ? { kind: "trigger", check: "no-credential" }
632
+ : undefined;
633
+ }
634
+ if (value.kind === "credential") {
610
635
  if (
611
- value.reason === "unmapped" ||
612
- value.reason === "ambiguous" ||
613
- value.reason === "spend-disabled"
636
+ value.failureClass === "missing_provider_record" ||
637
+ value.failureClass === "missing_subscription_record"
614
638
  ) {
615
- return { kind: "route", reason: value.reason };
639
+ return { kind: "credential", failureClass: value.failureClass };
616
640
  }
617
641
  return undefined;
618
642
  }
@@ -625,11 +649,7 @@ function parseCliClass(value: unknown): CliErrorClass | undefined {
625
649
  }
626
650
  }
627
651
  if (value.kind === "config-parse") {
628
- if (
629
- value.source === "routing" ||
630
- value.source === "repo-config" ||
631
- value.source === "extra-hunters"
632
- ) {
652
+ if (value.source === "repo-config" || value.source === "extra-hunters") {
633
653
  return { kind: "config-parse", source: value.source };
634
654
  }
635
655
  return undefined;
@@ -795,51 +815,38 @@ export function codeOf(cls: ErrorClass): ErrorCode {
795
815
  case "trigger":
796
816
  switch (cls.check) {
797
817
  case "no-credential":
798
- return "PRH-CRED-MISSING";
799
- case "routing-missing":
800
- return "PRH-ROUTING-MISSING";
818
+ return "CRYSK-CRED-MISSING";
819
+ case "removed-input":
820
+ return "CRYSK-INPUT-REMOVED";
801
821
  case "pr-unresolved":
802
- return "PRH-PR-UNRESOLVED";
822
+ return "CRYSK-PR-UNRESOLVED";
803
823
  default:
804
- return unmapped(cls.check, "PRH-UNCLASSIFIED");
824
+ return unmapped(cls.check, "CRYSK-UNCLASSIFIED");
805
825
  }
806
826
  case "config-parse":
807
827
  switch (cls.source) {
808
- case "routing":
809
- return "PRH-ROUTING-INVALID";
828
+ case "models-input":
829
+ case "credentials-input":
810
830
  case "repo-config":
811
831
  case "person-config":
812
- return "PRH-CONFIG-INVALID";
832
+ return "CRYSK-CONFIG-INVALID";
813
833
  case "extra-hunters":
814
- return "PRH-PROMPTSET-INVALID";
834
+ return "CRYSK-PROMPTSET-INVALID";
815
835
  default:
816
- return unmapped(cls.source, "PRH-UNCLASSIFIED");
836
+ return unmapped(cls.source, "CRYSK-UNCLASSIFIED");
817
837
  }
818
838
  case "prompt-set":
819
- return "PRH-PROMPTSET-INVALID";
820
- // `reason` is captured in a local: it is a discriminant shared by the
821
- // gotchas and route members, so narrowing on `cls.reason` in the inner
822
- // default would collapse `cls` itself to never.
839
+ return "CRYSK-PROMPTSET-INVALID";
840
+ // `reason` is captured in a local, so narrowing on `cls.reason` in the inner
841
+ // default does not collapse `cls` itself to never.
823
842
  case "gotchas": {
824
843
  const reason = cls.reason;
825
844
  switch (reason) {
826
845
  case "empty":
827
846
  case "placeholder":
828
- return "PRH-GOTCHAS-MISSING";
847
+ return "CRYSK-GOTCHAS-MISSING";
829
848
  default:
830
- return unmapped(reason, "PRH-UNCLASSIFIED");
831
- }
832
- }
833
- case "route": {
834
- const reason = cls.reason;
835
- switch (reason) {
836
- case "unmapped":
837
- case "ambiguous":
838
- case "spend-disabled":
839
- case "multiple-opencode-providers":
840
- return "PRH-ROUTE-UNRESOLVABLE";
841
- default:
842
- return unmapped(reason, "PRH-UNCLASSIFIED");
849
+ return unmapped(reason, "CRYSK-UNCLASSIFIED");
843
850
  }
844
851
  }
845
852
  case "credential":
@@ -849,34 +856,34 @@ export function codeOf(cls: ErrorClass): ErrorCode {
849
856
  case "malformed_payload":
850
857
  case "source_read_failed":
851
858
  case "env-absent":
852
- return "PRH-CRED-UNUSABLE";
859
+ return "CRYSK-CRED-UNUSABLE";
853
860
  case "unsupported_kind":
854
861
  case "projection_layout_invalid":
855
- return "PRH-ENGINE-DEFECT";
862
+ return "CRYSK-ENGINE-DEFECT";
856
863
  default:
857
- return unmapped(cls.failureClass, "PRH-UNCLASSIFIED");
864
+ return unmapped(cls.failureClass, "CRYSK-UNCLASSIFIED");
858
865
  }
859
866
  case "capability":
860
867
  switch (cls.issue) {
861
868
  case "binary_unresolved":
862
869
  case "sdk_unavailable":
863
870
  case "version_unsupported":
864
- return "PRH-RUNTIME-UNAVAILABLE";
871
+ return "CRYSK-RUNTIME-UNAVAILABLE";
865
872
  default:
866
- return unmapped(cls.issue, "PRH-UNCLASSIFIED");
873
+ return unmapped(cls.issue, "CRYSK-UNCLASSIFIED");
867
874
  }
868
875
  case "transport":
869
876
  return transportCode(cls.cause);
870
877
  case "github":
871
878
  return githubCode(cls);
872
879
  case "install":
873
- return "PRH-INSTALL-FAILED";
880
+ return "CRYSK-INSTALL-FAILED";
874
881
  case "invariant":
875
- return "PRH-ENGINE-DEFECT";
882
+ return "CRYSK-ENGINE-DEFECT";
876
883
  case "unknown":
877
- return "PRH-UNCLASSIFIED";
884
+ return "CRYSK-UNCLASSIFIED";
878
885
  default:
879
- return unmapped(cls, "PRH-UNCLASSIFIED");
886
+ return unmapped(cls, "CRYSK-UNCLASSIFIED");
880
887
  }
881
888
  }
882
889
 
@@ -885,14 +892,15 @@ export function codeOf(cls: ErrorClass): ErrorCode {
885
892
  // 403 without the flag is a permission problem. A 429 is always a rate limit.
886
893
  // A status outside the mapped families is unclassified, never an outage.
887
894
  function githubCode(cls: GithubClass): ErrorCode {
888
- if (cls.status === 401) return "PRH-GITHUB-TOKEN-INVALID";
895
+ if (cls.status === 401) return "CRYSK-GITHUB-TOKEN-INVALID";
889
896
  if (cls.status === 403) {
890
897
  return cls.rateLimited === true
891
- ? "PRH-GITHUB-UNAVAILABLE"
892
- : "PRH-TOKEN-PERMISSION";
898
+ ? "CRYSK-GITHUB-UNAVAILABLE"
899
+ : "CRYSK-TOKEN-PERMISSION";
893
900
  }
894
- if (cls.status === 429 || cls.status >= 500) return "PRH-GITHUB-UNAVAILABLE";
895
- return "PRH-UNCLASSIFIED";
901
+ if (cls.status === 429 || cls.status >= 500)
902
+ return "CRYSK-GITHUB-UNAVAILABLE";
903
+ return "CRYSK-UNCLASSIFIED";
896
904
  }
897
905
 
898
906
  function transportCode(
@@ -900,26 +908,26 @@ function transportCode(
900
908
  ): ErrorCode {
901
909
  switch (cause) {
902
910
  case "auth_invalid":
903
- return "PRH-CRED-REJECTED";
911
+ return "CRYSK-CRED-REJECTED";
904
912
  case "quota_exhausted":
905
913
  case "rate_limit":
906
- return "PRH-PROVIDER-LIMITED";
914
+ return "CRYSK-PROVIDER-LIMITED";
907
915
  case "network_transient":
908
916
  case "remote_abort_unconfirmed":
909
- return "PRH-PROVIDER-UNAVAILABLE";
917
+ return "CRYSK-PROVIDER-UNAVAILABLE";
910
918
  case "safety_refusal":
911
- return "PRH-PROVIDER-REFUSED";
919
+ return "CRYSK-PROVIDER-REFUSED";
912
920
  case "provider_configuration_invalid":
913
921
  case "model_unavailable":
914
- return "PRH-MODEL-UNAVAILABLE";
922
+ return "CRYSK-MODEL-UNAVAILABLE";
915
923
  case "missing_provider_record":
916
- return "PRH-CRED-UNUSABLE";
924
+ return "CRYSK-CRED-UNUSABLE";
917
925
  case "protocol_truncation":
918
926
  case "protocol_mismatch":
919
927
  case "protocol_overflow":
920
928
  case "output_limit_exceeded":
921
929
  case "context_window_exceeded":
922
- return "PRH-ENGINE-DEFECT";
930
+ return "CRYSK-ENGINE-DEFECT";
923
931
  // WHY runtime_unavailable is unclassified, not an engine defect: one cause
924
932
  // covers failures with different owners. OpenCodeSdkTransport raises it
925
933
  // from classifyFailure for a provider refusal the provider marked not
@@ -932,9 +940,9 @@ function transportCode(
932
940
  // this contract exists to prevent.
933
941
  case "runtime_unavailable":
934
942
  case "legacy_terminal":
935
- return "PRH-UNCLASSIFIED";
943
+ return "CRYSK-UNCLASSIFIED";
936
944
  default:
937
- return unmapped(cause, "PRH-UNCLASSIFIED");
945
+ return unmapped(cause, "CRYSK-UNCLASSIFIED");
938
946
  }
939
947
  }
940
948
 
@@ -943,7 +951,7 @@ export function ownerOf(cls: ErrorClass, ctx: OutcomeContext): Owner {
943
951
  case "trigger":
944
952
  switch (cls.check) {
945
953
  case "no-credential":
946
- case "routing-missing":
954
+ case "removed-input":
947
955
  case "pr-unresolved":
948
956
  return "config";
949
957
  default:
@@ -951,7 +959,8 @@ export function ownerOf(cls: ErrorClass, ctx: OutcomeContext): Owner {
951
959
  }
952
960
  case "config-parse":
953
961
  switch (cls.source) {
954
- case "routing":
962
+ case "models-input":
963
+ case "credentials-input":
955
964
  case "repo-config":
956
965
  case "person-config":
957
966
  case "extra-hunters":
@@ -961,7 +970,6 @@ export function ownerOf(cls: ErrorClass, ctx: OutcomeContext): Owner {
961
970
  }
962
971
  case "prompt-set":
963
972
  case "gotchas":
964
- case "route":
965
973
  return "config";
966
974
  case "credential":
967
975
  switch (cls.failureClass) {
@@ -1005,10 +1013,10 @@ export function ownerOf(cls: ErrorClass, ctx: OutcomeContext): Owner {
1005
1013
 
1006
1014
  function githubOwner(cls: GithubClass): Owner {
1007
1015
  switch (githubCode(cls)) {
1008
- case "PRH-TOKEN-PERMISSION":
1009
- case "PRH-GITHUB-TOKEN-INVALID":
1016
+ case "CRYSK-TOKEN-PERMISSION":
1017
+ case "CRYSK-GITHUB-TOKEN-INVALID":
1010
1018
  return "config";
1011
- case "PRH-GITHUB-UNAVAILABLE":
1019
+ case "CRYSK-GITHUB-UNAVAILABLE":
1012
1020
  return "provider";
1013
1021
  default:
1014
1022
  return "unclassified";
@@ -1107,14 +1115,6 @@ const CAPABILITY_PHRASE: Record<CapabilityIssue, string> = {
1107
1115
  version_unsupported: "an unsupported OpenCode version is installed",
1108
1116
  };
1109
1117
 
1110
- const ROUTE_PHRASE: Record<RouteReason, string> = {
1111
- unmapped: "no mapping covers this route",
1112
- ambiguous: "more than one mapping matches this route",
1113
- "spend-disabled": "spend is turned off for this route",
1114
- "multiple-opencode-providers":
1115
- "more than one OpenCode provider is configured",
1116
- };
1117
-
1118
1118
  const TRANSPORT_PHRASE: Record<
1119
1119
  TransportFailureCause | "legacy_terminal",
1120
1120
  string
@@ -1142,46 +1142,125 @@ const DOCS_BASE =
1142
1142
  "https://github.com/cryskai/crysk/blob/v0/docs/github-actions.md#";
1143
1143
 
1144
1144
  const ENGINE_DEFECT_ISSUE =
1145
- 'gh issue create -R cryskai/crysk --title "PRH-ENGINE-DEFECT {detail}" --body "{runUrl}"';
1145
+ 'gh issue create -R cryskai/crysk --title "CRYSK-ENGINE-DEFECT {detail}" --body "{runUrl}"';
1146
1146
  const RERUN_FAILED = "$ gh run rerun {runId} --failed";
1147
1147
  const REVIEW_AGAIN = '$ gh pr comment {pr} --body "/crysk review"';
1148
1148
  // A workflow set up before the rename filters only `/pr-hero`, and the
1149
1149
  // floating action tag still delivers this text to it.
1150
1150
  const LEGACY_REVIEW_NOTE =
1151
1151
  "On a workflow set up before the rename, comment `/pr-hero review` instead.";
1152
- const OPENCODE_STORE =
1153
- "$ gh secret set OPENCODE_AUTH_JSON < ~/.local/share/opencode/auth.json";
1152
+ // The OpenCode secrets (S8): one per provider, <PROVIDER> being the provider id
1153
+ // uppercased with `-` and `.` as `_` (opencodeSecretToken in crysk-secrets.ts,
1154
+ // which this module cannot import: see the builtins-only guard).
1155
+ const OPENCODE_API_KEY_SECRET =
1156
+ "$ gh secret set CRYSK_OPENCODE_<PROVIDER>_API_KEY";
1157
+ const OPENCODE_PROVIDER_TOKEN_NOTE =
1158
+ "<PROVIDER> is the provider id uppercased with `-` and `.` as `_` (`deepseek` is DEEPSEEK).";
1159
+ const OPENAI_OAUTH_SECRET =
1160
+ "$ jq -c .openai ~/.local/share/opencode/auth.json | base64 -w0 | gh secret set CRYSK_OPENCODE_OPENAI_OAUTH";
1154
1161
  const CRED_STORE_WHY =
1155
1162
  "the credential store does not hold what this route needs";
1156
1163
  // missing_subscription_record is raised for a Claude keychain record and for an
1157
1164
  // OpenAI OAuth record alike, so each route's fix names the login it really uses.
1158
1165
  const CLAUDE_SUBSCRIPTION_FIXES = [
1159
- "Log in again with `claude setup-token`, then set `CLAUDE_CODE_OAUTH_TOKEN`:",
1160
- "$ claude setup-token && gh secret set CLAUDE_CODE_OAUTH_TOKEN",
1166
+ "Log in again with `claude setup-token`, then set `CRYSK_CLAUDE_OAUTH_TOKEN`:",
1167
+ "$ claude setup-token && gh secret set CRYSK_CLAUDE_OAUTH_TOKEN",
1161
1168
  ];
1162
1169
  const OPENCODE_SUBSCRIPTION_FIXES = [
1163
- "Provider `openai` expects a ChatGPT login: run `opencode auth login` and choose ChatGPT, then re-set the secret:",
1170
+ "Provider `openai` expects a ChatGPT login: run `opencode auth login` and choose ChatGPT, then set its record, base64 on one line (on macOS, drop -w0):",
1164
1171
  "$ opencode auth login",
1165
- OPENCODE_STORE,
1166
- "Or rename the provider in CRYSK_ROUTING (PRHERO_ROUTING on a workflow set up before the rename).",
1172
+ OPENAI_OAUTH_SECRET,
1173
+ "Or bill per token with an OpenAI API key instead:",
1174
+ "$ gh secret set CRYSK_OPENCODE_OPENAI_API_KEY",
1167
1175
  ];
1168
1176
  // Only the OpenCode route stores a ChatGPT login; any other backend, or none, is
1169
1177
  // the Claude route.
1170
1178
  function isOpencodeRoute(params: ErrorParams): boolean {
1171
1179
  return params.backend?.trim() === "opencode";
1172
1180
  }
1181
+ // A refused `crysk-secrets` input (src/ci/crysk-secrets.ts, U1) records
1182
+ // malformed_payload with a detail that names a CRYSK_* secret or a line of the
1183
+ // input, never a value. Its fix is that secret, not the OpenCode auth store.
1184
+ function isCryskSecretsDetail(params: ErrorParams): boolean {
1185
+ const detail = params.detail?.trim() ?? "";
1186
+ return (
1187
+ detail.startsWith("CRYSK_") ||
1188
+ /^line \d+ of the crysk-secrets input /.test(detail)
1189
+ );
1190
+ }
1191
+ const CRYSK_SECRETS_FIXES = [
1192
+ "Re-set the CRYSK_* secret the message names. An _OAUTH secret is the provider's record from your OpenCode auth file, base64 on one line (on macOS, drop -w0):",
1193
+ OPENAI_OAUTH_SECRET,
1194
+ "Each line of the crysk-secrets input is NAME=value, one CRYSK_* secret per line.",
1195
+ ];
1196
+ // U5: the platform's stub forwards OpenCode API keys through provider slots,
1197
+ // `CRYSK_OPENCODE_<TOKEN>_API_KEY`, the token coming from the dispatch. A slot
1198
+ // that arrived with a key and no token (src/ci/crysk-secrets.ts refuses it) is the
1199
+ // platform's slot list, not the secret: re-setting the secret would fail again.
1200
+ // The text is parseCryskSecrets's, matched here for the same reason as below.
1201
+ const EMPTY_SLOT_DETAIL =
1202
+ "CRYSK_OPENCODE__API_KEY has a value but no provider: an unused OpenCode slot must be empty";
1203
+ // Setup joins one refusal per line with "; ", so several unused slots that
1204
+ // carry a value arrive as that refusal repeated; every part must be it.
1205
+ function isEmptySlotDetail(detail: string): boolean {
1206
+ const parts = detail.trim().split(/; (?=CRYSK_OPENCODE__API_KEY )/);
1207
+ return parts.every((part) => part.trim() === EMPTY_SLOT_DETAIL);
1208
+ }
1209
+ const EMPTY_SLOT_FIXES = [
1210
+ "The Crysk platform passed an OpenCode key through a provider slot with no provider name, so Crysk cannot tell whose key it is. The platform's provider slots for this run are empty while a key was forwarded:",
1211
+ "Open the repository's model settings on the Crysk platform, save the OpenCode provider whose key this is again so its slot names the provider, then re-run the workflow:",
1212
+ "$ gh run rerun {runId}",
1213
+ "In a workflow you wrote yourself, name the provider in the line: CRYSK_OPENCODE_<PROVIDER>_API_KEY, and leave an unused slot as CRYSK_OPENCODE__API_KEY= with nothing after it.",
1214
+ ];
1215
+ // U3: an _OAUTH secret for a provider other than openai is refused, since
1216
+ // only openai's subscription record can be projected. Re-setting it would fail
1217
+ // again, so the fix is that provider's _API_KEY, which the detail names.
1218
+ // The text is chooseOpenCodeSecret's (crysk-secrets.ts), matched here rather
1219
+ // than imported because this module imports no repo module but ../brand (the
1220
+ // builtins-only guard in test/ci/outcome.test.ts). test/ci/publish.test.ts
1221
+ // renders that function's own text, so a change on either side fails it.
1222
+ const UNSUPPORTED_OAUTH_DETAIL_RE =
1223
+ /^CRYSK_OPENCODE_[A-Z0-9_]+_OAUTH is an OpenCode subscription record, which Crysk reads only for openai for now; set (CRYSK_OPENCODE_[A-Z0-9_]+_API_KEY) instead$/;
1224
+ // Setup joins one refusal per provider with "; ". The fix applies only when
1225
+ // every part is such a refusal, and then names each provider's _API_KEY.
1226
+ function unsupportedOAuthApiKeyNames(detail: string): string[] | undefined {
1227
+ const names: string[] = [];
1228
+ for (const part of detail.split(/; (?=CRYSK_OPENCODE_[A-Z0-9_]+_OAUTH )/)) {
1229
+ const name = UNSUPPORTED_OAUTH_DETAIL_RE.exec(part.trim())?.[1];
1230
+ if (name === undefined) return undefined;
1231
+ names.push(name);
1232
+ }
1233
+ return names.length === 0 ? undefined : names;
1234
+ }
1235
+ function cryskSecretsFixes(params: ErrorParams): string[] {
1236
+ if (isEmptySlotDetail(params.detail ?? "")) return [...EMPTY_SLOT_FIXES];
1237
+ const apiKeys = unsupportedOAuthApiKeyNames(params.detail ?? "");
1238
+ if (apiKeys === undefined) return CRYSK_SECRETS_FIXES;
1239
+ return [
1240
+ "Only openai reads an _OAUTH secret for now. Remove that _OAUTH secret from the crysk-secrets input and set this provider's API key instead:",
1241
+ ...apiKeys.map((apiKey) => `$ gh secret set ${apiKey}`),
1242
+ "Each line of the crysk-secrets input is NAME=value, one CRYSK_* secret per line.",
1243
+ ];
1244
+ }
1245
+ function cryskSecretsAnnotationFix(params: ErrorParams): string {
1246
+ if (isEmptySlotDetail(params.detail ?? "")) {
1247
+ return "the Crysk platform forwarded an OpenCode key in a slot with no provider: save that OpenCode provider again in the platform's model settings, then re-run";
1248
+ }
1249
+ return unsupportedOAuthApiKeyNames(params.detail ?? "") === undefined
1250
+ ? "re-set the CRYSK_* secret it names (an _OAUTH secret is base64 -w0 of the provider's OpenCode record)"
1251
+ : "remove that _OAUTH secret from the crysk-secrets input and set the provider's _API_KEY secret instead (only openai reads an _OAUTH secret for now)";
1252
+ }
1173
1253
  const MODEL_NOT_SERVED: CatalogVariant = {
1174
- why: "the routing names a model this provider does not offer",
1254
+ why: "the configured models name a model this provider does not offer",
1175
1255
  fixes: [
1176
- "Fix the `modelSnapshot` for this step in CRYSK_ROUTING (PRHERO_ROUTING on a workflow set up before the rename).",
1256
+ "Set a model this provider serves for this step's role in `models` (on the Crysk platform, the model settings).",
1177
1257
  "List the models this provider serves:",
1178
1258
  "$ opencode models {provider}",
1179
1259
  ],
1180
1260
  annotationFix:
1181
- "fix the `modelSnapshot` for {step} in CRYSK_ROUTING (PRHERO_ROUTING on a workflow set up before the rename) to a model that {provider} serves",
1261
+ "set a model that {provider} serves for {step}'s role in `models` (the Crysk platform's model settings)",
1182
1262
  };
1183
1263
 
1184
- const ROUTE_WHY = "every agent needs exactly one backend, provider and model";
1185
1264
  const PROVIDER_REFUSED_WHY = "the provider's safety system declined this input";
1186
1265
  const UNCLASSIFIED_FIXES = [
1187
1266
  "Re-run the failed jobs:",
@@ -1194,44 +1273,58 @@ const UNCLASSIFIED_FIX =
1194
1273
  // The GitHub Actions expression is spliced in from two literals so the source
1195
1274
  // never holds a `${` pair that reads as a template placeholder here.
1196
1275
  const GITHUB_TOKEN_INPUT = "github-token: $" + "{{ secrets.GITHUB_TOKEN }}";
1197
- // The `with:` line that hands the Claude secret to the action, spliced the same way.
1198
- const CLAUDE_TOKEN_INPUT =
1199
- "claude-token: $" + "{{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}";
1200
- // The `with:` line that hands the OpenCode auth store to the action, spliced the same way.
1201
- const OPENCODE_AUTH_INPUT =
1202
- "opencode-auth: $" + "{{ secrets.OPENCODE_AUTH_JSON }}";
1203
- // The `with:` line for the Claude API key, the alternative to the OAuth token.
1204
- const ANTHROPIC_API_KEY_INPUT =
1205
- "anthropic-api-key: $" + "{{ secrets.ANTHROPIC_API_KEY }}";
1206
- // The fix for a missing credential, by route. A Claude route names only the Claude
1207
- // secrets. An OpenCode route leads with the OpenCode secret, and names the Claude
1208
- // token only as the route it does not use (odd/tasks/agent-first-ci.md, A5).
1276
+ // The fix for a missing credential, by route (S8, U5): the CRYSK_* secrets, passed
1277
+ // in the crysk-secrets input. A Claude route names only the Claude secrets. An
1278
+ // OpenCode route leads with the OpenCode secrets, and names the Claude token only
1279
+ // as the route it does not use (odd/tasks/agent-first-ci.md, A5).
1209
1280
  const CLAUDE_CREDENTIAL_FIXES = [
1210
1281
  "Set one credential for the route you use:",
1211
- "$ claude setup-token && gh secret set CLAUDE_CODE_OAUTH_TOKEN",
1212
- "$ gh secret set ANTHROPIC_API_KEY",
1213
- "$ opencode auth login && gh secret set OPENCODE_AUTH_JSON < ~/.local/share/opencode/auth.json",
1214
- `If the secret is already set, check that the workflow passes it to the action under \`with:\`, for example \`${CLAUDE_TOKEN_INPUT}\` or \`${ANTHROPIC_API_KEY_INPUT}\`: a secret the workflow does not pass never reaches Crysk.`,
1282
+ "$ claude setup-token && gh secret set CRYSK_CLAUDE_OAUTH_TOKEN",
1283
+ "$ gh secret set CRYSK_CLAUDE_API_KEY",
1284
+ `If the secret is already set, check that the workflow passes it to the action in the \`crysk-secrets\` input, one NAME=value line per secret, for example \`${cryskSecretsLine("CRYSK_CLAUDE_OAUTH_TOKEN")}\`: a secret the workflow does not pass never reaches Crysk.`,
1215
1285
  "Dependabot PRs read Dependabot secrets, so set this one too:",
1216
- "$ gh secret set --app dependabot CLAUDE_CODE_OAUTH_TOKEN",
1286
+ "$ gh secret set --app dependabot CRYSK_CLAUDE_OAUTH_TOKEN",
1217
1287
  "Then re-run the workflow:",
1218
1288
  "$ gh run rerun {runId}",
1219
1289
  ] as const;
1220
- // A workflow scaffolded before the rename to Crysk passes only
1221
- // vars.PRHERO_ROUTING to the action, so a fix that names CRYSK_ROUTING alone
1222
- // would send its owner to set a variable nothing reads.
1223
- const LEGACY_ROUTING_NOTE =
1224
- "A workflow set up before the rename reads PRHERO_ROUTING instead: set that one, or run `crysk ci init --force` so the workflow also reads CRYSK_ROUTING.";
1225
1290
  const OPENCODE_CREDENTIAL_FIXES = [
1226
- "Set the OpenCode credential for the route you use:",
1227
- "$ opencode auth login && gh secret set OPENCODE_AUTH_JSON < ~/.local/share/opencode/auth.json",
1228
- `If the secret is already set, check that the workflow passes it to the action under \`with:\`, for example \`${OPENCODE_AUTH_INPUT}\`: a secret the workflow does not pass never reaches Crysk.`,
1229
- "An OpenCode route also needs the routing variable:",
1230
- "$ gh variable set CRYSK_ROUTING --body '<routing-object-json>'",
1231
- LEGACY_ROUTING_NOTE,
1291
+ "Set the OpenCode credential of each provider your models use:",
1292
+ OPENCODE_API_KEY_SECRET,
1293
+ OPENCODE_PROVIDER_TOKEN_NOTE,
1294
+ "For an OpenAI subscription, set its record from your OpenCode auth file, base64 on one line (on macOS, drop -w0):",
1295
+ OPENAI_OAUTH_SECRET,
1296
+ `If the secret is already set, check that the workflow passes it to the action in the \`crysk-secrets\` input, one NAME=value line per secret, for example \`${cryskSecretsLine("CRYSK_OPENCODE_DEEPSEEK_API_KEY")}\`: a secret the workflow does not pass never reaches Crysk.`,
1232
1297
  "Dependabot PRs read Dependabot secrets, so set this one too:",
1233
- "$ gh secret set --app dependabot OPENCODE_AUTH_JSON < ~/.local/share/opencode/auth.json",
1234
- "A Claude route uses `CLAUDE_CODE_OAUTH_TOKEN` instead, from `claude setup-token`.",
1298
+ "$ gh secret set --app dependabot CRYSK_OPENCODE_<PROVIDER>_API_KEY",
1299
+ "A Claude route uses `CRYSK_CLAUDE_OAUTH_TOKEN` instead, from `claude setup-token`.",
1300
+ "Then re-run the workflow:",
1301
+ "$ gh run rerun {runId}",
1302
+ ] as const;
1303
+
1304
+ // The `models` and `credentials` inputs as a workflow writes them (D1), spliced like
1305
+ // the inputs above. The scaffolded workflow (src/ci/setup.ts) writes these lines, so
1306
+ // a fix that quotes them cannot disagree with the file the person has.
1307
+ export const MODELS_INPUT_LINE = "models: $" + "{{ vars.CRYSK_MODELS }}";
1308
+ export const CREDENTIALS_INPUT_LINE =
1309
+ "credentials: $" + "{{ vars.CRYSK_CREDENTIALS }}";
1310
+ // One line of the crysk-secrets input as a workflow writes it, spliced like the
1311
+ // inputs above. `{name}` is not a catalog placeholder here: the caller passes a name.
1312
+ function cryskSecretsLine(name: string): string {
1313
+ return `${name}=$` + `{{ secrets.${name} }}`;
1314
+ }
1315
+ // The old inputs and the CRYSK_* secret or setting that replaces each (U5, S2, S8).
1316
+ // The trigger names only the inputs the workflow passed (the record's detail); the
1317
+ // fix lists every replacement, so it reads the same whichever ones they are.
1318
+ const REMOVED_INPUT_FIXES = [
1319
+ "Set the CRYSK_* secret that replaces each old credential input:",
1320
+ "$ claude setup-token && gh secret set CRYSK_CLAUDE_OAUTH_TOKEN",
1321
+ "$ gh secret set CRYSK_CLAUDE_API_KEY",
1322
+ "$ gh secret set CRYSK_OPENCODE_<PROVIDER>_API_KEY",
1323
+ "claude-token becomes CRYSK_CLAUDE_OAUTH_TOKEN and anthropic-api-key becomes CRYSK_CLAUDE_API_KEY. opencode-auth becomes one CRYSK_OPENCODE_<PROVIDER>_API_KEY per provider your models use, <PROVIDER> being the provider id uppercased with `-` and `.` as `_`. An OpenAI subscription is the provider's record from your OpenCode auth file, base64 on one line (on macOS, drop -w0):",
1324
+ "$ jq -c .openai ~/.local/share/opencode/auth.json | base64 -w0 | gh secret set CRYSK_OPENCODE_OPENAI_OAUTH",
1325
+ `In the workflow, delete the old lines under \`with:\` and pass the secrets in one \`crysk-secrets: |\` block, one NAME=value line per secret, for example \`${cryskSecretsLine("CRYSK_CLAUDE_OAUTH_TOKEN")}\`.`,
1326
+ `The routing input becomes the \`models\` input: set your models per role in the CRYSK_MODELS variable, and pass it as \`${MODELS_INPUT_LINE}\` (a repository connected to the Crysk platform takes them from its model settings instead).`,
1327
+ '$ gh variable set CRYSK_MODELS --body \'{"default": ["claude:sonnet-latest"]}\'',
1235
1328
  "Then re-run the workflow:",
1236
1329
  "$ gh run rerun {runId}",
1237
1330
  ] as const;
@@ -1260,18 +1353,6 @@ const CREDENTIAL_UNUSABLE_ENV: CatalogVariant = {
1260
1353
  annotationFix: "set the {secret} secret with `gh secret set {secret}`",
1261
1354
  };
1262
1355
 
1263
- // Two UnmappedRouteError throw sites (src/model/routing.ts) share this variant: a
1264
- // model with no mapping at all, and a mapping that names no modelSnapshot. "Add or
1265
- // complete" covers both; "add a modelSnapshot" alone was false for the first.
1266
- const ROUTE_UNMAPPED: CatalogVariant = {
1267
- why: ROUTE_WHY,
1268
- fixes: [
1269
- "Add or complete this model's route in CRYSK_ROUTING (PRHERO_ROUTING on a workflow set up before the rename), with an explicit `modelSnapshot`.",
1270
- ],
1271
- annotationFix:
1272
- "add or complete this model's route in CRYSK_ROUTING (PRHERO_ROUTING on a workflow set up before the rename), with an explicit `modelSnapshot`",
1273
- };
1274
-
1275
1356
  const RUNTIME_LOCAL: CatalogVariant = {
1276
1357
  why: "a required tool is missing from your environment",
1277
1358
  fixes: ["Reconcile the crysk install:", "$ crysk upgrade --reconcile"],
@@ -1284,12 +1365,12 @@ const GITHUB_SERVER: CatalogVariant = {
1284
1365
  annotationFix: "re-run the workflow once GitHub is serving requests again",
1285
1366
  };
1286
1367
 
1287
- // WHY no class maps to PRH-STATUS-WRITE-FAILED, PRH-HUNTERS-FAILED or
1288
- // PRH-CANCELLED: each is a condition the caller observes directly (a status
1368
+ // WHY no class maps to CRYSK-STATUS-WRITE-FAILED, CRYSK-HUNTERS-FAILED or
1369
+ // CRYSK-CANCELLED: each is a condition the caller observes directly (a status
1289
1370
  // write, the hunter set, a superseded run), so the caller requests the code
1290
1371
  // through renderCode. The class-to-code table cannot see those conditions.
1291
1372
  export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1292
- "PRH-CRED-MISSING": {
1373
+ "CRYSK-CRED-MISSING": {
1293
1374
  level: "error",
1294
1375
  owner: "config",
1295
1376
  what: "No credential for the {backend} route reached the action",
@@ -1301,11 +1382,21 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1301
1382
  : CLAUDE_CREDENTIAL_FIXES,
1302
1383
  (params) =>
1303
1384
  params.backend?.trim() === "opencode"
1304
- ? "set the OPENCODE_AUTH_JSON secret: `gh secret set OPENCODE_AUTH_JSON < ~/.local/share/opencode/auth.json`"
1305
- : "set a Claude credential: `claude setup-token && gh secret set CLAUDE_CODE_OAUTH_TOKEN`",
1385
+ ? "set the provider's CRYSK_OPENCODE_<PROVIDER>_API_KEY secret (`gh secret set CRYSK_OPENCODE_<PROVIDER>_API_KEY`) and pass it in the crysk-secrets input"
1386
+ : "set a Claude credential (`claude setup-token && gh secret set CRYSK_CLAUDE_OAUTH_TOKEN`) and pass it in the crysk-secrets input",
1306
1387
  ),
1307
1388
  },
1308
- "PRH-CRED-UNUSABLE": {
1389
+ "CRYSK-INPUT-REMOVED": {
1390
+ level: "error",
1391
+ owner: "config",
1392
+ what: "The workflow passes inputs Crysk no longer reads: {detail}",
1393
+ variants: single(
1394
+ "Crysk now takes its credentials only from the CRYSK_* secrets in the crysk-secrets input, and its models only from `models`, so a review would run without the credential or models the workflow names",
1395
+ REMOVED_INPUT_FIXES,
1396
+ "delete the {detail} input lines from the workflow and pass the CRYSK_* secrets in the crysk-secrets input instead (a routing input becomes the models input, from `vars.CRYSK_MODELS`)",
1397
+ ),
1398
+ },
1399
+ "CRYSK-CRED-UNUSABLE": {
1309
1400
  level: "error",
1310
1401
  owner: "config",
1311
1402
  what: "The {backend}/{provider} route for {step} has no usable credential ({detail})",
@@ -1320,12 +1411,12 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1320
1411
  "The {backend}/{provider} route for {step} has no usable credential ({detail})",
1321
1412
  why: CRED_STORE_WHY,
1322
1413
  fixes: [
1323
- "Add {provider} to the OpenCode store, then re-set the secret:",
1324
- "$ opencode auth login",
1325
- OPENCODE_STORE,
1414
+ "Set {provider}'s secret and pass it in the crysk-secrets input:",
1415
+ OPENCODE_API_KEY_SECRET,
1416
+ OPENCODE_PROVIDER_TOKEN_NOTE,
1326
1417
  ],
1327
1418
  annotationFix:
1328
- "add {provider} to the OpenCode store with `opencode auth login`, then set OPENCODE_AUTH_JSON again",
1419
+ "set {provider}'s CRYSK_OPENCODE_<PROVIDER>_API_KEY secret and pass it in the crysk-secrets input",
1329
1420
  },
1330
1421
  missing_subscription_record: {
1331
1422
  why: CRED_STORE_WHY,
@@ -1335,71 +1426,75 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1335
1426
  : CLAUDE_SUBSCRIPTION_FIXES,
1336
1427
  annotationFix: (params) =>
1337
1428
  isOpencodeRoute(params)
1338
- ? "run `opencode auth login` and choose ChatGPT for provider `openai`, then re-set OPENCODE_AUTH_JSON, or rename the provider in CRYSK_ROUTING (PRHERO_ROUTING on a workflow set up before the rename)"
1339
- : "log in again with `claude setup-token` and set `CLAUDE_CODE_OAUTH_TOKEN` (`gh secret set CLAUDE_CODE_OAUTH_TOKEN`)",
1429
+ ? "run `opencode auth login` and choose ChatGPT for provider `openai`, then set CRYSK_OPENCODE_OPENAI_OAUTH from its record, or set CRYSK_OPENCODE_OPENAI_API_KEY to bill per token"
1430
+ : "log in again with `claude setup-token` and set `CRYSK_CLAUDE_OAUTH_TOKEN` (`gh secret set CRYSK_CLAUDE_OAUTH_TOKEN`)",
1340
1431
  },
1341
1432
  malformed_payload: {
1342
1433
  // WHY no route in the sentence: this class is raised for the OpenCode auth
1343
1434
  // store and for a Claude keychain payload alike, and {detail} names which.
1344
1435
  what: "The credential store is not usable: {detail}",
1345
1436
  why: CRED_STORE_WHY,
1346
- fixes: [
1347
- "Check that the store is a JSON object:",
1348
- "$ jq -e 'type==\"object\"' ~/.local/share/opencode/auth.json",
1349
- "Then re-set the secret:",
1350
- OPENCODE_STORE,
1351
- ],
1352
- annotationFix:
1353
- "make the OpenCode auth store a JSON object, then set OPENCODE_AUTH_JSON again",
1437
+ fixes: (params) =>
1438
+ isCryskSecretsDetail(params)
1439
+ ? cryskSecretsFixes(params)
1440
+ : [
1441
+ "Check that the store is a JSON object:",
1442
+ "$ jq -e 'type==\"object\"' ~/.local/share/opencode/auth.json",
1443
+ "In CI the action builds this file from the CRYSK_OPENCODE_* secrets: re-set the one for this provider.",
1444
+ OPENCODE_API_KEY_SECRET,
1445
+ ],
1446
+ annotationFix: (params) =>
1447
+ isCryskSecretsDetail(params)
1448
+ ? cryskSecretsAnnotationFix(params)
1449
+ : "make the OpenCode auth store a JSON object (in CI, re-set the provider's CRYSK_OPENCODE_* secret)",
1354
1450
  },
1355
1451
  source_read_failed: CREDENTIAL_UNUSABLE_ENV,
1356
1452
  "env-absent": CREDENTIAL_UNUSABLE_ENV,
1357
1453
  default: CREDENTIAL_UNUSABLE_ENV,
1358
1454
  },
1359
1455
  },
1360
- "PRH-CRED-REJECTED": {
1456
+ "CRYSK-CRED-REJECTED": {
1361
1457
  level: "error",
1362
1458
  owner: "config",
1363
1459
  what: "provider {provider} rejected the credential in {secret}",
1364
1460
  variants: {
1365
- // The rejected secret is a per-token credential (ANTHROPIC_API_KEY or
1366
- // ANTHROPIC_AUTH_TOKEN): the CLI prefers it to the OAuth token, so
1367
- // setting CLAUDE_CODE_OAUTH_TOKEN alone leaves the next run rejected the same way.
1461
+ // The rejected secret is a per-token credential. Since S5 the run used it because it
1462
+ // was the first present credential in `credentials.claude`, so the way to the
1463
+ // subscription is that order (with the OAuth secret set), never deleting the key.
1464
+ // The alternative names the secret both ways: the old name the workflow passes
1465
+ // today, and its CRYSK_* name (S8).
1368
1466
  api_key: {
1369
- why: "the key is invalid, expired or revoked, and the CLI uses it ahead of CLAUDE_CODE_OAUTH_TOKEN",
1467
+ why: "the key is invalid, expired or revoked, and it is the Claude credential this run chose from credentials.claude",
1370
1468
  fixes: [
1371
- // Prose between the two commands keeps them in separate code blocks: they are
1372
- // alternatives, and one copied block would set the new key and then delete it.
1373
1469
  "Create a new key in the Claude Console and set it:",
1374
1470
  "$ gh secret set {secret}",
1375
- "Or delete the secret so the review uses CLAUDE_CODE_OAUTH_TOKEN (setting CLAUDE_CODE_OAUTH_TOKEN alone changes nothing while {secret} is set):",
1376
- "$ gh secret delete {secret}",
1471
+ "Or run on the subscription: set CRYSK_CLAUDE_OAUTH_TOKEN and put subscription first in `credentials.claude` (the default order).",
1377
1472
  "Then ask for a new review:",
1378
1473
  REVIEW_AGAIN,
1379
1474
  LEGACY_REVIEW_NOTE,
1380
1475
  ],
1381
1476
  annotationFix:
1382
- "create a new key and run `gh secret set {secret}`, or delete the {secret} secret so the OAuth token is used (setting CLAUDE_CODE_OAUTH_TOKEN alone changes nothing while the key is set)",
1477
+ "create a new key and run `gh secret set {secret}`, or set CRYSK_CLAUDE_OAUTH_TOKEN and put subscription first in `credentials.claude` (the default order)",
1383
1478
  },
1384
1479
  oauth: {
1385
1480
  why: "it is expired, revoked, or a short-lived /login session token",
1386
1481
  fixes: [
1387
- "$ claude setup-token && gh secret set CLAUDE_CODE_OAUTH_TOKEN",
1482
+ "$ claude setup-token && gh secret set {secret}",
1388
1483
  "Then ask for a new review:",
1389
1484
  REVIEW_AGAIN,
1390
1485
  LEGACY_REVIEW_NOTE,
1391
1486
  ],
1392
1487
  annotationFix:
1393
- "log in again with `claude setup-token` and set `CLAUDE_CODE_OAUTH_TOKEN` (`gh secret set CLAUDE_CODE_OAUTH_TOKEN`)",
1488
+ "log in again with `claude setup-token` and set `{secret}` (`gh secret set {secret}`)",
1394
1489
  },
1395
1490
  default: {
1396
1491
  why: "it is expired, revoked, or a short-lived /login session token",
1397
1492
  fixes: [
1398
- "$ claude setup-token && gh secret set CLAUDE_CODE_OAUTH_TOKEN",
1493
+ "$ claude setup-token && gh secret set CRYSK_CLAUDE_OAUTH_TOKEN",
1399
1494
  "Or, for an API key, create a new key in the Claude Console and set it:",
1400
- "$ gh secret set ANTHROPIC_API_KEY",
1401
- "Or, for OpenCode, re-export the auth store and re-set the secret:",
1402
- OPENCODE_STORE,
1495
+ "$ gh secret set CRYSK_CLAUDE_API_KEY",
1496
+ "Or, for OpenCode, set the provider's key again:",
1497
+ OPENCODE_API_KEY_SECRET,
1403
1498
  "Then ask for a new review:",
1404
1499
  REVIEW_AGAIN,
1405
1500
  LEGACY_REVIEW_NOTE,
@@ -1409,71 +1504,10 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1409
1504
  },
1410
1505
  },
1411
1506
  },
1412
- "PRH-ROUTING-MISSING": {
1413
- level: "error",
1414
- owner: "config",
1415
- what: "OpenCode auth is set but the routing variable is empty, so the default Claude route is used",
1416
- variants: single(
1417
- "the run would fail later at the Claude credential check",
1418
- [
1419
- '$ gh variable set CRYSK_ROUTING --body "$(jq -c .routing ~/.crysk/config.json)"',
1420
- "On a machine set up before the rename the config is ~/.prhero/config.json: use that path in the command.",
1421
- LEGACY_ROUTING_NOTE,
1422
- ],
1423
- `set CRYSK_ROUTING from your routing config: \`gh variable set CRYSK_ROUTING --body "$(jq -c .routing ~/.crysk/config.json)"\` (~/.prhero/config.json on a machine set up before the rename; PRHERO_ROUTING on a workflow set up before the rename)`,
1424
- ),
1425
- },
1426
- "PRH-ROUTING-INVALID": {
1427
- level: "error",
1428
- owner: "config",
1429
- what: "The routing variable is invalid: {detail}",
1430
- variants: single(
1431
- "Crysk cannot tell which backend and model each agent should use",
1432
- [
1433
- "Edit the JSON, then set it again:",
1434
- '$ gh variable set CRYSK_ROUTING --body "$(jq -c . routing.json)"',
1435
- LEGACY_ROUTING_NOTE,
1436
- ],
1437
- "fix the routing JSON ({detail}), then set it again with `gh variable set CRYSK_ROUTING` (PRHERO_ROUTING on a workflow set up before the rename)",
1438
- ),
1439
- },
1440
- "PRH-ROUTE-UNRESOLVABLE": {
1441
- level: "error",
1442
- owner: "config",
1443
- what: "Model routing for {step} has no usable route: {detail}",
1444
- variants: {
1445
- unmapped: ROUTE_UNMAPPED,
1446
- ambiguous: {
1447
- why: ROUTE_WHY,
1448
- fixes: [
1449
- "Remove the duplicate mapping for this route from CRYSK_ROUTING (PRHERO_ROUTING on a workflow set up before the rename).",
1450
- ],
1451
- annotationFix:
1452
- "remove the duplicate mapping for this route from CRYSK_ROUTING (PRHERO_ROUTING on a workflow set up before the rename)",
1453
- },
1454
- "spend-disabled": {
1455
- why: ROUTE_WHY,
1456
- fixes: [
1457
- "Enable spend for this route in CRYSK_ROUTING (PRHERO_ROUTING on a workflow set up before the rename).",
1458
- ],
1459
- annotationFix:
1460
- "enable spend for this route in CRYSK_ROUTING (PRHERO_ROUTING on a workflow set up before the rename)",
1461
- },
1462
- "multiple-opencode-providers": {
1463
- why: ROUTE_WHY,
1464
- fixes: [
1465
- "Keep one OpenCode provider per review in CRYSK_ROUTING (PRHERO_ROUTING on a workflow set up before the rename).",
1466
- ],
1467
- annotationFix:
1468
- "keep one OpenCode provider per review in CRYSK_ROUTING (PRHERO_ROUTING on a workflow set up before the rename)",
1469
- },
1470
- default: ROUTE_UNMAPPED,
1471
- },
1472
- },
1473
1507
  // WHY provider-owned: the provider refused the model, so the lead reads
1474
1508
  // "Provider <name>:". provider_configuration_invalid shares this code and keeps
1475
1509
  // its own owner (config) through its variant, so its rendering is unchanged.
1476
- "PRH-MODEL-UNAVAILABLE": {
1510
+ "CRYSK-MODEL-UNAVAILABLE": {
1477
1511
  level: "error",
1478
1512
  owner: "provider",
1479
1513
  what: "Provider {provider} does not serve the model configured for {step}",
@@ -1490,7 +1524,7 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1490
1524
  provider_configuration_invalid: { ...MODEL_NOT_SERVED, owner: "config" },
1491
1525
  },
1492
1526
  },
1493
- "PRH-PROMPTSET-INVALID": {
1527
+ "CRYSK-PROMPTSET-INVALID": {
1494
1528
  level: "error",
1495
1529
  owner: "config",
1496
1530
  what: "The prompt set is invalid: {detail}",
@@ -1503,7 +1537,7 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1503
1537
  "fix the agent file or `agents_dir` ({detail}), then check it with `crysk review --pr {pr} --dry-run`",
1504
1538
  ),
1505
1539
  },
1506
- "PRH-GOTCHAS-MISSING": {
1540
+ "CRYSK-GOTCHAS-MISSING": {
1507
1541
  level: "error",
1508
1542
  owner: "config",
1509
1543
  what: "the review instructions file (REVIEW.md or .crysk/gotchas.md) is empty or still the scaffold",
@@ -1515,17 +1549,48 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1515
1549
  "write real rules into REVIEW.md or .crysk/gotchas.md (remove the scaffold marker line if present) and commit it to the base branch, or delete the file",
1516
1550
  ),
1517
1551
  },
1518
- "PRH-CONFIG-INVALID": {
1552
+ "CRYSK-CONFIG-INVALID": {
1519
1553
  level: "error",
1520
1554
  owner: "config",
1521
1555
  what: ".crysk/config.json is invalid: {detail}",
1522
- variants: single(
1523
- "Crysk refuses to guess repository settings",
1524
- ["Fix the file, then check it:", "$ crysk review --pr {pr} --dry-run"],
1525
- "fix `.crysk/config.json` ({detail}), then check it with `crysk review --pr {pr} --dry-run`",
1526
- ),
1556
+ variants: {
1557
+ ...single(
1558
+ "Crysk refuses to guess repository settings",
1559
+ ["Fix the file, then check it:", "$ crysk review --pr {pr} --dry-run"],
1560
+ "fix `.crysk/config.json` ({detail}), then check it with `crysk review --pr {pr} --dry-run`",
1561
+ ),
1562
+ // The setup step's reading of the `models` input, which the workflow fills from
1563
+ // vars.CRYSK_MODELS (D1). The detail names the input, never its content.
1564
+ "models-input": {
1565
+ what: "The models input is invalid: {detail}",
1566
+ why: "Crysk refuses to guess which model each role should use",
1567
+ fixes: [
1568
+ "Fix the models per role, a JSON object from role to model list, and set the variable again:",
1569
+ '$ gh variable set CRYSK_MODELS --body "$(jq -c . models.json)"',
1570
+ `The workflow passes it as \`${MODELS_INPUT_LINE}\`.`,
1571
+ "Then re-run the workflow:",
1572
+ "$ gh run rerun {runId}",
1573
+ ],
1574
+ annotationFix:
1575
+ "fix the models JSON ({detail}) and set it again with `gh variable set CRYSK_MODELS`, the variable the workflow passes as `vars.CRYSK_MODELS`",
1576
+ },
1577
+ // The `credentials` input, beside it, from vars.CRYSK_CREDENTIALS (D1).
1578
+ "credentials-input": {
1579
+ what: "The credentials input is invalid: {detail}",
1580
+ why: "Crysk refuses to guess which Claude credential to use",
1581
+ fixes: [
1582
+ 'Fix the Claude credential order, a JSON object such as {"claude": ["subscription", "api_key"]}, and set the variable again:',
1583
+ '$ gh variable set CRYSK_CREDENTIALS --body "$(jq -c . credentials.json)"',
1584
+ `The workflow passes it as \`${CREDENTIALS_INPUT_LINE}\`.`,
1585
+ "Then re-run the workflow:",
1586
+ "$ gh run rerun {runId}",
1587
+ ],
1588
+ annotationFix:
1589
+ "fix the credentials JSON ({detail}) and set it again with `gh variable set CRYSK_CREDENTIALS`, the variable the workflow passes as `vars.CRYSK_CREDENTIALS`",
1590
+ },
1591
+ },
1527
1592
  },
1528
- "PRH-TOKEN-PERMISSION": {
1593
+ "CRYSK-TOKEN-PERMISSION": {
1529
1594
  level: "error",
1530
1595
  owner: "config",
1531
1596
  what: "The workflow token lacks `{scope}: write`",
@@ -1551,7 +1616,7 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1551
1616
  },
1552
1617
  },
1553
1618
  },
1554
- "PRH-GITHUB-TOKEN-INVALID": {
1619
+ "CRYSK-GITHUB-TOKEN-INVALID": {
1555
1620
  level: "error",
1556
1621
  owner: "config",
1557
1622
  what: "The github-token input is invalid",
@@ -1561,7 +1626,7 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1561
1626
  `set \`${GITHUB_TOKEN_INPUT}\` on the action step`,
1562
1627
  ),
1563
1628
  },
1564
- "PRH-GITHUB-UNAVAILABLE": {
1629
+ "CRYSK-GITHUB-UNAVAILABLE": {
1565
1630
  level: "error",
1566
1631
  owner: "provider",
1567
1632
  providerName: "GitHub",
@@ -1581,7 +1646,7 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1581
1646
  default: GITHUB_SERVER,
1582
1647
  },
1583
1648
  },
1584
- "PRH-PR-UNRESOLVED": {
1649
+ "CRYSK-PR-UNRESOLVED": {
1585
1650
  level: "error",
1586
1651
  owner: "config",
1587
1652
  what: "Crysk could not determine the pull request number or head",
@@ -1603,7 +1668,7 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1603
1668
  },
1604
1669
  },
1605
1670
  },
1606
- "PRH-STATUS-WRITE-FAILED": {
1671
+ "CRYSK-STATUS-WRITE-FAILED": {
1607
1672
  level: "error",
1608
1673
  owner: "unclassified",
1609
1674
  providerName: "GitHub",
@@ -1637,7 +1702,7 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1637
1702
  },
1638
1703
  },
1639
1704
  },
1640
- "PRH-RUNTIME-UNAVAILABLE": {
1705
+ "CRYSK-RUNTIME-UNAVAILABLE": {
1641
1706
  level: "error",
1642
1707
  owner: { action: "pr-hero", local: "config" },
1643
1708
  what: "a runtime Crysk depends on is unusable: {detail}",
@@ -1646,7 +1711,7 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1646
1711
  why: "the action installs this runtime itself, so this is a Crysk defect",
1647
1712
  fixes: [
1648
1713
  "Report it with this run:",
1649
- '$ gh issue create -R cryskai/crysk --title "PRH-RUNTIME-UNAVAILABLE" --body "{runUrl}"',
1714
+ '$ gh issue create -R cryskai/crysk --title "CRYSK-RUNTIME-UNAVAILABLE" --body "{runUrl}"',
1650
1715
  ],
1651
1716
  annotationFix: "report it at cryskai/crysk with this run's URL",
1652
1717
  },
@@ -1654,7 +1719,7 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1654
1719
  default: RUNTIME_LOCAL,
1655
1720
  },
1656
1721
  },
1657
- "PRH-INSTALL-FAILED": {
1722
+ "CRYSK-INSTALL-FAILED": {
1658
1723
  level: "error",
1659
1724
  owner: "unclassified",
1660
1725
  what: "The {step} step failed",
@@ -1669,7 +1734,7 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1669
1734
  "re-run only the failed jobs with `gh run rerun {runId} --failed`",
1670
1735
  ),
1671
1736
  },
1672
- "PRH-PROVIDER-LIMITED": {
1737
+ "CRYSK-PROVIDER-LIMITED": {
1673
1738
  level: "error",
1674
1739
  owner: "provider",
1675
1740
  what: "rate limit or quota reached",
@@ -1684,40 +1749,39 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1684
1749
  ...PROVIDER_LIMITED,
1685
1750
  what: "{detail} (rate limit or quota reached)",
1686
1751
  },
1687
- // The credit balance or spend limit of the account behind ANTHROPIC_API_KEY (the CLI
1688
- // prefers that key over the subscription token, so it is the credential in use).
1689
- // Waiting does not help: the fix is to top up, or to stop using the key.
1752
+ // The credit balance or spend limit of the account behind ANTHROPIC_API_KEY (the
1753
+ // credential this run chose from credentials.claude, S5). Waiting does not help:
1754
+ // the fix is to top up, or to move the run to the subscription through that order.
1690
1755
  api_key: {
1691
- what: "{detail}: the Anthropic account behind ANTHROPIC_API_KEY has no credit left or reached its spend limit",
1756
+ what: "{detail}: the Anthropic account behind the API key has no credit left or reached its spend limit",
1692
1757
  why: "the provider refuses every request until the account has credit again, so a retry would fail the same way",
1693
1758
  fixes: [
1694
- "Add credit to the Anthropic account behind ANTHROPIC_API_KEY (Claude Console → Plans & Billing), or delete the secret so the review uses CLAUDE_CODE_OAUTH_TOKEN:",
1695
- "$ gh secret delete ANTHROPIC_API_KEY",
1759
+ "Add credit to the Anthropic account behind the API key (Claude Console → Plans & Billing), or run on the subscription: set CRYSK_CLAUDE_OAUTH_TOKEN and put subscription first in `credentials.claude` (the default order).",
1696
1760
  "Then ask for a new review:",
1697
1761
  REVIEW_AGAIN,
1698
1762
  LEGACY_REVIEW_NOTE,
1699
1763
  ],
1700
1764
  annotationFix:
1701
- "add credit to the Anthropic account behind ANTHROPIC_API_KEY (Claude Console → Plans & Billing), or delete the ANTHROPIC_API_KEY secret so the review uses CLAUDE_CODE_OAUTH_TOKEN",
1765
+ "add credit to the Anthropic account behind the API key (Claude Console → Plans & Billing), or set CRYSK_CLAUDE_OAUTH_TOKEN and put subscription first in `credentials.claude` (the default order)",
1702
1766
  },
1703
1767
  // The Claude subscription behind CLAUDE_CODE_OAUTH_TOKEN reached a usage window. The
1704
1768
  // provider's own sentence carries the reset time, so the what quotes it.
1705
1769
  subscription: {
1706
- what: "{detail}: the Claude subscription behind CLAUDE_CODE_OAUTH_TOKEN reached its usage limit",
1770
+ what: "{detail}: the Claude subscription reached its usage limit",
1707
1771
  why: "the subscription refuses requests until its usage window resets, so an immediate retry would fail the same way",
1708
1772
  fixes: [
1709
1773
  "Re-run after the limit resets (the reset time is in the sentence above):",
1710
1774
  REVIEW_AGAIN,
1711
1775
  LEGACY_REVIEW_NOTE,
1712
- "Or set ANTHROPIC_API_KEY to bill per token:",
1713
- "$ gh secret set ANTHROPIC_API_KEY",
1776
+ "Or bill per token: set CRYSK_CLAUDE_API_KEY and put api_key first in `credentials.claude` (the default order uses the subscription while it is set):",
1777
+ "$ gh secret set CRYSK_CLAUDE_API_KEY",
1714
1778
  ],
1715
1779
  annotationFix:
1716
- "re-run after the limit resets, or set ANTHROPIC_API_KEY to bill per token",
1780
+ "re-run after the limit resets, or set CRYSK_CLAUDE_API_KEY and put api_key first in `credentials.claude` to bill per token",
1717
1781
  },
1718
1782
  },
1719
1783
  },
1720
- "PRH-PROVIDER-UNAVAILABLE": {
1784
+ "CRYSK-PROVIDER-UNAVAILABLE": {
1721
1785
  level: "error",
1722
1786
  owner: "provider",
1723
1787
  what: "unreachable",
@@ -1727,7 +1791,7 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1727
1791
  "re-run the workflow with `gh run rerun {runId}`",
1728
1792
  ),
1729
1793
  },
1730
- "PRH-PROVIDER-REFUSED": {
1794
+ "CRYSK-PROVIDER-REFUSED": {
1731
1795
  level: "error",
1732
1796
  owner: "provider",
1733
1797
  what: "the request was refused",
@@ -1742,7 +1806,7 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1742
1806
  "ask for a new review once, and report it if the provider refuses again",
1743
1807
  ),
1744
1808
  },
1745
- "PRH-ENGINE-DEFECT": {
1809
+ "CRYSK-ENGINE-DEFECT": {
1746
1810
  level: "error",
1747
1811
  owner: "pr-hero",
1748
1812
  what: "Crysk hit an internal error ({detail}) in {step}",
@@ -1752,7 +1816,7 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1752
1816
  "report it at cryskai/crysk with this run's URL",
1753
1817
  ),
1754
1818
  },
1755
- "PRH-HUNTERS-FAILED": {
1819
+ "CRYSK-HUNTERS-FAILED": {
1756
1820
  level: "error",
1757
1821
  owner: "unclassified",
1758
1822
  // WHY a lead of its own: the caller requests this code for a condition it
@@ -1784,7 +1848,7 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1784
1848
  },
1785
1849
  },
1786
1850
  },
1787
- "PRH-UNCLASSIFIED": {
1851
+ "CRYSK-UNCLASSIFIED": {
1788
1852
  level: "error",
1789
1853
  owner: "unclassified",
1790
1854
  what: "Crysk stopped at {step} and could not tell why",
@@ -1802,11 +1866,11 @@ export const ERROR_CATALOG: Readonly<Record<ErrorCode, CatalogEntry>> = {
1802
1866
  },
1803
1867
  },
1804
1868
  },
1805
- "PRH-CANCELLED": {
1869
+ "CRYSK-CANCELLED": {
1806
1870
  level: "notice",
1807
1871
  owner: "unclassified",
1808
1872
  lead: "Not reviewed:",
1809
- headline: "PRH-CANCELLED: not reviewed",
1873
+ headline: "CRYSK-CANCELLED: not reviewed",
1810
1874
  what: "The review was cancelled or superseded by a newer push",
1811
1875
  variants: single(
1812
1876
  "a newer run replaces this one, so this result would describe an outdated head",
@@ -1839,7 +1903,7 @@ export function renderError(
1839
1903
  // have (the secret, the backend, the step) and would ship a placeholder to the PR. A cause
1840
1904
  // is rendered only when its message is complete with the params the path has: provider,
1841
1905
  // model, pr, runId, runUrl, step and detail. Every other cause, or a missing param, keeps the
1842
- // caller's generic PRH-HUNTERS-FAILED.
1906
+ // caller's generic CRYSK-HUNTERS-FAILED.
1843
1907
  export function renderHunterCause(
1844
1908
  cause: TransportFailureCause,
1845
1909
  params: ErrorParams,
@@ -1858,8 +1922,8 @@ export function renderHunterCause(
1858
1922
  return undefined;
1859
1923
  }
1860
1924
  return renderCode(
1861
- "PRH-CRED-REJECTED",
1862
- { ...params, secret: shared.credential },
1925
+ "CRYSK-CRED-REJECTED",
1926
+ { ...params, secret: secretNameOf(shared.credential, ctx) },
1863
1927
  ctx,
1864
1928
  );
1865
1929
  }
@@ -1869,7 +1933,7 @@ export function renderHunterCause(
1869
1933
  // stands.
1870
1934
  if (cause === "quota_exhausted") {
1871
1935
  if (shared.detail === undefined) {
1872
- return renderCode("PRH-PROVIDER-LIMITED", params, ctx);
1936
+ return renderCode("CRYSK-PROVIDER-LIMITED", params, ctx);
1873
1937
  }
1874
1938
  const quoted = { ...params, detail: shared.detail };
1875
1939
  const variant =
@@ -1878,13 +1942,13 @@ export function renderHunterCause(
1878
1942
  : shared.credential === "CLAUDE_CODE_OAUTH_TOKEN"
1879
1943
  ? "subscription"
1880
1944
  : "every_hunter";
1881
- return renderCode("PRH-PROVIDER-LIMITED", quoted, ctx, variant);
1945
+ return renderCode("CRYSK-PROVIDER-LIMITED", quoted, ctx, variant);
1882
1946
  }
1883
1947
  // The provider's 404 names the model, so the every_hunter wording keeps it. Its fixes name
1884
1948
  // the provider, so the provider must be known; the model is optional (whatWithoutModel).
1885
1949
  if (cause === "model_unavailable") {
1886
1950
  if (isBlank(params.provider)) return undefined;
1887
- return renderCode("PRH-MODEL-UNAVAILABLE", params, ctx, "every_hunter");
1951
+ return renderCode("CRYSK-MODEL-UNAVAILABLE", params, ctx, "every_hunter");
1888
1952
  }
1889
1953
  // The credential sentence and its fixes name both the route's provider and model.
1890
1954
  if (cause === "missing_provider_record") {
@@ -1894,6 +1958,25 @@ export function renderHunterCause(
1894
1958
  return undefined;
1895
1959
  }
1896
1960
 
1961
+ // The secret a rejected credential came from, as the reader sets it. A hunter
1962
+ // records the Claude CLI's own variable (FailureCredential); in the action that
1963
+ // variable was filled from the CRYSK_* secret the workflow passes in the
1964
+ // crysk-secrets input (S8, U5), so `gh secret set` must name that secret. A local
1965
+ // run exports the CLI's variable itself, so it keeps that name.
1966
+ const CRYSK_SECRET_OF_CREDENTIAL: Readonly<
1967
+ Partial<Record<FailureCredential, string>>
1968
+ > = {
1969
+ ANTHROPIC_API_KEY: "CRYSK_CLAUDE_API_KEY",
1970
+ CLAUDE_CODE_OAUTH_TOKEN: "CRYSK_CLAUDE_OAUTH_TOKEN",
1971
+ };
1972
+ function secretNameOf(
1973
+ credential: FailureCredential,
1974
+ ctx: OutcomeContext,
1975
+ ): string {
1976
+ if (ctx !== "action") return credential;
1977
+ return CRYSK_SECRET_OF_CREDENTIAL[credential] ?? credential;
1978
+ }
1979
+
1897
1980
  // For a code the caller requests directly. `variant` picks the sub-class, which
1898
1981
  // fixes the owner, the wording and the fix; renderError supplies it for classes.
1899
1982
  export function renderCode(
@@ -1956,25 +2039,31 @@ function paramVariant(
1956
2039
  params: ErrorParams,
1957
2040
  variant: string | undefined,
1958
2041
  ): string | undefined {
1959
- if (code === "PRH-TOKEN-PERMISSION" && isBlank(params.scope)) {
2042
+ if (code === "CRYSK-TOKEN-PERMISSION" && isBlank(params.scope)) {
1960
2043
  return "no-scope";
1961
2044
  }
1962
2045
  // The credential in the secret picks the fix: a rejected API key and a rejected OAuth
1963
- // token are replaced differently, and the CLI uses the key ahead of the token.
1964
- if (code === "PRH-CRED-REJECTED" && variant === undefined) {
2046
+ // token are replaced differently.
2047
+ if (code === "CRYSK-CRED-REJECTED" && variant === undefined) {
1965
2048
  if (
1966
2049
  params.secret === "ANTHROPIC_API_KEY" ||
1967
- params.secret === "ANTHROPIC_AUTH_TOKEN"
2050
+ params.secret === "ANTHROPIC_AUTH_TOKEN" ||
2051
+ params.secret === "CRYSK_CLAUDE_API_KEY"
1968
2052
  ) {
1969
2053
  return "api_key";
1970
2054
  }
1971
- if (params.secret === "CLAUDE_CODE_OAUTH_TOKEN") return "oauth";
2055
+ if (
2056
+ params.secret === "CLAUDE_CODE_OAUTH_TOKEN" ||
2057
+ params.secret === "CRYSK_CLAUDE_OAUTH_TOKEN"
2058
+ ) {
2059
+ return "oauth";
2060
+ }
1972
2061
  }
1973
2062
  // A caller that names a variant keeps it, so the default wording stays
1974
2063
  // reachable with a detail present.
1975
2064
  if (
1976
2065
  variant === undefined &&
1977
- code === "PRH-PR-UNRESOLVED" &&
2066
+ code === "CRYSK-PR-UNRESOLVED" &&
1978
2067
  !isBlank(params.detail)
1979
2068
  ) {
1980
2069
  return "malformed-input";
@@ -2003,12 +2092,14 @@ function variantOf(cls: ErrorClass): string | undefined {
2003
2092
  switch (cls.kind) {
2004
2093
  case "credential":
2005
2094
  return cls.failureClass;
2006
- case "route":
2007
- return cls.reason;
2095
+ // Only the models and credentials inputs have a variant of their own
2096
+ // (CRYSK-CONFIG-INVALID); the other sources find none and render their code's default.
2097
+ case "config-parse":
2098
+ return cls.source;
2008
2099
  case "github":
2009
2100
  return githubVariant(cls);
2010
2101
  // The transport cause picks its own sub-class where the code shares one:
2011
- // PRH-MODEL-UNAVAILABLE serves provider_configuration_invalid (config) and
2102
+ // CRYSK-MODEL-UNAVAILABLE serves provider_configuration_invalid (config) and
2012
2103
  // model_unavailable (provider). Other codes have no such variant and fall
2013
2104
  // back to their default.
2014
2105
  case "transport":
@@ -2025,7 +2116,7 @@ function githubVariant(cls: GithubClass): string | undefined {
2025
2116
  return "rate_limit";
2026
2117
  }
2027
2118
  if (cls.status >= 500) return "server";
2028
- return githubCode(cls) === "PRH-UNCLASSIFIED" ? "github" : undefined;
2119
+ return githubCode(cls) === "CRYSK-UNCLASSIFIED" ? "github" : undefined;
2029
2120
  }
2030
2121
 
2031
2122
  function classDetail(cls: ErrorClass): string | undefined {
@@ -2036,8 +2127,6 @@ function classDetail(cls: ErrorClass): string | undefined {
2036
2127
  return CREDENTIAL_PHRASE[cls.failureClass];
2037
2128
  case "transport":
2038
2129
  return TRANSPORT_PHRASE[cls.cause];
2039
- case "route":
2040
- return ROUTE_PHRASE[cls.reason];
2041
2130
  case "github":
2042
2131
  return String(cls.status);
2043
2132
  default:
@@ -2167,15 +2256,17 @@ function escapeCommandData(text: string): string {
2167
2256
  // keeps a lookalike marker from matching.
2168
2257
  export const OUTCOME_MARKER_PREFIX = `${MARKER_OPEN}outcome `;
2169
2258
 
2170
- // The PRH-* code an outcome comment names, or null. renderError's summary opens with
2259
+ // The CRYSK-* code an outcome comment names, or null. renderError's summary opens with
2171
2260
  // `### <headline>`, and a headline is the bare code or the code then a colon and a sentence
2172
- // (`PRH-CANCELLED: not reviewed`), so the code is the token at the start of that heading. The
2261
+ // (`CRYSK-CANCELLED: not reviewed`), so the code is the token at the start of that heading. The
2173
2262
  // token must be a catalogued code: a heading that merely looks like one reads as no code.
2263
+ // WHY PRH-* too: the codes were PRH-* before the rename, and comments already posted keep
2264
+ // them. An old code reads as the CRYSK-* code it became; a code removed since reads as none.
2174
2265
  export function parseOutcomeCode(body: string): ErrorCode | null {
2175
2266
  if (matchMarkerPrefix(body, OUTCOME_MARKER_PREFIX) === undefined) return null;
2176
- const heading = /^### (PRH-[A-Z0-9-]+)(?=[:\s]|$)/m.exec(body);
2177
- const code = heading?.[1];
2178
- if (code === undefined) return null;
2267
+ const heading = /^### (?:CRYSK|PRH)-([A-Z0-9-]+)(?=[:\s]|$)/m.exec(body);
2268
+ if (heading === null) return null;
2269
+ const code = `CRYSK-${heading[1]}`;
2179
2270
  return (ERROR_CODES as readonly string[]).includes(code)
2180
2271
  ? (code as ErrorCode)
2181
2272
  : null;