Skip to content

fix(box): record a metadata read of an unresolved path as a response - #288

Merged
kevin-orellana merged 2 commits into
mainfrom
feature/reach-floor-records-answered-probes
Nov 3, 2026
Merged

kevin-orellana merged 2 commits into
mainfrom
feature/reach-floor-records-answered-probes

Conversation

@priyasingh2111

@priyasingh2111 priyasingh2111 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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 records fs:read::error. The workload still gets its answer, but a ::response-keyed read_metadata budget 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.

main interaction with #152: since #152, a lookup that the host refuses for permission is also refused by the floor. So on main, SH-PROBE-PERMISSION fails: Python's check raises PermissionError, and the budget is not spent. With this change the budget is spent again. The case now accepts a refusal from Python as well as False, 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.md records 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

  • New unit tests in reach.rs, shell.rs, and python/effects.rs cover 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.
  • New integration cases: 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 here.
  • Mutation proofs: each part of the fix was removed in turn, and each removal makes one or more new tests fail.
  • macOS aarch64 results: test-integ has 140 cases (128 pass, 12 skip, 0 fail). Workspace tests: 4531 pass and 0 fail. The strands-box doctest target does not compile on main (can't find crate for policy, from crates/box/src/lib.rs in 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.
  • The original metadata-fix validation at 3e91dbb did 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's 3e91dbb plus the exact repair from #289). These results cover the branch tree; GitHub checks must validate its merge with current main.

Check Result
Workspace build with all features and formatting Passed.
Repaired protection_alias tests 10 passed; zero failed, ignored, or prerequisite skips.
bash scripts/test-all.sh Passed: 4,855 Rust test passes, zero failures, 17 ignored tests. The custom library target also passed.
bash test-integ/run.sh GREEN: 131 passed, zero failed or errored, nine declared macOS-only exclusions. All 140 expected records were present; no quarantine or coverage reduction.
Metadata-budget regressions MO-PROBE-FOLDER, SH-PROBE-FOLDER, SH-PROBE-FOLDER-SHARED, and SH-PROBE-PERMISSION all passed.
Linux test-output audit Passed with the two existing omissions below.
Workspace Clippy with the repository's CI allowances Passed.
Containment Clippy, all targets/features, -D warnings, no allowances Passed with zero warnings.
Containment build without default features Passed with 66 warnings from unchanged production code.

The 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 warnings with 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, and non_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.

  • I ran the relevant suites (cargo test --workspace --all-features; see the doctest note above)
  • If I touched Rust, I ran cargo fmt --all and the CI clippy command (-D warnings with the CI allow list)

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • My changes generate no new warnings

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

## 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`.
@github-actions github-actions Bot added Area - Agent Containment bug Something isn't working labels Nov 3, 2026
@priyasingh2111
priyasingh2111 marked this pull request as ready for review November 3, 2026 21:59
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.
Comment thread crates/box/src/run/broker/reach.rs Resolved
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

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 held.rs already owns. I reviewed head 080614a; since 3e91dbb it adds only the test-only repair to protection_alias.rs from #289.

Details Checked and held
  • A Shell test -e or a Python stat()/predicate under a missing folder records ::response, the floor still refuses, and the message is unchanged.
  • An unsearchable folder (EACCES) and a file used as a folder (ENOTDIR) count as answers, which matches the documented rule.
  • Box-state paths stay ::error, including macOS case-variant spellings, which has_ancestor_among catches by inode.
  • Links, dangling leaves, and .. spellings stay ::error. .. rarely arrives anyway, because the Shell runs vfs::normalize and Python resolves paths lexically.
  • Content reads, mutations, and Python Resolve/Absolute keep ::error. Only the two callers read Refused::is_unresolved.
  • The interface change (one temporal observation) is stated and approved in the description, and the user docs, design docs, and decision record are updated together.
  • The non-atomic second lookup and the gap behind unsearchable folders are recorded in the crates/box/AGENTS.md open findings.
  • The integration cases check both that the budget is spent after N probes and that it is not spent early, so a single probe counted twice would fail them.

The integration cases are well targeted and catch both undercounting and overcounting.

Comment thread crates/box/src/run/broker/reach.rs Resolved
Comment thread docs/user/policy/actions.md Resolved
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Assessment: Comment

I reviewed commit 3e91dbb, the metadata fix. The PR on GitHub also contains 080614a, the protection_alias.rs test repair from #289, which I only skimmed. I found no case where the floor leaks or the refusal message changes. The two inline comments are about who owns the "answered vs. refused" decision, and about a user-facing condition that can't actually happen. Neither blocks the merge.

Checks that held
  • Common case: test -e absent-dir/x and Python stat() under a missing folder record ::response, and the floor still refuses. The 7 new unit tests pass on Linux (non-root).
  • Unsearchable folder: locked/… records ::response, which matches the decision entry.
  • Deny floor: paths in box state, including macOS case variants caught by has_ancestor_among, stay ::error. The outcome doesn't depend on what is in box state.
  • Links: links, dangling leaves (leaf name is already taken), and loops stay ::error.
  • Scope: content reads, mutations, and Python Resolve/Absolute stay ::error. Only two callers use Refused, and both check that the operation is a metadata read.
  • Valid before: NotCanonical and Unreachable refusals still record ::error, because of the Unresolvable match. That match isn't covered by any test, as the commit message says.
  • Frozen surface: the temporal observation change is stated in the description as approved by the user. No action, attribute, or export changes.
  • Race: the remaining race (a link removed, or a link behind an unsearchable folder) is recorded in crates/box/AGENTS.md open findings.

The integration cases share one budget across both routes, which is the right way to prove that the two routes now agree.

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

Labels

Area - Agent Containment bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants