Package under review: joons_agent_guard 0.1.0 (stdlib-only, SQLite).
Environment: Python 3.14.7, pytest 9.1.1, 64-bit, no network, no package install.
Date: 2026-11-12.
For each mutant below:
-
Copy
src/to./_mutant/src/(pristine copy;src/itself is never modified). -
Apply ONE small change in
./_mutant/src/joons_agent_guard/(exact diffs in the Appendix). -
Run, from the repository root:
PYTHONPATH=_mutant/src python -m pytest -q -p no:cacheprovider -x -
Killed = the suite exits non-zero. With
-x, the reported killing test is the first failing test in pytest's run order. "Seconds" is the wall-clock time of the pytest process (including interpreter/startup overhead), so it is not comparable to the in-CSI time printed inside the summary line. -
Restore:
./_mutant/srcwas re-created fresh fromsrc/before every mutant.
The pristine src/ was never edited: the control run passed before the matrix,
and a final full-suite run after all _mutant work and deletion also passed
(208 passed in 25.43s).
PYTHONPATH=src python -m pytest -q -p no:cacheprovider -x → 208 passed in 25.42s, exit code 0.
| # | Mutant (one change) | File | Killed | Killing test | Seconds | pytest summary |
|---|---|---|---|---|---|---|
| 1 | acquire always returns True |
lock.py |
yes | tests/test_lock.py::test_acquire_succeeds_exactly_once |
2.9 | 1 failed, 46 passed |
| 2 | release ignores job_id |
lock.py |
yes | tests/test_lock.py::test_release_requires_matching_owner_and_job_id |
3.0 | 1 failed, 47 passed |
| 3 | break_lock ignores expected_job_id |
lock.py |
yes | tests/test_lock.py::test_break_lock_only_removes_matching_job |
3.3 | 1 failed, 51 passed |
| 4 | begin allows a second job while one is pending |
circuit.py |
yes | tests/test_circuit.py::test_begin_claims_slot_and_refuses_second_begin |
0.4 | 1 failed, 1 passed |
| 5 | open → closed instead of half_open on begin |
circuit.py |
yes | tests/test_circuit.py::test_finish_success_resets_failures_and_clears_reason |
0.4 | 1 failed, 3 passed |
| 6 | finish does not increment failures |
circuit.py |
yes | tests/test_circuit.py::test_finish_failure_opens_and_stores_reason |
0.5 | 1 failed, 2 passed |
| 7 | claim returns 'new' for a conflicting digest |
replay.py |
yes | tests/test_replay.py::TestClaim::test_conflict_while_pending |
9.0 | 1 failed, 134 passed |
| 8 | complete() allowed when state is not pending |
replay.py |
yes | tests/test_replay.py::TestComplete::test_complete_works_exactly_once |
8.8 | 1 failed, 138 passed |
| 9 | apply_pending runs the effect after COMMIT, stores the response in a second transaction |
replay.py |
yes | tests/test_failure_modes.py::test_apply_pending_effect_crash_leaves_request_pending_and_rolls_back |
2.8 | 1 failed, 44 passed |
| 10 | reserve_outbound generates a new request_id on every call |
replay.py |
yes | tests/test_replay.py::TestReserveOutbound::test_retry_returns_identical_context |
9.2 | 1 failed, 160 passed |
| 11 | write_txn uses plain BEGIN (deferred) instead of BEGIN IMMEDIATE |
_db.py |
yes | tests/test_threads.py::test_per_thread_circuit_breaker_same_file |
21.9 | 1 failed, 204 passed |
| 12 | write_txn without the guard_lock |
_db.py |
yes | tests/test_threads.py::test_shared_resource_lock_single_instance |
11.4 | 1 failed, 200 passed |
Score: 12 / 12 killed.
- M1: a second
acquireof a held resource must reportFalse; the mutant reportsTrue. - M2:
releasewith a wrongjob_idmust be refused and keep the lock; the mutant deletes byresource+owneronly. - M3: a stale
expected_job_idmust not remove a lock re-acquired by a new job; the mutant deletes byresourceonly. - M4: the actor's run slot is single; the mutant lets
begin("a", "job-2")succeed while"job-1"is pending. - M5: the first
beginafter a failure is the recovery attempt and must flip the state tohalf_open; the mutant leaves itclosed, so the recovery state is invisible. - M6: a failed finish must raise
consecutive_failuresto 1; the mutant leaves the counter at its old value. - M7: the same
(principal, request_id)with a different digest must returnconflict; the mutant returnsnew, i.e. it would re-run a replayed request. - M8:
complete()on an already-completed request must returnFalseand keep the first response; the mutant overwrites it (secondcompletereturnsTrue). - M9: with the effect moved after COMMIT, a failing effect leaves the request already marked
completedwith a NULL response and the effect's own partial writes committed; the suite asserts the request is stillpendingand the effect's writes were rolled back, so exactly-once is observably broken. - M10: retrying the same
intent_idmust return the identical context; the mutant returns a freshrequest_idon every call, so a retry no longer maps to one outbound request. - M11: observed failure is
OperationalError('database is locked')from 7 of 8 worker threads. With deferredBEGIN,CircuitBreaker.beginreads (SHARED lock) and then writes inside its transaction; under contention the SHARED→write upgrade fails immediately (busy handler not invoked for the upgrade path), so workers crash instead of serializing. - M12: observed failures are
OperationalError('cannot start a transaction within a transaction')andOperationalError('not an error')— without the re-entrantguard_lock, two threads sharing one connection interleave theirBEGIN/COMMITpairs and corrupt each other's transactions.
Mutants 11 and 12 are killed by timed thread races, so both were run a second
time from a fresh src copy. Both were killed again by the same tests:
- M11:
test_per_thread_circuit_breaker_same_file— killed in 22.3s. - M12:
test_shared_resource_lock_single_instance— killed in 12.0s.
No mutant survived (12/12 killed), so no tests/test_mutants_extra.py was
required by the task and none was created. The suite already contains focused
regression coverage for every mutated behavior listed above.
tests/test_lock_concurrency.py inserts the real ../src at the front of
sys.path so that spawn-started worker processes can import the package.
Under mutation runs this means the multi-process tests in that file (and the
spawn workers of test_replay_concurrency.py) always exercise the pristine
package, not the mutant, and can never kill anything. They also cannot cause a
false kill (pristine code passes them). All 12 kills above come from the
single-process and in-process-thread tests, which do see the mutant.
./_mutantdeleted at the end (verified: it is absent from the repository root).- Helper work files used to drive the matrix were removed; the exact mutations are documented in the Appendix below and are trivially re-appliable.
src/unmodified: pristine suite passes before and after (208 passed).
lock.py(ResourceLock.acquire):return cur.rowcount == 1→return True(after theINSERT OR IGNORE ... time.time()statement).lock.py(ResourceLock.release): SQL"DELETE FROM resource_locks WHERE resource=? AND owner=? AND job_id=?"with params(resource, owner, job_id)→ SQL"DELETE FROM resource_locks WHERE resource=? AND owner=?"with params(resource, owner).lock.py(ResourceLock.break_lock):"DELETE FROM resource_locks WHERE resource=? AND job_id=?", (resource, expected_job_id)→"DELETE FROM resource_locks WHERE resource=?", (resource,).circuit.py(CircuitBreaker.begin):if row and (row[1] is not None or row[0] == "half_open"):→if row and row[0] == "half_open":.circuit.py(CircuitBreaker.begin):state = "half_open" if row and row[0] == "open" else "closed"→state = "closed".circuit.py(CircuitBreaker.finish):failures=CASE WHEN ? THEN 0 ELSE failures+1 END→failures=CASE WHEN ? THEN 0 ELSE failures END.replay.py(ReplayGuard.claim):return stored[1] if stored[0] == digest else CONFLICT→return stored[1] if stored[0] == digest else NEW.replay.py(ReplayGuard.complete):WHERE principal=? AND request_id=? AND digest=? AND state='pending'→WHERE principal=? AND request_id=? AND digest=?.replay.py(ReplayGuard.apply_pending): inside the transaction, the effect call and its response store were replaced byUPDATE requests SET state='completed', code=NULL, response=NULL ...; the effect then runs after thewith _db.write_txn(...)block, and its(code, response)is stored in a second transaction.replay.py(ReplayGuard.reserve_outbound):return context→return candidate(the freshly generated candidate, i.e. a newrequest_idon every call; the stored reservation is untouched)._db.py(write_txn):db.execute("BEGIN IMMEDIATE")→db.execute("BEGIN")._db.py(write_txn):with db.guard_lock:→if True:(the transaction body no longer holds the connection's re-entrant guard lock).
RESULT: task=T17 status=done killed=12/12 files=MUTATION_REPORT.md