Skip to main content

relay_knowledge/storage/contracts/
business.rs

1//! Storage boundary for authored business-knowledge projections.
2
3use crate::domain::{
4    BusinessKnowledgeProjection, BusinessKnowledgeProjectionInput, BusinessKnowledgeQueryRequest,
5    BusinessKnowledgeStatus, CodeIndexPublicationFence,
6};
7
8use super::{StorageError, StorageFuture};
9
10/// Repository-scoped business projection writes and immutable indexed reads.
11pub trait BusinessKnowledgeStore: Send + Sync {
12    fn replace_business_knowledge_projection(
13        &self,
14        input: BusinessKnowledgeProjectionInput,
15    ) -> StorageFuture<'_, BusinessKnowledgeStatus> {
16        Box::pin(async move {
17            Err(StorageError::InvalidInput(format!(
18                "business knowledge projection for scope '{}' is unavailable",
19                input.source_scope
20            )))
21        })
22    }
23
24    fn replace_business_knowledge_projection_with_fence(
25        &self,
26        input: BusinessKnowledgeProjectionInput,
27        fence: CodeIndexPublicationFence,
28    ) -> StorageFuture<'_, BusinessKnowledgeStatus> {
29        Box::pin(async move {
30            Err(StorageError::InvalidInput(format!(
31                "attempt-scoped business projection for task '{}' scope '{}' is unavailable",
32                fence.task_id, input.source_scope
33            )))
34        })
35    }
36
37    fn business_knowledge_projection_for_scope(
38        &self,
39        source_scope: String,
40        _request: BusinessKnowledgeQueryRequest,
41    ) -> StorageFuture<'_, BusinessKnowledgeProjection> {
42        Box::pin(async move {
43            Err(StorageError::InvalidInput(format!(
44                "business knowledge projection for source scope '{source_scope}' is unavailable"
45            )))
46        })
47    }
48
49    fn business_knowledge_status(
50        &self,
51        _source_scope: String,
52    ) -> StorageFuture<'_, Option<BusinessKnowledgeStatus>> {
53        Box::pin(async { Ok(None) })
54    }
55}
56
57#[cfg(test)]
58#[path = "business_tests.rs"]
59mod tests;