# COMMON CHARTER PREAMBLE — batch 2026-09-01 (ec-av1 decode, his real films) GOAL (why): ec-av1 must decode the user's two real AV1 films bit-exact (`/home/user/Videos/Films/reelc.mkv`, `/home/user/Downloads/reelb.mkv`, both yuv420p10le). 47 refusal strings remain in crates/ec-av1/src/refusal_inventory.rs. Each lane lifts its cluster of refusals WITH a real-aomenc gate proving it. WORKING RULES (binding): - Work ONLY in your worktree; branch named in your charter. Never touch main, never merge into main, never `git checkout ` to revert (copy to scratch first). - `export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-` (named in charter) for EVERY cargo command. sccache is the global rustc wrapper. Use `nice -n 10 cargo ... -j3` — 10 lanes run concurrently on 12 cores / 30G RAM. Long/lavfi runs under `systemd-run --user --scope -p MemoryMax=8G` and bound ffmpeg with `-t`. - Test scope: `cargo test -p ec-av1 --lib` only (plus `cargo check -p ec-av1`). Never the workspace suite. Set `EC_AV1_REQUIRE_AOMENC=1` so an absent oracle FAILS, never SKIPs. - Oracle: `~/.cache/aom-oracle/build/aomenc` and instrumented `aomdec` (scripts/build-aom-oracle.sh, scripts/instrument-aom-oracle.sh; rungs EC_TRACE=1 / EC_TRACE_COEFF=1 / EC_TRACE_MODE=1 / EC_AV1_PREFILT_DUMP). Ours: EC_TRACE_COEFF / EC_TRACE_MODE / EC_TRACE_MODE_STEP in decode.rs. Cross-decoder bisection compares msac RANGE element by element, never tell(). The reference is at the oracle source tree (find via scripts/build-aom-oracle.sh). - FIRST STEP, always: `git log --oneline -8 main` and MERGE main into your branch (`git merge main`; never rebase a branch a merge agent may already have taken; resolve conflicts keeping BOTH sides' features, re-read every hand-resolved function). A charter line saying "never rebase/merge" means never rebase and never merge OTHER lanes; merging main is always the first step. Then RE-MEASURE your lane's premise before building — charters may carry stale premises. Cite the command that produced every premise you act on. - Fixtures: `fixtures` is a symlink to main's fixtures dir (shared). Pin any new stream fixture under crates/ec-av1/fixtures/ or fixtures/ with a hash; hash an aomenc output TWICE before trusting a seed (lavfi gradients ignores its seed). - A refusal is lifted ONLY together with a gate: a real-aomenc stream (tool explicitly enabled on the aomenc command line) decoded pixel-exact vs ffmpeg/aomdec, that HARD-ASSERTS a hit counter proving the feature fired, and never turns a decode error or pixel mismatch into SKIP. Update refusal_inventory.rs + gate_coverage.rs in the same commit. `refusal_inventory` and `gate_coverage` tests must stay green. - Defect classes to check first (memory-proven, each cost rounds): CDF row indexed by a field that moves; table indexed by RAW vs adjusted tx_size; scan/ctx tables transposed vs spec (libaom layout is not the spec's — gate on asymmetric behaviour); neighbour ctx read from one cell instead of gathered over the span; a symbol we read that the reference never wrote (reference range unchanged = unread); a header field parsed then never consumed; counter-reset list missing a table; call-site arg order; a probe loop reusing last run's output file (rm -f first, check exit status). - Tool-call ceiling ~70. If you hit it: commit everything on your branch, write `lanes/-r.handoff.md` with exact facts (ranges, stream, element) so a fresh agent continues without re-reading. - DONE = commit(s) on your branch + `lanes/-r.report.md` in your worktree with: what changed (path:line), gate name + command + result, refusals lifted, test totals (`cargo test -p ec-av1 --lib` passed/failed/ignored), and EVIDENCE lines of the form `EVIDENCE: | | `. State open residue with fix-now | deferred() | accepted. Never claim "done" beyond what you ran. - Film check, when your lane targets a film blocker: extract 0.4s with `ffmpeg -t 0.4 -i -c:v copy -f obu .obu` (bounded), run `cargo run -p ec-av1 --example decode_probe -- .obu` before and after; report the refusal string each film now stops at. VERIFIERS (added 2026-09-01 22:40 after a verifier left a lane worktree on a detached HEAD while its builder was mid-round): a verifier NEVER runs `git checkout`, `git switch`, `git stash` or any tree-changing git command inside a lane worktree. To test a specific commit, `git worktree add --detach /tmp/claude-1000/.../scratchpad/verify- ` with its own CARGO_TARGET_DIR, and remove it when done. NEIGHBOUR MAPS (added 2026-09-02 00:50, class new-map-ignores-tile-edge): any per-mi side band you add or inherit (mode, uv_mode, skip, ref, filter, txfm ctx, palette) MUST (1) guard availability with `mi_r > tile_row0_mi` / `mi_c > tile_col0_mi`, never `> 0`; (2) be reset in start_tile AND start_row; (3) have a `--tile-columns=1` arm in the lane's gate. Gate Err arms tolerate ONLY messages containing "unsupported"; lavfi sources carry an explicit seed (noise=all_seed=N) and the report shows two identical hashes. SIBLING GATES (added 2026-09-02 03:00, rectsplit r3): a root-cause fix that turns YOUR gate green is not done until every gate that exercises the same tables/paths (grep the table name and the function in stream.rs) is re-run — rectsplit r2 shipped a transposition that fixed its gate and broke the merged SB HORZ/VERT gate at seed 43. Run the siblings before writing "root cause". FORMAT + LOGS (added 2026-09-02 03:30): never run a repo-wide `cargo fmt` in a lane (txselect carried 5000 lines of churn that the merge had to strip; format only files you touched, or not at all). Suite logs go to a PRIVATE path (`$CARGO_TARGET_DIR/../-suite.log`), never a shared scratchpad name — another session overwrote a verifier's log mid-run. ## AOMENC FLAG PRECEDENCE (measured 2026-09-02 08:45, md5 of 4 orderings) aomenc keeps the LAST occurrence of a repeated `--enable-*` flag. Per-arm overrides go AFTER the base recipe. Every gate proves its flag arrived through a decoder-side counter or a header field; a counter at 0 means the flag did not arrive or the encoder declined — never weaken the assert. ## SUITE RUNS (3 self-kills on 2026-09-02; setsid -f ALSO died ~10 min in, twice) Run the full suite as a user systemd unit — the only form that survived every time today: `systemd-run --user --unit=-suite-$(date +%s) -p MemoryMax=10G --same-dir bash -lc 'EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target- nice -n 10 cargo test -p ec-av1 --lib -j3 > $HOME/.cache/-suite.log 2>&1'` Then continue other work; check with single instantaneous `grep -E "^test result|FAILED" ` calls. NEVER wait with a foreground `until/while ... sleep` loop or `tail --pid`. ## NEVER pkill BY BINARY NAME (2026-09-02: one lane's `pkill -f ec_av1-` killed another lane's suite) The test binary hash is identical across worktrees. Kill only by PID you own (`$!`, or the systemd unit name you started). `pkill -f`/`killall` on cargo/ec_av1 patterns is forbidden. ## NEVER `cargo fmt` IN A LANE (3 lanes lost their diffs to it on 2026-09-02) main is not rustfmt-clean (~6000 lines of churn). Hand-indent; `cargo test --no-run` is the check. If you ran it: extract your own hunks, `git checkout -- crates/`, re-apply. ## MEMORY (user order 2026-09-02: an unsteady box fails the job) 30 GB box shared by ~10 agents. Every decode/encode/probe invocation runs under `systemd-run --user --scope -q -p MemoryMax=6G `; suites under a unit with `-p MemoryMax=10G`; never two suites per lane; film extracts ≤2 s; a watchdog (`ec-memwatch` user unit, log `$HOME/.cache/ec-memwatch.log`) SIGKILLs any codec/test process above 6 GiB RSS or the largest one when MemAvailable < 3 GiB — a killed run means YOUR command exceeded the budget: bound it, do not retry as-is. ## WORKTREE SETUP (2026-09-02, three lanes lost a round to this) A new worktree needs the TOP-LEVEL fixtures symlink: `ln -s /home/user/Documents/Code/Rust/edith_codecs/fixtures /fixtures`. Without it exactly one gate fails: a_real_aomenc_stream_with_film_grain_decodes_pixel_exact with Os NotFound — it is NOT a decode defect. New files under crates/ec-av1/fixtures/ need `git add -f` (bare `fixtures` in .gitignore); verify with `git ls-files`. Commit-msg hook rejects film titles / home paths: describe streams by codec/resolution/bit depth.