@bongos/core 1.19.409 → 1.19.411

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.
Files changed (37) hide show
  1. package/.bongos-core.json +56 -41
  2. package/clients/bongos-client/README.md +1 -1
  3. package/clients/bongos-client/bongos-client.global.js +4 -0
  4. package/clients/bongos-client/index.cjs +4 -0
  5. package/clients/bongos-client/index.d.ts +5 -0
  6. package/clients/bongos-client/index.mjs +4 -0
  7. package/docs/adr/0203-doorway-changelog-out-of-module-api.md +54 -0
  8. package/docs/adr/README.md +1 -0
  9. package/docs/api/openapi.json +122 -3
  10. package/docs/api-reference.md +4 -2
  11. package/docs/copy-inventory.md +43 -36
  12. package/docs/copy-registry.json +122 -39
  13. package/docs/file-map.md +2 -1
  14. package/docs/module-api-changelog.md +1263 -0
  15. package/docs/modules-contract.md +2 -0
  16. package/docs/recipes/core-release-pipeline.md +3 -3
  17. package/docs/recipes/private-npm-distribution.md +1 -1
  18. package/migrations/core_229_goals_accepting_requests.sql +37 -0
  19. package/modules/dev-box/app/src/vendor/bongos-client.cjs +4 -0
  20. package/modules/hall-ui/public/goals-page.js +26 -2
  21. package/modules/hall-ui/public/goals-render.js +35 -0
  22. package/modules/lifecycle/db-goals.js +22 -1
  23. package/modules/lifecycle/db.js +4 -1
  24. package/modules/lifecycle/goal-edits.js +40 -0
  25. package/modules/lifecycle/routes/goal-route-authz.js +51 -1
  26. package/modules/lifecycle/routes/goals.js +46 -1
  27. package/package-lock.json +2 -2
  28. package/package.json +1 -1
  29. package/scripts/gds/bump-version.js +53 -25
  30. package/scripts/gds/deploy-divergence.js +1 -1
  31. package/scripts/gds/publish-manifest.js +6 -0
  32. package/src/bongos/module-scope-map.js +6 -1
  33. package/src/bongos/route-rank-check.js +6 -0
  34. package/src/module-api.js +10 -1227
  35. package/tests/bump_version.mjs +72 -13
  36. package/tests/goal_membership_requests.mjs +154 -1
  37. package/tests/prose_edits.mjs +8 -4
@@ -4,10 +4,19 @@
4
4
  //
5
5
  // WHY THIS EXISTS. ADR 0161 makes every merge to main publishable: when a merge
6
6
  // lands without a human version bump, CI bumps a PATCH itself so the release
7
- // has a unique version. The bump edits src/module-api.js in the two places the
8
- // repo's version discipline lives — the `const CORE_VERSION` literal and the
9
- // changelog comment block above it — because a bare literal change with no
10
- // changelog line is exactly the drift the discipline exists to prevent.
7
+ // has a unique version. The bump writes the two places the repo's version
8
+ // discipline lives — the `const CORE_VERSION` literal in src/module-api.js and
9
+ // the release ledger in docs/module-api-changelog.md — because a bare literal
10
+ // change with no changelog line is exactly the drift the discipline prevents.
11
+ //
12
+ // WHERE THE LEDGER LIVES (ADR 0203). It used to be a comment block directly
13
+ // above the literal, in src/module-api.js. Appending two lines there on EVERY
14
+ // release grew that file past the 1500-line oversized-file fitness ratchet, and
15
+ // because this lane pushes straight to main it broke the very `unit` gate it
16
+ // rides behind — for main and for every open PR at once. The ledger is now a
17
+ // markdown file, which `git ls-files '*.js'` never counts, so it can grow
18
+ // forever. The INSERTION CONTRACT is unchanged: entries stay oldest-first and
19
+ // each new one goes immediately above the divider that closes the ledger.
11
20
  //
12
21
  // POLICY (deliberately narrow): this script only ever bumps PATCH. A MINOR or
13
22
  // MAJOR is a statement about the doorway surface that only a human (or a far
@@ -19,7 +28,7 @@
19
28
  //
20
29
  // Usage:
21
30
  // node scripts/gds/bump-version.js # dry-run: print the plan
22
- // node scripts/gds/bump-version.js --apply # rewrite src/module-api.js
31
+ // node scripts/gds/bump-version.js --apply # rewrite both files
23
32
  // node scripts/gds/bump-version.js --apply --note "run 123456" # extra provenance
24
33
  // stdout (both modes): one JSON line { from, to, applied } for CI to capture.
25
34
 
@@ -29,35 +38,45 @@ const fs = require('node:fs');
29
38
  const path = require('node:path');
30
39
 
31
40
  const TARGET = path.join(__dirname, '..', '..', 'src', 'module-api.js');
41
+ // The release ledger (ADR 0203) — markdown, so the .js line ratchet never counts it.
42
+ const CHANGELOG = path.join(__dirname, '..', '..', 'docs', 'module-api-changelog.md');
32
43
  const CONST_RE = /^const CORE_VERSION = '(\d+)\.(\d+)\.(\d+)';.*$/m;
33
- // The changelog block's closing divider sits immediately above the const line.
34
- const DIVIDER = '// ---------------------------------------------------------------------------';
44
+ // The ledger's closing divider — the last line inside its fenced block, and the
45
+ // insertion anchor each new entry goes immediately above. Same 75-dash rule the
46
+ // comment block used, minus the `// ` that made it a JS comment.
47
+ const DIVIDER = '---------------------------------------------------------------------------';
35
48
 
36
- // Pure transform: (source text, optional note) -> { from, to, text }.
49
+ // Pure transform: (module-api source, { note, changelog }) -> { from, to, text,
50
+ // changelogText }. Pass the ledger's current text as `changelog` to get the
51
+ // entry appended too; omit it to bump the literal alone (the unit tests do).
37
52
  // Throws with a precise message on any shape it does not recognize — a silent
38
53
  // mis-edit of the version literal is the worst possible failure mode here.
39
- function bumpPatch(src, { note = '' } = {}) {
54
+ function bumpPatch(src, { note = '', changelog = null } = {}) {
40
55
  const m = src.match(CONST_RE);
41
56
  if (!m) throw new Error(`bump-version: could not find the CORE_VERSION literal in ${TARGET} (expected: const CORE_VERSION = 'x.y.z';)`);
42
57
  const [major, minor, patch] = [Number(m[1]), Number(m[2]), Number(m[3])];
43
58
  const from = `${major}.${minor}.${patch}`;
44
59
  const to = `${major}.${minor}.${patch + 1}`;
45
60
 
46
- // 1. The changelog entry — inserted just above the divider that closes the
47
- // changelog block, matching the existing two-line entry style.
48
- const constLineStart = src.search(CONST_RE);
49
- const dividerStart = src.lastIndexOf(DIVIDER, constLineStart);
50
- if (dividerStart === -1) throw new Error('bump-version: could not find the changelog closing divider above CORE_VERSION');
51
- const noteSuffix = note ? ` ${note}.` : '';
52
- const entry =
53
- `// ${to} — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges\n` +
54
- `// landed since ${from} with no explicit bump.${noteSuffix} (task 1002620)\n`;
61
+ // 1. The literal — same line shape deploy-divergence greps for.
62
+ const newConstLine = `const CORE_VERSION = '${to}'; // CI auto-patch carrier (ADR 0161); changelog: docs/module-api-changelog.md`;
63
+ const text = src.replace(CONST_RE, newConstLine);
55
64
 
56
- // 2. The literal — same line shape deploy-divergence greps for.
57
- const newConstLine = `const CORE_VERSION = '${to}'; // CI auto-patch carrier (ADR 0161); see changelog above`;
65
+ // 2. The ledger entry — inserted just above the divider that closes the
66
+ // ledger, keeping the historic two-line entry style byte-for-byte (the
67
+ // old `// ` / `// ` comment prefixes minus the `// ` marker).
68
+ let changelogText = null;
69
+ if (changelog !== null) {
70
+ const dividerStart = changelog.lastIndexOf(DIVIDER);
71
+ if (dividerStart === -1) throw new Error(`bump-version: could not find the changelog closing divider in ${CHANGELOG} — the ledger's insertion anchor is gone (ADR 0203)`);
72
+ const noteSuffix = note ? ` ${note}.` : '';
73
+ const entry =
74
+ ` ${to} — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges\n` +
75
+ ` landed since ${from} with no explicit bump.${noteSuffix} (task 1002620)\n`;
76
+ changelogText = changelog.slice(0, dividerStart) + entry + changelog.slice(dividerStart);
77
+ }
58
78
 
59
- const text = src.slice(0, dividerStart) + entry + src.slice(dividerStart).replace(CONST_RE, newConstLine);
60
- return { from, to, text };
79
+ return { from, to, text, changelogText };
61
80
  }
62
81
 
63
82
  function main() {
@@ -65,10 +84,19 @@ function main() {
65
84
  const noteIdx = process.argv.indexOf('--note');
66
85
  const note = noteIdx !== -1 ? (process.argv[noteIdx + 1] || '') : '';
67
86
 
87
+ // Read and transform BOTH files before writing EITHER: a half-applied bump
88
+ // (literal moved, ledger silent) is precisely the drift this script exists
89
+ // to prevent, and it would be committed and pushed to main before anyone saw it.
68
90
  const src = fs.readFileSync(TARGET, 'utf8');
69
- const { from, to, text } = bumpPatch(src, { note });
70
- if (apply) fs.writeFileSync(TARGET, text);
71
- else console.error(`bump-version: would bump ${from} → ${to} (dry-run; pass --apply to write)`);
91
+ const changelog = fs.readFileSync(CHANGELOG, 'utf8');
92
+ const { from, to, text, changelogText } = bumpPatch(src, { note, changelog });
93
+ if (changelogText === null) throw new Error('bump-version: the ledger was not rewritten — refusing to write a versionless release');
94
+ if (apply) {
95
+ fs.writeFileSync(TARGET, text);
96
+ fs.writeFileSync(CHANGELOG, changelogText);
97
+ } else {
98
+ console.error(`bump-version: would bump ${from} → ${to} in ${TARGET} + ${CHANGELOG} (dry-run; pass --apply to write)`);
99
+ }
72
100
  console.log(JSON.stringify({ from, to, applied: apply }));
73
101
  }
74
102
 
@@ -246,7 +246,7 @@ function report(r, { quiet = false } = {}) {
246
246
  ? ` (${u.countWithMerges} counting merges)` : '';
247
247
  say(` ⚠ UNRELEASED — ${u.count} work commit${u.count === 1 ? '' : 's'}${merges} on ${r.mainRef} since the last CORE_VERSION bump.`);
248
248
  say(' No instance can take these at ANY pin: no published version contains them.');
249
- say(` Fix: bump CORE_VERSION in src/module-api.js (+ a changelog line) and land it.`);
249
+ say(` Fix: bump CORE_VERSION in src/module-api.js (+ an entry in docs/module-api-changelog.md) and land it.`);
250
250
  }
251
251
  if (r.behind) {
252
252
  say(` ⚠ UNDEPLOYED — live is ${r.live.coreVersion}, main declares ${r.onMain}.`);
@@ -104,6 +104,12 @@ const PUBLISH_ALLOWLIST = [
104
104
  'docs/api/openapi.json', // the generated OpenAPI 3.1 spec served at /docs/openapi.json
105
105
  'docs/api-reference.md', // the markdown API reference
106
106
  'docs/modules-contract.md',
107
+ // The doorway's release ledger (ADR 0203). It USED TO ship inside
108
+ // src/module-api.js as a comment block, so an instance that installs
109
+ // @bongos/core has always received it; omitting it here would silently drop
110
+ // the history from the package at the next release. A module author checking
111
+ // what a `coreVersion` floor actually buys them reads exactly this file.
112
+ 'docs/module-api-changelog.md',
107
113
  'docs/branding-contract.md',
108
114
  'docs/branding-fill-prompt.md',
109
115
  // RUNTIME DATA that happens to live under docs/, not documentation (ADR 0178).
@@ -52,7 +52,12 @@ const MODULE_GLOBS = {
52
52
  'src/bongos/repo-info.js', 'src/bongos/api-path-404.js', 'src/bongos/serve-internal.js',
53
53
  'src/bongos/module-scope-map.js', 'src/bongos/hierarchy-config.js',
54
54
  'src/instance-config.js', 'src/branding.js', 'src/modules.js',
55
- 'src/module-api.js', 'src/module-loader/',
55
+ // The doorway and its release ledger travel together: since ADR 0203 the
56
+ // CORE_VERSION changelog is a separate markdown file, so a kernel-scoped
57
+ // goal authoring a version bump touches BOTH. Enumerated like copy-desk's
58
+ // docs/ artifacts below — without it, scopeSubset() denies the ledger as
59
+ // out_of_scope and a hand-cut MINOR/MAJOR cannot be authored at all.
60
+ 'src/module-api.js', 'docs/module-api-changelog.md', 'src/module-loader/',
56
61
  // security-the-PROPERTY: the threat-model (/security/adr) + Archon-only
57
62
  // exploit-detail engagement-doc store (/security/docs). Stays kernel when the
58
63
  // red-team FEATURE carved to modules/security/ (BV1.R79 / 02-module-map §5).
@@ -391,6 +391,12 @@ const MODULE_EXPECTED_RANKS = {
391
391
  // (authorizeWithdrawJoinRequest).
392
392
  'GET /goals/:id/requests': 'any-builder',
393
393
  'POST /goals/:id/requests/:reqId/withdraw': 'any-builder',
394
+ // task 1002971 (spec D6): the private-goal open/closed-to-requests toggle and
395
+ // the manager-side rescind of a pending invitation. Both walls are in-handler
396
+ // (authorizeGoalManagement / authorizeRescindInvitation), so both stay
397
+ // 'any-builder' — pinned so an accidental requireRank re-gate reds the build.
398
+ 'PATCH /goals/:id/accepting-requests': 'any-builder',
399
+ 'POST /goals/:id/invitations/:reqId/rescind': 'any-builder',
394
400
  // criterion confirmation + goal auto-achieve (ADR 0086 §6) — the planner's close loop.
395
401
  'POST /done-when/:criterionId/satisfy': 'metic+archon',
396
402
  // runtime criterion create (ADR 0105 gap fix, task 1874) — re-ranked Archon→Metic+