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

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions docs/reference/trajectory-assessment.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,13 @@ This records an immutable version link; it neither appends to the original
source nor starts a model. The Agent prepares this link with the input, rather
than asking the reader to enter internal identifiers.

Use `--preserve-default` when importing another captured version for comparison
without changing the Goal's current selection. It retains the existing default;
the first registered capture still becomes the default. Omitting the option
keeps the existing select-on-registration behavior. New counter reductions need
their own registered identity and base link; a frozen preview does not establish
that its capture is available from the live owner.

The existing Goal analysis action becomes **Continue analysis**. Its inline
version summary identifies added, corrected and removed sources/episodes,
previous and current coverage, and changed judgments after completion. Previous
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ def register_pack(
loopx_input_json: str | None = None,
native_outcomes_json: str | None = None,
base_pack_id: str | None = None,
select_default: bool = True,
) -> dict:
"""Trusted operator only; no HTTP/renderer path-registration endpoint."""
if not title.strip():
Expand Down Expand Up @@ -454,7 +455,8 @@ def register_pack(
path.chmod(0o600)
if pack_id not in index["pack_ids"]:
index["pack_ids"].append(pack_id)
index["default_pack_id"] = pack_id
if select_default or index["default_pack_id"] is None:
index["default_pack_id"] = pack_id
_write(owner / "packs.json", index)
return {"ok": True, **_summary(record, None)}

Expand Down
3 changes: 3 additions & 0 deletions loopx/cli_commands/benchmark_trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def register_benchmark_trajectory_commands(subparsers, add_format) -> None:
register.add_argument("--source-root", type=Path, required=True)
register.add_argument("--title", required=True)
register.add_argument("--base-pack-id", help="Existing frozen pack in this owner Goal and original case/run; links a successor without running analysis.")
register.add_argument("--preserve-default", action="store_true",
help="Keep the existing default capture when registering another version; the first capture still becomes default.")
register.add_argument(
"--usage-jsonl",
help="Optional complete Codex session capture, relative to source-root; read-only cost facts, not model input.",
Expand Down Expand Up @@ -109,6 +111,7 @@ def _handle_benchmark_trajectory_command(
loopx_input_json=args.loopx_input_json,
native_outcomes_json=args.native_outcomes_json,
base_pack_id=args.base_pack_id,
select_default=not args.preserve_default,
)
if args.benchmark_command == "trajectory-pack-register"
else discover(**scope)
Expand Down
41 changes: 40 additions & 1 deletion tests/capabilities/test_trajectory_assessment_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,44 @@ def test_continuation_does_not_cross_owner_run_or_revoked_source(pack, tmp_path)
assert result["status"] == "succeeded" and not result["reused"]


def test_display_usage_captures_bind_registered_successor_versions():
from pathlib import Path

from loopx.capabilities.benchmark_toolkit.trajectory_assessment_store import _pack_id

fixture = Path(__file__).resolve().parents[2] / "apps/presentation/dashboard/src/data/fixtures/research-usage-real-captures.json"
data = json.loads(fixture.read_text())
lineage = {row["registered_pack_id"]: row for row in data["lineage"]}
for captured in data["packs"]:
source = lineage[captured["pack_id"]]
assert captured["continuation"]["base_pack_id"] == source["original_pack_id"]
usage = {key: value for key, value in captured["solver_usage"].items()
if key not in {"applicability", "reason_code"}}
assert usage["artifact_sha256"] == source["source_sha256"]
record = {"owner_goal_id": data["owner_goal_id"], "title": captured["title"],
"analysis_key": captured["analysis_key"], "solver_usage": usage,
"base_pack_id": source["original_pack_id"]}
assert _pack_id(data["owner_goal_id"], record) == captured["pack_id"]


def test_registration_can_preserve_the_current_selection(pack):
scope, _, original, input_path, sources, _ = pack
args = dict(**scope, input_path=input_path, source_root=sources,
title="Another captured version", base_pack_id=original["pack_id"])
alternate = register_pack(**args, select_default=False)
catalog = discover(**scope)
assert catalog["default_pack_id"] == original["pack_id"]
assert {p["pack_id"] for p in catalog["packs"]} == {original["pack_id"], alternate["pack_id"]}
assert inspect_pack(**scope, pack_id=alternate["pack_id"])["job"] is None
# Selection is not part of frozen evidence identity; legacy callers still
# select their registration without mutating either captured version.
assert register_pack(**args)["pack_id"] == alternate["pack_id"]
assert discover(**scope)["default_pack_id"] == alternate["pack_id"]
empty = {**scope, "runtime_root": scope["runtime_root"] / "empty"}
first = register_pack(**{**args, **empty, "base_pack_id": None}, select_default=False)
assert discover(**empty)["default_pack_id"] == first["pack_id"]


def test_native_results_register_through_real_cli_and_read_without_analysis(pack, tmp_path):
scope, _, original, input_path, sources, _ = pack
native = {
Expand All @@ -335,9 +373,10 @@ def test_native_results_register_through_real_cli_and_read_without_analysis(pack
"--runtime-root", str(scope["runtime_root"]), "--format", "json", "benchmark", "trajectory-pack-register",
"--goal-id", scope["owner_goal_id"], "--input-json", str(input_path), "--source-root", str(sources),
"--title", "Native outcome window", "--native-outcomes-json", native_path.name,
"--base-pack-id", original["pack_id"]],
"--base-pack-id", original["pack_id"], "--preserve-default"],
capture_output=True, text=True, check=True)
registered = json.loads(result.stdout)
assert discover(**scope)["default_pack_id"] == original["pack_id"]
assert registered["analysis_key"] == original["analysis_key"]
assert "native_outcomes" not in original
assert registered["native_outcomes"]["projection"]["initial"]["value"] == 2
Expand Down
2 changes: 1 addition & 1 deletion tests/control_plane/test_goal_create_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_managed_creation_retains_requirements_before_one_host_dispatch(environm
original = getattr(target, method)

def lose_response(*args, **kwargs):
result = original(*args, **kwargs)
original(*args, **kwargs)
raise TimeoutError("Committed creation response was lost")

monkeypatch.setattr(target, method, lose_response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ test('four real native prefixes retain the Bench owner counts, missing text attr
assert.equal(grid.left.input.unattributed_requests, 818); assert.equal(grid.right.input.unattributed_requests, 956);
for (let i=0; i<packs.length; i++) {
assert.equal(packs[i]!.solver_usage!.artifact_sha256, fixture.lineage[i].source_sha256);
assert.equal(packs[i]!.pack_id, fixture.lineage[i].candidate_pack_id);
assert.equal(packs[i]!.pack_id, fixture.lineage[i].registered_pack_id);
assert.notEqual(packs[i]!.pack_id, fixture.lineage[i].original_pack_id, 'New frozen observation does not rewrite its original pack');
}
});
Expand Down
Loading