Skip to content

Add OpenSessions workflow trace sink#62

Open
andrei-hasna wants to merge 2 commits into
mainfrom
openloops/open-loops/66186d5a-f7f2-45ce-906d-6b6220b0c31a-fc934ef8
Open

Add OpenSessions workflow trace sink#62
andrei-hasna wants to merge 2 commits into
mainfrom
openloops/open-loops/66186d5a-f7f2-45ce-906d-6b6220b0c31a-fc934ef8

Conversation

@andrei-hasna

Copy link
Copy Markdown
Contributor

Summary

  • add an OpenSessions trace sink for workflow runs, with opt-in package-backed @hasna/sessions persistence via OPENLOOPS_OPENSESSIONS_TRACE=1
  • emit redacted workflow/step/process/agent progress/terminal trace entries and expose the trace replay command from workflows inspect
  • document OpenSessions trace usage and keep OpenLoops events/Todos comments as the orchestration/task sources of truth

Validation

  • TMPDIR=/tmp/codewith-bun-tmp TMP=/tmp/codewith-bun-tmp TEMP=/tmp/codewith-bun-tmp BUN_INSTALL_CACHE_DIR=/tmp/codewith-bun-cache bun run typecheck
  • TMPDIR=/tmp/codewith-bun-tmp TMP=/tmp/codewith-bun-tmp TEMP=/tmp/codewith-bun-tmp BUN_INSTALL_CACHE_DIR=/tmp/codewith-bun-cache bun test
  • TMPDIR=/tmp/codewith-bun-tmp TMP=/tmp/codewith-bun-tmp TEMP=/tmp/codewith-bun-tmp BUN_INSTALL_CACHE_DIR=/tmp/codewith-bun-cache bun run test:boundary
  • package-backed smoke with temporary HASNA_SESSIONS_DB_PATH: workflows inspect exposed openSessionsTrace.sessionId and the OpenSessions DB row had ended_at, duration_seconds, 5 messages, and 1 tool call

Adversarial Review

  • reviewer found package-backed sessions were not marked ended; fixed by passing terminal workflow context to the writer and updating duration_seconds on upsert
  • added regression coverage for package-backed terminal trace metadata

Notes

  • tracing is opt-in for the package-backed writer to avoid ordinary local/test runs writing to an operator sessions DB; SDK callers can inject a trace sink directly
  • hidden reasoning, prompts, env values, credential-like fields, shell commands, and raw output are redacted or bounded before trace persistence

… claim

Vendor the @hasna/contracts 0.4.0 storage kit into src/generated/storage-kit
(pool/query/tls/mode/migrations/health) and build the Postgres run-claim
correctness core on top of it:

- PgPoolExecutor adapts the vendored pg.Pool client to PostgresQueryExecutor
  so PostgresStorage.migrate() runs against live cloud Postgres.
- claimNextRun/heartbeatRunLease use SELECT ... FOR UPDATE SKIP LOCKED so
  concurrent loops-runner processes never double-claim a queued run.
- Two-connection concurrency test (skips unless LOOPS_TEST_DATABASE_URL set)
  verifies exactly-once claiming across two pooled connections.
- Promote pg to a direct dependency; add @types/pg dev dependency.
- docs/CUTOVER-RUNBOOK.md documents remaining store wiring + enable steps.

PURE REMOTE (Amendment A1): kit builds a pool only in cloud mode; no
hybrid/sync path. Daemon stays on local sqlite until the full
LoopStorageContract impl + async consumer wiring land (tracked in runbook).
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