test(sessions): cover cleanup reload failure and HTTP 500 envelope
Context
During the follow-up review of #3051, the production fixes were verified:
- cleanup facts are scoped to the current terminal generation;
- persistence and reload failures propagate instead of returning a false success;
- the cleanup disposition is a closed API enum.
The remaining concerns are test-proof gaps only and should not block #3051 or #3052.
Gaps
1. The reload-failure test exits before the post-persist reload
TestCleanupSession_ReloadFailurePropagatesError in
backend/internal/session_manager/finalize_test.go sets getCleanupErr on the
fake store.
However, releaseAndPersistLocked first calls persistCleanupFacts, and
persistCleanupFacts performs its own GetSessionCleanupFacts read before the
upsert. The fake therefore fails that first read and never reaches:
- the successful cleanup-facts upsert; or
- the post-persist reload in
releaseAndPersistLocked.
The test passes, but it does not protect the branch named by the test.
2. The cleanup controller does not explicitly test the 500 API envelope
TestCleanupSessionEndpoint currently covers:
- 200 with cleanup facts;
- 409 for a live session;
- 501 when the session service is unavailable.
It does not cover an unrecognized manager/storage error flowing through the service and controller as the standard 500 API error envelope.
Acceptance criteria
- Make the session-manager fake store able to fail a selected
GetSessionCleanupFactscall. - Update the reload-failure test so:
- the pre-write read succeeds;
- the upsert succeeds;
- the post-write reload fails;
CleanupSessionreturns the wrapped reload error.
- Add a controller/HTTP test proving a generic cleanup failure returns the standard 500 API error envelope, including its error code/request-id behavior as established by nearby controller tests.
- Keep this tests-only unless the stronger coverage exposes a production defect.
Related
- #3051
- #3052
- #2811
Thanks for contributing to Agent Orchestrator.
This issue is being picked up by the current external contributor on-call pair:
- @illegalcall
- @pulkit7070
If someone is already working on this, please continue as usual. The on-call pair is added for visibility, tracking, and support, not to take over the work. If you need help with review, direction, reproduction, or next steps, please tag @illegalcall and @pulkit7070 here.
For faster context or live questions, you can also join the AO Discord.
Join the session here: https://discord.gg/H6ZDcUXmq
Come by if you want to see what is being built, ask questions, or just hang around with the community.
@AgentWrapper, these test gaps are valid, but the cleanup API has not landed on main yet. Please carry the reload-failure and HTTP 500 tests with the cleanup PRs when they are rebased. Keep this open as P3.
Closing as obsolete. These test-only gaps were scoped to #3051, which closed without merge, and the current cleanup-facts lifecycle remains tracked as a production problem in #3402 rather than by tests for an implementation that is not present.