agentleFS
hua0512hua0512/rust-srec/crates/AGENTS.md

rust-srec / crates

AGENTS.md121 starsChanged 8 days agoApache-2.0View on GitHub

These notes apply to the library crates under crates/. Repository-wide rules still apply. Package names differ from directory names in three places: crates/mesio is mesio-engine, crates/platforms is platforms-parser, and the mesio package is the CLI in mesio-cli/. Lower layers never depend on higher ones. Changing a lower crate affects every consumer above it, so widen validation accordingly. Consumers: rust-srec uses every processing/engine/extraction crate; mesio-cli uses the engine and processing crates; strev-cli uses only platforms-parser. Design doc: docs/HLS_ENGINE_ARCHITECTURE.md (segment engine; read…

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 35,040 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository4 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    No ffmpeg dependency for muxing and no third-party MP4/MPD crate: extend crates/mp4, citing the spec clause, fuzzed, never panicking.

    line 34

≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Library crates AGENTS.md

These notes apply to the library crates under crates/. Repository-wide rules still apply. Package names differ from directory names in three places: crates/mesio is mesio-engine, crates/platforms is platforms-parser, and the mesio package is the CLI in mesio-cli/.

Dependency layers

Lower layers never depend on higher ones. Changing a lower crate affects every consumer above it, so widen validation accordingly.

LayerCratesPurpose
Primitivesbytes-util, expgolomb, media-types, amf0, tars-codec, process-utils, proxy-targetBit/byte readers, Exp-Golomb, shared Resolution/SplitReason/codec info, AMF0, Tencent TARS codec (Huya), child-process helpers, the proxy endpoint and target types shared by platforms-parser and the backend (srec-core re-exports them)
Codecsaac, h264, h265, av1Bitstream headers and parameter sets
Containersflv, ts, mp4, hlsFLV tag/header parsing and writing (incl. Enhanced RTMP, see flv/enhanced-rtmp-v2.md), MPEG-TS packets/PSI/PES/SCTE-35, ISOBMFF/fMP4 boxes and track merging, HLS segment data (HlsData, TS/fMP4 segments, stream profiles)
Processingpipeline-common, flv-fix, hls-fixGeneric processor pipeline and writer task; FLV and HLS repair/split operators
Enginemesio (mesio-engine)HLS, MPEG-DASH and FLV downloader
Extractionplatforms (platforms-parser)Platform stream URL extraction and danmaku (live chat)

Consumers: rust-srec uses every processing/engine/extraction crate; mesio-cli uses the engine and processing crates; strev-cli uses only platforms-parser.

mesio-engine (crates/mesio)

Design doc: docs/HLS_ENGINE_ARCHITECTURE.md (segment engine; read before changing scheduling, store or assembly). README.md shows the public API and the session contract (guaranteed items vs. best-effort events).

  • session.rs: MesioDownloader and per-download DownloadSession<T>: guaranteed items stream, best-effort events stream, cancellation handle.
  • protocol_builder.rs, builder.rs, config.rs, source.rs: protocol builders, shared config, source selection and fallback.
  • segment_engine/ (crate-private): protocol-neutral core shared by HLS and DASH. identity.rs (segment identity), store.rs (authoritative lifecycle state), reactor.rs (scheduling), budget.rs/throttle.rs (byte budgets, backpressure), fetch.rs (download + decrypt), assembler.rs (ordered output).
  • hls/: playlist watcher and planner in engine/, AES decryption, platform quirks (twitch_processor.rs, soop_processor.rs).
  • dash/: manifest/ is pure MPD parsing/resolution with no I/O (parse.rs, resolve.rs, timeline.rs, template.rs, clock.rs); watcher.rs refreshes MPDs; planner.rs picks segments per track; mux.rs muxes video and audio into one fMP4 stream emitted as hls::HlsData.
  • flv/: FLV HTTP downloader.
  • cache/, rate_limit.rs, proxy.rs, redact.rs: caching, rate limiting, proxy config, URL/secret redaction for logs.
  • Tests: tests/hls_engine.rs, tests/dash_engine.rs, tests/dash_manifest.rs with local fixtures.

Design decisions (ask before reversing):

  • No ffmpeg dependency for muxing and no third-party MP4/MPD crate: extend crates/mp4, citing the spec clause, fuzzed, never panicking.
  • DRM (CENC) is out of scope; protected content fails with a typed error.
  • Known limits kept on purpose: HLS progress counts bytes from failed attempts (real network traffic); DownloadError::StreamNetwork keeps a string reason because rust-srec constructs it; the opt-in vod_segment_timeout only arms once a later segment has arrived; one slow VOD segment can hold the 80% byte window (skipping instead used to drop segments still in flight); a DASH encoder restart that reuses segment numbers ends through the 60 s stall watchdog; a video-only DASH Period waits up to max_audio_lag and reports TrackStalled (see dash/mux.rs).

platforms-parser (crates/platforms)

  • extractor/factory.rs: the platform_registry! table mapping URL regexes to extractors, and ExtractorSelection (built-in vs. streamlink fallback in streamlink_extractor.rs).
  • extractor/platform_extractor.rs: the PlatformExtractor trait every platform implements.
  • extractor/batch_status.rs: the optional BatchStatusProbe trait (live/offline for many channels in one anonymous request), found with factory::batch_probe_for_url; implementations in platforms/{bilibili,twitch}/batch_status.rs, tested against serve_once in extractor/test_support.rs.
  • extractor/platforms/<name>/: one directory per platform. builder.rs is the extractor, models.rs holds API response types, danmu.rs is the chat provider; signing/auth helpers live beside them (douyin/abogus.rs, bilibili/wbi.rs, douyu/app_sign/, huya/tars/).
  • danmaku/: provider trait, registry.rs (ProviderRegistry::with_defaults lists chat providers), shared WebSocket provider, XML writer, statistics.
  • media/: MediaInfo and StreamInfo returned by extractors.
  • Tests that hit live platforms are #[ignore]d; keep new ones that way.
  • Platform notes:
    • TikTok's cmaf stream is a live DASH MPD and is opt-in (format_opt_in); FLV stays the default.
    • Douyu: the App endpoint gets origin quality only with the token built from the account's acf_* cookies (app_token() in douyu/app.rs). Signed-in Web needs the session cookies on getEncryption too, or signing returns 403. Signed-out Web URLs carry a signed expire=300, so don't rewrite URL parameters. live_signed_in_playback (ignored; set DOUYU_COOKIES and DOUYU_LIVE_URL) checks both paths against a real account.

Adding a platform touches, besides its directory: extractor/platforms.rs, the registry in extractor/factory.rs (a batch status probe, if any, attaches to the platform's entry with ; batch: PROBE), extractor/platform_configs.rs if it has settings, danmaku/registry.rs if it has chat, crates/platforms/README.md, strev-cli/src/commands.rs (list_platforms), a backend migration seeding its platform_config row (e.g. rust-srec/migrations/20260715000000_add_soop_platform.sql) and rust-srec/crates/srec-recorder/src/proxies/probe.rs, frontend src/lib/utils.ts, src/components/pipeline/constants.tsx and src/api/schemas/platform-configs.ts, the docs pages under rust-srec/docs/{en,zh}/platforms/, and the platform lists in the root README.md/README.zh-CN.md.

Processing crates

  • pipeline-common: Processor<T> and Pipeline<T> (processor.rs, pipeline.rs), threaded pipelines (channel_pipeline.rs), generic writer task with file rotation (writer_task.rs), manual split control, progress reporting, StreamerContext (cancellation and shared state).
  • flv-fix: FlvPipeline::build_pipeline in pipeline.rs fixes the operator order, which is significant: defragment → header check → split → GOP sort → duplicate filter (optional) → time consistency → timing repair → limit → time consistency → keyframe filler (optional) → script filter (the last two are skipped in pipe mode). Operators are in operators/, one per file. writer_task.rs owns FLV output files and patches onMetaData (duration, keyframe index) through amf/ when a file closes. script_modifier.rs is a public post-hoc file patcher with no in-repo callers.
  • hls-fix: operators in operators/ (defragment, segment split, segment limiter), pipeline.rs, and writer_task.rs for TS/fMP4 output.

Backend touchpoints

Backend consumers live in rust-srec/crates/srec-engines/src/ (per-engine adapters, mesio/ for this engine) and, in rust-srec/crates/srec-recorder/src/, danmu/ (danmaku service), credentials/platforms/ (platform login/cookie refresh), monitor/ (live checks via extractors) and proxies/.

Testing

Apply the root testing bar to library crates:

  • Do test: binary/wire protocol parsing edge cases and malformed inputs, signing/redaction/auth helpers, stream-repair operator invariants and ordering, segment-engine state transitions, concurrency/cancellation/backpressure, and fault injection.
  • Do not test: Default, Clone, Debug, Display, trivial getters/builders, struct-literal or simple serde round trips, standard-library/third-party crate behavior, or thin unit tests that duplicate scenarios already covered by crates/mesio/tests/ or rust-srec/tests/.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.