Skip to content

fix(rooms): read a candidate with its own room's round, or with none (#293) - #311

Merged
memtomem merged 1 commit into
mainfrom
fix/room-candidate-round-binding
Nov 14, 2026
Merged

memtomem merged 1 commit into
mainfrom
fix/room-candidate-round-binding

Conversation

@memtomem

Copy link
Copy Markdown
Owner

Closes #293.

Problem

RoomStore._list_candidates joined candidates to rounds on round_id alone:

  • a candidate whose round_id named another room's round was listed with that round's number;
  • a candidate whose round was gone disappeared from the listing.

Every reader working from those rows (repair parent order, branch/continued parents, feedback evidence, the delta watermark, the conversation and provenance validators) took the borrowed number at face value. The artifact path refused only one of the four damage shapes.

Change

Read model. LEFT JOIN rounds r ON r.id = c.round_id AND r.room_id = c.room_id: the candidate stays listed and its round_number is NULL, the existing "round not recorded" shape the numeric readers already skip.

One rule per fact. Whoever writes a round record now decides with the function its validator reads it with:

Writer Validator function it now uses
checkpoint builder (_checkpoint) checkpoint_eligible
delta watermark in run_round last_completed_round
repair guard (_repair_parent_problem) _repair_parent_tree_problem + _newer_completed
branch-from (preflight_round, and run_round before _cleanup_workspaces) _branch_tree_problem

Before this, a NULL or renumbered candidate made a cold round's checkpoint disagree with its record, and the round froze as recovery_required before any provider ran. A branch base the record would reject was only refused after the room's workspaces had been removed. _continued_parents keeps its own code: it emits only an exact previous-round match or None, which its validator always accepts.

Unknown order. A completed candidate with no recorded round makes its member's order unknown. Neither the repair guard nor the repair record accepts a parent for that member.

Artifact binding. Loading a candidate also requires its round to exist in the same room (RoomStore.round_room_id). All four shapes are now refused on the artifact path: row repointed, dangling, round moved, round deleted.

Surfaces.

  • room compare adds a damaged entry for a candidate outside the room's rounds. The entry shape and JSON fields are unchanged.
  • room candidates prints an unreadable candidate on its own line, lists the rest, and exits 1.
  • The TUI shows a RoomError from the candidate's own row or artifact as "unreadable" in that pane only, never cached, while the room's other panes refresh. Store failures still degrade the whole room. The candidate cache key now carries round_id and the round's room.

Tests

  • tests/test_room_round_binding.py (new, 15) uses a real RoomStore damaged by SQL. It covers:
    • the issue's reproduction, dangling/moved/deleted rounds;
    • cold and resumed rounds beside damage, including a round renumbered to 100;
    • the repair guard and its record agreeing (unknown order, past the next round);
    • branch-from refusing in preflight and again after a post-preflight change, with workspaces intact;
    • compare's damaged entry and the CLI exit.
  • tests/test_tui.py (+5): unreadable pane with other panes refreshing; uncached re-read and recovery; round moved or vanished; candidate repointed to another round; row read failure; Diff→Output after a bad patch.
  • Existing checkpoint tests only gained the new round_number= argument. The frozen prompt golden, frozen room fixtures and persisted-contract pins pass unmodified.

Each new guard was removed one at a time (19 mutations); every removal fails a test. Full hermetic suite clean locally; ruff clean. Codex design review: 2 rounds NEEDS-FIX, then an unprimed SHIP. Implementation review: round 1 NEEDS-FIX (all fixed), round 2 SHIP.

🤖 Generated with Claude Code

…293)

A candidate whose round_id named another room's round was listed with
that round's number, and one whose round was gone vanished from the
listing. Every reader that orders candidates by round took the borrowed
number at face value.

- The candidate listing joins its round only within the same room;
  otherwise round_number is NULL, the existing "round not recorded"
  shape the numeric readers already skip.
- Whoever writes a round record decides with the function its validator
  uses: the checkpoint with checkpoint_eligible, the delta watermark with
  last_completed_round, the repair guard with _repair_parent_tree_problem
  and _newer_completed, branch-from with _branch_tree_problem. A cold
  round beside a damaged candidate no longer freezes as recovery_required,
  and a branch base the record would reject is refused before any
  workspace is removed.
- A completed candidate with no recorded round makes its member's order
  unknown, so neither the guard nor the record accepts a repair there.
- Loading a candidate's artifact also requires its round to exist in the
  same room.
- room compare reports a candidate outside the room's rounds as damaged.
- room candidates prints an unreadable candidate on its own line, lists
  the rest and exits 1; the TUI shows it as unreadable in that pane only
  (never cached) while the room's other panes refresh, and its cache key
  carries the round binding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@memtomem
memtomem merged commit 157b777 into main Nov 14, 2026
12 checks passed
@memtomem
memtomem deleted the fix/room-candidate-round-binding branch November 14, 2026 22:44
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.

A candidate whose round_id names another room's round is read with that round's number

1 participant