Dokumentation · Arkitektur og beslutninger
Stored facts – Build specification: day facts for the figures made from readings (ADR-004's remedy)
Status: version 1.2, 26 November 2026. Written by worker elo-a6-stored-facts (Claude · Fable) on the brief
orchestration/tasks/a6-stored-facts.md, after the owner said that the first install after the owner's own is a
company login of about 50 metering points. B97's first numbers at 50 points came from the lead while this was
written and are in §7.4, marked [B97]; its other queries and its 70 and 100 points were not in. Nothing here
was built or run; no service was called. Version 1.1 applies three static reads (reviews/build/A6-agy-exact.md,
A6-agy-fresh.md, A6-agy-readers.md: fourteen findings) with the lead's rulings
(orchestration/tasks/a6f-fixes.md); version 1.2 writes the partitions' triggers on what the lead measured in
PostgreSQL 18.7 (§4.2); the last section says what was done.
Precedence. docs/architecture/phase-1.md, phase-2.md and municipality-method.md stay the specification
of everything they describe; this document adds to them and changes only the sentences listed in §9. It replaces
the fact tables of docs/architecture/solution.md §2.7 and §2.8 (calc.emission_day, calc.cost_day,
calc.mix_month, calc.dirty, agg.*) for everything it names. An epic is built from this document, the three
specifications and docs/adr/ADR-004-scale-at-500.md.
0. Reading guide
Who reads what. Every builder: §0, §1, §2.1, §3.1. Then the sections named in the epic's row of §7.2.
Conventions. Those of phase-2.md §0: "§2" is a section of this document, "P1 §9.3" of phase-1.md,
"P2 §3.4" of phase-2.md, "MM §2.3" of municipality-method.md, "S §2.7" of solution.md, "ADR §5" of
docs/adr/ADR-004-scale-at-500.md. [code] marks a statement about the code as it is on main at 8d67485,
read for this document. [ADR] marks a number ADR-004 measured, on generated data, on a shared machine.
[B97] marks one of B97's first numbers as the lead passed them on 26 November (50 roots, 61 series, 4.9
million readings, a year to date with py, the median of five, a virtual machine of its own on a host under
load from other workers): not yet in the ADR, and not re-verified here.
[LM] marks what the lead measured on 26 November in a throwaway PostgreSQL 18.7, the stack's image, and
passed on: not re-run here.
[est] marks an estimate made here from such numbers and measured by nobody: an epic's report replaces each
one it is told to measure (§7.2). Epics are B130 to B137; migrations start at 0430 (0400 to 0429 are another
specification's).
The terms.
| Term | Meaning |
|---|---|
| Root-day | One E17 root on one local day (Europe/Copenhagen): the grain of every fact |
| Cell | An hour cell of P1 §2: (local date, clock hour, occurrence). A day has 23, 24 or 25 |
| Mask | 25 bits in an integer, one per cell of a day: bit h for clock hour h (0 to 23), bit 24 for the second 02:00 of a 25-hour day |
| The functions | calc.emission_buckets, calc.consumption_matched, calc.cost_buckets, calc.mix_buckets and the others that compute a figure from ts.reading when it is asked for [code]. They are not changed by this document and stay the reference |
| The maker | The new function that computes the fact rows of given root-days from the readings (§2.5). What it returns is what is stored |
| The readers | The new functions that return what the functions return, made from fact rows (§5) |
| Stale | A root-day that holds a mark (§4.1): its stored rows are not read |
| Live | Computed from the readings inside the query, as every figure is today |
No figure of an install is in this document. Every number is ADR-004's (generated data), a count of rows that follows from a calendar, or marked [est].
1. Scope, and what is not built
| # | What | Section |
|---|---|---|
| F1 | Two fact tables at the grain root and local day: the readings' and the cost's part of a day, and the emission of a day per method and status | §2 |
| F2 | The like-for-like measure of any comparison (py, pp, from:) from masks stored per day, with a remainder computed from the readings | §2.4 |
| F3 | Marks written by the database when an input changes, a job of the worker that recomputes marked days, and a query that never reads a marked day's row | §4 |
| F4 | Readers with the functions' own columns; the overview's and the development page's queries read them, always | §5 |
| F5 | The row budget keeps its numbers and its meaning: the reading rows a query reads. A query reads far fewer | §5.4 |
| Not built | Why |
|---|---|
| A fact at hour grain | §2.1. A root-hour table is the readings again: 24 rows a root-day where the cost is the rows. What needs hours stays on the readings |
| A fact of the mix | §3.3: the mix is rounded per hour on the selection's sum, so no row of one root can hold it. It stays computed |
| A stored matched sum per comparison ("against the previous year's day", ADR §6) | §2.4: it would serve py alone and be stale by two days' inputs. The masks serve every comparison |
| The cost's two effects from facts | §2.6: the volume effect is one day's energy times another day's price, hour by hour. It becomes a query of its own, on the readings |
Month facts, facts per node, agg.node_hour (S §2.8) | A year of 420 roots with its previous year is 306 600 root-days (ADR §6): read in well under a second [est]. Month facts are named in §8 for 5 000 points, not specified |
| Facts for export children (E03, K02) | Few series (40 among ADR-004's 420 roots [ADR]); energy.split reads them from the readings (§5.5) |
| Losses, biogenic CO2 and the gases per kWh as facts | Only report.footprint returns them [code], and it stays on the readings so that the validation does not rest on the facts (§5.5) |
| A result cache in the API | P1 §1.4 stands: every request runs its query |
| A change to any rule of a figure | "Every stored figure equals what the functions of today compute" (ADR §9). A like-for-like rule by the day (P1 §1.4's alternative) is rejected for that reason |
2. The facts
2.1 Grain and keys
**Decision: a fact is a row of one E17 root and one local day. The method and the status of the hours are
keys; the data basis, the GWP set and the comparison are not. No fact has a finer grain than the day, and the
tables live in a schema of their own, fact.**
| Key or grain | Decision | Reason |
|---|---|---|
| Root | The E17 root, by mp_id. No child, no export series, no node | Every emission, cost and like-for-like figure of the pages is of E17 roots alone (P1 §9.2; docs/cost.md for K01). A location-based fact is linear in consumption, so a selection is a sum of roots (S §2.7) |
| Local day | The local date of the interval's start (P1 §2) | A month, a period and a card's strip are sums of local days (docs/queries.md, "The previous year"); the price area is a fact of the root's local day (core.mp_geo); a UTC hour lies in one local day, so an hour is never divided between two rows |
| Hour | Never stored. | A row per root and hour is as many rows as an hourly root's readings, and the time of the functions is their rows (ADR §5: 5 to 13 µs a reading row). Compact vectors of a day's hours (an array per root-day) were weighed: they would hold the heat map, the mix and the effects, but a quarter-hourly cost needs the quarters, an emission needs a vector per method, and the result is a second store of every reading with a second implementation of every hour-level rule. The hour-level figures are bounded by the row budget instead (§5.5) |
| Method | A key: every row of ref.method with status available: three today (LB-PA-125, LB-PA-200, LB-MU-125). LB-MU-200 is reserved and has no fact; the UPDATE that makes it available marks every root-day (§4.2) and its facts follow with no other change | Two methods share no factor row (the allocation, MM §2.3's dataset), so nothing of one is derived from another. "A method that is offered is answered" (docs/queries.md): every available method has its facts, asked for or not |
| Status of the hours | A key of the emission's rows (§2.3): the hours of a day are divided by what their factor is | It carries both data bases in one set of rows: best is the rows of status 1 to 3, final the rows of status 3, and what the other basis leaves out is the pending part. A day has one status nearly always, so the key adds few rows. S §2.7 had it; rejected: basis as a key (every row twice, the second a subset of the first) |
| GWP set | Not a key. The three gases are stored and CO2e is made by the reader: co2_g + ch4_mg × GWP_CH4 × 0.001 + n2o_mg × GWP_N2O × 0.001 on the sums | The expression is linear, so on sums it gives the digits and the scale it gives on intervals (§3.1). A further GWP set costs no row and no recomputation |
| Comparison | Not a key. A row knows nothing of another day | §2.4. pp and from: set any day against any earlier day |
| The measure | Columns, not a key: E01's like-for-like parts and K01/K03's in one row of the day, G01/G16's in the emission's rows | One read per function |
Sizes [est], from ADR-004's organisation (420 roots, 2 191 days, 920 220 root-days): fact.day 920 220 rows
of about 150 B; fact.emission_day three methods, about 2.8 million rows of about 130 B; together under 0.7 GiB
with their keys, beside 4.1 GiB of readings [ADR]. At 50 roots: about 110 000 and 330 000 rows, under
0.1 GiB. No partitions: a root's days are a range of the key.
2.2 fact.day: the readings' and the cost's part of a root-day
PK (mp_id, local_date); mp_id references core.metering_point. One row for every root-day on which a
series of the root's own has a stored interval; a day with none has no row. Whether a day is marked does not
depend on that (§4.1). Every row carries version smallint, the version it was made under (§4.1).
| Column | What it is | Serves |
|---|---|---|
kwh numeric | Σ quantity of the day's intervals; NULL when none has one | The matched energy of a whole pair (§2.4); the cost's kwh |
s_cells, q_cells, c_cells (integer, masks) | The cells with a stored interval; with at least one quantity; complete by P1 §9.3 (the hour's intervals cover exactly its 60 minutes once, each with a quantity, none A02 or A05) | h, H, excluded_readings of every comparison (§2.4) |
priced_kwh, cost_dkk, estimated_cost_dkk, unpriced_kwh, no_price_area_kwh (numeric) | The columns of calc.cost_buckets' side totals of the same names [code], for this day: the cost is of the priced intervals, the estimated part of A03 readings | K01, K03 (cost_dkk ÷ priced_kwh, made by the reader), the note of the unpriced share, basis.price |
unpriced_hours int | The hours with an interval that has a quantity, a price area and no price | "x % af købet (n timer) har endnu ingen pris" |
quantity_intervals, no_area_intervals (int) | The intervals with a quantity; of those, without a price area | p_all_without_area (every interval with a quantity lacks an area; NULL when none has a quantity: docs/cost.md) |
price_generated, price_real (boolean) | A price behind the day's cost is generated; is not | basis.priceSource |
p_cells (integer, mask) | The cells in which every stored interval has a price | excluded_price and the matched cost (§2.4) |
The consumption (E01) is not read from here. calc.consumption_buckets reads ts.day_load [code], which
is written in the transaction of the readings and holds at every size (ADR §1); nothing of it changes. fact.day
adds what ts.day_load lacks: the cells.
2.3 fact.emission_day: the emission of a root-day, per method and status
PK (mp_id, local_date, method_id, status); mp_id references core.metering_point, method_id
ref.method. Every stored interval of the day is in exactly one row of each method: an hour has one status under
a method, because the price area is the day's, the municipality the root's, and the factor and the share the UTC
hour's.
status | The hours whose intervals | Methods |
|---|---|---|
| 0 | have a price area (and, under a municipal method, a share) and no factor row of any version: pending, reason no_factor | all |
| 1, 2, 3 | have a figure, and the factor row's version is Initial, Preliminary, Final | all |
| 4 | have no price area (noPriceArea) | all |
| 5 | are of a root without a usable municipality (noMunicipality, reason no_municipality) | municipal |
| 6 | are of a root whose municipality the setting's list leaves out (noMunicipality, reason municipality_not_loaded) | municipal |
| 7 | have a wanted municipality and no usable share: pending, reason no_local_share | municipal |
The order of the reasons is MM §5's: 4 before 5 and 6, those before 7, 7 before 0. Under basis=final the hours
of status 1 and 2 are pending with the reason no_factor, as the view has them [code]: a factor row that is
not Final is no factor under that basis.
| Column | What it is |
|---|---|
cells (integer, mask) | The cells of this status |
kwh numeric | Σ quantity of the status's intervals; NULL when none has one |
quantity_minutes int, quantity_hours int | The minutes of the intervals with a quantity, NULL when none has one (as kwh); the hours with at least one such interval, 0 when none |
co2_g, ch4_mg, n2o_mg (numeric; status 1 to 3 only, NULL otherwise: a check) | Σ of the interval amounts of P1 §9.2; under a municipal method on the remainder q_E (MM §2.3) |
est_co2_g, est_ch4_mg, est_n2o_mg (numeric; status 1 to 3) | The same over the intervals whose reading is estimated (A03) |
local_kwh numeric (status 1 to 3, municipal methods) | Σ q × R × 0.01, the municipal part (MM §2.3) |
generated, real (boolean; status 1 to 3) | A factor behind the amounts is generated; is not |
version smallint | The version the row was made under (§4.1) |
How each column of calc.emission_buckets is made from these rows (per side and bucket; "in the basis" is
status 1 to 3 under best, status 3 under final):
| The function's column [code] | From the rows |
|---|---|
kwh | Σ kwh, every status |
factor_kwh; co2e_g | Σ kwh in the basis; the CO2e of Σ gases in the basis |
provisional_co2e_g | The CO2e of: every gas of status 1 and 2 in the basis, plus est_… of status 3. An amount is provisional when its reading is estimated or its factor is not Final, counted once (P1 §10.2) |
pending_minutes, pending_hours, pending_kwh | Σ quantity_minutes, quantity_hours, kwh of status 0 and 7, and under final also of 1 and 2. pending_hours is a count: 0 for a side's bucket that has a stored interval and none pending, NULL only for a bucket with no stored interval (the function counts hours, it does not sum them: A6v-exact-02). The other two are sums: NULL over no row, and pending_minutes NULL where no pending interval has a quantity |
no_local_share_kwh | kwh of status 7 |
no_price_area_kwh | kwh of status 4 |
no_municipality_kwh, municipality_not_loaded_kwh | kwh of status 5 and 6; of 6 |
final_kwh, preliminary_kwh, initial_kwh | kwh of status 3, 2, 1 in the basis (under final the last two are NULL, as today) |
local_kwh | Σ local_kwh in the basis |
generated, real | bool_or over the rows in the basis |
p_… (the period's shares) | The same sums over the period, divided once at 9 decimals where the function divides |
p_all_without_area | p_kwh > 0 AND coalesce(p_no_price_area_kwh, 0) = p_kwh, the function's own predicate [code]: false for a period of 0,000 kWh without a price area. The cost's column of that name is another predicate, by the counts of intervals (§2.2), and true there: the two functions differ on it, and so do the two readers (A6v-exact-03) |
What the queries make of these columns: the cards' local_share, a row's provisional, the reason of a figure with no energy | Ratios and a threshold of the same sums, made where they are made today (§3.2). The hours of each cause, for fact.emission_reason_hours (§5.2): quantity_hours, or the bits of cells, by status |
h, H, the exclusions, the matched sums, generated_factors | §2.4 |
A sum over no row is NULL, as sum() over no interval is in the function: "an unavailable figure is never a
zero" needs no rule of its own. A count is the one exception, above: the function's count() over a bucket's
stored hours is 0 where none qualifies.
2.4 The like-for-like measure
**Decision: nothing of a comparison is stored. A day stores the masks of its own cells; the counts of any
comparison are bit operations on the masks of the two days that correspond, the matched sums are the two days'
own totals wherever the pair matches whole, and the pairs that match in part are computed from the readings of
those two days.** Reason: the matched sum of a day depends on which earlier day it is set against, and pp and
from: set it against any (P2 §3.4); a sum stored "against the previous year's day" (ADR §6) would serve py
alone, be stale whenever either day's inputs change, and leave the other two kinds on the readings. Rejected
also: storing the hour values of a day beside its totals (§2.1, the hour grain).
What of a matched sum can be stored per day: which cells are there, complete and in the figures, and the day's totals. What stays a computation: the sum over the hours that both sides have, when those are not all of either day.
For a period day d of a root and the day d′ that corresponds to it for hour cells (P2 §3.4: the same day of
the month under a shift in months, the same offset under a shift in days; docs/time-rules.md), cells correspond
by clock hour and occurrence, which is by bit:
| Name | Mask | From |
|---|---|---|
Q, C, S (of d); Q′, C′, S′ (of d′) | The cells with a quantity; complete; stored | fact.day |
K′ | The cells the day d′ has in the calendar: 23, 24 or 25 | calc.expected_minutes of d′, as the functions take it [code] (a comparison day may lie before the first year of ref.calendar_day). Empty when d has no corresponding day (29 February under py, 29 to 31 March against February) |
G, G′ | The cells in the figures of the measure: E01: every cell. G01: the cells of the method's rows in the basis (§2.3). K01, K03: p_cells | fact.emission_day, fact.day |
X = Q ∧ K′ | The period's cells that have a counterpart | |
M = X ∧ C ∧ C′ ∧ G ∧ G′ | The matched cells |
| The function's figure | From the masks |
|---|---|
hours_in_period (H) | bits of Q |
excluded_readings | bits of X ∧ ¬(C ∧ C′) |
excluded_factor (G01), excluded_price (K01) | bits of X ∧ C ∧ C′ ∧ ¬(G ∧ G′) |
matched_hours (h) | bits of M |
| The matched sums of each side (kWh; the gases; the cost; the generated flag) | By the kind of the pair, below |
| Kind of the pair | When | The matched sums |
|---|---|---|
| Empty | M has no bit | None: the pair adds to the counts alone, and the generated flag is NULL. No reading is read. A day whose hours are all pending is of this kind |
| Whole | M = S = S′: the matched cells are every cell either day stores | Each side's own totals: fact.day.kwh, and the day's gases in the basis or cost_dkk with priced_kwh. Exact: every stored interval of both days lies in a matched cell, and every matched cell is in the figures, so no row outside the basis holds a cell. generated_factors and generated_prices are the two days' own flags in the basis |
| Partial | Otherwise | Computed from the readings of d and d′ by the cells of §2.5, summed over M. The generated flags are the cells' own, over M: never the day's, which an unmatched hour with a generated factor or price would make true where the function says false (A6v-exact-01) |
A bucket's counts and sums are the sums of its days' (the functions' buckets add up to the period: B55), and a period's of its buckets'. The reason of a figure with h = 0 is the function's own rule on the counts.
How many pairs are partial. In a year against its previous year, for a root without gaps: the two clock-change days of each year (a 23-hour or 25-hour day against a day of 24, four pairs), and the day on which the factors end, if they end inside it. A missing or incomplete hour makes its own pair partial. A root that misses an hour every day is read from the readings whole, as today, and the row budget counts it (§5.4).
2.5 The maker and the cells
**Decision: one function computes the fact rows of given root-days from the readings; the job stores what it returns and a reader calls it for a stale day. A second function returns the cells of given root-days.** Reason: a stored row and a live row are then the same expression, and the only equality left to hold is the readers' against the functions (§3.4).
| Function | Returns | Used by |
|---|---|---|
fact.make_day(mp_ids int[], days date[], with_cost boolean) (the two arrays are pairs) | The rows of fact.day of those root-days. Without the cost, its cost columns and p_cells are NULL and no price is read | The job (§4.3), with the cost; a reader, for stale root-days: fact.consumption_matched without it |
fact.make_emission_day(mp_ids int[], days date[], method_id int) | The rows of fact.emission_day of those root-days, of the method asked; method_id NULL: of every available method | The job, for every method; a reader, for the one method it was asked (§5.4) |
fact.cells(mp_ids int[], days date[], method_id int) | One row per root-day and cell: the hour's kWh, whether it is complete, has a quantity, has a price for every interval, its cost and price_generated, and for the method its status, its three gases and factor_generated (method_id NULL: no emission columns). The two flags are the cell's own factor's and prices' | A reader, for the two days of a partial pair |
Each reads the readings by the root's series, named first (B77's rule, ADR §5), with the price area once per root
and day (calc.price_areas), the factor rows by their key and the prices by calc.hour_prices [code]: the
building blocks of the functions, not a second statement of the rules. The amounts are those of
calc.emission_intervals_price_area and calc.emission_intervals_municipal, the costs those of calc.cost_sum;
the maker sums them by day where the functions sum them by hour and bucket.
2.6 What a day row cannot hold
| Figure | Why not | What it reads |
|---|---|---|
The sources and the origin (mix.structure, mix.series, the mix rows of report.footprint) | §3.3 | The readings, as today |
| The volume effect and the price effect of K01 (P2 §3.2) | Per matched cell (q_AC − q_CP) × P_CP × 0.001: Σ q_AC × P_CP multiplies one day's hours by another day's prices. Neither day's row can hold it, for any comparison | The readings: a query of its own, cost.effects (§5.6) |
The heat map (consumption.weekday_hours) | A mean per root, weekday and clock hour over eligible hours: no sum of days | The readings; its budget of 6 000 000 rows holds E01 to 420 roots (ADR §6) |
E03, K02 and the split's sold row | Not E17 roots (§1) | The export children's readings |
| The intervals of one point (D1) | They are the readings | The readings (ADR §1: at most 0.49 s at 420 roots) |
2.7 Worked example
P2 §3.4's example: one root, the period one day of 24 hours, the comparison the day before (pp, by offset).
Hour 08 has 4 kWh against 3; hour 09 has 5 kWh against no stored value; the other 22 hours have 1 kWh on both.
| The period's day | The comparison's day | |
|---|---|---|
fact.day.kwh | 31,000 | 25,000 |
s_cells = q_cells = c_cells | 24 bits | 23 bits: bit 9 is not set |
K′ is 24 bits. H = 24 (bits of Q); X is 24 bits; X ∧ ¬(C ∧ C′) is bit 9: excluded_readings 1; for E01
M is the other 23 bits: h = 23. M is not S (24 bits): the pair is partial, and the 47 readings of the
two days are read: 26 kWh against 25 over the 23 cells, the like-for-like variance +1 kWh. The total variance,
31 − 25 = +6 kWh, is ts.day_load's, as today. Had the comparison's hour 09 held 5 kWh, the pair would be
whole: 31 against 30 from the two rows, and no reading read. Had the period's day no factor yet, G01's G
would be empty: the pair empty, H = 24, excluded_factor 24 (both days complete), no sum, no reading read.
3. Exactness
3.1 The decimals
**Decision: a fact stores the exact sum, unrounded, in a numeric without a declared scale. Nothing is rounded
when a fact is made, stored or summed.** Reason: every amount of the functions is made by +, − and × on
exact decimals (docs/emission.md, docs/cost.md), and a sum of exact decimals does not depend on how its
terms are grouped. So Σ over days of (Σ over the day's intervals) is, digit for digit and with the same number
of decimals, the functions' Σ over hours: "to the last decimal", which is more than the last printed digit.
| Stored sum | Scale it has | Why |
|---|---|---|
| kWh | 3 | ts.reading.quantity is numeric(15,3) |
| A gas under a price-area method | 9 | 3 + the 6 of fx.factor_hour |
local_kwh; a gas under a municipal method | 11; 17 | q × R × 0.01 (3 + 6 + 2), then × the factor |
| A cost | 12, or 14 where an hour took the mean of four quarters | docs/cost.md |
A numeric column with a declared scale would pad or round; one without keeps the scale of the sum, which is
the largest scale of its terms, as the function's own sum has. CO2e from stored gases: per interval the
function computes co2 + ch4 × G × 0.001 + n2o × G′ × 0.001; on the day's three sums the same expression gives
the same value (multiplication distributes exactly) and the same scale (every interval of a method has the
scales above). The test of §3.4 compares scale as well as value.
3.2 Where the functions round, and what the readers do there
| The functions round | Where | A reader |
|---|---|---|
A ratio: the intensity G16, K03, a status share, a share of the unpriced or pending energy, the cards' local_share, a relative variance | Once, at 9 decimals, from two exact sums (docs/queries.md; calc.cost_ratio) | Makes the two sums from the facts and divides once, by the same expression. A ratio is never stored and never summed |
A threshold: a row's provisional (more than 1 % of the figure is provisional) | In the query, from the provisional amount and the total | The same expression on the same two sums |
| The source energy of the mix | Per price area and hour, at 9 decimals, with a residual rule (docs/mix.md, step 2) | Does not exist: §3.3 |
| Nothing else | The functions sum; the page's formatting module rounds for display | – |
3.3 The mix stays computed
**Decision: no fact of the mix: not of the nine sources, not of the origins. mix.structure, mix.series and
the mix rows of report.footprint read the readings, as today, at every size.** The source energy of an hour is q × s ÷ S rounded to 9 decimals, with
the residual to the largest family and group, **where q is the selection's energy of that hour in that price
area, summed first** (P2 §3.3 step 2; docs/mix.md: "a figure is computed for its selection"). So:
- a mix summed from rows of single roots is not the mix of the selection: the parts of two selections "do not add to the ninth decimal", by the specification's own words;
- a row of a day is no better: a day's source energy is 24 roundings of the selection's hours, and the selection is the request's;
- what would have to be stored is the energy of every root and hour, which is the readings (§2.1).
Why that holds at 50 to 100 roots. The mix never joins a reading to the rows of its hour (P2 §4): it sums
the selection per price area and hour, then meets one row an hour. It costs less a reading row than the emission
does: 2.0 s for a year of the demo's 18 roots against its previous year where the emission took 2.7 s
(docs/queries.md, the budget table), about 5 µs a reading row [est]. Its budget is the default 2 000 000
rows, which a year to date with its previous year reaches at about 94 hourly roots (1 064 064 rows at 50
[ADR]): about 5 s at 50 roots and 10 s at 94 [est], above which it is refused, never wrong. It is A4's query, one step from the overview and not its
first view. B97 measures it at 50, 70 and 100; §7.4 says what follows from the number.
What waits for B87 and B88. Nothing of this document: the municipal sources (geo=municipality, the part
local, the parts per municipality) are computed by the same function with a parameter (MM §2.4) and stay
computed with it. The municipal emission is in the facts from the first epic: its method is available
today [code].
3.4 The tests that hold it
The functions stay, unchanged, as the reference: of the equality test below, of make verify (§4.5), of the
Python reference's own tests, and of every figure that is not read from a fact.
| Test | What it holds | Where it runs |
|---|---|---|
| The readers equal the functions | For every named case of elo_devtools.emission_cases, cost_cases and comparison_cases (loaded as the queries' tests load them, by query_harness.arrange, which writes the day summaries the row budget counts by), and on the demo organisation over seeded random periods and selections that hold both clock-change days, 29 February, the ends of months of unequal length and both municipalities: each reader's rows equal the function's rows, column by column, value and scale (the text of the numeric); for every available method, both bases, both GWP sets, py, pp, from: and none, the grains period, month and day | services/api/tests, in the test database at the head |
| The same in four states of the facts | (a) every root-day made; (b) every root-day stale: the readers compute everything live; (c) a seeded half stale; (d) every root-day made and ELO_FACTS_LIVE on (§5.1). The four answers are one answer | The same |
| A partial pair | The worked example of §2.7, its three variants; a day of four quarters against one hourly value; an A05 interval; an hour of A02 alone (a stored cell without a quantity: never whole); a pair whose one unmatched hour has a generated factor and a generated price | The same |
| Stored equals made | After any sequence of writes and a run of the job, every row of the two tables equals what the maker returns now | The walk of the writers (§4.2); make verify |
At the head only. Every one of these tests runs in a database migrated to the head, with today's code. No test migrates to an older revision and runs today's code there, and none compares "before and after the migration": the reference is a function that is still there, not an answer saved from an older schema. B66's fixture stays what it is, a file of answers, and the queries that change readers must still equal it (§7.1).
4. Freshness
4.1 A mark, and one invariant
**Decision: a root-day is stale while the table fact.stale holds its mark. The database writes the mark, by a
trigger of every table a fact is made from, in the transaction that changes the input: for every write that can
change the day, whether a fact of it exists or not, and for every write that removes what it was made from. A
query never reads the stored rows of a marked root-day: it computes that day from the readings. A job of the
worker recomputes marked root-days and takes their marks away.**
fact.stale: PK (mp_id, local_date); seq bigint (from a sequence, a new value at every marking, also of a
day already marked); marked_at; attempts smallint (0 until a making failed), failed_at timestamptz,
error text (the SQLSTATE of the failure, never a message). A marking, new or renewed, sets attempts to 0 and
clears the other two: a day whose inputs changed is tried at once. Only two things write the table: the
triggers' functions and fact.refresh (§4.3), both the owner's.
fact.state: one row. version int and what it stands for (definitions bytea, time_zone bytea: §4.2);
live boolean (§5.1). **Every row of fact.day and fact.emission_day carries the version smallint it was
made under, and a reader reads only rows of the current version**: a row of another version is as if it were
not there.
The invariant (F). In every committed state of the database, a root-day without a mark has exactly the rows the maker returns for it from that state's inputs, at the current version: none, when no series of the root has a stored interval that day. Three rules keep it:
| Rule | Detail |
|---|---|
| A change and its mark commit together | The trigger runs in the writer's transaction. A reader's snapshot holds both or neither |
| The job removes only the mark it worked from | It reads (mp_id, local_date, seq), then the inputs, writes the maker's rows and deletes the mark by all three in one transaction. A mark renewed meanwhile has another seq and survives, so the day stays stale and is made again |
| A query reads marks, facts and readings in one snapshot | It is one REPEATABLE READ read-only transaction already (P1 §10.1) |
So freshness never depends on the job having run: only on the mark having been written. A database in which no
job runs (a test's, the validation's) answers every query right, at today's speed. **A mark does not ask
whether there is anything to make.** A day whose readings were withdrawn, a point that is no longer a root and
a series that moved are marked like any other; the maker then returns no row, fact.refresh deletes what was
stored and the mark, and such a day costs a query no reading (ts.day_load.points is 0 or the row is gone).
Version 1.0 marked "only root-days that have a stored interval", which left exactly those days unmarked with
their old rows in place (A6v-fresh-01).
Why a trigger, and why a mark. P1 §1.4 stored nothing to remove one class of error: "stale facts; a
preparing state; a recomputation that misses a trigger". The inputs have many writers (§4.2 lists twenty). A
mark written by each writer's code is forgotten by the next writer; a trigger of the table is not. Rejected:
computing the facts in the writer's transaction (one window of factors is 121 days: at 500 roots 60 500
root-days inside the loader's transaction, and a defect of the calculation would stop the ingestion); a
fingerprint of the inputs in every fact row, compared by the reader (it needs the same triggers, to keep a
version per price area and day); S §2.7's calc.dirty by scope (price area, municipality): fewer rows, but the
reader would resolve scopes for every root-day it reads, and a municipality's code would have a fifth place
(MM §4).
4.2 What makes a fact stale: the triggers, the writers, the walk
The triggers. Each is AFTER … FOR EACH STATEMENT with a transition table, one trigger per event (PostgreSQL
takes one event for a trigger that has a transition table), so that a statement of a hundred thousand rows
resolves its root-days once and writes one mark for each (A6v-fresh-05). The function of each is the owner's
(SECURITY DEFINER, search_path pinned). "Every day of a root" is every local day on which a series of the
root's own has a row of ts.day_load or the root has a row of fact.day.
| Table | Events, and the columns that count | Root-days marked |
|---|---|---|
ts.reading | INSERT; DELETE; UPDATE of quantity, quality, resolution | The E17 root of the row's series; the local day of its interval_start. Old and new rows both. A row of a series that is no root's own marks nothing |
ts.reading's partitions | The same three triggers on each partition, beside the parent's. What they are for is in "The partitioned parent and its partitions" below. fact.arm_partition(regclass) is the one place that creates them: the migration calls it for the 144 partitions of today, and whatever makes a partition later calls it | The same |
| Each input | TRUNCATE (a statement trigger without a transition table) | Every root-day: fact.mark_all(). No writer of the repository truncates an input outside a test's own database [code] |
ts.series | INSERT; DELETE; UPDATE of mp_id | Every day of the series (its ts.day_load rows), for the root it belonged to and the root it belongs to; and every day of the root it left |
core.metering_point | INSERT; DELETE; UPDATE of root_mp_id, type_code | Every day of the point, as old and as new: a point that stops being an E17 root is marked through the rows it has in fact.day |
core.mp_version | INSERT; DELETE; UPDATE of municipality_code, observed_to | Every day of the point when it is an E17 root. The writer closes the current version and inserts the next (write_version [code]), so the rule is "a version came, went or was closed", not a comparison of two codes: a new version is rare (a change of master data), and a root's six years are 1.5 s of the lane [est] |
core.mp_geo | INSERT; DELETE; UPDATE of price_area, valid_from, valid_to | Every day of the root |
fx.factor_hour | INSERT; DELETE; UPDATE of the six value columns, version, generated (not of retrieved_at, meta_updated_at, fetch_id, extras alone) | Every E17 root whose price area on the hour's local day is the row's (calc.price_areas), that has a stored day or a fact of that day; that day |
price.spot | INSERT; DELETE; UPDATE of dkk_per_mwh, resolution, generated (the table has no version) | The same |
fx.re_coverage_hour | INSERT; DELETE; UPDATE of re_share_pct, generated (the table has no version) | Every E17 root whose current municipality is the row's (calc.mp_municipality), with a stored day or a fact of the hour's local day; that day. The mark names the root, never the code |
ingest.municipality_setting | UPDATE of municipalities (not of names: a name changes no figure) | Every root-day: fact.mark_all() |
ref.municipality | INSERT; DELETE | Every root-day |
ref.method | INSERT; DELETE; UPDATE of status, allocation, geography (not of is_default: the default changes which method is asked, not a fact) | Every root-day |
The partitioned parent and its partitions [LM]. ts.reading is the one partitioned input (144 month
partitions, made by migration 0007 [code]). In PostgreSQL 18.7:
| Case | Measured |
|---|---|
(a) An AFTER INSERT or AFTER DELETE trigger REFERENCING NEW TABLE / OLD TABLE, FOR EACH STATEMENT, on the partitioned parent | Created. It fires once per statement with the statement's rows, whichever partitions they lie in: an INSERT of three rows over two partitions (n = 3), a COPY into the parent (n = 2), a DELETE through the parent (n = 1) |
| (b) The same trigger on a partition | Created: 18.7 takes a transition table on a partition |
(c) A statement that names a partition (INSERT INTO it, DELETE FROM it) | Fires no trigger of the parent: only a trigger of that partition sees it |
| (d) A partition made later | A write through the parent fires the parent's trigger (n = 1); a write that names the new partition fires nothing unless the partition has its own |
**Decision: both. The parent's three triggers are what marks for every writer of today; every partition carries the same three as well.**
- Every one of the twenty writers below writes the readings through the parent. Each row was checked for
the relation its statement names [code]:
ts.apply_day,ts.observe_absenceandts.withdraw_rows(0040) insert into, update and delete fromts.reading; the bulk loader inserts intots.reading; the harnesses likewise; **the removal deletesFROM ts.reading … RETURNING tableoid, through the parent, and names the partitions only in its answer** (0370; version 1.1 said it deleted "partition by partition", which was wrong). No statement of the repository namests.reading_<year>_<month>; a test of B130 reads the sources and the functions' texts for that pattern and fails on one. So by (a) the parent's triggers alone mark every write there is, a partition made later included, by (d). - The partitions' triggers are for the write that is not in the list: by (c), a statement that names a
partition (a repair by hand, a job somebody adds) would change a day and mark nothing. With the three
triggers on the partition it marks. By (b) they can be made;
fact.arm_partitionmakes them; a test listspg_inheritsand fails for a partition without the three, and with the triggers of one partition dropped aDELETEthat names it fails its marks' test. A write through the parent fires the parent's statement triggers and not the partitions' (statement triggers are those of the table a statement names), so nothing is marked twice; B130 asserts that too, and a mark written twice would be the same mark. - What no trigger sees: a partition dropped or detached. Nothing does that today (P1 §1.4: no partition job,
no retention); the housekeeping job that one day does must call
fact.mark_all(), or mark the partition's days, in its own transaction (§8, point 1).
The four triggers of the public figures mark a root-day only where there is something to make or to unmake: a price for tomorrow marks nothing, because tomorrow has no reading; when the reading comes, its own trigger marks the day. That is the one place "is there a stored day" is asked, and it is asked of days that can only gain a fact, never lose one.
The version. fact.version() is a hash of two things: the definitions of every function and view of the
schemas calc and fact (pg_get_functiondef, pg_get_viewdef), and the time zone's rules as the server has
them: the length in minutes of every local day of 2015 to 2040, computed with AT TIME ZONE 'Europe/Copenhagen'
(a new PostgreSQL image may bring other rules while no definition changes: A6v-fresh-06). **When it differs
from what fact.state holds, fact.state.version is raised and fact.mark_all() runs.** It is compared in two
places: in migrate.upgrade(), the function every entry point of the migrations reaches (the Compose step, the
tests' databases), so before the API of a new release serves a request; and at the start of every run of
fact.refresh. No migration's author has to remember it. The cost is the first load again (§6): 1.5 minutes of
the lane at 50 hourly roots, 13 to 18 minutes at 500 [est]; until a day is made again its rows are of
another version and no reader reads them.
The writers. Every writer of an input in the repository at 8d67485 [code], the days its write marks,
and what marks them. A row is a writer, not a table: the test below walks this list.
| # | Writer | Writes | Marks | By |
|---|---|---|---|---|
| 1 | ts.apply_day: the merge of a response (the daily run, the backfill, the replay of a capture, the demo load) | ts.reading inserted, updated, deleted | The root's day, when a reading of it changed. A day that is confirmed touches no reading: no mark (7 000 confirmations a day at 500 series [ADR]) | ts.reading |
| 2 | ts.observe_absence, ts.withdraw_day (ts.withdraw_rows) | ts.reading deleted | The day, although nothing of it is left | ts.reading, DELETE |
| 3 | The merge's registration of a series (merge.py; ts.apply_day's updates of ts.series) | ts.series | A new series: nothing yet. A series whose point changes: every day of it, both roots | ts.series |
| 4 | The master data's register (masterdata.Tree._register), the daily run's and the demo load's updates of a point | core.metering_point | A point that becomes or stops being an E17 root, or changes its root: every day of it. Another column: nothing | core.metering_point |
| 5 | The master data's versions (masterdata.write_version) | core.mp_version closed and inserted | Every day of the root | core.mp_version |
| 6 | The price area: the master data's periods, make set-price-area, the demo's removal of one root's periods (Makefile, demo-load) | core.mp_geo | Every day of the root | core.mp_geo |
| 7 | The declaration's loader, GE (eds-load, eds-monthly-repull, the file mode) | fx.factor_hour, dataset 1: rows inserted and updated, vanished rows deleted. The history table is no input | The roots of the area, the hours' local days | fx.factor_hour |
| 8 | The transmission factors' loader, TE (eds-tx-load, eds-tx-monthly, the file mode) | fx.factor_hour, dataset 2 | The same | fx.factor_hour |
| 9 | The prices' loader, both datasets (eds-prices, eds-prices-monthly, the file mode) | price.spot | The same | price.spot |
| 10 | The municipal share's loader, the set and a catch-up (eds-recoverage, eds-recoverage-monthly, the file mode) | fx.re_coverage_hour | The roots of the municipality, the hours' local days | fx.re_coverage_hour |
| 11 | fx.forget_municipality | fx.re_coverage_hour deleted | The same, by the deleted rows | fx.re_coverage_hour, DELETE |
| 12 | The mix's loaders, GM and TM | fx.mix_hour | Nothing: no fact is made from it (§3.3). The table has no trigger, and the catalogue's test says why | – |
| 13 | ops.remove_account | Deletes the account's readings (through the parent; its answer names the partitions), series, versions, periods, points; under auto the shares of a municipality no root has any more | Its own points: the function deletes their facts and marks itself (§4.5). The triggers fire as for any writer; a share it deletes is of a municipality no remaining root has, so marks nobody | The function, and the triggers |
| 14 | migrate.install_settings | ingest.municipality_setting (municipalities, names), ref.method.is_default, fact.state.live | A changed list: every root-day. The other three: nothing | ingest.municipality_setting |
| 15 | ref.add_generated_municipality (the demo's two); a migration that adds or removes a municipality | ref.municipality | Every root-day | ref.municipality |
| 16 | The UPDATE that makes a method available (method 4, by hand); a migration that seeds or changes a method | ref.method | Every root-day | ref.method |
| 17 | A migration that changes a function or a view of calc or fact; a new image of PostgreSQL with other time zone rules | No table | Every root-day | The version |
| 18 | The bulk loader (elo_devtools.synth.bulk), as the owner: points, versions, periods, series, the readings of a series in one statement, COPY fx.factor_hour | Six of the tables above | What each table's trigger marks | The triggers |
| 19 | The harnesses that write tables directly (emission_cases, cost_cases, query_harness, merge_harness, footprint_demo) | The same tables | The same | The triggers |
| 20 | fact.refresh | fact.day, fact.emission_day, fact.stale | – (it is what makes a day) | – |
No writer after the migrations: ref.calendar_day, ref.price_area (seeds). Not read by the maker:
ref.gwp_set (§2.1), ts.day_load (the maker reads the readings; the day summary is the readings' by R5 and
serves the row budget's count).
Three tests hold the list.
| Test | What it holds |
|---|---|
| The walk of the writers (B131) | For each row of the list, on the demo organisation with every fact made: the writer performs its write by its real path (the merge with a corrected value and with a withdrawal; a point given a parent; a series moved; a new version with another code; a second period of core.mp_geo; the loader's file mode with a restated factor, a vanished factor, a changed price, a changed share; the forgetting of a municipality; the removal of the other company; the setting moved from auto to a list; a method made available; a function of calc replaced; the bulk loader's statement; a harness's direct insert). Then, for every root-day without a mark, the stored rows equal the maker's and the readers equal the functions; then the job runs and the same holds for every root-day. A writer that marks too little fails the first half |
| The catalogue's test (B130) | Every table of the database stands in one of three lists of the test: an input, with its triggers asserted event by event; a fact table; or a table the maker does not read, which the test checks against the maker's reach (the text of the maker's functions and of every function of calc they call; the catalogue's dependencies for views). A new table that the maker reads, or one that is in no list, fails it the day its migration runs, as B75f3's walk does for the removal (docs/storage.md, "Ids and the removal") |
| A trigger dropped (B130) | For each trigger: with it dropped, its row of the walk's marks fails |
The cost of a mark, measured. B130 measures, on the bulk organisation at 420 roots, what the triggers add to
the largest statement of each kind: the bulk loader's statement of one series' six years of readings and its
COPY of 315 504 factor rows [ADR]; a loader's window of factors (121 days, two areas, three allocations)
and of shares; and the mix loader's largest statement, which must cost what it cost before (no trigger). The
estimate: a transition table costs about what the statement's own rows cost to write once more, and the marks
are one small row a root-day: 60 500 for a window of factors at 500 roots [est].
4.3 Who recomputes, in which lane, at what cost
**Decision: the worker, in a third lane of its own, the facts lane: one thread, one job at a time, kind
facts-refresh.** Reason: the job calls no service and must wait for none. In the declaration lane it would
stand behind a re-pull of the mix (about two hours and twenty-five minutes on the 2nd, docs/declarations.md);
in the main loop behind a backfill.
| Rule | Detail |
|---|---|
| Due | When a mark is due, not when the table holds a row (A6v-fresh-03): a mark with attempts 0, or one whose failed_at is older than the wait of its attempts: 1 hour, 6 hours, 1 day, then daily, the ladder of a parked chunk (P1 §6.2). The lane's own check before each claim asks fact.status() and queues the job when it reports a due mark, as the declaration lane's check does [code]. A day that keeps failing therefore costs four jobs on its first day and one a day after, not one every poll |
| The demo stack | The lane runs with ELO_DEMO=1 too: it calls nobody |
| The order | The due marks, newest local day first, then the lowest mp_id: the year a default view reads is ready first |
| A batch | At most ELO_FACTS_BATCH (2 000) root-days, in a transaction of its own (engine.begin(), as a loader's window is; not the claim's transaction, which stays open for the job and only acknowledges it [code]): the marks read, the rows made, the root-days' old rows deleted, the new ones inserted, the marks deleted by seq |
| A run | Batches until no mark is due or 60 s have passed; then its successor is queued, as a slice's is (P2 §2.2) |
| How it writes | fact.refresh(max_days int): SECURITY DEFINER, owned by elo_owner, executable by elo_worker alone, as ts.apply_day is. One call is one batch. The worker's role gains no right on any table of fact and none on calc: it executes fact.refresh and fact.status() (the counts make status and the lane's check need) and nothing else |
| A root-day it cannot make | Inside fact.refresh: when the making of a batch raises, the function makes its root-days one by one, each in a block of its own, and for the one that raises writes attempts + 1, failed_at and the SQLSTATE into its mark; the others are made. That day is computed live by every query for as long as it fails, which the invariant allows: slow for that day, never wrong, and never a reason for preparing (§4.4). make status names it by mp_id, day and SQLSTATE |
| The lock | Below |
| Statistics | fact.refresh analyses the two tables when a run has written more than a tenth of their rows (ts.analyze_loaded's reason, docs/runner.md) |
ops.data_version | Not raised: the job changes no figure |
The lock between the lane and the removal (A6v-fresh-02; one rule with B92f's for the municipal share).
The job holds the advisory lock elo.facts (hashtextextended('elo.facts', 0), exclusive) **as a session lock
on a connection of its own, from before its first batch to after its last**, the way the share's jobs hold
theirs (recoverage.run_lock [code]): taken with a lock_timeout of 60 s, the connection discarded on an
error, so that a failed batch can leave no lock behind on a pooled connection. fact.refresh itself takes no
advisory lock: the batches run on other connections, inside the job's lock. ops.remove_account tries the
lock for its transaction (pg_try_advisory_xact_lock) and refuses when it is held: elo-remove: facts, which
the command answers with "a worker recomputes the stored facts; nothing changed: try again in a minute, or stop
the worker (make down) and run make account-remove again" (REFUSALS of elo_devtools/account_remove.py). A
job that starts during a removal waits for its commit and then reads what is left.
| Order | The removal takes |
|---|---|
| 1 | The account's row, FOR UPDATE |
| 2 | elo.ingest (tried: elo-remove: call) |
| 3 | The queued jobs' rows (tried: elo-remove: job) |
| 4 | elo.eds.recoverage (tried: elo-remove: share) |
| 5 | elo.facts (tried: elo-remove: facts) |
| 6 | The rows it deletes: the account's ts rows, then fact.stale, fact.emission_day, fact.day of its points, then the points |
The lane takes elo.facts and then only rows of fact; it never takes elo.ingest or the share's lock, so
there is no second order to contradict the first. A writer's trigger takes row locks of fact.stale alone and
never an advisory lock: a merge beside a batch waits for at most that batch, and its mark survives it (§4.1).
The cost per day [est]. A root-day of an hourly root costs about 0.7 ms to make, for three methods and the cost: ADR §5's 8.5 µs a reading row for the emission without a comparison, three times, plus the cost's 3 to 5 µs (4.9 with its comparison [B97]), on 24 rows. A quarter-hourly root-day costs four times that, so ADR-004's organisation, a seventh of whose roots are quarter-hourly, costs 1.4 times the hourly figure: the last column. B131 measures the rate at 50 and 420 roots; until then:
| What happens | Root-days marked | 50 roots, hourly | 100 roots, hourly | 500 roots, hourly | 500 roots, a seventh quarter-hourly |
|---|---|---|---|---|---|
| An ordinary day: each root's newest day arrives; the factors of about three days are published or gain a version (GE and TE mark the same root-days); one day's shares | 5 to 10 a root | under 1 s | about 1 s | 2 to 4 s | 3 to 5 s |
| The readings of a past day corrected | That root-day | – | – | – | – |
| The re-pull of the 2nd finds every hour since 1 January of the previous year restated (the worst case: up to 700 days) | 700 a root | 35 000: half a minute | 70 000: 1 min | 350 000: 4 min | 6 min |
The shares republished whole (as on 5 November 2026, docs/declarations.md); another version (a function of calc changed, other time zone rules) | Every stored day: 2 191 a root with six years | 110 000: 1.5 min | 220 000: 3 min | 1.1 million: 13 min | 18 min |
4.4 What a query does with a stale day, and what a page says
"Live rows" are the reading rows a request must read (§5.4); a stale root-day is failed when its mark has
attempts above 0.
| Case | The answer |
|---|---|
| No root-day of the request is stale | From the facts, with the partial pairs from the readings (§2.4) |
| Some are stale, and the live rows fit the query's row budget | ok, and every figure is current: a reader makes the stale root-days with the maker, in the query's own snapshot, and goes on as if they were stored. The response says nothing of it, because nothing in it is behind. A failed day is always answered so |
| The live rows exceed the budget, and they would fit it once the request's stale root-days that are not failed were made | A new state, preparing, reason facts_behind, no rows, with basis.facts: {"made": m, "days": N}: of the request's N stored root-days, m are made. HTTP 200, as too_large_for_grain. It says one thing: the making of the facts has not reached this selection's days yet, and will |
| The live rows exceed the budget and making would not help: the partial pairs and the failed days alone exceed it | too_large_for_grain, reason row_budget, as today. Waiting cannot answer it, so the page is not told to wait (A6v-fresh-04) |
| The install's setting makes every reader compute live (§5.1) | No day counts as stale: ok inside the budget, too_large_for_grain above it, never preparing |
Never: a stored row of a marked day, or of another version, in a figure; a zero for a day that is not made;
a caveat that asks the reader to distrust a figure. A response is of one snapshot, and its dataVersion stays
what it is: the version of the inputs (ops.data_version) in that snapshot. No figure of a response is older
than its dataVersion.
The words, and the bound (docs/pages.md; a page shows no state it has no sentence for): in the place of
the figures, "Tallene beregnes: m af N målepunktsdage er klar. Siden henter dem selv, når de er det." with m
and N from basis.facts, formatted by the one module. The shell asks the page's queries again every 20 s
while m rises: its patience is counted from the last answer in which m was higher than before, so a rebuild
of eighteen minutes that goes on is waited for. After five minutes without a rise it stops and shows "Beregningen
står stille. Prøv igen." with a control that asks once more. The caveats of every figure (pending hours, the
factor status, the unpriced share, "Sammenlignet over h af H timer") are the functions' own columns and are
unchanged.
4.5 The removal, the validation, make verify, make status
| Topic | Rule |
|---|---|
make account-remove | ops.remove_account is replaced by a revision of B130's block (its text keeps SET lock_timeout = '5s', docs/storage.md): the lock and the order of §4.3; it deletes its points' rows of fact.stale, fact.emission_day and fact.day after the account's ts rows (whose triggers mark) and before its core.metering_point rows; each table is named once in the answer, with 0 rows too. ops.removal_statistics covers the schema fact. The three tables reference core.metering_point, so B75's walk finds them and they are named, not excused; tools/tests/b75_mutations.py gains one mutation per table (the delete left out: a test fails); B75's search for the account's sentinels covers the three tables and their statistics; the other company's answers are what they were, to the last decimal, and its facts are untouched |
| The validation's throwaway database | The migrations create the tables and triggers; the replay marks its root-days; no worker runs; report.footprint reads no fact (§5.5); the database is dropped. Nothing is built for it, and the validation does not rest on the facts. tools/tests/test_validate_footprint.py passes unchanged |
make verify | Gains fact.verify(sample) (the owner's, as ts.verify): for root-days without a mark, the stored rows against the maker's, by value and scale; a difference fails with mp_id, day and table, never a figure. By default every root-day of the last 60 days and a seeded 2 000 others; FACTS=all every one (13 to 18 min at 500 roots [est]). A difference is a missing mark or a defect: what an owner does then is §5.1's setting, and fact.mark_all() |
make status | Lines of the facts, from fact.status(): root-days stored; stale, with the oldest mark's age; failed, each by mp_id, day and SQLSTATE, with the words "computed from the readings on every request until it can be made"; the last run's root-days and rate; the version; and, first of them, "the stored facts are switched off: every figure is computed from the readings (ELO_FACTS_LIVE)" when the setting is on. A warning when a mark that is not failed is older than a day |
| Grants | elo_api: SELECT on the three tables and fact.state, EXECUTE on the maker, the cells and the readers (it computes stale days live). elo_worker: EXECUTE on fact.refresh and fact.status(), no right on a table of fact. Nobody but the owner writes the tables; the triggers' functions and fact.refresh are the owner's |
5. The readers
5.1 Always, with one setting
**Decision: the queries of §5.3 read the facts for every request, whatever the size of the selection: one root or five hundred. There is no threshold.** Reason: one path in production. The owner's install of a few roots then runs what the install of 50 runs, and so do the demo and CI; behind a threshold the fact path would first run on the first large customer's data. Rejected: the functions below n roots and the facts above (two answers to keep equal in production, and a figure that changes its path when a point is added).
One setting of the install turns the stored rows off: ELO_FACTS_LIVE, off unless the owner sets it on
(the lead's ruling on A6v-readers-05; version 1.0 had none).
ELO_FACTS_LIVE=on | |
|---|---|
| Where it is set | On the settings' path B92 built: the shell, then .env.local; migrate installs it as the owner at every make up (elo_api.db.migrate.install_settings) into fact.state.live. One name, one reader |
| What it does | Every reader treats every root-day as not made and computes it with the maker, as it does for a marked day anyway; fact.live_rows counts accordingly. No stored row is read by any query |
| What it does not do | It calls no function of calc in a reader's place: it is state (b) of §3.4, which every release already tests query by query, not a second path. No day counts as stale, so no answer is preparing. The lane goes on making facts and make verify goes on comparing them, so the owner sees when they are right again |
| Why it exists | It is the one thing an owner can do when a fact is found wrong after a release. Going back a release is not: the migrations are forward-only ("There is no downgrade", migrate.py [code]), so 0430 and later stay applied, and after B135 an older page asks the cards for two columns they no longer have |
| What it costs | Today's seconds and today's refusals: at 50 roots the cards take about 25 s and are refused under the municipal method [B97] |
| What it cannot mend | A defect in the maker is in the live answer too: that needs a release, whose changed definition marks everything by itself (§4.2) |
| Who sees it | make status, as its first line of the facts (§4.5) |
| How long it stays | Through the first delivery, and until the lead removes it |
| The test | Every query of §5.3, for the parameters of B66's fixture, answers the same with the setting on and off, value for value (B134, B135, B136, each for its queries) |
5.2 The readers
Four functions of the schema fact, each with the parameters and the columns of the function it stands for,
in the same order, so that a query changes one name:
| Reader | Stands for [code] | Differs |
|---|---|---|
fact.emission_buckets(mp_ids, from, to, method_id, basis, gwp_set, grain, cmp, cmp_date) | calc.emission_buckets | Nothing |
fact.emission_reason_hours(mp_ids, from, to, method_id, basis, gwp_set) | calc.emission_reason_hours: the reason of a municipal figure whose energy is 0, from the hours of each cause (calc.footprint's hour counts, B84f) | Nothing. The hours of each status are the rows' quantity_hours, or the bits of their cells where the function counts hours without a quantity: B133 holds it to the function. Without it the cards, G01's two queries and the runner would still read every reading of a period of 0,000 kWh under a municipal method (A6v-readers-01) |
fact.consumption_matched(mp_ids, from, to, per_mp, cmp, cmp_date) | calc.consumption_matched without p_export | The export children are not E17 roots: energy.split's sold keeps the function |
fact.cost_buckets(mp_ids, from, to, grain, cmp, cmp_date) | calc.cost_buckets without p_export | No volume_effect_dkk and no price_effect_dkk (§5.6) |
What a reader does, in this order:
- Resolves the roots, the period's buckets and the comparison with the functions' own helpers
(
calc.period_buckets,calc.comparison_period,calc.comparison_buckets): the calendar has one place. 2. Reads the rows of both sides' days, of the current version, fromfact.day(andfact.emission_dayof the method), leaves out the marked root-days and makes those with the maker (§4.4): **for the method asked alone, and without the cost's part where the reader has no use for it** (§2.5). 3. Sums the totals per side and bucket. A comparison day counts in the bucket of the period day it corresponds to, by the functions' own expression (greatest(day + shift, first day), B55). 4. Pairs each period day with its corresponding day and classifies the pair by the masks (§2.4); takes whole pairs from the rows and asksfact.cellsfor the two days of each partial pair. 5. Divides where the function divides, once, at 9 decimals (§3.2).
It keeps the functions' planner rules where it reads readings (the series named first; no nested loop for the join to the factors: ADR §5, B77).
5.3 Which query reads what
| Query | After this document |
|---|---|
overview.cards (X1; also asked by A1 and D1 [code]) | E01 and COVERAGE: ts.day_load, unchanged. E01's like-for-like: fact.consumption_matched. G01, G16: fact.emission_buckets, and fact.emission_reason_hours where the query calls calc.emission_reason_hours today. K01, K03: fact.cost_buckets. The two effects leave the K01 row (§5.6) |
overview.months, development.series | E01, E03, ENET: ts.day_load, unchanged. G01: fact.emission_buckets, with fact.emission_reason_hours in the query file and in the runner's _emission_basis [code]. K01: fact.cost_buckets, without the effects. K02: the function, on the export children's readings. KNET: K01 from the reader less K02 from the function, "from the two figures as shown" (P2 §3.2) |
overview.mp_variance | fact.consumption_matched per root |
The providers factor_status.sql, price_status.sql | The readers, where they call the functions today. factor_status.sql is also the basis of mp.emission_intervals [code]: for D1's one root it then reads that root's facts |
cost.effects (new, §5.6) | The readings |
energy.split | bought: the readers (B136). sold, net: the functions, on the export children's readings |
consumption.weekday_hours; mix.structure, mix.series; report.footprint | The readings, unchanged (§2.6) |
mp.series, mp.emission_intervals, mp.cost_intervals and the rest of D1 | The intervals are the readings, unchanged. One point at the hour is the readings (ADR §1) |
meta.context, meta.selection | Unchanged |
report.footprint could take its emission blocks from facts and does not: it is the query make validate
holds against Eloverblik's report, and a validation that read the facts would validate two things at once. Its
budget by blocks holds a year of 420 roots (docs/queries.md). calc.emission_reason_hours and
calc.footprint stay for it.
5.4 The row budget afterwards
**Decision: every query keeps the number it has (docs/queries.md, "The budget is a number per query"), and the
number keeps its meaning: the reading rows the query reads. It counts every row a query will read live, each
side of a comparison for itself, as providers/budget.sql counts today.**
| Query | What providers/budget.sql counts |
|---|---|
| A query on the readings (§5.3) | As today: ts.day_load.points of the series it reads, the period's rows and the comparison period's own, summed apart |
| A query on the facts | For each reader the query calls, ts.day_load.points of the root-days that reader reads live: the stale ones (with ELO_FACTS_LIVE on: all), and both days of every pair that is partial for that reader's measure. Each side for itself: a day that lies in the period and in an overlapping py comparison counts twice, as today. Once for each reader that reads it: the cards call three readers, so a stale day of theirs counts three times, which is how often it is read; energy.split's number treats its two reads so already (docs/queries.md) |
| The export leg of KNET and of the split | The export children's rows, as today, added to the above |
fact.live_rows(…) gives, from the masks and the marks and before a reading is read: the live rows; the
request's stored root-days N and those made m; and the live rows that would remain were its stale days that are
not failed made (§4.4's line between preparing and too_large_for_grain). The readers take their live set
from the same function, so what is counted is what is read.
A period of marked days as large as today's refusal is still refused (A6v-readers-02). With every day of a
request stale, each reader's count is the count of today or more, so the sum is never below the number that
refuses the request today: the cards of 50 roots, a year to date with py, count 3 × 1 064 064 rows and answer
preparing, where today they run 24.6 s [B97]; the cards answer wholly live up to about 18 roots [est]. Version 1.0 counted "each day once" and made the maker compute three methods for a reader that asked
one: it would have admitted, live, more than the timeout holds.
Above the number: preparing or too_large_for_grain, by §4.4. **A second number, the same for every query on
the facts:** the root-days of both sides, roots × days from the calendar, may not exceed 2 000 000
(ELO_FACT_DAY_BUDGET); above it too_large_for_grain. A year of 420 roots with its previous year is 306 600;
six years of 420 roots against the six before are 1 840 440; the number is reached at about 2 700 roots for a
year with its previous year.
For the overview's default view (a year to date, all roots, py) at 50 roots without gaps, with the facts
made, the cards' count falls from 1 064 064 rows [ADR] to about 30 000 [est]: for each of the three
readers four clock-change pairs a root, two days of 24 to 100 rows each, and for the emission the pair of the day the
factors end in. The cards' 1 200 000 then admits the default view at any number of roots this document is
written for, and bounds what a first load, a restatement or a root full of gaps may cost a request. Today that
view is refused at 50 roots under the municipal method, whose factor makes the number 1 000 000 [B97]. **The
numbers are not changed here**: each was set where its query ran into the timeout computing everything; B137
measures the rate of the live rows and the lead sets them again by the rule docs/queries.md has.
municipal_budget_factor (MM §5) stays on the live rows.
5.5 What stays computed, and what is refused at 100 and at 500 roots
At about 21 300 reading rows a root for a year to date with its previous year (1 064 064 at 50 roots of ADR-004's organisation, a seventh of them quarter-hourly [ADR]), half of that without a comparison:
| Query | Budget | Refused from about (roots, a year to date in late November) | With the facts built |
|---|---|---|---|
consumption.weekday_hours E01, E03 | 6 000 000 | 560 without a comparison, 280 with one | Unchanged |
consumption.weekday_hours G01, K01 | 2 000 000 | 188 without, 94 with | Unchanged |
mix.structure, mix.series | 2 000 000 | 188 without, 94 with py | Unchanged (§3.3) |
cost.effects | 2 000 000 | 94 with py | New; it is K01's read of today |
energy.split | 1 000 000 | 47 with py: refused at 50 today | B136: the bought row from the facts. The budget then counts the export children's rows and the live rows of the bought row's two readers (§5.4), not the export children's alone |
report.footprint | 1 400 000 (all), 5 300 000 (emissions) | 131 (all), 498 (emissions) | Unchanged |
| K02, KNET | 2 000 000 | By the export children's rows, and K01's live rows | Unchanged |
| D1's queries | – | Never (one point) | Unchanged |
In the roadmap's words: what an install is refused, with the first delivery built (the lead's ruling on point 3: the first delivery's target is 50 roots, and beyond about 94 these are held by budgets alone). A year to date of every root in late November, roots as ADR-004's:
| At 100 roots | At 500 roots | |
|---|---|---|
| The overview (X1), A1's series, the cards on D1 | Answered | Answered; the seconds are B137's to measure |
| The sources (A4) | Answered without a comparison; refused with the previous year | Refused, with or without a comparison; answered for up to about 120 days of all roots (60 with a comparison) |
| The heat map of the consumption | Answered | Answered without a comparison; refused with one |
| The heat map of the emission and of the cost | Answered without a comparison; refused with one | Refused |
| The cost's two effects | Refused (they need a comparison) | Refused |
| Bought, sold, net | Answered | Answered |
report.footprint (make validate) | Answered | The emission blocks answered for a year to date until about late November; all blocks refused |
| One metering point (D1's intervals) | Answered | Answered |
Each refusal is too_large_for_grain, never a wrong figure, and a smaller selection or a shorter period is
answered. What would hold these beyond the budgets is in §8, point 2.
5.6 The cost's effects become a query of their own
**Decision (ruled by the lead): volume_effect and price_effect leave overview.cards, overview.months and
development.series; a new query, cost.effects, returns them, and A1 asks it when the measure is K01 and a
comparison is chosen.** Reason: they cannot be made from facts (§2.6; the read confirms the product per matched
hour, A6v-readers-03), only A1 draws them (Development.tsx and Effects.tsx, from the K01 row of the cards
[code]), and while they are columns of the cards the overview reads every reading of both periods for a
figure it does not show. Rejected: keeping them on the cards and computing them there (the overview at 50
roots would wait about 5 s for the cost's read: overview.months K01 takes 5.2 s there [B97]); a parameter
of the cards that switches them off (a default that is slow, and a cards answer that is refused whole when the
effects alone exceed the budget).
cost.effects | |
|---|---|
| Page, parameters | A1; p, mp, sel, cmp, g (period, the default; month; day) |
cmp=none | unavailable, reason no_comparison, by the catalogue's own rule, as overview.mp_variance answers it [code]: no 422, and catalog.py is not changed |
| Returns | Per bucket: bucket_key, bucket_from, bucket_to; unit (DKK) and polarity (−1), which the chart draws by; volume_effect, price_effect, delta_cp (their sum, digit for digit) and delta_cp_pct (9 decimals, NULL when the comparison's matched cost is not above zero); provisional; matched_hours, hours_in_period, excluded_readings, excluded_price, reason; basis.price, priceSource, basis.matched as K01's |
| Computed by | calc.cost_buckets, unchanged, and the expressions series.k01.sql and cards.sql have today for the three columns the function does not return (delta_cp_pct, provisional, the polarity) |
| Budget | 2 000 000, K01's of today; readings: always |
| The page | A1 asks cost.effects after the cards have answered, and where the two bars will stand it says "Pris- og mængdeeffekt beregnes …" until the answer is there. Refused (too_large_for_grain): the reason's line in the bars' place, "Pris- og mængdeeffekten kan ikke beregnes for så stort et udvalg. Vælg færre målepunkter eller en kortere periode."; the cards and the series of the same request stand |
| The same numbers in a new place | B66's stored fixture is never regenerated. It was written before the cost existed and holds no effect; its test (test_queries_b66.py) goes on comparing every other column value for value, with the two names taken out of its list of columns that are newer than the fixture and cost.effects added to its list of queries that are. B135's first commit is a fixture of its own: the two effects of the K01 row of overview.cards, and of every bucket of overview.months and development.series with K01, for the parameters of B66's list with a comparison, asked before a column is removed. Afterwards cost.effects answers every one of them, value for value, for the same parameters; and the assertions of test_queries_b57.py on the effects (the worked example's +1,00 and −0,60; each bucket's two summing to its delta_cp; the months' adding to the period's) are asked of cost.effects, unchanged in what they assert |
6. The first load
Decision: nothing orders the first load of the facts. The facts follow whatever arrives, by the marks. There is no step for a person and no job to start.
| An existing install (the owner's: a few roots since 2021) | A new install of about 50 points | |
|---|---|---|
| What starts it | The upgrade: the migrations create the tables and triggers, and migrate.upgrade(), finding no version in fact.state, sets it and calls fact.mark_all(): a mark for every stored root-day | The first responses of the Eloverblik backfill: every reading inserted marks its root-day |
| The work | 2 191 root-days a root for six years: about 1.5 s a root [est] (§4.3), newest day first | About 110 000 root-days. A root-day is made again when its factors, its shares or its prices arrive after its readings, at most four more times: about 5 minutes of the lane's work in all [est], spread over the load |
| Beside what | Nothing: the worker's other lanes go on | The backfill in the main loop, newest quarter first (P1 §6); the first loads of Energi Data Service in the declaration lane, one call a minute: the factors and prices of both splits within the first hour, the shares in about half an hour more (MM §8.3), the mix for hours after (it concerns A4 and no fact). The facts lane keeps up with each response: 920 root-days for 10 points and a quarter, under a second [est] |
| How long | Seconds to a minute | As long as the backfill's calls take (docs/operations.md); the facts add no call |
| What the pages show meanwhile | What they show today: every query answers live, inside the budgets the install is inside today | What is loaded, by the rules of today: the frontier, the coverage, the pending shares ("afventer faktor", "har endnu ingen pris"). A request that meets more unmade root-days than its budget admits answers preparing with m of N (§4.4) and is asked again by the page; with the lane keeping up that is a matter of seconds after a response |
| When it is done | make status: no stale root-day. Then make verify | The same |
The demo, the stack check and CI. make demo's last write is the removal of one root's price area after the
load (demo-load in the Makefile [code]), which marks that root's days: **make demo therefore ends by
waiting until fact.status() reports no due mark**, after that statement, and says how many root-days were
made. The stack check (deploy/smoke.py) loads no reading [code]: it has nothing to wait for, and asserts
that the lane started and that fact.status() answers. A test that wants the facts made calls fact.refresh
as the owner of its own database; a test that does not gets the live answer (§3.4, state b).
The way back is the setting, not the release. ELO_FACTS_LIVE=on (§5.1) makes every figure the readings'
again at the next make up. Going back a release does not undo a migration.
7. Delivery
7.1 Rules for every epic
Those of P1 §13.1, P2 §7.1 and MM §8.1: naming, the definition of done, generated data only, sizes S and M, no
call to a service, the tests under TZ=UTC and TZ=America/Los_Angeles, no municipality of a real account.
Further:
- No epic changes a function or a view of
calcthat exists. They are the reference. What is new is in the schemafact. - An epic that gives a query another reader keeps its answers value for value: B66's stored fixture, which
is never regenerated, and every existing test of the query pass unchanged in their assertions. The one
exception is B135's: the two effect columns leave three queries, and the same numbers are held in
cost.effects(§5.6). - Equality is tested at the head only (§3.4): no test of these epics migrates to an older revision. A fixture that an epic writes in its first commit, before it changes a query, is answers of the head it starts from, as B66's is.
- An epic that replaces
ops.remove_accountkeepsSET lock_timeout = '5s'in its text (docs/storage.md). - Every number of this document marked [est] that an epic's row names is measured by that epic and stands in its report, with what it replaces.
- Documents: a new page,
docs/facts.md(B130 starts it, each later epic adds its part);docs/storage.md(every epic with a migration);docs/daily-run.mdanddocs/operations.md(B130 for the setting, B132);docs/queries.md(B134, B135, B136);docs/pages.md(B134, B135);docs/adr/ADR-004-scale-at-500.md(B137).
7.2 The epics
| Epic | Scope | Acceptance criteria | The lead's validation | Depends on | Owns | Size | Agent · model · effort | Review |
|---|---|---|---|---|---|---|---|---|
| B130 The tables, the marks, the version | §2.2, §2.3 (the tables, their checks, version), §4.1, §4.2 (fact.stale, fact.state, every trigger per event with its transition table, fact.arm_partition, fact.mark_all, fact.version() and its comparison in migrate.upgrade()), §4.3 (the removal's lock and order), §4.5 (the removal, its statistics, the grants), §5.1 (the setting's path into fact.state.live) | On the demo organisation, for each of the twenty rows of §4.2's list of writers, by the writer's real path: the root-days named are marked, and no other; a withdrawn day is marked though no reading of it is left, a point given a parent is marked for every day it has a fact of, a moved series for both roots; a daily run in which every day is confirmed and a re-pull that changes no value mark nothing; a price for a day without a reading marks nothing and the reading that comes marks it; the four cases of §4.2's measurement as tests: (a) an INSERT of three readings over two partitions, a COPY into the parent and a DELETE through the parent each mark their root-days, once; (b) every partition carries the three triggers (the list of pg_inherits); (c) an INSERT and a DELETE that name a partition mark, and with that partition's triggers dropped the same test fails; (d) a partition made in the test and armed marks by both ways, and one made without fact.arm_partition fails the partitions' test while a write through the parent still marks; no source file and no function's text names a partition of ts.reading; a TRUNCATE of an input marks every root-day; a renewed mark has attempts 0; a changed share marks no row that holds a municipality's code (the search of MM §8.1 with ZZ8, ZZ9); the catalogue's test of §4.2, and with each trigger dropped its marks' test fails; migrate.upgrade() run twice marks once, and marks every root-day after a function of calc is replaced with another body and after fact.state.time_zone is changed by hand; ELO_FACTS_LIVE set in the shell, in .env.local and in both (the shell wins) installs that value, and another word than on or off refuses the start; after make account-remove no row of the three tables refers to the account, each is named once in the answer, each of the three mutations fails a test, and with a session holding elo.facts the removal refuses with the sentence of §4.3 and changes nothing; B75's walk passes with the tables named; the grants' matrix (test_storage.py) holds §4.5's row. The report gives the seconds the triggers add to the statements §4.2 names (the bulk loader's largest, the COPY of the factors, a window of factors and of shares at 420 roots, and the mix loader's, which must be unchanged) | – | – (after the release's epic that holds migrate.py, where one runs: §7.3) | The schema fact (tables, triggers, arm_partition, mark_all, version), ops.remove_account and ops.removal_statistics (replaced); elo_api/db/migrate.py, deploy/compose.yaml, elo_devtools/doctor.py, elo_devtools/account_remove.py and tools/tests/b75_mutations.py while it runs; migrations 0430–0439 | M | Claude · Opus · high | Codex x |
| B131 The maker | §2.5 (fact.make_day, fact.make_emission_day, fact.cells), §4.3 (fact.refresh with its failure by root-day, fact.status()), §4.5 (fact.verify); §3.1 | On the named cases (loaded by query_harness.arrange, with their day summaries) and the demo organisation, at the head: the maker's rows summed by bucket equal every total column of calc.emission_buckets and calc.cost_buckets asked with cmp=none, by value and scale, for every available method, both bases, both GWP sets, by day, month and period (§2.3's table of columns, row by row, with its three rules of NULL and zero); asked for one method the maker returns that method's rows alone, and without the cost it reads no price (the plan); every status of §2.3 occurs in a case, the cells of a day's rows of one method are disjoint and their union is s_cells; days of 23, 24 and 25 hours set 23, 24 and 25 bits, the repeated hour bit 24; an hour of A02 alone is in s_cells and not in q_cells, an hour of three quarters in q_cells and not in c_cells; fact.cells summed over a day equals the day's rows, and its two generated flags are those of the cell's own factor and price; the walk of the writers of §4.2, both halves; a mark renewed while a batch ran is still there (a test with two sessions); a root-day whose making raises keeps its mark with attempts 1, failed_at and the SQLSTATE, the others of its batch are made, it is not due again within the hour and is due at once when its mark is renewed; fact.status() counts it as failed and not as due; fact.verify passes, and fails naming mp_id, day and table after one stored value is changed by hand. The report gives the milliseconds a root-day at 50 and at 420 roots of the bulk organisation, hourly and quarter-hourly, and the time of fact.mark_all() with its refresh | – | B130 | New files only: the functions of the schema fact named here, docs/facts.md; deploy/sql/verify.sql while it runs; migrations 0440–0449 | M | Claude · Opus · high | Codex x |
| B132 The facts lane | §4.3 (the lane, its check by due marks, the job's lock and its batches in transactions of their own, the demo), §4.5 (make status), §6 | Against a real stack on the demo source: make demo ends, after its last write, with no due mark and no call made; a worker killed in the middle of a batch leaves that batch's marks and rows as they were, holds no elo.facts afterwards, and the next run makes them; with one root-day that fails and nothing else due, no facts-refresh job is queued for an hour (the job table's rows counted over ten polls); a job of the declaration lane asleep in its wait does not delay a facts-refresh; a removal begun while a run holds the lock is refused, and a run begun during a removal waits for it; the marks are worked newest day first; a run ends after 60 s with its successor queued; make status shows the stored, the stale and the failed root-days with their words, the version, and its first line of the facts when ELO_FACTS_LIVE is on, and warns for a mark that is not failed and older than a day; make verify runs fact.verify; a load of the demo organisation by the backfill job alone (B71's path) ends with every fact made | The upgrade on the owner's stack: make status shows the marks fall to none, then make verify passes; the time recorded, no figure | B131 (after B95 and B98 in its lane, and the release's epics that hold the same files: §7.3) | The worker's __main__.py, schedule.py, status.py, a job module, the demo load, deploy/smoke.py, the Makefile, while it runs; docs/daily-run.md, docs/operations.md | M | Claude · Sonnet · high | Codex high |
| B133 The readers I: the pairs, the emission, the consumption | §2.4, §5.2: fact.emission_buckets, fact.emission_reason_hours, fact.consumption_matched, fact.live_rows; §5.1 in the readers | The equality test of §3.4 for the three readers against calc.emission_buckets, calc.emission_reason_hours and calc.consumption_matched (per root and whole), in the four states of the facts; the worked example of §2.7 in its three variants, with the readings read counted: 47, 0 and 0; a 23-hour day against a day of 24 hours is a partial pair and 29 February under py has no pair; a partial pair whose one unmatched hour has a generated factor answers generated_factors false, as the function does (A6v-exact-01's rows); a bucket with stored hours and none pending answers pending_hours 0, one with no stored hour NULL, and an hour of A02 alone without a factor pending_minutes NULL; a period of 0,000 kWh without a price area answers p_all_without_area false; a period of 0,000 kWh under a municipal method answers the function's reason and reads no reading (the plan); a row of another version is not read; a root that misses an hour every day is read from the readings whole and its answer is the function's; fact.live_rows returns the rows the readers then read (asserted on the plans' counts), a day on both sides of an overlapping py twice, and m and N; with every root-day made, a year of every root of the demo with its previous year by month takes under a fifth of the function's time, and with every root-day stale no more than 1,2 times it | – | B131 | New files only: the three readers and fact.live_rows, their test, docs/facts.md; migrations 0455–0464 | M | Claude · Opus · high | Codex x |
| B134 The overview on the facts | §5.3 for overview.cards (E01's like-for-like, G01, G16, the reason's hours), overview.months G01 with the runner's _emission_basis, overview.mp_variance, factor_status.sql; §5.4 (budget.sql, the second number); §4.4 (preparing in the runner; the shell's sentence with m of N and its asking again) | Through HTTP on the demo organisation: every answer of the three queries equals B66's fixture, and every existing test of them passes unchanged in its assertions, with the facts made, with every root-day stale, and with ELO_FACTS_LIVE on; with a budget set one row below a request's live rows the answer is preparing with m and N when making its stale days would bring it inside, too_large_for_grain when it would not (a root full of gaps; a failed day alone never gives preparing), and ok at that number; with every day of a request stale the budget's count is at least what budget.sql counts for it today (the cards: three times it), for a period of two years with py too; a request above the second number is too_large_for_grain; the auto-explain of a default view with the facts made, under each of the three methods, shows no scan of a reading partition but for the partial pairs' days, a period of 0,000 kWh included; Playwright: a page whose query answers preparing shows the sentence with its two numbers, asks again while m rises, shows the figures when the facts are made, and after five minutes without a rise shows the second sentence with its control | The owner's stack shows the overview; the lead records the cards' seconds before and after, no figure | B132, B133 (after B88 in the named queries' lane; after B90 or before it in the shell's: §7.3) | The catalogue, runner.py, budget.sql; queries/overview/, queries/providers/; web/packages/shell, the app's src/shared/ and the pages' use of the query's state, while it runs; migrations 0470–0472 only if the catalogue needs one | M | Claude · Sonnet · high | Codex high |
| B135 The readers II: the cost, and the effects' query | §5.2 (fact.cost_buckets), §5.3 for the cards' K01 and K03, overview.months K01 and KNET's K01 leg, price_status.sql; §5.6 (cost.effects; A1 asking it after the cards) | Its first commit is the fixture of §5.6: the effects of the three queries for B66's parameters, before a column is removed. The equality test of §3.4 for fact.cost_buckets against every column of calc.cost_buckets but the two effects, in the four states; an hour read hourly after the seam with three quarter prices is outside p_cells and counted in excluded_price; a priced quarter of an hour whose fourth has no price keeps its cost in the day's total; a partial pair whose unmatched hour has a generated price answers generated_prices false. Through HTTP: the cards' and the months' cost answers equal their answers before, value for value, but for the two columns, which are gone from the three queries' catalogue entries; test_queries_b66.py passes with the two names out of its newer columns and cost.effects among its newer queries, its fixture file untouched (the file's hash asserted); cost.effects answers every row of the first commit's fixture value for value, each pair summing to its delta_cp, which equals the reader's; the effect assertions of test_queries_b57.py hold of cost.effects; cmp=none is unavailable, no_comparison; above its budget it is too_large_for_grain while the cards of the same request answer; the same with ELO_FACTS_LIVE on. Vitest and Playwright (b61.test.tsx, e2e/b61.spec.ts, moved to the new query): A1 with K01 and a comparison asks cost.effects after the cards, shows "Pris- og mængdeeffekt beregnes …" meanwhile, draws the two bars and their sum from it, and the reason's line when it is refused | – | B134 | fact.cost_buckets and its test; the catalogue, runner.py, budget.sql, queries/overview/, queries/development/series.k01.sql, queries/providers/, a new queries/cost/; tests/test_queries_b57.py and the two lists of tests/test_queries_b66.py; the A1 directory's Development.tsx and Effects.tsx, src/shared/data.ts, src/shared/b61.test.tsx, e2e/b61.spec.ts; migrations 0465–0469 | M | Claude · Opus · high | Codex x |
| B136 A1 on the facts | §5.3: development.series G01 (with the reason's hours), K01 and KNET's K01 leg; energy.split's bought row; §5.5 (what the split's budget counts) | Through HTTP on the demo organisation: every answer of development.series (by day and by month) and of energy.split equals B66's fixture and B68's tests, facts made, stale, and with ELO_FACTS_LIVE on; energy.split for a year of every root with its previous year, the facts made, reads no reading of a root but for the partial pairs (the plan), and its budget counts the export children's rows and the bought row's live rows for each of its two readers: with every day stale it is refused or preparing wherever it is refused today | – | B135 | The catalogue, budget.sql; queries/development/, queries/energy/; migrations 0475–0479 only if needed | S | Claude · Sonnet · high | Codex high |
| B137 The measurement afterwards | ADR-004's method (§3, §7, §8) and B97's machine, on the bulk organisation with every fact made: the default views of X1, A1, A4 and D1 at 50, 100 and 420 roots under the three methods; the same with the newest 14 days of every root stale, and at 50 roots with ELO_FACTS_LIVE on; the rate of the live rows; the size of the two tables; a day's marks and the lane's time for them | docs/adr/ADR-004-scale-at-500.md gains "As built (B130 to B136)" with the table of its §1 at the three sizes and the target of §7.3 met or not, per query and method; the run files are under docs/adr/ADR-004/; a second run repeats within a tenth; the report proposes each query's budget by docs/queries.md's rule from the measured rate, and the table of §5.5 as measured: what is refused at 100 and at 420. No product code | The lead sets the budgets, and writes the README's sentence about scale (ADR §9, item 3), or says why not yet | B136 (B135 for a first run) | New files only: the run files, the ADR's section, the report | S | Claude · Sonnet · high | The lead |
Where Codex's limit is reached, its review falls to Claude or Agy (the lead's standing rule); nothing waits.
7.3 Lanes, order, and the first delivery
A shared file has one holder at a time (P2 §7.3). The lanes of these epics are also other epics' today
(A6v-readers-04); the lead starts an epic when the one before it in its lane has merged.
| Lane | Shared files | These epics | Who else holds them [code: orchestration/ROSTER.md] |
|---|---|---|---|
| The settings' path, the removal | migrate.py, deploy/compose.yaml, elo_devtools/doctor.py, ops.remove_account, account_remove.py, b75_mutations.py | B130 | The release's epics of the packaging specification (the worker's state and the one-worker lock; update and backup, which checks the migrations; the removal as a job): B130 and each of them one after the other, never beside |
| The worker and the tools | __main__.py, schedule.py, status.py, the demo load, deploy/smoke.py, the Makefile, docs/operations.md | B132 | B95 and B98 (status.py, schedule.py), unmerged today: before B132. The release's command in the worker's image, which takes over status, doctor and the Makefile's targets: before or after B132, never beside |
| The named queries | The catalogue, runner.py, budget.sql | B134 → B135 → B136 | B88 (the municipal sources in the queries): before B134 |
| The web app | web/packages/shell, src/shared/, the A1 directory | B134 (the shell), B135 (A1) | B90 (A4 under the split: "the shell's switch"), which starts when B88 has merged, as B134 may: one of the two first, the lead's choice, never both |
| Nothing shared | – | B131, B133 | They own new files only and run beside anything; B87 and B89 share no file with any epic here |
The packaging specification is not on this branch: its epics are named here from the roster, and **their "Owns" are to be read against this table when it merges**; where they differ, that specification's column decides and the lead orders. The migration blocks say who owns a number, not an order (MM §8.3).
**The smallest first delivery that makes the overview of about 50 roots answer in a second or two: B130, B131, B132, B133, B134, B135**, in that order, with B132 beside B133.
| After | What an install of 50 roots sees |
|---|---|
| B134 | The overview's consumption and emission figures come from the facts. The cards still wait for the cost's read of both periods, about 5 s, and overview.months K01 takes its 5.2 s [B97]. Under LB-MU-125 the cards answer, where today they are refused |
| B135 | Every query of the overview reads facts: the target below |
| B136 | A1's series likewise, and energy.split answers again at 50 roots with a comparison |
The target, and where it is measured. On the generator's organisation (elo_devtools.synth.bulk) of 50
roots with every fact made, every query the overview asks (a year to date, all roots, cmp=py:
overview.cards, overview.months for E01, G01 and K01, overview.mp_variance) answers within 1,0 s
under each of the three methods, and the page's last figure stands within 2,0 s of its first request;
at 100 roots within 2,0 s and 3,0 s; with the newest 14 days of every root stale, within twice those. Seconds as
ADR §3 has them: through HTTP as elo_api, warm, the median of five, by python -m elo_devtools.scale, in a
virtual machine of its own as B97's brief has it. B137 measures it; B135's worker reports a first run at 50
roots on its own stack.
What each epic costs. Six epics of size M and two of size S; four on Opus (the storage, the maker and the two readers, where an error is a wrong figure or a stale one) and four on Sonnet. The first delivery is the six of size M.
7.4 What B97's numbers decide
The design does not wait for them: the facts are owed before an account of more than 70 points is loaded (ADR §9, as built), whatever a quiet machine says of 50. The order does.
The first numbers [B97], the overview's default view at 50 roots:
| Query | LB-PA-125 | LB-MU-125 |
|---|---|---|
overview.cards | 24.6 s | refused, too_large_for_grain: 1 064 064 rows over 1 000 000 (the cards' 1 200 000 times the municipal factor 0,90, rounded down) |
overview.months E01 | 0.08 s | – |
overview.months G01 | 12.8 s | 14.9 s |
overview.months K01 | 5.2 s | 5.2 s |
| The page | 25.0 s: the cards decide; the month queries run beside them without slowing them | No cards |
What they settle:
| Number | Settles |
|---|---|
| The cards at 25 s, and refused under the municipal method | The first delivery (§7.3) is what makes the overview answer at 50 roots under all three methods, and it is needed for the first company install, not only beyond 70 points. With the facts made the cards read about 30 000 rows (§5.4): no method's budget refuses them |
| K01 at 5.2 s (this document had estimated 3 s) | The cost is no afterthought: without B135 the page waits about 5 s. B135 goes before B136, the order of §7.3 |
| G01 at 12.8 s for 1 064 064 rows: 12 µs a row | ADR §5's rate (12.7 µs) holds on a machine of its own, so the estimates of §4.3 made from it stand until B131 measures |
| The month queries do not slow the cards | The page's wait is its slowest query: the target's two numbers (1,0 s a query, 2,0 s the page) stand |
What the numbers still to come decide:
| B97's number | Decides |
|---|---|
overview.mp_variance at 50 | Nothing: fact.consumption_matched is B133's in any case. ADR-004's own run at 50 roots has it at 9.70 s for 1 064 064 rows (docs/adr/ADR-004/2026-11-23-8bf435f-50-roots.md), on the shared machine; B97 has not measured it again |
| The municipal join's part of the time | Nothing in the order (the municipal method's facts are B131's with the others) |
development.series G01 and energy.split at 50 (the split is refused from about 47 roots with py) | Whether B136 follows B135 at once (the default) or waits for the owner's word after seeing the overview |
mix.structure and mix.series at 50, 70 and 100 | The mix's budget, by docs/queries.md's rule from the measured rate: no fact (§3.3). Above 10 s at 50 roots, or a customer above what a budget admits: §8, point 2 |
| The heat map's G01 and K01 at 50 to 100 | The same |
| What a rewrite with the same answer would gain without a fact (B97's item 4) | If it brings the cards at 50 roots under 2 s by itself, the lead may ship it first. The facts are still built |
7.5 Exit
Of the first delivery (B130 to B135): at 50 roots of the generator's organisation, with every fact made,
every query the overview asks (overview.cards, overview.months for E01, G01 and K01,
overview.mp_variance) answers under each of the three methods (LB-PA-125, LB-PA-200, LB-MU-125)
within the target of §7.3, none refused; and with ELO_FACTS_LIVE on, each answers what it answered with it
off, or is refused where it is refused today.
Of the whole:
- B137's run files show the target of §7.3 met at 50 and 100 roots, and the overview's default view answered at
420, under the three methods.
2. The equality test passes at the head in the four states of the facts, the walk of the writers passes, and
every query that changed its reader equals B66's fixture.
3. On the owner's stack, after the upgrade:
make statusshows no stale root-day andmake verifypasses; the lead records the outcome, no figure. 4. An account removed leaves no fact and no mark, and the mutation tests say so. 5. ADR-004 has its "As built", and the lead has set the budgets from B137's rates.
8. For the lead
Ruled on 26 November (orchestration/tasks/a6f-fixes.md), and built into the text:
| Point of version 1.0 | Ruling | Where |
|---|---|---|
| The cost's two effects as a query of their own | Yes. B66's stored fixture is never regenerated; the same numbers are held in the new place; the page asks them after the cards and says so | §5.6, B135 |
The state preparing | Yes, bounded: only while the making of the facts has not reached the selection's days, with m of N; never behind a day that cannot be made, which is computed live for ever and said in make status | §4.3, §4.4 |
| The mix, the heat map's emission and cost, and the effects by budgets only beyond about 94 roots | Yes, for the first delivery; what is refused at 100 and at 500 is said | §5.5 |
| "No switch back to the functions" | No: one setting of the install, ELO_FACTS_LIVE, makes every reader compute live | §5.1 |
Still open, or to be known:
The partitions' triggers: measured, and decided (§4.2). The lead tried the four cases in PostgreSQL 18.7: a statement trigger with a transition table is taken on the parent and on a partition; the parent's fires for every write through the parent and for none that names a partition. Every one of the twenty writers writes through the parent, the removal included, so the parent's triggers mark all there is; the partitions carry the same triggers for a write that names one, made by
fact.arm_partitionand held by the test that drops one. What is left, and is nobody's today: a partition dropped or detached fires no trigger; the job that first does so (retention, P1 §1.4's housekeeping) marks in its own transaction, and its specification says so. 2. What this document does not hold beyond the budgets (§5.5): the mix, the heat map's G01 and K01, andcost.effects. Named, not specified: for each, a higher budget once B97 and B137 give its rate (the mix costs less a row than the emission did); for the heat map, ADR §6's fact per root, weekday, clock hour and month, which is exact (a root's mean is one division of a stored sum by a stored count); for the mix, nothing exact exists below the root and hour (§3.3), so beyond a budget it needs a specification of its own, and the first question there is whether the selection's hours may be stored for the selections that do not change (every root; a company). 3. The simple choices, and what each costs at 5 000 points (P1 §1.4's form):Choice Cost at 5 000 points Revisit with A mark per root-day, also for a change that is a price area's One window of factors marks 605 000 rows in the loader's transaction A mark by price area and day, resolved by the job Facts for every available method, asked for or not Three times the emission's rows: about 33 million Facts for the methods an install has asked The day as the only grain A year with its previous year is 3.65 million root-days: refused by §5.4's second number Month facts beside, for whole months Every root-day made again when any function of calcchanges, or the time zone's rulesAbout 2 hours of the lane [est] after such an upgrade A hash per function the maker reaches A row counted once for each reader that reads it live The cards of a stale period are admitted at a third of the roots a shared read would admit One making of a request's stale days, shared by its readers Numbers and lanes. Epics B130 to B137 and migrations 0430 to 0479 assume that the packaging specification holds B100 to B120 and 0400 to 0429, as the brief says of the migrations. That specification is not on this branch: §7.3's table of lanes names its epics from the roster and is to be read against its "Owns" when it merges. 5.
LB-MU-200. Its facts come with theUPDATEthat makes it available (§2.1), at the cost of one row of §4.3's table (every stored day). Nothing else of this document changes with it. 6. B97. Its first numbers are in §7.4 and stand; its full matrices were not in. Every [est] of this document is an extrapolation from ADR-004's rates on a shared machine; §7.4 says what each number still to come moves, and none moves the design.
9. The sentences that change
| Where | Today | Becomes |
|---|---|---|
| P1 §1.4, the rows "No stored emission facts, no aggregates beyond the day summary, no dirty queue" and "Like-for-like comparison computed per hour in the query" | "Phase 2 revisits with: B22: the stored day and month facts of solution.md §2.7–2.8"; "A stored matched measure, or a day-level definition" | Revisited by stored-facts.md: day facts per root, method and status, marks by trigger, and masks for the like-for-like measure; no stored matched sum and no day-level rule |
| P1 §9.1 | "phase 1 stores no emission fact and no aggregate beyond the day summary" | Stands for the functions, which stay. Beside them the day facts of stored-facts.md are stored; every figure read from them equals the function's, and a day whose inputs changed is computed from the readings |
P1 §10.2, state | ok, empty, unavailable, too_large_for_grain | Also preparing, reason facts_behind, with basis.facts (§4.4) |
| P1 §10.3, "Row budget" | "a query's reading rows are estimated as Σ over its series of days × points a day" | For a query that reads the facts: the reading rows of the root-days it reads live; and a second number for its root-days (§5.4) |
P2 §4, overview.cards; overview.months, development.series | "for K01 volume_effect and price_effect"; "for K01 the two effects per bucket" | The effects are cost.effects' (§5.6) |
| P2 §5.2, "The price effect and the volume effect" | Two variance bars from the measure's query | From cost.effects |
| P2 §6.5, first row | "Stored facts for what ADR-004 names … named, not specified" | Specified: stored-facts.md. No fact of the sources |
S §2.7 (calc.run, calc.dirty, calc.emission_day, calc.emission_month, calc.mix_month, calc.cost_day, calc.cost_month), S §2.8 (agg.*) | The fact tables and pre-aggregates of the first design | For the hourly location-based methods and the spot cost: fact.day, fact.emission_day, fact.stale of this document. The rest is not built |
| MM §1, "Not built: stored emission or mix facts" | "P2 ruling 5 and ADR-004 are not reopened" | The municipal method's emission is in the facts as every available method's; the sources are not stored under either split |
docs/queries.md, "Grain and budget" and "Cost in the queries"; docs/emission.md and docs/cost.md, "Nothing is stored" | – | Brought up to date by B134 and B135; "calc holds views and functions only" stays true |
docs/operations.md, the settings | – | Gains ELO_FACTS_LIVE (§5.1), by B130 |
| ADR-004 §9 | The decision's item 2 | Gains "As built (B130 to B136)" by B137; the decision's text is not changed |
The static read A6v: what was done
Three static reads of version 1.0 by a third model family (reviews/build/A6-agy-exact.md, A6-agy-fresh.md,
A6-agy-readers.md, committed with this round) confirmed the core as exact (the unrounded sums and their
scales, the day boundaries and the clock-change days, the linearity of the gases under each GWP set, the keys,
the masks' logic) and made fourteen findings, three of them blockers, all on freshness. All fourteen are
accepted in substance, with the lead's rulings (orchestration/tasks/a6f-fixes.md). Nothing was built or run
for this round either; what the reads say of the code was read again where the text now rests on it (the
removal's order of locks, recoverage.run_lock, the writers of each input, migrate.py's entry points), and
not otherwise re-verified.
| Finding | What changed | Where |
|---|---|---|
A6v-fresh-01 (blocker): a withdrawn day, a demoted point, a moved or deleted series were not marked | The invariant is turned round: a day is marked by every write that can change it, whether a fact exists or not, and by every write that removes what it was made from. The triggers are on the readings themselves (ts.reading and its partitions), not on the day summary; "every day of a root" includes the days it has a fact of. A table of the twenty writers of the repository against the days each marks; the walk of the writers; the catalogue's test, which a new table fails until it is placed | §4.1, §4.2; §2.2; B130, B131 |
A6v-fresh-02 (blocker): the lock between the lane and the removal was dropped between batches | The job holds elo.facts as a session lock on a connection of its own for the whole run, as the share's jobs hold theirs; every batch is a transaction of its own inside it; fact.refresh takes no advisory lock. The removal tries it fifth, after elo.ingest, the jobs' rows and the share's lock, before the rows; its refusal has a sentence, and account_remove.py is B130's | §4.3; B130, B132 |
A6v-fresh-03 (blocker): a failed day was tried every five seconds, and nothing could record its failure | The mark carries attempts, failed_at and the SQLSTATE, written inside fact.refresh (the owner's) when a root-day made alone raises, and cleared by any renewal; "due" is a due mark (the parked chunk's ladder), not a table that holds a row; the worker executes fact.refresh and fact.status() and has no right on a table of fact | §4.1, §4.3, §4.5; B131, B132 |
A6v-fresh-04 (major): preparing behind a failed mark or a long rebuild; make demo and the stack check | preparing only when making the request's stale days that are not failed would bring it inside its budget, with m of N; otherwise too_large_for_grain. A failed day is computed live for as long as it fails and never gives preparing. The shell asks again while m rises and stops after five minutes without a rise, with a control. make demo waits after its last write; the stack check loads no reading and waits for nothing. The estimates at 500 roots also for a seventh of quarter-hourly roots (18 min); B134 owns the pages' use of the state | §4.3, §4.4, §6; B132, B134 |
A6v-fresh-05 (major): bulk writers, new versions, the columns that count; the partitions (A6f2) | One statement trigger per event with a transition table on every input; the columns per table as they are (price.spot and the share have no version; resolution counts); a version that came, went or was closed marks the root; ref.method also on insert and delete; the cost of the triggers measured in B130 on the bulk loader's largest statements, a loader's windows and the mix loader's, which carries none; the partitions armed by one function, with a test; the cases loaded with their day summaries | §4.2, §3.4; B130, B131 |
A6v-fresh-06 (minor): the server's time zone rules; migrate's entry points | The facts carry the version they were made under; the version is a hash of the definitions and of the time zone's day lengths; it is compared in migrate.upgrade() and at the start of every run of fact.refresh; another version marks everything, at the cost of the first load again (1.5 min at 50 roots, 13 to 18 at 500) | §4.1, §4.2, §6; B130 |
A6v-exact-01 (major): the cells lacked the generated flags a partial pair needs | fact.cells returns the cell's own factor_generated and price_generated; a whole pair takes the days' flags, a partial pair the cells' over the matched cells, an empty pair none. K′ is taken as the functions take it (calc.expected_minutes) | §2.4, §2.5; B131, B133, B135 |
A6v-exact-02 (major): pending_hours NULL where the function gives 0; quantity_minutes | pending_hours is 0 for a side's bucket that has a stored interval and none pending, NULL only for one with none; quantity_minutes is NULL when no interval of the row has a quantity, quantity_hours 0 | §2.3; B131, B133 |
A6v-exact-03 (minor): p_all_without_area without its predicate | A row of its own: the emission's is p_kwh > 0 AND coalesce(p_no_price_area_kwh, 0) = p_kwh, the cost's is by the counts of intervals; the two differ on 0,000 kWh, as the functions do. The mapping also names local_share, provisional and the hours of each cause | §2.3, §3.2 |
A6v-readers-01 (major): the reason of a municipal figure with no energy still read every reading | A fourth reader, fact.emission_reason_hours, from the hours of each status; the cards, G01's two queries and the runner call it; factor_status.sql as D1's basis is said | §5.2, §5.3; B133, B134, B136 |
A6v-readers-02 (major): the budget afterwards admitted what it should refuse | The budget counts every row read live, each side of a comparison for itself and once for each reader that reads it, so a period of marked days as large as today's refusal is still refused; a reader makes a stale day for the method asked alone, and without the cost where it has no use for it; the split's budget counts the bought row's live rows beside the export children's | §2.5, §5.4, §5.5; B133, B134, B136 |
A6v-readers-03 (major): the effects' contract: the fixture, the tests, the web's readers, the columns, cmp=none | B66's fixture is never regenerated and held no effect: B135's first commit is a fixture of the effects, which cost.effects then answers value for value; test_queries_b57.py's effect assertions are asked of the new query; cost.effects returns what Effects.tsx reads (delta_cp_pct, provisional, the polarity, the buckets' days); cmp=none is unavailable, no_comparison; Development.tsx, b61.test.tsx and e2e/b61.spec.ts are B135's; the page asks after the cards and says so | §5.6, §7.1; B135 |
A6v-readers-04 (major): lanes and epics that were not named | The table of lanes names who else holds each file: B88 and B90, B95 and B98, the release's epics; the packaging specification's "Owns" are to be read against it when it merges. The first delivery's exit is restated: every query the overview asks, under the three methods, at 50 roots. overview.mp_variance at 50 roots: ADR-004's own run has it | §7.2, §7.3, §7.4, §7.5 |
A6v-readers-05 (minor): "no switch back" | Reversed by the lead: ELO_FACTS_LIVE, on the settings' path, makes every reader compute live for every day; forced days are not stale, so nothing answers preparing; make status says when it is on; a test that every query answers the same with it on and off; why going back a release is no way back | §5.1, §4.4, §4.5, §6; B130, B132 to B136 |
A6f2 (version 1.2). Version 1.1 left one point as unverified: whether PostgreSQL 18 takes a statement
trigger with a transition table on a partition. The lead measured it (§4.2, [LM]: four cases) and it does.
§4.2 and §8 are written on those facts: the parent's triggers mark for every writer, each of the twenty rows
having been checked for the relation it names; the partitions carry the triggers too; B130's criteria gain the
four cases as tests. One statement of version 1.1 was wrong and is withdrawn: the removal does not delete
"partition by partition", it deletes through the parent and names the partitions in its answer. Added on the
way: a TRUNCATE of an input marks everything, and a dropped or detached partition is named as what no
trigger sees.
Kilde: docs/architecture/stored-facts.md i løsningens
repository.