@ultimat3/cli 31.27.0 → 31.29.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 (134) hide show
  1. package/CLAUDE.md +4 -1
  2. package/README.md +14 -4
  3. package/package.json +29 -29
  4. package/src/app-manifest.ts +6 -1
  5. package/src/app-migrations-verdict.ts +84 -0
  6. package/src/cmd-doctor.ts +11 -3
  7. package/src/cmd-drill.ts +23 -9
  8. package/src/cmd-repro-spec.ts +13 -1
  9. package/src/cmd-repro.ts +37 -5
  10. package/src/cmd-upgrade-codemods.ts +71 -0
  11. package/src/cmd-upgrade-spec.ts +19 -5
  12. package/src/cmd-upgrade.ts +91 -34
  13. package/src/codemods/agents-dev-mcp.ts +50 -0
  14. package/src/codemods/authenticator-session-refusal.ts +214 -0
  15. package/src/codemods/biome-no-default-export.ts +58 -0
  16. package/src/codemods/bunfig-island-coverage.ts +33 -0
  17. package/src/codemods/chart-dashboard.ts +73 -0
  18. package/src/codemods/ci-e2e-browser-stock.ts +75 -0
  19. package/src/codemods/ci-e2e-browser.ts +63 -0
  20. package/src/codemods/codemod.ts +58 -0
  21. package/src/codemods/define-error-leaf.ts +73 -0
  22. package/src/codemods/docs-ci-parts.ts +65 -0
  23. package/src/codemods/docs-gate-prose.ts +53 -0
  24. package/src/codemods/docs-island-rows.ts +31 -0
  25. package/src/codemods/docs-shipped-guards.ts +100 -0
  26. package/src/codemods/docs-test-services.ts +62 -0
  27. package/src/codemods/engine-diff.ts +104 -0
  28. package/src/codemods/engine-edits.ts +111 -0
  29. package/src/codemods/engine-fs.ts +95 -0
  30. package/src/codemods/engine.ts +191 -0
  31. package/src/codemods/format-edited-hook-3122.ts +28 -0
  32. package/src/codemods/format-edited-hook.ts +152 -0
  33. package/src/codemods/helm-alerts-deploy.ts +85 -0
  34. package/src/codemods/helm-alerts-objective.ts +105 -0
  35. package/src/codemods/helm-alerts-stock.ts +108 -0
  36. package/src/codemods/index.ts +60 -0
  37. package/src/codemods/metrics-probe-healthz.ts +47 -0
  38. package/src/codemods/migrate-job-ordered.ts +81 -0
  39. package/src/codemods/migrate-job-stock.ts +41 -0
  40. package/src/codemods/pending.ts +36 -0
  41. package/src/codemods/repro-gitignore.ts +40 -0
  42. package/src/codemods/runtime-pin-lines.ts +109 -0
  43. package/src/codemods/runtime-pin.ts +116 -0
  44. package/src/codemods/solid-floor.ts +63 -0
  45. package/src/codemods/test-ports.ts +86 -0
  46. package/src/codemods/test-suites.ts +37 -0
  47. package/src/codemods/theme-toggle-mount-over.ts +70 -0
  48. package/src/codemods/vendored-guards.ts +186 -0
  49. package/src/codemods/verify-floor-skips.ts +88 -0
  50. package/src/codemods/verify-floor-steps.ts +90 -0
  51. package/src/doctor-advisory-floors.ts +113 -0
  52. package/src/doctor-guards.ts +39 -86
  53. package/src/doctor-superseded.ts +67 -0
  54. package/src/drill-schema-behind.ts +26 -0
  55. package/src/error-codes-doctor.ts +12 -4
  56. package/src/error-codes.ts +9 -0
  57. package/src/exercise-database.ts +7 -2
  58. package/src/framework-schema-apply.ts +7 -19
  59. package/src/framework-schema-stamp.ts +38 -3
  60. package/src/framework-schema-verify.ts +120 -0
  61. package/src/framework-schema-wait.ts +125 -0
  62. package/src/generate-files.ts +6 -5
  63. package/src/guards-built-in-codes.ts +36 -0
  64. package/src/guards-built-in-refusal.ts +25 -0
  65. package/src/guards-built-in.ts +134 -0
  66. package/src/guards-materialize.ts +42 -0
  67. package/src/guards-paths.ts +37 -0
  68. package/src/guards-shipped-names.ts +38 -0
  69. package/src/guards-vendored.ts +73 -0
  70. package/src/guards.ts +90 -34
  71. package/src/index.ts +10 -0
  72. package/src/lint-findings.ts +3 -3
  73. package/src/mcp-errors.ts +12 -1
  74. package/src/measure-scope.ts +23 -3
  75. package/src/messages-repro.ts +16 -2
  76. package/src/messages-upgrade.ts +15 -0
  77. package/src/messages.ts +1 -1
  78. package/src/repro-archive-collect.ts +161 -0
  79. package/src/repro-archive-write.ts +96 -0
  80. package/src/repro-archive.ts +161 -0
  81. package/src/repro-bundle.ts +8 -16
  82. package/src/repro-errors.ts +14 -2
  83. package/src/repro-framework.ts +53 -0
  84. package/src/repro-parse.ts +87 -0
  85. package/src/repro-redact.ts +218 -0
  86. package/src/repro-scrub.ts +257 -0
  87. package/src/role-pg-stats.ts +21 -0
  88. package/src/role-start.ts +4 -0
  89. package/src/runtime-queue.ts +27 -6
  90. package/src/serve-boot-probe.ts +97 -0
  91. package/src/serve-boot.ts +26 -1
  92. package/src/serve-retire.ts +16 -3
  93. package/src/superseded-match.ts +87 -0
  94. package/src/superseded.ts +84 -0
  95. package/src/templates/bun-image.ts +48 -0
  96. package/src/templates/chart-dashboard-panels.ts +178 -0
  97. package/src/templates/chart-dashboard.ts +9 -135
  98. package/src/templates/github/ci.yml.ts +1 -1
  99. package/src/templates/guard-released-forms.ts +112 -0
  100. package/src/templates/guard-runtime-pin-test.ts +54 -0
  101. package/src/templates/guard-runtime-pin.ts +189 -0
  102. package/src/templates/scaffold-claude-agents.ts +6 -6
  103. package/src/templates/scaffold-claude-commands.ts +1 -1
  104. package/src/templates/scaffold-claude-hook.ts +18 -8
  105. package/src/templates/scaffold-claude.ts +2 -2
  106. package/src/templates/scaffold-container.ts +2 -2
  107. package/src/templates/scaffold-docs.ts +26 -24
  108. package/src/templates/scaffold-guards.ts +73 -39
  109. package/src/templates/scaffold-helm-alert-deploy.ts +105 -0
  110. package/src/templates/scaffold-helm-alert-rules.ts +7 -1
  111. package/src/templates/scaffold-helm-alerts.ts +3 -0
  112. package/src/templates/scaffold-helm-migrate.ts +85 -0
  113. package/src/templates/scaffold-helm-templates.ts +2 -36
  114. package/src/templates/scaffold-helm.ts +1 -0
  115. package/src/templates/scaffold-repo.ts +2 -1
  116. package/src/unthrown-codes.ts +2 -0
  117. package/src/upgrade-bun-floor.ts +4 -0
  118. package/src/upgrade-clean-tree.ts +54 -0
  119. package/src/upgrade-gate-codemods-install.ts +40 -0
  120. package/src/upgrade-gate-codemods.ts +151 -0
  121. package/src/upgrade-gate.ts +38 -6
  122. package/src/upgrade-lock.ts +118 -0
  123. package/src/upgrade-plan.ts +2 -1
  124. package/src/upgrade-report-codemods.ts +54 -0
  125. package/src/upgrade-report.ts +52 -27
  126. package/src/upgrade-signals.ts +91 -0
  127. package/src/upgrade-unfinished.ts +61 -0
  128. package/wiki/CLI-Reference.md +70 -5
  129. package/wiki/Deployment.md +2 -1
  130. package/wiki/Interface-Rules.md +17 -8
  131. package/wiki/Known-Gaps.md +1 -1
  132. package/wiki/Observability.md +1 -0
  133. package/wiki/Project-Layout.md +4 -4
  134. package/wiki/Upgrading.md +6 -0
@@ -0,0 +1,85 @@
1
+ // 31.29.0: the chart's alerts gain the deploy-contract rules (latency, the Postgres server, the
2
+ // framework schema, volumes) and its dashboard their panels. Each file, still exactly as 31.18.0
3
+ // through 31.28.x wrote it (recognised by hash), is replaced whole; one the app edited is reported.
4
+
5
+ import { CHART_FILE } from '../generate-chart-alerts';
6
+ import { DASHBOARD_FILE, dashboardJson } from '../templates/chart-dashboard';
7
+ import { names } from '../templates/naming';
8
+ import { helmMonitoringFiles } from '../templates/scaffold-helm-alerts';
9
+ import { chartName } from './chart-dashboard';
10
+ import type { Codemod, CodemodApp, CodemodResult } from './codemod';
11
+ import { unifiedDiff } from './engine-diff';
12
+ import { mergeResults, readText } from './engine-edits';
13
+
14
+ export const RULES_FILE = 'docker/helm/templates/alert-rules.yaml';
15
+
16
+ /** SHA-256 of `alert-rules.yaml` as 31.18.0–31.28.x wrote it, its chart name spelled `<APP>`. */
17
+ export const RULES_31_18_SHA256 =
18
+ 'ae896fa5eea1c56d93f6c498fbf3dc026318be9feabcf0dbcbad2bc850c3d348';
19
+
20
+ /** SHA-256 of `dashboards/ultimate-app.json` as 31.18.0–31.28.x wrote it (it names no chart). */
21
+ export const DASHBOARD_31_18_SHA256 =
22
+ 'db34c29579f532cb5dac35de3f3e63141cf64e30643917b74e0eb9ecbd081f38';
23
+
24
+ const sha256 = (text: string): string => new Bun.CryptoHasher('sha256').update(text).digest('hex');
25
+
26
+ /** The chart's name in its helpers, spelled `<APP>`: one hash recognises every app's copy. */
27
+ export const unnamed = (text: string, chart: string): string =>
28
+ text.replaceAll(`include "${chart}.`, 'include "<APP>.');
29
+
30
+ /**
31
+ * Today's bytes over the stock ones; a file already today's, or absent, is left alone. Anything else
32
+ * is the app's, reported with what writing today's would change.
33
+ */
34
+ async function replaceStock(
35
+ app: CodemodApp,
36
+ path: string,
37
+ stock: (text: string) => boolean,
38
+ today: string,
39
+ what: string,
40
+ ): Promise<CodemodResult> {
41
+ const file = await readText(app, path);
42
+ if (file === undefined || file.text === today) return { changed: [], skipped: [] };
43
+ if (stock(file.text)) {
44
+ await app.write(path, file.restore(today));
45
+ return { changed: [path], skipped: [] };
46
+ }
47
+ return {
48
+ changed: [],
49
+ skipped: [
50
+ {
51
+ path,
52
+ reason: `the chart's ${what} is the app's own, so the deploy-contract additions were not written: the diff is today's file against yours, to merge by hand`,
53
+ diff: unifiedDiff(path, file.text, today),
54
+ },
55
+ ],
56
+ };
57
+ }
58
+
59
+ export const codemod: Codemod = {
60
+ id: 'helm-alerts-deploy',
61
+ since: '31.29.0',
62
+ summary: `${RULES_FILE} gains the latency, Postgres, framework-schema and volume rules, and ${DASHBOARD_FILE} their panels`,
63
+ async run(app) {
64
+ const chart = chartName((await readText(app, CHART_FILE))?.text ?? '');
65
+ if (chart === undefined) return { changed: [], skipped: [] };
66
+ const rules = helmMonitoringFiles(names(chart)).find((one) => one.path === RULES_FILE);
67
+ if (typeof rules?.contents !== 'string') return { changed: [], skipped: [] };
68
+ return mergeResults([
69
+ await replaceStock(
70
+ app,
71
+ RULES_FILE,
72
+ (text) => sha256(unnamed(text, chart)) === RULES_31_18_SHA256,
73
+ rules.contents,
74
+ 'alert rules',
75
+ ),
76
+ await replaceStock(
77
+ app,
78
+ DASHBOARD_FILE,
79
+ (text) => sha256(text) === DASHBOARD_31_18_SHA256,
80
+ dashboardJson(),
81
+ 'dashboard',
82
+ ),
83
+ ]);
84
+ },
85
+ };
@@ -0,0 +1,105 @@
1
+ // 31.18.0: the chart's alerts gain burn-rate rules against `alerts.objective`, and each role's
2
+ // memory request is what it measured idle. The rules template, still exactly the old one, is
3
+ // replaced whole; each values.yaml line moves where it stands as `x new` wrote it.
4
+
5
+ import { CHART_FILE, VALUES_FILE } from '../generate-chart-alerts';
6
+ import { names } from '../templates/naming';
7
+ import { helmMonitoringFiles } from '../templates/scaffold-helm-alerts';
8
+ import { chartName } from './chart-dashboard';
9
+ import type { Codemod, CodemodApp, CodemodResult } from './codemod';
10
+ import { unifiedDiff } from './engine-diff';
11
+ import type { SnippetEdit } from './engine-edits';
12
+ import { editSnippets, mergeResults, readText } from './engine-edits';
13
+ import { ALERT_RULES_31_15_LINES } from './helm-alerts-stock';
14
+
15
+ const RULES = 'docker/helm/templates/alert-rules.yaml';
16
+
17
+ const lines = (...text: readonly string[]): string => text.join('\n');
18
+
19
+ export const HELM_VALUES_EDITS: readonly SnippetEdit[] = [
20
+ {
21
+ from: lines('alerts:', ' enabled: auto', ' runbookBase:'),
22
+ to: lines(
23
+ 'alerts:',
24
+ ' enabled: auto',
25
+ " objective: 99.9 # percent of requests answered without a 5xx; the burn-rate rules' budget",
26
+ ' runbookBase:',
27
+ ),
28
+ },
29
+ {
30
+ from: lines(' port: 3000', ' resources:', ' requests: { cpu: 200m, memory: 256Mi }'),
31
+ to: lines(
32
+ ' port: 3000',
33
+ ' # Requests are measured idle plus headroom, limits the ceiling: a web pod of the demo app idled',
34
+ ' # at 73 Mi (plan 101 O6, 2026-11-11), so 128Mi; the limit is what an OOMKill reads.',
35
+ ' resources:',
36
+ ' requests: { cpu: 200m, memory: 128Mi }',
37
+ ),
38
+ optional: true,
39
+ },
40
+ {
41
+ from: lines(
42
+ ' retireSeconds: 3600',
43
+ ' resources:',
44
+ ' requests: { cpu: 200m, memory: 256Mi }',
45
+ ),
46
+ to: lines(
47
+ ' retireSeconds: 3600',
48
+ ' # 160Mi: ROLE=worker of the reference app idled at 138 MiB (Bun 1.4.4, 45 s, 2026-11-13).',
49
+ ' resources:',
50
+ ' requests: { cpu: 200m, memory: 160Mi }',
51
+ ),
52
+ optional: true,
53
+ },
54
+ {
55
+ from: lines(' resources:', ' requests: { cpu: 50m, memory: 128Mi }'),
56
+ to: lines(
57
+ ' resources:',
58
+ ' # 160Mi: ROLE=scheduler of the reference app idled at 137 MiB (Bun 1.4.4, 45 s, 2026-11-13).',
59
+ ' requests: { cpu: 50m, memory: 160Mi }',
60
+ ),
61
+ optional: true,
62
+ },
63
+ ];
64
+
65
+ /**
66
+ * Today's rules template, when the app's is still the pre-31.18 one exactly; one of the app's own
67
+ * (neither that nor today's) is reported with the template's change as a diff.
68
+ */
69
+ async function rules(app: CodemodApp, chart: string): Promise<CodemodResult> {
70
+ const file = await readText(app, RULES);
71
+ const today = helmMonitoringFiles(names(chart)).find((one) => one.path === RULES)?.contents;
72
+ if (file === undefined || typeof today !== 'string' || file.text === today) {
73
+ return { changed: [], skipped: [] };
74
+ }
75
+ const stock = ALERT_RULES_31_15_LINES.map((line) => line.replaceAll('<APP>', chart)).join('\n');
76
+ if (file.text === stock) {
77
+ await app.write(RULES, file.restore(today));
78
+ return { changed: [RULES], skipped: [] };
79
+ }
80
+ return {
81
+ changed: [],
82
+ skipped: [
83
+ {
84
+ path: RULES,
85
+ reason:
86
+ "the chart holds alert rules of its own, so the burn-rate rules were not written: the diff is the template's change, to make by hand",
87
+ diff: unifiedDiff(RULES, stock, today),
88
+ },
89
+ ],
90
+ };
91
+ }
92
+
93
+ export const codemod: Codemod = {
94
+ id: 'helm-alerts-objective',
95
+ since: '31.18.0',
96
+ summary: `${RULES} gains the burn-rate rules, ${VALUES_FILE} alerts.objective and the measured memory requests`,
97
+ async run(app) {
98
+ const chart = chartName((await readText(app, CHART_FILE))?.text ?? '');
99
+ if (chart === undefined) return { changed: [], skipped: [] };
100
+ return mergeResults([
101
+ await rules(app, chart),
102
+ await editSnippets(app, VALUES_FILE, HELM_VALUES_EDITS),
103
+ ]);
104
+ },
105
+ };
@@ -0,0 +1,108 @@
1
+ // `docker/helm/templates/alert-rules.yaml` as `x new` wrote it from 31.4.0 through 31.17.x — before
2
+ // the burn-rate rules and `alerts.objective` — kept byte for byte (the chart's name as `<APP>`), so
3
+ // a template still exactly that is recognised and replaced whole by today's, and an edited one not.
4
+
5
+ // biome-ignore-all lint/suspicious/noTemplateCurlyInString: Helm's own {{ … }}, never a JS template
6
+
7
+ export const ALERT_RULES_31_15_LINES: readonly string[] = [
8
+ '{{/*',
9
+ "The alert rules for this release's own series, written from @ultimat3/cli's rule table. Each rule",
10
+ 'reads alerts.rules.<alert> for threshold, for, severity and enabled; its runbook_url is',
11
+ "alerts.runbookBase plus the rule's anchor. Rendered by capability, like servicemonitor.yaml.",
12
+ '*/}}',
13
+ '{{- $cfg := .Values.alerts | default dict }}',
14
+ '{{- $mode := toString (ternary $cfg.enabled "auto" (hasKey $cfg "enabled")) }}',
15
+ '{{- if not (has $mode (list "auto" "true" "false")) }}',
16
+ '{{- fail (printf "alerts.enabled is %q — set it to auto (render when the cluster serves monitoring.coreos.com/v1/PrometheusRule), true or false" $mode) }}',
17
+ '{{- end }}',
18
+ '{{- if or (eq $mode "true") (and (eq $mode "auto") (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1/PrometheusRule")) }}',
19
+ '{{- $rules := $cfg.rules | default dict }}',
20
+ '{{- $base := $cfg.runbookBase | default "https://github.com/developerz-ai/ultimate/blob/main/docs/ops/06-runbooks.md" }}',
21
+ 'apiVersion: monitoring.coreos.com/v1',
22
+ 'kind: PrometheusRule',
23
+ 'metadata:',
24
+ ' name: {{ include "<APP>.fullname" . }}',
25
+ ' labels:',
26
+ ' {{- include "<APP>.labels" . | nindent 4 }}',
27
+ ' {{- with $cfg.labels }}',
28
+ ' {{- toYaml . | nindent 4 }}',
29
+ ' {{- end }}',
30
+ 'spec:',
31
+ ' groups:',
32
+ ' - name: {{ include "<APP>.fullname" . }}.ultimate',
33
+ ' rules:',
34
+ ' {{- $r := index $rules "UltimateQueueStalled" | default dict }}',
35
+ ' {{- if ne (toString $r.enabled) "false" }}',
36
+ ' - alert: UltimateQueueStalled',
37
+ ' expr: >-',
38
+ ' max by (namespace, app_kubernetes_io_instance, queue) (queue_oldest_ready_seconds{namespace="{{ $.Release.Namespace }}",app_kubernetes_io_instance="{{ $.Release.Name }}"}) > {{ ternary $r.threshold 300 (hasKey $r "threshold") }}',
39
+ ' for: {{ $r.for | default "5m" }}',
40
+ ' labels:',
41
+ ' severity: {{ $r.severity | default "warning" }}',
42
+ ' annotations:',
43
+ ' summary: "A queue has a due job nothing has claimed for longer than the threshold"',
44
+ ' runbook_url: {{ printf "%s#ultimatequeuestalled" $base | quote }}',
45
+ ' {{- end }}',
46
+ ' {{- $r := index $rules "UltimateDeadLetters" | default dict }}',
47
+ ' {{- if ne (toString $r.enabled) "false" }}',
48
+ ' - alert: UltimateDeadLetters',
49
+ ' expr: >-',
50
+ ' max by (namespace, app_kubernetes_io_instance, queue) (queue_dead_jobs{namespace="{{ $.Release.Namespace }}",app_kubernetes_io_instance="{{ $.Release.Name }}"}) > 0',
51
+ ' for: {{ $r.for | default "5m" }}',
52
+ ' labels:',
53
+ ' severity: {{ $r.severity | default "warning" }}',
54
+ ' annotations:',
55
+ ' summary: "A queue holds dead-lettered jobs"',
56
+ ' runbook_url: {{ printf "%s#ultimatedeadletters" $base | quote }}',
57
+ ' {{- end }}',
58
+ ' {{- $r := index $rules "UltimateLeaseLost" | default dict }}',
59
+ ' {{- if ne (toString $r.enabled) "false" }}',
60
+ ' - alert: UltimateLeaseLost',
61
+ ' expr: >-',
62
+ ' sum by (namespace, app_kubernetes_io_instance, queue) (rate(job_leases_lost_total{namespace="{{ $.Release.Namespace }}",app_kubernetes_io_instance="{{ $.Release.Name }}"}[5m])) > 0',
63
+ ' for: {{ $r.for | default "5m" }}',
64
+ ' labels:',
65
+ ' severity: {{ $r.severity | default "warning" }}',
66
+ ' annotations:',
67
+ ' summary: "Job leases are lapsing while their jobs still run, so jobs run twice"',
68
+ ' runbook_url: {{ printf "%s#ultimateleaselost" $base | quote }}',
69
+ ' {{- end }}',
70
+ ' {{- $r := index $rules "UltimateFramesDropped" | default dict }}',
71
+ ' {{- if ne (toString $r.enabled) "false" }}',
72
+ ' - alert: UltimateFramesDropped',
73
+ ' expr: >-',
74
+ ' sum by (namespace, app_kubernetes_io_instance) (rate(channel_frames_dropped_total{namespace="{{ $.Release.Namespace }}",app_kubernetes_io_instance="{{ $.Release.Name }}"}[5m])) > 0',
75
+ ' for: {{ $r.for | default "5m" }}',
76
+ ' labels:',
77
+ ' severity: {{ $r.severity | default "warning" }}',
78
+ ' annotations:',
79
+ ' summary: "Sync nodes are dropping channel frames to socket backpressure"',
80
+ ' runbook_url: {{ printf "%s#ultimateframesdropped" $base | quote }}',
81
+ ' {{- end }}',
82
+ ' {{- $r := index $rules "UltimateServerErrors" | default dict }}',
83
+ ' {{- if ne (toString $r.enabled) "false" }}',
84
+ ' - alert: UltimateServerErrors',
85
+ ' expr: >-',
86
+ ' sum by (namespace, app_kubernetes_io_instance) (rate(http_requests_total{namespace="{{ $.Release.Namespace }}",app_kubernetes_io_instance="{{ $.Release.Name }}",status="5xx"}[5m])) / sum by (namespace, app_kubernetes_io_instance) (rate(http_requests_total{namespace="{{ $.Release.Namespace }}",app_kubernetes_io_instance="{{ $.Release.Name }}"}[5m])) > {{ ternary $r.threshold 0.05 (hasKey $r "threshold") }}',
87
+ ' for: {{ $r.for | default "10m" }}',
88
+ ' labels:',
89
+ ' severity: {{ $r.severity | default "critical" }}',
90
+ ' annotations:',
91
+ ' summary: "The share of requests answered 5xx is above the threshold"',
92
+ ' runbook_url: {{ printf "%s#ultimateservererrors" $base | quote }}',
93
+ ' {{- end }}',
94
+ ' {{- $r := index $rules "UltimateTargetDown" | default dict }}',
95
+ ' {{- if ne (toString $r.enabled) "false" }}',
96
+ ' - alert: UltimateTargetDown',
97
+ ' expr: >-',
98
+ ' count by (namespace, app_kubernetes_io_instance, app_kubernetes_io_component) (up{namespace="{{ $.Release.Namespace }}",app_kubernetes_io_instance="{{ $.Release.Name }}"} == 0) > 0',
99
+ ' for: {{ $r.for | default "5m" }}',
100
+ ' labels:',
101
+ ' severity: {{ $r.severity | default "critical" }}',
102
+ ' annotations:',
103
+ ' summary: "A role has a scrape target that is down"',
104
+ ' runbook_url: {{ printf "%s#ultimatetargetdown" $base | quote }}',
105
+ ' {{- end }}',
106
+ '{{- end }}',
107
+ '',
108
+ ];
@@ -0,0 +1,60 @@
1
+ // The one ordered list of codemods `x upgrade` runs, in run order (`since`, then `id`). A codemod
2
+ // module not listed here is refused by `index.test.ts`; `scripts/template-codemods.ts` refuses a
3
+ // scaffold-owned template change with no codemod (or no written reason) for the next release.
4
+
5
+ import { codemod as agentsDevMcp } from './agents-dev-mcp';
6
+ import { codemod as authenticatorSessionRefusal } from './authenticator-session-refusal';
7
+ import { codemod as biomeNoDefaultExport } from './biome-no-default-export';
8
+ import { codemod as bunfigIslandCoverage } from './bunfig-island-coverage';
9
+ import { codemod as chartDashboard } from './chart-dashboard';
10
+ import { codemod as ciE2eBrowser } from './ci-e2e-browser';
11
+ import type { Codemod } from './codemod';
12
+ import { codemod as defineErrorLeaf } from './define-error-leaf';
13
+ import { codemod as docsCiParts } from './docs-ci-parts';
14
+ import { codemod as docsGateProse } from './docs-gate-prose';
15
+ import { codemod as docsIslandRows } from './docs-island-rows';
16
+ import { codemod as docsShippedGuards } from './docs-shipped-guards';
17
+ import { codemod as docsTestServices } from './docs-test-services';
18
+ import { codemod as formatEditedHook } from './format-edited-hook';
19
+ import { codemod as helmAlertsDeploy } from './helm-alerts-deploy';
20
+ import { codemod as helmAlertsObjective } from './helm-alerts-objective';
21
+ import { codemod as metricsProbeHealthz } from './metrics-probe-healthz';
22
+ import { codemod as migrateJobOrdered } from './migrate-job-ordered';
23
+ import { codemod as reproGitignore } from './repro-gitignore';
24
+ import { codemod as runtimePin } from './runtime-pin';
25
+ import { codemod as solidFloor } from './solid-floor';
26
+ import { codemod as testPorts } from './test-ports';
27
+ import { codemod as testSuites } from './test-suites';
28
+ import { codemod as themeToggleMountOver } from './theme-toggle-mount-over';
29
+ import { codemod as vendoredGuards } from './vendored-guards';
30
+ import { codemod as verifyFloorSkips } from './verify-floor-skips';
31
+ import { codemod as verifyFloorSteps } from './verify-floor-steps';
32
+
33
+ export const CODEMODS: readonly Codemod[] = [
34
+ defineErrorLeaf,
35
+ biomeNoDefaultExport,
36
+ docsIslandRows,
37
+ themeToggleMountOver,
38
+ docsCiParts,
39
+ chartDashboard,
40
+ helmAlertsObjective,
41
+ authenticatorSessionRefusal,
42
+ agentsDevMcp,
43
+ docsGateProse,
44
+ metricsProbeHealthz,
45
+ bunfigIslandCoverage,
46
+ ciE2eBrowser,
47
+ docsTestServices,
48
+ testPorts,
49
+ testSuites,
50
+ verifyFloorSkips,
51
+ docsShippedGuards,
52
+ formatEditedHook,
53
+ reproGitignore,
54
+ runtimePin,
55
+ solidFloor,
56
+ vendoredGuards,
57
+ verifyFloorSteps,
58
+ helmAlertsDeploy,
59
+ migrateJobOrdered,
60
+ ];
@@ -0,0 +1,47 @@
1
+ // 31.25.0: a role with no HTTP socket is probed on `/healthz` of its scrape listener — the one path
2
+ // that reads the loops' heartbeats — where it was `/metrics`, which answers while a loop is stuck.
3
+ // The compose anchor and the chart's liveness probe, each where it stands as `x new` wrote it.
4
+
5
+ import type { Codemod } from './codemod';
6
+ import type { SnippetEdit } from './engine-edits';
7
+ import { editSnippets, mergeResults } from './engine-edits';
8
+
9
+ const COMPOSE = 'docker/docker-compose.prod.yml';
10
+ const HELPERS = 'docker/helm/templates/_helpers.tpl';
11
+
12
+ const probe = (path: string): string =>
13
+ ` test: ['CMD', 'bun', '--eval', "fetch('http://127.0.0.1:'+(process.env.METRICS_PORT||9090)+'${path}').then(r=>process.exit(r.ok?0:1),()=>process.exit(1))"]`;
14
+
15
+ export const METRICS_PROBE_EDITS: Readonly<Record<string, readonly SnippetEdit[]>> = {
16
+ [COMPOSE]: [
17
+ {
18
+ from: '# gated on it never starts. Probes follow the role here, exactly as they do in `docker/helm`.',
19
+ to: [
20
+ '# gated on it never starts. Probes follow the role here, exactly as they do in `docker/helm`:',
21
+ "# `/healthz`, the one path on the scrape listener that reads the loops' heartbeats.",
22
+ ].join('\n'),
23
+ optional: true,
24
+ },
25
+ // The probe itself, apart from the prose above it: a reworded comment keeps no stale probe.
26
+ { from: probe('/metrics'), to: probe('/healthz') },
27
+ ],
28
+ [HELPERS]: [
29
+ {
30
+ from: ' livenessProbe:\n httpGet: { path: /metrics, port: metrics }\n periodSeconds: 15',
31
+ to: ' livenessProbe:\n httpGet: { path: /healthz, port: metrics }\n periodSeconds: 15',
32
+ },
33
+ ],
34
+ };
35
+
36
+ export const codemod: Codemod = {
37
+ id: 'metrics-probe-healthz',
38
+ since: '31.25.0',
39
+ summary: `${COMPOSE} and ${HELPERS} probe a socketless role on /healthz, which reads its loops' heartbeats`,
40
+ async run(app) {
41
+ const results = [];
42
+ for (const [path, edits] of Object.entries(METRICS_PROBE_EDITS)) {
43
+ results.push(await editSnippets(app, path, edits));
44
+ }
45
+ return mergeResults(results);
46
+ },
47
+ };
@@ -0,0 +1,81 @@
1
+ // 31.29.0: the chart's migrate Job orders every rollout under any applier — a Helm hook, an Argo CD
2
+ // Sync hook in wave -1 (no longer the PreSync Argo mapped the Helm hook to), and named by its image
3
+ // so an applier that ignores hooks gets a new Job per image. The Job, still exactly the old
4
+ // template, is replaced whole; `docker/README.md`'s two rows move where they stand.
5
+
6
+ import { CHART_FILE } from '../generate-chart-alerts';
7
+ import { names } from '../templates/naming';
8
+ import { helmMigrateFile, MIGRATE_JOB_PATH } from '../templates/scaffold-helm-migrate';
9
+ import { chartName } from './chart-dashboard';
10
+ import type { Codemod, CodemodApp, CodemodResult } from './codemod';
11
+ import { unifiedDiff } from './engine-diff';
12
+ import type { SnippetEdit } from './engine-edits';
13
+ import { editSnippets, mergeResults, readText } from './engine-edits';
14
+ import { MIGRATE_JOB_31_28_LINES } from './migrate-job-stock';
15
+
16
+ const README = 'docker/README.md';
17
+ const VALUES = 'docker/helm/values.yaml';
18
+
19
+ /** The TTL's own line; absent, the template collects after the same day, so it is optional. */
20
+ export const MIGRATE_VALUES_EDITS: readonly SnippetEdit[] = [
21
+ {
22
+ from: 'migrate:\n enabled: true\n backoffLimit: 1\n',
23
+ to: 'migrate:\n enabled: true\n backoffLimit: 1\n ttlSecondsAfterFinished: 86400 # a finished Job, and its logs, are collected after a day\n',
24
+ optional: true,
25
+ },
26
+ ];
27
+
28
+ /** What no file shows: the cluster still holds the Job the old fixed name made. */
29
+ const ORPHAN =
30
+ 'a cluster deployed from the old chart keeps its fixed-name Job: kubectl delete job <release>-migrate, once';
31
+
32
+ export const MIGRATE_README_EDITS: readonly SnippetEdit[] = [
33
+ {
34
+ from: '| Kubernetes | an `initContainer` or a `Job` on the same image with `ROLE=migrate` |',
35
+ to: "| Kubernetes | the chart's one `migrate` Job on the same image (`docker/helm`), ordered before every role — never a per-pod `initContainer` |",
36
+ optional: true,
37
+ },
38
+ {
39
+ from: '| Job | release | `ROLE=migrate`, a `pre-install,pre-upgrade` hook — it runs to completion first |',
40
+ to: '| Job | release | `ROLE=migrate`, run to completion first: a `pre-install,pre-upgrade,pre-rollback` hook, an Argo CD `Sync` hook in wave -1, and named by its image so any other applier gets a new Job per image |',
41
+ optional: true,
42
+ },
43
+ ];
44
+
45
+ const NOTHING: CodemodResult = { changed: [], skipped: [] };
46
+
47
+ /** Today's Job when the app's is still the old template exactly; an edited one is reported. */
48
+ async function job(app: CodemodApp, chart: string): Promise<CodemodResult> {
49
+ const file = await readText(app, MIGRATE_JOB_PATH);
50
+ const next = String(helmMigrateFile(names(chart)).contents);
51
+ if (file === undefined || file.text === next) return NOTHING;
52
+ const stock = `${MIGRATE_JOB_31_28_LINES.map((line) => line.replaceAll('<APP>', chart)).join('\n')}\n`;
53
+ if (file.text === stock) {
54
+ await app.write(MIGRATE_JOB_PATH, file.restore(next));
55
+ return { changed: [MIGRATE_JOB_PATH], skipped: [] };
56
+ }
57
+ return {
58
+ changed: [],
59
+ skipped: [
60
+ {
61
+ path: MIGRATE_JOB_PATH,
62
+ reason: `the app's migrate Job is its own, so the ordering annotations, the image-derived name and the TTL were not written: the diff is the template's change, to make by hand; ${ORPHAN}`,
63
+ diff: unifiedDiff(MIGRATE_JOB_PATH, stock, next),
64
+ },
65
+ ],
66
+ };
67
+ }
68
+
69
+ export const codemod: Codemod = {
70
+ id: 'migrate-job-ordered',
71
+ since: '31.29.0',
72
+ summary: `${MIGRATE_JOB_PATH} orders every rollout under helm, Argo CD and a hook-blind applier alike, and is collected a day after it finishes; ${ORPHAN}`,
73
+ async run(app) {
74
+ const chart = chartName((await readText(app, CHART_FILE))?.text ?? '');
75
+ return mergeResults([
76
+ chart === undefined ? NOTHING : await job(app, chart),
77
+ await editSnippets(app, README, MIGRATE_README_EDITS),
78
+ await editSnippets(app, VALUES, MIGRATE_VALUES_EDITS),
79
+ ]);
80
+ },
81
+ };
@@ -0,0 +1,41 @@
1
+ // `docker/helm/templates/migrate-job.yaml` as `x new` wrote it through 31.28.x — a Helm hook alone,
2
+ // under one fixed name — kept byte for byte (the chart's name as `<APP>`), so a template still
3
+ // exactly that is recognised and replaced whole, and an edited one is not.
4
+
5
+ // biome-ignore-all lint/suspicious/noTemplateCurlyInString: Helm's own {{ … }}, never a JS template
6
+
7
+ export const MIGRATE_JOB_31_28_LINES: readonly string[] = [
8
+ '{{/*',
9
+ 'The release phase, as a pre-install / pre-upgrade hook: ROLE=migrate applies every pending',
10
+ 'migration under an advisory lock and exits, before any serving role starts. Same image, same entry',
11
+ 'point — there is no second migration engine and no toolchain in the container.',
12
+ '*/}}',
13
+ '{{- if .Values.migrate.enabled }}',
14
+ 'apiVersion: batch/v1',
15
+ 'kind: Job',
16
+ 'metadata:',
17
+ ' name: {{ include "<APP>.fullname" . }}-migrate',
18
+ ' labels:',
19
+ ' {{- include "<APP>.labels" . | nindent 4 }}',
20
+ ' app.kubernetes.io/component: migrate',
21
+ ' annotations:',
22
+ ' helm.sh/hook: pre-install,pre-upgrade',
23
+ ' helm.sh/hook-weight: "-5"',
24
+ ' helm.sh/hook-delete-policy: before-hook-creation',
25
+ 'spec:',
26
+ ' backoffLimit: {{ .Values.migrate.backoffLimit }}',
27
+ ' template:',
28
+ ' metadata:',
29
+ ' labels:',
30
+ ' {{- include "<APP>.labels" . | nindent 8 }}',
31
+ ' app.kubernetes.io/component: migrate',
32
+ ' spec:',
33
+ ' restartPolicy: Never',
34
+ ' automountServiceAccountToken: false',
35
+ ' securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }}',
36
+ ' containers:',
37
+ ' {{- include "<APP>.container" (dict "role" "migrate" "cfg" .Values.migrate "root" .) | nindent 8 }}',
38
+ ' volumes:',
39
+ ' {{- include "<APP>.tmpVolume" . | nindent 8 }}',
40
+ '{{- end }}',
41
+ ];
@@ -0,0 +1,36 @@
1
+ // The codemods an app still owes, for `x doctor`: an `x upgrade` driven by a CLI older than the
2
+ // engine applied none, and the installed CLI's gate cannot write. A dry run of every codemod up to
3
+ // this CLI's release names them; `x upgrade --json` at the target then applies them (idempotent).
4
+
5
+ import type { Finding } from '../output';
6
+ import type { Codemod } from './codemod';
7
+ import { runCodemods } from './engine';
8
+ import { fsCodemodApp } from './engine-fs';
9
+ import { CODEMODS } from './index';
10
+
11
+ export const CODEMODS_PENDING = 'X_UPGRADE_CODEMODS_PENDING';
12
+
13
+ export async function pendingCodemodFindings(
14
+ root: string,
15
+ to: string,
16
+ codemods: readonly Codemod[] = CODEMODS,
17
+ ): Promise<readonly Finding[]> {
18
+ const report = await runCodemods({
19
+ app: fsCodemodApp(root),
20
+ codemods,
21
+ from: '0.0.0',
22
+ to,
23
+ dryRun: true,
24
+ });
25
+ const owed = report.applied.filter((one) => one.changed.length > 0);
26
+ if (owed.length === 0) return [];
27
+ const files = [...new Set(owed.flatMap((one) => one.changed))].sort();
28
+ return [
29
+ {
30
+ code: CODEMODS_PENDING,
31
+ cause: `${String(files.length)} file(s) still as an older scaffold wrote them, owed by ${owed.map((one) => `${one.id} (${one.since})`).join(', ')}: the x upgrade that installed ${to} ran under a CLI with no codemods — ${files.slice(0, 8).join(', ')}`,
32
+ fix: 'x upgrade --json # on a clean tree; at the release it is on, it applies every codemod still owed',
33
+ at: files[0] ?? '.',
34
+ },
35
+ ];
36
+ }
@@ -0,0 +1,40 @@
1
+ // Carries an older app's `.gitignore` to the 31.28.0 scaffold's: the line that keeps an
2
+ // `x repro --bundle` file — redacted, but meant for an issue, never the repository — out of a
3
+ // commit. Idempotent; an app that already ignores `repro/` whole is left alone; no file, no file.
4
+
5
+ import type { Codemod } from './codemod';
6
+
7
+ /** The line, as `x new`'s `.gitignore` (`templates/scaffold-repo.ts`) writes it. */
8
+ export const REPRO_BUNDLE_IGNORE = 'repro/bundle-*.json';
9
+
10
+ const GITIGNORE = '.gitignore';
11
+
12
+ /** Lines that already keep a bundle out: this one, or the whole `repro/` directory. */
13
+ const COVERING = new Set([REPRO_BUNDLE_IGNORE, `/${REPRO_BUNDLE_IGNORE}`, 'repro/', '/repro/']);
14
+
15
+ export const codemod: Codemod = {
16
+ id: 'repro-gitignore',
17
+ since: '31.28.0',
18
+ summary: `.gitignore gains ${REPRO_BUNDLE_IGNORE}: an x repro --bundle file is for an issue, never a commit`,
19
+ async run(app) {
20
+ const source = await app.read(GITIGNORE);
21
+ if (source === undefined) {
22
+ return {
23
+ changed: [],
24
+ skipped: [
25
+ {
26
+ path: GITIGNORE,
27
+ reason: `the app has no .gitignore, so none was created; add ${REPRO_BUNDLE_IGNORE} to whatever keeps files out of its commits`,
28
+ diff: `+${REPRO_BUNDLE_IGNORE}`,
29
+ },
30
+ ],
31
+ };
32
+ }
33
+ const lines = source.split(/\r?\n/).map((line) => line.trim());
34
+ if (lines.some((line) => COVERING.has(line))) return { changed: [], skipped: [] };
35
+ const eol = source.includes('\r\n') ? '\r\n' : '\n';
36
+ const base = source === '' || source.endsWith('\n') ? source : `${source}${eol}`;
37
+ await app.write(GITIGNORE, `${base}${REPRO_BUNDLE_IGNORE}${eol}`);
38
+ return { changed: [GITIGNORE], skipped: [] };
39
+ },
40
+ };