Skip to content

Commit d06a9fc

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-oqumno
2 parents 6079316 + a4d8755 commit d06a9fc

16 files changed

Lines changed: 1236 additions & 28 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@objectstack/mcp': patch
3+
'@objectstack/runtime': patch
4+
'@objectstack/spec': patch
5+
---
6+
7+
fix(mcp, runtime)!: MCP describe_object answers the same field-masked object schema the /meta door answers (ADR-0106)
8+
9+
Clause-②: no (narrowing) — the MCP object-schema reads now serve a caller only the fields the `/meta` object door serves that caller, which ADR-0106 D1 ("a field the caller cannot read does not exist for that caller, on any plane") and the MCP security model ("field-level security applies to the agent exactly as it does to a person") already promise, so no stated contract is narrowed; what narrows is the answer to a caller with a `readable: false` field. Nothing is widened: no export, answer member, error code or status is added.
10+
Metadata-protocol: none
11+
Skills-docs: no move — `skills/**` teaches no field set for `describe_object`; `content/docs/ai/connect-mcp.mdx` states that schema discovery is covered by field-level security.
12+
13+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema, no export and no stored shape changes: the MCP tools answer a field-restricted caller the field set the metadata door already serves them, with a code and status already on the wire. There is nothing for a migration to rewrite and no tombstone. -->
14+
15+
**BREAKING** for a field-restricted caller of the MCP object-schema reads, on both transports (`/api/v1/mcp` and the stdio server).
16+
17+
- **Now.** `describe_object`, `list_objects`' `fieldCount`, the fields `validate_expression` puts in scope (and its `label()` option-field check) and, on the stdio server, the `objectstack://objects` resources serve each object through the ADR-0106 posture and projection the `/meta` doors run (`resolveObjectSchemaMaskPosture` → `relateObjectSchemaMaskPosture` → `applyObjectSchemaMask`, `@objectstack/metadata-core`), for the same caller: a field the caller cannot read is not listed, and the D4 exemptions, the D6 tiers and the D8 switch (`OS_ALLOW_UNMASKED_OBJECT_METADATA`) are the shared posture's. The HTTP bridge asks the `/meta` door's own masker (`resolveObjectMasker` / `maskObjectSchema`, `@objectstack/runtime`); the stdio bridge asks the host's `security` service about its API-key principal.
18+
- **Refusal.** Where the caller's field visibility cannot be evaluated, or the projection would leave the object with no field, the read is refused as the `/meta` door refuses it: `FIELD_VISIBILITY_UNRESOLVED` / 503, rendered as the tools' coded error (`{ error: { code, message, status } }`) and, on a stdio object resource, as `{ error, code, status }`. One object that cannot be projected refuses `list_objects`, as the `/meta` object list does.
19+
- **Unchanged.** A caller who may read every field, a D4-exempt caller and a deployment with no `security` service are answered byte for byte as before. The data verbs, their gates and `list_actions` / `run_action` are untouched. The stdio object reads now resolve the API-key principal on each call, as the data verbs already do, so a revoked key is refused there too.
20+
- **`@objectstack/mcp`** now depends on `@objectstack/metadata-core` at runtime (it was a dev dependency).
21+
- **`@objectstack/spec`**: the error-code ledger lists `FIELD_VISIBILITY_UNRESOLVED` under `@objectstack/runtime` and `@objectstack/mcp` as well, its two new emitters. The code itself was already registered.

‎.claude/skills/pm-dispatch/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ Seat: `domain:<x>#<n>` (the seat number this PM sits on; absent = seat 1)
310310
File surface: `<预期触碰的目录>` (stop on breach; explain in the report)
311311
Container & model: `<S 级机械卡 / M / L>`, `mode:subagent | mode:cloud | mode:thread`, `model: <档位词,引当次 --tier 输出;天花板拼 CONTRACT_REVIEW_TIER,同行引其 MANDATORY 路径行或 reason:(逐卡裁决,或常设档位令的 id 与时刻);⛔ 不抄模型 id>`, `effort: <medium | high | xhigh | max,按卡难度定>`
312312
Clause-②: yes | no
313-
Metadata-protocol: added | narrowed | semantic | none (the kind of change to what a metadata author can write; the level table is AGENTS.md's Post-Task Checklist step 3; the dev copies it beside `Clause-②:` into the PR body and every changeset body; a kind other than `none`, or a `(narrowing)` arm, owes the PR body a third line the dev writes from the diff: `Skills-docs: updated here | follow-up owed — FILES | follow-up #N | none — REASON`; `updated here` = this diff teaches it in `skills/**` or the docs and the package's evals exercise it; the seat files the owed card and rewrites `owed — FILES` to `#N` before ACCEPT)
313+
Metadata-protocol: added | narrowed | semantic | none (the kind of change to what a metadata author can write; the level table is AGENTS.md's Post-Task Checklist step 3; the dev copies it beside `Clause-②:` into the PR body and every changeset body; a kind other than `none`, or a `(narrowing)` arm, owes the PR body a third line the dev writes from the diff: `Skills-docs: updated here | follow-up owed — FILES | follow-up #N | none — REASON`; `updated here` = this diff teaches it in `skills/**` or the docs and the package's evals exercise it; the seat files the owed card and rewrites `owed — FILES` to `#N` before ACCEPT, through the PR-body line of `references/seat-post-protocol.md`, with no footer (`references/platform-readings.md`))
314314
Responsibility: `<whose code produces the risk, and the repo it lives in (objectstack ⇒ a platform card carries the fix, references/cross-repo-coordination.md rule 1) | the platform path that already covers it, or none | who reaches it, and whether anyone uses it today>` (defect cards and cards whose premise is a failing behaviour, else `n/a — not a defect card`; the dispatch prompt's ruling section repeats the three answers)
315315
Thread-read: <id of the newest comment on the card at the moment this claim is written, or none>
316316
Premise: holds | corrected <comment id> | inbox (the pre-dispatch premise reading, dispatch-runbook.md 派发前置)

‎.claude/skills/pm-dispatch/references/seat-post-protocol.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
- 可跑读法:本车道 `pm:dispatched` 卡按 `updated_at` 降序一搜,或读最近一条认领评论。
2929
- 写侧刷新三时刻:派发、收班、暂停或交接前;时间戳恒取自 `scripts/pm/post-stamped.mjs`。
3030
- 帖与卡正文首行恒为署名 `LANE#N · ACCOUNT · SESSION`;缺即写工具拒发(`post-stamped.mjs` 头注)。
31+
- PR 正文末非空行署 `<!-- signed: LANE#N · ACCOUNT · SESSION -->`,整篇经 `dispatch.mjs` 的 `issue_patch`。
3132
- 刷新前回执敲门;`--body` 拦截:评论晚于末次戳 ⇒ `--ack-through=ID`;空座欠账无卡号 ⇒ 拒写。
3233
- 耐久状态只住正文或以 App 写入;正文守中继上限 60,000 字节,超大贴由半状态巡查浮出。
3334
- 协议升级迁移状态、或巡检发现正文不符时,当场改正文 + 审计评论。
3435
- Routine 座位的收尾简报也落自己的座位贴,它是下一轮自退守卫的读数。
35-
- 收班默认交回(〈交接收尾清单〉第 2 步);留守只剩已 ACCEPT 待队列或待人批的 PR。
36-
- 留守写面 = 简报点名的这些 PR,残余定时器同界;留不了才热移交:收单注记 + 点名看护者。
36+
- 留守写面 = 简报点名的 PR,残余定时器同界;留不了才热移交:收单注记 + 点名看护者。
3737
- 收单注记写评审判据、落地步骤与当前状态;看护只守落地,⛔ 评审判断不可外包。
3838
- 看护者默认下任座位;在跑云会话经 poke 触发器投递,⛔ 非 `SendMessage` 直投。
3939
- 收班序列不看维护者措辞:`check-handover.mjs` 退出 0 → 刷正文与标题 → 简报最终一笔。

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,12 @@ drive this MCP server. Same word, different layer.
361361
- **Every call runs as the caller.** The MCP bridge resolves the same
362362
`ExecutionContext` as a REST request, so RBAC, row-level security, and
363363
field-level security apply to the agent exactly as they do to a person in
364-
the Console. Sparse results or denied writes usually mean governance is
365-
*working*, not that the connection is broken.
364+
the Console. Schema discovery is included: `describe_object`,
365+
`list_objects`' `fieldCount` and the fields `validate_expression` puts in
366+
scope name only the fields the caller can read, the same field set
367+
`GET /api/v1/meta/object/:name` serves that caller. Sparse results or denied
368+
writes usually mean governance is *working*, not that the connection is
369+
broken.
366370
- **OAuth scopes narrow the toolset.** Tokens carry `data:read`,
367371
`data:write`, and `actions:execute` scopes — tools outside the granted
368372
scopes are not even registered for that session. API-key and session

‎packages/mcp/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
"@modelcontextprotocol/sdk": "^1.30.1",
3131
"@objectstack/core": "workspace:*",
3232
"@objectstack/formula": "workspace:*",
33+
"@objectstack/metadata-core": "workspace:*",
3334
"@objectstack/spec": "workspace:*",
3435
"@objectstack/types": "workspace:*",
3536
"zod": "^4.6.6"
3637
},
3738
"devDependencies": {
3839
"@objectstack/lint": "workspace:*",
39-
"@objectstack/metadata-core": "workspace:*",
4040
"@types/node": "^26.6.5",
4141
"typescript": "^6.0.3",
4242
"vitest": "^4.1.11"

‎packages/mcp/src/mcp-server-runtime.ts‎

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,23 @@ export function setRuntimeObjectView(runtime: MCPServerRuntime, objects: McpObje
877877
runtimeObjectViews.set(runtime, objects);
878878
}
879879

880+
/**
881+
* [ADR-0106] A coded refusal an object view raised (a schema whose field
882+
* visibility could not be evaluated, refused by the stdio host's caller view),
883+
* in the `{ error, code, status }` vocabulary the object resources answer a
884+
* miss and an outage with; `undefined` for a throw with no code. `details` is
885+
* withheld, as on the data tools.
886+
*/
887+
function objectResourceRefusal(err: unknown): { error: string; code: string; status?: number } | undefined {
888+
const envelope = thrownRefusalEnvelope(err);
889+
if (!envelope) return undefined;
890+
return {
891+
error: envelope.message,
892+
code: envelope.code,
893+
...(envelope.status !== undefined ? { status: envelope.status } : {}),
894+
};
895+
}
896+
880897
/**
881898
* [#6055] Resolve the `objectstack://objects/{objectName}` answer for one call.
882899
*
@@ -906,7 +923,18 @@ export async function buildObjectSchemaResource(
906923

907924
// [#25245] The object from `objects` ({@link McpObjectView}); the verdict
908925
// on a miss is still the metadata service's.
909-
const objectDef = await objects.getObject(objectName);
926+
// [ADR-0106] A coded refusal from the view (the stdio host's caller view
927+
// refuses a schema whose field visibility it could not evaluate) answers
928+
// in this resource's `{ error, code, status }` vocabulary
929+
// ({@link objectResourceRefusal}); an uncoded throw travels, as before.
930+
let objectDef: unknown;
931+
try {
932+
objectDef = await objects.getObject(objectName);
933+
} catch (err) {
934+
const refusal = objectResourceRefusal(err);
935+
if (refusal) return body(refusal);
936+
throw err;
937+
}
910938

911939
if (!objectDef) {
912940
const { degraded, errors } = await diagnoseEmptyRead(metadataService, 'object', objectName);
@@ -997,7 +1025,17 @@ export async function buildObjectListResource(
9971025
): Promise<ObjectSchemaResourceResult> {
9981026
// [#25245] The items from `view` ({@link McpObjectView}); the verdict below
9991027
// is still the metadata service's.
1000-
const objects = await view.listObjects();
1028+
// [ADR-0106] …and a coded refusal from it answers as on the schema resource.
1029+
let objects: unknown[];
1030+
try {
1031+
objects = await view.listObjects();
1032+
} catch (err) {
1033+
const refusal = objectResourceRefusal(err);
1034+
if (!refusal) throw err;
1035+
return {
1036+
contents: [{ uri: 'objectstack://objects', mimeType: 'application/json', text: JSON.stringify(refusal) }],
1037+
};
1038+
}
10011039
const summary = ((objects ?? []) as ObjectDef[]).map(o => ({
10021040
name: o.name,
10031041
label: o.label ?? o.name,

‎packages/mcp/src/plugin.ts‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ import { MCPServerRuntime, setRuntimeObjectView } from './mcp-server-runtime.js'
3636
import { PACKAGE_VERSION, DEFAULT_SERVER_VERSION } from './package-version.js';
3737
import type { MCPServerRuntimeConfig, McpMergedMetadataRead } from './mcp-server-runtime.js';
3838
import type { ToolRegistry } from './types.js';
39+
import type { ObjectSchemaMaskSecuritySurface } from '@objectstack/metadata-core';
3940
import {
41+
callerObjectView,
4042
createStdioDataBridge,
4143
enforceApiExposure,
4244
GATED_ACTIONS,
@@ -458,6 +460,21 @@ export class MCPServerPlugin implements Plugin {
458460
return undefined;
459461
}
460462
};
463+
// [ADR-0106] The `security` service the object-schema mask asks for the
464+
// stdio principal's readable fields — resolved at each use, as the
465+
// protocol is, and `undefined` on a host that registers none (no
466+
// field-level posture there, so the schema is served as declared).
467+
const securityReads = (): ObjectSchemaMaskSecuritySurface | undefined => {
468+
try {
469+
return ctx.getService<ObjectSchemaMaskSecuritySurface>('security') ?? undefined;
470+
} catch {
471+
return undefined;
472+
}
473+
};
474+
// [ADR-0106 D1/D5] The stdio principal, once this transport has one: the
475+
// object resources below serve their schemas to it through the same mask
476+
// `list_objects` / `describe_object` do.
477+
let schemaPrincipal: (() => Promise<ExecutionContext>) | undefined;
461478

462479
// ── stdio auto-start decision (opt-in, its OWN switch) ──
463480
// Deliberately stricter than the HTTP-surface default (`isMcpServerEnabled`,
@@ -729,6 +746,7 @@ export class MCPServerPlugin implements Plugin {
729746
metadataService,
730747
protocol: protocolReads,
731748
resolvePrincipal,
749+
security: securityReads,
732750
keyedDigest: storedHashDigest,
733751
});
734752
} else {
@@ -791,6 +809,7 @@ export class MCPServerPlugin implements Plugin {
791809
storedHashDigest(),
792810
);
793811
};
812+
schemaPrincipal = resolvePrincipal;
794813
ctx.logger.info(
795814
`[MCP] stdio transport principal-bound to OS_MCP_STDIO_API_KEY identity ${initial.userId} (RLS/FLS/tenant applied)`,
796815
);
@@ -801,7 +820,17 @@ export class MCPServerPlugin implements Plugin {
801820
// `describe_object` answer from (`stdioObjectView`), never the metadata
802821
// service alone: on a kernel with an `environmentId` that service holds
803822
// no copy of an object a package registered during the boot.
804-
setRuntimeObjectView(this.runtime, stdioObjectView({ metadataService, protocol: protocolReads }));
823+
// [ADR-0106 D1/D5] …served to the stdio principal through the
824+
// object-schema mask (`callerObjectView`), the view the tools read, so
825+
// a resource never names a field the tools withhold. With no principal
826+
// (this process starts no stdio transport) the view is the bare one.
827+
const objectView = stdioObjectView({ metadataService, protocol: protocolReads });
828+
setRuntimeObjectView(
829+
this.runtime,
830+
schemaPrincipal
831+
? callerObjectView(objectView, { resolvePrincipal: schemaPrincipal, security: securityReads })
832+
: objectView,
833+
);
805834
this.runtime.bridgeResources(metadataService, getRecord);
806835
// Awaited: the prompt bridge reads `skill` metadata to project each
807836
// skill's instructions onto an MCP prompt (#3905), so the surface must be

0 commit comments

Comments
 (0)