docs: sync memory, docs and skills with the current runtime

Global memory (groups/global/CLAUDE.md):
- add a model/runtime section: current versions (Opus 5.5, SDK 0.3.286,
  Codex 0.159.3), the model upgrade checklist, the stale nested
  node_modules and single-Codex-account gotchas, and the 09-19..10-01 fixes
- fix the garbled credentials paragraph and list every stored credential key
- correct the reviewer description (reviewer is codex, arbiter claude-code)
- the tmpfs/RAM watchdog it described no longer existed; point to the
  restored /home/claude/tmpfs-ram-watchdog.sh
- refresh stale host facts (tmpfs/disk sizes, nvidia-smi version-mismatch
  after driver auto-updates means "reboot pending", not "GPU broken")
- include the Windows CI runner section written on 2026-09-23 that was
  already live but never committed

Docs and skills:
- README / configuration.md / .env.example: current SDK and model
  versions, per-room reviewer/arbiter override, real attachment types,
  existing OpenAI Whisper fallback, src-based service and detached restart
- architecture.md: registered_groups is gone; RestartPreventExitStatus only
  applies to setup-rendered units
- setup/debug/customize skills: canonical DISCORD_*_BOT_TOKEN keys (the old
  alias now aborts startup), Bun instead of Node, Codex OAuth login instead
  of OPENAI_API_KEY, drop ignored register flags, journald instead of
  logs/*.log, room_settings query instead of registered_groups, bun run test
- CONTRIBUTING: drop the reference to the nonexistent /add-telegram skill
- legacy-compat-removal-spec: mark as implemented/historical
- CHANGELOG: add an Unreleased section for the recent fixes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codex
2026-10-01 14:35:53 +09:00
parent a7f2e02699
commit e4828896f6
11 changed files with 196 additions and 56 deletions

View File

@@ -10,7 +10,8 @@ Do not store platform-wide operating rules here. Those now live in `prompts/clau
This host has an NVIDIA GPU available for compute:
- GPU: NVIDIA GeForce RTX 5050 (GB207, Blackwell), 8GB VRAM, compute capability 12.0 (sm_120)
- Driver 595.71.05, CUDA runtime 13.2; `libcuda.so` present so GPU compute is usable
- Driver 595.x (open kernel module), CUDA runtime 13.2; `libcuda.so` present so GPU compute is usable
- Driver packages auto-update via apt. After an update the userspace libs move ahead of the still-loaded kernel module, and `nvidia-smi` fails with `Failed to initialize NVML: Driver/library version mismatch` until the host reboots. CUDA compute through `/home/claude/gpu-venv` keeps working in that state (verified 2026-10-01: libs 595.91, module 595.84, `torch.cuda.is_available()` True). Treat that `nvidia-smi` error as "reboot pending", not "GPU broken".
- Ready-to-use PyTorch (CUDA 12.8 / Blackwell-capable) venv at `/home/claude/gpu-venv` — run with `/home/claude/gpu-venv/bin/python`. `torch.cuda.is_available()` is True.
- For CUDA C compilation, `nvcc` is not installed; install the CUDA Toolkit only if a task needs it.
@@ -24,15 +25,15 @@ Behavioral rule: when a task could meaningfully benefit from the GPU (ML inferen
## Host RAM / disk safety (tmpfs rule)
`/tmp` (7.2G) and `/dev/shm` (13G) are RAM-backed tmpfs. Anything large written there consumes RAM, not disk.
`/tmp` (16G) and `/dev/shm` (16G) are RAM-backed tmpfs. Anything large written there consumes RAM, not disk.
- 2026-06-11 incident: MeloTTS Korean-TTS venv (~2.4GB) was installed into `/tmp/melo311` (tmpfs), eating RAM and risking OOM. Fixed by moving it to disk at `/home/claude/jarvis-tts/melo311` and updating 43 script shebangs.
- Recurrence guards (in place, defence-in-depth):
1. `~/.bashrc` exports `TMPDIR=$HOME/.tmp`, `UV_CACHE_DIR=$HOME/.cache/uv`, `PIP_CACHE_DIR=$HOME/.cache/pip` (all ext4 disk), above the interactive-shell guard so non-interactive agent shells inherit it.
2. The `ejclaw.service` user unit (`~/.config/systemd/user/ejclaw.service`) sets the same three `Environment=` vars, so every child process (agent runners, install/build steps that never source `.bashrc`) inherits disk temp at the systemd root. Applied via `daemon-reload`; takes full effect on the next `ejclaw.service` restart. Do NOT restart it from inside a live agent turn (the agent is its descendant).
3. Scheduled watchdog (cron `*/30`) alerts the group only if `/tmp` or `/dev/shm` > 3GB, available RAM < 4GB, or disk free < 10GB, and auto-deletes `$HOME/.tmp` files older than 3 days. This catches an explicit `/tmp/...` write that bypasses `TMPDIR`.
3. Watchdog `/home/claude/tmpfs-ram-watchdog.sh` (user crontab `*/30`) posts once per episode to the EJClaw #상태 channel when `/tmp` or `/dev/shm` usage > 3GB or MemAvailable < 4GB, re-arms after recovery, and deletes `$HOME/.tmp` files older than 3 days. Token-free (Discord REST with the owner bot token, no agent run); log `/home/claude/tmpfs-ram-watchdog.log`, latches under `~/.tmpfs-ram-watchdog/`. Test with `DRYRUN=1 TMPFS_MAX_MB=100 /home/claude/tmpfs-ram-watchdog.sh`. This catches an explicit `/tmp/...` write that bypasses `TMPDIR`. (The original watchdog had silently disappeared; restored 2026-10-01.) Disk space is watched separately by `/home/claude/disk85-alert.sh` (cron `*/10`, @everyone alert at ≥85% root usage).
- Rule: NEVER install venvs, models, datasets, or any multi-GB artefact into `/tmp` or `/dev/shm`. Use disk paths under `$HOME` (e.g. `/home/claude/jarvis-tts`). If a tool ignores `TMPDIR`, pass an explicit disk path. EJClaw runs directly via `bun` under the user systemd unit (no Docker/compose in use here).
- As of 2026-06-11 the root filesystem was expanded: `/` (ext4) is now 353G total with ~214G free (37% used); earlier it was 156G/84%. RAM is 30GB total, usually ~25GB free. Adding RAM is not the real fix for tmpfs blowups; keeping big artefacts on disk is. Disk is no longer tight, but the watchdog still warns if free drops below 10GB.
- Root filesystem `/` (ext4) is 506G total, ~221G free (55% used) as of 2026-10-01 (it was 156G in early June, then 353G). RAM is 30GB as seen by the guest (Proxmox shows 32GiB and counts guest page cache as "used", so its ~85% figure is misleading — judge by `free -h` → `available`). Adding RAM is not the real fix for tmpfs blowups; keeping big artefacts on disk is.
- The two TTS scratch scripts (`/home/claude/jarvis-tts/gen_melo.py`, `gen_xtts.py`) now route output to disk and hard-refuse any `/tmp` or `/dev/shm` write path via a `disk_path()` guard.
- 2026-07-26 OOM incident + `MemoryHigh` change: the `ejclaw.service` base unit set `MemoryHigh=3G` (soft cgroup cap; `MemoryMax` unset). An agent-launched GPU/diffusers job in the `anyway2` channel (`gen_banner.py`, ~2.9GB RSS on its own) ran INSIDE the bot's cgroup, pushed total past 3G, and `systemd-oomd` oom-killed `ejclaw.service` ~6× in a row (systemd auto-restarted each time → restart loop; the banner also never finished). Fix: raised the soft cap to `MemoryHigh=16G` via a documented drop-in `~/.config/systemd/user/ejclaw.service.d/10-memory-high.conf` (applied with `daemon-reload`, no restart needed for a cgroup-property change). Rationale: host has 30G, KAclaw is capped at 3G and other services ~2G, so 16G leaves ~11G+cache headroom while still capping runaways; `MemoryMax` stays infinity so a burst is throttled, not hard-killed. The base unit still reads 3G — the drop-in overrides it (`systemctl --user cat ejclaw` shows both). Cleaner long-term alternative (not done): keep the bot cap tight and launch heavy GPU jobs OUTSIDE the bot cgroup via `systemd-run --user --scope`.
@@ -57,7 +58,10 @@ Schema: `credentials.<host>.{type, host, token, note, added_at}`.
Currently stored:
- `git.tkrmagid.kr` — Gitea personal access token. Use via `Authorization: token <value>` header, or embed in HTTPS URL as `https://<user>:<token>@git.tkrmagid.kr/...`. For `git clone/push`, prefer the URL form or `git -c http.extraHeader="Authorization: token <value>" clone ...`. Do not paste the raw token into chat replies.
- `sudo` — local sudo password for the `claude` user on this host. Use via `echo "$PW" | sudo -S <cmd>` (read the password from `credentials.sudo.password` with the Read tool, then pipe). Do not paste the raw password into chat replies.
- `discord.com/bot/testbot` — Discord test bot (테스트봇, client/app ID `1538122882528321536`), stored 2026-08-15 for use across all chats. Read the token from `credentials["discord.com/bot/testbot"].token` in secrets.json with the Read tool (token is NOT written here). Use as `Authorization: Bot <token>` against `https://discord.com/api/v10`, or as the bot token for a discord.js/gateway login. Do not paste the raw token into chat replies. Token was chat-exposed on save; if used for anything sensitive/long-term, rotate it in the Discord Developer Portal first. Re-ask the user if Discord returns 401., edit `secrets.json` and append a new entry under `credentials`; update this list with the host and intended use.
- `discord.com/bot/testbot` — Discord test bot (테스트봇, client/app ID `1538122882528321536`), stored 2026-08-15 for use across all chats. Read the token from `credentials["discord.com/bot/testbot"].token` in secrets.json with the Read tool (token is NOT written here). Use as `Authorization: Bot <token>` against `https://discord.com/api/v10`, or as the bot token for a discord.js/gateway login. Do not paste the raw token into chat replies. Token was chat-exposed on save; if used for anything sensitive/long-term, rotate it in the Discord Developer Portal first. Re-ask the user if Discord returns 401.
- Other entries (each has its own `note` with usage rules — read it before use): `docker5.ssh` (root password fallback for .5; prefer key auth), `kis.koreainvestment` + `dart.fss.or.kr` (stock-adviser APIs), `huggingface.co` (read token), `anthropic.api` (stock-adviser API key with a monthly budget cap; also usable to list models via `GET /v1/models`), `tossinvest.com` (IP-allowlisted), `washing_machine_app.keystore`, `api.smartthings.com`, `discord.com/oauth/virtual-stock-site-bot`, `youtube.oauth/music_bot_v2`, and per-repo GitHub PATs `github.com/Kacarong/{style-ai-site,flight-tracker,stock-adviser,virtual-stock-site-bot,cgv-macro}` (use only via ephemeral push URLs, never persist in `.git/config`).
To add a credential: edit `secrets.json`, append a new entry under `credentials`, and add the key + intended use to this list. Never paste raw secret values into chat or into this file.
## User communication preferences
@@ -65,7 +69,7 @@ Currently stored:
## Room mode policy
All rooms default to `tribunal` (paired) mode. Owner runs the work, reviewer/arbiter (claude-code) verifies. New rooms registered via `bun setup/index.ts --step register` are also `tribunal` by default.
All rooms default to `tribunal` (paired) mode. Owner (claude-code) runs the work, the reviewer (codex, `REVIEWER_AGENT_TYPE=codex`) verifies, and the arbiter (claude-code) breaks deadlocks. New rooms registered via `bun setup/index.ts --step register` are `tribunal` by default and get their paired workspace (`work_dir`) provisioned at registration. A room that ends up tribunal with `work_dir = NULL` (e.g. created through another path) is now self-healed on its first turn (fix c7a8a43, 2026-09-19); before that fix such rooms silently dropped follow-up messages.
If the user in a channel says any of these — "클로드 사용하지 말자", "paired 모드 끄자", "리뷰어 끄자", "이 방은 single 로 바꿔줘" — switch that channel back to `single` mode. Use:
@@ -150,6 +154,119 @@ Fix (mirrors the Claude per-service isolation above): EJClaw now uses a dedicate
then open the printed `https://auth.openai.com/codex/device` URL and enter the one-time code. A plain `codex login` writes to `~/.codex` and will NOT update the account EJClaw uses. Account: ChatGPT `account_id 7e40ecd8-461b-49bd-bbe4-cdc6c7dc68cf`.
- Verify: `cd /home/claude/EJClaw && bun -e 'import {initCodexTokenRotation,getActiveCodexAuthPath} from "./src/codex-token-rotation.ts"; initCodexTokenRotation(); console.log(getActiveCodexAuthPath())'` → should print `/home/claude/.codex-accounts/0/auth.json`.
## EJClaw / KAclaw model + runtime versions (updated 2026-10-01)
Current state:
- EJClaw: `CLAUDE_MODEL=claude-opus-5-5` (Claude Opus 5.5), `CLAUDE_EFFORT=high`, `CLAUDE_THINKING=adaptive`. Runner SDK `@anthropic-ai/claude-agent-sdk` 0.3.286 → bundled Claude Code CLI 2.1.286 (pinned in `runners/agent-runner/package.json`). Reviewer: Codex `gpt-5.5` via `@openai/codex` 0.159.3 (pinned in `runners/codex-runner/package.json`). `.env` backup before the 5.5 switch: `/home/claude/ejclaw-env-backup-20261001-140746`.
- KAclaw: `CLAUDE_MODEL=claude-opus-5` (account hjj100411, Pro). Not upgraded to 5.5 — it likely needs the same SDK bump first.
Model upgrade checklist (both incidents below were caused by skipping it):
1. Get the exact model ID from the models API, never by guessing from the marketing name: `curl -s https://api.anthropic.com/v1/models -H "x-api-key: <anthropic.api key>" -H "anthropic-version: 2023-06-01"`. Valid 5.x IDs as of 2026-10-01: `claude-opus-5-5`, `claude-sonnet-5-5`, `claude-opus-5`, `claude-sonnet-5`, `claude-fable-5-1`, `claude-fable-5`. Writing `5.0` as `claude-opus-5-0` is invalid — that typo broke every KAclaw channel 2026-09-17 → 09-21.
2. Before editing `.env`, run a real query through the service's own SDK + bundled binary + credentials (`query({model, pathToClaudeCodeExecutable: <repo>/node_modules/@anthropic-ai/claude-agent-sdk-linux-x64/claude})` with `CLAUDE_CREDENTIALS_PATH` exported). Newer models can require a newer Claude Code CLI: Opus 5.5 is rejected by CLI 2.1.153 with `400 ... version 2.1.280 or newer is required`, so the SDK had to be bumped first.
3. Opus/Sonnet 5.x support only `adaptive` thinking — keep `CLAUDE_THINKING=adaptive` (`enabled` + budget fails on 5.x).
4. Apply with the detached `systemd-run … systemctl --user restart` form and verify the new PID + zero `does not support this model` / `issue with the selected model` log lines.
Gotchas found 2026-10-01:
- **Stale nested `node_modules` can shadow the lockfile version.** `runners/codex-runner/node_modules/@openai/codex` held an untracked 0.124.0 copy from 2026-04-26, so the reviewer kept running 0.124 no matter what the pin said (that old CLI failed every run with `failed to decode models response: unknown variant max` and dumped the whole models payload into the journal). It was removed (backup `/home/claude/.tmp/stale-codex-backup/`). After any runner dependency bump, verify what the runner really loads: `cd runners/codex-runner/dist && bun -e "const p=Bun.resolveSync('@openai/codex/package.json', process.cwd()+'/index.js'); console.log(p, require(p).version)"` — it must be the root `node_modules` path.
- **One Codex account = one Codex run at a time.** The per-account auth lease is exclusive (protects refresh-token rotation). Two rooms needing Codex at once used to fail the second run instantly ("Codex rotation pool unavailable") and close the task as `reviewer_codex_unavailable` — the review was silently skipped (3× on 2026-09-28). Since fix 30ba510 the second run waits up to 15 min for the lease; a dead/rate-limited pool still fails fast. Adding a second Codex account under `~/.codex-accounts/1/` would remove the waiting.
- The service runs `bun src/index.ts`, so root `dist/` staleness does not matter; runner `dist/` (spawned by path) does — rebuild with `bun run build:runners` after runner changes.
EJClaw fixes 2026-09-19 → 10-01 (details in each commit message):
- c7a8a43 — tribunal room with `work_dir = NULL` self-heals instead of freezing its task revision and dropping follow-ups for 10 min.
- 69ae334 — superseded run's 5s progress ticker is stopped when it loses the turn attempt (room no longer looks frozen).
- 8b68885 — claude-agent-sdk 0.3.153 → 0.3.286 for Opus 5.5.
- 30ba510 — wait for a busy Codex lease instead of skipping the review.
- a7f2e02 — @openai/codex 0.133 → 0.159.3 (+ stale 0.124 nested copy removed); simple reviewer turn 49s → 5s, 0 app-server errors.
## Windows CI 러너 / .9 중첩 가상화 (2026-09-23) — 모든 프로젝트 공용
`.9` 안에서 Windows VM 을 돌려 Windows 전용 경로를 자동 검증할 수 있다.
LiveSub 에서 처음 구축했지만 **어느 프로젝트든 그대로 재사용**하면 된다.
### 중첩 가상화 — 된다 (실측)
`.9` 는 Proxmox 위의 QEMU/KVM VM 이지만 중첩 가상화가 켜져 있다.
`/dev/kvm` 존재, `kvm_intel nested=Y`, `qemu -enable-kvm` → `kvm support: enabled`.
- 설치해 둔 것: `qemu-system-x86`, `ovmf`, `swtpm`, `swtpm-tools`, `xorriso`
- **`claude` 계정을 `kvm` 그룹에 넣었다.** `/dev/kvm` 이 `root:kvm 0660` 이라
없으면 `Could not access KVM kernel module: Permission denied` 로 죽는다.
usermod 는 재로그인해야 적용되므로 그 전에는 `sg kvm -c '...'` 로 감싼다.
- **중첩 GPU 패스스루는 불가능하다.** IOMMU 그룹 0개, 커널 cmdline 에 iommu
옵션 없음. GPU 검증은 `.9`(리눅스)에서 직접 해야 한다.
### 자원 한계 — CPU 는 절대 늘리지 말 것 (실측 근거)
물리 호스트는 **i7-11700 (8코어/16스레드), RAM 62.6GB** 다. Proxmox(`192.168.10.2`)
에는 SSH 키가 없어 접근 못 하지만, `.5` LXC 를 통해 호스트 스펙을 읽을 수 있다.
`/proc/meminfo` 는 lxcfs 가 컨테이너 한도로 가리므로
**`/sys/devices/system/node/node0/meminfo`** 를 읽어야 진짜 값이 나온다.
`.9` 의 vCPU 를 늘리면 `.5` 의 운영 컨테이너 19개가 느려진다. `.5` 응답 실측:
```
.9 한가할 때 616~628ms 기준
.9 가 4코어 사용 657~678ms +7% <- VM 100% 인 정상 상황
.9 가 8코어 전부 1487~1491ms +140% <- 이 상태를 만들면 안 된다
```
그래서 VM 은 **vCPU 4 / RAM 8GB / 디스크 80GB** 로 띄우고, 최악을 막으려면
`CPUQuota=400%` + `CPUWeight=50` 을 건다. CI 작업은 코어 4개에서 포화하므로
더 줘도 빨라지지 않는다 (파이프라인 2코어 13초 / 4코어 10초 / 8코어 11초).
### ⚠️ VM 은 반드시 `systemd-run --user --scope` 로 띄울 것
에이전트 턴에서 그냥 `qemu` 를 실행하면 VM 이 **봇의 cgroup 안에서** 돈다.
`ejclaw.service` 는 `MemoryHigh=16G` 이고 8GB VM 이 그 안에 들어가면 상한을
쳐서 봇이 OOM 으로 죽는다 (2026-07-26 에 실제로 6회 연속 OOM 전례 있음).
```bash
systemd-run --user --scope -p MemoryMax=10G -p CPUQuota=400% -p CPUWeight=50 \
--unit win-ci qemu-system-x86_64 -enable-kvm -m 8192 ...
```
`app.slice` 의 형제 scope 로 빠지는 것을 실측 확인했다.
### ISO 출처 (라이선스 키 불필요)
- **Windows 11 Enterprise LTSC 2024 평가판** (90일, 키 없이 설치·사용)
`https://go.microsoft.com/fwlink/p/?linkid=2289029` → 4.8GB
파일명 `26100.1742...CLIENT_LTSC_EVAL_x64FRE_en-us.iso` (빌드 26100 = 24H2)
LTSC 라 Store·소비자 앱이 없어 CI 러너로 오히려 유리하다.
90일 후에는 `slmgr /rearm` 으로 최대 3회 연장하거나 VM 을 다시 만든다.
- **virtio-win** (virtio 드라이버)
`https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso` → 0.9GB
- 다운로드 속도 약 12.5MB/s → 둘 합쳐 약 8분.
- 사용자 지시: **설치 끝나면 ISO 는 지워서 디스크를 회수할 것.**
### VM 구성 시 빠뜨리면 조용히 실패하는 것들
- `-device virtio-vga,max_outputs=2` — 화면 2개. 기본 `-vga std` 는 1개라
**모니터 선택 기능을 검증할 수 없다.** 게스트에 virtio-gpu 드라이버 필요.
- 오디오 장치를 안 붙이면 WASAPI 장치 열거가 0개로 실패한다.
- **자동 로그온 필수.** 러너를 서비스로 돌리면 데스크톱 세션이 없어 GUI
테스트와 스크린샷이 전부 실패한다. 자동 로그온 + 로그온 시 예약 작업.
- Windows 11 은 TPM 2.0 + SecureBoot 필요 → `swtpm` + `OVMF_CODE_4M.secboot.fd`.
### Gitea Actions 러너
- 라벨 형식 `<name>[:<schema>]`, schema 기본값 `host`.
- **라벨이 안 맞아도 작업이 실패하지 않고 기본 ubuntu 컨테이너에서 돈다.**
Windows 검증이 조용히 리눅스에서 도는 착각이 생기므로 워크플로 첫 단계에서
`RUNNER_OS` 를 확인해 막을 것.
- `shell: bash` 를 쓰지 말 것. Git for Windows 를 깔아도 `bash.exe` 는 기본
PATH 에 없다 (`Git\cmd` 만 등록). `pwsh`(PowerShell 7) 를 쓰고 winget 으로
`Microsoft.PowerShell` 을 설치해야 한다.
- GPU 러너를 여러 프로젝트가 공유하면 **`capacity: 1`** 을 반드시 확인한다.
워크플로 `concurrency` 는 같은 저장소 안에서만 막아준다.
### .9 재부팅 시 확인 (2026-09-23 기준)
`linger=yes` 이고 아래 유저 서비스가 전부 `enabled` 라 재부팅 후 자동 복구된다.
ejclaw, kaclaw, geoglobe-web/tunnel, unifi-site/tunnel, exvideo-tunnel,
wsai-voice, xmas-counter, vncserver, filter-chain. 시스템 쪽은 docker,
containerd, ollama 가 enabled. 재부팅 전에 이 목록을 다시 확인할 것.
## .5 Docker host + remote docker context (2026-07-21)
A second LAN machine runs Docker workloads; any Claude channel on .9 can drive it.