fix(issue-10,11,13,15): complete agy purge, orchestrator purge, workspace-anchored registry
Issue #10 - agy purge_artifacts left resumable pieces behind: it now also removes the SQLite sidecars (-wal/-shm/-journal), the title annotation and the presence lock (the lock only once no live process references the conversation), and residual_artifacts() reports anything under ~/.gemini/antigravity-cli still carrying the uuid. Issue #13 - the orchestrator has no herdr_sessions row, so its conversation could not be purged by any skill. `lib_py.agents purge <agent|auto> <uuid>` resolves the adapter from what is on disk (orchestrator_uuids stores bare uuids), refuses while a live process names the uuid (conversation_in_use: process list minus the caller's own lineage, plus lsof), and prints what it purged. `orc_onboard.sh --remove <uuid> --purge-conversation --yes [--agent]` runs it before the registry update so a refusal changes nothing (exit 4 without --yes, 5 while in use). Issue #11 - "Successfully removeed": conjugate add/remove explicitly. Issue #15 - the job registry and audit log followed the caller's cwd, so the pytest suite (create_session.sh with its default onboarding job, run from the repo root) had left 593 test records in the real .mam/jobs. Defaults now resolve MAM_JOBS_DIR / DELEGATE_JOB_LOGS_DIR, then $WORKSPACE_ROOT/.mam/..., then the cwd (mqtt_common.default_registry_dir / get_logs_dir; registry.py, publish_event.py, service.py, create_session.sh, stop_session.sh); the sandbox fixture pins both. The tier suites that used to leak now leave the real registry untouched (881 records before and after). Tests: test_issue10_13_purge.py (13), test_issue15_registry_isolation.py (7); T-O13 pins the corrected message; the R1 helper test and B-9 logs-dir test now assert the workspace-anchored contract; publish_event snapshot updated. Refs #10 #11 #13 #15 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff
This commit is contained in:
1 parent
bd3df890dc
commit
c82ea75a15
20 files changed
+723
-33
No files matched your search
@@ -137,6 +137,31 @@ DEFAULT_REGISTRY_DIR = ".mam/jobs"
|
||||
DEFAULT_TOPIC_ROOT = "python/mqtt/jobs"
|
||||
LOCK_FILENAME = ".lock"
|
||||
|
||||
|
||||
def _workspace_mam_dir(leaf: str) -> Optional[str]:
|
||||
"""`$WORKSPACE_ROOT/.mam/<leaf>` when lib.sh has told us which workspace we
|
||||
serve; None otherwise."""
|
||||
root = os.environ.get("WORKSPACE_ROOT")
|
||||
if root and root.strip() and os.path.isdir(root):
|
||||
return os.path.join(root, ".mam", leaf)
|
||||
return None
|
||||
|
||||
|
||||
def default_registry_dir() -> str:
|
||||
"""Registry root, resolved at call time (Issue #15).
|
||||
|
||||
``MAM_JOBS_DIR`` wins; otherwise the workspace lib.sh exported as
|
||||
``WORKSPACE_ROOT``; otherwise the historical cwd-relative ``.mam/jobs``.
|
||||
Anchoring on the workspace is what keeps a test sandbox (or any caller
|
||||
whose cwd is not the workspace) from registering jobs into whichever
|
||||
``.mam/jobs`` happens to sit under the current directory - the pytest
|
||||
suite used to leave hundreds of onboarding records in the real registry.
|
||||
"""
|
||||
env = os.environ.get("MAM_JOBS_DIR")
|
||||
if env and env.strip():
|
||||
return env
|
||||
return _workspace_mam_dir("jobs") or DEFAULT_REGISTRY_DIR
|
||||
|
||||
# Persistent audit-log layout: .mam/delegate_job_logs/<job_id>/{meta,events,status}.
|
||||
# This is a *separate* artifact from the registry: the registry is the live job
|
||||
# record (mutated in place), the audit log is an append-only history that
|
||||
@@ -150,14 +175,16 @@ def get_logs_dir() -> str:
|
||||
"""Audit-log root, resolved at call time (B-9).
|
||||
|
||||
Overridable with ``DELEGATE_JOB_LOGS_DIR``; otherwise
|
||||
``<cwd>/.mam/delegate_job_logs``. Resolved per call rather than at import
|
||||
so a chdir after import cannot strand the audit trail in the old tree —
|
||||
the same reason ``DEFAULT_REGISTRY_DIR`` stays a relative string.
|
||||
``$WORKSPACE_ROOT/.mam/delegate_job_logs`` (Issue #15, see
|
||||
``default_registry_dir``); otherwise ``<cwd>/.mam/delegate_job_logs``.
|
||||
Resolved per call rather than at import so a chdir after import cannot
|
||||
strand the audit trail in the old tree — the same reason
|
||||
``DEFAULT_REGISTRY_DIR`` stays a relative string.
|
||||
"""
|
||||
env = os.environ.get("DELEGATE_JOB_LOGS_DIR")
|
||||
if env and env.strip():
|
||||
return env
|
||||
return os.path.join(os.getcwd(), ".mam", "delegate_job_logs")
|
||||
return _workspace_mam_dir("delegate_job_logs") or os.path.join(os.getcwd(), ".mam", "delegate_job_logs")
|
||||
|
||||
|
||||
def __getattr__(name: str): # PEP 562 (3.7+)
|
||||
|
||||
@@ -35,6 +35,7 @@ from lib_py.delegation.mqtt_common import (
|
||||
DEFAULT_REGISTRY_DIR,
|
||||
SCHEMA_VERSION,
|
||||
broker_config_from_job,
|
||||
default_registry_dir,
|
||||
events_topic_for,
|
||||
load_job,
|
||||
next_seq,
|
||||
@@ -242,7 +243,7 @@ def main(argv=None) -> int:
|
||||
parser.add_argument("--data", default=None, help="optional JSON object string")
|
||||
parser.add_argument("--retained", action="store_true",
|
||||
help="force retain=True (auto for completed/error)")
|
||||
parser.add_argument("--registry-dir", default=DEFAULT_REGISTRY_DIR)
|
||||
parser.add_argument("--registry-dir", default=default_registry_dir())
|
||||
parser.add_argument("--attempts", type=int, default=3)
|
||||
parser.add_argument("--finalize-report", default=None, metavar="PATH",
|
||||
help="atomically finalize this report and declare its "
|
||||
|
||||
@@ -28,6 +28,7 @@ from lib_py.delegation.mqtt_common import (
|
||||
_atomic_write_record,
|
||||
_utcnow,
|
||||
broker_config_from_env,
|
||||
default_registry_dir,
|
||||
load_job,
|
||||
registry_lock,
|
||||
topic_prefix_for,
|
||||
@@ -266,7 +267,7 @@ def get_feedback(job_id: str, registry_dir: str = DEFAULT_REGISTRY_DIR) -> str:
|
||||
# --------------------------------------------------------------------------
|
||||
def _build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(description="multi-agent-mux-delegate-job registry CLI")
|
||||
parser.add_argument("--registry-dir", default=DEFAULT_REGISTRY_DIR)
|
||||
parser.add_argument("--registry-dir", default=default_registry_dir())
|
||||
sub = parser.add_subparsers(dest="command", required=True)
|
||||
|
||||
p_reg = sub.add_parser("register", help="create a pending job; prints the job id")
|
||||
|
||||
@@ -18,7 +18,7 @@ logger = logging.getLogger("delegate_job.service")
|
||||
|
||||
class DelegationService(object):
|
||||
def __init__(self, registry_dir=None, persistent=False):
|
||||
self.registry_dir = registry_dir or mqtt_common.DEFAULT_REGISTRY_DIR
|
||||
self.registry_dir = registry_dir or mqtt_common.default_registry_dir()
|
||||
self.persistent = persistent
|
||||
self._publisher = None
|
||||
|
||||
|
||||
Reference in new issue
Block a user