@bongos/core 1.19.452 → 1.19.453

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.452",
6
- "core_contract": "1.19.452",
7
- "source_commit": "a59941e00bdc972cede45d82263d6bb9a334d59d",
5
+ "core_version": "1.19.453",
6
+ "core_contract": "1.19.453",
7
+ "source_commit": "d608d7888d16f919cc2775428848dcfff82d333b",
8
8
  "source_ref": "HEAD",
9
- "built_at": "2026-09-01T19:56:39.788Z",
9
+ "built_at": "2026-09-01T20:06:17.187Z",
10
10
  "redaction": {
11
11
  "model": "docs-redacted+functional-verbatim",
12
12
  "docs_redacted": 371,
13
13
  "agent_docs_stubbed": 24,
14
- "functional_verbatim": 1788,
14
+ "functional_verbatim": 1789,
15
15
  "rules": 3,
16
16
  "gate_literals": 3,
17
17
  "gate": "passed"
18
18
  },
19
- "file_count": 2183,
20
- "tree_sha256": "d6e755d26822b3fbb320367835d28cb2e6e317309a6da4985730541e202fec63",
19
+ "file_count": 2184,
20
+ "tree_sha256": "b32b4f4ed373293772fa27594b928449ab80778248125d70b8401f71e0b34ac3",
21
21
  "files": [
22
22
  {
23
23
  "path": ".claude/skills/blocker-review/SKILL.md",
@@ -2092,7 +2092,7 @@
2092
2092
  {
2093
2093
  "path": "docs/module-api-changelog.md",
2094
2094
  "mode": "0000644",
2095
- "sha256": "1b44d9a28067aee44f6461a6ec2ff31dcbcd1d92aba9b5e5d53ac97dcb782cbe"
2095
+ "sha256": "9626b5a975e660041681a9d58615224db812a74a705251d12f53cd51bcc88f1f"
2096
2096
  },
2097
2097
  {
2098
2098
  "path": "docs/modules-contract.md",
@@ -6302,12 +6302,12 @@
6302
6302
  {
6303
6303
  "path": "package-lock.json",
6304
6304
  "mode": "0000644",
6305
- "sha256": "a24646cf791a4ef41bf5fbca236cf24a27c9d05ba0f4419483054f38b849688e"
6305
+ "sha256": "a9e7b10b99360f563204364b2a444ff18b701669723ef0a9a76a04a0046df317"
6306
6306
  },
6307
6307
  {
6308
6308
  "path": "package.json",
6309
6309
  "mode": "0000644",
6310
- "sha256": "76ba0c0adc1241f0051796e43d8519486163d142b23a57704d60aabd56806cb6"
6310
+ "sha256": "ea1047b8ac17de0376d21a3a07d9f22f2854e20397b72b0626c896e4129bbfdf"
6311
6311
  },
6312
6312
  {
6313
6313
  "path": "public-docs/index.html",
@@ -7957,7 +7957,7 @@
7957
7957
  {
7958
7958
  "path": "src/module-api.js",
7959
7959
  "mode": "0000644",
7960
- "sha256": "4b7bee96fc2dfb083dcc43f811b46f135c4103cf719e68546ee2b898569cfc65"
7960
+ "sha256": "118d1bcac62c551bf53344abd1b77785f9875d4a6e6c29a86123f4587ac79906"
7961
7961
  },
7962
7962
  {
7963
7963
  "path": "src/module-loader/catalog.js",
@@ -9479,6 +9479,11 @@
9479
9479
  "mode": "0000644",
9480
9480
  "sha256": "51e1286235cbde1b56188f29b0e2bd12ac73a9637dbf1c16b325f10147256f27"
9481
9481
  },
9482
+ {
9483
+ "path": "tests/idea_route_attribution.mjs",
9484
+ "mode": "0000644",
9485
+ "sha256": "99a4665c1ddd97bb27238082c0e6e420eb66ab3c18ec92b543c3b35ba607ebda"
9486
+ },
9482
9487
  {
9483
9488
  "path": "tests/idea_routing.mjs",
9484
9489
  "mode": "0000644",
@@ -1341,5 +1341,7 @@ is load-bearing: the script throws rather than guess if it is missing, and
1341
1341
  landed since 1.19.450 with no explicit bump. run 33549781105. (task 1002620)
1342
1342
  1.19.452 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
1343
1343
  landed since 1.19.451 with no explicit bump. run 33552353620. (task 1002620)
1344
+ 1.19.453 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
1345
+ landed since 1.19.452 with no explicit bump. run 33553290345. (task 1002620)
1344
1346
  ---------------------------------------------------------------------------
1345
1347
  ```
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@bongos/core",
3
- "version": "1.19.452",
3
+ "version": "1.19.453",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@bongos/core",
9
- "version": "1.19.452",
9
+ "version": "1.19.453",
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.452",
3
+ "version": "1.19.453",
4
4
  "description": "Cloud Bongos — the AI-first build platform core (GDS + platform surfaces + module system), installed as a versioned dependency (ADR 0108).",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "main": "src/platform-server.js",
package/src/module-api.js CHANGED
@@ -33,7 +33,7 @@ const { validateOrRespond, LIMITS, parseId, asyncHandler, corsPublicGet, parsePa
33
33
  // there. scripts/gds/bump-version.js still rewrites the literal below; it appends
34
34
  // the entry to that file. Look for a version's history there, not here.
35
35
  // ---------------------------------------------------------------------------
36
- const CORE_VERSION = '1.19.452'; // CI auto-patch carrier (ADR 0161); changelog: docs/module-api-changelog.md
36
+ const CORE_VERSION = '1.19.453'; // CI auto-patch carrier (ADR 0161); changelog: docs/module-api-changelog.md
37
37
 
38
38
  // A namespaced logger so a module's log lines are attributable + consistent.
39
39
  // Usage: const log = api.logger('dev-box'); log.info('mounted');
@@ -0,0 +1,330 @@
1
+ // tests/idea_route_attribution.mjs
2
+ //
3
+ // THE PROOF — task 1003072 (BV1.R04, goal 1000071 "Idea routing"). Criterion
4
+ // C3, "no route loses the person who thought of it":
5
+ //
6
+ // (1) every routed task has an ideas_task_lineage row (origin='route') back to
7
+ // an idea_inbox row with captured_by;
8
+ // (3) sourceIdeaForTask on a routed, SHIPPED task returns the filer — the trail
9
+ // goal 1000067's ideator credit will pay against;
10
+ // (4) an unlinked Discord author still yields an idea row (captured_by null)
11
+ // rather than an attribution-free task.
12
+ //
13
+ // WHY THIS FILE EXISTS ALONGSIDE tests/idea_routing.mjs. That file proves the
14
+ // WRITE: a routed capture emits idea + task + lineage in one transaction, in FK
15
+ // order, and rolls all three back together. tests/idea_task_lineage.mjs proves
16
+ // the READ: given a hand-seeded lineage row, sourceIdeaForTask names the idea and
17
+ // its author. Neither proves the two HALVES COMPOSE — that the row routing
18
+ // actually writes is the row the credit hook actually finds. A typo'd origin, a
19
+ // task id written where an idea id was meant, a captured_by dropped on the way
20
+ // in: each passes both existing files and still loses the ideator their credit,
21
+ // silently, months before anyone tries to pay them.
22
+ //
23
+ // So this file runs the write and the read against ONE store. Nothing is
24
+ // hand-seeded: every row the assertions read was put there by captureIdea.
25
+ //
26
+ // THE STORE, not a matcher table. The other two files answer per-statement with
27
+ // canned rows, which is right for asserting statement SEQUENCE. Here the point is
28
+ // end-to-end agreement, so the fake speaks the three tables as maps and the
29
+ // queries genuinely join across them. A canned answer would prove nothing: it
30
+ // would be the test asserting its own fixture.
31
+ //
32
+ // MUTATION-VERIFIED (task 1003072). A proof that has never failed is a rumour, so
33
+ // each of these was applied to modules/ideas/inbox.js and the file was confirmed RED
34
+ // before being reverted:
35
+ //
36
+ // origin 'route' -> 'promote' in the lineage insert ......... 4 of 9 fail
37
+ // createdBy: capturedBy -> null on the task ................. 1 of 9 fail
38
+ // lineage params [task.id, idea.id] swapped ................. 5 of 9 fail
39
+ // captured_by -> null on the idea insert .................... 3 of 9 fail
40
+ // the lineage INSERT deleted (the #bugs bypass shape) ....... 5 of 9 fail
41
+ //
42
+ // Re-run that check if this file is ever rewritten: the store fake is expressive
43
+ // enough that a careless edit could make it answer its own questions.
44
+ //
45
+ // Run: node tests/idea_route_attribution.mjs
46
+
47
+ import { strict as assert } from 'node:assert';
48
+ import { createRequire } from 'node:module';
49
+ import { makeRunner } from './helpers.mjs';
50
+
51
+ process.env.NODE_ENV = 'test';
52
+
53
+ const require = createRequire(import.meta.url);
54
+ const api = require('../src/module-api.js');
55
+
56
+ // ---------------------------------------------------------------------------
57
+ // The store: idea_inbox, tasks, ideas_task_lineage as three maps.
58
+ // ---------------------------------------------------------------------------
59
+
60
+ const GOAL = {
61
+ id: 7, status: 'open', version_id: 'BONGOS-V1', version_status: 'building', scope_modules: ['ideas'],
62
+ };
63
+
64
+ function makeStore() {
65
+ return {
66
+ ideas: new Map(), // id -> row
67
+ tasks: new Map(), // id -> row
68
+ lineage: new Map(), // task_id -> { idea_id, origin }
69
+ nextIdeaId: 500,
70
+ nextTaskId: 9000,
71
+ goal: { ...GOAL },
72
+ };
73
+ }
74
+
75
+ // One SQL handler over the store, shared by the transaction client and the
76
+ // module-level pool — so the write path and the read path cannot disagree about
77
+ // what is in the database.
78
+ function handlerFor(store) {
79
+ return async (s, params = []) => {
80
+ // the locked goal read (routeIdeaToGoal step a)
81
+ if (/FROM goals g JOIN versions v/.test(s)) {
82
+ return { rows: store.goal ? [store.goal] : [] };
83
+ }
84
+ // the idea row (step b)
85
+ if (/INSERT INTO idea_inbox/.test(s)) {
86
+ const [title, bodyMd, kind, suggestedVersion, suggestedPriority, capturedBy, suggestedGoalId] = params;
87
+ const id = store.nextIdeaId++;
88
+ const row = {
89
+ id,
90
+ title,
91
+ body_md: bodyMd,
92
+ kind,
93
+ suggested_version: suggestedVersion ?? null,
94
+ suggested_priority: suggestedPriority ?? null,
95
+ // captured_by is THE field under test: it must survive the write
96
+ // unmodified, including when it is null (the unlinked-Discord case).
97
+ captured_by: capturedBy ?? null,
98
+ status: 'promoted',
99
+ suggested_goal_id: suggestedGoalId ?? null,
100
+ promoted_to_task_id: null,
101
+ reviewed_at: 'T0',
102
+ merged_into_idea_id: null,
103
+ triage_note: null,
104
+ captured_at: 'T0',
105
+ };
106
+ store.ideas.set(String(id), row);
107
+ return { rows: [row] };
108
+ }
109
+ // the lineage row (step d)
110
+ if (/INSERT INTO ideas_task_lineage/.test(s)) {
111
+ const [taskId, ideaId] = params;
112
+ // origin is a literal in the statement, not a param — read it from the SQL
113
+ // so a change to that literal is caught here rather than assumed.
114
+ const origin = (s.match(/VALUES \(\$1, \$2, '(\w+)'\)/) || [])[1] ?? null;
115
+ store.lineage.set(String(taskId), { idea_id: String(ideaId), origin });
116
+ return { rowCount: 1, rows: [] };
117
+ }
118
+ // closing the FK loop (step e)
119
+ if (/UPDATE idea_inbox SET promoted_to_task_id/.test(s)) {
120
+ const [ideaId, taskId] = params;
121
+ const row = store.ideas.get(String(ideaId));
122
+ if (row) row.promoted_to_task_id = taskId;
123
+ return { rows: row ? [row] : [] };
124
+ }
125
+ // sourceIdeaForTask — the read the ship hook does
126
+ if (/l\.idea_id, l\.origin, i\.captured_by/.test(s)) {
127
+ const link = store.lineage.get(String(params[0]));
128
+ if (!link) return { rows: [] };
129
+ const idea = store.ideas.get(String(link.idea_id));
130
+ if (!idea) return { rows: [] }; // an INNER JOIN finds nothing
131
+ return { rows: [{ idea_id: link.idea_id, origin: link.origin, captured_by: idea.captured_by }] };
132
+ }
133
+ // countShippedTasksForIdea
134
+ if (/COUNT\(\*\)::int AS n/.test(s)) {
135
+ const ideaId = String(params[0]);
136
+ let n = 0;
137
+ for (const [taskId, link] of store.lineage) {
138
+ if (link.idea_id === ideaId && (store.tasks.get(taskId) || {}).status === 'shipped') n++;
139
+ }
140
+ return { rows: [{ n }] };
141
+ }
142
+ return { rows: [] }; // BEGIN / COMMIT / ROLLBACK and anything unmatched
143
+ };
144
+ }
145
+
146
+ // A pool whose query() and connect().query() both run the same handler against
147
+ // the same store, and which records every statement for ordering assertions.
148
+ function poolFor(store) {
149
+ const handler = handlerFor(store);
150
+ const queries = [];
151
+ const client = {
152
+ queries,
153
+ async query(sql, params) {
154
+ queries.push({ sql: String(sql).replace(/\s+/g, ' ').trim(), params });
155
+ return handler(String(sql).replace(/\s+/g, ' ').trim(), params);
156
+ },
157
+ release() {},
158
+ };
159
+ return {
160
+ queries,
161
+ query: client.query,
162
+ connect: async () => client,
163
+ };
164
+ }
165
+
166
+ // ---------------------------------------------------------------------------
167
+ // Wiring: the lifecycle port (createTask) writes into the SAME store.
168
+ // ---------------------------------------------------------------------------
169
+
170
+ const seams = require('../src/module-seams.js');
171
+ seams._reset();
172
+
173
+ let activeStore = makeStore();
174
+
175
+ seams.registerProvider('lifecycle', {
176
+ createTask: async (args) => {
177
+ const id = activeStore.nextTaskId++;
178
+ const row = {
179
+ id,
180
+ status: args.status,
181
+ goal_id: args.goalId,
182
+ version_id: args.versionId,
183
+ title: args.title,
184
+ kind: args.kind,
185
+ source: args.source,
186
+ source_ref: args.sourceRef,
187
+ created_by: args.createdBy ?? null,
188
+ };
189
+ activeStore.tasks.set(String(id), row);
190
+ return row;
191
+ },
192
+ });
193
+
194
+ const inbox = require('../modules/ideas/inbox.js');
195
+ const { captureIdea, sourceIdeaForTask, countShippedTasksForIdea } = inbox;
196
+
197
+ // sourceIdeaForTask and countShippedTasksForIdea read the MODULE-LEVEL pool (no
198
+ // deps seam), so point that at the live store too. Same object the module
199
+ // captured at load, so replacing the method is enough.
200
+ api.pool.query = async (sql, params) => handlerFor(activeStore)(String(sql).replace(/\s+/g, ' ').trim(), params);
201
+
202
+ const { test, summary } = makeRunner();
203
+
204
+ // Route one bug and hand back everything the assertions need.
205
+ async function routeABug({ capturedBy = 42, filerRank = 'metic', title = 'the thing is broken' } = {}) {
206
+ activeStore = makeStore();
207
+ const pool = poolFor(activeStore);
208
+ const idea = await captureIdea(
209
+ { title, bodyMd: 'steps to reproduce', kind: 'bug', goalId: GOAL.id, capturedBy, filerRank },
210
+ { pool }
211
+ );
212
+ return { idea, pool, store: activeStore };
213
+ }
214
+
215
+ const ship = (store, taskId) => { store.tasks.get(String(taskId)).status = 'shipped'; };
216
+
217
+ // =========================================================================
218
+ // C3 (1) — the routed task HAS a lineage row, and it points at a real idea
219
+ // =========================================================================
220
+
221
+ await test('a routed bug writes lineage origin=route from the task back to the idea', async () => {
222
+ const { idea, store } = await routeABug();
223
+ const taskId = idea.routing.task_id;
224
+
225
+ assert.ok(taskId, 'the capture became a task');
226
+ const link = store.lineage.get(String(taskId));
227
+ assert.ok(link, 'a lineage row exists for the task that was just created');
228
+ assert.equal(link.origin, 'route', "origin is 'route' — not 'promote', which would misattribute the lane");
229
+ assert.equal(link.idea_id, String(idea.id), 'and it points at the idea this very capture wrote');
230
+ assert.ok(store.ideas.has(String(idea.id)), 'that idea id is a real row, not a dangling reference');
231
+ });
232
+
233
+ await test('the idea row carries the filer, and the task records them as its creator', async () => {
234
+ const { idea, store } = await routeABug({ capturedBy: 42 });
235
+ assert.equal(store.ideas.get(String(idea.id)).captured_by, 42, 'the filer is on the idea row');
236
+ assert.equal(store.tasks.get(String(idea.routing.task_id)).created_by, 42,
237
+ 'and on the task — routing an idea attributes the work to whoever reported it');
238
+ });
239
+
240
+ // =========================================================================
241
+ // C3 (3) — THE COMPOSITION. What routing wrote is what the ship hook reads.
242
+ // =========================================================================
243
+
244
+ await test('sourceIdeaForTask on the routed, SHIPPED task returns the filer', async () => {
245
+ const { idea, store } = await routeABug({ capturedBy: 42 });
246
+ const taskId = idea.routing.task_id;
247
+ ship(store, taskId);
248
+
249
+ const src = await sourceIdeaForTask(taskId);
250
+ assert.ok(src, 'the ship hook finds a source idea — nothing to pay is the failure this goal exists to prevent');
251
+ assert.equal(String(src.idea_id), String(idea.id), 'it names the idea the filing created');
252
+ assert.equal(src.origin, 'route', 'and says the route is where it came from');
253
+ assert.equal(src.captured_by, 42, 'and names the person to pay');
254
+ });
255
+
256
+ await test('the shipped-task count for that idea is exactly one — the credit lane can meter it', async () => {
257
+ const { idea, store } = await routeABug();
258
+ assert.equal(await countShippedTasksForIdea(idea.id), 0, 'nothing is owed before it ships');
259
+ ship(store, idea.routing.task_id);
260
+ assert.equal(await countShippedTasksForIdea(idea.id), 1, 'and exactly one afterwards — never double-paid');
261
+ });
262
+
263
+ await test('the trail survives with NOTHING hand-seeded — every row came from the capture', async () => {
264
+ const { idea, store } = await routeABug({ capturedBy: 77 });
265
+ // The point of the whole file, asserted directly: three tables, one act.
266
+ assert.equal(store.ideas.size, 1, 'one idea');
267
+ assert.equal(store.tasks.size, 1, 'one task');
268
+ assert.equal(store.lineage.size, 1, 'one lineage row');
269
+ ship(store, idea.routing.task_id);
270
+ const src = await sourceIdeaForTask(idea.routing.task_id);
271
+ assert.deepEqual(
272
+ { idea: String(src.idea_id), origin: src.origin, who: src.captured_by },
273
+ { idea: String(idea.id), origin: 'route', who: 77 }
274
+ );
275
+ });
276
+
277
+ // =========================================================================
278
+ // C3 (4) — an unlinked author still leaves a trail
279
+ // =========================================================================
280
+
281
+ await test('an UNLINKED filer (captured_by null) still yields an idea row, not an attribution-free task', async () => {
282
+ // A Discord author with no Bongos account. The report must not become a task
283
+ // that exists with no idea behind it — that is precisely the #bugs bypass this
284
+ // goal retires. The trail exists and is honestly empty at the person-shaped
285
+ // end, which is recoverable later; a missing lineage row never is.
286
+ const { idea, store } = await routeABug({ capturedBy: null, filerRank: 'metic' });
287
+ const taskId = idea.routing.task_id;
288
+
289
+ assert.ok(store.lineage.get(String(taskId)), 'the lineage row exists even with no known author');
290
+ ship(store, taskId);
291
+ const src = await sourceIdeaForTask(taskId);
292
+ assert.ok(src, 'the ship hook still finds the idea');
293
+ assert.equal(src.origin, 'route');
294
+ assert.equal(src.captured_by, null, 'unattributed, and honestly so — never guessed');
295
+ assert.equal(store.tasks.get(String(taskId)).created_by, null, 'the task does not invent a creator either');
296
+ });
297
+
298
+ // =========================================================================
299
+ // The negative: a task with no route has no trail, so a passing test above
300
+ // cannot be the fake answering itself.
301
+ // =========================================================================
302
+
303
+ await test('a task that was never routed has no source idea (the read is not vacuously true)', async () => {
304
+ activeStore = makeStore();
305
+ activeStore.tasks.set('4242', { id: 4242, status: 'shipped' });
306
+ assert.equal(await sourceIdeaForTask(4242), null,
307
+ 'no lineage row → null; if this returned a row the store would be answering blind');
308
+ });
309
+
310
+ await test('lineage pointing at a missing idea reads as no source, never as a half-row', async () => {
311
+ activeStore = makeStore();
312
+ activeStore.tasks.set('4243', { id: 4243, status: 'shipped' });
313
+ activeStore.lineage.set('4243', { idea_id: '999', origin: 'route' }); // idea absent
314
+ assert.equal(await sourceIdeaForTask(4243), null,
315
+ "the INNER JOIN drops it — the credit lane must never see an author-less 'source'");
316
+ });
317
+
318
+ // =========================================================================
319
+ // The provenance pair, so one idea can only ever mint one routed task
320
+ // =========================================================================
321
+
322
+ await test('the routed task carries the idempotency provenance the create-vector read keys on', async () => {
323
+ const { idea, store } = await routeABug();
324
+ const task = store.tasks.get(String(idea.routing.task_id));
325
+ assert.equal(task.source, 'idea-route', 'source names the vector');
326
+ assert.equal(task.source_ref, `idea-${idea.id}`,
327
+ 'and source_ref names the idea — db.findTaskBySourceRef is what stops a second task being minted');
328
+ });
329
+
330
+ summary();