Skip to content
1 change: 1 addition & 0 deletions changelog.d/1080.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add country-neutral recorded execution exports for Orrery: gate-first independent status badges with an attempt-level cache summary, phase history, one artifact reference per content-store object, the executing kernel as each activity's agent, digest-bound evidence links and aggregate calibration, size-search and per-gate diagnostics. Fields are contained by their providing operation, scope names the document, and `metadata.microcosm` binds the separately saved compiler schema by digest. Shared helpers save the schema with copied checkpoint bytes, project checkpoint provenance without linking absent files, and publish flat evidence merged across attempts. UK drivers preserve native evidence through an explicit presentation roster. Orrery snapshots remain opt-in.
1 change: 1 addition & 0 deletions changelog.d/1144-uk-full-graph-export.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Raise the bound on every serialized string in compiler schemas and Orrery exports to 131,072 characters so the maintained full UK gate contracts round-trip; the document, complexity, node and edge limits are unchanged.
4 changes: 3 additions & 1 deletion docs/agent-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ The Orrery parser compatibility assertion lives in
engine-free runner installs the supported public Orrery range and locked Node
dependency set under `tools/orrery-contract/`; the pytest test generates a
document through Microcosm's public Python API and requires Orrery's public
parser to accept it. It performs no browser rendering.
parser to accept it. The recorded-evidence assertion in `test_graph_evidence.py`
uses the same pinned parser for groups, statuses, activities and artifacts.
These CI tests perform no browser rendering.

Workspace tests use an in-memory telemetry emitter by default. The shared
fixture isolates Hugging Face credentials and cache paths and blocks collector
Expand Down
270 changes: 259 additions & 11 deletions docs/orrery-adapter.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
write_uk_national_frame,
)
from .national_sampling import UK_SAMPLE_RUNG_TOKENS
from .orrery_contract import persist_uk_run_evidence, save_uk_graph_schema
from .rowwise_cli import (
MANIFEST_FILENAME,
REPOSITORY,
Expand Down Expand Up @@ -968,12 +969,40 @@ def _materialize_evidence(manifest, store, out: Path) -> dict:
return inventory


def _persist_checkpoint(manifest, store, args, phase: str) -> None:
def _record_capture_cost(
out: Path, phase: str, started: float, rss_before: int
) -> None:
"""Append the evidence-capture cost of one phase; a measurement, not a gate."""
import resource

record = {
"phase": phase,
"wall_s": round(time.perf_counter() - started, 3),
"maxrss_before_bytes": rss_before,
"maxrss_after_bytes": resource.getrusage(resource.RUSAGE_SELF).ru_maxrss,
}
with (out / "evidence-capture-timing.jsonl").open("a", encoding="utf-8") as sink:
sink.write(json.dumps(record, sort_keys=True) + "\n")
print(
f"evidence capture {phase}: {record['wall_s']:.1f}s, "
f"peak RSS {record['maxrss_after_bytes'] / 2**30:.2f} GiB",
file=sys.stderr,
flush=True,
)


def _persist_checkpoint(manifest, store, args, phase: str, *, graph: Graph) -> None:
"""Keep receipts and small evidence durable if a later kernel refuses."""
import resource

payload = manifest.to_json_bytes()
materialize_bytes(payload, args.out / f"{phase}.graph.json")
attempt = Path(args.attempt_evidence)
materialize_bytes(payload, attempt / f"{phase}.graph.json")
started = time.perf_counter()
rss_before = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
persist_uk_run_evidence(graph, manifest, store, args, phase=phase)
_record_capture_cost(args.out, phase, started, rss_before)
evidence = {}
for node_id, receipt in manifest.nodes.items():
for name, key in receipt.opaque_artifacts.items():
Expand All @@ -992,6 +1021,17 @@ def _persist_checkpoint(manifest, store, args, phase: str) -> None:
)


def _save_graph_presentation(graph: Graph, args, *, scope: str) -> None:
sidecar = getattr(args, "input_sidecar", None)
input_h5 = getattr(args, "input_h5", None)
if sidecar is None and input_h5 is not None:
sidecar = input_h5.with_suffix(".build.json")
save_uk_graph_schema(graph, args.out, scope=scope, sidecar_path=sidecar)
save_uk_graph_schema(
graph, Path(args.attempt_evidence), scope=scope, sidecar_path=sidecar
)


def _argument_sources(args: argparse.Namespace) -> dict[str, Path]:
"""The path-valued request arguments, for the output-location check
before (or without) a prepared build."""
Expand Down Expand Up @@ -1317,6 +1357,11 @@ def _execute_full_build(
args.out.mkdir(parents=True, exist_ok=True)
store = ContentStore(args.graph_store or args.out / ".graph-store")
graph = full.graph
_save_graph_presentation(
graph,
args,
scope="checkpoint_dense" if args.input_h5 is not None else "full_dense",
)
materialize_bytes(graph_to_json(graph).encode(), args.out / "graph.json")
materialize_bytes(
canonical_json(full.operation_inventory()), args.out / "operations.json"
Expand All @@ -1342,7 +1387,9 @@ def _execute_full_build(
kernels=kernels,
resume=resume,
)
_persist_checkpoint(checkpoint, store, args, endpoint)
_persist_checkpoint(
checkpoint, store, args, endpoint, graph=_through(graph, endpoint)
)
resume = "require" if args.resume == "require" else "auto"
# Persist preflight outcomes before any solver can reject them.
stage(telemetry, "target_compilation", "started")
Expand All @@ -1354,7 +1401,7 @@ def _execute_full_build(
kernels=kernels,
resume=resume,
)
_persist_checkpoint(preflight, store, args, "preflight")
_persist_checkpoint(preflight, store, args, "preflight", graph=preflight_graph)
_materialize_evidence(preflight, store, args.out)
if "uk.full.target_selection" in preflight.nodes:
selection = json.loads(
Expand Down Expand Up @@ -1390,7 +1437,13 @@ def _execute_full_build(
kernels=kernels,
resume="require" if args.resume == "require" else "auto",
)
_persist_checkpoint(manifest, store, args, "numerical")
_persist_checkpoint(
manifest,
store,
args,
"numerical",
graph=_through(graph, "uk.full.gates.calibrated"),
)
_materialize_evidence(manifest, store, args.out)
_require_gate_kernel_completed(manifest, "uk.full.gates.calibrated")
terminal_files = materialize_uk_terminal_artifacts(
Expand Down Expand Up @@ -1467,6 +1520,7 @@ def _execute_full_build(
kernels=kernels,
resume="require" if args.resume == "require" else "auto",
)
_persist_checkpoint(manifest, store, args, "export", graph=graph)
descriptor = json.loads(
_payload(manifest, store, "uk.full.export.prepare", "export_descriptor")
)
Expand Down Expand Up @@ -1553,6 +1607,16 @@ def _execute_full_build(
resume="auto",
)
final.save(args.out / "build.graph.json")
_persist_checkpoint(final, store, args, "final", graph=graph)
_save_graph_presentation(
graph,
args,
scope="checkpoint_dense" if args.input_h5 is not None else "full_dense",
)
materialize_bytes(
canonical_json(replace(full, graph=graph).operation_inventory()),
args.out / "operations.json",
)
materialize_bytes(graph_to_json(graph).encode(), args.out / "graph.json")
_materialize_evidence(final, store, args.out)
package = json.loads(_payload(final, store, "uk.full.package", "package_inventory"))
Expand Down Expand Up @@ -1915,6 +1979,7 @@ def _execute_national_build(
args.out.mkdir(parents=True, exist_ok=True)
store = ContentStore(args.graph_store or args.out / ".graph-store")
graph = national.graph
_save_graph_presentation(graph, args, scope="national")
materialize_bytes(graph_to_json(graph).encode(), args.out / "graph.json")
materialize_bytes(
canonical_json(national.operation_inventory()), args.out / "operations.json"
Expand All @@ -1933,7 +1998,13 @@ def _execute_national_build(
kernels=kernels,
resume=resume,
)
_persist_checkpoint(checkpoint, store, args, "uk.full.spine_checkpoint")
_persist_checkpoint(
checkpoint,
store,
args,
"uk.full.spine_checkpoint",
graph=_through(graph, "uk.full.spine_checkpoint"),
)
resume = "require" if args.resume == "require" else "auto"
spine_frame = checkpoint.population("uk.full.spine_checkpoint")
stage(
Expand All @@ -1954,6 +2025,9 @@ def _execute_national_build(
kernels=kernels,
resume=resume,
)
_persist_checkpoint(
targets, store, args, "targets", graph=_through(graph, NATIONAL_TARGETS_NODE)
)
registry_document = json.loads(
graph_payload(targets, store, NATIONAL_TARGETS_NODE, "registry")
)
Expand Down Expand Up @@ -2007,7 +2081,13 @@ def _execute_national_build(
kernels=kernels,
resume=resume,
)
_persist_checkpoint(manifest, store, args, "numerical")
_persist_checkpoint(
manifest,
store,
args,
"numerical",
graph=_through(graph, "uk.full.gates.calibrated"),
)
_materialize_evidence(manifest, store, args.out)
_require_gate_kernel_completed(manifest, NATIONAL_GATES_NODE)
if state is not None:
Expand Down Expand Up @@ -2162,6 +2242,13 @@ def _execute_national_build(
kernels=kernels,
resume="auto",
)
_persist_checkpoint(final, store, args, "final", graph=continued)
_save_graph_presentation(continued, args, scope="national")
materialize_bytes(graph_to_json(continued).encode(), args.out / "graph.json")
materialize_bytes(
canonical_json(replace(national, graph=continued).operation_inventory()),
args.out / "operations.json",
)
_require_gate_kernel_completed(final, NATIONAL_READBACK_NODE)
readback = json.loads(
graph_payload(final, store, NATIONAL_READBACK_NODE, "readback")
Expand Down
Loading
Loading