Skip to content

Move function calls and results into sessions and sessionpg - #333

Merged
SaladDay merged 1 commit into
mainfrom
refactor/sessions-functions
Sep 30, 2026
Merged

SaladDay merged 1 commit into
mainfrom
refactor/sessions-functions

Conversation

@SaladDay

@SaladDay SaladDay commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Function calls and results move out of store into sessions and sessionpg. This PR also introduces the lease-bound Session execution skeleton.

What changes

  • Execution skeleton:
    • sessions.ExecutionOperations with ExecutionStorage { FunctionExecution }.
    • sessionpg.Execution{lease}.
    • execution.Owner.Sessions.
    • Dispatcher.Bind(owner): StartWorker binds through it, and a Dispatcher that runs Turns outside a Worker binds the same way. The Session execution operations are unexported on the Dispatcher.
  • Function execution:
    • RecordFunctionCall, PendingFunctionCalls and ConfirmFunctionResult run on the lease under the Session lock.
    • Each one loads facts, decides with pure sessions rules, then applies. The Turn status change and its journal entries are settled in the same order as before.
  • Result admission: sessions.AdmitFunctionResult is a procedure over a four-method Tx that sessionpg.BindSession implements. It runs inside the public SubmitInputs transaction.
  • Required actions: LoadRequiredActions is the lock-free snapshot read used by scheduling.
  • Removed from store:
    • function_calls.go, function_inputs.go, function_results.go and function_state.go;
    • the test-only GetFunctionCall/SubmitFunctionResult. Tests now submit results through the public tool_result input.
  • Tests:
    • The store test harness binds one execution lease per harness. Restart tests observe the lease release before they reacquire it.
  • Docs: IMPLEMENTATION.md and sessions/doc.go name the new owners.

Behavior

Unchanged. The api mapping and precedence are the same for ErrFunctionCallTurnMismatch, ErrUnknownFunctionCall and ErrFunctionResultConflict, and so are idempotent replay, the pending order and the conflict rules.

Checks

  • go build ./... and go vet ./services/core/....
  • sessions and sessionpg in full. The PostgreSQL tests cover rollback, a concurrent single winner, scoping, a closed lease and the ownership handoff.
  • execution -run '^(TestStartWorker|TestWorkerRun|TestFunction|TestSandboxReset|TestSandboxDeploymentDrain|TestCommittedResetView|TestFinishRun)'.
  • cmd/server, and the api function and tool_result tests.
  • Store: an exact-name sweep over 182 tests. It covers every test that builds or uses a Dispatcher, dispatch harness, worker or execution owner, and it ran with the pinned official SDK. The 11 skips are native-daemon cases.
  • scripts/check-names.py and make check-docs.

A blind review found one blocker (an unbound Dispatcher in a store test) and three minor issues. All are fixed in this commit.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@SaladDay
SaladDay merged commit a838016 into main Sep 30, 2026
1 check passed
@SaladDay
SaladDay deleted the refactor/sessions-functions branch September 30, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant