Skip to content

feat(db): record the agent sign-ins a cloud workspace booted with - #8049

Merged
saddlepaddle merged 1 commit into
mainfrom
saddlepaddle/boot-agent-credential-digest-column
Oct 1, 2026
Merged

saddlepaddle merged 1 commit into
mainfrom
saddlepaddle/boot-agent-credential-digest-column

Conversation

@saddlepaddle

@saddlepaddle saddlepaddle commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

What

Adds cloud_workspaces.boot_agent_credential_digest (nullable text), migration 0135. 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

  • Production size checked: cloud_workspaces is 208 kB, ~133 rows (read-only role, 2026-10-01)
  • No column type change
  • No foreign keys, so no lock ordering concern
  • ADD COLUMN ... text with no default is a catalog-only change; the ACCESS EXCLUSIVE lock is momentary on a small table that isn't hot
  • Finishes far inside 60 s
  • Rehearsed under load: not done. Not needed for a nullable add on a 208 kB table that no job holds open
  • No reads move to this column yet
  • No tRPC input or output change written in this PR. cloudWorkspace.list and create return 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 text column cloud_workspaces.boot_agent_credential_digest via migration 0135. 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_workspaces is ~133 rows / 208 kB; the add is catalog-only with a momentary lock and no foreign keys.
  • The column is unwritten and unread until follow-ups land; the additive nullable output field is ignored by released clients.

Written for commit 69f4569. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features
    • Cloud workspace records now include a credential digest associated with agent sign-ins at startup. This adds a stored value for boot-time sign-in information; no changes to the workspace experience are noted.

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

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
.agents/skills/db-migrations/SKILL.md — Agent Skill

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 43631e05-462a-4a88-9dad-29bfb00de06b

📥 Commits

Reviewing files that changed from the base of the PR and between c4ba25b and 69f4569.

📒 Files selected for processing (4)
  • packages/db/drizzle/0135_cloud_workspace_boot_agent_credential_digest.sql
  • packages/db/drizzle/meta/0135_snapshot.json
  • packages/db/drizzle/meta/_journal.json
  • packages/db/src/schema/schema.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The cloud workspace schema and database migration add a nullable text column named boot_agent_credential_digest.

Changes

Cloud workspace credential digest

Layer / File(s) Summary
Add the boot agent credential digest column
packages/db/src/schema/schema.ts, packages/db/drizzle/0135_cloud_workspace_boot_agent_credential_digest.sql, packages/db/drizzle/meta/_journal.json
The schema and migration add a nullable text column to cloud_workspaces. The migration journal records the new migration.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~4 minutes

Change: Feature

Suggested reviewers: harshithmullapudi

Merge Risk: ⚪ Minimal · up to 69f45

This is an additive nullable-column change, and no concrete merge-blocking issue was found.

Architecture Summary

Architecture risk: 🔵 Low · up to 69f45

The change affects 1 system.

Changed systems: packages/db

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — packages/db (library) was modified; 3 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in packages/db/drizzle/0135_cloud_workspace_boot_agent_credential_digest.sql: Adds the boot_agent_credential_digest text column to cloud_workspaces.
  • observed — Modified behavior in packages/db/drizzle/meta/_journal.json: Adds migration journal entry 135, recording version 7, timestamp 1790894174033, tag 0135_cloud_workspace_boot_agent_credential_digest, and breakpoints: true.
  • observed — Modified behavior in packages/db/src/schema/schema.ts: cloudWorkspaces adds a nullable text column, bootAgentCredentialDigest, for the keyed digest of the creator’s boot-time agent sign-ins.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title uses conventional commit format and clearly describes the primary change: recording the agent sign-ins used when a cloud workspace boots.
Description check ✅ Passed The description explains the schema change, its purpose, migration safety, testing, and follow-up scope. It does not explicitly confirm lint, typecheck, or maintainer-edit settings, but it is otherwis…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@expo

expo Bot commented Oct 1, 2026

Copy link
Copy Markdown

No installed development build can load this pull request as an update: its native fingerprint is bdcb71ceb7e0 and no development build has it. Add the mobile-build label to build one.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Critical risk] Adds a database column to the cloud workspace table.

The migration appears safe to merge, but the full-row API responses should omit the digest before it is populated.

Findings

  1. P2 Security Credential digest reaches clients ▶
Fix with agent prompt
### Issue 1
packages/db/src/schema/schema.ts:895
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.

Summary

Adds a nullable cloud-workspace column for a keyed digest of the agent sign-ins present at boot, with migration 0135 and matching Drizzle metadata.

  • The schema change precedes the planned API writer and desktop comparison.
  • Existing full-row API responses will expose the digest once it is populated.

Reviews (1) · Last reviewed commit: "feat(db): record the agent sign-ins a cl..."

.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"),

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.

P2 security 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.

@cubic-dev-ai cubic-dev-ai 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.

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)
Loading

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"),

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.

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>

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

@saddlepaddle
saddlepaddle merged commit ab0a9de into main Oct 1, 2026
22 checks passed
@saddlepaddle
saddlepaddle deleted the saddlepaddle/boot-agent-credential-digest-column branch October 1, 2026 22:49
harshithmullapudi added a commit that referenced this pull request Oct 2, 2026
…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.

This branch was previously deployed

1 inactive deployment
preview — 69f4569a Deployed Oct 1, 2026 by saddlepaddle via Deploy Admin #10776
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