Skip to content

feat(mcp): bound read_file PDF and Word extraction with a CPU-time budget and a concurrency cap - #31848

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/project-thread-z645c5
Nov 9, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/project-thread-z645c5

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread
Fixes #31826

Clause-②: yes — read_file gains a new truncated answer (out of CPU budget) and a new retryable refusal (over the concurrency cap) on a door that used to answer every file within its caps in full. Not (narrowing): no input it accepted is now refused for good; the refusal is transient and retryable, the truncated answer is the shape the door already serves at its length and page caps, and under the defaults every file within those caps reads as before (measured below).
Metadata-protocol: none

维护者速读

  • 改了什么:AI 助手用 read_file 读 PDF / Word 时,每个文件最多耗 2 秒 CPU(到点停,返回已读部分并提示下载);同一进程最多同时抽取 4 个,再来一个立刻回「稍后再试」。两个数都由宿主环境变量设置。
  • 为什么改:抽取在请求线程上同步跑,期间同进程所有别的请求都在等;共享云上一个租户连读大文件会拖慢所有人([Decision] read_file on a shared cloud: how PDF text extraction is bounded so one tenant cannot slow everyone #31100 裁定 B 第一期)。
  • 风险与回滚:默认值下实测的最重文件(9 MiB、200 页)仍完整读出,行为不变;只动 @objectstack/mcp,回滚即 revert 本 PR。
  • 先看:packages/mcp/src/file-content.ts 的 withExtractionSlot 与两处预算检查;mcp-http-tools.ts 的拒绝渲染;plugin.ts 的启动读取。
  • 两分钟验证:pnpm --filter @objectstack/mcp exec vitest run src/mcp-file-tools.test.ts,应见 28 个用例全绿,其中 7 个是新加的预算与并发用例。
  • 需要你做的:无,席位落地;合并后 cloud 车道在部署配置里设共享云的两个值。

What changes

packages/mcp/src/file-content.ts:

  • CPU-time budget per extraction (OS_MCP_READ_FILE_CPU_BUDGET_MS, default 2000). Process CPU time, read as process.cpuUsage() deltas from the extraction's start (ADR-0102 D1's dimension). PDF: checked between pages, never mid-page; the first page is always read. Word: checked between paragraphs of word/document.xml, every 64 paragraphs (the clock read stays a rounding error on a long body); the body's single inflateRawSync cannot stop part-way and stays bounded by the existing 32 MiB cap. Out of budget the answer is the text read so far, truncated: true, and a note: "Reading stopped at the CPU-time budget for one file (N ms) after page K of M, so the text is partial. Download the file with the link for the rest." No new answer key: truncated and note are the keys the length and page caps already use. No wall-clock ceiling was added (the ruling makes it optional; extraction does no I/O wait a wall bound would catch).
  • Process-wide concurrency cap (OS_MCP_READ_FILE_MAX_CONCURRENT, default 4) on PDF and Word extractions in flight; text files and images are not counted. A counter taken before the extraction's first await and released in finally. Over the cap the call is refused at once, never queued: ReadFileExtractionBusyError, code SERVICE_UNAVAILABLE, status 503, message "…Try again in about N seconds."
  • Both read once at boot: configureReadFileExtraction() is called from MCPServerPlugin.init (boot site: packages/mcp/src/plugin.ts). A value that is not a positive integer throws, naming the variable, so the boot fails (the reader follows @objectstack/types' query-read-limits.ts readLimitVar, the nearest loud OS_* numeric reader). A process that never calls it reads the host's values on its first read_file, outside the extractors' catch-all, so a malformed value still answers naming the variable.

packages/mcp/src/mcp-http-tools.ts: the read_file door renders the busy refusal through the same codedErrorResult the other coded refusals use, with details: { retryAfterSeconds } (the slot the runtime's inbound rate limiter carries the wait in; a tool result has no Retry-After header). Every other throw keeps errorResultWithCode.

content/docs/ai/connect-mcp.mdx: both variables, their defaults and why, under "Files: read_file and create_upload_link".

Why

#31100 ruling B (6708423049), phase 1. Phase 2 (extraction off the request thread, #31828) is not in this PR.

Tests

New top-level describe in packages/mcp/src/mcp-file-tools.test.ts (the file tools' shared harness), plus one boot pin in src/__tests__/plugin.test.ts. No existing test was edited.

  • the two variables: unset → defaults; ' 750 ' / '2' taken; 0, -5, 1.5, abc, 2s throw naming the variable.
  • CONTROL: under the defaults a 3-page PDF and a 2-paragraph .docx read in full, no truncated, no note.
  • PDF out of budget (a stepping CPU clock, 1 ms per read, budget 1 ms): page 1 only, truncated: true, the note verbatim, link present.
  • Word out of budget: 200 paragraphs, stops after 64, text equals the first 64.
  • Over the cap (2 held open by a pass-through unpdf mock): the door answers { code: 'SERVICE_UNAVAILABLE', status: 503, message, details: { retryAfterSeconds: 3 } }; a text file still reads; the held two finish and a slot is free again.
  • N run, the N+1th is refused (cap 3, four extractions); a .docx is refused the same way when the one slot is held.
  • an extraction that throws (the CPU clock throws at start) releases its slot: with cap 1, the next call reads.
  • plugin init with OS_MCP_READ_FILE_MAX_CONCURRENT=four rejects naming the variable and registers nothing.
Ablations (each mutation landed on disk via scripts/ablation-replace.mjs, test red, restored to HEAD blob)

Tests import ./file-content.js and ./mcp-http-tools.js from src (no dist leg).

# Mutation Red
A1 PDF budget check if (n > 1 && budget.spent()) → if (false) "a PDF out of CPU budget…" (reads all 3 pages) · 1 failed / 27
A2 Word budget check → if (false) "a Word document out of CPU budget…" · 1 failed / 27
A3 cap check if (extractionsInFlight >= limits.maxConcurrent) → if (false) "one extraction over the cap…" (the call queues behind the held two: timeout) and "N run, the N+1th is refused" (received { content }, expected the busy error) · 2 failed / 26
A4 release moved out of finally "an extraction that throws releases its slot" · 1 failed / 27
A5 door's busy branch → if (false) "one extraction over the cap…": details.retryAfterSeconds missing · 1 failed / 27

Every leg: ok mutation landed: anchor 1 -> 0, then ok restored: blob == HEAD and git diff HEAD is empty.

Measurement (card item 1): a 9.21 MiB, 200-page PDF, 2,250 path operators per page, 4-core container

Method from #31100: a 1 ms setInterval counted during extractFileContent, three runs after one warm-up.

Before, main 4ed20928:

run 1: cpu 646 ms · wall 469 ms · 1ms ticks fired 0 (missed ≈ 469)
run 2: cpu 470 ms · wall 425 ms · 1ms ticks fired 0 (missed ≈ 425)
run 3: cpu 316 ms · wall 309 ms · 1ms ticks fired 0 (missed ≈ 309)

After, bd107fb4, default budget (2000 ms): unchanged, the whole file read (8,290 chars, truncated: false):

run 1: cpu 694 ms · wall 525 ms · 1ms ticks fired 0
run 2: cpu 402 ms · wall 342 ms · 1ms ticks fired 0
run 3: cpu 286 ms · wall 279 ms · 1ms ticks fired 0

After, budget 100 ms: the hold is bounded by the budget.

run 1: cpu 106 ms · wall 50 ms · ticks fired 0 (missed ≈ 49) · truncated after page 6 of 200
run 2: cpu 103 ms · wall 36 ms · ticks fired 0 (missed ≈ 36) · truncated after page 6 of 200
run 3: cpu 101 ms · wall 78 ms · ticks fired 0 (missed ≈ 78) · truncated after page 35 of 200

Reading: the timer still never fires during an extraction (phase 1 bounds the hold, phase 2 removes it). Process CPU runs ahead of wall time because it also counts V8's helper threads, so the budget stops early, never late, as ADR-0102 D1 accepts.

Acceptance notes

  • Process CPU charges an extraction for anything interleaved with it (another extraction's microtasks, GC threads). The error direction is stopping early.
  • A between-pages macrotask yield would let other requests run between pages; it is not in this card (the ruling's phase 2 moves extraction off the thread) and is listed in the report's open questions.
  • The busy refusal's code is the standard SERVICE_UNAVAILABLE, not a registered extension code: registering one is a packages/spec ledger edit, outside this card's surface. Listed in the report's open questions.

Verification

Head 645f4183, after merging origin/main.

  • pnpm --filter @objectstack/mcp typecheck · exit 0
  • pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2 · Test Files 62 passed (62) · Tests 987 passed (987) · lock VERDICT command-exit 0
  • eslint --no-inline-config on packages/mcp · exit 0
  • node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack → 98 derived; --ran reconciliation: 97 run, 1 NOT-MEASURED, 0 UNRUN. 96 exit 0. Two not green locally, both prerequisites of the local build, both run by CI on this PR:
    • check:skill-examples · exit 3, PREREQUISITE NOT MET (reads built docs output this container did not build). NOT MEASURED locally.
    • check:dual-build-cjs-loads · exit 1, 122 findings, every one "declares types … which is NOT emitted": the workspace was built with OS_SKIP_DTS=1 here, so no package has declarations. Not about this diff (no exports map changes); CI builds with declarations.
    • check-plugin-teardown-shape --self-test and check:lean-entry-closure first answered exit 3 (fixture commit not fetched, objectql not built) and exit 0 after git fetch of the fixture and the build.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (no spec change)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: n/a.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English (the 维护者速读 section is Chinese by repo rule).

Generated by Claude Code

@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/mcp, touching 33 documentable anchor(s).

14 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/ai/actions-as-tools.mdx (via MCPServerPlugin (symbol, a top-level class))
  • content/docs/ai/connect-mcp.mdx (via OS_MCP_READ_FILE_CPU_BUDGET_MS (literal, a string literal in READ_FILE_CPU_BUDGET_MS_ENV), OS_MCP_READ_FILE_MAX_CONCURRENT (literal, a string literal in READ_FILE_MAX_CONCURRENT_ENV), SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • content/docs/ai/natural-language-queries.mdx (via MCPServerPlugin (symbol, a top-level class))
  • content/docs/api/client-sdk.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • content/docs/api/error-catalog.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • content/docs/api/index.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • content/docs/automation/webhooks.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • content/docs/deployment/self-hosting.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • content/docs/permissions/authentication.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • content/docs/permissions/authorization.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • content/docs/permissions/sharing-rules.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • content/docs/protocol/kernel/error-handling.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • content/docs/protocol/kernel/index.mdx (via MCPServerPlugin (symbol, a top-level class))
  • content/docs/ui/print-pages.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))

⛔ 5 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • content/docs/releases/v17/17-3.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • content/docs/releases/v17/17-4.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • content/docs/releases/v17/17-7.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • content/docs/releases/v18/18-2.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 6 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 231 client-bound route-ledger rows — the other 166 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 166: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 107 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 12 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 3487ccc12a6ad00dc75450f3f8b29a8a0630701d → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 430f835af1c33b97fda8e02228d4206841357f35 — the merge of head 645f4183ae460c1cddfb82cfc2b290ebd72c2699 into base 3487ccc12a6ad00dc75450f3f8b29a8a0630701d, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 430f835af1c33b97fda8e02228d4206841357f35 && git checkout 430f835af1c33b97fda8e02228d4206841357f35
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 3487ccc12a6ad00dc75450f3f8b29a8a0630701d 645f4183ae460c1cddfb82cfc2b290ebd72c2699 && git checkout -B drift-repro 3487ccc12a6ad00dc75450f3f8b29a8a0630701d && git merge --no-ff 645f4183ae460c1cddfb82cfc2b290ebd72c2699

node scripts/docs-audit/affected-docs.mjs --json 3487ccc12a6ad00dc75450f3f8b29a8a0630701d

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 3487ccc12a6ad00dc75450f3f8b29a8a0630701d → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#2 · os-steve · session_01ADHkmQKZzp4DLtqiCkZZRM

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 645f4183ae460c1cddfb82cfc2b290ebd72c2699
Local-runs: none

Inputs: card #31826 (body, the seat's delta, and ruling 6708423049 on #31100), PR #31848 body and file list, and the net diff of 645f4183 against main (7 files, +555/−20). Face: the Clause-②: yes declaration alone. No packages/spec/**, no governed path, no narrowing arm.

① Derived judgments

  1. New truncated answer on read_file. A PDF or .docx extraction that spends its CPU budget (OS_MCP_READ_FILE_CPU_BUDGET_MS, default 2000 ms, measured by process.cpuUsage() deltas) answers the text read so far, with truncated: true and a note naming the budget and the page or paragraph count, pointing at the download link the facts block already carries. The check is between PDF pages (the first page is always read) and every 64 .docx paragraphs, never mid-page. Right: the shape is the one the door already serves at its length and page caps, plus an optional note on ExtractedContent. Under the default, every file the measurement covered (a 9 MiB, 200-page drawing-heavy PDF at 316 to 646 ms) reads in full as before.
  2. New retryable refusal. Past OS_MCP_READ_FILE_MAX_CONCURRENT (default 4) PDF or Word extractions in flight, ReadFileExtractionBusyError refuses at once, never queued. The door renders it through codedErrorResult as SERVICE_UNAVAILABLE / 503, with details.retryAfterSeconds = ceil(budget / 1000). The slot is released in finally, and an ablation pins it. Right: an ADR-0112 standard code and the existing coded tool-error shape, with no new envelope. 503 and not 429, because the process is out of capacity and the caller's rate has nothing to do with it. Text files and images are not counted.
  3. Host configuration. Two OS_* variables are read once in MCPServerPlugin.init (configureReadFileExtraction). A value that is not a positive integer throws, naming the variable, and fails the boot. renderReadFile reads the limits outside the extractors' catch, so a malformed value can never read as "could not be read". Right: a typo cannot switch a bound off.
  4. Exports added to file-content.ts: the two env-name constants, their defaults, ReadFileExtractionLimits, resolveReadFileExtractionLimits, configureReadFileExtraction and ReadFileExtractionBusyError. renderReadFile now throws that one error. Its only caller is the read_file handler, which catches it. Right: all additive.

② Semver level

Clause-②: yes, with no arm and the reason written; Metadata-protocol: none; patch on @objectstack/mcp. Right: a non-protocol widening ships patch. It is not (narrowing): no input is refused for good, the refusal is transient, and the truncated answer reuses the existing shape.

③ Boundary flags

  • The env names, 503 over 429, the defaults, the Clause-② face and the between-page yield (left to phase 2) are ruled by the seat as the dev proposed.
  • Files outside the delta's surface: plugin.ts (the boot site, named in the PR) and the read_file catch in mcp-http-tools.ts (the door's rendering of the refusal). Both are accepted.
  • Gates the dev could not measure locally (check:skill-examples, check:dual-build-cjs-loads) are answered by the check-runs on this head.

Implemented-by: claude/project-thread-z645c5
Reviewed-by: session_01ADHkmQKZzp4DLtqiCkZZRM

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#2 · os-steve · session_01ADHkmQKZzp4DLtqiCkZZRM

维护者速读

  • 改了什么: MCP 的 read_file 读取 PDF 和 Word 文本时加了两道限制:每个文件有 CPU 时间预算(默认 2000 ms),超了就返回已读部分并标记 truncated、附下载链接;同时最多 4 个文件同时提取,再多立刻返回可重试的 503(带建议等待秒数),不排队。两个值由宿主环境变量设置,写错会在启动时报错。
  • 为什么改: 提取跑在请求线程上,一个画图密集的大 PDF 会让整个进程在几百毫秒内不响应别的请求(实测 9 MiB、200 页约 300–650 ms,期间 1 ms 定时器一次都没触发)。
  • 风险与回滚: 默认值下,实测范围内的文件读取结果不变。只有超长提取会被截断,或并发超过 4 时被要求重试。回滚即还原本 PR。
  • 先看: packages/mcp/src/file-content.ts 的 withExtractionSlot 和 startCpuBudget。
  • 需要你做的: 无,由席位落地。
  • 席位意见: ACCEPT。

席位核对 — ACCEPT · domain:server#2 · Head-sha 645f4183ae460c1cddfb82cfc2b290ebd72c2699 · 2026-11-09T07:23Z

  1. Shape: draft to main, Fixes #31826, Clause-②: yes, Metadata-protocol: none, with a patch changeset for @objectstack/mcp. The variables are documented in content/docs/ai/connect-mcp.mdx. 7 files, +555/−20.
  2. Contract review: TIER_DEFAULT, declaration face, PASS (6734311777).
  3. Delta rulings, checked against the diff:
    • Measured first on main, with the numbers before and after.
    • The CPU budget is read with process.cpuUsage(), between PDF pages (the first page is always read) and every 64 .docx paragraphs.
    • The cap is process-wide, refuses at once and is released in finally.
    • The refusal is ADR-0112 SERVICE_UNAVAILABLE through the existing coded tool error, with details.retryAfterSeconds; there is no new envelope.
    • The variables are read once at boot, and a malformed value fails the boot naming the variable.
    • CONTROLs: a small PDF and a small .docx still read in full.
  4. Open questions, ruled: the variable names, 503 over 429, the defaults 2000 ms and 4, and Clause-②: yes are all approved as proposed. The between-page yield is left to phase 2. plugin.ts (the boot site) and the read_file catch in mcp-http-tools.ts are accepted outside the named surface.
  5. Gates:
    • Dev: mcp 987/987; typecheck and eslint 0; 5 ablations went red and were restored. check:skill-examples and check:dual-build-cjs-loads could not be measured locally.
    • Check-runs on this head: 38 success, 14 skipped, 0 failed. They cover both gates the dev could not measure.
    • Governed surfaces: 0 of 7 paths on the register.
  6. Landing: pr_ready + automerge_enable.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 9, 2026 07:24
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 9, 2026 07:24
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit bd09b21 Nov 9, 2026
53 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-z645c5 branch November 9, 2026 07:53
rajeev-kumar-se pushed a commit to rajeev-kumar-se/objectstack that referenced this pull request Nov 10, 2026
…stry carries a native data tool name (objectstack-ai#31873)

<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9VBGAc66DtZYVbM24V9d2t2)_
Fixes objectstack-ai#31836

Clause-②: no
Metadata-protocol: none

## 维护者速读

- 改了什么:MCP 长连接服务器(stdio)上,AI 工具注册表和原生数据工具同名时只留原生数据工具,另一边跳过并记一行 debug 日志。
- 为什么改:企业版打开 stdio 后启动失败("Tool list_objects is already registered"),整个
MCP 插件回滚。
- 风险与回滚:只影响同名工具;不同名的注册表工具照旧桥接。HTTP 本来就只给原生工具,两边现在一致。回滚即撤本 PR。
- 先看:`packages/mcp/src/mcp-server-runtime.ts` 的 `yieldBridgedTool` 与
`bridgeDataTools`;`packages/mcp/src/mcp-stdio-tools.test.ts` 新增的 objectstack-ai#31836
用例。
- 两分钟验证:`pnpm --filter @objectstack/mcp exec vitest run
src/mcp-stdio-tools.test.ts`,预期 18 个全绿,其中 6 个 objectstack-ai#31836 用例在 main 上是红的。
- 需要你做的:无,席位落地。

## What changes

- `MCPServerRuntime` keeps the handles of the AI-registry tools
`bridgeTools` registered on the long-lived server, and the names
`bridgeDataTools` registered there.
- The rule, for a name both sources offer: the native data tool is
served, the registry tool of that name is not, and one `debug` line
names the tool and the source that was skipped. It sits in the runtime
where both registrations meet, so it gives the same answer in either
call order:
- registry first (the order `MCPServerPlugin.start` uses): each native
registration first removes a bridged tool of its name
(`yieldBridgedTool`, via the SDK's `RegisteredTool.remove()`);
  - data tools first: `bridgeTools` skips a name already native.
- `bridgeTools`' info line now counts the tools it actually bridged.
- `plugin.ts` is unchanged.

## Why

A licensed host's AI registry carries `list_objects` and data tools of
the same names as the native set. `bridgeDataTools` then hit the SDK's
duplicate refusal, and the plugin's boot rolled back.

Measurement (step 0, on `origin/main` 31ae944): HTTP `/api/v1/mcp`
builds each request's server from `wireBridgeTools(bridge)` plus the
host's authoring registry under `metadata:write`; it never bridges the
AI `ToolRegistry`. So HTTP has always served the native data tool under
these names, and stdio now serves the same one. No tool that a caller
could reach before is refused now: on the colliding host stdio never
booted, and on a host without a collision nothing changes. That is why
`Clause-②: no`.

## Tests

New top-level `describe` in `packages/mcp/src/mcp-stdio-tools.test.ts`
(real `StdioServerTransport`), plus one case in that file's existing
plugin-composition `describe` (the card's repro through
`MCPServerPlugin.start`). No existing test edited.

- tools/list names each tool once, registry bridged first.
- `list_objects` reaches the data bridge and not the registry; exactly
two debug lines, naming `list_objects` and `query_records`.
- Same answer with the data tools registered first.
- Over stdio, the `list_objects` entry equals the one HTTP lists for the
same bridge.
- CONTROL: a registry tool with no native namesake
(`summarize_pipeline`) is still listed and its call reaches the
registry.
- Plugin boot with an `ai` service whose `toolRegistry` carries the
colliding names.

## Acceptance notes

- Divergence left as it was (noted here, not filed): HTTP never exposes
AI-registry tools at all, while stdio exposes those with no native
namesake. This card only settles names both offer.
- A plugin's own tools registered on `mcp:ready` still meet the SDK's
duplicate refusal; this rule covers only the registry bridge and the
native data tools.

## Verification

Head: 0b9e56b (fix commit ed8186f; merge of `origin/main` 2e9121e
after objectstack-ai#31848 landed as ce22396; then 0b9e56b moves the new log
helper above the class's doc comment, a comment-position change only).

<details><summary>Red on main, green on the fix</summary>

On 31ae944, with the new pins only: `Tests 6 failed | 12 passed (18)`,
each `Error: Tool list_objects is already registered`. With the fix:
`Tests 18 passed (18)`.
</details>

<details><summary>Ablations (scripts/ablation-replace.mjs, restored blob
== HEAD, git diff HEAD empty)</summary>

- `yieldBridgedTool` made to return before removing (the skip dropped,
plugin order): 5 failed, each `Tool list_objects is already registered`;
the data-tools-first case stays green, as expected.
- `bridgeTools`' native-name skip disabled: 1 failed (`gives the same
answer when the data tools register first`), same error.
</details>

<details><summary>Package and gates</summary>

- `pnpm --filter @objectstack/mcp test`: 62 files, 994 tests passed on
0b9e56b (985 before the merge). `pnpm --filter @objectstack/mcp
typecheck` (tsc + check:test-typecheck): exit 0.
- `eslint --no-inline-config` on both touched source files: exit 0 (the
package has no `lint` script).
- `node scripts/pm/dispatch-gates.mjs --commands`: 64 families, run on
0b9e56b and before that on ce22396; all 64 exit 0 on both, `--ran`
reconciled: "64 run, 0 NOT-MEASURED". On the pre-merge head ed8186f the
same 64 ran with `check:dual-build-cjs-loads` NOT MEASURED (exit 3, no
full build then).
</details>

---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmSheMCfRrgSamoMm75)_

<!-- signed: domain:server#2 · os-steve ·
session_01ADHkmQKZzp4DLtqiCkZZRM -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
rajeev-kumar-se pushed a commit to rajeev-kumar-se/objectstack that referenced this pull request Nov 10, 2026
… and record-mode currency since 18.3.0 (objectstack-ai#32259)

<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBNP69gnL1YUb368kmLct4Bn)_

Fixes objectstack-ai#32020

Clause-②: no
Metadata-protocol: none

## 维护者速读

- 改了什么:给 18.4.0 发布测试台账补上 18.3.0 之后落地的三块能力的测试项:回收站(删除后撤销、恢复、清空、Setup
页面)、多币种记录模式金额(本币预览、Studio 本币字段编辑器、改指向货币字段时的 409 拒绝),以及 Redis
多副本部署的启动拒绝和运行期行为。共新增 16 条,并修正一条发票多币种条目。
- 为什么改:发布前的 `since:v18.4` 测试轮只能测台账里有的东西;这三块能力此前没有任何条目,测试员会漏测。
- 风险与回滚:只改 `docs/qa/platform-checklist/` 下的台账文件,没有产品代码、权限或数据语义变化,可直接
revert。
- 先看:`FOLLOW-UPS.md` 的 §17(范围、哪些条目被阻塞及原因),然后是 `areas/api-backend.json`
末尾两条回收站条目。
- 两分钟验证:`node scripts/check-platform-checklist.mjs`(exit 0);`node
scripts/checklist-select.mjs since:v18.4` 应列出 34 条,其中 10 条来自本 PR(9 条新增、1
条修订),另有 6 条多副本条目因缺少多节点授权门而标为 blocked,加 `--include-blocked` 后为 40 条。
- 需要你做的:无,席位落地。

## Premise

The card's premise command at the base (`43a51b55`, history deepened to
the 18.3.0 subject):

```
$ git -C . log --oneline 83d7e4a..origin/main | wc -l
1159
$ git -C . log --oneline 83d7e4a..origin/main | grep -iE 'replica|recycle|home amount|currency' | wc -l
51
```

Before this PR, the 24 items carrying `since: "v18.4"` were all M1's
(themes 1 and 3), so none covered themes 2, 4 or 5. FOLLOW-UPS §17
accounts for all 51 commits: 23 are covered by an item here, 10 are
docs, ADR, skills or test commits with no surface, 17 are outside the
card's named list, and one (objectstack-ai#31848) is a false match ("concurrency"
contains "currency").

## Theme 4: the recycle bin (4 items, all active)

- `api-backend.recycle-bin-delete-entry-restore` (P1): the delete
answer's `recycleBinEntryId`, the listing (cascade snapshot, deletedBy,
30-day retention, purgeAfter), the restore receipt under the original
ids, the second restore's 404, and a `sys_` delete that keeps no entry.
- `api-backend.recycle-bin-refusals-purge-empty` (P1):
`RESTORE_PARENT_IN_RECYCLE_BIN` (naming the parent's entry, then
restoring once it is restored), `RESTORE_PARENT_PURGED`, purge, empty,
the declared paging and parameter refusals, and the non-manager 403s
(via `search:qa-contributor-bound-member`) and the anonymous 401.
- `records-forms.delete-toast-undo-restore` (P1): the confirm question
without a permanence promise, the toast's Undo restoring through the
bin, the list-row Undo, the bulk toast with no Undo, and a
platform-object delete that still says it cannot be undone.
- `records-forms.setup-recycle-bin-page` (P2): Setup → Recycle bin's
object list, entries table, Restore and Empty with its confirm.
- Not driven live, recorded in knownGaps and FOLLOW-UPS §17b/§17c:
`RESTORE_UNIQUE_VALUE_TAKEN` (no showcase business object declares a
unique field), `RESTORE_PACKAGE_UNINSTALLED` (destructive to the boot),
and the own-entry half of the restore rule (no stock persona holds
`allowRestoreOwnDeleted` without `manageRecycleBin`). All three are
pinned by tests.

## Theme 5: record-mode currency (3 active, 1 planned, 1 revision)

- `records-forms.home-amount-preview-states` (P2): the preview's
converted, home-currency, awaiting-date and awaiting-rate states, and
the unreadable-rate message for a member who may not read
`sys_exchange_rate`.
- `studio-authoring.currency-home-amount-editor` (P2): which fields each
picker offers, the three saved pointers, a record stored through them,
and clearing them.
- `studio-authoring.currency-field-repointed-refusal` (P2): the 409
`DESTRUCTIVE_CHANGE` with the `currency_field_repointed` issue, its
remedies, `?force=true`, and an identical pointer raising nothing.
- Planned: `records-forms.master-detail-child-follows-parent-currency`
(`since: null`). The spec admits the `PARENT_FIELD.CODE_FIELD` path
(objectstack-ai#31956), but at the base the engine reads `currencyField` as a field of
the same row, so a path reads no code. The engine half is objectstack-ai#31911 (open).
FOLLOW-UPS §17a.
- Revision: `records-forms.multi-currency-invoice` rev 2. `since` goes
from `v18` to `v18.4`: the showcase invoice became the multi-currency
example in objectstack-ai#31757, and the hint and preview that `acceptance[5]` reads
landed in objectstack-ai#31638 and objectstack-ai#31724, all after 18.3.0. Its knownGaps[0] no
longer says a child amount cannot take its parent's currency. No clause
changed.

## Theme 2: multi-replica on Redis (8 items, all active, 6 blocked)

- Runnable now (both refuse before any gate or Redis is needed):
- `cli.serve-multi-replica-local-database-refusal` (P1): `os serve`
refuses a SQLite or file database under declared replicas on redis, exit
1, naming a shared Postgres, before anything connects.
- `cli.start-multi-replica-auth-secret-refusal` (P1): `os start` refuses
without `OS_AUTH_SECRET` and writes no `auth-secret` file; a memory
driver is not the declaration.
- `blocked: { by: "fixture" }`, each stating its two-replica fixture:
  - `attachments-storage.multi-replica-local-root-refusal`;
- `platform-core.multi-replica-package-change-refusal` (the seven
`/packages` doors, install-local both ways, and the clone that would
create a customization package);
  - `platform-core.ready-cluster-driver-health`;
  - `platform-core.cluster-membership-heartbeat`;
  - `platform-core.settings-change-reaches-every-replica`;
  - `platform-core.shared-redis-cache-across-replicas`.
- Why they are blocked: the open tree registers no multi-node gate.
`checkMultiNodeAllowed` fails closed with none registered, `os serve`
falls back to the in-process driver, and the split-brain guard refuses
the declared topology, so no declared multi-replica boot on Redis
reaches `kernel:ready` on a stock tree. The open-tree route the CLI pin
uses (an app whose own `@objectstack/service-cluster` calls
`registerMultiNodeGate`, `writeApp` in
`serve-multi-node-gate-declaration.integration.test.ts`) is unproven
with the real redis driver. The first run that proves it should become
an area recipe and lift `blocked` on all six. FOLLOW-UPS §17c.

## What changes

- 16 new items across `api-backend`, `records-forms`,
`studio-authoring`, `cli`, `attachments-storage` and `platform-core`,
each with `source[]` anchors that resolve and a history row citing
objectstack-ai#32020. One revision (`records-forms.multi-currency-invoice` rev 2).
- `coverage.json`: the recycle-bin items are mapped to `crud_endpoints`
(and the refusals item to `permission`); the currency items to `field`,
and the re-point refusal to `object` and `metadata_endpoints`; the
invoice item, never mapped before, to `field`. The six blocked theme-2
items are mapped nowhere: an item no run can drive does not carry a
kind.
- `FOLLOW-UPS.md` §17: scope and angles, the item list, 17a (planned,
carded), 17b (notes for owners), 17c (fixtures worth adding), 17d
(security note).

## Why

The 18.4.0 release run selects `since:v18.4`. Before this PR it held
nothing for the recycle bin, record-mode currency or multi-replica
deployments, which landed after 18.3.0 (epic objectstack-ai#32022, M2).

## Tests

No test code changed. Every clause is read from source at `43a51b55`
(the merge of `origin/main` at `036a9fbf` was re-checked by the gates
below), and each item's `automated.ref` names the pins that hold it
today. No live checklist run was made; that is the QA seat's
`since:v18.4` run on the release candidate.

## Acceptance notes

- **Read from source, not from titles.** Each assertion was read in the
code it cites (routes, refusal sentences, codes, constants). Two first
drafts were corrected against the code before commit: a storage settings
change to the local adapter under declared replicas is not refused at
the settings door but logged and not applied by the subscriber (§17b
records this as an owner note), and `/me/permissions` is served at
`/api/v1/auth/me/permissions`.
- **Blocked, not faked.** The order allows a multi-replica item without
a fixture only as `blocked` with its reason. The six items state the
fixture they need and the premise check (`[cluster] multi-node not
authorized (` absent from both boot logs) that proves it was met.
- **The doc-formula gate's first run exited 3** (nothing measured:
`@objectstack/formula` and `@objectstack/lint` were not built in this
fresh container). After `pnpm exec turbo run build
--filter=@objectstack/formula --filter=@objectstack/lint` it exited 0,
and that is the exit recorded below.
- **Shared files with objectstack-ai#32233** (open): `api-backend.json`,
`platform-core.json` and `records-forms.json`. This PR only appends
items at the end of each items array and revises the last item of
`records-forms.json`. The seat was told before the push; whichever lands
second merges main.
- No changeset: `docs/qa/` only, labelled `skip-changeset`.

## Verification

On head `a4eaf691` (this branch with `origin/main` at `036a9fbf` merged
in):

- `node scripts/check-platform-checklist.mjs` → exit 0 (16 areas, 402
items; coverage 40 kinds mapped, 4 waived; 10/10 recipes referenced, 17
item references resolved; symbol anchors 1397/1407 resolved, the other
10 on the named objectstack-ai#16898 residual).
- `node scripts/checklist-select.mjs since:v18.4 --json` → exit 0, 34
runnable items, 10 of them from this PR (9 new, plus the revised invoice
item): theme 4 × 4, theme 5 × 4 (3 new and the invoice revision), theme
2 × 2. With `--include-blocked`: 40 (the 6 blocked theme-2 items).
- `node scripts/pm/dispatch-gates.mjs --commands` → 16 commands, each
run with its exit recorded: 16 × exit 0 (see the doc-formula note
above). `--ran` on that record: `16 derived famil(ies) accounted for —
16 run, 0 NOT-MEASURED` (exit 0).
- Diff: 8 files, +1335 / -8 (1,343 changed lines, under 3,000).

## Human Minimum

Each item is one rule from
[CONTRIBUTING.md › Human
Minimum](https://github.com/objectstack-ai/objectstack/blob/main/CONTRIBUTING.md#human-minimum),
which links the AGENTS.md text that states it.

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(`packages/**` is untouched.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (No lintable source
changed: JSON and Markdown under `docs/qa/` only.)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset. (Nothing
publishes; labelled `skip-changeset`.)
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (Not touched.)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [ ] 8. Title, body and comments are in English. (All but the `##
维护者速读` block, which the order asks for in Chinese.)
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzhw1tf6sUQgFxnzeJy)_

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

1 participant