Skip to content

docs(adr): durable remote session and workspace retention - #161

Merged
delete-cloud merged 2 commits into
mainfrom
adr-0025-durable-remote-retention
May 14, 2026
Merged

delete-cloud merged 2 commits into
mainfrom
adr-0025-durable-remote-retention

Conversation

@delete-cloud

@delete-cloud delete-cloud commented May 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add ADR-0025 for durable remote session/workspace retention state
  • define PG as control-plane metadata, with workspace data remaining on provider hosts
  • require provider_instance_id so PG and workspace hosts can be separate machines
  • outline retention policies, API/CLI surface, and staged implementation plan

Validation

  • grep -n '[[:blank:]]$' docs/adr/0025-durable-remote-session-and-workspace-retention.md -> no trailing whitespace
  • uv run python - <<'PY' ... -> required ADR sections present
  • git diff --check

Summary by CodeRabbit

  • Documentation
    • Added architecture documentation for improved remote session and workspace retention. Defines state preservation mechanisms, workspace identity management, and retention policies to support restart recovery and workspace lifecycle management.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@delete-cloud has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 53 minutes and 36 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 24e2731a-0b53-4a38-a5aa-41530dc77ac6

📥 Commits

Reviewing files that changed from the base of the PR and between 032e444 and 7854cb0.

📒 Files selected for processing (1)
  • coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md
📝 Walkthrough

Walkthrough

Added ADR-0025 defining a PostgreSQL-backed control-plane layer for durable remote session and workspace retention. The document specifies core data models, updated lifecycle semantics, API/CLI extensions, configuration requirements, design rationale, phased implementation plan across six PRs, and acceptance criteria.

Changes

Durable Remote Session and Workspace Retention Architecture

Layer / File(s) Summary
Motivation and Core Durable Concepts
coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md (lines 1–124)
ADR header, motivation, and foundational definitions of control-plane vs data-plane separation, remote session records, workspace records, workspace resource records, and retention policies with enumerations of workspace statuses and retention policy types.
Updated Lifecycle and Operational Semantics
coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md (lines 125–155)
Specifications for closing sessions, server shutdown, and garbage collection flows driven by durable workspace records; fail-closed provider instance verification; and filesystem scanning as reconciliation/orphan detection fallback.
API, CLI, and Configuration Requirements
coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md (lines 156–225)
Extensions to remote operations API and CLI commands to expose durable workspace retention state; production configuration requirements for PostgreSQL session backend and stable provider_instance_id; and validation behavior differences.
Result Publication and Behavior Expectations
coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md (lines 226–239)
Retention and cleanup behavior tied to result publication expectations, including persistence of session/workspace result references and unavailability of provider-local exports after cleanup.
Design Decisions and Rejected Alternatives
coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md (lines 240–262)
Enumeration of rejected alternatives such as direct PostgreSQL workspace data storage, filesystem scan-only approaches, co-location assumptions, and other broader-scope designs.
Implementation Roadmap and Acceptance Criteria
coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md (lines 263–336)
Acceptance criteria test names and phased six-PR implementation plan covering ADR/schema contracts, PostgreSQL metadata store, provider instance validation, session close/retention policy updates, durable GC/reconciliation, and cleaned-workspace result behavior.
Related References
coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md (lines 337–354)
References section enumerating related ADRs, documentation, source modules, and tests anticipated for implementation.

Possibly Related PRs

  • delete-cloud/Coding-Agent-Loop#142: Both PRs add new ADR documentation that define HTTP/CLI semantics for durable remote session state, including fail-closed behavior and explicit remote session/workspace handling.
  • delete-cloud/Coding-Agent-Loop#124: This ADR builds directly on ADR-0021's Remote Session/Workspace Operations API by extending the session/workspace operation and CLI semantics to add durable, retention-aware behavior.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A PostgreSQL garden now grows,
Where workspaces rest in neat rows,
Session states bind,
With provider peace of mind,
As retention across restarts flows. 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding ADR-0025 documentation for durable remote session and workspace retention. It directly reflects the primary content of the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch adr-0025-durable-remote-retention

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (4)
coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md (4)

209-214: ⚡ Quick win

Clarify the configuration section name and fallback behavior.

The example introduces a [remote_retention] configuration section, but this section name appears nowhere else in the document. Consider adding a brief note about:

  1. Whether [remote_retention] is the final section name or placeholder
  2. Behavior when remote_retention.enabled = false while cloud_workspace.enabled = true (does it use the old filesystem-scan-only mode?)
  3. Relationship between this section and the production validation mentioned at line 222-224

This ensures configuration semantics are clear for implementers.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md`
around lines 209 - 214, Clarify the [remote_retention] config section and
fallback behavior: state explicitly whether "[remote_retention]" is the final
canonical section name or a placeholder and update any other docs to match;
document what happens when remote_retention.enabled = false while
cloud_workspace.enabled = true (e.g., whether the system falls back to the
legacy filesystem-scan-only mode) and describe how that fallback interacts with
the production validation referenced in the "production validation" lines;
finally, add a short note linking the [remote_retention] settings
(default_policy, default_ttl_seconds, allow_user_pin) to the production
validation requirements so implementers know which combinations are validated in
prod.

58-58: ⚡ Quick win

Clarify "provider-neutral" terminology.

The workspace record is described as "provider-neutral" but line 74 shows it requires a provider field. Consider rephrasing to "provider-agnostic schema" or "multi-provider workspace record" to clarify that while the record structure works across provider types, each record must specify its provider.

This prevents confusion about whether the record actually tracks provider information.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md`
at line 58, The term "provider-neutral" is misleading because the workspace
record requires a provider field; update the wording in the ADR where
"provider-neutral" appears to a clearer phrase such as "provider-agnostic
schema" or "multi-provider workspace record" and add one short clarifying
sentence that each workspace record must still include a provider field (e.g.,
reference "workspace record" and the "provider" field) to make explicit that the
schema is usable across providers but each record records its provider.

274-274: ⚡ Quick win

Consider using pytest markers instead of complex -k filters.

The pytest command uses a long keyword filter: "workspace_record or retention or provider_instance or pin or cleanup_failed". As the implementation grows, this filter may become fragile and hard to maintain.

Consider introducing a pytest marker (e.g., @pytest.mark.workspace_retention) for tests related to this feature, then run:

uv run pytest tests/ui tests/coding_agent/environment -m workspace_retention -v

This provides more explicit test organization and is easier to maintain across the 6-PR implementation plan.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md`
at line 274, Replace the fragile -k keyword filter with a dedicated pytest
marker: add `@pytest.mark.workspace_retention` to all tests covering
workspace_record/retention/provider_instance/pin/cleanup_failed in tests/ui and
tests/coding_agent/environment, run them with uv run pytest ... -m
workspace_retention -v, and register the marker (workspace_retention) in
pytest.ini under markers to avoid "unknown marker" warnings; ensure test names
remain unchanged and only the marker annotations and pytest.ini entries are
added.

107-107: ⚡ Quick win

Define when a workspace transitions to lost status.

The lost status is enumerated but never explained in the document. Consider adding a brief explanation of when this status applies (e.g., workspace record exists but underlying provider resources cannot be found or verified).

This would help implementers understand the complete state machine.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md`
at line 107, Add a short definition for the `lost` workspace status in the ADR:
state that `lost` applies when a workspace record exists but the underlying
provider resources cannot be found or verified (e.g., API 404s, missing
VM/container, or auth failures), list the detection criteria (failed discovery,
inconsistent resource IDs, repeated health-check timeouts), and indicate
expected handling/remediation (mark `lost`, alert owners, schedule cleanup or
manual recovery). Reference the `lost` enum in the state machine and ensure
transitions into/out-of `lost` are described consistently with existing
statuses.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md`:
- Around line 51-56: The ADR mentions workspace_record_id but the "Required
workspace identity fields" list only includes workspace_id, causing ambiguity;
update the ADR to explicitly define workspace_record_id (and its relation to
workspace_id): state whether workspace_record_id is the same identifier as
workspace_id, a separate database primary key on the workspace table, or a
foreign-key reference from session to workspace, and then add
workspace_record_id to the "Required workspace identity fields" list with its
intended type and semantics (e.g., "workspace_record_id: UUID primary key of the
workspace table, used as FK from session records") so implementers can
unambiguously map session rows to workspace rows in functions handling session
persistence and resume.
- Around line 169-170: Clarify the unpin behavior in the ADR by explicitly
stating which approach is used: if unpin restores the actual previous policy,
update the data model to add a previous_retention_policy field on the Workspace
record and describe how/when it is set (e.g., Workspace.pin() saves current
retention to previous_retention_policy and Workspace.unpin() restores it);
otherwise state that unpin applies a configured default or requires an explicit
parameter (e.g., POST /workspaces/{workspace_id}/unpin accepts optional
--ttl/--policy or falls back to system_default_retention). Reference the POST
/workspaces/{workspace_id}/unpin operation and the Workspace data model (add
previous_retention_policy) in the ADR text so behavior and required fields are
unambiguous.

---

Nitpick comments:
In
`@coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md`:
- Around line 209-214: Clarify the [remote_retention] config section and
fallback behavior: state explicitly whether "[remote_retention]" is the final
canonical section name or a placeholder and update any other docs to match;
document what happens when remote_retention.enabled = false while
cloud_workspace.enabled = true (e.g., whether the system falls back to the
legacy filesystem-scan-only mode) and describe how that fallback interacts with
the production validation referenced in the "production validation" lines;
finally, add a short note linking the [remote_retention] settings
(default_policy, default_ttl_seconds, allow_user_pin) to the production
validation requirements so implementers know which combinations are validated in
prod.
- Line 58: The term "provider-neutral" is misleading because the workspace
record requires a provider field; update the wording in the ADR where
"provider-neutral" appears to a clearer phrase such as "provider-agnostic
schema" or "multi-provider workspace record" and add one short clarifying
sentence that each workspace record must still include a provider field (e.g.,
reference "workspace record" and the "provider" field) to make explicit that the
schema is usable across providers but each record records its provider.
- Line 274: Replace the fragile -k keyword filter with a dedicated pytest
marker: add `@pytest.mark.workspace_retention` to all tests covering
workspace_record/retention/provider_instance/pin/cleanup_failed in tests/ui and
tests/coding_agent/environment, run them with uv run pytest ... -m
workspace_retention -v, and register the marker (workspace_retention) in
pytest.ini under markers to avoid "unknown marker" warnings; ensure test names
remain unchanged and only the marker annotations and pytest.ini entries are
added.
- Line 107: Add a short definition for the `lost` workspace status in the ADR:
state that `lost` applies when a workspace record exists but the underlying
provider resources cannot be found or verified (e.g., API 404s, missing
VM/container, or auth failures), list the detection criteria (failed discovery,
inconsistent resource IDs, repeated health-check timeouts), and indicate
expected handling/remediation (mark `lost`, alert owners, schedule cleanup or
manual recovery). Reference the `lost` enum in the state machine and ensure
transitions into/out-of `lost` are described consistently with existing
statuses.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d775a71b-2f34-41aa-9bd1-c828bbdb1460

📥 Commits

Reviewing files that changed from the base of the PR and between b4395a5 and 032e444.

📒 Files selected for processing (1)
  • coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md

Comment thread coding-agent/docs/adr/0025-durable-remote-session-and-workspace-retention.md Outdated
@delete-cloud
delete-cloud merged commit 93c3d62 into main May 14, 2026
1 check passed
@delete-cloud
delete-cloud deleted the adr-0025-durable-remote-retention branch May 14, 2026 15:58
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