Definition
A journal record budget is a fixed maximum number of records that one operation, such as one run of an experiment, may append to a journal: an append-only log §8.13 in which a program records what happened, in order. The budget comes with an accounting rule, which says which records count against it, and an overflow rule, which says what happens when the next record would exceed it. The budget limits records only, not bytes or time, and it does not say how many measurements succeeded.
The idea
A test program appends records to a journal kept in a small storage area that holds 100 records per run. The researcher reads 100 as room for 100 measurements. But a run also writes a start record, configuration records, a record each time it resets the device, error and retry records, and at the end a terminal record that states how the run ended. If each measurement needs three records, such as request, result and check, far fewer than 100 measurements fit. Worse, if the budget runs out before the terminal record is written, the journal no longer shows how the run ended, and a reader cannot tell a run that finished from one that crashed.
A paper lab notebook with 100 numbered lines is a fair picture. Every line counts, whether it holds a measurement, a note that the instrument was recalibrated, or the closing signature, and running out of lines before the signature leaves the last experiment in doubt. So a budget needs three decisions made in advance: count every kind of record, keep room for the records that make the journal readable, and decide what happens at the limit. The picture stops being accurate in one respect: a full notebook is plainly full, but a refused append to a journal can leave no trace unless the overflow rule makes it leave one.
How it works
A record budget is set up and enforced in six steps.
Fix the unit and the limit. The budget is a number of records for one operation. The count starts at 0 when the operation starts and is never reset during it.
Write the accounting rule. List every kind of record and whether it counts. The safe rule counts every append of every kind: operational records, such as start, configuration and reset records; scientific records, which carry measured values; failure and retry records; and the terminal record. Count each record when its space is reserved, before it is written, so that an append that fails halfway still counts.
Reserve room. Set aside records for the records without which the journal cannot be read: the terminal record and an overflow notice. Ordinary records may use only records.
Check before writing. Before each ordinary append, check that the count after it will not exceed . Before starting a measurement that needs records, check that records are still free, so that no measurement starts that cannot be finished.
Apply the overflow rule. When an ordinary record or a measurement does not fit, do not write it. Write the overflow notice, which says that the budget was reached and what was not recorded. Then stop the operation, or continue without journaling, as the rule says, and write the terminal record, which states that the run ended because its budget ran out.
Check the evidence separately. After the run, check that every scientific record the analysis needs is present and complete. A run that stayed within its budget may still lack them.
Worked example
Let the budget be records. Every run needs fixed records: 1 start record, 7 configuration records and the reserved records, which are the overflow notice and the terminal record. Each complete measurement needs records.
The room for measurements is records, which holds complete measurements. Now let one measurement fail once and be retried, and let the failure and the retry add extra records. The room for complete measurements shrinks to records. Since , only 29 complete measurements fit.
With the check of step 4, the program refuses to start measurement 30, because only 1 ordinary record is free and the measurement needs 3. The journal then holds ordinary records, which leaves ordinary record unused, and ends with the overflow notice and the terminal record, records in all. A reader sees 29 complete measurements and a run that ended because its budget ran out. Without the check of step 4, measurement 30 would write 1 record and then be cut off, leaving a partial measurement that the analysis must recognize and exclude.
Stated precisely
Let be the budget in records, the number of fixed records every run needs (the reserved records included), the number of extra records from failures and retries, and the number of records in one complete measurement. If , the number of complete measurements satisfies where is rounded down to a whole number. The rounding is down because part of a measurement is not a measurement. In the example, .
The contract of the budget, in words: the operation appends at most records; each record is counted when its space is reserved; the reserved records are used only for the overflow notice and the terminal record; and an ordinary record that would raise the count above is not written, and the overflow rule runs instead. The contract holds only if the count belongs to one operation and is not reset during it, and if every program that writes to the journal for that operation goes through the same check.
Bytes and time need bounds of their own. If no record is longer than bytes, the journal of one operation takes at most bytes; if record length has no limit, the record budget bounds no number of bytes. A record budget bounds no length of time, because counting records does not limit the time between them.
Limits and common mistakes
A budget that counts only scientific records does not protect storage. A fault that makes the program retry in a loop can write thousands of error records while the scientific count stays low. Counting every record is what lets the budget prevent this.
Staying within the budget is not success. A short journal can mean an efficient run or a run that lost its evidence; check the required records directly. And a journal that simply stops looks like a crash: only the overflow notice and the terminal record, written into reserved room, make an exhausted budget readable as such.
Overwriting is a different overflow rule. A circular log §8.14, which overwrites its oldest records when it is full, keeps writing but loses the start and configuration records first, so the surviving records can no longer be interpreted. A journal kept as a circular log needs the records required for interpretation stored somewhere else.
Deciding afterwards which runs count is a selection. A run that exhausted its budget is a partial run. Whether partial runs are excluded from the analysis should be decided before the data are seen, as a prospective exclusion rule §13.15; a choice made after seeing the results can bias them.
Enforcing a budget cannot create missing evidence. It can only end a run early and say so.
Questions answered
Does the budget include operational records as well as scientific events?
Yes, a journal record budget should count every record the operation appends, operational records as well as scientific events. A journal record budget is a fixed maximum number of records that one operation may append to its journal, the log of what happened. Operational records include the start record, configuration records, device resets, failure and retry records and the terminal record that states how the run ended. Each takes storage just as a scientific record does. A budget that counted only scientific events would let a fault that writes error records in a loop fill the storage while the budget still showed room.
Two consequences follow. First, plan the scientific capacity after the other records. With a budget of records, fixed records per run, extra records from failures and retries and records per complete measurement, at most complete measurements fit, where means rounded down. For , , and that is 29, not 100. Second, reserve room for the terminal record and an overflow notice, so that a run that exhausts its budget still says so. Staying within the budget does not show that the scientific records are complete; check them separately.
Related entries: Canonical record (§13.13), Evidence eligibility (§13.14), Append-only log (§8.13), Circular log (§8.14), Prospective exclusion rule (§13.15).