Repository navigation
Data
voxix edited this page Nov 16, 2026
·
7 revisions
| Kind | Examples | Where |
|---|---|---|
| Records | Users, jobs, rounds, model calls and cost, feedback, grades | Postgres |
| Files | Uploaded task files (photos, PDFs, documents), drafts, final answers, Substrate snapshots | Object storage |
| What agents know about a student | "writes informally", "teacher wants 5 paragraphs" | Markdown memory docs, as Postgres rows |
Only the API touches the database and storage. Migrations use Alembic.
| Table | Holds |
|---|---|
users |
id (the Firebase UID, upserted when a user creates a job), is_anonymous (follows the token), created_at
|
jobs |
One homework request: input, subject, level, language, status, review_deadline
|
job_rounds |
One agent run per round; round 2+ come from feedback. failed_at marks a round with no answer (the row stays); lease_id, lease_until and claims say which API process runs it |
artifacts |
What agents wrote (notes, drafts, reviews, final), per round, with an optional title. Agents pass ids, not content |
files |
One uploaded file: the student's file name, storage_key in object storage, MIME type, size, extracted_text (empty until the agent reads the file and saves its text with save_file_text). A job lists the keys of its files, in order, in jobs.photo_keys (named when only photos were taken; the code calls it file_keys, and the column keeps its name so a rolling deploy never runs old code against a renamed column). A student may upload at most 20 files a day that no task uses; the next upload gets 429 |
memory_docs |
profile or one doc per subject, content_md, version (update_memory refuses a stale base version with 412, unlike a lost round, which is 409), full-text tsv
|
Planned: llm_calls (model, tier, tokens,
cost, latency), feedback, grades (raw plus normalized), events (append-only log),
and chunks for vector search.
Conventions:
- Enums are stored as text with a CHECK constraint, generated from
packages/shared. -
updated_atusesclock_timestamp(), notnow(), so polling doesn't miss rows from long transactions. -
llm_callsplusfeedbackform an eval dataset: an accepted result labels the model choice.
-
app-data:runs/{id}/artifacts. -
<project>-uploads: task files, atusers/{id}/uploads/{file_id}. The API's service account may only create and read objects there; an object is never overwritten. - Task files: any type (photos, PDF, Word, ...), at most 20 MiB each and 5 per job, sent as the raw
body of
POST /files?name=.... The web app first shrinks a JPEG, PNG or WebP photo to a JPEG (long edge 1600 px). An image type's bytes must match the type, because only images are served inline; every other file is served as a download (Content-Disposition: attachment,nosniff, CSPsandbox), so an uploaded HTML or SVG never runs on the app's origin. The object is written first, then thefilesrow, so no row points at nothing.POST /jobstakes the ids (a job without text is titled by its first file's name);GET /files/{id}serves the signed-in student's own files, and the Context API serves an agent only the files of its job (get_file). - The API writes to the bucket in
GCS_BUCKET, or to the directory inSTORAGE_DIRfor local development and tests (it takes precedence). -
snapshots: Substrate snapshots, deleted by a lifecycle rule after 3 days. - Locally, an S3-compatible store inside kind holds snapshots.
- Each user has a profile doc and one doc per subject, capped at about 2k tokens, always in the orchestrator's prompt. The curator agent updates them after accepted runs and feedback. They are derived from the other tables and can be rebuilt.
- For anything else, agents use agentic search through Context API tools:
list_history,read_artifact,search_history(Postgres full-text search). With a few dozen items per student this beats embeddings and has no indexing pipeline. - Rows in Postgres rather than files in a bucket: saved in the same transaction as the run, one access path to secure, one delete.
pgvector in the same Postgres, added next to the memory docs, not instead of them:
-
CREATE EXTENSION vector, achunkstable with an HNSW index. - An embedding step on each "artifact saved" event.
-
search_historyswitches to hybrid search (keyword + vector, filtered byuser_id). Agents keep calling the same tool, so prompts don't change.
Why not a separate vector database: every query is "this student only" and every deletion request is
"everything about this student". In Postgres both are WHERE user_id = ...; a second system doubles
every write and delete. Revisit only if measurements show pgvector falling behind.