rungate 0.8.0 → 0.8.2
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/gates/.gate-salt +1 -0
- package/gates/SCHEMA-GUIDE.md +485 -0
- package/gates/ac-quality.test.ts +106 -0
- package/gates/adversarial.test.ts +283 -0
- package/gates/brief-assembler.test.ts +487 -0
- package/gates/brief-assembler.ts +448 -0
- package/gates/bunfig.toml +2 -0
- package/gates/chain.test.ts +91 -0
- package/gates/e2e-smoke.test.ts +234 -0
- package/gates/error-classifier.test.ts +250 -0
- package/gates/error-classifier.ts +99 -0
- package/gates/gate-executor.ts +3071 -0
- package/gates/orchestrator.test.ts +968 -0
- package/gates/orchestrator.ts +827 -0
- package/gates/preload.ts +89 -0
- package/gates/prompts/ac-adversary.md +20 -0
- package/gates/prompts/evidence-validator.md +22 -0
- package/gates/prompts/prove-reproducer.md +53 -0
- package/gates/prompts.sha256 +3 -0
- package/gates/prove.test.ts +164 -0
- package/gates/rook-state.test.ts +108 -0
- package/gates/run-attribution.ts +290 -0
- package/gates/run-gate.ts +163 -0
- package/gates/schema-parity.test.ts +378 -0
- package/gates/schema.ts +1209 -0
- package/gates/self-heal.test.ts +511 -0
- package/gates/self-heal.ts +125 -0
- package/gates/ship-orchestrator.test.ts +399 -0
- package/gates/ship-orchestrator.ts +384 -0
- package/gates/spec-compliance-probe.ts +159 -0
- package/gates/test-fixtures/broken-no-environments.json +110 -0
- package/gates/test-fixtures/consumer-directory-layout.json +90 -0
- package/gates/test-fixtures/valid-standard.json +91 -0
- package/gates/test-utils.ts +43 -0
- package/gates/typecheck-gate.ts +111 -0
- package/gates/witness.ts +349 -0
- package/gates/workflow.test.ts +2018 -0
- package/hooks/BashWriteGuard.hook.ts +19 -0
- package/hooks/GateResultProtection.hook.ts +27 -1
- package/hooks/VerifyPhaseLock.hook.ts +51 -11
- package/hooks/WorkflowStateGuard.hook.ts +24 -0
- package/lib/ai-review-rounds.ts +462 -0
- package/lib/bash-file-read.ts +17 -3
- package/lib/bash-write-guard.ts +1285 -50
- package/lib/distribution-standing.ts +75 -4
- package/lib/failure-intake.ts +12 -4
- package/lib/file-extensions.ts +81 -0
- package/lib/finding-arbiter.ts +1015 -0
- package/lib/finding-jury.ts +537 -0
- package/lib/gate-enforcement.ts +171 -43
- package/lib/gate-result-protection.ts +12 -2
- package/lib/generators/code-map.ts +55 -4
- package/lib/generators/types.ts +27 -1
- package/lib/github.ts +55 -0
- package/lib/interpreters.ts +64 -0
- package/lib/issue-create-override.ts +69 -8
- package/lib/issue-filing-gate.ts +605 -0
- package/lib/js-top-level-code.ts +20 -2
- package/lib/junit-checks.ts +239 -1
- package/lib/package-closure.ts +114 -0
- package/lib/publish-window.ts +287 -0
- package/lib/scaffold/ai-review-findings.ts +142 -3
- package/lib/scaffold/ai-review-step.ts +1012 -18
- package/lib/scaffold/managed-workflow.ts +163 -4
- package/lib/scaffold/steps.ts +498 -22
- package/lib/scanner.ts +13 -4
- package/lib/ticked-sc-symbols.ts +361 -0
- package/lib/transcript-checker.ts +6 -0
- package/lib/workflow-actions.ts +18 -0
- package/package.json +3 -1
- package/scripts/arbitrate-finding.ts +224 -0
- package/scripts/generate-code-map.ts +18 -10
- package/scripts/sync-sc-status.ts +82 -8
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
import { existsSync, readFileSync, readdirSync, writeFileSync, statSync } from "fs";
|
|
12
12
|
import { join, basename } from "path";
|
|
13
13
|
import { localCalendarDay } from "../lib/local-calendar-day";
|
|
14
|
+
import { FRESHNESS_NOTICE, directoryTable } from "../lib/generators/code-map";
|
|
15
|
+
import { fileExtensions } from "../lib/file-extensions";
|
|
14
16
|
import {
|
|
15
17
|
fallowAvailable,
|
|
16
18
|
fallowUnmeasuredNotice,
|
|
@@ -114,7 +116,7 @@ function scanRoutes(): Route[] {
|
|
|
114
116
|
|
|
115
117
|
// ── Directory structure ──────────────────────────────────────
|
|
116
118
|
|
|
117
|
-
interface DirSummary { name: string;
|
|
119
|
+
interface DirSummary { name: string; types: string[] }
|
|
118
120
|
|
|
119
121
|
function scanDirectories(): DirSummary[] {
|
|
120
122
|
const dirs: DirSummary[] = [];
|
|
@@ -126,12 +128,17 @@ function scanDirectories(): DirSummary[] {
|
|
|
126
128
|
const full = join(projectPath, entry);
|
|
127
129
|
try {
|
|
128
130
|
if (!statSync(full).isDirectory()) continue;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
// One binding for what a "type" is, shared with `lib/scanner.ts` and
|
|
132
|
+
// `generateCodeMapInline` (#1200). The copy that used to be here
|
|
133
|
+
// reported directory names — this script produced the shipped
|
|
134
|
+
// `| evals/ | marcus-tdd-order, … |` row.
|
|
135
|
+
dirs.push({ name: entry, types: fileExtensions(full) });
|
|
132
136
|
} catch {}
|
|
133
137
|
}
|
|
134
|
-
|
|
138
|
+
// Unsorted. Row order is `directoryTable`'s single decision (#1163) —
|
|
139
|
+
// this used to sort by `fileCount`, which is how the census survived one
|
|
140
|
+
// indirection past being printed.
|
|
141
|
+
return dirs;
|
|
135
142
|
}
|
|
136
143
|
|
|
137
144
|
// ── Component scanning (React) ───────────────────────────────
|
|
@@ -257,7 +264,9 @@ generator: rungate/scripts/generate-code-map.ts
|
|
|
257
264
|
# Code Map — ${pkg.name}
|
|
258
265
|
|
|
259
266
|
Auto-generated architecture snapshot. Re-run \`bun generate-code-map.ts ${projectPath}\` to refresh.
|
|
260
|
-
Regenerate when src/ has commits since scanned-at-sha
|
|
267
|
+
Regenerate when src/ has commits since scanned-at-sha.
|
|
268
|
+
|
|
269
|
+
${FRESHNESS_NOTICE}`);
|
|
261
270
|
|
|
262
271
|
// Summary
|
|
263
272
|
sections.push(`## Summary
|
|
@@ -276,12 +285,11 @@ sections.push(`## Summary
|
|
|
276
285
|
| Module import mappings | ${consumerMappings.length} |
|
|
277
286
|
| Page-component mappings | ${pageMappings.length} |`);
|
|
278
287
|
|
|
279
|
-
// Directory structure
|
|
288
|
+
// Directory structure. No `Files` column, and the order is `directoryTable`'s
|
|
289
|
+
// rather than the scanner's — see `FRESHNESS_NOTICE` and #1163.
|
|
280
290
|
sections.push(`## Directory Structure
|
|
281
291
|
|
|
282
|
-
|
|
283
|
-
|-----------|-------|-------|
|
|
284
|
-
${dirs.map(d => `| ${d.name}/ | ${d.fileCount} | ${d.types.join(", ")} |`).join("\n")}`);
|
|
292
|
+
${directoryTable(dirs)}`);
|
|
285
293
|
|
|
286
294
|
// Routes
|
|
287
295
|
if (routes.length > 0) {
|
|
@@ -217,7 +217,33 @@ export interface ClaimSite {
|
|
|
217
217
|
form: ClaimForm | null;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
/**
|
|
221
|
+
* A source with no id in it cannot produce a site, so it is not scanned (#1223).
|
|
222
|
+
*
|
|
223
|
+
* Every `add()` below sits inside the `matchAll(scIdMentionPattern())` loop,
|
|
224
|
+
* so a source the pattern does not match returns `[]` — this is an EXACT
|
|
225
|
+
* early return, not a heuristic, and it uses the same pattern the loop does
|
|
226
|
+
* so the two cannot disagree about what an id is.
|
|
227
|
+
*
|
|
228
|
+
* The three full-source scans above the loop are the whole cost of this
|
|
229
|
+
* function and they are paid before anything looks for an id. MEASURED over
|
|
230
|
+
* `test/` on 2026-10-22: 567 files / 9.27 MiB, scan 698ms CPU, of which
|
|
231
|
+
* `stripJsComments` 193ms, `stripJsComments({blankLiterals})` 184ms and
|
|
232
|
+
* `commentMask` 352ms. **Half the tree has no SC id at all** — 286 files of
|
|
233
|
+
* 567 carry one — so the probe costs 1ms over the whole tree and removes
|
|
234
|
+
* 333ms: **48% cheaper per scan, with identical output.**
|
|
235
|
+
*
|
|
236
|
+
* `test/sc-scan-cost.test.ts` holds it to the identical-output half over
|
|
237
|
+
* every file in the tree, against a reference that does not short-circuit.
|
|
238
|
+
* Making the probe narrower than the loop's pattern turns that red.
|
|
239
|
+
*
|
|
240
|
+
* Deliberately NOT done here, and measured rather than argued: making
|
|
241
|
+
* `commentMask` lazy — computing it only when an id turns out to be in a
|
|
242
|
+
* comment. 254 of those 286 files have one, so it would fire 11% of the time
|
|
243
|
+
* and bought 405ms → 373ms (8%). Not worth a second code path.
|
|
244
|
+
*/
|
|
220
245
|
export function coverageClaimSites(source: string): ClaimSite[] {
|
|
246
|
+
if (!scIdMentionPattern().test(source)) return [];
|
|
221
247
|
const noComments = stripJsComments(source);
|
|
222
248
|
const codeOnly = stripJsComments(source, { blankLiterals: true });
|
|
223
249
|
const mask = commentMask(source);
|
|
@@ -331,9 +357,19 @@ export function findTestFilesForSCs(
|
|
|
331
357
|
const dir = testDir || TEST_DIR;
|
|
332
358
|
const out = new Map<string, ScCredit[]>();
|
|
333
359
|
if (!existsSync(dir)) return out;
|
|
334
|
-
//
|
|
335
|
-
//
|
|
336
|
-
|
|
360
|
+
// ONE parse of the tree, two readings of it (#1223). `intendedOnly(dir)`
|
|
361
|
+
// walked and parsed every file, and the credit loop below then walked and
|
|
362
|
+
// parsed every file again — the same deterministic scan, twice per call,
|
|
363
|
+
// and this function is called 17 times against the real tree across the
|
|
364
|
+
// suite. The scan is 97% parse and 3% read (23ms of 753ms over 567 files),
|
|
365
|
+
// so what has to be shared is the SITES; re-reading a source below for
|
|
366
|
+
// `isQualifiedBy` costs nothing.
|
|
367
|
+
//
|
|
368
|
+
// Tree-wide, and settled before any credit is awarded: whether a criterion
|
|
369
|
+
// has a running test anywhere is not a question a single file can answer
|
|
370
|
+
// (#810).
|
|
371
|
+
const scan = scanTestTree(dir);
|
|
372
|
+
const intended = new Set(intendedFrom(scan).keys());
|
|
337
373
|
|
|
338
374
|
const wanted = new Map<string, string[]>();
|
|
339
375
|
for (const sc of scs) {
|
|
@@ -342,10 +378,11 @@ export function findTestFilesForSCs(
|
|
|
342
378
|
wanted.set(sc.id, specs);
|
|
343
379
|
}
|
|
344
380
|
|
|
345
|
-
for (const file of
|
|
381
|
+
for (const { file, sites } of scan) {
|
|
382
|
+
if (sites.length === 0) continue;
|
|
346
383
|
const source = readFileSync(join(dir, file), "utf-8");
|
|
347
384
|
const credits: ScCredit[] = [];
|
|
348
|
-
for (const { id, at, kind, form } of
|
|
385
|
+
for (const { id, at, kind, form } of sites) {
|
|
349
386
|
// #360. A comment earns a credit only in a structural declaring form.
|
|
350
387
|
// The position was never the question — a comment is equally where this
|
|
351
388
|
// project declares coverage and where it explains itself, and a bare id
|
|
@@ -417,12 +454,49 @@ export function findTestFilesForSCs(
|
|
|
417
454
|
* `measured` is what gives that case something to see.
|
|
418
455
|
*/
|
|
419
456
|
export function intendedOnly(testDir: string): Map<string, string[]> {
|
|
457
|
+
if (!existsSync(testDir)) return new Map();
|
|
458
|
+
return intendedFrom(scanTestTree(testDir));
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/** One file of the test tree, with its claim sites already parsed. */
|
|
462
|
+
export interface ScannedTestFile {
|
|
463
|
+
/** Path relative to the scanned directory, as `walkTestFiles` reports it. */
|
|
464
|
+
file: string;
|
|
465
|
+
sites: ClaimSite[];
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* The test tree, walked once and parsed once (#1223).
|
|
470
|
+
*
|
|
471
|
+
* The one place a tree-wide claim scan happens, so a caller that wants two
|
|
472
|
+
* readings of it pays for one. Both readings this file needs — the intended
|
|
473
|
+
* set and the credit map — were separately re-deriving it, which doubled the
|
|
474
|
+
* cost of every `findTestFilesForSCs` call. See that function.
|
|
475
|
+
*
|
|
476
|
+
* Not memoised, deliberately. A cache would have to decide when the tree has
|
|
477
|
+
* changed, and the callers that pass a scratch directory write into it
|
|
478
|
+
* between calls — that is the fail-open shape in
|
|
479
|
+
* `.claude/rules/checks-must-be-able-to-fail.md`, where a stale reading and a
|
|
480
|
+
* correct one are the same green. Sharing a reading is the CALLER's decision,
|
|
481
|
+
* because only the caller knows its inputs have not moved;
|
|
482
|
+
* `test/sc-id-namespace.test.ts` does exactly that for the two cases that ask
|
|
483
|
+
* the identical whole-registry question.
|
|
484
|
+
*/
|
|
485
|
+
export function scanTestTree(testDir: string): ScannedTestFile[] {
|
|
486
|
+
if (!existsSync(testDir)) return [];
|
|
487
|
+
return walkTestFiles(testDir).map(file => ({
|
|
488
|
+
file,
|
|
489
|
+
sites: coverageClaimSites(readFileSync(join(testDir, file), "utf-8")),
|
|
490
|
+
}));
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/** `intendedOnly`'s reading, over a scan somebody else already paid for. */
|
|
494
|
+
export function intendedFrom(scan: readonly ScannedTestFile[]): Map<string, string[]> {
|
|
420
495
|
const out = new Map<string, string[]>();
|
|
421
|
-
if (!existsSync(testDir)) return out;
|
|
422
496
|
const measured = new Set<string>();
|
|
423
497
|
const intended = new Map<string, string[]>();
|
|
424
|
-
for (const file of
|
|
425
|
-
for (const site of
|
|
498
|
+
for (const { file, sites } of scan) {
|
|
499
|
+
for (const site of sites) {
|
|
426
500
|
if (site.kind === "unrun-title") {
|
|
427
501
|
const files = intended.get(site.id) ?? [];
|
|
428
502
|
if (!files.includes(file)) files.push(file);
|