fix(opencode): a purge takes its child sessions' 1.x rows, the background service alone holds no session, XDG_DATA_HOME is followed (Issue #60, review)
- Review 614b6263 (codex, P2): `opencode session delete` removes the child
sessions with their parent, but their 1.x rows stayed and the parent's
residual was empty. The child sessions (session_v2 and a 1.x session
table, any depth) are taken before the delete; the 1.x tables (message,
part, todo, session_share, session) are cleaned for all of them, and the
residual also reports a child still on record (a failed delete).
- The in-use check counted any process holding the shared opencode.db; the
per-user 2.x background service (`serve --service`) holds it for every
session, so every opencode purge was refused while it ran (it does on
this Mac). It no longer counts; any other holder and a command line
naming the session still do.
- The data dir follows the caller's XDG_DATA_HOME when ctx is the caller's
own home (else <home>/.local/share), for debug paths, the fallback and the
residual scan (review 614b6263 / f4cedbae N4).
- resident_children = ('opencode',): the --standalone server stays the TUI's
idle child; what runs under it still counts (review 1abe0a90).
- Tests: child sessions on a migrated database, a failed delete, the service
holder, XDG, resident children, drift C pinning the parent over a newer
child session (review f4cedbae N2), and the real-binary test no longer
depends on PATH (N1).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff
This commit is contained in:
1 parent
6b4b96fa18
commit
cb5f439cce
4 files changed
+245
-41
No files matched your search
@@ -1249,6 +1249,17 @@ def test_comp_opencode_create_and_reconcile_and_stop(mam_sandbox, mock_herdr, mo
|
||||
assert s["opencode_session_id_own"] is None
|
||||
assert s["session_id_source"] == "pending-discovery"
|
||||
|
||||
# A subagent's session in the same directory, newer than the TUI's own
|
||||
# (opencode 2.x, Issue #60): drift C must pin the top-level session.
|
||||
import sqlite3
|
||||
odb = os.path.join(os.environ["HOME"], ".local", "share", "opencode", "opencode.db")
|
||||
conn = sqlite3.connect(odb)
|
||||
(parent, directory, created), = conn.execute("SELECT id, directory, time_created FROM session_v2").fetchall()
|
||||
conn.execute("INSERT INTO session_v2 (id, parent_id, directory, time_created) VALUES (?, ?, ?, ?)",
|
||||
(f"{parent}-child", parent, directory, created + 1000))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
# Run reconcile.sh to trigger drift-C materialization
|
||||
reconcile_script = mam_sandbox / ".agents" / "skills" / "multi-agent-mux-monitor" / "scripts" / "reconcile.sh"
|
||||
res_rec = subprocess.run(["bash", str(reconcile_script), "--once", "--emit-diff"], capture_output=True, text=True, cwd=str(mam_sandbox), env={**os.environ, "WORKSPACE_ROOT": str(mam_sandbox)})
|
||||
@@ -1259,7 +1270,7 @@ def test_comp_opencode_create_and_reconcile_and_stop(mam_sandbox, mock_herdr, mo
|
||||
with open(yaml_path) as f:
|
||||
data_after = yaml.safe_load(f)
|
||||
s_after = [x for x in data_after.get("herdr_sessions", []) if x.get("name") == session_name][0]
|
||||
assert s_after.get("opencode_session_id_own") is not None
|
||||
assert s_after.get("opencode_session_id_own") == parent
|
||||
assert s_after.get("last_visible_status") in ("pinned", "resume_verified")
|
||||
|
||||
# Stop session
|
||||
|
||||
Reference in new issue
Block a user