mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-27 20:29:18 +01:00
leetcode_coach.relay implements DOCS-coach-relay.md: one paced serial lane (1 start / 3 s, 5 queued, done-map re-answers a rid), the loopback API on 127.0.0.1:8777 (Host check, JSON only, 16 KiB), the RTDB request/result/ state/chat/heartbeat mirror over SSE with 60 s rescans and 24 h cleanup, the five-step state machine derived from the session log, graders (steps 1/5 haiku -> Ollama, fail open "unverified"; step 2 through PhaseGate.screen; step 3 mechanical against answer_key.json), the CLI's sonnet chat with the log in the child env and the local hand-over, run-code on node --permission, and step 4 through the harvester's read-only fetch_recent_ac once a minute (three-valued: unknown is never "not yet"). New log events session_start/grade/chat/session_end land in session_log, _coach_log and _well_formed together; the snapshot rows gain grades and accepted (_coach_grades). A forced step-2 grade opens code (phase.req_state). leetcode-coach-relay.service + an install.sh step (not run). Contract fixes in the same commit: step 3 counts also_accepted and combined entries' parts, step-2 grade events and the force event shape, next_step, per-call model caps instead of a 280 s watchdog, heartbeat on busy changes, the statement fetched in-process, enable + restart on reinstall. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PjvF5DZG9JduSBYKxqyysi
17 lines
512 B
Python
17 lines
512 B
Python
"""The one exception a request handler raises to answer with an error result."""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
class CoachError(Exception):
|
|
"""Answer the request with ``code``; the message is shown to kuhy."""
|
|
|
|
def __init__(
|
|
self, message: str, *, code: str, retry: bool = False, **extra: object
|
|
) -> None:
|
|
"""Keep the result fields (section 2's error codes)."""
|
|
super().__init__(message)
|
|
self.code = code
|
|
self.retry = retry
|
|
self.extra = extra
|