refactor(skills): cleanup dead code + full workflow A→B→C→D integration

Cleanup:
- Remove unused validate_yaml() helper from lib.sh
- Remove USER_MANUAL.html + mqtt-broker-setup.html (no refs found)

Workflow A (create_session ↔ delegate-job):
- Add --submit-job <prompt> option to create_session.sh
- Auto-register session in delegate-job registry, store delegate_job_id in YAML

Workflow B (push-based monitor):
- Migrate reconcile.sh to MQTT subscriber mode (polling fallback preserved)

Workflow C (unified status):
- status.sh now shows session + delegate-job state in single column

Workflow D (audit log + perms):
- JSON job files chmod 600
- create/delete/resume now publish lifecycle events to delegate-job
This commit is contained in:
2026-06-19 14:27:29 +00:00
parent 97f649a3e1
commit 0eb1d94a9c
15 changed files with 335 additions and 3688 deletions
@@ -61,15 +61,17 @@ if [ -z "$AGENT" ]; then
esac
fi
# 세션이 YAML 에 있는지 + 해당 row 의 워크스페이스 cwd 추출
TARGET_CWD=$(env_python "$AGENT_SESSIONS_YAML" SESSION_NAME="$SESSION_NAME" <<'PYEOF'
# 세션이 YAML 에 있는지 + 해당 row 의 워크스페이스 cwd 및 delegate_job_id 추출
MAPPED_DATA=$(env_python "$AGENT_SESSIONS_YAML" SESSION_NAME="$SESSION_NAME" <<'PYEOF'
import os, yaml
name = os.environ['SESSION_NAME']
with open(os.environ['YAML_PATH']) as f:
d = yaml.safe_load(f) or {}
for s in d.get('tmux_sessions', []):
if s.get('name') == name:
print((s.get('pane') or {}).get('cwd', ''))
cwd = (s.get('pane') or {}).get('cwd', '')
jid = s.get('delegate_job_id', '') or ''
print(f"{cwd}|{jid}")
raise SystemExit(0)
raise SystemExit(7)
PYEOF
@@ -78,6 +80,9 @@ PYEOF
exit 1
}
TARGET_CWD="${MAPPED_DATA%|*}"
DELEGATE_JOB_ID="${MAPPED_DATA#*|}"
# purge 확인
if [ "$PURGE" = "1" ] && [ "$YES" != "1" ]; then
echo "DANGER: --purge-conversation will DELETE this workspace's on-disk conversation."
@@ -104,6 +109,20 @@ if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
LAST_STATUS=$(tmux capture-pane -t "$SESSION_NAME" -p -S -10 2>/dev/null | tr '\n' ' ' | head -c 500 || true)
fi
if [ -n "$DELEGATE_JOB_ID" ]; then
py_bin="python3"
d_dir="$(dirname "${BASH_SOURCE[0]}")"
while [ "$d_dir" != "/" ] && [ -n "$d_dir" ]; do
if [ -x "$d_dir/.venv/bin/python" ]; then
py_bin="$d_dir/.venv/bin/python"
break
fi
d_dir="$(dirname "$d_dir")"
done
pub_script="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)/delegate-job/scripts/publish_event.py"
"$py_bin" "$pub_script" --job "$DELEGATE_JOB_ID" --event progress --detail "terminating" || true
fi
# hard 모드면 tmux 죽임
if [ "$MODE" = "hard" ] && [ "$TMUX_ALIVE" = "1" ]; then
tmux kill-session -t "$SESSION_NAME"
@@ -187,6 +206,20 @@ elif purge and not purge_uuid:
print(f"updated: {name} status={target['status']}", flush=True)
PYEOF
if [ -n "$DELEGATE_JOB_ID" ]; then
py_bin="python3"
d_dir="$(dirname "${BASH_SOURCE[0]}")"
while [ "$d_dir" != "/" ] && [ -n "$d_dir" ]; do
if [ -x "$d_dir/.venv/bin/python" ]; then
py_bin="$d_dir/.venv/bin/python"
break
fi
d_dir="$(dirname "$d_dir")"
done
pub_script="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)/delegate-job/scripts/publish_event.py"
"$py_bin" "$pub_script" --job "$DELEGATE_JOB_ID" --event completed --detail "session terminated" || true
fi
echo
echo "=== delete complete ==="
echo " session: $SESSION_NAME"