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.

Batch: outside PRs #2362 (flaky hash assertion) + #2363 (report unproven Swarm worktrees) (#2369)

0xken1570404d85fd9f
diff --git a/cli/src/lib/pullRequestsStatus.spec.ts b/cli/src/lib/pullRequestsStatus.spec.ts
index ff23e06a5..3482bc765 100644
--- a/cli/src/lib/pullRequestsStatus.spec.ts
+++ b/cli/src/lib/pullRequestsStatus.spec.ts
@@ -171,7 +171,6 @@ describe('linked pull requests read directly from GitHub', () => {
account = null
const none = await read([url()])
expect([none.account, none.account === grace.account]).toEqual([expect.stringMatching(/^[0-9a-f]{16}$/), false])
- expect(none.account).not.toContain('ada')
})
it('reads the account as a hash of the token gh holds, and none without one', async () => {
const tokens = vi.fn<Run>(async () => ({ stdout: 'gho_secret\n' }))
diff --git a/cli/src/superTabs/machines.spec.ts b/cli/src/superTabs/machines.spec.ts
index abe1e5335..8f8b002d6 100644
--- a/cli/src/superTabs/machines.spec.ts
+++ b/cli/src/superTabs/machines.spec.ts
@@ -1743,6 +1743,19 @@ describe('removed machine cleanup', () => {
expect(readFileSync(join(m.ownWorktree, 'unpushed.txt'), 'utf8')).toBe('work')
})
+ // #2284: a folder whose .git proof disappeared is kept with its record and logged without its path.
+ it('keeps and logs a recorded worktree whose .git proof file is missing without exposing its path', async () => {
+ const m = machine()
+ m.setLive([])
+ rmSync(join(m.recorded, 'unpushed.txt'))
+ rmSync(join(m.recorded, '.git'))
+ await m.open().removeStoppedWorktree('tab', 'h-recorded')
+ expect(existsSync(m.recorded)).toBe(true)
+ expect(startIds(m)).toEqual(['recorded', 'kept'])
+ expect(m.log.mock.calls).toEqual([['Kept a Swarm worktree: WORKTREE_UNPROVEN']])
+ expect(m.log.mock.calls.flat().join('\n')).not.toContain(m.recorded)
+ })
+
it('keeps the record when its folder cannot be read for any reason but being gone', async () => {
const m = machine()
m.setLive([])
diff --git a/cli/src/superTabs/machines.ts b/cli/src/superTabs/machines.ts
index 6f7c29e20..e4e1086c0 100644
--- a/cli/src/superTabs/machines.ts
+++ b/cli/src/superTabs/machines.ts
@@ -780,7 +780,12 @@ export class ContributedMachines {
// Diego, 10-30: a folder deleted by hand kept its record for good, and every later stop tried it again. Only a folder
// that is not there drops it; one that cannot be read for any other reason keeps it. Nothing on disk is touched.
if (await folderGone(record.path)) return writeWorktrees(file, readWorktrees(file).filter(w => !mine(w)))
- if (!await swarmWorktree(record.path, record.source, record.startId)) return
+ if (!await swarmWorktree(record.path, record.source, record.startId)) {
+ // The record no longer proves this belongs to Harness. Keep it; never loosen the proof to recover it.
+ if (await folderGone(record.path)) return writeWorktrees(file, readWorktrees(file).filter(w => !mine(w)))
+ this.log('Kept a Swarm worktree: WORKTREE_UNPROVEN')
+ return
+ }
if (this.core.agents.live().some(a => !!a.cwd && within(record.path, a.cwd))) return
// Review of #2266: like the weekly sweep (services/workspaces.ts), a paused session of another agent can be resumed
// there, so its folder stays. This agent's own paused session is not kept: it was stopped or removed.