# Storage cleanup reproduction

AI-assisted; verified with the tests and tools listed above.

These captures run the real, independently bundled T3 Code server on Linux x86_64.
No tests, mocked services, provider turns, browser, or live user data are used.
Each commit runs from its own checkout with a fresh, isolated database.
Both terminal recordings are 1440 x 900, with the same white terminal theme and font.
The two synthetic fixtures have identical commit objects and an annotated
`v0.9.1-ea2` tag whose peeled commit is outside every remote branch.
The Git remote is a reachable local bare repository, rather than an external host.

## Build and launch each side

In each checkout, install with `vp i`, then build with
`vp run --filter t3 build:bundle`. Generate one temporary random credential
(at least 32 characters), store it in a private file, and use it for both servers.
Never upload that file or raw server startup logs (which contain pairing tokens).

Compile the supplied clock shim:

```sh
cc -shared -fPIC clock.c -o clock.so -ldl
```

Choose a new timestamped run directory for each side and a new data directory.
Write `0` to its clock-offset file. Launch the bundled server from that side's
checkout, with the following environment and arguments (replace placeholders):

```sh
T3CODE_DEV_SEED=0 \
T3CODE_DEV_AUTH_TOKEN="$(cat CREDENTIAL_FILE)" \
LD_PRELOAD=ABSOLUTE_CLOCK_SO_PATH \
EVIDENCE_CLOCK_FILE=ABSOLUTE_CLOCK_OFFSET_PATH \
node apps/server/dist/bin.mjs --no-browser --port PORT \
  --dev-url http://localhost:UNUSED_WEB_PORT --base-dir NEW_DATA_DIRECTORY
```

Only CLOCK_REALTIME/gettimeofday/time in this server process are offset.
Monotonic time and the machine clock remain unchanged. The driver advances
that process by 48 hours to make the one-day inactivity rule eligible without
waiting two days. This is a time-controlled live-server reproduction.

## Seed and drive

```sh
python3 seed.py NEW_TIMESTAMPED_RUN_DIRECTORY
node driver.mjs seed PORT RUN_DIRECTORY CREDENTIAL_FILE CLOCK_FILE
node driver.mjs cleanup PORT RUN_DIRECTORY CREDENTIAL_FILE CLOCK_FILE
```

The seed phase adds the project via HTTP and creates the idle thread via
orchestration RPC. It never writes database rows. The cleanup phase verifies
clean status, matching published tags, and absence from remote branches;
enables a one-day inactive-worktree policy; advances the server clock; then
calls `server.runStorageCleanup`, the same RPC Maintenance > Delete now uses.
The response and a filesystem existence check are printed and saved.

`capture.py` and `terminal.sh` are the exact recording helpers, using
headless-desktop, GNOME Terminal, and ffmpeg. Their final run directory names
are recorded in terminal.sh; substitute your new timestamped directory names
for a repeat. The recording starts before the terminal launches and retains
its final result for eight seconds. No UI screenshot claims are made.

Observed base: kept, reason "Submodule has commits not on a remote-tracking ref",
worktree still exists. Observed head: removed, reason "Inactive for 2 days",
worktree no longer exists.
