CI / checks (push) Skipped
CI / checks (pull_request) Successful in 1m22s
Development Plan M0.1. Every section reference in code, tests, specs/, the example config, the tuning guide, and the CLAUDE.md and README files now cites docs/Architecture.md (P, L, D, O, X, Q) instead of the old spec's A-H, and docs/Architecture-Build-Spec.md is deleted (git keeps it). The plan's old-to-new table goes with it. Mostly mechanical, with a per-site choice where one old section split: A4 became L2 where it meant stop/abandon/the loop and L3 where it meant approvals; A10 became L6 in the context-budget code and L7 elsewhere; B2 became D4 for outbound Gitea and publishing and D5 for review intake; 'A3 step N' became the matching step of L8's boot sequence. Comments describing behaviour the architecture drops (planning always escalating, thresholds tuned at an old build step) now describe the current code and point at the Development Plan. docs/Architecture.md gains one line the rewrite missed: intake outages delay but never fail work (old B2), now in L5, where the poller and Matrix code cite it. Comments and docs only; no behaviour change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPQ14L3LikyefCMFBqEbKE
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
"""Structured operational logging (architecture L12).
|
|
|
|
One JSON object per line to stderr (journald captures it when running as a
|
|
service). Every event carries the fixed envelope: ts, agent, event, task_id,
|
|
cause. Logs are diagnostic, never load-bearing — nothing may read them back
|
|
to derive state.
|
|
"""
|
|
|
|
import json
|
|
import sys
|
|
from datetime import UTC, datetime
|
|
from typing import Any, TextIO
|
|
|
|
|
|
class OpLog:
|
|
def __init__(self, agent: str, stream: TextIO | None = None) -> None:
|
|
self.agent = agent
|
|
# Correlation ID for the enclosing unit of work; the orchestrator sets
|
|
# it when a unit starts and clears it when the unit ends (L12).
|
|
self.task_id: str | None = None
|
|
self._stream = stream if stream is not None else sys.stderr
|
|
|
|
def emit(self, event: str, *, cause: str, **fields: Any) -> None:
|
|
record: dict[str, Any] = {
|
|
"ts": datetime.now(UTC).isoformat(),
|
|
"agent": self.agent,
|
|
"event": event,
|
|
"task_id": self.task_id,
|
|
"cause": cause,
|
|
**fields,
|
|
}
|
|
self._stream.write(json.dumps(record) + "\n")
|
|
self._stream.flush()
|