← Back to Pull requests

fix(sessions): publish each session transition after its own save #1352

Open
unknown opened this pull request with 262 lines diff across 3 files
View on GitHub
unknown unknown commented on Dec 03, 2026 18:57 UTC
Author

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 to SessionStore.

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 SessionPersistence unchanged.

Out of scope

Write retries: #1338.

Proposal

Each transition carries isPersistenceAttempted (SessionManager.swift:16). SessionStore releases 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.

written by billy's 🤖

Diff: 262 lines (+196 / -66) across 3 files Reviewer: aranhave Review duration: 2186m
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
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
46%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 46.7% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 39.3% (MEDIUM) · Higher = larger blast radius
39.3%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 46.7% · Lower = rushed or shallow review
46.7%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 20.9% · Safe to merge
20.9%