fix(audio): establish canonical local-audio resource policy - #866
fix(audio): establish canonical local-audio resource policy#866seonghobae wants to merge 536 commits into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Stale comment
Reviewed exact head
3f976e55. Local-file Python, TypeScript, and Rust encoded-byte ceilings match (100 MiB, exclusive upper bound, exact ceiling accepted). Do not mark Ready or merge this draft until YouTube download uses that same ceiling and #865 is in protecteddevelop.Request changes:
import_youtube_urlnow callsvalidate_local_audio_file_sizeonly afteryoutube.pyhas already finished. That module still downloads with no yt-dlpmax_filesizeand then rejects> 50 * 1024 * 1024. A 60–100 MiB import that policy-v1 would accept is still rejected with a 50 MB message. A multi-gigabyte transfer can fill the cache root before the new native check ever runs, so the new YouTube-path size check is dead for oversized inputs.Doctoring residual-risk text on this head still says the desktop/Rust intake path is not established, which is no longer true for local-file bootstrap.
The successor branch
cursor/bc-977eae6a-247d-427f-a2eb-533a75284f2e-6591drives YouTube admission fromDEFAULT_MAX_ENCODED_FILE_BYTES, aborts in-flight, and updates the evidence note. Apply that here or reconstruct this branch onto it before Ready.Checks on this synchronization were still queued at review time. Queued, skipped, predecessor, or draft-skipped CodeRabbit evidence is not success.
Sent by Cursor Automation: fix all
There was a problem hiding this comment.
Stale comment
Reviewed exact head
1f3fdb8b. The prior 50 MB / missingmax_filesize/ stale doctoring findings are fully addressed: YouTube download now usesDEFAULT_MAX_ENCODED_FILE_BYTES, rejects announced oversize beforedownload=True, aborts from the progress hook, and revalidates the written file. Do not mark Ready or merge this draft until #865 is in protecteddevelopand the abort-path cache leak below is on this head.Request changes: in-flight abort still returns
size_exceededwithout deleting bytes already written. yt-dlp HttpFD writes the current block, then calls the hook; on exception it only closes the stream. The post-download path deletes an oversize final artifact; the abort path does not. Each rejected import can leave*.part,*-Frag*, and*.ytdlin a fresh project cache.Successor
cursor/bc-75568fe4-aa90-4cf7-bb40-c9d68be95b82-b46fat5e8fa77fdeletes owned siblings that stay inside that importout_dirand ignores escaped paths. Apply that here or reconstruct this branch onto it before Ready.Queued, skipped, predecessor, or draft-skipped CodeRabbit evidence is not success.
Sent by Cursor Automation: Fix Issues
There was a problem hiding this comment.
Reviewed exact head 5e8fa77f on fix/audio-resource-policy-781 (base develop@acdbea63). The prior in-flight abort finding is fully addressed on this head: _abort_over_budget_download deletes owned siblings before the fail-closed size_exceeded raise. _owned_file_path realpaths the candidate and the import out_dir, rejects the directory root, and requires resolved.startswith(root + os.sep), so a path or symlink that escapes that import directory is ignored. _remove_download_artifacts stems tmpfilename / filename (one .part strip) and removes matching stem, stem.*, and stem-* entries, which covers .part, .ytdl, and -Frag*. test_download_youtube_audio_progress_hook_deletes_partial_artifacts proves those three are gone after abort while keep-me.txt and an outsider .part remain.
The earlier 50 MB post-write, missing Rust intake doctoring, CHANGELOG 50 MB, and progress-hook int-only items stay fixed. YouTube admission uses DEFAULT_MAX_ENCODED_FILE_BYTES (100 MiB) in Python, desktop analysis.ts, and native audio_resource.rs. Announced oversize rejects before download=True. Exact 100 MiB is accepted; 60 MiB is accepted; 100 MiB + 1 is rejected. Closed #875 is the same tree as this head — do not reopen a competing abort-cleanup owner.
Next action: keep this Draft. Integrate #865 into protected develop first, then reconstruct and revalidate this stack on the unchanged resulting exact head. Do not mark Ready or merge on queued, skipped, predecessor, or CodeRabbit draft-skipped evidence. Remaining #781 channel/rate contracts and decoded-memory / CPU/GPU admission budgets are still out of this draft's claim — do not treat policy-v1 encoded-byte admission as full #781 closure.
Residual (not a change request): a process kill, a locked Windows .part, or a differently named format-id fragment can still leave cache bytes until that per-project import directory is removed. Generic DownloadError / timeout paths do not sweep unnamed artifacts. Admission still fails closed.
Sent by Cursor Automation: Fix Issues
|
@opencode-agent Take the canonical #781 owner lane on the existing First repair the exact current-head CI blocker with repository-pinned tooling, not guessed formatting: CI run Then, on the resulting exact head, preserve the unique non-duplicative #781 evidence currently stranded in competing PR #985 (
Run focused RED→GREEN tests, repository-pinned Ruff check/format, Bandit, mypy where applicable, then canonical quickcheck. If a finding belongs to #865 or #783 rather than this exact branch, prove the first causal boundary and leave it with its owner rather than adding a leaf workaround. Commit only to this branch and report resulting exact head and evidence. |
|
@OpenCode repair exact head |
|
@opencode-agent Please review the current exact PR head |
|
Exact-head maintenance update for 505a595:
Keep Draft; predecessor evidence does not transfer. |
|
@opencode-agent review\n\nReview only current PR head 505a595 against protected develop base 749511c. Revalidate the canonical local-audio resource policy, source metadata preflight before decode, post-decode limits, empty-layout chord handling, payload-safe diagnostics, exact tests, and current security checks. Do not reuse predecessor-head evidence or provider-unavailable results. |
|
@coderabbitai review Please review only current exact source head |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
repo="ContextualWisdomLab/bandscope"
head="4704db0ae24e8c6183fd6ed10385e126024abd6c"
red_prefix="a1eaeadc"
repair_prefix="4fa56489"
ruff_failure="c400e652079b59e70816114538072278edddaea9"
numbered() { awk '{printf "%6d\t%s\n", NR, $0}'; }
echo "== Exact head identity =="
git cat-file -e "${head}^{commit}"
git show -s --format='%H%n%P%n%s%n%b' "$head"
printf 'checkout=%s\n' "$(git rev-parse HEAD)"
test "$(git rev-parse HEAD)" = "$head"
echo "== Requested repair commits =="
for prefix in "$red_prefix" "$repair_prefix" "$ruff_failure"; do
commit="$(git rev-list --all | grep -i "^${prefix}" | head -n 1 || true)"
printf '%s %s\n' "$prefix" "$commit"
test -n "$commit"
done
red="$(git rev-list --all | grep -i "^${red_prefix}" | head -n 1)"
repair="$(git rev-list --all | grep -i "^${repair_prefix}" | head -n 1)"
echo "== Requested lineage and changes =="
git merge-base --is-ancestor "$red" "$head"
git merge-base --is-ancestor "$repair" "$head"
git merge-base --is-ancestor "$ruff_failure" "$head"
git log --format='%H %P %s' --ancestry-path "${red}..${head}"
for commit in "$red" "$repair" "$ruff_failure" "$head"; do
echo "-- $commit"
git show -s --format='%H %P %s%n%b' "$commit"
git diff-tree --no-commit-id --name-status -r "$commit"
done
echo "== Files changed after the known Ruff failure =="
git diff --name-status "$ruff_failure" "$head"
git diff --check "$ruff_failure" "$head"
git diff --unified=120 "$ruff_failure" "$head" -- \
services/analysis-engine/src services/analysis-engine/tests docs
echo "== Map exact cache-related modules and tests =="
fd -t f -e py . services/analysis-engine/src services/analysis-engine/tests \
| rg '(feature_cache|cache.*admission|local_audio|role|stem)' || true
ast-grep outline services/analysis-engine/src/bandscope_analysis/feature_cache_admission.py --items all
rg -n -C 5 \
'def _load_cached_local_audio_features|def load_bounded_stem_archive|stemRoleTypes|stem_role|canonical.*role|role.*canonical' \
services/analysis-engine/src services/analysis-engine/tests --glob '*.py' || true
echo "== Exact first-read loader, archive admission, and role helpers =="
for path in $(fd -t f -e py . services/analysis-engine/src); do
if git show "${head}:${path}" 2>/dev/null | rg -q \
'(_load_cached_local_audio_features|stemRoleTypes|load_bounded_stem_archive|canonical.*role|role.*canonical)'; then
echo "-- $path"
git show "${head}:${path}" | numbered | rg -n -A220 -B45 \
'(_load_cached_local_audio_features|stemRoleTypes|load_bounded_stem_archive|canonical.*role|role.*canonical|sidecar|metadata)' || true
fi
done
echo "== RED, production repair, and exact tests for role replacement =="
for commit in "$red" "$repair"; do
echo "-- patch $commit"
git show --format=fuller --unified=180 "$commit" -- \
services/analysis-engine/src services/analysis-engine/tests
done
for path in $(fd -t f -e py . services/analysis-engine/tests); do
if git show "${head}:${path}" | rg -q \
'(stemRoleTypes|role.*replacement|replacement.*role|bass.*vocal|vocal.*instrument|cached_local_audio_features)'; then
echo "-- $path"
git show "${head}:${path}" | numbered
fi
done
echo "== Direct cache replay and role assignment inventory =="
git grep -n -E \
'(np\.load[[:space:]]*\(|load_bounded_stem_archive[[:space:]]*\(|stemRoleTypes|stem_role_types|["'\'']role["'\'']|canonical_stem)' \
"$head" -- services/analysis-engine/src -- '*.py' || true
echo "== Exact-head current checks and PR state =="
gh api "repos/$repo/commits/$head/check-runs?per_page=100" \
--jq '.check_runs[] | [.name,.status,.conclusion,.details_url] | `@tsv`'
gh pr view 866 --repo "$repo" \
--json isDraft,headRefOid,baseRefOid,mergeStateStatus,reviewDecision,statusCheckRollup,url
gh api graphql -F owner="ContextualWisdomLab" -F name="bandscope" -F number=866 -f query='
query($owner:String!, $name:String!, $number:Int!) {
repository(owner:$owner,name:$name) {
pullRequest(number:$number) {
reviewThreads(first:100) { nodes { isResolved } }
reviews(first:100) { nodes { author { login } state commit { oid } submittedAt } }
}
}
}' --jq '
.data.repository.pullRequest as $pr |
{
unresolved_threads: ([$pr.reviewThreads.nodes[] | select(.isResolved == false)] | length),
reviews: $pr.reviews.nodes
}'Length of output: 133442 🏁 Script executed: #!/bin/bash
set -euo pipefail
head="4704db0ae24e8c6183fd6ed10385e126024abd6c"
red="a1eaeadcf021665cc19461bfa4378f03de9ee6c8"
repair="4fa56489e93b8b5596738460bb033ba4011178a2"
ruff_failure="c400e652079b59e70816114538072278edddaea9"
echo "== Exact loader order =="
git show "${head}:services/analysis-engine/src/bandscope_analysis/api.py" \
| nl -ba | sed -n '685,785p'
echo "== Exact canonical role sidecar admission and replay order =="
git show "${head}:services/analysis-engine/src/bandscope_analysis/feature_cache_admission.py" \
| nl -ba | sed -n '1,215p'
git show "${head}:services/analysis-engine/src/bandscope_analysis/feature_cache_admission.py" \
| nl -ba | sed -n '315,420p'
echo "== RED and production repair, restricted to role behavior =="
git diff "${red}^" "$red" -- \
services/analysis-engine/src/bandscope_analysis/api.py \
services/analysis-engine/tests/test_feature_cache_metadata_generation.py \
services/analysis-engine/tests/test_feature_cache_role_binding.py
git diff "${repair}^" "$repair" -- \
services/analysis-engine/src/bandscope_analysis/api.py \
services/analysis-engine/src/bandscope_analysis/feature_cache_admission.py \
services/analysis-engine/tests/test_feature_cache_metadata_generation.py \
services/analysis-engine/tests/test_feature_cache_role_binding.py
echo "== Exact Ruff follow-up delta =="
git show --format=fuller --stat "$head"
git diff --unified=40 "$ruff_failure" "$head" -- \
services/analysis-engine/tests/test_feature_cache_role_binding.py \
services/analysis-engine/src/bandscope_analysis/feature_cache_admission.py
git show "${head}:services/analysis-engine/tests/test_feature_cache_role_binding.py" \
| nl -ba | sed -n '1,25p'
echo "== Role-related direct callers and public result use =="
git grep -n -E \
'(_normalize_stem_role_types\(|_has_canonical_stem_role_metadata\(|_read_canonical_stem_role_metadata\(|load_bounded_stem_archive\()' \
"$head" -- services/analysis-engine/src -- '*.py'Length of output: 2400 🏁 Script executed: #!/bin/bash
set -euo pipefail
head="4704db0ae24e8c6183fd6ed10385e126024abd6c"
red="a1eaeadcf021665cc19461bfa4378f03de9ee6c8"
repair="4fa56489e93b8b5596738460bb033ba4011178a2"
ruff_failure="c400e652079b59e70816114538072278edddaea9"
numbered() { awk '{printf "%6d\t%s\n", NR, $0}'; }
echo "== Exact loader order =="
git show "${head}:services/analysis-engine/src/bandscope_analysis/api.py" \
| numbered | sed -n '685,785p'
echo "== Exact canonical role sidecar admission and replay order =="
git show "${head}:services/analysis-engine/src/bandscope_analysis/feature_cache_admission.py" \
| numbered | sed -n '1,215p'
git show "${head}:services/analysis-engine/src/bandscope_analysis/feature_cache_admission.py" \
| numbered | sed -n '315,420p'
echo "== RED and production repair, restricted to role behavior =="
git diff "${red}^" "$red" -- \
services/analysis-engine/src/bandscope_analysis/api.py \
services/analysis-engine/tests/test_feature_cache_metadata_generation.py \
services/analysis-engine/tests/test_feature_cache_role_binding.py
git diff "${repair}^" "$repair" -- \
services/analysis-engine/src/bandscope_analysis/api.py \
services/analysis-engine/src/bandscope_analysis/feature_cache_admission.py \
services/analysis-engine/tests/test_feature_cache_metadata_generation.py \
services/analysis-engine/tests/test_feature_cache_role_binding.py
echo "== Exact Ruff follow-up delta =="
git show --format=fuller --stat "$head"
git diff --unified=40 "$ruff_failure" "$head" -- \
services/analysis-engine/tests/test_feature_cache_role_binding.py \
services/analysis-engine/src/bandscope_analysis/feature_cache_admission.py
git show "${head}:services/analysis-engine/tests/test_feature_cache_role_binding.py" \
| numbered | sed -n '1,25p'
echo "== Role-related direct callers and public result use =="
git grep -n -E \
'(_normalize_stem_role_types\(|_has_canonical_stem_role_metadata\(|_read_canonical_stem_role_metadata\(|load_bounded_stem_archive\()' \
"$head" -- services/analysis-engine/src -- '*.py'Length of output: 31359
The first-read role admission is correct.
The metadata-replacement regression is causal.
The second-read admission remains consistent with this boundary.
The Ruff repair is formatter-only.
I did not treat The PR is Draft and blocked. Current-head build, Rust, Python CodeQL, security, and platform checks are non-terminal. This review does not provide an approval. You are interacting with an AI system. |


Canonical #781 Resource Admission & Decode lane
This PR remains the single BandScope source writer for local-audio Resource Admission & Decode. Current exact source head is
af3efa803141cd139efd3d61fb1a9503fbbf316f; protected base remainsdevelop@314ddeae7b775a4957594b599358c8255617eb2e. Keep Draft. Predecessor, sibling, cancelled, or downstream evidence does not transfer to this head.#1176 remains sole owner of the inherited protected-base
services/analysis-engine/tests/test_supply_chain_policy.pyRuff-format repair. #1116 alone writesdocs/product-technical-gap-baseline.md. Central.github#1902remains the CodeQL verdict-publication/recovery owner. #970 and #1160 consume this lane only after protected ancestry; #985 retains its unsuperseded M4A fallback evidence.Latest producer admission repair
Fresh review found that the replay side already rejected noncanonical stem identities while the feature-cache producer could still serialize any identifier-shaped key. RED
0e436c14f3f23313a0805e56477df191e4778c84requires producer rejection ofguitarwhile preserving canonicalbass. Production4cb93a74b2668440479ed0ac884c60505acd7883derives the closed audio-stem vocabulary fromAudioStemNameand refuses producer publication outsidevocals|bass|drums|other. This aligns producer and consumer semantics without expanding the broader non-audioStemCategorymodel.Hosted RED is not claimed because the production descendant followed before a stable RED workflow result could be observed.
#1194 single-writer consolidation: bounded source-path diagnostic
Draft #1194 edited the same
validate_analysis_job_requestowner. Its valid unique runtime delta was a security warning for rejectedlocalSource.sourcePath; raw attacker-controlled paths must not enter logs. The branch-to-branch consolidation probe #1195 was non-mergeable and introduced no unique delta, so it was closed without merge rather than forcing or rebasing either branch.Canonical adoption occurred directly on #866. RED
0e313169299eb6112343ca7d8fbac612d6df5942injects both a..traversal segment and a forged newline suffix and requires the request to fail while the logger sees only the fixed field identifier. Production5546a17ccc848e2d043359586a2abc0bd198a66cadds the bounded warning before the existing rejection. Review of that file-replacement commit found two unrelated text-only drifts; exact descendant7c0e858da327daa07b56c75b2a90a2761b4c4880restores them. Compare4cb93a74...→7c0e858d...contains only one production-line addition plus the dedicated regression file. Doctoringaf3efa803141cd139efd3d61fb1a9503fbbf316frecords the decision, rejected raw-path/repr()alternatives, claim boundary, and CWE-117 (CWE 4.20) traceability.#1194 remains a preservation source until this exact successor has qualifying verification.
.jules/sentinel.mdis learning metadata rather than a second product authority; its useful security rationale is represented in the canonical doctoring document.Retained controls
Retained ancestry owns canonical stem identity/role semantics at both metadata reads, first- and second-read duration admission, second-read schema/stem/sample-rate consistency, synchronized stem sample counts, duration-vs-
sample_count / sample_rateagreement within half one sample, exact bounded ZIP/NPY declaration preflight, one immutable spooled archive replay snapshot, allocator/truncation cache-miss containment, owned finite canonical float32 re-admission through the liveAudioResourcePolicy, and exception-safe unknown-stem rejection before canonical role-table lookup. These are persistence/resource-integrity controls, not source-separation or MIR-accuracy evidence.Exact-head verification
Exact-head workflows for
af3efa80...are fresh and non-terminal. Do not transfer predecessor GREEN. Exact-head Python GREEN, full build GREEN, CodeQL/SAST success, qualifying independent current-head approval, Ready, merge, and release remain unclaimed until the current head proves them.Next causal gap
The feature cache still does not make first API metadata, replay NPZ bytes, and source publication one immutable generation. The next persistence contract remains a versioned immutable manifest binding the first metadata snapshot and private NPZ snapshot to #970-owned durable
contentSha256/sourceReferenceauthority after protected ancestry. Do not add another pathname/timestamp heuristic or duplicate Project Persistence source identity in #866.After that prerequisite, the next runtime gap is Windows race-free Job Object containment followed by rights-cleared full-length rehearsal-audio measurement of cancellation latency, inherited handle/pipe return, child temp cleanup, decoder/resampler/downstream peak RSS/VRAM, CPU/GPU budget, and MIR reproducibility.
Protected
developremains the only merge target; no force-push, destructive rebase, self-approval, or gate weakening is permitted.UI Delivery Gate remains FAIL: actual audio → audible playback, restart re-admission, stale-media races, pointer/touch/keyboard/browser focus, Narrator/VoiceOver, responsive evidence, and KO/EN/JA/ZH/VI/ES/DE/FR acceptance remain open.
Commercial Release Gate remains FAIL. #1129 owns audio-I/O licensing/format parity, #1180 owns immutable model distribution/signing/update rollback, and #1181 owns the upstream pretrained
htdemucscommercial-rights/replacement decision.