Skip to content

refactor(sandboxing): gate test-only legacy sandbox helpers behind cfg(test)#158

Closed
andrei-hasna wants to merge 1 commit into
mainfrom
openloops/open-codewith/b51df40e-166b-4807-a61a-df24b809ca25-e64149d4
Closed

refactor(sandboxing): gate test-only legacy sandbox helpers behind cfg(test)#158
andrei-hasna wants to merge 1 commit into
mainfrom
openloops/open-codewith/b51df40e-166b-4807-a61a-df24b809ca25-e64149d4

Conversation

@andrei-hasna

Copy link
Copy Markdown
Contributor

Summary

Prunes test-only legacy sandbox helpers from production builds. Replaces #[cfg_attr(not(test), allow(dead_code))] with #[cfg(test)] on the three sandbox helpers that are only exercised by tests, so non-test builds no longer compile dead compatibility/test-only code and the allow(dead_code) suppressions are gone.

Affected helpers:

  • codex-rs/sandboxing/src/seatbelt.rsdynamic_network_policy
  • codex-rs/sandboxing/src/seatbelt.rscreate_seatbelt_command_args_for_legacy_policy
  • codex-rs/sandboxing/src/landlock.rscreate_linux_sandbox_command_args

The helpers stay available to the #[cfg(test)] mod tests modules via use super::..., so seatbelt/landlock legacy-policy coverage is unchanged.

Safety

  • Live public entrypoints untouched and independent: create_seatbelt_command_args, create_linux_sandbox_command_args_for_permission_profile.
  • No dead-code cascade: dynamic_network_policy_for_network keeps its production caller inside create_seatbelt_command_args (seatbelt.rs:706).
  • Confirmed repo-wide that the three helpers have zero non-test callers.

Validation

  • just check-fast -p codex-sandboxing — pass (production build compiles without the helpers)
  • just test-fast -p codex-sandboxing — 50/50 tests pass
  • just fix -p codex-sandboxing — clippy clean
  • just fmt — no changes to scoped files
  • Independent adversarial verifier: CONFIRMED correct & safe.

Closes dead-code remediation task b51df40e-166b-4807-a61a-df24b809ca25.

🤖 Generated with Claude Code

@andrei-hasna
andrei-hasna force-pushed the openloops/open-codewith/b51df40e-166b-4807-a61a-df24b809ca25-e64149d4 branch from 328cc3f to 5fcbdb5 Compare July 6, 2026 19:08
…g(test)

Replace cfg_attr(not(test), allow(dead_code)) with cfg(test) on the legacy sandbox helper functions that are only exercised by tests.

Live public entrypoints remain compiled in production, while the legacy helper coverage remains available to cfg(test) modules.
@andrei-hasna
andrei-hasna force-pushed the openloops/open-codewith/b51df40e-166b-4807-a61a-df24b809ca25-e64149d4 branch from 5fcbdb5 to f21c873 Compare July 6, 2026 19:53
@andrei-hasna

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #207. Replacement #207 carries the current provider/docs cleanup slice and explicitly lists this PR in its carried scope. Please continue review on #207.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant