Skip to content

Move the Turn journal, usage and the Item and Subagent projections into sessions and sessionpg - #334

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

SaladDay merged 1 commit into
mainfrom
refactor/sessions-journal

Conversation

@SaladDay

@SaladDay SaladDay commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

The Turn event journal, token usage and the Item and Subagent projections move out of store into sessions and sessionpg.

What changes

  • sessions:
    • journal.go holds the batch, the limits and the append rules (NewJournalBatch, AppendTurnEvents, AppendTurnEvent).
    • projection.go holds ProjectSource, ProjectInput and the Item projection.
    • The Subagent identity, lifecycle, coordination and Turn projection decisions live in subagents.go.
    • ValidTransition lives in turn.go.
  • Execution: execution appends through the lease-bound JournalExecution family (ExecutionOperations.AppendTurnEvents on sessionpg.Execution.WithTurnJournal).
  • sessionpg: the SessionTx participants load journal, Item, usage and Subagent facts and apply the typed decisions. No decision lives in the adapter.
  • store: the remaining Turn operations (transitions, completion, input admission) call the procedures through sessionpg.BindSession until their own PRs.
  • Test fixtures: the seeder in services/core/tests/fixtures runs the same procedure pooled through sessionpg.WithSession and BindSession. That is its only pooled use.
  • Removed from store:
    • turn_events.go, item_projection.go and the five subagent_* projection and identity files.
    • The Store methods AppendTurnEvents, ListTurnEvents and GetSubagentIdentity. The two reads remain only as test helpers.
  • Docs: IMPLEMENTATION.md, sessions/doc.go and sessionpg/doc.go name the new owners.

Behavior

The public behavior is unchanged: event sequence allocation, ordering, idempotent replay, limits, projection order, pruning and rollback all behave as before. The error for a malformed ID still wins over the limit and missing-Session errors.

Internally:

  • Journal and Subagent writes exist only on the execution lease.
  • A missing native Subagent returns a typed error instead of a raw driver error.
  • Child Turn loads filter by Subagent.

Checks

  • go build ./... and go vet ./services/core/....
  • sessions, items and sessionpg in full. The PostgreSQL tests cover journal atomicity, lease fencing and isolation.
  • execution -run with the journal, Subagent, worker, owner and runtime protocol tests.
  • store -run with the 75 tests in the edited store test files, including the dispatch, archive cancellation and prepared dispatch tests. The official-client tests ran with the pinned SDK.
  • scripts/check-names.py.

A blind review found no blockers or majors. The validation-order finding is 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 d502aaf into main Sep 30, 2026
10 of 11 checks passed
@SaladDay
SaladDay deleted the refactor/sessions-journal branch September 30, 2026 22:02
…to sessions and sessionpg

The Turn execution journal runs through the lease-bound
sessions.ExecutionOperations on sessionpg.NewExecution(lease), which the
Worker receives as execution.Owner.Sessions and Dispatcher.Bind binds.
sessions owns the journal batch rules, AppendTurnEvents and
AppendTurnEvent, ProjectSource and ProjectInput, ValidTransition and the
Subagent projection decisions; sessionpg's SessionTx loads the facts and
applies them. The pooled store journal and its projection files are gone.
@blacksmith-sh

blacksmith-sh Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
github.com/MiniMax-AI/OpenAgentCore/services/core/internal/persistence/postgres/
deploymentpg/TestResetStartEscalateAndComplete
View Logs

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

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