end: add run details on session - #593
Conversation
🦋 Changeset detectedLatest commit: 0a677a3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
40756af to
69ce62b
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0a677a3. Configure here.
| /** How a session was created (schedule runs today). */ | ||
| export const SessionSourceSchema = z.discriminatedUnion('type', [SessionSourceScheduleSchema]).openapi('SessionSource'); | ||
|
|
||
| export type SessionSource = z.infer<typeof SessionSourceSchema>; |
There was a problem hiding this comment.
Single-variant SessionSource union
Low Severity
SessionSourceSchema is a one-member discriminatedUnion. Single-variant unions must be a plain object alias, not a one-member oneOf. This also makes the named SessionSource OpenAPI component a nullable oneOf, so internal get-or-create advertises source: null while the Zod field only allows omit or a schedule object.
Triggered by project rule: @truefoundry/trueforge review rules
Reviewed by Cursor Bugbot for commit 0a677a3. Configure here.


Summary
Add session source (schedule today) as nullable JSONB with expression index on (tenant_id, type, id) where source IS NOT NULL
Expose source on session responses; list via optional source_type / source_id (source_id requires source_type)
Public create/update do not accept source; schedule dispatch (in-process + controller) sets it on get-or-create
Regenerate Fern SDK from OpenAPI
How was this tested?
unit, store contract tests
Checklist
pnpm build,pnpm test,pnpm typecheck,pnpm lint:ci, andpnpm format:checkpass locallypackages/trueforge-sdk,.github/fern/openapi/openapi.json,docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge.env.exampleupdated if configuration or behavior changedNote
Medium Risk
Touches session persistence (migration + new list filters) and internal get-or-create behavior used by schedule dispatch; public write paths unchanged but list/query semantics expand.
Overview
Adds session provenance via a nullable
sourcefield (today:schedulewith schedule id and run id). Sessions store it as JSONB with a partial index on(tenant_id, type, id)for listing; interactive sessions keepsource: null.API & SDK:
sourceis required on session responses (nullable).GET /api/v1/sessionsgains optionalsource_typeandsource_id(source_idrequiressource_type). Public create/update still cannot setsource; internal get-or-create-by-external-id accepts it and schedule dispatch (API client and in-process controller) passes schedule provenance when creating run sessions.Core session store, Postgres/SQLite migrations, OpenAPI/Fern SDK, and store contract tests are updated accordingly.
created_by_subjectreads now useCreatedBySubjectSchema.parsedirectly instead of a small DB helper.Reviewed by Cursor Bugbot for commit 0a677a3. Bugbot is set up for automated code reviews on this repo. Configure here.