Refuse to save or resume a work session when the account changed while gathering (CLS-1264) #320

Merged
stephen merged 3 commits from cls-1264-work-snapshot into main 2026-11-12 01:42:11 +00:00
Owner

CLS-1264, work-session half (the race noted on #317): fj work context and fj work resume now resolve the account and instance identity before and after their API reads. If it changed, they fail with "the selected account or instance changed while gathering; nothing was saved. Run it again." context keeps the old session file; resume prints nothing. continue is offline and resolves once, so it has no window.

Scope: only the work-session path. The wider issue (routing, Client::connect, browser metadata and mute scope loading config separately in every command) needs one resolved snapshot carried through the client, which touches many files; it stays open on CLS-1264.

Failure paths

  • A switch that lasts through the gather is refused for both commands (test: a held repository read, the default account switched once the server has received the request, asserted for resume output empty and context leaving the previous session byte-identical).
  • A stable run still saves (same test, first step).
  • Identity unresolvable: unchanged (warning, nothing saved).

Known limits

  • This detects, it does not carry one snapshot: a switch away and back inside the window (A to B to A), or one between the first check and Client::connect's own config load, is not seen. Self-review repeated this Low twice; closing it needs the client to return the identity it connected as.
  • Self-review rounds: 2 of 3. The last edit (a bound on the test's poll loop) was not re-reviewed.
  • Local clippy stops at pr_line_comment.rs:65 (newer toolchain); CI pins 1.95. 103 gross lines.
CLS-1264, work-session half (the race noted on #317): `fj work context` and `fj work resume` now resolve the account and instance identity before and after their API reads. If it changed, they fail with "the selected account or instance changed while gathering; nothing was saved. Run it again." `context` keeps the old session file; `resume` prints nothing. `continue` is offline and resolves once, so it has no window. Scope: only the work-session path. The wider issue (routing, `Client::connect`, browser metadata and mute scope loading config separately in every command) needs one resolved snapshot carried through the client, which touches many files; it stays open on CLS-1264. **Failure paths** - A switch that lasts through the gather is refused for both commands (test: a held repository read, the default account switched once the server has received the request, asserted for resume output empty and context leaving the previous session byte-identical). - A stable run still saves (same test, first step). - Identity unresolvable: unchanged (warning, nothing saved). **Known limits** - This detects, it does not carry one snapshot: a switch away and back inside the window (A to B to A), or one between the first check and `Client::connect`'s own config load, is not seen. Self-review repeated this Low twice; closing it needs the client to return the identity it connected as. - Self-review rounds: 2 of 3. The last edit (a bound on the test's poll loop) was not re-reviewed. - Local clippy stops at `pr_line_comment.rs:65` (newer toolchain); CI pins 1.95. 103 gross lines.
gerri approved these changes 2026-11-12 01:11:39 +00:00
gerri left a comment

Automated Codex review (read-only) of head d24049d827.

No new actionable findings against STANDARDS.md.

  • Low (edge case), src/cli/work.rs:537: The invariant is that saved or displayed data belongs to the checked identity. The PR’s accepted “Known limits” remain: an A-to-B-to-A switch or a switch before the client’s separate config load can evade detection in both context and resume. Carrying one resolved identity through client creation and gathering fixes these deferred races.

Tests were inspected, not run, per the read-only review constraints.

BLOCKING: 0

Reviewed head d24049d827 at 2026-11-12T01:11:38Z by codex exec (read-only sandbox).

Automated Codex review (read-only) of head d24049d8271be2e156914beaed5626a440245f2c. No new actionable findings against STANDARDS.md. - **Low** (edge case), `src/cli/work.rs:537`: The invariant is that saved or displayed data belongs to the checked identity. The PR’s accepted “Known limits” remain: an A-to-B-to-A switch or a switch before the client’s separate config load can evade detection in both `context` and `resume`. Carrying one resolved identity through client creation and gathering fixes these deferred races. Tests were inspected, not run, per the read-only review constraints. BLOCKING: 0 --- Reviewed head d24049d8271be2e156914beaed5626a440245f2c at 2026-11-12T01:11:38Z by codex exec (read-only sandbox).
Sign in to join this conversation.
No description provided.