Skip to content

[implementation] live: O03 - configuration, runbook and one-hour real-provider proof (ADR-0075 slice 9.3, closes T02) #525

Closed

Description

@NeoNix-Lab

Parent

SCOPE.md Part C (DG-O), atom O03: configuration, runbook and real-provider proof (ADR-0075 slice 9.3, §9.3 of the order of work). Closes T02 (its one-hour ETHUSDT proof, part 6, is this atom's proof). Design gate #504, registration #507. Requires O02 (merged, PR #524 / issue #523), T03, T04 (merged). Branch from implement/fid; the pull request targets implement/fid, never main.

Authority

ADR-0075 (§1 and §5 as built in O02; item 9.3; "Not claimed": the provider's exchange_ts ordering and the bounds are measured, not proven, by this proof) and its Amendment 1 (accepted); ADR-0074 (per-instrument unit template, capacity gate §6, T02 part 6); ADR-0043 §1 and §4 (loop, signals); ADR-0042 §5; ADR-0044 (unchanged). AGENTS.md governance boundary: no governance file is touched (the closeout is a separate governance issue).

Start gate

O02 merged (PR #524); O01 merged (PR #510); governance #507 and #518 merged; implement/fid contains main. SCOPE.md Part C row O03 reads "after O02 is merged".

Problem

O02 put the continuous session in the code behind LiveIngestServerConfigV1.continuous_session (default None): the CLI (tools/live_ingest_server.py), the two unit templates (infra/systemd/quant-platform-live-ingest.service, quant-platform-live-ingest@.service) and their env examples cannot enable it or set slice_seconds, slice_max_trades and the buffer bound, and the runbook says "in the code, not enabled". Nothing has run against the real provider: the ordering of the provider's exchange_ts, the ping policy, the real slice sizes and the captured share against the Bybit archive are assumptions (ADR-0075 "Not claimed"), and T02 part 6 (the one-hour ETHUSDT proof) is still open.

Objective

Make the continuous session operable (configuration, CLI, unit templates, runbook) and produce, from a real-provider run of at least one hour for ETHUSDT, a reproducible evidence report that states what was captured against the Bybit archive of the same day, what is readable through the DataGateway, how many ordering violations occurred and what the health signals said. The report states results; it does not hide a shortfall.

Design (configuration; no semantic decision beyond ADR-0075 and the accepted O02)

  1. CLI (tools/live_ingest_server.py): --mode {cycles,continuous} (default cycles: the existing behaviour is unchanged); --slice-seconds, --slice-max-trades, --buffer-messages (defaults = LiveSessionConfig defaults: 300, 50 000, 20 000), valid only with --mode continuous (argparse error otherwise: no silently ignored flag). The CLI only builds LiveSessionConfig and passes it as LiveIngestServerConfigV1.continuous_session; it holds no ingest logic (C05). Invalid values (non-positive) are refused by the existing LiveSessionConfig validation, surfaced as a usage error. --max-cycles keeps its meaning (health snapshots; in continuous mode one per published slice) and is documented as such.
  2. Unit templates and env examples (BTC unit and the @ template): QP_LIVE_INGEST_MODE (default cycles in both examples), QP_LIVE_INGEST_SLICE_SECONDS, QP_LIVE_INGEST_SLICE_MAX_TRADES, QP_LIVE_INGEST_BUFFER_MESSAGES, rendered into ExecStart. Existing env files that do not set them keep working (the units must not fail on an old env file: use systemd defaults or the CLI defaults, and say which).
  3. Runbook (docs/engineering/LIVE_INGEST_SERVER_DEPLOYMENT.md): replace "in the code, not enabled" with the operating steps (how to enable per instance, the three bounds, what the operator sees: interruption/gap/degraded signals, how to read the counters, rollback to cycles), and the proof procedure (below). Deployment of a changed server stays a manual operator step; nothing here installs or starts anything.
  4. Proof tooling (read-only, no write to catalog or storage): a tool (e.g. tools/live_window_evidence.py, name at the implementer's discretion within the mutation boundary) that, given an instrument, a UTC window, the Bybit archive file(s) of the day(s) the window touches, the catalog/storage the run wrote to, and the captured server stdout (the signal ... lines), prints one JSON report and exits non-zero only on the stop conditions below:
    • archive trades in the window (by trade_id) vs trades read through the DataGateway (real read path, strict coverage over the window, VALID_ONLY): counts, the missing set (in archive, not read) and the extra set (read, not in archive), with the same equality of trade_id, millisecond timestamp, side, price and size that tools/compare_archive_day.py applies;
    • the recorded interruptions and gaps (from the signals and the explicit gap records) with their spans, and for every missing archive trade whether it falls inside such a span;
    • the number of exchange_ts ordering violations and of reconnects, the buffer high-water mark and capacity, the maximum slice lag, the number and size distribution of the published slices (partitions, rows), from the signals and the catalog;
    • the window, the unit/commit (code_ref) and the configuration that ran.
  5. The run (operator-executed, not part of CI; recorded in the PR as evidence): ETHUSDT, --mode continuous with the default bounds, at least one continuous hour against the real Bybit provider, on a disposable catalog and storage root (or a root chosen by the maintainer: this proof never touches the BTCUSDT dataset or its unit and enables nothing in production; the ADR-0074 §6 capacity gate stands). The archive of the day is available only after the day ends, so the report is generated after that (the PR can be updated with the evidence or the evidence can be attached by a follow-up commit/comment). The run is started and stopped (SIGTERM, a clean stop) by the maintainer; the agent does not start a real-provider run unless asked.

Mutation boundary

tools/live_ingest_server.py (flags and the construction of LiveSessionConfig only); application/live_ingest_server.py only if a config helper is needed (no behaviour change); infra/systemd/quant-platform-live-ingest.service, quant-platform-live-ingest@.service and their .env.example files; docs/engineering/LIVE_INGEST_SERVER_DEPLOYMENT.md; the evidence tool and its tests; the existing artifact/CLI tests (tests/test_live_ingest_server_cli_v1.py, tests/test_live_ingest_deployment_artifacts_v1.py, tests/test_live_ingest_template_artifacts_v1.py, tests/test_deployment_units_v1.py) extended; the new tests' CI wiring. Nothing else.

Forbidden: live_session.py, the assembler, the publication path, the checkpoint, the reconciliation, trade-v1, the ordering key, TradeKeyV1, dataset identities, ADRs, governance files, the cycle loop's behaviour and defaults, retention/cleanup code, the BTC unit's behaviour when its env file is unchanged, any deployment or production action.

Acceptance criteria

  1. --mode cycles (or no flag) produces exactly the config of today (continuous_session is None) — the existing CLI and unit tests pass unchanged; --mode continuous builds a LiveSessionConfig with the given bounds and defaults of 300 / 50 000 / 20 000.
  2. A slice/buffer flag without --mode continuous and any non-positive value are refused with a usage error (exit status 2) before any connection; no flag is silently ignored.
  3. Both unit templates and both env examples carry the mode and the three bounds, render them into ExecStart, and an env file that predates them still yields a valid command line (tested by the artifact tests); the @ template still refuses BTCUSDT, builds the checkpoint from the instance and does not read the instrument from the environment.
  4. The runbook describes enabling, the bounds, the signals and counters an operator sees, the rollback to cycles, and the proof procedure, and no longer says the session is not enabled; python tools/check_markdown_links.py passes.
  5. The evidence tool, on a fixture (a small archive file, a published window through the real catalog/gateway test path, a captured signal log), reports the counts, the missing and extra sets, the interruption/gap spans and the missing-inside-span classification; it fails (non-zero) when an archive trade in the window is neither read nor inside a recorded interruption/gap span, and when a trade is read that the provider archive does not contain with a different payload (a conflict); it never writes to the catalog or to storage.
  6. Mutation checks: each rule above has a test that fails when the rule is weakened (flag validity, default mode, bounds propagation, env rendering, the stop conditions and the in-span classification of the tool).
  7. The real-provider proof, recorded as evidence in the PR (or attached after the archive of the day is published): ≥ 1 h of ETHUSDT; the report with captured trades vs the archive of the same window, trades read through the DataGateway, ordering violations, reconnects/interruptions/gaps, buffer high-water, slice lag, slices published, and the signals' health summary. The numbers are reported as measured. Stop conditions (the issue is not closed as passed; report and wait for the maintainer): a missing archive trade outside any recorded interruption/gap span; a trade published that is not readable through the gateway; a conflicting payload against the archive; an exchange_ts ordering violation is not a failure of the proof (it is a measurement the ADR asks for and an interruption by design) but its count and the consequent interruptions must be explained in the report.
  8. Everything else is unchanged: the cycle loop, the BTC unit with an old env file, T02 parts 1 to 5, the ordering key, TradeKeyV1, identities.

Verification

python tools/run_tests.py; python tools/check_markdown_links.py; git diff --check; python tools/workflow.py preflight --base implement/fid; the PostgreSQL integration of the evidence tool on a disposable catalog if it reads through the real gateway (own CI job, as for O02); the operator's real run for criterion 7.

Out of scope

Changing the default mode of the CLI or of the BTC unit to continuous; deploying or restarting any unit; enabling any instrument in production (ADR-0074 §6); exposing ping_interval, pong_timeout, the reconnect backoff or recent_limit as configuration; consolidation of slices; the repair of damaged legacy days (DG-R); a second venue; the governance closeout (credit of T03, T02, O01 to O03 and the promotion PR), which are separate steps after this merge.

Risks, ambiguities and decisions to obtain before implementation

  • Default mode. This issue keeps cycles as the default in the CLI, the env examples and the units (the ADR's "the default" is decided here conservatively: nothing changes for a host that does not opt in). Making continuous the default is a separate maintainer decision after the proof's numbers are known. [Confirm or redirect before implementation.]
  • Where the run executes. The proof needs a host with outbound access to Bybit and a catalog it may write to (disposable, or an ETHUSDT-only root). The maintainer chooses the host and starts the run; if it is the production server, enabling ETHUSDT there is bounded to the proof (ADR-0074 §6) and its data stays out of any other claim.
  • Archive availability. The archive of the day appears after the day ends: the report is produced after that, so criterion 7 may close a day or two after the code merges (the PR/issue records the evidence when it exists).
  • Thin instrument. O02 waits for the first trade of a subscription before reconciling; on a quiet interval after a reconnect this delays the reconciliation (and a REST window behind the subscription becomes an explicit gap). The proof reports how often this happens; no behaviour change is proposed here.
  • The measurement may contradict an assumption (non-decreasing exchange_ts; the bounds). A contradiction is a finding to report, not something this issue fixes silently; it may require an ADR amendment decided by the maintainer.

Atomicity check

One responsibility (make the continuous session operable and prove it on the real provider); justified by SCOPE.md Part C O03; no implicit dependency (O02 merged, closeout comes after); no semantic decision beyond ADR-0075 slice 9.3 (the default mode is flagged for confirmation); observable criteria with explicit stop conditions; reviewable as one slice (configuration + read-only evidence tool + runbook).

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions