Take the current day as a load of the kind intraday in the one transform
Context and Problem Statement
ADR-0038 ("The current day") takes the current day of each account in a short cycle, at the level of campaigns, with is_partial_day on the row, every 3 hours by default. It builds the cycle as "a separate light DAG" with "its own table in L0" that "runs dbt build --select tag:intraday", and says that "both cycles write one fact, so both go through an Airflow pool of one slot, where they queue and do not collide". ADR-0046 has staging read, for each account and day, "the load with the largest _dlt_load_id".
Neither sentence holds against the code of November 2026:
- A pool serializes tasks, not runs. The transform runs in
ExecutionMode.LOCALwithTestBehavior.BUILD, one task of dbt for each node, in the pooldbtof two slots (airflow/dags/agoranomos_demo_transform.py), and the maintainer decided on 12 November 2026 that the watcher mode of ADR-0039 waits for the measurements of the long-running stand (#203). A run fills the tablesstaging.stg_loads__newest_days,staging.int_window_daysandstaging.int_g1_failuresonce, and its later tasks read them. A light build that queued in the same pool would rebuild them between two tasks of a daily run, which would then write its facts from the days of the light one. - A light run cannot accept by itself. The pin, the acceptance and the cleanup are tasks of the DAG of the transform, outside dbt. The acceptance marks as accepted every pinned row of
core.loadsup to the newestpinned_atthat the run read, of any source and any DAG (ACCEPTinairflow/dags/agoranomos_pipelines/acceptance.py). A light run that pinned and accepted would accept the daily loads that it never wrote, and the cleanup would delete their rows from L0. A separate path would need a pin, days, checks and an acceptance of its own, and every staging model of the facts joinsstg_loads__newest_days, so the fork would reach all of staging. The watcher mode does not change this: the pin and the acceptance stay outside the producer. - The largest load ID can lose a whole day. A read of the current day that started before midnight in the account and reached dlt after the daily load had begun would get the larger
_dlt_load_id, and replace the whole day with a partial one.
The design of the code has one transform DAG with max_active_runs = 1, which already keeps any two runs of the transform apart, and pins, reads, accepts and cleans every load in one way. How does the short cycle enter it, how does a partial day stay below a whole one, and what must leave it out?
Decision Drivers
- One run of the transform reads one set of loads and accepts only what it read (ADR-0046).
- A partial day never replaces a whole one, and its replacement by a whole one is no restatement (ADR-0038).
- A stop of any length still closes by itself: the watermark counts whole days only.
- The checks and the tests of the transform, and the rates of the day, apply to today as to any day (ADR-0035).
- It works in the local mode of today, and in the watcher mode without a change.
- No new service, so the memory budgets of ADR-0022 and ADR-0048 stay.
Considered Options
- A load of the kind
intradayinto the raw tables of its source, which the one transform takes like any load - A separate light DAG with its own table in L0 and a pool of one slot for dbt, as ADR-0038 says
- The same light DAG after the watcher mode, with a pin and an acceptance of its own
- A
dbt run-operationthat writes the current day into the fact outside the models
Decision Outcome
Chosen option: "A load of the kind intraday", because it adds no second path through the pin, the acceptance and the cleanup: the rules of ADR-0046 stay one, max_active_runs = 1 of the transform keeps the two cycles apart in the local mode and in the watcher mode, and every check and test of a run applies to today. What it costs is a full run of the transform for each cycle, which the consequences count.
In practice this means:
- A load of a new kind. A load of the short cycle has the kind
intradayin the journal_agoranomos_loadsof its source and incore.loads, besidewindowandhistory. It writes into the same raw tables, under its own_dlt_load_id, with the window of one day, the current day of each account in its time zone at the moment of the read. It brings impressions, clicks and cost of the campaigns only: no lists of entities, no totals of the account, no ad groups, ads or conversions by action. Its conversions are none (NULL), not zero, as Google dates them by click and adds them later. A DAG of its own updates an asset of its own in the conditionLOADEDof the transform (airflow/dags/agoranomos_pipelines/assets.py), so that the transform starts after it and the watermark of the asset of the daily load stays the daily one's. The transform pins, reads, accepts and cleans it like any load, and a load that ends during a run waits for the next one, as ADR-0046 has it. - A whole day beats a partial one. For each account and day, staging takes the newest load of the kinds
windowandhistorythat covers the day, and a load of the kindintradayonly for a day that no such load covers, whatever their load IDs. Among the loads of one rank, the largest load ID wins, as before. The rule holds against an accepted whole load too: the bound of ADR-0046 on the accepted loads, those newer than the oldest pinned load of the account (#191), counts for the loads of one rank, and an accepted whole load that covers a day of a pinned intraday load keeps the day, which is then not read. The rule goes intopinned_loadsofdbt/macros/newest_load.sql, and the pin copies the kind from the journal intocore.loads(dbt/macros/pin_loads.sql, whoseCASEturns every kind buthistoryintowindowtoday). is_partial_day. A migration adds the columnis_partial_day boolean NOT NULL DEFAULT falsetocore.ad_stats_campaign_daily, and widens the CHECK ofcore.loads.kindtointraday, as the core changes by addition (ADR-0044). The fact writes it from the kind of the load of the day. A day of an intraday load is a day of the fact of campaigns only, so no other fact gets a partial row, and no other fact reads the day as an empty day and deletes it (fact_daysandfact_empty_daysindbt/macros/facts.sql). A whole load replaces a partial day within the whole-day writes of ADR-0038:delete+insertby account and day deletes the partial rows with the day, and inserts the whole ones withis_partial_day = false. The freeze of ADR-0035 is never involved, as the current day lies in the newest month. The view of campaigns carries the column as the service column of ADR-0037.- What leaves intraday loads out.
- The journal of restatements of ADR-0036 skips an old row with
is_partial_day, so the replacement of a partial day is no restatement. - G1a of ADR-0035 skips intraday loads and leaves partial rows out of what the core holds: a partial day is below the day that it becomes, so the check would hold an account on the first cycle of each day, and with it every load that the account has pinned, its daily window included.
- The lists of entities:
newest_listsleaves intraday loads out, as they take no lists. A run that held only intraday loads would otherwise read empty lists and mark every campaign as no longer listed. - Every watermark: each reader of
window_tooras_ofin the journals and incore.loadsleaves the kindintradayout. These areaccepted(),last_day(),known_windows()andplan()ofairflow/dags/agoranomos_pipelines/google_ads.py,recorded()ofloads.py, which the demo and the rates use, thedue()of the daily load of the demo, which skips the load when every account has a load of its day, the late accounts ofwatcher.py,dbt/models/ops/ops_loads.sql, and the retention ofcore.loadsinmaintenance.py. Without it, after a stop of 120 days, an accepted intraday load of the first day back would set the last accepted day to today, the next daily window would start 90 days back, and 30 days would be lost for good; and a new account with an intraday load only would look to the history of Google Ads as an account that lacks every day before today. The DAG of maintenance deletes the accepted intraday rows ofcore.loadsthat no fact reads once they are 14 days old, so that they do not stay for good: 14 days is a proposal for the maintainer. - G0a of ADR-0035 does not check an intraday load, as the code stands: it compares a load with the totals of the account in the same load and skips a load without totals (
quarantine_totals_findingsindbt/macros/quarantine.sql), and the short cycle asks for none. G1 applies as to any load.
- The journal of restatements of ADR-0036 skips an old row with
- One load of a source at a time. The loads of one source go through an Airflow pool of one slot:
google_ads_loadfor the daily load of Google Ads, its runs of the history and its short cycle, anddemo_load, as today, for the loads of the demo.airflow-initsets the new pool on every start, as it doesdbtanddemo_load(compose.yaml). Todaymax_active_runs = 1of the DAG of Google Ads keeps its daily load and its runs of the history apart, but a DAG of the short cycle is another DAG. This is the "pool with one slot" of ADR-0038, put on the loads and not on dbt, where the transform keeps its pooldbt. - The period. A setting in
.envgives the period of the short cycle in hours, a divisor of 24 (1, 2, 3, 4, 6, 8, 12 or 24), at a fixed minute in UTC, or 0 for off, with 3 by default, as ADR-0038 says../agoranomosrefuses another value, as it does for its other settings. A run that waited longer than the period ends without a load, as the next one comes. - The day before, after midnight. While no whole load covers the day before in the account, the short cycle takes it too, in the same request, so that between midnight in the account and the daily load (10:37 UTC for Google Ads) the day before goes on growing instead of keeping the value of its last cycle. It costs no operation of the quota. This bullet is open to the acceptance of the maintainer; without it, the short cycle takes only the current day, as ADR-0038 says.
- Partial days in the numbers. A period, a KPI, a comparison of periods, a week and a month take closed days only, as ADR-0038 says, and so do the metrics of the glossary of Metabase (
metabase/metrics.py, ADR-0043), so that a metric and the card of the same period give one number. A card "Today, as of the load" answers the partial rows, with the time of the newest load. This bullet is open to the acceptance of the maintainer; the other choice is a metric that counts today as spent so far, and says so in its description. - The profiles. The short cycle is on, every 3 hours, in the default profile and in the demo, and the block of the agency profile in
.env.exampleturns it off, until C3c of #223 has measured a cycle on that profile and the watcher mode has lowered its cost. This bullet is open to the acceptance of the maintainer; the other choices are 3 hours there too, or a longer period. - Meta and the other platforms. The design takes any source, with a pool of its own. The short cycle of Meta waits for its quotas, which depend on the level of access (row 21 of the register of the audit, and "Not checked yet" of ADR-0038), in a task after that check and not in the connector of Meta. This bullet is open to the acceptance of the maintainer.
The other options were not chosen for these reasons:
- The light DAG of ADR-0038 fails both ways described above: in the local mode its build rebuilds the tables of a daily run between two of its tasks, and its acceptance, by itself, accepts what the daily run pinned and lets the cleanup delete it. Its own table in L0 would also need its own staging, as every staging model of the facts joins the days of the pin.
- The light DAG after the watcher mode removes the first failure and keeps the second: a light run still needs its own pin, its own days, its own checks and its own acceptance, a second path through the rules of ADR-0046. It also waits for the watcher mode, which waits for the measurements of the stand.
- A run-operation of dbt would write the fact outside the models: no contract, no test of dbt, no G1 or G2, and no rate of the current day, which
core_fx_rates_dailywrites up to the last day of the windows of a run. It would also be a write into the core that no pin or acceptance records.
Consequences
- Good, because the pin, the acceptance and the cleanup keep one rule for every load, and the two cycles cannot collide: the transform runs one run at a time, and a load that ends during a run waits for the next one.
- Good, because it works in the local mode of today, and the watcher mode changes its cost, not its design: the producer keeps the pool
dbt, andmax_active_runskeeps the runs apart. - Good, because the checks and the tests of a run, and the rate of the day, apply to today.
- Good, because a partial day cannot replace a whole one, whatever the order in which the loads end.
- Bad, because in the local mode each cycle is a full run of the transform, as dear in orchestration as a daily run, however few rows it writes. A run took 160 s for the demo on a Mac (ADR-0039, October 2026) and 239 s on a project of the size of the demo over empty tables, on a Mac (R1, 1 November 2026), and 789 to 812 s on the test server of B16 (11 and 12 November 2026). Eight cycles a day are 21 to 32 minutes of the transform on a Mac, and about 1.8 hours on that server. The watcher mode would cut it: R1 measured 36 and 39 s at the size of the demo.
- Bad, because a daily run of the transform may wait behind a run of the short cycle, up to the length of a run: about 13 minutes on the test server of B16.
- Bad, because the warehouse runs eight more transforms a day, in the hours when people read; the writes of today are small (0.2 + 0.07 s for 6,000 rows of campaigns at the density of the limit, ADR-0038), but the rest of a run, the dimensions, the snapshots, the tests and elementary, is not measured beside the readers.
- Bad, because elementary writes rows on every run: at about 1.1 MB a run, as measured in v0.4 (ADR-0044), eight more runs a day come to about 800 MB over the 90 days that the maintenance keeps.
- Bad, because a cycle costs quota: two operations of Google Ads for each account, the customer, for its time zone, and the statistics of today, so 16 a day at 3 hours, beside the 12 of a daily load. Explorer access, 2,880 operations a day, then carries about 100 accounts instead of about 240, and an agency of 200 accounts with the short cycle needs Basic access, 15,000 a day (read on 14 November 2026). A time zone read from the dimension of accounts would halve the cost of a cycle.
- Bad, because every reader of a watermark has to know the third kind, and one that does not closes a stop that never closed; the unit tests of each reader carry the case of a stop of 120 days.
- Bad, because the choice of the newest load gains a rank of the kind, and the bound on the accepted loads gains the case of an older whole load.
- Neutral: two DAGs of the short cycle, for Google Ads and the demo, a pool, a column, a kind and a setting; no service and no new right of a role.
Confirmation
Stack tests write a load of the kind intraday into the raw tables of the demo and its journal, as tests/stack/test_core_facts.py writes a changed day, and check that a run of the transform writes today into the fact of campaigns with is_partial_day and into no other fact or journal; that a later whole load replaces it with no row of the journal; that an intraday load with a larger load ID than a whole one leaves the day whole; that a run with only an intraday load leaves the lists and the dimensions as they were; and that a partial day below what the core holds puts no account in quarantine. Unit tests check that each reader of a watermark leaves the kind out, with the case of a stop of 120 days. A stack test of the demo runs the whole cycle. The code review checks that no reader of window_to or as_of counts an intraday load.
More Information
- Implementation status, as of November 2026: C3a to C3d of #223 are in place. The migration
postgres/migrations/0009_add_the_partial_day.sqlwidens the CHECK ofcore.loads.kindtointraday, by the nameloads_kind_checkthat PostgreSQL gave the CHECK of 0008, and addsis_partial_day boolean NOT NULL DEFAULT falsetocore.ad_stats_campaign_daily, which PostgreSQL 18.6 added with no rewrite of the partitions on a partitioned table with rows: the files of the partitions stayed the same and each kept the default in the catalog (atthasmissing), checked on 16 November 2026 on a throwaway cluster of PostgreSQL 18.6, the version of the image of the warehouse, with 100,000 rows in four partitions. The pin copies the kindintradayfrom the journal (dbt/macros/pin_loads.sql);pinned_loadsranks a whole load before an intraday one, counts of the accepted loads those newer than the oldest pinned load of their rank and the accepted whole loads on the days of a pinned intraday load, andnewest_listspasses intraday loads over (dbt/macros/newest_load.sql);staging.stg_loads__newest_dayscarries the kind of the load asload_kind, andstaging.int_window_daysthe flagis_partial_day; the partial day is a day of the fact of campaigns alone, the other facts and their G2 leave it out, the journal of restatements skips a partial row, and G1a skips intraday loads and partial rows (dbt/macros/facts.sql,dbt/macros/quarantine.sql); G0a is unchanged, as an intraday load brings no totals. The check of the accounts as a whole knows an account that a run reads from intraday loads alone, which take no list, whencore.dim_accountholds it from a list before, as it would else hold the account out asunknown_accounton every cycle that runs alone; this record did not name that reader. The stack tests oftests/stack/test_partial_day.pywrite loads of the kindintradayintoraw_demo_searchas the confirmation above says. The view of campaigns ends withis_partial_day(C3d); the card Today, as of the load, on the tab Overview of the dashboard Advertising reads its partial rows, with the time of their load and every filter of the dashboard but the period, and every other question on the view of campaigns, those of the demo among them, and every metric of Metabase over it take whole days (metabase/advertising.py,metabase/demo_init.py,metabase/metrics.py), which the same stack tests check on the dashboard, its KPI Spend and the metric CTR (Campaigns). For C3b, the DAGagoranomos_google_ads_intraday, paused on creation, loads the current day of each account of Google Ads that a whole load has taken, and the day before while no whole load covers it, in one request after that of the customer, everyAGORANOMOS_INTRADAY_HOURShours, 3 by default, at 27 minutes past the hour in UTC, or never at 0, which./agoranomosand the DAG file check (airflow/dags/agoranomos_pipelines/intraday.py); it updates an asset of its own inLOADED, and its load and that ofagoranomos_google_ads_dailyrun in the poolgoogle_ads_loadof one slot, whichairflow-initsets.accepted(),loads.recorded(),known_windows(), the late check ofwatcher.pyandops_loadsleave the kind out, with unit tests of a stop of 120 days on the SQL of the readers in SQLite, and the maintenance deletes the accepted intraday rows ofcore.loadsolder than 14 days that no row ofcore.ad_stats_campaign_dailynames, and the rows of their loads in_dlt_loadsafter 14 days too, as a row of_dlt_loadsthat stayed 90 days would keep the row ofcore.loads, which the next pin would else take again. Three choices that this record did not name: a cycle skips while a run of the daily DAG is queued or running, as that load can hold the pool for hours, longer than the hour of thedagrun_timeoutof a cycle; it leaves out an account that no whole load has taken, which the check of the accounts would hold asunknown_account; and it writes no row of a failed account into the journal, as such a row would make the newest pinned load of the account a failed one, which holds the account in quarantine with its daily window. The quotas above were read again on 19 November 2026: Basic access 15,000 operations a day, Explorer access 2,880 for production accounts, and one search request one operation. For C3c, the DAGagoranomos_demo_intraday, paused on creation, whichdemo-initunpauses with the daily load of the demo on the first start that finds it without a run, unless the period is 0, loads the current day of each account ofdemo_searchthat a whole load has taken, and the day before while no whole load covers it, on the same schedule, as a load of the kindintradayintocampaign_statswithout conversions, in the pooldemo_loadwith the history and the daily load of the demo, and updates an asset of its own inLOADED. The generator gives the numbers of a campaign so far as its numbers of the day times the share of the day that has passed in the time zone of the account at the moment of the run (airflow/dags/agoranomos_pipelines/demo/search.py), so that a moment always gives the same rows and the day before gives what the daily load takes of it but its conversions; the rule of the days of a cycle is one function that Google Ads and the demo share (intraday.days). The stack testtests/stack/test_demo_intraday.pyruns the whole cycle: a run of the DAG, the run of the transform that its asset starts, with the daily load ofdemo_searchbeside it, and the next run, which replaces the day before whole with no row of the journal and leaves today partial; it first makes the core forget yesterday of the two accounts, as the stack has loaded it. The jobs of the Stack workflow with the demo setAGORANOMOS_INTRADAY_HOURS=0, so that no cycle starts a run of the transform among the other tests, and the test checks the schedule of 0 and of 3 in the DAG file. One choice that this record did not name: a cycle of the demo skips while a run of the history of the demo is queued or running, as the history replaces every table of the demo. C3c measured a cycle on the runners of GitHub on 19 November 2026 (row 13 of the register of the audit, System requirements): on the demo, in server mode on arm64 with 4 CPUs, a run of the transform that read only a load of the short cycle took 429 s for its 124 tasks, with the daily load ofdemo_searchbeside it, with the tasks at 947 MiB of 1,280 andwarehouse-dbat 156 MiB of 384, and added 1,409,024 bytes toops, against 419 s and 1,384,448 bytes for the next run, which read the daily load. On the core of the agency profile, 6,000,000 rows of ads over 400 days, on amd64 with 4 CPUs, a run of the transform that read only a load of the short cycle took 427 s, against 354 s for a run that read no load, with the tasks at 937 MiB andwarehouse-dbat 932 MiB, and added 1,482,752 bytes toops; the cards of the tab Overview answered 30% fewer queries a second while it ran, 3.52 against 5.03. Neither condition of this record for the default of the period holds: the run takes far less than 3 hours, and the readers lost no more than B7 measured, 30% against 30 to 70%, though B7 measured eight clients ofpgbenchat the density of the limit. The block of the agency profile keeps the cycle off, as "The profiles" says, until the watcher mode lowers the cost of a run. - The facts behind this record:
- Read in the code of
mainat84e756e, on 14 November 2026:max_active_runs = 1and the pooldbtof two slots of the transform, and itsExecutionMode.LOCALwithTestBehavior.BUILD;ACCEPTofacceptance.py;pinned_loadsandnewest_listsofnewest_load.sql; theCASEon the kind inpin_loads.sql;fact_days,fact_empty_days,fact_restatementsandfact_thawoffacts.sql;quarantine_totals_findingsandquarantine_collapse_findingsofquarantine.sql;window(),accepted(),last_day(),known_windows(),missing()andplan()ofgoogle_ads.py, and its count of twelve operations for each account of a daily load;recorded()ofloads.py; the late accounts ofwatcher.py; the retention of the kindwindowofcore.loadsinmaintenance.py; the nullable conversions ofcore.ad_stats_campaign_daily(0005_create_the_facts.sql); the pools ofairflow-init(compose.yaml); and the conditionLOADEDofassets.py, on which the transform keeps the events that come during a run and starts one run for them when it ends. - The time of a run of the transform: 160 s for 657 nodes of the demo on a Mac (ADR-0039, October 2026). The report of R1 (#187), on 1 November 2026, on a Mac with Docker Desktop, arm64, Airflow 3.3.2 and Cosmos 1.15.1: on a project of the size of the demo over empty tables, the cost of the orchestration alone, 239.2 s in
ExecutionMode.LOCALwithTestBehavior.BUILDand two slots, against 36.4 and 39.1 s in the watcher mode, with a peak of the container of the tasks of 842 and 878 MiB of 1,280. The report of B16 (#208), on 11 and 12 November 2026, on the test server of the project, an Intel Core i5-3230M of 2012 with 2 cores, 4 threads and 7.6 GiB, in local mode without the demo, the LocalExecutor andWAREHOUSE_DB_MEMORY=3g: 812 s on an empty model and 789 s beside the core of the agency profile, as a run with no pinned load writes no window, with a peak of the container of the tasks of 943 MiB of 1,280. - The quotas of Google Ads, read on 14 November 2026 on Access levels: Basic access up to 15,000 operations a day, and Explorer access up to 2,880 a day for production accounts. A request counts as one operation whatever its rows (ADR-0032).
- Read in the code of
- Not checked yet, and to be checked with the code:
ADD COLUMNwith a constant default and no rewrite on a partitioned table with rows, in PostgreSQL 18.6: C3a checks it.- The choice of the newest load with the rank of the kind and the case of an older accepted whole load, in the time of the build of the demo: C3a gives it before and after.
- The freshness of today on Google, an SLO of 1 hour for clicks, impressions and cost, read in October 2026 (ADR-0038).
- Open at review: the bullets "The day before, after midnight", "Partial days in the numbers", "The profiles" and "Meta and the other platforms", and the 14 days of the retention of intraday rows, each with the option that this record recommends.
- Related decisions: at acceptance this record replaces, in ADR-0038, the sentence "A separate light DAG has its own table in L0 and runs
dbt build --select tag:intraday. Both cycles write one fact, so both go through an Airflow pool of one slot, where they queue and do not collide." of "The current day", and, with the bullet "The day before, after midnight", "only the current day of an account" of the same item; in ADR-0046, "the load with the largest_dlt_load_id" of "What L1 reads", as a whole load now comes before an intraday one whatever their load IDs. The rest of those records stands. ADR-0039 keeps its decision; the watcher mode would make each cycle cheaper and changes nothing here. - Revisit this record when the watcher mode is in place, with the cost of a cycle, or when a platform needs the current day below the level of campaigns.