8000 feat(run): add SessionRunStore adapter by Fodesu · Pull Request #85 · felinics/twilight · GitHub
[go: up one dir, main page]

Skip to content

feat(run): add SessionRunStore adapter - #85

Merged
Fodesu merged 2 commits into
feat/agent-runtime-core-11-run-testsfrom
feat/agent-runtime-core-12-session-run-store
Oct 3, 2026
Merged

Fodesu merged 2 commits into
feat/agent-runtime-core-11-run-testsfrom
feat/agent-runtime-core-12-session-run-store

Conversation

@Fodesu
@Fodesu Fodesu commented Oct 3, 2026 •
Copy link
Copy Markdown
Member

Summary

Add the Session-backed implementation of the RunStore protocol.

Run module

Register the twilight/run/ event domain:

  • one own stream per RunID
  • versioned codecs for every Run fact
  • strict runId validation at the event boundary
  • CAS bindings for frozen request, result, output, and response bodies
  • the authoritative twilight/run/machine projection

Run streams use own inheritance, so a forked Session does not inherit Runs from
its parent.

Machine projection

The machine projection keeps:

  • the current MachineState of each active Run
  • the last fact position for each active Run

Terminal Runs are removed from the projection. Their history remains the
authoritative source of record, so the projection is bounded by active Runs
rather than total historical Runs.

The projection is used for fast command evaluation. Record independently
reads and folds the Run stream, and compares the result with the projection
when both reads observe the same ledger head.

SessionRunStore

Implement the RunStore boundary over a Session Writer:

  • Bind attaches a RunStore to one Writer ownership capability.
  • Load reads the Writer's transactional machine projection.
  • Commit evaluates one command and contributes its facts as one Session unit
    of work.
  • CreateRun contributes Run creation and initial input facts to a larger
    creation unit.
  • Record provides an ownership-free, verified read of a Run.
  • FrozenRequest restores a model request from its content-addressed body.

All Run commands in a drive use the same Writer, epoch, projection view, and
ownership fence.

Commit and recovery semantics

Command bodies are frozen before the unit commits. Storage is idempotent and
content-addressed, so rejected or replayed commands cannot leave an
unreferenced body with an incorrect digest.

Commit results distinguish:

  • newly accepted commands
  • already-applied command replays
  • conflicts
  • stale runtime views
  • terminal or unknown Runs

Projection cache writes are best effort and never change commit success. The
event stream remains authoritative; the cache only reduces future replay work.

Cost model

Command evaluation operates on the active Run projection and the command's
facts rather than replaying the full Session. A full Record is linear in the
Run's fact history, while valid projection and frozen-body caches avoid that
work for normal command processing.

@Fodesu
Fodesu added this pull request to stack #105 October 3, 2026 12:27
@Fodesu Fodesu changed the title feat/agent runtime core 12 session run store feat(agentcore): add runstore protocol impl Oct 3, 2026
@Fodesu
Fodesu marked this pull request as ready for review October 3, 2026 13:57
@Fodesu Fodesu changed the title feat(agentcore): add runstore protocol impl feat(run): add SessionRunStore adapter Oct 3, 2026
@Fodesu
Fodesu removed this pull request from stack #105 October 3, 2026 16:13
@Fodesu
Fodesu added this pull request to stack #107 October 3, 2026 16:16
@Fodesu
Fodesu removed this pull request from stack #107 October 3, 2026 16:34
@Fodesu
Fodesu added this pull request to stack #108 October 3, 2026 16:37
@Fodesu
Fodesu removed this pull request from stack #108 October 3, 2026 16:51
@Fodesu
Fodesu added this pull request to stack #110 October 3, 2026 16:55
@Fodesu
Fodesu force-pushed the feat/agent-runtime-core-12-session-run-store branch from 7fb32df to b976908 Compare October 3, 2026 17:04
@Fodesu
Fodesu force-pushed the feat/agent-runtime-core-12-session-run-store branch from b976908 to b7b7cd9 Compare October 3, 2026 17:11
@Fodesu
Fodesu merged commit bee6b69 into main Oct 3, 2026
8 checks passed
@Fodesu
Fodesu deleted the feat/agent-runtime-core-12-session-run-store branch October 5, 2026 07:35
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

0