Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ internal/relpath/ library-relative path rules shared by catalog and auth: Cl
internal/catalog/ libraries, access grants, books, FTS search, listening state (the data layer)
internal/library/ filesystem view (fsview.go: SafeJoin, SafeJoinListed for the stream, /fs and a book read on demand (each name looked for in its folder's listing first, see Path spelling), and ContentPath/ContentJoin, the one hidden-segment rule) + background scanner (scanner.go: incl. IndexMoved and the .audiosilo/ walk; scanread.go: a scan reads several files at once, `scan.concurrency`, default one per CPU up to 8, and writes the index alone in discovery order, so the result is a serial scan's, a few books a transaction: `catalog.UpsertBooks`, `writeBatch`, each book under its own savepoint); attachments.go (a book's Bridge attachments: signatures, RefreshAttachments); givenup.go (givenUp: a file beside a book's audio whose bounded look was given up on keeps the book as stored, its problem recorded); ebook.go (BookEbook, the Bridge's own .epub rule, for the estimate and, through the one rule function ebookCandidate fed by the walk, books.ebook_path, the reader's ebook; a readable one only: a zip whose directory lists META-INF/container.xml, as the Bridge reads it; OpenEbook, every open of one: a regular file inside the library, checked before it is opened and the same file once open; OpenEbookBounded, the reader's, a bounded call)
internal/metadata/ dhowden/tag + ffprobe extraction (fastprobe*.go: the in-process probe, ffprobe's answer read in Go by the configured ffprobe's release's rules, but a header-less VBR MP3's frames counted where ffprobe estimates, ffprobe for a file it is unsure of, see In-process probe; probeview.go: ProbeView, the comparison cmd/probediff and the fixture tests make; bounded.go: Bounded, every other look at a library file a share that stopped answering would hold (a stat, a listing, an open and its reads) under a scan read's bounds and per-mount cap, given up on as GaveUp (see In-process probe), TransientFault (the share-fault rule's transient list, see Share faults), and NamesListed; openbelow.go: Below, a request's open through an os.Root at the library's root (OpenRegularBelow, ReadDirBelow); belowcache.go: BelowFolder, the scan's (OpenBelow, StatBelow, LstatBelow), through the file's folder kept open a moment, one openat a file; toolinput.go: ToolInput (bounded, one entry point), ffprobe and ffmpeg handed the file opened so, never its path (see Path spelling, links out of the root), and InputFormats/InputFormatArgs, the one demuxer list every tool run on a library file or an episode takes; dirnames.go: DirNames, the folder listings the spelling checks read, kept 3 s (see Path spelling); tagreader.go: ReadTags, the tag reads outside Extract (media.EmbeddedCoverBelow; Extract reads through the probe's block cache): dhowden reads an ID3v2 tag through a buffer up to the tag's end, not a byte per read system call; a narrator tag beats composer in both passes; mp4narrator.go reads the iTunes \xa9nrt item, which neither reads, with a bounded box walk; a series tag ending in a marked position, "Discworld, book #40", is the series and that position: seriestag.go SplitSeriesTag; a `series-part` tag "1-3" is a range: seriesrange.go, ParseSeriesRange, the one grammar of a range position, and ParseSeriesPosition, a number or a range; incl. ReleaseDate: a date tag as YYYY[-MM[-DD]], stored as books.released, never as published); DeriveFromPath (structural path parsing, the scan's baseline: the folder holding the book is the series and the one above it the author, but a lone folder is the author; a leaf named `Author; Series; Book NN[; Title]` states the series and position, a range or none, `@rev` 3); layout.go: ReadPathLayout (author/series/book LAYOUT, the match's path facts) and FromPathLayout (a path-first library's values); absfile.go: ParseABSFile/ReadABSFile (an Audiobookshelf metadata.json, see Metadata overrides); attachments.go: AttachmentsDir `.audiosilo`, Read/ParseCharacters, Recaps, Description and Provenance (the Bridge's generated files, checked against audiosilo-meta's formats; see Bridge attachments); chapterlist.go: Read/ParseChapterList (the Bridge's `chapters.json`, chapters found in the narration; see Generated chapters); foldercode.go: FolderCodePosition (a position or range from the code leading a folder name, "DH06 - ...", "LAM05-06", its letters the series' initials; read only by the Bridge's books listing); discfolder.go: IsDiscFolder ("CD 2", "Disc 3": the scan's join rule, and the Audible backup destination check); titlepos.go: PositionInTitle (a series position read from a title that is the series' name then a number, "He Who Fights with Monsters 4: ..."; narrow: set off by a space or comma, 1-3 digits, then the end or a separator, never a range); seriestitle.go: TitleNotSeries (an album tag naming only the book's series gives way to the title tag or the path's title; LeafSeries reads an `Author; Series; Book NN; Title` leaf (a `Leaf`: series, title part, position or range) and PathLeafSeries a book's own; MaybeSeriesTitle, the scan's re-read test for a snapshot before `@rev` 2; Metadata.PartsTitle: a book of several files takes the album over its first file's title tag, unless its folder or its last file's tag says the tag is the book's (PartNamed: when that file is worth reading), `@rev` 5; see Metadata overrides in CONVENTIONS.md)
internal/media/ Range streaming, download, embedded cover extraction, transcoding (the file opened through the library root and handed over as a descriptor: fd:, else as metadata.ToolInput hands it, /dev/fd/3 through a link on Unix, a re-checked, held path on Windows, for an ffmpeg older than 6.1, a cached copy's run too; pipe:0 for a podcast episode on an older ffmpeg; every input whose demuxer ffmpeg guesses an audio container only, metadata.InputFormatArgs); filecache.go: FileCache, a cache of copies ffmpeg makes from a cacheSpec (LRU by mtime, single-flight, .part + rename, disk guard, refusals remembered for an hour; Open/Status/Queue/WarmAll); remux.go: NewRemuxer, the MP3-in-MKA remux spec (<data>/cache/remux, 8 GiB, warmed by /item and /chapters, a cold stream transcoded after 2 s (a download, or with every transcode slot busy, after up to 45 s), own ETag; see Recognized audio); rendition.go: NewRenditionCache, the watch rendition spec (<data>/cache/renditions/watch, AAC-LC mono 48 kbps, 10 GiB; see Watch renditions)
internal/media/ Range streaming, download, embedded cover extraction, transcoding (the file opened through the library root and handed over as a descriptor: fd:, else as metadata.ToolInput hands it, /dev/fd/3 through a link on Unix, a re-checked, held path on Windows, for an ffmpeg older than 6.1, a cached copy's run too; pipe:0 for a podcast episode on an older ffmpeg; every input whose demuxer ffmpeg guesses an audio container only, metadata.InputFormatArgs); filecache.go: FileCache, a cache of copies ffmpeg makes from a cacheSpec (LRU by mtime, single-flight, .part + rename, disk guard, refusals remembered for an hour; Open/Status/Queue/WarmAll); remux.go: NewRemuxer, the MP3-in-MKA remux spec (<data>/cache/remux, 8 GiB, warmed by /item and /chapters, a cold stream transcoded after 2 s (a download, or with every transcode slot busy, after up to 45 s), own ETag; see Recognized audio); rendition.go: NewRenditionCache, the watch rendition spec (<data>/cache/renditions/watch, AAC-LC mono 48 kbps, 10 GiB; see Watch renditions); remoteart.go: ArtFetcher, the one remote art fetcher (community covers, podcast artwork) over a caller's netguard transport: no user info, <= 3 redirects without a downgrade, a 200 only, a byte cap
internal/names/ reading people in an Author/Narrator credit: Split (the deliberately shy co-credit rule), Reversed ("Surname, Given"), SortKey (surname first; the catalog registers it as the SQL function name_sort for the admin list's surname sort)
internal/meta/ Phase 1.5 community metadata lookup: HTTP client + Service (asin/isbn, or the book's recorded match in book_matches via EnrichMatch when it names another work or those find nothing -> composed enrichment envelope; a LibriVox recording's `librivox` id and links) with a bounded TTL cache and its persistent SQLite level (store.go); the /meta bundle's previous works and spoiler gating (bundle.go); the admin console's match (match.go: metaserve works/match over tag + path facts, metadata.ReadPathLayout; works/search fallback for an older metaserve); a bulk run's spacing of its requests (pacer.go: `Pacer`, `WithPacer`, the remote leg's `pacedTransport`); a call's time budget (budget.go: `withBudget`, which a bulk run's Retry-After waits don't count against, and `WithSharedBudget` for a request that composes twice); community cover fetches (cover.go: public addresses only); owned books' work ids for the Series cards (workids.go); placing the caller's books on rails and the next rail entry (local.go); which of a work's series a book is in (seriesrules.go: the series rules below); a work's positions on this book's chapters (positionscale.go: `OnRecording`); generated content laid beside the community work (generated.go: `Answer`, `Unmatched`, `MetaGenerated`, `MetaGeneratedDescription`); cache-only reads for the Bridge's estimate and book facts (cachedenrich.go: `cachedAnswerOf`, the newer of the cache and the upcoming job's resolution; `Coverages`, `CachedWork`, a `Coverage` per book whose `Description` is the community work's `community_description`); the console's Add from LibriVox reads (librivox.go: `LibrivoxSearch`, `LibrivoxWork`, `LibrivoxRecordingOf`)
internal/chapteralign/ fits a community recording's chapter list onto a book's own audio (pure, no I/O): anchors by title + time, places the rest in proportion, snaps each to its pause (an injected Prober); classifies fill/titles/refine/restructure/same or why not (length_mismatch, structure_mismatch, crosses_files). testdata/mythos is a real 34-vs-174-chapter golden case
Expand All @@ -150,8 +150,9 @@ internal/backup/ database backups: VACUUM INTO the backups folder on a sche
internal/jsonfile/ the small JSON files beside the database (backup's restore marker/result, the mirror's state.json): Write is owner-only, temp file synced then renamed (all or nothing); Read[T] is nil without a file
internal/bridge/ the Bridge's side on the server (BRIDGE-PLAN.md): its last heartbeat (status.go: validation, the 2-minute online window, features, the lenient `estimates`, Writable, CanContribute: the `setup` block's, else the estimates'; setup.go: the lenient, bounded onboarding checklist and the reply's `accepts`) and the job queue (jobs.go: kinds the server can check (`bridge.verify`, `sidecars.generate`, `sidecars.describe`, `chapters.detect`, Phase 2b's `sidecars.contribute` and `meta.correct`, contribute.go: their strict params, `ModuleFor`, and Phase 3c's `readalong.align`, Phase 4a's `audible.poll`, 4b's `audible.import` and 4c's `audible.sync` in audible.go, LibriVox L6's `librivox.fetch` in librivox.go), dedupe, priority claim with a lease (a queued job whose managed module is off held: `ModuleOn`), long-poll wake, lease expiry, held updates and parks, cooperative cancel, `OnTransition` / `Job.Notable`); estimate.go (EstimateSidecars: a job's cost from the heartbeat's figures); priority.go (the job priority bands every queue uses); pairing and the bridge token are auth's (auth/bridge.go)
internal/podcast/ podcast feed.json v1 reader and URL helpers (pure format in feed/), poll/fetch/retention scheduler, bounded on-demand media waits and scoped one-ahead prefetch; catalog/podcasts.go and podcast_{fetch,retention,move}.go hold the generation index, identity-bound status, follows, durable policies, aggregate checks and the state move of a show folder renamed by hand; library/podcast_media.go opens committed media
internal/podcast/ (2c-3) follow.go: Follower, follow by URL for the single follow and OPML rows; opmlimport.go (rows, the five-new-per-upload wave); export.go (BuildExport); discovery/ (iTunes + Podcast Index search, the artwork proxy, caches/quotas/cooldown, the build-tagged test origin); opml/ (the bounded strict OPML parser and the export writer); quota/ (token buckets with a bounded key map, slots)
internal/netguard/ the guarded dialer: PublicAddr, Control/Dialer check the address actually dialled, Downgrade refuses an https-to-http redirect (meta covers, podcast discovery)
internal/podcast/ (2c-3) follow.go: Follower, follow by URL for the single follow and OPML rows; opmlimport.go (rows, the five-new-per-upload wave); export.go (BuildExport); discovery/ (iTunes + Podcast Index search, the artwork proxy, caches/quotas/cooldown, the build-tagged test origin); opml/ (the bounded strict OPML parser and the export writer)
internal/netguard/ the guarded dialer: PublicAddr, Control/Dialer/Transport check the address actually dialled (Transport: no proxy, MaxHeaderBytes of headers), Downgrade refuses an https-to-http redirect (meta covers, podcast discovery)
internal/quota/ the one token-bucket type: PerSecond (the API's request buckets) and PerMinute (podcast discovery and OPML, a bounded key map), plus Slots
internal/oidc/ Sign in with OpenID Connect (server#235), pure (no DB, no handlers): Provider (go-oidc + x/oauth2: lazy discovery with backoff, asymmetric algs only, PKCE S256, nonce/aud/azp/iat checks, userinfo for missing claims (its failure leaves the ID token's), a reachability probe at /start and the status, one 20 s CallBudget per use), the sealed flow cookie (Sealer, Replay), Claims and Decide (link, create, pending or refuse); oidctest/ is the fake IdP for tests. Storage: auth/identities.go (OIDCSignIn in one durable tx, pending sign-ins, identities); routes: api/handlers_oidc.go
internal/modules/ managed modules (Bridge Phase 2a): Module (id = capability + config key, RequiresBridge, Routes, Start), Registrar, Deps, Validate, BridgeState/Active (the capability rule), Runner (each module's Start while on); modules/builtin is the registry (contributions: no routes of its own, its actions are Bridge jobs gated by `bridge.ModuleFor`; podcasts; audible)
internal/audible/ the audible module's Start (Bridge Phase 4a): RunScheduler queues each due account's `audible.poll` while a Bridge offers it; see Audible accounts in CONVENTIONS.md; imports.go (Phase 4b): Queues, a title's Back up, Back up everything and AfterPoll's policy backups (`audible.import`); see Audible backups; Phase 4c: the scheduler queues each synced account's `audible.sync` every 15 min (`queueSyncs`); see Audible sync
Expand Down
Loading
Loading