Repository navigation
Description
What happened
Scope, for
/issue-to-pr:
- Type: bug, infrastructure →
fix/branch prefix.- Client surface: none. No API, auth, playback, session, library, or metadata behavior
changes; no coordinatedsilo-apple/silo-androidfollow-up.- Linked scope: not tied to a v1 capability epic — this is repo infrastructure, not a
user-facing capability. Related to proposal: add a test, race and goroutine leak CI lane #385, which proposed the CI lane this issue's evidence
bears on; see "Prior art" immediately below. Happy to file it under an epic instead if you'd
rather it were tracked there.- Sign-off required before implementation. This issue asks for a CI change and an
architectural decision about test isolation, which are two ofissue-to-pr's own stop-and-ask
triggers ("a test/CI change would be needed to pass — get sign-off, don't do it silently"
and "the change balloons into something large or architectural — propose a plan first"). An
agent should stop here and get a decision rather than start. A phased plan is in
Technical notes.
Prior art: this overlaps #385, and I'd rather build on it than re-file it. #385 (2026-07-11) already noted that "DB tests actually skip on a missing SILO_TEST_DATABASE_URL", and listed "a Postgres service container to unlock the 28 self skipping DB test files" among its optional extras. I found it after doing this work, and it deserves the credit for spotting the gap first.
Two things have changed since, which is why I think this is still worth its own report:
- Its premise has partly been overtaken. proposal: add a test, race and goroutine leak CI lane #385 was written when "nothing runs on pull requests at all".
.github/workflows/ci.ymllanded on 2026-07-30 indc4b9a09(part of feat(settings): add the cross-platform settings contract and its manifest #479, the settings contract) — so the test lane now exists. The Postgres container did not come with it. - Unlocking these tests is not just provisioning. proposal: add a test, race and goroutine leak CI lane #385 reasonably assumed supplying a database would let them run. It does not: 7 fail deterministically, 2 packages are flaky, and one failure is a production defect rather than test rot. That's what this issue documents, and it changes the "optional extra" framing — the extra has to happen and it uncovers work.
The count has also grown: 28 self-skipping DB test files then, 48 now.
I'm not claiming the implementation. #385's author offered to do this work and should keep it if they want it; treat this as evidence for that effort rather than competition with it.
.github/workflows/ci.yml provisions no PostgreSQL service and never sets SILO_TEST_DATABASE_URL. Every DB-backed test therefore hits its t.Skip and is silently discarded — go test prints nothing for a skip without -v, so make test-go reports a clean green while 171 tests never execute.
Running the suite verbosely: 8,779 tests pass, 173 skip, and 171 of those 173 skips are the missing database.
The tests are not merely unrun. They have rotted, and the rot is invisible:
- 7 tests across 4 packages fail deterministically when a database is present — verified with
-p 1, and separately against a freshly-created, freshly-migrated database, so this is neither concurrent interference nor accumulated pollution of a long-lived database. - 2 packages are reproducibly flaky (
internal/markers,internal/recommendations) across 5 identical full runs, both database-related. Formarkersthe cause is pinned: a test rolls the shared schema down mid-run. - One failure is a genuine product bug in restart-resilient playback, not test cleanup.
The clearest example of the rot: internal/notifications/push_devices_test.go hand-writes its own CREATE TEMP TABLE push_devices, shadowing the real table. The real schema gained fcm_token_ciphertext / fcm_token_hash on 2026-07-14 in 20260714160000_push_devices_android.sql (#409, Android FCM push). The test's column list was never updated, so production code selecting those columns errors against the test's table. That test has been broken for about three and a half weeks with nothing to surface it. Three other test files use the same hand-written-schema pattern and carry identical drift risk: internal/notifications/operational_dispatch_test.go, internal/historyimport/plex_watchlist_test.go, internal/api/handlers/notifications_apple_display_test.go.
CLAUDE.md says a Go test that cannot pass yet carries a t.Skip and its reason in its own source — which reads as intent that these should run given the right environment. Right now nothing provides that environment, in CI or in the documented local workflow.
Steps to reproduce
Commands assume the repository root is the cwd.
-
Confirm CI provisions no database:
grep -nE "services:|postgres|SILO_TEST_DATABASE_URL|DATABASE_URL" .github/workflows/ci.yml -
Create the embedded-frontend stub. The Go binary embeds
web/dist, so anygo build,
go run, orgo testfails without it — including the migration step below:make embed-stub
-
Start a PostgreSQL with the extensions the migrations require (
vector,citext,pg_trgm—
stockpostgres:18is not sufficient), and wait for it to accept connections:docker rm -f silo-test-pg 2>/dev/null docker run -d --name silo-test-pg \ -e POSTGRES_USER=test -e POSTGRES_PASSWORD=test -e POSTGRES_DB=test \ -p 55432:5432 pgvector/pgvector:pg18 until docker exec silo-test-pg pg_isready -U test >/dev/null 2>&1; do sleep 2; done
-
Create a throwaway env file.
.env.testmatches the existing.env.*gitignore rule, so it
will not dirty the checkout.SECRET_KEYmust be at least 32 characters
(internal/config/bootstrap.go:13) or the binary refuses to start:cat > .env.test <<'EOF' DATABASE_URL=postgres://test:test@localhost:55432/test?sslmode=disable SECRET_KEY=test-only-not-a-real-secret-0000000000000000 EOF
-
Apply migrations:
go run ./cmd/silo/ --env .env.test --migrate-only
-
Run the suite the way CI does, then again with a database:
export DSN="postgres://test:test@localhost:55432/test?sslmode=disable" go test ./... -count=1 # CI configuration: green SILO_TEST_DATABASE_URL="$DSN" go test ./... -count=1 # with a database: fails
-
Re-run the failing packages with
-p 1(one package at a time, no cross-package
parallelism) to separate deterministic failures from shared-database interference:SILO_TEST_DATABASE_URL="$DSN" go test -p 1 -count=1 \ ./internal/auth ./internal/catalog ./internal/jellycompat ./internal/notifications \ ./internal/markers ./internal/recommendations
The first four fail deterministically;
markersandrecommendationspass, which is what
separates the two categories.
Expected behavior
Either CI provides a PostgreSQL service so DB-backed tests actually run, or — if excluding them is deliberate — that decision is written down somewhere a contributor will find it, so nobody assumes a green make test means the DB paths are covered.
Given CLAUDE.md's stance on t.Skip, I read the current state as unintended rather than a deliberate exclusion.
Acceptance criteria — what "done" means, in the order the work has to happen:
- The 7 deterministic failures pass against a migrated database (
internal/auth×1,internal/catalog×1,internal/jellycompat×2,internal/notifications×3). -
internal/markersandinternal/recommendationspass across 5 consecutive full runs at default parallelism. - Test fixtures no longer hand-write schemas that duplicate migrations (4 files, listed above).
- CI provisions PostgreSQL with the
vector,citext, andpg_trgmextensions, applies migrations, and setsSILO_TEST_DATABASE_URL. - A newly-broken DB-backed test fails CI. Verifiable by temporarily breaking one and confirming red.
- Skipped-test count in the CI configuration drops from 171 to ~0 for database reasons.
The last two are the ones that matter: without them the gate can pass while still proving nothing.
internal/scanner is deliberately not a criterion — see the separate note below; its flake has nothing to do with the database.
Silo version / commit
Repo main @ fe11b260. No tagged releases exist.
Deployment
Local dev build
Clients affected
- Other/not client-specific
Relevant logs
Blocks below marked [raw] are verbatim command output. Blocks marked [derived] are counts, tables, or comparisons I computed from raw logs — go test does not print them in that form.
[raw] CI provisions no database — the grep returns nothing:
$ grep -nE "services:|postgres|SILO_TEST_DATABASE_URL|DATABASE_URL" .github/workflows/ci.yml
$ echo $?
1[raw] What actually gets skipped, from a verbose run in the CI configuration:
$ go test ./... -count=1 -v > verbose.log 2>&1
$ grep -c '^\s*--- PASS' verbose.log
8779
$ grep -c '^\s*--- SKIP' verbose.log
173
$ grep -B1 '^\s*--- SKIP' verbose.log | grep -oE '[A-Za-z0-9_]+_test\.go:[0-9]+: .*' | sed 's/.*go:[0-9]*: //' | cut -c1-70 | sort | uniq -c | sort -rn
166 SILO_TEST_DATABASE_URL is not set
2 set SILO_TEST_DATABASE_URL to run DB-backed push device repository tes
1 set SILO_TEST_DATABASE_URL to run DB-backed unmatched items handler te
1 set SILO_TEST_DATABASE_URL to run DB-backed operational push dispatch
1 set SILO_TEST_DATABASE_URL to run DB-backed notification display handl
1 specifies unimplemented v3 planner behavior; see the comment in the ha171 of 173 skips are the missing database. Of the other 2, one is the v3-planner test above; the remaining skip is a subtest (TestRegistryDefaultsMatchTheContract/subtitle_appearance) that records no reason line, which is why the histogram sums to 172.
[derived] Package totals, counted from the run output. Note grep -c '^FAIL' over-counts, because go test also emits a bare FAIL per failing binary plus a final summary line; these use grep -cP '^FAIL\t':
| packages ok | packages failing | |
|---|---|---|
| CI configuration, no database | 118 | 0 |
| with a database | 113 | 5 |
The 5 are internal/auth, internal/catalog, internal/jellycompat, internal/notifications, and one of the two flaky packages, which varies by run.
[raw, excerpt] Failing packages re-run serially with -p 1. Failure-detail lines and the package's unrelated log output are elided for length; the pass/fail lines are verbatim and in the order printed:
--- FAIL: TestUserRepositoryUpdateAccessGroupIDDB (0.05s)
FAIL github.com/Silo-Server/silo-server/internal/auth 0.386s
--- FAIL: TestEpisodeSearchPostgresAndDocumentSource (0.09s)
FAIL github.com/Silo-Server/silo-server/internal/catalog 2.743s
--- FAIL: TestDurableCompatPlaybackStoreRevalidatesUnstartedNegotiationAcrossInstances (0.02s)
--- FAIL: TestDurableCompatPlaybackStorePutNegotiatedReplacesAcrossInstances (0.02s)
FAIL github.com/Silo-Server/silo-server/internal/jellycompat 2.772s
--- FAIL: TestDispatchOperationalEnqueuesApplePushAttempts (0.03s)
--- FAIL: TestPushDeviceRepositoryUpsertApplePreservesStableIDs (0.02s)
--- FAIL: TestPushDeviceRepositoryUpsertApplePurgesOtherProfiles (0.02s)
FAIL github.com/Silo-Server/silo-server/internal/notifications 0.212s
ok github.com/Silo-Server/silo-server/internal/markers 0.341s
ok github.com/Silo-Server/silo-server/internal/recommendations 0.278sThese 7 also fail identically against a database created and migrated from scratch immediately beforehand, so they are not an artifact of a polluted long-lived test database.
[raw] Three of the four distinct failure modes. The fourth, internal/catalog, is not yet diagnosed — it reproduces reliably (search_episode_db_test.go:102: episode document unexpectedly has vectors), including on a virgin database, but I have not established whether it is test rot or a production defect:
--- FAIL: TestUserRepositoryUpdateAccessGroupIDDB (0.07s)
repository_access_group_test.go:23: GetByID() before update error: scanning user: can't scan into dest[1] (col: email): cannot scan NULL into *string
2026/08/08 23:07:13 WARN persist negotiated compat playback session failed component=jellycompat error="ERROR: invalid byte sequence for encoding \"UTF8\": 0x00 (SQLSTATE 22021)" play_session_id=compat-negotiated-first-1786248433117847202
--- FAIL: TestDurableCompatPlaybackStorePutNegotiatedReplacesAcrossInstances (0.01s)
playback_sessions_postgres_test.go:156: replacement negotiation was not durable
--- FAIL: TestPushDeviceRepositoryUpsertApplePreservesStableIDs (0.01s)
push_devices_test.go:348: first upsert: select push device: ERROR: column "fcm_token_ciphertext" does not exist (SQLSTATE 42703)[derived] Flakiness. Five consecutive invocations of the same command (SILO_TEST_DATABASE_URL="$DSN" go test ./... -count=1) against the same database; I collected the failing-package list from each run's output:
| package | run 1 | run 2 | run 3 | run 4 | run 5 |
|---|---|---|---|---|---|
| auth, catalog, jellycompat, notifications | FAIL | FAIL | FAIL | FAIL | FAIL |
internal/markers |
– | – | FAIL | FAIL | – |
internal/recommendations |
FAIL | – | FAIL | – | FAIL |
The markers mechanism is pinned. internal/database/migrate_downto_test.go:60 calls MigrateDownTo(ctx, pool, migrations.FS, "sql", 20260728132326) against the shared database. That rolls public back past 20260807140637_settle_marker_contribution_conflicts.sql, which adds marker_contributions.claim_active — and the test never migrates back up, so the schema stays rolled back for the rest of the run. Anything querying that column afterwards gets SQLSTATE 42703.
Corroborating: with a database attached, 3 tests skip with marker contribution claim migration has not been applied, a reason that never fires without one.
A targeted two-package run reproduces it, and is far cheaper in wall clock (~30s for 18 attempts versus ~230s for 2.5 full runs) even though it is less likely per attempt — 2 of 18:
$ SILO_TEST_DATABASE_URL="$DSN" go test -count=1 ./internal/database ./internal/markers
--- FAIL: TestContributionStoreAllowsOnlyOneConcurrentStaleTakeover (0.09s)
contribution_repo_test.go:168: first Claim = ({ID: Token:}, false, find marker contribution claim: ERROR: column "claim_active" does not exist (SQLSTATE 42703)), want claimedinternal/recommendations fails differently (embed_all_test.go:188: EmbedAll re-embedded 3 up-to-date items, want 0) and I have not pinned it down.
[derived] Coverage. Methodology caveat: this is go test ./... -coverprofile without -coverpkg, so each package is credited only for its own tests and cross-package integration coverage is not counted — treat these as a floor, and the delta as the more meaningful figure. Totals are the last line of go tool cover -func:
| configuration | total statement coverage |
|---|---|
| CI configuration, no database | 37.8–37.9% |
| with a database | 42.3% |
The baseline varies by ~0.1pt between runs, which is itself a symptom — at least one package (internal/scanner, below) does not execute deterministically.
AI involvement in this report
AI-generated, human verified the repro
AI tool + model
Claude Code / claude-opus-5
Confirmations
- I reproduced this myself on a real checkout
- Logs above are raw copy-paste, not AI-summarized
Technical notes
The flakiness has to be fixed before the gate lands, not after. Adding a service container and setting the env var, with nothing else, buys intermittently red CI on a repo merging several PRs a day — worse than the current silent skip, and the kind of change that gets reverted. Suggested order:
- Fix the 7 deterministic failures. Six are mechanical;
jellycompatis not (see below). - Give DB-backed tests isolation — a database per test binary. A schema-per-binary scheme with
search_pathlooks cheaper but does not work here: 162 of 305 files inmigrations/sql/arepublic.-qualified — 418 literalCREATE TABLE public./ALTER TABLE public.statements, or 571 countingALTER TABLE ONLY public.andIF [NOT] EXISTSvariants — so Goose writes intopublicregardless ofsearch_pathand every binary silently collapses back onto one shared schema. - Only then add the CI gate.
Suggested CI shape. A separate job rather than extending the existing Go job, so the added latency on a PR's critical path is zero — jobs run concurrently, and standard runners are free for public repos. The service container must be pgvector/pgvector:pg18 or equivalent.
Measured cost, six paired full runs on one machine, summing the per-package durations go test reports:
| no database | with database | |
|---|---|---|
| range | 135.7–136.0s | 156.7–161.8s |
That is +15% to +19%, mean ≈ +17%. Two caveats: wall clock for a full go test ./... is ~92s either way on this machine, so the per-package sum is emphatically not wall clock; and this machine has 16 cores against a GitHub standard runner's 4, so neither figure ports directly to CI. internal/api/handlers alone accounts for ~89s of the ~136s baseline, so the total is dominated by one package while the database delta is spread thin.
For scale, the Go job's ten most recent first-attempt runs on main (push events) took 6:40–9:17 wall clock, typically 7:00–7:30 with one 9:17 outlier. I originally reasoned that this was "well under 15%, so fine to merge into the existing job" — at +15–19% I withdraw that. A concurrent job avoids the question entirely.
internal/jellycompat is a production defect, not test rot. The NUL byte is not in the test data; production constructs it at internal/jellycompat/playback_sessions_postgres.go:190:
scope := session.CompatToken + "\x00" + session.ClientDeviceID + "\x00" + session.RouteItemID
if _, err := tx.Exec(ctx, `SELECT pg_advisory_xact_lock(hashtextextended($1, 0))`, scope); err != nil {scope is passed as a text parameter; PostgreSQL rejects NUL in text, the transaction aborts, and :153 logs WARN and continues. The guard at :189 is exactly "all three fields non-empty", so every negotiated-session persist meeting that condition fails to persist at negotiation time. handlers_playback.go:725 populates all three for any client sending a DeviceId, i.e. essentially every real compat client. The row is not necessarily lost forever — markUnpersisted is set and repairUnpersisted can insert it later from the Get paths — but the atomic replacement of the stale negotiation, and durability at negotiation time, are unconditionally lost. Worth splitting into its own issue; happy to file it.
internal/scanner is a separate, pre-existing flake with no database involved. I originally grouped it with the two flaky packages above; that was wrong.
[raw, excerpt] tail of a failing run — the package emits substantial unrelated scan logging above this point:
$ go test -count=1 ./internal/scanner # no SILO_TEST_DATABASE_URL
--- FAIL: TestProbeFileSkipsPacketScanForCorroboratedLongVideo (0.00s)
probe_duration_test.go:324: ProbeFile() returned error: ffprobe failed for long.mp4: fork/exec /tmp/TestProbeFileSkipsPacketScanForCorroboratedLongVideo3246140162/001/ffprobe: text file busy
FAIL
FAIL github.com/Silo-Server/silo-server/internal/scanner 0.327s[derived] rate across three batches on this machine, no database configured: 13 of 90 runs, ≈14%. At GOMAXPROCS=4 it drops to roughly 1 in 30. Selecting a single test with -run never reproduced it (0 of 20).
The mechanism is the ETXTBSY fork/exec race, not a data race and not ffprobe timing. Each test writes a fake ffprobe script into its own t.TempDir() and immediately execs it (probe_duration_test.go:424-447); a sibling t.Parallel() test forking inside that window inherits the still-open write file descriptor, and Linux returns text file busy on the exec. -race will not find it. This is Go issue #22315.
This has already turned main red. CI run 30727749302 (push, main, attempt 1, 2026-08-02) failed the Go job's Test step with exactly this:
--- FAIL: TestProbeFileFallsBackToVideoPacketsForInvalidMetadata (0.00s)
probe_duration_test.go:147: ProbeFile() returned error: ffprobe failed for broken.mkv: fork/exec /tmp/TestProbeFileFallsBackToVideoPacketsForInvalidMetadata641056496/001/ffprobe: text file busy
FAIL github.com/Silo-Server/silo-server/internal/scanner 0.943s
So it does reproduce on a 4-core runner. It is unrelated to the database work — neither caused nor fixed by it — and deserves its own issue, which I'm happy to file.
Root cause of the notifications failures is schema duplication. Four test files hand-write CREATE TEMP TABLE schemas that shadow real tables and drift from migrations. Deriving fixtures from the migrations would prevent recurrence.
On who does what: the CI lane itself belongs with #385 if its author still wants it — this issue is meant to inform that work, not claim it. I'm happy to take the mechanical test fixes (Phase 1) in small PRs regardless of how the lane lands, since those are needed either way and are independent of the workflow change. The isolation work is the part I'd want a maintainer's opinion on before anyone starts, since it touches how every DB test sets itself up.
AI Disclosure
- Tool(s): Claude Code
- Model(s): claude-opus-5
- Involvement: AI-assisted
- Adversarial review: two adversarial re-audits of this report were run before filing. The first corrected a package-failure miscount (11 → 5), a cost figure (13% → 15–19%), and a CI wall-clock range. The second caught a synthesized log block, an overstated flake rate (3-in-10 → ~1-in-7), and found CI run 30727749302 — which refuted my own hedge that the scanner flake had not been seen on CI, and turned that caveat into a citation.
Activity
fix(dev): correct the DB-test instructions and surface cleanup failures
docs(downloads,notifications,historyimport): document the fixtures th…
fix(dbtest): bound the throwaway database drop
fix(dbtest): bound provisioning, keep the raw database name, report f…
ci: run the DB-backed query-budget pins against Postgres (#1374)