Skip to content

fix(api): platform GCP orphan sweep auth (box branch, P1b) - #2750

Closed
simple-agent-manager[bot] wants to merge 5 commits into
sam/selfhost-pass-2from
sam/p1b-box-orphan-sweep-gcp
Closed

simple-agent-manager[bot] wants to merge 5 commits into
sam/selfhost-pass-2from
sam/p1b-box-orphan-sweep-gcp

Conversation

@simple-agent-manager

Copy link
Copy Markdown
Contributor

Summary

Box branch for task P1b (01M7FBJF8CK4Y9KTY1PW4Y9QTR). Ports the platform-GCP orphan sweep fix from sam/task-p1-find-out-jq3vp8 (P1, task 01M7E7PHTQH57W6EPC8ZJQ3VP8) onto the self-host integration branch so it can be proven on the self-host test box, whose only cloud provider is Google Cloud through a platform credential with workload identity.

  • provider-orphan-reconciliation-core.ts resolveProvider(): a platform GCP credential (workload identity or service-account key) now builds a GCP provider through the existing createGcpTokenProvider / createGcpProviderForEnv path, acting as the credential's creator with no project scope. Before, the static provider builder rejected every GCP credential, so the sweep failed on every five-minute cron.
  • platform-credentials.ts: getPlatformCloudCredential() also returns createdBy.
  • scheduled/handler.ts: contained per-credential sweep errors are reported through the durable isolate path; partial-success counters are kept.
  • Tests: provider-orphan-platform-gcp.test.ts (real encrypted platform credential lookup, token exchange, provider HTTP boundary, owned vs foreign/legacy) and handler-kill-switch.test.ts additions.

Runtime/test diff is the same as P1's except for one conflict in handler.ts, where the integration branch's reverse-tunnel lease sweep was kept next to it. Task files are not included.

Draft. Do not merge. It may be made moot by the next merge of main into sam/selfhost-pass-2.

Validation

  • Focused orphan + handler tests: 6 files, 81 tests pass
  • apps/api typecheck, eslint and prettier on the changed files pass
  • CI (dispatched by hand)
  • Box round R16: live proof on the self-host test box

🤖 Generated with Claude Code

…ep (box branch)

Port of sam/task-p1-find-out-jq3vp8 runtime + tests onto sam/selfhost-pass-2:
resolveProvider builds a GCP provider (WIF or key) for a platform GCP credential,
and the scheduled handler reports contained per-credential sweep errors through
the durable isolate path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one): 1

  • coderabbit-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

raphaeltm and others added 3 commits November 15, 2026 11:33
Pure move, no behaviour change: claim check, final ownership re-read, delete
and deletion record move from provider-orphan-reconciliation-core.ts (575
lines) to provider-orphan-destroy.ts, ahead of a change to the delete path
(file size rule 18). Candidate and OwnershipScope become exported types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same change as 3f6d352 + 253e666 on sam/task-p1b-prove-platform-dyk8zb:
per-call request timeouts, sweep-budget deadline, and send-and-return GCP
deletion bound to the re-read instance (expectedInstance), counted as
deletionRequested. Found on the box in R16: one 5 s signal for the whole pass
aborted the GCP delete before it was sent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the security-auditor, cloudflare-specialist, test-engineer and
task-completion-validator reviews:

- Claim lookup batches node ids under D1's 100 bound-parameter limit; a
  backlog of 100+ orphans failed every pass before.
- The GCP delete is bound to the re-read's zone and ownership labels:
  expectedInstance.labels are re-checked on the provider's last read before
  the DELETE, and a known zone is read directly instead of walking every
  labelled zone. A re-read without a zone is refused, not bound by id alone.
- Failures confined to one user/project account count as accountErrors and
  no longer fail the platform sweep, so one tenant's dead credential cannot
  mask a platform failure or page operators every hour.
- Tests: delete-boundary label/id change, 105-candidate backlog against a D1
  fake enforcing the bind limit, persisted audit record, hung re-read, mid-pass
  budget, no-zone refusal, wider INCIDENT margins with an elapsed precondition.
- Deferred MEDIUM/LOW items filed in tasks/backlog/2026-11-15-provider-orphan-sweep-followups.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CodeRabbit (major): moving every failure inside a user/project account pass
into accountErrors also hid D1 claim-lookup failures, so every account could
fail against the shared database while the sweep reported green. Classify at
the source instead: provider-attributable failures (list, re-read, delete,
credential resolution) go to accountErrors for user/project accounts and to
errors for the platform account; a D1 claim-lookup failure stays in errors
wherever it happens. Also corrects the follow-up backlog note: the audit write
runs after the delete request (CodeRabbit minor).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@simple-agent-manager

Copy link
Copy Markdown
Contributor Author

Closing as superseded (self-host coordinator, task 01M7FB384QHQ1TQCK95D0SX0TX). This was the box branch for the orphan sweep fix. The reviewed version of the same fix landed on main as #2757 (a886029) and reached sam/selfhost-pass-2 through #2758 (a9da517), so the integration branch now carries main's version of every runtime file here. The box proof this branch was used for is recorded in the note "BOX ROUND R16 (orphan sweep fix)" on SAM idea 01M77HYN8N41MQ17TQZ622PPPV. The branch is kept.

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