refactor(memory): the memory store and the spend meter leave the plane package (C1)

openultrasast.plane.memory and openultrasast.plane.budget are now
openultrasast.memory and openultrasast.budget; every importer follows. A pure move:
no behaviour changes. The two renames themselves were swept into 1aad435 by mistake
(they were staged when that spec commit was made), so the three commits between it
and this one do not import; this commit completes the move.

memory.py still reaches into the plane in two lazy imports (results_root in
open_store, the reconciler in seed); the cut of the plane has to settle both.

Checked: ruff, ruff format, mypy; 163 test files around memory, budget, plane, learn
and hunt passed across three runs by the implementing agent, and the six closest
files again before this commit. The whole suite was not run locally.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Marius Ciepluch
2026-11-30 10:56:25 +01:00
co-authored by Claude Fable 5.2
parent e22bd420d9
commit b975acb7e0
65 changed files with 117 additions and 122 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ from datetime import timedelta
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from urllib.parse import unquote, urlsplit
from openultrasast.plane.memory import MemoryStore
from openultrasast.memory import MemoryStore
class HttpObjectStore(MemoryStore):
+1 -1
View File
@@ -130,7 +130,7 @@ def test_rustfs_page_lists_the_complete_policy_and_no_secret() -> None:
def test_rustfs_page_quotes_the_refusals_verify_bucket_writes() -> None:
"""Each refusal line the page quotes still appears, as a template fragment, in the store's code."""
code = (ROOT / "src" / "openultrasast" / "plane" / "memory.py").read_text(encoding="utf-8")
code = (ROOT / "src" / "openultrasast" / "memory.py").read_text(encoding="utf-8")
for fragment in (
"the bucket is not set up for the store. The store never configures its ",
"it must be Enabled (provenance cites object versions)",
+2 -2
View File
@@ -1238,7 +1238,7 @@ def test_kubernetes_host_pin_success_failure_and_cleanup(tmp_path, monkeypatch,
from engine_trace_k8s import Kubernetes
from openultrasast.plane.memory import S3Store
from openultrasast.memory import S3Store
objects, calls, expiries = {}, [], []
@@ -1372,7 +1372,7 @@ def test_scheduler_bounds_lanes_and_progress(tmp_path, monkeypatch, executor, pa
def test_k8s_check_roundtrip_and_retention(tmp_path, monkeypatch, capsys, keep):
from engine_trace_k8s import Kubernetes
from openultrasast.plane.memory import S3Store
from openultrasast.memory import S3Store
data, manifests_seen, commands = {}, [], []
+2 -2
View File
@@ -13,6 +13,7 @@ import pytest
from learn_fixtures import ScriptedChat, by_id, corpus, default_answer, example
from test_plane_memory import FakeObjects, _real_s3
from openultrasast.budget import MeteredClient
from openultrasast.learn import compile as compile_module
from openultrasast.learn.compile import (
DEFAULT_SPEC,
@@ -33,8 +34,7 @@ from openultrasast.learn.compile import (
from openultrasast.learn.examples import Example
from openultrasast.learn.folds import Fold, FoldError
from openultrasast.learn.program import Caller, Demo
from openultrasast.plane.budget import MeteredClient
from openultrasast.plane.memory import FileStore, MemoryStore, S3Store
from openultrasast.memory import FileStore, MemoryStore, S3Store
PRICES = {"cache_hit_per_m": 0.014, "input_per_m": 0.44, "output_per_m": 1.32}
MEMORY = corpus(groups=24, per_group=4)
+1 -1
View File
@@ -10,6 +10,7 @@ import random
import pytest
from learn_fixtures import ScriptedChat, corpus
from openultrasast.budget import MeteredClient
from openultrasast.learn.evaluate import (
Prediction,
candidate_from_example,
@@ -28,7 +29,6 @@ from openultrasast.learn.evaluate import (
from openultrasast.learn.folds import compile_split, outer_folds
from openultrasast.learn.program import SIGNATURE, Caller, Program, ProgramSpec
from openultrasast.learn.schema import SCHEMA_VERSION, feature_set_digest
from openultrasast.plane.budget import MeteredClient
def _preds(n: int = 300, *, folds: int = 3, seed: int = 0, unsure_every: int = 0) -> list[Prediction]:
+2 -2
View File
@@ -10,6 +10,7 @@ from pathlib import Path
import pytest
from test_plane_memory import FakeObjects
from openultrasast.budget import BudgetExhausted, MeteredEmbeddingClient, UnmeteredUsage
from openultrasast.learn.embeddings import (
EmbeddingCache,
EmbeddingError,
@@ -21,9 +22,8 @@ from openultrasast.learn.embeddings import (
vector_for,
)
from openultrasast.learn.excerpt import excerpt_sha
from openultrasast.plane.budget import BudgetExhausted, MeteredEmbeddingClient, UnmeteredUsage
from openultrasast.memory import FileStore, MemoryStore, S3Store
from openultrasast.plane.manifests import load_manifests
from openultrasast.plane.memory import FileStore, MemoryStore, S3Store
from openultrasast.provider.openrouter import parse_embedding_payload
PRICES = {"cache_hit_per_m": 0, "input_per_m": 0.02, "output_per_m": 0}
+1 -1
View File
@@ -24,7 +24,7 @@ from openultrasast.learn.examples import (
)
from openultrasast.learn.features import Part, quick_part, record
from openultrasast.learn.labels import Source, Sources
from openultrasast.plane.memory import FileStore, MemoryStore, MemoryStoreError, S3Store
from openultrasast.memory import FileStore, MemoryStore, MemoryStoreError, S3Store
PIN = "0123456789abcdef0123456789abcdef01234567"
SOURCES = Sources(
+2 -2
View File
@@ -13,13 +13,13 @@ from unittest.mock import Mock
import pytest
from learn_fixtures import ScriptedChat, corpus, x_record
from openultrasast.budget import MeteredClient
from openultrasast.cli import main
from openultrasast.learn import experiments as ex
from openultrasast.learn.compile import canonical, program_id
from openultrasast.learn.program import TEMPERATURES, Caller, Candidate, Program, ProgramSpec
from openultrasast.learn.retrieve import Target
from openultrasast.plane.budget import MeteredClient
from openultrasast.plane.memory import FileStore, MemoryStore, Record
from openultrasast.memory import FileStore, MemoryStore, Record
ROOT = Path(__file__).resolve().parents[1]
PRICES = {"cache_hit_per_m": 0.014, "input_per_m": 0.44, "output_per_m": 1.32}
+1 -1
View File
@@ -16,7 +16,7 @@ from openultrasast.learn import experiments as ex
from openultrasast.learn.fill import fill_rule
from openultrasast.learn.program import Candidate, Program, Prompt
from openultrasast.learn.retrieve import Target
from openultrasast.plane.memory import FileStore
from openultrasast.memory import FileStore
def snapshot(root: Path) -> dict[str, bytes]:
+1 -1
View File
@@ -12,7 +12,7 @@ from learn_fixtures import x_record
from openultrasast.cli import main
from openultrasast.learn.leaks import Pair, Signal, audit, pair_rows, separation
from openultrasast.learn.schema import BY_NAME
from openultrasast.plane.memory import FileStore
from openultrasast.memory import FileStore
def _pairs(n: int = 20) -> list[Pair]:
+2 -2
View File
@@ -12,6 +12,7 @@ from pathlib import Path
import pytest
from learn_fixtures import ScriptedChat, by_id, corpus, x_record
from openultrasast.budget import BudgetExhausted, MeteredClient
from openultrasast.learn import program as program_module
from openultrasast.learn.folds import outer_folds
from openultrasast.learn.program import (
@@ -34,9 +35,8 @@ from openultrasast.learn.program import (
)
from openultrasast.learn.retrieve import BoundaryViolation, Retrieval, Target
from openultrasast.learn.schema import EXCLUDED_FIELDS, FeatureRecordError
from openultrasast.memory import FileStore
from openultrasast.model.endpoint import DeepSeekChatClient
from openultrasast.plane.budget import BudgetExhausted, MeteredClient
from openultrasast.plane.memory import FileStore
PRICES = {"cache_hit_per_m": 0.014, "input_per_m": 0.44, "output_per_m": 1.32}
EXAMPLES = corpus(groups=10)
+1 -1
View File
@@ -7,6 +7,7 @@ from __future__ import annotations
import json
from pathlib import Path
from openultrasast.budget import MeteredClient
from openultrasast.learn.features import Vocabulary, function_of, model_sinks_part, roles_part
from openultrasast.learn.roles import (
RoleSet,
@@ -19,7 +20,6 @@ from openultrasast.learn.roles import (
vocabulary_overlay,
)
from openultrasast.model.specs import taint_specs
from openultrasast.plane.budget import MeteredClient
from openultrasast.plane.tasks import roles as roles_task
from openultrasast.tool_hunter import ChatResponse, ScriptedChatClient
+1 -1
View File
@@ -24,7 +24,7 @@ from openultrasast.learn.evaluate import (
) # fmt: skip
from openultrasast.learn.program import Candidate, Program
from openultrasast.learn.retrieve import Target
from openultrasast.plane.memory import FileStore
from openultrasast.memory import FileStore
ROOT = Path(__file__).resolve().parents[1]
+1 -1
View File
@@ -4,8 +4,8 @@ from __future__ import annotations
import pytest
from openultrasast.budget import AccountError, BudgetExhausted, MeteredClient, cost_of, prices_from
from openultrasast.model.endpoint import Prices
from openultrasast.plane.budget import AccountError, BudgetExhausted, MeteredClient, cost_of, prices_from
from openultrasast.tool_hunter import ChatResponse
FLASH = {"cache_hit_per_m": 0.014, "input_per_m": 0.44, "output_per_m": 1.32}
+1 -1
View File
@@ -9,7 +9,7 @@ from pathlib import Path
import pytest
from openultrasast.plane.memory import FileStore
from openultrasast.memory import FileStore
from openultrasast.plane.tasks import features
from openultrasast.plane.tasks.remember import remember_run
+2 -2
View File
@@ -14,12 +14,12 @@ import pytest
import yaml
from test_plane_reconciler import AX_FIELDS, non_ax_fields
from openultrasast.budget import prices_from
from openultrasast.memory import MEMORY_KEY_ANNOTATION, POPULATION_ANNOTATION, SPLIT_ANNOTATION, parse_memory_key
from openultrasast.model.endpoint import price_of
from openultrasast.plane import reconciler
from openultrasast.plane.budget import prices_from
from openultrasast.plane.generate import TEMPLATES, fix_ranges, increment, read_cases, render, repin_templates
from openultrasast.plane.manifests import load_manifests
from openultrasast.plane.memory import MEMORY_KEY_ANNOTATION, POPULATION_ANNOTATION, SPLIT_ANNOTATION, parse_memory_key
from openultrasast.source import _digest
PLANE = Path("plane")
+5 -4
View File
@@ -18,8 +18,8 @@ from typing import Any
import pytest
from openultrasast.plane import memory, reconciler
from openultrasast.plane.memory import (
from openultrasast import memory
from openultrasast.memory import (
S3_KEYS,
ExpiryRule,
FileStore,
@@ -34,6 +34,7 @@ from openultrasast.plane.memory import (
seed,
where_sql,
)
from openultrasast.plane import reconciler
from openultrasast.source import _digest
PIN = "0123456789abcdef0123456789abcdef01234567"
@@ -219,7 +220,7 @@ def test_a_malformed_row_fails_naming_it_and_writes_nothing(store: MemoryStore)
def test_facts_that_no_longer_match_their_hash_are_dropped(store: MemoryStore, caplog: pytest.LogCaptureFixture) -> None:
sha = store.put_facts(FACTS)
store._put(f"facts/{sha}.json", b"tampered")
with caplog.at_level(logging.WARNING, logger="openultrasast.plane.memory"):
with caplog.at_level(logging.WARNING, logger="openultrasast.memory"):
assert store.get_facts(sha) is None
assert "no longer matches" in caplog.text and store._get(f"facts/{sha}.json") is None
@@ -347,7 +348,7 @@ def _filled(client: FakeObjects) -> S3Store:
def test_select_is_pushed_down_when_the_probe_answers(caplog: pytest.LogCaptureFixture) -> None:
client = FakeObjects("works")
store = _filled(client)
with caplog.at_level(logging.WARNING, logger="openultrasast.plane.memory"):
with caplog.at_level(logging.WARNING, logger="openultrasast.memory"):
got = [r.row["candidate"] for r in store.rows(kind="verdict", where={"final": "disputed"})]
assert got == ["a.py::x"] and "locally" not in caplog.text
assert client.selects[0] == 'SELECT * FROM S3Object s WHERE s."probe" = 1'
+2 -2
View File
@@ -959,8 +959,8 @@ def test_state_is_mirrored_to_the_store_and_seeds_a_rerun_from_an_empty_results_
def test_a_store_that_cannot_open_stops_the_run_before_ax_and_leaves_no_lock(
fake: Fake, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
from openultrasast.plane import memory
from openultrasast.plane.memory import MemoryStoreError
from openultrasast import memory
from openultrasast.memory import MemoryStoreError
monkeypatch.setattr(reconciler, "open_store", memory.open_store) # the real one, not the fixture's fake
monkeypatch.setenv("OUSAST_MEMORY", "s3://nowhere") # the profile's override; no S3_* in the test environment
+2 -3
View File
@@ -13,9 +13,8 @@ from typing import Any
import pytest
import yaml
from openultrasast import cli
from openultrasast.plane import memory
from openultrasast.plane.memory import FileStore, MemoryStoreError, ingest, row_id
from openultrasast import cli, memory
from openultrasast.memory import FileStore, MemoryStoreError, ingest, row_id
from openultrasast.plane.tasks import remember
from openultrasast.plane.tasks.remember import Context, candidates_digest, remember_run, rows_for
+1 -1
View File
@@ -103,8 +103,8 @@ def test_matching_verdicts_are_identical_on_the_recorded_outputs(reference: tupl
def _units(case_id: str, kept: list[list[Any]]) -> tuple[list[dict[str, Any]], list[dict[str, Any]], float]:
"""The recorded per-file hunts as two `verify` passes: a hunt's usd is the file's spend minus its triage."""
from openultrasast.budget import cost_of
from openultrasast.model.endpoint import price_of
from openultrasast.plane.budget import cost_of
prices = price_of("deepseek-flash")
assert prices is not None
+1 -1
View File
@@ -9,7 +9,7 @@ from pathlib import Path
import pytest
from test_plane_verify import CANDIDATES, FACTS, FLASH, HuntClient, _two_passes, _workspace
from openultrasast.plane.budget import MeteredClient
from openultrasast.budget import MeteredClient
from openultrasast.plane.tasks import agree, verify
from openultrasast.tool_hunter import CLIENT_ENV
+1 -1
View File
@@ -9,7 +9,7 @@ from pathlib import Path
import pytest
from openultrasast.plane.budget import MeteredClient
from openultrasast.budget import MeteredClient
from openultrasast.plane.tasks import agree, verify
from openultrasast.tool_hunter import ChatResponse, ToolCall
+1 -1
View File
@@ -2,7 +2,7 @@ import json
import pytest
from openultrasast.plane.memory import FileStore
from openultrasast.memory import FileStore
from openultrasast.search.board import Board
+1 -1
View File
@@ -2,7 +2,7 @@ from concurrent.futures import ThreadPoolExecutor
import pytest
from openultrasast.plane.budget import BudgetExhausted, SpendBudget
from openultrasast.budget import BudgetExhausted, SpendBudget
from openultrasast.search.budget import SearchBudget
+2 -2
View File
@@ -1,6 +1,6 @@
import pytest
from openultrasast.plane.memory import FileStore
from openultrasast.memory import FileStore
from openultrasast.search.board import Board
from openultrasast.search.budget import SearchBudget
from openultrasast.search.coordinator import Coordinator
@@ -204,7 +204,7 @@ def test_worker_limit_preserves_fact_and_survives_resume(tmp_path, detail):
@pytest.mark.parametrize("detail", ["spend", "tasks", "reason_rounds", "demonstrations", "task_wall", "search_wall", "run_ceiling"])
def test_coordinator_identifies_each_own_limit(tmp_path, detail):
from openultrasast.plane.budget import SpendBudget
from openultrasast.budget import SpendBudget
now = [0]
+6 -6
View File
@@ -76,7 +76,7 @@ def test_driver_allocates_fair_share_with_settled_rollover(tmp_path, monkeypatch
from types import SimpleNamespace
from benchmarks.search import pilot_run
from openultrasast.plane.budget import BudgetExhausted
from openultrasast.budget import BudgetExhausted
monkeypatch.chdir(tmp_path)
root = Path("benchmarks/search/private")
@@ -145,9 +145,9 @@ def make_pilot(tmp_path, *, side="fixed", dry_run=False):
from argparse import Namespace
from benchmarks.search.pilot_run import Pilot
from openultrasast.budget import SpendBudget
from openultrasast.memory import FileStore
from openultrasast.model.endpoint import Prices
from openultrasast.plane.budget import SpendBudget
from openultrasast.plane.memory import FileStore
from openultrasast.search.worker import StubModel
args = Namespace(side=side, dry_run=dry_run, model="scripted", max_tokens=128, verify_lane="vm", image="unused")
@@ -209,8 +209,8 @@ def test_worker_failure_is_not_no_evidence(tmp_path):
def test_shared_budget_reserved_and_settled_on_error(tmp_path):
from openultrasast.budget import SpendBudget
from openultrasast.model.endpoint import Prices
from openultrasast.plane.budget import SpendBudget
from openultrasast.search.worker import Worker
run = SpendBudget(0.5)
@@ -400,8 +400,8 @@ def test_vm_preflight_refuses_before_client_or_store(tmp_path, monkeypatch):
def test_actual_usage_settles_shared_budget_and_counts_tokens(tmp_path):
from openultrasast.budget import SpendBudget
from openultrasast.model.endpoint import Prices
from openultrasast.plane.budget import SpendBudget
from openultrasast.search.worker import Worker
run, task = SpendBudget(0.5), SpendBudget(0.05)
@@ -421,8 +421,8 @@ def test_actual_usage_settles_shared_budget_and_counts_tokens(tmp_path):
def test_refused_shared_reservation_releases_task_allowance(tmp_path):
from openultrasast.budget import BudgetExhausted, SpendBudget
from openultrasast.model.endpoint import Prices
from openultrasast.plane.budget import BudgetExhausted, SpendBudget
from openultrasast.search.worker import StubModel, Worker
run, task = SpendBudget(0), SpendBudget(0.05)
+4 -4
View File
@@ -3,7 +3,7 @@ from dataclasses import asdict
import pytest
from openultrasast.plane.memory import FileStore
from openultrasast.memory import FileStore
from openultrasast.search import _sandbox
from openultrasast.search.board import Board
from openultrasast.search.budget import SearchBudget
@@ -100,8 +100,8 @@ def test_coordinator_stub_smoke_real_verify(tmp_path):
def test_reservation_precedes_each_call_and_refuses_over_budget(tmp_path):
from openultrasast.budget import SpendBudget
from openultrasast.model.endpoint import Prices
from openultrasast.plane.budget import SpendBudget
class MeteredStub(StubModel):
def complete_chat_raw(self, **kwargs):
@@ -353,8 +353,8 @@ def test_task_spend_finishes_with_confirmed_observations(tmp_path, with_evidence
def test_calibrated_reservation_covers_reported_usage(tmp_path):
import math
from openultrasast.budget import SpendBudget
from openultrasast.model.endpoint import Prices
from openultrasast.plane.budget import SpendBudget
class UsageStub(StubModel):
def complete_chat_raw(self, **kwargs):
@@ -375,8 +375,8 @@ def test_calibrated_reservation_covers_reported_usage(tmp_path):
@pytest.mark.parametrize("detail", ["worker_steps", "worker_wall", "run_ceiling"])
def test_worker_exhaustion_is_structured(tmp_path, monkeypatch, detail):
from openultrasast.budget import SpendBudget
from openultrasast.model.endpoint import Prices
from openultrasast.plane.budget import SpendBudget
worker = Worker(
StubModel([tool("list_files")]),
+2 -4
View File
@@ -464,8 +464,7 @@ def test_cli_uses_environment_and_injected_stores(
):
import json
from openultrasast import config
from openultrasast.plane import memory
from openultrasast import config, memory
seen = []
monkeypatch.setenv("GH_TOKEN", "fake-secret")
@@ -1700,8 +1699,7 @@ def test_bank_crash_resume_and_durability_failure(tmp_path, monkeypatch, failure
@pytest.mark.parametrize("bank_args,prefix", [([], None), (["--bank"], "unseen"), (["--bank", "custom"], "custom")])
def test_cli_corpus_bank_is_opt_in(tmp_path, monkeypatch, capsys, bank_args, prefix):
from openultrasast import config
from openultrasast.plane import memory
from openultrasast import config, memory
objects = CorpusFakeObjects()
monkeypatch.setattr(config, "load_dotenv", lambda *a: None)
+4 -6
View File
@@ -6,7 +6,7 @@ from pathlib import Path
import pytest
from openultrasast.plane.memory import FileStore
from openultrasast.memory import FileStore
with pytest.MonkeyPatch.context() as patch:
patch.syspath_prepend(str(Path(__file__).resolve().parents[1] / "benchmarks/unseen"))
@@ -109,8 +109,7 @@ def test_registered_units_and_read_only_store(tmp_path):
def test_cli_injected_store_and_credentials(tmp_path, monkeypatch, capsys):
from openultrasast import config
from openultrasast.plane import memory
from openultrasast import config, memory
calls = []
monkeypatch.setattr(config, "load_dotenv", lambda path: calls.append("dotenv"))
@@ -129,7 +128,7 @@ def test_cli_injected_store_and_credentials(tmp_path, monkeypatch, capsys):
def test_s3_open_is_read_only(tmp_path, monkeypatch):
from openultrasast.plane import memory
from openultrasast import memory
class Objects:
def keys(self, prefix):
@@ -267,8 +266,7 @@ def test_memory_values_are_skipped_and_counted(tmp_path, capsys):
@pytest.mark.parametrize("step", ["open_stores", "build_used", "report", "canonicalize", "verify_tests"])
def test_cli_failure_reports_only_step_and_exception_type(tmp_path, monkeypatch, capsys, step):
from openultrasast import config
from openultrasast.plane import memory
from openultrasast import config, memory
def fail(*args, **kwargs):
raise RuntimeError("sensitive/identity")