@bongos/core 1.19.213 → 1.19.214
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 +12 -12
- package/modules/lifecycle/db.js +39 -6
- package/modules/lifecycle/routes/goals.js +8 -2
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/src/module-api.js +3 -1
- package/tests/goal_membership_requests.mjs +89 -0
- package/tests/goal_tier.mjs +10 -5
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.
|
|
6
|
-
"core_contract": "1.19.
|
|
7
|
-
"source_commit": "
|
|
5
|
+
"core_version": "1.19.214",
|
|
6
|
+
"core_contract": "1.19.214",
|
|
7
|
+
"source_commit": "33a353b2b8d41b5d78870cf04e367ba35270db01",
|
|
8
8
|
"source_ref": "HEAD",
|
|
9
|
-
"built_at": "2026-08-17T23:
|
|
9
|
+
"built_at": "2026-08-17T23:48:10.122Z",
|
|
10
10
|
"redaction": {
|
|
11
11
|
"model": "docs-redacted+functional-verbatim",
|
|
12
12
|
"docs_redacted": 310,
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"gate": "passed"
|
|
18
18
|
},
|
|
19
19
|
"file_count": 1633,
|
|
20
|
-
"tree_sha256": "
|
|
20
|
+
"tree_sha256": "42e8f882bc77acfe1def79c56518e80678fb0bd4d4b635f94d013e55474b1ac1",
|
|
21
21
|
"files": [
|
|
22
22
|
{
|
|
23
23
|
"path": ".claude/skills/blocker-review/SKILL.md",
|
|
@@ -3557,7 +3557,7 @@
|
|
|
3557
3557
|
{
|
|
3558
3558
|
"path": "modules/lifecycle/db.js",
|
|
3559
3559
|
"mode": "0000644",
|
|
3560
|
-
"sha256": "
|
|
3560
|
+
"sha256": "3d88ff6be3d8378f0cf2826af92437dfafbeb589a677aa8928d9f325124eac5b"
|
|
3561
3561
|
},
|
|
3562
3562
|
{
|
|
3563
3563
|
"path": "modules/lifecycle/done-when.js",
|
|
@@ -3652,7 +3652,7 @@
|
|
|
3652
3652
|
{
|
|
3653
3653
|
"path": "modules/lifecycle/routes/goals.js",
|
|
3654
3654
|
"mode": "0000644",
|
|
3655
|
-
"sha256": "
|
|
3655
|
+
"sha256": "9e963e289039a6b1c64b17deae161895876831de20e4e06b947ea3b3f49afdf6"
|
|
3656
3656
|
},
|
|
3657
3657
|
{
|
|
3658
3658
|
"path": "modules/lifecycle/routes/lifecycle.js",
|
|
@@ -4282,12 +4282,12 @@
|
|
|
4282
4282
|
{
|
|
4283
4283
|
"path": "package-lock.json",
|
|
4284
4284
|
"mode": "0000644",
|
|
4285
|
-
"sha256": "
|
|
4285
|
+
"sha256": "02845f76d2382f9e1568f039c838a34505297ae619cdb9cdbe5d8b583cd1dd40"
|
|
4286
4286
|
},
|
|
4287
4287
|
{
|
|
4288
4288
|
"path": "package.json",
|
|
4289
4289
|
"mode": "0000644",
|
|
4290
|
-
"sha256": "
|
|
4290
|
+
"sha256": "6abe7a4d894357f207a16ab1735c642f46e2f5905d3845c436b6df438f66a3ac"
|
|
4291
4291
|
},
|
|
4292
4292
|
{
|
|
4293
4293
|
"path": "public-docs/index.html",
|
|
@@ -5902,7 +5902,7 @@
|
|
|
5902
5902
|
{
|
|
5903
5903
|
"path": "src/module-api.js",
|
|
5904
5904
|
"mode": "0000644",
|
|
5905
|
-
"sha256": "
|
|
5905
|
+
"sha256": "53487d418120e292c09bc2f647581d2541fbf7966052420827b8d6c49c77940d"
|
|
5906
5906
|
},
|
|
5907
5907
|
{
|
|
5908
5908
|
"path": "src/module-loader/catalog.js",
|
|
@@ -6797,7 +6797,7 @@
|
|
|
6797
6797
|
{
|
|
6798
6798
|
"path": "tests/goal_membership_requests.mjs",
|
|
6799
6799
|
"mode": "0000644",
|
|
6800
|
-
"sha256": "
|
|
6800
|
+
"sha256": "660dd4143c21de0fe81b4507f3cb9f0731e5722e6c77806de8327156b18198f6"
|
|
6801
6801
|
},
|
|
6802
6802
|
{
|
|
6803
6803
|
"path": "tests/goal_routes.mjs",
|
|
@@ -6812,7 +6812,7 @@
|
|
|
6812
6812
|
{
|
|
6813
6813
|
"path": "tests/goal_tier.mjs",
|
|
6814
6814
|
"mode": "0000644",
|
|
6815
|
-
"sha256": "
|
|
6815
|
+
"sha256": "c2e37bb797c1e9af23970bfee7587b16cd13f1fac23c0e334a5ea0d362174491"
|
|
6816
6816
|
},
|
|
6817
6817
|
{
|
|
6818
6818
|
"path": "tests/goal_wall_proof.mjs",
|
package/modules/lifecycle/db.js
CHANGED
|
@@ -854,15 +854,48 @@ async function achieveGoalIfComplete({ goalId }, deps = {}) {
|
|
|
854
854
|
// owner's row — bypassing authorizeMemberRoleChange's owner-only-demotion
|
|
855
855
|
// guards. Role changes go through PATCH /goals/:id/members/:builderId only
|
|
856
856
|
// (the acceptMembershipRequestAndAddMember precedent). role defaults to 'member'.
|
|
857
|
+
//
|
|
858
|
+
// ARRIVING AS A MEMBER CLOSES ANY PENDING ASK (task 1002888 / idea 1000688).
|
|
859
|
+
// The membership write used to be a bare upsert that never looked at
|
|
860
|
+
// goal_membership_requests, so a builder's pending row SURVIVED their arrival by
|
|
861
|
+
// any other route — the goal flips to public and they self-join, or an Archon
|
|
862
|
+
// adds them directly. The stale row lingered in the owner/manager inbox, a later
|
|
863
|
+
// approve resolved a request for an existing member, and a later deny stamped
|
|
864
|
+
// 'rejected' on someone who is in fact a member. Harmless to access control,
|
|
865
|
+
// wrong in the audit trail.
|
|
866
|
+
//
|
|
867
|
+
// BOTH kinds are cancelled, not just 'request'. The partial-unique index
|
|
868
|
+
// (core_188: one pending row per goal+builder, either direction) means there is
|
|
869
|
+
// at most ONE pending row to close, and a stale pending INVITE is the same bug
|
|
870
|
+
// mirrored — the invitee could later decline an invitation to a goal they are
|
|
871
|
+
// already in, stamping 'rejected' on a member. 'cancelled' is the right terminal
|
|
872
|
+
// state (core_188: "withdrawn/rescinded"); 'accepted' stays reserved for an
|
|
873
|
+
// accept/approve flow that actually ran, so the inbox history never claims a
|
|
874
|
+
// decision nobody made. resolvedBy is the ACTOR — the joiner themselves on
|
|
875
|
+
// /join, the adding owner/manager/Archon on /members.
|
|
876
|
+
//
|
|
877
|
+
// One CTE, not two queries — the acceptMembershipRequestAndAddMember precedent:
|
|
878
|
+
// the cancel commits with the membership write or not at all, so an error
|
|
879
|
+
// between them can't leave the pair half-applied. The two arms are independent
|
|
880
|
+
// (Postgres runs a data-modifying CTE to completion whether or not the primary
|
|
881
|
+
// query reads it), and both see the same snapshot.
|
|
857
882
|
|
|
858
|
-
async function addGoalMember({ goalId, builderId, role = 'member' }, deps = {}) {
|
|
883
|
+
async function addGoalMember({ goalId, builderId, role = 'member', resolvedBy = null }, deps = {}) {
|
|
859
884
|
const activePool = (deps.pool && process.env.NODE_ENV === 'test') ? deps.pool : pool;
|
|
860
885
|
const { rows } = await activePool.query(
|
|
861
|
-
`
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
886
|
+
`WITH added AS (
|
|
887
|
+
INSERT INTO goal_members (goal_id, builder_id, role)
|
|
888
|
+
VALUES ($1, $2, $3)
|
|
889
|
+
ON CONFLICT (goal_id, builder_id) DO UPDATE SET role = goal_members.role
|
|
890
|
+
RETURNING goal_id, builder_id, role, joined_at
|
|
891
|
+
), cancelled AS (
|
|
892
|
+
UPDATE goal_membership_requests
|
|
893
|
+
SET status = 'cancelled', resolved_by = $4, resolved_at = now(), updated_at = now()
|
|
894
|
+
WHERE goal_id = $1 AND builder_id = $2 AND status = 'pending'
|
|
895
|
+
RETURNING id
|
|
896
|
+
)
|
|
897
|
+
SELECT goal_id, builder_id, role, joined_at FROM added`,
|
|
898
|
+
[goalId, builderId, role, resolvedBy]
|
|
866
899
|
);
|
|
867
900
|
return rows[0];
|
|
868
901
|
}
|
|
@@ -580,7 +580,10 @@ module.exports = function buildGoalsRouter() {
|
|
|
580
580
|
return res.fail('goal_private', { status: 409, message: 'This goal is private — request to join (POST /goals/:id/requests) or wait for an invitation.' });
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
|
-
|
|
583
|
+
// resolvedBy: the joiner — arriving as a member cancels their own still-
|
|
584
|
+
// pending ask on this goal, atomically with the membership write (task
|
|
585
|
+
// 1002888). Self-joining is the same intent as withdrawing the request.
|
|
586
|
+
const member = await db.addGoalMember({ goalId: id, builderId: req.builder.id, role: 'member', resolvedBy: req.builder.id });
|
|
584
587
|
return res.status(201).json({ ok: true, member });
|
|
585
588
|
} catch (err) {
|
|
586
589
|
console.error('[gds] POST /goals/:id/join', err);
|
|
@@ -939,7 +942,10 @@ module.exports = function buildGoalsRouter() {
|
|
|
939
942
|
if (scopeIncludesProtected(goal.scope_modules) && !METIC_PLUS.includes(target.rank)) {
|
|
940
943
|
return res.fail('metic_required_for_protected_scope', { status: 403, message: 'A protected-scope goal requires a Metic+ member; sub-Metic membership is deferred to the Phase-5 ADR.' });
|
|
941
944
|
}
|
|
942
|
-
|
|
945
|
+
// resolvedBy: the ADDER (not the target) — a direct add closes the target's
|
|
946
|
+
// pending ask, and the audit trail should name whoever admitted them
|
|
947
|
+
// (task 1002888).
|
|
948
|
+
const member = await db.addGoalMember({ goalId: id, builderId, role, resolvedBy: req.builder.id });
|
|
943
949
|
return res.status(201).json({ ok: true, member });
|
|
944
950
|
} catch (err) {
|
|
945
951
|
console.error('[gds] POST /goals/:id/members', err);
|
package/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bongos/core",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.214",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@bongos/core",
|
|
9
|
-
"version": "1.19.
|
|
9
|
+
"version": "1.19.214",
|
|
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.
|
|
3
|
+
"version": "1.19.214",
|
|
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
|
@@ -853,8 +853,10 @@ const { validateOrRespond, LIMITS, parseId, asyncHandler, corsPublicGet, parsePa
|
|
|
853
853
|
// landed since 1.19.211 with no explicit bump. run 32080157462. (task 1002620)
|
|
854
854
|
// 1.19.213 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
|
|
855
855
|
// landed since 1.19.212 with no explicit bump. run 32081051255. (task 1002620)
|
|
856
|
+
// 1.19.214 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
|
|
857
|
+
// landed since 1.19.213 with no explicit bump. run 32081917908. (task 1002620)
|
|
856
858
|
// ---------------------------------------------------------------------------
|
|
857
|
-
const CORE_VERSION = '1.19.
|
|
859
|
+
const CORE_VERSION = '1.19.214'; // CI auto-patch carrier (ADR 0161); see changelog above
|
|
858
860
|
|
|
859
861
|
// A namespaced logger so a module's log lines are attributable + consistent.
|
|
860
862
|
// Usage: const log = api.logger('dev-box'); log.info('mounted');
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
// • listInboxFor — the three buckets, and that joinRequests gates on
|
|
14
14
|
// owner (goals.created_by) OR manager (goal_members 'lead').
|
|
15
15
|
// • listPendingRequestsForGoal — pending both-kinds for one goal.
|
|
16
|
+
// • addGoalMember (task 1002888) — arriving as a member by ANY route cancels
|
|
17
|
+
// that builder's still-pending ask, atomically and kind-agnostically.
|
|
16
18
|
// • the migration is additive + private-safe (default 'public', partial unique).
|
|
17
19
|
|
|
18
20
|
import { strict as assert } from 'node:assert';
|
|
@@ -31,6 +33,7 @@ const {
|
|
|
31
33
|
getMembershipRequest,
|
|
32
34
|
resolveMembershipRequest,
|
|
33
35
|
acceptMembershipRequestAndAddMember,
|
|
36
|
+
addGoalMember,
|
|
34
37
|
listInboxFor,
|
|
35
38
|
listPendingRequestsForGoal,
|
|
36
39
|
} = require('../modules/lifecycle/db.js');
|
|
@@ -190,6 +193,92 @@ await test('listPendingRequestsForGoal: pending both-kinds for one goal', async
|
|
|
190
193
|
assert.deepEqual(find(pool.queries, /goal_membership_requests/).params, [5]);
|
|
191
194
|
});
|
|
192
195
|
|
|
196
|
+
// =========================================================================
|
|
197
|
+
// addGoalMember — arriving as a member CLOSES any pending ask (task 1002888 /
|
|
198
|
+
// idea 1000688). The bug: the membership write was a bare upsert that never
|
|
199
|
+
// read goal_membership_requests, so a pending row survived the builder's
|
|
200
|
+
// arrival by any OTHER route (visibility flips to public and they self-join;
|
|
201
|
+
// an Archon adds them directly). The stale row sat in the owner/manager inbox,
|
|
202
|
+
// a later approve resolved a request for an existing member, and a later deny
|
|
203
|
+
// stamped 'rejected' on someone who is in fact a member.
|
|
204
|
+
// =========================================================================
|
|
205
|
+
|
|
206
|
+
const ADD_MEMBER_ROW = { goal_id: 7, builder_id: 42, role: 'member', joined_at: 'T0' };
|
|
207
|
+
const addMemberPool = () => fakePool((s) => (/^WITH added AS/.test(s) ? { rows: [ADD_MEMBER_ROW] } : null));
|
|
208
|
+
|
|
209
|
+
// join-cancels-request: the joiner arrives under their own steam.
|
|
210
|
+
await test('addGoalMember: a join cancels the joiner\'s pending ask in ONE statement', async () => {
|
|
211
|
+
const pool = addMemberPool();
|
|
212
|
+
const out = await addGoalMember({ goalId: 7, builderId: 42, role: 'member', resolvedBy: 42 }, { pool });
|
|
213
|
+
assert.deepEqual(out, ADD_MEMBER_ROW, 'still returns the member row — the route response shape is unchanged');
|
|
214
|
+
assert.equal(pool.queries.length, 1, 'ONE statement: the cancel commits with the membership write or not at all');
|
|
215
|
+
const q = find(pool.queries, /^WITH added AS/);
|
|
216
|
+
assert.ok(/INSERT INTO goal_members[\s\S]*ON CONFLICT \(goal_id, builder_id\) DO UPDATE SET role = goal_members\.role/.test(norm(q.sql)),
|
|
217
|
+
'the membership upsert is the first arm, role still preserved (task 1002689)');
|
|
218
|
+
assert.ok(/UPDATE goal_membership_requests[\s\S]*SET status = 'cancelled', resolved_by = \$4/.test(norm(q.sql)),
|
|
219
|
+
'the second arm closes the ask as cancelled, attributed to the actor');
|
|
220
|
+
assert.ok(/WHERE goal_id = \$1 AND builder_id = \$2 AND status = 'pending'/.test(norm(q.sql)),
|
|
221
|
+
'scoped to THIS goal+builder, and only a pending row');
|
|
222
|
+
assert.deepEqual(q.params, [7, 42, 'member', 42], 'goal, builder, role, resolvedBy — in that order');
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// add-cancels-request: an owner/manager/Archon admits them directly. Same
|
|
226
|
+
// statement; resolvedBy is the ADDER, so the audit trail names who admitted them.
|
|
227
|
+
await test('addGoalMember: a direct member-add cancels the target\'s pending ask, attributed to the adder', async () => {
|
|
228
|
+
const pool = addMemberPool();
|
|
229
|
+
await addGoalMember({ goalId: 7, builderId: 42, role: 'lead', resolvedBy: 99 }, { pool });
|
|
230
|
+
const q = find(pool.queries, /^WITH added AS/);
|
|
231
|
+
assert.deepEqual(q.params, [7, 42, 'lead', 99],
|
|
232
|
+
'resolved_by is the ADDER (99), not the target (42) — who admitted them is the audit fact');
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// The mirror-case decision (task 1002888): a stale pending INVITE is the same
|
|
236
|
+
// bug reflected — the invitee could later decline an invitation to a goal they
|
|
237
|
+
// are already in, stamping 'rejected' on a member. core_188's partial-unique
|
|
238
|
+
// index allows at most ONE pending row per (goal, builder) in EITHER direction,
|
|
239
|
+
// so "any pending row" is unambiguous and the cancel is deliberately kind-blind.
|
|
240
|
+
await test('addGoalMember: the cancel is kind-AGNOSTIC — a stale pending invite closes too', async () => {
|
|
241
|
+
const pool = addMemberPool();
|
|
242
|
+
await addGoalMember({ goalId: 7, builderId: 42, resolvedBy: 42 }, { pool });
|
|
243
|
+
const cancelArm = norm(find(pool.queries, /^WITH added AS/).sql).match(/UPDATE goal_membership_requests.*?RETURNING id/)[0];
|
|
244
|
+
assert.ok(!/kind\s*=/.test(cancelArm),
|
|
245
|
+
'no kind filter: both a pending request and a pending invite are closed by arrival');
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// 'accepted' stays reserved for an accept/approve flow that actually ran, so the
|
|
249
|
+
// inbox history never claims a decision nobody made; resolved rows are the audit
|
|
250
|
+
// trail and must survive untouched.
|
|
251
|
+
await test('addGoalMember: closes as \'cancelled\' (never \'accepted\'), and only pending rows', async () => {
|
|
252
|
+
const pool = addMemberPool();
|
|
253
|
+
await addGoalMember({ goalId: 7, builderId: 42, resolvedBy: 42 }, { pool });
|
|
254
|
+
const sql = norm(find(pool.queries, /^WITH added AS/).sql);
|
|
255
|
+
assert.ok(!/status = 'accepted'/.test(sql), "arrival never fabricates an 'accepted' decision");
|
|
256
|
+
assert.ok(/status = 'pending'/.test(sql), 'already-resolved rows stay as the audit trail');
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
await test('addGoalMember: resolvedBy defaults to null for a non-route caller', async () => {
|
|
260
|
+
const pool = addMemberPool();
|
|
261
|
+
await addGoalMember({ goalId: 7, builderId: 42 }, { pool });
|
|
262
|
+
assert.equal(find(pool.queries, /^WITH added AS/).params[3], null);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// Both route call sites must actually SUPPLY the actor — the db helper defaults
|
|
266
|
+
// resolvedBy to null, so a missed wire-up would silently drop the attribution
|
|
267
|
+
// while still cancelling. The routes are verified against live Postgres (see
|
|
268
|
+
// goal_routes.mjs header), so this pins the wiring at the source level.
|
|
269
|
+
await test('routes: both /join and /members pass resolvedBy to addGoalMember', () => {
|
|
270
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
271
|
+
const src = readFileSync(join(here, '..', 'modules', 'lifecycle', 'routes', 'goals.js'), 'utf8');
|
|
272
|
+
const calls = src.match(/db\.addGoalMember\(\{[^}]*\}\)/g) || [];
|
|
273
|
+
assert.equal(calls.length, 2, 'exactly two membership-add call sites: POST /join and POST /members');
|
|
274
|
+
for (const c of calls) {
|
|
275
|
+
assert.ok(/resolvedBy:\s*req\.builder\.id/.test(c),
|
|
276
|
+
`every membership add attributes the cancel to the acting builder — got: ${c}`);
|
|
277
|
+
}
|
|
278
|
+
assert.ok(calls.some((c) => /builderId:\s*req\.builder\.id/.test(c)), '/join adds the caller themselves');
|
|
279
|
+
assert.ok(calls.some((c) => /builderId,/.test(c)), '/members adds the named target builder');
|
|
280
|
+
});
|
|
281
|
+
|
|
193
282
|
// =========================================================================
|
|
194
283
|
// The migration is additive + private-safe
|
|
195
284
|
// =========================================================================
|
package/tests/goal_tier.mjs
CHANGED
|
@@ -154,20 +154,25 @@ await test('setGoalStatus: unknown goal returns null', async () => {
|
|
|
154
154
|
// =========================================================================
|
|
155
155
|
// addGoalMember
|
|
156
156
|
// =========================================================================
|
|
157
|
+
// task 1002888 wrapped the bare upsert in a CTE that also cancels any pending
|
|
158
|
+
// membership request, so the statement now STARTS with `WITH added AS (` — the
|
|
159
|
+
// INSERT is the first arm. The pending-ask cancellation itself is pinned in
|
|
160
|
+
// tests/goal_membership_requests.mjs; here we only re-anchor the role contract.
|
|
157
161
|
await test('addGoalMember: upsert PRESERVES the existing role (re-join cannot demote a lead)', async () => {
|
|
158
|
-
const pool = fakePool((s) => (/^
|
|
162
|
+
const pool = fakePool((s) => (/^WITH added AS/.test(s) ? { rows: [{ ...MEMBER_ROW, role: 'lead' }] } : null));
|
|
159
163
|
const out = await addGoalMember({ goalId: 7, builderId: 42, role: 'member' }, { pool });
|
|
160
164
|
assert.equal(out.role, 'lead', 'an existing lead row survives a role:member re-add');
|
|
161
|
-
const ins = find(pool.queries, /^
|
|
162
|
-
assert.deepEqual(ins.params, [7, 42, 'member']);
|
|
165
|
+
const ins = find(pool.queries, /^WITH added AS/);
|
|
166
|
+
assert.deepEqual(ins.params, [7, 42, 'member', null], 'resolvedBy defaults to null when no actor is supplied');
|
|
167
|
+
assert.match(ins.sql, /INSERT INTO goal_members/, 'the membership write is the first CTE arm');
|
|
163
168
|
assert.match(ins.sql, /ON CONFLICT \(goal_id, builder_id\) DO UPDATE SET role = goal_members\.role/,
|
|
164
169
|
'conflict keeps the stored role — role changes go through PATCH /goals/:id/members/:builderId only (task 1002689)');
|
|
165
170
|
});
|
|
166
171
|
|
|
167
172
|
await test('addGoalMember: role defaults to member', async () => {
|
|
168
|
-
const pool = fakePool((s) => (/^
|
|
173
|
+
const pool = fakePool((s) => (/^WITH added AS/.test(s) ? { rows: [MEMBER_ROW] } : null));
|
|
169
174
|
await addGoalMember({ goalId: 7, builderId: 42 }, { pool });
|
|
170
|
-
assert.equal(find(pool.queries, /^
|
|
175
|
+
assert.equal(find(pool.queries, /^WITH added AS/).params[2], 'member');
|
|
171
176
|
});
|
|
172
177
|
|
|
173
178
|
// =========================================================================
|