@aria-framework/tenancy 0.0.0-stage → 0.1.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,73 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ _(not yet released)_
6
+
7
+ - Scope: `createTenancy({ db, logger, dbKind, platformRequiresHouse, partnerModel, contactScope, beforeEachPartner,
8
+ refreshTokenOwner, unscopedRedirect, actingRequiresActive, activeMaxAgeMs, activeLoadTimeoutMs, now, timers })` — the starter's `lib/tenant.js` and `lib/scope.js` (every name and signature),
9
+ plus `asOwnPartner` (the hub, the soc app), the desk app's house rule (`platformRequiresHouse`, `isPlatformUser`,
10
+ `knownHouseId`) and its portal-contact and per-partner hooks. `dbKind`, `platformRequiresHouse` and `actingRequiresActive` are required.
11
+ - Scope: `actingRequiresActive` — deactivating a partner ends acting into it (the owner's decision of 29 Nov 2026): a set of
12
+ active partners on the main thread, loaded at boot, reloaded by `refreshActivePartners()` (one load at a time,
13
+ a refresh always answered by a load started after it, the newest result wins, a load timeout), closed while unknown;
14
+ a flag into a partner known inactive is cleared from the session, one missing from both sets is kept.
15
+ - Scope: `createWriteGate({ tenancy, whileActing, houseReading, messages, partnerById, logger })` — `writeScope`,
16
+ `readScope` (the noc and soc apps'), `createsLand`, `platformDestination`, `refusal` (the hub's), `authorship` and
17
+ `houseOperatorNames`, the desk app's edit-and-delete rule folded into `writeScope`, and its cross-tenant refusal as
18
+ `crossTenantWriteHandler()` and `crossTenantRefusalOf()`. At partner scope a row's partner is compared on Postgres
19
+ only. Every runner runs in the context it judged (`contextFor(req)`, or the current scope when the request is
20
+ `null`), whatever scope surrounds the call. `whileActing` and `houseReading` are required.
21
+ - Hosts: `hostname`, the pure host-name functions moved from the apps' `lib/hostname.js` (identical in four apps), with
22
+ the hub's reserved-label check taking the list as a REQUIRED `reservedLabels` option, a refusal of a label that is
23
+ not one valid DNS label in `hostFor`, `isHostLabel` and `PARTNER_BASE_DOMAIN_KEY`.
24
+ - Hosts: `createHostTenant({ tenancy, db, logger, trustForwardedHost, chrome, isSignedIn, onForget, maxAgeMs })`, the apps'
25
+ `middleware/hostTenant.js` (the starter's) with the noc app's keep-the-last-good-map reload, one `hostOf(req)`,
26
+ `partnerIdForRequest(req)` and `partnerOfHost(host)`; `trustForwardedHost` and `isSignedIn` are required with no default; an optional `maxAgeMs` bounds the map's age; an outage of reloads is logged once, then at most once a minute, then on recovery.
27
+ - Hosts: `createTenantChrome({ tenancy, db, fields })`, the apps' `lib/tenantChrome.js` (identical in five apps)
28
+ generalised to a REQUIRED list of fields (which must include `sessionTimeoutMs`; `STARTER_FIELDS` is the starter's two), keyed by db-worker's `tenantCacheKey`, with the desk
29
+ app's synchronous cache-only read as `cached(field, fallback)`.
30
+ - Partners: `createPartnerStore({ driver, sql, mintRef, refShape, refPolicy, counts, nameMaxLength, houseName,
31
+ mintHouseRef, writesRequirePlatform, allOrder, … })`, the partner model's nine methods (from the starter), with the
32
+ platform-scope refusal on `listWithCounts` (from the soc app), the house's reference minted at seed when
33
+ `mintHouseRef`, reference checks on create, `update` and `setActive` in one transaction with `setActive` a no-op
34
+ when unchanged and the `onChange` / `onDeactivate` hooks inside it (from the hub), paging and search on the list and
35
+ an editable domain (from the desk). Every setting whose value differs between apps is required, with no default.
36
+ `writesRequirePlatform: true` (a new app's value) refuses writes to the partner table below platform scope.
37
+ - Partners: `createProvisioner({ tenancy, db, rbac, logger, seeds, deactivateWith, onPartnersChanged })`,
38
+ `createPartner` / `provision` from the starter, with the seed results checked and `partnerId` on the error (from the
39
+ desk), RBAC refreshed after every provision (from the desk), a failed deactivation of a half-built partner logged at
40
+ error instead of swallowed (a defect in every copy), a failure path that a throwing logger cannot break, and
41
+ `updatePartner` / `setPartnerActive`, so ONE callback (`onPartnersChanged`) follows every committed write to the
42
+ partner list.
43
+ - Partners: `actingRoutes({ Router, tenancy, db, audit, requirePermission, permission, landing, refuseInactive,
44
+ messages })` (the starter's act-as and stop handlers: audit before the switch, after the switch back; every redirect
45
+ a local path, the mount's checked at request time; `refuseInactive` required, `true` for a new app),
46
+ `actingLocals({ tenancy, readOnly, note, stopPath })`, and `views/acting-banner.ejs` with `viewsDir`. The banner
47
+ shows only when `contextFor` says the scope has moved to the acting partner (a defect in every copy but the desk's).
48
+ - Integration: the three parts joined in one small app assembled from the package root (`test/integration/`), on
49
+ PostgreSQL under row-level security as a non-superuser and on SQLite, over HTTP with real sessions: provisioning,
50
+ deactivation through the provisioner and through `write(...)` (and a bypassing write, pinned), `refuseInactive`,
51
+ `writesRequirePlatform`, the write gate, host narrowing against the session's scope, cold start and outage, and
52
+ both settings off. README: "Wiring the three parts" (the assembly, its order, the boot call, every cross-part
53
+ name with its owner, held to the code by `test/integration/surface.js`); the parts' guessed cross-part names
54
+ corrected.
55
+ - Partners: `onPartnersChanged` may be a list of functions, run in order, each isolated (one that throws or rejects is
56
+ logged with its position and the next still runs); the README wiring passes the active-partner refresh first and
57
+ the host forget second.
58
+ - Partners: `createProvisioner`'s REQUIRED `writesRequirePlatform` (the store's value): `true` refuses
59
+ `createPartner`, `provision`, `updatePartner`, `setPartnerActive` and `write` below platform scope, judged on the
60
+ main thread from the current context before anything is written or any seed runs, on both engines.
61
+ - Partners: `actingRoutes` takes optional `flash(req, res, type, message)` and `notFound(req, res)`; the defaults are
62
+ today's (`res.flash` with a callback, the `errors/404` view), now stated as requirements.
63
+ - Scope: `refreshActivePartners()` marks the active set stale at once, so a request arriving while its load is in
64
+ flight waits for it instead of being answered from the set held before the change.
65
+ - Partners: `actingRoutes`' REQUIRED `auditScopes: { start: 'house' | 'both', stop: 'partner' | 'house' | 'both' }`
66
+ (every existing app: `{ start: 'house', stop: 'partner' }`, today's; a new app: `stop: 'both'`, the owner's decision
67
+ of 29 Nov 2026). A row written in an explicit scope goes through `tenancy.run`; the ADDED row of a `'both'` is
68
+ isolated (a failure is logged at error, `logger` required then). The README's sentence about where the stop row
69
+ lands corrected.
70
+ - Partners: the `onPartnersChanged` entries are all started at once, each isolated, and settled before the write
71
+ answers. Every entry must settle (the README says so).
72
+ - Scope: `whenActivePartnersKnown()`, for a caller that is not a request (a live stream's re-check before
73
+ `forSession`); the README says how long an acting request can wait.