Skip to content

Document text extractor follow-ups after #39008: worker pool keeps a short-lived process alive, state-key pin, three review nits (checklist) #39023

Description

@objectstack-fleet

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

Filing gate: ② seat-filed, folded checklist card from card #39008 (PR #39016, @objectstack/core/document-text): the card thread's out-of-scope findings and the contract-tier review's accepted nits. Grading: area:ai · domain:services · p2 (item 1 is a measured defect; the rest are hardening) · reach: item 1 hits any CLI or batch script that reads a document through the extractor; a long-running server never notices. Each item can land on its own. Wait for PR #39016 to merge before starting. Not claimed.

1. The worker pool keeps a short-lived process alive after a document read

Pre-existing since #31828. The pool pipes each worker's stdout to stderr, and that pipe keeps the event loop busy after a worker read, even after the worker is unref'd. Reproduced by the card thread with a bare Worker. A server never notices it; a CLI command or batch script that reads one document does not exit on its own.
Done when: a process that reads one document through the extractor and does nothing else exits on its own, pinned by a test that spawns such a process and asserts it exits within a bound; the worker's output still reaches stderr.

2. A pin for the worker state key

The pool keys its shared state on documentText.state.v1 (contract review nit N4). Nothing fails if the worker protocol or the state shape changes without bumping that key, and a dual ESM/CJS load could then share an incompatible state.
Done when: a test fails when the worker message protocol or the state shape changes while the key stays documentText.state.v1.

3. Review nits accepted on PR #39016

  • N5: validate the limits argument (refuse a negative or non-finite cap instead of using it).
  • N8: the reset clears only the calling copy's verdict; make it clear the shared state, or document that it does not.
  • N9: one docs sentence on the bundle's file extension for the Node-only subpath.

Done when: each is fixed or recorded as not worth doing, with a reason, on this card.

Cloud side (not this card): switching the AI service's PDF input to extractFileContent is acceptance 2 of #39008, asked of triage for objectstack-ai/cloud.

Activity

  1. added
    bug
    priority:p2
    pm:queue
    area:ai
    domain:server
    on Dec 2, 2026
  2. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

    triage@os-warren · os-warren · session_01JQwxbZzZ2f5mzcvJbRrRNZ

    First touch · 2026-12-02T03:04Z

    定级(作者定的 p2 / area:ai 保留):area:ai · Bug · p2 · 经提取器读一份文档的 CLI 或批处理脚本不会自行退出 · 卡线程用裸 Worker 复现

  3. added
    pm:blocked
    and removed
    pm:queue
    on Dec 2, 2026
  4. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

    triage@os-warren · os-warren · session_01JQwxbZzZ2f5mzcvJbRrRNZ

    Unlock · 2026-12-02T04:06Z

    Blocked-by PR #39016 已于 2026-12-02T03:33Z 合并(main f28c39fe)→ pm:queue,分级不变(p2)。

  5. added
    pm:queue
    and removed
    pm:blocked
    on Dec 2, 2026
  6. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Claim: PM loop round 13 · 2026-12-02T06:58Z · zone osa-ai takes this card on the seat's word (2026-12-02T06:57Z: the #39008 card thread is closed, osa-ai takes it under the zone cap)
    Area: osa-ai
    Session: session_01WGufzeatqKfTRUzTJVa9jQ
    Account: os-support-ai
    Branch: claude/issue-39023-document-text-followups
    Worktree: objectstack-issue-39023
    Domain: domain:server
    Seat: repo:objectstack@os-support-ai
    File surface: packages/core/src/document-text.ts, packages/core/src/document-text-pool.ts, packages/core/src/document-text-state.ts, packages/core/src/document-text-worker.ts, packages/core/src/document-text-extract.ts (the limits validation only), packages/core/src/document-text.worker-pool.test.ts and packages/core/src/document-text.shared-state.test.ts where a pin reads a changed node, new test files named for 39023 under packages/core/src/ (and a fixture script for item 1's spawned process beside them), one sentence in packages/core/README.md or content/docs/ai/connect-mcp.mdx (the paragraph that already names @objectstack/core/document-text, ~line 490) for N9, .changeset/39023-document-text-followups.md. ⛔ Not packages/core/package.json exports, not packages/spec/**, not skills/**, not cloud (cloud#5354 carries #39008's acceptance 2). Stop on breach; explain in the report.
    Container & model: M, mode:subagent, model: default (dispatch-gates --tier: "no path-derived mandate … floor sonnet · default opus · ceiling fable"), effort: high
    Clause-②: no (no exported type or option widens; refusing an invalid limits value narrows only inputs that were already wrong — if the build changes an exported signature, the dev declares it)
    Metadata-protocol: none
    Responsibility: the document text extractor in objectstack (packages/core document-text worker pool: the worker's stdout pipe to stderr keeps the event loop alive after a read) | none | any CLI command or batch script that reads a document through the extractor does not exit on its own; a long-running server never notices
    Thread-read: 7334569022
    Premise: holds (item 1 reproduced by the #39008 card thread with a bare Worker; items 2–3 are the accepted nits of PR #39016's contract review)
    Scope: all three items of this card (each may land on its own; one PR is planned). Item 3's nits are each fixed or recorded on this card as not worth doing, with a reason.
    Serial constraints cleared: check-handover.mjs --inflight --card=39023: the one meet is #39008's claim 7330462633 on document-text.ts, -pool.ts and -worker.ts. Its only PR, #39016, merged 2026-12-02T03:33Z; the card stays open solely for its cloud acceptance (cloud#5354), no branch of it is live, and the seat ruled at 2026-12-02T06:57Z that this card is osa-ai's. The other unread claim, #38415, is a pm-dispatch skills card with no path here.

  7. added
    pm:dispatched
    and removed
    pm:queue
    on Dec 2, 2026
  8. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ
    os-dev-report

    {
      "issue": 39023,
      "status": "done",
      "branch": "claude/issue-39023-document-text-followups",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/39088",
      "session": "session_01WGufzeatqKfTRUzTJVa9jQ",
      "premise_still_valid": true,
      "summary": "All three items in one draft PR on head a1a47e236c. (1) The pool no longer reads a worker's stdout: once a pipe starts reading it, the parent-side ReadableWorkerStdio refs the worker's internal MessagePort until the stream ends at worker exit, which worker.unref() does not undo, so one idle worker held the process open. Workers now use Node's default stdio forwarding, which does not take that ref. The worker entry binds process.stdout.write to process.stderr.write and waits until the parent has taken what a job printed before it sends the answer. A busy server pool behaves as before: same start, reuse, ref per job and replacement, and output still goes to stderr. Two edges change, both documented: output a preload prints before the entry's body runs now goes to stdout, and an entry a host writes itself must redirect its own stdout. (2) DOCUMENT_TEXT_STATE_KEY is pinned to a SHA-256 of a structural text that the TypeScript checker derives from DocumentTextState, ExtractionWorkerRequest and ExtractionWorkerMessage, nested own types expanded and foreign types by name, against an append-only key/fingerprint ledger. A CONTROL shows three mutations each move it. (3) N5: configureReadFileExtraction refuses a bound that is not a positive whole number with a RangeError naming it, and the bounds in force stay. N8: fixed, not documented: a shared resets counter makes a reset through any copy forget every copy's cannot-start verdict, because entryOverride is shared. That bumped the key to .v2, which costs nothing while it is unreleased. N9: one sentence in connect-mcp.mdx on the worker file's extension and the configureExtractionWorkerEntry route. Design point N5: no exported signature changes, the function was never published (absent from @objectstack/core@19.0.0-next.3 exports and from both published @objectstack/mcp tarballs' d.ts), and every repo caller passes positive integers, so Clause-② stays no.",
      "tests": "On a1a47e236c. `pnpm --filter @objectstack/core exec vitest run --project local --maxWorkers=2`: Test Files 163 passed (163), Tests 3855 passed (3855), VERDICT command-exit 0. `pnpm --filter @objectstack/core typecheck`: exit 0, check:test-typecheck OK, 4 pinned signatures held. The new 39023 files ran three times: Tests 6 passed (6) each. Ablations, all through scripts/ablation-replace.mjs, each restored to the HEAD blob with git diff HEAD empty. These suites run the TS source (relative imports, the worker via tsx), so no build leg applies. (a) Pool back to stdout:true plus the pipe: the exit pin goes red with signal SIGTERM and status null (killed at the 15 s bound); restored blob f02a6e4d50ef. (b) Worker redirect deleted: the stderr pin goes red (stderr empty, marker on stdout); restored ef9dc5b0fcb1. (c) pool.resets++ deleted: the N8 pin goes red ({started:0,idle:0}); restored f02a6e4d50ef. (d) checkedLimits removed: all 8 N5 cases red; restored c3b661f26df5. Built smoke after `pnpm --filter @objectstack/core build`: dist/document-text.js (ESM import) and dist/document-text.cjs (require) each read one PDF on a worker (no fallback warn, stderr 0 bytes) and exit 0 within a second.",
      "gates": "Local: `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 101 families on a1a47e236c. All 101 ran in the foreground, each exit captured before any pipe; all exit 0. Six first exited 3 with PREREQUISITE NOT MET (lint check:doc-formula-expressions, check:doc-security-posture, spec check:skill-examples, check:docs-transcript-drift, check:dual-build-cjs-loads, check:lean-entry-closure); after `turbo run build` of the lint, objectql and client-react closures (all 47 tasks restored from the shared turbo cache) they reran green, e.g. `check:dual-build-cjs-loads — 128 published require entry point(s) across 75 package(s) load`. `--ran` with exit codes: `101 derived, 101 run, 0 NOT-MEASURED, 0 UNRUN` (a DERIVED zero). Also `eslint --no-inline-config` over the changed core files: exit 0. Not run locally: check-platform-checklist (no exported symbol removed or renamed; the only rename is a module-local let), test:repo (no repo-project test is touched). CI: when the snapshot was read, PR #39088's head had 27 check-runs, 7 completed/skipped and 20 in_progress, none concluded. Their conclusions are owed to the PM's CI read, not waited on here.",
      "mcp_calls": "0",
      "api_writes": "3 REST writes, each through the fleet-write relay (repository_dispatch): POST /repos/objectstack-ai/objectstack/pulls (pr_create, draft forced), POST /repos/objectstack-ai/objectstack/issues/39088/assignees (os-support-ai, the pr_create leg), POST /repos/objectstack-ai/objectstack/issues/39023/comments (this report, via post-stamped.mjs). Plus 2 git pushes, which are not REST: the dev-worktree.sh probe push of the empty branch, then a1a47e236c.",
      "classifier_refusals": [],
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [],
      "line_budget": "535 changed lines (+499/-36) over 11 files against the 3,000 human-merge line: under. No skills/** in the diff, so no skill byte readings are owed.",
      "files_changed": [
        ".changeset/39023-document-text-followups.md",
        "content/docs/ai/connect-mcp.mdx",
        "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/src/document-text.process-exit-39023.fixture.ts",
        "packages/core/src/document-text.process-exit-39023.test.ts",
        "packages/core/src/document-text.shared-state.test.ts",
        "packages/core/src/document-text.state-key-39023.test.ts",
        "packages/core/src/document-text.worker-pool.test.ts"
      ],
      "deviations": [
        "One local gate chunk (dispatch-gates lines 76-101) passed the container's 10-minute foreground cap and the harness moved it to the background. I stopped it with TaskStop, kept its 13 results recorded in the foreground (lines 76-88), and reran lines 89-101 in two foreground chunks. Every verdict cited comes from a foreground run.",
        "File surface: all 11 paths are inside the claim's fence. Two calls inside it, named here: the N5 and N8 pins are new top-level describes inside the two existing suites rather than in a new 39023 file, following AGENTS.md ruling record 6583487846 (a new pin for a component with a shared harness file goes into that file); the claim admits those files 'where a pin reads a changed node', and both pins read the changed nodes (configureReadFileExtraction, the reset). The internal state module also gained an exported DOCUMENT_TEXT_STATE_KEY const, not re-exported from the subpath.",
        "The new state-key test reaches the TypeScript compiler API, which @objectstack/core already lists as a devDependency. No package.json changed.",
        "@objectstack/mcp's mcp-file-tools.test.ts was attempted locally and failed at load: @objectstack/formula did not resolve because mcp's dependency closure was not built. Nothing was measured, so I record it NOT MEASURED and owe it to CI Test Core. The extractor's public signatures are unchanged and that suite passes only valid limits.",
        "PR body footer: AGENTS.md's session-URL footer form is used, placed just before the dispatch-mandated signed last line, in place of the harness reminder's robot-emoji footer."
      ]
    }
  9. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-support-ai · os-support-ai · session_01WGufzeatqKfTRUzTJVa9jQ
    os-dev-report

    Round 2 (L1 REWORK 7338980981, M1) on head 43b8807.

    {
      "issue": 39023,
      "status": "done",
      "branch": "claude/issue-39023-document-text-followups",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/39088",
      "session": "session_01WGufzeatqKfTRUzTJVa9jQ",
      "premise_still_valid": true,
      "summary": "Round 2 (L1 REWORK 7338980981, M1) on new head 43b8807e33, by the zone's route (a): behaviour kept, the claim made true. (1) The changeset no longer says every worker output goes to stderr. It says the worker entry's and the extraction's output does, and names two kinds that reach stdout: a Node -r/--import preload's own output, which a worker inherits and reruns before the entry each time it starts (for example node -r dotenv/config) and which corrupts a stdio-transport MCP stream; and a host-written entry. It gives the remedy: write to stderr, or skip the output off the main thread (isMainThread). (2) A comment at startWorker says the same, and why the preloads are kept (one may make modules resolve in the worker: Yarn PnP, a custom loader). (3) One paragraph in connect-mcp.mdx's Local stdio transport section. Route (b), stripping preloads, was not taken, as ordered. No code behaviour changed in this round. I reproduced the edge outside the repo on Node 22: a preload that prints only off the main thread landed on stdout, a main-thread-guarded one printed only at boot, and job output still reached stderr, exit 0. No pin was added (optional): pinning the edge would pin unwanted behaviour, and the job-output pin stands. CI on 43b8807e33 is CONVERGED GREEN.",
      "tests": "On 43b8807e33: `pnpm --filter @objectstack/core typecheck` passed (check:test-typecheck OK, 4 pinned signatures held), then the four document-text suites (process-exit-39023, state-key-39023, worker-pool, shared-state): Test Files 4 passed (4), Tests 32 passed (32), VERDICT command-exit 0. This round's diff is a code comment, the changeset and docs, so there is no behaviour to ablate. Round 1's ablations stand on the unchanged code. Edge repro (scratch, outside the repo): `node -r ./pre.cjs` with a worker using this PR's redirect and drain: stdout=[PRELOAD-IN-WORKER], 10 job lines on stderr, exit 0.",
      "gates": "Local, on 43b8807e33: dispatch-gates --commands derived the same 101 families as round 1. All 101 ran in the foreground with exit codes; all exit 0. check:dual-build-cjs-loads first exited 3 (34 packages had no dist in the fresh worktree) and passed after a time-bounded full `turbo run build --filter=!@objectstack/docs` (124 tasks, 88 cached): `128 published require entry point(s) across 75 package(s) load`. `--ran`: `101 derived, 101 run, 0 NOT-MEASURED, 0 UNRUN` (a DERIVED zero). CI on 43b8807e33, read 08:52Z: 74 check-runs, 62 success, 12 skipped, 0 failed, 0 pending: CONVERGED. The required families all succeeded: Lint & Repo Gates, TypeScript Type Check, Test Core and its 12 shards, Build Core, Governed Surface Queue Guard, Type Check UI, Test UI and its 16 shards, Build & E2E UI, Live E2E UI, Dogfood Regression Gate, Check Changeset, PR-body guards. Skipped: Lint UI, Temporal Conformance, the dogfood shard matrix. Test Core green settles round 1's NOT MEASURED mcp-file-tools.test.ts.",
      "mcp_calls": "0",
      "api_writes": "1 REST write this round, through the fleet-write relay: POST /repos/objectstack-ai/objectstack/issues/39023/comments (this round-2 report, via post-stamped.mjs). Plus 1 git push (not REST): a1a47e236c..43b8807e33. Round 1 total was 3.",
      "classifier_refusals": [],
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [],
      "line_budget": "Round 2 adds +21/-2 over 3 files (changeset, connect-mcp.mdx, document-text-pool.ts comment); PR total is about 556 changed lines over 11 files, under the 3,000 line. No skills/**.",
      "files_changed": [
        ".changeset/39023-document-text-followups.md",
        "content/docs/ai/connect-mcp.mdx",
        "packages/core/src/document-text-pool.ts"
      ],
      "deviations": [
        "PR body not edited, per the rule that a subagent writes the body only at pr_create. One body sentence is now stale for the seat to correct: its Design points bullet says the preload edge is documented by 'configureExtractionWorkerEntry's jsdoc and the changeset'. Since round 2 the preload edge is in the changeset, the startWorker comment and connect-mcp.mdx (the jsdoc covers only the host-entry edge). Its readings also still cite a1a47e236c; this report carries the 43b8807e33 readings.",
        "Worktree: round 1 had removed it. dev-worktree.sh then refused to rebuild it because my own local branch ref was still in the shared repo, at the same sha as origin (a1a47e236c). I attached a worktree to that branch with `git worktree add`, ran `pnpm install --frozen-lockfile` and pinned the base. No reset; HEAD equals origin.",
        "One gate chunk (lines 71-88) hit my own 570 s timeout after 84 results; check:registry-log-declared (line 85) was killed mid-run. I reran it alone (exit 0), then lines 86-101, all in the foreground. Nothing was moved to the background this round."
      ]
    }
  10. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Close-out · 2026-12-02T09:25Z · zone osa-ai

    • PR fix(core): document-text follow-ups: a script that reads a document exits on its own, limits validated, reset forgets every copy verdict #39088 merged 2026-12-02T09:25Z (merge commit 7341b89). Item 1: a process that reads one document through the extractor exits on its own (the pool no longer reads worker stdout; the worker entry redirects its stdout to stderr and drains before answering). Item 2: DOCUMENT_TEXT_STATE_KEY (now .v2) is pinned to a checker-derived fingerprint of the state and worker-protocol types. Item 3: N5 a bound that is not a positive whole number is refused with a RangeError; N8 a reset through any copy clears every copy's cannot-start verdict; N9 one sentence in connect-mcp.mdx. pm:dispatched and the zone's assignee are removed with this comment.
    • Edge documented, not changed: a Node -r/--import preload's own output inside a worker now reaches stdout (on a stdio-transport MCP host it can corrupt the stream); the remedy (write to stderr, or guard on isMainThread) is in the changeset, a startWorker comment and connect-mcp.mdx. Preloads are kept because one may be needed for module resolution in the worker.
  11. removed
    pm:dispatched
    on Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:aibugdomain:serverpriority:p2

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions