@attalabs/vinaya 0.44.1 → 0.47.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/README.md +6 -4
- package/dist/checks/bin/check-body-bare-digits.js +233 -195
- package/dist/checks/bin/check-branch-topology.js +70 -23
- package/dist/checks/bin/check-brief-shape.js +233 -195
- package/dist/checks/bin/check-changeset-coverage.js +94 -16
- package/dist/checks/bin/check-ci-shard-coverage.js +3 -0
- package/dist/checks/bin/check-closes-n.js +128 -34
- package/dist/checks/bin/check-coherence.js +336 -245
- package/dist/checks/bin/check-dispatch-readiness.js +3623 -463
- package/dist/checks/bin/check-doc-claims.js +233 -195
- package/dist/checks/bin/check-doc-coverage-push.js +243 -196
- package/dist/checks/bin/check-doc-coverage.js +243 -196
- package/dist/checks/bin/check-doctrine-no-procedures.js +233 -195
- package/dist/checks/bin/check-doctrine-portability.js +233 -195
- package/dist/checks/bin/check-evidence-fresh.js +9983 -1995
- package/dist/checks/bin/check-exec-bits.js +3 -0
- package/dist/checks/bin/check-first-push-dispatch.js +301 -224
- package/dist/checks/bin/check-issue-milestone-attach.js +65 -10
- package/dist/checks/bin/check-issue-objectives-numbering.js +233 -195
- package/dist/checks/bin/check-issue-parts-coverage.js +65 -10
- package/dist/checks/bin/check-issue-surface-globs.js +1032 -236
- package/dist/checks/bin/check-issue-title-grammar.js +5 -1
- package/dist/checks/bin/check-no-disk-state.js +5 -1
- package/dist/checks/bin/check-pr-premise-reassert.js +10 -1
- package/dist/checks/bin/check-pr-report-density.js +5 -1
- package/dist/checks/bin/check-principal-test-plan-wait.js +253 -201
- package/dist/checks/bin/check-quoted-command.js +233 -195
- package/dist/checks/bin/check-reader-resolvable-prose.js +233 -195
- package/dist/checks/bin/check-registry-gates.js +131 -34
- package/dist/checks/bin/check-retired-vocabulary.js +233 -195
- package/dist/checks/bin/check-review-gate.js +233 -195
- package/dist/checks/bin/check-single-plan-pr.js +5 -1
- package/dist/checks/bin/check-surface-scope.js +107 -32
- package/dist/checks/bin/check-test-plan.js +253 -201
- package/dist/checks/bin/check-token-collection-wired.js +3 -0
- package/dist/checks/bin/check-workspace-escape.js +3 -0
- package/dist/checks/bin/verify-coherence.js +237 -148
- package/dist/checks/bin/verify-dispatch.js +870 -66
- package/dist/checks/bin/verify-docs.js +13 -6
- package/dist/harness.js +57 -10
- package/dist/index.js +16617 -7187
- package/dist/lib/pre-push-cache-test-run.js +4487 -2170
- package/dist/lib/pre-push-changed-files.js +251 -12
- package/dist/lib/pre-push-mode.js +69 -19
- package/dist/lib/pre-push-progress-dir.js +10265 -2853
- package/dist/lib/pre-push-record-tests.js +67 -19
- package/dist/lib/pre-push-select-tests.js +520 -222
- package/dist/lib/push-progress-observer.js +9176 -1757
- package/dist/process.js +2 -0
- package/dist/programs/archive.js +8948 -1547
- package/dist/programs/audit.js +9176 -1772
- package/dist/programs/check.js +9248 -1845
- package/dist/programs/commit-msg.js +8984 -1583
- package/dist/programs/dev-review-loop.js +15612 -7634
- package/dist/programs/dispatch.js +9977 -2726
- package/dist/programs/log-emit.js +9011 -1660
- package/dist/programs/log-selftest.js +8908 -1507
- package/dist/programs/log-send.js +9081 -1594
- package/dist/programs/pr-report.js +9476 -1820
- package/dist/programs/pr-snapshot.js +8916 -1515
- package/dist/programs/pr-verify-evidence.js +9481 -1825
- package/dist/programs/pr.js +11709 -4033
- package/dist/programs/review-post.js +11140 -3496
- package/dist/programs/review-status.js +8996 -1533
- package/dist/programs/run-engine.js +22031 -18759
- package/dist/programs/sync.js +9030 -1629
- package/dist/programs/task-brief.js +10185 -1821
- package/dist/programs/task-sweep.js +9266 -1621
- package/dist/programs/task-tools-serve.js +77118 -16678
- package/dist/programs/tokens.js +8966 -1565
- package/dist/programs/waiver.js +8983 -1582
- package/dist/types/harness/kernel/dev-process-socket/loader/load-process.d.ts +1 -1
- package/dist/types/harness/processes/vinaya-strict/tools/legacy-markers.d.ts +8 -0
- package/dist/types/harness/processes/vinaya-strict/tools/task-contract/brief-validation.d.ts +3 -3
- package/dist/types/harness/processes/vinaya-strict/tools/task-contract/objectives.d.ts +5 -6
- package/dist/vinaya-strict/checks/registry.ts +2 -2
- package/dist/vinaya-strict/executing/developer/developer-doctrine-shape.test.ts +8 -0
- package/dist/vinaya-strict/executing/developer/developer-turn-result.ts +1 -1
- package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.test.ts +2 -2
- package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.ts +30 -20
- package/dist/vinaya-strict/executing/developer/reference.md +5 -3
- package/dist/vinaya-strict/integration/config/vinaya-config-section.ts +29 -7
- package/dist/vinaya-strict/integration/policies/vinaya-policies.ts +4 -4
- package/dist/vinaya-strict/integration/process/process-integration.ts +5 -1
- package/dist/vinaya-strict/process.yaml +6 -1
- package/dist/vinaya-strict/thinking/plan-reviewer/doctrine.md +68 -0
- package/dist/vinaya-strict/thinking/plan-reviewer/grants.yaml +19 -0
- package/dist/vinaya-strict/thinking/plan-reviewer/output.schema.json +388 -0
- package/dist/vinaya-strict/thinking/planner/doctrine.md +4 -1
- package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.test.ts +10 -2
- package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.ts +5 -1
- package/dist/vinaya-strict/thinking/planner/tools/open-issue.test.ts +198 -34
- package/dist/vinaya-strict/thinking/planner/tools/open-issue.ts +120 -193
- package/dist/vinaya-strict/thinking/planner/tools/planner-operations.test.ts +629 -15
- package/dist/vinaya-strict/thinking/planner/tools/planner-operations.ts +726 -62
- package/dist/vinaya-strict/thinking/planner/tools/planner-tools.test.ts +505 -5
- package/dist/vinaya-strict/thinking/planner/tools/planner-tools.ts +636 -21
- package/package.json +3 -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/prerender-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- 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/app/_not-found/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/app/milestones/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/app/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/app/tasks/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/server/chunks/209.js +2 -2
- package/studio-standalone/apps/vinaya-studio/.next/server/chunks/951.js +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/server/preview-props.json +3 -3
- package/studio-standalone/apps/vinaya-studio/.next/server/server-reference-manifest.json +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/static/chunks/151-c365f0ef8268ad13.js +1 -0
- package/studio-standalone/apps/vinaya-studio/.next/static/chunks/19-aa314f13784dcc58.js +4 -0
- package/studio-standalone/apps/vinaya-studio/.next/static/chunks/app/{layout-dfa2186095e797bd.js → layout-f038e8deecb2bf5f.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/static/chunks/app/milestones/{page-2fffb49104860a15.js → page-12314f4deb06a414.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/static/chunks/app/{page-6ae258f663623b2a.js → page-7a06aa3cdd046fa8.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/static/chunks/app/tasks/{page-2fffb49104860a15.js → page-12314f4deb06a414.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/.next/static/css/8eb5ed5b65b9692e.css +1 -0
- package/studio-standalone/apps/vinaya-studio/log-follow.mjs +708 -93
- package/studio-standalone/apps/vinaya-studio/log-sync-folder-source.mjs +699 -84
- package/studio-standalone/apps/vinaya-studio/studio-server.mjs +4692 -3116
- package/vinaya-strict/artifacts/templates/brief-template.md +4 -0
- package/vinaya-strict/artifacts/templates/issue-rationale-template.md +7 -3
- package/vinaya-strict/artifacts/templates/pr-report-template.md +1 -1
- package/vinaya-strict/doctrine/contracts/planner-developer.md +2 -1
- package/vinaya-strict/doctrine/enforcement.md +4 -4
- package/vinaya-strict/doctrine/roles/principal.md +1 -1
- package/vinaya-strict/doctrine/state-machine.md +7 -2
- package/vinaya-strict/executing/developer/reference.md +5 -3
- package/vinaya-strict/thinking/plan-reviewer/doctrine.md +68 -0
- package/vinaya-strict/thinking/planner/doctrine.md +4 -1
- package/vinaya-strict/thinking/planner/reference.md +29 -8
- package/studio-standalone/apps/vinaya-studio/.next/static/chunks/151-23bea4cac9687151.js +0 -1
- package/studio-standalone/apps/vinaya-studio/.next/static/chunks/853-1d5548ff3a55a75f.js +0 -4
- package/studio-standalone/apps/vinaya-studio/.next/static/css/fb16828fc3128d4c.css +0 -1
- /package/studio-standalone/apps/vinaya-studio/.next/static/{3URbt6IPajL5OOhijN1-x → bJrgAp9Kl4JsCUYkeAYez}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/.next/static/{3URbt6IPajL5OOhijN1-x → bJrgAp9Kl4JsCUYkeAYez}/_ssgManifest.js +0 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawnSync } from 'node:child_process'
|
|
2
|
+
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, unlinkSync, writeFileSync } from 'node:fs'
|
|
2
3
|
import { tmpdir } from 'node:os'
|
|
3
4
|
import { join } from 'node:path'
|
|
4
|
-
import { describe, expect, it, vi } from 'vitest'
|
|
5
|
+
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'
|
|
5
6
|
import {
|
|
6
7
|
type AmendDepsDeps,
|
|
7
8
|
type AmendDepsFlags,
|
|
8
9
|
appliesTaskIssueGate,
|
|
9
|
-
|
|
10
|
+
createRefusalReason,
|
|
10
11
|
edgesEqual,
|
|
12
|
+
formatFinding,
|
|
11
13
|
formatLeftoverPrint,
|
|
12
14
|
type LeftoverFacts,
|
|
13
15
|
locateBody,
|
|
@@ -22,7 +24,9 @@ import {
|
|
|
22
24
|
taskIdFromTitle,
|
|
23
25
|
validateAmendFlags
|
|
24
26
|
} from './open-issue'
|
|
25
|
-
import {
|
|
27
|
+
import { makeCheckError } from '@harness/workflow/tools/task-contract/forge/forge-write'
|
|
28
|
+
import type { CheckError } from '@harness/kernel/gates/checks/contract'
|
|
29
|
+
import { createIssue, editIssue } from './planner-operations'
|
|
26
30
|
|
|
27
31
|
describe('appliesTaskIssueGate (task-run-v1 21, #541, round 2 review SECURITY HIGH)', () => {
|
|
28
32
|
it('applies on a vinaya/tranche:* label alone, even with a body carrying no task-shaped content', () => {
|
|
@@ -209,6 +213,17 @@ describe('regular-file body-file input is unaffected by the fix', () => {
|
|
|
209
213
|
})
|
|
210
214
|
})
|
|
211
215
|
|
|
216
|
+
describe('createRefusalReason', () => {
|
|
217
|
+
it('refuses a create that carries a tranche label, naming plan_publish', () => {
|
|
218
|
+
expect(createRefusalReason(['vinaya/tranche:demo'], false)).toContain('plan_publish')
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
it('lets a labelless create and any edit go on', () => {
|
|
222
|
+
expect(createRefusalReason(['vinaya/tier:1'], false)).toBeNull()
|
|
223
|
+
expect(createRefusalReason(['vinaya/tranche:demo'], true)).toBeNull()
|
|
224
|
+
})
|
|
225
|
+
})
|
|
226
|
+
|
|
212
227
|
describe('resolveMilestoneToAttach (sample-tranche-v1 task 1 follow-up)', () => {
|
|
213
228
|
const activeLookup = vi.fn((slug: string) =>
|
|
214
229
|
slug === 'sample-tranche-v1' ? { number: 9, title: 'sample-tranche-v1' } : null
|
|
@@ -484,47 +499,88 @@ function makeDeps(overrides: Partial<AmendDepsDeps> = {}): {
|
|
|
484
499
|
fail: (m) => {
|
|
485
500
|
throw new Error(m)
|
|
486
501
|
},
|
|
502
|
+
// The validation itself is proved against the real one below; these cases are about the amendment's own steps.
|
|
503
|
+
validate: async () => ({ errors: [], blocking: false, renderSkipped: null }),
|
|
487
504
|
...overrides
|
|
488
505
|
}
|
|
489
506
|
return { deps, edited, logs }
|
|
490
507
|
}
|
|
491
508
|
|
|
492
509
|
describe('runAmendDeps', () => {
|
|
493
|
-
it('refuses when the target is not a task Issue (no vinaya/tranche:* label)', () => {
|
|
510
|
+
it('refuses when the target is not a task Issue (no vinaya/tranche:* label)', async () => {
|
|
494
511
|
const { deps, edited } = makeDeps({ fetchLabels: () => ['vinaya/tier:1'] })
|
|
495
|
-
expect(
|
|
512
|
+
await expect(runAmendDeps(parseAmendArgs(['429', '--depends-on', '2', '--note', 'x']), deps)).rejects.toThrow(
|
|
496
513
|
/targets task Issues only/
|
|
497
514
|
)
|
|
498
515
|
expect(edited).toHaveLength(0)
|
|
499
516
|
})
|
|
500
517
|
|
|
501
|
-
it('refuses a missing --note (flag validation) with no forge write', () => {
|
|
518
|
+
it('refuses a missing --note (flag validation) with no forge write', async () => {
|
|
502
519
|
const { deps, edited } = makeDeps()
|
|
503
|
-
expect(
|
|
520
|
+
await expect(runAmendDeps(parseAmendArgs(['429', '--depends-on', '2']), deps)).rejects.toThrow(/non-empty `--note`/)
|
|
504
521
|
expect(edited).toHaveLength(0)
|
|
505
522
|
})
|
|
506
523
|
|
|
507
|
-
it('refuses on a round-trip mismatch and writes nothing (the gate, on real data)', () => {
|
|
524
|
+
it('refuses on a round-trip mismatch and writes nothing (the gate, on real data)', async () => {
|
|
508
525
|
// `sample-tranche-v1 #368, 5` — the bare `5` inherits the qualifier
|
|
509
526
|
// on parse (→ `sample-tranche-v1 5`), so the read-back != requested.
|
|
510
527
|
const { deps, edited } = makeDeps()
|
|
511
|
-
expect(
|
|
528
|
+
await expect(
|
|
512
529
|
runAmendDeps(parseAmendArgs(['429', '--depends-on', 'sample-tranche-v1 #368, 5', '--note', 'x']), deps)
|
|
513
|
-
).toThrow(/round-trip FAILED for Depends-on/)
|
|
530
|
+
).rejects.toThrow(/round-trip FAILED for Depends-on/)
|
|
531
|
+
expect(edited).toHaveLength(0)
|
|
532
|
+
})
|
|
533
|
+
|
|
534
|
+
it('writes nothing, and prints the finding with its check name, when the validation reports a blocking finding', async () => {
|
|
535
|
+
const blocking = makeCheckError('issue-pinned-importers', 'an importer of a pinned file is undecided', 'Decide it.')
|
|
536
|
+
const { deps, edited, logs } = makeDeps({
|
|
537
|
+
validate: async () => ({ errors: [blocking], blocking: true, renderSkipped: null })
|
|
538
|
+
})
|
|
539
|
+
await expect(
|
|
540
|
+
runAmendDeps(parseAmendArgs(['429', '--depends-on', '2, 3', '--note', 'Task 3 dropped.']), deps)
|
|
541
|
+
).rejects.toThrow(/Nothing written/)
|
|
514
542
|
expect(edited).toHaveLength(0)
|
|
543
|
+
expect(logs.some((l) => l.includes('[issue-pinned-importers]'))).toBe(true)
|
|
544
|
+
})
|
|
545
|
+
|
|
546
|
+
it('writes nothing on a blocking finding in a dry run either', async () => {
|
|
547
|
+
const blocking = makeCheckError('issue-pinned-importers', 'an importer of a pinned file is undecided', 'Decide it.')
|
|
548
|
+
const { deps, logs } = makeDeps({
|
|
549
|
+
validate: async () => ({ errors: [blocking], blocking: true, renderSkipped: null })
|
|
550
|
+
})
|
|
551
|
+
await expect(
|
|
552
|
+
runAmendDeps(parseAmendArgs(['429', '--depends-on', '2', '--note', 'x', '--dry-run']), deps)
|
|
553
|
+
).rejects.toThrow(/Nothing written/)
|
|
554
|
+
expect(logs).not.toContain('round-trip PASS')
|
|
555
|
+
})
|
|
556
|
+
|
|
557
|
+
it('writes the amended body only when the validation, given that body and the Issue, reports no blocking finding', async () => {
|
|
558
|
+
const seen: Array<{ body: string | null; labels: string[]; number: number | null }> = []
|
|
559
|
+
const { deps, edited } = makeDeps({
|
|
560
|
+
validate: async (body, _title, labels, _retry, number) => {
|
|
561
|
+
seen.push({ body, labels, number })
|
|
562
|
+
return { errors: [], blocking: false, renderSkipped: null }
|
|
563
|
+
}
|
|
564
|
+
})
|
|
565
|
+
await runAmendDeps(parseAmendArgs(['429', '--depends-on', '2, 3', '--note', 'Task 3 dropped.']), deps)
|
|
566
|
+
expect(edited).toHaveLength(1)
|
|
567
|
+
expect(seen).toHaveLength(1)
|
|
568
|
+
expect(seen[0]?.body).toBe(edited[0]?.body)
|
|
569
|
+
expect(seen[0]?.number).toBe(429)
|
|
570
|
+
expect(seen[0]?.labels).toContain('vinaya/tranche:other-tranche-v1')
|
|
515
571
|
})
|
|
516
572
|
|
|
517
|
-
it('dry-run prints the body + round-trip PASS and performs NO forge write', () => {
|
|
573
|
+
it('dry-run prints the body + round-trip PASS and performs NO forge write', async () => {
|
|
518
574
|
const { deps, edited, logs } = makeDeps()
|
|
519
|
-
runAmendDeps(parseAmendArgs(['429', '--depends-on', '2, 3', '--note', 'Task 3 dropped.', '--dry-run']), deps)
|
|
575
|
+
await runAmendDeps(parseAmendArgs(['429', '--depends-on', '2, 3', '--note', 'Task 3 dropped.', '--dry-run']), deps)
|
|
520
576
|
expect(edited).toHaveLength(0)
|
|
521
577
|
expect(logs).toContain('round-trip PASS')
|
|
522
578
|
expect(logs.some((l) => l.includes('`Depends-on: 2, 3`'))).toBe(true)
|
|
523
579
|
})
|
|
524
580
|
|
|
525
|
-
it('a real run ships the amended body once and logs the edge change', () => {
|
|
581
|
+
it('a real run ships the amended body once and logs the edge change', async () => {
|
|
526
582
|
const { deps, edited, logs } = makeDeps()
|
|
527
|
-
runAmendDeps(parseAmendArgs(['429', '--depends-on', '2, 3', '--note', 'Task 3 dropped.']), deps)
|
|
583
|
+
await runAmendDeps(parseAmendArgs(['429', '--depends-on', '2, 3', '--note', 'Task 3 dropped.']), deps)
|
|
528
584
|
expect(edited).toHaveLength(1)
|
|
529
585
|
expect(edited[0]?.issue).toBe('429')
|
|
530
586
|
expect(edited[0]?.body).toContain('**Amendment (2026-07-13, Planner)')
|
|
@@ -676,26 +732,134 @@ describe('readSharedPackages', () => {
|
|
|
676
732
|
})
|
|
677
733
|
})
|
|
678
734
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
735
|
+
// The script against the Planner tools, on one body: the real validation, behind a fake GitHub command line
|
|
736
|
+
// first on the path, so nothing reaches the forge and no rule is stubbed.
|
|
737
|
+
describe('the script decides through the validation the Planner tools call', () => {
|
|
738
|
+
const SCRIPT = join(__dirname, 'open-issue.ts')
|
|
739
|
+
const LABEL = 'vinaya/tranche:fixture-v1'
|
|
740
|
+
const TITLE = '[fixture-v1] 1 — Fix(planner): a fixture task'
|
|
741
|
+
// An importer of a pinned file the Surface neither reaches nor excludes: `open-issue.ts` imports `amend-rationale-deps.ts`.
|
|
742
|
+
const PINNED = 'harness/processes/vinaya-strict/thinking/planner/tools/amend-rationale-deps.ts'
|
|
743
|
+
const BODY = [
|
|
744
|
+
'**Project:** vinaya',
|
|
745
|
+
'',
|
|
746
|
+
'## Objectives',
|
|
747
|
+
'',
|
|
748
|
+
'O1. The fixture decides through the one validation.',
|
|
749
|
+
'',
|
|
750
|
+
'## Surface',
|
|
751
|
+
'',
|
|
752
|
+
'in: harness/processes/vinaya-strict/tests',
|
|
753
|
+
'out: —',
|
|
754
|
+
'',
|
|
755
|
+
'## Parts',
|
|
756
|
+
'',
|
|
757
|
+
'Part 1 (O1) — the only part.',
|
|
758
|
+
'',
|
|
759
|
+
`**Boundary** — Pinned files: \`${PINNED}\`. Out: other work.`
|
|
760
|
+
].join('\n')
|
|
761
|
+
|
|
762
|
+
let dir = ''
|
|
763
|
+
let bodyFile = ''
|
|
764
|
+
let savedPath: string | undefined
|
|
765
|
+
let savedRepo: string | undefined
|
|
766
|
+
let savedCwd = ''
|
|
767
|
+
|
|
768
|
+
beforeAll(() => {
|
|
769
|
+
dir = mkdtempSync(join(tmpdir(), 'open-issue-gate-'))
|
|
770
|
+
bodyFile = join(dir, 'body.md')
|
|
771
|
+
writeFileSync(bodyFile, BODY, 'utf8')
|
|
772
|
+
mkdirSync(join(dir, 'bin'))
|
|
773
|
+
writeFileSync(
|
|
774
|
+
join(dir, 'bin', 'gh'),
|
|
775
|
+
[
|
|
776
|
+
'#!/bin/sh',
|
|
777
|
+
`if [ "$1" = "issue" ] && [ "$2" = "view" ]; then echo '{"number":2218,"title":"${TITLE}","body":"","labels":[{"name":"${LABEL}"}]}'; exit 0; fi`,
|
|
778
|
+
`if [ "$2" = "list" ]; then echo '[]'; exit 0; fi`,
|
|
779
|
+
// The Principal read of the default branch's configuration, and an Issue with no comments.
|
|
780
|
+
`if [ "$1" = "api" ] && [ "\${2#*contents/vinaya.config.json}" != "$2" ]; then echo '${Buffer.from(JSON.stringify({ principals: ['fixture-principal'] })).toString('base64')}'; exit 0; fi`,
|
|
781
|
+
`if [ "$1" = "api" ] && [ "\${2#*/comments}" != "$2" ]; then echo '[]'; exit 0; fi`,
|
|
782
|
+
'exit 1',
|
|
783
|
+
''
|
|
784
|
+
].join('\n')
|
|
694
785
|
)
|
|
786
|
+
chmodSync(join(dir, 'bin', 'gh'), 0o755)
|
|
787
|
+
savedPath = process.env.PATH
|
|
788
|
+
savedRepo = process.env.VINAYA_REPO
|
|
789
|
+
// The script works from the repository root; the in-process side must resolve tracked files from the same root, whatever directory the test runs from.
|
|
790
|
+
savedCwd = process.cwd()
|
|
791
|
+
process.chdir(join(__dirname, '../../../../../..'))
|
|
792
|
+
process.env.PATH = `${join(dir, 'bin')}:${process.env.PATH ?? ''}`
|
|
793
|
+
process.env.VINAYA_REPO = 'test-owner/test-repo'
|
|
794
|
+
})
|
|
795
|
+
|
|
796
|
+
afterAll(() => {
|
|
797
|
+
process.env.PATH = savedPath
|
|
798
|
+
process.chdir(savedCwd)
|
|
799
|
+
if (savedRepo === undefined) delete process.env.VINAYA_REPO
|
|
800
|
+
else process.env.VINAYA_REPO = savedRepo
|
|
801
|
+
rmSync(dir, { recursive: true, force: true })
|
|
695
802
|
})
|
|
696
803
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
804
|
+
/** Runs the script as a program and returns its exit code and the finding lines it printed. */
|
|
805
|
+
function runScript(args: string[]): { status: number | null; findings: string[]; stderr: string } {
|
|
806
|
+
const r = spawnSync(process.execPath, [SCRIPT, ...args], {
|
|
807
|
+
encoding: 'utf8',
|
|
808
|
+
env: process.env,
|
|
809
|
+
timeout: 240_000
|
|
810
|
+
})
|
|
811
|
+
const findings = r.stderr.split('\n').filter((l) => /^ {2}[✗!] \[/.test(l))
|
|
812
|
+
return { status: r.status, findings, stderr: r.stderr }
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
const findingsOf = (outcome: Awaited<ReturnType<typeof createIssue>>): CheckError[] => {
|
|
816
|
+
if (outcome.ok) throw new Error('the Planner tools accepted the body')
|
|
817
|
+
return outcome.findings
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
const printed = (findings: CheckError[]): string[] => findings.map((e) => formatFinding(e))
|
|
821
|
+
|
|
822
|
+
it('refuses an undecided importer on validate-only, naming the check, with the findings the Planner tools return', async () => {
|
|
823
|
+
const tools = await createIssue({
|
|
824
|
+
ghArgs: ['--title', TITLE, '--body-file', bodyFile, '--label', LABEL],
|
|
825
|
+
validateOnly: true
|
|
826
|
+
})
|
|
827
|
+
expect(tools.ok).toBe(false)
|
|
828
|
+
const expected = printed(findingsOf(tools))
|
|
829
|
+
const importer = expected.find((l) => l.includes('Surface/importers'))
|
|
830
|
+
expect(importer).toBeDefined()
|
|
831
|
+
|
|
832
|
+
const script = runScript(['--validate-only', '--title', TITLE, '--body-file', bodyFile, '--label', LABEL])
|
|
833
|
+
expect(script.status).toBe(1)
|
|
834
|
+
expect(script.findings).toEqual(expected)
|
|
835
|
+
expect(script.stderr).toContain(importer as string)
|
|
836
|
+
expect(script.stderr).toMatch(/\[[a-z0-9-]+\] issue-validation Surface\/importers/)
|
|
837
|
+
}, 300_000)
|
|
838
|
+
|
|
839
|
+
it('refuses the same body on create with the same findings, and sends nothing to the forge', async () => {
|
|
840
|
+
const tools = await createIssue({
|
|
841
|
+
ghArgs: ['--title', TITLE, '--body-file', bodyFile, '--label', LABEL],
|
|
842
|
+
validateOnly: true
|
|
843
|
+
})
|
|
844
|
+
const script = runScript(['--title', TITLE, '--body-file', bodyFile, '--label', LABEL])
|
|
845
|
+
expect(script.status).toBe(1)
|
|
846
|
+
expect(script.findings).toEqual(printed(findingsOf(tools)))
|
|
847
|
+
expect(script.stderr).toContain('Nothing was sent to the forge')
|
|
848
|
+
}, 300_000)
|
|
849
|
+
|
|
850
|
+
it('refuses the same body on edit with the findings the Planner edit returns', async () => {
|
|
851
|
+
const tools = await editIssue({ args: ['2218', '--body-file', bodyFile], validateOnly: true })
|
|
852
|
+
expect(tools.ok).toBe(false)
|
|
853
|
+
const script = runScript(['edit', '2218', '--body-file', bodyFile])
|
|
854
|
+
expect(script.status).toBe(1)
|
|
855
|
+
expect(script.findings).toEqual(printed(findingsOf(tools)))
|
|
856
|
+
}, 300_000)
|
|
857
|
+
|
|
858
|
+
it('runs the validation once the Log sink factory is installed: the program stops on no missing-factory error', () => {
|
|
859
|
+
const script = runScript(['--validate-only', '--title', TITLE, '--body-file', bodyFile, '--label', LABEL])
|
|
860
|
+
// The program ran the validation to its findings and refused on them, rather than dying on a missing factory.
|
|
861
|
+
expect(script.status).toBe(1)
|
|
862
|
+
expect(script.findings.length).toBeGreaterThan(0)
|
|
863
|
+
expect(script.stderr).not.toMatch(/sink factory/i)
|
|
864
|
+
}, 300_000)
|
|
701
865
|
})
|