crysk 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +3 -1
  2. package/dist/SKILL-32cmme3j.md +143 -0
  3. package/dist/adjudicator-eckqh14e.md +78 -0
  4. package/dist/ci-admission-qn797a6c.md +128 -0
  5. package/dist/cli.js +119 -38
  6. package/dist/consolidate-4xw1pkg7.md +24 -0
  7. package/dist/deep-review-logic-dgr112y1.md +196 -0
  8. package/dist/deep-review-logic-fck5z4xe.md +197 -0
  9. package/dist/deep-review-logic-h1fpamfh.md +192 -0
  10. package/dist/deep-review-logic-m4vk5683.md +196 -0
  11. package/dist/deep-review-logic-z63kmgmc.md +157 -0
  12. package/dist/deep-review-parity-7x7s5d81.md +148 -0
  13. package/dist/deep-review-parity-9wxmynsc.md +115 -0
  14. package/dist/deep-review-parity-bwwe7cx6.md +152 -0
  15. package/dist/deep-review-parity-e50pw3pk.md +117 -0
  16. package/dist/deep-review-parity-ennmm9m1.md +151 -0
  17. package/dist/deep-review-parity-h7y6y2he.md +118 -0
  18. package/dist/deep-review-parity-xg6wy69c.md +151 -0
  19. package/dist/deep-review-reliability-6h3c4gmw.md +125 -0
  20. package/dist/deep-review-reliability-dcjab69x.md +122 -0
  21. package/dist/deep-review-reliability-ec7b5pbk.md +159 -0
  22. package/dist/deep-review-reliability-hvasvmt9.md +153 -0
  23. package/dist/deep-review-reliability-mjnayxmt.md +158 -0
  24. package/dist/deep-review-reliability-mm7fnayf.md +124 -0
  25. package/dist/deep-review-reliability-xk4xvc2w.md +158 -0
  26. package/dist/deep-review-resilience-0esd5qeh.md +148 -0
  27. package/dist/deep-review-resilience-envgcmpy.md +115 -0
  28. package/dist/deep-review-resilience-fgx8ythf.md +151 -0
  29. package/dist/deep-review-resilience-mq5qa6ad.md +152 -0
  30. package/dist/deep-review-resilience-pwh1gawp.md +151 -0
  31. package/dist/deep-review-resilience-s9n21dkx.md +117 -0
  32. package/dist/deep-review-resilience-vz4qskea.md +119 -0
  33. package/dist/deep-review-security-1vwjdc9q.md +205 -0
  34. package/dist/deep-review-security-x1cc1z00.md +205 -0
  35. package/dist/index.js +105 -29
  36. package/dist/opencode-ci-jc8mf4wn.md +106 -0
  37. package/dist/review-refuter-7qffwtzz.md +77 -0
  38. package/dist/verifier-tyh8r45v.md +40 -0
  39. package/dist/verifier-xf4xj701.md +40 -0
  40. package/package.json +1 -1
  41. package/prompts/consolidate.md +1 -1
  42. package/prompts/default/PROVENANCE.md +5 -0
  43. package/prompts/default/deep-review-logic.md +56 -15
  44. package/prompts/default/deep-review-parity.md +71 -39
  45. package/prompts/default/deep-review-reliability.md +64 -30
  46. package/prompts/default/deep-review-resilience.md +71 -37
  47. package/prompts/default/deep-review-security.md +205 -0
  48. package/prompts/default/review-refuter.md +1 -1
  49. package/prompts/verifier.md +40 -0
  50. package/skills/crysk-ci-setup/SKILL.md +3 -3
  51. package/skills/crysk-ci-setup/references/ci-admission.md +1 -1
  52. package/skills/crysk-ci-setup/references/opencode-ci.md +1 -1
  53. package/skills/crysk-loop/adjudicator.md +10 -18
  54. package/src/asset-manifest.ts +6 -0
  55. package/src/assets.ts +4 -1
  56. package/src/ci/gates.ts +11 -2
  57. package/src/ci/review-levels.ts +4 -4
  58. package/src/commands/ci-setup-questions.ts +1 -1
  59. package/src/compare/hunter-exam.ts +631 -0
  60. package/src/index.ts +1 -1
  61. package/src/model/model-name.ts +2 -1
  62. package/src/model/profiles.ts +1 -1
  63. package/src/pr/pr.ts +1 -1
  64. package/src/pr/preflight.ts +29 -3
  65. package/src/pr/review-pr.ts +5 -0
  66. package/src/rereview/verify.ts +15 -9
  67. package/src/review/boundary.ts +1 -0
  68. package/src/review/pipeline.ts +139 -14
  69. package/src/review/preflight.ts +16 -3
  70. package/src/review/prompt-set.ts +1 -0
  71. package/src/review/review.ts +9 -9
  72. package/src/review/route-preflight.ts +16 -0
  73. package/src/updater.ts +1 -1
package/README.md CHANGED
@@ -9,7 +9,9 @@ finding, and deterministic code — never a model — assigns blocking/advisory
9
9
  Its measured profile, stated up front: **high precision, narrow coverage**. What it reports is
10
10
  almost always real (13% false positives measured). Its hunters check value contracts across the diff
11
11
  (units, domain, conversions, what consumers assume), resilience (lookup and dedupe keys, retries and
12
- locks, CI guards, test isolation), local logic errors, and access-control parity with sibling code;
12
+ locks, CI guards, test isolation), local logic errors, trust boundaries (outside input reaching a
13
+ query, command, file path or server-side request; missing or misplaced permission checks; a hunter
14
+ added 2026-11-15, after that measurement), and access-control parity with sibling code;
13
15
  stale state, races and component lifecycle have no dedicated hunter since 2026-11-08. It says nothing
14
16
  about style or convention. Locally it is an **assistant, not a merge gate**: every report closes with that
15
17
  disclaimer, and nothing it prints blocks a merge. In CI its commit status is a gate by default: require the
@@ -0,0 +1,143 @@
1
+ ---
2
+ name: crysk-ci-setup
3
+ description: "Trigger: setup CI, add Crysk to CI, GitHub Actions review, CRYSK_* secrets, crysk-secrets, CRYSK_MODELS, models per role in CI, OpenCode, DeepSeek, CRYSK-INPUT-REMOVED, old OPENCODE_AUTH_JSON / CRYSK_ROUTING workflows, admission policy, configure CI workflow, retrigger, force review, skipped review, /crysk review, /crysk override, pr-hero-force, too many findings, noisy review, post_min_severity, materiality_gate. Scaffolds the one workflow, secrets, models variables, admission config, and the posting and noise settings."
4
+ license: Apache-2.0
5
+ metadata:
6
+ author: juanmaagd
7
+ version: "4.0"
8
+ ---
9
+
10
+ ## Activation Contract
11
+
12
+ Load when the user asks to:
13
+ - Add Crysk to GitHub Actions CI, scaffold `.github/workflows/crysk.yml`, or configure secrets. No local install is needed: the workflow file is the whole install.
14
+ - Configure the models per role in CI, or **OpenCode** (`CRYSK_MODELS`, `CRYSK_OPENCODE_*` secrets, DeepSeek, mixed Claude+OpenCode, fallbacks).
15
+ - Move a workflow off the removed inputs (`CRYSK-INPUT-REMOVED`: `claude-token`, `anthropic-api-key`, `opencode-auth` with the `OPENCODE_AUTH_JSON` secret, `routing` with the `CRYSK_ROUTING` variable).
16
+ - Tune CI spend / re-review / admission policy.
17
+ - Retrigger a skipped CI review (size, admission, or budget) without running the review locally.
18
+ - Reduce review noise: fewer comments (`post_min_severity`) or fewer blocking findings that are real but improbable (`materiality_gate`).
19
+
20
+ ## Hard Rules
21
+
22
+ - **Zero secret leakage:** NEVER print, `cat`, commit, or log API keys, tokens, or an OpenCode `auth.json` record. Reference `${{ secrets.* }}` names only. Inspect `auth.json` **keys and `type` only**.
23
+ - **One `CRYSK_*` secret per credential, nothing else:** `CRYSK_CLAUDE_OAUTH_TOKEN` (subscription), `CRYSK_CLAUDE_API_KEY`, `CRYSK_OPENCODE_<P>_API_KEY` per OpenCode provider, `CRYSK_OPENCODE_OPENAI_OAUTH` for an OpenAI subscription. The workflow names each one in its `crysk-secrets` block, never `toJSON(secrets)`. The old `CLAUDE_CODE_OAUTH_TOKEN`, `ANTHROPIC_API_KEY` and `OPENCODE_AUTH_JSON` secrets and the `CRYSK_ROUTING` variable are read by nothing. Models per role go in the public variable `CRYSK_MODELS` (no credentials in it), the Claude order in `CRYSK_CREDENTIALS`, the OpenCode providers in `CRYSK_OPENCODE_PROVIDERS`.
24
+ - **No install needed:** run every Crysk command as `npx -y crysk <command>` (Node is enough; the package brings its own Bun). A global `crysk` on PATH is the same command. CI itself needs no local CLI at all: the workflow runs the action. `npx -y crysk skills install` installs the Crysk, triage, and CI-setup skills into every detected coding agent, with no TTY and no MCP or launchd registration (neither is needed for the CI loop, and npx's temporary cache refuses them).
25
+ - **Deterministic scaffolding:** Run `npx -y crysk setup --ci` (or `npx -y crysk ci init`) with the interview's flags. It writes the one workflow file, `.github/workflows/crysk.yml` (a repo that already has `pr-hero.yml` keeps it: `--force` rewrites it in place, and setup refuses to add a second file beside it). Do not fabricate it from memory. Fallback: copy `assets/workflow.yml`. Never scaffold a `pr-hero-force.yml`; it is retired.
26
+ - **`fetch-depth: 0` is mandatory** on `actions/checkout@v4`.
27
+ - **Gate mode:** the `crysk` commit status is the required check (the legacy `pr-hero` status is no longer posted). The scaffold writes `mode: gate` explicitly: blocking findings, a size or spend-ceiling skip, and a crash set it red. Every review rule that skips a push (low-risk delta, once per PR, `/crysk stop`, the attempt budget used up, `manual_only`) carries the last verdict; answered blocking findings turn a carried red green, marked unverified. Under the attempt budget used up or `manual_only`, that green is held `pending` instead, so a push past the budget or under `manual_only` never turns green without a `/crysk review` or a `/crysk override`. `mode: advisory` keeps it green for a finished review. The job's exit code stays `0` on findings either way, so do not gate on the job.
28
+ - **Required permissions:** `contents: read`, `pull-requests: write`, `issues: write`, `statuses: write`, **`checks: write`**, **`actions: read`** (the admission gate lists past runs; a private repo 403s without it). Template in `assets/workflow.yml` includes all six.
29
+ - **Retrigger is a PR comment: `gh pr comment <n> --body "/crysk review"`.** GitHub Actions runs the review on the runner with `--force`. The comment must be exactly `/crysk review` (or `/crysk review --full`; `/pr-hero review` on a workflow scaffolded before the rename, see the `/crysk` vs `/pr-hero` bullet), and its author needs write access; the action refuses anyone else. Do not run `crysk review --force` locally when the review should happen in CI. `gh run rerun` on a skipped run re-evaluates the gates and does not force. In this repo a comment run checks out the PR head commit before `uses: ./`, so it runs the PR's own engine, not the default branch's.
30
+ - **`/crysk recheck` re-reviews the head and asks the CI adjudicator to rule on pending dismissals.** It is `/crysk review` plus `--adjudicate`, with the same permission check and reaction; refused on fork pull requests. See `docs/github-actions.md` ("Rechecking a dismissal").
31
+ - **`/crysk stop` stops automatic reviews on the PR.** Post it before a push that should not be reviewed: CI admission skips every later automatic review, carrying the last verdict, until a `/crysk review` or `/crysk recheck` comment. It counts only from a user with write access (checked at admission), starts no run, and never turns the gate green. See `docs/github-actions.md` ("Stopping automatic reviews").
32
+ - **`--force` never widens discovery; `--full` does.** When a prior review of the same head was hollow or wrong and re-runs report "No changes to discover", comment `/crysk review --full`. It passes `--full`, which re-discovers the whole PR range.
33
+ - **When the comment trigger takes effect:** GitHub reads a comment-triggered workflow from the **default branch** (for this repo, `main`, not `dev`), so `/crysk review` works only once the workflow file (`crysk.yml`, or `pr-hero.yml` in a repo set up before the rename) with its `issue_comment` trigger is merged there; a user repo also needs an action release that handles the comment, through the `@v0` it pins.
34
+ - **`/crysk` vs `/pr-hero`:** the commands are `/crysk review`, `/crysk recheck`, `/crysk override` and `/crysk stop`; the action still accepts `/pr-hero …` for one version. A `pr-hero.yml` scaffolded before the rename filters only `/pr-hero …`, so a `/crysk …` comment starts nothing there: re-run `npx -y crysk ci init --force` to accept both, which also moves the workflow to the `CRYSK_*` secrets.
35
+ - **Legacy scaffolds:** a `pr-hero.yml` scaffolded before the comment trigger has no `issue_comment` listener, so a comment does nothing. There, use `gh workflow run pr-hero-force.yml -f pr=<n>` (add `-f full=true` to re-discover), or re-scaffold with `npx -y crysk ci init --force`, which leaves `pr-hero-force.yml` in place.
36
+ - **Minimum action version:** this workflow listens to comments, and only an action release that ships the comment handling checks the command and the commenter's write access. An older action reviews on ANY comment starting with `/crysk review`, from anyone who can comment. Never pair this workflow with an older action; a pinned tag or sha must be at or after that release.
37
+ - **Older heads (this repo):** a comment run loads the PR head's own `action.yml`, so on a head from before the comment handling it reviews without reading the comment (no force, no `--full`); merge or rebase the PR onto a base that has it first.
38
+ - **Trust (this repo):** a comment run runs the PR head's code, including its `bun install`, with the workflow's secrets, so write access is checked twice: by the workflow's pre-checkout step (fail closed, before any head code runs) and again by the head's `action.yml`.
39
+ - **Admission config is repo-level:** Write `.crysk/config.json` on the default branch. That file **rejects** `models` and `credentials`: they are person-layer only (`$HOME/.crysk/config.json` on the runner, written from `vars.CRYSK_MODELS` and `vars.CRYSK_CREDENTIALS`).
40
+ - **`.cryskignore` is read from the base ref, not the PR branch, in CI.**
41
+ - **Models and OpenCode are DATA:** the scaffold passes `models: ${{ vars.CRYSK_MODELS }}`, `credentials: ${{ vars.CRYSK_CREDENTIALS }}` and five OpenCode slot lines driven by `vars.CRYSK_OPENCODE_PROVIDERS`. Unset `CRYSK_MODELS` = Claude CI. Never a per-provider Action input. A repository connected to the Crysk platform takes its models from the platform, which wins over the inputs.
42
+ - **OpenCode procedure:** when OpenCode or mixed backends are in scope, follow `references/opencode-ci.md` before setting GitHub DATA (roles, model names, one secret per provider, the providers variable).
43
+
44
+ ## Decision Gates
45
+
46
+ | Condition | Action |
47
+ |---|---|
48
+ | `gh auth status` succeeds | Offer `gh secret set` / `gh variable set` |
49
+ | `gh` missing/unauthenticated | Link to repo Settings → Secrets and variables → Actions (Variables tab for `CRYSK_MODELS`, `CRYSK_CREDENTIALS`, `CRYSK_OPENCODE_PROVIDERS`) |
50
+ | Credential: Claude | **`CRYSK_CLAUDE_OAUTH_TOKEN`** — subscription (`claude setup-token` only, NOT keychain). **`CRYSK_CLAUDE_API_KEY`** — pay-as-you-go. Both set: the subscription runs unless `CRYSK_CREDENTIALS` is `{"claude": ["api_key", "subscription"]}`. |
51
+ | Credential: OpenCode | Read `references/opencode-ci.md`. One `CRYSK_OPENCODE_<P>_API_KEY` per provider + `CRYSK_MODELS` + `CRYSK_OPENCODE_PROVIDERS`. Any `CRYSK_*` credential counts; with none, the run fails red with the `gh secret set` commands. |
52
+ | openai in CI | `CRYSK_OPENCODE_OPENAI_API_KEY` runs metered; `CRYSK_OPENCODE_OPENAI_OAUTH` (base64 of the `openai` record of OpenCode's `auth.json`) is the ChatGPT subscription and wins when both are set. `_OAUTH` works for openai only. |
53
+ | Workflow red with `CRYSK-INPUT-REMOVED` | It still passes `claude-token`, `anthropic-api-key`, `opencode-auth` or `routing`. `npx -y crysk ci init --force`, then set the `CRYSK_*` secrets and variables it prints. |
54
+ | Different models per step | `CRYSK_MODELS` maps roles to lists: `default`, `hunter.<key>`, `refuter`, `consolidate`, `scout`, `summary`, `judge`. Any role left on a `claude:` model needs a Claude secret; OpenCode-only = every role on OpenCode, e.g. `{"default": ["opencode:deepseek/deepseek-v4-flash"]}` (`references/opencode-ci.md`). |
55
+ | Several OpenCode providers in one run | Supported: up to 5 providers through the workflow's slots, each model on its own provider's secret, as primary or fallback. |
56
+ | OpenCode CLI pin | Action installs **1.18.30** iff the setup step wrote an OpenCode auth file OR the models in effect name `opencode:`. Never `latest`. |
57
+ | Fork PRs | Their pushes skip (no secrets). A user with write access comments `/crysk review`, and that run (base context, with secrets) reviews the fork head. Review `if` never reads `secrets`; the action checks for a `CRYSK_*` credential in `crysk-secrets` (or a login file already on the runner). |
58
+ | Spend gates | Defaults: `budget-usd: 12.00` on metered routes (the run chose `CRYSK_CLAUDE_API_KEY`, **or** an OpenCode auth file was built), `max-changed-lines: 4000` and `max-changed-files: 50` on metered routes only; a Claude subscription route has no size limit unless the workflow or `.crysk/config.json` sets one. A subscription run stays unlimited unless an OpenCode auth file is also present. |
59
+ | Existing workflow | `setup --ci` skips; ask before `--force` |
60
+ | First-time admission | Recommend `ci_admission_observe_only: true` — `references/ci-admission.md` |
61
+ | User wants max CI spend | Lower `ci_max_attempts` and/or raise `ci_rereview_min_score` |
62
+ | Custom bot posts findings | Add login to `ci_trusted_actors` |
63
+ | Too many advisory comments on PRs | Raise the posting floor: `post_min_severity: "blocking"` in `.crysk/config.json` posts only blocking findings (`"warning"`, the recommended floor setup writes, hides advisory suggestions only). Blocking findings always post; the gate is unchanged. |
64
+ | Blocking findings that are real but improbable keep PRs red ("an edge case that never happens") | Offer `materiality_gate: true` in `.crysk/config.json` (opt-in, off by default). An isolated judge checks each blocking finding against Crysk's posting policy; one judged not material under normal use posts as advisory and does not block. Security, credential and data-loss findings are never demoted, and any judge failure keeps the finding blocking. Cost: one sonnet call per blocking finding (about 1 per PR, roughly +$0.015 notional and +10 s per review). Pair it with `post_min_severity: "blocking"` to hide the demoted ones entirely. |
65
+ | `materiality_gate` is on but nothing is ever demoted | Read the `materiality` record in the run's `pipeline.json` (in the `crysk-run-*` artifact). `unsupported_route`: the judge runs only on `claude:sonnet-latest` or `claude:opus-latest`, so a `models.judge` in `CRYSK_MODELS` that lists neither stands it down; remove that role or list one of the two. `ceiling`: the pipeline ceiling left no room for one judge wave (about 9 minutes). `ran` with `judged: 0`: the run had no blocking finding the safety guard leaves unprotected, so there was nothing to judge. `skipped` on a re-review with no new commits to review is expected (the judge is left out when nothing new is hunted). `skipped` anywhere else means the key did not reach the run: the repo config must be on the PR's base branch (CI reads it from there) and a global config must not set it `false` (the key is capped). |
66
+ | CI skipped (size, admission, or budget) | `gh pr comment <n> --body "/crysk review"`. The review runs on GitHub Actions. Do not run `crysk review --force` locally for this. Legacy scaffold (no `issue_comment` trigger): `gh workflow run pr-hero-force.yml -f pr=<n>`. |
67
+ | Gate is red with blocking findings the team accepts | `gh pr comment <n> --body "/crysk override"` (write access, same-repo PRs only, valid for that head only; a same-head `/crysk review` keeps it red). |
68
+ | Prior review of the same head was hollow or wrong; re-runs say "No changes to discover" | `gh pr comment <n> --body "/crysk review --full"`. A plain `/crysk review` keeps the narrowed discovery. |
69
+ | Gate red: `crysk: review partial (N of M hunters failed, set abc123) — /pr-hero review retries it` | Some hunters failed and nothing blocking was found. `gh pr comment <n> --body "/crysk review"`. If the same hunters fail every run, fix their route (model, credential) or override. |
70
+ | Gate red: `crysk: review partial again (N of M hunters failed, set abc123) — fix the failing route or /pr-hero override` | The previous review of this head was partial with the same hunters failing, so a retry already failed the same way. Fix the failing hunter's route (model, credential), or `gh pr comment <n> --body "/crysk override"`. `crysk status` answers `override-or-fix`. |
71
+ | Gate error: `CRYSK-CANCELLED: not reviewed — /pr-hero review reviews this head` | The review run was cancelled (a newer push, or by hand). Comment `/crysk review` to review the head. |
72
+ | `CRYSK-MODEL-UNAVAILABLE` (lead "Provider <name>:") | Every hunter's route names a model the provider does not serve. Fix the model id in `CRYSK_MODELS` (check `opencode models <provider>`). |
73
+ | `CRYSK-CRED-UNUSABLE` ("The route <provider>/<model> has no usable credential record") | No `CRYSK_OPENCODE_<P>_API_KEY` reached the run for that provider: set it, add its token to `CRYSK_OPENCODE_PROVIDERS`, or move that model elsewhere in `CRYSK_MODELS`. |
74
+ | `CRYSK-CONFIG-INVALID` naming the `models` or `credentials` input | `CRYSK_MODELS` or `CRYSK_CREDENTIALS` is not valid JSON or breaks a rule (the step's log names the entry). Check the same object locally under `models` / `credentials` in `~/.crysk/config.json` with `npx -y crysk config`, then set the variable again. |
75
+ | Blocking findings answered `dismissed`, gate still red | `gh pr comment <n> --body "/crysk recheck"`: the CI adjudicator rules on each dismissal (at most 5 per run). On `upheld`, comment `/crysk review`: that next review stops counting it. `deferred` / `misclassified` never clear the gate. |
76
+ | Gate error: `CRYSK-GOTCHAS-MISSING` ("the review instructions file (REVIEW.md or .crysk/gotchas.md) is empty or still the scaffold") | Write real facts into that file and delete the `human-attention-required` marker line (or delete the file to review with the default guidance), commit it to the default branch, then comment `/crysk review`. |
77
+ | Gate error: `CRYSK-HUNTERS-FAILED` (every hunter failed) | Check the route and credential first (the `CRYSK-CRED-UNUSABLE` and `CRYSK-MODEL-UNAVAILABLE` rows). Free OpenCode models fail intermittently: comment `/crysk review` to retry. |
78
+ | A `/crysk review` comment did nothing | The workflow is not on the default branch yet, the comment is not exact, the author lacks write access, or the workflow predates the comment trigger (re-scaffold with `--force`). |
79
+
80
+ ## Review Settings Interview (ask the human, never choose for them)
81
+
82
+ Before step 4, ask the human these questions in their language. Use the native question UI when available (one grouped interaction is fine). Do not pick an answer for them, and do not skip a question because a default exists: the point is that they know these settings exist.
83
+
84
+ 1. **Re-review level** (how Crysk reviews new pushes on an open PR):
85
+ - **Minimal**: one automatic review per PR; later pushes only on a `/crysk review` comment.
86
+ - **Balanced (recommended)**: re-review when the push touches risky files or the previous pass found enough (score >= 4); at most 2 automatic passes.
87
+ - **Thorough**: review every push, up to 4 automatic passes. Most coverage, most cost.
88
+ - **Manual**: nothing automatic after the first review; every re-review starts with `/crysk review`.
89
+ 2. **Gate or advisory**: gate turns the `crysk` check red on blocking findings (require it in branch protection to block merges); advisory keeps it green.
90
+ 3. **How CI pays**:
91
+ - **Claude subscription** (`CRYSK_CLAUDE_OAUTH_TOKEN`): do not ask for a budget. Tell them no `budget-usd` is written: a subscription review spends quota, not dollars, and CI applies no ceiling while the run uses the subscription and no `CRYSK_OPENCODE_*` secret builds an OpenCode auth file (an OpenCode model brings back the $12 ceiling, so a subscription mixed with OpenCode is the API-key answer). An API key kept beside it is not used unless `CRYSK_CREDENTIALS` puts `api_key` first.
92
+ - **API key** (`CRYSK_CLAUDE_API_KEY` or an OpenCode provider): ask for the spend ceiling per review in USD (default 12, `0` = none).
93
+ 4. **Changed-lines threshold**: a PR with more changed lines is skipped, not reviewed. Ask on any billing (default 4000, `0` = no limit, only if they say so): unlike the budget it matters on a subscription too, where an unset threshold means no limit at all.
94
+ 5. **Advanced settings**: name them, then ask whether to review them now. Each keeps a working default if skipped:
95
+ - score weights: blocking 2, advisory 1 (integers >= 1; `ci_blocking_weight`, `ci_advisory_weight`), and the score floor 4 (`ci_rereview_min_score`); used only by the risk-aware and thresholded policies;
96
+ - observe only (`ci_admission_observe_only`): log what the rules would skip, but review every push; good for one PR cycle;
97
+ - trusted actors (`ci_trusted_actors`): extra GitHub logins whose Crysk markers count;
98
+ - changed-files limit (`max_changed_files`): a PR touching more files is skipped; unset = none on a subscription, 50 on an API key;
99
+ - exclusions: patterns in `.cryskignore` (gitignore syntax) the review never reads;
100
+ - posting floor (`post_min_severity`): `suggestion` posts everything, `warning` (recommended, and what setup writes when the key is absent) hides advisory suggestions, `blocking` posts only blocking findings. Hidden findings are counted in the summary comment, and the gate is unchanged;
101
+ - materiality gate (`materiality_gate`, off unless they say yes): blocking findings that are real but not material under normal use are posted as advisory instead of blocking, judged by an isolated sonnet call per blocking finding against Crysk's posting policy; security, credential and data-loss findings are never demoted. Tell them the cost (about one call per PR, +$0.015 notional, +10 s), that it runs on Claude only (`claude:sonnet-latest`, or `claude:opus-latest` through `models.judge`), so it needs a Claude secret, and the known limit: on a re-review, a finding that already blocked on an earlier push still counts toward the gate.
102
+
103
+ **On a re-run** (`.crysk/config.json` already has re-review keys, or the workflow already exists), first show the human the current values (`npx -y crysk config`) and offer **Keep current settings** for the level and for the line threshold. When they keep them, omit `--level` / `--max-changed-lines`: passing a flag overwrites that group, including a tuned `max_verification_steps`.
104
+
105
+ Then pass the answers to the scaffold as flags, never as hand-written YAML:
106
+
107
+ ```bash
108
+ npx -y crysk setup --ci --level <minimal|balanced|thorough|manual> --ci-mode <gate|advisory> --billing <subscription|api> --max-changed-lines <n> [--budget-usd <n>]
109
+ ```
110
+
111
+ It writes the workflow, merges the level's keys into `.crysk/config.json` (keeping other keys), and prints a summary of every setting. **Never run it without these flags**: with none it applies balanced and gate, and its summary says nobody chose them. Write any advanced answers into `.crysk/config.json` (and `.cryskignore`) afterwards. The summary `setup --ci` printed predates those edits, so when there were any, show the human the effective settings from `npx -y crysk config` instead. Otherwise show the printed summary, including any `Changed` and `Kept existing` lines: on a re-run (for example `--force` to refresh an old workflow) only the groups a flag names are overwritten, and keys nobody chose stay as the file had them; the workflow keeps its old `mode` and `budget-usd` unless `--ci-mode` or `--billing` / `--budget-usd` is passed. In a terminal, every question defaults to the repository's current value. Details: `references/ci-admission.md`.
112
+
113
+ ## Execution Steps
114
+
115
+ 1. **Inspect repo:** `git rev-parse --is-inside-work-tree`, `git remote get-url origin`, `gh auth status`.
116
+ 2. **Credential path:** Claude-only → skip OpenCode. OpenCode or mix → **read `references/opencode-ci.md`** and execute it (models per role, one secret per provider, the providers variable).
117
+ 3. **Claude secret (if used):** `gh secret set CRYSK_CLAUDE_OAUTH_TOKEN` or `CRYSK_CLAUDE_API_KEY` (secure input, never print).
118
+ 4. **Workflow:** run the interview above, then `npx -y crysk setup --ci` with its flags. It writes `.github/workflows/crysk.yml` (or rewrites an existing `pr-hero.yml` in place) and the level keys in `.crysk/config.json`, and its next steps print the `gh secret set` / `gh variable set` commands for the person's `~/.crysk/config.json` (models, credentials, OpenCode providers); run the ones the human agrees to. Confirm `checks: write` and `actions: read`, both `pull_request` and `issue_comment` triggers, the `crysk-secrets: |` block and the `models` / `credentials` lines. `--force` if an old template lacks them (an old `credentials` job, a missing `issue_comment` trigger, or `claude-token` / `routing` lines mean it predates the current workflow).
119
+ 5. **Review instructions (optional, recommended before the first review):** if the default branch has neither a root `REVIEW.md` nor `.crysk/gotchas.md`, run `npx -y crysk init` in the clone; it scaffolds `REVIEW.md` (an existing `.crysk/gotchas.md` is kept, and no `REVIEW.md` is written beside it). The agent writes the facts from the repository it has in context, not from the template: the deliberate oddity that looks like a bug, the invariant enforced outside the diff, the ownership rule a newcomer would break. The hunters and the refuter read the file as facts; the "Not blocking here" section is applied only by the materiality judge (`materiality_gate: true`, blocking findings only, and only to style, naming, test-hygiene, generated-code and dev-script findings), so fill it only when the human asked for that gate, and delete it otherwise. Delete the `human-attention-required` marker line (Crysk refuses to review while it is there), then commit the file to the default branch. With no file the review runs on the default guidance; an empty or scaffold file fails the run `CRYSK-GOTCHAS-MISSING`.
120
+ 6. **Require the check:** in branch protection, require the `crysk` status check (the gate), not the `review` job. The legacy `pr-hero` status is no longer posted, so a repository that still requires it is blocked until the rule moves to `crysk`. A private repository on GitHub Free cannot require status checks (HTTP 403): report that the gate is advisory there. With `gh`, and only after asking the human: read the current protection first (`gh api repos/<o>/<r>/branches/<default>/protection`), because the PUT replaces all of it; then `gh api -X PUT repos/<o>/<r>/branches/<default>/protection` with `required_status_checks` contexts `["crysk"]`.
121
+ 7. **Advanced settings:** write the answers from interview question 5 into `.crysk/config.json` (and `.cryskignore`), including `post_min_severity` when they chose a floor other than `warning` and `materiality_gate: true` only when they said yes; commit both to the default branch, and to any other branch PRs target (CI reads the config from the PR's base branch, so it applies from the next PR after the merge). **No `models` or `credentials` key there** (the repo parser refuses them). `npx -y crysk config` to verify.
122
+ 8. **Verify:** `npx -y crysk doctor`. `git status`. Confirm no echoed secret, and when OpenCode is on, that every `opencode:` model id in `CRYSK_MODELS` is one `opencode models <provider>` lists and each provider's token is in `CRYSK_OPENCODE_PROVIDERS`.
123
+ 9. **Deploy:** Offer commit. Open a **same-repo** test PR (forks skip).
124
+
125
+ ## Output Contract
126
+
127
+ Report:
128
+ - Secret status (set or manual link). Names only: which `CRYSK_*` secrets exist (`gh secret list`). Never values.
129
+ - Models (if set): the `CRYSK_MODELS` and `CRYSK_CREDENTIALS` JSON (no credentials in them), and for OpenCode the `CRYSK_OPENCODE_PROVIDERS` tokens and that each model id matches `opencode models <provider>`.
130
+ - Workflow path (`crysk.yml`, or the pre-rename `pr-hero.yml`; both present means two reviews per PR, delete one) and whether `checks: write`, `actions: read`, the `issue_comment` trigger, the `crysk-secrets` block and the `models` / `credentials` lines are present, with no removed input left.
131
+ - The review settings summary `setup --ci` printed (level, gate, budget, advanced settings), and which ones the human chose, including the posting floor (`post_min_severity`) and whether `materiality_gate` is on. Confirm repo `.crysk/config.json` has no `models` or `credentials` key.
132
+ - `npx -y crysk doctor` / `npx -y crysk config` outcome.
133
+ - Whether the default branch has a real `REVIEW.md` or `.crysk/gotchas.md` (no `human-attention-required` marker line), or neither (reviews run on the default guidance).
134
+ - Whether `crysk` is a required check (or only the legacy `pr-hero`, which should move to `crysk`), or that the repository cannot require one (private repository on GitHub Free).
135
+ - Next steps: merge the workflow to the default branch (the comment trigger needs it there), open a same-repo test PR, when to turn off observe-only. If CI skipped, the override is `gh pr comment <n> --body "/crysk review"`.
136
+
137
+ ## References
138
+
139
+ - `assets/workflow.yml` — the one review workflow (`pull_request` + `issue_comment` for `/crysk review`).
140
+ - `assets/admission-config.example.json` — starter `.crysk/config.json`.
141
+ - `references/ci-admission.md` — admission keys, modes, rollout, ledger.
142
+ - `references/opencode-ci.md` — OpenCode secrets and variables, models per role, pin, openai vs deepseek.
143
+ - `docs/github-actions.md` — full CI integration docs.
@@ -0,0 +1,78 @@
1
+ # Crysk triage adjudicator — system prompt
2
+
3
+ You are a fresh, isolated adjudicator. You are given exactly three things and nothing else:
4
+
5
+ 1. **The finding** — Crysk's claim, its path/line, and its filed severity/tier.
6
+ 2. **The author's argument** — the case the PR's own coding agent is making to have the finding
7
+ dismissed, deferred, or reclassified.
8
+ 3. **Read-only access to the repository**, at the PR's current head.
9
+
10
+ You do NOT have, and must never be given, the author's reasoning context — its conversation
11
+ history, its scratch notes, or anything explaining WHY it believes what it argues. You were spawned
12
+ precisely because you have nothing to defend. That is your entire value. If you find yourself
13
+ reasoning about what the author "probably meant" or extending charity beyond what the repository
14
+ itself shows, you have already failed at the one job isolation exists to do.
15
+
16
+ ## Your job
17
+
18
+ Rule on the author's argument against the finding, using the repository as your only source of
19
+ truth. Return exactly one of:
20
+
21
+ - **`upheld`** — the author is right. You independently verified, by reading the repository, the
22
+ exact claim the author made (the code already handles it, the fix is genuinely present, the
23
+ scope argument holds, or the misclassification claim is correct).
24
+ - **`rejected`** — the author is not right. The finding stands as Crysk filed it.
25
+ - **`inconclusive`** — neither is proven. The repository does not give you enough to independently
26
+ confirm OR refute the author's claim.
27
+
28
+ `inconclusive` exists on purpose: it is not a fallback for laziness, it is a real, distinct verdict.
29
+ It exists so that whoever chooses what to cite — the author — can never force you into a binary
30
+ between two answers you cannot actually stand behind. If the evidence does not settle it, say so.
31
+ A finding left `inconclusive` stays OPEN; it is not a quiet win for the author.
32
+
33
+ ## The burden of proof
34
+
35
+ The burden of proof is on whoever wants the finding gone — the author, in every case where you are
36
+ invoked (you are never spawned for `applied`). It is discharged by **citing code you can verify by
37
+ reading the repository**, never by asserting intent.
38
+
39
+ - "I did it on purpose" is not evidence.
40
+ - "This is expected behavior" is not evidence.
41
+ - "This line already covers it, here" — followed by a real path:line you can open and confirm —
42
+ IS evidence.
43
+ - A scope argument for `deferred` needs the same discipline: confirm the finding is real (you are
44
+ not being asked to accept "out of scope" as a way to skip verifying the defect itself), and
45
+ confirm the argument for why it does not belong in this PR is not simply "I don't want to fix
46
+ it now."
47
+ - A `misclassified` argument needs you to independently check the field the author says is wrong
48
+ (severity, tier, or causal disposition) against what the repository actually shows — not just
49
+ agree that the author's stated field sounds more plausible.
50
+
51
+ ## A persuasive argument is not evidence — say this to yourself before every verdict
52
+
53
+ This is the single most important thing this document tells you. An isolated judge, built to catch
54
+ an error, can still let it through because the argument in front of it is well-written and
55
+ confident, without ever checking it against the repository.
56
+
57
+ Do not let that happen here. A well-argued case is not a cited one. Before returning `upheld`, ask
58
+ yourself: did I independently confirm this by reading the repository myself, at the specific
59
+ path:line cited, or did I just find the argument convincing? If it is the second, the correct
60
+ verdict is `rejected` or `inconclusive` — never `upheld` on persuasion alone.
61
+
62
+ ## What you never do
63
+
64
+ - You never see or ask for the author's own reasoning context. If it is offered to you, refuse it
65
+ and rule on the finding, the argument as stated, and the repository only.
66
+ - You never write code, open a PR, or take any action beyond returning your verdict and reasoning.
67
+ - You never split your verdict or hedge between two of the three values — pick exactly one.
68
+ - You never treat "the author sounds confident" as evidence of anything.
69
+
70
+ ## Output
71
+
72
+ Return your verdict word (`upheld`, `rejected`, or `inconclusive`) and the specific evidence —
73
+ path:line citations you personally checked — that led you there, in the format the request asks for.
74
+ When the request fixes no format and your verdict is `inconclusive`, state exactly what would have
75
+ settled it and why the repository does not currently show it.
76
+
77
+ Your verdict word is recorded exactly as you return it and is never paraphrased or softened. That
78
+ record is what lets a later run tell a settled finding from an unsettled one.
@@ -0,0 +1,128 @@
1
+ # CI review admission — setup reference
2
+
3
+ Read this when configuring `.crysk/config.json` during CI setup. Full operator docs:
4
+ `docs/github-actions.md` (section **CI review admission**).
5
+
6
+ ## Where config lives
7
+
8
+ - **Repository** `.crysk/config.json` on the default branch — authoritative.
9
+ - NOT in the PR branch worktree. Authors cannot change admission to suppress their own PR.
10
+ - Verify with `crysk config` after editing.
11
+
12
+ ## Keys and defaults
13
+
14
+ | Key | Default | Meaning |
15
+ |---|---|---|
16
+ | `ci_review_policy` | `risk_aware` | When to spend on `synchronize` pushes |
17
+ | `ci_max_attempts` | `2` | Automatic attempt budget per PR |
18
+ | `ci_rereview_min_score` | `4` | Prior score floor for re-review |
19
+ | `ci_blocking_weight` | `2` | Score weight per blocking-tier finding |
20
+ | `ci_advisory_weight` | `1` | Score weight per advisory-tier finding |
21
+ | `ci_trusted_actors` | `[]` | Extra GitHub logins for authoritative markers (+ `GITHUB_ACTOR`) |
22
+ | `ci_admission_observe_only` | `false` | Log would-be skip/manual decisions but always run |
23
+ | `max_verification_steps` | `8` | Max prior open findings verified per re-review (`0` pauses verification; capped key) |
24
+
25
+ `ci_max_reviews` is legacy — use `ci_max_attempts` (same fallback).
26
+
27
+ **Score:** `blocking × ci_blocking_weight + advisory × ci_advisory_weight`
28
+
29
+ **How a re-review depends on the previous pass:**
30
+ - **Whether it runs (admission):** in `risk_aware` and `thresholded` modes, the previous review's finding score (`blocking × 2 + advisory × 1` by default) is compared against `ci_rereview_min_score`, bounded by `ci_max_attempts` total automatic passes per PR.
31
+ - **What it does when it runs:** discovery is incremental by default (hunters examine only commits since the last completed review's head SHA; `/crysk review --full` widens to the full PR), and up to `max_verification_steps` verifier steps check whether prior open findings were fixed by the new push.
32
+
33
+ ## Review levels (what setup --ci asks)
34
+
35
+ `setup --ci` (and `ci init`) asks for a level and always writes its keys. An agent asks the human and passes `--level`, `--ci-mode`, `--billing`, `--max-changed-lines` and `--budget-usd`; a terminal user gets the same questions from the CLI; with neither, `balanced` and `gate` apply and the summary says nobody chose them.
36
+
37
+ | Level | `ci_review_policy` | `ci_max_attempts` | `ci_rereview_min_score` | `max_verification_steps` |
38
+ |---|---|---|---|---|
39
+ | `minimal` | `once_per_pr` | 1 | (unset) | 8 |
40
+ | `balanced` (default) | `risk_aware` | 2 | 4 | 8 |
41
+ | `thorough` | `every_push` | 4 | (unset) | 8 |
42
+ | `manual` | `manual_only` | 1 | (unset) | 8 |
43
+
44
+ Billing: `--billing subscription` writes no `budget-usd` (a subscription spends quota, not dollars, and CI applies no ceiling while the run uses the subscription and no `CRYSK_OPENCODE_*` secret builds an OpenCode auth file; a run on `CRYSK_CLAUDE_API_KEY`, which `credentials.claude` decides, or with an OpenCode auth file is metered; an explicit 0 would warn on every run and outlive a later move to an API key); `--billing api` writes `--budget-usd` or the $12 default. `--budget-usd` alone implies `api`, and `--budget-usd` with `subscription` is refused.
45
+
46
+ Re-runs: a group (the level's keys, or `max_changed_lines`) is overwritten only when someone chose it this run (a flag or a terminal answer); otherwise it fills the file only if absent, and setup prints `Changed` and `Kept existing` lines. A `--force` refresh keeps the old workflow's `mode` and `budget-usd` unless a flag names them, and in a terminal every question defaults to the current value (a tuned level that matches no preset gets a "Keep current settings" option).
47
+
48
+ Size threshold: `max_changed_lines` is always written (default 4000, `--max-changed-lines`, `0` = no limit). Unlike the budget it applies on any billing: left unset, a subscription route reviews a PR of any size.
49
+
50
+ Posting floor: setup writes `post_min_severity: "warning"` only when the repo config has no value, so a re-run never replaces a chosen floor. `warning` hides advisory suggestions, `blocking` hides every advisory finding, `suggestion` (or unset) posts everything. Hidden findings are counted in the summary comment. The gate is unchanged, since a blocking finding always posts; admission scores only posted findings, so a hidden one never triggers a re-review.
51
+
52
+ Materiality gate: `materiality_gate: true` (opt-in; setup never writes it) sends each blocking finding the safety guard does not protect to an isolated sonnet judge (no tools, no MCP, PR title + claim + a ±25-line code window as untrusted data) that applies Crysk's written posting policy. When the repository has review instructions (root `REVIEW.md`, else `.crysk/gotchas.md`), the judge also applies their "Not blocking here" rules, but only to style, naming, test-hygiene, generated-code and dev-script findings: it never demotes a logic, correctness, data, contract or security finding, whatever the file says, and nothing filters advisory findings by it. An `immaterial` verdict demotes the finding to advisory with the reason in its comment, so the gate stops counting it; with `post_min_severity: "blocking"` it is not posted at all. Findings about security, credentials, permissions, sandboxing, injection or data loss are never sent and never demoted, including when consolidation merged them into another finding. Any failure (spawn, parse, unsafe input, unsupported route, ceiling) leaves the finding blocking. The key is capped: a global config can turn it off for every repo. Every run's `pipeline.json` carries a `materiality` record (`status`, `judged`, `demoted`, `protected`). Known limit: a finding that blocked on an earlier push still counts toward the gate on a re-review, so the effect shows mostly on first reviews and on new findings in later rounds.
53
+
54
+ ## Policy modes
55
+
56
+ | Mode | Use when |
57
+ |---|---|
58
+ | `risk_aware` | Default — re-review on risky delta OR score ≥ floor |
59
+ | `thresholded` | Score-only; ignore path risk classification |
60
+ | `once_per_pr` | One automatic review; later pushes reported as not reviewed |
61
+ | `every_push` | Review every push (still capped by `ci_max_attempts`) |
62
+ | `manual_only` | No automatic re-review; operator override only |
63
+
64
+ ## Outcomes users see
65
+
66
+ | Outcome | Meaning |
67
+ |---|---|
68
+ | Review runs | Normal pipeline |
69
+ | **Skipped** | Push did not justify spend (same head, low score, docs-only delta, etc.) — **not** “clean” |
70
+ | **Automatic reviews done** | Budget exhausted or `manual_only` — a red verdict carries; a green one, or a red whose blocking findings are all answered, is held `pending` until `/crysk review` runs another round or `/crysk override` merges it unverified |
71
+
72
+ Skipped and automatic-reviews-done posts include admission metadata in the step summary. The automatic-reviews-done
73
+ comment explains the end of the budget by the repository's rules (policy, attempts used, last reviewed head) and how to
74
+ ask for more rounds.
75
+
76
+ ## Durable ledger
77
+
78
+ - Check Runs named `crysk/ci-admission` on the reviewed commit (`pr-hero/ci-admission` on a commit first reviewed by an older release; both are read).
79
+ - Requires workflow permission **`checks: write`** (template includes it).
80
+ - Requires **`actions: read`** too: the gate lists this workflow's past runs, which a private repo refuses without it (HTTP 403).
81
+ - PR comments are presentation. The ledger counts a run that reached the provider (completed, failed, or still provider-started) and an admission skip. It does not count a run that yielded to an in-flight review, a size or budget gate skip, or a cancelled row (#164). A workflow run that concluded success or failure is dropped from the attempt count only when every ledger row on its head is a gate skip or a yield, because both are written before any provider spend. A cancelled row is not that proof: the signal handler that writes it can run after the provider started, so a run killed by `timeout-minutes` (concluded `failure`) still counts. A run whose row is still `reserved` stays counted too, because the provider-started write is best-effort and the run may have spent anyway.
82
+
83
+ ## Rollout (recommended)
84
+
85
+ 1. Ship workflow + secrets first.
86
+ 2. Add `.crysk/config.json` with `"ci_admission_observe_only": true`.
87
+ 3. Open a test PR; read `::notice::` lines for would-be skip/manual decisions.
88
+ 4. Set `ci_admission_observe_only` to `false` when behavior matches intent.
89
+
90
+ ## Example config
91
+
92
+ ```json
93
+ {
94
+ "ci_review_policy": "risk_aware",
95
+ "ci_max_attempts": 2,
96
+ "ci_rereview_min_score": 4,
97
+ "ci_blocking_weight": 2,
98
+ "ci_advisory_weight": 1,
99
+ "ci_trusted_actors": [],
100
+ "ci_admission_observe_only": true
101
+ }
102
+ ```
103
+
104
+ ## Manual override
105
+
106
+ Comment `/crysk review` on the pull request. GitHub Actions runs the review with `--force`. Posting the comment does not review anything on the machine that sends it:
107
+
108
+ ```bash
109
+ gh pr comment <n> --body "/crysk review"
110
+ ```
111
+
112
+ `/crysk review --full` also re-discovers the whole range. The comment must be exactly one of those two, and it works only once the workflow file (`crysk.yml`, or `pr-hero.yml` in a repo set up before the rename; with its `issue_comment` trigger) is on the default branch.
113
+
114
+ It bypasses the size gate, the admission rules (same commit, `once_per_pr`, score, low-risk delta, exhausted attempts, `manual_only`), and the budget ceiling. It does not reset the ledger.
115
+
116
+ Who can force: anyone with write access to the repository; a comment from anyone else is refused. A fork PR is reviewed only this way, since its own pushes are skipped. `gh run rerun` on a skipped run re-evaluates the gates and does not force.
117
+
118
+ A workflow scaffolded before the comment trigger has no `issue_comment` listener. There, use the legacy `gh workflow run pr-hero-force.yml -f pr=<n>`, or re-scaffold with `crysk ci init --force`.
119
+
120
+ A local agent posts the comment. It does not run `crysk review --pr <n> --force` when the review should happen in CI.
121
+
122
+ A red gate with blocking findings that the team accepts is unlocked by commenting exactly `/crysk override` on the pull request, not by `/crysk review`. In gate mode a same-head review re-runs the same blocking count and leaves the `failure` in place, so the gate clears only when a pushed fix is verified gone or the override is posted:
123
+
124
+ ```bash
125
+ gh pr comment <n> --body "/crysk override"
126
+ ```
127
+
128
+ The override sets the `crysk` status on that head to `success` with no review, no spend, and no credential, and only a user with write or admin access may post it. Each override is recorded: the status names who acted, and a `<!-- crysk-override` comment names who, which head, and when. It is valid only for the head it names, so a new push or a later `/crysk review` on that head replaces it, and it works only on pull requests from this repository, never on forks.