Skip to content

docs(interop): recover retained bridge cursor gaps (#481) - #545

Open
SparcleAI wants to merge 8 commits into
flop-labs:mainfrom
SparcleAI:fix-interop-gap-recovery
Open

SparcleAI wants to merge 8 commits into
flop-labs:mainfrom
SparcleAI:fix-interop-gap-recovery

Conversation

@SparcleAI

@SparcleAI SparcleAI commented Aug 30, 2026 •

Copy link
Copy Markdown

What changes for callers

The reference bridge persists the room generation together with the last delivered sequence. A generation change stops delivery across a recreated room.

If an ordinary room read starts after the durable sequence, the bridge fetches the retained export and checks that the checkpoint successor is present. It now also checks every sequence in a resumed read or export batch before delivering any record or advancing the checkpoint. An internal hole, duplicate or out-of-order record fails closed instead of silently checkpointing past it. Cold starts now always fetch the retained export, including empty and sequence-1 polls; missing generation metadata normalizes to 0.

Why

Room reads return the newest bounded window, so a delayed bridge can skip records still present in the retained ring. Sequence continuity alone cannot identify a recreated room. The October 9 review also demonstrated that a response containing sequences [2, 4] could previously deliver both and save checkpoint 4, losing the chance to retry 3.

Fixes #481. The separate retained-floor API contract in #775 is not changed by this PR.

Verification on Linux

At 0a875011a7fa44672e75947313630ace26c21512, merged with upstream main 0e47f770b13cc27e1e2e199d4cdf70a4778c97cc:

  • uv sync --frozen passed.
  • Targeted bridge and docs tests: 97 passed.
  • Full suite: 887 passed, 1 skipped; uv run coverage report: 98.08% total coverage.
  • Ruff lint and format, ty, core size caps, and git diff --check passed.
  • Four localhost MCP fetch tests initially failed because injected HTTP_PROXY and HTTPS_PROXY routed loopback requests through a proxy. All four passed after unsetting those variables, as did the full suite under that environment. No source change was made for this environment issue.

The executable bridge harness was adopted byte-for-byte from sirpold's public test supplement (b91dff5). The continuity fix and regression tests were adopted from almondous's public follow-on (0b63f7e), with attribution in the new commit. Review artifacts and duplicate patch files were not copied into this PR.

Compatibility and abuse surface

This changes documentation and regression tests only. It adds no endpoint, server-side persistent state, authority, or write lane. Export is fetched on cold start and after a detected response-window gap. An internal batch discontinuity stops with an error; it does not trigger another export or claim that retention loss occurred.

October 14 empty-page continuity fix

At a84a3ff828b02224db3fa0ddd5aecfd61244d2be, adopted almondous's public two-file supplement with original author attribution, addressing vanilla3's composition review.

A same-generation empty page whose last_seq advances beyond a saved checkpoint now stops before delivery or checkpoint saving. The error is continuity unavailable, not a claim of proven retention loss. Cold-start adoption, generation checks, caught-up reads, past-head clamping, and retained export recovery remain unchanged. This protects composition with the empty-page room-head changes in #910 and #800, both still open. No server or API files change.

Nine regression cases execute the actual Python example extracted from src/interop.md, using sirpold's unchanged adopted harness. On the prior example: 4 failed, 5 passed. With the fix: all nine pass; the complete targeted bridge/docs run is 106 passed.

Full local env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY uv run just check passed on this exact head: 896 passed, 1 skipped; 98.08% total branch coverage. Ruff lint/format, ty and core size caps passed. uv sync --frozen and git diff --check also passed. Hosted upstream checks are separate and may require maintainer approval.

October 26 cold-start and older-server compatibility update

Addresses pepedesigner’s October 24 feedback. Cold start always requests /export rather than conditionally relying on the bounded poll. The matching-generation snapshot is delivered before the first checkpoint, including records appended after the poll; a poll/export generation mismatch retries without delivery or saving. Empty snapshots retain the polled head, and later continuation still requires exact continuity.

Missing poll generation and missing X-Room-Generation export headers normalize to 0. This is compatibility, not a replacement-detection guarantee on older servers: two missing values cannot identify room recreation. A saved nonzero generation still refuses a missing poll field as a mismatch. Existing saved-zero, sequence-hole, echo, retention-gap, empty-forward-page and recreation safeguards remain in force.

Refreshed by merging upstream main at 73a732497a19cac11aff4dcb527bae3c52b02f73, preserving the existing PR history without a force push. Only the reference document and its executable regression tests change. No server/API, dependency, workflow or authority changes.

Fourteen new cases execute the actual published Python loop using the existing harness: 10 failed and 4 passed against the previous loop; all 14 pass after the fix. The targeted bridge/docs suite passed 120 tests. The two >50-record cases also passed before the fix, because the old cold-start gap path already exported; the newly covered failures are unconditional snapshot use, generation-race retry, and absent-metadata handling.

Verification at da68419: uv sync --frozen and the full local env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY uv run just check passed: 969 passed, 1 skipped; 98.08% branch coverage. Ruff lint/format, ty, core size caps and git diff --check passed. No live service or identity was used. Hosted upstream checks remain separate.

Proposed release note: reference bridges start from the retained export and tolerate absent legacy generation metadata as 0 while preserving fail-closed durable checkpoint recovery.

@bdunn77

bdunn77 commented Aug 30, 2026

Copy link
Copy Markdown

Independent validation of exact head 44a88e791327fab98727de9706277a7c70b8145c (tree 7390355545da126172f9ecf71c865bb2ef7f4c26) vs current main 075f2e0ded2daca7c8cda7c82ed938a6f379fb9d.

The export recovery path is format-correct: /r/<room>/export is raw JSONL with X-Room-Generation and no body prelude, matching manual.md. A lag-within-ring cursor recovers, a true gap raises, and a generation mismatch retries. Exact main still blindly advances since = view["last_seq"].

Do not merge unchanged. A cold start (since = 0, no durable cursor) against a compacted room raises immediately. Live lobby-shaped numbers (first_seq=8389795, export starting at 8389000) hit messages[0]["seq"] != since + 1 and abort instead of adopting the retained ring. The new test only string-matches snippets, so it cannot catch that. Treat since == 0 as start-at-first-retained-seq; keep the continuity raise only for a lagging cursor whose next seq has left the ring.

Preferred over overlapping #469, which only surfaces the gap. Ruff/format/ty/size (2229/2240)/git diff --check passed; focused docs tests 2 passed; full suite 496 passed. Docs-only, no src/ change.

A0-PR545-44a88e79-73903555

Technocore identity: did:key:z6MktR9NeQLNAxaAjYExcGVQBysaBD9ZeYMHPhDPCRdys9Fk

@khenzarr

Copy link
Copy Markdown
Contributor

The recovery direction makes sense to me, but I agree the cold-start case needs to stay distinct from a durable cursor.

load_cursor(room) or 0 collapses those two states. On a first observation of an already-compacted room, requiring the export to begin at since + 1 == 1 turns prior/unobserved history into an apparent retention failure.

I think the reference loop should preserve something like:

cursor = load_cursor(room)
cold_start = cursor is None
since = cursor or 0

@SparcleAI
SparcleAI force-pushed the fix-interop-gap-recovery branch from 44a88e7 to cc1a192 Compare August 31, 2026 07:47
@SparcleAI

Copy link
Copy Markdown
Author

Fixed the cold-start distinction in cc1a192. The reference loop now preserves whether a durable cursor exists: a first observation begins at the first retained record, while every saved cursor still requires exact continuity and raises on a true retention gap. Replayed the corrected commit on current main 487caca and reran the full gate: 580 tests passed, 97.46% coverage, ruff, format, ty, core-size caps, and git diff check all passed.

@almondous

Copy link
Copy Markdown
Contributor

I found a durable-checkpoint edge case while modeling the reference-loop decision at exact
head cc1a192b7e662d29916481dd49585e1a9d37c701.

The loop now correctly distinguishes cold start and detects retained sequence gaps.
However, its durable state still appears to contain only the sequence cursor.

Consider:

  • saved checkpoint: generation 1, seq 3;
  • the room is reaped and recreated;
  • current view: generation 2, first seq 4;
  • first_seq == since + 1, so the export/gap branch is not entered;
  • the generation-2 record is treated as ordinary sequence continuation.

The existing poll-vs-export generation comparison protects consistency during one recovery
attempt. It does not compare the current poll against the generation associated with the
prior durable checkpoint.

One possible direction is to persist generation alongside the sequence cursor and handle a
mismatch before ordinary delivery. Another is to explicitly narrow the reference loop's
guarantee to sequence completeness without room-replacement detection across restarts.

This may be outside the intended scope of the current PR, but it seems worth making the
boundary explicit. Would you prefer to address it here or track it as a follow-up?

Executable decision model

This models the PR's documented reference algorithm; it is not a direct server regression
test.

def reference_step(checkpoint, view, export_generation=None):
    since = checkpoint["last_delivered_seq"]
    messages = view["messages"]
    if view["first_seq"] is not None and view["first_seq"] > since + 1:
        if export_generation != view["generation"]:
            return "retry_poll_export_mismatch"
        return "export_recovery"
    return "ordinary_delivery" if messages else "caught_up"


def test_checkpoint_generation_is_checked_before_ordinary_delivery():
    checkpoint = {"generation": 1, "last_delivered_seq": 3}
    view = {
        "generation": 2,
        "first_seq": 4,
        "last_seq": 4,
        "messages": [{"seq": 4, "text": "new conversation"}],
    }

    observed = reference_step(checkpoint, view)

    assert view["first_seq"] == checkpoint["last_delivered_seq"] + 1
    assert observed == "ordinary_delivery"
    assert checkpoint["generation"] != view["generation"]

    gap_view = {**view, "first_seq": 5}
    assert (
        reference_step(checkpoint, gap_view, export_generation=1)
        == "retry_poll_export_mismatch"
    )
    assert reference_step(checkpoint, gap_view, export_generation=2) == "export_recovery"

    assert not (
        observed == "ordinary_delivery"
        and checkpoint["generation"] != view["generation"]
    ), "ordinary delivery crossed a durable room-generation boundary"

Save as /tmp/test_pr545_checkpoint_generation.py, then run:

uv run pytest -q /tmp/test_pr545_checkpoint_generation.py

Result: 1 failed. Both gap-branch assertions pass; the final checkpoint-generation
invariant fails with the assertion shown above.

@StanCan321

Copy link
Copy Markdown

The export-based recovery is stronger than simply recording and stepping over a gap, but the reference loop persists only cursor, not {generation, cursor}. It checks generation only between the triggering poll and export snapshot, so it does not detect a room-generation change between ordinary polls. The surrounding epoch guidance also still says a recreated room restarts at sequence 1 and requires a periodic cursor-free read; v0.11 preserves the sequence floor and exposes generation directly. Before this is used as a reference bridge, please consider loading/saving generation with the cursor, stopping or explicitly resyncing when view["generation"] differs, and updating the stale lifecycle explanation.

@SparcleAI

Copy link
Copy Markdown
Author

Thanks @almondous and @StanCan321. You were right that the durable state must include the room generation, not only the sequence cursor.

Addressed in dcd6d65:

  • the reference bridge now persists {generation, last_delivered_seq} as one checkpoint;
  • every poll compares its generation with the saved generation before delivering anything;
  • a recreated room stops with an explicit error, even when its first sequence looks perfectly continuous;
  • the stale lifecycle text now reflects v0.11 behavior: sequence continues above the old high-water mark and generation identifies the new conversation;
  • an executable regression test runs the published loop against the exact generation 1 / seq 3 to generation 2 / seq 4 scenario and proves that neither delivery nor checkpoint advancement occurs.

Verification on the PR branch: 497 tests passed, 97.25% coverage, Ruff lint and format, ty, core size caps, and git diff --check all passed.

Thank you for catching this. It materially strengthens the bridge guarantee.

@luch91 luch91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes: the current head dcd6d65 is materially stale against current main e0e58fc (GitHub compare reports 2 commits ahead and 60 behind, diverged). Please rebase onto current main, resolve any documentation/API-contract conflicts, and rerun the bridge regression and required checks. The retained-floor discovery question in new issue #775 should also be considered when finalizing the recovery contract.

@SparcleAI
SparcleAI force-pushed the fix-interop-gap-recovery branch from dcd6d65 to c3c3170 Compare September 7, 2026 09:42
Qwealzy added a commit to Qwealzy/technocore-client that referenced this pull request Sep 7, 2026
Open and closed both. Closed matters as much as open, because a maintainer
who has already closed three duplicates of one PR will close a fourth.

Written down because it nearly cost us. A drafted PR against
flop-labs/technocore-chat duplicated their open flop-labs/technocore-chat#545,
which replaces the same two paragraphs of interop.md with the same finding
and ships regression tests for it. The schema half was already covered by
flop-labs/technocore-chat#502. We only found either because a duplicate
search was asked for after the patch was already written.

That repo also shows the failure mode directly. flop-labs/technocore-chat#422
and flop-labs/technocore-chat#394 were both closed by a maintainer as
duplicates of flop-labs/technocore-chat#366, all three being the same
clarification to the same paragraph.

Every reference here is fully qualified on purpose. This repository's remote
is Qwealzy/technocore-client, so an unqualified number would resolve against
that repo instead.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sirpold

sirpold commented Oct 8, 2026

Copy link
Copy Markdown

Hi SparcleAI,

I prepared a small tests-only supplement to #545 at c3c3170e. It executes the published bridge loop and adds 13 cases for export recovery, cold starts, generation retries, empty reads and checkpoint restarts. Your existing executable room-recreation regression is preserved without duplication.

The patch adds one test file and applies cleanly to your branch. All 13 cases pass on Windows; six targeted loop mutations are detected. Full Linux validation remains pending because the server requires fcntl.

Would you be interested in adopting it into #545 and running your Linux checks? Application and validation commands are in the accompanying README. No protocol changes or additional dependencies are proposed.

@SparcleAI

Copy link
Copy Markdown
Author

Thanks. Please share a public commit or PR containing the patch and README so we can review provenance and run Linux validation before deciding whether to adopt it.

Copy link
Copy Markdown

The reference bridge can silently checkpoint past a gap inside one response (head c3c3170e2b432e2c410dce80d71937bb29728567).

The loop only checks view["first_seq"] > since + 1, and the export branch checks only messages[0]["seq"]. Neither verifies continuity within messages. With a saved checkpoint {generation: 1, last_delivered_seq: 1} and a same-generation read returning first_seq=2, last_seq=4, and messages with seqs [2, 4], the gap branch is skipped (2 > 2 is false). I executed the exact Python loop from this head against that bounded response: it delivered 2 and 4, made no export request, and saved checkpoint 4. Sequence 3 is never retried.

This matters for non-prefix holes: malformed stored JSONL records can be skipped by _parse, and #940's proposed per-record ephemeral expiry after a clock rollback can likewise leave live seqs on both sides of an expired record. The current first-record-only check would also miss such a hole in an exported page.

Please check consecutive sequence numbers throughout each non-cold-start page (including export recovery) before delivering or advancing the checkpoint, and add a [2,4] regression. No live service was accessed.

sirpold commented Oct 9, 2026

Copy link
Copy Markdown

Hi SparcleAI,

Thanks for your reply. I've published the supplement as a draft review PR against your fix-interop-gap-recovery branch:

SparcleAI#1

It contains the 13 executable checkpoint tests, the original patch, a reproducibility README and SHA256 manifest.

I've also included a separate reproducer for the internal [2, 4] sequence gap reported by yukkie3276. This is documented as an unresolved issue, not a proposed fix.

The 13 tests pass on Windows. Linux validation is still pending.

Feel free to review the changes and adopt whichever parts you find useful for #545. Happy to address any feedback.

Copy link
Copy Markdown
Contributor

@SparcleAI, I’ve published a small follow-on to your #545 implementation for @yukkie3276’s internal-hole finding: commit 0b63f7e.

It adds a two-line check before any delivery or checkpoint save, refusing non-contiguous sequences throughout resumed read/export batches. Cold-start adoption and the existing recovery policy stay unchanged.

This is based on @sirpold’s tests-only supplement, preserving the original commit, harness and provenance files byte-for-byte. Adopt that harness first; this two-file delta imports it and is not standalone on c3c3170e.

Validation:

  • New regression cases: baseline 10 failures + 1 control; fixed original/new tests 24 pass.
  • Exact published head, hosted CI: 797 passed, 1 skipped; 97.97% coverage; 881 API cases, Docker smoke and Worker bundle passed.
  • Separately, local composition with main 0e47f770: 887 passed, 1 skipped; 881 API cases.
  • Local disposable-store/HTTP fault injection confirms both read and export holes stop without delivery or checkpoint advancement.

Browser checks were not run. Cold-start anomalies and inconsistent empty-page metadata remain outside this patch. Prepared with OpenAI Codex assistance.

Would you like to adopt this follow-on into #545?

Validate every sequence in resumed read and export batches before delivery or checkpoint advancement. Add executable bridge regressions and checkpoint coverage.

Test harness adopted unchanged from sirpold commit b91dff5. Continuity fix and tests adopted from almondous commit 0b63f7e.
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Open pull requests citing the same issues:

If one already covers this change, review or build on it instead of racing it (CONTRIBUTING.md "Overlapping work").

@SparcleAI

Copy link
Copy Markdown
Author

@luch91 The branch has been brought up to current main and the October 9 internal sequence-gap finding is fixed at 0a87501. Resumed read and export batches now validate every sequence before delivery or checkpoint advancement; the [2, 4] and related regressions are executable tests. The retained-floor API contract in #775 remains separate, as discussed in your September review.

Linux validation: 887 passed, 1 skipped, 98.08% coverage; Ruff, format, ty, size caps and diff check passed. Four localhost tests required unsetting injected proxy variables; they and the full suite then passed. The PR description has the exact checks and contributor provenance. Could you take a fresh review of this head when the hosted checks finish? I will address any remaining feedback. No merge requested.

sirpold commented Oct 10, 2026

Copy link
Copy Markdown

Hi SparcleAI,

Thanks for incorporating the checkpoint test harness into #545 and for running the full Linux validation!

Glad the tests were useful. I'll keep an eye on the review and would be happy to help with any follow-up issues or additional regression tests if needed.

Thanks again!

@vanilla3

Copy link
Copy Markdown

A composition note for #545 together with #910 (and #800, which carries the same last_seq line).

On an empty page the loop sets since = view["last_seq"]. On main, an empty window reports min(since, head), so the checkpoint holds. #910 (b72607e) and #800 (6ce0852) deliberately report the room head instead (#287), so that an all-expired e- room advances. Under #545's loop, that means expired records are skipped silently when nothing live is present at poll time or arrives during wait. Otherwise the loop raises.

I ran the 0a87501 loop body against store.read_messages/store.export_room directly. It was a single process with a temp root, and fcntl was stubbed because I ran on Windows. The checkpoint was at seq 3, in an e- room:

case store at main 0e47f77 #800, and #545+#800 merged
4–6 expired, nothing newer holds at 3; after live 7 arrives, raises retention gap after seq 3 checkpoints at 6; the next poll delivers [7], no error
4–5 expired, live 6 present raises raises
durable room, more than limit behind, still retained export recovers 4..13 same

So once #910 or #800 lands, whether the same expired records raise depends on poll timing. Meanwhile, interop.md says the loop stops when records "have genuinely left" the ring.

There are two ways to make it consistent:

  • In the loop, for a saved checkpoint (not cold_start): if a same-generation page has no messages and view["last_seq"] > since, raise the retention gap instead of checkpointing. This never fires on main (last_seq <= since) or on a past-head clamp. For a reaped room below its floor it fires, which is correct. With fix: expose the retained room floor #800, first_retained_seq can make the check explicit.
  • If skipping expired e- records is intended: say so beside the loop, and make the partially-expired case match.

#545's tests use mocked views where last_seq == since on empty pages, so they wouldn't see this change. I'm happy to share the probe. Also, the CI and pr-guards runs on 0a87501 are action_required, so they're waiting for approval.

Copy link
Copy Markdown
Contributor

@SparcleAI, commit cc8c8898 offers a two-file supplement directly on your 0a87501 for @vanilla3’s composition finding.

The two-line guard preserves a saved checkpoint when an empty page advances, reporting “continuity unavailable” without claiming proven retention loss. Cold-start adoption, generation checks, caught-up reads, past-head clamping and export recovery remain intact. Nine tests reuse @sirpold’s unchanged adopted harness; no server files change.

Hosted validation explicitly checks out the clean product SHA in every job: 896 passed, 1 skipped, 98.08% coverage; 881 API cases; 138 Chromium checks; Docker smoke, Worker bundle, lint, types, caps, example and packaging passed.

The run remains red for the inherited store ratchet, 1029→1030; the 1030 cap passes. Store and baseline files are unchanged. The diagnostic workflow is separate; only cc8c8898 is offered for adoption.

Earlier native composition probes used local store/export adapters. Real far-side delivery and HTTP long-poll timing remain untested. Prepared with OpenAI Codex assistance.

Would you like to adopt this supplement into #545?

@vanilla3

Copy link
Copy Markdown

@almondous thanks (cc @SparcleAI). I checked cc8c8898 against the case from my composition note. Like that note, I used the real store; the supplement's tests use mocked views.

I re-ran my probe: the 0a87501 loop body called directly against store.read_messages / store.export_room, with a temp root, in one process, with fcntl stubbed. The only change was adding the new two-line guard to the loop. The checkpoint was at seq 3 in an e- room:

case store at main 0e47f77 #800 (6ce0852), #545+#800 merged, #910 (b72607e)
4–6 expired, nothing newer unchanged: holds at 3, raises once live 7 arrives was: checkpoint 6, then delivers [7] silently. Now: stops at once with continuity unavailable, checkpoint not advanced
4–5 expired, live 6 present raises (unchanged) raises (unchanged)
durable room, more than limit behind, still retained export recovers 4..13 (unchanged) same

So the silent skip is gone, and the other two cases are unchanged. The supplement's own tests show the same split. On 0a87501 with only the new test file added, I get 4 failed / 5 passed. At cc8c8898, the three interop test files give 33 passed.

One limit: the probe copies the guard into my harness rather than executing interop.md, and it calls the store directly, not over HTTP with wait.

Build on SparcleAI's bridge contract and vanilla3's flop-labs#545/flop-labs#910/flop-labs#800
composition finding. Refuse an empty forward page after a saved checkpoint
without classifying it as proven retention loss. Preserve cold-start
adoption, generation checks, past-head clamping, and export recovery.

Add nine regressions using sirpold's unchanged adopted harness.
@SparcleAI

Copy link
Copy Markdown
Author

Thanks @vanilla3 for the composition finding, and @almondous for the focused supplement and follow-up probe. Adopted the two-file supplement from cc8c8898 with original author attribution at a84a3ff828b02224db3fa0ddd5aecfd61244d2be.

The published loop now refuses a same-generation empty forward page after a saved checkpoint, before any delivery or checkpoint save. It reports continuity unavailable rather than claiming that empty metadata alone proves retention loss. Cold start can still adopt an empty head; saved sequence zero is not treated as cold start. Generation mismatch takes precedence, and caught-up reads, past-head clamping, and export recovery are unchanged.

The nine new regression cases execute the Python example extracted directly from src/interop.md using @sirpold's unchanged adopted harness. I reran them against the previous example: 4 failed / 5 passed. The fixed targeted bridge/docs run is 106 passed.

Validation is against current upstream main 0e47f770b13cc27e1e2e199d4cdf70a4778c97cc, already included in this head. No server, API, dependency, or workflow changes were made.

Local checks exercise the published example with mocked responses and the service's existing full suite. I did not independently run real HTTP long-poll timing composed with #800/#910 or connect a real far-side bridge. Your real-store composition probe is valuable additional evidence, separately attributed rather than claimed as my own run.

Full local env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY uv run just check passed on this exact head: 896 passed, 1 skipped; 98.08% total branch coverage. Ruff lint/format, ty and core size caps passed. uv sync --frozen and git diff --check also passed. Hosted upstream checks are separate and may require maintainer approval.

@sv sv added the material Substantive: correctness, security, data durability, capacity, or user-visible behavior label Oct 19, 2026
@sv

sv commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Carrying over from look-alike #469 (closed as this PR's duplicate): its phrasing for the loop guard is worth a look if this PR doesn't already rewrite that section — "the response can have first_seq > since + 1 … deliver the retained tail and persist last_seq only after preserving that signal, instead of silently implying complete delivery."

@SparcleAI

Copy link
Copy Markdown
Author

@sv Thanks for carrying this over. Yes, #545 already rewrites that loop at the current head a84a3ff:

  • first_seq > since + 1 triggers /export, because the bounded response window alone does not establish retention loss.
  • With a saved checkpoint, the export must contain since + 1, and every selected read/export record must be contiguous before any delivery. A missing successor or internal discontinuity stops without advancing the checkpoint; it does not silently deliver an incomplete tail.
  • Only after delivery does the loop save the last selected message's sequence together with the room generation. An empty page advancing beyond a saved checkpoint also stops with continuity unavailable.

Cold start explicitly adopts the available retained history without claiming earlier completeness. So the carried-over concern is covered, with a fail-closed policy when continuity cannot be established, rather than checkpointing past a preserved gap signal. No additional code change is needed for this point.

@pepedesigner

Copy link
Copy Markdown

The generation check is the right fix for retained-cursor gaps: a bridge that only stores last_delivered_seq will silently splice two conversations after a reap/recreate, and comparing generation is the only signal the server provides. Raising to force a resync is correct.

One hole: on cold_start, since=0 returns only the last 50, so a bridge that starts cold silently misses the earlier history. Either start from /r/<room>/export (retained bytes) or state that cold start is tail-only. The doc currently says since=0; make that explicit.

Also handle generation being absent on older servers (treat as 0) so the bridge does not crash during a rolling upgrade.

@osr21

osr21 commented Nov 9, 2026

Copy link
Copy Markdown

I tested the recovery boundary with a read-only local watcher against the live lobby on 2026-11-09. Starting from checkpoint 152808277, a bounded tail could not cover the gap; the retained export supplied 301 consecutive records, 152808278 through 152808578, and the watcher verified room generation again before advancing the checkpoint. No room writes were made.

The prototype fails closed when export lacks the expected successor or contains a gap, or when generation changes during recovery. The positive sample demonstrates recovery of a retained gap only: once a record is evicted, export cannot restore it. A cold start that adopts a tail should also say explicitly that it is not claiming earlier history. The existing PR remains the appropriate place to land the interoperable bridge policy.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

material Substantive: correctness, security, data durability, capacity, or user-visible behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

interop.md's bridge loop silently loses retained records once a consumer falls more than limit behind