Rename SolveCraft to SolidCraft everywhere, with compatibility shims (#389)
* WIP deep rename (not for push) * WIP2 * WIP3 * WIP4 wxs fix * rustfmt * Rename the remaining identifiers in merged crash-report code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RjGw4gA5ZvKrU8MQP6sBgT --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
27415e4dd7
commit
296683229d
464 files changed
+3408
-2956
No files matched your search
+17
-17
@@ -3,8 +3,8 @@
|
||||
//!
|
||||
//! - **Panics** are caught by a hook. One inside a command becomes a report with the design as
|
||||
//! it was before the command and the command itself, so `solidcraft-cli run replay.json --in
|
||||
//! design.solvecraft` reproduces it. Panics the third-party kernel raises (and
|
||||
//! `solvecraft_kernel::guard` turns into errors) are reported the same way, marked recovered.
|
||||
//! design.solidcraft` reproduces it. Panics the third-party kernel raises (and
|
||||
//! `solidcraft_kernel::guard` turns into errors) are reported the same way, marked recovered.
|
||||
//! - **Crashes no hook sees** (an abort, a stack overflow, a segfault, the process being killed)
|
||||
//! are found at the next start: every running app keeps a small, locked command journal; a
|
||||
//! journal nobody holds any more belongs to an app that died. Its report carries the design
|
||||
@@ -18,7 +18,7 @@
|
||||
//! reports, [`MAX_TOTAL_BYTES`] on disk, nothing older than [`MAX_AGE_DAYS`] days.
|
||||
//!
|
||||
//! Reports are folders `crashes/<time>-<signature>/` holding `report.json`, and when known
|
||||
//! `design.solvecraft` and `replay.json`. Nothing is ever sent anywhere.
|
||||
//! `design.solidcraft` and `replay.json`. Nothing is ever sent anywhere.
|
||||
|
||||
use std::backtrace::Backtrace;
|
||||
use std::cell::{Cell, RefCell};
|
||||
@@ -30,7 +30,7 @@ use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering};
|
||||
use std::sync::{Mutex, OnceLock};
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use solvecraft_doc::Document;
|
||||
use solidcraft_doc::Document;
|
||||
|
||||
use crate::Session;
|
||||
|
||||
@@ -53,7 +53,7 @@ const RECENT: usize = 32;
|
||||
const MAX_FRAMES: usize = 60;
|
||||
const MAX_MESSAGE: usize = 2000;
|
||||
/// The report format.
|
||||
pub const FORMAT: &str = "solvecraft-crash/1";
|
||||
pub const FORMAT: &str = "solidcraft-crash/1";
|
||||
|
||||
/// What the app is (shown in every report).
|
||||
#[derive(Clone, Debug, Default)]
|
||||
@@ -79,7 +79,7 @@ pub struct Summary {
|
||||
pub version: String,
|
||||
/// The report's folder.
|
||||
pub path: String,
|
||||
/// `replay.json` and `design.solvecraft` are there: the crash can be replayed.
|
||||
/// `replay.json` and `design.solidcraft` are there: the crash can be replayed.
|
||||
pub replayable: bool,
|
||||
}
|
||||
|
||||
@@ -114,16 +114,16 @@ pub fn enabled() -> bool {
|
||||
STATE.get().is_some()
|
||||
}
|
||||
|
||||
/// The crash folder, next to the recovery folder. `SOLVECRAFT_CRASH_DIR` overrides it.
|
||||
/// The crash folder, next to the recovery folder. `SOLIDCRAFT_CRASH_DIR` overrides it.
|
||||
pub fn default_dir() -> Option<PathBuf> {
|
||||
if let Some(s) = STATE.get() {
|
||||
return Some(s.dir.clone());
|
||||
}
|
||||
// Tests never touch the user's real crash folder.
|
||||
if cfg!(test) {
|
||||
return Some(std::env::temp_dir().join(format!("solvecraft-test-crashes-{}", std::process::id())));
|
||||
return Some(std::env::temp_dir().join(format!("solidcraft-test-crashes-{}", std::process::id())));
|
||||
}
|
||||
if let Some(d) = std::env::var_os("SOLVECRAFT_CRASH_DIR").filter(|d| !d.is_empty()) {
|
||||
if let Some(d) = solidcraft_geom::env::var_os("CRASH_DIR").filter(|d| !d.is_empty()) {
|
||||
return Some(PathBuf::from(d));
|
||||
}
|
||||
crate::recovery::default_dir().and_then(|d| d.parent().map(|p| p.join("crashes")))
|
||||
@@ -355,7 +355,7 @@ fn hook(info: &std::panic::PanicHookInfo<'_>) -> bool {
|
||||
let message = limited(info.payload_as_str().unwrap_or("(not a text message)"), MAX_MESSAGE);
|
||||
let location = info.location().map_or_else(|| "(unknown)".to_string(), |l| format!("{}:{}", l.file(), l.line()));
|
||||
let sig = signature(&location, &message);
|
||||
let recovered = solvecraft_kernel::guarded();
|
||||
let recovered = solidcraft_kernel::guarded();
|
||||
let in_command = IN_COMMAND.with(Cell::get) > 0;
|
||||
// Already reported (this run or before): count it, nothing else.
|
||||
let repeat = match state.known.lock() {
|
||||
@@ -467,7 +467,7 @@ pub(crate) fn command_done(
|
||||
let pending: Vec<Panic> = PENDING.with(|q| std::mem::take(&mut *q.borrow_mut()));
|
||||
for p in pending {
|
||||
let kind = if p.recovered { "kernel_panic_recovered" } else { "command_panic" };
|
||||
let design = solvecraft_io::write_design(before);
|
||||
let design = solidcraft_io::write_design(before);
|
||||
let replay = json!({ "commands": [{ "command": id, "params": params }] });
|
||||
let recent = if journaled { state.journal_path.as_deref().map(|p| read_journal(p).recent).unwrap_or_default() } else { Vec::new() };
|
||||
let extra = Extra {
|
||||
@@ -786,8 +786,8 @@ fn write_report(state: &State, kind: &str, p: Option<&Panic>, extra: Extra) -> O
|
||||
let mut notes = extra.notes;
|
||||
if let Some(d) = &extra.design {
|
||||
if d.len() <= MAX_DESIGN_BYTES {
|
||||
if solvecraft_io::write_atomic(&folder.join("design.solvecraft"), d, false).is_ok() {
|
||||
files.insert("design".into(), json!("design.solvecraft"));
|
||||
if solidcraft_io::write_atomic(&folder.join("design.solidcraft"), d, false).is_ok() {
|
||||
files.insert("design".into(), json!("design.solidcraft"));
|
||||
}
|
||||
} else {
|
||||
notes.push(format!("the design is larger than {} MB and was not copied", MAX_DESIGN_BYTES >> 20));
|
||||
@@ -795,7 +795,7 @@ fn write_report(state: &State, kind: &str, p: Option<&Panic>, extra: Extra) -> O
|
||||
}
|
||||
if let Some(r) = &extra.replay
|
||||
&& let Ok(b) = serde_json::to_vec_pretty(r)
|
||||
&& solvecraft_io::write_atomic(&folder.join("replay.json"), &b, false).is_ok()
|
||||
&& solidcraft_io::write_atomic(&folder.join("replay.json"), &b, false).is_ok()
|
||||
{
|
||||
files.insert("replay".into(), json!("replay.json"));
|
||||
}
|
||||
@@ -828,7 +828,7 @@ fn write_report(state: &State, kind: &str, p: Option<&Panic>, extra: Extra) -> O
|
||||
"notes": notes,
|
||||
});
|
||||
let bytes = serde_json::to_vec_pretty(&report).ok()?;
|
||||
solvecraft_io::write_atomic(&folder.join("report.json"), &bytes, false).ok()?;
|
||||
solidcraft_io::write_atomic(&folder.join("report.json"), &bytes, false).ok()?;
|
||||
prune(&state.dir, t);
|
||||
return Some(id);
|
||||
}
|
||||
@@ -846,7 +846,7 @@ fn bump(dir: &Path, id: &str, n: u64) {
|
||||
v["count"] = json!(count);
|
||||
v["last_seen"] = json!(utc(now()));
|
||||
if let Ok(b) = serde_json::to_vec_pretty(&v) {
|
||||
let _ = solvecraft_io::write_atomic(&path, &b, false);
|
||||
let _ = solidcraft_io::write_atomic(&path, &b, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -951,7 +951,7 @@ pub fn read(dir: &Path, id: &str) -> std::result::Result<Value, String> {
|
||||
let folder = dir.join(id);
|
||||
let mut v = read_report_file(&folder.join("report.json")).ok_or_else(|| format!("no crash report `{id}`"))?;
|
||||
v["path"] = json!(folder.to_string_lossy());
|
||||
for (k, f) in [("design_path", "design.solvecraft"), ("replay_path", "replay.json")] {
|
||||
for (k, f) in [("design_path", "design.solidcraft"), ("replay_path", "replay.json")] {
|
||||
if folder.join(f).is_file() {
|
||||
v[k] = json!(folder.join(f).to_string_lossy());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user