diff --git a/.sqlx/query-913496d365010822c99818a92fc901a1939d16cb7aff9023c8b7331ece7265c0.json b/.sqlx/query-37c8e360c3557ede7f79c9f210984598576292ee347427e1a54441bceb88ed12.json similarity index 87% rename from .sqlx/query-913496d365010822c99818a92fc901a1939d16cb7aff9023c8b7331ece7265c0.json rename to .sqlx/query-37c8e360c3557ede7f79c9f210984598576292ee347427e1a54441bceb88ed12.json index 31ab398..aca455a 100644 --- a/.sqlx/query-913496d365010822c99818a92fc901a1939d16cb7aff9023c8b7331ece7265c0.json +++ b/.sqlx/query-37c8e360c3557ede7f79c9f210984598576292ee347427e1a54441bceb88ed12.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "UPDATE podcast_job SET eta_secs = $2 WHERE id = $1 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", + "query": "UPDATE podcast_job SET eta_secs = $2 WHERE id = $1 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", "describe": { "columns": [ { @@ -49,6 +49,17 @@ }, { "ordinal": 4, + "name": "transcript", + "type_info": "Text", + "origin": { + "Table": { + "table": "podcast_job", + "name": "transcript" + } + } + }, + { + "ordinal": 5, "name": "state: PodcastJobState", "type_info": "Text", "origin": { @@ -59,7 +70,7 @@ } }, { - "ordinal": 5, + "ordinal": 6, "name": "stage", "type_info": "Text", "origin": { @@ -70,7 +81,7 @@ } }, { - "ordinal": 6, + "ordinal": 7, "name": "progress", "type_info": "Float8", "origin": { @@ -81,7 +92,7 @@ } }, { - "ordinal": 7, + "ordinal": 8, "name": "error_code", "type_info": "Text", "origin": { @@ -92,7 +103,7 @@ } }, { - "ordinal": 8, + "ordinal": 9, "name": "audio_key", "type_info": "Text", "origin": { @@ -103,7 +114,7 @@ } }, { - "ordinal": 9, + "ordinal": 10, "name": "audio_name", "type_info": "Text", "origin": { @@ -114,7 +125,7 @@ } }, { - "ordinal": 10, + "ordinal": 11, "name": "audio_type", "type_info": "Text", "origin": { @@ -125,7 +136,7 @@ } }, { - "ordinal": 11, + "ordinal": 12, "name": "audio_bytes", "type_info": "Int8", "origin": { @@ -136,7 +147,7 @@ } }, { - "ordinal": 12, + "ordinal": 13, "name": "duration_secs", "type_info": "Float8", "origin": { @@ -147,7 +158,7 @@ } }, { - "ordinal": 13, + "ordinal": 14, "name": "eta_secs", "type_info": "Int8", "origin": { @@ -158,7 +169,7 @@ } }, { - "ordinal": 14, + "ordinal": 15, "name": "created_at: Timestamp", "type_info": "Int8", "origin": { @@ -169,7 +180,7 @@ } }, { - "ordinal": 15, + "ordinal": 16, "name": "updated_at: Timestamp", "type_info": "Int8", "origin": { @@ -191,6 +202,7 @@ false, false, true, + true, false, false, false, @@ -205,5 +217,5 @@ false ] }, - "hash": "913496d365010822c99818a92fc901a1939d16cb7aff9023c8b7331ece7265c0" + "hash": "37c8e360c3557ede7f79c9f210984598576292ee347427e1a54441bceb88ed12" } diff --git a/.sqlx/query-826c34848d470eb17f7a677d1ce1d6d80b9a0cad9fbba7a655104c7d1a16ea18.json b/.sqlx/query-45ade92df6adc604f90c5e2111fc4bd23b8c6e901d81ca64a96bef3116ab906f.json similarity index 86% rename from .sqlx/query-826c34848d470eb17f7a677d1ce1d6d80b9a0cad9fbba7a655104c7d1a16ea18.json rename to .sqlx/query-45ade92df6adc604f90c5e2111fc4bd23b8c6e901d81ca64a96bef3116ab906f.json index 4419a53..664a2b3 100644 --- a/.sqlx/query-826c34848d470eb17f7a677d1ce1d6d80b9a0cad9fbba7a655104c7d1a16ea18.json +++ b/.sqlx/query-45ade92df6adc604f90c5e2111fc4bd23b8c6e901d81ca64a96bef3116ab906f.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\" FROM podcast_job WHERE id = $1", + "query": "SELECT id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\" FROM podcast_job WHERE id = $1 AND user_id = $2", "describe": { "columns": [ { @@ -49,6 +49,17 @@ }, { "ordinal": 4, + "name": "transcript", + "type_info": "Text", + "origin": { + "Table": { + "table": "podcast_job", + "name": "transcript" + } + } + }, + { + "ordinal": 5, "name": "state: PodcastJobState", "type_info": "Text", "origin": { @@ -59,7 +70,7 @@ } }, { - "ordinal": 5, + "ordinal": 6, "name": "stage", "type_info": "Text", "origin": { @@ -70,7 +81,7 @@ } }, { - "ordinal": 6, + "ordinal": 7, "name": "progress", "type_info": "Float8", "origin": { @@ -81,7 +92,7 @@ } }, { - "ordinal": 7, + "ordinal": 8, "name": "error_code", "type_info": "Text", "origin": { @@ -92,7 +103,7 @@ } }, { - "ordinal": 8, + "ordinal": 9, "name": "audio_key", "type_info": "Text", "origin": { @@ -103,7 +114,7 @@ } }, { - "ordinal": 9, + "ordinal": 10, "name": "audio_name", "type_info": "Text", "origin": { @@ -114,7 +125,7 @@ } }, { - "ordinal": 10, + "ordinal": 11, "name": "audio_type", "type_info": "Text", "origin": { @@ -125,7 +136,7 @@ } }, { - "ordinal": 11, + "ordinal": 12, "name": "audio_bytes", "type_info": "Int8", "origin": { @@ -136,7 +147,7 @@ } }, { - "ordinal": 12, + "ordinal": 13, "name": "duration_secs", "type_info": "Float8", "origin": { @@ -147,7 +158,7 @@ } }, { - "ordinal": 13, + "ordinal": 14, "name": "eta_secs", "type_info": "Int8", "origin": { @@ -158,7 +169,7 @@ } }, { - "ordinal": 14, + "ordinal": 15, "name": "created_at: Timestamp", "type_info": "Int8", "origin": { @@ -169,7 +180,7 @@ } }, { - "ordinal": 15, + "ordinal": 16, "name": "updated_at: Timestamp", "type_info": "Int8", "origin": { @@ -182,6 +193,7 @@ ], "parameters": { "Left": [ + "Uuid", "Uuid" ] }, @@ -190,6 +202,7 @@ false, false, true, + true, false, false, false, @@ -204,5 +217,5 @@ false ] }, - "hash": "826c34848d470eb17f7a677d1ce1d6d80b9a0cad9fbba7a655104c7d1a16ea18" + "hash": "45ade92df6adc604f90c5e2111fc4bd23b8c6e901d81ca64a96bef3116ab906f" } diff --git a/.sqlx/query-ad5b90d0407d3abf9a3bdf119146041a67a486a5560fa151ad8fe8210bfd9d53.json b/.sqlx/query-4b05eec4ece0295d6be7ce2b92238e49fabe71d62b021c1d1425e51d9f1adbe3.json similarity index 87% rename from .sqlx/query-ad5b90d0407d3abf9a3bdf119146041a67a486a5560fa151ad8fe8210bfd9d53.json rename to .sqlx/query-4b05eec4ece0295d6be7ce2b92238e49fabe71d62b021c1d1425e51d9f1adbe3.json index ce5bb21..0d966c8 100644 --- a/.sqlx/query-ad5b90d0407d3abf9a3bdf119146041a67a486a5560fa151ad8fe8210bfd9d53.json +++ b/.sqlx/query-4b05eec4ece0295d6be7ce2b92238e49fabe71d62b021c1d1425e51d9f1adbe3.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "UPDATE podcast_job SET state = 'cancelled', stage = '', updated_at = $2 WHERE id = $1 AND state IN ('queued', 'running') RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", + "query": "UPDATE podcast_job SET state = 'cancelled', stage = '', updated_at = $2 WHERE id = $1 AND state IN ('queued', 'running') RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", "describe": { "columns": [ { @@ -49,6 +49,17 @@ }, { "ordinal": 4, + "name": "transcript", + "type_info": "Text", + "origin": { + "Table": { + "table": "podcast_job", + "name": "transcript" + } + } + }, + { + "ordinal": 5, "name": "state: PodcastJobState", "type_info": "Text", "origin": { @@ -59,7 +70,7 @@ } }, { - "ordinal": 5, + "ordinal": 6, "name": "stage", "type_info": "Text", "origin": { @@ -70,7 +81,7 @@ } }, { - "ordinal": 6, + "ordinal": 7, "name": "progress", "type_info": "Float8", "origin": { @@ -81,7 +92,7 @@ } }, { - "ordinal": 7, + "ordinal": 8, "name": "error_code", "type_info": "Text", "origin": { @@ -92,7 +103,7 @@ } }, { - "ordinal": 8, + "ordinal": 9, "name": "audio_key", "type_info": "Text", "origin": { @@ -103,7 +114,7 @@ } }, { - "ordinal": 9, + "ordinal": 10, "name": "audio_name", "type_info": "Text", "origin": { @@ -114,7 +125,7 @@ } }, { - "ordinal": 10, + "ordinal": 11, "name": "audio_type", "type_info": "Text", "origin": { @@ -125,7 +136,7 @@ } }, { - "ordinal": 11, + "ordinal": 12, "name": "audio_bytes", "type_info": "Int8", "origin": { @@ -136,7 +147,7 @@ } }, { - "ordinal": 12, + "ordinal": 13, "name": "duration_secs", "type_info": "Float8", "origin": { @@ -147,7 +158,7 @@ } }, { - "ordinal": 13, + "ordinal": 14, "name": "eta_secs", "type_info": "Int8", "origin": { @@ -158,7 +169,7 @@ } }, { - "ordinal": 14, + "ordinal": 15, "name": "created_at: Timestamp", "type_info": "Int8", "origin": { @@ -169,7 +180,7 @@ } }, { - "ordinal": 15, + "ordinal": 16, "name": "updated_at: Timestamp", "type_info": "Int8", "origin": { @@ -191,6 +202,7 @@ false, false, true, + true, false, false, false, @@ -205,5 +217,5 @@ false ] }, - "hash": "ad5b90d0407d3abf9a3bdf119146041a67a486a5560fa151ad8fe8210bfd9d53" + "hash": "4b05eec4ece0295d6be7ce2b92238e49fabe71d62b021c1d1425e51d9f1adbe3" } diff --git a/.sqlx/query-00e4b6eca87d0ab5012f3d0562bf749302b7824859737c780efb433e972af5e4.json b/.sqlx/query-814486dbb11e8eeaf410bced5a0aae724aa3f0198ce4204cd94016b827ab55b7.json similarity index 87% rename from .sqlx/query-00e4b6eca87d0ab5012f3d0562bf749302b7824859737c780efb433e972af5e4.json rename to .sqlx/query-814486dbb11e8eeaf410bced5a0aae724aa3f0198ce4204cd94016b827ab55b7.json index 66bff97..37f4fb4 100644 --- a/.sqlx/query-00e4b6eca87d0ab5012f3d0562bf749302b7824859737c780efb433e972af5e4.json +++ b/.sqlx/query-814486dbb11e8eeaf410bced5a0aae724aa3f0198ce4204cd94016b827ab55b7.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "UPDATE podcast_job SET state = 'failed', error_code = $2, stage = '', updated_at = $3 WHERE id = $1 AND state IN ('queued', 'running') RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", + "query": "UPDATE podcast_job SET state = 'failed', error_code = $2, stage = '', updated_at = $3 WHERE id = $1 AND state IN ('queued', 'running') RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", "describe": { "columns": [ { @@ -49,6 +49,17 @@ }, { "ordinal": 4, + "name": "transcript", + "type_info": "Text", + "origin": { + "Table": { + "table": "podcast_job", + "name": "transcript" + } + } + }, + { + "ordinal": 5, "name": "state: PodcastJobState", "type_info": "Text", "origin": { @@ -59,7 +70,7 @@ } }, { - "ordinal": 5, + "ordinal": 6, "name": "stage", "type_info": "Text", "origin": { @@ -70,7 +81,7 @@ } }, { - "ordinal": 6, + "ordinal": 7, "name": "progress", "type_info": "Float8", "origin": { @@ -81,7 +92,7 @@ } }, { - "ordinal": 7, + "ordinal": 8, "name": "error_code", "type_info": "Text", "origin": { @@ -92,7 +103,7 @@ } }, { - "ordinal": 8, + "ordinal": 9, "name": "audio_key", "type_info": "Text", "origin": { @@ -103,7 +114,7 @@ } }, { - "ordinal": 9, + "ordinal": 10, "name": "audio_name", "type_info": "Text", "origin": { @@ -114,7 +125,7 @@ } }, { - "ordinal": 10, + "ordinal": 11, "name": "audio_type", "type_info": "Text", "origin": { @@ -125,7 +136,7 @@ } }, { - "ordinal": 11, + "ordinal": 12, "name": "audio_bytes", "type_info": "Int8", "origin": { @@ -136,7 +147,7 @@ } }, { - "ordinal": 12, + "ordinal": 13, "name": "duration_secs", "type_info": "Float8", "origin": { @@ -147,7 +158,7 @@ } }, { - "ordinal": 13, + "ordinal": 14, "name": "eta_secs", "type_info": "Int8", "origin": { @@ -158,7 +169,7 @@ } }, { - "ordinal": 14, + "ordinal": 15, "name": "created_at: Timestamp", "type_info": "Int8", "origin": { @@ -169,7 +180,7 @@ } }, { - "ordinal": 15, + "ordinal": 16, "name": "updated_at: Timestamp", "type_info": "Int8", "origin": { @@ -192,6 +203,7 @@ false, false, true, + true, false, false, false, @@ -206,5 +218,5 @@ false ] }, - "hash": "00e4b6eca87d0ab5012f3d0562bf749302b7824859737c780efb433e972af5e4" + "hash": "814486dbb11e8eeaf410bced5a0aae724aa3f0198ce4204cd94016b827ab55b7" } diff --git a/.sqlx/query-f1a079e6c5978b7d9458172705e0c66f070d71e3435dc8f359d09675c5fcccdc.json b/.sqlx/query-b3044b692a7cca8eb27c9060462465df513a477b6f67329ea555ed41c87919d0.json similarity index 87% rename from .sqlx/query-f1a079e6c5978b7d9458172705e0c66f070d71e3435dc8f359d09675c5fcccdc.json rename to .sqlx/query-b3044b692a7cca8eb27c9060462465df513a477b6f67329ea555ed41c87919d0.json index 5521750..280536d 100644 --- a/.sqlx/query-f1a079e6c5978b7d9458172705e0c66f070d71e3435dc8f359d09675c5fcccdc.json +++ b/.sqlx/query-b3044b692a7cca8eb27c9060462465df513a477b6f67329ea555ed41c87919d0.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "UPDATE podcast_job SET audio_key = $2, audio_name = $3, audio_type = $4, audio_bytes = $5, duration_secs = $6, updated_at = $7 WHERE id = $1 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", + "query": "UPDATE podcast_job SET audio_key = $2, audio_name = $3, audio_type = $4, audio_bytes = $5, duration_secs = $6, updated_at = $7 WHERE id = $1 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", "describe": { "columns": [ { @@ -49,6 +49,17 @@ }, { "ordinal": 4, + "name": "transcript", + "type_info": "Text", + "origin": { + "Table": { + "table": "podcast_job", + "name": "transcript" + } + } + }, + { + "ordinal": 5, "name": "state: PodcastJobState", "type_info": "Text", "origin": { @@ -59,7 +70,7 @@ } }, { - "ordinal": 5, + "ordinal": 6, "name": "stage", "type_info": "Text", "origin": { @@ -70,7 +81,7 @@ } }, { - "ordinal": 6, + "ordinal": 7, "name": "progress", "type_info": "Float8", "origin": { @@ -81,7 +92,7 @@ } }, { - "ordinal": 7, + "ordinal": 8, "name": "error_code", "type_info": "Text", "origin": { @@ -92,7 +103,7 @@ } }, { - "ordinal": 8, + "ordinal": 9, "name": "audio_key", "type_info": "Text", "origin": { @@ -103,7 +114,7 @@ } }, { - "ordinal": 9, + "ordinal": 10, "name": "audio_name", "type_info": "Text", "origin": { @@ -114,7 +125,7 @@ } }, { - "ordinal": 10, + "ordinal": 11, "name": "audio_type", "type_info": "Text", "origin": { @@ -125,7 +136,7 @@ } }, { - "ordinal": 11, + "ordinal": 12, "name": "audio_bytes", "type_info": "Int8", "origin": { @@ -136,7 +147,7 @@ } }, { - "ordinal": 12, + "ordinal": 13, "name": "duration_secs", "type_info": "Float8", "origin": { @@ -147,7 +158,7 @@ } }, { - "ordinal": 13, + "ordinal": 14, "name": "eta_secs", "type_info": "Int8", "origin": { @@ -158,7 +169,7 @@ } }, { - "ordinal": 14, + "ordinal": 15, "name": "created_at: Timestamp", "type_info": "Int8", "origin": { @@ -169,7 +180,7 @@ } }, { - "ordinal": 15, + "ordinal": 16, "name": "updated_at: Timestamp", "type_info": "Int8", "origin": { @@ -196,6 +207,7 @@ false, false, true, + true, false, false, false, @@ -210,5 +222,5 @@ false ] }, - "hash": "f1a079e6c5978b7d9458172705e0c66f070d71e3435dc8f359d09675c5fcccdc" + "hash": "b3044b692a7cca8eb27c9060462465df513a477b6f67329ea555ed41c87919d0" } diff --git a/.sqlx/query-636b29289a1fc139ca239ddae85bdd59d39b5f90fb69e27cf6acb616cd3c8101.json b/.sqlx/query-cabbdce4f24ffcd7792dc8b9b9f72d02d920bf9fabc10c61584b0bd64c7712ff.json similarity index 88% rename from .sqlx/query-636b29289a1fc139ca239ddae85bdd59d39b5f90fb69e27cf6acb616cd3c8101.json rename to .sqlx/query-cabbdce4f24ffcd7792dc8b9b9f72d02d920bf9fabc10c61584b0bd64c7712ff.json index f7420d1..d279439 100644 --- a/.sqlx/query-636b29289a1fc139ca239ddae85bdd59d39b5f90fb69e27cf6acb616cd3c8101.json +++ b/.sqlx/query-cabbdce4f24ffcd7792dc8b9b9f72d02d920bf9fabc10c61584b0bd64c7712ff.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "INSERT INTO podcast_job (id, user_id, source_id, format, state, stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $15) RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", + "query": "INSERT INTO podcast_job (id, user_id, source_id, format, state, stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $15) RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", "describe": { "columns": [ { @@ -49,6 +49,17 @@ }, { "ordinal": 4, + "name": "transcript", + "type_info": "Text", + "origin": { + "Table": { + "table": "podcast_job", + "name": "transcript" + } + } + }, + { + "ordinal": 5, "name": "state: PodcastJobState", "type_info": "Text", "origin": { @@ -59,7 +70,7 @@ } }, { - "ordinal": 5, + "ordinal": 6, "name": "stage", "type_info": "Text", "origin": { @@ -70,7 +81,7 @@ } }, { - "ordinal": 6, + "ordinal": 7, "name": "progress", "type_info": "Float8", "origin": { @@ -81,7 +92,7 @@ } }, { - "ordinal": 7, + "ordinal": 8, "name": "error_code", "type_info": "Text", "origin": { @@ -92,7 +103,7 @@ } }, { - "ordinal": 8, + "ordinal": 9, "name": "audio_key", "type_info": "Text", "origin": { @@ -103,7 +114,7 @@ } }, { - "ordinal": 9, + "ordinal": 10, "name": "audio_name", "type_info": "Text", "origin": { @@ -114,7 +125,7 @@ } }, { - "ordinal": 10, + "ordinal": 11, "name": "audio_type", "type_info": "Text", "origin": { @@ -125,7 +136,7 @@ } }, { - "ordinal": 11, + "ordinal": 12, "name": "audio_bytes", "type_info": "Int8", "origin": { @@ -136,7 +147,7 @@ } }, { - "ordinal": 12, + "ordinal": 13, "name": "duration_secs", "type_info": "Float8", "origin": { @@ -147,7 +158,7 @@ } }, { - "ordinal": 13, + "ordinal": 14, "name": "eta_secs", "type_info": "Int8", "origin": { @@ -158,7 +169,7 @@ } }, { - "ordinal": 14, + "ordinal": 15, "name": "created_at: Timestamp", "type_info": "Int8", "origin": { @@ -169,7 +180,7 @@ } }, { - "ordinal": 15, + "ordinal": 16, "name": "updated_at: Timestamp", "type_info": "Int8", "origin": { @@ -204,6 +215,7 @@ false, false, true, + true, false, false, false, @@ -218,5 +230,5 @@ false ] }, - "hash": "636b29289a1fc139ca239ddae85bdd59d39b5f90fb69e27cf6acb616cd3c8101" + "hash": "cabbdce4f24ffcd7792dc8b9b9f72d02d920bf9fabc10c61584b0bd64c7712ff" } diff --git a/.sqlx/query-91c968305e53e61df2c67fdaeea78150a1e8c7f19991e21b45272785cd2e4055.json b/.sqlx/query-d1b16c756ea05fe53f875c57b4d46dfdc152943eb31d5df4c531af6da3e6ec7b.json similarity index 86% rename from .sqlx/query-91c968305e53e61df2c67fdaeea78150a1e8c7f19991e21b45272785cd2e4055.json rename to .sqlx/query-d1b16c756ea05fe53f875c57b4d46dfdc152943eb31d5df4c531af6da3e6ec7b.json index 2e0ee6c..3314af8 100644 --- a/.sqlx/query-91c968305e53e61df2c67fdaeea78150a1e8c7f19991e21b45272785cd2e4055.json +++ b/.sqlx/query-d1b16c756ea05fe53f875c57b4d46dfdc152943eb31d5df4c531af6da3e6ec7b.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\" FROM podcast_job WHERE id = $1 AND user_id = $2", + "query": "SELECT id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\" FROM podcast_job WHERE id = $1", "describe": { "columns": [ { @@ -49,6 +49,17 @@ }, { "ordinal": 4, + "name": "transcript", + "type_info": "Text", + "origin": { + "Table": { + "table": "podcast_job", + "name": "transcript" + } + } + }, + { + "ordinal": 5, "name": "state: PodcastJobState", "type_info": "Text", "origin": { @@ -59,7 +70,7 @@ } }, { - "ordinal": 5, + "ordinal": 6, "name": "stage", "type_info": "Text", "origin": { @@ -70,7 +81,7 @@ } }, { - "ordinal": 6, + "ordinal": 7, "name": "progress", "type_info": "Float8", "origin": { @@ -81,7 +92,7 @@ } }, { - "ordinal": 7, + "ordinal": 8, "name": "error_code", "type_info": "Text", "origin": { @@ -92,7 +103,7 @@ } }, { - "ordinal": 8, + "ordinal": 9, "name": "audio_key", "type_info": "Text", "origin": { @@ -103,7 +114,7 @@ } }, { - "ordinal": 9, + "ordinal": 10, "name": "audio_name", "type_info": "Text", "origin": { @@ -114,7 +125,7 @@ } }, { - "ordinal": 10, + "ordinal": 11, "name": "audio_type", "type_info": "Text", "origin": { @@ -125,7 +136,7 @@ } }, { - "ordinal": 11, + "ordinal": 12, "name": "audio_bytes", "type_info": "Int8", "origin": { @@ -136,7 +147,7 @@ } }, { - "ordinal": 12, + "ordinal": 13, "name": "duration_secs", "type_info": "Float8", "origin": { @@ -147,7 +158,7 @@ } }, { - "ordinal": 13, + "ordinal": 14, "name": "eta_secs", "type_info": "Int8", "origin": { @@ -158,7 +169,7 @@ } }, { - "ordinal": 14, + "ordinal": 15, "name": "created_at: Timestamp", "type_info": "Int8", "origin": { @@ -169,7 +180,7 @@ } }, { - "ordinal": 15, + "ordinal": 16, "name": "updated_at: Timestamp", "type_info": "Int8", "origin": { @@ -182,7 +193,6 @@ ], "parameters": { "Left": [ - "Uuid", "Uuid" ] }, @@ -191,6 +201,7 @@ false, false, true, + true, false, false, false, @@ -205,5 +216,5 @@ false ] }, - "hash": "91c968305e53e61df2c67fdaeea78150a1e8c7f19991e21b45272785cd2e4055" + "hash": "d1b16c756ea05fe53f875c57b4d46dfdc152943eb31d5df4c531af6da3e6ec7b" } diff --git a/.sqlx/query-e3c904f558317d2d0c709f4b6bb3c2109bc86448a3dc6895c5bf2a9c0c99cc98.json b/.sqlx/query-f40008ce74997412bd8099f21cc58579d2c6efc73d04072849fe650a737e7a4c.json similarity index 85% rename from .sqlx/query-e3c904f558317d2d0c709f4b6bb3c2109bc86448a3dc6895c5bf2a9c0c99cc98.json rename to .sqlx/query-f40008ce74997412bd8099f21cc58579d2c6efc73d04072849fe650a737e7a4c.json index 013c0f4..821fdf8 100644 --- a/.sqlx/query-e3c904f558317d2d0c709f4b6bb3c2109bc86448a3dc6895c5bf2a9c0c99cc98.json +++ b/.sqlx/query-f40008ce74997412bd8099f21cc58579d2c6efc73d04072849fe650a737e7a4c.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "UPDATE podcast_job SET state = $3, stage = $4, progress = $5, error_code = $6, format = COALESCE(format, $7::text), updated_at = $8 WHERE id = $1 AND state = $2 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", + "query": "UPDATE podcast_job SET state = $3, stage = $4, progress = $5, error_code = $6, format = COALESCE(format, $7::text), transcript = COALESCE(transcript, $8::text), updated_at = $9 WHERE id = $1 AND state = $2 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", "describe": { "columns": [ { @@ -49,6 +49,17 @@ }, { "ordinal": 4, + "name": "transcript", + "type_info": "Text", + "origin": { + "Table": { + "table": "podcast_job", + "name": "transcript" + } + } + }, + { + "ordinal": 5, "name": "state: PodcastJobState", "type_info": "Text", "origin": { @@ -59,7 +70,7 @@ } }, { - "ordinal": 5, + "ordinal": 6, "name": "stage", "type_info": "Text", "origin": { @@ -70,7 +81,7 @@ } }, { - "ordinal": 6, + "ordinal": 7, "name": "progress", "type_info": "Float8", "origin": { @@ -81,7 +92,7 @@ } }, { - "ordinal": 7, + "ordinal": 8, "name": "error_code", "type_info": "Text", "origin": { @@ -92,7 +103,7 @@ } }, { - "ordinal": 8, + "ordinal": 9, "name": "audio_key", "type_info": "Text", "origin": { @@ -103,7 +114,7 @@ } }, { - "ordinal": 9, + "ordinal": 10, "name": "audio_name", "type_info": "Text", "origin": { @@ -114,7 +125,7 @@ } }, { - "ordinal": 10, + "ordinal": 11, "name": "audio_type", "type_info": "Text", "origin": { @@ -125,7 +136,7 @@ } }, { - "ordinal": 11, + "ordinal": 12, "name": "audio_bytes", "type_info": "Int8", "origin": { @@ -136,7 +147,7 @@ } }, { - "ordinal": 12, + "ordinal": 13, "name": "duration_secs", "type_info": "Float8", "origin": { @@ -147,7 +158,7 @@ } }, { - "ordinal": 13, + "ordinal": 14, "name": "eta_secs", "type_info": "Int8", "origin": { @@ -158,7 +169,7 @@ } }, { - "ordinal": 14, + "ordinal": 15, "name": "created_at: Timestamp", "type_info": "Int8", "origin": { @@ -169,7 +180,7 @@ } }, { - "ordinal": 15, + "ordinal": 16, "name": "updated_at: Timestamp", "type_info": "Int8", "origin": { @@ -189,6 +200,7 @@ "Float8", "Text", "Text", + "Text", "Int8" ] }, @@ -197,6 +209,7 @@ false, false, true, + true, false, false, false, @@ -211,5 +224,5 @@ false ] }, - "hash": "e3c904f558317d2d0c709f4b6bb3c2109bc86448a3dc6895c5bf2a9c0c99cc98" + "hash": "f40008ce74997412bd8099f21cc58579d2c6efc73d04072849fe650a737e7a4c" } diff --git a/migrations/school/20260923000001_podcast_transcript.sql b/migrations/school/20260923000001_podcast_transcript.sql new file mode 100644 index 0000000..f248b42 --- /dev/null +++ b/migrations/school/20260923000001_podcast_transcript.sql @@ -0,0 +1,10 @@ +-- The episode transcript, as the service reported it on `podcast.report`: +-- one TEXT blob, chapters already joined with blank lines. +-- +-- WHERE THIS FILE BELONGS: `migrations/school/` in the backend repo. APPEND-ONLY +-- relative to the existing school migrations: one new nullable column, no +-- backfill. A job finished before this column existed stays NULL, and a report +-- that omits the field (a service that has not learned it yet) leaves it NULL. +-- The report statement fills it once (`COALESCE`), the same way `format` is +-- filled, and never rewrites a value that already landed. +ALTER TABLE podcast_job ADD COLUMN transcript TEXT NULL; diff --git a/src/ai/podcast.rs b/src/ai/podcast.rs index 7a9ed1e..0af213b 100644 --- a/src/ai/podcast.rs +++ b/src/ai/podcast.rs @@ -114,6 +114,12 @@ pub struct PodcastReportPayload { pub progress: f64, #[serde(default)] pub error_code: Option, + /// The finished episode's transcript: one text blob, chapters already + /// joined with blank lines. Absent on a report that is not `done`, and on + /// a service that has not learned the field yet — `#[serde(default)]` + /// keeps that older payload valid. + #[serde(default)] + pub transcript: Option, } /// The answer to one report. `stored` is always `true` on an `Ok` — an @@ -148,7 +154,8 @@ pub async fn cancel( /// /// The decode is deliberately strict: a payload that does not fit /// [`PodcastReportPayload`] is `invalid_payload`, never coerced into a -/// half-filled report. +/// half-filled report. `transcript` is the one defaulted field, so a service +/// that omits it still reports. pub async fn report(db: &Database, payload: Value) -> Result { let report: PodcastReportPayload = serde_json::from_value(payload).map_err(|err| { ( @@ -165,6 +172,7 @@ pub async fn report(db: &Database, payload: Value) -> Result Ok(serde_json::to_value(PodcastReportReply { diff --git a/src/db/podcast_job.rs b/src/db/podcast_job.rs index 39e80fc..902ceb4 100644 --- a/src/db/podcast_job.rs +++ b/src/db/podcast_job.rs @@ -36,7 +36,7 @@ pub async fn insert(db: &Database, job: &PodcastJob) -> Result Result Ok(query_as!( PodcastJob, "SELECT id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \ - source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, \ + source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, \ audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \ created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\" \ FROM podcast_job WHERE id = $1", @@ -87,7 +87,7 @@ pub async fn read_for( Ok(query_as!( PodcastJob, "SELECT id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \ - source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, \ + source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, \ audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \ created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\" \ FROM podcast_job WHERE id = $1 AND user_id = $2", @@ -177,9 +177,11 @@ async fn with_source_titles( /// concurrent write (a cancel, another report) moved it first — the caller /// re-reads and answers the truth. /// -/// `format` fills the column once and never rewrites it: the service's default -/// resolution arrives on the first report, and a later report disagreeing with -/// it is refused by the service layer, not silently stored. +/// `format` and `transcript` fill their columns once and never rewrite them: +/// the service's default resolution arrives on the first report, and a later +/// report disagreeing with the format is refused by the service layer, not +/// silently stored. A later transcript is ignored the same way — the first +/// non-null value stands. #[allow(clippy::too_many_arguments)] pub async fn report( db: &Database, @@ -190,15 +192,17 @@ pub async fn report( progress: f64, error_code: Option<&str>, format: Option<&str>, + transcript: Option<&str>, ) -> Result, AppError> { let now = Timestamp::now().as_millis(); Ok(query_as!( PodcastJob, "UPDATE podcast_job SET state = $3, stage = $4, progress = $5, error_code = $6, \ - format = COALESCE(format, $7::text), updated_at = $8 \ + format = COALESCE(format, $7::text), transcript = COALESCE(transcript, $8::text), \ + updated_at = $9 \ WHERE id = $1 AND state = $2 \ RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \ - source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, \ + source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, \ audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \ created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", id.uuid(), @@ -208,6 +212,7 @@ pub async fn report( progress, error_code, format, + transcript, now, ) .fetch_optional(db) @@ -228,7 +233,7 @@ pub async fn set_cancelled( "UPDATE podcast_job SET state = 'cancelled', stage = '', updated_at = $2 \ WHERE id = $1 AND state IN ('queued', 'running') \ RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \ - source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, \ + source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, \ audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \ created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", id.uuid(), @@ -253,7 +258,7 @@ pub async fn set_failed( "UPDATE podcast_job SET state = 'failed', error_code = $2, stage = '', updated_at = $3 \ WHERE id = $1 AND state IN ('queued', 'running') \ RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \ - source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, \ + source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, \ audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \ created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", id.uuid(), @@ -284,7 +289,7 @@ pub async fn set_audio( audio_bytes = $5, duration_secs = $6, updated_at = $7 \ WHERE id = $1 \ RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \ - source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, \ + source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, \ audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \ created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", id.uuid(), @@ -311,7 +316,7 @@ pub async fn set_eta( PodcastJob, "UPDATE podcast_job SET eta_secs = $2 WHERE id = $1 \ RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \ - source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, \ + source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, \ audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \ created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", id.uuid(), @@ -355,6 +360,7 @@ mod tests { user_id: *user, source_id: "src".to_string(), format: None, + transcript: None, state: PodcastJobState::Queued, stage: String::new(), progress: 0.0, @@ -379,7 +385,9 @@ mod tests { let row = insert(&db, &job(&user)).await.expect("insert"); let id = row.get_id().clone(); - // The running report lands, and carries the resolved format with it. + // The running report lands, and carries the resolved format and the + // transcript with it. A later report that does not match the row + // cannot clear either. let running = report( &db, &id, @@ -389,12 +397,14 @@ mod tests { 0.25, None, Some("duz_okuma"), + Some("bolum bir\n\nbolum iki"), ) .await .expect("report") .expect("row was queued"); assert_eq!(running.get_state(), PodcastJobState::Running); assert_eq!(running.get_format(), Some("duz_okuma")); + assert_eq!(running.get_transcript(), Some("bolum bir\n\nbolum iki")); // A second report claiming the row is still queued matches nothing. let stale = report( @@ -406,6 +416,7 @@ mod tests { 0.5, None, None, + Some("should not land"), ) .await .expect("report"); @@ -422,6 +433,7 @@ mod tests { 1.0, None, None, + Some("also not"), ) .await .expect("report"); @@ -430,6 +442,15 @@ mod tests { read(&db, &id).await.expect("read").unwrap().get_state(), PodcastJobState::Cancelled ); + assert_eq!( + read(&db, &id) + .await + .expect("read") + .unwrap() + .get_transcript(), + Some("bolum bir\n\nbolum iki"), + "a report that matched nothing did not clear the stored transcript" + ); // A terminal row refuses the backend's own writes too. assert!(set_failed(&db, &id, "interrupted").await.unwrap().is_none()); } @@ -473,6 +494,7 @@ mod tests { 1.0, None, None, + None, ) .await; assert!(refused.is_err(), "the CHECK backstops the service layer"); @@ -497,6 +519,7 @@ mod tests { 1.0, None, None, + Some("metin"), ) .await .expect("report") @@ -505,5 +528,6 @@ mod tests { assert_eq!(done.get_audio_key(), Some("podcast/x.mp3")); assert_eq!(done.get_duration_secs(), Some(3.5)); assert_eq!(done.get_audio_bytes(), Some(12)); + assert_eq!(done.get_transcript(), Some("metin")); } } diff --git a/src/domain/podcast_job.rs b/src/domain/podcast_job.rs index a06f13d..b44959f 100644 --- a/src/domain/podcast_job.rs +++ b/src/domain/podcast_job.rs @@ -136,6 +136,9 @@ pub struct PodcastJob { pub(crate) user_id: UserId, pub(crate) source_id: String, pub(crate) format: Option, + /// The episode transcript, chapters joined with blank lines. `None` until + /// a report carries one, and forever for a job whose service never did. + pub(crate) transcript: Option, pub(crate) state: PodcastJobState, pub(crate) stage: String, pub(crate) progress: f64, @@ -167,6 +170,10 @@ impl PodcastJob { self.format.as_deref() } + pub fn get_transcript(&self) -> Option<&str> { + self.transcript.as_deref() + } + pub fn get_state(&self) -> PodcastJobState { self.state } @@ -326,6 +333,7 @@ mod tests { user_id: UserId::from_key("00000000-0000-7000-8000-000000000000"), source_id: "src".to_string(), format: None, + transcript: None, state, stage: String::new(), progress: 0.0, diff --git a/src/lib.rs b/src/lib.rs index 6f1d754..3ffbcf0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,7 +59,7 @@ use crate::web::module_gate::gate; (name = "chatbot", description = "The AI chatbot, relayed through the QUIC bridge to an out-of-process AI service. Every authenticated role may chat (parents included) and every thread is private to its owner — nobody, not even an admin, reads someone else's. A user keeps up to the school's `max_chatbot_threads` threads (409 at the cap, delete one first) and sends at most `RATE_LIMIT_CHATBOT_PER_MINUTE` messages a minute (default 20, `0` disables the tier; 429 with `Retry-After`). A thread can be renamed — or its name cleared — with `PATCH /chatbot/threads/{id}` (`{title}`, `null` to clear); nothing names a thread automatically. Sending is asynchronous: `POST /chatbot/threads/{id}/messages` writes the turn plus an empty `pending` assistant row and answers `202 {message_id, status}` immediately, because an inference outlives a normal request. The pending row is what a reload comes back to, not a queued job: the bridge round trip runs in an in-process task the `202` leaves behind, so a restart mid-inference strands that turn — it settles `failed`/`interrupted` (a reader projects a `pending` row older than 300 seconds as failed, and the boot sweep stamps that verdict durably) rather than being answered by anyone. Accepted, because the backend is a single process with stop-the-world deploys: there is no peer that could have taken the turn over. Sending is also serialized against the thread's own deletion — both rows ride a transaction that writes the thread row, so a turn accepted while `DELETE /chatbot/threads/{id}` is committing is refused with a `404` instead of surviving as a message under a thread that is gone. The answer is then read either by polling `GET .../messages/{mid}` or over the Server-Sent-Events stream at `.../messages/{mid}/stream` (`delta` chunks, then one `done` or `error`) — both read the same row, so they never disagree, and a stream opened after the answer landed still replays it. An answer the service made longer than `max_chatbot_message_len` is clipped rather than discarded, and the stored turn is flagged `truncated: true` — the polling read and the SSE `done` payload always agree on it. A turn always settles: `complete` with the text, or `failed` with a short code (`unavailable`, `busy`, `timed_out`, `transport`, `protocol`, `bad_reply`, `empty_reply`, `interrupted`, or the service's own). With no `chat.reply` service connected anywhere in the deployment, sending answers `503` and writes nothing"), (name = "rag", description = "The course-note RAG: its own nest, threads and tables, relayed through the same QUIC bridge as the chatbot — RAG is not folded into the chatbot's storage. Every authenticated role may ask (parents included) and every thread is private to its owner. Every question is scoped server-side to `(sınıf, ders)` pairs derived by the server — a manager or an admin gets every class-course pair in the school, everyone else their own memberships (a linked parent's children, and the school-wide club/etüt memberships they hold, which scope the subject across grades, `sinif: null`) — never from the body, so a caller cannot widen their own retrieval; a scope past `MAX_RAG_SCOPE_PAIRS` pairs is refused (400) rather than narrowed. A RAG thread draws on the school's existing AI thread seats (`max_chatbot_threads`, the same seat count the chatbot nest uses, one pool per user), its prompts and answers are bounded by `max_chatbot_message_len`, and its per-minute tier is its own: `RATE_LIMIT_RAG_PER_MINUTE` (default 6, `0` disables the tier; 429 with `Retry-After`). Sending is asynchronous exactly as the chatbot's is: `POST /rag/threads/{id}/messages` writes the turn plus a `pending` assistant row and answers `202`, then poll `GET /rag/threads/{id}/messages/{mid}` or open its `/stream` (SSE `delta`s then `done`/`error`). `503` when no AI service offers `rag.chat`, with nothing written. An answer may abstain — `abstained: true` with a `reason` (`guard_*`, `insufficient_data`, `model_abstained`) is a complete, successful turn, not an error — and carries its `citations`, up to `MAX_RAG_CITATIONS` per answer and at most `MAX_RAG_CITATION_PAGES` pages each (a service reply past either cap fails the turn whole). Each citation's corpus `doc_id` is resolved to the course-note file that owns it (`file`, `null` when no file the asker may view claims that document) beside the pages and retrieval span ids behind it. Two **study** doors are one-shot and synchronous rather than threaded: `POST /rag/summarize` returns a summary of one page/span range and `POST /rag/questions` returns a set of practice questions (plus their range-bounded answers) over one — the artifact is the answer, so nothing is stored and there is no thread or poll. Their body names only a *target within* the asker's own derived pairs (the body's `sinif` plus `ders`): a pair the caller does not hold is `403`, and omitting `sinif` for a ders taught at more than one grade is `400` — the backend never picks a corpus for the caller. Both answer `503` when no AI service offers `rag.summarize`/`rag.questions`, and an `abstained: true` reply with a `reason` is a complete `200`, exactly as on a chat turn. Each waits on its dispatch under a 25 s deadline, deliberately inside the middleware's own 30 s envelope — a dropped handler would answer with prose written for a request that may have written something."), (name = "insights", description = "ZEKA's computed student insights. The `hezarfen_zeka` AI service dials in over the same QUIC bridge as the chatbot, but it does **not** touch a school database: the backend owns every statement against the `zeka_*` tables, and the service calls the backend by name (`insight.*` capabilities on a client-initiated stream — see `src/ai/insight.rs`) to have its computed rows written and read back. So this nest reads what the service computed and asks it to compute on demand, and its write doors are the same operations the bridge serves: `POST /insights/summaries`, `/recommendations`, `/segments`, `/profiles` and `/runs` store one batch each (manager+, one call one transaction, rows about students school-wide), `GET /insights/pending` is the students the freshest run left pending, and `POST /insights/sweep` / `POST /insights/purge` are retention and graduation housekeeping — all scoped to the caller's own school by the nest's extractors, and none of them takes a school, a database or a query in its body. `GET /insights/schools` is the exception and is not this nest's usual principal: the active-school directory names every customer, so it is mounted on the **builder** principal outside the school gate (a school session answers `401`), exactly like the vendor surface's `GET /schools`. `GET /insights/me` is the caller's own view: a student's summary, their own recommendation cards and their segment profile — and **never** the attention list about themselves, which is a teacher's tool and is not returned to a student or to a linked parent. `GET /insights/students/{id}` is the observer's view of one student — teacher+ narrowed to the students they actually reach through a shared class×course instance, or a parent holding a live link — adding the attention list and the caller's own cards about that student; anyone else reads `404`, never `403`. `POST /insights/students/{id}` and `POST /insights/refresh` (manager+) queue a recompute through the bridge and answer `202` — the compute lands in the service's own rows, so a client polls the read routes; `GET /insights/runs` (manager+) is the run ledger, newest first. Both dispatch doors answer `503` when no service offers the capability, and nothing is queued. Expired and dismissed cards are filtered out of every card read, segment rows below 30 answers (`confidence: none`) are filtered out of every profile read, and a card's `about` is never returned to a student caller."), - (name = "podcast", description = "Podcast generation, relayed through the same QUIC bridge as the chatbot and the RAG nest — and the **backend owns the job**, not just the HTTP surface. `POST /podcast/jobs` (`{source_id, format?}`) resolves the note's newest `application/pdf` attachment — the blob key the dispatch hands the service as `source_key`, so the service opens `//` — refusing `409 source_missing` when the note has no PDF or its bytes are missing from this host, then mints the job id, writes the row, dispatches `podcast.submit` to the service and answers `202` with `{job_id, state, eta_secs}`; `GET /podcast/jobs/{id}` polls the backend's own row `{state, stage, progress, error_code}` with no service round trip, `GET /podcast/jobs/{id}/result` collects a finished job's `{audio_id, duration_secs, format}` (`409` while it is still running), `GET /podcast/jobs/{id}/audio` streams the episode the service uploaded into this school's own blob directory, and `POST /podcast/jobs/{id}/cancel` asks the service to stop it (`cancelled` is \"this call stopped work\", so a finished job answers `false`; a terminal job answers without the service); `GET /podcast/jobs` is the caller's own history, newest first (`?limit=&offset=`), each row carrying the title of the note it narrated. The service reports every transition back through the `podcast.report` capability and uploads the finished mp3 — so status, result and audio keep answering while the service is down or restarted, and a job nobody is updating reads as failed/interrupted after an ETA-scaled window. Submit and cancel refuse `503` when no worker is connected; none of the four read doors needs one (404 for an unknown or foreign job, 410 past the retention window, 409 before the job is done or when its blob is missing from this host)."), + (name = "podcast", description = "Podcast generation, relayed through the same QUIC bridge as the chatbot and the RAG nest — and the **backend owns the job**, not just the HTTP surface. `POST /podcast/jobs` (`{source_id, format?}`) resolves the note's newest `application/pdf` attachment — the blob key the dispatch hands the service as `source_key`, so the service opens `//` — refusing `409 source_missing` when the note has no PDF or its bytes are missing from this host, then mints the job id, writes the row, dispatches `podcast.submit` to the service and answers `202` with `{job_id, state, eta_secs}`; `GET /podcast/jobs/{id}` polls the backend's own row `{state, stage, progress, error_code}` with no service round trip, `GET /podcast/jobs/{id}/result` collects a finished job's `{audio_id, duration_secs, format, transcript}` (`409` while it is still running), `GET /podcast/jobs/{id}/audio` streams the episode the service uploaded into this school's own blob directory, and `POST /podcast/jobs/{id}/cancel` asks the service to stop it (`cancelled` is \"this call stopped work\", so a finished job answers `false`; a terminal job answers without the service); `GET /podcast/jobs` is the caller's own history, newest first (`?limit=&offset=`), each row carrying the title of the note it narrated. The service reports every transition back through the `podcast.report` capability and uploads the finished mp3 — so status, result and audio keep answering while the service is down or restarted, and a job nobody is updating reads as failed/interrupted after an ETA-scaled window. Submit and cancel refuse `503` when no worker is connected; none of the four read doors needs one (404 for an unknown or foreign job, 410 past the retention window, 409 before the job is done or when its blob is missing from this host)."), (name = "users", description = "User info: self-service profile and UI preferences (theme `light`/`dark`, language `tr`/`en`, accent color `palette_color` as `#rrggbb` — returned on every user response, `null` until chosen), name search for the pickers (any authenticated user, optionally role-filtered; a student or parent sees only the staff they may message), plus account creation (admin only: `POST /users` mints a school account outright, born with the role the caller names — `student` by default), listing, lookup, and role/profile/preferences administration (admin only). An admin never changes their own role, and the school's **last** admin cannot be demoted at all (`409`) — role management can no longer lock everyone out, not even when two admins…, accent color `palette_color` as `#rrggbb` — returned on every user response, `null` until chosen), name search for the pickers (any authenticated user, optionally role-filtered; a student or parent sees only the staff they may message), plus account creation (admin only: `POST /users` mints a school account outright, born with the role the caller names — `student` by default), listing, lookup, and role/profile/preferences administration (admin only). An admin never changes their own role, and the school's **last** admin cannot be demoted at all (`409`) — role management can no longer lock everyone out, not even when two admins demote each other at the same instant. Also the parent↔student ties: admins link students to a `parent` account under `/users/{id}/students` (link, list, unlink — a role change on either side drops its ties in the *same transaction* as the role write, so a failure mid-way leaves the old role with all its ties intact rather than a half-applied change), and a parent lists their own students at `/users/me/students`; every one of those lists is filtered to accounts that hold the `student` role **right now**, so a tie whose student was promoted out names nobody, exactly as it grants nothing; the tie grants the parent read access to those students' mark, attendance, pomodoro, and homework reports and nothing else. Every account also has a **public profile** (`GET /users/me/profile`, `GET /users/{id}/profile`): username, `display_name` (the self-chosen one, else the `name surname` join, else `null` — the very same three steps every embedded person ref resolves, so a chosen name shows school-wide; it never replaces `name`/`surname`, which stay the school-office record, and it deliberately stays out of the user search fold), role, `bio`, avatar metadata, a narrowed class/course block (id/name/grade and id/title/kind only — never a class's creator or homeroom teacher — capped at `max_profile_classes` / `max_profile_courses`, since `/classes/me` and `/courses/me` are the full paged lists), a sixteen-key `stats` block, and the badges those stats have earned. Four stats are computed at read (finished pomodoro stints and their focused milliseconds, plus the full course and class counts) and twelve are stored lifetime tallies maintained at write time, so a tally can outlive the rows behind it — a deleted exam does not un-sit it; all sixteen read `0`, never `null`. Five are the student's own work (`homework_submitted_total`, `homework_on_time_total`, `exam_sat_total` — **exams sat**, not sittings: a retake of an exam already counted moves nothing, since an `open` exam with unlimited attempts is a start/finish loop a student runs with no teacher in it —, `pomodoro_finished_total`, `pomodoro_focus_ms_total` — the last two count only stints that **counted**: at least `pomodoro.min_counted_ms` long and within that UTC day's `pomodoro.max_counted_per_day`, since a start/finish pair is two requests with nobody else in it, so `pomodoro_sessions` may legitimately run ahead of them), and seven more cover both sides of the school: `marks_given_total` (grades a teacher recorded, exam sittings and homework alike, once per pair — a regrade moves nothing, but deleting the grade gives it back, since the grader who deletes is the grader who was credited and grade → un-grade → regrade would otherwise count the same work twice), `lessons_held_total` (a session teacher's lessons, credited by the **first roll call taken at or after the lesson's own `starts_at`**, so neither a lesson scheduled and cancelled nor two hundred marked before they begin count for anything), `pool_approved_total` and `pool_published_total` (the approver's and the asker's halves of one pending→approved transition — a teacher approving their own question publishes it but earns neither, since a counter moves only when one person's work was judged by somebody else), `lessons_attended_total` (a **student** marked `present` or `late` at lesson roll call, moved back down by a correction to any other status and untouched by daily/event attendance), `high_mark_total` (the student's exam marks at or above `badges.high_mark_min`, once per sitting, given back when the mark is deleted on the same terms as the grader's — but unlike the grader's, a **regrade does move it** whenever the correction crosses the cut in either direction, since it counts marks *stored* above the line rather than first gradings, which is the only way the credit and the refund read the same value; homework marks are optional and often status-only, so they never count), and `study_streak_total` — the **longest** run of consecutive days the student finished a pomodoro stint that counted, not a sum, spelled `_total` like every other key so a client joins it to the catalog's `stat` name mechanically. Days there end at **midnight UTC**, like every other day calculation here, and the run is read as a high-water mark, so breaking it never takes a badge back. **Badges are auto-earned only** — no route awards or revokes one; a badge appears when a stored counter crosses a hardcoded threshold and is **permanent**, surviving that counter falling back (withdrawing a submission decrements the counter, never the badge), with `earned_at` pinned at the first crossing and the list ordered oldest first. Each entry is `{id, earned_at}`: labels and icons belong to the client, keyed by id, exactly as for `roles` and course `kinds`. The catalog behind the ids is `badges.catalog[]` at `GET /limits` (`{id, stat, threshold}`, 34 badges over twelve counters, `stat` being the API's name for the counter rather than the column it is stored in) alongside `badges.high_mark_min`, the exam mark the `high_mark` ladder counts from (the id alone does not say it), both compiled in, so a threshold moves only with a deploy. Contact details (`email`, `phone`, `birth_date`) are **not** part of it and keep exactly the gate they have today. Any authenticated account reads any profile — except a `parent`, who reads their own and their linked students' only, with the link *and* the target's live role re-read per call, so an unlinked or promoted-out student stops being readable at once. The courses block follows the owner's **live** role: teacher+ lists what they teach, everyone else what they are enrolled in, so a demoted ex-teacher lists enrollments and not what they created — and it is then cut to the courses the *reader* may already read at `GET /courses/{id}` (a title a reader is `403` on there must not arrive here instead), so a stranger sees an empty block while the owner and manager+ see it whole; the truncation runs after that filter. The class block is cut the same way, against the bar `GET /classes/user/{id}` holds: teacher+, a parent linked to that student, or the owner reading their own profile — every other reader (a fellow student included) gets an empty `classes` array rather than a `403`, since a class name and grade are exactly what the `/classes` routes withhold below teacher+. **Every** number in `stats` stays the owner's true total either way, not just those two — `pomodoro_focus_ms`/`pomodoro_focus_ms_total` are the same figure `GET /pomodoro/{id}` serves behind its observer gate, and `lessons_attended_total`, `homework_submitted_total`, `homework_on_time_total`, `exam_sat_total` and `high_mark_total` are magnitudes of the mark and attendance data behind that same gate (for a reader who is exactly a `teacher`, wider than the `can_manage_course`-narrowed `/marks/user/{id}` and `/attendance/user/{id}` reports). That is deliberate: they are motivational counters, a magnitude names no course, class, lesson or exam, and a per-reader figure would make one profile read differently to different people. `display_name` (≤ 50) and `bio` (≤ 500) ride the same `PATCH /users/me` / `PATCH /users/{id}/profile` pair as the rest of the personal info, `\"\"` clearing either. One avatar per account: `POST /users/me/avatar` (multipart, raster types only — no SVG, whose script can run when the bytes render inline school-wide — at most the school's `max_file_bytes` rather than a knob of its own; replacing one drops the previous picture), the bytes at `GET /users/{id}/avatar` — or `GET /users/me/avatar` for the caller's own, so a client never needs to know its own id — (same reach as the profile, served `nosniff` and `private, no-store`), removed by the owner at `DELETE /users/me/avatar` or, as moderation, by an admin at `DELETE /users/{id}/avatar`"), (name = "notes", description = "Per-user notes CRUD, plus file attachments per note (multipart upload, download, delete — at most 10 per note, each at most the school's settings-configured `max_file_bytes`). Every authenticated role keeps notes, `parent` included: a note is private own-scoped data with no other reader, and the routes carry **no role bar at all** — ownership is the whole authorization, so nobody but the owner ever reaches a note or its files (a stranger's id is a `404`, never a `403`). That is deliberate and it is the fix for a real defect: while these routes required `student`, a demotion to `parent` locked the owner out of their own notes for good, and since nothing else in the crate reads a note and no route cascades one, the rows and their on-disk blobs became unreachable and undeletable by everybody. Own-scoped personal data is not confiscated by a role change"), (name = "messages", description = "One-to-one mail-style messages, upward only below staff: a student or parent writes to a teacher, manager or admin (parents included — messaging is the one place a parent writes) and never to another student or parent (`403`), while staff write to anyone, each optionally tagged with a free-text `label` badge. Each party owns their copy independently: the recipient's moves through `inbox`/`archive`/`trash` with a read flag (visible to the sender as a read receipt), the sender's through `sent`/`archive`/`trash`. Filing a copy away records the folder it left as its `previous_folder`, so restoring it puts it back where it came from (a trashed archive copy returns to the archive, not the inbox). `GET /messages?folder=` lists one folder (`&read=false` narrows to unread — with `limit=1`, `total` is the unread badge); permanent deletion (`DELETE`) works only from the trash and removes the row once both sides have deleted"), diff --git a/src/service/podcast_job.rs b/src/service/podcast_job.rs index 5fbf298..f170449 100644 --- a/src/service/podcast_job.rs +++ b/src/service/podcast_job.rs @@ -23,6 +23,11 @@ use crate::validate::validate_required; /// service cannot write a paragraph into a column a UI renders inline. const MAX_CODE_LEN: usize = 64; +/// The most characters a report may put in `transcript`. A finished episode's +/// text is a few kilobytes; past a million characters the payload is not a +/// transcript, and it must not land in a column a result door returns whole. +const MAX_TRANSCRIPT_LEN: usize = 1_000_000; + /// Why one `podcast.report` (or an audio ingest) was refused. `code()` is the /// flat, stable, machine-readable string the bridge answers in the /// capability's `code` field — the same vocabulary the protocol's other @@ -95,6 +100,7 @@ pub struct ReportInput<'a> { pub stage: &'a str, pub progress: f64, pub error_code: Option<&'a str>, + pub transcript: Option<&'a str>, } /// Mint and store one freshly submitted job. The id is the backend's (the @@ -113,6 +119,7 @@ pub async fn create( user_id: *user, source_id: source_id.to_string(), format: format.map(str::to_string), + transcript: None, state: PodcastJobState::Queued, stage: String::new(), progress: 0.0, @@ -201,6 +208,13 @@ pub async fn report( "error_code is longer than 64 characters".to_string(), )); } + if let Some(transcript) = input.transcript + && transcript.chars().count() > MAX_TRANSCRIPT_LEN + { + return Err(PodcastRefusal::InvalidPayload(format!( + "transcript is longer than {MAX_TRANSCRIPT_LEN} characters" + ))); + } let Some(row) = podcast_job::read(db, &id).await? else { return Err(PodcastRefusal::UnknownJob); @@ -235,6 +249,10 @@ pub async fn report( if target == PodcastJobState::Done && row.get_audio_key().is_none() { return Err(PodcastRefusal::AudioMissing); } + // A progress report carries `""` (no text yet). `COALESCE` would store + // that empty string and then ignore the done report's text, so a blank + // or all-whitespace transcript is absent, not a value. + let transcript = input.transcript.filter(|text| !text.trim().is_empty()); match podcast_job::report( db, @@ -245,6 +263,7 @@ pub async fn report( input.progress, input.error_code, input.format, + transcript, ) .await? { @@ -347,3 +366,92 @@ pub async fn set_audio( ) -> Result, AppError> { podcast_job::set_audio(db, id, key, name, content_type, bytes, duration_secs).await } + +#[cfg(test)] +mod tests { + use super::*; + + /// The cap is checked before any query, so an oversized transcript never + /// reaches the row — and a missing field is not this refusal. + #[tokio::test] + async fn a_transcript_over_one_million_characters_is_refused() { + let (db, _leases) = crate::database::init_test_db().await; + let huge = "a".repeat(MAX_TRANSCRIPT_LEN + 1); + let input = ReportInput { + job_id: "019732e3-7b00-7000-8000-00000000dead", + source_id: "src", + format: None, + user_id: "00000000-0000-7000-8000-000000000000", + state: "running", + stage: "", + progress: 0.0, + error_code: None, + transcript: Some(&huge), + }; + let err = report(&db, &input).await.expect_err("over the cap"); + assert_eq!(err.code(), "invalid_payload"); + assert!( + err.message().contains("1000000"), + "names the cap: {}", + err.message() + ); + } + + /// The service sends `transcript: ""` on every report until the episode + /// is done. That blank must not fill the column, or the done text is + /// dropped by `COALESCE`. + #[tokio::test] + async fn a_blank_progress_transcript_does_not_block_the_done_text() { + let (db, _leases) = crate::database::init_test_db().await; + let user = UserId::from_key(&crate::domain::monotonic_id::next_uuid().to_string()); + sqlx::query("INSERT INTO app_user (id, username, created_at) VALUES ($1, $2, 0)") + .bind(user.uuid()) + .bind(format!("u{}", &user.key()[..8])) + .execute(&db) + .await + .expect("insert user"); + let job = create(&db, &user, "src", None).await.expect("create"); + let job_id = job.get_id().key(); + let user_id = user.key(); + let progress = ReportInput { + job_id: &job_id, + source_id: "src", + format: None, + user_id: &user_id, + state: "running", + stage: "script", + progress: 0.2, + error_code: None, + transcript: Some(""), + }; + let running = report(&db, &progress).await.expect("progress report"); + assert_eq!(running.get_state(), PodcastJobState::Running); + assert!(running.get_transcript().is_none(), "a blank transcript is absent"); + + set_audio( + &db, + job.get_id(), + "podcast/x.mp3", + "episode.mp3", + "audio/mpeg", + 12, + Some(1.5), + ) + .await + .expect("stamp audio") + .expect("row"); + let done = ReportInput { + job_id: &job_id, + source_id: "src", + format: None, + user_id: &user_id, + state: "done", + stage: "done", + progress: 1.0, + error_code: None, + transcript: Some("bolum bir\n\nbolum iki"), + }; + let finished = report(&db, &done).await.expect("done report"); + assert_eq!(finished.get_transcript(), Some("bolum bir\n\nbolum iki")); + } +} diff --git a/src/web/podcast.rs b/src/web/podcast.rs index 750ae90..328019b 100644 --- a/src/web/podcast.rs +++ b/src/web/podcast.rs @@ -135,6 +135,11 @@ struct JobArtifacts { duration_secs: Option, /// The resolved narration format. format: Option, + /// The episode transcript, chapters joined by blank lines. `null` when the + /// service that produced the episode did not report one — every job + /// finished before the column existed, and any later job whose done report + /// omitted the field. + transcript: Option, } /// The verdict on a cancel. @@ -466,6 +471,7 @@ async fn result( audio_id, duration_secs: job.get_duration_secs(), format: job.get_format().map(str::to_string), + transcript: job.get_transcript().map(str::to_string), }) .into_response()) } diff --git a/tests/ai_bridge.rs b/tests/ai_bridge.rs index 9aa42ce..0ca1ea3 100644 --- a/tests/ai_bridge.rs +++ b/tests/ai_bridge.rs @@ -4810,14 +4810,15 @@ async fn seed_podcast_job(db: &Database) -> (String, String) { } /// The row's own answers to what the tests ask of it: -/// (state, stage, progress, audio_key, duration_secs). +/// (state, stage, progress, audio_key, duration_secs, transcript). async fn podcast_row( db: &Database, job: &str, -) -> (String, String, f64, Option, Option) { +) -> (String, String, f64, Option, Option, Option) { use sqlx::Row as _; let row = sqlx::query( - "SELECT state, stage, progress, audio_key, duration_secs FROM podcast_job WHERE id = $1", + "SELECT state, stage, progress, audio_key, duration_secs, transcript \ + FROM podcast_job WHERE id = $1", ) .bind(uuid::Uuid::parse_str(job).expect("a job uuid")) .fetch_one(db) @@ -4829,6 +4830,7 @@ async fn podcast_row( row.get("progress"), row.get("audio_key"), row.get("duration_secs"), + row.get("transcript"), ) } @@ -4840,19 +4842,35 @@ fn report_call( stage: &str, progress: f64, ) -> CapabilityRequest { + report_call_with(school, job, user, state, stage, progress, None) +} + +fn report_call_with( + school: &str, + job: &str, + user: &str, + state: &str, + stage: &str, + progress: f64, + transcript: Option<&str>, +) -> CapabilityRequest { + let mut payload = json!({ + "job_id": job, + "source_id": "kaynak-1", + "format": "duz_okuma", + "user_id": user, + "state": state, + "stage": stage, + "progress": progress, + }); + if let Some(text) = transcript { + payload["transcript"] = json!(text); + } CapabilityRequest { id: format!("trace-report-{job}-{state}"), school: school.to_string(), capability: AI_PODCAST_REPORT_CAPABILITY.to_string(), - payload: json!({ - "job_id": job, - "source_id": "kaynak-1", - "format": "duz_okuma", - "user_id": user, - "state": state, - "stage": stage, - "progress": progress, - }), + payload, } } @@ -4928,6 +4946,10 @@ async fn the_report_and_upload_handshake_lands_on_the_backends_own_row() { assert_eq!(ok_capability(answer)["job_id"], job); assert_eq!(podcast_row(&db, &job).await.0, "running"); assert_eq!(podcast_row(&db, &job).await.1, "script"); + assert!( + podcast_row(&db, &job).await.5.is_none(), + "a report that omits transcript still stores, and the column stays null" + ); // `done` means a stored episode: a report that claims one before the // upload is refused, and nothing about the row moves. @@ -4977,18 +4999,29 @@ async fn the_report_and_upload_handshake_lands_on_the_backends_own_row() { assert_eq!(row.3.as_deref(), Some(key.as_str())); assert_eq!(row.4, Some(12.5)); - // Now — and only now — `done` is accepted. + // Now — and only now — `done` is accepted, and the transcript it carries + // is what the row holds. assert_eq!( ok_capability( capability_call( conn, - report_call(DEMO_SCHOOL_ID, &job, &user, "done", "done", 1.0) + report_call_with( + DEMO_SCHOOL_ID, + &job, + &user, + "done", + "done", + 1.0, + Some("bolum bir\n\nbolum iki"), + ) ) .await )["stored"], true ); - assert_eq!(podcast_row(&db, &job).await.0, "done"); + let done = podcast_row(&db, &job).await; + assert_eq!(done.0, "done"); + assert_eq!(done.5.as_deref(), Some("bolum bir\n\nbolum iki")); // And a job the backend never minted is `unknown_job`. let stranger = hezarfen_backend::domain::monotonic_id::next_uuid().to_string(); diff --git a/tests/limits_completeness.rs b/tests/limits_completeness.rs index 9868936..6e9188a 100644 --- a/tests/limits_completeness.rs +++ b/tests/limits_completeness.rs @@ -551,12 +551,20 @@ fn moved_value_tables_are_still_published_or_deliberately_excluded() { /// constant: every former entry now lives there and is excused (or published) /// through `EXCLUDED` above instead. A new name here is a claim that a bound /// belongs somewhere else, which needs an argument. -const NOT_A_CLIENT_BOUND: &[(&str, &str)] = &[( - "MAX_CODE_LEN", - "bound on the length of a podcast report's `stage`/`error_code` — values \ +const NOT_A_CLIENT_BOUND: &[(&str, &str)] = &[ + ( + "MAX_CODE_LEN", + "bound on the length of a podcast report's `stage`/`error_code` — values \ the AI *service* writes onto the job row; a browser reads the stored \ string back, it never sizes one against this", -)]; + ), + ( + "MAX_TRANSCRIPT_LEN", + "bound on a podcast report's `transcript` — the AI service writes it, \ + the result door returns the stored text; a browser never sizes a \ + transcript against this", + ), +]; #[test] fn validation_bounds_live_in_constant_rs() { diff --git a/tests/podcast.rs b/tests/podcast.rs index 92e4e63..33c0932 100644 --- a/tests/podcast.rs +++ b/tests/podcast.rs @@ -814,12 +814,10 @@ async fn a_finished_job_serves_the_uploaded_bytes() { assert_eq!(answer["key"], format!("podcast/{job_id}.mp3")); assert_eq!(answer["size"], bytes.len() as u64); + let mut done = report_frame(&job_id, ¬e, &user, "done", "", 1.0); + done["payload"]["transcript"] = json!("bolum bir\n\nbolum iki"); assert_report_stored( - &capability_call( - &service.conn, - report_frame(&job_id, ¬e, &user, "done", "", 1.0), - ) - .await, + &capability_call(&service.conn, done).await, &job_id, ); @@ -829,6 +827,7 @@ async fn a_finished_job_serves_the_uploaded_bytes() { assert_eq!(res.body["audio_id"], format!("podcast/{job_id}.mp3")); assert_eq!(res.body["duration_secs"], DURATION_SECS); assert_eq!(res.body["format"], FORMAT); + assert_eq!(res.body["transcript"], "bolum bir\n\nbolum iki"); let (status, headers, body) = audio_of(&app, &cookie, &job_id).await; assert_eq!(status, StatusCode::OK, "{:?}", String::from_utf8_lossy(&body)); @@ -1529,6 +1528,10 @@ async fn the_audio_door_reports_a_missing_blob() { let res = result_of(&app, &cookie, &job.to_string()).await; assert_eq!(res.status, StatusCode::OK, "{}", res.body); assert_eq!(res.body["audio_id"], key); + assert!( + res.body["transcript"].is_null(), + "a job finished before the column existed answers null, not an empty string" + ); let (status, _, body) = audio_of(&app, &cookie, &job.to_string()).await; assert_eq!(