Skip to content

feat(auth): migrate shared resource credentials (phase 5.2) - #5857

Closed
pandemicsyn wants to merge 42 commits into
mainfrom
feat/shared-token-issuer-migration
Closed

feat(auth): migrate shared resource credentials (phase 5.2)#5857
pandemicsyn wants to merge 42 commits into
mainfrom
feat/shared-token-issuer-migration

Conversation

@pandemicsyn

@pandemicsyn pandemicsyn commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds audience-bound tokens behind separate rollout flags. Existing CLI and mobile clients keep legacy issuance by default. Modern credentials retain scoped renewal and recovery support during rollback.

Rollout settings

For this merge: enable nothing. Leave all new adoption flags false or unset. Merging automatically deploys the services; wait until all deployments are healthy before changing flags.

Later: enable one family at a time

First pass that family's end-to-end smoke test. Then, in both web projects (kilocode-app and kilocode-global-app), set SHARED_RESOURCE_TOKENS_ENABLED=true and one of these flags to true. Leave the others off until separately validated.

Family Web flag to enable
Chat, events, notifications CHAT_RESOURCE_TOKENS_ENABLED
Explicit API/gateway, attribution, HTML delegation DELEGATED_RESOURCE_TOKENS_ENABLED
Workflow gateway credentials WORKFLOW_GATEWAY_RESOURCE_TOKENS_ENABLED
Auto-routing benchmarks BENCHMARK_RESOURCE_TOKENS_ENABLED

The shared flag alone enables none of these families.

Keep these off for now

Where Flag What must happen before enabling
Cloud Agent Worker RUNTIME_ISOLATION_ENABLED Pass Worker/wrapper isolation and startup/recovery smoke tests. Enable this before Cloud Agent web issuance.
Both web projects CLOUD_AGENT_RESOURCE_TOKENS_ENABLED Resolve startup/recovery smoke failures and verify isolation above; also requires the shared web flag.
Both web projects NATIVE_RESOURCE_TOKENS_ENABLED Complete CLI/mobile device and downgrade testing. Leave off in this shipping stage.
Both web projects GASTOWN_RESOURCE_TOKENS_ENABLED Fix Session Ingest audience coverage and credential renewal inside running CLI processes. Leave off in this shipping stage.
Both web projects WASTELAND_RESOURCE_TOKENS_ENABLED Verify its complete consumer chain.
Security Auto Analysis Worker Its own SHARED_RESOURCE_TOKENS_ENABLED Validate this Worker's issuance/consumer chain independently.
Webhook Agent Ingest Worker Its own SHARED_RESOURCE_TOKENS_ENABLED Validate this Worker's issuance/consumer chain independently.

Web flags do not change Worker settings. Leave the separate Phase 5.1 flag, BOUNDED_INTERNAL_SERVICE_TOKENS_ENABLED, unchanged.

Rollback: turn the affected producer flag off. Keep modern readers, renewal, and runtime support deployed for existing credentials. If Cloud Agent isolation was enabled, let outstanding admission credentials drain before turning it off.

Validation

  • Latest local smoke matrix: 9 passed, 4 failed. Legacy and unified cold/warm chats passed; intermittent startup and sandbox recovery failures remain. SDK cold-wake acceptance also failed. This is not a clean smoke-test sign-off.
  • Smoke-harness fixes: 85 unit tests passed. Runtime tests above used default-off adoption flags; modern control-plane, physical-device, and real-provider acceptance remain unverified.

Implementation details: token issuance policy.

@pandemicsyn
pandemicsyn marked this pull request as ready for review September 4, 2026 20:05
Comment thread services/cloud-agent-next/src/session/session-registration.ts
@kilo-code-bot

kilo-code-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
services/cloud-agent-next/src/session/session-registration.ts 959 Ledger replay can persist the caller control JWT as kilocodeToken for policy-bearing sessions, skipping destination-bound runtime authorization and Vercel proxy-handle injection
Files Reviewed (8 files)
  • services/cloud-agent-next/test/e2e/README.md
  • services/cloud-agent-next/test/e2e/client.ts
  • services/cloud-agent-next/test/e2e/fake-llm-server.ts
  • services/cloud-agent-next/test/e2e/lifecycle.ts
  • services/cloud-agent-next/test/e2e/smoke-cleanup.ts
  • services/cloud-agent-next/test/e2e/smoke.ts
  • services/cloud-agent-next/test/unit/fake-llm-server.test.ts
  • services/cloud-agent-next/test/unit/smoke-cleanup.test.ts

Fix these issues in Kilo Cloud

Previous Review Summaries (4 snapshots, latest commit c4c1ecb)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit c4c1ecb)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
services/cloud-agent-next/src/session/session-registration.ts 959 Ledger replay can persist the caller control JWT as kilocodeToken for policy-bearing sessions, skipping destination-bound runtime authorization and Vercel proxy-handle injection
Files Reviewed (24 files)
  • apps/web/src/lib/user/deletion-queue/deletion-constants.ts
  • apps/web/src/lib/user/deletion-queue/deletion-hints.ts
  • apps/web/src/lib/user/deletion-queue/handlers/anonymize.test.ts
  • apps/web/src/lib/user/deletion-queue/handlers/anonymize.ts
  • apps/web/src/lib/user/index.ts
  • apps/web/src/lib/user/owned-by-user-batch-delete.test.ts
  • apps/web/src/lib/user/owned-by-user-batch-delete.ts
  • services/cloud-agent-next/src/persistence/SandboxControl.ts
  • services/cloud-agent-next/src/router/handlers/session-worktree.test.ts
  • services/cloud-agent-next/src/router/handlers/session-worktree.ts
  • services/cloud-agent-next/src/sandbox-control/socket.test.ts
  • services/cloud-agent-next/src/sandbox-control/socket.ts
  • services/cloud-agent-next/src/sandbox-session/SandboxSession.ts
  • services/cloud-agent-next/src/sandbox-session/attach-payload.test.ts
  • services/cloud-agent-next/src/sandbox-session/attach-payload.ts
  • services/cloud-agent-next/src/shared/sandbox-control-protocol.ts
  • services/cloud-agent-next/test/integration/sandbox-control.test.ts
  • services/cloud-agent-next/test/integration/session/prepared-admission-control-plane.test.ts
  • services/cloud-agent-next/wrapper/src/control/apply-attach.test.ts
  • services/cloud-agent-next/wrapper/src/control/apply-attach.ts
  • services/cloud-agent-next/wrapper/src/control/operation-intent.ts
  • services/cloud-agent-next/wrapper/src/control/operation-registry.test.ts
  • services/cloud-agent-next/wrapper/src/control/sandbox-control-client.test.ts
  • services/cloud-agent-next/wrapper/src/control/sandbox-control-client.ts

Fix these issues in Kilo Cloud

Previous review (commit 853dc5e)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
services/cloud-agent-next/src/session/session-registration.ts 959 Ledger replay can persist the caller control JWT as kilocodeToken for policy-bearing sessions, skipping destination-bound runtime authorization and Vercel proxy-handle injection
Files Reviewed (240 files)
  • services/cloud-agent-next/src/session/session-registration.ts - 1 issue
  • services/cloud-agent-next/src/runtime-credential-proxy.ts
  • services/cloud-agent-next/src/runtime-credential-proxy-rpc.ts
  • services/cloud-agent-next/src/kilo/runtime-credential-proxy-routes.ts
  • services/cloud-agent-next/src/server.ts
  • services/cloud-agent-next/src/sandbox-control/session-credentials.ts
  • services/cloud-agent-next/src/sandbox-control/vercel-network-policy.ts
  • services/cloud-agent-next/src/persistence/CloudAgentSession.ts
  • services/cloud-agent-next/src/persistence/SandboxControl.ts
  • services/cloud-agent-next/src/sandbox-session/SandboxSession.ts
  • services/cloud-agent-next/src/router/handlers/session-worktree.ts
  • services/cloud-agent-next/src/session-service.ts
  • services/cloud-agent-next/src/session/runtime-authorization-persistence.ts
  • packages/worker-utils/src/runtime-authorization.ts
  • packages/worker-utils/src/kilo-token.ts
  • packages/worker-utils/src/kilo-token-policy.ts
  • packages/worker-utils/src/runtime-proxy-attestation.ts
  • packages/worker-utils/src/kilo-auth-middleware.ts
  • apps/web/src/lib/auth/resource-delegation.ts
  • apps/web/src/lib/tokens.ts
  • apps/web/src/app/api/auth/native/token/route.ts
  • apps/mobile/src/lib/auth/credentials.ts
  • apps/mobile/src/lib/auth/auth-context.tsx
  • services/gastown/src/dos/town/legacy-token-renewal.ts
  • services/gastown/src/dos/town/runtime-authorization.ts
  • services/security-auto-analysis/src/token.ts
  • services/webhook-agent-ingest/src/services/token-minting-service.ts
  • services/session-ingest/src/middleware/kilo-jwt-auth.ts
  • remaining auth, router, test, wrapper, and merge-reconciled files in the 240-file diff

Fix these issues in Kilo Cloud

Previous review (commit ecf3d94)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
services/cloud-agent-next/src/session/session-registration.ts 953 Ledger replay can persist the caller control JWT as kilocodeToken for policy-bearing sessions, skipping destination-bound runtime authorization and Vercel proxy-handle injection
Files Reviewed (40 files)
  • apps/web/src/app/api/internal/auto-routing-benchmark/token/route.ts
  • apps/web/src/app/api/internal/auto-routing-benchmark/token/route.test.ts
  • packages/worker-utils/src/kilo-token-policy.test.ts
  • services/cloud-agent-next/src/kilo/runtime-credential-proxy-routes.ts
  • services/cloud-agent-next/src/runtime-credential-proxy.ts
  • services/cloud-agent-next/src/runtime-credential-proxy.test.ts
  • services/cloud-agent-next/src/server.ts
  • services/cloud-agent-next/src/server.test.ts
  • services/cloud-agent-next/src/persistence/SandboxControl.ts
  • services/cloud-agent-next/src/sandbox-control/session-credentials.ts
  • services/cloud-agent-next/src/sandbox-control/vercel-network-policy.ts
  • services/cloud-agent-next/src/sandbox-session/SandboxSession.ts
  • services/cloud-agent-next/src/sandbox-session/control-rpc.ts
  • services/cloud-agent-next/src/session-service.ts
  • services/cloud-agent-next/src/shared/wrapper-bootstrap.ts
  • services/cloud-agent-next/wrapper/src/control/delete-worktree.ts
  • services/cloud-agent-next/wrapper/src/control/main.ts
  • services/cloud-agent-next/wrapper/src/control/sandbox-control-handlers.ts
  • services/cloud-agent-next/wrapper/src/control/terminal-runtime.ts
  • services/cloud-agent-next/wrapper/src/control/worktree-runtime.ts
  • remaining incremental wrapper, e2e, and fixture files in the 40-file diff

Fix these issues in Kilo Cloud

Previous review (commit e76dbb8)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
services/cloud-agent-next/src/session/session-registration.ts 953 Ledger replay can persist the caller control JWT as kilocodeToken for policy-bearing sessions, skipping destination-bound runtime authorization and Vercel proxy-handle injection
Files Reviewed (178 files)
  • services/cloud-agent-next/src/session/session-registration.ts - 1 issue
  • services/cloud-agent-next/src/runtime-credential-proxy.ts
  • services/cloud-agent-next/src/runtime-credential-proxy-rpc.ts
  • services/cloud-agent-next/src/kilo/runtime-credential-proxy-routes.ts
  • services/cloud-agent-next/src/server.ts
  • services/cloud-agent-next/src/sandbox-control/session-credentials.ts
  • services/cloud-agent-next/src/sandbox-control/vercel-network-policy.ts
  • services/cloud-agent-next/src/persistence/CloudAgentSession.ts
  • services/cloud-agent-next/src/persistence/SandboxControl.ts
  • services/cloud-agent-next/src/sandbox-session/SandboxSession.ts
  • services/cloud-agent-next/src/router/handlers/session-worktree.ts
  • services/cloud-agent-next/src/session-service.ts
  • services/cloud-agent-next/src/session/runtime-authorization-persistence.ts
  • packages/worker-utils/src/runtime-authorization.ts
  • packages/worker-utils/src/kilo-token.ts
  • packages/worker-utils/src/kilo-token-policy.ts
  • packages/worker-utils/src/runtime-proxy-attestation.ts
  • apps/web/src/lib/auth/resource-delegation.ts
  • apps/web/src/lib/tokens.ts
  • apps/web/src/app/api/auth/native/token/route.ts
  • apps/mobile/src/lib/auth/credentials.ts
  • apps/mobile/src/lib/auth/auth-context.tsx
  • services/gastown/src/dos/town/legacy-token-renewal.ts
  • services/gastown/src/dos/town/runtime-authorization.ts
  • services/security-auto-analysis/src/token.ts
  • services/webhook-agent-ingest/src/services/token-minting-service.ts
  • services/session-ingest/src/middleware/kilo-jwt-auth.ts
  • remaining auth, router, test, and generated files in the 178-file diff

Fix these issues in Kilo Cloud


Reviewed by grok-4.6 · Input: 240.4K · Output: 15.3K · Cached: 481K

Review guidance: REVIEW.md from base branch main

@pandemicsyn
pandemicsyn marked this pull request as draft September 4, 2026 21:31
Preserve delegation and authorization work for handoff. Modern Cloud Agent dispatch is fail-closed; proxy prototypes are not wired. Keep the PR draft and shared issuance disabled.
@pandemicsyn
pandemicsyn force-pushed the feat/shared-token-issuer-migration branch from 6123d6d to 2416519 Compare September 8, 2026 04:13
@pandemicsyn
pandemicsyn marked this pull request as ready for review September 8, 2026 13:42
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