@futurelastic/colab-handbook 1.18.0-rc.11 → 1.18.0-rc.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/audit/audit.mjs CHANGED
@@ -897,6 +897,16 @@ function makeSource(target) {
897
897
  return [];
898
898
  }
899
899
  },
900
+ // #676: the tracked files at HEAD under the given declared `migrations:` entries (pathspec-
901
+ // limited, never the whole tree). null = git could not list — the check then says nothing.
902
+ filesAtHeadUnder: (paths) => {
903
+ try {
904
+ const out = execFileSync("git", ["-C", root, "ls-tree", "-r", "--name-only", "HEAD", "--", ...paths], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], maxBuffer: 64 * 1024 * 1024 });
905
+ return out.split("\n").map((s) => s.trim()).filter(Boolean);
906
+ } catch {
907
+ return null;
908
+ }
909
+ },
900
910
  // Every path under a directory named `migrations` (#383's undeclared-layout check). null =
901
911
  // git could not list — the check then says nothing rather than reporting a clean tree.
902
912
  migrationDirFiles: () => {
@@ -928,6 +938,8 @@ function makeSource(target) {
928
938
  // Same cost argument as markdownFiles: a recursive tree listing per repo per sweep. null = not
929
939
  // enumerated, so #383's undeclared-migration-layout check is local-only, silently.
930
940
  migrationDirFiles: () => null,
941
+ // Same cost argument: the declared-path existence check (#676) is local-only too.
942
+ filesAtHeadUnder: () => null,
931
943
  tags: () => listRemoteTags(target.slug),
932
944
  metadata: () => readRemoteMetadata(target.slug),
933
945
  // The duration report (#137) needs a per-commit walk over historical blobs
@@ -1438,6 +1450,13 @@ function auditRepoInner(target, ctx) {
1438
1450
  const why = migrationPaths.noneContradiction(migCfg.none, migrationPaths.defaultLayoutDirs([...new Set(dirsOf)]));
1439
1451
  if (why) fail(`migrations: ${why}`);
1440
1452
  }
1453
+ // #676: a declared path that names nothing at HEAD is not a layout — release cut/finalize no
1454
+ // longer count it as one, and here it fails where the declaration is read, so the typo is found
1455
+ // before a release refuses on it. Local-only, like the rules around it.
1456
+ if (migCfg.paths.length && src.filesAtHeadUnder) {
1457
+ const presence = migrationPaths.declaredPresence(migCfg.paths, src.filesAtHeadUnder(migCfg.paths));
1458
+ if (presence && presence.missing.length) fail(`migrations: ${migrationPaths.missingNote(presence.missing, "HEAD")}`);
1459
+ }
1441
1460
  if (migFiles) {
1442
1461
  const undeclared = migrationPaths.undeclaredMigrationDirs(migFiles, migCfg.paths);
1443
1462
  if (undeclared.length) {
package/package.json CHANGED
@@ -33,5 +33,5 @@
33
33
  "engines": {
34
34
  "node": ">=18"
35
35
  },
36
- "version": "1.18.0-rc.11"
36
+ "version": "1.18.0-rc.12"
37
37
  }
package/tools/colab CHANGED
@@ -1493,17 +1493,27 @@ function measureCandidateConditions(repoAbs, { sha, lastFinal, at, readRuns, iss
1493
1493
  // path anywhere wins: the gate then sees more, never less). The default-layout guard is the verdicts'.
1494
1494
  const noneAt = declared.length ? null : migrationPaths.parseMigrationPaths(projectDocAt(repoAbs, sha)).none;
1495
1495
  const none = noneAt ? { ...noneAt, dirs: layoutDirs || [] } : null;
1496
+ // #676: a declared path is a layout only where it names something AT THE CANDIDATE — a misspelled or
1497
+ // stale entry used to open the grant gate having read nothing. null = the tree could not be listed.
1498
+ let presence = { present: [], missing: [] };
1499
+ if (declared.length) {
1500
+ // Pathspec-limited: only what sits under a declared entry is listed, never the whole tree.
1501
+ const filesR = git.git(['ls-tree', '-r', '--name-only', sha, '--', ...declared], repoAbs, { maxBuffer: 64 * 1024 * 1024 });
1502
+ presence = migrationPaths.declaredPresence(declared, filesR.ok ? filesR.stdout.split('\n').filter(Boolean) : null);
1503
+ }
1504
+ const missing = presence ? presence.missing : [];
1496
1505
  const schema = changes === null
1497
1506
  ? { ok: false, unread: true, detail: 'git diff failed — schema changes cannot be read' }
1498
- : releaseCut.schemaVerdict(changes, lastFinal || 'the first commit', declared, layout, none);
1507
+ : releaseCut.schemaVerdict(changes, lastFinal || 'the first commit', declared, presence ? layout : null, none, presence ? missing : null);
1499
1508
  // #441: every migration file since the last final, destructive or not — an operator-granted
1500
1509
  // automatic final refuses an ungranted one (release-finalize.js migrationGrantVerdict).
1501
1510
  const migrations = changes === null ? null : changes.filter((c) => releaseCut.isMigrationPath(c.path, declared)).map((c) => c.path);
1502
- // #671: could a migration have been seen at all? A declared prefix is a layout; otherwise the
1503
- // default-layout reading above (null = unread, never "absent"). The grant gate fails closed
1504
- // without one, so its empty list never reads "nothing read" as "nothing changed".
1505
- const migrationLayout = declared.length ? true : layout;
1506
- return { ci, suite, schema, switches, issues, migrations, migrationLayout, migrationsNone: none };
1511
+ // #671: could a migration have been seen at all? A declared prefix is a layout — #676: only one that
1512
+ // exists at the candidate; otherwise the default-layout reading above (null = unread, never
1513
+ // "absent"). The grant gate fails closed without one, so its empty list never reads "nothing read"
1514
+ // as "nothing changed". An unlistable tree with a declaration is unread, never a layout.
1515
+ const migrationLayout = !presence ? null : presence.present.length ? true : layout;
1516
+ return { ci, suite, schema, switches, issues, migrations, migrationLayout, migrationsNone: none, migrationsMissing: missing };
1507
1517
  }
1508
1518
 
1509
1519
  /**
@@ -1641,7 +1651,7 @@ function finalTags(repoAbs, onlyTags = null) {
1641
1651
  * since the newest final. The version is computed here only to find that tracking issue; decide()
1642
1652
  * computes it again from the same inputs, so the two cannot disagree.
1643
1653
  */
1644
- function measureFastRoute(repoAbs, { policy, remote, issues, lastFinal, tags, auto, migrationPaths: paths, migrationLayout = null, migrationsNone = null, remoteTags = null }) {
1654
+ function measureFastRoute(repoAbs, { policy, remote, issues, lastFinal, tags, auto, migrationPaths: paths, migrationLayout = null, migrationsNone = null, migrationsMissing = [], remoteTags = null }) {
1645
1655
  const grantDecl = policy.effective.finalGrant;
1646
1656
  const trust = trustAt(repoAbs, `${remote}/main`);
1647
1657
  const finalGrant = isGhUsable(repoAbs)
@@ -1661,7 +1671,7 @@ function measureFastRoute(repoAbs, { policy, remote, issues, lastFinal, tags, au
1661
1671
  : { ok: false, reason: 'no tracking issue yet to carry a grant' };
1662
1672
  if (grant && grant.ok) grant = { ...grant, issue: tracking.number };
1663
1673
  }
1664
- const migrations = { ...releaseFinalize.migrationGrantVerdict({ paths, grant, since: lastFinal, layout: migrationLayout, none: migrationsNone }), paths: paths || null };
1674
+ const migrations = { ...releaseFinalize.migrationGrantVerdict({ paths, grant, since: lastFinal, layout: migrationLayout, none: migrationsNone, missing: migrationsMissing }), paths: paths || null };
1665
1675
  const spacing = releaseCut.spacingVerdict({ finals: finalTags(repoAbs, remoteTags), spacingHours: policy.effective.finalSpacingHours, now: new Date().toISOString() });
1666
1676
  return { finalGrant, holds, migrations, spacing, tracking };
1667
1677
  }
@@ -1754,7 +1764,7 @@ function cmdReleaseCut(argv) {
1754
1764
  const tags = lines(git.git(['tag', '--list'], repoAbs)).filter(onRemote);
1755
1765
  const tagsAtSha = lines(git.git(['tag', '--points-at', sha], repoAbs)).filter(onRemote);
1756
1766
 
1757
- const { ci, suite, schema, switches, issues, migrations: migrationPathsSince, migrationLayout, migrationsNone } = measureCandidateConditions(repoAbs, {
1767
+ const { ci, suite, schema, switches, issues, migrations: migrationPathsSince, migrationLayout, migrationsNone, migrationsMissing } = measureCandidateConditions(repoAbs, {
1758
1768
  sha, lastFinal, at, readRuns: () => releaseCut.withoutOwnWorkflow(git.ghRunsForCommit(repoAbs, 'main', sha)), // #425
1759
1769
  verifying: verifyingPolicy(repoAbs), // #624: the ship gate's rule for which runs may veto
1760
1770
  });
@@ -1770,7 +1780,7 @@ function cmdReleaseCut(argv) {
1770
1780
  // #446: route deploy-tag-fast — the grant, the human veto, the migration gate and the spacing are
1771
1781
  // measured only there, so every candidate route's run is what it was.
1772
1782
  const fast = releaseCut.isFastRoute(policy) && !policy.findings.length;
1773
- const fastFacts = fast ? measureFastRoute(repoAbs, { policy, remote, issues, lastFinal, tags, auto, migrationPaths: migrationPathsSince, migrationLayout, migrationsNone, remoteTags }) : {};
1783
+ const fastFacts = fast ? measureFastRoute(repoAbs, { policy, remote, issues, lastFinal, tags, auto, migrationPaths: migrationPathsSince, migrationLayout, migrationsNone, migrationsMissing, remoteTags }) : {};
1774
1784
  if (fast && auto) auto.spacing = fastFacts.spacing;
1775
1785
  // #590: route library-fast — a final with nothing deployed. The release-hold veto is its one extra
1776
1786
  // read; a hand cut also needs MIGRATION.md for a manifest-declared major (--auto reads it already).
@@ -2257,7 +2267,7 @@ function cmdReleaseFinalize(argv) {
2257
2267
  const mg = tracking && tracking.number
2258
2268
  ? migrationGrant.evaluateIssue(rec, cand.version, tracking.number, labels.MIGRATION_GRANT_LABEL, { trust })
2259
2269
  : { ok: false, reason: 'no tracking issue yet to carry a grant' };
2260
- migrations = releaseFinalize.migrationGrantVerdict({ paths: conditions.migrations, grant: mg, since: releaseTag.latestReleaseTag(repoAbs, { ref: cand.sha, onlyTags: remoteTags }), layout: conditions.migrationLayout, none: conditions.migrationsNone });
2270
+ migrations = releaseFinalize.migrationGrantVerdict({ paths: conditions.migrations, grant: mg, since: releaseTag.latestReleaseTag(repoAbs, { ref: cand.sha, onlyTags: remoteTags }), layout: conditions.migrationLayout, none: conditions.migrationsNone, missing: conditions.migrationsMissing });
2261
2271
  }
2262
2272
  const verdict = releaseFinalize.decide({
2263
2273
  policy, selection: sel, tracking, supersededHeld, period, trunk, regressions,
@@ -172,6 +172,32 @@ function unionPaths(...docs) {
172
172
  return out;
173
173
  }
174
174
 
175
+ /**
176
+ * #676: which declared entries name something at a commit. `files` is that commit's tracked-file list
177
+ * (`git ls-tree -r --name-only <sha>`), or null when it could not be read. A directory entry exists
178
+ * when a tracked file sits under it, a no-slash entry when it is that file or a directory holding one
179
+ * (entryCovers, the same rule the gate matches by). Returns `{ present, missing }` in declared order,
180
+ * or null for an unread tree — never "everything missing", which would be a guess.
181
+ *
182
+ * Before this a declared path counted as a layout whether or not it existed, so a misspelled or stale
183
+ * entry opened the migration-grant gate having read nothing. Only `present` is a layout; `missing` is
184
+ * named wherever the gate reports, and a gate with nothing else to read fails closed.
185
+ */
186
+ function declaredPresence(declared, files) {
187
+ if (!Array.isArray(files)) return null;
188
+ const present = [];
189
+ const missing = [];
190
+ for (const p of declared || []) (files.some((f) => entryCovers(p, f)) ? present : missing).push(p);
191
+ return { present, missing };
192
+ }
193
+
194
+ /** `missing` (declaredPresence) as the one sentence every gate appends — empty when none is missing. */
195
+ function missingNote(missing, where = 'the candidate') {
196
+ if (!missing || !missing.length) return '';
197
+ const list = missing.join(', ');
198
+ return `declared \`migrations:\` ${missing.length === 1 ? 'path' : 'paths'} ${list} ${missing.length === 1 ? 'does' : 'do'} not exist at ${where}, so nothing was read there — fix or remove ${missing.length === 1 ? 'the entry' : 'the entries'} in .github/project.yml (a misspelled or stale path is not a layout, #676)`;
199
+ }
200
+
175
201
  /** Is `file` (repo-relative, `/`-separated) a migration under the defaults or a declared prefix? */
176
202
  function isMigrationPath(file, declared) {
177
203
  const f = String(file || '');
@@ -215,5 +241,5 @@ function undeclaredMigrationDirs(files, declared) {
215
241
 
216
242
  module.exports = {
217
243
  DEFAULT_MIGRATION_PATHS, parseMigrationPaths, unionPaths, isMigrationPath, isDeclaredFile, undeclaredMigrationDirs,
218
- noneContradiction, defaultLayoutDirs,
244
+ noneContradiction, defaultLayoutDirs, declaredPresence, missingNote,
219
245
  };
@@ -927,8 +927,22 @@ function laravelDestructive(up, addedBefore) {
927
927
  * true / false / null (the tree could not be read — never "absent"). Undefined = a caller that does
928
928
  * not measure it, read as today: present. `none` (#672) = the candidate's `migrations: none` block
929
929
  * (`{ reason, dirs? }`), or absent.
930
+ *
931
+ * #676: `missing` = the declared entries that do not exist at the candidate (migration-paths.js
932
+ * declaredPresence). They still classify a change (a file deleted under one is still read — the gate
933
+ * sees more, never less), but they are not a layout and not in the ✓'s scope: with nothing else to
934
+ * read the verdict is NOT CHECKED naming them, and beside a real layout every detail names them.
935
+ * `missing` null = the tree could not be listed (pass `layout` null with it): unread, never a ✓.
936
+ * Undefined = a caller that does not measure it, read as before: every declared path present.
930
937
  */
931
- function schemaVerdict(changes, since, declared, layout, none) {
938
+ function schemaVerdict(changes, since, declared, layout, none, missing) {
939
+ const v = schemaVerdictCore(changes, since, declared, layout, none, missing);
940
+ const note = v.missingNamed ? '' : migrationPaths.missingNote(missing);
941
+ const { missingNamed, ...out } = v;
942
+ return note ? { ...out, detail: `${out.detail} — ${note}` } : out;
943
+ }
944
+
945
+ function schemaVerdictCore(changes, since, declared, layout, none, missing) {
932
946
  // #672: the candidate's `migrations: none` block. Contradicted by a default layout → refused on every
933
947
  // cut, whatever changed; otherwise, with nothing changed, "not checked" naming the declaration —
934
948
  // never a ✓ (nothing was read), never the "declare a layout" advice (the repo already answered).
@@ -947,14 +961,19 @@ function schemaVerdict(changes, since, declared, layout, none) {
947
961
  const unread = (declared && declared.length)
948
962
  ? history.filter((c) => !/\.(php|sql)$/.test(c.path) && !migrationPaths.isMigrationPath(c.path, []))
949
963
  : [];
950
- const scope = `Laravel database/migrations + Prisma prisma/migrations${declared && declared.length ? ` + declared ${declared.join(', ')} (php/sql only; a declared file: the SQL it added)` : ''} — other layouts are not read`;
951
- const hasDeclared = !!(declared && declared.length);
964
+ // `missing` null = the candidate's tree could not be listed: no declared path is known to exist.
965
+ const present = missing === null ? [] : (declared || []).filter((p) => !(missing || []).includes(p));
966
+ const scope = `Laravel database/migrations + Prisma prisma/migrations${present.length ? ` + declared ${present.join(', ')} (php/sql only; a declared file: the SQL it added)` : ''} — other layouts are not read`;
967
+ const hasDeclared = present.length > 0;
952
968
  const notChecked = (why) => ({ ok: true, checked: false, detail: `not checked — ${why}` });
953
969
  const unreadWhy = () => `${unread.length} declared migration file(s) changed since ${since} in a format this check does not read (php/sql only) — a human reads them before the final: ${unread.map((c) => c.path).join(', ')}`;
954
970
  const howToDeclare = 'a repo whose migrations live elsewhere declares their directory as `migrations:` in .github/project.yml (project.schema.md `migrations`); a repo with no schema migrations declares `migrations:` then `none: <why>` (#672)';
955
971
  if (!migrations.length && !schemaFiles.length) {
956
972
  if (unread.length) return notChecked(unreadWhy());
957
973
  if (none && layout === false) return notChecked(`the repo declares \`migrations: none\` (${none.reason}) and no Laravel or Prisma migrations directory exists at the candidate, so there is no schema to read`);
974
+ if (!hasDeclared && layout === false && missing && missing.length) {
975
+ return { ...notChecked(`the declared \`migrations:\` ${missing.length === 1 ? 'path' : 'paths'} ${missing.join(', ')} ${missing.length === 1 ? 'does' : 'do'} not exist at the candidate and there is no Laravel database/migrations/ or Prisma prisma/migrations/ directory, so no migration was read — fix the path (a misspelled or stale entry is not a layout, #676), or ${howToDeclare}`), missingNamed: true };
976
+ }
958
977
  if (!hasDeclared && layout === false) return notChecked(`no Laravel database/migrations/ or Prisma prisma/migrations/ directory at the candidate and no \`migrations:\` declared, so no migration was read — ${howToDeclare}`);
959
978
  if (!hasDeclared && layout === null) return notChecked(`the tree at the candidate could not be read for a migration layout, so no migration was read — ${howToDeclare}`);
960
979
  return { ok: true, detail: `no migration file changed since ${since} (${scope})` };
@@ -569,9 +569,19 @@ function regressionVerdict(edges, { periodStart }) {
569
569
  * (`{ reason, dirs? }` — `dirs` the default-layout directories found, for the refusal), honoured only where no default layout exists (`layout` false). With a layout there
570
570
  * (`layout` true) the declaration is a contradiction and the gate refuses, migrations changed or not:
571
571
  * a repo that can have migrations is never waved through; an unread tree still fails closed.
572
+ * #676: `layout` true comes from a declared path only when it EXISTS at the candidate
573
+ * (migration-paths.js declaredPresence); `missing` lists the declared paths that do not. Every detail
574
+ * names them, and with nothing else to read the refusal says so — a misspelled or stale path is not
575
+ * a layout. Missing beside a real layout is reported, never refused: the gate reads what exists.
572
576
  * Returns { ok, detail } (+ unread: true when something could not be read).
573
577
  */
574
- function migrationGrantVerdict({ paths, grant, since, layout, none }) {
578
+ function migrationGrantVerdict(args) {
579
+ const { missingNamed, ...v } = migrationGrantVerdictCore(args);
580
+ const note = missingNamed ? '' : migrationPaths.missingNote(args.missing);
581
+ return note ? { ...v, detail: `${v.detail} — ${note}` } : v;
582
+ }
583
+
584
+ function migrationGrantVerdictCore({ paths, grant, since, layout, none, missing }) {
575
585
  if (paths === null || paths === undefined) return { ok: false, unread: true, detail: 'the migration files since the last final could not be read — an unread migration is not an absent one' };
576
586
  if (none) {
577
587
  if (layout === true) return { ok: false, detail: `${migrationPaths.noneContradiction(none, none.dirs && none.dirs.length ? none.dirs : ['a Laravel database/migrations/ or Prisma prisma/migrations/ directory'])} — then the usual migration grant applies (COLAB_HUMAN=1 colab migration-grant <tracking issue> --branch <version>)` };
@@ -584,6 +594,10 @@ function migrationGrantVerdict({ paths, grant, since, layout, none }) {
584
594
  // #673: a schema applied inline by the server's own code is declarable too — as the FILE — and the
585
595
  // detail names the grant command that clears its next change, so no one reaches for a raw tag.
586
596
  const wayOut = 'declare where the schema lives as `migrations:` in .github/project.yml (project.schema.md `migrations`) — a migration directory (`migrations: [backend/migrations/]`) or, for a schema the server applies inline, the file itself (`migrations: [server/db.ts]`); a change under it then clears the usual way (COLAB_HUMAN=1 colab migration-grant <tracking issue> --branch <version>). A repo with no schema migrations at all declares that instead, with its reason (`migrations:` then `none: <why>`, #672). Until then the final is a human act, not the grant\'s';
597
+ if (layout === false && missing && missing.length) {
598
+ // #676: declared, but nothing it names is there — the same "cannot see" as an undeclared repo.
599
+ return { ok: false, missingNamed: true, detail: `no migration was read since ${since || 'the first commit'}: the declared \`migrations:\` ${missing.length === 1 ? 'path' : 'paths'} ${missing.join(', ')} ${missing.length === 1 ? 'does' : 'do'} not exist at the candidate and there is no Laravel database/migrations/ or Prisma prisma/migrations/ directory, so a migration would be invisible — fix the path (a misspelled or stale entry is not a layout, #676), or ${wayOut}` };
600
+ }
587
601
  if (layout === false) return { ok: false, detail: `no migration was read since ${since || 'the first commit'}: no \`migrations:\` declared and no Laravel database/migrations/ or Prisma prisma/migrations/ directory at the candidate, so a migration elsewhere would be invisible — ${wayOut}` };
588
602
  if (layout !== true) return { ok: false, unread: true, detail: `the tree at the candidate could not be read for a migration layout, so an empty migration list since ${since || 'the first commit'} is not evidence that none changed — ${wayOut}` };
589
603
  return { ok: true, detail: `no migration file changed since ${since || 'the first commit'}` };