@attalabs/vinaya 0.42.1 → 0.43.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.
Files changed (88) hide show
  1. package/dist/checks/bin/check-evidence-fresh.js +177 -152
  2. package/dist/checks/bin/check-registry-gates.js +10 -3
  3. package/dist/index.js +300 -173
  4. package/dist/lib/pre-push-cache-test-run.js +145 -144
  5. package/dist/lib/pre-push-changed-files.js +10 -3
  6. package/dist/lib/pre-push-progress-dir.js +169 -147
  7. package/dist/lib/pre-push-select-tests.js +16 -4
  8. package/dist/lib/push-progress-observer.js +169 -147
  9. package/dist/programs/archive.js +172 -148
  10. package/dist/programs/audit.js +169 -147
  11. package/dist/programs/check.js +172 -148
  12. package/dist/programs/commit-msg.js +172 -148
  13. package/dist/programs/dev-review-loop.js +300 -176
  14. package/dist/programs/dispatch.js +1905 -1877
  15. package/dist/programs/log-emit.js +172 -148
  16. package/dist/programs/log-selftest.js +172 -148
  17. package/dist/programs/log-send.js +172 -148
  18. package/dist/programs/pr-report.js +177 -152
  19. package/dist/programs/pr-snapshot.js +172 -148
  20. package/dist/programs/pr-verify-evidence.js +177 -152
  21. package/dist/programs/pr.js +172 -148
  22. package/dist/programs/review-post.js +172 -148
  23. package/dist/programs/review-status.js +180 -148
  24. package/dist/programs/run-engine.js +110594 -0
  25. package/dist/programs/supervised-command.js +67 -0
  26. package/dist/programs/sync.js +63 -39
  27. package/dist/programs/task-brief.js +174 -150
  28. package/dist/programs/task-sweep.js +244 -151
  29. package/dist/programs/task-tools-serve.js +260 -163
  30. package/dist/programs/tokens.js +172 -148
  31. package/dist/programs/waiver.js +172 -148
  32. package/dist/vinaya-strict/checks/registry.ts +1085 -0
  33. package/dist/vinaya-strict/executing/code-reviewer/README.md +3 -0
  34. package/dist/vinaya-strict/executing/code-reviewer/doctrine.md +185 -0
  35. package/dist/vinaya-strict/executing/code-reviewer/evals/README.md +1 -0
  36. package/dist/vinaya-strict/executing/code-reviewer/evals/code-reviewer-cases.json +280 -0
  37. package/dist/vinaya-strict/executing/code-reviewer/grants.yaml +22 -0
  38. package/dist/vinaya-strict/executing/code-reviewer/output.schema.json +93 -0
  39. package/dist/vinaya-strict/executing/code-reviewer/review-result.ts +347 -0
  40. package/dist/vinaya-strict/executing/dev-review.flow.yaml +103 -0
  41. package/dist/vinaya-strict/executing/developer/README.md +3 -0
  42. package/dist/vinaya-strict/executing/developer/developer-doctrine-shape.test.ts +69 -0
  43. package/dist/vinaya-strict/executing/developer/developer-turn-result.ts +286 -0
  44. package/dist/vinaya-strict/executing/developer/doctrine.md +111 -0
  45. package/dist/vinaya-strict/executing/developer/evals/README.md +1 -0
  46. package/dist/vinaya-strict/executing/developer/evals/developer-capability-cases.json +6275 -0
  47. package/dist/vinaya-strict/executing/developer/evals/developer-capability-held-out.json +11526 -0
  48. package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.test.ts +498 -0
  49. package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.ts +1407 -0
  50. package/dist/vinaya-strict/executing/developer/grants.yaml +25 -0
  51. package/dist/vinaya-strict/executing/developer/output.schema.json +148 -0
  52. package/dist/vinaya-strict/executing/developer/reference.md +376 -0
  53. package/dist/vinaya-strict/executing/operator/doctrine.md +209 -0
  54. package/dist/vinaya-strict/executing/security-reviewer/README.md +3 -0
  55. package/dist/vinaya-strict/executing/security-reviewer/doctrine.md +171 -0
  56. package/dist/vinaya-strict/executing/security-reviewer/evals/README.md +1 -0
  57. package/dist/vinaya-strict/executing/security-reviewer/evals/security-reviewer-cases.json +141 -0
  58. package/dist/vinaya-strict/executing/security-reviewer/grants.yaml +22 -0
  59. package/dist/vinaya-strict/executing/security-reviewer/output.schema.json +93 -0
  60. package/dist/vinaya-strict/integration/config/vinaya-config-section.ts +1278 -0
  61. package/dist/vinaya-strict/integration/policies/vinaya-policies.ts +52 -0
  62. package/dist/vinaya-strict/integration/process/process-integration.ts +57 -0
  63. package/dist/vinaya-strict/loops/dev-review/v2/dev-review-v2.flow.yaml +136 -0
  64. package/dist/vinaya-strict/process.yaml +43 -0
  65. package/dist/vinaya-strict/retrospecting/archivist/doctrine.md +174 -0
  66. package/dist/vinaya-strict/retrospecting/tranche-archivist/doctrine.md +270 -0
  67. package/dist/vinaya-strict/thinking/architect/doctrine.md +110 -0
  68. package/dist/vinaya-strict/thinking/planner/doctrine.md +105 -0
  69. package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.test.ts +128 -0
  70. package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.ts +169 -0
  71. package/dist/vinaya-strict/thinking/planner/tools/open-issue.test.ts +701 -0
  72. package/dist/vinaya-strict/thinking/planner/tools/open-issue.ts +1035 -0
  73. package/dist/vinaya-strict/thinking/planner/tools/planner-operations.test.ts +359 -0
  74. package/dist/vinaya-strict/thinking/planner/tools/planner-operations.ts +815 -0
  75. package/dist/vinaya-strict/thinking/planner/tools/planner-tools.test.ts +200 -0
  76. package/dist/vinaya-strict/thinking/planner/tools/planner-tools.ts +458 -0
  77. package/package.json +4 -2
  78. package/studio-standalone/apps/vinaya-studio/.next/BUILD_ID +1 -1
  79. package/studio-standalone/apps/vinaya-studio/.next/build-manifest.json +2 -2
  80. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.html +1 -1
  81. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.rsc +1 -1
  82. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  83. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  84. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  85. package/studio-standalone/apps/vinaya-studio/.next/server/middleware-build-manifest.js +1 -1
  86. package/studio-standalone/apps/vinaya-studio/.next/server/pages/500.html +1 -1
  87. /package/studio-standalone/apps/vinaya-studio/.next/static/{yFfoujElgbwPk-7KNS-kw → x2q88XfwsihlevulRhIvs}/_buildManifest.js +0 -0
  88. /package/studio-standalone/apps/vinaya-studio/.next/static/{yFfoujElgbwPk-7KNS-kw → x2q88XfwsihlevulRhIvs}/_ssgManifest.js +0 -0
@@ -0,0 +1,347 @@
1
+ /**
2
+ * The reviewer's result — the one structured value a reviewer session ends
3
+ * with, delivered as each CLI's native structured final output (Claude Code
4
+ * `--json-schema`, Codex `--output-schema`) rather than three result files.
5
+ *
6
+ * Versioned (`schemaVersion`) and discriminated by `status`:
7
+ *
8
+ * - `completed` — `role`, the `headSha` and `manifestDigest` the review is
9
+ * bound to, `summary`, `findings` (a role-specific `severity`, a `file`, an
10
+ * optional `line` and `description`) and `objectiveResults`;
11
+ * - `blocked` — `role`, the same two bindings, `summary` and a typed `blocker`.
12
+ *
13
+ * There is no `needs_ruling` status: a reviewer never asks for a ruling.
14
+ *
15
+ * One schema serves both vendors, so it is written to the strictest common
16
+ * shape (see `developer-turn-result.ts`): the union sits under one root key,
17
+ * `reviewResult`, and every "optional" field is a required, nullable one. The
18
+ * same zod value generates the JSON Schema the CLIs receive and validates what
19
+ * comes back, so the two can never drift. The schema handed to a provider is
20
+ * built for ONE role (`reviewResultJsonSchema(role)`): its `role` is that
21
+ * role's literal and its severities are that role's scale.
22
+ *
23
+ * Nothing the agent writes decides anything about who it is. `role` is a
24
+ * claim, validated against the controller's own `ReviewBinding`; so are
25
+ * `headSha` and `manifestDigest`. Validation runs in two steps:
26
+ * `parseReviewResult` is the shape check, `semanticErrors` the check against
27
+ * the binding. `classifyReviewOutcome` turns a whole run — result or not —
28
+ * into either a review or "no review"; only a review can ever count, and a
29
+ * missing, malformed, stale, blocked, cancelled, context-exhausted,
30
+ * provider-errored or resumed run is never approval.
31
+ */
32
+
33
+ import { createHash } from 'node:crypto'
34
+ import { CODE_REVIEW_SEVERITY_ORDER, SECURITY_SEVERITY_ORDER } from '../../tools/task-contract/review-policy'
35
+ import type { ReviewInputManifest } from '../../tools/task-contract/review-input-manifest'
36
+ import { z } from 'zod/v4'
37
+
38
+ /** The one schema version this module produces and accepts. */
39
+ export const REVIEW_RESULT_SCHEMA_VERSION = 1
40
+
41
+ export const REVIEWER_ROLES = ['code-reviewer', 'security-reviewer'] as const
42
+ export type ReviewerRole = (typeof REVIEWER_ROLES)[number]
43
+
44
+ /** Each role's own severity scale — the scales the review policy already orders against. */
45
+ export const REVIEWER_SEVERITIES: Record<ReviewerRole, readonly string[]> = {
46
+ 'code-reviewer': CODE_REVIEW_SEVERITY_ORDER,
47
+ 'security-reviewer': SECURITY_SEVERITY_ORDER
48
+ }
49
+
50
+ const ALL_SEVERITIES = [...CODE_REVIEW_SEVERITY_ORDER, ...SECURITY_SEVERITY_ORDER] as [string, ...string[]]
51
+
52
+ /** What stopped a `blocked` review, typed. */
53
+ export const REVIEW_BLOCKER_KINDS = [
54
+ 'input_missing',
55
+ 'input_unreadable',
56
+ 'diff_unavailable',
57
+ 'tooling_unavailable',
58
+ 'scope_unclear'
59
+ ] as const
60
+
61
+ export const OBJECTIVE_STATUSES = ['MET', 'NOT MET'] as const
62
+
63
+ const schemaVersion = z.literal(REVIEW_RESULT_SCHEMA_VERSION)
64
+ const summary = z.string().min(1)
65
+
66
+ const FindingSchema = (severity: z.ZodType<string>) =>
67
+ z
68
+ .object({
69
+ severity,
70
+ /**
71
+ * The file the finding is about — required: a finding that names no file cannot be acted on. Strict structured
72
+ * outputs make every field present, so a model with no file sends `""`: the semantic check refuses it as `rejected`.
73
+ */
74
+ file: z.string(),
75
+ /** `null` when the finding is about the file as a whole. */
76
+ line: z.number().int().min(1).nullable(),
77
+ description: z.string().min(1).nullable()
78
+ })
79
+ .strict()
80
+
81
+ const ObjectiveResultSchema = z
82
+ .object({
83
+ id: z.string().min(1),
84
+ status: z.enum(OBJECTIVE_STATUSES),
85
+ evidence: z.string().min(1)
86
+ })
87
+ .strict()
88
+
89
+ const BlockerSchema = z.object({ kind: z.enum(REVIEW_BLOCKER_KINDS), detail: z.string().min(1) }).strict()
90
+
91
+ function variantSchemas(role: z.ZodType<string>, severity: z.ZodType<string>) {
92
+ const bound = { schemaVersion, role, headSha: z.string().min(1), manifestDigest: z.string().min(1), summary }
93
+ return [
94
+ z
95
+ .object({
96
+ ...bound,
97
+ status: z.literal('completed'),
98
+ findings: z.array(FindingSchema(severity)),
99
+ objectiveResults: z.array(ObjectiveResultSchema)
100
+ })
101
+ .strict(),
102
+ z.object({ ...bound, status: z.literal('blocked'), blocker: BlockerSchema }).strict()
103
+ ] as const
104
+ }
105
+
106
+ /** The shape check's own schema: either role, any role's severity — which role and scale applies is the controller's call. */
107
+ export const ReviewResultSchema = z.discriminatedUnion('status', [
108
+ ...variantSchemas(z.enum(REVIEWER_ROLES), z.enum(ALL_SEVERITIES))
109
+ ])
110
+
111
+ /** The structured output the provider is asked for, for either role: the union under one root key. */
112
+ export const ReviewOutputSchema = z.object({ reviewResult: ReviewResultSchema }).strict()
113
+
114
+ export type ReviewResult = z.infer<typeof ReviewResultSchema>
115
+ export type CompletedReview = Extract<ReviewResult, { status: 'completed' }>
116
+ export type BlockedReview = Extract<ReviewResult, { status: 'blocked' }>
117
+
118
+ function roleOutputSchema(role: ReviewerRole) {
119
+ return z
120
+ .object({
121
+ reviewResult: z.discriminatedUnion('status', [
122
+ ...variantSchemas(z.literal(role), z.enum(REVIEWER_SEVERITIES[role] as [string, ...string[]]))
123
+ ])
124
+ })
125
+ .strict()
126
+ }
127
+
128
+ /**
129
+ * The JSON Schema handed to the vendor CLI. With a `role` it is that role's:
130
+ * its literal `role` and its severity scale. Without one it admits either
131
+ * role, which is how the proof lets a model attempt a role or severity the
132
+ * controller must then refuse. `$schema` is dropped: neither CLI needs it.
133
+ */
134
+ export function reviewResultJsonSchema(role?: ReviewerRole): Record<string, unknown> {
135
+ const schema = role === undefined ? ReviewOutputSchema : roleOutputSchema(role)
136
+ const { $schema: _dropped, ...rest } = z.toJSONSchema(schema, { target: 'draft-7' }) as Record<string, unknown>
137
+ return rest
138
+ }
139
+
140
+ /** What the controller knows about one reviewer's dispatch — never read from the agent. */
141
+ export type ReviewBinding = {
142
+ readonly role: ReviewerRole
143
+ /** The round's judged head. */
144
+ readonly headSha: string
145
+ /** `manifestDigest` of the one review-input manifest both reviewers were dispatched against. */
146
+ readonly manifestDigest: string
147
+ /** The objective ids the frozen brief carries. */
148
+ readonly objectiveIds: readonly string[]
149
+ /**
150
+ * The run, round and attempt this dispatch belongs to. The result carries
151
+ * none of them: it is read from this dispatch's own process, so the
152
+ * controller attaches them to the accepted review itself.
153
+ */
154
+ readonly runId?: string
155
+ readonly round?: number
156
+ readonly attempt?: number
157
+ }
158
+
159
+ /** The digest the controller binds a review to: SHA-256 over the manifest's fields in a fixed key order. */
160
+ export function manifestDigest(manifest: ReviewInputManifest): string {
161
+ const ordered = {
162
+ manifestVersion: manifest.manifestVersion ?? 2,
163
+ headSha: manifest.headSha,
164
+ baseSha: manifest.baseSha,
165
+ briefHash: manifest.briefHash,
166
+ objectivesVersion: manifest.objectivesVersion,
167
+ rulingOrdinal: manifest.rulingOrdinal,
168
+ pauseBoundRuling: manifest.pauseBoundRuling ?? null,
169
+ policyDigest: manifest.policyDigest
170
+ }
171
+ return createHash('sha256').update(JSON.stringify(ordered)).digest('hex')
172
+ }
173
+
174
+ export type ReviewValidation =
175
+ | { ok: true; result: ReviewResult }
176
+ | { ok: false; stage: 'schema' | 'semantic'; errors: string[] }
177
+
178
+ /** The shape check alone: does `value` match the schema the provider was given? Returns the unwrapped result. */
179
+ export function parseReviewResult(value: unknown): ReviewValidation {
180
+ const parsed = ReviewOutputSchema.safeParse(value)
181
+ if (!parsed.success) {
182
+ return {
183
+ ok: false,
184
+ stage: 'schema',
185
+ errors: parsed.error.issues.map((i) => `${i.path.join('.') || '(root)'}: ${i.message}`)
186
+ }
187
+ }
188
+ return { ok: true, result: parsed.data.reviewResult }
189
+ }
190
+
191
+ /** Errors that make a result belong to another review than this one — a stale or crossed result. */
192
+ export function bindingErrors(result: ReviewResult, binding: ReviewBinding): string[] {
193
+ const errors: string[] = []
194
+ if (result.role !== binding.role) {
195
+ errors.push(`role: the result names ${result.role} but this dispatch is ${binding.role}`)
196
+ }
197
+ if (result.headSha !== binding.headSha) {
198
+ errors.push(`headSha: the result is bound to ${result.headSha}, the judged head is ${binding.headSha}`)
199
+ }
200
+ if (result.manifestDigest !== binding.manifestDigest) {
201
+ errors.push('manifestDigest: the result is bound to a different review-input manifest')
202
+ }
203
+ return errors
204
+ }
205
+
206
+ /** The rules a schema cannot express, checked against the controller's own binding. */
207
+ export function semanticErrors(result: ReviewResult, binding: ReviewBinding): string[] {
208
+ const errors = bindingErrors(result, binding)
209
+ if (result.status !== 'completed') return errors
210
+ const severities = REVIEWER_SEVERITIES[binding.role]
211
+ for (const [i, finding] of result.findings.entries()) {
212
+ if (!severities.includes(finding.severity)) {
213
+ errors.push(
214
+ `findings.${i}.severity: ${JSON.stringify(finding.severity)} is not on the ${binding.role} scale (${severities.join('|')})`
215
+ )
216
+ }
217
+ if (finding.file.trim().length === 0) errors.push(`findings.${i}.file: a finding must name a file`)
218
+ }
219
+ const known = new Set(binding.objectiveIds)
220
+ for (const objective of result.objectiveResults) {
221
+ if (!known.has(objective.id)) {
222
+ errors.push(`objectiveResults: unknown objective id ${JSON.stringify(objective.id)} (not in the brief)`)
223
+ }
224
+ }
225
+ return errors
226
+ }
227
+
228
+ /** The controller's whole acceptance check: the shape, then the semantics. Only `ok: true` is ever a review. */
229
+ export function validateReviewResult(value: unknown, binding: ReviewBinding): ReviewValidation {
230
+ const parsed = parseReviewResult(value)
231
+ if (!parsed.ok) return parsed
232
+ const errors = semanticErrors(parsed.result, binding)
233
+ return errors.length > 0 ? { ok: false, stage: 'semantic', errors } : parsed
234
+ }
235
+
236
+ /** Why a run produced no review. */
237
+ export type NoReviewReason =
238
+ | 'missing'
239
+ | 'malformed'
240
+ | 'stale'
241
+ | 'role_mismatch'
242
+ | 'rejected'
243
+ | 'blocked'
244
+ | 'cancelled'
245
+ | 'context_exhausted'
246
+ | 'provider_error'
247
+ | 'duplicate'
248
+ | 'resumed'
249
+
250
+ export type ReviewOutcome =
251
+ /** An accepted review, carrying the controller's own binding it was accepted under. */
252
+ | { kind: 'review'; result: CompletedReview; binding: ReviewBinding }
253
+ /** No review. `blocked` carries the result only once it is bound to this dispatch's role, head and manifest. */
254
+ | { kind: 'no_review'; reason: NoReviewReason; detail: string; blocked?: BlockedReview }
255
+
256
+ /** What a finished reviewer run showed at the adapter boundary. */
257
+ export type ReviewRunFacts = {
258
+ /** The run was killed before it finished. */
259
+ cancelled: boolean
260
+ /** The run continued an earlier provider session instead of starting a fresh one. */
261
+ resumed?: boolean
262
+ /** The stream's own terminal outcome, when it reported one (`success`, `turn.failed`, …). */
263
+ terminal: string | null
264
+ /** Error text the stream or the process reported. */
265
+ errors: readonly string[]
266
+ /** Whether the stream carried a structured result at all. */
267
+ hasResult: boolean
268
+ /** The value read, before any validation. */
269
+ raw: unknown
270
+ }
271
+
272
+ const CONTEXT_EXHAUSTED = /context (window|length)|prompt is too long|too many tokens|maximum context|token limit/i
273
+ const TERMINAL_FAILURE = /error|failed/i
274
+
275
+ /**
276
+ * One run's outcome. Everything but a completed, schema-valid, bound,
277
+ * semantically valid result is "no review" — the order below says which
278
+ * reason wins when several apply, and none of them is approval.
279
+ */
280
+ export function classifyReviewOutcome(facts: ReviewRunFacts, binding: ReviewBinding): ReviewOutcome {
281
+ const noReview = (reason: NoReviewReason, detail: string): ReviewOutcome => ({ kind: 'no_review', reason, detail })
282
+ const errorText = facts.errors.join(' | ')
283
+ if (facts.resumed === true) return noReview('resumed', 'a reviewer runs only on a fresh session, never a resumed one')
284
+ if (facts.cancelled) return noReview('cancelled', 'the run was cancelled before it finished')
285
+ if (CONTEXT_EXHAUSTED.test(errorText)) return noReview('context_exhausted', errorText)
286
+ if (!facts.hasResult) {
287
+ const failed = (facts.terminal !== null && TERMINAL_FAILURE.test(facts.terminal)) || errorText.length > 0
288
+ return failed
289
+ ? noReview('provider_error', `${facts.terminal ?? 'the run'} ended with no result: ${errorText}`)
290
+ : noReview('missing', 'the stream carried no structured result')
291
+ }
292
+ const parsed = parseReviewResult(facts.raw)
293
+ if (!parsed.ok) return noReview('malformed', parsed.errors.join('; '))
294
+ // A blocked result is held to the same binding as a completed one: one
295
+ // naming the other role, another head or another manifest is refused as
296
+ // crossed or stale before its blocker is read at all.
297
+ const unbound = bindingErrors(parsed.result, binding)
298
+ if (parsed.result.status === 'blocked') {
299
+ if (unbound.length === 0) {
300
+ const detail = `${parsed.result.blocker.kind}: ${parsed.result.blocker.detail}`
301
+ return { kind: 'no_review', reason: 'blocked', detail, blocked: parsed.result }
302
+ }
303
+ return noReview(parsed.result.role !== binding.role ? 'role_mismatch' : 'stale', unbound.join('; '))
304
+ }
305
+ const errors = semanticErrors(parsed.result, binding)
306
+ if (errors.length === 0) return { kind: 'review', result: parsed.result, binding }
307
+ if (parsed.result.role !== binding.role) return noReview('role_mismatch', errors.join('; '))
308
+ if (unbound.length > 0) return noReview('stale', errors.join('; '))
309
+ return noReview('rejected', errors.join('; '))
310
+ }
311
+
312
+ /**
313
+ * Whether a `blocked` result asks a question only the Principal can answer.
314
+ * A blocked result is never a review; the controller alone decides what
315
+ * follows it. An unclear scope is a ruling question, so the round pauses for
316
+ * the Principal; every other blocker is an input or tooling failure, which a
317
+ * fresh dispatch may not hit again.
318
+ */
319
+ export function reviewBlockerNeedsRuling(kind: (typeof REVIEW_BLOCKER_KINDS)[number]): boolean {
320
+ return kind === 'scope_unclear'
321
+ }
322
+
323
+ /**
324
+ * One round's collection of reviews: each role holds at most one accepted
325
+ * review, and a second offered for the same role is refused, never merged.
326
+ */
327
+ export class RoundReviews {
328
+ private readonly accepted = new Map<ReviewerRole, CompletedReview>()
329
+
330
+ /** Offers a role's outcome; returns what the round recorded for it. */
331
+ offer(role: ReviewerRole, outcome: ReviewOutcome): ReviewOutcome {
332
+ if (outcome.kind !== 'review') return outcome
333
+ if (this.accepted.has(role)) {
334
+ return { kind: 'no_review', reason: 'duplicate', detail: `${role} already has an accepted review this round` }
335
+ }
336
+ this.accepted.set(role, outcome.result)
337
+ return outcome
338
+ }
339
+
340
+ get(role: ReviewerRole): CompletedReview | undefined {
341
+ return this.accepted.get(role)
342
+ }
343
+
344
+ get size(): number {
345
+ return this.accepted.size
346
+ }
347
+ }
@@ -0,0 +1,103 @@
1
+ schema_version: "2.0"
2
+ id: vinaya-dev-review
3
+ display_name: Vinaya developer review
4
+ description: One task from prepared inputs to a reviewed pull request ready for merge.
5
+ experimental: true
6
+ benchmarked: false
7
+ defaults:
8
+ model: process-supplied
9
+ agents:
10
+ - role: developer
11
+ - role: code-reviewer
12
+ - role: security-reviewer
13
+ steps:
14
+ - { id: prepare-run, type: mechanical, action: vinaya.prepare-run }
15
+ - { id: reconcile-external-state, type: mechanical, action: vinaya.reconcile-external-state }
16
+ - { id: prepare-sources, type: mechanical, action: vinaya.prepare-sources }
17
+ # A Flow decision branches back to a prior step on true and forward on false, so the Developer is listed before the
18
+ # decision that routes to it: true (no pull request is open yet) develops, false (one is) attaches at the gates.
19
+ - id: develop
20
+ type: agent
21
+ role: developer
22
+ prompt_template: "Develop the task {{question}}."
23
+ permission: developer/grants.yaml
24
+ working_directory: "."
25
+ max_turns: 200
26
+ depends_on: [choose-start]
27
+ - id: choose-start
28
+ type: mechanical
29
+ action: vinaya.choose-start
30
+ depends_on: [prepare-sources]
31
+ decision: { examine: reconcile-external-state, if_true: develop, if_false: run-mechanical-gates, max_revisions: 3 }
32
+ # Every round outcome below is the shared assessment's (`assessRound`): each deciding step records the observation
33
+ # it built and the decision the assessment returned, and the decision only routes on it. Exit 1 sends the run back
34
+ # (to the Developer, or to the reviewers' dispatch); a pause halts the run through the handoff and routes where its
35
+ # resume continues. The checked-in ceilings are placeholders: the runner renders this Flow into the run's own folder
36
+ # with every `max_revisions` set to the review policy's `maxRounds` before the run starts.
37
+ - { id: validate-developer-output, type: mechanical, action: vinaya.validate-developer-output, depends_on: [develop] }
38
+ - id: classify-developer-output
39
+ type: mechanical
40
+ action: vinaya.classify-developer-output
41
+ decision: { examine: validate-developer-output, if_true: develop, if_false: run-mechanical-gates, max_revisions: 3 }
42
+ - { id: run-mechanical-gates, type: mechanical, action: harness.run-gates }
43
+ # The forge gates, in the standalone round order, before the gate is assessed and any reviewer is dispatched:
44
+ # mergeability first (a conflicting head goes back to the Developer before any CI wait), then the forge's CI
45
+ # (waited on while pending; a red read is part of the gate the assessment judges), then the premise re-check (a
46
+ # stale pin pauses through the handoff).
47
+ - { id: check-mergeability, type: mechanical, action: vinaya.check-mergeability }
48
+ - id: classify-mergeability
49
+ type: mechanical
50
+ action: vinaya.classify-mergeability
51
+ decision: { examine: check-mergeability, if_true: develop, if_false: refresh-evidence, max_revisions: 3 }
52
+ # The Evidence block is written for this head before the CI wait: the Evidence-dependent check cannot pass without it.
53
+ - { id: refresh-evidence, type: mechanical, action: vinaya.refresh-evidence }
54
+ - { id: read-forge-ci, type: mechanical, action: vinaya.read-forge-ci }
55
+ - { id: check-premise, type: mechanical, action: vinaya.check-premise }
56
+ - { id: assess-gate, type: mechanical, action: vinaya.assess-gate }
57
+ - id: classify-gate-result
58
+ type: mechanical
59
+ action: vinaya.classify-gate-result
60
+ decision: { examine: assess-gate, if_true: develop, if_false: run-security-scan, max_revisions: 3 }
61
+ # The configured agent-configuration scan runs here, outside both reviewers' sandboxes, before either is dispatched.
62
+ - { id: run-security-scan, type: mechanical, action: vinaya.run-security-scan }
63
+ - { id: dispatch-reviewers, type: mechanical, action: vinaya.dispatch-reviewers }
64
+ - id: code-review
65
+ type: agent
66
+ role: code-reviewer
67
+ prompt_template: "Review the task {{question}}."
68
+ permission: code-reviewer/grants.yaml
69
+ working_directory: ""
70
+ max_turns: 100
71
+ depends_on: [dispatch-reviewers]
72
+ - id: security-review
73
+ type: agent
74
+ role: security-reviewer
75
+ prompt_template: "Security-review the task {{question}}."
76
+ permission: security-reviewer/grants.yaml
77
+ working_directory: ""
78
+ max_turns: 100
79
+ depends_on: [dispatch-reviewers]
80
+ - { id: validate-reviewer-outputs, type: mechanical, action: vinaya.validate-reviewer-outputs, depends_on: [code-review, security-review] }
81
+ - id: classify-reviewer-outputs
82
+ type: mechanical
83
+ action: vinaya.classify-reviewer-outputs
84
+ decision: { examine: validate-reviewer-outputs, if_true: dispatch-reviewers, if_false: assess-round, max_revisions: 3 }
85
+ - { id: assess-round, type: mechanical, action: vinaya.assess-round }
86
+ - id: build-revision-handoff
87
+ type: mechanical
88
+ action: vinaya.build-revision-handoff
89
+ decision: { examine: assess-round, if_true: develop, if_false: run-live-checks, max_revisions: 3 }
90
+ # Both reviewers approved: the task's [live] Test Plan lines run on the approved head before it is published.
91
+ - { id: run-live-checks, type: mechanical, action: vinaya.run-live-checks }
92
+ - id: classify-live-result
93
+ type: mechanical
94
+ action: vinaya.classify-live-result
95
+ decision: { examine: run-live-checks, if_true: develop, if_false: check-publish-mergeability, max_revisions: 3 }
96
+ # Mergeability is read again before publication: an approved head that fell into conflict with the default branch
97
+ # while the reviewers worked is never published; it goes back to the Developer with the conflicting files.
98
+ - { id: check-publish-mergeability, type: mechanical, action: vinaya.check-publish-mergeability }
99
+ - id: classify-publish-mergeability
100
+ type: mechanical
101
+ action: vinaya.classify-publish-mergeability
102
+ decision: { examine: check-publish-mergeability, if_true: develop, if_false: publish-ready-for-merge, max_revisions: 3 }
103
+ - { id: publish-ready-for-merge, type: mechanical, action: harness.publish }
@@ -0,0 +1,3 @@
1
+ # harness/processes/vinaya-strict/executing/developer
2
+
3
+ The Developer role. Belongs to the "Any Process, One Harness" project; holds no code yet.
@@ -0,0 +1,69 @@
1
+ import { describe, expect, it } from 'bun:test'
2
+ import { readFileSync } from 'node:fs'
3
+ import { join } from 'node:path'
4
+ import {
5
+ countWords,
6
+ extractShortVersion,
7
+ ROLE_BLOCKS,
8
+ SHORT_VERSION_MAX_WORDS,
9
+ SHORT_VERSION_MIN_WORDS
10
+ } from '../../tools/docs/published-prose'
11
+ import { resolveDoctrineRoot } from '../../tools/doctrine/resolve-doctrine'
12
+ import { doctrineSource } from '../../tools/doctrine/doctrine-map'
13
+ import {
14
+ assembleDeveloperDoctrine,
15
+ DEVELOPER_CHECKLIST_HEADINGS,
16
+ extractDeveloperSection
17
+ } from '../../loops/dev-review/standalone/dev-review-loop/developer-dispatch'
18
+
19
+ /**
20
+ * The shape of the Developer doctrine that the dispatch driver and the
21
+ * published-prose gate both read. The driver prepends the role file's short
22
+ * version and the reference's two checklist sections to every fresh
23
+ * developer session, extracting each by its exact heading; an absent heading
24
+ * injects nothing, silently. These assertions make a later edit that empties
25
+ * or renames one of them fail here instead.
26
+ */
27
+
28
+ const root = resolveDoctrineRoot()
29
+
30
+ function doctrineFile(...segments: string[]): string {
31
+ if (root === null) throw new Error('no doctrine root resolves from this checkout')
32
+ return readFileSync(join(root, ...segments), 'utf8')
33
+ }
34
+
35
+ const roleFile = doctrineFile(doctrineSource('roles/developer.md'))
36
+ const reference = doctrineFile(doctrineSource('roles/developer/reference.md'))
37
+
38
+ describe('the developer role file short version', () => {
39
+ const short = extractShortVersion(roleFile) ?? ''
40
+
41
+ it('exists and sits inside the published word range', () => {
42
+ expect(short.length).toBeGreaterThan(0)
43
+ const words = countWords(short)
44
+ expect(words).toBeGreaterThanOrEqual(SHORT_VERSION_MIN_WORDS)
45
+ expect(words).toBeLessThanOrEqual(SHORT_VERSION_MAX_WORDS)
46
+ })
47
+
48
+ it('carries its four bold-led blocks, in order', () => {
49
+ const positions = ROLE_BLOCKS.map((block) => short.indexOf(`**${block}`))
50
+ for (const at of positions) expect(at).toBeGreaterThanOrEqual(0)
51
+ expect([...positions].sort((a, b) => a - b)).toEqual(positions)
52
+ })
53
+ })
54
+
55
+ describe('the developer reference checklist sections', () => {
56
+ it('carries both headings the driver injects, each with a body', () => {
57
+ const lines = reference.split('\n').map((line) => line.trim())
58
+ for (const heading of DEVELOPER_CHECKLIST_HEADINGS) {
59
+ expect(lines).toContain(`## ${heading}`)
60
+ expect(extractDeveloperSection(reference, heading).length).toBeGreaterThan(0)
61
+ }
62
+ })
63
+
64
+ it('assembles into the injected block with the short version and both sections', () => {
65
+ const assembled = assembleDeveloperDoctrine(extractShortVersion(roleFile), reference) ?? ''
66
+ expect(assembled).toContain('**You own**')
67
+ for (const heading of DEVELOPER_CHECKLIST_HEADINGS) expect(assembled).toContain(`## ${heading}\n\n`)
68
+ })
69
+ })