musehub.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
2 days ago
| 1 | """Optional MuseHub read adapter (§HGD.4.1) — never sole baseline (K7).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from dataclasses import dataclass |
| 6 | from urllib.parse import quote |
| 7 | |
| 8 | from tools.hosted_dashboard.http_client import UpstreamClient, UpstreamError |
| 9 | |
| 10 | |
| 11 | @dataclass(frozen=True) |
| 12 | class MuseFileContent: |
| 13 | """MuseHub-fetched file bytes.""" |
| 14 | |
| 15 | path: str |
| 16 | text: str |
| 17 | raw: bytes |
| 18 | sha256: str |
| 19 | ref: str |
| 20 | source_id: str = "musehub_read" |
| 21 | |
| 22 | |
| 23 | class MuseHubReadAdapter: |
| 24 | """Optional deepen — requires configured finite host allowlist entries.""" |
| 25 | |
| 26 | def __init__(self, client: UpstreamClient, *, base_url: str) -> None: |
| 27 | self._client = client |
| 28 | self._base = base_url.rstrip("/") |
| 29 | |
| 30 | def fetch_file(self, owner: str, repo: str, path: str, *, ref: str) -> MuseFileContent: |
| 31 | url = f"{self._base}/repos/{quote(owner)}/{quote(repo)}/contents/{quote(path, safe='/')}?ref={quote(ref)}" |
| 32 | raw = self._client.get_bytes(url, accept="application/octet-stream") |
| 33 | from tools.hosted_dashboard.cache import EphemeralByteCache |
| 34 | |
| 35 | digest = EphemeralByteCache.digest(raw) |
| 36 | return MuseFileContent( |
| 37 | path=path, |
| 38 | text=raw.decode("utf-8", errors="replace"), |
| 39 | raw=raw, |
| 40 | sha256=digest, |
| 41 | ref=ref, |
| 42 | ) |
| 43 | |
| 44 | |
| 45 | def musehub_baseline_impossible(*, github_contents_enabled: bool) -> bool: |
| 46 | """K7: MuseHub-only baseline is impossible — github_contents must remain enabled.""" |
| 47 | return not github_contents_enabled |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
2 days ago