Skip to content

test(accessibility): helper cache dir and reply-id matching - #162

Merged
M3gA-Mind merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:test/accessibility-helper-cache-dir
Oct 23, 2026
Merged

M3gA-Mind merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:test/accessibility-helper-cache-dir

Conversation

@M3gA-Mind

@M3gA-Mind M3gA-Mind commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Test-only, with two no-behaviour-change extractions so the code can be tested.

The macOS Swift helper is compiled into a cache directory under the temp dir, and private_cache_dir refuses a temp dir others can write and a cache dir that is a symlink, not a directory, or someone else's. Its replies are read off a channel, and only the line carrying the request's id may answer a request. Stale, blank and unnumbered lines are skipped. None of these checks was tested, so a refactor could drop one silently.

  • private_cache_dir(name) now resolves the temp dir and calls private_cache_dir_in(temp_dir, name), which holds the unchanged checks.
  • The reply-wait loop in helper_send_receive moved into await_reply(rx, id, timeout) -> Result<Option<Value>, String>. None means it timed out, and the caller still resets the helper and returns the same timeout error.

Related issue

None.

API or behavior changes

None.

Validation

Commands actually run, with their outcome:

  • N/A: cargo fmt --all -- --check: rustfmt run on the touched files only; CI runs the full check
  • N/A: cargo clippy --all-targets --all-features -- -D warnings: left to CI
  • N/A: cargo build --all-targets --all-features: left to CI
  • N/A: cargo test --all-features: only the new tests were run locally (below, macOS); CI runs the suite

CARGO_INCREMENTAL=0 cargo test -p tinycomputer-accessibility --lib -- helper::tests::cache_dir helper::process::tests

  • Current code: ok. 7 passed; 0 failed.
  • With a temporary local break (the symlink/is-dir check and the temp-dir 0o077 check removed, and any reply id accepted), restored before commit: FAILED. 3 passed; 4 failed. The failures are the symlink, writable-temp-dir, stale-line and timeout tests.

Tests

  • helper_tests.rs (cache_dir, macOS): a new cache dir is created 0700; an existing own dir is reused and tightened to 0700; a symlinked cache dir is refused; a temp dir with group access is refused and nothing is created in it.
  • New helper/process_tests.rs (macOS): stale, blank and unnumbered lines are skipped until the id matches; no match before the timeout is None; a non-JSON line is an error.

Not tested: the uid-mismatch branch, which needs a directory owned by another user.

Documentation

Not needed.

Checklist

  • The change is focused on one logical change
  • No new #[allow(...)], #[ignore], or relaxed lints: the two new test modules carry the crate's usual test-only #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
  • No secrets, tokens, or .env contents in the diff or the description

Split private_cache_dir into a wrapper over private_cache_dir_in(temp_dir)
and the reply-wait loop into await_reply(rx, id, timeout), with no
behaviour change, so both can be tested: a symlinked cache dir and a
group-writable temp dir are refused, an existing dir is reused and made
0700, and only the line carrying the request id answers it.
@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 378ec50a-06eb-4e49-8e62-e57ca6406070
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@tinysweeper

tinysweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Tiny Sweeper review

Reviewed head: 2fa02ac54003db80bc81f80deac673960000a894

Verdict: Ready for maintainer review · Priority: none
Coverage: Reviewed 4 of 4 files.
Pull request purpose (title): test(accessibility):…

Diagnostics and supporting details

Full summary

Pull request purpose (title): test(accessibility): helper cache dir and reply-id matching. Tiny Sweeper completed its review; deterministic results follow.

Review snapshot

Change surface Files Review signal Count
Production 2 Active findings 0
Tests 2 Noted findings 0
Documentation 0 Resolved findings 0
Configuration 0 Pending checks/questions 0

Completeness: Complete
Test assessment: Test coverage is assessed from changed tests and lane evidence; execution is not claimed without trusted check data.

What changed

The helper cache-directory check is split: `private_cache_dir` canonicalizes the temp dir and calls the new `private_cache_dir_in(temp_dir, name)` on a changed_path `crates/tinycomputer-accessibility/src/helper.rs` (new symbols `private_cache_dir_in`; per the whole-PR description the ownership, symlink, non-directory, and permission checks are unchanged). In a changed_path `crates/tinycomputer-accessibility/src/helper/process.rs`, the reply-wait loop of `helper_send_receive` moved into a new function `await_reply(rx_slot, id_str, timeout) -> Result<Option<Value>, String>`: `None` signals a timeout, and the caller still calls `reset_helper_process()` and returns the same timeout error string; a matching id still returns the parsed value. Two test modules are added: a changed_path `crates/tinycomputer-accessibility/src/helper/process_tests.rs` (macOS-gated) and a cache-dir module added to a changed_path `crates/tinycomputer-accessibility/src/helper_tests.rs`. The whole-PR diffstat reports 153 additions and 12 deletions across 4 files. No behavior change is claimed by the PR; the description notes the uid-mismatch branch remains untested.

Features

  • Internal refactor — private_cache_dir delegates to private_cache_dir_in: Separates temp-dir resolution from the validation logic so the checks can be exercised against a controlled directory in tests, without changing the checks applied in production. (crates/tinycomputer-accessibility/src/helper.rs)
  • Added — private_cache_dir_in: New macOS-only function that performs the ownership, symlink/not-a-directory, and permission checks (including set_permissions) against an already-resolved temp dir, enabling direct unit testing. (crates/tinycomputer-accessibility/src/helper.rs)
  • Added — await_reply: New macOS-only function that reads reply-channel lines until one carries the requested id, skipping blank, stale, and unnumbered lines, and returns Ok(None) on timeout instead of erroring; helper_send_receive maps None to reset_helper_process() plus the same timeout error string as before. (crates/tinycomputer-accessibility/src/helper/process.rs pub(crate) fn helper_send_receive(, crates/tinycomputer-accessibility/src/helper/process.rs)
  • Modified — helper_send_receive reply wait: The inline wait loop is replaced by a call to await_reply; the success path returns the parsed value and the timeout path still resets the helper and returns the original timeout message, so external behavior is unchanged. (crates/tinycomputer-accessibility/src/helper/process.rs pub(crate) fn helper_send_receive(, crates/tinycomputer-accessibility/src/helper/process.rs)
  • Added — macOS cache-directory and reply-wait tests: Adds macOS-gated unit tests: new cache dir created 0700, existing own dir reused and tightened to 0700, symlinked cache dir refused, a temp dir with group access refused with nothing created, and reply skipping of stale/blank/unnumbered lines, timeout returning None, and non-JSON returning an error. (crates/tinycomputer-accessibility/src/helper_tests.rs, crates/tinycomputer-accessibility/src/helper/process_tests.rs)

Tests

  • gap — The uid-mismatch branch (a cache directory owned by another user) is not covered by the new tests, per the whole-PR description.: Acknowledged limitation in the PR description; requires a directory owned by another user. The Answered tests lane reports no reportable defects despite this gap. (crates/tinycomputer-accessibility/src/helper.rs)

Findings

No active actionable findings.

Before merge

None.

Agent review details

critique

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The refactor is behavior-preserving: await_reply returns None on timeout while the caller still calls reset_helper_process() and returns the same error string, and private_cache_dir_in is a pure extraction of the original validation logic.
  • Lane summary: The refactor of `await_reply` out of `helper_send_receive` is behaviour-preserving: the timeout now returns `None` and the caller still calls `reset_helper_process()` before producing the same error string, and `private_cache_dir_in` is a pure extraction of the original body whose logic (including the symlink/ownership checks and `set_permissions`) is unchanged. The new tests exercise those paths. No reportable defect found in the four files. _The code index is behind this pull request (indexed at `37cc9f4fbda5`), so retrieved context may be out of date._

security

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The split preserves the original validation of owner-only permissions, symlink refusal, and writable temp-dir refusal, and the new tests assert owner-only modes, symlink refusal, and world-writable temp-dir rejection.
  • Lane summary: The changes look sound: `private_cache_dir` is split so tests can exercise the permission/ownership checks against a controlled directory without losing any of the original validation, and the helper reply wait is factored into `await_reply` with matching behaviour (timeout still ends with `reset_helper_process()` and the same error message; a matching id still returns the parsed value). The new tests are `macos`-gated and assert on owner-only modes, symlink refusal, and non-matching/stale line handling. I found no security or correctness defect introduced by this pull request. _The code index is behind this pull request (indexed at `37cc9f4fbda5`), so retrieved context may be out of date._

tests

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: New macOS-gated tests cover the reply-skipping, timeout, and JSON-parse error paths and the cache-dir permission/symlink/writable-temp paths; the tests lane reports they exercise real behavior and would fail on regression.
  • Lane summary: The change refactors the helper reply wait into a testable `await_reply` and the cache-directory guard into `private_cache_dir_in`, and adds unit tests for both — stale/blank/unnumbered line skipping, the timeout path, the JSON-parse error path, symlinked cache dirs, world-writable temp dirs, and owner-only creation. The tests exercise real behaviour and would fail if the refactor regressed; no reportable defects found. _The code index is behind this pull request (indexed at `37cc9f4fbda5`), so retrieved context may be out of date._

commits

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The commits lane reports no sensitive content in committed files.
  • Lane summary: No sensitive content in committed files. _The code index is behind this pull request (indexed at `37cc9f4fbda5`), so retrieved context may be out of date._

description

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The description matches the diff: two no-behaviour-change extractions plus macOS-only tests, and it discloses the untested uid-mismatch branch and that fmt/clippy/build were left to CI.
  • Lane summary: The description matches the diff: two no-behaviour-change extractions (`private_cache_dir_in`, `await_reply`) plus the new macOS-only tests it lists, with the stated caveats about validation and the uid-mismatch branch. I found no reportable defect in the code or the description. _The code index is behind this pull request (indexed at `37cc9f4fbda5`), so retrieved context may be out of date._
Evidence and run details
  • Models: ladder/vectors-oai3, deepseek-v4.1-flash
  • Spend: $0.005488
  • Tokens: 140610 input · 3445 output · 50922 cached · 349 embedding
  • Updated: 2026-10-23T01:49:36Z
Head State Pass summary
2fa02ac54003 ready for maintainer review 0 active finding(s), 0 resolved finding(s) (at 2026-10-23T01:49:36Z)

tinysweeper 0.1.2

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tinysweeper found nothing blocking. Approving.

Diagnostics

Total spend: $0.0055

@M3gA-Mind
M3gA-Mind merged commit a642df6 into tinyhumansai:main Oct 23, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant