# Task Spec: `M-SHORTURL-01..04` — Frozen V1, Additive V2 Local/Durable/Remote Providers & V1 Adapter - **Branch**: `feat/roadmap-p2-wave9` (baseline `main` at `3e25405`). - **Roadmap authority**: `docs/roadmap/modules/ShortUrl.md` (`M-SHORTURL-01`..`M-SHORTURL-04`), `ARCHITECTURE.md` C-02..C-05, C-09, C-13. - **Error domain**: `Void::Result::kShortUrlErrorDomain = 28`. ## Scope & Deliverables 1. **Frozen `V1` Contract (`include/Void/ShortUrl/ShortUrl.hpp`, `docs/short-url.md`)**: - Zero changes to `Void::ShortUrl::V1` layout, enum ordinals, virtual table order, or `docs/short-url.md`. - Keep `ShortUrl` module's internal dependencies lightweight (`Service Time`), with zero `Storage`, `Net`, or `Security` dependencies. 2. **Additive `Void::ShortUrl::V2` Core & Local Provider (`include/Void/ShortUrl/V2.hpp`)**: - `V2ErrorCode` mapped via `kShortUrlErrorDomain = 28` (`InvalidUrl`, `InvalidKey`, `InvalidExpiry`, `Conflict`, `NotFound`, `Expired`, `Revoked`, `Unsupported`, `RateLimited`, `QuotaExceeded`, `IdentityExpired`, `StorageError`, `UnknownOutcome`, `ProviderError`, `Timeout`, `Unavailable`). - `CreateLink`, `ShortenOptions` (`operation_id`, `idempotency_ttl = 24h`), `Link`, `LinkRecord`, `LinkState::{Active, Revoked}`, `LocalProviderLimits` (`max_url_bytes = 8192`, `max_key_bytes = 64`, `generated_key_length = 16`, `max_collision_retries = 8`, `max_retained_identities = 10000`, `max_entries = 100000`, `max_concurrent_ops = 128`). - Strict target URL validation (absolute `http`/`https`, no userinfo, no control chars, <= 8 KiB, optional host deny predicate) and custom key validation (1..64 `[A-Za-z0-9_-]`, case-sensitive, reserved route rejection). - Abstract `LinkRepositoryPort` + `RandomBytesPort`, explicitly nondurable `InMemoryLinkRepository` (for unit/semantics tests), rejection-sampled base62 key generation, atomic conditional insert + idempotency record, civil expiry via injected `Void::Time::CivilClock`, tombstone `revoke()` (never reusing revoked keys), `V1Adapter` implementing `V1::IShortener` without modifying `V1`. 3. **Durable Storage Provider (`src/ShortUrlStorage/module.cmake`, `include/Void/ShortUrlStorage/StorageRepository.hpp`, `src/ShortUrlStorage/StorageRepository.cpp`)**: - Separate module (`INTERNAL_DEPS ShortUrl Storage Security`) keeping `ShortUrl` free of `Storage`/`libsodium`. - `StorageLinkRepository` backed by `Void::Storage::Engine` conditional `WriteBatch` (versioned records, atomic link + idempotency commit, tombstone persistence, byte quota enforcement, full recovery across engine reopen) + `SecurityRandomBytesPort` backed by `Void::Security::random_bytes`. 4. **Remote Provider SPI (`src/ShortUrlRemote/module.cmake`, `include/Void/ShortUrlRemote/RemoteProvider.hpp`, `src/ShortUrlRemote/RemoteProvider.cpp`)**: - Separate module (`INTERNAL_DEPS ShortUrl Net Data`) keeping `ShortUrl` free of `Net`/Boost/OpenSSL. - `RemoteCapabilities`, `RemoteProviderOptions` (explicit origin, secure `HttpClient`, max 1 MiB response, 10s deadline), `RemoteProvider` checking capability flags before network mutation, preserving `Retry-After` and classifying transport failures after send as `UnknownOutcome` without blind replay, plus loopback fixture tests. 5. **Installed Consumers**: - `tests/package/ShortUrlOnly/` (`ShortUrl` with zero external packages) + `ShortUrlProviders` in `tests/package/InstalledComponents.cmake`. ## Verification - Standalone `ShortUrl;ShortUrlStorage;ShortUrlRemote;Testing` (`-DVOID_WARNINGS_AS_ERRORS=ON`), `ctest` (`ShortUrlOnly`, `ShortUrlProviders`), full `RelWithDebInfo`, Debug `ASan+UBSan`, Debug `TSan`.