# Submodule object reuse proof

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

Run the accompanying single-test scenario from a current main checkout after `vp i`.
The scenario generates synthetic Git history and drives the real web app with Replay (dev).

The e2e app-command environment allowlist must include `GIT_ALLOW_PROTOCOL`,
`GIT_TRACE_PACKFILE`, and `T3CODE_DEV_SEED` (add them to `app.command.inheritEnv`
for the web target in `scripts/e2e.config.ts`). The runner otherwise drops these
variables when starting the app server.

Set `SUBMODULE_PROOF_DIR` to a new disposable directory and `GIT_TRACE_PACKFILE`
to an absolute file path within that directory. Set `GIT_ALLOW_PROTOCOL=file` and
`T3CODE_DEV_SEED=0` for the proof command. Run:

```
vp run scenarios:prove scripts/scenarios/submodule-object-reuse.e2e.ts \
  --base b3fdf2b10fb92e5dbc71a83381c602a8a464bbca \
  --head ec77adfe1fae5e2cea30abdc446d25afe89bcc9a \
  --upload-command "ghdrop upload"
```

The scenario creates a project through `t3.project`, builds 24 commits of
512 KiB synthetic binary history, adds and initializes it as a committed top-level
submodule from a file:// bare remote, and adds a file:// origin for the project.
`t3.json` enables top-level submodule initialization and New worktree mode.
Start from remote is enabled by the app's default; the capture shows From main (remote).
It submits the first message through the web composer, waits for the replay turn,
then inspects the resulting actual worktree and Git pack-transfer trace.

`GIT_TRACE_PACKFILE` records incoming raw Git pack bytes. Fixture construction
runs with this tracing disabled; the trace is cleared before the UI operation.
It measures actual transferred bytes rather than predicting reuse from flags.

The scenario moves the source's `.git/modules/history` repository aside, runs
`git fsck --full` in the destination submodule, reads its current binary file and
its oldest committed README, and then restores the cache. It checks that HEAD
matches the recorded gitlink and there is no remaining alternates dependency.
The JSON observations contain these command results and measured transfer bytes.

The assertion permits less than 1 MiB of transfer to allow minor project metadata;
the observed head transfer is reported separately. No duration claim is made.
