Skip to content

Bounded log ring writer with cursor-read helper: journald or file feed (rigforge#682 chunk 2/3) #691

Open

Description

@pithead-architect

What's the problem

No bounded, machine-readable recent-log buffer exists on a RigForge rig. Appliance XMRig logs go to a volatile journal (only the interactive logs verb shells journalctl); standalone rigs keep $WORKER_ROOT/xmrig.log. A rig that crashes or reboots leaves no evidence a coordinator could later pull (parent rigforge#682; consumer pithead#4017).

What it impacts

Local-only new surface: a ring-writer util, a systemd unit, logs/log_ring_mb config keys and rigforge.sh apply/uninstall/doctor plumbing. Nothing is served over HTTP in this chunk, so no worker-to-Pithead wire contract changes yet — but a new unit runs on real rigs.

How I found it

Parent rigforge#682 ("The ring is bounded (size configurable); standalone file logs and appliance journald both work"). Read both log sources (rigforge.sh:1051-1053 LOG_FILE_PATH; the logs verb's journalctl path) and the rigforge-api.service + refresh-timer install/uninstall pattern (rigforge.sh:1400-1427, 2257-2260) this unit mirrors.

How important is it

Required by rigforge#682 and a blocker for its chunk 3: the route has nothing to serve without the ring.

Acceptance criteria

  • util/log-ring.py (python3 stdlib) follows one source — appliance journald (journalctl -u <miner unit> -f, selected when RIGFORGE_APPLIANCE=1) or the standalone $WORKER_ROOT/xmrig.log — with an explicit source argument so tests drive both paths without systemd, and appends newline-delimited JSON entries {"seq":N,"ts":ISO8601,"line":...} to a ring file in the API runtime dir. seq is strictly monotonic and survives writer restarts (persisted counter; never reset while the ring exists). Ordering is by seq, never by ts, so a wall-clock jump cannot reorder or corrupt the ring (a jumped timestamp is stored as-is).
  • Every stored line passes through chunk 1's util/log-redact.py before it hits disk.
  • Ring is byte-bounded by log_ring_mb (default 2 MiB, accepted 1..64): on overflow the oldest entries are dropped and the ring records the oldest surviving seq plus total appended, so a reader can report lost lines. A read helper in the same module returns (entries with seq > cursor, next_cursor, lost-lines report) — this is what chunk 3's route calls.
  • New config keys logs ("disabled" default | "enabled") and log_ring_mb in config.reference.json (+_docs) and docs/configuration.md, strictly validated like existing keys. logs=disabled (default) installs and starts nothing.
  • New systemd/rigforge-log-ring.service.template (Restart=on-failure, shares RuntimeDirectory=rigforge-api with the API) installed/enabled/started by apply only when enabled, removed by apply-off/uninstall; doctor reports the writer's state like api-refresh (rigforge.sh:5319 pattern).
  • tests/run.sh cases (red on base): ring fills from a fed file source and from a shimmed journald source; ring file never exceeds the configured cap and rotation reports the exact lost-line count; a cursor read returns the next chunk and reports loss after wrap; seq survives a writer restart with the ring file kept; a fed line carrying a token, a pool password and a wallet address lands fully redacted; logs=disabled installs nothing.

Possible solutions

One long-running follow process (journalctl -f / follow file) piped through the redactor into an appender — event-driven, so no polling rate; JSONL ring with a one-line header for rotation bookkeeping; the read helper lives in the same module for the API server to import.

Parent: #682

Worker brief: Test tier: tier4-e2e — a rig-side runtime change (new systemd unit on real rigs), so per RigForge rules it needs the bench tier-4 job, never a tier-1 string check: on a bench rig enable logs, show the ring fills on the appliance journald path, stays bounded at the configured log_ring_mb, and reports loss after wrap. Plus GitHub tiers 1-3 (lints + tests/run.sh unit cases for bounds, cursor loss, both sources, redaction at rest, disabled-installs-nothing). Submit through bin/bench-submit with --base develop on the pushed full SHA; paste the unedited bench-ci evidence block. Keep rigforge.sh inside its 6207-line file-budget ceiling (FILE_BUDGET_REQUIRE_BASE=1 bash scripts/lint-file-budget.sh before proof): put logic in util/log-ring.py, not rigforge.sh. No comments or docstrings in edited hunks. Blocked by the rigforge#682 redactor chunk (imports util/log-redact.py).

Release: issue rigforge#690 closed
Who: operator

Activity

  1. added
    needs-triage
    size:M
    on Nov 13, 2026
  2. added this to the v1.20.0 milestone on Nov 17, 2026
  3. pithead-developer commented on Nov 23, 2026

    @pithead-developer
    Contributor

    Needs an operator action (do it, then remove the operator-action label):

    The runner stopped a respawn loop after 3 fresh workers reached error within six hours. Inspect the repeated outcome, then remove this label to release one new worker.

  4. added
    operator-action
    on Nov 23, 2026
  5. pithead-architect commented on Nov 27, 2026

    @pithead-architect
    Author

    Release regroom (owner request, 2026-11-27): moved from v1.20.0 to v1.21.0. Trimmed from v1.20.0 (update API only) per the owner. Log tail API; the pithead log store depends on it.

  6. added
    operator-hold
    and removed
    operator-action
    on Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageoperator-holdsize:M

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions