Skip to content

fix(publish): find the personal drive's bucket in the region its distribution names - #24866

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
crew/issue-triage/fix-24820-drive-bucket-region
Oct 27, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
crew/issue-triage/fix-24820-drive-bucket-region

Conversation

@iamwhatever

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A second Kiro Crew install in the same AWS account can publish to the account's one personal drive, even when its deploy profile points at a different region.

Install A (profile region us-east-1) publishes once and builds the drive. Install B in the same account (profile region us-west-2) then tries to publish. B finds the drive's CloudFront distribution, because that is global. B does not find the drive's bucket, because the bucket lookup asks the tagging API in B's region only. B then refuses with "the storage bucket is missing", and can never publish.

Why it matters

The drive is one per account by design, so every install in the account must find the same drive. Today any install whose profile region differs from the drive's is locked out of Publish, and the error tells the user a bucket is missing when it is not. Workshop stands hit this: their bootstrap pre-creates the drive and swallows the failure, so Publish is silently broken.

Not a goal

  • Per-install drives (a configurable drive name or tag value). The drive stays one per account.
  • Moving or migrating existing buckets between regions.
  • Any change to the bucket policy, ACLs or IAM policy.
  • The AWS Control drive in src/kiro_crew/apps/builtins/aws_control/backend/storage_drive.py. It has the same single-region bucket lookup and is left for a separate issue.
  • The upload path. Open PR fix(publish): upload the personal-drive body from an opened descriptor #24733 edits the same file there; this PR touches discovery only.

What changed (motivation → approach → change)

Root cause: discovery asked for the bucket in the profile's region only, while the distribution is found from any region. A bucket in another region read as "missing".

Fix (src/kiro_crew/publish/personal_drive.py): when the bucket is not found in the profile's region but the drive's distribution is, read the distribution's S3 origin (<bucket>.s3.<region>.amazonaws.com). That names the bucket's region. Discovery then runs the same tag query in that region. It uses the bucket only if that query reports the same drive-scheme bucket. So the origin says where to look, and the drive tag still decides what is trusted.

This needs no new permission: cloudfront:GetDistribution is already used by the drive's status check. A real half-present drive (no tagged bucket anywhere the origin points) still raises the same refusal.

Backwards compatibility

Compatible: discovery only gains a second place to look when the first one missed; every drive found today is found the same way.

Removes nothing: no key, record, path or check is removed; the half-present refusal is kept.

Tests

  • test_a_drive_built_in_another_region_is_shared_not_refused: bucket in us-east-1, profile in us-west-2. Publish reuses the drive and builds nothing.
  • test_an_untagged_bucket_at_the_origin_is_still_a_half_present_drive: the origin names a region whose tag query does not report the bucket. Publish still refuses and builds nothing.
  • The test spy gains a bucket_region option and answers cloudfront get-distribution with the drive's origin.

Proof: not provable -- other: prove.py's throwaway tree errored at collection on every hunk on this host, so I ran two hand mutants instead. Removing the origin fallback turns the first test red; skipping the tag check at the origin turns the second test red.

Scoped runs: test/test_publish_personal_drive.py (95 passed) and the provisioning, read-back and registration drive files (59 passed); flake8, isort, black and mypy clean on the changed files.

Self-review (the local GPT and Opus reviewers were not run: the host's subagent gate stayed paused on memory, so CI's review lanes judge this head):

  • Trust: the origin only picks the region. A bucket is used only when that region's drive-tag query reports it and its name matches the drive scheme.
  • Failure: a get-distribution error propagates as an error and is never read as "no drive", so nothing gets rebuilt.
  • Region text comes from a strict regex and is passed as a list argument, never through a shell.
  • Downstream S3 calls run under the profile's region. The AWS CLI follows S3's cross-region redirect for them. This is not exercised against real AWS here.

Manual verification

N/A — unit coverage sufficient: discovery is driven entirely through the stubbed AWS CLI surface, and the two cases above are the whole behaviour change. Not run against a real two-region account.

Related Issues

Closes #24820

Sibling sweep

Swept: git grep -n '"resourcegroupstaggingapi"' -- src
Sibling: src/kiro_crew/apps/builtins/aws_control/backend/storage_drive.py -- not affected -- no global distribution to pair with, so there is no half-present refusal
Sibling: src/kiro_crew/deploy/engine.py -- not affected -- deploy sites are looked up in the region the site was deployed to
Sibling: src/kiro_crew/cloud/ec2.py -- not affected -- EC2 resources are regional by nature

Pattern harvest

Rule candidate: review-prompt
Pattern: an account-scoped resource discovered through a region-scoped API (resourcegroupstaggingapi) without saying which region the resource lives in.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners October 27, 2026 11:21
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 3da7df8eb9e9fd4e1b3394fc177e563483a6ecb0 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 3da7df8eb9e9fd4e1b3394fc177e563483a6ecb0 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The fix works at the mechanism level, and the one unfixed sibling (the AWS Control drive) is deferred in the description by name.

Notes

  • Item 1 — inherited: after discovery, the upload still runs in the profile's region. It rests on "The AWS CLI follows S3's cross-region redirect for them. This is not exercised against real AWS here." If that is wrong, the change only moves the failure from discovery to upload. It does not lock out any install that works today.

What this change ships

Inventory (3 items) — 2 justified

Intent: let a second install in the same AWS account publish to the account's one personal drive when its profile region differs from the region the drive was built in. FIX.

  1. A second install whose profile is in another region now finds the existing drive and publishes, instead of failing with "bucket is missing" — justified
  2. When the bucket is missing locally but the distribution exists, discovery reads the distribution's origin to find the bucket's region, then checks the drive tag there — justified
  3. After discovery, uploads to a bucket in another region rely on the AWS CLI's cross-region redirect — inherited, premise unverified

[FIRST-PRINCIPLES-REVIEWED] 3da7df8

Description read

[DESCRIPTION-READ] 877e75d17ed73fb92ec1b5899086e215ecc17d5d8da332a82958599f3d92b19e

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 3da7df8eb9e9fd4e1b3394fc177e563483a6ecb0 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

No design-level concerns: the origin only says which region to search, the drive tag still decides which bucket is trusted, and the change is purely additive with a clean revert.

Notes

  • After discovery, every S3 call (_reassert_bucket_policy, uploads, deletes) still runs under the profile's region and passes no --region, so it relies on botocore's cross-region redirect. The PR says this was never exercised against real AWS. One two-region manual publish would confirm it.

[DESIGN-REVIEWED] 3da7df8

Description read

[DESCRIPTION-READ] 9f8d17e122281575fe1865d140ce83a58583cff00587cc40119b2675e04633ab

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 3da7df8eb9e9fd4e1b3394fc177e563483a6ecb0 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 3da7df8

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 3da7df8eb9e9fd4e1b3394fc177e563483a6ecb0 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 3da7df8eb9e9fd4e1b3394fc177e563483a6ecb0 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 3da7df8

Verdict parsed from the review's SHA-scoped output markers for commit 3da7df8eb9e9fd4e1b3394fc177e563483a6ecb0.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 3da7df8eb9e9fd4e1b3394fc177e563483a6ecb0 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 27, 2026
@iamwhatever
iamwhatever force-pushed the crew/issue-triage/fix-24820-drive-bucket-region branch from 8edcf8b to 1898b7f Compare October 27, 2026 11:40
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 27, 2026
@iamwhatever
iamwhatever force-pushed the crew/issue-triage/fix-24820-drive-bucket-region branch from 1898b7f to 3da7df8 Compare October 27, 2026 12:51
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 27, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 27, 2026 15:07

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tier 1 auto-approve: fix (3 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: finds the personal drive's bucket in the region its CloudFront origin names, still requiring the drive tag and naming scheme; with tests.

@KiroCrewCaptain
KiroCrewCaptain merged commit 493e2b9 into main Oct 27, 2026
108 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the crew/issue-triage/fix-24820-drive-bucket-region branch October 27, 2026 15:10
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 27, 2026
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.

Publish drive: one per account, but its bucket is found per region, so a second install in another region cannot publish

2 participants