@bongos/core 1.19.352 → 1.19.353

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,11 +2,11 @@
2
2
  "artifact": "bongos-core",
3
3
  "manifest_schema": 1,
4
4
  "generator": "scripts/gds/package-core.js",
5
- "core_version": "1.19.352",
6
- "core_contract": "1.19.352",
7
- "source_commit": "e9a9e6873568180427946951f116e153cdef056f",
5
+ "core_version": "1.19.353",
6
+ "core_contract": "1.19.353",
7
+ "source_commit": "5bb1f8185d48f3d3d53181f4525eca45b0cef665",
8
8
  "source_ref": "HEAD",
9
- "built_at": "2026-08-25T13:00:42.177Z",
9
+ "built_at": "2026-08-25T13:07:06.857Z",
10
10
  "redaction": {
11
11
  "model": "docs-redacted+functional-verbatim",
12
12
  "docs_redacted": 329,
@@ -17,7 +17,7 @@
17
17
  "gate": "passed"
18
18
  },
19
19
  "file_count": 1857,
20
- "tree_sha256": "0a7c5bcf1b690464bce9877959778b5f611f54fedb8a6c7b9c51459d47ad7a04",
20
+ "tree_sha256": "3b39dee80eea8539fc0a7b82684369a69c58b09c426cac168f029815bc78270e",
21
21
  "files": [
22
22
  {
23
23
  "path": ".claude/skills/blocker-review/SKILL.md",
@@ -4787,12 +4787,12 @@
4787
4787
  {
4788
4788
  "path": "package-lock.json",
4789
4789
  "mode": "0000644",
4790
- "sha256": "a82b85a09d4f6e7259d1f11a8468e50b82a94a346f7cada1a1c63e09217d4a81"
4790
+ "sha256": "0b1bb5323c63aefbe9f58e5bd5eba8cfed791c5089bf5dbae18fde4055c31299"
4791
4791
  },
4792
4792
  {
4793
4793
  "path": "package.json",
4794
4794
  "mode": "0000644",
4795
- "sha256": "f371019e624fd7befd3ef764ae4cac6d7f98dc8ba3058a2ed552f361e48c5568"
4795
+ "sha256": "c524de81eaba481839a9515c321c48d231506f677459d76c495bb51ebfd8b90c"
4796
4796
  },
4797
4797
  {
4798
4798
  "path": "public-docs/index.html",
@@ -5797,17 +5797,17 @@
5797
5797
  {
5798
5798
  "path": "scripts/gds/provision-repo.js",
5799
5799
  "mode": "0000644",
5800
- "sha256": "bc1b8850038c8aaa8c0cbf2d5d9881f671b7cb959533802bc5d6b23b48ba15bd"
5800
+ "sha256": "c87cccdd63ac6fa6d38771c3ad178e5e919f8bee62ad769b9d127819f84e2750"
5801
5801
  },
5802
5802
  {
5803
5803
  "path": "scripts/gds/provision-units.js",
5804
5804
  "mode": "0000644",
5805
- "sha256": "6fe61c756ca409fd4e7967144cf53a064a7095ab09006f71642d5cac860e93d7"
5805
+ "sha256": "e8a44143883403c2ff8e20107250d63f6d19a14050279e8d675480582e07c555"
5806
5806
  },
5807
5807
  {
5808
5808
  "path": "scripts/gds/provision.js",
5809
5809
  "mode": "0000644",
5810
- "sha256": "2f9e608632b147602b8e141a0cba2071bf36e27fafadd410b7fea399f448250c"
5810
+ "sha256": "5b4f5edce415dd46db830104eb196de678214730d736ebf3ae26a7671b718c77"
5811
5811
  },
5812
5812
  {
5813
5813
  "path": "scripts/gds/publish-credential-check.js",
@@ -6652,7 +6652,7 @@
6652
6652
  {
6653
6653
  "path": "src/module-api.js",
6654
6654
  "mode": "0000644",
6655
- "sha256": "7433ae86603ef217160393fd3b36bb847092f0c040473a5bba43a21c14444be1"
6655
+ "sha256": "82bd181f16c9ee484e55c879439a7f61ff056588080a57bd95a3881d89b726f3"
6656
6656
  },
6657
6657
  {
6658
6658
  "path": "src/module-loader/catalog.js",
@@ -8557,7 +8557,7 @@
8557
8557
  {
8558
8558
  "path": "tests/provision.mjs",
8559
8559
  "mode": "0000644",
8560
- "sha256": "304f8d9243512672a706a1e073a4874aec2e24a43cfbed550967db1fd23a16dc"
8560
+ "sha256": "0fc6c6626b43458c2e065322bec5a2ecd87e50a44abd2838d81ff0f0b6abeae7"
8561
8561
  },
8562
8562
  {
8563
8563
  "path": "tests/provisioning_default_domain.mjs",
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@bongos/core",
3
- "version": "1.19.352",
3
+ "version": "1.19.353",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@bongos/core",
9
- "version": "1.19.352",
9
+ "version": "1.19.353",
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.352",
3
+ "version": "1.19.353",
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",
@@ -323,6 +323,18 @@ function alreadyScaffolded(root, mode, { fsImpl = fs } = {}) {
323
323
  //
324
324
  // Idempotent (see alreadyScaffolded) and dry-run safe (every mutation goes through the
325
325
  // injected exec/writeFile). ADR 0108 / 0121 / 0125.
326
+ // The signed-in builder who owns the instance — the founding firstAdmin. Best-effort:
327
+ // no db, no row, or a query error → null, and callers fall back to the repo owner in
328
+ // target_ref. Shared by the scaffold's branding.firstAdmin and web.env's
329
+ // <prefix>_FIRST_ADMIN (task 1003240) so the two can never disagree.
330
+ async function ownerLoginOf(inst, db) {
331
+ if (!inst || !inst.owner_builder_id || !db || typeof db.query !== 'function') return null;
332
+ try {
333
+ const r = await db.query('SELECT github_login FROM builders WHERE id = $1', [inst.owner_builder_id]);
334
+ return r && r.rows && r.rows[0] && r.rows[0].github_login ? r.rows[0].github_login : null;
335
+ } catch { return null; }
336
+ }
337
+
326
338
  async function scaffoldStandaloneRepo(inst, deps) {
327
339
  // The scaffold BUILDS + pushes the instance's repo (git clone, package-core,
328
340
  // `bongos init`, git push) — control-plane work that needs the packaging tools +
@@ -352,13 +364,7 @@ async function scaffoldStandaloneRepo(inst, deps) {
352
364
  : ` [scaffold] ${repo.owner}/${repo.name} → ${root} (clone → materialize → pin core ${coreV} → commit → push)`);
353
365
 
354
366
  // Owner login = the founding firstAdmin. Best-effort; the spec falls back to the repo owner.
355
- let ownerLogin = null;
356
- if (inst.owner_builder_id && db) {
357
- try {
358
- const r = await db.query('SELECT github_login FROM builders WHERE id = $1', [inst.owner_builder_id]);
359
- ownerLogin = r && r.rows && r.rows[0] ? r.rows[0].github_login : null;
360
- } catch { /* fall back to the repo owner */ }
361
- }
367
+ const ownerLogin = await ownerLoginOf(inst, db);
362
368
 
363
369
  // Resolve the instance owner's OAuth token BEFORE any git network op.
364
370
  //
@@ -820,6 +826,7 @@ module.exports = {
820
826
  CORE_PKG_DIR,
821
827
  INSTANCE_GITIGNORE,
822
828
  alreadyScaffolded,
829
+ ownerLoginOf,
823
830
  asPostgres,
824
831
  buildCorePinRefreshCommit,
825
832
  dbCreateCmd,
@@ -153,7 +153,7 @@ function provisionedEnvPrefix() {
153
153
  // the hall on this host + OAuth uses the real callback origin — without them the pack
154
154
  // stays at neutral localhost and the hall never loads (task 1972). No domain yet
155
155
  // (bring-your-own deferred, ADR 0111 §4) ⇒ origins stay neutral until one is set.
156
- function webEnvBody(inst, { clientId = '', clientSecret = '', appId = null, appPem = null, federation = null } = {}) {
156
+ function webEnvBody(inst, { clientId = '', clientSecret = '', appId = null, appPem = null, federation = null, ownerLogin = null } = {}) {
157
157
  const prefix = provisionedEnvPrefix(), { settingsEnvLines } = require(path.join(REPO_ROOT, 'modules/provisioning/provisioning')); // eslint-disable-line global-require
158
158
  const origin = inst.domain ? `https://${inst.domain}` : '';
159
159
  const originLines = origin
@@ -191,12 +191,12 @@ ${prefix}_OAUTH_ORIGIN=${origin}
191
191
  // demo had every origin override but no FIRST_ADMIN, so the owner could not be seated).
192
192
  // Derived from the instance repo owner (target_ref = "<owner>/<repo>"), the SAME source
193
193
  // instanceInitSpec uses for the scaffold's branding.firstAdmin — so this env override and
194
- // the scaffolded config/branding.json agree. (Org-owned repo: the org login is not a
195
- // sign-in identity, so it is left unset; the owner sets <prefix>_FIRST_ADMIN by hand.)
194
+ // the scaffolded config/branding.json agree — and, like the spec, PREFERS the signed-in
195
+ // builder's login when the caller resolved one (ownerLoginOf). An org-owned repo's
196
+ // owner is the org, which is not a sign-in identity: seating it seats nobody (task 1003240).
196
197
  const ownerRepo = parseTargetRef(inst.target_ref);
197
- const firstAdminLine = ownerRepo && ownerRepo.owner
198
- ? `${prefix}_FIRST_ADMIN=${ownerRepo.owner}\n`
199
- : '';
198
+ const firstAdmin = ownerLogin || (ownerRepo && ownerRepo.owner) || null;
199
+ const firstAdminLine = firstAdmin ? `${prefix}_FIRST_ADMIN=${firstAdmin}\n` : '';
200
200
  // Cross-site identity federation block (ADR 0141 §4, task #1002109). Present only for
201
201
  // a HOSTED (federated) instance: flips auth.idp ON via the env override branding.js
202
202
  // reads (idpEnabled), and carries the hub origin, this instance's per-client secret
@@ -50,7 +50,7 @@ const cp = require('node:child_process');
50
50
  const crypto = require('node:crypto');
51
51
 
52
52
  const { CONFIG, MANIFEST_UA, MANIFEST_VERIFY_INTERVAL_MS, MANIFEST_VERIFY_TRIES, MAX_INTENT_ATTEMPTS, REPO_ROOT, coreVersionSafe, hasFlag, loadDeps, oauthSecret, provisionerBotEmail } = require('./provision-config.js');
53
- const { APP_USER, alreadyScaffolded, buildCorePinRefreshCommit, dbCreateCmd, dbName, deployKeyPath, deployKeyTitle, ensurePrivateRepoAccess, installedCorePackDir, installedCoreTarball, instanceInitSpec, instanceRepoRemote, migrateCmd, onboardMode, parseTargetRef, planCorePinRefresh, refreshStandaloneCorePin, resolveOwnerGithubToken, resolveVendorableCoreTarball, safeVersionLabel, scaffoldStandaloneRepo, seedFirstVersionCmd, standaloneInstallCmd, standaloneMigrateCmd, standalonePullCmd, standaloneRegenDocsCmd, standaloneRoot } = require('./provision-repo.js');
53
+ const { APP_USER, alreadyScaffolded, buildCorePinRefreshCommit, dbCreateCmd, dbName, deployKeyPath, deployKeyTitle, ensurePrivateRepoAccess, installedCorePackDir, installedCoreTarball, instanceInitSpec, instanceRepoRemote, migrateCmd, onboardMode, ownerLoginOf, parseTargetRef, planCorePinRefresh, refreshStandaloneCorePin, resolveOwnerGithubToken, resolveVendorableCoreTarball, safeVersionLabel, scaffoldStandaloneRepo, seedFirstVersionCmd, standaloneInstallCmd, standaloneMigrateCmd, standalonePullCmd, standaloneRegenDocsCmd, standaloneRoot } = require('./provision-repo.js');
54
54
  const { backupScriptPath, backupService, backupServicePath, backupTimer, backupTimerPath, backupUnitName, serviceUnit, serviceUnitPath, webEnvBody, webEnvPath } = require('./provision-units.js');
55
55
  const { caddyBlock, caddySnippetPath, checkDnsTokenScope, classifyZoneScope, dnsUpsertEnv, federateInstance, federationHubOrigin, healthzCmd, shouldFederate, zoneForDomain } = require('./provision-net.js');
56
56
 
@@ -381,7 +381,7 @@ async function provisionInstance(inst, deps) {
381
381
 
382
382
  // ── step 3: config + per-instance secrets ─────────────────────────────────
383
383
  log(' [config] per-instance web.env');
384
- if (local) boxWriteFile(webEnvPath(inst), webEnvBody(inst, { federation }), { mode: 0o600, sudo: true });
384
+ if (local) boxWriteFile(webEnvPath(inst), webEnvBody(inst, { federation, ownerLogin: await ownerLoginOf(inst, deps.db) }), { mode: 0o600, sudo: true });
385
385
  else log(' (baked into cloud-init)');
386
386
 
387
387
  // ── step 4: systemd unit + enable ─────────────────────────────────────────
@@ -588,7 +588,7 @@ async function domainAttachInstance(inst, deps) {
588
588
  : CONFIG.publicIp;
589
589
 
590
590
  log(' [config] re-write per-instance web.env (origins now carry the domain)');
591
- boxWriteFile(webEnvPath(inst), webEnvBody(inst, { federation: null }), { mode: 0o600, sudo: true });
591
+ boxWriteFile(webEnvPath(inst), webEnvBody(inst, { federation: null, ownerLogin: await ownerLoginOf(inst, deps.db) }), { mode: 0o600, sudo: true });
592
592
  log(' [service] restart to pick up the new origins');
593
593
  boxExec(`${sudoP}systemctl restart ${inst.slug}`);
594
594
 
@@ -790,7 +790,7 @@ async function placeManifestCreds(inst, mrow, deps) {
790
790
  // writeFile logs only a byte count; the value is base64/temp-file placed).
791
791
  log(` [oauth-manifest] place creds in ${webEnvPath(inst)} + restart ${inst.slug}`);
792
792
  boxWriteFile(webEnvPath(inst), webEnvBody(inst, {
793
- clientId: creds.clientId, clientSecret: creds.clientSecret,
793
+ clientId: creds.clientId, clientSecret: creds.clientSecret, ownerLogin: await ownerLoginOf(inst, deps.db),
794
794
  // The App id + private key double as the ADR 0055 publish credential (task
795
795
  // 1003049); older Apps (pre-permission manifests) return a pem too — placing
796
796
  // it is harmless and heals once the owner grants the permissions + installs.
package/src/module-api.js CHANGED
@@ -1134,8 +1134,10 @@ const { validateOrRespond, LIMITS, parseId, asyncHandler, corsPublicGet, parsePa
1134
1134
  // landed since 1.19.350 with no explicit bump. run 32850120472. (task 1002620)
1135
1135
  // 1.19.352 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
1136
1136
  // landed since 1.19.351 with no explicit bump. run 32850767673. (task 1002620)
1137
+ // 1.19.353 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
1138
+ // landed since 1.19.352 with no explicit bump. run 32851392269. (task 1002620)
1137
1139
  // ---------------------------------------------------------------------------
1138
- const CORE_VERSION = '1.19.352'; // CI auto-patch carrier (ADR 0161); see changelog above
1140
+ const CORE_VERSION = '1.19.353'; // CI auto-patch carrier (ADR 0161); see changelog above
1139
1141
 
1140
1142
  // A namespaced logger so a module's log lines are attributable + consistent.
1141
1143
  // Usage: const log = api.logger('dev-box'); log.info('mounted');
@@ -238,6 +238,17 @@ t('webEnvBody: the repo target_ref seats the founding owner via <prefix>_FIRST_A
238
238
  assert.doesNotMatch(P.webEnvBody(coTenant), /_FIRST_ADMIN=/);
239
239
  });
240
240
 
241
+ t('webEnvBody: a resolved owner login wins over the repo owner — an org-owned repo seats the signed-in builder (task 1003240)', () => {
242
+ // The org that owns an adopted repo is not a sign-in identity; seating it seats nobody.
243
+ // Same preference instanceInitSpec already applies to the scaffold's branding.firstAdmin.
244
+ const inst = { ...coTenant, hosting_shape: 'standalone', domain: 'mercury.example.com', target_ref: 'acme-org/mercury' };
245
+ const withLogin = P.webEnvBody(inst, { ownerLogin: 'octocat' });
246
+ assert.match(withLogin, new RegExp(`${reEsc(NEUTRAL_PREFIX)}_FIRST_ADMIN=octocat`));
247
+ assert.doesNotMatch(withLogin, /_FIRST_ADMIN=acme-org/);
248
+ // no resolved login → the repo owner stays the fallback (a personal repo's owner IS the builder)
249
+ assert.match(P.webEnvBody(inst), new RegExp(`${reEsc(NEUTRAL_PREFIX)}_FIRST_ADMIN=acme-org`));
250
+ });
251
+
241
252
  t('caddyBlock: a domain → on-demand-TLS reverse_proxy to the local port; no domain → a comment', () => {
242
253
  const withDomain = P.caddyBlock({ ...coTenant, domain: 'mercury.example.com' });
243
254
  assert.match(withDomain, /mercury\.example\.com \{/);
@@ -408,6 +419,21 @@ await ta('provisionInstance(standalone): the backup unit ExecStart points at the
408
419
  assert.match(svc, /Environment=GDS_BACKUP_DB=mercury/);
409
420
  });
410
421
 
422
+ await ta('provisionInstance(standalone): web.env seats the signed-in builder, not the org that owns the repo (task 1003240)', async () => {
423
+ const { deps } = recorder();
424
+ const bodies = {};
425
+ deps.writeFile = (p, body) => { bodies[p] = body; return { ok: true }; };
426
+ // the builders lookup answers with the signed-in owner; every other query stays empty
427
+ deps.db = { query: async (sql) => (/FROM builders/.test(String(sql)) ? { rows: [{ github_login: 'octocat' }] } : { rows: [] }) };
428
+ const inst = { ...coTenant, hosting_shape: 'standalone', target_ref: 'acme-org/mercury', owner_builder_id: 7 };
429
+ const r = await P.provisionInstance(inst, deps);
430
+ assert.equal(r.ok, true);
431
+ const envPath = Object.keys(bodies).find((p) => p.endsWith('/web.env'));
432
+ assert.ok(envPath, 'wrote web.env');
433
+ assert.match(bodies[envPath], new RegExp(`${reEsc(NEUTRAL_PREFIX)}_FIRST_ADMIN=octocat`));
434
+ assert.doesNotMatch(bodies[envPath], /_FIRST_ADMIN=acme-org/);
435
+ });
436
+
411
437
  await ta('provisionInstance(standalone) SCAFFOLDS its repo, then syncs (pull + npm ci) + migrates from the instance root', async () => {
412
438
  const { deps, cmds, writes } = recorder();
413
439
  const r = await P.provisionInstance({ ...coTenant, hosting_shape: 'standalone', target_ref: 'lars589/mercury' }, deps);