Skip to main content

Module process_store

Module process_store 

Source
Expand description

Conformance cases for ProcessStore backends (spec 3.2 §11, §13 Q8).

CaseContract
put_get_round_tripA row reads back exactly as put, every field and every Wake, ProcessKind and Suspension variant included; ids with :, / and non-ASCII characters survive
put_replacesA second put with the same pid replaces the row, and list finds it only under its new partition, queue and parent
list_filters_and_orderslist applies partition, queue, parent and limit, orders by pid in byte order, and ignores states
set_wake_and_queueset_wake sets and clears the wake set, set_queue the queue, leaving every other field
unknown_pidget of an unknown pid is None; set_wake and set_queue fail with kernel.not_found and create no row; delete answers false
deletedelete removes the row and its list entries and answers true, then false
records_survive_a_restartRows read back through a new handle (durable backends only)
concurrent_writersConcurrent puts and updates from two handles over distinct pids lose no row, and concurrent updates of different fields of one row lose neither
sustained_writesA sustained stream of puts, updates and deletes from two handles, read concurrently, stays consistent and readable (SQLite’s write lock and WAL included)
suspend_request_round_tripsset_suspend_requested sets and clears the flag leaving every other field, put writes it, list filters on it, and an unknown pid fails with kernel.not_found
spend_sums_by_day_and_scopespend sums add_spend over an inclusive day range per process or per partition; concurrent additions from two handles all count; deleting a process keeps its spend
usage_sums_counters_by_day_and_scopeusage sums the cost, model calls, total tokens and every unit add_spend recorded, per process or per partition over an inclusive day range, through a second handle; concurrent additions all count; deleting a process keeps its usage

Every case writes under fresh process ids in fresh partitions and deletes its rows at the end, so a harness may point every case at one shared database. Spend totals have no delete, so the spend case leaves its totals, under ids no other case uses.

Traits§

ProcessStoreHarness
Opens a ProcessStore backend for the conformance suite.

Functions§

concurrent_writers
Sixteen writers over two handles put and update distinct pids at once and lose no row; two writers updating different fields of one row lose neither update.
delete
delete removes the row and its list entries and answers true, then false; the pid can be put again.
list_filters_and_orders
list applies partition, queue, parent and limit together, orders by pid in byte order (so B < Z < a < ä < 日), and ignores states, which the process table applies after joining the run store.
put_get_round_trip
A row reads back exactly as put: every field, every Wake, ProcessKind and Suspension variant, named queues, unicode labels, and ids with :, / and non-ASCII characters.
put_replaces
A second put with the same pid replaces the whole row; list then finds it under its new partition, queue and parent only.
records_survive_a_restart
Rows, with their updates, read back through a new handle as a restarted kernel opens one. Skipped for a backend that is not durable.
set_wake_and_queue
set_wake sets and clears the wake set and set_queue sets the queue, each leaving every other field as it was; list finds the row under its new queue.
spend_sums_by_day_and_scope
spend sums what add_spend recorded over an inclusive range of UTC days, per process or per partition: additions to one day accumulate, ranges cross month and year boundaries and reach back to the first century, an empty or reversed range is 0, and a process charged in two partitions counts in each. Forty concurrent additions from two handles all count, and deleting a process’s row keeps its spend.
suspend_request_round_trips
set_suspend_requested sets and clears the pending suspension request, leaving every other field; put writes the flag and a second put replaces it; list filters on it, alone and with the other fields; delete drops a requested row from the filter; an unknown pid fails with kernel.not_found and creates no row.
sustained_writes
Four writers over two handles each run 150 rounds of put, set_wake and set_queue, and delete every third row, while two readers list and get without pause. No call fails, every read decodes to a state some write produced, and the final table holds exactly the rows not deleted, each with its last update.
unknown_pid
An unknown pid reads as None; set_wake and set_queue fail with kernel.not_found naming it and create no row; delete answers false.
usage_sums_counters_by_day_and_scope
usage sums what add_spend recorded — cost, model calls, total tokens and each unit — over an inclusive range of UTC days, per process or per partition, read through a second handle: a delta with units and no cost counts, a unit no delta named stays absent, twenty concurrent additions from two handles all count, and deleting a process’s row keeps its usage. spend agrees with the cost usage reports.