Skip to content

Expose and test what Reset and Delete offer for a profile's archives - #201

Merged
bcourbage merged 1 commit into
mainfrom
test/archive-selection-seam
Nov 8, 2026
Merged

bcourbage merged 1 commit into
mainfrom
test/archive-selection-seam

Conversation

@bcourbage

Copy link
Copy Markdown
Owner

What

Moves the archive selection out of ProfileEditorWindowController's instance methods into nonisolated statics, with no behavior change, and adds ArchiveOfferSelectionTests over real archive files in a temporary Unison directory.

  • resetArchiveCandidates: the hash gate plus the located archives (the three Reset failure cases come back as ArchiveHash.Failure).
  • deleteArchiveOffer: the located files and hashes, the ownership verdict, and removalOffered (files present and no other owner).
  • locateArchives and profileRoots take the Unison directory and local hostname instead of reading controller state. ArchiveLocation is no longer private.
  • resetArchivesAction, confirmAndResetArchives and deleteAction now call these. The alert text, buttons and the mutation path are untouched.

Tests cover a local pair and a profile with an ssh root (selected files, hashes, header roots), the three Reset gates, archives under a former hostname (not live), and Delete's withheld offer when another profile shares the roots, for both root kinds.

Why

Step 2 of the cleanup plan. locateArchives never reads its computed parameter. Dropping it and reading the profile once is the next PR, and these tests are its baseline: they must pass unchanged. They also pin that the hash call still works as a gate.

Size

Production: +72 / -30 in one file (the statics and two small types add lines now; the next PR removes the unused parameter). Tests: one new file, 10 tests.

One ordering difference: Reset now locates archives before refreshTableFirstResponder() instead of after. That call only nudges focus and does not touch archive state.

Verified

make test on Heracles: 1546 tests, 0 failures.

🤖 Generated with Claude Code

Moves the archive selection out of the editor controller's instance
methods into nonisolated statics, with no change in behavior:

- resetArchiveCandidates: the hash gate plus the located archives
- deleteArchiveOffer: the located archives, the ownership verdict and
  whether removal is offered
- locateArchives and profileRoots take the Unison directory and local
  hostname instead of reading the controller's state

Adds ArchiveOfferSelectionTests over real archive files in a temporary
directory: a local pair and a profile with an ssh root (selected files,
hashes and header roots), the three Reset gates, archives under a former
hostname, and Delete's withheld offer when another profile shares the
roots, for both root kinds.

This is the baseline for dropping the unused hash parameter from
locateArchives and reading the profile once.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@bcourbage
bcourbage merged commit 38b2b27 into main Nov 8, 2026
2 checks passed
@bcourbage
bcourbage deleted the test/archive-selection-seam branch November 8, 2026 00:00
bcourbage added a commit that referenced this pull request Nov 8, 2026
locateArchives never read the computed hash result; it finds a profile's
archives by matching the roots recorded in each archive header. The hash
computation remains the gate that decides whether a profile can be reset
or whether Delete offers archive removal, so callers still run it and
branch on its failure. Only the unused value stops being passed along.

Also corrects the Reset action's doc comment, which said the hash
identifies the profile's files.

The ArchiveOfferSelectionTests from #201 are unchanged.

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
bcourbage added a commit that referenced this pull request Nov 8, 2026
Selecting archives parsed the profile text twice and computed MD5 digests
that both actions discarded. Add ArchiveHash.eligibilityFailure, the
no-roots and no-local-root gate on a parsed root list, and use it from
computeAllFromProfileText as well so there is one definition of the gate.
The editor now parses the roots once, applies the gate, and hands the same
roots to the header matcher. Hash computation stays for the callers that
use the digests (abandoned-staging recovery).

The ArchiveOfferSelectionTests from #201 are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
bcourbage added a commit that referenced this pull request Nov 8, 2026
)

* Read the profile once when selecting archives for Reset and Delete

The selection read the .prf twice: ArchiveHash.computeAll read it for the
gate, and locateArchives read it again for the roots it matches archive
headers against. The two reads could see different files if the profile
changed between them. Read the text once and feed both the gate and the
root list from it.

Delete's selection now calls resetArchiveCandidates instead of repeating
the gate and locate steps, and the separate root-reading helper goes
away. locateArchives takes the roots directly.

The ArchiveOfferSelectionTests from #201 are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Gate Reset and Delete on the roots without computing archive hashes

Selecting archives parsed the profile text twice and computed MD5 digests
that both actions discarded. Add ArchiveHash.eligibilityFailure, the
no-roots and no-local-root gate on a parsed root list, and use it from
computeAllFromProfileText as well so there is one definition of the gate.
The editor now parses the roots once, applies the gate, and hands the same
roots to the header matcher. Hash computation stays for the callers that
use the digests (abandoned-staging recovery).

The ArchiveOfferSelectionTests from #201 are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Describe Reset's root validation and header matching in its comments

The doc comment and an inline comment still presented the archive hash as
the eligibility gate. Reset validates the profile's roots and matches them
against archive headers; no hash is computed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Reflow the Reset action's doc comment

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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