Jump to content

MediaButler/SPEC

From MindAttic Docs

MediaButler — Product specification

The complete product, written down before it is built (owner, 2026-11-30, MAT-T360). Every epic, feature and story the finished product will have is listed here, built or not. The ticket tree mirrors this file one to one: every ID below is a ticket. Nothing gets built unless it is here, and anything taken out of here is closed wont-do in the tree. docs/RELEASE.md says which part of this the current milestone delivers.

1. Product definition

Place in the ecosystem: A product (App) in docs/ECOSYSTEM.md §2.2: the owner's media-library butler. MediaButler is a Windows tool for the owner's own media library: a .NET console app, an optional WPF shell and an MCP server over one pipeline. It sweeps inboxes of messy torrent dumps, cleans and classifies the names locally, hands the survivors to FileBot for titles, artwork and subtitles, and moves everything into a canonical Plex layout, dry-run first, idempotently, refusing to run when a source overlaps a destination. The finished product handles every naming shape the owner's library meets (including date-based TV and anime absolute numbering), has direct tests for every piece of code that moves, renames or deletes files, has its desktop shell and live FileBot and OpenSubtitles paths proven on a real desktop, and ships as 6.0.0 to R:\MindAttic\Apps\MediaButler.

2. Scope boundary

2.1 In the product

  • Scanning and classification of inbox entries, local clean-up, the variation catalog and the LLM long-tail fallback through MindAttic.Legion.
  • FileBot matching (titles, artwork, subtitles), library moves into the flat Plex layout, merges, duplicate policies, reboot-safe TV routing and the relocate command.
  • Safety: dry-run, overlap refusal, size-floored deletes, three exit codes, the audit log, Vault-only secrets.
  • Front doors: CLI and interactive menu, the mb.cmd shim, the WPF shell and the MCP server.
  • Tests for every mutating stage, the shared run menu deploy, the brochure page.

2.2 Never in the product

  • A downloader or torrent client — it organizes what is already on disk (BIBLE §3).
  • A metadata database — titles, posters and matching are FileBot's job via TheTVDB/TheMovieDB (BIBLE §3).
  • A media server or Plex integration — it produces a Plex-ready layout and never talks to Plex (BIBLE §3).
  • A music organizer — music is detected and moved as-is, never tagged or restructured (BIBLE §3).
  • A PowerShell rewrite — it is a .NET app so it can use MindAttic.Vault (BIBLE §3).
  • Removing the desktop shell (MB-T30, wont-do) — the WPF shell stays a front door.
  • Tests for cosmetic or display-only code — Ui/Status verbosity, ConsoleCaptureWriter, DialogService, the Run and Settings page bUnit tests (MB-T40, MB-T41, MB-T43, MB-T44, MB-T45, wont-do).
  • Settings pages of its own or in Vault Dashboard — superseded by Vault.Desktop (MB-T23 to MB-T26, wont-do; MB-T27 built).
  • Open-ended loops — whole-suite reruns, repo-wide clean-ups, exhaustive bughunts, LF conversion (MB-T15, MB-T16, MB-T19, MB-T49, wont-do).

3. Users and roles

  • The owner — runs it on M:\Torrents into M:\TV and M:\Movies and wants the library to come out right.
  • A scheduled run — runs it headless and reads exit code 2 as "a human is needed".
  • An LLM client — drives the same engine through mediabutler mcp.

4. Requirements

Status is built (closed ticket, with evidence), MS-33 (the active milestone) or MS-163 (the next one). Every unbuilt story is approved and prioritised in build order; the planner splits a story into tasks when the queue reaches it.

E1. Cleaning and classification — MB-T72 — built

F1.1 Scan and classify — MB-T73 — built

  • S1.1.1 Classify every inbox entry — MB-T74 — built As the owner, I want every top-level folder and loose video in an inbox classified (movie, season, multi-season, episode, pack, collection, extras, music, empty, unknown), so that each gets the right treatment. Acceptance: Given a mixed inbox, when it is scanned, then each entry has one kind. Evidence: MediaScanner.cs; MediaScannerTests.
  • S1.1.2 Idempotent canonical names — MB-T75 — built As the owner, I want canonical Show - Season NN and Title (YYYY) names that round-trip unchanged, so that re-running on a clean library is a no-op. Acceptance: Given an organized library, when the pipeline reruns, then nothing changes. Evidence: NameParser.cs; MB-LAW-2 tests.
  • S1.1.3 LLM fallback for the long tail — MB-T76 — built As the owner, I want unclassifiable folders and loose files optionally classified through Legion and skipped on any failure, so that odd names are handled without wrong renames. Acceptance: Given the provider fails, when a folder needs the fallback, then it is skipped, not renamed. Evidence: LegionFallbackParser.cs; LegionFallbackParserTests (MB-T2); MB-LAW-6.

F1.2 Local clean-up — MB-T77 — built

  • S1.2.1 Consolidate episode dumps — MB-T78 — built As the owner, I want per-episode dumps and loose episode files filed into their Show - Season NN, so that seasons arrive whole. Acceptance: Given loose episodes of one season, when the rename stage runs, then they share one folder. Evidence: RenameStage.cs; RenameStageTests.
  • S1.2.2 Split packs and hoist collections — MB-T79 — built As the owner, I want multi-movie packs split and collection husks hoisted into one Title (YYYY) folder per film, so that every movie stands alone. Acceptance: Given a three-film pack, when it runs, then three movie folders exist. Evidence: PathologicalLibraryPipelineTests.
  • S1.2.3 Hoist multi-season dumps — MB-T80 — built As the owner, I want nested Season N subfolders lifted out of a multi-season dump, so that each season is filed on its own. Acceptance: Given a show folder with three seasons, when it runs, then three season folders exist. Evidence: RealWorldLibraryPipelineTests.
  • S1.2.4 Delete empties safely, keep extras — MB-T81 — built As the owner, I want video-less folders deleted only under the size floor and Extras/Specials/Bonus left and flagged, so that nothing of value is lost. Acceptance: Given a 5 MB folder with no video, when it runs, then it is flagged, not deleted. Evidence: MB-LAW-4 tests.
  • S1.2.5 Music passes through — MB-T82 — built As the owner, I want audio-only folders recognised and moved as-is (or flagged), so that music is never renamed or deleted as empty. Acceptance: Given an album folder, when it runs, then it reaches MusicDestination unchanged. Evidence: music classification and move in MediaScanner/MoveStage.

E2. Matching and moving — MB-T83 — built

F2.1 FileBot matching — MB-T84 — built

  • S2.1.1 Titles and matches from FileBot — MB-T85 — built As the owner, I want FileBot to rename TV and movies from TheTVDB/TheMovieDB, in TEST mode during a dry-run, so that names carry real titles. Acceptance: Given a dry-run, when FileBot runs, then it uses --action TEST. Evidence: FileBotStage.cs, FileBotClient.cs; FileBotClientTests.
  • S2.1.2 Subtitles and artwork — MB-T86 — built As the owner, I want subtitles fetched with Vault-resolved OpenSubtitles credentials and artwork downloaded, so that the library is complete in Plex. Acceptance: Given credentials in Vault, when subtitles run, then FileBot gets @path references, not raw secrets. Evidence: SubtitleCredentialsTests.
  • S2.1.3 ID overrides reach FileBot — MB-T87 — built As the owner, I want my TVDB/TMDB id overrides honoured on every run, so that ambiguous titles match the show I mean. Acceptance: Given an override, when a per-inbox run clones settings, then the override survives. Evidence: f82b562 (MB-T28).

F2.2 Library moves — MB-T88 — built

  • S2.2.1 Flat Plex layout — MB-T89 — built As the owner, I want seasons moved to TvDestination as flat Show - Season NN folders and movies to MoviesDestination as Title (YYYY), so that Plex reads them. Acceptance: Given a clean season, when it moves, then no per-show container is created. Evidence: MoveStage.cs; MoveStageTests.
  • S2.2.2 Merge, never overwrite — MB-T90 — built As the owner, I want a second dump of a season merged file by file, so that no episode is overwritten or filed twice. Acceptance: Given an existing season, when another dump arrives, then new episodes merge in. Evidence: SeasonMerger.cs; SeasonMergerTests (MB-T3); MB-LAW-9.
  • S2.2.3 Duplicate policies — MB-T91 — built As the owner, I want true duplicate movies and episodes resolved by KeepLargest or Flag, audit-logged, so that the better copy wins or a human decides. Acceptance: Given two copies, when KeepLargest applies, then the larger survives. Evidence: DuplicateMovieActionTests, DuplicateEpisodeActionTests; 9db99ca (MB-T35).
  • S2.2.4 Reboot-safe TV routing — MB-T92 — built As the owner, I want year-tagged reboots routed to Show (YEAR) - Season NN once the library is disambiguated, so that two shows with one name stay apart. Acceptance: Given a year-tagged season folder exists, when a reboot season arrives, then it lands beside it. Evidence: MoveStage.IsShowDisambiguated.
  • S2.2.5 Relocate misfiled folders — MB-T93 — built As the owner, I want mediabutler relocate to move TV out of the movies library and movies out of the TV library, so that drifted folders come home. Acceptance: Given a season in M:\Movies, when relocate runs, then it moves to M:\TV. Evidence: RelocateStage.cs; RelocateStageTests; MB-LAW-5.

E3. Safety — MB-T94 — built

F3.1 Safe by default — MB-T95 — built

  • S3.1.1 Dry-run mutates nothing — MB-T96 — built As the owner, I want --dry-run to print every planned change and touch nothing, so that I can preview a run. Acceptance: Given a dry-run, when it finishes, then the disk is unchanged. Evidence: MB-LAW-1 tests.
  • S3.1.2 Refuse on overlap — MB-T97 — built As the owner, I want a live run refused when a source overlaps a destination, so that the pipeline never eats its own output. Acceptance: Given source inside M:\TV, when a live run starts, then it refuses. Evidence: PathGuard.cs; PathGuardTests; MB-LAW-3.
  • S3.1.3 Exit codes a scheduler can read — MB-T98 — built As the owner, I want exit codes 0, 1 and 2 (a human is needed), combined across sources by severity, so that a scheduled run reports honestly. Acceptance: Given only extras remain, when the run ends, then it exits 2. Evidence: MB-LAW-8 tests.
  • S3.1.4 Audit trail of every mutation — MB-T99 — built As the owner, I want every rename, move and delete appended to a daily NDJSON audit log, so that I can see what happened. Acceptance: Given a live run, when it moves a file, then the day's audit file has one line for it. Evidence: AuditLog.cs.
  • S3.1.5 Secrets never in settings — MB-T100 — built As the owner, I want OpenSubtitles and LLM credentials resolved only through Vault, so that no secret sits in settings.json. Acceptance: Given saved settings, when I read the file, then it holds no secret. Evidence: MB-LAW-7.

E4. Front doors and configuration — MB-T101 — built

F4.1 Front doors — MB-T102 — built

  • S4.1.1 CLI and interactive menu — MB-T103 — built As the owner, I want Spectre subcommands, an interactive menu and the mb.cmd shim, so that I can run any stage from a terminal. Acceptance: Given mb version, when it runs, then it prints the version and exits 0. Evidence: Commands/*; CliEndToEndTests.
  • S4.1.2 Many inboxes in one call — MB-T104 — built As the owner, I want ExtraSources, repeatable --source and --recursive container inboxes processed in one run, so that every inbox is swept at once. Acceptance: Given two sources, when the run ends, then both were processed. Evidence: PipelineRunner.EffectiveSources.
  • S4.1.3 MCP server — MB-T105 — built As an LLM client, I want mediabutler mcp to expose scan, status and run (dry-run by default) over stdio, so that an agent can drive the same engine. Acceptance: Given a malformed frame, when it arrives, then the server answers Invalid Request and keeps running. Evidence: McpServer.cs; McpServerTests; d69de0f (MB-T50).
  • S4.1.4 Desktop shell — MB-T106 — built As the owner, I want a WPF window that runs the same pipeline with a dry-run-first Run page and a LIVE confirmation, so that I can use it without a terminal. Acceptance: Given the shell, when I press Run, then it dry-runs first. Evidence: MediaButler.Wpf, MediaButler.Wpf.UI; smoke tests 5/5 on a desktop (2026-09-25).

F4.2 Configuration and catalog — MB-T107 — built

  • S4.2.1 Variation catalog — MB-T116 — built As the owner, I want every seen name recorded in a hand-editable variations.json whose sections pin categories, so that the parser learns my library. Acceptance: Given a name moved to the tv section, when the next scan runs, then it classifies as TV. Evidence: VariationCatalog.cs; MB-LAW-10 tests.
  • S4.2.2 Settings and keys in Vault.Desktop — MB-T27 — built As the owner, I want MediaButler's settings and shared keys managed in MindAttic Vault.Desktop, with the shell's cog opening it, so that every app is configured in one place. Acceptance: Given a setting changed in Vault, when MediaButler starts, then it uses it. Evidence: ea6d56a (MB-T27).

E5. Build and distribution — MB-T111 — built

F5.1 Install and publish — MB-T112 — built

  • S5.1.1 Brochure page — MB-T117 — built As a visitor, I want a one-page brochure for MediaButler, so that I can see what it does. Acceptance: Given the Pages site, when I open it, then the brochure shows. Evidence: 2afb60c (MB-T70).
  • S5.1.2 Deploy to R: with the shared run menu — MB-T60 — built As the owner, I want run.ps1 to deploy the console app and WPF shell to R:\MindAttic\Apps\MediaButler, so that I run installed builds. Acceptance: Given Release, when Redeploy runs, then both exes start from R:. Evidence: 10bfc7c, ef9f356.

E6. File-moving code proven — MB-T62 — MS-33 (900)

Direct tests for the code that moves, renames and deletes files.

F6.1 Stage tests — MB-T64 — MS-33 (990)

  • T6.1.1 AuditLog tests — MB-T4 — MS-33 As the owner, I want NUnit tests proving each AuditLog.Record appends one NDJSON line, swallows write failures into FailureCount, and resets cleanly, so that the audit-loss warning can be trusted.
  • T6.1.2 FileBotStage tests — MB-T5 — MS-33 As the owner, I want NUnit tests for FileBot outcome mapping, folder syncing, subtitle NeedsManual handling, dry-run skips, Limit and per-item errors, so that the FileBot stage is proven without a live FileBot.

F6.2 Runner and CLI tests — MB-T65 — MS-33 (980)

  • T6.2.1 PipelineRunner orchestration tests — MB-T6 — MS-33 As the owner, I want tests for EffectiveSources, exit-code combining, stage exit codes, the guard bypass and missing-source handling, so that orchestration is proven.
  • T6.2.2 BaseSettings flag overlay tests — MB-T39 — MS-33 As the owner, I want tests for every CLI flag overlay (dry-run vs live, sources, recursive, limit, destinations, no-guard, subtitles, verbosity), so that flags do what they say.

F6.3 Catalog regression tests — MB-T66 — MS-33 (970)

  • T6.3.1 VariationCatalog tests — MB-T46 — MS-33 As the owner, I want tests that seeding keeps user additions and order, path precedence holds, and JSON comments parse, so that my catalog edits are safe.
  • T6.3.2 MasterVariations regression — MB-T47 — MS-33 As the owner, I want a data-driven test running every MasterVariations movie and TV entry through NameParser, so that a parser change can't silently misclassify a known shape.

F6.4 Shell guard tests — MB-T67 — MS-33 (960; moved here from E7 on 2026-11-30, MAT-T470)

  • T6.4.1 Wpf PipelineRunner tests — MB-T42 — MS-33 As the owner, I want tests for the shell runner's console restore, path validation and overlap, Fix Library and Relocate settings, and report caps, so that the shell can't bypass the guard.

E7. MediaButler 5.0.0 released — MB-T63 — MS-33 (800)

One feature by design: this epic is the milestone's closing polish-and-release step.

F7.2 Polish and release 5.0.0 — MB-T68 — MS-33 (880)

  • T7.2.1 Release 5.0.0 — MB-T69 — MS-33 As the owner, I want MediaButler at 5.0.0 with BIBLE §6/§7 and docs/overview.md at the milestone state, so that the verified pipeline is what the docs describe. Acceptance: MediaButler.slnx builds clean; the owner signs off a dry-run then a live run on M:\Torrents.

E8. Every naming case — MB-T118 — MS-163 (700)

The naming shapes cataloged in MasterVariations but not yet converted are filed automatically.

F8.1 Date-based TV — MB-T119 — MS-163 (790)

  • S8.1.1 Daily shows by air date — MB-T120 — MS-163 As the owner, I want Daily.Show.2024.01.15-style files filed into Daily Show - Season 2024 with the date kept for FileBot, so that talk and news shows land in Plex. Acceptance: Given a dated episode, when the pipeline runs, then it lands in the year season; a dry-run shows the plan without moving it.

F8.2 Anime absolute numbering — MB-T121 — MS-163 (780)

  • S8.2.1 Anime absolute episodes — MB-T122 — MS-163 As the owner, I want [Group] Show - 01-style absolute-numbered releases consolidated and matched by FileBot absolute order into Show - Season NN, so that anime files like any other show. Acceptance: Given an absolute-numbered dump, when the pipeline runs, then each episode lands in its season; an unresolvable number is flagged needs-manual, never guessed.

E9. Proven front doors and 6.0 — MB-T123 — MS-163 (600)

F9.1 Desktop shell verified — MB-T124 — MS-163 (690)

  • S9.1.1 Desktop suites on a runner — MB-T125 — MS-163 As the owner, I want MediaButler.Wpf.UiTests and MediaButler.Wpf.AccessibilityTests run by the Orchestrator's test gate on this desktop, so that the WPF shell is verified rather than partial. Acceptance: Given main, when the gate runs, then both suites pass and BIBLE §6 marks the shell verified.

F9.2 Live integration harness — MB-T126 — MS-163 (680)

  • S9.2.1 Live FileBot and OpenSubtitles harness — MB-T127 — MS-163 (requires MB-T125) As the owner, I want an opt-in harness that runs a tiny sample library through real FileBot and OpenSubtitles when the binary and Vault credentials exist, and skips otherwise, so that the live paths are proven. Acceptance: Given FileBot and credentials, when the harness runs, then names, artwork and subtitles come back; without them it reports skipped.

F9.3 Polish and release 6.0.0 — MB-T128 — MS-163 (670)

  • S9.3.1 Release 6.0.0 — MB-T129 — MS-163 (requires MB-T120, MB-T122, MB-T127) As the owner, I want MediaButler at 6.0.0 with the BIBLE and docs/overview.md describing every naming case and the verified shell, deployed to R:, so that the finished tool is what I run. Acceptance: Given the milestone work landed, when I run a dry-run then a live run on M:\Torrents with daily and anime dumps, then the library comes out right.

5. Non-functional requirements

  • Platform: Windows; net10.0-windows console app, WPF shell on net10.0-windows10.0.19041.0.
  • Data and storage: settings and keys through MindAttic Vault; variations.json and the daily NDJSON audit log under the user's app data; no database.
  • Security: no secret in settings.json or FileBot arguments (MB-LAW-7); credentials via Vault only.
  • Safety: dry-run mutates nothing (MB-LAW-1); overlap refusal (MB-LAW-3); size-floored deletes (MB-LAW-4).
  • Accessibility: the shell meets WCAG 2.2 AA (axe-core clean on both tabs).
  • Quality bar: NUnit tests for every behaviour; build-only verification for agents (BIBLE §8).

6. Interfaces and dependencies

  • Platform concerns (docs/ECOSYSTEM.md §2.1): Credentials and settings: MindAttic.Vault. LLM calls: MindAttic.Legion (name fallback). Logging: MindAttic.Log. Shipping: the shared run menu.
  • FileBot (filebot.exe) for TheTVDB/TheMovieDB matching, artwork and OpenSubtitles.
  • MindAttic.Vault for settings, OpenSubtitles credentials and LLM keys; MindAttic.Legion for the LLM fallback.
  • MindAttic.Log for crash and app logging; MindAttic.Agency for the run menu and brochure.
  • Consumers: the owner, scheduled runs (exit codes), MCP clients (mediabutler mcp).

7. Release sequence

  1. MS-33 "MediaButler verified pipeline" (active): E6 Pipeline test coverage (900), E7 Shell guard and release (800, ends with release 5.0.0).
  2. MS-163 "MediaButler 6.0: every naming case, every front door proven" (planned, the finished product): E8 Every naming case (700), E9 Proven front doors and 6.0 (600, ends with polish and release 6.0.0).

8. Change log

Date Change to scope Ticket
2026-11-30 Specification written from the BIBLE, RFC 0001, docs/overview.md, the code and the ticket history. The BIBLE §7 frontier (date-based TV, anime numbering, a desktop runner for the shell suites, a live FileBot/OpenSubtitles harness) became MS-163; the charter's display-only tests and loops moved to the Never list MAT-T391
2026-11-30 MAT-T462 single-source pass: 3 renamed (MB-T62, T63, T68), 0 buckets dissolved (MB-T63 "Shell guard and release" split: shell guard tests MB-T67 moved under MB-T62, MB-T63 is now the 5.0.0 polish-and-release epic), 15 requires added (0 cross-repo), 0 platform re-points MAT-T470
Part of MediaButler.
From MediaButler/docs/SPEC.md via MindAttic.Docs; synced automatically, so edit the repo, not this page.