Repository navigation
test(box): name unit cases by condition and expected outcome - #258
kevin-orellana wants to merge 1 commit into
Conversation
## Problem Box core unit tests use mixed naming styles. A test list does not consistently separate the condition from the expected result. ## Solution Rename 687 existing unit-test definitions to when_<condition>_then_<expected_outcome>. Update exact child-process filters and references. Correct the memory-read test description to identify a parent and child. Keep test assertions, platform conditions, and ignored status unchanged. Leave suite extraction and HOME fixture changes in separate patches. ## Tests Linux ARM64: cargo test -p strands-box --lib --bins --all-features --locked -- --show-output. Exact publication-tree results: 677 passed, zero failures, zero ignored tests, and no reported skips. The prepared combined tree passed formatting, both crates' all-target/all-feature Clippy checks with the repository vendor allowlist, and source-preservation checks for all 1,130 existing test definitions. Adversarial review corrected four descriptions across the two rename batches. Native macOS and full workspace, integration, examples, and live-agent gates remain pending. The user approved draft publication before completing those gates. This commit makes no coverage-percentage claim.
| /// refused.** | ||
| #[test] | ||
| fn a_credential_store_is_granted_only_when_named_exactly() { | ||
| fn when_a_credential_store_is_named_exactly_then_it_can_be_granted() { |
There was a problem hiding this comment.
Important (non-blocking): This rename removes the refusal half of a credential-floor test from its name. The test still checks the refusal, but the name no longer says so.
Example: The old name a_credential_store_is_granted_only_when_named_exactly covered both arms. The body still checks both: read = ["~/.aws"] is granted, and read = ["~"] must be refused beneath every grant. The new name ..._then_it_can_be_granted names only the permissive arm. The deny arm is the security property here. crates/box/AGENTS.md:285-286 cites this test for "A prefix of a store, or a parent of one, stays refused." A reader who trusts the name could treat the ~ assertion as incidental.
The same "only when" → one-arm change happens in two other places:
run/contain/boundary.rs:1877a_log_directory_gets_metadata_only_when_the_process_lists_it→when_a_process_lists_its_log_directory_then_metadata_access_is_granted. The body also checks that an unlisted directory gets no rule, and thatfile-read*/file-read-data/file-write-data/process-execare never granted.run/contain/boundary.rs:1941the_disclosure_names_native_egress_only_when_it_is_selected→when_native_egress_is_selected_then_the_disclosure_names_it. The body also checks that a gateway leaf's disclosure does not mention native egress.
Suggestion: Keep both outcomes in the then_ clause. For example: when_a_credential_store_is_named_then_only_an_exact_entry_is_granted, when_a_log_directory_is_listed_then_only_metadata_is_granted, when_egress_mode_varies_then_only_native_egress_is_disclosed. Then update the AGENTS.md reference.
| operator's filesystem. Two escapes were found in its first version, both pinned by a test that | ||
| must not be deleted: | ||
| - a **dangling symlink written through** (`a_dangling_symlink_cannot_be_written_through`). "It | ||
| - a **dangling symlink written through** (`when_a_write_targets_a_dangling_symlink_then_it_is_refused`). "It |
There was a problem hiding this comment.
Important (non-blocking): The list of tests that must survive in .agents/agents/feature-critic.md:150-154 no longer covers the Monty escape tests that this file cites.
Example: On main, a_dangling_symlink_cannot_be_written_through and an_intra_home_symlink_cannot_launder_a_scoped_read each named two tests: one in run/broker/python/effects.rs, which this section and docs/design/decisions.md cite as "must not be deleted", and one in tests/box_shell.rs. This PR renames only the effects.rs copies. The old names in feature-critic.md still match the box_shell.rs copies, so git grep -w reports nothing stale. But the critic's "named examples that must survive" check now guards only the Shell halves. A later change that deletes when_a_write_targets_a_dangling_symlink_then_it_is_refused would not hit that list.
A smaller issue: line 229 of this file, which the PR also edits, cites run_config.rs::when_run_selects_a_box_then_.... That test is in src/record/config/mod.rs, not tests/run_config.rs. The wrong prefix was already there before this PR, but since the line is being rewritten anyway, now is a good time to fix it.
Suggestion: Add the two new effects.rs names to the feature-critic.md list next to the old ones. Change the line-229 prefix to record::config::tests:: (or config/mod.rs::).
|
Assessment: Comment The rename is mechanically sound. Mapping each old name to its new name over Checked and held
|
Pull request was closed
Human readable section
Problem. Unit tests use mixed naming styles. Their names do not consistently separate the condition from the expected result.
Solution. Give 687 existing box unit-test definitions condition/outcome names, and update their exact subprocess filters and references. The memory-read test now describes its actual parent/child relationship.
Trade-off. This produces 1,528 changed lines of mechanical review work. It adds no test coverage. Existing assertions, platform conditions, and ignored status are preserved.
Description
Use
when_<condition>_then_<expected_outcome>for the existing unit-test functions. Keep their test bodies and runtime behavior intact. Reference changes include documentation and integration-test comments or diagnostics; existing integration case names and assertions remain unchanged.Suite extraction and the HOME fixture cleanup are separate patches. This PR can target
mainindependently of the other component's rename PR.This is an intentionally incomplete draft, published before the remaining macOS and broader checks. It is not ready for approval or merge.
Related Issues
Related naming work: #249. This PR does not close the broader coverage effort.
Type of Change
Other (please describe): unit-test naming and reference cleanup.
Testing
Tested head:
84195459c6d11a22f040055876e94df9fc6e6d0c. Its source tree is5bc9f01d35107ef467351dd8424da546d0d1ea29, based one4ca8b80359b2213d684de31cd6ef32e0d61478a.Host: Linux ARM64, Rust 1.98.1. The exact publication tree ran:
cargo test -p strands-box --lib --bins --all-features --locked -- --show-outputDefinition counts and executed Linux test counts differ because platform conditions and shared code affect discovery. The Box alias-image test initially returned early without its helper; the helper was installed, and the exact publication run has no reported skip.
The following full-suite attestations remain unchecked. The author approved opening these drafts before completing them. Hosted checks will supply additional evidence; dispatch alone is not a pass.
just check, orcargo test --workspace --all-features)cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningsChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.