cctally 1.114.0 → 1.115.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/bin/_cctally_account.py +32 -8
- package/bin/_cctally_cache.py +4394 -279
- package/bin/_cctally_completion.py +1287 -0
- package/bin/_cctally_config.py +37 -0
- package/bin/_cctally_core.py +178 -2
- package/bin/_cctally_dashboard.py +2 -2
- package/bin/_cctally_dashboard_conversation.py +292 -23
- package/bin/_cctally_dashboard_envelope.py +16 -3
- package/bin/_cctally_dashboard_sources.py +18 -9
- package/bin/_cctally_db.py +316 -5
- package/bin/_cctally_doctor.py +436 -27
- package/bin/_cctally_five_hour.py +82 -31
- package/bin/_cctally_forecast.py +81 -9
- package/bin/_cctally_journal.py +3884 -112
- package/bin/_cctally_journal_repair.py +101 -12
- package/bin/_cctally_parser.py +42 -0
- package/bin/_cctally_project.py +8 -2
- package/bin/_cctally_quarantine.py +652 -0
- package/bin/_cctally_quota.py +26 -4
- package/bin/_cctally_quota_model.py +360 -83
- package/bin/_cctally_record.py +677 -149
- package/bin/_cctally_rederive.py +297 -32
- package/bin/_cctally_refresh.py +84 -13
- package/bin/_cctally_source_analytics.py +23 -2
- package/bin/_cctally_statusline.py +6137 -517
- package/bin/_cctally_store.py +287 -48
- package/bin/_cctally_transcript.py +8 -7
- package/bin/_cctally_tui.py +57 -53
- package/bin/_lib_account_binding.py +152 -0
- package/bin/_lib_account_protocol.py +386 -0
- package/bin/_lib_aggregators.py +4 -0
- package/bin/_lib_cache_coverage.py +13 -1
- package/bin/_lib_cache_writer_lock.py +19 -3
- package/bin/_lib_clone_copy.py +142 -0
- package/bin/_lib_codex_conversation_query.py +133 -19
- package/bin/_lib_codex_conversation_watch.py +59 -14
- package/bin/_lib_codex_drain_admission.py +214 -0
- package/bin/_lib_codex_metadata.py +18 -1
- package/bin/_lib_codex_publication_barrier.py +277 -0
- package/bin/_lib_codex_rollout_container.py +502 -0
- package/bin/_lib_conversation_dispatch.py +3 -0
- package/bin/_lib_conversation_query.py +11 -3
- package/bin/_lib_detector_access_registry.py +3817 -0
- package/bin/_lib_doctor.py +452 -1
- package/bin/_lib_five_hour.py +126 -0
- package/bin/_lib_ingest_frontier.py +414 -20
- package/bin/_lib_journal.py +141 -10
- package/bin/_lib_jsonl.py +5 -4
- package/bin/_lib_legacy_spool.py +126 -0
- package/bin/_lib_legacy_writer_evidence.py +136 -0
- package/bin/_lib_merge_gate.py +29 -302
- package/bin/_lib_meter_rate_change.py +10 -0
- package/bin/_lib_outcome_quarantine.py +690 -0
- package/bin/_lib_pricing.py +7 -2
- package/bin/_lib_quarantine.py +154 -0
- package/bin/_lib_quota_calibration.py +53 -8
- package/bin/_lib_quota_copy.py +2 -1
- package/bin/_lib_quota_model.py +288 -46
- package/bin/_lib_rederive.py +94 -5
- package/bin/_lib_segment_summary.py +35 -2
- package/bin/_lib_statusline_candidates.py +292 -23
- package/bin/cctally +23 -1
- package/package.json +14 -1
|
@@ -0,0 +1,3817 @@
|
|
|
1
|
+
"""The access-contract registry of the strict detector path (#825/#832,
|
|
2
|
+
spec 5.6 item 6).
|
|
3
|
+
|
|
4
|
+
Every transitive stats.db access reachable from the Claude usage pipeline's
|
|
5
|
+
roots has exactly one contract here: its function, its SQL fingerprint
|
|
6
|
+
(whitespace-collapsed literal SQL, or `dynamic:<function>#<n>` for SQL built at
|
|
7
|
+
run time), the table, key columns, predicate, ordering and selected values, its
|
|
8
|
+
write effect, and its class — period-keyed, range-keyed, cross-period or
|
|
9
|
+
singleton. A cross-period read must carry an `inert_rule`: the reason a
|
|
10
|
+
differing historical result cannot change a certified decision. While every
|
|
11
|
+
cross-period read has one, a deletion outcome leaves a recovery certificate in
|
|
12
|
+
place; an entry without one makes `non_inert_cross_period()` non-empty, and
|
|
13
|
+
then every deletion outcome revokes its account (`_cctally_quarantine`).
|
|
14
|
+
|
|
15
|
+
`tests/test_detector_access_registry.py` regenerates the reachable set from
|
|
16
|
+
the actual call graph (`tests/_detector_access_callgraph.py`) and fails on a
|
|
17
|
+
new, changed, removed or unclassified access. The entries below were generated
|
|
18
|
+
by that collector and classified by rule; the inert rules are the sentences a
|
|
19
|
+
reviewer checks against spec 5.6 items 4 and 5.
|
|
20
|
+
|
|
21
|
+
Cost-only families use the operator's Q7 residual; a field that feeds a strict
|
|
22
|
+
decision may not.
|
|
23
|
+
|
|
24
|
+
Reviewed re-pins (#825/#832 fix round R8, Codex fix-round-4 R8 option A). A
|
|
25
|
+
dynamic site's `sql_shape` covers its complete transitive closure, and that
|
|
26
|
+
closure deliberately includes the pricing tables: `_rebuild_stats_index_locked#1`
|
|
27
|
+
reaches `_lib_pricing.CLAUDE_MODEL_PRICING`, `CODEX_MODEL_PRICING`,
|
|
28
|
+
`PRICING_SNAPSHOT_DATE`, `_LIVE_PRICING_SNAPSHOT`, the pricing functions and
|
|
29
|
+
`_cctally_cache.CONVERSATION_ROLLUP_PRICING_FP_KEY` through `FOLD_APPLIERS`.
|
|
30
|
+
None of them is inert (the fingerprint key is a SQL lookup key, and the
|
|
31
|
+
snapshot date takes part in write authorization), so every pricing sync fails
|
|
32
|
+
the registry test until the affected pins are re-pinned. A re-pin is accepted
|
|
33
|
+
only through this review:
|
|
34
|
+
|
|
35
|
+
1. Print the before/after shape-line delta of every affected site with
|
|
36
|
+
`bin/cctally-test-remote python3 tests/_detector_access_callgraph.py
|
|
37
|
+
--base <rev>`, where `<rev>` is the tree the current pins were reviewed on
|
|
38
|
+
(`HEAD` for an uncommitted sync; the merge base for a committed branch).
|
|
39
|
+
Read it beside the source diff (`git diff <rev> -- bin/`).
|
|
40
|
+
2. Explain every added (`+`), removed (`-`) and changed (`~`) dependency.
|
|
41
|
+
"Only additions" is not an explanation.
|
|
42
|
+
3. Confirm that the site's table selection, keys, predicates, ordering,
|
|
43
|
+
selected columns, parameter construction, execution conditions and write
|
|
44
|
+
effects did not change, and say why each changed dependency leaves its
|
|
45
|
+
contract and inert rule valid. A changed access needs a contract review
|
|
46
|
+
(its `table`/`keys`/`predicate`/`ordering`/`selected`/`effects`/`classes`/
|
|
47
|
+
`inert_rule`), not a new hash.
|
|
48
|
+
4. Update `sql_shape` only on the explained sites, to the `now` digest the
|
|
49
|
+
command prints. The command must then end `guard: clean`: no missing, stale
|
|
50
|
+
or unresolved access, and no pin mismatch.
|
|
51
|
+
|
|
52
|
+
Regenerating every pin in bulk is not acceptance: it would also accept an
|
|
53
|
+
access change hidden in the same closure, which the R8 tests in
|
|
54
|
+
`tests/test_detector_access_registry.py` prove the guard otherwise rejects.
|
|
55
|
+
"""
|
|
56
|
+
from __future__ import annotations
|
|
57
|
+
|
|
58
|
+
import dataclasses
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@dataclasses.dataclass(frozen=True)
|
|
62
|
+
class AccessContract:
|
|
63
|
+
function: str # "module:qualified_name"
|
|
64
|
+
sql_fingerprint: str # normalized literal SQL, or "dynamic:<function>#<n>"
|
|
65
|
+
table: str
|
|
66
|
+
keys: "tuple[str, ...]"
|
|
67
|
+
predicate: str
|
|
68
|
+
ordering: str
|
|
69
|
+
selected: "tuple[str, ...]"
|
|
70
|
+
effects: str # "read" | "write" | "delete" | "upsert"
|
|
71
|
+
classes: "tuple[str, ...]" # subset of CLASSES
|
|
72
|
+
inert_rule: "str | None"
|
|
73
|
+
# #825/#832 fix round C (CD2-003): a dynamic site's fingerprint names
|
|
74
|
+
# only its function and ordinal, so its contract also carries the digest
|
|
75
|
+
# of what it executes (`_detector_access_callgraph.CallGraph.
|
|
76
|
+
# dynamic_shape`; since fix round E its producer's complete body, the
|
|
77
|
+
# helpers its SQL is built from and their constants; since revision 2
|
|
78
|
+
# the canonical AST of every binding they read, of any value type,
|
|
79
|
+
# followed through imports, aliases and transitive dependencies; since
|
|
80
|
+
# fix round R the definition of every function or class producing such
|
|
81
|
+
# a value, transitively, however it is imported). A changed query under
|
|
82
|
+
# an unchanged ordinal fails the guard, and a site depending on a name
|
|
83
|
+
# nothing resolves fails it closed.
|
|
84
|
+
sql_shape: "str | None" = None
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
CLASSES = frozenset({"period-keyed", "range-keyed", "cross-period", "singleton"})
|
|
88
|
+
EFFECTS = frozenset({"read", "write", "delete", "upsert"})
|
|
89
|
+
|
|
90
|
+
#: Milestone writers are reached through `_pipeline_claude_usage`.
|
|
91
|
+
ROOTS = (
|
|
92
|
+
"_cctally_record:_pipeline_claude_usage",
|
|
93
|
+
"_cctally_record:detect_reset_and_credit",
|
|
94
|
+
"_cctally_record:_pipeline_record_credit",
|
|
95
|
+
"_cctally_journal:_harvest",
|
|
96
|
+
"_cctally_journal:emit_model_a",
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# -- inert rules --------------------------------------------------------------
|
|
100
|
+
|
|
101
|
+
ACCOUNTS = (
|
|
102
|
+
'Account registry metadata (labels, emails, last-seen): display and '
|
|
103
|
+
'attribution of names, never a detector input.'
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
ANCHOR = (
|
|
107
|
+
'Five-hour anchor selection: every prefix raw reset lies beyond both '
|
|
108
|
+
"tolerances of the witness's (clause 2) and continuing validity keeps "
|
|
109
|
+
'later raw resets at or after it, so no prefix anchor or block is ever '
|
|
110
|
+
'selected.'
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
BASIS = (
|
|
114
|
+
'Accepted weekly basis: with a date key it reads only the current, '
|
|
115
|
+
'post-witness week (clause 1); without one it is reached only from a '
|
|
116
|
+
'scratch reviewed hold, which is never a witness and whose reviewed op '
|
|
117
|
+
'revokes every certificate.'
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
BLOCKS = (
|
|
121
|
+
'Five-hour block rollup, ownership and cross-week flag: a Q7 '
|
|
122
|
+
'cost/display family; the block existence that gates the rollover heal '
|
|
123
|
+
'is read by exact key (period-keyed).'
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
CODEX = (
|
|
127
|
+
'Codex quota family: provider-codex rows only; nothing it reads feeds a '
|
|
128
|
+
'Claude automatic credit, moved-end transition or drop-consensus '
|
|
129
|
+
'decision.'
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
DEBOUNCE = (
|
|
133
|
+
'Debounce singleton: one row per account whose stored date key and end '
|
|
134
|
+
'are compared in Python with the incoming reading; a prefix state '
|
|
135
|
+
"carries a date key below the witness's (clauses 1 and 6), so it never "
|
|
136
|
+
'matches a forward reading.'
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
JOURNAL = (
|
|
140
|
+
'Journal identity machinery: rows are matched by exact logical or '
|
|
141
|
+
'physical identity (event id, journal id, cursor, selector generation); '
|
|
142
|
+
'a fresh witness and its forward events share no identity with the '
|
|
143
|
+
'prefix (clause 7), so a prefix row is never returned for a forward '
|
|
144
|
+
'decision.'
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
MAINT = (
|
|
148
|
+
'Maintenance only: runs at open, rebuild, publication or validation, '
|
|
149
|
+
'never inside a live automatic decision.'
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
MANUAL = (
|
|
153
|
+
"Manual record-credit path: the quarantine fold revokes the account's "
|
|
154
|
+
'certificates before these effects run (spec 5.6 item 8), so no '
|
|
155
|
+
'certified decision depends on what it reads.'
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
PRED_FIVE = (
|
|
159
|
+
'Five-hour predecessor (latest five-hour row, any window): a prefix '
|
|
160
|
+
"row's window key is below the witness's (clause 1) and continuing "
|
|
161
|
+
'validity keeps keys forward, so same_window is false in every '
|
|
162
|
+
'reference and the identical cancel/baseline branch is taken.'
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
PRED_WEEKLY = (
|
|
166
|
+
'Weekly predecessor (latest non-held row of the account, any week): a '
|
|
167
|
+
"prefix row's weekly end precedes the witness's detection clock (clause "
|
|
168
|
+
'5) and continuing validity keeps the clock forward, so a prefix row '
|
|
169
|
+
'takes neither the moved-end nor the in-place branch (both require '
|
|
170
|
+
'prior_end > now) in any reference.'
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
Q7 = (
|
|
174
|
+
'Q7 cost/alert family: its result sets milestone costs, budget or '
|
|
175
|
+
'projected alerts and block rollups, never an automatic credit, '
|
|
176
|
+
'moved-end transition or drop-consensus decision (operator Q7).'
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
QUARANTINE = (
|
|
180
|
+
'Outcome-quarantine fold state (triggers, envelope, certificates): read '
|
|
181
|
+
"whole to answer an account's quarantine status, a control input that "
|
|
182
|
+
'gates or reports a decision; the rows carry no observation, window or '
|
|
183
|
+
'week, so no prefix row is ever returned as a detector input.'
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
READ_IDX = (
|
|
187
|
+
'Index-wide sample for a projection or diagnostic value, not a detector '
|
|
188
|
+
'decision.'
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
WAIT = (
|
|
192
|
+
'Statusline waiting-head dependency tokens (fix round K13): counted, '
|
|
193
|
+
'hashed and compared only for equality with a wait descriptor to decide '
|
|
194
|
+
'whether an activating event dispatches the reducer, which re-reads and '
|
|
195
|
+
'reclassifies everything it publishes; never a detector input.'
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
REGISTRY: "tuple[AccessContract, ...]" = (
|
|
199
|
+
AccessContract(
|
|
200
|
+
function='_cctally_account:account_label',
|
|
201
|
+
sql_fingerprint='SELECT label, email FROM accounts WHERE account_key = ?',
|
|
202
|
+
table='accounts',
|
|
203
|
+
keys=('account_key',),
|
|
204
|
+
predicate='account_key = ?',
|
|
205
|
+
ordering='',
|
|
206
|
+
selected=('label', 'email'),
|
|
207
|
+
effects='read',
|
|
208
|
+
classes=('cross-period',),
|
|
209
|
+
inert_rule=ACCOUNTS,
|
|
210
|
+
),
|
|
211
|
+
AccessContract(
|
|
212
|
+
function='_cctally_account:display_account_label',
|
|
213
|
+
sql_fingerprint='SELECT provider FROM accounts WHERE account_key = ?',
|
|
214
|
+
table='accounts',
|
|
215
|
+
keys=('account_key',),
|
|
216
|
+
predicate='account_key = ?',
|
|
217
|
+
ordering='',
|
|
218
|
+
selected=('provider',),
|
|
219
|
+
effects='read',
|
|
220
|
+
classes=('cross-period',),
|
|
221
|
+
inert_rule=ACCOUNTS,
|
|
222
|
+
),
|
|
223
|
+
AccessContract(
|
|
224
|
+
function='_cctally_account:load_accounts',
|
|
225
|
+
sql_fingerprint='dynamic:_cctally_account:load_accounts#1',
|
|
226
|
+
sql_shape='sha256:fb36e398466d6f61',
|
|
227
|
+
table='dynamic',
|
|
228
|
+
keys=(),
|
|
229
|
+
predicate='dynamic SQL',
|
|
230
|
+
ordering='',
|
|
231
|
+
selected=(),
|
|
232
|
+
effects='read',
|
|
233
|
+
classes=('cross-period',),
|
|
234
|
+
inert_rule=ACCOUNTS,
|
|
235
|
+
),
|
|
236
|
+
AccessContract(
|
|
237
|
+
function='_cctally_account:real_account_count',
|
|
238
|
+
sql_fingerprint='SELECT COUNT(*) FROM accounts WHERE provider = ? AND account_key != ?',
|
|
239
|
+
table='accounts',
|
|
240
|
+
keys=('provider',),
|
|
241
|
+
predicate='provider = ? AND account_key != ?',
|
|
242
|
+
ordering='',
|
|
243
|
+
selected=('COUNT(*)',),
|
|
244
|
+
effects='read',
|
|
245
|
+
classes=('cross-period',),
|
|
246
|
+
inert_rule=ACCOUNTS,
|
|
247
|
+
),
|
|
248
|
+
AccessContract(
|
|
249
|
+
function='_cctally_cache:sync_cache',
|
|
250
|
+
sql_fingerprint="SELECT 1 FROM schema_migrations WHERE name='001_dedup_highest_wins'",
|
|
251
|
+
table='schema_migrations',
|
|
252
|
+
keys=(),
|
|
253
|
+
predicate="name='001_dedup_highest_wins'",
|
|
254
|
+
ordering='',
|
|
255
|
+
selected=('1',),
|
|
256
|
+
effects='read',
|
|
257
|
+
classes=('cross-period',),
|
|
258
|
+
inert_rule=READ_IDX,
|
|
259
|
+
),
|
|
260
|
+
AccessContract(
|
|
261
|
+
function='_cctally_core:_apply_quota_projection_schema',
|
|
262
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS quota_window_blocks ( id INTEGER PRIMARY KEY AUTOINCREMENT, source TEXT NOT NULL, source_root_key TEXT NOT NULL, logical_limit_key TEXT NOT NULL, observed_slot TEXT NOT NULL, window_minutes INTEGER NOT NULL CHECK(window_minutes > 0), limit_id TEXT, limit_name TEXT, resets_at_utc TEXT NOT NULL, nominal_start_at_utc TEXT NOT NULL, first_observed_at_utc TEXT NOT NULL, last_observed_at_utc TEXT NOT NULL, first_percent REAL NOT NULL, current_percent REAL NOT NULL, last_source_path TEXT NOT NULL, last_line_offset INTEGER NOT NULL, generation TEXT NOT NULL, orphaned_at TEXT, account_key TEXT NOT NULL DEFAULT \'unattributed\', -- public #5: the REVERSE MAP. `physical_group_key` records the -- physical window this block was materialized from, so the -- generation sweep can be scoped to the groups a bounded pass -- actually re-materialized instead of to whole roots. -- `physical_group_digest` is that group\'s contribution to its -- root\'s physical signature: the root value is a digest over the -- root\'s sorted (group key, group digest) pairs, which makes it -- ASSOCIATIVE. A bounded pass recomputes only the dirty groups\' -- digests and re-derives the root value from the stored set — -- O(groups), 608 on the real store, against O(observations) at -- 211K. Hanging it off the blocks is what makes it self-maintaining: -- a group swept to nothing loses its blocks and drops out of the -- composition with them. physical_group_key TEXT, physical_group_digest TEXT, UNIQUE(source, source_root_key, account_key, logical_limit_key, observed_slot, window_minutes, resets_at_utc) ); CREATE INDEX IF NOT EXISTS idx_quota_blocks_active ON quota_window_blocks(source, source_root_key, account_key, orphaned_at, logical_limit_key, observed_slot, window_minutes, resets_at_utc); CREATE TABLE IF NOT EXISTS quota_percent_milestones ( id INTEGER PRIMARY KEY AUTOINCREMENT, source TEXT NOT NULL, source_root_key TEXT NOT NULL, logical_limit_key TEXT NOT NULL, observed_slot TEXT NOT NULL, window_minutes INTEGER NOT NULL CHECK(window_minutes > 0), resets_at_utc TEXT NOT NULL, percent_threshold INTEGER NOT NULL CHECK(percent_threshold BETWEEN 1 AND 100), captured_at_utc TEXT NOT NULL, source_path TEXT NOT NULL, line_offset INTEGER NOT NULL, high_water_percent INTEGER NOT NULL CHECK(high_water_percent BETWEEN 1 AND 100), generation TEXT NOT NULL, orphaned_at TEXT, account_key TEXT NOT NULL DEFAULT \'unattributed\', UNIQUE(source, source_root_key, account_key, logical_limit_key, observed_slot, window_minutes, resets_at_utc, percent_threshold) ); CREATE INDEX IF NOT EXISTS idx_quota_milestones_active ON quota_percent_milestones(source, source_root_key, account_key, orphaned_at, logical_limit_key, observed_slot, window_minutes, resets_at_utc, percent_threshold); CREATE TABLE IF NOT EXISTS quota_threshold_events ( id INTEGER PRIMARY KEY AUTOINCREMENT, source TEXT NOT NULL, source_root_key TEXT NOT NULL, logical_limit_key TEXT NOT NULL, observed_slot TEXT NOT NULL, window_minutes INTEGER NOT NULL CHECK(window_minutes > 0), resets_at_utc TEXT NOT NULL, threshold INTEGER NOT NULL CHECK(threshold BETWEEN 1 AND 100), qualifying_kind TEXT NOT NULL CHECK(qualifying_kind IN (\'actual\',\'projected\')), qualifying_percent REAL, projected_percent REAL, severity TEXT NOT NULL, created_at_utc TEXT NOT NULL, disposition TEXT NOT NULL CHECK(disposition IN (\'alerted\',\'suppressed_backfill\')), alerted_at TEXT, suppressed_at TEXT, orphaned_at TEXT, account_key TEXT NOT NULL DEFAULT \'unattributed\', CHECK((disposition = \'alerted\' AND alerted_at IS NOT NULL AND suppressed_at IS NULL) OR (disposition = \'suppressed_backfill\' AND suppressed_at IS NOT NULL AND alerted_at IS NULL)), UNIQUE(source, source_root_key, account_key, logical_limit_key, observed_slot, window_minutes, resets_at_utc, threshold) ); CREATE INDEX IF NOT EXISTS idx_quota_threshold_events_active ON quota_threshold_events(source, source_root_key, account_key, orphaned_at, logical_limit_key, observed_slot, window_minutes, resets_at_utc, threshold); CREATE TABLE IF NOT EXISTS quota_projection_state ( source_root_key TEXT NOT NULL, account_key TEXT NOT NULL DEFAULT \'unattributed\', generation TEXT NOT NULL, physical_signature TEXT NOT NULL, completed_at_utc TEXT NOT NULL, PRIMARY KEY(source_root_key, account_key) ); -- public #5: everything the incremental projector needs to know about -- its own last pass, keyed by provider source. One row, read once per -- reconcile. -- -- `watermark_seq` is the highest `quota_window_change_log.seq` this -- index has consumed. It is written INSIDE the same stats transaction -- as the projection it describes, so the two commit or roll back -- together; a crash therefore replays a ledger range rather than -- skipping one, which is safe because re-materializing a group is -- idempotent. (Writing it after the commit would need a second stats -- transaction, and `run_stats_ingest` is the sole stats writer.) -- -- `interpretation_version` invalidates the mechanism itself: a -- classification change alters interpreted keys with no row mutation -- for the ledger to observe, so a bump queues one complete pass. -- -- `alerts_enabled` / `next_evaluation_at_utc` are the two alert axes -- that are not functions of window dirtiness — a delivery-gate -- transition, and a future-clocked observation that becomes eligible -- when wall time passes it with no row mutation at all. -- `next_evaluation_by_root_json` owns that scalar minimum: one earliest -- future capture per root, so a due hook tick can reconcile only the -- roots whose instants matured. -- -- `last_full_pass_at` is the periodic verification\'s deadline. Two -- cases a scoped sweep structurally cannot see — a block whose physical -- group is absent from the cache entirely, and a milestone on a historic -- root no longer active — are otherwise repairable only by an -- interpretation bump, a rebuild or a burst overflow, none of which -- happen on a normal install. Every full pass stamps it, whatever -- triggered it, so the deadline is satisfied by whichever caller reaches -- it first and the bound on staleness is one interval rather than -- forever. NULL means "never verified", which reads as due. CREATE TABLE IF NOT EXISTS quota_projection_ledger_state ( source TEXT NOT NULL, watermark_seq INTEGER NOT NULL DEFAULT 0, interpretation_version INTEGER NOT NULL DEFAULT 0, alerts_enabled INTEGER, next_evaluation_at_utc TEXT, last_full_pass_at TEXT, next_evaluation_by_root_json TEXT NOT NULL DEFAULT \'{}\', PRIMARY KEY(source) ); -- #661 S2 §6: a provider metering-rate transition, recorded from the -- first upgrade whether or not notification is enabled (§6.2). The -- row is the durable forward-only latch: its presence is what stops -- the same transition alerting twice, and it survives a stats.db -- rebuild because the journal event that created it carries a -- self-sufficient payload (§6.5). -- -- The identity is `(provider, account_key, effective_from)` and the -- promise is stated at exactly that precision — once per exact key, -- not "once per provider regime". `reduce_state` closes and -- re-creates regimes on a fingerprint change and a revised detector -- can select a different `effective_from` for the same underlying -- transition; separately, R8 can turn a formerly merged identity into -- a real account key. Both produce a new key for a transition a human -- would call the same one. The FINGERPRINT stays out of the key -- deliberately: including it would re-alert on our own algorithm -- revisions. -- #690 / #692 (epoch 1012) adds the last four columns: the disclosure -- evidence captured at DETECTION time, stored as four independent -- facts rather than one merged status taxonomy. Folding the baseline -- count into `withholding_status` would make an otherwise healthy -- successor read as currently withheld. -- -- NULL, an empty array and 0 are THREE distinct states and every -- consumer must preserve the distinction: NULL means legacy or -- unrecoverable evidence, an empty typed set means assessed with no -- such origin, 0 means a clean baseline, and a positive count means -- thin baseline evidence. The #689 regime-recovery route sees stored -- calibration regimes and no `QuotaAnalysis` at all, and all four -- values are analysis-derived, so on that route all four are NULL by -- construction — which is why every one of them is nullable. -- -- `detector_input_causes` and `composition_provenance` hold canonical -- JSON arrays of enum VALUES, never their `repr`, so a sixth -- `CompositionProvenance` origin added later cannot silently alias -- onto an existing one. `baseline_withheld_days` carries -- `baseline_fit.population["withheld"]` — the count of fenced -- observations carrying a cause that fall strictly BEFORE -- `window_start` — as a count rather than a boolean, so zero, one and -- many stay distinguishable and honest copy stays possible. -- -- These comments sit OUTSIDE the statement deliberately: SQLite -- stores the CREATE TABLE text verbatim, so a comment written inside -- it lands in `sqlite_schema.sql`, in every `iterdump()` golden and -- in `_REBUILD_SCHEMA_FINGERPRINT`. CREATE TABLE IF NOT EXISTS meter_rate_change_events ( id INTEGER PRIMARY KEY AUTOINCREMENT, provider TEXT NOT NULL, account_key TEXT NOT NULL DEFAULT \'unattributed\', effective_from TEXT NOT NULL, previous_units_per_point REAL NOT NULL, new_units_per_point REAL NOT NULL, severity TEXT NOT NULL, detected_at_utc TEXT NOT NULL, created_at_utc TEXT NOT NULL, notified_at TEXT, withholding_status TEXT, detector_input_causes TEXT, composition_provenance TEXT, baseline_withheld_days INTEGER, UNIQUE(provider, account_key, effective_from) ); CREATE INDEX IF NOT EXISTS idx_meter_rate_change_events_key ON meter_rate_change_events(provider, account_key, effective_from); CREATE TABLE IF NOT EXISTS quota_alert_arming ( id INTEGER PRIMARY KEY AUTOINCREMENT, source TEXT NOT NULL, source_root_key TEXT NOT NULL, logical_limit_key TEXT NOT NULL, observed_slot TEXT NOT NULL, window_minutes INTEGER NOT NULL CHECK(window_minutes > 0), rule_fingerprint TEXT NOT NULL, activated_at_utc TEXT NOT NULL, account_key TEXT NOT NULL DEFAULT \'unattributed\', UNIQUE(source, source_root_key, account_key, logical_limit_key, observed_slot, window_minutes) );',
|
|
263
|
+
table='quota_window_blocks',
|
|
264
|
+
keys=(),
|
|
265
|
+
predicate='',
|
|
266
|
+
ordering='',
|
|
267
|
+
selected=(),
|
|
268
|
+
effects='write',
|
|
269
|
+
classes=('singleton',),
|
|
270
|
+
inert_rule=MAINT,
|
|
271
|
+
),
|
|
272
|
+
AccessContract(
|
|
273
|
+
function='_cctally_core:_apply_quota_projection_schema',
|
|
274
|
+
sql_fingerprint="CREATE TABLE quota_projection_state ( source_root_key TEXT NOT NULL, account_key TEXT NOT NULL DEFAULT 'unattributed', generation TEXT NOT NULL, physical_signature TEXT NOT NULL, completed_at_utc TEXT NOT NULL, PRIMARY KEY(source_root_key, account_key) )",
|
|
275
|
+
table='quota_projection_state',
|
|
276
|
+
keys=(),
|
|
277
|
+
predicate='',
|
|
278
|
+
ordering='',
|
|
279
|
+
selected=(),
|
|
280
|
+
effects='write',
|
|
281
|
+
classes=('singleton',),
|
|
282
|
+
inert_rule=MAINT,
|
|
283
|
+
),
|
|
284
|
+
AccessContract(
|
|
285
|
+
function='_cctally_core:_apply_quota_projection_schema',
|
|
286
|
+
sql_fingerprint='DROP TABLE quota_projection_state',
|
|
287
|
+
table='quota_projection_state',
|
|
288
|
+
keys=(),
|
|
289
|
+
predicate='',
|
|
290
|
+
ordering='',
|
|
291
|
+
selected=(),
|
|
292
|
+
effects='write',
|
|
293
|
+
classes=('singleton',),
|
|
294
|
+
inert_rule=MAINT,
|
|
295
|
+
),
|
|
296
|
+
AccessContract(
|
|
297
|
+
function='_cctally_core:_apply_quota_projection_schema',
|
|
298
|
+
sql_fingerprint='PRAGMA table_info(quota_projection_state)',
|
|
299
|
+
table='quota_projection_state',
|
|
300
|
+
keys=(),
|
|
301
|
+
predicate='',
|
|
302
|
+
ordering='',
|
|
303
|
+
selected=(),
|
|
304
|
+
effects='read',
|
|
305
|
+
classes=('cross-period',),
|
|
306
|
+
inert_rule=MAINT,
|
|
307
|
+
),
|
|
308
|
+
AccessContract(
|
|
309
|
+
function='_cctally_core:_apply_stats_read_indexes',
|
|
310
|
+
sql_fingerprint='dynamic:_cctally_core:_apply_stats_read_indexes#1',
|
|
311
|
+
sql_shape='sha256:b2b8c8f0aa057c00',
|
|
312
|
+
table='dynamic',
|
|
313
|
+
keys=(),
|
|
314
|
+
predicate='dynamic SQL',
|
|
315
|
+
ordering='',
|
|
316
|
+
selected=(),
|
|
317
|
+
effects='read',
|
|
318
|
+
classes=('cross-period',),
|
|
319
|
+
inert_rule=MAINT,
|
|
320
|
+
),
|
|
321
|
+
AccessContract(
|
|
322
|
+
function='_cctally_core:_get_latest_row_for_week',
|
|
323
|
+
sql_fingerprint='dynamic:_cctally_core:_get_latest_row_for_week#1',
|
|
324
|
+
sql_shape='sha256:8ab553bf203922bf',
|
|
325
|
+
table='dynamic',
|
|
326
|
+
keys=(),
|
|
327
|
+
predicate='latest snapshot of ONE week date key (and account)',
|
|
328
|
+
ordering='',
|
|
329
|
+
selected=(),
|
|
330
|
+
effects='read',
|
|
331
|
+
classes=('period-keyed',),
|
|
332
|
+
inert_rule=None,
|
|
333
|
+
),
|
|
334
|
+
AccessContract(
|
|
335
|
+
function='_cctally_core:_latest_reset_event_for_end',
|
|
336
|
+
sql_fingerprint='dynamic:_cctally_core:_latest_reset_event_for_end#1',
|
|
337
|
+
sql_shape='sha256:7e0f76eaaca68934',
|
|
338
|
+
table='dynamic',
|
|
339
|
+
keys=(),
|
|
340
|
+
predicate='week_reset_events row for one new_week_end_at',
|
|
341
|
+
ordering='',
|
|
342
|
+
selected=(),
|
|
343
|
+
effects='read',
|
|
344
|
+
classes=('period-keyed',),
|
|
345
|
+
inert_rule=None,
|
|
346
|
+
),
|
|
347
|
+
AccessContract(
|
|
348
|
+
function='_cctally_core:_rebuild_retired_week_reset_uniqueness',
|
|
349
|
+
sql_fingerprint='ALTER TABLE week_reset_events__rebuild_1013 RENAME TO week_reset_events',
|
|
350
|
+
table='week_reset_events',
|
|
351
|
+
keys=(),
|
|
352
|
+
predicate='',
|
|
353
|
+
ordering='',
|
|
354
|
+
selected=(),
|
|
355
|
+
effects='write',
|
|
356
|
+
classes=('singleton',),
|
|
357
|
+
inert_rule=MAINT,
|
|
358
|
+
),
|
|
359
|
+
AccessContract(
|
|
360
|
+
function='_cctally_core:_rebuild_retired_week_reset_uniqueness',
|
|
361
|
+
sql_fingerprint='DROP TABLE week_reset_events',
|
|
362
|
+
table='week_reset_events',
|
|
363
|
+
keys=(),
|
|
364
|
+
predicate='',
|
|
365
|
+
ordering='',
|
|
366
|
+
selected=(),
|
|
367
|
+
effects='write',
|
|
368
|
+
classes=('singleton',),
|
|
369
|
+
inert_rule=MAINT,
|
|
370
|
+
),
|
|
371
|
+
AccessContract(
|
|
372
|
+
function='_cctally_core:_rebuild_retired_week_reset_uniqueness',
|
|
373
|
+
sql_fingerprint='PRAGMA index_list(week_reset_events)',
|
|
374
|
+
table='week_reset_events',
|
|
375
|
+
keys=(),
|
|
376
|
+
predicate='',
|
|
377
|
+
ordering='',
|
|
378
|
+
selected=(),
|
|
379
|
+
effects='read',
|
|
380
|
+
classes=('cross-period',),
|
|
381
|
+
inert_rule=MAINT,
|
|
382
|
+
),
|
|
383
|
+
AccessContract(
|
|
384
|
+
function='_cctally_core:_rebuild_retired_week_reset_uniqueness',
|
|
385
|
+
sql_fingerprint='PRAGMA table_info(week_reset_events)',
|
|
386
|
+
table='week_reset_events',
|
|
387
|
+
keys=(),
|
|
388
|
+
predicate='',
|
|
389
|
+
ordering='',
|
|
390
|
+
selected=(),
|
|
391
|
+
effects='read',
|
|
392
|
+
classes=('cross-period',),
|
|
393
|
+
inert_rule=MAINT,
|
|
394
|
+
),
|
|
395
|
+
AccessContract(
|
|
396
|
+
function='_cctally_core:_rebuild_retired_week_reset_uniqueness',
|
|
397
|
+
sql_fingerprint='dynamic:_cctally_core:_rebuild_retired_week_reset_uniqueness#1',
|
|
398
|
+
sql_shape='sha256:a7e7c1e51534c5ea',
|
|
399
|
+
table='dynamic',
|
|
400
|
+
keys=(),
|
|
401
|
+
predicate='dynamic SQL',
|
|
402
|
+
ordering='',
|
|
403
|
+
selected=(),
|
|
404
|
+
effects='read',
|
|
405
|
+
classes=('cross-period',),
|
|
406
|
+
inert_rule=MAINT,
|
|
407
|
+
),
|
|
408
|
+
AccessContract(
|
|
409
|
+
function='_cctally_core:_reset_aware_floor',
|
|
410
|
+
sql_fingerprint='dynamic:_cctally_core:_reset_aware_floor#1',
|
|
411
|
+
sql_shape='sha256:87c79958f961edbc',
|
|
412
|
+
table='dynamic',
|
|
413
|
+
keys=(),
|
|
414
|
+
predicate='reset effective instant in [week_start_at, week_end_at); manual floor by account and date key',
|
|
415
|
+
ordering='',
|
|
416
|
+
selected=(),
|
|
417
|
+
effects='read',
|
|
418
|
+
classes=('range-keyed', 'period-keyed'),
|
|
419
|
+
inert_rule=None,
|
|
420
|
+
),
|
|
421
|
+
AccessContract(
|
|
422
|
+
function='_cctally_core:open_db',
|
|
423
|
+
sql_fingerprint='CREATE INDEX IF NOT EXISTS idx_cost_week_start_at_time ON weekly_cost_snapshots(week_start_at, captured_at_utc DESC, id DESC)',
|
|
424
|
+
table='weekly_cost_snapshots',
|
|
425
|
+
keys=(),
|
|
426
|
+
predicate='',
|
|
427
|
+
ordering='',
|
|
428
|
+
selected=(),
|
|
429
|
+
effects='write',
|
|
430
|
+
classes=('singleton',),
|
|
431
|
+
inert_rule=MAINT,
|
|
432
|
+
),
|
|
433
|
+
AccessContract(
|
|
434
|
+
function='_cctally_core:open_db',
|
|
435
|
+
sql_fingerprint='CREATE INDEX IF NOT EXISTS idx_cost_week_time ON weekly_cost_snapshots(week_start_date, captured_at_utc DESC, id DESC)',
|
|
436
|
+
table='weekly_cost_snapshots',
|
|
437
|
+
keys=(),
|
|
438
|
+
predicate='',
|
|
439
|
+
ordering='',
|
|
440
|
+
selected=(),
|
|
441
|
+
effects='write',
|
|
442
|
+
classes=('singleton',),
|
|
443
|
+
inert_rule=MAINT,
|
|
444
|
+
),
|
|
445
|
+
AccessContract(
|
|
446
|
+
function='_cctally_core:open_db',
|
|
447
|
+
sql_fingerprint='CREATE INDEX IF NOT EXISTS idx_five_hour_block_models_block ON five_hour_block_models(block_id)',
|
|
448
|
+
table='five_hour_block_models',
|
|
449
|
+
keys=(),
|
|
450
|
+
predicate='',
|
|
451
|
+
ordering='',
|
|
452
|
+
selected=(),
|
|
453
|
+
effects='write',
|
|
454
|
+
classes=('singleton',),
|
|
455
|
+
inert_rule=MAINT,
|
|
456
|
+
),
|
|
457
|
+
AccessContract(
|
|
458
|
+
function='_cctally_core:open_db',
|
|
459
|
+
sql_fingerprint='CREATE INDEX IF NOT EXISTS idx_five_hour_block_models_window ON five_hour_block_models(five_hour_window_key)',
|
|
460
|
+
table='five_hour_block_models',
|
|
461
|
+
keys=(),
|
|
462
|
+
predicate='',
|
|
463
|
+
ordering='',
|
|
464
|
+
selected=(),
|
|
465
|
+
effects='write',
|
|
466
|
+
classes=('singleton',),
|
|
467
|
+
inert_rule=MAINT,
|
|
468
|
+
),
|
|
469
|
+
AccessContract(
|
|
470
|
+
function='_cctally_core:open_db',
|
|
471
|
+
sql_fingerprint='CREATE INDEX IF NOT EXISTS idx_five_hour_block_projects_block ON five_hour_block_projects(block_id)',
|
|
472
|
+
table='five_hour_block_projects',
|
|
473
|
+
keys=(),
|
|
474
|
+
predicate='',
|
|
475
|
+
ordering='',
|
|
476
|
+
selected=(),
|
|
477
|
+
effects='write',
|
|
478
|
+
classes=('singleton',),
|
|
479
|
+
inert_rule=MAINT,
|
|
480
|
+
),
|
|
481
|
+
AccessContract(
|
|
482
|
+
function='_cctally_core:open_db',
|
|
483
|
+
sql_fingerprint='CREATE INDEX IF NOT EXISTS idx_five_hour_block_projects_window ON five_hour_block_projects(five_hour_window_key)',
|
|
484
|
+
table='five_hour_block_projects',
|
|
485
|
+
keys=(),
|
|
486
|
+
predicate='',
|
|
487
|
+
ordering='',
|
|
488
|
+
selected=(),
|
|
489
|
+
effects='write',
|
|
490
|
+
classes=('singleton',),
|
|
491
|
+
inert_rule=MAINT,
|
|
492
|
+
),
|
|
493
|
+
AccessContract(
|
|
494
|
+
function='_cctally_core:open_db',
|
|
495
|
+
sql_fingerprint='CREATE INDEX IF NOT EXISTS idx_five_hour_blocks_block_start ON five_hour_blocks(block_start_at DESC)',
|
|
496
|
+
table='five_hour_blocks',
|
|
497
|
+
keys=(),
|
|
498
|
+
predicate='',
|
|
499
|
+
ordering='',
|
|
500
|
+
selected=(),
|
|
501
|
+
effects='write',
|
|
502
|
+
classes=('singleton',),
|
|
503
|
+
inert_rule=MAINT,
|
|
504
|
+
),
|
|
505
|
+
AccessContract(
|
|
506
|
+
function='_cctally_core:open_db',
|
|
507
|
+
sql_fingerprint='CREATE INDEX IF NOT EXISTS idx_five_hour_milestones_block ON five_hour_milestones(block_id)',
|
|
508
|
+
table='five_hour_milestones',
|
|
509
|
+
keys=(),
|
|
510
|
+
predicate='',
|
|
511
|
+
ordering='',
|
|
512
|
+
selected=(),
|
|
513
|
+
effects='write',
|
|
514
|
+
classes=('singleton',),
|
|
515
|
+
inert_rule=MAINT,
|
|
516
|
+
),
|
|
517
|
+
AccessContract(
|
|
518
|
+
function='_cctally_core:open_db',
|
|
519
|
+
sql_fingerprint='CREATE INDEX IF NOT EXISTS idx_journal_protocol_violations_batch ON journal_protocol_violations(batch_id)',
|
|
520
|
+
table='journal_protocol_violations',
|
|
521
|
+
keys=(),
|
|
522
|
+
predicate='',
|
|
523
|
+
ordering='',
|
|
524
|
+
selected=(),
|
|
525
|
+
effects='write',
|
|
526
|
+
classes=('singleton',),
|
|
527
|
+
inert_rule=MAINT,
|
|
528
|
+
),
|
|
529
|
+
AccessContract(
|
|
530
|
+
function='_cctally_core:open_db',
|
|
531
|
+
sql_fingerprint='CREATE INDEX IF NOT EXISTS idx_usage_week_start_at_time ON weekly_usage_snapshots(week_start_at, captured_at_utc DESC, id DESC)',
|
|
532
|
+
table='weekly_usage_snapshots',
|
|
533
|
+
keys=(),
|
|
534
|
+
predicate='',
|
|
535
|
+
ordering='',
|
|
536
|
+
selected=(),
|
|
537
|
+
effects='write',
|
|
538
|
+
classes=('singleton',),
|
|
539
|
+
inert_rule=MAINT,
|
|
540
|
+
),
|
|
541
|
+
AccessContract(
|
|
542
|
+
function='_cctally_core:open_db',
|
|
543
|
+
sql_fingerprint='CREATE INDEX IF NOT EXISTS idx_usage_week_time ON weekly_usage_snapshots(week_start_date, captured_at_utc DESC, id DESC)',
|
|
544
|
+
table='weekly_usage_snapshots',
|
|
545
|
+
keys=(),
|
|
546
|
+
predicate='',
|
|
547
|
+
ordering='',
|
|
548
|
+
selected=(),
|
|
549
|
+
effects='write',
|
|
550
|
+
classes=('singleton',),
|
|
551
|
+
inert_rule=MAINT,
|
|
552
|
+
),
|
|
553
|
+
AccessContract(
|
|
554
|
+
function='_cctally_core:open_db',
|
|
555
|
+
sql_fingerprint='CREATE INDEX IF NOT EXISTS idx_weekly_usage_snapshots_5h_window_key ON weekly_usage_snapshots(five_hour_window_key)',
|
|
556
|
+
table='weekly_usage_snapshots',
|
|
557
|
+
keys=(),
|
|
558
|
+
predicate='',
|
|
559
|
+
ordering='',
|
|
560
|
+
selected=(),
|
|
561
|
+
effects='write',
|
|
562
|
+
classes=('singleton',),
|
|
563
|
+
inert_rule=MAINT,
|
|
564
|
+
),
|
|
565
|
+
AccessContract(
|
|
566
|
+
function='_cctally_core:open_db',
|
|
567
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS accounts ( account_key TEXT PRIMARY KEY, provider TEXT NOT NULL, natural_id TEXT, email TEXT, label TEXT, plan_type TEXT, label_source TEXT NOT NULL DEFAULT 'auto', first_seen_utc TEXT, last_seen_utc TEXT )",
|
|
568
|
+
table='accounts',
|
|
569
|
+
keys=(),
|
|
570
|
+
predicate='',
|
|
571
|
+
ordering='',
|
|
572
|
+
selected=(),
|
|
573
|
+
effects='write',
|
|
574
|
+
classes=('singleton',),
|
|
575
|
+
inert_rule=MAINT,
|
|
576
|
+
),
|
|
577
|
+
AccessContract(
|
|
578
|
+
function='_cctally_core:open_db',
|
|
579
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS budget_milestones ( id INTEGER PRIMARY KEY AUTOINCREMENT, vendor TEXT NOT NULL, period_start_at TEXT NOT NULL, period TEXT, threshold INTEGER NOT NULL, budget_usd REAL NOT NULL, spent_usd REAL NOT NULL, consumption_pct REAL NOT NULL, crossed_at_utc TEXT NOT NULL, alerted_at TEXT, account_key TEXT NOT NULL DEFAULT '*', UNIQUE(vendor, account_key, period_start_at, period, threshold) )",
|
|
580
|
+
table='budget_milestones',
|
|
581
|
+
keys=(),
|
|
582
|
+
predicate='',
|
|
583
|
+
ordering='',
|
|
584
|
+
selected=(),
|
|
585
|
+
effects='write',
|
|
586
|
+
classes=('singleton',),
|
|
587
|
+
inert_rule=MAINT,
|
|
588
|
+
),
|
|
589
|
+
AccessContract(
|
|
590
|
+
function='_cctally_core:open_db',
|
|
591
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS five_hour_block_models ( id INTEGER PRIMARY KEY AUTOINCREMENT, block_id INTEGER NOT NULL, five_hour_window_key INTEGER NOT NULL, model TEXT NOT NULL, input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0, cache_create_tokens INTEGER NOT NULL DEFAULT 0, cache_read_tokens INTEGER NOT NULL DEFAULT 0, cost_usd REAL NOT NULL DEFAULT 0, entry_count INTEGER NOT NULL DEFAULT 0, account_key TEXT NOT NULL DEFAULT 'unattributed', UNIQUE(account_key, five_hour_window_key, model), FOREIGN KEY (block_id) REFERENCES five_hour_blocks(id) )",
|
|
592
|
+
table='five_hour_block_models',
|
|
593
|
+
keys=(),
|
|
594
|
+
predicate='',
|
|
595
|
+
ordering='',
|
|
596
|
+
selected=(),
|
|
597
|
+
effects='write',
|
|
598
|
+
classes=('singleton',),
|
|
599
|
+
inert_rule=MAINT,
|
|
600
|
+
),
|
|
601
|
+
AccessContract(
|
|
602
|
+
function='_cctally_core:open_db',
|
|
603
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS five_hour_block_projects ( id INTEGER PRIMARY KEY AUTOINCREMENT, block_id INTEGER NOT NULL, five_hour_window_key INTEGER NOT NULL, project_path TEXT NOT NULL, input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0, cache_create_tokens INTEGER NOT NULL DEFAULT 0, cache_read_tokens INTEGER NOT NULL DEFAULT 0, cost_usd REAL NOT NULL DEFAULT 0, entry_count INTEGER NOT NULL DEFAULT 0, account_key TEXT NOT NULL DEFAULT 'unattributed', UNIQUE(account_key, five_hour_window_key, project_path), FOREIGN KEY (block_id) REFERENCES five_hour_blocks(id) )",
|
|
604
|
+
table='five_hour_block_projects',
|
|
605
|
+
keys=(),
|
|
606
|
+
predicate='',
|
|
607
|
+
ordering='',
|
|
608
|
+
selected=(),
|
|
609
|
+
effects='write',
|
|
610
|
+
classes=('singleton',),
|
|
611
|
+
inert_rule=MAINT,
|
|
612
|
+
),
|
|
613
|
+
AccessContract(
|
|
614
|
+
function='_cctally_core:open_db',
|
|
615
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS five_hour_blocks ( id INTEGER PRIMARY KEY AUTOINCREMENT, five_hour_window_key INTEGER NOT NULL, five_hour_resets_at TEXT NOT NULL, block_start_at TEXT NOT NULL, first_observed_at_utc TEXT NOT NULL, last_observed_at_utc TEXT NOT NULL, final_five_hour_percent REAL NOT NULL, seven_day_pct_at_block_start REAL, seven_day_pct_at_block_end REAL, crossed_seven_day_reset INTEGER NOT NULL DEFAULT 0, total_input_tokens INTEGER NOT NULL DEFAULT 0, total_output_tokens INTEGER NOT NULL DEFAULT 0, total_cache_create_tokens INTEGER NOT NULL DEFAULT 0, total_cache_read_tokens INTEGER NOT NULL DEFAULT 0, total_cost_usd REAL NOT NULL DEFAULT 0, pricing_provenance_json TEXT, is_closed INTEGER NOT NULL DEFAULT 0, created_at_utc TEXT NOT NULL, last_updated_at_utc TEXT NOT NULL, account_key TEXT NOT NULL DEFAULT 'unattributed', UNIQUE(account_key, five_hour_window_key) )",
|
|
616
|
+
table='five_hour_blocks',
|
|
617
|
+
keys=(),
|
|
618
|
+
predicate='',
|
|
619
|
+
ordering='',
|
|
620
|
+
selected=(),
|
|
621
|
+
effects='write',
|
|
622
|
+
classes=('singleton',),
|
|
623
|
+
inert_rule=MAINT,
|
|
624
|
+
),
|
|
625
|
+
AccessContract(
|
|
626
|
+
function='_cctally_core:open_db',
|
|
627
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS five_hour_credit_confirmation_state ( account_key TEXT NOT NULL, five_hour_window_key INTEGER NOT NULL, source TEXT NOT NULL, baseline_pct REAL NOT NULL, pending_low_pct REAL, pending_at_utc TEXT, pending_observation_id TEXT, PRIMARY KEY (account_key, five_hour_window_key, source) )',
|
|
628
|
+
table='five_hour_credit_confirmation_state',
|
|
629
|
+
keys=(),
|
|
630
|
+
predicate='',
|
|
631
|
+
ordering='',
|
|
632
|
+
selected=(),
|
|
633
|
+
effects='write',
|
|
634
|
+
classes=('singleton',),
|
|
635
|
+
inert_rule=MAINT,
|
|
636
|
+
),
|
|
637
|
+
AccessContract(
|
|
638
|
+
function='_cctally_core:open_db',
|
|
639
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS five_hour_milestones ( id INTEGER PRIMARY KEY AUTOINCREMENT, block_id INTEGER NOT NULL, five_hour_window_key INTEGER NOT NULL, percent_threshold INTEGER NOT NULL, captured_at_utc TEXT NOT NULL, usage_snapshot_id INTEGER NOT NULL, block_input_tokens INTEGER NOT NULL DEFAULT 0, block_output_tokens INTEGER NOT NULL DEFAULT 0, block_cache_create_tokens INTEGER NOT NULL DEFAULT 0, block_cache_read_tokens INTEGER NOT NULL DEFAULT 0, block_cost_usd REAL NOT NULL DEFAULT 0, marginal_cost_usd REAL, seven_day_pct_at_crossing REAL, reset_event_id INTEGER NOT NULL DEFAULT 0, account_key TEXT NOT NULL DEFAULT 'unattributed', UNIQUE(account_key, five_hour_window_key, percent_threshold, reset_event_id), FOREIGN KEY (block_id) REFERENCES five_hour_blocks(id) )",
|
|
640
|
+
table='five_hour_milestones',
|
|
641
|
+
keys=(),
|
|
642
|
+
predicate='',
|
|
643
|
+
ordering='',
|
|
644
|
+
selected=(),
|
|
645
|
+
effects='write',
|
|
646
|
+
classes=('singleton',),
|
|
647
|
+
inert_rule=MAINT,
|
|
648
|
+
),
|
|
649
|
+
AccessContract(
|
|
650
|
+
function='_cctally_core:open_db',
|
|
651
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS five_hour_reset_events ( id INTEGER PRIMARY KEY AUTOINCREMENT, detected_at_utc TEXT NOT NULL, five_hour_window_key INTEGER NOT NULL, prior_percent REAL NOT NULL, post_percent REAL NOT NULL, effective_reset_at_utc TEXT NOT NULL, account_key TEXT NOT NULL DEFAULT 'unattributed', UNIQUE(account_key, five_hour_window_key, effective_reset_at_utc) )",
|
|
652
|
+
table='five_hour_reset_events',
|
|
653
|
+
keys=(),
|
|
654
|
+
predicate='',
|
|
655
|
+
ordering='',
|
|
656
|
+
selected=(),
|
|
657
|
+
effects='write',
|
|
658
|
+
classes=('singleton',),
|
|
659
|
+
inert_rule=MAINT,
|
|
660
|
+
),
|
|
661
|
+
AccessContract(
|
|
662
|
+
function='_cctally_core:open_db',
|
|
663
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS journal_admission_summary (id INTEGER PRIMARY KEY CHECK (id = 1), cutover_id TEXT, scanned_high_water TEXT, excluded_total INTEGER NOT NULL DEFAULT 0, family_counts_json TEXT NOT NULL DEFAULT '{}', first_excluded_coordinate TEXT, latest_excluded_coordinate TEXT, coordinate_digest TEXT, complete_through TEXT, boundary_json TEXT)",
|
|
664
|
+
table='journal_admission_summary',
|
|
665
|
+
keys=(),
|
|
666
|
+
predicate='',
|
|
667
|
+
ordering='',
|
|
668
|
+
selected=(),
|
|
669
|
+
effects='write',
|
|
670
|
+
classes=('singleton',),
|
|
671
|
+
inert_rule=MAINT,
|
|
672
|
+
),
|
|
673
|
+
AccessContract(
|
|
674
|
+
function='_cctally_core:open_db',
|
|
675
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS journal_cursor (id INTEGER PRIMARY KEY CHECK (id = 1), segment TEXT NOT NULL, offset INTEGER NOT NULL, applied_segment TEXT, applied_offset INTEGER)',
|
|
676
|
+
table='journal_cursor',
|
|
677
|
+
keys=(),
|
|
678
|
+
predicate='',
|
|
679
|
+
ordering='',
|
|
680
|
+
selected=(),
|
|
681
|
+
effects='write',
|
|
682
|
+
classes=('singleton',),
|
|
683
|
+
inert_rule=MAINT,
|
|
684
|
+
),
|
|
685
|
+
AccessContract(
|
|
686
|
+
function='_cctally_core:open_db',
|
|
687
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS journal_effective_events (event_id TEXT PRIMARY KEY, rev INTEGER NOT NULL CHECK (rev >= 0), status TEXT NOT NULL CHECK (status IN ('active','tombstone')), content_hash TEXT NOT NULL, batch_id TEXT, event_json TEXT, winning_sequence INTEGER, conflict_hashes_json TEXT)",
|
|
688
|
+
table='journal_effective_events',
|
|
689
|
+
keys=(),
|
|
690
|
+
predicate='',
|
|
691
|
+
ordering='',
|
|
692
|
+
selected=(),
|
|
693
|
+
effects='write',
|
|
694
|
+
classes=('singleton',),
|
|
695
|
+
inert_rule=MAINT,
|
|
696
|
+
),
|
|
697
|
+
AccessContract(
|
|
698
|
+
function='_cctally_core:open_db',
|
|
699
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS journal_protocol_violations (fingerprint TEXT PRIMARY KEY, batch_id TEXT NOT NULL, kind TEXT NOT NULL, violation_json TEXT NOT NULL, available_after INTEGER)',
|
|
700
|
+
table='journal_protocol_violations',
|
|
701
|
+
keys=(),
|
|
702
|
+
predicate='',
|
|
703
|
+
ordering='',
|
|
704
|
+
selected=(),
|
|
705
|
+
effects='write',
|
|
706
|
+
classes=('singleton',),
|
|
707
|
+
inert_rule=MAINT,
|
|
708
|
+
),
|
|
709
|
+
AccessContract(
|
|
710
|
+
function='_cctally_core:open_db',
|
|
711
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS journal_selector_batch_records (batch_id TEXT NOT NULL, kind TEXT NOT NULL CHECK (kind IN ('marker','action')), key TEXT NOT NULL, record_digest TEXT NOT NULL, identity_digest TEXT, sequence INTEGER NOT NULL, action_core_json TEXT, PRIMARY KEY (batch_id, kind, key))",
|
|
712
|
+
table='journal_selector_batch_records',
|
|
713
|
+
keys=(),
|
|
714
|
+
predicate='',
|
|
715
|
+
ordering='',
|
|
716
|
+
selected=(),
|
|
717
|
+
effects='write',
|
|
718
|
+
classes=('singleton',),
|
|
719
|
+
inert_rule=MAINT,
|
|
720
|
+
),
|
|
721
|
+
AccessContract(
|
|
722
|
+
function='_cctally_core:open_db',
|
|
723
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS journal_selector_batches (batch_id TEXT PRIMARY KEY, status TEXT NOT NULL CHECK (status IN ('begin_only','completed','tainted')), action_count INTEGER, action_set_hash TEXT, begin_segment TEXT, begin_offset INTEGER, earliest_commit_segment TEXT, earliest_commit_offset INTEGER)",
|
|
724
|
+
table='journal_selector_batches',
|
|
725
|
+
keys=(),
|
|
726
|
+
predicate='',
|
|
727
|
+
ordering='',
|
|
728
|
+
selected=(),
|
|
729
|
+
effects='write',
|
|
730
|
+
classes=('singleton',),
|
|
731
|
+
inert_rule=MAINT,
|
|
732
|
+
),
|
|
733
|
+
AccessContract(
|
|
734
|
+
function='_cctally_core:open_db',
|
|
735
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS journal_selector_state (id INTEGER PRIMARY KEY CHECK (id = 1), generation_record_path TEXT, generation_stamped_at_utc TEXT, covered_segment TEXT, covered_offset INTEGER, next_sequence INTEGER NOT NULL DEFAULT 0, selector_version INTEGER NOT NULL, cutover_seen INTEGER NOT NULL DEFAULT 0, cutover_account_key TEXT)',
|
|
736
|
+
table='journal_selector_state',
|
|
737
|
+
keys=(),
|
|
738
|
+
predicate='',
|
|
739
|
+
ordering='',
|
|
740
|
+
selected=(),
|
|
741
|
+
effects='write',
|
|
742
|
+
classes=('singleton',),
|
|
743
|
+
inert_rule=MAINT,
|
|
744
|
+
),
|
|
745
|
+
AccessContract(
|
|
746
|
+
function='_cctally_core:open_db',
|
|
747
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS outcome_quarantine_certificates (account_key TEXT PRIMARY KEY, accounting_certificate_json TEXT, accounting_trigger_seq INTEGER, control_certificate_json TEXT, control_trigger_seq INTEGER)',
|
|
748
|
+
table='outcome_quarantine_certificates',
|
|
749
|
+
keys=(),
|
|
750
|
+
predicate='',
|
|
751
|
+
ordering='',
|
|
752
|
+
selected=(),
|
|
753
|
+
effects='write',
|
|
754
|
+
classes=('singleton',),
|
|
755
|
+
inert_rule=MAINT,
|
|
756
|
+
),
|
|
757
|
+
AccessContract(
|
|
758
|
+
function='_cctally_core:open_db',
|
|
759
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS outcome_quarantine_envelope (scope TEXT PRIMARY KEY, envelope_json TEXT NOT NULL)',
|
|
760
|
+
table='outcome_quarantine_envelope',
|
|
761
|
+
keys=(),
|
|
762
|
+
predicate='',
|
|
763
|
+
ordering='',
|
|
764
|
+
selected=(),
|
|
765
|
+
effects='write',
|
|
766
|
+
classes=('singleton',),
|
|
767
|
+
inert_rule=MAINT,
|
|
768
|
+
),
|
|
769
|
+
AccessContract(
|
|
770
|
+
function='_cctally_core:open_db',
|
|
771
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS outcome_quarantine_triggers (seq INTEGER PRIMARY KEY, segment TEXT, byte_offset INTEGER, kind TEXT NOT NULL, reason TEXT NOT NULL, at TEXT)',
|
|
772
|
+
table='outcome_quarantine_triggers',
|
|
773
|
+
keys=(),
|
|
774
|
+
predicate='',
|
|
775
|
+
ordering='',
|
|
776
|
+
selected=(),
|
|
777
|
+
effects='write',
|
|
778
|
+
classes=('singleton',),
|
|
779
|
+
inert_rule=MAINT,
|
|
780
|
+
),
|
|
781
|
+
AccessContract(
|
|
782
|
+
function='_cctally_core:open_db',
|
|
783
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS percent_milestones ( id INTEGER PRIMARY KEY AUTOINCREMENT, captured_at_utc TEXT NOT NULL, week_start_date TEXT NOT NULL, week_end_date TEXT NOT NULL, week_start_at TEXT, week_end_at TEXT, percent_threshold INTEGER NOT NULL, cumulative_cost_usd REAL NOT NULL, marginal_cost_usd REAL, usage_snapshot_id INTEGER NOT NULL, cost_snapshot_id INTEGER NOT NULL, reset_event_id INTEGER NOT NULL DEFAULT 0, account_key TEXT NOT NULL DEFAULT 'unattributed', UNIQUE(account_key, week_start_date, percent_threshold, reset_event_id) )",
|
|
784
|
+
table='percent_milestones',
|
|
785
|
+
keys=(),
|
|
786
|
+
predicate='',
|
|
787
|
+
ordering='',
|
|
788
|
+
selected=(),
|
|
789
|
+
effects='write',
|
|
790
|
+
classes=('singleton',),
|
|
791
|
+
inert_rule=MAINT,
|
|
792
|
+
),
|
|
793
|
+
AccessContract(
|
|
794
|
+
function='_cctally_core:open_db',
|
|
795
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS project_budget_milestones ( id INTEGER PRIMARY KEY AUTOINCREMENT, week_start_at TEXT NOT NULL, project_key TEXT NOT NULL, -- canonical git-root (bucket_path) threshold INTEGER NOT NULL, budget_usd REAL NOT NULL, -- project's target snapshotted AT crossing spent_usd REAL NOT NULL, consumption_pct REAL NOT NULL, crossed_at_utc TEXT NOT NULL, alerted_at TEXT, account_key TEXT NOT NULL DEFAULT '*', -- account-blind this epic (spec §6): always '*' UNIQUE(account_key, week_start_at, project_key, threshold) )",
|
|
796
|
+
table='project_budget_milestones',
|
|
797
|
+
keys=(),
|
|
798
|
+
predicate='',
|
|
799
|
+
ordering='',
|
|
800
|
+
selected=(),
|
|
801
|
+
effects='write',
|
|
802
|
+
classes=('singleton',),
|
|
803
|
+
inert_rule=MAINT,
|
|
804
|
+
),
|
|
805
|
+
AccessContract(
|
|
806
|
+
function='_cctally_core:open_db',
|
|
807
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS projected_milestones ( id INTEGER PRIMARY KEY AUTOINCREMENT, week_start_at TEXT NOT NULL, -- period-start instant (subscription-week OR calendar period-start; back-compat name) period TEXT, -- configured period at crossing; NULL = pre-011 unknown (migration 011) metric TEXT NOT NULL, -- 'weekly_pct' | 'budget_usd' | 'codex_budget_usd' threshold INTEGER NOT NULL, -- 90 | 100 projected_value REAL NOT NULL, denominator REAL NOT NULL, -- target_usd (budget / codex_budget) | 100.0 (weekly) crossed_at_utc TEXT NOT NULL, alerted_at TEXT, account_key TEXT NOT NULL DEFAULT '*', -- '*' for vendor-budget metrics; real account for weekly_pct (Task 3) UNIQUE(account_key, week_start_at, period, metric, threshold) )",
|
|
808
|
+
table='projected_milestones',
|
|
809
|
+
keys=(),
|
|
810
|
+
predicate='',
|
|
811
|
+
ordering='',
|
|
812
|
+
selected=(),
|
|
813
|
+
effects='write',
|
|
814
|
+
classes=('singleton',),
|
|
815
|
+
inert_rule=MAINT,
|
|
816
|
+
),
|
|
817
|
+
AccessContract(
|
|
818
|
+
function='_cctally_core:open_db',
|
|
819
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS stats_publication_stamp (record_path TEXT NOT NULL, started_at_utc TEXT NOT NULL, stamped_at_utc TEXT NOT NULL)',
|
|
820
|
+
table='stats_publication_stamp',
|
|
821
|
+
keys=(),
|
|
822
|
+
predicate='',
|
|
823
|
+
ordering='',
|
|
824
|
+
selected=(),
|
|
825
|
+
effects='write',
|
|
826
|
+
classes=('singleton',),
|
|
827
|
+
inert_rule=MAINT,
|
|
828
|
+
),
|
|
829
|
+
AccessContract(
|
|
830
|
+
function='_cctally_core:open_db',
|
|
831
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS stats_quota_projection_state (id INTEGER PRIMARY KEY CHECK (id = 1), incomplete INTEGER NOT NULL DEFAULT 0, target_version INTEGER NOT NULL DEFAULT 0, recovery_target_json TEXT)',
|
|
832
|
+
table='stats_quota_projection_state',
|
|
833
|
+
keys=(),
|
|
834
|
+
predicate='',
|
|
835
|
+
ordering='',
|
|
836
|
+
selected=(),
|
|
837
|
+
effects='write',
|
|
838
|
+
classes=('singleton',),
|
|
839
|
+
inert_rule=MAINT,
|
|
840
|
+
),
|
|
841
|
+
AccessContract(
|
|
842
|
+
function='_cctally_core:open_db',
|
|
843
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS usage_snapshot_suppressions (journal_id TEXT PRIMARY KEY)',
|
|
844
|
+
table='usage_snapshot_suppressions',
|
|
845
|
+
keys=(),
|
|
846
|
+
predicate='',
|
|
847
|
+
ordering='',
|
|
848
|
+
selected=(),
|
|
849
|
+
effects='write',
|
|
850
|
+
classes=('singleton',),
|
|
851
|
+
inert_rule=MAINT,
|
|
852
|
+
),
|
|
853
|
+
AccessContract(
|
|
854
|
+
function='_cctally_core:open_db',
|
|
855
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS week_reset_events ( id INTEGER PRIMARY KEY AUTOINCREMENT, detected_at_utc TEXT NOT NULL, old_week_end_at TEXT NOT NULL, new_week_end_at TEXT NOT NULL, effective_reset_at_utc TEXT NOT NULL, observed_pre_credit_pct REAL, account_key TEXT NOT NULL DEFAULT 'unattributed', origin_observation_id TEXT )",
|
|
856
|
+
table='week_reset_events',
|
|
857
|
+
keys=(),
|
|
858
|
+
predicate='',
|
|
859
|
+
ordering='',
|
|
860
|
+
selected=(),
|
|
861
|
+
effects='write',
|
|
862
|
+
classes=('singleton',),
|
|
863
|
+
inert_rule=MAINT,
|
|
864
|
+
),
|
|
865
|
+
AccessContract(
|
|
866
|
+
function='_cctally_core:open_db',
|
|
867
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS weekly_cost_snapshots ( id INTEGER PRIMARY KEY AUTOINCREMENT, captured_at_utc TEXT NOT NULL, week_start_date TEXT NOT NULL, week_end_date TEXT NOT NULL, week_start_at TEXT, week_end_at TEXT, range_start_iso TEXT, range_end_iso TEXT, cost_usd REAL NOT NULL, source TEXT NOT NULL DEFAULT 'cctally-range-cost', mode TEXT NOT NULL DEFAULT 'auto', project TEXT, account_key TEXT NOT NULL DEFAULT 'unattributed' )",
|
|
868
|
+
table='weekly_cost_snapshots',
|
|
869
|
+
keys=(),
|
|
870
|
+
predicate='',
|
|
871
|
+
ordering='',
|
|
872
|
+
selected=(),
|
|
873
|
+
effects='write',
|
|
874
|
+
classes=('singleton',),
|
|
875
|
+
inert_rule=MAINT,
|
|
876
|
+
),
|
|
877
|
+
AccessContract(
|
|
878
|
+
function='_cctally_core:open_db',
|
|
879
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS weekly_credit_floors ( id INTEGER PRIMARY KEY AUTOINCREMENT, week_start_date TEXT NOT NULL, effective_at_utc TEXT NOT NULL, observed_pre_credit_pct REAL NOT NULL, applied_at_utc TEXT NOT NULL, account_key TEXT NOT NULL DEFAULT 'unattributed', UNIQUE(account_key, week_start_date, effective_at_utc) )",
|
|
880
|
+
table='weekly_credit_floors',
|
|
881
|
+
keys=(),
|
|
882
|
+
predicate='',
|
|
883
|
+
ordering='',
|
|
884
|
+
selected=(),
|
|
885
|
+
effects='write',
|
|
886
|
+
classes=('singleton',),
|
|
887
|
+
inert_rule=MAINT,
|
|
888
|
+
),
|
|
889
|
+
AccessContract(
|
|
890
|
+
function='_cctally_core:open_db',
|
|
891
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS weekly_reset_debounce_state ( account_key TEXT PRIMARY KEY, week_start_date TEXT NOT NULL, week_end_at TEXT NOT NULL, baseline_pct REAL NOT NULL, first_zero_at_utc TEXT NOT NULL, first_zero_observation_id TEXT )',
|
|
892
|
+
table='weekly_reset_debounce_state',
|
|
893
|
+
keys=(),
|
|
894
|
+
predicate='',
|
|
895
|
+
ordering='',
|
|
896
|
+
selected=(),
|
|
897
|
+
effects='write',
|
|
898
|
+
classes=('singleton',),
|
|
899
|
+
inert_rule=MAINT,
|
|
900
|
+
),
|
|
901
|
+
AccessContract(
|
|
902
|
+
function='_cctally_core:open_db',
|
|
903
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS weekly_usage_snapshots ( id INTEGER PRIMARY KEY AUTOINCREMENT, captured_at_utc TEXT NOT NULL, week_start_date TEXT NOT NULL, week_end_date TEXT NOT NULL, week_start_at TEXT, week_end_at TEXT, weekly_percent REAL NOT NULL, page_url TEXT, source TEXT NOT NULL DEFAULT 'userscript', payload_json TEXT NOT NULL, account_key TEXT NOT NULL DEFAULT 'unattributed', weekly_observation_held INTEGER NOT NULL DEFAULT 0 CHECK (weekly_observation_held IN (0, 1)) )",
|
|
904
|
+
table='weekly_usage_snapshots',
|
|
905
|
+
keys=(),
|
|
906
|
+
predicate='',
|
|
907
|
+
ordering='',
|
|
908
|
+
selected=(),
|
|
909
|
+
effects='write',
|
|
910
|
+
classes=('singleton',),
|
|
911
|
+
inert_rule=MAINT,
|
|
912
|
+
),
|
|
913
|
+
AccessContract(
|
|
914
|
+
function='_cctally_core:open_db',
|
|
915
|
+
sql_fingerprint='CREATE TRIGGER IF NOT EXISTS trg_usage_snapshot_suppression AFTER DELETE ON weekly_usage_snapshots BEGIN INSERT OR IGNORE INTO usage_snapshot_suppressions (journal_id) SELECT OLD.journal_id WHERE OLD.journal_id IS NOT NULL; UPDATE percent_milestones SET usage_snapshot_id = 0 WHERE usage_snapshot_id = OLD.id; UPDATE five_hour_milestones SET usage_snapshot_id = 0 WHERE usage_snapshot_id = OLD.id; END',
|
|
916
|
+
table='usage_snapshot_suppressions',
|
|
917
|
+
keys=(),
|
|
918
|
+
predicate='',
|
|
919
|
+
ordering='',
|
|
920
|
+
selected=(),
|
|
921
|
+
effects='write',
|
|
922
|
+
classes=('singleton',),
|
|
923
|
+
inert_rule=MAINT,
|
|
924
|
+
),
|
|
925
|
+
AccessContract(
|
|
926
|
+
function='_cctally_core:open_db',
|
|
927
|
+
sql_fingerprint='CREATE UNIQUE INDEX IF NOT EXISTS idx_week_reset_events_legacy_tuple ON week_reset_events(account_key, old_week_end_at, new_week_end_at) WHERE origin_observation_id IS NULL',
|
|
928
|
+
table='week_reset_events',
|
|
929
|
+
keys=(),
|
|
930
|
+
predicate='origin_observation_id IS NULL',
|
|
931
|
+
ordering='',
|
|
932
|
+
selected=(),
|
|
933
|
+
effects='write',
|
|
934
|
+
classes=('singleton',),
|
|
935
|
+
inert_rule=MAINT,
|
|
936
|
+
),
|
|
937
|
+
AccessContract(
|
|
938
|
+
function='_cctally_core:open_db',
|
|
939
|
+
sql_fingerprint='CREATE UNIQUE INDEX IF NOT EXISTS idx_week_reset_events_origin ON week_reset_events(account_key, origin_observation_id) WHERE origin_observation_id IS NOT NULL',
|
|
940
|
+
table='week_reset_events',
|
|
941
|
+
keys=(),
|
|
942
|
+
predicate='origin_observation_id IS NOT NULL',
|
|
943
|
+
ordering='',
|
|
944
|
+
selected=(),
|
|
945
|
+
effects='write',
|
|
946
|
+
classes=('singleton',),
|
|
947
|
+
inert_rule=MAINT,
|
|
948
|
+
),
|
|
949
|
+
AccessContract(
|
|
950
|
+
function='_cctally_core:open_db',
|
|
951
|
+
sql_fingerprint='SELECT 1 FROM five_hour_blocks LIMIT 1',
|
|
952
|
+
table='five_hour_blocks',
|
|
953
|
+
keys=(),
|
|
954
|
+
predicate='',
|
|
955
|
+
ordering='',
|
|
956
|
+
selected=('1',),
|
|
957
|
+
effects='read',
|
|
958
|
+
classes=('cross-period',),
|
|
959
|
+
inert_rule=MAINT,
|
|
960
|
+
),
|
|
961
|
+
AccessContract(
|
|
962
|
+
function='_cctally_core:open_db',
|
|
963
|
+
sql_fingerprint='SELECT 1 FROM weekly_usage_snapshots WHERE five_hour_resets_at IS NOT NULL AND five_hour_window_key IS NULL LIMIT 1',
|
|
964
|
+
table='weekly_usage_snapshots',
|
|
965
|
+
keys=(),
|
|
966
|
+
predicate='five_hour_resets_at IS NOT NULL AND five_hour_window_key IS NULL',
|
|
967
|
+
ordering='',
|
|
968
|
+
selected=('1',),
|
|
969
|
+
effects='read',
|
|
970
|
+
classes=('cross-period',),
|
|
971
|
+
inert_rule=MAINT,
|
|
972
|
+
),
|
|
973
|
+
AccessContract(
|
|
974
|
+
function='_cctally_core:open_db',
|
|
975
|
+
sql_fingerprint='SELECT 1 FROM weekly_usage_snapshots WHERE five_hour_window_key IS NOT NULL AND five_hour_percent IS NOT NULL LIMIT 1',
|
|
976
|
+
table='weekly_usage_snapshots',
|
|
977
|
+
keys=(),
|
|
978
|
+
predicate='five_hour_window_key IS NOT NULL AND five_hour_percent IS NOT NULL',
|
|
979
|
+
ordering='',
|
|
980
|
+
selected=('1',),
|
|
981
|
+
effects='read',
|
|
982
|
+
classes=('cross-period',),
|
|
983
|
+
inert_rule=MAINT,
|
|
984
|
+
),
|
|
985
|
+
AccessContract(
|
|
986
|
+
function='_cctally_core:open_db',
|
|
987
|
+
sql_fingerprint='SELECT id, five_hour_resets_at FROM weekly_usage_snapshots WHERE five_hour_resets_at IS NOT NULL AND five_hour_window_key IS NULL',
|
|
988
|
+
table='weekly_usage_snapshots',
|
|
989
|
+
keys=(),
|
|
990
|
+
predicate='five_hour_resets_at IS NOT NULL AND five_hour_window_key IS NULL',
|
|
991
|
+
ordering='',
|
|
992
|
+
selected=('id', 'five_hour_resets_at'),
|
|
993
|
+
effects='read',
|
|
994
|
+
classes=('cross-period',),
|
|
995
|
+
inert_rule=MAINT,
|
|
996
|
+
),
|
|
997
|
+
AccessContract(
|
|
998
|
+
function='_cctally_core:open_db',
|
|
999
|
+
sql_fingerprint='SELECT name FROM schema_migrations_skipped',
|
|
1000
|
+
table='schema_migrations_skipped',
|
|
1001
|
+
keys=(),
|
|
1002
|
+
predicate='',
|
|
1003
|
+
ordering='',
|
|
1004
|
+
selected=('name',),
|
|
1005
|
+
effects='read',
|
|
1006
|
+
classes=('cross-period',),
|
|
1007
|
+
inert_rule=MAINT,
|
|
1008
|
+
),
|
|
1009
|
+
AccessContract(
|
|
1010
|
+
function='_cctally_core:open_db',
|
|
1011
|
+
sql_fingerprint='UPDATE journal_cursor SET applied_segment = segment, applied_offset = offset WHERE applied_segment IS NULL AND applied_offset IS NULL',
|
|
1012
|
+
table='journal_cursor',
|
|
1013
|
+
keys=(),
|
|
1014
|
+
predicate='applied_segment IS NULL AND applied_offset IS NULL',
|
|
1015
|
+
ordering='',
|
|
1016
|
+
selected=(),
|
|
1017
|
+
effects='write',
|
|
1018
|
+
classes=('singleton',),
|
|
1019
|
+
inert_rule=MAINT,
|
|
1020
|
+
),
|
|
1021
|
+
AccessContract(
|
|
1022
|
+
function='_cctally_core:open_db',
|
|
1023
|
+
sql_fingerprint='UPDATE weekly_usage_snapshots SET five_hour_window_key = ? WHERE id = ?',
|
|
1024
|
+
table='weekly_usage_snapshots',
|
|
1025
|
+
keys=('id',),
|
|
1026
|
+
predicate='id = ?',
|
|
1027
|
+
ordering='',
|
|
1028
|
+
selected=(),
|
|
1029
|
+
effects='write',
|
|
1030
|
+
classes=('singleton',),
|
|
1031
|
+
inert_rule=MAINT,
|
|
1032
|
+
),
|
|
1033
|
+
AccessContract(
|
|
1034
|
+
function='_cctally_core:open_db',
|
|
1035
|
+
sql_fingerprint='dynamic:_cctally_core:open_db#1',
|
|
1036
|
+
sql_shape='sha256:fccb556342da9ffa',
|
|
1037
|
+
table='dynamic',
|
|
1038
|
+
keys=(),
|
|
1039
|
+
predicate='dynamic SQL',
|
|
1040
|
+
ordering='',
|
|
1041
|
+
selected=(),
|
|
1042
|
+
effects='read',
|
|
1043
|
+
classes=('cross-period',),
|
|
1044
|
+
inert_rule=MAINT,
|
|
1045
|
+
),
|
|
1046
|
+
AccessContract(
|
|
1047
|
+
function='_cctally_core:open_db',
|
|
1048
|
+
sql_fingerprint='dynamic:_cctally_core:open_db#2',
|
|
1049
|
+
sql_shape='sha256:4422797e3a6480ba',
|
|
1050
|
+
table='dynamic',
|
|
1051
|
+
keys=(),
|
|
1052
|
+
predicate='dynamic SQL',
|
|
1053
|
+
ordering='',
|
|
1054
|
+
selected=(),
|
|
1055
|
+
effects='read',
|
|
1056
|
+
classes=('cross-period',),
|
|
1057
|
+
inert_rule=MAINT,
|
|
1058
|
+
),
|
|
1059
|
+
AccessContract(
|
|
1060
|
+
function='_cctally_core:open_db',
|
|
1061
|
+
sql_fingerprint='dynamic:_cctally_core:open_db#3',
|
|
1062
|
+
sql_shape='sha256:63e58c7c98c1aa20',
|
|
1063
|
+
table='dynamic',
|
|
1064
|
+
keys=(),
|
|
1065
|
+
predicate='dynamic SQL',
|
|
1066
|
+
ordering='',
|
|
1067
|
+
selected=(),
|
|
1068
|
+
effects='read',
|
|
1069
|
+
classes=('cross-period',),
|
|
1070
|
+
inert_rule=MAINT,
|
|
1071
|
+
),
|
|
1072
|
+
AccessContract(
|
|
1073
|
+
function='_cctally_core:weekly_held_exclusion',
|
|
1074
|
+
sql_fingerprint='PRAGMA table_info(weekly_usage_snapshots)',
|
|
1075
|
+
table='weekly_usage_snapshots',
|
|
1076
|
+
keys=(),
|
|
1077
|
+
predicate='',
|
|
1078
|
+
ordering='',
|
|
1079
|
+
selected=(),
|
|
1080
|
+
effects='read',
|
|
1081
|
+
classes=('cross-period',),
|
|
1082
|
+
inert_rule=MAINT,
|
|
1083
|
+
),
|
|
1084
|
+
AccessContract(
|
|
1085
|
+
function='_cctally_forecast:_apply_midweek_reset_override',
|
|
1086
|
+
sql_fingerprint='SELECT effective_reset_at_utc FROM week_reset_events WHERE new_week_end_at = ? AND datetime(detected_at_utc) <= datetime(?) ORDER BY datetime(detected_at_utc) DESC LIMIT 1',
|
|
1087
|
+
table='week_reset_events',
|
|
1088
|
+
keys=('new_week_end_at',),
|
|
1089
|
+
predicate='new_week_end_at = ? AND datetime(detected_at_utc) <= datetime(?)',
|
|
1090
|
+
ordering='datetime(detected_at_utc) DESC',
|
|
1091
|
+
selected=('effective_reset_at_utc',),
|
|
1092
|
+
effects='read',
|
|
1093
|
+
classes=('period-keyed', 'range-keyed'),
|
|
1094
|
+
inert_rule=Q7,
|
|
1095
|
+
),
|
|
1096
|
+
AccessContract(
|
|
1097
|
+
function='_cctally_forecast:_fetch_current_week_snapshots',
|
|
1098
|
+
sql_fingerprint='dynamic:_cctally_forecast:_fetch_current_week_snapshots#1',
|
|
1099
|
+
sql_shape='sha256:bc82aa15fa1aa9ed',
|
|
1100
|
+
table='dynamic',
|
|
1101
|
+
keys=(),
|
|
1102
|
+
predicate='dynamic SQL',
|
|
1103
|
+
ordering='',
|
|
1104
|
+
selected=(),
|
|
1105
|
+
effects='read',
|
|
1106
|
+
classes=('cross-period',),
|
|
1107
|
+
inert_rule=Q7,
|
|
1108
|
+
),
|
|
1109
|
+
AccessContract(
|
|
1110
|
+
function='_cctally_forecast:_fetch_current_week_snapshots',
|
|
1111
|
+
sql_fingerprint='dynamic:_cctally_forecast:_fetch_current_week_snapshots#2',
|
|
1112
|
+
sql_shape='sha256:372400419fad0c9e',
|
|
1113
|
+
table='dynamic',
|
|
1114
|
+
keys=(),
|
|
1115
|
+
predicate='dynamic SQL',
|
|
1116
|
+
ordering='',
|
|
1117
|
+
selected=(),
|
|
1118
|
+
effects='read',
|
|
1119
|
+
classes=('cross-period',),
|
|
1120
|
+
inert_rule=Q7,
|
|
1121
|
+
),
|
|
1122
|
+
AccessContract(
|
|
1123
|
+
function='_cctally_forecast:_fetch_current_week_snapshots',
|
|
1124
|
+
sql_fingerprint='dynamic:_cctally_forecast:_fetch_current_week_snapshots#3',
|
|
1125
|
+
sql_shape='sha256:4f8ce3420819f7e2',
|
|
1126
|
+
table='dynamic',
|
|
1127
|
+
keys=(),
|
|
1128
|
+
predicate='dynamic SQL',
|
|
1129
|
+
ordering='',
|
|
1130
|
+
selected=(),
|
|
1131
|
+
effects='read',
|
|
1132
|
+
classes=('cross-period',),
|
|
1133
|
+
inert_rule=Q7,
|
|
1134
|
+
),
|
|
1135
|
+
AccessContract(
|
|
1136
|
+
function='_cctally_forecast:_fetch_current_week_snapshots',
|
|
1137
|
+
sql_fingerprint='dynamic:_cctally_forecast:_fetch_current_week_snapshots#4',
|
|
1138
|
+
sql_shape='sha256:61d729e93a7eeffe',
|
|
1139
|
+
table='dynamic',
|
|
1140
|
+
keys=(),
|
|
1141
|
+
predicate='dynamic SQL',
|
|
1142
|
+
ordering='',
|
|
1143
|
+
selected=(),
|
|
1144
|
+
effects='read',
|
|
1145
|
+
classes=('cross-period',),
|
|
1146
|
+
inert_rule=Q7,
|
|
1147
|
+
),
|
|
1148
|
+
AccessContract(
|
|
1149
|
+
function='_cctally_journal:_apply_account_last_seen',
|
|
1150
|
+
sql_fingerprint='UPDATE accounts SET last_seen_utc = ? WHERE account_key = ? AND (last_seen_utc IS NULL OR ? > last_seen_utc)',
|
|
1151
|
+
table='accounts',
|
|
1152
|
+
keys=('account_key',),
|
|
1153
|
+
predicate='account_key = ? AND (last_seen_utc IS NULL OR ? > last_seen_utc)',
|
|
1154
|
+
ordering='',
|
|
1155
|
+
selected=(),
|
|
1156
|
+
effects='write',
|
|
1157
|
+
classes=('singleton', 'range-keyed'),
|
|
1158
|
+
inert_rule=ACCOUNTS,
|
|
1159
|
+
),
|
|
1160
|
+
AccessContract(
|
|
1161
|
+
function='_cctally_journal:_apply_quota_records',
|
|
1162
|
+
sql_fingerprint='dynamic:_cctally_journal:_apply_quota_records#1',
|
|
1163
|
+
sql_shape='sha256:8e0e66814fdb3614',
|
|
1164
|
+
table='dynamic',
|
|
1165
|
+
keys=(),
|
|
1166
|
+
predicate='dynamic SQL',
|
|
1167
|
+
ordering='',
|
|
1168
|
+
selected=(),
|
|
1169
|
+
effects='read',
|
|
1170
|
+
classes=('cross-period',),
|
|
1171
|
+
inert_rule=CODEX,
|
|
1172
|
+
),
|
|
1173
|
+
AccessContract(
|
|
1174
|
+
function='_cctally_journal:_apply_quota_records',
|
|
1175
|
+
sql_fingerprint='dynamic:_cctally_journal:_apply_quota_records#2',
|
|
1176
|
+
sql_shape='sha256:e6027d234f49f83b',
|
|
1177
|
+
table='dynamic',
|
|
1178
|
+
keys=(),
|
|
1179
|
+
predicate='dynamic SQL',
|
|
1180
|
+
ordering='',
|
|
1181
|
+
selected=(),
|
|
1182
|
+
effects='read',
|
|
1183
|
+
classes=('cross-period',),
|
|
1184
|
+
inert_rule=CODEX,
|
|
1185
|
+
),
|
|
1186
|
+
AccessContract(
|
|
1187
|
+
function='_cctally_journal:_backfill_meter_rate_change_evidence',
|
|
1188
|
+
sql_fingerprint='UPDATE meter_rate_change_events SET withholding_status = COALESCE(withholding_status, ?), detector_input_causes = COALESCE(detector_input_causes, ?), composition_provenance = COALESCE(composition_provenance, ?), baseline_withheld_days = COALESCE(baseline_withheld_days, ?) WHERE provider = ? AND account_key = ? AND effective_from = ?',
|
|
1189
|
+
table='meter_rate_change_events',
|
|
1190
|
+
keys=('provider', 'account_key', 'effective_from'),
|
|
1191
|
+
predicate='provider = ? AND account_key = ? AND effective_from = ?',
|
|
1192
|
+
ordering='',
|
|
1193
|
+
selected=(),
|
|
1194
|
+
effects='write',
|
|
1195
|
+
classes=('singleton',),
|
|
1196
|
+
inert_rule=JOURNAL,
|
|
1197
|
+
),
|
|
1198
|
+
AccessContract(
|
|
1199
|
+
function='_cctally_journal:_build_harvest_evt',
|
|
1200
|
+
sql_fingerprint='dynamic:_cctally_journal:_build_harvest_evt#1',
|
|
1201
|
+
sql_shape='sha256:be6d8235005bc42f',
|
|
1202
|
+
table='dynamic',
|
|
1203
|
+
keys=(),
|
|
1204
|
+
predicate='dynamic SQL',
|
|
1205
|
+
ordering='',
|
|
1206
|
+
selected=(),
|
|
1207
|
+
effects='read',
|
|
1208
|
+
classes=('cross-period',),
|
|
1209
|
+
inert_rule=JOURNAL,
|
|
1210
|
+
),
|
|
1211
|
+
AccessContract(
|
|
1212
|
+
function='_cctally_journal:_keep_five_hour_retirement',
|
|
1213
|
+
sql_fingerprint='SELECT 1 FROM five_hour_reset_events WHERE account_key = ? AND five_hour_window_key = ? AND unixepoch(effective_reset_at_utc) <= unixepoch(?) LIMIT 1',
|
|
1214
|
+
table='five_hour_reset_events',
|
|
1215
|
+
keys=('account_key', 'five_hour_window_key'),
|
|
1216
|
+
predicate='account_key = ? AND five_hour_window_key = ? AND unixepoch(effective_reset_at_utc) <= unixepoch(?)',
|
|
1217
|
+
ordering='',
|
|
1218
|
+
selected=('1',),
|
|
1219
|
+
effects='read',
|
|
1220
|
+
classes=('period-keyed', 'range-keyed'),
|
|
1221
|
+
inert_rule=None,
|
|
1222
|
+
),
|
|
1223
|
+
AccessContract(
|
|
1224
|
+
function='_cctally_journal:_keep_five_hour_retirement',
|
|
1225
|
+
sql_fingerprint='SELECT five_hour_percent, five_hour_resets_at, five_hour_window_key, weekly_observation_held FROM weekly_usage_snapshots WHERE id = ?',
|
|
1226
|
+
table='weekly_usage_snapshots',
|
|
1227
|
+
keys=('id',),
|
|
1228
|
+
predicate='id = ?',
|
|
1229
|
+
ordering='',
|
|
1230
|
+
selected=('five_hour_percent', 'five_hour_resets_at', 'five_hour_window_key', 'weekly_observation_held'),
|
|
1231
|
+
effects='read',
|
|
1232
|
+
classes=('period-keyed',),
|
|
1233
|
+
inert_rule=JOURNAL,
|
|
1234
|
+
),
|
|
1235
|
+
AccessContract(
|
|
1236
|
+
function='_cctally_journal:_keep_weekly_retirement',
|
|
1237
|
+
sql_fingerprint='SELECT weekly_observation_held, five_hour_percent, five_hour_resets_at FROM weekly_usage_snapshots WHERE id = ?',
|
|
1238
|
+
table='weekly_usage_snapshots',
|
|
1239
|
+
keys=('id',),
|
|
1240
|
+
predicate='id = ?',
|
|
1241
|
+
ordering='',
|
|
1242
|
+
selected=('weekly_observation_held', 'five_hour_percent', 'five_hour_resets_at'),
|
|
1243
|
+
effects='read',
|
|
1244
|
+
classes=('period-keyed',),
|
|
1245
|
+
inert_rule=JOURNAL,
|
|
1246
|
+
),
|
|
1247
|
+
AccessContract(
|
|
1248
|
+
function='_cctally_journal:_keep_weekly_retirement',
|
|
1249
|
+
sql_fingerprint='SELECT effective_reset_at_utc, observed_pre_credit_pct FROM week_reset_events WHERE account_key = ? AND new_week_end_at = ? AND observed_pre_credit_pct IS NOT NULL',
|
|
1250
|
+
table='week_reset_events',
|
|
1251
|
+
keys=('account_key', 'new_week_end_at'),
|
|
1252
|
+
predicate='account_key = ? AND new_week_end_at = ? AND observed_pre_credit_pct IS NOT NULL',
|
|
1253
|
+
ordering='',
|
|
1254
|
+
selected=('effective_reset_at_utc', 'observed_pre_credit_pct'),
|
|
1255
|
+
effects='read',
|
|
1256
|
+
classes=('period-keyed',),
|
|
1257
|
+
inert_rule=None,
|
|
1258
|
+
),
|
|
1259
|
+
AccessContract(
|
|
1260
|
+
function='_cctally_journal:_keep_weekly_retirement',
|
|
1261
|
+
sql_fingerprint='SELECT effective_at_utc, observed_pre_credit_pct FROM weekly_credit_floors WHERE week_start_date = ? AND account_key = ? AND observed_pre_credit_pct IS NOT NULL',
|
|
1262
|
+
table='weekly_credit_floors',
|
|
1263
|
+
keys=('week_start_date', 'account_key'),
|
|
1264
|
+
predicate='week_start_date = ? AND account_key = ? AND observed_pre_credit_pct IS NOT NULL',
|
|
1265
|
+
ordering='',
|
|
1266
|
+
selected=('effective_at_utc', 'observed_pre_credit_pct'),
|
|
1267
|
+
effects='read',
|
|
1268
|
+
classes=('period-keyed',),
|
|
1269
|
+
inert_rule=None,
|
|
1270
|
+
),
|
|
1271
|
+
AccessContract(
|
|
1272
|
+
function='_cctally_journal:_converge_row_from_effective',
|
|
1273
|
+
sql_fingerprint='SELECT account_key, five_hour_window_key FROM five_hour_blocks WHERE id = ?',
|
|
1274
|
+
table='five_hour_blocks',
|
|
1275
|
+
keys=('id',),
|
|
1276
|
+
predicate='id = ?',
|
|
1277
|
+
ordering='',
|
|
1278
|
+
selected=('account_key', 'five_hour_window_key'),
|
|
1279
|
+
effects='read',
|
|
1280
|
+
classes=('period-keyed',),
|
|
1281
|
+
inert_rule=JOURNAL,
|
|
1282
|
+
),
|
|
1283
|
+
AccessContract(
|
|
1284
|
+
function='_cctally_journal:_converge_row_from_effective',
|
|
1285
|
+
sql_fingerprint='dynamic:_cctally_journal:_converge_row_from_effective#1',
|
|
1286
|
+
sql_shape='sha256:87a7fa0212f80043',
|
|
1287
|
+
table='dynamic',
|
|
1288
|
+
keys=(),
|
|
1289
|
+
predicate='dynamic SQL',
|
|
1290
|
+
ordering='',
|
|
1291
|
+
selected=(),
|
|
1292
|
+
effects='read',
|
|
1293
|
+
classes=('cross-period',),
|
|
1294
|
+
inert_rule=JOURNAL,
|
|
1295
|
+
),
|
|
1296
|
+
AccessContract(
|
|
1297
|
+
function='_cctally_journal:_converge_row_from_effective',
|
|
1298
|
+
sql_fingerprint='dynamic:_cctally_journal:_converge_row_from_effective#2',
|
|
1299
|
+
sql_shape='sha256:b723310f1bacf1af',
|
|
1300
|
+
table='dynamic',
|
|
1301
|
+
keys=(),
|
|
1302
|
+
predicate='dynamic SQL',
|
|
1303
|
+
ordering='',
|
|
1304
|
+
selected=(),
|
|
1305
|
+
effects='read',
|
|
1306
|
+
classes=('cross-period',),
|
|
1307
|
+
inert_rule=JOURNAL,
|
|
1308
|
+
),
|
|
1309
|
+
AccessContract(
|
|
1310
|
+
function='_cctally_journal:_correction_index_converged',
|
|
1311
|
+
sql_fingerprint='SELECT rev, status, content_hash, batch_id FROM journal_effective_events WHERE event_id = ?',
|
|
1312
|
+
table='journal_effective_events',
|
|
1313
|
+
keys=('event_id',),
|
|
1314
|
+
predicate='event_id = ?',
|
|
1315
|
+
ordering='',
|
|
1316
|
+
selected=('rev', 'status', 'content_hash', 'batch_id'),
|
|
1317
|
+
effects='read',
|
|
1318
|
+
classes=('period-keyed',),
|
|
1319
|
+
inert_rule=MAINT,
|
|
1320
|
+
),
|
|
1321
|
+
AccessContract(
|
|
1322
|
+
function='_cctally_journal:_derived_fk_value',
|
|
1323
|
+
sql_fingerprint='dynamic:_cctally_journal:_derived_fk_value#1',
|
|
1324
|
+
sql_shape='sha256:5ddb375652a6e6e8',
|
|
1325
|
+
table='dynamic',
|
|
1326
|
+
keys=(),
|
|
1327
|
+
predicate='dynamic SQL',
|
|
1328
|
+
ordering='',
|
|
1329
|
+
selected=(),
|
|
1330
|
+
effects='read',
|
|
1331
|
+
classes=('cross-period',),
|
|
1332
|
+
inert_rule=JOURNAL,
|
|
1333
|
+
),
|
|
1334
|
+
AccessContract(
|
|
1335
|
+
function='_cctally_journal:_derived_fk_value',
|
|
1336
|
+
sql_fingerprint='dynamic:_cctally_journal:_derived_fk_value#2',
|
|
1337
|
+
sql_shape='sha256:876b10f37733a663',
|
|
1338
|
+
table='dynamic',
|
|
1339
|
+
keys=(),
|
|
1340
|
+
predicate='dynamic SQL',
|
|
1341
|
+
ordering='',
|
|
1342
|
+
selected=(),
|
|
1343
|
+
effects='read',
|
|
1344
|
+
classes=('cross-period',),
|
|
1345
|
+
inert_rule=JOURNAL,
|
|
1346
|
+
),
|
|
1347
|
+
AccessContract(
|
|
1348
|
+
function='_cctally_journal:_effective_event_for_convergence',
|
|
1349
|
+
sql_fingerprint='SELECT rev, status, content_hash, event_json FROM journal_effective_events WHERE event_id = ?',
|
|
1350
|
+
table='journal_effective_events',
|
|
1351
|
+
keys=('event_id',),
|
|
1352
|
+
predicate='event_id = ?',
|
|
1353
|
+
ordering='',
|
|
1354
|
+
selected=('rev', 'status', 'content_hash', 'event_json'),
|
|
1355
|
+
effects='read',
|
|
1356
|
+
classes=('period-keyed',),
|
|
1357
|
+
inert_rule=JOURNAL,
|
|
1358
|
+
),
|
|
1359
|
+
AccessContract(
|
|
1360
|
+
function='_cctally_journal:_emit_harvest_row',
|
|
1361
|
+
sql_fingerprint='dynamic:_cctally_journal:_emit_harvest_row#1',
|
|
1362
|
+
sql_shape='sha256:36b3715496826795',
|
|
1363
|
+
table='dynamic',
|
|
1364
|
+
keys=(),
|
|
1365
|
+
predicate='dynamic SQL',
|
|
1366
|
+
ordering='',
|
|
1367
|
+
selected=(),
|
|
1368
|
+
effects='read',
|
|
1369
|
+
classes=('cross-period',),
|
|
1370
|
+
inert_rule=JOURNAL,
|
|
1371
|
+
),
|
|
1372
|
+
AccessContract(
|
|
1373
|
+
function='_cctally_journal:_emit_harvest_row',
|
|
1374
|
+
sql_fingerprint='dynamic:_cctally_journal:_emit_harvest_row#2',
|
|
1375
|
+
sql_shape='sha256:36b3715496826795',
|
|
1376
|
+
table='dynamic',
|
|
1377
|
+
keys=(),
|
|
1378
|
+
predicate='dynamic SQL',
|
|
1379
|
+
ordering='',
|
|
1380
|
+
selected=(),
|
|
1381
|
+
effects='read',
|
|
1382
|
+
classes=('cross-period',),
|
|
1383
|
+
inert_rule=JOURNAL,
|
|
1384
|
+
),
|
|
1385
|
+
AccessContract(
|
|
1386
|
+
# #825/#832 fix round E: a derivation-completion scratch replay
|
|
1387
|
+
# removes the one row a retained tombstone says does not exist, on
|
|
1388
|
+
# the replay's PRIVATE projection, by its physical id; the table is
|
|
1389
|
+
# a journal family's own (`_HARVEST_SPECS`/`_EVT_SPECS`).
|
|
1390
|
+
function='_cctally_journal:_delete_scratch_row',
|
|
1391
|
+
sql_fingerprint='dynamic:_cctally_journal:_delete_scratch_row#1',
|
|
1392
|
+
sql_shape='sha256:25eb83cb79df6e1e',
|
|
1393
|
+
table='dynamic',
|
|
1394
|
+
keys=('id',),
|
|
1395
|
+
predicate='id = ? on a scratch projection (a journal family table)',
|
|
1396
|
+
ordering='',
|
|
1397
|
+
selected=(),
|
|
1398
|
+
effects='delete',
|
|
1399
|
+
classes=('singleton',),
|
|
1400
|
+
inert_rule=JOURNAL,
|
|
1401
|
+
),
|
|
1402
|
+
AccessContract(
|
|
1403
|
+
function='_cctally_journal:_full_taint_transition',
|
|
1404
|
+
sql_fingerprint='SELECT DISTINCT batch_id FROM journal_effective_events WHERE batch_id IS NOT NULL',
|
|
1405
|
+
table='journal_effective_events',
|
|
1406
|
+
keys=(),
|
|
1407
|
+
predicate='batch_id IS NOT NULL',
|
|
1408
|
+
ordering='',
|
|
1409
|
+
selected=('DISTINCT batch_id',),
|
|
1410
|
+
effects='read',
|
|
1411
|
+
classes=('cross-period',),
|
|
1412
|
+
inert_rule=MAINT,
|
|
1413
|
+
),
|
|
1414
|
+
AccessContract(
|
|
1415
|
+
function='_cctally_journal:_harvest',
|
|
1416
|
+
sql_fingerprint='dynamic:_cctally_journal:_harvest#1',
|
|
1417
|
+
sql_shape='sha256:3e35b6ce53d6446a',
|
|
1418
|
+
table='dynamic',
|
|
1419
|
+
keys=(),
|
|
1420
|
+
predicate='dynamic SQL',
|
|
1421
|
+
ordering='',
|
|
1422
|
+
selected=(),
|
|
1423
|
+
effects='read',
|
|
1424
|
+
classes=('cross-period',),
|
|
1425
|
+
inert_rule=JOURNAL,
|
|
1426
|
+
),
|
|
1427
|
+
AccessContract(
|
|
1428
|
+
function='_cctally_journal:_insert_effective_metadata',
|
|
1429
|
+
sql_fingerprint='INSERT INTO journal_effective_events (event_id, rev, status, content_hash, batch_id, event_json) VALUES (?, ?, ?, ?, ?, ?)',
|
|
1430
|
+
table='journal_effective_events',
|
|
1431
|
+
keys=(),
|
|
1432
|
+
predicate='',
|
|
1433
|
+
ordering='',
|
|
1434
|
+
selected=(),
|
|
1435
|
+
effects='write',
|
|
1436
|
+
classes=('singleton',),
|
|
1437
|
+
inert_rule=JOURNAL,
|
|
1438
|
+
),
|
|
1439
|
+
AccessContract(
|
|
1440
|
+
function='_cctally_journal:_insert_meter_rate_change',
|
|
1441
|
+
sql_fingerprint='dynamic:_cctally_journal:_insert_meter_rate_change#1',
|
|
1442
|
+
sql_shape='sha256:f0289da5c72e9295',
|
|
1443
|
+
table='dynamic',
|
|
1444
|
+
keys=(),
|
|
1445
|
+
predicate='dynamic SQL',
|
|
1446
|
+
ordering='',
|
|
1447
|
+
selected=(),
|
|
1448
|
+
effects='read',
|
|
1449
|
+
classes=('cross-period',),
|
|
1450
|
+
inert_rule=JOURNAL,
|
|
1451
|
+
),
|
|
1452
|
+
AccessContract(
|
|
1453
|
+
function='_cctally_journal:_insert_or_ignore',
|
|
1454
|
+
sql_fingerprint='dynamic:_cctally_journal:_insert_or_ignore#1',
|
|
1455
|
+
sql_shape='sha256:ddf39d7c6c26c825',
|
|
1456
|
+
table='dynamic',
|
|
1457
|
+
keys=(),
|
|
1458
|
+
predicate='dynamic SQL',
|
|
1459
|
+
ordering='',
|
|
1460
|
+
selected=(),
|
|
1461
|
+
effects='read',
|
|
1462
|
+
classes=('cross-period',),
|
|
1463
|
+
inert_rule=JOURNAL,
|
|
1464
|
+
),
|
|
1465
|
+
AccessContract(
|
|
1466
|
+
function='_cctally_journal:_latest_weekly_basis',
|
|
1467
|
+
sql_fingerprint='dynamic:_cctally_journal:_latest_weekly_basis#1',
|
|
1468
|
+
sql_shape='sha256:de026ae7c7c1f17e',
|
|
1469
|
+
table='dynamic',
|
|
1470
|
+
keys=(),
|
|
1471
|
+
predicate='dynamic SQL',
|
|
1472
|
+
ordering='',
|
|
1473
|
+
selected=(),
|
|
1474
|
+
effects='read',
|
|
1475
|
+
classes=('cross-period',),
|
|
1476
|
+
inert_rule=BASIS,
|
|
1477
|
+
),
|
|
1478
|
+
AccessContract(
|
|
1479
|
+
function='_cctally_journal:_metadata_event_record',
|
|
1480
|
+
sql_fingerprint='SELECT event_json FROM journal_effective_events WHERE event_id = ?',
|
|
1481
|
+
table='journal_effective_events',
|
|
1482
|
+
keys=('event_id',),
|
|
1483
|
+
predicate='event_id = ?',
|
|
1484
|
+
ordering='',
|
|
1485
|
+
selected=('event_json',),
|
|
1486
|
+
effects='read',
|
|
1487
|
+
classes=('period-keyed',),
|
|
1488
|
+
inert_rule=JOURNAL,
|
|
1489
|
+
),
|
|
1490
|
+
AccessContract(
|
|
1491
|
+
function='_cctally_journal:_metadata_row',
|
|
1492
|
+
sql_fingerprint='SELECT rev, status, content_hash, batch_id FROM journal_effective_events WHERE event_id = ?',
|
|
1493
|
+
table='journal_effective_events',
|
|
1494
|
+
keys=('event_id',),
|
|
1495
|
+
predicate='event_id = ?',
|
|
1496
|
+
ordering='',
|
|
1497
|
+
selected=('rev', 'status', 'content_hash', 'batch_id'),
|
|
1498
|
+
effects='read',
|
|
1499
|
+
classes=('period-keyed',),
|
|
1500
|
+
inert_rule=JOURNAL,
|
|
1501
|
+
),
|
|
1502
|
+
AccessContract(
|
|
1503
|
+
function='_cctally_journal:_prior_meter_rate_change_event',
|
|
1504
|
+
sql_fingerprint='SELECT status FROM journal_effective_events WHERE event_id = ?',
|
|
1505
|
+
table='journal_effective_events',
|
|
1506
|
+
keys=('event_id',),
|
|
1507
|
+
predicate='event_id = ?',
|
|
1508
|
+
ordering='',
|
|
1509
|
+
selected=('status',),
|
|
1510
|
+
effects='read',
|
|
1511
|
+
classes=('period-keyed',),
|
|
1512
|
+
inert_rule=JOURNAL,
|
|
1513
|
+
),
|
|
1514
|
+
AccessContract(
|
|
1515
|
+
function='_cctally_journal:_publish_generation_in_place',
|
|
1516
|
+
sql_fingerprint='DELETE FROM main.stats_publication_stamp',
|
|
1517
|
+
table='stats_publication_stamp',
|
|
1518
|
+
keys=(),
|
|
1519
|
+
predicate='',
|
|
1520
|
+
ordering='',
|
|
1521
|
+
selected=(),
|
|
1522
|
+
effects='delete',
|
|
1523
|
+
classes=('singleton',),
|
|
1524
|
+
inert_rule=MAINT,
|
|
1525
|
+
),
|
|
1526
|
+
AccessContract(
|
|
1527
|
+
function='_cctally_journal:_publish_generation_in_place',
|
|
1528
|
+
sql_fingerprint='INSERT INTO main.stats_publication_stamp (record_path, started_at_utc, stamped_at_utc) VALUES (?, ?, ?)',
|
|
1529
|
+
table='stats_publication_stamp',
|
|
1530
|
+
keys=(),
|
|
1531
|
+
predicate='',
|
|
1532
|
+
ordering='',
|
|
1533
|
+
selected=(),
|
|
1534
|
+
effects='write',
|
|
1535
|
+
classes=('singleton',),
|
|
1536
|
+
inert_rule=MAINT,
|
|
1537
|
+
),
|
|
1538
|
+
AccessContract(
|
|
1539
|
+
function='_cctally_journal:_publish_generation_in_place',
|
|
1540
|
+
sql_fingerprint="SELECT 1 FROM main.sqlite_schema WHERE type='table' AND name='journal_selector_state'",
|
|
1541
|
+
table='journal_selector_state',
|
|
1542
|
+
keys=(),
|
|
1543
|
+
predicate="type='table' AND name='journal_selector_state'",
|
|
1544
|
+
ordering='',
|
|
1545
|
+
selected=('1',),
|
|
1546
|
+
effects='read',
|
|
1547
|
+
classes=('cross-period',),
|
|
1548
|
+
inert_rule=MAINT,
|
|
1549
|
+
),
|
|
1550
|
+
AccessContract(
|
|
1551
|
+
function='_cctally_journal:_publish_generation_in_place',
|
|
1552
|
+
sql_fingerprint='UPDATE main.journal_selector_state SET generation_record_path = ?, generation_stamped_at_utc = ?',
|
|
1553
|
+
table='journal_selector_state',
|
|
1554
|
+
keys=(),
|
|
1555
|
+
predicate='',
|
|
1556
|
+
ordering='',
|
|
1557
|
+
selected=(),
|
|
1558
|
+
effects='write',
|
|
1559
|
+
classes=('singleton',),
|
|
1560
|
+
inert_rule=MAINT,
|
|
1561
|
+
),
|
|
1562
|
+
AccessContract(
|
|
1563
|
+
function='_cctally_journal:_publish_generation_in_place',
|
|
1564
|
+
sql_fingerprint='dynamic:_cctally_journal:_publish_generation_in_place#1',
|
|
1565
|
+
sql_shape='sha256:c03310d569d06566',
|
|
1566
|
+
table='dynamic',
|
|
1567
|
+
keys=(),
|
|
1568
|
+
predicate='dynamic SQL',
|
|
1569
|
+
ordering='',
|
|
1570
|
+
selected=(),
|
|
1571
|
+
effects='read',
|
|
1572
|
+
classes=('cross-period',),
|
|
1573
|
+
inert_rule=MAINT,
|
|
1574
|
+
),
|
|
1575
|
+
AccessContract(
|
|
1576
|
+
function='_cctally_journal:_publish_generation_in_place',
|
|
1577
|
+
sql_fingerprint='dynamic:_cctally_journal:_publish_generation_in_place#2',
|
|
1578
|
+
sql_shape='sha256:4c08ed64ebe47aa4',
|
|
1579
|
+
table='dynamic',
|
|
1580
|
+
keys=(),
|
|
1581
|
+
predicate='dynamic SQL',
|
|
1582
|
+
ordering='',
|
|
1583
|
+
selected=(),
|
|
1584
|
+
effects='read',
|
|
1585
|
+
classes=('cross-period',),
|
|
1586
|
+
inert_rule=MAINT,
|
|
1587
|
+
),
|
|
1588
|
+
AccessContract(
|
|
1589
|
+
function='_cctally_journal:_publish_generation_in_place',
|
|
1590
|
+
sql_fingerprint='dynamic:_cctally_journal:_publish_generation_in_place#3',
|
|
1591
|
+
sql_shape='sha256:4c08ed64ebe47aa4',
|
|
1592
|
+
table='dynamic',
|
|
1593
|
+
keys=(),
|
|
1594
|
+
predicate='dynamic SQL',
|
|
1595
|
+
ordering='',
|
|
1596
|
+
selected=(),
|
|
1597
|
+
effects='read',
|
|
1598
|
+
classes=('cross-period',),
|
|
1599
|
+
inert_rule=MAINT,
|
|
1600
|
+
),
|
|
1601
|
+
AccessContract(
|
|
1602
|
+
function='_cctally_journal:_publish_generation_in_place',
|
|
1603
|
+
sql_fingerprint='dynamic:_cctally_journal:_publish_generation_in_place#4',
|
|
1604
|
+
sql_shape='sha256:9fa2bbec8283329c',
|
|
1605
|
+
table='dynamic',
|
|
1606
|
+
keys=(),
|
|
1607
|
+
predicate='dynamic SQL',
|
|
1608
|
+
ordering='',
|
|
1609
|
+
selected=(),
|
|
1610
|
+
effects='read',
|
|
1611
|
+
classes=('cross-period',),
|
|
1612
|
+
inert_rule=MAINT,
|
|
1613
|
+
),
|
|
1614
|
+
AccessContract(
|
|
1615
|
+
function='_cctally_journal:_publish_generation_in_place',
|
|
1616
|
+
sql_fingerprint='dynamic:_cctally_journal:_publish_generation_in_place#5',
|
|
1617
|
+
sql_shape='sha256:4c08ed64ebe47aa4',
|
|
1618
|
+
table='dynamic',
|
|
1619
|
+
keys=(),
|
|
1620
|
+
predicate='dynamic SQL',
|
|
1621
|
+
ordering='',
|
|
1622
|
+
selected=(),
|
|
1623
|
+
effects='read',
|
|
1624
|
+
classes=('cross-period',),
|
|
1625
|
+
inert_rule=MAINT,
|
|
1626
|
+
),
|
|
1627
|
+
AccessContract(
|
|
1628
|
+
function='_cctally_journal:_read_admission_summary',
|
|
1629
|
+
sql_fingerprint='SELECT cutover_id, scanned_high_water, excluded_total, family_counts_json, first_excluded_coordinate, latest_excluded_coordinate, coordinate_digest, complete_through, boundary_json FROM journal_admission_summary WHERE id = 1',
|
|
1630
|
+
table='journal_admission_summary',
|
|
1631
|
+
keys=(),
|
|
1632
|
+
predicate='id = 1',
|
|
1633
|
+
ordering='',
|
|
1634
|
+
selected=('cutover_id', 'scanned_high_water', 'excluded_total', 'family_counts_json', 'first_excluded_coordinate', 'latest_excluded_coordinate', 'coordinate_digest', 'complete_through', 'boundary_json'),
|
|
1635
|
+
effects='read',
|
|
1636
|
+
classes=('cross-period',),
|
|
1637
|
+
inert_rule=JOURNAL,
|
|
1638
|
+
),
|
|
1639
|
+
AccessContract(
|
|
1640
|
+
function='_cctally_journal:_read_cursor',
|
|
1641
|
+
sql_fingerprint='SELECT segment, offset, applied_segment, applied_offset FROM journal_cursor WHERE id = 1',
|
|
1642
|
+
table='journal_cursor',
|
|
1643
|
+
keys=(),
|
|
1644
|
+
predicate='id = 1',
|
|
1645
|
+
ordering='',
|
|
1646
|
+
selected=('segment', 'offset', 'applied_segment', 'applied_offset'),
|
|
1647
|
+
effects='read',
|
|
1648
|
+
classes=('cross-period',),
|
|
1649
|
+
inert_rule=JOURNAL,
|
|
1650
|
+
),
|
|
1651
|
+
AccessContract(
|
|
1652
|
+
function='_cctally_journal:_read_selector_state',
|
|
1653
|
+
sql_fingerprint='SELECT generation_record_path, generation_stamped_at_utc, covered_segment, covered_offset, next_sequence, selector_version, cutover_seen, cutover_account_key FROM journal_selector_state',
|
|
1654
|
+
table='journal_selector_state',
|
|
1655
|
+
keys=(),
|
|
1656
|
+
predicate='',
|
|
1657
|
+
ordering='',
|
|
1658
|
+
selected=('generation_record_path', 'generation_stamped_at_utc', 'covered_segment', 'covered_offset', 'next_sequence', 'selector_version', 'cutover_seen', 'cutover_account_key'),
|
|
1659
|
+
effects='read',
|
|
1660
|
+
classes=('cross-period',),
|
|
1661
|
+
inert_rule=JOURNAL,
|
|
1662
|
+
),
|
|
1663
|
+
# Reviewed re-pin (#825/#832 fix round J4, #954): the closure's imported
|
|
1664
|
+
# producer `_backfill_five_hour_blocks` now takes the open block's boundary
|
|
1665
|
+
# row from a shared helper (the same MIN-captured SELECT, now also used by
|
|
1666
|
+
# the ownership pre-pass, which selects two more columns of the same row)
|
|
1667
|
+
# overridden by the producer's journaled first observation (pure Python,
|
|
1668
|
+
# `journaled_block_first_observations`), and its INSERT also writes
|
|
1669
|
+
# `pricing_provenance_json` through the new pure dependency
|
|
1670
|
+
# `_block_pricing_provenance_json` (the pricing snapshot date the closure
|
|
1671
|
+
# already reaches). The producer only passes that mapping. Table, keys,
|
|
1672
|
+
# predicates, ordering and effects of this maintenance rebuild site are
|
|
1673
|
+
# unchanged, so the contract and its MAINT inert rule stand.
|
|
1674
|
+
# Reviewed re-pin (#825/#832 fix round J5, 825-832-CD4-V01): the boundary
|
|
1675
|
+
# row helper now returns the producer's first-writer mapping whenever it
|
|
1676
|
+
# holds the window, and runs the same MIN-captured SELECT (text, table,
|
|
1677
|
+
# predicate and ordering unchanged) only as the fallback; the producer now
|
|
1678
|
+
# passes the decoded prefix and its effective `by_id` to the pure helper,
|
|
1679
|
+
# which orders decisions by first appearance. No SQL was added or changed,
|
|
1680
|
+
# so the contract and its MAINT inert rule stand.
|
|
1681
|
+
AccessContract(
|
|
1682
|
+
function='_cctally_journal:_rebuild_stats_index_locked',
|
|
1683
|
+
sql_fingerprint='dynamic:_cctally_journal:_rebuild_stats_index_locked#1',
|
|
1684
|
+
sql_shape='sha256:043784567bb14b97',
|
|
1685
|
+
table='dynamic',
|
|
1686
|
+
keys=(),
|
|
1687
|
+
predicate='dynamic SQL',
|
|
1688
|
+
ordering='',
|
|
1689
|
+
selected=(),
|
|
1690
|
+
effects='read',
|
|
1691
|
+
classes=('cross-period',),
|
|
1692
|
+
inert_rule=MAINT,
|
|
1693
|
+
),
|
|
1694
|
+
AccessContract(
|
|
1695
|
+
function='_cctally_core:open_db',
|
|
1696
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS journal_derivation_frontier (id INTEGER PRIMARY KEY CHECK (id = 1), segment TEXT NOT NULL, offset INTEGER NOT NULL, output_segment TEXT, output_offset INTEGER)',
|
|
1697
|
+
table='journal_derivation_frontier',
|
|
1698
|
+
keys=(),
|
|
1699
|
+
predicate='',
|
|
1700
|
+
ordering='',
|
|
1701
|
+
selected=(),
|
|
1702
|
+
effects='write',
|
|
1703
|
+
classes=('singleton',),
|
|
1704
|
+
inert_rule=MAINT,
|
|
1705
|
+
),
|
|
1706
|
+
AccessContract(
|
|
1707
|
+
function='_cctally_core:open_db',
|
|
1708
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS journal_excluded_event_revisions (event_id TEXT PRIMARY KEY, max_rev INTEGER NOT NULL)',
|
|
1709
|
+
table='journal_excluded_event_revisions',
|
|
1710
|
+
keys=(),
|
|
1711
|
+
predicate='',
|
|
1712
|
+
ordering='',
|
|
1713
|
+
selected=(),
|
|
1714
|
+
effects='write',
|
|
1715
|
+
classes=('singleton',),
|
|
1716
|
+
inert_rule=MAINT,
|
|
1717
|
+
),
|
|
1718
|
+
AccessContract(
|
|
1719
|
+
function='_cctally_journal:_read_derivation_state',
|
|
1720
|
+
sql_fingerprint='SELECT segment, offset, output_segment, output_offset, proof_generation FROM journal_derivation_frontier WHERE id = 1',
|
|
1721
|
+
table='journal_derivation_frontier',
|
|
1722
|
+
keys=('id',),
|
|
1723
|
+
predicate='id = 1',
|
|
1724
|
+
ordering='',
|
|
1725
|
+
selected=('segment', 'offset', 'output_segment', 'output_offset', 'proof_generation'),
|
|
1726
|
+
effects='read',
|
|
1727
|
+
classes=('singleton',),
|
|
1728
|
+
inert_rule=MAINT,
|
|
1729
|
+
),
|
|
1730
|
+
AccessContract(
|
|
1731
|
+
function='_cctally_journal:_record_excluded_revisions',
|
|
1732
|
+
sql_fingerprint='INSERT INTO journal_excluded_event_revisions (event_id, max_rev) VALUES (?, ?) ON CONFLICT(event_id) DO UPDATE SET max_rev = MAX(max_rev, excluded.max_rev)',
|
|
1733
|
+
table='journal_excluded_event_revisions',
|
|
1734
|
+
keys=('event_id',),
|
|
1735
|
+
predicate='event_id = ?',
|
|
1736
|
+
ordering='',
|
|
1737
|
+
selected=(),
|
|
1738
|
+
effects='upsert',
|
|
1739
|
+
classes=('period-keyed',),
|
|
1740
|
+
inert_rule=JOURNAL,
|
|
1741
|
+
),
|
|
1742
|
+
AccessContract(
|
|
1743
|
+
function='_cctally_journal:_write_derivation_frontier',
|
|
1744
|
+
sql_fingerprint='DELETE FROM journal_derivation_frontier',
|
|
1745
|
+
table='journal_derivation_frontier',
|
|
1746
|
+
keys=(),
|
|
1747
|
+
predicate='',
|
|
1748
|
+
ordering='',
|
|
1749
|
+
selected=(),
|
|
1750
|
+
effects='delete',
|
|
1751
|
+
classes=('singleton',),
|
|
1752
|
+
inert_rule=MAINT,
|
|
1753
|
+
),
|
|
1754
|
+
AccessContract(
|
|
1755
|
+
function='_cctally_journal:_write_derivation_frontier',
|
|
1756
|
+
sql_fingerprint='INSERT INTO journal_derivation_frontier (id, segment, offset, output_segment, output_offset, proof_generation) VALUES (1, ?, ?, ?, ?, ?)',
|
|
1757
|
+
table='journal_derivation_frontier',
|
|
1758
|
+
keys=('id',),
|
|
1759
|
+
predicate='',
|
|
1760
|
+
ordering='',
|
|
1761
|
+
selected=(),
|
|
1762
|
+
effects='write',
|
|
1763
|
+
classes=('singleton',),
|
|
1764
|
+
inert_rule=MAINT,
|
|
1765
|
+
),
|
|
1766
|
+
AccessContract(
|
|
1767
|
+
function='_cctally_journal:physical_excluded_revision',
|
|
1768
|
+
sql_fingerprint='SELECT max_rev FROM journal_excluded_event_revisions WHERE event_id = ?',
|
|
1769
|
+
table='journal_excluded_event_revisions',
|
|
1770
|
+
keys=('event_id',),
|
|
1771
|
+
predicate='event_id = ?',
|
|
1772
|
+
ordering='',
|
|
1773
|
+
selected=('max_rev',),
|
|
1774
|
+
effects='read',
|
|
1775
|
+
classes=('period-keyed',),
|
|
1776
|
+
inert_rule=JOURNAL,
|
|
1777
|
+
),
|
|
1778
|
+
AccessContract(
|
|
1779
|
+
function='_cctally_rederive:_joined_entries',
|
|
1780
|
+
sql_fingerprint='dynamic:_cctally_rederive:_joined_entries#1',
|
|
1781
|
+
sql_shape='sha256:2956a402028d910d',
|
|
1782
|
+
table='dynamic',
|
|
1783
|
+
keys=(),
|
|
1784
|
+
predicate='dynamic SQL over cache.db session entries only (the scratch derivation cost read); never stats.db',
|
|
1785
|
+
ordering='',
|
|
1786
|
+
selected=(),
|
|
1787
|
+
effects='read',
|
|
1788
|
+
classes=('range-keyed',),
|
|
1789
|
+
inert_rule=MAINT,
|
|
1790
|
+
),
|
|
1791
|
+
AccessContract(
|
|
1792
|
+
function='_cctally_journal:_record_new_effective_event',
|
|
1793
|
+
sql_fingerprint='DELETE FROM journal_effective_events WHERE event_id = ?',
|
|
1794
|
+
table='journal_effective_events',
|
|
1795
|
+
keys=('event_id',),
|
|
1796
|
+
predicate='event_id = ?',
|
|
1797
|
+
ordering='',
|
|
1798
|
+
selected=(),
|
|
1799
|
+
effects='delete',
|
|
1800
|
+
classes=('period-keyed',),
|
|
1801
|
+
inert_rule=JOURNAL,
|
|
1802
|
+
),
|
|
1803
|
+
AccessContract(
|
|
1804
|
+
function='_cctally_journal:_rematerialize_five_hour_high_water',
|
|
1805
|
+
sql_fingerprint="SELECT MAX(five_hour_percent) FROM weekly_usage_snapshots WHERE five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(COALESCE( (SELECT effective_reset_at_utc FROM five_hour_reset_events WHERE five_hour_window_key = ? AND account_key = ? ORDER BY id DESC LIMIT 1), '1970-01-01T00:00:00Z'))",
|
|
1806
|
+
table='weekly_usage_snapshots',
|
|
1807
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
1808
|
+
predicate='five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(COALESCE( (SELECT effective_reset_at_utc FROM five_hour_reset_events WHERE five_hour_window_key = ? AND account_key = ?',
|
|
1809
|
+
ordering='id DESC',
|
|
1810
|
+
selected=('MAX(five_hour_percent)',),
|
|
1811
|
+
effects='read',
|
|
1812
|
+
classes=('period-keyed', 'range-keyed'),
|
|
1813
|
+
inert_rule=MAINT,
|
|
1814
|
+
),
|
|
1815
|
+
AccessContract(
|
|
1816
|
+
function='_cctally_journal:_rematerialize_five_hour_high_water',
|
|
1817
|
+
sql_fingerprint='SELECT five_hour_window_key, account_key FROM weekly_usage_snapshots WHERE five_hour_window_key IS NOT NULL ORDER BY captured_at_utc DESC, id DESC LIMIT 1',
|
|
1818
|
+
table='weekly_usage_snapshots',
|
|
1819
|
+
keys=(),
|
|
1820
|
+
predicate='five_hour_window_key IS NOT NULL',
|
|
1821
|
+
ordering='captured_at_utc DESC, id DESC',
|
|
1822
|
+
selected=('five_hour_window_key', 'account_key'),
|
|
1823
|
+
effects='read',
|
|
1824
|
+
classes=('cross-period',),
|
|
1825
|
+
inert_rule=MAINT,
|
|
1826
|
+
),
|
|
1827
|
+
AccessContract(
|
|
1828
|
+
function='_cctally_journal:_replace_block_children',
|
|
1829
|
+
sql_fingerprint='dynamic:_cctally_journal:_replace_block_children#1',
|
|
1830
|
+
sql_shape='sha256:98c56d859553c085',
|
|
1831
|
+
table='dynamic',
|
|
1832
|
+
keys=(),
|
|
1833
|
+
predicate='dynamic SQL',
|
|
1834
|
+
ordering='',
|
|
1835
|
+
selected=(),
|
|
1836
|
+
effects='read',
|
|
1837
|
+
classes=('cross-period',),
|
|
1838
|
+
inert_rule=JOURNAL,
|
|
1839
|
+
),
|
|
1840
|
+
AccessContract(
|
|
1841
|
+
function='_cctally_journal:_replace_protocol_violations',
|
|
1842
|
+
sql_fingerprint='DELETE FROM journal_protocol_violations',
|
|
1843
|
+
table='journal_protocol_violations',
|
|
1844
|
+
keys=(),
|
|
1845
|
+
predicate='',
|
|
1846
|
+
ordering='',
|
|
1847
|
+
selected=(),
|
|
1848
|
+
effects='delete',
|
|
1849
|
+
classes=('singleton',),
|
|
1850
|
+
inert_rule=JOURNAL,
|
|
1851
|
+
),
|
|
1852
|
+
AccessContract(
|
|
1853
|
+
function='_cctally_journal:_replace_protocol_violations',
|
|
1854
|
+
sql_fingerprint='INSERT INTO journal_protocol_violations (fingerprint, batch_id, kind, violation_json, available_after) VALUES (?, ?, ?, ?, ?)',
|
|
1855
|
+
table='journal_protocol_violations',
|
|
1856
|
+
keys=(),
|
|
1857
|
+
predicate='',
|
|
1858
|
+
ordering='',
|
|
1859
|
+
selected=(),
|
|
1860
|
+
effects='write',
|
|
1861
|
+
classes=('singleton',),
|
|
1862
|
+
inert_rule=JOURNAL,
|
|
1863
|
+
),
|
|
1864
|
+
AccessContract(
|
|
1865
|
+
function='_cctally_journal:_resolve_fold_ref',
|
|
1866
|
+
sql_fingerprint='SELECT 1 FROM usage_snapshot_suppressions WHERE journal_id = ?',
|
|
1867
|
+
table='usage_snapshot_suppressions',
|
|
1868
|
+
keys=('journal_id',),
|
|
1869
|
+
predicate='journal_id = ?',
|
|
1870
|
+
ordering='',
|
|
1871
|
+
selected=(),
|
|
1872
|
+
effects='read',
|
|
1873
|
+
classes=('cross-period',),
|
|
1874
|
+
inert_rule=JOURNAL,
|
|
1875
|
+
),
|
|
1876
|
+
AccessContract(
|
|
1877
|
+
function='_cctally_journal:_resolve_ref',
|
|
1878
|
+
sql_fingerprint='dynamic:_cctally_journal:_resolve_ref#1',
|
|
1879
|
+
sql_shape='sha256:985085c93cb87555',
|
|
1880
|
+
table='dynamic',
|
|
1881
|
+
keys=(),
|
|
1882
|
+
predicate='dynamic SQL',
|
|
1883
|
+
ordering='',
|
|
1884
|
+
selected=(),
|
|
1885
|
+
effects='read',
|
|
1886
|
+
classes=('cross-period',),
|
|
1887
|
+
inert_rule=JOURNAL,
|
|
1888
|
+
),
|
|
1889
|
+
AccessContract(
|
|
1890
|
+
function='_cctally_journal:_reverse_ref',
|
|
1891
|
+
sql_fingerprint='dynamic:_cctally_journal:_reverse_ref#1',
|
|
1892
|
+
sql_shape='sha256:4f71c4c1dd51392d',
|
|
1893
|
+
table='dynamic',
|
|
1894
|
+
keys=(),
|
|
1895
|
+
predicate='dynamic SQL',
|
|
1896
|
+
ordering='',
|
|
1897
|
+
selected=(),
|
|
1898
|
+
effects='read',
|
|
1899
|
+
classes=('cross-period',),
|
|
1900
|
+
inert_rule=JOURNAL,
|
|
1901
|
+
),
|
|
1902
|
+
AccessContract(
|
|
1903
|
+
function='_cctally_journal:_scoped_query',
|
|
1904
|
+
sql_fingerprint='dynamic:_cctally_journal:_scoped_query#1',
|
|
1905
|
+
sql_shape='sha256:65fb6ece865bf93b',
|
|
1906
|
+
table='dynamic',
|
|
1907
|
+
keys=(),
|
|
1908
|
+
predicate='dynamic SQL',
|
|
1909
|
+
ordering='',
|
|
1910
|
+
selected=(),
|
|
1911
|
+
effects='read',
|
|
1912
|
+
classes=('cross-period',),
|
|
1913
|
+
inert_rule=JOURNAL,
|
|
1914
|
+
),
|
|
1915
|
+
AccessContract(
|
|
1916
|
+
function='_cctally_journal:_scoped_query',
|
|
1917
|
+
sql_fingerprint='dynamic:_cctally_journal:_scoped_query#2',
|
|
1918
|
+
sql_shape='sha256:fea23067d238cbe7',
|
|
1919
|
+
table='dynamic',
|
|
1920
|
+
keys=(),
|
|
1921
|
+
predicate='dynamic SQL',
|
|
1922
|
+
ordering='',
|
|
1923
|
+
selected=(),
|
|
1924
|
+
effects='read',
|
|
1925
|
+
classes=('cross-period',),
|
|
1926
|
+
inert_rule=JOURNAL,
|
|
1927
|
+
),
|
|
1928
|
+
AccessContract(
|
|
1929
|
+
function='_cctally_journal:_selector_generation_matches',
|
|
1930
|
+
sql_fingerprint='SELECT record_path, stamped_at_utc FROM stats_publication_stamp',
|
|
1931
|
+
table='stats_publication_stamp',
|
|
1932
|
+
keys=(),
|
|
1933
|
+
predicate='',
|
|
1934
|
+
ordering='',
|
|
1935
|
+
selected=('record_path', 'stamped_at_utc'),
|
|
1936
|
+
effects='read',
|
|
1937
|
+
classes=('cross-period',),
|
|
1938
|
+
inert_rule=JOURNAL,
|
|
1939
|
+
),
|
|
1940
|
+
AccessContract(
|
|
1941
|
+
function='_cctally_journal:_first_post_floor_unchanged',
|
|
1942
|
+
sql_fingerprint='SELECT five_hour_percent, five_hour_window_key, five_hour_resets_at, captured_at_utc FROM weekly_usage_snapshots WHERE week_start_date = ? AND account_key = ? ORDER BY captured_at_utc DESC, id DESC LIMIT 1',
|
|
1943
|
+
table='weekly_usage_snapshots',
|
|
1944
|
+
keys=('week_start_date', 'account_key'),
|
|
1945
|
+
predicate='week_start_date = ? AND account_key = ?',
|
|
1946
|
+
ordering='captured_at_utc DESC, id DESC',
|
|
1947
|
+
selected=('five_hour_percent', 'five_hour_window_key', 'five_hour_resets_at', 'captured_at_utc'),
|
|
1948
|
+
effects='read',
|
|
1949
|
+
classes=('period-keyed',),
|
|
1950
|
+
inert_rule=JOURNAL,
|
|
1951
|
+
),
|
|
1952
|
+
AccessContract(
|
|
1953
|
+
function='_cctally_journal:latest_post_floor_weekly_row',
|
|
1954
|
+
sql_fingerprint='SELECT weekly_percent, captured_at_utc FROM weekly_usage_snapshots WHERE week_start_date = ? AND account_key = ? AND weekly_observation_held = 0 AND weekly_percent IS NOT NULL AND unixepoch(week_end_at) = unixepoch(?) AND unixepoch(captured_at_utc) >= unixepoch(?) ORDER BY captured_at_utc DESC, id DESC LIMIT 1',
|
|
1955
|
+
table='weekly_usage_snapshots',
|
|
1956
|
+
keys=('week_start_date', 'account_key'),
|
|
1957
|
+
predicate='week_start_date = ? AND account_key = ? AND weekly_observation_held = 0 AND weekly_percent IS NOT NULL AND unixepoch(week_end_at) = unixepoch(?) AND unixepoch(captured_at_utc) >= unixepoch(?)',
|
|
1958
|
+
ordering='captured_at_utc DESC, id DESC',
|
|
1959
|
+
selected=('weekly_percent', 'captured_at_utc'),
|
|
1960
|
+
effects='read',
|
|
1961
|
+
classes=('period-keyed', 'range-keyed'),
|
|
1962
|
+
inert_rule=JOURNAL,
|
|
1963
|
+
),
|
|
1964
|
+
AccessContract(
|
|
1965
|
+
function='_cctally_journal:_usage_snapshot_fold_decision',
|
|
1966
|
+
sql_fingerprint='SELECT MAX(five_hour_percent) FROM weekly_usage_snapshots WHERE five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(?)',
|
|
1967
|
+
table='weekly_usage_snapshots',
|
|
1968
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
1969
|
+
predicate='five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(?)',
|
|
1970
|
+
ordering='',
|
|
1971
|
+
selected=('MAX(five_hour_percent)',),
|
|
1972
|
+
effects='read',
|
|
1973
|
+
classes=('period-keyed', 'range-keyed'),
|
|
1974
|
+
inert_rule=JOURNAL,
|
|
1975
|
+
),
|
|
1976
|
+
AccessContract(
|
|
1977
|
+
function='_cctally_journal:_usage_snapshot_fold_decision',
|
|
1978
|
+
sql_fingerprint='SELECT 1 FROM five_hour_blocks WHERE five_hour_window_key = ? AND account_key = ? LIMIT 1',
|
|
1979
|
+
table='five_hour_blocks',
|
|
1980
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
1981
|
+
predicate='five_hour_window_key = ? AND account_key = ?',
|
|
1982
|
+
ordering='',
|
|
1983
|
+
selected=('1',),
|
|
1984
|
+
effects='read',
|
|
1985
|
+
classes=('period-keyed',),
|
|
1986
|
+
inert_rule=JOURNAL,
|
|
1987
|
+
),
|
|
1988
|
+
AccessContract(
|
|
1989
|
+
function='_cctally_journal:_usage_snapshot_fold_decision',
|
|
1990
|
+
sql_fingerprint="SELECT MAX(five_hour_percent) FROM weekly_usage_snapshots WHERE five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(COALESCE( (SELECT effective_reset_at_utc FROM five_hour_reset_events WHERE five_hour_window_key = ? AND account_key = ? ORDER BY id DESC LIMIT 1), '1970-01-01T00:00:00Z'))",
|
|
1991
|
+
table='weekly_usage_snapshots',
|
|
1992
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
1993
|
+
predicate='five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(COALESCE( (SELECT effective_reset_at_utc FROM five_hour_reset_events WHERE five_hour_window_key = ? AND account_key = ?',
|
|
1994
|
+
ordering='id DESC',
|
|
1995
|
+
selected=('MAX(five_hour_percent)',),
|
|
1996
|
+
effects='read',
|
|
1997
|
+
classes=('period-keyed', 'range-keyed'),
|
|
1998
|
+
inert_rule=JOURNAL,
|
|
1999
|
+
),
|
|
2000
|
+
AccessContract(
|
|
2001
|
+
function='_cctally_journal:_usage_snapshot_fold_decision',
|
|
2002
|
+
sql_fingerprint='SELECT MAX(weekly_percent) FROM weekly_usage_snapshots WHERE week_start_date = ? AND account_key = ? AND weekly_observation_held = 0 AND unixepoch(captured_at_utc) >= unixepoch(?)',
|
|
2003
|
+
table='weekly_usage_snapshots',
|
|
2004
|
+
keys=('week_start_date', 'account_key'),
|
|
2005
|
+
predicate='week_start_date = ? AND account_key = ? AND weekly_observation_held = 0 AND unixepoch(captured_at_utc) >= unixepoch(?)',
|
|
2006
|
+
ordering='',
|
|
2007
|
+
selected=('MAX(weekly_percent)',),
|
|
2008
|
+
effects='read',
|
|
2009
|
+
classes=('period-keyed', 'range-keyed'),
|
|
2010
|
+
inert_rule=JOURNAL,
|
|
2011
|
+
),
|
|
2012
|
+
AccessContract(
|
|
2013
|
+
function='_cctally_journal:_usage_snapshot_fold_decision',
|
|
2014
|
+
sql_fingerprint='SELECT weekly_percent, five_hour_percent, five_hour_window_key FROM weekly_usage_snapshots WHERE week_start_date = ? AND account_key = ? ORDER BY captured_at_utc DESC, id DESC LIMIT 1',
|
|
2015
|
+
table='weekly_usage_snapshots',
|
|
2016
|
+
keys=('week_start_date', 'account_key'),
|
|
2017
|
+
predicate='week_start_date = ? AND account_key = ?',
|
|
2018
|
+
ordering='captured_at_utc DESC, id DESC',
|
|
2019
|
+
selected=('weekly_percent', 'five_hour_percent', 'five_hour_window_key'),
|
|
2020
|
+
effects='read',
|
|
2021
|
+
classes=('period-keyed',),
|
|
2022
|
+
inert_rule=JOURNAL,
|
|
2023
|
+
),
|
|
2024
|
+
AccessContract(
|
|
2025
|
+
function='_cctally_journal:_v1_rate_change_identity_exists',
|
|
2026
|
+
sql_fingerprint='SELECT 1 FROM journal_effective_events WHERE event_id = ?',
|
|
2027
|
+
table='journal_effective_events',
|
|
2028
|
+
keys=('event_id',),
|
|
2029
|
+
predicate='event_id = ?',
|
|
2030
|
+
ordering='',
|
|
2031
|
+
selected=('1',),
|
|
2032
|
+
effects='read',
|
|
2033
|
+
classes=('period-keyed',),
|
|
2034
|
+
inert_rule=JOURNAL,
|
|
2035
|
+
),
|
|
2036
|
+
AccessContract(
|
|
2037
|
+
function='_cctally_journal:_validate_rebuilt_stats_index',
|
|
2038
|
+
sql_fingerprint='SELECT id, journal_id FROM weekly_usage_snapshots ORDER BY id DESC LIMIT 1',
|
|
2039
|
+
table='weekly_usage_snapshots',
|
|
2040
|
+
keys=(),
|
|
2041
|
+
predicate='',
|
|
2042
|
+
ordering='id DESC',
|
|
2043
|
+
selected=('id', 'journal_id'),
|
|
2044
|
+
effects='read',
|
|
2045
|
+
classes=('cross-period',),
|
|
2046
|
+
inert_rule=MAINT,
|
|
2047
|
+
),
|
|
2048
|
+
AccessContract(
|
|
2049
|
+
function='_cctally_journal:_validate_rebuilt_stats_index',
|
|
2050
|
+
sql_fingerprint='SELECT segment, offset, applied_segment, applied_offset FROM journal_cursor WHERE id = 1',
|
|
2051
|
+
table='journal_cursor',
|
|
2052
|
+
keys=(),
|
|
2053
|
+
predicate='id = 1',
|
|
2054
|
+
ordering='',
|
|
2055
|
+
selected=('segment', 'offset', 'applied_segment', 'applied_offset'),
|
|
2056
|
+
effects='read',
|
|
2057
|
+
classes=('cross-period',),
|
|
2058
|
+
inert_rule=MAINT,
|
|
2059
|
+
),
|
|
2060
|
+
AccessContract(
|
|
2061
|
+
function='_cctally_journal:_write_admission_summary',
|
|
2062
|
+
sql_fingerprint='INSERT OR REPLACE INTO journal_admission_summary (id, cutover_id, scanned_high_water, excluded_total, family_counts_json, first_excluded_coordinate, latest_excluded_coordinate, coordinate_digest, complete_through, boundary_json) VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
2063
|
+
table='journal_admission_summary',
|
|
2064
|
+
keys=(),
|
|
2065
|
+
predicate='',
|
|
2066
|
+
ordering='',
|
|
2067
|
+
selected=(),
|
|
2068
|
+
effects='upsert',
|
|
2069
|
+
classes=('singleton',),
|
|
2070
|
+
inert_rule=JOURNAL,
|
|
2071
|
+
),
|
|
2072
|
+
AccessContract(
|
|
2073
|
+
function='_cctally_journal:_write_cursor',
|
|
2074
|
+
sql_fingerprint='INSERT INTO journal_cursor (id, segment, offset, applied_segment, applied_offset) VALUES (1, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET segment = excluded.segment, offset = excluded.offset, applied_segment = excluded.applied_segment, applied_offset = excluded.applied_offset',
|
|
2075
|
+
table='journal_cursor',
|
|
2076
|
+
keys=(),
|
|
2077
|
+
predicate='',
|
|
2078
|
+
ordering='',
|
|
2079
|
+
selected=(),
|
|
2080
|
+
effects='upsert',
|
|
2081
|
+
classes=('singleton',),
|
|
2082
|
+
inert_rule=JOURNAL,
|
|
2083
|
+
),
|
|
2084
|
+
AccessContract(
|
|
2085
|
+
function='_cctally_journal:_write_quota_projection_state',
|
|
2086
|
+
sql_fingerprint='INSERT INTO stats_quota_projection_state(id, incomplete, target_version, recovery_target_json) VALUES (1, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET incomplete = excluded.incomplete, target_version = excluded.target_version, recovery_target_json = excluded.recovery_target_json',
|
|
2087
|
+
table='stats_quota_projection_state',
|
|
2088
|
+
keys=(),
|
|
2089
|
+
predicate='',
|
|
2090
|
+
ordering='',
|
|
2091
|
+
selected=(),
|
|
2092
|
+
effects='upsert',
|
|
2093
|
+
classes=('singleton',),
|
|
2094
|
+
inert_rule=CODEX,
|
|
2095
|
+
),
|
|
2096
|
+
AccessContract(
|
|
2097
|
+
function='_cctally_journal:_write_selector_delta',
|
|
2098
|
+
sql_fingerprint='DELETE FROM journal_protocol_violations WHERE fingerprint = ?',
|
|
2099
|
+
table='journal_protocol_violations',
|
|
2100
|
+
keys=('fingerprint',),
|
|
2101
|
+
predicate='fingerprint = ?',
|
|
2102
|
+
ordering='',
|
|
2103
|
+
selected=(),
|
|
2104
|
+
effects='delete',
|
|
2105
|
+
classes=('singleton',),
|
|
2106
|
+
inert_rule=JOURNAL,
|
|
2107
|
+
),
|
|
2108
|
+
AccessContract(
|
|
2109
|
+
function='_cctally_journal:_write_selector_delta',
|
|
2110
|
+
sql_fingerprint='INSERT INTO journal_selector_state (id, generation_record_path, generation_stamped_at_utc, covered_segment, covered_offset, next_sequence, selector_version, cutover_seen, cutover_account_key) VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET generation_record_path = excluded.generation_record_path, generation_stamped_at_utc = excluded.generation_stamped_at_utc, covered_segment = excluded.covered_segment, covered_offset = excluded.covered_offset, next_sequence = excluded.next_sequence, selector_version = excluded.selector_version, cutover_seen = excluded.cutover_seen, cutover_account_key = excluded.cutover_account_key',
|
|
2111
|
+
table='journal_selector_state',
|
|
2112
|
+
keys=(),
|
|
2113
|
+
predicate='',
|
|
2114
|
+
ordering='',
|
|
2115
|
+
selected=(),
|
|
2116
|
+
effects='upsert',
|
|
2117
|
+
classes=('singleton',),
|
|
2118
|
+
inert_rule=JOURNAL,
|
|
2119
|
+
),
|
|
2120
|
+
AccessContract(
|
|
2121
|
+
function='_cctally_journal:_write_selector_delta',
|
|
2122
|
+
sql_fingerprint='INSERT OR REPLACE INTO journal_effective_events (event_id, rev, status, content_hash, batch_id, event_json, winning_sequence, conflict_hashes_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
|
|
2123
|
+
table='journal_effective_events',
|
|
2124
|
+
keys=(),
|
|
2125
|
+
predicate='',
|
|
2126
|
+
ordering='',
|
|
2127
|
+
selected=(),
|
|
2128
|
+
effects='upsert',
|
|
2129
|
+
classes=('singleton',),
|
|
2130
|
+
inert_rule=JOURNAL,
|
|
2131
|
+
),
|
|
2132
|
+
AccessContract(
|
|
2133
|
+
function='_cctally_journal:_write_selector_delta',
|
|
2134
|
+
sql_fingerprint='INSERT OR REPLACE INTO journal_protocol_violations (fingerprint, batch_id, kind, violation_json, available_after) VALUES (?, ?, ?, ?, ?)',
|
|
2135
|
+
table='journal_protocol_violations',
|
|
2136
|
+
keys=(),
|
|
2137
|
+
predicate='',
|
|
2138
|
+
ordering='',
|
|
2139
|
+
selected=(),
|
|
2140
|
+
effects='upsert',
|
|
2141
|
+
classes=('singleton',),
|
|
2142
|
+
inert_rule=JOURNAL,
|
|
2143
|
+
),
|
|
2144
|
+
AccessContract(
|
|
2145
|
+
function='_cctally_journal:_write_selector_delta',
|
|
2146
|
+
sql_fingerprint='INSERT OR REPLACE INTO journal_selector_batch_records (batch_id, kind, key, record_digest, identity_digest, sequence, action_core_json) VALUES (?, ?, ?, ?, ?, ?, ?)',
|
|
2147
|
+
table='journal_selector_batch_records',
|
|
2148
|
+
keys=(),
|
|
2149
|
+
predicate='',
|
|
2150
|
+
ordering='',
|
|
2151
|
+
selected=(),
|
|
2152
|
+
effects='upsert',
|
|
2153
|
+
classes=('singleton',),
|
|
2154
|
+
inert_rule=JOURNAL,
|
|
2155
|
+
),
|
|
2156
|
+
AccessContract(
|
|
2157
|
+
function='_cctally_journal:_write_selector_delta',
|
|
2158
|
+
sql_fingerprint='INSERT OR REPLACE INTO journal_selector_batches (batch_id, status, action_count, action_set_hash, begin_segment, begin_offset, earliest_commit_segment, earliest_commit_offset) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
|
|
2159
|
+
table='journal_selector_batches',
|
|
2160
|
+
keys=(),
|
|
2161
|
+
predicate='',
|
|
2162
|
+
ordering='',
|
|
2163
|
+
selected=(),
|
|
2164
|
+
effects='upsert',
|
|
2165
|
+
classes=('singleton',),
|
|
2166
|
+
inert_rule=JOURNAL,
|
|
2167
|
+
),
|
|
2168
|
+
AccessContract(
|
|
2169
|
+
function='_cctally_journal:_write_selector_state',
|
|
2170
|
+
sql_fingerprint='DELETE FROM journal_effective_events',
|
|
2171
|
+
table='journal_effective_events',
|
|
2172
|
+
keys=(),
|
|
2173
|
+
predicate='',
|
|
2174
|
+
ordering='',
|
|
2175
|
+
selected=(),
|
|
2176
|
+
effects='delete',
|
|
2177
|
+
classes=('singleton',),
|
|
2178
|
+
inert_rule=JOURNAL,
|
|
2179
|
+
),
|
|
2180
|
+
AccessContract(
|
|
2181
|
+
function='_cctally_journal:_write_selector_state',
|
|
2182
|
+
sql_fingerprint='DELETE FROM journal_selector_batch_records',
|
|
2183
|
+
table='journal_selector_batch_records',
|
|
2184
|
+
keys=(),
|
|
2185
|
+
predicate='',
|
|
2186
|
+
ordering='',
|
|
2187
|
+
selected=(),
|
|
2188
|
+
effects='delete',
|
|
2189
|
+
classes=('singleton',),
|
|
2190
|
+
inert_rule=JOURNAL,
|
|
2191
|
+
),
|
|
2192
|
+
AccessContract(
|
|
2193
|
+
function='_cctally_journal:_write_selector_state',
|
|
2194
|
+
sql_fingerprint='DELETE FROM journal_selector_batches',
|
|
2195
|
+
table='journal_selector_batches',
|
|
2196
|
+
keys=(),
|
|
2197
|
+
predicate='',
|
|
2198
|
+
ordering='',
|
|
2199
|
+
selected=(),
|
|
2200
|
+
effects='delete',
|
|
2201
|
+
classes=('singleton',),
|
|
2202
|
+
inert_rule=JOURNAL,
|
|
2203
|
+
),
|
|
2204
|
+
AccessContract(
|
|
2205
|
+
function='_cctally_journal:_write_selector_state',
|
|
2206
|
+
sql_fingerprint='DELETE FROM journal_selector_state',
|
|
2207
|
+
table='journal_selector_state',
|
|
2208
|
+
keys=(),
|
|
2209
|
+
predicate='',
|
|
2210
|
+
ordering='',
|
|
2211
|
+
selected=(),
|
|
2212
|
+
effects='delete',
|
|
2213
|
+
classes=('singleton',),
|
|
2214
|
+
inert_rule=JOURNAL,
|
|
2215
|
+
),
|
|
2216
|
+
AccessContract(
|
|
2217
|
+
function='_cctally_journal:_write_selector_state',
|
|
2218
|
+
sql_fingerprint='INSERT INTO journal_effective_events (event_id, rev, status, content_hash, batch_id, event_json, winning_sequence, conflict_hashes_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
|
|
2219
|
+
table='journal_effective_events',
|
|
2220
|
+
keys=(),
|
|
2221
|
+
predicate='',
|
|
2222
|
+
ordering='',
|
|
2223
|
+
selected=(),
|
|
2224
|
+
effects='write',
|
|
2225
|
+
classes=('singleton',),
|
|
2226
|
+
inert_rule=JOURNAL,
|
|
2227
|
+
),
|
|
2228
|
+
AccessContract(
|
|
2229
|
+
function='_cctally_journal:_write_selector_state',
|
|
2230
|
+
sql_fingerprint='INSERT INTO journal_selector_batch_records (batch_id, kind, key, record_digest, identity_digest, sequence, action_core_json) VALUES (?, ?, ?, ?, ?, ?, ?)',
|
|
2231
|
+
table='journal_selector_batch_records',
|
|
2232
|
+
keys=(),
|
|
2233
|
+
predicate='',
|
|
2234
|
+
ordering='',
|
|
2235
|
+
selected=(),
|
|
2236
|
+
effects='write',
|
|
2237
|
+
classes=('singleton',),
|
|
2238
|
+
inert_rule=JOURNAL,
|
|
2239
|
+
),
|
|
2240
|
+
AccessContract(
|
|
2241
|
+
function='_cctally_journal:_write_selector_state',
|
|
2242
|
+
sql_fingerprint='INSERT INTO journal_selector_batches (batch_id, status, action_count, action_set_hash, begin_segment, begin_offset, earliest_commit_segment, earliest_commit_offset) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
|
|
2243
|
+
table='journal_selector_batches',
|
|
2244
|
+
keys=(),
|
|
2245
|
+
predicate='',
|
|
2246
|
+
ordering='',
|
|
2247
|
+
selected=(),
|
|
2248
|
+
effects='write',
|
|
2249
|
+
classes=('singleton',),
|
|
2250
|
+
inert_rule=JOURNAL,
|
|
2251
|
+
),
|
|
2252
|
+
AccessContract(
|
|
2253
|
+
function='_cctally_journal:_write_selector_state',
|
|
2254
|
+
sql_fingerprint='INSERT INTO journal_selector_state (id, generation_record_path, generation_stamped_at_utc, covered_segment, covered_offset, next_sequence, selector_version, cutover_seen, cutover_account_key) VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
2255
|
+
table='journal_selector_state',
|
|
2256
|
+
keys=(),
|
|
2257
|
+
predicate='',
|
|
2258
|
+
ordering='',
|
|
2259
|
+
selected=(),
|
|
2260
|
+
effects='write',
|
|
2261
|
+
classes=('singleton',),
|
|
2262
|
+
inert_rule=JOURNAL,
|
|
2263
|
+
),
|
|
2264
|
+
AccessContract(
|
|
2265
|
+
function='_cctally_journal:emit_model_a',
|
|
2266
|
+
sql_fingerprint='dynamic:_cctally_journal:emit_model_a#1',
|
|
2267
|
+
sql_shape='sha256:e7dad38dc273784f',
|
|
2268
|
+
table='dynamic',
|
|
2269
|
+
keys=(),
|
|
2270
|
+
predicate='dynamic SQL',
|
|
2271
|
+
ordering='',
|
|
2272
|
+
selected=(),
|
|
2273
|
+
effects='read',
|
|
2274
|
+
classes=('cross-period',),
|
|
2275
|
+
inert_rule=JOURNAL,
|
|
2276
|
+
),
|
|
2277
|
+
AccessContract(
|
|
2278
|
+
function='_cctally_journal:freeze_five_hour_block_close',
|
|
2279
|
+
sql_fingerprint='SELECT * FROM five_hour_blocks WHERE id = ?',
|
|
2280
|
+
table='five_hour_blocks',
|
|
2281
|
+
keys=('id',),
|
|
2282
|
+
predicate='id = ?',
|
|
2283
|
+
ordering='',
|
|
2284
|
+
selected=('*',),
|
|
2285
|
+
effects='read',
|
|
2286
|
+
classes=('period-keyed',),
|
|
2287
|
+
inert_rule=JOURNAL,
|
|
2288
|
+
),
|
|
2289
|
+
AccessContract(
|
|
2290
|
+
function='_cctally_journal:latch_crossing_was_retired',
|
|
2291
|
+
sql_fingerprint='dynamic:_cctally_journal:latch_crossing_was_retired#1',
|
|
2292
|
+
sql_shape='sha256:dc25754c94998705',
|
|
2293
|
+
table='dynamic',
|
|
2294
|
+
keys=(),
|
|
2295
|
+
predicate='dynamic SQL',
|
|
2296
|
+
ordering='',
|
|
2297
|
+
selected=(),
|
|
2298
|
+
effects='read',
|
|
2299
|
+
classes=('cross-period',),
|
|
2300
|
+
inert_rule=JOURNAL,
|
|
2301
|
+
),
|
|
2302
|
+
AccessContract(
|
|
2303
|
+
function='_cctally_journal:read_publication_stamp',
|
|
2304
|
+
sql_fingerprint='SELECT record_path FROM stats_publication_stamp',
|
|
2305
|
+
table='stats_publication_stamp',
|
|
2306
|
+
keys=(),
|
|
2307
|
+
predicate='',
|
|
2308
|
+
ordering='',
|
|
2309
|
+
selected=('record_path',),
|
|
2310
|
+
effects='read',
|
|
2311
|
+
classes=('cross-period',),
|
|
2312
|
+
inert_rule=MAINT,
|
|
2313
|
+
),
|
|
2314
|
+
AccessContract(
|
|
2315
|
+
function='_cctally_journal:record_meter_rate_change',
|
|
2316
|
+
sql_fingerprint='SELECT provider, account_key, effective_from, previous_units_per_point, new_units_per_point, severity, withholding_status, detector_input_causes, composition_provenance, baseline_withheld_days FROM meter_rate_change_events WHERE provider = ? AND account_key = ? AND effective_from = ? LIMIT 1',
|
|
2317
|
+
table='meter_rate_change_events',
|
|
2318
|
+
keys=('provider', 'account_key', 'effective_from'),
|
|
2319
|
+
predicate='provider = ? AND account_key = ? AND effective_from = ?',
|
|
2320
|
+
ordering='',
|
|
2321
|
+
selected=('provider', 'account_key', 'effective_from', 'previous_units_per_point', 'new_units_per_point', 'severity', 'withholding_status', 'detector_input_causes', 'composition_provenance', 'baseline_withheld_days'),
|
|
2322
|
+
effects='read',
|
|
2323
|
+
classes=('cross-period',),
|
|
2324
|
+
inert_rule=JOURNAL,
|
|
2325
|
+
),
|
|
2326
|
+
AccessContract(
|
|
2327
|
+
function='_cctally_journal:stats_index_matches_journal_prefix',
|
|
2328
|
+
sql_fingerprint='SELECT event_id, rev, status, content_hash, batch_id, event_json FROM journal_effective_events ORDER BY event_id',
|
|
2329
|
+
table='journal_effective_events',
|
|
2330
|
+
keys=(),
|
|
2331
|
+
predicate='',
|
|
2332
|
+
ordering='event_id',
|
|
2333
|
+
selected=('event_id', 'rev', 'status', 'content_hash', 'batch_id', 'event_json'),
|
|
2334
|
+
effects='read',
|
|
2335
|
+
classes=('cross-period',),
|
|
2336
|
+
inert_rule=MAINT,
|
|
2337
|
+
),
|
|
2338
|
+
AccessContract(
|
|
2339
|
+
function='_cctally_journal:stats_index_matches_journal_prefix',
|
|
2340
|
+
sql_fingerprint='SELECT violation_json FROM journal_protocol_violations ORDER BY batch_id, kind, fingerprint',
|
|
2341
|
+
table='journal_protocol_violations',
|
|
2342
|
+
keys=(),
|
|
2343
|
+
predicate='',
|
|
2344
|
+
ordering='batch_id, kind, fingerprint',
|
|
2345
|
+
selected=('violation_json',),
|
|
2346
|
+
effects='read',
|
|
2347
|
+
classes=('cross-period',),
|
|
2348
|
+
inert_rule=MAINT,
|
|
2349
|
+
),
|
|
2350
|
+
AccessContract(
|
|
2351
|
+
function='_cctally_journal:stats_index_matches_journal_prefix',
|
|
2352
|
+
sql_fingerprint='dynamic:_cctally_journal:stats_index_matches_journal_prefix#1',
|
|
2353
|
+
sql_shape='sha256:5c869b43c418d251',
|
|
2354
|
+
table='dynamic',
|
|
2355
|
+
keys=(),
|
|
2356
|
+
predicate='dynamic SQL',
|
|
2357
|
+
ordering='',
|
|
2358
|
+
selected=(),
|
|
2359
|
+
effects='read',
|
|
2360
|
+
classes=('cross-period',),
|
|
2361
|
+
inert_rule=MAINT,
|
|
2362
|
+
),
|
|
2363
|
+
AccessContract(
|
|
2364
|
+
function='_cctally_journal:stats_index_matches_journal_prefix',
|
|
2365
|
+
sql_fingerprint='dynamic:_cctally_journal:stats_index_matches_journal_prefix#2',
|
|
2366
|
+
sql_shape='sha256:46cf0672d1ac6f95',
|
|
2367
|
+
table='dynamic',
|
|
2368
|
+
keys=(),
|
|
2369
|
+
predicate='dynamic SQL',
|
|
2370
|
+
ordering='',
|
|
2371
|
+
selected=(),
|
|
2372
|
+
effects='read',
|
|
2373
|
+
classes=('cross-period',),
|
|
2374
|
+
inert_rule=MAINT,
|
|
2375
|
+
),
|
|
2376
|
+
AccessContract(
|
|
2377
|
+
function='_cctally_milestones:_budget_crossings',
|
|
2378
|
+
sql_fingerprint='UPDATE budget_milestones SET alerted_at = ? WHERE vendor = ? AND account_key = ? AND period_start_at = ? AND period = ? AND threshold = ? AND alerted_at IS NULL',
|
|
2379
|
+
table='budget_milestones',
|
|
2380
|
+
keys=('vendor', 'account_key', 'period_start_at', 'period', 'threshold'),
|
|
2381
|
+
predicate='vendor = ? AND account_key = ? AND period_start_at = ? AND period = ? AND threshold = ? AND alerted_at IS NULL',
|
|
2382
|
+
ordering='',
|
|
2383
|
+
selected=(),
|
|
2384
|
+
effects='write',
|
|
2385
|
+
classes=('period-keyed',),
|
|
2386
|
+
inert_rule=Q7,
|
|
2387
|
+
),
|
|
2388
|
+
AccessContract(
|
|
2389
|
+
function='_cctally_milestones:_projected_levels_already_latched',
|
|
2390
|
+
sql_fingerprint='SELECT threshold FROM projected_milestones WHERE week_start_at = ? AND (period = ? OR period IS NULL) AND metric = ?',
|
|
2391
|
+
table='projected_milestones',
|
|
2392
|
+
keys=('week_start_at', 'period', 'metric'),
|
|
2393
|
+
predicate='week_start_at = ? AND (period = ? OR period IS NULL) AND metric = ?',
|
|
2394
|
+
ordering='',
|
|
2395
|
+
selected=('threshold',),
|
|
2396
|
+
effects='read',
|
|
2397
|
+
classes=('period-keyed',),
|
|
2398
|
+
inert_rule=Q7,
|
|
2399
|
+
),
|
|
2400
|
+
AccessContract(
|
|
2401
|
+
function='_cctally_milestones:get_max_milestone_for_week',
|
|
2402
|
+
sql_fingerprint='SELECT MAX(percent_threshold) AS max_pct FROM percent_milestones WHERE week_start_date = ? AND reset_event_id = ? AND account_key = ?',
|
|
2403
|
+
table='percent_milestones',
|
|
2404
|
+
keys=('week_start_date', 'reset_event_id', 'account_key'),
|
|
2405
|
+
predicate='week_start_date = ? AND reset_event_id = ? AND account_key = ?',
|
|
2406
|
+
ordering='',
|
|
2407
|
+
selected=('MAX(percent_threshold) AS max_pct',),
|
|
2408
|
+
effects='read',
|
|
2409
|
+
classes=('period-keyed',),
|
|
2410
|
+
inert_rule=Q7,
|
|
2411
|
+
),
|
|
2412
|
+
AccessContract(
|
|
2413
|
+
function='_cctally_milestones:get_milestone_cost_for_week',
|
|
2414
|
+
sql_fingerprint='SELECT cumulative_cost_usd FROM percent_milestones WHERE week_start_date = ? AND percent_threshold = ? AND reset_event_id = ? AND account_key = ?',
|
|
2415
|
+
table='percent_milestones',
|
|
2416
|
+
keys=('week_start_date', 'percent_threshold', 'reset_event_id', 'account_key'),
|
|
2417
|
+
predicate='week_start_date = ? AND percent_threshold = ? AND reset_event_id = ? AND account_key = ?',
|
|
2418
|
+
ordering='',
|
|
2419
|
+
selected=('cumulative_cost_usd',),
|
|
2420
|
+
effects='read',
|
|
2421
|
+
classes=('period-keyed',),
|
|
2422
|
+
inert_rule=Q7,
|
|
2423
|
+
),
|
|
2424
|
+
AccessContract(
|
|
2425
|
+
function='_cctally_milestones:insert_budget_milestone',
|
|
2426
|
+
sql_fingerprint='INSERT OR IGNORE INTO budget_milestones (vendor, account_key, period_start_at, period, threshold, budget_usd, spent_usd, consumption_pct, crossed_at_utc) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
2427
|
+
table='budget_milestones',
|
|
2428
|
+
keys=(),
|
|
2429
|
+
predicate='',
|
|
2430
|
+
ordering='',
|
|
2431
|
+
selected=(),
|
|
2432
|
+
effects='write',
|
|
2433
|
+
classes=('singleton',),
|
|
2434
|
+
inert_rule=Q7,
|
|
2435
|
+
),
|
|
2436
|
+
AccessContract(
|
|
2437
|
+
function='_cctally_milestones:insert_cost_snapshot',
|
|
2438
|
+
sql_fingerprint='INSERT INTO weekly_cost_snapshots ( captured_at_utc, week_start_date, week_end_date, week_start_at, week_end_at, range_start_iso, range_end_iso, cost_usd, mode, project, account_key ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
2439
|
+
table='weekly_cost_snapshots',
|
|
2440
|
+
keys=(),
|
|
2441
|
+
predicate='',
|
|
2442
|
+
ordering='',
|
|
2443
|
+
selected=(),
|
|
2444
|
+
effects='write',
|
|
2445
|
+
classes=('singleton',),
|
|
2446
|
+
inert_rule=Q7,
|
|
2447
|
+
),
|
|
2448
|
+
AccessContract(
|
|
2449
|
+
function='_cctally_milestones:insert_percent_milestone',
|
|
2450
|
+
sql_fingerprint='INSERT OR IGNORE INTO percent_milestones ( captured_at_utc, week_start_date, week_end_date, week_start_at, week_end_at, percent_threshold, cumulative_cost_usd, marginal_cost_usd, usage_snapshot_id, cost_snapshot_id, five_hour_percent_at_crossing, reset_event_id, account_key ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
2451
|
+
table='percent_milestones',
|
|
2452
|
+
keys=(),
|
|
2453
|
+
predicate='',
|
|
2454
|
+
ordering='',
|
|
2455
|
+
selected=(),
|
|
2456
|
+
effects='write',
|
|
2457
|
+
classes=('singleton',),
|
|
2458
|
+
inert_rule=Q7,
|
|
2459
|
+
),
|
|
2460
|
+
AccessContract(
|
|
2461
|
+
function='_cctally_milestones:insert_project_budget_milestone',
|
|
2462
|
+
sql_fingerprint='INSERT OR IGNORE INTO project_budget_milestones (week_start_at, project_key, threshold, budget_usd, spent_usd, consumption_pct, crossed_at_utc) VALUES (?, ?, ?, ?, ?, ?, ?)',
|
|
2463
|
+
table='project_budget_milestones',
|
|
2464
|
+
keys=(),
|
|
2465
|
+
predicate='',
|
|
2466
|
+
ordering='',
|
|
2467
|
+
selected=(),
|
|
2468
|
+
effects='write',
|
|
2469
|
+
classes=('singleton',),
|
|
2470
|
+
inert_rule=Q7,
|
|
2471
|
+
),
|
|
2472
|
+
AccessContract(
|
|
2473
|
+
function='_cctally_milestones:insert_projected_milestone',
|
|
2474
|
+
sql_fingerprint='INSERT OR IGNORE INTO projected_milestones (week_start_at, period, metric, threshold, projected_value, denominator, crossed_at_utc) VALUES (?, ?, ?, ?, ?, ?, ?)',
|
|
2475
|
+
table='projected_milestones',
|
|
2476
|
+
keys=(),
|
|
2477
|
+
predicate='',
|
|
2478
|
+
ordering='',
|
|
2479
|
+
selected=(),
|
|
2480
|
+
effects='write',
|
|
2481
|
+
classes=('singleton',),
|
|
2482
|
+
inert_rule=Q7,
|
|
2483
|
+
),
|
|
2484
|
+
AccessContract(
|
|
2485
|
+
function='_cctally_quarantine:load_state',
|
|
2486
|
+
sql_fingerprint='SELECT MAX(seq) FROM outcome_quarantine_triggers',
|
|
2487
|
+
table='outcome_quarantine_triggers',
|
|
2488
|
+
keys=(),
|
|
2489
|
+
predicate='',
|
|
2490
|
+
ordering='',
|
|
2491
|
+
selected=('MAX(seq)',),
|
|
2492
|
+
effects='read',
|
|
2493
|
+
classes=('cross-period',),
|
|
2494
|
+
inert_rule=QUARANTINE,
|
|
2495
|
+
),
|
|
2496
|
+
AccessContract(
|
|
2497
|
+
function='_cctally_quarantine:load_state',
|
|
2498
|
+
sql_fingerprint='SELECT account_key, accounting_certificate_json, accounting_trigger_seq, control_certificate_json, control_trigger_seq FROM outcome_quarantine_certificates',
|
|
2499
|
+
table='outcome_quarantine_certificates',
|
|
2500
|
+
keys=(),
|
|
2501
|
+
predicate='',
|
|
2502
|
+
ordering='',
|
|
2503
|
+
selected=('account_key', 'accounting_certificate_json', 'accounting_trigger_seq', 'control_certificate_json', 'control_trigger_seq'),
|
|
2504
|
+
effects='read',
|
|
2505
|
+
classes=('cross-period',),
|
|
2506
|
+
inert_rule=QUARANTINE,
|
|
2507
|
+
),
|
|
2508
|
+
AccessContract(
|
|
2509
|
+
function='_cctally_quarantine:load_state',
|
|
2510
|
+
sql_fingerprint='SELECT scope, envelope_json FROM outcome_quarantine_envelope',
|
|
2511
|
+
table='outcome_quarantine_envelope',
|
|
2512
|
+
keys=(),
|
|
2513
|
+
predicate='',
|
|
2514
|
+
ordering='',
|
|
2515
|
+
selected=('scope', 'envelope_json'),
|
|
2516
|
+
effects='read',
|
|
2517
|
+
classes=('cross-period',),
|
|
2518
|
+
inert_rule=QUARANTINE,
|
|
2519
|
+
),
|
|
2520
|
+
AccessContract(
|
|
2521
|
+
function='_cctally_quarantine:load_state',
|
|
2522
|
+
sql_fingerprint='SELECT seq, segment, byte_offset, reason, at FROM outcome_quarantine_triggers WHERE kind = ? ORDER BY seq',
|
|
2523
|
+
table='outcome_quarantine_triggers',
|
|
2524
|
+
keys=('kind',),
|
|
2525
|
+
predicate='kind = ?',
|
|
2526
|
+
ordering='seq',
|
|
2527
|
+
selected=('seq', 'segment', 'byte_offset', 'reason', 'at'),
|
|
2528
|
+
effects='read',
|
|
2529
|
+
classes=('cross-period',),
|
|
2530
|
+
inert_rule=QUARANTINE,
|
|
2531
|
+
),
|
|
2532
|
+
AccessContract(
|
|
2533
|
+
function='_cctally_quota:_activate_quota_rule',
|
|
2534
|
+
sql_fingerprint='INSERT INTO quota_alert_arming (source, source_root_key, logical_limit_key, observed_slot, window_minutes, rule_fingerprint, activated_at_utc, account_key) VALUES (?,?,?,?,?,?,?,?) ON CONFLICT(source, source_root_key, account_key, logical_limit_key, observed_slot, window_minutes) DO UPDATE SET rule_fingerprint=excluded.rule_fingerprint, activated_at_utc=excluded.activated_at_utc',
|
|
2535
|
+
table='quota_alert_arming',
|
|
2536
|
+
keys=(),
|
|
2537
|
+
predicate='',
|
|
2538
|
+
ordering='',
|
|
2539
|
+
selected=(),
|
|
2540
|
+
effects='upsert',
|
|
2541
|
+
classes=('singleton',),
|
|
2542
|
+
inert_rule=CODEX,
|
|
2543
|
+
),
|
|
2544
|
+
AccessContract(
|
|
2545
|
+
function='_cctally_quota:_apply_quota_projection_rows',
|
|
2546
|
+
sql_fingerprint='INSERT INTO quota_percent_milestones (source, source_root_key, logical_limit_key, observed_slot, window_minutes, resets_at_utc, percent_threshold, captured_at_utc, source_path, line_offset, high_water_percent, generation, orphaned_at, account_key) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,NULL,?) ON CONFLICT(source, source_root_key, account_key, logical_limit_key, observed_slot, window_minutes, resets_at_utc, percent_threshold) DO UPDATE SET captured_at_utc=excluded.captured_at_utc, source_path=excluded.source_path, line_offset=excluded.line_offset, high_water_percent=excluded.high_water_percent, generation=excluded.generation, orphaned_at=NULL',
|
|
2547
|
+
table='quota_percent_milestones',
|
|
2548
|
+
keys=(),
|
|
2549
|
+
predicate='',
|
|
2550
|
+
ordering='',
|
|
2551
|
+
selected=(),
|
|
2552
|
+
effects='upsert',
|
|
2553
|
+
classes=('singleton',),
|
|
2554
|
+
inert_rule=CODEX,
|
|
2555
|
+
),
|
|
2556
|
+
AccessContract(
|
|
2557
|
+
function='_cctally_quota:_apply_quota_projection_rows',
|
|
2558
|
+
sql_fingerprint='INSERT INTO quota_projection_state (source_root_key, account_key, generation, physical_signature, completed_at_utc) VALUES (?,?,?,?,?) ON CONFLICT(source_root_key, account_key) DO UPDATE SET generation=excluded.generation, physical_signature=excluded.physical_signature, completed_at_utc=excluded.completed_at_utc',
|
|
2559
|
+
table='quota_projection_state',
|
|
2560
|
+
keys=(),
|
|
2561
|
+
predicate='',
|
|
2562
|
+
ordering='',
|
|
2563
|
+
selected=(),
|
|
2564
|
+
effects='upsert',
|
|
2565
|
+
classes=('singleton',),
|
|
2566
|
+
inert_rule=CODEX,
|
|
2567
|
+
),
|
|
2568
|
+
AccessContract(
|
|
2569
|
+
function='_cctally_quota:_apply_quota_projection_rows',
|
|
2570
|
+
sql_fingerprint='INSERT INTO quota_window_blocks (source, source_root_key, logical_limit_key, observed_slot, window_minutes, limit_id, limit_name, resets_at_utc, nominal_start_at_utc, first_observed_at_utc, last_observed_at_utc, first_percent, current_percent, last_source_path, last_line_offset, generation, orphaned_at, account_key, physical_group_key, physical_group_digest) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,NULL,?,?,?) ON CONFLICT(source, source_root_key, account_key, logical_limit_key, observed_slot, window_minutes, resets_at_utc) DO UPDATE SET limit_id=excluded.limit_id, limit_name=excluded.limit_name, nominal_start_at_utc=excluded.nominal_start_at_utc, first_observed_at_utc=excluded.first_observed_at_utc, last_observed_at_utc=excluded.last_observed_at_utc, first_percent=excluded.first_percent, current_percent=excluded.current_percent, last_source_path=excluded.last_source_path, last_line_offset=excluded.last_line_offset, generation=excluded.generation, orphaned_at=NULL, physical_group_key=excluded.physical_group_key, physical_group_digest=excluded.physical_group_digest',
|
|
2571
|
+
table='quota_window_blocks',
|
|
2572
|
+
keys=(),
|
|
2573
|
+
predicate='',
|
|
2574
|
+
ordering='',
|
|
2575
|
+
selected=(),
|
|
2576
|
+
effects='upsert',
|
|
2577
|
+
classes=('singleton',),
|
|
2578
|
+
inert_rule=CODEX,
|
|
2579
|
+
),
|
|
2580
|
+
AccessContract(
|
|
2581
|
+
function='_cctally_quota:_apply_quota_projection_rows',
|
|
2582
|
+
sql_fingerprint='dynamic:_cctally_quota:_apply_quota_projection_rows#1',
|
|
2583
|
+
sql_shape='sha256:0c02fccf21f059a5',
|
|
2584
|
+
table='dynamic',
|
|
2585
|
+
keys=(),
|
|
2586
|
+
predicate='dynamic SQL',
|
|
2587
|
+
ordering='',
|
|
2588
|
+
selected=(),
|
|
2589
|
+
effects='read',
|
|
2590
|
+
classes=('cross-period',),
|
|
2591
|
+
inert_rule=CODEX,
|
|
2592
|
+
),
|
|
2593
|
+
AccessContract(
|
|
2594
|
+
function='_cctally_quota:_armed_identities',
|
|
2595
|
+
sql_fingerprint="SELECT source, source_root_key, account_key, logical_limit_key, observed_slot, window_minutes, rule_fingerprint FROM quota_alert_arming WHERE source='codex'",
|
|
2596
|
+
table='quota_alert_arming',
|
|
2597
|
+
keys=(),
|
|
2598
|
+
predicate="source='codex'",
|
|
2599
|
+
ordering='',
|
|
2600
|
+
selected=('source', 'source_root_key', 'account_key', 'logical_limit_key', 'observed_slot', 'window_minutes', 'rule_fingerprint'),
|
|
2601
|
+
effects='read',
|
|
2602
|
+
classes=('cross-period',),
|
|
2603
|
+
inert_rule=CODEX,
|
|
2604
|
+
),
|
|
2605
|
+
AccessContract(
|
|
2606
|
+
function='_cctally_quota:_arming_row',
|
|
2607
|
+
sql_fingerprint='SELECT rule_fingerprint, activated_at_utc FROM quota_alert_arming WHERE source=? AND source_root_key=? AND account_key=? AND logical_limit_key=? AND observed_slot=? AND window_minutes=?',
|
|
2608
|
+
table='quota_alert_arming',
|
|
2609
|
+
keys=('source', 'source_root_key', 'account_key', 'logical_limit_key', 'observed_slot', 'window_minutes'),
|
|
2610
|
+
predicate='source=? AND source_root_key=? AND account_key=? AND logical_limit_key=? AND observed_slot=? AND window_minutes=?',
|
|
2611
|
+
ordering='',
|
|
2612
|
+
selected=('rule_fingerprint', 'activated_at_utc'),
|
|
2613
|
+
effects='read',
|
|
2614
|
+
classes=('cross-period',),
|
|
2615
|
+
inert_rule=CODEX,
|
|
2616
|
+
),
|
|
2617
|
+
AccessContract(
|
|
2618
|
+
function='_cctally_quota:_blocks_missing_reverse_map',
|
|
2619
|
+
sql_fingerprint="SELECT 1 FROM quota_window_blocks WHERE source='codex' AND physical_group_key IS NULL LIMIT 1",
|
|
2620
|
+
table='quota_window_blocks',
|
|
2621
|
+
keys=(),
|
|
2622
|
+
predicate="source='codex' AND physical_group_key IS NULL",
|
|
2623
|
+
ordering='',
|
|
2624
|
+
selected=('1',),
|
|
2625
|
+
effects='read',
|
|
2626
|
+
classes=('cross-period',),
|
|
2627
|
+
inert_rule=CODEX,
|
|
2628
|
+
),
|
|
2629
|
+
AccessContract(
|
|
2630
|
+
function='_cctally_quota:_codex_quota_latest_rows',
|
|
2631
|
+
sql_fingerprint='dynamic:_cctally_quota:_codex_quota_latest_rows#1',
|
|
2632
|
+
sql_shape='sha256:303314c1c826d8b3',
|
|
2633
|
+
table='dynamic',
|
|
2634
|
+
keys=(),
|
|
2635
|
+
predicate='dynamic SQL',
|
|
2636
|
+
ordering='',
|
|
2637
|
+
selected=(),
|
|
2638
|
+
effects='read',
|
|
2639
|
+
classes=('cross-period',),
|
|
2640
|
+
inert_rule=CODEX,
|
|
2641
|
+
),
|
|
2642
|
+
AccessContract(
|
|
2643
|
+
function='_cctally_quota:_codex_quota_read_objects',
|
|
2644
|
+
sql_fingerprint='dynamic:_cctally_quota:_codex_quota_read_objects#1',
|
|
2645
|
+
sql_shape='sha256:6124cce1a9689748',
|
|
2646
|
+
table='dynamic',
|
|
2647
|
+
keys=(),
|
|
2648
|
+
predicate='dynamic SQL',
|
|
2649
|
+
ordering='',
|
|
2650
|
+
selected=(),
|
|
2651
|
+
effects='read',
|
|
2652
|
+
classes=('cross-period',),
|
|
2653
|
+
inert_rule=CODEX,
|
|
2654
|
+
),
|
|
2655
|
+
AccessContract(
|
|
2656
|
+
function='_cctally_quota:_codex_witness_anchors',
|
|
2657
|
+
sql_fingerprint='dynamic:_cctally_quota:_codex_witness_anchors#1',
|
|
2658
|
+
sql_shape='sha256:174522237238d2e7',
|
|
2659
|
+
table='dynamic',
|
|
2660
|
+
keys=(),
|
|
2661
|
+
predicate='dynamic SQL',
|
|
2662
|
+
ordering='',
|
|
2663
|
+
selected=(),
|
|
2664
|
+
effects='read',
|
|
2665
|
+
classes=('cross-period',),
|
|
2666
|
+
inert_rule=CODEX,
|
|
2667
|
+
),
|
|
2668
|
+
AccessContract(
|
|
2669
|
+
function='_cctally_quota:_evaluate_quota_alerts',
|
|
2670
|
+
sql_fingerprint="DELETE FROM quota_alert_arming WHERE source='codex'",
|
|
2671
|
+
table='quota_alert_arming',
|
|
2672
|
+
keys=(),
|
|
2673
|
+
predicate="source='codex'",
|
|
2674
|
+
ordering='',
|
|
2675
|
+
selected=(),
|
|
2676
|
+
effects='delete',
|
|
2677
|
+
classes=('singleton',),
|
|
2678
|
+
inert_rule=CODEX,
|
|
2679
|
+
),
|
|
2680
|
+
AccessContract(
|
|
2681
|
+
function='_cctally_quota:_evaluate_quota_alerts',
|
|
2682
|
+
sql_fingerprint="SELECT source, source_root_key, account_key, logical_limit_key, observed_slot, window_minutes FROM quota_alert_arming WHERE source='codex'",
|
|
2683
|
+
table='quota_alert_arming',
|
|
2684
|
+
keys=(),
|
|
2685
|
+
predicate="source='codex'",
|
|
2686
|
+
ordering='',
|
|
2687
|
+
selected=('source', 'source_root_key', 'account_key', 'logical_limit_key', 'observed_slot', 'window_minutes'),
|
|
2688
|
+
effects='read',
|
|
2689
|
+
classes=('cross-period',),
|
|
2690
|
+
inert_rule=CODEX,
|
|
2691
|
+
),
|
|
2692
|
+
AccessContract(
|
|
2693
|
+
function='_cctally_quota:_historic_root_keys',
|
|
2694
|
+
sql_fingerprint='dynamic:_cctally_quota:_historic_root_keys#1',
|
|
2695
|
+
sql_shape='sha256:7034d91472e41a27',
|
|
2696
|
+
table='dynamic',
|
|
2697
|
+
keys=(),
|
|
2698
|
+
predicate='dynamic SQL',
|
|
2699
|
+
ordering='',
|
|
2700
|
+
selected=(),
|
|
2701
|
+
effects='read',
|
|
2702
|
+
classes=('cross-period',),
|
|
2703
|
+
inert_rule=CODEX,
|
|
2704
|
+
),
|
|
2705
|
+
AccessContract(
|
|
2706
|
+
function='_cctally_quota:_insert_quota_terminal_event',
|
|
2707
|
+
sql_fingerprint='INSERT OR IGNORE INTO quota_threshold_events (source, source_root_key, logical_limit_key, observed_slot, window_minutes, resets_at_utc, threshold, qualifying_kind, qualifying_percent, projected_percent, severity, created_at_utc, disposition, alerted_at, suppressed_at, account_key) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
|
|
2708
|
+
table='quota_threshold_events',
|
|
2709
|
+
keys=(),
|
|
2710
|
+
predicate='',
|
|
2711
|
+
ordering='',
|
|
2712
|
+
selected=(),
|
|
2713
|
+
effects='write',
|
|
2714
|
+
classes=('singleton',),
|
|
2715
|
+
inert_rule=CODEX,
|
|
2716
|
+
),
|
|
2717
|
+
AccessContract(
|
|
2718
|
+
function='_cctally_quota:_iter_shard_rows',
|
|
2719
|
+
sql_fingerprint='dynamic:_cctally_quota:_iter_shard_rows#1',
|
|
2720
|
+
sql_shape='sha256:165fc1ccc9cadbab',
|
|
2721
|
+
table='dynamic',
|
|
2722
|
+
keys=(),
|
|
2723
|
+
predicate='dynamic SQL',
|
|
2724
|
+
ordering='',
|
|
2725
|
+
selected=(),
|
|
2726
|
+
effects='read',
|
|
2727
|
+
classes=('cross-period',),
|
|
2728
|
+
inert_rule=CODEX,
|
|
2729
|
+
),
|
|
2730
|
+
AccessContract(
|
|
2731
|
+
function='_cctally_quota:_ledger_rows_after',
|
|
2732
|
+
sql_fingerprint='dynamic:_cctally_quota:_ledger_rows_after#1',
|
|
2733
|
+
sql_shape='sha256:0bc7183f2e3057ba',
|
|
2734
|
+
table='dynamic',
|
|
2735
|
+
keys=(),
|
|
2736
|
+
predicate='dynamic SQL',
|
|
2737
|
+
ordering='',
|
|
2738
|
+
selected=(),
|
|
2739
|
+
effects='read',
|
|
2740
|
+
classes=('cross-period',),
|
|
2741
|
+
inert_rule=CODEX,
|
|
2742
|
+
),
|
|
2743
|
+
AccessContract(
|
|
2744
|
+
function='_cctally_quota:_ledger_state',
|
|
2745
|
+
sql_fingerprint="SELECT watermark_seq, interpretation_version, alerts_enabled, next_evaluation_at_utc, last_full_pass_at, next_evaluation_by_root_json FROM quota_projection_ledger_state WHERE source='codex'",
|
|
2746
|
+
table='quota_projection_ledger_state',
|
|
2747
|
+
keys=(),
|
|
2748
|
+
predicate="source='codex'",
|
|
2749
|
+
ordering='',
|
|
2750
|
+
selected=('watermark_seq', 'interpretation_version', 'alerts_enabled', 'next_evaluation_at_utc', 'last_full_pass_at', 'next_evaluation_by_root_json'),
|
|
2751
|
+
effects='read',
|
|
2752
|
+
classes=('cross-period',),
|
|
2753
|
+
inert_rule=CODEX,
|
|
2754
|
+
),
|
|
2755
|
+
AccessContract(
|
|
2756
|
+
function='_cctally_quota:_load_codex_window_group_evidence',
|
|
2757
|
+
sql_fingerprint='dynamic:_cctally_quota:_load_codex_window_group_evidence#1',
|
|
2758
|
+
sql_shape='sha256:db969904c3774419',
|
|
2759
|
+
table='dynamic',
|
|
2760
|
+
keys=(),
|
|
2761
|
+
predicate='dynamic SQL',
|
|
2762
|
+
ordering='',
|
|
2763
|
+
selected=(),
|
|
2764
|
+
effects='read',
|
|
2765
|
+
classes=('cross-period',),
|
|
2766
|
+
inert_rule=CODEX,
|
|
2767
|
+
),
|
|
2768
|
+
AccessContract(
|
|
2769
|
+
function='_cctally_quota:_orphan_unseen',
|
|
2770
|
+
sql_fingerprint='dynamic:_cctally_quota:_orphan_unseen#1',
|
|
2771
|
+
sql_shape='sha256:c7af562f46f3fbaa',
|
|
2772
|
+
table='dynamic',
|
|
2773
|
+
keys=(),
|
|
2774
|
+
predicate='dynamic SQL',
|
|
2775
|
+
ordering='',
|
|
2776
|
+
selected=(),
|
|
2777
|
+
effects='read',
|
|
2778
|
+
classes=('cross-period',),
|
|
2779
|
+
inert_rule=CODEX,
|
|
2780
|
+
),
|
|
2781
|
+
AccessContract(
|
|
2782
|
+
function='_cctally_quota:_orphan_unseen',
|
|
2783
|
+
sql_fingerprint='dynamic:_cctally_quota:_orphan_unseen#2',
|
|
2784
|
+
sql_shape='sha256:9603ce362ea0ea86',
|
|
2785
|
+
table='dynamic',
|
|
2786
|
+
keys=(),
|
|
2787
|
+
predicate='dynamic SQL',
|
|
2788
|
+
ordering='',
|
|
2789
|
+
selected=(),
|
|
2790
|
+
effects='read',
|
|
2791
|
+
classes=('cross-period',),
|
|
2792
|
+
inert_rule=CODEX,
|
|
2793
|
+
),
|
|
2794
|
+
AccessContract(
|
|
2795
|
+
function='_cctally_quota:_orphan_unseen',
|
|
2796
|
+
sql_fingerprint='dynamic:_cctally_quota:_orphan_unseen#3',
|
|
2797
|
+
sql_shape='sha256:43538e803b819a39',
|
|
2798
|
+
table='dynamic',
|
|
2799
|
+
keys=(),
|
|
2800
|
+
predicate='dynamic SQL',
|
|
2801
|
+
ordering='',
|
|
2802
|
+
selected=(),
|
|
2803
|
+
effects='read',
|
|
2804
|
+
classes=('cross-period',),
|
|
2805
|
+
inert_rule=CODEX,
|
|
2806
|
+
),
|
|
2807
|
+
AccessContract(
|
|
2808
|
+
function='_cctally_quota:_orphan_unseen_scoped',
|
|
2809
|
+
sql_fingerprint='dynamic:_cctally_quota:_orphan_unseen_scoped#1',
|
|
2810
|
+
sql_shape='sha256:ccbdb93e0a0638bd',
|
|
2811
|
+
table='dynamic',
|
|
2812
|
+
keys=(),
|
|
2813
|
+
predicate='dynamic SQL',
|
|
2814
|
+
ordering='',
|
|
2815
|
+
selected=(),
|
|
2816
|
+
effects='read',
|
|
2817
|
+
classes=('cross-period',),
|
|
2818
|
+
inert_rule=CODEX,
|
|
2819
|
+
),
|
|
2820
|
+
AccessContract(
|
|
2821
|
+
function='_cctally_quota:_orphan_unseen_scoped',
|
|
2822
|
+
sql_fingerprint='dynamic:_cctally_quota:_orphan_unseen_scoped#2',
|
|
2823
|
+
sql_shape='sha256:b6c101d59a0df239',
|
|
2824
|
+
table='dynamic',
|
|
2825
|
+
keys=(),
|
|
2826
|
+
predicate='dynamic SQL',
|
|
2827
|
+
ordering='',
|
|
2828
|
+
selected=(),
|
|
2829
|
+
effects='read',
|
|
2830
|
+
classes=('cross-period',),
|
|
2831
|
+
inert_rule=CODEX,
|
|
2832
|
+
),
|
|
2833
|
+
AccessContract(
|
|
2834
|
+
function='_cctally_quota:_orphan_unseen_scoped',
|
|
2835
|
+
sql_fingerprint='dynamic:_cctally_quota:_orphan_unseen_scoped#3',
|
|
2836
|
+
sql_shape='sha256:7fdd1662b4fc9bab',
|
|
2837
|
+
table='dynamic',
|
|
2838
|
+
keys=(),
|
|
2839
|
+
predicate='dynamic SQL',
|
|
2840
|
+
ordering='',
|
|
2841
|
+
selected=(),
|
|
2842
|
+
effects='read',
|
|
2843
|
+
classes=('cross-period',),
|
|
2844
|
+
inert_rule=CODEX,
|
|
2845
|
+
),
|
|
2846
|
+
AccessContract(
|
|
2847
|
+
function='_cctally_quota:_reanchor_terminal_events',
|
|
2848
|
+
sql_fingerprint='dynamic:_cctally_quota:_reanchor_terminal_events#1',
|
|
2849
|
+
sql_shape='sha256:c25bb9f7f3b70ee0',
|
|
2850
|
+
table='dynamic',
|
|
2851
|
+
keys=(),
|
|
2852
|
+
predicate='dynamic SQL',
|
|
2853
|
+
ordering='',
|
|
2854
|
+
selected=(),
|
|
2855
|
+
effects='read',
|
|
2856
|
+
classes=('cross-period',),
|
|
2857
|
+
inert_rule=CODEX,
|
|
2858
|
+
),
|
|
2859
|
+
AccessContract(
|
|
2860
|
+
function='_cctally_quota:_root_accounts',
|
|
2861
|
+
sql_fingerprint="SELECT DISTINCT account_key FROM quota_window_blocks WHERE source='codex' AND source_root_key=? AND orphaned_at IS NULL",
|
|
2862
|
+
table='quota_window_blocks',
|
|
2863
|
+
keys=('source_root_key',),
|
|
2864
|
+
predicate="source='codex' AND source_root_key=? AND orphaned_at IS NULL",
|
|
2865
|
+
ordering='',
|
|
2866
|
+
selected=('DISTINCT account_key',),
|
|
2867
|
+
effects='read',
|
|
2868
|
+
classes=('cross-period',),
|
|
2869
|
+
inert_rule=CODEX,
|
|
2870
|
+
),
|
|
2871
|
+
AccessContract(
|
|
2872
|
+
function='_cctally_quota:_root_group_pairs',
|
|
2873
|
+
sql_fingerprint="SELECT DISTINCT physical_group_key, physical_group_digest FROM quota_window_blocks WHERE source='codex' AND source_root_key=? AND orphaned_at IS NULL AND physical_group_key IS NOT NULL AND physical_group_digest IS NOT NULL",
|
|
2874
|
+
table='quota_window_blocks',
|
|
2875
|
+
keys=('source_root_key',),
|
|
2876
|
+
predicate="source='codex' AND source_root_key=? AND orphaned_at IS NULL AND physical_group_key IS NOT NULL AND physical_group_digest IS NOT NULL",
|
|
2877
|
+
ordering='',
|
|
2878
|
+
selected=('DISTINCT physical_group_key', 'physical_group_digest'),
|
|
2879
|
+
effects='read',
|
|
2880
|
+
classes=('cross-period',),
|
|
2881
|
+
inert_rule=CODEX,
|
|
2882
|
+
),
|
|
2883
|
+
AccessContract(
|
|
2884
|
+
function='_cctally_quota:_stats_projection_signatures_match',
|
|
2885
|
+
sql_fingerprint='SELECT source_root_key, account_key, physical_signature FROM quota_projection_state',
|
|
2886
|
+
table='quota_projection_state',
|
|
2887
|
+
keys=(),
|
|
2888
|
+
predicate='',
|
|
2889
|
+
ordering='',
|
|
2890
|
+
selected=('source_root_key', 'account_key', 'physical_signature'),
|
|
2891
|
+
effects='read',
|
|
2892
|
+
classes=('cross-period',),
|
|
2893
|
+
inert_rule=CODEX,
|
|
2894
|
+
),
|
|
2895
|
+
AccessContract(
|
|
2896
|
+
function='_cctally_quota:_store_ledger_state',
|
|
2897
|
+
sql_fingerprint="INSERT INTO quota_projection_ledger_state (source, watermark_seq, interpretation_version, alerts_enabled, next_evaluation_at_utc, last_full_pass_at, next_evaluation_by_root_json) VALUES ('codex',?,?,?,?,?,?) ON CONFLICT(source) DO UPDATE SET watermark_seq=excluded.watermark_seq, interpretation_version=excluded.interpretation_version, alerts_enabled=excluded.alerts_enabled, next_evaluation_at_utc=excluded.next_evaluation_at_utc, last_full_pass_at=excluded.last_full_pass_at, next_evaluation_by_root_json=excluded.next_evaluation_by_root_json",
|
|
2898
|
+
table='quota_projection_ledger_state',
|
|
2899
|
+
keys=(),
|
|
2900
|
+
predicate='',
|
|
2901
|
+
ordering='',
|
|
2902
|
+
selected=(),
|
|
2903
|
+
effects='upsert',
|
|
2904
|
+
classes=('singleton',),
|
|
2905
|
+
inert_rule=CODEX,
|
|
2906
|
+
),
|
|
2907
|
+
AccessContract(
|
|
2908
|
+
function='_cctally_quota:load_codex_quota_observations',
|
|
2909
|
+
sql_fingerprint='dynamic:_cctally_quota:load_codex_quota_observations#1',
|
|
2910
|
+
sql_shape='sha256:6a6e082ae339b9cf',
|
|
2911
|
+
table='dynamic',
|
|
2912
|
+
keys=(),
|
|
2913
|
+
predicate='dynamic SQL',
|
|
2914
|
+
ordering='',
|
|
2915
|
+
selected=(),
|
|
2916
|
+
effects='read',
|
|
2917
|
+
classes=('cross-period',),
|
|
2918
|
+
inert_rule=CODEX,
|
|
2919
|
+
),
|
|
2920
|
+
AccessContract(
|
|
2921
|
+
function='_cctally_quota:reconcile_codex_quota_projection',
|
|
2922
|
+
sql_fingerprint="SELECT 1 FROM quota_alert_arming WHERE source='codex' LIMIT 1",
|
|
2923
|
+
table='quota_alert_arming',
|
|
2924
|
+
keys=(),
|
|
2925
|
+
predicate="source='codex'",
|
|
2926
|
+
ordering='',
|
|
2927
|
+
selected=('1',),
|
|
2928
|
+
effects='read',
|
|
2929
|
+
classes=('cross-period',),
|
|
2930
|
+
inert_rule=CODEX,
|
|
2931
|
+
),
|
|
2932
|
+
AccessContract(
|
|
2933
|
+
function='_cctally_record:_apply_credit',
|
|
2934
|
+
sql_fingerprint='INSERT OR IGNORE INTO weekly_credit_floors (week_start_date, effective_at_utc, observed_pre_credit_pct, applied_at_utc, account_key) VALUES (?, ?, ?, ?, ?)',
|
|
2935
|
+
table='weekly_credit_floors',
|
|
2936
|
+
keys=(),
|
|
2937
|
+
predicate='',
|
|
2938
|
+
ordering='',
|
|
2939
|
+
selected=(),
|
|
2940
|
+
effects='write',
|
|
2941
|
+
classes=('singleton',),
|
|
2942
|
+
inert_rule=MANUAL,
|
|
2943
|
+
),
|
|
2944
|
+
AccessContract(
|
|
2945
|
+
function='_cctally_record:_apply_credit',
|
|
2946
|
+
sql_fingerprint='SELECT journal_id FROM weekly_credit_floors WHERE week_start_date = ? AND account_key = ? AND journal_id IS NOT NULL AND journal_id != ?',
|
|
2947
|
+
table='weekly_credit_floors',
|
|
2948
|
+
keys=('week_start_date', 'account_key'),
|
|
2949
|
+
predicate='week_start_date = ? AND account_key = ? AND journal_id IS NOT NULL AND journal_id != ?',
|
|
2950
|
+
ordering='',
|
|
2951
|
+
selected=('journal_id',),
|
|
2952
|
+
effects='read',
|
|
2953
|
+
classes=('period-keyed',),
|
|
2954
|
+
inert_rule=MANUAL,
|
|
2955
|
+
),
|
|
2956
|
+
AccessContract(
|
|
2957
|
+
function='_cctally_record:_apply_credit',
|
|
2958
|
+
sql_fingerprint="SELECT journal_id FROM weekly_usage_snapshots WHERE week_start_date = ? AND account_key = ? AND source = 'record-credit' AND journal_id IS NOT NULL AND journal_id NOT LIKE 'sa:' || ? || ':syn:%'",
|
|
2959
|
+
table='weekly_usage_snapshots',
|
|
2960
|
+
keys=('week_start_date', 'account_key'),
|
|
2961
|
+
predicate="week_start_date = ? AND account_key = ? AND source = 'record-credit' AND journal_id IS NOT NULL AND journal_id NOT LIKE 'sa:' || ? || ':syn:%'",
|
|
2962
|
+
ordering='',
|
|
2963
|
+
selected=('journal_id',),
|
|
2964
|
+
effects='read',
|
|
2965
|
+
classes=('period-keyed',),
|
|
2966
|
+
inert_rule=MANUAL,
|
|
2967
|
+
),
|
|
2968
|
+
AccessContract(
|
|
2969
|
+
function='_cctally_record:_arm_reset_debounce_state',
|
|
2970
|
+
sql_fingerprint='INSERT INTO weekly_reset_debounce_state (account_key, week_start_date, week_end_at, baseline_pct, first_zero_at_utc, first_zero_observation_id) VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT(account_key) DO UPDATE SET week_start_date = excluded.week_start_date, week_end_at = excluded.week_end_at, baseline_pct = excluded.baseline_pct, first_zero_at_utc = excluded.first_zero_at_utc, first_zero_observation_id = excluded.first_zero_observation_id',
|
|
2971
|
+
table='weekly_reset_debounce_state',
|
|
2972
|
+
keys=(),
|
|
2973
|
+
predicate='',
|
|
2974
|
+
ordering='',
|
|
2975
|
+
selected=(),
|
|
2976
|
+
effects='upsert',
|
|
2977
|
+
classes=('singleton',),
|
|
2978
|
+
inert_rule=None,
|
|
2979
|
+
),
|
|
2980
|
+
AccessContract(
|
|
2981
|
+
function='_cctally_record:_clear_reset_debounce_state',
|
|
2982
|
+
sql_fingerprint='DELETE FROM weekly_reset_debounce_state WHERE account_key = ?',
|
|
2983
|
+
table='weekly_reset_debounce_state',
|
|
2984
|
+
keys=('account_key',),
|
|
2985
|
+
predicate='account_key = ?',
|
|
2986
|
+
ordering='',
|
|
2987
|
+
selected=(),
|
|
2988
|
+
effects='delete',
|
|
2989
|
+
classes=('singleton',),
|
|
2990
|
+
inert_rule=None,
|
|
2991
|
+
),
|
|
2992
|
+
AccessContract(
|
|
2993
|
+
function='_cctally_record:_delete_doomed_snapshot_rows',
|
|
2994
|
+
sql_fingerprint='dynamic:_cctally_record:_delete_doomed_snapshot_rows#1',
|
|
2995
|
+
sql_shape='sha256:029afc7add377117',
|
|
2996
|
+
table='dynamic',
|
|
2997
|
+
keys=(),
|
|
2998
|
+
predicate='stale-replica band: account, date key, capture >= effective, weekly band, carrying its own five-hour reading (spec 4.7 revision 7: kept weekly-held)',
|
|
2999
|
+
ordering='',
|
|
3000
|
+
selected=(),
|
|
3001
|
+
effects='write',
|
|
3002
|
+
classes=('period-keyed', 'range-keyed'),
|
|
3003
|
+
inert_rule=None,
|
|
3004
|
+
),
|
|
3005
|
+
AccessContract(
|
|
3006
|
+
function='_cctally_record:_delete_doomed_snapshot_rows',
|
|
3007
|
+
sql_fingerprint='dynamic:_cctally_record:_delete_doomed_snapshot_rows#2',
|
|
3008
|
+
sql_shape='sha256:332a2909ac5f8963',
|
|
3009
|
+
table='dynamic',
|
|
3010
|
+
keys=(),
|
|
3011
|
+
predicate='stale-replica band: account, date key, capture >= effective, weekly band',
|
|
3012
|
+
ordering='',
|
|
3013
|
+
selected=(),
|
|
3014
|
+
effects='delete',
|
|
3015
|
+
classes=('period-keyed', 'range-keyed'),
|
|
3016
|
+
inert_rule=None,
|
|
3017
|
+
),
|
|
3018
|
+
AccessContract(
|
|
3019
|
+
function='_cctally_record:_derive_5h_window_key',
|
|
3020
|
+
sql_fingerprint='SELECT five_hour_resets_at, five_hour_window_key FROM weekly_usage_snapshots WHERE five_hour_resets_at IS NOT NULL AND five_hour_window_key IS NOT NULL AND account_key = ? ORDER BY captured_at_utc DESC, id DESC LIMIT 1',
|
|
3021
|
+
table='weekly_usage_snapshots',
|
|
3022
|
+
keys=('account_key',),
|
|
3023
|
+
predicate='five_hour_resets_at IS NOT NULL AND five_hour_window_key IS NOT NULL AND account_key = ?',
|
|
3024
|
+
ordering='captured_at_utc DESC, id DESC',
|
|
3025
|
+
selected=('five_hour_resets_at', 'five_hour_window_key'),
|
|
3026
|
+
effects='read',
|
|
3027
|
+
classes=('cross-period',),
|
|
3028
|
+
inert_rule=ANCHOR,
|
|
3029
|
+
),
|
|
3030
|
+
AccessContract(
|
|
3031
|
+
function='_cctally_record:_derive_5h_window_key',
|
|
3032
|
+
sql_fingerprint="SELECT five_hour_window_key, five_hour_resets_at FROM five_hour_blocks WHERE account_key = ? AND abs(? - CAST(strftime('%s', five_hour_resets_at) AS INTEGER)) <= ? ORDER BY abs(? - CAST(strftime('%s', five_hour_resets_at) AS INTEGER)) ASC LIMIT 1",
|
|
3033
|
+
table='five_hour_blocks',
|
|
3034
|
+
keys=('account_key',),
|
|
3035
|
+
predicate="account_key = ? AND abs(? - CAST(strftime('%s', five_hour_resets_at) AS INTEGER)) <= ?",
|
|
3036
|
+
ordering="abs(? - CAST(strftime('%s', five_hour_resets_at) AS INTEGER)) ASC",
|
|
3037
|
+
selected=('five_hour_window_key', 'five_hour_resets_at'),
|
|
3038
|
+
effects='read',
|
|
3039
|
+
classes=('range-keyed', 'cross-period'),
|
|
3040
|
+
inert_rule=ANCHOR,
|
|
3041
|
+
),
|
|
3042
|
+
AccessContract(
|
|
3043
|
+
function='_cctally_record:_doomed_snapshot_rows',
|
|
3044
|
+
sql_fingerprint='dynamic:_cctally_record:_doomed_snapshot_rows#1',
|
|
3045
|
+
sql_shape='sha256:b5941392ff09fd6b',
|
|
3046
|
+
table='dynamic',
|
|
3047
|
+
keys=(),
|
|
3048
|
+
predicate='stale-replica band: account, date key, capture >= effective, weekly band',
|
|
3049
|
+
ordering='',
|
|
3050
|
+
selected=(),
|
|
3051
|
+
effects='read',
|
|
3052
|
+
classes=('period-keyed', 'range-keyed'),
|
|
3053
|
+
inert_rule=None,
|
|
3054
|
+
),
|
|
3055
|
+
AccessContract(
|
|
3056
|
+
function='_cctally_record:_fire_in_place_credit',
|
|
3057
|
+
sql_fingerprint='INSERT OR IGNORE INTO week_reset_events (detected_at_utc, old_week_end_at, new_week_end_at, effective_reset_at_utc, observed_pre_credit_pct, account_key, origin_observation_id) VALUES (?, ?, ?, ?, ?, ?, ?)',
|
|
3058
|
+
table='week_reset_events',
|
|
3059
|
+
keys=(),
|
|
3060
|
+
predicate='',
|
|
3061
|
+
ordering='',
|
|
3062
|
+
selected=(),
|
|
3063
|
+
effects='write',
|
|
3064
|
+
classes=('singleton',),
|
|
3065
|
+
inert_rule=None,
|
|
3066
|
+
),
|
|
3067
|
+
AccessContract(
|
|
3068
|
+
function='_cctally_record:_five_hour_ownership_windows',
|
|
3069
|
+
sql_fingerprint='SELECT five_hour_window_key, block_start_at, five_hour_resets_at FROM five_hour_blocks WHERE account_key = ? AND five_hour_window_key != ? AND unixepoch(five_hour_resets_at) > unixepoch(?) AND unixepoch(block_start_at) <= unixepoch(?)',
|
|
3070
|
+
table='five_hour_blocks',
|
|
3071
|
+
keys=('account_key',),
|
|
3072
|
+
predicate='account_key = ? AND five_hour_window_key != ? AND unixepoch(five_hour_resets_at) > unixepoch(?) AND unixepoch(block_start_at) <= unixepoch(?)',
|
|
3073
|
+
ordering='',
|
|
3074
|
+
selected=('five_hour_window_key', 'block_start_at', 'five_hour_resets_at'),
|
|
3075
|
+
effects='read',
|
|
3076
|
+
classes=('range-keyed', 'cross-period'),
|
|
3077
|
+
inert_rule=BLOCKS,
|
|
3078
|
+
),
|
|
3079
|
+
AccessContract(
|
|
3080
|
+
function='_cctally_record:_insert_credit_snapshot',
|
|
3081
|
+
sql_fingerprint='dynamic:_cctally_record:_insert_credit_snapshot#1',
|
|
3082
|
+
sql_shape='sha256:93b68f833e86ea12',
|
|
3083
|
+
table='dynamic',
|
|
3084
|
+
keys=(),
|
|
3085
|
+
predicate='dynamic SQL',
|
|
3086
|
+
ordering='',
|
|
3087
|
+
selected=(),
|
|
3088
|
+
effects='read',
|
|
3089
|
+
classes=('cross-period',),
|
|
3090
|
+
inert_rule=MANUAL,
|
|
3091
|
+
),
|
|
3092
|
+
AccessContract(
|
|
3093
|
+
function='_cctally_record:_pipeline_claude_usage',
|
|
3094
|
+
sql_fingerprint='SELECT * FROM weekly_usage_snapshots WHERE week_start_date = ? AND account_key = ? ORDER BY captured_at_utc DESC, id DESC LIMIT 1',
|
|
3095
|
+
table='weekly_usage_snapshots',
|
|
3096
|
+
keys=('week_start_date', 'account_key'),
|
|
3097
|
+
predicate='week_start_date = ? AND account_key = ?',
|
|
3098
|
+
ordering='captured_at_utc DESC, id DESC',
|
|
3099
|
+
selected=('*',),
|
|
3100
|
+
effects='read',
|
|
3101
|
+
classes=('period-keyed',),
|
|
3102
|
+
inert_rule=None,
|
|
3103
|
+
),
|
|
3104
|
+
AccessContract(
|
|
3105
|
+
function='_cctally_record:_pipeline_claude_usage',
|
|
3106
|
+
sql_fingerprint='SELECT * FROM weekly_usage_snapshots WHERE id = ?',
|
|
3107
|
+
table='weekly_usage_snapshots',
|
|
3108
|
+
keys=('id',),
|
|
3109
|
+
predicate='id = ?',
|
|
3110
|
+
ordering='',
|
|
3111
|
+
selected=('*',),
|
|
3112
|
+
effects='read',
|
|
3113
|
+
classes=('period-keyed',),
|
|
3114
|
+
inert_rule=None,
|
|
3115
|
+
),
|
|
3116
|
+
AccessContract(
|
|
3117
|
+
function='_cctally_record:_read_five_hour_source_state',
|
|
3118
|
+
sql_fingerprint='SELECT baseline_pct, pending_low_pct, pending_at_utc, pending_observation_id FROM five_hour_credit_confirmation_state WHERE account_key = ? AND five_hour_window_key = ? AND source = ?',
|
|
3119
|
+
table='five_hour_credit_confirmation_state',
|
|
3120
|
+
keys=('account_key', 'five_hour_window_key', 'source'),
|
|
3121
|
+
predicate='account_key = ? AND five_hour_window_key = ? AND source = ?',
|
|
3122
|
+
ordering='',
|
|
3123
|
+
selected=('baseline_pct', 'pending_low_pct', 'pending_at_utc', 'pending_observation_id'),
|
|
3124
|
+
effects='read',
|
|
3125
|
+
classes=('period-keyed',),
|
|
3126
|
+
inert_rule=None,
|
|
3127
|
+
),
|
|
3128
|
+
AccessContract(
|
|
3129
|
+
function='_cctally_record:_read_reset_debounce_state',
|
|
3130
|
+
sql_fingerprint='SELECT week_start_date, week_end_at, baseline_pct, first_zero_at_utc, first_zero_observation_id FROM weekly_reset_debounce_state WHERE account_key = ?',
|
|
3131
|
+
table='weekly_reset_debounce_state',
|
|
3132
|
+
keys=('account_key',),
|
|
3133
|
+
predicate='account_key = ?',
|
|
3134
|
+
ordering='',
|
|
3135
|
+
selected=('week_start_date', 'week_end_at', 'baseline_pct', 'first_zero_at_utc', 'first_zero_observation_id'),
|
|
3136
|
+
effects='read',
|
|
3137
|
+
classes=('cross-period',),
|
|
3138
|
+
inert_rule=DEBOUNCE,
|
|
3139
|
+
),
|
|
3140
|
+
AccessContract(
|
|
3141
|
+
function='_cctally_record:_record_budget_milestone_for_vendor',
|
|
3142
|
+
sql_fingerprint='SELECT id FROM budget_milestones WHERE vendor=? AND account_key=? AND period_start_at=? AND period=? AND threshold=?',
|
|
3143
|
+
table='budget_milestones',
|
|
3144
|
+
keys=('vendor', 'account_key', 'period_start_at', 'period', 'threshold'),
|
|
3145
|
+
predicate='vendor=? AND account_key=? AND period_start_at=? AND period=? AND threshold=?',
|
|
3146
|
+
ordering='',
|
|
3147
|
+
selected=('id',),
|
|
3148
|
+
effects='read',
|
|
3149
|
+
classes=('period-keyed',),
|
|
3150
|
+
inert_rule=Q7,
|
|
3151
|
+
),
|
|
3152
|
+
AccessContract(
|
|
3153
|
+
function='_cctally_record:_record_budget_milestone_for_vendor',
|
|
3154
|
+
sql_fingerprint='SELECT threshold FROM budget_milestones WHERE vendor = ? AND account_key = ? AND period_start_at = ? AND (period = ? OR period IS NULL)',
|
|
3155
|
+
table='budget_milestones',
|
|
3156
|
+
keys=('vendor', 'account_key', 'period_start_at', 'period'),
|
|
3157
|
+
predicate='vendor = ? AND account_key = ? AND period_start_at = ? AND (period = ? OR period IS NULL)',
|
|
3158
|
+
ordering='',
|
|
3159
|
+
selected=('threshold',),
|
|
3160
|
+
effects='read',
|
|
3161
|
+
classes=('period-keyed',),
|
|
3162
|
+
inert_rule=Q7,
|
|
3163
|
+
),
|
|
3164
|
+
AccessContract(
|
|
3165
|
+
function='_cctally_record:_write_five_hour_source_state',
|
|
3166
|
+
sql_fingerprint='DELETE FROM five_hour_credit_confirmation_state WHERE account_key = ? AND source = ? AND five_hour_window_key < ?',
|
|
3167
|
+
table='five_hour_credit_confirmation_state',
|
|
3168
|
+
keys=('account_key', 'source'),
|
|
3169
|
+
predicate='account_key = ? AND source = ? AND five_hour_window_key < ?',
|
|
3170
|
+
ordering='',
|
|
3171
|
+
selected=(),
|
|
3172
|
+
effects='delete',
|
|
3173
|
+
classes=('singleton', 'range-keyed'),
|
|
3174
|
+
inert_rule=None,
|
|
3175
|
+
),
|
|
3176
|
+
AccessContract(
|
|
3177
|
+
function='_cctally_record:_write_five_hour_source_state',
|
|
3178
|
+
sql_fingerprint='INSERT INTO five_hour_credit_confirmation_state (account_key, five_hour_window_key, source, baseline_pct, pending_low_pct, pending_at_utc, pending_observation_id) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT(account_key, five_hour_window_key, source) DO UPDATE SET baseline_pct = excluded.baseline_pct, pending_low_pct = excluded.pending_low_pct, pending_at_utc = excluded.pending_at_utc, pending_observation_id = excluded.pending_observation_id',
|
|
3179
|
+
table='five_hour_credit_confirmation_state',
|
|
3180
|
+
keys=(),
|
|
3181
|
+
predicate='',
|
|
3182
|
+
ordering='',
|
|
3183
|
+
selected=(),
|
|
3184
|
+
effects='upsert',
|
|
3185
|
+
classes=('singleton',),
|
|
3186
|
+
inert_rule=None,
|
|
3187
|
+
),
|
|
3188
|
+
AccessContract(
|
|
3189
|
+
function='_cctally_record:detect_reset_and_credit',
|
|
3190
|
+
sql_fingerprint='DELETE FROM weekly_usage_snapshots WHERE five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(?) AND ABS(five_hour_percent - ?) < 1.0',
|
|
3191
|
+
table='weekly_usage_snapshots',
|
|
3192
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
3193
|
+
predicate='five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(?) AND ABS(five_hour_percent - ?) < 1.0',
|
|
3194
|
+
ordering='',
|
|
3195
|
+
selected=(),
|
|
3196
|
+
effects='delete',
|
|
3197
|
+
classes=('period-keyed', 'range-keyed'),
|
|
3198
|
+
inert_rule=None,
|
|
3199
|
+
),
|
|
3200
|
+
AccessContract(
|
|
3201
|
+
function='_cctally_record:detect_reset_and_credit',
|
|
3202
|
+
sql_fingerprint='INSERT OR IGNORE INTO five_hour_reset_events (detected_at_utc, five_hour_window_key, prior_percent, post_percent, effective_reset_at_utc, account_key) VALUES (?, ?, ?, ?, ?, ?)',
|
|
3203
|
+
table='five_hour_reset_events',
|
|
3204
|
+
keys=(),
|
|
3205
|
+
predicate='',
|
|
3206
|
+
ordering='',
|
|
3207
|
+
selected=(),
|
|
3208
|
+
effects='write',
|
|
3209
|
+
classes=('singleton',),
|
|
3210
|
+
inert_rule=None,
|
|
3211
|
+
),
|
|
3212
|
+
AccessContract(
|
|
3213
|
+
function='_cctally_record:detect_reset_and_credit',
|
|
3214
|
+
sql_fingerprint='INSERT OR IGNORE INTO week_reset_events (detected_at_utc, old_week_end_at, new_week_end_at, effective_reset_at_utc, account_key, origin_observation_id) VALUES (?, ?, ?, ?, ?, ?)',
|
|
3215
|
+
table='week_reset_events',
|
|
3216
|
+
keys=(),
|
|
3217
|
+
predicate='',
|
|
3218
|
+
ordering='',
|
|
3219
|
+
selected=(),
|
|
3220
|
+
effects='write',
|
|
3221
|
+
classes=('singleton',),
|
|
3222
|
+
inert_rule=None,
|
|
3223
|
+
),
|
|
3224
|
+
AccessContract(
|
|
3225
|
+
function='_cctally_record:detect_reset_and_credit',
|
|
3226
|
+
sql_fingerprint='SELECT five_hour_window_key, five_hour_percent, five_hour_resets_at FROM weekly_usage_snapshots WHERE five_hour_window_key IS NOT NULL AND five_hour_percent IS NOT NULL AND account_key = ? ORDER BY captured_at_utc DESC, id DESC LIMIT 1',
|
|
3227
|
+
table='weekly_usage_snapshots',
|
|
3228
|
+
keys=('account_key',),
|
|
3229
|
+
predicate='five_hour_window_key IS NOT NULL AND five_hour_percent IS NOT NULL AND account_key = ?',
|
|
3230
|
+
ordering='captured_at_utc DESC, id DESC',
|
|
3231
|
+
selected=('five_hour_window_key', 'five_hour_percent', 'five_hour_resets_at'),
|
|
3232
|
+
effects='read',
|
|
3233
|
+
classes=('cross-period',),
|
|
3234
|
+
inert_rule=PRED_FIVE,
|
|
3235
|
+
),
|
|
3236
|
+
AccessContract(
|
|
3237
|
+
function='_cctally_record:detect_reset_and_credit',
|
|
3238
|
+
sql_fingerprint='UPDATE weekly_usage_snapshots SET five_hour_percent = NULL, five_hour_resets_at = NULL, five_hour_window_key = NULL WHERE five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(?) AND ABS(five_hour_percent - ?) < 1.0',
|
|
3239
|
+
table='weekly_usage_snapshots',
|
|
3240
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
3241
|
+
predicate='five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(?) AND ABS(five_hour_percent - ?) < 1.0',
|
|
3242
|
+
ordering='',
|
|
3243
|
+
selected=(),
|
|
3244
|
+
effects='write',
|
|
3245
|
+
classes=('period-keyed', 'range-keyed'),
|
|
3246
|
+
inert_rule=None,
|
|
3247
|
+
),
|
|
3248
|
+
AccessContract(
|
|
3249
|
+
function='_cctally_record:detect_reset_and_credit',
|
|
3250
|
+
sql_fingerprint='UPDATE weekly_usage_snapshots SET five_hour_percent = NULL, five_hour_resets_at = NULL, five_hour_window_key = NULL WHERE five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(?) AND ABS(five_hour_percent - ?) < 1.0 AND weekly_observation_held = 0',
|
|
3251
|
+
table='weekly_usage_snapshots',
|
|
3252
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
3253
|
+
predicate='five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(?) AND ABS(five_hour_percent - ?) < 1.0 AND weekly_observation_held = 0',
|
|
3254
|
+
ordering='',
|
|
3255
|
+
selected=(),
|
|
3256
|
+
effects='write',
|
|
3257
|
+
classes=('period-keyed', 'range-keyed'),
|
|
3258
|
+
inert_rule=None,
|
|
3259
|
+
),
|
|
3260
|
+
AccessContract(
|
|
3261
|
+
function='_cctally_record:detect_reset_and_credit',
|
|
3262
|
+
sql_fingerprint='SELECT journal_id FROM weekly_usage_snapshots WHERE five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(?) AND ABS(five_hour_percent - ?) < 1.0',
|
|
3263
|
+
table='weekly_usage_snapshots',
|
|
3264
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
3265
|
+
predicate='five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(?) AND ABS(five_hour_percent - ?) < 1.0',
|
|
3266
|
+
ordering='',
|
|
3267
|
+
selected=('journal_id',),
|
|
3268
|
+
effects='read',
|
|
3269
|
+
classes=('period-keyed', 'range-keyed'),
|
|
3270
|
+
inert_rule=None,
|
|
3271
|
+
),
|
|
3272
|
+
AccessContract(
|
|
3273
|
+
function='_cctally_record:detect_reset_and_credit',
|
|
3274
|
+
sql_fingerprint='SELECT prior_percent, post_percent FROM five_hour_reset_events WHERE five_hour_window_key = ? AND account_key = ? ORDER BY id DESC LIMIT 1',
|
|
3275
|
+
table='five_hour_reset_events',
|
|
3276
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
3277
|
+
predicate='five_hour_window_key = ? AND account_key = ?',
|
|
3278
|
+
ordering='id DESC',
|
|
3279
|
+
selected=('prior_percent', 'post_percent'),
|
|
3280
|
+
effects='read',
|
|
3281
|
+
classes=('period-keyed',),
|
|
3282
|
+
inert_rule=None,
|
|
3283
|
+
),
|
|
3284
|
+
AccessContract(
|
|
3285
|
+
function='_cctally_record:detect_reset_and_credit',
|
|
3286
|
+
sql_fingerprint='SELECT week_end_at, weekly_percent FROM weekly_usage_snapshots WHERE week_end_at IS NOT NULL AND account_key = ? AND weekly_observation_held = 0 ORDER BY captured_at_utc DESC, id DESC LIMIT 1',
|
|
3287
|
+
table='weekly_usage_snapshots',
|
|
3288
|
+
keys=('account_key',),
|
|
3289
|
+
predicate='week_end_at IS NOT NULL AND account_key = ? AND weekly_observation_held = 0',
|
|
3290
|
+
ordering='captured_at_utc DESC, id DESC',
|
|
3291
|
+
selected=('week_end_at', 'weekly_percent'),
|
|
3292
|
+
effects='read',
|
|
3293
|
+
classes=('cross-period',),
|
|
3294
|
+
inert_rule=PRED_WEEKLY,
|
|
3295
|
+
),
|
|
3296
|
+
AccessContract(
|
|
3297
|
+
function='_cctally_record:maybe_record_milestone',
|
|
3298
|
+
sql_fingerprint='SELECT MIN(weekly_percent) FROM weekly_usage_snapshots WHERE week_start_date = ? AND account_key = ? AND weekly_observation_held = 0 AND unixepoch(captured_at_utc) >= unixepoch(?) AND unixepoch(captured_at_utc) <= unixepoch(?)',
|
|
3299
|
+
table='weekly_usage_snapshots',
|
|
3300
|
+
keys=('week_start_date', 'account_key'),
|
|
3301
|
+
predicate='week_start_date = ? AND account_key = ? AND weekly_observation_held = 0 AND unixepoch(captured_at_utc) >= unixepoch(?) AND unixepoch(captured_at_utc) <= unixepoch(?)',
|
|
3302
|
+
ordering='',
|
|
3303
|
+
selected=('MIN(weekly_percent)',),
|
|
3304
|
+
effects='read',
|
|
3305
|
+
classes=('period-keyed', 'range-keyed'),
|
|
3306
|
+
inert_rule=Q7,
|
|
3307
|
+
),
|
|
3308
|
+
AccessContract(
|
|
3309
|
+
function='_cctally_record:maybe_record_milestone',
|
|
3310
|
+
sql_fingerprint='SELECT cumulative_cost_usd, week_start_at FROM percent_milestones WHERE week_start_date = ? AND percent_threshold = ? AND reset_event_id = ? AND account_key = ?',
|
|
3311
|
+
table='percent_milestones',
|
|
3312
|
+
keys=('week_start_date', 'percent_threshold', 'reset_event_id', 'account_key'),
|
|
3313
|
+
predicate='week_start_date = ? AND percent_threshold = ? AND reset_event_id = ? AND account_key = ?',
|
|
3314
|
+
ordering='',
|
|
3315
|
+
selected=('cumulative_cost_usd', 'week_start_at'),
|
|
3316
|
+
effects='read',
|
|
3317
|
+
classes=('period-keyed',),
|
|
3318
|
+
inert_rule=Q7,
|
|
3319
|
+
),
|
|
3320
|
+
AccessContract(
|
|
3321
|
+
function='_cctally_record:maybe_record_milestone',
|
|
3322
|
+
sql_fingerprint='UPDATE percent_milestones SET alerted_at = ? WHERE week_start_date = ? AND percent_threshold = ? AND reset_event_id = ? AND account_key = ? AND alerted_at IS NULL',
|
|
3323
|
+
table='percent_milestones',
|
|
3324
|
+
keys=('week_start_date', 'percent_threshold', 'reset_event_id', 'account_key'),
|
|
3325
|
+
predicate='week_start_date = ? AND percent_threshold = ? AND reset_event_id = ? AND account_key = ? AND alerted_at IS NULL',
|
|
3326
|
+
ordering='',
|
|
3327
|
+
selected=(),
|
|
3328
|
+
effects='write',
|
|
3329
|
+
classes=('period-keyed',),
|
|
3330
|
+
inert_rule=Q7,
|
|
3331
|
+
),
|
|
3332
|
+
AccessContract(
|
|
3333
|
+
function='_cctally_record:maybe_record_project_budget_milestone',
|
|
3334
|
+
sql_fingerprint='SELECT project_key, threshold FROM project_budget_milestones WHERE week_start_at = ?',
|
|
3335
|
+
table='project_budget_milestones',
|
|
3336
|
+
keys=('week_start_at',),
|
|
3337
|
+
predicate='week_start_at = ?',
|
|
3338
|
+
ordering='',
|
|
3339
|
+
selected=('project_key', 'threshold'),
|
|
3340
|
+
effects='read',
|
|
3341
|
+
classes=('period-keyed',),
|
|
3342
|
+
inert_rule=Q7,
|
|
3343
|
+
),
|
|
3344
|
+
AccessContract(
|
|
3345
|
+
function='_cctally_record:maybe_record_project_budget_milestone',
|
|
3346
|
+
sql_fingerprint='UPDATE project_budget_milestones SET alerted_at = ? WHERE week_start_at = ? AND project_key = ? AND threshold = ? AND alerted_at IS NULL',
|
|
3347
|
+
table='project_budget_milestones',
|
|
3348
|
+
keys=('week_start_at', 'project_key', 'threshold'),
|
|
3349
|
+
predicate='week_start_at = ? AND project_key = ? AND threshold = ? AND alerted_at IS NULL',
|
|
3350
|
+
ordering='',
|
|
3351
|
+
selected=(),
|
|
3352
|
+
effects='write',
|
|
3353
|
+
classes=('period-keyed',),
|
|
3354
|
+
inert_rule=Q7,
|
|
3355
|
+
),
|
|
3356
|
+
AccessContract(
|
|
3357
|
+
function='_cctally_record:maybe_record_projected_alert',
|
|
3358
|
+
sql_fingerprint='UPDATE projected_milestones SET alerted_at = ? WHERE week_start_at = ? AND period = ? AND metric = ? AND threshold = ? AND alerted_at IS NULL',
|
|
3359
|
+
table='projected_milestones',
|
|
3360
|
+
keys=('week_start_at', 'period', 'metric', 'threshold'),
|
|
3361
|
+
predicate='week_start_at = ? AND period = ? AND metric = ? AND threshold = ? AND alerted_at IS NULL',
|
|
3362
|
+
ordering='',
|
|
3363
|
+
selected=(),
|
|
3364
|
+
effects='write',
|
|
3365
|
+
classes=('period-keyed',),
|
|
3366
|
+
inert_rule=Q7,
|
|
3367
|
+
),
|
|
3368
|
+
AccessContract(
|
|
3369
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3370
|
+
sql_fingerprint='DELETE FROM five_hour_block_models WHERE five_hour_window_key = ? AND account_key = ?',
|
|
3371
|
+
table='five_hour_block_models',
|
|
3372
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
3373
|
+
predicate='five_hour_window_key = ? AND account_key = ?',
|
|
3374
|
+
ordering='',
|
|
3375
|
+
selected=(),
|
|
3376
|
+
effects='delete',
|
|
3377
|
+
classes=('period-keyed',),
|
|
3378
|
+
inert_rule=BLOCKS,
|
|
3379
|
+
),
|
|
3380
|
+
AccessContract(
|
|
3381
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3382
|
+
sql_fingerprint='DELETE FROM five_hour_block_projects WHERE five_hour_window_key = ? AND account_key = ?',
|
|
3383
|
+
table='five_hour_block_projects',
|
|
3384
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
3385
|
+
predicate='five_hour_window_key = ? AND account_key = ?',
|
|
3386
|
+
ordering='',
|
|
3387
|
+
selected=(),
|
|
3388
|
+
effects='delete',
|
|
3389
|
+
classes=('period-keyed',),
|
|
3390
|
+
inert_rule=BLOCKS,
|
|
3391
|
+
),
|
|
3392
|
+
AccessContract(
|
|
3393
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3394
|
+
sql_fingerprint='INSERT INTO five_hour_block_models ( block_id, five_hour_window_key, model, input_tokens, output_tokens, cache_create_tokens, cache_read_tokens, cost_usd, entry_count, account_key ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
3395
|
+
table='five_hour_block_models',
|
|
3396
|
+
keys=(),
|
|
3397
|
+
predicate='',
|
|
3398
|
+
ordering='',
|
|
3399
|
+
selected=(),
|
|
3400
|
+
effects='write',
|
|
3401
|
+
classes=('singleton',),
|
|
3402
|
+
inert_rule=BLOCKS,
|
|
3403
|
+
),
|
|
3404
|
+
AccessContract(
|
|
3405
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3406
|
+
sql_fingerprint='INSERT INTO five_hour_block_projects ( block_id, five_hour_window_key, project_path, input_tokens, output_tokens, cache_create_tokens, cache_read_tokens, cost_usd, entry_count, account_key ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
3407
|
+
table='five_hour_block_projects',
|
|
3408
|
+
keys=(),
|
|
3409
|
+
predicate='',
|
|
3410
|
+
ordering='',
|
|
3411
|
+
selected=(),
|
|
3412
|
+
effects='write',
|
|
3413
|
+
classes=('singleton',),
|
|
3414
|
+
inert_rule=BLOCKS,
|
|
3415
|
+
),
|
|
3416
|
+
AccessContract(
|
|
3417
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3418
|
+
sql_fingerprint='INSERT INTO five_hour_blocks ( five_hour_window_key, five_hour_resets_at, block_start_at, first_observed_at_utc, last_observed_at_utc, final_five_hour_percent, seven_day_pct_at_block_start, seven_day_pct_at_block_end, crossed_seven_day_reset, total_input_tokens, total_output_tokens, total_cache_create_tokens, total_cache_read_tokens, total_cost_usd, pricing_provenance_json, is_closed, created_at_utc, last_updated_at_utc, account_key ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?) ON CONFLICT(account_key, five_hour_window_key) DO UPDATE SET last_observed_at_utc = excluded.last_observed_at_utc, final_five_hour_percent = excluded.final_five_hour_percent, seven_day_pct_at_block_end = excluded.seven_day_pct_at_block_end, total_input_tokens = excluded.total_input_tokens, total_output_tokens = excluded.total_output_tokens, total_cache_create_tokens = excluded.total_cache_create_tokens, total_cache_read_tokens = excluded.total_cache_read_tokens, total_cost_usd = excluded.total_cost_usd, pricing_provenance_json = excluded.pricing_provenance_json, last_updated_at_utc = excluded.last_updated_at_utc WHERE five_hour_blocks.is_closed = 0 OR five_hour_blocks.journal_id IS NULL',
|
|
3419
|
+
table='five_hour_blocks',
|
|
3420
|
+
keys=(),
|
|
3421
|
+
predicate='five_hour_blocks.is_closed = 0 OR five_hour_blocks.journal_id IS NULL',
|
|
3422
|
+
ordering='',
|
|
3423
|
+
selected=(),
|
|
3424
|
+
effects='upsert',
|
|
3425
|
+
classes=('singleton',),
|
|
3426
|
+
inert_rule=BLOCKS,
|
|
3427
|
+
),
|
|
3428
|
+
AccessContract(
|
|
3429
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3430
|
+
sql_fingerprint='INSERT OR IGNORE INTO five_hour_milestones ( block_id, five_hour_window_key, percent_threshold, captured_at_utc, usage_snapshot_id, block_input_tokens, block_output_tokens, block_cache_create_tokens, block_cache_read_tokens, block_cost_usd, marginal_cost_usd, seven_day_pct_at_crossing, reset_event_id, account_key ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
3431
|
+
table='five_hour_milestones',
|
|
3432
|
+
keys=(),
|
|
3433
|
+
predicate='',
|
|
3434
|
+
ordering='',
|
|
3435
|
+
selected=(),
|
|
3436
|
+
effects='write',
|
|
3437
|
+
classes=('singleton',),
|
|
3438
|
+
inert_rule=BLOCKS,
|
|
3439
|
+
),
|
|
3440
|
+
AccessContract(
|
|
3441
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3442
|
+
sql_fingerprint='SELECT COUNT(*) FROM five_hour_blocks WHERE account_key = ?',
|
|
3443
|
+
table='five_hour_blocks',
|
|
3444
|
+
keys=('account_key',),
|
|
3445
|
+
predicate='account_key = ?',
|
|
3446
|
+
ordering='',
|
|
3447
|
+
selected=('COUNT(*)',),
|
|
3448
|
+
effects='read',
|
|
3449
|
+
classes=('cross-period',),
|
|
3450
|
+
inert_rule=BLOCKS,
|
|
3451
|
+
),
|
|
3452
|
+
AccessContract(
|
|
3453
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3454
|
+
sql_fingerprint='SELECT MAX(percent_threshold) AS m FROM five_hour_milestones WHERE five_hour_window_key = ? AND reset_event_id = ? AND account_key = ?',
|
|
3455
|
+
table='five_hour_milestones',
|
|
3456
|
+
keys=('five_hour_window_key', 'reset_event_id', 'account_key'),
|
|
3457
|
+
predicate='five_hour_window_key = ? AND reset_event_id = ? AND account_key = ?',
|
|
3458
|
+
ordering='',
|
|
3459
|
+
selected=('MAX(percent_threshold) AS m',),
|
|
3460
|
+
effects='read',
|
|
3461
|
+
classes=('period-keyed',),
|
|
3462
|
+
inert_rule=BLOCKS,
|
|
3463
|
+
),
|
|
3464
|
+
AccessContract(
|
|
3465
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3466
|
+
sql_fingerprint='SELECT block_cost_usd FROM five_hour_milestones WHERE five_hour_window_key = ? AND percent_threshold = ? AND reset_event_id = ? AND account_key = ?',
|
|
3467
|
+
table='five_hour_milestones',
|
|
3468
|
+
keys=('five_hour_window_key', 'percent_threshold', 'reset_event_id', 'account_key'),
|
|
3469
|
+
predicate='five_hour_window_key = ? AND percent_threshold = ? AND reset_event_id = ? AND account_key = ?',
|
|
3470
|
+
ordering='',
|
|
3471
|
+
selected=('block_cost_usd',),
|
|
3472
|
+
effects='read',
|
|
3473
|
+
classes=('period-keyed',),
|
|
3474
|
+
inert_rule=BLOCKS,
|
|
3475
|
+
),
|
|
3476
|
+
AccessContract(
|
|
3477
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3478
|
+
sql_fingerprint='SELECT block_start_at FROM five_hour_blocks WHERE five_hour_window_key = ? AND account_key = ?',
|
|
3479
|
+
table='five_hour_blocks',
|
|
3480
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
3481
|
+
predicate='five_hour_window_key = ? AND account_key = ?',
|
|
3482
|
+
ordering='',
|
|
3483
|
+
selected=('block_start_at',),
|
|
3484
|
+
effects='read',
|
|
3485
|
+
classes=('period-keyed',),
|
|
3486
|
+
inert_rule=BLOCKS,
|
|
3487
|
+
),
|
|
3488
|
+
AccessContract(
|
|
3489
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3490
|
+
sql_fingerprint='SELECT id AS prior_block_id, block_start_at AS block_start_at, five_hour_resets_at AS prior_resets_at, is_closed AS is_closed, journal_id AS journal_id, last_updated_at_utc AS last_updated_at_utc FROM five_hour_blocks WHERE five_hour_window_key = ? AND account_key = ?',
|
|
3491
|
+
table='five_hour_blocks',
|
|
3492
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
3493
|
+
predicate='five_hour_window_key = ? AND account_key = ?',
|
|
3494
|
+
ordering='',
|
|
3495
|
+
selected=('id AS prior_block_id', 'block_start_at AS block_start_at', 'five_hour_resets_at AS prior_resets_at', 'is_closed AS is_closed', 'journal_id AS journal_id', 'last_updated_at_utc AS last_updated_at_utc'),
|
|
3496
|
+
effects='read',
|
|
3497
|
+
classes=('period-keyed',),
|
|
3498
|
+
inert_rule=BLOCKS,
|
|
3499
|
+
),
|
|
3500
|
+
AccessContract(
|
|
3501
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3502
|
+
sql_fingerprint='SELECT id FROM five_hour_blocks WHERE five_hour_window_key = ? AND account_key = ?',
|
|
3503
|
+
table='five_hour_blocks',
|
|
3504
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
3505
|
+
predicate='five_hour_window_key = ? AND account_key = ?',
|
|
3506
|
+
ordering='',
|
|
3507
|
+
selected=('id',),
|
|
3508
|
+
effects='read',
|
|
3509
|
+
classes=('period-keyed',),
|
|
3510
|
+
inert_rule=BLOCKS,
|
|
3511
|
+
),
|
|
3512
|
+
AccessContract(
|
|
3513
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3514
|
+
sql_fingerprint='SELECT id FROM five_hour_blocks WHERE id = ? AND is_closed = 1 AND journal_id IS NULL',
|
|
3515
|
+
table='five_hour_blocks',
|
|
3516
|
+
keys=('id',),
|
|
3517
|
+
predicate='id = ? AND is_closed = 1 AND journal_id IS NULL',
|
|
3518
|
+
ordering='',
|
|
3519
|
+
selected=('id',),
|
|
3520
|
+
effects='read',
|
|
3521
|
+
classes=('period-keyed',),
|
|
3522
|
+
inert_rule=BLOCKS,
|
|
3523
|
+
),
|
|
3524
|
+
AccessContract(
|
|
3525
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3526
|
+
sql_fingerprint='SELECT id FROM five_hour_blocks WHERE is_closed = 0 AND account_key = ? AND (five_hour_window_key < ? OR unixepoch(five_hour_resets_at) < unixepoch(?))',
|
|
3527
|
+
table='five_hour_blocks',
|
|
3528
|
+
keys=('account_key',),
|
|
3529
|
+
predicate='is_closed = 0 AND account_key = ? AND (five_hour_window_key < ? OR unixepoch(five_hour_resets_at) < unixepoch(?))',
|
|
3530
|
+
ordering='',
|
|
3531
|
+
selected=('id',),
|
|
3532
|
+
effects='read',
|
|
3533
|
+
classes=('range-keyed', 'cross-period'),
|
|
3534
|
+
inert_rule=BLOCKS,
|
|
3535
|
+
),
|
|
3536
|
+
AccessContract(
|
|
3537
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3538
|
+
sql_fingerprint='SELECT id FROM five_hour_blocks WHERE is_closed = 1 AND journal_id IS NOT NULL AND account_key = ? AND last_updated_at_utc = ? AND (five_hour_window_key < ? OR unixepoch(five_hour_resets_at) < unixepoch(?))',
|
|
3539
|
+
table='five_hour_blocks',
|
|
3540
|
+
keys=('account_key', 'last_updated_at_utc'),
|
|
3541
|
+
predicate='is_closed = 1 AND journal_id IS NOT NULL AND account_key = ? AND last_updated_at_utc = ? AND (five_hour_window_key < ? OR unixepoch(five_hour_resets_at) < unixepoch(?))',
|
|
3542
|
+
ordering='',
|
|
3543
|
+
selected=('id',),
|
|
3544
|
+
effects='read',
|
|
3545
|
+
classes=('range-keyed', 'cross-period'),
|
|
3546
|
+
inert_rule=BLOCKS,
|
|
3547
|
+
),
|
|
3548
|
+
AccessContract(
|
|
3549
|
+
function='_cctally_record:_flag_blocks_spanning_week_resets',
|
|
3550
|
+
sql_fingerprint='UPDATE five_hour_blocks SET crossed_seven_day_reset = 1 WHERE crossed_seven_day_reset = 0 AND account_key = ? AND (is_closed = 0 OR journal_id IS NULL) AND ( EXISTS ( SELECT 1 FROM week_reset_events e WHERE e.account_key = five_hour_blocks.account_key AND unixepoch(e.effective_reset_at_utc) BETWEEN unixepoch(five_hour_blocks.block_start_at) AND unixepoch(five_hour_blocks.last_observed_at_utc) ) OR EXISTS ( SELECT 1 FROM weekly_usage_snapshots ws WHERE ws.week_start_at IS NOT NULL AND ws.account_key = five_hour_blocks.account_key AND unixepoch(ws.week_start_at) > unixepoch(five_hour_blocks.block_start_at) AND unixepoch(ws.week_start_at) <= unixepoch(five_hour_blocks.last_observed_at_utc) ) )',
|
|
3551
|
+
table='five_hour_blocks',
|
|
3552
|
+
keys=('account_key',),
|
|
3553
|
+
predicate='crossed_seven_day_reset = 0 AND account_key = ? AND (is_closed = 0 OR journal_id IS NULL) AND ( EXISTS ( SELECT 1 FROM week_reset_events e WHERE e.account_key = five_hour_blocks.account_key AND unixepoch(e.effective_reset_at_utc) BETWEEN unixepoch(five_hour_blocks.block_start_at) AND unixepoch(five_hour_blocks.last_observed_at_utc) ) OR EXISTS ( SELECT 1 FROM weekly_usage_snapshots ws WHERE ws.week_start_at IS NOT NULL AND ws.account_key = five_hour_blocks.account_key AND unixepoch(ws.week_start_at) > unixepoch(five_hour_blocks.block_start_at) AND unixepoch(ws.week_start_at) <= unixepoch(five_hour_blocks.last_observed_at_utc) ) )',
|
|
3554
|
+
ordering='',
|
|
3555
|
+
selected=(),
|
|
3556
|
+
effects='write',
|
|
3557
|
+
classes=('singleton', 'range-keyed'),
|
|
3558
|
+
inert_rule=BLOCKS,
|
|
3559
|
+
),
|
|
3560
|
+
AccessContract(
|
|
3561
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3562
|
+
sql_fingerprint='UPDATE five_hour_blocks SET is_closed = 1, last_updated_at_utc = ? WHERE five_hour_window_key = ? AND account_key = ? AND is_closed = 0 AND unixepoch(five_hour_resets_at) < unixepoch(?)',
|
|
3563
|
+
table='five_hour_blocks',
|
|
3564
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
3565
|
+
predicate='five_hour_window_key = ? AND account_key = ? AND is_closed = 0 AND unixepoch(five_hour_resets_at) < unixepoch(?)',
|
|
3566
|
+
ordering='',
|
|
3567
|
+
selected=(),
|
|
3568
|
+
effects='write',
|
|
3569
|
+
classes=('period-keyed', 'range-keyed'),
|
|
3570
|
+
inert_rule=BLOCKS,
|
|
3571
|
+
),
|
|
3572
|
+
AccessContract(
|
|
3573
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3574
|
+
sql_fingerprint='UPDATE five_hour_blocks SET is_closed = 1, last_updated_at_utc = ? WHERE is_closed = 0 AND account_key = ? AND five_hour_window_key < ?',
|
|
3575
|
+
table='five_hour_blocks',
|
|
3576
|
+
keys=('account_key',),
|
|
3577
|
+
predicate='is_closed = 0 AND account_key = ? AND five_hour_window_key < ?',
|
|
3578
|
+
ordering='',
|
|
3579
|
+
selected=(),
|
|
3580
|
+
effects='write',
|
|
3581
|
+
classes=('singleton', 'range-keyed'),
|
|
3582
|
+
inert_rule=BLOCKS,
|
|
3583
|
+
),
|
|
3584
|
+
AccessContract(
|
|
3585
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3586
|
+
sql_fingerprint='UPDATE five_hour_blocks SET is_closed = 1, last_updated_at_utc = ? WHERE is_closed = 0 AND account_key = ? AND unixepoch(five_hour_resets_at) < unixepoch(?)',
|
|
3587
|
+
table='five_hour_blocks',
|
|
3588
|
+
keys=('account_key',),
|
|
3589
|
+
predicate='is_closed = 0 AND account_key = ? AND unixepoch(five_hour_resets_at) < unixepoch(?)',
|
|
3590
|
+
ordering='',
|
|
3591
|
+
selected=(),
|
|
3592
|
+
effects='write',
|
|
3593
|
+
classes=('singleton', 'range-keyed'),
|
|
3594
|
+
inert_rule=BLOCKS,
|
|
3595
|
+
),
|
|
3596
|
+
AccessContract(
|
|
3597
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
3598
|
+
sql_fingerprint='UPDATE five_hour_milestones SET alerted_at = ? WHERE five_hour_window_key = ? AND percent_threshold = ? AND reset_event_id = ? AND account_key = ? AND alerted_at IS NULL',
|
|
3599
|
+
table='five_hour_milestones',
|
|
3600
|
+
keys=('five_hour_window_key', 'percent_threshold', 'reset_event_id', 'account_key'),
|
|
3601
|
+
predicate='five_hour_window_key = ? AND percent_threshold = ? AND reset_event_id = ? AND account_key = ? AND alerted_at IS NULL',
|
|
3602
|
+
ordering='',
|
|
3603
|
+
selected=(),
|
|
3604
|
+
effects='write',
|
|
3605
|
+
classes=('period-keyed',),
|
|
3606
|
+
inert_rule=BLOCKS,
|
|
3607
|
+
),
|
|
3608
|
+
AccessContract(
|
|
3609
|
+
function='_cctally_record:resolve_five_hour_reset_event',
|
|
3610
|
+
sql_fingerprint='SELECT detected_at_utc, effective_reset_at_utc, id FROM five_hour_reset_events WHERE five_hour_window_key = ? AND account_key = ?',
|
|
3611
|
+
table='five_hour_reset_events',
|
|
3612
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
3613
|
+
predicate='five_hour_window_key = ? AND account_key = ?',
|
|
3614
|
+
ordering='',
|
|
3615
|
+
selected=('detected_at_utc', 'effective_reset_at_utc', 'id'),
|
|
3616
|
+
effects='read',
|
|
3617
|
+
classes=('period-keyed',),
|
|
3618
|
+
inert_rule=None,
|
|
3619
|
+
),
|
|
3620
|
+
AccessContract(
|
|
3621
|
+
function='_cctally_statusline:_tokens_from',
|
|
3622
|
+
sql_fingerprint='SELECT record_path, started_at_utc, stamped_at_utc FROM stats_publication_stamp ORDER BY rowid',
|
|
3623
|
+
table='stats_publication_stamp',
|
|
3624
|
+
keys=(),
|
|
3625
|
+
predicate='',
|
|
3626
|
+
ordering='rowid',
|
|
3627
|
+
selected=('record_path', 'started_at_utc', 'stamped_at_utc'),
|
|
3628
|
+
effects='read',
|
|
3629
|
+
classes=('cross-period',),
|
|
3630
|
+
inert_rule=WAIT,
|
|
3631
|
+
),
|
|
3632
|
+
AccessContract(
|
|
3633
|
+
function='_cctally_statusline:_tokens_from',
|
|
3634
|
+
sql_fingerprint='SELECT segment, offset, applied_segment, applied_offset FROM journal_cursor WHERE id = 1',
|
|
3635
|
+
table='journal_cursor',
|
|
3636
|
+
keys=(),
|
|
3637
|
+
predicate='id = 1',
|
|
3638
|
+
ordering='',
|
|
3639
|
+
selected=('segment', 'offset', 'applied_segment', 'applied_offset'),
|
|
3640
|
+
effects='read',
|
|
3641
|
+
classes=('cross-period',),
|
|
3642
|
+
inert_rule=WAIT,
|
|
3643
|
+
),
|
|
3644
|
+
AccessContract(
|
|
3645
|
+
function='_cctally_statusline:_tokens_from',
|
|
3646
|
+
sql_fingerprint='dynamic:_cctally_statusline:_tokens_from#1',
|
|
3647
|
+
sql_shape='sha256:ba847e069d2ffffc',
|
|
3648
|
+
table='dynamic',
|
|
3649
|
+
keys=(),
|
|
3650
|
+
predicate='dynamic SQL',
|
|
3651
|
+
ordering='',
|
|
3652
|
+
selected=(),
|
|
3653
|
+
effects='read',
|
|
3654
|
+
classes=('cross-period',),
|
|
3655
|
+
inert_rule=WAIT,
|
|
3656
|
+
),
|
|
3657
|
+
AccessContract(
|
|
3658
|
+
function='_cctally_store:apply_connection_policy',
|
|
3659
|
+
sql_fingerprint='dynamic:_cctally_store:apply_connection_policy#1',
|
|
3660
|
+
sql_shape='sha256:1c25e1344c04db44',
|
|
3661
|
+
table='dynamic',
|
|
3662
|
+
keys=(),
|
|
3663
|
+
predicate='dynamic SQL',
|
|
3664
|
+
ordering='',
|
|
3665
|
+
selected=(),
|
|
3666
|
+
effects='read',
|
|
3667
|
+
classes=('cross-period',),
|
|
3668
|
+
inert_rule=MAINT,
|
|
3669
|
+
),
|
|
3670
|
+
AccessContract(
|
|
3671
|
+
function='_cctally_store:apply_connection_policy',
|
|
3672
|
+
sql_fingerprint='dynamic:_cctally_store:apply_connection_policy#2',
|
|
3673
|
+
sql_shape='sha256:32c028acaaf363ab',
|
|
3674
|
+
table='dynamic',
|
|
3675
|
+
keys=(),
|
|
3676
|
+
predicate='dynamic SQL',
|
|
3677
|
+
ordering='',
|
|
3678
|
+
selected=(),
|
|
3679
|
+
effects='read',
|
|
3680
|
+
classes=('cross-period',),
|
|
3681
|
+
inert_rule=MAINT,
|
|
3682
|
+
),
|
|
3683
|
+
AccessContract(
|
|
3684
|
+
function='_cctally_store:apply_connection_policy',
|
|
3685
|
+
sql_fingerprint='dynamic:_cctally_store:apply_connection_policy#3',
|
|
3686
|
+
sql_shape='sha256:2f23eec2c9c63bb2',
|
|
3687
|
+
table='dynamic',
|
|
3688
|
+
keys=(),
|
|
3689
|
+
predicate='dynamic SQL',
|
|
3690
|
+
ordering='',
|
|
3691
|
+
selected=(),
|
|
3692
|
+
effects='read',
|
|
3693
|
+
classes=('cross-period',),
|
|
3694
|
+
inert_rule=MAINT,
|
|
3695
|
+
),
|
|
3696
|
+
AccessContract(
|
|
3697
|
+
function='_cctally_store:apply_policy',
|
|
3698
|
+
sql_fingerprint='dynamic:_cctally_store:apply_policy#1',
|
|
3699
|
+
sql_shape='sha256:f14edcbecbaa2e1d',
|
|
3700
|
+
table='dynamic',
|
|
3701
|
+
keys=(),
|
|
3702
|
+
predicate='dynamic SQL',
|
|
3703
|
+
ordering='',
|
|
3704
|
+
selected=(),
|
|
3705
|
+
effects='read',
|
|
3706
|
+
classes=('cross-period',),
|
|
3707
|
+
inert_rule=MAINT,
|
|
3708
|
+
),
|
|
3709
|
+
AccessContract(
|
|
3710
|
+
function='_cctally_store:apply_policy',
|
|
3711
|
+
sql_fingerprint='dynamic:_cctally_store:apply_policy#2',
|
|
3712
|
+
sql_shape='sha256:492dde2a4628ee0f',
|
|
3713
|
+
table='dynamic',
|
|
3714
|
+
keys=(),
|
|
3715
|
+
predicate='dynamic SQL',
|
|
3716
|
+
ordering='',
|
|
3717
|
+
selected=(),
|
|
3718
|
+
effects='read',
|
|
3719
|
+
classes=('cross-period',),
|
|
3720
|
+
inert_rule=MAINT,
|
|
3721
|
+
),
|
|
3722
|
+
AccessContract(
|
|
3723
|
+
function='_cctally_store:apply_writer_temp_store',
|
|
3724
|
+
sql_fingerprint='dynamic:_cctally_store:apply_writer_temp_store#1',
|
|
3725
|
+
sql_shape='sha256:37cd251c8e8e9040',
|
|
3726
|
+
table='dynamic',
|
|
3727
|
+
keys=(),
|
|
3728
|
+
predicate='dynamic SQL',
|
|
3729
|
+
ordering='',
|
|
3730
|
+
selected=(),
|
|
3731
|
+
effects='read',
|
|
3732
|
+
classes=('cross-period',),
|
|
3733
|
+
inert_rule=MAINT,
|
|
3734
|
+
),
|
|
3735
|
+
AccessContract(
|
|
3736
|
+
function='_cctally_sync_week:_cmd_sync_week_via_ingest',
|
|
3737
|
+
sql_fingerprint='SELECT id, week_start_date, week_end_date, week_start_at, week_end_at, range_start_iso, range_end_iso, cost_usd, mode FROM weekly_cost_snapshots WHERE journal_id LIKE ? ORDER BY id DESC LIMIT 1',
|
|
3738
|
+
table='weekly_cost_snapshots',
|
|
3739
|
+
keys=(),
|
|
3740
|
+
predicate='journal_id LIKE ?',
|
|
3741
|
+
ordering='id DESC',
|
|
3742
|
+
selected=('id', 'week_start_date', 'week_end_date', 'week_start_at', 'week_end_at', 'range_start_iso', 'range_end_iso', 'cost_usd', 'mode'),
|
|
3743
|
+
effects='read',
|
|
3744
|
+
classes=('cross-period',),
|
|
3745
|
+
inert_rule=Q7,
|
|
3746
|
+
),
|
|
3747
|
+
AccessContract(
|
|
3748
|
+
function='_cctally_weekrefs:_apply_reset_events_to_weekrefs',
|
|
3749
|
+
sql_fingerprint='dynamic:_cctally_weekrefs:_apply_reset_events_to_weekrefs#1',
|
|
3750
|
+
sql_shape='sha256:ef62f4486cc766b0',
|
|
3751
|
+
table='dynamic',
|
|
3752
|
+
keys=(),
|
|
3753
|
+
predicate='dynamic SQL',
|
|
3754
|
+
ordering='',
|
|
3755
|
+
selected=(),
|
|
3756
|
+
effects='read',
|
|
3757
|
+
classes=('cross-period',),
|
|
3758
|
+
inert_rule=Q7,
|
|
3759
|
+
),
|
|
3760
|
+
AccessContract(
|
|
3761
|
+
# #825/#832 fix round C (CD2-003): the canonical weekly boundary is
|
|
3762
|
+
# NOT a cost-only read: `_usage_snapshot_columns` stamps the returned
|
|
3763
|
+
# `week_start_at`/`week_end_at` into the accepted usage snapshot a
|
|
3764
|
+
# strict decision reads. The account predicate is spliced in (an
|
|
3765
|
+
# `account_key` is always supplied on this path), so the site is
|
|
3766
|
+
# dynamic; its contract is the real one, held by `sql_shape`.
|
|
3767
|
+
function='_cctally_weekrefs:_get_canonical_boundary_for_date',
|
|
3768
|
+
sql_fingerprint='dynamic:_cctally_weekrefs:_get_canonical_boundary_for_date#1',
|
|
3769
|
+
sql_shape='sha256:8e47b9024179d8d0',
|
|
3770
|
+
table='weekly_usage_snapshots',
|
|
3771
|
+
keys=('week_start_date', 'account_key'),
|
|
3772
|
+
predicate="week_start_date = ? AND week_start_at IS NOT NULL AND week_start_at != '' AND week_end_at IS NOT NULL AND week_end_at != '' AND account_key = ?",
|
|
3773
|
+
ordering='captured_at_utc ASC, id ASC',
|
|
3774
|
+
selected=('week_start_at', 'week_end_at'),
|
|
3775
|
+
effects='read',
|
|
3776
|
+
classes=('period-keyed',),
|
|
3777
|
+
inert_rule=None,
|
|
3778
|
+
),
|
|
3779
|
+
AccessContract(
|
|
3780
|
+
function='_cctally_weekrefs:_week_ref_has_reset_event',
|
|
3781
|
+
sql_fingerprint='dynamic:_cctally_weekrefs:_week_ref_has_reset_event#1',
|
|
3782
|
+
sql_shape='sha256:5087166fa6bd0e2e',
|
|
3783
|
+
table='dynamic',
|
|
3784
|
+
keys=(),
|
|
3785
|
+
predicate='dynamic SQL',
|
|
3786
|
+
ordering='',
|
|
3787
|
+
selected=(),
|
|
3788
|
+
effects='read',
|
|
3789
|
+
classes=('cross-period',),
|
|
3790
|
+
inert_rule=Q7,
|
|
3791
|
+
),
|
|
3792
|
+
AccessContract(
|
|
3793
|
+
function='_lib_five_hour:latest_five_hour_reading',
|
|
3794
|
+
sql_fingerprint='dynamic:_lib_five_hour:latest_five_hour_reading#1',
|
|
3795
|
+
sql_shape='sha256:c61db33f7457ea09',
|
|
3796
|
+
table='weekly_usage_snapshots',
|
|
3797
|
+
keys=('week_start_date', 'account_key'),
|
|
3798
|
+
predicate=('latest five-hour reading of ONE week date key and account '
|
|
3799
|
+
'(the no-change ingest derivation, #825/#832 spec 4.7 '
|
|
3800
|
+
'revision 7)'),
|
|
3801
|
+
ordering='captured_at_utc DESC, id DESC',
|
|
3802
|
+
selected=('id', 'account_key', 'captured_at_utc', 'five_hour_percent',
|
|
3803
|
+
'five_hour_resets_at', 'five_hour_window_key',
|
|
3804
|
+
'weekly_observation_held'),
|
|
3805
|
+
effects='read',
|
|
3806
|
+
classes=('period-keyed',),
|
|
3807
|
+
inert_rule=None,
|
|
3808
|
+
),
|
|
3809
|
+
)
|
|
3810
|
+
|
|
3811
|
+
|
|
3812
|
+
def non_inert_cross_period(registry=None) -> "tuple[AccessContract, ...]":
|
|
3813
|
+
"""Every registered cross-period READ without an inert rule."""
|
|
3814
|
+
entries = REGISTRY if registry is None else registry
|
|
3815
|
+
return tuple(c for c in entries
|
|
3816
|
+
if "cross-period" in c.classes and c.effects == "read"
|
|
3817
|
+
and c.inert_rule is None)
|