Repository navigation
test: isolate Windows registry and driver directories - #508
Conversation
zeroshade
left a comment
There was a problem hiding this comment.
Thanks — the process-private hive + temp roots approach is sound, and every production registry access in config/dirs_windows.go now goes through ConfigLevel.key() → winregroot, so nothing escapes the fixture.
One thing I'd like to settle before merging: with this change, the Windows DBC_TEST_LEVEL_SYSTEM CI job no longer exercises real HKLM\SOFTWARE\ADBC\Drivers or C:\Program Files\ADBC\Drivers. Isolation is the right default for dev machines, but CI runners are disposable — could we add an opt-out (e.g. an env var that skips wintest.Setup()) so one Windows job keeps covering the real locations?
Smaller items:
assertLocalHTTPRoundTripin the child process doesn't relate to registry/filesystem isolation — what is it guarding?- The
RWMutexes inwinregroot/systempatharen't needed since overrides are only set inTestMainbeforem.Run(); plain vars would do. Also consider merging the two packages. - With isolation in place, the
test_registrybuild-tag gate onregistry_test.gomay no longer be necessary (follow-up). - Please squash on merge;
80a6eefis superseded by6b4e99d.
|
@zeroshade Updated in 8c873ab.
|
zeroshade
left a comment
There was a problem hiding this comment.
Thanks — DBC_TEST_WINDOWS_REAL_LOCATIONS addresses my concern: the Windows System job now exercises the real HKLM/Program Files locations (confirmed in the CI log: TestSubcommandsSystem passes with the env set), while every other run stays isolated and Setup() never falls back to real roots implicitly. The rationale for keeping the loopback check, the mutexes and the package split is reasonable now that it's documented, and dropping the test_registry gate is a nice simplification.
Please squash on merge (80a6eef is superseded by 6b4e99d).
## Summary This PR extracts the transactional package installation foundation from #497 for dbc 0.4.0. Direct install, sync, and `Client.Install` prepare a validated, dbc-owned driver payload before replacing the runtime registration. The previous installation remains usable until commit. It also removes **manifest-only dbc package installation**, an undocumented feature with no known usage. Every installed package must contain an actual `Files.driver` payload; `Driver.shared` is no longer a fallback for a missing payload. This requirement applies even when signature verification is disabled. Ordinary ADBC runtime manifests that reference externally managed libraries remain supported. Removing manifest-only **packages** does not remove external runtime registration discovery or parsing. ## Transaction contract ```text private staging -> archive validation and optional verification -> ownership receipt -> unique owned-payload generation publication -> runtime registration replacement [commit] -> conservative post-commit cleanup ``` - Pre-commit failures preserve the previous registration and payload. Post-commit cleanup failures do not roll back a successful installation. - Unix registrations use atomic file replacement. Windows restores previous raw registry values after ordinary partial failure; rollback failure preserves the candidate because registration state is uncertain. - Driver-scoped locks serialize cooperating mutations. Install/update writes only the primary root; lower-priority installations remain in place. - Cleanup retains filesystem identity, symlink/TOCTOU, cross-root reference, and external-registration borrower checks. Receipts describe owned payloads only and are deleted last. - `InstallPackage(ctx, ...)` supports cancellation during lock waits and safe pre-commit boundaries. Registration mutation completes once started, including any rollback. ## Behavior changes in 0.4.0 | Case | Previous behavior | Behavior in this PR | | --- | --- | --- | | Package without `Files.driver` | Could install only a manifest pointing to an external library; this was undocumented. | Rejected before publication or registration changes. | | Replacing an installed version | Some paths uninstalled the working version before the replacement was ready. | Prepare and validate the replacement first, then switch registration and clean up. | | Receipt-backed dbc package uninstall | No transactional ownership receipt. | Remove registration, then delete validated owned files conservatively. | | Normal pre-0.4 dbc package uninstall | Could recursively remove the package directory. | Recognize `source = "dbc"` and a safe same-root legacy layout; delete only the exact registered driver binary, then remove its directory if empty. Metadata may remain. | | External or ambiguous registration uninstall | External library bytes could be deleted in some cases. | Remove registration and retain library bytes. | | `config.UninstallDriverShared` | Public API for shared-library removal. | Removed; use `Config.UninstallDriver` or `Client.Uninstall`. | Legacy ownership is a compatibility assumption based on the old install layout, not a provenance proof. Unsafe paths, uncertain filesystem identity, conflicting references, or unknown/corrupt receipts prevent payload deletion. No additional heuristics reconstruct legacy ownership. ## Compatibility and scope Same-version direct install still exits before download or verification. `Client.Install` does not gain mandatory signature or MANIFEST-version checks. `InstallDriver` remains a deprecated, non-transactional API, with the same owned-payload requirement. Native locks coordinate processes; Wasm locks are runtime-local. Wasm uninstall retains payloads because directory identity cannot be pinned safely. Post-uninstall cleanup errors identify retained paths; recovery of registration-less generations is deferred. Stable Windows registry lock identity remains follow-up work. With `ADBC_DRIVER_PATH`, cleanup scans other configured roots without taking their locks, so a manifest created there concurrently could reference a just-removed library; dbc never creates such cross-root references itself. Stale-generation cleanup errors after a successful install or uninstall are currently dropped; reporting them is follow-up work. Owned payloads are stored in hidden `.dbc-package-g-*` directories next to the driver manifest, created with the process umask applied. On Unix, lock files are intentionally left in place after release. Lockfile v2, Packslip, a new package format, external registration commands, aliases, and replay/repair are outside this PR. This foundation accepts prepared owned payloads so future package decoding and reproducible-artifact locking can build on the same transaction model. ## Validation CI passes on Linux, macOS, Windows, and Wasm (Node and Deno). Windows tests now use the shared registry and directory isolation from #508.
Fix unsafe Windows tests discovered while reviewing #502 by isolating registry and driver directories in process-private temporary fixtures.