Skip to content

test(backups): drive backup and a cancellable long operation against a published daemon - #76

Merged
AresConnor merged 4 commits into
masterfrom
feat/published-host-backup-e2e
Aug 1, 2026
Merged

AresConnor merged 4 commits into
masterfrom
feat/published-host-backup-e2e

Conversation

@AresConnor

Copy link
Copy Markdown
Contributor

Summary

Closes the coverage gap carried out of SDK-9b as the first MCP-6 item: the published-host suite now drives mcsl.backup.* end-to-end against a published daemon and runs, polls, and cancels a real long-running operation. Along the way the adversarial review of this branch surfaced a spec §7 violation in the operation coordinator, fixed here because the e2e's central assertion depends on it.

The daemon fix (fix(operations))

Spec §7 ("Result/cancellation race"): a committed executor outcome must not be downgraded to cancelled. Both coordinator override sites did exactly that downgrade unconditionally. For backup.restore.execute this was destructive: no cancellation check existed between extraction finishing and the working-directory swap + retired-tree delete, so a late cancel reported cancelled over a restore that had fully happened — with the pre-restore tree already deleted.

Fix: an internal commit-point seam (IOperationCommitPoint, daemon-internal on purpose — the packaged Daemon.API surface is byte-identical, ApiTests prove it). The restore performs a final ThrowIfCancellationRequested and then MarkCommitted() immediately before the first swap move; both override sites skip the downgrade once committed. After this fix, Cancelled ⇔ the swap never happened is a real guarantee, and the e2e asserts it.

Negative control: reverting one override guard alone makes exactly the markCommitted: true theory case fail; restored and re-verified.

The remaining executors (provisioning.execute, backup.create, automation intent) still lack commit points — tracked as #73, deliberately out of scope here.

The e2e (test(backups))

One scenario against a published daemon with no plugins: create a minimal MCJava instance (empty server.jar via the passthrough installer; the version detector tolerating an unrecognized jar is documented at the call site), seed 256 MiB of incompressible data plus a marker file, then:

  1. backup.create → operation observed Running, polled to Succeeded; backup.list shows the archive (both TotalSizeBytes and the on-disk CompressedSizeBytes asserted ≥ seed).
  2. Mutate the marker, restore.plan → confirm (hash echo) → execute; wait until the operation is observed at stage Extracting, then mcsl.operation.cancel; assert Cancelled, the observed stage trail includes Extracting, and the working directory was not swapped.
  3. A second plan/confirm/execute polled to Succeeded; marker restored to its original content.

All poll loops carry terminal early-exits and diagnostic trails; the previously vacuous log assertion now checks the terminal snapshot's ErrorCode. The PublishedDaemonFixture was extracted verbatim from PublishedInstanceHealthPluginTests (verified line-by-line in review) so both test classes share it.

Review provenance

Multi-agent adversarial review (3 dimensions → per-finding adversarial verification): 14 confirmed findings, all addressed in the last two commits — including the daemon fix, cancel-phase pinning (the original cancel landed during checksum verify, not extraction), and assertion-strength repairs.

Verification

  • ProtocolTests /m:1: 1375/1375. (The two historically "environmental" symlink failures no longer exist on the dev host — Developer Mode enables unprivileged Directory.CreateSymbolicLink; nothing is excused.)
  • Daemon.ApiTests: 116/116 — public API baselines unchanged by the daemon fix.
  • Published-host suite, daemon republished from this branch, 3 consecutive full runs: 12/12. Cancel→terminal 56/87/57 ms; uncancelled restore ~0.5–0.6 s.
  • git diff --check clean. Zero changes to the packaged surface; docs/preview2-package-pin.md gap note updated to state exactly what is and is not covered (no prune, no Maintenance:true backup of a running instance).

Lift PublishedDaemonFixture out of PublishedInstanceHealthPluginTests so a
second published-host test class can boot a daemon without depending on the
plugin-load tests. Behaviour is unchanged: the class moves verbatim, taking
the StartupTimeout default it already used with it.
…a published daemon

Close the recorded SDK-9b/MCP-6 gap without a daemon-side fake operation. The
test creates a minimal instance over mcsl.instance.create, seeds its working
directory with incompressible bytes, then runs mcsl.backup.create, a restore
that is cancelled mid-flight, and a restore that completes. The archived
payload is what makes the restore long enough to cancel before its staging
swap, so an archive that fails to capture it is asserted rather than silently
turning the cancel assertion into a tautology.

The fixture gains a plugin opt-out because these are built-in RPCs; skipping
the plugin payloads also skips the SDK pack and publish they require.
Spec section 7 says an executor that has committed its side effects keeps its
terminal status; the coordinator downgraded it to cancelled at both override
sites regardless. Restore made that concrete and destructive: nothing observed
the token between extraction finishing and the working directory being
swapped and the original tree deleted, so a late cancel reported cancelled
over a restore that had already happened.

Add an internal commit-point seam the coordinator owns, set it in the restore
immediately after its last cooperative check, and let both override sites
respect it. The seam is internal on purpose — the packaged Daemon.API surface
does not change. Wiring the remaining executors is deliberately out of scope.
Waiting for Running exited at stage Resolving, so the cancel landed during the
checksum verify and the per-entry extraction cancel path was never exercised.
Wait for Extracting instead, and give the timing-sensitive assertions failure
messages that name the cause and dump the observed status/stage trail.

Also drop two assertions that could not fail: the archive size guard now also
checks the on-disk zip size, and the manual-recovery check moves off the
daemon log, where that string never appears, onto the terminal error code.
The docs note now lists what the suite covers and what it still does not.
@AresConnor
AresConnor force-pushed the feat/published-host-backup-e2e branch from 39bdb03 to 80a5586 Compare August 1, 2026 08:55
@AresConnor
AresConnor merged commit 6b8089d into master Aug 1, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant