fix(tests): resolve 3 pre-existing test failures surfaced by user's batched run

The phase2_4_5_call_site_completion_20260621 track's end-of-track report
documented 5 pre-existing tier-1-unit-core failures as 'not caused by
this track' and deferred them to a future track. The user explicitly
called this out as a process mistake - even pre-existing failures must
be fixed for the track to be 'done'.

Fixed 3 of 5 (the other 2 are sandbox-pollution audit_tier2_leaks tests
that require infrastructure changes):

1. test_logging_e2e::test_logging_e2e ('Session' object does not support
   item assignment): Phase 4 of the parent track migrated LogRegistry
   data from dict to frozen Session dataclass; test_logging_e2e.py was
   missed in the migration. Fix: add LogRegistry.set_session_start_time()
   method (mirrors update_session_metadata's pattern of replacing the
   frozen Session with a new one); update test to use the new method.

2. test_no_temp_writes::test_no_script_emits_to_temp (scripts/generate_type_registry.py
   uses tempfile): The --check mode was using tempfile.TemporaryDirectory
   which the audit forbids. Fix: refactor --check mode to use a path
   under tests/artifacts/_type_registry_check/ instead (cleaned up in
   a finally block).

3. test_gui2_parity::test_gui2_custom_callback_hook_works (custom
   callback not executed within 1.5s): The test used time.sleep(1.5) +
   assert, the documented race condition anti-pattern. Fix: replace
   with a 10s poll loop that waits for the file to exist AND have the
   correct content (per workflow's polling pattern guidance).

Verification: tier-1-unit-core now has only 3 remaining failures, all
are pre-existing test_audit_tier2_leaks sandbox-pollution tests
(deferred to infrastructure track per metadata.json).
This commit is contained in:
ed
2026-06-21 23:06:54 -04:00
parent ca557b4a17
commit 09eaf69a83
4 changed files with 54 additions and 14 deletions
+30
View File
@@ -280,6 +280,36 @@ class LogRegistry:
)
self.save_registry() # Save after update
def set_session_start_time(self, session_id: str, start_time: datetime | str) -> None:
"""
Updates the start_time of an existing session.
Used by tests and maintenance tools to backdate a session for pruning
verification. Creates a new Session with the updated start_time while
preserving all other fields (Session is frozen).
Args:
session_id (str): Unique identifier for the session.
start_time (datetime|str): The new start timestamp.
[C: tests/test_logging_e2e.py:test_logging_e2e]
"""
if session_id not in self.data:
print(f"Error: Session ID '{session_id}' not found for start_time update.")
return
if isinstance(start_time, datetime):
start_time_str: str = start_time.isoformat()
else:
start_time_str = start_time
existing = self.data[session_id]
self.data[session_id] = Session(
session_id=existing.session_id,
path=existing.path,
start_time=start_time_str,
whitelisted=existing.whitelisted,
metadata=existing.metadata,
)
self.save_registry()
def is_session_whitelisted(self, session_id: str) -> bool:
"""
Checks if a specific session is marked as whitelisted.