cctally 1.116.1 → 1.117.2
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 +47 -0
- package/README.md +4 -6
- package/bin/_cctally_account.py +57 -3
- package/bin/_cctally_cache.py +5720 -885
- package/bin/_cctally_claude_attribution.py +997 -0
- package/bin/_cctally_completion.py +101 -28
- package/bin/_cctally_core.py +235 -12
- package/bin/_cctally_dashboard.py +263 -17
- package/bin/_cctally_dashboard_conversation.py +107 -21
- package/bin/_cctally_dashboard_envelope.py +44 -0
- package/bin/_cctally_db.py +928 -80
- package/bin/_cctally_diagnosis_sources.py +78 -13
- package/bin/_cctally_doctor.py +211 -86
- package/bin/_cctally_five_hour.py +446 -22
- package/bin/_cctally_forecast.py +302 -6
- package/bin/_cctally_journal.py +2418 -158
- package/bin/_cctally_milestone_history.py +379 -91
- package/bin/_cctally_oauth_samples.py +185 -7
- package/bin/_cctally_parser.py +38 -0
- package/bin/_cctally_project.py +34 -8
- package/bin/_cctally_quarantine.py +821 -343
- package/bin/_cctally_quota.py +69 -4
- package/bin/_cctally_quota_calibration.py +677 -3
- package/bin/_cctally_quota_model.py +927 -127
- package/bin/_cctally_record.py +922 -445
- package/bin/_cctally_rederive.py +119 -15
- package/bin/_cctally_statusline.py +1048 -176
- package/bin/_cctally_store.py +544 -110
- package/bin/_cctally_tui.py +455 -42
- package/bin/_cctally_update.py +77 -14
- package/bin/_lib_account_protocol.py +227 -19
- package/bin/_lib_claude_attribution.py +421 -0
- package/bin/_lib_clone_copy.py +30 -0
- package/bin/_lib_codex_conversation_query.py +45 -9
- package/bin/_lib_codex_conversation_watch.py +72 -13
- package/bin/_lib_codex_rollout_container.py +234 -19
- package/bin/_lib_codex_worker_lifecycle.py +374 -0
- package/bin/_lib_credit.py +22 -13
- package/bin/_lib_dashboard_sources.py +257 -18
- package/bin/_lib_detector_access_registry.py +1335 -166
- package/bin/_lib_doctor.py +276 -92
- package/bin/_lib_ingest_frontier.py +269 -36
- package/bin/_lib_journal.py +273 -22
- package/bin/_lib_jsonl.py +12 -0
- package/bin/_lib_meter_rate_change.py +72 -0
- package/bin/_lib_outcome_quarantine.py +917 -554
- package/bin/_lib_provider_activity.py +24 -6
- package/bin/_lib_quota_calibration.py +57 -3
- package/bin/_lib_quota_copy.py +7 -2
- package/bin/_lib_quota_lineage.py +613 -0
- package/bin/_lib_quota_model.py +464 -33
- package/bin/_lib_rate_change_delivery.py +16 -0
- package/bin/_lib_reclaim_planner.py +6 -4
- package/bin/_lib_rederive.py +2046 -21
- package/bin/_lib_selector_state.py +131 -3
- package/bin/_lib_snapshot_cache.py +8 -0
- package/bin/_lib_stale_proof.py +113 -4
- package/bin/_lib_statusline.py +72 -3
- package/bin/_lib_statusline_candidates.py +246 -42
- package/bin/_lib_tick_stats.py +10 -5
- package/bin/_lib_write_io.py +419 -6
- package/bin/cctally +28 -11
- package/dashboard/static/assets/{ConversationsView-Dflb_myA.js → ConversationsView-oqNsWzWV.js} +1 -1
- package/dashboard/static/assets/{DoctorModal-DFX5CfIs.js → DoctorModal-B0DnU9d9.js} +1 -1
- package/dashboard/static/assets/ModalRoot-CYua2wP_.js +1 -0
- package/dashboard/static/assets/{ProjectsDrillPanel-C3PJy1xx.js → ProjectsDrillPanel-DSxXQSa-.js} +1 -1
- package/dashboard/static/assets/{SourceDetailModal-BczsWKhD.js → SourceDetailModal-BleDpQqG.js} +1 -1
- package/dashboard/static/assets/{UpdateModal-Os-Lo5cs.js → UpdateModal-CMqaAkSK.js} +1 -1
- package/dashboard/static/assets/{index-CYZ3NLqF.js → index-BjQV-0-D.js} +3 -3
- package/dashboard/static/assets/index-D34eYhAc.css +1 -0
- package/dashboard/static/assets/{outlineNavigation-k-zIif6W.js → outlineNavigation-CO-VWBm7.js} +1 -1
- package/dashboard/static/assets/{useKeymap-CW7Up0Ay.js → useKeymap-CUgEnnua.js} +1 -1
- package/dashboard/static/dashboard.html +3 -3
- package/package.json +5 -1
- package/dashboard/static/assets/ModalRoot-HlxoagIa.js +0 -1
- package/dashboard/static/assets/index-BKITk1CT.css +0 -1
|
@@ -195,6 +195,12 @@ WAIT = (
|
|
|
195
195
|
'reclassifies everything it publishes; never a detector input.'
|
|
196
196
|
)
|
|
197
197
|
|
|
198
|
+
LINEAGE = (
|
|
199
|
+
'Correction-to-fit lineage projection (#1015): written for the '
|
|
200
|
+
'calibration lineage readers (forecast, project, doctor, status line); '
|
|
201
|
+
'no automatic credit, moved-end or drop-consensus decision reads it.'
|
|
202
|
+
)
|
|
203
|
+
|
|
198
204
|
REGISTRY: "tuple[AccessContract, ...]" = (
|
|
199
205
|
AccessContract(
|
|
200
206
|
function='_cctally_account:account_label',
|
|
@@ -257,9 +263,18 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
257
263
|
classes=('cross-period',),
|
|
258
264
|
inert_rule=READ_IDX,
|
|
259
265
|
),
|
|
266
|
+
# Reviewed re-fingerprint (#1015 T3, epoch 1022, spec 5.7). This one
|
|
267
|
+
# executescript creates every quota projection table, and its literal
|
|
268
|
+
# text changed in exactly two places: `meter_rate_change_events` gains the
|
|
269
|
+
# NULLABLE `fit_lineage` column (the canonical JSON lineage of the fits a
|
|
270
|
+
# transition compared, NULL on a row detected before #1015), and the
|
|
271
|
+
# script now also creates `meter_rate_change_supersessions` (the terminal
|
|
272
|
+
# supersession projection) with its explanatory comments outside the
|
|
273
|
+
# statement. The statement stays a schema-only MAINT write run at open;
|
|
274
|
+
# no detector decision reads either addition, so the contract stands.
|
|
260
275
|
AccessContract(
|
|
261
276
|
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) );',
|
|
277
|
+
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, fit_lineage TEXT, 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); -- #1015 epoch 1022 (spec 5.7). `fit_lineage` above is the canonical -- JSON lineage of the fits a transition compared, NULL on a row -- detected before #1015. `meter_rate_change_supersessions` is the -- terminal, idempotent projection of the journalled -- `meter_rate_change_supersession` event: one row per superseded -- transition identity, `corrections` the canonical JSON op ids. CREATE TABLE IF NOT EXISTS meter_rate_change_supersessions ( provider TEXT NOT NULL, account_key TEXT NOT NULL, effective_from TEXT NOT NULL, reason TEXT NOT NULL, corrections TEXT NOT NULL, superseded_at_utc TEXT NOT NULL, created_at_utc TEXT NOT NULL, PRIMARY KEY (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
278
|
table='quota_window_blocks',
|
|
264
279
|
keys=(),
|
|
265
280
|
predicate='',
|
|
@@ -634,6 +649,84 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
634
649
|
classes=('singleton',),
|
|
635
650
|
inert_rule=MAINT,
|
|
636
651
|
),
|
|
652
|
+
# #1015 epoch 1022 (spec 5.1): the correction-to-fit lineage
|
|
653
|
+
# projections, created by open_db's schema block beside
|
|
654
|
+
# `claude_weekly_observation_decisions`: the observation index and its
|
|
655
|
+
# (account_key, captured_at_utc) index, the reviewed decision history,
|
|
656
|
+
# the decision op coordinates, and the completed batch lineage with its
|
|
657
|
+
# footprint. Schema-only statements run at open, so MAINT.
|
|
658
|
+
AccessContract(
|
|
659
|
+
function='_cctally_core:open_db',
|
|
660
|
+
sql_fingerprint='CREATE INDEX IF NOT EXISTS idx_claude_weekly_observation_index_window ON claude_weekly_observation_index (account_key, captured_at_utc)',
|
|
661
|
+
table='claude_weekly_observation_index',
|
|
662
|
+
keys=(),
|
|
663
|
+
predicate='',
|
|
664
|
+
ordering='',
|
|
665
|
+
selected=(),
|
|
666
|
+
effects='write',
|
|
667
|
+
classes=('singleton',),
|
|
668
|
+
inert_rule=MAINT,
|
|
669
|
+
),
|
|
670
|
+
AccessContract(
|
|
671
|
+
function='_cctally_core:open_db',
|
|
672
|
+
sql_fingerprint="CREATE TABLE IF NOT EXISTS claude_weekly_correction_history ( decision_op_id TEXT NOT NULL, observation_id TEXT NOT NULL, disposition TEXT NOT NULL CHECK(disposition IN ('hold','retract','accept')), PRIMARY KEY (decision_op_id, observation_id) )",
|
|
673
|
+
table='claude_weekly_correction_history',
|
|
674
|
+
keys=(),
|
|
675
|
+
predicate='',
|
|
676
|
+
ordering='',
|
|
677
|
+
selected=(),
|
|
678
|
+
effects='write',
|
|
679
|
+
classes=('singleton',),
|
|
680
|
+
inert_rule=MAINT,
|
|
681
|
+
),
|
|
682
|
+
AccessContract(
|
|
683
|
+
function='_cctally_core:open_db',
|
|
684
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS claude_weekly_correction_ops ( decision_op_id TEXT PRIMARY KEY, op_segment TEXT NOT NULL, op_offset INTEGER NOT NULL )',
|
|
685
|
+
table='claude_weekly_correction_ops',
|
|
686
|
+
keys=(),
|
|
687
|
+
predicate='',
|
|
688
|
+
ordering='',
|
|
689
|
+
selected=(),
|
|
690
|
+
effects='write',
|
|
691
|
+
classes=('singleton',),
|
|
692
|
+
inert_rule=MAINT,
|
|
693
|
+
),
|
|
694
|
+
AccessContract(
|
|
695
|
+
function='_cctally_core:open_db',
|
|
696
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS claude_weekly_observation_index ( observation_id TEXT PRIMARY KEY, account_key TEXT NOT NULL, captured_at_utc TEXT NOT NULL )',
|
|
697
|
+
table='claude_weekly_observation_index',
|
|
698
|
+
keys=(),
|
|
699
|
+
predicate='',
|
|
700
|
+
ordering='',
|
|
701
|
+
selected=(),
|
|
702
|
+
effects='write',
|
|
703
|
+
classes=('singleton',),
|
|
704
|
+
inert_rule=MAINT,
|
|
705
|
+
),
|
|
706
|
+
AccessContract(
|
|
707
|
+
function='_cctally_core:open_db',
|
|
708
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS correction_batch_footprint ( batch_id TEXT NOT NULL, provider TEXT NOT NULL, account_key TEXT NOT NULL, PRIMARY KEY (batch_id, provider, account_key) )',
|
|
709
|
+
table='correction_batch_footprint',
|
|
710
|
+
keys=(),
|
|
711
|
+
predicate='',
|
|
712
|
+
ordering='',
|
|
713
|
+
selected=(),
|
|
714
|
+
effects='write',
|
|
715
|
+
classes=('singleton',),
|
|
716
|
+
inert_rule=MAINT,
|
|
717
|
+
),
|
|
718
|
+
AccessContract(
|
|
719
|
+
function='_cctally_core:open_db',
|
|
720
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS correction_batch_lineage ( batch_id TEXT PRIMARY KEY, commit_segment TEXT NOT NULL, commit_offset INTEGER NOT NULL )',
|
|
721
|
+
table='correction_batch_lineage',
|
|
722
|
+
keys=(),
|
|
723
|
+
predicate='',
|
|
724
|
+
ordering='',
|
|
725
|
+
selected=(),
|
|
726
|
+
effects='write',
|
|
727
|
+
classes=('singleton',),
|
|
728
|
+
inert_rule=MAINT,
|
|
729
|
+
),
|
|
637
730
|
AccessContract(
|
|
638
731
|
function='_cctally_core:open_db',
|
|
639
732
|
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) )",
|
|
@@ -672,7 +765,7 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
672
765
|
),
|
|
673
766
|
AccessContract(
|
|
674
767
|
function='_cctally_core:open_db',
|
|
675
|
-
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, baseline_observation_id TEXT, baseline_generation TEXT, pending_generation TEXT, pending_position TEXT, PRIMARY KEY (account_key, five_hour_window_key, source) )',
|
|
768
|
+
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, baseline_observation_id TEXT, baseline_generation TEXT, pending_generation TEXT, pending_position TEXT, pending_captured_at_utc TEXT, PRIMARY KEY (account_key, five_hour_window_key, source) )',
|
|
676
769
|
table='five_hour_credit_confirmation_state',
|
|
677
770
|
keys=(),
|
|
678
771
|
predicate='',
|
|
@@ -682,6 +775,36 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
682
775
|
classes=('singleton',),
|
|
683
776
|
inert_rule=MAINT,
|
|
684
777
|
),
|
|
778
|
+
# #943 T3 (spec 4.7): the exact-boundary companion of a five-hour credit,
|
|
779
|
+
# a harvest family (prefix `fhcb`, order 29) keyed by the credit's
|
|
780
|
+
# natural key. Schema creation only.
|
|
781
|
+
AccessContract(
|
|
782
|
+
function='_cctally_core:open_db',
|
|
783
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS five_hour_credit_boundaries ( id INTEGER PRIMARY KEY, account_key TEXT NOT NULL, five_hour_window_key INTEGER NOT NULL, effective_reset_at_utc TEXT NOT NULL, boundary_at_utc TEXT NOT NULL, arming_observation_id TEXT NOT NULL, credit_revision TEXT NOT NULL, detected_at_utc TEXT NOT NULL, journal_id TEXT, UNIQUE(account_key, five_hour_window_key, effective_reset_at_utc) )',
|
|
784
|
+
table='five_hour_credit_boundaries',
|
|
785
|
+
keys=(),
|
|
786
|
+
predicate='',
|
|
787
|
+
ordering='',
|
|
788
|
+
selected=(),
|
|
789
|
+
effects='write',
|
|
790
|
+
classes=('singleton',),
|
|
791
|
+
inert_rule=MAINT,
|
|
792
|
+
),
|
|
793
|
+
# #956 T5 (spec 4.6.3): the opening fact of a five-hour block, a harvest
|
|
794
|
+
# family (prefix `fhbo`, order 35) keyed by the block's natural key.
|
|
795
|
+
# Schema creation only.
|
|
796
|
+
AccessContract(
|
|
797
|
+
function='_cctally_core:open_db',
|
|
798
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS five_hour_block_openings ( id INTEGER PRIMARY KEY, account_key TEXT NOT NULL, 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, created_at_utc TEXT NOT NULL, opening_record_id TEXT NOT NULL, creation_kind TEXT NOT NULL, five_hour_percent REAL NOT NULL, seven_day_pct_at_block_start REAL, weekly_observation_held INTEGER NOT NULL DEFAULT 0, weekly_basis_captured_at_utc TEXT, journal_id TEXT, UNIQUE(account_key, five_hour_window_key) )',
|
|
799
|
+
table='five_hour_block_openings',
|
|
800
|
+
keys=(),
|
|
801
|
+
predicate='',
|
|
802
|
+
ordering='',
|
|
803
|
+
selected=(),
|
|
804
|
+
effects='write',
|
|
805
|
+
classes=('singleton',),
|
|
806
|
+
inert_rule=MAINT,
|
|
807
|
+
),
|
|
685
808
|
AccessContract(
|
|
686
809
|
function='_cctally_core:open_db',
|
|
687
810
|
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) )",
|
|
@@ -792,8 +915,20 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
792
915
|
),
|
|
793
916
|
AccessContract(
|
|
794
917
|
function='_cctally_core:open_db',
|
|
795
|
-
sql_fingerprint='CREATE TABLE IF NOT EXISTS
|
|
796
|
-
table='
|
|
918
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS outcome_quarantine_axis_state (generation INTEGER NOT NULL, account_key TEXT NOT NULL, axis TEXT NOT NULL, state TEXT NOT NULL, waiting_for TEXT, coverage_id TEXT, witness_id TEXT, release_id TEXT, revocation TEXT, since TEXT, recovered_at TEXT, not_before INTEGER, witness_key TEXT, PRIMARY KEY (generation, account_key, axis))',
|
|
919
|
+
table='outcome_quarantine_axis_state',
|
|
920
|
+
keys=(),
|
|
921
|
+
predicate='',
|
|
922
|
+
ordering='',
|
|
923
|
+
selected=(),
|
|
924
|
+
effects='write',
|
|
925
|
+
classes=('singleton',),
|
|
926
|
+
inert_rule=MAINT,
|
|
927
|
+
),
|
|
928
|
+
AccessContract(
|
|
929
|
+
function='_cctally_core:open_db',
|
|
930
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS outcome_quarantine_bounds (scope TEXT NOT NULL, axis TEXT NOT NULL, bounds_json TEXT NOT NULL, PRIMARY KEY (scope, axis))',
|
|
931
|
+
table='outcome_quarantine_bounds',
|
|
797
932
|
keys=(),
|
|
798
933
|
predicate='',
|
|
799
934
|
ordering='',
|
|
@@ -804,8 +939,8 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
804
939
|
),
|
|
805
940
|
AccessContract(
|
|
806
941
|
function='_cctally_core:open_db',
|
|
807
|
-
sql_fingerprint='CREATE TABLE IF NOT EXISTS
|
|
808
|
-
table='
|
|
942
|
+
sql_fingerprint='CREATE TABLE IF NOT EXISTS outcome_quarantine_episodes (opener_segment TEXT, opener_offset INTEGER, opened_at TEXT, closer_segment TEXT, closer_offset INTEGER, closed_at TEXT, PRIMARY KEY (opener_segment, opener_offset))',
|
|
943
|
+
table='outcome_quarantine_episodes',
|
|
809
944
|
keys=(),
|
|
810
945
|
predicate='',
|
|
811
946
|
ordering='',
|
|
@@ -1089,10 +1224,55 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1089
1224
|
# predicates, ordering, selected columns, execution condition and
|
|
1090
1225
|
# read-only effect are unchanged and the contract and its MAINT inert
|
|
1091
1226
|
# rule stand.
|
|
1227
|
+
# Reviewed re-pin (#1019/#1014 Task A, base 5b15db929), for open_db #1,
|
|
1228
|
+
# #2 and #3. Changed: only bindings these sites read through `open_db`'s
|
|
1229
|
+
# closure — `STATS_INDEX_EPOCH` 1019 -> 1020 (spec 4.7 C6), and the
|
|
1230
|
+
# `_init_paths_from_env` assignments of APP_DIR, DB_PATH, LOG_DIR,
|
|
1231
|
+
# HOOK_TICK_LOG_DIR and STATUSLINE_ACCOUNT_BOUND_DIR, whose statements
|
|
1232
|
+
# changed because the same function now also assigns the retired v2 root
|
|
1233
|
+
# and the revision-3 cache path and names the v3 root. DB_PATH's value is
|
|
1234
|
+
# unchanged. No SQL, table selection, predicate, ordering, selected column,
|
|
1235
|
+
# execution condition or effect changed, so each contract and its MAINT
|
|
1236
|
+
# inert rule stand.
|
|
1237
|
+
# Reviewed re-pin (#943 T3, base c5419d209), for open_db #1. Changed: only
|
|
1238
|
+
# bindings this site reads — `STATS_INDEX_EPOCH` 1020 -> 1021 (spec 4.7)
|
|
1239
|
+
# and the producer `open_db` itself, whose epoch-1021 schema block now
|
|
1240
|
+
# also creates `five_hour_credit_boundaries` with its two journal-id
|
|
1241
|
+
# indexes and creates `five_hour_credit_confirmation_state` with the
|
|
1242
|
+
# NULLABLE `pending_captured_at_utc` column; those are literal statements,
|
|
1243
|
+
# registered as their own MAINT contracts. No SQL, table selection,
|
|
1244
|
+
# predicate, ordering, selected column, execution condition or effect of
|
|
1245
|
+
# this site changed, so the contract and its inert rule stand.
|
|
1246
|
+
# Reviewed re-pin (#956 T5, base af10118c7), for open_db #1. Changed: only
|
|
1247
|
+
# the producer `open_db` itself, whose epoch-1021 schema block now also
|
|
1248
|
+
# creates `five_hour_block_openings` (the #956 class-2 opening fact, spec
|
|
1249
|
+
# 4.6.3) and lists it in the two journal-id index loops; the CREATE TABLE is
|
|
1250
|
+
# a literal statement, registered as its own MAINT contract. No SQL, table
|
|
1251
|
+
# selection, predicate, ordering, selected column, execution condition or
|
|
1252
|
+
# effect of this site changed, so the contract and its inert rule stand.
|
|
1253
|
+
# Reviewed re-pin (#1015 T3, base 16b055cae), for open_db #1. Changed: the
|
|
1254
|
+
# binding `STATS_INDEX_EPOCH` 1021 -> 1022 (spec 5.1) and the producer
|
|
1255
|
+
# `open_db` itself, whose epoch-1022 schema block now also creates
|
|
1256
|
+
# `claude_weekly_observation_index` with its (account_key,
|
|
1257
|
+
# captured_at_utc) index, `claude_weekly_correction_history`,
|
|
1258
|
+
# `claude_weekly_correction_ops`, `correction_batch_lineage` and
|
|
1259
|
+
# `correction_batch_footprint`; those are literal statements, registered
|
|
1260
|
+
# as their own MAINT contracts. No SQL, table selection, predicate,
|
|
1261
|
+
# ordering, selected column, execution condition or effect of this site
|
|
1262
|
+
# changed, so the contract and its MAINT inert rule stand.
|
|
1263
|
+
# Reviewed re-pin (#948 T-A, base 7e2ea2411), for open_db #1, #2 and #3.
|
|
1264
|
+
# Changed: the binding `STATS_INDEX_EPOCH` 1022 -> 1023 and the producer
|
|
1265
|
+
# `open_db` itself, whose epoch-1023 schema block no longer creates
|
|
1266
|
+
# `outcome_quarantine_envelope` / `outcome_quarantine_certificates` and
|
|
1267
|
+
# now creates `outcome_quarantine_episodes`, `outcome_quarantine_bounds`
|
|
1268
|
+
# and `outcome_quarantine_axis_state`; those are literal statements,
|
|
1269
|
+
# registered as their own MAINT contracts. No SQL, table selection,
|
|
1270
|
+
# predicate, ordering, selected column, execution condition or effect of
|
|
1271
|
+
# these sites changed, so each contract and its MAINT inert rule stand.
|
|
1092
1272
|
AccessContract(
|
|
1093
1273
|
function='_cctally_core:open_db',
|
|
1094
1274
|
sql_fingerprint='dynamic:_cctally_core:open_db#1',
|
|
1095
|
-
sql_shape='sha256:
|
|
1275
|
+
sql_shape='sha256:61bf241458c1f433',
|
|
1096
1276
|
table='dynamic',
|
|
1097
1277
|
keys=(),
|
|
1098
1278
|
predicate='dynamic SQL',
|
|
@@ -1102,10 +1282,36 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1102
1282
|
classes=('cross-period',),
|
|
1103
1283
|
inert_rule=MAINT,
|
|
1104
1284
|
),
|
|
1285
|
+
# Reviewed re-pin (#943 T3, base c5419d209), for open_db #2. Changed: only
|
|
1286
|
+
# bindings this site reads — `STATS_INDEX_EPOCH` 1020 -> 1021 (spec 4.7)
|
|
1287
|
+
# and the producer `open_db` itself, whose epoch-1021 schema block now
|
|
1288
|
+
# also creates `five_hour_credit_boundaries` with its two journal-id
|
|
1289
|
+
# indexes and creates `five_hour_credit_confirmation_state` with the
|
|
1290
|
+
# NULLABLE `pending_captured_at_utc` column; those are literal statements,
|
|
1291
|
+
# registered as their own MAINT contracts. No SQL, table selection,
|
|
1292
|
+
# predicate, ordering, selected column, execution condition or effect of
|
|
1293
|
+
# this site changed, so the contract and its inert rule stand.
|
|
1294
|
+
# Reviewed re-pin (#956 T5, base af10118c7), for open_db #2. Changed: only
|
|
1295
|
+
# the producer `open_db` itself, whose epoch-1021 schema block now also
|
|
1296
|
+
# creates `five_hour_block_openings` (the #956 class-2 opening fact, spec
|
|
1297
|
+
# 4.6.3) and lists it in the two journal-id index loops; the CREATE TABLE is
|
|
1298
|
+
# a literal statement, registered as its own MAINT contract. No SQL, table
|
|
1299
|
+
# selection, predicate, ordering, selected column, execution condition or
|
|
1300
|
+
# effect of this site changed, so the contract and its inert rule stand.
|
|
1301
|
+
# Reviewed re-pin (#1015 T3, base 16b055cae), for open_db #2. Changed: the
|
|
1302
|
+
# binding `STATS_INDEX_EPOCH` 1021 -> 1022 (spec 5.1) and the producer
|
|
1303
|
+
# `open_db` itself, whose epoch-1022 schema block now also creates
|
|
1304
|
+
# `claude_weekly_observation_index` with its (account_key,
|
|
1305
|
+
# captured_at_utc) index, `claude_weekly_correction_history`,
|
|
1306
|
+
# `claude_weekly_correction_ops`, `correction_batch_lineage` and
|
|
1307
|
+
# `correction_batch_footprint`; those are literal statements, registered
|
|
1308
|
+
# as their own MAINT contracts. No SQL, table selection, predicate,
|
|
1309
|
+
# ordering, selected column, execution condition or effect of this site
|
|
1310
|
+
# changed, so the contract and its MAINT inert rule stand.
|
|
1105
1311
|
AccessContract(
|
|
1106
1312
|
function='_cctally_core:open_db',
|
|
1107
1313
|
sql_fingerprint='dynamic:_cctally_core:open_db#2',
|
|
1108
|
-
sql_shape='sha256:
|
|
1314
|
+
sql_shape='sha256:7d7365dfd8acf5d3',
|
|
1109
1315
|
table='dynamic',
|
|
1110
1316
|
keys=(),
|
|
1111
1317
|
predicate='dynamic SQL',
|
|
@@ -1115,10 +1321,36 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1115
1321
|
classes=('cross-period',),
|
|
1116
1322
|
inert_rule=MAINT,
|
|
1117
1323
|
),
|
|
1324
|
+
# Reviewed re-pin (#943 T3, base c5419d209), for open_db #3. Changed: only
|
|
1325
|
+
# bindings this site reads — `STATS_INDEX_EPOCH` 1020 -> 1021 (spec 4.7)
|
|
1326
|
+
# and the producer `open_db` itself, whose epoch-1021 schema block now
|
|
1327
|
+
# also creates `five_hour_credit_boundaries` with its two journal-id
|
|
1328
|
+
# indexes and creates `five_hour_credit_confirmation_state` with the
|
|
1329
|
+
# NULLABLE `pending_captured_at_utc` column; those are literal statements,
|
|
1330
|
+
# registered as their own MAINT contracts. No SQL, table selection,
|
|
1331
|
+
# predicate, ordering, selected column, execution condition or effect of
|
|
1332
|
+
# this site changed, so the contract and its inert rule stand.
|
|
1333
|
+
# Reviewed re-pin (#956 T5, base af10118c7), for open_db #3. Changed: only
|
|
1334
|
+
# the producer `open_db` itself, whose epoch-1021 schema block now also
|
|
1335
|
+
# creates `five_hour_block_openings` (the #956 class-2 opening fact, spec
|
|
1336
|
+
# 4.6.3) and lists it in the two journal-id index loops; the CREATE TABLE is
|
|
1337
|
+
# a literal statement, registered as its own MAINT contract. No SQL, table
|
|
1338
|
+
# selection, predicate, ordering, selected column, execution condition or
|
|
1339
|
+
# effect of this site changed, so the contract and its inert rule stand.
|
|
1340
|
+
# Reviewed re-pin (#1015 T3, base 16b055cae), for open_db #3. Changed: the
|
|
1341
|
+
# binding `STATS_INDEX_EPOCH` 1021 -> 1022 (spec 5.1) and the producer
|
|
1342
|
+
# `open_db` itself, whose epoch-1022 schema block now also creates
|
|
1343
|
+
# `claude_weekly_observation_index` with its (account_key,
|
|
1344
|
+
# captured_at_utc) index, `claude_weekly_correction_history`,
|
|
1345
|
+
# `claude_weekly_correction_ops`, `correction_batch_lineage` and
|
|
1346
|
+
# `correction_batch_footprint`; those are literal statements, registered
|
|
1347
|
+
# as their own MAINT contracts. No SQL, table selection, predicate,
|
|
1348
|
+
# ordering, selected column, execution condition or effect of this site
|
|
1349
|
+
# changed, so the contract and its MAINT inert rule stand.
|
|
1118
1350
|
AccessContract(
|
|
1119
1351
|
function='_cctally_core:open_db',
|
|
1120
1352
|
sql_fingerprint='dynamic:_cctally_core:open_db#3',
|
|
1121
|
-
sql_shape='sha256:
|
|
1353
|
+
sql_shape='sha256:d3d6289b75b86c2f',
|
|
1122
1354
|
table='dynamic',
|
|
1123
1355
|
keys=(),
|
|
1124
1356
|
predicate='dynamic SQL',
|
|
@@ -1216,10 +1448,23 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1216
1448
|
classes=('singleton', 'range-keyed'),
|
|
1217
1449
|
inert_rule=ACCOUNTS,
|
|
1218
1450
|
),
|
|
1451
|
+
# Reviewed re-pin (#980 D3, base 5b021b820), for _apply_quota_records #1
|
|
1452
|
+
# and #2. Changed (`~ producer`): only the producer's bookkeeping around
|
|
1453
|
+
# its two dynamic statements. It now compares `cache.total_changes`
|
|
1454
|
+
# before and after the batch, collects each executed record's root,
|
|
1455
|
+
# raw reset and canonical anchor into in-memory spans, and, when the
|
|
1456
|
+
# batch changed rows, calls `_cctally_cache.add_codex_finalization_debt`
|
|
1457
|
+
# (a `cache_meta` read and write) with `model` from
|
|
1458
|
+
# `_codex_unresolved_quota_model_exists` (one indexed probe of
|
|
1459
|
+
# `quota_window_snapshots`), all on the same cache.db connection and
|
|
1460
|
+
# transaction. The natural-key read and the INSERT/UPSERT this pin
|
|
1461
|
+
# covers keep their table selection, predicate, ordering, selected
|
|
1462
|
+
# columns, parameter construction, execution conditions and effects, so
|
|
1463
|
+
# the contract and its inert rule stand.
|
|
1219
1464
|
AccessContract(
|
|
1220
1465
|
function='_cctally_journal:_apply_quota_records',
|
|
1221
1466
|
sql_fingerprint='dynamic:_cctally_journal:_apply_quota_records#1',
|
|
1222
|
-
sql_shape='sha256:
|
|
1467
|
+
sql_shape='sha256:265c580d51dc9ea0',
|
|
1223
1468
|
table='dynamic',
|
|
1224
1469
|
keys=(),
|
|
1225
1470
|
predicate='dynamic SQL',
|
|
@@ -1232,7 +1477,7 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1232
1477
|
AccessContract(
|
|
1233
1478
|
function='_cctally_journal:_apply_quota_records',
|
|
1234
1479
|
sql_fingerprint='dynamic:_cctally_journal:_apply_quota_records#2',
|
|
1235
|
-
sql_shape='sha256:
|
|
1480
|
+
sql_shape='sha256:b1a8eedf9a7f98c9',
|
|
1236
1481
|
table='dynamic',
|
|
1237
1482
|
keys=(),
|
|
1238
1483
|
predicate='dynamic SQL',
|
|
@@ -1242,9 +1487,14 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1242
1487
|
classes=('cross-period',),
|
|
1243
1488
|
inert_rule=CODEX,
|
|
1244
1489
|
),
|
|
1490
|
+
# #1015 T7 contract review: the evidence backfill also fills the
|
|
1491
|
+
# nullable `fit_lineage` column (spec 5.6) with COALESCE, so a lineage
|
|
1492
|
+
# already folded is never erased. Same table, natural-key predicate and
|
|
1493
|
+
# write effect; the column is read only by the calibration lineage
|
|
1494
|
+
# readers, never by a detector decision.
|
|
1245
1495
|
AccessContract(
|
|
1246
1496
|
function='_cctally_journal:_backfill_meter_rate_change_evidence',
|
|
1247
|
-
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 = ?',
|
|
1497
|
+
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, ?), fit_lineage = COALESCE(fit_lineage, ?) WHERE provider = ? AND account_key = ? AND effective_from = ?',
|
|
1248
1498
|
table='meter_rate_change_events',
|
|
1249
1499
|
keys=('provider', 'account_key', 'effective_from'),
|
|
1250
1500
|
predicate='provider = ? AND account_key = ? AND effective_from = ?',
|
|
@@ -1331,10 +1581,48 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1331
1581
|
# and `UPDATE ... WHERE id = ?`, their keys, predicates, execution
|
|
1332
1582
|
# conditions and effects are unchanged, so the contracts and their inert
|
|
1333
1583
|
# rules stand.
|
|
1584
|
+
# Reviewed re-pin (#1019/#1014 Task A, base 5b15db929), for both sites.
|
|
1585
|
+
# Changed: `_lib_account_protocol.strip_stamp` now also strips `wpx`
|
|
1586
|
+
# (new bindings SUCCESSOR_REVISION_KEY and _STAMP_KEYS), the semantic
|
|
1587
|
+
# comparison of a converged event, and the `_init_paths_from_env` path
|
|
1588
|
+
# assignments (see open_db above). The target-table SELECT/UPDATE, keys,
|
|
1589
|
+
# predicates, execution conditions and effects are unchanged, so the
|
|
1590
|
+
# contracts and inert rules stand.
|
|
1591
|
+
# Reviewed re-pin (#956 T5, base af10118c7), for
|
|
1592
|
+
# _converge_row_from_effective #1. Changed: the producer, which now ends
|
|
1593
|
+
# with the opening fact's coupled convergence (`_converge_opened_block`, its
|
|
1594
|
+
# statements registered as their own contracts) when the target is
|
|
1595
|
+
# `five_hour_block_openings`; and the `_EVT_SPECS` binding, whose
|
|
1596
|
+
# `five_hour_block_open` spec carries the applier
|
|
1597
|
+
# `_apply_five_hour_block_open`, so the closure now follows it into
|
|
1598
|
+
# `_apply_generic_evt` (and from there `_insert_or_ignore`,
|
|
1599
|
+
# `_resolve_fold_ref`, `_resolve_ref`, `_derived_fk_value`,
|
|
1600
|
+
# `_report_unresolved_fold_reference`, `_SUPPRESSIBLE_FOLD_REFS`,
|
|
1601
|
+
# `JournalError`, `UnresolvedFoldReference`), `_block_opening_row` and
|
|
1602
|
+
# `_materialize_opened_block`. This site still reads `spec.table` from the
|
|
1603
|
+
# spec, never its applier, and the dynamic statement it executes is
|
|
1604
|
+
# unchanged. No SQL, table selection, predicate, ordering, selected column,
|
|
1605
|
+
# execution condition or effect of this site changed, so the contract and
|
|
1606
|
+
# its inert rule stand.
|
|
1607
|
+
# Reviewed re-pin (#1015 T7, base 7455ca434), for _converge_row_from_effective #1. Changed: only the
|
|
1608
|
+
# fold machinery this site reaches through bindings: `_EVT_SPECS` gained
|
|
1609
|
+
# the table-less `meter_rate_change_supersession` spec (order 46), whose
|
|
1610
|
+
# applier `_apply_meter_rate_change_supersession` calls
|
|
1611
|
+
# `_insert_meter_rate_change_supersession` (a literal INSERT OR IGNORE,
|
|
1612
|
+
# registered as its own contract) and reads `MRC_SUPERSESSION_REASON`
|
|
1613
|
+
# and `_canonical_json_or_none`; `_MeterRateChangeRow` gained the
|
|
1614
|
+
# nullable `fit_lineage` field, which `_meter_rate_change_row` fills
|
|
1615
|
+
# through `_canonical_json_or_none` and
|
|
1616
|
+
# `_backfill_meter_rate_change_evidence` COALESCEs (its literal UPDATE is
|
|
1617
|
+
# reviewed beside its own contract). A table-less spec returns
|
|
1618
|
+
# `CONVERGE_DROPPED` before this site's statement, which still names the
|
|
1619
|
+
# spec's table. No SQL, table selection, predicate, ordering, selected
|
|
1620
|
+
# column, execution condition or effect of this site changed, so the
|
|
1621
|
+
# contract and its inert rule stand.
|
|
1334
1622
|
AccessContract(
|
|
1335
1623
|
function='_cctally_journal:_converge_row_from_effective',
|
|
1336
1624
|
sql_fingerprint='dynamic:_cctally_journal:_converge_row_from_effective#1',
|
|
1337
|
-
sql_shape='sha256:
|
|
1625
|
+
sql_shape='sha256:b92199c9a76d4a20',
|
|
1338
1626
|
table='dynamic',
|
|
1339
1627
|
keys=(),
|
|
1340
1628
|
predicate='dynamic SQL',
|
|
@@ -1344,10 +1632,41 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1344
1632
|
classes=('cross-period',),
|
|
1345
1633
|
inert_rule=JOURNAL,
|
|
1346
1634
|
),
|
|
1635
|
+
# Reviewed re-pin (#956 T5, base af10118c7), for
|
|
1636
|
+
# _converge_row_from_effective #2. Changed: the producer, which now ends
|
|
1637
|
+
# with the opening fact's coupled convergence (`_converge_opened_block`, its
|
|
1638
|
+
# statements registered as their own contracts) when the target is
|
|
1639
|
+
# `five_hour_block_openings`; and the `_EVT_SPECS` binding, whose
|
|
1640
|
+
# `five_hour_block_open` spec carries the applier
|
|
1641
|
+
# `_apply_five_hour_block_open`, so the closure now follows it into
|
|
1642
|
+
# `_apply_generic_evt` (and from there `_insert_or_ignore`,
|
|
1643
|
+
# `_resolve_fold_ref`, `_resolve_ref`, `_derived_fk_value`,
|
|
1644
|
+
# `_report_unresolved_fold_reference`, `_SUPPRESSIBLE_FOLD_REFS`,
|
|
1645
|
+
# `JournalError`, `UnresolvedFoldReference`), `_block_opening_row` and
|
|
1646
|
+
# `_materialize_opened_block`. This site still reads `spec.table` from the
|
|
1647
|
+
# spec, never its applier, and the dynamic statement it executes is
|
|
1648
|
+
# unchanged. No SQL, table selection, predicate, ordering, selected column,
|
|
1649
|
+
# execution condition or effect of this site changed, so the contract and
|
|
1650
|
+
# its inert rule stand.
|
|
1651
|
+
# Reviewed re-pin (#1015 T7, base 7455ca434), for _converge_row_from_effective #2. Changed: only the
|
|
1652
|
+
# fold machinery this site reaches through bindings: `_EVT_SPECS` gained
|
|
1653
|
+
# the table-less `meter_rate_change_supersession` spec (order 46), whose
|
|
1654
|
+
# applier `_apply_meter_rate_change_supersession` calls
|
|
1655
|
+
# `_insert_meter_rate_change_supersession` (a literal INSERT OR IGNORE,
|
|
1656
|
+
# registered as its own contract) and reads `MRC_SUPERSESSION_REASON`
|
|
1657
|
+
# and `_canonical_json_or_none`; `_MeterRateChangeRow` gained the
|
|
1658
|
+
# nullable `fit_lineage` field, which `_meter_rate_change_row` fills
|
|
1659
|
+
# through `_canonical_json_or_none` and
|
|
1660
|
+
# `_backfill_meter_rate_change_evidence` COALESCEs (its literal UPDATE is
|
|
1661
|
+
# reviewed beside its own contract). A table-less spec returns
|
|
1662
|
+
# `CONVERGE_DROPPED` before this site's statement, which still names the
|
|
1663
|
+
# spec's table. No SQL, table selection, predicate, ordering, selected
|
|
1664
|
+
# column, execution condition or effect of this site changed, so the
|
|
1665
|
+
# contract and its inert rule stand.
|
|
1347
1666
|
AccessContract(
|
|
1348
1667
|
function='_cctally_journal:_converge_row_from_effective',
|
|
1349
1668
|
sql_fingerprint='dynamic:_cctally_journal:_converge_row_from_effective#2',
|
|
1350
|
-
sql_shape='sha256:
|
|
1669
|
+
sql_shape='sha256:a43354e85f72febd',
|
|
1351
1670
|
table='dynamic',
|
|
1352
1671
|
keys=(),
|
|
1353
1672
|
predicate='dynamic SQL',
|
|
@@ -1440,6 +1759,14 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1440
1759
|
classes=('cross-period',),
|
|
1441
1760
|
inert_rule=JOURNAL,
|
|
1442
1761
|
),
|
|
1762
|
+
# Reviewed re-pin (#956 T5, base af10118c7), for _delete_scratch_row #1.
|
|
1763
|
+
# Changed: only the producer, which now first calls `_remove_opened_block`
|
|
1764
|
+
# (its statements registered as their own contracts) when the table is
|
|
1765
|
+
# `five_hour_block_openings`, so a tombstoned opening takes the open block
|
|
1766
|
+
# it materialized with it (spec 4.6.3). The `DELETE FROM {table} WHERE id =
|
|
1767
|
+
# ?` this pin covers is unchanged. No SQL, table selection, predicate,
|
|
1768
|
+
# ordering, selected column, execution condition or effect of this site
|
|
1769
|
+
# changed, so the contract and its inert rule stand.
|
|
1443
1770
|
AccessContract(
|
|
1444
1771
|
# #825/#832 fix round E: a derivation-completion scratch replay
|
|
1445
1772
|
# removes the one row a retained tombstone says does not exist, on
|
|
@@ -1447,7 +1774,7 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1447
1774
|
# a journal family's own (`_HARVEST_SPECS`/`_EVT_SPECS`).
|
|
1448
1775
|
function='_cctally_journal:_delete_scratch_row',
|
|
1449
1776
|
sql_fingerprint='dynamic:_cctally_journal:_delete_scratch_row#1',
|
|
1450
|
-
sql_shape='sha256:
|
|
1777
|
+
sql_shape='sha256:24df60c360ccd098',
|
|
1451
1778
|
table='dynamic',
|
|
1452
1779
|
keys=('id',),
|
|
1453
1780
|
predicate='id = ? on a scratch projection (a journal family table)',
|
|
@@ -1469,10 +1796,25 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1469
1796
|
classes=('cross-period',),
|
|
1470
1797
|
inert_rule=MAINT,
|
|
1471
1798
|
),
|
|
1799
|
+
# Reviewed re-pin (#943 T3, base c5419d209), for _harvest #1. Changed:
|
|
1800
|
+
# only bindings this site reads — `_HARVEST_SPECS`, which gains the
|
|
1801
|
+
# `five_hour_credit_boundary` spec (table `five_hour_credit_boundaries`,
|
|
1802
|
+
# prefix `fhcb`, order 29). The site iterates the specs generically, so
|
|
1803
|
+
# the new family is harvested by the same statement shapes as every other
|
|
1804
|
+
# harvest family. No SQL, table selection, predicate, ordering, selected
|
|
1805
|
+
# column, execution condition or effect of this site changed, so the
|
|
1806
|
+
# contract and its inert rule stand.
|
|
1807
|
+
# Reviewed re-pin (#956 T5, base af10118c7), for _harvest #1. Changed: only
|
|
1808
|
+
# the `_HARVEST_SPECS` binding, which gains the `five_hour_block_open` spec
|
|
1809
|
+
# (table `five_hour_block_openings`, prefix `fhbo`, order 35). The site
|
|
1810
|
+
# iterates the specs generically, so the new family is harvested by the same
|
|
1811
|
+
# statement shapes as every other harvest family. No SQL, table selection,
|
|
1812
|
+
# predicate, ordering, selected column, execution condition or effect of
|
|
1813
|
+
# this site changed, so the contract and its inert rule stand.
|
|
1472
1814
|
AccessContract(
|
|
1473
1815
|
function='_cctally_journal:_harvest',
|
|
1474
1816
|
sql_fingerprint='dynamic:_cctally_journal:_harvest#1',
|
|
1475
|
-
sql_shape='sha256:
|
|
1817
|
+
sql_shape='sha256:eeb08bab185c5989',
|
|
1476
1818
|
table='dynamic',
|
|
1477
1819
|
keys=(),
|
|
1478
1820
|
predicate='dynamic SQL',
|
|
@@ -1494,10 +1836,17 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1494
1836
|
classes=('singleton',),
|
|
1495
1837
|
inert_rule=JOURNAL,
|
|
1496
1838
|
),
|
|
1839
|
+
# Reviewed re-pin (#1015 T7, base 7455ca434), for _insert_meter_rate_change #1. Changed: only the
|
|
1840
|
+
# binding `_MeterRateChangeRow`, which gained the nullable `fit_lineage`
|
|
1841
|
+
# field (spec 5.6), so the row-driven INSERT OR IGNORE column list also
|
|
1842
|
+
# writes `fit_lineage`. Same table, natural-key conflict target, parameter
|
|
1843
|
+
# construction and execution condition; the added column is read only
|
|
1844
|
+
# by the calibration lineage readers, never by a detector decision, so
|
|
1845
|
+
# the contract and its inert rule stand.
|
|
1497
1846
|
AccessContract(
|
|
1498
1847
|
function='_cctally_journal:_insert_meter_rate_change',
|
|
1499
1848
|
sql_fingerprint='dynamic:_cctally_journal:_insert_meter_rate_change#1',
|
|
1500
|
-
sql_shape='sha256:
|
|
1849
|
+
sql_shape='sha256:2c2d27ca4dddd598',
|
|
1501
1850
|
table='dynamic',
|
|
1502
1851
|
keys=(),
|
|
1503
1852
|
predicate='dynamic SQL',
|
|
@@ -1507,6 +1856,21 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1507
1856
|
classes=('cross-period',),
|
|
1508
1857
|
inert_rule=JOURNAL,
|
|
1509
1858
|
),
|
|
1859
|
+
# #1015 T7: the `meter_rate_change_supersession` evt applier folds one
|
|
1860
|
+
# explicit supersession by its natural key with INSERT OR IGNORE, so a
|
|
1861
|
+
# replay or a duplicate repeats to the same row.
|
|
1862
|
+
AccessContract(
|
|
1863
|
+
function='_cctally_journal:_insert_meter_rate_change_supersession',
|
|
1864
|
+
sql_fingerprint='INSERT OR IGNORE INTO meter_rate_change_supersessions (provider, account_key, effective_from, reason, corrections, superseded_at_utc, created_at_utc) VALUES (?,?,?,?,?,?,?)',
|
|
1865
|
+
table='meter_rate_change_supersessions',
|
|
1866
|
+
keys=('provider', 'account_key', 'effective_from'),
|
|
1867
|
+
predicate='',
|
|
1868
|
+
ordering='',
|
|
1869
|
+
selected=(),
|
|
1870
|
+
effects='write',
|
|
1871
|
+
classes=('singleton',),
|
|
1872
|
+
inert_rule=LINEAGE,
|
|
1873
|
+
),
|
|
1510
1874
|
AccessContract(
|
|
1511
1875
|
function='_cctally_journal:_insert_or_ignore',
|
|
1512
1876
|
sql_fingerprint='dynamic:_cctally_journal:_insert_or_ignore#1',
|
|
@@ -1617,10 +1981,82 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1617
1981
|
classes=('singleton',),
|
|
1618
1982
|
inert_rule=MAINT,
|
|
1619
1983
|
),
|
|
1984
|
+
# #949: the replace mechanism's twin of the four sites above. It stamps
|
|
1985
|
+
# the closed scratch on the scratch's own connection before `os.replace`,
|
|
1986
|
+
# under the regime of the publishing rebuild.
|
|
1987
|
+
AccessContract(
|
|
1988
|
+
function='_cctally_journal:_stamp_replace_scratch',
|
|
1989
|
+
sql_fingerprint='DELETE FROM stats_publication_stamp',
|
|
1990
|
+
table='stats_publication_stamp',
|
|
1991
|
+
keys=(),
|
|
1992
|
+
predicate='',
|
|
1993
|
+
ordering='',
|
|
1994
|
+
selected=(),
|
|
1995
|
+
effects='delete',
|
|
1996
|
+
classes=('singleton',),
|
|
1997
|
+
inert_rule=MAINT,
|
|
1998
|
+
),
|
|
1999
|
+
AccessContract(
|
|
2000
|
+
function='_cctally_journal:_stamp_replace_scratch',
|
|
2001
|
+
sql_fingerprint='INSERT INTO stats_publication_stamp (record_path, started_at_utc, stamped_at_utc) VALUES (?, ?, ?)',
|
|
2002
|
+
table='stats_publication_stamp',
|
|
2003
|
+
keys=(),
|
|
2004
|
+
predicate='',
|
|
2005
|
+
ordering='',
|
|
2006
|
+
selected=(),
|
|
2007
|
+
effects='write',
|
|
2008
|
+
classes=('singleton',),
|
|
2009
|
+
inert_rule=MAINT,
|
|
2010
|
+
),
|
|
2011
|
+
AccessContract(
|
|
2012
|
+
function='_cctally_journal:_stamp_replace_scratch',
|
|
2013
|
+
sql_fingerprint="SELECT 1 FROM sqlite_schema WHERE type='table' AND name='journal_selector_state'",
|
|
2014
|
+
table='journal_selector_state',
|
|
2015
|
+
keys=(),
|
|
2016
|
+
predicate="type='table' AND name='journal_selector_state'",
|
|
2017
|
+
ordering='',
|
|
2018
|
+
selected=('1',),
|
|
2019
|
+
effects='read',
|
|
2020
|
+
classes=('cross-period',),
|
|
2021
|
+
inert_rule=MAINT,
|
|
2022
|
+
),
|
|
2023
|
+
AccessContract(
|
|
2024
|
+
function='_cctally_journal:_stamp_replace_scratch',
|
|
2025
|
+
sql_fingerprint='UPDATE journal_selector_state SET generation_record_path = ?, generation_stamped_at_utc = ?',
|
|
2026
|
+
table='journal_selector_state',
|
|
2027
|
+
keys=(),
|
|
2028
|
+
predicate='',
|
|
2029
|
+
ordering='',
|
|
2030
|
+
selected=(),
|
|
2031
|
+
effects='write',
|
|
2032
|
+
classes=('singleton',),
|
|
2033
|
+
inert_rule=MAINT,
|
|
2034
|
+
),
|
|
2035
|
+
# Reviewed re-pin (#1019/#1014 Task A, base 5b15db929), for all five
|
|
2036
|
+
# `_publish_generation_in_place` sites. Changed: only the
|
|
2037
|
+
# `STATS_INDEX_EPOCH` binding (1019 -> 1020) the publication stamps; the
|
|
2038
|
+
# statements, tables, predicates and effects are unchanged.
|
|
2039
|
+
# Reviewed re-pin (#943 T3, base c5419d209), for
|
|
2040
|
+
# _publish_generation_in_place #1. Changed: only bindings this site reads
|
|
2041
|
+
# — `STATS_INDEX_EPOCH` 1020 -> 1021 (spec 4.7). No SQL, table selection,
|
|
2042
|
+
# predicate, ordering, selected column, execution condition or effect of
|
|
2043
|
+
# this site changed, so the contract and its inert rule stand.
|
|
2044
|
+
# Reviewed re-pin (#1015 T3, base 16b055cae), for _publish_generation_in_place #1. Changed: only
|
|
2045
|
+
# the binding `STATS_INDEX_EPOCH` 1021 -> 1022 (spec 5.1). No SQL, table
|
|
2046
|
+
# selection, predicate, ordering, selected column, execution condition or
|
|
2047
|
+
# effect of this site changed, so the contract and its inert rule stand.
|
|
2048
|
+
# Reviewed re-pin (#948 T-A, base 7e2ea2411), for
|
|
2049
|
+
# _publish_generation_in_place #1-#5, _rebuild_stats_index_locked #1 and
|
|
2050
|
+
# stats_index_matches_journal_prefix #1. Changed: only the binding
|
|
2051
|
+
# `STATS_INDEX_EPOCH` 1022 -> 1023 (and, for the rebuild site, its helper
|
|
2052
|
+
# `open_db`, whose schema block changed as described at open_db #1). No
|
|
2053
|
+
# SQL, table selection, predicate, ordering, selected column, execution
|
|
2054
|
+
# condition or effect of these sites changed, so each contract and its
|
|
2055
|
+
# inert rule stand.
|
|
1620
2056
|
AccessContract(
|
|
1621
2057
|
function='_cctally_journal:_publish_generation_in_place',
|
|
1622
2058
|
sql_fingerprint='dynamic:_cctally_journal:_publish_generation_in_place#1',
|
|
1623
|
-
sql_shape='sha256:
|
|
2059
|
+
sql_shape='sha256:3dbfedf9486acbb9',
|
|
1624
2060
|
table='dynamic',
|
|
1625
2061
|
keys=(),
|
|
1626
2062
|
predicate='dynamic SQL',
|
|
@@ -1630,10 +2066,19 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1630
2066
|
classes=('cross-period',),
|
|
1631
2067
|
inert_rule=MAINT,
|
|
1632
2068
|
),
|
|
2069
|
+
# Reviewed re-pin (#943 T3, base c5419d209), for
|
|
2070
|
+
# _publish_generation_in_place #2/#3/#5. Changed: only bindings this site
|
|
2071
|
+
# reads — `STATS_INDEX_EPOCH` 1020 -> 1021 (spec 4.7). No SQL, table
|
|
2072
|
+
# selection, predicate, ordering, selected column, execution condition or
|
|
2073
|
+
# effect of this site changed, so the contract and its inert rule stand.
|
|
2074
|
+
# Reviewed re-pin (#1015 T3, base 16b055cae), for _publish_generation_in_place #2. Changed: only
|
|
2075
|
+
# the binding `STATS_INDEX_EPOCH` 1021 -> 1022 (spec 5.1). No SQL, table
|
|
2076
|
+
# selection, predicate, ordering, selected column, execution condition or
|
|
2077
|
+
# effect of this site changed, so the contract and its inert rule stand.
|
|
1633
2078
|
AccessContract(
|
|
1634
2079
|
function='_cctally_journal:_publish_generation_in_place',
|
|
1635
2080
|
sql_fingerprint='dynamic:_cctally_journal:_publish_generation_in_place#2',
|
|
1636
|
-
sql_shape='sha256:
|
|
2081
|
+
sql_shape='sha256:cde6ffe8c29bd1a7',
|
|
1637
2082
|
table='dynamic',
|
|
1638
2083
|
keys=(),
|
|
1639
2084
|
predicate='dynamic SQL',
|
|
@@ -1643,10 +2088,19 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1643
2088
|
classes=('cross-period',),
|
|
1644
2089
|
inert_rule=MAINT,
|
|
1645
2090
|
),
|
|
2091
|
+
# Reviewed re-pin (#943 T3, base c5419d209), for
|
|
2092
|
+
# _publish_generation_in_place #2/#3/#5. Changed: only bindings this site
|
|
2093
|
+
# reads — `STATS_INDEX_EPOCH` 1020 -> 1021 (spec 4.7). No SQL, table
|
|
2094
|
+
# selection, predicate, ordering, selected column, execution condition or
|
|
2095
|
+
# effect of this site changed, so the contract and its inert rule stand.
|
|
2096
|
+
# Reviewed re-pin (#1015 T3, base 16b055cae), for _publish_generation_in_place #3. Changed: only
|
|
2097
|
+
# the binding `STATS_INDEX_EPOCH` 1021 -> 1022 (spec 5.1). No SQL, table
|
|
2098
|
+
# selection, predicate, ordering, selected column, execution condition or
|
|
2099
|
+
# effect of this site changed, so the contract and its inert rule stand.
|
|
1646
2100
|
AccessContract(
|
|
1647
2101
|
function='_cctally_journal:_publish_generation_in_place',
|
|
1648
2102
|
sql_fingerprint='dynamic:_cctally_journal:_publish_generation_in_place#3',
|
|
1649
|
-
sql_shape='sha256:
|
|
2103
|
+
sql_shape='sha256:cde6ffe8c29bd1a7',
|
|
1650
2104
|
table='dynamic',
|
|
1651
2105
|
keys=(),
|
|
1652
2106
|
predicate='dynamic SQL',
|
|
@@ -1656,10 +2110,19 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1656
2110
|
classes=('cross-period',),
|
|
1657
2111
|
inert_rule=MAINT,
|
|
1658
2112
|
),
|
|
2113
|
+
# Reviewed re-pin (#943 T3, base c5419d209), for
|
|
2114
|
+
# _publish_generation_in_place #4. Changed: only bindings this site reads
|
|
2115
|
+
# — `STATS_INDEX_EPOCH` 1020 -> 1021 (spec 4.7). No SQL, table selection,
|
|
2116
|
+
# predicate, ordering, selected column, execution condition or effect of
|
|
2117
|
+
# this site changed, so the contract and its inert rule stand.
|
|
2118
|
+
# Reviewed re-pin (#1015 T3, base 16b055cae), for _publish_generation_in_place #4. Changed: only
|
|
2119
|
+
# the binding `STATS_INDEX_EPOCH` 1021 -> 1022 (spec 5.1). No SQL, table
|
|
2120
|
+
# selection, predicate, ordering, selected column, execution condition or
|
|
2121
|
+
# effect of this site changed, so the contract and its inert rule stand.
|
|
1659
2122
|
AccessContract(
|
|
1660
2123
|
function='_cctally_journal:_publish_generation_in_place',
|
|
1661
2124
|
sql_fingerprint='dynamic:_cctally_journal:_publish_generation_in_place#4',
|
|
1662
|
-
sql_shape='sha256:
|
|
2125
|
+
sql_shape='sha256:e42670f9ea1e0bc2',
|
|
1663
2126
|
table='dynamic',
|
|
1664
2127
|
keys=(),
|
|
1665
2128
|
predicate='dynamic SQL',
|
|
@@ -1669,10 +2132,19 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1669
2132
|
classes=('cross-period',),
|
|
1670
2133
|
inert_rule=MAINT,
|
|
1671
2134
|
),
|
|
2135
|
+
# Reviewed re-pin (#943 T3, base c5419d209), for
|
|
2136
|
+
# _publish_generation_in_place #2/#3/#5. Changed: only bindings this site
|
|
2137
|
+
# reads — `STATS_INDEX_EPOCH` 1020 -> 1021 (spec 4.7). No SQL, table
|
|
2138
|
+
# selection, predicate, ordering, selected column, execution condition or
|
|
2139
|
+
# effect of this site changed, so the contract and its inert rule stand.
|
|
2140
|
+
# Reviewed re-pin (#1015 T3, base 16b055cae), for _publish_generation_in_place #5. Changed: only
|
|
2141
|
+
# the binding `STATS_INDEX_EPOCH` 1021 -> 1022 (spec 5.1). No SQL, table
|
|
2142
|
+
# selection, predicate, ordering, selected column, execution condition or
|
|
2143
|
+
# effect of this site changed, so the contract and its inert rule stand.
|
|
1672
2144
|
AccessContract(
|
|
1673
2145
|
function='_cctally_journal:_publish_generation_in_place',
|
|
1674
2146
|
sql_fingerprint='dynamic:_cctally_journal:_publish_generation_in_place#5',
|
|
1675
|
-
sql_shape='sha256:
|
|
2147
|
+
sql_shape='sha256:cde6ffe8c29bd1a7',
|
|
1676
2148
|
table='dynamic',
|
|
1677
2149
|
keys=(),
|
|
1678
2150
|
predicate='dynamic SQL',
|
|
@@ -1793,10 +2265,133 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1793
2265
|
# are unchanged; this site's `SELECT COUNT(*) FROM {tbl}` over
|
|
1794
2266
|
# `_REBUILD_COUNT_TABLES`, its execution condition and its read-only
|
|
1795
2267
|
# effect are unchanged, so the contract and its MAINT inert rule stand.
|
|
2268
|
+
# Reviewed re-pin (#1019/#1014 Task A, base 5b15db929). Changed:
|
|
2269
|
+
# `STATS_INDEX_EPOCH` 1019 -> 1020, `_lib_journal.PROTOCOL_RESOLUTION_KINDS`
|
|
2270
|
+
# gaining `journal_protocol_resolution_v4` (new PROTOCOL_RESOLUTION_V4_KIND
|
|
2271
|
+
# bindings in both modules: the v4 repair acknowledgement, spec 4.7 C5)
|
|
2272
|
+
# and the `_init_paths_from_env` path assignments (see open_db). The
|
|
2273
|
+
# fold's SQL, tables, predicates and effects are unchanged, so the
|
|
2274
|
+
# contract and its inert rule stand.
|
|
2275
|
+
# Reviewed re-pin (#943 T3, base c5419d209), for
|
|
2276
|
+
# _rebuild_stats_index_locked #1. Changed: only bindings this site reads —
|
|
2277
|
+
# `STATS_INDEX_EPOCH` 1020 -> 1021 (spec 4.7) and the producer `open_db`
|
|
2278
|
+
# itself, whose epoch-1021 schema block now also creates
|
|
2279
|
+
# `five_hour_credit_boundaries` with its two journal-id indexes and
|
|
2280
|
+
# creates `five_hour_credit_confirmation_state` with the NULLABLE
|
|
2281
|
+
# `pending_captured_at_utc` column; those are literal statements,
|
|
2282
|
+
# registered as their own MAINT contracts. No SQL, table selection,
|
|
2283
|
+
# predicate, ordering, selected column, execution condition or effect of
|
|
2284
|
+
# this site changed, so the contract and its inert rule stand.
|
|
2285
|
+
# Reviewed re-pin (#956 T4, base 6528383a7), for
|
|
2286
|
+
# _rebuild_stats_index_locked #1. Changed: only functions in the closure
|
|
2287
|
+
# it reaches through Phase 2a's `_backfill_five_hour_blocks` —
|
|
2288
|
+
# `_backfill_five_hour_blocks` (its open-candidate path now materializes
|
|
2289
|
+
# start columns and refreshes every open block, its candidate ranking
|
|
2290
|
+
# breaks ties by `journal_id`) and the new `OpenBlockEnd`,
|
|
2291
|
+
# `select_open_block_end`, `project_open_block_end`,
|
|
2292
|
+
# `_materialize_open_candidate` and `_refresh_every_open_block`, whose
|
|
2293
|
+
# literal statements write the rebuild's private scratch index. None of
|
|
2294
|
+
# them is the dynamic statement this pin covers; its table selection,
|
|
2295
|
+
# predicate, ordering, selected columns, execution condition and effect
|
|
2296
|
+
# are unchanged, so the contract and its inert rule stand.
|
|
2297
|
+
# Reviewed re-pin (#956 T5, base af10118c7), for _rebuild_stats_index_locked
|
|
2298
|
+
# #1. Changed: the producer, whose Phase 2a now computes
|
|
2299
|
+
# `retired_block_openings` beside `journaled_block_first_observations` and
|
|
2300
|
+
# passes it to the backfill; `_backfill_five_hour_blocks`, which drops a
|
|
2301
|
+
# tombstoned opening's window from the legacy open candidates;
|
|
2302
|
+
# `select_open_block_end` and the `OpenBlockEnd` docstring, which project an
|
|
2303
|
+
# opening's reading when the window has no readings (origin `opening`; the
|
|
2304
|
+
# new seed read is registered as its own BLOCKS contract); and the helper
|
|
2305
|
+
# `open_db` (see open_db above). None of them is the dynamic statement this
|
|
2306
|
+
# pin covers. No SQL, table selection, predicate, ordering, selected column,
|
|
2307
|
+
# execution condition or effect of this site changed, so the contract and
|
|
2308
|
+
# its inert rule stand.
|
|
2309
|
+
# Reviewed re-pin (#943 F-I1-1, base 63d4363dc), for
|
|
2310
|
+
# _rebuild_stats_index_locked #1. Changed (`~ computed-by`): only
|
|
2311
|
+
# `_apply_op_weekly_credit_floor`, reached through `FOLD_APPLIERS`, which
|
|
2312
|
+
# for a `forced` op now also UPDATEs the `weekly_credit_floors` row at the
|
|
2313
|
+
# same `(account_key, week_start_date, effective_at_utc)` slot to the
|
|
2314
|
+
# forced op's journal id, observed level and applied time (a same-second
|
|
2315
|
+
# `record-credit --force` takes the slot over instead of being IGNOREd).
|
|
2316
|
+
# The applier already wrote that table; the new statement is a literal
|
|
2317
|
+
# write the writer-surface freeze counts, not the dynamic statement this
|
|
2318
|
+
# pin covers. No SQL, table selection, predicate, ordering, selected
|
|
2319
|
+
# column, execution condition or effect of this site changed, so the
|
|
2320
|
+
# contract and its inert rule stand.
|
|
2321
|
+
# Reviewed re-pin (#980 D5, base 5b021b820), for
|
|
2322
|
+
# _rebuild_stats_index_locked #1. Changed (`~ computed-by`
|
|
2323
|
+
# `_maybe_truncate_wal`, `+ computed-by` `_cache_wal_truncate_due` and
|
|
2324
|
+
# `_cache_wal_trigger_bytes`): the cache.db WAL size gate moved out of
|
|
2325
|
+
# `_maybe_truncate_wal` into those two helpers so the budgeted Codex
|
|
2326
|
+
# sync can record the TRUNCATE as owed maintenance. The gate is the same
|
|
2327
|
+
# strict `-wal` size > `CACHE_WAL_CHECKPOINT_TRIGGER_BYTES` comparison
|
|
2328
|
+
# with the same test override, and the checkpoint is a literal cache.db
|
|
2329
|
+
# statement, not the dynamic statement this pin covers. No SQL, table
|
|
2330
|
+
# selection, predicate, ordering, selected column, execution condition
|
|
2331
|
+
# or effect of this site changed, so the contract and its inert rule
|
|
2332
|
+
# stand.
|
|
2333
|
+
# Reviewed re-pin (#1015 T3, base 16b055cae), for
|
|
2334
|
+
# _rebuild_stats_index_locked #1. Added: the bindings
|
|
2335
|
+
# `_cctally_oauth_samples.DECISION_OP_KINDS` (the two reviewed weekly
|
|
2336
|
+
# decision op kinds whose journal coordinates the read pass now records)
|
|
2337
|
+
# and `_cctally_oauth_samples._INSERT_HISTORY` (the literal history
|
|
2338
|
+
# insert). Changed: `STATS_INDEX_EPOCH` 1021 -> 1022; the fold applier
|
|
2339
|
+
# `apply_weekly_observation_decision_op` (`~ computed-by`), which beside
|
|
2340
|
+
# its unchanged decision upsert now writes one
|
|
2341
|
+
# `claude_weekly_correction_history` row per decided observation with its
|
|
2342
|
+
# decoded disposition (`retract` for a schema-3 retraction); the helpers
|
|
2343
|
+
# `open_db` (see the open_db re-pin) and `_apply_quota_projection_schema`
|
|
2344
|
+
# (the `fit_lineage` column and `meter_rate_change_supersessions`, see its
|
|
2345
|
+
# re-fingerprint); and the producer, whose read pass records decision op
|
|
2346
|
+
# coordinates, resolves staged cutover-attributed observations through
|
|
2347
|
+
# `attribute_staged_observations` after the cutover is known, writes the
|
|
2348
|
+
# completed batches' lineage in transaction A and records each decision
|
|
2349
|
+
# op's coordinate after the op folds, and whose inventories list the new
|
|
2350
|
+
# tables. Every new statement is a literal write registered as its own
|
|
2351
|
+
# contract. This site's `SELECT COUNT(*) FROM {tbl}` over the unchanged
|
|
2352
|
+
# `_REBUILD_COUNT_TABLES`, its execution condition and its read-only
|
|
2353
|
+
# effect are unchanged, so the contract and its MAINT inert rule stand.
|
|
2354
|
+
# Reviewed re-pin (#939 D5, base 81bbcde43), for
|
|
2355
|
+
# _rebuild_stats_index_locked #1. Changed (`~ computed-by`
|
|
2356
|
+
# `_cctally_cache.IngestStats`): the dataclass gains one field,
|
|
2357
|
+
# `failed_paths: set` (default empty), the paths behind `files_failed`
|
|
2358
|
+
# that a conversation sync records through `_record_failed_files` and
|
|
2359
|
+
# only the dashboard's writeIo admission hold compares between passes;
|
|
2360
|
+
# the transcript rebuild worker does not serialize it
|
|
2361
|
+
# (`_CONVERSATION_RESIDUAL_FIELDS`). It is Python state, never SQL: this
|
|
2362
|
+
# site's `SELECT COUNT(*) FROM {tbl}` over the unchanged
|
|
2363
|
+
# `_REBUILD_COUNT_TABLES`, its table selection, predicate, ordering,
|
|
2364
|
+
# selected column, parameters, execution condition and read-only effect
|
|
2365
|
+
# are unchanged, so the contract and its MAINT inert rule stand.
|
|
2366
|
+
# Reviewed re-pin (#948 merge of #939 part A, base f840dd69d), for
|
|
2367
|
+
# _rebuild_stats_index_locked #1: the shape combines the #939 change
|
|
2368
|
+
# above (`IngestStats.failed_paths`) with the #948 T-A change recorded at
|
|
2369
|
+
# _publish_generation_in_place #1 (`STATS_INDEX_EPOCH` 1022 -> 1023 and
|
|
2370
|
+
# the `open_db` schema block). Neither touches this site's SQL, table
|
|
2371
|
+
# selection, predicate, ordering, selected column, execution condition or
|
|
2372
|
+
# effect, so the contract and its MAINT inert rule stand.
|
|
2373
|
+
# Reviewed re-pin (#1020, base a781dec99), for
|
|
2374
|
+
# _rebuild_stats_index_locked #1. The closure reaches the owner-record
|
|
2375
|
+
# liveness helper `_cctally_db._repair_marker_is_live` through the W9
|
|
2376
|
+
# keeper fence (`_lib_wal_checkpoint._fence_at`). Changed
|
|
2377
|
+
# (`~ computed-by` `_repair_marker_is_live`, `- computed-by`
|
|
2378
|
+
# `_read_repair_owner`, `+ computed-by` `_read_repair_owner_record`,
|
|
2379
|
+
# `_read_owner_record_text`, `_owner_record_file`,
|
|
2380
|
+
# `_decode_repair_owner`, `+ binding` `_OWNER_RECORD_FILE_NAME`,
|
|
2381
|
+
# `_OWNER_RECORD_READ_ATTEMPTS`): the record reader now resolves
|
|
2382
|
+
# `<marker>/owner` for a directory-form record (a volume without hard
|
|
2383
|
+
# links) with a bounded re-read, the old decoding moved unchanged into
|
|
2384
|
+
# `_decode_repair_owner`, and the identity-unavailable lease is taken
|
|
2385
|
+
# from the record file actually read. A file-form record reads and
|
|
2386
|
+
# judges exactly as before. It is file-system Python state, never SQL:
|
|
2387
|
+
# this site's `SELECT COUNT(*) FROM {tbl}` over the unchanged
|
|
2388
|
+
# `_REBUILD_COUNT_TABLES`, its table selection, predicate, ordering,
|
|
2389
|
+
# selected column, parameters, execution condition and read-only effect
|
|
2390
|
+
# are unchanged, so the contract and its MAINT inert rule stand.
|
|
1796
2391
|
AccessContract(
|
|
1797
2392
|
function='_cctally_journal:_rebuild_stats_index_locked',
|
|
1798
2393
|
sql_fingerprint='dynamic:_cctally_journal:_rebuild_stats_index_locked#1',
|
|
1799
|
-
sql_shape='sha256:
|
|
2394
|
+
sql_shape='sha256:d9d1dae4e1f35d58',
|
|
1800
2395
|
table='dynamic',
|
|
1801
2396
|
keys=(),
|
|
1802
2397
|
predicate='dynamic SQL',
|
|
@@ -1915,13 +2510,21 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
1915
2510
|
classes=('period-keyed',),
|
|
1916
2511
|
inert_rule=JOURNAL,
|
|
1917
2512
|
),
|
|
2513
|
+
# #943 T3 (spec 4.7): the post-credit floor is now bound from
|
|
2514
|
+
# `resolve_five_hour_axis_floor` (the exact companion boundary, else the
|
|
2515
|
+
# floored slot) instead of an inline COALESCE over the latest
|
|
2516
|
+
# `five_hour_reset_events` row, so the subquery and its ordering left
|
|
2517
|
+
# the statement. Same table, keys, `>=` band direction and read effect;
|
|
2518
|
+
# the older-policy fold branch now issues this identical statement and
|
|
2519
|
+
# is covered by the `_usage_snapshot_fold_decision` contract of the
|
|
2520
|
+
# same text.
|
|
1918
2521
|
AccessContract(
|
|
1919
2522
|
function='_cctally_journal:_rematerialize_five_hour_high_water',
|
|
1920
|
-
sql_fingerprint=
|
|
2523
|
+
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(?)',
|
|
1921
2524
|
table='weekly_usage_snapshots',
|
|
1922
2525
|
keys=('five_hour_window_key', 'account_key'),
|
|
1923
|
-
predicate='five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(
|
|
1924
|
-
ordering='
|
|
2526
|
+
predicate='five_hour_window_key = ? AND account_key = ? AND unixepoch(captured_at_utc) >= unixepoch(?)',
|
|
2527
|
+
ordering='',
|
|
1925
2528
|
selected=('MAX(five_hour_percent)',),
|
|
1926
2529
|
effects='read',
|
|
1927
2530
|
classes=('period-keyed', 'range-keyed'),
|
|
@@ -2100,18 +2703,6 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
2100
2703
|
classes=('period-keyed',),
|
|
2101
2704
|
inert_rule=JOURNAL,
|
|
2102
2705
|
),
|
|
2103
|
-
AccessContract(
|
|
2104
|
-
function='_cctally_journal:_usage_snapshot_fold_decision',
|
|
2105
|
-
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'))",
|
|
2106
|
-
table='weekly_usage_snapshots',
|
|
2107
|
-
keys=('five_hour_window_key', 'account_key'),
|
|
2108
|
-
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 = ?',
|
|
2109
|
-
ordering='id DESC',
|
|
2110
|
-
selected=('MAX(five_hour_percent)',),
|
|
2111
|
-
effects='read',
|
|
2112
|
-
classes=('period-keyed', 'range-keyed'),
|
|
2113
|
-
inert_rule=JOURNAL,
|
|
2114
|
-
),
|
|
2115
2706
|
AccessContract(
|
|
2116
2707
|
function='_cctally_journal:_usage_snapshot_fold_decision',
|
|
2117
2708
|
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(?)',
|
|
@@ -2376,10 +2967,28 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
2376
2967
|
classes=('singleton',),
|
|
2377
2968
|
inert_rule=JOURNAL,
|
|
2378
2969
|
),
|
|
2970
|
+
# Reviewed re-pin (#956 T4, base 6528383a7), for emit_model_a #1. Changed:
|
|
2971
|
+
# the producer `emit_model_a` itself and one binding it now reads,
|
|
2972
|
+
# `_FIVE_HOUR_DIRTYING_KINDS`. The function gained two calls to
|
|
2973
|
+
# `five_hour_windows_touched_by_evt` (an exact `journal_id` read,
|
|
2974
|
+
# registered as its own JOURNAL contract) and one in-memory update of
|
|
2975
|
+
# `ctx.five_hour_dirty_windows`; the dynamic `SELECT id FROM {table} WHERE
|
|
2976
|
+
# journal_id = ?` this pin covers is unchanged: same table selection,
|
|
2977
|
+
# key, predicate, selected column, execution condition and effect, so
|
|
2978
|
+
# the contract and its inert rule stand.
|
|
2979
|
+
# Reviewed re-pin (#956 T5, base af10118c7), for emit_model_a #1. Changed:
|
|
2980
|
+
# only the binding `_FIVE_HOUR_DIRTYING_KINDS`, which gains
|
|
2981
|
+
# `five_hour_block_open`, so an applied opening marks its own window and its
|
|
2982
|
+
# account's open blocks dirty (the in-memory dirty set;
|
|
2983
|
+
# `five_hour_windows_touched_by_evt`'s new account-scoped read is registered
|
|
2984
|
+
# as its own BLOCKS contract). The dynamic `SELECT id FROM {table} WHERE
|
|
2985
|
+
# journal_id = ?` this pin covers is unchanged. No SQL, table selection,
|
|
2986
|
+
# predicate, ordering, selected column, execution condition or effect of
|
|
2987
|
+
# this site changed, so the contract and its inert rule stand.
|
|
2379
2988
|
AccessContract(
|
|
2380
2989
|
function='_cctally_journal:emit_model_a',
|
|
2381
2990
|
sql_fingerprint='dynamic:_cctally_journal:emit_model_a#1',
|
|
2382
|
-
sql_shape='sha256:
|
|
2991
|
+
sql_shape='sha256:5babe769cb993e34',
|
|
2383
2992
|
table='dynamic',
|
|
2384
2993
|
keys=(),
|
|
2385
2994
|
predicate='dynamic SQL',
|
|
@@ -2401,10 +3010,23 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
2401
3010
|
classes=('period-keyed',),
|
|
2402
3011
|
inert_rule=JOURNAL,
|
|
2403
3012
|
),
|
|
3013
|
+
# Reviewed re-pin (#943 T3, base c5419d209), for
|
|
3014
|
+
# latch_crossing_was_retired #1. Changed: only bindings this site reads —
|
|
3015
|
+
# `_HARVEST_SPECS`, which gains the `five_hour_credit_boundary` spec
|
|
3016
|
+
# (table `five_hour_credit_boundaries`, prefix `fhcb`, order 29). No SQL,
|
|
3017
|
+
# table selection, predicate, ordering, selected column, execution
|
|
3018
|
+
# condition or effect of this site changed, so the contract and its inert
|
|
3019
|
+
# rule stand.
|
|
3020
|
+
# Reviewed re-pin (#956 T5, base af10118c7), for latch_crossing_was_retired
|
|
3021
|
+
# #1. Changed: only the `_HARVEST_SPECS` binding, which gains the
|
|
3022
|
+
# `five_hour_block_open` spec (prefix `fhbo`); the site looks up the latch's
|
|
3023
|
+
# own family spec, which is unchanged. No SQL, table selection, predicate,
|
|
3024
|
+
# ordering, selected column, execution condition or effect of this site
|
|
3025
|
+
# changed, so the contract and its inert rule stand.
|
|
2404
3026
|
AccessContract(
|
|
2405
3027
|
function='_cctally_journal:latch_crossing_was_retired',
|
|
2406
3028
|
sql_fingerprint='dynamic:_cctally_journal:latch_crossing_was_retired#1',
|
|
2407
|
-
sql_shape='sha256:
|
|
3029
|
+
sql_shape='sha256:36fef39af242870b',
|
|
2408
3030
|
table='dynamic',
|
|
2409
3031
|
keys=(),
|
|
2410
3032
|
predicate='dynamic SQL',
|
|
@@ -2438,6 +3060,20 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
2438
3060
|
classes=('cross-period',),
|
|
2439
3061
|
inert_rule=JOURNAL,
|
|
2440
3062
|
),
|
|
3063
|
+
# #1015 T7: the supersession emitter's presence check returns early
|
|
3064
|
+
# when the explicit row for this natural key already exists.
|
|
3065
|
+
AccessContract(
|
|
3066
|
+
function='_cctally_journal:record_meter_rate_change_supersession',
|
|
3067
|
+
sql_fingerprint='SELECT 1 FROM meter_rate_change_supersessions WHERE provider = ? AND account_key = ? AND effective_from = ?',
|
|
3068
|
+
table='meter_rate_change_supersessions',
|
|
3069
|
+
keys=('provider', 'account_key', 'effective_from'),
|
|
3070
|
+
predicate='provider = ? AND account_key = ? AND effective_from = ?',
|
|
3071
|
+
ordering='',
|
|
3072
|
+
selected=('1',),
|
|
3073
|
+
effects='read',
|
|
3074
|
+
classes=('singleton',),
|
|
3075
|
+
inert_rule=LINEAGE,
|
|
3076
|
+
),
|
|
2441
3077
|
AccessContract(
|
|
2442
3078
|
function='_cctally_journal:stats_index_matches_journal_prefix',
|
|
2443
3079
|
sql_fingerprint='SELECT event_id, rev, status, content_hash, batch_id, event_json FROM journal_effective_events ORDER BY event_id',
|
|
@@ -2468,10 +3104,54 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
2468
3104
|
# (the streamed accumulator, D12). The hasher executes no SQL; the SQL
|
|
2469
3105
|
# text, its execution condition and its read-only effect are unchanged,
|
|
2470
3106
|
# so the contract and its MAINT inert rule stand.
|
|
3107
|
+
# Reviewed re-pin (#1019/#1014 Task A, base 5b15db929), for #1 and #2.
|
|
3108
|
+
# Changed: `STATS_INDEX_EPOCH`, `PROTOCOL_RESOLUTION_KINDS` (+v4),
|
|
3109
|
+
# `_validate_protocol_resolution` accepting `wpx` in its key set and
|
|
3110
|
+
# identity core, `strip_stamp` stripping `wpx` (new `_WPX`,
|
|
3111
|
+
# SUCCESSOR_REVISION_KEY and _STAMP_KEYS bindings) and the path
|
|
3112
|
+
# assignments. The prefix-match reads, their tables, predicates and
|
|
3113
|
+
# read-only effect are unchanged, so the contracts stand.
|
|
3114
|
+
# Reviewed re-pin (#943 T3, base c5419d209), for
|
|
3115
|
+
# stats_index_matches_journal_prefix #1. Changed: only bindings this site
|
|
3116
|
+
# reads — `STATS_INDEX_EPOCH` 1020 -> 1021 (spec 4.7). No SQL, table
|
|
3117
|
+
# selection, predicate, ordering, selected column, execution condition or
|
|
3118
|
+
# effect of this site changed, so the contract and its inert rule stand.
|
|
3119
|
+
# Reviewed re-pin (#956 T5, base af10118c7), for
|
|
3120
|
+
# stats_index_matches_journal_prefix #1. Changed: only the `_EVT_SPECS`
|
|
3121
|
+
# binding, whose new `five_hour_block_open` spec carries the applier
|
|
3122
|
+
# `_apply_five_hour_block_open`; the closure follows it into
|
|
3123
|
+
# `_apply_generic_evt` and its helpers (`_insert_or_ignore`,
|
|
3124
|
+
# `_resolve_fold_ref`, `_resolve_ref`, `_derived_fk_value`,
|
|
3125
|
+
# `_report_unresolved_fold_reference`, `_SUPPRESSIBLE_FOLD_REFS`,
|
|
3126
|
+
# `JournalError`, `UnresolvedFoldReference`), `_block_opening_row` and
|
|
3127
|
+
# `_materialize_opened_block`. The site reads the family tables the specs
|
|
3128
|
+
# name, and the new family's table is read by the same statement shape as
|
|
3129
|
+
# every other. No SQL, table selection, predicate, ordering, selected
|
|
3130
|
+
# column, execution condition or effect of this site changed, so the
|
|
3131
|
+
# contract and its inert rule stand.
|
|
3132
|
+
# Reviewed re-pin (#1015 T3, base 16b055cae), for stats_index_matches_journal_prefix #1. Changed: only
|
|
3133
|
+
# the binding `STATS_INDEX_EPOCH` 1021 -> 1022 (spec 5.1). No SQL, table
|
|
3134
|
+
# selection, predicate, ordering, selected column, execution condition or
|
|
3135
|
+
# effect of this site changed, so the contract and its inert rule stand.
|
|
3136
|
+
# Reviewed re-pin (#1015 T7, base 7455ca434), for stats_index_matches_journal_prefix #1. Changed: only the
|
|
3137
|
+
# fold machinery this site reaches through bindings: `_EVT_SPECS` gained
|
|
3138
|
+
# the table-less `meter_rate_change_supersession` spec (order 46), whose
|
|
3139
|
+
# applier `_apply_meter_rate_change_supersession` calls
|
|
3140
|
+
# `_insert_meter_rate_change_supersession` (a literal INSERT OR IGNORE,
|
|
3141
|
+
# registered as its own contract) and reads `MRC_SUPERSESSION_REASON`
|
|
3142
|
+
# and `_canonical_json_or_none`; `_MeterRateChangeRow` gained the
|
|
3143
|
+
# nullable `fit_lineage` field, which `_meter_rate_change_row` fills
|
|
3144
|
+
# through `_canonical_json_or_none` and
|
|
3145
|
+
# `_backfill_meter_rate_change_evidence` COALESCEs (its literal UPDATE is
|
|
3146
|
+
# reviewed beside its own contract). The site skips a table-less spec
|
|
3147
|
+
# (`spec.table is None`) and reads the family tables the other specs
|
|
3148
|
+
# name with the same statement shape. No SQL, table selection,
|
|
3149
|
+
# predicate, ordering, selected column, execution condition or effect of
|
|
3150
|
+
# this site changed, so the contract and its inert rule stand.
|
|
2471
3151
|
AccessContract(
|
|
2472
3152
|
function='_cctally_journal:stats_index_matches_journal_prefix',
|
|
2473
3153
|
sql_fingerprint='dynamic:_cctally_journal:stats_index_matches_journal_prefix#1',
|
|
2474
|
-
sql_shape='sha256:
|
|
3154
|
+
sql_shape='sha256:b27ac2227f9613cb',
|
|
2475
3155
|
table='dynamic',
|
|
2476
3156
|
keys=(),
|
|
2477
3157
|
predicate='dynamic SQL',
|
|
@@ -2482,10 +3162,38 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
2482
3162
|
inert_rule=MAINT,
|
|
2483
3163
|
),
|
|
2484
3164
|
# Same reviewed re-pin as #1 (#997 D12).
|
|
3165
|
+
# Reviewed re-pin (#956 T5, base af10118c7), for
|
|
3166
|
+
# stats_index_matches_journal_prefix #2. Changed: only the `_EVT_SPECS`
|
|
3167
|
+
# binding, whose new `five_hour_block_open` spec carries the applier
|
|
3168
|
+
# `_apply_five_hour_block_open`; the closure follows it into
|
|
3169
|
+
# `_apply_generic_evt` and its helpers (`_insert_or_ignore`,
|
|
3170
|
+
# `_resolve_fold_ref`, `_resolve_ref`, `_derived_fk_value`,
|
|
3171
|
+
# `_report_unresolved_fold_reference`, `_SUPPRESSIBLE_FOLD_REFS`,
|
|
3172
|
+
# `JournalError`, `UnresolvedFoldReference`), `_block_opening_row` and
|
|
3173
|
+
# `_materialize_opened_block`. The site reads the family tables the specs
|
|
3174
|
+
# name, and the new family's table is read by the same statement shape as
|
|
3175
|
+
# every other. No SQL, table selection, predicate, ordering, selected
|
|
3176
|
+
# column, execution condition or effect of this site changed, so the
|
|
3177
|
+
# contract and its inert rule stand.
|
|
3178
|
+
# Reviewed re-pin (#1015 T7, base 7455ca434), for stats_index_matches_journal_prefix #2. Changed: only the
|
|
3179
|
+
# fold machinery this site reaches through bindings: `_EVT_SPECS` gained
|
|
3180
|
+
# the table-less `meter_rate_change_supersession` spec (order 46), whose
|
|
3181
|
+
# applier `_apply_meter_rate_change_supersession` calls
|
|
3182
|
+
# `_insert_meter_rate_change_supersession` (a literal INSERT OR IGNORE,
|
|
3183
|
+
# registered as its own contract) and reads `MRC_SUPERSESSION_REASON`
|
|
3184
|
+
# and `_canonical_json_or_none`; `_MeterRateChangeRow` gained the
|
|
3185
|
+
# nullable `fit_lineage` field, which `_meter_rate_change_row` fills
|
|
3186
|
+
# through `_canonical_json_or_none` and
|
|
3187
|
+
# `_backfill_meter_rate_change_evidence` COALESCEs (its literal UPDATE is
|
|
3188
|
+
# reviewed beside its own contract). The site skips a table-less spec
|
|
3189
|
+
# (`spec.table is None`) and reads the family tables the other specs
|
|
3190
|
+
# name with the same statement shape. No SQL, table selection,
|
|
3191
|
+
# predicate, ordering, selected column, execution condition or effect of
|
|
3192
|
+
# this site changed, so the contract and its inert rule stand.
|
|
2485
3193
|
AccessContract(
|
|
2486
3194
|
function='_cctally_journal:stats_index_matches_journal_prefix',
|
|
2487
3195
|
sql_fingerprint='dynamic:_cctally_journal:stats_index_matches_journal_prefix#2',
|
|
2488
|
-
sql_shape='sha256:
|
|
3196
|
+
sql_shape='sha256:0cb254b5c3b1d634',
|
|
2489
3197
|
table='dynamic',
|
|
2490
3198
|
keys=(),
|
|
2491
3199
|
predicate='dynamic SQL',
|
|
@@ -2603,6 +3311,90 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
2603
3311
|
classes=('singleton',),
|
|
2604
3312
|
inert_rule=Q7,
|
|
2605
3313
|
),
|
|
3314
|
+
# #1015 epoch 1022 (spec 5.1): the correction-to-fit lineage writers.
|
|
3315
|
+
# `project_observation` indexes each admitted Claude weekly observation
|
|
3316
|
+
# by its attributed account on live ingest (reached from
|
|
3317
|
+
# `_pipeline_claude_usage` through `project_record`); the apply-only
|
|
3318
|
+
# rebuild stages a cutover-attributed observation and
|
|
3319
|
+
# `attribute_staged_observations` resolves it once the cutover is known.
|
|
3320
|
+
# `record_correction_op` records a reviewed decision op's journal
|
|
3321
|
+
# coordinate. `write_batch_lineage` records each completed correction
|
|
3322
|
+
# batch's commit coordinate (an authoritative upsert from the selector's
|
|
3323
|
+
# completion step, else INSERT OR IGNORE) and its footprint. All are
|
|
3324
|
+
# keyed writes that a replay repeats to the same rows, and no detector
|
|
3325
|
+
# decision reads them.
|
|
3326
|
+
AccessContract(
|
|
3327
|
+
function='_cctally_journal:write_batch_lineage',
|
|
3328
|
+
sql_fingerprint='INSERT INTO correction_batch_lineage (batch_id, commit_segment, commit_offset) VALUES (?, ?, ?) ON CONFLICT(batch_id) DO UPDATE SET commit_segment = excluded.commit_segment, commit_offset = excluded.commit_offset',
|
|
3329
|
+
table='correction_batch_lineage',
|
|
3330
|
+
keys=('batch_id',),
|
|
3331
|
+
predicate='',
|
|
3332
|
+
ordering='',
|
|
3333
|
+
selected=(),
|
|
3334
|
+
effects='upsert',
|
|
3335
|
+
classes=('singleton',),
|
|
3336
|
+
inert_rule=LINEAGE,
|
|
3337
|
+
),
|
|
3338
|
+
AccessContract(
|
|
3339
|
+
function='_cctally_journal:write_batch_lineage',
|
|
3340
|
+
sql_fingerprint='INSERT OR IGNORE INTO correction_batch_footprint (batch_id, provider, account_key) VALUES (?, ?, ?)',
|
|
3341
|
+
table='correction_batch_footprint',
|
|
3342
|
+
keys=('batch_id', 'provider', 'account_key'),
|
|
3343
|
+
predicate='',
|
|
3344
|
+
ordering='',
|
|
3345
|
+
selected=(),
|
|
3346
|
+
effects='write',
|
|
3347
|
+
classes=('singleton',),
|
|
3348
|
+
inert_rule=LINEAGE,
|
|
3349
|
+
),
|
|
3350
|
+
AccessContract(
|
|
3351
|
+
function='_cctally_journal:write_batch_lineage',
|
|
3352
|
+
sql_fingerprint='INSERT OR IGNORE INTO correction_batch_lineage (batch_id, commit_segment, commit_offset) VALUES (?, ?, ?)',
|
|
3353
|
+
table='correction_batch_lineage',
|
|
3354
|
+
keys=('batch_id',),
|
|
3355
|
+
predicate='',
|
|
3356
|
+
ordering='',
|
|
3357
|
+
selected=(),
|
|
3358
|
+
effects='write',
|
|
3359
|
+
classes=('singleton',),
|
|
3360
|
+
inert_rule=LINEAGE,
|
|
3361
|
+
),
|
|
3362
|
+
AccessContract(
|
|
3363
|
+
function='_cctally_oauth_samples:attribute_staged_observations',
|
|
3364
|
+
sql_fingerprint='INSERT OR IGNORE INTO claude_weekly_observation_index (observation_id, account_key, captured_at_utc) SELECT observation_id, ?, captured_at_utc FROM rebuild_weekly_observation_unstamped',
|
|
3365
|
+
table='claude_weekly_observation_index',
|
|
3366
|
+
keys=('observation_id',),
|
|
3367
|
+
predicate='',
|
|
3368
|
+
ordering='',
|
|
3369
|
+
selected=(),
|
|
3370
|
+
effects='write',
|
|
3371
|
+
classes=('singleton',),
|
|
3372
|
+
inert_rule=LINEAGE,
|
|
3373
|
+
),
|
|
3374
|
+
AccessContract(
|
|
3375
|
+
function='_cctally_oauth_samples:project_observation',
|
|
3376
|
+
sql_fingerprint='INSERT OR IGNORE INTO claude_weekly_observation_index (observation_id, account_key, captured_at_utc) VALUES (?, ?, ?)',
|
|
3377
|
+
table='claude_weekly_observation_index',
|
|
3378
|
+
keys=('observation_id',),
|
|
3379
|
+
predicate='',
|
|
3380
|
+
ordering='',
|
|
3381
|
+
selected=(),
|
|
3382
|
+
effects='write',
|
|
3383
|
+
classes=('singleton',),
|
|
3384
|
+
inert_rule=LINEAGE,
|
|
3385
|
+
),
|
|
3386
|
+
AccessContract(
|
|
3387
|
+
function='_cctally_oauth_samples:record_correction_op',
|
|
3388
|
+
sql_fingerprint='INSERT OR IGNORE INTO claude_weekly_correction_ops (decision_op_id, op_segment, op_offset) VALUES (?, ?, ?)',
|
|
3389
|
+
table='claude_weekly_correction_ops',
|
|
3390
|
+
keys=('decision_op_id',),
|
|
3391
|
+
predicate='',
|
|
3392
|
+
ordering='',
|
|
3393
|
+
selected=(),
|
|
3394
|
+
effects='write',
|
|
3395
|
+
classes=('singleton',),
|
|
3396
|
+
inert_rule=LINEAGE,
|
|
3397
|
+
),
|
|
2606
3398
|
# #797/#823/#840 epoch 1019 (spec 4.3 D8): the provider-sample
|
|
2607
3399
|
# projection, reached from `_pipeline_claude_usage` through
|
|
2608
3400
|
# `project_record`. One row per admitted keyed api observation, keyed by
|
|
@@ -2623,48 +3415,48 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
2623
3415
|
),
|
|
2624
3416
|
AccessContract(
|
|
2625
3417
|
function='_cctally_quarantine:load_state',
|
|
2626
|
-
sql_fingerprint='SELECT
|
|
2627
|
-
table='
|
|
2628
|
-
keys=(),
|
|
2629
|
-
predicate='',
|
|
3418
|
+
sql_fingerprint='SELECT account_key, axis, state, waiting_for, coverage_id, witness_id, release_id, revocation, since, recovered_at, not_before, witness_key FROM outcome_quarantine_axis_state WHERE generation = ?',
|
|
3419
|
+
table='outcome_quarantine_axis_state',
|
|
3420
|
+
keys=('generation',),
|
|
3421
|
+
predicate='generation = ?',
|
|
2630
3422
|
ordering='',
|
|
2631
|
-
selected=('
|
|
3423
|
+
selected=('account_key', 'axis', 'state', 'waiting_for', 'coverage_id', 'witness_id', 'release_id', 'revocation', 'since', 'recovered_at', 'not_before', 'witness_key'),
|
|
2632
3424
|
effects='read',
|
|
2633
3425
|
classes=('cross-period',),
|
|
2634
3426
|
inert_rule=QUARANTINE,
|
|
2635
3427
|
),
|
|
2636
3428
|
AccessContract(
|
|
2637
3429
|
function='_cctally_quarantine:load_state',
|
|
2638
|
-
sql_fingerprint='SELECT
|
|
2639
|
-
table='
|
|
3430
|
+
sql_fingerprint='SELECT opener_segment, opener_offset, opened_at, closer_segment, closer_offset, closed_at FROM outcome_quarantine_episodes ORDER BY rowid',
|
|
3431
|
+
table='outcome_quarantine_episodes',
|
|
2640
3432
|
keys=(),
|
|
2641
3433
|
predicate='',
|
|
2642
|
-
ordering='',
|
|
2643
|
-
selected=('
|
|
3434
|
+
ordering='rowid',
|
|
3435
|
+
selected=('opener_segment', 'opener_offset', 'opened_at', 'closer_segment', 'closer_offset', 'closed_at'),
|
|
2644
3436
|
effects='read',
|
|
2645
3437
|
classes=('cross-period',),
|
|
2646
3438
|
inert_rule=QUARANTINE,
|
|
2647
3439
|
),
|
|
2648
3440
|
AccessContract(
|
|
2649
3441
|
function='_cctally_quarantine:load_state',
|
|
2650
|
-
sql_fingerprint='SELECT scope,
|
|
2651
|
-
table='
|
|
3442
|
+
sql_fingerprint='SELECT scope, axis, bounds_json FROM outcome_quarantine_bounds',
|
|
3443
|
+
table='outcome_quarantine_bounds',
|
|
2652
3444
|
keys=(),
|
|
2653
3445
|
predicate='',
|
|
2654
3446
|
ordering='',
|
|
2655
|
-
selected=('scope', '
|
|
3447
|
+
selected=('scope', 'axis', 'bounds_json'),
|
|
2656
3448
|
effects='read',
|
|
2657
3449
|
classes=('cross-period',),
|
|
2658
3450
|
inert_rule=QUARANTINE,
|
|
2659
3451
|
),
|
|
2660
3452
|
AccessContract(
|
|
2661
3453
|
function='_cctally_quarantine:load_state',
|
|
2662
|
-
sql_fingerprint='SELECT seq, segment, byte_offset, reason, at FROM outcome_quarantine_triggers
|
|
3454
|
+
sql_fingerprint='SELECT seq, segment, byte_offset, kind, reason, at FROM outcome_quarantine_triggers ORDER BY seq DESC LIMIT 1',
|
|
2663
3455
|
table='outcome_quarantine_triggers',
|
|
2664
|
-
keys=(
|
|
2665
|
-
predicate='
|
|
2666
|
-
ordering='seq',
|
|
2667
|
-
selected=('seq', 'segment', 'byte_offset', 'reason', 'at'),
|
|
3456
|
+
keys=(),
|
|
3457
|
+
predicate='',
|
|
3458
|
+
ordering='seq DESC',
|
|
3459
|
+
selected=('seq', 'segment', 'byte_offset', 'kind', 'reason', 'at'),
|
|
2668
3460
|
effects='read',
|
|
2669
3461
|
classes=('cross-period',),
|
|
2670
3462
|
inert_rule=QUARANTINE,
|
|
@@ -3075,48 +3867,155 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
3075
3867
|
classes=('cross-period',),
|
|
3076
3868
|
inert_rule=CODEX,
|
|
3077
3869
|
),
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3870
|
+
# #1015 T5/T7 and R6: the calibration lineage readers. `_read_base`
|
|
3871
|
+
# reads the always-needed half of the correction facts (completed
|
|
3872
|
+
# batches, their footprint, each reviewed op's coordinate, the distinct
|
|
3873
|
+
# ops the history names by a loose primary-key scan, and a probe that the
|
|
3874
|
+
# observation index exists); `_read_rows` reads one op's history rows
|
|
3875
|
+
# joined to their observation, narrowed to what the assessed lineages
|
|
3876
|
+
# can be affected by; `rate_change_supersession` reads one transition's
|
|
3877
|
+
# explicit supersession and its stored lineage by natural key. They feed
|
|
3878
|
+
# the forecast, project, doctor, status-line and quota refusal and the
|
|
3879
|
+
# rate-change marker/notification suppression; no automatic credit,
|
|
3880
|
+
# moved-end or drop-consensus decision reads them.
|
|
3881
|
+
AccessContract(
|
|
3882
|
+
function='_cctally_quota_calibration:_read_base',
|
|
3883
|
+
sql_fingerprint='SELECT batch_id, commit_segment, commit_offset FROM correction_batch_lineage',
|
|
3884
|
+
table='correction_batch_lineage',
|
|
3082
3885
|
keys=(),
|
|
3083
3886
|
predicate='',
|
|
3084
3887
|
ordering='',
|
|
3085
|
-
selected=(),
|
|
3086
|
-
effects='
|
|
3087
|
-
classes=('
|
|
3088
|
-
inert_rule=
|
|
3888
|
+
selected=('batch_id', 'commit_segment', 'commit_offset'),
|
|
3889
|
+
effects='read',
|
|
3890
|
+
classes=('cross-period',),
|
|
3891
|
+
inert_rule=LINEAGE,
|
|
3089
3892
|
),
|
|
3090
3893
|
AccessContract(
|
|
3091
|
-
function='
|
|
3092
|
-
sql_fingerprint='SELECT
|
|
3093
|
-
table='
|
|
3094
|
-
keys=(
|
|
3095
|
-
predicate='
|
|
3894
|
+
function='_cctally_quota_calibration:_read_base',
|
|
3895
|
+
sql_fingerprint='SELECT batch_id, provider, account_key FROM correction_batch_footprint',
|
|
3896
|
+
table='correction_batch_footprint',
|
|
3897
|
+
keys=(),
|
|
3898
|
+
predicate='',
|
|
3096
3899
|
ordering='',
|
|
3097
|
-
selected=('
|
|
3900
|
+
selected=('batch_id', 'provider', 'account_key'),
|
|
3098
3901
|
effects='read',
|
|
3099
|
-
classes=('period
|
|
3100
|
-
inert_rule=
|
|
3902
|
+
classes=('cross-period',),
|
|
3903
|
+
inert_rule=LINEAGE,
|
|
3101
3904
|
),
|
|
3102
3905
|
AccessContract(
|
|
3103
|
-
function='
|
|
3104
|
-
sql_fingerprint=
|
|
3105
|
-
table='
|
|
3106
|
-
keys=(
|
|
3107
|
-
predicate=
|
|
3906
|
+
function='_cctally_quota_calibration:_read_base',
|
|
3907
|
+
sql_fingerprint='SELECT decision_op_id, op_segment, op_offset FROM claude_weekly_correction_ops',
|
|
3908
|
+
table='claude_weekly_correction_ops',
|
|
3909
|
+
keys=(),
|
|
3910
|
+
predicate='',
|
|
3108
3911
|
ordering='',
|
|
3109
|
-
selected=('
|
|
3912
|
+
selected=('decision_op_id', 'op_segment', 'op_offset'),
|
|
3110
3913
|
effects='read',
|
|
3111
|
-
classes=('period
|
|
3112
|
-
inert_rule=
|
|
3914
|
+
classes=('cross-period',),
|
|
3915
|
+
inert_rule=LINEAGE,
|
|
3113
3916
|
),
|
|
3114
3917
|
AccessContract(
|
|
3115
|
-
function='
|
|
3116
|
-
sql_fingerprint='
|
|
3117
|
-
table='
|
|
3918
|
+
function='_cctally_quota_calibration:_read_base',
|
|
3919
|
+
sql_fingerprint='SELECT observation_id, account_key, captured_at_utc FROM claude_weekly_observation_index LIMIT 0',
|
|
3920
|
+
table='claude_weekly_observation_index',
|
|
3118
3921
|
keys=(),
|
|
3119
|
-
predicate='',
|
|
3922
|
+
predicate='LIMIT 0',
|
|
3923
|
+
ordering='',
|
|
3924
|
+
selected=('observation_id', 'account_key', 'captured_at_utc'),
|
|
3925
|
+
effects='read',
|
|
3926
|
+
classes=('cross-period',),
|
|
3927
|
+
inert_rule=LINEAGE,
|
|
3928
|
+
),
|
|
3929
|
+
AccessContract(
|
|
3930
|
+
function='_cctally_quota_calibration:_read_base',
|
|
3931
|
+
sql_fingerprint='WITH RECURSIVE d(op) AS (SELECT MIN(decision_op_id) FROM claude_weekly_correction_history UNION ALL SELECT (SELECT MIN(decision_op_id) FROM claude_weekly_correction_history WHERE decision_op_id > d.op) FROM d WHERE d.op IS NOT NULL) SELECT op FROM d WHERE op IS NOT NULL',
|
|
3932
|
+
table='claude_weekly_correction_history',
|
|
3933
|
+
keys=('decision_op_id',),
|
|
3934
|
+
predicate='decision_op_id > d.op',
|
|
3935
|
+
ordering='',
|
|
3936
|
+
selected=('decision_op_id',),
|
|
3937
|
+
effects='read',
|
|
3938
|
+
classes=('cross-period',),
|
|
3939
|
+
inert_rule=LINEAGE,
|
|
3940
|
+
),
|
|
3941
|
+
AccessContract(
|
|
3942
|
+
function='_cctally_quota_calibration:_read_rows',
|
|
3943
|
+
sql_fingerprint="SELECT h.observation_id, h.disposition, i.account_key, i.captured_at_utc FROM claude_weekly_correction_history h LEFT JOIN claude_weekly_observation_index i ON i.observation_id = h.observation_id WHERE h.decision_op_id = :op AND (i.observation_id IS NULL OR ((:scope = '*' OR i.account_key = :scope) AND (:account IS NULL OR i.account_key = :account) AND (:lo IS NULL OR i.captured_at_utc >= :lo) AND (:hi IS NULL OR i.captured_at_utc < :hi)) OR ((:scope = '*' OR i.account_key = :scope) AND NOT (substr(i.captured_at_utc, 1, 19) GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]' AND (substr(i.captured_at_utc, 20) IN ('Z', '+00:00') OR substr(i.captured_at_utc, 20) GLOB '.[0-9][0-9][0-9][0-9][0-9][0-9]Z' OR substr(i.captured_at_utc, 20) GLOB '.[0-9][0-9][0-9][0-9][0-9][0-9]+00:00' OR substr(i.captured_at_utc, 20) GLOB '.[0-9][0-9][0-9]Z' OR substr(i.captured_at_utc, 20) GLOB '.[0-9][0-9][0-9]+00:00') AND substr(i.captured_at_utc, 1, 4) <> '0000' AND datetime(substr(i.captured_at_utc, 1, 19)) = replace(substr(i.captured_at_utc, 1, 19), 'T', ' '))))",
|
|
3944
|
+
table='claude_weekly_correction_history',
|
|
3945
|
+
keys=('decision_op_id',),
|
|
3946
|
+
predicate='h.decision_op_id = :op AND (unresolved, or not a canonical UTC capture, or inside the account scope and the capture box)',
|
|
3947
|
+
ordering='',
|
|
3948
|
+
selected=('observation_id', 'disposition', 'account_key', 'captured_at_utc'),
|
|
3949
|
+
effects='read',
|
|
3950
|
+
classes=('cross-period',),
|
|
3951
|
+
inert_rule=LINEAGE,
|
|
3952
|
+
),
|
|
3953
|
+
AccessContract(
|
|
3954
|
+
function='_cctally_quota_calibration:rate_change_supersession',
|
|
3955
|
+
sql_fingerprint='SELECT detected_at_utc, fit_lineage FROM meter_rate_change_events WHERE provider = ? AND account_key = ? AND effective_from = ?',
|
|
3956
|
+
table='meter_rate_change_events',
|
|
3957
|
+
keys=('provider', 'account_key', 'effective_from'),
|
|
3958
|
+
predicate='provider = ? AND account_key = ? AND effective_from = ?',
|
|
3959
|
+
ordering='',
|
|
3960
|
+
selected=('detected_at_utc', 'fit_lineage'),
|
|
3961
|
+
effects='read',
|
|
3962
|
+
classes=('singleton',),
|
|
3963
|
+
inert_rule=LINEAGE,
|
|
3964
|
+
),
|
|
3965
|
+
AccessContract(
|
|
3966
|
+
function='_cctally_quota_calibration:rate_change_supersession',
|
|
3967
|
+
sql_fingerprint='SELECT reason, corrections, superseded_at_utc FROM meter_rate_change_supersessions WHERE provider = ? AND account_key = ? AND effective_from = ?',
|
|
3968
|
+
table='meter_rate_change_supersessions',
|
|
3969
|
+
keys=('provider', 'account_key', 'effective_from'),
|
|
3970
|
+
predicate='provider = ? AND account_key = ? AND effective_from = ?',
|
|
3971
|
+
ordering='',
|
|
3972
|
+
selected=('reason', 'corrections', 'superseded_at_utc'),
|
|
3973
|
+
effects='read',
|
|
3974
|
+
classes=('singleton',),
|
|
3975
|
+
inert_rule=LINEAGE,
|
|
3976
|
+
),
|
|
3977
|
+
AccessContract(
|
|
3978
|
+
function='_cctally_record:_apply_credit',
|
|
3979
|
+
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 (?, ?, ?, ?, ?)',
|
|
3980
|
+
table='weekly_credit_floors',
|
|
3981
|
+
keys=(),
|
|
3982
|
+
predicate='',
|
|
3983
|
+
ordering='',
|
|
3984
|
+
selected=(),
|
|
3985
|
+
effects='write',
|
|
3986
|
+
classes=('singleton',),
|
|
3987
|
+
inert_rule=MANUAL,
|
|
3988
|
+
),
|
|
3989
|
+
AccessContract(
|
|
3990
|
+
function='_cctally_record:_apply_credit',
|
|
3991
|
+
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 != ?',
|
|
3992
|
+
table='weekly_credit_floors',
|
|
3993
|
+
keys=('week_start_date', 'account_key'),
|
|
3994
|
+
predicate='week_start_date = ? AND account_key = ? AND journal_id IS NOT NULL AND journal_id != ?',
|
|
3995
|
+
ordering='',
|
|
3996
|
+
selected=('journal_id',),
|
|
3997
|
+
effects='read',
|
|
3998
|
+
classes=('period-keyed',),
|
|
3999
|
+
inert_rule=MANUAL,
|
|
4000
|
+
),
|
|
4001
|
+
AccessContract(
|
|
4002
|
+
function='_cctally_record:_apply_credit',
|
|
4003
|
+
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:%'",
|
|
4004
|
+
table='weekly_usage_snapshots',
|
|
4005
|
+
keys=('week_start_date', 'account_key'),
|
|
4006
|
+
predicate="week_start_date = ? AND account_key = ? AND source = 'record-credit' AND journal_id IS NOT NULL AND journal_id NOT LIKE 'sa:' || ? || ':syn:%'",
|
|
4007
|
+
ordering='',
|
|
4008
|
+
selected=('journal_id',),
|
|
4009
|
+
effects='read',
|
|
4010
|
+
classes=('period-keyed',),
|
|
4011
|
+
inert_rule=MANUAL,
|
|
4012
|
+
),
|
|
4013
|
+
AccessContract(
|
|
4014
|
+
function='_cctally_record:_arm_reset_debounce_state',
|
|
4015
|
+
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',
|
|
4016
|
+
table='weekly_reset_debounce_state',
|
|
4017
|
+
keys=(),
|
|
4018
|
+
predicate='',
|
|
3120
4019
|
ordering='',
|
|
3121
4020
|
selected=(),
|
|
3122
4021
|
effects='upsert',
|
|
@@ -3261,12 +4160,12 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
3261
4160
|
),
|
|
3262
4161
|
AccessContract(
|
|
3263
4162
|
function='_cctally_record:_read_five_hour_source_state',
|
|
3264
|
-
sql_fingerprint='SELECT baseline_pct, pending_low_pct, pending_at_utc, pending_observation_id, baseline_observation_id, baseline_generation, pending_generation, pending_position FROM five_hour_credit_confirmation_state WHERE account_key = ? AND five_hour_window_key = ? AND source = ?',
|
|
4163
|
+
sql_fingerprint='SELECT baseline_pct, pending_low_pct, pending_at_utc, pending_observation_id, baseline_observation_id, baseline_generation, pending_generation, pending_position, pending_captured_at_utc FROM five_hour_credit_confirmation_state WHERE account_key = ? AND five_hour_window_key = ? AND source = ?',
|
|
3265
4164
|
table='five_hour_credit_confirmation_state',
|
|
3266
4165
|
keys=('account_key', 'five_hour_window_key', 'source'),
|
|
3267
4166
|
predicate='account_key = ? AND five_hour_window_key = ? AND source = ?',
|
|
3268
4167
|
ordering='',
|
|
3269
|
-
selected=('baseline_pct', 'pending_low_pct', 'pending_at_utc', 'pending_observation_id', 'baseline_observation_id', 'baseline_generation', 'pending_generation', 'pending_position'),
|
|
4168
|
+
selected=('baseline_pct', 'pending_low_pct', 'pending_at_utc', 'pending_observation_id', 'baseline_observation_id', 'baseline_generation', 'pending_generation', 'pending_position', 'pending_captured_at_utc'),
|
|
3270
4169
|
effects='read',
|
|
3271
4170
|
classes=('period-keyed',),
|
|
3272
4171
|
inert_rule=None,
|
|
@@ -3278,12 +4177,12 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
3278
4177
|
# order; the id only fetches it). All three read one account and window.
|
|
3279
4178
|
AccessContract(
|
|
3280
4179
|
function='_cctally_record:_rebase_five_hour_sources',
|
|
3281
|
-
sql_fingerprint='SELECT source, baseline_pct, pending_low_pct, pending_at_utc, pending_observation_id, baseline_observation_id, baseline_generation, pending_generation, pending_position FROM five_hour_credit_confirmation_state WHERE account_key = ? AND five_hour_window_key = ?',
|
|
4180
|
+
sql_fingerprint='SELECT source, baseline_pct, pending_low_pct, pending_at_utc, pending_observation_id, baseline_observation_id, baseline_generation, pending_generation, pending_position, pending_captured_at_utc FROM five_hour_credit_confirmation_state WHERE account_key = ? AND five_hour_window_key = ?',
|
|
3282
4181
|
table='five_hour_credit_confirmation_state',
|
|
3283
4182
|
keys=('account_key', 'five_hour_window_key'),
|
|
3284
4183
|
predicate='account_key = ? AND five_hour_window_key = ?',
|
|
3285
4184
|
ordering='',
|
|
3286
|
-
selected=('source', 'baseline_pct', 'pending_low_pct', 'pending_at_utc', 'pending_observation_id', 'baseline_observation_id', 'baseline_generation', 'pending_generation', 'pending_position'),
|
|
4185
|
+
selected=('source', 'baseline_pct', 'pending_low_pct', 'pending_at_utc', 'pending_observation_id', 'baseline_observation_id', 'baseline_generation', 'pending_generation', 'pending_position', 'pending_captured_at_utc'),
|
|
3287
4186
|
effects='read',
|
|
3288
4187
|
classes=('period-keyed',),
|
|
3289
4188
|
inert_rule=None,
|
|
@@ -3362,7 +4261,7 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
3362
4261
|
),
|
|
3363
4262
|
AccessContract(
|
|
3364
4263
|
function='_cctally_record:_write_five_hour_source_state',
|
|
3365
|
-
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, baseline_observation_id, baseline_generation, pending_generation, pending_position) 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, baseline_observation_id = excluded.baseline_observation_id, baseline_generation = excluded.baseline_generation, pending_generation = excluded.pending_generation, pending_position = excluded.pending_position',
|
|
4264
|
+
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, baseline_observation_id, baseline_generation, pending_generation, pending_position, pending_captured_at_utc) 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, baseline_observation_id = excluded.baseline_observation_id, baseline_generation = excluded.baseline_generation, pending_generation = excluded.pending_generation, pending_position = excluded.pending_position, pending_captured_at_utc = excluded.pending_captured_at_utc',
|
|
3366
4265
|
table='five_hour_credit_confirmation_state',
|
|
3367
4266
|
keys=(),
|
|
3368
4267
|
predicate='',
|
|
@@ -3396,6 +4295,21 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
3396
4295
|
classes=('singleton',),
|
|
3397
4296
|
inert_rule=None,
|
|
3398
4297
|
),
|
|
4298
|
+
# #943 T3 (spec 4.7): the credit's exact-boundary companion, written
|
|
4299
|
+
# only when the credit INSERT above inserted a row (rowcount 1), so a
|
|
4300
|
+
# replayed or colliding confirm never mints a second boundary.
|
|
4301
|
+
AccessContract(
|
|
4302
|
+
function='_cctally_record:detect_reset_and_credit',
|
|
4303
|
+
sql_fingerprint='INSERT OR IGNORE INTO five_hour_credit_boundaries (account_key, five_hour_window_key, effective_reset_at_utc, boundary_at_utc, arming_observation_id, credit_revision, detected_at_utc) VALUES (?, ?, ?, ?, ?, ?, ?)',
|
|
4304
|
+
table='five_hour_credit_boundaries',
|
|
4305
|
+
keys=(),
|
|
4306
|
+
predicate='',
|
|
4307
|
+
ordering='',
|
|
4308
|
+
selected=(),
|
|
4309
|
+
effects='write',
|
|
4310
|
+
classes=('singleton',),
|
|
4311
|
+
inert_rule=None,
|
|
4312
|
+
),
|
|
3399
4313
|
AccessContract(
|
|
3400
4314
|
function='_cctally_record:detect_reset_and_credit',
|
|
3401
4315
|
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 (?, ?, ?, ?, ?, ?)',
|
|
@@ -3408,12 +4322,17 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
3408
4322
|
classes=('singleton',),
|
|
3409
4323
|
inert_rule=None,
|
|
3410
4324
|
),
|
|
4325
|
+
# #943 T3 (spec 4.2.3 crash analysis): the detector's previous accepted
|
|
4326
|
+
# row now excludes the observation's own `sa:<observation id>` snapshot,
|
|
4327
|
+
# which step 4a can fold from a crashed cycle before the detector
|
|
4328
|
+
# re-runs. Same table, keys, ordering, selected columns, read effect and
|
|
4329
|
+
# inert rule; live the excluded row does not exist yet.
|
|
3411
4330
|
AccessContract(
|
|
3412
4331
|
function='_cctally_record:detect_reset_and_credit',
|
|
3413
|
-
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',
|
|
4332
|
+
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 = ? AND (? IS NULL OR journal_id IS NOT ?) ORDER BY captured_at_utc DESC, id DESC LIMIT 1',
|
|
3414
4333
|
table='weekly_usage_snapshots',
|
|
3415
4334
|
keys=('account_key',),
|
|
3416
|
-
predicate='five_hour_window_key IS NOT NULL AND five_hour_percent IS NOT NULL AND account_key = ?',
|
|
4335
|
+
predicate='five_hour_window_key IS NOT NULL AND five_hour_percent IS NOT NULL AND account_key = ? AND (? IS NULL OR journal_id IS NOT ?)',
|
|
3417
4336
|
ordering='captured_at_utc DESC, id DESC',
|
|
3418
4337
|
selected=('five_hour_window_key', 'five_hour_percent', 'five_hour_resets_at'),
|
|
3419
4338
|
effects='read',
|
|
@@ -3468,12 +4387,18 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
3468
4387
|
classes=('period-keyed',),
|
|
3469
4388
|
inert_rule=None,
|
|
3470
4389
|
),
|
|
4390
|
+
# #943 (the weekly twin of T3's spec 4.2.3 crash analysis): the weekly
|
|
4391
|
+
# previous accepted row also excludes the observation's own
|
|
4392
|
+
# `sa:<observation id>` snapshot, which step 4a can fold from a cycle
|
|
4393
|
+
# that crashed between the `snapshot_accept` and `wr` appends. Same
|
|
4394
|
+
# table, keys, ordering, selected columns, read effect and inert rule;
|
|
4395
|
+
# live the excluded row does not exist yet.
|
|
3471
4396
|
AccessContract(
|
|
3472
4397
|
function='_cctally_record:detect_reset_and_credit',
|
|
3473
|
-
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',
|
|
4398
|
+
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 AND (? IS NULL OR journal_id IS NOT ?) ORDER BY captured_at_utc DESC, id DESC LIMIT 1',
|
|
3474
4399
|
table='weekly_usage_snapshots',
|
|
3475
4400
|
keys=('account_key',),
|
|
3476
|
-
predicate='week_end_at IS NOT NULL AND account_key = ? AND weekly_observation_held = 0',
|
|
4401
|
+
predicate='week_end_at IS NOT NULL AND account_key = ? AND weekly_observation_held = 0 AND (? IS NULL OR journal_id IS NOT ?)',
|
|
3477
4402
|
ordering='captured_at_utc DESC, id DESC',
|
|
3478
4403
|
selected=('week_end_at', 'weekly_percent'),
|
|
3479
4404
|
effects='read',
|
|
@@ -3552,66 +4477,6 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
3552
4477
|
classes=('period-keyed',),
|
|
3553
4478
|
inert_rule=Q7,
|
|
3554
4479
|
),
|
|
3555
|
-
AccessContract(
|
|
3556
|
-
function='_cctally_record:maybe_update_five_hour_block',
|
|
3557
|
-
sql_fingerprint='DELETE FROM five_hour_block_models WHERE five_hour_window_key = ? AND account_key = ?',
|
|
3558
|
-
table='five_hour_block_models',
|
|
3559
|
-
keys=('five_hour_window_key', 'account_key'),
|
|
3560
|
-
predicate='five_hour_window_key = ? AND account_key = ?',
|
|
3561
|
-
ordering='',
|
|
3562
|
-
selected=(),
|
|
3563
|
-
effects='delete',
|
|
3564
|
-
classes=('period-keyed',),
|
|
3565
|
-
inert_rule=BLOCKS,
|
|
3566
|
-
),
|
|
3567
|
-
AccessContract(
|
|
3568
|
-
function='_cctally_record:maybe_update_five_hour_block',
|
|
3569
|
-
sql_fingerprint='DELETE FROM five_hour_block_projects WHERE five_hour_window_key = ? AND account_key = ?',
|
|
3570
|
-
table='five_hour_block_projects',
|
|
3571
|
-
keys=('five_hour_window_key', 'account_key'),
|
|
3572
|
-
predicate='five_hour_window_key = ? AND account_key = ?',
|
|
3573
|
-
ordering='',
|
|
3574
|
-
selected=(),
|
|
3575
|
-
effects='delete',
|
|
3576
|
-
classes=('period-keyed',),
|
|
3577
|
-
inert_rule=BLOCKS,
|
|
3578
|
-
),
|
|
3579
|
-
AccessContract(
|
|
3580
|
-
function='_cctally_record:maybe_update_five_hour_block',
|
|
3581
|
-
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
3582
|
-
table='five_hour_block_models',
|
|
3583
|
-
keys=(),
|
|
3584
|
-
predicate='',
|
|
3585
|
-
ordering='',
|
|
3586
|
-
selected=(),
|
|
3587
|
-
effects='write',
|
|
3588
|
-
classes=('singleton',),
|
|
3589
|
-
inert_rule=BLOCKS,
|
|
3590
|
-
),
|
|
3591
|
-
AccessContract(
|
|
3592
|
-
function='_cctally_record:maybe_update_five_hour_block',
|
|
3593
|
-
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
3594
|
-
table='five_hour_block_projects',
|
|
3595
|
-
keys=(),
|
|
3596
|
-
predicate='',
|
|
3597
|
-
ordering='',
|
|
3598
|
-
selected=(),
|
|
3599
|
-
effects='write',
|
|
3600
|
-
classes=('singleton',),
|
|
3601
|
-
inert_rule=BLOCKS,
|
|
3602
|
-
),
|
|
3603
|
-
AccessContract(
|
|
3604
|
-
function='_cctally_record:maybe_update_five_hour_block',
|
|
3605
|
-
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',
|
|
3606
|
-
table='five_hour_blocks',
|
|
3607
|
-
keys=(),
|
|
3608
|
-
predicate='five_hour_blocks.is_closed = 0 OR five_hour_blocks.journal_id IS NULL',
|
|
3609
|
-
ordering='',
|
|
3610
|
-
selected=(),
|
|
3611
|
-
effects='upsert',
|
|
3612
|
-
classes=('singleton',),
|
|
3613
|
-
inert_rule=BLOCKS,
|
|
3614
|
-
),
|
|
3615
4480
|
AccessContract(
|
|
3616
4481
|
function='_cctally_record:maybe_update_five_hour_block',
|
|
3617
4482
|
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
@@ -3710,25 +4575,314 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
3710
4575
|
),
|
|
3711
4576
|
AccessContract(
|
|
3712
4577
|
function='_cctally_record:maybe_update_five_hour_block',
|
|
3713
|
-
sql_fingerprint='SELECT id FROM five_hour_blocks WHERE is_closed =
|
|
4578
|
+
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(?))',
|
|
3714
4579
|
table='five_hour_blocks',
|
|
3715
|
-
keys=('account_key',),
|
|
3716
|
-
predicate='is_closed =
|
|
4580
|
+
keys=('account_key', 'last_updated_at_utc'),
|
|
4581
|
+
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(?))',
|
|
3717
4582
|
ordering='',
|
|
3718
4583
|
selected=('id',),
|
|
3719
4584
|
effects='read',
|
|
3720
4585
|
classes=('range-keyed', 'cross-period'),
|
|
3721
4586
|
inert_rule=BLOCKS,
|
|
3722
4587
|
),
|
|
4588
|
+
# #956 class 2 (spec 4.6.3): every block creation retains an opening fact
|
|
4589
|
+
# whose fold materializes the open block. The opening's writer and the
|
|
4590
|
+
# milestone re-link run inside the creating cycle by exact key; the seed
|
|
4591
|
+
# read projects a reading-less window; the coupled convergence and removal
|
|
4592
|
+
# run only on derivation-completion and correction convergence paths, by
|
|
4593
|
+
# exact physical id or natural key. All are the five-hour block rollup
|
|
4594
|
+
# (BLOCKS), a Q7 cost/display family.
|
|
4595
|
+
AccessContract(
|
|
4596
|
+
function='_cctally_five_hour:select_open_block_end',
|
|
4597
|
+
sql_fingerprint='SELECT first_observed_at_utc, five_hour_percent, seven_day_pct_at_block_start FROM five_hour_block_openings WHERE account_key = ? AND five_hour_window_key = ?',
|
|
4598
|
+
table='five_hour_block_openings',
|
|
4599
|
+
keys=('account_key', 'five_hour_window_key'),
|
|
4600
|
+
predicate='account_key = ? AND five_hour_window_key = ?',
|
|
4601
|
+
ordering='',
|
|
4602
|
+
selected=('first_observed_at_utc', 'five_hour_percent', 'seven_day_pct_at_block_start'),
|
|
4603
|
+
effects='read',
|
|
4604
|
+
classes=('period-keyed',),
|
|
4605
|
+
inert_rule=BLOCKS,
|
|
4606
|
+
),
|
|
3723
4607
|
AccessContract(
|
|
3724
|
-
function='
|
|
3725
|
-
sql_fingerprint='SELECT
|
|
4608
|
+
function='_cctally_journal:_converge_opened_block',
|
|
4609
|
+
sql_fingerprint='SELECT * FROM five_hour_block_openings WHERE id = ?',
|
|
4610
|
+
table='five_hour_block_openings',
|
|
4611
|
+
keys=('id',),
|
|
4612
|
+
predicate='id = ?',
|
|
4613
|
+
ordering='',
|
|
4614
|
+
selected=('*',),
|
|
4615
|
+
effects='read',
|
|
4616
|
+
classes=('period-keyed',),
|
|
4617
|
+
inert_rule=BLOCKS,
|
|
4618
|
+
),
|
|
4619
|
+
AccessContract(
|
|
4620
|
+
function='_cctally_journal:_converge_opened_block',
|
|
4621
|
+
sql_fingerprint='dynamic:_cctally_journal:_converge_opened_block#1',
|
|
4622
|
+
sql_shape='sha256:e37cbdd6ab3cc61d',
|
|
3726
4623
|
table='five_hour_blocks',
|
|
3727
|
-
keys=('account_key', '
|
|
3728
|
-
predicate='
|
|
4624
|
+
keys=('account_key', 'five_hour_window_key'),
|
|
4625
|
+
predicate='account_key = ? AND five_hour_window_key = ? AND is_closed = 0 AND journal_id IS NULL (SET the opening start columns)',
|
|
4626
|
+
ordering='',
|
|
4627
|
+
selected=(),
|
|
4628
|
+
effects='write',
|
|
4629
|
+
classes=('period-keyed',),
|
|
4630
|
+
inert_rule=BLOCKS,
|
|
4631
|
+
),
|
|
4632
|
+
AccessContract(
|
|
4633
|
+
function='_cctally_journal:_remove_opened_block',
|
|
4634
|
+
sql_fingerprint='DELETE FROM five_hour_blocks WHERE id = ?',
|
|
4635
|
+
table='five_hour_blocks',
|
|
4636
|
+
keys=('id',),
|
|
4637
|
+
predicate='id = ?',
|
|
4638
|
+
ordering='',
|
|
4639
|
+
selected=(),
|
|
4640
|
+
effects='delete',
|
|
4641
|
+
classes=('period-keyed',),
|
|
4642
|
+
inert_rule=BLOCKS,
|
|
4643
|
+
),
|
|
4644
|
+
AccessContract(
|
|
4645
|
+
function='_cctally_journal:_remove_opened_block',
|
|
4646
|
+
sql_fingerprint='SELECT account_key, five_hour_window_key FROM five_hour_block_openings WHERE id = ?',
|
|
4647
|
+
table='five_hour_block_openings',
|
|
4648
|
+
keys=('id',),
|
|
4649
|
+
predicate='id = ?',
|
|
4650
|
+
ordering='',
|
|
4651
|
+
selected=('account_key', 'five_hour_window_key'),
|
|
4652
|
+
effects='read',
|
|
4653
|
+
classes=('period-keyed',),
|
|
4654
|
+
inert_rule=BLOCKS,
|
|
4655
|
+
),
|
|
4656
|
+
AccessContract(
|
|
4657
|
+
function='_cctally_journal:_remove_opened_block',
|
|
4658
|
+
sql_fingerprint='SELECT id FROM five_hour_blocks WHERE account_key = ? AND five_hour_window_key = ? AND is_closed = 0 AND journal_id IS NULL',
|
|
4659
|
+
table='five_hour_blocks',
|
|
4660
|
+
keys=('account_key', 'five_hour_window_key'),
|
|
4661
|
+
predicate='account_key = ? AND five_hour_window_key = ? AND is_closed = 0 AND journal_id IS NULL',
|
|
3729
4662
|
ordering='',
|
|
3730
4663
|
selected=('id',),
|
|
3731
4664
|
effects='read',
|
|
4665
|
+
classes=('period-keyed',),
|
|
4666
|
+
inert_rule=BLOCKS,
|
|
4667
|
+
),
|
|
4668
|
+
AccessContract(
|
|
4669
|
+
function='_cctally_journal:_remove_opened_block',
|
|
4670
|
+
sql_fingerprint='UPDATE five_hour_milestones SET block_id = 0 WHERE account_key = ? AND five_hour_window_key = ?',
|
|
4671
|
+
table='five_hour_milestones',
|
|
4672
|
+
keys=('account_key', 'five_hour_window_key'),
|
|
4673
|
+
predicate='account_key = ? AND five_hour_window_key = ?',
|
|
4674
|
+
ordering='',
|
|
4675
|
+
selected=(),
|
|
4676
|
+
effects='write',
|
|
4677
|
+
classes=('period-keyed',),
|
|
4678
|
+
inert_rule=BLOCKS,
|
|
4679
|
+
),
|
|
4680
|
+
AccessContract(
|
|
4681
|
+
function='_cctally_journal:_remove_opened_block',
|
|
4682
|
+
sql_fingerprint='dynamic:_cctally_journal:_remove_opened_block#1',
|
|
4683
|
+
sql_shape='sha256:4412618cbf5c0995',
|
|
4684
|
+
table='dynamic',
|
|
4685
|
+
keys=('account_key', 'five_hour_window_key'),
|
|
4686
|
+
predicate='account_key = ? AND five_hour_window_key = ? on each `_BLOCK_CHILDREN` table',
|
|
4687
|
+
ordering='',
|
|
4688
|
+
selected=(),
|
|
4689
|
+
effects='delete',
|
|
4690
|
+
classes=('period-keyed',),
|
|
4691
|
+
inert_rule=BLOCKS,
|
|
4692
|
+
),
|
|
4693
|
+
AccessContract(
|
|
4694
|
+
function='_cctally_journal:five_hour_windows_touched_by_evt',
|
|
4695
|
+
sql_fingerprint='SELECT five_hour_window_key FROM five_hour_blocks WHERE account_key = ? AND is_closed = 0',
|
|
4696
|
+
table='five_hour_blocks',
|
|
4697
|
+
keys=('account_key',),
|
|
4698
|
+
predicate='account_key = ? AND is_closed = 0',
|
|
4699
|
+
ordering='',
|
|
4700
|
+
selected=('five_hour_window_key',),
|
|
4701
|
+
effects='read',
|
|
4702
|
+
classes=('cross-period',),
|
|
4703
|
+
inert_rule=BLOCKS,
|
|
4704
|
+
),
|
|
4705
|
+
AccessContract(
|
|
4706
|
+
function='_cctally_record:_insert_five_hour_block_opening',
|
|
4707
|
+
sql_fingerprint='INSERT OR IGNORE INTO five_hour_block_openings ( account_key, five_hour_window_key, five_hour_resets_at, block_start_at, first_observed_at_utc, created_at_utc, opening_record_id, creation_kind, five_hour_percent, seven_day_pct_at_block_start, weekly_observation_held, weekly_basis_captured_at_utc ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
4708
|
+
table='five_hour_block_openings',
|
|
4709
|
+
keys=(),
|
|
4710
|
+
predicate='',
|
|
4711
|
+
ordering='',
|
|
4712
|
+
selected=(),
|
|
4713
|
+
effects='write',
|
|
4714
|
+
classes=('singleton',),
|
|
4715
|
+
inert_rule=BLOCKS,
|
|
4716
|
+
),
|
|
4717
|
+
AccessContract(
|
|
4718
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
4719
|
+
sql_fingerprint='UPDATE five_hour_milestones SET block_id = ? WHERE account_key = ? AND five_hour_window_key = ? AND block_id = 0',
|
|
4720
|
+
table='five_hour_milestones',
|
|
4721
|
+
keys=('account_key', 'five_hour_window_key'),
|
|
4722
|
+
predicate='account_key = ? AND five_hour_window_key = ? AND block_id = 0',
|
|
4723
|
+
ordering='',
|
|
4724
|
+
selected=(),
|
|
4725
|
+
effects='write',
|
|
4726
|
+
classes=('period-keyed',),
|
|
4727
|
+
inert_rule=BLOCKS,
|
|
4728
|
+
),
|
|
4729
|
+
# #956 class 1 (spec 4.5): the capture-order open-block end projection
|
|
4730
|
+
# and its dirty-window marking and flush. Every site is an exact-key or
|
|
4731
|
+
# account-scoped read or write of the five-hour block rollup (BLOCKS), or
|
|
4732
|
+
# an exact journal-id lookup (JOURNAL).
|
|
4733
|
+
AccessContract(
|
|
4734
|
+
function='_cctally_five_hour:project_open_block_end',
|
|
4735
|
+
sql_fingerprint='DELETE FROM five_hour_block_models WHERE five_hour_window_key = ? AND account_key = ?',
|
|
4736
|
+
table='five_hour_block_models',
|
|
4737
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
4738
|
+
predicate='five_hour_window_key = ? AND account_key = ?',
|
|
4739
|
+
ordering='',
|
|
4740
|
+
selected=(),
|
|
4741
|
+
effects='delete',
|
|
4742
|
+
classes=('period-keyed',),
|
|
4743
|
+
inert_rule=BLOCKS,
|
|
4744
|
+
),
|
|
4745
|
+
AccessContract(
|
|
4746
|
+
function='_cctally_five_hour:project_open_block_end',
|
|
4747
|
+
sql_fingerprint='DELETE FROM five_hour_block_projects WHERE five_hour_window_key = ? AND account_key = ?',
|
|
4748
|
+
table='five_hour_block_projects',
|
|
4749
|
+
keys=('five_hour_window_key', 'account_key'),
|
|
4750
|
+
predicate='five_hour_window_key = ? AND account_key = ?',
|
|
4751
|
+
ordering='',
|
|
4752
|
+
selected=(),
|
|
4753
|
+
effects='delete',
|
|
4754
|
+
classes=('period-keyed',),
|
|
4755
|
+
inert_rule=BLOCKS,
|
|
4756
|
+
),
|
|
4757
|
+
AccessContract(
|
|
4758
|
+
function='_cctally_five_hour:project_open_block_end',
|
|
4759
|
+
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
4760
|
+
table='five_hour_block_models',
|
|
4761
|
+
keys=(),
|
|
4762
|
+
predicate='',
|
|
4763
|
+
ordering='',
|
|
4764
|
+
selected=(),
|
|
4765
|
+
effects='write',
|
|
4766
|
+
classes=('singleton',),
|
|
4767
|
+
inert_rule=BLOCKS,
|
|
4768
|
+
),
|
|
4769
|
+
AccessContract(
|
|
4770
|
+
function='_cctally_five_hour:project_open_block_end',
|
|
4771
|
+
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
4772
|
+
table='five_hour_block_projects',
|
|
4773
|
+
keys=(),
|
|
4774
|
+
predicate='',
|
|
4775
|
+
ordering='',
|
|
4776
|
+
selected=(),
|
|
4777
|
+
effects='write',
|
|
4778
|
+
classes=('singleton',),
|
|
4779
|
+
inert_rule=BLOCKS,
|
|
4780
|
+
),
|
|
4781
|
+
AccessContract(
|
|
4782
|
+
function='_cctally_five_hour:project_open_block_end',
|
|
4783
|
+
sql_fingerprint='SELECT * FROM five_hour_blocks WHERE id = ?',
|
|
4784
|
+
table='five_hour_blocks',
|
|
4785
|
+
keys=('id',),
|
|
4786
|
+
predicate='id = ?',
|
|
4787
|
+
ordering='',
|
|
4788
|
+
selected=('*',),
|
|
4789
|
+
effects='read',
|
|
4790
|
+
classes=('period-keyed',),
|
|
4791
|
+
inert_rule=BLOCKS,
|
|
4792
|
+
),
|
|
4793
|
+
AccessContract(
|
|
4794
|
+
function='_cctally_five_hour:project_open_block_end',
|
|
4795
|
+
sql_fingerprint='SELECT EXISTS ( SELECT 1 FROM week_reset_events WHERE account_key = ? AND unixepoch(effective_reset_at_utc) BETWEEN unixepoch(?) AND unixepoch(?) ) OR EXISTS ( SELECT 1 FROM weekly_usage_snapshots WHERE week_start_at IS NOT NULL AND account_key = ? AND unixepoch(week_start_at) > unixepoch(?) AND unixepoch(week_start_at) <= unixepoch(?) )',
|
|
4796
|
+
table='week_reset_events',
|
|
4797
|
+
keys=('account_key',),
|
|
4798
|
+
predicate='account_key = ? AND unixepoch(effective_reset_at_utc) BETWEEN unixepoch(?) AND unixepoch(?) ) OR EXISTS ( SELECT 1 FROM weekly_usage_snapshots WHERE week_start_at IS NOT NULL AND account_key = ? AND unixepoch(week_start_at) > unixepoch(?) AND unixepoch(week_start_at) <= unixepoch(?) )',
|
|
4799
|
+
ordering='',
|
|
4800
|
+
selected=('EXISTS ( SELECT 1',),
|
|
4801
|
+
effects='read',
|
|
4802
|
+
classes=('range-keyed', 'cross-period'),
|
|
4803
|
+
inert_rule=BLOCKS,
|
|
4804
|
+
),
|
|
4805
|
+
AccessContract(
|
|
4806
|
+
function='_cctally_five_hour:project_open_block_end',
|
|
4807
|
+
sql_fingerprint='UPDATE five_hour_blocks SET last_observed_at_utc = ?, final_five_hour_percent = ?, seven_day_pct_at_block_end = ?, total_input_tokens = ?, total_output_tokens = ?, total_cache_create_tokens = ?, total_cache_read_tokens = ?, total_cost_usd = ?, pricing_provenance_json = ?, crossed_seven_day_reset = ?, last_updated_at_utc = ? WHERE id = ? AND is_closed = 0',
|
|
4808
|
+
table='five_hour_blocks',
|
|
4809
|
+
keys=('id',),
|
|
4810
|
+
predicate='id = ? AND is_closed = 0',
|
|
4811
|
+
ordering='',
|
|
4812
|
+
selected=(),
|
|
4813
|
+
effects='write',
|
|
4814
|
+
classes=('singleton',),
|
|
4815
|
+
inert_rule=BLOCKS,
|
|
4816
|
+
),
|
|
4817
|
+
AccessContract(
|
|
4818
|
+
function='_cctally_five_hour:select_open_block_end',
|
|
4819
|
+
sql_fingerprint='SELECT unixepoch(captured_at_utc) AS captured_epoch, journal_id, captured_at_utc, five_hour_percent, weekly_percent FROM weekly_usage_snapshots WHERE account_key = ? AND five_hour_window_key = ? AND five_hour_percent IS NOT NULL',
|
|
4820
|
+
table='weekly_usage_snapshots',
|
|
4821
|
+
keys=('account_key', 'five_hour_window_key'),
|
|
4822
|
+
predicate='account_key = ? AND five_hour_window_key = ? AND five_hour_percent IS NOT NULL',
|
|
4823
|
+
ordering='',
|
|
4824
|
+
selected=('unixepoch(captured_at_utc) AS captured_epoch', 'journal_id', 'captured_at_utc', 'five_hour_percent', 'weekly_percent'),
|
|
4825
|
+
effects='read',
|
|
4826
|
+
classes=('period-keyed',),
|
|
4827
|
+
inert_rule=BLOCKS,
|
|
4828
|
+
),
|
|
4829
|
+
AccessContract(
|
|
4830
|
+
function='_cctally_journal:five_hour_windows_touched_by_evt',
|
|
4831
|
+
sql_fingerprint='SELECT account_key, five_hour_window_key FROM weekly_usage_snapshots WHERE journal_id = ?',
|
|
4832
|
+
table='weekly_usage_snapshots',
|
|
4833
|
+
keys=('journal_id',),
|
|
4834
|
+
predicate='journal_id = ?',
|
|
4835
|
+
ordering='',
|
|
4836
|
+
selected=('account_key', 'five_hour_window_key'),
|
|
4837
|
+
effects='read',
|
|
4838
|
+
classes=('period-keyed',),
|
|
4839
|
+
inert_rule=JOURNAL,
|
|
4840
|
+
),
|
|
4841
|
+
AccessContract(
|
|
4842
|
+
function='_cctally_record:_refresh_open_five_hour_block',
|
|
4843
|
+
sql_fingerprint='SELECT id, block_start_at, five_hour_resets_at, last_observed_at_utc FROM five_hour_blocks WHERE account_key = ? AND five_hour_window_key = ? AND is_closed = 0',
|
|
4844
|
+
table='five_hour_blocks',
|
|
4845
|
+
keys=('account_key', 'five_hour_window_key'),
|
|
4846
|
+
predicate='account_key = ? AND five_hour_window_key = ? AND is_closed = 0',
|
|
4847
|
+
ordering='',
|
|
4848
|
+
selected=('id', 'block_start_at', 'five_hour_resets_at', 'last_observed_at_utc'),
|
|
4849
|
+
effects='read',
|
|
4850
|
+
classes=('period-keyed',),
|
|
4851
|
+
inert_rule=BLOCKS,
|
|
4852
|
+
),
|
|
4853
|
+
AccessContract(
|
|
4854
|
+
function='_cctally_record:mark_account_open_blocks_dirty',
|
|
4855
|
+
sql_fingerprint='SELECT five_hour_window_key FROM five_hour_blocks WHERE account_key = ? AND is_closed = 0',
|
|
4856
|
+
table='five_hour_blocks',
|
|
4857
|
+
keys=('account_key',),
|
|
4858
|
+
predicate='account_key = ? AND is_closed = 0',
|
|
4859
|
+
ordering='',
|
|
4860
|
+
selected=('five_hour_window_key',),
|
|
4861
|
+
effects='read',
|
|
4862
|
+
classes=('cross-period',),
|
|
4863
|
+
inert_rule=BLOCKS,
|
|
4864
|
+
),
|
|
4865
|
+
AccessContract(
|
|
4866
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
4867
|
+
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 NOTHING',
|
|
4868
|
+
table='five_hour_blocks',
|
|
4869
|
+
keys=(),
|
|
4870
|
+
predicate='',
|
|
4871
|
+
ordering='',
|
|
4872
|
+
selected=(),
|
|
4873
|
+
effects='upsert',
|
|
4874
|
+
classes=('singleton',),
|
|
4875
|
+
inert_rule=BLOCKS,
|
|
4876
|
+
),
|
|
4877
|
+
AccessContract(
|
|
4878
|
+
function='_cctally_record:maybe_update_five_hour_block',
|
|
4879
|
+
sql_fingerprint='SELECT id, five_hour_window_key FROM five_hour_blocks WHERE is_closed = 0 AND account_key = ? AND (five_hour_window_key < ? OR unixepoch(five_hour_resets_at) < unixepoch(?))',
|
|
4880
|
+
table='five_hour_blocks',
|
|
4881
|
+
keys=('account_key',),
|
|
4882
|
+
predicate='is_closed = 0 AND account_key = ? AND (five_hour_window_key < ? OR unixepoch(five_hour_resets_at) < unixepoch(?))',
|
|
4883
|
+
ordering='',
|
|
4884
|
+
selected=('id', 'five_hour_window_key'),
|
|
4885
|
+
effects='read',
|
|
3732
4886
|
classes=('range-keyed', 'cross-period'),
|
|
3733
4887
|
inert_rule=BLOCKS,
|
|
3734
4888
|
),
|
|
@@ -3794,12 +4948,27 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
3794
4948
|
),
|
|
3795
4949
|
AccessContract(
|
|
3796
4950
|
function='_cctally_record:resolve_five_hour_reset_event',
|
|
3797
|
-
sql_fingerprint='SELECT detected_at_utc, effective_reset_at_utc, id FROM five_hour_reset_events WHERE five_hour_window_key = ? AND account_key = ?',
|
|
4951
|
+
sql_fingerprint='SELECT detected_at_utc, effective_reset_at_utc, id, prior_percent, post_percent FROM five_hour_reset_events WHERE five_hour_window_key = ? AND account_key = ?',
|
|
3798
4952
|
table='five_hour_reset_events',
|
|
3799
4953
|
keys=('five_hour_window_key', 'account_key'),
|
|
3800
4954
|
predicate='five_hour_window_key = ? AND account_key = ?',
|
|
3801
4955
|
ordering='',
|
|
3802
|
-
selected=('detected_at_utc', 'effective_reset_at_utc', 'id'),
|
|
4956
|
+
selected=('detected_at_utc', 'effective_reset_at_utc', 'id', 'prior_percent', 'post_percent'),
|
|
4957
|
+
effects='read',
|
|
4958
|
+
classes=('period-keyed',),
|
|
4959
|
+
inert_rule=None,
|
|
4960
|
+
),
|
|
4961
|
+
# #943 T3 (spec 4.7): the boundary resolver's companion lookup, by the
|
|
4962
|
+
# selected credit's natural key; the caller accepts the boundary only
|
|
4963
|
+
# when its `credit_revision` equals the credit's revision.
|
|
4964
|
+
AccessContract(
|
|
4965
|
+
function='_cctally_record:_five_hour_credit_companion',
|
|
4966
|
+
sql_fingerprint='SELECT boundary_at_utc, credit_revision FROM five_hour_credit_boundaries WHERE account_key = ? AND five_hour_window_key = ? AND effective_reset_at_utc = ?',
|
|
4967
|
+
table='five_hour_credit_boundaries',
|
|
4968
|
+
keys=('account_key', 'five_hour_window_key', 'effective_reset_at_utc'),
|
|
4969
|
+
predicate='account_key = ? AND five_hour_window_key = ? AND effective_reset_at_utc = ?',
|
|
4970
|
+
ordering='',
|
|
4971
|
+
selected=('boundary_at_utc', 'credit_revision'),
|
|
3803
4972
|
effects='read',
|
|
3804
4973
|
classes=('period-keyed',),
|
|
3805
4974
|
inert_rule=None,
|
|
@@ -3831,7 +5000,7 @@ REGISTRY: "tuple[AccessContract, ...]" = (
|
|
|
3831
5000
|
AccessContract(
|
|
3832
5001
|
function='_cctally_statusline:_tokens_from',
|
|
3833
5002
|
sql_fingerprint='dynamic:_cctally_statusline:_tokens_from#1',
|
|
3834
|
-
sql_shape='sha256:
|
|
5003
|
+
sql_shape='sha256:3792420114949f41',
|
|
3835
5004
|
table='dynamic',
|
|
3836
5005
|
keys=(),
|
|
3837
5006
|
predicate='dynamic SQL',
|