Skip to content

docs(design): the threading cutoff is measured per instance from the first rooted reply - #1147

Merged
lilyshen0722 merged 3 commits into
mainfrom
threading-cutoff-per-instance
Aug 22, 2026
Merged

lilyshen0722 merged 3 commits into
mainfrom
threading-cutoff-per-instance

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Matches the ruling doc to TASK-046's revised remedy (pod 57395), replacing the "constant" paragraph from #1131.

  • A hardcoded deploy instant is wrong for self-hosted instances — the backfill script's own header said so.
  • MAX(created_at) over un-rooted edges is poisoned by retention orphans (sprint-review 57205).
  • MIN(created_at) over messages with a reply edge AND a root is exact per instance and orphan-immune; the un-rooted MAX stays only as the --derivation-live fallback. Written once, ON CONFLICT DO NOTHING.
  • 2026-08-22T16:01:52Z becomes this instance's cross-check, not the source.

Docs only, one paragraph. The script change is TASK-046 (pod-architect).

🤖 Generated with Claude Code

…first rooted reply — not hardcoded, not from the un-rooted set

TASK-046 / pod 57395. A hardcoded deploy instant is wrong for self-hosted
instances (the script's header was right); MAX over un-rooted edges is
poisoned by retention orphans. MIN(created_at) over replies that carry a
root is exact per instance and orphan-immune; the un-rooted MAX remains
only as the --derivation-live fallback. The 16:01:52Z instant becomes the
cross-check for this instance, not the source.

Co-Authored-By: Claude Fable 5 <[email protected]>
…orded boundary is never re-measured

Co-Authored-By: Claude Fable 5 <[email protected]>
…f never reaches a client (#1145)

Reverses the one-timestamp wire shape recorded after 57132. pod-architect
built the server-resolved form in #1145 and retracted the O(1) argument
that had justified the other: the join is bounded by thread count, and a
migration detail in every future client is the worse cost. following
stays raw tri-state on the wire — NULL is a value the wake path resolves;
the header toggle renders three states without computing participation.

Co-Authored-By: Claude Fable 5 <[email protected]>
(cherry picked from commit b234d10)
lilyshen0722 added a commit that referenced this pull request Aug 22, 2026
…toff, not the newest un-rooted one (TASK-046) (#1148)

* fix(threading): the backfill records the first rooted reply as the cutoff, not the newest un-rooted one (TASK-046)

The 22:28Z dry run on the live pod recorded cutoff 12:21:11Z — MAX(created_at)
over un-rooted edges, which is poisoned by retention orphans (a descendant of
a deleted root keeps a live parent and loses its root, so a recent orphan sets
the boundary late). A hardcoded deploy instant is no better: it is wrong on
every self-hosted instance that ships derivation on a different day, as the
script's own header already said.

The boundary that survives both: MIN(created_at) over messages that have a
reply edge AND a root — the first reply derivation-on-write ever wrote, exact
to within one reply, per instance, orphan-immune. The newest un-rooted reply
remains only as a fallback when no rooted reply exists, and only behind
--derivation-live; otherwise --apply refuses with exit 3, because without a
rooted reply there is no evidence derivation is deployed and ON CONFLICT DO
NOTHING would freeze a wrong boundary. The ledger row now records which source
produced the value (cutoffSource).

Also removes the header sentence the ruling rejected — a MISSING ledger row is
unknown and expands; a NULL cutoff in a written row is knowledge.

Tests: the three pinning suites flipped to the new contract (36 passing);
tsc:check clean. Ruling text: docs/design/threading-surface-ruling.md (#1147).

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(threading): the backfill's UPDATE and ledger INSERT are one transaction

sprint-review (TASK-046 note): losing the INSERT after the UPDATE leaves
every chain rooted and no cutoff recorded, and 'the backfill always writes
the ledger row' is the only remaining guarantee between a partial run and a
permanently unknown cutoff. BEGIN before the UPDATE, COMMIT after the
INSERT, ROLLBACK on error, on a dedicated client. Pinned by ordering test.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(threading): the backfill reads the ledger first and never re-measures a recorded boundary

sprint-review (57397): after the backfill every pre-threading reply carries
a root, so MIN over rooted replies returns the oldest reply ever written —
a plausible wrong answer. A run that finds the ledger row reports it and
stops before the population count and before CUTOFF_SQL; the recorded
value is the only true boundary. Pinned by ordering test.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(threading): the dry run prints the rooted-reply count so a fallback cutoff shows its cause

sprint-review (57398): on an instance with no reply written since
derivation deployed, the primary MIN is NULL and the gated fallback
yields the newest un-rooted reply. The dry run now prints how many
derivation-written replies exist, so an operator sees why the fallback
fired before deciding on --derivation-live.

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
@lilyshen0722
lilyshen0722 merged commit 32f5148 into main Aug 22, 2026
10 checks passed
@lilyshen0722
lilyshen0722 deleted the threading-cutoff-per-instance branch August 22, 2026 23:01
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.

1 participant