Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff
7.4 KiB
7.4 KiB
Issue #64 Code Review Report (3ce5d5f..b0eccc5)
- Job ID:
e95527ef - Reviewer:
agy(herdr:reviewer-agy-01) - Branch:
fix/issue-64-ro-connect - Base .. Head:
3ce5d5fdc108b0435e933a251fe1c1256b5d7973(v4.9.7) ..b0eccc530149bc6e9211727e19921665c7b80492(1 commit) - Verification Worktree:
/var/folders/q_/68sxgw3j073dgjg8wl9s08vw0000gn/T/mam-review/loop-20261019T134017Z-d90c23/1
1. Root Cause Analysis (Task 1)
Why did the Issue #55 agent home guard detect newly created .db-wal and .db-shm sidecars beside another workspace's agy conversation DB during a macOS test run?
- Global
agyconversation directory scan inreconcile.shdrift C (.agents/skills/multi-agent-mux-monitor/scripts/reconcile.sh:797-817):- When an
agysession isrunningand unpinned (agy_conversation_id_ownisNone),reconcile.shglobs every*.dbin${HOME_DIR}/.gemini/antigravity-cli/conversations/(a global directory shared across all workspaces under thatHOME) and invokesverify_session_uuid(cwd, 'agy', uuid, s_eval, mode="discover").
- When an
AgyAgentAdapter.verify_artifactopened every candidate.dbwith read-writesqlite3.connect(path)(.agents/skills/lib_py/agents/adapters/agy.py:60-80):- In
discovermode,verify_artifactreadscache/last_conversations.json. Whenlc_data.get(ctx.cwd) == uuidisFalse(for example,uuidbelongs to another workspace),verify_artifactonly filters outuuidif it is inctx.row.get("_sibling_claimed_uuids")(which tracks siblings in the same workspacecwd) or ifos.path.getmtime(path) < ctx.epoch. - For any conversation
.dbfrom another workspace whosemtime >= ctx.epoch(or whenctx.epochis not set),verify_artifactproceeded toconn = sqlite3.connect(path)to runSELECT count(*) FROM steps.
- In
- macOS persistent WAL sidecar creation:
- On macOS, Apple's system
libsqlite3.dylibsetsSQLITE_FCNTL_PERSIST_WAL = 1by default. Opening a WAL-mode.dbthat currently has no-wal/-shmsidecars with read-writesqlite3.connect(path)and closing it creates<uuid>.db-waland<uuid>.db-shmand leaves them on disk. - Similarly, if any
reconcile.shorverify_artifactcall ran against the realHOME(or if another workspace'sreconcile.sh/agyprocess scannedconversations/*.dbwhile the test suite was running), opening a clean WAL.dbwithsqlite3.connect(path)created<uuid>.db-waland<uuid>.db-shmin~/.gemini/antigravity-cli/conversations/, which_agent_home_guardflagged at session teardown. - Replacing
sqlite3.connect(path)with_ro_connect(path)(mode=ro&immutable=1when no-walexists) prevents MAM from ever creating or removing-wal/-shmsidecars when inspectingagyconversation databases (verified bytest_unpinned_agy_reconcile_leaves_other_workspace_clean_db_without_sidecars, which fails onbase3ce5d5fand passes onheadb0eccc5).
- On macOS, Apple's system
2. Summary of Changes (3ce5d5f..b0eccc5)
Changed Files & Lines (Read-Only Agent DB Queries)
.agents/skills/lib_py/agents/base.py:111-145:- Moved
_ro_connect(db: str)tolib_py.agents.baseas a shared helper (withtempfile.TemporaryDirectory(prefix="mam-ro-")andos.path.basename(path) or "state.db"for thewalonlybranch). - Updated
db_rows_namingdefaultconnectto_ro_connect(conn = (connect or _ro_connect)(db)), socodex.residual_artifacts(state_*.sqlite,thread_history_*.sqlite) and any otherdb_rows_namingcallers also use_ro_connectinstead of plainmode=ro.
- Moved
.agents/skills/lib_py/agents/adapters/opencode.py:3, 161-185:- Imports and reuses
_ro_connectfromlib_py.agents.base.
- Imports and reuses
.agents/skills/lib_py/agents/adapters/agy.py:3, 74:verify_artifact(anddiscover, which delegates toverify_artifact) opensconversations/<uuid>.dbvia_ro_connect(path).
.agents/skills/lib_py/agents/adapters/codex.py:3, 80, 195:_find_rollout_via_db(used by_find_rollout,artifact_path,verify_artifact) anddiscoveropenstate_*.sqlitevia_ro_connect(db).
.agents/skills/lib_py/agents/adapters/hermes.py:3, 51, 100:verify_artifactanddiscoveropen~/.hermes/state.dbvia_ro_connect(hdb).
.agents/skills/multi-agent-mux-status/scripts/status.sh:90-91, 103, 120-121, 290-291, 303, 320-321:- Both
--jsonand text modes use_ro_connectfromlib_py.agents.baseforhermes(hdb),opencode(odb), andcodex(db). Zero rawsqlite3.connectcalls remain instatus.sh.
- Both
.agents/skills/multi-agent-mux-monitor/scripts/reconcile.sh:423, 865, 954, 1047:- Imports
_ro_connectfromlib_py.agents.baseat top level and uses it forhermesdrift C (_ro_connect(hdb)),opencodedrift C (_ro_connect(odb)), andcodexdrift C (_ro_connect(state_db)). Zero rawsqlite3.connectcalls remain inreconcile.sh.
- Imports
tests/test_issue64_ro_connect.py(lines 1-408):- 43 new regression tests covering shared helper identity, all 4 WAL states (
clean,leftover,walonly,writer) acrossagy,codex,hermes, anddb_rows_naming, static and runtime checks ofstatus.shandreconcile.sh, and cross-workspace unpinnedagydrift-C discovery.
- 43 new regression tests covering shared helper identity, all 4 WAL states (
Intentionally Excluded sqlite3.connect Call Sites
- Agent DB write paths (
purge_artifacts):lib_py/agents/adapters/codex.py:152(DELETE FROM threads WHERE id=?)lib_py/agents/adapters/hermes.py:74(DELETE FROM sessions/DELETE FROM messages)lib_py/agents/adapters/opencode.py:193(DELETEfrom 1.x legacy tables)
- MAM's own state database (
agent-sessions.db):lib_py/atomic_yaml.py:61,lib_py/state.py:17,lib_py/verify_session.py:41,lib_py/loop/runner.py:416,lib.sh:1599, 2068.
3. Test Results (Base vs. Head) & Remaining Risks
- Negative verification on
base(3ce5d5f):- Running
tests/test_issue64_ro_connect.pyagainst an archive copy ofbase(3ce5d5f) on macOS:23 failed, 20 passed in 10.97s(everycleanandwalonlystate acrossagy,codex,hermes,db_rows_naming,status.sh,reconcile.sh, plustest_ro_connect_lives_in_base_and_opencode_reuses_it,test_status_and_reconcile_static_ro_connect_usage, andtest_unpinned_agy_reconcile_leaves_other_workspace_clean_db_without_sidecarsfailed as expected).
- Running
- Verification on
head(b0eccc5):tests/test_issue64_ro_connect.py: 43 passedtests/test_issue60_linux_fixes.py: 52 passedtests/test_issue60_opencode_v2.py: 15 passedtests/test_a4_adapter_contract.py: 33 passedtests/test_issue55_agent_homes.py: 11 passedtests/test_issue31_purge_residual.py: 67 passed- Total:
221 passed in 119.66s git status -sandgit diff --checkin the verification worktree are completely clean.
- Remaining risks:
- External processes outside MAM (such as an active
agyIDE/CLI session running in another workspace on the same host) can still create or remove their own conversation.db-wal/.db-shmsidecars in~/.gemini/antigravity-cli/conversations/while a pytest session is running, which_agent_home_guard(which only exempts live non-temp workspace directories forclaude) can observe as a new directory entry. Within MAM itself, all read-only queries againstagy,codex,hermes, andopencodedatabases are now sidecar-safe.
- External processes outside MAM (such as an active
[VERDICT: PASS]