paperclip/packages/adapter-utils/src
Devin Foley 721541c41d
Fix sandbox restore index drift (#8595)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Sandboxed agents can do useful work in a remote workspace, then
export that result back to a host review checkout.
> - A restore can leave the host checkout's index stale even when the
sandbox content and committed state are correct.
> - That drift makes reviewers see misleading missing-file or
dirty-state results after sandbox execution.
> - This pull request repairs the host index refresh path and surfaces a
clean/dirty restore signal during finalization.
> - The benefit is more reliable review checkouts and clearer sandbox
finalization status.

## Linked Issues or Issue Description

Refs #248

No exact public GitHub issue was found for this restore/index
consistency fix. The underlying bug is that a sandbox restore can update
host working-tree content without leaving the host git index aligned, so
local review tooling may report stale deletions or misleading dirtiness.
This PR keeps the restore/export path consistent and reports the
resulting clean/dirty state.

GitHub search performed for related or duplicate work: `sandbox runtime
status`, `sandbox restore index`, and `runtime progress`. No direct
duplicate PR was found.

## What Changed

- Refreshed git workspace sync/index handling after sandbox
restore/export operations.
- Added finalization status that reports whether the restored host
checkout is clean or dirty.
- Preserved sandbox-managed runtime progress callbacks around restore
and finalization.
- Added adapter-utils tests covering the host index drift repair and
clean/dirty finalization signal.

## Verification

- Local PII scan before push: high-confidence secret patterns, internal
issue links, local user paths, and private URL patterns checked across
all three split diffs; no real secrets or internal links found.
- `git diff --check
feat/sandbox-runtime-status..fix/sandbox-restore-index-sync`
- `pnpm exec vitest run
packages/adapter-utils/src/sandbox-managed-runtime.test.ts` — 1 file, 10
tests passed.
- `pnpm run typecheck` passed on `fix/sandbox-restore-index-sync`.
- `pnpm run build` passed on `fix/sandbox-restore-index-sync`; Vite
reported existing CSS `::highlight` and chunk-size warnings.
- `pnpm run test:run` was attempted on `fix/sandbox-restore-index-sync`;
it failed in two unrelated broad-suite tests. One depends on this host's
Git default branch behavior, and one depends on local Claude
model-discovery environment. The changed focused suite above passes.

## Risks

- Git index refresh behavior needs to remain conservative so it does not
hide real uncommitted user changes.
- The clean/dirty finalization signal is diagnostic; it should not by
itself mark a sandbox run successful or failed.
- This PR is stacked on the runtime-status branch so finalization
progress can reuse the same callback path.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

OpenAI GPT-5 via Codex coding agent, with shell/tool execution in a
local worktree. Exact context-window metadata is not exposed by the
runtime.

## 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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-06-24 23:21:13 -07:00
..
billing.test.ts
…
billing.ts
…
command-managed-runtime.test.ts Fix sandbox git publishing and large workspace uploads (#8422) 2026-06-20 22:03:55 -07:00
command-managed-runtime.ts Add ephemeral sandbox runtime status plumbing (#8593) 2026-06-24 23:17:39 -07:00
command-redaction.ts [codex] Roll up May 17 branch changes (#6210) 2026-05-17 17:15:06 -05:00
exclude-patterns.ts Fix sandbox git publishing and large workspace uploads (#8422) 2026-06-20 22:03:55 -07:00
execution-target-sandbox.test.ts Harden remote sandbox runtime probes, timeouts, and installs (#5685) 2026-05-11 00:31:54 -07:00
execution-target.test.ts Add secrets provider vaults and remote import (#5429) 2026-05-09 18:22:17 -05:00
execution-target.ts Add ephemeral sandbox runtime status plumbing (#8593) 2026-06-24 23:17:39 -07:00
git-workspace-sync.test.ts Fix sandbox git publishing and large workspace uploads (#8422) 2026-06-20 22:03:55 -07:00
git-workspace-sync.ts Fix sandbox restore index drift (#8595) 2026-06-24 23:21:13 -07:00
index.ts Add ephemeral sandbox runtime status plumbing (#8593) 2026-06-24 23:17:39 -07:00
log-redaction.ts
…
remote-execution-env.ts Sanitize remote execution envs at the boundary (#5325) 2026-05-05 19:30:14 -07:00
remote-managed-runtime.ts Fix sandbox git publishing and large workspace uploads (#8422) 2026-06-20 22:03:55 -07:00
runtime-progress.test.ts feat(adapter-utils): add observable sandbox sync progress (#8395) 2026-06-20 13:03:42 -07:00
runtime-progress.ts Add ephemeral sandbox runtime status plumbing (#8593) 2026-06-24 23:17:39 -07:00
sandbox-callback-bridge.test.ts Add Cloudflare sandbox provider plugin (#5687) 2026-05-11 07:33:13 -07:00
sandbox-callback-bridge.ts Add Cloudflare sandbox provider plugin (#5687) 2026-05-11 07:33:13 -07:00
sandbox-install-command.test.ts Fix exe.dev sandbox installs for gemini/opencode local adapters (#5737) 2026-05-11 14:28:22 -07:00
sandbox-install-command.ts Fix exe.dev sandbox installs for gemini/opencode local adapters (#5737) 2026-05-11 14:28:22 -07:00
sandbox-managed-runtime.test.ts Fix sandbox restore index drift (#8595) 2026-06-24 23:21:13 -07:00
sandbox-managed-runtime.ts Fix sandbox restore index drift (#8595) 2026-06-24 23:21:13 -07:00
sandbox-shell.ts Add secrets provider vaults and remote import (#5429) 2026-05-09 18:22:17 -05:00
server-utils.test.ts feat(skills): remove bundled paperclip-dev skill and retire required skill attribute (#7029) 2026-06-20 21:58:44 -07:00
server-utils.ts feat(skills): remove bundled paperclip-dev skill and retire required skill attribute (#7029) 2026-06-20 21:58:44 -07:00
session-compaction.ts Add cursor_cloud adapter for Cursor SDK + Cloud Agents API v1 (#5664) 2026-05-10 17:21:04 -07:00
ssh-fixture.test.ts feat(adapter-utils): add observable sandbox sync progress (#8395) 2026-06-20 13:03:42 -07:00
ssh.ts feat(adapter-utils): add observable sandbox sync progress (#8395) 2026-06-20 13:03:42 -07:00
types.ts Add ephemeral sandbox runtime status plumbing (#8593) 2026-06-24 23:17:39 -07:00
workspace-restore-merge.test.ts fix(remote-sandbox): harden host workspace resumes (#5922) 2026-05-13 16:23:04 -05:00
workspace-restore-merge.ts Fix sandbox restore index drift (#8595) 2026-06-24 23:21:13 -07:00