Repository navigation
fix(box): record a metadata read of an unresolved path as a response - #288
Conversation
## Problem A metadata read records `fs:read::response` when the workload gets an answer, also when the answer is "no". The Shell does this since #144, and Python since #268. But when the host cannot resolve the path, for example when a parent folder is missing or the host cannot search a folder, the reachable paths check refuses the read and both routes record `fs:read::error`. The workload still gets its answer. A `read_metadata` budget keyed on `::response` does not count these reads, so the budget counts fewer reads than the workload makes. Since #152, a lookup that the host refuses for permission is also a refusal of this type. Thus on `main` the integration case SH-PROBE-PERMISSION fails: the Python check raises `PermissionError`, and the budget is not spent. ## Solution - `Reach` marks a refusal as unresolved when the resolver returns `PathRefusal::Unresolvable` and the path is inside the reachable set, has no `.` or `..` component, has no symbolic link at a component the host can see, and is not beneath the deny floor (`Refused::is_unresolved`). - The Shell `ReachFloor` and the Python `admit_and_perform` record `Completed` for a refused metadata read whose refusal is unresolved. All other refusals record `Failed`, as before. - The floor still refuses. The message that the agent or script sees does not change. - The interface change is one temporal observation: such a read now records `fs:read::response` in place of `fs:read::error`. The user approved this change. No action, attribute, version, or façade export changes. - SH-PROBE-PERMISSION now accepts a refusal from Python as well as `False`, because the floor owns that answer since #152. It still asserts that the budget is spent. - Docs: `docs/user/policy/actions.md`, `docs/design/policy.md`, the decision entry `temporal-rules-are-enforced-against-recorded-history`, and `crates/policy/README.md` state the rule and its conditions. `crates/box/AGENTS.md` records that the classification is a second, non-atomic lookup. ## Tests - `reach::only_a_plain_path_under_a_missing_folder_is_unresolved`: a path under a missing folder is unresolved. A path beneath box state, through a link, through a dangling link into box state, or with a `..` component is not. - `shell::a_metadata_read_under_a_missing_folder_meets_a_response_precondition`: the Shell read meets a `::response` precondition. Box-state, link, and dangling-link reads do not, and neither does a content read. - Python: `a_metadata_read_under_a_missing_folder_spends_the_budget` (stat and the four predicates), `a_metadata_read_under_an_unsearchable_folder_spends_the_budget`, `a_metadata_read_through_a_link_in_the_home_spends_nothing`, `a_content_read_under_a_missing_folder_records_an_error`, and `a_stat_beneath_the_box_state_spends_nothing` (now also with dangling links into box state). - Integration: MO-PROBE-FOLDER, SH-PROBE-FOLDER, and SH-PROBE-FOLDER-SHARED (one budget shared by the Shell and Python). These three cases and SH-PROBE-PERMISSION fail on `main` and pass with this change. - Mutation proofs: each part of the fix was removed in turn (the gate in each route, the metadata-only gate in each route, the symbolic-link walk, the deny-floor check, and the component check). Each removal makes one or more new tests fail. Removing the `PathRefusal::Unresolvable` match makes no test fail, because the walk already refuses each input that could reach it. It stays as a statement of the rule. - Gates on macOS aarch64: `cargo fmt --all --check`, CI clippy, build, site manifest, and test-integ (140 cases, 128 pass, 12 skip, 0 fail) pass. `cargo test --workspace --all-features --no-fail-fast`: 4531 tests pass and 0 fail. The `strands-box` doctest target does not compile (`can't find crate for policy` in `command/policy.rs`), which comes from `crates/box/src/lib.rs` (#274) and not from this change. - Not run: Linux. On a root runner, the unsearchable-folder test prints `skipping`.
Import the published test-only repair from PR #289 into the metadata-response branch so its Linux checks can compile. Preserve the existing test assertions and fixture ordering. Priya's metadata implementation remains unchanged. Source commit: 35b2b50 Combined Linux validation: workspace build and tests passed (4,855 test passes, 17 ignored). All 10 protection-alias tests and 131 integration cases passed, with nine declared macOS exclusions. Format, Linux output audit, CI-equivalent workspace Clippy, and unsuppressed containment Clippy passed. The no-default build passed with 66 warnings from unchanged code. Test tree: 5787cc8. Hosted merge checks and human approval remain required.
|
Assessment: Comment The metadata fix is correct for every case I traced through both routes. I have one maintainability point, posted inline: the new unresolved-path check makes a decision that DetailsChecked and held
The integration cases are well targeted and catch both undercounting and overcounting. |
|
Assessment: Comment I reviewed commit Checks that held
The integration cases share one budget across both routes, which is the right way to prove that the two routes now agree. |
Human readable section
Problem: Some refused file-information checks do not count against the configured read limit. Linux tests also fail to compile.
Solution: Count eligible refused checks as responses, while preserving the refusal. Include the Linux test-compilation repair from #289.
Trade-off: The metadata change affects how policy counts these checks. The compiler repair changes only Linux test setup.
Description
A metadata read that gets an answer records
fs:read::response, also when the answer is "no". The Shell does this since #144 and Python since #268. There is one remaining case in both routes. If the host cannot resolve the path (for example, a parent folder is missing, or the host cannot search a folder), the reachable paths check refuses the read and it recordsfs:read::error. The workload still gets its answer, but a::response-keyedread_metadatabudget does not count it.This change records such a read as
::response. That happens only when the path is inside the reachable set, has no.or..component, has no symbolic link at a component the host can see, and is not beneath the deny floor. The floor still refuses, and the message the agent or script sees does not change. Content reads, writes, deletes, and every other refusal still record::error.Interface change (approved by the user): one temporal observation. A metadata read the host cannot resolve, such as one under a missing folder, now records a response. No action, attribute, version, or façade export changes.
maininteraction with #152: since #152, a lookup that the host refuses for permission is also refused by the floor. So onmain, SH-PROBE-PERMISSION fails: Python's check raisesPermissionError, and the budget is not spent. With this change the budget is spent again. The case now accepts a refusal from Python as well asFalse, because the floor owns that answer.Decision this depends on: temporal rules are enforced against recorded history, updated in this PR.
Known limit: the unresolved classification is a second lookup after the resolver, and it is not atomic.
crates/box/AGENTS.mdrecords this. A race gives only the event that a plain probe of the same reported path already gives.Related Issues
Follow-up to #144 and #268. Includes the Linux test-compilation repair from #289, which repairs the interaction between #254 and #266.
Type of Change
Bug fix
Testing
reach.rs,shell.rs, andpython/effects.rscover both directions. Paths under a missing folder or an unsearchable folder spend the budget. Box-state paths, links, dangling links,..spellings, outside-the-set paths, and content reads do not.mainand pass here.strands-boxdoctest target does not compile onmain(can't find crate for policy, fromcrates/box/src/lib.rsin feat(box): report the kind of an env refusal and a read-grant refusal to library callers #274). That failure is not from this change.3e91dbbdid not run Linux. Combined Linux validation is recorded below.Combined Linux validation
Validated commit:
080614a338a556f3ce7f19d9a55831d018d6d807.The combined branch passed these checks on Amazon Linux 2023 ARM64 with Rust 1.98.1 and
EXPERIMENTAL_LINUX_SUPPORT=TRUE. Tested tree:5787cc8a23674b83cebb0b0954ff91e8d3141c7c(Priya's3e91dbbplus the exact repair from #289). These results cover the branch tree; GitHub checks must validate its merge with currentmain.protection_aliastestsbash scripts/test-all.shbash test-integ/run.shMO-PROBE-FOLDER,SH-PROBE-FOLDER,SH-PROBE-FOLDER-SHARED, andSH-PROBE-PERMISSIONall passed.-D warnings, no allowancesThe workspace output retains the missing credential-daemon fixture and the omitted alias-read assertion. Its write assertions ran. Existing ignored tests and the manual SDK tutorial remain untested. The existing performance diagnostic still reports the unmet 1 ms p99 target tracked in #150; its relative-cost test passes. These results do not establish that performance target.
Workspace Clippy used
--workspace --all-targets --all-features --locked -- -D warningswith the repository allowances:clippy::too_many_arguments,clippy::only_used_in_recursion,clippy::await_holding_refcell_ref,clippy::explicit_auto_deref,clippy::chunks_exact_to_as_chunks,dead_code, andnon_snake_case. The containment-only Clippy run used no allowances.Fresh combined macOS validation and automated review remain pending on GitHub. Human approval remains required.
cargo test --workspace --all-features; see the doctest note above)cargo fmt --alland the CI clippy command (-D warningswith the CI allow list)Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.