test: repair full suite — hang fix, stale-test updates, patch hygiene, timeout backstop
Suite went from 27 failures plus one permanent hang (never finished) to 1846 passed / 0 failed in ~85s, including under FORCE_COLOR. - office_shutdown_lifecycle: construct WSHandler via the real __init__ (helper) instead of hand-copied __new__ stubs that drift from the constructor (#11 added _runtime_status_sync_task and the stubs hung); the formerly-hanging wait now has a 5s wait_for. - import-time patch hygiene: company_recruiter / company_reorg / engine_session_defaults replaced module-level permanent tempfile.TemporaryDirectory monkeypatching with paired setUpModule/tearDownModule, fixing order-dependent sqlite failures in transcript_pagination during full runs. - stale tests updated to current product semantics: resume stubs use status="done" (failed is deliberately non-resumable), fix4 asserts the native review contract through build_company_work_item_contract, delivery fixture carries user_visible/feedback_scope=final, ownership doc names progress_log, session compression calls maybe_compact_session(force=True) explicitly, hard delete removes the work item row, parallel-isolation asserts delegate rebind and stubs _get_project_delegate, role update goes through OrgService on an editable custom org (plus read-only rejection case), collab_rpc patches the single os.name decision point instead of poisoning pathlib, codex no-pty builds inside the patch, identity-guard false positives reworded. - cli_board actions rewritten against the real OfficeServiceFactory seam with a tempdir OPC_HOME (old direct-engine stubs were never consulted and the tests wrote into the real OPC home). - cli_app assertions strip ANSI via _plain_output so a color-forcing shell (FORCE_COLOR) cannot break plain-text expectations. - deleted never-runnable test_org_concurrency (pytest.mark.asyncio without the plugin, stdlib-only assertions) and three dead skipped filesystem-handoff tests. - pyproject: dev extra (pytest, pytest-timeout) and a 300s per-test timeout backstop so a wedged test fails instead of stalling the suite. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -202,14 +202,13 @@ class SessionContextCompressionTests(unittest.IsolatedAsyncioTestCase):
|
||||
store = OPCStore(db_path)
|
||||
await store.initialize()
|
||||
memory = MemoryManager(root, "proj1", store=store)
|
||||
memory.set_history_compactor(
|
||||
HistoryCompactor(
|
||||
llm=_StubLLM(),
|
||||
store=store,
|
||||
memory_manager=memory,
|
||||
compression_threshold=0.85,
|
||||
)
|
||||
compactor = HistoryCompactor(
|
||||
llm=_StubLLM(),
|
||||
store=store,
|
||||
memory_manager=memory,
|
||||
compression_threshold=0.85,
|
||||
)
|
||||
memory.set_history_compactor(compactor)
|
||||
session_id = "session-restart"
|
||||
|
||||
for idx in range(6):
|
||||
@@ -217,6 +216,20 @@ class SessionContextCompressionTests(unittest.IsolatedAsyncioTestCase):
|
||||
payload = f"message {idx} " + ("alpha beta gamma delta " * 40)
|
||||
await memory.append_session_message(session_id=session_id, role=role, text=payload)
|
||||
|
||||
# Append no longer auto-compacts; compaction is an explicit call.
|
||||
# Forced compaction consumes everything up to the latest message,
|
||||
# so the raw tail comes from messages appended afterwards.
|
||||
compacted = await compactor.maybe_compact_session(
|
||||
project_id="proj1",
|
||||
session_id=session_id,
|
||||
force=True,
|
||||
)
|
||||
self.assertTrue(compacted)
|
||||
for idx in range(6, 8):
|
||||
role = "user" if idx % 2 == 0 else "assistant"
|
||||
payload = f"message {idx} " + ("alpha beta gamma delta " * 40)
|
||||
await memory.append_session_message(session_id=session_id, role=role, text=payload)
|
||||
|
||||
snapshot = await store.get_latest_session_memory_snapshot(session_id)
|
||||
self.assertIsNotNone(snapshot)
|
||||
assert snapshot is not None
|
||||
@@ -225,7 +238,7 @@ class SessionContextCompressionTests(unittest.IsolatedAsyncioTestCase):
|
||||
context = await memory.build_session_prompt_context(session_id)
|
||||
self.assertIn("## Session Memory", context)
|
||||
self.assertIn("Session history summary before restart", context)
|
||||
self.assertIn("message 5", context)
|
||||
self.assertIn("message 7", context)
|
||||
|
||||
await store.close()
|
||||
|
||||
@@ -236,7 +249,7 @@ class SessionContextCompressionTests(unittest.IsolatedAsyncioTestCase):
|
||||
restarted_context = await restarted_memory.build_session_prompt_context(session_id)
|
||||
|
||||
self.assertTrue(any("Session history summary before restart" in item["content"] for item in restarted_history))
|
||||
self.assertTrue(any("message 5" in item["content"] for item in restarted_history))
|
||||
self.assertTrue(any("message 7" in item["content"] for item in restarted_history))
|
||||
self.assertFalse(any("message 0" in item["content"] for item in restarted_history))
|
||||
self.assertNotIn("message 0", restarted_context)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user