Skip to content

feat: add created_by_subject in db in place of created_by - #568

Open
thesujai wants to merge 5 commits into
mainfrom
feat/created-by-field
Open

feat: add created_by_subject in db in place of created_by#568
thesujai wants to merge 5 commits into
mainfrom
feat/created-by-field

Conversation

@thesujai

@thesujai thesujai commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

feat: add created_by_subject in db in place of created_by

Closes AGE-2067

Changes

[-](feat: add created_by_subject in db in place of created_by)

How was this tested?

With APIs, no UI testing was performed

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

High Risk
Major breaking API and SDK contract plus DB migrations that alter authorization and list filtering on sessions, schedules, and agents; incorrect migration or subject matching could leak or deny access.

Overview
Breaking change: creator identity moves from plain strings (created_by, triggered_by) to a required created_by_subject object (subject_id, subject_type, subject_display_name) on Agent, Session, Schedule, and ScheduleRun API responses and persistence.

New creates stamp createdBySubjectFromRequestContext from the authenticated subject. Ownership checks and server-side list scoping (sessions, schedules, metrics) now compare created_by_subject.subject_id (with existing admin bypass on schedules). ScheduleRun drops triggered_by in favor of created_by_subject for who triggered the run.

Postgres migrations add created_by_subject JSONB (session rows backfilled from created_by then column dropped; agents get a default for legacy rows), plus tenant + subject_id indexes. Core, trueforge APIs/stores, OpenAPI, and SDK types/tests are aligned with the new shape.

Reviewed by Cursor Bugbot for commit 734a1af. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 734a1af

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

This PR includes changesets to release 2 packages
Name Type
@truefoundry/trueforge-core Major
@truefoundry/trueforge Major

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

@thesujai
thesujai force-pushed the feat/request-context branch from 2d106c3 to e6df9b3 Compare September 3, 2026 05:51
Comment thread packages/trueforge/src/auth/identity.ts
Comment thread packages/trueforge/src/db/scheduleStore.ts
Comment thread packages/trueforge/src/auth/identity.ts Outdated
@thesujai
thesujai force-pushed the feat/created-by-field branch from 17b89b5 to d65eb70 Compare September 3, 2026 06:02
@thesujai
thesujai force-pushed the feat/request-context branch from c34c21d to e593de8 Compare September 3, 2026 09:52
Base automatically changed from feat/request-context to main September 3, 2026 09:58
@thesujai
thesujai force-pushed the feat/created-by-field branch from d65eb70 to cd75e71 Compare September 3, 2026 10:28

@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 2 potential issues.

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 cd75e71. Configure here.

created_at,
updated_at
FROM agent
`.execute(trx);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SQLite agent migration readds metadata

High Severity

The new SQLite agent rebuild copies and recreates metadata after 20260903_000001_drop_agent_metadata already dropped that column. The INSERT … SELECT metadata FROM agent will fail, so standalone upgrades cannot finish. It also brings agent.metadata back after it was removed.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cd75e71. Configure here.

Comment thread packages/trueforge-core/src/agent-session/schemas/subject.ts Outdated
Comment on lines +16 to +19
/** Re-parse persisted creator JSON so store readers validate on read. */
export function parseStoredCreatedBySubject(value: unknown): CreatedBySubject {
return CreatedBySubjectSchema.parse(value);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Move to server

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