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.
- package/README.md +26 -17
- package/config/models/anthropic.json +1 -1
- package/dist/SKILL-dsnffnfp.md +140 -0
- package/dist/SKILL-gnrbph72.md +140 -0
- package/dist/SKILL-k4k0zn1w.md +143 -0
- package/dist/SKILL-kq0xejn3.md +553 -0
- package/dist/SKILL-qaqsbygw.md +66 -0
- package/dist/SKILL-vhb4c3vv.md +553 -0
- package/dist/SKILL-vws0aqb8.md +553 -0
- package/dist/SKILL-xpf6kmdw.md +74 -0
- package/dist/ci-admission-0ken6ehx.md +128 -0
- package/dist/ci-admission-t0f5qwth.md +128 -0
- package/dist/cli.js +3366 -1680
- package/dist/index.js +1884 -947
- package/dist/opencode-ci-ac5zksdn.md +106 -0
- package/dist/workflow-4pkyck01.yml +160 -0
- package/package.json +2 -2
- package/prompts/default/PROVENANCE.md +1 -0
- package/skills/crysk/SKILL.md +16 -16
- package/skills/crysk-ci-setup/SKILL.md +42 -39
- package/skills/crysk-ci-setup/assets/workflow.yml +31 -22
- package/skills/crysk-ci-setup/references/ci-admission.md +2 -2
- package/skills/crysk-ci-setup/references/opencode-ci.md +53 -88
- package/skills/crysk-loop/SKILL.md +20 -9
- package/skills/crysk-pr/SKILL.md +1 -1
- package/src/asset-manifest.ts +0 -4
- package/src/assets.ts +2 -2
- package/src/ci/admission-ledger.ts +4 -0
- package/src/ci/classify-error.ts +21 -24
- package/src/ci/cli-record.ts +53 -1
- package/src/ci/crysk-secrets.ts +409 -0
- package/src/ci/gates.ts +31 -42
- package/src/ci/outcome.ts +421 -330
- package/src/ci/platform-config.ts +127 -0
- package/src/ci/platform-report.ts +935 -0
- package/src/ci/platform-trace.ts +551 -0
- package/src/ci/platform.ts +465 -0
- package/src/ci/publish.ts +19 -6
- package/src/ci/reporter.ts +9 -7
- package/src/ci/review-admission.ts +8 -4
- package/src/ci/review-levels.ts +8 -7
- package/src/ci/run.ts +88 -0
- package/src/ci/setup.ts +547 -109
- package/src/ci/trace-bundle.ts +1282 -0
- package/src/ci/trace-transcripts.ts +415 -0
- package/src/ci/trigger.ts +176 -33
- package/src/cli.ts +11 -3
- package/src/commands/ci-setup-questions.ts +3 -3
- package/src/commands/ci-setup.ts +152 -6
- package/src/commands/config.ts +3 -0
- package/src/commands/doctor.ts +15 -6
- package/src/compare/loop.ts +9 -1
- package/src/compare/martian-adapter.ts +1 -1
- package/src/config/config.ts +16 -3
- package/src/diversity/clustering.ts +0 -1
- package/src/diversity/identity.ts +4 -5
- package/src/diversity/pipeline-integration.ts +1 -9
- package/src/doctor.ts +3 -3
- package/src/execution/attempt-evidence.ts +10 -5
- package/src/execution/claude-session-trace.ts +480 -0
- package/src/execution/contracts.ts +21 -4
- package/src/execution/harness.ts +105 -8
- package/src/execution/model-fallback.ts +239 -0
- package/src/execution/usage-normalized.ts +6 -4
- package/src/home-preflight.ts +1 -1
- package/src/index.ts +1 -1
- package/src/model/catalog.ts +13 -37
- package/src/model/free-discovery.ts +117 -8
- package/src/model/model-name.ts +404 -0
- package/src/model/provider-capabilities.ts +22 -7
- package/src/model/routing.ts +346 -467
- package/src/pr/admission.ts +71 -11
- package/src/pr/ci-admission-gate.ts +2 -1
- package/src/pr/finding-state-record.ts +58 -0
- package/src/pr/gate-record.ts +22 -0
- package/src/pr/inline.ts +3 -0
- package/src/pr/plan.ts +20 -4
- package/src/pr/posting.ts +4 -0
- package/src/pr/pr-status.ts +27 -7
- package/src/pr/pr.ts +39 -8
- package/src/pr/preflight.ts +44 -2
- package/src/pr/publish-outcome.ts +11 -3
- package/src/pr/review-pr.ts +20 -4
- package/src/pr/target.ts +12 -3
- package/src/production-runtime.ts +760 -331
- package/src/rereview/classify.ts +4 -0
- package/src/rereview/prepare.ts +47 -22
- package/src/rereview/state.ts +34 -8
- package/src/review/pipeline.ts +277 -101
- package/src/review/preflight.ts +201 -294
- package/src/review/report.ts +60 -40
- package/src/review/review.ts +20 -3
- package/src/review/route-preflight.ts +79 -11
- package/src/review/run.ts +28 -6
- package/src/review/scout.ts +1 -1
- package/src/review/spec.ts +3 -3
- package/src/review/step-runner.ts +70 -1
- package/src/runner-authority.ts +127 -9
- package/src/security/binding-policy.ts +1 -2
- package/src/security/claude-credential.ts +355 -0
- package/src/security/credential-broker.ts +56 -40
- package/src/security/evidence-redaction.ts +179 -4
- package/src/security/opencode-secret-manifest.ts +114 -0
- package/src/security/published-text.ts +161 -0
- package/src/security/redact.ts +45 -0
- package/src/system-tools.ts +48 -21
- package/src/transport-registry.ts +12 -2
- package/src/transports/claude-code-cli.ts +21 -2
- package/src/transports/opencode-sdk.ts +11 -9
- package/src/transports/opencode-server.ts +7 -10
- package/src/triage/triage.ts +2 -1
- package/src/ui/config-edit.ts +9 -20
- package/src/ui/config.ts +32 -27
- package/src/ui/plan.ts +76 -47
- package/src/updater.ts +10 -7
- package/prompts/default/deep-review-lifecycle.md +0 -362
|
@@ -75,15 +75,21 @@ attempt budget used up, `/crysk stop`, `once_per_pr`, a low-risk or below-thresh
|
|
|
75
75
|
`fixes unverified`, on the next push when every blocking finding's newest reply, from your
|
|
76
76
|
write-access account, is `applied` at the head it was posted on or a `dismissed` the adjudicator
|
|
77
77
|
upheld. Nobody verifies those fixes, so `applied` must mean you fixed it and ran the tests. The
|
|
78
|
-
gate reads the replies when the push arrives: **reply first, then push.**
|
|
78
|
+
gate reads the replies when the push arrives: **reply first, then push.** The exception: under the
|
|
79
|
+
attempt budget used up or `manual_only`, no later push is reviewed on its own, so where the gate
|
|
80
|
+
would turn green it holds the head `pending` instead ("crysk: waiting for a manual review"), and
|
|
81
|
+
a maintainer decides between `/crysk review` and `/crysk override`.
|
|
79
82
|
|
|
80
83
|
**`/crysk override` is a maintainer's, and only for what answers cannot unlock.** Never post it,
|
|
81
|
-
and never ask for it because the review budget ran out
|
|
82
|
-
|
|
84
|
+
and never ask for it because the review budget ran out, except to answer a manual-review hold. Ask
|
|
85
|
+
a maintainer for it only when:
|
|
86
|
+
- the CI review itself is broken (every hunter failing, credit or credentials, `CRYSK-HUNTERS-FAILED`):
|
|
83
87
|
stop the loop and report what is failing, never route around it;
|
|
84
88
|
- a `deferred` or `misclassified` finding should merge unfixed: it names a real defect, so
|
|
85
89
|
accepting it is the maintainer's call;
|
|
86
|
-
- a partial review keeps failing on the same hunters and their route cannot be fixed
|
|
90
|
+
- a partial review keeps failing on the same hunters and their route cannot be fixed;
|
|
91
|
+
- the gate holds the head for a manual review (budget used up or `manual_only`) and the
|
|
92
|
+
unreviewed delta does not justify another paid review: the maintainer picks review or override.
|
|
87
93
|
|
|
88
94
|
`deferred` and `misclassified` never leave the gate count, whatever any adjudicator says: they are
|
|
89
95
|
for findings that are real (or real at another severity), so the gate stays red until a fix or a
|
|
@@ -113,7 +119,7 @@ Later review passes hunt only the push delta. Once the real defects from pass 1
|
|
|
113
119
|
1. **Never patch code to appease a contrived or over-severitied finding.**
|
|
114
120
|
- If the claimed bug requires an impossible precondition, contradicts an intentional invariant, or is already guarded: tag it `dismissed` with cited code and use `/crysk recheck` so the CI adjudicator clears it **without** a code change or a new push.
|
|
115
121
|
- If the observation is technically true but trivial, stylistic, pre-existing, or inflated to blocking: tag it `misclassified` or `deferred`. Never rewrite working code just to avoid asking for `/crysk override`.
|
|
116
|
-
2. **Do not auto-force past `ci_max_attempts` on routine fix-ups.** The repository's `ci_max_attempts` (default `2`) exists specifically to stop diminishing-returns re-reviews, and the PR gets an "automatic reviews are done" comment when it runs out.
|
|
122
|
+
2. **Do not auto-force past `ci_max_attempts` on routine fix-ups.** The repository's `ci_max_attempts` (default `2`) exists specifically to stop diminishing-returns re-reviews, and the PR gets an "automatic reviews are done" comment when it runs out. A red then still carries: answer every blocking finding (`applied` with the fix in the tree, or `dismissed` + `/crysk recheck`) **before** you push. Where the gate would turn green, it holds the head `pending` for a manual review instead, and `crysk status` answers `override-or-fix`. If the commits since `report.head` only applied straightforward fixes for already-triaged findings, do not post `/crysk review`: stop the loop and tell the user the PR finished its review passes and waits for a maintainer's `/crysk review` (to verify the fixes) or `/crysk override` (to merge them unverified).
|
|
117
123
|
3. **Stop and recommend merge when only diminishing-returns items remain.** On `override-or-fix` (or pass 2+ when every real bug is fixed and the only remaining red-gate items are `deferred`, `misclassified`, or a contrived finding whose dismissal the adjudicator did not uphold), **do not cave in and edit the code**. Exit the loop, list the remaining finding(s) with a one-line explanation of why they are contrived/out-of-scope, and tell the user the PR is ready to `/crysk override` and merge.
|
|
118
124
|
4. **Stop automatic reviews BEFORE the push that should not be reviewed.** When you decide no further review pass is needed but you still have fixes to push, post `gh pr comment <n> --body "/crysk stop"` **first**, then `git push`. CI admission reads the stop on that push and skips the review, carrying the last verdict (a carried red turns green, marked `fixes unverified`, when every blocking finding was answered before that push; otherwise it stays red). The stop stays in force for every later push until someone comments `/crysk review` or `/crysk recheck`. It counts only from a user with write access, starts no workflow run, and costs $0. Never push first and try to stop the review afterwards: nothing cancels a review that already started.
|
|
119
125
|
|
|
@@ -121,7 +127,7 @@ Later review passes hunt only the push delta. Once the real defects from pass 1
|
|
|
121
127
|
|
|
122
128
|
The opposite happens when a repository's workflow policy (`once_per_pr`, `thresholded`, `risk_aware` below the score floor, `ci_max_attempts` exhausted, or the size gate) suppresses an automatic review on a push that **genuinely changed load-bearing code**:
|
|
123
129
|
- Under `once_per_pr`, `thresholded`, or `risk_aware`, a skipped push can inherit a carried `success` status from `report.head`, so `next_action` reads `"done"` even though `report.head !== head` (the commits `report.head..head` were never reviewed).
|
|
124
|
-
- Under `ci_max_attempts` or `manual_only`,
|
|
130
|
+
- Under `ci_max_attempts` or `manual_only`, a red carries the same way, and a green is held `pending` ("crysk: waiting for a manual review"), so `next_action` reads `"override-or-fix"`. Under the size or spend-ceiling gate, the automatic run is blocked and the head is red. Either way `report.head !== head`.
|
|
125
131
|
|
|
126
132
|
Whenever `report.head !== head`, inspect `git diff <report.head>..<head>`:
|
|
127
133
|
- If that unreviewed delta introduced **new business logic, state-machine or concurrency changes, auth/security/isolation edits, or a non-trivial refactor** (for example, fixing a finding required redesigning a function rather than adding a guard), an extra review **is** justified:
|
|
@@ -187,8 +193,13 @@ read that file instead.
|
|
|
187
193
|
(`comment_id` is null: a summary-only row, or one never posted inline). Commit and `git push` the fix, then immediately run step 0 with `--wait` so the next review verifies it. A thread-less finding cannot be answered with `triage reply`, so fix it or ask a maintainer for `/crysk override`.
|
|
188
194
|
- `recheck`: blocking findings are answered `dismissed` (with no pending code fixes to push) and the CI adjudicator has not ruled on
|
|
189
195
|
them on this head (or ruled `inconclusive`). Comment `gh pr comment <n> --body "/crysk recheck"`, then immediately run step 0 with `--wait` and follow "Closing a dismissal" below.
|
|
190
|
-
- `override-or-fix`: the gate is red and nothing is left for
|
|
191
|
-
`reason` and act on the case it names; never override it yourself:
|
|
196
|
+
- `override-or-fix`: the gate is red (or held for a manual review) and nothing is left for
|
|
197
|
+
`triage` or `recheck`. Read the `reason` and act on the case it names; never override it yourself:
|
|
198
|
+
- the gate holds the head for a manual review (the gate description starts "crysk: waiting for
|
|
199
|
+
a manual review"): inspect `git diff <report.head>..<head>` as in "Requesting or suggesting
|
|
200
|
+
another review" above. A load-bearing delta justifies `/crysk review` (within the forced-run
|
|
201
|
+
bound), then step 0 with `--wait`; otherwise exit the loop and tell the maintainer the PR
|
|
202
|
+
waits for `/crysk review` or `/crysk override`;
|
|
192
203
|
- the head was size- or budget-skipped (the gate description starts "crysk skipped the
|
|
193
204
|
review", or "pr-hero skipped the review" on a status an older action wrote): comment `/crysk review`, then run step 0 with `--wait`;
|
|
194
205
|
- the review is "partial again" with the same hunters failing: fix the failing hunter's route
|
|
@@ -200,7 +211,7 @@ read that file instead.
|
|
|
200
211
|
description): read that description and act on what it says; when it names nothing you can
|
|
201
212
|
fix, ask a maintainer.
|
|
202
213
|
- `done`: nothing is owed on this head. The gate passed (or an override unlocked it) and every
|
|
203
|
-
finding posted on this head has a reply. A `fixes unverified` green (the `reason` says no review
|
|
214
|
+
finding posted on this head has a reply. When `findings` lists rows with `comment_id: null` (the `reason` says they "live only in the summary comment"), they are outside-diff findings with no thread: read each one in the summary, fix what is real before you report the PR ready, and name the rest in your report. A `fixes unverified` green (the `reason` says no review
|
|
204
215
|
verified it) is done too: report the PR ready to merge and say the fixes were not verified by a review. Before exiting, check whether `report.head && report.head !== head` (a green status carried over an unreviewed push under `once_per_pr`, `thresholded`, or `risk_aware`): if `git diff <report.head>..<head>` contains non-trivial logic or risky changes ("Requesting or suggesting another review" above), recommend `/crysk review` naming those changes; otherwise exit the loop and report that the PR is ready to merge.
|
|
205
216
|
|
|
206
217
|
**Bound the forced runs.** `/crysk review` and `/crysk recheck` each run a full paid review
|
package/skills/crysk-pr/SKILL.md
CHANGED
|
@@ -61,6 +61,6 @@ When `crysk` is active on the repository, **never stop right after `gh pr create
|
|
|
61
61
|
`--wait` holds automatically during the 3-minute startup grace window while `gate.state` is `"none"` (waiting for GitHub Actions to pick up the new PR), continues polling every 15s while `gate.state` is `"pending"`, and returns as soon as the review settles.
|
|
62
62
|
|
|
63
63
|
2. **Route on `next_action`:**
|
|
64
|
-
- **`next_action === "done"`:**
|
|
64
|
+
- **`next_action === "done"`:** First, if `findings` lists rows with `comment_id: null` (the `reason` says they "live only in the summary comment"), read each one in the PR's summary comment: an outside-diff finding has no thread, so `done` does not mean it was answered. Fix the real ones or hand off to `crysk-loop`; never report the PR ready without naming them. Then check whether `report.head` is non-null and `report.head !== head` (a green status carried forward over an unreviewed push under `once_per_pr`, `thresholded`, or `risk_aware`). If so and `git diff <report.head>..<head>` contains non-trivial logic or risky changes, explicitly recommend running `/crysk review` to the user naming those changes. Otherwise, the review passed the gate with zero untriaged findings: report the PR URL and clean review summary to the user.
|
|
65
65
|
- **`next_action !== "done"` (`"triage"`, `"fix"`, `"recheck"`, `"review"`, `"override-or-fix"`):**
|
|
66
66
|
Immediately load the `crysk-loop` skill (`skills/crysk-loop/SKILL.md`) and run its autonomous loop (`while (next_action !== "done")`) to judge findings, reply, push verified fixes, and wait for re-review until the PR is ready to merge.
|
package/src/asset-manifest.ts
CHANGED
|
@@ -5,9 +5,6 @@
|
|
|
5
5
|
// compile.assets is a silent no-op on Bun 1.3.14 — this manifest is the permanent mechanism.
|
|
6
6
|
|
|
7
7
|
import consolidatePrompt from "../prompts/consolidate.md" with { type: "file" };
|
|
8
|
-
import lifecyclePrompt from "../prompts/default/deep-review-lifecycle.md" with {
|
|
9
|
-
type: "file",
|
|
10
|
-
};
|
|
11
8
|
import logicPrompt from "../prompts/default/deep-review-logic.md" with {
|
|
12
9
|
type: "file",
|
|
13
10
|
};
|
|
@@ -49,7 +46,6 @@ import triageSkill from "../skills/crysk-loop/SKILL.md" with { type: "file" };
|
|
|
49
46
|
import prSkill from "../skills/crysk-pr/SKILL.md" with { type: "file" };
|
|
50
47
|
|
|
51
48
|
export const BUNDLED_AGENT_FILES: Record<string, string> = {
|
|
52
|
-
"deep-review-lifecycle.md": lifecyclePrompt,
|
|
53
49
|
"deep-review-logic.md": logicPrompt,
|
|
54
50
|
"deep-review-parity.md": parityPrompt,
|
|
55
51
|
"deep-review-reliability.md": reliabilityPrompt,
|
package/src/assets.ts
CHANGED
|
@@ -74,7 +74,7 @@ function resolveVersion(): string {
|
|
|
74
74
|
// Ignore read errors
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
return "0.
|
|
77
|
+
return "0.5.0";
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export function resolveEngineAssets(): EngineAssets {
|
|
@@ -142,7 +142,7 @@ export function isNpxCacheInvocation(invocation: SelfInvocation): boolean {
|
|
|
142
142
|
// run this engine has ever written — before and after a change that alters
|
|
143
143
|
// what every agent reads — reports the same engine. That is not a cosmetic gap. The Cal.com Martian
|
|
144
144
|
// baseline is ratified as valid ACROSS engine versions on the condition that
|
|
145
|
-
// the frontier is annotated (
|
|
145
|
+
// the frontier is annotated (benchmarks/martian/README.md), and an artifact whose
|
|
146
146
|
// engine field cannot change cannot annotate anything.
|
|
147
147
|
//
|
|
148
148
|
// The revision is the git commit, which moves on its own and needs nobody to
|
|
@@ -97,6 +97,10 @@ const TERMINAL_BUDGET_STATUSES: ReadonlySet<AdmissionAttemptStatus> = new Set([
|
|
|
97
97
|
// - `"gate-skipped"` also comes from recordCiConfigErrorSkip (pr/ci-admission-gate.ts),
|
|
98
98
|
// called from the pre-reservation catch in pr/review-pr.ts when gotchas or the
|
|
99
99
|
// prompt set is misconfigured. It runs before any reservation or provider call.
|
|
100
|
+
// - `"gate-skipped"` also comes from settleClaudeCredentialRefusal (pr/admission.ts),
|
|
101
|
+
// called from pr/plan.ts on a credential refusal (no listed Claude credential, or
|
|
102
|
+
// an OpenCode route with no auth record): after the budget gate and before any
|
|
103
|
+
// binding or provider call.
|
|
100
104
|
// - `"yielded"`: written only by yieldToInFlightReview (pr/ci-admission-gate.ts:380),
|
|
101
105
|
// whose sole caller is pr/review-pr.ts:359, again before the `"provider-started"`
|
|
102
106
|
// settle at pr/review-pr.ts:516.
|
package/src/ci/classify-error.ts
CHANGED
|
@@ -5,16 +5,12 @@
|
|
|
5
5
|
//
|
|
6
6
|
// Each mapping is justified by the throw site and by the catalog text of its code
|
|
7
7
|
// (src/ci/outcome.ts ERROR_CATALOG):
|
|
8
|
-
// -
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// - AmbiguousMappingError (src/model/routing.ts) -> route/ambiguous: "found N
|
|
12
|
-
// duplicate mappings"; its text asks to remove the duplicate.
|
|
13
|
-
// - UnauthorizedRouteError (src/model/routing.ts) -> route/spend-disabled: every
|
|
14
|
-
// throw says "Spend is disabled"; its text asks to enable spend.
|
|
8
|
+
// - No route class: the alias-keyed routing and its codes were removed
|
|
9
|
+
// (odd/tasks/role-model-routing.md S2, E-f F0). A model is now a name that parses
|
|
10
|
+
// or a usage error that says how to write it.
|
|
15
11
|
// - OpenCodeVersionAdmissionError (src/transport-registry.ts) with reason "version"
|
|
16
12
|
// -> capability/version_unsupported: the pinned version-pair checks
|
|
17
|
-
// (admitOpenCodeVersionPair, loadOpenCodeSdk);
|
|
13
|
+
// (admitOpenCodeVersionPair, loadOpenCodeSdk); CRYSK-RUNTIME-UNAVAILABLE calls the
|
|
18
14
|
// action-installed runtime a pr-hero defect, which the pinned version is.
|
|
19
15
|
// - The same class with reason "identity" -> unknown: the observed identity is missing
|
|
20
16
|
// in production, or the declared versions contradict it (transport-registry.ts). That
|
|
@@ -23,7 +19,14 @@
|
|
|
23
19
|
// - OpenCodeSdkUnavailableError (src/transports/opencode-admission.ts) -> capability/
|
|
24
20
|
// sdk_unavailable: "is not installed"; the same code, the local text says reconcile.
|
|
25
21
|
//
|
|
26
|
-
//
|
|
22
|
+
// - CredentialRefusalError (src/security/claude-credential.ts) names its own class
|
|
23
|
+
// (CliError.cls): a Claude route with no credential -> trigger/no-credential
|
|
24
|
+
// (CRYSK-CRED-MISSING), an OpenCode route with no auth record -> credential/
|
|
25
|
+
// missing_provider_record or missing_subscription_record (CRYSK-CRED-UNUSABLE). Its
|
|
26
|
+
// params (cliErrorParams below) let the record name the route and its fixes.
|
|
27
|
+
//
|
|
28
|
+
// Not mapped, on purpose: ModelRoutingError and InvalidModelError (their message is
|
|
29
|
+
// the fix, and no catalog text names it),
|
|
27
30
|
// RouteAdmissionError and OpenCodeProductionGatedError (a readiness gate, which no
|
|
28
31
|
// capability issue names), CliError and everything else.
|
|
29
32
|
//
|
|
@@ -32,14 +35,10 @@
|
|
|
32
35
|
// that runs before it.
|
|
33
36
|
|
|
34
37
|
import { CliError, CliUsageError, recordClassOf } from "../errors";
|
|
35
|
-
import {
|
|
36
|
-
AmbiguousMappingError,
|
|
37
|
-
UnauthorizedRouteError,
|
|
38
|
-
UnmappedRouteError,
|
|
39
|
-
} from "../model/routing";
|
|
38
|
+
import { CredentialRefusalError } from "../security/claude-credential";
|
|
40
39
|
import { OpenCodeVersionAdmissionError } from "../transport-registry";
|
|
41
40
|
import { OpenCodeSdkUnavailableError } from "../transports/opencode-admission";
|
|
42
|
-
import type { CliErrorClass } from "./outcome";
|
|
41
|
+
import type { CliErrorClass, ErrorParams } from "./outcome";
|
|
43
42
|
|
|
44
43
|
export function classifyCliError(error: unknown): CliErrorClass {
|
|
45
44
|
// The class the throw site named wins over the instanceof mapping below. WHY: the
|
|
@@ -52,15 +51,6 @@ export function classifyCliError(error: unknown): CliErrorClass {
|
|
|
52
51
|
) {
|
|
53
52
|
return error.cls;
|
|
54
53
|
}
|
|
55
|
-
if (error instanceof UnmappedRouteError) {
|
|
56
|
-
return { kind: "route", reason: "unmapped" };
|
|
57
|
-
}
|
|
58
|
-
if (error instanceof AmbiguousMappingError) {
|
|
59
|
-
return { kind: "route", reason: "ambiguous" };
|
|
60
|
-
}
|
|
61
|
-
if (error instanceof UnauthorizedRouteError) {
|
|
62
|
-
return { kind: "route", reason: "spend-disabled" };
|
|
63
|
-
}
|
|
64
54
|
if (error instanceof OpenCodeVersionAdmissionError) {
|
|
65
55
|
return error.reason === "identity"
|
|
66
56
|
? { kind: "unknown" }
|
|
@@ -71,3 +61,10 @@ export function classifyCliError(error: unknown): CliErrorClass {
|
|
|
71
61
|
}
|
|
72
62
|
return { kind: "unknown" };
|
|
73
63
|
}
|
|
64
|
+
|
|
65
|
+
// The params a throw site named for the record, or undefined. Only a credential
|
|
66
|
+
// refusal names any today. Provider and model pass the record's own checks
|
|
67
|
+
// (safeProviderName, safeModelName) in the writer.
|
|
68
|
+
export function cliErrorParams(error: unknown): ErrorParams | undefined {
|
|
69
|
+
return error instanceof CredentialRefusalError ? error.params : undefined;
|
|
70
|
+
}
|
package/src/ci/cli-record.ts
CHANGED
|
@@ -43,11 +43,13 @@ import {
|
|
|
43
43
|
CLI_RECORD_FILE,
|
|
44
44
|
type CliErrorClass,
|
|
45
45
|
type CliRecord,
|
|
46
|
+
type ErrorParams,
|
|
46
47
|
type HunterFailureRecord,
|
|
47
48
|
knownFailureCredential,
|
|
48
49
|
knownTransportCause,
|
|
49
50
|
PENDING_AT_FILE,
|
|
50
51
|
parseCliRecord,
|
|
52
|
+
RUN_DIR_FILE,
|
|
51
53
|
safeFailureDetail,
|
|
52
54
|
safeModelName,
|
|
53
55
|
safeProviderName,
|
|
@@ -162,6 +164,26 @@ export function recordPendingCreatedAt(
|
|
|
162
164
|
}
|
|
163
165
|
}
|
|
164
166
|
|
|
167
|
+
// The run directory's writer: src/pr/review-pr.ts calls it as soon as the directory
|
|
168
|
+
// exists, so a run that never reaches the run step's outputs (every hunter failed, a
|
|
169
|
+
// fatal error, a cancelled job) still names its files for the trace step
|
|
170
|
+
// (src/ci/platform-trace.ts). Never throws, and writes nothing outside action mode. A
|
|
171
|
+
// path with a line break writes nothing: the reader takes the first line.
|
|
172
|
+
export function recordRunDir(
|
|
173
|
+
runDir: string,
|
|
174
|
+
env: Readonly<Record<string, string | undefined>> = process.env,
|
|
175
|
+
): void {
|
|
176
|
+
const dir = env.CRYSK_OUTCOME_DIR ?? "";
|
|
177
|
+
if (dir === "" || runDir === "" || /[\r\n]/.test(runDir)) return;
|
|
178
|
+
try {
|
|
179
|
+
writeRecordAtomically(dir, RUN_DIR_FILE, `${runDir}\n`, NODE_FS);
|
|
180
|
+
} catch (error) {
|
|
181
|
+
process.stderr.write(
|
|
182
|
+
`crysk: could not write the run directory record: ${errnoCode(error)}\n`,
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
165
187
|
// The delivery writer: publishRunOutcome calls it once the review is delivered (see the
|
|
166
188
|
// header for which delivery point, and why). A run that did not deliver never calls it.
|
|
167
189
|
export function recordReviewDelivered(
|
|
@@ -232,9 +254,14 @@ export function recordUnsettledStatus(
|
|
|
232
254
|
// WHY no check that the record belongs to this job: the trigger clears cli.json at
|
|
233
255
|
// job start (clearStaleMarkers in trigger.ts), so a record present here was written
|
|
234
256
|
// by this job.
|
|
257
|
+
//
|
|
258
|
+
// `params` are the ones the throw site named (cliErrorParams, classify-error.ts). Only
|
|
259
|
+
// the values the record accepts are written: a provider or model that fails its check,
|
|
260
|
+
// or an empty string, is left out, so a bad value costs that detail, never the record.
|
|
235
261
|
export function writeFatalCliRecord(
|
|
236
262
|
cls: CliErrorClass,
|
|
237
263
|
env: Readonly<Record<string, string | undefined>> = process.env,
|
|
264
|
+
params?: ErrorParams,
|
|
238
265
|
): void {
|
|
239
266
|
const dir = env.CRYSK_OUTCOME_DIR ?? "";
|
|
240
267
|
if (dir === "") return;
|
|
@@ -245,7 +272,32 @@ export function writeFatalCliRecord(
|
|
|
245
272
|
);
|
|
246
273
|
return;
|
|
247
274
|
}
|
|
248
|
-
|
|
275
|
+
const recorded = params === undefined ? undefined : recordParams(params);
|
|
276
|
+
writeCliRecord(
|
|
277
|
+
{
|
|
278
|
+
v: 1,
|
|
279
|
+
outcome: "error",
|
|
280
|
+
cls,
|
|
281
|
+
...(recorded === undefined ? {} : { params: recorded }),
|
|
282
|
+
},
|
|
283
|
+
env,
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// The string params a fatal record may carry. Provider and model go through the
|
|
288
|
+
// record's own name checks; the others are names Crysk wrote (a backend, a step key,
|
|
289
|
+
// a CRYSK_* secret), kept when they are one non-empty line.
|
|
290
|
+
function recordParams(params: ErrorParams): ErrorParams | undefined {
|
|
291
|
+
const out: ErrorParams = {};
|
|
292
|
+
const provider = safeProviderName(params.provider);
|
|
293
|
+
if (provider !== undefined) out.provider = provider;
|
|
294
|
+
const model = safeModelName(params.model);
|
|
295
|
+
if (model !== undefined) out.model = model;
|
|
296
|
+
for (const key of ["backend", "step", "secret"] as const) {
|
|
297
|
+
const value = safeFailureDetail(params[key]);
|
|
298
|
+
if (value !== undefined) out[key] = value;
|
|
299
|
+
}
|
|
300
|
+
return Object.keys(out).length === 0 ? undefined : out;
|
|
249
301
|
}
|
|
250
302
|
|
|
251
303
|
// The record this job already wrote, or undefined when there is none, it cannot be
|