Skip to content

Commit 979fbb3

Browse files
committed
Merge branch 'claude/project-thread-1hzwul' into claude/area-A2-32656-refusals
2 parents cae401f + 1cffbad commit 979fbb3

148 files changed

Lines changed: 8649 additions & 664 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: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
'@objectstack/service-automation': patch
3+
---
4+
5+
feat(service-automation): the automation engine holds a connector instance by its package and name, and a dispatch addresses the one instance its caller's name resolves to (ADR-0150 D4, #31699)
6+
7+
Clause-②: yes (widening) — additive in-process surface only: `AutomationEngine` gains `resolveConnectorInstance`, `resolveConnectorInstanceFor` and `resolveConnectorActionInputSchema`; `registerConnector`, `registerDegradedConnector` and `unregisterConnector` take an optional instance (its package, and `soleOfName`); `resolveConnectorAction`, `resolveConnectorActionEffect`, `getConnectorOrigin`, `getConnectorDegradedReason` and `getConnectorDegradedHold` take an optional package; the barrel exports the types `ConnectorInstanceResolution` and `ConnectorInstanceOptions`. Dispatch answers change in one transitional state (an unstamped entry whose name gains a second holder after boot), as an intended tightening; the phase-1 one-holder refusal keeps a supported install out of that state, since it refuses a second holder at install and at package registration. Three smaller answers move too, each listed under "What answers differently" below: a dispatch that joins a refresh in flight for another connection row is refused 503 once, the store's two-holder refusal names a different remedy, and a re-registered instance moves to the end of the connector list. Every other dispatch, door and HTTP answer is as before: the declared-connector reconcile still keeps one instance per name (the one-holder backstop, its duplicate-name refusal, and `soleOfName` on every declarative registration), and a lookup by bare name answers that one instance.
8+
Metadata-protocol: none
9+
Skills-docs: none — nothing a skill or a docs page teaches changes while one instance per name is kept; the two-holder connector docs come with the PR that narrows the backstop.
10+
11+
Part of #31699 (ADR-0150 child B, PR 3b). PR 3a-ii made the connection store, the connect door and the OAuth callback address an instance by package and name; this PR makes the engine hold and dispatch it so.
12+
13+
**The engine's instances.**
14+
15+
- The registered connectors are held by `(package, name)` (`ConnectorInstances`): a declarative instance by the package the connection door addresses it by (`connectorInstancePackage`: its real stamp; none for the environment's stored entry; the name's durable holder for an unstamped or compatibility-default entry), a plugin's connector by no package.
16+
- A plugin's connector and a declarative instance still never share a name, whatever package the instance is of (ADR-0097 §4). With `soleOfName`, a declarative registration drops any other declarative instance of the name: the reconcile registers every instance so, and keeps one per name, until the backstop narrows.
17+
- A read by bare name answers the one instance of the name, and none when there are two, never one of them. `getRegisteredConnectors` lists each name once; `getConnectorDescriptors` lists every instance.
18+
19+
**Dispatch.**
20+
21+
- `connector_action` resolves its `connectorId` for the calling flow's package (`resolveConnectorInstance`): a refused name is refused as before, naming every candidate; a resolved holder is dispatched to its own instance, and its action's `inputSchema` and `effect` are read from that instance. A caller with no package, a name no registry holds, or a resolved holder with no instance registered under it (a plugin's connector of a declared name) is answered by the one instance of the name, as the dispatch by name answered; two are not dispatched. `connectorNameRefusal` answers as before.
22+
- The OAuth2 grant handle asks its instance's package on every read of the connection store, so an unstamped entry's connections are read under the package its name resolves to now, not when the handle was made. A cached access token is served only for the connection row it was obtained for (its row id, beside its revision): a read that now chooses another row (another package's connection of the organization) refreshes, never serves the other row's token.
23+
24+
**The reconcile.**
25+
26+
- The instance package is part of a provider-bound entry's desired signature, so an unstamped entry whose name's holder changes (installed, uninstalled, a second holder) is registered again under the package it resolves to now, on the next reconcile. The engine's instance and the connection the grant handle reads stay one package.
27+
- An instance the reconcile drops (no longer declared, degraded and removed) is unregistered by name, every instance of it: the reconcile keeps one per name, whatever package it was registered under.
28+
- Limit: the boot's second reconcile (packages registered during the boot) is skipped when the declared list's fingerprint is unchanged, and the fingerprint carries no package, so a holder that changes in that window without the declared list changing is followed on the next reload or restart.
29+
30+
**What answers differently.**
31+
32+
- An unstamped (or compatibility-default) declared entry whose name gains a second durable holder: its dispatch was answered with the connection of the package that held the name at boot (200) until a restart. It is now read under the package the name resolves to at that moment, which is no one package, so it is refused 503 (no connection of its own): under two holders a row is its own package's only (PR 3a-ii's store rule), as the connection door already refuses that name (409). It is recovered by stamping the entry or by uninstalling the second holder. A holder that is uninstalled or replaced, leaving one holder, changes no answer: every row of the name still answers the one instance, and the next reconcile registers the instance again under the package it resolves to now (any provider-bound instance is re-materialized on such a change). A re-materialized OAuth2 instance starts with a new grant handle whose access-token cache is empty, so a connection with no refresh token reads `reconnect_required` at its next dispatch, as after a restart.
33+
- A dispatch that joins an access-token refresh already in flight for another connection row of the organization (the instance's package changed while the refresh was out) is refused 503, never served that row's token; the next dispatch refreshes its own row.
34+
- The store's refusal of a row of a two-holder name that names none of the holders now names the remedy that works for it: `os migrate stored-references bind` for a row naming no package, and uninstalling one of the holders for a row already naming another package, which the bind refuses (PR 3a-ii contract review N4).
35+
- On a change of holder, the instance is re-registered, so its name moves to the end of `getRegisteredConnectors()` and `GET /automation/connectors`.
36+
37+
**Not in this PR (moved to the PR that narrows the backstop).**
38+
39+
- The materializer's own bookkeeping (`desired`, the materialized, degraded and credential-refusal maps, `grantHandles`, retry and dematerialize) stays keyed by name: under the backstop the reconcile cannot hold two instances of one name, so re-keying it is observable only once the duplicate-name refusal is lifted, and lands with it and with a two-live-instance test. Its registrations and unregistrations already pass the instance package.
40+
- The connector pull keeps reading its connector by bare name (the one instance): whether a mapping's connector is resolved for the job's package, and refused where that name is refused, changes an answer and is decided with the narrowing.
41+
- The resolved-holder fallback above (a resolved holder with no registered instance answered by the one instance of the name) is right only while one instance per name is kept; with two instances alive the narrowing PR makes it `none`.
42+
- `ConnectorDescriptor.packageId`, the addressed connection door (`?package=`), connector into the namespace-scoped type sets, and the backstop itself.
43+
- `registerConnector(def, handlers, 'declarative', { packageId })` without `soleOfName` is public and keeps two instances of one name side by side (the engine tests use it). So does `registerConnector(def, handlers, 'declarative')` with no instance argument over a name the reconcile holds under a package: it is registered under no package beside that instance instead of replacing it, and a bare-name read answers neither until the next reconcile. Nothing in-tree registers either way outside the tests; the reconcile always passes the instance with `soleOfName`.
44+
45+
**In-process APIs.** Listed under Clause-② above. All additive; every new parameter is optional and its absence answers as before, except the declarative registration with no instance argument named in the list above.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/lint': patch
3+
---
4+
5+
feat(lint): a flow `update_record` with `multi: true` whose `fields` set an input of a stored computed field on its target object is warned at authoring (`flow-multi-update-moves-stored-input`)
6+
7+
Clause-②: yes (widening) — a new advisory and its rule id exported from the package root; no build, validate, save or publish that passed before is refused, and the engine's behaviour is unchanged.
8+
Metadata-protocol: none
9+
10+
A stored computed field is any field but a `formula` that declares an `expression`; the engine computes it from the row each write stores. A predicate update writes one patch to every matched row and is never split into single-row writes, so the engine stores the computed value only when it is the same on every matched row, and refuses the whole update with `VALIDATION_FAILED` (nothing written) when the patch moves an input to values that compute differently on different rows. That refusal is unchanged. What is new is that `os validate`, `os build` and the flow save and publish doors now name it before the first run, with the shape that always works: `get_record` (same filter, `limit` above 1) → `loop` → `update_record` with `filter: { id: item.id }` and no `multi`.
11+
12+
An input is a field the `expression` reads as `record.FIELD`, through a reference field, or through another stored field that reads it; fields an object extension adds count. A target object the stack does not carry is not judged. The rule is a warning because a patch that computes the same value on every matched row is stored. `os explain flow-multi-update-moves-stored-input` carries the full explanation.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@objectstack/lint': patch
3+
---
4+
5+
feat(lint): advise a template `default` argument that reads like a variable path, and a `notify` node that sends an email template without a variable the template declares `required`
6+
7+
Clause-②: yes (widening) — two advisory rules and their exports are added; nothing that saved, built or validated before is refused.
8+
Metadata-protocol: none
9+
10+
A template default is literal text; to read another variable, compute it in the flow. No template syntax is added: the mail renderer's `default` formatter already prints a literal fallback (`{{ person_name | default:'Customer' }}`), and a variable declared `required` already refuses the send with `MISSING_VARIABLES` when it is absent. Two authoring checks now say so before a template or a flow ships:
11+
12+
- `email-template-default-reads-as-path` (`warning`; `os validate`, `os build`, `os lint` and the metadata publish door for an `email_template` write, where it is an advisory on the save response). An unquoted `default` argument shaped like a variable path (a dotted or `@`-marked path, a snake_case name, or a name the template itself uses as a variable) prints that text to the recipient: `{{ person_name | default:first_name }}` prints the word `first_name`, never the send's `first_name`. Quote the argument (`default:'first_name'`) when the text itself is meant.
13+
- `notify-template-variable-missing` (`warning`; `os validate`, `os build`, `os lint`). A `notify` node names an email template the app declares, and its `templateData` provably does not supply a variable a locale member of that template declares `required`: every send to a recipient of that locale fails with `MISSING_VARIABLES` and nothing is delivered. A CEL value envelope counts as supplied, as do `appName`, `baseUrl` and the keys of the stack's `email.defaultTemplateContext`. A `templateData` key is one name, not a path: the key `'task.title'` does not supply `task.title`, which the renderer reads as `title` under `task`, and the hint says so. It warns rather than refuses because a host can supply a variable through a default template context set in code, which the stack does not state.
14+
15+
`@objectstack/lint` exports `validateEmailTemplateDefaultArguments`, `EMAIL_TEMPLATE_DEFAULT_READS_AS_PATH`, `validateNotifyTemplateVariables`, `NOTIFY_TEMPLATE_VARIABLE_MISSING` and the two finding types.
16+
17+
The email templates guide states the rule, and its `notify` example, which passed `templateData: { 'task.title': … }` to a template that requires `task.title` (a send that always failed with `MISSING_VARIABLES`), now passes `task`.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/plugin-auth': patch
3+
---
4+
5+
feat(plugin-auth): `organizationDeleteGate`, a host check asked by the organization delete admission
6+
7+
Clause-②: yes (widening) — a new optional `AuthManagerOptions` / `AuthPluginOptions` member, `organizationDeleteGate`, and its two exported types, `OrganizationDeleteGateRequest` and `OrganizationDeleteGateRefusal`. Unset, every answer of `POST /organization/delete` is unchanged.
8+
Metadata-protocol: none
9+
10+
A host that must refuse an organization delete for its own reasons (the cloud control plane: a subscription that will charge again, environments that remain) sets `organizationDeleteGate`. It is asked once per delete, from the delete admission in better-auth's `hooks.before`, with the `organizationId` better-auth parsed from the JSON body (a body it does not parse is answered its `415` without asking), the caller (`userId`, `activeOrganizationId`, `impersonatedBy`) and the request's `Accept-Language`. It runs after the auth mount's gates (a request the IP allow-list refuses never reaches it) and after the platform's own refusals (`403 PERMISSION_DENIED` on the Default Organization's last administrator, `409 DELETE_RESTRICTED` while records remain, `503` on a failed read), and before better-auth's first write.
11+
12+
- Answering `undefined` or `null` lets the delete go ahead.
13+
- A refusal (`{ status, body }`, `status` 400–499, `body.code` and `body.message` required) is answered unchanged, status and body, and nothing is deleted.
14+
- Fail-closed: a check that throws, or answers anything else, is answered `503 SERVICE_UNAVAILABLE` naming the option, and nothing is deleted. The host's error text is not sent to the client.
15+
16+
The option is read per call, so a value an `auth:configure` handler sets is the one asked. A host that parsed the request body ahead of the auth mount to make this check can drop that reader and use the option.
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/spec': minor
4+
---
5+
6+
fix(metadata-protocol): deleting an object extension that re-declared a stored computed field fills the object's existing rows with the expression it hands back, as the save door does, and says so per field
7+
8+
Clause-②: yes (widening) — adds an optional `advisories` key to `DeleteMetaItemResponseSchema`
9+
Metadata-protocol: added
10+
11+
`deleteMetaItem` (`DELETE /api/v1/meta/:type/:name`) removed the row and healed the registry, so the object served the definition beneath the removed one, but it ran no stored-expression fill. Deleting an own-package `object_extension` that re-declared a stored computed field (a non-`formula` field declaring `expression`) therefore left every existing row holding the value the removed expression computed, while the object now computed the owner's expression. Totals, filters and reports read those values with no error anywhere.
12+
13+
The delete now captures the object's stored computed fields before its registry heal and runs the same fill the save, publish, rollback and revert doors run: each stored computed field the removal makes compute something new is recomputed over the object's existing rows and reported per field on the answer's new optional `advisories` (`stored-expression-filled`, or `stored-expression-fill-incomplete` with what is left and the `os migrate stored-expressions` command that fills it). A draft discard fills nothing. The key is omitted when there is nothing to report, so a clean delete's answer is byte-identical to before. The delete itself never fails on its fill.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/plugin-auth': patch
3+
---
4+
5+
fix(plugin-auth): a browser refused at `/oauth2/authorize` by the environment-access gate is sent back to the environment, or shown a readable page, instead of a raw JSON 403
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
When the host's `oidcAuthorizeGate` refuses a signed-in account at `/oauth2/authorize` (an account that is not a member of the environment's organization), the answer now depends on who is asking. The refusal itself, and who it applies to, are unchanged.
11+
12+
- A browser navigating to the URL (`Sec-Fetch-Dest: document`, or `Accept: text/html` with no Fetch Metadata), when the request's `redirect_uri` is registered for the client exactly as written: `302` to that `redirect_uri` with `error=access_denied`, `error_description`, the request's `state` and `iss` (RFC 6749 §4.1.2.1, RFC 9207). The environment's own sign-in page then shows the refusal.
13+
- A browser navigating to the URL with no such `redirect_uri` (none sent, one the client never registered, a disabled client, or a loopback URI on a port other than the registered one): a `403` HTML page that names the signed-in account and offers "Switch account" (the provider's `/oauth2/end-session`) and "Back to console". An unregistered `redirect_uri` is never followed.
14+
- Every other caller, including the Console's own post-sign-in `fetch` (`Accept: application/json`), a bearer API client and a bare `curl`: the same `403` with `code: ENV_ACCESS_DENIED` and the same message as before.
15+
16+
A request with no signed-in account is still not judged, and still goes to the provider's sign-in page.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/objectql': patch
3+
---
4+
5+
fix(objectql): an upgrade or re-install of a package withdraws the items its new version no longer ships, so their names are free at once (#33050)
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A package body re-registered under an installed id — `POST /api/v1/marketplace/install-local` re-installing or upgrading a package, or any other caller of the engine's `registerApp` / the `manifest` service — now replaces what that package ships instead of adding to it. Once the new body has registered, the registry withdraws the item slots the previous body registration wrote that this one did not write again (a dropped tool, flow, page, app, permission set, …), and releases the bare-name and security catalog claims the new manifest no longer declares. Before, a dropped item stayed registered and served until the next restart, and it kept its name: another package declaring that name was refused `422 PLUGIN_REGISTER_FAILED`, "already held by" the package that had dropped it.
11+
12+
What is withdrawn is exactly what the previous BODY registration wrote under the package's id: an environment overlay in the bare slot (ADR-0005), an item registered under the id outside a body, and the hook binder's function claims are left as they are, and a first registration withdraws nothing. The withdrawal runs inside the same restore-on-refusal run as the registration, so a refused upgrade still leaves the installed version serving whole, its items back in the order they stood. Objects and object extensions are not items and are not changed by this.
13+
14+
`SchemaRegistry.replacingPackageBody(packageId, manifest, register)` is the new verb `registerApp` runs its body registration through.

0 commit comments

Comments
 (0)