Artifact 1a687a623851aad3fb3756f447a249988f47455cec274f1701e91d640a44fd57:
- File
test/pic/journal-v3.sql
— part of check-in
[3ff8346a3f]
at
2026-11-19 00:38:38
on branch stage-4
— Journal every reply in two forms and convert across models
Assistant entries keep the provider content verbatim with its origin (provider, api, model) and Pi neutral form; tool calls come from the neutral form, the same for every provider. A turn goes back verbatim to the model that wrote it and is otherwise rebuilt from the neutral form, without thinking and with tool-call ids normalised identically in calls and results. --model resolves through the registry, keys come from the model, and schema 3 journals migrate in place on open. (user: dmestas, size: 2291) [annotate] [blame] [check-ins using] [more...]
-- A schema-3 journal as pic wrote it before the neutral form (2026-11-18): -- one answered submission with a write call, its result and an answer. -- test/pic/migrate.sh opens it with the current pic. CREATE TABLE pic_meta(key TEXT PRIMARY KEY, value TEXT NOT NULL); CREATE TABLE pic_submission(id INTEGER PRIMARY KEY, request_key TEXT NOT NULL UNIQUE, content TEXT NOT NULL, status TEXT NOT NULL CHECK(status IN ('admitted','answered','failed')), error TEXT); CREATE TABLE pic_entry(seq INTEGER PRIMARY KEY, submission_id INTEGER NOT NULL, kind TEXT NOT NULL CHECK(kind IN ('user','assistant','tool_result','answer')), body TEXT NOT NULL, effect_id INTEGER); CREATE TABLE pic_effect(id INTEGER PRIMARY KEY, entry_seq INTEGER NOT NULL, ordinal INTEGER NOT NULL, call_id TEXT NOT NULL, tool TEXT NOT NULL, input TEXT NOT NULL, replay_safe INTEGER NOT NULL CHECK(replay_safe IN (0,1)), state TEXT NOT NULL CHECK(state IN ('intent','started','done','unknown','skipped')), result TEXT, is_error INTEGER NOT NULL DEFAULT 0 CHECK(is_error IN (0,1)), plan BLOB, UNIQUE(entry_seq, ordinal)); CREATE TABLE pic_generation(id INTEGER PRIMARY KEY, submission_id INTEGER NOT NULL, turn INTEGER NOT NULL, attempt INTEGER NOT NULL, state TEXT NOT NULL CHECK(state IN ('started','done','failed')), entry_seq INTEGER, stop_reason TEXT, usage TEXT, request_id TEXT, error TEXT, UNIQUE(submission_id, turn, attempt)); INSERT INTO pic_meta VALUES('schema_version','3'); INSERT INTO pic_submission VALUES(1,'old-1','make notes','answered',NULL); INSERT INTO pic_entry VALUES(1,1,'user','make notes',NULL); INSERT INTO pic_entry VALUES(2,1,'assistant','[{"type":"thinking","thinking":"Write it.","signature":"SIG-OLD"},{"type":"tool_use","id":"toolu_old","name":"write","input":{"path":"notes.txt","content":"hi"}}]',NULL); INSERT INTO pic_entry VALUES(3,1,'tool_result','Successfully wrote to notes.txt',1); INSERT INTO pic_entry VALUES(4,1,'answer','[{"type":"text","text":"done"}]',NULL); INSERT INTO pic_effect VALUES(1,2,0,'toolu_old','write','{"path":"notes.txt","content":"hi"}',1,'done','Successfully wrote to notes.txt',0,NULL); INSERT INTO pic_generation VALUES(1,1,0,1,'done',2,'tool_use',NULL,NULL,NULL); INSERT INTO pic_generation VALUES(2,1,1,1,'done',4,'end_turn',NULL,NULL,NULL);