Skip to content

bug(omp): first tag revision allocation in a nonempty legacy session invalidates its snapshot #769

Closed

Description

@sisttri

What happened

I resumed an older OMP session and my next prompt was refused:

Magic Context could not safely prepare this turn; send your message again.
stage=pipeline elapsed=572ms recovery=no managed result; refused
(Pi tag hydration: tag snapshot is not ready; turn not sent, retry)

Hydration initially succeeded. The log then showed 25 pending operations applied, followed by a failure in runPipeline → getPiTagSnapshotView → sync.

Reproduction and likely cause

I reproduced the same error using the installed snapshot reader and a disposable database copy:

  1. Keep an existing session's tags, but remove its schema_migrations_meta key tag_revision:<sessionId> to simulate legacy state.
  2. Call ensurePiTagSnapshotReady, then read the snapshot successfully.
  3. Update a tag's status on the same connection.
  4. Read the snapshot again: tag snapshot is not ready.

With the revision key present, the same sequence passes. The first local update allocates a revision incarnation, changing foreignRevision. The existing firstAllocationPending handling only covers an empty session, so this nonempty legacy case is rejected.

I do not have the database from immediately before the original failure, so this establishes a reproducible mechanism, not proof of every original precondition.

Current status / expected behavior

The affected session now has a revision record. Offline replay of its current state passes context preparation (1,229 → 941 messages) and the OMP provider structure check. I have not verified a live model response.

I expect a session's own first revision allocation to preserve snapshot validity, while actual foreign writes and recreated revisions must still invalidate it. Please add regression coverage for nonempty legacy sessions and retain the foreign-write checks.

Environment

Activity

  1. sisttri commented on Oct 23, 2026

    @sisttri
    Author
    Image
  2. magic-alfonso commented on Oct 23, 2026

    @magic-alfonso

    Thanks, the mechanism fits our code. The first-allocation exception only covers an empty session, so a nonempty session from before revisions existed treats its own first revision as a foreign write and refuses the turn. We're fixing it so a session's own first allocation keeps its snapshot valid, while foreign writes and recreated revisions still invalidate it, with your sequence as the regression test. It ships in the next patch, crediting you.

  3. magic-alfonso commented on Oct 25, 2026

    @magic-alfonso

    Shipped in 0.49.21. In an older Pi or Oh My Pi session, the session's own first tag revision no longer invalidates the tag snapshot and refuses the turn. It's accepted only with full proof: exactly one matching allocation seen on that connection, its change record present, and version counts that add up. A foreign write, an untracked writer or missing evidence still refuses. Restart Pi after updating; there's no migration. Thanks, @sisttri.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions