Skip to main content

relay_knowledge/api/operations/
repository.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{
4    api::{ApiMetadata, CodeRepositoryFreshnessDiagnostics, CodeRepositoryScopeMetadata},
5    domain::{
6        BusinessDomain, BusinessKnowledgeQueryRequest, BusinessKnowledgeResolution,
7        BusinessKnowledgeStatus, BusinessTerm, CodeFeatureFlagGraph, CodeFeatureFlagRequest,
8        CodeImpactPathGroups, CodeImpactRequest, CodeIndexCheckpoint, CodeIndexSummary,
9        CodeIndexTaskRecord, CodeRepositoryRegistration, CodeRepositoryRemovalSummary,
10        CodeRepositoryReport, CodeRepositoryScopePreview, CodeRepositoryStatus, CodeRetrievalHit,
11        CodeRetrievalRequest, CodeScopeRetentionSummary, FrameworkGraph, FrameworkGraphRequest,
12        RepositoryGraphEdge, RepositoryGraphNeighborhoodRequest, RepositoryGraphNode,
13        SoftwareBuildTarget, SoftwareComponent, SoftwareDependencyUsage, SoftwareDesignElement,
14        SoftwareEntity, SoftwareExportProfile, SoftwareFile, SoftwareGlobalRequest,
15        SoftwareGlobalStatus, SoftwareIacResource, SoftwareRelationship, SoftwareSdkUsage,
16        SoftwareShapeDiagnostic, SoftwareStatement, SoftwareTopic,
17    },
18};
19
20/// Code repository registration request.
21#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
22pub struct CodeRepositoryRegisterRequest {
23    pub root_path: String,
24    #[serde(default)]
25    pub alias: String,
26    #[serde(default)]
27    pub path_filters: Vec<String>,
28    #[serde(default)]
29    pub language_filters: Vec<String>,
30}
31
32/// Requests an incremental update from the last published Git snapshot.
33///
34/// The service resolves both optional refs to immutable commit identities
35/// before durable work is queued. Omitting `base_ref` selects the last
36/// successfully published clean commit; omitting `head_ref` selects `HEAD`.
37#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
38pub struct CodeRepositoryUpdateRequest {
39    #[serde(default)]
40    pub repository: String,
41    #[serde(default, skip_serializing_if = "Option::is_none")]
42    pub base_ref: Option<String>,
43    #[serde(default, skip_serializing_if = "Option::is_none")]
44    pub head_ref: Option<String>,
45}
46
47/// Code repository registration response.
48#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
49pub struct CodeRepositoryRegisterResponse {
50    pub metadata: ApiMetadata,
51    pub registration: CodeRepositoryRegistration,
52    pub status: CodeRepositoryStatus,
53}
54
55/// Indexed code repository list response.
56#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
57pub struct CodeRepositoryListResponse {
58    pub metadata: ApiMetadata,
59    pub repositories: Vec<CodeRepositoryStatus>,
60}
61
62/// Code repository removal response.
63#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
64pub struct CodeRepositoryRemoveResponse {
65    pub metadata: ApiMetadata,
66    pub removed_status: CodeRepositoryStatus,
67    pub summary: CodeRepositoryRemovalSummary,
68}
69
70/// Code repository index response.
71#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
72pub struct CodeRepositoryIndexResponse {
73    pub metadata: ApiMetadata,
74    pub scope: CodeRepositoryScopeMetadata,
75    pub summary: CodeIndexSummary,
76    pub status: CodeRepositoryStatus,
77}
78
79/// Code repository index start response for queued or no-op index requests.
80#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
81pub struct CodeRepositoryIndexStartResponse {
82    pub metadata: ApiMetadata,
83    pub scope: CodeRepositoryScopeMetadata,
84    #[serde(skip_serializing_if = "Option::is_none")]
85    pub summary: Option<CodeIndexSummary>,
86    pub status: CodeRepositoryStatus,
87    #[serde(skip_serializing_if = "Option::is_none")]
88    pub task: Option<CodeIndexTaskRecord>,
89    #[serde(skip_serializing_if = "Option::is_none")]
90    pub checkpoint: Option<CodeIndexCheckpoint>,
91}
92
93/// Code repository index task reset response.
94#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
95pub struct CodeRepositoryIndexResetResponse {
96    pub metadata: ApiMetadata,
97    pub status: CodeRepositoryStatus,
98    pub reset_task_count: usize,
99    pub reset_tasks: Vec<CodeIndexTaskRecord>,
100    #[serde(skip_serializing_if = "Option::is_none")]
101    pub active_task: Option<CodeIndexTaskRecord>,
102    #[serde(skip_serializing_if = "Option::is_none")]
103    pub checkpoint: Option<CodeIndexCheckpoint>,
104    pub retention: CodeScopeRetentionSummary,
105}
106
107/// Code repository scope preview response.
108#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
109pub struct CodeRepositoryScopePreviewResponse {
110    pub metadata: ApiMetadata,
111    pub scope: CodeRepositoryScopeMetadata,
112    pub preview: CodeRepositoryScopePreview,
113}
114
115/// Code repository retrieval response.
116#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
117pub struct CodeRepositoryQueryResponse {
118    pub metadata: ApiMetadata,
119    pub scope: CodeRepositoryScopeMetadata,
120    #[serde(default = "CodeRepositoryFreshnessDiagnostics::legacy_unknown")]
121    pub freshness: CodeRepositoryFreshnessDiagnostics,
122    pub request: CodeRetrievalRequest,
123    pub results: Vec<CodeRetrievalHit>,
124    #[serde(skip_serializing_if = "Option::is_none")]
125    pub degraded_reason: Option<String>,
126}
127
128/// Versioned, snapshot-bound repository graph neighborhood.
129#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
130pub struct RepositoryGraphNeighborhoodResponseV1 {
131    pub schema_version: u8,
132    pub metadata: ApiMetadata,
133    pub scope: CodeRepositoryScopeMetadata,
134    pub request: RepositoryGraphNeighborhoodRequest,
135    pub nodes: Vec<RepositoryGraphNode>,
136    pub edges: Vec<RepositoryGraphEdge>,
137    pub truncated: bool,
138}
139
140/// Code repository feature-flag graph response.
141#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
142pub struct CodeRepositoryFeatureFlagsResponse {
143    pub metadata: ApiMetadata,
144    pub scope: CodeRepositoryScopeMetadata,
145    #[serde(default = "CodeRepositoryFreshnessDiagnostics::legacy_unknown")]
146    pub freshness: CodeRepositoryFreshnessDiagnostics,
147    pub request: CodeFeatureFlagRequest,
148    pub flags: Vec<CodeFeatureFlagGraph>,
149    #[serde(skip_serializing_if = "Option::is_none")]
150    pub degraded_reason: Option<String>,
151}
152
153/// Framework-aware component and template graph response.
154#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
155pub struct CodeRepositoryFrameworkGraphResponse {
156    pub metadata: ApiMetadata,
157    pub scope: CodeRepositoryScopeMetadata,
158    #[serde(default = "CodeRepositoryFreshnessDiagnostics::legacy_unknown")]
159    pub freshness: CodeRepositoryFreshnessDiagnostics,
160    pub request: FrameworkGraphRequest,
161    pub graph: FrameworkGraph,
162    #[serde(skip_serializing_if = "Option::is_none")]
163    pub degraded_reason: Option<String>,
164}
165
166/// Code repository impact response.
167#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
168pub struct CodeRepositoryImpactResponse {
169    pub metadata: ApiMetadata,
170    pub scope: CodeRepositoryScopeMetadata,
171    pub request: CodeImpactRequest,
172    pub path_groups: CodeImpactPathGroups,
173    pub results: Vec<CodeRetrievalHit>,
174}
175
176/// Code repository status response.
177#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
178pub struct CodeRepositoryStatusResponse {
179    pub metadata: ApiMetadata,
180    pub status: CodeRepositoryStatus,
181    #[serde(skip_serializing_if = "Option::is_none")]
182    pub active_task: Option<CodeIndexTaskRecord>,
183    #[serde(skip_serializing_if = "Option::is_none")]
184    pub checkpoint: Option<CodeIndexCheckpoint>,
185    pub retention: CodeScopeRetentionSummary,
186}
187
188/// Code repository operations report response.
189#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
190pub struct CodeRepositoryReportResponse {
191    pub metadata: ApiMetadata,
192    pub scope: CodeRepositoryScopeMetadata,
193    pub report: CodeRepositoryReport,
194}
195
196/// Repository-scoped software global model projection response.
197#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
198pub struct SoftwareGlobalResponse {
199    pub metadata: ApiMetadata,
200    pub scope: CodeRepositoryScopeMetadata,
201    pub request: SoftwareGlobalRequest,
202    pub status: SoftwareGlobalStatus,
203    pub components: Vec<SoftwareComponent>,
204    pub dependency_usages: Vec<SoftwareDependencyUsage>,
205    pub sdk_usages: Vec<SoftwareSdkUsage>,
206    pub files: Vec<SoftwareFile>,
207    pub topics: Vec<SoftwareTopic>,
208    pub relationships: Vec<SoftwareRelationship>,
209    pub build_targets: Vec<SoftwareBuildTarget>,
210    pub iac_resources: Vec<SoftwareIacResource>,
211    pub design_elements: Vec<SoftwareDesignElement>,
212    #[serde(default)]
213    pub entities: Vec<SoftwareEntity>,
214    #[serde(default)]
215    pub statements: Vec<SoftwareStatement>,
216    #[serde(default)]
217    pub diagnostics: Vec<SoftwareShapeDiagnostic>,
218}
219
220/// A standard-profile export produced from the same snapshot-bound software read model.
221#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
222pub struct SoftwareGlobalExportResponse {
223    pub metadata: ApiMetadata,
224    pub scope: CodeRepositoryScopeMetadata,
225    pub status: SoftwareGlobalStatus,
226    pub profile: SoftwareExportProfile,
227    pub media_type: String,
228    pub document: serde_json::Value,
229}
230
231/// Repository-scoped authored business knowledge projection response.
232#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
233pub struct BusinessKnowledgeQueryResponse {
234    pub metadata: ApiMetadata,
235    pub scope: CodeRepositoryScopeMetadata,
236    pub request: BusinessKnowledgeQueryRequest,
237    pub status: BusinessKnowledgeStatus,
238    pub resolution: BusinessKnowledgeResolution,
239    pub domains: Vec<BusinessDomain>,
240    pub terms: Vec<BusinessTerm>,
241}