Skip to content

refactor: keep each call's state in one atomic record (WT-1138) - #364

Merged
SERDUN merged 5 commits into
developfrom
refactor/tracker-callrecord
Aug 18, 2026
Merged

refactor: keep each call's state in one atomic record (WT-1138)#364
SERDUN merged 5 commits into
developfrom
refactor/tracker-callrecord

Conversation

@SERDUN

@SERDUN SERDUN commented Aug 18, 2026

Copy link
Copy Markdown
Member

Overview

The main-process call-state tracker kept the facts about one call spread across eight separate collections. Each collection was thread-safe on its own, but a lifecycle transition updated several of them one after another, so a reader could in principle observe a call halfway through a change - for example, a call being resurrected after a transfer-back briefly looked terminated. Nothing hits this today because all writes are serialized, but it was a standing trap for any future code that reads from another thread.

All per-call state now lives in a single immutable record, and every transition replaces that record in one atomic step: a reader always sees a consistent snapshot, and different calls never block each other. Behaviour is deliberately unchanged - the record's fields mirror exactly the facts the old collections kept, including the deliberately sticky ghost-call guard and the ability of a call to be registered and pending at the same time during a push-path re-registration.

Verification: the full native suite, including the recently added pinning tests for this layer's subtle semantics, passes without a single test being modified; each pinning test was also re-proven to fail against this implementation when the line it guards is broken.

SERDUN added 5 commits August 18, 2026 14:44
The tracker used to spread one call's state across eight separate
collections; each was safe on its own, but a transition touched several of
them one after another, so a reader could in principle catch a call halfway
through a change. All facts about a call now live in a single immutable
record, and every transition replaces that record in one atomic step, so any
reader always sees a consistent picture. Behaviour is intentionally
unchanged: the full test suite, including the recently added pinning tests
for the layer's subtle semantics, passes without modifying a single test.
The record describing one call's complete state now lives beside the other
core-layer classes instead of being nested inside the tracker, so its
documentation stands on its own and the tracker file stays focused on the
transitions. Only the tracker can still create or store records.
The layer document still described the eight separate collections this
change replaces. It now describes the single per-call record, the atomic
transitions, and what deliberately remains non-atomic, and its test-coverage
section reflects the pinning tests that now guard the layer - so the
document and the code ship in the same change and never disagree on develop.
Four areas of the call-state layer had no direct coverage: the window where
a call the app already knows is registered a second time by the push path,
the dispatch guards that survive a call's termination, the mid-call metadata
merge, and - the point of the record rework itself - that a reader can no
longer catch a call halfway through a transition. Ten tests pin them now,
each proven to fail when the behaviour it guards is broken; the concurrency
one also fails against the previous implementation, demonstrating the race
the rework closed. The re-registration tests double as a tripwire for the
planned tightening of that window: changing it will turn them red on purpose.
@SERDUN
SERDUN merged commit ac6c07d into develop Aug 18, 2026
2 checks passed
@SERDUN
SERDUN deleted the refactor/tracker-callrecord branch August 18, 2026 13:44
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