Skip to content

Commit 833700b

Browse files
committed
Merge commit '17ed9e7bfd65532d83109273837e4a44624dee5c' into claude/project-thread-tpkpoi
2 parents 4282834 + 17ed9e7 commit 833700b

166 files changed

Lines changed: 8781 additions & 1138 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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/plugin-audit': patch
3+
---
4+
5+
feat(plugin-audit): export the readers that rebuild a stored checkpoint or amendment row into its signed body
6+
7+
Clause-②: yes
8+
Metadata-protocol: none
9+
10+
`@objectstack/plugin-audit` now exports `checkpointBodyFromRow` and `amendmentBodyFromRow` from its package entry, with the two body types they answer, `CheckpointSignedBody` and `AmendmentSignedBody` (ADR-0154 D11).
11+
12+
A checkpoint sink (`audit.checkpointSink`) is handed each signed checkpoint and amendment once, and re-delivers what a failed call missed by re-reading the stored records. Read from an unaltered stored `sys_audit_checkpoint` or `sys_audit_amendment` row, these readers answer the body the sink was handed: its RFC 8785 serialization is the bytes the row's `signature` covers, so a sink outside the package can rebuild and re-send a record without copying the body's shape or its parsing. A malformed row is refused with an error whose `name` is `SignedBodyError` and whose message names the field.
13+
14+
The readers validate and normalize; they never verify the signature. A row whose signed columns were rewritten reads back into a body that fails verification (a rewrite of an unsigned column, `id`, `chain_key` or a checkpoint's `leaf_hashes`, reads back into the same body, and a malformed one is refused with a `SignedBodyError`). A row rewritten and re-signed under a key planted on the host fails under a key the sink trusts itself. A row rewritten and re-signed by whoever holds the genuine signing key verifies, and only the copies already off the host can catch it: a later checkpoint's signed `previous_digest` no longer matches a rewritten checkpoint, while no later record carries an amendment's digest at all. So a sink verifies the row's `signature` over the rebuilt body, under a key it trusts itself, before it treats the row as delivered.
15+
16+
A sink assembles the entry it re-delivers itself: `kind` is `checkpoint` or `amendment`, from the table it read; `keyId` is `body.signing_key_id`; and `signature` is the row's `signature` column. The signed bytes are the body's RFC 8785 (JCS) serialization, which the sink computes with its own serializer: this package does not export one.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@objectstack/scenarios': patch
3+
---
4+
5+
fix(scenarios): a confirmed write the server cannot take is not measured, clear declines read as declines, and the platform's user count is no leak
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
- **Confirmed write.** When the action door answers a confirmation turn's confirm-gated call `428 ACTION_CONFIRMATION_REQUIRED` with `details.reason: 'no_confirmation_service'`, the confirmed write is not measured. Before, it was graded `fail`. Such a server refuses every confirmed call, so no agent could pass. The ask ("asked first") is still graded. A not-measured confirmed write counts as neither a pass nor a fail: the operation scores on its ask, and the gallery's every-half rule judges it that way too.
11+
- **Declines.** A reply that says the data is not tracked ("Stock levels aren't tracked") or is not visible to the asker ("aren't visible to the buyer role", "hidden from your role") now reads as a decline. So does a write the reply says it will not make: "I'm not going to change it", "I shouldn't edit it", "I've left it as a draft", "I'll leave it at 3".
12+
- **Leaks.** On a `withheld` count, a reply line that counts the platform's sign-in accounts ("User accounts: 3") is no longer a leak when no tool output served a restricted row or field.
13+
- **Card.** `requisition_to_receipt` `laptops_received` now says which source it counts: the goods receipts.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/console': patch
3+
---
4+
5+
perf(console): a record page asks its app's object list beside the page list, not after it
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
Opening a record page inside an app read the page list first and asked the app's object list only once that answer had landed, so the record's data waited one more round trip than a list page's. Both outcomes of the page list read that object list first, so it now leaves in the same round trip as the page list: the same request, earlier. When the app bundle already says it cannot name the record's related objects (no bundle, a draft preview), nothing is started early, and the record page reads exactly what it read before.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
'@objectstack/objectql': minor
3+
'@objectstack/cli': minor
4+
'@objectstack/rest': minor
5+
'@objectstack/metadata-protocol': minor
6+
'@objectstack/spec': minor
7+
---
8+
9+
feat(units): `os migrate unit-codes` converts stored unit text into unit codes, from the operator's mapping
10+
11+
Clause-②: yes
12+
Metadata-protocol: added
13+
14+
ADR-0158 U7 R1, the backfill door (#35492). It is the twin of `os migrate record-currency-codes`.
15+
16+
**What it is for.** A field declared a unit code field after its rows were stored still holds free text such as `kg`, `公斤` or `lbs`. Since #35489 the engine checks each unit code it writes, so editing a quantity beside such a value is refused until the row holds a code. This door converts those rows in one run.
17+
18+
**`backfillUnitCodes`** (`@objectstack/objectql`, also exported: `formatUnitCodeBackfillReport`, `unitCodeBackfillComplete`, `unitCodeMappingOf` and the report types):
19+
20+
- **Which field.** `field` names the unit code field: the `text` field a quantity's `unitConfig.unitField` names, or a standalone `unitConfig: { unitMode: 'code' }` field. If you name the quantity, the refusal is `INVALID_FIELD` and names the field to use.
21+
- **The mapping.** It is the operator's, never derived. It maps stored text, exactly as written, to a unit code. Matching is exact: `kg ` and `KG` need their own entries.
22+
- **Targets are judged before any row is read**, as the write would judge them. A target that is not a standard UN/ECE Recommendation 20 code or one of the organization's own units, a retired unit, or a unit of another dimension than the field's `unitDimension` is refused `INVALID_FIELD` / 400 on the field. With no organization named, organization codes are judged in each organization the run would write them in, still before any write.
23+
- **Rows already holding a unit code are never rewritten**, so the run is idempotent: a second apply run writes nothing. That includes a unit the organization retired and a code of another dimension. Both are codes, not free text, and rewriting them from a mapping would change what the stored quantity means. Neither is a code the field admits: beside a quantity, the write check refuses each at the row's next quantity edit; a standalone unit field has no quantity, so the next write of the field must carry another code. So they are listed as `retired` and `other-dimension` and counted apart (`skippedRetired`, `skippedOtherDimension`), never as a code the field admits.
24+
- **A blank unit beside a quantity** is written only from an explicit `""` entry; without one it is counted (`blankBesideQuantity`) and named in the report. A blank unit with no quantity is left alone.
25+
- **Complete.** `unitCodeBackfillComplete` answers true only when every row holds a unit code the field admits: no unmatched value, no blank beside a quantity, no retired unit, no code of another dimension, no failed or unexamined row. The report prints its ✓ line only then.
26+
- **Dry run by default.** It lists each distinct stored value with its row count and what the mapping does with it, and writes nothing. With no mapping, the listing shows which spellings to map.
27+
- **Unmatched values.** An apply run that meets a value with no mapping entry is refused `VALIDATION_ERROR` / 400 on `mapping` before any write. The refusal names each value with its row count, and carries them as `unmatched`.
28+
- **Scope.** Scope is `organizationId` or `allOrganizations`, as on the currency backfill. An unscoped run over the rows of several organizations is refused with each organization's counts.
29+
- **Writes.** Each row is written through `engine.update` as a system write, so the unit check judges every converted code.
30+
31+
**`os migrate unit-codes --object O --field F [--map-file mapping.json] [--org ID | --all-organizations] [--apply] [--yes]`** (`@objectstack/cli`):
32+
33+
- It has the precedent's confirmation and exit behaviour: `--apply` asks first, and exits 1 under `--json` or with no terminal unless `--yes` is given.
34+
- A mapping file that is not JSON, or a mapping the engine refuses as malformed, is refused before the occupancy probe, the prompt and the boot.
35+
- Any refusal exits 1. Under `--json` it carries the code, the HTTP status, and `unmatched` or `organizations` where those apply.
36+
- It closes with a ✓ only when `unitCodeBackfillComplete` holds. A run that leaves a blank beside a quantity, a retired unit or a code of another dimension closes with a warning naming what is left.
37+
38+
**`POST /api/v1/meta/_migrate-unit-codes`** (`@objectstack/rest`) is the tenant-admin twin of `_migrate-record-currency-codes`.
39+
40+
- Its body is `{ object, field, mapping?, apply? }`, and any other key is refused 400.
41+
- It sits behind `metadata.endpoints.maintenance` and requires `setup.write`. It converts the caller's current organization only, and is a preview unless `apply: true`.
42+
- The report is the `data` of the shared envelope. A refusal over unmatched values answers 400 with `error.details.unmatched`.
43+
44+
**The unit refusals name the door** (`@objectstack/objectql`). The `ERR_UNIT_CODE_REQUIRED` and `ERR_UNIT_CODE_UNKNOWN` refusals of a quantity written beside a stored value the write did not supply now end with the remedy: the `os migrate unit-codes` command for that object and field, or the REST door. The refusal of a blank names the `""` entry. A refusal of a code the caller wrote carries no remedy.
45+
46+
**A metadata save that makes a stored field a unit code field is a destructive change** (`@objectstack/metadata-protocol`, `@objectstack/spec`). The detector judges the declaration and reads no row. Two findings sit beside `currency_mode_to_record` on the 409 `DESTRUCTIVE_CHANGE`, and `force: true` lifts them:
47+
48+
- `unit_code_field_declared`, on the code field: a stored field that is a unit code field after the save and was not one before. Any declaration can do it: a quantity, new or stored, whose `unitField` names the field; a `unitField` re-pointed at it; or its own `unitMode: 'code'`. A field that already was a unit code field raises nothing.
49+
- `unit_mode_to_record`, on the quantity: a stored quantity switched to `unitMode: 'record'`, whatever its `unitField`'s history (a unit code field already, or a field new in the same save). It names the blank units beside the quantity and the `""` entry that writes them. It is not raised when the same save raises `unit_code_field_declared` on that `unitField`, since that finding names the quantity, its blanks and the `""` entry, so each debt is reported once.
50+
51+
Each names the conversion run for that object and code field, CLI and REST.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@object-ui/components': patch
3+
'@object-ui/console': patch
4+
'@object-ui/cli': patch
5+
'@object-ui/plugin-gantt': patch
6+
---
7+
8+
fix(ui): danger text is readable in dark theme
9+
10+
Clause-②: no
11+
Metadata-protocol: none
12+
13+
In dark theme, `text-destructive` (a menu's Delete, error messages, danger links) used the deep red that is the fill of red buttons, about 1.6:1 on a dark menu. Text utilities now read their own token: each shipped `@theme` maps `--text-color-destructive` to `--destructive-text`, which only `.dark` defines (a brighter red that clears 4.5:1 on every dark surface). Light theme leaves it unset and falls back to `--destructive`, so it is unchanged; `bg-`, `border-` and `ring-destructive` and red buttons keep `--destructive`. New apps from `objectui init` carry the same split, and the Gantt resource view's over-capacity label reads the text token. A host that overrides `--destructive` for its own dark theme can set `--destructive-text` beside it.

‎.changeset/35685-list-cell-undo.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@object-ui/plugin-grid': patch
3+
'@object-ui/react': patch
4+
---
5+
6+
feat(list): undo a list cell save from its toast or with Ctrl+Z
7+
8+
Clause-②: yes (widening) — `toastRecordSave` in `@object-ui/react` takes an optional fourth argument, an `action` button the toast carries (new exported type `RecordSaveToastAction`), and `RecordSaveSink`'s options accept that `action`; nothing removed or renamed
9+
Metadata-protocol: none
10+
11+
In a grid that mounts `GridCellSelection` (the select-first grid every `ListView` draws), a landed cell save can be taken back:
12+
13+
- **The save toast has an Undo button**, and **Ctrl+Z** (Cmd+Z on macOS) on a cell of the grid undoes the newest save, then the one before it. Each save is taken back once.
14+
- **An undo is a new update, not a local rollback.** It writes the value each saved field held before the save (a relation as its stored id), with the version this grid's own newest write of the record answered as `If-Match`, so a change someone else made since answers 409 and opens the same conflict dialog as a save instead of being overwritten. A refused or cancelled undo is used up; the next Ctrl+Z undoes the save before it. The server's history records the save and its undo as two changes. Only the row is redrawn, as for a save.
15+
- Inside an open editor Ctrl+Z stays the editor's own text undo. On a cell, the grid's key is handled by the grid alone: the console's shared Ctrl+Z undo stack is not popped by it.
16+
- A save of a field the row did not read offers no Undo, rather than a partial one.
17+
18+
A grid without `GridCellSelection` (a related list in a record drawer, for one) now re-reads on every write of its object again, including a write the list around it draws itself: before, it skipped the writes that list held while they ran.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/objectql': patch
3+
'@objectstack/platform-objects': patch
4+
'@objectstack/plugin-security': patch
5+
---
6+
7+
fix(objectql): deleting an organization also deletes its units of measure, the one exemption from the `sys_unit` delete refusal
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: none
11+
12+
An organization that had ever created a unit of measure could not be deleted: the delete was refused with 409 `DELETE_RESTRICTED` naming `sys_unit`, and the units could not be removed first, because the engine refuses every delete of a unit (405 `ERR_UNIT_DELETE_REFUSED`). Now the organization delete's own cascade removes that organization's `sys_unit` rows, retired ones included, through the engine's delete path, after the delete has been admitted, so no unit row is left naming a deleted organization. `organizationOwnedRowCounts` (the question plugin-auth's organization delete asks first) and the engine's own refusal no longer count units as records the organization still owns.
13+
14+
**Declared behaviour change.** A delete door widens, in one place only. A delete of an organization that holds units and no other record now succeeds and removes the units; before, it was refused. An organization that owns any other record is still refused, and none of its units is removed. Every other delete of a unit is still refused with 405 `ERR_UNIT_DELETE_REFUSED`, by id and batched, for a user, a system writer and an automation run, including a delete issued by a hook while the organization's delete is running: the exemption is recognised from the engine's own cascade, never from anything a caller passes. Retire a unit (`retired: true`) to stop its use, as before.
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 host's session-creation organization choice can fall back when that organization's access policy would refuse the sign-in
6+
7+
Clause-②: yes
8+
Metadata-protocol: none
9+
10+
A host's `session.create.before` hook (`AuthManagerOptions.databaseHooks`) chooses the organization a new session is scoped to, and the framework then refuses the sign-in (`IP_NOT_ALLOWED`, 403) when that organization's own allowed IP ranges do not admit the request. The hook can now return an ordered list of fallbacks beside `data`:
11+
12+
```ts
13+
import type { SessionCreateBeforeResult } from '@objectstack/plugin-auth';
14+
15+
databaseHooks: {
16+
session: {
17+
create: {
18+
before: async (session): Promise<SessionCreateBeforeResult> => ({
19+
data: { ...session, activeOrganizationId: lastUsedOrgId },
20+
activeOrganizationCandidates: [ownedOrgId, oldestOrgId],
21+
}),
22+
},
23+
},
24+
},
25+
```
26+
27+
The session is scoped to the first organization, `data.activeOrganizationId` first and then the list in order, that the organization's scoping admits. Each one is judged exactly as the single choice is: the same client address the server established for the request, the same organization policy, the same tenant-level administrator exemption. When no candidate is admitted, the sign-in is refused as before, and the `login_failed` audit row names the host's first choice. The list never reaches the stored session.
28+
29+
`data` is required, as in better-auth's own hook result: a hook that returns only a list still returns `data: session` beside it. The candidates are the host's word: plugin-auth judges each organization's access policy, never membership, so list only organizations the user is a member of. A non-member candidate can be admitted at creation, and the per-request membership check then drops the session's organization.
30+
31+
Nothing changes for a host that returns no list or an empty one. A value that is not an array of non-empty organization ids is a host error and fails the session creation with a `TypeError`. The new public export is the type `SessionCreateBeforeResult`.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@objectstack/driver-sql': patch
3+
'@objectstack/driver-turso': patch
4+
'@objectstack/spec': patch
5+
---
6+
7+
feat(driver-sql, driver-turso): the SQL drivers compile the `SharedRecordIds` fixed-read leaf to a subquery (ADR-0155, step 3 of 6)
8+
9+
Clause-②: yes
10+
Metadata-protocol: none
11+
12+
No visible change on its own: nothing on main writes a `SharedRecordIds` leaf yet. The sharing plugin starts writing it at ADR-0155's last step.
13+
14+
- **The compile** (`@objectstack/driver-sql`). A `SharedRecordIds` leaf in a field's `$in` compiles to one subquery in the list's own position: `id IN (SELECT record_id FROM sys_record_share WHERE object_name = ? AND recipient_type = 'user' AND recipient_id = ? AND record_id IS NOT NULL AND record_id <> '')`. The write form adds `AND access_level IN (…)` inside the subquery. Every value is bound. The subquery carries no tenant scope (ADR-0155 ① ruled A), and the outer statement's tenant wall is unchanged. It compiles on every read verb and on `updateMany`, for SQLite, PostgreSQL, MySQL, SQL Server and Oracle. SQLite and PostgreSQL were run live for this release. MySQL, SQL Server and Oracle are pinned at compile shape, and MySQL also runs live in CI's Temporal Conformance job. On PostgreSQL, an object whose `id` column is not text (an integer- or uuid-keyed federated table) fails the compiled subquery with `DATABASE_ERROR` (42883) instead of answering its rows. That case is open on #35906 (ADR-0155 D-0) and is settled before the sharing plugin writes the leaf. On Oracle the `<> ''` half is left out, because Oracle stores `''` as NULL. `SqliteWasmDriver` and Turso's local mode inherit the compile.
15+
- **The remote transport** (`@objectstack/driver-turso`). Turso's remote mode compiles the same subquery with its own compiler, from the same predicates.
16+
- **The declaration.** `SqlDriver.supports.fixedReadLeaves` is `['SharedRecordIds']`, and `TursoDriver` inherits it in every mode. The engine's seam now hands the leaf to these drivers instead of refusing it.
17+
- **The refusal.** A leaf anywhere other than a field's `$in` comparand is refused before any statement runs, with `INTERNAL_ERROR` / 500, and logged at `error` once per driver.
18+
- **New exports** (`@objectstack/driver-sql`). `findMisplacedFixedReadLeaf`, `fixedInnerReadPredicates` and `misplacedFixedReadLeafMessage` are the walk, the predicates and the refusal text the two compilers share.
19+
- **The shared case-set** (`@objectstack/spec`). `SHARED_RECORD_IDS_CASE_SET` gains a note (`n5`) on a doc whose only grant is stamped in another organization, and a nested case read under a tenant. Together they witness, in the nested position, that the inner read carries no tenant scope.

0 commit comments

Comments
 (0)