Skip to content

Commit 27abd45

Browse files
Merge branch 'main' into claude/project-thread-3giljf
2 parents 17cfbf8 + c6230f4 commit 27abd45

188 files changed

Lines changed: 9829 additions & 490 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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
---
4+
5+
refactor(metadata-protocol): `applySeedBodies` builds its seed host on the class's per-instance host
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
- The body of `ObjectStackProtocolImplementation#applySeedBodies` (the host it hands the seed apply, with the slot that reads the `field-files` service from the kernel's registry) moves unedited out of `protocol.ts` into `protocol-publish-batch.ts` as `applySeedBodiesOnHost`, which runs on the class's host (`protocol-host.ts`). The method keeps its signature and docblock and is now one forwarding call, so the facade gate no longer needs an exception row for it.
11+
- No behaviour changes and nothing to do on upgrade: a published seed's files are still stored through the `field-files` service, as the boot seed's are. The built declaration files are unchanged; the source maps move.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/plugin-audit': patch
3+
'@objectstack/cli': patch
4+
---
5+
6+
feat(plugin-audit,cli): `os audit verify`, the live check of the sealed audit ledger
7+
8+
Clause-②: yes (widening) (a new command, new exports and a new stored checkpoint column; nothing main accepts is refused)
9+
Metadata-protocol: none (no authorable key; `lifecycle.seal` is unchanged)
10+
11+
The live check of ADR-0154 D9. The proof bundle (`--out`, `--bundle`, `--trusted-key`) follows separately.
12+
13+
- **`@objectstack/cli`.** New command `os audit verify` (`--org`, repeatable; `--from` / `--to`; `--json`; `--database-url`). It boots read-only, opens the checkpoint seeds and the signing key through the crypto provider `os serve` seals with (it never mints a key), and reads the hot store and the declared `archive` datasource. Every row a checkpoint lists reads `unmodified`, `modified`, `missing`, `late`, `redacted` or `expired`. A row of a sealed window that no trusted checkpoint lists reads `late` and unsealed. It prints the fingerprints of the signing keys it trusted. Exit 0 when everything verifies (or nothing is sealed), 1 on any `modified`, `missing` or unsealed row or any chain fault, and 2 on a usage error, a failed boot, a crypto provider that cannot open what is sealed, an archive datasource a sealed object declares that the run did not connect, or a check that stopped partway.
14+
- **`@objectstack/plugin-audit`.** New exports `verifyAuditLedger`, `AUDIT_ROW_VERDICTS` and the types `AuditVerifyReport` and `AuditRowVerdict`. A key is trusted only when its wrapped private half opens and derives its public half, the same rule the signer signs by. A checkpoint signed under any other key, or whose signature, stored leaf hashes or seed fails, holds nothing. Links are checked over each whole chain. The acceptance rules for redaction (D7) and expiry (D8) amendments are in place now; their writers come later. `sys_audit_checkpoint` gains a `leaf_hashes` column: each sealed row's leaf hash, in row-id order. It is unsigned, and is trusted only when it rebuilds the signed Merkle root, so each row is judged on its own. Checkpoints are written only by the sealer, and no host composes it with a crypto provider yet.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): the objectstack-data field-types rule teaches a line amount that follows its `master_detail` parent's currency
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`skills/objectstack-data/rules/field-types.md` § Currency taught `currencyField` only as a sibling code field, so an author building an invoice with line items gave each line its own code. It now teaches the two-segment form `'<master_detail field>.<parent code field>'` with one invoice and line-item example: one hop through a `master_detail` (a `lookup` path is refused) to the parent's `iso_4217_currency` field; a blank parent code refuses the line amount (`ERR_CURRENCY_CODE_REQUIRED`) and the code backfill refuses a path; a `sum`/`min`/`max`/`avg` roll-up through that `master_detail` declares `currencyConfig: { currencyMode: 'record', currencyField: <parent code field> }`; and once a line follows, the parent's code cannot change (`VALIDATION_FAILED`, a first code over a blank one passes) until no line follows it. Growth is paid first by same-file deletions of restated text: the dataset-measure `currency` sentence (home: objectstack-ui § Dashboards), the autonumber "Incorrect vs Correct" pair (home: § Autonumber rules 1 and 2) and the `user` row's `deleteBehavior` parenthetical (home: `rules/relationships.md` § Delete Behaviors).
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/core': patch
4+
---
5+
6+
fix(spec)!: install refuses the namespace `runs`, so no namespace it accepts is left without a qualified hook address (ADR-0150 D5)
7+
8+
Clause-②: no (narrowing)
9+
Metadata-protocol: narrowed
10+
11+
<!-- adr-0087: registered manifest-namespace-address-literal-refused -->
12+
13+
**BREAKING** accept-set narrowing for ADR-0150 D5: `runs` joins the namespaces the address grammar refuses (`actions`, `connectors`, `global`, `hooks`, `oauth`, `trigger`). Measured first-party: 0 manifests, examples, fixtures or templates declare it.
14+
15+
- **Why.** The qualified inbound hook `POST /api/v1/automation/hooks/:ns/:flowName/:hookId` never takes `runs` as its qualifier: `POST /api/v1/automation/hooks/runs/:runId/resume`, `…/cancel` and `…/restore-suspension` are the run doors of a flow named `hooks`, with the same verb and arity. A package namespaced `runs` therefore had no qualified hook address, and it was the one such namespace install still accepted.
16+
- **Before.** A package under `namespace: 'runs'` validated, built and installed, and its hook answered at the bare path only.
17+
- **Now.** `NAMESPACE_POSITION_LITERALS.inboundHook.literals` (`@objectstack/spec/kernel`) reads `['runs']`, so `NAMESPACE_REFUSED_LITERALS` holds `runs` and the one judge (`validateNamespaceNotAddressLiteral`) names it with its door, `/automation/hooks/runs`. Every reader of that judge follows with no code of its own: the registry's install gate raises `NAMESPACE_CONFLICT` (422), which `POST /api/v1/packages` answers as that code and `os package install`, through the install-local door, as `422 PLUGIN_REGISTER_FAILED`, both carrying the judge's sentence; `os validate` and `os build` exit 1 and `os build` writes no artifact; `defineStack` warns once and still returns the stack; and `os migrate stored-references` lists an installed one under `literalNamespaces`. `readNamespacePositionSegment('inboundHook', 'runs', …)` reads `literal`; no door asks it about the hook's position today.
18+
- **A package already held under `runs`.** It keeps booting, and a re-install or an upgrade under the same id and namespace still installs. New for it: the boot warns once that its namespace spells an address literal, and the report above lists it.
19+
- **The judge's sentence, for all seven literals.** It now says "so the package's qualified addresses there would never reach it": the refusal is about the doors it names, and a package under `runs` keeps every qualified address but its hook's.
20+
- **One source.** `INBOUND_HOOK_QUALIFIER_EXCLUSIONS` (`@objectstack/core`) is that spec entry itself, no longer a second spelling of `['runs']`. Its value is unchanged, and so is every answer of the allow-list row and of the trigger mount.
21+
- **Who moves.** An author whose stack, or a `packages[]` body, declares `namespace: 'runs'`, at `os validate`, `os build` and a new install. **The one-line fix:** FROM `namespace: 'runs'` TO any other namespace, e.g. `namespace: 'runs_app'`, and its object names' prefix with it. An object's name is its table name, so a deployment that already holds data under the old names and moves to the new namespace renames those objects, and with them their tables: plan that data move before upgrading the package, or keep the package installed under `runs`, which the server keeps booting.
22+
- **Migration entry.** `manifest-namespace-address-literal-refused` (protocol 18, semantic) states this refusal for the class, all seven literals, so the upgrade guide and `os migrate meta` carry it.
23+
- **Unchanged.** The qualified addresses of a package under `runs` on every other door (`/automation/runs/:name`, `/automation/trigger/runs/:name`, `/automation/connectors/runs/:name/connection`, `/actions/runs/…`, `/meta/:type/runs/:name`) answer as before, and its hook is still reached bare. A namespace that only contains the literal (`runs_app`, `reruns`) is accepted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
'@objectstack/objectql': patch
4+
'@objectstack/driver-mongodb': patch
5+
'@objectstack/cli': patch
6+
---
7+
8+
feat(metadata-protocol, objectql, driver-mongodb, cli): the permission-set grant table gets its package-less guard at schema sync on every kernel that runs its DDL, and a runtime-owned Mongo unique the server refuses is reported at `error` (#32164)
9+
10+
Clause-②: no
11+
- A runtime-owned unique on MongoDB (`RUNTIME_OWNED_UNIQUES`: the activation ledger's `uniq_sys_metadata_activation_packageless`, and now the grant's) that the server refuses at collection sync: on a duplicate (`E11000`), FROM the collection's whole sync failing (reported by the engine as "Schema sync FAILED", the declared indexes after it and the widening arm not run) TO one `error` line naming the index, its key, the consequence and the aggregation that lists the duplicates, with the sync going on; on an options or key-spec conflict (85, 86), FROM skipped without a word TO one `error` line naming the index and what to inspect, and saying the key is enforced only as far as the index in its way enforces it (an older unique on the same fields does). Either way the index is not built, and the widening arm keeps any older unique it stands in for, as it did. A declared index the server refuses is unchanged.
12+
13+
Metadata-protocol: none
14+
15+
<!-- adr-0087: not-required (no-migration-prescription) No key of any authorable schema is added, removed, renamed or re-shaped. The change adds a runtime-managed physical index beside a platform table's declared key, a kernel-bus event, and an error line. No stored metadata row is rewritten, so there is nothing for `objectstack migrate meta` to rewrite. -->
16+
17+
Part of #32164 (ADR-0150 D4). It lands ahead of the change that widens `sys_user_permission_set`'s key to `(user_id, permission_set, permission_set_package, organization_id)`. That key is NULL-distinct, and a grant names no package whenever the environment authored its set, the platform registered it, or two packages hold it with no binding yet, so for exactly those grants the wider key constrains nothing. The guard keeps them to one per `(user_id, permission_set, organization_id)`.
18+
19+
**The guard: `uniq_sys_user_permission_set_packageless`.**
20+
21+
- On SQL, `metadata-protocol` builds it: a partial unique index `(user_id, permission_set, organization_id) WHERE permission_set_package IS NULL` on SQLite and PostgreSQL, a functional key part over the driver's hash-shadow digest on MySQL 8.0.13+, and a UNIQUE key over an INVISIBLE generated column `uniq_sys_user_permission_set_packageless__hash` on MariaDB 10.3+ (the SQL driver's drift check reads that column as the guard's carrier, never as an orphan). On MongoDB, `driver-mongodb` builds it at collection sync with the object's own indexes (`RUNTIME_OWNED_UNIQUES`, `permission_set_package: null`, which matches a missing field and an explicit null).
22+
- When: at schema sync, not `kernel:ready` (epic ruling on #32164). `ObjectQLPlugin` now triggers `objectql:schema-synced` (exported as `OBJECTQL_SCHEMA_SYNCED_HOOK`) when each schema-sync pass's DDL is done, with the engine as its argument, and `metadata-protocol` builds the guard from it. The boot's first pass runs inside its schema-migration lock, so the guard stands before any later plugin's `start()` writes a grant, and on a `bootPhaseHooks: false` host too: the plugin triggers that event, the kernel does not, so the option does not withhold it. Every later pass checks it again, because a SQLite table rebuild drops every index it does not declare, and the check reads the catalog first: DDL only when the guard is missing, so a `metadata:reloaded` re-sync over a standing guard sends none. On PostgreSQL a `CREATE UNIQUE INDEX IF NOT EXISTS` over a standing index waits for the table's SHARE lock behind every open write, and holds every new write behind it, before it finds the name taken (measured on PostgreSQL 16); the MySQL family refuses that statement outright. A refusal is reported once per boot. Pinned through a booted kernel: two grants naming no package, written from a plugin's `start()` before `kernel:ready`, are refused at the second, with and without `bootPhaseHooks: false`; with the build moved back to `kernel:ready`, both pins go red. A guard dropped after the boot is back after the next pass; with `created` latched, that pin goes red. A second pass over a standing guard sends no DDL, on SQLite and, with a write open on the table, on PostgreSQL 16; with the catalog read removed, both pins go red.
23+
- Where: on every kernel whose schema sync runs the table's DDL, not behind the `runPlatformMigrations` gate that arms the boot repairs (MF6's review, must-fix 1). That gate is off on a kernel that passes an `environmentId` without declaring it (a per-project kernel) and on every one-shot CLI boot, and both create this table at their own schema sync, so both build the guard. Pinned on both: a kernel with an `environmentId` and nothing declared, and one that declares `runPlatformMigrations: false` (with `bootPhaseHooks: false`); with the subscription back inside the gate, both go red.
24+
- A boot that runs no DDL builds nothing. `os migrate plan` and every dry-run mode boot with their drivers holding DDL back, and `metadata-protocol` reads that (`schemaDdlDeferred`) and leaves the database as it was. `os migrate apply` holds its DDL back until the operator confirms; its flush then performs it and triggers `objectql:schema-synced` again (`DeferSchemaDdlPlugin.announceSchemaSynced`), which builds the guard. A write mode that boots without deferring (`--apply` of the data commands) builds it at its sync. Pinned in `packages/cli` over a SQLite file: the write boot builds it, the read-only boot leaves a table without it untouched, and `apply` on a fresh database has neither before the confirmation and both after the flush.
25+
- A `skipSchemaSync` boot (`OS_SKIP_SCHEMA_SYNC`) runs no DDL and triggers no pass. Its tables come from the boot that runs their DDL (a serving boot, an `OS_MIGRATE_AND_EXIT=1` job, or `os migrate apply`), and that boot builds the guard with them. Where the boot-repair gate is on, its `kernel:ready` repair also builds it, for a database whose DDL came from somewhere that did not. The skip-sync face of `os migrate plan` / `apply` (a Turso remote primary) builds nothing on the primary, which its serving boot provisions.
26+
- A server with no form for it (MySQL before 8.0.13, MariaDB before 10.3) keeps the old three-column key instead: an upgraded database keeps the one it has, and a database without one gets it under the name the SQL driver generates for it, `uniq_sys_user_permission_set_ac248331`, so the driver's widening arm reads it as the superseded key and keeps it until the guard can be built. It refuses every second grant naming no package, and also one user's grant of a second package's set of the same name in one organization: a declared limit of those servers. One `error` line says so each boot.
27+
- Refuse, never keep-one: a database that already holds two grants naming no package of one `(user_id, permission_set, organization_id)` keeps them. The build fails and logs, at `error`, the duplicated keys, the consequence and the query that lists them (on MongoDB, the aggregation), and the next boot tries again. `os migrate duplicates` lists this index too, six in all.
28+
- Admits nothing new, refuses nothing new, while the grant's declared key is still `(user_id, permission_set, organization_id)`: that key already refuses every second grant the guard would, and the guard exempts a NULL organization as that key does.
29+
- Measured on SQLite (`node:sqlite`, and a booted kernel over `better-sqlite3`) and PostgreSQL 16. The MySQL and MariaDB forms and the real-mongod pins are pinned in suites that run on `main` only, so they first run after this lands.
30+
31+
**In-process APIs.** `@objectstack/objectql` exports `OBJECTQL_SCHEMA_SYNCED_HOOK`. `@objectstack/cli`'s internal `DeferSchemaDdlPlugin` gains `announceSchemaSynced`. `@objectstack/metadata-protocol` exports `ensureUserPermissionSetPackagelessIndex`, `createUserPermissionSetGuardAtSchemaSync`, `buildUserPermissionSetPackagelessIndexSql`, `buildUserPermissionSetPackagelessDuplicateProbeSql`, `buildUserPermissionSetOldKeySql`, `resolveUserPermissionSetIndexSeam`, `USER_PERMISSION_SET_PACKAGELESS_INDEX_NAME`, `USER_PERMISSION_SET_PACKAGELESS_INDEX_COLUMNS`, `USER_PERMISSION_SET_OLD_KEY_INDEX_NAME` and the result, status and pass-outcome types. `driver-mongodb`'s `SchemaSyncLogger` gains an optional `error`; a logger without it gets that line at `warn`. All additive.
32+
33+
Unchanged: `driver-memory` builds no guard (no raw-SQL seam, the activation ledger's exemption). A pin measures that its unique check treats a NULL package as distinct; the change that widens the key declares what that admits.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@objectstack/objectql': patch
3+
'@objectstack/driver-memory': patch
4+
---
5+
6+
fix(objectql, driver-memory): a plugin driver's `where` refuses a combinator operand that is not a filter node, as every native driver does; driver-memory gates a class-instance `where` root like a literal one
7+
8+
Clause-②: no (narrowing)
9+
Metadata-protocol: none
10+
11+
On an object served by a plugin driver (a virtual object, `driver-odata` or any other plugin-published driver on an external datasource), the engine's floor applies the `where` itself over the rows the driver returned. A `where` whose `$and` / `$or` element or `$not` operand is not a filter condition object (a condition array, `null`, a string), or whose `$and` / `$or` operand is not a list, was evaluated anyway: `{ "$and": [[{ "stage": "won" }]] }` answered no row, `{ "$or": [null] }` every row, `{ "$not": "won" }` no row, and `{ "$and": { "stage": "won" } }` was read as a one-element list. driver-sql, driver-memory and driver-mongodb refuse each of these. The floor now refuses them too, `INVALID_FILTER` / 400, before the driver is asked for a row, in the drivers' words with the position named, for example `Filter node at where.$and[0] is a array (…), not a filter condition object.` or `Filter combinator "$and" at where.$and requires an array of filter conditions, …`, on `find`, `findOne` and `count`.
12+
13+
driver-memory's shape gate skipped a `where` root that is not a plain object, though the engine admits a class instance there and the driver reads it by its own keys. A class instance carrying `{ $and: [[…]] }` answered no row and one carrying `{ $or: [null] }` threw an uncoded `TypeError`. Such a root is now walked like a literal one and refused in the same words; a class instance carrying a valid filter answers what its literal twin answers. Only in-process callers can pass one: JSON over HTTP always parses to plain objects.
14+
15+
To fix a refused call, write each `$and` / `$or` element and the `$not` operand as a plain filter object, and `$and` / `$or` as a list of them: `{ "$and": [{ "stage": "won" }] }`, not `{ "$and": [[{ "stage": "won" }]] }`. Object-form filters answer exactly as before.
16+
17+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no stored row changes shape: the refused operands were never valid under FilterConditionSchema (every $and / $or element and the $not operand is declared a FilterCondition object, and $and / $or a list), so no row validated against the spec carries one. What moves is the floor's answer to a where that bypassed the schema, from a wrong row set to a refusal. -->

0 commit comments

Comments
 (0)