# Data acquisition queue (O07) The acquisition queue turns dataset revisions, target dossiers and causal maps into specific requests for new examples. It produces requests only. It never fetches data: rows come from fixtures that an operator supplies, and each ingest writes a new dataset revision. ```bash obliteratus experiments acquisition queue --revision rev.json --features features.json \ --dossier ./run/dossiers/alpha.json --map ./run/maps//map.json \ --registry ./run --config queue.json --out ./acquisition obliteratus experiments acquisition ingest --revision rev.json \ --queue ./acquisition/queue-.json --fixture fixture.json --store ./revisions obliteratus experiments acquisition study --config study.json --out ./acquisition ``` ```python from obliteratus.analysis.acquisition_queue import build_queue, verify_queue from obliteratus.analysis.acquisition_revisions import ingest, write_revision from obliteratus.analysis.acquisition_study import run_study, synthetic_pool queue = build_queue("rev.json", features="features.json", config={"budget": 10}) report = run_study(synthetic_pool(0), {"seeds": 5}) ``` ## Inputs - Dataset revision: JSON with `declaration` and `records`, which are the schema 2.0 dataset fields (roles, groups, families, pairs, ancestry). A seed file that holds only these two keys is accepted. Stored revisions also record their `digests` (revision, content, partition), and those digests are checked on every load. - Features (optional): `obliteratus.acquisition-features`, with `record_ids`, `values` (one vector per record, for example activations at one site) and an optional `observed` behaviour label per row. - Target dossiers and causal maps, cited by path and digest. - Confirmation registries (`--registry`): every registered confirmation row is protected, whether or not it has been exposed. ## Protected rows The following rows never enter scoring: - locked `test` rows; - rows of any other `protected_roles`; - confirmation rows, matched by text digest; - every row in the same independence unit as one of these. The queue reads only their role, group and text digest, so that it can refuse placements next to them. Scoring uses `scoring_roles`, which defaults to `fit`. The report counts the protected rows, and the feature rows that were dropped. ## Gap detectors | Gap | Source | Uncertainty | | --- | --- | --- | | `unstable_boundary` | Group-disjoint folds, redrawn per seed. Each held-out row is predicted by a difference-of-means direction fitted on the training folds. | `1 - abs(2p - 1)`, where `p` is the share of seeds that predict positive | | `prediction_disagreement` | The same predictions, compared with the class label (or the `observed` label); also dossier counterexamples | share of seeds that predict against the reference | | `sparse_neighbourhood` | Distance to the k-th nearest row of the same class | percentile of that distance | | `missing_stratum` | A (class, `strata_fields` value) stratum with fewer than `min_units_per_stratum` independence units, including values listed in `expected_strata`; also sets a dossier leaves untested | `1 - units / min_units` | | `confounded_controls` | A stratum value present in only one class, or an unresolved confound flag on a dossier estimate (a confound baseline that comes close to the target AUC) | 1 for dossier flags | | `intervention_failure` | A decision cell of a causal map that is `inconclusive` or not supported | 1.0 if inconclusive, 0.7 otherwise | ## Queue items Each item records: - the gap, and its evidence as references (`{path, sha256, pointer}` into the revision, features, dossier or map); - the selection rationale; - the source and permission requirement (operator-provided, never fetched); - the target class and set paths; - the required partition and group lineage; - the expected value of the label; - the priority. The expected value is `weight[gap] x uncertainty`. This is a declared heuristic for ordering requests. It is not a calibrated value of information. `verify_queue` resolves every evidence reference and checks its digest. The queue's own `queue_sha256` covers the whole file. Placement follows two rules: - A relative of an existing row joins that row's group, so it lands in that row's partition. - A request without an anchor creates a new group in `new_group_role` (default `fit`). Anchors in protected rows are refused and listed under `refused`. So are anchors outside the scoring roles, and placements into a protected role. ## Diversity and exploration Candidates are taken in order of expected value, subject to two limits: - at most one request per independence unit; - at most `max_per_neighbourhood` requests (default 1) within `radius_factor` times the median nearest-neighbour distance of an anchor that has already been chosen. Unanchored requests are limited per stratum or per source key instead. `explore_fraction` of the budget (default 0.2) goes to untargeted random requests drawn with the declared `seed`. These requests are spread evenly through the priority order. Requests that were suppressed are listed with the reason. When there are too few candidates, the shortfall is reported as `unfilled`. ## Ingest A fixture (`obliteratus.acquisition-fixture`) holds the following fields: - the `queue_sha256` of the queue it answers; - `provider` and `permission`; - rows, each giving the request it answers, a set path and a record. Ingest refuses a fixture in any of these cases: - a row in a role or group other than the one its item requires; - a row in a protected role or a protected group; - a row whose text matches a confirmation row; - a set path that the item did not request; - an unknown request; - a queue built on another revision; - any change that breaks the dataset's independence rules, such as an exact text shared with a test row. Ingest writes a new write-once revision at `/revisions/.json`. The new revision records its parent (revision digest, file SHA-256 and path), the queue and fixture digests, and the digest of every added row. The parent file is never modified. ## Study `run_study` compares three ways of acquiring rows at an equal budget, spread over equal rounds, on a pool with `labeled`, `reservoir` and hidden `heldout` parts. The three parts must not share any group. The arms are: - `random`: uniform sampling, the baseline, which is always reported; - `stratified`: a simple non-geometric arm that fills the thinnest (domain, class) stratum; - `queue`: the same planner and gap detectors as the acquisition queue. The queue arm's requests are fulfilled as an operator would fulfil them: - a stratum request gets a row from the matching stratum; - a row request gets the nearest unused row to its anchor; - an exploration request gets a random row. Requests that cannot be fulfilled, and unfilled slots, become random rows, and are counted as `fallback_random`. After each round the study fits on the labeled rows and scores on the hidden rows. Two measures are recorded: held-out error (`1 - balanced accuracy`) and held-out prediction instability across group-bootstrap refits. Costs are counted as acquired examples, forward passes (the queue arm is also charged for embedding the reservoir when it matches nearest neighbours) and boundary refits. Uncertainty is the `[min, max]` interval over the declared seeds. The verdict is `no improvement` unless the study ran at least `min_seeds` seeds (default 3) and one of these holds: - the queue's lowest error reduction per example is above random's highest; - the queue's highest final instability is below random's lowest. `beats_simple_baseline` reports the same error comparison against the stratified arm. Adoption should also require that comparison to pass. Coverage counts never enter the verdict. Results on synthetic fixtures, including this project's tests, are not evidence for real models. On the bundled synthetic pool with the default configuration (fixture seeds 0 to 2), the queue beat random for two of the three seeds and never beat the stratified arm.