Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

test(audit): delete source-inspection tests duplicated by behavioral proof (#2172)

Call Whitebd70cbec7530
diff --git a/tests/test_delivery_state_matrix.py b/tests/test_delivery_state_matrix.py
index d3f880a91..8eef1cd93 100644
--- a/tests/test_delivery_state_matrix.py
+++ b/tests/test_delivery_state_matrix.py
@@ -1,11 +1,7 @@
from __future__ import annotations
-import inspect
import re
-from core.session_turns import SessionTurnManager
-from core.vibe_agents import VibeAgentStore
-from storage.background import SQLiteBackgroundTaskStore
from storage.delivery_states import (
ADMITTED_DELIVERY_STATES,
CLAIMABLE_QUEUE_STATES,
@@ -78,18 +74,3 @@ def test_delivery_state_matrix_derives_every_cross_cutting_state_set() -> None:
if policy.run_cancel == "retire":
assert policy.native_effect == "none"
-
-def test_cross_cutting_callers_consume_matrix_semantics() -> None:
- from vibe import ui_server
-
- cancel_source = inspect.getsource(SQLiteBackgroundTaskStore.cancel_run)
- archive_source = inspect.getsource(VibeAgentStore._rewrite_references)
- send_now_source = inspect.getsource(SessionTurnManager._promote_fifo_head)
- show_dispatch_source = inspect.getsource(ui_server._run_show_event_dispatch)
-
- assert "retire_for_run_cancellation" in cancel_source
- assert 'delivery["state"]' not in cancel_source
- assert "message_deliveries" not in archive_source
- assert "snapshot_json" not in archive_source
- assert "expected_delivery_id" in send_now_source
- assert "ADMITTED_DELIVERY_STATES" in show_dispatch_source
diff --git a/tests/test_model_hub_config.py b/tests/test_model_hub_config.py
index be752d783..1f716361c 100644
--- a/tests/test_model_hub_config.py
+++ b/tests/test_model_hub_config.py
@@ -1,6 +1,5 @@
from __future__ import annotations
-import ast
import copy
import inspect
import json
@@ -528,8 +527,6 @@ def _mirror_schemas(registry: dict) -> dict[str, dict]:
def test_frozen_source_and_agent_examples_round_trip_byte_faithfully():
- assert Path("core/handlers/model_hub/adapter.py").read_bytes() == (CONTRACTS / "adapter-interface.py").read_bytes()
-
for example in _schema("source.schema.json")["examples"]:
serialized = ModelHubSourceConfig.from_payload(example).to_payload()
expected = json.loads(json.dumps(example))
@@ -1656,8 +1653,6 @@ def test_config_reload_rejects_pre_v4_opencode_shape_on_invalid_config_path(
backups = list(config_path.parent.glob("config.json.bak-recovery-*"))
assert backups
assert stat.S_IMODE(backups[0].stat().st_mode) == 0o600
- migration_source = inspect.getsource(v2_config._migrate_legacy_model_hub_payload)
- assert "opencode" not in migration_source
def test_config_reload_recovers_malformed_legacy_collections(monkeypatch, tmp_path):
@@ -2016,37 +2011,6 @@ def test_loading_a_persisted_config_yields_one_this_product_can_load_again(monke
assert reloaded.model_hub.to_payload() == loaded.model_hub.to_payload()
-def test_every_normalized_identifier_collection_collapses_through_one_owner():
- # Naming the class rather than its third member. Each collection whose leaf
- # validator settles a spelling needs its parent to collapse on the settled
- # value, and the two that exist cost one review round each because nothing
- # tied the two halves together. Counting them does: a normalization added
- # without its collapse fails here instead of arriving as a finding.
- source = Path("config/v2_config.py").read_text(encoding="utf-8")
- tree = ast.parse(source)
- parents = {child: parent for parent in ast.walk(tree) for child in ast.iter_child_nodes(parent)}
- normalizing = set()
- validating = set()
- collapsing = set()
- for node in ast.walk(tree):
- if not isinstance(node, ast.ClassDef):
- continue
- for call in ast.walk(node):
- if not isinstance(call, ast.Call) or not isinstance(call.func, ast.Name):
- continue
- if call.func.id == "normalized_model_id":
- # A comparison rejects an unsettled spelling; it does not
- # produce a normalized identity or require a collapse owner.
- owner_set = validating if isinstance(parents[call], ast.Compare) else normalizing
- owner_set.add(node.name)
- elif call.func.id == "_collapse_settled_duplicates":
- collapsing.add(node.name)
- assert normalizing == {"ModelHubModelConfig", "ModelHubRouteHopConfig"}
- assert validating == {"ModelHubAgentSupplyConfig"}
- assert collapsing == {"ModelHubSourceConfig", "ModelHubRouteConfig"}
- assert len(collapsing) == len(normalizing)
-
-
@pytest.mark.parametrize("repairing", (False, True))
@pytest.mark.parametrize(
"identifier,valid",
diff --git a/tests/test_model_hub_l3.py b/tests/test_model_hub_l3.py
index 4a6eb4c63..ede27a5dd 100644
--- a/tests/test_model_hub_l3.py
+++ b/tests/test_model_hub_l3.py
@@ -308,61 +308,6 @@ def test_responses_terminal_event_continues_sequence_on_cr_only_frames() -> None
assert event["sequence_number"] == 9
-def test_turn_outcome_copy_projection_has_one_runtime_owner() -> None:
- root = Path(__file__).parents[1]
- owner = root / "core/handlers/model_hub/provenance.py"
- runtime_files = [
- *sorted((root / "core/handlers/model_hub").glob("*.py")),
- root / "modules/agents/model_hub.py",
- ]
-
- assert "modelHub.launch." in owner.read_text(encoding="utf-8")
- for path in runtime_files:
- if path == owner:
- continue
- source = path.read_text(encoding="utf-8")
- assert "modelHub.launch." not in source
- assert '"copy_key"' not in source
-
- excluded = {".git", ".venv", "node_modules"}
-
- def is_projection_constructor(node: ast.Call) -> bool:
- return (
- isinstance(node.func, ast.Name)
- and node.func.id == "TurnOutcomeProjectionInput"
- ) or (
- isinstance(node.func, ast.Attribute)
- and node.func.attr == "TurnOutcomeProjectionInput"
- )
-
- constructor_calls: dict[Path, set[int]] = {}
- for path in root.rglob("*.py"):
- if any(part in excluded for part in path.parts):
- continue
- calls = [
- node.lineno
- for node in ast.walk(ast.parse(path.read_text(encoding="utf-8")))
- if isinstance(node, ast.Call)
- and is_projection_constructor(node)
- ]
- if calls:
- constructor_calls[path] = set(calls)
- owner_tree = ast.parse(owner.read_text(encoding="utf-8"))
- producer = next(
- node
- for node in owner_tree.body
- if isinstance(node, ast.FunctionDef) and node.name == "produce_turn_outcome"
- )
- producer_calls = {
- node.lineno
- for node in ast.walk(producer)
- if isinstance(node, ast.Call)
- and is_projection_constructor(node)
- }
- assert producer_calls
- assert constructor_calls == {owner: producer_calls}
-
-
def test_gateway_handle_termination_has_one_settlement_owner() -> None:
path = Path(__file__).parents[1] / "core/handlers/model_hub/turn_gateway.py"
tree = ast.parse(path.read_text(encoding="utf-8"))
@@ -452,33 +397,6 @@ def test_gateway_handle_termination_has_one_settlement_owner() -> None:
assert registered_closers[0].args[0].attr == "close_stream"
-def test_terminal_chain_reinspection_has_no_execution_channel_input() -> None:
- path = Path(__file__).parents[1] / "core/handlers/model_hub/service.py"
- tree = ast.parse(path.read_text(encoding="utf-8"))
- functions = {
- node.name: node
- for node in ast.walk(tree)
- if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef))
- }
- owner = functions["_inspect_terminal_chain"]
- owner_inputs = {
- argument.arg
- for argument in (*owner.args.args, *owner.args.kwonlyargs)
- }
- assert "supply_channel" not in owner_inputs
-
- def calls_owner(function_name: str) -> bool:
- return any(
- isinstance(node, ast.Call)
- and isinstance(node.func, ast.Attribute)
- and node.func.attr == "_inspect_terminal_chain"
- for node in ast.walk(functions[function_name])
- )
-
- assert calls_owner("_produce_attempt_terminal_outcome")
- assert calls_owner("resolve")
-
-
def _terminal_resolution_facts(
config: ModelHubConfig,
*,
@@ -10684,28 +10602,6 @@ def test_a_burst_of_metering_neither_borrows_the_shared_pool_nor_grows_unbounded
asyncio.run(exercise())
-def test_no_ending_of_a_turn_decides_for_itself_what_the_call_did() -> None:
- """The metering facts have one owner, so an ending is a *when*, not a *what*.
-
- Endings that answered locally answered in the vocabulary of the shape they
- happened to see, and the boundary — which can see either — got the buffered
- one wrong. An ending added later is covered by construction if it cannot pass
- the answer in, so that is what is asserted rather than today's three endings.
- """
-
- path = Path(__file__).parents[1] / "core/handlers/model_hub/turn_gateway.py"
- calls = [
- node
- for node in ast.walk(ast.parse(path.read_text(encoding="utf-8")))
- if isinstance(node, ast.Call)
- and isinstance(node.func, ast.Attribute)
- and node.func.attr == "_record_usage"
- ]
-
- assert calls, "the gateway must still meter the calls whose body it forwards"
- assert all(len(call.args) == 1 and not call.keywords for call in calls)
-
-
def test_no_downstream_ending_after_adoption_can_drop_the_turn_from_the_ledger(
tmp_path: Path,
) -> None:
diff --git a/tests/test_model_hub_resolution.py b/tests/test_model_hub_resolution.py
index f6a644e2e..8d119f089 100644
--- a/tests/test_model_hub_resolution.py
+++ b/tests/test_model_hub_resolution.py
@@ -2311,50 +2311,6 @@ def test_all_interruption_guards_use_the_shared_baseline_comparator():
assert "_would_interrupt" not in calls(methods[name])
-def test_credential_target_and_refresh_capability_have_single_service_consumers():
- from ast import AsyncFunctionDef, Attribute, Call, Name, parse, walk
- from pathlib import Path
-
- tree = parse(
- (Path(__file__).parents[1] / "core/handlers/model_hub/service.py").read_text(
- encoding="utf-8"
- )
- )
- methods = {
- node.name: node
- for node in walk(tree)
- if isinstance(node, AsyncFunctionDef)
- }
-
- def calls(method: AsyncFunctionDef) -> set[str]:
- return {
- node.func.id
- if isinstance(node.func, Name)
- else node.func.attr
- for node in walk(method)
- if isinstance(node, Call)
- and isinstance(node.func, (Name, Attribute))
- }
-
- assert "retarget_api_key_credential" in calls(methods["patch_source"])
- assert "_classify_credential_outcome" in calls(
- methods["_classify_source_outcome"]
- )
- assert "credential_supports_refresh" in calls(
- methods["_classify_credential_outcome"]
- )
- assert "_probe_agent_once" in calls(methods["probe_agent"])
- assert "_classify_source_outcome" in calls(methods["_probe_agent_once"])
- assert "_invoke_admitted" in calls(methods["_probe_agent_once"])
- assert "_classify_source_outcome" in calls(methods["resolve"])
- capability_callers = {
- name
- for name, method in methods.items()
- if "credential_supports_refresh" in calls(method)
- }
- assert capability_callers == {"_classify_credential_outcome"}
-
-
def test_direct_mode_refuses_chain_and_probe(tmp_path):
config = ModelHubConfig()
service, _, _ = _service(tmp_path, config)
diff --git a/tests/test_opencode_stop_receipt.py b/tests/test_opencode_stop_receipt.py
index fe4890a84..10eeb476e 100644
--- a/tests/test_opencode_stop_receipt.py
+++ b/tests/test_opencode_stop_receipt.py
@@ -11,7 +11,6 @@ silent result — a turn that ends with no trace at all.
from __future__ import annotations
import asyncio
-import inspect
import sys
import unittest
from pathlib import Path
@@ -323,26 +322,6 @@ class OpenCodeStopIntentTests(unittest.IsolatedAsyncioTestCase):
self.assertEqual(agent._user_stopped_sessions, set())
-class OpenCodeStopReceiptTests(unittest.TestCase):
- """The intent is only useful if the cancellation branch actually spends it.
-
- ``_process_message`` is a several-hundred-line coroutine whose cancellation
- branch sits behind server startup, session creation and the poll loop, so
- driving it here would mostly be a test of the stubs. Pin the coupling
- instead: the branch must read the intent set and ask for the receipt.
- """
-
- def test_restored_cancellation_branch_reads_the_intent(self):
- source = inspect.getsource(OpenCodePollLoop.run_restored_poll_loop)
- _, _, after = source.partition("except asyncio.CancelledError:")
- branch = after.partition("raise")[0]
-
- self.assertTrue(branch, "run_restored_poll_loop no longer handles cancellation")
- self.assertIn("consume_user_stop_intent", branch)
- self.assertIn("STOPPED_REACTION_EMOJI", branch)
- self.assertIn("restored_request", branch)
-
-
class _StubOpenCodeServer:
def __init__(self, *, block_start: bool = False):
self.block_start = block_start
diff --git a/tests/test_ui_show_pages.py b/tests/test_ui_show_pages.py
index 6fff34dcb..9f840295f 100644
--- a/tests/test_ui_show_pages.py
+++ b/tests/test_ui_show_pages.py
@@ -8348,122 +8348,6 @@ def test_show_runtime_failure_declarations_are_total_and_owner_safe():
)
-def test_download_failure_declaration_keys_cover_owner_stored_fields():
- details_tree = ast.parse(textwrap.dedent(inspect.getsource(dependency_network.dependency_error_details)))
- owner_stored_fields: set[str] = set()
-
- class DownloadDetailFieldVisitor(ast.NodeVisitor):
- def visit_Dict(self, node: ast.Dict) -> None:
- owner_stored_fields.update(
- key.value
- for key in node.keys
- if isinstance(key, ast.Constant) and isinstance(key.value, str)
- )
- self.generic_visit(node)
-
- def visit_Call(self, node: ast.Call) -> None:
- if isinstance(node.func, ast.Attribute) and node.func.attr == "update":
- owner_stored_fields.update(keyword.arg for keyword in node.keywords if keyword.arg)
- self.generic_visit(node)
-
- DownloadDetailFieldVisitor().visit(details_tree)
- declaration_lookup_tree = ast.parse(
- textwrap.dedent(inspect.getsource(show_runtime_failures_module._failure_declaration))
- )
- declaration_key_fields = {
- node.attr
- for node in ast.walk(declaration_lookup_tree)
- if isinstance(node, ast.Attribute)
- and isinstance(node.value, ast.Name)
- and node.value.id == "evidence"
- }
- explicitly_irrelevant = {
- "attempts",
- "exception_type",
- "host",
- "http_status",
- "kind",
- "message",
- "retry_after_seconds",
- "url",
- }
-
- assert owner_stored_fields - explicitly_irrelevant <= declaration_key_fields
-
-
-def test_archive_failure_provenance_census_matches_archive_path_emissions():
- manager_tree = ast.parse(textwrap.dedent(inspect.getsource(ShowRuntimeManager))).body[0]
- configured_archive_reasons: set[str] = set()
-
- def archive_path_guard(test: ast.expr) -> bool | None:
- if (
- isinstance(test, ast.Attribute)
- and isinstance(test.value, ast.Name)
- and test.value.id == "self"
- and test.attr == "archive_path"
- ):
- return True
- if isinstance(test, ast.UnaryOp) and isinstance(test.op, ast.Not):
- nested = archive_path_guard(test.operand)
- return None if nested is None else not nested
- if (
- isinstance(test, ast.Compare)
- and len(test.ops) == 1
- and len(test.comparators) == 1
- and isinstance(test.comparators[0], ast.Constant)
- and test.comparators[0].value is None
- ):
- nested = archive_path_guard(test.left)
- if nested is None:
- return None
- if isinstance(test.ops[0], (ast.IsNot, ast.NotEq)):
- return True
- if isinstance(test.ops[0], (ast.Is, ast.Eq)):
- return False
- return None
-
- class ArchivePathEmissionVisitor(ast.NodeVisitor):
- def __init__(self) -> None:
- self.archive_path_is_set = False
-
- def visit_If(self, node: ast.If) -> None:
- previous = self.archive_path_is_set
- guard = archive_path_guard(node.test)
- self.archive_path_is_set = previous or guard is True
- for child in node.body:
- self.visit(child)
- self.archive_path_is_set = previous or guard is False
- for child in node.orelse:
- self.visit(child)
- self.archive_path_is_set = previous
-
- def visit_Constant(self, node: ast.Constant) -> None:
- if (
- self.archive_path_is_set
- and isinstance(node.value, str)
- and node.value.startswith("runtime_archive_")
- ):
- configured_archive_reasons.add(node.value)
-
- ArchivePathEmissionVisitor().visit(manager_tree)
- declared_provenance = {
- reason: {
- provenance
- for (declared_reason, provenance, _retryable), declaration in SHOW_RUNTIME_FAILURE_DECLARATIONS.items()
- if declared_reason == reason and "archive" in declaration.owning_artifact
- }
- for reason in configured_archive_reasons
- }
- assert declared_provenance == {
- reason: {"configured", "packaged"} for reason in configured_archive_reasons
- }
- assert {
- declaration.reason
- for declaration in SHOW_RUNTIME_FAILURE_DECLARATIONS.values()
- if declaration.provenance == "configured" and declaration.owning_artifact == "configured-archive"
- } == configured_archive_reasons
-
-
def test_show_runtime_reason_literals_have_declared_evidence():
source = inspect.getsource(show_runtime)
reason_literals = {
@@ -9276,48 +9160,6 @@ def test_show_runtime_capability_probe_treats_transport_failure_as_unknown(monke
assert asyncio.run(manager._probe_render_markdown_capability("http://127.0.0.1:12345")) is None
-def test_provider_install_entrypoints_converge_on_single_admission_owner():
- manager_tree = ast.parse(textwrap.dedent(inspect.getsource(ShowRuntimeManager))).body[0]
- functions = {
- node.name: node for node in manager_tree.body if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef))
- }
- provider_methods = {
- "_install_manifest_runtime_locked",
- "_install_archive_runtime",
- "_install_npm_runtime",
- }
- direct_provider_callers = {
- function.name
- for function in functions.values()
- if any(
- isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute) and node.func.attr in provider_methods
- for node in ast.walk(function)
- )
- }
- assert direct_provider_callers == {"_install_managed_runtime_locked"}
-
- owner_callers = {
- function.name
- for function in functions.values()
- if any(
- isinstance(node, ast.Call)
- and isinstance(node.func, ast.Attribute)
- and node.func.attr == "_install_managed_runtime_locked"
- for node in ast.walk(function)
- )
- }
- assert owner_callers == {"_attempt_managed_install"}
-
- admission_callers = {
- function.name
- for function in functions.values()
- if any(
- isinstance(node, ast.Attribute) and node.attr == "_attempt_managed_install" for node in ast.walk(function)
- )
- }
- assert admission_callers == {"_resolve_managed_availability", "_prepare"}
-
-
def test_explicit_command_resolution_has_one_owner_and_four_consumers():
manager_tree = ast.parse(textwrap.dedent(inspect.getsource(ShowRuntimeManager))).body[0]
functions = {