scripts/ab/mirror-replay.py replays native harness data through opencode_mirror.py, agy_mirror.py and runner/cli.mjs (TranscriptWriter, fed by a stub pi) and dumps the JSONL they write: --base REF diffs base vs working tree byte for byte, --incremental feeds opencode / agy sources in steps (per op, seeded chunks with half-written lines, a fresh mirror per poll) and requires the hub's parse to match the one-shot output, --real adds read-only copies of the lab's opencode db and agy brain/. Committed synthetic fixtures (mirror_fixtures/) and sidecar/test_mirror_replay.py run without private data. Clock, output paths, git branch, run liveness and temp paths are frozen or normalised; no product code changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
161 lines
9.6 KiB
Python
161 lines
9.6 KiB
Python
"""Synthetic agy (Antigravity CLI) data, as the ordered writes agy and the
|
|
sidecar make. Replayed by ``mirror-replay.py`` into a throw-away layout:
|
|
|
|
home/.gemini/antigravity-cli/ the account's app dir (brain/, cache/)
|
|
logs/<hub uuid>.log the run logs (SIDECAR_LOG_DIR)
|
|
runner/ids.json hub uuid ⇄ agy conversation (SIDECAR_AGY_DIR)
|
|
|
|
Ops:
|
|
|
|
{"op": "record", sid, fields} agy_cli.record(): the launch's pending run
|
|
{"op": "alive", sid, alive} whether the run's process is still there
|
|
{"op": "append", file, line} one line onto an app-dir file (a step)
|
|
{"op": "write", file, json} a whole app-dir file (subagent link, cache)
|
|
{"op": "log", sid, line} one line onto the run's log
|
|
{"op": "log_reset", sid} a resume rewrites the run log
|
|
|
|
Covered: binding a hub run through the log's ``init`` event, the
|
|
``<USER_REQUEST>`` / ``<ai-agent-instructions>`` unwrapping, thinking + text +
|
|
tool calls (both tool spellings), results in call order, a tool error, a
|
|
background tool (``RUNNING`` then ``DONE`` for one step index), a
|
|
``SYSTEM_MESSAGE`` body, a turn closed by the next user message and by a
|
|
``SUCCESS`` result, an interrupt with a pending tool (``[Request interrupted
|
|
by user]``), a resume rewriting the run log, a subagent (sidechain +
|
|
meta.json, linked to the spawning call), a failed step + ``ERROR_MESSAGE`` + an
|
|
``ERROR`` result (API-error turns), effort suffixes, and a terminal
|
|
conversation (no hub run: cwd from ``last_conversations.json``, closed after
|
|
its quiet window).
|
|
"""
|
|
|
|
ACCOUNT = "google-personal"
|
|
HUB_A = "11111111-0000-4000-8000-00000000000a"
|
|
CONV_A = "a0000000-0000-4000-8000-00000000000a"
|
|
CHILD = "c0000000-0000-4000-8000-00000000000c"
|
|
HUB_B = "11111111-0000-4000-8000-00000000000b"
|
|
CONV_B = "b0000000-0000-4000-8000-00000000000b"
|
|
CONV_T = "d0000000-0000-4000-8000-00000000000d"
|
|
|
|
|
|
def tfile(conv: str) -> str:
|
|
return f"brain/{conv}/.system_generated/logs/transcript_full.jsonl"
|
|
|
|
|
|
def append(conv, **line):
|
|
return {"op": "append", "file": tfile(conv), "line": line}
|
|
|
|
|
|
INIT_A = {"event": "init", "conversation_id": CONV_A,
|
|
"init": {"model": "gemini-4-hydrogen", "cwd": "/w/demo", "tools": ["read_file"]}}
|
|
INSTR = ("<ai-agent-instructions>\nThis machine's instructions live in CLAUDE.md files.\n"
|
|
"</ai-agent-instructions>\n\n")
|
|
|
|
OPS: list[dict] = [
|
|
# ── hub run A, turn 1: read + a failing edit, then the answer ──
|
|
{"op": "record", "sid": HUB_A, "fields": {"account": ACCOUNT, "cwd": "/w/demo",
|
|
"pendingSince": 0}},
|
|
{"op": "alive", "sid": HUB_A, "alive": True},
|
|
{"op": "log", "sid": HUB_A, "line": INIT_A},
|
|
append(CONV_A, step_index=0, source="USER_EXPLICIT", type="USER_INPUT", status="DONE",
|
|
created_at="2026-11-22T00:58:35Z",
|
|
content=f"<USER_REQUEST>\n{INSTR}edit a.txt: b → g\n</USER_REQUEST>\n"
|
|
"<ADDITIONAL_METADATA>\nlocal time 01:58\n</ADDITIONAL_METADATA>"),
|
|
append(CONV_A, step_index=1, type="PLANNER_RESPONSE", status="DONE",
|
|
created_at="2026-11-22T00:58:36Z", model="gemini-4-hydrogen-low",
|
|
input_tokens=9490, cache_read_tokens=0, output_tokens=403, thinking=" plan it ",
|
|
tool_calls=[{"name": "read_file", "args": {"Path": "a.txt"}},
|
|
{"name": "edit_file", "args": {"Path": "/w/demo/a.txt", "Target": "b",
|
|
"Replacement": "g"}}]),
|
|
append(CONV_A, step_index=2, type="GENERIC", status="DONE",
|
|
created_at="2026-11-22T00:58:37Z",
|
|
content="Created At: 2026-11-22T01:58:37+01:00\nCompleted At: x\n1: a\n2: b"),
|
|
append(CONV_A, step_index=3, type="GENERIC", status="ERROR",
|
|
created_at="2026-11-22T00:58:38Z", content="", error="target not found"),
|
|
append(CONV_A, step_index=4, type="PLANNER_RESPONSE", status="DONE",
|
|
created_at="2026-11-22T00:58:40Z", model="gemini-4-hydrogen-low",
|
|
input_tokens=2313, cache_read_tokens=8167, output_tokens=174,
|
|
content="The edit failed: `b` isn't in a.txt."),
|
|
{"op": "log", "sid": HUB_A, "line": {"event": "result", "result": {
|
|
"status": "SUCCESS", "response": "The edit failed.", "duration_seconds": 5.2,
|
|
"usage": {"input_tokens": 11803, "output_tokens": 577}}}},
|
|
{"op": "alive", "sid": HUB_A, "alive": False},
|
|
|
|
# ── run A resumed, turn 2: a background command, a subagent, interrupted ──
|
|
{"op": "log_reset", "sid": HUB_A},
|
|
{"op": "alive", "sid": HUB_A, "alive": True},
|
|
{"op": "log", "sid": HUB_A, "line": INIT_A},
|
|
append(CONV_A, step_index=5, source="USER_EXPLICIT", type="USER_INPUT", status="DONE",
|
|
created_at="2026-11-22T01:05:00Z",
|
|
content="<USER_REQUEST>\nrun the tests, and list the files with a helper\n"
|
|
"</USER_REQUEST>"),
|
|
append(CONV_A, step_index=6, type="PLANNER_RESPONSE", status="DONE",
|
|
created_at="2026-11-22T01:05:02Z", model="gemini-4-neon-high",
|
|
input_tokens=12000, cache_read_tokens=4000, output_tokens=220,
|
|
content="Starting both.",
|
|
tool_calls=[{"name": "run_command", "args": {"CommandLine": "pytest -q",
|
|
"Cwd": "/w/demo",
|
|
"toolSummary": "Run tests"}},
|
|
{"name": "invoke_subagent", "args": {"Subagents": [{
|
|
"Prompt": "list the files", "Role": "Lister",
|
|
"TypeName": "research"}]}}]),
|
|
append(CONV_A, step_index=7, type="GENERIC", status="RUNNING",
|
|
created_at="2026-11-22T01:05:03Z", content="running"),
|
|
append(CONV_A, step_index=8, type="GENERIC", status="DONE",
|
|
created_at="2026-11-22T01:05:03Z",
|
|
content=f'Created the following subagent:\n{{"conversationId": "{CHILD}"}}'),
|
|
{"op": "write", "file": f"brain/{CONV_A}/.system_generated/subagents/{CHILD}.json",
|
|
"json": {"conversationId": CHILD, "spawnStepIndex": 8,
|
|
"subagentDescriptor": {"typeName": "research", "role": "Lister"}}},
|
|
append(CHILD, step_index=0, type="SYSTEM_MESSAGE", status="DONE",
|
|
created_at="2026-11-22T01:05:04Z",
|
|
content="<SYSTEM_MESSAGE>\n[Message] sender=" + CONV_A + " content=list the files\n"
|
|
"</SYSTEM_MESSAGE>"),
|
|
append(CHILD, step_index=1, type="PLANNER_RESPONSE", status="DONE",
|
|
created_at="2026-11-22T01:05:06Z", model="gemini-3.8-flash-low",
|
|
input_tokens=800, output_tokens=12, content="a.txt\nb.txt",
|
|
tool_calls=[{"name": "view_file", "args": {"AbsolutePath": "/w/demo/a.txt",
|
|
"StartLine": 1, "EndLine": 2}}]),
|
|
append(CHILD, step_index=2, type="GENERIC", status="DONE",
|
|
created_at="2026-11-22T01:05:07Z", content="1: a\n2: b"),
|
|
append(CONV_A, step_index=7, type="GENERIC", status="DONE",
|
|
created_at="2026-11-22T01:05:09Z", content="Command exited with code 0.\n3 passed"),
|
|
append(CONV_A, step_index=9, type="SYSTEM_MESSAGE", status="DONE",
|
|
created_at="2026-11-22T01:05:10Z",
|
|
content="The following is a <SYSTEM_MESSAGE> not actually sent by the user.\n\n"
|
|
f"<SYSTEM_MESSAGE>\n[Message] sender={CHILD} content=a.txt b.txt\n"
|
|
"</SYSTEM_MESSAGE>"),
|
|
append(CONV_A, step_index=10, type="PLANNER_RESPONSE", status="DONE",
|
|
created_at="2026-11-22T01:05:12Z", model="gemini-4-neon-high",
|
|
input_tokens=300, cache_read_tokens=16000, output_tokens=40,
|
|
tool_calls=[{"name": "view_file", "args": {"AbsolutePath": "/w/demo/b.txt"}}]),
|
|
# interrupted while view_file ran: agy writes no step, the log says it
|
|
{"op": "log", "sid": HUB_A, "line": {"event": "result", "result": {
|
|
"status": "ERROR", "error": "interrupted", "finished_reason": "interrupted"}}},
|
|
{"op": "alive", "sid": HUB_A, "alive": False},
|
|
|
|
# ── hub run B: a failed model call and an ERROR result ──
|
|
{"op": "record", "sid": HUB_B, "fields": {"account": ACCOUNT, "cwd": "/w/other",
|
|
"pendingSince": 0}},
|
|
{"op": "alive", "sid": HUB_B, "alive": True},
|
|
{"op": "log", "sid": HUB_B, "line": {"event": "init", "conversation_id": CONV_B,
|
|
"init": {"cwd": "/w/other"}}},
|
|
append(CONV_B, step_index=0, source="USER_EXPLICIT", type="USER_INPUT", status="DONE",
|
|
created_at="2026-11-22T02:00:00Z", content="<USER_REQUEST>\nsummarise\n</USER_REQUEST>"),
|
|
append(CONV_B, step_index=1, type="PLANNER_RESPONSE", status="ERROR",
|
|
created_at="2026-11-22T02:00:02Z", model="gemini-4-argon-xhigh",
|
|
input_tokens=100, output_tokens=0, content="Partial",
|
|
error="RESOURCE_EXHAUSTED: quota"),
|
|
append(CONV_B, step_index=2, type="ERROR_MESSAGE", status="DONE",
|
|
created_at="2026-11-22T02:00:03Z", content="upstream connection reset"),
|
|
{"op": "log", "sid": HUB_B, "line": {"event": "result", "result": {
|
|
"status": "ERROR", "error": "RESOURCE_EXHAUSTED: weekly limit"}}},
|
|
{"op": "alive", "sid": HUB_B, "alive": False},
|
|
|
|
# ── a conversation started in a terminal ──
|
|
{"op": "write", "file": "cache/last_conversations.json", "json": {"/w/term": CONV_T}},
|
|
append(CONV_T, step_index=0, source="USER_EXPLICIT", type="USER_INPUT", status="DONE",
|
|
created_at="2026-11-22T03:00:00Z", content="hello"),
|
|
append(CONV_T, step_index=1, type="PLANNER_RESPONSE", status="DONE",
|
|
created_at="2026-11-22T03:00:01Z", model="gemini-4-neon",
|
|
input_tokens=50, output_tokens=5, content="Hi!"),
|
|
]
|