Skip to content

Revalidate local Markdown images through the host daemon - #3295

Merged
ymichael merged 3 commits into
mainfrom
bb/fixer-revalidate-unchanged-markdown-images-thr_r8gnyt96ip
Sep 8, 2026
Merged

ymichael merged 3 commits into
mainfrom
bb/fixer-revalidate-unchanged-markdown-images-thr_r8gnyt96ip

Conversation

@ymichael

@ymichael ymichael commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Working-tree Markdown images used raw file routes that disabled browser caching. The first repair enabled HTTP ETag revalidation, but unchanged file bytes still traveled from the host daemon to the server before the server returned 304 Not Modified.

What changed

  • Enable private ETag revalidation for non-HTML worktree, thread-storage, preview-lease, and project file routes.
  • Pass validated SHA-256 entity tags through host.read_file.
  • Let the host daemon return metadata with notModified: true and no content when the local hash matches.
  • Return the complete file and its new hash when it changed.
  • Keep executable HTML previews on their existing no-store path.
  • Preserve full-content public file-read responses for unconditional callers.
  • Bump HOST_DAEMON_PROTOCOL_VERSION from 194 to 195 for the changed server/daemon wire contract.
  • Give the newly landed Pi skill-command bridge tests a file-local 30-second timeout because real child-process round trips exceeded Vitest's generic 5-second limit under full package CI load.

How you verified

  • pnpm exec turbo run typecheck --filter=@bb/host-daemon-contract --filter=@bb/host-daemon --filter=@bb/server-contract --filter=@bb/server --force
  • pnpm exec turbo run test --filter=@bb/host-daemon-contract --force -- test/contract.test.ts — 38 passed
  • pnpm exec turbo run test --filter=@bb/host-daemon --force -- src/command-handlers/host-files.test.ts test/command/workspace-dispatch.test.ts — 54 passed
  • pnpm exec turbo run test --filter=@bb/server --force -- test/hosts/daemon-file-response.test.ts test/files/host-file-routes.test.ts test/public/public-thread-data.test.ts test/public/public-project-workspace-routing.test.ts — 99 passed
  • pnpm exec turbo run build --filter=@bb/host-daemon --filter=@bb/server --force
  • Real source browser/server/daemon check: first load returned 200; unchanged reload returned 304 with zero response bytes; editing the image returned 200 with the complete new file and a new ETag; the next reload returned 304.
  • Formatting and git diff --check passed.
  • pnpm exec turbo run test --filter=bb-plugin-provider-pi --force -- src/bridge/bridge.skill-command.test.ts — 11 passed

The verification inventory currently reports the unrelated existing gap Unmapped CLI family: browser.

AGENT GENERATED

@ymichael
ymichael force-pushed the bb/fixer-revalidate-unchanged-markdown-images-thr_r8gnyt96ip branch from 1f8332f to 1052073 Compare September 8, 2026 22:43
@ymichael
ymichael force-pushed the bb/fixer-revalidate-unchanged-markdown-images-thr_r8gnyt96ip branch from 1052073 to 8f6cac3 Compare September 8, 2026 23:14
@ymichael
ymichael merged commit bb26b4f into main Sep 8, 2026
16 checks passed
@ymichael
ymichael deleted the bb/fixer-revalidate-unchanged-markdown-images-thr_r8gnyt96ip branch September 8, 2026 23:19
ymichael added a commit that referenced this pull request Sep 9, 2026
## Human comments

## What was wrong

`plugins/provider-pi/src/bridge/bridge.skill-command.test.ts` coupled a
deterministic input-to-Pi-prompt transformation matrix to full bridge
process lifecycle. Per-test setup initialized a new isolated bridge
harness, each case's first prompt started a fresh thread/session and
spawned a fake Pi RPC Node child, and teardown stopped that child; the
final case started two sessions. The 11-case file therefore paid for 12
serial child startups even though the behavior under test is a typed
input conversion.

The packages shard runs 89 package tests with Turbo `--concurrency=4`,
while each package starts its own Vitest worker pool. That nested
CPU/process oversubscription is the systemic trigger: child construction
crossed Vitest's 5 s case ceiling in unrelated [PR #3295 attempt
1](https://github.com/get-bb/bb/actions/runs/34285876225/job/102261224349),
[PR #3295 attempt
2](https://github.com/get-bb/bb/actions/runs/34285876225/job/102263472294),
and [PR #3299 attempt
2](https://github.com/get-bb/bb/actions/runs/34287966835/job/102269943782).
Attempt 1 timed out the no-arguments case; attempts 2 and 3 timed out
the two-turn unchanged-input case.

PR #3295 subsequently merged a file-wide 30 s timeout override for this
test. That masks the repeated-startup cost instead of removing it.
Scheduler contention exposes the flake, but the root cause is the
avoidable process lifecycle around pure transformation assertions.

## What changed

The existing typed input conversion now lives in `turn-input.ts`, and
`bridge.ts` calls it for start and steer input. The exact transformation
matrix and raw schema-boundary rejection cases run directly in
`turn-input.test.ts`. The old process-backed feature test and its newly
merged 30 s override are removed.

Feature behavior remains covered at the narrowest deterministic
boundary: native skill invocation, no-argument invocation,
command-position movement, whitespace, text/file/image composition,
multiple skills, malformed ranges, text mismatch, provider commands, raw
slash text, and invalid protocol inputs. Generic real-process bridge
lifecycle and input delivery remain covered by the existing conformance,
lifecycle, local-file, framing, and session suites. Keeping another
child solely around the skill conversion is redundant: the bridge now
directly calls the tested typed function, and the existing integration
suites cover delivery of its output to Pi.

No timeout, polling deadline, retry budget, wrapper limit, protocol
assertion, or production behavior is increased or weakened. This does
not change host-daemon wire behavior, so `HOST_DAEMON_PROTOCOL_VERSION`
is unchanged. There is no CLI, SDK, configuration, or documentation
surface change.

## How you verified

The mandatory fresh-main gate ran on enrolled Intel host
`host_nwqfteeqz4` at frozen SHA and merge-base
`124cf2e8888a396726f3f00271074b6a622bdb42`. After #3295 merged, the
final commit was rebased onto `bb26b4fd9a054d50e564642416319711bc4db16a`
and deliberately removed its timeout-only workaround.

- Unchanged-main focused baseline: 11 passed in 14.05 s of test time;
ordinary process cases took about 1.1 s and the two-session case took
2.218 s.
- Unchanged-main 32-burner stress: 7 of 11 cases hit the unchanged 5 s
ceiling; the first two were reported at 6.175 s and 6.177 s.
- An intermediate one-shared-child version was still not robust: one
identical 32-burner round passed, but another exceeded the existing
suite-hook ceiling before either bridge assertion ran. That proved the
feature-specific process was unnecessary residual exposure.
- Final identical 32-burner stress with no feature child and no timeout
override: all 11 deterministic/protocol cases passed in 89 ms of test
time.
- Final-tree `pnpm exec turbo run typecheck
--filter=bb-plugin-provider-pi --force` — 4 Turbo tasks passed.
- Final-tree full provider-pi Turbo test reached all 11 affected cases
in 81 ms; a separate existing `bridge.lifecycle.test.ts` local-image
process case timed out at 5.262 s while many unrelated process cases ran
2–3× slower. An earlier unloaded full run with the same production
extraction passed 28 files plus 1 skipped and 156 tests plus 1 skipped.
The separate recurrence is outside this focused fix and is reported as a
limitation.
- `pnpm exec turbo run build --filter=@bb/host-daemon --force` — 5 Turbo
tasks passed. Provider-pi has no package-local build task.
- `pnpm exec turbo run test --filter=@bb/plugin-build --force` — 10
files and 137 tests passed (1 skipped), including bundling and importing
the built-in provider-pi server and host artifacts.
- `pnpm exec oxfmt --check plugins/provider-pi/src/bridge/bridge.ts
plugins/provider-pi/src/bridge/turn-input.ts
plugins/provider-pi/src/bridge/turn-input.test.ts`
- `git diff --check`
- Post-run process and temp-directory audits found no surviving test,
build, load, fake-Pi, watcher, or worktree process and no related test
temp directory.

Every stress/load/test/build/watch command used a tracked process group,
external deadline, and cleanup trap. The 32-burner stress is
intentionally synthetic and models nested worker oversubscription rather
than treating contention as the root cause. Hosted CI on final head
`ecb35451f9407c9de5c6e9cd29cb41854e42d027` passed every required check,
including the packages shard and both package-smoke jobs.

> AGENT GENERATED
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