Eloverblik

Dokumentation · Kom i gang: installation og drift

The capture directory (phase-1.md §6.4)

The capture of the owner's history (B06b) writes it; the replay source (elo_sources.capture.ReplaySource, B04b) and make load-capture (B08b) read it. Reader and writer are one module, elo_sources.capture, and libs/sources/tests/test_capture_replay.py writes a directory and reads it back.

The directory is data/capture/<run>/, under the git-ignored data/: it holds the owner's metering point IDs and readings exactly as delivered (§12.2). It never holds a token: a token response has no body file, and requests.jsonl holds no header. Every file is written with mode 0600 and every directory made 0700.

FileContent
manifest.jsonformat (1), capture_id (a UUID given when the run is created), created_at, and mps: per metering point its capture-local number (1, 2, … in order of first sight) and its first_load_to (a local date, written when the planner tiles it, §6.1, N8; null until then); complete (the capture tool's verdict, B06bf: true only for a capture that is complete by elo_devtools.capture.verdict; false from the start of every run until its end) and accepted_refusals ({"number", "day"} for each day refused or without data twice inside delivered history that the lead accepted by name); api_base_url and account_fingerprint (B06bf2: the API's base URL and the hex SHA-256 of the refresh token the run was made with, recorded at its first write; a later start at another address or with another token is refused; a new token is a new run, B06bf3). accepted_refusals loses a day once it is stored (B06bv3-09); since B06bf4 it holds any day listed apart that the lead accepted (ACCEPT=), and accepted_list_differences the capture-local numbers on which the answers to the list (or the lists and a parent's details) disagreed and that the lead accepted (ACCEPT=<number>:list). The Month requests of requests.jsonl include the edge controls (B06bf4): one per calendar year over each span the tool takes as an access edge; the replay reads an answer without a value or with a refusal code as "nothing there". make load-capture reads complete before anything and refuses an incomplete capture unless INCOMPLETE=1 (B06bv2-04, docs/runner.md). No metering point ID: the manifest holds numbers, dates and the capture ID only (B06b). Written to a temporary file, synced and renamed at every change, the directory synced
metering-points.jsonPer capture-local number its metering_point_id: the one file that maps the numbers to the IDs (ReplaySource.mps reads it; without it the numbers could not be mapped to mp_id, §6.4 step 2). Written like the manifest, before it
requests.jsonlOne JSON line per request, in the order sent, appended and synced: seq (1, 2, …), endpoint (isalive, token, meteringpoints, getdetails, getcharges, gettimeseries), window ({"from", "to", "aggregation"} with local dates, to exclusive, or null), mps (capture-local numbers of the requested metering points, in request order), requested_at and completed_at (ISO 8601 with offset; completed_at null when no response came), status (HTTP status or null), error_code (the code of a request refused as a whole), retry_after_s, item_codes (the errorCode of each item in response order; null where an item had none), body (the body file, or null), sha256 (hex SHA-256 of the uncompressed body, or null), body_length (only for a body not kept because it is not JSON as a whole: its length in bytes; body is then null and sha256 that body's, B06bv5-03)
chunks.jsonlOne JSON line per change of a chunk row, appended and synced: the columns of ingest.chunk (§3.2) in the order of elo_sources.capture.CHUNK_FIELDS. chunk_id, parent_chunk_id and lineage_id are capture-local chunk IDs, mp a capture-local number, last_request_seq the seq of the request in requests.jsonl that stands for last_fetch_id. The last line of a chunk_id is that chunk's state; a resumed run continues from it
bodies/NNNNNN.json.gzThe body of request seq NNNNNN exactly as received, gzip-compressed (modification time 0). None for a token response
report.mdB06b's report (docs/capture.md): counts, dates, codes, states, durations, a hash; no figure and no ID. Not read by the replay
pending.jsonThe capture tool's write-ahead record (B06b), present only while a change is being made or after a run was killed: the sizes the two logs had before the change, its stage (rows, sent, applied), and the chunk rows the change appends; for a request its seq, endpoint, window, metering points and chunks. The next run repairs from it (docs/capture.md, "Resuming"). Not read by the replay; a complete capture has none
progress.jsonThe capture tool's own notes: search_from_seq (the first seq of the exhaustive search, so that the report counts its calls apart), complete, retries (B06bf2: per RETRY, its first seq and what it named: chunk IDs, [endpoint, number], [from, to, number] of Month controls) and withheld (the seq of each response whose body held a token and was not stored; its line in requests.jsonl is that of a request without a response). Not read by the replay

The checkpoint hash of §6.4 step 2 is ReplaySource.checkpoint_sha256(): SHA-256 over the bytes of chunks.jsonl followed by those of requests.jsonl.

ReplaySource answers each of the five calls of §5.1 with the latest captured response of the same endpoint (and, for time series, the same window and aggregation) whose request covered every requested metering point, restricted to the requested IDs, with the captured requested_at. The captured response is turned into items by elo_sources.items, the conversion of the live client: a captured 401, 429, 5xx or a request without a response gives RETRY_LATER, any other failed status PERMANENT, a body that cannot be read PARSE_ERROR for every requested ID; none of them raises. health() answers what the latest captured isalive answered (true only for a 200 with the body true). A request that was not captured raises CaptureError (for health(): no isalive in the capture), as does a body whose content differs from its recorded SHA-256. timeseries_responses() yields every captured time series response in the order of requested_at, failed and malformed ones included: the order of the replay's step 3.

Choices the specification left open (B04b report, "Deviations and open points"): gzip rather than zstd, so the owner can open a body with standard tools; the capture carries each metering point's ID, without which the capture-local numbers could not be mapped to mp_id (§6.4 step 2), since B06b in metering-points.json and not in the manifest; chunks.jsonl is a log of row versions rather than a snapshot, so a resumed run only appends. A request in flight when the capture was killed has a line with status and completed_at null and no body (written by the next run), and its chunks show the attempt; the replay treats it as a request without a response.

B08b. The replay (make load-capture, docs/runner.md) reads the captured list and getdetails responses in the order of requested_at (ReplaySource.masterdata_responses()), then timeseries_responses() with aggregation Actual only; the Month answers are the monthly control and are never replayed as readings. The generator's capture (elo_devtools.synth.capture.write_demo_capture) asks the Month controls of §6.4 step 4 with months=True: per metering point, one request per calendar year of each readable range.

Kilde: docs/capture-format.md i løsningens repository.