Policy: allow up to 2 MiB for Rust source files under asset policy #1361

Open
ashishdhillon wants to merge 1 commit from upstream-pr/1361 into main
ashishdhillon commented 2026-11-26 18:11:57 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by ashishdhillon on 2026-11-26T18:11:57Z.


Description

Fixes #1342. On main, crates/victory-gpu/src/host.rs (528,954 bytes) and crates/victory-shader/src/emit/lower.rs (535,588 bytes) exceeded the uniform 512 KiB MAX_FILE_SIZE ceiling in xtask/src/policy.rs, causing policy::tests::repository_passes_policy (CI Tests) to fail and cargo xtask policy --staged to reject commits touching either file.

This implements Option 1 discussed in #1342: giving .rs source files a dedicated 2 MiB size ceiling (MAX_SOURCE_FILE_SIZE) while keeping all content guards (allowlisted extension, forbidden binary signatures, NUL-byte check, and MAX_ENCODED_RUN = 512 hex/base64 run check) unchanged and keeping MAX_FILE_SIZE = 512 KiB for all other non-run-log files.

Changes

  • xtask/src/policy.rs: Added MAX_SOURCE_FILE_SIZE (2 MiB) for .rs files, updated check() size enforcement, added source_files_have_their_own_size_limit unit test, and updated rejects_game_like_files.
  • docs/asset-policy.md: Documented the 2 MiB ceiling for .rs source files alongside the 512 KiB general limit.

Verification

  • cargo clippy -p xtask --all-targets --locked -- -D warnings: passed
  • cargo test -p xtask --locked: 6 passed, 0 failed (including policy::tests::repository_passes_policy)
  • cargo xtask policy: asset policy: 223 files ok
<!-- greyfinch-sync:fxceless/victory-fork:issue:5515075208 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1361). Originally posted by [ashishdhillon](https://github.com/ashishdhillon) on 2026-11-26T18:11:57Z. --- ## Description Fixes #1342. On `main`, `crates/victory-gpu/src/host.rs` (528,954 bytes) and `crates/victory-shader/src/emit/lower.rs` (535,588 bytes) exceeded the uniform 512 KiB `MAX_FILE_SIZE` ceiling in `xtask/src/policy.rs`, causing `policy::tests::repository_passes_policy` (CI `Tests`) to fail and `cargo xtask policy --staged` to reject commits touching either file. This implements Option 1 discussed in #1342: giving `.rs` source files a dedicated 2 MiB size ceiling (`MAX_SOURCE_FILE_SIZE`) while keeping all content guards (allowlisted extension, forbidden binary signatures, NUL-byte check, and `MAX_ENCODED_RUN = 512` hex/base64 run check) unchanged and keeping `MAX_FILE_SIZE = 512 KiB` for all other non-run-log files. ## Changes - `xtask/src/policy.rs`: Added `MAX_SOURCE_FILE_SIZE` (2 MiB) for `.rs` files, updated `check()` size enforcement, added `source_files_have_their_own_size_limit` unit test, and updated `rejects_game_like_files`. - `docs/asset-policy.md`: Documented the 2 MiB ceiling for `.rs` source files alongside the 512 KiB general limit. ## Verification - `cargo clippy -p xtask --all-targets --locked -- -D warnings`: passed - `cargo test -p xtask --locked`: 6 passed, 0 failed (including `policy::tests::repository_passes_policy`) - `cargo xtask policy`: `asset policy: 223 files ok`
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1361:upstream-pr/1361'
git switch 'upstream-pr/1361'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1361'
git switch 'upstream-pr/1361'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1361'
git switch 'upstream-pr/1361'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1361'
git switch 'main'
git merge --squash 'upstream-pr/1361'
git switch 'main'
git merge --ff-only 'upstream-pr/1361'
git switch 'main'
git merge 'upstream-pr/1361'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!1361
No description provided.