@@ -14,9 +14,16 @@ pub(crate) fn import_incremental_codex_session_tree(
1414 record_id : Uuid ,
1515 progress : Option < CodexSessionImportProgressCallback > ,
1616 preinventory_catalog : Option < & CatalogSummary > ,
17+ preinventory_generation : Option < u64 > ,
1718 force_selection : bool ,
1819) -> Result < ProviderImportSummary > {
1920 let source_root = source. path . display ( ) . to_string ( ) ;
21+ let inventory_generation = match preinventory_generation {
22+ Some ( generation) => generation,
23+ None => {
24+ store. allocate_catalog_inventory_generation ( CaptureProvider :: Codex , & source_root) ?
25+ }
26+ } ;
2027 let mut summary = ProviderImportSummary :: default ( ) ;
2128 if let Some ( catalog) = preinventory_catalog {
2229 summary. failed += catalog. failed_sessions ;
@@ -27,6 +34,7 @@ pub(crate) fn import_incremental_codex_session_tree(
2734 store,
2835 CodexSessionCatalogOptions {
2936 source_root : Some ( source. path . clone ( ) ) ,
37+ observation_generation : Some ( inventory_generation) ,
3038 ..CodexSessionCatalogOptions :: default ( )
3139 } ,
3240 )
@@ -76,6 +84,7 @@ pub(crate) fn import_incremental_codex_session_tree(
7684 std:: slice:: from_ref ( session) ,
7785 & error,
7886 catalog_import_error_status ( & err) ,
87+ inventory_generation,
7988 ) ?;
8089 return Err ( err) ;
8190 }
@@ -104,6 +113,7 @@ pub(crate) fn import_incremental_codex_session_tree(
104113 std:: slice:: from_ref ( session) ,
105114 & err. to_string ( ) ,
106115 catalog_import_error_status ( & err) ,
116+ inventory_generation,
107117 ) ?;
108118 return Err ( err) ;
109119 }
@@ -129,6 +139,7 @@ pub(crate) fn import_incremental_codex_session_tree(
129139 utc_now ( ) . timestamp_millis ( ) ,
130140 status,
131141 error. as_deref ( ) ,
142+ inventory_generation,
132143 ) ?;
133144 summary. merge_from ( tail_summary) ;
134145 } else {
@@ -160,6 +171,7 @@ pub(crate) fn import_incremental_codex_session_tree(
160171 std:: slice:: from_ref ( session) ,
161172 & error,
162173 catalog_import_error_status ( & err) ,
174+ inventory_generation,
163175 ) ?;
164176 if failure_scope == ImportFailureScope :: System {
165177 return Err ( err) ;
@@ -171,7 +183,12 @@ pub(crate) fn import_incremental_codex_session_tree(
171183 continue ;
172184 }
173185 } ;
174- mark_catalog_sessions_result ( store, std:: slice:: from_ref ( session) , & file_summary) ?;
186+ mark_catalog_sessions_result (
187+ store,
188+ std:: slice:: from_ref ( session) ,
189+ & file_summary,
190+ inventory_generation,
191+ ) ?;
175192 summary. merge_from ( file_summary) ;
176193 }
177194 }
@@ -196,6 +213,7 @@ pub(crate) fn mark_catalog_sessions_result(
196213 store : & Store ,
197214 sessions : & [ CatalogSession ] ,
198215 summary : & ProviderImportSummary ,
216+ inventory_generation : u64 ,
199217) -> Result < ( ) > {
200218 let indexed_at_ms = utc_now ( ) . timestamp_millis ( ) ;
201219 let event_count = if sessions. len ( ) == 1 {
@@ -217,6 +235,7 @@ pub(crate) fn mark_catalog_sessions_result(
217235 indexed_at_ms,
218236 status,
219237 error. as_deref ( ) ,
238+ inventory_generation,
220239 ) ?;
221240 }
222241 Ok ( ( ) )
@@ -229,6 +248,7 @@ pub(crate) fn mark_catalog_session_result(
229248 indexed_at_ms : i64 ,
230249 status : CatalogIndexedStatus ,
231250 error : Option < & str > ,
251+ inventory_generation : u64 ,
232252) -> Result < ( ) > {
233253 let file_sha256 = if status == CatalogIndexedStatus :: Indexed {
234254 let hash = sha256_file_prefix_hex ( Path :: new ( & session. source_path ) , session. file_size_bytes )
@@ -242,6 +262,7 @@ pub(crate) fn mark_catalog_session_result(
242262 std:: slice:: from_ref ( session) ,
243263 & durable_error,
244264 catalog_import_error_status ( & err) ,
265+ inventory_generation,
245266 ) ?;
246267 return Err ( err) ;
247268 }
@@ -257,6 +278,7 @@ pub(crate) fn mark_catalog_session_result(
257278 file_size_bytes : session. file_size_bytes ,
258279 file_modified_at_ms : session. file_modified_at_ms ,
259280 import_revision : session. import_revision ,
281+ inventory_generation,
260282 file_sha256 : file_sha256. as_deref ( ) ,
261283 event_count,
262284 indexed_at_ms,
@@ -304,6 +326,7 @@ pub(crate) fn mark_catalog_sessions_error(
304326 sessions : & [ CatalogSession ] ,
305327 error : & str ,
306328 status : CatalogIndexedStatus ,
329+ inventory_generation : u64 ,
307330) -> Result < ( ) > {
308331 let indexed_at_ms = utc_now ( ) . timestamp_millis ( ) ;
309332 for session in sessions {
@@ -315,6 +338,7 @@ pub(crate) fn mark_catalog_sessions_error(
315338 file_size_bytes : session. file_size_bytes ,
316339 file_modified_at_ms : session. file_modified_at_ms ,
317340 import_revision : session. import_revision ,
341+ inventory_generation,
318342 file_sha256 : None ,
319343 event_count : None ,
320344 indexed_at_ms,
0 commit comments