Problem
When processing crates via the HTTP endpoint, the system logs warnings indicating database validation failures even though the crate processing completes successfully:
WARN: Cannot update acton-reactive@5.0.0 to 'chunked' status: No doc_chunks found in database (expected 18)
WARN: Cannot update acton-reactive@5.0.0 to 'vectorized' status: No embeddings found in database (expected 18)
WARN: Cannot update acton-reactive@5.0.0 to 'complete' status: Crate record not found in database
These warnings appear to the user as errors even though processing completes successfully moments later.
Root Cause
Race Condition in Message Ordering
The DatabaseActor subscribes to DocumentationChunked and DocumentationVectorized messages and immediately attempts to validate that chunks/embeddings exist in the database and update the crate status. However, these validation queries run BEFORE the actual PersistDocChunk/PersistEmbedding messages have been processed.
Current Broken Flow:
ProcessorActor finishes chunking
↓ IMMEDIATELY broadcasts
DocumentationChunked → DatabaseActor tries to validate chunks → FINDS 0 ❌
↓ ALSO broadcasts (async, processed later)
PersistDocChunk (x18) → DatabaseActor processes these → Inserts chunks ✓
The CrateCoordinatorActor correctly tracks DocChunkPersisted and EmbeddingPersisted messages to know when persistence is complete, but the DatabaseActor doesn't wait for this confirmation before attempting status updates.
Proposed Solution
Remove premature validation from DatabaseActor and add coordination messages:
- DatabaseActor should STOP subscribing to
DocumentationChunked and DocumentationVectorized
- CrateCoordinatorActor should broadcast NEW messages after confirming persistence:
ChunksPersistenceComplete - after all DocChunkPersisted received
EmbeddingsPersistenceComplete - after all EmbeddingPersisted received
- DatabaseActor should subscribe to these new messages and update status then
Corrected Flow:
ProcessorActor broadcasts DocumentationChunked + PersistDocChunk(x18)
↓
DatabaseActor processes PersistDocChunk → broadcasts DocChunkPersisted
↓
CrateCoordinatorActor tracks DocChunkPersisted → when count==expected
↓ broadcasts
ChunksPersistenceComplete → DatabaseActor updates status to "chunked" ✓
Implementation Tasks
Testing
Test with the following curl command to verify warnings no longer appear:
curl -X POST http://localhost:3333/crate \
-H "Content-Type: application/json" \
-d '{"name": "acton-reactive", "version": "5.0.0", "features": ["instrument"]}'
Expected: No warnings in logs, crate processes successfully to completion.
Files Affected
src/actors/crate_coordinator_actor.rs - Add broadcasts after persistence tracking
src/actors/database.rs - Replace handlers and remove validation queries
src/messages/chunks_persistence_complete.rs - New message type
src/messages/embeddings_persistence_complete.rs - New message type
src/messages/mod.rs - Export new messages
Problem
When processing crates via the HTTP endpoint, the system logs warnings indicating database validation failures even though the crate processing completes successfully:
These warnings appear to the user as errors even though processing completes successfully moments later.
Root Cause
Race Condition in Message Ordering
The DatabaseActor subscribes to
DocumentationChunkedandDocumentationVectorizedmessages and immediately attempts to validate that chunks/embeddings exist in the database and update the crate status. However, these validation queries run BEFORE the actualPersistDocChunk/PersistEmbeddingmessages have been processed.Current Broken Flow:
The CrateCoordinatorActor correctly tracks
DocChunkPersistedandEmbeddingPersistedmessages to know when persistence is complete, but the DatabaseActor doesn't wait for this confirmation before attempting status updates.Proposed Solution
Remove premature validation from DatabaseActor and add coordination messages:
DocumentationChunkedandDocumentationVectorizedChunksPersistenceComplete- after allDocChunkPersistedreceivedEmbeddingsPersistenceComplete- after allEmbeddingPersistedreceivedCorrected Flow:
Implementation Tasks
ChunksPersistenceCompleteinsrc/messages/chunks_persistence_complete.rsEmbeddingsPersistenceCompleteinsrc/messages/embeddings_persistence_complete.rssrc/messages/mod.rsto export new messagesCrateCoordinatorActorto broadcast completion messages:persisted_chunks.len() == expected_chunks, broadcastChunksPersistenceCompletepersisted_vectors.len() == expected_vectors, broadcastEmbeddingsPersistenceCompleteDatabaseActor:DocumentationChunkedandDocumentationVectorizedhandlersChunksPersistenceCompletehandler to update status to "chunked"EmbeddingsPersistenceCompletehandler to update status to "vectorized"Testing
Test with the following curl command to verify warnings no longer appear:
curl -X POST http://localhost:3333/crate \ -H "Content-Type: application/json" \ -d '{"name": "acton-reactive", "version": "5.0.0", "features": ["instrument"]}'Expected: No warnings in logs, crate processes successfully to completion.
Files Affected
src/actors/crate_coordinator_actor.rs- Add broadcasts after persistence trackingsrc/actors/database.rs- Replace handlers and remove validation queriessrc/messages/chunks_persistence_complete.rs- New message typesrc/messages/embeddings_persistence_complete.rs- New message typesrc/messages/mod.rs- Export new messages