Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit b0e91288d9b69a08102c01adbe4442fe728fcc88
parent 5d2b18aceea14e8bece2138e96ae586c089dedc7
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon,  9 Nov 2026 21:58:58 -0500

docs: drive health in ops get storage's help, the dev script's threads, changelog and FACTS

- `pnpm ops` help: get storage reports rows[].drive; COMMANDS.md regenerated.
- editor `dev` gives Node 16 file-access threads (UV_THREADPOOL_SIZE), as
  `start`, the service unit and the container already did; ENVIRONMENT.md
  regenerated from envVars.ts, which now names the unit and `dev`.
- editor/CHANGELOG.md [Unreleased]: the dashboard's drive banner and the
  Drive line, batches holding on a stalled drive, the watch's lock.
- plans/FACTS.md: "Lane drive-stall additions" under the storage health gate.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
MCOMMANDS.md | 4+++-
MENVIRONMENT.md | 2+-
Mcommon/lib/envVars.ts | 2+-
Meditor/CHANGELOG.md | 3+++
Meditor/package.json | 2+-
Mplans/FACTS.md | 34++++++++++++++++++++++++++++++++++
Mscripts/archilyzer-ops.mjs | 4+++-
7 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/COMMANDS.md b/COMMANDS.md @@ -281,7 +281,9 @@ job resume-interrupted does by hand what the editor does at boot: re-queues get settings [<key>] is settings.json as the editor reads it (migrated and defaulted; a secret is "<redacted>"), or one top-level key of it. -get storage is /storage: each location, mounted or not, free space, tiers. +get storage is /storage: each location, mounted or not, free space, tiers, + and its drive's health (rows[].drive: ok | slow | stalled | unmounted, + since, lastOkAt, latencyMs, the cause and the one-line text). get saved-alternates [<slug>] lists every saved video holding two copies: a download over a container already in the store keeps both — an explicit persist (persist-videos, Persist source video, a whole-recording diff --git a/ENVIRONMENT.md b/ENVIRONMENT.md @@ -106,7 +106,7 @@ Tokens, credentials and knobs a running process reads. Most configuration is not | `AUDIO_CHECK_BACKOFF_FACTOR` | the built-in factor | The audio check's interval backoff factor, in (0, 1], for a one-off run. | common/ytdlp/audioCheckedDownload.ts | | `ARCHILYZER_STATS_ALLOW_DOWNGRADE` | off | `1` lets a stats build clear a stats cache that a NEWER build wrote, for a deliberate rollback. Unset, such a build refuses and names both versions. | common/controller/buildStats.ts | | `ARCHILYZER_INDEX_ALLOW_HELD` | off | `1` lets a FULL index rebuild (a schema change, or no index yet) proceed while a channel's media cannot be read; that channel stays out of the index until its media is back and the index is built again. Unset, such a build refuses and names each channel. | common/controller/buildIndex.ts | -| `UV_THREADPOOL_SIZE` | `16` for the editor (`4` is Node's own) | Threads in Node's pool for filesystem calls. A call on a stalled drive holds one until the drive answers, so the editor starts with 16. It buys time for calls already in flight and isolates nothing: the storage health probe and its gate keep new calls off a stalled drive. | Node's libuv (set by editor/package.json `start` and docker/entrypoint.sh) | +| `UV_THREADPOOL_SIZE` | `16` for the editor (`4` is Node's own) | Threads in Node's pool for filesystem calls. A call on a stalled drive holds one until the drive answers, so the editor starts with 16. It buys time for calls already in flight and isolates nothing: the storage health probe and its gate keep new calls off a stalled drive. | Node's libuv (set by editor/package.json `start` and `dev`, the archilyzer-editor.service unit `archilyzer service install` writes, and docker/entrypoint.sh) | | `MCP_IO_STATS` | off | `1` turns on per-call I/O accounting, for `mcp/bench`. | common/lib/archive/io-stats.ts | | `ARCHILYZER_EDITOR_URL` | `http://localhost:3001` | Which editor `pnpm ops`, `archilyzer gen` and the MCP's editor-backed tools (`fetch_clip`, `enqueue`, `get_job`, `channel_coverage`, `generation_policy`, `generate`, `get_transcript`'s fallback) talk to, and whose `/api/pulse` `archilyzer storage migrate-tier` asks before it refuses to run beside it. | scripts/archilyzer-ops.mjs, common/bin/gen.ts, mcp/src/fetchClip.ts, mcp/src/editorOps.ts, umtool, common/bin/migrate-media-tier.ts | | `ARCHILYZER_AGENT` | `cli` | Who is asking, recorded as the provenance of a curated-tag write through `pnpm ops`. | scripts/archilyzer-ops.mjs | diff --git a/common/lib/envVars.ts b/common/lib/envVars.ts @@ -142,7 +142,7 @@ const DECLARED: EnvVarDecl[] = [ { name: "AUDIO_CHECK_BACKOFF_FACTOR", audience: "runtime", default: "the built-in factor", readBy: "common/ytdlp/audioCheckedDownload.ts", doc: "The audio check's interval backoff factor, in (0, 1], for a one-off run." }, { name: "ARCHILYZER_STATS_ALLOW_DOWNGRADE", audience: "runtime", default: "off", readBy: "common/controller/buildStats.ts", doc: "`1` lets a stats build clear a stats cache that a NEWER build wrote, for a deliberate rollback. Unset, such a build refuses and names both versions." }, { name: "ARCHILYZER_INDEX_ALLOW_HELD", audience: "runtime", default: "off", readBy: "common/controller/buildIndex.ts", doc: "`1` lets a FULL index rebuild (a schema change, or no index yet) proceed while a channel's media cannot be read; that channel stays out of the index until its media is back and the index is built again. Unset, such a build refuses and names each channel." }, - { name: "UV_THREADPOOL_SIZE", audience: "runtime", default: "`16` for the editor (`4` is Node's own)", readBy: "Node's libuv (set by editor/package.json `start` and docker/entrypoint.sh)", doc: "Threads in Node's pool for filesystem calls. A call on a stalled drive holds one until the drive answers, so the editor starts with 16. It buys time for calls already in flight and isolates nothing: the storage health probe and its gate keep new calls off a stalled drive." }, + { name: "UV_THREADPOOL_SIZE", audience: "runtime", default: "`16` for the editor (`4` is Node's own)", readBy: "Node's libuv (set by editor/package.json `start` and `dev`, the archilyzer-editor.service unit `archilyzer service install` writes, and docker/entrypoint.sh)", doc: "Threads in Node's pool for filesystem calls. A call on a stalled drive holds one until the drive answers, so the editor starts with 16. It buys time for calls already in flight and isolates nothing: the storage health probe and its gate keep new calls off a stalled drive." }, { name: "MCP_IO_STATS", audience: "runtime", default: "off", readBy: "common/lib/archive/io-stats.ts", doc: "`1` turns on per-call I/O accounting, for `mcp/bench`." }, { name: "ARCHILYZER_EDITOR_URL", audience: "runtime", default: "`http://localhost:3001`", readBy: "scripts/archilyzer-ops.mjs, common/bin/gen.ts, mcp/src/fetchClip.ts, mcp/src/editorOps.ts, umtool, common/bin/migrate-media-tier.ts", doc: "Which editor `pnpm ops`, `archilyzer gen` and the MCP's editor-backed tools (`fetch_clip`, `enqueue`, `get_job`, `channel_coverage`, `generation_policy`, `generate`, `get_transcript`'s fallback) talk to, and whose `/api/pulse` `archilyzer storage migrate-tier` asks before it refuses to run beside it." }, { name: "ARCHILYZER_AGENT", audience: "runtime", default: "`cli`", readBy: "scripts/archilyzer-ops.mjs", doc: "Who is asking, recorded as the provenance of a curated-tag write through `pnpm ops`." }, diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ## [Unreleased] +- **The dashboard says when a media drive is not answering, slow, or not mounted.** A stalled external drive used to show only on `/storage` and in channel badges, so the editor looked broken with nothing on its front page saying why. The dashboard now opens with one card per storage location in trouble: **not answering** (an alert: pages and polls skip the drive, and its channels' jobs wait until it answers), **answering slowly** (everything still runs, just late), or **not mounted** (only when some channel's media is on it). Each card links to `/storage` and to that location's channels. On `/storage` each location has a **Drive** line that says when the drive last answered and how long it took (for example "answering — 12 ms (a read in the editor), last at 11:42"), and a **slow** chip appears next to Available when reads on it are taking half the 3-second limit or more. `pnpm ops get storage` reports the same for each location under `rows[].drive`: `state` (`ok`, `slow`, `stalled` or `unmounted`), `since`, `lastOkAt`, `latencyMs`, the cause and the one-line text. +- **A transcription or backfill run waits while its channel's media drive is not answering.** Before, a run that started while the drive answered kept going after the drive stalled. Each next video asked the stalled drive for its audio, waited about 30 seconds and failed. Now the run pauses at the next video and says so in its log ("Holding: the media drive "…" is not answering (since 11:35) — no new transcription starts until it answers again"), then resumes by itself when the drive answers. A video that is refused because the drive is not answering is skipped, not added to the channel's failed-transcriptions list, and is transcribed on a later run. +- **The drive watch no longer overwrites a tier you change while it is pausing channels.** The five-minute storage watch, which pauses the channels on a drive that went away and restores them when it comes back, could save its change in the middle of yours and undo it. It now waits for the same settings lock that the channel-priority save uses. The editor's `dev` script also gives Node 16 file-access threads, as `start`, the systemd unit and the container already do. - **Deleting a channel takes it off every site.** On 9 Nov, deleting `mooler` left it in efapalyzer's `site.json`, and the site had to be fixed by hand. Danger → Delete and `pnpm ops delete-channel` now rewrite every site whose pool (`channels`) or cited scope (`citedChannels`) names the deleted channel, each as a `patchSite` under that site's lock, so a concurrent edit of the site is not written over (a rename already re-points them through the same writer). The ops answer names those sites in `sitesUpdated`. A site whose write is refused shows up as a `warnings` line, and the delete still stands. Sites that never named the channel are not written (`common/controller/siteMemberships.ts`). - **`pnpm ops create-site` is the New site form, without a browser.** On 9 Nov an agent had to call `writeSite` from a tsx script to make `efapalyzer`. `create-site` takes `{"siteId", "siteTitle"}` and any of the form's fields: header title (default the title), description, tagline, wordmark lead, accent, public URL, Pages project, hub URL, audience, listed, publish policy, search, archives, duplicates, transcript downloads, PWA, archive cap, groups, default group, channels, cited channels, social links and related sites. It builds the FormData the form posts and saves it through the form's own action (`saveSiteAction` → `writeSite`), so you get the same validation and the same sentences. A new site is **private and unlisted** unless the body says `"audience": "public"` / `"listed": true`. An existing id is refused (409) unless `"update": true`, which is the site page's Save with only the given keys changed; every other key, and the published page list, is kept. Unknown channels, a channel's `groupId` that names none of the site's groups, unknown keys and keys of the wrong type are refused before anything is written. The existence check, the read of the stored site and the save are one read-modify-write under the site's lock (`withSiteLock`). The site form's own Save now takes the same lock, so neither it nor an update is written over a concurrent edit such as a Reports-tab pages patch. It answers the saved site. - **`pnpm ops channel-rank` places one channel in the order the lanes follow.** Before this, only /channels' "Add to top" moved a channel, and it also sets the tier to normal and turns the download lane on. `channel-rank` moves the rank alone: `{"slug"}` plus exactly one of `"rank": <n>` (or `null` to unrank), `"top": true`, `"bottom": true`, `"before": "<slug>"` or `"after": "<slug>"`. Every other channel keeps its order: channels after it move down only as far as they must, ties stay tied, and `after` lands immediately after its anchor even when the anchor's rank is tied. It goes through the deck's one writer, so the four lane roots are recompiled in the same write. That writer now does its read-modify-write inside a settings lock, which every `saveSettings` takes too, so a concurrent deck save or a parallel `channel-rank` is never written over. Refused before any write: an unknown channel or anchor, an anchor with no rank, a rank that is not a whole number ≥ 0, and a channel paused for every operation (its rank would not be kept). It answers the saved rank and the whole ranked order (`common/lib/channelPriority.ts` `placeChannelRank`). diff --git a/editor/package.json b/editor/package.json @@ -4,7 +4,7 @@ "private": true, "type": "module", "scripts": { - "dev": "next dev --port ${EDITOR_PORT:-3001}", + "dev": "UV_THREADPOOL_SIZE=${UV_THREADPOOL_SIZE:-16} next dev --port ${EDITOR_PORT:-3001}", "dev:test": "WORKER_TOKEN=test-worker-token TRANSCRIPTS_DIR=${E2E_DATA_ROOT:-$(pwd)}/test-transcripts EXPORT_PUBLIC_DIR=${E2E_DATA_ROOT:-$(pwd)}/test-transcripts/.export-public SETTINGS_FILE=${E2E_DATA_ROOT:-$(pwd)}/test-settings.json EDITOR_CHANGELOG_FILE=${E2E_DATA_ROOT:-$(pwd)}/test-changelog.md EXPORT_CHANGELOG_FILE=${E2E_DATA_ROOT:-$(pwd)}/test-export-changelog.md GENERATION_USAGE_FILE=${E2E_DATA_ROOT:-$(pwd)}/test-transcripts/.generation-usage.jsonl YTDLP_BIN=$(pwd)/e2e/fixtures/bin/fake-ytdlp.mjs GALLERY_DL_BIN=$(pwd)/e2e/fixtures/bin/fake-gallery-dl.mjs WHISPER_BIN=$(pwd)/e2e/fixtures/bin/fake-whisper.mjs WHISPER_MODEL=/dev/null CHOUGH_BIN=$(pwd)/e2e/fixtures/bin/fake-chough.mjs CHOUGH_MODEL=/dev/null PARAKEET_STITCH_BIN=$(pwd)/e2e/fixtures/bin/fake-parakeet-stitch.mjs PARAKEET_CLI=/dev/null PARAKEET_MODEL=/dev/null DIARIZE_BIN=$(pwd)/e2e/fixtures/bin/fake-diarize.mjs FFMPEG_BIN=$(pwd)/e2e/fixtures/bin/fake-ffmpeg.mjs FFPROBE_BIN=$(pwd)/e2e/fixtures/bin/fake-ffprobe.mjs OLLAMA_URL=http://127.0.0.1:${OLLAMA_STUB_PORT:-11435} CLAUDE_BIN=$(pwd)/e2e/fixtures/bin/fake-claude.mjs FINDMNT_BIN=$(pwd)/e2e/fixtures/bin/fake-findmnt.mjs UDISKSCTL_BIN=$(pwd)/e2e/fixtures/bin/fake-udisksctl.mjs next dev --port ${PORT:-3011}", "start:test": "WORKER_TOKEN=test-worker-token TRANSCRIPTS_DIR=${E2E_DATA_ROOT:-$(pwd)}/test-transcripts EXPORT_PUBLIC_DIR=${E2E_DATA_ROOT:-$(pwd)}/test-transcripts/.export-public SETTINGS_FILE=${E2E_DATA_ROOT:-$(pwd)}/test-settings.json EDITOR_CHANGELOG_FILE=${E2E_DATA_ROOT:-$(pwd)}/test-changelog.md EXPORT_CHANGELOG_FILE=${E2E_DATA_ROOT:-$(pwd)}/test-export-changelog.md GENERATION_USAGE_FILE=${E2E_DATA_ROOT:-$(pwd)}/test-transcripts/.generation-usage.jsonl YTDLP_BIN=$(pwd)/e2e/fixtures/bin/fake-ytdlp.mjs GALLERY_DL_BIN=$(pwd)/e2e/fixtures/bin/fake-gallery-dl.mjs WHISPER_BIN=$(pwd)/e2e/fixtures/bin/fake-whisper.mjs WHISPER_MODEL=/dev/null CHOUGH_BIN=$(pwd)/e2e/fixtures/bin/fake-chough.mjs CHOUGH_MODEL=/dev/null PARAKEET_STITCH_BIN=$(pwd)/e2e/fixtures/bin/fake-parakeet-stitch.mjs PARAKEET_CLI=/dev/null PARAKEET_MODEL=/dev/null DIARIZE_BIN=$(pwd)/e2e/fixtures/bin/fake-diarize.mjs FFMPEG_BIN=$(pwd)/e2e/fixtures/bin/fake-ffmpeg.mjs FFPROBE_BIN=$(pwd)/e2e/fixtures/bin/fake-ffprobe.mjs OLLAMA_URL=http://127.0.0.1:${OLLAMA_STUB_PORT:-11435} CLAUDE_BIN=$(pwd)/e2e/fixtures/bin/fake-claude.mjs FINDMNT_BIN=$(pwd)/e2e/fixtures/bin/fake-findmnt.mjs UDISKSCTL_BIN=$(pwd)/e2e/fixtures/bin/fake-udisksctl.mjs next start --port ${PORT:-3011}", "build": "next build", diff --git a/plans/FACTS.md b/plans/FACTS.md @@ -8147,6 +8147,40 @@ shipped". Anchors are at slice DT's tip (`r15/drive-timings`). stalled at boot before the second counter sample, unless a page reaches it; per-click server actions; the file route's stream; the corpus disk itself. +### Lane drive-stall additions (2026-11-09, branch `lane/drive-stall`) + +- **The record says more than ok | stalled | absent.** `LocationHealth` gains `lastOkAt` (a pass's + clean `ok`, or an `onDrive` call answered in its budget; a registration sets none), `latencyMs` + + `latencyFrom` (`call`: the unit's time; `stat`: the child stat's round trip, process start + included; `counters`: the device's own average per completed request, Δ(fields 4 + 8 (+ 15 + 17)) / + Δcompleted between two samples — `blockStatTicksMs`, `countersLatencyMs` in `storageVolumes.ts`; + `parseBlockStat`'s shape is unchanged), and `slowAt`/`slowCause` (a measurement ≥ + `slowThresholdMs()` = budget / 2, or the watchdog's two "drive slow" refusals, `noteDriveSlow`). A + transition to stalled deletes slowAt. `noteDriveAnswer` writes only to an existing entry. +- **`driveHealthView(loc, health, { mounted })`** (`lib/storageHealth.ts`, pure) is the one view: + `stalled` (the record) > `unmounted` (record `absent`, or `mounted: false`) > `slow` (slowAt within + `slowWindowMs()` = 2 × passIntervalMs) > `ok`. `probeMounted(status)` (`views/storage.ts`): + available → true, stalled/undefined → undefined, the rest → false. Slow is shown, never acted on. +- **Surfaces.** `StorageRow.drive` (the shell passes `drives`, a record for another root under the + same id is dropped) → `pnpm ops get storage` `rows[].drive`; /storage's Drive line + (`aria-label="location drive"`) and `slow` chip (`location slow`). The dashboard banner: view + `driveHealth` (`storage/lib/driveHealth.ts`, `DriveHealthBanner`, cards `aria-label="drive <id>"`, + `data-state`, role alert for stalled/unmounted, status for slow); unmounted shows only with ≥ 1 + channel's media on the location; configs are read only when a drive is in trouble. +- **Batches hold mid-run.** `mediaStallHold(config, log, what)` (`lib/mediaStallHold.ts`, memory + only, edge-logged) is asked in the pool `limit()` of `runWhisperBatch` and of the backfill lane of + `runOperationBatch` (not digest): 0 while the channel's media location is stalled, so runPool + pauses (its idle poll is unref'd — a unit test needs a keep-alive). It gates DISPATCH only: the + batch's classification reads `data/` (readdir, the corpus disk) and never waits. The autoRunner + lanes were already held at pick time (`buildChannelWork`). `transcribeOneVideo` refuses before + `resolveAudioFile` with `MediaDriveHeldError` (`failureClass` "no-audio": skipped, never + failed-transcriptions; `transcribeOneFromQueue` logs its message). +- **The five-minute watch writes under the settings lock** (`withJsonFileLock(getPaths().settingsFile)`, + the lock `editor/app/settings/saveSettings.ts` `withSettingsLock` takes). `storageLocations.ts`'s and + `relocateSavedVideos.ts`'s settings writers still do not take it. +- **`/api/test/drive-health`** (`POST {id, state: "stalled"|"slow", cause?}`, E2E_TEST_ROUTES only) + records a detector's answer for a configured location; the pass clears a stall in 15–30 s. + ## The source's history (stagit) (verified 2026-09-30, branch `r15/stagit`) Release 15 slice SG ([`release-15.md`](release-15.md)); the operator-facing doc is `PUBLISH.md`, "The diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs @@ -1097,7 +1097,9 @@ export function usage() { "", "get settings [<key>] is settings.json as the editor reads it (migrated and", " defaulted; a secret is \"<redacted>\"), or one top-level key of it.", - "get storage is /storage: each location, mounted or not, free space, tiers.", + "get storage is /storage: each location, mounted or not, free space, tiers,", + " and its drive's health (rows[].drive: ok | slow | stalled | unmounted,", + " since, lastOkAt, latencyMs, the cause and the one-line text).", "get saved-alternates [<slug>] lists every saved video holding two copies:", " a download over a container already in the store keeps both — an", " explicit persist (persist-videos, Persist source video, a whole-recording",