agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

test(sessions): cover cleanup reload failure and HTTP 500 envelope

Open illegalcall opened this issue 4 months ago • 3 comments

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 GetSessionCleanupFacts call.
  • Update the reload-failure test so:
    • the pre-write read succeeds;
    • the upsert succeeds;
    • the post-write reload fails;
    • CleanupSession returns 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

illegalcall avatar Jul 25 '26 18:07 illegalcall

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.

somewherelostt avatar Jul 26 '26 15:07 somewherelostt

@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.

Rishet11 avatar Aug 30 '26 15:08 Rishet11

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.

codebanditssss avatar Sep 23 '26 14:09 codebanditssss