Skip to content

Commit 58bfc0b

Browse files
Xiiiingyyjeqhc
andauthored
refactor: isolate build identity and final-result snapshot retention (#769)
Co-authored-by: yyjeqhc <1772413353@qq.com>
1 parent 399fa74 commit 58bfc0b

26 files changed

Lines changed: 711 additions & 125 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ jobs:
207207
run: |
208208
bash scripts/workspace_boundary_check.sh --self-test
209209
bash scripts/workspace_boundary_check.sh
210+
- name: Check build identity and incremental boundary
211+
run: PYTHONDONTWRITEBYTECODE=1 python3 -m unittest scripts.tests.test_build_identity
210212
- name: Check formatting
211213
run: cargo fmt --all -- --check
212214
- name: Ensure test inventory dependency

‎Cargo.lock‎

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[workspace]
22
members = [
33
"crates/webcodex-admin",
4+
"crates/webcodex-build-info",
45
"crates/webcodex-browser",
56
"crates/webcodex-computer",
67
"crates/webcodex-code-mode",
@@ -54,6 +55,7 @@ path = "src/bin/webcodex-server.rs"
5455

5556
[dependencies]
5657
webcodex-admin = { path = "crates/webcodex-admin" }
58+
webcodex-build-info = { path = "crates/webcodex-build-info" }
5759
webcodex-code-mode = { path = "crates/webcodex-code-mode", optional = true }
5860
webcodex-runner-config = { path = "crates/webcodex-runner-config" }
5961
webcodex-runner-registry = { path = "crates/webcodex-runner-registry" }

‎apps/desktop/src-tauri/Cargo.lock‎

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎apps/desktop/src-tauri/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ tokio = { version = "1", features = ["fs", "io-util", "macros", "process", "rt-m
3131
url = "2"
3232
uuid = { version = "1", features = ["v4"] }
3333
webcodex-core = { path = "../../../crates/webcodex-core" }
34+
webcodex-build-info = { path = "../../../crates/webcodex-build-info" }
3435
webcodex-environment = { path = "../../../crates/webcodex-environment" }
3536
webcodex-process = { path = "../../../crates/webcodex-process" }
3637
webcodex-runner-config = { path = "../../../crates/webcodex-runner-config" }

‎apps/desktop/src-tauri/src/commands/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ pub async fn open_latest_release(state: State<'_, AppState>) -> DesktopResult<()
636636

637637
#[tauri::command]
638638
pub fn get_desktop_build_info() -> webcodex_core::desktop_runtime_contract::MachineBuildInfo {
639-
let mut info = webcodex_core::build_info::machine_build_info("webcodex-desktop");
639+
let mut info = webcodex_build_info::machine_build_info("webcodex-desktop");
640640
info.version = env!("CARGO_PKG_VERSION").to_string();
641641
info
642642
}

‎apps/desktop/src-tauri/src/diagnostics.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ pub fn report(
420420
}
421421
let safe_activity:Vec<_>=activity.iter().rev().take(25).map(|entry| json!({"sequence":entry.sequence,"timestamp_ms":entry.timestamp_ms,"level":entry.level,"event_kind":entry.event_kind})).collect();
422422
let connection_health:Vec<_>=snapshot.connections.profiles.iter().take(16).map(|p|json!({"lifecycle":p.runtime.lifecycle,"health":p.runtime.health,"ready":p.runtime.ready,"error_code":p.runtime.last_error})).collect();
423-
let mut desktop = webcodex_core::build_info::machine_build_info("webcodex-desktop");
423+
let mut desktop = webcodex_build_info::machine_build_info("webcodex-desktop");
424424
desktop.version = env!("CARGO_PKG_VERSION").into();
425425
json!({"schema_version":1,"desktop":safe_build(&desktop),
426426
"selected_runtime":{"source":match runtime.source {crate::runtime_selection::RuntimeSource::Bundled=>"bundled",_=>"custom"},

‎apps/desktop/src-tauri/src/runtime_selection.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ fn executable(path: &Path) -> bool {
185185
}
186186

187187
fn host_compatible(info: &MachineBuildInfo) -> bool {
188-
let arch = webcodex_core::build_info::current()
188+
let arch = webcodex_build_info::current()
189189
.architecture
190190
.unwrap_or(std::env::consts::ARCH);
191191
let os_matches = match std::env::consts::OS {

‎apps/desktop/src-tauri/src/runtime_selection/tests.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn fixture(changes: impl Fn(usize, &mut MachineBuildInfo)) -> PathBuf {
3737
.into_iter()
3838
.enumerate()
3939
{
40-
let mut info = webcodex_core::build_info::machine_build_info(name);
40+
let mut info = webcodex_build_info::machine_build_info(name);
4141
changes(index, &mut info);
4242
write_fixture_binary(&dir, name, &info);
4343
}
@@ -164,7 +164,7 @@ async fn an_ordinary_restart_rejects_replaced_custom_files_until_explicit_reappr
164164
let (_, resolved) = candidate(&dir).await;
165165
let approved_fingerprint = resolved.unwrap().fingerprint;
166166

167-
let mut replacement = webcodex_core::build_info::machine_build_info("webcodex-runner");
167+
let mut replacement = webcodex_build_info::machine_build_info("webcodex-runner");
168168
replacement.git_commit = Some("abcdef012345abcdef012345abcdef012345abcd".into());
169169
write_fixture_binary(&dir, "webcodex-runner", &replacement);
170170

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "webcodex-build-info"
3+
version.workspace = true
4+
license.workspace = true
5+
edition.workspace = true
6+
7+
# Checkout-dependent identity belongs beside composition, never below core or
8+
# domain crates. Keep the collector dependency-free and the public types in core.
9+
[dependencies]
10+
webcodex-core = { path = "../webcodex-core" }

0 commit comments

Comments
 (0)