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
|
@@ -265,7 +265,137 @@ function revokedSubKeys(
|
|
|
265
265
|
const emitted = new Set(parseSubKeys(generated.lines).blocks.map(s => s.key));
|
|
266
266
|
return parseSubKeys(before.lines)
|
|
267
267
|
.blocks.filter(s => owned.has(s.key) && !emitted.has(s.key))
|
|
268
|
-
.map(s => ({ section, key: s.key, lines: s.lines }));
|
|
268
|
+
.map(s => ({ section, key: s.key, lines: s.lines, reason: "computed" as const }));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* The sub-key PATHS the generators author outright, dotted (#1148).
|
|
273
|
+
*
|
|
274
|
+
* ## The gap this closes
|
|
275
|
+
*
|
|
276
|
+
* `mergeTopLevelSection` is additive: a sub-key both sides declare keeps the
|
|
277
|
+
* consumer's value. That is right for a local knob and it leaves the harness
|
|
278
|
+
* with no channel for a REMOVAL. #1136 took the `branches:` filter off
|
|
279
|
+
* `on.pull_request` — a filter that silently suppressed CI on every
|
|
280
|
+
* stacked pull request — and no consumer who already had the file could ever
|
|
281
|
+
* receive it, because `pull_request` is a sub-key both sides declare.
|
|
282
|
+
*
|
|
283
|
+
* ## Why this and not the `generated-sha` marker
|
|
284
|
+
*
|
|
285
|
+
* #1148 proposed regenerating a top-level `on:` block whose marker reads
|
|
286
|
+
* VERIFIED, on the reading that a verified marker proves the bytes are the
|
|
287
|
+
* harness's own output. It does not, and `restorableIntro` above already says
|
|
288
|
+
* so: the marker proves the harness WROTE the bytes, not that it AUTHORED
|
|
289
|
+
* them. The merge carries a consumer's value forward and re-stamps, so one
|
|
290
|
+
* re-scaffold launders a hand-edited `on:` into VERIFIED bytes — measured in
|
|
291
|
+
* `test/scaffold-on-trigger-authored.test.ts` AC-5. A fix gated on VERIFIED
|
|
292
|
+
* would delete the customisation #1148's own control demands be kept, and
|
|
293
|
+
* that control could not catch it: a freshly hand-edited fixture reads
|
|
294
|
+
* UNPROVEN, so it never reaches the branch that does the damage.
|
|
295
|
+
*
|
|
296
|
+
* So the discriminator is an explicit claim about the GENERATOR, which the
|
|
297
|
+
* harness can make, rather than an inference from a digest, which it cannot.
|
|
298
|
+
* `HARNESS_COMPUTED_SUBKEYS` is the same move one level up (#923).
|
|
299
|
+
*
|
|
300
|
+
* ## Why a module constant and not a per-file map
|
|
301
|
+
*
|
|
302
|
+
* #923 is keyed by FILE because an unscoped revoker would make
|
|
303
|
+
* `permissions.id-token` withdrawable in a workflow whose generator never
|
|
304
|
+
* emits it under any config — a consumer's own grant removed by a feature
|
|
305
|
+
* that was not reasoning about their file. That risk is handled structurally
|
|
306
|
+
* here instead: `withdrawAuthoredPaths` withdraws a leaf only where the
|
|
307
|
+
* generated file still emits the PARENT sub-key, so a generator silent about
|
|
308
|
+
* `pull_request` makes no claim on the consumer's copy of it. The emission
|
|
309
|
+
* gate is the scope, and it is tighter than a filename would be because it
|
|
310
|
+
* tracks what the generator actually did rather than which file it wrote.
|
|
311
|
+
*
|
|
312
|
+
* Narrow on purpose. `on.push.branches` is deliberately absent: a `push`
|
|
313
|
+
* filter asks which branches earn a run on their own, which is a different
|
|
314
|
+
* question, and #1136 left it alone for that reason.
|
|
315
|
+
*/
|
|
316
|
+
export const HARNESS_AUTHORED_PATHS: ReadonlySet<string> = new Set(["on.pull_request.branches"]);
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* A sub-block split into the comments introducing it and the key line onward.
|
|
320
|
+
*
|
|
321
|
+
* `parseSubKeys` emits a block as `[...pending comments, keyLine, ...body]` —
|
|
322
|
+
* the comments it was holding back come FIRST and the key line is not
|
|
323
|
+
* `lines[0]`. Re-applying the parser to such a block without this split reads
|
|
324
|
+
* the first comment as the key line, slices it off, and then finds the key
|
|
325
|
+
* itself at the body's base indent: the leaves come back as the block's own
|
|
326
|
+
* name and the real leaves are invisible.
|
|
327
|
+
*
|
|
328
|
+
* That is not hypothetical. The first draft of `withdrawAuthoredPaths` did
|
|
329
|
+
* exactly this, passed eleven cases, and withdrew NOTHING from the three real
|
|
330
|
+
* generated workflows — every one of which introduces `pull_request:` with a
|
|
331
|
+
* comment block. The unit fixtures had no comment above the trigger, so they
|
|
332
|
+
* measured a shape the generator never emits.
|
|
333
|
+
*/
|
|
334
|
+
function splitBlockIntro(lines: string[]): [string[], string[]] {
|
|
335
|
+
const at = lines.findIndex(l => l.trim() !== "" && !l.trimStart().startsWith("#"));
|
|
336
|
+
return at <= 0 ? [[], lines] : [lines.slice(0, at), lines.slice(at)];
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* The consumer's section with every authored leaf the generator has stopped
|
|
341
|
+
* emitting taken out, and the record of what went (#1148).
|
|
342
|
+
*
|
|
343
|
+
* Reads both sides through the same `parseSubKeys` the rest of the merge uses
|
|
344
|
+
* — applied twice, because the binding takes a key line followed by its body
|
|
345
|
+
* and a sub-block is that shape once `splitBlockIntro` has taken the
|
|
346
|
+
* introducing comments off it. One parser, so the thing removed and the thing
|
|
347
|
+
* reported removed cannot be two different readings (#834).
|
|
348
|
+
*/
|
|
349
|
+
function withdrawAuthoredPaths(
|
|
350
|
+
section: string,
|
|
351
|
+
before: Section,
|
|
352
|
+
generated: Section,
|
|
353
|
+
): { section: Section; withdrawn: RevokedSubKey[] } {
|
|
354
|
+
// The same scalar guard `mergeTopLevelSection` opens with: `on: [push]` has
|
|
355
|
+
// no sub-keys to withdraw and no way to express the removal if it did.
|
|
356
|
+
if (!/^[A-Za-z_][A-Za-z0-9_.\-]*:\s*(#.*)?$/.test(before.lines[0])) {
|
|
357
|
+
return { section: before, withdrawn: [] };
|
|
358
|
+
}
|
|
359
|
+
const parsed = parseSubKeys(before.lines);
|
|
360
|
+
const generatedByKey = new Map(parseSubKeys(generated.lines).blocks.map(s => [s.key, s] as const));
|
|
361
|
+
const withdrawn: RevokedSubKey[] = [];
|
|
362
|
+
|
|
363
|
+
const blocks = parsed.blocks.map(block => {
|
|
364
|
+
const gen = generatedByKey.get(block.key);
|
|
365
|
+
// THE EMISSION GATE. A generator that does not emit this trigger is making
|
|
366
|
+
// no statement about the consumer's copy of it.
|
|
367
|
+
if (gen === undefined) return block;
|
|
368
|
+
const [intro, fromKey] = splitBlockIntro(block.lines);
|
|
369
|
+
const consumerLeaves = parseSubKeys(fromKey);
|
|
370
|
+
const emitted = new Set(parseSubKeys(splitBlockIntro(gen.lines)[1]).blocks.map(s => s.key));
|
|
371
|
+
const gone = consumerLeaves.blocks.filter(
|
|
372
|
+
leaf => HARNESS_AUTHORED_PATHS.has(`${section}.${block.key}.${leaf.key}`) && !emitted.has(leaf.key),
|
|
373
|
+
);
|
|
374
|
+
if (gone.length === 0) return block;
|
|
375
|
+
for (const leaf of gone) {
|
|
376
|
+
withdrawn.push({
|
|
377
|
+
section: `${section}.${block.key}`,
|
|
378
|
+
key: leaf.key,
|
|
379
|
+
lines: leaf.lines,
|
|
380
|
+
reason: "authored",
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
const dropped = new Set(gone.map(l => l.key));
|
|
384
|
+
return {
|
|
385
|
+
...block,
|
|
386
|
+
lines: [
|
|
387
|
+
...intro,
|
|
388
|
+
...consumerLeaves.head,
|
|
389
|
+
...consumerLeaves.blocks.filter(l => !dropped.has(l.key)).flatMap(l => l.lines),
|
|
390
|
+
],
|
|
391
|
+
};
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
if (withdrawn.length === 0) return { section: before, withdrawn: [] };
|
|
395
|
+
return {
|
|
396
|
+
section: { ...before, lines: [...parsed.head, ...blocks.flatMap(b => b.lines)] },
|
|
397
|
+
withdrawn,
|
|
398
|
+
};
|
|
269
399
|
}
|
|
270
400
|
|
|
271
401
|
/**
|
|
@@ -337,12 +467,28 @@ const NO_COMPUTED_SUBKEYS: ComputedSubKeys = new Map();
|
|
|
337
467
|
|
|
338
468
|
/** A sub-key the merge withdrew because the generator stopped emitting it (#923). */
|
|
339
469
|
export interface RevokedSubKey {
|
|
340
|
-
/**
|
|
470
|
+
/**
|
|
471
|
+
* The key it sat under: a top-level key for a `computed` withdrawal, and a
|
|
472
|
+
* dotted path (`on.pull_request`) for an `authored` one, which reaches a
|
|
473
|
+
* level deeper.
|
|
474
|
+
*/
|
|
341
475
|
section: string;
|
|
342
476
|
/** The sub-key itself. */
|
|
343
477
|
key: string;
|
|
344
478
|
/** Its lines as they stood in the consumer's file, comment block included. */
|
|
345
479
|
lines: string[];
|
|
480
|
+
/**
|
|
481
|
+
* Which ownership claim took it away (#1148).
|
|
482
|
+
*
|
|
483
|
+
* Carried rather than inferred at the reporting layer, because the two
|
|
484
|
+
* withdrawals have different causes and therefore different advice.
|
|
485
|
+
* `computed` means the project's `ci` config stopped producing a derived
|
|
486
|
+
* grant; `authored` means the GENERATOR stopped emitting a path the harness
|
|
487
|
+
* names as its own. Reporting the second with the first's sentence sends a
|
|
488
|
+
* consumer to a config key that has nothing to do with what was removed —
|
|
489
|
+
* correct-but-misdescribed, which is the expensive kind of accurate.
|
|
490
|
+
*/
|
|
491
|
+
reason: "computed" | "authored";
|
|
346
492
|
}
|
|
347
493
|
|
|
348
494
|
/**
|
|
@@ -773,9 +919,22 @@ export function mergeManagedWorkflowRecording(
|
|
|
773
919
|
// to make impossible.
|
|
774
920
|
let merged: string[];
|
|
775
921
|
if (gen !== undefined && !declined.has(section.key)) {
|
|
776
|
-
|
|
922
|
+
// An authored path the generator has stopped emitting goes FIRST, for
|
|
923
|
+
// the reason #923 gives for ordering its own withdrawal before the
|
|
924
|
+
// merge: the sub-key merge's job is to carry what the generator newly
|
|
925
|
+
// emits into the consumer's section, and running it over a section that
|
|
926
|
+
// still holds a withdrawn leaf would have it decide ownership of a line
|
|
927
|
+
// that is on its way out.
|
|
928
|
+
//
|
|
929
|
+
// Inside the `!declined` arm for the reason #923 is: a consumer who has
|
|
930
|
+
// named this top-level key in `ci.workflowOverrides` has taken the whole
|
|
931
|
+
// block back, and reaching into it is the deletion-without-a-route that
|
|
932
|
+
// #839's hatch exists to make impossible.
|
|
933
|
+
const authored = withdrawAuthoredPaths(section.key, consumer, gen);
|
|
934
|
+
revoked.push(...authored.withdrawn);
|
|
935
|
+
const withdrawn = revokedSubKeys(section.key, authored.section, gen, computed);
|
|
777
936
|
revoked.push(...withdrawn);
|
|
778
|
-
merged = mergeTopLevelSection(withoutRevoked(
|
|
937
|
+
merged = mergeTopLevelSection(withoutRevoked(authored.section, withdrawn), gen);
|
|
779
938
|
} else {
|
|
780
939
|
merged = consumer.lines;
|
|
781
940
|
}
|