/** * Set / clear a doc's explicit DISPLAY ALIAS number — decoupled from the slug. * * ## Why this module exists * * Under the ratified slug-primary model (saga T11778, ADR reconcile T11676) the * kebab `slug` is the canonical handle and the rendered number (e.g. ADR "051") * is a DISPLAY ALIAS only. Until T11875 that number was DERIVED by parsing the * digits out of the slug string (`adr-051-*` → 051) — so three DISTINCT ADRs * that all slug as `adr-051-*` rendered the same "051" with no way to * disambiguate. The collision is unresolvable in a slug-primary world because * renumbering a slug would break the canonical handle. * * T11875 adds a real `attachments.display_alias` INTEGER column. This module is * the SDK chokepoint that sets it (and validates uniqueness among `type='adr'` * docs). {@link import('./numbering.js').resolveDisplayNumber} prefers the * stored alias when present and falls back to the slug-derived number when null. * * The transaction lives in CORE (not the CLI / dispatch layer) because: * 1. The CLI boundary gate forbids business logic > 30 LOC in CLI commands. * 2. The DB-open chokepoint (`openCleoDb` / `getNativeTasksDb`) is core-owned * per ADR-068; raw `DatabaseSync` opens outside `store/` are rejected. * 3. Future callers (HTTP dispatch, MCP, BRAIN bridges) re-use the same * entry point without re-implementing the all-or-nothing uniqueness check. * * @task T11875 (Epic T11781 / Saga T11778) * @adr ADR-078 — Docs Provenance Graph (display-alias half of T11676 reconcile) */ /** Stable error code surfaced when the target slug does not resolve to a row. */ export declare const SET_ALIAS_NOT_FOUND_CODE = "E_NOT_FOUND"; /** Stable error code surfaced when the requested number is already taken. */ export declare const SET_ALIAS_TAKEN_CODE = "E_ALIAS_TAKEN"; /** Stable error code surfaced when the requested number is not a positive int. */ export declare const SET_ALIAS_INVALID_CODE = "E_VALIDATION"; /** * Input to {@link setDisplayAlias} (ADR-057 uniform params shape). */ export interface SetDisplayAliasParams { /** Slug of the doc to alias (must resolve to an existing `attachments` row). */ slug: string; /** * The display-alias number to assign. Must be a positive integer. Pass * `null` to CLEAR an existing alias (revert to slug-derived rendering). */ displayAlias: number | null; } /** * Result returned by {@link setDisplayAlias}. */ export interface SetDisplayAliasResult { /** Echoed slug of the doc that was aliased. */ slug: string; /** Resolved `attachments.id` of the aliased doc. */ attachmentId: string; /** Doc kind (`type` column) of the aliased doc, echoed for the envelope. */ type: string | null; /** The previous alias value (or `null` if none was set). */ previousAlias: number | null; /** The newly-assigned alias value (or `null` when cleared). */ displayAlias: number | null; /** ISO-8601 timestamp the transaction committed. */ updatedAt: string; } /** * Assign (or clear) the explicit display-alias number for the doc identified by * `slug`, decoupled from the slug string. * * Effects (inside a single SQLite `BEGIN IMMEDIATE` transaction — all-or-none): * * 1. Resolve the row whose `slug` matches `params.slug`. `E_NOT_FOUND` when * no such row exists. * 2. When assigning (non-null) AND the target doc is `type='adr'`, scan every * OTHER `type='adr'` row for the same `display_alias`. Any conflict throws * `E_ALIAS_TAKEN` and the transaction rolls back — numbers are unique among * ADRs. Non-adr kinds skip the uniqueness check (they may reuse numbers). * 3. `UPDATE attachments SET display_alias = ? WHERE id = ?`. * * Uniqueness is enforced HERE (dispatch/SDK layer) rather than via a SQL UNIQUE * constraint because the constraint is scoped to a single `type` value — the * same discipline already used for `lifecycle_status` validation — so future * taxonomy changes never require a schema migration. * * Signature follows ADR-057 — `(projectRoot, params)` is the canonical shape for * core operations consumed by typed dispatch handlers and thin CLI verbs. * * @param projectRoot - Absolute project-root path. Production callers resolve it * via `getProjectRoot()`; tests pass a temp dir. * @param params - {@link SetDisplayAliasParams}. * @returns {@link SetDisplayAliasResult} describing the before/after alias state. * * @throws {CleoError} `E_VALIDATION` when `displayAlias` is a non-positive / * non-integer number. * @throws {CleoError} `E_NOT_FOUND` when `slug` resolves to no row. * @throws {CleoError} `E_ALIAS_TAKEN` when an ADR already owns the number. */ export declare function setDisplayAlias(projectRoot: string, params: SetDisplayAliasParams): Promise; //# sourceMappingURL=display-alias.d.ts.map