Keep chat reach checks out of per-publication attention and Crew rebuilds

This commit is contained in:
Jinwoo-H
2026-11-08 15:17:44 -05:00
parent 6844ffd85f
commit bc35114839
2 changed files with 10 additions and 2 deletions
@@ -19,6 +19,7 @@ import {
sessionActivityEvidence
} from '../../../../shared/orchestration/fleet/orchestration-fleet-worker-projection'
import { createSessionWorkerLivenessReader } from '../workers/lifecycle/session-worker-liveness'
import { isStructuredWorkerHandle } from '../../../../shared/orchestration/workers/structured-worker-handle'
import { federatedMessageNamesOnlyHome } from '../workers/reports/dispatch-report-mailbox'
import { workerReportRefusal } from '../workers/reports/worker-report-admission'
import { isEquivalentPaneKey } from '../db/pane-key-match'
@@ -154,7 +155,10 @@ export function buildCrewSnapshot(
evidence.binding.terminalHandle === target.terminalHandle &&
evidence.binding.paneKey === target.paneKey &&
(evidence.binding.kind !== 'worker' || evidence.binding.dispatchId === assignment?.id)))
const session = worker ? observeSession(worker) : undefined
// Chats keep their own status row: their reach check queries SQLite on every Crew rebuild.
const session = isStructuredWorkerHandle(worker?.agentTerminalHandle)
? observeSession(worker!)
: undefined
const fresh = session
? sessionActivityEvidence(session)
: bound && projectLiveness({ resource: null }, evidence, now).verdict === 'live'
@@ -77,7 +77,7 @@ export type DispatchSessionObserver = (
dispatch: Pick<DispatchContextRow, 'id' | 'assignee_handle' | 'process_incarnation'>
) => FleetSessionObservation | undefined
/** One verdict per Dispatch, so a batched attention pass reads the verdict its pane projection took. */
/** Structured workers' verdicts for per-pane attention, once per Dispatch so the batched pass reads the same one. */
export function createDispatchSessionLivenessReader(
...args: Parameters<typeof createSessionWorkerLivenessReader>
): {
@@ -88,6 +88,10 @@ export function createDispatchSessionLivenessReader(
const byDispatch = new Map<string, FleetSessionObservation | undefined>()
return {
observe: (dispatch) => {
// A chat's reach check queries SQLite; this runs per publication, so chats keep their status row here.
if (!isStructuredWorkerHandle(dispatch.assignee_handle)) {
return undefined
}
if (!byDispatch.has(dispatch.id)) {
byDispatch.set(
dispatch.id,