Skip to content

fix(dashboard): keep a recent-restored relay chat read-only - #18088

Merged
iamwhatever merged 1 commit into
mainfrom
fix/10826-recent-restore-executor
Oct 8, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/10826-recent-restore-executor

Conversation

@iamwhatever

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: An old relay chat brought back by the recent-sessions restore stays a read-only archive, the same as when the open-tab restore brings it back.

A chat that a peer crew once ran through the retired turn relay carries executor="remote" on its metadata line. After #17642 and #17662 such a chat is a read-only archive: every run path answers 409 relay_archive_read_only. But the recent-sessions restore (_apply_recent_session, the RECENT purpose) never read the marker. So the chat came back as a plain local chat. Its next send ran the crew's turn on this machine, and the next full save wrote the line without the marker, so the chat lost its archive status for good.

Why it matters

A user who reopens an old crew chat from the recent list can send into it and get a local agent replying to a conversation another machine owned. The relay_archive_read_only guard exists to stop exactly that, and the open-tab restore already honours it.

Not a goal

  • No change to the RESUME purpose (History resume and transfer import). It deliberately brings the session back local, as its why text says.
  • No migration of old relay chats into peer pointers (RFC remote-crew-sidebar, wave 4).
  • No change to the relay-archive guards themselves.

What changed (motivation → approach → change)

Symptom: a recent-restored relay chat runs locally and loses its marker. Cause: in the metadata field table, the executor, instance_id and remote_slot rows listed only RESTORE as a purpose, so _read_executor never ran for RECENT. Change: add RECENT to those three rows in slot_persistence/metadata_codec.py, and rewrite the executor row's why text, which named this gap. Both startup restores now keep the marker, so is_relay_archive sees it and every run path refuses with the existing 409.

Backwards compatibility

Compatible: a line without executor="remote" reads exactly as before; only old relay chats change, from runnable-local to the read-only archive they already are on the open-tab restore.

Removes nothing: the change makes one more purpose read three existing fields; no key, route or record is dropped.

Tests

  • test/test_slot_metadata_codec.py::test_a_recent_restored_relay_chat_stays_a_read_only_archive: a relay line read through RECENT keeps executor/instance_id/remote_slot, relay_archive_refusal answers 409 relay_archive_read_only, and the next encode writes the binding back. Red on main (('local', '', '') == ('remote', 'inst-1', 'rs-1')), green with the fix.
  • test_the_table_declares_every_asymmetry_the_readers_had: the pinned purposes for the three rows now read ["recent", "restore"].
  • Determinism: the new test uses no clock, thread or randomness. The file ran 3 times in order and once in reversed order: 38 passed each run.
  • Also green locally: test_session_restore.py, test_relay_archive.py, test_chat_slot_create_remote_retired.py, test_chat_persistence_composition_contract.py, test_dashboard_contract_pins.py, test_crew_main_contract.py, test_resume_publishes_hydrated_slot.py, test_local_turn_restart_marker.py, test_flake_pattern_ratchet.py.

Manual verification

N/A — unit coverage sufficient: the change is a field-table purpose set, and the test drives the same codec.apply the recent restore calls.

Related Issues

Closes #10826
Part of #6180

Pattern harvest

Not generalizable: the field table already pins every purpose asymmetry in test_the_table_declares_every_asymmetry_the_readers_had; this row was a declared asymmetry that #17662 made wrong, not an undeclared one.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners October 8, 2026 08:26
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 1865602a49144aacf3ec51320df8e269b715e1eb — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check that the RFC's tracking row for #10826 (docs/request-for-change/rfc-remote-crew-sidebar.md:71) is updated, since this PR closes the issue before wave 4 does.

[DESIGN-REVIEWED] 1865602

Description read

[DESCRIPTION-READ] 517a546566e8365894a520c0843dba520d03986b14078c560d0ab8484f2090e9

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 1865602a49144aacf3ec51320df8e269b715e1eb — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Nothing to check.

What this change ships

Inventory (3 items) — 3 justified

Intent: when a user reopens an old relay chat from the recent-sessions list, it should stay a read-only archive and not quietly turn into a local chat that runs on this machine. This is a FIX.

  1. An old relay chat brought back by the recent-sessions restore now refuses sends with the existing 409 relay_archive_read_only — justified
  2. When that chat is saved again, its relay marker (executor/instance_id/remote_slot) is written back instead of being lost for good — justified
  3. The table-asymmetry pin changes from ["restore"] to ["recent", "restore"] for the three binding fields. The old pin's own why text named this as the Remote-bound session restored by the recent-sessions path comes back as a local executor #10826 gap, not as a decision — justified

[FIRST-PRINCIPLES-REVIEWED] 1865602

Description read

[DESCRIPTION-READ] bdd99504e84c22dfe6002340a49ca420b552d2a25251b1879d023c289108415c

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 1865602a49144aacf3ec51320df8e269b715e1eb and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 1865602

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 1865602a49144aacf3ec51320df8e269b715e1eb: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 1865602a49144aacf3ec51320df8e269b715e1eb touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 1865602a49144aacf3ec51320df8e269b715e1eb — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 1865602

Verdict parsed from the review's SHA-scoped output markers for commit 1865602a49144aacf3ec51320df8e269b715e1eb.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 1865602a49144aacf3ec51320df8e269b715e1eb: <one-sentence reason>

@iamwhatever
iamwhatever force-pushed the fix/10826-recent-restore-executor branch from 4a36cc4 to 1865602 Compare October 8, 2026 08:56
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 8, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Self-review (crew-pr-reviewer, read-only): RECOMMEND APPROVE

This fixes #10826 at the root: the metadata field table listed only RESTORE for the executor, instance_id and remote_slot rows, so the recent-sessions restore (RECENT) never ran _read_executor and an old relay chat came back as a runnable local chat that then lost its marker on the next save. Adding RECENT to those three rows makes both startup restores go through the same fail-closed reader. RESUME stays local on purpose, and the PR leaves it alone. I read the full diff and _read_executor, and grepped every consumer of executor == "remote" / is_relay_archive (chat_runner, chat_handlers, session_control, openai_compat, chat_folders). They all treat the restored slot exactly as they already do after RESTORE, so I found no new side effect. The new test drives codec.apply through RECENT, checks the 409 relay_archive_read_only refusal and checks that the encode writes the binding back. The description shows it red on main, and the pinned asymmetry table was updated with it. Both Design and First Principles lanes PASS on the current head 1865602, checks are green, the base is main and there is no open change request. — crew-pr-reviewer

@iamwhatever
iamwhatever enabled auto-merge (squash) October 8, 2026 15:51

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve at 1865602a49144aacf3ec51320df8e269b715e1eb.

A relay chat brought back from the recent-sessions list now restores as the same read-only archive as an open-tab restore, instead of coming back local and running the other machine's conversation here.

Verified at head:

  • src/kiro_crew/dashboard/slot_persistence/metadata_codec.py:688: the executor field now applies to RECENT as well as RESTORE, written whole or not at all via _if_bound.
  • metadata_codec.py:1066 _read_executor: a remote marker is kept even when the target fields are incomplete, so a half binding fails closed (the incomplete-binding guards refuse the send) rather than resurrecting a local session.
  • metadata_codec.py:1572 and src/kiro_crew/dashboard/relay_archive.py:29: the archive marker survives the next save.
  • Ordinary and local recent sessions stay writable and never get an executor field.

Fail-closed: the only new behaviour on a bad record is refusing to run locally. Upgrade impact / audience fit: affects relay archives only; ordinary recent sessions restore exactly as before.

Mutation: removing RECENT from the executor row reddens 4 tests. test_slot_metadata_codec.py + test_relay_archive.py + test_session_restore.py: 121 passed.

Non-blocking follow-up: docs/request-for-change/rfc-remote-crew-sidebar.md:71 still lists "Executor lost on restore" as a current defect (_apply_recent_session never restores executor ... "The next send runs locally"). This PR closes it, so please mark that row resolved.

CI: 85 success, 13 skipped, 0 failing. Not run: full suite, Windows/macOS.

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.

Remote-bound session restored by the recent-sessions path comes back as a local executor

2 participants