refactor(shared): delete unwrapOk, the unadopted test value-object helper (RB-33)

unwrapOk had zero consumers in apps/ or libs/ since ADR-0006 shipped it.
The one call site the finding named already satisfies the ADR's real
rule (call the real parser, never a cast) with an inline guard, so
adding a manufactured first caller was not the better fix. This commit
deletes the helper and its file, and updates the one doc sentence that
named it. The finding's call site is unchanged. See rb-33.md for the
full adopt-or-delete reasoning.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
eho
2026-08-28 13:14:21 +02:00
co-authored by Claude Opus 5
parent 03c6e09306
commit 531817259e
4 changed files with 140 additions and 54 deletions
+5 -5
View File
@@ -89,11 +89,11 @@ can only ever be a state the real reducer actually produces:
const atStep3 = givenIntake(Start(), SetUren('1200'), Next(), SetDiplomaHerkomst('NL'), Next());
```
The same rule extends to value objects (`unwrapOk(parseX(raw))` instead of a cast) and to
`RemoteData` (`loading()` / `success(v)` / `failure(e)` in
`libs/shared/src/testing/{value-object,remote-data}.ts` instead of a redefined-per-file
literal). **Never** a `.withX().withY()` builder over an open constructor — that just
re-opens whatever illegal state the domain closed.
The same rule extends to value objects — call the real `parse*` and check `.ok` before use,
never a cast — and to `RemoteData` (`loading()` / `success(v)` / `failure(e)` in
`libs/shared/src/testing/remote-data.ts` instead of a redefined-per-file literal). **Never**
a `.withX().withY()` builder over an open constructor — that just re-opens whatever illegal
state the domain closed.
## UI = Storybook, not heavy component tests
-14
View File
@@ -1,14 +0,0 @@
import { Result } from '@shared/kernel/fp';
/**
* Unwrap a `Result` produced by a REAL `parse*` value-object parser, throwing
* if it isn't `ok`. This is the only sanctioned way for a spec to obtain a
* branded value-object type — it closes off the `'garbage' as Postcode` cast
* route, since the only door to the branded type is the parser itself.
*/
export function unwrapOk<E, T>(result: Result<E, T>): T {
if (!result.ok) {
throw new Error(`unwrapOk: expected ok, got error: ${JSON.stringify(result.error)}`);
}
return result.value;
}