fix(cpg): carry the engine's own account when a session request fails (M2)

The session-enabled NodeGoat run reported session_query_failed:census:
session_request_failed and fell back, which is correct behaviour but says nothing
about why. A bare transport failure cannot distinguish a timeout from a crash from
an out-of-memory kill, and the only account of which it was is in the server's own
log.

A transport failure now carries the exception and the tail of that log, and the
backend logs it with the process exit code alongside its own label. A control
asserts an OutOfMemoryError in the log reaches the caller.

This is diagnosis, not a repair: the run's timings were unchanged because the
session died early and everything fell back to the disposable path.

1,397 tests passed, nine skipped.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01EmM1j46qgKMh3zqD1QMwEo
This commit is contained in:
Marius Ciepluch
2026-09-16 21:00:24 +02:00
co-authored by Claude Opus 5
parent fc69055a32
commit d2362cd18d
3 changed files with 32 additions and 2 deletions
+12
View File
@@ -278,3 +278,15 @@ def test_the_session_switch_is_explicit_and_defaults_off(monkeypatch):
assert JoernBackend().session_transport is True
# An explicit argument still wins over the environment in both directions.
assert JoernBackend(session_transport=False).session_transport is False
def test_a_transport_failure_carries_the_server_log(tmp_path, fake):
"""M2: `session_request_failed` alone cannot tell a crash from an OOM kill."""
with session(tmp_path, fake) as live:
assert live.start()
(tmp_path / "scratch" / "session.log").write_text("java.lang.OutOfMemoryError: Java heap space\n")
live._port = 1 # nothing is listening there
assert live.evaluate("cpg.file.size", timeout=2) is None
assert live.failure == "session_request_failed"
assert "OutOfMemoryError" in live.last_body
assert "OutOfMemoryError" in live.log_tail()