Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions loopx/capabilities/explore/result_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,9 @@ def _materialized_parent_edges(
return derived


def _finding_view(event: Mapping[str, Any]) -> dict[str, Any]:
def _finding_view(
event: Mapping[str, Any], *, include_internal_order: bool = False
) -> dict[str, Any]:
measured: dict[str, Any] = {}
if "measurements" in event:
try:
Expand All @@ -943,11 +945,13 @@ def _finding_view(event: Mapping[str, Any]) -> dict[str, Any]:
# view, not the append-only history. Runtime failure propagates.
measured["measurement_error"] = str(error)
else:
measured.update(measurements=event["measurements"], recorded_order=event["_recorded_order"])
measured["measurements"] = event["measurements"]
return {
**({"work_binding": event["work_binding"]} if "work_binding" in event else {}),
**({"work_yardstick": event["work_yardstick"], "recorded_order": event["_recorded_order"]} if "work_yardstick" in event else {}),
**({"work_yardstick": event["work_yardstick"]} if "work_yardstick" in event else {}),
**({"execution_observation": event["execution_observation"]} if "execution_observation" in event else {}),
**({"recorded_order": event["_recorded_order"]} if include_internal_order
or "measurements" in event or "work_yardstick" in event else {}),
**measured,
"finding_id": str(event.get("result_id") or ""),
"finding": str(event.get("title") or ""),
Expand Down Expand Up @@ -1171,6 +1175,7 @@ def build_explore_result_projection(
goal_id: str,
finding_limit: int = DEFAULT_FINDING_LIMIT,
mermaid_node_limit: int = DEFAULT_MERMAID_NODE_LIMIT,
include_internal_finding_order: bool = False,
) -> dict[str, Any]:
"""Fold result events into the bounded projection display sinks render."""

Expand Down Expand Up @@ -1202,7 +1207,9 @@ def build_explore_result_projection(
# Whole-second source clocks can tie. Folding retains creation order, so
# break equal chronology keys with the existing latest-append ordinal
# before bounding any consumer; do not rewrite the stored evidence clock.
findings = [_finding_view(event) for event in sorted(
findings = [_finding_view(
event, include_internal_order=include_internal_finding_order,
) for event in sorted(
folded_findings,
key=lambda item: (chronology_key(item["last_updated_at"]), item["_recorded_order"]),
reverse=True,
Expand Down
16 changes: 3 additions & 13 deletions loopx/capabilities/explore/turn_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
from ...explore_graph import compact_explore_graph_policy
from ...control_plane.todos.list_readback import list_goal_todos
from .result_log import (
EVENT_KIND_FINDING,
_fold_by_result_id,
build_explore_result_projection,
explore_result_log_path,
load_explore_result_events_strict,
Expand Down Expand Up @@ -135,18 +133,10 @@ def explore_turn_context(
# applied. New unrelated findings must not hide an older refutation.
events, goal_id=goal_id, finding_limit=len(events),
mermaid_node_limit=3,
# Yardstick's typed owner needs the canonical append ordinal for
# execution feedback. Presentation callers keep their v0 wire.
include_internal_finding_order=yardstick,
)
if yardstick and any("execution_observation" in row and "recorded_order" not in row
for row in projection["findings"]):
# Supply canonical ordinals only to the opted-in work reader.
# Folding remains with the existing result-history owner.
orders = {row["result_id"]: row["_recorded_order"]
for row in _fold_by_result_id(events, event_kind=EVENT_KIND_FINDING)}
projection["findings"] = [
{**row, "recorded_order": orders[row["finding_id"]]}
if "execution_observation" in row and "recorded_order" not in row else row
for row in projection["findings"]
]
if gate["enabled"] or graph and (todo_id is not None or page_tasks or yardstick):
todos = list_goal_todos(
registry_path=registry_path,
Expand Down
Loading