upsert-case-&-dynamic-choices - #21
Conversation
…psert" capability to Case nodes route incominganswers that a casestep_index to patch an existing stepinstead of always appending a new one. - Add up field to CaseUpdate dataclass include it in serialization so can perform update_create on steps. - Implement Case.patch_step(index, updateCaseNode) that marks the update as upsert, sends it to the account, updates the in-memory updates list, and persists the. - Route update requests with answer.casestep_index in routes.py to call case.patch_step(...) and emit an_RECEIVED lifecycle event via PersistentEntityLifecycle. Fall back to receiveuman_input(...) casestep_index is. - Add a unit test ensuring requests with casestep_index the specified stepupsert) of creating a new one. -ump version from0.13.2.dev0 to0.13.2 and commit the version. This enables enriching or completing a previously sent step(e.g. adding interview end time to start step) without creatingduplicate steps in.
Review Summary by QodoAdd case step upsert/patch behavior and human_answer hook support
WalkthroughsDescription• Add upsert/patch capability to Case steps via CaseNodeUpdate.upsert field and Case.patch_step() method • Route incoming answers with casestep_index to patch existing steps instead of always appending new ones • Implement human_answer hook invocation in case update endpoint with graceful fallback for stateless replicas • Update case endpoint to handle missing Cases registry without returning 404 errors Diagramflowchart LR
A["POST /update with answer"] --> B{"casestep_index present?"}
B -->|Yes| C["Case.patch_step()"]
B -->|No| D["Case.receive_human_input()"]
C --> E["Set upsert=True"]
D --> E
E --> F["send_update_case()"]
F --> G["Call human_answer hook"]
H["Case not in registry"] --> G
G --> I["Return 200 success"]
File Changes1. src/supervaizer/case.py
|
Code Review by Qodo
1.
|
…ensive imports fixtures to tests/test_routes_case_update.py:
-ce pytest fixtures: _jobs_registryolation to reset Jobs()
registry tests, and_on_server to register a Job under the server's agent so POST /jobs/{id}/cases/{id}/update resolves.
- Import additional domain types (Agent, AgentMethod, AgentMethods,
JobResponse,, ParametersSetup and Jobs helper to support and assertions.
- Add cryptography and typing imports by fixtures.
Update to use job_server fixture:
- Replace direct use of job_fixture with job_server in tests that need an in-memory job registration so the route can locate the job.
- Adjust expected job_id assertions to match job_on_server.id.
- Clarify and tighten test expectations for error cases:
- Change test_update_case_job_not_found docstring and assertions to expect a404 job is and assert the error detail includes the id.
- Update test_update_case_not_found docstring to reflect404 behavior for unknown case_id under a known.
- Minor formatting and comment fixes:
- Fix capitalization in header.
- Organize into a grouped style for readability.
Why:
- Ensure tests run deterministically by isolating the global Jobs()
registry and by registering authoritative job under the server's agent name. This allows the update route to both success and failure paths correctly and makes assertions reflect the actual behavior (404 for missing resources).
upfield toCaseUpdatedataclass and it in serialization to allow update-or-create on steps -Case.patch_step(index updateNode to mark updates as upsert, send to account, update in-memory list, and persist - Route requests withanswer.casestep_indextocase.patch(...)and emit a RECEIVED lifecycle event viaPersistentEntity; back to regular receive when is missing - unit test ensuring withcasestep_indexupdate the specified step (and create when appropriate)human_answerhook in HITL callback and handle missingCases()` registry