diff --git a/rust/contracts/rust-core-api.md b/rust/contracts/rust-core-api.md index 2fd4d669..504143cc 100644 --- a/rust/contracts/rust-core-api.md +++ b/rust/contracts/rust-core-api.md @@ -399,6 +399,12 @@ stable error code and a user-facing message: } ``` +A panic inside a request does not cross the C ABI, where it would abort the +host process. The dispatcher catches it and returns `unknown` with details +`request_panicked` and the message `Core request failed unexpectedly`. Core +records the panic as `app.core.panic_interrupted`, with the request's method +and op, before it returns, so the host does not log the panic again. + ## Commands The MCP configuration and library commands were removed with the agent-facing MCP diff --git a/rust/crates/core/src/runtime/dispatcher.rs b/rust/crates/core/src/runtime/dispatcher.rs index 7ae39b2e..2a2cd218 100644 --- a/rust/crates/core/src/runtime/dispatcher.rs +++ b/rust/crates/core/src/runtime/dispatcher.rs @@ -104,7 +104,19 @@ fn execute(request: &str, document: Option<&str>) -> CoreResponse { }; // The trace spans every scope below and records once, after the final response. let trace = crate::runtime::request_trace::Request::begin(&parsed); - let response = execute_parsed(parsed, document); + let id = parsed.id.clone(); + let method = parsed.command.clone(); + // A panic here would otherwise unwind into the host and abort it; the + // boundary has already recorded it as app.core.panic_interrupted. + let response = + crate::runtime::panic_facts::request_boundary(&method, || execute_parsed(parsed, document)) + .unwrap_or_else(|| { + CoreResponse::failure( + id, + CoreError::new(ErrorCode::Unknown, "Core request failed unexpectedly") + .with_details("request_panicked"), + ) + }); trace.finish(&response); response } diff --git a/rust/crates/core/src/runtime/helper_failures.rs b/rust/crates/core/src/runtime/helper_failures.rs index 801d6d5e..7c4b9dda 100644 --- a/rust/crates/core/src/runtime/helper_failures.rs +++ b/rust/crates/core/src/runtime/helper_failures.rs @@ -8,9 +8,11 @@ use std::sync::Once; static INSTALL: Once = Once::new(); /// Every Core command and direct IDE/AskPass entry calls this before invoking -/// helpers or starting workers. Subsequent calls are cheap. +/// helpers or starting workers. Subsequent calls are cheap. The panic hook is +/// installed here too, because these are the entries that run Core code. pub(crate) fn install() { INSTALL.call_once(|| { + super::panic_facts::install(); lithe_git_host::failure_log::install_failure_sink(sink); lithe_ide_host::failure_log::install_failure_sink(sink); lithe_remote::failure_log::install_failure_sink(sink); diff --git a/rust/crates/core/src/runtime/mod.rs b/rust/crates/core/src/runtime/mod.rs index 56e8d06d..cacc7465 100644 --- a/rust/crates/core/src/runtime/mod.rs +++ b/rust/crates/core/src/runtime/mod.rs @@ -3,6 +3,7 @@ mod dispatcher; mod ffi; pub(crate) mod helper_failures; +pub(crate) mod panic_facts; pub(crate) mod request_trace; pub(crate) use dispatcher::execute_json; diff --git a/rust/crates/core/src/runtime/panic_facts.rs b/rust/crates/core/src/runtime/panic_facts.rs new file mode 100644 index 00000000..67a2458e --- /dev/null +++ b/rust/crates/core/src/runtime/panic_facts.rs @@ -0,0 +1,192 @@ +//! Records every Core panic as a catalog fact, and keeps a panic inside a +//! request from unwinding into the host. +//! +//! Core runs inside the host process. A panic that reaches the C ABI aborts +//! that process before the host's log writer drains any queued fact, so the +//! dispatcher runs each request inside [`request_boundary`], which turns a +//! panic into a failed response. Threads Core starts keep the standard +//! behavior: the panic unwinds that thread and its owner decides what happens +//! next. In both cases the hook installed here records one +//! `app.core.panic_interrupted` fact before unwinding starts, then runs the +//! hook that was installed before it, so the standard stderr report remains. + +use lithe_diagnostics::core_events; +use serde_json::{json, Value}; +use std::cell::RefCell; +use std::collections::BTreeMap; +use std::panic::{AssertUnwindSafe, PanicHookInfo}; +use std::sync::Once; + +const EVENT: &str = "app.core.panic_interrupted"; +static INSTALL: Once = Once::new(); + +thread_local! { + /// Method of the request this thread runs inside [`request_boundary`]. + static REQUEST: RefCell> = const { RefCell::new(None) }; +} + +/// Installs the recording hook once per process, in front of the hook that +/// was installed before it. Later calls are cheap. +pub(crate) fn install() { + INSTALL.call_once(|| { + let previous = std::panic::take_hook(); + std::panic::set_hook(Box::new(move |info| { + record(info); + previous(info); + })); + }); +} + +/// Runs one request so that a panic inside it returns `None` to the +/// dispatcher instead of unwinding across the C ABI. +pub(crate) fn request_boundary(method: &str, run: impl FnOnce() -> T) -> Option { + let enclosing = REQUEST.with(|request| request.replace(Some(method.to_owned()))); + // Asserting unwind safety is sound here: the closure's captures are + // consumed by the panicking request and never observed afterwards. State + // shared with later requests sits behind locks; one the panic poisoned + // either recovers or fails the next request the same way, and that panic + // is caught and recorded too. + let result = std::panic::catch_unwind(AssertUnwindSafe(run)); + REQUEST.with(|request| request.replace(enclosing)); + result.ok() +} + +/// Runs inside the panic hook, so it must neither wait for a lock the +/// panicking thread may hold nor panic: a second panic aborts the process. +fn record(info: &PanicHookInfo<'_>) { + let op = lithe_request_context::trace::try_current().and_then(|context| context.op); + core_events::record_without_waiting(EVENT, fields(info, current_method()), op); +} + +fn current_method() -> Option { + REQUEST + .try_with(|request| request.try_borrow().ok().and_then(|method| method.clone())) + .ok() + .flatten() +} + +fn fields(info: &PanicHookInfo<'_>, method: Option) -> BTreeMap { + let payload = info.payload(); + let message = payload + .downcast_ref::<&str>() + .copied() + .or_else(|| payload.downcast_ref::().map(String::as_str)) + .unwrap_or("Panic payload is not text"); + let boundary = if method.is_some() { + "request" + } else { + "thread" + }; + let mut fields = BTreeMap::from([ + ("boundary".to_string(), json!(boundary)), + ("panic".to_string(), json!(message)), + ]); + if let Some(location) = info.location() { + fields.insert( + "location".into(), + json!(format!( + "{}:{}:{}", + location.file(), + location.line(), + location.column() + )), + ); + } + if let Some(method) = method.as_deref().and_then(super::request_trace::token) { + fields.insert("method".into(), json!(method)); + } + fields +} + +#[cfg(test)] +mod tests { + use super::*; + use lithe_diagnostics::core_events::{capture, CoreEvent}; + + fn panic_facts(events: Vec) -> Vec { + events + .into_iter() + .filter(|event| event.event == EVENT) + .collect() + } + + #[test] + fn a_panicking_request_is_recorded_and_returns_none() { + install(); + let (result, events) = capture::run(false, || { + request_boundary("git.write", || -> i32 { panic!("request broke") }) + }); + assert!(result.is_none()); + let facts = panic_facts(events); + assert_eq!(facts.len(), 1); + let fact = &facts[0]; + assert_eq!(fact.channel, "app"); + assert_eq!(fact.fields["boundary"], json!("request")); + assert_eq!(fact.fields["method"], json!("git.write")); + assert_eq!(fact.fields["panic"], json!("request broke")); + assert!(fact.fields["location"] + .as_str() + .unwrap() + .contains("panic_facts.rs:")); + assert_eq!(current_method(), None); + } + + #[test] + fn a_request_that_returns_keeps_its_value_and_records_nothing() { + install(); + let (result, events) = capture::run(false, || request_boundary("git.write", || 7)); + assert_eq!(result, Some(7)); + assert!(panic_facts(events).is_empty()); + } + + #[test] + fn a_panic_outside_a_request_is_recorded_as_thread() { + install(); + let (result, events) = capture::run(false, || { + std::panic::catch_unwind(|| panic!("{} broke", String::from("worker"))) + }); + assert!(result.is_err()); + let facts = panic_facts(events); + assert_eq!(facts.len(), 1); + assert_eq!(facts[0].fields["boundary"], json!("thread")); + assert_eq!(facts[0].fields["panic"], json!("worker broke")); + assert!(!facts[0].fields.contains_key("method")); + } + + #[test] + fn a_panic_payload_that_is_not_text_gets_a_fixed_message() { + install(); + let (_, events) = capture::run(false, || { + std::panic::catch_unwind(|| std::panic::panic_any(42_u8)) + }); + let facts = panic_facts(events); + assert_eq!(facts.len(), 1); + assert_eq!(facts[0].fields["panic"], json!("Panic payload is not text")); + } + + #[test] + fn nested_requests_restore_the_enclosing_method() { + install(); + let (_, events) = capture::run(false, || { + request_boundary("workspace.repositories", || { + assert!(request_boundary("git.write", || panic!("inner")).is_none()); + assert_eq!(current_method().as_deref(), Some("workspace.repositories")); + }) + }); + let facts = panic_facts(events); + assert_eq!(facts.len(), 1); + assert_eq!(facts[0].fields["method"], json!("git.write")); + assert_eq!(current_method(), None); + } + + #[test] + fn a_method_that_is_not_a_token_is_left_out() { + install(); + let (_, events) = capture::run(false, || { + request_boundary("not a token", || panic!("odd method")) + }); + let facts = panic_facts(events); + assert_eq!(facts[0].fields["boundary"], json!("request")); + assert!(!facts[0].fields.contains_key("method")); + } +} diff --git a/rust/crates/core/src/runtime/request_trace.rs b/rust/crates/core/src/runtime/request_trace.rs index 9fe5e3cb..22290f37 100644 --- a/rust/crates/core/src/runtime/request_trace.rs +++ b/rust/crates/core/src/runtime/request_trace.rs @@ -217,7 +217,7 @@ fn request_path(payload: &Value) -> Option { } /// Catalog token shape; anything else is omitted rather than failing the record. -fn token(value: &str) -> Option { +pub(crate) fn token(value: &str) -> Option { (!value.is_empty() && value.len() <= 64 && value diff --git a/rust/crates/diagnostics/src/catalog_generated.rs b/rust/crates/diagnostics/src/catalog_generated.rs index b4819533..59af4d58 100644 --- a/rust/crates/diagnostics/src/catalog_generated.rs +++ b/rust/crates/diagnostics/src/catalog_generated.rs @@ -45,6 +45,21 @@ pub static EVENTS: &[EventMetadata] = &[ rate: 60, owner: "lithe-core", }, + EventMetadata { + id: "app.core.panic_interrupted", + channel: "app", + level: LogLevel::Error, + message: "Core code panicked at the {boundary} boundary", + fields: &[ + FieldMetadata { name: "boundary", field_type: FieldType::Token, required: true, description: "Where the panic ends: request when the dispatcher turned it into a failed response and Core kept running, thread when it unwinds a Core thread whose owner decides what happens next", reason: None }, + FieldMetadata { name: "location", field_type: FieldType::Text, required: false, description: "Source file, line and column the compiler attached to the panic", reason: Some("The compiler reports the panic site as a source path with line and column; dependency paths can be absolute, so Core redacts the text and caps it at 1 KiB instead of treating it as a stable identifier") }, + FieldMetadata { name: "method", field_type: FieldType::Token, required: false, description: "Core protocol method the request was running when boundary is request, e.g. git.write", reason: None }, + FieldMetadata { name: "panic", field_type: FieldType::Text, required: true, description: "Panic message from the Rust payload, or a fixed note when the payload is not text", reason: Some("A Rust panic message is free text written at the panic site, often with the Debug output of an error, and has no stable code; keep its wording after Core redaction and the 1 KiB cap") }, + ], + span: None, + rate: 60, + owner: "lithe-core", + }, EventMetadata { id: "app.core.request.failed", channel: "app/core", @@ -205,6 +220,20 @@ pub static EVENTS: &[EventMetadata] = &[ rate: 60, owner: "Lithe", }, + EventMetadata { + id: "app.runtime.panic_interrupted", + channel: "app", + level: LogLevel::Error, + message: "Recovered a panic at {boundary}", + fields: &[ + FieldMetadata { name: "boundary", field_type: FieldType::Token, required: true, description: "Recover site: viva: followed by the UI framework boundary such as viva:darwin:appkit-callback, or core:events-observer and core:log-waker for Core callbacks", reason: None }, + FieldMetadata { name: "panic", field_type: FieldType::Text, required: true, description: "Panic value as text, as the recovering boundary received it", reason: Some("A recovered Go panic value is arbitrary text with no stable code; keep its wording so the failing check can be found, after Core redaction and the 1 KiB cap") }, + FieldMetadata { name: "stack", field_type: FieldType::Text, required: false, description: "Frames of the panicking goroutine from the panic call outward, joined on one line", reason: Some("A Go stack trace has no structured equivalent; the host keeps only the frames after the panic call as function file:line pairs with base file names, and Core redacts and caps the text at 1 KiB") }, + ], + span: None, + rate: 60, + owner: "Lithe", + }, EventMetadata { id: "app.search.directory_skipped", channel: "app", @@ -218,6 +247,45 @@ pub static EVENTS: &[EventMetadata] = &[ rate: 60, owner: "lithe-core", }, + EventMetadata { + id: "app.session.close_missing", + channel: "app", + level: LogLevel::Warn, + message: "Previous session ended without closing its log", + fields: &[ + FieldMetadata { name: "session", field_type: FieldType::Path, required: true, description: "Log directory of the session that was killed, force quit or stopped by a native crash before closing its log", reason: None }, + ], + span: None, + rate: 60, + owner: "Lithe", + }, + EventMetadata { + id: "app.session.crash_capture_failed", + channel: "app", + level: LogLevel::Warn, + message: "Crash capture failed at {stage}", + fields: &[ + FieldMetadata { name: "error", field_type: FieldType::Error, required: true, description: "Filesystem or runtime error of that step", reason: None }, + FieldMetadata { name: "stage", field_type: FieldType::Token, required: true, description: "Step that failed: create when this session's crash file could not be made, so a fatal crash of this session is not recorded; claim when a previous session's crash file could not be read or removed; release when Close could not remove this session's file, so the next start reports this session as not closed", reason: None }, + ], + span: None, + rate: 60, + owner: "Lithe", + }, + EventMetadata { + id: "app.session.previous_interrupted", + channel: "app", + level: LogLevel::Error, + message: "Previous session ended in a crash", + fields: &[ + FieldMetadata { name: "panic", field_type: FieldType::Text, required: true, description: "First line the Go runtime printed when the process died, such as panic: or fatal error:", reason: Some("The Go runtime prints the cause of a fatal crash only as text in its crash output; keep the first line after Core redaction and the 1 KiB cap") }, + FieldMetadata { name: "session", field_type: FieldType::Path, required: true, description: "Log directory of the session that crashed, so its last records can be read next to this one", reason: None }, + FieldMetadata { name: "stack", field_type: FieldType::Text, required: false, description: "Frames of the goroutine that crashed, from its panic call outward, joined on one line", reason: Some("A Go stack trace has no structured equivalent; the host keeps only the frames after the panic call as function file:line pairs with base file names, and Core redacts and caps the text at 1 KiB") }, + ], + span: None, + rate: 60, + owner: "Lithe", + }, EventMetadata { id: "app.session.started", channel: "app", @@ -329,6 +397,18 @@ pub static EVENTS: &[EventMetadata] = &[ rate: 60, owner: "Lithe", }, + EventMetadata { + id: "app.window.loop_failed", + channel: "app", + level: LogLevel::Error, + message: "Window loop stopped with an error", + fields: &[ + FieldMetadata { name: "error", field_type: FieldType::Error, required: true, description: "Error the UI framework returned when its window loop ended for a reason other than a recovered panic", reason: None }, + ], + span: None, + rate: 60, + owner: "Lithe", + }, EventMetadata { id: "app.workspace.directory_skipped", channel: "app", diff --git a/rust/crates/diagnostics/src/core_events.rs b/rust/crates/diagnostics/src/core_events.rs index 537acbbf..59a215c1 100644 --- a/rust/crates/diagnostics/src/core_events.rs +++ b/rust/crates/diagnostics/src/core_events.rs @@ -122,6 +122,64 @@ pub fn record( Ok(()) } +/// Records like [`record`], but never waits for a lock. A panic hook runs on a +/// thread that may already hold the queue or waker lock, and waiting there +/// would hang the process instead of reporting the panic. A fact that fails +/// validation counts as dropped; when a lock stays busy the fact is lost +/// without a count, because counting needs the same lock. +pub fn record_without_waiting(event: &str, fields: BTreeMap, op: Option) { + let fact = prepare(event, fields, op); + #[cfg(any(test, feature = "test-support"))] + let fact = match fact { + Ok(fact) => match capture::divert(fact) { + Some(fact) => Ok(fact), + None => return, + }, + Err(error) => Err(error), + }; + let Some(mut queue) = lock_without_waiting(QUEUE.get_or_init(Mutex::default)) else { + return; + }; + match fact { + Ok(fact) => queue.record(fact), + Err(_) => queue.dropped = queue.dropped.saturating_add(1), + } + drop(queue); + wake_without_waiting(); +} + +/// Tries a lock for a bounded number of yields. Ordinary holders keep these +/// locks for one queue operation or one host callback, so they release them +/// well within the budget; a lock still held afterwards belongs to the +/// panicking thread itself. +fn lock_without_waiting(mutex: &Mutex) -> Option> { + const ATTEMPTS: usize = 1_000; + for _ in 0..ATTEMPTS { + match mutex.try_lock() { + Ok(guard) => return Some(guard), + Err(std::sync::TryLockError::Poisoned(poisoned)) => return Some(poisoned.into_inner()), + Err(std::sync::TryLockError::WouldBlock) => std::thread::yield_now(), + } + } + None +} + +/// [`wake`] for [`record_without_waiting`]: a signal it cannot deliver is +/// handed back, so the next recorded fact raises it again. +fn wake_without_waiting() { + if WAKE_REQUESTED.swap(true, Ordering::AcqRel) { + return; + } + let Some(waker) = lock_without_waiting(&WAKER) else { + WAKE_REQUESTED.store(false, Ordering::Release); + return; + }; + if let Some(waker) = *waker { + // SAFETY: as in `wake`; holding WAKER serializes the call with removal. + unsafe { (waker.callback)(waker.context as *mut c_void) } + } +} + fn queue() -> MutexGuard<'static, CoreEventQueue> { QUEUE .get_or_init(Mutex::default) @@ -453,6 +511,47 @@ mod tests { assert_eq!(queue.drain().dropped, 0); } + #[test] + fn lock_without_waiting_gives_up_on_a_held_lock_and_takes_a_poisoned_one() { + let mutex = Mutex::new(1); + { + let _held = mutex.lock().unwrap(); + assert!(lock_without_waiting(&mutex).is_none()); + } + assert_eq!(*lock_without_waiting(&mutex).unwrap(), 1); + let poisoned = std::sync::Arc::new(Mutex::new(2)); + let holder = poisoned.clone(); + let _ = std::thread::spawn(move || { + let _guard = holder.lock().unwrap(); + panic!("poison the test lock"); + }) + .join(); + assert!(poisoned.is_poisoned()); + assert_eq!(*lock_without_waiting(&poisoned).unwrap(), 2); + } + + #[test] + fn record_without_waiting_normalizes_like_record() { + let ((), events) = capture::run(false, || { + record_without_waiting( + "app.core.panic_interrupted", + BTreeMap::from([ + ("boundary".into(), json!("thread")), + ("panic".into(), json!("index out of bounds\nlen is 0")), + ]), + Some("op-1".into()), + ); + }); + assert_eq!(events.len(), 1); + assert_eq!(events[0].event, "app.core.panic_interrupted"); + assert_eq!(events[0].level, LogLevel::Error); + assert_eq!(events[0].op.as_deref(), Some("op-1")); + assert_eq!( + events[0].fields["panic"], + json!("index out of boundslen is 0") + ); + } + #[test] fn queue_rejects_non_core_owner_and_invalid_fields() { assert_eq!( diff --git a/rust/crates/request-context/src/trace.rs b/rust/crates/request-context/src/trace.rs index b27f1b70..35b3cf0d 100644 --- a/rust/crates/request-context/src/trace.rs +++ b/rust/crates/request-context/src/trace.rs @@ -22,6 +22,15 @@ pub fn current() -> Context { CURRENT.with(|current| current.borrow().clone()) } +/// [`current`] for a panic hook: `None` instead of a second panic when the +/// thread is being torn down or the panic struck while the context was borrowed. +pub fn try_current() -> Option { + CURRENT + .try_with(|current| current.try_borrow().ok().map(|context| context.clone())) + .ok() + .flatten() +} + /// Makes `context` the running request's correlation and returns the enclosing /// one, which the caller restores with another `replace` when its request ends. pub fn replace(context: Context) -> Context { diff --git a/rust/logging/README.md b/rust/logging/README.md index 533ab3e5..2ab291fb 100644 --- a/rust/logging/README.md +++ b/rust/logging/README.md @@ -82,6 +82,9 @@ - 桌面写入器(`desktop/internal/logstore` 的 `Store`)在详细诊断状态变化时调用 `configureCoreEvents`,只在开关变化时发送;调用失败时记录一次 `app.logging.diagnostics_failed`,直到想要的状态再次变化前不重试。 - 写入器在每次写入批次、flush 和退出时排空一次。没有其他宿主活动时,由 Core 的唤醒回调安排排空:drain 之后的第一条事实或第一次丢弃计数触发一次回调,同一个 drain 周期内的后续变化合并。Core 每个进程只有一个唤醒回调,所以只有 `cmd/lithe` 创建的应用写入器调用 `Store.ObserveCoreFacts()` 安装它;回调只唤醒写入器,复用宿主事件已有的 100 毫秒合并排空;`Close` 先移除回调,再做最后一次排空。回调不得重入 Core。不得为 Core 队列增加空闲轮询或独立写入器。 - 排空得到的 Core 事实与宿主事件进入同一批编码:保留 `ts`、`op` 和 Core 给出的通道,由写入器分配 `seq`,以 `validateCatalog: true` 写入。排空本身失败只计入写入失败数。 +- Core 的 panic 记为 `app.core.panic_interrupted`(ERROR),由 `rust/crates/core/src/runtime/panic_facts.rs` 安装的 panic hook 在展开开始前记录。每个 Core 命令和直接 IDE/AskPass 入口经 `helper_failures::install` 安装一次,新 hook 排在原 hook 前面,原来的 stderr 报告保留。hook 可能运行在持有队列锁的线程上,所以用 `core_events::record_without_waiting`:有限次 `try_lock` 拿不到锁就放弃这条事实,不等待,也不在 hook 里再次 panic(hook 内的 panic 会直接 abort)。`boundary` 为 `request` 表示请求分发中的 panic,同时记录 `method`(不符合 token 形状时省略)和当前请求的 op;为 `thread` 表示 Core 自己启动的线程中的 panic,该线程照常展开,由线程的所有者决定后续。`location` 是 `文件:行:列`,`panic` 是文本载荷,非文本载荷记为固定说明。 +- 宿主恢复的 Go panic 记为 `app.runtime.panic_interrupted`(ERROR)。Viva 的平台回调、Core 的唤醒回调和请求事件观察者在 recover 的地方把 panic 交给写入器的 `Store.RecordPanic`:它不加锁、不阻塞、不调用 Core,`Close` 已经开始时记录的 panic 也会进入最后一次排空。`boundary` 是 `viva:` 加 Viva 报告的边界,或 `core:log-waker`、`core:events-observer`;`stack` 只保留 panic 调用之后的帧,每帧写成“函数 文件基名:行”。窗口循环因恢复的 panic 以外的错误结束时,记 `app.window.loop_failed`。 +- Go 运行时的致命崩溃(没有恢复的 panic、`fatal error`)经 `debug.SetCrashOutput` 写进默认日志目录下的 `.crash/<会话名>`,只有应用写入器调用 `Store.CaptureCrashes()` 开启。下次启动认领上一次留下的文件:有内容记 `app.session.previous_interrupted`(ERROR),空文件说明进程被强制结束或在 Go 运行时之外崩溃,记 `app.session.close_missing`(WARN);正常 `Close` 删除本会话的文件。创建本会话的文件、认领旧文件或 `Close` 删除本会话的文件失败,记 `app.session.crash_capture_failed`,`stage` 分别是 `create`、`claim`、`release`。 ## 七、引擎宿主 diff --git a/rust/logging/events/app.json b/rust/logging/events/app.json index 842db5c1..fa0a4123 100644 --- a/rust/logging/events/app.json +++ b/rust/logging/events/app.json @@ -548,6 +548,142 @@ }, "rate": 60, "owner": "Lithe" + }, + { + "id": "app.core.panic_interrupted", + "channel": "app", + "level": "error", + "message": "Core code panicked at the {boundary} boundary", + "fields": { + "boundary": { + "type": "token", + "required": true, + "description": "Where the panic ends: request when the dispatcher turned it into a failed response and Core kept running, thread when it unwinds a Core thread whose owner decides what happens next" + }, + "panic": { + "type": "text", + "required": true, + "description": "Panic message from the Rust payload, or a fixed note when the payload is not text", + "reason": "A Rust panic message is free text written at the panic site, often with the Debug output of an error, and has no stable code; keep its wording after Core redaction and the 1 KiB cap" + }, + "location": { + "type": "text", + "required": false, + "description": "Source file, line and column the compiler attached to the panic", + "reason": "The compiler reports the panic site as a source path with line and column; dependency paths can be absolute, so Core redacts the text and caps it at 1 KiB instead of treating it as a stable identifier" + }, + "method": { + "type": "token", + "required": false, + "description": "Core protocol method the request was running when boundary is request, e.g. git.write" + } + }, + "rate": 60, + "owner": "lithe-core" + }, + { + "id": "app.runtime.panic_interrupted", + "channel": "app", + "level": "error", + "message": "Recovered a panic at {boundary}", + "fields": { + "boundary": { + "type": "token", + "required": true, + "description": "Recover site: viva: followed by the UI framework boundary such as viva:darwin:appkit-callback, or core:events-observer and core:log-waker for Core callbacks" + }, + "panic": { + "type": "text", + "required": true, + "description": "Panic value as text, as the recovering boundary received it", + "reason": "A recovered Go panic value is arbitrary text with no stable code; keep its wording so the failing check can be found, after Core redaction and the 1 KiB cap" + }, + "stack": { + "type": "text", + "required": false, + "description": "Frames of the panicking goroutine from the panic call outward, joined on one line", + "reason": "A Go stack trace has no structured equivalent; the host keeps only the frames after the panic call as function file:line pairs with base file names, and Core redacts and caps the text at 1 KiB" + } + }, + "rate": 60, + "owner": "Lithe" + }, + { + "id": "app.window.loop_failed", + "channel": "app", + "level": "error", + "message": "Window loop stopped with an error", + "fields": { + "error": { + "type": "error", + "required": true, + "description": "Error the UI framework returned when its window loop ended for a reason other than a recovered panic" + } + }, + "rate": 60, + "owner": "Lithe" + }, + { + "id": "app.session.previous_interrupted", + "channel": "app", + "level": "error", + "message": "Previous session ended in a crash", + "fields": { + "session": { + "type": "path", + "required": true, + "description": "Log directory of the session that crashed, so its last records can be read next to this one" + }, + "panic": { + "type": "text", + "required": true, + "description": "First line the Go runtime printed when the process died, such as panic: or fatal error:", + "reason": "The Go runtime prints the cause of a fatal crash only as text in its crash output; keep the first line after Core redaction and the 1 KiB cap" + }, + "stack": { + "type": "text", + "required": false, + "description": "Frames of the goroutine that crashed, from its panic call outward, joined on one line", + "reason": "A Go stack trace has no structured equivalent; the host keeps only the frames after the panic call as function file:line pairs with base file names, and Core redacts and caps the text at 1 KiB" + } + }, + "rate": 60, + "owner": "Lithe" + }, + { + "id": "app.session.close_missing", + "channel": "app", + "level": "warn", + "message": "Previous session ended without closing its log", + "fields": { + "session": { + "type": "path", + "required": true, + "description": "Log directory of the session that was killed, force quit or stopped by a native crash before closing its log" + } + }, + "rate": 60, + "owner": "Lithe" + }, + { + "id": "app.session.crash_capture_failed", + "channel": "app", + "level": "warn", + "message": "Crash capture failed at {stage}", + "fields": { + "stage": { + "type": "token", + "required": true, + "description": "Step that failed: create when this session's crash file could not be made, so a fatal crash of this session is not recorded; claim when a previous session's crash file could not be read or removed; release when Close could not remove this session's file, so the next start reports this session as not closed" + }, + "error": { + "type": "error", + "required": true, + "description": "Filesystem or runtime error of that step" + } + }, + "rate": 60, + "owner": "Lithe" } ] }