redlinegate 0.0.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.
Files changed (198) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +188 -0
  3. package/commands/redline-init.md +54 -0
  4. package/commands/redline-verify.md +69 -0
  5. package/dist/bin/redline.js +605 -0
  6. package/dist/bin/redline.js.map +1 -0
  7. package/dist/commands/exempt.js +45 -0
  8. package/dist/commands/exempt.js.map +1 -0
  9. package/dist/commands/init.js +615 -0
  10. package/dist/commands/init.js.map +1 -0
  11. package/dist/commands/policy.js +25 -0
  12. package/dist/commands/policy.js.map +1 -0
  13. package/dist/commands/remove.js +427 -0
  14. package/dist/commands/remove.js.map +1 -0
  15. package/dist/commands/review.js +72 -0
  16. package/dist/commands/review.js.map +1 -0
  17. package/dist/commands/sync.js +42 -0
  18. package/dist/commands/sync.js.map +1 -0
  19. package/dist/commands/verify.js +478 -0
  20. package/dist/commands/verify.js.map +1 -0
  21. package/dist/config/redline-json.js +187 -0
  22. package/dist/config/redline-json.js.map +1 -0
  23. package/dist/core/errors.js +25 -0
  24. package/dist/core/errors.js.map +1 -0
  25. package/dist/core/git.js +152 -0
  26. package/dist/core/git.js.map +1 -0
  27. package/dist/core/log.js +22 -0
  28. package/dist/core/log.js.map +1 -0
  29. package/dist/core/severity.js +16 -0
  30. package/dist/core/severity.js.map +1 -0
  31. package/dist/core/version.js +15 -0
  32. package/dist/core/version.js.map +1 -0
  33. package/dist/detect/scan.js +79 -0
  34. package/dist/detect/scan.js.map +1 -0
  35. package/dist/detect/stack.js +71 -0
  36. package/dist/detect/stack.js.map +1 -0
  37. package/dist/enforce/ladder.js +148 -0
  38. package/dist/enforce/ladder.js.map +1 -0
  39. package/dist/exempt/parse.js +86 -0
  40. package/dist/exempt/parse.js.map +1 -0
  41. package/dist/metrics/options.js +257 -0
  42. package/dist/metrics/options.js.map +1 -0
  43. package/dist/metrics/run.js +72 -0
  44. package/dist/metrics/run.js.map +1 -0
  45. package/dist/platforms/azure/client.js +53 -0
  46. package/dist/platforms/azure/client.js.map +1 -0
  47. package/dist/platforms/azure/index.js +69 -0
  48. package/dist/platforms/azure/index.js.map +1 -0
  49. package/dist/platforms/azure/install.js +917 -0
  50. package/dist/platforms/azure/install.js.map +1 -0
  51. package/dist/platforms/azure/policy-types.js +70 -0
  52. package/dist/platforms/azure/policy-types.js.map +1 -0
  53. package/dist/platforms/azure/verify.js +309 -0
  54. package/dist/platforms/azure/verify.js.map +1 -0
  55. package/dist/platforms/detect.js +40 -0
  56. package/dist/platforms/detect.js.map +1 -0
  57. package/dist/platforms/github/client.js +49 -0
  58. package/dist/platforms/github/client.js.map +1 -0
  59. package/dist/platforms/github/index.js +54 -0
  60. package/dist/platforms/github/index.js.map +1 -0
  61. package/dist/platforms/github/install.js +558 -0
  62. package/dist/platforms/github/install.js.map +1 -0
  63. package/dist/platforms/github/push.js +102 -0
  64. package/dist/platforms/github/push.js.map +1 -0
  65. package/dist/platforms/github/remote.js +36 -0
  66. package/dist/platforms/github/remote.js.map +1 -0
  67. package/dist/platforms/github/verify.js +366 -0
  68. package/dist/platforms/github/verify.js.map +1 -0
  69. package/dist/platforms/http.js +58 -0
  70. package/dist/platforms/http.js.map +1 -0
  71. package/dist/platforms/pull-request-templates.js +157 -0
  72. package/dist/platforms/pull-request-templates.js.map +1 -0
  73. package/dist/platforms/remote.js +21 -0
  74. package/dist/platforms/remote.js.map +1 -0
  75. package/dist/platforms/resolve.js +69 -0
  76. package/dist/platforms/resolve.js.map +1 -0
  77. package/dist/platforms/shape.js +19 -0
  78. package/dist/platforms/shape.js.map +1 -0
  79. package/dist/platforms/types.js +24 -0
  80. package/dist/platforms/types.js.map +1 -0
  81. package/dist/policy/checks.js +91 -0
  82. package/dist/policy/checks.js.map +1 -0
  83. package/dist/policy/diff.js +50 -0
  84. package/dist/policy/diff.js.map +1 -0
  85. package/dist/registry/discover.js +74 -0
  86. package/dist/registry/discover.js.map +1 -0
  87. package/dist/registry/serialize.js +41 -0
  88. package/dist/registry/serialize.js.map +1 -0
  89. package/dist/registry/types.js +2 -0
  90. package/dist/registry/types.js.map +1 -0
  91. package/dist/remove/host.js +294 -0
  92. package/dist/remove/host.js.map +1 -0
  93. package/dist/render/commands.js +139 -0
  94. package/dist/render/commands.js.map +1 -0
  95. package/dist/render/manifest.js +82 -0
  96. package/dist/render/manifest.js.map +1 -0
  97. package/dist/render/markers.js +166 -0
  98. package/dist/render/markers.js.map +1 -0
  99. package/dist/render/profile.js +23 -0
  100. package/dist/render/profile.js.map +1 -0
  101. package/dist/render/standards.js +169 -0
  102. package/dist/render/standards.js.map +1 -0
  103. package/dist/render/vendors.js +199 -0
  104. package/dist/render/vendors.js.map +1 -0
  105. package/dist/review/engines/api.js +95 -0
  106. package/dist/review/engines/api.js.map +1 -0
  107. package/dist/review/engines/embedded.js +20 -0
  108. package/dist/review/engines/embedded.js.map +1 -0
  109. package/dist/review/engines/types.js +2 -0
  110. package/dist/review/engines/types.js.map +1 -0
  111. package/dist/review/glob.js +29 -0
  112. package/dist/review/glob.js.map +1 -0
  113. package/dist/review/prompt.js +45 -0
  114. package/dist/review/prompt.js.map +1 -0
  115. package/dist/review/rules.js +25 -0
  116. package/dist/review/rules.js.map +1 -0
  117. package/dist/review/schema.js +84 -0
  118. package/dist/review/schema.js.map +1 -0
  119. package/dist/review/scope.js +27 -0
  120. package/dist/review/scope.js.map +1 -0
  121. package/dist/sarif/map.js +58 -0
  122. package/dist/sarif/map.js.map +1 -0
  123. package/dist/sarif/parse.js +88 -0
  124. package/dist/sarif/parse.js.map +1 -0
  125. package/dist/sarif/types.js +2 -0
  126. package/dist/sarif/types.js.map +1 -0
  127. package/dist/sync/host.js +21 -0
  128. package/dist/sync/host.js.map +1 -0
  129. package/dist/sync/plan.js +47 -0
  130. package/dist/sync/plan.js.map +1 -0
  131. package/dist/sync/render.js +57 -0
  132. package/dist/sync/render.js.map +1 -0
  133. package/dist/sync/run.js +118 -0
  134. package/dist/sync/run.js.map +1 -0
  135. package/dist/verify/host.js +52 -0
  136. package/dist/verify/host.js.map +1 -0
  137. package/dist/verify/remote.js +146 -0
  138. package/dist/verify/remote.js.map +1 -0
  139. package/package.json +52 -0
  140. package/platforms/azure/gate-template.yml +105 -0
  141. package/rulesets/redline-org-ruleset.json +46 -0
  142. package/rulesets/redline-ruleset.json +49 -0
  143. package/scripts/assign-rule-ids.mjs +129 -0
  144. package/scripts/build-baseline.mjs +124 -0
  145. package/scripts/build-correlation.mjs +74 -0
  146. package/scripts/build-dashboard.mjs +584 -0
  147. package/scripts/build-digest.mjs +164 -0
  148. package/scripts/build-inbox.mjs +133 -0
  149. package/scripts/build-registry.mjs +42 -0
  150. package/scripts/build-roi.mjs +181 -0
  151. package/scripts/check-pins.mjs +88 -0
  152. package/scripts/collect-telemetry.mjs +300 -0
  153. package/scripts/lib/__tests__/baseline.test.mjs +132 -0
  154. package/scripts/lib/__tests__/correlate.test.mjs +131 -0
  155. package/scripts/lib/__tests__/dora.test.mjs +110 -0
  156. package/scripts/lib/__tests__/exemptions.test.mjs +85 -0
  157. package/scripts/lib/__tests__/metrics-scanner.test.mjs +65 -0
  158. package/scripts/lib/__tests__/sarif.test.mjs +125 -0
  159. package/scripts/lib/__tests__/spend.test.mjs +64 -0
  160. package/scripts/lib/baseline.mjs +156 -0
  161. package/scripts/lib/correlate.mjs +125 -0
  162. package/scripts/lib/dora.mjs +133 -0
  163. package/scripts/lib/exemptions.mjs +79 -0
  164. package/scripts/lib/metrics.mjs +172 -0
  165. package/scripts/lib/rules.mjs +107 -0
  166. package/scripts/lib/sarif.mjs +108 -0
  167. package/scripts/lib/spend.mjs +69 -0
  168. package/scripts/measure-context.mjs +101 -0
  169. package/scripts/render-self.mjs +18 -0
  170. package/scripts/score-seeds.mjs +294 -0
  171. package/scripts/validate.mjs +394 -0
  172. package/standards/core.md +124 -0
  173. package/standards/manifest.json +214 -0
  174. package/standards/stacks/csharp.md +29 -0
  175. package/standards/stacks/go.md +30 -0
  176. package/standards/stacks/java.md +30 -0
  177. package/standards/stacks/javascript.md +42 -0
  178. package/standards/stacks/kotlin.md +27 -0
  179. package/standards/stacks/microservices.md +37 -0
  180. package/standards/stacks/nodejs.md +34 -0
  181. package/standards/stacks/python.md +29 -0
  182. package/standards/stacks/react-native.md +29 -0
  183. package/standards/stacks/react.md +46 -0
  184. package/standards/stacks/swift.md +26 -0
  185. package/standards/stacks/terraform.md +27 -0
  186. package/templates/CODEOWNERS +29 -0
  187. package/templates/azure/pull_request_template.md +72 -0
  188. package/templates/github/pull_request_template.md +72 -0
  189. package/templates/redline.yml +35 -0
  190. package/templates/repo-context.md +64 -0
  191. package/workflows/dashboard.yml +119 -0
  192. package/workflows/inbox.yml +97 -0
  193. package/workflows/redline-collect.yml +61 -0
  194. package/workflows/redline-gate.yml +301 -0
  195. package/workflows/redline-sync.yml +79 -0
  196. package/workflows/seed-canary.yml +231 -0
  197. package/workflows/verify-onboarding.yml +115 -0
  198. package/workflows/weekly-digest.yml +78 -0
@@ -0,0 +1,615 @@
1
+ import { existsSync, readdirSync, readFileSync, rmSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { isRedlineError, RedlineError } from "../core/errors.js";
4
+ import { CLI_VERSION } from "../core/version.js";
5
+ import { canPromote } from "../enforce/ladder.js";
6
+ import { CAPABILITY_KEYS, CONFIG_FILE, MENU_KEYS, deselectedCapabilities, labelsCarriedByGate, readConfig, writeConfig, } from "../config/redline-json.js";
7
+ import { proposeProfile } from "../detect/stack.js";
8
+ import { scanRepo } from "../detect/scan.js";
9
+ import { loadManifest } from "../render/manifest.js";
10
+ import { resolveProfile } from "../render/profile.js";
11
+ import { render } from "../render/standards.js";
12
+ import { renderCommands, COMMAND_HOSTS } from "../render/commands.js";
13
+ import { LOCAL_RULES_FILE } from "../render/vendors.js";
14
+ import { isPending } from "../platforms/types.js";
15
+ export const DEFAULT_MENU = {
16
+ blockingGate: false,
17
+ adrForLargeDiffs: true,
18
+ accessibility: true,
19
+ speckit: false,
20
+ sensitivePathReviewers: true,
21
+ };
22
+ // Named once so the label FLOOR_GATE soft-fails on and the label
23
+ // openPullRequest applies below share one literal instead of two that could
24
+ // drift apart, and so web/components/journey.tsx's hardcoded SYNC_LABEL can
25
+ // be pinned against the real source (cli/render/__tests__/vendors.test.ts).
26
+ export const SYNC_LABEL = 'redline-sync';
27
+ export const DEFAULT_CAPABILITIES = {
28
+ gate: true,
29
+ mergePolicy: true,
30
+ labels: true,
31
+ };
32
+ export const FLOOR_GATE = {
33
+ adrDiffThreshold: 300,
34
+ failOnDependencySeverity: 'high',
35
+ softFailLabels: ['redline-exempt', SYNC_LABEL],
36
+ };
37
+ // Mirrors templates/CODEOWNERS. Two things are load-bearing here.
38
+ //
39
+ // The owner is org-scoped: GitHub reads a bare `@platform-engineering` as a
40
+ // *user*, and a user that does not exist makes GitHub mark the whole
41
+ // CODEOWNERS file erroneous — at which point `require_code_owner_review`
42
+ // degrades to the silent no-op this file exists to prevent. A team must be
43
+ // written `@org/team`.
44
+ //
45
+ // The rendered standards are owned too. Without them a contributor can edit
46
+ // AGENTS.md, CLAUDE.md or the Copilot instructions — the rules their own pull
47
+ // request is reviewed against — and self-merge the weakening.
48
+ //
49
+ // There is deliberately no `*` default-owner line, which templates/CODEOWNERS
50
+ // carries as an `@<org>/<owning-team>` placeholder: the CLI cannot know a
51
+ // repository's owning team, and naming the platform team there would make it
52
+ // a required reviewer on every file in every onboarded repository. The
53
+ // ruleset already requires one approval on every pull request.
54
+ export const SENSITIVE_PATHS = [
55
+ '/.github/workflows/',
56
+ '/.github/CODEOWNERS',
57
+ '/.github/copilot-instructions.md',
58
+ '/.github/instructions/',
59
+ '/.github/dependabot.yml',
60
+ '/AGENTS.md',
61
+ '/CLAUDE.md',
62
+ '/infra/',
63
+ '/terraform/',
64
+ 'Dockerfile',
65
+ ];
66
+ export const OWNING_TEAM = 'platform-engineering';
67
+ // Accessibility rules only exist for the stacks that render a user interface,
68
+ // so recording `accessibility: true` on a Terraform or Go repository files a
69
+ // commitment against rules that will never be rendered there.
70
+ const ACCESSIBILITY_STACKS = ['react', 'react-native', 'kotlin', 'swift'];
71
+ // The 2.1 artifact that identifies a repository onboarded by the previous
72
+ // generation. It is NOT in the removal list below: v3's GitHub adapter writes
73
+ // the same path, so removing it would delete the gate this run just installed
74
+ // — and for the same reason its presence alone does not prove a 2.1
75
+ // repository. A v3 repository whose .redline.json was deleted has this file
76
+ // too, and mistaking it for 2.1 would run the removals below against it.
77
+ const LEGACY_MARKER = '.github/workflows/redline.yml';
78
+ // What v3's own caller workflow contains and 2.1's shell rollout could not:
79
+ // the reusable-workflow reference that templates/redline.yml installs.
80
+ const V3_CALLER = /\.github\/workflows\/redline-gate\.yml@/;
81
+ // Everything 2.1 left behind that v3 does not write. Rendered vendor artifacts
82
+ // (`.github/instructions/redline-*.instructions.md`, `.cursor/rules/redline-*.mdc`)
83
+ // are not here: render() already prunes those as stale.
84
+ const LEGACY_PATHS = ['.github/workflows/redline-sync.yml'];
85
+ const LEGACY_SCRIPT = /^redline-.*\.sh$/;
86
+ // `scripts/redline-*.sh` is a glob, not a path, and a repository that adopted
87
+ // Redline is exactly the kind that has a hand-written `scripts/redline-deploy.sh`.
88
+ // The brownfield rule applies to files as much as to host objects: what carries
89
+ // no Redline marker belongs to a human and is never deleted.
90
+ const REDLINE_OWNED = /(?:managed|generated|installed) by redline|REDLINE:BEGIN/i;
91
+ export function sensitivePathRules(org) {
92
+ return SENSITIVE_PATHS.map((pattern) => ({ pattern, owners: [`@${org}/${OWNING_TEAM}`] }));
93
+ }
94
+ export const ONBOARD_BRANCH = 'redline/onboard';
95
+ // Local and free — both adapters read the checkout and nothing else — but the
96
+ // path it reads is whatever is on disk by now, and with the gate deselected
97
+ // `installGate` no longer runs first to meet an unreadable one. Everything it
98
+ // feeds here is advisory output, so a path that cannot be read costs the notes
99
+ // and never the run.
100
+ function observeGateMachinery(platform, cwd) {
101
+ try {
102
+ return platform.readGateMachinery(cwd);
103
+ }
104
+ catch {
105
+ return null;
106
+ }
107
+ }
108
+ // Every other pipeline definition sitting where this host keeps them. Cheap
109
+ // (one readdir) and unambiguous as a statement — it says what is there and
110
+ // nothing about what it does, which is the operator's to know.
111
+ function otherPipelines(cwd, machineryPath) {
112
+ const slash = machineryPath.lastIndexOf('/');
113
+ const dir = slash === -1 ? '' : machineryPath.slice(0, slash);
114
+ const abs = join(cwd, dir);
115
+ if (!existsSync(abs))
116
+ return [];
117
+ return readdirSync(abs)
118
+ .filter((file) => /\.ya?ml$/.test(file))
119
+ .map((file) => (dir === '' ? file : `${dir}/${file}`))
120
+ .filter((relPath) => relPath !== machineryPath);
121
+ }
122
+ // Deleted, not just unwritten: a 2.1 sync workflow left in place keeps running
123
+ // against a repository that has moved to v3. The deletions ride out in the
124
+ // same pull request as the rest of the migration.
125
+ function removeLegacyArtifacts(cwd, dryRun) {
126
+ const removed = [];
127
+ const remove = (relPath) => {
128
+ if (!existsSync(join(cwd, relPath)))
129
+ return;
130
+ if (!dryRun)
131
+ rmSync(join(cwd, relPath));
132
+ removed.push(relPath);
133
+ };
134
+ // Exact paths only: `.github/workflows/redline-sync.yml` is a Redline-named
135
+ // workflow at a Redline-owned path, not something a human names by accident.
136
+ for (const relPath of LEGACY_PATHS)
137
+ remove(relPath);
138
+ if (existsSync(join(cwd, 'scripts'))) {
139
+ for (const file of readdirSync(join(cwd, 'scripts'))) {
140
+ if (!LEGACY_SCRIPT.test(file))
141
+ continue;
142
+ if (!REDLINE_OWNED.test(readFileSync(join(cwd, 'scripts', file), 'utf8')))
143
+ continue;
144
+ remove(`scripts/${file}`);
145
+ }
146
+ }
147
+ return removed;
148
+ }
149
+ // A 2.1 repository has the caller workflow and no .redline.json. A v3
150
+ // repository whose config was deleted has the caller workflow too — telling
151
+ // them apart is what stops the removals above running on a repository that
152
+ // never saw 2.1.
153
+ function detectMigration(cwd, onboarded) {
154
+ if (onboarded)
155
+ return null;
156
+ const caller = join(cwd, LEGACY_MARKER);
157
+ if (!existsSync(caller))
158
+ return null;
159
+ return V3_CALLER.test(readFileSync(caller, 'utf8')) ? null : '2.1';
160
+ }
161
+ // Detect-before-ask: a repository's existing tooling files pick the default
162
+ // vendor selection, so a Copilot-only team is not handed AGENTS.md and
163
+ // CLAUDE.md on day one. Only used when nothing else has decided already — see
164
+ // the precedence comment on `vendors` in init() below.
165
+ const VENDOR_MARKERS = [
166
+ { vendor: 'copilot', paths: ['.github/copilot-instructions.md', '.github/instructions'] },
167
+ { vendor: 'claude', paths: ['CLAUDE.md', '.claude'] },
168
+ { vendor: 'agents', paths: ['AGENTS.md'] },
169
+ { vendor: 'cursor', paths: ['.cursor/rules'] },
170
+ ];
171
+ // A repository with none of these markers gets `orgDefault` (every
172
+ // org-enabled vendor) rather than an empty selection — that is the greenfield
173
+ // case the standard is written for, not a repository that opted out of all of
174
+ // them.
175
+ function detectVendors(cwd, orgDefault) {
176
+ const found = VENDOR_MARKERS.filter((marker) => marker.paths.some((relPath) => existsSync(join(cwd, relPath)))).map((marker) => marker.vendor);
177
+ return found.length > 0 ? found : orgDefault;
178
+ }
179
+ // `pendingAdmin` records one fact and one only: a WRITE this run attempted was
180
+ // refused. Every entry is produced by `outcomes.filter(isPending)` further
181
+ // down, off what the four install calls returned. No read revises it, in either
182
+ // direction, for any capability — not `labels`, `review-ownership`,
183
+ // `repo-property` or `gate` (which have no read side at all), not
184
+ // `merge-policy` (whose `readPolicy` answers "a ruleset with Redline's name
185
+ // exists", never "this token may write one" — on GitHub those split exactly
186
+ // along GET /rulesets versus PUT /rulesets/{id}), and not the three security
187
+ // capabilities either.
188
+ //
189
+ // The security three look reconcilable and are not. `readSecurityState`
190
+ // answers "is the setting on?"; the record answers "was this token allowed to
191
+ // set it?". A fine-grained GitHub token with `administration: read` reads
192
+ // GET /vulnerability-alerts as 204 while PUT /automated-security-fixes answers
193
+ // 403; an Azure PAT with `vso.advsec` but no Project Administrator role reads
194
+ // `advSecEnabled: true` while the PATCH is refused, for all three at once.
195
+ // Letting the read clear or create an entry made the settled path disagree
196
+ // with what the apply path would record, so the two answers chased each other:
197
+ // the read cleared the entry, the refused write re-recorded it, and every run
198
+ // re-applied four host mutations and pushed another commit onto the onboarding
199
+ // pull request, exiting 0 throughout.
200
+ //
201
+ // The accepted cost of the uniform rule: a recorded entry survives even after
202
+ // an administrator grants the rights, because nothing re-applies and nothing
203
+ // reads write-permission back. `redline init --repair` is the sanctioned way
204
+ // out — it is what `redline verify`'s pending-admin finding points at — and
205
+ // the already-onboarded output qualifies the list as recorded at the last run.
206
+ export async function init(platform, opts) {
207
+ const { cwd, root } = opts;
208
+ const dryRun = opts.dryRun === true;
209
+ const repair = opts.repair === true;
210
+ const manifest = loadManifest(root);
211
+ const now = opts.now ?? (() => new Date());
212
+ // Profile resolution happens before any host call or write: a bad --profile
213
+ // flag must fail clean, with nothing on disk and nothing sent to the host.
214
+ const detected = opts.profile ?? proposeProfile(scanRepo(cwd)).profile;
215
+ const { profile, stacks } = resolveProfile(manifest, detected);
216
+ const existing = readConfig(cwd);
217
+ const migratedFrom = detectMigration(cwd, existing !== null);
218
+ // DEFAULT_MENU <- what this repository already chose <- the flags the caller
219
+ // actually typed. Rebuilding the menu from flag defaults alone demoted a
220
+ // `--blocking` repository back to advisory on the next plain `redline init`
221
+ // — and did it before the no-op check, so even a run with nothing to commit
222
+ // rewrote the live ruleset while .redline.json still claimed blocking.
223
+ const menu = {
224
+ ...DEFAULT_MENU,
225
+ accessibility: stacks.some((stack) => ACCESSIBILITY_STACKS.includes(stack)),
226
+ ...existing?.menu,
227
+ ...opts.menu,
228
+ };
229
+ // DEFAULT_CAPABILITIES <- what this repository already chose <- what the
230
+ // caller typed, the same precedence the menu resolves under.
231
+ const capabilities = {
232
+ ...DEFAULT_CAPABILITIES,
233
+ ...existing?.capabilities,
234
+ ...opts.capabilities,
235
+ };
236
+ // The rung, resolved before anything is written. A run that says nothing about
237
+ // enforcement keeps what the repository already had: a re-run for an unrelated
238
+ // reason silently promoting a repository is how a ladder loses the trust it
239
+ // exists to build.
240
+ const currentRung = existing?.rung ?? 'observe';
241
+ const rungNotes = [];
242
+ let rung = currentRung;
243
+ if (opts.rung !== undefined && opts.rung !== currentRung) {
244
+ const check = canPromote(currentRung, opts.rung, opts.evidence ?? { seedRecall: null, actedOnRate: null, sampleSize: 0, falsePositives: null }, opts.marketFloor ?? 'observe');
245
+ if (check.eligible) {
246
+ rung = opts.rung;
247
+ rungNotes.push(`enforcement: ${currentRung} -> ${rung}`);
248
+ }
249
+ else {
250
+ // Refused, and the run continues. Everything else this command does is
251
+ // still worth doing, and failing the whole onboarding over a rung the
252
+ // repository cannot reach yet would teach people to stop asking.
253
+ rungNotes.push(`enforcement stays at ${currentRung} — cannot move to ${opts.rung}:`);
254
+ for (const blocker of check.blockers)
255
+ rungNotes.push(` ${blocker}`);
256
+ }
257
+ }
258
+ // Refused before a host is contacted or a byte is written, because the state
259
+ // it describes cannot be recovered from by re-running: with no gate
260
+ // machinery nothing in the repository publishes the required check, and a
261
+ // blocking policy that requires a check nothing publishes blocks every pull
262
+ // request in the repository forever. A repository that runs its own gate
263
+ // wants its own branch policy too — `--skip gate --skip merge-policy` — or
264
+ // an advisory Redline policy alongside it.
265
+ if (!capabilities.gate && capabilities.mergePolicy && menu.blockingGate) {
266
+ throw new RedlineError('usage', 'the merge gate is deselected, so nothing in this repository publishes the check a blocking ' +
267
+ 'policy would require — every pull request would be blocked', 'either keep the gate, or add --skip merge-policy so this repository keeps its own branch policy');
268
+ }
269
+ // A dry run must work offline and with an unscoped token: repoRef() is a
270
+ // live GET, so the plan is built from what the local clone already knows.
271
+ const ref = dryRun ? platform.localRef(cwd) : await platform.repoRef(cwd);
272
+ // detected <- what this repository already recorded <- what the caller
273
+ // typed, the same precedence the menu resolves under. The org ceiling is
274
+ // deliberately not applied to the RECORD: render() enforces it on every call
275
+ // it makes (including verify's), so a recorded selection can outlive an
276
+ // org-side disablement without this function needing to track that.
277
+ const orgVendors = Object.entries(manifest.vendors)
278
+ .filter(([, v]) => v.enabled)
279
+ .map(([k]) => k);
280
+ const vendors = opts.vendors ?? existing?.vendors ?? detectVendors(cwd, orgVendors);
281
+ const gateOptions = {
282
+ ...FLOOR_GATE,
283
+ ...(menu.adrForLargeDiffs ? {} : { adrDiffThreshold: Number.MAX_SAFE_INTEGER }),
284
+ ...(opts.adoptCaller === true ? { adoptCaller: true } : {}),
285
+ ...(capabilities.labels ? {} : { manageLabels: false }),
286
+ // Written into the caller workflow, so the gate blocks or reports according
287
+ // to the rung recorded here rather than needing a second source of truth.
288
+ rung,
289
+ };
290
+ const ownershipRules = sensitivePathRules(ref.org);
291
+ // The gate and ownership file diffs are computed in check mode FIRST, before
292
+ // a single host setting is touched. Without it there was no way to know a
293
+ // re-run had nothing to do until four host objects had already been
294
+ // rewritten — and the answer itself was wrong, because alreadyOnboarded read
295
+ // only the rendered files and never these two.
296
+ //
297
+ // It also runs before the first byte reaches the working tree. `installGate`
298
+ // refuses rather than clobber a gate machinery file it cannot attribute to
299
+ // Redline, and its message says nothing was written; planning after the
300
+ // render made that untrue, leaving every vendor artifact and command file on
301
+ // disk with no .redline.json, no branch and no pull request to carry them.
302
+ const gatePlan = capabilities.gate
303
+ ? await platform.installGate(ref, cwd, gateOptions, true)
304
+ : { files: [], outcomes: [] };
305
+ const ownershipPlan = menu.sensitivePathReviewers
306
+ ? await platform.ensureReviewOwnership(ref, cwd, ownershipRules, true)
307
+ : { files: [], outcomes: [] };
308
+ // Everything this run observed and thinks the operator should know, without
309
+ // acting on any of it. Detection informs; it does not decide.
310
+ const machinery = observeGateMachinery(platform, cwd);
311
+ const notes = [...rungNotes];
312
+ // Detection, not a decision. `readGateMachinery` is local and free, and what
313
+ // it gives that nothing else here has is the path this host runs its gate
314
+ // from — so the only claim made is what else is already sitting in that
315
+ // directory. It is offered while Redline's own gate is still absent and
316
+ // never after, because a repository that already has it has answered the
317
+ // question.
318
+ const alreadyWired = capabilities.gate && machinery !== null && !machinery.present
319
+ ? otherPipelines(cwd, machinery.path)
320
+ : [];
321
+ if (alreadyWired.length > 0) {
322
+ notes.push(`this repository already has ${alreadyWired.join(', ')} — if one of them is already your ` +
323
+ 'merge gate, re-run with --skip gate and Redline will leave it in charge rather than ' +
324
+ 'writing a second one beside it');
325
+ }
326
+ // Deselecting the gate does not delete the workflow an earlier run installed
327
+ // — deleting a repository's files is not Redline's to do — so it is still
328
+ // there and still firing on every pull request. Saying only "opted out: gate"
329
+ // beside a running gate describes a state this repository is not in, and
330
+ // invites the operator to go and delete it by hand.
331
+ if (!capabilities.gate && machinery !== null && machinery.present) {
332
+ notes.push(`${machinery.path} from an earlier run is still in this repository and still publishes ` +
333
+ `${machinery.expected} — Redline no longer maintains it; it is yours to keep or delete`);
334
+ }
335
+ // The other half of the deadlock guard, and the half a refusal cannot cover:
336
+ // the guard only sees a blocking policy this run would apply, so deselecting
337
+ // the merge policy walks straight past it and leaves a Redline ruleset
338
+ // blocking on a check that, with the gate deselected too, nothing will ever
339
+ // publish. The policy is the repository's now, so this is not a refusal — but
340
+ // it is the last place anyone hears about it before a pull request hangs.
341
+ if (!capabilities.mergePolicy &&
342
+ menu.blockingGate &&
343
+ existing !== null &&
344
+ !existing.pendingAdmin.includes('merge-policy')) {
345
+ notes.push('the merge policy Redline applied here is blocking and is no longer maintained by Redline — ' +
346
+ 'it still requires the Redline gate check, so relax or delete it on the host unless ' +
347
+ 'something in this repository still publishes that check');
348
+ }
349
+ if (labelsCarriedByGate(capabilities)) {
350
+ notes.push("labels are created by the gate install, so a deselected gate takes Redline's labels with " +
351
+ 'it — the selection recorded in .redline.json is unchanged, and re-selecting the gate ' +
352
+ 'brings them back');
353
+ }
354
+ // Files next, host settings after: a denied host call must never cost the
355
+ // file-level work that already succeeded.
356
+ const rendered = render({ root, profile, out: cwd, vendors, check: dryRun });
357
+ // The ceiling render() applies internally, applied here too. renderCommands
358
+ // cannot enforce it for itself: COMMAND_HOSTS carries hosts the vendor
359
+ // manifest has no entry for at all (opencode), which is not the same thing
360
+ // as a vendor the org switched off. Without this, `redline init --vendors
361
+ // copilot,cursor` skipped .cursor/rules/ and still wrote .cursor/commands/,
362
+ // delivering half of a vendor the org had disabled.
363
+ const commands = renderCommands({
364
+ root,
365
+ out: cwd,
366
+ hosts: vendors.flatMap((v) => (orgVendors.includes(v) && v in COMMAND_HOSTS ? [v] : [])),
367
+ check: dryRun,
368
+ known: existing?.commandFiles ?? {},
369
+ });
370
+ const legacyRemovals = migratedFrom === '2.1' ? removeLegacyArtifacts(cwd, dryRun) : [];
371
+ // render() prunes stale vendor files with rmSync; those deletions must ride
372
+ // along in the same file list as the writes, or the PR never reflects them.
373
+ const removals = [
374
+ ...(dryRun ? rendered.staleRemovals : rendered.removed),
375
+ ...commands.removed,
376
+ ...legacyRemovals,
377
+ ];
378
+ const changedFiles = [
379
+ ...(dryRun ? rendered.staleWritten : rendered.written),
380
+ ...removals,
381
+ ...commands.written,
382
+ ...gatePlan.files,
383
+ ...ownershipPlan.files,
384
+ ];
385
+ // A menu change moves no file of its own (the gate template already diffs
386
+ // adrForLargeDiffs), but it is exactly what `redline init --blocking` on a
387
+ // settled repository is for: swallowing it as "nothing to change" would drop
388
+ // the promotion silently.
389
+ const menuChanged = existing !== null && MENU_KEYS.some((key) => existing.menu[key] !== menu[key]);
390
+ // Same shape as menuChanged: a vendor deselect that has nothing left on
391
+ // disk to remove (the file was already gone) moves no file of its own, and
392
+ // swallowing it as "nothing to change" would leave .redline.json recording
393
+ // a selection this run was explicitly told to drop.
394
+ const vendorsChanged = existing !== null &&
395
+ (existing.vendors.length !== vendors.length ||
396
+ [...existing.vendors].sort().join('') !== [...vendors].sort().join(''));
397
+ // Same shape again: deselecting a capability moves no file of its own, and
398
+ // swallowing it as "nothing to change" would leave .redline.json recording a
399
+ // capability the operator just switched off — with Redline still maintaining it.
400
+ const capabilitiesChanged = existing !== null &&
401
+ CAPABILITY_KEYS.some((key) => existing.capabilities[key] !== capabilities[key]);
402
+ // "Zero host calls on a settled repository" means zero host *mutations*.
403
+ // Reading is how the run finds out whether the repository is settled at all:
404
+ // without it, an operator who loosened the ruleset by hand got "already
405
+ // onboarded — nothing to change" from `redline init` AND from
406
+ // `redline init --blocking` (the config already said blocking, so nothing
407
+ // looked changed), and the only recovery was deleting .redline.json — which
408
+ // destroys onboardedAt, the recorded menu, and makes this run look like a
409
+ // 2.1 migration.
410
+ //
411
+ // The read happens only when nothing else has already settled the question.
412
+ // It exists to decide whether a run with no other work to do is genuinely
413
+ // finished, so a run that already has work does not need it — and must not
414
+ // be aborted by it: a 502 on GET /rulesets, or a token that can write but
415
+ // cannot list rulesets, would otherwise exit 4 on a run that had real work
416
+ // and had already written the rendered files.
417
+ // `--repair` exists precisely to bypass the settled verdict below, so
418
+ // computing it here would spend a host GET whose answer nothing then reads:
419
+ // `alreadyOnboarded` is forced false for a repair run further down, never
420
+ // mind what the read would have said.
421
+ const settledOnFiles = existing !== null &&
422
+ changedFiles.length === 0 &&
423
+ !menuChanged &&
424
+ !vendorsChanged &&
425
+ !capabilitiesChanged;
426
+ let settledOnHost = true;
427
+ if (existing !== null && settledOnFiles && !dryRun && !repair) {
428
+ // Not read at all when the repository manages its own merge policy: what
429
+ // is on the host then is a human's, and comparing Redline's menu against
430
+ // it would report the repository's own deliberate configuration as drift.
431
+ const policy = capabilities.mergePolicy ? await platform.readPolicy(ref) : null;
432
+ // A null policy read is not by itself drift. A repository onboarded
433
+ // without admin rights never got a ruleset — that refusal is exactly what
434
+ // `merge-policy` in pendingAdmin records — so null is its settled state.
435
+ // Where the record says the ruleset was applied, null means it vanished.
436
+ settledOnHost = !capabilities.mergePolicy
437
+ ? true
438
+ : policy === null
439
+ ? existing.pendingAdmin.includes('merge-policy')
440
+ : policy.blocking === menu.blockingGate;
441
+ }
442
+ // `--repair` skips the short-circuit outright: it exists for exactly the
443
+ // capabilities this settled verdict would otherwise call done forever —
444
+ // labels, review-ownership, repo-property, gate, and merge-policy's own
445
+ // null branch above — none of which a plain re-run can ever re-check.
446
+ // A rung change is work, so it must not be swallowed by the settled verdict.
447
+ // Without this an operator promoting an already-onboarded repository gets
448
+ // "nothing to change" and a rung that never moved — the flag silently doing
449
+ // nothing, which is worse than refusing.
450
+ const rungRequested = rung !== currentRung || rungNotes.length > 0;
451
+ const alreadyOnboarded = !repair && !rungRequested && settledOnFiles && settledOnHost;
452
+ const optedOut = deselectedCapabilities(menu, capabilities);
453
+ const hostPlan = [
454
+ ...(capabilities.gate ? [`merge gate machinery on ${platform.host}`] : []),
455
+ ...(menu.sensitivePathReviewers ? ['review ownership for the sensitive paths'] : []),
456
+ 'security floor: secret scanning, push protection, dependency alerts',
457
+ ...(capabilities.mergePolicy
458
+ ? [`branch policy: 1 approval, gate ${menu.blockingGate ? 'blocking' : 'advisory'}`]
459
+ : []),
460
+ `pull request on ${ONBOARD_BRANCH}`,
461
+ ];
462
+ if (alreadyOnboarded) {
463
+ return {
464
+ profile,
465
+ files: [],
466
+ removals: [],
467
+ outcomes: [],
468
+ // Exactly what .redline.json records, because this run attempted no
469
+ // write and only a write answers the question the record asks. `bin`
470
+ // marks it as recorded rather than measured.
471
+ pendingAdmin: existing.pendingAdmin,
472
+ pullRequest: null,
473
+ pullRequestError: null,
474
+ migratedFrom,
475
+ alreadyOnboarded: true,
476
+ dryRun,
477
+ menu,
478
+ capabilities,
479
+ optedOut,
480
+ notes,
481
+ hostPlan,
482
+ };
483
+ }
484
+ const files = [...changedFiles, CONFIG_FILE];
485
+ if (dryRun) {
486
+ return {
487
+ profile,
488
+ files,
489
+ removals,
490
+ // installGate's plan reports no outcome (it made no host call);
491
+ // ensureReviewOwnership's are decided locally and worth printing.
492
+ outcomes: [...gatePlan.outcomes, ...ownershipPlan.outcomes],
493
+ pendingAdmin: [],
494
+ pullRequest: null,
495
+ pullRequestError: null,
496
+ migratedFrom,
497
+ alreadyOnboarded: false,
498
+ dryRun: true,
499
+ menu,
500
+ capabilities,
501
+ optedOut,
502
+ notes,
503
+ hostPlan,
504
+ };
505
+ }
506
+ const gate = capabilities.gate
507
+ ? await platform.installGate(ref, cwd, gateOptions)
508
+ : { files: [], outcomes: [] };
509
+ const ownership = menu.sensitivePathReviewers
510
+ ? await platform.ensureReviewOwnership(ref, cwd, ownershipRules)
511
+ : { files: [], outcomes: [] };
512
+ const security = await platform.enableSecurityFloor(ref);
513
+ const policy = capabilities.mergePolicy
514
+ ? await platform.applyPolicy(ref, {
515
+ requiredApprovals: 1,
516
+ dismissStaleReviews: true,
517
+ requireCodeOwnerReview: menu.sensitivePathReviewers,
518
+ requireThreadResolution: true,
519
+ // Empty by design: the required check is the host's own gate check
520
+ // name, and each adapter supplies it (GitHub's REQUIRED_CHECK, Azure's
521
+ // AZURE_STATUS_NAME/GENRE). requiredChecks is the read side of
522
+ // MergePolicy — what verify reports back off the host.
523
+ requiredChecks: [],
524
+ blocking: menu.blockingGate,
525
+ })
526
+ : { outcomes: [], policy: null };
527
+ // denied -> pendingAdmin work for an administrator; unsupported -> the
528
+ // capability doesn't exist on this repository (e.g. Advanced Security is
529
+ // unlicensed) and must never be reported as permanently half-onboarded.
530
+ const outcomes = [...gate.outcomes, ...ownership.outcomes, ...security.outcomes, ...policy.outcomes];
531
+ const pendingAdmin = outcomes.filter(isPending).map((o) => o.capability);
532
+ writeConfig(cwd, {
533
+ standardsVersion: manifest.version,
534
+ cliVersion: CLI_VERSION,
535
+ host: platform.host,
536
+ profile,
537
+ vendors,
538
+ menu,
539
+ capabilities,
540
+ pendingAdmin,
541
+ // When the repository joined, not when it was last touched: overwriting
542
+ // this on every run erased the only record of when the standard landed.
543
+ onboardedAt: existing?.onboardedAt ?? now().toISOString(),
544
+ lastRunAt: now().toISOString(),
545
+ localRules: existsSync(join(cwd, LOCAL_RULES_FILE)),
546
+ commandFiles: commands.contentIds,
547
+ // The rung the repository asked for, or the one it already had, or the
548
+ // bottom. A run that says nothing about enforcement must never change it:
549
+ // a re-run for an unrelated reason silently promoting a repository is how a
550
+ // ladder loses the trust it exists to build.
551
+ rung,
552
+ });
553
+ let pullRequest = null;
554
+ let pullRequestError = null;
555
+ try {
556
+ pullRequest = await platform.openPullRequest(ref, cwd, {
557
+ branch: ONBOARD_BRANCH,
558
+ title: `chore(redline): onboard to standards v${manifest.version}`,
559
+ body: onboardBody(profile, manifest.version, pendingAdmin),
560
+ labels: capabilities.labels ? [SYNC_LABEL] : [],
561
+ files,
562
+ });
563
+ }
564
+ catch (error) {
565
+ // A usage refusal — a dirty git index — happens before any branch exists
566
+ // and before anything is pushed. That stays the caller's input error, not
567
+ // a half-finished onboarding.
568
+ if (isRedlineError(error) && error.kind === 'usage')
569
+ throw error;
570
+ // Everything else: the host mutations and .redline.json above are real and
571
+ // must not be thrown away. The operator is told where the work sits.
572
+ pullRequestError = error instanceof Error ? error.message : String(error);
573
+ }
574
+ // Work that only exists once the pull request does — labelling it. It is
575
+ // reported, but it cannot reach pendingAdmin: .redline.json records that
576
+ // list and is itself part of the pull request, so it was written above.
577
+ if (pullRequest?.outcomes)
578
+ outcomes.push(...pullRequest.outcomes);
579
+ return {
580
+ profile,
581
+ files,
582
+ removals,
583
+ outcomes,
584
+ pendingAdmin,
585
+ pullRequest,
586
+ pullRequestError,
587
+ migratedFrom,
588
+ alreadyOnboarded: false,
589
+ dryRun: false,
590
+ menu,
591
+ capabilities,
592
+ optedOut,
593
+ notes,
594
+ hostPlan,
595
+ };
596
+ }
597
+ function onboardBody(profile, version, pendingAdmin) {
598
+ const pending = pendingAdmin.length === 0
599
+ ? 'Everything that needed repository settings was applied.'
600
+ : `A repository administrator still needs to enable: ${pendingAdmin.join(', ')}. ` +
601
+ `Until then this repository shows as partially onboarded.`;
602
+ return [
603
+ `Onboards this repository to Redline standards \`v${version}\` (profile: \`${profile}\`).`,
604
+ '',
605
+ 'The merge gate runs **advisory** — it reports, it does not block. Promotion to blocking is a',
606
+ 'deliberate second step after a soak period.',
607
+ '',
608
+ 'Generated content sits inside `<!-- REDLINE:BEGIN -->` markers; anything outside them is yours',
609
+ 'and was preserved. If a rule is wrong for this repository, raise it in the Redline source repo',
610
+ 'rather than editing it here, so every repository benefits.',
611
+ '',
612
+ pending,
613
+ ].join('\n');
614
+ }
615
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../cli/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAA4B,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACL,eAAe,EACf,WAAW,EACX,SAAS,EACT,sBAAsB,EACtB,mBAAmB,EACnB,UAAU,EACV,WAAW,GAGZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAWlD,MAAM,CAAC,MAAM,YAAY,GAAmB;IAC1C,YAAY,EAAE,KAAK;IACnB,gBAAgB,EAAE,IAAI;IACtB,aAAa,EAAE,IAAI;IACnB,OAAO,EAAE,KAAK;IACd,sBAAsB,EAAE,IAAI;CAC7B,CAAC;AAEF,iEAAiE;AACjE,4EA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