Skip to content

fix(gastown): guard eviction resets with heartbeat#3566

Merged
jrf0110 merged 1 commit into
gastown-stagingfrom
3538-gastown-eviction-heartbeat
May 28, 2026
Merged

fix(gastown): guard eviction resets with heartbeat#3566
jrf0110 merged 1 commit into
gastown-stagingfrom
3538-gastown-eviction-heartbeat

Conversation

@jrf0110

@jrf0110 jrf0110 commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Guard agentCompleted container-eviction bead resets with the same 90s heartbeat freshness window used by the reconciler.
  • Share the heartbeat staleness constant/helper so live polecats keep their in-progress bead assignment while still unhooking the exited agent process.
  • Add regression coverage for fresh, stale, and missing heartbeats plus the Town DO fresh-heartbeat eviction path.

Verification

Not manually tested; non-visual Durable Object state-machine change.

Visual Changes

N/A

Reviewer Notes

Local automated checks were attempted after PR creation per issue instructions, but this shell has no pnpm, Node, Corepack, or Nix available on PATH, so pnpm format, pnpm typecheck, pnpm lint, and pnpm test could not start. The branch was pushed with --no-verify as requested.

Fixes #3538

@kilo-code-bot

kilo-code-bot Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Clean refactor that correctly guards container-eviction resets with the heartbeat freshness window; the extracted staleness.ts module, updated agentCompleted logic, and test coverage are all consistent and correct.

Files Reviewed (5 files)
  • services/gastown/src/dos/town/staleness.ts — new module, clean extraction
  • services/gastown/src/dos/town/staleness.test.ts — unit tests for heartbeatStale
  • services/gastown/src/dos/town/reconciler.ts — constants replaced with shared HEARTBEAT_STALE_MS
  • services/gastown/src/dos/town/review-queue.ts — eviction guard with fresh-heartbeat check
  • services/gastown/test/integration/reconciler.test.ts — integration coverage for fresh-heartbeat eviction path

Behaviour verified:

  • Fresh heartbeat → bead stays in_progress, agent is unhooked and set idle; the stale assignee_agent_bead_id on the bead remains intact so the Reconciler Rule 3 (5 min STALE_IN_PROGRESS_TIMEOUT_MS) naturally cleans it up if no agent reconnects — this is the intended design.
  • Stale heartbeat → existing reset-to-open path fires as before.
  • reconciler.ts lines 725 and 904 now reference the shared constant instead of duplicate 90_000 literals.

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-4.6 · 802,954 tokens

Review guidance: REVIEW.md from base branch main

@jrf0110
jrf0110 changed the base branch from main to gastown-staging May 28, 2026 16:08
@jrf0110
jrf0110 force-pushed the gastown-staging branch from 8e60feb to c52272a Compare May 28, 2026 16:08
@jrf0110
jrf0110 merged commit 1e7c8a1 into gastown-staging May 28, 2026
13 checks passed
@jrf0110
jrf0110 deleted the 3538-gastown-eviction-heartbeat branch May 28, 2026 16:33
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.

[Gastown] Beads flap in_progress↔open while polecat is heartbeating (container eviction event mishandled)

1 participant