Skip to content

Commit 5620dd9

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-b11gkm
2 parents 4e87db6 + 7189fb2 commit 5620dd9

31 files changed

Lines changed: 1519 additions & 306 deletions
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@objectstack/lint': minor
3+
---
4+
5+
fix(lint)!: a roll-up summary whose `summaryOperations.filter` names a key its child object lacks is refused at build and publish (`object-field-ref-unknown`), because every child write then fails its recompute
6+
7+
Clause-②: no (narrowing) — `os validate`, `os build`, `os lint` and the object save and publish doors refuse a summary field they accepted before. No export is added: the position joins the existing `object-field-ref-unknown` rule.
8+
Metadata-protocol: narrowed
9+
Skills-docs: none — `skills/**` and `content/docs/**` teach `summaryOperations.filter` keys that are fields of the child object, which this rule accepts. The reasoning ships in the `os explain object-field-ref-unknown` entry.
10+
11+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed or renamed: summaryOperations.filter keeps its shape and meaning, and lint now judges its keys against the child object the way lookupFilters[].field is judged against the referenced one. A refused key never filtered what the author meant (every child write answered a recompute failure and the summary stayed stale), so there is no rewrite that keeps the author's intent: the author names a real child field, and the verdict names the nearest one. -->
12+
13+
**BREAKING** accept-set narrowing in `os validate` / `os build` / `os lint` and at the object save and publish doors (`PUT /api/v1/meta/object/NAME` live save, the per-item and package publish; Studio, REST and MCP authors), through the `object-field-ref-unknown` rule.
14+
15+
- **Before.** A summary field with `summaryOperations: { object: 'invoice_line', function: 'sum', field: 'amount', filter: { stauts: 'paid' } }` parsed, built and published. The engine runs the filter as the `where` of an aggregate on the child, ANDed with the parent-FK match. Measured on a real `SqlDriver` (better-sqlite3): every insert of a child row then answered `SummaryRecomputeError` ("the triggering records WERE written"), and the summary kept a stale value.
16+
- **Now.** Each key the child lacks is refused `error` at `objects[i].fields.FIELD.summaryOperations.filter.KEY`, naming the key, the child object and the nearest field ("Did you mean"). Keys inside `$and` / `$or` / `$not` groups are judged too. Three more shapes the recompute query refuses are refused the same way, each measured on the same driver as a `SummaryRecomputeError` on every child insert:
17+
- a dotted key such as `account.status`: the cure is the nested one-level form the query serves, `{ account: { status: VALUE } }`;
18+
- a child field computed on read, such as a `formula`: denormalise it onto the child as a stored field;
19+
- beneath a relation, a key the related object lacks, a dotted key, a second relation holding a condition of its own, or an empty condition. The nested form reaches one level.
20+
- **Accepted.** Child fields with any operator, and the nested one-level relation form `{ relation: { field: VALUE } }` over fields of the related object.
21+
- **Not judged.** A child object the stack does not define, a child with no readable field map, and a registry-injected system column (resolved per object), the same skips every position of this rule takes.
22+
23+
**What an author does.** Nothing for a filter whose keys are fields of the child object. For a refused key: name the child field you meant (the verdict suggests the nearest one), or drop the key.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
'@objectstack/types': patch
3+
'@objectstack/runtime': patch
4+
'@objectstack/mcp': patch
5+
---
6+
7+
fix(mcp): `run_action` and `resume_run` answer a thrown error the way `POST /api/v1/actions` does, through that door's one reader
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: none
11+
12+
MCP `run_action` and `resume_run` answered an error thrown while running an action differently from `POST /api/v1/actions/:object/:action`, which runs the same action:
13+
14+
| The action threw | MCP answered | `/actions` answers, and MCP now answers |
15+
| --- | --- | --- |
16+
| A sandboxed body's own `throw new Error('Not enough leave')` | the runner's wrapper as bare text, naming the body: `action 'NAME' threw: Error: Not enough leave` | `400`, `HOOK_ABORTED`, `Not enough leave` |
17+
| A plain `Error` | its bare text, no code | `400`, `VALIDATION_ERROR`, its own sentence |
18+
| A driver error with a string code (`SQLITE_BUSY`) | `{ code: 'SQLITE_BUSY', message }`, no status | `400`, `VALIDATION_ERROR`, `declaredCode: 'SQLITE_BUSY'` |
19+
| A sandboxed body that crashed (`TypeError`), with or without a declared code | the wrapper with the native error text | `500`, `INTERNAL_ERROR`, `Internal server error` |
20+
21+
The tool error is `{ "error": { "code", "message", "status" } }` with `isError`, plus `declaredCode` and `userMessage` when the door serves them. The full wrapper and the fault line are logged on the server, as the door logs them. A refusal with a registered code (a body that throws `{ code: 'RECORD_LOCKED', status: 409 }`) keeps its code, its own sentence and its status. A refusal with an app's own unregistered code (`{ code: 'LEAVE_EXHAUSTED', status: 409 }`) now crosses as `/actions` serves it: the closed code its status derives (`RESOURCE_CONFLICT`), with `declaredCode: 'LEAVE_EXHAUSTED'` beside it; MCP used to answer `code: 'LEAVE_EXHAUSTED'`. A thrown `details` (the confirmation gate's) still rides on a refusal and is no longer served on a fault (status 500 and above), which answers only the door's sanitised envelope; the `PERMISSION_DENIED` withhold is unchanged. This supersedes the line in the `31218` changeset that says `run_action` and `resume_run` are unchanged.
22+
23+
A driver string code answers what `/actions` answers. `/api/v1/data` answers the same throw `500 DATABASE_ERROR`; that difference between the two REST doors is not changed here.
24+
25+
**New export (`@objectstack/types`): `actionsDoorAnswerOf(err, objectName?)` and its `ActionsDoorAnswer` type**, the `/api/v1/actions` door's answer to a thrown value, beside `mapDataError` (the `/api/v1/data` door's). The `/actions` door (`@objectstack/runtime`) now answers through it; its responses are unchanged byte for byte.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/spec': patch
3+
---
4+
5+
docs(spec): the `ValidationRule` `condition` example guards its nullable `amount` comparison with `record.amount != null`
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The publish-time null-guard rule refuses an ordering or arithmetic operator on a declared-nullable field in a validation `condition` unless an explicit `!= null` test guards it. The `condition` `.describe()` text compared `record.amount` without one; it now reads `record.amount != null && record.amount < 0`, and the generated `content/docs/references/data/validation.mdx` rows follow. The two doc-comment examples in the same file (the `cross_field` discount limit and the `conditional` enterprise rule) get the same guard.
11+
12+
The spec change is description and doc-comment text only: no schema shape changes, and no accept set moves.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/cli': patch
3+
---
4+
5+
fix(cli): `os serve` names an unloaded `devPlugins` entry by the list it was written in
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
When `os serve --dev` refuses to boot because an entry that may provide the crypto provider (`crypto-provider`) did not load, a `devPlugins` entry is now named `devPlugins[i]` instead of by its position after the stack's `plugins`. Which entries are refused is unchanged: the refusal reads an entry's `providesServices` through the same predicate as the rest of the crypto-provider checks.

‎content/docs/automation/approvals.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export const opportunityApproval: Flow = {
142142
config: {
143143
triggerType: 'record-after-update',
144144
objectName: 'opportunity',
145-
condition: "record.amount >= 50000 && record.stage == 'proposal'",
145+
condition: "record.amount != null && record.amount >= 50000 && record.stage == 'proposal'",
146146
},
147147
},
148148
{

‎content/docs/automation/flows.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2470,7 +2470,7 @@ placeholder such as `{today}` among them, which the query engine resolves.
24702470

24712471
| Where | Dialect | Write it like | Bindings |
24722472
|:---|:---|:---|:---|
2473-
| Start-node `condition` | **CEL** (bare, no braces) | `record.amount > 500` | `record.*`, `previous.*`, bare field names, `vars.*`, `current_user` |
2473+
| Start-node `condition` | **CEL** (bare, no braces) | `record.amount != null && record.amount > 500` | `record.*`, `previous.*`, bare field names, `vars.*`, `current_user` |
24742474
| Edge `condition` | **CEL** (bare, no braces) | `record.status == 'open'` | same as above |
24752475
| Decision-node `conditions[].expression` | **CEL** (bare, no braces) | `order_amount > 10000` | flow variables by name, `vars.*` and `current_user` |
24762476
| Field values and assignment values, as a **literal** | none — written as it is | `'open'`, `42`, `true`, `['a', 'b']` | — (a `{…}` template token is refused here since [#19939](https://github.com/objectstack-ai/objectstack/issues/19939), `{$User.*}` and the date macros `{NOW()}` / `{TODAY() ± N}` included: a date is `isoDate(today())` / `isoDatetime(now())` in an envelope) |

‎content/docs/automation/hook-bodies.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Pure formula. No IO, no mutation. This is the `body.language: 'expression'` shap
7171
{ "language": "expression", "source": "input.amount > 1000 && input.status == 'open'" }
7272
```
7373

74-
Hook `condition` is a **separate field with a different envelope** — a bare CEL string, or `{ dialect: 'cel', source }` (`ExpressionInputSchema` in `packages/spec/src/shared/expression.zod.ts`), not a `{ language, source }` body. e.g. `condition: 'record.status == "open" && record.amount > 1000'`.
74+
Hook `condition` is a **separate field with a different envelope** — a bare CEL string, or `{ dialect: 'cel', source }` (`ExpressionInputSchema` in `packages/spec/src/shared/expression.zod.ts`), not a `{ language, source }` body. e.g. `condition: 'record.status == "open" && record.amount != null && record.amount > 1000'`.
7575

7676
Both forms are evaluated by the same formula engine that powers field formulas — see [Formula Reference](/docs/data-modeling/formulas).
7777

‎content/docs/data-modeling/formulas.mdx‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export const Invoice = ObjectSchema.create({
116116
expression: F`record.subtotal + record.subtotal * record.tax_rate`,
117117
}),
118118
po_number: Field.text({
119-
requiredWhen: P`record.amount > 10000`,
119+
requiredWhen: P`record.amount != null && record.amount > 10000`,
120120
}),
121121
// M9.9b — declarative default, evaluated at insert time
122122
issued_date: Field.date({
@@ -353,7 +353,7 @@ ObjectSchema.create({
353353
Field.text({
354354
visibleWhen: P`record.type == 'business'`,
355355
readonlyWhen: P`record.status == 'approved'`,
356-
requiredWhen: P`record.amount > 10000`,
356+
requiredWhen: P`record.amount != null && record.amount > 10000`,
357357
})
358358
```
359359

@@ -391,14 +391,16 @@ clock at install time.
391391
{
392392
name: 'amount_positive',
393393
type: 'script',
394-
condition: P`record.amount <= 0`,
394+
condition: P`record.amount != null && record.amount <= 0`,
395395
message: 'Amount must be positive.',
396396
}
397397
```
398398

399399
The generic CEL rule is `type: 'script'`. For `script` rules, the `condition`
400400
is the **failure** predicate — when it evaluates TRUE the validation fails, so
401-
invert the test (here `amount <= 0` rejects non-positive amounts).
401+
invert the test (here `amount <= 0` rejects non-positive amounts). An optional
402+
field needs the `!= null` test first: the publish gate refuses `<`, `<=`, `>`, `>=`
403+
or arithmetic on a nullable field unless a null test guards it.
402404

403405
### Hook condition
404406

‎content/docs/data-modeling/validation.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ validations: [
326326
type: 'script',
327327
severity: 'error',
328328
message: 'Order amount must be positive',
329-
condition: 'record.amount <= 0',
329+
condition: 'record.amount != null && record.amount <= 0',
330330
events: ['insert', 'update'],
331331
priority: 10,
332332
},

‎content/docs/deployment/cli.mdx‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3242,6 +3242,7 @@ is its production, so a deploy is always a deliberate act.
32423242
| `-s, --server <url>` | `OS_CLOUD_URL` | Control-plane URL. Default `https://cloud.objectos.ai`, or the URL recorded by `os cloud login` |
32433243
| `-t, --token <key>` | `OS_CLOUD_API_KEY` | Bearer token; `$OS_TOKEN` and `~/.objectstack/cloud.json` are the fallbacks |
32443244
| `--confirm-access-upgrade <token>` | — | Self-hosted target only: confirm the upgrade's access findings with the finding-set token the runtime's refusal printed (as [`os package install`](#os-package-install)). Refused when the target is ObjectOS Cloud |
3245+
| `--confirm-upgrade <token>` | — | Self-hosted target only: confirm the upgrade's schema findings (a suspected rename, a type change that is not safe) with the finding-set token the runtime's refusal printed (as [`os package install`](#os-package-install)). Refused when the target is ObjectOS Cloud |
32453246
32463247
`os package publish` stays the command for a **release**: it publishes the
32473248
version the manifest declares, with `--install` optional.
@@ -3262,12 +3263,17 @@ answers are the ones printed.
32623263
build is printed; nothing is installed. A runtime that refuses it, or does not
32633264
serve install-local, stops the deploy with exit `1`. A runtime that predates the
32643265
dry run ignores it and installs: the command says so and exits `1`.
3265-
3. **Install** — with `--confirm-access-upgrade` passed through. The endpoint's
3266-
refusals (an access upgrade to confirm, a package the running kernel cannot
3267-
register, …) stop the deploy with exit `1`.
3266+
3. **Install** — with `--confirm-access-upgrade` and `--confirm-upgrade` passed
3267+
through. The endpoint's refusals (an access upgrade to confirm, a schema
3268+
upgrade to confirm, a package the running kernel cannot register, …) stop the
3269+
deploy with exit `1`. An upgrade refusal prints its retry as
3270+
`os deploy --confirm-access-upgrade <token>` for access findings or
3271+
`os deploy --confirm-upgrade <token>` for schema findings.
32683272
4. **Live** — install-local registers the package in the running kernel before it
32693273
answers, so the answer is the verdict: `hotLoaded` prints `Live: … now serves …`
3270-
and exits `0`.
3274+
and exits `0`. A package the runtime recorded but its running kernel could not
3275+
load is not live: the command prints that it loads when the runtime restarts
3276+
and exits `1`.
32713277

32723278
The `d` key in [`os dev`](#os-dev) runs the same `os deploy`, so it deploys to the
32733279
runtime too and asks for no cloud login.

0 commit comments

Comments
 (0)