Skip to content

Commit 9b0824a

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/issue-34095-upgrade-plan-extensions
2 parents 432c9d2 + a121e29 commit 9b0824a

181 files changed

Lines changed: 11546 additions & 797 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@objectstack/driver-turso': patch
3+
---
4+
5+
fix(driver-turso): Turso's remote face relaxes a NOT NULL column in place, so a package upgrade that makes a field optional reaches hosted databases
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: none
9+
10+
On Turso's remote face (`libsql://`, every hosted tenant database), a `relax_not_null` drift entry is now applied. Until now it was skipped with "it needs the SQLite table rebuild, which the Turso REMOTE transport does not run". A package upgrade that declares `storage: { notNull: false }` on a column therefore left the column NOT NULL on a hosted database, and every save that left the field empty failed.
11+
12+
The maintainer ruled how (decision record 6915086281 on #33724): the column is relaxed in place with libSQL's own column statement, `ALTER TABLE t ALTER COLUMN c TO c <definition>`, and no table rebuild runs.
13+
14+
- **Only the NOT NULL clause changes.** The definition sent is the column's own, cut from the table's stored `CREATE TABLE` with only its `[CONSTRAINT name] NOT NULL [ON CONFLICT …]` clause removed. The type, the DEFAULT, and any CHECK, COLLATE, UNIQUE or REFERENCES clause stay byte for byte. No row is copied or revalidated.
15+
- **Applied only on a read-back.** The statement is sent in one `write` batch with a check that the table's stored SQL now reads exactly as planned. If it reads any other way, the batch rolls back. The entry is reported `applied` only when the column then reads back nullable, with the type, the DEFAULT and the primary-key position it had before.
16+
- **A refusal is reported, and nothing falls back.** A statement the database refuses, a stored definition the plan cannot read, or a read-back that differs is reported `skipped`, and the reason is logged. Measured on libSQL (SQLite 3.45.1): libSQL ends the old definition at the first comma after the column's name, so a column whose definition holds a comma (in a DEFAULT, a CHECK, a type width such as `NUMERIC(10, 2)`, or a comment) is refused that way, and a real `sqld` 0.24.33 refuses it the same way. It keeps its NOT NULL, the table is left byte-identical, and the logged reason says the definition holds a comma. The maintainer accepted this limit (decision record 6922037129 on #33724): no table rebuild is added for such a column. Columns this face creates are `TEXT`, `INTEGER` or `REAL` with no DEFAULT and no width, so they are never in it.
17+
18+
The same three acts reach the relax as before: a managed install or upgrade of a package that declares `storage: { notNull: false }` on the column, the publish of an environment-authored object, and `os migrate apply`. A boot still never alters a column (ADR-0113 D5). On the remote face, `TursoDriver.applyMigrationEntries` now applies a `relax_not_null` entry, and `TursoDriver.driftApplyLimit('relax_not_null')` answers `null` where it answered the table-rebuild sentence. So `os migrate plan` and the apply's listing show a relax on a remote database with no transport limit, and count one fewer change they cannot apply.
19+
20+
A tightened NOT NULL, a dropped DEFAULT, and the type and width entries keep their answer on this face: skipped, because they need the table rebuild. The statement does not revalidate existing rows, so it is never used to tighten. A local SQLite file keeps the existing table rebuild for every column entry.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/lint': patch
3+
---
4+
5+
docs(lint)!: `os explain approval-approvers-may-resolve-empty` names SCIM as a route that populates `sys_user.manager_id`
6+
7+
Clause-②: yes (narrowing)
8+
Metadata-protocol: none
9+
10+
<!-- adr-0087: not-required (no-migration-prescription) This package changes explanation text only: no key of any authorable schema and no stored row changes, so there is nothing for `objectstack migrate meta` to rewrite. The narrowing it describes is plugin-auth's SCIM answer, declared in that package's note. -->
11+
12+
**BREAKING** in the behaviour this text now describes, not in the lint package: a SCIM user write whose named manager would make the user their own manager, close a cycle, run past the depth cap or cross an organization boundary was served before and is now refused with SCIM `400 invalidValue` (plugin-auth's note has the details). The lint rule and its findings are unchanged.
13+
14+
The `manager` arm's remedy said the platform declares the SCIM `manager` attribute without projecting it onto the column. plugin-auth now projects it, so the remedy says that the Enterprise User `manager` attribute, whose value is the manager's SCIM resource id, is written onto the column for an active user a SCIM directory holds, from the connection that provisioned that user's profile, on a create, replace or patch that names the attribute, through the admin operation's refusals. A write that does not name it leaves the column as it is, and an id naming no existing user the connection provisioned is served with the column unchanged. Any other directory sync is still named as something your own deployment supplies.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
'@objectstack/plugin-auth': patch
3+
---
4+
5+
feat(plugin-auth)!: a SCIM directory sets, changes and clears a user's manager through the Enterprise User `manager` attribute
6+
7+
Clause-②: yes (narrowing)
8+
Metadata-protocol: none
9+
10+
<!-- adr-0087: not-required (no-migration-prescription) No key of any authorable schema is added, removed, renamed or re-shaped and no stored row changes shape: what moves is the answer a SCIM user write gets when the manager it names would be refused by the admin endpoint. There is nothing for `objectstack migrate meta` to rewrite; the identity provider's manager mapping is corrected in the directory. -->
11+
12+
**BREAKING** for a SCIM identity provider that sends a manager the admin endpoint would refuse. A SCIM create, replace or patch that names the Enterprise User `manager` attribute, for an active user the directory holds, whose manager resolves to a User the same connection provisioned, and where that link would make the user their own manager, close a cycle, run past the 20-link depth cap, or cross an organization boundary, used to answer `201` / `200` and leave `manager_id` untouched. It now answers SCIM `400` with `scimType: invalidValue` and the admin endpoint's reason, and nothing of the request is written. Those four are the only requests served before and refused now. Remedy: correct the manager in the directory.
13+
14+
**On upgrade.** An identity provider that syncs by replace and maps no manager clears, on its next sync, a `manager_id` set earlier for a user the directory holds, because a replace without the attribute is a clear. Map the manager attribute in the identity provider before upgrading if those values should stay.
15+
16+
**The gap.** `POST /api/v1/auth/admin/set-user-manager` refuses a person a SCIM directory holds and says to change the manager in the directory, but nothing carried the directory's answer to `sys_user.manager_id`: `@better-auth/scim` stored and echoed `urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:manager` and wrote nothing of it onto the user. So a SCIM-held user's manager could not change from either side, and approvals routed to the manager could not follow a reorganisation.
17+
18+
**The rule.** A SCIM user write that names the attribute now projects `manager.value` onto `sys_user.manager_id`, inside the SCIM transaction. `manager.value` is the manager's SCIM resource `id` (RFC 7643 §4.3), looked up among the Users the same connection provisioned; a `$ref` alone is read by its final `/Users/{id}` segment. The link goes through the admin endpoint's own refusals, above.
19+
20+
- **Silence is not a clear.** A create or PATCH that does not name the attribute leaves `manager_id` as it is. An explicit PATCH `remove`, or a replace without the attribute, clears it.
21+
- **One owner per identity.** The projection writes only on an identity whose manager the directory owns, which is exactly the set the admin endpoint refuses (one shared predicate). On any other identity, for example one holding a local password, the admin endpoint owns the column and the projection writes nothing.
22+
- **A reference that names no User is served.** An unknown id, an `externalId` or email, another connection's id, a `$ref` with no readable `/Users/{id}` segment, or a User of this connection whose platform user no longer exists does not fail the write: the user is saved, `manager_id` stays as it was, and the event is recorded with one operator warning and one `scim_manager_unresolved` audit row (when `@objectstack/plugin-audit` is installed), both once per connection per window, carrying the count held back. The row names the connection, the user and the reference, cut to 256 characters, and nothing else from the request; a request that is refused writes none.
23+
- **An unchanged manager is not judged again**, so a write is never refused over a chain other links have since reshaped, and a report whose manager was deleted keeps working.
24+
25+
**Where it does not project, and why.**
26+
27+
- Outside an authenticated SCIM request: the vendor also runs this step while it decommissions a connection or replays a provisioning domain. Neither is a write the directory made, and a decommission must never be refused over an org-chart reference.
28+
- When the user's profile source belongs to another connection: that connection authors the user's name and email, so its manager is the one that counts, not this request's.
29+
- For an inactive user: a deprovision is never refused over the org chart. A manager named while the user is inactive is not applied on re-activation alone; it lands on the next replace, or on a patch that changes it. (`@better-auth/scim` calls the host only when a PATCH changes what it stores, so a patch that re-sends the same value, or removes an attribute the directory never sent, writes nothing; a replace always reaches the projection.)
30+
31+
The `idp_provisioned` stamp (ADR-0135 D4) is unchanged.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@objectstack/plugin-audit': patch
3+
---
4+
5+
feat(plugin-audit)!: `sys_audit_log` records a SCIM user write whose Enterprise `manager` reference names no user, as one bounded `scim_manager_unresolved` row
6+
7+
Clause-②: yes (narrowing)
8+
Metadata-protocol: none
9+
10+
<!-- adr-0087: not-required (no-migration-prescription) This package adds one ledger action and its writer: no key of any authorable schema is added, removed, renamed or re-shaped and no stored row changes shape, so there is nothing for `objectstack migrate meta` to rewrite. The narrowing the PR declares is plugin-auth's SCIM answer, described in that package's note. -->
11+
12+
**BREAKING** in the SCIM behaviour this row belongs to, not in this package: plugin-auth now refuses with SCIM `400 invalidValue` a manager link the admin endpoint would refuse (self, cycle, depth cap, cross-organization); plugin-auth's note has the details. Nothing this package already wrote or read changes.
13+
14+
**The new row.** `sys_audit_log.action` gains `scim_manager_unresolved` (label "SCIM Manager Unresolved"), written by the SCIM writer on the `audit` slot (`recordScimManagerUnresolved`, beside `recordScimRefusal`, through the same insert). plugin-auth hands it one event when a SCIM user write it served named an Enterprise User `manager` whose reference resolves to no user that connection provisioned: the write is saved, `manager_id` is left as it was, and the event is recorded with one operator warning and this row.
15+
16+
- **Bounded rate.** The row and the warning share one admission: one per SCIM connection per 10-minute window. The next row carries the number held back in between as `metadata.suppressed`. The admission happens inside the SCIM transaction, before the answer is known: a request refused after its reference was admitted still logs the warning and spends the window, so the next served unresolvable reference in that window is counted only in `suppressed`.
17+
- **Bounded content.** `actor` is the connection's service principal (`svc:scim:CONNECTION_ID`), `object_name` / `record_id` the `sys_user` the write was about, `tenant_id` the connection's organization, and `metadata` holds `scim_connection_id`, `reference_kind` (`id` or `unreadable`) and `manager_reference`, the reference as the directory sent it, cut to 256 characters (`manager_reference_truncated: true` when it was longer). Nothing else from the request or the user is recorded.
18+
- **Only served writes.** A refused request writes no such row (its `scim_refused` row is unchanged), and the row is written after the response, outside the SCIM transaction.
19+
20+
Find them in the Audit Log under the "SCIM Manager Unresolved" action, or on the user's own audit history.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/organizations': patch
3+
---
4+
5+
fix(organizations): a new organization's seed resolves its founder
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
On a walled (`isolated`) deployment, `POST /api/v1/auth/organization/create` replayed the app's seed into the new organization before better-auth wrote the founder's `sys_member` row. A seed loaded into an organization resolves a person only through membership in that organization, so every person reference the seed declared (`Field.user()`, `Field.lookup('sys_user')`, the injected `owner_id`) was stored empty with "not a member of organization ORG", the founder's included.
11+
12+
The per-organization replay now waits, for an organization a signed-in person creates (`POST /api/v1/auth/organization/create`, whose `sys_organization` insert carries that person as `attributedUserId`), until that organization's first `sys_member` row is stored, and replays then. A seed record naming the founder now stores the founder's user id. A person who is not a member of the new organization still resolves to nothing, with the same warning. The replay still runs once per organization, still seeds in the founder's language, and still finishes before a host's `onOrganizationCreated` callback runs. Organizations created any other way (the Default Organization bootstrap, a system insert, or a server-side `auth.api.createOrganization({ body: { userId } })` call made with no auth request in scope, whose insert carries no `attributedUserId`) replay on the insert, as before.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
---
4+
5+
fix(metadata-protocol)!: a bare save or delete answers the holders the bare read counts: a name two enabled packages hold is refused naming both, and a name only disabled packages hold is refused naming none (ADR-0150 D3/D5)
6+
7+
Clause-②: no (narrowing)
8+
Metadata-protocol: none
9+
10+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export changes shape. The moved answers are write doors under a reversible package state: no stored row is rewritten, so there is nothing for a migration to rewrite and no tombstone. -->
11+
12+
**BREAKING** for a writer that saves or deletes a name without naming a package (`PUT` or `DELETE /meta/:type/:name` with no `?package=`, or `saveMetaItem` / `deleteMetaItem` with no `packageId`), in two states. The bare write used to take its address from the stored rows alone, while the bare read counts the name's holders. It now counts them as the read does (ADR-0150 D3/D5, red line 2: ambiguity is reported, never guessed). Every refusal is the existing `409 RESOURCE_CONFLICT` with the `?package=` remedy; there is no new code. Measured on a booted kernel through the runtime dispatcher and `RestServer`, in both registration orders.
13+
14+
**Two or more enabled packages hold the name.** The bare read refuses 409 naming them.
15+
16+
- A publish-mode bare save used to answer 200. Over no stored row it wrote a package-unbound row beside both packages; over one package's row it updated that row. It is now refused naming both packages, and nothing is written. Over a row of each it was refused already, and still is.
17+
- A draft-mode bare save (`?mode=draft`) used to write a package-unbound draft, or the one package's draft. It is now refused the same way.
18+
- A bare delete used to remove the one package's row. It is now refused the same way, and the row stays.
19+
- A bare delete or bare draft discard (`?state=draft`) over no stored row used to answer the no-op receipt (`success: true, reset: false`). It is now refused the same way.
20+
21+
**Every package that holds the name is disabled.** A disabled package holds no name (ruling A on #34144 and the registry's served-holder rule, #32183), so the bare read answers 404. The bare write is now refused naming no package (ruling A):
22+
23+
- A publish-mode bare save of a name whose only holder D is disabled used to answer 200. Over D's row alone it updated D's row; over no stored row it wrote a package-unbound row that every read then withheld. It is now refused, and nothing is written.
24+
- A bare save of a bundled name (an `email_template`) whose every holder is disabled, at a member the holder never ships, used to answer 200 and store a package-unbound row that the by-name read and both lists withheld until the package was enabled again. It is now refused, and nothing is stored. This replaces the "accepted and kept" save described in this release's note on reads of a disabled package's customization: FROM `success: true` with the row stored and hidden, TO `409 RESOURCE_CONFLICT` with the `?package=` remedy, naming no package, no row stored. The line of `.changeset/33385-disabled-holders-env-404.md` that says this save "is accepted and kept, as before" is superseded by this note: while every holder is disabled, the save is refused and nothing is stored. A delete of such a row while the package is disabled still removes it, a save at a member the package ships is still refused `403 NOT_OVERRIDABLE` where the package door refuses it, and once the package is enabled again the same save is kept.
25+
- A draft-mode bare save (`?mode=draft`) of such a name used to write a package-unbound draft. It is now refused the same way.
26+
- A bare delete of such a name used to remove D's row. It is now refused, and D's row stays.
27+
- A bare delete or bare draft discard (`?state=draft`) of such a name over no stored row used to answer the no-op receipt (`success: true, reset: false`). It is now refused the same way.
28+
29+
**Not moved.** A write naming the package (`?package=`, `packageId`) answers as before. So do a name one enabled package holds, a name an enabled and a disabled package both hold, a name no package holds (the environment's own item), and a package-unbound row stored at the address: the save edits that row and the delete removes it, as before. Once a disabled package is enabled again, its bare writes answer as before. A type the registry does not read by package (`action`, `doc`, whose bare reads refuse through their own judges) is not judged here and answers as before. A bare save in these two states that a later gate already refused (an invalid body, a read-only inherited package) is still refused, now with this `409` first: refused to refused.
30+
31+
**No migration.** No schema key or stored row changes. To write one holder's item, name its package; to write a disabled package's item, name it or enable it again.

0 commit comments

Comments
 (0)