@attalabs/vinaya 0.40.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/aeg-root/contracts/developer-reviewer.md +2 -2
- package/aeg-root/contracts/planner-developer.md +4 -4
- package/aeg-root/process.md +3 -3
- package/aeg-root/roles/developer/reference.md +3 -0
- package/aeg-root/state-machine.md +2 -2
- package/aeg-root/templates/brief-template.md +1 -1
- package/dist/checks/bin/check-body-bare-digits.js +165 -65
- package/dist/checks/bin/check-branch-topology.js +169 -60
- package/dist/checks/bin/check-brief-shape.js +165 -65
- package/dist/checks/bin/check-changeset-coverage.js +342 -122
- package/dist/checks/bin/check-ci-shard-coverage.js +384 -130
- package/dist/checks/bin/check-closes-n.js +169 -60
- package/dist/checks/bin/check-coherence.js +165 -65
- package/dist/checks/bin/check-dead-branch-push.js +142 -59
- package/dist/checks/bin/check-dispatch-readiness.js +211 -81
- package/dist/checks/bin/check-doc-claims.js +165 -65
- package/dist/checks/bin/check-doc-coverage-push.js +342 -122
- package/dist/checks/bin/check-doc-coverage.js +344 -124
- package/dist/checks/bin/check-doctrine-no-procedures.js +165 -65
- package/dist/checks/bin/check-doctrine-portability.js +342 -122
- package/dist/checks/bin/check-evidence-fresh.js +376 -129
- package/dist/checks/bin/check-exec-bits.js +342 -122
- package/dist/checks/bin/check-first-push-dispatch.js +208 -78
- package/dist/checks/bin/check-issue-milestone-attach.js +142 -59
- package/dist/checks/bin/check-issue-objectives-numbering.js +165 -65
- package/dist/checks/bin/check-issue-parts-coverage.js +142 -59
- package/dist/checks/bin/check-issue-surface-globs.js +218 -88
- package/dist/checks/bin/check-issue-title-grammar.js +142 -59
- package/dist/checks/bin/check-main-branch-refusal.js +142 -59
- package/dist/checks/bin/check-no-disk-state.js +142 -59
- package/dist/checks/bin/check-pr-premise-reassert.js +165 -65
- package/dist/checks/bin/check-pr-report-density.js +142 -59
- package/dist/checks/bin/check-principal-test-plan-wait.js +165 -65
- package/dist/checks/bin/check-quoted-command.js +338 -118
- package/dist/checks/bin/check-reader-resolvable-prose.js +338 -118
- package/dist/checks/bin/check-registry-gates.js +206 -78
- package/dist/checks/bin/check-retired-vocabulary.js +338 -118
- package/dist/checks/bin/check-review-gate.js +203 -83
- package/dist/checks/bin/check-single-plan-pr.js +142 -59
- package/dist/checks/bin/check-surface-scope.js +169 -60
- package/dist/checks/bin/check-test-plan.js +165 -65
- package/dist/checks/bin/check-token-collection-wired.js +142 -59
- package/dist/checks/bin/check-workspace-escape.js +340 -120
- package/dist/checks/bin/verify-coherence.js +153 -60
- package/dist/checks/bin/verify-dispatch.js +169 -69
- package/dist/checks/bin/verify-docs.js +142 -57
- package/dist/index.js +16280 -11764
- package/dist/lib/pre-push-cache-test-run.js +791 -68
- 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 +1426 -454
- package/dist/lib/push-progress-observer.js +4213 -0
- package/package.json +11 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +5 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +18 -4
- 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 +17 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +13 -17
- 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/gate-audience.ts +1 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +77 -7
- 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 +221 -56
- 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 +1 -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/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 +52 -109
- 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/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.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.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.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.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.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.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.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]__1a3j3n1._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1wzfiav._.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/{38kom-9c-oi65.js → 0x7u6si-ai179.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1p3vr9qts86_b.js → 2fu7mfsj4oima.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{21tunzmxjvm2a.js → 34b4ruddunn3q.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{Y3oaZSTSP9PivUuJvxK1W → 2ZARxTwpuRew8-SvYsRdU}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{Y3oaZSTSP9PivUuJvxK1W → 2ZARxTwpuRew8-SvYsRdU}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{Y3oaZSTSP9PivUuJvxK1W → 2ZARxTwpuRew8-SvYsRdU}/_ssgManifest.js +0 -0
|
@@ -40,6 +40,7 @@ const REASONS: Record<string, { words: string; person: boolean }> = {
|
|
|
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
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 },
|
|
43
44
|
principal_stop: { words: 'an item needs a person to decide', person: true },
|
|
44
45
|
escalated: { words: 'a role escalated a question', person: true }
|
|
45
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
|
|
@@ -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
|
+
}
|