Skip to content

test(host-bridge): size the context fixture budget from the protocol - #514

Open
zuizhuai wants to merge 1 commit into
Tencent-Hunyuan:mainfrom
zuizhuai:test/context-integration-budget
Open

zuizhuai wants to merge 1 commit into
Tencent-Hunyuan:mainfrom
zuizhuai:test/context-integration-budget

Conversation

@zuizhuai

Copy link
Copy Markdown
Contributor

What

Two lines in memhub/packages/host-bridge/src/context-integration.test.ts:

  • size the file's per-test budget from HOST_CONTEXT_TIMEOUT_MS instead of vitest's 5s default;
  • let the fixture cleanup retry its rm() instead of throwing ENOTEMPTY.

No production code changes.

Why

The suite's budget is below the budget it exercises. proxyContext gives Core timeout_ms + 1000, and contextThroughBroker / McpSession fill an omitted timeout_ms up to HOST_CONTEXT_TIMEOUT_MS (8s) — so a legitimate /context round trip is allowed to take nine seconds while the test that drives it is killed at five.

On 2026-11-18 that showed up on main (d8138b5, run 44341072396):

FAIL src/context-integration.test.ts > does not pass a legacy-shaped context response through
Error: Test timed out in 5000ms.
FAIL src/context-integration.test.ts > rejects invalid request {"query":"x","limit":true} without a downstream read
Error: Test timed out in 5000ms.

Both cases are a fixture() plus one post(); neither depends on timing, and re-running the same commit is green, so the runner was simply slow enough that the fixture's three writes and two listens no longer fit in 5s. The memhub job has been re-run green several times since (e.g. #503, #504), which is what makes this a budget problem rather than a behaviour problem.

The timeout then produced a second, misleading failure. RecallBroker.stop() writes the stopped discovery on its way out, so a file can land between rm()'s readdir and its rmdir:

Error: ENOTEMPTY: directory not empty, rmdir '/tmp/one-memory-tests.gBPZUt/tmp/om-context-EfaIlA'

vitest reports that against the test that just failed, so the log shows two failures where there was one, and the visible error (ENOTEMPTY) is not the real one (the timeout). maxRetries/retryDelay are the documented remedy for exactly this race.

Verification

In a Linux checkout (the fixture requires POSIX grant storage):

  • pnpm --filter @one-memory/host-bridge typecheck — clean
  • vitest run src/context-integration.test.ts --maxWorkers=1 — 91/91 passed
  • full package suite vitest run --maxWorkers=1 — green
  • biome check on the file (LF) — clean

`proxyContext` gives Core `timeout_ms + 1000`, and every client helper fills
the omitted budget up to `HOST_CONTEXT_TIMEOUT_MS` (8s), so a normal /context
round trip is allowed to run for nine seconds. The suite kept vitest's 5s
default, so a loaded runner could fail a passing assertion: run 44341072396
lost "does not pass a legacy-shaped context response through" and "rejects
invalid request {"query":"x","limit":true}" to 5000ms timeouts with no broker
fault, and a re-run of the same commit is green.

The timeout also dragged in a misleading second failure. `broker.stop()`
writes the "stopped" discovery on the way out, so a file can land between
`rm()`'s readdir and its rmdir; the race surfaced as ENOTEMPTY and vitest
reported it against the test that had just failed, hiding the timeout.

Size the file's budget from the protocol constant and let `rm()` retry the
race instead of throwing. No production code changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant