Skip to content

tests: hermetic cello spawns, guardrail, pty and flake fixes - #81

Merged
ryuzdev merged 8 commits into
mainfrom
cello/test-hermetic
Nov 19, 2026
Merged

ryuzdev merged 8 commits into
mainfrom
cello/test-hermetic

Conversation

@ryuzdev

@ryuzdev ryuzdev commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

This closes the test-isolation Candidates.

  • Hermetic spawns. tests/common gains cello_command, which runs env_clear() and then applies an allowlist: PATH, TMPDIR, a per-project HOME, plus explicit per-test env. All ~50 binary spawns in 40 test files now go through it.
    • Before: an exported CELLD_FOO=1 made the child refuse to start, and CELLO_DEV_STATE leaked writes outside the temp project.
    • After: the full suite passes with CELLD_X=1 CELLO_DEV_STATE=/tmp/x RUST_LOG=error exported, and nothing writes outside the temp project.
  • Guardrail. hermetic_spawn_guardrail.rs fails if any test outside common/ names CARGO_BIN_EXE_cello.
  • container::pty_tests order dependency. Both tests now set up their own domain (ensure_domain). Each fails alone before the change (asyncrt::set_host_handle must run…) and passes alone after.
  • env_vars::renamed_prefix_tests flake (from rename: celld → cello (crate, binary, CELLO_* env, paths, telemetry), v0.1.0 #79). The refusal check is now a pure refuse_renamed(vars), so the tests no longer mutate the process env. Before: 3/6 runs failed. After: 10/10 pass with a hostile env.
  • PROJECT_COUNT flake. The global cfg(test) counter is removed, and sharing is asserted with Arc::ptr_eq. Before: it failed under a stress run (count 557550 vs 1).

Verified: full cargo test --profile release --locked --no-fail-fast under the hostile env, all targets green; clippy -D warnings clean.

Summary by CodeRabbit

  • Tests
    • Improved consistency and isolation across integration tests by standardizing how test processes are launched and configured.
    • Strengthened checks around runtime initialization, environment-variable validation, and shared resource behavior.
    • Existing conformance scenarios and their expected results remain unchanged.

- common::cello_command / apply_hermetic_env / cello_binary: env_clear plus an explicit allowlist (PATH, TMPDIR, HOME in the fixture tempdir) plus per-test entries.
- Documents why: CELLO_DEV_STATE, RUST_LOG, ambient proxies/TLS vars, and any stray CELLD_* (which makes cello refuse to start).
- Every TestNode::boot (and the two inline spawns plus the disk-full bash wrapper) builds its command with cleared env plus the test's explicit entries; behavior is otherwise unchanged.
- The five files carrying local announced/forward_announce copies now share common/.
- Scans tests/*.rs for CARGO_BIN_EXE_cello outside common/; fails with the offending files and the helper to use.
- exec_rejects_pty_size_before_start and resize_refuses_non_pty_and_zero_dims reached asyncrt::timeout on their valid-size probes, which needs the process domain handle; they passed only when another test installed it first.
- Both now call the shared ensure_domain installer, matching control_timeout_tests and lifecycle_tests.
- Import order and chain reflows only; no semantics.
- It scans the repo's own test sources on disk, not node storage; same allow as every other test file.
- refuse_renamed(vars) is pure over an env iterator; validate() passes std::env::vars_os().
- renamed_prefix_tests no longer touch process env, so parallel siblings and the harness env cannot race them.
- Removes the cfg(test) PROJECT_COUNT counter; the sharing test asserts Arc::ptr_eq plus node contents instead of exact global counts, which parallel tests inflated.
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The pull request adds shared hermetic process-launch helpers and updates conformance tests to use them. It also extracts the renamed-environment-variable check for explicit test inputs and updates PTY and bundle-tree tests.

Changes: Hermetic test process setup

Layer / File(s) Summary
Shared spawn helpers
crates/cello/tests/common/mod.rs, crates/cello/tests/disk_full_conformance.rs
Shared helpers construct Cello commands, clear inherited variables, set project-local HOME, and apply extra environment entries. The disk-full test applies the environment to its Bash command.
Conformance test launches
crates/cello/tests/*_conformance.rs, crates/cello/tests/{d1_export_gate,operator_token,staged_invoke}.rs
Tests use the shared command helper instead of local binary-path and direct command setup. Existing arguments and assertions remain unchanged.
Parameterized launches and shared utilities
crates/cello/tests/{cache_*,egress_policy_conformance,node_identity_conformance,operator_token,queue_dlq_conformance,retire_leftover_conformance,rpc_stub_conformance,runtime_isolate_conformance,staged_invoke,svc_*_conformance,telemetry_http_conformance,tls_roots_conformance,tmp_fs_conformance,trace_context_conformance}.rs
Tests pass environment overrides through the helper. Several tests also use shared listener-announcement and stderr-forwarding utilities.
Spawn guardrail
crates/cello/tests/hermetic_spawn_guardrail.rs
A test scans sibling Rust test files and fails if it finds direct Cargo binary-path lookup or scans no test sources.

Environment-variable validation

Layer / File(s) Summary
Renamed-variable check
crates/cello/env_vars.rs
The CELLD_* scan is extracted into refuse_renamed, which accepts explicit environment pairs. validate passes the process environment, and the renamed-prefix test passes explicit pairs.

Test check updates

Layer / File(s) Summary
PTY runtime initialization
crates/cello/container.rs
The PTY-size and resize tests initialize the shared test runtime before running checks.
Bundle-tree sharing assertions
crates/cello/js.rs
The test-only projection counter is removed. The bundle-tree test checks sharing and separation through pointer identity.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Merge Risk: Minimal · up to 36fbd

This PR isolates test subprocesses from the ambient environment and fixes several test flakes. It does not change production behavior, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "tests: hermetic cello spawns, guardrail, pty and flake fixes" names the main change. The PR adds a cleared-environment spawn helper (cello_command) that migrates roughly 50 test spawns acro…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "tests: hermetic cello spawns, guardrail, pty and flake fixes" names the main change. The PR adds a cleared-environment spawn helper (cello_command) that migrates roughly 50 test spawns across about 40 files, and it adds a guardrail test that blocks bypassing that helper. The title also names the PTY domain setup fix and the renamed-prefix flake fix, which the raw summary and objectives both describe. The title does not mention the removal of the global PROJECT_COUNT counter, but it is a secondary item. The title is concise and specific, so it passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bed9c953-bd57-4e70-b026-0c03c880ac94
Commits

Reviewing files that changed from the base of the PR and between f4b9d07 and 36fbd6d.

Files selected for processing: 48

  • crates/cello/container.rs
  • crates/cello/env_vars.rs
  • crates/cello/js.rs
  • crates/cello/tests/abort_drain_conformance.rs
  • crates/cello/tests/abort_timeout_conformance.rs
  • crates/cello/tests/abort_timer_conformance.rs
  • crates/cello/tests/aes_kw_conformance.rs
  • crates/cello/tests/binding_forgery_conformance.rs
  • crates/cello/tests/cache_conformance.rs
  • crates/cello/tests/cache_eviction_conformance.rs
  • crates/cello/tests/cache_scope_conformance.rs
  • crates/cello/tests/cancelled_lazy_conformance.rs
  • crates/cello/tests/common/mod.rs
  • crates/cello/tests/continuation_resume_conformance.rs
  • crates/cello/tests/d1_concurrency_conformance.rs
  • crates/cello/tests/d1_export_gate.rs
  • crates/cello/tests/disk_full_conformance.rs
  • crates/cello/tests/do_later_ws_conformance.rs
  • crates/cello/tests/ec_raw_conformance.rs
  • crates/cello/tests/egress_policy_conformance.rs
  • crates/cello/tests/env_probe_conformance.rs
  • crates/cello/tests/exec_carrier_conformance.rs
  • crates/cello/tests/exec_signal_conformance.rs
  • crates/cello/tests/gzip_decode_conformance.rs
  • crates/cello/tests/hermetic_spawn_guardrail.rs
  • crates/cello/tests/loader_abort_conformance.rs
  • crates/cello/tests/loader_imports_conformance.rs
  • crates/cello/tests/node_identity_conformance.rs
  • crates/cello/tests/operator_token.rs
  • crates/cello/tests/queue_dlq_conformance.rs
  • crates/cello/tests/retire_leftover_conformance.rs
  • crates/cello/tests/rpc_dispose_conformance.rs
  • crates/cello/tests/rpc_stub_conformance.rs
  • crates/cello/tests/runtime_isolate_conformance.rs
  • crates/cello/tests/shared_waiter_conformance.rs
  • crates/cello/tests/staged_invoke.rs
  • crates/cello/tests/static_dir_index_conformance.rs
  • crates/cello/tests/svc_do_stub_conformance.rs
  • crates/cello/tests/svc_stub_wait_conformance.rs
  • crates/cello/tests/telemetry_http_conformance.rs
  • crates/cello/tests/tls_roots_conformance.rs
  • crates/cello/tests/tmp_fs_conformance.rs
  • crates/cello/tests/trace_context_conformance.rs
  • crates/cello/tests/waituntil_tx_conformance.rs
  • crates/cello/tests/woken_outbound_conformance.rs
  • crates/cello/tests/workflow_budget_conformance.rs
  • crates/cello/tests/ws_close_conformance.rs
  • crates/cello/tests/ws_loader_upgrade_conformance.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@ryuzdev

ryuzdev commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Security review record. Independent reviewer SecCello: OK. refuse_renamed is moved verbatim and validate() still calls it first, so the refusal still runs before anything serves. No security test relied on inherited env (the operator-token tests are pure). .github/Dockerfile are unchanged.

@ryuzdev
ryuzdev merged commit 2f1fcf4 into main Nov 19, 2026
3 checks passed
@ryuzdev
ryuzdev deleted the cello/test-hermetic branch November 19, 2026 08:14
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