fix(sessions): publish each session transition after its own save #1352
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 262 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.333
Real PR Conversation Timeline
1 comments
"Review active on #1352"
general
weight: 0.35
aranhave
Publish each session transition after its own save
Author: @williazz · Status: ready for review · Follow-up to #1338
Background
!Two timelines. Top, main: a reset queued behind a paused callback and a blocked write is published while storage still holds the previous session. Bottom, this PR: it publishes only after its own write.
On
main, only the caller holding the publishing claim passes a publish hook toSessionStore.Problem statement
A queued reset or end publishes before its write (diagram, top).
A solution must:
1. Publish each transition after its own save or clear is attempted, in order.
2. Keep one synchronous publication per caller.
3. Keep public APIs and
SessionPersistenceunchanged.Out of scope
Write retries: #1338.
Proposal
Each transition carries
isPersistenceAttempted(SessionManager.swift:16).SessionStorereleases a follow-up only after a write covering its change, backing off past the four-write limit, and acknowledges a batch before running it (SessionStore.swift:407-487). Regression tests reproduce each race (SessionEndTests.swift:286-716, SessionStoreTests.swift:686).Alternate solutions
Do nothing
Exporters see sessions start before they are saved.
Glossary
Claim: the flag whose holder publishes queued transitions.