{"version":3,"sources":["../resolver.ts","../host/error-report.ts","../resolver/component-resolver.ts","../resolver/overlay-loader.ts"],"sourcesContent":["/**\n * `@ai-matrx/content-ir/resolver` — (kind, platform, role) → component:\n * the `kind_component` row vocabulary and the `ComponentResolver` (compiled\n * floor, DB override, granular per-kind repaint, cold-fetch dedupe,\n * warm/refresh with loud recovery). Pure TS — no React runtime; deliberately\n * unstamped so server graphs can import it.\n */\nexport * from \"./resolver/component-resolution.types\";\nexport * from \"./resolver/component-resolver\";\nexport * from \"./resolver/overlay-loader\";\n","/**\n * THE SCREAM SEAM.\n *\n * Every recovery path in this package is loud: a defective component row, a\n * failed resolver load, a kind whose component throws on a provisional value.\n * The package refuses to own where those screams land — matrx-frontend routes\n * them to the Error Inspector, the dashboard to its own log, the extension to\n * its background page. Each host binds one function.\n *\n * A host that binds a no-op has chosen silence, which is a defect in itself;\n * {@link consoleErrorReporter} is the honest default.\n */\n\nexport interface ContentIrErrorReport {\n  /** Always `\"content-ir\"` — hosts key their capture stores on it. */\n  source: \"content-ir\";\n  message: string;\n  name?: string;\n  stack?: string;\n  /** Free-form grouping key (the host's `relation`), e.g. `\"partial-kind\"`. */\n  relation?: string;\n  raw?: unknown;\n}\n\nexport type ContentIrErrorReporter = (report: ContentIrErrorReport) => void;\n\n/** The default when a host binds nothing: never silent. */\nexport const consoleErrorReporter: ContentIrErrorReporter = (report) => {\n  console.error(`[content-ir] ${report.message}`, report.raw ?? \"\");\n};\n","/**\n * The Shape System component RESOLVER (rulings R1 + R6): (kind, platform,\n * role) → component, with two tiers:\n *\n * - eager: a COMPILED bootstrap the host ships in its bundle — the\n *   trusted-at-boot floor, available at import so the render seam can gate\n *   synchronously from the first streamed byte.\n * - warm:  one `content_ir.kind_component` list fetch per app session\n *   (`ensureWarm`). A DB row for a (kind, platform, role) OVERRIDES the\n *   compiled entry once warm; the compiled floor keeps answering until then\n *   (and forever, on DB failure).\n * - overlay (shape layers): the VIEWER's own `kind_component_layer` rows,\n *   ABOVE the db tier — mine → my organization's (newest) → shared db →\n *   compiled → generic. Installed per viewer by the host (`setOverlay`),\n *   dropped on every auth / admin-lane change (`clearOverlay`). With no\n *   overlay installed, resolution is exactly the two-tier behavior.\n *\n * Resolution is SYNCHRONOUS (the render seam calls it per block); the only\n * async work is the loading, off the render path.\n *\n * WHAT MOVED AND WHY. This class was matrx-frontend's `ComponentRegistry`. It\n * is a large part of why a second UI could not render a kind: every tier rule,\n * every repaint counter, every dedupe latch lived in one app. Nothing about it\n * is Next.js, Redux, or Supabase — the only host-specific parts were the two\n * loaders and the error sink, which are now constructor arguments.\n */\n\nimport type { ContentIrErrorReporter } from \"../host/error-report\";\nimport { consoleErrorReporter } from \"../host/error-report\";\nimport type {\n  ComponentLayerScope,\n  ComponentOverlayInput,\n  ComponentResolution,\n  ComponentResolutionSource,\n  ComponentRole,\n  KindComponentLayerRow,\n  KindComponentRow,\n  SystemComponentEntry,\n} from \"./component-resolution.types\";\n\nexport interface ComponentResolverOptions {\n  /**\n   * The compiled bootstrap, as a THUNK resolved on first use: a host's system\n   * component table is often mid-initialization when this module evaluates\n   * (matrx-frontend's registry cluster has a deliberate import cycle).\n   */\n  compiledEntries?: () => SystemComponentEntry[];\n  /** The warm/refresh list load — every `kind_component` row the user may see. */\n  loadAll?: () => Promise<KindComponentRow[]>;\n  /** The eager single-kind load fired the moment a kind is identified mid-stream. */\n  loadForKind?: (kind: string, platform: string) => Promise<KindComponentRow[]>;\n  /** Where recovery screams land. Defaults to `console.error`, never silence. */\n  reportError?: ContentIrErrorReporter;\n  /** Clock seam — the refresh rate limiter. Defaults to `Date.now`. */\n  now?: () => number;\n  /**\n   * THE BOUNDED WAIT: how long a demanded kind's lookup may stay unanswered before\n   * {@link ComponentResolver.hasSettledFor} gives up on it (screaming once) so the route answers\n   * with the generic floor instead of an endless loader. A late answer still repaints the kind.\n   * Default {@link KIND_LOOKUP_BOUND_MS}.\n   */\n  lookupBoundMs?: number;\n}\n\n/** Default for {@link ComponentResolverOptions.lookupBoundMs}: never an endless skeleton. */\nexport const KIND_LOOKUP_BOUND_MS = 10_000;\n\n/** Unit separator — a character no kind slug, platform, or role can contain. */\nconst KEY_SEPARATOR = String.fromCharCode(1);\n\n/**\n * A refresh lands a BODY-LESS warm list (metadata only; bodies arrive per kind).\n * Dropping a body we already hold for the very same row version sent every\n * mounted db component back to its loading state and remounted it from\n * scratch on each refresh — on every tab return, via the auth re-kick. The\n * same row (component key, source, `updated_at`) keeps its body; an edited row\n * (new `updated_at`) or a different winner does not, so edits still land.\n */\nfunction keepUnchangedBody(\n  next: KindComponentRow,\n  prev: KindComponentRow | undefined,\n): KindComponentRow {\n  if (\n    !prev ||\n    next.componentSource !== null ||\n    prev.componentSource === null ||\n    prev.componentKey !== next.componentKey ||\n    prev.source !== next.source ||\n    (prev.id ?? null) !== (next.id ?? null) ||\n    prev.updatedAt === null ||\n    prev.updatedAt !== next.updatedAt\n  ) {\n    return next;\n  }\n  return {\n    ...next,\n    componentSource: prev.componentSource,\n    propsTransform: next.propsTransform ?? prev.propsTransform,\n  };\n}\n\nfunction keyOf(kind: string, platform: string, role: string): string {\n  return `${kind}${KEY_SEPARATOR}${platform}${KEY_SEPARATOR}${role}`;\n}\n\n/** One ranked overlay winner — the row plus which layer it came from. */\nexport interface OverlayEntry {\n  row: KindComponentLayerRow;\n  scope: ComponentLayerScope;\n}\n\n/**\n * THE LAYER RANK for one (kind, platform, role), pure: the viewer's own row →\n * their organization's row (newest `updated_at` when several organizations\n * have one) → nothing (the shared tiers answer). A switched-off row\n * (`is_active=false`) is not a candidate at all — it FALLS THROUGH to the next\n * layer, unlike the shared tier where an inactive row is a known-held answer.\n * Ties break on id so the pick never depends on arrival order.\n */\nexport function rankLayerRows(\n  candidates: readonly OverlayEntry[],\n): OverlayEntry | null {\n  let best: OverlayEntry | null = null;\n  for (const candidate of candidates) {\n    if (!candidate.row.isActive) continue;\n    if (!best) {\n      best = candidate;\n      continue;\n    }\n    if (candidate.scope !== best.scope) {\n      if (candidate.scope === \"user\") best = candidate;\n      continue;\n    }\n    if (\n      candidate.row.updatedAt > best.row.updatedAt ||\n      (candidate.row.updatedAt === best.row.updatedAt && candidate.row.id > best.row.id)\n    ) {\n      best = candidate;\n    }\n  }\n  return best;\n}\n\nfunction describe(error: unknown): string {\n  return error instanceof Error ? error.message : String(error);\n}\n\n/** Error-shaped fields, spread-safe under `exactOptionalPropertyTypes`. */\nfunction errorFields(error: unknown): { name?: string; stack?: string } {\n  if (!(error instanceof Error)) return {};\n  return {\n    name: error.name,\n    ...(error.stack === undefined ? {} : { stack: error.stack }),\n  };\n}\n\n/**\n * Warm-load retry backoff. Sized for the auth-hydration race: a fresh tab's\n * first list load can run before the Supabase session restores and fail with\n * a permission error; the session is typically live within a second or two,\n * so the first retry usually completes the load. After the last delay the\n * resolver settles on whatever it has — see the failure branch in ensureWarm.\n */\nconst WARM_RETRY_DELAYS_MS: readonly number[] = [1_000, 5_000, 15_000];\n\nexport class ComponentResolver implements ComponentResolutionSource {\n  private compiled: Map<string, SystemComponentEntry> | null = null;\n  private readonly db = new Map<string, KindComponentRow>();\n  /**\n   * THE OVERLAY TIER (shape layers): the viewer's personal / organization\n   * layered winners, ABOVE the db tier. Owned by exactly one viewer\n   * (`overlayViewer`); null viewer = no overlay at all. Never filled by the\n   * warm/refresh/cold loaders — only by {@link setOverlay}.\n   */\n  private readonly overlay = new Map<string, OverlayEntry>();\n  private overlayViewer: string | null = null;\n  /** Change signature of the installed overlay — an identical re-install is a no-op. */\n  private overlaySignature = \"\";\n  /** The host's live \"who is looking right now\" — see {@link setOverlayViewerProbe}. */\n  private overlayViewerProbe: (() => string | null) | null = null;\n  private warmPromise: Promise<void> | null = null;\n  /** Consecutive warm-load failures — indexes WARM_RETRY_DELAYS_MS. */\n  private warmFailures = 0;\n  private warmRetryTimer: ReturnType<typeof setTimeout> | null = null;\n  /**\n   * True once a list load has RUN TO COMPLETION (success or failure), or once\n   * any rows have been ingested by any tier. Until then `resolve()` answering\n   * null means \"I have not looked yet\" — never \"no such component\". See THE\n   * COLD-VERDICT RULE on `ComponentResolutionSource.hasSettled`.\n   */\n  private settled = false;\n  /**\n   * When the last successful wholesale refresh landed, or null for \"never\".\n   * Explicitly nullable rather than 0: with a host-supplied clock that starts\n   * near zero, a `0` sentinel makes the FIRST refresh look rate-limited and\n   * silently skip.\n   */\n  private lastRefreshAt: number | null = null;\n  private refreshPromise: Promise<void> | null = null;\n  private readonly listeners = new Set<() => void>();\n  /**\n   * Cold single-kind fetch dedupe (streaming eager path). In-flight is keyed\n   * by (kind, platform) — the fetch unit; misses are keyed by (kind, platform,\n   * role) so a miss on web/output never suppresses other roles, and CLEARED on\n   * every wholesale refresh (a component created mid-session becomes eagerly\n   * fetchable again — misses are cheap to re-verify).\n   */\n  private readonly coldInFlight = new Set<string>();\n  private readonly coldMisses = new Set<string>();\n  /** Kinds whose demanded lookup outlived the bound (THE BOUNDED WAIT), and the pending bounds. */\n  private readonly lookupGaveUp = new Set<string>();\n  private readonly lookupBounds = new Set<string>();\n  /** Monotonic db-tier version — the repaint hook's snapshot key. */\n  private version = 0;\n  /** Per-kind versions + listeners (granular repaint) + wholesale epoch. */\n  private readonly kindVersions = new Map<string, number>();\n  private readonly kindListeners = new Map<string, Set<() => void>>();\n  private epoch = 0;\n\n  private readonly reportError: ContentIrErrorReporter;\n  private readonly now: () => number;\n\n  private readonly options: ComponentResolverOptions;\n\n  // Explicit field, not a parameter property: consumers compile this source\n  // directly, and a strict host (the dashboard) sets `erasableSyntaxOnly`,\n  // under which parameter properties are a hard error.\n  constructor(options: ComponentResolverOptions = {}) {\n    this.options = options;\n    this.reportError = options.reportError ?? consoleErrorReporter;\n    this.now = options.now ?? (() => Date.now());\n  }\n\n  private compiledMap(): Map<string, SystemComponentEntry> {\n    if (!this.compiled) {\n      this.compiled = new Map();\n      for (const entry of this.options.compiledEntries?.() ?? []) {\n        this.compiled.set(keyOf(entry.kind, entry.platform, entry.role), entry);\n      }\n    }\n    return this.compiled;\n  }\n\n  /**\n   * Synchronous resolve — the render seam's per-block call. DB override first\n   * (once warm), compiled floor second, null for unknown.\n   */\n  resolve(\n    kind: string,\n    platform: string,\n    role: ComponentRole,\n  ): ComponentResolution | null {\n    return this.resolveFrom(kind, platform, role, true);\n  }\n\n  /**\n   * THE SHARED ANSWER — what EVERYONE gets: the db tier, then the compiled\n   * floor, never the viewer's own layered view (\"My view\" / \"My organization's\n   * view\"). Admin screens and fix-it surfaces that grade or compare the shared\n   * component read this; reading `resolve` there mislabels a person's own view\n   * as the shared one. `layer` is always null here.\n   */\n  resolveShared(\n    kind: string,\n    platform: string,\n    role: ComponentRole,\n  ): ComponentResolution | null {\n    return this.resolveFrom(kind, platform, role, false);\n  }\n\n  private resolveFrom(\n    kind: string,\n    platform: string,\n    role: ComponentRole,\n    withOverlay: boolean,\n  ): ComponentResolution | null {\n    const key = keyOf(kind, platform, role);\n\n    // An installed overlay belongs to ONE viewer: if the host says someone else\n    // is looking NOW (a user switch whose clear has not run yet), it does not\n    // answer — the shared tiers do.\n    const layered =\n      withOverlay && this.overlayIsCurrent() ? this.overlay.get(key) : undefined;\n    if (layered) {\n      const row = layered.row;\n      return {\n        componentKey: row.componentKey,\n        source: row.source,\n        config: row.config,\n        isActive: true, // only active rows enter the overlay\n        resolvedBy: \"db\",\n        componentSource: row.componentSource,\n        propsTransform: row.propsTransform,\n        hasComponentSource:\n          row.hasComponentSource ??\n          Boolean(row.componentSource && row.componentSource.trim()),\n        pinnedKindVersion: row.pinnedKindVersion,\n        updatedAt: row.updatedAt,\n        createdBy: row.createdBy,\n        rowId: row.id,\n        layer: { scope: layered.scope, rowId: row.id },\n      };\n    }\n\n    const dbRow = this.db.get(key);\n    if (dbRow) {\n      return {\n        componentKey: dbRow.componentKey,\n        source: dbRow.source,\n        config: dbRow.config,\n        isActive: dbRow.isActive,\n        resolvedBy: \"db\",\n        componentSource: dbRow.componentSource,\n        propsTransform: dbRow.propsTransform,\n        hasComponentSource:\n          dbRow.hasComponentSource ??\n          Boolean(dbRow.componentSource && dbRow.componentSource.trim()),\n        pinnedKindVersion: dbRow.pinnedKindVersion,\n        updatedAt: dbRow.updatedAt,\n        createdBy: dbRow.createdBy,\n        rowId: dbRow.id ?? null,\n        layer: null,\n      };\n    }\n\n    const compiledEntry = this.compiledMap().get(key);\n    if (compiledEntry) {\n      return {\n        componentKey: compiledEntry.componentKey,\n        source: compiledEntry.source,\n        config: compiledEntry.config,\n        isActive: true, // trusted at bootstrap (R6)\n        resolvedBy: \"compiled\",\n        componentSource: null,\n        propsTransform: null,\n        hasComponentSource: false,\n        pinnedKindVersion: null,\n        updatedAt: null,\n        createdBy: null,\n      };\n    }\n\n    return null;\n  }\n\n  /**\n   * Install the viewer's overlay — REPLACES any previous overlay wholesale.\n   * Every row is re-checked against the viewer: a user row whose audience is\n   * not `viewerId`, or an organization row whose audience is not one of\n   * `organizationIds`, is dropped (a host's read that returned too much — an\n   * admin-lane request, a stale membership — can never render a stranger's\n   * view). Always notifies every kind subscriber: the winner of any kind may\n   * have changed.\n   */\n  setOverlay(input: ComponentOverlayInput): void {\n    const organizations = new Set(input.organizationIds);\n    const candidates = new Map<string, OverlayEntry[]>();\n    for (const row of input.rows) {\n      let scope: ComponentLayerScope | null = null;\n      if (row.audienceUserId !== null && row.audienceOrganizationId === null) {\n        if (row.audienceUserId === input.viewerId) scope = \"user\";\n      } else if (row.audienceOrganizationId !== null && row.audienceUserId === null) {\n        if (organizations.has(row.audienceOrganizationId)) scope = \"organization\";\n      }\n      if (scope === null) continue;\n      const key = keyOf(row.kind, row.platform, row.role);\n      const list = candidates.get(key) ?? [];\n      list.push({ row, scope });\n      candidates.set(key, list);\n    }\n    const next = new Map<string, OverlayEntry>();\n    for (const [key, list] of candidates) {\n      const winner = rankLayerRows(list);\n      if (winner) next.set(key, winner);\n    }\n    const signature = [...next.entries()]\n      .map(([key, e]) => `${key}\\u0001${e.scope}\\u0001${e.row.id}\\u0001${e.row.updatedAt}`)\n      .sort()\n      .join(\"\\u0002\");\n    const unchanged =\n      this.overlayViewer === input.viewerId && this.overlaySignature === signature;\n    this.overlay.clear();\n    for (const [key, entry] of next) this.overlay.set(key, entry);\n    this.overlayViewer = input.viewerId;\n    this.overlaySignature = signature;\n    // Nothing a mounted shape could see changed (the common first load of a\n    // viewer with no layered rows is empty → empty): do not repaint every shape.\n    if (!unchanged) this.notifyWholesale();\n  }\n\n  /**\n   * Let the host tell the resolver who is looking RIGHT NOW. `resolve` ignores\n   * an installed overlay whose owner is not that viewer, so a user switch can\n   * never render the previous person's view in the tick before the clear.\n   */\n  setOverlayViewerProbe(probe: () => string | null): void {\n    this.overlayViewerProbe = probe;\n  }\n\n  private overlayIsCurrent(): boolean {\n    if (this.overlayViewer === null) return false;\n    return this.overlayViewerProbe === null || this.overlayViewerProbe() === this.overlayViewer;\n  }\n\n  /**\n   * Drop the overlay. Hosts call this on EVERY auth change (sign-out, sign-in,\n   * user switch) and admin-lane change, before loading the next viewer's rows:\n   * an overlay must never outlive the viewer it was read for.\n   */\n  clearOverlay(): void {\n    const had = this.overlay.size > 0 || this.overlayViewer !== null;\n    this.overlay.clear();\n    this.overlayViewer = null;\n    this.overlaySignature = \"\";\n    if (had) this.notifyWholesale();\n  }\n\n  /** Whose overlay is installed — null when none. */\n  getOverlayViewer(): string | null {\n    return this.overlayViewer;\n  }\n\n  /** Wholesale repaint: bump the epoch, call every per-kind listener, notify. */\n  private notifyWholesale(): void {\n    this.epoch += 1;\n    for (const set of this.kindListeners.values()) {\n      for (const listener of set) listener();\n    }\n    this.notifyChanged();\n  }\n\n  /** R6 floor check: compiled-bootstrap membership = always render-trusted. */\n  hasCompiled(kind: string, platform: string, role: ComponentRole): boolean {\n    return this.compiledMap().has(keyOf(kind, platform, role));\n  }\n\n  /**\n   * Pure ingest — the warm landing point and the unit-test seam. First row per\n   * key wins: rows arrive is_default-first / sort_order-asc from the source.\n   */\n  ingestDbRows(rows: readonly KindComponentRow[]): void {\n    const wasSettled = this.hasSettled();\n    const changedKinds = new Set<string>();\n    for (const row of rows) {\n      const key = keyOf(row.kind, row.platform, row.role);\n      if (!this.db.has(key)) {\n        this.db.set(key, row);\n        changedKinds.add(row.kind);\n      }\n    }\n    // Warm/cold ingest is a resolver-tier change the render seam must see — a\n    // db component landing AFTER a region finalized re-runs the route via the\n    // repaint hook. Per-kind bumps keep the repaint granular.\n    // The first rows settle the tier (hasSettled): every waiting kind hears it,\n    // ONCE — the epoch covers the ingested kinds too.\n    if (!wasSettled && this.hasSettled()) {\n      this.notifySettled();\n      return;\n    }\n    if (changedKinds.size > 0) {\n      for (const kind of changedKinds) this.bumpKind(kind);\n      this.notifyChanged();\n    }\n  }\n\n  /**\n   * Mark the tier settled. THE COLD-VERDICT RULE held every block whose kind\n   * the tier could not answer; settling changes that verdict for ALL of them,\n   * so the flip bumps the epoch and calls every per-kind listener (as a\n   * wholesale replace does). Before 0.13.0 a settle notified only kinds that\n   * gained rows, and a waiting block for any other kind kept its pre-settle\n   * rendering until something unrelated re-rendered it.\n   */\n  private markSettled(): void {\n    // The LIST landing is what every waiting kind waits for (`hasSettledFor`), even when one\n    // kind's own row already made `hasSettled()` true — so the first list landing always\n    // notifies (2026-10-17: a per-kind row closed the tier early and the list landing was silent).\n    const wasListSettled = this.settled;\n    this.settled = true;\n    if (!wasListSettled) this.notifySettled();\n  }\n\n  private notifySettled(): void {\n    this.epoch += 1;\n    for (const set of this.kindListeners.values()) {\n      for (const listener of set) listener();\n    }\n    this.notifyChanged();\n  }\n\n  /**\n   * Refresh landing point: REPLACE the db tier wholesale (same\n   * first-row-per-key contract as {@link ingestDbRows}) so edits, deletions,\n   * and is_active flips all take effect. Always notifies.\n   */\n  replaceDbRows(rows: readonly KindComponentRow[]): void {\n    // A wholesale replace IS a completed list load — the refresh landing\n    // point, and the seam tests use to declare \"the list loaded\". Settling\n    // here keeps THE COLD-VERDICT RULE from holding blocks forever in any\n    // host that warms through refresh() rather than ensureWarm().\n    this.settled = true;\n    const previous = new Map(this.db);\n    this.db.clear();\n    // Wholesale invalidation: every recorded miss is stale (a component\n    // created mid-session must become eagerly fetchable again).\n    this.coldMisses.clear();\n    for (const row of rows) {\n      const key = keyOf(row.kind, row.platform, row.role);\n      if (!this.db.has(key)) this.db.set(key, keepUnchangedBody(row, previous.get(key)));\n    }\n    // A wholesale replace ALWAYS notifies (deletions/flips count too), and\n    // bumps the epoch so EVERY per-kind subscriber re-snapshots.\n    this.epoch += 1;\n    for (const set of this.kindListeners.values()) {\n      for (const listener of set) listener();\n    }\n    this.notifyChanged();\n  }\n\n  getVersion(): number {\n    return this.version;\n  }\n\n  getKindVersion(kind: string): number {\n    return this.epoch + (this.kindVersions.get(kind) ?? 0);\n  }\n\n  subscribeKind(kind: string, listener: () => void): () => void {\n    const set = this.kindListeners.get(kind) ?? new Set<() => void>();\n    set.add(listener);\n    this.kindListeners.set(kind, set);\n    return () => {\n      set.delete(listener);\n      if (set.size === 0) this.kindListeners.delete(kind);\n    };\n  }\n\n  subscribe(listener: () => void): () => void {\n    this.listeners.add(listener);\n    return () => {\n      this.listeners.delete(listener);\n    };\n  }\n\n  private bumpKind(kind: string): void {\n    this.kindVersions.set(kind, (this.kindVersions.get(kind) ?? 0) + 1);\n    const listeners = this.kindListeners.get(kind);\n    if (listeners) for (const listener of listeners) listener();\n  }\n\n  private notifyChanged(): void {\n    this.version += 1;\n    for (const listener of this.listeners) listener();\n  }\n\n  /**\n   * A warm metadata shell is resolved enough for routing, but not for the\n   * host's db-component renderer. Its body must still come from the cold\n   * single-kind loader.\n   */\n  private needsColdFetch(\n    kind: string,\n    platform: string,\n    role: ComponentRole,\n  ): boolean {\n    const resolution = this.resolve(kind, platform, role);\n    return (\n      resolution === null ||\n      (resolution.resolvedBy === \"db\" &&\n        resolution.hasComponentSource &&\n        resolution.componentSource === null)\n    );\n  }\n\n  /**\n   * Cold rows are the authoritative heavy form of warm metadata shells. Keep\n   * the same first-row-per-key winner contract, but replace an existing shell\n   * so `componentSource` / `propsTransform` can land and repaint the kind.\n   */\n  private ingestColdRows(rows: readonly KindComponentRow[]): void {\n    const winners = new Map<string, KindComponentRow>();\n    for (const row of rows) {\n      const key = keyOf(row.kind, row.platform, row.role);\n      if (!winners.has(key)) winners.set(key, row);\n    }\n    if (winners.size === 0) return;\n\n    const changedKinds = new Set<string>();\n    for (const [key, row] of winners) {\n      this.db.set(key, row);\n      changedKinds.add(row.kind);\n    }\n    for (const kind of changedKinds) this.bumpKind(kind);\n    this.notifyChanged();\n  }\n\n  /**\n   * The eager lightweight single-kind fetch (streaming path): the moment a\n   * cloud kind is identified mid-stream, pull ONLY that kind's resolver rows\n   * and ingest them so {@link resolve} can answer before — or shortly after —\n   * the region completes. Deduped in-flight and by known-miss. Fire-and-forget;\n   * failures are loud (the warm list remains the backstop).\n   */\n  requestComponent(kind: string, platform: string, role: ComponentRole): void {\n    this.boundKindLookup(kind, platform);\n    const loadForKind = this.options.loadForKind;\n    if (!loadForKind) return;\n    if (!this.needsColdFetch(kind, platform, role)) return;\n    const missKey = keyOf(kind, platform, role);\n    const flightKey = `${kind}${KEY_SEPARATOR}${platform}`;\n    if (this.coldInFlight.has(flightKey) || this.coldMisses.has(missKey)) {\n      return;\n    }\n    this.coldInFlight.add(flightKey);\n    const versionBefore = this.kindVersions.get(kind) ?? 0;\n\n    void (async () => {\n      try {\n        this.ingestColdRows(await loadForKind(kind, platform));\n        // Record the miss for exactly the requested (kind, platform, role) —\n        // rows may exist for OTHER roles on this platform; those must not be\n        // suppressed, and this one must not be re-fetched until a refresh.\n        if (this.needsColdFetch(kind, platform, role)) {\n          this.coldMisses.add(missKey);\n        }\n      } catch (error) {\n        this.reportError({\n          source: \"content-ir\",\n          message: `component-resolver cold fetch failed for \"${kind}\": ${describe(error)}`,\n          ...errorFields(error),\n          raw: error,\n        });\n      } finally {\n        this.coldInFlight.delete(flightKey);\n        // The kind's single-kind fetch answered (rows, a miss, or a failure):\n        // a block waiting on THIS kind re-routes now. A landing already bumped\n        // inside ingestColdRows; a miss or failure changed nothing in the\n        // tier, but the waiting block must still be told to re-ask.\n        if ((this.kindVersions.get(kind) ?? 0) === versionBefore) {\n          this.bumpKind(kind);\n        }\n      }\n    })();\n  }\n\n  /**\n   * Refresh-on-view: re-fetch the warm list and REPLACE the db tier, so an\n   * edited `source='db'` component (its `updated_at` bump re-keys the host's\n   * compile cache) renders fresh on the next view. Deduped in-flight and\n   * rate-limited by `maxAgeMs` (default 10s) — mounting several previews costs\n   * one fetch. Server-side edits do NOT push to open clients; the contract is\n   * refresh-on-view via this call.\n   */\n  refresh(maxAgeMs = 10_000): Promise<void> {\n    const loadAll = this.options.loadAll;\n    if (!loadAll) return Promise.resolve();\n    if (this.refreshPromise) return this.refreshPromise;\n    if (\n      this.lastRefreshAt !== null &&\n      this.now() - this.lastRefreshAt < maxAgeMs\n    ) {\n      return Promise.resolve();\n    }\n    // Any refresh intent invalidates recorded misses immediately (also cleared\n    // in replaceDbRows when the fetch lands) — cheap to re-verify.\n    this.coldMisses.clear();\n\n    this.refreshPromise = loadAll()\n      .then((rows) => {\n        this.lastRefreshAt = this.now();\n        this.replaceDbRows(rows);\n      })\n      .catch((error: unknown) => {\n        // Loud recovery: the current tier keeps answering; a refresh failure is\n        // a real defect (same posture as the warm loader).\n        this.reportError({\n          source: \"content-ir\",\n          message: `component-resolver refresh failed (current resolver tier still serving): ${describe(error)}`,\n          ...errorFields(error),\n          raw: error,\n        });\n      })\n      .finally(() => {\n        this.refreshPromise = null;\n      });\n    return this.refreshPromise;\n  }\n\n  /** One list fetch per app session; failed loads retry on the next call. */\n  ensureWarm(): Promise<void> {\n    const loadAll = this.options.loadAll;\n    if (!loadAll) return Promise.resolve();\n    if (!this.warmPromise) {\n      this.warmPromise = loadAll()\n        .then((rows) => {\n          this.ingestDbRows(rows);\n          this.markSettled();\n          this.warmFailures = 0;\n          if (this.warmRetryTimer) {\n            clearTimeout(this.warmRetryTimer);\n            this.warmRetryTimer = null;\n          }\n        })\n        .catch((error: unknown) => {\n          // The host owns presentation and severity through reportError. A\n          // direct console.error here duplicates that report and prevents a\n          // host from classifying a still-serving compiled fallback as a\n          // recoverable warning.\n          const message = `component-resolver warm load failed (compiled bootstrap still serving): ${describe(error)}`;\n          this.reportError({\n            source: \"content-ir\",\n            message,\n            ...errorFields(error),\n            raw: error,\n          });\n          this.warmPromise = null;\n          // 🚨 A FAILED load is NOT truth (2026-08-31). The 0.9.0 posture —\n          // \"a failed load still settles\" — turned the auth-hydration race\n          // into a lie: a fresh tab fires this load BEFORE the Supabase\n          // session hydrates, the read runs as `anon`, RLS answers\n          // 42501 permission denied, and settling on that failure declared an\n          // EMPTY resolver to be the loaded state of the world. Every kind on\n          // the page then routed to the generic floor as \"unregistered\" —\n          // while the same rows were one authenticated retry away. So: retry\n          // with backoff, and settle only when retries are exhausted (the\n          // backend really is down; the generic floor + the per-attempt\n          // scream above are then the honest, announced stand-in).\n          this.warmFailures += 1;\n          const delay =\n            WARM_RETRY_DELAYS_MS[this.warmFailures - 1] ?? null;\n          if (delay === null) {\n            this.markSettled();\n          } else if (!this.warmRetryTimer) {\n            this.warmRetryTimer = setTimeout(() => {\n              this.warmRetryTimer = null;\n              void this.ensureWarm();\n            }, delay);\n          }\n        });\n    }\n    return this.warmPromise;\n  }\n\n  /**\n   * THE BOUNDED WAIT. A demanded kind whose lookup has not answered within the bound (a hung\n   * read, a refusal that never re-arms, a list that never lands) is settled by giving up — loudly,\n   * once — so the reader gets the honest generic floor, never an endless loader. A late answer\n   * still lands and repaints the kind with its real component.\n   */\n  private boundKindLookup(kind: string, platform: string): void {\n    const key = keyOf(kind, platform, \"output\");\n    if (this.lookupBounds.has(key) || this.lookupGaveUp.has(key)) return;\n    if (this.hasSettledFor(kind, platform)) return;\n    this.lookupBounds.add(key);\n    const boundMs = this.options.lookupBoundMs ?? KIND_LOOKUP_BOUND_MS;\n    const timer = setTimeout(() => {\n      this.lookupBounds.delete(key);\n      if (this.hasSettledFor(kind, platform)) return;\n      this.lookupGaveUp.add(key);\n      this.reportError({\n        source: \"content-ir\",\n        message:\n          `component-resolver: the component lookup for \"${kind}\" (${platform}) did not answer ` +\n          `within ${boundMs}ms; the reader is shown the generic view until it does.`,\n        raw: { kind, platform, boundMs },\n      });\n      this.bumpKind(kind);\n    }, boundMs);\n    (timer as { unref?: () => void }).unref?.();\n  }\n\n  /** @see ComponentResolutionSource.hasSettledFor */\n  hasSettledFor(kind: string, platform: string): boolean {\n    if (!this.options.loadAll || this.settled) return true;\n    if (this.resolve(kind, platform, \"output\") !== null) return true;\n    // THIS kind's own read answered \"none\" (2026-10-17): that IS this kind's answer. Without it a\n    // kind with no component waited for the whole list — forever on a path that never warms it.\n    const key = keyOf(kind, platform, \"output\");\n    return this.coldMisses.has(key) || this.lookupGaveUp.has(key);\n  }\n\n  /** @see ComponentResolutionSource.hasSettled */\n  hasSettled(): boolean {\n    // No list loader configured = nothing to wait for: the compiled floor IS\n    // the complete truth for this resolver, so it is settled from birth. (A\n    // host that never wired a loader must not have every block held forever.)\n    if (!this.options.loadAll) return true;\n    return this.settled || this.db.size > 0;\n  }\n}\n","/**\n * SHAPE LAYERS — the viewer's overlay LIFECYCLE, shared by every signed-in\n * resolver host (matrx-frontend, the dashboard, the workflow studio).\n *\n * `content_ir.kind_component_layer` holds \"My view\" (`audience_user_id`) and\n * \"My organization's view\" (`audience_organization_id`) components for a kind\n * slug. A host reads THE VIEWER's rows and hands them to\n * {@link ComponentResolver.setOverlay}; this module owns everything around that\n * read so there is ONE implementation of it:\n *\n *  - THE AUDIENCE PREDICATE ({@link layerAudienceFilter}) — the read declares\n *    its own scope (`audience_user_id = me OR audience_organization_id IN my\n *    orgs`). RLS is the ceiling, never the view: the table carries the\n *    mandatory platform-admin read arm, so an unscoped select on an admin-lane\n *    page would hand an admin EVERY person's rows. The resolver re-checks every\n *    row against the viewer as well.\n *  - THE LIFECYCLE ({@link KindComponentOverlayLoader}) — signed out → no read,\n *    no overlay; any change of user / lane / membership clears the overlay\n *    before the next viewer's rows load; a read that lands after the viewer\n *    moved is DISCARDED; a failed read is a BOUNDED outage (finite timer-free\n *    backoff, ONE error per outage) — never a request and error storm; a\n *    forced sync during an in-flight read coalesces into one follow-up read.\n *\n * The host injects only its two reads (organizations, one filtered chunk of\n * layer rows) and its viewer snapshot. Pure TS — no React, no Supabase.\n * Plain fields, no parameter properties: consumers compile this source\n * directly and a strict host (the dashboard) sets `erasableSyntaxOnly`.\n */\n\nimport type {\n  ComponentOverlayInput,\n  JsonObject,\n  KindComponentLayerRow,\n} from \"./component-resolution.types\";\n\n/** The resolver surface the loader drives (`ComponentResolver` satisfies it). */\nexport interface OverlayTarget {\n  setOverlay(input: ComponentOverlayInput): void;\n  clearOverlay(): void;\n  /**\n   * Optional: let the resolver refuse an installed overlay whose owner is no\n   * longer the current viewer (closes the window between a user switch and the\n   * next-tick clear).\n   */\n  setOverlayViewerProbe?(probe: () => string | null): void;\n}\n\n/** ~100 uuids per GET url — a person's memberships can run to hundreds. */\nexport const OVERLAY_ORGANIZATION_CHUNK = 100;\n\n/** Timer-free backoff between retries of a FAILED read, then only `force` retries. */\nexport const OVERLAY_RETRY_DELAYS_MS: readonly number[] = [5_000, 15_000, 30_000, 60_000];\n\nexport const LAYER_COLUMNS =\n  \"id, kind, platform, role, component_key, source, is_active, config, component_source, props_transform, pinned_kind_version, updated_at, created_by, audience_user_id, audience_organization_id\";\n\n/** A `kind_component_layer` row as the database returns it (LAYER_COLUMNS). */\nexport interface LayerDbRow {\n  id: string;\n  kind: string;\n  platform: string;\n  role: string;\n  component_key: string;\n  source: string;\n  is_active: boolean;\n  config: unknown;\n  component_source: string | null;\n  props_transform: string | null;\n  pinned_kind_version: number | null;\n  updated_at: string;\n  created_by: string | null;\n  audience_user_id: string | null;\n  audience_organization_id: string | null;\n}\n\n/**\n * THE AUDIENCE PREDICATE — the PostgREST `or` filter for one chunk of the\n * viewer's organizations. Pure, so a guard test can pin it: it always names the\n * viewer, and only ever the viewer's own organizations.\n */\nexport function layerAudienceFilter(\n  userId: string,\n  organizationIds: readonly string[],\n): string {\n  const mine = `audience_user_id.eq.${userId}`;\n  if (organizationIds.length === 0) return mine;\n  return `${mine},audience_organization_id.in.(${organizationIds.join(\",\")})`;\n}\n\nfunction chunks<T>(items: readonly T[], size: number): T[][] {\n  if (items.length === 0) return [[]];\n  const out: T[][] = [];\n  for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));\n  return out;\n}\n\nfunction isJsonObject(value: unknown): value is JsonObject {\n  return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** Project a database row onto the resolver's layer row; null for an unroutable role. */\nexport function layerDbRowToLayerRow(row: LayerDbRow): KindComponentLayerRow | null {\n  if (row.role !== \"output\" && row.role !== \"input\" && row.role !== \"loading\") {\n    return null;\n  }\n  return {\n    id: row.id,\n    kind: row.kind,\n    platform: row.platform,\n    role: row.role,\n    componentKey: row.component_key,\n    source: row.source,\n    config: isJsonObject(row.config) ? row.config : {},\n    isActive: row.is_active,\n    componentSource: row.component_source,\n    propsTransform: row.props_transform,\n    pinnedKindVersion: row.pinned_kind_version,\n    updatedAt: row.updated_at,\n    createdBy: row.created_by,\n    audienceUserId: row.audience_user_id,\n    audienceOrganizationId: row.audience_organization_id,\n  };\n}\n\n/**\n * ONE scoped read of the viewer's layered rows (chunked only by url length).\n * The host supplies `readChunk(filter)`: select {@link LAYER_COLUMNS} from\n * `content_ir.kind_component_layer` where `deleted_at is null` AND the given\n * `or` filter, read to completion (never a bare capped select). The PREDICATE\n * is built here, once, for every host.\n */\nexport async function readViewerLayerRows(\n  userId: string,\n  organizationIds: readonly string[],\n  readChunk: (orFilter: string) => Promise<readonly LayerDbRow[]>,\n): Promise<KindComponentLayerRow[]> {\n  const byId = new Map<string, KindComponentLayerRow>();\n  for (const chunk of chunks(organizationIds, OVERLAY_ORGANIZATION_CHUNK)) {\n    const rows = await readChunk(layerAudienceFilter(userId, chunk));\n    for (const raw of rows) {\n      const row = layerDbRowToLayerRow(raw);\n      if (row) byId.set(row.id, row);\n    }\n  }\n  return [...byId.values()];\n}\n\n/** Who is looking, and through which lane — the overlay's identity. */\nexport interface OverlayViewer {\n  userId: string | null;\n  laneOpen: boolean;\n  /**\n   * The host's current membership state as a stable string (e.g. the sorted\n   * organization ids). A change re-reads — a view from an organization the\n   * person has left must stop rendering without a reload.\n   */\n  membershipKey?: string;\n}\n\nexport interface OverlayLoaderPorts {\n  /** The current viewer (synchronous snapshot, read fresh every call). */\n  viewer: () => OverlayViewer;\n  readOrganizationIds: () => Promise<string[]>;\n  readRows: (userId: string, organizationIds: readonly string[]) => Promise<KindComponentLayerRow[]>;\n  reportError: (message: string, error: unknown) => void;\n  /** Test seam. */\n  now?: () => number;\n  /** Test seam / host override of {@link OVERLAY_RETRY_DELAYS_MS}. */\n  retryDelaysMs?: readonly number[];\n}\n\ninterface Outage {\n  key: string;\n  failures: number;\n  retryAt: number;\n}\n\n/**\n * The lifecycle, host-free so it is testable. `sync()` is cheap when the viewer\n * is unchanged; any change of user, lane or membership clears the overlay first\n * and then loads the new viewer's rows.\n */\nexport class KindComponentOverlayLoader {\n  private readonly target: OverlayTarget;\n  private readonly ports: OverlayLoaderPorts;\n  private loadedKey: string | null = null;\n  private inFlightKey: string | null = null;\n  private inFlight: Promise<void> | null = null;\n  private rereadAfter = false;\n  /** True once the in-flight read has issued its rows query (a forced ask after that needs a follow-up). */\n  private rowsIssued = false;\n  private generation = 0;\n  private outage: Outage | null = null;\n\n  constructor(target: OverlayTarget, ports: OverlayLoaderPorts) {\n    this.target = target;\n    this.ports = ports;\n    target.setOverlayViewerProbe?.(() => ports.viewer().userId);\n  }\n\n  private static keyOf(viewer: OverlayViewer): string | null {\n    return viewer.userId\n      ? `${viewer.userId}|${viewer.laneOpen ? \"lane\" : \"user\"}|${viewer.membershipKey ?? \"\"}`\n      : null;\n  }\n\n  /** Re-read when the viewer, lane or membership changed (or `force`); no-op otherwise. */\n  sync(force = false): Promise<void> {\n    const viewer = this.ports.viewer();\n    const key = KindComponentOverlayLoader.keyOf(viewer);\n    if (key === null) {\n      // Signed out: no overlay and no read at all.\n      this.generation += 1;\n      this.loadedKey = null;\n      this.inFlightKey = null;\n      this.inFlight = null;\n      this.rereadAfter = false;\n      this.outage = null;\n      this.target.clearOverlay();\n      return Promise.resolve();\n    }\n    if (key === this.inFlightKey && this.inFlight) {\n      // ONE read per viewer at a time. A forced sync (an edit landed) asks for\n      // exactly one follow-up read instead of a parallel duplicate — and none\n      // at all when the in-flight read has not issued its rows query yet (it\n      // will see whatever changed).\n      if (force && this.rowsIssued) this.rereadAfter = true;\n      return this.inFlight;\n    }\n    if (!force) {\n      if (key === this.loadedKey) return Promise.resolve();\n      const outage = this.outage;\n      if (outage && outage.key === key) {\n        const delays = this.ports.retryDelaysMs ?? OVERLAY_RETRY_DELAYS_MS;\n        // Bounded: inside the backoff window, or past the last retry, only a\n        // forced sync (or a different viewer) asks again.\n        if (outage.failures > delays.length || this.now() < outage.retryAt) {\n          return Promise.resolve();\n        }\n      }\n    }\n    if (key !== this.loadedKey) {\n      this.loadedKey = null;\n      this.target.clearOverlay();\n    }\n    if (this.outage && this.outage.key !== key) this.outage = null;\n    const generation = ++this.generation;\n    this.inFlightKey = key;\n    this.rowsIssued = false;\n    const userId = viewer.userId as string;\n    const run = (async () => {\n      try {\n        const organizationIds = await this.ports.readOrganizationIds();\n        this.rowsIssued = true;\n        const rows = await this.ports.readRows(userId, organizationIds);\n        if (generation !== this.generation) return; // the viewer moved on\n        const now = KindComponentOverlayLoader.keyOf(this.ports.viewer());\n        if (now !== key) return;\n        this.target.setOverlay({ viewerId: userId, organizationIds, rows });\n        this.loadedKey = key;\n        this.outage = null;\n      } catch (error) {\n        if (generation !== this.generation) return;\n        const previous = this.outage && this.outage.key === key ? this.outage : null;\n        const failures = (previous?.failures ?? 0) + 1;\n        const delays = this.ports.retryDelaysMs ?? OVERLAY_RETRY_DELAYS_MS;\n        this.outage = {\n          key,\n          failures,\n          retryAt: this.now() + (delays[Math.min(failures - 1, delays.length - 1)] ?? 0),\n        };\n        // Loud, never fatal, ONCE per outage: the shared tiers keep answering,\n        // which is what the viewer saw before layers existed.\n        if (failures === 1) {\n          this.ports.reportError(\n            `[content-ir] the viewer's own / organization shape views could not be read — shared views render instead: ${\n              error instanceof Error ? error.message : String(error)\n            }`,\n            error,\n          );\n        }\n      } finally {\n        if (generation === this.generation) {\n          this.inFlightKey = null;\n          this.inFlight = null;\n          if (this.rereadAfter) {\n            this.rereadAfter = false;\n            void this.sync(true);\n          }\n        }\n      }\n    })();\n    this.inFlight = run;\n    return run;\n  }\n\n  private now(): number {\n    return (this.ports.now ?? Date.now)();\n  }\n\n  /** Test seam / sign-out hard reset. */\n  reset(): void {\n    this.generation += 1;\n    this.loadedKey = null;\n    this.inFlightKey = null;\n    this.inFlight = null;\n    this.rereadAfter = false;\n    this.outage = null;\n    this.target.clearOverlay();\n  }\n}\n\n/**\n * THE VIEWER WATCH for hosts with a push-style auth source (Supabase\n * `onAuthStateChange`): the signed-in user id, kept current by ONE lazy\n * subscription. `connect(report)` wires the host's auth source and calls\n * `report(userId | null)` on every change (and once on subscribe); the watch\n * defers `onChange` to the next tick — never call back into Supabase inside its\n * auth callback (it holds its auth lock there). Signed out / not yet told = null.\n */\nexport interface OverlayViewerWatch {\n  current(): string | null;\n  /** Idempotent; a no-op outside a browser. */\n  start(onChange: () => void): void;\n}\n\nexport function createOverlayViewerWatch(\n  connect: (report: (userId: string | null) => void) => void | Promise<void>,\n  options: { isBrowser?: () => boolean } = {},\n): OverlayViewerWatch {\n  let userId: string | null = null;\n  let installed = false;\n  const isBrowser = options.isBrowser ?? (() => typeof window !== \"undefined\");\n  return {\n    current: () => userId,\n    start(onChange) {\n      if (installed || !isBrowser()) return;\n      installed = true;\n      const report = (next: string | null) => {\n        if (next === userId) return;\n        userId = next;\n        setTimeout(onChange, 0);\n      };\n      void Promise.resolve()\n        .then(() => connect(report))\n        .catch(() => {\n          installed = false;\n        });\n    },\n  };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;A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