@bongos/core 1.19.277 → 1.19.279
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 +27 -17
- package/docs/adr/0182-project-visibility-two-axes.md +168 -0
- package/docs/adr/README.md +1 -0
- package/modules/lifecycle/claim-feed.js +142 -0
- package/modules/lifecycle/db.js +52 -53
- package/modules/lifecycle/goal-authz.js +56 -1
- package/modules/lifecycle/routes/claims.js +6 -0
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/src/module-api.js +5 -1
- package/tests/goal_abuse_matrix.mjs +72 -0
- package/tests/reward_gate.mjs +4 -3
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.
|
|
6
|
-
"core_contract": "1.19.
|
|
7
|
-
"source_commit": "
|
|
5
|
+
"core_version": "1.19.279",
|
|
6
|
+
"core_contract": "1.19.279",
|
|
7
|
+
"source_commit": "20fdd2b00fa489173ea330aeec453d56dcb6999a",
|
|
8
8
|
"source_ref": "HEAD",
|
|
9
|
-
"built_at": "2026-08-
|
|
9
|
+
"built_at": "2026-08-21T20:04:41.616Z",
|
|
10
10
|
"redaction": {
|
|
11
11
|
"model": "docs-redacted+functional-verbatim",
|
|
12
|
-
"docs_redacted":
|
|
12
|
+
"docs_redacted": 319,
|
|
13
13
|
"agent_docs_stubbed": 22,
|
|
14
|
-
"functional_verbatim":
|
|
14
|
+
"functional_verbatim": 1377,
|
|
15
15
|
"rules": 3,
|
|
16
16
|
"gate_literals": 3,
|
|
17
17
|
"gate": "passed"
|
|
18
18
|
},
|
|
19
|
-
"file_count":
|
|
20
|
-
"tree_sha256": "
|
|
19
|
+
"file_count": 1718,
|
|
20
|
+
"tree_sha256": "98ca3398579326bf1dc3356202895e6911341413dbf4e0238347e3357888565f",
|
|
21
21
|
"files": [
|
|
22
22
|
{
|
|
23
23
|
"path": ".claude/skills/blocker-review/SKILL.md",
|
|
@@ -1389,10 +1389,15 @@
|
|
|
1389
1389
|
"mode": "0000644",
|
|
1390
1390
|
"sha256": "26f39ae01ea1768dfbd61789752356ae30364b465117b1e7ddee94fabc7d6bbf"
|
|
1391
1391
|
},
|
|
1392
|
+
{
|
|
1393
|
+
"path": "docs/adr/0182-project-visibility-two-axes.md",
|
|
1394
|
+
"mode": "0000644",
|
|
1395
|
+
"sha256": "119637165d2d6b89f8c00afccd07d9f073629f1502f4b2f2cdc673001b2f8d2a"
|
|
1396
|
+
},
|
|
1392
1397
|
{
|
|
1393
1398
|
"path": "docs/adr/README.md",
|
|
1394
1399
|
"mode": "0000644",
|
|
1395
|
-
"sha256": "
|
|
1400
|
+
"sha256": "56d478e1b5285c1c133225240c65ec23c6b3b4f280cdda853c50b33564cc2910"
|
|
1396
1401
|
},
|
|
1397
1402
|
{
|
|
1398
1403
|
"path": "docs/api-reference.md",
|
|
@@ -3739,6 +3744,11 @@
|
|
|
3739
3744
|
"mode": "0000644",
|
|
3740
3745
|
"sha256": "0c52ae165d304f0f08ca04c9a288ef7d8ffb07288282dcd7b2d503fced7cd744"
|
|
3741
3746
|
},
|
|
3747
|
+
{
|
|
3748
|
+
"path": "modules/lifecycle/claim-feed.js",
|
|
3749
|
+
"mode": "0000644",
|
|
3750
|
+
"sha256": "3586cc2aa07913870ad99073c534e70ef2e2c5ff6a5ef2ddeb141cfd397269cd"
|
|
3751
|
+
},
|
|
3742
3752
|
{
|
|
3743
3753
|
"path": "modules/lifecycle/conflict-resolve.js",
|
|
3744
3754
|
"mode": "0000644",
|
|
@@ -3752,7 +3762,7 @@
|
|
|
3752
3762
|
{
|
|
3753
3763
|
"path": "modules/lifecycle/db.js",
|
|
3754
3764
|
"mode": "0000644",
|
|
3755
|
-
"sha256": "
|
|
3765
|
+
"sha256": "74eedb9ee1c423c9ecdea6f09d8555fa3200ac9e3a86a194182774cb72f0cd0b"
|
|
3756
3766
|
},
|
|
3757
3767
|
{
|
|
3758
3768
|
"path": "modules/lifecycle/done-when.js",
|
|
@@ -3777,7 +3787,7 @@
|
|
|
3777
3787
|
{
|
|
3778
3788
|
"path": "modules/lifecycle/goal-authz.js",
|
|
3779
3789
|
"mode": "0000644",
|
|
3780
|
-
"sha256": "
|
|
3790
|
+
"sha256": "3eb9d818e0e0d45a896a5c0a515842b5f5a01e102d02f8a9a605c271088c8e5d"
|
|
3781
3791
|
},
|
|
3782
3792
|
{
|
|
3783
3793
|
"path": "modules/lifecycle/goal-conflicts.js",
|
|
@@ -3832,7 +3842,7 @@
|
|
|
3832
3842
|
{
|
|
3833
3843
|
"path": "modules/lifecycle/routes/claims.js",
|
|
3834
3844
|
"mode": "0000644",
|
|
3835
|
-
"sha256": "
|
|
3845
|
+
"sha256": "e02abac52a82fb02603dd92074d4ebd060ec03195803d704b021614806ef00fe"
|
|
3836
3846
|
},
|
|
3837
3847
|
{
|
|
3838
3848
|
"path": "modules/lifecycle/routes/dependencies.js",
|
|
@@ -4487,12 +4497,12 @@
|
|
|
4487
4497
|
{
|
|
4488
4498
|
"path": "package-lock.json",
|
|
4489
4499
|
"mode": "0000644",
|
|
4490
|
-
"sha256": "
|
|
4500
|
+
"sha256": "66c790ddb5f66b9c7e5961f8402a508bdb36d5dddf35215401eda673a115c003"
|
|
4491
4501
|
},
|
|
4492
4502
|
{
|
|
4493
4503
|
"path": "package.json",
|
|
4494
4504
|
"mode": "0000644",
|
|
4495
|
-
"sha256": "
|
|
4505
|
+
"sha256": "ea43d45c4c7ef30f10935c5ec6e967e9a1c707a6f9a69ed7f5f6b2e5771fef8e"
|
|
4496
4506
|
},
|
|
4497
4507
|
{
|
|
4498
4508
|
"path": "public-docs/index.html",
|
|
@@ -6137,7 +6147,7 @@
|
|
|
6137
6147
|
{
|
|
6138
6148
|
"path": "src/module-api.js",
|
|
6139
6149
|
"mode": "0000644",
|
|
6140
|
-
"sha256": "
|
|
6150
|
+
"sha256": "e58b6609edc9a144ab403e149a715aebdc324b598244833d1ef3a6aa3713f88a"
|
|
6141
6151
|
},
|
|
6142
6152
|
{
|
|
6143
6153
|
"path": "src/module-loader/catalog.js",
|
|
@@ -7037,7 +7047,7 @@
|
|
|
7037
7047
|
{
|
|
7038
7048
|
"path": "tests/goal_abuse_matrix.mjs",
|
|
7039
7049
|
"mode": "0000644",
|
|
7040
|
-
"sha256": "
|
|
7050
|
+
"sha256": "daf3a5942ce3f154d29618e4242557758db50d8c70046562995fc2c10d5ee954"
|
|
7041
7051
|
},
|
|
7042
7052
|
{
|
|
7043
7053
|
"path": "tests/goal_achievement.mjs",
|
|
@@ -8057,7 +8067,7 @@
|
|
|
8057
8067
|
{
|
|
8058
8068
|
"path": "tests/reward_gate.mjs",
|
|
8059
8069
|
"mode": "0000644",
|
|
8060
|
-
"sha256": "
|
|
8070
|
+
"sha256": "a21d9f4d3ff937d59b9361b330a2e5e93ded9c9a12d73434eb843cae9d1a3c74"
|
|
8061
8071
|
},
|
|
8062
8072
|
{
|
|
8063
8073
|
"path": "tests/reward_mode_cost_plus_only.mjs",
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# ADR 0182 — Project visibility is TWO axes: a derived publish gate and a stored join door
|
|
2
|
+
|
|
3
|
+
- **Status:** Accepted
|
|
4
|
+
- **Date:** 2026-08-21
|
|
5
|
+
- **Task:** [task 1002320](https://cloudbongos.com/builders#/task/1002320) (BONGOS-V1, goal 1000046 — *Project creation — visibility & customization*)
|
|
6
|
+
- **Deciders:** IAMMASTERQUA (Archon), Claude
|
|
7
|
+
- **Confirms R04–R18** — the full accounting is in *Scope* below, including the two that this ADR deliberately does **not** govern.
|
|
8
|
+
- **Bounds — deliberately NOT decided here:** the self-hosted→hub *reporting and trust* mechanics ([task 1002321](https://cloudbongos.com/builders#/task/1002321), R02) · the applications/invite *model* (`docs/specs/<redacted>.md` D2, already decided) · project *authority* (same spec, D1)
|
|
9
|
+
- **Related:** [ADR 0141](<redacted>.md) (hub = identity + relay, authority stays local) · [ADR 0112](<redacted>.md) (`goals.visibility`, the precedent this copies) · [ADR 0108](<redacted>.md) (the instance IS the project) · [ADR 0174](<redacted>.md) (one word, one meaning)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Scope — what "confirms R04–R18" means, task by task
|
|
14
|
+
|
|
15
|
+
The task description says this ADR *"confirms R04–R18"*. That is 15 tasks and they do not
|
|
16
|
+
all relate to it the same way, so they are enumerated rather than gestured at. **Its
|
|
17
|
+
criteria** are `proj-visibility-states`, `proj-join-policy` and `proj-detail-interview`
|
|
18
|
+
(the goal's C1–C3); task 1002320 is linked to all three.
|
|
19
|
+
|
|
20
|
+
**Shape set by this ADR** — these build what it decides, and each should be read against it:
|
|
21
|
+
|
|
22
|
+
| | Task | Gets from this ADR |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| R04 | [1002323](https://cloudbongos.com/builders#/task/1002323) | the 3-value enum + the derived gate + the missing `description` column (D1, D4) |
|
|
25
|
+
| R05 | [1002324](https://cloudbongos.com/builders#/task/1002324) | **moves host** — an instance surface, not a hub one (D5) |
|
|
26
|
+
| R06 | [1002325](https://cloudbongos.com/builders#/task/1002325) | the feed predicate change + **server-side** stealth redaction (D2a, D3) |
|
|
27
|
+
| R07 | [1002326](https://cloudbongos.com/builders#/task/1002326) | which three states render, and that `featured` no longer gates presence (D3) |
|
|
28
|
+
| R08 | [1002327](https://cloudbongos.com/builders#/task/1002327) | the hub row is a cache; **unreported ⇒ fail-closed** (D5) |
|
|
29
|
+
| R09 | [1002328](https://cloudbongos.com/builders#/task/1002328) | the render mapping, and that it may not be trusted to redact (D2a) |
|
|
30
|
+
| R11 | [1002330](https://cloudbongos.com/builders#/task/1002330) | per-state application rules on the already-decided model (D6) |
|
|
31
|
+
| R12 | [1002331](https://cloudbongos.com/builders#/task/1002331) | **visibility is the ceiling; join policy may only narrow** (D6) |
|
|
32
|
+
| R15 | [1002334](https://cloudbongos.com/builders#/task/1002334) | why skipping the interview is a supported default, not a dead end (D4) |
|
|
33
|
+
| R16 | [1002335](https://cloudbongos.com/builders#/task/1002335) | the bar is identity only, and it must name what is missing (D4) |
|
|
34
|
+
|
|
35
|
+
**Proofs of those shapes** — no new decisions, but their assertions are set here:
|
|
36
|
+
R10 ([1002329](https://cloudbongos.com/builders#/task/1002329)) must assert stealth's
|
|
37
|
+
**absent fields, not absent pixels** (D2a);
|
|
38
|
+
R14 ([1002333](https://cloudbongos.com/builders#/task/1002333)) must cover the
|
|
39
|
+
ceiling-vs-narrowing rule (D6);
|
|
40
|
+
R18 ([1002337](https://cloudbongos.com/builders#/task/1002337)) must cover
|
|
41
|
+
skip ⇒ dark-matter-until-published (D4).
|
|
42
|
+
|
|
43
|
+
**NOT governed by this ADR**, stated so the omission is a decision rather than a gap:
|
|
44
|
+
|
|
45
|
+
- **R13** ([1002332](https://cloudbongos.com/builders#/task/1002332)), the owner
|
|
46
|
+
applications review queue — belongs to `docs/specs/<redacted>.md`
|
|
47
|
+
(D1/D2), which already decided the queue, its authority and its storage. This ADR sets
|
|
48
|
+
only which states *accept* an application (D6), never what happens to it afterwards.
|
|
49
|
+
- **R17** ([1002336](https://cloudbongos.com/builders#/task/1002336)), rule-based
|
|
50
|
+
recommendations from the project detail — orthogonal. Recommendations concern module and
|
|
51
|
+
governance presets; nothing about them depends on visibility or publishability.
|
|
52
|
+
|
|
53
|
+
## Context
|
|
54
|
+
|
|
55
|
+
Goal 1000046 seeded 31 tasks, and R04–R18 each say *"per R01"* — this ADR. Nothing in the goal could start until it landed: at claim time it gated **29 open tasks**, the largest single chokepoint in the repo, and it was itself parked at `backlog` with no dependencies of its own.
|
|
56
|
+
|
|
57
|
+
The spec its planning task cites — `docs/specs/<redacted>.md` — **was never written**. This ADR is therefore the design of record, not a summary of one.
|
|
58
|
+
|
|
59
|
+
**What exists today.** `platform_identity_projects` (hub-side, keyed by `origin`) carries `status ('active'|'hidden')`, an Archon-curated `featured` boolean, and `owner_github_id` — explicitly commented *"advisory attribution (not an authority)"*. The public feed reads `featured = true AND status = 'active'`. So today a project's presence on the map is **Archon editorial curation**, and the owner has no control at all. The goal's premise is the inverse: the owner shapes it.
|
|
60
|
+
|
|
61
|
+
**The apparent contradiction that motivated this ADR.** The goal's own criterion `proj-visibility-states` says *"one of **four** states"* (Public/Private/Stealth/Unlisted). R04's description says *"3-state visibility enum … dark-matter is derived … not a stored 4th state"*. Read as one enum these disagree. They do not disagree; they describe different layers, and conflating those layers is the trap this ADR exists to prevent.
|
|
62
|
+
|
|
63
|
+
## Decision 1 — Two independent axes, not one four-valued enum
|
|
64
|
+
|
|
65
|
+
| Axis | Stored? | Set by | Governs |
|
|
66
|
+
|---|---|---|---|
|
|
67
|
+
| **Publishability** | **Derived** | the identity gate (R16) | whether the project is on the map *at all* |
|
|
68
|
+
| **The join door** | Stored: `visibility ∈ (public, private, stealth)` | the project's owner | how it renders, and who may get in |
|
|
69
|
+
|
|
70
|
+
The four user-facing states are **3 × publishable, plus one derived state that collapses all three**:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
publishable = false → DARK MATTER (off the map, un-joinable) — whatever the enum says
|
|
74
|
+
publishable = true → public → planet (identified, anyone may join)
|
|
75
|
+
private → star (identified, no self-join, applications accepted)
|
|
76
|
+
stealth → black hole (ANONYMOUS, no self-join, applications refused)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**The name `visibility` is kept, and it is a mild lie.** The column does not decide visibility — publishability does. We keep the name because `goals.visibility` (ADR 0112) already established it and one word across both planes beats an accurate name used in one place. This paragraph is the mitigation: **anyone reading `visibility = 'public'` and expecting the orb on the map is reading it wrong**, and the publish gate is the thing to check. R04 must carry that sentence to the column comment.
|
|
80
|
+
|
|
81
|
+
## Decision 2 — All three stored states are VISIBLE; only the derived state is invisible
|
|
82
|
+
|
|
83
|
+
This is what makes the 3+1 split honest rather than a workaround: the enum is a *door* policy, and every value of it is on the map. Consequences worth stating because R06/R07/R09 all depend on them:
|
|
84
|
+
|
|
85
|
+
- **`private` means visible-but-closed, exactly as it already does for goals.** ADR 0112: *"a private goal stays VISIBLE in the goal list but non-members can't self-join."* The project plane inherits that meaning unchanged. A private project is a star you can see and ask to join.
|
|
86
|
+
- **`stealth` exposes EXISTENCE but not IDENTITY.** The black hole is the metaphor and it is precise: you see the gravitational effect, not the object. R06/R09 say "stealth is anonymous", and that is a real privacy primitive, not a rendering note.
|
|
87
|
+
- **Dark matter is not a state an owner picks.** It is the absence of a met bar. There is deliberately no way to *choose* it, because "unlisted" as a selectable option would compete with `private` and nobody could say which to pick.
|
|
88
|
+
|
|
89
|
+
### Decision 2a — stealth redaction is SERVER-SIDE, in the feed
|
|
90
|
+
|
|
91
|
+
A stealth project's `name`, `tagline`, `art_url`, and `origin` **must not leave the server** in the public feed. The feed emits the orb (existence, render type, and whatever aggregate the map needs) and nothing identifying.
|
|
92
|
+
|
|
93
|
+
This is called out because the naive implementation is to send the row and let the orbs page hide it — which leaks the whole thing to anyone who opens the network tab, and the orbs page is a **static site outside this repo** (R09), so we cannot enforce it there even in principle. Redaction at the boundary is the only version of this that is true. R06 owns it; R10's proof must assert the absence of the fields, not the absence of pixels.
|
|
94
|
+
|
|
95
|
+
## Decision 3 — Three mechanisms, three owners, one composition rule
|
|
96
|
+
|
|
97
|
+
`status`, `visibility` and `featured` all touch "does this appear", and they are not the same thing:
|
|
98
|
+
|
|
99
|
+
| Field | Owner | Meaning |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| `status` | system / Archon | operational lifecycle — a deprovisioned project is `hidden` |
|
|
102
|
+
| `visibility` | the **project owner** | the join door (Decision 1) |
|
|
103
|
+
| `featured` | Archon | editorial promotion |
|
|
104
|
+
|
|
105
|
+
**Composition:** a project is on the map iff `status = 'active' AND publishable`. `featured` may only **rank or promote among projects already on the map** — it can never put an unpublishable or `hidden` project there.
|
|
106
|
+
|
|
107
|
+
That is a behaviour change: today's feed predicate is `featured = true AND status = 'active'`, so **featuring is currently load-bearing for visibility at all**, and an owner setting `public` on an unfeatured project would see nothing happen. R06 replaces the predicate; R07 dogfoods it. Without this decision the owner-control premise of the whole goal silently does not work.
|
|
108
|
+
|
|
109
|
+
## Decision 4 — The publish gate is identity only: `name` + `description`
|
|
110
|
+
|
|
111
|
+
Per the owner interview (recorded on R16): the bar is a name and a description. **Not** tagline, art, modules, governance, or a completed interview.
|
|
112
|
+
|
|
113
|
+
The bar exists to keep empty husks off the map — not to enforce completeness. A higher bar would make "skip the optional detail step" a dead end rather than the supported default the goal explicitly wants (`proj-detail-interview`: *"skipping it produces sensible defaults"*).
|
|
114
|
+
|
|
115
|
+
**The gate must name what is missing, never merely refuse.** A project that cannot be published and is not told why is indistinguishable from a broken one.
|
|
116
|
+
|
|
117
|
+
*Note for R04:* `platform_identity_projects` has `name NOT NULL` but **no `description` column** (only `tagline`). R04 adds it. Do not repurpose `tagline` — it is the card one-liner and a description is the publish bar; collapsing them means editing your card can unpublish your project.
|
|
118
|
+
|
|
119
|
+
## Decision 5 — Visibility is owned by the INSTANCE and mirrored to the hub
|
|
120
|
+
|
|
121
|
+
The hub's `platform_identity_projects` row is a **cache, never the source of truth.**
|
|
122
|
+
|
|
123
|
+
This follows from ADR 0141 §3 and the admin-console spike's D1 (*the instance IS the project; authority lives on the project instance*), and it resolves what otherwise looks like a gap: `owner_github_id` being "advisory, not an authority" is **correct**, not a hole to be filled. The hub never authorizes a visibility change; it accepts a report from the authenticated `sso_client` and stores it.
|
|
124
|
+
|
|
125
|
+
Two consequences that redirect seeded work:
|
|
126
|
+
|
|
127
|
+
1. **R05 (owner set/change visibility) is an INSTANCE surface**, not a hub one. The setting lives in the project's own hall settings, gated by the project's own ranks.
|
|
128
|
+
2. **R08 is the sync, not an afterthought.** A hub row whose visibility was never reported is stale, and stale here means *wrong on the public map*. R08's absent-report default must be **fail-closed: unreported ⇒ treated as not publishable (dark matter)**, so a project that has never spoken is off the map rather than exposed by omission.
|
|
129
|
+
|
|
130
|
+
The *trust* mechanics of that report — how the hub authenticates it, replay, rate — are **R02's** ([task 1002321](https://cloudbongos.com/builders#/task/1002321)), not this ADR's.
|
|
131
|
+
|
|
132
|
+
## Decision 6 — Per-state join rules, and how they compose with the join-policy setting
|
|
133
|
+
|
|
134
|
+
The applications *model* is already decided (`docs/specs/<redacted>.md` D2: extend `access_requests` with `kind ∈ ('application','invite')`, no new table). This ADR adds only the per-state rules on top:
|
|
135
|
+
|
|
136
|
+
| State | Self-join | Applications |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| public / planet | permitted | not needed |
|
|
139
|
+
| private / star | refused | accepted, owner reviews |
|
|
140
|
+
| stealth / black hole | refused | **refused at the door** (the public POST 403s) |
|
|
141
|
+
| dark matter | refused | refused — there is no door to knock on |
|
|
142
|
+
|
|
143
|
+
Stealth's distinction from private is **at the door, not in the queue**: a refused application is never stored, so a stealth project accumulates no queue to leak.
|
|
144
|
+
|
|
145
|
+
**Two knobs could contradict.** [task 1002817](https://cloudbongos.com/builders#/task/1002817) adds a per-project join policy (`open|closed`) at the same door. Rule: **visibility sets the ceiling; join policy may only narrow it.** A `closed` public project accepts no self-joins; an `open` stealth project still refuses everything. The stricter of the two always wins, and neither can widen the other. Without this, the two settings are a coin-flip decided by evaluation order.
|
|
146
|
+
|
|
147
|
+
## Decision 7 — The word `stealth` already means something else; product surfaces win, and the collision is tracked
|
|
148
|
+
|
|
149
|
+
`src/bongos/stealth-gate.js` + `STEALTH_PASSWORD` already mean *an instance-wide pre-launch password wall* — an entire instance made **unreadable**. Project `visibility = 'stealth'` means a project that is **on the public map, anonymously, refusing applications**. These are close to opposites, and ADR 0174 is the standing lesson that one word carrying two meanings costs more than a rename.
|
|
150
|
+
|
|
151
|
+
**Decision:** the *product* meaning (the owner-facing state, whose orb metaphor is locked by the criterion) keeps the word. The infra gate is the one that should be renamed — to `prelaunch` — but that touches a protected path, an env var, and a live instance's configuration, so it is **not** decided here by an ADR about visibility. It is filed as its own task with the owner's call attached.
|
|
152
|
+
|
|
153
|
+
Until then: `stealth` unqualified in product code and copy means the project state. The infra gate is referred to as the **pre-launch gate** in prose even while its identifier still says stealth.
|
|
154
|
+
|
|
155
|
+
## Consequences
|
|
156
|
+
|
|
157
|
+
- R04 lands `visibility` (3-value CHECK, default `public`, precedent `goals.visibility`) **and** the missing `description` column, plus the backfill. Existing rows keep today's behaviour: `visibility='public'`, publishable iff they already have a name and description.
|
|
158
|
+
- R06's feed predicate changes from `featured`-gated to `publishable + active`, with stealth rows redacted server-side. This is the single riskiest change in the goal — it is what actually moves control from Archon curation to the owner — and R10 is its proof.
|
|
159
|
+
- R05 moves host: instance-side settings, not a hub page.
|
|
160
|
+
- R08 defaults fail-closed on an unreported project.
|
|
161
|
+
- Anything reading `featured = true AND status = 'active'` as "is this public" is now wrong and must be found. `modules/platform-identity/routes/projects.js` is the known site.
|
|
162
|
+
|
|
163
|
+
## Alternatives rejected
|
|
164
|
+
|
|
165
|
+
- **A stored four-valued enum including `unlisted`.** Rejected: it makes "unlisted" a choice competing with `private`, and it lets a project be simultaneously "publishable" and "unlisted" — two sources of truth for one question, which is the bug the derived gate prevents by construction.
|
|
166
|
+
- **A separate `published` boolean.** Rejected for the same reason: a boolean can disagree with the identity it is supposed to summarise. Derived cannot drift.
|
|
167
|
+
- **Letting `featured` keep gating visibility, with owner visibility layered on top.** Rejected: an owner who sets `public` and appears nowhere until an Archon blesses them has not been given control, and the goal's premise is that they have.
|
|
168
|
+
- **Client-side stealth redaction.** Rejected: the orbs page is a static site outside this repo, so the guarantee would be unenforceable by construction.
|
package/docs/adr/README.md
CHANGED
|
@@ -255,5 +255,6 @@ This keeps the decision history honest and traceable.
|
|
|
255
255
|
| 0179 | [**`rank:metic+` means metic and above; a bare `rank:metic` still means exactly metic** ([task 1003094](https://cloudbongos.com/builders#/task/1003094), goal 1000069). [ADR 0175](<redacted>.md) gave the constitution ONE membership form, `rank:<key>`, resolved by an EXACT SQL match — so `rank:metic` seated metics ONLY (excluding Archons), `rank:xenos` seated NEWCOMERS ONLY rather than "everyone", and "Metic and above" was inexpressible. Everywhere else a rank is a LADDER and authority is cumulative (ADR 0034 inheritance, requireRank('metic','archon'), the floor-derived seed); board membership was the one place it meant "exactly", and nothing said so. Rehearsing R25 on a real Postgres, an Archon ratified `rank:metic` under monarchy — the apply worked perfectly — and the next vote came back 403 not_board_member: **the owner flipped the switch and fell off their own board**, with the board deadlocked at one member because an Archon can still PROPOSE but no longer VOTE. Owner decision: EXPLICIT GRAMMAR. `rank:metic+` (that rank and above), `rank:metic,archon` (union), and **a bare key still means EXACTLY that key** — rejecting the smaller diff (silently redefining the bare form) precisely because it would have changed the meaning of every already-ratified constitution, the monarchy default included, on upgrade: nothing in a government should change meaning without a vote. `+` is defined only on the STANDARD ladder — "and above" about a custom rank with no ladder position is a parse REFUSAL, not a guess, and a refusal seats nobody. The grammar had been written TWICE (a shape regex in the config sanitizer, a parse regex in the resolver, pinned by a property test) — sound for one literal form, unsound the moment a rule needs a LOOKUP, which is the same class of drift that produced the bug; both now call one pure `membership-predicate.js`. Adds the DISENFRANCHISEMENT GUARD: a proposal that would unseat its own proposer is refused before any write, naming the one-character fix, overridable with an explicit `acknowledge_self_removal` (a separate parameter, never a proposal field) because stepping back is a legitimate act. The two DB reads take a set via `= ANY($1)` + DISTINCT (a double-counted member silently raises the consent bar), the structural filters are re-proven against real Postgres (a deactivated builder and a machine principal still never govern), and the hall panel now describes every form in plain language — rendering `rank:metic+` as "the metic+ rank" would be the same bug one layer up. Unblocks task 1003095, which can now write each charter's TRUE predicate rather than wording around a limitation.](<redacted>.md) | government / the board |
|
|
256
256
|
| 0180 | [**Dependency intake & drift policy: baseline-ratchet audit gate, install scripts off, cooldown via patrol, OIDC publish** ([task 1003127](https://cloudbongos.com/builders#/task/1003127), goal 1000076). The red-team baseline audit found 18 advisories (2 high) sitting unwatched in 9 production deps, the `undici ^6.27.0` override pinned INSIDE a vulnerable range while also breaking Node 26 CLIs, and nothing gated what an agent may install — against a 2025 npm threat wave (chalk/debug, Shai-Hulud, Nx) that ran on postinstall scripts and long-lived publish tokens. Four decisions. (1) `scripts/gds/audit-gate.js` runs in the required `unit` check: a high/critical advisory NOT in the committed `config/audit-baseline.json` fails the merge gate; the baseline is **shrink-only pre-gate debt** (10 findings at adoption) — adding an entry to silence a NEW advisory is out of policy. Fail-OPEN on registry/infra errors, fail-CLOSED on findings: the gate catches new advisories, it does not prove registry uptime. Notably a blanket `npm audit fix` cannot even run here (`workspace:` protocol, EUNSUPPORTEDPROTOCOL) — fixes are explicit tasks. (2) `.npmrc ignore-scripts=true`: the tree needs no install-lifecycle scripts — sharp installs prebuilds via optionalDependencies, proven by a script-less `npm ci` + full 430-test suite; a future dep needing one is an ADR-level exception. (3) Update cooldown is PATROL-enforced (task 1003128 flags versions younger than 7 days + stale overrides + action-pin drift) rather than `.npmrc`-enforced, because CI's npm 10 warns on the npm-11 `minimum-release-age` key for every builder; move it into `.npmrc` when the toolchain floor reaches npm ≥ 11.10. (4) Publish auth moves to npm **trusted publishing (OIDC)** — needs a one-time owner registration on npmjs.com (blocker filed); until then the granular 90-day `NPM_TOKEN` is a documented exception.](<redacted>.md) | devsecops / supply chain |
|
|
257
257
|
| 0181 | [**Teardown accepts every state but `torn_down`, and deliberately keeps the address** ([task 1003042](https://cloudbongos.com/builders#/task/1003042), goal 1000058). Walk finding N5: an instance at `status='error'` could never be removed — the owner's teardown answered 409 `not_teardownable` and the archon `force-teardown`, which exists as the escape hatch, answered the SAME refusal, because both read one hand-kept whitelist `['provisioning','active','tearing_down']` that omitted `requested` and `error`. No role had a path out, so errored rows accumulated permanently (instance 15 `swag` from 2026-08-07). The whitelist justified itself as "nothing running to tear down", which is FALSE for `error`: a provision failing mid-run lands there AFTER it may have created the database, taken a port, and written the systemd unit, Caddy block and DNS record — a partial standup is the thing most in need of reclaiming. `TEARDOWN_FROM` is now DERIVED from `INSTANCE_STATES` minus `torn_down`, so a future state is teardownable by DEFAULT — the bug was an allow-list that silently omitted states, and for a failure mode whose signature is "a row with no exit", the safe default is that an exit exists. The runner needed no change (its steps are each `allowFail`); only the web guard refused. The one surviving refusal is now ONE shared helper: the copies had drifted, and force-teardown's positional `res.fail` form put the bare code `not_teardownable` on the wire as the human text. **The `port` and `domain` are deliberately NOT released** — releasing the port alone would be WORSE than the status quo, because the `<slug>.caddy` block survives teardown and proxies the hostname to a PORT NUMBER, so a later instance given that port would answer at the torn-down project's still-live address (verified live: two projects torn down 2026-08-13 still resolved on 2026-08-19). Holding the port is what keeps the address inert at a harmless 502; releasing both is [task 1002897](https://cloudbongos.com/builders#/task/1002897). Retention is also correct for revive, which re-uses the same hostname. Copy was corrected to match: it had promised "the address stops answering", which was never true.](0181-teardown-state-gate-and-address-retention.md) | provisioning / lifecycle |
|
|
258
|
+
| 0182 | [**Project visibility is TWO axes: a derived publish gate and a stored join door** ([task 1002320](https://cloudbongos.com/builders#/task/1002320), goal 1000046). Goal 1000046 seeded 31 tasks each citing "per R01" — this ADR — so nothing in the goal could start until it landed: it gated **29 open tasks**, the largest single chokepoint in the repo, while itself parked at `backlog` with no dependencies. The spec its planning task cites was never written, so this is the design of record. The goal's criterion says **four** states (Public/Private/Stealth/Unlisted) and R04 says **three** stored plus a derived dark-matter; both are right and conflating them is the trap. There are two INDEPENDENT axes: **publishability** (DERIVED from the identity gate — name + description, per the owner interview) decides whether a project is on the map at all, and **the join door** (STORED `visibility ∈ public|private|stealth`, owner-set) decides how it renders and who gets in. Four user-facing states = 3 × publishable + one derived state that collapses all three. The column name `visibility` is a mild lie kept for consistency with `goals.visibility` (ADR 0112) — it does NOT decide visibility, publishability does — and the ADR is the mitigation. All three stored states are VISIBLE; only the derived state is invisible, which is what makes the 3+1 split honest rather than a workaround. `private` inherits ADR 0112's exact meaning (visible-but-closed); `stealth` exposes EXISTENCE but not IDENTITY, and its redaction is **server-side in the feed** — the naive client-side version leaks to anyone opening the network tab, and the orbs page is a static site OUTSIDE this repo (R09) so it could never be enforced there. Three mechanisms touch "does this appear" and are separated: `status` (operational), `visibility` (owner), `featured` (Archon editorial) — on the map iff `status='active' AND publishable`, with `featured` only ranking among those. That is a real behaviour change: today's predicate is `featured=true AND status='active'`, so **featuring is currently load-bearing for visibility at all** and the goal's owner-control premise silently does not work without it. Visibility is owned by the INSTANCE and the hub row is a CACHE (ADR 0141 §3 + the admin-console spike's D1) — so `owner_github_id` being "advisory, not an authority" is CORRECT rather than a gap, R05 moves to an instance surface, and R08's absent-report default is fail-closed (unreported ⇒ dark matter, off the map rather than exposed by omission). Per-state join rules compose with the separate `open|closed` join policy ([task 1002817](https://cloudbongos.com/builders#/task/1002817)) by one rule: **visibility sets the ceiling, join policy may only narrow** — otherwise the two settings are a coin-flip decided by evaluation order. Finally, `stealth` COLLIDES with the existing instance-wide pre-launch password gate (`STEALTH_PASSWORD`, `src/bongos/stealth-gate.js`), which means nearly the opposite (a whole instance made unreadable vs a project publicly on the map, anonymously); per ADR 0174 the product meaning keeps the word and the infra rename is filed separately rather than decided by an ADR about visibility. Rejected: a stored 4-valued enum (makes `unlisted` compete with `private`, and lets publishable+unlisted disagree), a separate `published` boolean (can drift from the identity it summarises; derived cannot), and keeping `featured` as the visibility gate (an owner who sets public and appears nowhere has not been given control).](<redacted>.md) | platform-identity / project visibility |
|
|
258
259
|
|
|
259
260
|
> ⚠️ **Numbering collision (known):** two ADRs share `0008`. The numbers were assigned in parallel sessions before the lock could be enforced. The files are kept under their existing filenames to preserve git history, but the table disambiguates them as `0008-a` / `0008-b`. New ADRs should resume at `0040` to avoid further collisions. (`0024` is also a real on-disk duplicate: the cloneable-repo/local-first-memory ADR and the multi-agent-system-architecture ADR were both numbered `0024` in parallel; both keep their filenames, disambiguated as `0024-a` / `0024-b` like `0008`. Likewise `0025` ended up with two on-disk files — the offsite-backup ADR and the structured-criterion↔task-link ADR — both kept under their existing filenames and disambiguated as `0025-a` / `0025-b`; separately, the BFG ADR had also claimed `0025` on 2026-05-30 and yielded to `0026`. A third happened 2026-06-06: `0036` was claimed in parallel by the builders-subdomain ADR ([#726](https://example.com/builders#/task/726)) and this Discord-channels ADR ([#727](https://example.com/builders#/task/727)); the Discord-channels ADR yielded to `0037`. A fourth landed 2026-06-10: `0044` was claimed in parallel by the palette-replacement ADR and the per-box game-preview ADR ([#897](https://example.com/builders#/task/897)); both keep their filenames, disambiguated as `0044-a` / `0044-b` like `0008`. A fifth was caught pre-land 2026-06-13: `0050` was claimed in parallel by the device-flow-admission ADR ([#1000](https://example.com/builders#/task/1000)) and the sandbox-for-everyone ADR ([#1001](https://example.com/builders#/task/1001)); the latter yielded to `0052` before merging, so there is no `0050` duplicate. A sixth was caught pre-land 2026-06-21: the tool-agnostic-design-layer ADR ([#1375](https://example.com/builders#/task/1375)) first collided at `0079` with the value-gated-autonomous-engagement ADR, then at `0080` with the llm-cache-api-transport ADR (both part of the 0075–0080 LLM-cost-reduction series, landed on `main` in parallel); it yielded to `0081` before merging, so there is no `0079`/`0080` design-layer duplicate. A seventh landed 2026-06-23: `0084` was claimed in parallel by the auto-derived-per-task-rank-floor ADR and the remove-default-spend-cap ADR (task 1499); the rank-floor ADR landed on `main` first, so the spend-cap ADR yielded to `0085`, leaving no `0084` duplicate. An eighth landed 2026-06-27: `0095` was claimed in parallel by the borrowed-memory-and-retrieval-concepts ADR (PR #459, landed first) and the cross-agent-context-management ADR ([#1651](https://example.com/builders#/task/1651), PR #460); both keep their filenames, disambiguated as `0095-a` / `0095-b` like `0008`. These two are companions — `0095-a` adopts the memory/retrieval concepts and explicitly defers the grep-vs-semantic question to `0095-b`.)
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// modules/lifecycle/claim-feed.js — shaping + gating helpers for the claimable
|
|
4
|
+
// feed and the two claim paths, carved out of the oversized db.js (task 1003137;
|
|
5
|
+
// the fitness excess-lines ratchet is why these live here and not inline).
|
|
6
|
+
//
|
|
7
|
+
// Three residents, two halves of one rule plus a feed cap:
|
|
8
|
+
//
|
|
9
|
+
// - goalMembershipFailures — the CLAIM-time goal-membership gate (task
|
|
10
|
+
// 1003137, owner ruling 2026-08-19: a task that lives in a goal is
|
|
11
|
+
// claimable only by that goal's members — every goal, catch-alls included).
|
|
12
|
+
// EXTRACTED so BOTH `INSERT INTO claims` sites (db.claimTask and
|
|
13
|
+
// db.claimTasksBatch — the batch path duplicates claimTask's gates one by
|
|
14
|
+
// one, so an inline-only gate would be trivially bypassable via
|
|
15
|
+
// /claims/batch) run the identical check. The DECISION itself is the pure
|
|
16
|
+
// goal-authz.goalMembershipClaimRefusal; this wrapper only fetches the
|
|
17
|
+
// goal + membership facts on the caller's open txn client.
|
|
18
|
+
// - decorateGoalMembership — the FEED half of the same rule (owner chose
|
|
19
|
+
// filter-plus-show-as-joinable): a ready task whose goal the builder has
|
|
20
|
+
// not joined is never silently advertised as claimable — the exact trap
|
|
21
|
+
// task 1002650 closed for open blockers. The row stays in the feed but
|
|
22
|
+
// carries goal_membership { required, goal_id, visibility, action } so the
|
|
23
|
+
// caller renders it joinable. Reuses the SAME pure refusal fn, so feed and
|
|
24
|
+
// gate cannot disagree on join-vs-apply or on the leak rule (a private
|
|
25
|
+
// goal's title/scope never leave the server).
|
|
26
|
+
// - capNewcomerTasks — the newcomer-chore display cap (task 1266), moved
|
|
27
|
+
// verbatim from db.js.
|
|
28
|
+
//
|
|
29
|
+
// db.js re-exports all three, so callers and tests keep their import site.
|
|
30
|
+
|
|
31
|
+
// Pure kernel-adjacent matcher via the doorway (never the core file); the pure
|
|
32
|
+
// membership decision from the authority-model sibling.
|
|
33
|
+
const api = require('../../src/module-api');
|
|
34
|
+
const { scopeIncludesProtected } = api.moduleScopeMap;
|
|
35
|
+
const { goalMembershipClaimRefusal } = require('./goal-authz.js');
|
|
36
|
+
|
|
37
|
+
// The claim-txn half. `tasks` rows need { id, goal_id }; goal_id NULL rows are
|
|
38
|
+
// skipped (nullable by migration 160 — a NULL goal has no membership to check;
|
|
39
|
+
// a dangling goal_id can't occur, tasks.goal_id is FK'd). An Archon passes as
|
|
40
|
+
// the implicit member (the isMemberOrArchon convention). Runs on the caller's
|
|
41
|
+
// open txn `client` so the read shares the claim transaction's snapshot.
|
|
42
|
+
// Returns [{ task_id, refusal }] — empty when every task is claimable.
|
|
43
|
+
async function goalMembershipFailures({ client, tasks, builderId, builderRank }) {
|
|
44
|
+
const gated = tasks.filter((t) => t.goal_id != null);
|
|
45
|
+
if (gated.length === 0 || builderRank === 'archon') return [];
|
|
46
|
+
const goalIds = Array.from(new Set(gated.map((t) => Number(t.goal_id))));
|
|
47
|
+
const { rows: goalRows } = await client.query(
|
|
48
|
+
`SELECT g.id, g.title, g.visibility, g.scope_modules,
|
|
49
|
+
EXISTS (SELECT 1 FROM goal_members gm
|
|
50
|
+
WHERE gm.goal_id = g.id AND gm.builder_id = $2) AS is_member
|
|
51
|
+
FROM goals g
|
|
52
|
+
WHERE g.id = ANY($1::bigint[])`,
|
|
53
|
+
[goalIds, builderId]
|
|
54
|
+
);
|
|
55
|
+
const byId = new Map(goalRows.map((r) => [Number(r.id), r]));
|
|
56
|
+
const failures = [];
|
|
57
|
+
for (const t of gated) {
|
|
58
|
+
const goal = byId.get(Number(t.goal_id)) ?? null;
|
|
59
|
+
const refusal = goalMembershipClaimRefusal({
|
|
60
|
+
goal,
|
|
61
|
+
isMember: goal ? goal.is_member === true : false,
|
|
62
|
+
actorRank: builderRank,
|
|
63
|
+
scopeProtected: goal ? scopeIncludesProtected(goal.scope_modules) : false,
|
|
64
|
+
});
|
|
65
|
+
if (refusal) failures.push({ task_id: Number(t.id), refusal });
|
|
66
|
+
}
|
|
67
|
+
return failures;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// The feed half. Consumes (and strips) the g_* scratch columns db.js's
|
|
71
|
+
// LEFT JOIN rides along; member / Archon / goal-less rows pass through shaped
|
|
72
|
+
// exactly as before task 1003137. The SQL folds "Archon" into g_is_member, so
|
|
73
|
+
// actorRank is passed null here — membership is the only remaining question.
|
|
74
|
+
function decorateGoalMembership(row) {
|
|
75
|
+
const { g_visibility, g_scope_modules, g_title, g_is_member, ...task } = row;
|
|
76
|
+
if (task.goal_id == null || g_visibility == null) return task; // no goal → not gated
|
|
77
|
+
const refusal = goalMembershipClaimRefusal({
|
|
78
|
+
goal: { id: task.goal_id, title: g_title, visibility: g_visibility },
|
|
79
|
+
isMember: g_is_member === true,
|
|
80
|
+
actorRank: null,
|
|
81
|
+
scopeProtected: scopeIncludesProtected(g_scope_modules),
|
|
82
|
+
});
|
|
83
|
+
if (!refusal) return task; // member/Archon → as today
|
|
84
|
+
return {
|
|
85
|
+
...task,
|
|
86
|
+
goal_membership: {
|
|
87
|
+
required: true,
|
|
88
|
+
goal_id: refusal.goal_id,
|
|
89
|
+
visibility: refusal.visibility,
|
|
90
|
+
action: refusal.action,
|
|
91
|
+
...('goal_title' in refusal ? { goal_title: refusal.goal_title } : {}),
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Cap the number of newcomer_friendly rows in a claimable feed to `cap`
|
|
97
|
+
// (task 1266). Pure + exported for unit testing. Non-newcomer (real version)
|
|
98
|
+
// rows pass through untouched and unbounded. When newcomer rows exceed the cap
|
|
99
|
+
// they're selected round-robin across the disciplines PRESENT among them — so
|
|
100
|
+
// each of the builder's lanes is represented before a slot goes to a duplicate
|
|
101
|
+
// of an already-shown discipline. Input ordering (priority, est, created) is
|
|
102
|
+
// preserved: we compute a keep-set of ids and then filter the original array.
|
|
103
|
+
function capNewcomerTasks(rows, cap = 3) {
|
|
104
|
+
const all = Array.isArray(rows) ? rows : [];
|
|
105
|
+
const newcomer = all.filter((t) => t && t.newcomer_friendly === true);
|
|
106
|
+
if (newcomer.length <= cap) return all;
|
|
107
|
+
|
|
108
|
+
// Group newcomer rows by discipline, preserving (a) input order within each
|
|
109
|
+
// group and (b) first-appearance order of the groups themselves — so the
|
|
110
|
+
// highest-priority discipline's chore is picked first.
|
|
111
|
+
const groups = new Map(); // discipline -> [rows], insertion-ordered
|
|
112
|
+
for (const t of newcomer) {
|
|
113
|
+
const disc = t.discipline || 'unclassified';
|
|
114
|
+
if (!groups.has(disc)) groups.set(disc, []);
|
|
115
|
+
groups.get(disc).push(t);
|
|
116
|
+
}
|
|
117
|
+
const lists = Array.from(groups.values());
|
|
118
|
+
|
|
119
|
+
// Round-robin: take index 0 from each group, then index 1, etc., until we've
|
|
120
|
+
// kept `cap` rows. Duplicate disciplines fill later passes once each lane has
|
|
121
|
+
// been represented.
|
|
122
|
+
const keep = new Set();
|
|
123
|
+
let depth = 0;
|
|
124
|
+
let progressed = true;
|
|
125
|
+
while (keep.size < cap && progressed) {
|
|
126
|
+
progressed = false;
|
|
127
|
+
for (const list of lists) {
|
|
128
|
+
if (depth < list.length) {
|
|
129
|
+
keep.add(list[depth].id);
|
|
130
|
+
progressed = true;
|
|
131
|
+
if (keep.size >= cap) break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
depth += 1;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Filter the original (ordered) array: every non-newcomer row, plus the kept
|
|
138
|
+
// newcomer rows. Preserves the original feed ordering.
|
|
139
|
+
return all.filter((t) => t.newcomer_friendly !== true || keep.has(t.id));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
module.exports = { goalMembershipFailures, decorateGoalMembership, capNewcomerTasks };
|
package/modules/lifecycle/db.js
CHANGED
|
@@ -46,6 +46,9 @@ const { claimEligibilityAllows, CLAIM_ANY, CLAIM_NEWCOMER } = require('./claim-e
|
|
|
46
46
|
// Pure kernel-adjacent matchers via the doorway (never the core file).
|
|
47
47
|
const { matchProtected } = api.permissionPathCheck;
|
|
48
48
|
const { touchesOverlap } = api.pathMatch;
|
|
49
|
+
// Claimable-feed shaping + the goal-membership claim gate (task 1003137; the
|
|
50
|
+
// newcomer cap of task 1266 moved there too) — see claim-feed.js.
|
|
51
|
+
const { goalMembershipFailures, decorateGoalMembership, capNewcomerTasks } = require('./claim-feed.js');
|
|
49
52
|
|
|
50
53
|
|
|
51
54
|
// ---------------------------------------------------------------------------
|
|
@@ -1923,6 +1926,8 @@ const SESSION_FIT_SQL = `
|
|
|
1923
1926
|
async function listClaimableTasks({ versionId = null, builderId = null, discipline = null, fit = null } = {}) {
|
|
1924
1927
|
const params = [];
|
|
1925
1928
|
const where = [];
|
|
1929
|
+
let goalJoin = '';
|
|
1930
|
+
let selectCols = 'v.*';
|
|
1926
1931
|
if (versionId) {
|
|
1927
1932
|
params.push(versionId);
|
|
1928
1933
|
where.push(`v.version_id = $${params.length}`);
|
|
@@ -1971,6 +1976,16 @@ async function listClaimableTasks({ versionId = null, builderId = null, discipli
|
|
|
1971
1976
|
WHEN 'archon' THEN 4 WHEN 'metic' THEN 3 WHEN 'thetes' THEN 2 WHEN 'xenos' THEN 1 ELSE 0
|
|
1972
1977
|
END
|
|
1973
1978
|
)`);
|
|
1979
|
+
// task 1003137: ride the goal + own-membership facts along so
|
|
1980
|
+
// decorateGoalMembership (claim-feed.js) can flag non-member rows joinable.
|
|
1981
|
+
// Same parameter index — all three reads are the same builderId. The
|
|
1982
|
+
// goal_members PK (goal_id, builder_id) means the LEFT JOIN never
|
|
1983
|
+
// multiplies rows; an Archon reads as member (isMemberOrArchon convention).
|
|
1984
|
+
goalJoin = ` LEFT JOIN goals g ON g.id = v.goal_id
|
|
1985
|
+
LEFT JOIN goal_members gm ON gm.goal_id = g.id AND gm.builder_id = $${params.length}`;
|
|
1986
|
+
selectCols = `v.*, g.visibility AS g_visibility, g.scope_modules AS g_scope_modules, g.title AS g_title,
|
|
1987
|
+
(gm.builder_id IS NOT NULL
|
|
1988
|
+
OR (SELECT rank FROM builders WHERE id = $${params.length}) = 'archon') AS g_is_member`;
|
|
1974
1989
|
}
|
|
1975
1990
|
// Autonomy / parallel-eligibility filter. Joining the session-fit relation
|
|
1976
1991
|
// (also a SELECT t.* shape) makes bare column names like priority/created_at
|
|
@@ -1988,12 +2003,14 @@ async function listClaimableTasks({ versionId = null, builderId = null, discipli
|
|
|
1988
2003
|
// recent actuals; ordering on the raw estimate puts oversized tasks at the
|
|
1989
2004
|
// bottom even when their actual time-to-ship is short. See migration 015.
|
|
1990
2005
|
const sql =
|
|
1991
|
-
`SELECT
|
|
2006
|
+
`SELECT ${selectCols} FROM (${CLAIMABLE_SQL}) v` + goalJoin + fitJoin +
|
|
1992
2007
|
(where.length ? ` WHERE ${where.join(' AND ')}` : '') +
|
|
1993
2008
|
` ORDER BY v.priority NULLS LAST,
|
|
1994
2009
|
COALESCE(v.est_minutes_calibrated, v.est_minutes) NULLS LAST,
|
|
1995
2010
|
v.created_at`;
|
|
1996
|
-
const { rows } = await pool.query(sql, params);
|
|
2011
|
+
const { rows: rawRows } = await pool.query(sql, params);
|
|
2012
|
+
// task 1003137: strip g_* scratch columns, flag non-member rows joinable.
|
|
2013
|
+
const rows = rawRows.map(decorateGoalMembership);
|
|
1997
2014
|
// SR-12 / G2 (task 994): when the autonomous/parallel runner is asking, drop
|
|
1998
2015
|
// any task whose declared touches[] reach the permission/methodology/deploy
|
|
1999
2016
|
// core. The runner ships as Archon straight to main, so these must never be
|
|
@@ -2002,7 +2019,12 @@ async function listClaimableTasks({ versionId = null, builderId = null, discipli
|
|
|
2002
2019
|
// with the grader pre-pass, pre-push hook, and main-audit — no second source
|
|
2003
2020
|
// of truth to drift.
|
|
2004
2021
|
if (fit === 'autonomous' || fit === 'parallel') {
|
|
2005
|
-
|
|
2022
|
+
// task 1003137: membership-required rows are DROPPED, not flagged — the
|
|
2023
|
+
// claim gate will refuse them and an autonomous runner can't answer a join
|
|
2024
|
+
// prompt. (No builderId → no membership facts; the claim gate stays the
|
|
2025
|
+
// hard control.)
|
|
2026
|
+
return rows.filter((t) => !taskTouchesProtectedPath(t)
|
|
2027
|
+
&& !(t.goal_membership && t.goal_membership.required === true));
|
|
2006
2028
|
}
|
|
2007
2029
|
// Newcomer-chore display cap (task 1266, owner decision 2026-06-19). The
|
|
2008
2030
|
// newcomer-floor keeps a deep supply pool (floor: 3 artist + 2 ideator) so
|
|
@@ -2017,53 +2039,6 @@ async function listClaimableTasks({ versionId = null, builderId = null, discipli
|
|
|
2017
2039
|
return capNewcomerTasks(rows);
|
|
2018
2040
|
}
|
|
2019
2041
|
|
|
2020
|
-
// Cap the number of newcomer_friendly rows in a claimable feed to `cap`
|
|
2021
|
-
// (task 1266). Pure + exported for unit testing. Non-newcomer (real version)
|
|
2022
|
-
// rows pass through untouched and unbounded. When newcomer rows exceed the cap
|
|
2023
|
-
// they're selected round-robin across the disciplines PRESENT among them — so
|
|
2024
|
-
// each of the builder's lanes is represented before a slot goes to a duplicate
|
|
2025
|
-
// of an already-shown discipline. Input ordering (priority, est, created) is
|
|
2026
|
-
// preserved: we compute a keep-set of ids and then filter the original array.
|
|
2027
|
-
|
|
2028
|
-
function capNewcomerTasks(rows, cap = 3) {
|
|
2029
|
-
const all = Array.isArray(rows) ? rows : [];
|
|
2030
|
-
const newcomer = all.filter((t) => t && t.newcomer_friendly === true);
|
|
2031
|
-
if (newcomer.length <= cap) return all;
|
|
2032
|
-
|
|
2033
|
-
// Group newcomer rows by discipline, preserving (a) input order within each
|
|
2034
|
-
// group and (b) first-appearance order of the groups themselves — so the
|
|
2035
|
-
// highest-priority discipline's chore is picked first.
|
|
2036
|
-
const groups = new Map(); // discipline -> [rows], insertion-ordered
|
|
2037
|
-
for (const t of newcomer) {
|
|
2038
|
-
const disc = t.discipline || 'unclassified';
|
|
2039
|
-
if (!groups.has(disc)) groups.set(disc, []);
|
|
2040
|
-
groups.get(disc).push(t);
|
|
2041
|
-
}
|
|
2042
|
-
const lists = Array.from(groups.values());
|
|
2043
|
-
|
|
2044
|
-
// Round-robin: take index 0 from each group, then index 1, etc., until we've
|
|
2045
|
-
// kept `cap` rows. Duplicate disciplines fill later passes once each lane has
|
|
2046
|
-
// been represented.
|
|
2047
|
-
const keep = new Set();
|
|
2048
|
-
let depth = 0;
|
|
2049
|
-
let progressed = true;
|
|
2050
|
-
while (keep.size < cap && progressed) {
|
|
2051
|
-
progressed = false;
|
|
2052
|
-
for (const list of lists) {
|
|
2053
|
-
if (depth < list.length) {
|
|
2054
|
-
keep.add(list[depth].id);
|
|
2055
|
-
progressed = true;
|
|
2056
|
-
if (keep.size >= cap) break;
|
|
2057
|
-
}
|
|
2058
|
-
}
|
|
2059
|
-
depth += 1;
|
|
2060
|
-
}
|
|
2061
|
-
|
|
2062
|
-
// Filter the original (ordered) array: every non-newcomer row, plus the kept
|
|
2063
|
-
// newcomer rows. Preserves the original feed ordering.
|
|
2064
|
-
return all.filter((t) => t.newcomer_friendly !== true || keep.has(t.id));
|
|
2065
|
-
}
|
|
2066
|
-
|
|
2067
2042
|
// SR-12 / G2 (task 994): does this task's declared touches[] overlap any
|
|
2068
2043
|
// permission-sensitive (ADR 0043) path? Pure + exported for unit testing.
|
|
2069
2044
|
// Returns true if ANY declared touch matches a protected glob — such a task is
|
|
@@ -2659,7 +2634,7 @@ async function claimTask({ taskId, builderId, worktreeName, headSha, creatorSess
|
|
|
2659
2634
|
}
|
|
2660
2635
|
|
|
2661
2636
|
const { rows: taskRows } = await client.query(
|
|
2662
|
-
`SELECT id, status, touches, newcomer_friendly, requires_rank, needs_migration, module_key, credits_reward, reward_gate_exempt, est_minutes, kind FROM tasks WHERE id = $1 FOR UPDATE`,
|
|
2637
|
+
`SELECT id, status, touches, newcomer_friendly, requires_rank, needs_migration, module_key, credits_reward, reward_gate_exempt, est_minutes, kind, goal_id FROM tasks WHERE id = $1 FOR UPDATE`,
|
|
2663
2638
|
[taskId]
|
|
2664
2639
|
);
|
|
2665
2640
|
if (taskRows.length === 0) {
|
|
@@ -2730,6 +2705,15 @@ async function claimTask({ taskId, builderId, worktreeName, headSha, creatorSess
|
|
|
2730
2705
|
};
|
|
2731
2706
|
}
|
|
2732
2707
|
|
|
2708
|
+
// task 1003137 (owner ruling 2026-08-19): a task's goal requires MEMBERSHIP —
|
|
2709
|
+
// every goal, catch-alls included; goal_id NULL is NOT gated. After the rank
|
|
2710
|
+
// gates (membership only narrows — it must never mask a rank refusal),
|
|
2711
|
+
// before deps. Decision + leak rule: goal-authz.goalMembershipClaimRefusal;
|
|
2712
|
+
// the SAME extracted check runs in claimTasksBatch (the only other INSERT
|
|
2713
|
+
// INTO claims site) — see claim-feed.js.
|
|
2714
|
+
const goalRefusals = await goalMembershipFailures({ client, tasks: [task], builderId, builderRank });
|
|
2715
|
+
if (goalRefusals.length > 0) throw goalRefusals[0].refusal;
|
|
2716
|
+
|
|
2733
2717
|
// The claim gate (ADR 0015, generalized in task 1516 / ADR 0086 §5): a task
|
|
2734
2718
|
// can't be claimed while any dependency is un-done — its OWN edges plus those
|
|
2735
2719
|
// inherited from its goal/criteria, where "done" = task shipped | criterion
|
|
@@ -2986,7 +2970,7 @@ async function claimTasksBatch({ taskIds, builderId, worktreePrefix, creatorSess
|
|
|
2986
2970
|
|
|
2987
2971
|
// Lock every requested task row up front (sorted to avoid deadlocks).
|
|
2988
2972
|
const { rows: taskRows } = await client.query(
|
|
2989
|
-
`SELECT id, status, touches, newcomer_friendly, requires_rank, needs_migration, module_key FROM tasks WHERE id = ANY($1::bigint[]) ORDER BY id FOR UPDATE`,
|
|
2973
|
+
`SELECT id, status, touches, newcomer_friendly, requires_rank, needs_migration, module_key, goal_id FROM tasks WHERE id = ANY($1::bigint[]) ORDER BY id FOR UPDATE`,
|
|
2990
2974
|
[uniqIds]
|
|
2991
2975
|
);
|
|
2992
2976
|
|
|
@@ -3069,6 +3053,14 @@ async function claimTasksBatch({ taskIds, builderId, worktreePrefix, creatorSess
|
|
|
3069
3053
|
}
|
|
3070
3054
|
}
|
|
3071
3055
|
|
|
3056
|
+
// task 1003137: the SAME extracted goal-membership gate as claimTask — this
|
|
3057
|
+
// path owns the repo's only other INSERT INTO claims, so an inline-only gate
|
|
3058
|
+
// would be bypassable via batch. Same ladder position: after rank, before deps.
|
|
3059
|
+
for (const f of await goalMembershipFailures({ client, tasks: taskRows, builderId, builderRank })) {
|
|
3060
|
+
const { code, ...rest } = f.refusal;
|
|
3061
|
+
failures.push({ task_id: f.task_id, reason: code, ...rest });
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3072
3064
|
// Per-task dependency check (ADR 0015, generalized task 1516). An EXTERNAL dep
|
|
3073
3065
|
// (not in this batch) must already be done; a batch-internal dep isn't done yet
|
|
3074
3066
|
// at claim time but doesn't block — the batch is worked serially. "Internal"
|
|
@@ -3351,7 +3343,7 @@ async function validateClaimBatch({ taskIds, builderId }) {
|
|
|
3351
3343
|
const builderRank = builderRows[0] ? builderRows[0].rank : null;
|
|
3352
3344
|
|
|
3353
3345
|
const { rows: taskRows } = await pool.query(
|
|
3354
|
-
`SELECT id, status, touches, newcomer_friendly, requires_rank, module_key
|
|
3346
|
+
`SELECT id, status, touches, newcomer_friendly, requires_rank, module_key, goal_id
|
|
3355
3347
|
FROM tasks WHERE id = ANY($1::bigint[])`,
|
|
3356
3348
|
[uniqIds]
|
|
3357
3349
|
);
|
|
@@ -3393,6 +3385,12 @@ async function validateClaimBatch({ taskIds, builderId }) {
|
|
|
3393
3385
|
}
|
|
3394
3386
|
}
|
|
3395
3387
|
|
|
3388
|
+
// task 1003137: goal-membership, kept in sync with claimTasksBatch (see claim-feed.js).
|
|
3389
|
+
for (const f of await goalMembershipFailures({ client: pool, tasks: taskRows, builderId, builderRank })) {
|
|
3390
|
+
const { code, ...rest } = f.refusal;
|
|
3391
|
+
push(f.task_id, { reason: code, ...rest });
|
|
3392
|
+
}
|
|
3393
|
+
|
|
3396
3394
|
// Dependencies — external to the batch only (a batch-internal dep is fine;
|
|
3397
3395
|
// the batch is worked serially, same rule as claimTasksBatch).
|
|
3398
3396
|
const batchIdSet = new Set(uniqIds);
|
|
@@ -5688,6 +5686,7 @@ module.exports = {
|
|
|
5688
5686
|
listClaimableTasks,
|
|
5689
5687
|
capNewcomerTasks,
|
|
5690
5688
|
taskTouchesProtectedPath, // SR-12 / G2 (task 994): autonomous-fit protected-path exclusion (pure, testable)
|
|
5689
|
+
decorateGoalMembership, // task 1003137: feed-side joinable flag (pure, testable)
|
|
5691
5690
|
rankCrossDisciplineRecommendations,
|
|
5692
5691
|
listActiveClaims,
|
|
5693
5692
|
updateTaskStatus,
|
|
@@ -62,4 +62,59 @@ function authorizeGoalManagement({ goal, actorId, actorRank, actorMembership })
|
|
|
62
62
|
return { ok: true };
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
// goalMembershipClaimRefusal — the CLAIM-time membership gate (task 1003137).
|
|
66
|
+
// Owner ruling 2026-08-19: a task that lives in a goal is claimable only by that
|
|
67
|
+
// goal's members — EVERY goal, the '<version> — general' catch-alls included.
|
|
68
|
+
// Safe precisely because the refusal is actionable in-session: joining a public
|
|
69
|
+
// goal costs one 'yes' (POST /goals/:id/join), a private/protected one an
|
|
70
|
+
// application (POST /goals/:id/requests).
|
|
71
|
+
//
|
|
72
|
+
// Returns null when the claim may proceed, else the refusal payload the claim
|
|
73
|
+
// paths throw (code GOAL_MEMBERSHIP_REQUIRED, HTTP 403 at the route). PURE —
|
|
74
|
+
// both INSERT INTO claims sites (claimTask + claimTasksBatch, db.js) feed it
|
|
75
|
+
// through db.goalMembershipFailures so the batch path cannot drift from the
|
|
76
|
+
// single-claim path.
|
|
77
|
+
//
|
|
78
|
+
// The decision, in order (fail-closed on the membership question itself):
|
|
79
|
+
// - no goal → not gated. tasks.goal_id is NULLABLE (migration 160) and every
|
|
80
|
+
// version created after it gets no catch-all, so goal_id IS NULL is COMMON —
|
|
81
|
+
// a NULL goal has no membership to check. (A dangling goal_id can't occur:
|
|
82
|
+
// tasks.goal_id is FK'd to goals(id).)
|
|
83
|
+
// - Archon → pass. An Archon is an implicit member everywhere in the goal
|
|
84
|
+
// surface (isMemberOrArchon, POST /goals/:id/join, isGoalOwnerOrManager);
|
|
85
|
+
// the claim gate follows that single convention rather than minting a
|
|
86
|
+
// second membership model. Membership only NARROWS what the rank gates
|
|
87
|
+
// (which run before this in claimTask's ladder) already allow — it never
|
|
88
|
+
// widens what a Xenos reaches.
|
|
89
|
+
// - member → pass.
|
|
90
|
+
// - else refuse, naming the action: 'join' for a public unprotected goal,
|
|
91
|
+
// 'apply' for a private one OR a protected-scope one (self-join on
|
|
92
|
+
// protected scope is Archon-mediated — routes/goals.js POST /:id/join).
|
|
93
|
+
//
|
|
94
|
+
// LEAK RULE (the goal_abuse_matrix ordering discipline, gotcha d): a PRIVATE
|
|
95
|
+
// goal's refusal carries goal_id, visibility and the action ONLY — never the
|
|
96
|
+
// title, never scope. A public goal's title is public; it rides along so the
|
|
97
|
+
// CLI can name what to join.
|
|
98
|
+
function goalMembershipClaimRefusal({ goal, isMember, actorRank, scopeProtected }) {
|
|
99
|
+
if (!goal) return null; // goal_id NULL — no membership to check, NOT gated
|
|
100
|
+
if (actorRank === 'archon') return null;
|
|
101
|
+
if (isMember) return null;
|
|
102
|
+
const isPrivate = goal.visibility === 'private';
|
|
103
|
+
const action = (isPrivate || scopeProtected === true) ? 'apply' : 'join';
|
|
104
|
+
const goalId = Number(goal.id);
|
|
105
|
+
return {
|
|
106
|
+
code: 'GOAL_MEMBERSHIP_REQUIRED',
|
|
107
|
+
goal_id: goalId,
|
|
108
|
+
visibility: goal.visibility,
|
|
109
|
+
action,
|
|
110
|
+
...(isPrivate ? {} : { goal_title: goal.title }),
|
|
111
|
+
what_to_do: action === 'join'
|
|
112
|
+
? `Join the goal (POST /api/bongos/goals/${goalId}/join), then retry the claim.`
|
|
113
|
+
: `Apply to join (POST /api/bongos/goals/${goalId}/requests); nothing can be claimed until an owner approves.`,
|
|
114
|
+
message: isPrivate
|
|
115
|
+
? `This task lives in goal ${goalId}, which is private — you are not a member.`
|
|
116
|
+
: `This task lives in goal ${goalId} ("${goal.title}") — you are not a member.`,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
module.exports = { isGoalOwner, isGoalOwnerOrManager, authorizeGoalManagement, goalMembershipClaimRefusal };
|
|
@@ -301,6 +301,12 @@ module.exports = function buildClaimsRouter() {
|
|
|
301
301
|
// builder's. Same 403 semantics as the Xenos gate; the body carries
|
|
302
302
|
// { required, actual } so the CLI can render a clean message.
|
|
303
303
|
err.code === 'INSUFFICIENT_RANK' ? 403 :
|
|
304
|
+
// task 1003137: the task's goal requires membership. The body carries
|
|
305
|
+
// goal_id, visibility, and the action (join|apply) + what_to_do —
|
|
306
|
+
// enough for the CLI to offer the join inline (task 1003138). A
|
|
307
|
+
// private goal's body deliberately omits its title/scope (leak rule
|
|
308
|
+
// in goal-authz.goalMembershipClaimRefusal).
|
|
309
|
+
err.code === 'GOAL_MEMBERSHIP_REQUIRED' ? 403 :
|
|
304
310
|
500;
|
|
305
311
|
// V4.R14 (#952): a TASK_NOT_READY 409 names the way forward instead of
|
|
306
312
|
// leaving the caller to discover the promote route by spelunking (#506).
|
package/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bongos/core",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.279",
|
|
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.279",
|
|
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.279",
|
|
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
|
@@ -981,8 +981,12 @@ const { validateOrRespond, LIMITS, parseId, asyncHandler, corsPublicGet, parsePa
|
|
|
981
981
|
// landed since 1.19.275 with no explicit bump. run 32499257959. (task 1002620)
|
|
982
982
|
// 1.19.277 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
|
|
983
983
|
// landed since 1.19.276 with no explicit bump. run 32503053532. (task 1002620)
|
|
984
|
+
// 1.19.278 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
|
|
985
|
+
// landed since 1.19.277 with no explicit bump. run 32508270995. (task 1002620)
|
|
986
|
+
// 1.19.279 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
|
|
987
|
+
// landed since 1.19.278 with no explicit bump. run 32521664476. (task 1002620)
|
|
984
988
|
// ---------------------------------------------------------------------------
|
|
985
|
-
const CORE_VERSION = '1.19.
|
|
989
|
+
const CORE_VERSION = '1.19.279'; // CI auto-patch carrier (ADR 0161); see changelog above
|
|
986
990
|
|
|
987
991
|
// A namespaced logger so a module's log lines are attributable + consistent.
|
|
988
992
|
// Usage: const log = api.logger('dev-box'); log.info('mounted');
|
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
// O1 ordering: non-member + out-of-scope → not_a_member (no scope hint leaks)
|
|
30
30
|
// O2 ordering: a closed goal short-circuits first → goal_not_open
|
|
31
31
|
// P Metic+ on an in-scope protected path → ALLOW (rank clears the floor)
|
|
32
|
+
// Q* CLAIM a task in a goal you never joined (task 1003137)→ 403 GOAL_MEMBERSHIP_REQUIRED
|
|
33
|
+
// (join for public, apply for private/protected; a private goal's refusal
|
|
34
|
+
// leaks no title and no scope; goal_id NULL is not gated; both INSERT
|
|
35
|
+
// INTO claims sites run the same extracted gate)
|
|
32
36
|
//
|
|
33
37
|
// Ordering is fail-closed (a missing/ambiguous input denies), and membership is
|
|
34
38
|
// checked BEFORE scope so a non-member never learns the scope (O1 vs B). Per-branch
|
|
@@ -155,6 +159,74 @@ await test('[K] a protected-scope goal is recognized as protected; a normal goal
|
|
|
155
159
|
assert.equal(scopeIncludesProtected(G_IDEAS.scope_modules), false, 'ideas is a normal, open-join module');
|
|
156
160
|
});
|
|
157
161
|
|
|
162
|
+
// ---- [Q] the CLAIM-time membership wall (task 1003137) ----
|
|
163
|
+
// A task that lives in a goal is claimable only by that goal's members — every
|
|
164
|
+
// goal, the '<version> — general' catch-alls included (owner ruling 2026-08-19).
|
|
165
|
+
// The decision is the pure goalMembershipClaimRefusal (goal-authz.js); db.js
|
|
166
|
+
// feeds BOTH claim paths through the one extracted db.goalMembershipFailures.
|
|
167
|
+
const { goalMembershipClaimRefusal } = require('../modules/lifecycle/goal-authz.js');
|
|
168
|
+
const G_PUBLIC = { id: 21, title: 'Public builder profiles', visibility: 'public' };
|
|
169
|
+
const G_PRIVATE = { id: 22, title: 'SECRET-TITLE-MUST-NOT-LEAK', visibility: 'private', scope_modules: ['lifecycle'] };
|
|
170
|
+
|
|
171
|
+
await test('[Q1] goal_id NULL is NOT gated — a NULL goal has no membership to check (migration 160 nullable)', () => {
|
|
172
|
+
assert.equal(goalMembershipClaimRefusal({ goal: null, isMember: false, actorRank: 'xenos', scopeProtected: false }), null);
|
|
173
|
+
});
|
|
174
|
+
await test('[Q2] a member claims freely', () => {
|
|
175
|
+
assert.equal(goalMembershipClaimRefusal({ goal: G_PUBLIC, isMember: true, actorRank: 'xenos', scopeProtected: false }), null);
|
|
176
|
+
});
|
|
177
|
+
await test('[Q3] an Archon is an implicit member (the isMemberOrArchon convention)', () => {
|
|
178
|
+
assert.equal(goalMembershipClaimRefusal({ goal: G_PRIVATE, isMember: false, actorRank: 'archon', scopeProtected: true }), null);
|
|
179
|
+
});
|
|
180
|
+
await test('[Q4] non-member on a public unprotected goal → GOAL_MEMBERSHIP_REQUIRED, action=join, title rides along', () => {
|
|
181
|
+
const r = goalMembershipClaimRefusal({ goal: G_PUBLIC, isMember: false, actorRank: 'metic', scopeProtected: false });
|
|
182
|
+
assert.equal(r.code, 'GOAL_MEMBERSHIP_REQUIRED');
|
|
183
|
+
assert.equal(r.action, 'join');
|
|
184
|
+
assert.equal(r.goal_id, 21);
|
|
185
|
+
assert.equal(r.visibility, 'public');
|
|
186
|
+
assert.equal(r.goal_title, 'Public builder profiles');
|
|
187
|
+
assert.ok(/join/i.test(r.what_to_do), 'the way forward names the join route');
|
|
188
|
+
});
|
|
189
|
+
await test('[Q5] non-member on a PRIVATE goal → action=apply, and the refusal leaks NO title and NO scope', () => {
|
|
190
|
+
const r = goalMembershipClaimRefusal({ goal: G_PRIVATE, isMember: false, actorRank: 'metic', scopeProtected: true });
|
|
191
|
+
assert.equal(r.code, 'GOAL_MEMBERSHIP_REQUIRED');
|
|
192
|
+
assert.equal(r.action, 'apply');
|
|
193
|
+
assert.equal(r.visibility, 'private');
|
|
194
|
+
assert.ok(!('goal_title' in r), 'a private goal\'s title must not leak to a non-member');
|
|
195
|
+
const flat = JSON.stringify(r);
|
|
196
|
+
assert.ok(!flat.includes('SECRET-TITLE-MUST-NOT-LEAK'), 'no field may carry the private title');
|
|
197
|
+
assert.ok(!flat.includes('scope_modules') && !flat.includes('lifecycle'), 'no field may carry the private scope');
|
|
198
|
+
});
|
|
199
|
+
await test('[Q6] non-member on a public PROTECTED-scope goal → action=apply (self-join is Archon-mediated)', () => {
|
|
200
|
+
const r = goalMembershipClaimRefusal({ goal: G_PUBLIC, isMember: false, actorRank: 'metic', scopeProtected: true });
|
|
201
|
+
assert.equal(r.action, 'apply', 'a protected-scope goal is never offered as open-join');
|
|
202
|
+
});
|
|
203
|
+
await test('[Q7] source contract: BOTH INSERT INTO claims sites run the extracted gate (batch cannot bypass)', () => {
|
|
204
|
+
const dbSrc = readFileSync(new URL('../modules/lifecycle/db.js', import.meta.url), 'utf8');
|
|
205
|
+
const insertSites = dbSrc.match(/INSERT INTO claims \(/g) || [];
|
|
206
|
+
assert.equal(insertSites.length, 2, 'exactly two claim-insert sites (claimTask + claimTasksBatch) — a third needs the gate too');
|
|
207
|
+
const gateCalls = dbSrc.match(/await goalMembershipFailures\(/g) || [];
|
|
208
|
+
assert.equal(gateCalls.length, 3, 'the membership gate must run on both claim paths + validateClaimBatch (the dry-run twin that must stay in sync)');
|
|
209
|
+
});
|
|
210
|
+
await test('[Q8] feed contract: a non-member row is flagged joinable, never silently claimable (leak rule holds)', () => {
|
|
211
|
+
const { decorateGoalMembership } = require('../modules/lifecycle/db.js');
|
|
212
|
+
// member / goal-less rows pass through shaped as today
|
|
213
|
+
assert.deepEqual(decorateGoalMembership({ id: 1, goal_id: null }), { id: 1, goal_id: null });
|
|
214
|
+
assert.deepEqual(
|
|
215
|
+
decorateGoalMembership({ id: 2, goal_id: 21, g_visibility: 'public', g_scope_modules: ['ideas'], g_title: 'T', g_is_member: true }),
|
|
216
|
+
{ id: 2, goal_id: 21 }
|
|
217
|
+
);
|
|
218
|
+
// non-member public → flagged join, title carried, scope stripped
|
|
219
|
+
const pub = decorateGoalMembership({ id: 3, goal_id: 21, g_visibility: 'public', g_scope_modules: ['ideas'], g_title: 'T', g_is_member: false });
|
|
220
|
+
assert.deepEqual(pub.goal_membership, { required: true, goal_id: 21, visibility: 'public', action: 'join', goal_title: 'T' });
|
|
221
|
+
assert.ok(!('g_scope_modules' in pub) && !('g_title' in pub), 'scratch columns must not leave the feed');
|
|
222
|
+
// non-member private → flagged apply, NO title
|
|
223
|
+
const priv = decorateGoalMembership({ id: 4, goal_id: 22, g_visibility: 'private', g_scope_modules: ['ideas'], g_title: 'SECRET', g_is_member: false });
|
|
224
|
+
assert.deepEqual(priv.goal_membership, { required: true, goal_id: 22, visibility: 'private', action: 'apply' });
|
|
225
|
+
// non-member public but protected-scope → apply (matches the join route's Archon-mediation)
|
|
226
|
+
const prot = decorateGoalMembership({ id: 5, goal_id: 23, g_visibility: 'public', g_scope_modules: ['lifecycle'], g_title: 'L', g_is_member: false });
|
|
227
|
+
assert.equal(prot.goal_membership.action, 'apply');
|
|
228
|
+
});
|
|
229
|
+
|
|
158
230
|
// ---- the pins that make a rank drift on a goal route a red build (BV1.R61) ----
|
|
159
231
|
// The wall is only drift-proof if the goal routes are PINNED and the LIVE routes
|
|
160
232
|
// classify to those pins. The catch-violation (a downgrade → blocker) is proven in
|
package/tests/reward_gate.mjs
CHANGED
|
@@ -163,9 +163,10 @@ t('claim path AUTO-ASSIGNS inside the FOR UPDATE transaction (never refuses)', (
|
|
|
163
163
|
// pre-flight half of claimTask (which spans ~13k chars). Widened 5000 -> 6000 in
|
|
164
164
|
// BV1.R106, when the permission-expressed claim gate pushed the reward-gate block
|
|
165
165
|
// past the old edge; 6000 -> 7000 in task 1002613, when the enriched
|
|
166
|
-
// rank_too_low_for_task denial did the same
|
|
167
|
-
//
|
|
168
|
-
|
|
166
|
+
// rank_too_low_for_task denial did the same; 7000 -> 8500 in task 1003137, when
|
|
167
|
+
// the goal-membership gate landed between the rank gates and deps. Keep it
|
|
168
|
+
// comfortably below the claimTasksBatch boundary (~16.5k chars in).
|
|
169
|
+
const body = dbSrc.slice(start, start + 8500);
|
|
169
170
|
assert.match(body, /rewardGateAssignment\(task\)/, 'claimTask must consult the auto-assign decision');
|
|
170
171
|
assert.match(body, /UPDATE tasks SET credits_reward/, 'claimTask must persist the assigned reward in-tx');
|
|
171
172
|
// it must SELECT the columns the gate needs.
|