Repository navigation
Create Sessions through one use case - #555
Merged
Merged
Conversation
createSession ran the whole creation flow inside the HTTP handler and re-checked replay on six branches. createSessionFrom now owns the flow without HTTP types: one replay lookup at entry, one more at the single resolution failure point, then admission or plain creation. The handler decodes, calls it, maps errors in one switch and writes the response. A configurationError marks rejections of the resolved configuration so the switch keeps the stage-dependent mapping. validateSessionModelConfiguration repeated the provider check resolveSessionExecution already runs on the same harness_config, so it is deleted. /v1 responses, error bodies, check order, stream events and audit rows are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
POST /v1/agents/sessionsno longer runs the creation flow inside the HTTP handler, and replay recovery happens in one place instead of six.api/session_creation.goholdscreateSessionFromandresolveSessionCreation, Handler methods with no HTTP types. They record the intent, look up a replay, resolve the template, saved Agent, model configuration, credentials and execution selection, validate, project, and choose admission or plain creation.createSessiondecodes, calls the use case, and has one switch: error, stream, replay (reread plus audit), or created.writeSessionCreationErroris the single mapping. TheconfigurationErrormarker keeps resolution-stage rejections as 400unsupported_or_invalid_configuration. Template, Agent and Vault errors map by their domain; reader failures stay 500.recoverSessionCreationand its six call sites are deleted.validateSessionModelConfiguration. It repeatedprovider.ValidateConfigurationon the inputsresolveSessionExecutionalready validates.harnessconfig/builtin./v1behaviour is unchanged. On base and head, a temporary differential test compared status, full error body, lookup count, creation path and audit rows for every stage's errors, and they were identical. A blind review repeated the comparison independently (60 requests through the router). One new lean test covers the second replay lookup; it fails when that lookup is removed.Hand-written non-test code is net −6 lines.
Checks:
go build,go vet ./services/core/...,go testfor api, execution and sessions, the full integration package on a lane database (381 pass, 32 skipped for missing SDK or tools),check-names, andmake check-openapiwith no drift.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.