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
@@ -26,10 +26,27 @@ Registers an orchestrator session UUID into the `orchestrator_uuids` list of `.m
|
||||
### Options
|
||||
- `--uuid <uuid>`: Explicitly register the specified orchestrator session UUID.
|
||||
- `--remove <uuid>`: Remove the specified UUID from the `orchestrator_uuids` list.
|
||||
- `--purge-conversation`: With `--remove`, also delete the conversation's on-disk artifacts through its agent adapter (Issue #13). Irreversible — requires `--yes`; refused (exit `5`, registration untouched) while a live process still references the conversation, e.g. when run from inside that very session.
|
||||
- `--yes`: Skip the `--purge-conversation` confirmation (without it the script prints the danger notice and exits `4`).
|
||||
- `--agent <name>`: Adapter to purge with (`claude|agy|hermes|grok|opencode|codex`). Default `auto`: each adapter is asked whether it owns an artifact for the UUID (`agy` → `~/.gemini/antigravity-cli/conversations/<uuid>.db` etc.). Needed because `orchestrator_uuids` stores bare UUIDs, not the agent kind.
|
||||
- `--list`: Display all currently registered orchestrator UUIDs.
|
||||
- `--no-autodetect`: Disable process ancestry auto-detection when `--uuid` is not provided.
|
||||
- `--dry-run`: Output proposed changes without mutating the state registry.
|
||||
|
||||
### Purging the orchestrator conversation
|
||||
|
||||
`multi-agent-mux-stop --purge-conversation` only reaches sessions that have a `herdr_sessions` row; the orchestrator never has one. To wipe an orchestrator conversation for good:
|
||||
|
||||
```bash
|
||||
.agents/skills/multi-agent-mux-orc-onboard/scripts/orc_onboard.sh --remove <uuid> --purge-conversation --yes
|
||||
# purged: ~/.gemini/antigravity-cli/conversations/<uuid>.db
|
||||
# purged: ~/.gemini/antigravity-cli/brain/<uuid>
|
||||
# ...
|
||||
# residual: none (agent: agy)
|
||||
```
|
||||
|
||||
The purge runs before the registry update, so a refused purge (conversation in use, exit `5`) changes nothing. If no adapter finds an artifact for the UUID the registration is still removed with a warning. For agy the adapter also removes the SQLite sidecars (`-wal`/`-shm`/`-journal`), the title annotation and the presence lock (Issue #10) and reports anything under `~/.gemini/antigravity-cli` that still carries the UUID as `WARN residual:`.
|
||||
|
||||
## Auto-Detection Hierarchy (Rev.2)
|
||||
|
||||
When `--uuid` is omitted, `orc_onboard.sh` inspects the process ancestry tree of the nearest agent ancestor (`claude`, `agy`, `hermes`, `grok`, `opencode`, `codex`) in the following order:
|
||||
@@ -51,5 +68,7 @@ When `--uuid` is omitted, `orc_onboard.sh` inspects the process ancestry tree of
|
||||
## Exit Statuses
|
||||
- `0`: Success (registered, removed, listed, or already present).
|
||||
- `1`: Conflict — the ID is currently owned by a `running` sub-agent session row.
|
||||
- `2`: Invalid arguments or malformed ID format.
|
||||
- `2`: Invalid arguments or malformed ID format (including `--purge-conversation` without `--remove`).
|
||||
- `3`: Detection failed — ID could not be determined.
|
||||
- `4`: `--purge-conversation` needs `--yes` — nothing changed.
|
||||
- `5`: Purge refused — the conversation is still in use by a live process; nothing changed.
|
||||
@@ -13,17 +13,26 @@ MODE="add"
|
||||
TARGET_UUID=""
|
||||
AUTODETECT=true
|
||||
DRY_RUN=false
|
||||
PURGE=false
|
||||
YES=false
|
||||
AGENT_HINT="auto"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage: orc_onboard.sh [OPTIONS]
|
||||
|
||||
Options:
|
||||
--uuid <uuid> Register specified orchestrator session UUID
|
||||
--remove <uuid> Remove specified UUID from orchestrator_uuids list
|
||||
--list List all registered orchestrator UUIDs
|
||||
--no-autodetect Disable process ancestry auto-detection when --uuid is omitted
|
||||
--dry-run Preview changes without updating state registry
|
||||
--uuid <uuid> Register specified orchestrator session UUID
|
||||
--remove <uuid> Remove specified UUID from orchestrator_uuids list
|
||||
--purge-conversation With --remove: also delete the conversation's on-disk
|
||||
artifacts through its agent adapter (irreversible;
|
||||
refused while a live process still references it)
|
||||
--yes Skip the --purge-conversation confirmation
|
||||
--agent <name> Adapter for --purge-conversation (claude|agy|hermes|
|
||||
grok|opencode|codex); default: auto-detect from disk
|
||||
--list List all registered orchestrator UUIDs
|
||||
--no-autodetect Disable process ancestry auto-detection when --uuid is omitted
|
||||
--dry-run Preview changes without updating state registry
|
||||
EOF
|
||||
exit 2
|
||||
}
|
||||
@@ -46,6 +55,19 @@ while [ $# -gt 0 ]; do
|
||||
MODE="list"
|
||||
shift
|
||||
;;
|
||||
--purge-conversation)
|
||||
PURGE=true
|
||||
shift
|
||||
;;
|
||||
--yes)
|
||||
YES=true
|
||||
shift
|
||||
;;
|
||||
--agent)
|
||||
if [ $# -lt 2 ] || [ -z "$2" ]; then usage; fi
|
||||
AGENT_HINT="$2"
|
||||
shift 2
|
||||
;;
|
||||
--no-autodetect)
|
||||
AUTODETECT=false
|
||||
shift
|
||||
@@ -197,6 +219,11 @@ if ! is_valid_id "$TARGET_UUID"; then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ "$PURGE" = true ] && [ "$MODE" != "remove" ]; then
|
||||
echo "ERROR: --purge-conversation only applies together with --remove <uuid>." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ "$MODE" = "add" ]; then
|
||||
# Check if running sub-agent session row currently owns this UUID
|
||||
check_owner_rc=0
|
||||
@@ -222,10 +249,45 @@ sys.exit(0)
|
||||
fi
|
||||
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo "[dry-run] would $MODE orchestrator uuid: $TARGET_UUID"
|
||||
if [ "$PURGE" = true ]; then
|
||||
echo "[dry-run] would remove orchestrator uuid: $TARGET_UUID and purge its conversation artifacts (agent: $AGENT_HINT)"
|
||||
else
|
||||
echo "[dry-run] would $MODE orchestrator uuid: $TARGET_UUID"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Issue #13: the orchestrator has no herdr_sessions row, so stop_session.sh
|
||||
# --purge-conversation can never reach its conversation. Purge FIRST, through
|
||||
# the adapter (`lib_py.agents purge`): a refusal because the conversation is
|
||||
# still in use leaves the registration untouched.
|
||||
PURGE_JSON=""
|
||||
if [ "$PURGE" = true ]; then
|
||||
if [ "$YES" != true ]; then
|
||||
echo "DANGER: --purge-conversation will DELETE orchestrator conversation $TARGET_UUID from disk." >&2
|
||||
echo " This cannot be undone: no future resume of that conversation." >&2
|
||||
echo " Re-run with --yes to confirm." >&2
|
||||
exit 4
|
||||
fi
|
||||
purge_rc=0
|
||||
PURGE_JSON="$("$(_delegate_py_bin)" -m lib_py.agents purge "$AGENT_HINT" "$TARGET_UUID" "$WORKSPACE_ROOT")" || purge_rc=$?
|
||||
case "$purge_rc" in
|
||||
0) ;;
|
||||
4)
|
||||
echo "ERROR: conversation $TARGET_UUID is still in use (a live process references it); nothing purged, registration unchanged." >&2
|
||||
exit 5
|
||||
;;
|
||||
5)
|
||||
echo "WARN: no on-disk conversation found for $TARGET_UUID (agent: $AGENT_HINT); nothing to purge." >&2
|
||||
PURGE_JSON=""
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: purge failed (rc=$purge_rc): $PURGE_JSON" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
MAM_TARGET_UUID="$TARGET_UUID" MAM_OP_MODE="$MODE" atomic_dump_yaml "$AGENT_SESSIONS_YAML" <<'PYEOF'
|
||||
import os, sys, json
|
||||
|
||||
@@ -243,4 +305,23 @@ elif op == "remove":
|
||||
d["orchestrator_uuids"] = uuids
|
||||
PYEOF
|
||||
|
||||
echo "Successfully ${MODE}ed orchestrator UUID: $TARGET_UUID"
|
||||
case "$MODE" in
|
||||
add) verb="added" ;;
|
||||
remove) verb="removed" ;;
|
||||
*) verb="${MODE}ed" ;;
|
||||
esac
|
||||
echo "Successfully $verb orchestrator UUID: $TARGET_UUID"
|
||||
|
||||
if [ -n "$PURGE_JSON" ]; then
|
||||
printf '%s' "$PURGE_JSON" | python3 -c '
|
||||
import json, sys
|
||||
d = json.loads(sys.stdin.read() or "{}")
|
||||
for p in d.get("purged", []):
|
||||
print("purged: %s" % p)
|
||||
residual = d.get("residual", [])
|
||||
for p in residual:
|
||||
print("WARN residual: %s" % p)
|
||||
if not residual:
|
||||
print("residual: none (agent: %s)" % d.get("agent"))
|
||||
'
|
||||
fi
|
||||
Reference in new issue
Block a user