ADR-0017 — Fence scope and what the loser sees
- Status: Accepted
- Date: 2026-11-13
- Supersedes: none
- Authors: project maintainers
Context
Two concurrent runs on one thread fork it, whatever the saver does (write-ordering.md). The second-writer fence stops the second writer. It must not refuse what upstream's conformance suite does, time travel, deliberate forks, or a resume after upstream's saver wrote the thread during a rolling deploy.
Decision
A root-namespace put carrying a read's token will be admitted only forward from the head, from
the read when nothing of ours wrote since, idempotently, or as a thread's first write. A put
without a token is admitted. A refused put writes nothing and raises ThreadConflictError, which
the saver does not retry. The documentation names durability="sync" as the way to stop a loser's
side effects.
Alternatives considered
- Compare-and-set for
loopputs, token for the rest — rejected: it refuses a resume after an upstream write in a rolling deploy and depends on thesourcemetadata. - Every parented put must have the head as parent — rejected: it refuses time travel and forks and fails upstream's conformance suite.
- More alternatives are in fence-and-expiry.md §2.7.
Consequences
- Upstream's conformance suite passes unchanged; token-less callers and races on a brand-new thread are not fenced.
- The check is a few CTEs inside the existing single
putstatement, soputstays one round trip. - Under
asyncdurability, a loser's node side effects may already have happened before itsputis refused.