Skip to content

Commit 016eb45

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-oj61dz
2 parents 5ac6ed0 + 98583cd commit 016eb45

75 files changed

Lines changed: 2886 additions & 1280 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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
'@objectstack/plugin-auth': patch
3+
'@objectstack/service-settings': patch
4+
'@objectstack/platform-objects': patch
5+
---
6+
7+
feat(plugin-auth, service-settings)!: the access policy is set per organization, and the multi-factor requirement has three levels
8+
9+
Clause-②: yes (narrowing) — a new `access_policy` settings namespace (scope `tenant`) carries each organization's allowed IP ranges, idle, absolute and concurrent session limits and multi-factor requirement; `auth.mfa_required` changes from a toggle to the levels `off` / `administrators` / `everyone`, `sys_organization.require_mfa` is no longer writable, and `AuthManagerOptions.mfaRequired` becomes `mfaRequirement`.
10+
Metadata-protocol: none
11+
12+
<!-- adr-0087: not-required (runtime-interface-only packages/plugins/plugin-auth/src/auth-manager.ts#AuthManagerOptions) the narrowed operands are a runtime option of the auth manager (`AuthManagerOptions.mfaRequired`, which the compiler names at every caller), a settings value (`auth.mfa_required`, rewritten from a stored toggle to a level by plugin-auth at boot) and a platform object column's editability (`sys_organization.require_mfa`, whose stored value plugin-auth moves into the organization's access policy at boot); no packages/spec schema, registered node type or ADR-0087 conversion surface names any of them, so there is nothing for `objectstack migrate meta` to rewrite -->
13+
14+
**BREAKING.** The access policy is set per organization (rulings of record on objectstack-ai/cloud#3668: 「支持按组织(推荐)」, 「可以,按三档做(推荐)」). Each organization sets its own allowed IP ranges, session idle timeout, absolute session lifetime, concurrent-session cap and multi-factor requirement in **Settings → Access policy** (the `access_policy` namespace, one row per organization, written by its administrators). The deployment's values in **Settings → Authentication** are the default and the floor: an organization may tighten and never loosen.
15+
16+
The rule per key — a value weaker than the deployment's is refused at the save, and enforcement holds the floor whatever is stored:
17+
18+
- `allowed_ip_ranges`: each range must lie inside a deployment range (any range when the deployment sets none), and the list must admit the address it is saved from. A request must pass both lists. A session is scoped to an organization only from an address its list admits: the sign-in is refused with `403 IP_NOT_ALLOWED` when the organization the session would be scoped to does not admit the address, and so is a switch of the active organization. A session the organization's list no longer admits (it roamed, or the list was tightened) is signed out on its next session read through the auth routes. Sign-in itself, before any organization is chosen, is judged by the deployment's list alone. A platform administrator is held by the deployment's list only, so an organization that locks out its own administrators can be reopened, and the save check does not refuse a platform administrator's save from outside an organization's list.
19+
- `session_idle_timeout_minutes`, `session_absolute_max_hours`: `0` keeps the deployment's limit; a positive value may not exceed the deployment's. The shorter of the two applies to every session scoped to the organization. A switch of the active organization is judged against the target organization's limits before it lands, from the session's last request in any organization; a session past either is signed out and the switch refused.
20+
- `max_concurrent_sessions_per_user`: `0` keeps the deployment's cap; a positive value may not exceed the deployment's. The deployment's cap still counts every session of the user, in any organization; an organization's cap counts only the user's sessions in that organization and signs out only those, oldest first. Both are checked at sign-in and when a session switches into the organization.
21+
- `mfa_required`: `off` keeps the deployment's level; a level may not be weaker than the deployment's. The stronger of the two applies. `administrators` holds platform administrators, the organization's own administrators (owner or admin membership) and delegated administrators (a permission set with an `adminScope`), and lets everyone else through.
22+
23+
What to do on upgrade:
24+
25+
- `auth.mfa_required` saved as on now reads `everyone`, and as off `off`. A stored toggle is rewritten at the first boot; the `OS_AUTH_MFA_REQUIRED` env override still reads `true`/`false` with a warning for one major release — set it to `off`, `administrators` or `everyone`. A **write** of `true` or `false` to `auth.mfa_required` is now refused by the setting's option table (`invalid_option`): write `everyone` or `off`. Consumer: objectstack-ai/cloud's `apps/cloud/test/settings-cross-org-doors.test.ts` (`:533` writes `true`, `:552` expects it back) must be rewritten to `everyone` when the framework pin moves past this release.
26+
- An organization whose `sys_organization.require_mfa` was on now carries `access_policy.mfa_required` set to `everyone`. Moved at the first boot (unless the organization already chose a level), and the column is cleared once the row lands; a move that fails is logged at `error` and retried at the next boot. The column is now readonly: a data-API write to it is refused like any other non-editable column.
27+
- A host that passed the auth manager or plugin option `mfaRequired: true` passes `mfaRequirement: 'everyone'` (or `'administrators'`) instead. A host still passing `mfaRequired` is refused at construction (and on `applyConfigPatch`) with an error naming the replacement, never run without the requirement.
28+
29+
What does not change: with no organization policy saved, every deployment enforces exactly what it enforced before, and the deployment's own keys keep their names.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@objectstack/formula': patch
3+
'create-objectstack': patch
4+
---
5+
6+
fix(formula): the bare-reference and unbound-root refusals say the expression faults, not that it evaluates to null
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
- **`@objectstack/formula`.** In a `record`-scoped expression, a bare field name (`amount` where `record.amount` is meant) and a mistyped root (`pge.…` where the surface binds `page`) are unknown variables: the expression faults with `Unknown variable: NAME` and never reads the field. The `bare-reference` and `unbound-root` refusals used to say the name "resolves to nothing and the expression silently evaluates to null", which is true only of a formula field. They now say the expression faults, and `bare-reference` names three outcomes of that fault: a formula field reads null, an `error` validation rule refuses the write, an action's `visible` hides the action. `os validate`, `os build` and the `validate_expression` tool print the new sentences.
12+
- Codes and params are unchanged (`bare-reference` `{ name }`, `unbound-root` `{ name, roots, suggestion }`). What is refused, warned or passed is unchanged. Only the English `message` changed, so a consumer that matched the old text re-keys to the `code`.
13+
- **`create-objectstack`.** The scaffolded `AGENTS.md` no longer says a bare field reference "evaluates to `null`". It now says the predicate cannot be evaluated on any record, so an action whose `visible` reads it is hidden everywhere and an `error` validation rule that reads it refuses every write. Projects scaffolded earlier keep their copy until it is edited.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ come at two severities: **errors** fail the build; **warnings** are advisory
239239

240240
| Check | Example | Severity |
241241
|:---|:---|:---|
242-
| **Qualify field references** — a formula / validation / predicate binds only the `record` namespace, so a bare `amount` resolves to nothing and evaluates to `null`. Write `record.amount`. | `amount > 100` → `record.amount > 100` | error |
242+
| **Qualify field references** — a formula / validation / predicate binds only the `record` namespace, so a bare `amount` is an unknown variable and the expression faults instead of reading the field: a formula reads `null`, and a predicate takes its site's fault outcome (an `error` validation rule refuses the write, an action's `visible` hides the action). Write `record.amount`. | `amount > 100` → `record.amount > 100` | error |
243243
| **Field must exist** — a typo'd `record.<field>` is flagged with a did-you-mean. | `record.amont` → `record.amount` | error |
244244
| **Unknown function** — a misspelled or nonexistent stdlib call. | `isBlnk(record.x)` | error |
245245
| **Type soundness** — a text or boolean field used with an arithmetic (`+ - * / %`) or ordering (`< > <= >=`) operator against a number faults at runtime unless the text is numeric. In a formula it evaluates to `null`. Where a fault does something else it is an error, worded for what happens: a validation rule, a field `requiredWhen` / `readonlyWhen`, an option `visibleWhen` or a hook `condition` refuses the write; a record-triggered flow's start, edge or `decision` branch condition fails the run (the write that fired it still lands), whether it reads the field bare or as `record.<field>`, and so does a time-relative flow's that sweeps the same object, where no write fires the run and only the run for that row fails; a bare name that a declared flow variable or a `screen` field holds reads that value, so it is not judged as the field, and a bare name after a node that can bind any name (`script`, `connector_action`, `wait`, `subflow`, `map`, a screen with no fields) gets the warning instead, while its `record.<field>` read is still refused; an advisory (`severity: 'warning'` / `'info'`) validation rule is skipped, so it never gives its advisory. Store it as a number field, compare text with text, or convert explicitly (`size(record.name)` for the length; `double(record.name)`, which itself faults on text that is not a number). | `record.title * 2`; `record.name > 5` in a validation rule → `size(record.name) > 5` | warning in a formula or a display predicate, and in a condition of any other flow, where the warning says the run fails if the condition faults (what such a flow binds under the name depends on how it is started); error at the sites named |

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,10 @@ To compare against a field's previous value, reference `previous.<field>`
390390
(e.g. `record.stage != previous.stage`).
391391

392392
> **Qualify your references.** A validation predicate binds only the `record`
393-
> namespace, so a bare `status == "won"` resolves to nothing and the rule
394-
> silently never fires — write `record.status == "won"`. `objectstack build`
393+
> namespace, so a bare `status == "won"` is an unknown variable and the rule
394+
> cannot be evaluated: an `error` rule then refuses every write it judges, and a
395+
> `warning` / `info` rule is skipped with a log line and never applied — write
396+
> `record.status == "won"`. `objectstack build`
395397
> flags bare references, unknown fields, and text/boolean fields misused in
396398
> arithmetic — see [Build-time validation](/docs/data-modeling/formulas#build-time-validation).
397399

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ they reference record fields through the `record.` scope:
2828

2929
```ts
3030
// ✗ Wrong — `done` is a bare reference. It type-checks (it's just a string),
31-
// but at runtime it resolves to null → the action is hidden on EVERY record.
31+
// but at runtime it is an unknown variable, so the predicate faults on every
32+
// record — and the Console hides an action whose `visible` faults: hidden on
33+
// EVERY record.
3234
{ name: 'mark_done', visible: '!done' }
3335

3436
// ✓ Right
@@ -896,16 +898,19 @@ What the failure does depends on what the predicate guards:
896898

897899
| Predicate | On failure |
898900
| :--- | :--- |
899-
| A field's `visibleWhen`, `readonlyWhen`, `requiredWhen`; a view's `visibleOn`; an option's `visibleWhen`; list conditional formatting | **Fail open**: the rule's safe default applies, so a broken rule never hides a field. A rule that never fires while its field stays visible is the symptom, usually a bare field name where `record.<field>` was meant |
901+
| A field's `visibleWhen`, `readonlyWhen`, `requiredWhen`; a view's `visibleOn`; an option's `visibleWhen`; list conditional formatting | **Fail open in the Console's rendering**: the rule's safe default applies, so a broken rule never hides a field. A rule that never fires while its field stays visible is the symptom, usually a bare field name where `record.<field>` was meant. This row is the Console's display only; the server judges `requiredWhen`, `readonlyWhen` and an option's `visibleWhen` again on the write (see below) |
900902
| An object field group's `visibleWhen` | **Fail closed**: the whole group is hidden on the form and the record page |
901903
| A page node's `visibleWhen` / `visible` / `hidden`, and a `page:tabs` item's `visibleWhen` | **Fail closed**: the node or tab is withheld; a withheld related list is not counted in its tab badge |
902904
| A navigation item's or area's `visible` | **Fail open**: the item renders for everyone, reported under `app-shell:visible` |
903905

904906
At **submit** a broken field rule is refused, not passed. A field `visibleWhen` that
905907
cannot be evaluated refuses the submit on the client, with a message naming the field
906-
and the rule, because no server evaluates `visibleWhen`. A broken `requiredWhen` or
907-
`readonlyWhen` is refused by the server, and the form shows that refusal beside the
908-
input. A `visibleWhen` that reads `previous` cannot be evaluated on a create form, so
908+
and the rule, because no server evaluates a field's `visibleWhen`. A broken
909+
`requiredWhen` or `readonlyWhen`, or an option's `visibleWhen`, is refused by the
910+
server, and the form shows that refusal beside the input. One exception: a
911+
`readonlyWhen` that reads a name the write does not bind (a bare field name, or
912+
`parent` where no master-detail header was resolved) holds the lock instead: the
913+
server drops the incoming change to that field and the rest of the write lands. A `visibleWhen` that reads `previous` cannot be evaluated on a create form, so
909914
such a form is always refused.
910915

911916
A **blank** rule (`''`, whitespace, or an envelope whose `source` is blank) is not "no

‎content/docs/getting-started/build-with-claude-code.mdx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ reference** — `status` instead of `record.status`:
300300
{/* os:check */}
301301
```typescript
302302
// ✗ Wrong — bare `status`. Type-checks (it's just a string), but at runtime
303-
// it resolves to null, so the action is hidden on EVERY ticket.
303+
// it is an unknown variable, so the predicate faults on every ticket — and
304+
// the Console hides an action whose `visible` faults: hidden on EVERY ticket.
304305
visible: 'status != "resolved"'
305306
```
306307

@@ -315,8 +316,11 @@ visible: 'status != "resolved"'
315316
✗ Author-time rules failed (1 issue)
316317
• stack · action 'resolve_ticket' visible: bare reference `status` — a
317318
formula/validation expression binds the record as the `record` namespace,
318-
not at top level, so `status` resolves to nothing and the expression
319-
silently evaluates to null. Write `record.status`.
319+
not at top level, so `status` is an unknown variable and the expression
320+
faults with `Unknown variable: status` instead of reading the field. The
321+
site's fault rule decides the outcome (a formula field reads null, an
322+
`error` validation rule refuses the write, an action's `visible` hides the
323+
action). Write `record.status`.
320324
— source: `status != "resolved"`
321325
rule: expression-invalid at stack · action 'resolve_ticket' visible
322326
```

0 commit comments

Comments
 (0)