@aria-framework/tenancy 0.0.0-stage → 0.2.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,104 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ _(not yet released)_
6
+
7
+ Additive: fleet view, and an idle end for working in a partner (the owner's decisions of 29 Nov 2026). Everything 0.1.0
8
+ exports keeps its path, identity and behaviour; an app that only bumps notices nothing.
9
+
10
+ - Scope: `createFleetView({ permission, can, scopeOf, userIdOf, idleMinutes, now, isBackground, audit, logger, readOnlyExcept, home,
11
+ startPath, stopPath, flash, wantsJson, refusalView, messages })`, self-contained (no other factory of this package
12
+ needed): `isOn(req, res)`, `middleware` (the idle end with its one-time notice, the activity clock, the locals, the
13
+ read-only guard), `routes(Router)` (start, stop), `classify(method, path)` (the guard's decision, for an app's
14
+ route-table test), `end(req, reason)`, `writesRefused(req)`. Audited as `fleet_view.start` and `fleet_view.stop`
15
+ (`detail.reason`: `left`, `idle`, `permission`, `scope`, `user`, `error`, `acting`, `signout`). The guard judges the raw
16
+ target and refuses one that is not plain (`#`, backslash, control characters) and one Express would dispatch on another
17
+ path; a `:name` entry segment matches a conservative id only. The session is written only on start, stop and end and
18
+ for a throttled activity stamp (never at 0 minutes); the stamp and the automatic end (and the acting idle end's writes)
19
+ re-read the session's row and, if it still holds the same mode, write that row plus the request's own changes (against
20
+ the session as loaded, kept by `fleet.loaded` / the acting `loaded`, mounted directly after the session) plus the
21
+ package's change; otherwise nothing. What remains is one store round trip
22
+ (README, "When the package writes the session").
23
+ - Views: `fleet-view-banner.ejs` and `fleet-view-button.ejs` beside `acting-banner.ejs` (classes `fleet-view-banner`,
24
+ `btn-fleet-view`; the app adds two CSS rules).
25
+ - Scope: `createWriteGate`'s optional `fleetView`: the house reading becomes "the house's rows unless the permission is
26
+ held AND fleet view is on"; while the mode is on `writeScope` is null, `createsLand` false and `refusal` answers
27
+ `reason: 'fleetView'` (`messages.fleetView` required then). Absent: 0.1.0.
28
+ - Partners: `createActingIdle({ idleMinutes, now, isBackground, audit, logger, auditScopes, run, flash, messages })` with `before` and
29
+ `after` around an app's own scope middleware, and `tenancy.requestScope({ actingIdle })` running the same two halves
30
+ around this package's. 0 minutes is no idle end and no session write. The stop row follows `auditScopes.stop`.
31
+ `requestScope()` with no argument is 0.1.0's.
32
+ - One idle rule (`lib/scope/idle.js`) for both modes.
33
+ - README: "Fleet view", "The idle end of working in a partner"; a new app's `auditScopes.start` is `'both'` (the owner's
34
+ decision; it said "owner to confirm").
35
+
36
+ ## 0.1.0 — 2026-11-29 (UTC, as published)
37
+
38
+ - Scope: `createTenancy({ db, logger, dbKind, platformRequiresHouse, partnerModel, contactScope, beforeEachPartner,
39
+ refreshTokenOwner, unscopedRedirect, actingRequiresActive, activeMaxAgeMs, activeLoadTimeoutMs, now, timers })` — the starter's `lib/tenant.js` and `lib/scope.js` (every name and signature),
40
+ plus `asOwnPartner` (the hub, the soc app), the desk app's house rule (`platformRequiresHouse`, `isPlatformUser`,
41
+ `knownHouseId`) and its portal-contact and per-partner hooks. `dbKind`, `platformRequiresHouse` and `actingRequiresActive` are required.
42
+ - Scope: `actingRequiresActive` — deactivating a partner ends acting into it (the owner's decision of 29 Nov 2026): a set of
43
+ active partners on the main thread, loaded at boot, reloaded by `refreshActivePartners()` (one load at a time,
44
+ a refresh always answered by a load started after it, the newest result wins, a load timeout), closed while unknown;
45
+ a flag into a partner known inactive is cleared from the session, one missing from both sets is kept.
46
+ - Scope: `createWriteGate({ tenancy, whileActing, houseReading, messages, partnerById, logger })` — `writeScope`,
47
+ `readScope` (the noc and soc apps'), `createsLand`, `platformDestination`, `refusal` (the hub's), `authorship` and
48
+ `houseOperatorNames`, the desk app's edit-and-delete rule folded into `writeScope`, and its cross-tenant refusal as
49
+ `crossTenantWriteHandler()` and `crossTenantRefusalOf()`. At partner scope a row's partner is compared on Postgres
50
+ only. Every runner runs in the context it judged (`contextFor(req)`, or the current scope when the request is
51
+ `null`), whatever scope surrounds the call. `whileActing` and `houseReading` are required.
52
+ - Hosts: `hostname`, the pure host-name functions moved from the apps' `lib/hostname.js` (identical in four apps), with
53
+ the hub's reserved-label check taking the list as a REQUIRED `reservedLabels` option, a refusal of a label that is
54
+ not one valid DNS label in `hostFor`, `isHostLabel` and `PARTNER_BASE_DOMAIN_KEY`.
55
+ - Hosts: `createHostTenant({ tenancy, db, logger, trustForwardedHost, chrome, isSignedIn, onForget, maxAgeMs })`, the apps'
56
+ `middleware/hostTenant.js` (the starter's) with the noc app's keep-the-last-good-map reload, one `hostOf(req)`,
57
+ `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.
58
+ - Hosts: `createTenantChrome({ tenancy, db, fields })`, the apps' `lib/tenantChrome.js` (identical in five apps)
59
+ 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
60
+ app's synchronous cache-only read as `cached(field, fallback)`.
61
+ - Partners: `createPartnerStore({ driver, sql, mintRef, refShape, refPolicy, counts, nameMaxLength, houseName,
62
+ mintHouseRef, writesRequirePlatform, allOrder, … })`, the partner model's nine methods (from the starter), with the
63
+ platform-scope refusal on `listWithCounts` (from the soc app), the house's reference minted at seed when
64
+ `mintHouseRef`, reference checks on create, `update` and `setActive` in one transaction with `setActive` a no-op
65
+ when unchanged and the `onChange` / `onDeactivate` hooks inside it (from the hub), paging and search on the list and
66
+ an editable domain (from the desk). Every setting whose value differs between apps is required, with no default.
67
+ `writesRequirePlatform: true` (a new app's value) refuses writes to the partner table below platform scope.
68
+ - Partners: `createProvisioner({ tenancy, db, rbac, logger, seeds, deactivateWith, onPartnersChanged })`,
69
+ `createPartner` / `provision` from the starter, with the seed results checked and `partnerId` on the error (from the
70
+ desk), RBAC refreshed after every provision (from the desk), a failed deactivation of a half-built partner logged at
71
+ error instead of swallowed (a defect in every copy), a failure path that a throwing logger cannot break, and
72
+ `updatePartner` / `setPartnerActive`, so ONE callback (`onPartnersChanged`) follows every committed write to the
73
+ partner list.
74
+ - Partners: `actingRoutes({ Router, tenancy, db, audit, requirePermission, permission, landing, refuseInactive,
75
+ messages })` (the starter's act-as and stop handlers: audit before the switch, after the switch back; every redirect
76
+ a local path, the mount's checked at request time; `refuseInactive` required, `true` for a new app),
77
+ `actingLocals({ tenancy, readOnly, note, stopPath })`, and `views/acting-banner.ejs` with `viewsDir`. The banner
78
+ shows only when `contextFor` says the scope has moved to the acting partner (a defect in every copy but the desk's).
79
+ - Integration: the three parts joined in one small app assembled from the package root (`test/integration/`), on
80
+ PostgreSQL under row-level security as a non-superuser and on SQLite, over HTTP with real sessions: provisioning,
81
+ deactivation through the provisioner and through `write(...)` (and a bypassing write, pinned), `refuseInactive`,
82
+ `writesRequirePlatform`, the write gate, host narrowing against the session's scope, cold start and outage, and
83
+ both settings off. README: "Wiring the three parts" (the assembly, its order, the boot call, every cross-part
84
+ name with its owner, held to the code by `test/integration/surface.js`); the parts' guessed cross-part names
85
+ corrected.
86
+ - Partners: `onPartnersChanged` may be a list of functions, run in order, each isolated (one that throws or rejects is
87
+ logged with its position and the next still runs); the README wiring passes the active-partner refresh first and
88
+ the host forget second.
89
+ - Partners: `createProvisioner`'s REQUIRED `writesRequirePlatform` (the store's value): `true` refuses
90
+ `createPartner`, `provision`, `updatePartner`, `setPartnerActive` and `write` below platform scope, judged on the
91
+ main thread from the current context before anything is written or any seed runs, on both engines.
92
+ - Partners: `actingRoutes` takes optional `flash(req, res, type, message)` and `notFound(req, res)`; the defaults are
93
+ today's (`res.flash` with a callback, the `errors/404` view), now stated as requirements.
94
+ - Scope: `refreshActivePartners()` marks the active set stale at once, so a request arriving while its load is in
95
+ flight waits for it instead of being answered from the set held before the change.
96
+ - Partners: `actingRoutes`' REQUIRED `auditScopes: { start: 'house' | 'both', stop: 'partner' | 'house' | 'both' }`
97
+ (every existing app: `{ start: 'house', stop: 'partner' }`, today's; a new app: `stop: 'both'`, the owner's decision
98
+ of 29 Nov 2026). A row written in an explicit scope goes through `tenancy.run`; the ADDED row of a `'both'` is
99
+ isolated (a failure is logged at error, `logger` required then). The README's sentence about where the stop row
100
+ lands corrected.
101
+ - Partners: the `onPartnersChanged` entries are all started at once, each isolated, and settled before the write
102
+ answers. Every entry must settle (the README says so).
103
+ - Scope: `whenActivePartnersKnown()`, for a caller that is not a request (a live stream's re-check before
104
+ `forSession`); the README says how long an acting request can wait.