Skip to content

test(invariants): cover lock-file ownership, instance lock, channel stop and worker paths - #16

Merged
Blackwellcode merged 2 commits into
masterfrom
test/invariant-coverage
Nov 12, 2026
Merged

Blackwellcode merged 2 commits into
masterfrom
test/invariant-coverage

Conversation

@Blackwellcode

Copy link
Copy Markdown
Owner

Summary

Adds tests for the invariant functions that still had none (audit finding T1, 06-tests 1.3 a/c/d). No production code changes.

tests/test_invariants.py
├── ChannelLockFileTests              lock file carries the child PID; release only by holder / matching PID
├── InstanceLockRealFlockTests        (POSIX) second recorder instance exits 1 while the flock is held
├── StopChannelProcessRealChildTests  (POSIX, fork) worker ignoring SIGTERM is SIGKILLed within the deadline
└── WorkerVodTaskPathTests            _safe_vod_task_path rejects traversal, absolute, temp and symlinked names

Split out of #14, which keeps only the error-handling changes.

Evidence

  • Before: worker._safe_vod_task_path 1/17 lines executed; try_acquire_channel_lock 1/23, update_channel_lock_pid 1/15, release_channel_lock 1/27 (local Windows coverage run).
    After: 17/17, 14/23, 10/15, 18/27. python -m unittest tests.test_invariants -> Ran 38 tests ... OK (skipped=11) on Windows.
  • The instance-lock, SIGKILL and symlink tests only run on Linux (CI). In the CI run of fix: remove the last broad exception handlers, cover remaining invariants #14 they reported ok.

Merge Danger

Door: two-way

Blast Radius: none

Tests only. On Linux CI, the fork-based test adds about 0.5 s.

🤖 Generated with Claude Code

Blackwellcode and others added 2 commits November 12, 2026 16:20
…top and worker paths

Closes the remaining gaps from the test audit (06-tests 1.3 a/c/d):

- ChannelLockFileTests: the lock file carries the child PID after spawn;
  release_channel_lock() leaves a held or foreign lock alone unless the
  PID matches.
- InstanceLockRealFlockTests (POSIX): a second recorder instance exits
  with status 1 while another process holds the instance flock.
- StopChannelProcessRealChildTests (POSIX, fork): a channel worker that
  ignores SIGTERM is SIGKILLed within the deadline.
- WorkerVodTaskPathTests: _safe_vod_task_path() rejects traversal,
  absolute names, temp/non-archive files and symlinks out of the archive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Blackwellcode Blackwellcode reopened this Nov 12, 2026
@Blackwellcode
Blackwellcode merged commit e9e7a64 into master Nov 12, 2026
5 of 8 checks passed
@Blackwellcode
Blackwellcode deleted the test/invariant-coverage branch November 12, 2026 15:43
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