forge
Explore
Log in

Don't you dare go Hollow

Persist the transcript and serve it on the result door

Browse files at this commit

64eabd41bc8eefc2152a595b96e0942baef2150aAhmet Kaan GümüşParent: f195e7a
  • feat
    • persist the transcript and serve it on the result door
Show full message
✨ feat(podcast): persist the transcript and serve it on the result door

The service's done report now carries the narration text; the backend
stores it in podcast_job.transcript (fill-once, blank means absent so a
progress report cannot stick an empty string) and returns it from
GET /podcast/jobs/{id}/result under the same owner-scoping and expiry
rules as the audio. Reports without the field keep passing, so older
service builds are unaffected.
Local-Gate: 2824ca0c3e6cf2366b8f62c09f5babe384f6e0db (1512 passed, 449s)
.sqlx/query-913496d365010822c99818a92fc901a1939d16cb7aff9023c8b7331ece7265c0.json → .sqlx/query-37c8e360c3557ede7f79c9f210984598576292ee347427e1a54441bceb88ed12.jsonrenamed+25 -13
@@ -1,6 +1,6 @@
1 {1 {
2 "db_name": "PostgreSQL",2 "db_name": "PostgreSQL",
3- "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\"",3+ "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\"",
4 "describe": {4 "describe": {
5 "columns": [5 "columns": [
6 {6 {
@@ -49,6 +49,17 @@
49 },49 },
50 {50 {
51 "ordinal": 4,51 "ordinal": 4,
52+ "name": "transcript",
53+ "type_info": "Text",
54+ "origin": {
55+ "Table": {
56+ "table": "podcast_job",
57+ "name": "transcript"
58+ }
59+ }
60+ },
61+ {
62+ "ordinal": 5,
52 "name": "state: PodcastJobState",63 "name": "state: PodcastJobState",
53 "type_info": "Text",64 "type_info": "Text",
54 "origin": {65 "origin": {
@@ -59,7 +70,7 @@
59 }70 }
60 },71 },
61 {72 {
62- "ordinal": 5,73+ "ordinal": 6,
63 "name": "stage",74 "name": "stage",
64 "type_info": "Text",75 "type_info": "Text",
65 "origin": {76 "origin": {
@@ -70,7 +81,7 @@
70 }81 }
71 },82 },
72 {83 {
73- "ordinal": 6,84+ "ordinal": 7,
74 "name": "progress",85 "name": "progress",
75 "type_info": "Float8",86 "type_info": "Float8",
76 "origin": {87 "origin": {
@@ -81,7 +92,7 @@
81 }92 }
82 },93 },
83 {94 {
84- "ordinal": 7,95+ "ordinal": 8,
85 "name": "error_code",96 "name": "error_code",
86 "type_info": "Text",97 "type_info": "Text",
87 "origin": {98 "origin": {
@@ -92,7 +103,7 @@
92 }103 }
93 },104 },
94 {105 {
95- "ordinal": 8,106+ "ordinal": 9,
96 "name": "audio_key",107 "name": "audio_key",
97 "type_info": "Text",108 "type_info": "Text",
98 "origin": {109 "origin": {
@@ -103,7 +114,7 @@
103 }114 }
104 },115 },
105 {116 {
106- "ordinal": 9,117+ "ordinal": 10,
107 "name": "audio_name",118 "name": "audio_name",
108 "type_info": "Text",119 "type_info": "Text",
109 "origin": {120 "origin": {
@@ -114,7 +125,7 @@
114 }125 }
115 },126 },
116 {127 {
117- "ordinal": 10,128+ "ordinal": 11,
118 "name": "audio_type",129 "name": "audio_type",
119 "type_info": "Text",130 "type_info": "Text",
120 "origin": {131 "origin": {
@@ -125,7 +136,7 @@
125 }136 }
126 },137 },
127 {138 {
128- "ordinal": 11,139+ "ordinal": 12,
129 "name": "audio_bytes",140 "name": "audio_bytes",
130 "type_info": "Int8",141 "type_info": "Int8",
131 "origin": {142 "origin": {
@@ -136,7 +147,7 @@
136 }147 }
137 },148 },
138 {149 {
139- "ordinal": 12,150+ "ordinal": 13,
140 "name": "duration_secs",151 "name": "duration_secs",
141 "type_info": "Float8",152 "type_info": "Float8",
142 "origin": {153 "origin": {
@@ -147,7 +158,7 @@
147 }158 }
148 },159 },
149 {160 {
150- "ordinal": 13,161+ "ordinal": 14,
151 "name": "eta_secs",162 "name": "eta_secs",
152 "type_info": "Int8",163 "type_info": "Int8",
153 "origin": {164 "origin": {
@@ -158,7 +169,7 @@
158 }169 }
159 },170 },
160 {171 {
161- "ordinal": 14,172+ "ordinal": 15,
162 "name": "created_at: Timestamp",173 "name": "created_at: Timestamp",
163 "type_info": "Int8",174 "type_info": "Int8",
164 "origin": {175 "origin": {
@@ -169,7 +180,7 @@
169 }180 }
170 },181 },
171 {182 {
172- "ordinal": 15,183+ "ordinal": 16,
173 "name": "updated_at: Timestamp",184 "name": "updated_at: Timestamp",
174 "type_info": "Int8",185 "type_info": "Int8",
175 "origin": {186 "origin": {
@@ -191,6 +202,7 @@
191 false,202 false,
192 false,203 false,
193 true,204 true,
205+ true,
194 false,206 false,
195 false,207 false,
196 false,208 false,
@@ -205,5 +217,5 @@
205 false217 false
206 ]218 ]
207 },219 },
208- "hash": "913496d365010822c99818a92fc901a1939d16cb7aff9023c8b7331ece7265c0"220+ "hash": "37c8e360c3557ede7f79c9f210984598576292ee347427e1a54441bceb88ed12"
209 }221 }
.sqlx/query-826c34848d470eb17f7a677d1ce1d6d80b9a0cad9fbba7a655104c7d1a16ea18.json → .sqlx/query-45ade92df6adc604f90c5e2111fc4bd23b8c6e901d81ca64a96bef3116ab906f.jsonrenamed+26 -13
@@ -1,6 +1,6 @@
1 {1 {
2 "db_name": "PostgreSQL",2 "db_name": "PostgreSQL",
3- "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",3+ "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",
4 "describe": {4 "describe": {
5 "columns": [5 "columns": [
6 {6 {
@@ -49,6 +49,17 @@
49 },49 },
50 {50 {
51 "ordinal": 4,51 "ordinal": 4,
52+ "name": "transcript",
53+ "type_info": "Text",
54+ "origin": {
55+ "Table": {
56+ "table": "podcast_job",
57+ "name": "transcript"
58+ }
59+ }
60+ },
61+ {
62+ "ordinal": 5,
52 "name": "state: PodcastJobState",63 "name": "state: PodcastJobState",
53 "type_info": "Text",64 "type_info": "Text",
54 "origin": {65 "origin": {
@@ -59,7 +70,7 @@
59 }70 }
60 },71 },
61 {72 {
62- "ordinal": 5,73+ "ordinal": 6,
63 "name": "stage",74 "name": "stage",
64 "type_info": "Text",75 "type_info": "Text",
65 "origin": {76 "origin": {
@@ -70,7 +81,7 @@
70 }81 }
71 },82 },
72 {83 {
73- "ordinal": 6,84+ "ordinal": 7,
74 "name": "progress",85 "name": "progress",
75 "type_info": "Float8",86 "type_info": "Float8",
76 "origin": {87 "origin": {
@@ -81,7 +92,7 @@
81 }92 }
82 },93 },
83 {94 {
84- "ordinal": 7,95+ "ordinal": 8,
85 "name": "error_code",96 "name": "error_code",
86 "type_info": "Text",97 "type_info": "Text",
87 "origin": {98 "origin": {
@@ -92,7 +103,7 @@
92 }103 }
93 },104 },
94 {105 {
95- "ordinal": 8,106+ "ordinal": 9,
96 "name": "audio_key",107 "name": "audio_key",
97 "type_info": "Text",108 "type_info": "Text",
98 "origin": {109 "origin": {
@@ -103,7 +114,7 @@
103 }114 }
104 },115 },
105 {116 {
106- "ordinal": 9,117+ "ordinal": 10,
107 "name": "audio_name",118 "name": "audio_name",
108 "type_info": "Text",119 "type_info": "Text",
109 "origin": {120 "origin": {
@@ -114,7 +125,7 @@
114 }125 }
115 },126 },
116 {127 {
117- "ordinal": 10,128+ "ordinal": 11,
118 "name": "audio_type",129 "name": "audio_type",
119 "type_info": "Text",130 "type_info": "Text",
120 "origin": {131 "origin": {
@@ -125,7 +136,7 @@
125 }136 }
126 },137 },
127 {138 {
128- "ordinal": 11,139+ "ordinal": 12,
129 "name": "audio_bytes",140 "name": "audio_bytes",
130 "type_info": "Int8",141 "type_info": "Int8",
131 "origin": {142 "origin": {
@@ -136,7 +147,7 @@
136 }147 }
137 },148 },
138 {149 {
139- "ordinal": 12,150+ "ordinal": 13,
140 "name": "duration_secs",151 "name": "duration_secs",
141 "type_info": "Float8",152 "type_info": "Float8",
142 "origin": {153 "origin": {
@@ -147,7 +158,7 @@
147 }158 }
148 },159 },
149 {160 {
150- "ordinal": 13,161+ "ordinal": 14,
151 "name": "eta_secs",162 "name": "eta_secs",
152 "type_info": "Int8",163 "type_info": "Int8",
153 "origin": {164 "origin": {
@@ -158,7 +169,7 @@
158 }169 }
159 },170 },
160 {171 {
161- "ordinal": 14,172+ "ordinal": 15,
162 "name": "created_at: Timestamp",173 "name": "created_at: Timestamp",
163 "type_info": "Int8",174 "type_info": "Int8",
164 "origin": {175 "origin": {
@@ -169,7 +180,7 @@
169 }180 }
170 },181 },
171 {182 {
172- "ordinal": 15,183+ "ordinal": 16,
173 "name": "updated_at: Timestamp",184 "name": "updated_at: Timestamp",
174 "type_info": "Int8",185 "type_info": "Int8",
175 "origin": {186 "origin": {
@@ -182,6 +193,7 @@
182 ],193 ],
183 "parameters": {194 "parameters": {
184 "Left": [195 "Left": [
196+ "Uuid",
185 "Uuid"197 "Uuid"
186 ]198 ]
187 },199 },
@@ -190,6 +202,7 @@
190 false,202 false,
191 false,203 false,
192 true,204 true,
205+ true,
193 false,206 false,
194 false,207 false,
195 false,208 false,
@@ -204,5 +217,5 @@
204 false217 false
205 ]218 ]
206 },219 },
207- "hash": "826c34848d470eb17f7a677d1ce1d6d80b9a0cad9fbba7a655104c7d1a16ea18"220+ "hash": "45ade92df6adc604f90c5e2111fc4bd23b8c6e901d81ca64a96bef3116ab906f"
208 }221 }
.sqlx/query-ad5b90d0407d3abf9a3bdf119146041a67a486a5560fa151ad8fe8210bfd9d53.json → .sqlx/query-4b05eec4ece0295d6be7ce2b92238e49fabe71d62b021c1d1425e51d9f1adbe3.jsonrenamed+25 -13
@@ -1,6 +1,6 @@
1 {1 {
2 "db_name": "PostgreSQL",2 "db_name": "PostgreSQL",
3- "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\"",3+ "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\"",
4 "describe": {4 "describe": {
5 "columns": [5 "columns": [
6 {6 {
@@ -49,6 +49,17 @@
49 },49 },
50 {50 {
51 "ordinal": 4,51 "ordinal": 4,
52+ "name": "transcript",
53+ "type_info": "Text",
54+ "origin": {
55+ "Table": {
56+ "table": "podcast_job",
57+ "name": "transcript"
58+ }
59+ }
60+ },
61+ {
62+ "ordinal": 5,
52 "name": "state: PodcastJobState",63 "name": "state: PodcastJobState",
53 "type_info": "Text",64 "type_info": "Text",
54 "origin": {65 "origin": {
@@ -59,7 +70,7 @@
59 }70 }
60 },71 },
61 {72 {
62- "ordinal": 5,73+ "ordinal": 6,
63 "name": "stage",74 "name": "stage",
64 "type_info": "Text",75 "type_info": "Text",
65 "origin": {76 "origin": {
@@ -70,7 +81,7 @@
70 }81 }
71 },82 },
72 {83 {
73- "ordinal": 6,84+ "ordinal": 7,
74 "name": "progress",85 "name": "progress",
75 "type_info": "Float8",86 "type_info": "Float8",
76 "origin": {87 "origin": {
@@ -81,7 +92,7 @@
81 }92 }
82 },93 },
83 {94 {
84- "ordinal": 7,95+ "ordinal": 8,
85 "name": "error_code",96 "name": "error_code",
86 "type_info": "Text",97 "type_info": "Text",
87 "origin": {98 "origin": {
@@ -92,7 +103,7 @@
92 }103 }
93 },104 },
94 {105 {
95- "ordinal": 8,106+ "ordinal": 9,
96 "name": "audio_key",107 "name": "audio_key",
97 "type_info": "Text",108 "type_info": "Text",
98 "origin": {109 "origin": {
@@ -103,7 +114,7 @@
103 }114 }
104 },115 },
105 {116 {
106- "ordinal": 9,117+ "ordinal": 10,
107 "name": "audio_name",118 "name": "audio_name",
108 "type_info": "Text",119 "type_info": "Text",
109 "origin": {120 "origin": {
@@ -114,7 +125,7 @@
114 }125 }
115 },126 },
116 {127 {
117- "ordinal": 10,128+ "ordinal": 11,
118 "name": "audio_type",129 "name": "audio_type",
119 "type_info": "Text",130 "type_info": "Text",
120 "origin": {131 "origin": {
@@ -125,7 +136,7 @@
125 }136 }
126 },137 },
127 {138 {
128- "ordinal": 11,139+ "ordinal": 12,
129 "name": "audio_bytes",140 "name": "audio_bytes",
130 "type_info": "Int8",141 "type_info": "Int8",
131 "origin": {142 "origin": {
@@ -136,7 +147,7 @@
136 }147 }
137 },148 },
138 {149 {
139- "ordinal": 12,150+ "ordinal": 13,
140 "name": "duration_secs",151 "name": "duration_secs",
141 "type_info": "Float8",152 "type_info": "Float8",
142 "origin": {153 "origin": {
@@ -147,7 +158,7 @@
147 }158 }
148 },159 },
149 {160 {
150- "ordinal": 13,161+ "ordinal": 14,
151 "name": "eta_secs",162 "name": "eta_secs",
152 "type_info": "Int8",163 "type_info": "Int8",
153 "origin": {164 "origin": {
@@ -158,7 +169,7 @@
158 }169 }
159 },170 },
160 {171 {
161- "ordinal": 14,172+ "ordinal": 15,
162 "name": "created_at: Timestamp",173 "name": "created_at: Timestamp",
163 "type_info": "Int8",174 "type_info": "Int8",
164 "origin": {175 "origin": {
@@ -169,7 +180,7 @@
169 }180 }
170 },181 },
171 {182 {
172- "ordinal": 15,183+ "ordinal": 16,
173 "name": "updated_at: Timestamp",184 "name": "updated_at: Timestamp",
174 "type_info": "Int8",185 "type_info": "Int8",
175 "origin": {186 "origin": {
@@ -191,6 +202,7 @@
191 false,202 false,
192 false,203 false,
193 true,204 true,
205+ true,
194 false,206 false,
195 false,207 false,
196 false,208 false,
@@ -205,5 +217,5 @@
205 false217 false
206 ]218 ]
207 },219 },
208- "hash": "ad5b90d0407d3abf9a3bdf119146041a67a486a5560fa151ad8fe8210bfd9d53"220+ "hash": "4b05eec4ece0295d6be7ce2b92238e49fabe71d62b021c1d1425e51d9f1adbe3"
209 }221 }
.sqlx/query-00e4b6eca87d0ab5012f3d0562bf749302b7824859737c780efb433e972af5e4.json → .sqlx/query-814486dbb11e8eeaf410bced5a0aae724aa3f0198ce4204cd94016b827ab55b7.jsonrenamed+25 -13
@@ -1,6 +1,6 @@
1 {1 {
2 "db_name": "PostgreSQL",2 "db_name": "PostgreSQL",
3- "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\"",3+ "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\"",
4 "describe": {4 "describe": {
5 "columns": [5 "columns": [
6 {6 {
@@ -49,6 +49,17 @@
49 },49 },
50 {50 {
51 "ordinal": 4,51 "ordinal": 4,
52+ "name": "transcript",
53+ "type_info": "Text",
54+ "origin": {
55+ "Table": {
56+ "table": "podcast_job",
57+ "name": "transcript"
58+ }
59+ }
60+ },
61+ {
62+ "ordinal": 5,
52 "name": "state: PodcastJobState",63 "name": "state: PodcastJobState",
53 "type_info": "Text",64 "type_info": "Text",
54 "origin": {65 "origin": {
@@ -59,7 +70,7 @@
59 }70 }
60 },71 },
61 {72 {
62- "ordinal": 5,73+ "ordinal": 6,
63 "name": "stage",74 "name": "stage",
64 "type_info": "Text",75 "type_info": "Text",
65 "origin": {76 "origin": {
@@ -70,7 +81,7 @@
70 }81 }
71 },82 },
72 {83 {
73- "ordinal": 6,84+ "ordinal": 7,
74 "name": "progress",85 "name": "progress",
75 "type_info": "Float8",86 "type_info": "Float8",
76 "origin": {87 "origin": {
@@ -81,7 +92,7 @@
81 }92 }
82 },93 },
83 {94 {
84- "ordinal": 7,95+ "ordinal": 8,
85 "name": "error_code",96 "name": "error_code",
86 "type_info": "Text",97 "type_info": "Text",
87 "origin": {98 "origin": {
@@ -92,7 +103,7 @@
92 }103 }
93 },104 },
94 {105 {
95- "ordinal": 8,106+ "ordinal": 9,
96 "name": "audio_key",107 "name": "audio_key",
97 "type_info": "Text",108 "type_info": "Text",
98 "origin": {109 "origin": {
@@ -103,7 +114,7 @@
103 }114 }
104 },115 },
105 {116 {
106- "ordinal": 9,117+ "ordinal": 10,
107 "name": "audio_name",118 "name": "audio_name",
108 "type_info": "Text",119 "type_info": "Text",
109 "origin": {120 "origin": {
@@ -114,7 +125,7 @@
114 }125 }
115 },126 },
116 {127 {
117- "ordinal": 10,128+ "ordinal": 11,
118 "name": "audio_type",129 "name": "audio_type",
119 "type_info": "Text",130 "type_info": "Text",
120 "origin": {131 "origin": {
@@ -125,7 +136,7 @@
125 }136 }
126 },137 },
127 {138 {
128- "ordinal": 11,139+ "ordinal": 12,
129 "name": "audio_bytes",140 "name": "audio_bytes",
130 "type_info": "Int8",141 "type_info": "Int8",
131 "origin": {142 "origin": {
@@ -136,7 +147,7 @@
136 }147 }
137 },148 },
138 {149 {
139- "ordinal": 12,150+ "ordinal": 13,
140 "name": "duration_secs",151 "name": "duration_secs",
141 "type_info": "Float8",152 "type_info": "Float8",
142 "origin": {153 "origin": {
@@ -147,7 +158,7 @@
147 }158 }
148 },159 },
149 {160 {
150- "ordinal": 13,161+ "ordinal": 14,
151 "name": "eta_secs",162 "name": "eta_secs",
152 "type_info": "Int8",163 "type_info": "Int8",
153 "origin": {164 "origin": {
@@ -158,7 +169,7 @@
158 }169 }
159 },170 },
160 {171 {
161- "ordinal": 14,172+ "ordinal": 15,
162 "name": "created_at: Timestamp",173 "name": "created_at: Timestamp",
163 "type_info": "Int8",174 "type_info": "Int8",
164 "origin": {175 "origin": {
@@ -169,7 +180,7 @@
169 }180 }
170 },181 },
171 {182 {
172- "ordinal": 15,183+ "ordinal": 16,
173 "name": "updated_at: Timestamp",184 "name": "updated_at: Timestamp",
174 "type_info": "Int8",185 "type_info": "Int8",
175 "origin": {186 "origin": {
@@ -192,6 +203,7 @@
192 false,203 false,
193 false,204 false,
194 true,205 true,
206+ true,
195 false,207 false,
196 false,208 false,
197 false,209 false,
@@ -206,5 +218,5 @@
206 false218 false
207 ]219 ]
208 },220 },
209- "hash": "00e4b6eca87d0ab5012f3d0562bf749302b7824859737c780efb433e972af5e4"221+ "hash": "814486dbb11e8eeaf410bced5a0aae724aa3f0198ce4204cd94016b827ab55b7"
210 }222 }
.sqlx/query-f1a079e6c5978b7d9458172705e0c66f070d71e3435dc8f359d09675c5fcccdc.json → .sqlx/query-b3044b692a7cca8eb27c9060462465df513a477b6f67329ea555ed41c87919d0.jsonrenamed+25 -13
@@ -1,6 +1,6 @@
1 {1 {
2 "db_name": "PostgreSQL",2 "db_name": "PostgreSQL",
3- "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\"",3+ "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\"",
4 "describe": {4 "describe": {
5 "columns": [5 "columns": [
6 {6 {
@@ -49,6 +49,17 @@
49 },49 },
50 {50 {
51 "ordinal": 4,51 "ordinal": 4,
52+ "name": "transcript",
53+ "type_info": "Text",
54+ "origin": {
55+ "Table": {
56+ "table": "podcast_job",
57+ "name": "transcript"
58+ }
59+ }
60+ },
61+ {
62+ "ordinal": 5,
52 "name": "state: PodcastJobState",63 "name": "state: PodcastJobState",
53 "type_info": "Text",64 "type_info": "Text",
54 "origin": {65 "origin": {
@@ -59,7 +70,7 @@
59 }70 }
60 },71 },
61 {72 {
62- "ordinal": 5,73+ "ordinal": 6,
63 "name": "stage",74 "name": "stage",
64 "type_info": "Text",75 "type_info": "Text",
65 "origin": {76 "origin": {
@@ -70,7 +81,7 @@
70 }81 }
71 },82 },
72 {83 {
73- "ordinal": 6,84+ "ordinal": 7,
74 "name": "progress",85 "name": "progress",
75 "type_info": "Float8",86 "type_info": "Float8",
76 "origin": {87 "origin": {
@@ -81,7 +92,7 @@
81 }92 }
82 },93 },
83 {94 {
84- "ordinal": 7,95+ "ordinal": 8,
85 "name": "error_code",96 "name": "error_code",
86 "type_info": "Text",97 "type_info": "Text",
87 "origin": {98 "origin": {
@@ -92,7 +103,7 @@
92 }103 }
93 },104 },
94 {105 {
95- "ordinal": 8,106+ "ordinal": 9,
96 "name": "audio_key",107 "name": "audio_key",
97 "type_info": "Text",108 "type_info": "Text",
98 "origin": {109 "origin": {
@@ -103,7 +114,7 @@
103 }114 }
104 },115 },
105 {116 {
106- "ordinal": 9,117+ "ordinal": 10,
107 "name": "audio_name",118 "name": "audio_name",
108 "type_info": "Text",119 "type_info": "Text",
109 "origin": {120 "origin": {
@@ -114,7 +125,7 @@
114 }125 }
115 },126 },
116 {127 {
117- "ordinal": 10,128+ "ordinal": 11,
118 "name": "audio_type",129 "name": "audio_type",
119 "type_info": "Text",130 "type_info": "Text",
120 "origin": {131 "origin": {
@@ -125,7 +136,7 @@
125 }136 }
126 },137 },
127 {138 {
128- "ordinal": 11,139+ "ordinal": 12,
129 "name": "audio_bytes",140 "name": "audio_bytes",
130 "type_info": "Int8",141 "type_info": "Int8",
131 "origin": {142 "origin": {
@@ -136,7 +147,7 @@
136 }147 }
137 },148 },
138 {149 {
139- "ordinal": 12,150+ "ordinal": 13,
140 "name": "duration_secs",151 "name": "duration_secs",
141 "type_info": "Float8",152 "type_info": "Float8",
142 "origin": {153 "origin": {
@@ -147,7 +158,7 @@
147 }158 }
148 },159 },
149 {160 {
150- "ordinal": 13,161+ "ordinal": 14,
151 "name": "eta_secs",162 "name": "eta_secs",
152 "type_info": "Int8",163 "type_info": "Int8",
153 "origin": {164 "origin": {
@@ -158,7 +169,7 @@
158 }169 }
159 },170 },
160 {171 {
161- "ordinal": 14,172+ "ordinal": 15,
162 "name": "created_at: Timestamp",173 "name": "created_at: Timestamp",
163 "type_info": "Int8",174 "type_info": "Int8",
164 "origin": {175 "origin": {
@@ -169,7 +180,7 @@
169 }180 }
170 },181 },
171 {182 {
172- "ordinal": 15,183+ "ordinal": 16,
173 "name": "updated_at: Timestamp",184 "name": "updated_at: Timestamp",
174 "type_info": "Int8",185 "type_info": "Int8",
175 "origin": {186 "origin": {
@@ -196,6 +207,7 @@
196 false,207 false,
197 false,208 false,
198 true,209 true,
210+ true,
199 false,211 false,
200 false,212 false,
201 false,213 false,
@@ -210,5 +222,5 @@
210 false222 false
211 ]223 ]
212 },224 },
213- "hash": "f1a079e6c5978b7d9458172705e0c66f070d71e3435dc8f359d09675c5fcccdc"225+ "hash": "b3044b692a7cca8eb27c9060462465df513a477b6f67329ea555ed41c87919d0"
214 }226 }
.sqlx/query-636b29289a1fc139ca239ddae85bdd59d39b5f90fb69e27cf6acb616cd3c8101.json → .sqlx/query-cabbdce4f24ffcd7792dc8b9b9f72d02d920bf9fabc10c61584b0bd64c7712ff.jsonrenamed+25 -13
@@ -1,6 +1,6 @@
1 {1 {
2 "db_name": "PostgreSQL",2 "db_name": "PostgreSQL",
3- "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\"",3+ "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\"",
4 "describe": {4 "describe": {
5 "columns": [5 "columns": [
6 {6 {
@@ -49,6 +49,17 @@
49 },49 },
50 {50 {
51 "ordinal": 4,51 "ordinal": 4,
52+ "name": "transcript",
53+ "type_info": "Text",
54+ "origin": {
55+ "Table": {
56+ "table": "podcast_job",
57+ "name": "transcript"
58+ }
59+ }
60+ },
61+ {
62+ "ordinal": 5,
52 "name": "state: PodcastJobState",63 "name": "state: PodcastJobState",
53 "type_info": "Text",64 "type_info": "Text",
54 "origin": {65 "origin": {
@@ -59,7 +70,7 @@
59 }70 }
60 },71 },
61 {72 {
62- "ordinal": 5,73+ "ordinal": 6,
63 "name": "stage",74 "name": "stage",
64 "type_info": "Text",75 "type_info": "Text",
65 "origin": {76 "origin": {
@@ -70,7 +81,7 @@
70 }81 }
71 },82 },
72 {83 {
73- "ordinal": 6,84+ "ordinal": 7,
74 "name": "progress",85 "name": "progress",
75 "type_info": "Float8",86 "type_info": "Float8",
76 "origin": {87 "origin": {
@@ -81,7 +92,7 @@
81 }92 }
82 },93 },
83 {94 {
84- "ordinal": 7,95+ "ordinal": 8,
85 "name": "error_code",96 "name": "error_code",
86 "type_info": "Text",97 "type_info": "Text",
87 "origin": {98 "origin": {
@@ -92,7 +103,7 @@
92 }103 }
93 },104 },
94 {105 {
95- "ordinal": 8,106+ "ordinal": 9,
96 "name": "audio_key",107 "name": "audio_key",
97 "type_info": "Text",108 "type_info": "Text",
98 "origin": {109 "origin": {
@@ -103,7 +114,7 @@
103 }114 }
104 },115 },
105 {116 {
106- "ordinal": 9,117+ "ordinal": 10,
107 "name": "audio_name",118 "name": "audio_name",
108 "type_info": "Text",119 "type_info": "Text",
109 "origin": {120 "origin": {
@@ -114,7 +125,7 @@
114 }125 }
115 },126 },
116 {127 {
117- "ordinal": 10,128+ "ordinal": 11,
118 "name": "audio_type",129 "name": "audio_type",
119 "type_info": "Text",130 "type_info": "Text",
120 "origin": {131 "origin": {
@@ -125,7 +136,7 @@
125 }136 }
126 },137 },
127 {138 {
128- "ordinal": 11,139+ "ordinal": 12,
129 "name": "audio_bytes",140 "name": "audio_bytes",
130 "type_info": "Int8",141 "type_info": "Int8",
131 "origin": {142 "origin": {
@@ -136,7 +147,7 @@
136 }147 }
137 },148 },
138 {149 {
139- "ordinal": 12,150+ "ordinal": 13,
140 "name": "duration_secs",151 "name": "duration_secs",
141 "type_info": "Float8",152 "type_info": "Float8",
142 "origin": {153 "origin": {
@@ -147,7 +158,7 @@
147 }158 }
148 },159 },
149 {160 {
150- "ordinal": 13,161+ "ordinal": 14,
151 "name": "eta_secs",162 "name": "eta_secs",
152 "type_info": "Int8",163 "type_info": "Int8",
153 "origin": {164 "origin": {
@@ -158,7 +169,7 @@
158 }169 }
159 },170 },
160 {171 {
161- "ordinal": 14,172+ "ordinal": 15,
162 "name": "created_at: Timestamp",173 "name": "created_at: Timestamp",
163 "type_info": "Int8",174 "type_info": "Int8",
164 "origin": {175 "origin": {
@@ -169,7 +180,7 @@
169 }180 }
170 },181 },
171 {182 {
172- "ordinal": 15,183+ "ordinal": 16,
173 "name": "updated_at: Timestamp",184 "name": "updated_at: Timestamp",
174 "type_info": "Int8",185 "type_info": "Int8",
175 "origin": {186 "origin": {
@@ -204,6 +215,7 @@
204 false,215 false,
205 false,216 false,
206 true,217 true,
218+ true,
207 false,219 false,
208 false,220 false,
209 false,221 false,
@@ -218,5 +230,5 @@
218 false230 false
219 ]231 ]
220 },232 },
221- "hash": "636b29289a1fc139ca239ddae85bdd59d39b5f90fb69e27cf6acb616cd3c8101"233+ "hash": "cabbdce4f24ffcd7792dc8b9b9f72d02d920bf9fabc10c61584b0bd64c7712ff"
222 }234 }
.sqlx/query-91c968305e53e61df2c67fdaeea78150a1e8c7f19991e21b45272785cd2e4055.json → .sqlx/query-d1b16c756ea05fe53f875c57b4d46dfdc152943eb31d5df4c531af6da3e6ec7b.jsonrenamed+25 -14
@@ -1,6 +1,6 @@
1 {1 {
2 "db_name": "PostgreSQL",2 "db_name": "PostgreSQL",
3- "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",3+ "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",
4 "describe": {4 "describe": {
5 "columns": [5 "columns": [
6 {6 {
@@ -49,6 +49,17 @@
49 },49 },
50 {50 {
51 "ordinal": 4,51 "ordinal": 4,
52+ "name": "transcript",
53+ "type_info": "Text",
54+ "origin": {
55+ "Table": {
56+ "table": "podcast_job",
57+ "name": "transcript"
58+ }
59+ }
60+ },
61+ {
62+ "ordinal": 5,
52 "name": "state: PodcastJobState",63 "name": "state: PodcastJobState",
53 "type_info": "Text",64 "type_info": "Text",
54 "origin": {65 "origin": {
@@ -59,7 +70,7 @@
59 }70 }
60 },71 },
61 {72 {
62- "ordinal": 5,73+ "ordinal": 6,
63 "name": "stage",74 "name": "stage",
64 "type_info": "Text",75 "type_info": "Text",
65 "origin": {76 "origin": {
@@ -70,7 +81,7 @@
70 }81 }
71 },82 },
72 {83 {
73- "ordinal": 6,84+ "ordinal": 7,
74 "name": "progress",85 "name": "progress",
75 "type_info": "Float8",86 "type_info": "Float8",
76 "origin": {87 "origin": {
@@ -81,7 +92,7 @@
81 }92 }
82 },93 },
83 {94 {
84- "ordinal": 7,95+ "ordinal": 8,
85 "name": "error_code",96 "name": "error_code",
86 "type_info": "Text",97 "type_info": "Text",
87 "origin": {98 "origin": {
@@ -92,7 +103,7 @@
92 }103 }
93 },104 },
94 {105 {
95- "ordinal": 8,106+ "ordinal": 9,
96 "name": "audio_key",107 "name": "audio_key",
97 "type_info": "Text",108 "type_info": "Text",
98 "origin": {109 "origin": {
@@ -103,7 +114,7 @@
103 }114 }
104 },115 },
105 {116 {
106- "ordinal": 9,117+ "ordinal": 10,
107 "name": "audio_name",118 "name": "audio_name",
108 "type_info": "Text",119 "type_info": "Text",
109 "origin": {120 "origin": {
@@ -114,7 +125,7 @@
114 }125 }
115 },126 },
116 {127 {
117- "ordinal": 10,128+ "ordinal": 11,
118 "name": "audio_type",129 "name": "audio_type",
119 "type_info": "Text",130 "type_info": "Text",
120 "origin": {131 "origin": {
@@ -125,7 +136,7 @@
125 }136 }
126 },137 },
127 {138 {
128- "ordinal": 11,139+ "ordinal": 12,
129 "name": "audio_bytes",140 "name": "audio_bytes",
130 "type_info": "Int8",141 "type_info": "Int8",
131 "origin": {142 "origin": {
@@ -136,7 +147,7 @@
136 }147 }
137 },148 },
138 {149 {
139- "ordinal": 12,150+ "ordinal": 13,
140 "name": "duration_secs",151 "name": "duration_secs",
141 "type_info": "Float8",152 "type_info": "Float8",
142 "origin": {153 "origin": {
@@ -147,7 +158,7 @@
147 }158 }
148 },159 },
149 {160 {
150- "ordinal": 13,161+ "ordinal": 14,
151 "name": "eta_secs",162 "name": "eta_secs",
152 "type_info": "Int8",163 "type_info": "Int8",
153 "origin": {164 "origin": {
@@ -158,7 +169,7 @@
158 }169 }
159 },170 },
160 {171 {
161- "ordinal": 14,172+ "ordinal": 15,
162 "name": "created_at: Timestamp",173 "name": "created_at: Timestamp",
163 "type_info": "Int8",174 "type_info": "Int8",
164 "origin": {175 "origin": {
@@ -169,7 +180,7 @@
169 }180 }
170 },181 },
171 {182 {
172- "ordinal": 15,183+ "ordinal": 16,
173 "name": "updated_at: Timestamp",184 "name": "updated_at: Timestamp",
174 "type_info": "Int8",185 "type_info": "Int8",
175 "origin": {186 "origin": {
@@ -182,7 +193,6 @@
182 ],193 ],
183 "parameters": {194 "parameters": {
184 "Left": [195 "Left": [
185- "Uuid",
186 "Uuid"196 "Uuid"
187 ]197 ]
188 },198 },
@@ -191,6 +201,7 @@
191 false,201 false,
192 false,202 false,
193 true,203 true,
204+ true,
194 false,205 false,
195 false,206 false,
196 false,207 false,
@@ -205,5 +216,5 @@
205 false216 false
206 ]217 ]
207 },218 },
208- "hash": "91c968305e53e61df2c67fdaeea78150a1e8c7f19991e21b45272785cd2e4055"219+ "hash": "d1b16c756ea05fe53f875c57b4d46dfdc152943eb31d5df4c531af6da3e6ec7b"
209 }220 }
.sqlx/query-e3c904f558317d2d0c709f4b6bb3c2109bc86448a3dc6895c5bf2a9c0c99cc98.json → .sqlx/query-f40008ce74997412bd8099f21cc58579d2c6efc73d04072849fe650a737e7a4c.jsonrenamed+26 -13
@@ -1,6 +1,6 @@
1 {1 {
2 "db_name": "PostgreSQL",2 "db_name": "PostgreSQL",
3- "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\"",3+ "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\"",
4 "describe": {4 "describe": {
5 "columns": [5 "columns": [
6 {6 {
@@ -49,6 +49,17 @@
49 },49 },
50 {50 {
51 "ordinal": 4,51 "ordinal": 4,
52+ "name": "transcript",
53+ "type_info": "Text",
54+ "origin": {
55+ "Table": {
56+ "table": "podcast_job",
57+ "name": "transcript"
58+ }
59+ }
60+ },
61+ {
62+ "ordinal": 5,
52 "name": "state: PodcastJobState",63 "name": "state: PodcastJobState",
53 "type_info": "Text",64 "type_info": "Text",
54 "origin": {65 "origin": {
@@ -59,7 +70,7 @@
59 }70 }
60 },71 },
61 {72 {
62- "ordinal": 5,73+ "ordinal": 6,
63 "name": "stage",74 "name": "stage",
64 "type_info": "Text",75 "type_info": "Text",
65 "origin": {76 "origin": {
@@ -70,7 +81,7 @@
70 }81 }
71 },82 },
72 {83 {
73- "ordinal": 6,84+ "ordinal": 7,
74 "name": "progress",85 "name": "progress",
75 "type_info": "Float8",86 "type_info": "Float8",
76 "origin": {87 "origin": {
@@ -81,7 +92,7 @@
81 }92 }
82 },93 },
83 {94 {
84- "ordinal": 7,95+ "ordinal": 8,
85 "name": "error_code",96 "name": "error_code",
86 "type_info": "Text",97 "type_info": "Text",
87 "origin": {98 "origin": {
@@ -92,7 +103,7 @@
92 }103 }
93 },104 },
94 {105 {
95- "ordinal": 8,106+ "ordinal": 9,
96 "name": "audio_key",107 "name": "audio_key",
97 "type_info": "Text",108 "type_info": "Text",
98 "origin": {109 "origin": {
@@ -103,7 +114,7 @@
103 }114 }
104 },115 },
105 {116 {
106- "ordinal": 9,117+ "ordinal": 10,
107 "name": "audio_name",118 "name": "audio_name",
108 "type_info": "Text",119 "type_info": "Text",
109 "origin": {120 "origin": {
@@ -114,7 +125,7 @@
114 }125 }
115 },126 },
116 {127 {
117- "ordinal": 10,128+ "ordinal": 11,
118 "name": "audio_type",129 "name": "audio_type",
119 "type_info": "Text",130 "type_info": "Text",
120 "origin": {131 "origin": {
@@ -125,7 +136,7 @@
125 }136 }
126 },137 },
127 {138 {
128- "ordinal": 11,139+ "ordinal": 12,
129 "name": "audio_bytes",140 "name": "audio_bytes",
130 "type_info": "Int8",141 "type_info": "Int8",
131 "origin": {142 "origin": {
@@ -136,7 +147,7 @@
136 }147 }
137 },148 },
138 {149 {
139- "ordinal": 12,150+ "ordinal": 13,
140 "name": "duration_secs",151 "name": "duration_secs",
141 "type_info": "Float8",152 "type_info": "Float8",
142 "origin": {153 "origin": {
@@ -147,7 +158,7 @@
147 }158 }
148 },159 },
149 {160 {
150- "ordinal": 13,161+ "ordinal": 14,
151 "name": "eta_secs",162 "name": "eta_secs",
152 "type_info": "Int8",163 "type_info": "Int8",
153 "origin": {164 "origin": {
@@ -158,7 +169,7 @@
158 }169 }
159 },170 },
160 {171 {
161- "ordinal": 14,172+ "ordinal": 15,
162 "name": "created_at: Timestamp",173 "name": "created_at: Timestamp",
163 "type_info": "Int8",174 "type_info": "Int8",
164 "origin": {175 "origin": {
@@ -169,7 +180,7 @@
169 }180 }
170 },181 },
171 {182 {
172- "ordinal": 15,183+ "ordinal": 16,
173 "name": "updated_at: Timestamp",184 "name": "updated_at: Timestamp",
174 "type_info": "Int8",185 "type_info": "Int8",
175 "origin": {186 "origin": {
@@ -189,6 +200,7 @@
189 "Float8",200 "Float8",
190 "Text",201 "Text",
191 "Text",202 "Text",
203+ "Text",
192 "Int8"204 "Int8"
193 ]205 ]
194 },206 },
@@ -197,6 +209,7 @@
197 false,209 false,
198 false,210 false,
199 true,211 true,
212+ true,
200 false,213 false,
201 false,214 false,
202 false,215 false,
@@ -211,5 +224,5 @@
211 false224 false
212 ]225 ]
213 },226 },
214- "hash": "e3c904f558317d2d0c709f4b6bb3c2109bc86448a3dc6895c5bf2a9c0c99cc98"227+ "hash": "f40008ce74997412bd8099f21cc58579d2c6efc73d04072849fe650a737e7a4c"
215 }228 }
migrations/school/20260923000001_podcast_transcript.sqladded+10 -0
@@ -0,0 +1,10 @@
1+-- The episode transcript, as the service reported it on `podcast.report`:
2+-- one TEXT blob, chapters already joined with blank lines.
3+--
4+-- WHERE THIS FILE BELONGS: `migrations/school/` in the backend repo. APPEND-ONLY
5+-- relative to the existing school migrations: one new nullable column, no
6+-- backfill. A job finished before this column existed stays NULL, and a report
7+-- that omits the field (a service that has not learned it yet) leaves it NULL.
8+-- The report statement fills it once (`COALESCE`), the same way `format` is
9+-- filled, and never rewrites a value that already landed.
10+ALTER TABLE podcast_job ADD COLUMN transcript TEXT NULL;
src/ai/podcast.rsmodified+9 -1
@@ -114,6 +114,12 @@ pub struct PodcastReportPayload {
114 pub progress: f64,114 pub progress: f64,
115 #[serde(default)]115 #[serde(default)]
116 pub error_code: Option<String>,116 pub error_code: Option<String>,
117+ /// The finished episode's transcript: one text blob, chapters already
118+ /// joined with blank lines. Absent on a report that is not `done`, and on
119+ /// a service that has not learned the field yet — `#[serde(default)]`
120+ /// keeps that older payload valid.
121+ #[serde(default)]
122+ pub transcript: Option<String>,
117 }123 }
118 124
119 /// The answer to one report. `stored` is always `true` on an `Ok` — an125 /// The answer to one report. `stored` is always `true` on an `Ok` — an
@@ -148,7 +154,8 @@ pub async fn cancel(
148 ///154 ///
149 /// The decode is deliberately strict: a payload that does not fit155 /// The decode is deliberately strict: a payload that does not fit
150 /// [`PodcastReportPayload`] is `invalid_payload`, never coerced into a156 /// [`PodcastReportPayload`] is `invalid_payload`, never coerced into a
151-/// half-filled report.157+/// half-filled report. `transcript` is the one defaulted field, so a service
158+/// that omits it still reports.
152 pub async fn report(db: &Database, payload: Value) -> Result<Value, (&'static str, String)> {159 pub async fn report(db: &Database, payload: Value) -> Result<Value, (&'static str, String)> {
153 let report: PodcastReportPayload = serde_json::from_value(payload).map_err(|err| {160 let report: PodcastReportPayload = serde_json::from_value(payload).map_err(|err| {
154 (161 (
@@ -165,6 +172,7 @@ pub async fn report(db: &Database, payload: Value) -> Result<Value, (&'static st
165 stage: &report.stage,172 stage: &report.stage,
166 progress: report.progress,173 progress: report.progress,
167 error_code: report.error_code.as_deref(),174 error_code: report.error_code.as_deref(),
175+ transcript: report.transcript.as_deref(),
168 };176 };
169 match crate::service::podcast_job::report(db, &input).await {177 match crate::service::podcast_job::report(db, &input).await {
170 Ok(job) => Ok(serde_json::to_value(PodcastReportReply {178 Ok(job) => Ok(serde_json::to_value(PodcastReportReply {
src/db/podcast_job.rsmodified+37 -13
@@ -36,7 +36,7 @@ pub async fn insert(db: &Database, job: &PodcastJob) -> Result<PodcastJob, AppEr
36 eta_secs, created_at, updated_at) \36 eta_secs, created_at, updated_at) \
37 VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $15) \37 VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $15) \
38 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \38 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \
39- source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, \39+ source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, \
40 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \40 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \
41 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"",41 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"",
42 job.get_id().uuid(),42 job.get_id().uuid(),
@@ -65,7 +65,7 @@ pub async fn read(db: &Database, id: &PodcastJobId) -> Result<Option<PodcastJob>
65 Ok(query_as!(65 Ok(query_as!(
66 PodcastJob,66 PodcastJob,
67 "SELECT id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \67 "SELECT id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \
68- source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, \68+ source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, \
69 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \69 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \
70 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\" \70 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\" \
71 FROM podcast_job WHERE id = $1",71 FROM podcast_job WHERE id = $1",
@@ -87,7 +87,7 @@ pub async fn read_for(
87 Ok(query_as!(87 Ok(query_as!(
88 PodcastJob,88 PodcastJob,
89 "SELECT id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \89 "SELECT id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \
90- source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, \90+ source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, \
91 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \91 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \
92 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\" \92 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\" \
93 FROM podcast_job WHERE id = $1 AND user_id = $2",93 FROM podcast_job WHERE id = $1 AND user_id = $2",
@@ -177,9 +177,11 @@ async fn with_source_titles(
177 /// concurrent write (a cancel, another report) moved it first — the caller177 /// concurrent write (a cancel, another report) moved it first — the caller
178 /// re-reads and answers the truth.178 /// re-reads and answers the truth.
179 ///179 ///
180-/// `format` fills the column once and never rewrites it: the service's default180+/// `format` and `transcript` fill their columns once and never rewrite them:
181-/// resolution arrives on the first report, and a later report disagreeing with181+/// the service's default resolution arrives on the first report, and a later
182-/// it is refused by the service layer, not silently stored.182+/// report disagreeing with the format is refused by the service layer, not
183+/// silently stored. A later transcript is ignored the same way — the first
184+/// non-null value stands.
183 #[allow(clippy::too_many_arguments)]185 #[allow(clippy::too_many_arguments)]
184 pub async fn report(186 pub async fn report(
185 db: &Database,187 db: &Database,
@@ -190,15 +192,17 @@ pub async fn report(
190 progress: f64,192 progress: f64,
191 error_code: Option<&str>,193 error_code: Option<&str>,
192 format: Option<&str>,194 format: Option<&str>,
195+ transcript: Option<&str>,
193 ) -> Result<Option<PodcastJob>, AppError> {196 ) -> Result<Option<PodcastJob>, AppError> {
194 let now = Timestamp::now().as_millis();197 let now = Timestamp::now().as_millis();
195 Ok(query_as!(198 Ok(query_as!(
196 PodcastJob,199 PodcastJob,
197 "UPDATE podcast_job SET state = $3, stage = $4, progress = $5, error_code = $6, \200 "UPDATE podcast_job SET state = $3, stage = $4, progress = $5, error_code = $6, \
198- format = COALESCE(format, $7::text), updated_at = $8 \201+ format = COALESCE(format, $7::text), transcript = COALESCE(transcript, $8::text), \
202+ updated_at = $9 \
199 WHERE id = $1 AND state = $2 \203 WHERE id = $1 AND state = $2 \
200 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \204 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \
201- source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, \205+ source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, \
202 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \206 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \
203 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"",207 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"",
204 id.uuid(),208 id.uuid(),
@@ -208,6 +212,7 @@ pub async fn report(
208 progress,212 progress,
209 error_code,213 error_code,
210 format,214 format,
215+ transcript,
211 now,216 now,
212 )217 )
213 .fetch_optional(db)218 .fetch_optional(db)
@@ -228,7 +233,7 @@ pub async fn set_cancelled(
228 "UPDATE podcast_job SET state = 'cancelled', stage = '', updated_at = $2 \233 "UPDATE podcast_job SET state = 'cancelled', stage = '', updated_at = $2 \
229 WHERE id = $1 AND state IN ('queued', 'running') \234 WHERE id = $1 AND state IN ('queued', 'running') \
230 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \235 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \
231- source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, \236+ source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, \
232 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \237 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \
233 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"",238 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"",
234 id.uuid(),239 id.uuid(),
@@ -253,7 +258,7 @@ pub async fn set_failed(
253 "UPDATE podcast_job SET state = 'failed', error_code = $2, stage = '', updated_at = $3 \258 "UPDATE podcast_job SET state = 'failed', error_code = $2, stage = '', updated_at = $3 \
254 WHERE id = $1 AND state IN ('queued', 'running') \259 WHERE id = $1 AND state IN ('queued', 'running') \
255 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \260 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \
256- source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, \261+ source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, \
257 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \262 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \
258 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"",263 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"",
259 id.uuid(),264 id.uuid(),
@@ -284,7 +289,7 @@ pub async fn set_audio(
284 audio_bytes = $5, duration_secs = $6, updated_at = $7 \289 audio_bytes = $5, duration_secs = $6, updated_at = $7 \
285 WHERE id = $1 \290 WHERE id = $1 \
286 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \291 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \
287- source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, \292+ source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, \
288 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \293 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \
289 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"",294 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"",
290 id.uuid(),295 id.uuid(),
@@ -311,7 +316,7 @@ pub async fn set_eta(
311 PodcastJob,316 PodcastJob,
312 "UPDATE podcast_job SET eta_secs = $2 WHERE id = $1 \317 "UPDATE podcast_job SET eta_secs = $2 WHERE id = $1 \
313 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \318 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \
314- source_id, format, state AS \"state: PodcastJobState\", stage, progress, error_code, \319+ source_id, format, transcript, state AS \"state: PodcastJobState\", stage, progress, error_code, \
315 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \320 audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, \
316 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"",321 created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"",
317 id.uuid(),322 id.uuid(),
@@ -355,6 +360,7 @@ mod tests {
355 user_id: *user,360 user_id: *user,
356 source_id: "src".to_string(),361 source_id: "src".to_string(),
357 format: None,362 format: None,
363+ transcript: None,
358 state: PodcastJobState::Queued,364 state: PodcastJobState::Queued,
359 stage: String::new(),365 stage: String::new(),
360 progress: 0.0,366 progress: 0.0,
@@ -379,7 +385,9 @@ mod tests {
379 let row = insert(&db, &job(&user)).await.expect("insert");385 let row = insert(&db, &job(&user)).await.expect("insert");
380 let id = row.get_id().clone();386 let id = row.get_id().clone();
381 387
382- // The running report lands, and carries the resolved format with it.388+ // The running report lands, and carries the resolved format and the
389+ // transcript with it. A later report that does not match the row
390+ // cannot clear either.
383 let running = report(391 let running = report(
384 &db,392 &db,
385 &id,393 &id,
@@ -389,12 +397,14 @@ mod tests {
389 0.25,397 0.25,
390 None,398 None,
391 Some("duz_okuma"),399 Some("duz_okuma"),
400+ Some("bolum bir\n\nbolum iki"),
392 )401 )
393 .await402 .await
394 .expect("report")403 .expect("report")
395 .expect("row was queued");404 .expect("row was queued");
396 assert_eq!(running.get_state(), PodcastJobState::Running);405 assert_eq!(running.get_state(), PodcastJobState::Running);
397 assert_eq!(running.get_format(), Some("duz_okuma"));406 assert_eq!(running.get_format(), Some("duz_okuma"));
407+ assert_eq!(running.get_transcript(), Some("bolum bir\n\nbolum iki"));
398 408
399 // A second report claiming the row is still queued matches nothing.409 // A second report claiming the row is still queued matches nothing.
400 let stale = report(410 let stale = report(
@@ -406,6 +416,7 @@ mod tests {
406 0.5,416 0.5,
407 None,417 None,
408 None,418 None,
419+ Some("should not land"),
409 )420 )
410 .await421 .await
411 .expect("report");422 .expect("report");
@@ -422,6 +433,7 @@ mod tests {
422 1.0,433 1.0,
423 None,434 None,
424 None,435 None,
436+ Some("also not"),
425 )437 )
426 .await438 .await
427 .expect("report");439 .expect("report");
@@ -430,6 +442,15 @@ mod tests {
430 read(&db, &id).await.expect("read").unwrap().get_state(),442 read(&db, &id).await.expect("read").unwrap().get_state(),
431 PodcastJobState::Cancelled443 PodcastJobState::Cancelled
432 );444 );
445+ assert_eq!(
446+ read(&db, &id)
447+ .await
448+ .expect("read")
449+ .unwrap()
450+ .get_transcript(),
451+ Some("bolum bir\n\nbolum iki"),
452+ "a report that matched nothing did not clear the stored transcript"
453+ );
433 // A terminal row refuses the backend's own writes too.454 // A terminal row refuses the backend's own writes too.
434 assert!(set_failed(&db, &id, "interrupted").await.unwrap().is_none());455 assert!(set_failed(&db, &id, "interrupted").await.unwrap().is_none());
435 }456 }
@@ -473,6 +494,7 @@ mod tests {
473 1.0,494 1.0,
474 None,495 None,
475 None,496 None,
497+ None,
476 )498 )
477 .await;499 .await;
478 assert!(refused.is_err(), "the CHECK backstops the service layer");500 assert!(refused.is_err(), "the CHECK backstops the service layer");
@@ -497,6 +519,7 @@ mod tests {
497 1.0,519 1.0,
498 None,520 None,
499 None,521 None,
522+ Some("metin"),
500 )523 )
501 .await524 .await
502 .expect("report")525 .expect("report")
@@ -505,5 +528,6 @@ mod tests {
505 assert_eq!(done.get_audio_key(), Some("podcast/x.mp3"));528 assert_eq!(done.get_audio_key(), Some("podcast/x.mp3"));
506 assert_eq!(done.get_duration_secs(), Some(3.5));529 assert_eq!(done.get_duration_secs(), Some(3.5));
507 assert_eq!(done.get_audio_bytes(), Some(12));530 assert_eq!(done.get_audio_bytes(), Some(12));
531+ assert_eq!(done.get_transcript(), Some("metin"));
508 }532 }
509 }533 }
src/domain/podcast_job.rsmodified+8 -0
@@ -136,6 +136,9 @@ pub struct PodcastJob {
136 pub(crate) user_id: UserId,136 pub(crate) user_id: UserId,
137 pub(crate) source_id: String,137 pub(crate) source_id: String,
138 pub(crate) format: Option<String>,138 pub(crate) format: Option<String>,
139+ /// The episode transcript, chapters joined with blank lines. `None` until
140+ /// a report carries one, and forever for a job whose service never did.
141+ pub(crate) transcript: Option<String>,
139 pub(crate) state: PodcastJobState,142 pub(crate) state: PodcastJobState,
140 pub(crate) stage: String,143 pub(crate) stage: String,
141 pub(crate) progress: f64,144 pub(crate) progress: f64,
@@ -167,6 +170,10 @@ impl PodcastJob {
167 self.format.as_deref()170 self.format.as_deref()
168 }171 }
169 172
173+ pub fn get_transcript(&self) -> Option<&str> {
174+ self.transcript.as_deref()
175+ }
176+
170 pub fn get_state(&self) -> PodcastJobState {177 pub fn get_state(&self) -> PodcastJobState {
171 self.state178 self.state
172 }179 }
@@ -326,6 +333,7 @@ mod tests {
326 user_id: UserId::from_key("00000000-0000-7000-8000-000000000000"),333 user_id: UserId::from_key("00000000-0000-7000-8000-000000000000"),
327 source_id: "src".to_string(),334 source_id: "src".to_string(),
328 format: None,335 format: None,
336+ transcript: None,
329 state,337 state,
330 stage: String::new(),338 stage: String::new(),
331 progress: 0.0,339 progress: 0.0,
src/lib.rsmodified+1 -1
@@ -59,7 +59,7 @@ use crate::web::module_gate::gate;
59 (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"),59 (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"),
60 (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."),60 (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."),
61 (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."),61 (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."),
62- (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 `<media root>/<school>/<source_key>` — 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)."),62+ (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 `<media root>/<school>/<source_key>` — 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)."),
63 (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`"),63 (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`"),
64 (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"),64 (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"),
65 (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"),65 (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"),
src/service/podcast_job.rsmodified+108 -0
@@ -23,6 +23,11 @@ use crate::validate::validate_required;
23 /// service cannot write a paragraph into a column a UI renders inline.23 /// service cannot write a paragraph into a column a UI renders inline.
24 const MAX_CODE_LEN: usize = 64;24 const MAX_CODE_LEN: usize = 64;
25 25
26+/// The most characters a report may put in `transcript`. A finished episode's
27+/// text is a few kilobytes; past a million characters the payload is not a
28+/// transcript, and it must not land in a column a result door returns whole.
29+const MAX_TRANSCRIPT_LEN: usize = 1_000_000;
30+
26 /// Why one `podcast.report` (or an audio ingest) was refused. `code()` is the31 /// Why one `podcast.report` (or an audio ingest) was refused. `code()` is the
27 /// flat, stable, machine-readable string the bridge answers in the32 /// flat, stable, machine-readable string the bridge answers in the
28 /// capability's `code` field — the same vocabulary the protocol's other33 /// capability's `code` field — the same vocabulary the protocol's other
@@ -95,6 +100,7 @@ pub struct ReportInput<'a> {
95 pub stage: &'a str,100 pub stage: &'a str,
96 pub progress: f64,101 pub progress: f64,
97 pub error_code: Option<&'a str>,102 pub error_code: Option<&'a str>,
103+ pub transcript: Option<&'a str>,
98 }104 }
99 105
100 /// Mint and store one freshly submitted job. The id is the backend's (the106 /// Mint and store one freshly submitted job. The id is the backend's (the
@@ -113,6 +119,7 @@ pub async fn create(
113 user_id: *user,119 user_id: *user,
114 source_id: source_id.to_string(),120 source_id: source_id.to_string(),
115 format: format.map(str::to_string),121 format: format.map(str::to_string),
122+ transcript: None,
116 state: PodcastJobState::Queued,123 state: PodcastJobState::Queued,
117 stage: String::new(),124 stage: String::new(),
118 progress: 0.0,125 progress: 0.0,
@@ -201,6 +208,13 @@ pub async fn report(
201 "error_code is longer than 64 characters".to_string(),208 "error_code is longer than 64 characters".to_string(),
202 ));209 ));
203 }210 }
211+ if let Some(transcript) = input.transcript
212+ && transcript.chars().count() > MAX_TRANSCRIPT_LEN
213+ {
214+ return Err(PodcastRefusal::InvalidPayload(format!(
215+ "transcript is longer than {MAX_TRANSCRIPT_LEN} characters"
216+ )));
217+ }
204 218
205 let Some(row) = podcast_job::read(db, &id).await? else {219 let Some(row) = podcast_job::read(db, &id).await? else {
206 return Err(PodcastRefusal::UnknownJob);220 return Err(PodcastRefusal::UnknownJob);
@@ -235,6 +249,10 @@ pub async fn report(
235 if target == PodcastJobState::Done && row.get_audio_key().is_none() {249 if target == PodcastJobState::Done && row.get_audio_key().is_none() {
236 return Err(PodcastRefusal::AudioMissing);250 return Err(PodcastRefusal::AudioMissing);
237 }251 }
252+ // A progress report carries `""` (no text yet). `COALESCE` would store
253+ // that empty string and then ignore the done report's text, so a blank
254+ // or all-whitespace transcript is absent, not a value.
255+ let transcript = input.transcript.filter(|text| !text.trim().is_empty());
238 256
239 match podcast_job::report(257 match podcast_job::report(
240 db,258 db,
@@ -245,6 +263,7 @@ pub async fn report(
245 input.progress,263 input.progress,
246 input.error_code,264 input.error_code,
247 input.format,265 input.format,
266+ transcript,
248 )267 )
249 .await?268 .await?
250 {269 {
@@ -347,3 +366,92 @@ pub async fn set_audio(
347 ) -> Result<Option<PodcastJob>, AppError> {366 ) -> Result<Option<PodcastJob>, AppError> {
348 podcast_job::set_audio(db, id, key, name, content_type, bytes, duration_secs).await367 podcast_job::set_audio(db, id, key, name, content_type, bytes, duration_secs).await
349 }368 }
369+
370+#[cfg(test)]
371+mod tests {
372+ use super::*;
373+
374+ /// The cap is checked before any query, so an oversized transcript never
375+ /// reaches the row — and a missing field is not this refusal.
376+ #[tokio::test]
377+ async fn a_transcript_over_one_million_characters_is_refused() {
378+ let (db, _leases) = crate::database::init_test_db().await;
379+ let huge = "a".repeat(MAX_TRANSCRIPT_LEN + 1);
380+ let input = ReportInput {
381+ job_id: "019732e3-7b00-7000-8000-00000000dead",
382+ source_id: "src",
383+ format: None,
384+ user_id: "00000000-0000-7000-8000-000000000000",
385+ state: "running",
386+ stage: "",
387+ progress: 0.0,
388+ error_code: None,
389+ transcript: Some(&huge),
390+ };
391+ let err = report(&db, &input).await.expect_err("over the cap");
392+ assert_eq!(err.code(), "invalid_payload");
393+ assert!(
394+ err.message().contains("1000000"),
395+ "names the cap: {}",
396+ err.message()
397+ );
398+ }
399+
400+ /// The service sends `transcript: ""` on every report until the episode
401+ /// is done. That blank must not fill the column, or the done text is
402+ /// dropped by `COALESCE`.
403+ #[tokio::test]
404+ async fn a_blank_progress_transcript_does_not_block_the_done_text() {
405+ let (db, _leases) = crate::database::init_test_db().await;
406+ let user = UserId::from_key(&crate::domain::monotonic_id::next_uuid().to_string());
407+ sqlx::query("INSERT INTO app_user (id, username, created_at) VALUES ($1, $2, 0)")
408+ .bind(user.uuid())
409+ .bind(format!("u{}", &user.key()[..8]))
410+ .execute(&db)
411+ .await
412+ .expect("insert user");
413+ let job = create(&db, &user, "src", None).await.expect("create");
414+ let job_id = job.get_id().key();
415+ let user_id = user.key();
416+ let progress = ReportInput {
417+ job_id: &job_id,
418+ source_id: "src",
419+ format: None,
420+ user_id: &user_id,
421+ state: "running",
422+ stage: "script",
423+ progress: 0.2,
424+ error_code: None,
425+ transcript: Some(""),
426+ };
427+ let running = report(&db, &progress).await.expect("progress report");
428+ assert_eq!(running.get_state(), PodcastJobState::Running);
429+ assert!(running.get_transcript().is_none(), "a blank transcript is absent");
430+
431+ set_audio(
432+ &db,
433+ job.get_id(),
434+ "podcast/x.mp3",
435+ "episode.mp3",
436+ "audio/mpeg",
437+ 12,
438+ Some(1.5),
439+ )
440+ .await
441+ .expect("stamp audio")
442+ .expect("row");
443+ let done = ReportInput {
444+ job_id: &job_id,
445+ source_id: "src",
446+ format: None,
447+ user_id: &user_id,
448+ state: "done",
449+ stage: "done",
450+ progress: 1.0,
451+ error_code: None,
452+ transcript: Some("bolum bir\n\nbolum iki"),
453+ };
454+ let finished = report(&db, &done).await.expect("done report");
455+ assert_eq!(finished.get_transcript(), Some("bolum bir\n\nbolum iki"));
456+ }
457+}
src/web/podcast.rsmodified+6 -0
@@ -135,6 +135,11 @@ struct JobArtifacts {
135 duration_secs: Option<f64>,135 duration_secs: Option<f64>,
136 /// The resolved narration format.136 /// The resolved narration format.
137 format: Option<String>,137 format: Option<String>,
138+ /// The episode transcript, chapters joined by blank lines. `null` when the
139+ /// service that produced the episode did not report one — every job
140+ /// finished before the column existed, and any later job whose done report
141+ /// omitted the field.
142+ transcript: Option<String>,
138 }143 }
139 144
140 /// The verdict on a cancel.145 /// The verdict on a cancel.
@@ -466,6 +471,7 @@ async fn result(
466 audio_id,471 audio_id,
467 duration_secs: job.get_duration_secs(),472 duration_secs: job.get_duration_secs(),
468 format: job.get_format().map(str::to_string),473 format: job.get_format().map(str::to_string),
474+ transcript: job.get_transcript().map(str::to_string),
469 })475 })
470 .into_response())476 .into_response())
471 }477 }
tests/ai_bridge.rsmodified+48 -15
@@ -4810,14 +4810,15 @@ async fn seed_podcast_job(db: &Database) -> (String, String) {
4810 }4810 }
4811 4811
4812 /// The row's own answers to what the tests ask of it:4812 /// The row's own answers to what the tests ask of it:
4813-/// (state, stage, progress, audio_key, duration_secs).4813+/// (state, stage, progress, audio_key, duration_secs, transcript).
4814 async fn podcast_row(4814 async fn podcast_row(
4815 db: &Database,4815 db: &Database,
4816 job: &str,4816 job: &str,
4817-) -> (String, String, f64, Option<String>, Option<f64>) {4817+) -> (String, String, f64, Option<String>, Option<f64>, Option<String>) {
4818 use sqlx::Row as _;4818 use sqlx::Row as _;
4819 let row = sqlx::query(4819 let row = sqlx::query(
4820- "SELECT state, stage, progress, audio_key, duration_secs FROM podcast_job WHERE id = $1",4820+ "SELECT state, stage, progress, audio_key, duration_secs, transcript \
4821+ FROM podcast_job WHERE id = $1",
4821 )4822 )
4822 .bind(uuid::Uuid::parse_str(job).expect("a job uuid"))4823 .bind(uuid::Uuid::parse_str(job).expect("a job uuid"))
4823 .fetch_one(db)4824 .fetch_one(db)
@@ -4829,6 +4830,7 @@ async fn podcast_row(
4829 row.get("progress"),4830 row.get("progress"),
4830 row.get("audio_key"),4831 row.get("audio_key"),
4831 row.get("duration_secs"),4832 row.get("duration_secs"),
4833+ row.get("transcript"),
4832 )4834 )
4833 }4835 }
4834 4836
@@ -4840,19 +4842,35 @@ fn report_call(
4840 stage: &str,4842 stage: &str,
4841 progress: f64,4843 progress: f64,
4842 ) -> CapabilityRequest {4844 ) -> CapabilityRequest {
4845+ report_call_with(school, job, user, state, stage, progress, None)
4846+}
4847+
4848+fn report_call_with(
4849+ school: &str,
4850+ job: &str,
4851+ user: &str,
4852+ state: &str,
4853+ stage: &str,
4854+ progress: f64,
4855+ transcript: Option<&str>,
4856+) -> CapabilityRequest {
4857+ let mut payload = json!({
4858+ "job_id": job,
4859+ "source_id": "kaynak-1",
4860+ "format": "duz_okuma",
4861+ "user_id": user,
4862+ "state": state,
4863+ "stage": stage,
4864+ "progress": progress,
4865+ });
4866+ if let Some(text) = transcript {
4867+ payload["transcript"] = json!(text);
4868+ }
4843 CapabilityRequest {4869 CapabilityRequest {
4844 id: format!("trace-report-{job}-{state}"),4870 id: format!("trace-report-{job}-{state}"),
4845 school: school.to_string(),4871 school: school.to_string(),
4846 capability: AI_PODCAST_REPORT_CAPABILITY.to_string(),4872 capability: AI_PODCAST_REPORT_CAPABILITY.to_string(),
4847- payload: json!({4873+ payload,
4848- "job_id": job,
4849- "source_id": "kaynak-1",
4850- "format": "duz_okuma",
4851- "user_id": user,
4852- "state": state,
4853- "stage": stage,
4854- "progress": progress,
4855- }),
4856 }4874 }
4857 }4875 }
4858 4876
@@ -4928,6 +4946,10 @@ async fn the_report_and_upload_handshake_lands_on_the_backends_own_row() {
4928 assert_eq!(ok_capability(answer)["job_id"], job);4946 assert_eq!(ok_capability(answer)["job_id"], job);
4929 assert_eq!(podcast_row(&db, &job).await.0, "running");4947 assert_eq!(podcast_row(&db, &job).await.0, "running");
4930 assert_eq!(podcast_row(&db, &job).await.1, "script");4948 assert_eq!(podcast_row(&db, &job).await.1, "script");
4949+ assert!(
4950+ podcast_row(&db, &job).await.5.is_none(),
4951+ "a report that omits transcript still stores, and the column stays null"
4952+ );
4931 4953
4932 // `done` means a stored episode: a report that claims one before the4954 // `done` means a stored episode: a report that claims one before the
4933 // upload is refused, and nothing about the row moves.4955 // 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() {
4977 assert_eq!(row.3.as_deref(), Some(key.as_str()));4999 assert_eq!(row.3.as_deref(), Some(key.as_str()));
4978 assert_eq!(row.4, Some(12.5));5000 assert_eq!(row.4, Some(12.5));
4979 5001
4980- // Now — and only now — `done` is accepted.5002+ // Now — and only now — `done` is accepted, and the transcript it carries
5003+ // is what the row holds.
4981 assert_eq!(5004 assert_eq!(
4982 ok_capability(5005 ok_capability(
4983 capability_call(5006 capability_call(
4984 conn,5007 conn,
4985- report_call(DEMO_SCHOOL_ID, &job, &user, "done", "done", 1.0)5008+ report_call_with(
5009+ DEMO_SCHOOL_ID,
5010+ &job,
5011+ &user,
5012+ "done",
5013+ "done",
5014+ 1.0,
5015+ Some("bolum bir\n\nbolum iki"),
5016+ )
4986 )5017 )
4987 .await5018 .await
4988 )["stored"],5019 )["stored"],
4989 true5020 true
4990 );5021 );
4991- assert_eq!(podcast_row(&db, &job).await.0, "done");5022+ let done = podcast_row(&db, &job).await;
5023+ assert_eq!(done.0, "done");
5024+ assert_eq!(done.5.as_deref(), Some("bolum bir\n\nbolum iki"));
4992 5025
4993 // And a job the backend never minted is `unknown_job`.5026 // And a job the backend never minted is `unknown_job`.
4994 let stranger = hezarfen_backend::domain::monotonic_id::next_uuid().to_string();5027 let stranger = hezarfen_backend::domain::monotonic_id::next_uuid().to_string();
tests/limits_completeness.rsmodified+12 -4
@@ -551,12 +551,20 @@ fn moved_value_tables_are_still_published_or_deliberately_excluded() {
551 /// constant: every former entry now lives there and is excused (or published)551 /// constant: every former entry now lives there and is excused (or published)
552 /// through `EXCLUDED` above instead. A new name here is a claim that a bound552 /// through `EXCLUDED` above instead. A new name here is a claim that a bound
553 /// belongs somewhere else, which needs an argument.553 /// belongs somewhere else, which needs an argument.
554-const NOT_A_CLIENT_BOUND: &[(&str, &str)] = &[(554+const NOT_A_CLIENT_BOUND: &[(&str, &str)] = &[
555- "MAX_CODE_LEN",555+ (
556- "bound on the length of a podcast report's `stage`/`error_code` — values \556+ "MAX_CODE_LEN",
557+ "bound on the length of a podcast report's `stage`/`error_code` — values \
557 the AI *service* writes onto the job row; a browser reads the stored \558 the AI *service* writes onto the job row; a browser reads the stored \
558 string back, it never sizes one against this",559 string back, it never sizes one against this",
559-)];560+ ),
561+ (
562+ "MAX_TRANSCRIPT_LEN",
563+ "bound on a podcast report's `transcript` — the AI service writes it, \
564+ the result door returns the stored text; a browser never sizes a \
565+ transcript against this",
566+ ),
567+];
560 568
561 #[test]569 #[test]
562 fn validation_bounds_live_in_constant_rs() {570 fn validation_bounds_live_in_constant_rs() {
tests/podcast.rsmodified+8 -5
@@ -814,12 +814,10 @@ async fn a_finished_job_serves_the_uploaded_bytes() {
814 assert_eq!(answer["key"], format!("podcast/{job_id}.mp3"));814 assert_eq!(answer["key"], format!("podcast/{job_id}.mp3"));
815 assert_eq!(answer["size"], bytes.len() as u64);815 assert_eq!(answer["size"], bytes.len() as u64);
816 816
817+ let mut done = report_frame(&job_id, &note, &user, "done", "", 1.0);
818+ done["payload"]["transcript"] = json!("bolum bir\n\nbolum iki");
817 assert_report_stored(819 assert_report_stored(
818- &capability_call(820+ &capability_call(&service.conn, done).await,
819- &service.conn,
820- report_frame(&job_id, &note, &user, "done", "", 1.0),
821- )
822- .await,
823 &job_id,821 &job_id,
824 );822 );
825 823
@@ -829,6 +827,7 @@ async fn a_finished_job_serves_the_uploaded_bytes() {
829 assert_eq!(res.body["audio_id"], format!("podcast/{job_id}.mp3"));827 assert_eq!(res.body["audio_id"], format!("podcast/{job_id}.mp3"));
830 assert_eq!(res.body["duration_secs"], DURATION_SECS);828 assert_eq!(res.body["duration_secs"], DURATION_SECS);
831 assert_eq!(res.body["format"], FORMAT);829 assert_eq!(res.body["format"], FORMAT);
830+ assert_eq!(res.body["transcript"], "bolum bir\n\nbolum iki");
832 831
833 let (status, headers, body) = audio_of(&app, &cookie, &job_id).await;832 let (status, headers, body) = audio_of(&app, &cookie, &job_id).await;
834 assert_eq!(status, StatusCode::OK, "{:?}", String::from_utf8_lossy(&body));833 assert_eq!(status, StatusCode::OK, "{:?}", String::from_utf8_lossy(&body));
@@ -1529,6 +1528,10 @@ async fn the_audio_door_reports_a_missing_blob() {
1529 let res = result_of(&app, &cookie, &job.to_string()).await;1528 let res = result_of(&app, &cookie, &job.to_string()).await;
1530 assert_eq!(res.status, StatusCode::OK, "{}", res.body);1529 assert_eq!(res.status, StatusCode::OK, "{}", res.body);
1531 assert_eq!(res.body["audio_id"], key);1530 assert_eq!(res.body["audio_id"], key);
1531+ assert!(
1532+ res.body["transcript"].is_null(),
1533+ "a job finished before the column existed answers null, not an empty string"
1534+ );
1532 1535
1533 let (status, _, body) = audio_of(&app, &cookie, &job.to_string()).await;1536 let (status, _, body) = audio_of(&app, &cookie, &job.to_string()).await;
1534 assert_eq!(1537 assert_eq!(