Skip to content

Phase 3, ticket #22: Hand-off delivery works with real postgres-mode thread access - #26

Merged
codaswin merged 1 commit into
mainfrom
brooklyn-base
Oct 29, 2026
Merged

codaswin merged 1 commit into
mainfrom
brooklyn-base

Conversation

@codaswin

Copy link
Copy Markdown
Owner

Summary

  • copilot.ts's postgres branch returned throwing stand-ins for threadLock/history/runnerConnection (Phase 1), since nothing called them while hand-offs were guarded off entirely. Replaced with real implementations backed by the Phase 2 ThreadBackend.
  • CopilotRuntimeMount.runner replaces runnerConnection: it hands out the actual runner instance mountCopilotRuntime drives chat through, not connection details to build a second one. In postgres mode this is the literal same PostgresAgentRunner the mounted CopilotRuntime uses — one shared instance, not a second one, which is what makes decision Approval resumption's saved-tool-call check reads through ThreadBackend #28's idempotent re-acquire fix load-bearing here too.
  • New createPostgresThreadLock (beside createPostgresThreadBackend): creates the thread if needed, then locks it, firing onRunBusy — the postgres-mode mirror of createIntelligenceThreadLock, simpler since ThreadBackend.acquire already answers a conflict with null and there's no Learning container to resolve in this mode.
  • handoff-wiring.ts now takes copilotRuntime.runner directly instead of building its own IntelligenceAgentRunner from connection details. index.ts's mode guard on startHandoffDelivery is removed.

See docs/brooklyn/DECISIONS.md #29 for the full reasoning, including why the "3-Bot group" acceptance criterion is covered structurally (ticket #21's createTurnRunner fix + this ticket's real thread access) rather than by a new dedicated test, with a genuine browser-level run-through left to Aswin's Phase 4 manual checklist.

Closes #22.

Test plan

  • bun run typecheck / bun run lint — green
  • New handoff-postgres-backend.test.ts: drives createHandoffDelivery against the real postgres-mode runner/threadLock/history trio directly — a hop into its own scratch thread (locked, runs, released), and a scratch thread somebody else already holds (waited for, not failed)
  • Existing agent-handoff-delivery.test.ts, learning-handoff.test.ts, group-conversations*.test.ts, enterprise-controls.integration.test.ts — all pass unchanged, confirming intelligence mode's hand-off behavior is untouched
  • Full suite (bun test): 8206 pass / 18 fail / 9 errors, same pre-existing categories (agent-bot subprocess $PATH, live-provider network tests, one load-induced timeout flake) — no regressions

🤖 Generated with Claude Code

…22)

copilot.ts's postgres branch returned throwing stand-ins for
threadLock/history/runnerConnection (Phase 1), since nothing called
them while hand-offs were guarded off entirely. Replaced with real
implementations backed by the Phase 2 ThreadBackend:

- CopilotRuntimeMount.runner replaces runnerConnection: it hands out
  the actual runner instance mountCopilotRuntime drives chat through,
  not connection details to build a second one. In postgres mode this
  is the literal same PostgresAgentRunner the mounted CopilotRuntime
  uses -- one shared instance, not a second one, which is what makes
  decision #28's idempotent re-acquire fix load-bearing here too.
- threadLock is createPostgresThreadLock (new, beside
  createPostgresThreadBackend): creates the thread if needed, then
  locks it, firing onRunBusy -- the postgres-mode mirror of
  createIntelligenceThreadLock, simpler since ThreadBackend.acquire
  already answers a conflict with null and there is no Learning
  container to resolve in this mode.
- history reads through ThreadBackend.getThreadMessages.

handoff-wiring.ts now takes copilotRuntime.runner directly instead of
building its own IntelligenceAgentRunner from connection details.
index.ts's mode guard on startHandoffDelivery is removed.

New tests (handoff-postgres-backend.test.ts) drive createHandoffDelivery
against this real postgres-mode trio directly: a hop into its own
scratch thread, locked and released; and a scratch thread somebody
else already holds, waited for rather than failed. Existing hand-off
and group-conversation tests continue to pass unchanged, confirming
intelligence mode is untouched.

See docs/brooklyn/DECISIONS.md #29.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@codaswin
codaswin merged commit 53642ba into main Oct 29, 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.

Hand-off delivery works with real postgres-mode thread access: hand-offs, groups, busy-thread waiting

2 participants