Skip to content

[AGE-2882] Add artifact metadata tables - #1435

Open
rutvij-menavlikar wants to merge 8 commits into
mainfrom
rutvij/age-2882_1
Open

rutvij-menavlikar wants to merge 8 commits into
mainfrom
rutvij/age-2882_1

Conversation

@rutvij-menavlikar

@rutvij-menavlikar rutvij-menavlikar commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds Postgres + SQLite migrations for the artifact metadata tables from the Artifacts design. File bytes live in S3; these tables hold metadata only. Store, upload, list, and serving paths come in later PRs.

Linear: AGE-2882

Schema

Postgres types; SQLite stores jsonb as BLOB, timestamps as ISO text, bigint as INTEGER.

artifact
  id                     text PK (ULID)
  tenant_id              text NOT NULL
  slug                   text NOT NULL
  title                  text NOT NULL
  latest_version         integer NOT NULL     -- 0 until first commit
  created_by_subject     jsonb NOT NULL
  created_by_session_id  text NOT NULL        -- no FK; outlives the session
  created_at, updated_at timestamptz NOT NULL
  UNIQUE (tenant_id, slug)
  INDEX (tenant_id, created_by_subject->>'subject_id', updated_at DESC, id)  -- creator's list
  INDEX (tenant_id, created_by_session_id)    -- "this session" filter

artifact_version
  artifact_id            text NOT NULL  FK -> artifact ON DELETE CASCADE
  version                integer NOT NULL     -- 1-based, monotonic
  status                 text NOT NULL        -- pending | committed | failed
  entrypoint             text NOT NULL
  created_by_turn_id     text NOT NULL
  created_at, updated_at timestamptz NOT NULL
  PK (artifact_id, version)
  INDEX (artifact_id, status)

artifact_file
  artifact_id            text NOT NULL
  version                integer NOT NULL
  path                   text NOT NULL        -- relative path within the version
  size_bytes             bigint NOT NULL
  storage_key            text NOT NULL        -- object-store key
  sha256                 text NOT NULL
  created_at             timestamptz NOT NULL
  PK (artifact_id, version, path)
  FK (artifact_id, version) -> artifact_version ON DELETE CASCADE

Changes

  • artifact: ULID id, UNIQUE (tenant_id, slug), title, latest_version (0 until first commit), created_by_subject, created_by_session_id (no FK; outlives the session). Indexes (tenant_id, created_by_subject->>'subject_id', updated_at DESC, id) (SQLite: json_extract(created_by_subject, '$.subject_id')) and (tenant_id, created_by_session_id).
  • artifact_version: PK (artifact_id, version), status (pending/committed/failed), entrypoint, created_by_turn_id. Index (artifact_id, status). Cascades from artifact.
  • artifact_file: PK (artifact_id, version, path), size_bytes, storage_key (object-store key), sha256, created_at. Cascades from artifact_version.

How was this tested?

  • Full migration chain on SQLite (jest.store.sqlite.config.cjs) and on a throwaway database on the devtest RDS, PG 17.11 (jest.store.postgres.config.cjs).
  • tsc --noEmit, eslint, prettier on changed files.

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, python/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

Low Risk
Additive schema-only migrations with down migrations; no application logic or auth changes in this PR.

Overview
Introduces artifact metadata persistence via paired Postgres and SQLite Kysely migrations: artifact (tenant-scoped slug/title, creator subject/session, latest_version), artifact_version (monotonic versions with status, entrypoint, turn linkage), and artifact_file (per-version paths pointing at object-store keys and checksums).

Postgres uses jsonb/timestamptz/bigint, unique (tenant_id, slug), list/session indexes including JSON subject_id, and cascade FKs from artifact → version → file. SQLite mirrors the same shape with STRICT tables, subject as BLOB, ISO text timestamps, and json_extract for the list index. A changeset records a patch bump for @truefoundry/trueforge. Store/API behavior is not in this diff.

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

rutvij-menavlikar and others added 2 commits November 19, 2026 17:09
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@rutvij-menavlikar rutvij-menavlikar changed the title [AGE-2882] Add artifact tables and DB store [AGE-2882] Add artifact metadata tables Nov 19, 2026
rutvij-menavlikar and others added 2 commits November 19, 2026 17:39
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@rutvij-menavlikar rutvij-menavlikar mentioned this pull request Nov 19, 2026
3 of 5 tasks
rutvij-menavlikar and others added 2 commits November 19, 2026 18:56
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@datadog-official

datadog-official Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Code Quality  Code Vulnerabilities  IaC  Library Vulnerabilities  Secrets

🎉 All green!

🛠️ No new code quality issues
🛡️ No new code vulnerabilities
📚 No new vulnerable libraries detected
🧱 No new Infrastructure as Code (IaC) issues
🔑 No new secrets detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 1d9e88c | Docs | Give us feedback!

@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 9e9efaa. Configure here.

Comment thread .changeset/artifact-apis.md Resolved
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

This branch has not been deployed

No deployments
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