Skip to content

Commit ce2f6fe

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/issue-35137-withheld-fields
# Conflicts: # packages/mcp/src/mcp-http-tools.ts
2 parents 69216b0 + 1caee8c commit ce2f6fe

36 files changed

Lines changed: 3168 additions & 183 deletions
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.

‎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,

‎docs/qa/platform-checklist/areas/platform-core.json‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@
640640
"title": "The built-in apps a stock boot REGISTERS (Setup / Account) render every merged-nav destination; app-level and entry-level gates are enforced, not errored — and Studio's deliberate absence is asserted, never hunted",
641641
"since": "v15",
642642
"status": "active",
643-
"revision": 16,
643+
"revision": 17,
644644
"priority": "P0",
645645
"surface": "browser",
646646
"personas": [
@@ -662,7 +662,7 @@
662662
"steps": [
663663
"as admin, GET /api/v1/meta/app?id=setup and extract every merged nav destination — Setup is a SHELL of empty group anchors (packages/platform-objects/src/apps/setup.app.ts: group_overview/apps/people_org/access_control/approvals/configuration/diagnostics/integrations/advanced) filled by SETUP_NAV_CONTRIBUTIONS (setup-nav.contributions.ts) plus capability-plugin contributions (plugin-security Positions/Permission Sets, plugin-sharing Sharing Rules/Record Shares, plugin-approvals, plugin-webhooks)",
664664
"GET /api/v1/meta/app with NO query first and record the names actually served — a stock boot answers exactly showcase_app, setup, account. Then GET /api/v1/meta/app?id=account (account.app.ts — Profile + Inbox/Security/Developer groups). ⚠️ GET /api/v1/meta/app?id=studio answers 200 {\"items\":[]} on every stock boot and that is the expected result (knownGap): record the absence as an assertion and move on — do NOT install @objectstack/studio to make the step runnable",
665-
"as admin, hand-walk each destination in each app. At a window narrower than 1416 px (1280 px included) the console folds the sidebar to its icon rail, and Setup and Account open that way (ui/packages/app-shell/src/layout/consoleSidebarRail.ts CONSOLE_SIDEBAR_RAIL_BELOW_WIDTH, objectstack#27593; QA run #29877 met it at 1280 px): press the sidebar toggle at the app bar's left edge (Ctrl/⌘+B) to unfold it before expanding any group. EXPAND every nav group first: some render collapsed by default — Setup's Advanced group and Account's Developer group declare `expanded: false` (packages/platform-objects/src/apps/setup.app.ts, account.app.ts), and QA run #24557 found Setup's Configuration group collapsed as well — so a walk that never expands them never reaches their entries. Then navigate, wait for render, SCREENSHOT FIRST, then read the DOM — assert no pageerror, no 'failed to load', no blank <main>, no 'no actions configured' placeholder",
665+
"as admin, hand-walk each destination in each app. At a window narrower than 1416 px (1280 px included) the console folds the sidebar, and Setup and Account open that way (ui/packages/app-shell/src/layout/consoleSidebarRail.ts CONSOLE_SIDEBAR_RAIL_BELOW_WIDTH, objectstack#27593; QA run #29877 met it at 1280 px). Folded, the sidebar is hidden, with no icon column (ruling 6973617688 on objectstack#35062): press the sidebar toggle at the app bar's left edge (Ctrl/⌘+B), or rest the pointer on the window's left edge, to float the full menu over the page before expanding any group. The float folds back after each chosen entry, so float it again for the next destination. EXPAND every nav group first: some render collapsed by default — Setup's Advanced group and Account's Developer group declare `expanded: false` (packages/platform-objects/src/apps/setup.app.ts, account.app.ts), and QA run #24557 found Setup's Configuration group collapsed as well — so a walk that never expands them never reaches their entries. Then navigate, wait for render, SCREENSHOT FIRST, then read the DOM — assert no pageerror, no 'failed to load', no blank <main>, no 'no actions configured' placeholder",
666666
"Setup detail: confirm each settings URL entry (nav_settings_* → /apps/setup/system/settings/<namespace>) opens the settings namespace form — the 11 namespaces of a stock single-posture boot, localization/company/branding/auth/access_policy/mail/sms/storage/ai/knowledge/lifecycle: the nav_settings_* entries of packages/platform-objects/src/apps/setup-nav.contributions.ts, plus nav_settings_branding, which packages/services/service-settings/src/settings-service-plugin.ts contributes only where no organization wall stands, and Users / Organization / Business Units / Teams / Sessions / OAuth Applications render. User preferences and identity links are not Setup destinations: open a user's record page, /_console/apps/setup/sys_user/record/ID (a row click on the Users list opens a side panel at ?recordId=, which is not that page: take the id from the row or the panel), and confirm the user page's Preferences and Linked Accounts tabs (packages/platform-objects/src/pages/sys-user.page.ts#SysUserDetailPage) render that user's rows",
667667
"Studio detail is NOT walked from here — the app is not registered on a stock boot (knownGap), so there is no merged nav to render. Its metadata:resource lists and component surfaces (App Builder, All Metadata Types, Packages, API Console, Flow Runs, Public Forms) are reached through the console surface at /_console/studio/<pkg>/<pillar> and are covered by area studio-authoring. What THIS item asserts about Studio is the absence itself, per clause 6",
668668
"Account detail: confirm Profile (account:profile_card), Notifications (sys_inbox_message/mine), Approvals (nav_account_approvals, the approvals:inbox component, served as …/component/approvals/inbox — the Approvals Inbox, not the sys_approval_request grid; account.app.ts), Linked Accounts (sys_account), Active Sessions (sys_session/mine), API Keys (sys_api_key/mine), OAuth Applications (sys_oauth_application/mine) and Connect an Agent (nav_connect_agent) each render — 8 Account destinations and 47 Setup destinations for the admin on a stock single-org showcase boot, read from source after objectstack#34724 retired Setup › Packaged Actions (nav_packaged_actions; its switch moved onto the action in Studio); QA runs #32953 (at 5fb79bc0) and #33087 (at 8e3d4a54) read 48 before it (GET /api/v1/meta/app leaves, which match the nav source minus its gates). QA run #29877 read 46 at 589049b0, before Access policy (nav_settings_access_policy, the access_policy namespace) joined the Configuration group. Since QA run #28545's reading Setup's Packaged automation page retired under ADR-0146 D11, leaving Packaged Actions (nav_packaged_actions, automation:packaged-actions; #28785, itself retired by objectstack#34724), and its unfiltered Packages entry moved to Studio (#29547) (47 for #28927, 50 at eeec88d1 for QA run #28545, 48 re-measured at 3fd80337 for #28338, QA run #27481 read 44 and 8, QA run #24557 read 42 at 5b14b7f3, 45 on 2026-10-01, and #9453 recorded 43 and 7). Recount from the payload each run",
@@ -816,6 +816,12 @@
816816
"date": "2026-11-17",
817817
"change": "steps[5]: the admin's Setup destinations are 47, not 48: Setup › Packaged Actions (nav_packaged_actions) retired, its switch moved onto the action in Studio (the ADR-0146 D4 amendment of 2026-11-17). Read from source; not yet re-measured by a QA run.",
818818
"ref": "#34724"
819+
},
820+
{
821+
"revision": 17,
822+
"date": "2026-11-18",
823+
"change": "steps[2]: below 1416 px the fold now hides the sidebar instead of leaving its icon rail (ruling 6973617688 on #35062): the walk floats the full menu with the toggle (Ctrl/⌘+B) or by resting the pointer on the window's left edge, and floats it again after each chosen entry, since the float folds back on navigation. The walk is unchanged in substance. No clause changed. Read from source, and measured on a CRM boot (at 1280×800 the toggle floated the menu with focus on its entry; at 1600×900 choosing an entry in the float folded it); not yet re-run by a QA run.",
824+
"ref": "#35187"
819825
}
820826
]
821827
},

‎packages/drivers/driver-sql/src/index.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ export {
4646
UnsupportedDialectEmissionError,
4747
renderDialectEmissionRefusal,
4848
} from './dialect-emission-refusal.js';
49+
// [latest per group] The window directive `find` compiles, so a subclass that
50+
// answers `find` on another transport (Turso's remote face) can tell it rode in.
51+
export { LATEST_PER_DIRECTIVE, latestPerDirectiveOf } from './sql-driver-latest-per.js';
52+
export type { LatestPerDirective, LatestPerDirectiveOrder } from './sql-driver-latest-per.js';
4953
// [ADR-0131 D9] The autonumber counter's refusal of an organization-less row on
5054
// a tenant table — exported for the same reason: a caller recognises it by `code`.
5155
export {

‎packages/drivers/driver-sql/src/sql-driver-crud.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {
4141
import type { SqlDriver } from './sql-driver.js';
4242
import { oracleUuidReadForm } from './sql-driver-oracle-dialect.js';
4343
import { StandardErrorCode } from '@objectstack/spec/api';
44+
import { latestPerDirectiveOf, latestPerIdSubquery } from './sql-driver-latest-per.js';
4445

4546
/**
4647
* [`DriverOptions.lockRows`] Lock the rows a `find()` returns until its
@@ -154,7 +155,7 @@ export class CrudFacet {
154155
* cited that as agreement, which it was not; objectstack#4419.) The
155156
* obligation the contract states is on `find`, and this keeps it there.
156157
*/
157-
static async findRows(this: Pick<CrudHost, 'applyFilters' | 'applyTenantScope' | 'backendStatementFault' | 'formatOutput' | 'getBuilder' | 'isMssql' | 'isOracle' | 'mapSortField' | 'orderKeysFor' | 'primeMssqlGuidColumns' | 'primeMssqlPagingKey' | 'primeOracleRawUuidColumns' | 'remoteColumn' | 'unresolvableFilterColumnRefusal'>, object: string, query: DriverQuery, options?: DriverOptions, singleRowLookup = false): Promise<any[]> {
158+
static async findRows(this: Pick<CrudHost, 'applyFilters' | 'applyTenantScope' | 'backendStatementFault' | 'formatOutput' | 'getBuilder' | 'isMssql' | 'isOracle' | 'knex' | 'mapSortField' | 'orderKeysFor' | 'primeMssqlGuidColumns' | 'primeMssqlPagingKey' | 'primeOracleRawUuidColumns' | 'remoteColumn' | 'unresolvableFilterColumnRefusal'>, object: string, query: DriverQuery, options?: DriverOptions, singleRowLookup = false): Promise<any[]> {
158159
// [#31390] On Oracle a federated object's RAW(16) uuid columns are read from
159160
// the remote catalog before a comparand or a written value is bound.
160161
if (this.isOracle) await this.primeOracleRawUuidColumns(object);
@@ -169,6 +170,10 @@ export class CrudFacet {
169170
// whether the statement HAS a sort to drop, instead of asking whether the
170171
// caller supplied one — since #4363 those are different questions.
171172
const orderKeys = this.orderKeysFor(object, query, { singleRowLookup });
173+
// [latest per group] One row per group, when the engine handed the window
174+
// directive (`sql-driver-latest-per.ts`): one more predicate on the same
175+
// statement, so every clause below holds for it unchanged.
176+
const latestPer = latestPerDirectiveOf(query);
172177

173178
// Build everything EXCEPT the SELECT list, so the unknown-column retry
174179
// below can rebuild without re-deriving where/order/pagination.
@@ -181,6 +186,12 @@ export class CrudFacet {
181186
if (query.where) {
182187
this.applyFilters(b, query.where, options);
183188
}
189+
if (latestPer !== undefined) {
190+
b.whereIn(
191+
this.remoteColumn(object, 'id', 'id'),
192+
latestPerIdSubquery.call(this, object, query.where, latestPer, options),
193+
);
194+
}
184195

185196
// ORDER BY
186197
if (withOrderBy) {

0 commit comments

Comments
 (0)