Scope saved work sessions to the account and instance (#157 step 2b-iv) #317

Merged
stephen merged 5 commits from fj-157-work-sessions into main 2026-11-11 17:38:17 +00:00
Owner

Step 2b-iv of #157: a saved work session now belongs to one host, account and Fjord instance, so fj work resume and fj work continue cannot show or advance another account's snapshot. Lead decision: refuse on a mismatch.

Behavior

  • fj work context resolves its destination once (--host, else the clone host routed through the selected account, else the configured default or sole host; -R ignores the clone host, as the other repo commands do). That one target feeds the account display, the API client, the saved host and the saved identity.
  • The session stores an opaque SHA-256 digest of host, account and instance (identity, none for the legacy default) and whether it was saved with -R. No login name is written to disk or printed.
  • resume and continue (and their --dry-run) compare the digest before showing or writing anything and refuse with "the saved work session belongs to a different account or instance ... Run fj work context". continue follows how the session was saved (-R or not).
  • Old session files parse as the legacy identity: valid with no account selected, refused when an account is selected. A routing refusal (account does not match the clone's instance) is an error, never a fall back to another host. An account selected with no resolvable host is refused, not saved as legacy.
  • docs/account-override.md updated.

Failure paths (STANDARDS)

  • Refused resume or continue writes nothing: asserted by comparing session.json bytes.
  • Identity or routing cannot be resolved: resume and continue fail; context prints "work session not saved" and leaves the old file.
  • Concurrency: see the known limit below.
  • Tests (tests/work_session_identity.rs, 5, plus unit tests in work_session.rs): account A saved, B refused for resume, continue and continue --dry-run, A still advances; legacy valid only for legacy; clone host differs from default host; -R with continue and --json host; sole host without current; old JSON parses; no login name in session or error.

Known limits, not fixed here

  • The three self-review rounds are spent. The last commit (resolved host for display and saved data; continue following -R) was not re-reviewed locally; gerri reviews the PR.
  • A switch of account or instance by another process while work context awaits API reads can save the old data under the new digest (same family as CLS-1264). The race window is the API reads; carrying one resolved target through gather and save would narrow it but not close it without a config generation check.
  • continue for a session saved with -R follows the saved flag; resuming one without -R resolves from the clone host and may refuse. Pass -R again.
  • Local clippy stops at src/cli/pr_line_comment.rs:65 (newer toolchain); CI pins 1.95. Size: 377 gross lines (cap 500).
Step 2b-iv of #157: a saved work session now belongs to one host, account and Fjord instance, so `fj work resume` and `fj work continue` cannot show or advance another account's snapshot. Lead decision: refuse on a mismatch. **Behavior** - `fj work context` resolves its destination once (`--host`, else the clone host routed through the selected account, else the configured default or sole host; `-R` ignores the clone host, as the other repo commands do). That one target feeds the account display, the API client, the saved host and the saved identity. - The session stores an opaque SHA-256 digest of host, account and instance (`identity`, none for the legacy default) and whether it was saved with `-R`. No login name is written to disk or printed. - `resume` and `continue` (and their `--dry-run`) compare the digest before showing or writing anything and refuse with "the saved work session belongs to a different account or instance ... Run `fj work context`". `continue` follows how the session was saved (`-R` or not). - Old session files parse as the legacy identity: valid with no account selected, refused when an account is selected. A routing refusal (account does not match the clone's instance) is an error, never a fall back to another host. An account selected with no resolvable host is refused, not saved as legacy. - docs/account-override.md updated. **Failure paths (STANDARDS)** - Refused resume or continue writes nothing: asserted by comparing session.json bytes. - Identity or routing cannot be resolved: resume and continue fail; context prints "work session not saved" and leaves the old file. - Concurrency: see the known limit below. - Tests (tests/work_session_identity.rs, 5, plus unit tests in work_session.rs): account A saved, B refused for resume, continue and `continue --dry-run`, A still advances; legacy valid only for legacy; clone host differs from default host; `-R` with `continue` and `--json` host; sole host without `current`; old JSON parses; no login name in session or error. **Known limits, not fixed here** - The three self-review rounds are spent. The last commit (resolved host for display and saved data; `continue` following `-R`) was not re-reviewed locally; gerri reviews the PR. - A switch of account or instance by another process while `work context` awaits API reads can save the old data under the new digest (same family as CLS-1264). The race window is the API reads; carrying one resolved target through gather and save would narrow it but not close it without a config generation check. - `continue` for a session saved with `-R` follows the saved flag; resuming one without `-R` resolves from the clone host and may refuse. Pass `-R` again. - Local clippy stops at `src/cli/pr_line_comment.rs:65` (newer toolchain); CI pins 1.95. Size: 377 gross lines (cap 500).
gerri approved these changes 2026-11-11 17:14:44 +00:00
Dismissed
gerri left a comment

Automated Codex review (read-only) of head 3b9b985393.

  • Low (edge case), src/cli/work.rs:513: Invariant: gathered data and persisted identity must describe the same target (STANDARDS 7, 17). As acknowledged under “Known limits,” context resolves identity again after API reads. Another process switching the default account or instance during those reads can save the previous target’s snapshot under the new identity, allowing the new account to resume it. Both resume modes and continue modes trust that persisted digest. Carry the resolved target through gathering and saving, and check a configuration generation before persistence. This remains an accepted follow-up.

No additional confirmed correctness or security findings. Review used read-only inspection; tests were not run.

BLOCKING: 0

Reviewed head 3b9b985393 at 2026-11-11T17:14:43Z by codex exec (read-only sandbox).

Automated Codex review (read-only) of head 3b9b985393a9d0a12e48e89c113dbae3196363ca. - **Low** (edge case), `src/cli/work.rs:513`: **Invariant: gathered data and persisted identity must describe the same target** (STANDARDS 7, 17). As acknowledged under “Known limits,” context resolves identity again after API reads. Another process switching the default account or instance during those reads can save the previous target’s snapshot under the new identity, allowing the new account to resume it. Both resume modes and continue modes trust that persisted digest. Carry the resolved target through gathering and saving, and check a configuration generation before persistence. This remains an accepted follow-up. No additional confirmed correctness or security findings. Review used read-only inspection; tests were not run. BLOCKING: 0 --- Reviewed head 3b9b985393a9d0a12e48e89c113dbae3196363ca at 2026-11-11T17:14:43Z by codex exec (read-only sandbox).
Elide the clone_remote lifetime for clippy
All checks were successful
ci / check (pull_request) Successful in 12m44s
ci / live-e2e (pull_request) Successful in 2m57s
ci / coverage (pull_request) Successful in 3m15s
d7652230df
gerri approved these changes 2026-11-11 17:21:16 +00:00
gerri left a comment

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

  • Low (edge case), src/cli/work.rs:513: Invariant: gathered data and persisted identity must describe the same target (STANDARDS 7, 17). As acknowledged under “Known limits,” another process switching the default account or instance during API reads can cause context to save the previous target’s snapshot under the new target’s digest. Subsequent resume or continue can then accept that mismatched snapshot. Carry the resolved target through gathering and saving, and reject persistence if its configuration generation changed. This remains an accepted follow-up, with no new evidence warranting escalation.

No additional correctness or security findings.

BLOCKING: 0

Reviewed head d7652230df at 2026-11-11T17:21:15Z by codex exec (read-only sandbox).

Automated Codex review (read-only) of head d7652230df09159a2c0528ed1125a5d3df24d226. - **Low** (edge case), `src/cli/work.rs:513`: **Invariant: gathered data and persisted identity must describe the same target** (STANDARDS 7, 17). As acknowledged under “Known limits,” another process switching the default account or instance during API reads can cause context to save the previous target’s snapshot under the new target’s digest. Subsequent resume or continue can then accept that mismatched snapshot. Carry the resolved target through gathering and saving, and reject persistence if its configuration generation changed. This remains an accepted follow-up, with no new evidence warranting escalation. No additional correctness or security findings. BLOCKING: 0 --- Reviewed head d7652230df09159a2c0528ed1125a5d3df24d226 at 2026-11-11T17:21:15Z by codex exec (read-only sandbox).
Sign in to join this conversation.
No description provided.