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.
- AGENTS.mdAGENTS.md
- rust-srec/AGENTS.mdAGENTS.md
- release-rust-srecSkill
- review-testsSkill
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
- Very specific: line 34
No ffmpeg dependency for muxing and no third-party MP4/MPD crate: extend crates/mp4, citing the spec clause, fuzzed, never panicking.
≈ “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.
Files
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.
| Layer | Crates | Purpose |
| Primitives | bytes-util, expgolomb, media-types, amf0, tars-codec, process-utils, proxy-target | Bit/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) |
| Codecs | aac, h264, h265, av1 | Bitstream headers and parameter sets |
| Containers | flv, ts, mp4, hls | FLV 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) |
| Processing | pipeline-common, flv-fix, hls-fix | Generic processor pipeline and writer task; FLV and HLS repair/split operators |
| Engine | mesio (mesio-engine) | HLS, MPEG-DASH and FLV downloader |
| Extraction | platforms (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:MesioDownloaderand per-downloadDownloadSession<T>: guaranteeditemsstream, best-efforteventsstream, cancellationhandle.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 inengine/, 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.rsrefreshes MPDs;planner.rspicks segments per track;mux.rsmuxes video and audio into one fMP4 stream emitted ashls::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.rswith 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::StreamNetworkkeeps a string reason because rust-srec constructs it; the opt-invod_segment_timeoutonly 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 tomax_audio_lagand reportsTrackStalled(seedash/mux.rs).
platforms-parser (crates/platforms)
extractor/factory.rs: theplatform_registry!table mapping URL regexes to extractors, andExtractorSelection(built-in vs. streamlink fallback instreamlink_extractor.rs).extractor/platform_extractor.rs: thePlatformExtractortrait every platform implements.extractor/batch_status.rs: the optionalBatchStatusProbetrait (live/offline for many channels in one anonymous request), found withfactory::batch_probe_for_url; implementations inplatforms/{bilibili,twitch}/batch_status.rs, tested againstserve_onceinextractor/test_support.rs.extractor/platforms/<name>/: one directory per platform.builder.rsis the extractor,models.rsholds API response types,danmu.rsis 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_defaultslists chat providers), shared WebSocket provider, XML writer, statistics.media/:MediaInfoandStreamInforeturned by extractors.- Tests that hit live platforms are
#[ignore]d; keep new ones that way. - Platform notes:
- TikTok's
cmafstream 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
tokenbuilt from the account'sacf_*cookies (app_token()indouyu/app.rs). Signed-in Web needs the session cookies ongetEncryptiontoo, or signing returns 403. Signed-out Web URLs carry a signedexpire=300, so don't rewrite URL parameters.live_signed_in_playback(ignored; setDOUYU_COOKIESandDOUYU_LIVE_URL) checks both paths against a real account.
- TikTok's
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>andPipeline<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_pipelineinpipeline.rsfixes 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 inoperators/, one per file.writer_task.rsowns FLV output files and patchesonMetaData(duration, keyframe index) throughamf/when a file closes.script_modifier.rsis a public post-hoc file patcher with no in-repo callers.hls-fix: operators inoperators/(defragment, segment split, segment limiter),pipeline.rs, andwriter_task.rsfor 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 simpleserderound trips, standard-library/third-party crate behavior, or thin unit tests that duplicate scenarios already covered bycrates/mesio/tests/orrust-srec/tests/.
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
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.

