Skip to content

feat: per-unit daemon log trail — rebalance summaries, skip reasons, order/fill lines#227

Merged
ArthurBernard merged 2 commits into
developfrom
feat/daemon-unit-event-logs
Jul 14, 2026
Merged

feat: per-unit daemon log trail — rebalance summaries, skip reasons, order/fill lines#227
ArthurBernard merged 2 commits into
developfrom
feat/daemon-unit-event-logs

Conversation

@ArthurBernard

Copy link
Copy Markdown
Owner

Summary

  • Leaf 02/3 of the daemon-logging plan (docs: plan daemon-logging #225): the log now tells each unit's story — one grep-stable INFO summary per evaluated rebalance (unit=… asof=… legs/submitted/round_up/skipped/on_target), round-up/skip decisions with their full LegDecision.reason, order submits (cid/side/qty/px/venue id) at INFO and refusals at WARN, one line per applied fill, unit start/stop/step-error transitions.

Why

  • The 2026-07-14 audit could not tell whether alloc1-kraken's post-genesis silence was dust-skips or a stall — the runner's decisions existed only as invisible DEBUG/bus events. ADR: lifecycle lines live in the per-unit runner (not the shared router); module-logger lines are emitted alongside the EventBus LogEvents (two sinks: daemon.log vs the SSE dashboard feed); step errors log-with-traceback then re-raise.

Changes

  • portfolio_runner.py: rebalance summary (counters partition the universe), INFO skip/round-up reasons, INFO submits / WARN refusals; _prepare_delta returns (delta, action).
  • order_fill_sync.py: additive unit_name; one INFO per applied fill (cid, signed qty, price, fee, fee asset with quote fallback).
  • service_factory.py: threads the unit name into each unit's fill sync.
  • supervisor.py: unit started/stopped INFO, step errors via logger.exception (re-raised), idle ticks at DEBUG.
  • Tests: caplog assertions in runner/fill-sync/supervisor suites (+235 lines).

Changelog

Added under [Unreleased]: per-unit daemon log trail — a unit's inactivity is now explained by the log.

Test plan

  • python -m pytest — 1501 passed, 1 skipped, cov 96.29%
  • ruff check + ruff format --check green
  • Real-data verification: scratch daemon (port 8099, fresh books, real dccd bars) — both units' summary lines (binance legs=14 submitted=3 round_up=2 skipped=9, kraken legs=13 submitted=5 round_up=1 skipped=7), full skip reason (LTC/USDT below 0.5×min_notional), submit+fill pair cid alloc1-binance-BTC/USDT-0 cross-checked exact against the scratch book; idle tick added zero per-unit lines; live daemon untouched
  • CI green

…rs, fills

Make the daemon log tell each unit's story so "why hasn't alloc1-kraken
traded since genesis?" is answerable by grepping logs/daemon.log, while an
idle steady-state tick still adds zero per-unit INFO lines.

- PortfolioRunner: one INFO rebalance-summary per evaluated tick
  (unit / asof / legs / submitted / round_up / skipped / on_target — the four
  counters partition the universe); elevate round_up/skip leg decisions to
  pinned INFO lines carrying the LegDecision.reason; INFO on each accepted
  order (cid/side/qty/symbol/px/venue_id) and WARN on a refused leg. Plain
  submits stay summary-only (no double INFO). Idle ticks are gated before
  rebalance() runs, so they emit nothing.
- OrderFillSync: optional unit_name; INFO per applied fill
  (cid / signed qty / price / fee / fee_asset-or-quote), prefixed unit= when
  known, threaded from service_factory for a single-unit slice.
- StrategySupervisor: INFO on unit start/stop, ERROR (logger.exception) when a
  unit's step raises, DEBUG on a no-new-bar tick.

Verified on today's real dccd bars via a scratch daemon (fresh empty books,
port 8099): both units' genesis rebalance summaries, skip lines with full
reasons, submit lines and their matching fills — one fill cross-checked to
the store (cid/qty/price exact) — and an idle tick adding only the heartbeat.
@ArthurBernard
ArthurBernard force-pushed the feat/daemon-unit-event-logs branch from 6ce711e to f2b26b0 Compare July 14, 2026 13:05
@ArthurBernard
ArthurBernard merged commit b317c0b into develop Jul 14, 2026
3 checks passed
@ArthurBernard
ArthurBernard deleted the feat/daemon-unit-event-logs branch July 14, 2026 13:07
This was referenced Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant