Skip to content

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

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

rutvij-menavlikar wants to merge 13 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 the first version
  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
  storage_prefix         text NOT NULL        -- folder key of the version's files in the object store
                                              -- (S3 or local FS); file key = prefix + relative path
  total_bytes            bigint NOT NULL
  created_at             timestamptz NOT NULL -- immutable row; no updated_at
  PK (artifact_id, version)

Changes

  • artifact: ULID id, UNIQUE (tenant_id, slug), title, latest_version (0 until the first version), 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: immutable rows with PK (artifact_id, version), storage_prefix, total_bytes, created_at. Cascades from artifact. Written once after files are uploaded, so there is no status or per-file table; file listings come from the object store.

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 no runtime or security logic changes; standard lock_timeout and rollback down paths.

Overview
Introduces artifact metadata storage in Postgres and SQLite via paired Kysely migrations, plus a patch changeset for @truefoundry/trueforge. File content stays in object storage; these tables only track identity, versioning, and pointers.

The artifact table holds per-tenant slugs, titles, latest_version, creator subject/session (session id is not an FK so rows persist after the session), and indexes for listing by creator and filtering by session. artifact_version stores immutable version rows with storage_prefix and total_bytes, keyed by (artifact_id, version) with cascade delete from artifact.

Reviewed by Cursor Bugbot for commit 3307efc. 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: 3307efc | 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>
rutvij-menavlikar and others added 5 commits November 20, 2026 15:08
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

2 participants