Summaries
Period totals over an append-only record type, stored as immutable runs that a person confirms.
Raw Markdown for agents: summaries.md. MCP: read_docs("summaries").
A summary turns the rows of an append-only record type into totals per period:
for example outgoing stock per month, or points earned per quarter. The
definition says which rows count and how; summaries.compute stores each
result as an immutable run with its values, evidence and a content hash, and a
person confirms the run once it is final.
Summaries only read append-only types, because their rows never change after
they are written. A confirmed run therefore stays reproducible: the same
definition over the same period and data gives the same content_hash.
Flow
records.types.describeon the append-only type: note the field keys.summaries.createwithspace_id,record_type_id,key,nameandconfig. Errors name the invalid config path.summaries.computewithdefinition_id,period_startandperiod_end(exclusive, at most 5 years). Every call stores a new run; nothing is overwritten.summaries.runs.list(newest first, without lines) andsummaries.runs.get(complete run) to read results.summaries.confirmwithrun_idonce a person agrees with the values. Assistants need the person's approval for this step.
Configuration
{
"period_field": "moved_on",
"bucket": "month",
"group_by": ["warehouse"],
"lines": [
{
"key": "outgoing",
"label": "Outgoing units",
"filter": {
"conditions": [{"field": "direction", "op": "eq", "value": "out"}]
},
"measure": {"field": "quantity", "agg": "sum"},
"sign": -1,
"corrections": {"field": "is_correction", "mode": "separate"},
"rounding": {"unit": 100, "mode": "half_up"},
"requires": {
"type": "stock_counts",
"filter": {
"conditions": [
{"field": "year", "op": "eq", "value": "{bucket.year}"},
{"field": "month", "op": "eq", "value": "{bucket.month}"}
]
}
}
},
{"key": "movements", "label": "Movements", "measure": {"agg": "count"}}
]
}period_field: a date field of the type. Rows count whenperiod_start <= value < period_end; archived rows never count.bucket:month,quarter,four_month(January-April, May-August, September-December),yearorwhole(one bucket for the full period). Buckets follow the calendar and are cut at the period edges.group_by: up to two text, single select, date or number fields; each bucket then has one result per group value.lines(1 to 100), each with a uniquekeyand alabel:filter: the same filter tree asrecords.rows.query; empty means all rows.measure:sumof a number or money field, orcountof rows. A sum may setweight_field(a number field); each row then addsfield * weight, and an empty weight counts as1. Example: with{"field": "amount", "agg": "sum", "weight_field": "share"}a row with amount 200 and share 0.25 adds 50.sign:1or-1, applied after the corrections.corrections: a boolean field that marks correction rows.netsubtracts the correction rows from the other rows;separatekeeps both values apart (baseandcorrections).rounding: rounds to a multiple ofunit(half up), applied last.requires: an evidence condition. The line looks for rows of another record type that match the filter; without a match the line ispendingin that bucket. Its values are still computed and shown.cumulative:truemakes the line a balance at the end of each bucket (see below). Defaultfalse.
Cumulative lines
A cumulative line counts every row with value < bucket end, without a lower
bound: stock on hand, a points balance, open items or an account balance at
the cut-off date. Filter, corrections, sign, weight_field and count work as
usual; rounding applies to the accumulated value. A group shows up in every
bucket in which its balance is not zero, also without movements in that
bucket; groups whose balance is zero are left out. rows counts all rows up
to the bucket end, and rows_included and data_through include the rows
before period_start. The 5-year limit applies only to the bucket grid, not
to the data.
Signed movements come from the data (a signed field, weight_field) or from
two lines with opposite sign. A trial balance per account uses three lines:
[
{"key": "debits", "label": "Debits", "measure": {"field": "debit"}},
{"key": "credits", "label": "Credits", "measure": {"field": "credit"}},
{"key": "closing", "label": "Closing balance", "measure": {"field": "balance"}, "cumulative": true}
]The opening balance of a bucket is closing - debits + credits.
Placeholders
String values in requires.filter may contain {bucket.start},
{bucket.end} (dates, end exclusive), {bucket.year}, {bucket.month} (first
month of the bucket) and {bucket.index} (position of the bucket within its
year, starting at 1). {bucket.month2} and {bucket.index2} are the same
numbers as two-digit text with a leading zero (05), for example
"{bucket.year}-{bucket.month2}" gives 2026-05. A value that is only a
placeholder keeps its type for number and date fields; inside text it is
replaced as text.
Run contents
A run holds the period, bucket, a snapshot of the configuration with its hash,
the published schema version, engine_version, rows_included,
data_through (newest row creation time seen) and snapshot_xmin. Each line
has one result per bucket and group with:
base,corrections,raw(value after corrections and sign),roundedandcorrections_rounded, all as decimal stringsrows(number of rows counted),status(okorpending) andevidence(ids of the records that satisfiedrequires)
Immutability and confirmation
Runs never change and cannot be deleted, also not directly in the database.
The single allowed change is summaries.confirm: status computed becomes
confirmed with time and person. To correct a result, append correction rows
to the source type and compute a new run. Changing a definition does not touch
existing runs. Archiving a definition keeps its runs readable and frees its key.
Errors
summary_config_invalid: the configuration does not fit;details.issueslists each path and problem.summary_target_invalid: the record type is not a published append-only type.summary_key_taken: an active summary with this key exists in the Space.summary_archived: the summary is archived and cannot be changed or computed.summary_timeout: the computation took too long; shorten the period or use a coarser bucket.result_too_large: a line yields more than 10,000 groups.summary_run_confirmed: the run is already confirmed.validation_error:period_startis not beforeperiod_end, or the period is longer than 5 years.