Skip to content

fix(mcp): a read_file stop before the first page or paragraph never calls its text partial - #35271

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-34855-ceiling-before-page1
Nov 19, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-34855-ceiling-before-page1

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Bill · project thread

Fixes #34855

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:MCP read_file 读 PDF / Word 时,如果在第 1 页(或第一批段落)读回来之前就被停下,回答仍是「没有内容」,但说明改为「在读到第 1 页之前就停了,没有拿到任何文字」;读过的页都没有文字时,说明改为「已读部分没有找到文字」。读到了文字的情况,说明不变(仍说「文字是部分的」)。
  • 为什么改:原来的说明写「在第 0 页后停下,所以文字是部分的」,实际一个字都没给;外部 agent 会照这句话以为拿到了部分文本。
  • 风险与回滚:只改一个文件里的说明文字和分支,不动数据、不动接口形状(content、truncated、note 字段不变);回滚即 revert 本 PR。
  • 先看:packages/mcp/src/file-content.ts(cpuBudgetNote 与 stoppedExtractionAnswer 的两个分支),packages/mcp/src/mcp-file-tools.test.ts 末尾新增的 describe。
  • 两分钟验证:pnpm --filter @objectstack/mcp exec vitest run src/mcp-file-tools.test.ts,预期 52 个测试全绿,其中新增的「before page 1 of 120 was read, so no text came back」那条通过。
  • 需要你做的:无,席位落地。

What changes

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

  • cpuBudgetNote now takes where the read stopped (after the pages or paragraphs read, or before the first one) and whether any text came back. It calls the text partial only when text came back.
  • stoppedExtractionAnswer (the wall-clock ceiling's overrun answer) branches on "no page / no paragraphs came back": a PDF says before page 1 of M was read, so no text came back (before page 1 was read when the PDF had not opened yet), a Word document says before the first paragraph was read, so no text came back. A stop after page 1 or later keeps the partial-text note.
  • pdfAnswer / docxAnswer build the note themselves, so a content: none answer can never carry the partial-text sentence. A stop after parts that held no text (a scanned PDF, blank paragraphs) now says after page P of M, and no text was found in what was read.

The second bullet is the card. The third is a bounded in-place fix of the same defect class in the same function family (same file, same gate families, no claim elsewhere on the file): before it, a budget stop on the in-process path after page 1 of an image-only PDF answered content: none with after page 1 of 3, so the text is partial. The new pin out of CPU budget after pages or paragraphs that held no text reproduces that answer on origin/main's logic (ablation A below).

Tests

All in the shared harness file packages/mcp/src/mcp-file-tools.test.ts:

  • New top-level describe read_file: a worker stopped at its wall-clock ceiling before the first page answers no text, never partial text. A stand-in worker sends back exactly the progress a test scripts (the real ExtractionProgress messages) and never answers, so the pool's own overrun path builds the answer and how far the read got is fixed by the script, not by machine load. The clock only decides when the read stops, never where. Pins: PDF opened then stopped before page 1, PDF stopped before it opened, Word stopped before its first paragraphs, and a CONTROL (stop after page 1, and after 64 paragraphs, keep truncated: true and the partial-text note).
  • In the CPU-budget describe, one new pin with the existing stepping CPU clock: an image-only PDF and a blank Word body stopped at the budget answer content: none with the no-text-found note.
Test runs at a94ee5a
pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2 src/mcp-file-tools.test.ts
 Test Files  1 passed (1)
      Tests  52 passed (52)
os-verify-lock: VERDICT command-exit 0

pnpm --filter @objectstack/mcp typecheck && pnpm --filter @objectstack/mcp test
 Test Files  77 passed (77)
      Tests  1404 passed (1404)
os-verify-lock: VERDICT command-exit 0
Ablations (fix committed first; each restore proven blob == HEAD, git diff HEAD empty)

The tests import ./file-content.js from source and the stand-in worker is a data: module, so no dist/ is involved.

A: return gotText replaced with return true (every stop calls its text partial). Expected red on the no-text pin only:

× out of CPU budget after pages or paragraphs that held no text: no text, and a note that never calls the text partial
Tests  1 failed | 51 passed (52)

B: pages.length === 0 and paragraphs === 0 made never true (the before-first branch gone). Expected red on the two before-first pins, CONTROL green:

× a PDF opened but stopped before page 1, and one stopped before it opened, answer no text and say so
-   "note": "... (100 ms) before page 1 of 120 was read, so no text came back. ..."
+   "note": "... (100 ms) after page 0 of 120, and no text was found in what was read. ..."
× a Word document stopped before its first paragraphs came back answers no text and says so
+   "note": "... (100 ms) after 0 paragraphs, and no text was found in what was read. ..."
Tests  2 failed | 50 passed (52)

A and B together are origin/main's behaviour.

Acceptance notes

  • The note still names the CPU-time budget when the wall-clock ceiling (5 budgets of real time) is what stopped the read. That shape is deliberate (stoppedExtractionAnswer answers "the same shape an extraction stopped at its budget answers") and is left as is.
  • The note text is not translated anywhere: it appears only in file-content.ts, its tests and the released CHANGELOG.md, so no i18n surface moves.

Verification

Derived gate families at a94ee5a (dispatch-gates --commands, 65 commands)

dispatch-gates --ran with recorded exit codes: 65 derived, 63 run, 2 NOT-MEASURED, 0 UNRUN. 63 exited 0.

  • NOT MEASURED: node scripts/check-plugin-teardown-shape.mjs --self-test, reason: PREREQUISITE NOT MET, the positive control is pinned to a commit a shallow checkout cannot reach (it grades the checker, not this diff).
  • NOT MEASURED: pnpm check:dual-build-cjs-loads, reason: PREREQUISITE NOT MET, it reads every package's dist/ and only the mcp closure was built here. CI runs it.

node scripts/pm/overlap-check.mjs --branch=HEAD: VERDICT clean exit 0 (merges cleanly with origin/main, 0 PR heads overlap).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7

…alls its text partial

A worker stopped at its wall-clock ceiling before page 1 answered no text
with a note saying it stopped "after page 0 ... so the text is partial";
a Word read stopped before its first paragraphs said the same with
"0 paragraphs". Such a stop now says the read stopped before page 1 (or
the first paragraph) was read and that no text came back, and a stop
after parts that held no text says no text was found. A stop that did
return text keeps the partial-text note.

Claude-Session: https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m 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 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

7 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 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; 123 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 f4dbcc2153566226f283c79c73255369c2c97587 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from e6cc60ff2bc7d4cfa65fdb1d82fc9f469de6df43 — the merge of head a94ee5a0fa4c04fa494c1b2e43e3d85380662b8e into base f4dbcc2153566226f283c79c73255369c2c97587, 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 e6cc60ff2bc7d4cfa65fdb1d82fc9f469de6df43 && git checkout e6cc60ff2bc7d4cfa65fdb1d82fc9f469de6df43
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin f4dbcc2153566226f283c79c73255369c2c97587 a94ee5a0fa4c04fa494c1b2e43e3d85380662b8e && git checkout -B drift-repro f4dbcc2153566226f283c79c73255369c2c97587 && git merge --no-ff a94ee5a0fa4c04fa494c1b2e43e3d85380662b8e

node scripts/docs-audit/affected-docs.mjs --json f4dbcc2153566226f283c79c73255369c2c97587

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4

维护者速读

  • 改了什么:MCP read_file 读 PDF / Word 时,如果在第 1 页(或第一批段落)读回之前就被停下,回答仍是「没有内容」,说明改为「在读到第 1 页之前就停了,没有拿到任何文字」;读过的页里都没有文字时(比如扫描件),说明改为「已读部分没有找到文字」。拿到了文字的情况说明不变。
  • 为什么改:原说明写「在第 0 页后停下,所以文字是部分的」,实际一个字都没给,外部 agent 会照这句话以为拿到了部分文本。
  • 风险与回滚:只改 file-content.ts 里的说明文字和分支,content、truncated、note 字段形状不变;回滚即 revert 本 PR。
  • 先看:packages/mcp/src/file-content.ts 的 cpuBudgetNote 与 stoppedExtractionAnswer;mcp-file-tools.test.ts 末尾新增的 describe。
  • 两分钟验证:pnpm --filter @objectstack/mcp exec vitest run src/mcp-file-tools.test.ts,52 个测试全绿。
  • 需要你做的:无,区内落地(非受管面、219 行)。L1 意见:卡内修复加同类缺陷的就地修复都有钉子和消融,可落。

席位核对 — ACCEPT (L1-a) · repo:objectstack#5 · head a94ee5a0fa4c04fa494c1b2e43e3d85380662b8e · 2026-11-19T01:32Z

  • 形态: draft → main, 3 files, +196/−23, 2 commits. Fixes #34855 on the first content line; no other card number beside a closing keyword. check-governed-merges --pr 35271: 0 of 3 paths governed, 219 lines ≤ 3000 → ordinary queue landing. Clause-②: no, Metadata-protocol: none. Card note "Lands after PR test(mcp): drive the worker CPU-budget case from a stepping thread clock #34853": test(mcp): drive the worker CPU-budget case from a stepping thread clock #34853 is merged.
  • Changeset: .changeset/34855-read-file-stop-before-page-1.md, patch for @objectstack/mcp (not private, published). Sentences read against the diff: the three new note texts (before page 1 of M was read, so no text came back, before page 1 was read, before the first paragraph was read) and the no-text-found text match cpuBudgetNote verbatim; "A stop that did return text keeps truncated: true and the note … so the text is partial" matches the gotText arm and the CONTROL pin. No content/docs/releases/ change, no unrelated file.
  • 差异由 L1 读过: cpuBudgetNote(stop, gotText) with a BudgetStop union (after | before); pdfAnswer / docxAnswer now build the note (false in the empty arm, true in the text arm), so a content: none answer cannot carry the partial sentence. stoppedExtractionAnswer picks before when pages.length === 0 / paragraphs === 0. L1 checked the Word edge: docxXmlText emits progress only after paragraphs++ on a closed paragraph, so paragraphs === 0 never arrives with text, and the in-process path sets outOfBudget only at a checkpoint (≥ 64 paragraphs) → before is reachable only from the ceiling path with no text, as intended.
  • 就地修复(范围外邻接)四条件: same defect class (a no-text answer saying "partial"), mechanical, same file and functions inside the claim's file surface (file-content.ts, claim 6995738937, so no claim revision needed), same gate family and test file; named in the PR body with its own pin and ablation A. Holds.
  • Pins: new top-level describe with a stand-in worker posting scripted ExtractionProgress and never answering: PDF opened then stopped, PDF stopped before open, Word stopped before paragraphs, CONTROL (after page 1, after 64 paragraphs keep truncated: true + partial note). In-process pin with the stepping CPU clock for an image-only PDF and a blank Word body. Ablations A (1 failed | 51 passed) and B (2 failed | 50 passed, CONTROL green) in the PR body, both restored blob == HEAD; A+B together = origin/main's behaviour.
  • 门禁: check-runs on head a94ee5a0: 37 success, 16 skipped (UI families, opt-in), 0 failure. Lint & Repo Gates, TypeScript Type Check, Test Core (10/10 shards), Build Core, Check Changeset, Type Check · debt ledger all success. Dev local NOT MEASURED x2 (check-plugin-teardown-shape --self-test, check:dual-build-cjs-loads): both are covered by CI's Lint families on this head, which are green.
  • 接受的偏差: (1) commit trailers model-free per AGENTS.md, not the dispatch text (correct direction); (2) PR body footer layout. Neither moves code.
  • 范围外去向: the ceiling note still names the CPU-time budget when wall-clock stopped the read: documented as deliberate in stoppedExtractionAnswer, listed in Acceptance notes, no card needed. docs/qa/platform-checklist/areas/ai.json item citing #stoppedExtractionAnswer describes the zero-page shape as "content 'none' … the budget sentence as the note": still true after this PR (the note is still the budget sentence, now without "partial"), so no checklist edit is owed.
  • Flake watch (not a REWORK reason): the stand-in-worker pins wait a real 500 ms ceiling; the scripted progress must arrive inside it. Worker start sits outside the ceiling (per test(mcp): drive the worker CPU-budget case from a stepping thread clock #34853), so the risk is low; if it ever reds on a loaded runner, the carrier is this test file.
  • 落地条款: K = 1 first-parent commit on main since merge base e8a78c4b (< 15), no new locale pack. Non-governed ⇒ ai-1 lands per landing-operations.md (pr_ready + auto-merge) after this ACCEPT; on MERGED, close-out on mcp read_file: when the worker ceiling cuts a read before page 1, the answer is content none with a note saying "after page 0 … so the text is partial" #34855.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CazXu8zyYD5PC6J2u7

Landing · ACCEPT (L1-a) → PR #35271 comment 6996919772 · head a94ee5a0 · 2026-11-19T01:33Z

Probe Reading
check-governed-merges --pr 35271 0 of 3 paths governed; 219 lines ≤ 3000 → ordinary queue landing
check-runs on a94ee5a0 37 success, 16 skipped, 0 failure; mergeable_state clean

Area ai-1 landing armed (ready + auto-merge); #34855 close-out on MERGED.

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/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants