@@ -240,7 +240,11 @@ export class TownDO extends DurableObject<Env> {
240240 }
241241
242242 private emitEvent ( data : Omit < GastownEventData , 'userId' | 'delivery' > ) : void {
243- writeEvent ( this . env , { ...data , delivery : 'internal' , userId : this . _ownerUserId } ) ;
243+ writeEvent ( this . env , {
244+ ...data ,
245+ delivery : 'internal' ,
246+ userId : this . _ownerUserId ,
247+ } ) ;
244248 }
245249
246250 /** Build the context object used by the scheduling sub-module. */
@@ -290,7 +294,9 @@ export class TownDO extends DurableObject<Env> {
290294 } ) ;
291295 }
292296
293- return scheduling . dispatchAgent ( schedulingCtx , agent , bead , { systemPromptOverride } ) ;
297+ return scheduling . dispatchAgent ( schedulingCtx , agent , bead , {
298+ systemPromptOverride,
299+ } ) ;
294300 } ,
295301 stopAgent : async agentId => {
296302 await dispatch . stopAgentInContainer ( this . env , this . townId , agentId ) ;
@@ -677,7 +683,9 @@ export class TownDO extends DurableObject<Env> {
677683 const townConfig = await this . getTownConfig ( ) ;
678684 if ( ! townConfig . kilocode_token || townConfig . kilocode_token !== rigConfig . kilocodeToken ) {
679685 console . log ( `${ TOWN_LOG } configureRig: propagating kilocodeToken to town config` ) ;
680- await this . updateTownConfig ( { kilocode_token : rigConfig . kilocodeToken } ) ;
686+ await this . updateTownConfig ( {
687+ kilocode_token : rigConfig . kilocodeToken ,
688+ } ) ;
681689 }
682690 }
683691
@@ -1214,10 +1222,14 @@ export class TownDO extends DurableObject<Env> {
12141222 * Return undelivered, non-expired nudges for an agent.
12151223 * Urgent nudges are returned first, then FIFO within same priority.
12161224 */
1217- async getPendingNudges (
1218- agentId : string
1219- ) : Promise <
1220- { nudge_id : string ; message : string ; mode : string ; priority : string ; source : string } [ ]
1225+ async getPendingNudges ( agentId : string ) : Promise <
1226+ {
1227+ nudge_id : string ;
1228+ message : string ;
1229+ mode : string ;
1230+ priority : string ;
1231+ source : string ;
1232+ } [ ]
12211233 > {
12221234 const rows = [
12231235 ...query (
@@ -1722,6 +1734,14 @@ export class TownDO extends DurableObject<Env> {
17221734 return reviewQueue . advanceMoleculeStep ( this . sql , agentId , summary ) ;
17231735 }
17241736
1737+ async getMergeQueueData ( params : {
1738+ rigId ?: string ;
1739+ limit ?: number ;
1740+ since ?: string ;
1741+ } ) : Promise < reviewQueue . MergeQueueData > {
1742+ return reviewQueue . getMergeQueueData ( this . sql , params ) ;
1743+ }
1744+
17251745 // ══════════════════════════════════════════════════════════════════
17261746 // Atomic Sling (create bead + agent + hook)
17271747 // ══════════════════════════════════════════════════════════════════
@@ -1768,7 +1788,12 @@ export class TownDO extends DurableObject<Env> {
17681788
17691789 /** Build the rig list for mayor agent startup (browse worktree setup on fresh containers). */
17701790 private async rigListForMayor ( ) : Promise <
1771- Array < { rigId : string ; gitUrl : string ; defaultBranch : string ; platformIntegrationId ?: string } >
1791+ Array < {
1792+ rigId : string ;
1793+ gitUrl : string ;
1794+ defaultBranch : string ;
1795+ platformIntegrationId ?: string ;
1796+ } >
17721797 > {
17731798 const rigRecords = rigs . listRigs ( this . sql ) ;
17741799 return Promise . all (
@@ -1792,7 +1817,10 @@ export class TownDO extends DurableObject<Env> {
17921817 message : string ,
17931818 _model ?: string ,
17941819 uiContext ?: string
1795- ) : Promise < { agentId : string ; sessionStatus : 'idle' | 'active' | 'starting' } > {
1820+ ) : Promise < {
1821+ agentId : string ;
1822+ sessionStatus : 'idle' | 'active' | 'starting' ;
1823+ } > {
17961824 const townId = this . townId ;
17971825
17981826 let mayor = agents . listAgents ( this . sql , { role : 'mayor' } ) [ 0 ] ?? null ;
@@ -1876,7 +1904,10 @@ export class TownDO extends DurableObject<Env> {
18761904 * Called eagerly on page load so the terminal is available immediately
18771905 * without requiring the user to send a message first.
18781906 */
1879- async ensureMayor ( ) : Promise < { agentId : string ; sessionStatus : 'idle' | 'active' | 'starting' } > {
1907+ async ensureMayor ( ) : Promise < {
1908+ agentId : string ;
1909+ sessionStatus : 'idle' | 'active' | 'starting' ;
1910+ } > {
18801911 const townId = this . townId ;
18811912
18821913 let mayor = agents . listAgents ( this . sql , { role : 'mayor' } ) [ 0 ] ?? null ;
@@ -2250,7 +2281,10 @@ export class TownDO extends DurableObject<Env> {
22502281 tasks : Array < { title : string ; body ?: string ; depends_on ?: number [ ] } > ;
22512282 merge_mode ?: 'review-then-land' | 'review-and-merge' ;
22522283 staged ?: boolean ;
2253- } ) : Promise < { convoy : ConvoyEntry ; beads : Array < { bead : Bead ; agent : Agent | null } > } > {
2284+ } ) : Promise < {
2285+ convoy : ConvoyEntry ;
2286+ beads : Array < { bead : Bead ; agent : Agent | null } > ;
2287+ } > {
22542288 // Resolve staged: explicit request wins, otherwise fall back to town config default.
22552289 const townConfig = await this . getTownConfig ( ) ;
22562290 const isStaged = input . staged ?? townConfig . staged_convoys_default ;
@@ -2449,9 +2483,10 @@ export class TownDO extends DurableObject<Env> {
24492483 /**
24502484 * Transition a staged convoy to active: hook agents and begin dispatch.
24512485 */
2452- async startConvoy (
2453- convoyId : string
2454- ) : Promise < { convoy : ConvoyEntry ; beads : Array < { bead : Bead ; agent : Agent | null } > } > {
2486+ async startConvoy ( convoyId : string ) : Promise < {
2487+ convoy : ConvoyEntry ;
2488+ beads : Array < { bead : Bead ; agent : Agent | null } > ;
2489+ } > {
24552490 const convoy = this . getConvoy ( convoyId ) ;
24562491 if ( ! convoy ) throw new Error ( `Convoy not found: ${ convoyId } ` ) ;
24572492 if ( ! convoy . staged ) throw new Error ( `Convoy is not staged: ${ convoyId } ` ) ;
@@ -2994,9 +3029,14 @@ export class TownDO extends DurableObject<Env> {
29943029 const violations = reconciler . checkInvariants ( this . sql ) ;
29953030 metrics . invariantViolations = violations . length ;
29963031 if ( violations . length > 0 ) {
2997- console . error (
2998- `${ TOWN_LOG } [reconciler:invariants] town=${ townId } ${ violations . length } violation(s): ${ JSON . stringify ( violations ) } `
2999- ) ;
3032+ // Emit as an analytics event for observability dashboards instead
3033+ // of console.error (which spams Workers logs every 5s per town).
3034+ this . emitEvent ( {
3035+ event : 'reconciler.invariant_violations' ,
3036+ townId,
3037+ label : violations . map ( v => `[${ v . invariant } ] ${ v . message } ` ) . join ( '; ' ) ,
3038+ value : violations . length ,
3039+ } ) ;
30003040 }
30013041 } catch ( err ) {
30023042 console . warn ( `${ TOWN_LOG } [reconciler:invariants] town=${ townId } check failed` , err ) ;
@@ -3575,7 +3615,13 @@ export class TownDO extends DurableObject<Env> {
35753615 [ ]
35763616 ) ,
35773617 ] ;
3578- const beadCounts = { open : 0 , inProgress : 0 , inReview : 0 , failed : 0 , triageRequests : 0 } ;
3618+ const beadCounts = {
3619+ open : 0 ,
3620+ inProgress : 0 ,
3621+ inReview : 0 ,
3622+ failed : 0 ,
3623+ triageRequests : 0 ,
3624+ } ;
35793625 for ( const row of beadRows ) {
35803626 const s = `${ row . status as string } ` ;
35813627 const c = Number ( row . cnt ) ;
0 commit comments