Skip to content

Capture tests fabricate {type:"session.idle"} — the green suite pins a trigger the host has never sent #137

Closed

Description

@abogartz

Problem

Every capture test hand-fabricates the event the plugin is waiting for:

  • test/capture.test.ts:291, 297, 320
  • test/capture-compaction.test.ts:237, 270, 389-390

all push { type: "session.idle", … }. opencode 2.x has never emitted that event (see the capture root-cause issue), so the entire auto-capture suite — hundreds of assertions, 480 tests green in CI — pins a trigger that does not exist. The fake and the production code are wrong together, which is exactly the failure mode recorded twice already (#86, #90: "fake-payload drift is the failure mode this repo keeps paying for").

This also survived an adversarial review and a merge (#79), because the review verified the sid read against the same imagined envelope.

Fix

  1. Drive capture tests from a recorded host stream: throwaway probe plugin → JSONL of real payloads under every host mode (run --standalone, serve --service, desktop app), replayed by the harness. That method already exists from test(scenarios): acceptance suites — ordered-event harness + cross-process red/green #86/Session repo identity never binds on host 2.1.4 — recall silently partitions writes under the server cwd #90; apply it here.
  2. Add a host-fidelity test that fails when the plugin subscribes to an event type absent from the installed @opencode/schema event manifest. This is the structural fix: it makes "invented event name" a class of bug the suite can never repeat, for capture or any future subscriber.
  3. Re-run the mutation sweep (Testing-2: the mutation sweep audits the scenarios (instrument, status classes, four audit findings) #70) after the fix and publish the score change — if the trigger invariant was previously "pinned" by a fake-driven test, the score should drop, and that drop is the honest measurement of how much the green suite was worth.

Acceptance

  • Removing the real event name from the plugin makes a recorded-stream test red.
  • The fidelity test is red if anyone introduces a subscriber event type not in the manifest.

Activity

  1. added
    test-integrity
    on Oct 26, 2026
  2. added
    verified-on-main
    on Oct 30, 2026
  3. abogartz commented on Oct 30, 2026

    @abogartz
    OwnerAuthor

    Fixed — the trigger the suite pins is a real observed event

    src/index.ts:223 now defines the trigger from the recording rather than from imagination:

    export const TURN_END_EVENTS = ["session.execution.succeeded", "session.execution.interrupted"] as const;
    export const CAPTURE_EVENT_TYPES: readonly string[] = [...TURN_END_EVENTS];

    Both names are present in test/fixtures/host-events.jsonl, and test/event-fidelity.test.ts asserts the strong form — "every event type auto-capture reacts to was really observed on a live host" (expect(neverSent).toEqual([])). That is the structural fix item 2 asked for: an invented subscriber name is now a red build, for capture and for any future subscriber.

    The remaining session.idle references in tests are deliberate negative pins (test/capture.test.ts:577-578 asserts a legacy envelope shape produces 0 model calls), and src/index.ts:228-230 documents why session.idle, session.status and session.execution.failed deliberately do not trigger.

    Item 3 (re-run the sweep and publish the score delta) is not done by this — scripts/test-sweep.ts is now committed with a bun run sweep:test script, so publishing the score is #72's job.


    Severity triage 2026-10-30 — reviewed against main @ 525ed89 (v0.14.24). Labeled verified-on-main: the behavior this ticket describes no longer exists, so there is nothing to build. Full-suite baseline at that commit: 722 pass / 12 skip / 0 fail. Closing is your call; the evidence is here so the claim is checkable rather than asserted.

  4. abogartz commented on Nov 2, 2026

    @abogartz
    OwnerAuthor

    Closing on the verified-on-main call. The fabricated event is gone: capture.test.ts drives from test/fixtures/host-events.jsonl and now pins the opposite claim at line 575, 'declared-but-never-emitted events do NOT fire: session.idle' asserting 0 model calls, with test/event-fidelity.test.ts guarding the fixture.

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

    test-integrityverified-on-main

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions