Repository navigation
Commit e09f1ac
fix(cloud-connection): refuse install-local sample data for a session with no active organization (ADR-0123 D2/D4) (#21780)
Fixes #21774
Clause-②: no
Under an organization wall, a session with no active organization is
ADR-0123 D1's declared state. The install-local sample-data doors now
answer it the way ADR-0123 D2 / D4 require, instead of skipping quietly.
## What changed
- `resolveActiveOrgId`
(`packages/cloud-connection/src/marketplace-install-local-plugin.ts`):
the "first membership" fallback is **deleted**, not repaired. It read
`sys_organization_member`, an object nothing defines.
- **Reseed and purge** answer `403 PERMISSION_DENIED` (standard catalog,
no new code) with one sentence built in one place
(`noActiveOrganizationRefusal`). The sentence says the session has no
active organization and gives the remedy.
- **Install** still registers the env-wide package. Its `seeded` block
is `{ mode: "refused", reason }`, with the same sentence in `reason`
(was `{ mode: "skipped", reason: "multi-tenant-no-active-org" }`).
- `RESEED_SKIPPED` stays for reseed's other declines: `no-datasets`,
`objectql-or-metadata-missing`, `seed-error: …`.
- `storage-service-plugin.ts` (comment only, declared cross-lane): the
clause citing the deleted fallback now cites ADR-0123 D1. The comment's
own rule is unchanged.
- Ratchets moved down by one each for this file
(`scripts/slot-lookup-baseline.json` 15 to 14,
`scripts/query-options-erasure-baseline.json` 2 to 1). The deleted
fallback carried those sites.
## Measured before the change (`origin/main` `ebfe658c72`, real walled
boot, posture-only)
Tenancy `isolated`, `isolationActive: true`; session
`activeOrganizationId` null; 1 `sys_member` row for the admin.
- install: `200`, `seeded {mode: "skipped", reason:
"multi-tenant-no-active-org"}`
- reseed: `400 RESEED_SKIPPED` "Reseed did not run:
multi-tenant-no-active-org"
- purge: `400 RESEED_SKIPPED` "Purge did not run:
multi-tenant-no-active-org. …"
- the fallback's read: `Object 'sys_organization_member' not found`
(thrown, swallowed)
## Pins
- Unit: `marketplace-install-local-no-active-organization.test.ts`
(new). It covers walled with no active org and two memberships served by
the store, walled with an active org, and `single` (a spy proves
`resolveActiveOrgId` is never called). The purge unit pin moves to 403.
- Door pin on a real walled boot:
`packages/qa/dogfood/test/install-local-no-active-organization.dogfood.test.ts`
(new). In one session: no-org install/reseed/purge, then the same
session after `set-active` to org B, as the control. 7/7 green.
- Reverse verification (A5), committed fix at `a1a5513852`, through
`scripts/ablation-replace.mjs`, two literal anchors, nested WRAP:
- anchor 1, the seed refusal line, replaced by the old `mode: 'skipped'`
line: blob `5f88579b38e0` to `24f914c847b4`
- anchor 2, the purge 403, replaced by the old `RESEED_SKIPPED` / 400:
blob to `505004807245`
- On disk: removed lines 0/0, injected lines 1/1.
- Unit: 4 red (the 3 no-org pins and the purge no-org pin; received
`skipped` and `400`), 33 green.
- Door: 3 red (no-org install/reseed/purge), 4 green (preconditions,
nothing seeded, org-B control).
- Restore: three legs prove blob == HEAD `5f88579b38e0` and an empty
`git diff HEAD`.
## Verification (head `0590b46d38`)
- `pnpm --filter @objectstack/cloud-connection test`: 38 files, 466
tests passed.
- typecheck green for cloud-connection, dogfood and service-storage;
`--listFiles` includes both new test files.
- full `pnpm lint`: exit 0.
- `dispatch-gates --commands` derived 79 commands; 78 ran green on the
final head. `check-empty-changeset` is red **on purpose**; see below.
## Pending release note corrected (the empty-changeset gate stays red by
design)
`.changeset/21728-install-local-purge.md` is pending, from #21773; the
last version PR `617f25f8a4` predates that merge. It said a
no-active-organization purge is answered `400 RESEED_SKIPPED`. This PR
makes that sentence false, and both changesets ship in one release, so
its clause now reads `403 PERMISSION_DENIED`, naming the missing active
organization. Nothing else in that note changed. The gate's own text
classes this as a deliberate correction that a person confirms on the
PR. **Please confirm or reject this edit.**
## Acceptance notes
- The console (objectui at the pinned `.objectui-sha`,
`marketplaceApi.ts` `postLocalSampleAction`) shows `error.message` for
any non-ok status and does not branch on the code or status. The 400 to
403 move is shown to the user as the new sentence. The `os package
install` CLI does not read `seeded`.
- `resolveActiveOrgId` reads only the better-auth session. An API-key
caller (no session cookie) on a walled boot is refused with the session
wording. Before, it was skipped. This was not measured further; carrier:
none.
---
_Generated by [Claude
Code](https://claude.ai/code/session_016GiHYRmLSNWTfbX9gVQkpz)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent e83c9f6 commit e09f1ac
9 files changed
Lines changed: 578 additions & 38 deletions
File tree
- .changeset
- packages
- cloud-connection/src
- qa/dogfood/test
- services/service-storage/src
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
Lines changed: 268 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
0 commit comments