phase 2 rework

This commit is contained in:
admin_rb committed 2026-10-23 18:19:44 +02:00
1 parent 20054198f3
commit b397ea9256
44 files changed
+5528 -1377

No files matched your search

+33 -5
View File
@@ -2,9 +2,11 @@
Express/EJS submission and status pages, a MongoDB episode queue, Node workers managed by PM2, and Python download entrypoints.
## Phase 1: reliable execution and a protected streaming boundary
## Phase 2: dashboard, worker activity, and reusable session tokens
The Phase 1 changes preserve the original files in `scripts/lib/`, the streaming call sequence, existing CLI entrypoint names, and the established filename conventions. The top bar redesign, full modular execution architecture, expiring job ownership, automatic retries, and enforced bandwidth controls are later phases. See [the rollout roadmap](docs/rollout-roadmap.md).
The interface has a responsive top bar, a default Dashboard, active-download cards per worker, a searchable paginated queue with state-specific clearing controls, and numbered quick-add workers. Series submissions include a separate Season field and an exact filename preview. A supplied token is saved in MongoDB after a successful download-access check and checked again on every new submission. See the [refinement guide and verification report](docs/phase-2-refinements.md).
The user confirmed successful series and single-episode workflows with the first Phase 2 UI, after previously confirming that the verification pause retained and retried the affected episode and completed the queue. These refinements preserve that execution behavior and every original file in `scripts/lib/`. Worker identity is diagnostic metadata; durable ownership, recovery, shared execution modules, and enforced bandwidth controls remain in the [later rollout phases](docs/rollout-roadmap.md).
The current worker records success only when Python exits with code 0, emits exactly one valid completed result, and produces a nonempty regular output file. This is a completion contract, not full media-integrity verification. The protected stream library still writes directly to the target file and cannot resume a partial transfer.
@@ -50,7 +52,7 @@ The test runner checks the entire protected directory before and after all suite
Set `TEST_PYTHON` to an absolute interpreter path when the test interpreter should differ from `python3`. The protected check covers all seven original files, their executable flags, exact directory entries, additions, deletions, and symlinks. The frozen baseline must not be regenerated to hide an unexpected change.
The current Phase 1 run, including the unresolved-link pause fix, passed **158 tests** (114 Node and 44 Python). See the [verification report](docs/phase-1-verification.md) for coverage, runtime versions, and the remaining deployment checks.
The current refinement run passed **258 tests** (214 Node and 44 Python), plus **42 browser checks**. The [current refinement report](docs/phase-2-refinements.md) records the expanded verification and deployment scope; the [initial UI report](docs/phase-2-ui.md) and [Phase 1 report](docs/phase-1-verification.md) preserve their earlier baselines.
## Start locally
@@ -66,6 +68,29 @@ npm run worker
The worker-management page creates workers using the configured checkout and current Node interpreter. It only lists and controls PM2 processes whose executable is this checkout's `queue_worker.js`; unrelated services are excluded. PM2 IDs are resolved on the server. Saving the host-wide PM2 process list is a deployment operation (`pm2 save` as the download account), so the web control is removed.
## Using the interface
- **Dashboard** (`/`): see current claims by worker, waiting/active/history counts, and the latest five completed and five failed-attempt records. Each summary links to the relevant full queue or history.
- **New download** (`/download`): choose Series or Single episode and check the filename preview. Series has a Season field, defaulting to 1. Leave the token blank to use the saved token, or paste a replacement. Each submission checks access before adding any jobs.
- **Queue** (`/status`): choose Queued, Active, Completed, or Failed attempts. Search filenames and choose 10, 25, or 50 results per page. Refresh preserves expanded logs, filters, and unsent search input. The danger button beside Refresh clears the selected waiting/history state after confirmation; Active has no clear operation.
- **Workers** (`/pm2`): use **Quick add worker** for `proxer-worker-1`, `proxer-worker-2`, and subsequent numbers. The counter persists in MongoDB and avoids existing PM2 names. Custom names remain available. Select a worker to inspect metrics and logs or start/stop/restart/delete it. Disruptive commands ask for confirmation.
The dashboard and queue show a card for each managed worker. A newly claimed job carries a startup identity so it can be matched to the correct live process. Legacy claims and ambiguous/stale assignments remain visible without guessing. File sizes describe the current file on disk; there is no guessed percentage or speed. Restart workers after installing this refinement so subsequent claims carry identity metadata.
The status API returns one selected page in `items`, together with `counts`, `pagination`, `filters`, `global`, and bounded `activity`. It accepts `state`, `q`, `page`, and `pageSize`. `/status-summary` stays count-only, while `/dashboard-data` returns overview counts, activity, and bounded recent history. See the [API details](docs/phase-2-refinements.md#api-and-data-additions).
Queue/history clearing applies to all records in the selected state, including those outside the current filter or page. Clearing history keeps media files on disk. Active processing flags remain protected.
### Saved session token
The cache is a single document in the existing MongoDB `settings` collection (`_id: "proxer-session-token"`), shared by this application deployment. The token field is always empty when a page is rendered; safe metadata reports whether a token is saved and the last successful check. No token is sent back in HTML/JSON, stored in browser storage, or added to a URL.
Each submission checks the first requested episode's source page using the configured cookie and stream preference. It requires the same positive embed-code evidence as the protected resolver, with a 12-second timeout and 1 MiB response limit. It performs no media transfer and never follows redirects with the cookie. HTTP 200 alone is insufficient.
A rejected token prompts for a replacement and prevents enqueueing. Verification challenges, missing sources, unfamiliar responses, and connection failures have separate warnings and keep the saved token. A successful replacement is saved only after validation. Revision checks prevent an older in-flight request from erasing or overwriting a newer saved token.
This validates download access at submission time; it does not prove account identity or guarantee the token will remain usable during a long queue. Existing queued jobs retain their original token. The existing worker pause/verification flow still handles failures after enqueueing. MongoDB access and backups protect the cached credential just as they protect credentials already held in queue records.
## Submission and filenames
Only HTTPS Proxer watch URLs on `proxer.me` or `www.proxer.me` are accepted. The URL must identify a positive integer series ID, positive integer episode, and one of `engsub`, `engdub`, `gersub`, or `gerdub`. Fragments and an optional trailing slash are normalized away. Query parameters, credentials in URLs, and custom ports are rejected.
@@ -74,10 +99,11 @@ Only HTTPS Proxer watch URLs on `proxer.me` or `www.proxer.me` are accepted. The
|---|---|
| Web video with title | Explicit legacy `filename`, then the form's `name` |
| Web video without title | `{id} E{episode} {language}` |
| Web series | `{trimmedNameOrId}E{paddedEpisode}_{language}` |
| Web series with Season | `{trimmedNameOrId}S{season:03}E{episode:03}_{language}` |
| Legacy web/API series without `season` | `{trimmedNameOrId}E{paddedEpisode}_{language}` |
| Standalone series CLI | `{name}_Episode_{episode}_{language}` |
Web series padding uses the width of the highest requested episode. All destinations are validated before a batch is queued. Filenames must be single names inside the configured directory; symlink and non-file targets are rejected. The corrected video-title fallback is intentional. [Compatibility fixtures](tests/fixtures/legacy-contracts.json) record the original conventions.
The current form always submits a season: for example, `My SeriesS001E009_engsub.mp4`. Season and episode use a minimum of three digits and expand beyond 999. Season 0 represents specials. Season affects only the filename, not the source episode numbers; there is no automatic season-to-absolute-episode mapping. Enter the title without an existing season/episode suffix. Legacy clients that omit `season` retain padding based on the highest requested episode. Existing files and queue names are not renamed. All destinations are validated before a batch is queued. Filenames must be single names inside the configured directory; symlink and non-file targets are rejected. The corrected video-title fallback is intentional. [Compatibility fixtures](tests/fixtures/legacy-contracts.json) record the original conventions.
## Python CLI compatibility
@@ -111,6 +137,8 @@ The blanket `clear-processing` operation is disabled and returns HTTP 409. Phase
## Documentation
- [Phase 2 refinements, token cache, and verification](docs/phase-2-refinements.md)
- [Initial Phase 2 interface baseline](docs/phase-2-ui.md)
- [Phase 1 baseline and compatibility boundary](docs/phase-1-baseline.md)
- [Phase 1 verification report](docs/phase-1-verification.md)
- [Unresolved-link pause fix and recovery](docs/phase-1-resolution-fix.md)