Skip to content

end: add run details on session - #593

Open
heerambavi1998 wants to merge 6 commits into
mainfrom
ha/run-metadata
Open

end: add run details on session#593
heerambavi1998 wants to merge 6 commits into
mainfrom
ha/run-metadata

Conversation

@heerambavi1998

@heerambavi1998 heerambavi1998 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

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

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed

Note

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 source field (today: schedule with schedule id and run id). Sessions store it as JSONB with a partial index on (tenant_id, type, id) for listing; interactive sessions keep source: null.

API & SDK: source is required on session responses (nullable). GET /api/v1/sessions gains optional source_type and source_id (source_id requires source_type). Public create/update still cannot set source; 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_subject reads now use CreatedBySubjectSchema.parse directly 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.

@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0a677a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@truefoundry/trueforge Patch
@truefoundry/trueforge-core Patch
@truefoundry/trueforge-sdk Patch
@truefoundry/trueforge-ui Patch

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

Comment thread packages/trueforge-core/src/agent-session/schemas/session.ts Outdated
Comment thread packages/trueforge-core/src/agent-session/schemas/session.ts Outdated
Comment thread packages/trueforge-core/src/agent-session/store/InMemorySessionStore.ts Outdated
Comment thread packages/trueforge-core/src/agent-session/store/InMemorySessionStore.ts Outdated
Comment thread packages/trueforge-core/src/agent-session/store/ISessionStore.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Triggered by project rule: @truefoundry/trueforge review rules

Reviewed by Cursor Bugbot for commit 0a677a3. Configure here.

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.

2 participants