@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.
- package/dist/checks/bin/check-evidence-fresh.js +177 -152
- package/dist/checks/bin/check-registry-gates.js +10 -3
- package/dist/index.js +300 -173
- package/dist/lib/pre-push-cache-test-run.js +145 -144
- package/dist/lib/pre-push-changed-files.js +10 -3
- package/dist/lib/pre-push-progress-dir.js +169 -147
- package/dist/lib/pre-push-select-tests.js +16 -4
- package/dist/lib/push-progress-observer.js +169 -147
- package/dist/programs/archive.js +172 -148
- package/dist/programs/audit.js +169 -147
- package/dist/programs/check.js +172 -148
- package/dist/programs/commit-msg.js +172 -148
- package/dist/programs/dev-review-loop.js +300 -176
- package/dist/programs/dispatch.js +1905 -1877
- package/dist/programs/log-emit.js +172 -148
- package/dist/programs/log-selftest.js +172 -148
- package/dist/programs/log-send.js +172 -148
- package/dist/programs/pr-report.js +177 -152
- package/dist/programs/pr-snapshot.js +172 -148
- package/dist/programs/pr-verify-evidence.js +177 -152
- package/dist/programs/pr.js +172 -148
- package/dist/programs/review-post.js +172 -148
- package/dist/programs/review-status.js +180 -148
- package/dist/programs/run-engine.js +110594 -0
- package/dist/programs/supervised-command.js +67 -0
- package/dist/programs/sync.js +63 -39
- package/dist/programs/task-brief.js +174 -150
- package/dist/programs/task-sweep.js +244 -151
- package/dist/programs/task-tools-serve.js +260 -163
- package/dist/programs/tokens.js +172 -148
- package/dist/programs/waiver.js +172 -148
- 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/{yFfoujElgbwPk-7KNS-kw → x2q88XfwsihlevulRhIvs}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/.next/static/{yFfoujElgbwPk-7KNS-kw → x2q88XfwsihlevulRhIvs}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import { describe, expect, it } from 'vitest'
|
|
5
|
+
import { captureRefusal, makeCheckError, refuse } from '../../../tools/task-contract/forge/forge-write'
|
|
6
|
+
import {
|
|
7
|
+
type ObjectivesDeps,
|
|
8
|
+
type PlannerForge,
|
|
9
|
+
createIssue,
|
|
10
|
+
editIssue,
|
|
11
|
+
editObjectives,
|
|
12
|
+
printIssueSurface,
|
|
13
|
+
renderBrief
|
|
14
|
+
} from './planner-operations'
|
|
15
|
+
|
|
16
|
+
const finding = (check: string) => makeCheckError(check, `${check} message`, `${check} recovery`)
|
|
17
|
+
|
|
18
|
+
/** A forge whose every step passes; a test overrides the step it exercises. */
|
|
19
|
+
function stubForge(over: Partial<PlannerForge> = {}): PlannerForge & { calls: string[] } {
|
|
20
|
+
const calls: string[] = []
|
|
21
|
+
const forge: PlannerForge = {
|
|
22
|
+
fetchLabels: () => ({ labels: ['vinaya/tranche:demo'] }),
|
|
23
|
+
frozenSectionChange: () => [],
|
|
24
|
+
validate: async () => ({ errors: [], blocking: false, renderSkipped: null }),
|
|
25
|
+
ensureTrancheLabel: (slug) => {
|
|
26
|
+
calls.push(`label:${slug}`)
|
|
27
|
+
return []
|
|
28
|
+
},
|
|
29
|
+
milestoneArgs: (args) => ({ args: [...args, '--milestone', 'M'], notice: null }),
|
|
30
|
+
ghWrite: (cmd, args) => {
|
|
31
|
+
calls.push(`gh ${cmd.join(' ')} ${args.join(' ')}`)
|
|
32
|
+
return { ok: true, url: 'https://example.test/issues/7' }
|
|
33
|
+
},
|
|
34
|
+
...over
|
|
35
|
+
}
|
|
36
|
+
return Object.assign(forge, { calls })
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function withBody<T>(body: string, run: (bodyFile: string) => Promise<T> | T): Promise<T> | T {
|
|
40
|
+
const dir = mkdtempSync(join(tmpdir(), 'planner-ops-'))
|
|
41
|
+
const file = join(dir, 'body.md')
|
|
42
|
+
writeFileSync(file, body, 'utf8')
|
|
43
|
+
const done = () => rmSync(dir, { recursive: true, force: true })
|
|
44
|
+
try {
|
|
45
|
+
const out = run(file)
|
|
46
|
+
if (out instanceof Promise) return out.finally(done)
|
|
47
|
+
done()
|
|
48
|
+
return out
|
|
49
|
+
} catch (e) {
|
|
50
|
+
done()
|
|
51
|
+
throw e
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const createArgs = (file: string) => [
|
|
56
|
+
'--title',
|
|
57
|
+
'[demo] 1 — A task',
|
|
58
|
+
'--label',
|
|
59
|
+
'vinaya/tranche:demo',
|
|
60
|
+
'--body-file',
|
|
61
|
+
file
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
describe('createIssue', () => {
|
|
65
|
+
it('passes: ensures the label, attaches the Milestone, and returns the written link', async () => {
|
|
66
|
+
const forge = stubForge()
|
|
67
|
+
const out = await withBody('body', (f) => createIssue({ ghArgs: createArgs(f) }, {}, forge))
|
|
68
|
+
expect(out).toMatchObject({ ok: true, written: true, url: 'https://example.test/issues/7' })
|
|
69
|
+
expect(forge.calls[0]).toBe('label:demo')
|
|
70
|
+
expect(forge.calls[1]).toContain('--milestone M')
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('validate-only runs the gates and writes nothing', async () => {
|
|
74
|
+
const forge = stubForge()
|
|
75
|
+
const out = await withBody('body', (f) => createIssue({ ghArgs: createArgs(f), validateOnly: true }, {}, forge))
|
|
76
|
+
expect(out).toMatchObject({ ok: true, written: false, url: '', renderSkipped: null })
|
|
77
|
+
expect(forge.calls).toEqual([])
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('refuses with the gate findings and writes nothing', async () => {
|
|
81
|
+
const forge = stubForge({
|
|
82
|
+
validate: async () => ({ errors: [finding('brief-shape')], blocking: true, renderSkipped: null })
|
|
83
|
+
})
|
|
84
|
+
const out = await withBody('body', (f) => createIssue({ ghArgs: createArgs(f) }, {}, forge))
|
|
85
|
+
expect(out.ok).toBe(false)
|
|
86
|
+
if (!out.ok) expect(out.findings.map((e) => e.check)).toEqual(['brief-shape'])
|
|
87
|
+
expect(forge.calls).toEqual([])
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('reports a warning without refusing', async () => {
|
|
91
|
+
const warning = makeCheckError('depends-on', 'unmerged', 'wait', 'warning')
|
|
92
|
+
const seen: string[] = []
|
|
93
|
+
const forge = stubForge({ validate: async () => ({ errors: [warning], blocking: false, renderSkipped: null }) })
|
|
94
|
+
const out = await withBody('body', (f) =>
|
|
95
|
+
createIssue({ ghArgs: createArgs(f) }, { warning: (e) => seen.push(e.check) }, forge)
|
|
96
|
+
)
|
|
97
|
+
expect(out.ok).toBe(true)
|
|
98
|
+
expect(seen).toEqual(['depends-on'])
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('refuses an unreadable invocation (--body-file with no path) as a forge-args finding', async () => {
|
|
102
|
+
const out = await createIssue({ ghArgs: ['--body-file'] }, {}, stubForge())
|
|
103
|
+
expect(out.ok).toBe(false)
|
|
104
|
+
if (!out.ok) expect(out.findings[0]?.check).toBe('forge-args')
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('returns the tranche-label failure as a finding, before the write', async () => {
|
|
108
|
+
const forge = stubForge({ ensureTrancheLabel: () => [finding('forge-fetch')] })
|
|
109
|
+
const out = await withBody('body', (f) => createIssue({ ghArgs: createArgs(f) }, {}, forge))
|
|
110
|
+
expect(out.ok).toBe(false)
|
|
111
|
+
expect(forge.calls).toEqual([])
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('returns a failed gh write as a refusal carrying the raw error', async () => {
|
|
115
|
+
const boom = new Error('gh exploded')
|
|
116
|
+
const forge = stubForge({ ghWrite: () => ({ ok: false, errors: [finding('forge-write')], cause: boom }) })
|
|
117
|
+
const out = await withBody('body', (f) => createIssue({ ghArgs: createArgs(f) }, {}, forge))
|
|
118
|
+
expect(out.ok).toBe(false)
|
|
119
|
+
if (!out.ok) {
|
|
120
|
+
expect(out.forgeError).toBe(boom)
|
|
121
|
+
expect(out.findings[0]?.check).toBe('forge-write')
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
describe('editIssue', () => {
|
|
127
|
+
const edit = (f: string) => ['7', '--body-file', f]
|
|
128
|
+
|
|
129
|
+
it('passes: writes and returns the link', async () => {
|
|
130
|
+
const forge = stubForge()
|
|
131
|
+
const out = await withBody('body', (f) => editIssue({ args: edit(f) }, {}, forge))
|
|
132
|
+
expect(out).toMatchObject({ ok: true, written: true, url: 'https://example.test/issues/7' })
|
|
133
|
+
expect(forge.calls.at(-1)).toContain('gh issue edit 7')
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
it('validate-only writes nothing', async () => {
|
|
137
|
+
const forge = stubForge()
|
|
138
|
+
const out = await withBody('body', (f) => editIssue({ args: edit(f), validateOnly: true }, {}, forge))
|
|
139
|
+
expect(out).toMatchObject({ ok: true, written: false })
|
|
140
|
+
expect(forge.calls).toEqual([])
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('refuses without a target Issue', async () => {
|
|
144
|
+
const out = await editIssue({ args: ['--body-file', 'x'] }, {}, stubForge())
|
|
145
|
+
expect(out.ok).toBe(false)
|
|
146
|
+
if (!out.ok) expect(out.findings[0]?.check).toBe('forge-args')
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('refuses a change to a frozen section before validating', async () => {
|
|
150
|
+
const forge = stubForge({ frozenSectionChange: () => [finding('issue-frozen-brief')] })
|
|
151
|
+
const out = await withBody('body', (f) => editIssue({ args: edit(f) }, {}, forge))
|
|
152
|
+
expect(out.ok).toBe(false)
|
|
153
|
+
if (!out.ok) expect(out.findings[0]?.check).toBe('issue-frozen-brief')
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
it('refuses when the label fetch fails', async () => {
|
|
157
|
+
const forge = stubForge({ fetchLabels: () => ({ errors: [finding('forge-fetch')] }) })
|
|
158
|
+
const out = await withBody('body', (f) => editIssue({ args: edit(f) }, {}, forge))
|
|
159
|
+
expect(out.ok).toBe(false)
|
|
160
|
+
expect(forge.calls).toEqual([])
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
it('returns a failed gh write as a refusal carrying the raw error', async () => {
|
|
164
|
+
const boom = new Error('gh exploded')
|
|
165
|
+
const forge = stubForge({ ghWrite: () => ({ ok: false, errors: [finding('forge-write')], cause: boom }) })
|
|
166
|
+
const out = await withBody('body', (f) => editIssue({ args: edit(f) }, {}, forge))
|
|
167
|
+
expect(out.ok).toBe(false)
|
|
168
|
+
if (!out.ok) expect(out.forgeError).toBe(boom)
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
describe('printIssueSurface', () => {
|
|
173
|
+
it('refuses with exit code 2 when no body is given', () => {
|
|
174
|
+
const out = printIssueSurface([])
|
|
175
|
+
expect(out).toEqual({
|
|
176
|
+
ok: false,
|
|
177
|
+
exitCode: 2,
|
|
178
|
+
message: 'task_issue_surface: supply the draft Issue text in the `body` field.\n'
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
it('refuses with exit code 2 when the Surface does not parse', async () => {
|
|
183
|
+
const out = await withBody('no surface here', (f) => printIssueSurface(['--body-file', f]))
|
|
184
|
+
expect(out.ok).toBe(false)
|
|
185
|
+
if (!out.ok) expect(out.message).toContain('does not parse')
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
it('refuses a body file that cannot be read without ending the process', () => {
|
|
189
|
+
const out = printIssueSurface(['--body-file', '/nonexistent/planner-ops-body.md'])
|
|
190
|
+
expect(out).toMatchObject({ ok: false, exitCode: 2 })
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
describe('renderBrief', () => {
|
|
195
|
+
it('returns the missing facts as a refusal for a task that does not exist', async () => {
|
|
196
|
+
const assemble = (async (trancheSlug: string) => ({
|
|
197
|
+
ok: false,
|
|
198
|
+
missing: [`tranche ${trancheSlug} does not exist on the forge`]
|
|
199
|
+
})) as never
|
|
200
|
+
const out = await renderBrief({ trancheSlug: 'no-such-tranche-planner-ops', taskId: '1' }, assemble)
|
|
201
|
+
expect(out.ok).toBe(false)
|
|
202
|
+
if (!out.ok) expect(out.missing.length).toBeGreaterThan(0)
|
|
203
|
+
})
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
describe('editObjectives', () => {
|
|
207
|
+
it('returns an argument refusal as findings, never exiting', async () => {
|
|
208
|
+
const out = await editObjectives(['7'])
|
|
209
|
+
expect(out.ok).toBe(false)
|
|
210
|
+
if (!out.ok) expect(out.findings[0]?.check).toBe('forge-args')
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
it('refuses a missing --reason', async () => {
|
|
214
|
+
const out = await editObjectives(['7', '--add', 'Do a thing.'])
|
|
215
|
+
expect(out.ok).toBe(false)
|
|
216
|
+
if (!out.ok) expect(out.findings[0]?.message).toContain('--reason')
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
it('refuses --add without --part', async () => {
|
|
220
|
+
const out = await editObjectives(['7', '--add', 'Do a thing.', '--reason', 'because'])
|
|
221
|
+
expect(out.ok).toBe(false)
|
|
222
|
+
if (!out.ok) expect(out.findings[0]?.check).toBe('objectives-part-required')
|
|
223
|
+
})
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
describe('editObjectives with a stubbed forge', () => {
|
|
227
|
+
const issueBody = ['## Objectives', '', 'O1. First thing.', '', '## Parts', '', 'Part 1 (O1) — does it', ''].join(
|
|
228
|
+
'\n'
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
function stubDeps(
|
|
232
|
+
over: Partial<ObjectivesDeps> = {}
|
|
233
|
+
): ObjectivesDeps & { posted: string[]; forgeStub: ReturnType<typeof stubForge> } {
|
|
234
|
+
const posted: string[] = []
|
|
235
|
+
const forgeStub = stubForge()
|
|
236
|
+
const deps: ObjectivesDeps = {
|
|
237
|
+
forge: forgeStub,
|
|
238
|
+
requirePrincipal: () => {},
|
|
239
|
+
resolvePrincipals: () => ['someone'],
|
|
240
|
+
fetchIssue: () => ({ number: 7, body: issueBody, title: '[demo] 1 — A task', labels: [], comments: [] }),
|
|
241
|
+
supersede: (async () => ({ commentUrl: 'https://example.test/super' })) as never,
|
|
242
|
+
postComment: (_kind, _ref, marker) => {
|
|
243
|
+
posted.push(marker)
|
|
244
|
+
return 'https://example.test/comment'
|
|
245
|
+
},
|
|
246
|
+
...over
|
|
247
|
+
}
|
|
248
|
+
return Object.assign(deps, { posted, forgeStub })
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const addArgs = ['7', '--add', 'Second thing.', '--part', 'Part 2 (O2) — does more', '--reason', 'because']
|
|
252
|
+
|
|
253
|
+
it('passes: writes the Issue, posts the audit comment and returns the link', async () => {
|
|
254
|
+
const deps = stubDeps()
|
|
255
|
+
const out = await editObjectives(addArgs, {}, deps)
|
|
256
|
+
expect(out).toMatchObject({ ok: true, url: 'https://example.test/comment', supersedeUrl: null })
|
|
257
|
+
expect(deps.posted).toHaveLength(1)
|
|
258
|
+
expect(deps.forgeStub.calls.at(-1)).toContain('gh issue edit 7')
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
it('refuses when the Principal gate refuses, before reading the Issue', async () => {
|
|
262
|
+
let fetched = false
|
|
263
|
+
const deps = stubDeps({
|
|
264
|
+
requirePrincipal: () => refuse([finding('principal-only')]),
|
|
265
|
+
fetchIssue: () => {
|
|
266
|
+
fetched = true
|
|
267
|
+
throw new Error('unreachable')
|
|
268
|
+
}
|
|
269
|
+
})
|
|
270
|
+
const out = await editObjectives(addArgs, {}, deps)
|
|
271
|
+
expect(out.ok).toBe(false)
|
|
272
|
+
if (!out.ok) expect(out.findings[0]?.check).toBe('principal-only')
|
|
273
|
+
expect(fetched).toBe(false)
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
it('refuses with the label-fetch failure and posts nothing', async () => {
|
|
277
|
+
const deps = stubDeps({ forge: stubForge({ fetchLabels: () => ({ errors: [finding('forge-fetch')] }) }) })
|
|
278
|
+
const out = await editObjectives(addArgs, {}, deps)
|
|
279
|
+
expect(out.ok).toBe(false)
|
|
280
|
+
expect(deps.posted).toEqual([])
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
it('rethrows a failed gh write and posts no comment', async () => {
|
|
284
|
+
const boom = new Error('gh exploded')
|
|
285
|
+
const deps = stubDeps({
|
|
286
|
+
forge: stubForge({ ghWrite: () => ({ ok: false, errors: [finding('forge-write')], cause: boom }) })
|
|
287
|
+
})
|
|
288
|
+
await expect(editObjectives(addArgs, {}, deps)).rejects.toBe(boom)
|
|
289
|
+
expect(deps.posted).toEqual([])
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
it('returns a failed comment post as findings', async () => {
|
|
293
|
+
const deps = stubDeps({ postComment: () => refuse([finding('forge-comment')]) })
|
|
294
|
+
const out = await editObjectives(addArgs, {}, deps)
|
|
295
|
+
expect(out.ok).toBe(false)
|
|
296
|
+
if (!out.ok) expect(out.findings[0]?.check).toBe('forge-comment')
|
|
297
|
+
})
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
describe('refusal capture is fail-closed', () => {
|
|
301
|
+
it('turns a refusal deep in awaited work into findings, never a pass', async () => {
|
|
302
|
+
const r = await captureRefusal(async () => {
|
|
303
|
+
await Promise.resolve()
|
|
304
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
305
|
+
refuse([finding('deep')])
|
|
306
|
+
return 'continued'
|
|
307
|
+
})
|
|
308
|
+
expect(r.ok).toBe(false)
|
|
309
|
+
if (!r.ok) expect(r.errors[0]?.check).toBe('deep')
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
it('rethrows an unrelated error rather than reporting a refusal', async () => {
|
|
313
|
+
await expect(
|
|
314
|
+
captureRefusal(() => {
|
|
315
|
+
throw new Error('not a refusal')
|
|
316
|
+
})
|
|
317
|
+
).rejects.toThrow('not a refusal')
|
|
318
|
+
})
|
|
319
|
+
})
|
|
320
|
+
|
|
321
|
+
describe('printIssueSurface pass', () => {
|
|
322
|
+
it('returns the forced set and its rendering for a parseable Surface', async () => {
|
|
323
|
+
const body = '## Surface\n\nin: packages/ui/**\nout: —\n\n**Project:** vinaya\n'
|
|
324
|
+
const out = await withBody(body, (f) => printIssueSurface(['--body-file', f]))
|
|
325
|
+
expect(out.ok).toBe(true)
|
|
326
|
+
if (out.ok) {
|
|
327
|
+
expect(out.json).toBe(false)
|
|
328
|
+
expect(out.text.length).toBeGreaterThan(0)
|
|
329
|
+
}
|
|
330
|
+
const asJson = await withBody(body, (f) => printIssueSurface(['--body-file', f, '--json']))
|
|
331
|
+
expect(asJson.ok && asJson.json).toBe(true)
|
|
332
|
+
})
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
describe('renderBrief with a stubbed assembler', () => {
|
|
336
|
+
it('returns the rendered brief on a pass', async () => {
|
|
337
|
+
const out = await renderBrief({ trancheSlug: 't', taskId: '1' }, (async () => ({
|
|
338
|
+
ok: true,
|
|
339
|
+
brief: 'BRIEF'
|
|
340
|
+
})) as never)
|
|
341
|
+
expect(out).toEqual({ ok: true, brief: 'BRIEF' })
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
it('returns the missing facts as a refusal', async () => {
|
|
345
|
+
const out = await renderBrief({ trancheSlug: 't', taskId: '1' }, (async () => ({
|
|
346
|
+
ok: false,
|
|
347
|
+
missing: ['a', 'b']
|
|
348
|
+
})) as never)
|
|
349
|
+
expect(out).toEqual({ ok: false, missing: ['a', 'b'] })
|
|
350
|
+
})
|
|
351
|
+
|
|
352
|
+
it('lets an assembler failure (the forge) propagate', async () => {
|
|
353
|
+
await expect(
|
|
354
|
+
renderBrief({ trancheSlug: 't', taskId: '1' }, async () => {
|
|
355
|
+
throw new Error('forge down')
|
|
356
|
+
})
|
|
357
|
+
).rejects.toThrow('forge down')
|
|
358
|
+
})
|
|
359
|
+
})
|