/** * Composite-key helpers for daemon registries. * * Every daemon-side map keyed on "a photon" in a multi-PHOTON_DIR world needs * to be keyed on (photon, base) instead — otherwise two workspaces hosting * photons with the same name clobber each other. The schedule regression * cascade that came out of the v1.22.1→main post-release review traced * directly to photon-name-only keys in scattered Maps. This * module centralizes every key producer the daemon uses so call sites can't * drift apart. * * Keep this module pure (no daemon side-effects, no cross-module state). * It's safe to import from tests without starting the daemon. */ /** * Branded key types. `ScopedKey<'...'>` is structurally a string, but * TypeScript refuses to assign a plain `string` to it. That means any * `Map, V>` can ONLY be indexed by the result of * `declaredKey(...)`. Bare-string lookups — the cause of the whole * multi-base cascade — stop compiling. * * The brand is erased at runtime; this is purely a compile-time guardrail. */ declare const __brand: unique symbol; export type ScopedKey = string & { readonly [__brand]: Tag; }; export type ScheduleKey = ScopedKey<'schedule'>; export type WebhookRouteKey = ScopedKey<'webhook'>; export type LocationKey = ScopedKey<'location'>; export type PhotonCompositeKey = ScopedKey<'photon'>; /** * Coerce a raw string to a ScheduleKey at a trust boundary (IPC protocol * input, persisted file read, etc.). The boundary is where you explicitly * accept that TypeScript can't verify the value's shape. Use sparingly — * prefer producing keys through declaredKey() when the photon/method/base * are known at compile time. */ export declare function asScheduleKey(raw: string): ScheduleKey; export declare function asWebhookRouteKey(raw: string): WebhookRouteKey; export declare function asLocationKey(raw: string): LocationKey; /** * Composite cache/session key: `` for the default base, else * `:` where hash8 is sha256(baseDir) truncated. Preserves * legacy behavior when the workingDir matches the supplied default base, * so single-base deployments keep their existing key shape. */ export declare function compositeKey(photonName: string, workingDir: string | undefined, defaultBase: string): PhotonCompositeKey; /** * Inverse of compositeKey: recover the photon name. Photon names never * contain colons, so the first segment is always the name regardless of * whether the key carries a `:hash8` qualifier. */ export declare function photonFromCompositeKey(key: string): string; /** * Identity key for declared schedules / scheduled-job timers: * `:::`. `` is the absolute * path of the owning PHOTON_DIR, `-` when no base is available (legacy * callers predating multi-base). * * Unlike compositeKey, this ALWAYS includes the base segment. The * scheduled-job maps use the base segment as discriminator so same-named * photon methods in different bases don't collide. */ export declare function declaredKey(photon: string, method: string, workingDir?: string): ScheduleKey; /** * Identity key for the webhookRoutes map: `::`. * Webhook lookups from the HTTP handler pass only a photon name (they don't * know the base), so callers that need cross-base search use * `findMatching(map, photon)` over the values instead of a direct .get(). */ export declare function webhookKey(photon: string, workingDir?: string): WebhookRouteKey; /** * Identity key for proactivePhotonLocations — same shape as webhookKey, * intentionally kept separate because the two maps hold different value * types and could drift in the future. */ export declare function locationKey(photon: string, workingDir?: string): LocationKey; /** * Narrow signature for entries that carry a `photon` field — every value * stored in a base-scoped map must expose it so cross-base search works. */ export interface PhotonScoped { photon: string; workingDir?: string; } /** * Iterate a base-scoped map and return every entry whose photon matches. * Used by callers that only have a photon name in scope (HTTP webhook * handler, IPC clients that don't pre-know the base). */ export declare function findByPhoton(map: Map, V> | Map, photon: string): V[]; export {}; //# sourceMappingURL=registry-keys.d.ts.map