@intentius/sql-yodeler 0.11.1 → 0.12.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 (52) hide show
  1. package/dist/chant/gated-request.d.ts +31 -1
  2. package/dist/chant/gated-request.js +57 -1
  3. package/dist/chant/gated-request.js.map +1 -1
  4. package/dist/chant-floor-version.d.ts +1 -1
  5. package/dist/chant-floor-version.js +1 -1
  6. package/dist/chant-floor.d.ts +14 -12
  7. package/dist/chant-floor.js +33 -19
  8. package/dist/chant-floor.js.map +1 -1
  9. package/dist/ci/login.d.ts +22 -47
  10. package/dist/ci/login.js +35 -82
  11. package/dist/ci/login.js.map +1 -1
  12. package/dist/ci/render.d.ts +42 -73
  13. package/dist/ci/render.js +78 -137
  14. package/dist/ci/render.js.map +1 -1
  15. package/dist/ci-words.d.ts +3 -3
  16. package/dist/ci-words.js +3 -3
  17. package/dist/commands/apply.d.ts +6 -0
  18. package/dist/commands/apply.js +34 -12
  19. package/dist/commands/apply.js.map +1 -1
  20. package/dist/commands/mcp.js +15 -20
  21. package/dist/commands/mcp.js.map +1 -1
  22. package/dist/commands/plan.js +52 -8
  23. package/dist/commands/plan.js.map +1 -1
  24. package/dist/commands/revert.js +5 -1
  25. package/dist/commands/revert.js.map +1 -1
  26. package/dist/config/define.d.ts +1 -1
  27. package/dist/config/settings.d.ts +23 -3
  28. package/dist/config/settings.js +32 -9
  29. package/dist/config/settings.js.map +1 -1
  30. package/dist/mcp/chant-hook.d.ts +7 -5
  31. package/dist/mcp/chant-hook.js +19 -22
  32. package/dist/mcp/chant-hook.js.map +1 -1
  33. package/dist/pr/note.d.ts +26 -23
  34. package/dist/pr/note.js +59 -49
  35. package/dist/pr/note.js.map +1 -1
  36. package/dist/pr/part.d.ts +11 -0
  37. package/dist/pr/part.js +35 -1
  38. package/dist/pr/part.js.map +1 -1
  39. package/dist/pr/render.d.ts +0 -4
  40. package/dist/pr/render.js +5 -62
  41. package/dist/pr/render.js.map +1 -1
  42. package/dist/pr/tenants.d.ts +7 -0
  43. package/dist/pr/tenants.js +25 -0
  44. package/dist/pr/tenants.js.map +1 -1
  45. package/dist/versioned/engine.d.ts +1 -1
  46. package/package.json +7 -7
  47. package/dist/mcp/server.d.ts +0 -40
  48. package/dist/mcp/server.js +0 -106
  49. package/dist/mcp/server.js.map +0 -1
  50. package/dist/versioned/stand-down.d.ts +0 -44
  51. package/dist/versioned/stand-down.js +0 -84
  52. package/dist/versioned/stand-down.js.map +0 -1
package/dist/ci/render.js CHANGED
@@ -37,20 +37,17 @@
37
37
  * migrations and the digest to approve. One job per environment, holding
38
38
  * that environment's reader credentials and nothing else.
39
39
  * - yodel-apply: on a push to main, one job per wave, each needing the one
40
- * before, running `chant run wave`: it plans the environment (`yodel apply
41
- * <env> --wave-plan`), reads the wave's gate policy from yodel-waves.json
42
- * as the commit before the push has it, waits for an approval when that
43
- * policy asks for one (exit 3, and the waves after it do not run), and
44
- * applies (`yodel apply <env> --wave-apply`). The only jobs that hold a
45
- * writer's credentials, one environment's each, with
46
- * YODEL_CREDENTIALS=writer. Two merges in quick succession do not fail the
47
- * second apply: it waits for the first's lock (YODEL_LOCK_WAIT), and an
48
- * apply whose commit is no longer main's tip stands down
49
- * (YODEL_STAND_DOWN), since the newer commit's waves apply the same
50
- * environments. With a chant that has the lock grain and stand-down
51
- * (#293), chant does both: its lease on the environment exits 5 for the
52
- * apply that finds it held, and `standDown` in the spec exits 6 for one
53
- * a newer commit supersedes; the jobs carry neither variable.
40
+ * before, running `yodel chant run wave`: through the sql lexicon's
41
+ * `sql-migrate` capability it plans the environment (`yodel apply <env>
42
+ * --wave-plan`), reads the wave's gate policy from yodel-waves.json as the
43
+ * commit before the push has it, waits for an approval when that policy
44
+ * asks for one (exit 3, and the waves after it do not run), and applies
45
+ * (`yodel apply <env> --wave-apply`). The only jobs that hold a writer's
46
+ * credentials, one environment's each, with YODEL_CREDENTIALS=writer. Two
47
+ * merges in quick succession do not fail the second apply: chant's lease
48
+ * on the environment exits 5 for the apply that finds it held, and
49
+ * `standDown` in the spec exits 6 for one a newer commit supersedes
50
+ * (#293).
54
51
  * - watch-<env>: the environment's WatchOp on its own schedule, rendered by
55
52
  * chant's generateOpsPipeline, with the reader's credentials. After the
56
53
  * Op, `yodel drift <env> --issue` compares the server with the schema the
@@ -75,16 +72,15 @@
75
72
  * in that image instead, which carries node, yodel, chant and the lexicons
76
73
  * on PATH, and no job runs `npm ci` ({@link Toolchain}).
77
74
  *
78
- * With a chant that has `@intentius/chant/ci-product` (chant#4550), yodel ci
79
- * renders through chant's product pipeline with yodel's words (#289,
80
- * ../ci-words.ts): {@link productWaves}.
75
+ * yodel ci renders through chant's product pipeline (chant#4550) with
76
+ * yodel's words (#289, ../ci-words.ts): {@link productWaves}.
81
77
  */
82
78
  import { existsSync } from "node:fs";
83
79
  import { join, resolve } from "node:path";
84
80
  import { pathToFileURL } from "node:url";
85
81
  import { APPROVAL_MODES, WAVE_GATES, waveGateHint } from "../config/define.js";
86
82
  import { stepHooks } from "../apply-steps/index.js";
87
- import { audience, chantTrade, CLOUD_OF, jobLogins, loginSteps, tradeIdTokens, tradesThroughChant, useChantTrade } from "./login.js";
83
+ import { CLOUD_OF, jobLogins, loginSteps, tradeIdTokens } from "./login.js";
88
84
  import { RECORD_PLANS_ENV } from "../approval-mode/index.js";
89
85
  import { cloudToken, credentialsOf, roleVariables } from "../credentials.js";
90
86
  import { loadYodelConfig } from "../config/load.js";
@@ -98,6 +94,7 @@ import { forgejoSerializer } from "@intentius/chant-lexicon-forgejo/serializer";
98
94
  import { Artifacts as GitLabArtifacts, Image, Job as GitLabJob, Pipeline as GitLabPipeline, Rule, Service as GitLabService, Workflow as GitLabWorkflow, WorkflowRule, } from "@intentius/chant-lexicon-gitlab";
99
95
  import { gitlabSerializer } from "@intentius/chant-lexicon-gitlab/serializer";
100
96
  import { chantProduct, YODEL_WORDS } from "../ci-words.js";
97
+ import { CHANT_CI_FLOOR, installLine } from "../chant-floor-version.js";
101
98
  export const FORGES = ["github", "gitlab", "forgejo"];
102
99
  /** The image every job runs in, where the forge runs jobs in a container. It needs git, so not -slim. */
103
100
  export const IMAGE = "node:22-bookworm";
@@ -145,13 +142,13 @@ export const writerVariables = (env, dialect, creds) => {
145
142
  // ── Cloud identity (#50) ────────────────────────────────────────────────────
146
143
  //
147
144
  // A role whose password is minted by a cloud token source (rds-iam,
148
- // cloud-sql-iam, entra) mints it with the cloud's command line, from the
149
- // job's identity. A job holding one gets an OIDC token from the forge: on
150
- // GitHub the workflow grants `id-token: write`; on GitLab the job declares
151
- // an ID token for the cloud's audience. Forgejo issues no OIDC token to a
152
- // job (its dialect drops `permissions:`), so there the runner's own cloud
153
- // identity mints.
154
- /** The GitLab ID token per cloud: its variable and its audience. */
145
+ // cloud-sql-iam, entra) mints it from the job's identity. A job holding one
146
+ // gets an OIDC token from the forge: on GitHub the workflow grants
147
+ // `id-token: write`; on GitLab the job declares an ID token, chant's for a
148
+ // cloud the job logs in to through chant's trade (./login.ts), else one for
149
+ // the cloud's audience. Forgejo issues no OIDC token to a job (its dialect
150
+ // drops `permissions:`), so there the runner's own cloud identity mints.
151
+ /** The GitLab ID token per cloud, for a job that holds a cloud-minted role and names no login for it: its variable and its audience. */
155
152
  export const ID_TOKENS = {
156
153
  "rds-iam": { variable: "AWS_ID_TOKEN", aud: "sts.amazonaws.com" },
157
154
  "cloud-sql-iam": { variable: "GCP_ID_TOKEN", aud: "https://iam.googleapis.com/" },
@@ -161,16 +158,11 @@ export const ID_TOKENS = {
161
158
  const cloudsOf = (envs, held) => [
162
159
  ...new Set(held.map(([env, role]) => envs.credentials?.[env]?.[role].cloud).filter((c) => c !== undefined)),
163
160
  ];
164
- /** A GitLab job's `id_tokens` for `clouds`, each for its login's audience when the job logs in (#132): GCP's is the workload identity provider's own. */
161
+ /** A GitLab job's `id_tokens` for `clouds`: chant's for the clouds the job logs in to through the trade (#296), yodel's for the rest. */
165
162
  const idTokens = (clouds, logins = []) => ({
166
- ...ownIdTokens(clouds.filter((c) => !(tradesThroughChant() && logins.some((l) => l.cloud === CLOUD_OF[c]))), logins),
167
- // Through chant's trade (#296), the logins' tokens come in chant's variables.
163
+ ...Object.fromEntries(clouds.filter((c) => !logins.some((l) => l.cloud === CLOUD_OF[c])).map((c) => [ID_TOKENS[c].variable, { aud: ID_TOKENS[c].aud }])),
168
164
  ...(tradeIdTokens(logins) ?? {}),
169
165
  });
170
- const ownIdTokens = (clouds, logins) => Object.fromEntries(clouds.map((c) => {
171
- const login = logins.find((l) => l.cloud === CLOUD_OF[c]);
172
- return [ID_TOKENS[c].variable, { aud: login ? audience(login) : ID_TOKENS[c].aud }];
173
- }));
174
166
  /** The cloud logins (#132) of a job holding the roles `held`, from yodel.config.ts `ci.login`. */
175
167
  const loginsOf = (envs, held) => jobLogins(envs.login, held, (env, role) => envs.credentials?.[env]?.[role].cloud);
176
168
  /** A job's login steps as the github lexicon's Steps. */
@@ -204,7 +196,8 @@ const runsChant = (st) => typeof st.run === "string" && st.run.startsWith("chant
204
196
  /** The roles a pull request's plan job for `env` holds: the environment's reader and the reader of the one it requires. */
205
197
  const planRoles = (waves, env) => [env, ...requiredOf(waves, env)].map((e) => [e, "reader"]);
206
198
  /** The roles a wave job for `env` holds: the writer, and the reader of the environment it requires. */
207
- const waveRoles = (waves, env) => [[env, "writer"], ...requiredOf(waves, env).map((e) => [e, "reader"])];
199
+ // chant's sql-migrate plans a wave with the writer taken out (readerEnv), so the job holds its environment's reader too.
200
+ const waveRoles = (waves, env) => [[env, "writer"], [env, "reader"], ...requiredOf(waves, env).map((e) => [e, "reader"])];
208
201
  /** The header lines saying what the cloud identity is for, when a job here holds a cloud-minted role. */
209
202
  function identityHeader(forge, clouds) {
210
203
  if (clouds.length === 0)
@@ -226,8 +219,6 @@ const secrets = (names) => Object.fromEntries(names.map((n) => [n, secret(n)]));
226
219
  * The remote-tracking ref is what chant's push lease reads.
227
220
  */
228
221
  export const FETCH_APPROVALS = "git fetch --no-tags origin '+refs/heads/chant/lifecycle:refs/remotes/origin/chant/lifecycle' && git branch -f chant/lifecycle origin/chant/lifecycle || echo 'no chant/lifecycle branch yet, so nothing is approved'";
229
- /** The apply jobs' lock settings: wait for another apply's lock, and stand down for a newer commit on main. */
230
- export const APPLY_LOCK = { YODEL_LOCK_WAIT: "10m", YODEL_STAND_DOWN: "1" };
231
222
  /** The watch reads; it never pushes. See the comment at the top. */
232
223
  export const NO_PUSH = "git remote set-url --push origin no-push://the-drift-watch-only-reads";
233
224
  /** After the watch's `chant run`: drift against the history, the environment's tracking issue, and exit 2 on drift. */
@@ -685,13 +676,14 @@ export const APPLY_PIPELINE = "yodel-apply";
685
676
  * The waves spec. What the file holds is the same for every forge; each
686
677
  * forge's jobs get their own variables on top (`variables`).
687
678
  *
688
- * With `step` (#291), a chant whose sql lexicon has the `sql-migrate`
689
- * capability (chant#4569): the spec names the capability, and chant plans
690
- * and applies each run through it, which calls the same engine entry points
691
- * (`yodel apply <env> --wave-plan` and `--wave-apply`) by a fixed argv. The
692
- * spec then has no `plan` or `apply` callback. Without it, the callbacks.
679
+ * The spec names the sql lexicon's `sql-migrate` capability (#291,
680
+ * chant#4569), and chant plans and applies each run through it, which calls
681
+ * the engine's entry points (`yodel apply <env> --wave-plan` and
682
+ * `--wave-apply`) by a fixed argv. yodel's own `plan` and `apply` callbacks,
683
+ * which a 0.10.1 spec has, left in 0.12 (#303). chant locks each run's
684
+ * environment and stands a superseded run down (`standDown`, #293).
693
685
  *
694
- * The steps around apply (#64) under `step`: chant refuses `hooks.apply.runBy:
686
+ * The steps around apply (#64): chant refuses `hooks.apply.runBy:
695
687
  * "apply"` with a capability step, and it would run apply-stage hooks
696
688
  * around the step itself, outside the engine's lock, while `--wave-apply`
697
689
  * with no CHANT_HOOKS runs the steps at base under its lock as well. So the
@@ -701,21 +693,16 @@ export const APPLY_PIPELINE = "yodel-apply";
701
693
  * the base commit, as it does run by hand. A step runs once, under the
702
694
  * lock, as #107 asks.
703
695
  */
704
- export function wavesSpec(waves, variables, resume, options = {}) {
696
+ export function wavesSpec(waves, variables, resume) {
705
697
  const first = waves[0];
706
698
  if (!first)
707
699
  throw new Error("no waves to render");
708
700
  return {
709
701
  name: APPLY_PIPELINE,
710
702
  op: `migrate-${first.env}`,
711
- ...(options.step
712
- ? { step: { kind: SQL_MIGRATE, environment: "{target}", spec: WAVES_SPEC } }
713
- : {
714
- plan: ["yodel", "apply", "{target}", "--wave-plan", "{plan}", "--spec", WAVES_SPEC],
715
- apply: ["yodel", "apply", "{target}", "--wave-apply", "{plan}", "--spec", WAVES_SPEC],
716
- }),
703
+ step: { kind: SQL_MIGRATE, environment: "{target}", spec: WAVES_SPEC },
717
704
  // chant's stand-down (#293): the job applies nothing and exits 6 when a newer commit on main will apply the same environments.
718
- ...(options.step && options.chantLocks ? { standDown: true } : {}),
705
+ standDown: true,
719
706
  branches: [MAIN],
720
707
  waves: waves.map((w) => ({
721
708
  name: w.env,
@@ -725,90 +712,42 @@ export function wavesSpec(waves, variables, resume, options = {}) {
725
712
  ...(w.approval !== undefined && w.approval !== "ledger" ? { approval: w.approval } : {}),
726
713
  ...(variables ? { environment: { name: w.env }, variables: variables(w.env) } : {}),
727
714
  // The steps around apply (#64) as chant's stage hooks, which the apply runs under its lock (#206).
728
- ...hooksOf(w.steps, options.step === true),
715
+ ...hooksOf(w.steps),
729
716
  })),
730
717
  ...(resume ? { resume } : {}),
731
718
  };
732
719
  }
733
- /**
734
- * Whether the installed chant locks and stands down the waves itself (#293):
735
- * `@intentius/chant/op` exports `OP_WAVE_STAND_DOWN_FLOOR` and
736
- * `newerCommitOnBranch` (chant#4581), and the sql lexicon gives SQL members
737
- * their lock grain, the environment (`sqlDefaultLockGrain`, chant#4571, on
738
- * chant#4552's grain). Then the apply jobs carry no lock settings of their
739
- * own: chant's lease on the target keeps two applies of one environment
740
- * apart and exits 5 (`held`) for the one that finds it taken, the engine's
741
- * own lock still guards the history under it, and a superseded apply exits
742
- * 6 (`superseded`). Lazy imports, with the specifiers in variables, so a
743
- * published chant keeps YODEL_LOCK_WAIT and YODEL_STAND_DOWN.
744
- */
745
- export async function chantLocksWaves() {
746
- const op = "@intentius/chant/op";
747
- const grain = "@intentius/chant-lexicon-sql/lock-grain";
748
- try {
749
- const m = (await import(op));
750
- const g = (await import(grain));
751
- return typeof m.OP_WAVE_STAND_DOWN_FLOOR === "string" && typeof m.newerCommitOnBranch === "function" && typeof g.sqlDefaultLockGrain === "function";
752
- }
753
- catch {
754
- return false;
755
- }
756
- }
757
720
  /** The sql lexicon's capability for a versioned environment (chant#4569). */
758
721
  export const SQL_MIGRATE = "sql-migrate";
759
- /**
760
- * Whether the installed sql lexicon plans and applies through chant (#291):
761
- * it exports `sqlCapabilityPlugin` (chant#4569), and the chant that ships
762
- * with it runs an op wave's `step`. A lazy import, with the specifier in a
763
- * variable, so a published lexicon without it keeps the callbacks.
764
- */
765
- export async function hasSqlCapability() {
766
- const specifier = "@intentius/chant-lexicon-sql/capability-plugin";
767
- try {
768
- const m = (await import(specifier));
769
- return m.sqlCapabilityPlugin !== undefined && m.sqlCapabilityPlugin !== null;
770
- }
771
- catch {
772
- return false;
773
- }
774
- }
775
- /** A wave's stage hooks from its steps, when it has any; under a capability `step`, the `before.plan` checks only ({@link wavesSpec}). */
776
- function hooksOf(steps, step = false) {
777
- const hooks = stepHooks(steps);
778
- if (!hooks)
779
- return {};
780
- if (!step)
781
- return { hooks };
782
- const plan = hooks.before?.plan;
722
+ /** A wave's stage hooks from its steps, when it has any: the `before.plan` checks only, under the capability `step` ({@link wavesSpec}). */
723
+ function hooksOf(steps) {
724
+ const plan = stepHooks(steps)?.before?.plan;
783
725
  return plan && plan.length > 0 ? { hooks: { before: { plan } } } : {};
784
726
  }
785
727
  /**
786
- * The waves spec file and the apply pipeline on each forge. With `product`
787
- * (chant's product pipeline, #289), the spec comes from chant's
788
- * productPipelineJobs under yodel's words, and each job runs `yodel chant`
789
- * where chant's own runs `chant` ({@link productWaves}).
728
+ * The waves spec file and the apply pipeline on each forge. The spec comes
729
+ * from chant's productPipelineJobs under yodel's words (#289), and each job
730
+ * runs `yodel chant` where chant's own runs `chant` ({@link productWaves}).
790
731
  */
791
732
  export async function applyPipelines(dir, envs, product) {
792
733
  const { dialect, waves } = envs;
793
734
  const tc = toolchainOf(envs);
794
735
  const { generateOpWavesPipeline } = (await import("@intentius/chant/op"));
795
- const named = (forge, spec) => (product ? productWaves(product, forge, spec) : { spec, jobs: [] });
796
- // Through chant's product pipeline, the sql capability plans and applies (#291) when the installed lexicon has it.
797
- const capable = product !== undefined && (await hasSqlCapability());
798
- // chant's lock grain and stand-down (#293), under the capability, when chant has them.
799
- const step = { step: capable, chantLocks: capable && (await chantLocksWaves()) };
800
- const out = [{ path: WAVES_SPEC, content: `${JSON.stringify(named("github", wavesSpec(waves, undefined, undefined, step)).spec, null, 2)}\n` }];
736
+ const named = (forge, spec) => productWaves(product, forge, spec);
737
+ const out = [{ path: WAVES_SPEC, content: `${JSON.stringify(named("github", wavesSpec(waves)).spec, null, 2)}\n` }];
801
738
  // A GitLab job already has the project's variables, a writer's only under its environment.
802
739
  const variables = (forge) => (env) => {
803
740
  const wave = waves.find((w) => w.env === env);
804
741
  const required = wave?.requires;
805
742
  return {
806
743
  YODEL_CREDENTIALS: `writer:${env}`,
807
- ...(step.chantLocks ? {} : APPLY_LOCK),
808
744
  ...(forge === "gitlab"
809
745
  ? {}
810
746
  : {
811
747
  ...secrets([...writerVariables(env, dialect, envs.credentials?.[env]), ...WEBHOOK_VARIABLES]),
748
+ // chant's sql-migrate runs the wave's yodel plan --part and --wave-plan with the writer taken out
749
+ // (readerEnv in the sql lexicon), so they connect as the environment's reader.
750
+ ...secrets(readerVariables(env, dialect, envs.credentials?.[env])),
812
751
  ...(required ? secrets(readerVariables(required, dialect, envs.credentials?.[required])) : {}),
813
752
  // A pr-review wave (#48) reads the merged pull request's reviews with the job's token.
814
753
  ...(wave?.approval === "pr-review" ? { GITHUB_TOKEN: "${{ github.token }}" } : {}),
@@ -825,9 +764,10 @@ export async function applyPipelines(dir, envs, product) {
825
764
  "# exits 3 with the yodel approve command, so the waves after it do not run.",
826
765
  "# yodel approve <env> records the approval and starts the waiting job again",
827
766
  "# (or approve, push chant/lifecycle, and run the failed job again). These are",
828
- "# the only jobs that hold a writer's credentials, one environment's each, with",
829
- "# the reader of the environment before (waves[].requires): yodel apply refuses",
830
- "# a migration that environment's history does not record as applied.",
767
+ "# the only jobs that hold a writer's credentials, one environment's each. Each",
768
+ "# also holds its environment's reader, which the plan runs as, and the reader of",
769
+ "# the environment before (waves[].requires): yodel apply refuses a migration",
770
+ "# that environment's history does not record as applied.",
831
771
  ];
832
772
  const resumeHeader = (forge) => [
833
773
  ...HEADER,
@@ -851,7 +791,7 @@ export async function applyPipelines(dir, envs, product) {
851
791
  "# holds no writer's credentials: it plans with each environment's reader.",
852
792
  ];
853
793
  for (const forge of FORGES) {
854
- const { spec, jobs } = named(forge, wavesSpec(waves, variables(forge), envs.resume, step));
794
+ const { spec, jobs } = named(forge, wavesSpec(waves, variables(forge), envs.resume));
855
795
  const result = await generateOpWavesPipeline(spec, forge, {
856
796
  specFile: WAVES_SPEC,
857
797
  image: tc.image,
@@ -1050,14 +990,12 @@ export async function withTenants(dir, waves) {
1050
990
  // recorded keep counting), and each job running `yodel chant` where chant's
1051
991
  // own runs `chant`, so the job writes yodel's statuses and approve lines.
1052
992
  // The forge lexicons serialize the jobs as before, and yodel adds its
1053
- // reports, logins and readers to them as before. A chant without the entry
1054
- // leaves every file as yodel rendered it before, so main stays green on its
1055
- // published chant.
993
+ // reports, logins and readers to them as before.
1056
994
  //
1057
- // Still yodel's own until chant can run them: the plan jobs (`yodel plan
1058
- // <env> --comment` with the write probe) wait for the sql lexicon's
1059
- // capability (chant#4569) and the note through chant's renderer (#290); the
1060
- // lint job for the check hook (#294); the watch for chant#4582
995
+ // Still yodel's own: the plan jobs (`yodel plan <env> --comment` with the
996
+ // write probe), which post chant's note (../pr/note.ts, #290); the lint
997
+ // job's own steps for a project with no workspace declaration, which has
998
+ // no check hooks to run (#294); the watch until chant#4582
1061
999
  // ({@link watchPipelines}).
1062
1000
  /** The spec under yodel's words, and the wave jobs chant's product pipeline names for `forge`. */
1063
1001
  export function productWaves(product, forge, spec) {
@@ -1073,10 +1011,8 @@ export function productWaves(product, forge, spec) {
1073
1011
  }
1074
1012
  /** A `chant` command line in a rendered file: a step's `run:` or a GitLab script line, never a comment. */
1075
1013
  const CHANT_LINE = /^(\s*(?:- )?(?:run: )?)(chant [a-z].*)$/gm;
1076
- /** `yaml` with yodel's bin in each chant command line (#289), through chant's own productCommand; unchanged without `product`. */
1014
+ /** `yaml` with yodel's bin in each chant command line (#289), through chant's own productCommand. */
1077
1015
  export function withBin(product, yaml) {
1078
- if (!product)
1079
- return yaml;
1080
1016
  const words = product.assertProductWords(YODEL_WORDS);
1081
1017
  return yaml.replace(CHANT_LINE, (_m, lead, line) => `${lead}${product.productCommand(words, line)}`);
1082
1018
  }
@@ -1163,9 +1099,9 @@ function withWatchIdTokens(yaml, envs) {
1163
1099
  return emit(doc);
1164
1100
  }
1165
1101
  /**
1166
- * The drift watches. With `product` (#289) each job runs `yodel chant run
1167
- * watch-<env>` where chant's runs `chant run watch-<env>`, so the Op's
1168
- * statuses and notices say yodel.
1102
+ * The drift watches, through chant's product pipeline (#289): each job runs
1103
+ * `yodel chant run watch-<env>` where chant's runs `chant run watch-<env>`,
1104
+ * so the Op's statuses and notices say yodel.
1169
1105
  *
1170
1106
  * The job stays chant's generateOpsPipeline and its last line stays `yodel
1171
1107
  * drift <env> --issue`, which plans the build for ClickHouse grant drift
@@ -1354,24 +1290,29 @@ export function forgeOf(path) {
1354
1290
  return "gitlab";
1355
1291
  return undefined;
1356
1292
  }
1293
+ /** chant's product pipeline (#289), which every pipeline renders through; refused, naming the install line, on a chant without it. */
1294
+ export async function requireProduct() {
1295
+ const product = await chantProduct();
1296
+ if (!product)
1297
+ throw new Error(`the installed chant has no product pipeline (@intentius/chant/ci-product), and yodel ci renders every pipeline on it from chant ${CHANT_CI_FLOOR}. Install it, then run yodel upgrade:\n ${installLine()}`);
1298
+ return product;
1299
+ }
1357
1300
  /**
1358
- * Every file `yodel ci` writes. Through chant's product pipeline when the
1359
- * installed chant has it (#289), unless `options.product` is false, which
1360
- * renders with yodel's own generator as a chant before chant#4550 does.
1361
- * `options.declaration` is a workspace declaration to render the check
1362
- * hooks into when the project has none on disk: the one `yodel upgrade`
1363
- * adds (#298).
1301
+ * Every file `yodel ci` writes, through chant's product pipeline (#289).
1302
+ * Yodel's own generator, for a chant before chant#4550, left in 0.12
1303
+ * (#303). `options.declaration` is a workspace declaration to render the
1304
+ * check hooks into when the project has none on disk: the one `yodel
1305
+ * upgrade` adds (#298). A project with no declaration, in its directory or
1306
+ * given here, keeps the lint job's own steps ({@link checkHooksDeclaration}).
1364
1307
  */
1365
1308
  export async function render(dir, options = {}) {
1366
1309
  const envs = await environments(dir);
1367
1310
  const forges = envs.forges ?? FORGES;
1368
1311
  if (envs.checkOnly)
1369
1312
  return review(envs).filter((f) => forges.includes(forgeOf(f.path)));
1370
- const product = options.product === false ? undefined : await chantProduct();
1371
- // The cloud login through chant's ci-identity (#296), with the product pipeline, when chant and the sql lexicon have it.
1372
- useChantTrade(product ? await chantTrade() : undefined);
1373
- // The check on chant's check moment (#294), with the product pipeline, when chant has the moment and the project a declaration.
1374
- const hooks = product ? await checkHooksDeclaration(dir, envs, options.declaration) : undefined;
1313
+ const product = await requireProduct();
1314
+ // The check on chant's check moment (#294), when the project has a declaration.
1315
+ const hooks = await checkHooksDeclaration(dir, envs, options.declaration);
1375
1316
  const reviewed = hooks ? { ...envs, checkHooks: true } : envs;
1376
1317
  // ci.apply: false (#175): no waves spec and no apply pipeline on any forge.
1377
1318
  const files = [...review(reviewed), ...(hooks ? [hooks] : []), ...(rendersApply(envs) ? await applyPipelines(dir, envs, product) : []), ...(await watchPipelines(dir, envs, product))];