refactor(security): introduce PipeName newtype (Phase 4 sub-phase 5b.1)#256
Merged
Merged
Conversation
Replace the free `pipe_name_for_current_user()` function and bare `String`
pipe paths with a validated `PipeName` newtype in `uffs-security::pipe`,
mirroring the `DriveLetter` precedent from sub-phase 5b.
Pipe paths now carry their Win32 invariants in the type system:
* `\\.\pipe\` prefix
* non-empty name segment
* <= 256 chars total (Win32 `CreateNamedPipeW` limit)
API surface:
* `PipeName::for_current_user() -> io::Result<Self>` — canonical
deterministic per-user path (`\\.\pipe\uffs-<fnv1a64-of-user-sid>`).
* `PipeName::parse<Input: Into<String>>(input) -> Result<Self, PipeNameError>`
— validates an owned-or-borrowed string; returns a structured error
enum (`BadPrefix { raw }` / `Empty` / `TooLong { len }`).
* `as_str()`, `Display`, `AsRef<str>` for FFI / tracing call-sites.
Consumers migrated:
* `uffs-client::daemon_ctl::pipe_name()` now returns `io::Result<PipeName>`.
* `connect_platform.rs`, `connect_sync_platform.rs`, the keep-alive
nudge in `daemon_ctl.rs`, and the blackhole-pipe test in
`windows_deadline.rs` all pass `name.as_str()` to Win32 `.open()`.
* `uffs-daemon::ipc::create_pipe_server()` takes `&PipeName` instead
of `&str`, propagating the invariant to the FFI boundary.
Tests strengthened (no suppression hacks):
* Pre-existing deterministic-per-user + canonical-shape tests now
exercise the typed API.
* Added 4 parse-validation tests: accepts valid path, rejects missing
prefix, rejects empty-after-prefix, rejects over-length input.
* Added round-trip test asserting `for_current_user()` output
re-parses as a valid `PipeName`.
* `windows_deadline.rs` test fixture builds its unique pipe path
through `PipeName::parse`, doubling as a regression pin against
invariant drift (prefix or length-cap changes).
Lint posture: full `just lint-pre-push` gate passes (fmt + clippy host
+ clippy Windows + lint-tests + rustdoc + doc-tests + tests + smoke +
deny + manifest-audit). No `#[allow]` / `#[expect]` added; surgical
fixes only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sub-phase 5b.1 of the Phase 4 newtype migration: replace the free
pipe_name_for_current_user()function and bareStringpipe paths with a validatedPipeNamenewtype inuffs-security::pipe, mirroring theDriveLetterprecedent from sub-phase 5b.Pipe paths now carry their Win32 invariants in the type system:
\\.\pipe\prefixCreateNamedPipeWlimit)API surface
PipeName::for_current_user() -> io::Result<Self>— canonical deterministic per-user path (\\.\pipe\uffs-<fnv1a64-of-user-sid>).PipeName::parse<Input: Into<String>>(input) -> Result<Self, PipeNameError>— validates owned-or-borrowed strings; returns a structured error enum (BadPrefix { raw }/Empty/TooLong { len }).as_str(),Display,AsRef<str>for FFI + tracing call-sites.Consumers migrated
uffs-client::daemon_ctl::pipe_name()now returnsio::Result<PipeName>.connect_platform.rs,connect_sync_platform.rs, the keep-alive nudge indaemon_ctl.rs, and the blackhole-pipe test inwindows_deadline.rsall passname.as_str()to Win32.open().uffs-daemon::ipc::create_pipe_server()takes&PipeNameinstead of&str, propagating the invariant to the FFI boundary.Tests strengthened (no suppression hacks)
for_current_user()output re-parses as a validPipeName.windows_deadline.rstest fixture builds its unique pipe path throughPipeName::parse— doubles as a regression pin against invariant drift.Lint posture
Full
just lint-pre-pushgate passes locally (fmt + clippy host + clippy Windows + lint-tests + rustdoc + doc-tests + tests + smoke + deny + manifest-audit). Zero#[allow]/#[expect]added; surgical fixes only.Follow-ups (separate PRs)
UsnnewtypeFrsnewtype