The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: keep the invariant tests for the jonpol01 perf trio
kshitijk4poore1760ee4c94d
diff --git a/tests/agent/test_memory_context_dedupe.py b/tests/agent/test_memory_context_dedupe.pyindex 2c20b2de31a..c78c5f58caf 100644--- a/tests/agent/test_memory_context_dedupe.py+++ b/tests/agent/test_memory_context_dedupe.py@@ -35,77 +35,3 @@ def test_a_bullet_with_continuation_lines_is_never_touched():"- prefers draft PRs\n (logged 3 Feb, source: builtin)\n")assert _body(build_memory_context_block(raw)) == raw---def test_a_bold_heading_is_not_a_bullet():- """``**Preferences**`` starts with ``*``; without the whitespace test it entered the rule and a- repeated section heading was silently deleted."""- raw = "**Preferences**\n- a\n\n**Preferences**\n- b\n"-- assert _body(build_memory_context_block(raw)) == raw---def test_emphasis_and_numbered_items_are_left_as_written():- for raw in ("*Important:*\n- x\n*Important:*\n- y\n",- "1. ships on Fridays\n2. reviews in the morning\n1. ships on Fridays\n"):- assert _body(build_memory_context_block(raw)) == raw---def test_bullets_repeated_across_merged_provider_sections_collapse():- raw = ("## Store A\n- the operator prefers draft PRs\n- ships on Fridays\n\n"- "## Store B\n- the operator prefers draft PRs\n- reviews in the morning\n")-- body = _body(build_memory_context_block(raw))-- assert body.count("- the operator prefers draft PRs") == 1- # Both headings survive: only the duplicate bullet went.- assert "## Store A" in body and "## Store B" in body- assert "- ships on Fridays" in body and "- reviews in the morning" in body---def test_indented_duplicates_at_the_same_depth_still_collapse():- raw = " - fact\n - other\n - fact\n"-- body = _body(build_memory_context_block(raw))-- assert body.splitlines() == [" - fact", " - other"]---def test_a_nested_bullet_is_a_child_and_is_left_alone():- """``- fact`` followed by a deeper ``- fact`` is a parent and its child, not a repeat."""- raw = "- fact\n - fact\n"-- assert _body(build_memory_context_block(raw)) == raw---def test_structure_and_prose_are_left_exactly_as_written():- raw = ("# Recall\n\n---\n\n- a\n\n---\n\nThe same sentence.\nThe same sentence.\n\n---\n"- "-\n-\n")-- body = _body(build_memory_context_block(raw))-- assert body.count("---") == 3, "separator rules are structure, never duplicates"- assert body.count("The same sentence.") == 2, "prose lines are not list items"- assert body.count("\n-\n") >= 1, "a bare dash carries no content to duplicate"---def test_a_block_without_repeats_is_passed_through_byte_for_byte():- raw = "## Memory\n- one\n- two\n- three\n"-- assert _body(build_memory_context_block(raw)) == raw---def test_the_pre_wrapped_warning_still_tracks_sanitization_not_dedupe(caplog):- """A deduped bullet is routine; only a provider returning wrapped context is a fault."""- with caplog.at_level("WARNING"):- build_memory_context_block("- dup\n- dup\n")- assert not [r for r in caplog.records if "pre-wrapped" in r.message]-- with caplog.at_level("WARNING"):- build_memory_context_block("<memory-context>\n- x\n</memory-context>")- assert [r for r in caplog.records if "pre-wrapped" in r.message]---def test_an_empty_or_blank_prefetch_still_yields_no_block():- assert build_memory_context_block("") == ""- assert build_memory_context_block(" \n\t\n") == ""diff --git a/tests/gateway/test_delivery_ledger_single_connection.py b/tests/gateway/test_delivery_ledger_single_connection.pynew file mode 100644index 00000000000..450132dd905--- /dev/null+++ b/tests/gateway/test_delivery_ledger_single_connection.py@@ -0,0 +1,31 @@+"""Recording a reply opens exactly one SQLite connection.++``record_obligation`` runs on every outbound final response. Its retention prune must run on the+recording connection, inside the recording transaction — the way the cron ledgers prune — not on a+second connection opened after the first one closed.+"""+from __future__ import annotations++import sqlite3++from gateway import delivery_ledger as dl+++def test_recording_a_reply_does_not_open_a_second_connection(tmp_path, monkeypatch):+ monkeypatch.setattr(dl, "_db_path", lambda: tmp_path / "state.db")+ real_connect = sqlite3.connect+ opened: list[str] = []++ def counting_connect(*args, **kwargs):+ opened.append(str(args[0]) if args else str(kwargs.get("database")))+ return real_connect(*args, **kwargs)++ monkeypatch.setattr(sqlite3, "connect", counting_connect)+ dl.record_obligation(obligation_id="ob-warm", session_key="s", platform="p", chat_id="c",+ thread_id=None, content="warm-up (schema)")+ opened.clear()++ dl.record_obligation(obligation_id="ob-1", session_key="s", platform="p", chat_id="c",+ thread_id=None, content="hello")++ assert len(opened) == 1, openeddiff --git a/tests/tools/test_capability_fingerprint_skill_scope.py b/tests/tools/test_capability_fingerprint_skill_scope.pyindex 29db3629af4..79cbd807b49 100644--- a/tests/tools/test_capability_fingerprint_skill_scope.py+++ b/tests/tools/test_capability_fingerprint_skill_scope.py@@ -14,7 +14,6 @@ from __future__ import annotationsimport pytest-from agent.skill_utils import EXCLUDED_SKILL_DIRSfrom tools import bot_mode_probe@@ -67,54 +66,3 @@ def test_archiving_a_skill_does_not_move_the_epoch(home):assert bot_mode_probe.capability_fingerprint(home) == after_archive_install(home, ".archive/another-old-skill", "another")assert bot_mode_probe.capability_fingerprint(home) == after_archive--[email protected]("excluded", sorted(EXCLUDED_SKILL_DIRS))-def test_no_excluded_directory_can_move_the_epoch(home, excluded):- _install(home, "web/keep", "keep")- before = bot_mode_probe.capability_fingerprint(home)-- _install(home, f"{excluded}/pkg", "hidden")-- assert bot_mode_probe.capability_fingerprint(home) == before, excluded---def test_a_curator_backup_does_not_rebuild_every_bot_chat_prompt(home):- """The curator writes into `.curator_backups/` on its own schedule — routine churn that must- not invalidate a months-long Bot Chat's prompt cache."""- _install(home, "web/keep", "keep")- before = bot_mode_probe.capability_fingerprint(home)-- _install(home, ".curator_backups/2026-09-21T00-00-00Z/web/keep", "keep")-- assert bot_mode_probe.capability_fingerprint(home) == before---def test_a_skill_support_dir_is_not_a_second_skill(home):- """`references/` inside a skill package is progressive-disclosure material, not an install."""- _install(home, "web/keep", "keep")- before = bot_mode_probe.capability_fingerprint(home)-- _install(home, "web/keep/references/deep-dive", "deep-dive")-- assert bot_mode_probe.capability_fingerprint(home) == before---def test_the_epoch_tracks_exactly_what_the_skills_walker_reports(home):- """The fingerprint and every other reader of the tree must agree on what is installed."""- from agent.skill_utils import iter_skill_index_files-- for rel in ("web/keep", "ops/deploy", ".archive/old", ".curator_backups/x/web/keep"):- _install(home, rel, rel.rsplit("/", 1)[-1])-- walker = sorted(str(p.parent.relative_to(home / "skills"))- for p in iter_skill_index_files(home / "skills", "SKILL.md"))-- assert walker == ["ops/deploy", "web/keep"]- # Same surface: removing a skill the walker reports moves the epoch, removing one it does not- # report leaves it alone.- before = bot_mode_probe.capability_fingerprint(home)- (home / "skills" / ".archive" / "old" / "SKILL.md").unlink()- assert bot_mode_probe.capability_fingerprint(home) == before- (home / "skills" / "ops" / "deploy" / "SKILL.md").unlink()- assert bot_mode_probe.capability_fingerprint(home) != before