Skip to content

mig: add MCP approval workflow tables - #5035

Open
daviddanialy wants to merge 1 commit into
mainfrom
daviddanialy/ais-466-mig-mcp-approval-workflow-schema
Open

mig: add MCP approval workflow tables#5035
daviddanialy wants to merge 1 commit into
mainfrom
daviddanialy/ais-466-mig-mcp-approval-workflow-schema

Conversation

@daviddanialy

@daviddanialy daviddanialy commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Schema foundation for the MCP approval workflow (AIS-466): a request-and-approve
flow for unverified MCP servers, where an admin decides with assembled evidence
rather than the platform issuing a verdict.

Migration only — no application code. The services that read these tables follow
in later PRs.

Tables

Table Purpose
mcp_approval_requests One review per server per project
mcp_approval_request_requesters Who asked and why
mcp_research_reports Async research-agent output
mcp_approval_decisions Append-only approve/deny history

Why these are separate from risk_policy_bypass_requests

The existing bypass request means "let me past this block": personal, one-off,
keyed per requester, satisfied by granting risk_policy:bypass. An approval
request asks whether a server is allowed at the organization at all — durable,
carrying an evidence trail and a re-review lifecycle.

The two are linked rather than merged: a block still mints a bypass request, and
mcp_approval_requests.risk_policy_bypass_request_id records a promotion.
Bending one record into the other would have compromised both.

Design notes

Evidence is JSONB in two places, deliberately. mcp_approval_requests.current_evidence
is a refreshable cache of the latest signal gather. mcp_approval_decisions.evidence_snapshot
is a frozen copy taken at decision time. The duplication is the point: a decision
record has to show what the reviewer actually saw, so it must not follow a later
refresh. JSONB rather than columns because the payload is only ever read back
whole for one request, and the signal set grows as sources are added.

Decisions are append-only. A re-review adds a row rather than replacing one,
so the sequence of decisions on a server becomes the history that a chat channel
does not preserve. granted_principal_urns records the resolved blast radius —
requester, team, or organization — rather than a mode, keeping the audit trail
honest about who was actually given access.

Approvals are project-scoped, matching risk_policies and the shadow-MCP
enforcement path so a decision can reconcile into existing grants.

No enum CHECK constraints on status / decision; allowed values are
validated in application code per the schema conventions. The CHECKs present
are structural (jsonb_typeof(...) = 'object'), matching
risk_policy_bypass_requests.target_dimensions.

Migration safety

All four tables are new, so no ACCESS EXCLUSIVE scan on an existing table and
no PG305/PG306 lint warnings. Applied locally and atlas migrate diff reports
the directory synced with schema.sql.


Summary by cubic

Add MCP approval workflow schema (AIS-466). Introduces project-scoped approval requests, requesters, research reports, and append-only decisions with frozen evidence to support admin review of unverified MCP servers.

  • Migration
    • Adds mcp_approval_requests, mcp_approval_request_requesters, mcp_research_reports, and mcp_approval_decisions.
    • Adds dedupe/lookup indexes (incl. project + target_kind + target_key), composite FKs (request_id, project_id) so child rows can’t cross projects, unique (report_id, request_id) so decisions only cite research for the same request, unique (request_id, user_id) to dedupe requesters, and non-partial indexes to back ON DELETE cascades.
    • Evidence is JSONB with versioning; decisions snapshot evidence and are append-only; evidence_version on decisions has no default; ships a new migration and regenerated server/internal/database/models.go.

Written for commit 921bed8. Summary will update on new commits.

Review in cubic

@daviddanialy
daviddanialy requested a review from a team as a code owner August 6, 2026 23:07
@daviddanialy daviddanialy added enhancement New feature or request go Pull requests that update go code labels Aug 6, 2026
@linear-code

linear-code Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

AIS-466

@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: da1f26d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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

cubic analysis

All reported issues were addressed across 4 files

Linked issue analysis

Linked issue: AIS-466: mig: MCP approval workflow schema

Status Acceptance criteria Notes
PR is a migration (mig:) PR with the new MCP approval workflow schema committed PR title uses the mig: prefix and the repo contains a new migration file and schema updates as part of this commit.
Create mcp_approval_requests table with expected fields (target_kind, target_raw, target_key, current_evidence, evidence_version, artifact_ref, version_pinned, risk_policy_bypass_request_id, status, timestamps, soft-delete) schema.sql contains CREATE TABLE IF NOT EXISTS mcp_approval_requests with the listed columns, constraints, and comments.
Create mcp_approval_request_requesters table (requester rows attached to a request) schema.sql and the migration file include mcp_approval_request_requesters with foreign key to mcp_approval_requests and required columns.
Create mcp_research_reports table for agent findings (report JSONB, run metadata, timestamps) schema.sql and migration add mcp_research_reports with report JSONB, versioning, model/prompt fields, timestamps, and FK to mcp_approval_requests.
Create mcp_approval_decisions table (append-only decisions with evidence_snapshot, rationale, granted_principal_urns, decided_at) schema.sql and migration add mcp_approval_decisions with evidence_snapshot JSONB, rationale, granted_principal_urns, decided_at, and FK relations.
Regenerated committed DB models (models.go) matching the new schema server/internal/database/models.go includes new generated types for McpApprovalRequest, McpApprovalRequestRequester, McpResearchReport, and McpApprovalDecision consistent with the schema additions.

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Comment thread server/database/schema.sql Outdated
Comment thread server/database/schema.sql Outdated
Comment thread server/migrations/20260807160345_mcp-approval-workflow.sql
Comment thread server/migrations/20260807160345_mcp-approval-workflow.sql
Comment thread server/migrations/20260807160345_mcp-approval-workflow.sql
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

atlas migrate lint on server/migrations

Status Step Result
1 new migration file detected 20260806225751_mcp-approval-workflow.sql
ERD and visual diff generated View Visualization
No issues found View Report
Read the full linting report on Atlas Cloud

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

atlas migrate lint on server/clickhouse/migrations

Status Step Result
No migration files detected  
ERD and visual diff generated View Visualization
No issues found View Report
Read the full linting report on Atlas Cloud

@daviddanialy
daviddanialy force-pushed the daviddanialy/ais-466-mig-mcp-approval-workflow-schema branch 2 times, most recently from c9115b4 to da1f26d Compare August 6, 2026 23:52
@daviddanialy daviddanialy reopened this Aug 7, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 7, 2026
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@daviddanialy
daviddanialy force-pushed the daviddanialy/ais-466-mig-mcp-approval-workflow-schema branch from da1f26d to 921bed8 Compare August 7, 2026 16:05
@daviddanialy daviddanialy reopened this Aug 7, 2026
@daviddanialy

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants