Files
PaperClipAI/tests
DottaandClaude Opus 5.5 874fed09a4 test(restart-chaos): enable isolated workspaces for repo tasks (#19536)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The restart chaos harness (`tests/restart-chaos`) restarts the
control plane while agents work, then grades the result
> - Rule R2 says files an agent wrote before a restart must still be
present afterwards
> - Repo workloads failed R2 with `pre_fault_files_lost`. The first run
worked in the shared project checkout, not in its own worktree
> - The seed sets a `git_worktree` project policy, but the server
applies that policy only when the instance `enableIsolatedWorkspaces`
setting is on. The seed did not turn it on
> - This pull request makes the seed turn on the setting (as users do on
the Experimental page, and as `tests/runner-e2e` does) and fail if the
server does not confirm it
> - The benefit is that repo tasks get their own worktree, so one task's
files cannot appear in another task's R2 snapshot

## Linked Issues or Issue Description

Refs #19477

**What happened?**
In a restart chaos wave, two repo tasks (B1 and B5) ran at the same
time. Both ran in the project primary checkout (`strategyType:
project_primary`). Task B1's `NOTES-*.md` file and its `cli.py` edit
appeared in the B5 task's workspace before any fault. After a Retry, the
B5 task moved to a fresh attempt directory, and R2 reported the B1 file
as lost from B5.

**Expected behavior**
Each repo task gets its own git worktree, as the harness project policy
asks. The R2 snapshot of a task contains only that task's files.

**Steps to reproduce**
1. Run `tests/restart-chaos/main.ts --env local --adapters codex
--workloads B1,B5 --concurrency 2`.
2. Read `currentExecutionWorkspace` for each task. It shows
`project_primary` and the fixture checkout as `cwd`.
3. Read `GET /api/instance/settings/experimental`.
`enableIsolatedWorkspaces` is `false`.

**Root cause**
`server/src/services/heartbeat.ts` reads `enableIsolatedWorkspaces` and
`gateProjectExecutionWorkspacePolicy`
(`server/src/services/execution-workspace-policy.ts`) returns `null`
when the setting is off. The project policy is then ignored, and the
task resolves to the shared primary checkout.
`tests/restart-chaos/seed.ts` created the project policy but did not
turn on the setting.

## What Changed

- `tests/restart-chaos/seed.ts`: before it creates the project, the seed
sends `PATCH /api/instance/settings/experimental` with
`enableIsolatedWorkspaces: true`. If the response does not confirm the
setting, the seed stops with an error. It records a
`seed_isolated_workspaces` timeline entry.
- `tests/restart-chaos/seed.test.ts`: new unit tests. One test checks
that the seed turns on the setting before it creates the `git_worktree`
project. One test checks that the seed refuses to continue when the
server does not confirm the setting.
- `tests/restart-chaos/README.md`: the `seed.ts` row says that the seed
turns on the setting, and why.

## Verification

- Red before the fix: `pnpm exec vitest run --config
tests/restart-chaos/vitest.config.ts seed.test.ts` failed 2/2 (`expected
-1 to be greater than or equal to 0`).
- Green after the fix: the full restart-chaos unit suite passes, 5 files
and 42 tests.
- Live wave on this branch (`16f5c8c5d7`, local runner, native Codex,
macOS, load average about 40): `tests/restart-chaos/main.ts --env local
--adapters codex --workloads B1 --tasks 3 --concurrency 1 --faults K1
--seed 21` (wave `w-20261106T181436-s21`). The timeline shows
`seed_isolated_workspaces`. Result: 3/3 pass. Each task crossed a
SIGKILL restart. R1, R2, R4, R5, R6 and the workload oracle passed for
each task, with no lost files.
- Each task's pre-fault file list now has a `.git` file (a git worktree,
not the primary checkout) and only its own `NOTES-*.md` file. In the
failing wave, the B5 task's list had the B1 task's `NOTES-*.md` file.
- Not exercised: no task needed a Retry in this wave, so the
Retry-to-fresh-attempt path did not run.
- Ledger preflight: install and runner builds passed. The provider-free
restart suite had 2 failures in
`runnerd-codex-transport-warm-attachment.test.ts` at load average 44; a
rerun of that file passed 18/18.

## Risks

- Low risk. The change is in the test harness only. It changes no
product code.
- The harness instance is temporary, so the experimental setting does
not reach a real instance.
- Repo tasks now run in git worktrees. Earlier waves ran in the shared
checkout, so R2 results for repo workloads from earlier waves are not
comparable with new waves.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, via Claude Code with
tool use (shell, file edits). Standard context window; reasoning
enabled.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 12:33:13 -06:00
..