@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
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pull request's record of its `[live]` Test plan lines — the commands
|
|
3
|
+
* that need real signed-in agent sessions, which the review loop runs on its
|
|
4
|
+
* own host only on a head both reviewers approved (`apps/cli/specs/loop.md`,
|
|
5
|
+
* "The live check"). Pure: a body in, a body or the record's lines out.
|
|
6
|
+
*
|
|
7
|
+
* The record is an `AEG:LIVE` anchored region the driver owns, like
|
|
8
|
+
* `AEG:BEYOND-SURFACE`: rewritten by the driver after each live run, and
|
|
9
|
+
* carried over from the live body on every other body write, so an agent's
|
|
10
|
+
* edit to it never survives. One checkbox line per `[live]` command:
|
|
11
|
+
*
|
|
12
|
+
* - passed — ticked, naming the head it passed at and its pass count;
|
|
13
|
+
* - failed — unticked, naming the head and the exit;
|
|
14
|
+
* - unverified — unticked, naming the head and why the host could not run
|
|
15
|
+
* it. The Principal may run it and tick the box, exactly as for a
|
|
16
|
+
* `[principal]` item; the driver keeps that tick while the head and the
|
|
17
|
+
* command are unchanged.
|
|
18
|
+
*
|
|
19
|
+
* `evaluateTestPlanGate` reads each unticked line as it reads an unticked
|
|
20
|
+
* `[principal]` item, so the merge gate stays red while one remains. Every
|
|
21
|
+
* digit sits inside a code span, so the body's bare-digit rule never sees one.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { maskCode } from '@attalabs/aeg-forge-state/strip-code'
|
|
25
|
+
import { anchoredRegion, anchoredRegionBounds } from './anchored-region'
|
|
26
|
+
import { locateTestPlanSection } from './test-plan-section'
|
|
27
|
+
|
|
28
|
+
export type LiveRecordEntry =
|
|
29
|
+
| { command: string; head: string; outcome: 'passed'; passCount: number | null }
|
|
30
|
+
| { command: string; head: string; outcome: 'failed'; detail: string }
|
|
31
|
+
| { command: string; head: string; outcome: 'unverified'; reason: string; ticked: boolean }
|
|
32
|
+
|
|
33
|
+
const LIVE_RECORD_LEAD =
|
|
34
|
+
'**Live checks** — recorded by the review-loop driver after each run on its own host; never edit it:'
|
|
35
|
+
|
|
36
|
+
/** `text` as a code span one backtick longer than any run inside it, padded when it starts or ends with a backtick. */
|
|
37
|
+
function codeSpan(text: string): string {
|
|
38
|
+
const longest = Math.max(0, ...(text.match(/`+/g) ?? []).map((run) => run.length))
|
|
39
|
+
const ticks = '`'.repeat(longest + 1)
|
|
40
|
+
const pad = text.startsWith('`') || text.endsWith('`') ? ' ' : ''
|
|
41
|
+
return `${ticks}${pad}${text}${pad}${ticks}`
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** One entry's line. */
|
|
45
|
+
export function renderLiveRecordLine(entry: LiveRecordEntry): string {
|
|
46
|
+
const at = `at ${codeSpan(entry.head)}`
|
|
47
|
+
const cmd = codeSpan(entry.command)
|
|
48
|
+
switch (entry.outcome) {
|
|
49
|
+
case 'passed':
|
|
50
|
+
return `- [x] **[live]** ${cmd} — passed ${at}, ${
|
|
51
|
+
entry.passCount === null ? 'its output naming no pass count' : `${codeSpan(String(entry.passCount))} passing`
|
|
52
|
+
}`
|
|
53
|
+
case 'failed':
|
|
54
|
+
return `- [ ] **[live]** ${cmd} — failed ${at}: ${entry.detail}`
|
|
55
|
+
case 'unverified':
|
|
56
|
+
return `- [${entry.ticked ? 'x' : ' '}] **[live]** ${cmd} — unverified ${at}: ${entry.reason}; the Principal runs it and ticks this box`
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The whole marked block — the `AEG:LIVE` pair around the lead line and one line per entry, or around nothing when there is none. */
|
|
61
|
+
export function renderLiveRecordBlock(entries: readonly LiveRecordEntry[]): string {
|
|
62
|
+
const inner = entries.length === 0 ? '' : `${[LIVE_RECORD_LEAD, ...entries.map(renderLiveRecordLine)].join('\n')}\n`
|
|
63
|
+
return `<!-- AEG:LIVE:START -->\n${inner}<!-- AEG:LIVE:END -->`
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const RECORD_LINE_RE =
|
|
67
|
+
/^-\s*\[([ xX])\]\s*\*\*\[live\]\*\*\s+(`+) ?(.+?) ?\2(?!`)\s+—\s+(passed|failed|unverified)\s+at\s+`([^`]+)`/
|
|
68
|
+
|
|
69
|
+
/** One line the record carries, as the gate and the driver read it back. */
|
|
70
|
+
export type LiveRecordLine = {
|
|
71
|
+
line: string
|
|
72
|
+
ticked: boolean
|
|
73
|
+
command: string
|
|
74
|
+
outcome: 'passed' | 'failed' | 'unverified'
|
|
75
|
+
head: string
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Every `AEG:LIVE` start or end marker outside code, by position — the driver writes exactly one of each. */
|
|
79
|
+
function liveMarkers(body: string): { start: number; end: number }[] {
|
|
80
|
+
const masked = maskCode(body)
|
|
81
|
+
return [...masked.matchAll(/<!--\s*AEG:LIVE:(?:START|END)\s*-->/g)].map((m) => ({
|
|
82
|
+
start: m.index as number,
|
|
83
|
+
end: (m.index as number) + m[0].length
|
|
84
|
+
}))
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The line read back from a body whose `AEG:LIVE` markers are not exactly one pair: unticked, so the merge gate holds and no run is skipped. */
|
|
88
|
+
const AMBIGUOUS_RECORD_LINE: LiveRecordLine = {
|
|
89
|
+
line: "- [ ] **[live]** the pull request body carries more than one `AEG:LIVE` marker pair, so the driver's record cannot be told apart",
|
|
90
|
+
ticked: false,
|
|
91
|
+
command: '',
|
|
92
|
+
outcome: 'failed',
|
|
93
|
+
head: ''
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Every checkbox line inside the body's `AEG:LIVE` block — `[]` when the body
|
|
98
|
+
* carries none. Fails closed: a body with any marker beyond the driver's one
|
|
99
|
+
* pair reads as a single unticked line, never as the first pair's lines.
|
|
100
|
+
*/
|
|
101
|
+
export function readLiveRecord(body: string): LiveRecordLine[] {
|
|
102
|
+
const markers = liveMarkers(body).length
|
|
103
|
+
if (markers === 0) return []
|
|
104
|
+
if (markers !== 2) return [AMBIGUOUS_RECORD_LINE]
|
|
105
|
+
const region = anchoredRegion(body, 'LIVE')
|
|
106
|
+
if (region === null) return []
|
|
107
|
+
const lines: LiveRecordLine[] = []
|
|
108
|
+
for (const raw of region.split('\n')) {
|
|
109
|
+
const line = raw.trim()
|
|
110
|
+
const m = RECORD_LINE_RE.exec(line)
|
|
111
|
+
if (!m) continue
|
|
112
|
+
lines.push({
|
|
113
|
+
line,
|
|
114
|
+
ticked: (m[1] as string).toLowerCase() === 'x',
|
|
115
|
+
command: m[3] as string,
|
|
116
|
+
outcome: m[4] as LiveRecordLine['outcome'],
|
|
117
|
+
head: m[5] as string
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
return lines
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* `body` with its `AEG:LIVE` block rewritten to `entries` — only that marked
|
|
125
|
+
* region is replaced. A body with no such block gets one at the end of its
|
|
126
|
+
* Test Plan section (after an `AEG:TEST-PLAN` pair when the body has one),
|
|
127
|
+
* else appended.
|
|
128
|
+
*/
|
|
129
|
+
export function withLiveRecord(body: string, entries: readonly LiveRecordEntry[]): string {
|
|
130
|
+
const block = renderLiveRecordBlock(entries)
|
|
131
|
+
const existing = anchoredRegionBounds(body, 'LIVE')
|
|
132
|
+
if (existing) return body.slice(0, existing.outerStart) + block + body.slice(existing.outerEnd)
|
|
133
|
+
const anchoredPlan = anchoredRegionBounds(body, 'TEST-PLAN')
|
|
134
|
+
if (anchoredPlan) return insertAt(body, anchoredPlan.outerEnd, block)
|
|
135
|
+
const located = locateTestPlanSection(body)
|
|
136
|
+
const at = located.found ? body.indexOf(located.section) : -1
|
|
137
|
+
if (located.found && at >= 0) return insertAt(body, at + located.section.length, block)
|
|
138
|
+
return `${body.replace(/\s*$/, '')}\n\n${block}\n`
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function insertAt(body: string, at: number, block: string): string {
|
|
142
|
+
const before = body.slice(0, at).replace(/\s*$/, '')
|
|
143
|
+
const after = body.slice(at).replace(/^\s*/, '')
|
|
144
|
+
return `${before}\n\n${block}\n${after.length > 0 ? `\n${after}` : ''}`
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* `next` with its `AEG:LIVE` block replaced by `current`'s — the driver's own
|
|
149
|
+
* record survives an agent body write, and a block the agent wrote itself
|
|
150
|
+
* never does: with no record on `current`, any block on `next` is removed.
|
|
151
|
+
*/
|
|
152
|
+
export function carryLiveRecord(next: string, current: string | null): string {
|
|
153
|
+
const stripped = withoutAgentLiveRecord(next)
|
|
154
|
+
const kept = current === null || liveMarkers(current).length !== 2 ? null : anchoredRegionBounds(current, 'LIVE')
|
|
155
|
+
if (kept === null) return stripped
|
|
156
|
+
return withLiveRecordBlockText(stripped, (current as string).slice(kept.outerStart, kept.outerEnd))
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* `body` with every `AEG:LIVE` pair an agent wrote removed, contents and all,
|
|
161
|
+
* then every leftover lone marker removed — so no number of forged pairs, and
|
|
162
|
+
* no stray marker pairing with the driver's own, survives.
|
|
163
|
+
*/
|
|
164
|
+
function withoutAgentLiveRecord(body: string): string {
|
|
165
|
+
let out = body
|
|
166
|
+
for (let pair = anchoredRegionBounds(out, 'LIVE'); pair !== null; pair = anchoredRegionBounds(out, 'LIVE')) {
|
|
167
|
+
const before = out.slice(0, pair.outerStart).replace(/\s*$/, '')
|
|
168
|
+
const after = out.slice(pair.outerEnd).replace(/^\s*/, '')
|
|
169
|
+
out = after.length > 0 ? `${before}\n\n${after}` : `${before}\n`
|
|
170
|
+
}
|
|
171
|
+
for (const marker of liveMarkers(out).reverse()) out = out.slice(0, marker.start) + out.slice(marker.end)
|
|
172
|
+
return out
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function withLiveRecordBlockText(body: string, block: string): string {
|
|
176
|
+
const placeholder = withLiveRecord(body, [])
|
|
177
|
+
const bounds = anchoredRegionBounds(placeholder, 'LIVE') as NonNullable<ReturnType<typeof anchoredRegionBounds>>
|
|
178
|
+
return placeholder.slice(0, bounds.outerStart) + block + placeholder.slice(bounds.outerEnd)
|
|
179
|
+
}
|
|
@@ -96,6 +96,8 @@ export type HeaderInput = {
|
|
|
96
96
|
* by the caller (the sink, from `git`/`gh`); this module stays pure.
|
|
97
97
|
*/
|
|
98
98
|
branchIssue?: number | null
|
|
99
|
+
/** Commit already resolved by the caller for a gate event; absent reads null. */
|
|
100
|
+
revision?: string | null
|
|
99
101
|
subject?: Partial<Subject>
|
|
100
102
|
/** Stable per-event identity (O1) — generated by the caller (the sink), once per `log()` call, never here (this module stays free of non-deterministic output). */
|
|
101
103
|
eventId: string
|
|
@@ -105,9 +107,11 @@ export type HeaderInput = {
|
|
|
105
107
|
provenance?: Provenance
|
|
106
108
|
/** Mirrors `review-input-manifest.ts`'s field set (camelCase, matching that module); absent fields read back `null`, never invented. */
|
|
107
109
|
inputVersions?: {
|
|
110
|
+
manifestVersion?: 2 | null
|
|
108
111
|
objectivesVersion?: string | null
|
|
109
112
|
briefHash?: string | null
|
|
110
113
|
rulingOrdinal?: number | null
|
|
114
|
+
pauseBoundRuling?: { rulingId: string; pauseId: string; contentDigest: string } | null
|
|
111
115
|
policyDigest?: string | null
|
|
112
116
|
}
|
|
113
117
|
}
|
|
@@ -155,9 +159,11 @@ export function buildHeader(input: HeaderInput): Header {
|
|
|
155
159
|
parent: lineageFieldFromEnv(input.env.parent)
|
|
156
160
|
},
|
|
157
161
|
input_versions: {
|
|
162
|
+
manifest_version: input.inputVersions?.manifestVersion ?? null,
|
|
158
163
|
objectives_version: input.inputVersions?.objectivesVersion ?? null,
|
|
159
164
|
brief_hash: input.inputVersions?.briefHash ?? null,
|
|
160
165
|
ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
|
|
166
|
+
pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
|
|
161
167
|
policy_digest: input.inputVersions?.policyDigest ?? null
|
|
162
168
|
},
|
|
163
169
|
provenance: provenanceFor(input),
|
|
@@ -165,8 +171,8 @@ export function buildHeader(input: HeaderInput): Header {
|
|
|
165
171
|
// A stated reference wins; failing that the Issue number `subject.issue` already carries; never anything guessed.
|
|
166
172
|
ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
|
|
167
173
|
repo: input.repo,
|
|
168
|
-
change: null,
|
|
169
|
-
revision: null
|
|
174
|
+
change: pr === undefined ? null : String(pr),
|
|
175
|
+
revision: input.revision ?? null
|
|
170
176
|
},
|
|
171
177
|
flow: {
|
|
172
178
|
id: lineageFieldFromEnv(input.env.flow) ?? 'vinaya',
|
|
@@ -36,6 +36,7 @@ export {
|
|
|
36
36
|
} from './fixtures'
|
|
37
37
|
export type { ExecutionName, FactSheet, FixtureExecution, FixtureLine, FixtureValidity } from './fixtures'
|
|
38
38
|
export { redact } from './redact'
|
|
39
|
+
export { describeSchema, logEventSchemaDigest, schemaDigest } from './schema-digest'
|
|
39
40
|
export {
|
|
40
41
|
classifyStoredLine,
|
|
41
42
|
createFixtureStore,
|
|
@@ -39,6 +39,8 @@ const REASONS: Record<string, { words: string; person: boolean }> = {
|
|
|
39
39
|
stale_driver: { words: 'the base branch moved past the driver code', person: false },
|
|
40
40
|
brief_superseded: { words: 'the brief was replaced during the round', person: false },
|
|
41
41
|
policy_changed: { words: 'the review policy changed during the round', person: false },
|
|
42
|
+
sandbox_refused: { words: "the agent's sandbox could not run a command on this host", person: true },
|
|
43
|
+
missing_source: { words: 'a required source could not be prepared', person: true },
|
|
42
44
|
principal_stop: { words: 'an item needs a person to decide', person: true },
|
|
43
45
|
escalated: { words: 'a role escalated a question', person: true }
|
|
44
46
|
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The event validator's structural digest: one short string that names exactly
|
|
3
|
+
* which lines a build of `LogEventSchema` accepts, so two processes can tell
|
|
4
|
+
* whether they validate the same way without sharing anything but the string.
|
|
5
|
+
*
|
|
6
|
+
* The log server reports the digest of the validator it bundled on its stats
|
|
7
|
+
* route, and the CLI compares it with its own (`vinaya log selftest`,
|
|
8
|
+
* `vinaya doctor`). A server whose digest differs was deployed from an older
|
|
9
|
+
* (or newer) schema, and refuses or stores verbatim lines the sender considers
|
|
10
|
+
* valid — the drift a rejected-row count only shows after the events are lost.
|
|
11
|
+
*
|
|
12
|
+
* The digest is computed from the validator's own structure, never from a
|
|
13
|
+
* hand-maintained constant, the package version or the source file's text: a
|
|
14
|
+
* walk over the zod definition tree produces a canonical description (every
|
|
15
|
+
* object's keys, sorted; every union's members, sorted; every literal, enum
|
|
16
|
+
* value and string or number check), and the digest is that description's
|
|
17
|
+
* SHA-256. Two validators that accept a different key differ in the
|
|
18
|
+
* description, so in the digest; the same validator yields the same
|
|
19
|
+
* description in any process, because nothing in it depends on declaration
|
|
20
|
+
* order, object identity or the runtime.
|
|
21
|
+
*
|
|
22
|
+
* What a walk cannot see is a refinement's body — `.refine(fn)` is opaque
|
|
23
|
+
* code. The description records that a refinement is there, and where, but a
|
|
24
|
+
* change to its predicate alone does not change the digest.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { createHash } from 'node:crypto'
|
|
28
|
+
import type { ZodTypeAny } from 'zod'
|
|
29
|
+
import { LogEventSchema } from './schema'
|
|
30
|
+
|
|
31
|
+
/** A node of the canonical description — plain JSON, so its serialization is the whole of its identity. */
|
|
32
|
+
type Shape = null | boolean | number | string | Shape[] | { [key: string]: Shape }
|
|
33
|
+
|
|
34
|
+
type Def = Record<string, unknown> & { typeName?: string }
|
|
35
|
+
|
|
36
|
+
function defOf(schema: unknown): Def {
|
|
37
|
+
const def = (schema as { _def?: unknown } | null)?._def
|
|
38
|
+
if (def === null || typeof def !== 'object') {
|
|
39
|
+
throw new Error('schema digest: a node of the validator carries no definition to walk')
|
|
40
|
+
}
|
|
41
|
+
return def as Def
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Serialization used for both sorting and hashing: key order inside `describe`'s output is already fixed. */
|
|
45
|
+
function serialize(shape: Shape): string {
|
|
46
|
+
return JSON.stringify(shape)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Members whose order carries no meaning (union options, enum values, checks), in one canonical order. */
|
|
50
|
+
function sortedShapes(shapes: Shape[]): Shape[] {
|
|
51
|
+
return shapes
|
|
52
|
+
.map((shape) => [serialize(shape), shape] as const)
|
|
53
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
54
|
+
.map(([, shape]) => shape)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A string, number or array check: its kind and every bound or pattern it holds. */
|
|
58
|
+
function describeChecks(checks: unknown): Shape[] {
|
|
59
|
+
if (!Array.isArray(checks)) return []
|
|
60
|
+
return sortedShapes(
|
|
61
|
+
checks.map((check: Record<string, unknown>) => {
|
|
62
|
+
const out: { [key: string]: Shape } = { kind: String(check.kind) }
|
|
63
|
+
for (const key of Object.keys(check).sort()) {
|
|
64
|
+
if (key === 'kind' || key === 'message') continue
|
|
65
|
+
const value = check[key]
|
|
66
|
+
if (value instanceof RegExp) out[key] = { source: value.source, flags: value.flags }
|
|
67
|
+
else if (value === undefined) continue
|
|
68
|
+
else out[key] = value as Shape
|
|
69
|
+
}
|
|
70
|
+
return out
|
|
71
|
+
})
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function lengthBound(value: unknown): Shape {
|
|
76
|
+
if (value === null || typeof value !== 'object') return null
|
|
77
|
+
return (value as { value?: number }).value ?? null
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The canonical description of one validator node. A construct this walk does
|
|
82
|
+
* not know is an error, never a silent skip: a digest that ignored part of the
|
|
83
|
+
* validator would report two different validators as the same one.
|
|
84
|
+
*/
|
|
85
|
+
function describe(schema: ZodTypeAny, walking: Set<unknown>): Shape {
|
|
86
|
+
const def = defOf(schema)
|
|
87
|
+
const type = def.typeName
|
|
88
|
+
switch (type) {
|
|
89
|
+
case 'ZodString':
|
|
90
|
+
case 'ZodNumber':
|
|
91
|
+
case 'ZodBigInt':
|
|
92
|
+
case 'ZodDate':
|
|
93
|
+
return { type, checks: describeChecks(def.checks) }
|
|
94
|
+
case 'ZodBoolean':
|
|
95
|
+
case 'ZodNull':
|
|
96
|
+
case 'ZodUndefined':
|
|
97
|
+
case 'ZodAny':
|
|
98
|
+
case 'ZodUnknown':
|
|
99
|
+
case 'ZodNever':
|
|
100
|
+
case 'ZodVoid':
|
|
101
|
+
case 'ZodNaN':
|
|
102
|
+
case 'ZodSymbol':
|
|
103
|
+
return { type }
|
|
104
|
+
case 'ZodLiteral':
|
|
105
|
+
return { type, value: def.value as Shape }
|
|
106
|
+
case 'ZodEnum':
|
|
107
|
+
return { type, values: [...(def.values as string[])].sort() }
|
|
108
|
+
case 'ZodNativeEnum':
|
|
109
|
+
return { type, values: sortedShapes(Object.values(def.values as Record<string, Shape>)) }
|
|
110
|
+
case 'ZodObject': {
|
|
111
|
+
const shape = (def.shape as () => Record<string, ZodTypeAny>)()
|
|
112
|
+
const keys: { [key: string]: Shape } = {}
|
|
113
|
+
for (const key of Object.keys(shape).sort()) keys[key] = describe(shape[key] as ZodTypeAny, walking)
|
|
114
|
+
const catchall = def.catchall as ZodTypeAny
|
|
115
|
+
return {
|
|
116
|
+
type,
|
|
117
|
+
unknownKeys: String(def.unknownKeys),
|
|
118
|
+
catchall: defOf(catchall).typeName === 'ZodNever' ? null : describe(catchall, walking),
|
|
119
|
+
keys
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
case 'ZodArray':
|
|
123
|
+
return {
|
|
124
|
+
type,
|
|
125
|
+
element: describe(def.type as ZodTypeAny, walking),
|
|
126
|
+
minLength: lengthBound(def.minLength),
|
|
127
|
+
maxLength: lengthBound(def.maxLength),
|
|
128
|
+
exactLength: lengthBound(def.exactLength)
|
|
129
|
+
}
|
|
130
|
+
case 'ZodUnion':
|
|
131
|
+
return { type, options: sortedShapes((def.options as ZodTypeAny[]).map((o) => describe(o, walking))) }
|
|
132
|
+
case 'ZodDiscriminatedUnion':
|
|
133
|
+
return {
|
|
134
|
+
type,
|
|
135
|
+
discriminator: String(def.discriminator),
|
|
136
|
+
options: sortedShapes((def.options as ZodTypeAny[]).map((o) => describe(o, walking)))
|
|
137
|
+
}
|
|
138
|
+
case 'ZodIntersection':
|
|
139
|
+
return {
|
|
140
|
+
type,
|
|
141
|
+
sides: sortedShapes([describe(def.left as ZodTypeAny, walking), describe(def.right as ZodTypeAny, walking)])
|
|
142
|
+
}
|
|
143
|
+
case 'ZodTuple':
|
|
144
|
+
return {
|
|
145
|
+
type,
|
|
146
|
+
items: (def.items as ZodTypeAny[]).map((item) => describe(item, walking)),
|
|
147
|
+
rest: def.rest === null || def.rest === undefined ? null : describe(def.rest as ZodTypeAny, walking)
|
|
148
|
+
}
|
|
149
|
+
case 'ZodRecord':
|
|
150
|
+
case 'ZodMap':
|
|
151
|
+
return {
|
|
152
|
+
type,
|
|
153
|
+
key: describe(def.keyType as ZodTypeAny, walking),
|
|
154
|
+
value: describe(def.valueType as ZodTypeAny, walking)
|
|
155
|
+
}
|
|
156
|
+
case 'ZodSet':
|
|
157
|
+
return {
|
|
158
|
+
type,
|
|
159
|
+
element: describe(def.valueType as ZodTypeAny, walking),
|
|
160
|
+
minSize: lengthBound(def.minSize),
|
|
161
|
+
maxSize: lengthBound(def.maxSize)
|
|
162
|
+
}
|
|
163
|
+
case 'ZodOptional':
|
|
164
|
+
case 'ZodNullable':
|
|
165
|
+
case 'ZodReadonly':
|
|
166
|
+
return { type, inner: describe(def.innerType as ZodTypeAny, walking) }
|
|
167
|
+
case 'ZodDefault':
|
|
168
|
+
case 'ZodCatch':
|
|
169
|
+
// The fallback value is produced, never validated, so it changes no
|
|
170
|
+
// line's acceptance; only the wrapped validator does.
|
|
171
|
+
return { type, inner: describe(def.innerType as ZodTypeAny, walking) }
|
|
172
|
+
case 'ZodBranded':
|
|
173
|
+
return { type, inner: describe(def.type as ZodTypeAny, walking) }
|
|
174
|
+
case 'ZodEffects': {
|
|
175
|
+
const effect = def.effect as { type?: unknown } | undefined
|
|
176
|
+
return { type, effect: String(effect?.type), inner: describe(def.schema as ZodTypeAny, walking) }
|
|
177
|
+
}
|
|
178
|
+
case 'ZodPipeline':
|
|
179
|
+
return { type, in: describe(def.in as ZodTypeAny, walking), out: describe(def.out as ZodTypeAny, walking) }
|
|
180
|
+
case 'ZodLazy': {
|
|
181
|
+
// A self-referencing validator would recurse forever; the second visit
|
|
182
|
+
// of a lazy node describes the reference, not the node again.
|
|
183
|
+
if (walking.has(schema)) return { type, recursive: true }
|
|
184
|
+
walking.add(schema)
|
|
185
|
+
const inner = describe((def.getter as () => ZodTypeAny)(), walking)
|
|
186
|
+
walking.delete(schema)
|
|
187
|
+
return { type, inner }
|
|
188
|
+
}
|
|
189
|
+
default:
|
|
190
|
+
throw new Error(`schema digest: the validator holds a ${String(type)} node, which this walk does not describe`)
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* The canonical description of a validator — the value `schemaDigest` hashes.
|
|
196
|
+
* Exported so a test can show what the digest covers, never for comparison:
|
|
197
|
+
* compare digests.
|
|
198
|
+
*/
|
|
199
|
+
export function describeSchema(schema: ZodTypeAny): Shape {
|
|
200
|
+
return describe(schema, new Set())
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* `sha256:<hex>` of a validator's canonical description. The same validator
|
|
205
|
+
* gives the same digest in every process and runtime; validators that accept
|
|
206
|
+
* a different key, literal, enum value or string/number bound give different
|
|
207
|
+
* ones.
|
|
208
|
+
*/
|
|
209
|
+
export function schemaDigest(schema: ZodTypeAny): string {
|
|
210
|
+
return `sha256:${createHash('sha256')
|
|
211
|
+
.update(serialize(describeSchema(schema)))
|
|
212
|
+
.digest('hex')}`
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
let eventSchemaDigest: string | null = null
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* The digest of `LogEventSchema` as this build bundles it — what the log
|
|
219
|
+
* server reports on its stats route and what the CLI compares that against.
|
|
220
|
+
* Computed once per process: the validator never changes while it runs.
|
|
221
|
+
*/
|
|
222
|
+
export function logEventSchemaDigest(): string {
|
|
223
|
+
eventSchemaDigest ??= schemaDigest(LogEventSchema)
|
|
224
|
+
return eventSchemaDigest
|
|
225
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The Vinaya Log's typed event schema (Linear "Tech spec — The Vinaya Log").
|
|
3
|
-
* This module versions the envelope to `schema:
|
|
3
|
+
* This module versions the envelope to `schema: 3` and widens `kind` past
|
|
4
4
|
* the first three families it originally shipped with.
|
|
5
5
|
*
|
|
6
6
|
* Three families shipped first — `dispatch`, `dev_review_loop`, and
|
|
@@ -126,9 +126,15 @@ const LineageSchema = z
|
|
|
126
126
|
/** Mirrors `review-input-manifest.ts`'s own field set (`briefHash`, `objectivesVersion`, `rulingOrdinal`, `policyDigest`) — the "input versions" O1 asks the envelope to carry, snake_cased to match every other envelope field. Independent of `subject.objectives_version` (kept, unchanged, for backward compatibility); a producer may set either, both, or neither. */
|
|
127
127
|
const InputVersionsSchema = z
|
|
128
128
|
.object({
|
|
129
|
+
manifest_version: z.literal(2).nullable().optional(),
|
|
129
130
|
objectives_version: z.string().nullable(),
|
|
130
131
|
brief_hash: z.string().nullable(),
|
|
131
132
|
ruling_ordinal: z.number().int().nullable(),
|
|
133
|
+
pause_bound_ruling: z
|
|
134
|
+
.object({ rulingId: z.string().min(1), pauseId: z.string().min(1), contentDigest: z.string().min(1) })
|
|
135
|
+
.strict()
|
|
136
|
+
.nullable()
|
|
137
|
+
.optional(),
|
|
132
138
|
policy_digest: z.string().nullable()
|
|
133
139
|
})
|
|
134
140
|
.strict()
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
* in worktrees), not a bug.
|
|
19
19
|
*
|
|
20
20
|
* `defaultBranch: null` means the caller could not derive the default
|
|
21
|
-
* branch (no
|
|
21
|
+
* branch (`resolveDefaultBranch` found no `origin/HEAD`, no remote-tracking
|
|
22
|
+
* `origin/main` or `origin/master`, as in a repository with no remote) — this predicate
|
|
22
23
|
* fails OPEN with a `warning` finding naming why, never a false refusal: a
|
|
23
24
|
* check whose job is refusing risky actions must not itself risk refusing
|
|
24
25
|
* a legitimate one it cannot actually evaluate.
|
|
@@ -52,6 +53,27 @@ function pushesAnyBranchRef(pushRefs: string): boolean {
|
|
|
52
53
|
.some((line) => line.split(/\s+/)[2]?.startsWith('refs/heads/') === true)
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Picks the repository's default branch from local git facts alone, strongest
|
|
58
|
+
* first: the branch `origin/HEAD` points at, else `main` when a remote-tracking
|
|
59
|
+
* `origin/main` exists, else `master` when `origin/master` exists. `null` when
|
|
60
|
+
* none of them resolves — a repository with no remote has no default branch to
|
|
61
|
+
* refuse on. `init.defaultBranch` is deliberately not read: it is a per-user
|
|
62
|
+
* setting for new repositories, not a fact about this one. Pure — the caller
|
|
63
|
+
* reads the facts with local `git` calls and passes them in.
|
|
64
|
+
*/
|
|
65
|
+
export function resolveDefaultBranch(facts: {
|
|
66
|
+
originHead: string | null
|
|
67
|
+
hasOriginMain: boolean
|
|
68
|
+
hasOriginMaster: boolean
|
|
69
|
+
}): string | null {
|
|
70
|
+
const { originHead, hasOriginMain, hasOriginMaster } = facts
|
|
71
|
+
if (originHead !== null && originHead !== '') return originHead
|
|
72
|
+
if (hasOriginMain) return 'main'
|
|
73
|
+
if (hasOriginMaster) return 'master'
|
|
74
|
+
return null
|
|
75
|
+
}
|
|
76
|
+
|
|
55
77
|
export function checkMainBranchRefusal(facts: {
|
|
56
78
|
currentSymbolicBranch: string | null
|
|
57
79
|
defaultBranch: string | null
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
* full, is the one thing being said.
|
|
53
53
|
*/
|
|
54
54
|
|
|
55
|
-
import { anchoredRegionBounds, stripCode } from './anchored-region'
|
|
55
|
+
import { ANCHOR_FIELDS, anchoredRegionBounds, stripCode } from './anchored-region'
|
|
56
56
|
|
|
57
57
|
export type DensityResult = { status: 'pass' | 'fail'; errors: string[] }
|
|
58
58
|
|
|
@@ -75,14 +75,16 @@ function headingSectionBody(prBody: string, heading: string): string | null {
|
|
|
75
75
|
/**
|
|
76
76
|
* `headingSectionBody`'s text with every well-formed `AEG:*` anchor block removed
|
|
77
77
|
* outright (not just unwrapped) — an anchored field (Scope's trailing
|
|
78
|
-
* `AEG:TIER` block, in the canonical template
|
|
79
|
-
*
|
|
78
|
+
* `AEG:TIER` block, in the canonical template, or the driver-written
|
|
79
|
+
* `AEG:BEYOND-SURFACE` block beside it) is a field, not a second prose
|
|
80
|
+
* paragraph, and must not count as one. Every field in `ANCHOR_FIELDS`, so an
|
|
81
|
+
* anchor added there is never a paragraph here. Reuses `anchoredRegionBounds`
|
|
80
82
|
* (the same span `vinaya pr report --write` targets) rather than a second,
|
|
81
83
|
* drifting regex for "what an anchor block looks like."
|
|
82
84
|
*/
|
|
83
85
|
function stripAnchorBlocks(sectionText: string): string {
|
|
84
86
|
let result = sectionText
|
|
85
|
-
for (const field of
|
|
87
|
+
for (const field of ANCHOR_FIELDS) {
|
|
86
88
|
for (;;) {
|
|
87
89
|
const bounds = anchoredRegionBounds(result, field)
|
|
88
90
|
if (!bounds) break
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { join } from 'node:path'
|
|
3
|
+
|
|
4
|
+
/** The fix a refusal names: the one config edit that makes the scripts runnable. */
|
|
5
|
+
export const PRINCIPALS_CONFIG_FIX = 'add "principals": [...] to vinaya.config.json'
|
|
6
|
+
|
|
7
|
+
export type ConfigPrincipalsResult = { ok: true; principals: string[] } | { ok: false; reason: string }
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* `vinaya.config.json`'s `principals` — the logins every aeg-core script
|
|
11
|
+
* counts as a Principal — read as plain JSON beside its precedent
|
|
12
|
+
* `readConfigObjectivesSinceIssue`, because aeg-core cannot depend on
|
|
13
|
+
* `apps/cli`'s zod configuration loader. This is the only place the aeg-core
|
|
14
|
+
* scripts read the key.
|
|
15
|
+
*
|
|
16
|
+
* Never a default: an unreadable file, a file that is not JSON, a missing
|
|
17
|
+
* key, or a value that is not a non-empty array of strings is a refusal whose
|
|
18
|
+
* reason names the fix. An empty list is a misconfiguration (the application's
|
|
19
|
+
* schema requires at least one entry), not "trust nobody". The read is of the
|
|
20
|
+
* working tree, unlike the application's trust-anchored default-branch read.
|
|
21
|
+
* `repoRoot` defaults to the current working directory; a caller that has not
|
|
22
|
+
* `chdir`'d to the repo root passes it explicitly.
|
|
23
|
+
*/
|
|
24
|
+
export function readConfigPrincipals(repoRoot = '.'): ConfigPrincipalsResult {
|
|
25
|
+
const path = join(repoRoot, 'vinaya.config.json')
|
|
26
|
+
let raw: unknown
|
|
27
|
+
try {
|
|
28
|
+
raw = JSON.parse(readFileSync(path, 'utf8'))
|
|
29
|
+
} catch (err) {
|
|
30
|
+
const why = err instanceof Error ? err.message : String(err)
|
|
31
|
+
return { ok: false, reason: `cannot read ${path} as JSON (${why}) — ${PRINCIPALS_CONFIG_FIX}` }
|
|
32
|
+
}
|
|
33
|
+
const value = raw !== null && typeof raw === 'object' ? (raw as { principals?: unknown }).principals : undefined
|
|
34
|
+
if (value === undefined) {
|
|
35
|
+
return { ok: false, reason: `${path} declares no Principal list — ${PRINCIPALS_CONFIG_FIX}` }
|
|
36
|
+
}
|
|
37
|
+
if (!Array.isArray(value) || value.length === 0 || !value.every((p) => typeof p === 'string' && p.length > 0)) {
|
|
38
|
+
return {
|
|
39
|
+
ok: false,
|
|
40
|
+
reason: `${path}'s "principals" must be a non-empty array of login strings — ${PRINCIPALS_CONFIG_FIX}`
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { ok: true, principals: value as string[] }
|
|
44
|
+
}
|