Repository navigation
feat(db): record the agent sign-ins a cloud workspace booted with - #8049
Conversation
A nullable column on cloud_workspaces for a keyed digest of the creator's agent credentials at the box's last boot. The API compares it on wake to tell a box running on credentials that have since changed. Schema only; the API and desktop changes follow in their own PRs.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe cloud workspace schema and database migration add a nullable text column named ChangesCloud workspace credential digest
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~4 minutes Change: Feature Suggested reviewers: Merge Risk: ⚪ Minimal · up to This is an additive nullable-column change, and no concrete merge-blocking issue was found. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
No installed development build can load this pull request as an update: its native fingerprint is |
|
| .references(() => environments.id), | ||
| hostVersion: text("host_version"), | ||
| /** The creator's agent sign-ins the running box booted with, keyed; null before it was recorded. */ | ||
| bootAgentCredentialDigest: text("boot_agent_credential_digest"), |
There was a problem hiding this comment.
Credential digest reaches clients
If the planned API writer populates this field, cloudWorkspace.list and rename will return it as part of the full workspace row. Members can view org-visible workspaces, so they would receive a stable digest of the creator’s agent sign-ins even though those responses do not need it. Exclude the digest from these responses before it is populated.
How this was verified: Both procedures return complete workspace rows, and the new digest is a column on those rows.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/db/src/schema/schema.ts
Line: 895
Comment:
**Credential digest reaches clients**
If the planned API writer populates this field, `cloudWorkspace.list` and `rename` will return it as part of the full workspace row. Members can view org-visible workspaces, so they would receive a stable digest of the creator’s agent sign-ins even though those responses do not need it. Exclude the digest from these responses before it is populated.
**How this was verified:** Both procedures return complete workspace rows, and the new digest is a column on those rows.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/db/src/schema/schema.ts">
<violation number="1" location="packages/db/src/schema/schema.ts:895">
P2: Exclude `bootAgentCredentialDigest` from full-row workspace responses before the API starts populating it; otherwise org members receive a stable identifier for the creator's credential set.</violation>
</file>
Architecture diagram
sequenceDiagram
participant API as API Server
participant DB as PostgreSQL Database
participant CloudWS as Cloud Workspace Service
participant Agent as Cloud Agent
participant Secret as Server Secret Store
Note over API,DB: Cloud Workspace Boot Sign-in Digest Tracking
API->>API: Process workspace boot request
API->>CloudWS: bootWorkspace(workspaceId)
CloudWS->>Secret: getServerSecret()
Secret-->>CloudWS: HMAC secret key
CloudWS->>Agent: Fetch creator agent sign-ins
Agent-->>CloudWS: Sign-in credentials list
CloudWS->>CloudWS: Compute HMAC digest of sign-ins
CloudWS->>DB: UPDATE cloud_workspaces SET boot_agent_credential_digest = ?
DB-->>CloudWS: Updated (1 row)
Note over API,DB: Workspace Wake Flow (with digest comparison)
API->>CloudWS: wakeWorkspace(workspaceId)
CloudWS->>Secret: getServerSecret()
Secret-->>CloudWS: HMAC secret key
CloudWS->>Agent: Fetch current creator agent sign-ins
Agent-->>CloudWS: Current credentials list
CloudWS->>CloudWS: Compute new HMAC digest
CloudWS->>DB: SELECT boot_agent_credential_digest FROM cloud_workspaces
DB-->>CloudWS: Stored boot digest
alt Digests match
CloudWS-->>API: Workspace ready (no changes)
else Digests differ
CloudWS-->>API: Credentials changed signal
API-->>API: Queue restart notification
end
Note over API,DB: Schema Details
Note over DB: cloud_workspaces table (~133 rows, 208 kB)
Note over DB: boot_agent_credential_digest: nullable text column (no default)
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| .references(() => environments.id), | ||
| hostVersion: text("host_version"), | ||
| /** The creator's agent sign-ins the running box booted with, keyed; null before it was recorded. */ | ||
| bootAgentCredentialDigest: text("boot_agent_credential_digest"), |
There was a problem hiding this comment.
P2: Exclude bootAgentCredentialDigest from full-row workspace responses before the API starts populating it; otherwise org members receive a stable identifier for the creator's credential set.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/db/src/schema/schema.ts, line 895:
<comment>Exclude `bootAgentCredentialDigest` from full-row workspace responses before the API starts populating it; otherwise org members receive a stable identifier for the creator's credential set.</comment>
<file context>
@@ -891,6 +891,8 @@ export const cloudWorkspaces = pgTable(
.references(() => environments.id),
hostVersion: text("host_version"),
+ /** The creator's agent sign-ins the running box booted with, keyed; null before it was recorded. */
+ bootAgentCredentialDigest: text("boot_agent_credential_digest"),
agentStatus: text("agent_status").$type<ActiveAgentStatus>(),
agentStatusAt: timestamp("agent_status_at", { withTimezone: true }),
</file context>
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
…n id Main's #8049 took migration 0135, so the two here regenerated as 0136 and 0137 off main's drizzle state — never hand-edited. Main's #7985 also moved the Linear plugin's connector slug to linear_mcp, which the test fixtures had hardcoded as linear; the code reads it from the manifest and was right. An entry named linear-9f8a7c6b tells an agent nothing about which account it is reaching, and a real externalUserId is a UUID. The segment now prefers the nickname the person set, then the provider's label, then the id. All or nothing across a connector: a label for one account beside a raw id for its twin reads as two unrelated schemes.
What
Adds
cloud_workspaces.boot_agent_credential_digest(nullabletext), migration0135. Schema only.The API will write a keyed digest (HMAC with a server secret) of the creator's agent sign-ins each time a box boots. On wake it compares the digest with the current sign-ins. When they differ, the desktop shows "Agent credentials changed · Restart workspace", because running agents keep the env they started with. The API and desktop changes come in follow-up PRs, merged after this migration is live.
Migration safety
cloud_workspacesis 208 kB, ~133 rows (read-only role, 2026-10-01)ADD COLUMN ... textwith no default is a catalog-only change; the ACCESS EXCLUSIVE lock is momentary on a small table that isn't hotcloudWorkspace.listandcreatereturn full rows, so they gain this field automatically. That is an additive, nullable output field, which released clients ignore.Applied to a Neon branch of production, where it ran end to end with the API and desktop changes on a real cloud box: https://app.superset.sh/page/agent-credentials-restart-banner-wll4rn
Summary by cubic
Adds a nullable
textcolumncloud_workspaces.boot_agent_credential_digestvia migration0135. It stores a keyed digest of the creator's agent sign-ins at the box's last boot, so a later API change can detect on wake that credentials changed and prompt a restart. Schema only; API and desktop changes land in follow-up PRs.Migration
cloud_workspacesis ~133 rows / 208 kB; the add is catalog-only with a momentary lock and no foreign keys.Written for commit 69f4569. Summary will update on new commits.
Summary by CodeRabbit