Phase 2 fprintd shim — GNOME Settings enrollment + deletion evidence
=====================================================================
Date: 2026-10-15  (continues work/debug/fprintd_shim_lock_screen_SUCCESS.txt)

What works
----------
* Enrollment from GNOME Settings (Users -> Fingerprint Authentication ->
  Add Fingerprint): verification of the flow 2026-10-15 13:04, 8 stages
  then commit; the finger is listed and matches:

    journalctl -u fprintd:
      13:04:38 enroll start (right-middle-finger) by :1.2110
      13:04:51..13:05:00 enroll: stages 1..8 passed
      13:05:04 enroll: committed
      13:05:04 enroll: user nebulon -> right-middle-finger (harness eof rc=0)

    $ fprintd-list nebulon
      Fingerprints for user nebulon on Synaptics 06cb:0081 (press):
       - #0: right-middle-finger
    $ fprintd-verify -f any nebulon        (touch)
      Verify result: verify-match (done)   rc=0

* Deletion (executed end-to-end through the shim's DeleteEnrolledFinger):
    ListEnrolledFingers -> ['right-middle-finger']
    DeleteEnrolledFinger ok
    ListEnrolledFingers -> net.reactivated.Fprint.Error.NoEnrolledPrints

  Device-side, `delete.exe` (a.exe with enroll() redirected to the existing
  deleteRecord()) returns:
      about to 442034
      Got back 0x8 bytes: 0100000000000000      <- success

Artifacts
---------
* work/artifacts/make-enroll-delete.sh -> enroll.exe / delete.exe
  (a.exe ignores argv - the nop|identify|enroll dispatch is #if 0 upstream -
  so the hardcoded default flow is patched instead; no WDK headers needed)
* state: /var/lib/fprintd-shim/state.json (created by the service;
  default for nebulon is right-index-finger = the original enrollment)

Findings / caveats (all reproduced, all with log evidence)
----------------------------------------------------------
1. winusb stub exit(0): the hacked Wine winusb calls exit(0) on any failed
   libusb transfer (res_err/winusb.c).  With WINEDEBUG=-all this is silent.
   Harness runs now use -all,err+all and log to /tmp/opencode/harness-*.log.
2. Re-enrolling an EXISTING record can die in the commit phase (the stub
   exits mid-write; both attempts 12:46 and 12:47 ended after the commit
   request with no response).  A fresh commit (no record / after delete)
   committed cleanly (12:59 and 13:05).  Recovery for a broken record:
   delete -> enroll again.
3. The 12:47 aborted update-commit left a device record that matched
   nothing (0x8009801F WINBIO_E_NO_MATCH for both fingers).  Cleared with
   delete.exe; a fresh enroll then matched.
4. GNOME Settings' delete flow starts with an identify step (VerifyStart,
   expects a touch) and appears to abandon the delete call after ~10 s; the
   shim now (a) keeps a running delete.exe alive when the client releases,
   (b) updates the reported state optimistically at delete start (restored
   if the harness fails) so the UI immediately reflects the deletion, and
   (c) updates state after a successful harness run even if the client is
   gone (previously the release-during-delete left state.json stale).
   Verified 2026-10-15 13:5x: removal via Settings worked.
5. Why re-enrollments failed (13:10-13:13): a commit that *replaces* an
   existing record makes the device re-enumerate mid-write:

     /tmp/opencode/harness-enroll.exe-1792062705.log:
       0009:err:winusb:WinUsb_WritePipe xfer Failed - LIBUSB_ERROR_NO_DEVICE
       (last marker: "about to Commit Enrollment", no response, harness rc=0)

   while a fresh commit (no record) completes normally:
     ... about to Commit Enrollment -> Got back 0x1 bytes: 01

   Fix in the shim: always delete any existing record before enrolling
   (delete ioctl does not reset the device), so every enrollment is a fresh
   write; state is cleared accordingly and set again on commit.
   Result: an enrollment that previously failed on the second attempt now
   runs delete -> fresh commit on every try.
