feat(m0.6-r4): public Analysis v1 and Trace v1

- add check --emit with a deterministic, read-only semantic projection:
  package-aware modules, signatures, normalized bodies, refs, calls,
  diagnostics and source digests
- remove stale analysis artifacts on compile errors; atomic writes
- add run/call --trace-file with interpreter call/branch/loop/return events
  and host effect events under one sequence; redact values and record error
  status
- add Analysis/Trace v1 specs, ADR-0015 and an independent Python consumer
- add contract tests for determinism, stale artifacts, trace ordering/status
  and secret redaction
This commit is contained in:
cflmy committed 2026-11-20 11:46:37 +08:00
1 parent 25a1faa6ef
commit b5a28a9825
16 files changed
+1365 -13

No files matched your search

+20
View File
@@ -8,6 +8,9 @@ use serde::{Deserialize, Serialize};
/// One recorded host effect.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct TraceEntry {
/// Global event sequence within the run.
#[serde(default)]
pub seq: u64,
/// Operation name (`print`, `fs.read`, `foreign.call`, ...).
pub op: String,
/// Module that initiated it.
@@ -41,6 +44,7 @@ impl EffectTrace {
/// Record an effect.
pub fn record(
&mut self,
seq: u64,
op: impl Into<String>,
module: impl Into<String>,
span: Option<Span>,
@@ -51,6 +55,7 @@ impl EffectTrace {
return;
}
self.entries.push(TraceEntry {
seq,
op: op.into(),
module: module.into(),
span,
@@ -64,3 +69,18 @@ impl EffectTrace {
&self.entries
}
}
/// One semantic event emitted by the interpreter (Trace v1).
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SemanticEvent {
/// Global event sequence within the run.
pub seq: u64,
/// Stable event kind (`call.enter`, `call.exit`, `branch.eval`, ...).
pub kind: String,
/// Canonical function id, when inside a call.
pub function_id: Option<String>,
/// Source span, when known.
pub span: Option<Span>,
/// Non-sensitive detail (`ok`, `true`, `int`, an error code).
pub detail: Option<String>,
}