/** * REFUSING TO PUBLISH A DUPLICATE ADD-ON A CREATOR ALREADY HAS LIVE. * * `helix item publish` has no memory: a lane that republishes from a stale local staging * directory, or reruns a batch script against the wrong output, mints a brand-new item every * time — same mesh, same title, same slot, different id — with nothing anywhere to notice. That * is exactly the shape of the 15-item duplicate-publish incident this guard exists to make * structurally impossible, not just documented against: a lane published new items from stale * local staging directories without checking the live catalogue first. * * Two independent signals, either one enough to refuse: * * 1. TITLE + SLOT TYPE + BASE ITEM, same creator. The backend's own search endpoint filters by * `creatorId` and `slotType` directly (confirmed via its own 400 error listing supported params), * so this is one targeted query, not a full-catalogue scan. Title compares case-insensitively (so * "Sinth Ascetic Pants" catches "sinth ascetic pants") but not as a substring — a real revision * like "Sinth Ascetic Pants V2" is a different title and must NOT false-positive. * * WHY BASE ITEM IS PART OF THE KEY. Title + slot alone is not an identity: a garment title is * only unique WITHIN a host. "Cargo Pants" legitimately exists for Base Male and for Base Female * at the same `character.bottom@1` slot, and a male/female pair is a normal thing to publish, not * a duplicate. Keying on title + slot made every legitimate cross-gender pair a false positive, * whose documented escape hatch was `--allow-duplicate` — and a lane that applied that flag across * a whole batch to get past the false positive ALSO punched through the true positive, which is * how a second Female Ninja Costume went live beside the first. The host the add-on fits is the * missing half of the identity: both sides' `fits.only.items` (an array of base item ids, e.g. * Base Male `b45e4a1e-…` / Base Female `bcafa7e1-…`), and a refusal requires the sets to OVERLAP. * Titles that match under disjoint host sets are different garments and must pass with no flag. * * FAIL SAFE: if EITHER side's base ids are missing or empty, the base-item test cannot separate * the two and the pair is treated as a match. A gap in the catalogue data must weaken the guard to * its OLD title+slot behaviour, never below it — an unknown host is not a licence to publish. * * 2. CONTENT HASH, same creator. There is no live-catalogue field exposing a hosted asset's * content hash to compare against (checked: the search/detail responses carry `sizeBytes` and a * Continuum `manifestCid`, which hashes the sealed PACKAGE MANIFEST, not the raw mesh bytes) — * so an API-side hash comparison is not practically available without a new backend surface. * What IS available locally: this machine's own record of what it has already published. Every * successful add_on publish from THIS CLI records the mesh's sha256 under `~/.helix/`, beside * credentials.json — the same per-machine directory every agent lane on this host already * shares — so a republish of byte-identical content from a stale staging directory, even under * a different title, is still caught. This is a local record of history, not a live-catalogue * guarantee: it will not catch a duplicate uploaded from a machine that has never published it * before. The title+slot+base check above is the one that still holds in that case. * * `--allow-duplicate` is the explicit, auditable override for a creator who genuinely means to * publish a second copy (an intentional variant, a deliberate re-release) — never a silent default. */ export interface PublishDuplicateGuardInput { /** The title about to be published. */ title: string; /** `fits.slotType` — always present by the time this runs; add_on payloads require it. */ slotType: string; /** `fits.only.items` on the payload being published — the base host item ids this add-on fits. * Empty/undefined is possible (an add-on may declare its host by tag or not at all yet); the * fail-safe in `baseItemSetsOverlap` treats that as "cannot separate", see the file header. */ baseItemIds: readonly string[]; /** sha256 of the mesh bytes about to be uploaded. Undefined for a meshless (clip-set) add-on. */ contentHash: string | undefined; /** The authenticated creator's id (JWT `sub`), scoping both checks to "this creator's own items". */ creatorId: string; apiUrl: string; } export interface PublishDuplicateMatch { reason: 'content-hash' | 'title-slot'; itemId: string; title: string; } interface CatalogueApi { request(method: string, path: string, body?: unknown): Promise; } interface HashCacheEntry { itemId: string; title: string; slotType: string; creatorId: string; publishedAt: string; } /** Records a successful add_on publish's content hash for future duplicate detection. Best-effort: * a write failure (read-only home, disk full) must never fail the publish that already succeeded. */ export declare function recordPublishedContentHash(contentHash: string, entry: HashCacheEntry): void; /** sha256 of the mesh bytes about to be uploaded — the same identity a republish of the exact same * file, from any staging directory or filename, will always reproduce. */ export declare function contentHashOf(meshBytes: Buffer): string; /** * Checks both signals and returns the first match, or null when neither fires. Does not throw — * the caller decides how to surface a match. This is retained for read-only * duplicate inspection of existing catalogue content. */ export declare function findDuplicatePublish(api: CatalogueApi, input: PublishDuplicateGuardInput): Promise; export declare function renderDuplicateMatchError(match: PublishDuplicateMatch, title: string, slotType: string): string; export {};