Patch Client¶
Patch Client — mvp.patch_client
Cluster: Uncategorised | Type: component | MCP Tools: None
Overview¶
Client-side patch management. Submits diagnostic reports to a patch server, checks bug status, downloads and applies patches with cryptographic signature verification (Ed25519), lists applied patches from the local manifest, rolls back previously applied patches, and checks for available updates.
Patches can also be applied offline from .g6p files. Includes a hotfix overlay system that intercepts component imports to apply in-memory patches without restarting the process.
When to use:
- Submitting crash diagnostics to a central patch server for automated fix generation
- Applying signed patches in production with cryptographic verification
- Operating in air-gapped environments where
.g6poffline patch files are the only update path
Example:
from mvp.patch_client import PatchClientBlock, PatchClientInput
block = PatchClientBlock()
result = block.infer(PatchClientInput(
op="apply",
patch_id="fix-1234",
server_url="https://patches.g6.internal",
))
# result.value -> PatchClientOutput with applied=True, patch_id
Caveats and known limitations:
- Requires optional
httpxlibrary for server communication — degrades to offline-only mode without it - Signature verification uses
get_embedded_public_key()— key source and rotation are not user-configurable - List operation falls back to the local manifest if the server is unreachable, with no cross-check for staleness
- mcp_surface: none — patch operations require operator authorization; mutating submit, apply, and rollback are not exposed for autonomous MCP use
- Rollback removes the hotfix overlay file and manifest row status changes to
rolled_back, invalidates the affectedmvp.*module cache, and the next import falls back to the base package or any lower-priority hotfix. Patch stacking is not explicitly modeled; a future manifestsupersedesfield would be needed for precise stacked rollback semantics - Hotfix overlay intercepts imports at the Python level — not visible to static analysis tools
Works well with: patch_server, diagnostic_collector, immune_system
Public API¶
PatchClientBlock(AIBlock[PatchClientInput, PatchClientOutput, None])¶
Client-side patch management block.
| Field | Type | Default |
|---|---|---|
name | str | 'patch_client' |
Methods:
infer(data: PatchClientInput) -> Result[PatchClientOutput]¶
PatchRecord(BaseModel)¶
A single patch entry.
| Field | Type | Default |
|---|---|---|
patch_id | str | required |
component | str | required |
target_version | str | required |
created_at | str | '' |
files | dict[str, str] | Field(default_factory=dict) |
sha256 | dict[str, str] | Field(default_factory=dict) |
signature | str | '' |
status | str | 'available' |
PatchManifest(BaseModel)¶
Mutable manifest updated on disk as patches are applied/rolled back.
| Field | Type | Default |
|---|---|---|
g6_version | str | '0.0.0' |
patches | list[PatchRecord] | Field(default_factory=list) |
PatchClientInput(BaseModel)¶
Input for PatchClientBlock.
| Field | Type | Default |
|---|---|---|
op | Literal['submit', 'check', 'apply', 'list', 'rollback', 'check_update', 'capabilities'] | required |
diagnostic_report | str | '' |
bug_id | str | '' |
patch_id | str | '' |
file_path | str | '' |
component | str | '' |
current_version | str | '' |
server_url | str | '' |
api_key | str | '' |
PatchClientOutput(BaseModel)¶
Output from PatchClientBlock.
| Field | Type | Default |
|---|---|---|
message | str | '' |
bug_id | str | '' |
patch_id | str | '' |
status | str | '' |
patches | list[dict] | Field(default_factory=list) |
applied | bool | False |
rolled_back | bool | False |
update_available | bool | False |
degraded | bool | False |
degradation_reason | str \| None | None |
available_with | str | '' |
completion_state | Literal['verified', 'qualified-draft', 'blocked-escalated'] | 'qualified-draft' |
warning_card | dict | Field(default_factory=dict) |
evidence | dict | Field(default_factory=dict) |
request_id | str | Field(default_factory=lambda: f'patch-client-{uuid4()}') |
task_id | str | '' |
run_id | str | Field(default_factory=lambda: f'patch-client-{uuid4()}') |
capabilities | dict | Field(default_factory=dict) |
Functions¶
install_hotfix_overlay(hotfix_dir: Path = HOTFIX_DIR) -> None¶
Install the HotfixFinder into sys.meta_path. No-op if dir doesn't exist.
uninstall_hotfix_overlay() -> None¶
Remove all HotfixFinder instances from sys.meta_path.