Skip to content

Commit d8a12f2

Browse files
committed
Merge origin/main (#35199 latestPer, #35202 lookup group labels) into the aggregate order and cut
Five adjacent-insertion conflicts, each resolved keeping both sides: the engine exports and the runtime imports of AGGREGATE_ORDER_CUT beside LATEST_PER (objectql index, runtime action-execution and domains/mcp), the two Symbol.for read options in the stdio bridge, and the aggregation-entry test, where the order-and-cut describe block and #35202's lookup-label block both land after the served-schema block. mcp-http-tools.ts merged without conflict. Claude-Session: https://claude.ai/code/session_01JQwxbWDsbbJizuYnDwBxT8 Co-authored-by: Claude <noreply@anthropic.com>
2 parents f766f5d + 084156d commit d8a12f2

64 files changed

Lines changed: 4827 additions & 279 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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@objectstack/runtime': patch
3+
'@objectstack/mcp': patch
4+
---
5+
6+
feat(runtime,mcp): the open MCP server saves and discards metadata drafts, and every save answers with what publishing the draft would say
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
The open draft door on a self-hosted runtime gains its write half. It is served to the same OAuth clients as the read tools: the token carries `metadata:write` and its user holds `manage_metadata`.
12+
13+
- `save_metadata_draft({ type, name, item, package, ifMatch? })` saves `item` as a pending draft in `package`, recorded as an MCP save by the token's OAuth client. The reply carries `saved` (type, name, package, state, version), `verdict` and `review`. `verdict` is what publishing the stored draft would say: `publishable`, `refusals` (the issues a publish would refuse the draft on) and `advisories`, each with `rule`, `path`, `message`, `hint` and `severity`. `review` holds the Console routes where a person reviews and publishes the draft in Studio. `ifMatch` is the version the save expects to replace; a stale one is refused as the `/meta` draft save refuses it.
14+
- A save that names no `package` is refused `400 VALIDATION_ERROR`, and nothing is saved. The refusal names the writable packages in that environment.
15+
- `delete_metadata_draft({ type, name, package? })` discards a pending draft. The published version, if any, is left as it is.
16+
- `list_drafts` now gives each draft its `verdict`. A draft the user may not read (for example a dashboard whose `requiredPermissions` they lack) is listed with `verdict: null` and the reason it was withheld.
17+
18+
A plural type spelling (`dashboards`) is folded to its singular before any gate, verdict or write, as the `/meta` doors fold it. Both writes ask the type-level write admission every `/meta` write asks, so a metadata type the user may not write is refused `403 PERMISSION_DENIED` and nothing is written; a verdict, on a save or a listed draft, is withheld for a type the user may not read. A tenant whose catalog is walled refuses both writes `403 PERMISSION_DENIED`, as the `/meta` write path does; a platform admin is admitted. Nothing on this server publishes: there is no publish tool and no `force`.
19+
20+
When the authoring tools are listed, the open server's default `initialize` instructions add one paragraph saying that they save drafts only and that a person publishes in Studio. The paragraph is absent when the tools are not served, and a host's own instructions replace the default text as before.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
---
4+
5+
feat(metadata-protocol): the draft publish verdict is a public protocol method, and it reads the stored draft itself
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: none
9+
10+
`ObjectStackProtocolImplementation.draftPublishJudgement` is now public. It answers what publishing a stored draft would say, without publishing it: `refusals`, the issues the publish would refuse the draft on, and `advisories`, the findings a publish that passes still returns. Each issue keeps every member the publish's `422 INVALID_METADATA` carries: `rule`, `path`, `where`, `message`, `hint` (the next step) and `severity`. The draft read's `_diagnostics` folds the same verdict but drops the `hint`.
11+
12+
A caller that holds no stored row may omit `body`: the method then reads the stored draft at `type`, `name` and `packageId` (`null` for the draft bound to no package), and `member` for a bundled type, and judges the bytes as stored. An address that holds no draft is refused `404 NO_DRAFT`, as the strict draft read refuses it. It runs the same judgement the draft read and the publish gate run; nothing about either changes.
13+
14+
A caller that judges several drafts in one pass may hand one `packageClosures` map (an empty `Map`) to every call of the pass. The package's other drafts, which a package publish judges each draft against, are then collected once per package instead of once per call. The answers are the same; without the map, each call collects them as before.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@objectstack/skills': patch
3+
'@objectstack/spec': patch
4+
---
5+
6+
docs(skills, spec): the ui and i18n skills teach an action's `refusals` catalogue and its translation keys; `action.zod.ts` gains a module description
7+
8+
Clause-②: no — skill teaching text, evals and two comment-only edits in packages/spec; no schema, export or accept set moves
9+
Metadata-protocol: none — no metadata key is touched
10+
11+
objectstack-ui's `rules/actions.md` gains a short section, "Refusing by code (`refusals`)": a `type: 'script'` action with a `js` body declares the refusals it may throw and throws the code instead of a sentence, the catalogue, the throws and the checks are the ones a hook has (taught in objectstack-data's `references/data-hooks.md` § Declared refusals), the sentence is answered as `userMessage` and translated at `objects.<object>._actions.<action>.refusals.<CODE>.message`, and an authored `errorMessage` replaces it in the console's failure toast. The file's Add Line example now declares `refusals: { PRODUCT_NOT_FOUND: … }` and throws `{ code: 'PRODUCT_NOT_FOUND' }` where it threw `new Error('Product not found.')`.
12+
13+
objectstack-i18n's SKILL.md lists the keys in the object key table — `_actions.{action_name}.refusals.{CODE}` holds `message` and `reasons.{reason}.message`, the same under `globalActions.{action_name}`, and a key for a code or reason the action does not declare is `translation-target-unknown` — and the server-composed text section names an action's refusal beside a hook's. Each skill's eval file gains one case that grades the rule.
14+
15+
`@objectstack/spec`: comments only. `src/ui/action.zod.ts` opens with a module doc block, so the generated reference page and the two skill reference indexes describe the module ("Action protocol schemas — `ActionSchema`, the `action` metadata type, and the parts it is built from.") where they listed its first five exports, and the jsdoc above `actionRefusalsWithoutSandboxedBody` names the third case as the function judges it: a `script` action with no `body`.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(app-shell): a collapsed console sidebar hides fully, and its full menu floats out from the window's left edge
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
From 768 px up, a collapsed app sidebar no longer leaves a column of unlabelled icons: it is hidden, the list and record pages get its width, and nothing in it can be focused or is announced. Both ways of collapsing look the same: collapsing it with the app bar's button, and the fold that collapses it on its own on a window narrower than 1416 px. To get the menu back, rest the pointer on the window's left edge (or press there): the full menu, with its labels and groups, floats over the page and folds back when the pointer moves away, a choice is made, Esc is pressed or the page is clicked. The app bar's button and ⌘B float the same menu, however the sidebar was collapsed, and move the keyboard focus into it; Esc gives focus back to the button. Floating it does not expand the sidebar, so a reload still finds it collapsed. To put the sidebar back beside the page, choose "Keep sidebar open" at the foot of the floated menu: the sidebar stays expanded, after a reload too, and on a narrow window the fold stays off. The phone keeps its bottom menu bar and drawer.

‎.changeset/35145-mcp-latest-per.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@objectstack/mcp': patch
3+
'@objectstack/objectql': patch
4+
'@objectstack/driver-sql': patch
5+
'@objectstack/driver-turso': patch
6+
'@objectstack/metadata-protocol': patch
7+
'@objectstack/runtime': patch
8+
---
9+
10+
feat(mcp): "each X with its latest Y" in one `query_records` call — `latestPer`
11+
12+
Clause-②: yes (widening): a new read form on the published MCP tool surface. Judged from the card content; the build confirms it
13+
Metadata-protocol: none
14+
15+
`query_records` takes `latestPer: { by, orderBy }`: one row per group, the group's first row in the given order. `by` names 1 to 3 fields, `orderBy` 1 to 3 keys (`asc` / `desc`); a tie goes to the record id in the direction of the last key, and an empty order value ranks last. "Each account with its latest deal" is `{ objectName: 'crm_opportunity', latestPer: { by: ['account'], orderBy: [{ field: 'close_date', order: 'desc' }] } }`.
16+
17+
- The row is chosen among the rows the caller may read and the `where` admits: a group whose newest row is hidden from the caller answers its newest readable row, never the hidden one and never nothing. The organization wall holds inside the choice. Field masking still applies to the returned rows.
18+
- A partition or order field the caller may not read is refused as it is in `orderBy`; a computed, JSON or multi-value field, or a dotted path, is refused as a partition or order field.
19+
- `limit` counts groups, capped at the tool's `maxLimit` like any list. The answer is `{ object, records, hasMore }` and never a `total`; when more groups exist than came back it carries `truncated: true`.
20+
- Served by the SQL driver (Postgres, MySQL, SQLite) and by `driver-sqlite-wasm` and the Turso driver on a local or embedded-replica database: the driver compiles a `ROW_NUMBER()` window over the read's own scoped selection. Every other driver (in-memory, Turso's remote connection, MongoDB), an object with an `afterFind` hook and an object with object-scoped read middleware refuse with `INVALID_QUERY` / 400 before anything is read. The Turso driver's remote face refuses the directive itself too.
21+
- New exports: `LATEST_PER`, `LATEST_PER_MAX_KEYS` and the `LatestPerRequest` / `LatestPerOrder` / `LatestPerOutcome` types from `@objectstack/objectql`; `LATEST_PER_DIRECTIVE`, `latestPerDirectiveOf` and the `LatestPerDirective` / `LatestPerDirectiveOrder` types from `@objectstack/driver-sql`; `McpLatestPer` from `@objectstack/mcp`. The request rides an in-process read option, never a wire or query key; `@objectstack/spec` is unchanged.
22+
23+
Without `latestPer`, `query_records` and every read are unchanged.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@objectstack/mcp': patch
3+
---
4+
5+
feat(mcp): `aggregate_records` names the record of a lookup group beside its id, read as the caller
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: none
9+
10+
When the MCP `aggregate_records` tool groups by a `lookup` or `master_detail` field, each group now carries a new member `<key>__label` beside the key: the name of the referenced record, from the referenced object's name field (`nameField`, as ADR-0079 resolves it). `<key>` is the group column, which is the key's alias when the call gives one. The same spelling is used by the hosted ask tools, so one prompt reads both. This holds on both the HTTP and the stdio door.
11+
12+
The name is read as the caller, through the same bridge and context as the aggregate, in one batched read of the referenced object for the groups the tool serves. Nothing is read with other rights, so the caller's object, field and record permissions apply as they do for any read the caller makes.
13+
14+
- A label is present only for a key whose record the caller's read returns with a non-blank name. Any other key carries no label, and nothing else in the answer changes.
15+
- No label is added, and the answer is exactly as before, when the caller is not served the referenced object, its name field or the lookup field, when the referenced object is a system object the tool does not read, or when the read fails. A failed name read never fails the aggregate.
16+
17+
The tool description now tells a model to name such a group by its `__label`, never by the id, and to say the record cannot be named where no label is present. Existing members (`rows`, `totalGroups`, `truncated`, `currencies`) are unchanged.

‎content/docs/ai/connect-mcp.mdx‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,39 @@ service is installed:
280280
| `list_datasets` | List the governed datasets (business metrics) you may query: their measures and dimensions with business labels, descriptions and synonyms, and which of the question's words each one matches exactly |
281281
| `query_dataset` | Compute a governed metric by the names `list_datasets` gives; the answer carries its provenance (the dataset and measures used) |
282282

283+
### Each X with its latest Y: `latestPer`
284+
285+
"Each account with its latest deal" is one `query_records` call. `latestPer`
286+
names the groups and the order that picks each group's row:
287+
288+
```json
289+
{
290+
"objectName": "crm_opportunity",
291+
"where": { "stage": { "$ne": "closed_won" } },
292+
"latestPer": { "by": ["account"], "orderBy": [{ "field": "close_date", "order": "desc" }] }
293+
}
294+
```
295+
296+
- `by` takes 1 to 3 fields; `orderBy` takes 1 to 3 keys, each `asc` or `desc`.
297+
The answer is one row per group: the group's first row in that order. A tie
298+
goes to the record id, in the direction of the last key; an empty order value
299+
ranks last.
300+
- The row is chosen among the rows the caller may read and the `where` admits:
301+
a group whose newest row is hidden from the caller answers its newest row the
302+
caller can read. Your own `orderBy`, `fields` and `offset` apply to the
303+
answered rows.
304+
- `limit` counts groups (capped at 50, like any list). The answer is
305+
`{ object, records, hasMore }` with no `total`; when more groups exist than
306+
came back it also carries `truncated: true`.
307+
- A partition or order field the caller may not read is refused, as it is in
308+
`orderBy`. A computed, JSON or multi-value field, or a dotted path, is refused
309+
as a partition or order field.
310+
- The SQL drivers serve it (Postgres, MySQL, SQLite, and Turso on a local or
311+
embedded-replica database). Elsewhere (the in-memory driver, Turso's remote
312+
connection, MongoDB) the call is refused with `INVALID_QUERY` before anything
313+
is read, as it is for an object with an `afterFind` hook or object-scoped read
314+
middleware.
315+
283316
### Governed metrics and the `initialize` instructions
284317

285318
`list_datasets` and `query_dataset` are registered with the `data:read` scope,

0 commit comments

Comments
 (0)