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:
1 parent
509bdb1bf6
commit
55dcb57553
11 files changed
+581
-32
No files matched your search
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Independent Analysis v1 consumer: no Marqdo/Rust imports."""
|
||||
"""Independent Analysis v2 consumer: no Marqdo/Rust imports."""
|
||||
import json
|
||||
import sys
|
||||
|
||||
@@ -11,15 +11,38 @@ with open(sys.argv[1], encoding="utf-8") as handle:
|
||||
|
||||
if analysis.get("schema") != "marqdo.analysis":
|
||||
raise SystemExit("unexpected schema")
|
||||
if analysis.get("schema_version") != 1:
|
||||
if analysis.get("schema_version") != 2:
|
||||
raise SystemExit("unsupported schema_version")
|
||||
|
||||
project = analysis["project"]
|
||||
if project.get("identity_kind") not in ("manifest", "workspace_snapshot"):
|
||||
raise SystemExit("bad project identity")
|
||||
if not isinstance(project.get("root_id"), str) or not project["root_id"]:
|
||||
raise SystemExit("bad root_id")
|
||||
|
||||
functions = []
|
||||
for module in analysis["modules"]:
|
||||
if not module["id"].startswith("root:"):
|
||||
raise SystemExit("unexpected module identity")
|
||||
if not isinstance(module["source_digest"], str) or len(module["source_digest"]) != 64:
|
||||
raise SystemExit("bad source digest")
|
||||
resources = module.get("resources")
|
||||
if not isinstance(resources, list):
|
||||
raise SystemExit("resources must be an array")
|
||||
seen = set()
|
||||
for resource in resources:
|
||||
if resource.get("id") in seen:
|
||||
raise SystemExit("duplicate resource id")
|
||||
seen.add(resource.get("id"))
|
||||
if resource.get("kind") not in ("formula", "code"):
|
||||
raise SystemExit("unknown resource kind")
|
||||
if resource.get("module_id") != module["id"]:
|
||||
raise SystemExit("resource module mismatch")
|
||||
if not isinstance(resource.get("content_digest"), str) or len(resource["content_digest"]) != 64:
|
||||
raise SystemExit("bad resource digest")
|
||||
span = resource.get("span") or {}
|
||||
if not isinstance(span.get("start"), int) or not isinstance(span.get("end"), int):
|
||||
raise SystemExit("bad resource span")
|
||||
for function in module["functions"]:
|
||||
body = json.dumps(function["body"], ensure_ascii=False)
|
||||
functions.append((function["id"], body))
|
||||
|
||||
Reference in new issue
Block a user