Skip to content

chore(gastown): stage release updates - #4688

Open
jrf0110 wants to merge 15 commits into
mainfrom
gastown-staging
Open

chore(gastown): stage release updates#4688
jrf0110 wants to merge 15 commits into
mainfrom
gastown-staging

Conversation

@jrf0110

@jrf0110 jrf0110 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Continue the long-lived Gastown staging release PR from gastown-staging to main.
  • Remove persisted dynamic container env vars from TownContainerDO and hydrate runtime town, rig, agent, token, and auth configuration through control-server/container dispatch requests instead; boot logs now use the dynamic town id from the hydrated runtime config.
  • Fix Gastown session ingest for mayor/prewarm sessions via #3372: bump @kilocode/cli to 7.3.1, extract shared Kilo auth env construction, and pass KILO_AUTH_CONTENT, KILO_PLATFORM, and KILO_ORG_ID through the prewarm path.
  • Shorten mayor cold-start readiness via #3369: mint container JWTs without a synchronous refresh-token request, move best-effort git credential refresh and non-critical registry/worktree setup off the visible request path, prioritize mayor hydration/prewarm, and add phase timing telemetry.
  • Add Gastown to the cloud-agent sessions platform filter via #3426, so Gastown sessions can be isolated in the sessions UI.
  • Bump Gastown staging resources and make agent worktree creation idempotent when a local branch already exists but its worktree directory is missing; this prevents startup failures like fatal: a branch named '<branch>' already exists after partial setup or cleanup.
  • Exclude internal @kilocode/* packages from the pnpm minimum-release-age delay so coordinated internal package bumps can be installed during release work.
  • Treat trusted Gastown agent events and status messages as container liveness, preventing the reconciler from resetting live beads when heartbeat records are missing or stale; heartbeat startup is also retried when runtime config and tokens are injected after container boot.
  • Update production Gastown debug monitoring docs and scripts to use cloudflared access login with the cf-access-token header, while retaining service-token fallback support.

Verification

N/A for this release-rollup PR. See the constituent PRs linked above for change-specific verification notes.

Visual Changes

N/A

Reviewer Notes

This PR is intended to stay open as the ongoing Gastown staging-to-main release vehicle; more commits may be added over time. Direct commits on gastown-staging currently include the container env-var cleanup/hydration fixes, dynamic town id boot logs, resource bump, worktree branch reuse fix, pnpm release-age exception, agent-activity liveness fix, heartbeat startup hardening, and production debug monitoring auth updates. Constituent PRs merged into the staging branch include #3372, #3369, and #3426.

Supersedes #3353, which GitHub would not reopen after the required branch rebase.

Comment thread apps/web/src/components/gastown/BabysitPrPanel.tsx
Comment thread apps/web/src/components/gastown/BabysitPrPanel.tsx
Comment thread services/gastown/scripts/monitor-town.sh Outdated
Comment thread services/gastown/docs/post-deploy-monitoring.md Outdated
Comment thread services/gastown/test/unit/babysit-pr-helpers.ts Outdated
Comment thread services/gastown/test/unit/sling-existing-pr.test.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

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

CRITICAL

File Line Issue
apps/web/src/components/gastown/BabysitPrPanel.tsx 165 preview accessed without null-narrowing under isPrClosed (existing tracked comment, not yet fixed)

Note: also unresolved — CodeQL flagged possible DOM-text-as-HTML on BabysitPrPanel.tsx:203 (existing platform comment, not a Kilo finding).

Fixed since last review: wrong Cloudflare Access header (cf-access-tokenCf-Access-Jwt-Assertion) in monitor-town.sh and post-deploy-monitoring.md; tautological babysit-pr-helpers.ts tests now call the real resolveForcePushAllowed/production helpers; duplicate sling-existing-pr.test.ts file removed.

Files Reviewed (61 files)
  • apps/mobile/src/components/agents/platform-filter-modal.tsx
  • apps/web/src/app/(app)/gastown/[townId]/rigs/[rigId]/RigDetailPageClient.tsx
  • apps/web/src/app/admin/gastown/towns/[townId]/beads/[beadId]/BeadInspectorDashboard.tsx
  • apps/web/src/components/cloud-agent-next/ChatSidebar.tsx
  • apps/web/src/components/cloud-agent-next/CloudSidebarLayout.tsx
  • apps/web/src/components/gastown/ActivityFeed.tsx / .test.ts
  • apps/web/src/components/gastown/BabysitPrPanel.tsx / .test.ts - 1 issue (existing)
  • apps/web/src/components/gastown/SlingDialog.tsx
  • apps/web/src/components/gastown/drawer-panels/BeadPanel.tsx / .test.ts
  • apps/web/src/components/gastown/drawer-panels/buildRelatedBeads.ts
  • apps/web/src/components/gastown/eventDescription.ts
  • apps/web/src/lib/gastown/types/router.d.ts
  • apps/web/src/lib/gastown/types/schemas.d.ts
  • pnpm-lock.yaml (generated, skipped)
  • pnpm-workspace.yaml
  • services/gastown/container/Dockerfile / Dockerfile.dev
  • services/gastown/container/package.json
  • services/gastown/container/plugin/client.ts / .test.ts
  • services/gastown/container/plugin/mayor-tools.ts / .test.ts
  • services/gastown/container/plugin/types.ts
  • services/gastown/container/src/agent-runner.ts / .test.ts
  • services/gastown/container/src/control-server.ts
  • services/gastown/container/src/git-manager.ts
  • services/gastown/container/src/heartbeat.ts
  • services/gastown/container/src/main.ts
  • services/gastown/container/src/process-manager.ts / .test.ts
  • services/gastown/docs/post-deploy-monitoring.md - fixed
  • services/gastown/scripts/monitor-town.sh - fixed
  • services/gastown/src/db/tables/bead-events.table.ts
  • services/gastown/src/dos/Town.do.ts
  • services/gastown/src/dos/TownContainer.do.ts
  • services/gastown/src/dos/town/actions.ts
  • services/gastown/src/dos/town/agents.ts
  • services/gastown/src/dos/town/config.ts
  • services/gastown/src/dos/town/container-dispatch.ts
  • services/gastown/src/dos/town/reconciler.ts
  • services/gastown/src/dos/town/review-queue.ts
  • services/gastown/src/dos/town/staleness.ts / .test.ts
  • services/gastown/src/dos/town/town-scm.ts
  • services/gastown/src/gastown.worker.ts
  • services/gastown/src/handlers/mayor-tools.handler.ts
  • services/gastown/src/prompts/mayor-system.prompt.ts
  • services/gastown/src/prompts/polecat-system.prompt.ts
  • services/gastown/src/trpc/router.ts
  • services/gastown/src/trpc/schemas.ts
  • services/gastown/src/types.ts
  • services/gastown/src/util/platform-pr.util.ts
  • services/gastown/test/integration/reconciler.test.ts
  • services/gastown/test/unit/babysit-pr-helpers.ts - fixed
  • services/gastown/test/unit/babysit-pr.test.ts
  • services/gastown/test/unit/sling-existing-pr.test.ts - deleted (fixed)
  • services/gastown/wrangler.jsonc

Fix these issues in Kilo Cloud

Previous Review Summary (commit 9d176cd)

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

Previous review (commit 9d176cd)

Status: 5 Issues Found | Recommendation: Address before merge

Executive Summary

The new monitor-town.sh/post-deploy-monitoring.md interactive-token auth path sends the wrong Cloudflare Access header name and will not authenticate.

Overview

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

CRITICAL

File Line Issue
apps/web/src/components/gastown/BabysitPrPanel.tsx 165 preview.state accessed without null-narrowing under isPrClosed, will fail strict typecheck
services/gastown/scripts/monitor-town.sh 30 Wrong Cloudflare Access header (cf-access-token instead of Cf-Access-Jwt-Assertion); same bug in docs/post-deploy-monitoring.md:42

WARNING

File Line Issue
services/gastown/docs/post-deploy-monitoring.md 42 Documents the same wrong Cloudflare Access header as the script
services/gastown/test/unit/babysit-pr-helpers.ts 419 registerMetadataShapeTests/registerForcePushAllowedTests assert against locally-built literals instead of calling submitExternalPrToReviewQueue/resolveForcePushAllowed
services/gastown/test/unit/sling-existing-pr.test.ts 9 New file duplicates babysit-pr.test.ts registrations with no sling-specific coverage
Files Reviewed (61 files)
  • apps/mobile/src/components/agents/platform-filter-modal.tsx
  • apps/web/src/app/(app)/gastown/[townId]/rigs/[rigId]/RigDetailPageClient.tsx
  • apps/web/src/app/admin/gastown/towns/[townId]/beads/[beadId]/BeadInspectorDashboard.tsx
  • apps/web/src/components/cloud-agent-next/ChatSidebar.tsx
  • apps/web/src/components/cloud-agent-next/CloudSidebarLayout.tsx
  • apps/web/src/components/gastown/ActivityFeed.tsx / .test.ts
  • apps/web/src/components/gastown/BabysitPrPanel.tsx / .test.ts - 1 issue
  • apps/web/src/components/gastown/SlingDialog.tsx
  • apps/web/src/components/gastown/drawer-panels/BeadPanel.tsx / .test.ts
  • apps/web/src/components/gastown/drawer-panels/buildRelatedBeads.ts
  • apps/web/src/components/gastown/eventDescription.ts
  • apps/web/src/lib/gastown/types/router.d.ts
  • apps/web/src/lib/gastown/types/schemas.d.ts
  • pnpm-lock.yaml (generated, skipped)
  • pnpm-workspace.yaml
  • services/gastown/container/Dockerfile / Dockerfile.dev
  • services/gastown/container/package.json
  • services/gastown/container/plugin/client.ts / .test.ts
  • services/gastown/container/plugin/mayor-tools.ts / .test.ts
  • services/gastown/container/plugin/types.ts
  • services/gastown/container/src/agent-runner.ts / .test.ts
  • services/gastown/container/src/control-server.ts
  • services/gastown/container/src/git-manager.ts
  • services/gastown/container/src/heartbeat.ts
  • services/gastown/container/src/main.ts
  • services/gastown/container/src/process-manager.ts / .test.ts
  • services/gastown/docs/post-deploy-monitoring.md - 1 issue
  • services/gastown/scripts/monitor-town.sh - 1 issue
  • services/gastown/src/db/tables/bead-events.table.ts
  • services/gastown/src/dos/Town.do.ts
  • services/gastown/src/dos/TownContainer.do.ts
  • services/gastown/src/dos/town/actions.ts
  • services/gastown/src/dos/town/agents.ts
  • services/gastown/src/dos/town/config.ts
  • services/gastown/src/dos/town/container-dispatch.ts
  • services/gastown/src/dos/town/reconciler.ts
  • services/gastown/src/dos/town/review-queue.ts
  • services/gastown/src/dos/town/staleness.ts / .test.ts
  • services/gastown/src/dos/town/town-scm.ts
  • services/gastown/src/gastown.worker.ts
  • services/gastown/src/handlers/mayor-tools.handler.ts
  • services/gastown/src/prompts/mayor-system.prompt.ts
  • services/gastown/src/prompts/polecat-system.prompt.ts
  • services/gastown/src/trpc/router.ts
  • services/gastown/src/trpc/schemas.ts
  • services/gastown/src/types.ts
  • services/gastown/src/util/platform-pr.util.ts
  • services/gastown/test/integration/reconciler.test.ts
  • services/gastown/test/unit/babysit-pr-helpers.ts - 1 issue
  • services/gastown/test/unit/babysit-pr.test.ts
  • services/gastown/test/unit/sling-existing-pr.test.ts - 1 issue
  • services/gastown/wrangler.jsonc

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5 · Input: 38 · Output: 16.4K · Cached: 1.1M

Review guidance: REVIEW.md from base branch main

jrf0110 and others added 14 commits July 22, 2026 15:35
…rm (#3372)

Bug 1: @kilocode/cli@7.2.14 doesn't read KILO_AUTH_CONTENT, causing all
kilo serve session-ingest to silently no-op. Bumped to 7.3.1 which has the
feature. Verified KILO_AUTH_CONTENT present in binary strings.

Bug 2: buildPrewarmEnv didn't set KILO_AUTH_CONTENT, KILO_PLATFORM, or
KILO_ORG_ID, so mayor sessions (which go through prewarm) were invisible.
Extracted buildKiloAuthEnv helper from buildAgentEnv and used it in both
buildAgentEnv and buildPrewarmEnv.

Refs #3307

Co-authored-by: John Fawcett <john@kilcoode.ai>
* perf(gastown): shorten mayor cold start path

* fix(gastown): address mayor latency review feedback

* fix(gastown): remove stale mayor setup parameter

* fix(gastown): remove stale mayor setup comment
* feat(cloud-agent): add Gastown filter option to ChatSidebar and mobile modal

* fix(cloud-agent-next): remove stale comment in default branch handling

---------

Co-authored-by: John Fawcett <john@kilcoode.ai>
Make worktree creation tolerate an existing local branch with a missing worktree directory, and allow internal @kilocode package updates to bypass release-age delays.
* fix(gastown): bump @kilocode/cli to 7.3.1 + plumb auth env into prewarm (#3372)

Bug 1: @kilocode/cli@7.2.14 doesn't read KILO_AUTH_CONTENT, causing all
kilo serve session-ingest to silently no-op. Bumped to 7.3.1 which has the
feature. Verified KILO_AUTH_CONTENT present in binary strings.

Bug 2: buildPrewarmEnv didn't set KILO_AUTH_CONTENT, KILO_PLATFORM, or
KILO_ORG_ID, so mayor sessions (which go through prewarm) were invisible.
Extracted buildKiloAuthEnv helper from buildAgentEnv and used it in both
buildAgentEnv and buildPrewarmEnv.

Refs #3307

Co-authored-by: John Fawcett <john@kilcoode.ai>

* feat(gastown): Town DO slingExistingPr method (babysit PR feature, chunk 0) (#3576)

* feat(gastown): Town DO slingExistingPr method (babysit PR feature, chunk 0)

* fix(gastown): address PR review feedback on slingExistingPr

- Remove async from submitExternalPrToReviewQueue (no awaits inside)
- Add GitLab host validation in slingExistingPr URL parsing to prevent
  non-GitLab URLs (e.g. Bitbucket) from matching the GitLab regex
- Replace vacuous state validation tests with meaningful checkPRStatus
  integration tests that exercise the actual status resolution path

---------

Co-authored-by: John Fawcett <john@kilcoode.ai>

* feat(gastown): tRPC + HTTP for babysit PR (chunk 1)

Add gastown.babysitPr tRPC mutation, gastown.previewPr tRPC query,
mayor-tools babysit-pr HTTP route, refinery bypass for babysat beads,
and reconciler fast-track extension for babysat MR beads.

* chore: remove duplicate sling-existing-pr.test.ts

The file was a verbatim copy of the first 442 lines of
babysit-pr.test.ts, causing 24 tests to run twice with
zero added coverage.

* fix(gastown): resolve merge conflict markers in process-manager.test.ts

---------

Co-authored-by: John Fawcett <john@kilcoode.ai>
* feat(gastown): Town DO slingExistingPr method (babysit PR feature, chunk 0) (#3576)

* feat(gastown): Town DO slingExistingPr method (babysit PR feature, chunk 0)

* fix(gastown): address PR review feedback on slingExistingPr

- Remove async from submitExternalPrToReviewQueue (no awaits inside)
- Add GitLab host validation in slingExistingPr URL parsing to prevent
  non-GitLab URLs (e.g. Bitbucket) from matching the GitLab regex
- Replace vacuous state validation tests with meaningful checkPRStatus
  integration tests that exercise the actual status resolution path

---------

Co-authored-by: John Fawcett <john@kilcoode.ai>

* feat(gastown): tRPC + HTTP for babysit PR (chunk 1)

Add gastown.babysitPr tRPC mutation, gastown.previewPr tRPC query,
mayor-tools babysit-pr HTTP route, refinery bypass for babysat beads,
and reconciler fast-track extension for babysat MR beads.

* feat(web): BeadPanel babysit badge + metadata (chunk 4) (#3581)

feat(web): BeadPanel babysit badge + metadata surfacing (chunk 4)

- Add 'Babysat external PR' badge (cyan) when gt:babysit label present
- Hide source bead link for babysit beads (no source_bead_id)
- Add babysit metadata panel: head_sha (7-char, linked), force_push_allowed (Lock/Unlock icons), babysit_started_at (relative time)
- Add event formatters for babysit_started, pr_feedback_detected, pr_conflict_detected, pr_auto_merge, pr_status_changed
- Mirror babysit badge + metadata in BeadInspectorDashboard
- Extract buildRelatedBeads and eventDescription into separate files for testability
- Add unit tests for eventDescription and buildRelatedBeads babysit logic

Co-authored-by: John Fawcett <john@kilcoode.ai>

* feat(gastown): gt_babysit_pr mayor tool + force-push gate (chunk 2) (#3582)

* feat(gastown): gt_babysit_pr mayor tool + force-push gate (chunk 2)

Add gt_babysit_pr mayor tool registration and client method, update
mayor and polecat system prompts with babysit PR guidance and force-push
policy, surface force_push_allowed in polecat prime context, and add
corresponding unit tests.

* fix(gastown): address PR review warnings on babysit PR feature

- Rewrite PR Conflict Resolution Workflow in polecat-system.prompt.ts
  to choose strategy upfront (rebase vs merge) based on force_push_allowed,
  instead of rebase-then-abort which discarded conflict resolution work.
- Extract resolveForcePushAllowed() from agents.ts prime() so tests
  exercise the actual function instead of inlining the logic.

---------

Co-authored-by: John Fawcett <john@kilcoode.ai>

* feat(web): SlingDialog babysit-PR mode (chunk 3)

Add tabbed SlingDialog with 'Sling work' and 'Babysit existing PR' tabs.
The Babysit tab includes PR URL input with debounced preview, repo mismatch
and closed PR validation, title/body overrides, force-push checkbox, and
calls babysitPr mutation on submit. Also updates generated tRPC type
declarations for the new previewPr and babysitPr procedures.

* fix: address review feedback on PR #3583

- Fix CRITICAL: move isBabysit declaration above relatedBeads in BeadPanel.tsx
  (temporal dead zone caused ReferenceError on babysit bead renders)
- Fix WARNING: wire up userEditedTitle/userEditedBody in BabysitPrPanel.tsx
  (auto-populate title/body from preview unless user has manually edited)
- Fix WARNING: add babysit_started_at to bead metadata in
  submitExternalPrToReviewQueue so UI timestamps render correctly

* fix(web): move defaultTitle/defaultBody after preview declaration to fix TDZ bug

The defaultTitle and defaultBody const declarations referenced preview
before it was declared (temporal dead zone), causing ReferenceError on
every render. Moved them after the preview declaration.

---------

Co-authored-by: John Fawcett <john@kilcoode.ai>
* feat(gastown): Town DO slingExistingPr method (babysit PR feature, chunk 0) (#3576)

* feat(gastown): Town DO slingExistingPr method (babysit PR feature, chunk 0)

* fix(gastown): address PR review feedback on slingExistingPr

- Remove async from submitExternalPrToReviewQueue (no awaits inside)
- Add GitLab host validation in slingExistingPr URL parsing to prevent
  non-GitLab URLs (e.g. Bitbucket) from matching the GitLab regex
- Replace vacuous state validation tests with meaningful checkPRStatus
  integration tests that exercise the actual status resolution path

---------

Co-authored-by: John Fawcett <john@kilcoode.ai>

* feat(gastown): tRPC + HTTP for babysit PR (chunk 1)

Add gastown.babysitPr tRPC mutation, gastown.previewPr tRPC query,
mayor-tools babysit-pr HTTP route, refinery bypass for babysat beads,
and reconciler fast-track extension for babysat MR beads.

* feat(web): BeadPanel babysit badge + metadata (chunk 4) (#3581)

feat(web): BeadPanel babysit badge + metadata surfacing (chunk 4)

- Add 'Babysat external PR' badge (cyan) when gt:babysit label present
- Hide source bead link for babysit beads (no source_bead_id)
- Add babysit metadata panel: head_sha (7-char, linked), force_push_allowed (Lock/Unlock icons), babysit_started_at (relative time)
- Add event formatters for babysit_started, pr_feedback_detected, pr_conflict_detected, pr_auto_merge, pr_status_changed
- Mirror babysit badge + metadata in BeadInspectorDashboard
- Extract buildRelatedBeads and eventDescription into separate files for testability
- Add unit tests for eventDescription and buildRelatedBeads babysit logic

Co-authored-by: John Fawcett <john@kilcoode.ai>

* feat(gastown): gt_babysit_pr mayor tool + force-push gate (chunk 2) (#3582)

* feat(gastown): gt_babysit_pr mayor tool + force-push gate (chunk 2)

Add gt_babysit_pr mayor tool registration and client method, update
mayor and polecat system prompts with babysit PR guidance and force-push
policy, surface force_push_allowed in polecat prime context, and add
corresponding unit tests.

* fix(gastown): address PR review warnings on babysit PR feature

- Rewrite PR Conflict Resolution Workflow in polecat-system.prompt.ts
  to choose strategy upfront (rebase vs merge) based on force_push_allowed,
  instead of rebase-then-abort which discarded conflict resolution work.
- Extract resolveForcePushAllowed() from agents.ts prime() so tests
  exercise the actual function instead of inlining the logic.

---------

Co-authored-by: John Fawcett <john@kilcoode.ai>

* fix(gastown): address rework feedback for babysit PR feature

- Fix GitLab MR head SHA link in BeadPanel.tsx (regex now handles /-/merge_requests/ URLs)
- Extract shared test helpers into babysit-pr-helpers.ts to eliminate ~400 lines of duplication
- babysit_started_at already present from staging (confirmed)

* fix(web): remove duplicate isBabysit declaration in BeadPanel

---------

Co-authored-by: John Fawcett <john@kilcoode.ai>
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.

2 participants