Skip to content

mcp: the worker CPU-budget case in mcp-file-tools.test.ts depends on runner load and fails on unrelated PRs #34758

Closed

Description

@objectstack-fleet

repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA

Filing gate ①: a timing-dependent test that failed twice today on PRs that do not touch packages/mcp. Dedupe: mcp-file-tools; no open card.

Suggested-grade: p2 · domain:server (packages/mcp) · tooling

What happened

packages/mcp/src/mcp-file-tools.test.ts, case "out of CPU budget on the worker: the pages read so far, truncated, with the budget note, as in-process" (around line 950), failed in Test Core shard 3/8 on PR #34545 (run https://github.com/objectstack-ai/objectstack/actions/runs/44001704215; green on re-run) and again on PR #34719 at head 2a25dade9 today. Neither PR touches packages/mcp.

The case sets cpuBudgetMs: 30 on the extraction worker and asserts that the read stops partway with the budget note. A 30 ms CPU budget on a loaded CI runner makes the stop point, and whether the warm-up is charged, depend on runner load.

What is wanted

Make the case deterministic at the root: drive the budget from a controllable clock or a budget the fixture is sure to cross (and not cross on the warm read), so the assertion does not depend on runner load. ⛔ Not a skip, a retry wrapper or a looser assertion that stops pinning the truncation.

Re-check

git grep -n "cpuBudgetMs: 30" -- packages/mcp/src/mcp-file-tools.test.ts

Activity

  1. added
    bug
    finding
    on Nov 17, 2026
  2. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: first touch → p2 · domain:server · pm:queue · 2026-11-17T09:57Z

    ⛔ Not a claim.

    • Suggested grade p2 is accepted. Fleet-efficiency tooling: the worker CPU-budget case in packages/mcp/src/mcp-file-tools.test.ts depends on runner load, and it failed twice today on PRs that do not touch packages/mcp. Each failure costs a re-run or an ejection.
    • Domain: packages/mcp → domain:server.
    • Fix direction: make the budget deterministic in the test, for example an injected clock or budget, rather than racing real CPU. Never widen the budget or skip the case to get green.
    • The filing seat is winding down, so this is open to any repo-wide seat.
  3. added
    domain:server
    pm:queue
    priority:p2
    on Nov 17, 2026
  4. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C

    Claim: PM loop round 1
    Session: session_012MmDsS4GoHCgYwA2uv3n3C
    Account: os-lizheng
    Branch: claude/issue-34758-mcp-worker-cpu-budget
    Worktree: objectstack-issue-34758
    Domain: domain:server
    Seat: repo:objectstack#4
    File surface: packages/mcp/src/mcp-file-tools.test.ts, packages/mcp/src/file-extraction-worker.ts (a test seam for the CPU-time read only), packages/mcp/src/file-content.ts only if the seam is shared, .changeset/34758-*.md if a shipped file changes (stop on breach; explain in the report)
    Container & model: M, mode:subagent, model: default tier (dispatch-gates --tier: no path-derived mandate; a test seam design in a worker thread), effort: high
    Clause-②: no
    Metadata-protocol: none
    Responsibility: the worker CPU-budget case in packages/mcp (objectstack) races real thread CPU time on a shared runner | the in-process sibling cases already use a stepping fake clock (steppingCpuClock); the worker has no seam | every PR whose Test Core shard carries packages/mcp: two unrelated PRs failed on it on 2026-11-17
    Thread-read: 6944733782
    Premise: holds — read at 2026-11-17T12:51Z on origin/main c513d62: the case at mcp-file-tools.test.ts:942 sets cpuBudgetMs: 30 (:943) on heavyPdf(120, …) and asserts 1..119 pages; the worker reads process.threadCpuUsage() via startThreadCpuBudget (file-extraction-worker.ts:33-40, called :54); steppingCpuClock (test.ts:674) spies process.cpuUsage in the main thread and does not reach the worker thread.
    Serial constraints cleared: no open pm:dispatched claim names packages/mcp file tools at 2026-11-17T12:50Z.
    Pre-claim lane: packages/mcp/** → domain:server, repo:objectstack lane.
    Pre-claim deps: none.
    Prior rulings read: card's own fence (verbatim, triage 6944733782): "Never widen the budget or skip the case to get green."; filer's: "⛔ Not a skip, a retry wrapper or a looser assertion that stops pinning the truncation."

  5. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 17, 2026
  6. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C
    os-dev-report

    {
      "issue": 34758,
      "status": "done",
      "branch": "claude/issue-34758-mcp-worker-cpu-budget",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/34853",
      "session": "session_012MmDsS4GoHCgYwA2uv3n3C",
      "premise_still_valid": true,
      "summary": "The worker CPU-budget case in packages/mcp/src/mcp-file-tools.test.ts is now deterministic, through a test-only seam that crosses the thread boundary. The case starts its worker with a data-URL --import preload that replaces process.threadCpuUsage INSIDE the worker thread with a stepping clock (the worker twin of steppingCpuClock), so file-extraction-worker.ts is unchanged and no shipped file changes. The case pins exact stop points: page 3 of 120 for the PDF (budget 3000 ms, step 1000), and 12800 Word paragraphs (step 15), which is past the 100,000-char cap, so the cap pin now bites. PM mechanism assumption partly FALSIFIED: the measured red is not the CPU race but the pool's WALL-CLOCK ceiling (5 x 30 ms = 150 ms of real time) cutting the read before page 1. An instrumented run under load printed content none with 'Reading stopped at the CPU-time budget for one file (30 ms) after page 0 of 120'. That is why the budget value is 3000 ms (real-time ceiling 15 s) and not 30: a stepping clock at 30 ms would leave the ceiling race in place. This departs from the letter of the ruling area's 'never widen the budget', though not its intent; see open_questions. Truncation is pinned exactly, and the ablation shows the case goes red without the clock.",
      "tests": "pnpm --filter @objectstack/mcp test at a5821d88e9 (verify lock): 'Test Files 68 passed (68) / Tests 1237 passed (1237)', VERDICT command-exit 0. pnpm --filter @objectstack/mcp typecheck: exit 0, check:test-typecheck OK (6 files / 53 errors / 8 signatures held, ledger unchanged). STRESS (32 'node -e for(;;){}' loops on a 4-core box, case run alone with -t): origin/main dfbc316dfe original case pass=1 fail=5 of 6, each failure the CI shape (content 'none' where 'text' was expected); branch 53d7c7f385 pass=12 fail=0 of 12; with 8 loops the original passed 8/8. ABLATION (scripts/ablation-replace.mjs, the helper's execArgv line without the clock --import): 'mutation landed: anchor 1 -> 0, blob 58c2867c7929 -> 98321a40db56' -> 'Tests 1 failed' (note '...after page 3 of 120...' and truncated:true missing: the real clock reads all 120 pages) -> 'restored: blob == HEAD (58c2867c7929) and git diff HEAD is empty'. There is no dist leg: vitest and the tsx-loaded worker both run from source. CONTROL: git diff origin/main on file-extraction-worker.ts, file-content.ts and file-extraction-pool.ts is empty; the rest of the worker describe block runs on the real thread clock.",
      "gates": "Local subset at a5821d88e9, derived by 'dispatch-gates --commands --repo objectstack-ai/objectstack' (50 families). 49 ran with exit 0 (exit captured before any pipe). pnpm check:dual-build-cjs-loads exited 3 with 'PREREQUISITE NOT MET ... some package has no dist/' and is NOT MEASURED: a declared narrowing, because a full repo build was not run for a test-only diff; CI Lint & Repo Gates runs it. '--ran' reconciliation: '50 derived, 49 run, 0 NOT-MEASURED, 1 UNRUN' (that one). overlap-check: 'VERDICT clean exit 0'. CI check-runs on PR #34853: in_progress at report time; the seat reads convergence.",
      "dogfood_battery": "n/a — no '!' in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "2 relay dispatches (POST /repos/objectstack-ai/objectstack/dispatches). The relay executed: POST /repos/objectstack-ai/objectstack/pulls (#34853, draft), POST /issues/34853/assignees (os-lizheng), POST /issues/34853/labels (skip-changeset), POST /issues/34758/comments (this report)",
      "files_changed": [
        "packages/mcp/src/mcp-file-tools.test.ts"
      ],
      "deviations": [
        "File surface narrower than the claim: no seam in file-extraction-worker.ts. The preload replaces process.threadCpuUsage in the worker thread, so no shipped file, export or type changes, and no changeset is owed (skip-changeset on create; the file is a *.test.ts outside tsup entries and files[]).",
        "The budget value moved 30 -> 3000 ms, because the measured failure is the real-time ceiling (5 budgets). The stepping clock decides truncation; flagged against the ruling's letter in open_questions.",
        "The warm read was removed: a 1-page PDF never reaches a budget checkpoint, and worker start is outside the ceiling.",
        "Commit trailers use the model-free pair AGENTS.md prescribes, not the harness reminder's model-named Co-Authored-By. The PR footer uses AGENTS.md's session-URL form, not the harness's line. Where they disagree, AGENTS.md was followed.",
        "check:dual-build-cjs-loads NOT MEASURED locally (prerequisite: every package's dist)."
      ],
      "open_questions": [
        {
          "question": "The ruling area says 'never widen the budget'. The fixed case uses cpuBudgetMs 3000 with a stepping thread clock, instead of 30, because the pool's wall-clock ceiling (5 x budget, real time) is what reddened CI. Accept?",
          "options": [
            "A: keep 3000 ms + stepping clock. Exact truncation is pinned, the real-time ceiling is 15 s, and production code is unchanged. Cost: none further.",
            "B: keep 30 ms and also stop the ceiling from racing, by faking the request thread's setTimeout around the read, or by adding a test seam on the pool's ceiling. Cost: fake timers reach every timer in the runtime under test, or a seam in shipped pool code; about half a day plus risk."
          ],
          "recommendation": "A, because the budget number no longer races anything. The stepping clock fixes the stop point, the ablation proves the clock is what pins it, and B adds risk for a literal reading of the fence."
        }
      ],
      "security_findings": "none",
      "out_of_scope_findings": [
        "class: a · reach: read_file through MCPServerRuntime.callTool in this suite, measured under load: content 'none' whose reason reads 'Reading stopped at the CPU-time budget for one file (30 ms) after page 0 of 120, so the text is partial.' No text is returned, and 'after page 0 ... text is partial' misleads the reader. Landing: file-content.ts stoppedExtractionAnswer -> pdfAnswer([], numPages, note), when the worker's ceiling fires before its first page (docx path analogous). It is reachable without load by a PDF whose page 1 outruns 5 budgets of wall time · dedupe words: 'after page 0', stoppedExtractionAnswer, 'text is partial' none, read_file ceiling",
        "carrier: none · noted, not filed: sibling worker cases still on real wall time (the ceiling case's 200 ms window before page 1, the request-thread tick count, default-budget full reads). No CI failure is known and none was stress-run here."
      ]
    }
  7. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C

    ACCEPT → PR #34853 (seat record, head a5821d8). The open question (budget 30 → 3000 under a stepping clock) is accepted by the seat, with the reason recorded there. Out of scope: filed #34855.

  8. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C

    MERGED: PR #34853 closed this card (2026-11-17T14:53Z). On origin/main the worker case runs on the stepping thread clock (git grep steppingThreadCpuWorker in mcp-file-tools.test.ts: present). pm:dispatched and lease:o4-C are off. Follow-up: #34855 (the ceiling stop before page 1 answers with a note claiming partial text).

  9. removed
    pm:dispatched
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugdomain:serverfindingpriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions