@bongos/core 1.19.600 → 1.19.601

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/.bongos-core.json CHANGED
@@ -2,22 +2,22 @@
2
2
  "artifact": "bongos-core",
3
3
  "manifest_schema": 1,
4
4
  "generator": "scripts/gds/package-core.js",
5
- "core_version": "1.19.600",
6
- "core_contract": "1.19.600",
7
- "source_commit": "8e02f02563986161d1b77b266027bab29d5534aa",
5
+ "core_version": "1.19.601",
6
+ "core_contract": "1.19.601",
7
+ "source_commit": "16a19ddf0ad7e10177aea562deb878093568f308",
8
8
  "source_ref": "HEAD",
9
- "built_at": "2026-09-08T04:42:02.346Z",
9
+ "built_at": "2026-09-08T05:00:27.028Z",
10
10
  "redaction": {
11
11
  "model": "docs-redacted+functional-verbatim",
12
12
  "docs_redacted": 457,
13
13
  "agent_docs_stubbed": 24,
14
- "functional_verbatim": 2075,
14
+ "functional_verbatim": 2076,
15
15
  "rules": 3,
16
16
  "gate_literals": 3,
17
17
  "gate": "passed"
18
18
  },
19
- "file_count": 2556,
20
- "tree_sha256": "a008ff8e9029ba8be4b741e6ce36012a90a005bad10e76f4fed030cee2404487",
19
+ "file_count": 2557,
20
+ "tree_sha256": "eb65ec1fb208a9e7c09906234b5a43e7660816544a9b4ae44ecf94d7f64e6260",
21
21
  "files": [
22
22
  {
23
23
  "path": ".claude/skills/blocker-review/SKILL.md",
@@ -392,7 +392,7 @@
392
392
  {
393
393
  "path": "clients/bongos-client/index.d.ts",
394
394
  "mode": "0000644",
395
- "sha256": "16af99cbe6df845f0f7a90f4569f77550635af0967dce552e2ef07a7b4ef0080"
395
+ "sha256": "877ca14cd017c1392fcc5206c2f3603fb24becdc32670aa1e2ad0de9d930dfca"
396
396
  },
397
397
  {
398
398
  "path": "clients/bongos-client/index.mjs",
@@ -1852,7 +1852,7 @@
1852
1852
  {
1853
1853
  "path": "docs/api/openapi.json",
1854
1854
  "mode": "0000644",
1855
- "sha256": "f2433a337aed6aa2f0f1a1c2d61b17103b493a028fa03c2944b92b5f3bb5e609"
1855
+ "sha256": "81485c0440de636511dc9ee723e18af89f313b175ea626723d0beeeed31bba2f"
1856
1856
  },
1857
1857
  {
1858
1858
  "path": "docs/architecture.md",
@@ -2727,7 +2727,7 @@
2727
2727
  {
2728
2728
  "path": "docs/module-api-changelog.md",
2729
2729
  "mode": "0000644",
2730
- "sha256": "251ae2f82d65d325f220649d865bc5413a3febbf493db6994b6f3e9713968ac8"
2730
+ "sha256": "71f84a8b41b3efb16f49909dcf6b6542deecfa51378e24ad271267cf3de1d6a9"
2731
2731
  },
2732
2732
  {
2733
2733
  "path": "docs/modules-contract.md",
@@ -5567,12 +5567,12 @@
5567
5567
  {
5568
5568
  "path": "modules/lifecycle/db-versions.js",
5569
5569
  "mode": "0000644",
5570
- "sha256": "53f87c20f89c33a3d14ee4410bafa0f3122fb7534708ce5bdacb8cc1098a487c"
5570
+ "sha256": "2c10a17f86506788ab2f9db25c23024120ec9fddb3c7c4894e65d8354cd46869"
5571
5571
  },
5572
5572
  {
5573
5573
  "path": "modules/lifecycle/db.js",
5574
5574
  "mode": "0000644",
5575
- "sha256": "33fc8959d522bcf18c445b1a5710940379f84d1e938eecdc52cdf52bec9c4b3d"
5575
+ "sha256": "b4b2d6d7890ec67e52fc00718a814bf01a64f4432ed7380a175dca8bc794b0e4"
5576
5576
  },
5577
5577
  {
5578
5578
  "path": "modules/lifecycle/dead-deps.js",
@@ -5817,7 +5817,7 @@
5817
5817
  {
5818
5818
  "path": "modules/lifecycle/routes/versions.js",
5819
5819
  "mode": "0000644",
5820
- "sha256": "35919f2cdd1e9a5da11a89adc9731818aa6b1b292c0754d9123a4cd8324bd970"
5820
+ "sha256": "014de34389dbf26b4b089b677466c9c7cfd81f79b9e1714241be12f589086c0f"
5821
5821
  },
5822
5822
  {
5823
5823
  "path": "modules/lifecycle/routes/visuals.js",
@@ -7627,12 +7627,12 @@
7627
7627
  {
7628
7628
  "path": "package-lock.json",
7629
7629
  "mode": "0000644",
7630
- "sha256": "d3456f52cc8555eb1a20f884dc2d32240032138193c5d525ea455d07423e9656"
7630
+ "sha256": "d9ab931e2e3779b181225611efe7019b45d037bea4249d643574104445931164"
7631
7631
  },
7632
7632
  {
7633
7633
  "path": "package.json",
7634
7634
  "mode": "0000644",
7635
- "sha256": "107d899ff6ec92f0f2dd863f62ab2a68eaa82c7f60d9e172c243b9b5ff421f52"
7635
+ "sha256": "9903e5cd3c9d790a76647c7fff7556c33d900dd119d5b5afd0ada6797508df1d"
7636
7636
  },
7637
7637
  {
7638
7638
  "path": "public-docs/index.html",
@@ -9347,7 +9347,7 @@
9347
9347
  {
9348
9348
  "path": "src/module-api.js",
9349
9349
  "mode": "0000644",
9350
- "sha256": "fa5a67fefe06f235502a19ee017a75467ab1f5cadf77c2b004edd4109b397ece"
9350
+ "sha256": "de0d452d14fef52118d0302145065609722f6fbdf333fcbf47ec5864cbd3d86a"
9351
9351
  },
9352
9352
  {
9353
9353
  "path": "src/module-loader/catalog.js",
@@ -12719,6 +12719,11 @@
12719
12719
  "mode": "0000644",
12720
12720
  "sha256": "692261c26e3da46519757733a7fcf9a9998e0942bc5890688b66b79590d82c27"
12721
12721
  },
12722
+ {
12723
+ "path": "tests/version_promotion.mjs",
12724
+ "mode": "0000644",
12725
+ "sha256": "43ba25381f3d02d7ecaaa8a2639bb8f1f72587d6966e6498db1c887b289148eb"
12726
+ },
12722
12727
  {
12723
12728
  "path": "tests/version_roll_forward.mjs",
12724
12729
  "mode": "0000644",
@@ -390,7 +390,7 @@ export interface PostTasksNewcomerRestockResponse { ok: boolean; stamped: unknow
390
390
  export interface PostTasksRequest { version_id: string; title: string; description?: string; status?: string; touches?: string[]; est_minutes?: number; est_cost_usd?: number; manual_degree?: number; priority?: number; automation_tag?: string; credits_reward?: number; source?: string; source_ref?: string; value_summary?: string; kind?: string; discipline?: string; parallel_safe?: unknown; newcomer_friendly?: boolean; security_sensitive?: boolean; requires_rank?: string; auto_detect_touches?: boolean; criterion_ids?: unknown[]; module_key?: string; goal_id?: number }
391
391
  export interface PostTasksResponse { task: unknown; needs_migration: unknown; criteria: unknown; idempotent: boolean }
392
392
  export interface PostVersionsIdCloseRequest { reason?: string; dispositions?: Record<string, unknown> }
393
- export interface PostVersionsIdCloseResponse { ok: boolean; version: unknown; applied: unknown }
393
+ export interface PostVersionsIdCloseResponse { ok: boolean; version: unknown; applied: unknown; promoted: unknown; carried: unknown }
394
394
  export interface PostVersionsIdDoneWhenRequest { criterion_id: string; criterion_md: string; goal_id?: number; sort_order?: number }
395
395
  export interface PostVersionsIdDoneWhenResponse { ok: boolean; criterion: unknown }
396
396
  export interface PostVersionsRequest { id: string; name: string; status?: string; track?: string; done_when?: string; scope_doc_path?: string; criteria?: unknown[] }
@@ -22494,12 +22494,16 @@
22494
22494
  "type": "boolean"
22495
22495
  },
22496
22496
  "version": {},
22497
- "applied": {}
22497
+ "applied": {},
22498
+ "promoted": {},
22499
+ "carried": {}
22498
22500
  },
22499
22501
  "required": [
22500
22502
  "ok",
22501
22503
  "version",
22502
- "applied"
22504
+ "applied",
22505
+ "promoted",
22506
+ "carried"
22503
22507
  ]
22504
22508
  },
22505
22509
  "PostVersionsIdDoneWhenRequest": {
@@ -1649,5 +1649,7 @@ is load-bearing: the script throws rather than guess if it is missing, and
1649
1649
  landed since 1.19.598 with no explicit bump. run 34187136306. (task 1002620)
1650
1650
  1.19.600 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
1651
1651
  landed since 1.19.599 with no explicit bump. run 34187881031. (task 1002620)
1652
+ 1.19.601 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
1653
+ landed since 1.19.600 with no explicit bump. run 34188958832. (task 1002620)
1652
1654
  ---------------------------------------------------------------------------
1653
1655
  ```
@@ -245,14 +245,51 @@ async function openNonMaintenanceGoals(versionId, deps = {}) {
245
245
  // must run INSIDE this transaction and BEFORE any carry-over, because
246
246
  // `ensureMaintenanceGoal` returns null for a non-`building` version. The seam
247
247
  // is `deps.onClosed` below rather than a later edit to this function.
248
- // • It does not create successor goals. `roll_forward` here only ABSTAINS from
249
- // cutting the goal; task 1003604 (R17) does the lineage write. Until it ships,
250
- // a rolled-forward goal simply stays open on the closed version visible and
251
- // recoverable, which is the right failure while half the feature exists.
248
+ // • It DOES create successor goals now task 1003604 (R17) shipped, so
249
+ // `roll_forward` writes the successor, moves the unfinished tasks and records
250
+ // `succeeded_by_goal_id`. This note used to say the opposite; it is kept,
251
+ // corrected, because a reader who met the old wording would otherwise go
252
+ // looking for the abstention it described.
252
253
  // • It does not write `limitations/<version>-shipped.md`. That is a repo file; a
253
254
  // route cannot write one, and file I/O has no business in this transaction.
254
255
  //
255
256
  // `plan` is planVersionClose's validated output: [{ goalId, verb }].
257
+ // promotePlanningVersion — the single `planning` version becomes the live train
258
+ // (BV1.R20, task 1003607, goal 1000086, ADR 0263 §8).
259
+ //
260
+ // WHY IT RUNS IN THE CLOSE'S TRANSACTION. A project with zero building versions
261
+ // is a BROKEN state, not an intermediate one: `currentBuildingVersionId` returns
262
+ // null there and every routing path closed over it fails, so nothing is
263
+ // claimable. Promoting in a second transaction would leave exactly that window
264
+ // open, however briefly.
265
+ //
266
+ // ZERO PLANNING VERSIONS IS NOT AN ERROR. The close succeeds and the project sits
267
+ // with no live train until someone cuts one. Refusing the close instead would
268
+ // trap a finished version open because nobody had scoped the next one yet — and
269
+ // the close is the thing that makes scoping the next one worth doing.
270
+ //
271
+ // SELF-GUARDING IN SQL rather than by a read-then-write. The `NOT EXISTS`
272
+ // sub-select is what keeps this from creating the second building version R19
273
+ // forbids: it is evaluated inside the same statement, so a concurrent close
274
+ // cannot slip a promotion past a check that has already run. `ORDER BY id LIMIT 1`
275
+ // makes the pick deterministic; R04 guarantees there is at most one to pick.
276
+ //
277
+ // `started_at` is stamped only if it was never set — a version's start is when it
278
+ // began building, and a re-promotion (which cannot happen, but the COALESCE costs
279
+ // nothing) must not rewrite history.
280
+ //
281
+ // Returns the promoted row, or null when there was nothing to promote.
282
+ async function promotePlanningVersion(exec) {
283
+ const { rows } = await exec.query(
284
+ `UPDATE versions
285
+ SET status = 'building', started_at = COALESCE(started_at, now())
286
+ WHERE id = (SELECT id FROM versions WHERE status = 'planning' ORDER BY id LIMIT 1)
287
+ AND NOT EXISTS (SELECT 1 FROM versions WHERE status = 'building')
288
+ RETURNING id, name, track, status, started_at`
289
+ );
290
+ return rows[0] ?? null;
291
+ }
292
+
256
293
  async function closeVersion({ versionId, plan = [], reason, planningVersionId = null }, deps = {}) {
257
294
  const activePool = (deps.pool && process.env.NODE_ENV === 'test') ? deps.pool : pool;
258
295
  const client = await activePool.connect();
@@ -437,6 +474,7 @@ async function closeVersion({ versionId, plan = [], reason, planningVersionId =
437
474
 
438
475
  module.exports = {
439
476
  closeVersion,
477
+ promotePlanningVersion,
440
478
  createVersion,
441
479
  maintenanceGoalExemptSql,
442
480
  openNonMaintenanceGoals,
@@ -63,7 +63,7 @@ const {
63
63
  singleRungPromotionError,
64
64
  xenosClaimAllowed,
65
65
  } = require('./db-rank-authz.js');
66
- const { closeVersion, createVersion, currentBuildingVersionId, getVersion, listVersions, maintenanceGoalExemptSql, openNonMaintenanceGoals, versionProgress, versionsWithStatus } = require('./db-versions.js');
66
+ const { closeVersion, promotePlanningVersion, createVersion, currentBuildingVersionId, getVersion, listVersions, maintenanceGoalExemptSql, openNonMaintenanceGoals, versionProgress, versionsWithStatus } = require('./db-versions.js');
67
67
  const {
68
68
  acceptMembershipRequestAndAddMember,
69
69
  achieveGoalIfComplete,
@@ -222,6 +222,7 @@ module.exports = {
222
222
  openNonMaintenanceGoals,
223
223
  versionsWithStatus,
224
224
  closeVersion,
225
+ promotePlanningVersion,
225
226
  createVersion,
226
227
  currentBuildingVersionId,
227
228
  createGoal,
@@ -287,12 +287,53 @@ module.exports = function buildVersionsRouter() {
287
287
  try {
288
288
  const out = await db.closeVersion({
289
289
  versionId, plan: plan.plan, reason,
290
+ // BV1.R20 (task 1003607, ADR 0263 §8): the close's last act, inside its
291
+ // own transaction. A project with zero building versions is a BROKEN
292
+ // state — `currentBuildingVersionId` returns null and nothing is
293
+ // claimable — so promoting in a second transaction would leave exactly
294
+ // that window open.
295
+ //
296
+ // ORDER IS LOAD-BEARING: promote, THEN carry the bugs forward.
297
+ // `ensureMaintenanceGoal` returns null for a version that is not yet
298
+ // `building`, so a carry-over run first silently carries nothing and the
299
+ // defect queue stays entombed on the version that just shipped.
300
+ //
301
+ // COMPOSED HERE rather than inside closeVersion because the two halves
302
+ // live in different db units (versions and goals, siblings in the
303
+ // module's require DAG) and the route is the one place already holding
304
+ // the whole facade — reaching sideways between the units is how that DAG
305
+ // stops being one.
306
+ //
307
+ // Zero planning versions is NOT an error: the close succeeds and the
308
+ // project sits idle until someone cuts the next version.
290
309
  // R04 guarantees at most one planning version, so [0] is THE successor
291
310
  // rather than a pick. Null when nothing rolls forward, which is the
292
311
  // common close.
293
312
  planningVersionId: planning[0]?.id ?? null,
313
+ }, {
314
+ // NOTE THE SECOND ARGUMENT. `closeVersion` reads this hook from `deps`,
315
+ // not from its options object — putting it in the first one is silently
316
+ // ignored, the hook never runs, and the close still returns 200 having
317
+ // promoted nothing. Caught here by running the real close against a real
318
+ // Postgres; no fake would have noticed.
319
+ onClosed: async (client, { versionId: closedId }) => {
320
+ const promoted = await db.promotePlanningVersion(client);
321
+ const carried = promoted
322
+ ? await db.carryBugsForward({ fromVersionId: closedId, toVersionId: promoted.id }, { client })
323
+ : null;
324
+ return { promoted, carried };
325
+ },
326
+ });
327
+ // `promoted` and `carried` ride the response because a close now changes
328
+ // WHICH version is live, and a caller that has to go and re-read
329
+ // /versions to discover that has been told half the outcome. `promoted:
330
+ // null` is the honest answer for a project with nothing scoped next, not
331
+ // an omission.
332
+ return res.json({
333
+ ok: true, version: out.version, applied: out.applied,
334
+ promoted: out.after?.promoted ?? null,
335
+ carried: out.after?.carried ?? null,
294
336
  });
295
- return res.json({ ok: true, version: out.version, applied: out.applied });
296
337
  } catch (err) {
297
338
  if (err && err.code === 'VERSION_NOT_FOUND') return res.fail('version_not_found', 404);
298
339
  if (err && err.code === 'VERSION_NOT_BUILDING') {
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@bongos/core",
3
- "version": "1.19.600",
3
+ "version": "1.19.601",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@bongos/core",
9
- "version": "1.19.600",
9
+ "version": "1.19.601",
10
10
  "license": "AGPL-3.0-or-later",
11
11
  "dependencies": {
12
12
  "express": "^4.21.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bongos/core",
3
- "version": "1.19.600",
3
+ "version": "1.19.601",
4
4
  "description": "Cloud Bongos — the AI-first build platform core (GDS + platform surfaces + module system), installed as a versioned dependency (ADR 0108).",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "main": "src/platform-server.js",
package/src/module-api.js CHANGED
@@ -55,7 +55,7 @@ const { buildInfo } = require('./build-info');
55
55
  // there. scripts/gds/bump-version.js still rewrites the literal below; it appends
56
56
  // the entry to that file. Look for a version's history there, not here.
57
57
  // ---------------------------------------------------------------------------
58
- const CORE_VERSION = '1.19.600'; // CI auto-patch carrier (ADR 0161); changelog: docs/module-api-changelog.md
58
+ const CORE_VERSION = '1.19.601'; // CI auto-patch carrier (ADR 0161); changelog: docs/module-api-changelog.md
59
59
 
60
60
  // A namespaced logger so a module's log lines are attributable + consistent.
61
61
  // Usage: const log = api.logger('dev-box'); log.info('mounted');
@@ -0,0 +1,143 @@
1
+ // tests/version_promotion.mjs — the planning version promotes itself when the
2
+ // building version closes (BV1.R20, task 1003607, goal 1000086, ADR 0263 §8).
3
+ //
4
+ // WHY IT RUNS INSIDE THE CLOSE'S TRANSACTION. A project with zero building
5
+ // versions is a BROKEN state, not an intermediate one: `currentBuildingVersionId`
6
+ // returns null there and every routing path closed over it fails, so nothing is
7
+ // claimable. Promoting in a second transaction leaves exactly that window open,
8
+ // however briefly.
9
+ //
10
+ // AND WHY THE ORDER IS LOAD-BEARING. Promote, THEN carry the bugs forward.
11
+ // `ensureMaintenanceGoal` returns null for a version that is not yet `building`,
12
+ // so a carry-over run first silently carries nothing and the defect queue stays
13
+ // entombed on the version that just shipped — the 1000771 shape, arriving through
14
+ // the close instead of through routing.
15
+ //
16
+ // ONE MORE THING THIS FILE PINS, because it is the bug that actually happened
17
+ // while building R20: `closeVersion` reads the hook from its SECOND argument
18
+ // (`deps`), not from its options object. Passing `onClosed` in the first one is
19
+ // silently ignored — the hook never runs, nothing is promoted, and the close
20
+ // still answers 200. No fake caught it; running the real close against a real
21
+ // Postgres did.
22
+ //
23
+ // Run: node --test tests/version_promotion.mjs
24
+
25
+ import assert from 'node:assert/strict';
26
+ import { test } from 'node:test';
27
+ import { readFileSync } from 'node:fs';
28
+ import { createRequire } from 'node:module';
29
+ import { makeSqlAwareClient } from './helpers.mjs';
30
+
31
+ process.env.NODE_ENV = 'test';
32
+ const require = createRequire(import.meta.url);
33
+ const { promotePlanningVersion } = require('../modules/lifecycle/db-versions.js');
34
+
35
+ const src = (rel) => readFileSync(new URL('../' + rel, import.meta.url), 'utf8');
36
+ const ROUTES = src('modules/lifecycle/routes/versions.js');
37
+ const DBV = src('modules/lifecycle/db-versions.js');
38
+
39
+ const recorder = (handler) => {
40
+ const seen = [];
41
+ const c = makeSqlAwareClient((sql, params) => { seen.push({ sql: String(sql).replace(/\s+/g, ' '), params }); return handler(sql, params); });
42
+ return { seen, exec: { query: (sql, params) => c._client.query(sql, params) } };
43
+ };
44
+
45
+ // ---------------------------------------------------------------------------
46
+ // The promotion itself
47
+ // ---------------------------------------------------------------------------
48
+
49
+ test('promotion is ONE self-guarding statement, not a read-then-write', async () => {
50
+ // A read-then-write leaves a window in which a concurrent close promotes too,
51
+ // producing the second building version R19 forbids. The NOT EXISTS is
52
+ // evaluated inside the same statement, so it cannot be raced past.
53
+ const r = recorder(() => ({ rows: [] }));
54
+ await promotePlanningVersion(r.exec);
55
+ assert.equal(r.seen.length, 1, 'one statement — a separate check could be raced');
56
+ const sql = r.seen[0].sql;
57
+ assert.match(sql, /UPDATE versions SET status = 'building'/);
58
+ assert.match(sql, /WHERE status = 'planning' ORDER BY id LIMIT 1/);
59
+ assert.match(sql, /NOT EXISTS \(SELECT 1 FROM versions WHERE status = 'building'\)/,
60
+ 'the guard against creating a second building version must be in the statement');
61
+ });
62
+
63
+ test('started_at is stamped only if it was never set', async () => {
64
+ const r = recorder(() => ({ rows: [] }));
65
+ await promotePlanningVersion(r.exec);
66
+ assert.match(r.seen[0].sql, /started_at = COALESCE\(started_at, now\(\)\)/,
67
+ "a version's start is when it began building; a re-promotion must not rewrite history");
68
+ });
69
+
70
+ test('nothing to promote returns null — an idle project is not an error', async () => {
71
+ const r = recorder(() => ({ rows: [] }));
72
+ assert.equal(await promotePlanningVersion(r.exec), null);
73
+ });
74
+
75
+ test('the promoted row is returned so the caller can carry bugs into it', async () => {
76
+ const r = recorder(() => ({ rows: [{ id: 'V2', name: 'two', status: 'building', started_at: 't' }] }));
77
+ const out = await promotePlanningVersion(r.exec);
78
+ assert.equal(out.id, 'V2');
79
+ assert.equal(out.status, 'building');
80
+ });
81
+
82
+ // ---------------------------------------------------------------------------
83
+ // The wiring — where the bug was
84
+ // ---------------------------------------------------------------------------
85
+
86
+ test('onClosed is passed as the DEPS argument, not in the options object', () => {
87
+ // THE BUG THIS PINS. `closeVersion({...opts}, deps)` reads `deps.onClosed`.
88
+ // Putting the hook in the first object is silently ignored: no promotion, no
89
+ // carry-over, and a 200 response that looks correct.
90
+ const call = ROUTES.slice(ROUTES.indexOf('const out = await db.closeVersion('), ROUTES.indexOf('return res.json({ ok: true, version: out.version'));
91
+ const optsEnd = call.indexOf('}, {');
92
+ assert.ok(optsEnd !== -1, 'the close must be called with a second (deps) argument');
93
+ assert.equal(call.slice(0, optsEnd).includes('onClosed'), false,
94
+ 'onClosed in the options object is a silent no-op — it belongs in deps');
95
+ assert.ok(call.slice(optsEnd).includes('onClosed'), 'and it must actually be in deps');
96
+ });
97
+
98
+ test('the hook promotes BEFORE it carries — the ordering trap', () => {
99
+ const hook = ROUTES.slice(ROUTES.indexOf('onClosed: async (client'), ROUTES.indexOf('return { promoted, carried };'));
100
+ const promoteAt = hook.indexOf('promotePlanningVersion');
101
+ const carryAt = hook.indexOf('carryBugsForward');
102
+ assert.ok(promoteAt !== -1 && carryAt !== -1);
103
+ assert.ok(promoteAt < carryAt,
104
+ 'ensureMaintenanceGoal returns null for a non-building version, so carrying first silently carries nothing');
105
+ });
106
+
107
+ test('no promotion means no carry attempt at all', () => {
108
+ // Not "carry into null and hope" — there is genuinely nowhere to put them, and
109
+ // the honest answer is that the bugs stay findable on the closed version until
110
+ // someone cuts the next one.
111
+ assert.match(ROUTES, /const carried = promoted\s*\n?\s*\?\s*await db\.carryBugsForward/);
112
+ assert.match(ROUTES, /:\s*null;/);
113
+ });
114
+
115
+ test('the close reports what it promoted and carried', () => {
116
+ // A close now changes WHICH version is live. A caller made to re-read /versions
117
+ // to discover that has been told half the outcome.
118
+ assert.match(ROUTES, /promoted: out\.after\?\.promoted \?\? null/);
119
+ assert.match(ROUTES, /carried: out\.after\?\.carried \?\? null/);
120
+ });
121
+
122
+ // ---------------------------------------------------------------------------
123
+ // Composition
124
+ // ---------------------------------------------------------------------------
125
+
126
+ test('the hook is composed in the ROUTE, not inside closeVersion', () => {
127
+ // The two halves live in different db units — versions and goals, siblings in
128
+ // the module's require DAG — and the route is the one place already holding the
129
+ // whole facade. Reaching sideways between the units is how that DAG stops being
130
+ // one.
131
+ assert.equal(/carryBugsForward/.test(DBV), false,
132
+ 'db-versions.js must not reach into db-goals.js');
133
+ assert.match(ROUTES, /db\.promotePlanningVersion\(client\)/);
134
+ assert.match(ROUTES, /db\.carryBugsForward\(/);
135
+ });
136
+
137
+ test('the stale R17 note in closeVersion was corrected, not left to mislead', () => {
138
+ // It said roll_forward "only ABSTAINS from cutting the goal ... until R17
139
+ // ships". R17 shipped; a reader meeting the old wording would go looking for
140
+ // an abstention that is no longer there.
141
+ assert.equal(/Until it ships/.test(DBV), false);
142
+ assert.match(DBV, /It DOES create successor goals now/);
143
+ });