10 KiB
Return-from-a-year-away Audit — 2026-08-05
Scope reviewed: main (checked out), manifest, cleanup (all local + origin equivalents).
Remote: https://git.aaronic.cc/kacarmichael/StreamRecorder.git
Branch situation (read this first)
The three branches are not parallel efforts — they're one linear line of development that main never caught up to:
main (0f4a39f, 2025-07-26) ──┐ stale, single-file-era downloader only
│
manifest (718d69c, 2025-08-10) ── +restructured cmd/pkg layout, config-less
│
cleanup (7d67cec, 2025-08-11) ── +pkg/config, tests, CI, Makefile, deployment docs
manifest is literally an ancestor of cleanup (same commit 718d69c). cleanup is the most complete state that ever existed and was the last thing touched (2025-08-11) before the year gap. None of this reached main. If you pick this project back up, decide this before anything else:
- Merge
cleanup→main(recommended — it's a strict superset: config validation,pkg/nas,pkg/processing, unit tests, CI workflow,DEPLOYMENT.md/TESTING.md). Then deletemanifest(fully subsumed) and re-evaluatecleanupfor deletion once merged. - Or, if
cleanup's direction (FFmpeg concatenation, NAS-mirroring processing pipeline) is no longer where you want to go, explicitly archive it and restartmainfrom a clean design — but do this as a decision, not by default.
🔴 Critical — fix/rotate before running this again
-
Leaked NAS credentials, committed in plaintext.
pkg/config/config.go(branchcleanup) hardcodes a real default:Username: "NASAdmin", Password: "s3tkY6tzA&KN6M",This is in git history on a remote (
git.aaronic.cc) regardless of whether you later change the default. Rotate this NAS account's password now — changing the code doesn't un-leak a password that's sat in a repo for a year. Then remove the credential entirely (fail closed: requireNAS_USERNAME/NAS_PASSWORDenv vars with no default, error out if unset when transfer is enabled) rather than shipping a working default. -
Guaranteed crash: double mutex unlock in
pkg/transfer/cleanup.go. InExecuteCleanup(present onmaintoo, not justcleanup):cs.mu.Lock() ... cs.mu.Unlock() // line 72 — releases the lock ... batch := make([]string, batchSize) copy(batch, cs.pendingFiles[:batchSize]) cs.pendingFiles = cs.pendingFiles[batchSize:] // mutated WITHOUT the lock held cs.mu.Unlock() // line 79 — unlocking an already-unlocked mutexAn unlock of an unlocked
sync.Mutexis a fatal, unrecoverable runtime error (fatal error: sync: unlock of unlocked mutex) — it kills the whole process, not just a goroutine. SinceCleanup.AfterTransferdefaults totrueandRetainHours: 0(immediate eligibility), this fires the first time any file finishes transferring and cleanup runs. This is very likely why any end-to-end run with NAS transfer enabled never survived long. Fix: hold the lock for the whole slice mutation, or copy-then-release-then-mutate-under-a-second-short-lock, but don't unlock twice. -
Nil-pointer crash in
pkg/media/stream.go(VariantDownloader,mainbranch):playlist, err := LoadMediaPlaylist(variant.URL) seq := playlist.SeqNo // <-- dereferenced before the err check if err != nil { ... goto waitTick }LoadMediaPlaylistreturnsnil, erron any HTTP/parse failure, soplaylistis a typed-nil pointer here —playlist.SeqNopanics. A panic in a goroutine takes down the entire process (Go doesn't isolate goroutine panics). Practically: any single transient network hiccup on any variant's playlist fetch kills the whole download session, mid-recording. Move theerr != nilcheck above theSeqNoread.
🟠 High-priority bugs / correctness
-
PriorityQueue.Lessinpkg/transfer/queue.gosorts newest-first (pq[i].Timestamp.After(pq[j].Timestamp)), making the transfer queue LIFO. For a live-recording pipeline that keeps producing new segments, this means the oldest queued segments can be starved indefinitely as long as new ones keep arriving — the opposite of what you'd want (drain oldest first so nothing waits forever). Worth confirming this was intentional; if not, flip the comparison. -
Retry backoff runs before the first attempt, not just retries —
pkg/transfer/queue.go,processItem:for attempt := 1; attempt <= maxRetries; attempt++ { if attempt > 0 { // always true, since attempt starts at 1 ... backoff ...Every single transfer sleeps
1sbefore even trying once. Should beattempt > 1. -
pkg/constants/constants.go(main) hardcodes a live FloSports auth token directly in source (MasterURLwithtoken=...,hmac2=...). It's expired now (epoch ~2025-07), so no live exposure, but it's the same pattern as #1 — secrets/tokens don't belong in source. Worth a rule going forward: URLs/tokens come from CLI args or env, never constants. -
http.Client{}created with no timeout inpkg/media/stream.go,playlist.go, andsegment.go. A stalled TCP connection (dead CDN edge, network partition) can hang a fetch forever — nothing in the surrounding code will time it out except the 10s context wrapped specifically around segment downloads inVariantDownloader. Playlist-fetch calls (GetAllVariants,LoadMediaPlaylist) have no such wrapper. Give the shared client a saneTimeout(e.g. 15–30s) as a backstop.
🟡 Cleanup / dead weight
cmd/proc/main.gois a one-line stub (package proc) onmain— dead entry point, nofunc main(). Either finish it or delete it; right nowgo build ./...would fail on this if it were ever wired as a realmainpackage (it currently silently isn't, which is its own trap for future-you).- Built binaries committed to git (
bin/flo_download,bin/flo_download.exe, ~18MB, oncleanup/manifest). The.gitea/workflows/build.ymlalready cross-compiles and uploads artifacts — there's no reason binaries should also live in the repo/history. Remove and addbin/to.gitignore. scratch.txtis tracked despite being in.gitignore. Adding a path to.gitignoreafter it's already tracked does nothing — it's still in the repo (and it's just a raw debug log dump).git rm --cached scratch.txt..idea/*(JetBrains project files) are committed. Low stakes solo-repo, but standard practice is to gitignore the whole.idea/directory rather than cherry-pick.
🔵 Program / architecture — bigger picture
- The project's own
CLAUDE.mdstates the goal is "a listening REST API [that] take[s] in m3u8 urls, parse[s] them, and eventually send[s] to a conversion service." None of the three branches implement any HTTP server — all three are CLI-only, one-shot-per-invocation tools. This is the largest gap between stated intent and actual code. Worth deciding: is the REST-API framing still the goal, or has the project's actual direction (CLI recorder + NAS mirror + FFmpeg concat, percleanup'sCLAUDE.md) superseded it? Right now the docs and the code disagree with each other. pkg/nas/nas.go's "connection" is a Windows-only shell-out tonet use(EstablishConnection), while CI (build.yml) cross-compiles forlinux/darwin/windows. On non-Windows the UNC-path logic (\\server\share) andnet usesimply don't apply — there's no SMB client abstraction, so the Linux/macOS builds can produce a binary that can't actually do NAS transfer. If cross-platform deployment is real (not just "it happens to compile"), this needs a real cross-platform SMB/CIFS story (e.g., assume the NAS is pre-mounted by the OS and just treat it as a local path, which is actually simpler and already half-true for the Linux CIFS example inDEPLOYMENT.md).- Zero tests on
main.cleanuphas real coverage (pkg/config,pkg/utils,pkg/constants,pkg/httpClient,pkg/media/manifest,pkg/processing) plus aMakefile(test,test-coverage,lint,securityviagosec) and aTESTING.md. All of this is stuck on a branch that was never merged — it's not a "write tests" TODO so much as a "land the tests you already wrote" TODO. - CI never actually runs tests, lint, or
gosecdespite theMakefiledefining a fullcitarget (fmt tidy lint security test build)..gitea/workflows/build.ymlonly cross-compiles. Wiremake ci(or its steps) into the pipeline so a broken build/test doesn't silently ship a binary artifact. - Unbounded
seenmap inVariantDownloader(pkg/media/stream.go) grows for the lifetime of a variant's polling loop with no eviction — fine for a few-hour event, worth a note if this is ever meant to run continuously/24-7.
🟢 Deployment
DEPLOYMENT.md(oncleanup) documents Docker/Compose/Kubernetes deployment in detail, but there's no actualDockerfilecommitted anywhere in the repo — it's a doc-only example. If containerized deployment is the real target, commit the Dockerfile and at least smoke-test the build.- No secrets-management story beyond "use env vars" — fine for a home lab, but the doc's own "Security" section says "use secret management systems," which isn't backed by anything concrete (no
.env.example, no sealed-secrets/vault reference). Given finding #1, this is worth actually doing, not just documenting. - Health checks, metrics/log shipping are listed as "considerations" in
DEPLOYMENT.mdbut nothing is implemented — the app is a fire-and-forget CLI process withlog.Printfto stdout only. If this runs unattended (e.g., in a container watching for the next event), you have no way to know it's alive short of watching logs.
Suggested order of attack
- Rotate the NAS credential (#1) — this is time-sensitive regardless of anything else.
- Fix the two crash bugs (#2, #3) — nothing else is worth doing until a full recording session can survive.
- Decide the branch-merge question and land
cleanup→main(or consciously don't). - Wire CI to actually test/lint (#15) so regressions get caught going forward.
- Then tackle the architecture question (#12: REST API vs. CLI-recorder-as-is) before investing more in either direction.