Skip to content

Tests: journal replays reproduce File Info's dates; the MCP connect test holds its own port - #91

Merged
bflatastic merged 2 commits into
mainfrom
pr/flaky-clock-and-port-tests
Oct 5, 2026
Merged

bflatastic merged 2 commits into
mainfrom
pr/flaky-clock-and-port-tests

Conversation

@bflatastic

Copy link
Copy Markdown
Member

Fixes three tests that failed at random in CI, two caused by File Info's clock dates (#77) and one by a port race, and a fourth that was silently skipping cases whenever the clock ticked.

  • M4.55: a journal replay reproduces File Info's dates.
    • Cause: file.new and saves read their dates from the clock. A journal replayed a second later therefore rebuilt a different document, which failed journal_replay_reproduces_document, rich_fixture_satisfies_invariants_and_undoes_to_blank and, latently, known_bugs::bug_nested_commands_double_journal.
    • One approach: a date is a command input that defaults to now, and the journal records the value actually used.
    • Actions: recorded actions use Session::journal_for_action, which leaves these dates out (REPLAY_ONLY), so playing an action later dates the document then.
    • Test fixtures: fixture documents get a fixed date (fixtures::CREATED).
    • A hidden skip: mcp/tests/protocol_props.rs::run_command_sequences_match_local_session used to skip any case where the clock ticked. It now dates its local document like the headless one, and every case is compared.
  • M1.9: remote_connect_fails_fast holds its own closed port.
    • Cause: the test bound a port and dropped it, so another process could take it.
    • Fix: it now holds a bound but not listening socket, so connections are refused and nothing else can bind the port. It also checks the failure comes within 5 s.
    • New dependency: this needs socket2 0.6 (MIT OR Apache-2.0), as a test-only dependency of vectorcraft-mcp.

Known limit: a file.new or save inside command.batch doesn't get its date recorded, the same existing limit as the recorded preference values.

Checks

Rebased onto 53f4279 (#90). cargo xtask ci passes all 7 steps (fmt, clippy, test, assets, brands, layers, wasm): 2,334 tests, 0 failed.

  • Each flake reproduced first:
    • a forced 1.1 s sleep failed the clock tests every time;
    • re-binding the port failed the MCP test.
  • After the fix:
    • journal replay passed 25 runs × 96 cases;
    • the MCP suite passed 100 runs.
  • Nothing dropped:
    • every test name on main still exists, with five added in tests_journal.rs;
    • command ids, UI_COMMANDS, menu entries and MCP tools are unchanged.
  • Changed test bodies: remote_connect_fails_fast and run_command_sequences_match_local_session.

🤖 Generated with Claude Code

bflatastic and others added 2 commits October 5, 2026 11:41
File Info's dates come from the clock, so documents made or saved a second
apart differed: journal_replay_reproduces_document and
rich_fixture_satisfies_invariants_and_undoes_to_blank failed at random.
One approach for every clock-derived date: it is a command input that
defaults to now, and the journal records the value used.

- file.new takes created? and document.save / file.saveAs take modified?
  (Unix seconds, or null for none; default now), through date_param /
  clock_date on the one save path (save_with), so Save, Save As and the
  UI's save stamp alike; Save a Copy still leaves the dates.
- Their journal entries always record the date used, so replaying the
  journal makes the same document whenever it runs. Actions recorded from
  the journal (Session::journal_for_action) leave those dates out, so
  playing an action later dates the document then.
- Test fixtures date their documents fixtures::CREATED, and the MCP
  property test dates its local document as the headless one, so
  documents built at different moments compare equal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
remote_connect_fails_fast bound a port and dropped it, so another test or
process could take the port before the connect and make it succeed. It now
holds a socket bound without listening (socket2, a test-only dependency):
connections to it are refused and nothing else can bind it meanwhile. It
also checks the failure comes within 5 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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