Skip to content

Commit e552e18

Browse files
committed
fix(mothership): keep the persisted goRoute recovery key, drop the write-only trace collector and dead _serviceCost output
Recovery rows keep the goRoute key every deployed Sim parses, so a rollback or mixed-version deploy still takes over in-flight runs; workerRoute is the in-memory name only. Also removes TraceCollector and its span plumbing (nothing read it), the _serviceCost tool output no reader consumes, Go-era span data fallbacks (pending, tool_call_id), the Go-only billing replay live test, and takes the worker contract's removal of the async tool status by owning it in async-runs.
1 parent 6eee122 commit e552e18

60 files changed

Lines changed: 179 additions & 1024 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/CODEOWNERS‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/apps/sim/app/workspace/*/home/hooks/use-chat.ts @simstudioai/mothership
2626
/apps/sim/app/workspace/*/home/hooks/preview/ @simstudioai/mothership
2727
/apps/sim/app/workspace/*/home/hooks/stream/ @simstudioai/mothership
28-
/apps/sim/hooks/queries/tasks.ts @simstudioai/mothership
28+
/apps/sim/hooks/queries/mothership-tasks.ts @simstudioai/mothership
2929

3030
# Dependency manifests and package-manager config. Any change here — adding,
3131
# removing, or bumping a dependency, or altering install/security settings —

‎apps/sim/app/api/billing/update-cost/replay.live.test.ts‎

Lines changed: 0 additions & 221 deletions
This file was deleted.

‎apps/sim/app/api/mothership/chats/[chatId]/fork/route.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,12 @@ describe('POST /api/mothership/chats/[chatId]/fork', () => {
303303

304304
expect(mockExecuteChatFileBlobCopies).toHaveBeenCalledWith(blobTasks)
305305

306-
const goCall = mockFetchWorker.mock.calls[0]
307-
expect(goCall[0]).toBe('http://mothership.test/api/chats/fork')
308-
const goBody = JSON.parse(goCall[1].body)
306+
const workerCall = mockFetchWorker.mock.calls[0]
307+
expect(workerCall[0]).toBe('http://mothership.test/api/chats/fork')
308+
const workerBody = JSON.parse(workerCall[1].body)
309309
// The copilot service only knows USER message ids, so the clone cut is the
310310
// kept slice's last user message (msg-1), not the clicked assistant (msg-2).
311-
expect(goBody).toEqual({
311+
expect(workerBody).toEqual({
312312
sourceChatId: 'chat-1',
313313
newChatId: body.id,
314314
upToMessageId: 'msg-1',

‎apps/sim/app/workspace/[workspaceId]/home/hooks/stream/handle-span-event.ts‎

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ import type {
88
StreamEventScope,
99
StreamLoopContext,
1010
} from '@/app/workspace/[workspaceId]/home/hooks/stream/stream-context'
11-
import {
12-
asPayloadRecord,
13-
FILE_SUBAGENT_ID,
14-
} from '@/app/workspace/[workspaceId]/home/hooks/stream/stream-helpers'
11+
import { FILE_SUBAGENT_ID } from '@/app/workspace/[workspaceId]/home/hooks/stream/stream-helpers'
1512

1613
type SpanEvent = Extract<PersistedStreamEventEnvelope, { type: 'span' }>
1714

@@ -29,20 +26,11 @@ export function handleSpanEvent(
2926
scope: StreamEventScope
3027
): void {
3128
const { state, ops, deps } = ctx
32-
const { scopedParentToolCallId, scopedAgentId, scopedSpanId } = scope
29+
const { scopedParentToolCallId: parentToolCallId, scopedAgentId, scopedSpanId } = scope
3330
const payload = parsed.payload
3431
if (payload.kind !== MothershipStreamV1SpanPayloadKind.subagent) {
3532
return
3633
}
37-
const spanData = asPayloadRecord(payload.data)
38-
const parentToolCallIdFromData =
39-
typeof spanData?.tool_call_id === 'string'
40-
? spanData.tool_call_id
41-
: typeof spanData?.toolCallId === 'string'
42-
? spanData.toolCallId
43-
: undefined
44-
const parentToolCallId = scopedParentToolCallId ?? parentToolCallIdFromData
45-
const isPendingPause = spanData?.pending === true
4634
const name = typeof payload.agent === 'string' ? payload.agent : scopedAgentId
4735
const runId = scopedSpanId ?? parentToolCallId
4836

@@ -79,9 +67,6 @@ export function handleSpanEvent(
7967
}
8068

8169
if (payload.event === MothershipStreamV1SpanLifecycleEvent.end) {
82-
if (isPendingPause) {
83-
return
84-
}
8570
if (
8671
deps.previewSessionRef.current &&
8772
(!deps.activePreviewSessionIdRef.current ||

‎apps/sim/app/workspace/[workspaceId]/home/hooks/stream/stream-helpers.ts‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ export const WORKFLOW_MUTATION_TOOL_NAMES: Set<string> = new Set([
5959
'rename_workflow',
6060
])
6161

62-
export type StreamPayload = Record<string, unknown>
63-
64-
export function asPayloadRecord(value: unknown): StreamPayload | undefined {
65-
return isRecordLike(value) ? value : undefined
66-
}
67-
6862
/**
6963
* Settles every unfinished tool row (running, pending, or awaiting approval) at
7064
* a turn terminal by propagating the turn's outcome: a clean `complete` settles

‎apps/sim/app/workspace/[workspaceId]/home/hooks/stream/turn-model-serialize.test.ts‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,7 @@ describe('modelToContentBlocks', () => {
183183
expect(mainText[0].content).toBe('Spawning research.')
184184

185185
// The real subagent_start lands afterward and no-ops: still one research lane.
186-
reduceEvent(
187-
m,
188-
env(
189-
4,
190-
'span',
191-
{ kind: 'subagent', event: 'start', agent: 'research', data: { tool_call_id: 'tc-r1' } },
192-
sub
193-
)
194-
)
186+
reduceEvent(m, env(4, 'span', { kind: 'subagent', event: 'start', agent: 'research' }, sub))
195187
const after = modelToContentBlocks(m)
196188
expect(after.filter((b) => b.type === 'subagent')).toHaveLength(1)
197189
expect(after.find((b) => b.type === 'subagent')?.content).toBe('research')
@@ -208,12 +200,7 @@ describe('modelToContentBlocks', () => {
208200
build([
209201
env(1, 'text', { channel: 'assistant', text: 'before' }),
210202
env(2, 'tool', { phase: 'call', toolCallId: 'tc-file', toolName: 'file' }),
211-
env(
212-
3,
213-
'span',
214-
{ kind: 'subagent', event: 'start', agent: 'file', data: { tool_call_id: 'tc-file' } },
215-
sub
216-
),
203+
env(3, 'span', { kind: 'subagent', event: 'start', agent: 'file' }, sub),
217204
env(
218205
4,
219206
'tool',
@@ -247,12 +234,7 @@ describe('modelToContentBlocks', () => {
247234
}
248235
const m = build([
249236
env(1, 'tool', { phase: 'call', toolCallId: 'tc-file', toolName: 'file' }),
250-
env(
251-
2,
252-
'span',
253-
{ kind: 'subagent', event: 'start', agent: 'file', data: { tool_call_id: 'tc-file' } },
254-
sub
255-
),
237+
env(2, 'span', { kind: 'subagent', event: 'start', agent: 'file' }, sub),
256238
env(
257239
3,
258240
'tool',

‎apps/sim/app/workspace/[workspaceId]/home/hooks/stream/turn-model-serialize.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,7 @@ export function contentBlocksToModel(blocks: ContentBlock[]): TurnModel {
349349
kind: 'subagent',
350350
event: 'start',
351351
agent: block.content,
352-
data: {
353-
...(block.parentToolCallId ? { tool_call_id: block.parentToolCallId } : {}),
354-
...(block.subagentName ? { name: block.subagentName } : {}),
355-
},
352+
data: block.subagentName ? { name: block.subagentName } : {},
356353
},
357354
scopeFor(block),
358355
block.timestamp

0 commit comments

Comments
 (0)