Skip to content

fix(client): hold answer entries it cannot type; refuse a newer store - #209

Merged
gregpriday merged 2 commits into
developfrom
bugfix/issue-186-an-older-client-types-a-newer-state
Nov 19, 2026
Merged

gregpriday merged 2 commits into
developfrom
bugfix/issue-186-an-older-client-types-a-newer-state

Conversation

@gregpriday

Copy link
Copy Markdown
Contributor

An older client run on a newer client's state directory could type a stored entry it does not understand as an empty human answer: 0.8.0 types 0.9.0's never-published notice (kind: 'unpublished', source: 'system') as source: human, with no status and no authorised: no. Released versions cannot change, so this makes the next new entry kind safe in two layers: the store records a data format that an older client refuses at open, and delivery never types an entry it does not understand.

Resolves #186

Changes

  • Delivery holds what it cannot type. unsupportedEntry() (answers.ts) flags an unknown kind (answer_unknown_kind), or an answer from anyone but the person or the proxy, or a decline from anyone but the person (answer_unknown_source). DeliveryEngine.thread() holds such a question's answers, and the follow-ups behind them, before any destination is looked up, and reports it once (needs-attention, audited, reported to the relay as other holds are), on a fresh read under the delivery lock so a round replaced meanwhile is never held; a retry reports it again and still types nothing. A question whose earlier write may already be on screen keeps saying so instead. The entry is kept exactly as stored.
  • No fall-through to the answer block. formatAnswerNotice throws on an unsupported kind or source instead of formatting it as an answer, and delivery passes the stored source rather than mapping everything but proxy to human. get_decision reports no provenance for an answer from an unknown source, and counts only the person's confirmation of a proxy answer and only the person's decline. The legacy sealing pass leaves unsupported entries untouched.
  • A store format, refused when newer. store-format.ts adds STORE_FORMAT (1), kept in meta under store_format (missing means 0), and StoreFormatError. A release moves it on only when it starts storing something an older client may misread, with or without a schema step.
    • SqliteLocalStore refuses a user_version past its last migration, or a newer or unreadable format (a BLOB included), before it changes the file, and closes its handle. Both are read in one snapshot, and an up-to-date file is only read on open, so it opens beside a running listener's write. Otherwise it re-reads both under BEGIN IMMEDIATE, runs the missing steps and stamps the format in one transaction, so an older client never lowers a newer stamp. WAL is set after admission.
    • DecisionsBridge.start() admits a host-supplied store (admitStoreFormat) before it starts anything. A start made while another admits the store is that start's second call, a stop or revocation during admission wins, and idle() waits for every admission before the host closes the store.
    • Every CLI command opening the state directory reports cannot use …/decisions.db: the local store holds data format 2, and this client reads formats up to 1 … Upgrade this client to use it. before sealing or migrating anything.
  • Docs. The integration spec (section 7) asks Daintree's store to check and stamp the format atomically when it opens, as SqliteLocalStore does; docs/operations.md describes the refusal and says to stop running listeners before upgrading.

A client already running when a newer one opens the same directory does not check again; the delivery hold covers what it reads after that.

Testing

  • New packages/client/tests/newer-state.test.ts: an unknown kind held and reported (the reproduction failed before the change, typing the entry into the pane), reported once and again after a retry, an uncertain earlier write left uncertain, unknown answer and decline sources, later answers and follow-ups held while another question's answer is typed, sealing leaves the entry alone while sealing the rest, get_decision provenance, confirmation and decline, formatter refusal, every current writer's kind and source accepted; start() refusing a newer or unreadable format before sealing or recovery reads anything, stamping only an older or unmarked store, a stop during admission, and idle() waiting for it.
  • packages/client/tests/store.test.ts: stamping new, unmarked and migrated files; opening an up-to-date file while another connection holds a write transaction; refusing a newer schema (handle closed, rows unchanged), a newer format on the current schema and on a migratable older one (not migrated), malformed and BLOB markers (left as they were), and a newer stamp written between the first read and the write lock.
  • packages/cli/tests/cli.test.ts: status refuses a newer state directory with the error above, leaving the format and a plaintext legacy row untouched.
  • Also: a start made during another's admission shares it (one read; a refusal rejects both), and a hold whose entry was replaced while the pass waited for the lock flags nothing.
  • Own and adjacent tests (client: 15 files, 454 tests, including the delivery, advisory, expiry, decline, proxy, MCP and HTTP-listen suites; CLI: cli and ask-wait, 76 tests) and the impact set, 8 of 73 test files (10%), all pass on the final commit. No flaky or base-level failures. The package type check was not run here (no typecheck:changed script); stabilization runs it.

Open

  • A host DecisionLearner whose learn() awaits bridge.notifyPaneIdle() waits on the delivery lock the inbox holds while it calls the learner. The hold check now takes that lock too, but typing any answer already does (injectChunk), so such a learner already deadlocks on an ordinary answer; nothing here changes that.
  • The overlapping-start test passes { socket: false } to both calls, so it proves the shared admission, not that the first call's transport wins.
  • Out of scope by design: a client that already holds the store open while a newer client upgrades it does not check again (documented in docs/operations.md).

… a newer client's store

- Delivery holds an entry of an unknown kind, or an answer or decline from an
  unexpected source, and flags its question for a human instead of typing it;
  the formatter refuses such an entry rather than typing it as an answer
- get_decision never reports such an entry as the person's answer, and the
  legacy sealing pass leaves it as it is
- A store_format marker in meta: SqliteLocalStore refuses a newer schema or
  format before touching the file, DecisionsBridge.start() refuses before it
  starts anything, and the CLI reports it as a clear error
- Integration spec and operations docs describe the store format contract
- A start made while another admits the store waits for that admission and
  returns as a second call, so the first call's transport is the one used
- A hold is flagged on a fresh read under the delivery lock, so an entry a
  reopen or answer replaced meanwhile never holds the new round
- Tests cover both, and an ASCII-digit BLOB marker
@gregpriday
gregpriday merged commit 66eaedd into develop Nov 19, 2026
2 checks passed
@gregpriday
gregpriday deleted the bugfix/issue-186-an-older-client-types-a-newer-state branch November 19, 2026 14:35
@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.

An older client types a newer state directory's timeouts as human answers

1 participant