Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Revert the PM wake footing line (#3141) (#3147)

0xken15948cc394e10c
diff --git a/backend/integration/superTabPmSchedule.test.ts b/backend/integration/superTabPmSchedule.test.ts
index 936725161..7e6db9ae9 100644
--- a/backend/integration/superTabPmSchedule.test.ts
+++ b/backend/integration/superTabPmSchedule.test.ts
@@ -80,10 +80,8 @@ async function swarm({ fresh = false, told }: { fresh?: boolean; told?: string[]
// Its own first: a machine's report also judges the others', and one not heard from in 2 minutes loses its work.
for (const machineId of ['test-host', 'lead-host']) await timed.observeMachine(host, tab, machineId, { generation: generations.get(machineId)!,
resources: { cpuPercent: 10, memoryTotalBytes: 32e9, memoryUsedBytes: 4e9, diskFreeBytes: 120e9, diskTotalBytes: 500e9, projectDiskFreeBytes: 120e9, deviceType: 'Laptop', chip: 'Fixture', os: 'macOS', gpuPercent: null },
- quotas: machineId === 'lead-host' ? readings.lead : [], tools: {}, runningHarnessIds: [harnessOf.get(machineId)!], stoppedHarnessIds: [] })
+ quotas: [], tools: {}, runningHarnessIds: [harnessOf.get(machineId)!], stoppedHarnessIds: [] })
}
- /** What the coordinator's machine reports of its week: nothing, until a test sets it. */
- const readings = { lead: [] as unknown[] }
const poll = async () => {
// Its worker keeps saying where it is, as a live one does; a finished task refuses the line and nothing changes.
await execute({ type: 'work.status', conversationId: group, assignmentId, status: 'working', result: randomUUID() }, host, worker).catch(() => {})
@@ -112,7 +110,7 @@ async function swarm({ fresh = false, told }: { fresh?: boolean; told?: string[]
})
return id
}
- return { timed, tab, execute, lead, group, worker, assignmentId, clock, poll, status, write, add, readings }
+ return { timed, tab, execute, lead, group, worker, assignmentId, clock, poll, status, write, add }
}
const rowsOf = (tabId: string, where: Record<string, unknown> = {}) => db.superTabDelivery.findMany({ where: { tabId, ...where }, orderBy: { createdAt: 'asc' } })
@@ -145,26 +143,6 @@ describe('the built-in schedule on the coordinator\'s poll', () => {
expect((await projectOf(f)).schedule).toMatchObject({ lastSlot: scheduleSlot(f.clock.now) })
})
- it('ends the wake with where the coordinator runs and its week left when its machine reports it, and says nothing when it does not (Ken, 11-05)', async () => {
- const reported = { engine: 'codex', known: true, windows: [{ name: 'weekly', usedPercent: 30, resetsAt: Date.parse('2026-11-04T06:30:00.000Z') + 4 * 86_400_000 }] }
- const f = await swarm()
- f.readings.lead = [reported]
- wantSchedule()
- await unassigned(f)
- await f.poll()
- const [known] = await schedules(f.tab)
- expect(known!.text).toMatch(/\n\nYou run on Lead Mac, host's own account: weekly 70% left, resets in \d+[dhm]\.$/)
- expect(known!.text).not.toContain('@')
- // The same wake with no reading: the line is left out, not guessed.
- const g = await swarm()
- wantSchedule()
- await unassigned(g)
- await g.poll()
- const [unknown] = await schedules(g.tab)
- expect(unknown).toBeDefined()
- expect(unknown!.text).not.toContain('You run on')
- })
-
it('is the coordinator\'s alone: no person sees it in the chat, and no other agent reads it', async () => {
const f = await swarm()
wantSchedule()
diff --git a/backend/src/superTabs/othersWork.ts b/backend/src/superTabs/othersWork.ts
index e7820beba..06f54c81d 100644
--- a/backend/src/superTabs/othersWork.ts
+++ b/backend/src/superTabs/othersWork.ts
@@ -12,7 +12,7 @@ import { canReadProject, groupProject, ledProject } from './projects.js'
import { usernameOf } from './usernames.js'
/** "3d", "5h", "20m": how long until [ms] from [now], as the Machines screen says a reset. */
-export function until(ms: number, now: number): string {
+function until(ms: number, now: number): string {
const left = Math.max(0, ms - now)
if (left >= 86_400_000) return `${Math.floor(left / 86_400_000)}d`
if (left >= 3_600_000) return `${Math.floor(left / 3_600_000)}h`
diff --git a/backend/src/superTabs/pmFooting.test.ts b/backend/src/superTabs/pmFooting.test.ts
deleted file mode 100644
index 68fab2af7..000000000
--- a/backend/src/superTabs/pmFooting.test.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-import { describe, expect, it } from 'vitest'
-import type { Agent, MessageDraft, SuperTabState } from './model.js'
-import { addFooting, pmFooting } from './pmFooting.js'
-
-const NOW = Date.UTC(2026, 10, 5, 3, 0)
-const DAY = 86_400_000
-
-const agent = (id: string, machineId: string, engine = 'claude'): Agent => ({ id, name: id, contributorId: 'ken', membershipGeneration: 'g', machineId, harnessId: `h-${id}`,
- machineOwnerId: 'ken', configuration: { engine, model: 'opus', effort: 'high', contextWindow: null, engineVersion: null } } as unknown as Agent)
-
-/** A Mac "Mac Studio" owned by ken, with a Harness Team account pool on it, and one reading of Claude's week on the Mac. */
-function swarm(quotas: unknown, pmMachine = 'mac'): SuperTabState {
- const base = { contributorId: 'ken', membershipGeneration: 'g', generation: 'g', cwd: '/x', engines: ['claude'], maxAgents: 4, paused: false }
- return {
- version: 1, id: 'tab', name: 'Swarm', ownerId: 'ken', environment: 'prod', paused: false, invitations: [],
- people: [{ id: 'ken', email: '[email protected]', username: 'ken', role: 'owner', generation: 'g' }],
- agents: [agent('pm', pmMachine)], conversations: [],
- projects: [{ id: 'p1', name: 'openharness', ownerId: 'ken', leadConversationId: 'lead-p1', visibility: 'public', members: [], updateMinutes: 5 }],
- machines: [{ ...base, machineId: 'mac', name: 'Mac Studio', observation: { receivedAt: NOW, quotas } },
- { ...base, machineId: 'team', name: 'Mac Studio', hostMachineId: 'mac' }],
- } as unknown as SuperTabState
-}
-const known = [{ engine: 'claude', known: true, windows: [{ name: '5-hour', usedPercent: 10, resetsAt: null }, { name: 'weekly', usedPercent: 38, resetsAt: NOW + 3 * DAY + 3_600_000 }] }]
-const pm = (state: SuperTabState) => state.agents[0]!
-
-describe('the PM\'s footing line in every built-in wake', () => {
- it('says the machine, the account and the weekly quota left with its reset, when the reading is known', () => {
- expect(pmFooting(swarm(known), pm(swarm(known)), NOW)).toBe('You run on Mac Studio, ken\'s own account: weekly 62% left, resets in 3d.')
- })
- it('names a Harness Team account as that, with its Mac\'s name and the Mac\'s reading', () => {
- const state = swarm(known, 'team')
- expect(pmFooting(state, pm(state), NOW)).toBe('You run on Mac Studio, the Harness Team account: weekly 62% left, resets in 3d.')
- })
- it('leaves the reset out when only it is unknown, and says nothing at all when the week is unknown', () => {
- const noReset = [{ engine: 'claude', known: true, windows: [{ name: 'weekly', usedPercent: 38, resetsAt: null }] }]
- expect(pmFooting(swarm(noReset), pm(swarm(noReset)), NOW)).toBe('You run on Mac Studio, ken\'s own account: weekly 62% left.')
- for (const quotas of [undefined, [], [{ engine: 'claude', known: false, windows: [] }], [{ engine: 'codex', known: true, windows: [{ name: 'weekly', usedPercent: 1, resetsAt: null }] }],
- [{ engine: 'claude', known: true, windows: [{ name: '5-hour', usedPercent: 1, resetsAt: null }] }]]) {
- const state = swarm(quotas)
- expect(pmFooting(state, pm(state), NOW), JSON.stringify(quotas)).toBeNull()
- }
- })
- it('names the other account a PM runs on by its label, with that account\'s own reading, and says nothing when that reading is missing', () => {
- const profile = (leftPercent: number | null) => ({ engine: 'claude', id: 'a'.repeat(16), label: 'Work Max', leftPercent, resetsAt: new Date(NOW + 2 * DAY + 3_600_000).toISOString() })
- const withProfile = (profiles: unknown[] | undefined, profileId: string | null = 'a'.repeat(16)) => {
- const state = swarm(known)
- ;(state.machines![0] as { observation: { profiles?: unknown[] } }).observation.profiles = profiles
- state.agents[0]!.profileId = profileId ?? undefined
- return state
- }
- let state = withProfile([profile(71)])
- expect(pmFooting(state, pm(state), NOW)).toBe('You run on Mac Studio, Work Max: weekly 71% left, resets in 2d.')
- // Its own account's reading, never the machine's default one.
- for (const missing of [withProfile([profile(null)]), withProfile(undefined), withProfile([{ ...profile(50), id: 'b'.repeat(16) }])]) expect(pmFooting(missing, pm(missing), NOW)).toBeNull()
- state = withProfile([profile(71)], null)
- expect(pmFooting(state, pm(state), NOW)).toBe('You run on Mac Studio, ken\'s own account: weekly 62% left, resets in 3d.')
- })
- it('says nothing for a machine the Swarm does not list, and never names an email', () => {
- const state = swarm(known, 'gone')
- expect(pmFooting(state, pm(state), NOW)).toBeNull()
- const noName = swarm(known)
- noName.people[0]!.username = undefined
- expect(pmFooting(noName, pm(noName), NOW) ?? '').not.toMatch(/@|example\.com/)
- })
- it('adds it once to each built-in wake the PM gets, and to no other message', () => {
- const state = swarm(known)
- const draft = (kind: string, over: Partial<MessageDraft> = {}) => ({ id: kind, conversationId: 'lead-p1', text: `A ${kind}.`, recipients: ['pm'], source: { kind }, ...over }) as unknown as MessageDraft
- const wakes = ['schedule-request', 'update-request', 'digest-request', 'notice-digest', 'work-lost', 'work-stalled', 'idle'].map(k => draft(k))
- const others = [draft('review-failed'), draft('idle', { id: 'to-other', recipients: ['eng'] })]
- const line = 'You run on Mac Studio, ken\'s own account: weekly 62% left, resets in 3d.'
- addFooting(state, pm(state), [...wakes, ...others], NOW)
- for (const w of wakes) expect(w.text, w.id).toBe(`A ${w.id}.\n\n${line}`)
- expect(others.map(o => o.text)).toEqual(['A review-failed.', 'A idle.'])
- addFooting(state, pm(state), wakes, NOW)
- for (const w of wakes) expect(w.text.split('You run on ').length, w.id).toBe(2)
- })
- it('leaves every wake as it is when the reading is unknown', () => {
- const state = swarm(undefined)
- const wake = { id: 'w', conversationId: 'lead-p1', text: 'Built-in schedule.', recipients: ['pm'], source: { kind: 'schedule-request' } } as unknown as MessageDraft
- addFooting(state, pm(state), [wake], NOW)
- expect(wake.text).toBe('Built-in schedule.')
- })
-})
diff --git a/backend/src/superTabs/pmFooting.ts b/backend/src/superTabs/pmFooting.ts
deleted file mode 100644
index c436dc29c..000000000
--- a/backend/src/superTabs/pmFooting.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * The coordinator's own footing (Ken, 2026-11-05, follow-up to #3134): every built-in wake ends with where its PM runs and
- * how much of its week is left, so it spends its own quota knowing it. Names only, from the machine's last reading; a reading
- * the Swarm does not have leaves the line out rather than guessing it.
- */
-import { weeklyUse } from './leaderboard/brought.js'
-import type { Agent, MessageDraft, SuperTabState } from './model.js'
-import { until } from './othersWork.js'
-import { usernameOf } from './usernames.js'
-
-/** The messages the Swarm's built-in schedule wakes the coordinator with: the schedule, the update request, the morning
- * digest, the notice digest, and the lost, stalled and idle notices. */
-const WAKE_KINDS = new Set(['schedule-request', 'update-request', 'digest-request', 'notice-digest', 'work-lost', 'work-stalled', 'idle'])
-const MARK = 'You run on '
-
-/** "You run on <machine>, <account>: weekly X% left, resets in <time>." for [pm]'s machine and account, null when the
- * machine, the account's name or its weekly reading is unknown. A PM on another account (profileId) is named by that
- * account's label, with that account's own reading, never the machine's default one. A Harness Team account is named as
- * that, with its Mac's name and the Mac's reading; the default account is its owner's username's, never an email. */
-export function pmFooting(state: SuperTabState, pm: Agent, now: number): string | null {
- const pool = state.machines?.find(m => m.machineId === pm.machineId)
- if (!pool) return null
- const home = (pool.hostMachineId && state.machines?.find(m => m.machineId === pool.hostMachineId)) || pool
- const engine = pm.configuration.engine
- let account: string | undefined, usedPercent: number | null, resetsAt: number | null
- if (pm.profileId) {
- const profile = (pool.observation?.profiles ?? []).find(p => p.engine === engine && p.id === pm.profileId)
- if (!profile || profile.leftPercent == null) return null
- account = profile.label
- usedPercent = 100 - profile.leftPercent
- resetsAt = profile.resetsAt ? Date.parse(profile.resetsAt) : null
- if (resetsAt != null && Number.isNaN(resetsAt)) resetsAt = null
- } else {
- const owner = usernameOf(state, pool.contributorId)
- account = pool.hostMachineId ? 'the Harness Team account' : owner && `${owner}'s own account`
- ;({ usedPercent, resetsAt } = weeklyUse(home, engine))
- }
- if (!account || usedPercent == null || !Number.isFinite(usedPercent)) return null
- const left = Math.min(100, Math.max(0, Math.round(100 - usedPercent)))
- return `${MARK}${home.name}, ${account}: weekly ${left}% left${resetsAt == null ? '' : `, resets in ${until(resetsAt, now)}`}.`
-}
-
-/** Ends each built-in wake in [drafts] that goes to [pm] with its footing line, once; the other messages and a wake that
- * already has it stay as they are. */
-export function addFooting(state: SuperTabState, pm: Agent, drafts: readonly MessageDraft[], now: number): void {
- const wakes = drafts.filter(d => WAKE_KINDS.has(String(d.source?.kind)) && d.recipients?.includes(pm.id) && !d.text.includes(MARK))
- const line = wakes.length ? pmFooting(state, pm, now) : null
- if (line) for (const draft of wakes) draft.text = `${draft.text}\n\n${line}`
-}
diff --git a/backend/src/superTabs/store.ts b/backend/src/superTabs/store.ts
index 297d63385..1614278dc 100644
--- a/backend/src/superTabs/store.ts
+++ b/backend/src/superTabs/store.ts
@@ -89,7 +89,6 @@ import { QUIET_CLAIM, type HoldReason } from './holdReason.js'
import { stuck } from './deliverySettle.js'
import { digestIsDue, digestMessage, digestText, doneRow, endedAlert, GATHERED_LIMIT_MS, gatheredNotice, NOTICE_DIGEST_MAX, noticeLine } from './noticeDigest.js'
import { PM_SCHEDULE_TEXT, recordWake, scheduleRequest } from './pmSchedule.js'
-import { addFooting } from './pmFooting.js'
import { agentDisplayName } from './agentNames.js'
import { endedHolds, HOLDING, startedHolds, type WorkHold } from '../github/holds.js'
import { accrueLent, addLent, lentAgents, lentProjects } from './leaderboard/lent.js'
@@ -3970,8 +3969,6 @@ export class SuperTabStore {
await this.releaseRuns(tx, tabId, await this.staleRuns(tx, tabId, state))
}
// One write for all: the time checks' changes, the digest and the wake-ups'.
- // Every built-in wake ends with where its PM runs and its week's quota (pmFooting.ts), once the wakes are merged.
- addFooting(state, target, written, this.now())
const sequences = numberMessages(state, written, this.now())
// A loss or a start's failure was judged from a machine's report: a newer report makes this write retry.
await this.save(tx, loaded, state, clock.next(), [...judgedMachines(loaded.state, state, written),