## Description
Replace argv-based proxy client detection with per-port wrap client
markers so cleanup and ephemeral restarts do not tear down a shared
proxy while another wrapped session is still attached.
Also prune stale markers, guard against PID reuse when process identity
is available, and add coverage for the marker-based lifecycle behavior.
Fixes#804
## Type of Change
- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)
## Testing
Describe the tests you ran to verify your changes:
- [x] Unit tests pass (`pytest`)
- [x] Linting passes (`ruff check .`)
- [x] Type checking passes (`mypy headroom`)
- [x] New tests added for new functionality
---------
Co-authored-by: JerrettDavis <mxjerrett@gmail.com>
Three scenarios lock the issue-175 additive guarantee:
1. Legacy-only user (HEADROOM_SAVINGS_PATH set, canonical unset) still
gets the byte-for-byte legacy value.
2. Canonical-only user (HEADROOM_WORKSPACE_DIR set) sees every workspace
bucket resource relocate with the correct filenames.
3. Both set: legacy per-resource env var wins over canonical root env
for its own resource; other unreserved helpers still follow the new
canonical root (orthogonality).
Plus a regression guard asserting all three legacy vars (savings, toin,
subscription) simultaneously beat the canonical workspace override.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>