Medlar/docs/PROGRESS.md
astar76 9ff6bd8876 S002: test server with faults, fixtures and proxy stubs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 23:40:52 -06:00

3.6 KiB

Progress

One entry per session, newest last, ≤ 15 lines: done, verified how, not done, later.

S001 — Workspace, store, settings and strings (2026-11-24)

Done: four crates; core has paths, model, store, settings, strings, logging, redact. No egui dependency yet: the first UI plan adds it to crates/app. Verified: nice cargo test -j 2 green (34 tests; kill test run 5 times, 5 kills each), build without warnings, --version prints 0.1.0, a made-up tr! key fails the test.

  • Store (store::Store, share in Arc): open, add_task/save_task/set_state/delete_task/task/tasks, save_parts (waits) / post_parts (journal, doesn't), parts, save_queue/queues/delete_queue, tags, save_host/host. Calls block briefly: use spawn_blocking from async. State and error change only through set_state (model::State::moves). Migration number 1 (store/001.sql); add 002.sql to MIGRATIONS, never edit 001.
  • Secrets: secret columns hold a keyring item name. The store refuses cookie/authorization headers and user:password@ links. A token inside a link's query is stored (it is the link) but never logged.
  • Settings: Settings::load(path) -> (Settings, Option<Damage>), save, limits(). Speed-mode numbers and the own colour are placeholders. Bad single values fall back alone.
  • Strings: add the key to crates/core/lang/en.json, use tr!("key", name = value); plurals are objects chosen by n; run-time keys use strings::text and need their own test. User files: <config>/languages/<code>.json.
  • Logging: logging::init(&paths.log(), level); every line is redacted. Nothing calls it, Paths::create or Store::open from the binary yet: whoever starts the engine does.
  • ErrorKind is empty (S007): add variants and error.<name> texts. Not done: statistics and quota tables (their plans add a migration).

S002 — Test server with faults (2026-11-24)

Done: crates/testserver (hand-made HTTP/1.1 on tokio, 127.0.0.1 only), binary medlar-testserver [--port N] [--tls] [--media] [--proxies]. Verified: nice cargo test -j 2 -p medlar-testserver green (44 tests, ~1 s, one per fault and fixture); clippy clean; zip/tar checked with unzip/bsdtar.

  • API: TestServer::start()/start_tls() (async, port 0), url(path), log()/requests_for(path)/clear_log(), set_faults(path, Faults) (exact, prefix*, or *), clear_faults, open_connections(), build_media() (ffmpeg → /media/), cert_der() for HTTPS clients. Content: expected(seed, start, len).
  • Files: /data/<seed>/<len>[/name] (len takes k m g t; 100g ok). Query: disp=attachment|bare|star|both|inline|evil|dotfile, chunked=1, nolen=1, etag=0, lm=0, weak=1. Also /redirect/<n>?to=&code=, /redirect/loop, /status/<code>, /basic|digest/<u>/<p>/…, /cookie/<tok>/login, /referrer/<needle>/…, /dir/, /site/, /archive.zip|tar, /sum/<algo>/<seed>/<len>, /meta/v4.meta4|v3.metalink|header.bin.
  • Faults (field of Faults, or same name in the query): throttle_conn, throttle_total (bytes/s), latency_ms, stall_after (+stall_ms), cut_after (clean close), reset_after (RST), status (+retry_after, status_count), wrong_length (added to Content-Length), ignore_range, change_after (bytes switch), version_after_requests (new ETag, date, bytes), gzip (header only, body stays plain), expire_secs / expire_requests (+expire_status, default 403), max_conns (open connections per client; over it → 429).
  • Proxies: proxy::Proxy::start_http(auth) / start_socks5(auth); seen() lists kind, target, credentials, allowed; they connect only to loopback or names set with map_host. Not done: BLAKE3 sidecar, HTTP/2, a real gzip body, FTP/SFTP servers (their plans).

Later