Skip to content

feat(mcp): preserve legacy grants and add read-only identity consent - #524

Closed
yxr-2025 wants to merge 19 commits into
Noveum:mainfrom
yxr-2025:feature/agent-consent-binding
Closed

yxr-2025 wants to merge 19 commits into
Noveum:mainfrom
yxr-2025:feature/agent-consent-binding

Conversation

@yxr-2025

@yxr-2025 yxr-2025 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Current integration and release instructions

The current-main integration continues in #565 on fix/agent-consent-binding-current, preserving this PR's contribution history. This original PR remains at c1136dea41cbc9cc9d9efbf6095d33802a466001 until its replacement merges. Its earlier artifact and migration tables are superseded.

The active sequence is reader #564, compatibility #562 with 0034, read-only bound consent #565 with 0035, then controlled Issue writes #566 with 0036. Released history through 0033 stays immutable. The deployable compatibility artifact is e4c50b1779c34bf15674cd5588b7dd703e3ca4ca.

Release and deploy compatibility separately before applying 0035. The final consent checkout applies every pending migration without pausing for that runtime deployment. Exclude and drain retired OAuth/MCP runtimes before dropping the global index; verified compatible canonical writers may continue serving. Keep Agent gates off until their independent prerequisites are proven. Preserve expanded schema/history and the partial legacy index for rollback.

#565 contains the updated source, runbook, current-main focused verification and fresh CI/review status. Its final combined full verification and staged production evidence remain required. No production activation is implied by the historical approvals or tests retained on this original PR.

Refs #512, #523, #525, #562, #564, #565, #566.

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

Thanks for your first pull request to Orbit.

Two things that will save you a review round: bun run verify runs the
same four checks CI does, and the repo has no comments in code by policy,
so bun run check-comments will flag any you added out of habit.

A maintainer will review this shortly. Ask anything on the thread.

@github-actions github-actions Bot added documentation Docs, the README, or anything that explains Orbit tests Test coverage and test infrastructure area: web The Next.js app and its UI area: mcp The MCP server, its tools and its OAuth area: database Schema, migrations, queries, seed area: auth Sign-in, sessions, passkeys, OAuth area: policy Roles, permissions and authorization labels Oct 5, 2026
Comment thread packages/core/src/auth/mcp-token.ts Dismissed

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

The credential domains, grant/version binding, original-membership checks, consent validation, and refresh/revocation handling hold up in the reviewed paths. The focused migration/rollout, core auth, and MCP suites pass. I agree the HMAC password-hashing alert is a false positive and have explained/resolved that review thread; its underlying code-scanning disposition still needs to be completed.

The deployment stack is blocked: this head and the pinned compatibility-stage artifacts still carry the superseded 0030, so an actual release after current #516 fails on its checksum. Please provide synchronized, separately deployable stage 3a and 3b artifacts and verify #516 -> stage 3a release/deploy -> stage 3b release/deploy. Deploying only the final checkout applies both migrations without the required intermediate runtime deployment.

@yxr-2025

Copy link
Copy Markdown
Contributor Author

PR #524: local staged deployment validation

The single-instance local production-build sequence passed. No production environment was touched. The accompanying evidence bundle contains the file paths referenced below. The rehearsal ran on 14 October 2026 against one isolated database, preserving its data through all migrations and runtime switches.

Stage Fixed source commit Schema at initial startup
#516 911cfcbc19140b2b4e8f97ee3ce553f1b718d877 Through 0030, 31 ledger entries
3a 94b92a2e50f24defb8ce22a3a4110795de686e5c Through 0031, 32 ledger entries
3b 07ab2f8a3d95ce19dc3f964b6000342ee7a56614 Through 0032, 33 ledger entries

Each stage was built separately with bun run build, including the required schema guard, Next production build, and standalone preparation. The Git archive commit headers matched these SHAs. Reused dependency workspace links resolved into each stage's own /stages/<stage>/packages directory. The deployed processes ran standalone output under real Linux Node 20.19.2, with no Bun runtime. Build/tooling used Bun 1.3.14; Next was 16.4.0, better-auth 1.6.33, and Postgres 18.6. See runtime provenance (evidence/runtime-provenance.txt) and stage build logs under logs (logs/).

The Docker network was internal, HTTP was exposed only through loopback at http://localhost:45240, and database operations targeted orbit_test_pr524_runtime on orbit-pr524-postgres. There was no database reset or reseeding between stages. Postgres retained fsync, full_page_writes, and synchronous_commit enabled.

Deployment sequence and schema checks

  1. Applied feat(db): add actor schema compatibility expansion #516 migrations and started its Node runtime. Established three independent Human OAuth connections.
  2. Kept feat(db): add actor schema compatibility expansion #516 running while applying 0031. Verified its original Human access token and refresh path against the expanded schema, then stopped feat(db): add actor schema compatibility expansion #516 and started 3a.
  3. Verified 3a with Agent consent unavailable. Confirmed feat(db): add actor schema compatibility expansion #516 was stopped before applying 0032, with only 3a serving requests. On the new schema, 3a still supported existing Human credentials and issued a new Human OAuth connection that successfully created and read back an issue.
  4. Stopped 3a and started 3b with ORBIT_AGENT_MCP=false. Rechecked Human access and refresh, then restarted the same 3b artifact with the flag enabled and completed Agent authorization.

Release logs show 31 -> 32 -> 33 ledger entries. Both incremental releases applied exactly one migration; immediate repeats applied zero. All stage drift checks passed. The final ledger audit (ledger-audit.json) matched all 33 entries against canonical migration files, including unchanged #516 and 3a prefixes. The shared 0030 checksum remained e4c0f9da17988ac12dc53bc9e825d88dcea6e14a623330b003db190cfa36642b. Runtime start/stop ordering is recorded in runtime-starts.txt (evidence/runtime-starts.txt).

Credential continuity and Agent permissions

Domain fixtures and an Argon2id password account were prepared locally. Sessions and OAuth artifacts were issued through real HTTP password login, dynamic client registration, S256 PKCE authorization, consent decisions, and token exchanges. No sessions or OAuth tokens were inserted as fixtures. Requests and assertions are retained in http-evidence.jsonl (http-evidence.jsonl).

The original #516 Human access credential retained fingerprint b3d615cc573d4ae3, with zero refreshes, across all successful checkpoints. It continued identifying the same Human Principal/workspace, exposing 94 tools, creating issues, and reading them back. Its database token binding remained NULL, exercising legacy compatibility. A separate rolling credential refreshed successfully at each migration/runtime boundary. A third untouched #516 refresh credential was first exchanged successfully on 3b, preserving Human read/write scopes and producing working access credentials.

3a rejected Agent consent with HTTP 400/invalid_request; 3b with the gate disabled rejected it with HTTP 403/forbidden, “Agent connections are not enabled.” Enabling the gate issued openid offline_access orbit.read, removing requested orbit.write. Agent initialization identified the read-only connection; get_agent_identity returned its explicit identity while get_me retained the authorizing Human Principal. Its 33 tools exactly matched the permitted pure-read set plus Agent identity. Each Agent probe directly called 12 forbidden tools, receiving HTTP 200 containing MCP isError results with exact Tool <name> not found messages, including create_issue with valid team/title arguments. These were tool-access rejections, not argument-validation failures. Agent refresh preserved identity, scopes, and restrictions; issue count stayed 15 -> 15 during refresh and its repeated tool probes.

After issuance, disabling the gate and then rolling runtime back to 3a rejected the existing Agent access credential with HTTP 401 for initialization, tool listing, and tool calls. Human access/refresh remained functional. Restoring 3b with the gate enabled restored the same Agent credential, and the original Human credential still created/read an issue. Final database assertions confirmed four legacy grants, one explicitly bound Agent grant, preserved NULL/explicit issue Owners, and unchanged historical identity snapshots.

Corrections and limits

The log retains preparation failures: an unsupported fixture role owner initially caused Human writes to fail; correcting it to admin made the already-issued credentials pass without reauthorization. A rollback probe initially expected the wrong rejection message; correcting the harness expectation and rerunning confirmed HTTP 401. During evidence collection, an accidental #516 db:release invocation against the final schema exited 1 with “migration ledger is ahead of this checkout.” This was an execution mistake, not a planned negative test. Subsequent ledger checks passed; before/after recorded snapshots matched apart from labels/timestamps.

This validates a serial, single-instance local switch. It does not establish Node 22 parity, multi-instance or zero-downtime rollout, Vercel behavior, browser consent UI, passkey step-up, external-provider authentication, or production rollout. A full repository verify rerun is not claimed.
PR-524-validation-evidence.zip

Copy link
Copy Markdown
Contributor

Recorded the security disposition for CodeQL alert 49 as a false positive after checking the data flow. mcp-token.ts:60 verifies a keyed HMAC-SHA-256 signature over a grant-bound OAuth bearer credential with BETTER_AUTH_SECRET and timingSafeEqual; this is not human password hashing. The shared alert also affects #525. The code-scanning rule remains enabled. The staged production compatibility rollout and final fresh checks are still required.

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

The source changes requested in the prior review are fixed. Independently verified the exact #516 -> stage 3a 94b92a2 -> stage 3b 07ab2f8 release sequence, unchanged ledger prefixes, repeat releases, original v1 credentials, and stage 3a legacy writes after 0032. Current migration tests pass 36/36, core authorization/consent/token tests 39/39, MCP authorization/server/tool tests 75/75, and web provider/consent/settings tests 51/51. Workspace types, lint, and policy checks pass. The HMAC CodeQL alert is recorded as a false positive with its rationale.

This is source approval. Keep the PR as a draft until the stage 3a compatibility runtime is separately deployed and verified in production before applying 0032. Update with current main and obtain fresh green checks before the final merge. Do not run the final checkout's release while the pre-3a runtime remains active.

@imshashank

Copy link
Copy Markdown
Contributor

@yxr-2025 a heads-up for the whole stack. #531 merged 0031_broad_lifeguard to main, and it's already applied in production: it adds organization.project_staleness_days and the stale notification reason. This branch's 0031_mcp_grant_compatibility and 0032_mcp_agent_grant_binding, and #525's 0033_issue_actor_write_compatibility, now collide with it. That's why #524 and #525 show conflicts in _journal.json and 0031_snapshot.json.

Please merge main and regenerate the stack's migrations with drizzle-kit so they follow 0031_broad_lifeguard, as 0032, 0033 and 0034, each with a journal when later than 0031's. Don't edit 0030 or 0031. Then rerun the release tests on the actual sequence: main's ledger through 0031, then your stages in order. The staged rollout notes on this PR refer to "0032" as the binding migration; that becomes 0033 after the renumber, so please update the runbook text to match. The source approval stands otherwise. Please get fresh green CI on the regenerated head before we stage it.

@yxr-2025

Copy link
Copy Markdown
Contributor Author

@imshashank, the migration synchronization requested in your latest comment is complete across the stack.

Both rollout stages and #525 now include main ad1206e. Released 0030_actor_schema_expand and 0031_broad_lifeguard, including their SQL, snapshots and journal entries, are unchanged. The unpublished Drizzle migrations and snapshot ancestry have been regenerated after main's 0031; their journal when values are strictly increasing and later than 0031.

Stage Current artifact Migration
3a compatibility 037e941376a42ba730e3d75d974ad1f6bbc415ca 0032_mcp_grant_compatibility
3b identity consent, #524 4ae17a6def6f833d62a103bb11d5cf00b09eab75 0033_mcp_agent_grant_binding
Issue writes, #525 c2aa691e04f668e658c5b2ac88e57f489b5d6b3f 0034_issue_actor_write_compatibility

The MCP rollout runbook, Issue write runbook and PR descriptions now use these numbers and pinned artifacts.

Fresh validation

New rehearsal evidence, 23 October 2026

Replayed the actual immutable main -> 3a -> 3b -> Issue write checkouts against one dedicated local PostgreSQL database, orbit_test_sync_rollout, on an isolated Docker network. The successful sequence retained that database across stages.

Checkout First release Immediate repeat Schema drift
main through 0031 32 applied, 32 total 0 applied current
3a, 0032 1 applied, 33 total 0 applied current
3b, 0033 1 applied, 34 total 0 applied current
Issue writes, 0034 1 applied, 35 total 0 applied current

Existing business rows, historical identity, consent and legacy credentials survived. The main-issued credential remained accepted through the compatibility and binding upgrades. The 3b service created two exact read-only Agent grants for one client/user. The actual 3a service then created/updated Human issues and reauthorized the legacy grant after 0033, preserving both Agent grants and their tokens. Repeating the 3a compatibility checks after 0034 also passed, including Actor mirrors and read-only Agent scopes.

Sanitized excerpts from the new rehearsal logs

staged-rollout-main.log:

{"mode":"main","first":{"mode":"migrated","applied":32,"total":32},"second":{"mode":"current","applied":0,"total":32},"drift":"current"}

staged-rollout-stage3a.log:

{"mode":"stage3a","first":{"mode":"migrated","applied":1,"total":33},"second":{"mode":"current","applied":0,"total":33},"drift":"current"}

staged-rollout-stage3b.log:

{"mode":"stage3b","first":{"mode":"migrated","applied":1,"total":34},"second":{"mode":"current","applied":0,"total":34},"drift":"current"}

staged-rollout-stage4.log:

{"mode":"stage4","first":{"mode":"migrated","applied":1,"total":35},"second":{"mode":"current","applied":0,"total":35},"drift":"current"}

Both staged-rollout-legacy-after3b.log and staged-rollout-legacy-after4.log:

Legacy credential remains accepted by this exact checkout.
Stage 3a binary writes Human issues and preserves both Agent grants and tokens.

The rehearsal's two setup expectations were corrected: a valid fixture workspace slug, and the final-stage Owner initialization after 0034. The first fresh rehearsal database was recreated after the slug setup error. The final sequence and all six phases passed without product source changes. Post-rehearsal tracked-file diffs and source-tree checks passed in all four containers.

Verified source trees:

This new evidence covers isolated PostgreSQL release/drift and service-level compatibility on the actual Linux checkouts. Production, multi-instance and Vercel rollout verification remain pending.

Production is on hold. Both PRs remain Draft. No production deployment, target production database migration or feature-gate change has been performed or is being initiated. The separate 3a release/deployment/verification remains a prerequisite before applying 0033; the final checkout will not be released against production ahead of that step.

Please re-check the synchronized artifacts and the evidence above when convenient. Thank you.

@imshashank

Copy link
Copy Markdown
Contributor

Thanks @yxr-2025, I checked the renumbering. 0030 and 0031 are unchanged from main, the new migrations are 0032 to 0034 with increasing journal timestamps, and the snapshot chain links up correctly on both #524 and #525. CI is green apart from a label job that failed to start, which I re-ran. Nothing else needed from you right now. These stay as drafts until we do the staged production rollout.

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

Re-reviewed the current consent/binding head and pinned compatibility artifact 037e941. Released migration SQL, snapshots and journal prefix through 0031 are unchanged; 0032/0033 numbering and snapshot ancestry are correct. The exact main -> stage 3a -> stage 3b -> Issue write database rehearsal passed with repeat releases, immutable ledger prefixes, preserved historical NULL Owner/timestamps/Sync IDs and surviving legacy/Agent credentials. Current auth, provider/consent and rollout regressions pass. No additional concrete source defect found. This approval does not establish production readiness: keep the draft, merge current main and complete fresh reviews/checks, separately release and deploy stage 3a everywhere before 0033, and keep the Agent gate disabled until the documented runtime prerequisites are verified.

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

Re-reviewed this head and retained stage 3a artifact 8cc8462. Released SQL, snapshots and journal entries through main's 0033 are unchanged; compatibility and binding correctly follow as 0034 and 0035. Actual main -> stage 3a -> stage 3b -> Issue-write rehearsal passed with 34 -> 35 -> 36 -> 37 ledger entries, repeat releases, immutable prefixes, preserved historical responsibility/timestamps/Sync ID, surviving legacy and separate read-only Agent credentials, and a working stage 3a legacy writer after global-index removal. Independently passed 44 Core auth, 56 Web OAuth/settings and 25 database release/rollout tests. No additional concrete source defect found. Preserve this draft: deploy stage 3a to every affected instance before 0035, and retain default-off gates until documented runtime checks pass. Refresh the PR description's superseded 037e941/0032/0033 rollout table to match the checked-in runbook before using it operationally.

Copy link
Copy Markdown
Contributor

Current-main integration follow-up after #554 merged as 58d7aa6: merge-tree now conflicts in packages/mcp-server/src/server.ts and tools/index.ts. Preserve the public app URL plumbing and the explicit Human/Agent identity argument, tool filtering and instructions together; do not resolve by dropping either side. Rerun scope/identity, canonical-link and OAuth tests on the integrated head. Before production rollout, rebuild and revalidate the retained stage3a artifact from the integrated baseline so deploying it does not roll back the newly shipped MCP-link behavior. Preserve the immutable migration prefix, separate stage3a deployment before 0035, default-off gates and the draft. The earlier approval applies to reviewed source head c1136de, not an untested merge resolution.

Copy link
Copy Markdown
Contributor

Implemented through the reviewed compatibility and binding replacements #562 and #565, now merged with the current main integration. Migration 0035 has been applied separately and verified, preserving the existing ledger and credentials. Closing this superseded PR; the original source history is retained.

@imshashank imshashank closed this Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: auth Sign-in, sessions, passkeys, OAuth area: database Schema, migrations, queries, seed area: mcp The MCP server, its tools and its OAuth area: policy Roles, permissions and authorization area: web The Next.js app and its UI documentation Docs, the README, or anything that explains Orbit tests Test coverage and test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants