Skip to content

fix(client): report a store that cannot repair reopened rounds at start - #208

Merged
gregpriday merged 4 commits into
developfrom
bugfix/issue-189-reopen-repair-is-skipped-for-stores
Nov 19, 2026
Merged

gregpriday merged 4 commits into
developfrom
bugfix/issue-189-reopen-repair-is-skipped-for-stores

Conversation

@gregpriday

Copy link
Copy Markdown
Contributor

A 0.8.0 bridge kept the earlier round's deadline when it applied a reopen. 0.9.0 repairs those rows from verified history, but only through the optional LocalStore.processedEventsOfType, and a store without it skipped the repair silently. A question asked with no deadline and reopened under 0.8.0 with a finite one then keeps a stale null, and the relay's genuine expiry is refused as expiry-without-deadline. Daintree's DaintreeLocalStore does not implement the method.

Without verified history the bridge cannot recover the signed deadline itself: an unsigned relay expiry must not close a round on the relay's word alone. So this takes the issue's second branch. The integrator is told at start, and the docs say what a custom store needs.

Resolves #189

Changes

  • Inbox checks a store without processedEventsOfType before a pass applies any event. It used to mark the repair done in memory.
    • With no live reopened question there is nothing to repair. The store is marked rounds-reconciled, as a searched store would be, so fresh installs are never warned.
    • With reopened questions, the check audits rounds.unreconciled / store-without-history and leaves the store unmarked. The repair then runs on the first bridge whose store implements the method.
    • While any of them is open or queued, it sends one BridgeError('not_supported') naming the method on bridge.on('error'), once per bridge. A store read failure during the check is reported there too, and the check runs again a minute later.
  • DecisionsBridge.start() waits for that check before the socket, polling or pump start, so the error has fired by the time start() returns. A second concurrent start() also waits for it. The check is one shared promise, not the inbox lock, so start() never waits behind a pass blocked on a terminal write. Stores that have the method still start the background repair from the first event pass.
  • applyExpired is unchanged. A guard that refuses expiries of unrepaired rounds was considered and left out. On a store without the method, rounds reopened by 0.9.0 itself look the same as legacy ones, so the guard would refuse their genuine expiries after a restart.
  • packages/client/README.md, docs/daintree-integration-spec.md (section 7) and the LocalStore JSDoc now say:
    • what processedEventsOfType must return;
    • that a store a 0.8.0 bridge wrote to needs it;
    • to register the error listener before the first start(), catchUp() or sync();
    • that a new bridge over the same store does the repair;
    • that an expiry refused before then stays refused.

Testing

  • packages/client/tests/expiry-rounds.test.ts has eight new tests for a store without the method. The first five failed on develop before the fix.
    • The integrator is told, and the store is repaired once the method exists, after which the relay's expiry closes the question.
    • The error has fired by the time a single start() returns, and a concurrent second start() waits for it, with one report in total.
    • start() resolves while an inbox pass is held on a hanging directory lookup. This test times out if the check takes the inbox lock again.
    • A failed store read is reported and retried a minute later.
    • An empty store is marked and nothing is reported. Only closed reopened questions are audited, but neither reported nor marked. An already-marked store or one with only imported history reports nothing.
  • The block's restart helper now takes the bridge's live clock, so a copy of the test env no longer freezes time.
  • Own and adjacent: expiry-rounds, expiry, store.
  • Impact: 15 of 144 test files (10%), 461 tests, all green after the final rebase.
  • prettier --check on the changed files. No type check ran: the repo has no changed-files type check.

Known and left open

  • Pre-existing: if 0.8.0 crashed after writing a reopen's row but before marking the event processed, the replayed reopen is refused and that row is not repaired.
  • With a store that lacks the method, a legacy row with a stale earlier deadline can still be closed by an expiry the relay sends before the signed deadline. The error tells the integrator to remove this by implementing the method.

- A reopened row a 0.8.0 bridge left with no deadline, on a store without processedEventsOfType
- Check a store without processedEventsOfType in place, before any event of the pass is applied
- Mark a store with no reopened question as reconciled; audit one whose reopened questions cannot be searched
- Report not_supported on the bridge's error listener while any such question is open, before start() returns
- Document what a custom store needs for the 0.9.0 repair in the README, the integration spec and the interface
…ore that cannot be read

- Share one promise for the missing-history check instead of taking the inbox lock, so start() waits for the check alone
- Make the check's audit best effort, and report a store read failure on the error listener
- Cover a single start, a start beside a held pass, a failed read, and the fixtures each test names
- Say in the docs that a new bridge repairs the rows, and when the bridge looks
- A caller the store reaches during the check joins it instead of starting a second one
- Say the bridge looks as it starts or first applies events
@gregpriday
gregpriday merged commit b77e1b0 into develop Nov 19, 2026
2 checks passed
@gregpriday
gregpriday deleted the bugfix/issue-189-reopen-repair-is-skipped-for-stores branch November 19, 2026 14:05
@gregpriday gregpriday mentioned this pull request Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reopen repair is skipped for stores without processedEventsOfType

1 participant