This is the contract for the operations ck-astrocyte serves and the
operations it calls on peer modules. The source of truth is
crates/astrocyte-module/src/ops.rs. See the data model for
the tables these operations read and write.
astrocyte runs under subc, the subconscious daemon, which supervises local
modules and routes requests between them. It displays as "Spending Tracker" and
serves one management surface under module id astrocyte. A
client opens a route with target {"kind": "management_surface", "module_id": "astrocyte"} and sends a request body {"method": <operation>, "params": <object>} on that route. spend_drive is a client that does exactly this;
see operations.
- A success is a Response frame whose body is
{"result": <reply>}. - A refusal is an Error frame whose body is
{"code": <code>, "message": <text>}.codeis a closed string from this document;messageis for people and is not a stable interface. - A body that does not decode as
{method, params}is refusedinvalid_request. - A request/reply read under
spend.*orusage.*, or a call tobudget.verdictorwatermark.get, refusesreply_too_largeif its reply would exceed the daemon's frame limit. The Error'sdetailcarriesreply_bytesandlimit_bytesfor the encoded body (including theresultwrapper on success, excluding the frame header), plusrowswhen the result has arowsarray. The body limit is 4,194,283 bytes. The caller must narrow the request; the watch subscriptions are not subject to this read check. Test:read_reply_uses_exact_body_size_and_keeps_refusal_code. - A reply larger than the daemon delivers (4 MiB, counting the 21-byte
frame header) that reaches the transport is replaced by
frame_too_largewhosedetailis{"size": <reply bytes>, "limit": <limit>}, on the request's own route and correlation id. Test:oversized_route_reply_is_refused_frame_too_large_on_its_own_correlation. - A request whose handler panics is refused
internal, and the module then stops with a non-zero exit, because a panic may have left shared state broken. Test:handler_panic_replies_before_serving_ends_with_nonzero_exit. - A route opened by an approved subc flow (work that runs for its owner without
the owner present) may call exactly these reads:
budget.verdict,spend.report,spend.subscription.report,spend.workclass.report,spend.ledger.coverage,spend.charge.explain,spend.reconcile,spend.multiplier.report,spend.multiplier.pace,usage.cache.sessions,usage.cache.steps,usage.runs.listandusage.runs.detail. The manifest declaresflow-scopes/v1and names these inflow_operations; the same list controls dispatch. Run reads retain their principal checks on flow routes. - Every other operation on a flow route is refused
flow_scopes_unsupportedbefore dispatch, including every write and the principal-checked readsusage.steps.subscribe,usage.steps.read,usage.runs.subscribeandwatermark.get. Without a flow, the step feed admits only local apps and Callosum phones and desktops, andwatermark.getadmits onlythalamus-harness. Tests:manifest_provides_flow_scopes_and_exact_read_operations,a_flow_stamped_subscription_report_is_advertised_and_served,a_flow_stamped_route_may_call_only_declared_operations,a_flow_stamped_feed_read_is_refused_before_dispatch,a_flow_stamped_watermark_read_is_refused_before_dispatchanda_flow_stamped_runs_read_keeps_principal_checks.
The manifest advertises the operation list and a versioned params schema per
operation (operation_schemas, OPERATION_SCHEMA_VERSION = 2). Every params
object is closed (additionalProperties: false). A field is required exactly
when the request type has no default for it. Optional fields can be omitted,
but only nullable fields accept explicit null. For example, spend.report
defaults an omitted where to an empty object, and spend.event.ingest
defaults omitted measurements to an empty array. Neither field accepts null.
Integer bounds are the Rust type's range. Tests:
operation_surface_is_set_equal_to_the_versioned_artifact,
every_operation_schema_agrees_with_its_decoder.
PUBLIC_OPERATION_NAMES is the closed list. An unknown method is refused
unknown_method. Writes are serialized through one writer. Each read uses one
snapshot on one of two read-only connections and neither waits for nor blocks
ingest.
Test: every_operation_name_reaches_its_own_handler.
| Operation | Kind | Request fields (required unless marked ?) |
|---|---|---|
budget.verdict |
read | project_root?, provider?, model?, est_cost_nanos? |
spend.report |
read | grouping (string array), grain, timezone; optional paired from_ms/to_ms, where |
spend.subscription.report |
read | none |
spend.workclass.report |
read | none |
spend.ledger.coverage |
read | none |
spend.charge.explain |
read | event_id |
spend.reconcile |
read | statement_id |
spend.multiplier.report |
read | from_ms, to_ms |
spend.multiplier.pace |
read | quota_provider, from_ms, to_ms, plan?, pool? |
usage.cache.sessions |
read | since_ms?, harness?, limit? |
usage.cache.steps |
read | harness, session, limit?, after_cursor? |
usage.runs.list |
read | from_ms, to_ms, harness?, limit?, after? |
usage.runs.detail |
read | key, limit?, after? |
usage.runs.subscribe |
read, watch | none |
spend.quota.history |
read | from_ms, to_ms, grain, quota_providers? |
usage.steps.subscribe |
read, watch | harness?, session? |
usage.steps.read |
read | after?, limit?, harness?, session? |
watermark.get |
read | none |
spend.event.ingest |
write | see §3.1 |
spend.correction.ingest |
write | see §3.2 |
spend.chargeability.settle |
write | event_id, to_state, reason |
spend.statement.import |
write | path, provider, account_ref, period_start, period_end, amount_exponent, currency |
spend.subscription.set |
write | account_ref, provider, plan_name, recurring_cost_minor, currency, amount_exponent, period, effective_from |
spend.subscription.close |
write | account_ref, provider, effective_to |
spend.event.reprice |
write | event_id |
spend.basis.correct |
write | event_id, corrected_basis, reason |
spend.multiplier.recompute |
write | observation_day, quota_provider? |
Times are Unix milliseconds. Money is signed integer nanounits of the named
currency (*_nanos); *_minor amounts are minor units scaled by
amount_exponent (0 to 9).
Every request that fails to decode (a missing or unknown field, a wrong type,
a value outside an enum) is refused malformed. Store failures are
internal. A refusal writes nothing. Test:
malformed_operation_is_a_refusal_without_a_write.
All nine writes above share a daemon operator-confirmation gate, declared in the
manifest's confirm_operations. The gate is off until release, so that a
daemon unable to prompt never blocks development:
ledger_write_confirmation_required() returns false. Release enables
it by changing only that function to return true, with no config, environment
or feature switch. While off, direct callers write without a prompt as before.
When enabled, only a Principal::Direct caller (a local program) must obtain
daemon confirmation for each in-flight write. The deployed daemon chooses its
OS presence provider. Module-route calls and the refresher never prompt; flow
routes keep their existing flow_scopes_unsupported refusal. The prompt names
the operation and target, and waits outside the lock that serializes ledger
writes and outside the store transaction. Callers
must allow at least 300 seconds for the person's response. A confirmation is
never cached or retried: any refusal or failure returns
operator_confirmation_refused without dispatching or changing the store. The
message includes the daemon's reason, not request secrets. Any confirmation
error refuses the write, on every platform. This includes direct Linux writes
when the deployed daemon cannot confirm the person, for example before its
polkit provider is available; there is no platform bypass.
spend_drive allows 300 seconds for these writes, even while the gate is off;
its reads and authentication retain their 15-second deadlines.
Records one usage event pushed by a peer. Required: producer,
producer_ref, charge_basis (metered_api, subscription_included or
unknown). Optional strings: producer_lineage, prior_event_ref,
harness, project_root, session, run_ref, work_class,
terminal_status, vendor_request_id, provider, model, account_ref,
auth_selection. Optional integers: occurred_at_ms, emitted_at_ms,
attempt_ordinal. measurements defaults to empty; each item has role,
unit, kind, source and optional quantity_units, quantity_exponent.
Reply: event_id, disposition, transitions_written,
quarantine_evidence_written, waiting_for_target. disposition is one of:
| Disposition | Meaning |
|---|---|
recorded |
A new event. Astrocyte queues it for pricing only if its charge basis is known and at least one billed measurement has no current charge (a charge row that no newer charge replaces). |
exact_redelivery |
The identity exists with the same payload. Nothing changes except one redelivery_log row. |
quarantined_redelivery |
The identity exists with a different payload. The stored event is kept; the incoming payload goes to rejected_delivery. |
Refusal malformed: empty producer or producer_ref, an empty
prior_event_ref, a measurement with an empty field, a quantity with only one
of its two parts, negative units, an exponent outside -9..0, or two
measurements with the same (role, unit). Tests:
exact_redelivery_is_an_order_independent_content_noop_and_logs_occurrence,
same_identity_different_payload_is_quarantined_without_overwrite.
Appends a signed money adjustment to an event. Required: correction_id (1 to
128 UTF-8 bytes), event_id, currency, amount_nanos, reason
(write_off, vendor_restatement, our_repricing, refund, goodwill),
occurred_at_ms (at least 0). Optional: note. Reply: adjustment_id,
origin (correction_ingest). The retry rules are in
money ingest.
| Code | Condition |
|---|---|
malformed |
An empty or oversized correction_id, an empty event_id or currency, or a negative time. |
correction_id_reused |
The key exists with different content. |
not_found |
No event has event_id. |
undated_target |
The event has no occurred_at_ms. |
unpriced_target |
The event has no currency yet: it has never been priced. |
currency_mismatch |
currency differs from the event's. |
write_off_requires_pricing |
reason is write_off; write-offs are not accepted yet. |
Tests: correction_ingest_requires_key_and_replays_without_moving_money,
correction_key_conflicting_content_is_refused_without_moving_money.
Settles whether an event is chargeable, once. to_state is billed,
written_off or unbillable. Reply: event_id, to_state.
| Code | Condition |
|---|---|
malformed |
An empty event_id or reason. |
operator_cannot_bill |
to_state is billed; only a later record or a statement can bill. |
not_found |
No event has event_id. |
already_settled |
The event already has a transition. |
unpriced_target |
The event has no currency. |
Tests: operator_cannot_mark_candidate_billed_without_effect,
settlement_is_terminal_and_current_state_comes_from_history.
Imports a vendor statement CSV from path and matches its lines against the
ledger. The import folder is statements/ beside astrocyte's store.db; create
it before importing. A relative path resolves inside that folder. The folder
and the requested file are each fully resolved, including all symlinks, and the
resolved file must remain inside the resolved folder. The file is read before
the write transaction. Reply: statement_id, import_id, content_outcome
(created or no_op), lines_created, lines_skipped, matching.
| Code | Condition |
|---|---|
invalid_request |
path is not a regular file, or is over 64 MiB. |
statement_outside_import_folder |
The resolved file is outside the resolved import folder. |
statement_source |
The import folder or file is missing, or the file cannot be read. |
malformed |
A line or field does not parse. |
invalid_period |
period_start is not before period_end. |
line_outside_period |
A line falls outside the declared period. |
statement_currency_mismatch |
A line's currency differs from currency. |
conflicting_reimport |
A line already imported has different content. |
amount_out_of_range |
An amount cannot be represented in nanounits. |
settlement_act_refused |
A settlement the import makes is refused. |
Tests: statement_import_refuses_a_directory_without_importing,
statement_import_refuses_files_over_64_mib_without_importing,
statement_import_refuses_fifo_without_waiting_for_a_writer,
safeguard_statement_import_reads_relative_name_inside_folder,
safeguard_statement_import_refuses_parent_escape,
safeguard_statement_import_refuses_absolute_path_outside,
safeguard_statement_import_refuses_file_symlink_outside,
safeguard_statement_import_refuses_folder_symlink_outside.
spend.subscription.set declares a plan for (provider, account_ref) from effective_from,
bounding any open plan for that key at the same instant. period is month
or year; currency is three uppercase letters. Its reply is the plan's
fields plus backdated (effective_from is before the call) and
coverage_notice (the one-way notice text when backdated, else null).
spend.subscription.close bounds the open plan at effective_to. Its reply is subscription,
coverage_is_one_way (always true) and coverage_notice.
| Code | Operation | Condition |
|---|---|---|
malformed |
both | An empty field, a negative cost or time, amount_exponent above 9, or a non-canonical currency. |
recurring_cost_out_of_range |
set | The cost cannot be represented in nanounits. |
overlapping_effective_range |
set | An open plan starts at or after effective_from, or a closed plan ends after it. |
no_open_subscription |
close | No open plan exists for the key. |
close_before_effective_from |
close | effective_to is at or before the open plan's start. |
Coverage is one-way: closing or superseding a plan never uncovers an event the
plan already priced as covered. See operations. Tests:
subscription_set_reply_carries_the_one_way_notice_only_when_backdated,
storage_update_and_delete_guards_preserve_subscription_history.
spend.event.reprice re-resolves an event's billed measurements whose current
head is unpriced or missing, and keeps priced and covered heads.
spend.basis.correct changes the event's charge basis to corrected_basis and
appends a new head for every billed measurement, replacing any existing head.
Both resolve against the catalog (or the subscription in force) before the write
transaction, then re-check that nothing moved. Reply: event_id,
pricing_generation, measurements_repriced, measurements_preserved.
| Code | Condition |
|---|---|
malformed |
An empty event_id, or (correction) a blank reason. |
not_found |
No event has event_id. |
basis_unchanged |
(correction) corrected_basis equals the current basis. |
no_measurements_to_price |
The event has no billed measurements, including events with only observed measurements. |
already_priced |
(reprice) Every billed measurement already has a priced or covered head. |
pricing_superseded |
Another pricing act committed between resolve and commit. |
subscription_coverage_superseded |
The subscription in force changed between resolve and commit. |
catalog_currency_mismatch |
A resolved price's currency differs from the event's currency or from another measurement's. |
Tests: op_event_reprice_routes_subscription_included_through_coverage,
basis_correction_op_refusals_write_no_charges,
basis_correction_op_reaches_all_three_arms,
missing_reprice_event_preserves_not_found_and_writes_nothing.
Recomputes the seven days ending at observation_day (YYYY-MM-DD) at 00:00Z.
The interval must already have ended.
Name a quota_provider or omit it to recompute providers with readings in
that interval or a provider-day marker on or before the requested day. A
marker qualifies even when it has no observations. Each new row supersedes its
own provider/plan/pool head for the day or starts a chain if none exists. For a
pool that drops out, recompute appends a pool_retired row: the old head no
longer appears in the report. Pre-migration chains are not superseded.
All rows and provider-day records commit in one transaction or none does.
If a provider-day marker or pool head changed while recompute read its inputs,
Astrocyte retries the entire operation once with fresh inputs.
Reply: {"recomputed": [{quota_provider, plan, observation_day, observation_id, supersedes, multiplier, fee_multiplier}]}.
| Code | Condition |
|---|---|
malformed |
observation_day is not a date. |
invalid_range |
The requested interval has not ended. |
unknown_quota_provider |
The named provider has no readings, observations or provider-day record, or no providers qualify when the name is omitted. |
provider_day_changed |
Both attempts found a changed provider-day marker or pool head. |
vault_plans_pending |
The provider-day has quota readings but no vault plan history has arrived yet. |
catalog_unavailable |
A catalog read was needed, but no Fusiform catalog is connected or the call failed. |
plan_prices_unavailable |
Plan prices were needed and could not be read. |
rate_fact_unrecognized |
The catalog served a rate this build cannot read. |
source_reads_pending |
A pool may be measurable, but a tracked source is stale or has backlog and two hours have not passed since the interval ended. Recompute checks this even for an existing day. After the bound, measured rows with source_backlog are routing-ineligible. |
arithmetic_out_of_range |
An exact computation overflowed. |
Tests: a_recompute_supersedes_the_day_and_the_report_serves_it,
recompute_creates_a_missing_day_without_supersedes_and_refuses_unknown_provider,
served_recompute_refuses_excluded_scope_without_calls_or_rows.
Reads never write. A refusal on a read is one of the codes below.
-
budget.verdict:decision(alwaysallow),consumed_nanos(current heads plus adjustments, by currency, filtered by the optional fields),est_cost_nanos(echoed),limit_nanosandremaining_nanos(alwaysnull),uncertainty(unpriced_events,events_total),uncertainty_scope(machine). Test:only_the_charge_nothing_supersedes_counts_toward_verdict_and_total. -
spend.report:totals,rows,undated,ingest_freshness,rate_staleness, andhierarchy_resolution(unavailable) when grouped byproject.groupingnames areprovider,model,account,auth_selection,charge_basis,work_class,project,producer,runner,harness,plan,plan_account,alfonso,parent_alfonso,workload,project_idandworkspace;grainishour,day,week,monthorrange;timezoneis an IANA name. Refusals:invalid_grouping(unknown or repeated),invalid_grain,invalid_timezone. Test:spend_report_refusal_keeps_its_code. Event exclusion reasons in spend, work-class and ledger coverage includeobserved_onlywhen a producer reported readings but no billed quantity. The work-class report's populations and producer labels are unchanged.Optional
from_msandto_msmust be supplied together, withfrom_ms < to_ms, or the read refusesinvalid_range. They select a half-open interval widened outward to whole buckets. Without them, day/week/month/range cover all history as before. Day buckets begin at the first existing instant of the local date; weeks begin Monday, and months begin on the first local date of the month. Day ranges are limited to 400 days after widening. Week/month requests are limited to 400 days before widening, with widening permitted to add less than one week/month bucket on each side. A supplied span over 400 days is alwaysrange_too_large. These limits use elapsed 24-hour days, not local-date counts. Hour buckets are UTC hours regardless of timezone, including across daylight saving transitions. Hour requires an explicit range and allows at most 744 UTC buckets after widening; otherwise it refusesrange_too_large. A 31-day interval with non-hour-aligned edges therefore needs shortening or alignment. Hour refuseshour_timezone_unsupportedif the timezone has any offset that is not an integral number of UTC hours anywhere in the widened range, including historical second offsets and fractional-hour daylight saving offsets.rangeselects the same local days asday, with the same 400-day limit and grouping and filter rules. It returns one row per group and currency instead of one per day. With explicit bounds, all rows share the widened request edges. Without bounds they span the first through last local day with selected usage, including future-dated days if the day report shows them. The range has no rows if the equivalent day report has none. Counts and money sum the day rows, retaining their daily rounding and fee allocation.deduced.by_rule_shareis never present because fees are not assigned by rule.totalsandattribution_coveragematch the equivalent day report. Test:spend_report_range_matches_daily_values_across_dst.runnergroups calls by the recorded runner (broca,thalamusorcolliculus); null identifies unmanaged calls. The label is recorded once, not derived from current session declarations.harnessnames the host loop: the event's harness forthalamus-harnesspayer rows, and its producer otherwise. A BROCA call therefore has harnessbroca, regardless of its event's harness field. Both dimensions supportwhere;{"runner":[null]}selects unmanaged calls.whereis an optional object mapping any supported grouping name to a nonempty list of strings or JSON null. Values are ORed within each dimension, dimensions are ANDed, and null matches an absent dimension, not an empty string. Filters need not be grouping dimensions. An unknown key refusesinvalid_grouping, just like an unknown grouping; an empty list refusesinvalid_filter. The recognized per-runtaskdimension still refusesdimension_unavailablein grouping and where. Unknown request members remainmalformed.undatedandrate_stalenessdescribe the selected population, so a ranged report's zero undated count does not claim the ledger has no undated events;ingest_freshnessremains global because it describes the sources.Attribution dimensions are
alfonso,parent_alfonso,workload,project_idandworkspace. Up to two distinct attribution dimensions may appear across grouping and where, with at most one ofmodelorprovider, whether grouped or filtered. Any other dimension combined with attribution, or using both model and provider, refusescombination_unavailable, naming the incompatible pair. Attribution supports the same ranges, calendar grains, exact quantities, recorded spend, list value and deduced cost as ordinary reports. Fees still use the whole unfiltered UTC day for each subscription pool; attribution filters select only row weights, never fee denominators.projectis the folder the call ran in, as recorded inproject_root; its existinghierarchy_resolution: "unavailable"is unchanged.project_idis the project the publisher named for the session, run or flow. It has nohierarchy_resolutionmember. Combining legacyprojectwith an attribution dimension is unavailable, not a request to translate folders into projects.A call joins its run fact first, then its session fact, then its flow fact. Session names meet through the runner's canonical reference and recorded aliases; runner labels are normalised for matching, not for reference computation. The newest unsuperseded fact supplies its owning
alfonsoand workload.parent_alfonsocomes from the launching subject's own winning fact. Workspace is the placement of that fact's project at the call's occurrence time. If none of those publisher facts matches, a BROCA call can use the daemon scope stamp on its export. A stamped flow joins the flow's publisher fact. A stamped agent suppliesalfonso, withparent_alfonsoandproject_idfrom the stamped run's publisher fact when known. The workload isbroca_sessionfor session segments and model attempts, andsystem_onefor System One calls, whose export does not name an operation. No task is inferred. If no publisher fact matches a Colliculus call, itscaller.agent_idsuppliesalfonsoonly. This is the app's stated value, not a verified identity or a permission. Device evidence is not an attribution dimension. Without matching publisher or fallback evidence, all five values are null (Not attributed). A known fact may itself name a null Alfonso, so a null Alfonso group alone does not prove that every call lacks attribution.A request grouping or filtering by attribution additionally carries
attribution_coverage: {attributed_calls, unattributed_calls}. These count dated calls in the selected range with its non-attribution filters, ignoring attribution filters. Their sum equals the ordinary report's dated call total for that population. When nonzero,stamp_disagreement_callscounts calls in the same population for which the winning publisher fact and either the BROCA stamp or the Colliculus caller name different agents. The publisher still wins. Even without a range, undated calls remain solely in the separateundateddisclosure. Ordinary requests omit attribution coverage. Tests:attribution_report_real_split_rows_keep_unattributed_and_all_metric_totals,attribution_report_randomized_groups_sum_to_ordinary_totals_with_identical_model_filters,attribution_report_filter_coverage_ignores_attribution_but_keeps_model_filter.Each row and each currency total additionally carries
tokensandunits. Tokens have optionalinput,output,reasoning,cache_read,cache_write,cache_write_5mandcache_write_1hinteger counts. Output includes reasoning using the Runs served-token rule: stored output plus stored reasoning, but output stays omitted when only reasoning was stated in that row or total. Reasoning is also a breakdown inside output. Cache write is all lifetimes together; the 5-minute and 1-hour fields are parts of that total. A role with no stated quantity is omitted, never invented as zero; a stated zero remains present. Exact fractional token sums are served only when they represent whole tokens, as on Runs reads. Counts include measurements regardless of pricing state or charge basis, including observed readings. Non-token units are a list of{role, unit, quantity: {units, exponent}}, with exact base-10 quantities and no floating-point conversion. Token-role measurements missing quantity are counted in optionalunknown_quantities: {role: count}on the row/total. For non-token units the count is an optionalunknown_quantitiesmember on the corresponding{role, unit}entry, whosequantityis omitted if none was stated. A count with unknown measurements is a lower bound. Totals aggregate stored roles before applying inclusive output, so they can include reasoning whose row omitted output. All new figures use hourly summary quantities for clean hours; dirty hours and UTC hours crossed by a local bucket boundary or UTC offset transition use the existing ledger fallback. Tests:analytics_unknown_quantities_are_not_measured_zero_on_either_path,analytics_tokens_and_exact_media_units_are_additive,analytics_widened_range_caps_and_calendar_edges,analytics_refusals_are_specific_and_read_only. Handler samples for range grain andreply_too_largeare incrates/astrocyte-module/test-vectors/analytics-reads-v7, pinned byanalytics_vectors_match_real_dispatch_and_sha256sums. The publishedanalytics-reads-v3throughanalytics-reads-v6sets are unchanged.Every row and currency total also carries
list_value, with{currency: "USD", nanos, unvalued: {measurements, tokens, by_reason}, not_yet_valued_hours}. It values positive measurements at the published USD API rates in force at each call, independently of recorded charge basis. Exact token line values are summed before one half-even rounding to nanodollars. Unit-billed measurements are valued per measurement, as they would be charged. Unusable positive measurements each count once underno_rate,refused,non_usd,missing_modelorvaluation_error;tokenscounts their token quantities. Zero quantities do not count as unvalued. Other valued measurements in the same call still contribute, except that a valuation error discards the entire call's partial valuation.not_yet_valued_hourscounts distinct UTC hours whose valuation is not current, not missing rates already fetched and known to be absent. List value is therefore an at-least figure. Bundled usage above a context threshold has no per-call prompt size: its tokens are valued at the base rate; the real cost may be higher. The optionalbase_rate_tier_untested_tokenscounter onlist_valuecounts those tokens and is omitted when zero, on rows and totals.tiered_bundleis not an unvalued reason.plannames the active subscription fee record's provider, including for a hand-recorded plan.plan_accountis that record's account or credential. Calls with charge basismetered_apiareapi. Other calls look up fee records by account first, or by paying credential when there is no account, preferring the resolved credential to the selected credential. No active record givesnone; more than one active record givespool_conflict, still valued but never a fee weight. Those labels have nullplan_account.account_unknownis no longer used. A plan with multiple quota pools still has one membership and its fee is counted once. Unlike the multiplier, hourly grouping uses fee records rather than vault plan history. Both dimensions work ingroupingandwhere, including null filters. When grouping or filtering by either dimension, unbuilt or stale valuation hours retain recorded spend underplan: "pending",plan_account: null. Otherwise their recorded rows are unchanged and their hours count innot_yet_valued_hours. A summary-dirty hour uses the same per-call valuer and membership resolver as the builder; an unfetched rate timeline leaves that hour pending. Calendar seams use the same bounded per-call path. These figures never change recorded spend,total_nanosormetered_nanos.Rows with USD or no recorded currency additionally carry
deduced:{currency: "USD", nanos, pending_days}. It is recorded spend plus the row's exact share of USD subscription fees, rounded once half-even. Fees come only from account/credential plan records, prorated over UTC calendar days of the plan's month or year and over partial-day membership. Each record spreads its fee over its own calls' list value. Without positive weight the fee stays unspread; it is not allocated to calls lacking a matching record. Day denominators always cover the whole UTC day, unfiltered; row numerators cover only matching calls. A day is pending if it has not ended or an hour holding the record's calls is not current; pending fees are neither spread nor unspread.pending_dayscounts distinct pending UTC days touching the row. A dirty summary is never a built valuation hour even when its live row can be valued. While an hour awaits valuation, non-metered NULL-account summary cells without a retained resolved payer conservatively defer a fee spread if a credential plan could match. This can delay a spread until the builder reaches the hour, but cannot assign a fee to the wrong calls.Summed row
deducednanos match the USD total within one nanodollar per independently rounded row (the day rows before folding forrange). The exception is a USD fee share assigned to a call whose recorded currency is neither USD nor null: only the USD total counts that share.Only the USD currency total carries
deducedand the fee diagnostics:deduced_unspread_nanos,deduced_non_usd_plans,deduced_conflict_plans. Unspread fees are prorated to the report window's overlap with the plan's active part of each UTC day and rounded once. A filter onplanorplan_accountrestricts them to matching records; a filter on any other dimension omitsdeduced_unspread_nanos. Non-USD plans contribute no fee and count indeduced_non_usd_plans; records mapping to multiple pools count indeduced_conflict_plansand their USD fees go directly to unspread. Totals aggregate exact values and distinct pending hours/days across rows before rounding. Non-USD and null-currency totals carrylist_valueonly. When USD fees exist but no USD calls match, an additional USD total has zero recorded spend and exposes those fees; no such entry is added without USD fees. With explicit dates, the fee window is the widened report window. Without dates, it starts at the first calendar bucket holding any dated summary hour and ends at the end of the bucket holdingnow_ms; with no dated hours it covers just that current bucket. Plans before the ledger's first bucket do not contribute, but fee days after its last call still do. If the ledger's first bucket is after the current bucket, the fee window is empty; recorded spend and list value are still returned. Tests:report_surface_plan_grouping_filters_and_unfiltered_fee_weights,report_surface_pending_hours_preserve_recorded_spend_and_distinct_counts,report_surface_dirty_fallback_matches_built_across_five_timezones,report_surface_existing_members_are_byte_identical,report_surface_range_free_fees_cover_empty_ledger_and_days_after_last_call,report_surface_currency_totals_expose_fees_once_and_do_not_add_empty_usd,report_surface_bundle_counter_is_served_in_rows_and_totals. -
spend.subscription.reportkeepsrows,coverageandingest_freshness.rowslists account plans only. The additivecredential_rowslists covered usage of credential-keyed plans as{provider, credential_ref, period_start_ms, period_end_ms, plan_cost_nanos, covered_events, covered_measurements, quantities}, and the additivecoverage.events_covered_by_credentialcounts the account-less events those plans cover. Such events are not counted incoverage.events_unpriced;coverage.events_without_accountstill counts every dated event with no account. Hours holding a fully priced account-less subscription call on a provider with a credential plan in force are read from the ledger rather than the hourly summary. Tests:vault_key_only_plan_covers_past_calls_by_paying_credentialandcredential_plan_seams_only_hours_with_covered_account_less_calls. It adds optional diagnostic members; the request remains{}, so the params schema stays at version 2.unpriced_planslists{plan_key, provider, plan_tier, accounts}for exact vault keys without a usable sourced price.providerandplan_tierretain the vault's raw spelling, andaccountscontains account IDs, or vault record IDs for credential-keyed plans. The owner of the price catalog (the fusiform module) reads this list to find tiers that still need a sourced price.unknown_planslists records without exactly one provider and a tier, with a nullplan_key.hand_vault_differenceslists{provider, account_id, ledger_plan, vault_plan}; the hand-recorded ledger interval is never changed by the vault.vault_record_differenceslists disagreements between records sharing an account, withprovider,account_id,records,winning_planandambiguous. The latest effective observation wins; equal-time disagreements have no winner and cannot change the ledger. Records includecredential_id,provider,account_id,plan_tier,plan_key,source,effective_from_msandobserved_at_ms.chatgpt_account_mismatcheslists{credential_id, account_id, account_refs}where subscription calls attributed to that OpenAI credential carry a different account reference.invalid_plan_tier_since, omitted when empty, lists{credential_id, reason}for ignoredplan_tier_since_msvalues in the latest successful listing. Reasons arenot_non_negative_integerorafter_observed_at; affected rows still use the observed timestamp, or the first observation when it is absent.vault_read_statusis{status: "not_read" | "available" | "unavailable"}, with a safereasonon failures; it is process-local and resets on restart.plan_price_statusisavailableorunavailable, independently of the vault read. A failed vault read changes no recorded plans or history. Tests:vault_hand_plan_is_untouched_and_difference_is_reported,vault_unpriced_raw_tier_is_reported_and_later_price_records_planandvault_shared_account_uses_latest_record_without_tick_order_churn. -
spend.workclass.report:rows,producers. -
spend.ledger.coverage:set_aside_by_source,skipped_local_by_source,events_total,events_unpriced,events_undated,zero_measurement_events,unpriced_events_by_reason,unpriced_measurements_by_reason,broca_segment_usage_mismatches,ingest_freshness,rate_staleness,capacity. Test:open_coverage_report_does_not_stall_an_ingest_commit.skipped_local_by_sourceis always a map of producer keys to counts of local work acknowledged without spend events; it is empty when no work was skipped. Test:media_skipped_local_coverage_is_live_on_base_and_hourly_paths.broca_segment_usage_mismatchescounts marked BROCA segments for which any reported usage quantity differs from the sum of attempt shares naming the segment. The refresher checks a bounded batch per tick and waits until a segment has been in the ledger for more than an hour, giving its attempts time to arrive. It records each differing role and unit once; an unreported quantity is distinct from zero. This is a consistency check, not a pricing input. Optionalthalamus_payerreports lifetime counts of distinct identities:transcript_calls_without_payer(timeout or queue overflow),late_payer_rows,unmatched_main_rows,set_aside_payer_rows,owner_disagreements(the owner Thalamus's roots file declares for a session differing from the owner on its payer session row) andcache_split_mismatches(well-formed main cache-write splits that disagree with one another or do not match a transcript cache-write total). These counters include explicit zeroes when payer coverage is present. Replays do not increase them. Its additivewaiting_calls_by_readermap reports current process-local queue lengths by reader source key, including explicit zero after a queue drains. A restart clears these gauges until readers replay their transcripts; it does not clear the lifetime counts. Tests:payer_coverage_counts_exceptions_once_and_reports_live_waits,thalamus_payer_coverage_is_live_on_base_and_hourly_paths. -
spend.charge.explain:event,measurements,adjustments,transition. BROCA calls also carrymode_sourcewhen a non-standard mode was selected for pricing:servedif the attempt stated a served speed or tier, orrequestedif neither was reported and the requested tier was used. Each measurement suppliesroleandunit; its charges are identified bypricing_generationwithin that measurement. There is nocharge_idfield.supersedesis the predecessor's pricing generation (null for an original), not an integer storage key. Event IDs are unchanged and no local keys are served. Refusals:malformed(emptyevent_id),not_found. -
spend.reconcile:statement,lines,summary. Refusals:malformed,statement_not_found; a store failure isstore_error. -
spend.multiplier.report: migration 68 introduced per-pool observations. For each quota provider,latestshows the unsuperseded, unretired pool rows of its newest recorded day, one per(quota_provider, plan, pool_id). An empty day yields no rows for that provider. An unmeasured row still appears;latestdoes not fall back to an older day.last_eligible, when available, gives the newest eligible, unsuperseded head for the same provider, plan and pool as{day, interval_end_ms, multiplier, fee_multiplier}. This value can come from before migration 68, but those rows never appear inlatestthemselves.seriesshows unsuperseded, unretired rows withinterval_end_msin[from_ms, to_ms). Historical rows appear there only for keys without pool observations since migration 68. Refusal:invalid_range(from_msnegative or not beforeto_ms).pool_idis insula's slot name (primary,secondary,tertiary) or the raw ID of an extra window, not its storedwindow_pool_key. A historical row can have a nullpool_idif its stored key has no stable identity.pool_scopeisall,subset, orunknownwhen there is no single stated scope; it is null on historical rows.catalog_provideris the catalog provider the readings agree on, or null; it is distinct from the insulaquota_provider.pool_modelsis the served subset list asprovider/modelIDs, or null when there is no list.pool_models_at_msis the day-endingplan.priceslookup instant for a subset, even if its list is missing; otherwise it is null.pool_member_modelsrecords raw IDs admitted through suffix removal or alias resolution; it is null ifpool_modelsis null.window_minutesis the newest positive duration (the larger duration if readings share that instant). Named and extra windows for the same login and pool ID are treated as one pool.Reasons
scope_unstated,scope_changed,window_changed,pool_list_missingandpool_reading_conflictmark rows whose ratios are null and whoserouting_eligibleis false. Their zero token counts,api_nanos,subscription_nanos,fee_paid_nanos,delta_percent, quality shares and usage and login counts, and empty usage and login diagnostics are placeholders, not measured zero usage.pool_reading_conflictmeans readings for the same instant disagree between aliases of the same pool. It does not suppress other pools.window_tiealso has null ratios and is ineligible, but its other measurements are computed normally. A recompute usespool_retiredto supersede a pool that dropped out of that day. Retirement heads are not served inlatest,series,last_eligible, pace or the bus.Rows retain
routing_eligible,eligibility_reasons,clean_hours_share,saturated_share,gap_share,unpriced_share,unconfigured_accounts,source_backlog,unattributed_event_share,zero_measurement_events,missing_quantity_eventsand the derivedunknown_quantity_measurementscount. Missing-quantity and no-measurement usage exclude account-hours; neither their counts nor their share independently veto a row. Retained sample adequacy and stability govern eligibility. Saturation keeps its separate veto. Quality shares are fractions of the login-hours under consideration for the row's plan and pool; unpriced diagnostics also include excluded hours. Historical rows retain their old values, including a null plan on older rows pooled across plans.fee_api_nanosis thefee_multipliernumerator: API list value of the pool's calls in every hour of the interval, whereapi_nanoscovers clean hours only. It has no per-model split, and it's omitted on rows recorded before it was stored, which never means zero. The bus copy of each row carries it too.api_nanos_by_model[].ratesmay include an optionalconditionalmap for complete token condition sets, including lifetime-only rows and combined lifetime, mode and context-tier rows. Its keys are rate keys with selectors sorted by name. It is omitted when empty; older rows decode with an empty map. A supported billing rule is stored at its role and condition as{"state":"billed_as","key":"rate.output"}for reasoning, or withrate.input(including its named context-tier key) for cache writes.stability_diagnosticsadds the recorded day-block bootstrap interval/width, active-day count, held-out-day six-hour RMSE/R² and resampling parameters; older rows without calibration inputs return null there. Adequacy uses clean hours/points, active days and interval width, not a clean-, gap- or unknown-share floor. -
spend.multiplier.pace: hourly usage by producer and work class, valued at the selected head's recorded rates without a catalog call. Optionalplanandpoolselect a plan key and apool_id. Candidates are eligible, unsuperseded pool heads ending in[to_ms − 2 days, to_ms]; historical and retirement rows do not qualify. Withoutplan, candidates spanning more than one plan refuseplan_required. Withoutpool, candidates in the selected plan spanning more than one pool refusepool_required. A pool can qualify even if it is absent from the provider's newest day. The newest candidate of the selected plan and pool supplies the estimate; the reply namesplanandpool_idand setsrouting_eligible: true.Pace counts calls with charge basis
subscription_includedorunknownonly when the login held the selected plan at the time of the call. Calls markedmetered_apido not count. Anallpool includes every qualifying call. Asubsetpool includes only rawprovider/modelIDs in the head'spool_modelsorpool_member_models. Pace cannot resolve new aliases or strip suffixes offline: a raw ID that only matches by such a step must already be inpool_member_models. Other refusals:unknown_quota_provider(no observation since migration 68),no_multiplier_observation(no eligible candidate for the selection),invalid_rangeandrange_too_large(over 192 aligned hours).
Absent values are null or omitted, never zero. A total that cannot be
priced is reported with its unpriced population, not as a smaller number.
These two operations serve harness steps per session, with cache verdicts.
A harness is a producer whose events are one
model step each: claude-code, codex, gemini, kimi, omp, opencode or
pi. BROCA steps will arrive from its step log, not its exported spend facts.
A request that fails to decode is refused malformed, as everywhere
else. A request that decodes is refused with one of these codes:
| Code | Condition |
|---|---|
invalid_request |
limit is 0, session is empty, or since_ms is negative. |
unknown_harness |
harness is not one of the harnesses above. |
range_too_large |
limit is above its maximum, or since_ms is more than 7 days before now. |
usage.cache.steps returns up to limit steps of one session (default 200,
maximum 1,000): the newest ones, oldest first. With after_cursor, only the
steps of that window whose cursor is greater are returned. The reply has
harness, session, steps, earlier_steps (whether the session has older
steps than the window) and undated_steps (steps without a time, which are
not placed on the timeline). Each step has these fields:
cursor, the durable cache-step cursor. It increases across harness events, survives restarts and is never reused. A late step can have a greater cursor than a step that happened after it.step_ref, the harness's own id for the step, andoccurred_at_ms. BROCA's step-log reader will use the event'sattempt_id, a random id per provider attempt, as described in section 4.2.input,cache_read,cache_write,outputandreasoning, each omitted when the reader did not store it.cache_writesums every cache lifetime Claude Code reports.outputincludes reasoning, the fleet convention:reasoningis a breakdown insideoutput. The ledger stores the two disjoint, and a served row adds them:outputis the stored output plus the stored reasoning when both are present, the stored output when reasoning is absent, and omitted when no output was stored. A count is never made up from reasoning alone. Test:served_output_includes_reasoning_on_both_reads.provider,model,finishandcontext_limit.finishcomes from OpenCode'sfinish, Pi'sstopReason, or the stored stop reason of Claude Code and Oh My Pi.context_limitcomes from Codex.request_body_lenis optional and is not populated by the current readers. On a prompt drop,request_sizeis present when both adjacent steps report body lengths:smallerwhen the current body is shorter, otherwisenot_smaller.prompt, which is input plus cache read plus cache write.retention,verdictandprompt_dropped.retentionis served unrounded and unclamped: a non-negative number that may exceed 1 when a step reads more cache than expected.cause, omitted when there is no stored explanation. This is the feed's persisted rewrite cause, looked up by(harness, step_ref), not a guess computed from ledger rows. The cause is kept forever, including after its evidence and live feed row expire.account_ref,warm_up,view_version,tools_digest,system_digest,signed_floor,started_at_ms,finished_at_ms,cache_ttl_msandcache_implicitare the feed's event-only rewrite evidence, with the same meanings as in section 4.2. They are read by(harness, step_ref)for 30 days from when the step first reached the feed, independently of the live feed's one-day window. Each member is omitted when unknown or expired, never defaulted. A retainedview_changedcause therefore includesview_versionwhile that evidence is kept, but can outlive it.
The verdict is one of cold_start, stable, warning, bust, full_bust
and unknown. It is computed over the whole session in time order, so a
step's verdict does not depend on the page size. The rules are the Magic
Context dashboard's:
- A step without a stored cache read is
unknown. It is also never the baseline the next step is compared with. - In a session where no step ever read a positive number of cached tokens,
every step is
unknown. Codex is the exception. - The session's first step is
cold_start. - Otherwise, the step is compared with the last earlier step that reported its
cache. When there is none, or that step read zero, the verdict is
stablewith noretention. Otherwise,expectedis that step's cache read plus its growth, which is its cache write when positive and otherwise its uncached input.retentionis this step's cache read divided byexpected. - Codex reports no cache writes, so its
retentionis the cache read divided by the cache read plus the uncached input. When that sum is zero, the verdict isunknown. - A cache read of zero is
full_bust. Otherwise, aretentionof at least 0.95 isstable, at least 0.80 iswarning, and anything lower isbust. prompt_droppedis true whenpromptis at least 15,000 tokens smaller than that earlier step's prompt.
The serving side keeps the newest 1,000 steps of up to 200 sessions active in
the last 24 hours in memory. It loads them at startup and adds each commit's
new steps after the commit. A request it can answer exactly is answered from
memory, and any other request is answered from the store. Both build the reply
the same way. Tests: drained_pi_steps_are_served_alike_from_memory_and_store,
store_steps_are_the_same_whatever_the_window,
prefix_cache_verdicts_cover_every_band_and_edge.
The memory window is distinct from storage retention. BROCA diagnostics are kept for 30 days after the step finished, with at most 500 expired rows deleted per maintenance transaction. Harness ledger steps are kept indefinitely.
Sample replies, published for a client to pin its decoder against, live in
crates/astrocyte-module/test-vectors/usage-cache-steps-v1/, with the request
that produced each one. The step cursor is the cache-step cursor, a
different cursor space from the live feed's cN cursors: it numbers recorded
steps in their own order, so two rows with the same number in a cache read and
a feed read are not the same step. To join a session's history with
the live feed, an app matches rows by (harness, step_ref) and replaces its
stored copy of a matched step with the newer row, and never compares a
cache-step cursor with a feed cursor.
usage.cache.sessions returns since_ms (default: 24 hours ago) and
sessions, the harness sessions with a step at or after since_ms, most
recently active first. There are at most limit sessions (default 50, maximum
200), optionally for one harness. Each session has these fields:
harnessandsession.project_root, from the newest step in the window that has one.steps, the number of steps in the window.hit_ratio, which is the cache reads divided by the sum of input, cache read and cache write. Only steps that report their cache count, and the field is omitted when there are none.busts, the number of steps whose verdict isbustorfull_bust.last_activity_ms.context_limit, the newest positive context limit in the window.
It is always read from the store. Test:
sessions_report_hit_ratio_busts_limit_and_activity.
Apps follow cache diagnostics live through two operations: a subscription
that only says new steps exist, and a paged read that returns them. Apps talk
only to astrocyte. Astrocyte combines the steps it reads from harness files
with the step.finished.v1 events agent runners publish on the bus. A step a
runner announces is in the feed within seconds; billing still comes only from
the durable reads.
Who may call. The daemon-attested principal at route bind decides:
Principal::Direct (local apps on the same computer) and reserved:callosum
with the person's phone or desktop as the device label (fed-phone:<fingerprint>
or fed-app:<fingerprint>). Every other
principal is refused not_permitted, simulators (fed-sim:) and other
computers (fed-computer:) included.
Astrocyte declares usage.cache.steps, usage.steps.read and
usage.steps.subscribe to Callosum for paired phones and desktop apps, and
usage.cache.sessions for paired desktop apps only; spend reports stay on
this computer.
Cursors are opaque strings. They are ordered by astrocyte's commits, are stable across restarts and are never reused. Apps pass them back and never parse or compare them.
Order rule for apps. Subscribe first and hold the notices, read history
with usage.steps.read, then read again from the read's through. After a
reconnect, read once more a few seconds later: a step that has just finished
can take a few seconds to be committed.
The request is {} or {"harness": "pi", "session": "session-id"}.
harness and session are optional, but must come together; one alone is
refused invalid_request. Unknown members are refused malformed.
Each notice is one StreamData frame:
{"through": "c1824004"}through is the newest committed cursor. Notices are coalesced: at most four
a second, and a notice may cover many steps or none that the caller may see.
With a session filter, a notice is sent only when a row whose own harness
and session match exactly is appended. Its through is the feed-wide cursor
committed with that row; later unrelated rows do not advance it, so it may be
older than the feed's newest cursor. A caller reads after its own last cursor
with the same filter, so this changes nothing it needs. Without a filter,
notices are unchanged.
| How it ends | Meaning |
|---|---|
| StreamEnd | Astrocyte is stopping or the route closed. Subscribe again. |
Error lagged, detail {"through": "<last notified cursor>"} |
The subscriber fell behind its queue bound. Subscribe again and read from the last cursor it holds. |
| Caller's Cancel | Ended by the caller. The caller may still receive Error cancelled (the daemon may drop it) and treats it as the normal end. |
Opening refusals: not_permitted, subscription_capacity (the shared limit of 16
open step and Runs subscriptions), draining (astrocyte is stopping), malformed, and
invalid_request (only one filter member was supplied).
The request is {"after": "<cursor>", "limit": 200, "harness": "pi", "session": "session-id"}.
All members are optional. harness and session must come together; one alone
is refused invalid_request. Unknown members are refused malformed.
Without after, the read starts at the oldest row the feed still holds. The
feed holds the rows committed in the last 24 hours. limit defaults to 200,
with a maximum of 1,000.
With a session filter, only rows whose own harness and session match exactly
are returned, still excluding superseded identities. limit bounds the rows
returned, not the unrelated rows between them. through remains the newest
cursor across the whole feed. next is the last returned row's cursor while
more matching rows exist up to through, and null when no matching rows remain.
A filtered page is never empty with a non-null next. Cursor expiry is unchanged.
Without a filter, the read and its reply are unchanged.
Reply:
{
"rows": [
{
"cursor": "c1824003",
"harness": "opencode",
"source": "file",
"step_ref": "msg_0a1b2c3d4e5f",
"session": "ses_0a1b2c3d",
"occurred_at_ms": 1792880000000,
"provider": "anthropic",
"model": "claude-sonnet-5",
"input": 1200,
"cache_read": 182000,
"cache_write": 900,
"output": 640,
"reasoning": 120,
"finish": "tool-calls",
"prompt": 184100,
"retention": 0.9912,
"verdict": "stable",
"prompt_dropped": false
}
],
"next": null,
"through": "c1824004"
}rowsare oldest first.nextis the cursor to pass asafterfor the following page, or null when the reply reachedthrough.throughis the newest committed cursor.- A row's identity is
harnessplusstep_ref. When any field of a step changes (a runner-announced step recorded from its log, a finish reason that arrives late, or a verdict recomputed because an earlier step of its session arrived late), the whole row is sent again at a new cursor. The last row for an identity wins: apps replace, never append.
Runner rows are served: a row from a runner's step.finished.v1 event takes
its identity from the event. When the event carries harness_step_ref (runner contract 14.3,
present for runners whose history is the host harness's own record),
harness is mapped through cortexkit-usage-steps' host table (opencode2
is served as opencode), and step_ref is harness_step_ref, so
astrocyte's later read of the harness store replaces the row. An unmapped
host is counted and dropped. Without harness_step_ref,
harness is the event's runner and step_ref is the event's attempt_id, a
random id per provider attempt. Retries reported as separate steps have their
own rows, matching astrocyte's read of that runner's durable step log. Refused
attempts listed in a step's fallback do not create separate runner rows. A
step with no durable record stays a live-only row with source: "runner".
sourceisfilefor a step astrocyte read from a harness store or a runner's durable log, andrunnerfor a step known so far only from a runner's bus event.harnessis the producer:claude-code,codex,gemini,kimi,omp,opencode,pi, or the runner's module id (broca,thalamus-harness,thalamus).- Required:
cursor,harness,source,step_ref,session,occurred_at_ms,prompt,verdict,prompt_dropped. Steps without a time are not in the feed. - Optional, omitted when unknown and never zero for unknown:
message_id,run_id(runner steps),provider,model,input,cache_read,cache_write,cache_write_5m,cache_write_1h,output,reasoning,finish,context_limit,request_body_len,retention,request_size,started_at_ms,finished_at_ms,account_ref,cache_ttl_ms,cache_implicit,cache_chain,warm_up,view_version,tools_digest,system_digest,signed_floor,cause. started_at_msandfinished_at_msare the event's request start and completion timestamps, not a reinterpretation ofoccurred_at_ms.account_refis the runner contract's domain-separated SHA-256 reference to routing's admitted account and credential, never their raw ids.cache_ttl_msis the shortest cache-breakpoint lifetime;cache_implicitis true for a cache whose lifetime cannot be proved and is never emitted false.warm_upmarks a keep-warm request. Unknown is always omitted.cache_chainreports whether the runner extended the provider's server-side conversation chain:{"continued": true}or{"continued": false}with an optionalreason. A reason matching^[a-z0-9_]{1,64}$is passed through verbatim; an invalid reason is omitted without losingcontinued. An absent chain report omitscache_chainand does not meancontinued: false. The field is kept only in the 24-hour feed and is never present on a file row. Pinned read and subscribe samples are incrates/astrocyte-module/test-vectors/usage-steps-cache-chain-v1/.view_versionis the applied compaction view (last_prompt_view), where zero means no applied view.tools_digestandsystem_digestare opaque runner-local visible-ASCII digests of provider inputs, ignoring cache markers.signed_flooris the stable entry id of the newest boundary before which the runner invalidates earlier signed reasoning after a prompt-prefix change, such as a changed tool definition. Event evidence is retained for 30 days from when the step first reached the feed and remains on the file row when a durable read replaces a runner row. It is never reconstructed from ledger rows, and repeated digests are interned rather than copied per feed emission.causeis computed bycortexkit-usage-steps0.2.8 forwarning,bustandfull_bust, in precedence order:account_or_model_changed,cache_expired(busts only),tools_or_system_changed,view_changed,signed_floor_moved, thenunexplained. Missing facts skip comparisons. For expiry, Astrocyte checks the eight latest Thalamus keep-warms mirrored for the same harness and session with a recorded time between the previous step's finish and the current step's start, and uses the latest positive cache read as the last cache touch. The predecessor is the same harness/session's previous distinct step from the same runner, warm-ups included, ordered by request start (occurrence time when unknown), with first feed cursor breaking ties. Steps with no runner identity compare only with other such steps. Late steps and replacements also recompute the following step's cause. If late evidence changes a step's comparison runner or request start, the successor at its old position is rejudged as well. Changed explanations append a new feed row and notify subscribers through the existing cursor notices; subscriptions carry no row payload. Cause history is append-only and kept forever, independently of its evidence.usage.cache.stepsserves the newest stored cause even after live feed retention expires; no cause means the member is omitted, notunexplainedby default.
Synthetic samples for usage.cache.steps and usage.steps.read are pinned in
crates/astrocyte-module/test-vectors/usage-cache-causes-v1/ with SHA256SUMS.
They cover every cause and a row without one. The strict llm-runner 0.9.6
step-event decoder accepts the optional fallback record; older pinned runner
events remain valid.
message_idis a content-free message identifier: on a file row the host's own, on a runner row the one the runner serves for that message. It is present only when the host or runner has one and is never invented. Consumers join onharnessplussessionplusmessage_id, not onmessage_idalone: it is unique only within its session.harnessplusstep_refremains the row identity; consumers must not parsestep_refto recover a message id, because its format is not promised. OpenCode 1 and 2 (including THALAMUS stores) use the message'sid; Pi uses the assistant entry'sid; Claude Code usesmessage.id; Gemini CLI uses the message'sid; Kimi CLI usesStatusUpdate.payload.message_id. Codex has turn and response ids, Oh My Pi has entry and response ids, and Goose has session totals, so none supplies a message id here. Pi operation entries are not messages and omit it too. A runner row carries the step event'smessage_idwhen the runner sends one: the id the runner serves for the assistant message the step's reply was placed in. A runner row without one omits it, and it is never derived fromstep_reforharness_step_ref. A file row that replaces a runner row serves its ownmessage_id, or none. Previously recorded rows are not backfilled; they remain without the member and age out of the 24-hour feed.outputincludesreasoning, which is a breakdown inside it, as in section 4.1, andcache_writeis the sum of every cache lifetime.cache_write_5mandcache_write_1hare present only when the source split them.prompt,retention,verdict(cold_start,stable,warning,bust,full_bust,unknown),prompt_droppedandrequest_size(smaller,not_smaller) follow the rules in section 4.1 exactly. They are computed over the step's whole session in time order. The thresholds 0.95 and 0.80 and the 15,000-token prompt drop are part of this contract's version.- Rows never carry prompt text, tool names or error text.
Refusals: malformed (undecodable, or an unknown member), invalid_request
(limit is 0, or after is not a cursor astrocyte issued), range_too_large
(limit above 1,000), cursor_expired (after is older than the feed holds;
detail {"through": "<newest cursor>"}: reload per-session history with
usage.cache.sessions and usage.cache.steps, then read from through), and
not_permitted.
- The feed is the
step_feedtable (see the data model). After each commit that adds steps or changes a step's stored detail, astrocyte recomputes the served rows of each affected session, from the earliest changed step onward, and appends every row that differs from the newest row stored for itsharnessandstep_ref. That append is its own transaction, run after the commit that recorded the steps; subscribers are told only once it has committed. A cursor iscfollowed by the row's feed position. - A step that happened more than 24 hours before it is committed (a first
read of old history) is not added to the feed;
usage.cache.stepsserves it. Rows become eligible for deletion 24 hours after they were committed; each feed append deletes up to 1,000 of them, so a cursor stays readable until the deletion reaches it. Pruning stops at the oldest live row, even when a backward wall-clock step made later cursors expire first. - Runner rows come from the
step.finished.v1events of the runners the bus naming table grants astrocyte; today those arebroca,thalamus-harnessandthalamus. Astrocyte follows each runner's own subject,ck.<account>.live.<runner>.step.finished.v1, with a plain subscription and no durable. The subscriptions share the quota reader's single ckbus credential and NATS connection, and they run whether or not insula is configured. A row is appended as soon as the event arrives, and subscribers are told once it is committed. Runner rows are display data only: nothing from an event reaches the spend ledger. - A runner row's
prompt,retention,verdict,prompt_droppedandrequest_sizeare computed by the same rules as a file row's, over the session's recorded steps and its other runner rows. When an event reports a refusal fallback, the row keeps the answering model and subtracts refused attempts from each token counter before computing prompt and cache diagnostics. A counter is omitted if the step or any refused attempt omits it. If the sum of refused attempts exceeds the step's counter, the row keeps the reported step value for that counter. A fallback without refused attempts (cause: "round") leaves the counters unchanged. A runner's first positive cache read in a session can append corrected verdicts for earlier retained runner rows.run_id,cache_write_5mandcache_write_1hare sent only on runner rows.outputincludesreasoningunless the event says reasoning is outside it. - When the feed's newest row for the identity is a file row, astrocyte drops the runner event, because the durable read is the step's record. When it is the same runner row, the event is a duplicate and is also dropped. A later file row for the same identity replaces a runner row. An event that does not decode, or whose subject names a different runner than its body, is counted and dropped. So is a step that finished more than 24 hours ago. If the bus is unavailable or refuses the subscription, astrocyte logs it once and retries, and no new runner rows arrive; runner rows already appended stay served until a feed append prunes them. Quota events are not affected.
- The device label is the route's bind identity
harness(fed-phone:<fingerprint>orfed-app:<fingerprint>), as Callosum stamps it; the principal must bereserved:callosumas well. - A subscriber's queue holds 64 cursors. A subscriber whose notices are held
up for longer than that ends
lagged. - The serve helper always answers a cancelled request; a cancelled
subscription's last frame is the error
cancelled, which the daemon may drop because the caller asked to stop.
Tests: a_notice_is_sent_only_after_its_steps_commit,
reads_page_through_the_feed_in_commit_order,
a_verdict_changed_by_a_late_earlier_step_is_sent_again,
a_read_from_beyond_the_window_is_refused_cursor_expired,
the_feed_is_refused_to_simulators_computers_and_other_modules,
a_subscriber_that_falls_behind_its_queue_ends_lagged,
a_drain_ends_every_step_subscription_before_goodbye,
two_subscribers_both_receive_a_notice,
each_runners_event_is_served_as_a_runner_row,
a_file_row_for_the_step_supersedes_the_runner_row,
a_runner_event_after_the_file_row_leaves_the_file_row_newest,
an_undecodable_event_is_counted_and_dropped,
a_runner_rows_verdict_matches_the_file_row_that_replaces_it,
a_runner_row_wakes_its_sessions_filtered_subscription,
bus_reader_without_insula_serves_runner_step_events.
watermark.get tells a module how far astrocyte has durably read the logs
that module writes, so the module can erase logs that have been recorded.
Astrocyte declares the capability in the manifest's capabilities.provides.
The names and wire types are the watermark module of
cortexkit-role-llm-runner (0.7.1, contract §9.15).
- The request is
{}; any member is refusedinvalid_params. - Astrocyte answers for the principal the daemon attested when the route was bound, never for a module the request names. It forgets that principal when the route goes or the connection ends.
- A module principal maps to its session reader. Today the only row is
thalamus-harness→opencode-thalamus(the THALAMUS sessions contract §4). - Reply
{"watermark_ms": <u64>}, the minimum of the storedopencode-thalamusandthalamus-payerpass watermarks, read in one snapshot on the read-only connection;{"watermark_ms": null}(present, not omitted) until both sources have committed a complete read pass. Each payer pass uses its start minus 60 seconds and advances only after all mirror pages commit; a full pass that finds no payer store publishes the same safe empty-pass watermark without creating a runtime row or changing health. Fast absent-store checks do not advance it. Whenthalamus-payeris excluded, its component is ignored and the session source's value is served alone. Health timestamps and waiting queues do not determine this value. See the payer contract §4. - Refusal
not_a_read_source: the caller is not in that table (a local app'sDirectprincipal, any other module), or its source is excluded inharness_ingest(named inexclude, orenabled: false).
Tests: watermark_get_answers_thalamus_harness_as_the_crate_vectors_pin,
watermark_get_refuses_every_caller_astrocyte_does_not_read,
watermark_get_refuses_thalamus_while_its_source_is_excluded,
the_bind_principal_is_forgotten_when_the_route_or_connection_goes,
manifest_provides_the_log_read_watermark_capability.
The minimum and rollback rules are covered by
watermark_requires_both_committed_passes_and_serves_the_lower_value.
Absent, excluded and newly appearing payer stores are covered by
payer_watermark_absent_store_full_pass_serves_session_progress_without_a_lane,
payer_watermark_excluded_source_serves_only_session_progress and
payer_watermark_store_appearing_after_absence_cannot_pass_its_uncommitted_first_row.
These reads serve machine-wide session, BROCA run and BROCA flow costs from the
ledger, never from client-side pricing. They share the live feed's admission
check: Principal::Direct and reserved callosum routes with a fed-phone:
or fed-app: identity harness. Every other caller is refused not_permitted before operation-specific parameters are decoded.
Each reply is the response frame's result, read from one SQLite snapshot.
Keys are closed tagged objects:
{"kind":"session","harness":h,"session":s}:(producer, session), not the ledger's optional hosting-harness attribution. Harnesses areopencode(both versions),claude-code,codex,pi,gemini,goose,omp,kimi.{"kind":"run","harness":"broca","run_id":r}: BROCArun_ref, verbatim.{"kind":"flow","harness":"broca","flow_id":f}: BROCA batchflow_ref.
Run rows also carry session when any fact of the run records its label, even
if that fact is outside the requested range. It is absent for unlabelled runs;
no label is fabricated and no run is dropped. Flow rows carry work_class when
recorded; no additional flow-launcher identity is inferred.
usage.runs.list request: {from_ms, to_ms, harness?, limit?, after?}.
The half-open range must satisfy from_ms < to_ms and span at most 31 days.
limit defaults to 50 and must be 1–200. harness filters the key's harness.
after is the opaque next from a previous page with the same range/filter.
Reply: {rows, totals:{rows, steps, tokens, cost}, next?}. Range totals are on
every page and cover the entire filtered range. Each row is
{key, first_at_ms, last_at_ms, steps, tokens, cost, pricing_unit, models};
models are {provider, model, steps, tokens, cost} splits of exactly the same
figures. Missing provider/model identity is null. Every figure counts only
facts with occurred_at_ms in the range. Undated facts are not listed.
Rows sort by newest last_at_ms, then canonical key; the cursor resumes after
that pair. next is absent on the last page. A concurrently active key may move
to the first page: restart paging on a feed notice rather than merging snapshots.
usage.runs.detail request: {key, limit?, after?}. limit defaults to 200
and must be 1–1000. Reply: {key, pricing_unit, items, totals:{tokens,cost}, next?}.
Totals cover the entire key, not just the page or the list's time range. Items
sort oldest first, with undated (occurred_at_ms: null) items first and stable
ledger order for ties. Harness items are
{step_ref, occurred_at_ms, provider, model, measurements}: step_ref is the
verbatim producer reference also used by the feed for step-based harnesses.
Goose's reference identifies its accumulated session event, not a feed call.
BROCA attempt items carry a step_ref identifying the attempt share in the
ledger, not its live feed step id. Other BROCA items carry segment_ref, the
fact id.
Pricing units are step for ordinary harnesses and BROCA runs with any attempt
calls, run_segment for other BROCA runs and flows, and session_total for
Goose. A BROCA step run can still have segment_ref items for unmarked
segments such as warm calls. Goose's detail has one item for its accumulated
session event. Segment/session-total costs belong to the run/session as a
whole; clients must not divide them over feed calls.
Tokens have optional input, output, reasoning, cache_read, and
cache_write integer members. Missing is not zero: a role is absent when no
included event reports an exact whole-token quantity. A role total too large to
represent is also left out, just like an unknown total. Exact decimal encodings
are normalized (100 × 10^-1 contributes 10). Genuinely fractional quantities
are omitted from integer totals without rounding and preserved exactly in detail. output includes reasoning, as on the feed;
reasoning is its breakdown. Stored detail roles remain disjoint.
Cost is {priced, covered_measurements, unpriced_measurements, unpriced_by_reason, pending_measurements}. priced maps currency to signed
integer nanos and includes only current priced charges; it is {} if none.
Covered/unpriced/pending counts are never folded into money. Reasons are the
ledger's closed set, including no_rate, no_catalog_coverage, rate_tiered,
rate_inherited, and stated_zero_requires_policy.
Observed measurements count as unpriced under unpriced_by_reason.observed_only,
never as pending or free.
A billed measurement with no charge head is unpriced with reason
charge_basis_unknown if the event's basis is unknown, and pending otherwise.
All-zero counts plus empty priced means no measurements.
Each detail measurement is {role, unit, quantity, state, amount_nanos?, currency?, reason?}. quantity is {units, exponent} (decimal ledger quantity),
or null when unreported. State is priced, covered, unpriced, or pending.
Only priced measurements carry amount/currency, and only unpriced measurements
carry reason. Current means no charge row supersedes it, so repricing replaces
figures rather than adding historical charges. List money excludes adjustments.
List refusals: malformed, invalid_range, range_too_large, invalid_request
(bad limit, harness or cursor/request mismatch), not_permitted. Detail refusals:
malformed, invalid_request, not_found (no fact has that key), not_permitted.
Pricing may lag ingestion; pending counts expose that lag. Subscribe to
usage.runs.subscribe to re-read when calls or their recorded prices change.
List totals use rebuildable key/model/hour cells maintained by the existing hourly dirty triggers, revision fence, bounded reducer, atomic publication and audit. Clean complete hours use cells; dirty/missing/partial hours use indexed base ranges in the same snapshot. Detail pages use key/time indexes with LIMIT; whole-key totals combine clean cells and dirty-hour base reductions.
Synthetic vectors and SHA-256 checksums are published under
crates/astrocyte-module/test-vectors/usage-runs-v1/. Tests regenerate frame bodies
through the real dispatch and the serving path's shared permission refusal.
The request is {}. Each StreamData body is only {"cursor":"<opaque>"}.
The cursor advances within the process when a committed call, a new or superseding
charge head (the current recorded price row for a measurement), or a rebuilt
run-summary hour could change Runs reads. A replacement charge preserves the
earlier row and becomes the new head. The cursor is a change
token, not a paging or durable resume cursor; a process restart can repeat a value.
On opening or reconnecting, read usage.runs.list, then re-read on each notice.
Notices are coalesced to at most one per two seconds per subscriber, and an idle
ledger sends nothing. No call or price evidence is carried by a notice.
Admission is exactly the Runs reads' admission: local apps and Callosum phone
and desktop routes, not flows. The watch shares the step watch's 16 subscription slots and
held-request pool. Opening refusals are not_permitted, subscription_capacity,
draining, and malformed (unknown parameters). Cancellation ends with the same
cancelled error as the step watch; route closure and module shutdown end the
stream. A slow subscriber receives the newest coalesced token rather than a
queue of intermediate tokens. Synthetic request, notice and refusal vectors with
checksums are in crates/astrocyte-module/test-vectors/usage-runs-subscribe-v1/.
A history of the insula quota readings astrocyte has recorded, read on the read-only connection. It makes no provider request and estimates neither usage nor spend. A route opened by an approved flow (§1) may not call it.
Request: {from_ms, to_ms, grain, quota_providers?}, for example
{"from_ms":0,"to_ms":3600000,"grain":"hour","quota_providers":["claude"]}.
grain is hour or day, in UTC. The range is widened outward to whole UTC
buckets, and readings are selected in that widened half-open range. The
widened range may span at most 31 days for hour (744 buckets) and 400 days
for day; a longer one, including an exactly-31-day hourly range that doesn't
start on the hour, refuses range_too_large. from_ms >= to_ms refuses
invalid_range. quota_providers selects quota-provider names: omitted or
null selects all, an unknown name selects nothing, and an empty list refuses
invalid_filter. Decoding is closed: a missing required member, an unknown
member, a wrong type or another grain refuses malformed.
Reply:
{
"windows": [
{
"quota_provider": "claude",
"account": "synthetic-account",
"credential": null,
"pool": "primary",
"window_minutes": 300,
"buckets": [{"start_ms": 0, "used_percent_max": 142.0, "samples": 3}],
"resets": [{"at_ms": 0, "from_percent": 197.0, "to_percent": 103.0}]
}
],
"earliest_sample_ms": -1
}- One window per quota provider, account or credential, and pool that has
readings in the selected range. An account reading has
accountset andcredential: null; an account-less reading hasaccount: nulland its recordedcredential. Windows sort by quota provider, accounts before credentials, then identity and pool; buckets and resets are in time order. window_minutesis the window length on the last selected reading, ornullif it wasn't recorded. It can differ from earlier readings in the range.- Each bucket has a UTC-aligned
start_ms, the highest percent read in it (the raw percent when insula gave one, otherwise the normalized one, as the subscription multiplier reads them) and the number of readings. Percents can exceed 100. Buckets with no reading are omitted. - A reset is the recorded reset time moving forward past the latest reset time seen so far by more than ten minutes, or half the window length if shorter, stamped at the later reading with the previous and current percents. A percent drop alone is not a reset, and a reading with no reset time cannot start a period. A cached reading whose reset time is older than the current period's by more than that tolerance is excluded from both buckets and resets. The most recent period observed before the range supplies the starting reset time, and the last accepted reading supplies the previous percent. Earlier readings add to no bucket.
earliest_sample_msis the first recorded reading among the selected providers, from either table and regardless of the range, ornullif none. A provider with no reading in the range can set it without appearing inwindows.
Samples, generated through the real handler and pinned by test, are in
crates/astrocyte-module/test-vectors/analytics-quota-history-v2/. Tests:
quota_history_buckets_raw_percent_predecessor_resets_and_credentials,
quota_history_refuses_invalid_ranges_and_empty_filters.
| Peer | Route | Calls | On failure |
|---|---|---|---|
| fusiform (price catalog) | Attested tool_provider, module fusiform |
catalog.status, catalog.get, catalog.history, plan.prices as {"name", "arguments"} tool calls |
A failed pricing call writes no charge; the event stays queued and a later pass retries it. Recompute refuses. Route death and module_reloading are retried once within the call's deadline. |
| insula (quota) | Attested management_surface, module insula |
usage.get with empty params; events_get with event_key and event_name: "quota_sampled" |
Invalid or missing event bodies owe a snapshot. A failed snapshot records the attempt and keeps the last windows. Capacity is advisory and never blocks spend. |
| colliculus (media usage) | management_surface, module colliculus |
usage.read pages and usage.ack after each committed page |
Keep the committed cursor and retry. An absent module does not degrade health; transient route refusals (the module warming or reloading) defer the drain. feed_not_admitted means colliculus is not configured to let astrocyte read its usage feed; that won't fix itself, so it degrades health immediately. |
| ckbus | Attested management_surface, module ckbus |
ckbus.credential, ckbus.credential_renew, ckbus.nonce_sign |
Retain per-tick insula polling and retry with exponential backoff (250 ms to 30 s). Never fail the module or change broker topology. |
| claustrum (credential vault) | Attested management_surface, module claustrum |
credential.list_scoped and held auth.watch_scoped, with empty params |
Startup never waits for the peer. Missing vault or grant changes no history or ledger plans, is logged on transition and is shown in spend.subscription.report. unknown_method on watch enables full-tick-only list polling. |
| prefrontal, basal, magic-context | Attested management_surface of each publisher |
attribution.read with optional opaque after and page limit |
Keep the committed cursor and health unchanged on failure; retry at the next scheduled refresh, but back off per absent publisher from one minute up to ten minutes unless a bus wake arrives first. |
| entorhinal | Attested management_surface, module entorhinal |
placement.read with optional opaque after and page limit |
The same optional-reader behavior as attribution publishers. |
Fusiform, insula and ckbus use the module's daemon connection file supplied by the supervisor, not paths in desired configuration. Their routes use the module's daemon-validated identity after HELLO. If Fusiform is not reachable, events wait for pricing; if insula is not reachable, capacity remains advisory.
Claustrum uses the module's daemon connection and launch identity, as colliculus
does, under reserved:astrocyte's list grants on the llm-provider category or
on exact credential IDs. Astrocyte uses only llm-provider records. No read
grant or credential.get_scoped call is needed. The published
cortexkit-claustrum-client 0.9.0 decoder and watch types validate replies;
Astrocyte's SDK consumer connections use the serving connection's claim when
launched with a registration channel, and the SDK's implicit identity on older
unbound launches. The reader
re-lists after every notice and on daily full-tick backstops. Only full ticks
record its queued observations, outside all peer calls.
Colliculus uses the module's daemon connection file while its source is ingested.
HELLO always declares Colliculus as a peer and astrocyte-colliculus-usage-read
as a conditional self-signal. A reload changes whether astrocyte ingests
Colliculus usage, not what the connection declares.
The signal declares that the refresher polls usage.read to observe the feed
on each full tick. usage.ack follows each committed page. For feeds with an
ID, pending acknowledgments survive restart. Before retrying one, Astrocyte
reads again and checks that the feed ID matches and its head is at or beyond
the committed sequence.
The manifest always declares the four attribution publishers as service clients.
Its self_signals also describe each periodic read as a poller with an observe
effect: the peer call reads facts rather than mutating the publisher. With the
bus consumer attached, an attribution-fact event wakes only its publisher;
scheduled full refreshes provide an hourly polling backstop. Without the bus
consumer, full refreshes poll each publisher. Each page commits its facts and
cursor in one transaction. A publisher with more than eight pages to read yields
to the others and resumes from its saved cursor on the next full refresh or wake.
Only a returned next is a resume token; a terminal null keeps the request
cursor and replays that suffix next refresh. An unchanged page with no new
resume token opens no write transaction. A new resume token is saved even when
the page has only known facts or is empty. Changed
bodies for known identifiers are set aside as fact_body_changed, never
replaced. Malformed facts, invalid open workload/task names, and subjects already
claimed by another publisher are also set aside and counted by source in
spend.ledger.coverage.
Known correction targets must have the same publisher and exact subject
(project_id for placements);
supersedes_other_subject distinguishes a bad correction from a malformed body.
Unknown targets are kept pending and checked on arrival, without deleting
immutable evidence.
Insula notices use ck.{bus_account}.event.insula.quota_sampled.v1, with no body.
Astrocyte binds its pre-existing pull durable from cortexkit-bus-naming's consumer
table, fetches in batches of 32 (one-second expiry), and hashes the exact compact
result.body bytes against both reply and notice digests. It checks the body's
provider, optional account, epoch and sequence against the notice. In-sequence
readings update only that account (or unlabeled provider-current readings); they
have no complete-provider retirement authority. First notices, new epochs, gaps,
missing bodies or failed validation record a snapshot obligation before ack.
Duplicates do not write again. Progress acks protect pending writes; final acks
follow commit or recorded recovery. A restart begins with a snapshot owed.
Queued events published at or before the start of a committed usage.get
snapshot cannot replace it. A complete inventory also forgets event cursors
for accounts the snapshot retires.
Healthy attachment, a current credential and a recent successful pull suppress
per-tick snapshots. The backstop is the earlier of ten minutes and the existing
capacity freshness horizon minus one cadence: normally 90 seconds. Event commits
refresh capacity sooner; empty pulls never do. Any bus failure restores per-tick
polling. Transitions are logged; health reply shapes, freshness rules, the
multiplier and budget.verdict are unchanged.
If only astrocyte's quota-event bus consumer cannot attach, runner steps and the
other bus paths continue on the same connection while quota falls back to polling.
broca, the coding harnesses and thalamus-harness are not called. astrocyte reads their stores and files directly; see harness readers.
budget.verdictenforces no cap. Callers must not readallowas approval of a budget.- A timed-out write has an unknown outcome. Clients must not retry a write
blindly;
spend.correction.ingestis the one write with a retry key. - Served writes carry no operator identity. The caller is whoever subc admitted to the route.
Astrocyte publishes three additive views for readers moving from polling to the
fleet bus. The existing reports, usage.steps.subscribe notices, watermark
operation, acknowledgement files and all reader polls remain in place. Subjects
and bucket names come from cortexkit-bus-naming; Astrocyte reuses its existing
ckbus credential and NATS connection without changing the m_astrocyte durable
or its quota and runner-step readers. The module declares registration-channel
support. The SDK's serve helper adopts that channel, and its consumer connections
obtain a self claim from the serving registration owner. Calls do not supply a
per-call identity; the SDK retains its implicit identity behavior for older,
unbound launches.
Ledger changes are committed before their values are staged for publication. Acknowledgement values are staged only after the corresponding atomic file write succeeds, or after reading an unchanged file that already exists. Network work runs independently of the writer, outside every store transaction. A bus failure neither rolls back a commit nor changes module health. A fixed warning is logged once per failure streak, without peer error text, credentials or values. The next change or credential session republishes the current desired state. These publications are hints and mirrors, not a replacement for the ledger or a new source of billing facts.
After a commit appends rows to the live step feed, Astrocyte publishes on
ck.{acct}.live.astrocyte.steps_committed.v1, constructed with
AccountNames::live_subject. Magic-context is the registered reader. The exact
body shape is {"cursor":"c42"}, using the newest feed cursor, not a row or a
session name. A rollback and an unchanged feed emit nothing. There is at most
one hint in flight; commits during a send replace the pending cursor with the
newest one. The live subject is Core NATS, with no replay or offline delivery.
The existing usage.steps.subscribe stream is unchanged.
The astrocyte.multiplier bucket is written by Astrocyte and read by Striatum.
AccountNames::module_bucket_name("astrocyte", "multiplier") derives its
account-specific name. Values are limited to the bucket's declared size (64 KiB
today, from cortexkit-bus-naming), with history 1 and no TTL.
Each key identifies one (quota_provider, plan, pool_id) and its value is
the whole spend.multiplier.report latest row in compact JSON. The key is
x<provider-hex>.x<plan-hex>.x<pool-hex>: each x is followed by the lowercase
hexadecimal of that component's UTF-8 bytes, even for ASCII IDs. Dots only
separate the three components. All three IDs are retained in the value; the
pool component encodes the raw pool_id, not window_pool_key. To join the
row to a served subset list, use the value's catalog_provider and pool_id.
Astrocyte reconciles the bucket to the current latest rows after a daily
provider-day commit, after an operator recompute and at startup. Unchanged
values are not put again. Keys absent from the new set, including old
two-part keys, are deleted even when latest is empty. A failed day's write
does not evict that provider's older rows; a failed report read leaves the
bucket unchanged.
Values larger than the declared size are omitted without stopping publication of other rows. An earlier value for an omitted key is deleted rather than left stale. The warning records the key and byte count, not the value. Astrocyte never truncates a report row to fit. An absent key means no estimate from the bucket.
The astrocyte.read-marks bucket is written by Astrocyte and read by
thalamus-harness. Its account-specific name comes from
AccountNames::module_bucket_name("astrocyte", "read-marks"). Values are limited
to 256 bytes, with history 1 and no TTL.
thalamus.watermark holds exactly the value watermark.get serves:
{"watermark_ms":123} or {"watermark_ms":null}. It is staged at startup and
whenever the committed effective watermark changes, including changes in the
payer watermark that bounds session progress. watermark.get remains available
with its existing admission rules. When ingestion is disabled or its source is
excluded, the operation stops serving a value and the key is deleted after the
configuration commit is published, including at startup. Re-enabling the source
restores its served value after the next commit; a served null watermark remains
a key, not a deletion.
For each session in a THALAMUS acknowledgement file, the key is
thalamus.ack.<encoded source>.<encoded session>. Source and session ids use the
same always-prefixed UTF-8 hex rule as multiplier keys; they are never treated
as paths or as already-separated key fragments. For example, source
pi-thalamus and session s/_.é map to
thalamus.ack.x70692d7468616c616d7573.x732f5f2ec3a9. Its value is
{"session":"s/_.é","source":"pi-thalamus","through_ms":123}. The readable ids
are included so readers do not need to decode a key.
The bucket mirrors each successfully written acknowledgement file's complete
session set. Removing an entry from the file revokes its key; a failed file
write changes neither the desired puts nor the desired deletions. Unchanged
files also seed their entries when first read after startup. File writes and
all source reads continue unchanged. A value above 256 bytes is omitted and any
old key is deleted, with the same key-and-size warning policy as the multiplier
bucket. It is never truncated. A missing key is not evidence that a session is
unacknowledged until THALAMUS has switched to the bucket; during migration it
must retain its acknowledgement-file read. A missing or stale bus view must
never allow deletion that the file or watermark.get would not allow.