// favela post SCOPES — the POSSE scope selector (DESIGN §3), the single source of truth shared by the
// Writer (what collection to sign into), the Appview (what collections to fold), and the web shell
// (the compose toggle). Keeping the scope->collection map in ONE place is what makes "local-only" a
// pure data decision instead of three stringly-typed constants drifting apart.
//
// The whole mechanism of step 1: a post's atproto `$type` MUST equal its collection NSID, and bsky's
// AppView only indexes `app.bsky.*` lexicons. So a record in `net.favela.local.post` is still signed by
// the hpp into the DID's repo and rides the firehose — but bsky silently ignores it (unknown lexicon),
// while favela folds it into the local timeline. No bridge change is needed; "local-only" falls out of
// which collection we write + which collections favela indexes.
//
// HONESTY (DESIGN §10.2): local-only means UNINDEXED BY BSKY, not UNREPLICATED. If the DID is fronted +
// crawled, the record BYTES still reach bsky's relay; they just never render there. It is "community,
// not secret" until encryption lands — surface that in the UI, never promise erasure.
// scope -> the atproto collection NSID (== the record `$type`) it writes into.
export const SCOPE_COLLECTION = {
public: 'app.bsky.feed.post', // fronted to bsky by the bridge (POSSE syndicate arm)
local: 'net.favela.local.post' // favela-only; bridge never projects it (not app.bsky.*)
}
export const DEFAULT_SCOPE = 'public'
// Every collection favela's appview folds into the timeline (both scopes render locally).
export const POST_COLLECTIONS = Object.values(SCOPE_COLLECTION)
// scope name -> collection NSID; throws on an unknown scope (fail loud, no silent public fallback).
export function collectionForScope (scope = DEFAULT_SCOPE) {
const c = SCOPE_COLLECTION[scope]
if (!c) throw new Error(`unknown scope '${scope}' (expected one of: ${Object.keys(SCOPE_COLLECTION).join(', ')})`)
return c
}
// Reverse map: a record's collection/$type -> its scope name (for render badges). Unknown -> null.
export function scopeForCollection (collection) {
for (const [scope, nsid] of Object.entries(SCOPE_COLLECTION)) if (nsid === collection) return scope
return null
}