mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-19 11:34:32 +01:00
Dependencies (exact pins): claude-agent-sdk 0.2.183, rtdb-relay 0.1.1, httpx 0.28.1, hypothesis 6.170.15 (dev). The pylint hook env gets the same pins. Entry points, each reachable only through one module attribute: _claude_connect.connect_sealed (RTDB + e2e unlock), _claude_sdk.run_model (the model call), _claude_sync.pull_peers / publish (narrow pull, full tick). SDK and rtdb_relay are imported only by these modules, never by the gate or CLI at load time. Test isolation, all fail closed: connect_sealed and run_model are replaced by a function that raises; pull/publish return None; the sandbox dir and kuhy's real Claude login path point into tmp_path; _test_guard also protects ~/.config/diet_guard_claude and ~/.cache/diet_guard. Each of the six redirects was removed once and its canary went red (fail closed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWZHWP4KZ6x5TcXDBFC
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
"""Where the "send to Claude" relay lives in RTDB and what is sealed.
|
|
|
|
The contract is ``docs/DOCS-claude-relay.md``; ``tests/fixtures/
|
|
claude_relay_contract.json`` pins the same layout for the phone. The root is
|
|
chosen so its e2e header is the one diet_guard already uses
|
|
(``diet-guard-sync/e2e``): same passphrase, same salt, same key.
|
|
|
|
Imports ``rtdb_relay`` and ``crdt_sync``, so only the relay worker's own
|
|
modules import this one -- never the gate or the CLI at load time.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Final
|
|
|
|
from crdt_sync import E2eLayout
|
|
from rtdb_relay.layout import Layout
|
|
|
|
#: The unencrypted-era prefix the e2e root and header are derived from.
|
|
OLD_PREFIX: Final = "diet-guard-sync/claude"
|
|
E2E_LAYOUT: Final = E2eLayout.of(OLD_PREFIX)
|
|
ROOT: Final = E2E_LAYOUT.prefix
|
|
|
|
#: The only request kind this relay serves.
|
|
KIND: Final = "meal"
|
|
|
|
LAYOUT: Final = Layout(
|
|
root=ROOT,
|
|
clear=("requests/*/claim",),
|
|
units={
|
|
"requests/*/req": frozenset({"created"}),
|
|
"requests/*/result": frozenset({"at"}),
|
|
},
|
|
)
|