rungate 0.7.0 → 0.8.1
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/ActionVerificationGate.hook.ts +96 -0
- package/hooks/AgentBriefGuard.hook.ts +38 -0
- package/hooks/AgentVerdictCapture.hook.ts +87 -0
- package/hooks/AutoVerifyGate.hook.ts +79 -0
- package/hooks/BashToolGuard.hook.ts +65 -0
- package/hooks/BashWriteGuard.hook.ts +60 -0
- package/hooks/CommitEnforcement.hook.ts +130 -0
- package/hooks/DocHygiene.hook.ts +148 -0
- package/hooks/GateEnforcement.hook.ts +58 -0
- package/hooks/GateResultProtection.hook.ts +95 -0
- package/hooks/HarnessAFKGate.hook.ts +85 -0
- package/hooks/HookCurrency.hook.ts +99 -0
- package/hooks/IssueCloseGuard.hook.ts +149 -0
- package/hooks/MergeGuard.hook.ts +58 -0
- package/hooks/PostCompact.hook.ts +60 -0
- package/hooks/ProjectStateSync.hook.ts +103 -0
- package/hooks/SkillGuard.hook.ts +69 -0
- package/hooks/SpecConformityTrigger.hook.ts +43 -0
- package/hooks/SpecSCGuard.hook.ts +123 -0
- package/hooks/StaleTTLCleanup.hook.ts +141 -0
- package/hooks/TaskCompleted.hook.ts +51 -0
- package/hooks/TeamInit.hook.ts +85 -0
- package/hooks/TestSuiteGuard.hook.ts +70 -0
- package/hooks/TestSuiteRelease.hook.ts +85 -0
- package/hooks/TopLevelCdGuard.hook.ts +108 -0
- package/hooks/VerifyPhaseLock.hook.ts +84 -0
- package/hooks/WorkflowStateGuard.hook.ts +64 -0
- package/hooks/lib/agent-config.json +9 -0
- package/hooks/lib/agentDetection.ts +201 -0
- package/hooks/lib/comment-template.ts +86 -0
- package/hooks/lib/findWorkflow.ts +101 -0
- package/hooks/lib/parseStdin.ts +37 -0
- package/hooks/lib/paths.ts +111 -0
- package/hooks/lib/utils.ts +338 -0
- package/lib/affected-tests.ts +29 -0
- package/lib/bash-write-guard.ts +627 -0
- package/lib/branch-cleanup.ts +279 -7
- package/lib/config-trackable.ts +9 -0
- package/lib/distribution-currency.ts +55 -5
- package/lib/failure-intake.ts +7 -1
- package/lib/gate-enforcement.ts +360 -38
- package/lib/gate-names.ts +72 -0
- package/lib/gate-result-protection.ts +437 -0
- package/lib/generators/code-map.ts +55 -4
- package/lib/generators/types.ts +27 -1
- package/lib/intake-sources.ts +380 -0
- package/lib/js-top-level-code.ts +20 -2
- package/lib/junit-checks.ts +239 -1
- package/lib/late-env-spawn.ts +331 -0
- package/lib/launch-base.ts +128 -5
- package/lib/package-closure.ts +114 -0
- package/lib/paths.ts +96 -3
- package/lib/phase2-decomposition.ts +1 -1
- package/lib/published-artifact.ts +162 -18
- package/lib/sc-id-cross-tree.ts +84 -8
- package/lib/scaffold/ai-review-findings.ts +149 -4
- package/lib/scaffold/ai-review-step.ts +1006 -132
- package/lib/scaffold/defaults.ts +82 -1
- package/lib/scaffold/steps.ts +642 -54
- package/lib/scanner.ts +4 -2
- package/lib/security-verdict.ts +1 -1
- package/lib/shell-path-interpolation.ts +594 -0
- package/lib/text-dependents.ts +875 -0
- package/lib/transcript-checker.ts +6 -0
- package/lib/workflow-security.ts +29 -0
- package/lib/workflow-taint.ts +732 -0
- package/lib/worktree-cleanup.ts +65 -38
- package/lib/worktree-repo.ts +32 -2
- package/package.json +4 -1
- package/scripts/check-installed-hook-currency.ts +825 -0
- package/scripts/generate-code-map.ts +13 -8
package/lib/worktree-cleanup.ts
CHANGED
|
@@ -12,6 +12,61 @@
|
|
|
12
12
|
import { readdirSync, realpathSync, statSync, existsSync, readFileSync, rmSync } from "fs";
|
|
13
13
|
import { join, isAbsolute } from "path";
|
|
14
14
|
import { spawnSync } from "child_process";
|
|
15
|
+
import { gitIsolatedArgs, gitIsolatedEnv } from "./git-isolation";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The ONE place this module runs `git` (#1097).
|
|
19
|
+
*
|
|
20
|
+
* ## Why isolation matters more here than anywhere it has been applied yet
|
|
21
|
+
*
|
|
22
|
+
* Every other consumer of `lib/git-isolation.ts` reads. This one deletes.
|
|
23
|
+
* The chain is three steps and it was live on `origin/main`:
|
|
24
|
+
*
|
|
25
|
+
* 1. `core.excludesFile` makes an untracked file invisible to
|
|
26
|
+
* `git status --porcelain`. Measured on git 2.50.1 by #1048/#1090.
|
|
27
|
+
* 2. The dirty check below reads clean, so the worktree falls through
|
|
28
|
+
* every remaining check.
|
|
29
|
+
* 3. `git worktree remove --force` takes the tree, and the file that
|
|
30
|
+
* existed in exactly one place is gone.
|
|
31
|
+
*
|
|
32
|
+
* **The guard meant to spare the work is the reading that was tampered
|
|
33
|
+
* with**, which is why no amount of care in the checks downstream of it
|
|
34
|
+
* helps. #1090 isolated the census — the module that REPORTS the same
|
|
35
|
+
* reading — and did not touch this one.
|
|
36
|
+
*
|
|
37
|
+
* Latent rather than active when this shipped: none of
|
|
38
|
+
* `core.excludesFile`, `core.hooksPath` or `core.fsmonitor` was set in any
|
|
39
|
+
* scope on the machine (measured 2026-10-22). What makes it worth fixing
|
|
40
|
+
* is that a global gitignore is ordinary advice, setting one silently arms
|
|
41
|
+
* this, and the failure is silent — the summary prints `N removed` and
|
|
42
|
+
* nothing says what was in them.
|
|
43
|
+
*
|
|
44
|
+
* ## One seam, not the flags at each site
|
|
45
|
+
*
|
|
46
|
+
* There are eight `git` invocations in this module. `lib/git-isolation.ts`
|
|
47
|
+
* is the single declaring position for WHAT isolation is; this is the
|
|
48
|
+
* single declaring position for WHERE this module applies it. Pasting the
|
|
49
|
+
* `-c` flags at eight call sites is the cheaper change and is measured as
|
|
50
|
+
* the cheapest WRONG fix in #1090's battery: it works, and it reinstates
|
|
51
|
+
* the drifting spellings #1001 removed.
|
|
52
|
+
*
|
|
53
|
+
* ## WHAT THIS DOES NOT COVER
|
|
54
|
+
*
|
|
55
|
+
* `rmSync` on an orphaned checkout, in the `removeOrphans` arm below. Git
|
|
56
|
+
* has no registration for that directory — that is the definition of the
|
|
57
|
+
* bucket — so there is no git invocation there to isolate and no config
|
|
58
|
+
* that could steer it. It is a recursive delete of content nothing has
|
|
59
|
+
* classified, which is why it is off by default; that is #436's argument
|
|
60
|
+
* and this change does not touch it.
|
|
61
|
+
*/
|
|
62
|
+
function cleanupGit(args: readonly string[], cwd: string, timeout: number) {
|
|
63
|
+
return spawnSync("git", gitIsolatedArgs(args), {
|
|
64
|
+
cwd,
|
|
65
|
+
encoding: "utf-8",
|
|
66
|
+
timeout,
|
|
67
|
+
env: gitIsolatedEnv(),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
15
70
|
|
|
16
71
|
export interface CleanupResult {
|
|
17
72
|
removed: string[];
|
|
@@ -78,15 +133,11 @@ export interface CleanupOptions {
|
|
|
78
133
|
* safety check reverted.
|
|
79
134
|
*/
|
|
80
135
|
export function unpushedCommitCount(projectRoot: string, branch: string): number | null {
|
|
81
|
-
const remotes =
|
|
82
|
-
cwd: projectRoot, encoding: "utf-8", timeout: 5000,
|
|
83
|
-
});
|
|
136
|
+
const remotes = cleanupGit(["remote"], projectRoot, 5000);
|
|
84
137
|
if (remotes.status !== 0) return null;
|
|
85
138
|
if (!remotes.stdout.split("\n").map(r => r.trim()).includes("origin")) return 0;
|
|
86
139
|
|
|
87
|
-
const count =
|
|
88
|
-
cwd: projectRoot, encoding: "utf-8", timeout: 10_000,
|
|
89
|
-
});
|
|
140
|
+
const count = cleanupGit(["rev-list", "--count", branch, "--not", "--remotes=origin"], projectRoot, 10_000);
|
|
90
141
|
if (count.status !== 0) return null;
|
|
91
142
|
const n = parseInt(count.stdout.trim(), 10);
|
|
92
143
|
return Number.isFinite(n) ? n : null;
|
|
@@ -124,13 +175,11 @@ export type OriginState =
|
|
|
124
175
|
| { kind: "on-origin" };
|
|
125
176
|
|
|
126
177
|
export function originState(projectRoot: string, branch: string): OriginState {
|
|
127
|
-
const remotes =
|
|
178
|
+
const remotes = cleanupGit(["remote"], projectRoot, 5000);
|
|
128
179
|
if (remotes.status !== 0) return { kind: "unknown" };
|
|
129
180
|
if (!remotes.stdout.split("\n").map(r => r.trim()).includes("origin")) return { kind: "no-origin" };
|
|
130
181
|
|
|
131
|
-
const count =
|
|
132
|
-
cwd: projectRoot, encoding: "utf-8", timeout: 10_000,
|
|
133
|
-
});
|
|
182
|
+
const count = cleanupGit(["rev-list", "--count", branch, "--not", "--remotes=origin"], projectRoot, 10_000);
|
|
134
183
|
if (count.status !== 0) return { kind: "unknown" };
|
|
135
184
|
const n = parseInt(count.stdout.trim(), 10);
|
|
136
185
|
if (!Number.isFinite(n)) return { kind: "unknown" };
|
|
@@ -193,9 +242,7 @@ export function removalKeepReason(
|
|
|
193
242
|
* permission — the same rule `unpushedCommitCount` follows for `null`.
|
|
194
243
|
*/
|
|
195
244
|
export function lockedWorktreePaths(projectRoot: string): Set<string> | null {
|
|
196
|
-
const list =
|
|
197
|
-
cwd: projectRoot, encoding: "utf-8", timeout: 15_000,
|
|
198
|
-
});
|
|
245
|
+
const list = cleanupGit(["worktree", "list", "--porcelain"], projectRoot, 15_000);
|
|
199
246
|
if (list.status !== 0) return null;
|
|
200
247
|
|
|
201
248
|
const paths = new Set<string>();
|
|
@@ -420,11 +467,7 @@ export async function cleanupWorktrees(opts: CleanupOptions): Promise<CleanupRes
|
|
|
420
467
|
}
|
|
421
468
|
|
|
422
469
|
// Check for uncommitted changes
|
|
423
|
-
const statusCheck =
|
|
424
|
-
cwd: worktreePath,
|
|
425
|
-
encoding: "utf-8",
|
|
426
|
-
timeout: 5000,
|
|
427
|
-
});
|
|
470
|
+
const statusCheck = cleanupGit(["status", "--porcelain"], worktreePath, 5000);
|
|
428
471
|
|
|
429
472
|
if (statusCheck.status !== 0) {
|
|
430
473
|
result.errors.push(`Failed to check git status for ${entry}: ${statusCheck.stderr}`);
|
|
@@ -438,11 +481,7 @@ export async function cleanupWorktrees(opts: CleanupOptions): Promise<CleanupRes
|
|
|
438
481
|
}
|
|
439
482
|
|
|
440
483
|
// Get branch name
|
|
441
|
-
const branchCheck =
|
|
442
|
-
cwd: projectRoot,
|
|
443
|
-
encoding: "utf-8",
|
|
444
|
-
timeout: 5000,
|
|
445
|
-
});
|
|
484
|
+
const branchCheck = cleanupGit(["-C", worktreePath, "branch", "--show-current"], projectRoot, 5000);
|
|
446
485
|
|
|
447
486
|
if (branchCheck.status !== 0) {
|
|
448
487
|
result.errors.push(`Failed to get branch name for ${entry}: ${branchCheck.stderr}`);
|
|
@@ -475,11 +514,7 @@ export async function cleanupWorktrees(opts: CleanupOptions): Promise<CleanupRes
|
|
|
475
514
|
// asks whether BRANCH is an ancestor of main. Reversed, every branch cut
|
|
476
515
|
// from main would look merged and cleanup would delete unmerged work.
|
|
477
516
|
// test/unit/worktree-cleanup-merge.test.ts pins both directions.
|
|
478
|
-
const mergeCheck =
|
|
479
|
-
cwd: projectRoot,
|
|
480
|
-
encoding: "utf-8",
|
|
481
|
-
timeout: 5000,
|
|
482
|
-
});
|
|
517
|
+
const mergeCheck = cleanupGit(["merge-base", "--is-ancestor", branchName, "main"], projectRoot, 5000);
|
|
483
518
|
|
|
484
519
|
// Exit 0 = merged, 1 = not merged. Anything else (128: bad revision, no
|
|
485
520
|
// `main`, not a repo) is an error, NOT a verdict — treating it as "not
|
|
@@ -507,11 +542,7 @@ export async function cleanupWorktrees(opts: CleanupOptions): Promise<CleanupRes
|
|
|
507
542
|
}
|
|
508
543
|
|
|
509
544
|
// All safety checks passed — remove the worktree
|
|
510
|
-
const removeResult =
|
|
511
|
-
cwd: projectRoot,
|
|
512
|
-
encoding: "utf-8",
|
|
513
|
-
timeout: 15000,
|
|
514
|
-
});
|
|
545
|
+
const removeResult = cleanupGit(["worktree", "remove", "--force", worktreePath], projectRoot, 15000);
|
|
515
546
|
|
|
516
547
|
if (removeResult.status !== 0) {
|
|
517
548
|
result.errors.push(`Failed to remove ${entry}: ${removeResult.stderr}`);
|
|
@@ -521,11 +552,7 @@ export async function cleanupWorktrees(opts: CleanupOptions): Promise<CleanupRes
|
|
|
521
552
|
}
|
|
522
553
|
|
|
523
554
|
// Prune worktree references
|
|
524
|
-
const pruneResult =
|
|
525
|
-
cwd: projectRoot,
|
|
526
|
-
encoding: "utf-8",
|
|
527
|
-
timeout: 5000,
|
|
528
|
-
});
|
|
555
|
+
const pruneResult = cleanupGit(["worktree", "prune"], projectRoot, 5000);
|
|
529
556
|
|
|
530
557
|
if (pruneResult.status !== 0) {
|
|
531
558
|
result.errors.push(`Failed to prune worktree references: ${pruneResult.stderr}`);
|
package/lib/worktree-repo.ts
CHANGED
|
@@ -482,11 +482,27 @@ export interface WorktreeReport {
|
|
|
482
482
|
* check" — it is a row claiming files with no checkable origin, and omitting
|
|
483
483
|
* one field would skip the guard entirely. Callers that are about to act on
|
|
484
484
|
* the rows pass `true`; callers merely surveying them do not.
|
|
485
|
+
*
|
|
486
|
+
* `allowPath` is the DESTINATION question asked at the same boundary (#1098).
|
|
487
|
+
* Identity answers "which repository is this a worktree of", read off the
|
|
488
|
+
* remote; it says nothing about whether the directory is one this run may act
|
|
489
|
+
* in. In `workflows/ship.js` those were two checks ~350 lines apart, and the
|
|
490
|
+
* second ran after two agents had already been told to validate and to fix
|
|
491
|
+
* inside the path. Asked here, every reported path is vetted once, before
|
|
492
|
+
* anything is interpolated into a prompt.
|
|
493
|
+
*
|
|
494
|
+
* It is asked where identity had nothing to say, not instead of it: a row in
|
|
495
|
+
* the wrong repository keeps #218's own refusal, which names the repository.
|
|
496
|
+
*
|
|
497
|
+
* The predicate is INJECTED, not referenced: ship.js's allowlist is declared
|
|
498
|
+
* in a different marked block and the identity block is sliced out and
|
|
499
|
+
* executed on its own. Absent, nothing is allowlisted — a caller merely
|
|
500
|
+
* surveying rows has no destination to vet.
|
|
485
501
|
*/
|
|
486
502
|
export function worktreeIdentityViolations(
|
|
487
503
|
reports: readonly WorktreeReport[] | null | undefined,
|
|
488
504
|
expectedRepo: string | null | undefined,
|
|
489
|
-
opts: { requirePath?: boolean } = {},
|
|
505
|
+
opts: { requirePath?: boolean; allowPath?: (path: string) => unknown } = {},
|
|
490
506
|
): string[] {
|
|
491
507
|
if (!Array.isArray(reports)) return [];
|
|
492
508
|
const out: string[] = [];
|
|
@@ -494,7 +510,21 @@ export function worktreeIdentityViolations(
|
|
|
494
510
|
const path = r && typeof r.worktreePath === "string" ? r.worktreePath.trim() : "";
|
|
495
511
|
if (!path && !opts.requirePath) continue;
|
|
496
512
|
const got = worktreeIdentity(path, expectedRepo, r?.worktreeRepo);
|
|
497
|
-
if (got.refusal)
|
|
513
|
+
if (got.refusal) {
|
|
514
|
+
out.push(got.refusal);
|
|
515
|
+
continue;
|
|
516
|
+
}
|
|
517
|
+
// AFTER the identity reading, and only where identity had nothing to
|
|
518
|
+
// say. A row that is a worktree of the wrong repository keeps #218's own
|
|
519
|
+
// refusal, which names the repository. What this adds is the case
|
|
520
|
+
// identity CANNOT see: a checkout of the RIGHT repository sitting in a
|
|
521
|
+
// directory this run does not own, which reads as a match.
|
|
522
|
+
if (path && typeof opts.allowPath === "function" && !opts.allowPath(path)) {
|
|
523
|
+
out.push(
|
|
524
|
+
`${path} is not this run's project root nor one of its agent worktrees, ` +
|
|
525
|
+
`so it is not a directory this run may act in (#1098)`,
|
|
526
|
+
);
|
|
527
|
+
}
|
|
498
528
|
}
|
|
499
529
|
return out;
|
|
500
530
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rungate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Ship harness — conformity tests, scaffold, and agent briefs for AI-first development",
|
|
6
6
|
"repository": {
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"bin/",
|
|
16
16
|
"lib/",
|
|
17
|
+
"gates/",
|
|
18
|
+
"hooks/",
|
|
17
19
|
"prompts/",
|
|
18
20
|
"config/",
|
|
19
21
|
"templates/",
|
|
@@ -32,6 +34,7 @@
|
|
|
32
34
|
"scripts/sync-sc-status.ts",
|
|
33
35
|
"scripts/audit-transcript.ts",
|
|
34
36
|
"scripts/detect-sc-drift.ts",
|
|
37
|
+
"scripts/check-installed-hook-currency.ts",
|
|
35
38
|
"package.json"
|
|
36
39
|
],
|
|
37
40
|
"exports": {
|