feat(analysis): Analysis v2 logical identity and resource projection (B-06 B-07)

- add ProjectIdentity (manifest root instance or workspace snapshot digest)
  and remove absolute-path root ids from Analysis bytes
- replace the resources count with an addressable array over the two real
  marqdo-ir resource kinds (formula, code), including unit/span/payload digest
  and code language
- project diagnostics by module/relative path/span, removing machine paths
- define the digest as SHA-256 of the exact emitted bytes so consumers can
  verify it; Trace binds to the same digest
- add analysis-v2 spec and JSON schema, supersede v1, update the independent
  Python consumer, schemas and docs
- tests: location-independent byte equality and resource addressing
This commit is contained in:
cflmy committed 2026-11-20 12:58:58 +08:00
1 parent 509bdb1bf6
commit 55dcb57553
11 files changed
+581 -32

No files matched your search

+1 -11
View File
@@ -7,7 +7,6 @@ use std::path::Path;
use marqdo_host::{Host, SemanticEvent, StdHost, TraceEntry};
use serde_json::{json, Value};
use sha2::{Digest, Sha256};
use crate::loader::LoadedProject;
@@ -32,10 +31,7 @@ pub fn write(
.unwrap_or(0)
);
let analysis_digest = crate::analysis::digest(project);
let root_id = format!(
"sha256:{}",
sha256_hex(project.root.to_string_lossy().as_bytes())
);
let root_id = project.identity.root_id();
let mut events: Vec<Value> = host
.semantic_events()
.iter()
@@ -99,9 +95,3 @@ fn atomic_write(path: &Path, bytes: &[u8]) -> Result<(), String> {
}
Ok(())
}
fn sha256_hex(bytes: &[u8]) -> String {
let mut hasher = Sha256::new();
hasher.update(bytes);
hex::encode(hasher.finalize())
}