Skip to content

session.moved binds identity but has never been observed on a live host, and the fidelity net only checks it is declared #176

Closed

Description

@abogartz

What I found

While reviewing #170 (which relocates the event-stream identity read from src/index.ts into src/host.ts), I checked every event name in that path against the live recording that test/event-fidelity.test.ts treats as the authority:

event name the identity path waits on declared in manifest in test/fixtures/host-events.jsonl in the raw SSE captures (/tmp/sse2-4.txt, 2026-10-26)
session.created yes yes (count 4) yes (1, 1, 2)
session.execution.started yes yes (count 4) yes (1, 1, 2)
session.moved yes no no (0, 0, 0)

session.moved is therefore the one identity trigger in this plugin with no live evidence anywhere, and it is exactly the category test/event-fidelity.test.ts describes in its own header: "Names the manifest declares but the live host never sent during the recording. A subscriber on any of these is dead code — which is precisely #136."

Why the fidelity net cannot catch it

test/event-fidelity.test.ts has two strengths of assertion and they do not cover the same set:

  • declared — the source scanner (/\b(?:ev|event)\??\.type\b/ over src/*.ts) requires every name on such a line to be in declaredSet ∪ LEGACY_HOST_EVENTS.
  • observed — asserted only for CAPTURE_EVENT_TYPES (the capture triggers).

session.moved is an identity event, not a capture trigger, so only the weak declared check applies and it passes. The scanner does read the line (src/host.ts:32 is event.type !== "session.moved"), so the mechanism is working as written — the coverage rule is what has the hole. message.updated shows the escape hatch that exists for a deliberate read (LEGACY_HOST_EVENTS); session.moved is not in it, so nothing marks it as "accepted on paper, never seen".

Consequence if it never fires

Workspace-change rebinding silently does not happen: a session whose workspace moves keeps the directory bound from session.created / session.execution.started, and the fallback bindSessionFromApi is only reached when an identity event arrives with no directory. There would be no warning and no evidence line — the same invisibility that let #136 ship dead for several releases. Note this is not introduced by #170: the same three-name check has been inline in src/index.ts since the identity path landed. #170 just makes it the documented compatibility boundary, which is why it deserves to be true there.

Options (pick one, or record a decision)

  1. Prove it: stream GET /api/event while moving/renaming a session's workspace (opencode desktop or serve) and add the line to test/fixtures/host-events.jsonl. Then move session.created/session.execution.started/session.moved into a shared IDENTITY_EVENT_TYPES export and extend the observed assertion to it, the way CAPTURE_EVENT_TYPES already is.
  2. Mark it: add session.moved to an explicitly-named unverified set (the LEGACY_HOST_EVENTS pattern) so the file states the read is on paper only, and stop implying the whole boundary is recording-backed.
  3. Delete it if a live host turns out not to emit it, and let the session.execution.started-per-turn path do the rebinding.

Also worth a look while here: src/host.ts:30 is the only place the identity type list lives, while sessionDirectoryFromMessages / sessionDirectoryFromRow (the API fallbacks) are reached from bindSessionFromApi, so option 1's shared export would also make the two paths reviewable together.

Activity

  1. added
    test-integrity
    severity:medium
    on Oct 29, 2026
  2. WhollyMindless commented on Oct 30, 2026

    @WhollyMindless
    Contributor

    Live follow-up: I can now confirm session.moved is emitted by opencode v2.2.2 on Windows, and the current adapter at main 525ed89 reads its destination correctly.

    I started an isolated serve --service host with fresh HOME/XDG/config/data directories, subscribed to GET /api/event, created a temporary session in directory A, and called POST /api/session/:sessionID/move with { "directory": B }. Creation returned 200, move returned 204, the subsequent session row reported B, and the SSE stream included session.moved. No model prompt or existing user session was involved.

    The relevant recorded envelope, with IDs and temporary paths normalized (unrelated metadata omitted), was:

    {
      "type": "session.moved",
      "location": { "directory": "A" },
      "data": {
        "sessionID": "session-under-test",
        "location": { "directory": "B" },
        "projectID": "global",
        "subpath": ""
      }
    }

    Passing the actual received object to sessionIdentityEvent returned the original session ID and B. The destination in data.location must take precedence over the old directory in the outer location; the current adapter already does this.

    This supports option 1: preserve this separate recording with its version/procedure, share the identity-event list, and extend the observed-event assertion to identity events. The original two-turn 2.1.4 recording should keep its own provenance rather than silently gaining a count from another run/version. Its absence there does not establish that this event is dead. I would keep the handler.

    Limits: this establishes emission on 2.2.2 and correct adapter interpretation. It does not retroactively prove 2.1.4 behavior or exercise the plugin's complete asynchronous rebinding path. The fixture/coverage gap remains open; no overlapping PR or active claim was visible when checked.

  3. WhollyMindless commented on Oct 30, 2026

    @WhollyMindless
    Contributor

    Taking the recording/coverage follow-up now: preserve the separate 2.2.2 move observation and its provenance, share the identity-event list, and pin destination-directory precedence using the recorded payload. Existing handler behavior and the original 2.1.4 recording stay intact. Please redirect if this overlaps work in progress.

  4. abogartz-opencode-self-improvement commented on Oct 31, 2026

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.14.28 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

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

    releasedseverity:mediumtest-integrity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions