Dokumentation · Kom i gang: installation og drift
The capture of the owner's history (make capture)
elo_devtools.capture (B06b) is the tool of docs/architecture/phase-1.md §6.4: the one step of phase 1
that depends on what the Customer API still serves. On 1 January 2027 the API's window moves to
1 January 2022 and everything of 2021 leaves it for good, so **the lead runs it once, on the owner's machine,
with the owner's token, before 31 December 2026** (B06b's row: by 15 December). Loading the result into a
database is a replay (make load-capture, B08b) and can be repeated as often as needed.
The directory it writes is described field by field in docs/capture-format.md.
What it does
Each step is skipped when the run directory already records it.
| Step | What | Calls |
|---|---|---|
| 0 | The state directory (ELO_STATE_DIR, else data/state/, resolved as the worker's is: one resolver, B02bx-02) and data/capture/ are made (0700) where missing and checked (N9, §12.2): every component from the repository root down must be the user's own, no link, no group or other write bit, no ACL. An unsafe one ends the tool before any call, lock or token file (exit 3). Then the capture owns the egress (§5.2) or exits naming the owner (exit 4). It continues the worker's pacing history from the handoff record | none |
| 1 | The list; getdetails and getcharges for every metering point of the tree, ten to a request (the token call comes first, by the client). Each metering point needs a successful item in each; one without (no response, 5xx, 20011) is asked again in the run, one with an odd answer (another 4xx, an unreadable body) by the next run, one refused with a documented code by the second pass (3b), one refused with 400 never. Every successful answer to the list or to getdetails is a sighting (B06bx-02, -04): a point any sighting names is registered at once, wherever in the run it comes (a second pass, a resume, RETRY=), and gets steps 1 to 4 in the same run; a sighting that gives a point a time series obliges the capture to ask for it (a later D99 never takes that away); sightings that disagree on its type, resolution or relation are a named disagreement (4b) | 1 + 1 + 2 × ⌈n / 10⌉ |
| 2 | The planner of §6.1–§6.3 (elo_core.plan, the same as the worker's) tiles every metering point from 1 January of (year − 5) to today, in quarters (PT1H) or months (PT15M, unknown); requests them newest first, ten metering points of one window to a request; the edge search; the ladder of §6.2 on 503 and timeouts. isalive before the first time series request and every 5 minutes | 24 per hourly group, 71 per quarter-hourly group, ≤ 8 / 6 per access edge |
| 3 | The exhaustive search (§6.3 level 3) over every chunk left outside, oldest first, down to single days. A chunk parked after transient failures is waited for (its tries come after 1 hour, 6 hours, 1 day, then daily); no_data is a complete state and is not waited for | ≤ 2 per refused day per group |
| 3b | The second pass (B06bf, B06bf2, B06bf3): one rule, in one place (run.delivered_nothing): an answer that delivered nothing is final only after two answers at least 10 minutes apart. When nothing else is pending, every window that is not done with a stored day, whatever code or state closed it — a day refused alone (not_available), 30015 (no_data), outside, an invalid-ID code (20003, 20004, 20008: invalid), empty, a successful item without a day, and any code that comes next — is asked once more, at least 10 minutes after its answer (the tool waits for that). Only a 200 whose item has a code counts as an answer: a 429, a 5xx, no response or 20011 does not, and two answers count as apart only by their recorded instants, later minus earlier (a wall clock stepped back never makes them so). A real access edge answers the same again; a fault has passed and the days are stored. After the second answer (B06bf4, ruling 1) only a refusal of a day or no data (not_available, no_data, empty) may be final by position, at the start or the end of a series' stored history (an access edge, checked by its edge control, step 4); at the newest end of a metering point listed with a relation only its newest 14 days (DAILY_WINDOW_DAYS, the daily run's window: "not yet published", no bar); everything else is listed apart and accepted by name or asked again: a day inside delivered history, any other code (an invalid-ID code, a success without a day, a code that comes next) wherever it lies, every day of a series without a stored day, the older newest-end days; outside twice means the API's window has moved (30017) and is listed for the lead. A window final by two answers is never asked again by §6.2's schedule (a no_data retry 7 or 30 days on), only by RETRY. After step 4 the same holds for an item of step 1 or a Month control refused with a documented code or answered without a value: asked once more 10 minutes later, refused for good after the second | 1 per window not done per group, + ≤ 10 min (twice, if step 1 or a control was refused) |
| 3c | Days missing inside a delivered window (B06bx-03, ruling 3 with the lead's amendment): every window done with a stored day is compared with its whole local-date range. The days it left out are asked again as their contiguous spans, one request per span (the points with the same span together; step 3b: n spans of days missing inside delivered windows are asked), never one per day; what a span delivers is stored, and what it still lacks is asked as its own spans. A span answered twice, at least 10 minutes apart, successfully without its days or with 30015 (no data), is a hole: final, under the report's heading "Holes", only when its month's validated Month control confirms it: the union of meeting Month periods that holds the day (one period per access period; as a rule the whole month), compared over exactly the union's range with the sum of the delivered days, by the replay's tolerance (elo_sources.month.MONTH_ROUNDING; the report says to which step, e.g. "to the nearest 0.001 kWh", B06bf6 rulings 4 and 5), from the control's latest answer at or after its control_from; otherwise (the union differs, no union holds the day, the answer is missing, refused or odd, or the whole month has no delivered day) its days are listed apart. Each hole says on which run date it was confirmed. A span answered with another code (a refusal, an invalid-ID code), refused with 400 or odd in every try is listed apart. A day counts as delivered only with the number of points its bounds hold (23, 24 or 25 hours; 92, 96 or 100 quarters; B06bv5-02, ruling 6): the local day's own bounds at the series' resolution, never the answer's timeInterval, counted as distinct positions inside them (B06bx2-01, B06bf7 ruling 2: a period that covers part of a day leaves it short); a stored day with fewer is asked again with its span; an answer with more points is stored (the merge's own rule decides between the two); answered twice without more it is a short day, under its own heading, final when its month's control equals the sum of the month's delivered energy (the holes' check), else listed apart; RETRY=<number>:<day> asks it again. Within the newest 14 days of a metering point listed with a relation (B06bf6, ruling 2), a day after its last stored day is not asked ("not yet published", no bar), and a day before it is asked as its span like any other; answered twice without data (both answers a success without the day or 30015; any other code is listed apart, B06bv6a-03) it is listed under "Not yet published" as such, no bar, no Month check. The daily run, make status and make refetch cover both. The limit: the control can contradict a hole only by energy, so a day on which the point used nothing cannot be told from a day the API does not hold The 10 minutes between a span's answers count from its latest answer of any kind, a partial delivery too, and only two answers after its last delivery settle it (B06bv7a-07). One span is asked at most SPAN_ASKS_PER_RUN (4) times for a point in one run; beyond it the run says so, and the next run asks it again (the bound is per run) or RETRY=<number>:<day> now; it is not listed apart, so no ACCEPT= (B06bv7a-06). | 1 per span, twice; 30 scattered one-day holes in a year: 60 requests, each paced like any other (about 2 minutes at 1 s latency, plus the 10-minute wait shared with the second pass) |
| 4 | The Month controls: per metering point, one request per calendar year of each unbroken run of windows done with a stored day (a done window that delivered nothing is not readable history: no control is asked over it, B06bv3a-02); metering points with the same window together. Asked when no chunk is pending or parked. A control window is answered for a metering point only by values that can be placed, of a month its window touches, with no failed or unreadable item beside them and no two of one business type whose periods overlap (elo_sources.month.read_month_answer, the one order the replay shares, B06bf6 ruling 4: an item that did not parse, whatever its code, is odd and never agrees); periods that meet (one per access period) are one union; only the metering points still without such an answer are asked again. Edge controls (B06bf4, ruling 2): over every span final at an access edge, one Month request per calendar year, the same path, pace, echo scan and storage. No value (validated: no quantity at all), or a refusal (an access code or 30015), agrees with the edge; an answer with a value contradicts it: the span is listed apart (RETRY= or ACCEPT=); no answer (a 503, a 429, a timeout, 20011, an unknown or invalid-ID code, an odd answer by the same order: a value that cannot be placed, a failed or unreadable item beside a value, two values whose periods overlap, an item that did not parse; never an agreement) is asked again and keeps the capture INCOMPLETE; out of tries (eight runs) or refused with 400, its span is listed apart with the control's last code ("its edge's Month control got no answer it could take, the last code …"), accepted by name or asked again, never COMPLETE by tries running out | ≤ 6 per run of readable days per group, + 1 per year of each edge span |
| 4b | The list once more (B06bf3, ruling 2), at least 10 minutes after its first answer (the list of metering points is asked once more: waiting until …). A metering point seen in either answer is captured: one the second list adds gets steps 1 to 4 in the same run (the list once more named n metering points not seen before …). A child the stored getdetails of a parent names and no list holds is captured too (B06bf4, ruling 3). A metering point, or a parent-child pair, that is in one answer and not in another, on which the lists and the parent's details disagree, or on whose type, resolution or relation the answers to the list and to getdetails disagree (B06bx-04), is printed (the list: …), reported in the report's first lines and keeps the capture INCOMPLETE until it is accepted by name: make capture ACCEPT=<number>:list (one point by its number, never all; recorded in manifest.json accepted_list_differences). No third list is asked | 1 |
| 5 | report.md: first the API it was captured from; complete or not and, if not, first what is missing and what the next run asks; the disagreements of the answers to the list and the details; the days listed apart, at the top; the holes under their own heading; the details and charges; the access edges; every window that keeps it incomplete, per series the first readable day and the code for the day before, consumerStartDate if sent, calls by kind (those of the exhaustive search apart) and the days it found, latency per call (median, 95th percentile, maximum), whether Retry-After was seen, every window not done, the Month controls. No figure, no ID, no address, no name: metering points by their capture-local number | none |
Complete is decided in one place, elo_devtools.capture.verdict (B06bf, the lead's ruling 1), whose table
of cases is the definition. The capture is COMPLETE, exits 0 and writes manifest.json with "complete": true
only if:
- the run reached its end (an interrupted or stopped run never is, nor one whose response held a token);
- the list was answered twice, at least 10 minutes apart; every point any successful answer to the list or to
getdetailsnames is registered (a stored answer naming a point that is not is a bar of its own); and the answers do not disagree on a point (its membership, its parent, its type, its resolution or its relation), or each disagreement is accepted by name (ACCEPT=<number>:list); getdetailsandgetchargeshave a successful item for every metering point;- every window of every series is
donewith its days, and every day adonewindow left out (or delivered with fewer points than its bounds hold) is stored whole, a hole or a short day its validatedMonthcontrol confirms, one of the newest days of a point listed with a relation, or accepted by name; or the window is final: a refusal of a day or no data (not_available,no_data,empty:EDGE_STATES, nothing else) on two answers at least 10 minutes apart at the start or the end of the series' stored history, whose edge control agreed (no value, or a refusal), or, at the newest end of a point listed with a relation, within its newest 14 days (not yet published). Everything else that delivered nothing on two answers is listed apart until accepted by name (ACCEPT=<number>:<day>) or asked again (RETRY=): a day inside delivered history; any other code wherever it lies (an invalid-ID code such as20008answered twice ten minutes apart at the oldest or newest end is listed apart, never final by its position; a success without a day; a code that comes next); every day of a series without a stored day; the older newest-end days of a current point; an edge whose control holds a value, or got no answer it could take; a hole whose month's control differs or cannot confirm it; - the newest days (B06bf6, ruling 2): within the newest 14 days (
DAILY_WINDOW_DAYS) of a point listed with a relation, a day after its last stored day is "not yet published": listed, no bar, and the row says when it was last asked; a day before its last stored day is asked as its span like any other (twice, 10 minutes apart) and, if it comes without data both times, listed under "Not yet published" as asked twice without data, no bar and noMonthcheck (the running month has no whole control). The daily run,make statusandmake refetchcover both; - the newest span (B06bv6-01, the lead's P1): before the control of the year that holds the tiling's date is
asked for a point (the first time, afresh: a later run,
RETRY=all, or its second answer after one without a value, B06bv7a-03), its newest days, stored or not, are asked as one span, once per run and point; a span that got no answer it could take (none in its tries, an odd one, a 400, a refusal) holds that control back in that run, which ends INCOMPLETE and says so, and the next run asks both (B06bv7a-04). The span: from the earlier of the first day of the month that holds its newest stored day and the tiling's date lessDAILY_WINDOW_DAYS, to the tiling's date. What it delivers is stored: of two answers of a day the one with more points stays, the later among as many (in the capture's own sums and in the database: a correction wins, a later short answer never shortens a stored day, B06bv7-01); what it lacks stays "not yet published". Late days and corrections inside the span are then of the same hour as the control; the report says under "The newest span" which days it added and which it changed. Controls of earlier years get no such span. The limit: a correction of a stored day older than the span, published after the day was stored, makesmake load-capturefail for its month once its year's control is asked again;RETRYcannot repair it, and the remedy is a new capture (NEW=1) while the API still serves the year: the lead decides; - every normal
Monthcontrol window is answered with a value for each of its metering points (step 4: values placeable, of a month the window touches, nothing failed or unreadable beside them, no overlap), and every edge control was answered (no value or a refusal agrees, a value contradicts); - the details name no more than 50 metering points that no list holds (
DETAILS_ONLY_MAX, B06bv5-08); one more is not registered, nothing is asked for it, and the report names the bound and the parent. Items for IDs a request did not name are listed under their own heading and counted, no bar.
Anything else is INCOMPLETE (exit 1). A type without time series (D99, in every sighting) needs only its
details and charges. Nothing is final on one answer (B06bf2, ruling 2; B06bf3, ruling 1), but a 400, which is
never sent again unchanged (§5.2).
Resuming, and what is never asked twice
A run can be stopped at any instant: Ctrl-C, kill, a closed terminal, a sleeping or crashed machine. The next
make capture continues it from its files. A request whose response was recorded is never sent again as
such; what the next run asks is decided from the recorded answers (B06bf, ruling 5):
| Recorded answer | The next run |
|---|---|
A successful item for a metering point (list, details, charges; a Month control with a value) | Nothing more for it |
| HTTP 400 | Never sent again unchanged (§5.2), not even by RETRY; listed, the lead decides |
An item with a documented code (30018, 20010, 30015, 20008 …, any code but a delivery), a Month item without a value | Asked once more by the second pass, at least 10 minutes later (B06bf2, B06bf3); after the second such answer refused for good or final: listed, and asked again only by RETRY |
No response, 5xx, 429, 20011 | Asked again (up to 8 times in each run) |
| Another 4xx (403, 404), a body or item that cannot be read | Asked again by the next run, once per run, at most 8 times in all; then listed |
A time series chunk unresolved by such an answer (B06bf, ruling 2) | pending again at the start of the next run, while it has attempts left before §6.2 would park it (8); not after a 400; a chunk parked out of tries stays unresolved and is listed |
| A window that delivered nothing on two answers 10 minutes apart (any code) | Final or listed as above; asked again only by RETRY, never by §6.2's schedule (B06bv3-04) |
RETRY (B06bf2, ruling 2): what the tool took as refused for good or final can be asked once more by name,
without a new run: make capture RETRY=all (everything not done: every window whose answer delivered nothing,
whatever code closed it, every chunk unresolved, every hole, confirmed or listed apart, and every span of missing days with a day listed apart (B06bv5-01, B06bv5a-07), every item of step 1
and every Month control without a successful answer, and the newest span of every point, its months'
controls afresh (B06bv6-01); on a complete capture with an access edge that is every edge day again, twice, as costly as
the second pass was), or
RETRY=3:2024-05-17,3:2021-01-01..2021-03-31 (time series days, also a day missing inside a done window: its
span is asked again; a day after the last stored day: the point's newest span, its months' controls afresh), RETRY=3:getdetails, RETRY=3:getcharges. A retried window or span makes every edge control
over it be asked afresh, an agreeing one too (B06bx-05), and every normal Month control of the months it
touches, a valued one too (B06bv5-01): the new answers get a new control, never yesterday's.
A named thing that is neither not done nor refused for good, or was refused with 400, is refused before any
call (exit 2). The retry is recorded in progress.json (retries); the answers before it no longer count for
what it names, which then gets the whole treatment again (an answer, and the second pass 10 minutes later).
The one request that was in flight when the run ended has no recorded response; it is recorded as such
(status null) and its chunks follow the ladder of §6.2, exactly as the worker treats a request that left no
response: it is sent again as a retry. Tokens: the access token is kept in the state directory's capture-access-token (mode 0600, bound to the
refresh token's fingerprint) and reused while it has more than 30 minutes left; the one read there at the start is
guarded against an echo until it expires, usable or not (B06bv5a-05).
How: requests.jsonl and chunks.jsonl are append-only, and each change of them goes through a write-ahead
record (pending.json, see docs/capture-format.md): written before the change, removed after it. Opening a run
removes a line cut off at the end of a log, re-applies a change the record describes, removes a body file whose
line never came, and finishes the request that was in flight. Every write is synced to the medium
(F_FULLFSYNC on macOS, where fsync alone does not reach it). Should a disk still lose whole lines of
requests.jsonl that it had reported written (B06bv2-08), opening the run sets the chunks back to before the
first lost request, says so (requests.jsonl had lost request n … this run asks them again), and asks them
again. Ctrl-C, SIGTERM and SIGHUP release the egress (with
the handoff record) before the tool exits; after SIGKILL or a crash the lock stays, and the next capture takes it
over when no process with the recorded PID runs on this host (§5.2).
A run belongs to one API and one account
At its first write a run records in manifest.json the API's base URL (api_base_url) and the fingerprint of
the account (account_fingerprint: the SHA-256 of the refresh token, the hash ingest.source_account holds;
never the token). Every later start compares both and refuses (exit 2, before any call) a run made at
another address or with another refresh token, naming the recorded address, never a token or a fingerprint:
[capture] refused, no call was made: run 2026-11-20-101500 was made at http://127.0.0.1:8099/customerapi/api/; this command calls https://api.eloverblik.dk/customerapi/api/. A run belongs to one API and one account: make capture NEW=1 starts a new run beside it (nothing is deleted)
So a rehearsal can never satisfy the real run (B06bv2-01): after a rehearsal, the real run starts with
make capture NEW=1, and its fourth line (after the API, the token's source and the state directory) must say
starting run. NEW=1 starts a new directory beside the
others and never deletes or reuses one (two in the same second: the second gets -2). A run made before these
fields existed is refused the same way.
Without RUN=, make capture continues the run made last (by its manifest's created_at, not its name)
at the address it calls; runs of other addresses are passed over and named (runs made at another address passed over: …). So a rehearsal run started after the real one does not stand in its way; RUN=<name> always
names the run to continue.
A new refresh token means a new run (B06bf3, ruling 3): a capture takes hours and a refresh token lasts a
year, so after exit 5 (the token revoked or replaced at the portal) the new token goes into .env and the run
starts again with make capture NEW=1, which is safe. There is no way to continue a run with another token.
The worker, make up, make down
The capture and the worker share one egress (§5.2): one of them calls the API at a time.
- The stack is up (the worker owns the egress):
make captureexits at once, with no call, naming the worker (exit 4).make downstops the worker gracefully: it writes its pacing history to the handoff record and releases the egress; the capture then starts from it, and its first call waits for that pace:the first call is not before HH:MM:SS(about a minute after the worker's release; nothing else is printed meanwhile). - The worker was not stopped gracefully (
docker kill, the VM stopped under it, a power loss): its lock stays andmake downalone does not release it (exit 4 again).make up, wait until the stack is healthy, thenmake down: the new worker takes the dead one's lock over and releases it. The message of exit 4 says both. - A capture's lock whose PID lives on as another program (a capture that crashed, the number given out again
after a restart): exit 4 names the PID; when no capture runs and
ps -p <pid>shows another program, check that no capture and no worker runs, then removeegress/lockin the state directory the capture's third line names (data/state/egress/lockunlessELO_STATE_DIRis set). - A capture is running and
make upis run: the stack starts; the worker cannot acquire the egress, tries again once a minute, makes no Eloverblik call and runs its other jobs;make status(B09) is to name the capture as the owner. When the capture ends (or is interrupted) it releases, and the worker takes over at its next try, continuing the capture's pacing history.make upnever touchesdata/capture/and the capture tool never touches a container. Nothing needs the database: the capture runs with or without the stack. make downwhile a capture runs: stops the stack; the capture is not affected.make capture-purgerefuses while a capture owns the egress, also one that crashed.
Runbook for the lead (the owner's token)
Before. B02b is merged (it is) and Codex has confirmed it (not before 21 November). The owner's refresh token
is in .env as ELOVERBLIK_REFRESH_TOKEN (the tool reads that key alone; the environment variable of the same
name wins, and the command's second line says which it used: [capture] refresh token from the environment or
… from /…/.env). In a fresh terminal env | grep -i -e proxy -e SSL_CERT -e ELOVERBLIK -e MAKEFLAGS -e ELO_ | grep -v -e '^PWD=' -e '^OLDPWD='
prints nothing (the last part because the repository's own path, in PWD, holds "eloverblik"; the
capture's client takes no proxy and no certificate file from the environment anyway, B06bv3-10; the check is for
the token; MAKEFLAGS in the environment would hand make options as if typed, B06bv4-05; ELO_STATE_DIR set in one
terminal and not in another gives the capture and the worker two egress locks, B06bv5-06: the capture's third
line and make up's first name the state directory each uses). The stack is down: make down. Disk: the demo organisation's full capture (22 series, 8 981 calls)
took 80 MB; the owner's four series with a whole readable window take a few MB of bodies, more with a long
exhaustive search (each refusal is a small body and a few hundred bytes of log).
Rehearse first (B06bv-05, B06bv2-05). The whole runbook runs with the real command against the rehearsal server, from the repository alone: the demo organisation served as the Customer API on this machine. In one terminal:
make capture-rehearsal-server
It prints the address, http://127.0.0.1:8099/customerapi/api/, the rehearsal's refresh token (a JWT of
tokenType CaptureRehearsal, accepted there only) and the line to run in a second terminal:
ELOVERBLIK_REFRESH_TOKEN=<the printed token> make capture CAPTURE_API_URL=http://127.0.0.1:8099/customerapi/api/
CASES= chooses what it serves (;-separated): L1 (the default: the town hall's tree, four series, the whole
window readable), AT-01 (an access edge on 17 May 2023: the second pass and "Access edges"), AT-11 (two access
periods: "Refused or without data inside delivered history" and the ACCEPT= line), any AT-xx or a root's
name; PORT= another port. Ctrl-C stops it. Each set of cases has its own token, so a run of one set is never
continued against another (the section above). It answers at the wall clock, paced as the API is (1 s apart):
measured (B06bv3), L1 about 10 minutes (the list is asked again 10 minutes after its first answer, and the rest is done by then; since B06bf6 about 13 minutes: the spans of its missing day and short days are asked twice, 10 minutes apart), AT-01 54 min
(2 625 calls: the search 29 min, the 10 minutes, the second pass 14 min 30 s), AT-11 1 h 44 min (5 638
calls); the six steps one after the other about 3 hours, nearly all of it steps 4 and 5 running by themselves. A
port in use is said in a line (PORT=).
The rehearsal, each step printing what the real run will print (the address in the first line aside):
make capture-rehearsal-server(L1); themake captureline it prints. First line[capture] API http://127.0.0.1:8099/customerapi/api/ (NOT the real API: a rehearsal), then the token's source and the state directory,starting run …, the steps,step 5: report written to …: COMPLETE; exit 0. The report's third line:Captured from http://127.0.0.1:8099/customerapi/api/ (NOT the real API: a rehearsal).2. The same line withNEW=1, and Ctrl-C after a few calls:interrupted: the run is kept; make capture resumes it, exit 6. The line again, withoutNEW=1:resuming run …, then COMPLETE. 3. The same line once more:resuming run …,step 1: 4 metering points (numbers 1-4) (the recorded list; no call), no call, COMPLETE. **This is what the real run must not print.** 4. The server stopped and started withCASES=AT-01(another token: copy the new line), withNEW=1: the second pass (second pass: n windows not done are asked once more,second pass: waiting until …), and the report's "Access edges"; COMPLETE. 5.CASES=AT-11, withNEW=1: INCOMPLETE, exit 1; the report's first section **Refused or without data inside delivered history** and itsmake capture ACCEPT=…line. Typed as printed (on the samemake captureline): exit 0, COMPLETE. 6. WithoutCAPTURE_API_URLand with the rehearsal's token still in the environment: the first line names the real API, the secondrefresh token from the environment, and the command refuses:the refresh token is a rehearsal's … and this command calls the real API, exit 2, no call (B06bv3-05). Close that terminal (the rehearsal's token leaves with it). In a new terminal, with the stand-in token of the rehearsal nowhere,make capture(noNEW=1) at the real API passes the rehearsal runs over (runs made at another address passed over: …) and, there being no run at the real API, starts one: so typeNEW=1for the real run anyway.
With another address the command refuses, before anything: an address that is not of this machine (http or https
to a loopback address or localhost), whatever is given with it; and a refresh token that may be the owner's —
one read from .env, or one in the environment that is not positively a rehearsal's (the rehearsal server's, or
a text beginning rehearsal-) — unless CAPTURE_REAL_TOKEN=1 is given too; and at the real API a token that is
positively a rehearsal's. The yes/no variables (NEW, NOWAIT, CAPTURE_REAL_TOKEN) are yes only for 1
(the value compared whole: "0 1" is refused); 0, false and nothing are no; any other value is refused
without being shown; and they, CAPTURE_API_URL, RUN, ACCEPT and RETRY count only on the make command
line, never from the shell's environment. make does not echo the command it runs. The default is the real API;
leave CAPTURE_API_URL unset for the run itself.
Run. From the repository root, after a rehearsal with NEW=1 (the section "A run belongs to one API and
one account"):
make capture NEW=1
It prints a line per stage, each with the local time, and never an ID, a reading or a token:
[capture] API https://api.eloverblik.dk/customerapi/api/ (the real API)
[capture] refresh token from /…/.env
[capture] state directory /…/data/state (the default: ELO_STATE_DIR unset)
[capture 2026-12-01 09:00:00] starting run 2026-12-01-090000 (capture ID 3f…)
[capture 2026-12-01 09:00:00] the first call is not before 09:01:00 (the pace the other mode left, §5.2)
[capture 2026-12-01 09:01:03] step 1: 4 metering points (numbers 1-4)
[capture 2026-12-01 09:01:09] step 2: 143 chunks planned for 4 metering points
[capture 2026-12-01 09:06:10] 150 calls in this run; chunks: done 90, outside 37, pending 16, split 8
[capture 2026-12-01 09:21:41] step 3: the exhaustive search begins over 3 chunks
[capture 2026-12-01 13:05:02] second pass: 866 windows not done are asked once more (not_available 866)
[capture 2026-12-01 13:05:02] second pass: waiting until 13:15:02
[capture 2026-12-01 14:02:17] step 4: 6 Month control requests
[capture 2026-12-01 14:02:55] step 5: report written to …/data/capture/2026-12-01-090000/report.md: COMPLETE
(the line the first call is not before when the pace holds the first call back more than 5 s, as after the
worker's handoff: the deadlines that bind it, B06bv4-07; the list is asked once more at least 10 minutes after
the first, which on a run this long passes unnoticed; on a short one it prints the list of metering points is asked once more: waiting until …; and, when chunks are parked after repeated 503s, n chunks parked after failures; waiting until …).
What make prints as the exit status. The statuses below are the tool's. Through make capture the
tool's status is in make's last line, make: *** [capture] Error 6, and the shell's $? is then 2 for every
status but 0 (make's own). Read the number after Error; a wrapper must not test $? for 1. $? 2 is also
the tool's own status for a refused option: the message says which. The same holds for make load-capture
(make: *** [load-capture] Error 3 and so on). This mapping is that of a recipe that ends normally. **A Ctrl-C
in the terminal** goes to make too: the capture stops safely (interrupted: the run is kept; make capture resumes it, make: *** [capture] Error 6), but make itself then ends by SIGINT, and the shell's $? is 130,
not 2 (B06bx-08). A wrapper treats an interruption apart, and reads the saved manifest.json and report.md
before resuming; make capture continues the run.
Variables:
RUN=<name> continues a named run (one that does not exist is refused; with NEW=1 it names a new one),
NEW=1 starts a new one, NOWAIT=1 ends instead of waiting for parked chunks (the run is then incomplete and
make capture continues it later; the second pass's wait of at most 10 minutes is always waited),
ACCEPT=<number>:<day>,… accepts days listed apart (below), ACCEPT=<number>:list a disagreement of the
answers to the list on one metering point (B06bf4, ruling 3), RETRY=… asks
again what was refused for good (above), CAPTURE_API_URL= and CAPTURE_REAL_TOKEN=1 are for the rehearsal
only. To continue the real run after any later rehearsal: RUN=<its name> (or nothing: the latest run at this
address), never NEW=1.
How long. One call at a time, each spaced 1 s from the completion of the one before (§5.2), so a run takes calls × (latency + 1 s). Nobody has measured the latency (§6.6); the report measures it. For the owner's tree (three hourly series and one quarter-hourly, one group each):
| Case | Calls | at 1 s latency | at 5 s | at 30 s |
|---|---|---|---|---|
| Whole window readable | ≈ 106 (1 token, 1 list, 2, 24 + 71 time series, 6 controls, isalive every 5 min) | 4 min | 11 min | 55 min |
| An access edge on 17 May 2023 (866 older days refused) | ≈ 106 + 2 × 8 (edge search) + ≤ 2 × 866 × 2 (exhaustive search, two groups) + 866 × 2 (second pass, two groups) ≈ 5 318, + 10 min | 3 h | 9 h | 46 h |
For many trees: metering points with the same windows share a request, ten at a time, so the time series calls
are about 24 × ⌈hourly series / 10⌉ + 71 × ⌈quarter-hourly series / 10⌉, plus 2 × ⌈n / 10⌉ for details and
charges, plus up to two per refused day per group of metering points with the same chunks. The demo
organisation's 22 series (18 trees, ten access cases) took 212 calls before the exhaustive search and 8 769
during it. A 429 or a 503 adds its cooldown (Retry-After, at least 60 s; 15 minutes after five 503 in a row).
Resume. Run make capture again (without NEW=1); it continues the latest run made at this address (see "A
run belongs to one API and one account"). Interrupt it whenever needed (Ctrl-C; a second Ctrl-C while it stops
is ignored).
Complete or not. The exit status is 0 for a complete capture and 1 for an incomplete one; the report's first
statement is **The capture is COMPLETE.** or INCOMPLETE, and manifest.json and progress.json hold
"complete": true or false (false from the start of every run until its verdict). An INCOMPLETE report
says, in this order:
The answers to the list disagree, when they do (B06bf4, ruling 3): each point by number. Compare with the owner's count; accept each by name,
make capture ACCEPT=<number>:list. 2. Listed apart, no access edge: n days, when there are any (B06bf4, ruling 1): days that delivered nothing on two answers at least 10 minutes apart and are no access edge, each range with its reason: inside delivered history; a code that is no refusal of the day or no data (an invalid-ID code, a success without a day …); every day of a series without a stored day; the newest end of a metering point listed with a relation, older than its newest 14 days; an edge whoseMonthcontrol holds a value or got no answer it could take; a day missing inside a delivered window whose span was answered with a code, a hole or a short day (fewer points than its bounds hold) whose month'sMonthcontrol differs from (or cannot confirm) the sum of its delivered days. No run treats them as final. Look into each (the owner's answer on the access history, §14); then ask them again (RETRY=, the line the report prints) or accept them by name, with the line the report prints:make capture ACCEPT=3:2024-05-17,8:2021-05-21..2026-02-28(
A..Bnames every day from A to B inclusive). Only days the report lists are taken; anything else is refused (exit 2) before any call. The accepted days are recorded inmanifest.json(accepted_refusals); that run makes no call for them and, if nothing else is missing, is COMPLETE. 3. What is missing, one line per metering point and kind (chunks pending, parked, outside or unresolved, days refused once, spans of missing days not yet answered twice, details, charges,Monthcontrols, points a stored answer names that are not registered, details that name more points thanDETAILS_ONLY_MAX, an interrupted run). 4. What the next run asks: runmake captureagain (later, if the API was unavailable). Below it, what no run asks again by itself (a 400, a chunk out of attempts, an item or a control refused twice, a windowoutsidetwice because the API's window has moved): the lead decides, andmake capture RETRY=all(or by name) asks it once more, never a 400.
If a response ever holds the refresh token or a data token this process has used while it can still be valid (an
echo of the Authorization header, also of a token replaced by a renewal), whatever its status (a 401 included)
and on whatever call (a data call, isalive), nothing of its body is stored. The guard reads every body three
ways (B06bx-01; B06bx2-02, B06bf7 ruling 1): its bytes; every decoded JSON string, key or value, at any depth,
every pair of every object kept (a duplicate key's shadowed value too); and a lexical net that does not
depend on the structure: the body's text, UTF-8 or the UTF-16/-32 JSON allows, with every \u escape (either
case, surrogate pairs) and \/ replaced by what it stands for. A body that does not decode is also read
literal by literal. Any one of them ends the run.
A body of a data call or of isalive that does not decode as JSON as a whole is never stored (B06bv5-03,
ruling 7): requests.jsonl keeps its status, its length and its SHA-256 (body null, body_length), and its
chunk or item gets the outcome of an answer that cannot be read; a body nested too deep to read is such a body,
never a crash (exit 7). Such an answer, a 200 too, is never counted as an answer (its window is not done by it),
so nothing the capture delivered is in it; make load-capture prints how many 200 answers the run holds so
(B06bv7a-24). The data token read from the cache at the start is guarded until it expires, usable or
not. The limit: a token cut in pieces (two strings, or bytes between) is not found, nor one escaped in a body that is
neither JSON nor a text the net reads (gzip bytes under no Content-Encoding, say: such a body is not stored). Then the line in requests.jsonl is
that of a request without a response, the fact (the seq, never the value) is in progress.json (withheld) and at the top of the report, and the run ends at once with exit 8:
no further call of any kind, not the renewal a 401 would bring (B06bv3a-01). (A token call's own body is never
stored.) Check the address in the first line; the next run asks that request again.
A complete capture has no chunk outside and no window that delivered nothing on one answer only. Re-running a
complete capture makes no call and writes the report again: also days, weeks or a New Year later, since what is
final by two answers is not asked again by the schedule (B06bv3-04). A day accepted by name that a later RETRY
stored leaves accepted_refusals (B06bv3-09).
| Exit | Meaning | What to do |
|---|---|---|
| 0 | Complete | Keep it (below) |
| 1 | Incomplete: anything of the list above; also a run stopped because the API was unavailable for long | Read the report's first sections; accept refused days by name or make capture again, later |
| 2 | No refresh token in the environment or .env; an ACCEPT= or RETRY= that names what the report does not list, or is malformed (nothing is written: a complete capture stays complete); a RUN= that names no run (or exists, with NEW=1) or is not a plain name; the named run was made at another address, or the run was made with another refresh token; another address that is not of this machine, or with a token that may be the owner's; a rehearsal's token at the real API; a yes/no variable with another value, or a variable from the shell's environment (by make) | Add ELOVERBLIK_REFRESH_TOKEN; correct the option; RUN=<name> for another run, NEW=1 for a new one (also for a new token) |
| 3 | An unsafe state or capture directory or token file; nothing was called | Repair what the message names (chmod 700, remove the link) |
| 4 | The other mode owns the egress; or a lock without an owner record (a start killed between making the lock and writing its owner) | The worker: make down; if that does not help (a worker killed), make up, wait until healthy, make down. Another capture: wait for it; if none runs and ps -p <pid> shows another program, check that neither the worker nor a capture runs, then remove egress/lock in the state directory the capture names in its third line (data/state/egress/lock unless ELO_STATE_DIR is set). The lock without an owner: the same check, then remove it |
| 5 | The refresh token was refused (the message says where it came from: the environment or .env) | A new token from the portal into .env (and nothing in the environment); make capture NEW=1: a new token is a new run |
| 6 | Interrupted (never complete) | make capture continues |
| 7 | The run directory could not be continued safely (an unreadable pending.json, a log that does not number its requests 1 to n), or an unexpected error (reported by its type and code location only) | Keep the directory as it is and report it; make capture NEW=1 starts a new run beside it |
| 8 | A response held a token: nothing of its body was stored | Check the address in the first line; make capture asks that request again |
Check. The report's first readable day per series, its access edges (with their codes), its holes and short
days (with the step of each comparison), the days "not yet published", the items for IDs no request named and any line "consumerStartDate before the first readable day" against the owner's own answer (§14):
a check, not a condition (what is listed apart is a condition: step 2 above). The calls, the latency and whether Retry-After was seen go to the B06b record without figures.
Keep. The whole run directory data/capture/<run>/ is the only copy of history that leaves the API's window:
manifest.json, metering-points.json, requests.jsonl, chunks.jsonl, bodies/, progress.json,
report.md. Give the owner a second copy (an encrypted disk image or an encrypted archive that keeps the 0600
modes) on a medium of his choosing. Never into git, a worktree, an image, a volume or a fixture (§12.2). It holds
no token. data/capture/pace.json is the capture's pacing state and need not be kept; the handoff record in the
state directory's egress/ carries it to the worker.
After COMPLETE. Copy the run directory to the second medium first. Running make capture on it again makes
no call (above). On another day before 31 December, after the second copy: make capture RETRY=all
(B06bf4, ruling 2; B06bv5-01, ruling 1: 2021 is what leaves the API on 1 January, and an access edge or a hole
rests on one day's evidence until it is asked again). It asks every access edge (every one that touches 2021
among them) and every hole again, confirmed or listed apart, each window and each span twice at least 10
minutes apart, the newest span of every point before its running year's control, and every normal Month
control of the months a retried window or span touches afresh, the valued ones too: only a control answer from then
on confirms or contradicts (B06bx-05). A day the API publishes between the newest span and the control that follows
makes the load fail on that month (make load-capture, exit 4): make capture RETRY=all again asks the newest span
and the control afresh (B06bv6-01). The limit: a correction of a stored day older than the newest span makes
the load fail for its month after such a recheck; RETRY cannot repair it; the remedy is a new capture (NEW=1)
while the API still serves the year, and the lead decides. A hole that delivers its
days on the retry is stored and is no hole; one that answers the same, and whose month's new control agrees,
stays a hole; an edge that answers the same on two days, and whose control agrees on the second, is an edge.
The report prints the line under "Access edges" and under "Holes", says every run date each hole and each short
day final by its month was confirmed on (confirmed on 2026-11-13, 2026-11-14; the dates are kept in
progress.json, B06bv6-03), and prints holes confirmed on one day only: ask again on another day (make capture RETRY=all) while some hole rests on one date, and the same line for short days under "Short days" (information,
not a bar).
Then. make up, then make load-capture CAPTURE=data/capture/<run> (B08b) into the live database; B07's and
B08b's criteria on the capture follow. make load-capture reads the capture's api_base_url and complete
first: a capture made at another address than the API's (a rehearsal's) is refused (make: *** [load-capture] Error 3, nothing written) unless REHEARSAL=1, which says "rehearsal" in the first and the last line
(B06bv4-06); an incomplete capture is refused the same way (Error 3) unless INCOMPLETE=1, which loads it and
ends with make: *** [load-capture] Error 6, never a pass (docs/runner.md, B06bv2-04). The shell's $? is 2
for each (above). The monthly control reads the edge controls: a month an edge control answered without a value,
with nothing stored, is compared and equal (B06bv4a-02); a Month answer is read in the capture's order (B06bf6,
ruling 4): an odd one is no value and never "nothing" (a root's months not compared, Error 5; a child's a bar),
two values whose periods overlap fail the month "counted twice" (Error 4), and each month compared says to
which step ("each month compared to the nearest 0.001 of the Month value's unit", ruling 5). Beside the E17 roots' energy comparison,
the retention gate covers every captured series, children included (B06bx-07, B06bv5a-22): every series-day
with a value in any stored Actual answer, read from the bodies (an item that did not parse too), must be in the
database after the load; a day the loader refused by a validation rule (named with its code, in words), one in
an item that did not parse, in a period without bounds or outside its window, a missing one, or a child's month
whose Month value differs from its stored sum makes the control FAILED (Error 4), naming the point, the dates
and the rule; so does a metering point of the manifest not in the database (B06bv5a-21: the children the
capture registered from details are loaded with their parent). "Passed" therefore needs every series, not only the roots. **A hole accepted by
name** (ACCEPT=<number>:<day>, listed apart because its month's control differs from its delivered days) is
no pass at the replay, unlike an accepted refused window: its month fails there (Error 4: the root's month
differs, or for a child retention: … days of a month whose Month value differs from its stored sum). What the
lead does instead: ask it again on another day before 31 December (make capture RETRY=<number>:<day>, which also
asks its month's control afresh); if it still answers without the day and the month still differs, the load still
writes everything it holds (the control reports, it undoes nothing), and that month's FAILED line, with the
accepted day, goes into the B06b record for the owner; a new capture (make capture NEW=1) is the alternative
while the API still serves the month.
Delete (only once the second copy is verified): make capture-purge asks for delete and removes
data/capture/, nothing else.
Kilde: docs/capture.md i løsningens
repository.