feat: add created_by_subject in db in place of created_by - #568
Conversation
🦋 Changeset detectedLatest commit: 734a1af The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 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 |
2d106c3 to
e6df9b3
Compare
17b89b5 to
d65eb70
Compare
c34c21d to
e593de8
Compare
…ables, replacing created_by field with JSONB structure for improved data integrity and indexing
d65eb70 to
cd75e71
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ 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); |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit cd75e71. Configure here.
… and enhancing JSONB handling for created_by_subject
| /** Re-parse persisted creator JSON so store readers validate on read. */ | ||
| export function parseStoredCreatedBySubject(value: unknown): CreatedBySubject { | ||
| return CreatedBySubjectSchema.parse(value); | ||
| } |


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
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
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 requiredcreated_by_subjectobject (subject_id,subject_type,subject_display_name) on Agent, Session, Schedule, and ScheduleRun API responses and persistence.New creates stamp
createdBySubjectFromRequestContextfrom the authenticated subject. Ownership checks and server-side list scoping (sessions, schedules, metrics) now comparecreated_by_subject.subject_id(with existing admin bypass on schedules).ScheduleRundropstriggered_byin favor ofcreated_by_subjectfor who triggered the run.Postgres migrations add
created_by_subjectJSONB (session rows backfilled fromcreated_bythen column dropped; agents get a default for legacy rows), plus tenant +subject_idindexes. 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.