Files
xjxandlilei 2844e08037 test: strip sibling env overrides from isolated generation-lifecycle children (#55)
## Summary

Fixes the intermittent `integration_b` failure observed under parallel
load (once on 2026-08-23 local validation; the same class was last seen
in CI on 2026-08-18 and partially addressed by #46).

**Root cause.** `generation_lifecycle` tests run in child processes
spawned by `run_in_isolated_process`, which strips a fixed key list from
the child environment. A sibling `app_server_transport` test
(`turn_event_stdout_eof_fails_immediately`) sets
`APC_TEST_PET_STUDIO_TURN_TIMEOUT_MS=5000` process-wide in the shared
parent via `EnvGuard`. When a lifecycle spawn happened inside that
window, the child inherited the 5-second override, the fake app-server
turn hit `turn did not complete within 5000 ms`, the edit job landed in
`recoverable_error`/`Failed`, and the test then waited 180 s for a
`generation_failed` terminal message that never came — surfacing as an
unrelated timeout panic far from the real trigger.

## Changes
(`crates/petcore/tests/integration_b/generation_lifecycle.rs`, +93
lines, no production code)

- Extend `ISOLATED_ENV_KEYS` from 5 to 17 keys: every process-wide
override any sibling integration_b test can hold (`APC_TEST_*`
timing/count/path hooks and the skill-source strictness gates).
- Take `test_support::lock_process_state()` around the isolated-child
spawn so no sibling holds an override while the child environment is
captured.
- Add
`isolated_child_environment_strips_every_sibling_process_wide_override`:
parses the sibling suite source and fails if any `EnvGuard::set` key is
missing from the strip list (drift guard in both directions).
- Add `isolated_child_spawn_clears_leaked_studio_turn_timeout_override`:
reproduces the exact leak (parent holds the 5 s override, spawns child)
and asserts the child does not observe it.
- Changelog fragment under `changes/unreleased/`.

## Validation

- New tests: both pass; parity test verified to fail against the pre-fix
list.
- Leak-window stress (EOF test holding the override, concurrent with all
lifecycle isolated spawns, 8 threads × 8 rounds): 8/8 pass.
- Full `integration_b` × 3: 3/3 pass (42 tests each). `integration_a`
96, `integration_c` 66, `integration_d` 164, petcore lib 301, CLI +
types: all pass.
- `cargo fmt --check` clean, `clippy --all-targets` zero warnings,
`script/validate_pre_push.sh --base origin/main` passed.
- No production code changed; runtime behavior is untouched (test-only
env gating already existed).

## Development claim / 开发声明

- Domain: `release-control-plane`
- Claim: `engineering-speedup`
- Base commit: `ee53d683413b2c4ba6a308dc5e7d76293ca0cf6f`
- Release preparation: `no`
- Focused validation:
  - `python3 script/tests/test_validation_tooling.py`
  - `./script/validate_build_scripts_safety.sh --static-only`

<!-- apc-engineering-coordination-v1
{"claim_overlap_rejections":1,"merge_tree_conflicts":0,"schema_version":"apc.engineering-coordination.v1","task_created_at":"2026-08-24T01:52:17Z","train_conflict_resolutions":0}
-->

---------

Co-authored-by: lilei <lilei@xmfunny.com>
2026-08-24 18:12:31 +08:00
..