check.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
9 hours ago
| 1 | """Fail-closed Muse-sync hard gate (§KH2.4). |
| 2 | |
| 3 | Detects the precise, narrow condition that motivated this module: Git has |
| 4 | already captured a change (its working tree is clean) while Muse's tracked |
| 5 | snapshot still differs from the current working tree (Muse has not been |
| 6 | committed to since). Mid-edit work — where *both* VCS working trees are |
| 7 | dirty because nothing has been committed anywhere yet — is deliberately |
| 8 | never flagged; see §KH2.4/§KH2.6 for the frozen non-trigger rules. |
| 9 | """ |
| 10 | |
| 11 | from __future__ import annotations |
| 12 | |
| 13 | from dataclasses import dataclass |
| 14 | |
| 15 | from adapters.config import OverseerConfig |
| 16 | from adapters.types import StatusResult |
| 17 | |
| 18 | MUSE_GIT_MIRROR_REGIME = "muse+git-mirror" |
| 19 | REMEDIATION = 'muse code add -A && muse commit -m "<message>"' |
| 20 | |
| 21 | |
| 22 | @dataclass(frozen=True) |
| 23 | class MuseSyncReport: |
| 24 | """Result of a Muse-sync probe — no shell, no inference from docs.""" |
| 25 | |
| 26 | regime: str |
| 27 | state: str # synced | pending | not_applicable | unreadable |
| 28 | message: str |
| 29 | remediation: str | None |
| 30 | |
| 31 | @property |
| 32 | def ok(self) -> bool: |
| 33 | return self.state in {"synced", "not_applicable"} |
| 34 | |
| 35 | |
| 36 | def check_muse_sync(config: OverseerConfig, status: StatusResult) -> MuseSyncReport: |
| 37 | """Resolve a ``MuseSyncReport`` from a single already-fetched ``StatusResult``. |
| 38 | |
| 39 | Pure function of ``(config.vcs.regime, status.muse_dirty, status.git_dirty)`` — |
| 40 | no I/O, no additional command execution (§KH2.8 data-integrity / performance). |
| 41 | """ |
| 42 | regime = config.vcs.regime |
| 43 | if regime != MUSE_GIT_MIRROR_REGIME: |
| 44 | return MuseSyncReport( |
| 45 | regime=regime, |
| 46 | state="not_applicable", |
| 47 | message=f"{regime}: single history — no cross-VCS sync gap possible", |
| 48 | remediation=None, |
| 49 | ) |
| 50 | |
| 51 | if status.muse_dirty is None or status.git_dirty is None: |
| 52 | return MuseSyncReport( |
| 53 | regime=regime, |
| 54 | state="unreadable", |
| 55 | message="could not determine Muse/Git working-tree state — failing closed", |
| 56 | remediation="re-run ok status once the adapter can read muse/git state", |
| 57 | ) |
| 58 | |
| 59 | if status.muse_dirty and not status.git_dirty: |
| 60 | return MuseSyncReport( |
| 61 | regime=regime, |
| 62 | state="pending", |
| 63 | message=( |
| 64 | "Git working tree is clean but Muse has not captured the current tree — " |
| 65 | "a commit landed in Git without a matching `muse commit`" |
| 66 | ), |
| 67 | remediation=REMEDIATION, |
| 68 | ) |
| 69 | |
| 70 | return MuseSyncReport( |
| 71 | regime=regime, |
| 72 | state="synced", |
| 73 | message="Muse and Git working trees are consistent", |
| 74 | remediation=None, |
| 75 | ) |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
8 hours ago