Skip to content

feat(gastown): babysit existing PR feature#3601

Merged
jrf0110 merged 6 commits into
gastown-stagingfrom
convoy/babysit-existing-pr-feature-re-staged/254a4b7e/head
May 30, 2026
Merged

feat(gastown): babysit existing PR feature#3601
jrf0110 merged 6 commits into
gastown-stagingfrom
convoy/babysit-existing-pr-feature-re-staged/254a4b7e/head

Conversation

@jrf0110

@jrf0110 jrf0110 commented May 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the "babysit existing PR" feature to Gastown, allowing towns to adopt and manage external PRs (created manually, by other tools, or by third parties). The town polls the PR, addresses review feedback, fixes merge conflicts, and auto-merges — bypassing the refinery code review path since the user is opting into "merge this PR", not "review this PR".

Key changes across 4 chunks:

  • Chunk 0 (Town DO): slingExistingPr and previewPr methods on TownDO — validates PR URL against rig repo, checks PR status via SCM, creates a merge_request bead with gt:babysit label and babysit metadata (head_sha, force_push_allowed)
  • Chunk 1 (tRPC + HTTP): babysitPr and previewPr tRPC mutations + POST /api/mayor/:townId/tools/babysit-pr HTTP handler for mayor tool access
  • Chunk 2 (Mayor tool + force-push gate): gt_babysit_pr mayor tool, force_push_allowed metadata propagated through pr_fixup_context/pr_conflict_context in prime context, polecat prompt updated with force-push policy (default false for babysat PRs = merge-only, no history rewriting)
  • Chunk 3 (SlingDialog + UI): SlingDialog babysit-PR mode, BeadPanel babysit badge and metadata display, eventDescription extracted to module with babysit event types, buildRelatedBeads extracted for testability, ActivityFeed icons/colors for babysit events, Gastown platform filter in sessions UI

Also includes infrastructure improvements:

  • Container env var refactor: Removes setEnvVar/deleteEnvVar from TownContainerDO in favor of passing config through control server request protocol (/sync-config, /refresh-token, /agents/start). Eliminates stale persisted env var issues across DO evictions and container restarts.
  • Mayor cold start optimization: Backgrounds browse worktree setup, logs timing metrics for workspace creation and AGENTS.md writes
  • Boot hydration optimization: Prioritizes mayor resume over non-mayor agents, uses Zod validation for registry entries, defers non-mayor resumes
  • SDK bump: @kilocode/sdk 7.2.14 → 7.3.1, @kilocode/cli 7.2.14 → 7.3.1
  • Container max instances: 500 → 700

Verification

  • Tested babysit PR flow via mayor tool in staging environment
  • Verified babysat PR beads bypass refinery and fast-track to in_progress in reconciler
  • Verified force_push_allowed: false polecats use merge commits (no force-push)
  • Verified PR URL repo validation rejects cross-repo adoption
  • Verified previewPr returns correct metadata for GitHub and GitLab PRs

Visual Changes

  • Babysit badge ("Babysat external PR" with eye icon) on merge_request beads in BeadPanel
  • Babysit metadata section: Head SHA (linked to commit), Force-push status, Babysit started timestamp
  • New event icons/colors in ActivityFeed for babysit-related events
  • "Gastown" platform filter added to Cloud Agent sessions sidebar

Reviewer Notes

  • The slingExistingPr method in TownDO has duplicated PR URL parsing logic with previewPr — this is intentional to keep previewPr as a lightweight read-only path that can fail independently
  • The force_push_allowed gate defaults to true when absent (backwards compat for pre-babysit beads) — only explicit false disables force-push
  • The container env var refactor (removing setEnvVar/deleteEnvVar) is a significant infra change that removes the persisted env var store in favor of always-fresh request-scoped delivery. This eliminates stale-token bugs across DO evictions
  • 173 commits on this branch include many prior staging commits that have already been reviewed/merged separately

Comment thread apps/web/src/components/gastown/drawer-panels/BeadPanel.tsx
Comment thread apps/web/src/components/gastown/drawer-panels/BeadPanel.tsx
@kilo-code-bot

kilo-code-bot Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The duplicate const isBabysit declaration in BeadPanel.tsx has been removed — all previously flagged issues are now resolved.

Resolved Issues
File Line Issue Status
apps/web/src/components/gastown/drawer-panels/BeadPanel.tsx 259 (old) Duplicate const isBabysit declaration causing TypeScript compile error ✅ Fixed — duplicate removed in commit 324444b0c
apps/web/src/components/gastown/drawer-panels/BeadPanel.tsx 245 isBabysit used before declaration (TDZ) ✅ Fixed — declaration moved to line 239, before first use
apps/web/src/components/gastown/drawer-panels/BeadPanel.tsx 561 babysit_started_at displayed without data ✅ Fixed — review-queue.ts now writes the value
apps/web/src/app/admin/gastown/towns/[townId]/beads/[beadId]/BeadInspectorDashboard.tsx 297 Same babysit_started_at display issue ✅ Fixed — same upstream fix
Files Reviewed (7 files)
  • apps/web/src/components/gastown/drawer-panels/BeadPanel.tsx — all issues resolved
  • apps/web/src/app/admin/gastown/towns/[townId]/beads/[beadId]/BeadInspectorDashboard.tsx — no issues
  • services/gastown/src/dos/Town.do.ts — no issues
  • services/gastown/src/dos/town/review-queue.ts — no issues
  • services/gastown/test/unit/babysit-pr-helpers.ts — no issues
  • services/gastown/test/unit/babysit-pr.test.ts — no issues
  • services/gastown/test/unit/sling-existing-pr.test.ts — no issues

Reviewed by claude-sonnet-4.6 · 191,127 tokens

Review guidance: REVIEW.md from base branch gastown-staging

jrf0110 and others added 5 commits May 30, 2026 16:43
…unk 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>
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 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>
…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 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)
@jrf0110
jrf0110 force-pushed the convoy/babysit-existing-pr-feature-re-staged/254a4b7e/head branch from 879a3b7 to 6db98e9 Compare May 30, 2026 16:53
Comment thread apps/web/src/components/gastown/drawer-panels/BeadPanel.tsx Outdated
@jrf0110
jrf0110 merged commit 00f1b8f into gastown-staging May 30, 2026
2 checks passed
@jrf0110
jrf0110 deleted the convoy/babysit-existing-pr-feature-re-staged/254a4b7e/head branch May 30, 2026 17:08
jrf0110 added a commit that referenced this pull request Jul 22, 2026
* 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>
jrf0110 added a commit that referenced this pull request Jul 22, 2026
* 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.

1 participant