Skip to content

Commit c5d0e37

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-3giljf
# Conflicts: # packages/metadata-protocol/src/index.ts # packages/metadata-protocol/src/protocol-exact-qualifier.ts # packages/objectql/src/bare-name-one-holder.ts # packages/objectql/src/package-scoped-exact-qualifier.test.ts
2 parents c79a4e6 + 326453e commit c5d0e37

174 files changed

Lines changed: 10578 additions & 689 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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/service-automation': patch
3+
---
4+
5+
feat(automation): the flow credential channel reads and writes by package, so each slot of a flow name two packages hold reads its own package's credentials (ADR-0150 D8 row R9, part of #31696)
6+
7+
Clause-②: yes (widening)
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 is removed or renamed. The credential reads widen (a shared slot's read is now answered), and the save refusal relaxes, so there is nothing for a migration to rewrite and no tombstone. -->
11+
12+
- `FlowCredentialChannel` now declares `readsByPackage = true`. Its index is keyed by flow name and package (`sys_flow_credential.flow_package`), so a credential read for a slot of a name two packages hold (an http node's signing secret, an inbound hook's secret) is answered by that package's rows only. It used to be refused. Under two holders a row naming no package (one the boot backfill could not attribute, or one written before this release) belongs to no slot anyone can tell, so it fails closed for every slot: it reads as held, and its read is refused with `FlowCredentialUnresolvableError` (503) naming the flow, so an http node is refused and sends nothing rather than falling back to its literal or going unsigned.
13+
- Each row the save door writes is stamped with the flow's one package holder. The plugin passes the engine's `flowHolderPackage` as the channel's new optional third constructor parameter (`holderOf`); existing two-argument callers keep compiling.
14+
- Under a name two packages hold, a save or a publish never reads a holder's row, so it never rewrites or removes another package's credential. A save that sets a credential there, clears one where a row of any package stands, or would delete a row naming no package, and a publish that would promote, consume or remove a row naming no package, are refused with `RESOURCE_CONFLICT`, naming every holder, before anything is written. A save that drops a position where only a holder's row stands no longer is (that row stays), and a save that touches no row still saves.
15+
- A slot's run history is no longer cut short by another slot's newer runs of the same name: the store's window widens until the slot's own `limit` rows are in it or the store has no more.
16+
- A stored run naming no package, written back while one package's slot holds a name the registry holds twice, keeps naming no package instead of being stamped with that slot's package.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/objectql': minor
4+
'@objectstack/service-automation': minor
5+
'@objectstack/runtime': minor
6+
'@objectstack/cloud-connection': minor
7+
---
8+
9+
feat(sync-in): a job pulls a mapping's `datasourceSource` — the federated object it names is read in windows and copied into the `synced` target (ADR-0153 D1, D2, D8)
10+
11+
Clause-②: yes (widening)
12+
Metadata-protocol: semantic
13+
Skills-docs: none — no published skill teaches `connectorSource` or `datasourceSource` today (`git grep` over `skills/` finds neither); the hand-written guide this change made false, `content/docs/automation/jobs.mdx` ("Pulling a mapping"), is corrected in the same change, and the sync-in guide and skills are ADR-0153's P3 guide + skills child
14+
15+
A mapping's `datasourceSource` now does what it declares. A `job` whose `pull` names such a mapping is scheduled, and each run reads the federated object the mapping names and writes its rows into the mapping's `synced` target through the import runner, as a connector pull does. Before this release that job was not scheduled, and the key warned its author that nothing read it.
16+
17+
- **Two read paths (ADR-0153 D1).** A built-in driver (the SQL dialects, `memory`, `mongodb`, `turso`) is read in aligned windows, each whole and paged by the key the object's `external.columnMap` maps onto `id`. A plugin driver is read through the engine's floor in windows bounded on both sides and halved while they come back over the datasource's row cap. Every read names its own `limit`, so a deployment's default page size never cuts a window.
18+
- **Judged again before the first read.** The target is `managedBy: 'synced'`; the source is a federated object on a non-managed datasource; its `columnMap` maps a column onto `id` (`source_key_missing`); `watermark.field` is a `datetime`, `date` or `scale: 0` number field; a `fieldMapping` entry copies it unchanged onto a target field of its type (`watermark_field_unmapped`). The build already refuses each of these; the run-time judgment covers a stack the build never saw. Each refusal is a `ConnectorPullError` with `code`, `status` and `reason`.
19+
- **Whose rows (ADR-0153 D8, the read half).** Under a walled tenancy posture (`isolated`, `group`), a source that declares its own `organization_id` is read for the job's organization only, on every read. A shared source (`tenancy: { enabled: false }` or `systemFields: { tenant: false }`) is read whole. A source that states no scope is refused (`source_organization_scope_unstated`), and so is a walled source pulled in no organization (`job_organization_missing`). Under `single` the source is read as configured.
20+
- **No committed position is kept yet.** The read position is stored on `sys_sync_run` (ADR-0153 D7), which lands separately. Until then every run reads from `watermark.start`, so an incremental pull reads what a `full` one reads. The keyed upsert keeps the rows right, but every run rewrites every row of the `synced` target: record-triggered automations run, audit rows are written and `updated_at` moves for each row, on every run, until the slice that stores the read position lands. `datasourceSource.full`, `deletePolicy` and `deletedField` still warn their author that they change nothing yet.
21+
- **The pull result names its source.** `ConnectorSourcePullResult` (`@objectstack/spec/contracts`) is now a union told apart by `source`: the connector arm (`connector`, `action`, `watermark`; `source` optional, read as `'connector'`), and the datasource arm (`source: 'datasource'`, `object`, `datasource`, `readPath`, and `watermark: { field, from, committed? }`). An implementation that answers the connector shape still compiles. A caller that reads `connector` or `action` narrows on `source` first. `ConnectorSourcePullConnectorResult`, `ConnectorSourcePullDatasourceResult` and `ConnectorSourcePullResultBase` are new exports.
22+
- **The windowed read**, two corrections: on a window read in several pages, an absent high-water value reads as the window's own start, and a commit never goes below where the run started. An unreadable watermark value in an over-cap answer is refused as `watermark_not_exact`, the data's fault, rather than `sync_bounds_not_pushed`.
23+
- `@objectstack/objectql` exports `resolveExternalRowCap`. `@objectstack/service-automation` now depends on `@objectstack/plugin-security` at run time, to read a federated object's organization scope with the one reading the organization wall uses.
24+
- A pull job whose mapping declares no source is refused at bind naming both keys, `connectorSource` and `datasourceSource`, and the install-local door's remedy names both.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
'@objectstack/service-automation': patch
3+
'@objectstack/objectql': patch
4+
---
5+
6+
fix(service-automation)!: a flow `script` node runs the function of its own flow's package — a name that means no single function for that flow is refused naming every holder, and the hook binder keeps a package's own function after another package registers the name (ADR-0150 D3)
7+
8+
Clause-②: no (narrowing)
9+
Metadata-protocol: none
10+
11+
<!-- adr-0087: not-required (no-migration-prescription) no metadata shape, schema, stored row or registered node type changes: the change is which registered function a script node's name answers and which a hook's engine read binds, the flow and hook metadata are read exactly as before, so there is nothing for `objectstack migrate meta` to rewrite -->
12+
13+
A flow `script` node resolved `config.function` through the engine's bare function map, which keeps the last registration per name. It now resolves through the one package-scoped resolver for functions (`resolvePackageScopedFunction`, `@objectstack/objectql`), in the package of the calling flow: the package whose own body is armed under the flow's name (`AutomationEngine#armedFlowPackage`). An environment-authored flow and an environment override of a packaged flow are callers with no package. A packaged flow gets its own package's function, else the one holder in its declared dependency closure (plus `sys` and the platform's owner-less function), else a refusal. A caller with no package gets the one holder in the environment, else a refusal. The refusal is `PackageScopedNameRefusedError` (`409 RESOURCE_CONFLICT`, every candidate named). The step fails as a guard with the refusal's text, `code: 'RESOURCE_CONFLICT'` (`$error.code`) and `innerRefusal: { code: 'RESOURCE_CONFLICT' }`. So every door that reports a failed run answers `400 FLOW_FAILED` with `error.details.innerRefusal.code: 'RESOURCE_CONFLICT'`: `POST /automation/:name/trigger`, the resume door of a paused (screen) flow, a flow-type action at `/actions` (and the MCP `run_action` bridge), and a declared endpoint that runs a flow. A name with one holder in the caller's reach (own, closure, environment-wide or platform) runs exactly the function it ran before, with the `effect` it declared.
14+
15+
An action `target` is not touched. It names a handler key in the action registry, which E2 already resolves by package; no action reads the function registry.
16+
17+
**BREAKING** for these answers (first-party count: 0 for each — the booted showcase, crm and multi-package apps hold no function name twice and no owner-less function, and the one first-party `script` node names its own package's function):
18+
19+
1. A packaged flow naming a function two packages hold, one of them its own, ran the last-registered holder's function. It now runs its own. A fix.
20+
2. A flow with no package naming a function two packages hold ran the last-registered one. The step now fails `RESOURCE_CONFLICT` (`ambiguous-in-environment`) naming both, and each flow door answers `400 FLOW_FAILED` carrying it.
21+
3. ADR-0150 D3 (c): a packaged flow naming a function that only a package outside its declared dependency closure holds was served that function. The step now fails `RESOURCE_CONFLICT` (`outside-closure`) naming the holder. This is the one refusal a single holder gets. A function registered under an owner that is no installed package is refused the same way for a packaged flow.
22+
4. The platform's owner-less function beside a package's function of the same name ran the last registration. For a caller with no package, or a packaged flow that holds none itself and reaches the package holder, the step now fails `RESOURCE_CONFLICT` naming both.
23+
5. A packaged flow holding none, with two holders in its declared closure, ran the last registration. The step now fails `RESOURCE_CONFLICT` (`ambiguous-in-closure`) naming both.
24+
6. Published in-process API: `AutomationEngine#resolveFunction(name)` returned the last registration for every shape in 2–5. It is now `resolveFunction(name, context?)`, resolved for `context`'s flow (no `context`: a caller with no package), and it THROWS `PackageScopedNameRefusedError` for those shapes. `FlowFunctionResolver` gains a second parameter, `callerPackageId: string | null`. A one-parameter resolver still type-checks and is still called.
25+
7. A host whose `objectql` service offers `resolveFunction` but not `functionHoldersOf` had its script nodes bridged to the bare map. It is now left unbridged, so the step fails "no function named … is registered". Every `ObjectQL` offers `functionHoldersOf`.
26+
8. A packaged flow holding none, with one holder in its declared closure and another holder outside it registered last, ran the outside holder's function. It now runs the closure holder's (served by a different holder, not refused).
27+
9. A packaged flow holding none, with the platform's owner-less function and a package holder outside its closure, ran the last registration. It now runs the platform's (served by a different holder, not refused).
28+
29+
**Widening** (objectql `bindHooksToEngine`): a hook whose string `handler` names a function its own package registered on the engine earlier, with no `functions` handed to the bind, was refused `400 INVALID_REFERENCE` once another package had registered the same name, because the bare map's entry then named the other package. It is now bound to its own package's function. The rule is still own package only: every other holder (a closure holder, the platform's owner-less function, another package's) is refused `400 INVALID_REFERENCE` as before. Two more answers move with it:
30+
31+
- A hook bound on an engine that carries `resolveFunctionEntry` but not `functionHoldersOf` (reachable only through a cast; every `ObjectQL` carries both) was bound to its own package's engine-registered function. It is now refused `400 INVALID_REFERENCE`, the same class as item 7.
32+
- After `unregisterFunctionsByPackage` removes the last package that registered a name, an earlier package's function of that name is served again (to its own hooks, and to every flow it is in reach of), where the bare map answered "no function". No source caller of that method exists.
33+
34+
The fix for each:
35+
36+
- FROM a flow with no package naming a two-holder function (or a platform function beside a package's) TO a packaged flow in the package whose function it means, or a renamed function.
37+
- FROM a packaged flow naming a function held only outside its closure TO the holder declared in the flow's package `dependencies` (ADR-0141); for a function whose owner is no installed package, TO an owner-less registration (the platform) or a registration under the package that ships it.
38+
- FROM a packaged flow holding none with two (or a package and the platform) in reach TO the function registered in the flow's own package, or one holder in reach.
39+
- FROM `engine.resolveFunction(name)` reading one of several holders TO `engine.resolveFunction(name, context)` with the calling run's context, catching `PackageScopedNameRefusedError` (or `code === 'RESOURCE_CONFLICT' && refusal.status === 'refused'`).
40+
- FROM a custom `objectql` service (or an engine handed to `bindHooksToEngine`) without `functionHoldersOf` TO one that offers it (and `registry`), as `ObjectQL` does.
41+
- FROM a packaged flow that relied on an outside holder's function, or on the last registration (items 8 and 9), TO that function registered in the flow's own package (a package's own function is reached first), or to a function renamed apart.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@object-ui/data-objectstack': patch
3+
'@object-ui/plugin-dashboard': patch
4+
---
5+
6+
feat(ui): a dashboard render sends its dataset queries as one batch request
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
A dashboard used to send one `POST /api/v1/analytics/dataset/query` per dataset-bound widget. It now sends the queries one render asks as one `POST /api/v1/analytics/dataset/query/batch` per package, through the batch door `@objectstack/rest` serves. Nothing to author and nothing to change in a host.
12+
13+
- `@object-ui/data-objectstack`: `ObjectStackAdapter.queryDatasetBatch(queries, { packageId?, previewDrafts? })` runs several dataset queries and resolves to one outcome per query, in order, in `Promise.allSettled`'s shape. Each outcome is what `queryDataset` gives that query alone: its answer, or the error it throws for that query's refusal, classified by the same ladder. Queries are grouped by the package they are read from (an inline draft goes without one) and sent at most `DATASET_QUERY_BATCH_MAX_QUERIES` to a request; a lone query takes the single door. A batch refused whole for a reason that is no query's own (not signed in, no analytics service) refuses each query with the single door's error for that answer. A server that does not serve the batch door (`404 ROUTE_NOT_FOUND`, or a bare 404/501) has each query answered by the single door, and the adapter stops asking it for batches.
14+
- `@object-ui/plugin-dashboard`: `DashboardRenderer` and `DashboardGridLayout` gather the dataset queries their widgets and filter bar ask in one render and hand them to the data source's `queryDatasetBatch`. Each widget keeps its own query, answer, refusal state and invalidation refetch. A query alone in its render window (a widget mounted alone, a one-widget refetch) and every query of a data source with no `queryDatasetBatch` take `queryDataset` unchanged.

0 commit comments

Comments
 (0)