Repository navigation
Conversation
Art warming and the screen drew from the same token bucket with no precedence, and warming always arrives first because it has been running for minutes. Measured with a cold 20-card grid and a 5s budget: on AniList (0.5/s) warming dropped served cards from 7 to 2; on MyAnimeList and Kitsu (3/s) it did not interfere, because real network latency already holds it at 1.07 req/s out of 3. Background work now leaves half the burst untouched and never spends a future token. Reserving the future is what turns a crowd into a queue, and a queue of a thousand titles ahead of someone opening the grid is the thing to avoid. It is declared by the caller rather than inferred from the wait budget: a long budget is a proxy for "nobody is waiting", and a proxy holds until the case where the two come apart. Measured after: AniList goes to 5 of 20, against a 7 ceiling with no warming at all.
Art warming was invisible from start to finish: the import status went to done and the bell fired before it even began. Measured against 1,200 titles, it takes 18.7 min on MyAnimeList and 52 min on AniList — time in which someone has already read "finished" and closed the screen. Two phases with two counters, never one number. Folding warming into the import counter would undo the 07/09 decision written in the runner — holding done there would park the counter at 426/426 for minutes and let a CDN outage fail an import that succeeded — and it would land on "a number that sums two reasons verifies nothing". The enrich job reuses import_jobs through a kind column instead of getting its own table: status, total, processed, the cancel stamp and the zombie reconciliation all live there already, and a second table would copy six columns and two rules. The unique index had to move with it. It covered status alone, so it meant "one running row per installation" — with warming as a job, a 52-minute run would have refused every new import for an hour. The original argument decides the shape rather than falling: one-at-a-time exists because the import freezes the server (14.2ms per 200-row batch, measured), and warming is paced network I/O. So the two coexist and the index now forbids two of the same kind.
GET /api/entries answers 347 KB for a 1,200-title library, and the route does not paginate by scope decision. On a LAN that never shows; over a remote connection — half the point of self-hosting — it is 347 KB every time /library opens. Measured after: 15.5 KB. It registers before everything else, because it wraps whatever comes after: added midway, routes mounted earlier would answer uncompressed and the difference would only show in a header. Nothing changes for the client. The browser negotiates through the Accept-Encoding it already sends, and without that header the response goes out raw exactly as before.
…brary Items 11(c) and 11(d) of the owner's queue. A title's data was written once and never revisited: a manga that gained chapters kept the old total forever, and nothing in the app offered to ask again. Refreshing reuses the warming loop rather than copying it. Warming asks "what is missing?", refreshing asks "what changed?" — same path (token, detail, art, snapshot, pause, event-loop yield, per-title failure), two questions. WarmMode separates them without separating the path. The manual action bypasses the 6h response cache. Without that, clicking Refresh inside the window would return exactly what was already on screen — a button that lies. The total crosses a boundary on purpose, and only upward (owner's decision). Snapshots are installation rows with no owner; entries.total belongs to a person and may have been typed by hand. Growing is what reality does; shrinking would erase someone's correction and could park a title at 340 / 12, which is the pair the counter reads. The sweep is a third job kind rather than enrich with a flag, because the screen says different things about each and the per-kind index lets them coexist — refusing a sweep someone asked for because an automatic warming is still running would be the side effect outranking the gesture. It is on demand only; the cron comes later, and what this cycle leaves ready for it is the staleness cut in refreshTargets. source becomes nullable (0054): a sweep rereads whatever providers the titles point at, so there is no single source. Writing 'csv' to satisfy NOT NULL would be a plausible lie in the database.
perf(providers): make background work yield, and give it a counter
The library sweep ran at 0.47 titles/s against a 3/s ceiling, and each title cost 2.1s — while the provider detail measures 0.37s and the image another 0.37s. The gap was a second round trip nobody needed. fetchArt and captureSnapshot read the SAME detail, and the first one had just filled provider_cache with it. Passing fresh to both threw that away: two requests and two limiter tokens per title. fresh now applies only when the art was not fetched in this pass, which is the case where there is no first response to reuse. The background cushion drops from half the burst to a fifth, and that number came from measuring its cost rather than from taste. Half was calibrated against AniList at 0.5/s, where contention genuinely hurts. On a 3/s provider it was charging a lot and protecting little: a cold grid took the same time with warming running (2.97s) and without it (2.78s). Protecting the screen too slowly leaves it unprotected for longer. Background work also debits its token again. The first version had it sleep without debiting and retry, so that a queue of a thousand titles would not cut ahead of someone opening the grid — but warming is a SEQUENTIAL loop that asks for the next token only after finishing the previous title, so there was never a queue to avoid. What the retry produced was repeated waiting. With the loop gone, not debiting would have left background work with no ceiling at all. Measured after: 0.47 -> 1.84 titles/s, and half the provider requests.
Measuring performance in `vite dev` measures the wrong thing, and that cost a full diagnosis cycle: returning from a title to /library took 120-140ms of frozen UI there and no long task at all against the production build, on the same gesture with 1442 titles. The gap is not Vite. It is React in development mode, which mounts every component twice under StrictMode (a no-op in production) and ships unminified. No bundler or runtime swap moves it — bun in place of node starts the dev server ~0.3s sooner and changes nothing after, and on the server it does not run at all: better-sqlite3 panics with a NAPI fatal error, which is a second reason for the runtime decision the brief already made. It builds the client and serves that build, in one command. It is not real production — the server still runs through tsx rather than dist/ — and that is deliberate: what this exists to observe is the screen, and the API answers in milliseconds either way. Packaging for real stays electron:build or the Docker image. It does not go in the README. That file is for people installing Watchpile; this is scaffolding for people writing it.
perf(providers): stop paying for the same provider detail twice
…istory Three things the owner asked for after picking the two-step mockup, and two of them turned out to be one. Resuming after a sudden stop and starting warming by hand are the SAME action. Warming skips whatever is already stored — that is its definition — so "continue where it left off" does not need to know where it left off: run it again and it finds what is left. That is why the same route serves Continue and Fill in missing. And it is not the Refresh that already exists: that one passes force and fresh and rereads the whole library, costing everything instead of costing the gap. The new one is enrich, the same kind the import fires on its own — what differs is only who pressed. A stopped run was silent until now. A restarted container closes the row as interrupted and nobody learned that hundreds of titles had been left without artwork. The status route now returns that row alongside the running one, and the screen can offer the way out. Dismissing is not deleting: the row stays in history and what goes away is the request for attention, which is the same distinction notifications draws between read and dismissed. A timestamp rather than a boolean, like cancel_requested_at and pinned_at — WHEN somebody dismissed is a fact a 1 would lose. Clearing history removes finished rows only. What is running stays, and not out of care: deleting a live job's row would leave the executor writing counters into a row that does not exist, and the zombie reconciliation without the reference it closes jobs by. It does not touch event_log — what entered the library is still recorded there. pending counts external IDENTITIES, not titles: two titles pointing at the same identity are one lookup, because warming deduplicates before starting. A larger number would promise work that never happens.
feat(import): fill in what is missing, dismiss a stopped run, clear history
WATCHPILE_ART_CACHE_PATH defaulted to ./data/art, relative to the process cwd. In the Docker image that is /app/data/art, outside the /data volume, so cached artwork was silently lost on every container recreation; in packaged Electron it landed wherever the cwd was. The comment next to the variable claimed the opposite. The variable is now an optional override. Without it the cache lives in art/ next to WATCHPILE_DB_PATH, the one path both hosts declare, via besideDatabase() in lib/data-dir.ts, which the log file will reuse. READMEs: art cache is no longer "in the future", and the variable is listed in the configuration table.
The pino instance lived inside the HTTP middleware, so only route handlers could log; background work used console.* and nothing reached disk. lib/logger.ts is now the root logger, and the middleware is one of its consumers. - Two destinations: stdout (pino-pretty as an in-process stream in dev, never a transport, which breaks in packaged Electron) and logs/watchpile.log next to the database, rotated in-process at 5 MB x 3 files (WATCHPILE_LOG_PATH, _MAX_MB, _FILES overrides). - Secrets are redacted on every line at the emitter (streamWrite): by value for resolved provider credentials, OAuth tokens and the session secret, and by name for cookie/authorization/password keys and credential query params. - The per-request line no longer carries headers (the session cookie was logged on every request). Only 5xx (error), 4xx and responses over 1s (info) reach the file at the default level; the rest drops to debug. - The startup line goes through the logger instead of console.log.
Provider, art, import and update failures became typed states for the UI and left no trace, so a user reporting "search is broken" had nothing to send. Every such catch now emits through the root logger, never with the request URL (it can carry a key); the redaction in streamWrite scrubs whatever else slips through. - warn when a third party fails: provider search/detail/units refused, unreachable or not JSON; art image refused, not an image or out of range; token exchange; import sources going down (the cause used to be lost in ImportFailure); update feed and asset download; an unreadable *_FILE credential (path only). - error when the failure is ours: unexpected import, fill, refresh and enrich jobs; art warm; update download, check and install; corrupt JSON in notification params and import jobs. - debug for a job that did not start because one is already running, which is the expected path. - import logs "import finished", and a typed failure logs its kind (params stay out: they carry the username). - console.* is gone from the server outside env.ts, which runs before the logger exists. logger.spec.ts writes through the root logger and reads the file, so removing the redaction hook fails a test (checked by removing it).
GET /api/logs returns the newest lines of the file lib/logger.ts writes, and GET /api/logs/download returns every kept file as JSON Lines. Both sit behind adminMiddleware for the whole feature, like storage: the log is the instance's, not a user's. - The read walks files newest first, backwards, and stops at 1,000 lines, so a poll costs the slice and not the 15 MB. - level=all|warn|error is cumulative by severity. before= loads older lines, after= follows new ones. The cursor is the pino time, which survives rotation (line numbers do not); two lines in the same millisecond at a page boundary may repeat or skip. - Every line goes through redactLine again on the way out, so a secret registered after the line was written is still scrubbed. - The download is named by the server (watchpile-log-YYYY-MM-DD.jsonl) and never cached. - The download handler casts its response: @hono/zod-openapi types application/x-ndjson as a malformed JSON media type (never), and declaring another type would make openapi.json lie about the file. The e2e test checks status, headers and body instead.
New section "O log de diagnóstico" (root logger, rotation, redaction, the admin read/download feature and seven invariants), the lib files in the tree, and the container bullet now says stdout and file, following the brief 5.1 correction.
feat(logs): diagnostic log in a rotating file, readable by the admin
One release per version: moving package.json is what makes the main build publish v0.2.1 and ghcr.io/digit4w/watchpile:0.2.1 instead of updating v0.2.0 in place. The pinned image tag moves with it in both READMEs, and the configuration table gains the three log variables this release introduces (WATCHPILE_LOG_PATH, _MAX_MB, _FILES).
build: cut version 0.2.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Promotes dev to main for the v0.2.1 pre-release. The client was promoted first (Digit4w/watchpile-client#38), because this build checks out the client's
main.Merging this publishes, from build.yml on main: the GitHub pre-release
v0.2.1with the three installers, andghcr.io/digit4w/watchpile:0.2.1plus:latestfor amd64 and arm64.Since v0.2.0: the diagnostic log (rotating file next to the database, secrets redacted at the emitter, admin read and download), logging for failures that were swallowed, the two-phase import with pausable artwork warming, and the fix that moves the art cache inside the
/datavolume.No migration upgrade test between versions exists yet — back up before upgrading (README, Backup).
🤖 Generated with Claude Code