Repository navigation
fix(gastown): stop towns whose owner lacks Gastown access - #8558
Conversation
Town, user and org HTTP routes now require the gastownAccess claim or an admin token. Plain Kilo API keys no longer bypass the PostHog flag. The TownDO alarm checks the owner's gastown-access flag every 10 minutes. When the flag is off, it stops the running container and blocks all container starts in TownContainerDO. The run policy cannot clear the block.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryReviewed the Gastown access-revocation change end to end — the new route gate, the alarm-driven owner check, the container-level start block, and the PostHog flag util — and found no correctness or security defects on the changed lines. Assumptions: Files Reviewed (14 files)
Reviewed by deepseek-flash-latest · Input: 262.9K · Output: 51.1K · Cached: 5.6M Review guidance: REVIEW.md from base branch |
Summary
Gastown is EOL, but the
gastown-accessgate let users keep running towns. Some use them only for compute. This PR stops towns whose owner is not in thegastown-accessPostHog flag, and blocks their HTTP API access./api/users/*,/api/towns/*and/api/orgs/*now require thegastownAccessclaim or an admin token (gastownRouteAccessMiddleware). Plain Kilo API keys never carry the claim, so they no longer bypass the flag. tRPC already had this check.dos/town/owner-access.ts). The owner is the user the mayor runs as. When the flag is off, the alarm stops the container.TownContainerDO.setAccessRevokedstores a block, andassertAutomaticStartsEnabledandonStartenforce it, so warm-up, fetch, WebSocket and rig setup all fail. The block is separate from the run policy, so the owner cannot clear it. It clears when the owner is back in the flag.util/gastown-access-flag.util.tscalls PostHog/flags/?v=2with the same body asposthog-nodegetFeatureFlag, scoped to this one flag. This is the call the web token route makes. Outside production, access is always allowed, as in the web app. A missing flag counts as denied. A PostHog error or quota limit keeps the last verdict.every()fromhono/combine. Before this, a 403 fromtownAuthMiddlewarewas lost and returned as a 500.NEXT_PUBLIC_POSTHOG_KEYtowrangler.jsonc. kiloclaw and kilo-mcp already commit the same token.Verification
/flagsrequest with the worker's body. A cohort user returnsenabled: true(condition_match). An unknown id returnsenabled: false(no_condition_match), witherrorsWhileComputingFlags: false.typecheckandlintpass.owner-access,user-route-auth): 50 passed. On main, the full integration suite fails 52 tests, and this branch fails the same 52.Visual Changes
N/A
Reviewer Notes
/api/towns/:townId/rigs/:rigId/*keep their own auth, which containers need. A revoked owner can still write beads there, but no container can start.