Replay your coding agent sessions as a map and a timeline
Python agent-observabilityai-agentsclaudeclaude-codecodexcoding-agentscursordeveloper-toolsdevtoolsgithub-copilotkirollmobservabilityopencodeprivacypythonsession-replaytypescriptvisualization
refactor(antigravity): move discovery and aliases into their own modules
shubhookdb8f168abafa
diff --git a/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/antigravity_index.py b/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/antigravity_index.pynew file mode 100644index 0000000..3b9023f--- /dev/null+++ b/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/antigravity_index.py@@ -0,0 +1,237 @@+"""Antigravity CLI (`agy`) discovery for `LocalSource`.++`agy` keeps one step log per conversation at+``<home>/brain/<uuid>/.system_generated/logs/transcript_full.jsonl``. The step+log records no working directory and no parent conversation, so both come from+``<home>/conversation_summaries.db`` (see `antigravity_summaries`). The parser+itself lives in ``parsers/antigravity.py``.+"""++from __future__ import annotations++from collections.abc import Callable, Iterable+from dataclasses import dataclass+from datetime import UTC, datetime+import json+import logging+from pathlib import Path+import re+import shutil+import sqlite3+import tempfile+from typing import Any+from urllib.parse import unquote, urlsplit++from agentplay._core.ingestion.coding_agent._sources.local.parsers import AgentType, detect_agent++logger = logging.getLogger(__name__)++# Relative to an Antigravity CLI home.+TRANSCRIPT_GLOB = "brain/*/.system_generated/logs/transcript_full.jsonl"+++def _path_from_file_uri(uri: object) -> str | None:+ """A local path from a ``file://`` URI, the same on every OS.++ ``file:///Users/dev/project`` gives ``/Users/dev/project`` and+ ``file:///C:/Users/dev/project`` gives ``C:/Users/dev/project`` (no leading+ slash before a drive letter), whichever OS reads it: the session may have+ been recorded on another machine. A host part (``file://server/share``) is+ kept as a UNC-style ``//server/share`` prefix.+ """+ if not isinstance(uri, str) or not uri.startswith("file:"):+ return None+ parts = urlsplit(uri)+ path = unquote(parts.path)+ if re.match(r"^/[A-Za-z]:", path):+ path = path[1:]+ if parts.netloc and parts.netloc != "localhost":+ path = f"//{parts.netloc}{path}"+ return path or None+++@dataclass(frozen=True)+class _AntigravitySummary:+ """The structural columns of one `conversation_summaries` row."""++ cwd: str | None+ parent_id: str | None+++# Only structural columns. `title`, `preview` and `raw_summary` are prompt or+# model text and are never selected.+_ANTIGRAVITY_SUMMARY_SQL = (+ "SELECT conversation_id, workspace_uris, parent_conversation_id FROM conversation_summaries"+)+++def _summary_file_stamp(path: Path) -> tuple[str, int | None, int | None]:+ """`(name, size, mtime_ns)` for one summaries file, or `(name, None, None)` when absent."""+ if not path.is_file():+ return (path.name, None, None)+ st = path.stat()+ return (path.name, st.st_size, st.st_mtime_ns)+++def _antigravity_summary_files(db: Path) -> list[Path]:+ return [db.with_name(db.name + suffix) for suffix in ("", "-wal", "-shm")]+++def _copy_antigravity_summaries(db: Path, tmp_dir: Path) -> None:+ """Copy the db and its sidecars without opening the original.++ `agy` may be writing the WAL while we copy. Stat size and mtime of the db,+ `-wal`, and `-shm` before and after each attempt, and retry up to 3 times+ when any of them changed (including a sidecar appearing or disappearing).+ A snapshot that is still moving after that is used as-is.+ """+ files = _antigravity_summary_files(db)+ for _ in range(3):+ before = tuple(_summary_file_stamp(path) for path in files)+ for src in files:+ dest = tmp_dir / src.name+ if src.is_file():+ shutil.copyfile(src, dest)+ elif dest.exists():+ dest.unlink()+ after = tuple(_summary_file_stamp(path) for path in files)+ if before == after:+ return+ logger.debug(+ "antigravity-cli: conversation summaries changed while copying; using the last copy"+ )+++def _antigravity_summaries(home: Path) -> dict[str, _AntigravitySummary]:+ """cwd and parent conversation per conversation id, from `conversation_summaries.db`.++ The live database is in WAL mode and may be open in `agy`, so it is copied+ (with its `-wal` / `-shm` files when present) to a temporary directory and+ opened read-only there. Missing or unreadable: an empty dict, and sessions+ are indexed without a cwd.+ """+ db = home / "conversation_summaries.db"+ if not db.is_file():+ return {}+ rows: list[tuple] = []+ try:+ with tempfile.TemporaryDirectory(prefix="agentplay-antigravity-") as tmp:+ tmp_dir = Path(tmp)+ _copy_antigravity_summaries(db, tmp_dir)+ conn = sqlite3.connect(f"{(tmp_dir / db.name).as_uri()}?mode=ro", uri=True)+ try:+ rows = conn.execute(_ANTIGRAVITY_SUMMARY_SQL).fetchall()+ finally:+ # Closed before the directory is removed: Windows cannot delete an open file.+ conn.close()+ except (OSError, sqlite3.Error) as exc:+ logger.debug("antigravity-cli: conversation summaries unreadable: %s", exc)+ return {}+ out: dict[str, _AntigravitySummary] = {}+ for conversation_id, workspace_uris, parent_id in rows:+ if not isinstance(conversation_id, str) or not conversation_id:+ continue+ try:+ uris = json.loads(workspace_uris) if isinstance(workspace_uris, str) else None+ except (ValueError, RecursionError):+ uris = None+ cwd = None+ try:+ for uri in uris if isinstance(uris, list) else []:+ cwd = _path_from_file_uri(uri)+ if cwd:+ break+ except ValueError:+ # urlsplit rejects a host like "[bad". Drop the row so one bad URI+ # cannot abort discovery of every other conversation.+ continue+ parent = parent_id if isinstance(parent_id, str) and parent_id else None+ out[conversation_id] = _AntigravitySummary(cwd=cwd, parent_id=parent)+ return out+++def index_antigravity_home(+ home: Path,+ transcripts: Iterable[Path],+ record: Callable[[str, str], None],+) -> list[tuple[str, dict[str, Any]]]:+ """`(session_id, _FileRef fields)` for each Antigravity CLI step log in `home`.++ `transcripts` are the home's `TRANSCRIPT_GLOB` matches. `record` is+ `LocalSource._record_discovery`. The summaries db is read once per home,+ and only when the home has a `brain/` folder.+ """+ brain_dir = home / "brain"+ if not brain_dir.is_dir():+ logger.debug("Skipping non-existent path: %s", brain_dir)+ return []+ summaries = _antigravity_summaries(home)+ refs = []+ for jsonl_file in transcripts:+ ref = _index_antigravity_file(jsonl_file, home=home, summaries=summaries, record=record)+ if ref:+ refs.append(ref)+ return refs+++def _index_antigravity_file(+ jsonl_file: Path,+ *,+ home: Path,+ summaries: dict[str, _AntigravitySummary],+ record: Callable[[str, str], None],+) -> tuple[str, dict[str, Any]] | None:+ """Index one Antigravity CLI `transcript_full.jsonl`."""+ # source.py imports this module, so its helpers are looked up at call time.+ from agentplay._core.ingestion.coding_agent._sources.local.source import (+ _agent_detected,+ _project_from_cwd,+ _read_head,+ )++ if not jsonl_file.is_file():+ return None+ size = jsonl_file.stat().st_size+ if size == 0:+ record("antigravity-cli", "empty_or_unreadable")+ return None+ try:+ head = _read_head(jsonl_file, stop_when=_agent_detected)+ except OSError:+ record("antigravity-cli", "empty_or_unreadable")+ return None++ agent = detect_agent(head)+ if agent is None:+ logger.warning(+ "agent detection failed for %s (%d bytes); session skipped",+ jsonl_file,+ size,+ )+ record("antigravity-cli", "detection_failed")+ return None+ if agent != AgentType.ANTIGRAVITY_CLI:+ record("antigravity-cli", "different_agent")+ return None++ # brain/<uuid>/.system_generated/logs/transcript_full.jsonl+ native_id = jsonl_file.parents[2].name+ session_id = f"local:{agent}:{native_id}"+ mtime = datetime.fromtimestamp(jsonl_file.stat().st_mtime, tz=UTC)+ summary = summaries.get(native_id)+ cwd = summary.cwd if summary else None+ parent = summary.parent_id if summary else None++ record("antigravity-cli", "indexed")+ return session_id, {+ "path": jsonl_file,+ "agent": agent,+ "mtime": mtime,+ "project_name": _project_from_cwd(cwd) if cwd else None,+ "cwd": cwd,+ "home": home,+ "parent_session_id": f"local:{agent}:{parent}" if parent else None,+ }+++__all__ = ["TRANSCRIPT_GLOB", "index_antigravity_home"]diff --git a/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/__init__.py b/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/__init__.pyindex dc5c44c..dae1d9b 100644--- a/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/__init__.py+++ b/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/__init__.py@@ -16,9 +16,6 @@ returns the agent type by sniffing for marker lines:- Kiro: synthesized header line with `type="kiro_session"`.- Gemini CLI: header line with `sessionId` + `projectHash` and no `type`, or a`type="gemini"` message (`~/.gemini/tmp/<project>/chats/session-*.jsonl`).-- Antigravity CLI: step lines with an int `step_index`, a `source` and a step- `type` (`~/.gemini/antigravity-cli/brain/<uuid>/.system_generated/logs/- transcript_full.jsonl`).- opencode: materialized records carrying a `message` object and a `parts` list.Each parser exposes `parse_X(data, trace_id, user_id=None,diff --git a/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/antigravity.py b/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/antigravity.pyindex 0c90254..2e8e2ba 100644--- a/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/antigravity.py+++ b/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/antigravity.py@@ -244,6 +244,20 @@ def parse_antigravity(return trace, all_spans+def is_antigravity_step(obj: dict) -> bool:+ """True for an agy step-log line: an int `step_index`, a `source` string and a step `type`.++ No other agent writes `step_index`, and these upper-case types are agy's own.+ """+ index = obj.get("step_index")+ return (+ obj.get("type") in _STEP_TYPES+ and isinstance(index, int)+ and not isinstance(index, bool)+ and isinstance(obj.get("source"), str)+ )++def _steps(records: list[dict]) -> list[dict]:"""Known steps ordered by `step_index`, keeping the last copy of each index."""latest: dict[int, dict] = {}@@ -418,4 +432,4 @@ def _labelled_time(content: str, pattern: re.Pattern[str]) -> datetime | None:return None-__all__ = ["parse_antigravity"]+__all__ = ["is_antigravity_step", "parse_antigravity"]diff --git a/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/base.py b/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/base.pyindex a68691f..9aad1fe 100644--- a/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/base.py+++ b/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/parsers/base.py@@ -10,6 +10,8 @@ from __future__ import annotationsfrom enum import StrEnumimport json+from agentplay._core.ingestion.coding_agent._sources.local.parsers.antigravity import is_antigravity_step+class AgentType(StrEnum):"""Agent enum used by the parsers + LocalSource dispatch.@@ -28,9 +30,6 @@ class AgentType(StrEnum):ANTIGRAVITY_CLI = "antigravity-cli"-_ANTIGRAVITY_STEP_TYPES = ("USER_INPUT", "PLANNER_RESPONSE", "GENERIC", "SYSTEM_MESSAGE")--def detect_agent(data: bytes) -> AgentType | None:"""Detect the agent that produced this transcript.@@ -89,15 +88,7 @@ def detect_agent(data: bytes) -> AgentType | None:if line_type == "gemini" and isinstance(obj.get("id"), str):return AgentType.GEMINI_CLI- # Antigravity CLI (`agy`): every step-log line carries an int- # `step_index`, a `source` string and a step `type`. No other agent- # writes `step_index`, and these upper-case types are agy's own.- if (- line_type in _ANTIGRAVITY_STEP_TYPES- and isinstance(obj.get("step_index"), int)- and not isinstance(obj.get("step_index"), bool)- and isinstance(obj.get("source"), str)- ):+ if is_antigravity_step(obj):return AgentType.ANTIGRAVITY_CLI# Codex: session_meta with codex originator.diff --git a/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/source.py b/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/source.pyindex ba2f0b9..6fcfe3b 100644--- a/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/source.py+++ b/python/src/agentplay/_core/ingestion/coding_agent/_sources/local/source.py@@ -1,7 +1,5 @@"""Local filesystem source — walks ~/.claude / ~/.codex / ~/.gemini / Copilot dirs.-Also walks ~/.gemini/antigravity-cli (Antigravity CLI step logs).-Indexes JSONL session files under per-agent homes, detects the agentfrom the file head, and emits the universal `SpanData` shape via thematching parser. Multi-agent by design — drop a Codex session next to@@ -19,11 +17,7 @@ import loggingimport osfrom pathlib import Pathimport re-import shutil-import sqlite3-import tempfilefrom typing import Any-from urllib.parse import unquote, urlsplitfrom agentplay._core.ingestion.coding_agent._paths import to_posixfrom agentplay._core.ingestion.coding_agent._sources._base import (@@ -31,6 +25,10 @@ from agentplay._core.ingestion.coding_agent._sources._base import (OversizedSessionError,)from agentplay.discover import MAX_SOURCE_BYTES+from agentplay._core.ingestion.coding_agent._sources.local.antigravity_index import (+ TRANSCRIPT_GLOB as ANTIGRAVITY_TRANSCRIPT_GLOB,+ index_antigravity_home,+)from agentplay._core.ingestion.coding_agent._sources.local.parsers import (AgentType,detect_agent,@@ -1199,126 +1197,6 @@ def _cwd_from_gemini_project(jsonl_file: Path, header: dict | None) -> str | Nonreturn root-def _path_from_file_uri(uri: object) -> str | None:- """A local path from a ``file://`` URI, the same on every OS.-- ``file:///Users/dev/project`` gives ``/Users/dev/project`` and- ``file:///C:/Users/dev/project`` gives ``C:/Users/dev/project`` (no leading- slash before a drive letter), whichever OS reads it: the session may have- been recorded on another machine. A host part (``file://server/share``) is- kept as a UNC-style ``//server/share`` prefix.- """- if not isinstance(uri, str) or not uri.startswith("file:"):- return None- parts = urlsplit(uri)- path = unquote(parts.path)- if re.match(r"^/[A-Za-z]:", path):- path = path[1:]- if parts.netloc and parts.netloc != "localhost":- path = f"//{parts.netloc}{path}"- return path or None---@dataclass(frozen=True)-class _AntigravitySummary:- """The structural columns of one `conversation_summaries` row."""-- cwd: str | None- parent_id: str | None---# Only structural columns. `title`, `preview` and `raw_summary` are prompt or-# model text and are never selected.-_ANTIGRAVITY_SUMMARY_SQL = (- "SELECT conversation_id, workspace_uris, parent_conversation_id FROM conversation_summaries"-)---def _summary_file_stamp(path: Path) -> tuple[str, int | None, int | None]:- """`(name, size, mtime_ns)` for one summaries file, or `(name, None, None)` when absent."""- if not path.is_file():- return (path.name, None, None)- st = path.stat()- return (path.name, st.st_size, st.st_mtime_ns)---def _antigravity_summary_files(db: Path) -> list[Path]:- return [db.with_name(db.name + suffix) for suffix in ("", "-wal", "-shm")]---def _copy_antigravity_summaries(db: Path, tmp_dir: Path) -> None:- """Copy the db and its sidecars without opening the original.-- `agy` may be writing the WAL while we copy. Stat size and mtime of the db,- `-wal`, and `-shm` before and after each attempt, and retry up to 3 times- when any of them changed (including a sidecar appearing or disappearing).- A snapshot that is still moving after that is used as-is.- """- files = _antigravity_summary_files(db)- for _ in range(3):- before = tuple(_summary_file_stamp(path) for path in files)- for src in files:- dest = tmp_dir / src.name- if src.is_file():- shutil.copyfile(src, dest)- elif dest.exists():- dest.unlink()- after = tuple(_summary_file_stamp(path) for path in files)- if before == after:- return- logger.debug(- "antigravity-cli: conversation summaries changed while copying; using the last copy"- )---def _antigravity_summaries(home: Path) -> dict[str, _AntigravitySummary]:- """cwd and parent conversation per conversation id, from `conversation_summaries.db`.-- The live database is in WAL mode and may be open in `agy`, so it is copied- (with its `-wal` / `-shm` files when present) to a temporary directory and- opened read-only there. Missing or unreadable: an empty dict, and sessions- are indexed without a cwd.- """- db = home / "conversation_summaries.db"- if not db.is_file():- return {}- rows: list[tuple] = []- try:- with tempfile.TemporaryDirectory(prefix="agentplay-antigravity-") as tmp:- tmp_dir = Path(tmp)- _copy_antigravity_summaries(db, tmp_dir)- conn = sqlite3.connect(f"{(tmp_dir / db.name).as_uri()}?mode=ro", uri=True)- try:- rows = conn.execute(_ANTIGRAVITY_SUMMARY_SQL).fetchall()- finally:- # Closed before the directory is removed: Windows cannot delete an open file.- conn.close()- except (OSError, sqlite3.Error) as exc:- logger.debug("antigravity-cli: conversation summaries unreadable: %s", exc)- return {}- out: dict[str, _AntigravitySummary] = {}- for conversation_id, workspace_uris, parent_id in rows:- if not isinstance(conversation_id, str) or not conversation_id:- continue- try:- uris = json.loads(workspace_uris) if isinstance(workspace_uris, str) else None- except (ValueError, RecursionError):- uris = None- cwd = None- try:- for uri in uris if isinstance(uris, list) else []:- cwd = _path_from_file_uri(uri)- if cwd:- break- except ValueError:- # urlsplit rejects a host like "[bad". Drop the row so one bad URI- # cannot abort discovery of every other conversation.- continue- parent = parent_id if isinstance(parent_id, str) and parent_id else None- out[conversation_id] = _AntigravitySummary(cwd=cwd, parent_id=parent)- return out--def _project_from_cwd(cwd: str) -> str | None:"""Project name from the transcript's cwd.@@ -1483,10 +1361,7 @@ class LocalSource:# comes from the header's `sessionId`, the cwd from the project# folder's `.project_root` (see `_cwd_from_gemini_project`).self.gemini_homes = gemini_homes or []- # Antigravity CLI keeps one step log per conversation:- # `<home>/brain/<uuid>/.system_generated/logs/transcript_full.jsonl`.- # cwd and subagent parent come from `<home>/conversation_summaries.db`- # (see `_antigravity_summaries`).+ # Antigravity CLI step logs; discovery lives in antigravity_index.py.self.antigravity_homes = antigravity_homes or []# Per-home identity stamp (`<home>/_manifest/*.json`). It carries a# user_uuid/email/github_username used to detect duplicated sessions@@ -1729,20 +1604,11 @@ class LocalSource:if ref:_index_put(index, ref[0], ref[1], newest)- # Antigravity CLI: `<home>/brain/<uuid>/.system_generated/logs/transcript_full.jsonl`.- # Only `brain/` is walked, so Gemini CLI's `tmp/` (a sibling under- # `~/.gemini`) and the Antigravity IDE's `~/.gemini/antigravity/` are- # never reached; `detect_agent` rejects anything else.+ # Antigravity CLI: only `<home>/brain/` is walked (see antigravity_index.py).for home in self.antigravity_homes:- brain_dir = home / "brain"- if not brain_dir.is_dir():- logger.debug("Skipping non-existent path: %s", brain_dir)- continue- summaries = _antigravity_summaries(home)- for jsonl_file in brain_dir.glob("*/.system_generated/logs/transcript_full.jsonl"):- ref = self._index_antigravity_file(jsonl_file, home=home, summaries=summaries)- if ref:- _index_put(index, ref[0], ref[1], newest)+ transcripts = home.glob(ANTIGRAVITY_TRANSCRIPT_GLOB)+ for sid, fields in index_antigravity_home(home, transcripts, self._record_discovery):+ _index_put(index, sid, _FileRef(**fields), newest)_carry_collision_mtimes(index, newest)self._file_index = index@@ -2139,58 +2005,6 @@ class LocalSource:home=home,)- def _index_antigravity_file(- self,- jsonl_file: Path,- *,- home: Path,- summaries: dict[str, _AntigravitySummary],- ) -> tuple[str, _FileRef] | None:- """Index one Antigravity CLI `transcript_full.jsonl`."""- if not jsonl_file.is_file():- return None- size = jsonl_file.stat().st_size- if size == 0:- self._record_discovery("antigravity-cli", "empty_or_unreadable")- return None- try:- head = _read_head(jsonl_file, stop_when=_agent_detected)- except OSError:- self._record_discovery("antigravity-cli", "empty_or_unreadable")- return None-- agent = detect_agent(head)- if agent is None:- logger.warning(- "agent detection failed for %s (%d bytes); session skipped",- jsonl_file,- size,- )- self._record_discovery("antigravity-cli", "detection_failed")- return None- if agent != AgentType.ANTIGRAVITY_CLI:- self._record_discovery("antigravity-cli", "different_agent")- return None-- # brain/<uuid>/.system_generated/logs/transcript_full.jsonl- native_id = jsonl_file.parents[2].name- session_id = f"local:{agent}:{native_id}"- mtime = datetime.fromtimestamp(jsonl_file.stat().st_mtime, tz=UTC)- summary = summaries.get(native_id)- cwd = summary.cwd if summary else None- parent = summary.parent_id if summary else None-- self._record_discovery("antigravity-cli", "indexed")- return session_id, _FileRef(- path=jsonl_file,- agent=agent,- mtime=mtime,- project_name=_project_from_cwd(cwd) if cwd else None,- cwd=cwd,- home=home,- parent_session_id=f"local:{agent}:{parent}" if parent else None,- )-def _index_copilot_file(self,jsonl_file: Path,@@ -2623,9 +2437,9 @@ class LocalSource:project_name=ref.project_name,)if ref.agent in (AgentType.GEMINI_CLI, AgentType.ANTIGRAVITY_CLI) and ref.cwd:- # Neither transcript records a cwd; the indexer read the project- # root from Gemini's `.project_root` or Antigravity's- # `conversation_summaries.db`. Every call ran there.+ # Gemini CLI's transcript records no cwd; the indexer read the+ # project root from `.project_root`. Every call ran there.+ # Antigravity CLI's cwd comes from `conversation_summaries.db`.for span in spans:if span.parent_id is not None and not span.attributes.get("cwd"):span.attributes["cwd"] = ref.cwd@@ -2633,9 +2447,7 @@ class LocalSource:root = next((span for span in spans if span.parent_id is None), None)if root is not None:root.attributes.update({"git.branch": branch, "git.branches": branches})- if ref.parent_session_id:- # A subagent's own conversation (Antigravity CLI): the map- # builder marks it a subagent session under its parent.+ if ref.parent_session_id: # a subagent stored as its own conversation (Antigravity CLI)root.attributes["harness.session_role"] = "subagent"root.attributes["harness.parent_session_id"] = ref.parent_session_id# A cloud-run session stores selected-repository metadata in a sidecar@@ -2739,17 +2551,7 @@ class LocalSource:class _FileRef:"""Internal pointer: session_id → file path + index-time metadata."""- __slots__ = (- "agent",- "branch",- "cwd",- "home",- "mtime",- "parent_session_id",- "path",- "project_name",- "subformat",- )+ __slots__ = ("agent", "branch", "cwd", "home", "mtime", "parent_session_id", "path", "project_name", "subformat")def __init__(self,@@ -2782,8 +2584,7 @@ class _FileRef:# The home dir under which this file was discovered — used to# look up the manifest identity for that home.self.home = home- # Session id of the conversation that spawned this one, for agents- # that store a subagent as its own conversation (Antigravity CLI).+ # Session id of the conversation that spawned this one (Antigravity CLI subagents).self.parent_session_id = parent_session_iddiff --git a/python/src/agentplay/_core/ingestion/coding_agent/tool_taxonomy.py b/python/src/agentplay/_core/ingestion/coding_agent/tool_taxonomy.pyindex e1b9ce6..e7e4ef4 100644--- a/python/src/agentplay/_core/ingestion/coding_agent/tool_taxonomy.py+++ b/python/src/agentplay/_core/ingestion/coding_agent/tool_taxonomy.py@@ -255,7 +255,7 @@ _GEMINI_CLI: dict[str, str] = {# `read_url_content` are names in the 1.4.6 binary that no captured session# used. `send_message` (a subagent reporting to its parent) and other meta# tools pass through unaliased.-_ANTIGRAVITY_CLI: dict[str, str] = {+_ANTIGRAVITY_ALIASES: dict[str, str] = {"run_command": "Bash","read_file": "Read","view_file": "Read",@@ -273,7 +273,7 @@ _ANTIGRAVITY_CLI: dict[str, str] = {}TOOL_ALIASES: dict[str, dict[str, str]] = {- "antigravity-cli": _ANTIGRAVITY_CLI,+ "antigravity-cli": _ANTIGRAVITY_ALIASES,"codex": _CODEX,"gemini-cli": _GEMINI_CLI,"cursor": _CURSOR,diff --git a/python/src/agentplay/discover.py b/python/src/agentplay/discover.pyindex bfacd84..9272cfc 100644--- a/python/src/agentplay/discover.py+++ b/python/src/agentplay/discover.py@@ -44,17 +44,8 @@ from ._util import capturedlogger = logging.getLogger("agentplay.discover")-AGENTS = (- "claude-code",- "codex",- "cursor",- "copilot",- "copilot-vscode",- "opencode",- "kiro",- "gemini-cli",- "antigravity-cli",-)+AGENTS = ("claude-code", "codex", "cursor", "copilot", "copilot-vscode", "opencode", "kiro", "gemini-cli",+ "antigravity-cli")# Transcripts above this size are skipped rather than parsed (a 20k-event map cap# applies anyway; this keeps one pathological file from stalling a run).@@ -283,8 +274,7 @@ def build_map(c: Candidate, source: Any, *, path_mode: str = "relative",spans = source.get_spans_by_session(c.session_id)if not spans:raise SkipSession("no_spans")- # A subagent stored as its own conversation (Antigravity CLI) carries its- # role and parent on the root span.+ # A subagent stored as its own conversation (Antigravity CLI) carries its role and parent on the root span.root = next((s for s in spans if s.parent_id is None), None)root_attrs = root.attributes if root is not None else {}return builder.build_map_from_spans(diff --git a/python/tests/core/test_antigravity_parser.py b/python/tests/core/test_antigravity_parser.pyindex e38d1ef..01361c5 100644--- a/python/tests/core/test_antigravity_parser.py+++ b/python/tests/core/test_antigravity_parser.py@@ -25,6 +25,7 @@ tests build one from the real column schema with made-up rows.from __future__ import annotations+import copyimport jsonimport loggingimport sqlite3@@ -34,16 +35,18 @@ from pathlib import Pathimport pytestfrom agentplay import builder, discover-from agentplay._core.ingestion.coding_agent._sources.local import source as local_source+from agentplay._core.ingestion.coding_agent import tool_taxonomy as tt+from agentplay._core.ingestion.coding_agent._sources.local import antigravity_index+from agentplay._core.ingestion.coding_agent._sources.local.antigravity_index import _path_from_file_urifrom agentplay._core.ingestion.coding_agent._sources.local.parsers import (AgentType,+ antigravity,detect_agent,parse_antigravity,)-from agentplay._core.ingestion.coding_agent._sources.local.source import (- LocalSource,- _path_from_file_uri,-)+from agentplay._core.ingestion.coding_agent._sources.local.source import LocalSource++from .test_parser_robustness import WRONG_TYPES, _assign, _damage_cases, _encode, _pathsFIXTURES = Path(__file__).parent / "fixtures" / "antigravity"GEMINI_FIXTURES = Path(__file__).parent / "fixtures" / "gemini"@@ -675,7 +678,7 @@ def test_deeply_nested_workspace_uris_do_not_abort_discovery(tmp_path, monkeypatexcept RecursionError:passelse:- real_loads = local_source.json.loads+ real_loads = antigravity_index.json.loadsdef loads(raw, *args, **kwargs):text = raw if isinstance(raw, str) else bytes(raw).decode("utf-8", "replace")@@ -683,7 +686,7 @@ def test_deeply_nested_workspace_uris_do_not_abort_discovery(tmp_path, monkeypatraise RecursionError("maximum recursion depth exceeded")return real_loads(raw, *args, **kwargs)- monkeypatch.setattr(local_source.json, "loads", loads)+ monkeypatch.setattr(antigravity_index.json, "loads", loads)home = _antigravity_home(tmp_path, names=("read_explain", "failed_edit"))(home / "conversation_summaries.db").unlink()@@ -712,7 +715,7 @@ def test_summaries_copy_stops_after_three_changing_snapshots(tmp_path, monkeypatwal.write_bytes(b"wal")shm.write_bytes(b"shm")copies: list[str] = []- real_copy = local_source.shutil.copyfile+ real_copy = antigravity_index.shutil.copyfiledef copyfile(src, dst, *args, **kwargs):real_copy(src, dst, *args, **kwargs)@@ -723,8 +726,8 @@ def test_summaries_copy_stops_after_three_changing_snapshots(tmp_path, monkeypatif name == db.name:wal.write_bytes(b"wal" + b"x" * copies.count(name))- monkeypatch.setattr(local_source.shutil, "copyfile", copyfile)- caplog.set_level(logging.DEBUG, logger=local_source.logger.name)+ monkeypatch.setattr(antigravity_index.shutil, "copyfile", copyfile)+ caplog.set_level(logging.DEBUG, logger=antigravity_index.logger.name)source = LocalSource(claude_code_homes=[], codex_homes=[], antigravity_homes=[home])source._build_index()assert source.get_cwd(f"local:antigravity-cli:{IDS['read_explain']}") == "/Users/dev/project"@@ -907,3 +910,99 @@ def test_built_map_of_a_subagent_records_its_parent():doc = _map("subagent_child", role="subagent", parent_session_id=parent)assert doc["session"]["role"] == "subagent"assert doc["session"]["parentSessionId"] == parent+++# ---------------------------------------------------------------- shared sweeps and alias table+# The structural-damage and wrong-type sweeps from test_parser_robustness.py, run+# on a minimal agy step log, and the alias-table checks from test_tool_taxonomy.py.++ROBUSTNESS_TS = "2026-09-14T10:00:0{}Z"+DAMAGE_CASES = (+ "truncated_last_line",+ "invalid_json_line",+ "non_dict_json",+ "unknown_record_type",+ "bom_prefix",+ "non_utf8_bytes",+ "blank_lines",+)+++def _robustness_records() -> list[dict]:+ step = {"source": "MODEL", "status": "DONE", "created_at": ROBUSTNESS_TS.format(1)}+ return [+ {"step_index": 0, "source": "USER_EXPLICIT", "type": "USER_INPUT", "status": "DONE",+ "created_at": ROBUSTNESS_TS.format(0), "content": "<USER_REQUEST>\nlist files\n</USER_REQUEST>"},+ {**step, "step_index": 1, "type": "PLANNER_RESPONSE", "input_tokens": 10, "cache_read_tokens": 2,+ "output_tokens": 5, "thinking": "t",+ "tool_calls": [{"name": "run_command", "args": {"CommandLine": "ls", "WaitMsBeforeAsync": 5000}}]},+ {**step, "step_index": 2, "type": "GENERIC",+ "content": "Created At: 2026-09-14T10:00:02Z\nCompleted At: 2026-09-14T10:00:02Z\n"+ "Command exited with code 0.\n\nCommand output:\nx"},+ {**step, "step_index": 3, "type": "PLANNER_RESPONSE", "input_tokens": 12, "output_tokens": 3,+ "content": "done"},+ ]+++def _turn_count(data: bytes) -> int:+ return len(_turns(parse_antigravity(data, "t")[1]))+++def test_robustness_clean_log_yields_a_turn():+ assert _turn_count(_encode(_robustness_records())) >= 1++[email protected]("case", DAMAGE_CASES)+def test_robustness_structural_damage_keeps_the_session(case, caplog):+ caplog.set_level(logging.CRITICAL)+ clean = _encode(_robustness_records())+ assert _turn_count(_damage_cases(clean)[case]) == _turn_count(clean)+++def test_robustness_wrong_typed_fields_never_raise(caplog):+ caplog.set_level(logging.CRITICAL)+ base = _robustness_records()+ failures = []+ for index, record in enumerate(base):+ for path in _paths(record):+ for bad in WRONG_TYPES:+ records = copy.deepcopy(base)+ _assign(records[index], path, bad)+ try:+ parse_antigravity(_encode(records), "t")+ except Exception as exc:+ failures.append(f"record {index} {path} = {bad!r}: {type(exc).__name__}: {exc}")+ assert not failures, "\n".join(failures[:25])+++def test_robustness_wrong_typed_record_keeps_other_records():+ """A record whose every field is junk costs only itself."""+ base = _robustness_records()+ junk = {"type": 123, "timestamp": 123, "message": "str", "payload": None, "usage": [], "content": None}+ assert _turn_count(_encode([*base, junk])) == _turn_count(_encode(base))+++def test_parser_reads_the_shared_alias_table():+ # Same object, not a copy: a new row in tool_taxonomy reaches the parser.+ assert antigravity._TOOL_ALIASES is tt.aliases_for("antigravity-cli")+++ ("raw", "canonical"),+ [+ ("run_command", "Bash"),+ ("read_file", "Read"),+ ("view_file", "Read"),+ ("edit_file", "Edit"),+ ("write_file", "Write"),+ ("invoke_subagent", "Task"),+ ],+)+def test_known_raw_names_resolve(raw, canonical):+ assert tt.aliases_for("antigravity-cli")[raw] == canonical+++def test_alias_table_size_is_pinned():+ # 14 rows: names seen in real agy 1.4.6 sessions plus tool names in the 1.4.6+ # binary. A changed count means a row was added or dropped on purpose.+ assert len(tt.aliases_for("antigravity-cli")) == 14diff --git a/python/tests/core/test_parser_robustness.py b/python/tests/core/test_parser_robustness.pyindex 5d87305..35dafc5 100644--- a/python/tests/core/test_parser_robustness.py+++ b/python/tests/core/test_parser_robustness.py@@ -21,7 +21,6 @@ import loggingimport pytestfrom agentplay._core.ingestion.coding_agent._sources.local.parsers import (- parse_antigravity,parse_claude_code,parse_codex,parse_copilot,@@ -318,24 +317,7 @@ def _gemini() -> list[dict]:]-def _antigravity() -> list[dict]:- step = {"source": "MODEL", "status": "DONE", "created_at": TS.format(1)}- return [- {"step_index": 0, "source": "USER_EXPLICIT", "type": "USER_INPUT", "status": "DONE",- "created_at": TS.format(0), "content": "<USER_REQUEST>\nlist files\n</USER_REQUEST>"},- {**step, "step_index": 1, "type": "PLANNER_RESPONSE", "input_tokens": 10, "cache_read_tokens": 2,- "output_tokens": 5, "thinking": "t",- "tool_calls": [{"name": "run_command", "args": {"CommandLine": "ls", "WaitMsBeforeAsync": 5000}}]},- {**step, "step_index": 2, "type": "GENERIC",- "content": "Created At: 2026-09-14T10:00:02Z\nCompleted At: 2026-09-14T10:00:02Z\n"- "Command exited with code 0.\n\nCommand output:\nx"},- {**step, "step_index": 3, "type": "PLANNER_RESPONSE", "input_tokens": 12, "output_tokens": 3,- "content": "done"},- ]--PARSERS = {- "antigravity": (parse_antigravity, _antigravity),"claude_code": (parse_claude_code, _claude),"codex": (parse_codex, _codex),"copilot": (parse_copilot, _copilot),diff --git a/python/tests/core/test_tool_taxonomy.py b/python/tests/core/test_tool_taxonomy.pyindex 9bec41e..3a6e1bb 100644--- a/python/tests/core/test_tool_taxonomy.py+++ b/python/tests/core/test_tool_taxonomy.py@@ -10,7 +10,6 @@ import pytestfrom agentplay._core.ingestion.coding_agent import tool_taxonomy as ttfrom agentplay._core.ingestion.coding_agent._sources.local.parsers import (- antigravity,codex,copilot,cursor_agent_transcript,@@ -24,7 +23,6 @@ from agentplay._core.ingestion.coding_agent._sources.local.parsers import (@pytest.mark.parametrize(("module", "agent"),[- (antigravity, "antigravity-cli"),(codex, "codex"),(cursor_store, "cursor"),(cursor_agent_transcript, "cursor"),@@ -53,12 +51,6 @@ def test_every_parser_reads_the_shared_table(module, agent) -> None:("gemini-cli", "read_file", "Read"),("gemini-cli", "replace", "Edit"),("gemini-cli", "write_file", "Write"),- ("antigravity-cli", "run_command", "Bash"),- ("antigravity-cli", "read_file", "Read"),- ("antigravity-cli", "view_file", "Read"),- ("antigravity-cli", "edit_file", "Edit"),- ("antigravity-cli", "write_file", "Write"),- ("antigravity-cli", "invoke_subagent", "Task"),("kiro", "execute_bash", "Bash"),("opencode", "todowrite", "TodoWrite"),],@@ -78,10 +70,8 @@ def test_unknown_and_claude_names_pass_through() -> None:def test_table_sizes_are_pinned() -> None:# These counts are pinned; a changed count means a row was added or dropped on purpose -- update here.# copilot-vscode's 12 rows are pinned against real tool names; gemini-cli's- # 12 against real sessions plus the 0.65 bundle's tool-name constants; antigravity-cli's- # 14 against real agy 1.4.6 sessions plus tool names in the 1.4.6 binary.- assert {a: len(t) for a, t in tt.TOOL_ALIASES.items()} == {- "antigravity-cli": 14,+ # 12 against real sessions plus the 0.65 bundle's tool-name constants.+ assert {a: len(t) for a, t in tt.TOOL_ALIASES.items() if a != "antigravity-cli"} == { # own test pins it"codex": 7,"cursor": 26,"copilot": 23,