Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d339d53
fix(devtools): recover complete red testmon graphs
Sinity Aug 8, 2026
b5ce090
fix(devtools): harden testmon seed recovery provenance
Sinity Aug 8, 2026
3b1ab74
fix(devtools): bind testmon recovery artifacts
Sinity Aug 8, 2026
90a69dc
fix(devtools): keep incomplete testmon attempts non-releasable
Sinity Aug 9, 2026
0575473
fix(devtools): preserve fail-closed testmon provenance
Sinity Aug 9, 2026
2b80951
fix(devtools): satisfy testmon provenance typing
Sinity Aug 9, 2026
3af9ec1
fix(devtools): bind testmon run receipts
Sinity Aug 9, 2026
a422770
fix(devtools): keep red testmon attempts selection-only
Sinity Aug 9, 2026
ac768db
fix: preserve typed testmon recovery authority
Sinity Aug 9, 2026
657b35b
fix: separate affected and release verification gates
Sinity Aug 9, 2026
84c41dc
test: cover verification scope combinations
Sinity Aug 9, 2026
ab2e789
ci: synchronize PR scope carrier
Sinity Aug 9, 2026
ef82c3b
fix: harden testmon terminal authority
Sinity Aug 9, 2026
a779761
fix: guard skipped slow seed promotion
Sinity Aug 9, 2026
708d069
fix: require typed seed promotion authority
Sinity Aug 9, 2026
5e01ad7
fix: validate persisted train authority
Sinity Aug 9, 2026
c626736
test: satisfy testmon authority typing
Sinity Aug 9, 2026
0c2390c
fix: bind terminal verification to merged master
Sinity Aug 9, 2026
5a22ae7
fix: publish testmon bootstrap atomically
Sinity Aug 9, 2026
f0cb999
fix: harden testmon recovery publication
Sinity Aug 9, 2026
e4ed36e
fix: bind terminal verification to durable merge state
Sinity Aug 9, 2026
7d1cf1b
fix: make merge-train recovery transactional
Sinity Aug 9, 2026
7f5840b
fix(testmon): cap seed worker concurrency
Sinity Aug 10, 2026
4590cda
fix(verify): record capped pytest concurrency
Sinity Aug 10, 2026
7b3b29b
fix(testmon): close validated SQLite reads
Sinity Aug 10, 2026
10265a1
fix(testmon): validate local bootstrap attempts
Sinity Aug 10, 2026
14ea1ce
fix(testmon): prove selection attempt source
Sinity Aug 10, 2026
1d0b1c5
fix(testmon): bind reusable state to runtime environment
Sinity Aug 10, 2026
3ac00e8
fix(merge): recover terminal verification state
Sinity Aug 10, 2026
4d6f93e
fix(testmon): type runtime fingerprint metadata
Sinity Aug 10, 2026
5bcbb41
fix(testmon): validate staged bootstrap runtime inputs
Sinity Aug 10, 2026
2d95500
fix: bind testmon state to test behavior environment
Sinity Aug 10, 2026
e27caee
fix: type focused verification receipts
Sinity Aug 10, 2026
cd3cbbf
fix: type focused verification receipts
Sinity Aug 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions devtools/checkout_guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@

import tomllib

from devtools.testmon_state import attempt_is_checkout_bound, seed_marker_is_checkout_bound


class CheckoutImportMismatchError(RuntimeError):
"""``import polylogue`` resolved to a package outside the invoking checkout."""
Expand Down Expand Up @@ -130,6 +132,7 @@ def as_dict(self) -> dict[str, object]:
_TESTMON_STATE_DIR = Path(".cache/testmon")
_TESTMON_STATE_MARKER = _TESTMON_STATE_DIR / "seed.json"
_TESTMON_SEED_ATTEMPT = _TESTMON_STATE_DIR / "seed-attempt.json"
_TESTMON_SEED_PROTOCOL_VERSION = 5
_VERIFY_STATE_DIR = Path(".cache/verify")
_VERIFY_STATE_MARKER = _VERIFY_STATE_DIR / "current-run.json"

Expand Down Expand Up @@ -249,6 +252,10 @@ def _marker_origin(marker: Path) -> Path | None:
if not isinstance(payload, Mapping):
return None
raw = payload.get("checkout_root")
if raw is None:
binding = payload.get("binding")
if isinstance(binding, Mapping):
raw = binding.get("checkout_root")
if raw is None:
fingerprint = payload.get("environment_fingerprint")
if isinstance(fingerprint, Mapping):
Expand All @@ -258,7 +265,7 @@ def _marker_origin(marker: Path) -> Path | None:
return Path(raw).resolve()


def _is_valid_in_progress_testmon_seed_attempt(attempt: Path) -> bool:
def _is_valid_in_progress_testmon_seed_attempt(attempt: Path, *, checkout_root: Path) -> bool:
"""Recognize the live seed ledger before its completion marker exists.

``verify --seed-testmon`` writes this receipt before pytest starts and
Expand All @@ -270,8 +277,25 @@ def _is_valid_in_progress_testmon_seed_attempt(attempt: Path) -> bool:
payload = json.loads(attempt.read_text(encoding="utf-8"))
except (OSError, UnicodeDecodeError, json.JSONDecodeError):
return False
if not isinstance(payload, Mapping) or payload.get("status") not in {"running", "incomplete"}:
if not isinstance(payload, Mapping) or payload.get("status") not in {
"running",
"incomplete",
"reusable",
"complete",
}:
return False
if payload.get("status") == "complete":
return attempt_is_checkout_bound(
payload,
checkout_root=checkout_root,
protocol_version=_TESTMON_SEED_PROTOCOL_VERSION,
Comment on lines +287 to +291

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Permit unpublished complete attempts for selection

If a linked-worktree seed is interrupted after _finalize_testmon_seed_attempt writes a status: complete attempt but before it publishes seed.json, this branch calls attempt_is_checkout_bound with its default reusable_only=True; that predicate requires release_baseline_allowed is False, while a complete attempt records it as true. decide_testmon_bootstrap already recognizes this same attempt through stamp_from_attempt(..., published_marker=False) and therefore skips replacement, but the subsequent checkout guard rejects the cache, leaving the lane unable to run affected verification. Accept the complete receipt here as selection-only while continuing to withhold release authority until seed.json exists.

AGENTS.md reference: AGENTS.md:L338-L341

Useful? React with 👍 / 👎.

)
if payload.get("status") == "reusable":
return attempt_is_checkout_bound(
payload,
checkout_root=checkout_root,
protocol_version=_TESTMON_SEED_PROTOCOL_VERSION,
)
Comment on lines +287 to +298

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Collapse the two identical status branches.

The complete and reusable branches call attempt_is_checkout_bound with identical arguments. attempt_is_checkout_bound already restricts accepted statuses to {"reusable", "complete"} when reusable_only is the default. One branch expresses the same contract.

♻️ Proposed consolidation
-    if payload.get("status") == "complete":
-        return attempt_is_checkout_bound(
-            payload,
-            checkout_root=checkout_root,
-            protocol_version=_TESTMON_SEED_PROTOCOL_VERSION,
-        )
-    if payload.get("status") == "reusable":
+    if payload.get("status") in {"complete", "reusable"}:
         return attempt_is_checkout_bound(
             payload,
             checkout_root=checkout_root,
             protocol_version=_TESTMON_SEED_PROTOCOL_VERSION,
         )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if payload.get("status") == "complete":
return attempt_is_checkout_bound(
payload,
checkout_root=checkout_root,
protocol_version=_TESTMON_SEED_PROTOCOL_VERSION,
)
if payload.get("status") == "reusable":
return attempt_is_checkout_bound(
payload,
checkout_root=checkout_root,
protocol_version=_TESTMON_SEED_PROTOCOL_VERSION,
)
if payload.get("status") in {"complete", "reusable"}:
return attempt_is_checkout_bound(
payload,
checkout_root=checkout_root,
protocol_version=_TESTMON_SEED_PROTOCOL_VERSION,
)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@devtools/checkout_guard.py` around lines 287 - 298, Consolidate the duplicate
status handling around attempt_is_checkout_bound by using one condition that
accepts both "complete" and "reusable" statuses, then perform the existing call
once with the same arguments. Preserve the default reusable_only behavior and
leave other statuses on their existing path.

protocol_version = payload.get("protocol_version")
if not isinstance(protocol_version, int) or isinstance(protocol_version, bool) or protocol_version <= 0:
Comment on lines 299 to 300

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require the current protocol for in-progress attempts

When a linked worktree contains a markerless running or incomplete attempt left by an older testmon protocol, this accepts any positive protocol version rather than the guard's current version 5. The cache is therefore classified as trustworthy even though current validation and preflight cannot interpret it, allowing guarded entrypoints to proceed with stale foreign state until verification later fails; require protocol_version == _TESTMON_SEED_PROTOCOL_VERSION before granting this exception.

AGENTS.md reference: AGENTS.md:L338-L341

Useful? React with 👍 / 👎.

return False
Expand Down Expand Up @@ -331,12 +355,32 @@ def _cache_artifact(
marker_path = repo_root / marker
origin = _marker_origin(marker_path)
if origin == repo_root:
if state_dir == _TESTMON_STATE_DIR and not seed_marker_is_checkout_bound(
marker_path,
checkout_root=repo_root,
protocol_version=_TESTMON_SEED_PROTOCOL_VERSION,
):
return (
origin,
EnvironmentArtifact(
kind="invalid_testmon_seed",
path=marker_path,
detail="testmon seed marker is stale, malformed, or its SQLite graph is incomplete",
remediation=(
f"remove {state_path} and run `devtools verify --seed-testmon` "
"to rebuild the typed testmon state"
),
),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
)
return origin, None
if (
origin is None
and not marker_path.exists()
and state_dir == _TESTMON_STATE_DIR
and _is_valid_in_progress_testmon_seed_attempt(repo_root / _TESTMON_SEED_ATTEMPT)
and _is_valid_in_progress_testmon_seed_attempt(
repo_root / _TESTMON_SEED_ATTEMPT,
checkout_root=repo_root,
)
):
return None, None
if origin is None:
Expand Down
Loading