Skip to content

Commit 8b1ecbb

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-ztk9p3
2 parents f05af6c + 0eb97fa commit 8b1ecbb

59 files changed

Lines changed: 2751 additions & 212 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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
---
4+
5+
fix(metadata-protocol): the layered read of a form view naming a field its object lacks now carries the form-field-unknown warning
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`GET /api/v1/meta/view/NAME?layers=true` judged its `_diagnostics` with the schema alone, so a published form view whose section names a missing field (or an undeclared field group) read `{ valid: true }` there, while `GET /api/v1/meta/view/NAME` of the same view carried the lint's warning. Studio's item editor reads the layered answer when no draft is pending, so the author of a published form view saw no warning.
11+
12+
The layered read now runs the same form-layout pass on its `effective` body that the single-item read runs, against the object the registry serves for each name the view spells. The warnings land at the same paths, and `valid` stays the schema's answer. A form naming only real fields still reads `{ valid: true }`.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/lint': minor
4+
'@objectstack/platform-objects': patch
5+
---
6+
7+
feat(spec): a flow start input can declare that it is the id of a record of a named object (`objectName`)
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: added
11+
12+
`FlowVariableSchema` declares one optional key, `objectName`: on an input (`isInput: true`), it says the input's value is the id of one record of the named object, e.g. `{ name: 'accountId', type: 'text', isInput: true, objectName: 'crm_account' }`. The key is **planned**: no door reads it yet, and `os validate` warns on every flow that writes it (`liveness-planned-property`). The contract it states, for the start doors to enforce: every door that starts the flow by name (the trigger route, an action of type flow over REST and MCP `run_action`, a declared endpoint of type flow) loads a declared input from that object in the caller's own scope before the run exists; an id the caller cannot read there is refused `404 RECORD_NOT_FOUND`, and a value that is not an id is refused `400 VALIDATION_FAILED` naming the input. An input without the declaration keeps the visible-read rule: it is judged as a record only where the flow's own definition reads it as a record id.
13+
14+
- **Spec.** `objectName` is an object name (snake_case) and is refused on a variable that is not an input, since no caller's value reaches one. `type` stays the data type: the variable holds the id. A `reference` or `object` key on a flow variable is still refused, and the refusal now names `objectName`. The flow form's variables repeater gains the column, labelled in the metadata-form bundles (en, zh-CN, ja-JP, es-ES).
15+
- **Lint.** `flow-input-unknown-object`: a declared object the stack does not define is a warning (it may come from another installed package), and an error at the runtime publish gate when the write's package closure does not reach it, the verdict `flow-trigger-unknown-object` gives a trigger object. A `sys_` name is not judged.
16+
17+
This is the contract half: the start doors read the declaration in a later change, and until then no door loads a declared input, so a start that hands the input an id the caller cannot read still runs. Nothing to do for existing flows.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
'@objectstack/lint': patch
4+
---
5+
6+
fix(metadata-protocol): both publish doors judge a stored flow draft in its D2-converted spelling, as the save door does
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
A flow draft stored in a legacy ADR-0087 D2 spelling that the automation engine registers (a `get_record` node's `config.filters`, for one) saved as a draft, because the save door judges a flow in its converted spelling and stores the body as written, but the per-item publish (`POST /meta/flow/:name/publish`) and the package publish (`publish-drafts`) then refused it with `422 INVALID_METADATA` (`expression-invalid`, `flow-region-shape-invalid`), because both judged the raw stored body. Both doors, and the draft read's publish verdict, now judge the stored draft through the save door's conversion seam, with the full conversion chain the engine replays when it registers a stored row, and promote it as stored: the active row is the draft's bytes. A draft the flow rules still refuse once converted is refused with the issues its current spelling gets.
12+
13+
The `flow-region-shape-invalid` explanation (`os explain`) now also names the server as a reader of the rule and the body it judges.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@objectstack/plugin-auth': patch
3+
---
4+
5+
fix(plugin-auth)!: a user preference's owner is fixed when the preference is saved
6+
7+
Clause-②: no (narrowing) — a non-system update of a `sys_user_preference` row that sends a `user_id` other than the stored one is refused `403 PERMISSION_DENIED`, which some callers' writes were admitted before. Nothing is widened.
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 or type changes: a save rule on one platform object refuses a change of the row's owner. The refusal is a 403 a caller cannot work around by rewriting metadata, so there is nothing for a migration to rewrite and no tombstone. -->
11+
12+
**BREAKING** accept-set narrowing at the generic data door for `sys_user_preference` (`@objectstack/plugin-auth`).
13+
14+
- **Now.** A preference belongs to the user it was saved for. An update that sends a different `user_id` is refused `403 PERMISSION_DENIED`, for every caller but the system: a member, an organization administrator and a platform administrator alike. The refusal names the row and the `user_id` column. The row is unchanged.
15+
- **Unchanged.** An update that echoes the stored `user_id`, or does not send it, saves as before. The console's preference writer updates `value` only and creates rows in the caller's own name, so it is not affected. A system write (the platform's own writers) is not judged.
16+
- **Shared rule.** `sys_personal_view` and `sys_user_preference` now hold this with one check, `owner-fixed-rule.ts`. The personal view's behaviour and message are unchanged.
17+
- **Who sees it.** A client that changes the `user_id` of a saved preference.
18+
19+
**The remedy.** Save a new preference in the other user's name, as that user, instead of moving one.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/objectql': patch
3+
---
4+
5+
fix(objectql)!: a string-typed field refuses a Date, a Map, a Set, a class instance or a typed array as its value, as it already refused a plain object or an array (#29645)
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 or type changes: what a metadata author writes is read exactly as before. Only a record write carrying an object of the wrong shape on a text-family field is refused, with the validator's existing invalid_type code and the existing ADR-0104 shape sentence, so there is nothing for objectstack migrate meta to rewrite and no tombstone. Rows already stored are not rewritten by this change, so no stored-row migration is prescribed either. -->
11+
12+
**BREAKING** accept-set narrowing at the record write door (`@objectstack/objectql`), on the engine's insert, insertMany, update by id, update by predicate and the `validate()` dry run. Those are the doors flows, hooks and server code write through; a JSON request body carries none of these values, so REST callers see no change.
13+
14+
- **Before.** The string arm refused a plain object or an array, but its object test was prototype-strict, so any other object passed on its string reading. On a `text`, `textarea`, `password`, `markdown`, `html`, `richtext`, `code`, `signature` or `qrcode` field, driver-memory stored the object itself and SQLite stored a `Date` as its epoch number in TEXT (`"1767312000000.0"`), a `Map` or a `Set` as `"{}"`, and a class instance or a typed array as its JSON text. On `email`, `url` and `phone` the same write was refused, but only because that string failed the format check (`invalid_email`, `invalid_url`, `invalid_phone`).
15+
- **Now.** Every object is refused `invalid_type` with the sentence `FIELD has an invalid TYPE value: expected a string, received an object`, on all twelve types, before any bound or format is judged, so the three format types now answer `invalid_type` for an object instead of their format code. The driver is never written. A readonly field's value is judged the same way, as a shape check.
16+
- **Unchanged.** A string. A number and a boolean, which keep their string reading and are stored as that string. `null` and a missing value. A plain object and an array (already refused). A filter-operator object keeps its own earlier refusal sentence. A `json` field and the structured-JSON types still hold any object.
17+
18+
**The remedy.** Write the string you mean: `value.toISOString()` for a `Date` on a text field (or declare the field `datetime`), `JSON.stringify(...)` when JSON text is really what the field should hold, or declare the field `json` when it holds structured data.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@objectstack/runtime': patch
3+
---
4+
5+
Clause-②: no
6+
Metadata-protocol: none
7+
8+
`GET /packages/<base>/export` carries the base's own document again while its `.custom` pair's override of an item is live (measured for dashboard, report, page, app, dataset, doc and book) (ADR-0146 D8 item 3). On a boot that also holds the base's code documents in the metadata service, as every `defineStack` host does, the per-package layer listed only the override copy under the base's name, and the export's override filter (#29563) left the item out of the base's export. The export now serves the base's code artifact in that item's place, so the base's export is byte-identical with or without a published override, and still carries no `overrides` block.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/runtime': patch
3+
---
4+
5+
fix(runtime): New similar on a flow with a live override writes a copy instead of answering 403 NOT_OVERRIDABLE
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
When an administrator had customized a packaged flow in Studio and published the override, New similar (`POST /api/v1/automation/:name/clone`) refused with `403 NOT_OVERRIDABLE`: the copy kept the override's `overrides: { package, basedOn }` block under its new name, so it declared an override of a flow the base does not ship. The clone now drops the override declaration along with the protection envelope (`FLOW_CLONE_DROPPED_KEYS` derives `OverrideDeclarationFields`), so the copy is the customization package's own item under its new name, switched off as before (ADR-0146 D2, D4). It copies what the source serves, which with a live override is the override's definition. The override itself is left as it was.

‎content/docs/automation/flows.mdx‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,6 +2029,7 @@ variables: [
20292029
| `isInput` | `boolean` | Available as input parameter |
20302030
| `isOutput` | `boolean` | Available as output parameter |
20312031
| `defaultValue` | `unknown` | Bound at run start when no parameter supplies one — this is what makes the declaration a guarantee. Optional |
2032+
| `objectName` | `string` | **Planned.** On an input only (refused at parse on any other variable): the input is the id of a record of this object. No start door reads it yet. See [a start input that is a record id](#a-start-input-that-is-a-record-id). Optional |
20322033

20332034
### `defaultValue` — declaring a variable is not the same as binding it
20342035

@@ -2098,6 +2099,56 @@ The value is **not** checked against the declared `type` — `type` is an open
20982099
string, so there is no vocabulary to check against. It behaves like every other
20992100
`defaultValue` on the authoring surface.
21002101

2102+
### A start input that is a record id
2103+
2104+
An input may declare that its value is the id of a record of a named object,
2105+
with `objectName` — the word the CRUD nodes use for the object they read:
2106+
2107+
{/* os:check */}
2108+
```typescript
2109+
import { defineFlow } from '@objectstack/spec/automation';
2110+
2111+
export const CloseAccount = defineFlow({
2112+
name: 'close_account',
2113+
label: 'Close Account',
2114+
type: 'autolaunched',
2115+
variables: [
2116+
{ name: 'accountId', type: 'text', isInput: true, objectName: 'crm_account' },
2117+
],
2118+
nodes: [
2119+
{ id: 'start', type: 'start', label: 'Start' },
2120+
{ id: 'end', type: 'end', label: 'End' },
2121+
],
2122+
edges: [{ id: 'e1', source: 'start', target: 'end' }],
2123+
});
2124+
```
2125+
2126+
<Callout type="warn">
2127+
**Planned — no door applies this yet.** The declaration parses, is refused on a
2128+
variable that is not an input, and is linted, but no start door loads a
2129+
declared input today: a start that hands it an id the caller cannot read still
2130+
runs. `os validate` warns on every flow that writes it
2131+
(`liveness-planned-property`). The contract below is what the start doors will
2132+
enforce.
2133+
</Callout>
2134+
2135+
The contract: every door that starts the flow by name (the trigger route, an
2136+
action of `type: 'flow'` over REST and MCP `run_action`, a declared endpoint of
2137+
`type: 'flow'`) loads a declared input from the named object in the caller's
2138+
own scope before the run exists. An id the caller cannot read there is refused
2139+
`404` `RECORD_NOT_FOUND`; a value that is not an id is refused `400`
2140+
`VALIDATION_FAILED` naming the input. An input without the declaration is
2141+
judged as a record only where the flow's own definition reads it as a record id
2142+
(see the `404` row under [running a flow via the API](#run-a-flow-via-api)).
2143+
2144+
- **Inputs only.** A variable that is not `isInput: true` receives nothing from
2145+
a caller, so `objectName` there is refused at parse.
2146+
- **`type` stays the data type.** The variable holds the id the caller sent, so
2147+
it is `'text'`; `type: 'record'` already means a variable that holds a whole
2148+
record (a `get_record` node's `outputVariable`), and is not the declaration.
2149+
- **The name is checked.** `os validate` warns when the stack defines no object
2150+
of that name (`flow-input-unknown-object`); a `sys_` name is not judged.
2151+
21012152
<Callout type="warn">
21022153
**Reading a variable that might be unbound: only the `vars.`-scoped guard
21032154
works.** Conditions are strict CEL, and `has()` is not the escape hatch it looks

‎content/docs/deployment/validating-metadata.mdx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,8 @@ no package provenance (#9612); a provenance it cannot read narrows nothing at al
740740
That changes what a rule can **resolve**, never which rules run, and nothing at
741741
this door walks `packages[]`. Two rules are told the closure is in force. A flow
742742
whose trigger object is outside it is refused with `flow-trigger-unknown-object`
743-
instead of advised (#24669), and a list
743+
instead of advised (#24669), as is a flow with a start input declared a record of
744+
an object outside it, with `flow-input-unknown-object` (#29442), and a list
744745
view bound to an object outside it is refused with
745746
`list-view-object-outside-closure` instead of having its field references
746747
skipped (#24563). With no closure in force — a write that names no package —

‎content/docs/permissions/system-context.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ bugs — it is the protection or the side effect that silently does not happen.
143143
| 25 | Engine-owned / append-only write guard bypassed | plugin-security | Get: generic writes to `managedBy` engine-owned objects | `packages/plugins/plugin-security/src/system-write-guard.ts#isUserContextWrite`, `packages/plugins/plugin-security/src/system-write-guard.ts#assertEngineOwnedWriteAllowed` |
144144
| 26 | Identity write guard bypassed (ADR-0092) | plugin-auth | Get: direct writes to identity tables through the generic data path | `packages/plugins/plugin-auth/src/identity-write-guard.ts#isUserContextWrite` |
145145
| 26b | API key restore guard does not refuse | plugin-auth | Get: a write setting `revoked: false` on a `sys_api_key` row an administrator's forced password reset revoked is admitted without the platform-administrator check a user-context restore must pass; the reason is still cleared. Lose: nothing a caller reaches: no system writer restores a key, and the mint, the last-used stamp and the forced reset itself never set `revoked: false` | `packages/plugins/plugin-auth/src/api-key-restore-guard.ts#isUserContextWrite` |
146-
| 26c | **Personal-view owner rule does not refuse** — a `sys_personal_view` update that changes `user_id` is admitted | plugin-auth | Get: a system writer can move a personal view to another owner (no shipped system writer does). Lose: nothing a caller reaches. A non-system update whose `user_id` differs from the stored owner is refused `403 PERMISSION_DENIED`, for every caller, a platform administrator included; an echo of the stored owner is no change. The rule exists because, for an organization member, `member_default`'s `'*'` update floor (`created_by == current_user.id`) applies to an update in place of the object's own row scope | `packages/plugins/plugin-auth/src/personal-view-hooks.ts#registerPersonalViewHooks` |
146+
| 26c | **Per-user owner rule does not refuse** — a `sys_personal_view` or `sys_user_preference` update that changes `user_id` is admitted | plugin-auth | Get: a system writer can move a personal view or a preference to another owner (no shipped system writer does). Lose: nothing a caller reaches. A non-system update whose `user_id` differs from the stored owner is refused `403 PERMISSION_DENIED`, for every caller, a platform administrator included; an echo of the stored owner is no change. One shared check holds it for both objects. The rule exists because, for an organization member, `member_default`'s `'*'` update floor (`created_by == current_user.id`) applies to an update beside the object's own row scope | `packages/plugins/plugin-auth/src/owner-fixed-rule.ts#isOwnerChange` |
147147
| 27 | Search-companion column **kept** in a read's rows when it was explicitly requested | objectql | Get: the internal companion column is readable. Lose: nothing for app code — this is the engine reading its own index | `stripSearchCompanionFromRead` |
148148
| 28 | Dependent-count disclosure on a blocked delete | objectql | Get: the count of blocking children. Nothing was elevated past the caller, so nothing is withheld | `dependentCountIsDisclosable` |
149149
| 29 | Reference-cleanup log attributes the write to `'system'` | objectql | Get: an honest actor label instead of `anonymous` when the context carries neither `userId` nor `actor` | `recordReferenceCheckElevation` |
@@ -575,7 +575,7 @@ and CI refuses one that differs from what the tree produces.
575575
| `packages/plugins/plugin-auth/src/api-key-restore-guard.ts#isUserContextWrite` | 1 | 26b |
576576
| `packages/plugins/plugin-auth/src/auth-plugin.ts#start` | 1 | 12 |
577577
| `packages/plugins/plugin-auth/src/identity-write-guard.ts#isUserContextWrite` | 1 | 26 |
578-
| `packages/plugins/plugin-auth/src/personal-view-hooks.ts#registerPersonalViewHooks` | 1 | 26c |
578+
| `packages/plugins/plugin-auth/src/owner-fixed-rule.ts#isOwnerChange` | 1 | 26c |
579579
| `packages/plugins/plugin-auth/src/principal-session-mint.ts#refuseUpFront` | 1 | 61b |
580580
| `packages/plugins/plugin-email/src/email-template-door.ts#isOrganizationWrite` | 1 | 59 |
581581
| `packages/plugins/plugin-security/src/flow-system-identity-write-refusal.ts#elevationSource` | 1 | 1b |

0 commit comments

Comments
 (0)