Skip to content

refactor(credentials): resolve Vanta tokens through the coordinated client-token resolver - #9919

Merged
waleedlatif1 merged 3 commits into
stagingfrom
refactor/vanta-coordinated-token
Nov 12, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
refactor/vanta-coordinated-token

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • vanta-token.ts is now a thin wrapper over resolveCoordinatedClientToken. The duplicated lock-and-memo machinery is gone: digests, lock_timeout, advisory lock, failure memo, decode helpers, upsert and invalidation by digest. About 180 lines are removed, so later fixes to the coordinated token chain reach Vanta too.
  • CoordinatedClientTokenInput gains four optional fields: minRemainingMs, failureKeyQualifier, accessTokenDigestTag (also accepted by invalidateCoordinatedClientToken) and pinnedState. When a field is omitted the behavior is unchanged, so Shopify, Atlassian and Linear are unaffected.
  • What Vanta reads and writes is byte-compatible with the previous code, so old and new workers share rows and contend on the same lock during a rolling deploy. That covers the row id, the advisory lock name and key, the failure-memo id and body, the access-token digest, the encrypted payload shape and order, the 30s reuse margin, and the first-mint scope pin.
  • Vanta's exported API is unchanged.

Type of Change

  • Refactor (no functional change)

Testing

  • Compatibility proofs run against real Postgres in vanta-token.integration.ts (19 pass) and coordinated-client-token.integration.ts (11 pass). Fixture rows are seeded exactly as the previous build wrote them, using inline sha256 ids and digests and real encryption. The tests show that:
    • the new resolver serves a fresh stored token without calling the provider;
    • it honors an old failure memo and the expired-row scope pin;
    • a minted token and a refusal are written where the old build reads them, with byte-equal payloads;
    • invalidation matches the old digest;
    • the resolver blocks on a raw advisory lock taken with the old key, then serves the token the "old build" commits;
    • Shopify-style defaults keep their row id, digest and memo id.
  • Five scratch format changes, made one at a time, each turned the suite red: the Vanta digest tag, the lock key, the failure-key scope, the default digest tag and the invalidation tag.
  • bunx biome check, check:test-patterns, check:comment-hygiene and check:unused-exports pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…lient-token resolver

vanta-token.ts carried a second copy of the lock-and-memo protocol in
coordinated-client-token.ts. Vanta now calls resolveCoordinatedClientToken and
invalidateCoordinatedClientToken through four optional inputs whose defaults
leave Shopify, Atlassian, and Linear rows unchanged:

- minRemainingMs: Vanta keeps its 30-second reuse margin
- failureKeyQualifier: Vanta's failure memo stays keyed by secret and scope
- accessTokenDigestTag: Vanta's token digest stays keyed by API domain
- pinnedState: Vanta's scope is stored with the token and checked against
  every stored record, expired ones included, under the lock

Row ids, the advisory lock name and key, token digests, and encrypted payloads
are unchanged, so old and new workers read each other's rows and contend on
the same lock during a rollout. Unit tests pin those formats for Vanta and for
the shared defaults; they pass against the previous code too.
@vercel

vercel Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 12, 2026 2:14am UTC

Request Review

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

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no actionable issues found.

Summary

Vanta now uses resolveCoordinatedClientToken while keeping its existing stored formats, expiry margin, and pinned permissions.

  • Vanta token requests now use the shared coordinated resolver.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  V["resolveVantaClientToken"] --> C["resolveCoordinatedClientToken"]
  C --> F{"Fresh token with matching secret and scope?"}
  F -->|Yes| R["Return stored token"]
  F -->|No| L["Take application lock"]
  L --> S["Recheck token and pinned scope"]
  S --> M["Reuse token, replay refusal, or mint"]
  M --> D["Store encrypted result"]
Loading

Reviews (3) · Last reviewed commit: "test(credentials): prove rolling-deploy ..." · Reviewed by Greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

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

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

…eal Postgres

Replace the mock-based unit tests for the coordinated resolver and the Vanta token chain
with integration tests that seed rows exactly as the previous build wrote them (inline
sha256 ids and digests, real encryptSecret) and read back what the new resolver writes.
They cover a fresh stored token, a remembered refusal, the expired-row scope pin,
mint and refusal payloads at the old ids, invalidation by the old digest, the old
build's advisory lock blocking a new resolution, and the default Shopify-style formats.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

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

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 56f7ed7 into staging Nov 12, 2026
78 of 79 checks passed
@waleedlatif1
waleedlatif1 deleted the refactor/vanta-coordinated-token branch November 12, 2026 02:18

This branch was previously deployed

1 inactive deployment
Preview — e85c16fc Deployed Nov 12, 2026 by vercel[bot]
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