@attalabs/vinaya 0.37.0 → 0.38.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/enforcement.md +5 -4
- package/aeg-root/roles/developer/reference.md +24 -22
- package/aeg-root/roles/developer.md +4 -4
- package/aeg-root/roles/planner/reference.md +11 -0
- package/aeg-root/roles/reviewer.md +5 -3
- package/aeg-root/roles/security.md +3 -2
- package/aeg-root/state-machine.md +1 -1
- package/aeg-root/templates/brief-template.md +4 -4
- package/aeg-root/tranche-model.md +6 -0
- package/dist/checks/bin/check-body-bare-digits.js +139 -12
- package/dist/checks/bin/check-branch-topology.js +171 -13
- package/dist/checks/bin/check-brief-shape.js +139 -12
- package/dist/checks/bin/check-changeset-coverage.js +177 -17
- package/dist/checks/bin/check-closes-n.js +171 -13
- package/dist/checks/bin/check-coherence.js +171 -13
- package/dist/checks/bin/check-dead-branch-push.js +139 -12
- package/dist/checks/bin/check-dispatch-readiness.js +195 -23
- package/dist/checks/bin/check-doc-coverage-push.js +173 -13
- package/dist/checks/bin/check-doc-coverage.js +180 -13
- package/dist/checks/bin/check-doctrine-no-procedures.js +139 -12
- package/dist/checks/bin/check-doctrine-portability.js +173 -13
- package/dist/checks/bin/check-evidence-fresh.js +173 -13
- package/dist/checks/bin/check-exec-bits.js +173 -13
- package/dist/checks/bin/check-first-push-dispatch.js +171 -13
- package/dist/checks/bin/check-issue-assignment.js +171 -13
- package/dist/checks/bin/check-issue-milestone-attach.js +139 -12
- package/dist/checks/bin/check-issue-objectives-numbering.js +139 -12
- package/dist/checks/bin/check-issue-parts-coverage.js +139 -12
- package/dist/checks/bin/check-issue-surface-globs.js +171 -13
- package/dist/checks/bin/check-issue-title-grammar.js +139 -12
- package/dist/checks/bin/check-issue-tranche-label.js +139 -12
- package/dist/checks/bin/check-main-branch-refusal.js +139 -12
- package/dist/checks/bin/check-no-disk-state.js +139 -12
- package/dist/checks/bin/check-pr-premise-reassert.js +139 -12
- package/dist/checks/bin/check-pr-report-density.js +139 -12
- package/dist/checks/bin/check-principal-test-plan-wait.js +139 -12
- package/dist/checks/bin/check-quoted-command.js +173 -13
- package/dist/checks/bin/check-reader-resolvable-prose.js +173 -13
- package/dist/checks/bin/check-registry-gates.js +406 -68
- package/dist/checks/bin/check-retired-vocabulary.js +173 -13
- package/dist/checks/bin/check-review-gate.js +139 -12
- package/dist/checks/bin/check-single-plan-pr.js +139 -12
- package/dist/checks/bin/check-surface-scope.js +171 -13
- package/dist/checks/bin/check-test-plan.js +139 -12
- package/dist/checks/bin/check-token-collection-wired.js +139 -12
- package/dist/checks/bin/check-workspace-escape.js +173 -13
- package/dist/checks/bin/verify-dispatch.js +3849 -0
- package/dist/index.js +7348 -2095
- package/dist/lib/pre-push-cache-test-run.js +42 -2
- package/dist/lib/pre-push-changed-files.js +16 -11
- package/dist/lib/pre-push-select-tests.js +177 -21
- package/package.json +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +7 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +33 -15
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +51 -12
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/index.ts +1 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +31 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +31 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +214 -24
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +11 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +5 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +13 -13
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +46 -145
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +63 -14
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/index.ts +3 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/published-prose.ts +30 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +6 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +0 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +56 -7
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +7 -7
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/leftover-detection.ts +24 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/custom.ts +157 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +44 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/executions.ts +493 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/fact-sheets.ts +111 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/generator.ts +155 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/index.ts +12 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +128 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/catches.ts +63 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/checks.ts +146 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/common.ts +137 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/completion.ts +137 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/convergence.ts +420 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/determinism.ts +65 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/index.ts +69 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/judgment.ts +132 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/labels.ts +21 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/time.ts +167 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/usage.ts +139 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +219 -15
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/store.ts +7 -7
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/cache-contract.ts +207 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/contracts.ts +105 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/engine.ts +308 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/index.ts +34 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/measured.ts +20 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/memory-cache.ts +78 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/normalize.ts +156 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/row.ts +103 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +34 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +70 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +19 -14
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +38 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +5 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-phase-history.ts +46 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +15 -28
- 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/page_client-reference-manifest.js +1 -1
- 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]__04adkz-._.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]__0h9yhwx._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__14ui9sz._.js → [root-of-the-server]__0jdjsxe._.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]__1gjqmhq._.js +1 -1
- 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 +1 -1
- 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 +1 -1
- 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/1-acpmtfmrc35.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3qtt1v3ya-ofe.js → 2f2y8xxok8zph.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3l56x8wjdzvaw.js → 2xevgia1h8g0y.js} +4 -4
- package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
- package/dist/checks/bin/check-token-report.js +0 -6526
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0vtfb0g813gki.js +0 -1
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{yR5RsCxb1OGnYggiaO09S → yNZEFRSjP9BLUfdf96Eol}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{yR5RsCxb1OGnYggiaO09S → yNZEFRSjP9BLUfdf96Eol}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{yR5RsCxb1OGnYggiaO09S → yNZEFRSjP9BLUfdf96Eol}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one normaliser: a stored log line in, exactly one dataset row or
|
|
3
|
+
* exactly one quarantine record out (`apps/cli/specs/log-sync.md`).
|
|
4
|
+
* Validation, schema-version handling and redaction are
|
|
5
|
+
* `classifyStoredLine`'s; this module only maps its three outcomes, and
|
|
6
|
+
* applies the same `redact` to a quarantined line's raw text, which the
|
|
7
|
+
* classifier keeps verbatim. Pure —
|
|
8
|
+
* `node:crypto` is the one import outside this package.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { createHash } from 'node:crypto'
|
|
12
|
+
import type { Provenance } from '../schema'
|
|
13
|
+
import { redact } from '../redact'
|
|
14
|
+
import { classifyStoredLine } from '../store'
|
|
15
|
+
import {
|
|
16
|
+
type DatasetRow,
|
|
17
|
+
type JsonObject,
|
|
18
|
+
LOW_TRUST_BELOW_VERSION,
|
|
19
|
+
type NormalizedLine,
|
|
20
|
+
type RowOrigin,
|
|
21
|
+
type RowTrust,
|
|
22
|
+
type UnknownableField
|
|
23
|
+
} from './row'
|
|
24
|
+
|
|
25
|
+
function sha256(text: string): string {
|
|
26
|
+
return createHash('sha256').update(text).digest('hex')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function asObject(value: unknown): JsonObject {
|
|
30
|
+
return value !== null && typeof value === 'object' ? (value as JsonObject) : {}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function has(obj: JsonObject, key: string): boolean {
|
|
34
|
+
return Object.hasOwn(obj, key)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function stringOrNull(value: unknown): string | null {
|
|
38
|
+
return typeof value === 'string' ? value : null
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function integerOrNull(value: unknown): number | null {
|
|
42
|
+
return typeof value === 'number' && Number.isInteger(value) ? value : null
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const VERSION_PATTERN = /^v?(\d+)\.(\d+)\.(\d+)(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$/
|
|
46
|
+
|
|
47
|
+
type ParsedVersion = { core: [number, number, number]; prerelease: boolean }
|
|
48
|
+
|
|
49
|
+
function parseVersion(text: string): ParsedVersion | null {
|
|
50
|
+
const match = VERSION_PATTERN.exec(text.trim())
|
|
51
|
+
if (match === null) return null
|
|
52
|
+
return { core: [Number(match[1]), Number(match[2]), Number(match[3])], prerelease: match[4] !== undefined }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** `true` when `version` names no readable CLI version, or one below `LOW_TRUST_BELOW_VERSION` (a pre-release of the threshold itself counts as below it). */
|
|
56
|
+
export function isLowTrustVersion(version: string): boolean {
|
|
57
|
+
const parsed = parseVersion(version)
|
|
58
|
+
const floor = parseVersion(LOW_TRUST_BELOW_VERSION) as ParsedVersion
|
|
59
|
+
if (parsed === null) return true
|
|
60
|
+
for (let i = 0; i < 3; i++) {
|
|
61
|
+
const a = parsed.core[i] as number
|
|
62
|
+
const b = floor.core[i] as number
|
|
63
|
+
if (a !== b) return a < b
|
|
64
|
+
}
|
|
65
|
+
return parsed.prerelease
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Normalises one stored line. `origin` records where it was read from and
|
|
70
|
+
* is carried on the result unchanged — it never feeds the identity or the
|
|
71
|
+
* content hash.
|
|
72
|
+
*/
|
|
73
|
+
export function normalizeStoredLine(raw: string, origin: RowOrigin | null = null): NormalizedLine {
|
|
74
|
+
const classified = classifyStoredLine(raw, '')
|
|
75
|
+
if (classified.status !== 'ok') {
|
|
76
|
+
const raw = redact(classified.raw, '')
|
|
77
|
+
return {
|
|
78
|
+
type: 'quarantine',
|
|
79
|
+
record: {
|
|
80
|
+
status: classified.status,
|
|
81
|
+
identity: classified.identity,
|
|
82
|
+
schema: classified.status === 'unknown_version' ? classified.schema : null,
|
|
83
|
+
reason: classified.reason,
|
|
84
|
+
raw,
|
|
85
|
+
contentHash: sha256(raw),
|
|
86
|
+
origin
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const stored = asObject(JSON.parse(classified.postLine))
|
|
92
|
+
const meta = asObject(stored.meta)
|
|
93
|
+
const subject = asObject(stored.subject)
|
|
94
|
+
const schema = classified.schema
|
|
95
|
+
const unknown: Partial<Record<UnknownableField, string>> = {}
|
|
96
|
+
const missing = (field: UnknownableField, headerField: string): null => {
|
|
97
|
+
unknown[field] = `a schema ${schema} header has no ${headerField}`
|
|
98
|
+
return null
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const work = asObject(meta.work)
|
|
102
|
+
const flow = asObject(meta.flow)
|
|
103
|
+
const workRef = has(meta, 'work') ? stringOrNull(work.ref) : missing('workRef', 'work.ref')
|
|
104
|
+
const actor = has(meta, 'actor_id') ? stringOrNull(meta.actor_id) : missing('actor', 'actor_id')
|
|
105
|
+
const flowId = has(meta, 'flow') ? stringOrNull(flow.id) : missing('flowId', 'flow.id')
|
|
106
|
+
const flowVersion = has(meta, 'flow') ? stringOrNull(flow.version) : missing('flowVersion', 'flow.version')
|
|
107
|
+
const provenance = has(meta, 'provenance')
|
|
108
|
+
? (stringOrNull(meta.provenance) as Provenance | null)
|
|
109
|
+
: missing('provenance', 'provenance')
|
|
110
|
+
|
|
111
|
+
const cliVersion = typeof meta.vinaya === 'string' ? meta.vinaya : ''
|
|
112
|
+
let trust: RowTrust | null
|
|
113
|
+
if (isLowTrustVersion(cliVersion)) trust = 'low'
|
|
114
|
+
else if (provenance !== null) trust = provenance
|
|
115
|
+
else {
|
|
116
|
+
trust = null
|
|
117
|
+
unknown.trust = `a schema ${schema} header declares no provenance`
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const payload: Record<string, unknown> = {}
|
|
121
|
+
for (const [key, value] of Object.entries(stored)) {
|
|
122
|
+
if (key !== 'meta' && key !== 'subject' && key !== 'kind' && key !== 'event') payload[key] = value
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const row: DatasetRow = {
|
|
126
|
+
identity: classified.identity,
|
|
127
|
+
schema,
|
|
128
|
+
kind: String(stored.kind),
|
|
129
|
+
event: String(stored.event),
|
|
130
|
+
time: String(meta.ts),
|
|
131
|
+
runId: classified.runId,
|
|
132
|
+
seq: classified.seq,
|
|
133
|
+
workRef,
|
|
134
|
+
actor,
|
|
135
|
+
cliVersion,
|
|
136
|
+
doctrine: String(meta.doctrine),
|
|
137
|
+
flowId,
|
|
138
|
+
flowVersion,
|
|
139
|
+
host: String(meta.host),
|
|
140
|
+
repo: stringOrNull(meta.repo),
|
|
141
|
+
provenance,
|
|
142
|
+
trust,
|
|
143
|
+
issue: integerOrNull(subject.issue),
|
|
144
|
+
pr: integerOrNull(subject.pr),
|
|
145
|
+
round: integerOrNull(subject.round),
|
|
146
|
+
commit: stringOrNull(subject.sha),
|
|
147
|
+
role: String(subject.role),
|
|
148
|
+
objectivesVersion: stringOrNull(subject.objectives_version),
|
|
149
|
+
header: { meta, subject },
|
|
150
|
+
payload,
|
|
151
|
+
contentHash: sha256(classified.postLine),
|
|
152
|
+
origin,
|
|
153
|
+
unknown
|
|
154
|
+
}
|
|
155
|
+
return { type: 'row', row }
|
|
156
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The normalised shape every reader of the Vinaya Log shares
|
|
3
|
+
* (`apps/cli/specs/log-sync.md`): one dataset row per stored line that
|
|
4
|
+
* validated, one quarantine record per line that did not. A row keeps the
|
|
5
|
+
* fields a question filters or groups by as columns and the rest of the
|
|
6
|
+
* event as JSON, so a family added later — a consumer's own declared event
|
|
7
|
+
* included — is stored and read back without a code change here.
|
|
8
|
+
*
|
|
9
|
+
* Nothing in this module names an event kind or an event name: `kind` and
|
|
10
|
+
* `event` are plain text, and the family body is an untyped JSON object.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { Provenance } from '../schema'
|
|
14
|
+
|
|
15
|
+
/** Where a line was read from: the source's stable id and the line's opaque position inside it. Provenance only — never part of a row's identity, since two sources can hold the same event. */
|
|
16
|
+
export type RowOrigin = {
|
|
17
|
+
source: string
|
|
18
|
+
position: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* How far a row's attribution can be trusted. `'low'` for a line written by
|
|
23
|
+
* a CLI older than `LOW_TRUST_BELOW_VERSION`, or naming no readable CLI
|
|
24
|
+
* version; otherwise the provenance the line's own header declares.
|
|
25
|
+
*/
|
|
26
|
+
export type RowTrust = 'low' | Provenance
|
|
27
|
+
|
|
28
|
+
/** A JSON object as parsed from a stored line — a row's header or family body. */
|
|
29
|
+
export type JsonObject = { readonly [key: string]: unknown }
|
|
30
|
+
|
|
31
|
+
/** The row columns that can read as unknown: each one a field some schema version's header does not have. */
|
|
32
|
+
export type UnknownableField = 'workRef' | 'actor' | 'flowId' | 'flowVersion' | 'provenance' | 'trust'
|
|
33
|
+
|
|
34
|
+
/** One stored line that fully validated, normalised. */
|
|
35
|
+
export type DatasetRow = {
|
|
36
|
+
/** The line's stable identity: its `event_id`, or `<run_id>:<seq>` for a schema 1 line. */
|
|
37
|
+
identity: string
|
|
38
|
+
schema: number
|
|
39
|
+
kind: string
|
|
40
|
+
event: string
|
|
41
|
+
/** `meta.ts` as written. */
|
|
42
|
+
time: string
|
|
43
|
+
runId: string
|
|
44
|
+
seq: number
|
|
45
|
+
/** `meta.work.ref` — schema 3 onward; unknown before. */
|
|
46
|
+
workRef: string | null
|
|
47
|
+
/** `meta.actor_id` — schema 2 onward; unknown before. */
|
|
48
|
+
actor: string | null
|
|
49
|
+
/** `meta.vinaya`, the CLI version that wrote the line. */
|
|
50
|
+
cliVersion: string
|
|
51
|
+
doctrine: string
|
|
52
|
+
/** `meta.flow.id` / `meta.flow.version` — schema 3 onward; unknown before. */
|
|
53
|
+
flowId: string | null
|
|
54
|
+
flowVersion: string | null
|
|
55
|
+
host: string
|
|
56
|
+
repo: string | null
|
|
57
|
+
/** `meta.provenance` — schema 2 onward; unknown before. */
|
|
58
|
+
provenance: Provenance | null
|
|
59
|
+
/** `'low'` or the declared provenance; unknown when neither applies (a schema 1 line from a trusted CLI version). */
|
|
60
|
+
trust: RowTrust | null
|
|
61
|
+
issue: number | null
|
|
62
|
+
pr: number | null
|
|
63
|
+
round: number | null
|
|
64
|
+
/** `subject.sha`. */
|
|
65
|
+
commit: string | null
|
|
66
|
+
role: string
|
|
67
|
+
objectivesVersion: string | null
|
|
68
|
+
/** The line's `meta` and `subject` exactly as validated — every header field, including the ones with no column. */
|
|
69
|
+
header: { meta: JsonObject; subject: JsonObject }
|
|
70
|
+
/** Every field of the event outside `meta`, `subject`, `kind` and `event` — the family body, as JSON. */
|
|
71
|
+
payload: JsonObject
|
|
72
|
+
/** sha256 (hex) of the line as the read boundary serialises it after redaction. */
|
|
73
|
+
contentHash: string
|
|
74
|
+
origin: RowOrigin | null
|
|
75
|
+
/**
|
|
76
|
+
* Each column whose value the line's schema cannot state, with the reason.
|
|
77
|
+
* A column named here is `null` and means "not recorded", never "none" —
|
|
78
|
+
* a column absent from this map carries the line's own value, `null`
|
|
79
|
+
* included.
|
|
80
|
+
*/
|
|
81
|
+
unknown: Readonly<Partial<Record<UnknownableField, string>>>
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** One stored line that did not validate: an unknown schema version, or a known one that failed validation. It produces no row. */
|
|
85
|
+
export type QuarantineRecord = {
|
|
86
|
+
status: 'unknown_version' | 'invalid'
|
|
87
|
+
/** The line's identity when one could be read from it, else `null`. */
|
|
88
|
+
identity: string | null
|
|
89
|
+
/** `meta.schema` when readable, else `null`. */
|
|
90
|
+
schema: number | null
|
|
91
|
+
reason: string
|
|
92
|
+
/** The line's text after redaction — a secret in a line that failed validation never reaches a cache. */
|
|
93
|
+
raw: string
|
|
94
|
+
/** sha256 (hex) of `raw` — what keys a quarantine record, since `identity` can be absent. */
|
|
95
|
+
contentHash: string
|
|
96
|
+
origin: RowOrigin | null
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** A stored line after normalisation: exactly one row or exactly one quarantine record. */
|
|
100
|
+
export type NormalizedLine = { type: 'row'; row: DatasetRow } | { type: 'quarantine'; record: QuarantineRecord }
|
|
101
|
+
|
|
102
|
+
/** A line written by a CLI version below this one is low-trust: attribution before it was not recorded reliably. */
|
|
103
|
+
export const LOW_TRUST_BELOW_VERSION = '0.33.0'
|
|
@@ -295,18 +295,34 @@ export function legacySlugPattern(legacySlugs: readonly string[]): RegExp | null
|
|
|
295
295
|
* `PRODUCT_SLUG_SCOPE`) is checked only against `TRANCHE_SLUG_VN_PATTERN`,
|
|
296
296
|
* and its finding is `blocking: true`; every other finding is `blocking: false`.
|
|
297
297
|
*/
|
|
298
|
+
/**
|
|
299
|
+
* The spec class's exemption. The array form lists paths skipped entirely; the
|
|
300
|
+
* object form maps each listed path to the most findings that file may carry —
|
|
301
|
+
* a file above its number fails, at or below it passes, and the number is
|
|
302
|
+
* lowered as the file is rewritten.
|
|
303
|
+
*/
|
|
304
|
+
export type SpecGrandfather = readonly string[] | Readonly<Record<string, number>>
|
|
305
|
+
|
|
306
|
+
/** Every listed path in either form, in the order written. */
|
|
307
|
+
export function specGrandfatherPaths(specGrandfather: SpecGrandfather): string[] {
|
|
308
|
+
return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather)
|
|
309
|
+
}
|
|
310
|
+
|
|
298
311
|
export function checkUnresolvableReferences(
|
|
299
312
|
files: readonly ProseSourceFile[],
|
|
300
313
|
readerFacingPrefix: string,
|
|
301
314
|
readerFacingSuffix: string,
|
|
302
315
|
legacySlugs: readonly string[] = [],
|
|
303
316
|
shipsPrefix: string = SHIPS_PREFIX,
|
|
304
|
-
specGrandfather:
|
|
317
|
+
specGrandfather: SpecGrandfather = [],
|
|
305
318
|
specPaths: readonly string[] = DEFAULT_SPEC_PATHS
|
|
306
319
|
): ProseFinding[] {
|
|
307
320
|
const findings: ProseFinding[] = []
|
|
308
321
|
const legacyPattern = legacySlugPattern(legacySlugs)
|
|
309
|
-
const
|
|
322
|
+
const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? (specGrandfather as readonly string[]) : [])
|
|
323
|
+
const limits = new Map<string, number>(
|
|
324
|
+
Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather as Readonly<Record<string, number>>)
|
|
325
|
+
)
|
|
310
326
|
// `group` names the capture holding the actual cited text — the plain
|
|
311
327
|
// patterns have none (report the whole match), the boundary-checked
|
|
312
328
|
// legacy-slug pattern reports its group 2 so the boundary chars around it
|
|
@@ -343,8 +359,9 @@ export function checkUnresolvableReferences(
|
|
|
343
359
|
// is matched against every spec-class file, so it exempts a default path
|
|
344
360
|
// (a root spec, a decision record) exactly as it exempts a
|
|
345
361
|
// per-product one — one exemption for the class, not one per path
|
|
346
|
-
// source.
|
|
347
|
-
|
|
362
|
+
// source. A path listed with a number is not skipped: its findings are
|
|
363
|
+
// counted below and reported only once they exceed that number.
|
|
364
|
+
if (cls === 'spec' && grandfatheredWhole.has(file.path)) continue
|
|
348
365
|
const blocking = cls === 'product' || cls === 'spec'
|
|
349
366
|
const scrubbed =
|
|
350
367
|
cls === 'product' ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content)
|
|
@@ -352,6 +369,7 @@ export function checkUnresolvableReferences(
|
|
|
352
369
|
// reference pattern set, never the narrower product-code list — plus the
|
|
353
370
|
// task-number rule that applies to this class alone.
|
|
354
371
|
const patternsToRun = cls === 'product' ? productPatterns : cls === 'spec' ? specPatterns : patterns
|
|
372
|
+
const fileFindings: ProseFinding[] = []
|
|
355
373
|
for (const { pattern, what, group } of patternsToRun) {
|
|
356
374
|
pattern.lastIndex = 0
|
|
357
375
|
let match: RegExpExecArray | null = pattern.exec(scrubbed)
|
|
@@ -366,7 +384,7 @@ export function checkUnresolvableReferences(
|
|
|
366
384
|
// one character that can never itself start the cited text, and an
|
|
367
385
|
// empty boundary (start of file) resolves to offset zero.
|
|
368
386
|
const citedIndex = match.index + match[0].indexOf(cited)
|
|
369
|
-
|
|
387
|
+
fileFindings.push({
|
|
370
388
|
file: file.path,
|
|
371
389
|
line: lineAt(scrubbed, citedIndex),
|
|
372
390
|
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
@@ -375,6 +393,16 @@ export function checkUnresolvableReferences(
|
|
|
375
393
|
match = pattern.exec(scrubbed)
|
|
376
394
|
}
|
|
377
395
|
}
|
|
396
|
+
const limit = cls === 'spec' ? limits.get(file.path) : undefined
|
|
397
|
+
if (limit !== undefined) {
|
|
398
|
+
if (fileFindings.length <= limit) continue
|
|
399
|
+
// Every finding of the over-limit file carries the count and the limit,
|
|
400
|
+
// so whichever ones a diff-scoped run prints still name both.
|
|
401
|
+
for (const f of fileFindings) {
|
|
402
|
+
f.message += `; ${file.path} carries ${fileFindings.length} such findings, over its proseGates.specGrandfather limit of ${limit}`
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
findings.push(...fileFindings)
|
|
378
406
|
}
|
|
379
407
|
return findings
|
|
380
408
|
}
|
|
@@ -637,7 +665,7 @@ export function checkReaderResolvableProse(
|
|
|
637
665
|
readerFacingSuffix: string,
|
|
638
666
|
legacySlugs: readonly string[] = [],
|
|
639
667
|
shipsPrefix: string = SHIPS_PREFIX,
|
|
640
|
-
specGrandfather:
|
|
668
|
+
specGrandfather: SpecGrandfather = [],
|
|
641
669
|
specPaths: readonly string[] = DEFAULT_SPEC_PATHS
|
|
642
670
|
): ProseFinding[] {
|
|
643
671
|
return [
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* (`'fail'` on any violation).
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import { extractCitedPaths } from './doctrine-portability'
|
|
25
26
|
import { GATE_AUDIENCE, isShipped, NON_GATE_BINS } from './gate-audience'
|
|
26
27
|
import type { GateRow } from './registry-parse'
|
|
27
28
|
|
|
@@ -39,14 +40,76 @@ export type RegistryCheckResult = {
|
|
|
39
40
|
findings: RegistryFinding[]
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
/** The hook directories a doctrine citation may name a script under. */
|
|
44
|
+
const HOOK_DIR_PREFIXES: readonly string[] = ['.claude/hooks/', '.vinaya/hooks/', '.husky/', '.git/hooks/']
|
|
45
|
+
|
|
46
|
+
/** A bare hook-script name — `check-*.sh` — cited with no directory. */
|
|
47
|
+
const BARE_HOOK_NAME = /^check-[A-Za-z0-9_.-]*\.sh$/
|
|
48
|
+
|
|
49
|
+
/** One doctrine file's path and text, read by the caller. */
|
|
50
|
+
export type HookScanFile = { path: string; content: string }
|
|
51
|
+
|
|
52
|
+
/** What G1's hook-reference half needs from its caller: the doctrine files to
|
|
53
|
+
* scan, and every hook path that counts as shipped (tracked in git, or emitted
|
|
54
|
+
* by `vinaya init`). */
|
|
55
|
+
export type HookReferenceInput = { docs: HookScanFile[]; shipped: ReadonlySet<string> }
|
|
56
|
+
|
|
57
|
+
function basename(path: string): string {
|
|
58
|
+
return path.slice(path.lastIndexOf('/') + 1)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function lineOf(content: string, index: number): number {
|
|
62
|
+
let line = 1
|
|
63
|
+
for (let i = 0; i < index; i++) if (content.charCodeAt(i) === 10) line++
|
|
64
|
+
return line
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Every inline-code token in `docs` that names a hook script that is not in
|
|
69
|
+
* `shipped`: a full path under a hook directory (`.claude/hooks/`,
|
|
70
|
+
* `.vinaya/hooks/`, `.husky/`, `.git/hooks/`), or a bare `check-*.sh` name that
|
|
71
|
+
* matches the basename of no shipped path. A directory or glob token
|
|
72
|
+
* (`.husky/`, `.husky/*`) names no single script and is never a finding.
|
|
73
|
+
*/
|
|
74
|
+
export function findUnshippedHookRefs(docs: HookScanFile[], shipped: ReadonlySet<string>): RegistryFinding[] {
|
|
75
|
+
const shippedNames = new Set([...shipped].map(basename))
|
|
76
|
+
const findings: RegistryFinding[] = []
|
|
77
|
+
const flag = (doc: HookScanFile, token: string, index: number): void => {
|
|
78
|
+
findings.push({
|
|
79
|
+
path: doc.path,
|
|
80
|
+
reason: `${doc.path}:${lineOf(doc.content, index)} names hook "${token}", which is neither tracked in git nor emitted by \`vinaya init\``
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
for (const doc of docs) {
|
|
84
|
+
for (const { cited, index } of extractCitedPaths(doc.content)) {
|
|
85
|
+
if (cited.endsWith('/') || !HOOK_DIR_PREFIXES.some((p) => cited.startsWith(p))) continue
|
|
86
|
+
if (!shipped.has(cited)) flag(doc, cited, index)
|
|
87
|
+
}
|
|
88
|
+
const spanPattern = /`([^`\n]+)`/g
|
|
89
|
+
let match: RegExpExecArray | null = spanPattern.exec(doc.content)
|
|
90
|
+
while (match !== null) {
|
|
91
|
+
const token = match[1] ?? ''
|
|
92
|
+
if (BARE_HOOK_NAME.test(token) && !shippedNames.has(token)) flag(doc, token, match.index)
|
|
93
|
+
match = spanPattern.exec(doc.content)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return findings
|
|
97
|
+
}
|
|
98
|
+
|
|
42
99
|
/**
|
|
43
|
-
* G1 — every row's non-empty `implementation` resolves on disk
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
100
|
+
* G1 — every row's non-empty `implementation` resolves on disk, and — when the
|
|
101
|
+
* caller supplies `hookRefs` — every hook script the doctrine names is shipped
|
|
102
|
+
* (`findUnshippedHookRefs`). Blocking as of task 8 (re-graded from
|
|
103
|
+
* report-only: eleven permanent `info` findings on every run had become
|
|
104
|
+
* indistinguishable from silence, which is how the gap this tranche closes
|
|
105
|
+
* stayed invisible; the report-only window had already cleared the backlog it
|
|
106
|
+
* existed to surface).
|
|
48
107
|
*/
|
|
49
|
-
export function checkG1(
|
|
108
|
+
export function checkG1(
|
|
109
|
+
rows: GateRow[],
|
|
110
|
+
existsFn: (path: string) => boolean,
|
|
111
|
+
hookRefs?: HookReferenceInput
|
|
112
|
+
): RegistryCheckResult {
|
|
50
113
|
const findings: RegistryFinding[] = []
|
|
51
114
|
for (const row of rows) {
|
|
52
115
|
if (row.implementation === '') continue
|
|
@@ -58,6 +121,7 @@ export function checkG1(rows: GateRow[], existsFn: (path: string) => boolean): R
|
|
|
58
121
|
})
|
|
59
122
|
}
|
|
60
123
|
}
|
|
124
|
+
if (hookRefs) findings.push(...findUnshippedHookRefs(hookRefs.docs, hookRefs.shipped))
|
|
61
125
|
return { check: 'G1', status: findings.length > 0 ? 'fail' : 'pass', findings }
|
|
62
126
|
}
|
|
63
127
|
|
|
@@ -60,27 +60,32 @@ export function briefHash(brief: string): string {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
* `sha256` of the
|
|
64
|
-
*
|
|
65
|
-
* callers resolving the identical `ReviewPolicy`
|
|
66
|
-
* digest regardless of how they built the object
|
|
63
|
+
* `sha256` of the two review-policy settings that decide whether a verdict's
|
|
64
|
+
* findings block — `codeReviewThreshold` and `securityThreshold` — in one
|
|
65
|
+
* canonical field order so two callers resolving the identical `ReviewPolicy`
|
|
66
|
+
* value always agree on its digest regardless of how they built the object
|
|
67
|
+
* literal. This is what a verdict binds against: change either threshold and
|
|
68
|
+
* verdicts cast under the old one no longer cover the policy, so the gate
|
|
69
|
+
* demands a fresh round (O2).
|
|
67
70
|
*
|
|
68
|
-
* `maxRounds`
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
71
|
+
* `maxRounds` and `maxTaskMinutes` are deliberately LEFT OUT of the digest
|
|
72
|
+
* (O1). They are the loop's own limits — the round cap and the wall-clock
|
|
73
|
+
* budget — and they bound only how long the loop runs, never whether a finding
|
|
74
|
+
* in an already-cast verdict blocks. Folding them in (as this digest once did)
|
|
75
|
+
* meant that merely changing a limit re-computed the digest and re-opened every
|
|
76
|
+
* approved pull request for a fresh review round with no code change — twice in
|
|
77
|
+
* two days, once for removing a `maxRounds` override and once for adding
|
|
78
|
+
* `maxTaskMinutes`. Because the two limits cannot change any verdict's block
|
|
79
|
+
* decision, the digest a verdict binds to covers the blocking thresholds only
|
|
80
|
+
* (a Principal decision). The fields still live on `ReviewPolicy` and the
|
|
81
|
+
* loop still reads them; they are simply not part of this identity.
|
|
76
82
|
*/
|
|
77
83
|
export function policyDigest(policy: ReviewPolicy): string {
|
|
78
84
|
return createHash('sha256')
|
|
79
85
|
.update(
|
|
80
86
|
JSON.stringify({
|
|
81
87
|
codeReviewThreshold: policy.codeReviewThreshold,
|
|
82
|
-
securityThreshold: policy.securityThreshold
|
|
83
|
-
maxRounds: policy.maxRounds
|
|
88
|
+
securityThreshold: policy.securityThreshold
|
|
84
89
|
})
|
|
85
90
|
)
|
|
86
91
|
.digest('hex')
|
|
@@ -25,18 +25,53 @@ export type SecuritySeverity = (typeof SECURITY_SEVERITY_ORDER)[number]
|
|
|
25
25
|
/** The dev-review-loop's own round cap, default — replaces the `assess-round.ts` constant this once was; overridable via `reviewPolicy.maxRounds` in `vinaya.config.json`. */
|
|
26
26
|
export const DEFAULT_MAX_ROUNDS = 3
|
|
27
27
|
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* The dev-review-loop's own wall-clock budget for one task, in minutes —
|
|
30
|
+
* default, overridable via `reviewPolicy.maxTaskMinutes`. Three hours: long
|
|
31
|
+
* enough that no honest multi-round task has ever needed more, short enough
|
|
32
|
+
* that a loop nobody is watching cannot spend a night on one task.
|
|
33
|
+
*
|
|
34
|
+
* The round cap above bounds review ROUNDS, and nothing bounded the time
|
|
35
|
+
* between them: a loop can spend hours pushing, rebasing and retrying without
|
|
36
|
+
* the round number ever advancing, so the cap it would eventually hit is one
|
|
37
|
+
* it never reaches. This budget bounds the whole task instead, whatever the
|
|
38
|
+
* time went to.
|
|
39
|
+
*/
|
|
40
|
+
export const DEFAULT_MAX_TASK_MINUTES = 180
|
|
41
|
+
|
|
42
|
+
/** An omitted policy means today's behaviour: code review at `BLOCKER`, security at `HIGH`, `DEFAULT_MAX_ROUNDS` rounds, `DEFAULT_MAX_TASK_MINUTES` minutes. */
|
|
29
43
|
export const DEFAULT_REVIEW_POLICY: ReviewPolicy = {
|
|
30
44
|
codeReviewThreshold: 'BLOCKER',
|
|
31
45
|
securityThreshold: 'HIGH',
|
|
32
|
-
maxRounds: DEFAULT_MAX_ROUNDS
|
|
46
|
+
maxRounds: DEFAULT_MAX_ROUNDS,
|
|
47
|
+
maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
export type ReviewPolicy = {
|
|
36
51
|
codeReviewThreshold: CodeReviewSeverity
|
|
37
52
|
securityThreshold: SecuritySeverity
|
|
38
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* The dev-review-loop's own round cap — repository policy, not a hardcoded
|
|
55
|
+
* constant. Resolved once per loop run, same trust class as the two
|
|
56
|
+
* thresholds above. NOT part of `policyDigest` (`review-input-manifest.ts`):
|
|
57
|
+
* a round cap bounds how long the loop runs, never whether a finding in an
|
|
58
|
+
* already-cast verdict blocks, so changing it must not invalidate a verdict.
|
|
59
|
+
*/
|
|
39
60
|
maxRounds: number
|
|
61
|
+
/**
|
|
62
|
+
* The dev-review-loop's own wall-clock budget for one task, in minutes,
|
|
63
|
+
* measured from the loop's first recorded start for that task rather than
|
|
64
|
+
* from any one driver process's own start. `0` turns the budget off —
|
|
65
|
+
* the one value that disables a bound rather than tightening it, so a
|
|
66
|
+
* repository that would rather bound only rounds can say so explicitly
|
|
67
|
+
* instead of setting a number large enough to never fire.
|
|
68
|
+
*
|
|
69
|
+
* Same trust class and same resolution point as the fields above: read from
|
|
70
|
+
* the default branch, resolved once per loop run. Like `maxRounds`, NOT part
|
|
71
|
+
* of `policyDigest` (`review-input-manifest.ts`): the budget bounds how long
|
|
72
|
+
* the loop runs, never whether a finding in an already-cast verdict blocks.
|
|
73
|
+
*/
|
|
74
|
+
maxTaskMinutes: number
|
|
40
75
|
}
|
|
41
76
|
|
|
42
77
|
/** The minimal shape the evaluator needs — every real finding type (review-post.ts's `Finding`, a gate-side severity-only extraction) satisfies it. `location` is optional so a caller with no location to report (an older extraction shape) still type-checks; such a finding is simply never prose-capped (O5, below). */
|
|
@@ -226,8 +226,11 @@ export function deriveReviewStatus(input: ReviewStatusInput): ReviewStatus {
|
|
|
226
226
|
return { state: 'PAUSE', reason: 'objectives-moved', round: rounds.length }
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
// max-rounds — the count alone
|
|
230
|
-
//
|
|
229
|
+
// max-rounds — the count alone: the cap is the number of rounds that run,
|
|
230
|
+
// so the round that reaches it is the last, and the Principal decides
|
|
231
|
+
// whether the loop continues. The loop pauses at the same round
|
|
232
|
+
// (`assessRound` compares `obs.round >= maxRounds`); a green round is the
|
|
233
|
+
// one difference — the loop publishes it, this read has no green signal.
|
|
231
234
|
if (rounds.length >= input.maxRounds) return { state: 'PAUSE', reason: 'max-rounds', round: rounds.length }
|
|
232
235
|
|
|
233
236
|
return { state: 'CONTINUE' }
|
|
@@ -89,6 +89,52 @@ export function phaseHistoryClassFor(phase: string): PhaseHistoryClass | null {
|
|
|
89
89
|
return null
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
// --- which phases count as WORK, for the task time budget -------------------
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The recorded phases the task time budget does NOT count — the two a driver
|
|
96
|
+
* sits in without working the task forward: `pause` (the task is waiting for a
|
|
97
|
+
* Principal) and `publish` (the pull request is already approved and the loop
|
|
98
|
+
* is only posting). Every other recorded phase is a driver doing the task's
|
|
99
|
+
* own work — `dispatch_developer` (developing, which spans the push and the
|
|
100
|
+
* gate wait after it, and the mechanical retries recorded under the same
|
|
101
|
+
* word), `dispatch_reviewers` (reviewing), and `ask_confidence` (a developer
|
|
102
|
+
* re-ask turn, not separable from the developing it interrupts).
|
|
103
|
+
*/
|
|
104
|
+
export const INACTIVE_BUDGET_PHASES = ['pause', 'publish'] as const
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Whether a recorded phase is ACTIVE work the time budget counts. A phase this
|
|
108
|
+
* vocabulary does not know is NOT active: an unknown recorded word is no
|
|
109
|
+
* evidence a driver was working, and the budget exists to bound work, so the
|
|
110
|
+
* safe direction on an unknown is to under-count (the task runs longer) rather
|
|
111
|
+
* than to pause it on a phase that cannot be vouched for — the very failure
|
|
112
|
+
* the first cut of this budget produced when it counted wall-clock age.
|
|
113
|
+
*
|
|
114
|
+
* Time with no driver running at all is never recorded against any phase, so
|
|
115
|
+
* it is excluded by its own absence from the map, never by this predicate.
|
|
116
|
+
*/
|
|
117
|
+
export function isActiveBudgetPhase(phase: string): boolean {
|
|
118
|
+
return isRecordedLoopPhase(phase) && !(INACTIVE_BUDGET_PHASES as readonly string[]).includes(phase)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The task time budget's clock: the sum of every ACTIVE phase's recorded
|
|
123
|
+
* milliseconds, and nothing else. This is the one figure the budget is decided
|
|
124
|
+
* on (`taskBudgetExceeded`), and the total the pause detail reports as spent —
|
|
125
|
+
* so a task that sat paused, published, or driverless for hours is measured by
|
|
126
|
+
* the minutes it actually worked, never by its age. A negative recorded value
|
|
127
|
+
* (a clock skew a driver could have written) contributes nothing rather than
|
|
128
|
+
* subtracting from the sum.
|
|
129
|
+
*/
|
|
130
|
+
export function activeBudgetMs(byPhaseMs: Record<string, number>): number {
|
|
131
|
+
let sum = 0
|
|
132
|
+
for (const [phase, ms] of Object.entries(byPhaseMs)) {
|
|
133
|
+
if (isActiveBudgetPhase(phase) && ms > 0) sum += ms
|
|
134
|
+
}
|
|
135
|
+
return sum
|
|
136
|
+
}
|
|
137
|
+
|
|
92
138
|
// --- typical phase times, from merged pull requests -------------------------
|
|
93
139
|
|
|
94
140
|
/** One comment as a history read sees it: its body, its author, and the forge's own creation timestamp. */
|