fix(sessions): re-review fixes for MMDB-2925 (PR #29 review round 2)

Round 2 of adversarial review confirmed defects 2,3,4,5,7 fixed and
raised three new ones; all three are fixed here, plus the guard-message
nit.

NEW-1 (the FAIL driver): the OneDrive send path overwrote the truthful
status from handleDidShareItems with its own success text, silently
dropping an archive failure and any state-refresh problem. The seam now
takes the caller's success summary and composes ONE truthful message:
summary (the share itself did complete) + archive error if any + refresh
problems if any. Both callers (AirDrop delegate, OneDrive) pass their
summary; the OneDrive text is never clobbered.

NEW-2: if the replacement open session could not be created after the
archive rename (disk full), the store kept reporting the already-archived
session as the open one. SpoolStore now has a truth guard
(ensureOpenSession): the open session is verified to really exist on disk
and be in state .open before any read/mutate; a stale one is replaced by
a genuinely fresh session, or the call fails loudly. Never a lie.

NEW-3: archivedSessions() read the folder tie-break dates AFTER
reconciliation, so a healed same-second session could bump its own
modification date and outrank a genuinely newer peer. The dates are now
read BEFORE reconciling.

Nit: the startNewSession guard now reports "A new session is already
being started." when the refusal is about a concurrent session start,
not a send.

Also added REDLINE_SELFTEST_PHASE=sendtruth (mirroring the existing
=onedrive escape hatch) so the SEND-TRUTH selftest can run without the
picker chain's display-dependent REGION-PERSIST phase.

Evidence: 136 swift tests pass (2 new: OneDrive summary survives
archiving; stale open session never returned as current).
REDLINE_SELFTEST_PHASE=sendtruth -> SEND-TRUTH PASS.
REDLINE_SELFTEST_PHASE=onedrive -> ONEDRIVE-SELFTEST PASS against the
real OneDrive sync root.
This commit is contained in:
Claude Fable 5
2026-10-11 13:58:45 +04:00
parent eaa5bd5884
commit 0506ce04e9
7 changed files with 148 additions and 30 deletions
+1 -1
View File
@@ -426,7 +426,7 @@ public final class AppModel {
// the menu's `.disabled` state cannot stop a Task that was queued just before
// a send started.
guard !isSending, !isStartingNewSession else {
setStatus("Finish the current send first.")
setStatus(isSending ? "Finish the current send first." : "A new session is already being started.")
return
}
isStartingNewSession = true