Skip to content

feat: validate remote retention production config - #164

Merged
delete-cloud merged 2 commits into
mainfrom
feature/remote-retention-production-validation
May 14, 2026
Merged

delete-cloud merged 2 commits into
mainfrom
feature/remote-retention-production-validation

Conversation

@delete-cloud

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

Copy link
Copy Markdown
Owner

Summary

  • add [remote_retention] config loading
  • validate durable retention production config requires PostgreSQL HTTP session storage and cloud_workspace.provider_instance_id
  • document that PostgreSQL and workspace hosts may be separate machines and that provider_instance_id gates local cleanup authority

Validation

  • uv run pytest tests/ui/test_http_server.py -k "remote_retention or durable_remote_retention or production_config" -q
  • uv run basedpyright --level error src/coding_agent/ui/http_server.py tests/ui/test_http_server.py
  • uv run ruff format --check src/coding_agent/ui/http_server.py tests/ui/test_http_server.py
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Added remote workspace retention configuration capabilities to control session and workspace lifecycle behavior.
    • Introduced new retention policies (delete_on_close, ttl, pinned, manual) for managing durable remote sessions.
  • Documentation

    • Updated production configuration guidance for Docker workspace provider identification and retention settings.
  • Tests

    • Added validation test coverage for remote retention configuration and production configuration scenarios.

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 52 minutes and 54 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: 85568e56-c43e-40c1-9abe-db9ad24971d4

📥 Commits

Reviewing files that changed from the base of the PR and between f9bdd06 and cb25977.

📒 Files selected for processing (2)
  • coding-agent/src/coding_agent/ui/http_server.py
  • coding-agent/tests/ui/test_http_server.py
📝 Walkthrough

Walkthrough

This PR adds configuration loading and production validation for durable remote workspace retention. It documents the [cloud_workspace] provider instance fields and new [remote_retention] section, implements config parsing, enforces validation constraints (PostgreSQL session storage, valid policies, TTL correctness), and wires validation into session manager startup with comprehensive test coverage.

Changes

Remote Retention Configuration

Layer / File(s) Summary
Configuration Schema and Loading
coding-agent/docs/remote-sandbox-production.md, coding-agent/src/coding_agent/ui/http_server.py, coding-agent/tests/ui/test_http_server.py
Extended [cloud_workspace] with provider_instance_id and workspace_host_label fields; introduced [remote_retention] section with enabled, default_policy, default_ttl_seconds, and allow_user_pin; implemented _load_remote_retention_config() to parse TOML retention settings; tests verify parsing of booleans and default TTL values.
Production Validation Rules
coding-agent/src/coding_agent/ui/http_server.py, coding-agent/docs/remote-sandbox-production.md
When remote_retention.enabled=true, validation enforces: required cloud workspace provider_instance_id, non-empty workspace_host_label if set, PostgreSQL HTTP session storage backend, retention policies from allowed set (delete_on_close, ttl, pinned, manual), and correct TTL/boolean field types; extended _validate_production_config to accept optional storage_config and remote_retention_config parameters; documented production constraints on local workspace cleanup targeting.
Session Manager Integration and Test Coverage
coding-agent/src/coding_agent/ui/http_server.py, coding-agent/tests/ui/test_http_server.py
Updated _build_session_manager to load storage_config and remote_retention_config, passing both into production validation; wired retention validator into _validate_production_config; added positive test accepting valid durable retention configurations with correct cloud workspace and storage setup; added parametrized test rejecting invalid retention + storage combinations with expected error messages.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • delete-cloud/Coding-Agent-Loop#112: Both PRs modify http_server.py to load and use cloud_workspace configuration during session manager setup; main PR extends this with remote retention validation and config-aware session handling.
  • delete-cloud/Coding-Agent-Loop#161: Main PR's remote retention production validation enforces the same durable session/workspace retention semantics (PostgreSQL backend and provider_instance_id-aware cleanup binding) from that ADR.
  • delete-cloud/Coding-Agent-Loop#137: Both PRs extend _validate_production_config in http_server.py to enforce additional cloud workspace policy constraints; main PR adds remote_retention validation adjacent to existing policy enforcement points.

Poem

🐰 A rabbit hops through config lands,
With retention rules in steady hands—
PostgreSQL holds what must persist,
While cleanup's bound to provider lists.
Sessions live longer when enabled's true—
Production safety, through and through! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: validate remote retention production config' directly and accurately reflects the main change: adding validation for remote retention production configuration.
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 feature/remote-retention-production-validation

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.

@delete-cloud

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 1

🧹 Nitpick comments (2)
coding-agent/src/coding_agent/ui/http_server.py (1)

424-426: 💤 Low value

Clarify that allow_user_pin is required when retention is enabled.

The error message states "must be a boolean" but doesn't make it clear that the field is also required to be present (not just correctly typed). Consider making the error message more explicit about the requirement.

📝 Suggested improvement
 allow_user_pin = remote_retention_config.get("allow_user_pin")
 if not isinstance(allow_user_pin, bool):
-    raise ValueError("remote_retention.allow_user_pin must be a boolean")
+    raise ValueError(
+        "remote_retention.allow_user_pin is required and must be a boolean"
+    )
🤖 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/src/coding_agent/ui/http_server.py` around lines 424 - 426, The
validation for remote_retention_config's allow_user_pin currently only raises
"must be a boolean" but doesn't state the field is required when retention is
enabled; update the check around allow_user_pin (the variable derived from
remote_retention_config.get("allow_user_pin")) to raise a clearer ValueError
that both insists the key be present and that its value be a boolean (e.g.
"remote_retention.allow_user_pin is required when remote retention is enabled
and must be a boolean"), or split into two checks that raise explicit errors if
the key is missing vs. wrong type so callers of the code path using
remote_retention_config (where allow_user_pin is validated) see the
required-when-enabled semantic.
coding-agent/tests/ui/test_http_server.py (1)

400-472: ⚡ Quick win

Consider adding test cases for invalid retention policy values and negative TTL.

The parametrized test covers several important negative cases, but appears to be missing:

  1. Invalid retention policy validation: According to the review context, production validation should constrain policies to allowed values (delete_on_close, ttl, pinned, manual). Consider adding a test case that provides an invalid policy value like "forever" or "invalid" to verify this constraint is enforced during production config validation.

  2. Negative TTL values: Case 3 tests default_ttl_seconds: 0, but consider also testing negative values (e.g., -1) to ensure comprehensive bounds checking.

📋 Suggested additional test cases
        (
            {"provider_instance_id": "docker-host-a"},
            {"http_session_backend": "pg", "dsn": "postgresql://example"},
            {
                "enabled": True,
                "default_policy": "forever",
                "allow_user_pin": False,
            },
            "remote_retention.default_policy",
        ),
        (
            {"provider_instance_id": "docker-host-a"},
            {"http_session_backend": "pg", "dsn": "postgresql://example"},
            {
                "enabled": True,
                "default_policy": "ttl",
                "default_ttl_seconds": -3600,
                "allow_user_pin": False,
            },
            "remote_retention.default_ttl_seconds",
        ),
🤖 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/tests/ui/test_http_server.py` around lines 400 - 472, Add two
parametrized negative cases to
test_production_config_rejects_unsafe_remote_retention_config so production
validation rejects unknown policies and negative TTLs: update the parameter list
in coding-agent/tests/ui/test_http_server.py (the pytest.mark.parametrize for
test_production_config_rejects_unsafe_remote_retention_config) to include a case
with remote_retention.default_policy set to "forever" (expecting error match
"remote_retention.default_policy") and a case with
remote_retention.default_policy "ttl" and default_ttl_seconds -3600 (expecting
"remote_retention.default_ttl_seconds"); these will exercise
http_server._validate_production_config and ensure the allowed policy values and
non-negative TTL checks are enforced.
🤖 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/src/coding_agent/ui/http_server.py`:
- Around line 374-383: Remove the earlier duplicate definition of the function
_storage_uses_pg_http_sessions (the first occurrence in the file) so only the
later implementation remains; delete the entire first function block and keep
the later one (which Python will actually use) to avoid dead/conflicting code,
ensuring callers of _storage_uses_pg_http_sessions continue to refer to the
single remaining implementation.

---

Nitpick comments:
In `@coding-agent/src/coding_agent/ui/http_server.py`:
- Around line 424-426: The validation for remote_retention_config's
allow_user_pin currently only raises "must be a boolean" but doesn't state the
field is required when retention is enabled; update the check around
allow_user_pin (the variable derived from
remote_retention_config.get("allow_user_pin")) to raise a clearer ValueError
that both insists the key be present and that its value be a boolean (e.g.
"remote_retention.allow_user_pin is required when remote retention is enabled
and must be a boolean"), or split into two checks that raise explicit errors if
the key is missing vs. wrong type so callers of the code path using
remote_retention_config (where allow_user_pin is validated) see the
required-when-enabled semantic.

In `@coding-agent/tests/ui/test_http_server.py`:
- Around line 400-472: Add two parametrized negative cases to
test_production_config_rejects_unsafe_remote_retention_config so production
validation rejects unknown policies and negative TTLs: update the parameter list
in coding-agent/tests/ui/test_http_server.py (the pytest.mark.parametrize for
test_production_config_rejects_unsafe_remote_retention_config) to include a case
with remote_retention.default_policy set to "forever" (expecting error match
"remote_retention.default_policy") and a case with
remote_retention.default_policy "ttl" and default_ttl_seconds -3600 (expecting
"remote_retention.default_ttl_seconds"); these will exercise
http_server._validate_production_config and ensure the allowed policy values and
non-negative TTL checks are enforced.
🪄 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: efa22937-b864-41fc-87f0-debb4b3e05c8

📥 Commits

Reviewing files that changed from the base of the PR and between 0f47c12 and f9bdd06.

📒 Files selected for processing (3)
  • coding-agent/docs/remote-sandbox-production.md
  • coding-agent/src/coding_agent/ui/http_server.py
  • coding-agent/tests/ui/test_http_server.py

@delete-cloud
delete-cloud merged commit 6586a91 into main May 14, 2026
1 check passed
@delete-cloud
delete-cloud deleted the feature/remote-retention-production-validation branch May 14, 2026 16:48
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