Five Macroscope findings on the media push, all confirmed against the
code:
- adapter.py _start_turn: a failure in the awaits after registering the
turn left a phantom entry that rejected every later turn.start on the
thread and advertised a stale activeTurnId on reconnect. The entry is
now removed on any exception, guarded on identity so a replacement
installed by an error path keeps ownership.
- home.py queue: a transient read error made append() see an empty queue
and rewrite the file, destroying every unacknowledged delivery. Read
errors now propagate; append falls back to a single O_APPEND write (cap
briefly unenforced — recoverable; a destroyed outbox is not), purge
declines to rewrite (the entry replays once and dedupes server-side).
- adapter.py deliveries (text and media): the queue append's return was
discarded, so an unpersisted delivery reported success — and media
could complete its turn — even when the live send also failed. Success
now requires either leg: queued-and-unsent rides the next connect,
sent-but-unqueued is already at T3.
- home.py permissions: the outbox (which now carries base64 media
payloads, not just text) was 0644 in 0755 under a default umask. Queue
file, temp file, append path, and lock sidecar are 0600 in 0700.
- hermesGatewayHttp dedupe: alreadyDelivered read through
getThreadDetailById, which filters archived threads — an archived Home
with a failed best-effort unarchive made every retry of a deliveryId
append a fresh duplicate. Dedupe now uses a purpose-built
hasThreadNotificationDelivery on projection_thread_messages with no
archive filter and json_extract on the deliveryId, so a match in a
message body cannot false-positive.
Skipped (documented on the PR): Windows lock no-op (unsupported host,
pre-existing), whole-file read in build_media_delivery (the read is the
25MB check), MAX_FLUSH_PER_CONNECT bound (deliberate), bytes-based queue
cap (design change nothing warrants yet).
Plugin tests 150 across four files; server suites green.
Co-Authored-By: Claude Fable 5 <[email protected]>