mig: add upstream identity and validation columns to remote_sessions - #6100
Open
daviddanialy wants to merge 1 commit into
Open
mig: add upstream identity and validation columns to remote_sessions#6100daviddanialy wants to merge 1 commit into
daviddanialy wants to merge 1 commit into
Conversation
Contributor
🦋 Changeset detectedLatest commit: dc45ad5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
|
||||||||||||||||
Contributor
|
|
||||||||||||||||
Contributor
There was a problem hiding this comment.
1 issue found across 7 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="server/database/schema.sql">
<violation number="1" location="server/database/schema.sql:2581">
P1: Custom agent: **Flag Security Vulnerabilities**
Soft-deleted sessions retain the new upstream identity and personal data. `remote_sessions` uses `deleted_at` rather than physical deletion, and this schema adds no trigger or deletion rule to clear `upstream_email`, the other identity fields, or `enrichment`; clear these fields in every session-revocation path (including client/issuer cascades) or enforce clearing at the database layer.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
This was referenced Sep 4, 2026
daviddanialy
force-pushed
the
aim-200-KvG6
branch
from
September 4, 2026 23:31
585a47c to
1653150
Compare
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C555wgLmfbVWf4oxK7FvwB
daviddanialy
force-pushed
the
aim-203-session-enrichment-mig
branch
from
September 4, 2026 23:33
a995d37 to
dc45ad5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AIM-203, part 1 of 2. Stacked on #6090; merge that first. Supersedes #6099, which GitHub closed when its base branch was folded into #6090.
Summary
remote_sessions, all with no default:upstream_subject,upstream_email,upstream_email_verified,upstream_display_name,upstream_picture_url,upstream_session_id,upstream_auth_time,identity_source,identity_verified_at,enrichment jsonblast_validated_at,validation_status,validation_reasonidentity_sourceandvalidation_statusare plain text with values validated in application code, following the repo rule of not using CHECK constraints for enumerations. NULL on both means no interface has reported yet.Motivation
A remote session stores tokens and deadlines only, so the consent page cannot say who an upstream grant belongs to or whether the token still works. It infers "Connected" from timestamps, which is wrong for revoked tokens and meaningless for the 15% of prod sessions whose provider issues non-expiring tokens without a refresh token. These columns hold what the enrichment interfaces return, normalised into one typed projection with a verbatim JSON column for the rest, and the last observed validity of the token.
upstream_emailis the first third-party email Gram persists; it is stored in plaintext like every other email column and is cleared with the session.Plain
ADD COLUMN ... NULL, no rewrite or scan.No index ships with these columns on purpose. Every value is NULL until the writers land, so an index now is maintenance cost on a hot table with nothing to shape a plan, and the two lookups that will want one (push revocation by issuer, client, and subject; the validation sweep by status) cannot have their column order and partial predicate chosen until those queries exist. Atlas emits
CREATE INDEX CONCURRENTLY, so adding it later against populated rows is online. The query PR owes the index.🤖 Generated with Claude Code
https://claude.ai/code/session_01C555wgLmfbVWf4oxK7FvwB
Summary by cubic
Part 1 of AIM-203 adds nullable upstream identity and validation columns to
remote_sessions, which currently stores only tokens and deadlines, so the consent page can later show who an upstream grant belongs to and whether its token still works. This PR is schema, Atlas migration, changeset, and regenerated sqlc models only; nothing writes the columns yet.NULLmeans no enrichment interface has reported yet.enrichmentstores the unmodeled remainder of an enrichment response as JSONB.upstream_emailis stored in plaintext like existing email columns and cleared with the session.identity_sourceandvalidation_status, with values validated in application code.ADD COLUMN ... NULL; no index ships yet because every value is NULL until the writers land.Written for commit dc45ad5. Summary will update on new commits.