Skip to content

[fix] Harden hosted subscription release paths - #6751

Merged
mmabrouk merged 1 commit into
release/v0.117.0from
agent/fix-hosted-subscription-release-gates
Sep 10, 2026
Merged

[fix] Harden hosted subscription release paths#6751
mmabrouk merged 1 commit into
release/v0.117.0from
agent/fix-hosted-subscription-release-gates

Conversation

@mmabrouk

Copy link
Copy Markdown
Member

Problem

Hosted ChatGPT sessions can lose a rotated login after the initial Agenta run credential expires. A 401 or 403 currently marks the rotated login as acknowledged even though the vault never stored it. Acquire-time recovery can also skip environment cleanup when recovery throws, and concurrent ChatGPT connection creation can escape the application precheck and fail as an unhandled database conflict.

This is a follow-up to #6674.

Result

  • Keep a live platform-credential lease for the subscription publisher and retry 401 and 403 responses without acknowledging the login.
  • Contain acquire-time recovery failures so sandbox, workspace, and publisher cleanup still runs.
  • Force the canonical chatgpt storage slug and translate the database uniqueness tie-breaker into the existing subscription 409 conflict.
  • Make the hosted refresh journey mandatory when release changes touch subscription storage or publication, even when the release command uses --only.

How to review

  1. Start in publisher.ts: verify each API request reads the lease's current credential, authentication failures remain unacknowledged, and stop() releases the lease.
  2. Review the acquire catch in environment.ts: a recovery exception is logged and execution reaches environment.destroy().
  3. Review services.py and the secrets DAO: the provider owns the storage slug and the unique-index race becomes SubscriptionProviderConflict.
  4. Review path_triggers.py and qa_product.py: subscription paths select H1/H2 and force the refresh journey.

Validation

  • pnpm exec vitest run --project unit tests/unit/subscription-login-publish.test.ts tests/unit/subscription-recovery-throws.test.ts (25 passed)
  • pnpm run typecheck (passed)
  • pytest -q oss/tests/pytest/unit/secrets (167 passed)
  • pytest -q .agents/skills/agent-release-gate/resources/test_qa_product_concurrency.py -k subscription_change (1 passed)
  • Full runner unit suite: 3,116 passed; five existing failures. Four require build:extension in a fresh checkout and pass after building it. The remaining AGENTA_API_URL expectation failure reproduces unchanged on origin/release/v0.117.0.

@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agenta-documentation Ready Ready Preview Sep 10, 2026 4:11pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Advanced

Run ID: c46a9d87-6e4f-4255-9ac7-f53fbc5aeb87

📥 Commits

Reviewing files that changed from the base of the PR and between 3f0ab53 and 24b91c6.

📒 Files selected for processing (13)
  • .agents/skills/agent-release-gate/SKILL.md
  • .agents/skills/agent-release-gate/resources/path_triggers.py
  • .agents/skills/agent-release-gate/resources/qa_product.py
  • .agents/skills/agent-release-gate/resources/test_qa_product_concurrency.py
  • api/oss/src/core/secrets/services.py
  • api/oss/src/dbs/postgres/secrets/dao.py
  • api/oss/tests/pytest/unit/secrets/test_subscription_login_service.py
  • api/oss/tests/pytest/unit/secrets/test_subscription_secret_dao_conflict.py
  • services/runner/src/engines/sandbox_agent/environment.ts
  • services/runner/src/engines/sandbox_agent/subscription-login/publisher.ts
  • services/runner/tests/unit/subscription-login-publish.test.ts
  • services/runner/tests/unit/subscription-recovery-throws.test.ts
  • services/runner/tests/utils/sandbox-agent-harness.ts

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes

    • Subscription connections now use a consistent storage identity, preventing duplicate connections during concurrent creation.
    • Conflicts from simultaneous subscription-connection creation are reported clearly.
    • Subscription authentication retries after unauthorized responses using refreshed credentials.
    • Authentication recovery failures no longer prevent normal environment cleanup and failure reporting.
  • Release Quality

    • Changes affecting subscription authentication or secret storage now require refresh coverage in release checks.
    • Release checks report and persist required journeys when they are automatically added.

Walkthrough

The change adds path-triggered refresh coverage to the release gate, canonical subscription-secret conflict handling, rotating publisher credentials with retry support, and best-effort subscription recovery during sandbox acquisition.

Changes

Release gate coverage

Layer / File(s) Summary
Mandatory journey rules
.agents/skills/agent-release-gate/resources/path_triggers.py, .agents/skills/agent-release-gate/SKILL.md, .agents/skills/agent-release-gate/resources/test_qa_product_concurrency.py
Changed subscription, vault, and secret-storage paths now require the refresh journey. The documentation describes the --release-base behavior.
Journey enforcement and reporting
.agents/skills/agent-release-gate/resources/qa_product.py
The release gate validates and adds mandatory journeys. It reports their triggering paths and stores them in run artifacts and summaries.

Subscription secret storage

Layer / File(s) Summary
Canonical slugs and conflict translation
api/oss/src/core/secrets/services.py, api/oss/src/dbs/postgres/secrets/dao.py, api/oss/tests/pytest/unit/secrets/*
Subscription provider secrets always use the canonical provider slug. Unique-constraint races are translated to SubscriptionProviderConflict, with unit coverage for both behaviors.

Runner subscription authentication

Layer / File(s) Summary
Credential lease and retry flow
services/runner/src/engines/sandbox_agent/subscription-login/publisher.ts, services/runner/tests/unit/subscription-login-publish.test.ts
The publisher resolves credentials at request time, retries 401 and 403 responses, and releases its credential lease during shutdown.
Acquire recovery failure handling
services/runner/src/engines/sandbox_agent/environment.ts, services/runner/tests/utils/sandbox-agent-harness.ts, services/runner/tests/unit/subscription-recovery-throws.test.ts
Recovery exceptions are logged during acquisition while the original acquire failure remains authoritative. The harness and tests cover cleanup and failure reporting.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SubscriptionPublisher
  participant PlatformCredentialLease
  participant SubscriptionAPI
  SubscriptionPublisher->>PlatformCredentialLease: Resolve current credential
  SubscriptionPublisher->>SubscriptionAPI: Publish login with authorization
  SubscriptionAPI-->>SubscriptionPublisher: Return 401 or 403
  SubscriptionPublisher->>PlatformCredentialLease: Refresh credential
  SubscriptionPublisher->>SubscriptionAPI: Retry login with refreshed authorization
  SubscriptionPublisher->>PlatformCredentialLease: Release on stop
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/fix-hosted-subscription-release-gates

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.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Agenta Product Agent seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@mmabrouk
mmabrouk marked this pull request as ready for review September 10, 2026 19:06
@mmabrouk
mmabrouk merged commit 6c1256b into release/v0.117.0 Sep 10, 2026
36 of 38 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Preview URL https://gateway-pr-6751.up.railway.app/w
Project agenta-oss-clone-spike
Image tag pr-6751-4e03a7f
Status Deployed
Railway logs Open logs
Workflow logs View workflow run
Updated at 2026-09-10T19:19:10.426Z

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.

2 participants