@bongos/core 1.19.989 → 1.19.990

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.989",
6
- "core_contract": "1.19.989",
7
- "source_commit": "e2ff7b827391116e3e99f4b850441ca7482a3466",
5
+ "core_version": "1.19.990",
6
+ "core_contract": "1.19.990",
7
+ "source_commit": "b1a0a6f54282f522323d1e84921384ce4af0d190",
8
8
  "source_ref": "HEAD",
9
- "built_at": "2026-09-23T19:44:16.401Z",
9
+ "built_at": "2026-09-23T19:56:56.227Z",
10
10
  "redaction": {
11
11
  "model": "docs-redacted+functional-verbatim",
12
12
  "docs_redacted": 518,
13
13
  "agent_docs_stubbed": 26,
14
- "functional_verbatim": 2394,
14
+ "functional_verbatim": 2396,
15
15
  "rules": 3,
16
16
  "gate_literals": 3,
17
17
  "gate": "passed"
18
18
  },
19
- "file_count": 2938,
20
- "tree_sha256": "65dea20f4453b26ed36b673a7a34da0008c338d0f4307aa1b327f3171ce42cb0",
19
+ "file_count": 2940,
20
+ "tree_sha256": "2568c6298b1a5aa67172a39885d5bf19ef7a05679f3032125d57660ee881e2ca",
21
21
  "files": [
22
22
  {
23
23
  "path": ".claude/skills/ask-for-help/SKILL.md",
@@ -2152,7 +2152,7 @@
2152
2152
  {
2153
2153
  "path": "docs/api/openapi.json",
2154
2154
  "mode": "0000644",
2155
- "sha256": "b227cab471090f0e961366e0299ad4ac7195c9123e46215f4af7b3bd7cf7713b"
2155
+ "sha256": "8b1f2a53680ae8b68be5d54a82664413fa29186fb580825f5a1b0e3ce3677525"
2156
2156
  },
2157
2157
  {
2158
2158
  "path": "docs/architecture.md",
@@ -2712,7 +2712,7 @@
2712
2712
  {
2713
2713
  "path": "docs/module-api-changelog.md",
2714
2714
  "mode": "0000644",
2715
- "sha256": "b06d9ffcfde6e55a0997ffa926a671d0f53478d5e7c351b92374485e359cc0cd"
2715
+ "sha256": "807ee161f37480d116b1e3c75835fcde8eb347dc994839a69c0f3aeaa43e273e"
2716
2716
  },
2717
2717
  {
2718
2718
  "path": "docs/modules-contract.md",
@@ -2832,7 +2832,7 @@
2832
2832
  {
2833
2833
  "path": "docs/recipes/core-release-pipeline.md",
2834
2834
  "mode": "0000644",
2835
- "sha256": "53721b3314eab8f538aa7027862253abdbdd41be59f9dce75431c1b40ef80e63"
2835
+ "sha256": "12e2fdc72d1bed7d524b50960dea3a67791b098b7dbafaff9c6f95cd356b185a"
2836
2836
  },
2837
2837
  {
2838
2838
  "path": "docs/recipes/failed-ship-recovery-proof.md",
@@ -2962,7 +2962,7 @@
2962
2962
  {
2963
2963
  "path": "docs/recipes/upgrading-the-core.md",
2964
2964
  "mode": "0000644",
2965
- "sha256": "0df57ea34114fb1ae81389458334b392d768fc83d9e82eb00fa917219189de87"
2965
+ "sha256": "e035ebbda54d0d94f38bbcc9502689318c4f9bb2fe5bcca2592aa710dca5ffb0"
2966
2966
  },
2967
2967
  {
2968
2968
  "path": "docs/recipes/windows-builders.md",
@@ -6042,7 +6042,7 @@
6042
6042
  {
6043
6043
  "path": "modules/lifecycle/routes/artist-gate.js",
6044
6044
  "mode": "0000644",
6045
- "sha256": "6b7928201e9bb8c35691f388b1aa73c0986dd9d5e186796d8b087b7a1645ac96"
6045
+ "sha256": "9b6990b00e071e2b47c20fc790f975db63563b700ffbd4a6b0c60dfd138f0def"
6046
6046
  },
6047
6047
  {
6048
6048
  "path": "modules/lifecycle/routes/claims.js",
@@ -8162,12 +8162,12 @@
8162
8162
  {
8163
8163
  "path": "package-lock.json",
8164
8164
  "mode": "0000644",
8165
- "sha256": "09936259916688c880c3c787419714a83a798ccf7fd09b50d7fe26d3d293e600"
8165
+ "sha256": "47f81c7b7d52feec484d30c948a6f511be97d949d51008e3951536b6d5a16e4d"
8166
8166
  },
8167
8167
  {
8168
8168
  "path": "package.json",
8169
8169
  "mode": "0000644",
8170
- "sha256": "126708cbc785a14f0cf42ef0a151889033a852f1a331e6ab73b0c75743f41856"
8170
+ "sha256": "eb28fe24fd57a826eee9a4c24dae6980d2ba6cfd59f866bdf40b4ededb09bab0"
8171
8171
  },
8172
8172
  {
8173
8173
  "path": "public-docs/index.html",
@@ -9739,10 +9739,15 @@
9739
9739
  "mode": "0000644",
9740
9740
  "sha256": "6418f51f933eac634a7df854af1e3a6dbde25e152e3dca0ce8df7d37d19c1d0c"
9741
9741
  },
9742
+ {
9743
+ "path": "scripts/gds/upgrade-artist-gate.js",
9744
+ "mode": "0000644",
9745
+ "sha256": "caf07b70b066fe1388037ce1c622ea3aed82cbf43f67ffb918214159cbe4444e"
9746
+ },
9742
9747
  {
9743
9748
  "path": "scripts/gds/upgrade.js",
9744
9749
  "mode": "0000644",
9745
- "sha256": "d736a08f303447e3889c478b0a22d6e9ae96e326f75bd57bead6199ffc23f1c5"
9750
+ "sha256": "70a7de81b25a17cb7ab7e57f92577b6d977f89911b784f33df668b650fb208b0"
9746
9751
  },
9747
9752
  {
9748
9753
  "path": "scripts/gds/validate-design.js",
@@ -10202,7 +10207,7 @@
10202
10207
  {
10203
10208
  "path": "src/module-api.js",
10204
10209
  "mode": "0000644",
10205
- "sha256": "5ed09f42ce4e04ca5f27bc3d4004ceab18bf604bd8a8fca72648afbf389b0935"
10210
+ "sha256": "dcb76f459cc34113dd39ecd6229efe70abf82efc64da2c8c7ff35f514c8b17ec"
10206
10211
  },
10207
10212
  {
10208
10213
  "path": "src/module-loader/catalog.js",
@@ -10507,7 +10512,7 @@
10507
10512
  {
10508
10513
  "path": "tests/artist_gate_route.mjs",
10509
10514
  "mode": "0000644",
10510
- "sha256": "616c19815b83f6796856ad6000eda4ce1c66eb526ecc4c1b901abdd9c49b4285"
10515
+ "sha256": "3337ab686f2fa4bef95d0eabcf9b134a9b919d40480750e07a500b8007ae9659"
10511
10516
  },
10512
10517
  {
10513
10518
  "path": "tests/asset_version.mjs",
@@ -14549,6 +14554,11 @@
14549
14554
  "mode": "0000644",
14550
14555
  "sha256": "8bd1c116b5459b54a847208c01669159414fed17b3704d621e1dc5acfb00f255"
14551
14556
  },
14557
+ {
14558
+ "path": "tests/upgrade_artist_gate.mjs",
14559
+ "mode": "0000644",
14560
+ "sha256": "a9b5fadd7f829fd54a9d976d82832eb536e7d988c466647860b0257109feec50"
14561
+ },
14552
14562
  {
14553
14563
  "path": "tests/upgrade_persist_pin.mjs",
14554
14564
  "mode": "0000644",
@@ -1065,7 +1065,7 @@
1065
1065
  "artist-gate"
1066
1066
  ],
1067
1067
  "summary": "GET /artist-gate",
1068
- "description": "GET /artist-gate — this project's artist strictness and what it is holding. rank: any authenticated builder. The payload is ordinary board state — a policy value the instance already publishes as its own behaviour, and task ids/titles any builder can read on the hall — so a floor above requireBuilder would gate a fact the board already shows. Nothing here is writable. Response: mode 'off' | 'advisory' | 'strict' the project's setting as resolved since ISO string | null when it was last RAISED to strict holds boolean does anything hold a deploy now? truncated boolean `reviews` hit the scan cap — a floor reviews [{ id, created_at }] the open reviews that count halt { code, message, detail } | null the refusal, pre-composed `halt` is composed HERE rather than by the caller on purpose: ADR 0241 §4's second guard is that the refusal must name what holds the deploy and which control releases it, and a sentence assembled independently by each caller is a sentence that eventually says something different. One composer, one wording.\n\n**Rank:** `any-builder` — Any authenticated builder (row-level ownership enforced in-handler).",
1068
+ "description": "GET /artist-gate — this project's artist strictness and what it is holding. rank: any authenticated builder. The payload is ordinary board state — a policy value the instance already publishes as its own behaviour, and task ids/titles any builder can read on the hall — so a floor above requireBuilder would gate a fact the board already shows. Nothing here is writable. Response: mode 'off' | 'advisory' | 'strict' the project's setting as resolved since ISO string | null when it was last RAISED to strict holds boolean does anything hold a deploy now? truncated boolean `reviews` hit the scan cap — a floor reviews [{ id, created_at }] the open reviews that count halt { code, message, detail } | null the refusal, pre-composed `halt` is composed HERE rather than by the caller on purpose: ADR 0241 §4's second guard is that the refusal must name what holds the deploy and which control releases it, and a sentence assembled independently by each caller is a sentence that eventually says something different. One composer, one wording. A caller on this machine that reached the app DIRECTLY may also read it, without a session (task 1004205; owner decision 2026-09-23): that is how `bongos upgrade` on the box asks before moving the pin, and the box holds no builder session. Everything else still passes requireBuilder.\n\n**Rank:** `any-builder` — Any authenticated builder (row-level ownership enforced in-handler).",
1069
1069
  "x-rank": "any-builder",
1070
1070
  "x-source": "modules/lifecycle/routes/artist-gate.js",
1071
1071
  "responses": {
@@ -2451,6 +2451,8 @@ is load-bearing: the script throws rather than guess if it is missing, and
2451
2451
  1.19.988 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
2452
2452
  landed since 1.19.987 with no explicit bump. run 35909292753. (task 1002620)
2453
2453
  1.19.989 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
2454
- landed since 1.19.988 with no explicit bump. run 35911149318. (task 1002620)
2454
+ landed since 1.19.988 with no explicit bump. run 35911817390. (task 1002620)
2455
+ 1.19.990 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
2456
+ landed since 1.19.989 with no explicit bump. run 35912578496. (task 1002620)
2455
2457
  ---------------------------------------------------------------------------
2456
2458
  ```
@@ -207,6 +207,11 @@ There are three ways past it, and the first two are the ordinary ones:
207
207
  the audit log as a self-override. It is the valve that stops a solo project deadlocking,
208
208
  not a routine step: the right answer to being gated is to fix the work or fix the grader.
209
209
 
210
+ **`bongos upgrade` asks the same gate** (task 1004205): the vendored `upgrade.js --from` run
211
+ refuses before the pin moves, with the same halt, the same three ways past it and the same two
212
+ unknowns below — it reuses `go-live.js`'s reader. Until then only `go-live.js` asked, and an
213
+ instance that moved its pin by hand moved it past open reviews.
214
+
210
215
  `go-live.js` prints the gate's level on every plan, held or not, so "why did nothing stop?" is
211
216
  answerable without going and looking. Two different unknowns, two different verdicts:
212
217
 
@@ -10,6 +10,7 @@
10
10
 
11
11
  0. **downgrade guard** (task [#1004009](https://example.com/builders#/task/1004009)) — a `--to` **older** than this instance's core is refused before anything moves, in one line naming both versions and the newest published release. "This instance's core" is the **newer** of what is installed and what is pinned, because a half-applied bump leaves the two apart and the pin is the thing about to be overwritten. `--force` does not waive it; `--allow-downgrade` does, and the run then says `DOWNGRADE` in its first line, its last line and its `core_upgrades` ledger note. Migrations are never reverted, so going backwards across one leaves the DB ahead of the code; and an instance subscribed to an update channel is taken forward again by the next sweep, so set it to `pinned` first if the downgrade is meant to hold. Auto-rollback (step 8) restores its own pin and is unaffected.
12
12
  1. **pre-flight** — module-compat vs the target core + a clean git tree (skip with `--force`).
13
+ 1a. **the artist gate** (task [#1004205](https://example.com/builders#/task/1004205), [ADR 0241](../adr/0241-the-artist-gate-is-a-per-project-deploy-gate-that-reads-a-state.md)) — asks the instance being upgraded, at the origin of `--health-url`, whether an unresolved artist review holds its deploy, and **refuses before anything moves** if one does. `--force` does not waive it, and a dry run reports it. Every change to a page files such a review (owner decision 2026-09-23), so on a `strict` project an upgrade waits until each has been looked at. The ways past it are ADR 0241's, unchanged: resolve or dismiss the review, lower `artist_gate` to `advisory`, or the project owner releases it (see [the release pipeline](core-release-pipeline.md)). It uses `go-live.js`'s own reader, so both paths decide one answer the same way: a gate that is there and errors halts; one that cannot be read (no `--health-url`, an older instance, the instance down) is printed as a note. A **downgrade** is never held — rolling back must not wait on a review. Before this, only `go-live.js` asked, so the vendored `--from` path this instance used moved its pin past open reviews. The instance answers this local request without a session (the box has none); a request through the proxy still needs one. So the **first** upgrade that carries this asks an instance still running the older route, gets a 401 and can only print the note — every upgrade after it holds.
13
14
  2. **bump the pin** — vendor the new `bongos-core-<version>.tgz` and rewrite the `"@bongos/core": "file:vendor/…"` dependency.
14
15
  3. **`npm install`** — `node_modules/@bongos/core` becomes the new version.
15
16
  3b. **verify the integrity pin** (task [#1002216](https://example.com/builders#/task/1002216)) — recompute `tree_sha256` over the installed core and check the vendored `.tgz` bytes against `tarball.sha256`, comparing to the trusted reference manifest (the committed `vendor/…manifest.json`; the installed inner manifest for `--registry`). Runs **before** migrate so a corrupted core never touches the DB. A **mismatch is fatal → rollback**; a missing reference warns (fatal with `--require-pin`); opt out with `--skip-pin-verify`.
@@ -50,7 +50,12 @@ module.exports = function buildArtistGateRouter() {
50
50
  // second guard is that the refusal must name what holds the deploy and which
51
51
  // control releases it, and a sentence assembled independently by each caller is
52
52
  // a sentence that eventually says something different. One composer, one wording.
53
- router.get('/artist-gate', api.requireBuilder, async (req, res) => {
53
+ //
54
+ // A caller on this machine that reached the app DIRECTLY may also read it,
55
+ // without a session (task 1004205; owner decision 2026-09-23): that is how
56
+ // `bongos upgrade` on the box asks before moving the pin, and the box holds no
57
+ // builder session. Everything else still passes requireBuilder.
58
+ router.get('/artist-gate', unlessDirectLocalCall(api.requireBuilder), async (req, res) => {
54
59
  try {
55
60
  const gate = api.artistGate;
56
61
  const mode = gate.artistGateMode();
@@ -99,3 +104,21 @@ module.exports = function buildArtistGateRouter() {
99
104
 
100
105
  return router;
101
106
  };
107
+
108
+ // A request from this machine with NO proxy hop. Public traffic always reaches
109
+ // the app through the proxy (Caddy, behind Cloudflare), which sets a forwarding
110
+ // header, so a loopback peer without one is a local process — the rule
111
+ // src/bongos/metrics.js applies to its local scraper. The payload is ids, dates
112
+ // and the policy level: nothing a process already on the box could not read.
113
+ function isDirectLocalCall(req) {
114
+ const h = req.headers || {};
115
+ if (h['x-forwarded-for'] || h['x-real-ip'] || h.forwarded || h['cf-connecting-ip']) return false;
116
+ const peer = (req.socket && req.socket.remoteAddress) || '';
117
+ return peer === '127.0.0.1' || peer === '::1' || peer === '::ffff:127.0.0.1';
118
+ }
119
+
120
+ // Runs `requireSession` for everyone except a direct local call (above), which
121
+ // goes straight to the handler with no builder attached.
122
+ function unlessDirectLocalCall(requireSession) {
123
+ return (req, res, next) => (isDirectLocalCall(req) ? next() : requireSession(req, res, next));
124
+ }
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@bongos/core",
3
- "version": "1.19.989",
3
+ "version": "1.19.990",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@bongos/core",
9
- "version": "1.19.989",
9
+ "version": "1.19.990",
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.989",
3
+ "version": "1.19.990",
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",
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ // scripts/gds/upgrade-artist-gate.js — the artist gate's deploy hold on the
4
+ // UPGRADE path (task 1004205; ADR 0241).
5
+ //
6
+ // WHY. On a `strict` project an unresolved artist review holds the DEPLOY, never
7
+ // the ship. Only go-live.js asked the gate, and cloudbongos.com moves its pin
8
+ // with the vendored `upgrade.js --from` instead, so on this instance an open
9
+ // review held nothing (2026-09-23: the gate answered holds:true and the upgrade
10
+ // never read it). Every UI change now files such a review (owner decision
11
+ // 2026-09-23, task 1004201), so this is where "the owner sees it before users
12
+ // do" is actually enforced.
13
+ //
14
+ // It reuses go-live.js's reader and judgement verbatim, so both deploy paths
15
+ // decide the same answer the same way: a hold or a broken gate halts, a gate
16
+ // that cannot be read at all is a note. It asks the instance being upgraded,
17
+ // at the origin of --health-url, because the box runs the instance it upgrades;
18
+ // the instance answers a direct local request without a session (the route).
19
+ // The FIRST upgrade carrying this asks an instance that still wants a session,
20
+ // so it can only print the unread note — every upgrade after that holds.
21
+ // Kept out of upgrade.js, which sits at the line cap.
22
+
23
+ const { readArtistGate, artistGateEntries } = require('./go-live');
24
+
25
+ const GATE_TIMEOUT_MS = 10_000;
26
+
27
+ function unreadNote(why) {
28
+ return { halts: [], notes: [{ code: 'ARTIST_GATE_UNREAD', message: `could not read this instance's artist gate (${why}) — if the project runs artist_gate 'strict', an unresolved artist review may be holding this deploy and this upgrade cannot see it` }] };
29
+ }
30
+
31
+ // checkArtistGate — { halts, notes } for this instance's gate, go-live's shape.
32
+ async function checkArtistGate({ healthUrl }, deps = {}) {
33
+ if (!healthUrl) return unreadNote('no --health-url to reach the instance by');
34
+ let origin;
35
+ try { origin = new URL(healthUrl).origin; } catch (_) { return unreadNote(`--health-url ${healthUrl} is not a URL`); }
36
+ const fetchImpl = deps.fetchImpl || fetch;
37
+ const call = async (method, urlPath) => {
38
+ const res = await fetchImpl(`${origin}${urlPath}`, { method, signal: AbortSignal.timeout(GATE_TIMEOUT_MS) });
39
+ let data = null;
40
+ try { data = await res.json(); } catch (_) { /* not JSON: readArtistGate reads it as "not a gate" */ }
41
+ return { status: res.status, ok: res.ok, data };
42
+ };
43
+ return artistGateEntries(await readArtistGate(call));
44
+ }
45
+
46
+ module.exports = { checkArtistGate };
@@ -5,7 +5,7 @@
5
5
  // Turns the former stub (which only ran a module-vs-core compatibility PRE-CHECK) into the real
6
6
  // channel a two-repo consumer uses to pull the Cloud Bongos core from version N to N+1:
7
7
  //
8
- // pre-flight clean git tree + module-compat vs the TARGET core version
8
+ // pre-flight clean git tree + module-compat vs the TARGET core version + the artist gate (ADR 0241)
9
9
  // → bump pin vendor the new core .tgz, rewrite the package.json `file:` dependency
10
10
  // → npm install node_modules/@bongos/core becomes the new version
11
11
  // → migrate `npm run migrate` → the core's migrate.sh applies additive `core_*` migrations
@@ -13,13 +13,10 @@
13
13
  // → restart restart the instance's service so the new core is live
14
14
  // → verify installed package version == target (+ optional /healthz + ledger row)
15
15
  //
16
- // SCOPE (ADR 0100 §2, reshaped by ADR 0103 §4): the SMALLEST channel the FIRST real consumer needs
17
- // on its first core bump — driven by that consumer, not designed up front. That consumer is
18
- // emersonian-circles (task 1917): a greenfield npm-dependency instance that pins the core as
19
- // "@bongos/core": "file:vendor/bongos-core-<ver>.tgz"
20
- // with `start`/`migrate` npm scripts and a materialized .claude/. Every step below maps to something
21
- // that consumer actually has. A published-registry source, rollback, and multi-consumer shapes are
22
- // deliberately OUT — they are follow-ups a second consumer's needs will define.
16
+ // SCOPE (ADR 0100 §2, reshaped by ADR 0103 §4): first built for emersonian-circles (task 1917), an
17
+ // npm-dependency instance pinning "@bongos/core": "file:vendor/bongos-core-<ver>.tgz" with
18
+ // `start`/`migrate` npm scripts and a materialized .claude/; the registry source (ADR 0134) and
19
+ // auto-rollback (task 2149) came later, with the consumers that needed them.
23
20
  //
24
21
  // Runs from the consumer instance root (default) or `--instance <dir>`. This script ships IN the core
25
22
  // package, so once a consumer is on core vN+1 its own `bongos upgrade` is this code. The FIRST bump
@@ -33,6 +30,7 @@ const crypto = require('node:crypto');
33
30
  const { spawnSync } = require('node:child_process');
34
31
  const { arg, hasFlag } = require('./cli-lib');
35
32
  const { parseSemver, compareSemver, isStable, listAvailableVersions } = require('./update-channel');
33
+ const { checkArtistGate } = require('./upgrade-artist-gate');
36
34
 
37
35
  const CORE_PKG = '@bongos/core';
38
36
  const ARTIFACT = 'bongos-core';
@@ -1146,13 +1144,13 @@ async function runUpgrade(opts, deps = {}) {
1146
1144
  else log(` ✓ pre-flight: database${db ? ` "${db}"` : ''} reachable as the current user`);
1147
1145
  }
1148
1146
 
1149
- // 1b. mandatory post-restart health check (audit H9 / task 1002222, finding F5). A bump that
1150
- // brings the new core live via a managed restart (--service / --restart-cmd) MUST confirm it
1151
- // actually serves — an upgrade that can't be health-checked can't be reported as a success.
1152
- // Enforced here in PRE-FLIGHT, before anything is mutated, so there is nothing to roll back:
1153
- // if this bump will restart the service and the check isn't explicitly opted out, a
1154
- // --health-url is required. (No managed restart ⇒ nothing is brought live here ⇒ the check
1155
- // does not apply; the operator restarts + verifies separately.)
1147
+ // 1a. artist gate (ADR 0241, task 1004205): an open review holds the pin, --force too; a downgrade never waits.
1148
+ const gate = isDowngrade ? { halts: [], notes: [] } : await (deps.checkArtistGate || checkArtistGate)(opts, deps);
1149
+ for (const n of gate.notes) err(` ! ${n.message}`);
1150
+ if (gate.halts.length) return { ok: false, artistGate: true, error: gate.halts.map((h) => [h.message, h.detail].filter(Boolean).join('\n ')).join('\n') };
1151
+ // 1b. mandatory post-restart health check (audit H9 / task 1002222, F5): a bump that restarts the
1152
+ // service must prove it serves, so --health-url is required up front, before anything moves.
1153
+ // (No managed restart ⇒ nothing is brought live here ⇒ the operator restarts + verifies.)
1156
1154
  const willRestart = !!(opts.service || opts.restartCmd);
1157
1155
  if (!dryRun && opts.healthCheck !== false && willRestart && !opts.healthUrl) {
1158
1156
  return { ok: false, error: 'post-restart health check is mandatory for a bump that restarts the service, but no --health-url was given.\n Pass --health-url <url> to confirm the new core serves after restart, or --no-health-check to explicitly skip the confirmation.' };
package/src/module-api.js CHANGED
@@ -71,7 +71,7 @@ const { responsibilityFor, ROLE_RESPONSIBILITIES } = require('./role-responsibil
71
71
  // there. scripts/gds/bump-version.js still rewrites the literal below; it appends
72
72
  // the entry to that file. Look for a version's history there, not here.
73
73
  // ---------------------------------------------------------------------------
74
- const CORE_VERSION = '1.19.989'; // CI auto-patch carrier (ADR 0161); changelog: docs/module-api-changelog.md
74
+ const CORE_VERSION = '1.19.990'; // CI auto-patch carrier (ADR 0161); changelog: docs/module-api-changelog.md
75
75
 
76
76
  // A namespaced logger so a module's log lines are attributable + consistent.
77
77
  // Usage: const log = api.logger('dev-box'); log.info('mounted');
@@ -37,7 +37,12 @@ db.listOpenArtistReviews = async (opts) => { queries.push(opts); return { review
37
37
 
38
38
  let mode = 'strict';
39
39
  let since = null;
40
- api.requireBuilder = (req, _res, next) => { req.builder = { id: 7, rank: 'thetes' }; next(); };
40
+ let signedIn = true;
41
+ api.requireBuilder = (req, res, next) => {
42
+ if (!signedIn) return res.status(401).json({ error: { code: 'unauthenticated' } });
43
+ req.builder = { id: 7, rank: 'thetes' };
44
+ next();
45
+ };
41
46
  // The route must resolve the level through the doorway's ONE reader; stubbing it
42
47
  // here is also what proves it does not read branding().project behind its back.
43
48
  api.artistGate = { ...gateModule, artistGateMode: () => mode, artistGateSince: () => since };
@@ -171,4 +176,68 @@ test('a database failure is a 500 with no internals, never a quiet "nothing hold
171
176
  db.listOpenArtistReviews = async (opts) => { queries.push(opts); return { reviews: rows, truncated: scanTruncated }; };
172
177
  });
173
178
 
179
+ // ---- who may read it without a session (task 1004205) ---------------------------
180
+
181
+ function getWith(path, headers) {
182
+ return new Promise((resolve, reject) => {
183
+ http.get(`${base}${path}`, { headers }, (res) => {
184
+ let d = '';
185
+ res.on('data', (c) => { d += c; });
186
+ res.on('end', () => { let j = null; try { j = JSON.parse(d); } catch { /* non-JSON */ } resolve({ status: res.statusCode, body: j }); });
187
+ }).on('error', reject);
188
+ });
189
+ }
190
+
191
+ test('the box asking its OWN instance directly reads the gate with no session — how `bongos upgrade` asks', async () => {
192
+ reset({ open: [review()] });
193
+ signedIn = false;
194
+ try {
195
+ const r = await getWith('/artist-gate', {});
196
+ assert.equal(r.status, 200);
197
+ assert.equal(r.body.holds, true);
198
+ assert.deepEqual(r.body.reviews, [{ id: '9001', created_at: '2026-09-12T00:00:00.000Z' }]);
199
+ } finally { signedIn = true; }
200
+ });
201
+
202
+ test('anything that came through a proxy still needs a session — public traffic never rides the local exception', async () => {
203
+ reset({ open: [review()] });
204
+ signedIn = false;
205
+ try {
206
+ for (const headers of [
207
+ { 'X-Forwarded-For': '203.0.113.9' },
208
+ { 'X-Real-IP': '203.0.113.9' },
209
+ { Forwarded: 'for=203.0.113.9' },
210
+ { 'CF-Connecting-IP': '203.0.113.9' },
211
+ ]) {
212
+ const r = await getWith('/artist-gate', headers);
213
+ assert.equal(r.status, 401, JSON.stringify(headers));
214
+ }
215
+ } finally { signedIn = true; }
216
+ });
217
+
218
+ test('a peer that is not this machine is not local, forwarding header or not — it needs a session', async () => {
219
+ reset({ open: [review()] });
220
+ signedIn = false;
221
+ try {
222
+ const out = await new Promise((resolve) => {
223
+ const r = { statusCode: 200 };
224
+ const res = {
225
+ status(c) { r.statusCode = c; return this; },
226
+ json(b) { r.body = b; resolve(r); return this; },
227
+ set() { return this; },
228
+ fail(code, o) { r.statusCode = (o && o.status) || 400; resolve(r); },
229
+ };
230
+ buildRouter().handle({ method: 'GET', url: '/artist-gate', headers: {}, socket: { remoteAddress: '203.0.113.9' } }, res, () => resolve({ statusCode: 404 }));
231
+ });
232
+ assert.equal(out.statusCode, 401);
233
+ } finally { signedIn = true; }
234
+ });
235
+
236
+ test('a signed-in builder behind the proxy reads it exactly as before', async () => {
237
+ reset({ open: [review()] });
238
+ const r = await getWith('/artist-gate', { 'X-Forwarded-For': '203.0.113.9' });
239
+ assert.equal(r.status, 200);
240
+ assert.equal(r.body.holds, true);
241
+ });
242
+
174
243
  test.after(() => server.close());
@@ -0,0 +1,144 @@
1
+ // tests/upgrade_artist_gate.mjs — the artist gate holds the pin on the UPGRADE
2
+ // path too (task 1004205; ADR 0241).
3
+ //
4
+ // go-live.js consulted the gate; the vendored `upgrade.js --from` this instance
5
+ // actually moves its pin with did not, so an open review held nothing. These
6
+ // pin the gate reader against a fake instance, and runUpgrade refusing BEFORE
7
+ // anything moves — with a downgrade (rolling back) never held.
8
+ //
9
+ // Run: node tests/upgrade_artist_gate.mjs
10
+ import assert from 'node:assert/strict';
11
+ import { createRequire } from 'node:module';
12
+ import { mkdtempSync, mkdirSync, writeFileSync, readFileSync } from 'node:fs';
13
+ import { tmpdir } from 'node:os';
14
+ import { join } from 'node:path';
15
+ import { makeRunner } from './helpers.mjs';
16
+ import { checkArtistGate } from '../scripts/gds/upgrade-artist-gate.js';
17
+
18
+ const require = createRequire(import.meta.url);
19
+ const u = require('../scripts/gds/upgrade.js');
20
+ const { test, summary } = makeRunner();
21
+
22
+ // A fake instance: answers GET <origin>/api/bongos/artist-gate with `status` + `body`.
23
+ function instance(status, body) {
24
+ const asked = [];
25
+ const fetchImpl = async (url, init) => {
26
+ asked.push({ url, method: init && init.method });
27
+ return { status, ok: status >= 200 && status < 300, json: async () => { if (body === undefined) throw new Error('not json'); return body; } };
28
+ };
29
+ return { asked, fetchImpl };
30
+ }
31
+ const HOLD = {
32
+ ok: true, mode: 'strict', holds: true, reviews: [{ id: '1004199' }],
33
+ halt: { code: 'ARTIST_REVIEW_UNRESOLVED', message: '1 unresolved artist review hold this deploy', detail: 'Held by task 1004199. Two ways out.' },
34
+ };
35
+
36
+ // ---- the reader ---------------------------------------------------------------
37
+
38
+ await test('it asks the instance being upgraded, at the ORIGIN of --health-url', async () => {
39
+ const i = instance(200, { ok: true, mode: 'strict', holds: false, reviews: [], halt: null });
40
+ const r = await checkArtistGate({ healthUrl: 'http://127.0.0.1:3000/api/bongos/healthz' }, { fetchImpl: i.fetchImpl });
41
+ assert.deepEqual(i.asked, [{ url: 'http://127.0.0.1:3000/api/bongos/artist-gate', method: 'GET' }]);
42
+ assert.deepEqual(r, { halts: [], notes: [] }, 'strict with nothing open holds nothing');
43
+ });
44
+
45
+ await test('an open review on a strict project HALTS, naming the review and the way out', async () => {
46
+ const r = await checkArtistGate({ healthUrl: 'https://cloudbongos.com/api/bongos/healthz' }, { fetchImpl: instance(200, HOLD).fetchImpl });
47
+ assert.equal(r.halts.length, 1);
48
+ assert.equal(r.halts[0].code, 'ARTIST_REVIEW_UNRESOLVED');
49
+ assert.match(r.halts[0].detail, /1004199/);
50
+ });
51
+
52
+ await test('advisory and off hold nothing', async () => {
53
+ for (const mode of ['advisory', 'off']) {
54
+ const r = await checkArtistGate({ healthUrl: 'http://x/h' }, { fetchImpl: instance(200, { mode, holds: false, reviews: [], halt: null }).fetchImpl });
55
+ assert.deepEqual(r.halts, [], mode);
56
+ }
57
+ });
58
+
59
+ await test('a gate that is THERE and broken halts; one that cannot be read at all is a note', async () => {
60
+ assert.equal((await checkArtistGate({ healthUrl: 'http://x/h' }, { fetchImpl: instance(500, {}).fetchImpl })).halts[0].code, 'ARTIST_GATE_UNREADABLE');
61
+ for (const [status, body] of [[404, {}], [200, undefined], [200, { hello: 'an SPA page' }]]) {
62
+ const r = await checkArtistGate({ healthUrl: 'http://x/h' }, { fetchImpl: instance(status, body).fetchImpl });
63
+ assert.deepEqual(r.halts, [], `${status} → no halt`);
64
+ assert.equal(r.notes[0].code, 'ARTIST_GATE_UNREAD', `${status} → said out loud, never read as "nothing holds" silently`);
65
+ }
66
+ const down = await checkArtistGate({ healthUrl: 'http://x/h' }, { fetchImpl: async () => { throw new Error('ECONNREFUSED'); } });
67
+ assert.equal(down.notes[0].code, 'ARTIST_GATE_UNREAD');
68
+ });
69
+
70
+ await test('with no --health-url there is nothing to ask — a note, never a silent pass', async () => {
71
+ for (const healthUrl of [undefined, 'not a url']) {
72
+ const r = await checkArtistGate({ healthUrl }, { fetchImpl: async () => { throw new Error('must not be called'); } });
73
+ assert.deepEqual(r.halts, []);
74
+ assert.equal(r.notes[0].code, 'ARTIST_GATE_UNREAD');
75
+ }
76
+ });
77
+
78
+ // ---- runUpgrade -----------------------------------------------------------------
79
+
80
+ function consumer(version = '1.14.1') {
81
+ const dir = mkdtempSync(join(tmpdir(), 'otb-upgrade-gate-'));
82
+ writeFileSync(join(dir, 'package.json'), JSON.stringify({
83
+ name: 'c', version: '0.1.0', dependencies: { '@bongos/core': `file:vendor/bongos-core-${version}.tgz` }, scripts: { migrate: 'true', start: 'true' },
84
+ }, null, 2) + '\n');
85
+ mkdirSync(join(dir, 'node_modules', '@bongos', 'core'), { recursive: true });
86
+ writeFileSync(join(dir, 'node_modules', '@bongos', 'core', 'package.json'), JSON.stringify({ name: '@bongos/core', version }) + '\n');
87
+ return dir;
88
+ }
89
+ function tarball(version) {
90
+ const src = mkdtempSync(join(tmpdir(), 'src-'));
91
+ writeFileSync(join(src, `bongos-core-${version}.tgz`), 'TGZ');
92
+ return join(src, `bongos-core-${version}.tgz`);
93
+ }
94
+ const run = (calls) => (cmd, args) => { calls.push(`${cmd} ${(args || []).join(' ')}`); return cmd === 'git' ? { status: 0, stdout: '' } : { status: 0 }; };
95
+ const holding = async () => ({ halts: [{ code: 'ARTIST_REVIEW_UNRESOLVED', message: '1 unresolved artist review hold this deploy', detail: 'Held by task 1004199.' }], notes: [] });
96
+
97
+ await test('runUpgrade REFUSES a held pin before anything moves — --force included', async () => {
98
+ for (const force of [false, true]) {
99
+ const dir = consumer();
100
+ const calls = [];
101
+ const res = await u.runUpgrade({ to: '1.15.0', from: tarball('1.15.0'), instance: dir, force, skipMigrate: true },
102
+ { log: () => {}, err: () => {}, run: run(calls), checkArtistGate: holding });
103
+ assert.equal(res.ok, false);
104
+ assert.equal(res.artistGate, true);
105
+ assert.match(res.error, /unresolved artist review/);
106
+ assert.match(res.error, /1004199/, 'names the review');
107
+ assert.equal(u.readPinnedCoreVersion(dir), '1.14.1', 'the pin never moved');
108
+ assert.ok(!calls.some((c) => c.startsWith('npm')), 'nothing installed');
109
+ }
110
+ });
111
+
112
+ await test('a dry run reports the hold too — that is what a dry run is for', async () => {
113
+ const res = await u.runUpgrade({ to: '1.15.0', from: tarball('1.15.0'), instance: consumer(), dryRun: true, skipMigrate: true },
114
+ { log: () => {}, err: () => {}, run: run([]), checkArtistGate: holding });
115
+ assert.equal(res.ok, false);
116
+ assert.equal(res.artistGate, true);
117
+ });
118
+
119
+ await test('nothing open: the upgrade proceeds exactly as before, and a note is printed, not swallowed', async () => {
120
+ const errs = [];
121
+ const res = await u.runUpgrade({ to: '1.15.0', from: tarball('1.15.0'), instance: consumer(), dryRun: true, skipMigrate: true },
122
+ { log: () => {}, err: (m) => errs.push(m), run: run([]), checkArtistGate: async () => ({ halts: [], notes: [{ code: 'ARTIST_GATE_UNREAD', message: 'could not read this instance\'s artist gate (x)' }] }) });
123
+ assert.equal(res.ok, true);
124
+ assert.ok(errs.some((m) => /could not read this instance's artist gate/.test(m)));
125
+ });
126
+
127
+ await test('a DOWNGRADE is never held — rolling back must not wait on a review', async () => {
128
+ let asked = 0;
129
+ const res = await u.runUpgrade({ to: '1.14.0', from: tarball('1.14.0'), instance: consumer('1.14.1'), allowDowngrade: true, dryRun: true, skipMigrate: true },
130
+ { log: () => {}, err: () => {}, run: run([]), checkArtistGate: async () => { asked++; return holding(); } });
131
+ assert.equal(asked, 0);
132
+ assert.equal(res.ok, true);
133
+ });
134
+
135
+ await test('the gate runs from the pre-flight, before the pin step, and the reader is go-live\'s own', () => {
136
+ const whole = readFileSync(new URL('../scripts/gds/upgrade.js', import.meta.url), 'utf8');
137
+ const src = whole.slice(whole.indexOf('async function runUpgrade('));
138
+ const gateAt = src.indexOf('checkArtistGate)(opts, deps)');
139
+ assert.ok(gateAt > 0 && gateAt < src.indexOf('writePin(instanceDir'), 'checked before the pin is written');
140
+ const gateSrc = readFileSync(new URL('../scripts/gds/upgrade-artist-gate.js', import.meta.url), 'utf8');
141
+ assert.match(gateSrc, /require\('\.\/go-live'\)/, 'one reader and one judgement for both deploy paths');
142
+ });
143
+
144
+ summary();