crysk 0.0.0 → 0.3.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.
- package/LICENSE +176 -0
- package/README.md +611 -3
- package/bin/pr-hero.js +166 -0
- package/config/models/anthropic.json +5 -0
- package/dist/SKILL-7e3725zn.md +496 -0
- package/dist/SKILL-7q35wcaz.md +66 -0
- package/dist/SKILL-9at22381.md +74 -0
- package/dist/SKILL-ex2hxxh3.md +134 -0
- package/dist/SKILL-y8rv8msh.md +134 -0
- package/dist/SKILL-ygka1bs0.md +515 -0
- package/dist/adjudicator-dtg2axnh.md +86 -0
- package/dist/admission-config.example-a9vqmmad.json +9 -0
- package/dist/ci-admission-camfbx2b.md +122 -0
- package/dist/ci-admission-qk9r9taq.md +124 -0
- package/dist/cli.js +42501 -0
- package/dist/consolidate-ac0mnfyj.md +24 -0
- package/dist/deep-review-lifecycle-m698ybjp.md +362 -0
- package/dist/deep-review-logic-a6b1gczf.md +156 -0
- package/dist/deep-review-parity-0ec904db.md +120 -0
- package/dist/deep-review-reliability-qyakbjb9.md +125 -0
- package/dist/deep-review-resilience-3tz8y26e.md +118 -0
- package/dist/index.js +20190 -0
- package/dist/opencode-ci-7b0be64p.md +141 -0
- package/dist/review-refuter-j4e9gezy.md +71 -0
- package/dist/scout-yvp153q7.md +140 -0
- package/dist/summarizer-zca44nxa.md +18 -0
- package/dist/workflow-w1g9szna.yml +151 -0
- package/package.json +81 -4
- package/prompts/consolidate.md +24 -0
- package/prompts/default/PROVENANCE.md +18 -0
- package/prompts/default/deep-review-lifecycle.md +362 -0
- package/prompts/default/deep-review-logic.md +156 -0
- package/prompts/default/deep-review-parity.md +120 -0
- package/prompts/default/deep-review-reliability.md +125 -0
- package/prompts/default/deep-review-resilience.md +118 -0
- package/prompts/default/review-refuter.md +71 -0
- package/prompts/scout.md +140 -0
- package/prompts/summarizer.md +18 -0
- package/skills/crysk/SKILL.md +74 -0
- package/skills/crysk-ci-setup/SKILL.md +134 -0
- package/skills/crysk-ci-setup/assets/admission-config.example.json +9 -0
- package/skills/crysk-ci-setup/assets/workflow.yml +151 -0
- package/skills/crysk-ci-setup/references/ci-admission.md +124 -0
- package/skills/crysk-ci-setup/references/opencode-ci.md +141 -0
- package/skills/crysk-loop/SKILL.md +515 -0
- package/skills/crysk-loop/adjudicator.md +86 -0
- package/skills/crysk-pr/SKILL.md +66 -0
- package/src/agent-env.ts +1084 -0
- package/src/asset-manifest.ts +83 -0
- package/src/assets.d.ts +6 -0
- package/src/assets.ts +183 -0
- package/src/brand-paths.ts +155 -0
- package/src/brand.ts +255 -0
- package/src/ci/admission-ledger.ts +350 -0
- package/src/ci/classify-error.ts +73 -0
- package/src/ci/cli-record.ts +271 -0
- package/src/ci/force-comment.ts +39 -0
- package/src/ci/gates.ts +945 -0
- package/src/ci/outcome.ts +2181 -0
- package/src/ci/override.ts +187 -0
- package/src/ci/publish.ts +1639 -0
- package/src/ci/reporter.ts +626 -0
- package/src/ci/review-admission.ts +910 -0
- package/src/ci/review-levels.ts +310 -0
- package/src/ci/review-policy.ts +18 -0
- package/src/ci/review-risk.ts +184 -0
- package/src/ci/setup.ts +844 -0
- package/src/ci/trigger.ts +1353 -0
- package/src/cli.ts +348 -0
- package/src/commands/activity.ts +67 -0
- package/src/commands/ci-setup-questions.ts +397 -0
- package/src/commands/ci-setup.ts +381 -0
- package/src/commands/config.ts +99 -0
- package/src/commands/doctor.ts +108 -0
- package/src/commands/init.ts +139 -0
- package/src/commands/mcp.ts +10 -0
- package/src/commands/menu.ts +129 -0
- package/src/commands/post.ts +302 -0
- package/src/commands/skills.ts +83 -0
- package/src/commands/status.ts +173 -0
- package/src/commands/triage.ts +342 -0
- package/src/commands/uninstall.ts +37 -0
- package/src/commands/upgrade.ts +214 -0
- package/src/commands/usage.ts +98 -0
- package/src/compare/compare.ts +28 -0
- package/src/compare/floor-test.ts +471 -0
- package/src/compare/martian-adapter.ts +80 -0
- package/src/config/config.ts +267 -0
- package/src/corpus/corpus.ts +1094 -0
- package/src/corpus/preflight.ts +1789 -0
- package/src/diversity/accounting.ts +90 -0
- package/src/diversity/adjudication.ts +145 -0
- package/src/diversity/admission.ts +60 -0
- package/src/diversity/benchmark.ts +195 -0
- package/src/diversity/clustering.ts +285 -0
- package/src/diversity/errors.ts +7 -0
- package/src/diversity/identity.ts +285 -0
- package/src/diversity/index.ts +11 -0
- package/src/diversity/pipeline-integration.ts +448 -0
- package/src/diversity/projection.ts +57 -0
- package/src/diversity/self-contained.ts +68 -0
- package/src/diversity/target-validation.ts +179 -0
- package/src/doctor-migration.ts +209 -0
- package/src/doctor.ts +723 -0
- package/src/errors.ts +83 -0
- package/src/execution/admission.ts +75 -0
- package/src/execution/atomic-write.ts +35 -0
- package/src/execution/attempt-evidence.ts +415 -0
- package/src/execution/bucket-id.ts +136 -0
- package/src/execution/concurrency-limiter.ts +175 -0
- package/src/execution/contracts.ts +443 -0
- package/src/execution/failure-classification.ts +42 -0
- package/src/execution/failure-policy.ts +240 -0
- package/src/execution/harness.ts +2548 -0
- package/src/execution/settlement.ts +348 -0
- package/src/execution/spawned-process.ts +66 -0
- package/src/execution/spend-limiter.ts +424 -0
- package/src/execution/step-artifacts.ts +55 -0
- package/src/execution/usage-normalized.ts +469 -0
- package/src/git/git.ts +396 -0
- package/src/git/identity.ts +64 -0
- package/src/git/refs.ts +140 -0
- package/src/home-preflight.ts +443 -0
- package/src/home.ts +243 -0
- package/src/ignore-file.ts +336 -0
- package/src/ignore-read.ts +118 -0
- package/src/index.ts +34 -0
- package/src/legacy-launchd.ts +29 -0
- package/src/mcp/mcp.ts +150 -0
- package/src/mcp/preflight.ts +407 -0
- package/src/menu-context.ts +192 -0
- package/src/model/catalog.ts +251 -0
- package/src/model/exec-snapshots.ts +390 -0
- package/src/model/free-discovery.ts +302 -0
- package/src/model/provider-capabilities.ts +814 -0
- package/src/model/routing.ts +600 -0
- package/src/pr/admission.ts +984 -0
- package/src/pr/answered-findings.ts +169 -0
- package/src/pr/ci-admission-gate.ts +743 -0
- package/src/pr/ci-publish.ts +76 -0
- package/src/pr/discovery.ts +432 -0
- package/src/pr/inline.ts +507 -0
- package/src/pr/plan.ts +366 -0
- package/src/pr/posting.ts +115 -0
- package/src/pr/pr-status.ts +845 -0
- package/src/pr/pr.ts +3642 -0
- package/src/pr/preflight.ts +1031 -0
- package/src/pr/publish-outcome.ts +361 -0
- package/src/pr/range.ts +119 -0
- package/src/pr/reverts-preflight.ts +606 -0
- package/src/pr/reverts.ts +377 -0
- package/src/pr/review-pr.ts +927 -0
- package/src/pr/status.ts +154 -0
- package/src/pr/target.ts +388 -0
- package/src/pr/teardown.ts +437 -0
- package/src/pr/worktree-setup.ts +60 -0
- package/src/production-runtime.ts +1877 -0
- package/src/progress.ts +487 -0
- package/src/rereview/adjudicate.ts +89 -0
- package/src/rereview/classify.ts +362 -0
- package/src/rereview/identity.ts +211 -0
- package/src/rereview/plan.ts +308 -0
- package/src/rereview/prepare.ts +1025 -0
- package/src/rereview/state.ts +767 -0
- package/src/rereview/verify.ts +241 -0
- package/src/review/boundary.ts +105 -0
- package/src/review/consolidate.ts +246 -0
- package/src/review/dedupe.ts +368 -0
- package/src/review/drafts.ts +448 -0
- package/src/review/findings-conformance.ts +120 -0
- package/src/review/findings.ts +714 -0
- package/src/review/pipeline.ts +3977 -0
- package/src/review/preflight.ts +3575 -0
- package/src/review/prompt-set.ts +177 -0
- package/src/review/proof-refs.ts +187 -0
- package/src/review/report.ts +1821 -0
- package/src/review/review.ts +490 -0
- package/src/review/root-cause.ts +120 -0
- package/src/review/route-preflight.ts +289 -0
- package/src/review/run.ts +601 -0
- package/src/review/scout.ts +323 -0
- package/src/review/size-gate.ts +595 -0
- package/src/review/spec.ts +235 -0
- package/src/review/step-runner.ts +233 -0
- package/src/runner-authority.ts +596 -0
- package/src/security/binding-policy.ts +115 -0
- package/src/security/credential-broker.ts +773 -0
- package/src/security/evidence-redaction.ts +62 -0
- package/src/security/execution-authority.ts +27 -0
- package/src/security/redact.ts +71 -0
- package/src/security/workspace-read-broker.ts +466 -0
- package/src/server/client.ts +190 -0
- package/src/server/preflight.ts +217 -0
- package/src/server/server.ts +327 -0
- package/src/signal-handler.ts +50 -0
- package/src/store/activity.ts +413 -0
- package/src/store/backfill-preflight.ts +49 -0
- package/src/store/backfill.ts +141 -0
- package/src/store/gc-preflight.ts +206 -0
- package/src/store/gc.ts +424 -0
- package/src/store/metrics-preflight.ts +229 -0
- package/src/store/metrics.ts +236 -0
- package/src/store/preflight.ts +748 -0
- package/src/store/store.ts +693 -0
- package/src/system-tools.ts +355 -0
- package/src/transport-registry.ts +1124 -0
- package/src/transports/claude-code-cli.ts +1348 -0
- package/src/transports/opencode-admission.ts +515 -0
- package/src/transports/opencode-client.ts +3328 -0
- package/src/transports/opencode-evidence.ts +557 -0
- package/src/transports/opencode-mcp.ts +248 -0
- package/src/transports/opencode-sdk.ts +2294 -0
- package/src/transports/opencode-server.ts +535 -0
- package/src/triage/adjudication.ts +113 -0
- package/src/triage/reply.ts +125 -0
- package/src/triage/triage.ts +255 -0
- package/src/ui/activity.ts +173 -0
- package/src/ui/config-edit.ts +816 -0
- package/src/ui/config.ts +462 -0
- package/src/ui/menu.ts +1325 -0
- package/src/ui/plan.ts +1039 -0
- package/src/ui/primitives.ts +300 -0
- package/src/ui/progress.ts +298 -0
- package/src/ui/result.ts +552 -0
- package/src/ui/review-menu.ts +312 -0
- package/src/ui/select.ts +528 -0
- package/src/ui/tree.ts +178 -0
- package/src/uninstaller.ts +479 -0
- package/src/updater.ts +836 -0
- package/src/usage.ts +77 -0
- package/src/watch/preflight.ts +1389 -0
- package/src/watch/watch.ts +1235 -0
- package/src/wizard.ts +877 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { liveBlockingFindings } from "#pr/pr-status";
|
|
2
|
+
import { parseFindingMarker } from "#pr/preflight";
|
|
3
|
+
import { TIER_UNRECOVERABLE } from "#rereview/classify";
|
|
4
|
+
import { CI_ADJUDICATOR_LOGIN } from "#triage/adjudication";
|
|
5
|
+
import { parseTriageMarker } from "#triage/triage";
|
|
6
|
+
import { parsePrCommentMarker } from "#watch/preflight";
|
|
7
|
+
|
|
8
|
+
// budget-exhausted-carry S3-S5: whether every blocking finding of the reviewed head is answered, read when a
|
|
9
|
+
// skip carries a blocking red and no review is left to verify the fixes. Pure: the impure half (who may write
|
|
10
|
+
// to the repository) is the gate's, which passes its lookups in as `writers`.
|
|
11
|
+
|
|
12
|
+
// The blocking findings the read could see, and how many of them are still open. A finding is answered when
|
|
13
|
+
// its newest triage reply sits at the head it was posted on (the rule crysk status uses) and is `applied`, or
|
|
14
|
+
// is a `dismissed` the CI adjudicator upheld. `deferred` and `misclassified` stay open: they name a real
|
|
15
|
+
// finding, and only a fix or a human override may close one.
|
|
16
|
+
export interface AnsweredFindings {
|
|
17
|
+
blocking: number;
|
|
18
|
+
open: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface AnswerIssueComment {
|
|
22
|
+
id: number;
|
|
23
|
+
user: string;
|
|
24
|
+
body: string;
|
|
25
|
+
created_at?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface AnswerReviewComment extends AnswerIssueComment {
|
|
29
|
+
in_reply_to_id: number | null;
|
|
30
|
+
path?: string;
|
|
31
|
+
line?: number | null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function isTriageReply(body: string): boolean {
|
|
35
|
+
return parseTriageMarker(body) !== null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// The logins whose permission the gate must look up: every author of a triage reply.
|
|
39
|
+
export function triageReplyAuthors(
|
|
40
|
+
comments: readonly AnswerIssueComment[],
|
|
41
|
+
): string[] {
|
|
42
|
+
const authors = new Set<string>();
|
|
43
|
+
for (const comment of comments) {
|
|
44
|
+
if (isTriageReply(comment.body)) authors.add(comment.user);
|
|
45
|
+
}
|
|
46
|
+
return [...authors];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// WHY the CI bot is trusted for a finding or a summary: Crysk posts both as github-actions[bot], which only a
|
|
50
|
+
// workflow of this repository can write as. `trustedActors` (resolveCiTrustedActors) adds the configured
|
|
51
|
+
// writers; when it is undefined no author is known, and every author passes, as scanPostedFindingTiers does.
|
|
52
|
+
function trustedPoster(
|
|
53
|
+
user: string,
|
|
54
|
+
trustedActors: ReadonlySet<string> | undefined,
|
|
55
|
+
): boolean {
|
|
56
|
+
if (trustedActors === undefined) return true;
|
|
57
|
+
return user === CI_ADJUDICATOR_LOGIN || trustedActors.has(user);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function isGateInput(body: string): boolean {
|
|
61
|
+
return (
|
|
62
|
+
parseFindingMarker(body) !== null || parsePrCommentMarker(body) !== null
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// WHY a reply to a finding from an older head must be newer than the carried verdict: such a finding is live
|
|
67
|
+
// on the reviewed head through the summary's rows, so the review that wrote the verdict saw its reply and kept
|
|
68
|
+
// it. A reply from before that verdict is the claim the review already contradicted. A reply carries the
|
|
69
|
+
// head its finding was posted on (triage/reply.ts), so its time is the only thing that says it came after.
|
|
70
|
+
// A reply at the reviewed head itself always answers the review of that head.
|
|
71
|
+
function isStaleReply(
|
|
72
|
+
comment: AnswerIssueComment,
|
|
73
|
+
reviewedHead: string,
|
|
74
|
+
verdictAt: number | null,
|
|
75
|
+
): boolean {
|
|
76
|
+
const marker = parseTriageMarker(comment.body);
|
|
77
|
+
if (marker === null || marker.headSha === reviewedHead) return false;
|
|
78
|
+
const createdAt =
|
|
79
|
+
comment.created_at === undefined
|
|
80
|
+
? Number.NaN
|
|
81
|
+
: Date.parse(comment.created_at);
|
|
82
|
+
return (
|
|
83
|
+
verdictAt === null || Number.isNaN(createdAt) || createdAt <= verdictAt
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// The comments the read may trust, or null when one cannot be judged (S5: fail closed).
|
|
88
|
+
// WHY a triage reply needs write access (S4): it is the only thing that turns a red green here, and anyone
|
|
89
|
+
// can comment on a pull request. A reply from a login with no write access is dropped; a login whose
|
|
90
|
+
// permission did not read (null, or never looked up) fails the whole read closed.
|
|
91
|
+
function trustedComments<T extends AnswerIssueComment>(
|
|
92
|
+
comments: readonly T[],
|
|
93
|
+
writers: ReadonlyMap<string, boolean | null>,
|
|
94
|
+
trustedActors: ReadonlySet<string> | undefined,
|
|
95
|
+
reviewedHead: string,
|
|
96
|
+
verdictAt: number | null,
|
|
97
|
+
): T[] | null {
|
|
98
|
+
const kept: T[] = [];
|
|
99
|
+
for (const comment of comments) {
|
|
100
|
+
if (isTriageReply(comment.body)) {
|
|
101
|
+
if (isStaleReply(comment, reviewedHead, verdictAt)) continue;
|
|
102
|
+
const writer = writers.get(comment.user);
|
|
103
|
+
if (writer === undefined || writer === null) return null;
|
|
104
|
+
if (writer) kept.push(comment);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (
|
|
108
|
+
isGateInput(comment.body) &&
|
|
109
|
+
!trustedPoster(comment.user, trustedActors)
|
|
110
|
+
)
|
|
111
|
+
continue;
|
|
112
|
+
kept.push(comment);
|
|
113
|
+
}
|
|
114
|
+
return kept;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function answeredBlockingFindings(input: {
|
|
118
|
+
pr: number;
|
|
119
|
+
reviewedHead: string;
|
|
120
|
+
issueComments: readonly AnswerIssueComment[];
|
|
121
|
+
reviewComments: readonly AnswerReviewComment[];
|
|
122
|
+
trustedActors: ReadonlySet<string> | undefined;
|
|
123
|
+
writers: ReadonlyMap<string, boolean | null>;
|
|
124
|
+
// When the carried verdict was written (its commit status's created_at), or null when unknown.
|
|
125
|
+
verdictAt: string | null;
|
|
126
|
+
}): AnsweredFindings | null {
|
|
127
|
+
const parsedAt =
|
|
128
|
+
input.verdictAt === null ? Number.NaN : Date.parse(input.verdictAt);
|
|
129
|
+
const verdictAt = Number.isNaN(parsedAt) ? null : parsedAt;
|
|
130
|
+
const issueComments = trustedComments(
|
|
131
|
+
input.issueComments,
|
|
132
|
+
input.writers,
|
|
133
|
+
input.trustedActors,
|
|
134
|
+
input.reviewedHead,
|
|
135
|
+
verdictAt,
|
|
136
|
+
);
|
|
137
|
+
const reviewComments = trustedComments(
|
|
138
|
+
input.reviewComments,
|
|
139
|
+
input.writers,
|
|
140
|
+
input.trustedActors,
|
|
141
|
+
input.reviewedHead,
|
|
142
|
+
verdictAt,
|
|
143
|
+
);
|
|
144
|
+
if (issueComments === null || reviewComments === null) return null;
|
|
145
|
+
const findings = liveBlockingFindings({
|
|
146
|
+
pr: input.pr,
|
|
147
|
+
head: input.reviewedHead,
|
|
148
|
+
nowMs: 0,
|
|
149
|
+
statuses: [],
|
|
150
|
+
issueComments,
|
|
151
|
+
reviewComments,
|
|
152
|
+
});
|
|
153
|
+
// S5: a finding whose tier could not be read is blocking only by fail-closed default; it cannot be
|
|
154
|
+
// the evidence that unlocks the gate.
|
|
155
|
+
if (findings.some((finding) => finding.tier === TIER_UNRECOVERABLE))
|
|
156
|
+
return null;
|
|
157
|
+
let open = 0;
|
|
158
|
+
for (const finding of findings) {
|
|
159
|
+
const triage = finding.triage;
|
|
160
|
+
const answered =
|
|
161
|
+
triage !== null &&
|
|
162
|
+
finding.head !== null &&
|
|
163
|
+
triage.head === finding.head &&
|
|
164
|
+
(triage.tag === "applied" ||
|
|
165
|
+
(triage.tag === "dismissed" && finding.ci_verdict === "upheld"));
|
|
166
|
+
if (!answered) open++;
|
|
167
|
+
}
|
|
168
|
+
return { blocking: findings.length, open };
|
|
169
|
+
}
|