@attalabs/vinaya 0.39.0 → 0.41.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 +9 -9
- package/aeg-root/contracts/developer-reviewer.md +2 -2
- package/aeg-root/contracts/planner-developer.md +5 -5
- package/aeg-root/enforcement.md +22 -22
- package/aeg-root/process.md +4 -4
- package/aeg-root/roles/archivist.md +1 -1
- package/aeg-root/roles/developer/reference.md +7 -1
- package/aeg-root/roles/developer.md +1 -1
- package/aeg-root/roles/planner/reference.md +18 -5
- package/aeg-root/roles/principal.md +1 -1
- package/aeg-root/roles/reviewer.md +3 -3
- package/aeg-root/roles/security.md +4 -4
- package/aeg-root/roles/tranche-archivist.md +2 -2
- package/aeg-root/skills/aeg/SKILL.md +1 -1
- package/aeg-root/state-machine.md +10 -15
- package/aeg-root/templates/brief-template.md +5 -2
- package/aeg-root/templates/decision-record-template.md +38 -0
- package/aeg-root/templates/issue-rationale-template.md +1 -1
- package/aeg-root/tranche-model.md +1 -1
- package/dist/checks/bin/check-body-bare-digits.js +1974 -354
- package/dist/checks/bin/check-branch-topology.js +1296 -243
- package/dist/checks/bin/check-brief-shape.js +2038 -460
- package/dist/checks/bin/check-changeset-coverage.js +2411 -564
- package/dist/checks/bin/check-ci-shard-coverage.js +12391 -15
- package/dist/checks/bin/check-closes-n.js +1296 -243
- package/dist/checks/bin/check-coherence.js +1914 -1155
- package/dist/checks/bin/check-dead-branch-push.js +1242 -230
- package/dist/checks/bin/check-dispatch-readiness.js +2222 -460
- package/dist/checks/bin/check-doc-claims.js +2233 -260
- package/dist/checks/bin/check-doc-coverage-push.js +2436 -550
- package/dist/checks/bin/check-doc-coverage.js +2434 -552
- package/dist/checks/bin/check-doctrine-no-procedures.js +1776 -353
- package/dist/checks/bin/check-doctrine-portability.js +2408 -561
- package/dist/checks/bin/check-evidence-fresh.js +2370 -508
- package/dist/checks/bin/check-exec-bits.js +2407 -560
- package/dist/checks/bin/check-first-push-dispatch.js +1984 -380
- package/dist/checks/bin/check-issue-assignment.js +712 -170
- package/dist/checks/bin/check-issue-milestone-attach.js +1233 -230
- package/dist/checks/bin/check-issue-objectives-numbering.js +1769 -346
- package/dist/checks/bin/check-issue-parts-coverage.js +1233 -230
- package/dist/checks/bin/check-issue-surface-globs.js +1926 -378
- package/dist/checks/bin/check-issue-title-grammar.js +1233 -230
- package/dist/checks/bin/check-issue-tranche-label.js +702 -170
- package/dist/checks/bin/check-main-branch-refusal.js +1245 -232
- package/dist/checks/bin/check-no-disk-state.js +1233 -230
- package/dist/checks/bin/check-pr-premise-reassert.js +1769 -346
- package/dist/checks/bin/check-pr-report-density.js +1233 -230
- package/dist/checks/bin/check-principal-test-plan-wait.js +2489 -259
- package/dist/checks/bin/check-quoted-command.js +2391 -544
- package/dist/checks/bin/check-reader-resolvable-prose.js +2437 -564
- package/dist/checks/bin/check-registry-gates.js +1380 -296
- package/dist/checks/bin/check-retired-vocabulary.js +2416 -550
- package/dist/checks/bin/check-review-gate.js +2073 -371
- package/dist/checks/bin/check-single-plan-pr.js +1297 -235
- package/dist/checks/bin/check-surface-scope.js +1531 -252
- package/dist/checks/bin/check-test-plan.js +2487 -258
- package/dist/checks/bin/check-token-collection-wired.js +1233 -230
- package/dist/checks/bin/check-workspace-escape.js +2408 -561
- package/dist/checks/bin/verify-coherence.js +597 -97
- package/dist/checks/bin/verify-dispatch.js +632 -152
- package/dist/checks/bin/verify-docs.js +642 -132
- package/dist/index.js +25948 -16630
- package/dist/lib/pre-push-cache-test-run.js +1813 -297
- package/dist/lib/pre-push-changed-files.js +65 -19
- package/dist/lib/pre-push-mode.js +466 -0
- package/dist/lib/pre-push-progress-dir.js +4205 -0
- package/dist/lib/pre-push-record-tests.js +446 -0
- package/dist/lib/pre-push-select-tests.js +2353 -632
- package/dist/lib/push-progress-observer.js +4213 -0
- package/package.json +22 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +17 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +73 -30
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +3 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +88 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +34 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +26 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +7 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +7 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +29 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +35 -18
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/index.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/published-prose.ts +70 -45
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +6 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/entry-point.ts +27 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +3 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +96 -9
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-assignment.ts +24 -54
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +809 -106
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/live-record.ts +179 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +8 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +1 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/narration.ts +2 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema-digest.ts +225 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +7 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +23 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +6 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/principals-config.ts +44 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/prose-rules.ts +532 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/protected-paths.ts +31 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +157 -80
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +8 -12
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/retired-vocabulary.ts +53 -93
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +46 -17
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +85 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +32 -13
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +46 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-branch-identity.ts +2 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-gate.ts +63 -8
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +24 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/waiver-label.ts +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/1q96_modules_@clerk_nextjs_dist_esm_app-router_client_keyless-creator-reader_0lom2js.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0sxadt2._.js +13 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1a3j3n1._.js +57 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1ug9syi._.js → [root-of-the-server]__1d4eth3._.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1snpgaw._.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_@clerk_nextjs_dist_esm_app-router_server-actions_1x7vfhn.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{33rszkngkuoko.js → 0x7u6si-ai179.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{06_55xbp7rcbi.js → 2fu7mfsj4oima.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2brkwv169ygep.js → 34b4ruddunn3q.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__04adkz-._.js +0 -57
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__19jyp3m._.js +0 -13
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → 2ZARxTwpuRew8-SvYsRdU}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → 2ZARxTwpuRew8-SvYsRdU}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → 2ZARxTwpuRew8-SvYsRdU}/_ssgManifest.js +0 -0
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* now gated pre-merge and blocking instead of post-merge and advisory-only.
|
|
8
8
|
*
|
|
9
9
|
* Verdict comments are ONLY counted when their author is on the same
|
|
10
|
-
*
|
|
10
|
+
* Principal list the waiver actor-check trusts (a security finding):
|
|
11
11
|
* body-shape alone is never sufficient on a public repo. Unverified
|
|
12
12
|
* comments are ignored, not fatal.
|
|
13
13
|
*
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
* head sha via `gh` and calls `checkReviewGate`.
|
|
74
74
|
*/
|
|
75
75
|
|
|
76
|
-
import { isPrincipal, isWaiverLabelActorVerified,
|
|
76
|
+
import { isPrincipal, isWaiverLabelActorVerified, WAIVER_LABEL_REVIEW } from './waiver-label'
|
|
77
77
|
import { extractCodeReviewVerdict, extractSecurityReviewVerdict } from './verdict-extraction'
|
|
78
78
|
import {
|
|
79
79
|
consequentialFindings,
|
|
@@ -108,6 +108,7 @@ export type ReviewGateComment = {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
export type ReviewGateInput = {
|
|
111
|
+
manifestVersion?: 2
|
|
111
112
|
/** Every comment on the PR, with its author. */
|
|
112
113
|
comments: ReviewGateComment[]
|
|
113
114
|
/** Every label currently applied to the PR. */
|
|
@@ -126,17 +127,16 @@ export type ReviewGateInput = {
|
|
|
126
127
|
*/
|
|
127
128
|
headSha: string
|
|
128
129
|
/**
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* already had counted for nobody.
|
|
130
|
+
* The Principal list for this evaluation — the repository's own
|
|
131
|
+
* `vinaya.config.json` `principals` field, resolved by the caller before
|
|
132
|
+
* calling in (never read from here; this stays pure). REQUIRED, with no
|
|
133
|
+
* built-in fallback: a hardcoded Principal made the gate structurally
|
|
134
|
+
* unpassable on any adopter repo — found live on a real client repo's
|
|
135
|
+
* first dispatched task, the reviewer/security verdicts it already had
|
|
136
|
+
* counted for nobody — so a caller that supplies no list is a compile
|
|
137
|
+
* error, not a silent default.
|
|
138
138
|
*/
|
|
139
|
-
principalAllowlist
|
|
139
|
+
principalAllowlist: string[]
|
|
140
140
|
/**
|
|
141
141
|
* The PATCH IDENTITY of a commit — `git diff <base>...<sha> | git patch-id
|
|
142
142
|
* --stable`, truncated — or `null` when git cannot answer for that sha
|
|
@@ -194,14 +194,15 @@ export type ReviewGateInput = {
|
|
|
194
194
|
* unconditional skip, since a ruling's existence is never ambiguous.
|
|
195
195
|
*/
|
|
196
196
|
rulingOrdinal: number
|
|
197
|
+
/** Ruling that authenticated the resumed pause preceding this review round. */
|
|
198
|
+
pauseBoundRuling?: import('./review-input-manifest').PauseBoundRuling | null
|
|
197
199
|
/**
|
|
198
200
|
* Which severities block is repository policy — resolved by the caller from the DEFAULT BRANCH's
|
|
199
201
|
* `vinaya.config.json` (`resolveReviewPolicy(loadTrustAnchorConfig())`),
|
|
200
202
|
* never from here (this stays pure) and never from the PR's own checkout,
|
|
201
203
|
* so a change cannot lower its own threshold. Defaults to
|
|
202
204
|
* `DEFAULT_REVIEW_POLICY` (`BLOCKER`/`HIGH`) when omitted — every existing
|
|
203
|
-
* caller that predates this field is unaffected
|
|
204
|
-
* fallback shape `principalAllowlist` already uses above.
|
|
205
|
+
* caller that predates this field is unaffected.
|
|
205
206
|
*/
|
|
206
207
|
policy?: ReviewPolicy
|
|
207
208
|
/**
|
|
@@ -272,7 +273,7 @@ export function isReviewGateExemptBranch(_branch: string): boolean {
|
|
|
272
273
|
|
|
273
274
|
/**
|
|
274
275
|
* `pass` when either (a) `vinaya/waiver:review` is present and actor-verified against
|
|
275
|
-
* `
|
|
276
|
+
* `input.principalAllowlist`, or (b) both verdicts are clean AND bound — code-reviewer
|
|
276
277
|
* `APPROVE` (not `REQUEST_CHANGES`, not missing, not unclear) covering the PR's
|
|
277
278
|
* current `headSha` — by that sha, or by an equal patch identity when
|
|
278
279
|
* `patchIdOf` is supplied — and security-review `PASS` (not `FAIL`, not
|
|
@@ -297,7 +298,7 @@ export function isReviewGateExemptBranch(_branch: string): boolean {
|
|
|
297
298
|
* overrides the evaluator.
|
|
298
299
|
*/
|
|
299
300
|
export function checkReviewGate(input: ReviewGateInput): ReviewGateResult {
|
|
300
|
-
const principalAllowlist = input
|
|
301
|
+
const { principalAllowlist } = input
|
|
301
302
|
const waived = isWaiverLabelActorVerified({
|
|
302
303
|
label: WAIVER_LABEL_REVIEW,
|
|
303
304
|
labels: input.labels,
|
|
@@ -316,7 +317,7 @@ export function checkReviewGate(input: ReviewGateInput): ReviewGateResult {
|
|
|
316
317
|
// repo any GitHub account can post a `VERDICT: APPROVE`-shaped comment, and
|
|
317
318
|
// most-recent-clear-hit-wins extraction would let a forged later APPROVE
|
|
318
319
|
// override a real earlier REQUEST CHANGES. Only comments whose author is on
|
|
319
|
-
// the same
|
|
320
|
+
// the same Principal list the waiver's actor check already trusts
|
|
320
321
|
// participate in verdict extraction; everything else — unknown authors and
|
|
321
322
|
// unresolvable (`null`) ones alike — is IGNORED, never fatal, so a drive-by
|
|
322
323
|
// comment cannot brick evaluation, only fail to count. Dispatched reviewer
|
|
@@ -394,27 +395,33 @@ export function checkReviewGate(input: ReviewGateInput): ReviewGateResult {
|
|
|
394
395
|
// brief string) since the caller already resolved `briefHash` itself and
|
|
395
396
|
// this module stays pure — no hashing of forge content here.
|
|
396
397
|
const currentManifest: ReviewInputManifest = {
|
|
398
|
+
...(input.manifestVersion === undefined ? {} : { manifestVersion: input.manifestVersion }),
|
|
397
399
|
headSha: input.headSha,
|
|
398
400
|
baseSha: input.baseSha ?? null,
|
|
399
401
|
briefHash: input.briefHash ?? null,
|
|
400
402
|
objectivesVersion: input.objectivesVersion,
|
|
401
403
|
rulingOrdinal: input.rulingOrdinal,
|
|
404
|
+
pauseBoundRuling: input.pauseBoundRuling ?? null,
|
|
402
405
|
policyDigest: computePolicyDigest(policy)
|
|
403
406
|
}
|
|
404
407
|
const codeReviewEchoed: EchoedManifest = {
|
|
408
|
+
manifestVersion: codeReview.manifestVersion,
|
|
405
409
|
headSha: codeReview.headSha,
|
|
406
410
|
baseSha: codeReview.baseSha,
|
|
407
411
|
briefHash: codeReview.briefHash,
|
|
408
412
|
objectivesVersion: codeReview.objectivesVersion,
|
|
409
413
|
rulingOrdinal: codeReview.rulingOrdinal,
|
|
414
|
+
pauseBoundRuling: codeReview.pauseBoundRuling,
|
|
410
415
|
policyDigest: codeReview.policyDigest
|
|
411
416
|
}
|
|
412
417
|
const securityEchoed: EchoedManifest = {
|
|
418
|
+
manifestVersion: security.manifestVersion,
|
|
413
419
|
headSha: security.headSha,
|
|
414
420
|
baseSha: security.baseSha,
|
|
415
421
|
briefHash: security.briefHash,
|
|
416
422
|
objectivesVersion: security.objectivesVersion,
|
|
417
423
|
rulingOrdinal: security.rulingOrdinal,
|
|
424
|
+
pauseBoundRuling: security.pauseBoundRuling,
|
|
418
425
|
policyDigest: security.policyDigest
|
|
419
426
|
}
|
|
420
427
|
const codeReviewBinding = compareManifest(codeReviewEchoed, currentManifest, input.patchIdOf)
|
|
@@ -473,6 +480,14 @@ export function checkReviewGate(input: ReviewGateInput): ReviewGateResult {
|
|
|
473
480
|
problems.push(
|
|
474
481
|
`the newest code-review verdict was cast against review policy digest ${codeReview.policyDigest ?? 'none'}, this repository's current policy digest is ${currentManifest.policyDigest}`
|
|
475
482
|
)
|
|
483
|
+
} else if (!codeReviewBinding.manifestVersion) {
|
|
484
|
+
problems.push(
|
|
485
|
+
`the newest code-review verdict echoes manifest version ${codeReview.manifestVersion ?? 'none'}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? 'unversioned'}`
|
|
486
|
+
)
|
|
487
|
+
} else if (!codeReviewBinding.pauseBoundRuling) {
|
|
488
|
+
problems.push(
|
|
489
|
+
`the newest code-review verdict echoes pauseBoundRuling ${renderBinding(codeReview.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`
|
|
490
|
+
)
|
|
476
491
|
}
|
|
477
492
|
if (!securityTextClean) {
|
|
478
493
|
problems.push(`security-review verdict is not a clean PASS (found: ${security.value})`)
|
|
@@ -504,6 +519,14 @@ export function checkReviewGate(input: ReviewGateInput): ReviewGateResult {
|
|
|
504
519
|
problems.push(
|
|
505
520
|
`the newest security-review verdict was cast against review policy digest ${security.policyDigest ?? 'none'}, this repository's current policy digest is ${currentManifest.policyDigest}`
|
|
506
521
|
)
|
|
522
|
+
} else if (!securityBinding.manifestVersion) {
|
|
523
|
+
problems.push(
|
|
524
|
+
`the newest security-review verdict echoes manifest version ${security.manifestVersion ?? 'none'}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? 'unversioned'}`
|
|
525
|
+
)
|
|
526
|
+
} else if (!securityBinding.pauseBoundRuling) {
|
|
527
|
+
problems.push(
|
|
528
|
+
`the newest security-review verdict echoes pauseBoundRuling ${renderBinding(security.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`
|
|
529
|
+
)
|
|
507
530
|
}
|
|
508
531
|
const ignoredNote =
|
|
509
532
|
ignoredCount > 0
|
|
@@ -517,6 +540,12 @@ export function checkReviewGate(input: ReviewGateInput): ReviewGateResult {
|
|
|
517
540
|
}
|
|
518
541
|
}
|
|
519
542
|
|
|
543
|
+
/** A ruling binding as the gate's failure text names it: `<ruling>|<pause>|<digest>`, `(none)`, or `(absent)` when no slot was echoed at all. */
|
|
544
|
+
function renderBinding(binding: import('./review-input-manifest').PauseBoundRuling | null | undefined): string {
|
|
545
|
+
if (binding === undefined) return '(absent)'
|
|
546
|
+
return binding === null ? '(none)' : `${binding.rulingId}|${binding.pauseId}|${binding.contentDigest}`
|
|
547
|
+
}
|
|
548
|
+
|
|
520
549
|
/**
|
|
521
550
|
* Exported so a caller can cheaply pre-check the branch BEFORE paying for
|
|
522
551
|
* whatever it takes to resolve `expectedAuthor` — resolving that value is a
|
|
@@ -44,6 +44,59 @@
|
|
|
44
44
|
|
|
45
45
|
import { createHash } from 'node:crypto'
|
|
46
46
|
import type { ReviewPolicy } from './review-policy'
|
|
47
|
+
import { parseRulingIdentity } from './ruling-ordinal'
|
|
48
|
+
|
|
49
|
+
/** The authenticated Principal ruling that resumed the pause preceding a round. */
|
|
50
|
+
export type PauseBoundRuling = {
|
|
51
|
+
rulingId: string
|
|
52
|
+
pauseId: string
|
|
53
|
+
contentDigest: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** SHA-256 of a ruling's text — its comment body after the marker line, trimmed. */
|
|
57
|
+
export function pauseBoundRulingDigest(rulingText: string): string {
|
|
58
|
+
return createHash('sha256').update(rulingText).digest('hex')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The fields of a consumed resolution record the ruling binding reads. */
|
|
62
|
+
export type ConsumedResolution = {
|
|
63
|
+
escalationId: string
|
|
64
|
+
decision: 'resume' | 'cancel'
|
|
65
|
+
authenticatedBy: string
|
|
66
|
+
authenticatedFrom: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The pause-bound ruling slot for a run resumed from `resolution`, read from
|
|
71
|
+
* that consumed resolution alone: its `escalationId` is the pause identity,
|
|
72
|
+
* its `authenticatedFrom` the ruling identity, and the digest is taken over
|
|
73
|
+
* the text of the one ruling comment that identity names — its ordinal, on the pull request or Issue it names
|
|
74
|
+
* (`readRulingText`, which must never fall back to another ruling). `null`
|
|
75
|
+
* when the resolution carries no ruling — no resolution, a cancel, a
|
|
76
|
+
* self-recovery (`'driver-self'`), or an identity that names no ruling
|
|
77
|
+
* marker. Throws when the identity names a ruling whose text cannot be read,
|
|
78
|
+
* rather than binding some other ruling's text to it.
|
|
79
|
+
*/
|
|
80
|
+
export function pauseBoundRulingFromResolution(
|
|
81
|
+
resolution: ConsumedResolution | null,
|
|
82
|
+
readRulingText: (rulingId: string) => string | null
|
|
83
|
+
): PauseBoundRuling | null {
|
|
84
|
+
if (resolution === null || resolution.decision !== 'resume' || resolution.authenticatedBy === 'driver-self') {
|
|
85
|
+
return null
|
|
86
|
+
}
|
|
87
|
+
if (parseRulingIdentity(resolution.authenticatedFrom) === null) return null
|
|
88
|
+
const text = readRulingText(resolution.authenticatedFrom)
|
|
89
|
+
if (text === null) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`resolution ${resolution.escalationId} authenticates from ruling ${resolution.authenticatedFrom}, but no single principal ruling comment carries that ruling identity.`
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
rulingId: resolution.authenticatedFrom,
|
|
96
|
+
pauseId: resolution.escalationId,
|
|
97
|
+
contentDigest: pauseBoundRulingDigest(text)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
47
100
|
|
|
48
101
|
/**
|
|
49
102
|
* `sha256` of the frozen brief's own text as it appears posted, below its
|
|
@@ -101,6 +154,8 @@ export function policyDigest(policy: ReviewPolicy): string {
|
|
|
101
154
|
* either configured or defaulted.
|
|
102
155
|
*/
|
|
103
156
|
export type ReviewInputManifest = {
|
|
157
|
+
/** Closed protocol version. Readers must refuse values other than 2. */
|
|
158
|
+
manifestVersion?: 2
|
|
104
159
|
/** The candidate identity — the round's judged head (O1: "base and candidate identity"). */
|
|
105
160
|
headSha: string
|
|
106
161
|
/**
|
|
@@ -115,6 +170,8 @@ export type ReviewInputManifest = {
|
|
|
115
170
|
briefHash: string | null
|
|
116
171
|
objectivesVersion: string | null
|
|
117
172
|
rulingOrdinal: number
|
|
173
|
+
/** `null` explicitly means this round did not follow a ruling-resolved pause. */
|
|
174
|
+
pauseBoundRuling?: PauseBoundRuling | null
|
|
118
175
|
policyDigest: string
|
|
119
176
|
}
|
|
120
177
|
|
|
@@ -126,17 +183,20 @@ export type ReviewInputManifestFacts = {
|
|
|
126
183
|
briefContent: string | null
|
|
127
184
|
objectivesVersion: string | null
|
|
128
185
|
rulingOrdinal: number
|
|
186
|
+
pauseBoundRuling?: PauseBoundRuling | null
|
|
129
187
|
policy: ReviewPolicy
|
|
130
188
|
}
|
|
131
189
|
|
|
132
190
|
/** The one builder — every call site that used to compute these facts as separate, ad hoc values now builds this instead. */
|
|
133
191
|
export function buildReviewInputManifest(facts: ReviewInputManifestFacts): ReviewInputManifest {
|
|
134
192
|
return {
|
|
193
|
+
manifestVersion: 2,
|
|
135
194
|
headSha: facts.headSha,
|
|
136
195
|
baseSha: facts.baseSha,
|
|
137
196
|
briefHash: facts.briefContent === null ? null : briefHash(facts.briefContent),
|
|
138
197
|
objectivesVersion: facts.objectivesVersion,
|
|
139
198
|
rulingOrdinal: facts.rulingOrdinal,
|
|
199
|
+
pauseBoundRuling: facts.pauseBoundRuling ?? null,
|
|
140
200
|
policyDigest: policyDigest(facts.policy)
|
|
141
201
|
}
|
|
142
202
|
}
|
|
@@ -158,23 +218,27 @@ export function buildReviewInputManifest(facts: ReviewInputManifestFacts): Revie
|
|
|
158
218
|
* fact anywhere.
|
|
159
219
|
*/
|
|
160
220
|
export type EchoedManifest = {
|
|
221
|
+
manifestVersion?: number | null
|
|
161
222
|
headSha: string | null
|
|
162
223
|
/** `null` when no `Judged base:` line was found (O1) — pre-cutover legacy stock, or a stripped line. */
|
|
163
224
|
baseSha: string | null
|
|
164
225
|
briefHash: string | null
|
|
165
226
|
objectivesVersion: string | null
|
|
166
227
|
rulingOrdinal: number | null
|
|
228
|
+
pauseBoundRuling?: PauseBoundRuling | null
|
|
167
229
|
policyDigest: string | null
|
|
168
230
|
}
|
|
169
231
|
|
|
170
232
|
/** `manifest`'s own fields, reshaped as an `EchoedManifest` — for a same-process comparison (the loop's pre-hold self-check) where the "echo" is simply the in-memory manifest a verdict was rendered from, never a round-trip through the rendered text. */
|
|
171
233
|
export function manifestAsEchoed(manifest: ReviewInputManifest): EchoedManifest {
|
|
172
234
|
return {
|
|
235
|
+
...(manifest.manifestVersion === undefined ? {} : { manifestVersion: manifest.manifestVersion }),
|
|
173
236
|
headSha: manifest.headSha,
|
|
174
237
|
baseSha: manifest.baseSha,
|
|
175
238
|
briefHash: manifest.briefHash,
|
|
176
239
|
objectivesVersion: manifest.objectivesVersion,
|
|
177
240
|
rulingOrdinal: manifest.rulingOrdinal,
|
|
241
|
+
...(manifest.manifestVersion === undefined ? {} : { pauseBoundRuling: manifest.pauseBoundRuling ?? null }),
|
|
178
242
|
policyDigest: manifest.policyDigest
|
|
179
243
|
}
|
|
180
244
|
}
|
|
@@ -329,6 +393,8 @@ export type ManifestBindingResult = {
|
|
|
329
393
|
briefHash: boolean
|
|
330
394
|
objectivesVersion: boolean
|
|
331
395
|
rulingOrdinal: boolean
|
|
396
|
+
pauseBoundRuling: boolean
|
|
397
|
+
manifestVersion: boolean
|
|
332
398
|
policyDigest: boolean
|
|
333
399
|
}
|
|
334
400
|
|
|
@@ -376,14 +442,32 @@ export function compareManifest(
|
|
|
376
442
|
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash)
|
|
377
443
|
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion)
|
|
378
444
|
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal)
|
|
445
|
+
const legacyCurrent = current.manifestVersion === undefined
|
|
446
|
+
const manifestVersion = legacyCurrent
|
|
447
|
+
? echoed.manifestVersion === undefined || echoed.manifestVersion === null
|
|
448
|
+
: echoed.manifestVersion === current.manifestVersion
|
|
449
|
+
const pauseBoundRuling = legacyCurrent
|
|
450
|
+
? true
|
|
451
|
+
: Object.hasOwn(echoed, 'pauseBoundRuling') &&
|
|
452
|
+
JSON.stringify(echoed.pauseBoundRuling) === JSON.stringify(current.pauseBoundRuling)
|
|
379
453
|
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest)
|
|
380
454
|
return {
|
|
381
|
-
bound:
|
|
455
|
+
bound:
|
|
456
|
+
head &&
|
|
457
|
+
base &&
|
|
458
|
+
briefHashBound &&
|
|
459
|
+
objectivesVersion &&
|
|
460
|
+
rulingOrdinal &&
|
|
461
|
+
pauseBoundRuling &&
|
|
462
|
+
manifestVersion &&
|
|
463
|
+
policyDigestBound,
|
|
382
464
|
head,
|
|
383
465
|
base,
|
|
384
466
|
briefHash: briefHashBound,
|
|
385
467
|
objectivesVersion,
|
|
386
468
|
rulingOrdinal,
|
|
469
|
+
pauseBoundRuling,
|
|
470
|
+
manifestVersion,
|
|
387
471
|
policyDigest: policyDigestBound
|
|
388
472
|
}
|
|
389
473
|
}
|
|
@@ -187,8 +187,8 @@ export const DEFERRAL_REASON_TEXT: Record<DeferralReason, string> = {
|
|
|
187
187
|
* (or the round-1/no-previous-head case where the unchanged-line rule does
|
|
188
188
|
* not apply), or a security finding at or above HIGH the unchanged-line
|
|
189
189
|
* rule never defers;
|
|
190
|
-
* - `'deferred'` — WOULD block, but this round cannot act on it:
|
|
191
|
-
* Surface (any round, O3) or on a line that did not change since the
|
|
190
|
+
* - `'deferred'` — WOULD block, but this round cannot act on it: on a file
|
|
191
|
+
* outside the Surface the branch did not change (any round, O3) or on a line that did not change since the
|
|
192
192
|
* previous round's head (round 2 on, O2). `deferralReason` names which;
|
|
193
193
|
* - `'non_blocking'` — below threshold, or a prose-located finding capped to
|
|
194
194
|
* `PROSE_CAP_SEVERITY` (O5). Never deferred: it was never going to block,
|
|
@@ -218,13 +218,21 @@ export type FindingClassification = {
|
|
|
218
218
|
* recover one treats every in-Surface finding as blocking rather than
|
|
219
219
|
* guessing. Never inferred here from a `false` return.
|
|
220
220
|
* - `inSurface` — `inSurface(location)` is `true` when the finding's file is
|
|
221
|
-
* covered by the task's `## Surface` `in:` list.
|
|
222
|
-
*
|
|
223
|
-
*
|
|
221
|
+
* covered by the task's `## Surface` `in:` list.
|
|
222
|
+
* - `changedFile` — `changedFile(location)` is `true` when the task branch
|
|
223
|
+
* changed the finding's file (its merge-base diff names it).
|
|
224
|
+
*
|
|
225
|
+
* The out-of-Surface rule (O3) needs BOTH: it defers only a finding on a
|
|
226
|
+
* file the Surface does not cover AND the branch did not change. A changed
|
|
227
|
+
* file beyond the Surface is recorded in the pull request and reviewed
|
|
228
|
+
* like any change, so its finding counts at its reported severity. Either
|
|
229
|
+
* predicate undefined means this caller cannot tell, so the rule is not
|
|
230
|
+
* applied — never a silent "everything is out of Surface."
|
|
224
231
|
*/
|
|
225
232
|
export type FindingDeferralContext = {
|
|
226
233
|
changedLine?: (location: string) => boolean
|
|
227
234
|
inSurface?: (location: string) => boolean
|
|
235
|
+
changedFile?: (location: string) => boolean
|
|
228
236
|
}
|
|
229
237
|
|
|
230
238
|
/**
|
|
@@ -234,8 +242,9 @@ export type FindingDeferralContext = {
|
|
|
234
242
|
* `CRITICAL` and `HIGH`; those two severities exist on no other scale, so
|
|
235
243
|
* membership alone identifies a security finding of that rank without needing
|
|
236
244
|
* to know which scale the caller passed. The out-of-Surface rule (O3) carries
|
|
237
|
-
* NO such exception — a finding outside the Surface never
|
|
238
|
-
* not — so this is consulted only on the unchanged-line
|
|
245
|
+
* NO such exception — a finding on an unchanged file outside the Surface never
|
|
246
|
+
* blocks, security or not — so this is consulted only on the unchanged-line
|
|
247
|
+
* path below.
|
|
239
248
|
*/
|
|
240
249
|
const SECURITY_HIGH_AND_ABOVE: readonly string[] = blockingSeverities(SECURITY_SEVERITY_ORDER, 'HIGH')
|
|
241
250
|
|
|
@@ -250,9 +259,11 @@ const SECURITY_HIGH_AND_ABOVE: readonly string[] = blockingSeverities(SECURITY_S
|
|
|
250
259
|
* 2. the threshold — below it, `'non_blocking'` (never deferred: a finding
|
|
251
260
|
* that was never going to block is not "set aside", it simply passes);
|
|
252
261
|
* 3. the out-of-Surface rule (O3) — a would-block finding whose file the
|
|
253
|
-
* Surface `in:` does not cover
|
|
254
|
-
*
|
|
255
|
-
*
|
|
262
|
+
* Surface `in:` does not cover AND the task branch did not change is
|
|
263
|
+
* `'deferred'`, ANY round; a changed file beyond the Surface is reviewed
|
|
264
|
+
* like any change and blocks at its reported severity; a PR-body or
|
|
265
|
+
* comment location is no file, so neither this rule nor the next ever
|
|
266
|
+
* defers it;
|
|
256
267
|
* 4. the unchanged-line rule (O2) — from round 2 on (`context.changedLine`
|
|
257
268
|
* present), a would-block finding on an unchanged line is `'deferred'`,
|
|
258
269
|
* EXCEPT a security finding at or above HIGH, which blocks anyway.
|
|
@@ -284,9 +295,17 @@ export function classifyFinding(
|
|
|
284
295
|
// neither deferral rule applies to it — it is capped above, never set aside.
|
|
285
296
|
const hasLocation = location !== undefined && location.length > 0 && !isBodyOrCommentLocation(location)
|
|
286
297
|
|
|
287
|
-
// O3 first:
|
|
288
|
-
// security exception — so it is
|
|
289
|
-
|
|
298
|
+
// O3 first: a finding on a file outside the Surface that the branch did not
|
|
299
|
+
// change never blocks, in ANY round, with no security exception — so it is
|
|
300
|
+
// decided before the unchanged-line rule. A file the branch changed is
|
|
301
|
+
// reviewed whatever the Surface says.
|
|
302
|
+
if (
|
|
303
|
+
hasLocation &&
|
|
304
|
+
context.inSurface &&
|
|
305
|
+
context.changedFile &&
|
|
306
|
+
!context.inSurface(location as string) &&
|
|
307
|
+
!context.changedFile(location as string)
|
|
308
|
+
) {
|
|
290
309
|
return { outcome: 'deferred', deferralReason: 'outside-surface' }
|
|
291
310
|
}
|
|
292
311
|
|
|
@@ -90,3 +90,49 @@ export function newestPrincipalRulingAuthor(
|
|
|
90
90
|
}
|
|
91
91
|
return bestAuthor
|
|
92
92
|
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Where a ruling identity points. A resolution record names the ruling that
|
|
96
|
+
* authenticated it as `<pr>-<k>` for a ruling on a pull request, or
|
|
97
|
+
* `issue-<n>-<k>` for a ruling on the task Issue; either way the ruling
|
|
98
|
+
* comment itself carries the marker `<ref>-<k>`. Any other value — a
|
|
99
|
+
* self-recovery tag, or a superseding-brief reference — names no ruling, and
|
|
100
|
+
* reads `null`.
|
|
101
|
+
*/
|
|
102
|
+
export function parseRulingIdentity(rulingId: string): { target: 'pr' | 'issue'; ref: number; ordinal: number } | null {
|
|
103
|
+
const m = /^(issue-)?(\d+)-(\d+)$/.exec(rulingId)
|
|
104
|
+
if (!m) return null
|
|
105
|
+
const ref = Number.parseInt(m[2] as string, 10)
|
|
106
|
+
const ordinal = Number.parseInt(m[3] as string, 10)
|
|
107
|
+
if (ref <= 0 || ordinal <= 0) return null
|
|
108
|
+
return { target: m[1] ? 'issue' : 'pr', ref, ordinal }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The text of the ONE principal-authored ruling a ruling identity names — the
|
|
113
|
+
* comment body after its marker line, trimmed, the same text every ruling
|
|
114
|
+
* reader hands a Developer. The caller passes the comments of the pull
|
|
115
|
+
* request or Issue the identity names; the identity's ordinal is matched
|
|
116
|
+
* against each marker's ordinal, exactly the number the resume read when it
|
|
117
|
+
* minted that identity (`newestPrincipalRulingOrdinal` reads the ordinal
|
|
118
|
+
* alone). Never chosen by position, by newest ordinal, or by being the only
|
|
119
|
+
* ruling present: `null` when no principal comment carries that ordinal, or
|
|
120
|
+
* when more than one does (an ambiguous identity is not an identity).
|
|
121
|
+
*/
|
|
122
|
+
export function principalRulingTextById(
|
|
123
|
+
comments: readonly RulingComment[],
|
|
124
|
+
allowlist: readonly string[],
|
|
125
|
+
rulingId: string
|
|
126
|
+
): string | null {
|
|
127
|
+
const identity = parseRulingIdentity(rulingId)
|
|
128
|
+
if (identity === null) return null
|
|
129
|
+
const matches = comments.filter((c) => {
|
|
130
|
+
if (!isPrincipal(c.author, allowlist as string[])) return false
|
|
131
|
+
const m = RULING_MARKER_ORDINAL.exec((c.body.split('\n')[0] ?? '').trim())
|
|
132
|
+
return m !== null && Number.parseInt(m[1] as string, 10) === identity.ordinal
|
|
133
|
+
})
|
|
134
|
+
if (matches.length !== 1) return null
|
|
135
|
+
const body = (matches[0] as RulingComment).body
|
|
136
|
+
const idx = body.indexOf('\n')
|
|
137
|
+
return idx === -1 ? '' : body.slice(idx + 1).trim()
|
|
138
|
+
}
|
|
@@ -9,10 +9,8 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Deliberately NOT the same export as `first-push-dispatch-gate.ts`'s
|
|
11
11
|
* `parseTaskBranch` — that function (and its flat `{tranche, taskId}` return
|
|
12
|
-
* shape) is shared by `first-push-dispatch
|
|
13
|
-
*
|
|
14
|
-
* widening its return type would ripple into checks this task has no brief
|
|
15
|
-
* coverage for. This module is the new, additional shape-parser named in the
|
|
12
|
+
* shape) is shared by `first-push-dispatch` and its gate; widening its
|
|
13
|
+
* return type would ripple into checks that read the flat shape. This module is the new, additional shape-parser named in the
|
|
16
14
|
* Traps to avoid: "`task/issue-<n>` is its own shape, parsed by one function
|
|
17
15
|
* next to `task/<tranche>/<n>`."
|
|
18
16
|
*/
|
|
@@ -20,8 +20,20 @@
|
|
|
20
20
|
* grandfathered by `brief-shape`'s own rollout) is never graded here —
|
|
21
21
|
* see the module doc comment above.
|
|
22
22
|
* - All `[principal]` boxes ticked (or none exist at all) → `pass`.
|
|
23
|
+
*
|
|
24
|
+
* The driver's `AEG:LIVE` record (`live-record.ts`) is graded alongside: each
|
|
25
|
+
* unticked `[live]` line — a run that failed, or one the loop's host could not
|
|
26
|
+
* verify — counts as an unticked `[principal]` box, and stops the
|
|
27
|
+
* no-section and `unit-tests-only` passes above from applying.
|
|
28
|
+
*
|
|
29
|
+
* Given the frozen brief's `[live]` commands and the pull request's head
|
|
30
|
+
* (`LiveGateInputs`), the gate fails closed: each command is decided from the
|
|
31
|
+
* record's entry for it at that head, never from the record alone. A command
|
|
32
|
+
* with no ticked entry at the head — no record at all, or an entry for an
|
|
33
|
+
* older head only — counts as an unticked `[live]` line.
|
|
23
34
|
*/
|
|
24
35
|
|
|
36
|
+
import { type LiveRecordLine, readLiveRecord } from './live-record'
|
|
25
37
|
import { locateTestPlanSection } from './test-plan-section'
|
|
26
38
|
import { parseTaskBranchIdentity } from './task-branch-identity'
|
|
27
39
|
|
|
@@ -31,7 +43,36 @@ export type TestPlanGateResult = {
|
|
|
31
43
|
messages: string[]
|
|
32
44
|
}
|
|
33
45
|
|
|
34
|
-
|
|
46
|
+
/** The frozen brief's `[live]` commands (`parseLiveTestPlanItems`) and the pull request's head SHA they must have passed at. */
|
|
47
|
+
export type LiveGateInputs = {
|
|
48
|
+
liveCommands: readonly string[]
|
|
49
|
+
head: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The record's lines as the gate grades them. Without `live`, every line the
|
|
54
|
+
* record carries. With it, each brief command is graded by its entry at
|
|
55
|
+
* `live.head` — its ticked line when it passed there (or the Principal
|
|
56
|
+
* ticked it), its unticked line when it failed or went unverified there, and
|
|
57
|
+
* an unticked line naming the head when the record holds no entry for it at
|
|
58
|
+
* that head — and the record's lines for any other command are kept as they
|
|
59
|
+
* are.
|
|
60
|
+
*/
|
|
61
|
+
function gradedLiveLines(record: readonly LiveRecordLine[], live: LiveGateInputs | undefined): string[] {
|
|
62
|
+
if (live === undefined) return record.map((entry) => entry.line)
|
|
63
|
+
const commands = new Set(live.liveCommands)
|
|
64
|
+
const others = record.filter((entry) => !commands.has(entry.command)).map((entry) => entry.line)
|
|
65
|
+
const graded = live.liveCommands.map((command) => {
|
|
66
|
+
const atHead = record.filter((entry) => entry.command === command && entry.head === live.head)
|
|
67
|
+
return (
|
|
68
|
+
(atHead.find((entry) => entry.ticked) ?? atHead[0])?.line ??
|
|
69
|
+
`- [ ] **[live]** \`${command}\` — no passed run recorded at \`${live.head || 'an unknown head'}\``
|
|
70
|
+
)
|
|
71
|
+
})
|
|
72
|
+
return [...others, ...graded]
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function evaluateTestPlanGate(body: string, branch: string, live?: LiveGateInputs): TestPlanGateResult {
|
|
35
76
|
if (!body) {
|
|
36
77
|
return {
|
|
37
78
|
verdict: 'pass',
|
|
@@ -43,8 +84,14 @@ export function evaluateTestPlanGate(body: string, branch: string): TestPlanGate
|
|
|
43
84
|
}
|
|
44
85
|
|
|
45
86
|
const located = locateTestPlanSection(body)
|
|
87
|
+
// The driver's `AEG:LIVE` record (`live-record.ts`): an unticked line — a
|
|
88
|
+
// `[live]` run that failed, or one the loop's host could not verify — holds
|
|
89
|
+
// the merge exactly as an unticked `[principal]` box does, wherever in the
|
|
90
|
+
// body the record sits and whatever the Test Plan section says.
|
|
91
|
+
const liveLines = gradedLiveLines(readLiveRecord(body), live)
|
|
92
|
+
const liveUnticked = liveLines.some((line) => /^[-*]\s+\[\s\]/.test(line))
|
|
46
93
|
|
|
47
|
-
if (!located.found) {
|
|
94
|
+
if (!located.found && !liveUnticked) {
|
|
48
95
|
if (parseTaskBranchIdentity(branch) !== null) {
|
|
49
96
|
return {
|
|
50
97
|
verdict: 'fail',
|
|
@@ -65,9 +112,9 @@ export function evaluateTestPlanGate(body: string, branch: string): TestPlanGate
|
|
|
65
112
|
}
|
|
66
113
|
}
|
|
67
114
|
|
|
68
|
-
const section = located.section
|
|
115
|
+
const section = located.found ? located.section : ''
|
|
69
116
|
|
|
70
|
-
if (/unit-tests-only/i.test(section)) {
|
|
117
|
+
if (/unit-tests-only/i.test(section) && !liveUnticked) {
|
|
71
118
|
return {
|
|
72
119
|
verdict: 'pass',
|
|
73
120
|
messages: ['Test Plan: unit-tests-only — pure-logic brief, CI unit-tests are the proof.', 'PASS.']
|
|
@@ -78,10 +125,13 @@ export function evaluateTestPlanGate(body: string, branch: string): TestPlanGate
|
|
|
78
125
|
// An older body may still carry them (grandfathered by `brief-shape`'s
|
|
79
126
|
// own rollout); this gate simply does not look at that tag at all any
|
|
80
127
|
// more, ticked or not.
|
|
81
|
-
const checkboxLines =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
128
|
+
const checkboxLines = [
|
|
129
|
+
...section
|
|
130
|
+
.split('\n')
|
|
131
|
+
.map((line) => line.trimStart())
|
|
132
|
+
.filter((line) => /^[-*]\s+\[[ xX]\]\s*\*{0,2}\[principal\]\*{0,2}/i.test(line)),
|
|
133
|
+
...liveLines
|
|
134
|
+
]
|
|
85
135
|
|
|
86
136
|
if (checkboxLines.length === 0) {
|
|
87
137
|
return {
|
|
@@ -105,6 +155,11 @@ export function evaluateTestPlanGate(body: string, branch: string): TestPlanGate
|
|
|
105
155
|
'',
|
|
106
156
|
'Per aeg-root/roles/developer.md (Verification), a PR is not mergeable while any [principal] Test Plan box is unticked.',
|
|
107
157
|
'The Principal runs the item in a real signed-in browser and ticks the box.',
|
|
158
|
+
...(liveUnticked
|
|
159
|
+
? [
|
|
160
|
+
'An unticked [live] line is a live run that failed or that the review loop could not verify on its host: a later head re-runs it, or the Principal runs it and ticks the box.'
|
|
161
|
+
]
|
|
162
|
+
: []),
|
|
108
163
|
'Note: editing the PR body does not retrigger most workflows. If your PR body changes do not surface here, push an empty commit to re-run.'
|
|
109
164
|
)
|
|
110
165
|
return { verdict: 'fail', messages }
|
|
@@ -201,6 +201,24 @@ const POLICY_DIGEST_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Policy digest:\s*([0-9a
|
|
|
201
201
|
* (never confused with a real hex sha).
|
|
202
202
|
*/
|
|
203
203
|
const BASE_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged base:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im
|
|
204
|
+
const MANIFEST_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Manifest version:\s*(\d+)\s*$/im
|
|
205
|
+
const PAUSE_BOUND_RULING_PATTERN =
|
|
206
|
+
/^[ \t]*(?:\*{1,3}|_{1,3})?Pause-bound ruling:\s*(?:(\S+)\|(\S+)\|([0-9a-f]{64})|\(none\))\s*$/im
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The `Pause-bound ruling:` line of a driver-rendered comment — a verdict's
|
|
210
|
+
* echo, or the round comment the driver posts from the frozen manifest before
|
|
211
|
+
* any reviewer runs. `undefined` when the comment carries no such line;
|
|
212
|
+
* `null` for an explicit `(none)`; otherwise the ruling identity, pause
|
|
213
|
+
* identity and content digest.
|
|
214
|
+
*/
|
|
215
|
+
export function extractPauseBoundRuling(
|
|
216
|
+
comment: string
|
|
217
|
+
): import('./review-input-manifest').PauseBoundRuling | null | undefined {
|
|
218
|
+
const m = comment.match(PAUSE_BOUND_RULING_PATTERN)
|
|
219
|
+
if (!m) return undefined
|
|
220
|
+
return m[1] ? { rulingId: m[1], pauseId: m[2] as string, contentDigest: m[3] as string } : null
|
|
221
|
+
}
|
|
204
222
|
|
|
205
223
|
/**
|
|
206
224
|
* AEG:CLAIM: packages/aeg-core/src/verdict-extraction.ts contains:function firstFiveLines(comment: string): string {
|
|
@@ -403,6 +421,8 @@ export type VerdictExtraction = {
|
|
|
403
421
|
policyDigest: string | null
|
|
404
422
|
/** `null` when no `Judged base:` line was found (O1) — legacy stock, or no base resolvable at cast time; every comment rendered from this task forward carries it unconditionally. */
|
|
405
423
|
baseSha: string | null
|
|
424
|
+
manifestVersion?: number | null
|
|
425
|
+
pauseBoundRuling?: import('./review-input-manifest').PauseBoundRuling | null
|
|
406
426
|
/**
|
|
407
427
|
* The winning comment's own FINDINGS block severities and locations,
|
|
408
428
|
* whole-body read (O2/O3; location added O5; id and re-review state added
|
|
@@ -466,6 +486,8 @@ function extractVerdict(comments: string[], valuePattern: RegExp, missingLabel:
|
|
|
466
486
|
}
|
|
467
487
|
}
|
|
468
488
|
|
|
489
|
+
const versionMatch = latest.match(MANIFEST_VERSION_PATTERN)
|
|
490
|
+
const pauseBoundRuling = extractPauseBoundRuling(latest)
|
|
469
491
|
return {
|
|
470
492
|
value: (m[1] as string).toUpperCase().replace(/[_-]/g, ' '),
|
|
471
493
|
headSha: extractHeadSha(latest),
|
|
@@ -474,6 +496,8 @@ function extractVerdict(comments: string[], valuePattern: RegExp, missingLabel:
|
|
|
474
496
|
briefHash: extractBriefHash(latest),
|
|
475
497
|
policyDigest: extractPolicyDigest(latest),
|
|
476
498
|
baseSha: extractBaseSha(latest),
|
|
499
|
+
...(versionMatch ? { manifestVersion: Number.parseInt(versionMatch[1] as string, 10) } : {}),
|
|
500
|
+
...(pauseBoundRuling === undefined ? {} : { pauseBoundRuling }),
|
|
477
501
|
findingSeverities: extractFindingSeverities(latest),
|
|
478
502
|
danglingNote: null
|
|
479
503
|
}
|