rungate 0.5.0 → 0.7.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.
Files changed (142) hide show
  1. package/lib/affected-tests.ts +398 -0
  2. package/lib/agent-audit.ts +2 -3
  3. package/lib/agent-worktree.ts +287 -0
  4. package/lib/agents-md-sections.ts +209 -0
  5. package/lib/behavioral-cache.ts +150 -2
  6. package/lib/branch-diff.ts +139 -0
  7. package/lib/branch-protection.ts +790 -0
  8. package/lib/brief-ac-alignment.ts +104 -0
  9. package/lib/brief-references.ts +205 -0
  10. package/lib/bun-version.ts +347 -0
  11. package/lib/check-remedy.ts +140 -0
  12. package/lib/ci-checkout.ts +18 -1
  13. package/lib/ci-history-depth.ts +159 -0
  14. package/lib/ci-setup-step.ts +96 -0
  15. package/lib/claude-code-action.ts +85 -0
  16. package/lib/claude-tool-vocabulary.ts +188 -0
  17. package/lib/cli-commands.ts +15 -0
  18. package/lib/commit-sha.ts +42 -0
  19. package/lib/commit-subject.ts +90 -0
  20. package/lib/compliance-report.ts +377 -45
  21. package/lib/compliance.ts +196 -20
  22. package/lib/config-loader.ts +51 -1
  23. package/lib/config-trackable.ts +391 -0
  24. package/lib/conformity.ts +1272 -189
  25. package/lib/containment.ts +238 -0
  26. package/lib/content-hash.ts +24 -0
  27. package/lib/context-docs.ts +143 -28
  28. package/lib/create-brief.ts +2 -1
  29. package/lib/create-sc.ts +323 -4
  30. package/lib/dev-liveness.ts +180 -0
  31. package/lib/discovery-branch-points.ts +432 -0
  32. package/lib/discovery-stability.ts +481 -0
  33. package/lib/distribution-currency.ts +186 -0
  34. package/lib/doc-routing.ts +157 -0
  35. package/lib/doc-scan-targets.ts +9 -0
  36. package/lib/evidence-command-transport.ts +160 -0
  37. package/lib/evidence-prevalidator.ts +246 -2
  38. package/lib/evidence-satisfiability.ts +534 -12
  39. package/lib/failure-intake.ts +317 -0
  40. package/lib/fallow-availability.ts +286 -0
  41. package/lib/fs-write-capabilities.ts +232 -0
  42. package/lib/gate-refusal-currency.ts +112 -0
  43. package/lib/gate-run-split.ts +147 -0
  44. package/lib/gate-timeouts.ts +82 -0
  45. package/lib/generators/agent-briefs.ts +4 -1
  46. package/lib/generators/agents-md.ts +204 -48
  47. package/lib/generators/code-map.ts +2 -1
  48. package/lib/generators/types.ts +8 -0
  49. package/lib/git-dates.ts +55 -0
  50. package/lib/git-isolation.ts +140 -0
  51. package/lib/github.ts +15 -0
  52. package/lib/google-auth-action.ts +93 -0
  53. package/lib/harness-project.ts +48 -0
  54. package/lib/harness-provenance.ts +255 -0
  55. package/lib/hook-evidence.ts +235 -0
  56. package/lib/hook-scopes.ts +386 -0
  57. package/lib/hook-target-tree.ts +398 -0
  58. package/lib/hook-trees.ts +447 -0
  59. package/lib/js-top-level-code.ts +78 -10
  60. package/lib/junit-checks.ts +536 -0
  61. package/lib/launch-base.ts +253 -0
  62. package/lib/line-citation.ts +372 -0
  63. package/lib/local-calendar-day.ts +78 -0
  64. package/lib/orphan-reaper.ts +468 -0
  65. package/lib/parity-binding.ts +205 -0
  66. package/lib/per-test-timeouts.ts +219 -0
  67. package/lib/plan-coverage.ts +151 -0
  68. package/lib/prior-branch.ts +201 -8
  69. package/lib/process-table.ts +146 -0
  70. package/lib/project-state-derivation.ts +219 -0
  71. package/lib/project-state-root.ts +258 -0
  72. package/lib/project-state-shape.ts +59 -0
  73. package/lib/promote-outputs.ts +6 -2
  74. package/lib/published-artifact.ts +525 -0
  75. package/lib/readdir-sorted.ts +45 -0
  76. package/lib/report-provenance.ts +156 -0
  77. package/lib/review-execution-reading.ts +206 -0
  78. package/lib/review-tool-agreement.ts +433 -0
  79. package/lib/rule-promotion.ts +234 -0
  80. package/lib/rule-retirement.ts +525 -0
  81. package/lib/run-branch.ts +612 -0
  82. package/lib/rungate-schema.ts +19 -0
  83. package/lib/runner-home.ts +274 -0
  84. package/lib/sc-claim-forms.ts +75 -0
  85. package/lib/sc-id-cross-tree.ts +323 -0
  86. package/lib/sc-ids.ts +121 -13
  87. package/lib/sc-reservations.ts +289 -0
  88. package/lib/scaffold/ai-review-findings.ts +403 -0
  89. package/lib/scaffold/ai-review-step.ts +4777 -0
  90. package/lib/scaffold/managed-workflow.ts +587 -192
  91. package/lib/scaffold/owned-files.ts +186 -39
  92. package/lib/scaffold/pre-push-hook.ts +49 -5
  93. package/lib/scaffold/rehearsal.ts +205 -71
  94. package/lib/scaffold/steps.ts +1517 -293
  95. package/lib/scaffold/workflow-census.ts +217 -0
  96. package/lib/scaffold/workflow-drift.ts +217 -0
  97. package/lib/scaffold/write-steps.ts +10 -4
  98. package/lib/scan-budget.ts +247 -0
  99. package/lib/scanner.ts +80 -62
  100. package/lib/scratch-roots.ts +50 -5
  101. package/lib/screenshot-discovery.ts +121 -0
  102. package/lib/screenshot-upload.ts +41 -1
  103. package/lib/secret-patterns.ts +511 -8
  104. package/lib/ship-mode.ts +219 -0
  105. package/lib/source-slice.ts +294 -0
  106. package/lib/spec-listing.ts +148 -0
  107. package/lib/spec-requirements.ts +209 -0
  108. package/lib/stale-cleanup.ts +37 -3
  109. package/lib/suite-flake.ts +278 -0
  110. package/lib/suite-measurement.ts +23 -4
  111. package/lib/suite-run-reading.ts +411 -1
  112. package/lib/suite-timeout-margin.ts +193 -0
  113. package/lib/test-case-bodies.ts +883 -0
  114. package/lib/test-case-deletion.ts +653 -0
  115. package/lib/test-census.ts +97 -29
  116. package/lib/test-command-positions.ts +274 -0
  117. package/lib/test-command.ts +133 -0
  118. package/lib/test-suite-lock.ts +325 -26
  119. package/lib/tool-probe.ts +142 -0
  120. package/lib/top-level-cd.ts +393 -0
  121. package/lib/tracked-vs-ignored.ts +234 -0
  122. package/lib/tree-entries.ts +89 -0
  123. package/lib/ts-ast.ts +200 -0
  124. package/lib/validators/spec-validators.ts +3 -2
  125. package/lib/walk-test-files.ts +97 -0
  126. package/lib/workflow-actions.ts +263 -0
  127. package/lib/worktree-collect.ts +177 -5
  128. package/lib/worktree-repo.ts +36 -1
  129. package/package.json +2 -1
  130. package/scripts/ai-review-findings.ts +45 -0
  131. package/scripts/audit-specs.ts +247 -12
  132. package/scripts/audit-transcript.ts +2 -1
  133. package/scripts/convert-spec.ts +2 -1
  134. package/scripts/create-sc.ts +37 -7
  135. package/scripts/create-spec.ts +2 -1
  136. package/scripts/create-success.ts +2 -1
  137. package/scripts/extract-constraints.ts +197 -26
  138. package/scripts/generate-code-map.ts +62 -28
  139. package/scripts/scaffold-project.ts +12 -2
  140. package/scripts/split-spec.ts +2 -1
  141. package/scripts/sync-sc-status.ts +127 -14
  142. package/scripts/sync-spec-tests.ts +2 -1
@@ -0,0 +1,139 @@
1
+ /**
2
+ * What THIS branch changed since the scope gate ran (#531).
3
+ *
4
+ * Three gate checks — `prove-evidence-type`, `contextual-skip-validation`
5
+ * and the ship-round repeat — decide what a run must prove from a list of
6
+ * changed files. All three built that list with
7
+ *
8
+ * git diff --name-only ${scopeSha}..HEAD
9
+ *
10
+ * Two dots compares two commits DIRECTLY. When `scopeSha` is not an ancestor
11
+ * of `HEAD`, the output also carries everything on the other side of the
12
+ * fork, and the gate attributes all of it to this branch.
13
+ *
14
+ * Measured on run `wf_e230fddc-a71`, whose `gates.scope.commitSha` was
15
+ * `247afba4`:
16
+ *
17
+ * ```
18
+ * git merge-base --is-ancestor 247afba4 HEAD -> false
19
+ * git diff --name-only 247afba4..HEAD | wc -l -> 78
20
+ * git diff --name-only 247afba4...HEAD | wc -l -> 3
21
+ * ```
22
+ *
23
+ * The branch touched three files. The gate saw seventy-eight and refused
24
+ * twice over files that do not exist on it — a `Dockerfile` it has never
25
+ * contained, and seven `.tsx` files it has never contained.
26
+ *
27
+ * Three dots diffs HEAD against the MERGE BASE, which is the question every
28
+ * one of these checks is actually asking: what did this branch do.
29
+ *
30
+ * ## Why the sha was wrong to begin with, and why three dots is not enough
31
+ *
32
+ * `247afba4` was the tip of the branch the MAIN CHECKOUT happened to be
33
+ * sitting on, while the run was shipping a worktree. `writeGateResult`
34
+ * recorded `gitSha(state.projectRoot)`. The state names `treeUnderTest`
35
+ * correctly, so the right value was available and the writer read HEAD from
36
+ * somewhere else — which is `.claude/rules/checks-must-be-able-to-fail.md`'s
37
+ * "a consumer reads a name, a producer writes a different name" in the
38
+ * smallest possible form. Both halves are fixed: the recorder reads the tree
39
+ * under test, and the readers compare branch-relative. Three dots alone
40
+ * still mis-attributes when the recorded sha came from the wrong tree, and
41
+ * the right sha alone still mis-attributes across a fork.
42
+ *
43
+ * ## An unusable diff is UNMEASURED, and says so
44
+ *
45
+ * The three call sites read `if (!diff.ok || !diff.output) return`, which
46
+ * collapses "git could not answer" into "nothing changed" — and the first of
47
+ * those is the state a check should be loudest about, because every file
48
+ * gate below it then passes for want of input. The reading keeps them apart:
49
+ * `files: null` is "could not measure", `files: []` is "measured, nothing
50
+ * changed" (`.claude/rules/config-access.md`, Silent Default Substitution).
51
+ *
52
+ * **The call sites still RETURN on `null`, and that is deliberate rather
53
+ * than an oversight.** An unreachable scope sha is an ORDINARY outcome, not
54
+ * an anomaly: a rebase during the run — which this project does on nearly
55
+ * every PR — leaves `gates.scope.commitSha` pointing at a commit no longer
56
+ * in the branch's history, and `A...HEAD` then fails. Refusing on it would
57
+ * red every rebased run, so the reading is printed as `WARN: … UNMEASURED`
58
+ * and the check declines to decide. The difference from before is that the
59
+ * decline is now visible in the gate log instead of being spelled
60
+ * `// no changed files`.
61
+ */
62
+
63
+ /** What one reading of the branch diff says. */
64
+ export interface BranchDiffReading {
65
+ /**
66
+ * The files this branch changed, or `null` when git could not answer.
67
+ * `[]` means it answered and the answer was none, which is a measurement.
68
+ */
69
+ files: string[] | null;
70
+ /** Why `files` is null. */
71
+ reason?: string;
72
+ }
73
+
74
+ /**
75
+ * An argv-form git runner, injected so the reading can be driven without git.
76
+ *
77
+ * Argv and not a command string: `scopeSha` comes out of
78
+ * `workflow-state.json`, which the run's own agents write, and the old call
79
+ * sites interpolated it straight into a shell. The sha is validated below as
80
+ * well — both, because the validation is the thing a later edit is most
81
+ * likely to widen.
82
+ */
83
+ export type DiffRunner = (args: string[]) => { ok: boolean; output: string };
84
+
85
+ /** A git object name and nothing else. */
86
+ const SHA = /^[0-9a-f]{7,64}$/;
87
+
88
+ /**
89
+ * The argv. One place, so the dot count has one binding to mutate.
90
+ *
91
+ * `-z` for the same reason `scripts/verify-merge-content.ts` uses it:
92
+ * `git diff --name-only` C-QUOTES any path holding a non-ASCII byte, a
93
+ * quote, a tab or a newline — `"caf\303\251.tsx"`, quotes included. Every
94
+ * consumer of this list is a regex on the filename, and
95
+ * `/\.(tsx|jsx|css)$/i` does not match a string ending in `"`. So a UI file
96
+ * with an accent in its name walks past `local-ui-validated` and
97
+ * `quinn-on-ui-change` without matching anything, which is #531's own defect
98
+ * — a changed-file list that is wrong about what changed — arriving through
99
+ * the encoding instead of through the dot count. `-z` emits raw bytes,
100
+ * NUL-separated, and nothing is ever re-parsed.
101
+ */
102
+ export function branchDiffArgs(scopeSha: string): string[] {
103
+ // THREE dots. See the docstring: two dots is the whole of #531.
104
+ return ["diff", "--name-only", "-z", `${scopeSha}...HEAD`];
105
+ }
106
+
107
+ /**
108
+ * The files this branch changed since `scopeSha`, branch-relative.
109
+ *
110
+ * `checkName` is carried so the UNMEASURED line names the check that could
111
+ * not measure rather than the helper that noticed.
112
+ */
113
+ export function readBranchDiff(
114
+ scopeSha: unknown,
115
+ run: DiffRunner,
116
+ checkName: string,
117
+ ): BranchDiffReading {
118
+ if (typeof scopeSha !== "string" || !SHA.test(scopeSha)) {
119
+ return {
120
+ files: null,
121
+ reason:
122
+ `${checkName}: gates.scope.commitSha is ${JSON.stringify(scopeSha)}, which is not a git ` +
123
+ `object name, so the changed-file list could not be built (#531).`,
124
+ };
125
+ }
126
+ const r = run(branchDiffArgs(scopeSha));
127
+ if (!r.ok) {
128
+ return {
129
+ files: null,
130
+ reason:
131
+ `${checkName}: \`git ${branchDiffArgs(scopeSha).join(" ")}\` failed, so the changed-file ` +
132
+ `list is UNMEASURED. This is not "nothing changed" — every file-matched gate below reads ` +
133
+ `this list, and an empty one waves all of them through (#531).`,
134
+ };
135
+ }
136
+ // NUL, not newline, and no `trim` on the paths themselves — a filename may
137
+ // legally contain a newline, and trimming one would rewrite it.
138
+ return { files: r.output.split("\0").filter(Boolean) };
139
+ }