Skip to content

Commit f4bbd64

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-tfbq5b
2 parents 1b81f7e + 3eac63a commit f4bbd64

32 files changed

Lines changed: 2029 additions & 58 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/mcp': patch
3+
'@objectstack/runtime': patch
4+
'@objectstack/plugin-approvals': patch
5+
'@objectstack/plugin-security': patch
6+
'@objectstack/plugin-audit': patch
7+
---
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: none
11+
12+
The MCP read tools (`list_objects`, `describe_object`, `query_records`, `get_record`, `aggregate_records`) now admit a system object whose author declared `enable.aiReadable: true`, asked through a new optional bridge member `aiReadExposed` that both bridges answer with `isAiReadExposed`. Every gate after admission is unchanged (the caller's permissions, row-level security, the object's own read gates, field masking), and every write tool still refuses every `sys_*` object. `sys_approval_request` declares the key; `query_records` names the "waiting on you" filter shape.
13+
14+
The member baseline `member_default` now names `sys_approval_request` read-only, so every signed-in member holds a data-door read on it; which rows is still the approvals request read gate (the submitter, a current approver, a past actor), and no write opens. That gate now answers a conjunctive `pending_approvers` `$contains` of the caller's own id with the approvals service's acting-address fold, so the console's My Pending view and an agent's "waiting on me" query find a slot addressed by email or an unstaffed position, not only one holding the user id. A `pending_approvers` predicate naming another id, or under `$or`, is read as written.
15+
16+
`@objectstack/plugin-audit`: the activity and audit copies of an approval request are hardened (GHSA-2985-5f64-8wgh). New copies no longer carry the request's subject snapshot, and `migrateSideCopies` / `migrateArchivedSideCopies` rewrite the copies at rest. Both ledgers' read redactions drop it from an older copy whether or not the rewrite has run.
17+
18+
**Who can query those copies narrows.** A non-system query on `sys_activity` or `sys_audit_log` that names `sys_approval_request` by equality on `object_name` and names a column holding the copy (`metadata`; `old_value`, `new_value`), as a free-text search does, is now judged against every registered object, as a query naming no object already is. A reader withheld any field of any object, an organization administrator included, is refused it (`403`) where they were answered before. The same query pinned to another object, or naming only other columns, is judged as before. This does not depend on the rewrite having run.

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,17 @@ usable on an app with hundreds of objects. Which objects and actions that spine
362362
can reach is the **default exposure policy (v1)**:
363363

364364
- **Objects are exposed automatically** — except `sys_*` system objects, which
365-
are blocked fail-closed.
365+
are blocked fail-closed. A system object whose author declared
366+
`enable.aiReadable: true` is open to the read tools only (`list_objects`,
367+
`describe_object`, `query_records`, `get_record`, `aggregate_records`), read
368+
as you under every gate a read already runs (your permissions, row-level
369+
security, the object's own read rules, field masking); no write tool opens
370+
it, and the stored-metadata tables stay refused. `sys_approval_request`
371+
declares it: every signed-in member reads the requests they take part in
372+
(submitted, waiting on them, or acted on) and no others, so an agent can
373+
list the approvals waiting on you with `pending_approvers` contains
374+
`{current_user_id}` — answered for a slot that names you by email, position
375+
or team too, not only by user id.
366376
- **Actions require the author's opt-in**: `ai: { exposed: true }` plus an
367377
`ai.description` of at least 40 characters, and the action must be callable
368378
without a UI. In the open framework that means three types — `script`

‎content/docs/automation/approvals.mdx‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -590,16 +590,22 @@ The same rule governs a decision's files: an attachment is exactly as readable
590590
as the decision it hangs off, never more (`sys_approval_action` delegates that
591591
question back to this service via `fileAccessDelegate`).
592592

593-
So do the two objects' definitions. The metadata API answers an object the
594-
caller may not read as absent, and `sys_approval_request` and
595-
`sys_approval_action` are closed to ordinary members on the data side, yet the
596-
request page renders from both definitions. Both declare
597-
`schemaReadDelegate: 'approvals'`, so `GET /api/v1/meta/object/sys_approval_request`
598-
(and `…/sys_approval_action`, and the object list) serves them to a caller who
599-
can see at least one request by the rule above, projected by that caller's
600-
field-level security. A member who can see none is answered `404`, and a
601-
member the data door refuses still reaches the rows only through
602-
`/api/v1/approvals/*`.
593+
Every signed-in member holds a read on `sys_approval_request` through the
594+
member baseline (`member_default`), and the data door serves them exactly the
595+
requests the rule above lets them see, with the same snapshot redaction. So
596+
`GET /api/v1/data/sys_approval_request` (and an MCP agent's `query_records`)
597+
lists a member's own requests, and a `pending_approvers` filter on
598+
`{current_user_id}` finds the requests waiting on them, including a step
599+
addressed to their email or position. No write opens on it.
600+
601+
The two objects' definitions follow. The metadata API answers an object the
602+
caller may not read as absent; with the baseline read, every member is served
603+
the `sys_approval_request` definition, projected by their field-level
604+
security. `sys_approval_action` stays closed to ordinary members on the data
605+
side, and both objects declare `schemaReadDelegate: 'approvals'`, so
606+
`GET /api/v1/meta/object/sys_approval_action` (and the object list) serves it
607+
to a caller who can see at least one request by the rule above. A member who
608+
can see none is answered `404` for it.
603609
</Callout>
604610

605611
<Callout type="info">
@@ -857,8 +863,8 @@ progress, the approvers it is waiting on, the merged decision timeline and a rem
857863
button for the submitter. Every viewer who can read the record sees it, not only
858864
approvers. A request opens on its record page through the approvals routes rather
859865
than the data API, so an approver who is not an administrator sees the whole page,
860-
decision actions included, although the data API stays closed to them on the
861-
approval objects.
866+
decision actions included, even where the data API does not serve them the
867+
request row.
862868

863869
Each action's visibility is gated by a **server-computed per-viewer block** the
864870
service attaches to every request it returns:

‎packages/mcp/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ apply):
109109

110110
```typescript
111111
// Object data
112-
'list_objects' // List objects (system sys_* objects hidden by default)
112+
'list_objects' // List objects (sys_* hidden unless declared enable.aiReadable)
113113
'describe_object' // Object schema: fields + features
114114
'validate_expression' // Check a CEL expression against a schema before authoring it
115115
'query_records' // Filter / sort / paginate

‎packages/mcp/src/mcp-http-tools.ts‎

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030
* action tools yield PER ACTION: a `sys_*` action whose author declared
3131
* `ai.exposed: true` (the bridge attests it as `aiExposed`) is listed and
3232
* run like any other exposed action (#27681, ADR-0011) — no other key and
33-
* no deployment switch opens one.
33+
* no deployment switch opens one. The READ tools (list, describe, query,
34+
* get one, aggregate) yield PER OBJECT the same way: a `sys_*` object whose
35+
* author declared `enable.aiReadable: true` (the bridge attests it through
36+
* `isAiReadExposed`, {@link McpDataBridge.aiReadExposed}) is read like any
37+
* other object, under every later gate (#32442). No write tool ever opens a
38+
* `sys_*` object.
3439
* - The bridge is bound to the caller's principal; tools cannot widen it.
3540
* - Errors are returned as tool errors (text), never thrown across the wire,
3641
* and never include secrets.
@@ -144,6 +149,24 @@ export interface McpDataBridge {
144149
*/
145150
listObjectsDiagnosed?(): Promise<DiagnosedObjectListing<McpObjectSummary>>;
146151
describeObject(name: string): Promise<unknown | null>;
152+
/**
153+
* [#32442, ruling A] Has the system object `name` opted its records into the
154+
* AI READ tools? The bridge answers with `isAiReadExposed`
155+
* (`@objectstack/spec/data`), the ONE reading of `enable.aiReadable`, over
156+
* the object's whole served definition: the stored-metadata family answers
157+
* `false` before the key is read, and only the boolean `true` opens.
158+
*
159+
* The read tools (`list_objects`, `describe_object`, `query_records`,
160+
* `get_record`, `aggregate_records`) ask it only for a `sys_*` name their
161+
* fail-closed guard would otherwise refuse. An attested object is then read
162+
* exactly like a business object: AS the caller, under the caller's
163+
* permissions, row-level security, the object's own read gates and field
164+
* masking. It never opens a write: every write tool keeps refusing `sys_*`.
165+
*
166+
* OPTIONAL and fail-closed: a bridge that omits it, or whose answer throws,
167+
* keeps every system object refused, exactly as before.
168+
*/
169+
aiReadExposed?(name: string): Promise<boolean>;
147170
/**
148171
* [#28715] The fields of `name` that declare options — the fields a
149172
* formula's `label(record.<field>)` can answer on — or `null` when no such
@@ -494,6 +517,12 @@ function isSystemObject(name: string): boolean {
494517
return /^sys_/i.test(name);
495518
}
496519

520+
/** `items` kept where `keep` answers true, asked concurrently, in order. */
521+
async function filterAsync<T>(items: readonly T[], keep: (item: T) => Promise<boolean>): Promise<T[]> {
522+
const verdicts = await Promise.all(items.map(keep));
523+
return items.filter((_, i) => verdicts[i]);
524+
}
525+
497526
/**
498527
* [#27681] Whether the action tools may list a summary with `allowSystemObjects`
499528
* off: any action not on a `sys_*` object, and a `sys_*` one only when the
@@ -2283,6 +2312,30 @@ export function registerObjectTools(
22832312
}
22842313
return undefined;
22852314
};
2315+
/**
2316+
* [#32442] Does the bridge attest this system object's read opt-in
2317+
* ({@link McpDataBridge.aiReadExposed})? Fail-closed: no member, or a throw,
2318+
* is `false`.
2319+
*/
2320+
const attestsAiRead = async (objectName: string): Promise<boolean> => {
2321+
if (typeof bridge.aiReadExposed !== 'function') return false;
2322+
try {
2323+
return (await bridge.aiReadExposed(objectName)) === true;
2324+
} catch {
2325+
return false;
2326+
}
2327+
};
2328+
/**
2329+
* [#32442] The guard of the READ tools only (`describe_object`,
2330+
* `query_records`, `get_record`, `aggregate_records`): {@link guard}, except
2331+
* that a `sys_*` object the bridge attests as AI-readable is admitted. Every
2332+
* write tool keeps {@link guard}, so no declaration opens a system write.
2333+
*/
2334+
const readGuard = async (objectName: string): Promise<string | undefined> => {
2335+
const bad = guard(objectName);
2336+
if (bad === undefined || !isSystemObject(objectName)) return bad;
2337+
return (await attestsAiRead(objectName)) ? undefined : bad;
2338+
};
22862339

22872340
if (canRead) {
22882341
server.registerTool(
@@ -2321,9 +2374,11 @@ export function registerObjectTools(
23212374
const diagnosed = bridge.listObjectsDiagnosed
23222375
? await bridge.listObjectsDiagnosed()
23232376
: { objects: await bridge.listObjects(), degraded: false, errors: [] };
2377+
// [#32442] A system object is listed only where the bridge attests
2378+
// its read opt-in, the same admission `readGuard` makes.
23242379
const visible = allowSystem
23252380
? diagnosed.objects
2326-
: diagnosed.objects.filter((o) => !isSystemObject(o.name));
2381+
: await filterAsync(diagnosed.objects, async (o) => !isSystemObject(o.name) || await attestsAiRead(o.name));
23272382
if (!diagnosed.degraded) {
23282383
return textResult({ objects: visible, totalCount: visible.length });
23292384
}
@@ -2357,7 +2412,7 @@ export function registerObjectTools(
23572412
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
23582413
},
23592414
async ({ objectName }) => {
2360-
const bad = guard(objectName);
2415+
const bad = await readGuard(objectName);
23612416
if (bad) return errorResult(bad);
23622417
try {
23632418
const def = await bridge.describeObject(objectName);
@@ -2546,7 +2601,13 @@ export function registerObjectTools(
25462601
{
25472602
description:
25482603
'Query records from an object with optional filter, field selection, sorting and pagination. ' +
2549-
'Runs under the caller\'s permissions and row-level security.',
2604+
'Runs under the caller\'s permissions and row-level security. ' +
2605+
'A filter value "{current_user_id}" stands for you. ' +
2606+
// [#32442] The console's My Pending list, filter for filter: the
2607+
// participant read alone also serves requests the caller submitted
2608+
// or already decided, so an agent must not guess "mine" from it.
2609+
'For example, where the app runs approvals, the ones waiting on you: objectName "sys_approval_request", where ' +
2610+
'{"status":"pending","pending_approvers":{"$contains":"{current_user_id}"}}; decide one with run_action.',
25502611
inputSchema: strictToolInput(
25512612
{
25522613
surface: 'this query_records call',
@@ -2592,7 +2653,7 @@ export function registerObjectTools(
25922653
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
25932654
},
25942655
async ({ objectName, where, fields, limit, offset, orderBy }) => {
2595-
const bad = guard(objectName);
2656+
const bad = await readGuard(objectName);
25962657
if (bad) return errorResult(bad);
25972658
try {
25982659
const result = await bridge.query(objectName, {
@@ -2693,7 +2754,7 @@ export function registerObjectTools(
26932754
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
26942755
},
26952756
async ({ objectName, aggregations, groupBy, where, timezone }) => {
2696-
const bad = guard(objectName);
2757+
const bad = await readGuard(objectName);
26972758
if (bad) return errorResult(bad);
26982759
try {
26992760
const rows = (await aggregateFn(objectName, {
@@ -2731,7 +2792,7 @@ export function registerObjectTools(
27312792
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
27322793
},
27332794
async ({ objectName, recordId }) => {
2734-
const bad = guard(objectName);
2795+
const bad = await readGuard(objectName);
27352796
if (bad) return errorResult(bad);
27362797
try {
27372798
const record = await bridge.get(objectName, recordId);

0 commit comments

Comments
 (0)