Skip to content

feat(core): export the bounded document text extractor as @objectstack/core/document-text - #39016

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-10iivq
Dec 2, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-10iivq

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

Part of #39008 (this PR is its first acceptance item; the second, the cloud card that switches PDF input to the extracted text, is filed by the seat when this lands)

Clause-②: yes (widening)
Metadata-protocol: none

维护者速读

  • 用户无感:MCP 读文件工具的回答一字不变;平台多了一个公开入口,云端 AI 服务以后可以直接拿文档里的文字,不必再把 PDF 原文件交给模型。
  • 为云端 AI 读 PDF 解决:不支持 PDF 的模型那一轮报错、费用随页数涨,这是它的前置一步。
  • 出错会怎样:最坏是读 PDF、Word 的文字变慢或失败,读文件工具回一句读不了的说明;改动可整个撤回,无数据迁移。
  • 要你做什么:无。

What changes

The bounded document text extractor MCP read_file used (until now private to @objectstack/mcp) moves to @objectstack/core and is exported from a new Node-only subpath, @objectstack/core/document-text. The last public manifest of @objectstack/service-ai (npm 10.3.0) depends on @objectstack/core, formula, spec and types, never on @objectstack/mcp, so the AI service can use it without a new dependency (the cloud tree is not readable from here: the cloud follow-up card re-reads its manifest).

  • Home: a subpath like @objectstack/core/egress, kept off the main entry, so a host that never reads a document never loads unpdf. unpdf 1.9.1 moves from @objectstack/mcp dependencies to @objectstack/core (still a dynamic import on the first PDF; it stays an @objectstack/mcp devDependency for the suite's vi.mock('unpdf')).
  • Moved verbatim: the caps (100,000 characters, 200 PDF pages, 32 MiB inflated .docx body, 5 MiB image), the CPU budget per extraction and its wall-clock ceiling, the process-wide cap on extractions in flight and its refusal (ReadFileExtractionBusyError, 503, retryable), the worker pool and the worker entry (packages/mcp/src/file-extraction-{pool,worker}.ts → packages/core/src/document-text-{pool,worker}.ts, git renames; the extractor itself to packages/core/src/document-text-extract.ts). Names and the two host variables (OS_MCP_READ_FILE_*) are unchanged.
  • The public entry is curated: packages/core/src/document-text.ts re-exports exactly extractFileContent and ExtractedContent, ReadFileExtractionBusyError, the caps and bound constants (READ_FILE_*), resolveReadFileExtractionLimits / configureReadFileExtraction / activeReadFileExtractionLimits and ReadFileExtractionLimits, and configureExtractionWorkerEntry / ExtractionWorkerEntry. New beside the moved names: activeReadFileExtractionLimits() (the bounds now, failing on a malformed variable; renderReadFile calls it where it called the private one) and configureExtractionWorkerEntry, so a host that bundles core into one file can point the pool at the worker entry it ships. The rest (the document-only extractDocument, the worker protocol, the pool's stats and reset) stays internal.
  • One state per process, whatever the copy: the bounds, the count of extractions in flight and the pool live under a registered symbol on globalThis (packages/core/src/document-text-state.ts, key objectstack.core.documentText.state.v1, the pattern of security/credential-use-client.ts), so an ESM import and a CJS require of the subpath, or two installed versions, share one cap instead of admitting it once each. One fact stays per copy: whether a worker entry can be found beside that copy's own import.meta.url (the pool's unavailableReason), so a bundled copy that finds no worker never sends another copy, read_file's included, to the request thread; an idle worker serves any copy first. ReadFileExtractionBusyError answers instanceof for a refusal from any copy (a symbol brand). A worker thread has its own globalThis and counts nothing.
  • Buffer-safe hand-off to the worker: the pool copies the caller's bytes with new Uint8Array(bytes) instead of bytes.slice(). A Node Buffer is a Uint8Array whose slice is a view over the same memory: a small one sits in Node's shared pool, which cannot be transferred (DataCloneError, the read rejects), and a large one would have its memory detached from the caller. Today's read_file bridge hands a Uint8Array; a public caller would naturally hand a Buffer.
  • Build: packages/core/tsup.config.ts builds document-text as an entry and document-text-worker beside it in both formats, with shims: true so the CJS build's import.meta.url finds the worker (nothing else in core reads import.meta, __dirname or __filename). packages/mcp/tsup.config.ts drops its worker entry.
  • read_file: packages/mcp/src/file-content.ts keeps READ_FILE_MAX_BYTES, the file bridge types and renderReadFile, and imports the extractor; plugin.ts and mcp-http-tools.ts import configureReadFileExtraction / ReadFileExtractionBusyError from the subpath. One process, one pool and one count, whoever asks.
  • Docs: content/docs/ai/connect-mcp.mdx says the two bounds cover every caller in the process; the platform checklist item ai.mcp-read-file-pdf-word-extraction repoints its anchors (revision 4, no clause changed).
  • Test alias tables: every vitest config that maps @objectstack/core to its source by prefix now maps @objectstack/core/document-text first (mcp, runtime, metadata, driver-memory, driver-sql, knowledge-memory, knowledge-pgvector, knowledge-turso, plugin-dev, plugin-hono-server); check:test-source-alias found them, and runtime was a live ENOTDIR (its tests reach @objectstack/mcp).
Read first (by risk)
  1. packages/core/src/document-text-state.ts: the shared state and its key; the suffix must change whenever the state's shape or the worker protocol does.
  2. packages/core/tsup.config.ts: the worker entry and shims; a CJS build that cannot find the worker silently reads in-process (still bounded). shims changes no other entry: dist/logger.{js,cjs}, dist/index.js and dist/egress.cjs carry no shim, only dist/document-text.cjs does.
  3. packages/core/src/document-text-pool.ts: the worker URL is now ./document-text-worker.(c)js beside document-text.(c)js.
  4. packages/core/src/document-text.worker-pool.test.ts: the worker pins, moved from the MCP suite and re-asserted on the extractor's answer.

Tests

At b2b49cb9:

  • pnpm --filter @objectstack/core test: 161 files, 3,839 passed. pnpm --filter @objectstack/mcp exec vitest run: 89 files, 1,659 passed.
  • packages/runtime (at a48aefc4; nothing it reaches changed since) src/mcp-record-file-bridge.test.ts and src/domains/mcp-object-schema-mask.test.ts (after the alias fix): 2 files, 87 passed.
  • pnpm --filter @objectstack/core typecheck and pnpm --filter @objectstack/mcp typecheck: clean, test-typecheck ledgers held.
  • The ten worker-pool pins (read_file extracts PDF and Word text on a worker pool… and …stopped at its wall-clock ceiling before the first page…) moved from packages/mcp/src/mcp-file-tools.test.ts to packages/core/src/document-text.worker-pool.test.ts: same cases, same inputs, asserting the extractor's ExtractedContent (or its rejection) instead of the read_file blocks. How read_file renders each shape (facts, note, the coded busy refusal, the could-not-read sentence for a rejected read) stays pinned in-process in the MCP suite, which keeps its other 44 tests and automated.ref.
  • New: packages/core/src/document-text.shared-state.test.ts (5 tests) loads two module copies of the public entry and pins that bounds set through one bind the other, an extraction in flight through one is refused by the other at a cap of 1, and a refusal from either is instanceof both classes (and a look-alike error is not). With the state key swapped for a plain Symbol(), 3 of the first 4 fail. The fifth pins that one copy's "cannot start" is its own: a second copy looks for its own entry, and a copy that recorded one still takes an idle worker another copy started; with the verdict back in the shared state it fails. New in the worker suite: a pooled and a non-pooled Buffer each read on a worker and are left unchanged; with slice() restored it fails with DataCloneError.
  • Built-output smoke, one process loading both builds: import('@objectstack/core/document-text') and require('@objectstack/core/document-text') are distinct modules; bounds set through the ESM copy are what the CJS copy reads; with a cap of 1, a read held through the ESM copy makes the CJS copy refuse with SERVICE_UNAVAILABLE, instanceof both classes; each then reads a one-page PDF on a real worker with no fallback warning. The ESM export list is exactly the 15 curated runtime names (the three curated types beside them have no runtime form). @objectstack/mcp's built dist/index.{js,cjs} carries no copy of the extractor (getDocumentProxy 0 hits) and imports the subpath; core's main dist/index.js carries none either.

Gates

Local, re-run in full at e1cb87d2 after the review fixes: dispatch-gates --commands derived 127 commands over this change set; 126 green, including check:dual-build-cjs-loads, check:published-readme-exports, @objectstack/spec check:skill-examples, check:query-options-erasure, check:test-source-alias and check:platform-checklist (each unmeasured or red in the first round: the first four lacked a full build or were killed with the container, and the alias tables fixed the fifth). NOT MEASURED, prerequisite not met (exit 3): check-plugin-teardown-shape --self-test, whose fixture is pinned to a commit a shallow clone cannot reach; CI runs it. check-platform-checklist --changed-from origin/main: 30 anchors judged, 0 lost. After the S3 fix (b2b49cb9): core tests and typecheck, the MCP suite, check:test-source-alias and check-platform-checklist --changed-from origin/main re-run green, and the built ESM-plus-CJS smoke repeated. CI on b2b49cb9: 75 check-runs, 64 success and 11 skipped, none failed; mergeable state clean.

Acceptance notes

  • The Buffer hand-off fix changes one read_file answer: on a built worker, a Node Buffer small enough to sit in Node's shared pool used to fail the transfer and answer the could-not-read sentence; it now reads. The changeset names it.

  • Two installed versions of core with the same state key share idle workers too, so one version's job can run on the other's worker. The .v1 suffix guards the worker protocol; bumping it when the protocol changes is a comment in document-text-state.ts with no pin yet (contract review N4, accepted; a pin belongs on a follow-up card).

  • The extractor's kind: 'none' sentences were written for read_file: two name the tool and all say "Download it with the link instead". A caller that hands them to a model with no link (the cloud follow-up) should know; changing them changes read_file's answers, so they are left as they are. carrier: cloud (the follow-up card).

  • The constant names keep the READ_FILE_ prefix and the host variables keep OS_MCP_READ_FILE_*, now bounding every caller. Renaming them is a separate change through the deprecation helper, not this PR.

  • Two copies of @objectstack/core in one process (ESM and CJS, or two installed versions) now share one pool and one count, as long as they carry the same state key suffix.

  • One operator-visible change: the one-time warn when no worker can start now reads [document-text] PDF and Word text (read_file and every other caller) is extracted on the request thread, not on a worker: … (was [MCP] read_file extracts PDF and Word text on the request thread, not on a worker: …). The changeset and connect-mcp.mdx say so; a log alert on the old text needs the new one.

  • Found while smoking, not changed here (since mcp read_file: move PDF and Word text extraction off the request thread onto a worker pool (#31100 ruling B, phase 2) #31828, moved verbatim): a short-lived script that reads a PDF or Word file on a worker does not exit by itself afterwards, because the pool pipes each worker's stdout to the parent's stderr and a piped worker stream holds the event loop open even after worker.unref() (reproduced with a bare Worker; a data listener does the same). A server never notices; a CLI or batch script calling the extractor would. Follow-up card for the seat to file.

  • unpdf (2.1 MB unpacked, no dependencies) now installs with @objectstack/core. Every server install already had it through @objectstack/runtime → @objectstack/mcp.

Follow-ups

Verification

node -e "import('@objectstack/core/document-text').then(m => console.log(Object.keys(m).includes('extractFileContent')))" from packages/core after pnpm --filter @objectstack/core build: prints true.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WGufzegtzKWMxkohs9dHSd

…/core/document-text

The extractor read_file reads PDF and Word text with (its caps, the CPU
budget, the worker pool and the cap on reads in flight) moves out of
@objectstack/mcp into a Node-only subpath of @objectstack/core, so an AI
service can hand a model a document's text without depending on the MCP
package. read_file reads through it and answers exactly as before.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzegtzKWMxkohs9dHSd
…xtractor; changeset

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzegtzKWMxkohs9dHSd
…s the new document-text subpath first

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzegtzKWMxkohs9dHSd
@github-actions github-actions Bot added size/xl dependencies Pull requests that update a dependency file 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 Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 11 package(s): @objectstack/core, @objectstack/driver-memory, @objectstack/driver-sql, @objectstack/mcp, @objectstack/metadata, @objectstack/knowledge-memory, @objectstack/knowledge-pgvector, @objectstack/knowledge-turso, @objectstack/plugin-dev, @objectstack/plugin-hono-server, @objectstack/runtime, touching 105 documentable anchor(s). ⚠️ 15 changed file(s) yielded no anchor (packages/core/package.json, packages/drivers/driver-memory/vitest.config.ts, packages/drivers/driver-sql/vitest.config.ts, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

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

  • 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/knowledge-rag.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • 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/frontend/data-objectstack.mdx (via getPage (symbol, a method of interface PdfDocument))
  • content/docs/kernel/runtime-services/email-service.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/knowledge.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))
  • content/docs/ui/print-pages.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in ReadFileExtractionBusyError))

⛔ 6 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/v18/18-5.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
  • 15 changed file(s) yielded no anchor (packages/core/package.json, packages/drivers/driver-memory/vitest.config.ts, packages/drivers/driver-sql/vitest.config.ts, …) — pages documenting those are invisible to this run
  • 35 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 71 of 254 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 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; 124 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 — 77 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 2f9a68cfa184eaa7e77616df03654233ddd9f9f9 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 2f9a68cfa184eaa7e77616df03654233ddd9f9f9

⚠️ 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 2f9a68cfa184eaa7e77616df03654233ddd9f9f9 → 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

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzegtzKWMxkohs9dHSd

Contract review

Served-tier: TIER_DEFAULT
Head-sha: a48aefc42f0d585a3dc83c34d73bbf86e510d5ba
Local-runs: none

① Derived judgments

PR #39016, card #39008. Read: the card and its three comments, the PR body and its 26 files, the net diff origin/main...a48aefc4 (merge-base 571b4947), the tree at the head, and the head's check-runs. Nothing was built or run.

  • The move is verbatim: right. packages/core/src/document-text.ts against packages/mcp/src/file-content.ts on main differs only in comments, the pool import path, the rename of the private activeExtractionLimits to the exported activeReadFileExtractionLimits, and the re-export of four pool names. Caps, defaults, the two variable names, the withExtractionSlot logic, the PDF and Word extractors and every answer sentence are byte-identical.
  • read_file answers as before: right. renderReadFile in the head's packages/mcp/src/file-content.ts is the main body unchanged. The malformed-variable check is still its first statement, before the facts are built and outside the extractor's catch. The busy refusal is still rethrown by instanceof; file-content.ts and mcp-http-tools.ts take the class from the same external subpath, so one build format sees one class.
  • Worker entry in both formats: right on the read. packages/core/tsup.config.ts adds src/document-text-worker.ts to the JS half only (both formats, splitting: false, no declaration) and sets shims: true. The pool resolves ./document-text-worker plus the extension of its own import.meta.url, so .js beside document-text.js and .cjs beside document-text.cjs. This is the logic @objectstack/mcp shipped, with the file name changed. unpdf is a dependencies entry of core, so it stays external and resolves for the worker. Core's main entry does not import the module. The dev's built-output smoke is the only measurement of the CJS path; Build Core is pending.
  • Moved tests: faithful. All ten cases removed from packages/mcp/src/mcp-file-tools.test.ts (lines 964 to 1328 on main) are in packages/core/src/document-text.worker-pool.test.ts with the same inputs, budgets, pool-stat assertions and note strings, asserted on ExtractedContent or the rejection. The two renderings that only read_file owns stay pinned in the MCP suite: the coded 503 with details.retryAfterSeconds (line 873) and the could-not-read sentence for a rejected read (line 938). One shape change: the CONTROL case reads the PDF and the Word file with Promise.all where the original read them in turn; the assertions still hold.
  • Checklist and docs anchors: right. Every packages/mcp/src/file-content.ts# anchor left in docs/qa/platform-checklist/areas/ai.json names a symbol that stayed (renderReadFile, READ_FILE_MAX_BYTES); the repointed ones exist at the new path. No reference to the deleted file-extraction-* files remains outside a shipped CHANGELOG.

S1 (should-fix) — The single process-wide count is not single when the subpath is loaded in both formats. extractionsInFlight, extractionLimits and the pool's idle, started and entryOverride are module-level variables in document-text.ts and document-text-pool.ts. An ESM load and a CJS load of @objectstack/core/document-text in one process are two module instances, so two caps (8 in flight at the default), two pools, and two ReadFileExtractionBusyError classes. On main the extractor had one consumer; this PR publishes it for a second, which is what makes the case reachable. Core already treats this as real: packages/core/src/security/credential-use-client.ts holds its store under Symbol.for(...) on globalThis for exactly "an ESM and a CJS load of the same build". The changeset, the module jsdoc and content/docs/ai/connect-mcp.mdx all say the cap "holds whoever asks" without condition, and the PR's acceptance notes name only the two-versions case. Fix: hold the count, the limits and the pool state under a registered symbol on globalThis, as that file does, or state the condition wherever the claim is made.

S2 (should-fix) — The published surface is wider than the card asks and wider than the PR body lists. The public entry is the implementation module, so every name the worker and the tests import is now a semver-held export of @objectstack/core:

  • extractDocument runs an extraction outside the cap and the pool, on the caller's thread, under a CpuBudget the caller supplies. It is a published way around the bounds the card says to keep.
  • configureReadFileExtraction(limits) lets any importer replace the host's two bounds for the whole process.
  • resetExtractionWorkerPool and extractionWorkerPoolStats are test hooks; no file in the diff imports the first.
  • preloadPdfReader, stoppedExtractionAnswer, effectiveMimeType, resolveReadFileExtractionLimits and the types CpuBudget, ProgressSink, ExtractionProgress, DocumentKind are internals of the worker protocol.

The PR body's "New exports" names only activeReadFileExtractionLimits and three pool functions. Fix: keep the implementation in an internal module that the worker and the tests import, and make document-text.ts a curated re-export. The set the card needs is extractFileContent, ExtractedContent, ReadFileExtractionBusyError, the cap constants, the limits pair and configureExtractionWorkerEntry with its type. Narrowing it after a release is a breaking change; doing it now costs nothing.

N1 (nit) — The operator-visible fallback line changed from [MCP] read_file extracts PDF and Word text on the request thread… to [document-text] PDF and Word text (…) is extracted on the request thread…, and the two rejection messages from read_file extraction… to document extraction…. No tool answer changes and nothing in the repo matches on the old text, but the changeset's "answers exactly as before" does not mention the log line.

N2 (nit) — shims: true now applies to every core entry, including the browser-safe logger. The config comment says the other entries are untouched; that holds if esbuild drops the unused shim, which this read-only review cannot confirm. Build Core and the UI families are pending and will answer it.

② Semver level

  • @objectstack/core patch and @objectstack/mcp patch: right. AGENTS.md sets the level by the Metadata-protocol: kind alone; none takes patch, and a non-protocol widening ships patch.
  • Clause-②: yes (widening): right. A new exports subpath on a published package widens its accept set; nothing exports-addressable is removed. @objectstack/mcp loses only dist/file-extraction-worker.{js,cjs}, which no export addressed, and its unpdf dependency, which it now reaches through core.
  • Metadata-protocol: none: right. No spec file, schema or authorable key is in the diff.
  • Both declarations are line-initial in the PR body and in the changeset. Check Changeset is green.
  • Changeset text: accurate on caps, variables, defaults, the 503 and the bundled-host route. Its unconditional shared-count sentence is S1; it lists none of the extra exports in S2.

③ Boundary flags

  • open_questions: none in the dev report.
  • Dev flag, the kind: 'none' sentences name read_file and a download link (carrier: cloud): accepted as left. Changing them changes read_file's answers, which the claim forbids; the cloud follow-up card decides how to present them.
  • Dev flag, the READ_FILE_ and OS_MCP_READ_FILE_* names now bound every caller: accepted. A rename is a separate change through the deprecation helper.
  • Dev flag, two versions of core give two pools: true, and S1 is the wider form of it within one version.
  • Claim surface: the nine extra vitest configs were amended onto the claim in the report comment; each adds one alias line and nothing else.
  • SQL push-down: not applicable. The diff has no query, no id materialisation and no in-app join.
  • Author: the PR's user.login is objectstack-fleet[bot], so no off-relay note.
  • Check-runs on the head, at the time of this record. Green: Check Changeset, Governed Surface Queue Guard, PR-body guards, Validate Package Dependencies, every Lint · family, Lint & Repo Gates, Type Check · source gates, Type Check · debt ledger, Build Docs, Check Documentation Links, Live E2E UI. Pending: Build Core, Test Core (12 shards), Type Check · workspace, Type Check · consumer gates, Test UI (16 shards), Type Check UI, Lint UI, Build & E2E UI. This verdict is of the contract and does not stand in for the pending families.
  • Findings: no must-fix. S1 and S2 are open should-fix findings; the delta that closes them comes back to this reviewer before landing.

Implemented-by: claude/project-thread-10iivq
Reviewed-by: session_01WGufzegtzKWMxkohs9dHSd

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzegtzKWMxkohs9dHSd

The brief the card thread handed its isolated reviewer sub-agent (model run at the contract-review tier; the record's face is the Clause-②: yes declaration alone, so it reads TIER_DEFAULT). The record on this head is the comment beside this one.

Contract review brief — PR #39016 @ a48aefc42f0d585a3dc83c34d73bbf86e510d5ba (card #39008)

You review at TIER_DEFAULT. Render ONE ## Contract review record on this head — its shape is
node scripts/pm/record-recognisers.mjs --template --face declaration — with a PASS or FAIL verdict, and post it as ONE comment
on the PR or its card.

Inputs — these and nothing else:
· card #39008: its body and EVERY comment (rulings and earlier records included)
· PR #39016: its body, its file list, and the net diff against main at a48aefc42f0d585a3dc83c34d73bbf86e510d5ba
· the check-runs on a48aefc42f0d585a3dc83c34d73bbf86e510d5ba: their conclusions ARE the gate verdicts
⛔ Not the dispatch order, ⛔ not the dispatching seat's own conclusions — this brief is adversarial by design.

⛔ READ-ONLY. No worktree, no checkout, no build, no test run, no gate re-run, no ablation: the check-runs
on the head already answered every derived gate family, and a local run costs more than it returns.
If ONE probe is unavoidable, the record's Local-runs: line says probe — REASON; otherwise none.
Scratch space is /tmp/claude-0/-home-claude/4b91d9be-85ce-5be0-ad03-de8b9077052d/scratchpad/pr-39016/ alone; nothing there you did not write this round is read.

Judge, in the record's own sections:
① Derived judgments — every accept-set and public-surface change the diff implies, each named right or wrong.
② Semver level — the changeset (or skip-changeset) matches what the diff publishes, and the Clause-②: line.
③ Boundary flags — every dev flag and every open_questions entry answered, or escalated.
On every face, SQL push-down: a new id materialisation or in-app join where SQL could push down is a
finding unless a reason is given (AGENTS.md, Prime Directive 5: SQL first).
Sign Implemented-by: with the dev's branch and Reviewed-by: with your session id — the value is the FIRST
thing after each colon.

…y, Buffer-safe worker hand-off

Review findings on the pull request:

- S1: the bounds, the count of extractions in flight and the worker pool now
  live under a registered symbol on globalThis (document-text-state.ts), so an
  ESM import and a CJS require of @objectstack/core/document-text (or two
  installed versions) share one cap instead of one each; a busy refusal from
  any copy answers instanceof for every copy's class.
- S2: the implementation moves to document-text-extract.ts; document-text.ts
  is the curated public entry (the extractor, its caps and bounds, the busy
  refusal, configureExtractionWorkerEntry). Platform checklist anchors follow
  the declaring file.
- The worker hand-off copies the caller's bytes into a fresh Uint8Array
  instead of slice(): a Node Buffer's slice is a view over Node's shared,
  untransferable pool (DataCloneError) or over memory the transfer would
  detach from the caller.
- Changeset and connect-mcp say the one-time warn line changed.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzegtzKWMxkohs9dHSd
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzegtzKWMxkohs9dHSd

Contract review

Served-tier: TIER_DEFAULT
Head-sha: e1cb87d2768daec2e7fcdeafc57327403d9faffc
Local-runs: none

① Derived judgments

Delta read of PR #39016 (card #39008): a48aefc4..e1cb87d2, one commit, ten files. It follows the record on a48aefc42f0d585a3dc83c34d73bbf86e510d5ba by this reviewer. Nothing was built or run; the dev's test counts and built-output smoke are the dev's.

  • S1: closed. packages/core/src/document-text-state.ts holds limits, inFlight, entryOverride, unavailableReason, idle and started in one object under Symbol.for('objectstack.core.documentText.state.v1') on globalThis, the credential-use-client.ts pattern. No module-level state is left in document-text-extract.ts or document-text-pool.ts: every read and write of the old variables now goes through that object, and nothing else in the cap or pool logic changed. ReadFileExtractionBusyError sets a Symbol.for brand in its constructor and answers instanceof by it, so a refusal raised by one copy is recognised by another; renderReadFile and the MCP door keep working unchanged. document-text.shared-state.test.ts pins the four facts across two module copies: the copies are distinct, limits are shared, a slot held through one copy refuses the other, and the brand admits only real refusals.
  • S2: closed. document-text.ts is now a re-export of sixteen names: the nine READ_FILE_* constants, resolveReadFileExtractionLimits, configureReadFileExtraction, activeReadFileExtractionLimits, ReadFileExtractionBusyError, extractFileContent, the types ReadFileExtractionLimits and ExtractedContent, plus configureExtractionWorkerEntry and its entry type. extractDocument, preloadPdfReader, stoppedExtractionAnswer, effectiveMimeType, the worker-protocol types and the two pool test hooks are no longer reachable from the subpath. The worker and the core tests import the internal modules; @objectstack/mcp imports only curated names. configureReadFileExtraction(limits) stays public and can still replace the host's bounds for the process. That is accepted: the MCP plugin's boot call is that function, and with one shared state its effect is now the same for every copy.
  • Implementation move: right. document-text-extract.ts against document-text.ts at a48aefc4 differs only in the state references above, the brand, and the removed header and re-exports. Caps, sentences and extractors are unchanged.
  • Checklist anchors: right. The ai.json anchors name packages/core/src/document-text-extract.ts, where each cited symbol now lives.
  • N1: closed. The changeset names the old and the new warn line and says a log alert needs the new text; connect-mcp.mdx quotes the new line.
  • N2: closed on the dev's measurement. The dev reports that only dist/document-text.cjs carries the shim. Build Core is pending on this head.
  • Buffer hand-off: right. new Uint8Array(job.bytes) always allocates a fresh buffer, so the transfer can neither fail on Node's shared pool nor detach the caller's memory; slice() on a Buffer returns a view and could do both. The new pin covers a pooled Buffer and a view over a larger one, and checks the caller's bytes afterwards.

N3 (nit) — The Buffer fix changes what read_file answers on a built worker when the bridge hands it a Node Buffer: a small pooled one used to fail the transfer and answer the could-not-read sentence, and now reads. The changeset still says read_file "answers exactly as before" and does not name the fix. One sentence in the changeset would cover it.

N4 (nit) — Two installed versions of core now share the idle workers as well as the count, so a job from one version can run on a worker started from the other version's entry. The .v1 suffix is the guard, and bumping it when the state shape or the worker protocol changes is a comment, with no test that fails if someone forgets. Accepted as a deviation; a pin tying the suffix to the protocol types would belong on a follow-up card.

② Semver level

  • Unchanged from the first record: patch on @objectstack/core and @objectstack/mcp, Clause-②: yes (widening), Metadata-protocol: none. The delta narrows what the widening publishes; it removes nothing a release ever shipped.
  • The changeset now states the shared state across copies and the warn-line change. Its only gap is N3.

③ Boundary flags

  • Dev note, a piped worker stdout keeps a short-lived process alive after unref (present since mcp read_file: move PDF and Word text extraction off the request thread onto a worker pool (#31100 ruling B, phase 2) #31828, reproduced with a bare Worker): out of this PR's scope and unchanged by it. It goes to the follow-up card the dev names.
  • The earlier accepted flags stand: the kind: 'none' sentences and the READ_FILE_ names.
  • SQL push-down: not applicable; the delta has no query.
  • Author: objectstack-fleet[bot], no off-relay note.
  • Check-runs on this head, at the time of this record. Green: Governed Surface Queue Guard, PR-body guards, Validate Package Dependencies, Check Documentation Links, Spec property liveness, Dogfood Regression Gate. Pending: Build Core, Check Changeset, Build Docs, every Lint · family, the four Type Check · families, the test shard plans and Live E2E UI; the Test Core and UI shards have not started. This verdict is of the contract and does not stand in for them.
  • Findings: no must-fix, no should-fix. S1, S2, N1 and N2 are closed. N3 and N4 are nits and this is the final round.

Implemented-by: claude/project-thread-10iivq
Reviewed-by: session_01WGufzegtzKWMxkohs9dHSd

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract-review-claim: session_01WGufzhGA3zoCFquQgku4pm · head 7e4f966 · 2026-12-02T02:13Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 7e4f9664297a69d150eba7b9fbb5cd46d7bdb25e
Local-runs: none
Scope: packages/core/package.json, packages/core/src/document-text.ts, packages/core/src/document-text-extract.ts, packages/core/src/document-text-pool.ts, packages/core/src/document-text-state.ts, packages/core/src/document-text-worker.ts, packages/core/tsup.config.ts, packages/mcp/src/file-content.ts, packages/mcp/src/mcp-http-tools.ts, packages/mcp/src/plugin.ts, packages/mcp/package.json, packages/mcp/tsup.config.ts + none

PR #39016 for card #39008 (acceptance item 1). No path of the diff is on the governed register; the seat asked for a contract-tier read because the PR adds a public subpath to a published package, and the twelve files above are read as hits. The tests, the vitest alias lines, the checklist JSON, the docs page and the changeset were read only to judge them. Read: the card and its three comments, the PR body and comments, the net diff from merge-base 571b4947 to the head, the tree at the head, and the 66 green and 13 skipped check-runs on the head (none failed). The two earlier records on this PR were read and not relied on.

① Derived judgments

  • New public subpath @objectstack/core/document-text: right. packages/core/package.json adds one exports entry with import and require conditions, each with its own declaration file, in the shape of ./egress. It publishes 15 runtime names and 3 types.
  • Nothing public is removed: right. packages/mcp/src/index.ts exported none of the moved names on main, and @objectstack/mcp has a single . export, so the deleted dist/file-extraction-worker.{js,cjs} was never addressable.
  • unpdf moves from @objectstack/mcp dependencies to @objectstack/core dependencies: right. It stays external in core's build (a dependencies entry) and stays a dynamic import. @objectstack/mcp keeps it as a devDependency for its suite only; no non-test file under packages/mcp/src imports it.
  • The extractor is a verbatim move: right. A line diff of packages/mcp/src/file-content.ts at the merge-base against packages/core/src/document-text-extract.ts shows only: the header comment, two jsdoc lines, the three module variables replaced by fields of the shared state, the rename of the private activeExtractionLimits to the exported activeReadFileExtractionLimits, the instanceof brand, and the read_file-only parts that stayed behind. The pool and the worker are git renames whose code changes are the state fields, the worker file name, three message strings and the byte hand-off.
  • read_file answers as on main: right, with the one declared exception. renderReadFile at the head is the main body with the limits call renamed. The exception is the Buffer hand-off below, which the changeset names.
  • One operator-visible string changed: right, and declared. The one-time warn now opens [document-text] …; the two rejection messages say document extraction where they said read_file extraction. No tool answer carries them.

② Semver level

  • @objectstack/core patch and @objectstack/mcp patch: right. Metadata-protocol: none takes patch, and a non-protocol widening ships patch (AGENTS.md).
  • Clause-②: yes (widening): right. A new exports subpath widens what a consumer may import; nothing addressable is removed.
  • Metadata-protocol: none: right. No spec file, schema or authorable key is in the diff.
  • Both lines are line-initial in the PR body and in the changeset. Check Changeset is green on the head.
  • The changeset's account matches the tree on the caps, the two variables and their defaults, the 503 refusal, the shared state, the Buffer fix and the warn line. Its two loose sentences are N6 and S3 below.

③ Boundary flags

  • open_questions: none in the dev report.
  • Dev flag, the kind: 'none' sentences name read_file and a download link (carrier: cloud): accepted as left. Changing them changes read_file's answers. The cloud follow-up card decides how to present them.
  • Dev flag, the READ_FILE_ and OS_MCP_READ_FILE_* names now bound every caller: accepted. A rename is a separate change through the deprecation helper.
  • Dev flag, a piped worker stdout keeps a short-lived script alive after unref: true of main since mcp read_file: move PDF and Word text extraction off the request thread onto a worker pool (#31100 ruling B, phase 2) #31828 and unchanged here (worker.stdout.pipe(process.stderr) moved verbatim). It now reaches a public caller, so the follow-up card the dev names is owed when this lands.
  • Dev flag, unpdf now installs with every @objectstack/core consumer, including one that imports only /logger: accepted. undici already does the same for /egress.
  • Dev flag, two installed versions share idle workers under one .v1 key (the earlier N4): accepted as a deviation. The follow-up pin stands.
  • Claim surface: the nine extra vitest configs were amended onto the claim in the report comment. Each adds one alias line.
  • SQL push-down: not applicable. The diff has no query, no id materialisation and no in-app join.

④ Design judgment

(a) The main entry stays free of unpdf and worker_threads, in both formats: holds. Nothing under packages/core/src outside the five document-text* files imports any of them, so index, logger and egress cannot reach unpdf or node:worker_threads in either format (splitting: false, one bundle per entry). packages/core/tsup.config.ts adds document-text to the entries and the worker beside it for the JS half only, in both formats. shims: true applies to every entry of that half; no other core source reads import.meta, __dirname or __filename, so the injected shim has no user outside document-text.cjs. That the unused shim is dropped from the other bundles cannot be read off the tree. The gate families that would break are green on the head: Build Core, Build & E2E UI and Live E2E UI (which bundle /logger for a browser), and Type Check · consumer gates. packages/mcp, runtime and metadata-protocol already build with the same flag on main.

(b) One cap and one pool across copies, and instanceof across copies: holds. document-text-state.ts creates the state once under Symbol.for('objectstack.core.documentText.state.v1') with ??=, so a second copy adopts the first copy's object. document-text-extract.ts and document-text-pool.ts keep no module-level state of the cap, the bounds or the pool; the only module variable left is the unpdf import promise, which is a cache. The cap check and the increment in withExtractionSlot have no await between them, so two copies cannot both pass at the last slot. ReadFileExtractionBusyError carries a registered-symbol brand set in its constructor and answers Symbol.hasInstance by it, so both instanceof sites in @objectstack/mcp (file-content.ts:159, mcp-http-tools.ts:5632) recognise a refusal from any copy. A worker thread has its own globalThis and counts nothing. One field does not belong in the shared object:

S3 (should-fix) — unavailableReason is a fact about one copy and is stored for all of them. builtWorkerEntry() reads the calling copy's own import.meta.url, but its verdict is written to the shared state by markUnavailable, and runExtractionInWorker returns unavailable to every copy once it is set (document-text-pool.ts:129-138, :207). In a process where one copy cannot find its worker and another can (an AI service that bundled core into one file beside an @objectstack/mcp that loads core from node_modules, which is the two-consumer case this PR creates), the first PDF or Word read through the bundled copy that finds no idle worker moves every later extraction in the process to the request thread, read_file's included. The CPU budget and the cap still hold, so this is no must-fix. What is lost is the request thread staying free (ADR-0102 D1), which read_file had on main whatever else ran in the process, and the only signal is one warn naming the other copy's path. The changeset and the entry's jsdoc promise in-process extraction for "a host where the worker cannot start", not for a host where it can. Fix: keep the verdict of builtWorkerEntry() per copy (a module variable) and share only what is true of the process (the override, the idle list, the count); or leave it shared only when entryOverride produced it. A pin with two copies, one of which has no entry, would hold it.

(c) Every bound of read_file on main, sentence by sentence: holds.

  • 100,000 characters: bounded() cuts text, PDF and Word answers at READ_FILE_TEXT_MAX_CHARS; unchanged.
  • 200 PDF pages: Math.min(doc.numPages, READ_FILE_PDF_MAX_PAGES), and truncated when fewer pages were read; unchanged.
  • 32 MiB inflated Word body: inflateRawSync(..., { maxOutputLength }) plus the stored-entry length check; unchanged.
  • 5 MiB image: checked before the base64 encode; unchanged.
  • CPU budget: checked between pages (never before the first) and every 64 paragraphs; the worker uses its own thread's CPU time, the in-process path process CPU time; unchanged.
  • Wall ceiling: cpuBudgetMs * READ_FILE_WALL_CEILING_MULTIPLE, the worker terminated and never reused, the answer built from the progress it had sent; unchanged.
  • Concurrency and refusal never queued: refused synchronously before any worker is touched, the slot released in finally; unchanged, and now counted in the shared state.
  • Malformed variable: renderReadFile still calls the limits function first, outside the extractors' catch; the plugin's init still calls configureReadFileExtraction() with no argument at boot.

(d) The Buffer hand-off: holds. new Uint8Array(job.bytes) always allocates a fresh, exactly sized buffer, so the transfer list can neither name Node's shared pool nor detach the caller's memory. For the plain Uint8Array the bridge hands today it does what slice() did. The in-process path still reads the caller's bytes without moving them.

(e) The public surface: holds for a first consumer, with two notes. document-text.ts is a re-export and nothing else. extractDocument, the worker protocol types, preloadPdfReader, stoppedExtractionAnswer, effectiveMimeType and the pool's stats and reset are not reachable from the subpath. The shared state and the brand symbol are not exported.

N5 (nit) — Two knobs are wider than any consumer in the diff needs. configureReadFileExtraction(limits) takes an optional object that only tests pass (the plugin calls it bare), and it is not validated: the variable route rejects anything but a positive integer, while { maxConcurrent: NaN } through this argument leaves the cap off without a word. ExtractionWorkerEntry.execArgv exists for the suite's TypeScript loader. Both are semver-held from the first release. Accepted as a deviation; validating the argument belongs on a follow-up card.

N6 (nit) — The changeset says the extractor "keeps every bound read_file had". The 10 MiB input cap (READ_FILE_MAX_BYTES) is a bound read_file has and the extractor does not: it stays in @objectstack/mcp, and text and image inputs are decoded on the calling thread at whatever size they arrive. The entry's jsdoc says so; the changeset does not. The cloud card's own per-file cap (card acceptance 2) covers the first consumer. One sentence in the changeset would close it.

N7 (nit) — The changeset tells a bundling host to point the pool at "the worker entry it ships", but dist/document-text-worker.{js,cjs} is addressed by no exports entry, so a host can reach it only by file path. Shipping the file beside the bundle works without the call. A docs sentence, or a follow-up card if the entry should be addressable.

The MCP side: holds. file-content.ts keeps READ_FILE_MAX_BYTES, the bridge types and renderReadFile, and imports six curated names. mcp-http-tools.ts and plugin.ts each change one import. packages/mcp/tsup.config.ts drops the worker entry and keeps shims for package-version.ts. @objectstack/core was already a dependency of @objectstack/mcp, so the subpath stays external in its build.

S3 is the one open finding, and its fix comes back for a delta read. The three notes numbered N5 to N7 end with this round.

Implemented-by: claude/project-thread-10iivq
Reviewed-by: session_01WGufzhGA3zoCFquQgku4pm

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

L1 — PR #39016 @ 7e4f9664297a69d150eba7b9fbb5cd46d7bdb25e — must-fix: 1

Contract L2 at CONTRACT_REVIEW_TIER on this head: PASS with S3 (should-fix) open (comment 7332742169). The queue guard reads S3 as open, so this head does not land. The two earlier in-house records (a48aefc, e1cb87d) ran at TIER_DEFAULT and stand as dev-side reviews only.

Must-fix before landing

  1. S3 — unavailableReason lives in the process-wide shared state, but the fact it records is per copy: builtWorkerEntry() resolves against the calling copy's own import.meta.url, and markUnavailable writes the verdict for every copy (packages/core/src/document-text-pool.ts, markUnavailable / startWorker). I read it in the tree and agree: one read through a bundled copy that finds no worker moves every later extraction, read_file's included, onto the request thread. Fix: keep the "cannot start" verdict per copy (or share it only when entryOverride produced it), with a two-copy pin. Then a delta L2 at this tier naming S3: closed, and an L1 delta from me.

Optional, same push (prose faces, do not move the review of code)

  • N6: the changeset says the extractor "keeps every bound read_file had"; the 10 MiB input cap stays in @objectstack/mcp. One clause fixes it.
  • N7: the changeset tells a bundling host to point at "the worker entry it ships", but dist/document-text-worker.{js,cjs} has no exports entry. Say it is reached by file path, or leave as is.
  • N5 (test-only knobs configureReadFileExtraction(limits) and ExtractionWorkerEntry.execArgv on the public entry) is a nit; an accepted deviation is fine.

L1 reads on this head

  • Face: Part of #39008, no closing keyword; declarations Clause-②: yes (widening) · Metadata-protocol: none, right for a new subpath export; patch on core and mcp. Not governed (0 of 31 paths); 2826 changed lines, under 3000.
  • Changeset flag on nine packages (driver-memory, driver-sql, metadata, knowledge-memory, knowledge-pgvector, knowledge-turso, plugin-dev, plugin-hono-server, runtime): each is one vitest.config.ts alias line to core/src/document-text.ts; files[] is dist + README + CHANGELOG, so nothing ships. No entry owed.
  • Changeset read sentence by sentence against the tree: true, apart from N6 and N7 above. The renamed one-time warn is called out with old and new text.
  • content/docs/ai/connect-mcp.mdx: the added paragraph matches the pool's markUnavailable text and the shared cap.
  • Head commit 7e4f966 over e1cb87d is one changeset line (Buffer hand-off sentence).
  • Checks at 7e4f966: 67 success, expected skips only, Check Changeset pending at my read.

Landing rule B: Part of card #39008 keeps pm:dispatched after the merge.

The built worker entry is found beside each copy's own import.meta.url, so
whether it exists is a fact about that copy, not the process. The verdict now
lives in a module variable of document-text-pool.ts instead of the shared
state: a bundled copy that finds no worker no longer sends every other copy
(read_file's included) to the request thread. An idle worker serves any copy,
so it is taken before the copy's own verdict is consulted. Two-copy pin added.

The changeset says the input byte cap stays the caller's, and that the worker
file is addressed by path (no exports entry).

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzegtzKWMxkohs9dHSd
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract-review-claim: session_01WGufzhGA3zoCFquQgku4pm · head b2b49cb · 2026-12-02T02:54Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: b2b49cb98a8ade7562d94c760668fd1a487b655e
Local-runs: none
Scope: packages/core/package.json, packages/core/src/document-text.ts, packages/core/src/document-text-extract.ts, packages/core/src/document-text-pool.ts, packages/core/src/document-text-state.ts, packages/core/src/document-text-worker.ts, packages/core/tsup.config.ts, packages/mcp/src/file-content.ts, packages/mcp/src/mcp-http-tools.ts, packages/mcp/src/plugin.ts, packages/mcp/package.json, packages/mcp/tsup.config.ts + none

Delta read of PR #39016 (card #39008): 7e4f9664..b2b49cb9, one commit, four files (document-text-pool.ts, document-text-state.ts, the shared-state test, the changeset). It follows this reviewer's record on 7e4f9664297a69d150eba7b9fbb5cd46d7bdb25e. Of the twelve hits files only the pool and the state changed; the other ten are byte-identical to the head already judged. Nothing was built or run.

① Derived judgments

  • No public name added or removed: right. document-text.ts is untouched, so the subpath still publishes the same 15 runtime names and 3 types. unavailableReason was never exported.
  • The shared state loses one field: right. DocumentTextState now holds limits, inFlight, entryOverride, idle and started. The interface is internal and reachable from no export.
  • No bound moved: right. The delta touches neither document-text-extract.ts nor the cap check, the budget, the ceiling or any cap constant.

② Semver level

  • Unchanged: patch on @objectstack/core and @objectstack/mcp, Clause-②: yes (widening), Metadata-protocol: none. The delta publishes nothing new.
  • The two new changeset clauses are true of the tree.
    • The byte-cap clause: READ_FILE_MAX_BYTES stays in packages/mcp/src/file-content.ts, and extractFileContent decodes text at the size it is handed. An image over 5 MiB is refused before it is encoded, which the next bullet of the changeset already says.
    • The bundling clause: builtWorkerEntry() looks for document-text-worker plus the bundle's own extension beside the bundle's import.meta.url, the worker file has no exports entry, and configureExtractionWorkerEntry takes a path. The last sentence (a copy without a worker reads on the request thread, another copy keeps its workers, an idle worker serves any copy) is what runExtractionInWorker now does.

③ Boundary flags

  • open_questions: none.
  • N5 (the unvalidated limits argument and execArgv) is left as an accepted deviation by the dev: agreed. Validating the argument belongs on a follow-up card.
  • The earlier accepted flags stand: the kind: 'none' sentences, the READ_FILE_ names, the piped worker stdout, the install weight of unpdf, and the .v1 suffix with no pin.
  • SQL push-down: not applicable. The delta has no query.
  • Check-runs on this head at the time of this record: 65 success, 13 skipped, none failed. One Check Changeset run is still in progress; an earlier Check Changeset run on the same head is green. This verdict does not stand in for the run still open.

④ Design judgment

S3: closed

The fix, against the scenario it was raised on: holds. unavailableReason is a module variable of document-text-pool.ts, written only by that copy's markUnavailable and read only by that copy's runExtractionInWorker. A bundled copy that finds no entry beside itself no longer changes what a copy loaded from node_modules does: that copy reaches startWorker() with its own verdict unset and starts workers from its own entry. The bundled copy now pops an idle worker before it consults its own verdict, so it reads on a worker whenever one is idle and in-process only when none is. The cap is still enforced before this function is entered, so the idle-first order admits nothing extra. The fifth pin exercises exactly this with two module copies.

Does a reset leave another copy inconsistent: no. resetExtractionWorkerPool terminates the workers in the shared idle list and zeroes started. A worker running a job for another copy is not in the idle list, so it is not touched; it returns to the list when its job ends, as it did on main when a reset fell during a job. started is read only by the stats function, which only tests import. No copy holds a reference to an idle worker outside the list.

Is key .v1 safe with the field removed: yes. No build carrying the old shape was released: the field existed only on earlier heads of this PR. Two copies of this build create and read the same five fields. A later copy that met an object with an extra field would ignore it.

N8 (nit) — A copy's verdict can now outlive the entry it was reached on. entryOverride is shared, but configureExtractionWorkerEntry clears only the verdict of the copy it is called through. If one copy has already failed to start a worker and the entry is then changed through another copy, the first copy keeps its "cannot start" and reads in-process whenever no worker is idle, although the new entry would start for it. The jsdoc on configureExtractionWorkerEntry still says "a recorded cannot start is forgotten" without saying whose. A host sets the entry once at boot, before any read and through its own copy, so the order is not reached in a deployment and no bound is affected; the new pin's last step shows the shape. Accepted as a deviation. A shared reset counter that a copy compares its verdict against would close it on a follow-up card.

N9 (nit) — The changeset names the file to ship as document-text-worker.js (or .cjs). The pool looks for the bundle's own extension, so a bundle named .mjs needs the file renamed, and a CommonJS bundle whose bundler empties import.meta finds nothing beside it and needs configureExtractionWorkerEntry. The changeset's second route covers both. A sentence in the docs page would say so.

S3 is closed and this delta raises no finding above a nit. The notes numbered N5 to N9 end with this round.

Implemented-by: claude/project-thread-10iivq
Reviewed-by: session_01WGufzhGA3zoCFquQgku4pm

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

L1 delta · PR #39016 (#39008) · head b2b49cb · 2026-12-02T02:57Z

ACCEPT, on head b2b49cb98a8ade7562d94c760668fd1a487b655e. Must-fix 1 of L1 on 7e4f966 is closed.

  • Contract L2 delta at CONTRACT_REVIEW_TIER on this head: PASS, S3: closed, with N8 and N9 as nits only (comment 7333375139). No graded finding is open on this head.
  • The fix commit 7e4f9664..b2b49cb9 (4 files, +57/−10), read in the tree: unavailableReason moved out of the shared state into a module variable of document-text-pool.ts, so each copy keeps its own "cannot start" verdict. runExtractionInWorker takes an idle worker first and consults its own verdict only when none is idle. Reset clears only the caller's verdict. The fifth pin in document-text.shared-state.test.ts holds two copies apart: two warns, nothing inherited, and the idle worker is shared.
  • The .v1 key stays with a smaller shape. The removed field existed only on earlier heads of this PR, so no released build carries it.
  • Changeset read sentence by sentence: the N6 clause (the input byte cap stays the caller's, read_file keeps 10 MiB) and the N7 clause (the worker file is reached by path, with no exports entry) are true. N9's point about the bundle's own extension is a nit for a docs sentence later. N5 and N8 stand as accepted deviations.
  • Face: checks 66 success, 13 expected skips, 0 failed, 0 pending; mergeable_state clean. The changeset flag is the nine vitest.config.ts alias lines, which ship nothing (files[] is dist), as read on 7e4f966.

Landing rule B: Part of card #39008 keeps pm:dispatched after the merge. The seat files the cloud card for acceptance item 2 when this lands.

Next: landing.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhPdWmTd47Fi2bKYZS

席位核对

ACCEPT — PR #39016 @ b2b49cb98a (Part of #39008; card thread of seat os-support-ai).

  • Reviews adopted: contract review at CONTRACT_REVIEW_TIER, delta PASS 7333375139 with S3 closed; L1 ACCEPT 7333391105 on this head. The card thread's earlier two rounds at the default tier stand as dev-side reviews only.
  • What lands: the Node-only subpath @objectstack/core/document-text exports the bounded extractor (CPU budget, worker pool, 100k-character cap kept); unpdf moves to core's dependencies; a small Node Buffer no longer fails the worker hand-off. Clause-② yes (widening).
  • l1-face changeset flag, judged: the flagged driver, plugin, metadata and runtime packages are touched only in their vitest.config.ts (one line each, test config, not in any package's files), so nothing published moves there. The changeset names core and mcp.
  • Part of #39008: acceptance 2, the cloud AI service passing extracted text instead of the raw PDF, is asked of triage for objectstack-ai/cloud on pm:mailbox — triage#1 · os-warren #36743. Objectstack follow-ups are filed as Document text extractor follow-ups after #39008: worker pool keeps a short-lived process alive, state-key pin, three review nits (checklist) #39023 (the worker pool keeps a short-lived process alive, a state-key pin, nits N5, N8 and N9).

落地

reading value
check-governed-merges.mjs --pr 39016 NOT governed; 2,861 changed lines ≤ 3000
pr-state.mjs on b2b49cb9 66 success · 13 expected skip · 0 failed · 0 pending; mergeable_state clean
landing-k.mjs --pr 39016 K = 0 < 15
l1-face.mjs --pr 39016 one flag (changeset), judged above; every other leg ok

State change: ready for review + auto-merge, by the owning seat. #39008 stays open for its cloud acceptance.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review December 2, 2026 03:03
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit f28c39f Dec 2, 2026
84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants