2026-06-21 07:17:25 +08:00
|
|
|
/**
|
|
|
|
|
* The `Branded<B>` nominal-typing primitive — a type-only utility (no runtime
|
|
|
|
|
* code, no harness-package dependency) shared by every package that owns a
|
|
|
|
|
* cross-boundary id.
|
|
|
|
|
*
|
|
|
|
|
* A brand makes structurally-identical strings non-interchangeable at the type
|
2026-07-14 01:59:21 +08:00
|
|
|
* level: a `SessionId` cannot be passed where a `CallId` is expected, even
|
2026-06-21 07:17:25 +08:00
|
|
|
* though both are plain strings at runtime. Construction goes through a per-id
|
|
|
|
|
* factory in the OWNING package (a plain cast inside — zero runtime cost);
|
|
|
|
|
* comparison, logging, and serialization all behave as ordinary strings.
|
|
|
|
|
*
|
|
|
|
|
* Policy: a package brands the ids it owns — `CallId` in dsh-llm (tool-call
|
2026-07-15 23:29:47 +08:00
|
|
|
* correlation), the shared agent/session `SessionId` in dsh-session, and
|
2026-07-13 16:29:50 +08:00
|
|
|
* `TaskId` in dsh-tasks. Branding is for ids that cross package boundaries and
|
|
|
|
|
* could plausibly be confused; not every string needs a brand.
|
2026-06-21 07:17:25 +08:00
|
|
|
* This package owns ONLY the primitive — no concrete id, no runtime code beyond
|
|
|
|
|
* the (erased) type — so the brand vocabulary stays dependency-free and a
|
|
|
|
|
* package can brand its ids without depending on an unrelated capability
|
2026-07-13 16:29:50 +08:00
|
|
|
* package.
|
2026-06-21 07:17:25 +08:00
|
|
|
*
|
|
|
|
|
* @module @deepseek-ai/dsh-brand
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
declare const BRAND: unique symbol
|
|
|
|
|
|
|
|
|
|
/** A string carrying a compile-time-only brand `B`. */
|
|
|
|
|
export type Branded<B extends string> = string & { readonly [BRAND]: B }
|