1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
//! `software.release.*` ingestion.
//!
//! Select each product default/latest version from deps.dev, fetch one artifact
//! from its ecosystem registry, and publish project/manifest/version/channel/
//! status records plus local links.
//!
//! The former `sync_one` monolith is split by concern: [`planner`] selects a
//! version, [`versioning`] normalizes versions, [`records`] builds wire shapes
//! and rkeys, [`service`] orchestrates publishing, and [`source`] holds the
//! Phase 2+ source adapter contract.
pub mod artifact;
pub mod artifacts;
pub mod cve_links;
pub mod history;
pub mod host;
pub mod http;
pub mod metadata;
pub mod planner;
pub mod records;
pub mod service;
pub mod source;
pub mod sources;
pub mod status;
pub mod versioning;
pub use artifacts::{
ArtifactCounters, ArtifactError, ArtifactMirror, ArtifactResolver, NoopMirror, S3Mirror,
};
pub use history::{
ArtifactProvider, HistoryConfig as HistoryJobConfig, HistoryCounters as HistoryJobCounters,
};
pub use planner::select_release;
pub use service::{
build_history_source, sync_affected, sync_affected_with_cursor,
sync_affected_with_cursor_resolver, sync_all_with_http, sync_all_with_http_resolver,
sync_extras, sync_extras_with_cursor, sync_extras_with_cursor_resolver, sync_history,
sync_history_mode, sync_releases, sync_releases_with_http, sync_releases_with_http_cursor,
sync_releases_with_http_cursor_resolver, sync_releases_with_http_resolver,
};
use std::path::PathBuf;
use serde::Serialize;
#[derive(Debug, Clone)]
pub struct ReleaseConfig {
pub repo_did: String,
pub limit: usize,
pub recheck_seconds: f64,
}
/// Configuration for `--release-mode affected`.
#[derive(Debug, Clone)]
pub struct AffectedConfig {
pub repo_did: String,
pub limit: usize,
pub recheck_seconds: f64,
/// Purl types to include; empty means every type.
pub ecosystems: Vec<String>,
/// Source names or purl types to include; empty means every source.
pub sources: Vec<String>,
/// Reserved for a future concurrent source pass; affected runs in order.
pub concurrency: usize,
pub osv_online: bool,
/// When set, OSV advisories are loaded from this directory, not the API.
pub osv_bulk_dir: Option<PathBuf>,
}
/// Rotation cursor for `--release-limit` pages.
///
/// The candidate query orders least-recently-checked first and pages strictly
/// after `after_slug`, so equal-timestamp groups rotate instead of starving
/// projects that sort later. The integration layer persists this between
/// cycles; callers that do not pass a cursor still get the first page.
#[derive(Debug, Clone, Default)]
pub struct ReleaseCursor {
pub after_slug: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ReleaseCounters {
pub projects_checked: u64,
pub projects_created: u64,
pub versions_created: u64,
pub channels_created: u64,
pub statuses_created: u64,
pub unchanged: u64,
pub skipped: u64,
/// Candidates with no release-ecosystem purl (OS/distro-only projects).
pub unsupported_no_purl: u64,
pub failures: u64,
}
/// `--release-mode affected` cycle counters.
#[derive(Debug, Clone, Default, Serialize)]
pub struct AffectedCounters {
pub projects_checked: u64,
pub projects_linked: u64,
pub versions_planned: u64,
pub versions_created: u64,
pub versions_label_only: u64,
pub cves_linked: u64,
pub unchanged: u64,
pub skipped: u64,
pub failures: u64,
pub unsupported: u64,
}
/// `--release-mode history`: one candidate page per call.
#[derive(Debug, Clone, Default)]
pub struct HistoryModeConfig {
pub repo_did: String,
/// Candidates inspected per cycle; `0` means all.
pub limit: usize,
pub recheck_seconds: f64,
/// Purl types to include; empty means every type.
pub ecosystems: Vec<String>,
/// Source names or purl types to include; empty means every source.
pub sources: Vec<String>,
/// Versions processed per project per cycle; `0` means all.
pub history_limit: usize,
/// Projects enumerated concurrently; clamped to at least 1.
pub concurrency: usize,
/// Artifact byte cap; `0` means no cap.
pub artifact_max_bytes: u64,
/// S3 artifact mirror; `None` leaves the no-op mirror.
pub artifact_s3: Option<crate::config::S3Config>,
/// Test/mirror seam for sources that expose a configurable base URL.
pub source_base_url: Option<String>,
pub github_token: Option<String>,
pub gitlab_token: Option<String>,
pub gitee_token: Option<String>,
}
/// One project's history pass.
#[derive(Debug, Clone)]
pub struct HistoryProjectConfig {
pub repo_did: String,
pub project_slug: String,
pub purl: String,
pub source: String,
/// Versions processed in this call; `0` means all.
pub limit: usize,
/// Artifact byte cap; `0` means no cap.
pub max_bytes: u64,
}
/// `--release-mode history` cycle counters.
#[derive(Debug, Clone, Default, Serialize)]
pub struct HistoryModeCounters {
pub projects_checked: u64,
pub projects_skipped: u64,
pub unsupported: u64,
pub enqueued: u64,
pub processed: u64,
pub versions_created: u64,
pub manifests_created: u64,
pub skipped: u64,
pub failed: u64,
pub reused: u64,
}
impl HistoryModeCounters {
pub fn add_jobs(&mut self, counters: &history::HistoryCounters) {
self.enqueued += counters.enqueued;
self.processed += counters.processed;
self.versions_created += counters.versions_created;
self.manifests_created += counters.manifests_created;
self.skipped += counters.skipped;
self.failed += counters.failed;
self.reused += counters.reused;
}
}
/// Configuration for `--release-mode extras`.
#[derive(Clone)]
pub struct ExtrasConfig {
pub repo_did: String,
/// Candidates inspected per cycle; `0` means all.
pub limit: usize,
pub recheck_seconds: f64,
/// Purl types to include; empty means every type.
pub ecosystems: Vec<String>,
/// Source names or purl types to include; empty means every source.
pub sources: Vec<String>,
/// Artifact byte cap; `0` means no cap.
pub artifact_max_bytes: u64,
/// Fetch and plan through the source, but never write to the PDS.
pub dry_run: bool,
/// Base-URL override for adapters with a configurable endpoint.
pub source_base_url: Option<String>,
pub github_token: Option<String>,
pub gitlab_token: Option<String>,
pub gitee_token: Option<String>,
}
/// `--release-mode extras` cycle counters.
#[derive(Debug, Clone, Default, Serialize)]
pub struct ExtrasCounters {
pub projects_checked: u64,
pub projects_created: u64,
pub versions_created: u64,
pub manifests_created: u64,
pub statuses_created: u64,
pub unchanged: u64,
pub skipped: u64,
pub unsupported: u64,
pub failures: u64,
}
/// `--release-mode all`: one cycle of every release mode with separate
/// counters. History is present only when `--release-history-limit > 0`.
#[derive(Debug, Clone, Default)]
pub struct AllModeCounters {
pub latest: ReleaseCounters,
pub affected: AffectedCounters,
pub history: Option<HistoryModeCounters>,
pub extras: ExtrasCounters,
pub artifacts: artifacts::ArtifactCounters,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SelectedRelease {
pub raw: String,
pub version: String,
pub deprecated: bool,
pub reason: String,
}