Skip to content

feat: store retention_days and a server-side /undo that refuses while work is active or due - #502

Merged
lg2m merged 1 commit into
mainfrom
feat/plan-h-retention-undo
Oct 29, 2026
Merged

lg2m merged 1 commit into
mainfrom
feat/plan-h-retention-undo

Conversation

@lg2m

@lg2m lg2m commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Change

Finishes plan section H, which #501 started, and removes section H from the plan.

  • retention_days (store retention). New top-level key, 1–3650. It is unset by default, so nothing is deleted unless you set it.
    • When set, the server deletes idle sessions untouched for that many days, at startup and hourly. Deletion goes through the same path as DeleteSession, so each one is a session_deleted event.
    • Sessions with a live goal, a queued prompt or unfinished work are kept.
    • Run snapshots also drop refs/qq/snapshots/ entries older than the cutoff, in addition to the cap of 50.
    • Only user and managed config can set it, because one store serves every workspace. A project file that sets it fails to load.
  • /undo in the TUI, as a server command. New undo_workspace command (POST /v1/workspaces/undo) with a workspace_undone outcome. PROTOCOL_VERSION goes from 41 to 42.
    • The runtime refuses the undo while any session in the workspace is busy, any run is queued or running, a goal check is unacknowledged, or a live goal is active.
    • Once the undo is accepted, the claim query and goal queueing skip that workspace until the restore finishes, and a second undo is refused. This covers other clients and goal scheduling, which a guard in the client can't see.
    • The Git restore runs outside the store. The restoring flag is cleared on every exit, including failure and panic.
    • Only snapshots of that exact workspace are used, never one from an enclosing workspace.
    • qq undo and the server now share the same snapshot selection.

Verification

Regression tests for the guard and the retention sweep, each confirmed to fail when its fix is reverted:

  • cargo nextest run -p qq-core -E 'test(/no_run_starts_in_the_workspace_until_its_restore_finishes/)': fails without the claim guard.
  • cargo nextest run -p qq-core -E 'test(/a_due_goal_waits_for_a_workspace_restore/)': fails without the goal-queue guard.
  • cargo nextest run -p qq-core -E 'test(/a_failed_undo_leaves_the_workspace_free_to_run/)': hangs if the flag is not cleared after a failure.
  • cargo nextest run -p qq-core -E 'test(/undo_in_a_subdirectory_never_restores_the_parent_workspace/)': fails if an enclosing workspace's snapshot is used.
  • cargo nextest run -p qq-core -E 'test(/retention_deletes_idle_sessions/)': hangs without the sweep.

Other tests:

  • Busy refusals with an active run and with a queued prompt.
  • Restore plus replay of the same command_id returns the first receipt without restoring again.
  • Age-based snapshot pruning.
  • Config bounds, provenance and project refusal for retention_days.
  • The TUI /undo round trip.
  • New command_undo_workspace and receipt_workspace_undone goldens; v42 fixtures regenerated, with v41 kept.

cargo xtask check passed on the pushed head.

Known impact

  • Protocol 42: clients and servers must be upgraded together. CHANGELOG now says 40 → 42.
  • Retention deletes durable session data. It is opt-in and unset by default.
  • qq undo on the CLI still works on the files directly and does not check for running agents. The guide says so.
  • xtask/src/legacy-sleeps.txt line numbers moved. No new sleeps were added.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T22:21:15.749489Z 50afc07 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b284fa58d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/qq-core/src/sessions/commands.rs Resolved
Comment thread crates/qq-core/src/sessions/runtime.rs Resolved
Comment thread crates/qq-core/src/sessions/runtime.rs Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f93af56f7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/qq-core/src/sessions/runtime.rs Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4bd091901a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli.rs Resolved
Comment thread crates/qq-core/src/sessions/commands.rs Resolved
@lg2m
lg2m force-pushed the feat/plan-h-retention-undo branch from 4bd0919 to 45071e1 Compare October 29, 2026 21:59
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45071e1380

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/qq-core/src/sessions/commands.rs Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m
lg2m force-pushed the feat/plan-h-retention-undo branch from 975d83a to 50afc07 Compare October 29, 2026 22:12
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 50afc07b67

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lg2m
lg2m merged commit 62406ca into main Oct 29, 2026
10 checks passed
@lg2m
lg2m deleted the feat/plan-h-retention-undo branch October 29, 2026 22:24
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