@bongos/core 1.19.847 → 1.19.848

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.847",
6
- "core_contract": "1.19.847",
7
- "source_commit": "2f39aee80129563c843fb3b14b31a00db502f851",
5
+ "core_version": "1.19.848",
6
+ "core_contract": "1.19.848",
7
+ "source_commit": "cec883a4362510c614bbf91576983ff03d6df2ce",
8
8
  "source_ref": "HEAD",
9
- "built_at": "2026-09-17T19:42:18.427Z",
9
+ "built_at": "2026-09-17T19:52:14.256Z",
10
10
  "redaction": {
11
11
  "model": "docs-redacted+functional-verbatim",
12
12
  "docs_redacted": 496,
@@ -17,7 +17,7 @@
17
17
  "gate": "passed"
18
18
  },
19
19
  "file_count": 2795,
20
- "tree_sha256": "6e729d424a5377af457b9b765d44e5af905a4228a5f2df22ee259583224231a0",
20
+ "tree_sha256": "31f2347b41b6fb4c9974eb45d6b3b99d10ae8827fec75f36b3f239159ecbe87c",
21
21
  "files": [
22
22
  {
23
23
  "path": ".claude/skills/ask-for-help/SKILL.md",
@@ -322,7 +322,7 @@
322
322
  {
323
323
  "path": "Dockerfile",
324
324
  "mode": "0000644",
325
- "sha256": "25e2854dfdea46cda6b60268890ac1ec21ae6a35b29758257c1f8df35d16cbd6"
325
+ "sha256": "e0876b6353244e13917d10510d9f60f61dd85983dee9b19a5da762c574cbae4b"
326
326
  },
327
327
  {
328
328
  "path": "GOVERNANCE.md",
@@ -2582,7 +2582,7 @@
2582
2582
  {
2583
2583
  "path": "docs/module-api-changelog.md",
2584
2584
  "mode": "0000644",
2585
- "sha256": "6ba668dea0868f1ab54467d18278e494c3fc4eb121d19313c6d85d2c80d89e63"
2585
+ "sha256": "ed51b2e95fbd3cfd4d5aed5a54aea53a9fc147ee0c7075dd4ecf9eda265ec50e"
2586
2586
  },
2587
2587
  {
2588
2588
  "path": "docs/modules-contract.md",
@@ -2812,7 +2812,7 @@
2812
2812
  {
2813
2813
  "path": "docs/recipes/self-host.md",
2814
2814
  "mode": "0000644",
2815
- "sha256": "2108b55f6e3264af35c2db885b5a98ff8cc9a5c5c68881d3f5ce8037db1bf159"
2815
+ "sha256": "135f3942a01e50af87c4645f8920b25e0b779aac45cb5101b39e62cacfa59168"
2816
2816
  },
2817
2817
  {
2818
2818
  "path": "docs/recipes/server-bring-up.md",
@@ -7907,12 +7907,12 @@
7907
7907
  {
7908
7908
  "path": "package-lock.json",
7909
7909
  "mode": "0000644",
7910
- "sha256": "6adf112f9a6622910cb13b7dd741da5a7d1c84976c286e13068974bb8717c629"
7910
+ "sha256": "c4a58e2d12411921c911607c5345671c595e34d7d7c8c51747d7ea5978cf21d4"
7911
7911
  },
7912
7912
  {
7913
7913
  "path": "package.json",
7914
7914
  "mode": "0000644",
7915
- "sha256": "f7dc6b6b5522f7b4e1bddf7f62cd371fda49d1304497cb6b5de979c5f7a2ac93"
7915
+ "sha256": "a3b15f291e7851a3578a38113485b76f54b695dca7bf97859954a26707a24c2a"
7916
7916
  },
7917
7917
  {
7918
7918
  "path": "public-docs/index.html",
@@ -8767,7 +8767,7 @@
8767
8767
  {
8768
8768
  "path": "scripts/gds/package-core.js",
8769
8769
  "mode": "0000644",
8770
- "sha256": "d9a6748c0dadbff9954809df1c83345979e1356559312723e107f19949edfd7b"
8770
+ "sha256": "4d439440fe0fe498382c7ee6e1684637a5bcad46ae67878c0d2c98d5de6cbbdd"
8771
8771
  },
8772
8772
  {
8773
8773
  "path": "scripts/gds/paste-token.js",
@@ -8837,7 +8837,7 @@
8837
8837
  {
8838
8838
  "path": "scripts/gds/provision-repo.js",
8839
8839
  "mode": "0000644",
8840
- "sha256": "c8d4ce3004cafbd1d70ee72845700c95c85da41ced29fe059af333869a75cc03"
8840
+ "sha256": "b04300749c4f119912ecfb2e6df4a6703f004130570e47a4e5bfaffacd7e2118"
8841
8841
  },
8842
8842
  {
8843
8843
  "path": "scripts/gds/provision-teardown.js",
@@ -8852,7 +8852,7 @@
8852
8852
  {
8853
8853
  "path": "scripts/gds/provision.js",
8854
8854
  "mode": "0000644",
8855
- "sha256": "43dd54ec69ff29ad83e631d53a65c1a2d22b89ef07181e4df14581e5199bfa61"
8855
+ "sha256": "cbf44d415e3c5bb803e68af7b70ebfb08e7d0ab2388cc7f17a114512f29662e8"
8856
8856
  },
8857
8857
  {
8858
8858
  "path": "scripts/gds/publish-credential-check.js",
@@ -9847,7 +9847,7 @@
9847
9847
  {
9848
9848
  "path": "src/module-api.js",
9849
9849
  "mode": "0000644",
9850
- "sha256": "c2347ac91ce5aa5e5f46bcb3e0734bd151e2abbe1f2347290d75891229223a17"
9850
+ "sha256": "f6dcadffbe81524b07bdc5821ae2cf1f5268eeea497354a09d0e7158673e3b85"
9851
9851
  },
9852
9852
  {
9853
9853
  "path": "src/module-loader/catalog.js",
@@ -12427,7 +12427,7 @@
12427
12427
  {
12428
12428
  "path": "tests/package_core.mjs",
12429
12429
  "mode": "0000644",
12430
- "sha256": "a8278101d0de34bb8214f4c7a5a68760b5546099df27044c20d5c360fdc4442f"
12430
+ "sha256": "7d64e3c217274af48f24557d49deeb2cb54d7929bd9e939f15b3d3ceb757336c"
12431
12431
  },
12432
12432
  {
12433
12433
  "path": "tests/parallel-load.mjs",
@@ -12702,7 +12702,7 @@
12702
12702
  {
12703
12703
  "path": "tests/provision.mjs",
12704
12704
  "mode": "0000644",
12705
- "sha256": "5a1abd44776798ca89266f86663037086c1270aca569e54647607d4488cbfea9"
12705
+ "sha256": "d763e2b5a10fbdd9a0e95fae493b524c7a52b437663125e3dbaf753435402e9c"
12706
12706
  },
12707
12707
  {
12708
12708
  "path": "tests/provision_caddy_wiring.mjs",
package/Dockerfile CHANGED
@@ -15,8 +15,13 @@ FROM node:22-bookworm-slim
15
15
 
16
16
  # postgresql-client gives us `psql` for scripts/migrate.sh; bash runs it; tini
17
17
  # is a proper PID 1 so signals/zombies are handled. curl powers HEALTHCHECK.
18
+ # git is the provisioning scaffold's only unmet tool (task 1003995): scaffoldStandaloneRepo
19
+ # materializes a child instance's repo with `git init`/`clone` → commit → push, so without it
20
+ # `provision.js run-intents --apply` cannot run here at all. The image still carries NO .git
21
+ # of its own (.dockerignore excludes it by design) — that half is package-core's
22
+ # --from-worktree rung, not an apt line.
18
23
  RUN apt-get update \
19
- && apt-get install -y --no-install-recommends postgresql-client bash tini curl ca-certificates \
24
+ && apt-get install -y --no-install-recommends postgresql-client bash tini curl ca-certificates git \
20
25
  && rm -rf /var/lib/apt/lists/*
21
26
 
22
27
  WORKDIR /app
@@ -2168,5 +2168,7 @@ is load-bearing: the script throws rather than guess if it is missing, and
2168
2168
  landed since 1.19.845 with no explicit bump. run 35264882014. (task 1002620)
2169
2169
  1.19.847 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
2170
2170
  landed since 1.19.846 with no explicit bump. run 35266409194. (task 1002620)
2171
+ 1.19.848 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
2172
+ landed since 1.19.847 with no explicit bump. run 35267380720. (task 1002620)
2171
2173
  ---------------------------------------------------------------------------
2172
2174
  ```
@@ -39,7 +39,7 @@ Author `config/branding.json` from the neutral starter — see [the branding con
39
39
 
40
40
  **Or scaffold it with `bongos init`** ([task #1204](https://example.com/builders#/task/1204)): a short interview (or `bongos init --from spec.json` for a hands-free / CI run) that writes both config files, **seeds your first version + its done-when goal**, and **files the human-only kickoff steps** (register a GitHub OAuth app, first owner sign-in, repo binding, admission) as real tracked tasks — so a fresh instance has a claimable queue on day one instead of an empty hall. It never invents your branding (it points you at the fill prompt for that). Preview the whole plan with `bongos init --dry-run`.
41
41
 
42
- **Production hosting, optional (the `provisioning` module — [ADR 0111](../adr/0111-instance-hosting-provisioning-module.md) §3).** If you enable the `provisioning` module and answer the interview's hosting questions (shape — co-tenant `$0` or a dedicated droplet — bring-your-own domain, credential ref, tier), init turns those answers into a real **provisioning request** (a queued `provision` intent the control-plane runner drains) instead of only filing a manual "production topology" task. **A queued request does nothing until a runner drains it:** on the control plane that is a systemd timer running `node scripts/gds/provision.js run-intents --apply`. This Docker image cannot run that today (no git in the image, systemd and a DigitalOcean token assumed; task 1002718), so on a compose self-host a new project waits indefinitely. The two irreducibly-human legs — the GitHub OAuth app and the first owner sign-in — stay guided/manual. If the module isn't enabled on the target instance, init falls back to the manual production-topology task, so nothing is silently skipped.
42
+ **Production hosting, optional (the `provisioning` module — [ADR 0111](../adr/0111-instance-hosting-provisioning-module.md) §3).** If you enable the `provisioning` module and answer the interview's hosting questions (shape — co-tenant `$0` or a dedicated droplet — bring-your-own domain, credential ref, tier), init turns those answers into a real **provisioning request** (a queued `provision` intent the control-plane runner drains) instead of only filing a manual "production topology" task. **A queued request does nothing until a runner drains it:** on the control plane that is a systemd timer running `node scripts/gds/provision.js run-intents --apply`. This Docker image now carries the tools the scaffold needs — git, and a core it can package out of its own `.git`-less checkout (task 1003995) — but the standup leg still assumes root + systemd, which a container has not got (task 1003997), so on a compose self-host a new project waits indefinitely. The two irreducibly-human legs — the GitHub OAuth app and the first owner sign-in — stay guided/manual. If the module isn't enabled on the target instance, init falls back to the manual production-topology task, so nothing is silently skipped.
43
43
 
44
44
  ## Configuration surface
45
45
 
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@bongos/core",
3
- "version": "1.19.847",
3
+ "version": "1.19.848",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@bongos/core",
9
- "version": "1.19.847",
9
+ "version": "1.19.848",
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.847",
3
+ "version": "1.19.848",
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",
@@ -51,9 +51,22 @@
51
51
  // The manifest ALSO records tarball.sha256 to verify the exact downloaded bytes.
52
52
  //
53
53
  // USAGE:
54
- // node scripts/gds/package-core.js [--ref <git-ref>] [--out-dir dist]
54
+ // node scripts/gds/package-core.js [--ref <git-ref> | --from-worktree] [--out-dir dist]
55
55
  // [--version <v>] [--droplet-ip <ip>] [--self-verify [--self-verify-boot]] [--publish [--live]]
56
56
  // Defaults: --ref HEAD, --out-dir dist, --version = platform CORE_VERSION.
57
+ // --from-worktree build from the files ON DISK instead of a commit, for a core checkout
58
+ // that carries no git history — which is exactly what the shipped
59
+ // self-host image is (.dockerignore excludes .git by design), and the
60
+ // only way the provisioning scaffold inside it can vendor a core into a
61
+ // child instance (task 1003995). Selection is unchanged (isPublishable);
62
+ // the artifact simply has no commit to anchor to, so source_commit is null
63
+ // and the tree_sha256 pin is the whole lineage. It packages what is ON DISK,
64
+ // which in the image is exactly what `COPY . .` put there — so on a DEV
65
+ // checkout prefer the ref build: measured on this repo the two select an
66
+ // IDENTICAL 2793-file set, but a Windows working tree hands back CRLF where
67
+ // the blob is LF, which changes every text file's hash and would ship a
68
+ // CRLF shebang. That is why rung 4 in provision-repo.js is reached only
69
+ // when there is no history to build from.
57
70
  // --self-verify after building, prove the artifact reproduces its pin (unpack the .tgz,
58
71
  // recompute tree_sha256 == manifest + verify tarball.sha256). Fatal on mismatch.
59
72
  // (task 1002218 / audit H3) — deterministic + network-free.
@@ -85,7 +98,7 @@ const REPO_ROOT = path.resolve(__dirname, '..', '..');
85
98
 
86
99
  // Reuse — never re-type. The core definition, the redaction, and the tree parser
87
100
  // all already exist and are unit-tested at their homes.
88
- const { isPublishable } = require(path.join(REPO_ROOT, 'scripts/gds/publish-manifest.js'));
101
+ const { isPublishable, PUBLISH_ALLOWLIST } = require(path.join(REPO_ROOT, 'scripts/gds/publish-manifest.js'));
89
102
  const {
90
103
  buildRedactionRules, collectSensitiveLiterals, findLeaks,
91
104
  } = require(path.join(REPO_ROOT, 'scripts/gds/mirror-redact.js'));
@@ -544,6 +557,47 @@ function buildTar(entries) {
544
557
  return zlib.gzipSync(tar, { level: 9 });
545
558
  }
546
559
 
560
+ // ---- the git-LESS source: enumerate the working tree (task 1003995) --------
561
+ //
562
+ // Everything below the enumeration step is already git-free, so the ONE thing that
563
+ // makes package-core unrunnable without history is `git ls-tree`. That matters because
564
+ // the shipped self-host image IS a core checkout with no `.git` (.dockerignore excludes
565
+ // it by design), and the provisioning scaffold inside it has no other way to build the
566
+ // tarball it vendors into a child instance — the fourth rung of the ladder in
567
+ // scripts/gds/provision-repo.js.
568
+ //
569
+ // The walk starts at PUBLISH_ALLOWLIST's own entries rather than the repo root. The
570
+ // allowlist is already the single source of truth for what the core is, so starting
571
+ // there means node_modules/ and dist/ are never descended into at all. Selection still
572
+ // runs through isPublishable() in main(), so the denylist applies exactly as it does on
573
+ // the git path — this function only decides what is OFFERED, never what is kept.
574
+ //
575
+ // Rows match parseLsTree's shape ({ path, type, mode }) minus `sha`: there is no object
576
+ // to name, so main() reads these blobs off disk instead. Mode is derived the way git
577
+ // derives it — the executable bit and nothing else. fs injectable for tests.
578
+ function walkWorktreeEntries(root, { allow = PUBLISH_ALLOWLIST, fsImpl = fs } = {}) {
579
+ const out = [];
580
+ const addFile = (rel) => {
581
+ let st;
582
+ try { st = fsImpl.statSync(path.join(root, rel)); } catch { return; } // absent here → simply not in the core set
583
+ if (st.isFile()) out.push({ path: rel, type: 'blob', mode: (st.mode & 0o111) ? '100755' : '100644' });
584
+ };
585
+ const walk = (rel) => {
586
+ let children;
587
+ try { children = fsImpl.readdirSync(path.join(root, rel), { withFileTypes: true }); } catch { return; }
588
+ for (const child of children) {
589
+ const childRel = `${rel}/${child.name}`;
590
+ if (child.isDirectory()) walk(childRel);
591
+ else if (child.isFile()) addFile(childRel);
592
+ }
593
+ };
594
+ for (const entry of allow) {
595
+ if (entry.endsWith('/')) walk(entry.replace(/\/$/, ''));
596
+ else addFile(entry);
597
+ }
598
+ return out.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
599
+ }
600
+
547
601
  // ---- git plumbing (impure) ------------------------------------------------
548
602
  function git(args) {
549
603
  return execFileSync('git', ['-C', REPO_ROOT, ...args], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
@@ -773,16 +827,22 @@ function selfVerify({ tgzPath, sidecar, outDir, boot }) {
773
827
  }
774
828
 
775
829
  function main() {
776
- const ref = arg('--ref', 'HEAD');
830
+ // --from-worktree: build from the files on disk instead of a commit (task 1003995).
831
+ // The lineage anchor of such a build is the tree hash alone — there is no commit to
832
+ // name — so source_commit is null and source_ref says where it came from.
833
+ const fromWorktree = process.argv.includes('--from-worktree');
834
+ const ref = fromWorktree ? '(worktree)' : arg('--ref', 'HEAD');
777
835
  const outDir = path.resolve(REPO_ROOT, arg('--out-dir', 'dist'));
778
836
  const version = arg('--version', coreVersion());
779
837
  const contract = coreVersion();
780
838
  const dropletIp = arg('--droplet-ip', process.env.DROPLET_IP || null);
781
839
 
782
840
  // 1. Resolve the source ref → commit SHA (the lineage anchor of this artifact).
783
- let sha;
784
- try { sha = git(['rev-parse', ref]).trim(); }
785
- catch (e) { console.error(`refusing: could not resolve --ref "${ref}": ${e.message}`); process.exit(2); }
841
+ let sha = null;
842
+ if (!fromWorktree) {
843
+ try { sha = git(['rev-parse', ref]).trim(); }
844
+ catch (e) { console.error(`refusing: could not resolve --ref "${ref}": ${e.message}`); process.exit(2); }
845
+ }
786
846
 
787
847
  // 2. Enumerate + partition the tree through the manifest (single source of truth).
788
848
  // package.json/package-lock.json are SYNTHESIZED (task 1882, ADR 0108 §2) —
@@ -790,7 +850,12 @@ function main() {
790
850
  // ships them verbatim), but the core package needs its OWN identity + a pruned
791
851
  // dependency set, not the game's. Pulled out of the generic per-file loop below.
792
852
  const SYNTHESIZED_PATHS = new Set(['package.json', 'package-lock.json']);
793
- const entries = parseLsTree(git(['ls-tree', '-r', sha])).filter((e) => e.type === 'blob');
853
+ const entries = fromWorktree
854
+ ? walkWorktreeEntries(REPO_ROOT)
855
+ : parseLsTree(git(['ls-tree', '-r', sha])).filter((e) => e.type === 'blob');
856
+ // A blob is named by its git object on the ref path and by its own path on the
857
+ // worktree path; everything downstream just wants the bytes.
858
+ const readBlob = (e) => (fromWorktree ? fs.readFileSync(path.join(REPO_ROOT, e.path)) : gitBuf(['cat-file', 'blob', e.sha]));
794
859
  const selected = entries.filter((e) => isPublishable(e.path) && !SYNTHESIZED_PATHS.has(e.path));
795
860
  // Drop npm-never-installed files (.gitignore, .npmignore, .npmrc) so the manifest +
796
861
  // tree_sha256 pin describe exactly what `npm install` materializes — otherwise the
@@ -798,7 +863,10 @@ function main() {
798
863
  // auto-rolls-back (idea 1000543). Done here, so they never reach the tarball or the pin.
799
864
  const npmStripped = selected.filter((e) => isNpmStripped(e.path));
800
865
  const publishable = selected.filter((e) => !isNpmStripped(e.path));
801
- console.error(`[package-core] ${ref} = ${sha.slice(0, 12)} — ${entries.length} files, ${publishable.length} in the core (+2 synthesized), ${entries.length - publishable.length - 2} excluded.`);
866
+ // The worktree walk is already allowlist-scoped and never offers the two synthesized
867
+ // paths, so only the ref path discounts them from what it enumerated.
868
+ const excludedCount = entries.length - selected.length - (fromWorktree ? 0 : SYNTHESIZED_PATHS.size);
869
+ console.error(`[package-core] ${ref}${sha ? ` = ${sha.slice(0, 12)}` : ''} — ${entries.length} files, ${publishable.length} in the core (+2 synthesized), ${excludedCount} excluded.`);
802
870
  if (npmStripped.length) {
803
871
  console.error(`[package-core] dropped ${npmStripped.length} npm-never-installed file(s) from the pin (npm strips these on install; idea 1000543): ${npmStripped.map((e) => e.path).join(', ')}`);
804
872
  }
@@ -811,14 +879,24 @@ function main() {
811
879
  // SOURCE files at this ref (never the live working tree, so --ref stays
812
880
  // reproducible) — express+pg only, name @bongos/core, version = the
813
881
  // platform version being packaged.
814
- const pkgJsonBlob = entries.find((e) => e.path === 'package.json');
815
- const pkgLockBlob = entries.find((e) => e.path === 'package-lock.json');
816
- if (!pkgJsonBlob || !pkgLockBlob) {
817
- console.error('refusing: source package.json/package-lock.json not found at this ref — cannot synthesize the core package.');
882
+ // On the worktree path there is no ref to stay reproducible against, so the two
883
+ // files come off disk beside everything else in the build.
884
+ const sourceRootFile = (rel) => {
885
+ if (fromWorktree) {
886
+ const abs = path.join(REPO_ROOT, rel);
887
+ return fs.existsSync(abs) ? fs.readFileSync(abs) : null;
888
+ }
889
+ const blob = entries.find((e) => e.path === rel);
890
+ return blob ? gitBuf(['cat-file', 'blob', blob.sha]) : null;
891
+ };
892
+ const pkgJsonRaw = sourceRootFile('package.json');
893
+ const pkgLockRaw = sourceRootFile('package-lock.json');
894
+ if (!pkgJsonRaw || !pkgLockRaw) {
895
+ console.error(`refusing: source package.json/package-lock.json not found at ${fromWorktree ? 'the repo root' : 'this ref'} — cannot synthesize the core package.`);
818
896
  process.exit(1);
819
897
  }
820
- const sourcePkgJson = JSON.parse(gitBuf(['cat-file', 'blob', pkgJsonBlob.sha]).toString('utf8'));
821
- const sourcePkgLock = JSON.parse(gitBuf(['cat-file', 'blob', pkgLockBlob.sha]).toString('utf8'));
898
+ const sourcePkgJson = JSON.parse(pkgJsonRaw.toString('utf8'));
899
+ const sourcePkgLock = JSON.parse(pkgLockRaw.toString('utf8'));
822
900
  const corePkgJson = buildPackageJson({ version, sourceDeps: sourcePkgJson.dependencies, sourceOverrides: sourcePkgJson.overrides });
823
901
  const corePkgLock = prunePackageLock(sourcePkgLock, {
824
902
  name: corePkgJson.name, version, rootRanges: { express: corePkgJson.dependencies.express, pg: corePkgJson.dependencies.pg },
@@ -865,7 +943,7 @@ function main() {
865
943
  let stubCount = 0; // agent docs (CLAUDE.md/AGENTS.md) replaced with the brand-free stub (task 2121)
866
944
  for (const e of publishable) {
867
945
  let raw;
868
- try { raw = gitBuf(['cat-file', 'blob', e.sha]); }
946
+ try { raw = readBlob(e); }
869
947
  catch (err) { leaks.push({ path: e.path, label: `read-failed:${err.message}` }); continue; }
870
948
  const { buf, leaks: fileLeaks, advisories: fileAdvisories, kind } =
871
949
  processCoreFile({ pathRel: e.path, raw, rules, sensitiveLiterals, envSecrets, knownDocNames });
@@ -955,7 +1033,7 @@ function main() {
955
1033
 
956
1034
  console.error('');
957
1035
  console.error(`[package-core] Cloud Bongos core v${version} packaged (contract ^${contract}).`);
958
- console.error(` source_commit ${sha}`);
1036
+ console.error(` source_commit ${sha || '(none — built from the working tree)'}`);
959
1037
  console.error(` file_count ${filesMeta.length}`);
960
1038
  console.error(` tree_sha256 ${treeHash}`);
961
1039
  console.error(` tarball ${path.relative(REPO_ROOT, tgzPath)} (${(tgz.length / 1024).toFixed(1)} KiB, sha256 ${sidecar.tarball.sha256.slice(0, 12)}…)`);
@@ -1059,6 +1137,8 @@ module.exports = {
1059
1137
  leakScanVerdict,
1060
1138
  // task 1002217 (audit H4) — the fixed neutral floor injected into the doc-redaction + fail-closed gate
1061
1139
  PRIOR_INSTANCE_FLOOR,
1140
+ // task 1003995 — --from-worktree's enumerator, for a core checkout with no git history
1141
+ walkWorktreeEntries,
1062
1142
  };
1063
1143
 
1064
1144
  if (require.main === module) main();
@@ -399,7 +399,17 @@ function installedCorePackDir({ instanceRoot, fsImpl = fs } = {}) {
399
399
  return null;
400
400
  }
401
401
 
402
- // Resolve a vendorable @bongos/core tarball — the three-rung ladder, freshest-correct
402
+ // Can package-core.js enumerate this checkout from GIT? It builds the core set from
403
+ // `git ls-tree` at a ref, so a checkout with no `.git` aborts at `git rev-parse HEAD` —
404
+ // and that is not a broken install, it is the SHIPPED SELF-HOST IMAGE: .dockerignore
405
+ // excludes .git by design, so /app is a complete core source tree with no history
406
+ // (task 1003995). The presence of `.git` — a directory in a clone, a file in a linked
407
+ // worktree — is the whole question. fs injectable for tests; read-only → dry-run safe.
408
+ function coreCheckoutHasGit({ repoRoot = REPO_ROOT, fsImpl = fs } = {}) {
409
+ return fsImpl.existsSync(path.join(repoRoot, '.git'));
410
+ }
411
+
412
+ // Resolve a vendorable @bongos/core tarball — the four-rung ladder, freshest-correct
403
413
  // first, shared by the fresh scaffold and the re-provision pin refresh (task 1003050):
404
414
  // 1. a `file:`-pinned control plane reuses its own pinned tarball (task 1002275 —
405
415
  // rebuilding via package-core.js aborts with an EMPTY core set when this runner
@@ -408,31 +418,37 @@ function installedCorePackDir({ instanceRoot, fsImpl = fs } = {}) {
408
418
  // it has INSTALLED — the child pins the SAME, CURRENT core the hub runs, ending
409
419
  // the frozen-old-tarball births (task 1002706, gap 13) without requiring the
410
420
  // child's owner to hold a token for the still-private registry package;
411
- // 3. a genuine core source checkout rebuilds fresh via package-core.js.
421
+ // 3. a genuine core source checkout rebuilds fresh via package-core.js;
422
+ // 4. a core checkout with NO git history — the self-host image — packs its working
423
+ // tree via package-core.js --from-worktree (task 1003995). LAST because it is the
424
+ // only rung with no commit to anchor the artifact to: whenever history is there,
425
+ // rung 3's reproducible build is the better answer for the identical file set.
412
426
  // Returns { tgz, packDest } — packDest (set only on rung 2) is a temp dir the CALLER
413
427
  // must `rm -rf` once the tarball has been vendored.
414
- function resolveVendorableCoreTarball({ instanceRoot, exec, log, coreV, tag = '[core]' }) {
415
- let tgz = installedCoreTarball({ instanceRoot });
416
- let packDest = null;
417
- if (tgz) {
418
- log(` ${tag} reusing the pinned core tarball this control plane runs (${path.basename(tgz)}) — no source rebuild (task 1002275)`);
428
+ function resolveVendorableCoreTarball({ instanceRoot, repoRoot = REPO_ROOT, exec, log, coreV, tag = '[core]' }) {
429
+ const pinned = installedCoreTarball({ instanceRoot });
430
+ if (pinned) {
431
+ log(` ${tag} reusing the pinned core tarball this control plane runs (${path.basename(pinned)}) — no source rebuild (task 1002275)`);
432
+ return { tgz: pinned, packDest: null };
433
+ }
434
+ const packSrc = installedCorePackDir({ instanceRoot });
435
+ if (packSrc) {
436
+ // Keyed by VERSION, not slug: no request-derived value enters this command, and
437
+ // two concurrent scaffolds of the same core pack identical bytes — collision-safe.
438
+ const packDest = path.join(os.tmpdir(), `bongos-core-pack-${packSrc.version}`);
439
+ log(` ${tag} packing the registry-installed core this control plane runs (v${packSrc.version}) — no source rebuild (task 1002706)`);
440
+ exec(`mkdir -p ${packDest}`);
441
+ exec(`npm pack ${packSrc.dir} --pack-destination ${packDest}`);
442
+ return { tgz: path.join(packDest, packSrc.tarballName), packDest };
443
+ }
444
+ if (coreCheckoutHasGit({ repoRoot })) {
445
+ log(` ${tag} building a fresh vendored tarball from source (package-core.js)`);
446
+ exec(`node scripts/gds/package-core.js`); // cwd = REPO_ROOT → dist/bongos-core-<v>.tgz
419
447
  } else {
420
- const packSrc = installedCorePackDir({ instanceRoot });
421
- if (packSrc) {
422
- // Keyed by VERSION, not slug: no request-derived value enters this command, and
423
- // two concurrent scaffolds of the same core pack identical bytes — collision-safe.
424
- packDest = path.join(os.tmpdir(), `bongos-core-pack-${packSrc.version}`);
425
- log(` ${tag} packing the registry-installed core this control plane runs (v${packSrc.version}) — no source rebuild (task 1002706)`);
426
- exec(`mkdir -p ${packDest}`);
427
- exec(`npm pack ${packSrc.dir} --pack-destination ${packDest}`);
428
- tgz = path.join(packDest, packSrc.tarballName);
429
- } else {
430
- log(` ${tag} building a fresh vendored tarball from source (package-core.js)`);
431
- exec(`node scripts/gds/package-core.js`); // cwd = REPO_ROOT → dist/bongos-core-<v>.tgz
432
- tgz = path.join(REPO_ROOT, 'dist', `bongos-core-${coreV}.tgz`);
433
- }
448
+ log(` ${tag} this checkout IS the core and carries no git history — packing the working tree (package-core.js --from-worktree, task 1003995)`);
449
+ exec(`node scripts/gds/package-core.js --from-worktree`);
434
450
  }
435
- return { tgz, packDest };
451
+ return { tgz: path.join(repoRoot, 'dist', `bongos-core-${coreV}.tgz`), packDest: null };
436
452
  }
437
453
 
438
454
  // The onboard mode a provisioning row carries (migration provisioning_004, task 1002562).
@@ -633,7 +649,7 @@ async function scaffoldStandaloneRepo(inst, deps) {
633
649
  const spec = instanceInitSpec(inst, { ownerLogin });
634
650
  const specPath = path.join(os.tmpdir(), `bongos-init-${inst.slug}.json`);
635
651
  writeFile(specPath, JSON.stringify(spec, null, 2));
636
- // Vendored tarball — resolveVendorableCoreTarball's three-rung ladder (shared
652
+ // Vendored tarball — resolveVendorableCoreTarball's four-rung ladder (shared
637
653
  // with the re-provision pin refresh, task 1003050).
638
654
  const { tgz, packDest } = resolveVendorableCoreTarball({
639
655
  instanceRoot: deps.instanceRoot, exec, log, coreV, tag: '[scaffold] core install:',
@@ -1007,6 +1023,7 @@ module.exports = {
1007
1023
  ownerLoginOf,
1008
1024
  asPostgres,
1009
1025
  buildCorePinRefreshCommit,
1026
+ coreCheckoutHasGit,
1010
1027
  dbCreateCmd,
1011
1028
  dbName,
1012
1029
  dbRoleCmd,
@@ -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, dbRoleCmd, dbRoleCmdShown, dbRoleGrantsCmd, ensureInstanceUserCmd, generateDbPassword, grantInstanceRepoReadCmd, instanceDbRole, instanceStateDir, instanceUser, 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');
53
+ const { APP_USER, alreadyScaffolded, buildCorePinRefreshCommit, coreCheckoutHasGit, dbCreateCmd, dbName, dbRoleCmd, dbRoleCmdShown, dbRoleGrantsCmd, ensureInstanceUserCmd, generateDbPassword, grantInstanceRepoReadCmd, instanceDbRole, instanceStateDir, instanceUser, 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, instanceManifestCmd, originEnvVarsFor, serviceUnit, serviceUnitPath, settingsConsumed, settingsEnvVarsFor, upsertEnvVars, webEnvBody, webEnvPath } = require('./provision-units.js');
55
55
  const { caddyBlock, caddySnippetPath, checkCaddyWiring, checkDnsTokenScope, classifyZoneScope, dnsReleaseEnv, dnsUpsertEnv, federateInstance, federationHubOrigin, healthzCmd, identityCmd, identityVerdict, shouldFederate, zoneForDomain } = require('./provision-net.js');
56
56
  const { capacityPreflight, statusCapacityLine } = require('./provision-capacity.js');
@@ -1457,6 +1457,8 @@ module.exports = {
1457
1457
  parseTargetRef, instanceRepoRemote, instanceInitSpec, installedCoreTarball, installedCorePackDir, scaffoldStandaloneRepo, coreVersionSafe,
1458
1458
  // re-provision core-pin refresh (gap-list W3, task 1003050)
1459
1459
  resolveVendorableCoreTarball, planCorePinRefresh, safeVersionLabel, buildCorePinRefreshCommit, refreshStandaloneCorePin,
1460
+ // the git-less core checkout — the self-host image's rung (task 1003995)
1461
+ coreCheckoutHasGit,
1460
1462
  // adopt vs greenfield onboarding (ADR 0121, task 1002562)
1461
1463
  onboardMode, alreadyScaffolded,
1462
1464
  // private-repo deploy key (ADR 0176, task 1002735)
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.847'; // CI auto-patch carrier (ADR 0161); changelog: docs/module-api-changelog.md
74
+ const CORE_VERSION = '1.19.848'; // 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');
@@ -42,8 +42,11 @@ const {
42
42
  scanArtifactForLeaks, PRIOR_INSTANCE_LITERALS,
43
43
  // task 1002217 (audit H4) — the fixed neutral floor
44
44
  PRIOR_INSTANCE_FLOOR,
45
+ // task 1003995 — --from-worktree's enumerator, for a core checkout with no git history
46
+ walkWorktreeEntries,
45
47
  } = m;
46
48
  const { buildRedactionRules, collectSensitiveLiterals, redactText, findLeaks } = require('../scripts/gds/mirror-redact.js');
49
+ const { isPublishable } = require('../scripts/gds/publish-manifest.js');
47
50
 
48
51
  // A synthetic instance brand for the classification tests (never the real OTB literals).
49
52
  const TEST_BRANDING = {
@@ -747,5 +750,67 @@ t('idea 1000543 (the fix): the isNpmStripped filter makes the pin reproduce agai
747
750
  } finally { rmSync(root, { recursive: true, force: true }); }
748
751
  });
749
752
 
753
+ // ── --from-worktree: the git-less enumeration (task 1003995) ─────────────────────
754
+ // package-core builds the core set from `git ls-tree`, so a core checkout with no .git —
755
+ // the shipped self-host image, where .dockerignore excludes it by design — cannot build
756
+ // the tarball its provisioning scaffold vendors into a child instance. walkWorktreeEntries
757
+ // is the replacement source. It decides only what is OFFERED; isPublishable still decides
758
+ // what is KEPT, so the core set stays defined in exactly one place.
759
+ function worktreeFixture() {
760
+ const root = mkdtempSync(join(tmpdir(), 'wt-core-'));
761
+ const put = (rel, body = 'x') => {
762
+ mkdirSync(join(root, dirname(rel)), { recursive: true });
763
+ writeFileSync(join(root, rel), body);
764
+ };
765
+ put('src/module-api.js');
766
+ put('src/bongos/tasks.js'); // nested, to prove the walk recurses
767
+ put('scripts/gds/package-core.js');
768
+ put('CLAUDE.md'); // an allowlisted FILE entry, not a subtree
769
+ put('node_modules/@bongos/core/index.js'); // huge + never core: must never be descended
770
+ put('dist/bongos-core-1.0.0.tgz'); // this tool's own output
771
+ put('config/branding.json'); // instance identity: outside every allowlist root
772
+ return { root, cleanup: () => rmSync(root, { recursive: true, force: true }) };
773
+ }
774
+
775
+ t('walkWorktreeEntries: offers the allowlisted tree and never descends node_modules/ or dist/', () => {
776
+ const { root, cleanup } = worktreeFixture();
777
+ try {
778
+ const paths = walkWorktreeEntries(root).map((e) => e.path);
779
+ assert.deepEqual(
780
+ paths,
781
+ ['CLAUDE.md', 'scripts/gds/package-core.js', 'src/bongos/tasks.js', 'src/module-api.js'],
782
+ `unexpected set: ${paths.join(', ')}`,
783
+ );
784
+ assert.ok(!paths.some((p) => p.startsWith('node_modules/')), 'node_modules is never walked');
785
+ assert.ok(!paths.some((p) => p.startsWith('dist/')), 'the packager never re-enumerates its own output');
786
+ assert.ok(!paths.includes('config/branding.json'), 'instance identity is outside every allowlist root');
787
+ } finally { cleanup(); }
788
+ });
789
+
790
+ t('walkWorktreeEntries: rows match the git-tree shape — sorted blobs carrying a mode', () => {
791
+ const { root, cleanup } = worktreeFixture();
792
+ try {
793
+ const entries = walkWorktreeEntries(root);
794
+ assert.deepEqual([...entries].sort((a, b) => (a.path < b.path ? -1 : 1)), entries, 'sorted, so the pin is stable');
795
+ for (const e of entries) {
796
+ assert.equal(e.type, 'blob', 'only files, matching the ls-tree filter main() applies');
797
+ assert.ok(['100644', '100755'].includes(e.mode), `mode must be a git file mode, got ${e.mode}`);
798
+ }
799
+ } finally { cleanup(); }
800
+ });
801
+
802
+ t('walkWorktreeEntries: a DENIED path inside an allowlisted subtree is still offered — the denylist is main()’s job, not the walk’s', () => {
803
+ const { root, cleanup } = worktreeFixture();
804
+ try {
805
+ // A host-feature script lives under the allowlisted scripts/ root and is denied by name.
806
+ // If the walk pre-filtered it, the two enumeration paths would be applying different rules.
807
+ const denied = 'scripts/gds/art-stage.js';
808
+ writeFileSync(join(root, denied), 'x');
809
+ const offered = walkWorktreeEntries(root).map((e) => e.path);
810
+ assert.ok(offered.includes(denied), 'the walk offers it…');
811
+ assert.equal(isPublishable(denied), false, '…and isPublishable is what drops it');
812
+ } finally { cleanup(); }
813
+ });
814
+
750
815
  console.log(`\n${passed} passed, ${failed} failed`);
751
816
  process.exit(failed ? 1 : 0);
@@ -816,6 +816,78 @@ t('installedCorePackDir: a registry-pinned consumer with an installed core → i
816
816
  [reg, filePinned, uninstalled, bare2, alt2].forEach((d) => rmSync(d, { recursive: true, force: true }));
817
817
  });
818
818
 
819
+ // ── the git-less core checkout: rung 4 (task 1003995) ────────────────────────────
820
+ // The shipped self-host image is a complete core source tree with NO .git (.dockerignore
821
+ // excludes it by design), so package-core.js's `git ls-tree` enumeration has nothing to
822
+ // read and the scaffold inside the container could never build the tarball it vendors
823
+ // into a child. Rung 4 packs the working tree instead.
824
+ t('coreCheckoutHasGit: a clone (.git dir) and a linked worktree (.git file) both have history; the image does not', () => {
825
+ const clone = mkdtempSync(join(tmpdir(), 'cchg-clone-'));
826
+ mkdirSync(join(clone, '.git'));
827
+ assert.equal(P.coreCheckoutHasGit({ repoRoot: clone }), true, 'a clone carries a .git DIRECTORY');
828
+
829
+ // A linked worktree's .git is a FILE pointing at the real gitdir — every claim in this
830
+ // project is worked in one, so treating it as history-less would take the wrong rung on
831
+ // the machine that runs these tests.
832
+ const wt = mkdtempSync(join(tmpdir(), 'cchg-worktree-'));
833
+ writeFileSync(join(wt, '.git'), 'gitdir: /somewhere/.git/worktrees/task-1\n');
834
+ assert.equal(P.coreCheckoutHasGit({ repoRoot: wt }), true, 'a linked worktree carries a .git FILE');
835
+
836
+ const image = mkdtempSync(join(tmpdir(), 'cchg-image-'));
837
+ assert.equal(P.coreCheckoutHasGit({ repoRoot: image }), false, 'the self-host image has no .git at all');
838
+
839
+ [clone, wt, image].forEach((d) => rmSync(d, { recursive: true, force: true }));
840
+ });
841
+
842
+ t('resolveVendorableCoreTarball: the ladder picks file: pin → registry pack → git source → worktree, in that order', () => {
843
+ // One helper per rung so the ONLY thing varying between cases is which shape the
844
+ // control-plane root presents. Asserting on the recorded commands is what proves the
845
+ // ORDER: a rung that fires early leaves the later rung's command unrun.
846
+ const run = (instanceRoot, repoRoot) => {
847
+ const cmds = [];
848
+ const res = P.resolveVendorableCoreTarball({
849
+ instanceRoot, repoRoot, exec: (c) => { cmds.push(c); }, log: () => {}, coreV: '9.9.9',
850
+ });
851
+ return { cmds, ...res };
852
+ };
853
+ const gitRoot = mkdtempSync(join(tmpdir(), 'rvct-git-'));
854
+ mkdirSync(join(gitRoot, '.git'));
855
+ const bareRoot = mkdtempSync(join(tmpdir(), 'rvct-bare-')); // no .git → the image shape
856
+
857
+ // Rung 1 — a file: pin wins even from a git-less root: nothing is rebuilt at all.
858
+ const filePinned = mkdtempSync(join(tmpdir(), 'rvct-file-'));
859
+ mkdirSync(join(filePinned, 'vendor'));
860
+ writeFileSync(join(filePinned, 'vendor', 'bongos-core-1.2.3.tgz'), 'x');
861
+ writeFileSync(join(filePinned, 'package.json'), JSON.stringify({ dependencies: { '@bongos/core': 'file:vendor/bongos-core-1.2.3.tgz' } }));
862
+ const r1 = run(filePinned, bareRoot);
863
+ assert.equal(r1.tgz, join(filePinned, 'vendor', 'bongos-core-1.2.3.tgz'));
864
+ assert.deepEqual(r1.cmds, [], 'rung 1 runs no command — it reuses bytes already on disk');
865
+
866
+ // Rung 2 — a registry-installed core packs, still without touching package-core.js.
867
+ const reg = mkdtempSync(join(tmpdir(), 'rvct-reg-'));
868
+ mkdirSync(join(reg, 'node_modules', '@bongos', 'core'), { recursive: true });
869
+ writeFileSync(join(reg, 'node_modules', '@bongos', 'core', 'package.json'), JSON.stringify({ name: '@bongos/core', version: '1.19.56' }));
870
+ writeFileSync(join(reg, 'package.json'), JSON.stringify({ dependencies: { '@bongos/core': '1.19.56' } }));
871
+ const r2 = run(reg, bareRoot);
872
+ assert.ok(r2.cmds.some((c) => c.startsWith('npm pack ')), 'rung 2 packs the installed core');
873
+ assert.ok(!r2.cmds.some((c) => /package-core\.js/.test(c)), 'rung 2 never reaches package-core.js');
874
+ assert.ok(r2.packDest, 'rung 2 returns the temp pack dir for the caller to clean up');
875
+
876
+ // Rung 3 — a source checkout WITH history rebuilds reproducibly from the ref.
877
+ const source = mkdtempSync(join(tmpdir(), 'rvct-src-'));
878
+ const r3 = run(source, gitRoot);
879
+ assert.deepEqual(r3.cmds, ['node scripts/gds/package-core.js'], 'history present → the ref build, NOT --from-worktree');
880
+ assert.equal(r3.tgz, join(gitRoot, 'dist', 'bongos-core-9.9.9.tgz'));
881
+ assert.equal(r3.packDest, null);
882
+
883
+ // Rung 4 — the same source checkout with its history stripped: the self-host image.
884
+ const r4 = run(source, bareRoot);
885
+ assert.deepEqual(r4.cmds, ['node scripts/gds/package-core.js --from-worktree'], 'no history → pack the working tree');
886
+ assert.equal(r4.tgz, join(bareRoot, 'dist', 'bongos-core-9.9.9.tgz'), 'the child still pins the running CORE_VERSION');
887
+
888
+ [gitRoot, bareRoot, filePinned, reg, source].forEach((d) => rmSync(d, { recursive: true, force: true }));
889
+ });
890
+
819
891
  await ta('scaffoldStandaloneRepo: a REGISTRY-pinned consumer control plane PACKS its installed core — current version, no source rebuild (task 1002706)', async () => {
820
892
  const cp = mkdtempSync(join(tmpdir(), 'cpdir-cp-'));
821
893
  mkdirSync(join(cp, 'node_modules', '@bongos', 'core'), { recursive: true });