Skip to content

Reliability: remembered handshake bound, merged gap markers, ordered writes - #25

Merged
9clg6 merged 15 commits into
mainfrom
oats-reliability-5
Nov 23, 2026
Merged

9clg6 merged 15 commits into
mainfrom
oats-reliability-5

Conversation

@9clg6

@9clg6 9clg6 commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

What

  • A new outage starts with the handshake bound that last succeeded for that source; a fast accept brings it back to 10 s; a new session starts again at 10 s.
  • Gap markers of one source never overlap: a gap touching an existing marker is merged into it under the first marker's id. The union is stored first (retried if the write fails), absorbed markers are removed after.
  • The backfill plans stored markers by union, so overlapping markers left on disk by a kill are recovered once.
  • Segment writes are chained per segment id and survive a failed earlier write, so a sentence re-stamped with its gap start cannot be overwritten by its earlier, slower write.
  • saveSegment reports whether the segment was stored.

Checked

  • Tests: app 1734, core_data 162, core_domain 58; analyze clean; debug build.
  • Specs replay sequences and a stored end state recorded against the real transcription server.

Not checked

  • These changes against the real server.

Clement Guyon added 15 commits November 23, 2026 03:25
…st succeeded

Probe 7: outages of 22.5 / 25.5 / 55.5 s for accepts of 12 / 15 / 25 s,
because the bound restarted at 10 s after each successful reconnection.
The round-8 spec "a new outage starts again at 10 s" is changed: with the
same slow server (15 s) the next outage needs one attempt and lasts about
the accept delay. New guard: after a fast accept the bound is back to 10 s.
…t worked

Why: the bound restarted at 10 s after each successful reconnection, so
a slow server cost one failed attempt per outage (probe 7: outages of
22.5 / 25.5 / 55.5 s for accepts of 12 / 15 / 25 s).

What: per source, a successful reconnection records its bound when the
accept took longer than 10 s, and 10 s when it was faster; a new outage
starts from it. Still one attempt at a time, doubled after an expiry,
60 s at most. The accept speed is measured with a timer so it follows
fake time in tests.

How proven: slow_accept specs green (same slow server: one attempt,
outage about the accept delay; after a fast accept back to 10 s),
connect timeout and client specs green.
Why: three losses declared at the same instant left three nested markers
in the note (probe 7), and the re-stamp of a sealed sentence was not
chained after its first save: with a slow write the sentence ended at its
arrival time instead of the gap start.

What:
- _writeGapMarker is the only writer of gap markers: a loss touching or
  overlapping markers of the same source merges them into one, the
  union, under the first marker's id; the others are removed from the
  database and the screen. Sources never merge.
- Writes are chained per segment id (_chainWrite), so the last intended
  value of a segment always lands last; _savePartial, the re-stamp and
  marker merges go through it.

How proven: gap_marker_merge and restamp_write_order specs green (both
completion orders); sealed_partial_time and late_done_after_gap green;
services suite green (899).
Why: the provisional marker is written outside the live merge, and a
kill during an outage can leave overlapping markers on disk (probe 7);
plan() trusted what was stored and planned nested intervals twice.

What: plan() merges the gap markers of one source that overlap or touch
into unions: one interval under the first marker, the end of the latest;
the absorbed markers go into replacedIds and are removed when the union
is recovered. The extension of an interval to the next intact segment
stops where the next union of the source starts, so no audio is
transcribed twice. The end-edge exception uses the union's end.

How proven: gap_backfill_overlapping_markers (probe-7 stored state) green;
time edges, edge exception, backfill, overlap, sealed partial and marker
merge specs green (39).
Why: the union of overlapping losses and the removal of the absorbed
markers ran on different chains, and a failed earlier write for an id
skipped every later write for it: an interval could be left with no
marker.

What: the union write waits for pending writes of the absorbed markers,
saves the union (retried 1, 2, 4, 8 s; saveSegment now says whether it
stored), and only then removes the siblings. _chainWrite logs a failed
write and still runs the next one for that id.

How proven: gap_marker_merge_atomic (failing and held repository) green
with gap_marker_merge, restamp_write_order and sealed_partial_time (11);
core_domain 58 green.
Why: the app lives in the menu bar for days; a slow server learned in
one session made every later session wait up to 60 s for a dead socket.

What: connect() resets the learned slow-accept count of both sources.

How proven: transcription_remote_data_source_slow_accept green (7).
Why: five attempts then a logged give-up is a deliberate shortcut; Stop
may wait up to 15 s more on a failing disk.

What: ponytail comment only. How proven: analyze clean.
@9clg6
9clg6 merged commit b61e14f into main Nov 23, 2026
2 checks passed
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