From b975acb7e078992fbefc94d855673d8c279cc452 Mon Sep 17 00:00:00 2001 From: Marius Ciepluch <11855163+norandom@users.noreply.github.com> Date: Mon, 30 Nov 2026 10:56:25 +0100 Subject: [PATCH] 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 --- benchmarks/ax/batch.py | 2 +- .../instrument_check.py | 2 +- benchmarks/learn/build_features.py | 2 +- benchmarks/learn/engine_trace.py | 2 +- benchmarks/learn/engine_trace_ax.py | 2 +- benchmarks/learn/engine_trace_k8s.py | 2 +- benchmarks/learn/engine_trace_queue.py | 2 +- benchmarks/learn/engine_worker_service.py | 2 +- benchmarks/learn/slice_leak_audit.py | 2 +- benchmarks/search/pilot_run.py | 4 ++-- benchmarks/unseen/draft.py | 3 +-- benchmarks/unseen/eligibility.py | 5 ++--- benchmarks/valid/hunter_arm.py | 2 +- plane/models/openrouter-embedding.yaml | 2 +- pyproject.toml | 4 ++-- src/openultrasast/budget.py | 4 ++-- src/openultrasast/cli.py | 7 ++++--- src/openultrasast/hunt/runner.py | 2 +- src/openultrasast/learn/cli.py | 18 +++++++++--------- src/openultrasast/learn/compile.py | 4 ++-- src/openultrasast/learn/embeddings.py | 6 +++--- src/openultrasast/learn/examples.py | 2 +- src/openultrasast/learn/experiments.py | 4 ++-- src/openultrasast/learn/fill.py | 4 ++-- src/openultrasast/learn/program.py | 6 +++--- src/openultrasast/memory.py | 6 +++--- src/openultrasast/plane/delivery.py | 2 +- src/openultrasast/plane/doctor.py | 2 +- src/openultrasast/plane/generate.py | 6 +++--- src/openultrasast/plane/reconciler.py | 2 +- src/openultrasast/plane/tasks/remember.py | 2 +- src/openultrasast/plane/tasks/roles.py | 2 +- src/openultrasast/plane/tasks/verify.py | 2 +- src/openultrasast/search/board.py | 2 +- src/openultrasast/search/coordinator.py | 4 ++-- src/openultrasast/search/worker.py | 2 +- tests/plane_fake_store.py | 2 +- tests/test_docs_site.py | 2 +- tests/test_engine_trace.py | 4 ++-- tests/test_learn_compile.py | 4 ++-- tests/test_learn_decide.py | 2 +- tests/test_learn_embeddings.py | 4 ++-- tests/test_learn_examples.py | 2 +- tests/test_learn_experiments.py | 4 ++-- tests/test_learn_fill.py | 2 +- tests/test_learn_leaks.py | 2 +- tests/test_learn_program.py | 4 ++-- tests/test_learn_roles.py | 2 +- tests/test_learn_rules.py | 2 +- tests/test_plane_budget.py | 2 +- tests/test_plane_features.py | 2 +- tests/test_plane_increment.py | 4 ++-- tests/test_plane_memory.py | 9 +++++---- tests/test_plane_reconciler.py | 4 ++-- tests/test_plane_remember.py | 5 ++--- tests/test_plane_scoring_parity.py | 2 +- tests/test_plane_tiebreak.py | 2 +- tests/test_plane_verify.py | 2 +- tests/test_search_board.py | 2 +- tests/test_search_budget.py | 2 +- tests/test_search_coordinator.py | 4 ++-- tests/test_search_pilot_run.py | 12 ++++++------ tests/test_search_worker.py | 8 ++++---- tests/test_unseen_draft.py | 6 ++---- tests/test_unseen_eligibility.py | 10 ++++------ 65 files changed, 117 insertions(+), 122 deletions(-) diff --git a/benchmarks/ax/batch.py b/benchmarks/ax/batch.py index e3b5d385..17065fb0 100644 --- a/benchmarks/ax/batch.py +++ b/benchmarks/ax/batch.py @@ -27,7 +27,7 @@ import yaml from benchmarks.valid.artifact_contract import read_benchmark_artifact, write_benchmark_artifact from openultrasast.config import load_dotenv -from openultrasast.plane.memory import PRESIGNED_ARCHIVE_SUFFIX, S3Store, open_store +from openultrasast.memory import PRESIGNED_ARCHIVE_SUFFIX, S3Store, open_store from openultrasast.search.task_storage import diagnostic, exception_reason diff --git a/benchmarks/experiments/exp-004-pooled-block-gate/instrument_check.py b/benchmarks/experiments/exp-004-pooled-block-gate/instrument_check.py index cd9e8572..686a7ece 100644 --- a/benchmarks/experiments/exp-004-pooled-block-gate/instrument_check.py +++ b/benchmarks/experiments/exp-004-pooled-block-gate/instrument_check.py @@ -12,7 +12,7 @@ from pathlib import Path from openultrasast.config import load_dotenv from openultrasast.learn import experiments as ex -from openultrasast.plane.memory import open_store +from openultrasast.memory import open_store EXPERIMENT = "exp-004-pooled-block-gate" UNITS = Path(f"plane/experiments/{EXPERIMENT}.units.jsonl") diff --git a/benchmarks/learn/build_features.py b/benchmarks/learn/build_features.py index 90ae2852..b3d83b26 100644 --- a/benchmarks/learn/build_features.py +++ b/benchmarks/learn/build_features.py @@ -45,6 +45,7 @@ from collections.abc import Mapping from pathlib import Path from typing import Any +from openultrasast import memory from openultrasast.findings import quick_scan_findings from openultrasast.learn.features import ( NONE, @@ -71,7 +72,6 @@ from openultrasast.learn.features import ( from openultrasast.learn.labels import Clone from openultrasast.learn.roles import RoleSet, from_model_roles, infer_for_checkout from openultrasast.pairs import DEFAULT_CATALOG, _materialize_side, _targets, load_pair_catalog -from openultrasast.plane import memory from openultrasast.plane.harvest import declares from openultrasast.plane.tasks.alerts import covers from openultrasast.plane.tasks.alerts import engine_languages as _engine_languages diff --git a/benchmarks/learn/engine_trace.py b/benchmarks/learn/engine_trace.py index eed4562a..66d5f450 100644 --- a/benchmarks/learn/engine_trace.py +++ b/benchmarks/learn/engine_trace.py @@ -31,11 +31,11 @@ from engine_trace_worker import EXCLUDED_DIRS, safe_path, unit_record, write_jso from openultrasast.learn.examples import read_jsonl from openultrasast.learn.labels import load_sources, repo_name +from openultrasast.memory import FileStore from openultrasast.model.specs import taint_specs from openultrasast.model.taint import request_params from openultrasast.pairs import _materialize_side, load_pair_catalog from openultrasast.plane.engine_alerts import export_pin -from openultrasast.plane.memory import FileStore from openultrasast.plane.tasks.alerts import engine_languages from openultrasast.preprocess import detect_language diff --git a/benchmarks/learn/engine_trace_ax.py b/benchmarks/learn/engine_trace_ax.py index 46e8258a..b4a49698 100644 --- a/benchmarks/learn/engine_trace_ax.py +++ b/benchmarks/learn/engine_trace_ax.py @@ -17,7 +17,7 @@ from engine_trace_k8s import pack from benchmarks.ax.batch import AXLane, Item, SandboxFailure, Workload, manifest from benchmarks.ax.batch import task_state as task_state -from openultrasast.plane.memory import open_store as open_store +from openultrasast.memory import open_store as open_store def task_manifest(name, args, urls): diff --git a/benchmarks/learn/engine_trace_k8s.py b/benchmarks/learn/engine_trace_k8s.py index 812e2acb..09d06cc3 100644 --- a/benchmarks/learn/engine_trace_k8s.py +++ b/benchmarks/learn/engine_trace_k8s.py @@ -12,7 +12,7 @@ import time import uuid from datetime import timedelta -from openultrasast.plane.memory import PRESIGNED_ARCHIVE_SUFFIX, S3Store, open_store +from openultrasast.memory import PRESIGNED_ARCHIVE_SUFFIX, S3Store, open_store IMAGE = "ghcr.io/norandom/openultrasast:2.0.1" BOOTSTRAP = r""" diff --git a/benchmarks/learn/engine_trace_queue.py b/benchmarks/learn/engine_trace_queue.py index 5243bdfb..69bd1175 100644 --- a/benchmarks/learn/engine_trace_queue.py +++ b/benchmarks/learn/engine_trace_queue.py @@ -9,7 +9,7 @@ import uuid from engine_worker_service import PENDING, client_from_env, pack, put, read, result_key, status -from openultrasast.plane.memory import PRESIGNED_ARCHIVE_SUFFIX +from openultrasast.memory import PRESIGNED_ARCHIVE_SUFFIX class Dispatcher: diff --git a/benchmarks/learn/engine_worker_service.py b/benchmarks/learn/engine_worker_service.py index 0c8aa1ce..11d49457 100644 --- a/benchmarks/learn/engine_worker_service.py +++ b/benchmarks/learn/engine_worker_service.py @@ -28,7 +28,7 @@ from pathlib import Path from engine_trace_worker import unit_record, worker -from openultrasast.plane.memory import S3Client, s3_settings +from openultrasast.memory import S3Client, s3_settings PENDING = "engine-queue/pending/" CLAIMED = "engine-queue/claimed/" diff --git a/benchmarks/learn/slice_leak_audit.py b/benchmarks/learn/slice_leak_audit.py index 6d46b49e..7f369cf3 100644 --- a/benchmarks/learn/slice_leak_audit.py +++ b/benchmarks/learn/slice_leak_audit.py @@ -22,7 +22,7 @@ from openultrasast.config import load_dotenv from openultrasast.learn.examples import load_examples from openultrasast.learn.labels import load_sources from openultrasast.learn.slice import function_slice -from openultrasast.plane.memory import MemoryStore, open_store +from openultrasast.memory import MemoryStore, open_store UNITS = Path("plane/experiments/exp-004-pooled-block-gate.units.jsonl") OUTPUT = Path("benchmarks/measurements/2026-10-03-graph-slice-leak-audit/record.json") diff --git a/benchmarks/search/pilot_run.py b/benchmarks/search/pilot_run.py index 7db28c4b..f11dd500 100644 --- a/benchmarks/search/pilot_run.py +++ b/benchmarks/search/pilot_run.py @@ -21,7 +21,9 @@ from pathlib import Path from benchmarks.ax.batch import AXLane, ClusterUnavailable, SearchExecutorTask, Workload, validate_image from benchmarks.ax.search_verify import AXSideDispatcher, validate_result from benchmarks.search.executor_smoke import CLONE +from openultrasast.budget import BudgetExhausted, SpendBudget from openultrasast.config import load_dotenv +from openultrasast.memory import FileStore, open_store from openultrasast.model.endpoint import ( DEEPSEEK_BASE_ENV, DEEPSEEK_BASE_URL, @@ -30,8 +32,6 @@ from openultrasast.model.endpoint import ( Prices, price_of, ) -from openultrasast.plane.budget import BudgetExhausted, SpendBudget -from openultrasast.plane.memory import FileStore, open_store from openultrasast.provider.openrouter import OpenRouterChatClient from openultrasast.search import _sandbox from openultrasast.search.board import Board diff --git a/benchmarks/unseen/draft.py b/benchmarks/unseen/draft.py index 0eb76da0..2ea6ce6d 100644 --- a/benchmarks/unseen/draft.py +++ b/benchmarks/unseen/draft.py @@ -837,8 +837,7 @@ def run( def main(argv: list[str] | None = None) -> int: - from openultrasast import config - from openultrasast.plane import memory + from openultrasast import config, memory from openultrasast.plane.reconciler import results_root parser = argparse.ArgumentParser(description=__doc__) diff --git a/benchmarks/unseen/eligibility.py b/benchmarks/unseen/eligibility.py index ec1186f9..696fc8b8 100644 --- a/benchmarks/unseen/eligibility.py +++ b/benchmarks/unseen/eligibility.py @@ -18,7 +18,7 @@ from urllib.parse import urlsplit import yaml -from openultrasast.plane.memory import MemoryStore +from openultrasast.memory import MemoryStore URL = re.compile(r"github\.com/([\w.-]+/[\w.-]+)", re.I) NAME = re.compile(r"[\w.-]+/[\w.-]+") @@ -327,8 +327,7 @@ def verify_tests(root: Path) -> dict: def main(argv: list[str] | None = None) -> int: import os - from openultrasast import config - from openultrasast.plane import memory + from openultrasast import config, memory from openultrasast.plane.reconciler import results_root parser = argparse.ArgumentParser(description=__doc__) diff --git a/benchmarks/valid/hunter_arm.py b/benchmarks/valid/hunter_arm.py index 8c42c458..0ed6faf7 100644 --- a/benchmarks/valid/hunter_arm.py +++ b/benchmarks/valid/hunter_arm.py @@ -12,6 +12,7 @@ from copy import deepcopy from pathlib import Path from openultrasast import tool_hunter +from openultrasast.budget import MeteredClient from openultrasast.complexity.map import Hotspot from openultrasast.config import load_config from openultrasast.hunt.runner import _full_checkout as full_checkout @@ -19,7 +20,6 @@ from openultrasast.hunter_tools import clamp_repo_path from openultrasast.learn.program import ANSWER_FORMAT, Caller, Prompt, classify from openultrasast.model.endpoint import resolve_models from openultrasast.model.taxonomy import FAMILY_IDS, load_families -from openultrasast.plane.budget import MeteredClient if __package__ in {None, ""}: sys.path.insert(0, str(Path(__file__).resolve().parents[2])) diff --git a/plane/models/openrouter-embedding.yaml b/plane/models/openrouter-embedding.yaml index 2479cce9..5d7a457d 100644 --- a/plane/models/openrouter-embedding.yaml +++ b/plane/models/openrouter-embedding.yaml @@ -2,7 +2,7 @@ # OpenRouter serves embeddings only; the chat model stays DeepSeek. `openrouter` is not an ax provider, so the # annotation declares the extension. `secretKey` names the Kubernetes Secret and key that hold OPENROUTER_API_KEY; # the key itself is never in a manifest. Prices in USD per million tokens: embeddings bill input only, so the cache -# and output rates are 0 and `plane.budget.MeteredEmbeddingClient` prices the provider's `usage.prompt_tokens`. +# and output rates are 0 and `openultrasast.budget.MeteredEmbeddingClient` prices the provider's `usage.prompt_tokens`. apiVersion: ax.io/v1alpha1 kind: Model metadata: diff --git a/pyproject.toml b/pyproject.toml index 4635c815..f0089e04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ docs = [ "mkdocs>=1.6,<2", "mkdocs-material>=9.5,<10", ] -# The plane's memory store on an S3-compatible bucket (OUSAST_MEMORY=s3://, plane/memory.py; RustFS is the +# The plane's memory store on an S3-compatible bucket (OUSAST_MEMORY=s3://, memory.py; RustFS is the # tested server). Imported lazily; the core install and the file store need nothing beyond PyYAML. s3 = [ "boto3>=1.35,<2", @@ -81,7 +81,7 @@ warn_unused_configs = true module = "tree_sitter" ignore_missing_imports = true -# boto3 is an optional extra without inline types, absent in the type-check environment (plane/memory.py imports +# boto3 is an optional extra without inline types, absent in the type-check environment (memory.py imports # it lazily). [[tool.mypy.overrides]] module = ["boto3", "botocore.*"] diff --git a/src/openultrasast/budget.py b/src/openultrasast/budget.py index aa6b1fe3..177a7591 100644 --- a/src/openultrasast/budget.py +++ b/src/openultrasast/budget.py @@ -13,8 +13,8 @@ from collections.abc import Mapping from decimal import Decimal from typing import Any, Protocol -from ..model.endpoint import Prices -from ..tool_hunter import ChatClient, ChatResponse +from .model.endpoint import Prices +from .tool_hunter import ChatClient, ChatResponse _ACCOUNT_MARKERS = ("HTTP Error 401", "HTTP Error 402", "Insufficient Balance") _USAGE_FIELDS = ("prompt_tokens", "prompt_cache_hit_tokens", "completion_tokens") diff --git a/src/openultrasast/cli.py b/src/openultrasast/cli.py index bb6df86c..764d2bef 100644 --- a/src/openultrasast/cli.py +++ b/src/openultrasast/cli.py @@ -1542,7 +1542,7 @@ def _plane(args: argparse.Namespace) -> int: print(f"plane: {exc}", file=sys.stderr) return 2 if args.plane_command == "run": - from .plane.memory import MemoryStoreError + from .memory import MemoryStoreError _plane_memory("seed", args.run_manifest) try: @@ -1618,7 +1618,7 @@ def _plane_alerts_engine(args: argparse.Namespace) -> int: def _plane_memory_normalise(args: argparse.Namespace) -> int: """``ousast plane memory-normalise``: one pass over every row object; prints the counts.""" - from .plane import memory + from . import memory try: store = memory.open_store(args.store) @@ -1640,7 +1640,8 @@ def _plane_memory( ) -> int: """``seed`` before a Run, ``ingest`` after it (and ``ousast plane remember``). A store failure is reported and never changes the run's result: ingest can be repeated by hand.""" - from .plane import memory, reconciler + from . import memory + from .plane import reconciler from .plane.tasks.remember import UNKNOWN, remember_run try: diff --git a/src/openultrasast/hunt/runner.py b/src/openultrasast/hunt/runner.py index cb9abbe7..72100221 100644 --- a/src/openultrasast/hunt/runner.py +++ b/src/openultrasast/hunt/runner.py @@ -20,8 +20,8 @@ from pathlib import Path from typing import Any from .. import source +from ..budget import cost_of from ..model.endpoint import _PRICES -from ..plane.budget import cost_of from ..preprocess import detect_language from .artifact import RunArtifact, UsageLedger from .labels import label_rows diff --git a/src/openultrasast/learn/cli.py b/src/openultrasast/learn/cli.py index d0aff8b3..9c9a0bcc 100644 --- a/src/openultrasast/learn/cli.py +++ b/src/openultrasast/learn/cli.py @@ -116,8 +116,8 @@ def _experiment(args: argparse.Namespace) -> int: ceiling stops the run (``unfinished``: a rerun resumes from the outcome rows).""" from datetime import date - from ..plane.budget import MeteredClient - from ..plane.memory import open_store + from ..budget import MeteredClient + from ..memory import open_store from . import experiments as ex from .program import Caller, ReplayMiss @@ -240,7 +240,7 @@ def _write(report: dict[str, Any], out: Path | None) -> None: def _caller(args: argparse.Namespace, store: Any, model: str) -> Any: """The metered, cached caller; ``None`` client under --replay-only. Exits 2 without a ceiling or a key.""" - from ..plane.budget import MeteredClient + from ..budget import MeteredClient from .program import Caller parameters = _model_parameters(args.manifest) @@ -275,8 +275,8 @@ def _program_command(args: argparse.Namespace) -> int: """compile | evaluate | curve. Exit 3 when the ceiling stops the run (``unfinished``, no artifact, no number).""" from datetime import date - from ..plane.budget import BudgetExhausted - from ..plane.memory import open_store + from ..budget import BudgetExhausted + from ..memory import open_store from .compile import DEFAULT_SPEC, compile_program, load_program, load_spec, spec_of from .embeddings import EmbeddingCache from .evaluate import candidate_from_example, evaluate, learning_curve, predict, targets, unevaluable_families @@ -341,8 +341,8 @@ def _model_parameters(path: Path) -> dict[str, Any]: def _memory_embed(args: argparse.Namespace) -> int: """Exit 2 without a ceiling, 3 when the ceiling stops the run (``unfinished``; a rerun resumes from the cache).""" - from ..plane.budget import BudgetExhausted, MeteredEmbeddingClient - from ..plane.memory import open_store + from ..budget import BudgetExhausted, MeteredEmbeddingClient + from ..memory import open_store from .embeddings import embed_excerpts from .examples import EXAMPLE_KIND @@ -370,7 +370,7 @@ def _memory_embed(args: argparse.Namespace) -> int: def _memory_build(args: argparse.Namespace) -> int: """Exit 2 on a refused label (``origin: user``, a source outside the list) or a source with >10% unread excerpts.""" - from ..plane.memory import open_store + from ..memory import open_store from .examples import ExampleBuildError, SideReader, build_examples, pair_pins, read_jsonl, records_by_key from .labels import DEFAULT_CACHE, DEFAULT_SOURCES, load_sources @@ -402,7 +402,7 @@ def _memory_build(args: argparse.Namespace) -> int: def _audit_leaks(args: argparse.Namespace) -> int: """Exit 2 when the store holds no pair to audit (an unread store is not a clean one).""" - from ..plane.memory import open_store + from ..memory import open_store from .leaks import MIN_PAIRS, THRESHOLD, audit, pair_rows, sides_from_units store = open_store(args.memory) diff --git a/src/openultrasast/learn/compile.py b/src/openultrasast/learn/compile.py index 2f7d46b9..249b49a8 100644 --- a/src/openultrasast/learn/compile.py +++ b/src/openultrasast/learn/compile.py @@ -36,8 +36,8 @@ from dataclasses import dataclass, field, replace from pathlib import Path from typing import Any -from ..plane.budget import BudgetExhausted -from ..plane.memory import MemoryStore +from ..budget import BudgetExhausted +from ..memory import MemoryStore from .examples import Example from .folds import CompileSplit, Fold, assert_disjoint, compile_split, folds_digest, outer_folds from .labels import _ADVISORY diff --git a/src/openultrasast/learn/embeddings.py b/src/openultrasast/learn/embeddings.py index d408307b..4d95feb5 100644 --- a/src/openultrasast/learn/embeddings.py +++ b/src/openultrasast/learn/embeddings.py @@ -2,7 +2,7 @@ OpenRouter serves embeddings only (``openai/text-embedding-3-small``, 1,536 dimensions, $0.02 per million input tokens; ``plane/models/openrouter-embedding.yaml``). Every call goes through -:class:`..plane.budget.MeteredEmbeddingClient`, so a ceiling stops the next batch and a call reporting no tokens is +:class:`..budget.MeteredEmbeddingClient`, so a ceiling stops the next batch and a call reporting no tokens is an error, not a free call. The cache key is the excerpt's sha (the content-addressed blob ``excerpts/.txt``) per embedding model: ``embeddings//.json`` holds ``{model, dimensions, vector (float32, base64, little-endian), tokens, created}``. An excerpt is embedded once; a rerun makes no call. @@ -20,8 +20,8 @@ from dataclasses import asdict, dataclass from datetime import date from typing import Any -from ..plane.budget import EmbeddingClient -from ..plane.memory import MemoryStore +from ..budget import EmbeddingClient +from ..memory import MemoryStore from .excerpt import excerpt_sha, normalise DEFAULT_MODEL = "openai/text-embedding-3-small" diff --git a/src/openultrasast/learn/examples.py b/src/openultrasast/learn/examples.py index 592def35..22ba3ff3 100644 --- a/src/openultrasast/learn/examples.py +++ b/src/openultrasast/learn/examples.py @@ -37,7 +37,7 @@ from dataclasses import asdict, dataclass, field from pathlib import Path from typing import Any -from ..plane.memory import MemoryStore, repo_key, row_id +from ..memory import MemoryStore, repo_key, row_id from .excerpt import EXAMPLE, Bounds, delta_diff, excerpt, function_bounds, identities_of from .labels import Label, Sources from .schema import features_for diff --git a/src/openultrasast/learn/experiments.py b/src/openultrasast/learn/experiments.py index b12e823f..e58894d1 100644 --- a/src/openultrasast/learn/experiments.py +++ b/src/openultrasast/learn/experiments.py @@ -42,8 +42,8 @@ from typing import Any import yaml -from ..plane.budget import BudgetExhausted, MeteredClient -from ..plane.memory import MemoryStore, row_id +from ..budget import BudgetExhausted, MeteredClient +from ..memory import MemoryStore, row_id from .compile import load_program, spec_of from .evaluate import ( BOUNDS, diff --git a/src/openultrasast/learn/fill.py b/src/openultrasast/learn/fill.py index e6d0ce12..0a9785a9 100644 --- a/src/openultrasast/learn/fill.py +++ b/src/openultrasast/learn/fill.py @@ -12,9 +12,9 @@ from collections.abc import Callable, Mapping, Sequence from dataclasses import dataclass from typing import Any +from ..budget import BudgetExhausted, MeteredClient, cost_of, prices_from +from ..memory import MemoryStore from ..model.endpoint import DeepSeekChatClient -from ..plane.budget import BudgetExhausted, MeteredClient, cost_of, prices_from -from ..plane.memory import MemoryStore from ..tool_hunter import ChatClient, ChatResponse from . import experiments as ex from .examples import Example diff --git a/src/openultrasast/learn/program.py b/src/openultrasast/learn/program.py index f4faa1bf..0a3da4b6 100644 --- a/src/openultrasast/learn/program.py +++ b/src/openultrasast/learn/program.py @@ -32,8 +32,8 @@ from collections.abc import Callable, Collection, Mapping, Sequence from dataclasses import asdict, dataclass, field, replace from typing import Any -from ..plane.budget import cost_of, prices_from -from ..plane.memory import MemoryStore +from ..budget import cost_of, prices_from +from ..memory import MemoryStore from .examples import Example from .folds import Fold from .retrieve import Retrieval, Target, assert_boundary, demonstrations_for, retrieve @@ -368,7 +368,7 @@ def params_digest(parameters: Mapping[str, Any] | None) -> str: @dataclass class Caller: """Every model call of a program run: cached by request in ``responses/.json`` (and in memory), replayed at - $0. ``client`` is a metered client (``plane.budget.MeteredClient``); ``None`` is replay-only.""" + $0. ``client`` is a metered client (``budget.MeteredClient``); ``None`` is replay-only.""" client: Any model: str diff --git a/src/openultrasast/memory.py b/src/openultrasast/memory.py index b17b8bae..6a5f3c49 100644 --- a/src/openultrasast/memory.py +++ b/src/openultrasast/memory.py @@ -901,7 +901,7 @@ def s3_settings(environ: Mapping[str, str] | None = None) -> dict[str, Any]: """Endpoint, keys, region and session token from ``.env``/the environment; a missing key is named, a value never is. ``S3_ENDPOINT`` is a full URL (``https://host[:port]``).""" if environ is None: - from ..config import load_dotenv + from .config import load_dotenv load_dotenv() environ = os.environ @@ -925,7 +925,7 @@ def open_store(spec: str | None = None, environ: Mapping[str, str] | None = None """The store ``spec`` (else ``OUSAST_MEMORY``, else ``file:///memory``) names. ``s3://`` with no bucket uses ``S3_BUCKET``. ``read_only`` skips the S3 write/Select capability probe and refuses S3 mutations; it is intended for GET/list inventory readers, which do not need Select. Default opening is unchanged.""" - from .reconciler import results_root + from .plane.reconciler import results_root env = environ if environ is not None else os.environ text = spec or env.get("OUSAST_MEMORY") or "" @@ -980,7 +980,7 @@ def seed(run_manifest: Path, store: MemoryStore | None = None, *, results_root: """Reuse stored facts for a Run's tasks whose ``openultrasast.io/memory-key`` matches (Req 6.1): each such task without a directory or a state gets ``facts.json`` and a ``done`` summary and is marked done under the run lock. Returns the seeded task names. A changed pin, candidate set or runner image finds nothing and recomputes.""" - from . import reconciler + from .plane import reconciler run_spec, manifests = reconciler.load_run(Path(run_manifest)) store = store or open_store() diff --git a/src/openultrasast/plane/delivery.py b/src/openultrasast/plane/delivery.py index bb60739f..76eb0327 100644 --- a/src/openultrasast/plane/delivery.py +++ b/src/openultrasast/plane/delivery.py @@ -30,8 +30,8 @@ from pathlib import Path from typing import Any from urllib.parse import urlsplit +from ..memory import RUNS_PREFIX, MemoryStore from .manifests import Run -from .memory import RUNS_PREFIX, MemoryStore __all__ = ["DONE", "GRACE_SECONDS", "OUTPUT_TAR", "STATE", "Delivery", "DeliveryError", "declared", "expiry", "input_var"] diff --git a/src/openultrasast/plane/doctor.py b/src/openultrasast/plane/doctor.py index f9cc345c..35e01fff 100644 --- a/src/openultrasast/plane/doctor.py +++ b/src/openultrasast/plane/doctor.py @@ -108,7 +108,7 @@ def doctor(profile: PlaneProfile | None = None) -> list[tuple[str, bool, str]]: else: ok, out = _registry_has(runner) checks.append((f"runner image in {profile.registry}", ok, out if ok else f"{out}; {hint} and loads it")) - from .memory import MemoryStoreError, open_store # lazy: boto3 only when the profile names an S3 store + from ..memory import MemoryStoreError, open_store # lazy: boto3 only when the profile names an S3 store try: store = open_store(profile.memory) diff --git a/src/openultrasast/plane/generate.py b/src/openultrasast/plane/generate.py index 2219df43..ab2b8885 100644 --- a/src/openultrasast/plane/generate.py +++ b/src/openultrasast/plane/generate.py @@ -21,7 +21,7 @@ under ``--plane`` (default ``plane/``), everything a Run over the set needs besi stems) the memory rows carry. Each ``repo-facts`` Task carries ``openultrasast.io/memory-key`` (repository, pin, candidates digest, runner image -digest): the key under which stored facts are reused instead of recomputed (``plane/memory.py``, ``seed``). +digest): the key under which stored facts are reused instead of recomputed (``memory.py``, ``seed``). Why per-case Tasks rather than one Task per step: an ax Task binds its Workspaces by name and a Run entry adds neither a binding nor env (it names a Task, artifacts and a budget), and ``Run.inputs`` accepts only @@ -57,10 +57,10 @@ from typing import Any import yaml +from ..budget import cost_of +from ..memory import MEMORY_KEY_ANNOTATION, POPULATION_ANNOTATION, SPLIT_ANNOTATION, memory_key from ..model.endpoint import price_of -from .budget import cost_of from .manifests import GIT_COMMITS_ANNOTATION, RUN_API_VERSION, Task, load_manifests -from .memory import MEMORY_KEY_ANNOTATION, POPULATION_ANNOTATION, SPLIT_ANNOTATION, memory_key from .reconciler import _ax_name, _doc from .tasks.repo_facts import _digest from .tasks.verify import MAX_STEPS, units_of diff --git a/src/openultrasast/plane/reconciler.py b/src/openultrasast/plane/reconciler.py index 6b367f9d..cec5490b 100644 --- a/src/openultrasast/plane/reconciler.py +++ b/src/openultrasast/plane/reconciler.py @@ -42,11 +42,11 @@ from typing import Any import yaml +from ..memory import open_store from .delivery import Delivery, DeliveryError, declared from .doctor import doctor from .egress import Egress, policy_for from .manifests import AX_API_VERSION, Manifests, Model, Run, RunTask, Task, Workspace, load_manifests -from .memory import open_store from .profile import PlaneProfile, load_profile from .router import Router, credentials, open_router diff --git a/src/openultrasast/plane/tasks/remember.py b/src/openultrasast/plane/tasks/remember.py index d501b12d..53be97db 100644 --- a/src/openultrasast/plane/tasks/remember.py +++ b/src/openultrasast/plane/tasks/remember.py @@ -40,7 +40,7 @@ from typing import Any import yaml from ...learn.schema import validate_record -from ..memory import REMEMBER_OUTPUT, IngestResult, MemoryStore, image_digest, ingest, repo_key, row_id, validate_row +from ...memory import REMEMBER_OUTPUT, IngestResult, MemoryStore, image_digest, ingest, repo_key, row_id, validate_row from .repo_facts import _digest PASSES = ("a", "b", "c") diff --git a/src/openultrasast/plane/tasks/roles.py b/src/openultrasast/plane/tasks/roles.py index 1eb8ee69..c25a6563 100644 --- a/src/openultrasast/plane/tasks/roles.py +++ b/src/openultrasast/plane/tasks/roles.py @@ -30,11 +30,11 @@ from collections.abc import Mapping, Sequence from pathlib import Path from typing import Any +from ...budget import AccountError, BudgetExhausted, MeteredClient from ...learn.roles import MODEL_ROLE_KINDS from ...learn.schema import OPERATIONS, SOURCE_KINDS from ...source import MODULE_FUNCTION, product_files from ...tool_hunter import ChatClient -from ..budget import AccountError, BudgetExhausted, MeteredClient from .verify import build_client CHUNK_LINES = 400 diff --git a/src/openultrasast/plane/tasks/verify.py b/src/openultrasast/plane/tasks/verify.py index 2c126fde..0b42a7d7 100644 --- a/src/openultrasast/plane/tasks/verify.py +++ b/src/openultrasast/plane/tasks/verify.py @@ -26,8 +26,8 @@ from collections.abc import Mapping, Sequence from pathlib import Path from typing import Any +from ...budget import AccountError, BudgetExhausted, MeteredClient from ...tool_hunter import CLIENT_ENV, ChatClient, ChatResponse, resolve_hunter_client, run_tool_hunter, scripted_hunter_client -from ..budget import AccountError, BudgetExhausted, MeteredClient PER_HUNT = 6 MAX_STEPS = 6 diff --git a/src/openultrasast/search/board.py b/src/openultrasast/search/board.py index 82650bf6..1abf5da7 100644 --- a/src/openultrasast/search/board.py +++ b/src/openultrasast/search/board.py @@ -15,7 +15,7 @@ from typing import Any import yaml -from ..plane.memory import MemoryStore +from ..memory import MemoryStore class Board: diff --git a/src/openultrasast/search/coordinator.py b/src/openultrasast/search/coordinator.py index 855995c1..e3e4337d 100644 --- a/src/openultrasast/search/coordinator.py +++ b/src/openultrasast/search/coordinator.py @@ -14,7 +14,7 @@ from collections.abc import Callable from dataclasses import asdict, dataclass, replace from typing import Any, Protocol -from ..plane.budget import BudgetExhausted, SpendBudget +from ..budget import BudgetExhausted, SpendBudget from .board import Board from .budget import SearchBudget @@ -43,7 +43,7 @@ class Executor(Protocol): A missing cost on a model task charges its entire reservation. Model workers must reserve each call against limits.max_call_usd (the task's - total allowance) using plane.budget.SpendBudget. Exceptions are untrusted + total allowance) using openultrasast.budget.SpendBudget. Exceptions are untrusted diagnostics and must never be copied into the board. """ ... diff --git a/src/openultrasast/search/worker.py b/src/openultrasast/search/worker.py index 26aacd64..55ec1698 100644 --- a/src/openultrasast/search/worker.py +++ b/src/openultrasast/search/worker.py @@ -11,8 +11,8 @@ from typing import Any, Protocol, cast import yaml +from ..budget import BudgetExhausted, SpendBudget, cost_of from ..model.endpoint import Prices -from ..plane.budget import BudgetExhausted, SpendBudget, cost_of from ..provider.openrouter import parse_json_content from . import _sandbox from .budget import SearchBudget diff --git a/tests/plane_fake_store.py b/tests/plane_fake_store.py index 5f81c53b..70799d7e 100644 --- a/tests/plane_fake_store.py +++ b/tests/plane_fake_store.py @@ -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): diff --git a/tests/test_docs_site.py b/tests/test_docs_site.py index e912251d..5b9670b4 100644 --- a/tests/test_docs_site.py +++ b/tests/test_docs_site.py @@ -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)", diff --git a/tests/test_engine_trace.py b/tests/test_engine_trace.py index e95d1a9e..f41bc4b8 100644 --- a/tests/test_engine_trace.py +++ b/tests/test_engine_trace.py @@ -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 = {}, [], [] diff --git a/tests/test_learn_compile.py b/tests/test_learn_compile.py index f5bc9eec..6c85d906 100644 --- a/tests/test_learn_compile.py +++ b/tests/test_learn_compile.py @@ -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) diff --git a/tests/test_learn_decide.py b/tests/test_learn_decide.py index b988ea9b..ce169bc2 100644 --- a/tests/test_learn_decide.py +++ b/tests/test_learn_decide.py @@ -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]: diff --git a/tests/test_learn_embeddings.py b/tests/test_learn_embeddings.py index bb7cc0cb..c51deef9 100644 --- a/tests/test_learn_embeddings.py +++ b/tests/test_learn_embeddings.py @@ -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} diff --git a/tests/test_learn_examples.py b/tests/test_learn_examples.py index ed8e6a81..1dea584f 100644 --- a/tests/test_learn_examples.py +++ b/tests/test_learn_examples.py @@ -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( diff --git a/tests/test_learn_experiments.py b/tests/test_learn_experiments.py index 0cb047fe..a88384e1 100644 --- a/tests/test_learn_experiments.py +++ b/tests/test_learn_experiments.py @@ -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} diff --git a/tests/test_learn_fill.py b/tests/test_learn_fill.py index 8e8ec3be..82f3990f 100644 --- a/tests/test_learn_fill.py +++ b/tests/test_learn_fill.py @@ -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]: diff --git a/tests/test_learn_leaks.py b/tests/test_learn_leaks.py index 70a66f1f..e7b63cca 100644 --- a/tests/test_learn_leaks.py +++ b/tests/test_learn_leaks.py @@ -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]: diff --git a/tests/test_learn_program.py b/tests/test_learn_program.py index f2d297a0..99d8cd6c 100644 --- a/tests/test_learn_program.py +++ b/tests/test_learn_program.py @@ -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) diff --git a/tests/test_learn_roles.py b/tests/test_learn_roles.py index 01e10459..6035f94c 100644 --- a/tests/test_learn_roles.py +++ b/tests/test_learn_roles.py @@ -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 diff --git a/tests/test_learn_rules.py b/tests/test_learn_rules.py index 14cfa06a..175e3184 100644 --- a/tests/test_learn_rules.py +++ b/tests/test_learn_rules.py @@ -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] diff --git a/tests/test_plane_budget.py b/tests/test_plane_budget.py index 266e6001..037e2d8a 100644 --- a/tests/test_plane_budget.py +++ b/tests/test_plane_budget.py @@ -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} diff --git a/tests/test_plane_features.py b/tests/test_plane_features.py index 439e7f1d..1b5f94c3 100644 --- a/tests/test_plane_features.py +++ b/tests/test_plane_features.py @@ -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 diff --git a/tests/test_plane_increment.py b/tests/test_plane_increment.py index 87f868c6..d2e50b39 100644 --- a/tests/test_plane_increment.py +++ b/tests/test_plane_increment.py @@ -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") diff --git a/tests/test_plane_memory.py b/tests/test_plane_memory.py index e58cb586..bc00729c 100644 --- a/tests/test_plane_memory.py +++ b/tests/test_plane_memory.py @@ -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' diff --git a/tests/test_plane_reconciler.py b/tests/test_plane_reconciler.py index afb269cb..4b31e634 100644 --- a/tests/test_plane_reconciler.py +++ b/tests/test_plane_reconciler.py @@ -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 diff --git a/tests/test_plane_remember.py b/tests/test_plane_remember.py index cacdf9c0..7b7ccb31 100644 --- a/tests/test_plane_remember.py +++ b/tests/test_plane_remember.py @@ -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 diff --git a/tests/test_plane_scoring_parity.py b/tests/test_plane_scoring_parity.py index 7c44cb69..b4c4f719 100644 --- a/tests/test_plane_scoring_parity.py +++ b/tests/test_plane_scoring_parity.py @@ -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 diff --git a/tests/test_plane_tiebreak.py b/tests/test_plane_tiebreak.py index 61a79edd..2379cb51 100644 --- a/tests/test_plane_tiebreak.py +++ b/tests/test_plane_tiebreak.py @@ -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 diff --git a/tests/test_plane_verify.py b/tests/test_plane_verify.py index 69cb1bc1..707d734f 100644 --- a/tests/test_plane_verify.py +++ b/tests/test_plane_verify.py @@ -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 diff --git a/tests/test_search_board.py b/tests/test_search_board.py index 9f5a2f81..a11e86f6 100644 --- a/tests/test_search_board.py +++ b/tests/test_search_board.py @@ -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 diff --git a/tests/test_search_budget.py b/tests/test_search_budget.py index 13b98236..5df25462 100644 --- a/tests/test_search_budget.py +++ b/tests/test_search_budget.py @@ -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 diff --git a/tests/test_search_coordinator.py b/tests/test_search_coordinator.py index ed5c37ee..124fc8a9 100644 --- a/tests/test_search_coordinator.py +++ b/tests/test_search_coordinator.py @@ -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] diff --git a/tests/test_search_pilot_run.py b/tests/test_search_pilot_run.py index 619becc8..df8d5c64 100644 --- a/tests/test_search_pilot_run.py +++ b/tests/test_search_pilot_run.py @@ -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) diff --git a/tests/test_search_worker.py b/tests/test_search_worker.py index b476a0ca..1c31bd18 100644 --- a/tests/test_search_worker.py +++ b/tests/test_search_worker.py @@ -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")]), diff --git a/tests/test_unseen_draft.py b/tests/test_unseen_draft.py index 2f3f7e2b..3b1de1fa 100644 --- a/tests/test_unseen_draft.py +++ b/tests/test_unseen_draft.py @@ -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) diff --git a/tests/test_unseen_eligibility.py b/tests/test_unseen_eligibility.py index a6fe6327..573bcaa1 100644 --- a/tests/test_unseen_eligibility.py +++ b/tests/test_unseen_eligibility.py @@ -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")