Skip to content

Commit a785894

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/area-E1-32354
# Conflicts: # packages/objectql/src/package-scoped-exact-qualifier.test.ts
2 parents 333edb0 + 2797f81 commit a785894

434 files changed

Lines changed: 21627 additions & 1720 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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/plugin-approvals': patch
3+
---
4+
5+
fix(approvals)!: an approval request whose flow package was uninstalled never reads another package's flow of the same name (ADR-0150 D8 row R7)
6+
7+
Clause-②: yes (narrowing) — an approval request stamped with the package it was opened on (`process_package`), whose package no longer holds a flow of the request's name while another package does, moves FROM reading that other package's flow TO reading none, at four doors: (1) send-back (`POST /approvals/requests/ID/revise`) FROM checking the other package's revise edge (then returning the request on that graph where the run carries the bare name, or refused `409 RESUME_TARGET_LOST` by the run pre-flight where it carries its package's key) TO `409 RESOURCE_CONFLICT` (reason `not-held-by-qualifier`, the stamped package as the qualifier, every holder named) with nothing written; (2) the request read (`GET /approvals/requests/ID`) FROM serving the other package's `flow_route` and `flow_steps` TO serving neither; (3) the stranded-resubmit continuation's revise window FROM the other package's window TO the same `409`; (4) the queue package a re-resolved slate reads a `queue` approver's name from FROM the other package TO none (the environment-wide read a request with no flow takes). The other package is read today through the bare name (the stamped package withdrew from a name two packages held) or through the run's key (the stamped package was the name's one holder, and the other package installed the name after it left). First-party callers in that position: 0 (no first-party package uninstalls a flow that another first-party package ships under the same name). Unchanged: a request whose stamped package still holds the name, beside a second holder or alone, and a request naming no package; with no holder of the name left, every door answers as for a deleted flow, as before.
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 stored row changes shape: what moves is which flow body four approval doors read for a request whose package was uninstalled, so there is nothing for a migration to rewrite and no tombstone. -->
11+
12+
**BREAKING** for an approval request opened on a package's flow after that package is uninstalled while another package ships a flow of the same name. FROM the request answered from the other package's flow TO refused `409 RESOURCE_CONFLICT`, naming every package that holds the name. The fix: install the request's package again (the refusal names it) to act on the request; nothing else answers it from a flow it was not opened on.
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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
'@objectstack/metadata': patch
3+
---
4+
5+
fix(metadata)!: `MetadataManager.loadMany` takes a by-package name's bodies and packages off the loader's keyed entries, so a boot no longer turns a name two packages hold into one body when another row's body says that name; `loadManyKeyed` entries carry their package (#32680)
6+
7+
Clause-②: yes (narrowing) — narrowed: on a host that wires a `DatabaseLoader` (none in the workspace), after the boot priming pass a read naming no package (`MetadataManager.get`, `getDiagnosed`) of an `api`, `agent`, `skill`, `action`, `permission`, `flow`, `picklist`, `mapping`, `dataset` or `tool` name two packages' rows hold, beside another row whose body says that name, is refused `409 RESOURCE_CONFLICT` (`ambiguous-in-environment`, naming both packages), where it served one of those bodies; the same read without the pass already refused. Widened: `MetadataManager.loadManyKeyed` entries carry `packageId` (the package the loader holds the entry for), where they carried the key and the body only.
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 stored row changes: what moves is which package a plural read stamps on a body it hands on, which the boot pass then registers, and a field a keyed entry carries beside its body, none of which a stored row records, so there is nothing for `objectstack migrate meta` to rewrite. -->
11+
12+
**BREAKING** for one kind of host: a host that wires a `DatabaseLoader` and, after the boot, reads with no package a name two packages' rows hold while a third row's body also says that name, now gets `409` naming both packages instead of one body. Name the package that holds it, or rename one of the two.
13+
14+
What moves, for every unbundled type in `PACKAGE_SLOTTED_STORE_TYPES`, on a loader that holds items per package (`loadManySlots`: `DatabaseLoader`, the artifact door's `MemoryLoader`):
15+
16+
- `MetadataManager.loadMany` hands on each of the loader's keyed entries' own bodies, stamped (`_packageId`) with the package the loader holds that entry for when the body carries the entry's key as its `name`, FROM `loader.loadMany`'s bodies paired to the keyed entries by their serialisation. A body the keyed read cannot name (a row whose `name` column is empty) is still handed on after them, unstamped.
17+
- A name two packages hold, beside another row whose body says that name: each holder is handed on stamped with its own row's package and the other row's body unstamped, FROM all of them unstamped and the first one alone handed on. The boot pass then fills each package's slot and files the other row's body in the name's bare slot, FROM filing the one body in the bare slot. After the pass a bare read is refused `409` naming both packages, FROM serving that body; for `action` the refusal also names `platform`, as an action name's package-less registry slot no loader stores under that name is counted (the other row is stored under its own key). A read naming either package answers that package's own body, as without the pass.
18+
- A name one package holds, beside another row whose body says that name: the holder is handed on stamped with its row's package, FROM unstamped. The boot pass fills the holder's slot, FROM the bare slot, so after the pass a read naming a package that holds no row of the name answers nothing, as without the pass, FROM the holder's body.
19+
- A loader whose `loadMany` and `loadManyKeyed` serialise a body differently (key order): both holders of a two-holder name are stamped, FROM neither.
20+
- `MetadataManager.loadManyKeyed` entries carry `packageId` where the loader's entry carries one (every type stored per `(package, name)`, `email_template` included), FROM `{ name, data }` alone. objectql's action audit, which reads it, can now tell two packages' entries of one name apart.
21+
22+
Not changed: a name one package holds with no other row's body saying it, a name no package holds, and a loader that does not hold items per package (its bodies are handed on as its `loadMany` answers them). `loadMany` and `loadManyKeyed` hand on as many entries as before for every shape above but the two-holder one, where the other row's body is now kept beside both holders.

0 commit comments

Comments
 (0)