Repository navigation
Make plugin host loading and telemetry tests deterministic - #1877
Conversation
|
🚨 SLOP COP 🚨 · I am SlopCop. I am now reviewing this pull request under the configured security, quality, performance, test, and architecture rules. |
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain English summary: This pull request makes cached plugin code load as ESM by using a .mjs file. It also splits telemetry tests to reduce timing failures.
I found three issues:
- Medium: Existing
host.jscache files cause a second download and can remain besidehost.mjs. - Medium: The new boot test still starts unrelated bundled plugins. My focused run took 14.7 seconds.
- Low: The incompatible fixtures no longer test a successful reload, enable, or boot load.
I found no new security issue. Digest checks, size checks, staged writes, and atomic file moves remain active.
The code uses the shared artifact cache well. A small test helper could replace three repeated cache paths, but this change is optional. A different-digest prune race exists on main, so I did not attribute it to this pull request.
Validation passed:
- 51 focused host-daemon tests.
- 23 focused server plugin-service tests.
- Turbo type checks for both affected packages.
- All GitHub checks at the reviewed SHA.
- A full dev app browser smoke test with no page errors.
- A real
host.mjsplugin worker start with no module-type warning.
Please address the three inline findings. I posted this as a comment-only review.
c18f6fe to
a734a71
Compare
a734a71 to
53365ae
Compare
…, the runtime assembles the timeline (v2) (#1834) Implements [plans/narrow-grammar-protocol.md](plans/narrow-grammar-protocol.md) **end to end**: the Provider Bridge Protocol's timeline lane is now a narrow grammar of parsed semantic deltas (`thread/delta`), and one runtime-owned assembler constructs every canonical `ThreadEvent`. All four bridges are converted; the old `thread/event` lane is deleted; there is exactly one dialect. `PROVIDER_BRIDGE_PROTOCOL_VERSION` 1 → 2. ## The design in one paragraph Previously a bridge owed the runtime finished canonical events: it opened turns, minted and scoped item ids, queued accepted input, settled items, and constructed `@bb/domain` shapes — four parallel implementations of the same timeline state machine, which is where the recurring turn-lifecycle and id-collision bug classes lived. Now **the bridge knows the dialect, the runtime knows the timeline**: bridges emit facts (`item.open {command, cwd}`, `message.delta`, `turn.boundary {status}`, `session.ended`…) and the assembler — one implementation with an extensive dedicated test suite — owns id minting (entropy-scoped, bidirectional provider↔bb maps), accepted-input correlation, the exactly-one-terminal-state invariant, delta-first synthesis, settle/reopen dedup, pairing/close-echo, text accumulation, snapshot diffing, usage accumulation, and progress throttling. Structural violations of turn lifecycle are no longer possible for a provider to express. ## What each conversion proved - **pi** (first tenant): the terminal-turn triangle, threshold-compaction last-turn scoping, cumulative bash-output diffing, checkpoint stamping — translator went stateful 1,259 → stateless 898 lines. - **acp**: the uniform `item.close` rule (close always carries the full terminal shape — mid-flight reclassification and close-without-open become one rule); interaction `turnId` resolved runtime-side (`turnId: null` on the wire). - **codex**: vouched provider-turn keys (multiplexed subagent child turns as first-class keyed turns); `item.textDelta` vs `item.outputDelta` making the started-synthesis exception structural; command-plane reverse id mapping at the adapter seam (steer/interrupt translate bb ids → provider ids via assembler maps). - **claude-code** (hardest): **no per-provider assembler extension was needed.** The background-task machine decomposed into bridge-side dialect (snapshot fold, generations, completion-blocking — the bridge withholds `turn.boundary` while blocking tasks are open) and generic policy (central progress throttling — now every provider's delta-aggregation knob — and an open-items eviction guard). Calibration golden: byte-identical event stream. Every conversion ported its full test suite as equivalence evidence (same fixtures → deltas → real assembler → exact canonical events; ids asserted by shape) and passes the conformance suite end to end. ## The deletion `thread/event` ingestion, its notification vocabulary, and the bridge kit's assembly machinery (turn-state registry, scoped-item-ids, accepted-user-messages, terminal-turn resolution, item constructors — 1,140 published lines) are gone. The published SDK surface ends at **184 names** (192 at branch base, after absorbing the entire delta grammar in between), and `docs/api_to_audit.md` audit item 1 is resolved: the protocol owns its own timeline vocabulary; the remaining `@bb/domain` re-exports are command-plane contracts with named consumers. The handshake now actually enforces the protocol version (it previously never checked): a v1 artifact fails startup with a legible "update the provider plugin" error. No third-party bridges exist in the wild; first-party artifacts rebuild with the repo. Nothing crosses the server↔daemon wire — `HOST_DAEMON_PROTOCOL_VERSION` untouched. ## Verification - Full forced Turbo gate green during branch-targeted QA: lint (0 errors; 147 existing warnings), build (8/8), and the test graph (60/60 uncached). Coverage included agent-runtime (411), plugin-sdk (104), ACP (162), Codex (167), Claude Code (262), server (1,731), host daemon (583), fake-provider integration (55), and app (2,887; 3 skipped). After deduplicating the independent five-file #1877 patch, all affected branch-specific suites were rerun on the committed tree: agent-runtime (411), plugin-sdk (104), and Claude Code (262). - Real-provider integration green with ambient `OPENAI_API_KEY` unset: 4/4 Turbo tasks, 64 direct runtime CLI tests, and 11 server/daemon E2E tests. Subscription-backed Codex, Claude, and Pi plus ACP/OpenCode all ran in the full manual runbook. - Live QA passed on all four providers: spawn/tool turns, mid-turn steer, interrupt, resume with zero cross-boundary id collisions, forks, Pi manual compaction (49,932 → 30,264 tokens), Claude blocking-subagent turn hold, Codex `spawnAgent` delegation, ACP accept-edits writes, archive round trip, and a clean process sweep. Two unrelated findings were reproduced as pre-existing on main: #1721 and #1833. - The branch-targeted pass found and fixed two bugs with regression coverage: concurrent plugin-SDK builds could temporarily delete live runtime exports, so builds now stage outputs and promote each file atomically; and interrupted Claude streams could leave a partially streamed assistant item open, so `session.ended` now settles that item before the interrupted turn completes. The runbook log commands were also corrected to use the configured rotated-log directories. - The same pass exposed independent host artifact-cache and telemetry-test flakes. Those fixes were deliberately removed from this branch and are owned by #1877; the two PRs have no overlapping files. ## Follow-ups (not in this PR) - #1721 / #1833 as tracked. - The session-mode primitive (separate plan): with the grammar narrowed, the transport consolidation carries a smaller protocol. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED: by Claude Fable 5 --------- Co-authored-by: Claude Fable 5 <[email protected]>
What was wrong
Two full-suite flakes had distinct root causes. Downloaded plugin-host bundles are ESM, but the daemon cached them as
host.js, so Node could inherit module classification from an unrelated ancestorpackage.json; a typeless ancestor producedMODULE_TYPELESS_PACKAGE_JSONwarnings and made lifecycle-log assertions environment-dependent. Separately, the plugin telemetry test combined install/reload/enable assertions, a full stop/start boot reconciliation, and plugin runtime startup under one short timeout, so full-graph contention could time out unrelated work before the telemetry assertion ran.What changed
Plugin-host artifacts are now cached as
host.mjs, making their ESM contract explicit regardless of the surrounding filesystem. The regression test installs a typeless ancestorpackage.jsonand verifies lifecycle logging remains clean, and expected cached artifact paths were updated. Plugin telemetry coverage now uses an engine-incompatible fixture when runtime execution is irrelevant and separates boot-time reconciliation into its own test, preserving coverage for install, reload, enablement, and restart semantics without sharing a contention-sensitive lifecycle budget. These are daemon-local cache/test changes only; there is no host/server wire change and noHOST_DAEMON_PROTOCOL_VERSIONbump.How you verified
pnpm exec turbo run lint --force --output-logs=full— passed with 0 errors (147 existing warnings).pnpm exec turbo run build --force --output-logs=full— 14/14 tasks passed.pnpm exec turbo run typecheck --force --output-logs=full— 66/66 tasks passed.pnpm exec turbo run test --force --output-logs=full— 60/60 tasks passed.pnpm exec turbo run test:integration --force --output-logs=full— 4/4 tasks passed, including 64 agent-runtime integration tests and 11 real-provider tests.qa/manual-runbook.mdusing subscription-backed Codex, Claude Code, and Pi. Attachments, parent/child threads, worktrees, helper commit inference, merge-base metadata, archive cleanup, shared environments, recovery/restarts, provider lifecycle, approvals, denial, and grants all passed. The standalone environment was cleanly removed afterward. App UI/Electron/browser behavior is explicitly outside this runbook.Fixes: no linked issue; both flakes were discovered during the full validation pass.