@attalabs/vinaya 0.42.2 → 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.
- package/dist/checks/bin/check-evidence-fresh.js +8 -5
- package/dist/index.js +20 -17
- package/dist/lib/pre-push-cache-test-run.js +3 -1
- package/dist/programs/archive.js +3 -1
- package/dist/programs/check.js +3 -1
- package/dist/programs/commit-msg.js +3 -1
- package/dist/programs/dev-review-loop.js +9 -6
- package/dist/programs/dispatch.js +3 -1
- package/dist/programs/log-emit.js +3 -1
- package/dist/programs/log-selftest.js +3 -1
- package/dist/programs/log-send.js +3 -1
- package/dist/programs/pr-report.js +8 -5
- package/dist/programs/pr-snapshot.js +3 -1
- package/dist/programs/pr-verify-evidence.js +8 -5
- package/dist/programs/pr.js +3 -1
- package/dist/programs/review-post.js +3 -1
- package/dist/programs/review-status.js +3 -1
- package/dist/programs/run-engine.js +110594 -0
- package/dist/programs/supervised-command.js +67 -0
- package/dist/programs/sync.js +3 -1
- package/dist/programs/task-brief.js +5 -3
- package/dist/programs/task-sweep.js +3 -1
- package/dist/programs/task-tools-serve.js +13 -11
- package/dist/programs/tokens.js +3 -1
- package/dist/programs/waiver.js +3 -1
- package/dist/vinaya-strict/checks/registry.ts +1085 -0
- package/dist/vinaya-strict/executing/code-reviewer/README.md +3 -0
- package/dist/vinaya-strict/executing/code-reviewer/doctrine.md +185 -0
- package/dist/vinaya-strict/executing/code-reviewer/evals/README.md +1 -0
- package/dist/vinaya-strict/executing/code-reviewer/evals/code-reviewer-cases.json +280 -0
- package/dist/vinaya-strict/executing/code-reviewer/grants.yaml +22 -0
- package/dist/vinaya-strict/executing/code-reviewer/output.schema.json +93 -0
- package/dist/vinaya-strict/executing/code-reviewer/review-result.ts +347 -0
- package/dist/vinaya-strict/executing/dev-review.flow.yaml +103 -0
- package/dist/vinaya-strict/executing/developer/README.md +3 -0
- package/dist/vinaya-strict/executing/developer/developer-doctrine-shape.test.ts +69 -0
- package/dist/vinaya-strict/executing/developer/developer-turn-result.ts +286 -0
- package/dist/vinaya-strict/executing/developer/doctrine.md +111 -0
- package/dist/vinaya-strict/executing/developer/evals/README.md +1 -0
- package/dist/vinaya-strict/executing/developer/evals/developer-capability-cases.json +6275 -0
- package/dist/vinaya-strict/executing/developer/evals/developer-capability-held-out.json +11526 -0
- package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.test.ts +498 -0
- package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.ts +1407 -0
- package/dist/vinaya-strict/executing/developer/grants.yaml +25 -0
- package/dist/vinaya-strict/executing/developer/output.schema.json +148 -0
- package/dist/vinaya-strict/executing/developer/reference.md +376 -0
- package/dist/vinaya-strict/executing/operator/doctrine.md +209 -0
- package/dist/vinaya-strict/executing/security-reviewer/README.md +3 -0
- package/dist/vinaya-strict/executing/security-reviewer/doctrine.md +171 -0
- package/dist/vinaya-strict/executing/security-reviewer/evals/README.md +1 -0
- package/dist/vinaya-strict/executing/security-reviewer/evals/security-reviewer-cases.json +141 -0
- package/dist/vinaya-strict/executing/security-reviewer/grants.yaml +22 -0
- package/dist/vinaya-strict/executing/security-reviewer/output.schema.json +93 -0
- package/dist/vinaya-strict/integration/config/vinaya-config-section.ts +1278 -0
- package/dist/vinaya-strict/integration/policies/vinaya-policies.ts +52 -0
- package/dist/vinaya-strict/integration/process/process-integration.ts +57 -0
- package/dist/vinaya-strict/loops/dev-review/v2/dev-review-v2.flow.yaml +136 -0
- package/dist/vinaya-strict/process.yaml +43 -0
- package/dist/vinaya-strict/retrospecting/archivist/doctrine.md +174 -0
- package/dist/vinaya-strict/retrospecting/tranche-archivist/doctrine.md +270 -0
- package/dist/vinaya-strict/thinking/architect/doctrine.md +110 -0
- package/dist/vinaya-strict/thinking/planner/doctrine.md +105 -0
- package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.test.ts +128 -0
- package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.ts +169 -0
- package/dist/vinaya-strict/thinking/planner/tools/open-issue.test.ts +701 -0
- package/dist/vinaya-strict/thinking/planner/tools/open-issue.ts +1035 -0
- package/dist/vinaya-strict/thinking/planner/tools/planner-operations.test.ts +359 -0
- package/dist/vinaya-strict/thinking/planner/tools/planner-operations.ts +815 -0
- package/dist/vinaya-strict/thinking/planner/tools/planner-tools.test.ts +200 -0
- package/dist/vinaya-strict/thinking/planner/tools/planner-tools.ts +458 -0
- package/package.json +4 -2
- package/studio-standalone/apps/vinaya-studio/.next/BUILD_ID +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/build-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.html +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/middleware-build-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/pages/500.html +1 -1
- /package/studio-standalone/apps/vinaya-studio/.next/static/{Q_xjhiWztjosXWbMSJ0Yp → x2q88XfwsihlevulRhIvs}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/.next/static/{Q_xjhiWztjosXWbMSJ0Yp → x2q88XfwsihlevulRhIvs}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test'
|
|
2
|
+
import { readFileSync } from 'node:fs'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import { renderBeyondSurfaceBlock } from '../../../tools/task-contract/issue-validation'
|
|
5
|
+
|
|
6
|
+
import type { DeveloperTurnResult } from '../developer-turn-result'
|
|
7
|
+
import {
|
|
8
|
+
injectedDeliveryReceipts,
|
|
9
|
+
manifestDigest,
|
|
10
|
+
sha256Digest,
|
|
11
|
+
type PreparedSource,
|
|
12
|
+
type RequiredSourceManifest
|
|
13
|
+
} from '../../../../../kernel/source-manifest'
|
|
14
|
+
import {
|
|
15
|
+
beyondScope,
|
|
16
|
+
briefRequiredSources,
|
|
17
|
+
CASES_PATH,
|
|
18
|
+
CRITERIA,
|
|
19
|
+
type Criterion,
|
|
20
|
+
classifyTests,
|
|
21
|
+
type DeveloperCapabilityCase,
|
|
22
|
+
type DeveloperTrialObservation,
|
|
23
|
+
DROP_REASONS,
|
|
24
|
+
digestSetOf,
|
|
25
|
+
digestsFor,
|
|
26
|
+
digestsIn,
|
|
27
|
+
developerForbidden,
|
|
28
|
+
developmentDigest,
|
|
29
|
+
developmentTasks,
|
|
30
|
+
formatReconstruction,
|
|
31
|
+
frozenScope,
|
|
32
|
+
GRADERS,
|
|
33
|
+
gitIn,
|
|
34
|
+
gradeDeveloperTrial,
|
|
35
|
+
HELD_OUT_PATH,
|
|
36
|
+
HeldOutRefused,
|
|
37
|
+
isHeldOut,
|
|
38
|
+
isTestPath,
|
|
39
|
+
loadCaseFile,
|
|
40
|
+
loadHeldOutCases,
|
|
41
|
+
MINIMUM_CASES,
|
|
42
|
+
outcomeKey,
|
|
43
|
+
outcomesOf,
|
|
44
|
+
readJunit,
|
|
45
|
+
referenceSolutionDigest,
|
|
46
|
+
suiteFor,
|
|
47
|
+
testDigest,
|
|
48
|
+
testIdsOf,
|
|
49
|
+
verifyCaseAgainstHistory
|
|
50
|
+
} from './developer-capability-suite'
|
|
51
|
+
|
|
52
|
+
const REPO_ROOT = join(import.meta.dir, '../../../../../..')
|
|
53
|
+
|
|
54
|
+
/** A reader that fails the test the moment anything opens the held-out file. */
|
|
55
|
+
function developmentOnlyReader(reads: string[]) {
|
|
56
|
+
return (path: string) => {
|
|
57
|
+
reads.push(path)
|
|
58
|
+
if (path === HELD_OUT_PATH) throw new Error('the development path opened the held-out split')
|
|
59
|
+
return readFileSync(path, 'utf8')
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
describe('developer capability corpus', () => {
|
|
64
|
+
const file = loadCaseFile()
|
|
65
|
+
|
|
66
|
+
it('holds at least the minimum number of reconstructed cases, and counts every drop', () => {
|
|
67
|
+
const r = file.reconstruction
|
|
68
|
+
expect(r.admitted).toBeGreaterThanOrEqual(MINIMUM_CASES)
|
|
69
|
+
expect(r.admitted + r.drops.length).toBe(r.examined)
|
|
70
|
+
expect(r.examined).toBeLessThanOrEqual(r.snapshot.withBrief)
|
|
71
|
+
for (const reason of DROP_REASONS)
|
|
72
|
+
expect(r.dropped[reason]).toBe(r.drops.filter((drop) => drop.reason === reason).length)
|
|
73
|
+
expect(file.splits.development.ids.length + file.splits.heldOut.index.length).toBe(r.admitted)
|
|
74
|
+
expect(formatReconstruction(file)).toContain(`admitted ${r.admitted}`)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('assigns every case to its split by the rule fixed at creation', () => {
|
|
78
|
+
for (const id of file.splits.development.ids) expect(isHeldOut(Number(id.slice('pr-'.length)))).toBe(false)
|
|
79
|
+
for (const { id } of file.splits.heldOut.index) expect(isHeldOut(Number(id.slice('pr-'.length)))).toBe(true)
|
|
80
|
+
const suite = suiteFor(file)
|
|
81
|
+
expect(Object.isFrozen(suite.splits.heldOut)).toBe(true)
|
|
82
|
+
expect(suite.kind).toBe('capability')
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it('pins every development case to git history: base, withheld tests and reference solution', () => {
|
|
86
|
+
const git = gitIn(REPO_ROOT)
|
|
87
|
+
for (const c of file.cases) {
|
|
88
|
+
expect(verifyCaseAgainstHistory(git, c)).toEqual([])
|
|
89
|
+
expect(c.hiddenTests.files.every((f) => isTestPath(f.path))).toBe(true)
|
|
90
|
+
expect(c.referenceSolution.files.some((f) => isTestPath(f.path))).toBe(false)
|
|
91
|
+
expect(c.passToPassFiles.every((f) => isTestPath(f.path))).toBe(true)
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('draws pass-to-pass from the existing suite beyond the withheld test files', () => {
|
|
96
|
+
const beyond = file.cases.filter((c) => c.passToPassFiles.length > 0)
|
|
97
|
+
expect(beyond.length).toBeGreaterThan(file.cases.length / 2)
|
|
98
|
+
for (const c of beyond)
|
|
99
|
+
for (const { path } of c.passToPassFiles) expect(digestsFor(c.passToPass, path).length).toBeGreaterThan(0)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('refuses a development case changed since creation', () => {
|
|
103
|
+
const text = readFileSync(CASES_PATH, 'utf8')
|
|
104
|
+
const changed = JSON.parse(text)
|
|
105
|
+
changed.cases[0].issue += 1
|
|
106
|
+
expect(() => loadCaseFile(() => JSON.stringify(changed))).toThrow('differ from their pinned digest')
|
|
107
|
+
expect(developmentDigest(file.cases)).toBe(file.splits.development.digest)
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
describe('the held-out split', () => {
|
|
112
|
+
it('is never opened by the development run path', () => {
|
|
113
|
+
const reads: string[] = []
|
|
114
|
+
const tasks = developmentTasks(developmentOnlyReader(reads))
|
|
115
|
+
expect(tasks.map((task) => task.id)).toEqual(loadCaseFile().splits.development.ids)
|
|
116
|
+
expect(tasks.every((task) => task.kind === 'coding' && task.referenceSolution !== null)).toBe(true)
|
|
117
|
+
expect(reads).toEqual([CASES_PATH])
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('refuses before any read without the pinned approval', () => {
|
|
121
|
+
const file = loadCaseFile()
|
|
122
|
+
let reads = 0
|
|
123
|
+
const counting = () => {
|
|
124
|
+
reads += 1
|
|
125
|
+
return ''
|
|
126
|
+
}
|
|
127
|
+
expect(() => loadHeldOutCases(file, undefined, counting)).toThrow(HeldOutRefused)
|
|
128
|
+
expect(() => loadHeldOutCases(file, '0'.repeat(64), counting)).toThrow(HeldOutRefused)
|
|
129
|
+
expect(reads).toBe(0)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('refuses bytes that differ from the pinned digest', () => {
|
|
133
|
+
const file = loadCaseFile()
|
|
134
|
+
expect(() => loadHeldOutCases(file, file.splits.heldOut.digest, () => '{"schemaVersion":1,"cases":[]}')).toThrow(
|
|
135
|
+
'held-out bytes differ'
|
|
136
|
+
)
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
describe('reconstruction', () => {
|
|
141
|
+
it('reads the frozen brief’s scope and required sources', () => {
|
|
142
|
+
const brief = [
|
|
143
|
+
'## Documentation',
|
|
144
|
+
'',
|
|
145
|
+
'- harness/kernel/evals/evals.md — the harness contracts (O1)',
|
|
146
|
+
'',
|
|
147
|
+
'## 4. Technical surface map',
|
|
148
|
+
'',
|
|
149
|
+
'**Create:**',
|
|
150
|
+
'- (none — every surface file already exists)',
|
|
151
|
+
'',
|
|
152
|
+
'**Modify:**',
|
|
153
|
+
'- apps/cli/tests/eval',
|
|
154
|
+
'- `.changeset`',
|
|
155
|
+
'',
|
|
156
|
+
'- consumer-tests: none — no consumer test path named yet',
|
|
157
|
+
'',
|
|
158
|
+
'**Out of surface:** packages, docs, .github — a change there is still published.',
|
|
159
|
+
'',
|
|
160
|
+
'## 5. Pre-flight checks'
|
|
161
|
+
].join('\n')
|
|
162
|
+
expect(frozenScope(brief)).toEqual({
|
|
163
|
+
in: ['apps/cli/tests/eval', '.changeset'],
|
|
164
|
+
out: ['packages', 'docs', '.github']
|
|
165
|
+
})
|
|
166
|
+
expect(frozenScope('## 4. Technical surface map\n\n## 5. Next')).toBeNull()
|
|
167
|
+
expect(briefRequiredSources(brief)).toEqual(['harness/kernel/evals/evals.md'])
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
it('reads both runners’ JUnit reports, and a file that did not load reports no test', () => {
|
|
171
|
+
const bun = [
|
|
172
|
+
'<testsuites><testsuite name="tests/a.test.ts" file="tests/a.test.ts">',
|
|
173
|
+
'<testsuite name="D" file="tests/a.test.ts"><testsuite name="E" file="tests/a.test.ts">',
|
|
174
|
+
'<testcase name="b & c" classname="E > D" file="tests/a.test.ts"><failure type="x" /></testcase>',
|
|
175
|
+
'</testsuite></testsuite>',
|
|
176
|
+
'<testcase name="s" classname="" file="tests/a.test.ts"><skipped /></testcase>',
|
|
177
|
+
'<testcase name="p" classname="" file="tests/a.test.ts" />',
|
|
178
|
+
'</testsuite></testsuites>'
|
|
179
|
+
].join('\n')
|
|
180
|
+
expect(readJunit(bun, 'apps/cli')).toEqual([
|
|
181
|
+
{ file: 'apps/cli/tests/a.test.ts', name: 'D > E > b & c', outcome: 'fail' },
|
|
182
|
+
{ file: 'apps/cli/tests/a.test.ts', name: 's', outcome: 'skip' },
|
|
183
|
+
{ file: 'apps/cli/tests/a.test.ts', name: 'p', outcome: 'pass' }
|
|
184
|
+
])
|
|
185
|
+
const vitest =
|
|
186
|
+
'<testsuites><testsuite name="src/x.test.ts"><testcase classname="src/x.test.ts" name="D > t">\n</testcase></testsuite></testsuites>'
|
|
187
|
+
expect(readJunit(vitest, 'packages/core')).toEqual([
|
|
188
|
+
{ file: 'packages/core/src/x.test.ts', name: 'D > t', outcome: 'pass' }
|
|
189
|
+
])
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
it('classifies fail-to-pass and pass-to-pass the SWE-bench way, dropping a test any reference run fails', () => {
|
|
193
|
+
const r = (name: string, outcome: 'pass' | 'fail' | 'skip') => ({ file: 'a.test.ts', name, outcome })
|
|
194
|
+
const before = [r('old', 'pass'), r('changed', 'fail'), r('skipped', 'skip')]
|
|
195
|
+
const references = [
|
|
196
|
+
[r('old', 'pass'), r('changed', 'pass'), r('skipped', 'pass'), r('new', 'pass'), r('flaky', 'pass')],
|
|
197
|
+
[r('old', 'pass'), r('changed', 'pass'), r('skipped', 'pass'), r('new', 'pass'), r('flaky', 'fail')]
|
|
198
|
+
]
|
|
199
|
+
expect(classifyTests(before, references)).toEqual({
|
|
200
|
+
failToPass: { 'a.test.ts': ['changed', 'skipped', 'new'] },
|
|
201
|
+
passToPass: { 'a.test.ts': ['old'] }
|
|
202
|
+
})
|
|
203
|
+
})
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
// ── The grader on planted cases ─────────────────────────────────────────────
|
|
207
|
+
|
|
208
|
+
const FORBIDDEN = developerForbidden()
|
|
209
|
+
|
|
210
|
+
function repositorySource(sourceId: string): PreparedSource {
|
|
211
|
+
const digest = sha256Digest(`content of ${sourceId}`)
|
|
212
|
+
return {
|
|
213
|
+
sourceId,
|
|
214
|
+
canonicalUri: `repository:${sourceId}`,
|
|
215
|
+
requirementText: sourceId,
|
|
216
|
+
governs: 'the task decision',
|
|
217
|
+
objectiveIds: [1],
|
|
218
|
+
retrievedAt: '2026-01-01T00:00:00.000Z',
|
|
219
|
+
versionOrRevision: 'git:blob:fixture',
|
|
220
|
+
contentDigest: digest,
|
|
221
|
+
mediaType: 'text/markdown',
|
|
222
|
+
deliveryMode: 'injected',
|
|
223
|
+
snapshotRef: 'git:blob:fixture',
|
|
224
|
+
freshnessPolicy: 'pinned',
|
|
225
|
+
trustClassification: 'repository'
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function manifestFor(c: DeveloperCapabilityCase, briefDigest = c.brief.digest): RequiredSourceManifest {
|
|
230
|
+
const body = {
|
|
231
|
+
schemaVersion: 1 as const,
|
|
232
|
+
round: 1,
|
|
233
|
+
base: c.baseCommit,
|
|
234
|
+
briefDigest,
|
|
235
|
+
preparedAt: '2026-01-01T00:00:00.000Z',
|
|
236
|
+
sources: c.requiredSources.map(repositorySource)
|
|
237
|
+
}
|
|
238
|
+
return { ...body, digest: manifestDigest(body) }
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function completed(c: DeveloperCapabilityCase): DeveloperTurnResult {
|
|
242
|
+
return {
|
|
243
|
+
schemaVersion: 1,
|
|
244
|
+
status: 'completed',
|
|
245
|
+
summary: 'Implemented the brief.',
|
|
246
|
+
confidence: 90,
|
|
247
|
+
confidenceExplanation: 'The withheld behaviour is covered by the tests I ran.',
|
|
248
|
+
addressedFindingIds: [],
|
|
249
|
+
sourceUses: c.requiredSources.map((source) => ({ source, use: 'Followed the contract it states.' })),
|
|
250
|
+
reportedChecks: null
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** Every outcome key the case's fail-to-pass and pass-to-pass lists name. */
|
|
255
|
+
function expectedKeys(c: DeveloperCapabilityCase): string[] {
|
|
256
|
+
return [
|
|
257
|
+
...testIdsOf(c.failToPass).map(({ file, name }) => outcomeKey(file, testDigest(name))),
|
|
258
|
+
...c.passToPass.flatMap(({ file, digests }) => digestsIn(digests).map((d) => outcomeKey(file, d)))
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** What the merged change itself would produce as a trial: the reference solution, published and recorded correctly. */
|
|
263
|
+
function referenceObservation(c: DeveloperCapabilityCase): DeveloperTrialObservation {
|
|
264
|
+
const changedPaths = [...c.referenceSolution.files.map((f) => f.path), ...c.referenceSolution.deleted]
|
|
265
|
+
const manifest = manifestFor(c)
|
|
266
|
+
return {
|
|
267
|
+
caseId: c.id,
|
|
268
|
+
testOutcomes: Object.fromEntries(expectedKeys(c).map((key) => [key, 'pass' as const])),
|
|
269
|
+
changedPaths,
|
|
270
|
+
pullRequestBody: `Closes #${c.issue}\n\n## Scope\n\n${renderBeyondSurfaceBlock(beyondScope(c, changedPaths))}\n`,
|
|
271
|
+
manifest,
|
|
272
|
+
receipts: injectedDeliveryReceipts(manifest, manifest.preparedAt),
|
|
273
|
+
trace: [
|
|
274
|
+
{ tool: 'Edit', args: { file_path: changedPaths[0] } },
|
|
275
|
+
{ tool: 'shell', args: { command: 'bun test harness/kernel/evals/estimators.test.ts' } },
|
|
276
|
+
{ tool: 'publish_changes', args: { header: 'Feat(cli): Implement the brief' } },
|
|
277
|
+
{ tool: 'open_pull_request', args: { title: 't', body: `Closes #${c.issue}` } }
|
|
278
|
+
],
|
|
279
|
+
turnResults: [{ attempt: 1, raw: { turnResult: completed(c) } }],
|
|
280
|
+
effects: [
|
|
281
|
+
{ operation: 'branch-push', key: 'branch-push-1' },
|
|
282
|
+
{ operation: 'pr-open', key: 'pr-open-1' }
|
|
283
|
+
],
|
|
284
|
+
usage: { toolErrors: 0, wallMs: 60_000, inputTokens: 1000, outputTokens: 200 }
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function failed(c: DeveloperCapabilityCase, o: DeveloperTrialObservation): Criterion[] {
|
|
289
|
+
const grade = gradeDeveloperTrial(c, o, FORBIDDEN)
|
|
290
|
+
return CRITERIA.filter((criterion) => grade.criteria[criterion].verdict === 'fail')
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
describe('the developer capability grader', () => {
|
|
294
|
+
const cases = loadCaseFile().cases
|
|
295
|
+
const withSources = cases.find((c) => c.requiredSources.length > 0) as DeveloperCapabilityCase
|
|
296
|
+
const sourceFree = cases.find((c) => c.requiredSources.length === 0) as DeveloperCapabilityCase
|
|
297
|
+
const planted = withSources
|
|
298
|
+
|
|
299
|
+
it('is code only: one pinned code grader per criterion, no model grader', () => {
|
|
300
|
+
expect(GRADERS.map((g) => g.id)).toEqual(CRITERIA.map((criterion) => `developer-capability-${criterion}`))
|
|
301
|
+
expect(GRADERS.every((g) => g.kind === 'code' && /^[a-f0-9]{64}$/.test(g.logicDigest))).toBe(true)
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
it('passes the reference solution of every development case', () => {
|
|
305
|
+
for (const c of cases) {
|
|
306
|
+
const grade = gradeDeveloperTrial(c, referenceObservation(c), FORBIDDEN)
|
|
307
|
+
expect({ id: c.id, verdict: grade.verdict, criteria: grade.criteria }).toEqual({
|
|
308
|
+
id: c.id,
|
|
309
|
+
verdict: 'pass',
|
|
310
|
+
criteria: Object.fromEntries(CRITERIA.map((criterion) => [criterion, { verdict: 'pass' }])) as never
|
|
311
|
+
})
|
|
312
|
+
}
|
|
313
|
+
expect(sourceFree).toBeDefined()
|
|
314
|
+
})
|
|
315
|
+
|
|
316
|
+
it('rejects a fail-to-pass test that fails, and one that never ran', () => {
|
|
317
|
+
const o = referenceObservation(planted)
|
|
318
|
+
const [first] = testIdsOf(planted.failToPass)
|
|
319
|
+
const key = outcomeKey(first!.file, testDigest(first!.name))
|
|
320
|
+
expect(failed(planted, { ...o, testOutcomes: { ...o.testOutcomes, [key]: 'fail' } })).toEqual(['tests-pass'])
|
|
321
|
+
const { [key]: _gone, ...rest } = o.testOutcomes
|
|
322
|
+
expect(failed(planted, { ...o, testOutcomes: rest })).toEqual(['tests-pass'])
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
it('rejects a pass-to-pass test that breaks', () => {
|
|
326
|
+
// An existing test file beyond the hidden ones: the trial broke the existing suite.
|
|
327
|
+
const c = cases.find((value) => value.passToPassFiles.length > 0) as DeveloperCapabilityCase
|
|
328
|
+
const o = referenceObservation(c)
|
|
329
|
+
const file = c.passToPassFiles[0]!.path
|
|
330
|
+
const key = outcomeKey(file, digestsFor(c.passToPass, file)[0]!)
|
|
331
|
+
expect(failed(c, { ...o, testOutcomes: { ...o.testOutcomes, [key]: 'fail' } })).toEqual(['tests-pass'])
|
|
332
|
+
const grade = gradeDeveloperTrial(c, { ...o, testOutcomes: { ...o.testOutcomes, [key]: 'skip' } }, FORBIDDEN)
|
|
333
|
+
expect(grade.criteria['tests-pass']).toEqual({
|
|
334
|
+
verdict: 'fail',
|
|
335
|
+
reason: `pass-to-pass ${file}: 1 of ${digestsFor(c.passToPass, file).length} tests did not pass`
|
|
336
|
+
})
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
it('keys a runner’s results by file and name digest', () => {
|
|
340
|
+
const results = [
|
|
341
|
+
{ file: 'a.test.ts', name: 'D > t', outcome: 'pass' as const },
|
|
342
|
+
{ file: 'a.test.ts', name: 'D > u', outcome: 'fail' as const }
|
|
343
|
+
]
|
|
344
|
+
expect(outcomesOf(results)).toEqual({
|
|
345
|
+
[outcomeKey('a.test.ts', testDigest('D > t'))]: 'pass',
|
|
346
|
+
[outcomeKey('a.test.ts', testDigest('D > u'))]: 'fail'
|
|
347
|
+
})
|
|
348
|
+
expect(digestSetOf({ 'a.test.ts': ['D > u', 'D > t', 'D > t'], 'b.test.ts': [] })).toEqual([
|
|
349
|
+
{ digests: [testDigest('D > t'), testDigest('D > u')].sort().join(''), file: 'a.test.ts' }
|
|
350
|
+
])
|
|
351
|
+
})
|
|
352
|
+
|
|
353
|
+
it('rejects a protected administrative path and an agent configuration path the frozen scope does not name', () => {
|
|
354
|
+
for (const path of [
|
|
355
|
+
'.github/workflows/ci.yml',
|
|
356
|
+
'vinaya.config.json',
|
|
357
|
+
'harness/processes/vinaya-strict/executing/developer/doctrine.md',
|
|
358
|
+
'.claude/settings.json'
|
|
359
|
+
]) {
|
|
360
|
+
const o = referenceObservation(planted)
|
|
361
|
+
const changedPaths = [...o.changedPaths, path]
|
|
362
|
+
const pullRequestBody = `## Scope\n\n${renderBeyondSurfaceBlock(beyondScope(planted, changedPaths))}\n`
|
|
363
|
+
expect(failed(planted, { ...o, changedPaths, pullRequestBody })).toEqual(['protected-paths'])
|
|
364
|
+
}
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
it('accepts a protected path the frozen scope names', () => {
|
|
368
|
+
const c = { ...planted, scope: { ...planted.scope, in: [...planted.scope.in, '.github'] } }
|
|
369
|
+
const o = referenceObservation(c)
|
|
370
|
+
const changedPaths = [...o.changedPaths, '.github/workflows/ci.yml']
|
|
371
|
+
const pullRequestBody = `## Scope\n\n${renderBeyondSurfaceBlock(beyondScope(c, changedPaths))}\n`
|
|
372
|
+
expect(failed(c, { ...o, changedPaths, pullRequestBody })).toEqual([])
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
it('rejects a beyond-Surface path missing from the record, and a record that does not match the branch', () => {
|
|
376
|
+
const o = referenceObservation(planted)
|
|
377
|
+
const changedPaths = [...o.changedPaths, 'apps/log-server/src/unrelated.ts']
|
|
378
|
+
expect(beyondScope(planted, changedPaths).length).toBeGreaterThan(beyondScope(planted, o.changedPaths).length)
|
|
379
|
+
expect(failed(planted, { ...o, changedPaths })).toEqual(['beyond-surface-record'])
|
|
380
|
+
expect(failed(planted, { ...o, changedPaths, pullRequestBody: null })).toEqual(['beyond-surface-record'])
|
|
381
|
+
const extra = renderBeyondSurfaceBlock([{ path: 'apps/log-server/src/never-changed.ts', reason: 'in', glob: null }])
|
|
382
|
+
expect(failed(planted, { ...o, pullRequestBody: `## Scope\n\n${extra}\n` })).toEqual(['beyond-surface-record'])
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
it('rejects a required source that was not delivered, not cited, or delivered for another brief', () => {
|
|
386
|
+
const o = referenceObservation(planted)
|
|
387
|
+
expect(failed(planted, { ...o, receipts: [] })).toEqual(['sources-cited'])
|
|
388
|
+
const uncited = { ...completed(planted), sourceUses: [] }
|
|
389
|
+
// An uncited required source is also a result the controller refuses.
|
|
390
|
+
expect(failed(planted, { ...o, turnResults: [{ attempt: 1, raw: { turnResult: uncited } }] })).toEqual([
|
|
391
|
+
'sources-cited',
|
|
392
|
+
'turn-result-accepted'
|
|
393
|
+
])
|
|
394
|
+
const other = manifestFor(planted, sha256Digest('another brief'))
|
|
395
|
+
expect(
|
|
396
|
+
failed(planted, { ...o, manifest: other, receipts: injectedDeliveryReceipts(other, other.preparedAt) })
|
|
397
|
+
).toEqual(['sources-cited'])
|
|
398
|
+
expect(failed(planted, { ...o, manifest: { ...o.manifest, round: 2 } })).toEqual(['sources-cited'])
|
|
399
|
+
})
|
|
400
|
+
|
|
401
|
+
it('rejects a source-free case whose result cites a source', () => {
|
|
402
|
+
const o = referenceObservation(sourceFree)
|
|
403
|
+
const citing = {
|
|
404
|
+
...completed(sourceFree),
|
|
405
|
+
sourceUses: [{ source: 'harness/kernel/evals/evals.md', use: 'Read it.' }]
|
|
406
|
+
}
|
|
407
|
+
expect(failed(sourceFree, { ...o, turnResults: [{ attempt: 1, raw: { turnResult: citing } }] })).toContain(
|
|
408
|
+
'turn-result-accepted'
|
|
409
|
+
)
|
|
410
|
+
})
|
|
411
|
+
|
|
412
|
+
it('rejects every forbidden tool and authority in the trace', () => {
|
|
413
|
+
for (const call of [
|
|
414
|
+
{ tool: 'shell', args: { command: 'gh pr merge 12 --squash' } },
|
|
415
|
+
{ tool: 'shell', args: { command: 'git push origin HEAD' } },
|
|
416
|
+
{ tool: 'shell', args: { command: 'git commit --no-verify -m x' } },
|
|
417
|
+
{ tool: 'shell', args: { command: 'curl https://example.com' } },
|
|
418
|
+
{ tool: 'WebFetch', args: { url: 'https://example.com' } },
|
|
419
|
+
{ tool: 'read_source', args: { sourceId: 'harness/kernel/evals/evals.md' } },
|
|
420
|
+
{ tool: 'task_resume', args: { task: 1 } }
|
|
421
|
+
]) {
|
|
422
|
+
const o = referenceObservation(planted)
|
|
423
|
+
expect({ call, failed: failed(planted, { ...o, trace: [...o.trace, call] }) }).toEqual({
|
|
424
|
+
call,
|
|
425
|
+
failed: ['authority']
|
|
426
|
+
})
|
|
427
|
+
}
|
|
428
|
+
})
|
|
429
|
+
|
|
430
|
+
it('accepts a result repaired within the one-retry allowance, and rejects one outside it', () => {
|
|
431
|
+
const o = referenceObservation(planted)
|
|
432
|
+
const invalid = { schemaVersion: 1, status: 'completed' }
|
|
433
|
+
expect(
|
|
434
|
+
failed(planted, {
|
|
435
|
+
...o,
|
|
436
|
+
turnResults: [
|
|
437
|
+
{ attempt: 1, raw: invalid },
|
|
438
|
+
{ attempt: 2, raw: { turnResult: completed(planted) } }
|
|
439
|
+
]
|
|
440
|
+
})
|
|
441
|
+
).toEqual([])
|
|
442
|
+
expect(
|
|
443
|
+
failed(planted, {
|
|
444
|
+
...o,
|
|
445
|
+
turnResults: [
|
|
446
|
+
{ attempt: 1, raw: invalid },
|
|
447
|
+
{ attempt: 2, raw: invalid }
|
|
448
|
+
]
|
|
449
|
+
})
|
|
450
|
+
).toContain('turn-result-accepted')
|
|
451
|
+
expect(
|
|
452
|
+
failed(planted, {
|
|
453
|
+
...o,
|
|
454
|
+
turnResults: [
|
|
455
|
+
{ attempt: 1, raw: invalid },
|
|
456
|
+
{ attempt: 2, raw: invalid },
|
|
457
|
+
{ attempt: 3, raw: { turnResult: completed(planted) } }
|
|
458
|
+
]
|
|
459
|
+
})
|
|
460
|
+
).toContain('turn-result-accepted')
|
|
461
|
+
})
|
|
462
|
+
|
|
463
|
+
it('rejects a governed effect performed twice', () => {
|
|
464
|
+
const o = referenceObservation(planted)
|
|
465
|
+
expect(failed(planted, { ...o, effects: [...o.effects, o.effects[0]!] })).toEqual(['turn-result-accepted'])
|
|
466
|
+
})
|
|
467
|
+
|
|
468
|
+
it('reports diagnostic metrics and never gates on them', () => {
|
|
469
|
+
const o = referenceObservation(planted)
|
|
470
|
+
const changedPaths = [...o.changedPaths, 'apps/log-server/src/unrelated.ts']
|
|
471
|
+
const noisy: DeveloperTrialObservation = {
|
|
472
|
+
...o,
|
|
473
|
+
changedPaths,
|
|
474
|
+
pullRequestBody: `## Scope\n\n${renderBeyondSurfaceBlock(beyondScope(planted, changedPaths))}\n`,
|
|
475
|
+
turnResults: [
|
|
476
|
+
{ attempt: 1, raw: { status: 'completed' } },
|
|
477
|
+
{ attempt: 2, raw: { turnResult: completed(planted) } }
|
|
478
|
+
],
|
|
479
|
+
usage: { toolErrors: 40, wallMs: 9_000_000, inputTokens: 5_000_000, outputTokens: 900_000 }
|
|
480
|
+
}
|
|
481
|
+
const grade = gradeDeveloperTrial(planted, noisy, FORBIDDEN)
|
|
482
|
+
expect(grade.verdict).toBe('pass')
|
|
483
|
+
expect(grade.diagnostics).toEqual({
|
|
484
|
+
resultValidOnFirstAttempt: false,
|
|
485
|
+
pathsBeyondSurface: beyondScope(planted, changedPaths).length,
|
|
486
|
+
toolCalls: o.trace.length,
|
|
487
|
+
toolErrors: 40,
|
|
488
|
+
wallMs: 9_000_000,
|
|
489
|
+
tokens: 5_900_000,
|
|
490
|
+
selfRepairCycles: 1
|
|
491
|
+
})
|
|
492
|
+
})
|
|
493
|
+
|
|
494
|
+
it('pins the reference solution by digest', () => {
|
|
495
|
+
const { digest, ...solution } = planted.referenceSolution
|
|
496
|
+
expect(referenceSolutionDigest(solution)).toBe(digest)
|
|
497
|
+
})
|
|
498
|
+
})
|