[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6JEV0AZPQRWFTCCQ8AG1FN6":3,"skill-same:01M6JEV0AZPQRWFTCCQ8AG1FN6":67},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":45,"commitSha":46,"skillDirectory":47,"forksCount":48,"repositoryHtmlUrl":49,"repositoryHomepageUrl":50,"ownerHtmlUrl":51,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":52,"install":53,"resources":66},"01M6JEV0AZPQRWFTCCQ8AG1FN6","security-scanning",null,"Design, build, and maintain automated daily security scans for a multi-machine CTO fleet. Covers scan architecture, macOS-specific scripting quirks, SSL cert checking, supply-chain auditing, and CVE monitoring.","S3YED\u002Fappie-kit","S3YED","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F62743867?v=4","01M6JBKBRRVP6KMS0VWZ27T3R6","01M6JBKBX0KG30284PW1DBYJT1",14,"MIT","https:\u002F\u002Fgithub.com\u002FS3YED\u002Fappie-kit\u002Fblob\u002Fmaster\u002Fskills\u002Fmisc\u002Fsecurity-scanning\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"security","security scanning","scanning","improve","for","cto","you","supply","scan","exploration","youtube","design","explore","supply-chain","monitoring","topology","security scan","secure","architecture","macos","2026-11-10 10:12:30",false,"---\nname: security-scanning\ntitle: Daily Security Scanning & Fleet Health Automation (v2)\ndescription: Design, build, and maintain automated daily security scans for a multi-machine CTO fleet. Covers scan architecture, macOS-specific scripting quirks, SSL cert checking, supply-chain auditing, and CVE monitoring.\ntrigger: User asks for security scan, daily briefing, fleet health check, fleet exploration, tailnet reconnaissance, 'scan the fleet', 'check certificates', 'build a security cron job', 'daily security suggestions', 'governance pattern', 'secure all client bots', 'can you access all bots', 'check bot health', 'check client bots', 'youtube deeds', 'explore tailnet', 'inventory fleet', 'improve security scripts', 'daily research', or any request to automate security monitoring, discover fleet topology, or continuously harden the fleet based on research.\n---\n\n# Daily Security Scanning & Fleet Health Automation (v2)\n\n## When to Use\n\nBuild or maintain a daily security scan when:\n- User requests a \"security scan\" or \"daily security briefing\"\n- Setting up cron jobs for CTO oversight\n- Automating fleet health monitoring\n- Checking SSL cert expiry, CVE feeds, supply chain vulns\n- Any recurring security audit workflow\n\n## Scan Architecture (v2 — 9 Layers)\n\nThe canonical script lives at the workspace path `~\u002Fclawd\u002Ftools\u002Fappie-3-daily-security-scan.sh`. The actual runnable copy is at `~\u002F.hermes\u002Fscripts\u002Fappie-3-daily-security-scan.sh` (or the profile-specific scripts dir, e.g. `~\u002F.hermes-appie3\u002Fscripts\u002F` on some setups). Every layer maps to a function.\n\n### Layer 1: Local Machine Health\n\n```bash\n- Disk usage (df -h \u002F)\n- Memory: vm_stat — use grep, NOT awk \u002Fpattern\u002F\n  * WRONG: vm_stat | awk '\u002Fpages active\u002F {print $NF}'  → empty!\n  * RIGHT: vm_stat | grep 'pages active' | awk '{print $NF}'\n  * On macOS vm_stat output starts with uppercase \"Pages\", awk \u002Fpages\u002F doesn't match\n  * If >90% active: dump top 5 processes by RSS + swap info\n- Load averages (sysctl vm.loadavg \u002F uptime)\n- Hermes agent count (pgrep -f hermes_cli | wc -l)\n- Failed logins in 24h (log show --predicate)\n```\n\n### Layer 2: Fleet Health (SSH via Tailscale)\n\nUses **4 category arrays** (all indexed, pipe-separated — bash 3.x compat):\n\n| Array | Emoji | Condition | Check Type |\n|-------|-------|-----------|------------|\n| `FLEET` | ?\u002F? | SSH key works | Full SSH health (disk, load, Hermes, updates) |\n| `BROKEN_KEYS` | ? | Online, port 22 open, key rejected | `nc -zv` port check (\u003C1s) |\n| `TAILNET_ONLINE` | ⚪ | Online, no SSH daemon | Tailnet status only |\n| `GHOSTS` | ? | Offline >7d | Archived, no active check |\n\nEntry format: `\"name|user@tailscale_ip|ssh_key_path|description\"`\nSSH: `-o ConnectTimeout=5 -o BatchMode=yes -o StrictHostKeyChecking=no`\nResults cached to FLEET_CACHE file (pipe-separated: `name|status|desc`)\n\n**Key v2 fix**: FLEET_CACHE is shared between markdown report and Telegram output. NO separate SSH loop for Telegram. This eliminates the v1 Telegram divergence bug.\n\n**Tailnet-only entries** (BROKEN_KEYS, TAILNET_ONLINE, GHOSTS) also write to FLEET_CACHE so the Telegram output can render all 4 groups in sequence from a single cache read. This is critical for completeness — the Telegram scan should show ALL tailnet nodes, not just SSH-reachable ones.\n\n### Layer 3: Local Open Ports\n\n```bash\nlsof -iTCP -sTCP:LISTEN -P -n | awk 'NR>1 && !seen[$1,$9]++'\n```\nFlags unexpected dev services on unprivileged ports. Expected: bun on 37701 (Hermes internal).\n\n### Layer 4: Supply Chain Security\n\n```bash\n# npm audit (high+ only)\nnpm audit --audit-level=high\n\n# Python safety check\nsafety check --short\n\n# Gitleaks secret scan — CRITICAL: always use --no-git with .gitleaks.toml\ngitleaks detect --source $CLAWD_DIR --no-git --config .gitleaks.toml --verbose\n```\n- **ALWAYS --no-git**: git mode scans 2369 commits (487MB) → 35k false positives\n- **ALWAYS .gitleaks.toml**: suppress example keys, lockfile hashes, test data\n- **ALWAYS timeout 60**: gitleaks --no-git can CPU-spike to 975%\n- Extract leak count from \"leaks found: N\" line, not grep -c\n\n### Layer 5: SSL\u002FTLS Certificates\n\n```bash\n# Use brew OpenSSL — system LibreSSL can't parse x509 output\nossl=\"\u002Fopt\u002Fhomebrew\u002Fbin\u002Fopenssl\"\ncert_raw=$(echo \"\" | \"$ossl\" s_client -servername \"$domain\" -connect \"$domain\":443 2>&1)\nenddate=$(echo \"$cert_raw\" | \"$ossl\" x509 -noout -enddate 2>\u002Fdev\u002Fnull | cut -d= -f2)\n```\n- NO 2>\u002Fdev\u002Fnull on s_client (kills output in subshell)\n- NO timeout wrapper (kills mid-handshake)\n- Flag \u003C7d ?, \u003C30d ⚠️\n\n### Layer 6: Security Headers\n\n```bash\ncurl -sI --max-time 5 \"https:\u002F\u002F$domain\"\n# Check for: HSTS, CSP, X-Frame-Options, X-Content-Type-Options\n```\nAll 4 required. Score: 4\u002F4 ?, 2-3 ⚠️, 0-1 ?.\nCaveat: follow redirects with `-L` if domain uses Cloudflare\u002Fredirect chains.\n\n### Layer 7: Pending Updates (fleet SSH)\n\n```bash\nssh \u003Cnode> \"apt list --upgradable | grep -v 'Listing...' | wc -l\"\nssh \u003Cnode> \"apt list --upgradable | grep -i security | wc -l\"\n```\n- Security count via `grep -i security` (not `-security` — varies by distro)\n- 0 updates ✅, 1-20 ⚠️, 20+ or any security ?\n\n### Layer 8: Tailscale Network\n\n```bash\ntailscale status --json | python3 -c \"import sys,json; ...\"\n```\nCounts peers, finds offline nodes, shows last-seen timestamps.\n\n### Layer 9: CVE Watch (v2 — no NVD)\n\n**PRIMARY: GitHub Advisory API** (no auth, no rate limit issues)\n```\nGET https:\u002F\u002Fapi.github.com\u002Fadvisories?type=reviewed&severity=critical&per_page=8\n```\n- Returns GHSA advisories sorted by `published_at` desc\n- Use HTTP status code check (curl -w %{http_code}) — don't rely on python successfully parsing\n- Filter by published_at within 48h via Python datetime comparison\n- Also fetch high severity for awareness\n\n**SECONDARY: OSV.dev** (per-package, always works)\n```\nPOST https:\u002F\u002Fapi.osv.dev\u002Fv1\u002Fquery\n{\"package\": {\"name\": \"openssl\", \"ecosystem\": \"PyPI\"}}\n```\n- Query key packages: openssl, node, curl\n- Also query agent frameworks via `agent-framework-cve-scan.py` (see `references\u002Fagent-framework-cve-scan.md`)\n- Filter by published date within 90d\n- No auth needed, no rate limits observed\n\n**TERTIARY: Agent Framework & Go Ecosystem CVE Scanner** (standalone Python script)\n  - Covers 20 packages: 17 Python agent frameworks (LangChain, CrewAI, Semantic Kernel, AutoGen, LlamaIndex, LiteLLM, guardrails-ai, giskard, etc.) + 3 Go infra packages (golang.org\u002Fx\u002Fcrypto, github.com\u002Fgo-chi\u002Fchi, github.com\u002Fsigstore\u002Frekor)\n  - Checks `pip list` locally + OSV.dev API per package\n  - Go packages added 2026-06-26 n.a.v. 7 critical SSH crypto CVEs published 2026-06-25\n- Run: `python3 ~\u002Fclawd\u002Ftools\u002Fagent-framework-cve-scan.py`\n- See `references\u002Fagent-framework-cve-scan.md`\n\nNVD API v2.0 is NOT used — requires API key to avoid 5 req\u002F30s limit. Free key tier exists but is unavailable from this environment.\n\n### Layer 10: Bot & Client Health Check (ad-hoc, not in daily scan)\n\nRun periodically (weekly or on demand) — check all active Telegram bots and web live services for basic health:\n\n```bash\n# 1. List deployed bots from project config\n# 2. For each bot endpoint, check:\n#    - curl -m 5 \u003Cbot_url>\u002Fhealth (or \u002F) — returns 200?\n#    - curl -m 5 \u003Cbot_url> | grep -i \"ok\\|alive\\|running\"\n# 3. For Telegram bots, check response via bot API:\n#    curl -m 5 \"https:\u002F\u002Fapi.telegram.org\u002Fbot\u003CTOKEN>\u002FgetMe\"\n# 4. For YouTube \u002F media bots, check if deploy is still live on platform\n```\n\nNot automated as a daily cron (too many client-specific endpoints, rate-limit risk on Telegram API). Run as an ad-hoc CTO audit.\n\n### Layer 11: Continuous Improvement — Research → Scripts\n\nSeyed's standing directive: **use the daily AI briefing research to improve the security scripts.** After each daily briefing, scan the research output for:\n\n| Signal | Action |\n|--------|--------|\n| New CVE class or attack vector | Add a check layer or tool to the scan |\n| New tool or best practice | Add install command + verification to the scan or host-init |\n| Configuration hardening advice | Add to the security suggestion pipeline |\n| Client bot platform deprecation | Flag in bot health check layer |\n| New scanning methodology | Replace or augment an existing scan layer |\n\nImplementation checklist after each daily briefing:\n1. Read the research output (`~\u002Fclawd\u002Fappie-brain\u002Fknowledge\u002Fresearch\u002Fdaily-research\u002FYYYY-MM-DD\u002FREADME.md`)\n2. Cross-reference against existing scan layers — what's missing?\n3. For any gap: add a new function to the scan script or update existing logic, **or create a standalone script** for cross-platform use\n4. Test the change: run the affected layers manually\n5. If the improvement is structural (new layer, new tool), update this SKILL.md — add a reference file if the new tool has its own docs\n6. Log to Mission Control: `mc-log-task.py \"Security script improvement: \u003Csummary>\" --agent Appie-3`\n\n**Do not batch up improvements.** Make them as you discover them. A one-line regex addition or a new cert check costs nothing; deferring it until \"next Monday\" means it never happens.\n\n**Examples of recent improvements from research:**\n- `agent-framework-cve-scan.py` — created from 2026-06-20 briefing which found CVE-2026-26030 (Semantic Kernel RCE), GHSA-gr75-jv2w-4656 (LangChain path traversal). Expanded 2026-06-25 +3 (litellm, guardrails-ai, giskard). Expanded 2026-06-26 +3 Go infra packages (golang.org\u002Fx\u002Fcrypto after 7 critical SSH CVEs, go-chi\u002Fchi IP spoofing, sigstore\u002Frekor OOM). See `references\u002Fagent-framework-cve-scan.md`.\n- `headroom-ai` v0.26.0 — installed after 2026-06-20 briefing flagged Headroom (60-95% token compression). Has MCP server, pure Python, Apache-2.0.\n- SkillsGuard evaluated — TypeScript\u002FNode.js project (not installable on Python stack), cloud API available at `https:\u002F\u002Fskillsguard.apiskillsguard.workers.dev\u002Fscan`.\n\n### Tailnet Reconnaissance — Full Fleet Exploration Pattern\n\nA standalone workflow for when you need a **complete picture of every machine on Tailscale**: what's online, what ports are open, what services run, and whether SSH keys work. Use this before setting up scans, deploying keys, or auditing fleet security posture.\n\n#### Workflow\n\nStep-by-step exploration, run each command and compile results:\n\n**Step 1: List all machines**\n\n```bash\ntailscale status\n# Full listing with IP, name, OS, online\u002Foffline status\ntailscale status | grep -v offline  # only online machines\ntailscale status --json             # programmatic access\n```\n\n**Step 2: Ping all online machines**\n\n```bash\nfor ip in \u003Call_online_tailscale_ips>; do\n  result=$(ping -c 2 -W 3 $ip 2>&1 | tail -1)\n  echo \"$ip -> $result\"\ndone\n```\n\nHelps identify reachability and latency. Machines behind DERP relays show higher RTT (100-400ms). Local DERP-free machines show 1-5ms.\n\n**Step 3: Port-scan per machine**\n\nUse `nc -zv` for fast TCP port checks. Common ports to probe:\n\n```bash\n# Linux servers\nfor port in 22 80 443 3000 5000 8000 8080 8443 9090 2375 2376 6443 7860 8888; do\n  nc -zv -w 2 $ip $port 2>&1 | grep -v \"Connection refused\"\ndone\n```\n\nAdditional macOS-specific ports: 5900 (VNC), 7000 (AirPlay), 5353 (mDNS).\n\nKey port signatures:\n- `22` → SSH (verify key auth next)\n- `443` → HTTPS web service\n- `80` → HTTP (redirect to HTTPS or legacy)\n- `3000` → Common dev\u002FNext.js default port\n- `5000` → Flask\u002FExpress\u002Fdevelopment\n- `5900` → VNC\u002FScreen Sharing (macOS)\n- `8443` → Alternative HTTPS\n\n**Step 4: Identify web services**\n\nFor every open HTTP\u002FHTTPS port, curl the root path to identify the service:\n\n```bash\n# HTTPS\ncurl -sk https:\u002F\u002F$ip\u002F | head -c 200\ncurl -sk https:\u002F\u002F$ip\u002F 2>&1 | grep -i \"\u003Ctitle>\"\n\n# HTTP on alternate ports\ncurl -sk http:\u002F\u002F$ip:$port\u002F | head -c 200\n```\n\nLook for:\n- `\u003Ctitle>` tag — identifies the site\u002Fapp\n- Server headers: `curl -sI https:\u002F\u002F$ip\u002F | grep -i server`\n- Framework fingerprints (Next.js, WordPress, Flask, etc.)\n- JSON responses if it's an API\n- Empty response may indicate TLS SNI filtering — try `-H \"Host: example.com\"`\n\n### Step 5: Test SSH Connectivity & Diagnose Failures\n\nWhen SSH fails, methodically diagnose *why* — the remediation differs by failure mode.\n\n#### 5a. Basic Auth Test\n\n```bash\nssh -o ConnectTimeout=5 -o BatchMode=yes -o StrictHostKeyChecking=no \\\n  -i ~\u002F.ssh\u002Fid_ed25519 \u003Cuser>@\u003Cip> \"hostname && uname -a\"\n```\n\n**Outcomes by error message:**\n\n| Error | Meaning | Next step |\n|---|---|---|\n| `Permission denied (publickey)` | Port open, SSH running, key **not accepted** | Deploy the key (see refs) |\n| `Connection refused` | Port 22 closed, no SSH daemon | Go to 5b below |\n| `Connection timed out` \u002F hangs | Firewall dropping or host unreachable | Check network (ping) |\n| `unexpected HTTP response: 502 Bad Gateway` via `tailscale ssh` | Tailscale SSH not configured on remote | Go to 5b below |\n\nAlso test alternative keys: `id_ed25519_github`, `id_ed25519_spark`, etc.\n\n#### 5b. Port-Closed Diagnosis (SSH daemon not running)\n\nWhen port 22 is closed, use this systematic flow:\n\n```bash\n# 1) Verify basic network reachability\nping -c 2 -W 3 \u003CIP>\n\n# 2) Check if the host is on Tailscale and its state\ntailscale status | grep \u003CIP-or-name>\n# Look for: \"active\" → reachable, \"offline\" → unreachable\n\n# 3) Check the remote peer's Tailscale SSH capabilities\ntailscale status --json | python3 -c \"\nimport sys, json\nd = json.load(sys.stdin)\nfor pid, p in d.get('Peer', {}).items():\n    if '\u003CIP>' in str(p.get('TailscaleIPs', [])):\n        print('OS:', p.get('OS'))\n        print('Online:', p.get('Online'))\n        print('Capabilities:', p.get('Capabilities'))\n        print('CapMap:', p.get('CapMap'))\n\"\n```\n\n**Interpretation:**\n- `Capabilities: null` \u002F `CapMap: null` → **Tailscale SSH is NOT enabled** on the remote node. SSH won't work via `tailscale ssh` either.\n- `\"https:\u002F\u002Ftailscale.com\u002Fcap\u002Fssh\": null` in CapMap → Tailscale SSH IS enabled. If it fails with 502, check the Tailscale admin console.\n- Node is `active` with direct connection → reachable (even if SSH is closed).\n\n```bash\n# 4) Port scan common services to see if ANY ports are open\nfor port in 22 443 5900 8080 8443 3000 5000; do\n  nc -zv -w 3 \u003CIP> $port 2>&1 | grep -v \"Connection refused\"\ndone\n```\n\n**Remediation by failure mode:**\n\n| Failure | Fix |\n|---|---|\n| Port 22 closed, macOS | On the Mac: **System Settings → General → Sharing → Remote Login**. Or in **Tailscale Admin Console** → approve node for Tailscale SSH. |\n| Port 22 closed, Linux | `sudo systemctl enable --now sshd` or `sudo apt install openssh-server` |\n| Port 22 open, `Permission denied` | Deploy SSH public key to remote `~\u002F.ssh\u002Fauthorized_keys` (see `references\u002Fssh-key-deployment.md` \u002F `references\u002Fmac-mini-coding-harness-recovery.md`) |\n| Tailscale SSH 502, port 22 works fine | Retry direct `ssh` via Tailscale IP. The 502 is a Tailscale relay issue, not an SSH error. |\n| No ports open at all (22, 443, 5900, etc. all refused) | Machine may be asleep, on a restricted network, or fully locked down. macOS: no services enabled in Sharing prefs. |\n\nFor detailed session walkthrough with real error transcripts, see `references\u002Fssh-connectivity-diagnostics.md`.\n\n**macOS coding-harness recovery pattern**: if a Mac mini is online, port `22` is open, but common users reject Appie-3's key, stop guessing users\u002Fpasswords. Ask the local operator or another authorized agent on the box to add Appie-3's public key to the active macOS user's `~\u002F.ssh\u002Fauthorized_keys`, enable Remote Login, and report the actual username. Then verify harness state (`~\u002Fclawd`, `~\u002F.hermes`, `~\u002F.codex`, `~\u002F.claude`, and `ps` for `hermes|claude|codex|copilot|node|python`) before changing anything. Full recipe: `references\u002Fmac-mini-coding-harness-recovery.md`.\n\n**Step 6: Check local authorized_keys**\n\n```bash\ncat ~\u002F.ssh\u002Fauthorized_keys\ncat ~\u002F.ssh\u002Fid_ed25519.pub  # your own public key\n```\n\nThis tells you:\n- Who can SSH into *you* (the keys in authorized_keys)\n- Who *you* claim to be (the pubkey comment field)\n- Whether cross-fleet SSH is unidirectional only\n\n**Step 7: Compile and present**\n\nPresent findings as a compact table:\n\n```\n| Machine | IP | OS | Ping | Open ports | Services |\n|---------|----|----|------|------------|---------|\n| machine | 100.x.x.x | Linux | Xms | 22, 443, 3000 | SSH, web (app name) |\n```\n\nInclude:\n- Online\u002Foffline status per machine\n- Reachable services and what they are\n- SSH key acceptance status\n- The user's own pubkey (ready to copy-paste for deployment)\n\n#### Common Findings\n\n- **SSH key not deployed**: New VPS\u002Fmachine provisioning — pubkey needs to be added to authorized_keys. Common pattern: Appie-3's key isn't on any fleet machine, but other agents' keys already are.\n- **VNC open**: macOS machines with Screen Sharing enabled. Port 5900 open means anyone on tailnet could attempt authentication. Verify VNC is password-protected.\n- **Web service on alternate port**: Next.js dev server (3000), Flask\u002FExpress (5000), alternative HTTPS (8443) — may be development\u002Fstaging environments not meant for production.\n- **Offline nodes >30d**: Move to GHOSTS array in scan script. Their Tailscale IPs may change on reconnection.\n- **Multi-OS tailnet**: macOS machines have VNC (5900), AirPlay (7000), and different SSH configuration paths. Linux servers are more consistent.\n\n### Multi-Agent Cron Inventory — Fleet-Wide Schedule Audit\n\nA systematic method for auditing ALL cron jobs across a multi-agent fleet. Use when Seyed asks for a comprehensive schedule review, \"make all cron jobs aesthetic\", or before any fleet-wide cron reformatting.\n\n#### Workflow\n\n**Step 1: Enumerate all accessible machines**\n\n```bash\n# SSH key test across ALL tailnet hosts\nfor host in \"root@100.x.x.x\" \"appie@100.x.x.x\" \"eva@100.x.x.x\" \"root@100.x.x.x\"; do\n  result=$(ssh -o ConnectTimeout=3 -o BatchMode=yes -o StrictHostKeyChecking=no \\\n    -i ~\u002F.ssh\u002Fid_ed25519 \"$host\" \"hostname\" 2>&1)\n  echo \"$host → $result\"\ndone\n```\n\nNote: SSH user varies by machine — try `root`, `appie`, the user's name (`eva`, `harry`). Don't assume one user works everywhere.\n\n**Step 2: For each reachable machine, identify the runtime**\n\n```bash\n# Hermes cron\nhermes cron list\n\n# OpenClaw cron (legacy)\nls ~\u002F.openclaw\u002Fcron\u002F 2>\u002Fdev\u002Fnull\n\n# launchd plists (macOS)\nls ~\u002FLibrary\u002FLaunchAgents\u002F | grep -v 'com\\.google\\|homebrew'\n```\n\nKey signals for runtime detection via `ps aux`:\n- `hermes_cli.main gateway run` → Hermes agent\n- `openclaw` in process name → OpenClaw agent\n- `claude` or `codex` in process name → Claude Code \u002F Codex CLI\n\n**Step 3: Check cron managers**\n\n| Runtime | Cron Manager | Command |\n|---------|-------------|---------|\n| Hermes | `hermes cron` | `hermes cron list` |\n| OpenClaw (legacy) | cron files | `ls ~\u002F.openclaw\u002Fcron\u002F` |\n| macOS (legacy) | launchd plists | `launchctl list \\| grep com.weblyfe` |\n| System crontab | system cron | `crontab -l` |\n\n**Step 4: Document per-job health**\n\nFor each job, note:\n- Name and schedule\n- Last run status (ok\u002Ferror\u002Ffailed delivery)\n- Delivery target (telegram\u002Forigin\u002Fnone)\n- If job is broken: capture the exact error message\n\n**Step 5: Identify aesthetic\u002Fstyling improvements**\n\nCheck for:\n- **Naming convention**: consistent prefix per agent (`appie3-`, `appie2-`), no mixed case\n- **Output formatting**: Markdown + emoji headers vs plain text\n- **Delivery target**: all jobs deliver to Telegram (or all to origin — be consistent)\n- **Timing deconfliction**: no overlapping runs on the same agent\n- **Broken jobs**: provider errors, expired credits, delivery failures — all need fixing\n\n#### Fleet Topology Map (2026-06-24)\n\n| Machine | IP | Runtime | Cron | Notes |\n|---------|----|---------|------|-------|\n| appie-3-hermes | 100.69.131.51 | Hermes | `hermes cron` (6 jobs) | ✅ stable |\n| appie-2 | 100.118.143.10 | Hermes | `hermes cron` (13 jobs) | ? 7 broken |\n| appie-1 | 100.101.29.56 | OpenClaw | launchd (40+ plists) | ? |\n| eva | 100.99.64.92 | Hermes + OpenClaw | launchd | ? |\n| eugi | 100.110.58.73 | Hermes | 0 cron jobs | schone lei |\n| Deadpool | ? (off-tailnet) | ? | ? | Aparte Hetzner VPS voor Roslan + EKO |\n\nZie `references\u002Ffleet-inventory.md` voor de complete actuele inventaris.\n\n### Tailnet Discovery\n\n**Not all fleet machines are on Tailscale.** Deadpool (Hetzner VPS voor Roslan + EKO) is NOT on the tailnet and has no SSH config entry. When checking \"all machines\", distinguish between tailnet-connected and off-tailnet infrastructure.\n\n```bash\n# Full peer list with online status\ntailscale status\n\n# JSON output for programmatic use (Self vs Peer distinction is CRITICAL)\ntailscale status --json\n```\n\nThe local machine appears in `Self`, ALL other nodes in `Peer` dict:\n\n```python\nd = json.load(sys.stdin)\nself = d.get('Self', {})\nself_online = self.get('Online', False)               # local machine\npeer_online = any(p.get('Online', False)\n                  for p in d.get('Peer', {}).values()) # others\n```\n\n**WRONG**: Looping over `Peer` to find \"appie-1\" → always returns offline.\n**RIGHT**: Check `Self` for the local machine, `Peer` for all others.\n\nThis matters for watchdog scripts that check local node tailnet health. The `tailscale status` CLI output shows the local node without a status column (making it look unknown), but JSON `Self.Online` is always `True` for the running machine.\n\n### Connectivity Checks\n\n```bash\ntailscale ping -c 1 --timeout 3s \u003CIP>          # cross-platform\nssh -o ConnectTimeout=5 -o BatchMode=yes -o StrictHostKeyChecking=no \u003Cuser>@\u003Cip> \u003Ccmd>\n```\n\n**Key**: Never use direct Hetzner IPs — they change on reprovision. Always use Tailscale IPs (`100.x.x.x`). SSH key timeout: `ConnectTimeout=5` is required; `ConnectTimeout=3` gives false positives on DERP relay nodes.\n\n### Cross-Machine File Retrieval\n\nWhen you need to find and retrieve a file from a fleet machine:\n\n1. **Know where canonical assets live** — common locations per machine:\n   - **appie-1** (Mac Mini): `~\u002Fclawd\u002Fprojects\u002Fopenclaw-guide\u002Fcanonical\u002F` (Build-Your-Own-Appie PDFs), `~\u002Fclawd\u002Fassets\u002Fagent-avatars\u002F` (Telegram bot avatars)\n   - **appie-2** (Hetzner VPS): `\u002Froot\u002Fappie-brain\u002F`, `\u002Froot\u002F.hermes\u002F`\n   - **eugi** (Hetzner VPS): `\u002Froot\u002F.openclaw\u002F`, `\u002Froot\u002F.hermes\u002F`\n\n2. **Search remotely** — use `find` with name globs:\n   ```bash\n   ssh \u003Cuser>@\u003Ctailscale-host> \"find \u003Cpath> -iname '*pattern*v4*' -o -iname '*pdf*' 2>\u002Fdev\u002Fnull\"\n   ```\n   - Always use `find` (not `ls -R`) — scales to large directories\n   - Quote paths with spaces: `\"\u002FUsers\u002Fappie\u002Fclawd\u002Fprojects\u002Fopenclaw-guide\u002F\"`\n   - Use wildcards for version numbers: `*v4.5*`\n\n3. **SCP back** — file to local `\u002Ftmp\u002F`:\n   ```bash\n   scp \u003Cuser>@\u003Ctailscale-host>:\"\u003Cremote-path>\" \u002Ftmp\u002F\u003Clocal-name>\n   ```\n   - `scp` via Tailscale IP\u002Fhostname works without extra flags\n   - Use `\u002Ftmp\u002F` for ephemeral copies; move to `~\u002Fclawd\u002F` for permanent storage\n\n4. **Deliver the file**:\n   - **Telegram**: include `MEDIA:\u002Ftmp\u002F\u003Cfile>` in response — sends as native attachment\n   - **Email**: NOT set up on this VPS (no himalaya, mailtools, or SMTP creds). Ask Seyed for creds or an alternative\n   - **Public URL**: upload somewhere if Seyed needs to share the link\n\n5. **Clean up** — remove from `\u002Ftmp\u002F` when no longer needed:\n   ```bash\n   rm \u002Ftmp\u002F\u003Clocal-name>\n   ```\n\n**Pitfall**: macOS paths start with `\u002FUsers\u002F`, not `\u002Froot\u002F`. Check remote OS before constructing search paths.\n\n## SSH Key Inventory\n\nKeys stored in `~\u002F.ssh\u002F`. SSH config (`~\u002F.ssh\u002Fconfig`) has host aliases for fleet machines.  \n**Current reality (2026-06-24):** `appie-2`, `eugi`, `appie-1`, and `eva` all accept Appie-3's key. All other fleet nodes reject it or have no SSH daemon. Deploying the key to remaining BROKEN_KEYS nodes is the next step for fleet-wide SSH management.\n\n| File | Purpose | Status | Last Verified |\n|------|---------|--------|---------------|\n| `~\u002F.ssh\u002Fid_ed25519` | Default key (`appie-3-hermes@tailnet`) | ? appie-2, eugi, appie-1, eva \u002F ? others | 2026-06-24 |\n| `~\u002F.ssh\u002Fid_ed25519_github` | GitHub-only key | ? Works | — |\n| `~\u002F.ssh\u002Fid_ed25519_spark` | Spark Atlas key | ? Stale (node offline) | 2026-06-11 |\n\n### Fleet SSH Access Map (2026-06-23)\n\n| Device | OS | Port 22 | SSH Key | Category | Remedy |\n|--------|----|---------|---------|----------|--------|\n| appie-2 | Linux | ✅ Open | ✅ Root accepted | FLEET ? | — |\n| eugi | Linux | ✅ Open | ✅ Root accepted | FLEET ? | — |\n| appie-1 | macOS | ✅ Open | ✅ `appie@100.101.29.56` | FLEET ? | User `appie`, discovered 2026-06-24 |\n| eva | macOS | ✅ Open | ✅ `eva@100.99.64.92` | FLEET ? | User `eva`, discovered 2026-06-24 |\n| appie-mc-1 | Linux | ✅ Open | ❌ Key rejected | BROKEN_KEYS ? | Deploy pubkey to `root@100.107.179.3` |\n| harry (mac-mini-van-harry) | macOS | ✅ Open | ❌ Key rejected | BROKEN_KEYS ? | Add pubkey to macOS user's authorized_keys |\n| rabi (mac-mini-van-rabi) | macOS | ❌ Closed | N\u002FA | TAILNET_ONLINE ⚪ | Enable Remote Login in Sharing prefs |\n| techwiz-mbp | macOS | ❌ Closed | N\u002FA | TAILNET_ONLINE ⚪ | Enable Remote Login in Sharing prefs |\n| ipad-pro | iOS | N\u002FA | N\u002FA | TAILNET_ONLINE ⚪ | No SSH possible |\n| spark-atlas | Linux | ❌ Offline | N\u002FA | GHOSTS ? | Wait for node to come online |\n| artemis | macOS | ❌ Offline | N\u002FA | GHOSTS ? | Wait for node to come online |\n| mac-studio-luminaire | macOS | ❌ Offline | N\u002FA | GHOSTS ? | Wait for node to come online |\n| iphone181 | iOS | ❌ Offline | N\u002FA | GHOSTS ? | No SSH possible |\n| macbook-air-lorenzo | macOS | ❌ Offline | N\u002FA | GHOSTS ? | Wait for node to come online |\n| wolf-diddy | macOS | ❌ Offline | N\u002FA | GHOSTS ? | External peer, no access |\n\n**Key SSH failure patterns (2026-06-19 audit):**\n- **macOS with port 22 open**: SSH server running but `appie-3-hermes@tailnet` key not in any macOS user's `~\u002F.ssh\u002Fauthorized_keys`. Remedy: deploy the key to the actual macOS user.\n- **Linux with port closed**: SSH daemon not installed\u002Fstarted (`systemctl enable --now sshd` + `apt install openssh-server` if needed).\n- **Linux with `Connection refused` after initial `Permission denied`**: fail2ban likely blocked the source IP (eugi pattern).\n- **macOS with all ports closed**: Remote Login + Screen Sharing both disabled in System Sharing prefs.\n\nSee `references\u002Fssh-connectivity-diagnostics.md` for detailed error transcripts and step-by-step per-failure diagnosis.\n\n### Fleet Node Authorized Keys Audit\n\nCheck how many authorized keys exist per node and who they belong to:\n\n```bash\nfor host in \"root@100.118.143.10\" \"root@100.110.58.73\"; do\n  echo \"=== $host ===\"\n  ssh -o ConnectTimeout=5 -o BatchMode=yes -o StrictHostKeyChecking=no \\\n    -i \"$HOME\u002F.ssh\u002Fid_ed25519\" \"$host\" \\\n    \"cat \u002Froot\u002F.ssh\u002Fauthorized_keys | awk '{print \\$3}'\"\ndone\n```\n\n| Node | Keys | Identities |\n|------|------|------------|\n| appie-2 | 4 | appie@weblyfe-ocean, appie@weblyfe, seyed@Techwiz-MacBook-Pro-8, mc@appie-mc-1 |\n| eugi | 2 | appie@weblyfe, Appie-2@appie-brain |\n\nDocument any unexpected keys. The comment field (3rd column) identifies the key owner. Stale keys (old hostnames, decommissioned users) should be removed.\n\n### Fleet Node Deploy Keys\n\nFleet nodes may carry per-service deploy keys for CI\u002FCD:\n\n```bash\nssh \u003Chost> \"ls -la \u002Froot\u002F.ssh\u002F | grep -v authorized_keys | grep -v known_hosts\"\n```\n\nExample from appie-2:\n```\nprivanotify_admin_deploy     → PrivaNotify admin\nprivanotify_deploy           → PrivaNotify\nweblyfe_ai_deploy            → Weblyfe AI\nweblyfe_ai_deploy_new        → Weblyfe AI (new)\ngithub_do_appie              → GitHub Actions deploy\n```\n\nDocument the purpose of each key. Remove stale ones.\n\n### SSH Config Audit\n\n```bash\nssh \u003Chost> \"cat \u002Froot\u002F.ssh\u002Fconfig\"\n```\n\nCheck for:\n- `PasswordAuthentication no`\n- `PubkeyAuthentication yes`\n- No wildcard `Host *` patterns that expose sensitive hosts\n\nSSH config aliases can drift over time as Tailscale IPs change during reprovisioning. Periodically run `tailscale status` and update SSH config.\n\n### Hermes Agent Detection\n\n```bash\nssh \u003Chost> \"ps aux | grep -iE '(hermes|claude|python.*bot|node.*bot|discord|telegram)' | grep -v grep\"\n```\n\nThe process looks like:\n```\n\u002Fusr\u002Flocal\u002Flib\u002Fhermes-agent\u002Fvenv\u002Fbin\u002Fpython -m hermes_cli.main gateway run --replace\n```\n\nHermes proc count on a healthy node: 2-5 (gateway + workers). Count of 0-1 is a warning.\n\n### Appie-Brain Locations\n\n| Machine | Path |\n|---------|------|\n| appie-3-hermes (deze VPS) | `\u002Froot\u002Fclawd\u002Fappie-brain\u002F` |\n| appie-2 (Hetzner) | `\u002Froot\u002Fappie-brain\u002F` |\n| appie-1 (Mac Mini) | `~\u002Fclawd\u002Fappie-brain\u002F` |\n\n### Fleet Reality-Check (Periodic Inventory Refresh)\n\nFleet node status changes over time — offline nodes come back, new nodes join, nodes get decommissioned. All 4 arrays in the scan script drift from reality.\n\n**Run this check monthly** to verify the script's arrays match real Tailscale status:\n\n```bash\n# 1. Get actual Tailscale online state\ntailscale status | grep -v '^$' | awk '{print $1, $2, $(NF)}'\n\n# 2. Compare against script's FLEET array\ngrep -A20 '^FLEET=(' ~\u002Fclawd\u002Ftools\u002Fappie-3-daily-security-scan.sh\n\n# 3. Check BROKEN_KEYS — are they still online?\ngrep -A15 '^BROKEN_KEYS=(' ~\u002Fclawd\u002Ftools\u002Fappie-3-daily-security-scan.sh\n\n# 4. Check TAILNET_ONLINE — still no SSH?\ngrep -A10 '^TAILNET_ONLINE=(' ~\u002Fclawd\u002Ftools\u002Fappie-3-daily-security-scan.sh\n\n# 5. Check GHOSTS — any back online?\ngrep -A15 '^GHOSTS=(' ~\u002Fclawd\u002Ftools\u002Fappie-3-daily-security-scan.sh\n```\n\n**When to move a node between arrays**:\n- Ghost comes online → move to FLEET (with current SSH key and Tailscale IP)\n- Active node offline >30d → move to GHOSTS\n- Node decommissioned → remove from both arrays\n\n**2026-06-02 update**: `spark-atlas` and `mac-mini-van-eva` both returned online after 51+ days offline. Move from GHOSTS back to FLEET. Verify SSH keys still work before re-adding.\n\n### Fleet Status Categories\n\n15 tailnet nodes (2026-06-23) grouped into 4 arrays:\n\n#### FLEET — SSH-reachable (daily full health check)\n```bash\nFLEET=(       # dagelijks SSH health → ? (full data) \u002F ? (failed)\n    \"appie-2|root@100.118.143.10|$HOME\u002F.ssh\u002Fid_ed25519|Weblyfe VPS\"\n    \"eugi|root@100.110.58.73|$HOME\u002F.ssh\u002Fid_ed25519|Ubuntu VPS (FSN)\"\n    \"appie-1|appie@100.101.29.56|$HOME\u002F.ssh\u002Fid_ed25519|Mac Mini Weblyfe (macOS)\"\n    \"eva|eva@100.99.64.92|$HOME\u002F.ssh\u002Fid_ed25519|Mac Mini Naoufal (macOS)\"\n)\n```\n\n#### BROKEN_KEYS — online, port 22 open, key rejected\n```bash\nBROKEN_KEYS=( # daily nc port check only → ?\n    \"appie-mc-1|root@100.107.179.3|$HOME\u002F.ssh\u002Fid_ed25519|Mission Control v1 (Linux) — key rejected\"\n    \"harry|100.79.180.56|none|Mac Mini Harry (macOS) — key rejected\"\n)\n```\n\n#### TAILNET_ONLINE — online, no SSH daemon at all\n```bash\nTAILNET_ONLINE=( # tailnet status only → ⚪\n    \"rabi|100.67.184.25|macOS|Mac Mini Rabi — Remote Login off\"\n    \"techwiz-mbp|100.87.99.11|macOS|Techwiz MacBook Pro — Remote Login off\"\n    \"ipad-pro|100.105.56.2|iOS|iPad Pro — no SSH\"\n)\n```\n\n#### GHOSTS — offline >7d (logged but no active check)\n```bash\nGHOSTS=(      # archived → ?\n    \"spark-atlas|100.69.197.43|linux|DGX Spark — offline 9d\"\n    \"artemis|100.95.165.116|macOS|Artemis — offline 11d\"\n    \"mac-studio-luminaire|100.126.237.96|macOS|Studio Luminaire — offline 11d\"\n    \"iphone181|100.98.117.8|iOS|iPhone S3YED — offline 4d\"\n    \"macbook-air-lorenzo|100.112.169.28|macOS|Book Air Lorenzo — offline 74d\"\n    \"wolf-diddy|100.102.181.116|macOS|Wolf Diddy — offline 32d\"\n)\n```\n\n**Transition rules:**\n- Ghost comes online → move to BROKEN_KEYS or TAILNET_ONLINE (test SSH first)\n- BROKEN_KEYS node gets SSH key deployed → move to FLEET\n- Online node offline >7d → move to GHOSTS\n- Node decommissioned → remove from all arrays\n- iOS\u002FiPad nodes belong in TAILNET_ONLINE or GHOSTS — never in FLEET (no SSH)\n\nVoorkomt: valse ? elke dag, 5s SSH timeouts per ghost, ruis in CTO notes.\n\n**CRITICAL**: Maintener de arrays actief. Wanneer een ghost node terug online komt (check via `tailscale status`), verplaats hem direct terug naar BROKEN_KEYS of TAILNET_ONLINE. De SSH key en Tailscale IP kunnen veranderd zijn sinds de node offline ging.\n\nPeriodic refresh: zie \"Fleet Reality-Check\" sectie hierboven.\n\n### Fleet Health Report Template\n\n```markdown\n? Weblyfe Tailnet — [DATE]\n\n### ✅ Actieve Bots\nappie-1 | 100.101.29.56 | macOS | ✅\nappie-2 | 100.118.143.10 | Linux | ✅\n\n### ? Gearchiveerd\nspark-atlas — offline >30d\neva — offline >30d\n\n### ? Offline (overige nodes)\nmacbook-air-van-lorenzo — last seen 2026-04-10\n```\n\n### Quick Fleet Scan Pattern (Telegram \u002F on-demand)\n\nWhen Seyed asks for a quick fleet analysis, keep it fast and operational rather than running the full daily scan:\n\n1. **Local health first**: `hostname`, `date -Is`, `uptime`, `df -h \u002F`, `free -m`, Hermes gateway service status, failed SSH logins in 24h, pending apt update count.\n2. **Tailnet state via JSON**: parse `tailscale status --json`; include `Self` and `Peer` separately. Summarize online\u002Foffline, OS, Tailscale IP, and last-seen age.\n3. **Expected-offline context matters**: if Seyed says a device is physically offline\u002Fin suitcase, mark it `expected\u002Fno action`, not an incident. Still include last-seen time.\n4. **Reachability probes**: for online\u002Fcore nodes, run `tailscale ping` and quick TCP checks for `22,80,443,3000,5000,8000,8080,8443,5900`.\n5. **SSH auth check**: test key-based SSH separately from port reachability. Report `port 22 open but key rejected` as an access\u002Fremediation issue, not node downtime.\n6. **Service fingerprints**: for open HTTP(S) ports, use `curl -skI` and a short body\u002Ftitle probe. On macOS, `5000` often fingerprints as AirTunes and `5900` is Screen Sharing\u002FVNC, both tailnet-accessible rather than internet-facing.\n7. **Report concise risk classes**: `healthy`, `expected offline`, `access issue`, `tailnet-exposed service`, `ghost\u002Foffline >30d`. End with the next 1-3 recommended actions.\n\nAvoid over-escalating offline personal devices, iOS nodes, or user-declared travel\u002Fsuitcase devices. The security signal is unexpected offline core infrastructure, key rejection on nodes that should be manageable, public DNS\u002Fservice failure, or exposed services that should not be tailnet-wide.\n\n### Telegram Fleet Output — Grouped by Status Category\n\nThe daily scan Telegram output groups all fleet nodes by their connectivity status for at-a-glance readability. Implemented via `FLEET_CACHE` pipe-separated file and a `case` statement that tracks group transitions:\n\n```\n*Fleet*\n  SSH ✅\n    ? appie-2\n    ? eugi\n\n  SSH key rejected\n    ? appie-mc-1\n    ? appie-1\n    ? eva\n    ? harry\n\n  Online (geen SSH)\n    ⚪ rabi\n    ⚪ techwiz-mbp\n    ⚪ ipad-pro\n\n  Offline\n    ? spark-atlas\n    ? artemis\n    ...\n```\n\n**Implementation pattern** in the script's Telegram generation block:\n\n```bash\ncurrent_group=\"\"\nwhile IFS=\"|\" read -r name status desc; do\n    case \"$status\" in\n        \"?\") group=\"SSH ✅\" ;;\n        \"?\") group=\"SSH ❌\" ;;\n        \"?\") group=\"SSH key rejected\" ;;\n        \"⚪\") group=\"Online (geen SSH)\" ;;\n        \"?\") group=\"Offline\" ;;\n        *) group=\"\" ;;\n    esac\n    if [ \"$group\" != \"$current_group\" ] && [ -n \"$group\" ]; then\n        [ -n \"$current_group\" ] && tg_echo \"\"\n        tg_echo \"  $group\"\n        current_group=\"$group\"\n    fi\n    tg_echo \"    $status $name\"\ndone \u003C \"$FLEET_CACHE\"\n```\n\n**Key constraint**: ALL 4 array types (FLEET, BROKEN_KEYS, TAILNET_ONLINE, GHOSTS) must write to the same FLEET_CACHE in array order. The Telegram block reads once sequentially. This guarantees the Telegram output matches the report and no nodes are missed.\n\n**Cache format** (pipe-separated, no JSON):\n```\nappie-2|?|Weblyfe VPS (Hetzner)\neugi|?|Ubuntu VPS (FSN)\nappie-mc-1|?|Mission Control v1 — key rejected\nrabi|⚪|Mac Mini Rabi — Remote Login off\nspark-atlas|?|DGX Spark — offline 9d\n```\n\n## Watchdog Architecture (separate cron jobs, no_agent=True)\n\nThese run independently from the daily scan to catch problems early. Script-only mode: zero LLM tokens per tick, silent when healthy.\n\n| Watchdog | Schedule | Script | Trigger |\n|----------|----------|--------|---------|\n| Disk | Every 4h | `disk-watchdog.sh` | >80% ⚠️, >90% ? on any fleet node |\n| Tailscale | Every 30min | `tailscale-watchdog.sh` | Core node (appie-1, appie-2, eugi) goes offline |\n| SSH key audit | 1st of month | `ssh-key-audit.sh` | Monthly authorized_keys review per node |\n| Failed login trend | In daily scan | `failed-login-trend.sh` | Spike >5x yesterday or >10\u002Fday |\n| Agent framework CVEs (Python + Go) | Daily 06:30 UTC | `agent-framework-cve-scan.py` (via LLM cron job `c503abd02155`) | Any CVE reported in last 90d for 20 packages (17 Python agent + 3 Go infra). Uses `[SILENT]` when clean. |\n\nCron job setup:\n```bash\n# Scripts must be at ~\u002F.hermes\u002Fscripts\u002F (or the profile-specific scripts dir)\n# Symlinks may be blocked by the cron scheduler — use real files\ncronjob action=create name=\"disk-watchdog\" schedule=\"0 *\u002F4 * * *\" \\\n  no_agent=True script=\"disk-watchdog.sh\" deliver=\"telegram:1817919454\"\n```\n\n## Security Governance & Suggestion Pipeline\n\nA multi-agent governance pattern for human-in-the-loop security improvements. Appie-3 (CTO specialist) creates the suggestion plan, Appie-Opus (orchestrator) presents suggestions to Seyed, Seyed approves before execution.\n\n### When to Use\n\n- After the daily security scan finds issues that need remediation\n- User asks for \"daily security suggestions\", \"action plan for opus\", \"suggestions to present to seyed\"\n- Setting up a security governance workflow where changes require human approval\n- Any recurring task where the CTO recommends but the user decides\n\n### Architecture\n\n```\nAppie-3 (CTO)                Appie-Opus (orchestrator)    Seyed (human)\n      │                              │                        │\n      │  Creates plan ──────────────►│                        │\n      │  DAILY-SECURITY-             │                        │\n      │  SUGGESTIONS.md              │                        │\n      │                              │  Presents S001-S00X ──►│\n      │                              │  \"Wat, waarom,         │\n      │                              │   risico, revert\"      │\n      │                              │◄─────── ? \u002F ? ──────│\n      │                              │                        │\n      │  (Appie-3 only acts          │  Executes approved     │\n      │   when directly asked)       │  suggestions           │\n```\n\n### Suggestion Format\n\nEach suggestion MUST include four fields:\n\n| Field | Description |\n|-------|-------------|\n| **Wat** | What the check\u002Fchange is (1-2 zinnen) |\n| **Waarom** | Why it matters (1 zin) |\n| **Risico** | Risk level: Geen \u002F Laag \u002F Medium |\n| **Revert** | Exact command to undo the change |\n\n### Safety Rules (for Appie-Opus)\n\n1. **Read-only or reversible only** — no `rm -rf`, `chmod -R`, `iptables -F`\n2. **STOP on error** — report to Seyed, do not self-fix\n3. **No lockouts** — always test key-based login before disabling password auth\n4. **No service restarts** without explicit Seyed approval\n5. **Every suggestion has a revert step** — if missing, do not execute\n\n### Suggestion Count\n\nS001-S027 exist (expanded 2026-06-20 met S021-S027: agent framework CVE scan, Headroom install\u002Fverify\u002FMCP, SkillsGuard cloud API, CVE-2026-2256 check, MCP cutover check, SSH key deployment plan).\n\n### Daily Rotation\n\n27 suggestions exist (S001-S027), rotated by day:\n\n| Dag | Category | Sample Suggestions |\n|-----|----------|-------------------|\n| Maandag | Access audit | authorized_keys check (appie-2 + eugi), tailnet status, S027 (SSH key plan) |\n| Dinsdag | Config check | .env perms, open ports on fleet, S025 (CVE-2026-2256 check) |\n| Woensdag | Dependency scan | gitleaks, npm audit, S021 (agent framework CVE scan), S026 (MCP cutover) |\n| Donderdag | Web security | SSL certs, security headers, failed logins, S024 (SkillsGuard) |\n| Vrijdag | System health | disk, pending updates, S022-S023 (Headroom check\u002FMCP) |\n| Weekend | Fleet check | tailnet status, spark-atlas SSH, gateway uptime |\n\n### Plan Location\n\nCanonical plan: `~\u002Fclawd\u002Fappie-3-cto\u002FDAILY-SECURITY-SUGGESTIONS.md`\n\nZie `references\u002Fsecurity-suggestions.md` voor de volledige, actuele suggestielijst.\n\n## Backup Sync (optional, needs approval)\n\n`backup-sync.sh` — rsyncs appie-brain, Hermes config, SSH config, and secrets to appie-2.\nNot active by default. Script exists at `~\u002F.hermes-appie3\u002Fscripts\u002Fbackup-sync.sh`.\n\n## Cross-Platform Detection (macOS vs Linux)\n\nThe daily scan script may run on macOS (Mac Mini) or Linux (Hetzner VPS). Use an `uname` check at the top to branch OS-specific commands:\n\n```bash\nOS=\"$(uname -s)\"\ncase \"$OS\" in\n  Darwin) IS_MACOS=true; IS_LINUX=false ;;\n  Linux)  IS_MACOS=false; IS_LINUX=true  ;;\nesac\n```\n\n### Command Equivalents\n\n| macOS Command | Linux Alternative | When to Use |\n|---|---|---|\n| `vm_stat` | `free` or `\u002Fproc\u002Fmeminfo` | Memory check |\n| `sysctl -n vm.loadavg` | `cat \u002Fproc\u002Floadavg` | Load averages |\n| `log show --predicate ... --last 24h` | `journalctl --since \"24 hours ago\" \\| grep -c \"Failed password\"` | Failed login count |\n| `date -j -f \"%b %d %H:%M:%S %Y %Z\" \"$date\" +%s` | `date -d \"$date\" +%s` | Date parsing (SSL cert expiry) |\n| `date -v-1d +%Y-%m-%d` | `date -d \"yesterday\" +%Y-%m-%d` | Date arithmetic |\n| `\u002Fopt\u002Fhomebrew\u002Fbin\u002Fopenssl` | `\u002Fusr\u002Fbin\u002Fopenssl` | SSL cert check |\n| `pgrep -f \"hermes_cli\"` | `pgrep -f \"hermes gateway\"` | Hermes process detection |\n| `ping` | `ping` (exists on both, but macOS has stricter permissions) | Connectivity check |\n| `trash` | `rm -i` or `\u002Fusr\u002Fbin\u002Ftrash-cli` | Safe delete |\n\n### Branch Template\n\n```bash\nif [ \"$IS_MACOS\" = true ]; then\n    mem_active=$(vm_stat | grep 'pages active' | awk '{print $NF}' | tr -d '.')\n    mem_free=$(vm_stat | grep 'pages free' | awk '{print $NF}' | tr -d '.')\n    load=$(sysctl -n vm.loadavg | tr -d '{}')\n    failed_logins=$(log show --predicate 'eventMessage contains \"Failed to authenticate\"' --last 24h --style compact 2>\u002Fdev\u002Fnull | wc -l | tr -d ' ')\n    ossl=\"\u002Fopt\u002Fhomebrew\u002Fbin\u002Fopenssl\"\n    hermes_pat=\"hermes_cli\"\n    date_parse() { date -j -f \"%b %d %H:%M:%S %Y %Z\" \"$1\" +%s 2>\u002Fdev\u002Fnull; }\n    date_prev() { date -v-1d '+%Y-%m-%dT00:00:00.000' 2>\u002Fdev\u002Fnull; }\nelse\n    mem_active=$(awk '\u002FActive\u002F {print $2}' \u002Fproc\u002Fmeminfo 2>\u002Fdev\u002Fnull || echo 0)\n    mem_free=$(awk '\u002FMemAvailable\u002F {print $2}' \u002Fproc\u002Fmeminfo 2>\u002Fdev\u002Fnull || echo 0)\n    load=$(cat \u002Fproc\u002Floadavg | cut -d' ' -f1-3)\n    failed_logins=$(journalctl --since \"24 hours ago\" 2>\u002Fdev\u002Fnull | grep -c \"Failed password\" || echo 0)\n    ossl=\"\u002Fusr\u002Fbin\u002Fopenssl\"\n    hermes_pat=\"hermes gateway\"\n    date_parse() { date -d \"$1\" +%s 2>\u002Fdev\u002Fnull; }\n    date_prev() { date -d \"yesterday\" '+%Y-%m-%dT00:00:00.000' 2>\u002Fdev\u002Fnull; }\nfi\n```\n\n### Key Pitfall: Memory Calculation Mismatch\n\n`vm_stat` outputs **pages** (4096 bytes each on macOS ARM) while `\u002Fproc\u002Fmeminfo` outputs **kB** on Linux. The percentage calculation may differ. If you only need percentage, use platform-specific thresholds or normalise to MB first.\n\nOn Linux:\n```bash\nmem_total_kb=$(awk '\u002FMemTotal\u002F {print $2}' \u002Fproc\u002Fmeminfo)\nmem_active_kb=$(awk '\u002FActive\u002F {print $2}' \u002Fproc\u002Fmeminfo)\nmem_pct=$(( mem_active_kb * 100 \u002F mem_total_kb ))\n```\n\nOn macOS:\n```bash\npage_size=$(vm_stat | grep 'page size' | awk '{print $8}')\nmem_active=$(vm_stat | grep 'pages active' | awk '{print $NF}' | tr -d '.')\nmem_active_mb=$(( mem_active * page_size \u002F 1048576 ))\n```\n\n### Hermes Process Detection\n\nThe binary path varies between machines. Instead of matching a specific process name, detect Hermes generically:\n\n```bash\nhermes_count=$(pgrep -f \"$hermes_pat\" | wc -l | tr -d ' ')\n# Also try the canonical install path\nif [ \"$hermes_count\" -eq 0 ]; then\n    hermes_count=$(pgrep -af \"\u002Fusr\u002Flocal\u002Flib\u002Fhermes-agent\" | wc -l | tr -d ' ')\nfi\n```\n\n## macOS-Specific Scripting Quirks\n\nAll discovered through trial and error. Encode these in every script.\n\n### Bash 3.x — No Associative Arrays, `local` Only in Functions\n- macOS bash 3.x: `local -A` (associative arrays) fails silently\n- `local` keyword ONLY inside function bodies. Brace blocks `{ }` are NOT functions.\n- The Telegram generation block (brace group at script bottom) must NOT use `local`\n- Use indexed arrays with pipe-separated fields:\n```bash\nlocal fleet=(\n    \"appie-2|root@100.118.143.10|$HOME\u002F.ssh\u002Fid_ed25519\"\n)\nfor entry in \"${fleet[@]}\"; do\n    name=$(echo \"$entry\" | cut -d'|' -f1)\n    ssh_target=$(echo \"$entry\" | cut -d'|' -f2)\ndone\n```\n\n### vm_stat Parsing — Case-Sensitive grep Required (macOS only; irrelevant on Linux)\nmacOS vm_stat outputs uppercase field names:\n```\nPages free:                               96480.\nPages active:                            296328.\n```\n```bash\n# WRONG — awk \u002Fpages active\u002F doesn't match (case)\nmem_active=$(vm_stat | awk '\u002Fpages active\u002F {print $NF}')\n# RIGHT\nmem_active=$(vm_stat | grep 'pages active' | awk '{print $NF}' | tr -d '.')\n```\nThis applies to ALL vm_stat fields. The `-i` flag on grep works too.\n\n### LibreSSL vs OpenSSL (macOS only)\n`\u002Fusr\u002Fbin\u002Fopenssl` is LibreSSL 3.3.6 — silently fails on `x509 -noout -enddate`.\nAlways use brew: `\u002Fopt\u002Fhomebrew\u002Fbin\u002Fopenssl` (OpenSSL 3.x). On Linux `\u002Fusr\u002Fbin\u002Fopenssl` works fine.\n\n### No `2>\u002Fdev\u002Fnull` With openssl in Subshells\n```bash\n# DON'T: cert=$(openssl ... 2>\u002Fdev\u002Fnull)  ← kills cert output!\n# DO:    cert=$(openssl ... 2>&1)\n```\n\n### No `timeout` With openssl\n`timeout 5 openssl s_client` kills the process mid-TLS-handshake. Don't wrap openssl in timeout (it exits naturally after DONE).\n\n### No `ping` Binary (macOS only)\nUse `tailscale ping` instead. On Linux, `ping` is available.\n\n### No `\u002Fdev\u002Ftcp` (macOS only)\nBash's virtual filesystem `\u002Fdev\u002Ftcp` doesn't exist on macOS.\n\n### SSH Key Timeout for Relay Nodes\nNodes behind Tailscale DERP relays take 3-5s per SSH connection. Always use `ConnectTimeout=5`. `ConnectTimeout=3` gives false positives.\n\n### No SSH Private Keys on Linux VPS\nOn the Hetzner VPS where Appie-3 runs, `~\u002F.ssh\u002F` typically only has `authorized_keys` — no `id_*` private keys. Fleet SSH checks that rely on SSH keys will fail. Use the local machine as the SSH client (Mac Mini appie-1) or deploy keys to the VPS if fleet checks must run from there.\n\n## Client Site Reconnaissance & Deployment Inspection\n\nA recurring CTO task: user says \"check out [client site]\" and you need to identify the platform, find the deployment, and inspect the build.\n\n### 1. Platform Identification\n\nWhen visiting an unknown client site, determine what platform it's built on:\n\n| Signal | Platform | How to Check |\n|--------|----------|-------------|\n| Scripts from `cdn.prod.website-files.com` | **Webflow** | `document.querySelectorAll('script[src*=\\\"website-files\\\"]')` via browser_console |\n| `server: Netlify` in HTTP headers | **Netlify** | `curl -sI https:\u002F\u002Fexample.com \\| grep -i server` |\n| `X-NF-Request-Id` \u002F `Netlify Edge` in cache-status | **Netlify** | `curl -sI \\| grep -i 'x-nf\\|netlify'` |\n| `server: cloudflare` only | **Cloudflare proxy** (platform unknown) | `curl -sI \\| grep -i server` — need to dig deeper |\n| WordPress paths (`\u002Fwp-content\u002F`, `\u002Fwp-admin\u002F`) | **WordPress** | Check page source or paths |\n| `meta[name=\"generator\"]` content | Various | `document.querySelector('meta[name=\\\"generator\\\"]')?.content` |\n| Nameservers | Hosting provider | `dig example.com NS +short` |\n\n**Pattern**: always check multiple signals — a single header can be misleading (Cloudflare proxies many platforms).\n\n### 2. Codebase Search for Non-Resolving Subdomains\n\nWhen user gives a subdomain that doesn't resolve (DNS error), search the workspace:\n\n```bash\n# The domain is likely stored somewhere in project configs\nsearch_files(path=\"~\u002Fclawd\", pattern=\"booking.example*\", target=\"content\")\nsearch_files(path=\"~\u002Fclawd\u002Fprojects\", pattern=\"example*\", target=\"files\")\n```\n\nCommon hiding places in the Weblyfe workspace:\n- `projects\u002Fweblyfe-ai-standalone\u002Fscreenshot-tool.js` — `url` keys in the array\n- `projects\u002F*\u002Fnetlify.toml` — custom domain configs\n- `projects\u002F*\u002Ffleet-config.ts` — agent\u002Fclient domain inventory\n- `docs\u002Fopenclaw_clients*.csv` — client domain lists\n\n### 3. Netlify Deployment Inspection\n\nRequires: `NETLIFY_AUTH_TOKEN` in `~\u002F.weblyfe-secrets\u002F.env`.\n\n```bash\n# Source the token\nsource ~\u002F.weblyfe-secrets\u002F.env\n\n# List all sites and find the target\ncurl -s -H \"Authorization: Bearer $NETLIFY_AUTH_TOKEN\" \\\n  \"https:\u002F\u002Fapi.netlify.com\u002Fapi\u002Fv1\u002Fsites?page=1&per_page=100\" | \\\n  python3 -c \"import sys,json; [print(s['name'], s.get('custom_domain','')) for s in json.load(sys.stdin)]\"\n\n# Get site details — includes build_settings (cmd, dir, repo_url, repo_branch)\nSITE_ID=$(curl -s -H \"Authorization: Bearer $NETLIFY_AUTH_TOKEN\" \\\n  \"https:\u002F\u002Fapi.netlify.com\u002Fapi\u002Fv1\u002Fsites?page=1&per_page=100\" | \\\n  python3 -c \"import sys,json; [print(s['id']) for s in json.load(sys.stdin) if 'example' in s['name'].lower()]\")\n\n# Check deploys (last 5)\ncurl -s -H \"Authorization: Bearer $NETLIFY_AUTH_TOKEN\" \\\n  \"https:\u002F\u002Fapi.netlify.com\u002Fapi\u002Fv1\u002Fsites\u002F$SITE_ID\u002Fdeploys?page=1&per_page=5\"\n```\n\n**Key fields from deploy:**\n- `state`: `ready` \u002F `error` — build success\n- `created_at`: deploy timestamp\n- `deploy_time`: seconds\n- `commit_ref`: git commit SHA (first 10 chars for display)\n- `commit_url`: link to GitHub commit\n- `published`: `true` = live version (`None` = not published)\n- `error_message`: build failure reason\n\n**Key fields from build_settings** (in site detail):\n- `cmd`: build command (e.g. `npm run build`)\n- `dir`: publish directory (e.g. `dist`)\n- `repo_url`: linked GitHub repo\n- `repo_branch`: branch for auto-deploys\n- `provider`: git provider (`github`)\n- `allowed_branches`: which branches trigger deploys\n\n### 4. DNS & Nameserver Checks\n\n```bash\n# Check A record\ndig example.com A +short\n\n# Check nameservers (identify hosting provider)\ndig example.com NS +short\n\n# Check if subdomain exists\ndig sub.example.com A +short\n\n# Check HTTP headers (platform identification)\ncurl -sI https:\u002F\u002Fexample.com | grep -iE 'server|x-powered-by|x-served-by'\n```\n\n### 5. GitHub Repo Inspection (if token works)\n\nSource from `~\u002F.weblyfe-secrets\u002F.env` and use:\n```bash\ncurl -s -H \"Authorization: token $GITHUB_TOKEN\" \\\n  \"https:\u002F\u002Fapi.github.com\u002Frepos\u002FOWNER\u002FREPO\"\n```\n\nIf the token returns `401 Bad credentials`, note it and proceed without — the build settings from Netlify usually have enough info.\n\n### 6. Site Reconnaissance Results Template\n\nReport findings in a compact table for Telegram:\n\n```markdown\n**? Site:** `https:\u002F\u002Fexample.com` — description\n**Platform:** Webflow \u002F Netlify \u002F WordPress\n\n**Netlify:** naam | ✅ Live | laatst: datum (Xs)\n**Repo:** `owner\u002Frepo` (branch: main)\n**Build:** `npm run build` → `dist\u002F`\n\n**App details:**\n- Multi-step wizard: Step 1 → Step 2 → ...\n- Key features: feature list\n- Footer: credits, links\n```\n\n## Post-Scan Steps\n\nAfter the scan script finishes:\n\n### 0. Log to Mission Control\n\nLog task lifecycle to the fleet orchestrator dashboard:\n\n```bash\npython3 ~\u002Fclawd\u002Ftools\u002Fmc-log-task.py \"Daily security scan\" --agent Appie-3 --status done\n```\n\nZie `references\u002Fmission-control-integration.md` voor de standing directive, tool setup, en endpoint details.\n\n### 1. Update INDEX.md\nAppend one line to `~\u002Fclawd\u002Fappie-brain\u002Fknowledge\u002Fresearch\u002Fdaily-research\u002FINDEX.md`:\n```\n| YYYY-MM-DD | ?\u002F? Security Scan — key findings | [Report](.\u002FYYYY-MM-DD\u002Fsecurity-scan.md) |\n```\nUse `patch` to append after the last table row — never `write_file` (would overwrite index).\n\n### 2. Add CTO Action Items\nFor every ?\u002F⚠️ finding, append a `## CTO Action Items` section:\n```\n## CTO Action Items\n  ? **finding** — context\n  ├─ Check: command\n  └─ Priority: High\u002FMedium\u002FLow\n```\n\n### 3. Verify Report\nRead file at `~\u002Fclawd\u002Fappie-brain\u002Fknowledge\u002Fresearch\u002Fdaily-research\u002FYYYY-MM-DD\u002Fsecurity-scan.md` before delivering.\n\n## Timing\n\nv2 scan takes ~120-180s (down from 180-300s in v1):\n- SSH fleet: 5-15s\n- SSL certs: 10-15s (4 domains)\n- Gitleaks --no-git: 10-60s\n- Security headers: 10-20s (4 domains)\n- Pending updates: 5-10s (SSH)\n- CVE APIs: 5-15s\n- npm audit: 30-60s\n\n## Pitfalls\n\n### Pending Updates Scorecard Bug — SSH Fail Falsely Reports ✅ (FIXED 2026-06-12)\n\nThe `scan_updates()` function had a logic flaw: when SSH fails (`$updates = \"?\"`), the if-condition fell through to `else` which reported `\"✅ $name — up-to-date\"`. Fixed by adding an explicit `?` check that reports `\"? $name — unreachable\"` instead. See `references\u002Flinux-cross-platform-notes.md` for the cross-platform equivalents used during the port.\n\n**Old behavior**: SSH unreachable → falsely reported as \"up-to-date\"\n**Current behavior**: SSH unreachable → \"? $name — unreachable\"\n- **vm_stat awk bug**: `awk '\u002Fpages active\u002F'` returns empty on macOS. Always use `grep`.\n- **Gitleaks git mode**: 35,399 false positives from history. Always `--no-git` with `.gitleaks.toml`.\n### Cron Workdir Must Exist on the Host\n\nEach cron job can have a `workdir` that Hermes `cd`s into before running the script. If the workdir path doesn't exist on the host (e.g. macOS path `\u002FUsers\u002Fappie\u002Fclawd` on a Linux VPS), the job may fail silently or produce no delivery.\n\n**Best practice**: either omit `workdir` (uses default), or set it to an absolute path that exists on the current host. Check with `ls -d \u002Fpath\u002Fto\u002Fworkdir` before scheduling.\n\n### `no_agent` Script Location\n\nScripts must be at `~\u002F.hermes\u002Fscripts\u002F\u003Cname>` (or the active profile's scripts directory). Hermes resolves no_agent script names from this directory — do not include a path prefix in the cron `script` field, just the filename.\n- **FLEET_CACHE format**: Use pipe-separated, not JSON. JSON escaping of emoji statuses (??) and descriptions with parentheses causes parse failures.\n- **`[]` in fleet cache**: Initialize with `: > \"$FLEET_CACHE\"` (empty file), not `echo \"[]\" > \"$FLEET_CACHE\"`. The Telegram section reads all lines and `[]` appears as garbage output.\n- **Security headers via curl**: Cloudflare\u002Fredirect chains may show intermediate headers. Use `-L` or check the final URL separately.\n- **Pending updates security count**: Use `grep -i security` not `-security` — the dash-prefix format varies by Ubuntu version.\n\n### v1 → v2 What Changed\n- **Telegram\u002Freport divergence**: FIXED. v1 had separate SSH loops for report and Telegram with different ConnectTimeout values. v2 uses shared FLEET_CACHE.\n- **CVE feed**: NVD (rate-limited) → GitHub Advisory API (no auth) + OSV.dev (no auth).\n- **Ghost nodes**: spark-atlas, eva removed from active scan → \"Archived Nodes\" section.\n- **Duplicate macOS quirks**: Removed from bottom of SKILL.md. Now only in the macOS section.\n- **Watchdogs**: Not part of daily scan. Separate cron jobs with no_agent=True.\n\n### v4 — New (2026-06-23)\n- **4-category fleet model**: Added TAILNET_ONLINE array for online nodes without SSH (iOS, Remote Login off). BROKEN_KEYS refactored for port-22-open\u002Fkey-rejected nodes. GHOSTS expanded to ALL offline nodes, not just >30d.\n- **Comprehensive fleet coverage**: Scan now covers all 15 tailnet nodes instead of just 2-3 reachable ones. Telegram output groups by status category.\n- **Grouped Telegram output**: New `case`-based group-tracking pattern for organized fleet display. All 4 array types write to shared FLEET_CACHE.\n- **Fleet SSH Access Map**: Updated from 7 to 15 nodes with category column.\n- **Fleet Reality-Check**: Expanded from 2 arrays to all 4.\n\n## Docker Web Service Hardening\n\nA recurring CTO task: a client-facing web service (often n8n, but the pattern applies to any Docker-based service) that's exposed to the internet via reverse proxy. This section captures the systematic hardening sequence, applied during the 2026-06-15 n8n-weblyfe upgrade.\n\n### Hardening Sequence (ordered by risk)\n\n| Step | Action | Risk if skipped | Revert |\n|------|--------|-----------------|--------|\n| 1 | **Pin Docker images** — never `latest` tag. Use exact semver (e.g. `n8n:2.26.3`, `caddy:2`) | Unpredictable updates break workflows | `docker compose up -d` with old tag |\n| 2 | **Bind internal ports to 127.0.0.1 only** — `127.0.0.1:5678:5678` instead of `5678:5678`. The reverse proxy (Caddy) reaches it via the Docker network, not host interface | Direct HTTP access bypasses TLS\u002FHTTPS | Revert port mapping in compose |\n| 3 | **Persist encryption keys in .env** — extract from container config (e.g. n8n's `\u002Fhome\u002Fnode\u002F.n8n\u002Fconfig` encryptionKey), add to `.env`, reference in compose as `N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}` | On volume rebuild, all encrypted credentials become unrecoverable | Remove env var, config falls back to auto-generated key |\n| 4 | **UFW firewall** — `deny incoming`, allow only 22, 80, 443. Docker's DOCKER-USER chain runs before UFW, so container-networking (Caddy→n8n) stays intact | Exposed SSH + direct service ports | `ufw disable` |\n| 5 | **Fail2ban for SSH** — `maxretry=3`, `bantime=86400` on sshd jail. Pre-installed on many Ubuntu images but often not enabled | Unlimited brute-force attempts | `fail2ban-client stop sshd` |\n| 6 | **SSH key-only** — `PermitRootLogin prohibit-password`, `PasswordAuthentication no`. Verify with `sshd -t && systemctl reload ssh` before disconnecting. **Exception:** Digital Ocean web console requires password login — set `PermitRootLogin yes` + `PasswordAuthentication yes` if DO console access is needed | Password-based attacks | Revert sshd_config changes |\n| 7 | **System updates + reboot** — `apt update && DEBIAN_FRONTEND=noninteractive apt upgrade -y` then reboot for kernel. **Use `systemctl reboot`** — `reboot`\u002F`shutdown -r now` may be blocked by agent security. May leave SSH session in background during long upgrades | Unpatched kernel + CVE-exploitable packages | Rollback via apt snapshots (rarely needed) |\n| 8 | **Clean up old Docker images** — `docker image prune -f`, remove old tags (`docker rmi \u003Cold-tag>`). Reclaim 2-4GB on small droplets | Disk fills up, service degrades | Images can be re-pulled by tag |\n\n### Docker Compose Pitfalls (n8n-specific, but apply generally)\n\n**Docker Compose v2:** Remove the `version:` top-level key. Compose v2 emits `version must be a string` validation errors and ignores it entirely. Use raw services block.\n\n**`.env` variable expansion:** Docker Compose auto-loads `.env` from the compose project directory. But when `docker compose config` shows unresolved paths (e.g. `${DATA_FOLDER}\u002Fx`), switch to **absolute paths** in the compose file to guarantee reliability regardless of env loading order.\n\n**Image registry divergence:** The n8n 1-Click Droplet had two n8n images — `n8nio\u002Fn8n:latest` (Docker Hub) and `docker.n8n.io\u002Fn8nio\u002Fn8n:latest` (official n8n registry). Only one is used by the compose file; the other is orphaned waste. After pinning a specific version, clean up the orphan with `docker rmi`.\n\n**n8n deprecation handling:** After upgrade, check container logs (`docker logs \u003Ccontainer> --tail 20`). Common deprecations to action:\n- `N8N_RUNNERS_ENABLED` → Remove from environment; no longer needed (task runners auto-register)\n- `storage directory rename` → Set `N8N_MIGRATE_FS_STORAGE_PATH=true` to migrate binaryData→storage for n8n v3\n- `pdf-lib not installed` in task runner → Install via Dockerfile or remove from NODE_FUNCTION_ALLOW_EXTERNAL if not used\n\n### n8n-Specific Hardening (see reference)\n\nSee `references\u002Fn8n-droplet-hardening.md` for the full session transcript including version gap (2.13.2 → 2.26.3 = 12+ minor versions), n8n config structure, and the exact docker-compose.yml changes applied.\n\n### Original v1 Pitfalls (still relevant)\n- SSH timeout consistency: all sections must use same ConnectTimeout.\n- Hermes agent count >1 is normal (gateway + workers).\n- macOS load includes disk I\u002FO, expect slightly higher readings vs Linux.\n\n## Reference Files\n### Seyed Communication Pattern — Short Blocker Lists\n\nSeyed responds best to **executive blocker summaries** — not detailed reports. When reporting fleet security status:\n\n- Lead with a **3-6 item checklist** of blockers (? = blocks me, ? = needs his input, ✅ = already working)\n- Each blocker: 1 line description + 1 line remedy\n- End with what's already running without his help\n- Example pattern from 2026-06-20: \"? Blocker 1 — eugi SSH\" → Seyed forwarded the key within minutes\n- Do NOT bury the blocker in prose. Use a compact table or bullet list with urgency emoji\n\nThis pattern is preferred over full scan reports for daily\u002Fstandup comms. Save the full report for when he asks \"run the scan\" or for cron deliveries.\n\n## Reference Files\n\n- `references\u002Fdaily-security-scan-script.md` — annotated v2 script reference (output structure, key implementation details, normal ranges)\n- `references\u002Fmission-control-integration.md` — Mission Control task-logging setup, standing directive, fleet config reference\n- `references\u002Ffleet-snapshot-v2.md` — fleet state after 2026-06-02 update (spark-atlas\u002Feva back online, current node inventory)\n- `references\u002Ffleet-inventory.md` — SSH key inventory, active\u002Fghost node map, latency, and per-machine notes\n- `references\u002Fsecurity-suggestions.md` — daily security suggestion pipeline (S001-S020) voor multi-agent governance, dagrotatie, en veilige\u002Freversible acties\n- `references\u002Fcron-log-self-audit.md` — systematic procedure for auditing cron job health, log anomalies, and script config drift against real Tailscale state\n- `references\u002Fssh-key-deployment.md` — batch deploy Appie-3's SSH public key to the fleet: deploy script template, idempotent key check, non-Tailscale server pattern (public IP \u002F Digital Ocean), post-deployment verification\n- `references\u002Ftailscale-device-cleanup.md` — identify and remove stale\u002Fduplicate Tailscale devices via dashboard\u002FAdmin API, including StableID verification and post-key-deploy SSH probes\n- `references\u002Fnew-host-init.md` — procedure for initializing the CTO agent on a fresh host: cron validation, platform-specific patching, tool installation, pending-items documentation\n- `references\u002Fnew-host-init.md` — procedure for initializing the CTO agent on a fresh host: cron validation, platform-specific patching, tool installation, pending-items documentation\n- `references\u002Fmac-mini-coding-harness-recovery.md` — recover access to an online macOS Mini \u002F coding harness over Tailscale when SSH is listening but Appie-3's key is not authorized.\n- `references\u002Fnew-host-init.md` — procedure for initializing the CTO agent on a fresh host: cron validation, platform-specific patching, tool installation, pending-items documentation\n\n## Scripts (in `~\u002F.hermes\u002Fscripts\u002F`, or profile-specific scripts dir)\n\n- `disk-watchdog.sh` — disk threshold check, silent when healthy\n- `tailscale-watchdog.sh` — core node connectivity, silent when healthy\n- `ssh-key-audit.sh` — monthly authorized_keys review per fleet node\n- `failed-login-trend.sh` — CSV-based daily count with spike detection\n- `backup-sync.sh` — rsync to appie-2 (optional, needs approval)\n- `file-integrity-check.sh` — sha256 baseline for critical system files\n- `appie-3-daily-security-scan.sh` — daily security scan (covers 9 layers)===ME:security-scanning","# Daily Security Scanning & Fleet Health Automation (v2)\n\n## When to Use\n\nBuild or maintain a daily security scan when:\n- User requests a \"security scan\" or \"daily security briefing\"\n- Setting up cron jobs for CTO oversight\n- Automating fleet health monitoring\n- Checking SSL cert expiry, CVE feeds, supply chain vulns\n- Any recurring security audit workflow\n\n## Scan Architecture (v2 — 9 Layers)\n\nThe canonical script lives at the workspace path `~\u002Fclawd\u002Ftools\u002Fappie-3-daily-security-scan.sh`. The actual runnable copy is at `~\u002F.hermes\u002Fscripts\u002Fappie-3-daily-security-scan.sh` (or the profile-specific scripts dir, e.g. `~\u002F.hermes-appie3\u002Fscripts\u002F` on some setups). Every layer maps to a function.\n\n### Layer 1: Local Machine Health\n\n```bash\n- Disk usage (df -h \u002F)\n- Memory: vm_stat — use grep, NOT awk \u002Fpattern\u002F\n  * WRONG: vm_stat | awk '\u002Fpages active\u002F {print $NF}'  → empty!\n  * RIGHT: vm_stat | grep 'pages active' | awk '{print $NF}'\n  * On macOS vm_stat output starts with uppercase \"Pages\", awk \u002Fpages\u002F doesn't match\n  * If >90% active: dump top 5 processes by RSS + swap info\n- Load averages (sysctl vm.loadavg \u002F uptime)\n- Hermes agent count (pgrep -f hermes_cli | wc -l)\n- Failed logins in 24h (log show --predicate)\n```\n\n### Layer 2: Fleet Health (SSH via Tailscale)\n\nUses **4 category arrays** (all indexed, pipe-separated — bash 3.x compat):\n\n| Array | Emoji | Condition | Check Type |\n|-------|-------|-----------|------------|\n| `FLEET` | ?\u002F? | SSH key works | Full SSH health (disk, load, Hermes, updates) |\n| `BROKEN_KEYS` | ? | Online, port 22 open, key rejected | `nc -zv` port check (\u003C1s) |\n| `TAILNET_ONLINE` | ⚪ | Online, no SSH daemon | Tailnet status only |\n| `GHOSTS` | ? | Offline >7d | Archived, no active check |\n\nEntry format: `\"name|user@tailscale_ip|ssh_key_path|description\"`\nSSH: `-o ConnectTimeout=5 -o BatchMode=yes -o StrictHostKeyChecking=no`\nResults cached to FLEET_CACHE file (pipe-separated: `name|status|desc`)\n\n**Key v2 fix**: FLEET_CACHE is shared between markdown report and Telegram output. NO separate SSH loop for Telegram. This eliminates the v1 Telegram divergence bug.\n\n**Tailnet-only entries** (BROKEN_KEYS, TAILNET_ONLINE, GHOSTS) also write to FLEET_CACHE so the Telegram output can render all 4 groups in sequence from a single cache read. This is critical for completeness — the Telegram scan should show ALL tailnet nodes, not just SSH-reachable ones.\n\n### Layer 3: Local Open Ports\n\n```bash\nlsof -iTCP -sTCP:LISTEN -P -n | awk 'NR>1 && !seen[$1,$9]++'\n```\nFlags unexpected dev services on unprivileged ports. Expected: bun on 37701 (Hermes internal).\n\n### Layer 4: Supply Chain Security\n\n```bash\n# npm audit (high+ only)\nnpm audit --audit-level=high\n\n# Python safety check\nsafety check --short\n\n# Gitleaks secret scan — CRITICAL: always use --no-git with .gitleaks.toml\ngitleaks detect --source $CLAWD_DIR --no-git --config .gitleaks.toml --verbose\n```\n- **ALWAYS --no-git**: git mode scans 2369 commits (487MB) → 35k false positives\n- **ALWAYS .gitleaks.toml**: suppress example keys, lockfile hashes, test data\n- **ALWAYS timeout 60**: gitleaks --no-git can CPU-spike to 975%\n- Extract leak count from \"leaks found: N\" line, not grep -c\n\n### Layer 5: SSL\u002FTLS Certificates\n\n```bash\n# Use brew OpenSSL — system LibreSSL can't parse x509 output\nossl=\"\u002Fopt\u002Fhomebrew\u002Fbin\u002Fopenssl\"\ncert_raw=$(echo \"\" | \"$ossl\" s_client -servername \"$domain\" -connect \"$domain\":443 2>&1)\nenddate=$(echo \"$cert_raw\" | \"$ossl\" x509 -noout -enddate 2>\u002Fdev\u002Fnull | cut -d= -f2)\n```\n- NO 2>\u002Fdev\u002Fnull on s_client (kills output in subshell)\n- NO timeout wrapper (kills mid-handshake)\n- Flag \u003C7d ?, \u003C30d ⚠️\n\n### Layer 6: Security Headers\n\n```bash\ncurl -sI --max-time 5 \"https:\u002F\u002F$domain\"\n# Check for: HSTS, CSP, X-Frame-Options, X-Content-Type-Options\n```\nAll 4 required. Score: 4\u002F4 ?, 2-3 ⚠️, 0-1 ?.\nCaveat: follow redirects with `-L` if domain uses Cloudflare\u002Fredirect chains.\n\n### Layer 7: Pending Updates (fleet SSH)\n\n```bash\nssh \u003Cnode> \"apt list --upgradable | grep -v 'Listing...' | wc -l\"\nssh \u003Cnode> \"apt list --upgradable | grep -i security | wc -l\"\n```\n- Security count via `grep -i security` (not `-security` — varies by distro)\n- 0 updates ✅, 1-20 ⚠️, 20+ or any security ?\n\n### Layer 8: Tailscale Network\n\n```bash\ntailscale status --json | python3 -c \"import sys,json; ...\"\n```\nCounts peers, finds offline nodes, shows last-seen timestamps.\n\n### Layer 9: CVE Watch (v2 — no NVD)\n\n**PRIMARY: GitHub Advisory API** (no auth, no rate limit issues)\n```\nGET https:\u002F\u002Fapi.github.com\u002Fadvisories?type=reviewed&severity=critical&per_page=8\n```\n- Returns GHSA advisories sorted by `published_at` desc\n- Use HTTP status code check (curl -w %{http_code}) — don't rely on python successfully parsing\n- Filter by published_at within 48h via Python datetime comparison\n- Also fetch high severity for awareness\n\n**SECONDARY: OSV.dev** (per-package, always works)\n```\nPOST https:\u002F\u002Fapi.osv.dev\u002Fv1\u002Fquery\n{\"package\": {\"name\": \"openssl\", \"ecosystem\": \"PyPI\"}}\n```\n- Query key packages: openssl, node, curl\n- Also query agent frameworks via `agent-framework-cve-scan.py` (see `references\u002Fagent-framework-cve-scan.md`)\n- Filter by published date within 90d\n- No auth needed, no rate limits observed\n\n**TERTIARY: Agent Framework & Go Ecosystem CVE Scanner** (standalone Python script)\n  - Covers 20 packages: 17 Python agent frameworks (LangChain, CrewAI, Semantic Kernel, AutoGen, LlamaIndex, LiteLLM, guardrails-ai, giskard, etc.) + 3 Go infra packages (golang.org\u002Fx\u002Fcrypto, github.com\u002Fgo-chi\u002Fchi, github.com\u002Fsigstore\u002Frekor)\n  - Checks `pip list` locally + OSV.dev API per package\n  - Go packages added 2026-06-26 n.a.v. 7 critical SSH crypto CVEs published 2026-06-25\n- Run: `python3 ~\u002Fclawd\u002Ftools\u002Fagent-framework-cve-scan.py`\n- See `references\u002Fagent-framework-cve-scan.md`\n\nNVD API v2.0 is NOT used — requires API key to avoid 5 req\u002F30s limit. Free key tier exists but is unavailable from this environment.\n\n### Layer 10: Bot & Client Health Check (ad-hoc, not in daily scan)\n\nRun periodically (weekly or on demand) — check all active Telegram bots and web live services for basic health:\n\n```bash\n# 1. List deployed bots from project config\n# 2. For each bot endpoint, check:\n#    - curl -m 5 \u003Cbot_url>\u002Fhealth (or \u002F) — returns 200?\n#    - curl -m 5 \u003Cbot_url> | grep -i \"ok\\|alive\\|running\"\n# 3. For Telegram bots, check response via bot API:\n#    curl -m 5 \"https:\u002F\u002Fapi.telegram.org\u002Fbot\u003CTOKEN>\u002FgetMe\"\n# 4. For YouTube \u002F media bots, check if deploy is still live on platform\n```\n\nNot automated as a daily cron (too many client-specific endpoints, rate-limit risk on Telegram API). Run as an ad-hoc CTO audit.\n\n### Layer 11: Continuous Improvement — Research → Scripts\n\nSeyed's standing directive: **use the daily AI briefing research to improve the security scripts.** After each daily briefing, scan the research output for:\n\n| Signal | Action |\n|--------|--------|\n| New CVE class or attack vector | Add a check layer or tool to the scan |\n| New tool or best practice | Add install command + verification to the scan or host-init |\n| Configuration hardening advice | Add to the security suggestion pipeline |\n| Client bot platform deprecation | Flag in bot health check layer |\n| New scanning methodology | Replace or augment an existing scan layer |\n\nImplementation checklist after each daily briefing:\n1. Read the research output (`~\u002Fclawd\u002Fappie-brain\u002Fknowledge\u002Fresearch\u002Fdaily-research\u002FYYYY-MM-DD\u002FREADME.md`)\n2. Cross-reference against existing scan layers — what's missing?\n3. For any gap: add a new function to the scan script or update existing logic, **or create a standalone script** for cross-platform use\n4. Test the change: run the affected layers manually\n5. If the improvement is structural (new layer, new tool), update this SKILL.md — add a reference file if the new tool has its own docs\n6. Log to Mission Control: `mc-log-task.py \"Security script improvement: \u003Csummary>\" --agent Appie-3`\n\n**Do not batch up improvements.** Make them as you discover them. A one-line regex addition or a new cert check costs nothing; deferring it until \"next Monday\" means it never happens.\n\n**Examples of recent improvements from research:**\n- `agent-framework-cve-scan.py` — created from 2026-06-20 briefing which found CVE-2026-26030 (Semantic Kernel RCE), GHSA-gr75-jv2w-4656 (LangChain path traversal). Expanded 2026-06-25 +3 (litellm, guardrails-ai, giskard). Expanded 2026-06-26 +3 Go infra packages (golang.org\u002Fx\u002Fcrypto after 7 critical SSH CVEs, go-chi\u002Fchi IP spoofing, sigstore\u002Frekor OOM). See `references\u002Fagent-framework-cve-scan.md`.\n- `headroom-ai` v0.26.0 — installed after 2026-06-20 briefing flagged Headroom (60-95% token compression). Has MCP server, pure Python, Apache-2.0.\n- SkillsGuard evaluated — TypeScript\u002FNode.js project (not installable on Python stack), cloud API available at `https:\u002F\u002Fskillsguard.apiskillsguard.workers.dev\u002Fscan`.\n\n### Tailnet Reconnaissance — Full Fleet Exploration Pattern\n\nA standalone workflow for when you need a **complete picture of every machine on Tailscale**: what's online, what ports are open, what services run, and whether SSH keys work. Use this before setting up scans, deploying keys, or auditing fleet security posture.\n\n#### Workflow\n\nStep-by-step exploration, run each command and compile results:\n\n**Step 1: List all machines**\n\n```bash\ntailscale status\n# Full listing with IP, name, OS, online\u002Foffline status\ntailscale status | grep -v offline  # only online machines\ntailscale status --json             # programmatic access\n```\n\n**Step 2: Ping all online machines**\n\n```bash\nfor ip in \u003Call_online_tailscale_ips>; do\n  result=$(ping -c 2 -W 3 $ip 2>&1 | tail -1)\n  echo \"$ip -> $result\"\ndone\n```\n\nHelps identify reachability and latency. Machines behind DERP relays show higher RTT (100-400ms). Local DERP-free machines show 1-5ms.\n\n**Step 3: Port-scan per machine**\n\nUse `nc -zv` for fast TCP port checks. Common ports to probe:\n\n```bash\n# Linux servers\nfor port in 22 80 443 3000 5000 8000 8080 8443 9090 2375 2376 6443 7860 8888; do\n  nc -zv -w 2 $ip $port 2>&1 | grep -v \"Connection refused\"\ndone\n```\n\nAdditional macOS-specific ports: 5900 (VNC), 7000 (AirPlay), 5353 (mDNS).\n\nKey port signatures:\n- `22` → SSH (verify key auth next)\n- `443` → HTTPS web service\n- `80` → HTTP (redirect to HTTPS or legacy)\n- `3000` → Common dev\u002FNext.js default port\n- `5000` → Flask\u002FExpress\u002Fdevelopment\n- `5900` → VNC\u002FScreen Sharing (macOS)\n- `8443` → Alternative HTTPS\n\n**Step 4: Identify web services**\n\nFor every open HTTP\u002FHTTPS port, curl the root path to identify the service:\n\n```bash\n# HTTPS\ncurl -sk https:\u002F\u002F$ip\u002F | head -c 200\ncurl -sk https:\u002F\u002F$ip\u002F 2>&1 | grep -i \"\u003Ctitle>\"\n\n# HTTP on alternate ports\ncurl -sk http:\u002F\u002F$ip:$port\u002F | head -c 200\n```\n\nLook for:\n- `\u003Ctitle>` tag — identifies the site\u002Fapp\n- Server headers: `curl -sI https:\u002F\u002F$ip\u002F | grep -i server`\n- Framework fingerprints (Next.js, WordPress, Flask, etc.)\n- JSON responses if it's an API\n- Empty response may indicate TLS SNI filtering — try `-H \"Host: example.com\"`\n\n### Step 5: Test SSH Connectivity & Diagnose Failures\n\nWhen SSH fails, methodically diagnose *why* — the remediation differs by failure mode.\n\n#### 5a. Basic Auth Test\n\n```bash\nssh -o ConnectTimeout=5 -o BatchMode=yes -o StrictHostKeyChecking=no \\\n  -i ~\u002F.ssh\u002Fid_ed25519 \u003Cuser>@\u003Cip> \"hostname && uname -a\"\n```\n\n**Outcomes by error message:**\n\n| Error | Meaning | Next step |\n|---|---|---|\n| `Permission denied (publickey)` | Port open, SSH running, key **not accepted** | Deploy the key (see refs) |\n| `Connection refused` | Port 22 closed, no SSH daemon | Go to 5b below |\n| `Connection timed out` \u002F hangs | Firewall dropping or host unreachable | Check network (ping) |\n| `unexpected HTTP response: 502 Bad Gateway` via `tailscale ssh` | Tailscale SSH not configured on remote | Go to 5b below |\n\nAlso test alternative keys: `id_ed25519_github`, `id_ed25519_spark`, etc.\n\n#### 5b. Port-Closed Diagnosis (SSH daemon not running)\n\nWhen port 22 is closed, use this systematic flow:\n\n```bash\n# 1) Verify basic network reachability\nping -c 2 -W 3 \u003CIP>\n\n# 2) Check if the host is on Tailscale and its state\ntailscale status | grep \u003CIP-or-name>\n# Look for: \"active\" → reachable, \"offline\" → unreachable\n\n# 3) Check the remote peer's Tailscale SSH capabilities\ntailscale status --json | python3 -c \"\nimport sys, json\nd = json.load(sys.stdin)\nfor pid, p in d.get('Peer', {}).items():\n    if '\u003CIP>' in str(p.get('TailscaleIPs', [])):\n        print('OS:', p.get('OS'))\n        print('Online:', p.get('Online'))\n        print('Capabilities:', p.get('Capabilities'))\n        print('CapMap:', p.get('CapMap'))\n\"\n```\n\n**Interpretation:**\n- `Capabilities: null` \u002F `CapMap: null` → **Tailscale SSH is NOT enabled** on the remote node. SSH won't work via `tailscale ssh` either.\n- `\"https:\u002F\u002Ftailscale.com\u002Fcap\u002Fssh\": null` in CapMap → Tailscale SSH IS enabled. If it fails with 502, check the Tailscale admin console.\n- Node is `active` with direct connection → reachable (even if SSH is closed).\n\n```bash\n# 4) Port scan common services to see if ANY ports are open\nfor port in 22 443 5900 8080 8443 3000 5000; do\n  nc -zv -w 3 \u003CIP> $port 2>&1 | grep -v \"Connection refused\"\ndone\n```\n\n**Remediation by failure mode:**\n\n| Failure | Fix |\n|---|---|\n| Port 22 closed, macOS | On the Mac: **System Settings → General → Sharing → Remote Login**. Or in **Tailscale Admin Console** → approve node for Tailscale SSH. |\n| Port 22 closed, Linux | `sudo systemctl enable --now sshd` or `sudo apt install openssh-server` |\n| Port 22 open, `Permission denied` | Deploy SSH public key to remote `~\u002F.ssh\u002Fauthorized_keys` (see `references\u002Fssh-key-deployment.md` \u002F `references\u002Fmac-mini-coding-harness-recovery.md`) |\n| Tailscale SSH 502, port 22 works fine | Retry direct `ssh` via Tailscale IP. The 502 is a Tailscale relay issue, not an SSH error. |\n| No ports open at all (22, 443, 5900, etc. all refused) | Machine may be asleep, on a restricted network, or fully locked down. macOS: no services enabled in Sharing prefs. |\n\nFor detailed session walkthrough with real error transcripts, see `references\u002Fssh-connectivity-diagnostics.md`.\n\n**macOS coding-harness recovery pattern**: if a Mac mini is online, port `22` is open, but common users reject Appie-3's key, stop guessing users\u002Fpasswords. Ask the local operator or another authorized agent on the box to add Appie-3's public key to the active macOS user's `~\u002F.ssh\u002Fauthorized_keys`, enable Remote Login, and report the actual username. Then verify harness state (`~\u002Fclawd`, `~\u002F.hermes`, `~\u002F.codex`, `~\u002F.claude`, and `ps` for `hermes|claude|codex|copilot|node|python`) before changing anything. Full recipe: `references\u002Fmac-mini-coding-harness-recovery.md`.\n\n**Step 6: Check local authorized_keys**\n\n```bash\ncat ~\u002F.ssh\u002Fauthorized_keys\ncat ~\u002F.ssh\u002Fid_ed25519.pub  # your own public key\n```\n\nThis tells you:\n- Who can SSH into *you* (the keys in authorized_keys)\n- Who *you* claim to be (the pubkey comment field)\n- Whether cross-fleet SSH is unidirectional only\n\n**Step 7: Compile and present**\n\nPresent findings as a compact table:\n\n```\n| Machine | IP | OS | Ping | Open ports | Services |\n|---------|----|----|------|------------|---------|\n| machine | 100.x.x.x | Linux | Xms | 22, 443, 3000 | SSH, web (app name) |\n```\n\nInclude:\n- Online\u002Foffline status per machine\n- Reachable services and what they are\n- SSH key acceptance status\n- The user's own pubkey (ready to copy-paste for deployment)\n\n#### Common Findings\n\n- **SSH key not deployed**: New VPS\u002Fmachine provisioning — pubkey needs to be added to authorized_keys. Common pattern: Appie-3's key isn't on any fleet machine, but other agents' keys already are.\n- **VNC open**: macOS machines with Screen Sharing enabled. Port 5900 open means anyone on tailnet could attempt authentication. Verify VNC is password-protected.\n- **Web service on alternate port**: Next.js dev server (3000), Flask\u002FExpress (5000), alternative HTTPS (8443) — may be development\u002Fstaging environments not meant for production.\n- **Offline nodes >30d**: Move to GHOSTS array in scan script. Their Tailscale IPs may change on reconnection.\n- **Multi-OS tailnet**: macOS machines have VNC (5900), AirPlay (7000), and different SSH configuration paths. Linux servers are more consistent.\n\n### Multi-Agent Cron Inventory — Fleet-Wide Schedule Audit\n\nA systematic method for auditing ALL cron jobs across a multi-agent fleet. Use when Seyed asks for a comprehensive schedule review, \"make all cron jobs aesthetic\", or before any fleet-wide cron reformatting.\n\n#### Workflow\n\n**Step 1: Enumerate all accessible machines**\n\n```bash\n# SSH key test across ALL tailnet hosts\nfor host in \"root@100.x.x.x\" \"appie@100.x.x.x\" \"eva@100.x.x.x\" \"root@100.x.x.x\"; do\n  result=$(ssh -o ConnectTimeout=3 -o BatchMode=yes -o StrictHostKeyChecking=no \\\n    -i ~\u002F.ssh\u002Fid_ed25519 \"$host\" \"hostname\" 2>&1)\n  echo \"$host → $result\"\ndone\n```\n\nNote: SSH user varies by machine — try `root`, `appie`, the user's name (`eva`, `harry`). Don't assume one user works everywhere.\n\n**Step 2: For each reachable machine, identify the runtime**\n\n```bash\n# Hermes cron\nhermes cron list\n\n# OpenClaw cron (legacy)\nls ~\u002F.openclaw\u002Fcron\u002F 2>\u002Fdev\u002Fnull\n\n# launchd plists (macOS)\nls ~\u002FLibrary\u002FLaunchAgents\u002F | grep -v 'com\\.google\\|homebrew'\n```\n\nKey signals for runtime detection via `ps aux`:\n- `hermes_cli.main gateway run` → Hermes agent\n- `openclaw` in process name → OpenClaw agent\n- `claude` or `codex` in process name → Claude Code \u002F Codex CLI\n\n**Step 3: Check cron managers**\n\n| Runtime | Cron Manager | Command |\n|---------|-------------|---------|\n| Hermes | `hermes cron` | `hermes cron list` |\n| OpenClaw (legacy) | cron files | `ls ~\u002F.openclaw\u002Fcron\u002F` |\n| macOS (legacy) | launchd plists | `launchctl list \\| grep com.weblyfe` |\n| System crontab | system cron | `crontab -l` |\n\n**Step 4: Document per-job health**\n\nFor each job, note:\n- Name and schedule\n- Last run status (ok\u002Ferror\u002Ffailed delivery)\n- Delivery target (telegram\u002Forigin\u002Fnone)\n- If job is broken: capture the exact error message\n\n**Step 5: Identify aesthetic\u002Fstyling improvements**\n\nCheck for:\n- **Naming convention**: consistent prefix per agent (`appie3-`, `appie2-`), no mixed case\n- **Output formatting**: Markdown + emoji headers vs plain text\n- **Delivery target**: all jobs deliver to Telegram (or all to origin — be consistent)\n- **Timing deconfliction**: no overlapping runs on the same agent\n- **Broken jobs**: provider errors, expired credits, delivery failures — all need fixing\n\n#### Fleet Topology Map (2026-06-24)\n\n| Machine | IP | Runtime | Cron | Notes |\n|---------|----|---------|------|-------|\n| appie-3-hermes | 100.69.131.51 | Hermes | `hermes cron` (6 jobs) | ✅ stable |\n| appie-2 | 100.118.143.10 | Hermes | `hermes cron` (13 jobs) | ? 7 broken |\n| appie-1 | 100.101.29.56 | OpenClaw | launchd (40+ plists) | ? |\n| eva | 100.99.64.92 | Hermes + OpenClaw | launchd | ? |\n| eugi | 100.110.58.73 | Hermes | 0 cron jobs | schone lei |\n| Deadpool | ? (off-tailnet) | ? | ? | Aparte Hetzner VPS voor Roslan + EKO |\n\nZie `references\u002Ffleet-inventory.md` voor de complete actuele inventaris.\n\n### Tailnet Discovery\n\n**Not all fleet machines are on Tailscale.** Deadpool (Hetzner VPS voor Roslan + EKO) is NOT on the tailnet and has no SSH config entry. When checking \"all machines\", distinguish between tailnet-connected and off-tailnet infrastructure.\n\n```bash\n# Full peer list with online status\ntailscale status\n\n# JSON output for programmatic use (Self vs Peer distinction is CRITICAL)\ntailscale status --json\n```\n\nThe local machine appears in `Self`, ALL other nodes in `Peer` dict:\n\n```python\nd = json.load(sys.stdin)\nself = d.get('Self', {})\nself_online = self.get('Online', False)               # local machine\npeer_online = any(p.get('Online', False)\n                  for p in d.get('Peer', {}).values()) # others\n```\n\n**WRONG**: Looping over `Peer` to find \"appie-1\" → always returns offline.\n**RIGHT**: Check `Self` for the local machine, `Peer` for all others.\n\nThis matters for watchdog scripts that check local node tailnet health. The `tailscale status` CLI output shows the local node without a status column (making it look unknown), but JSON `Self.Online` is always `True` for the running machine.\n\n### Connectivity Checks\n\n```bash\ntailscale ping -c 1 --timeout 3s \u003CIP>          # cross-platform\nssh -o ConnectTimeout=5 -o BatchMode=yes -o StrictHostKeyChecking=no \u003Cuser>@\u003Cip> \u003Ccmd>\n```\n\n**Key**: Never use direct Hetzner IPs — they change on reprovision. Always use Tailscale IPs (`100.x.x.x`). SSH key timeout: `ConnectTimeout=5` is required; `ConnectTimeout=3` gives false positives on DERP relay nodes.\n\n### Cross-Machine File Retrieval\n\nWhen you need to find and retrieve a file from a fleet machine:\n\n1. **Know where canonical assets live** — common locations per machine:\n   - **appie-1** (Mac Mini): `~\u002Fclawd\u002Fprojects\u002Fopenclaw-guide\u002Fcanonical\u002F` (Build-Your-Own-Appie PDFs), `~\u002Fclawd\u002Fassets\u002Fagent-avatars\u002F` (Telegram bot avatars)\n   - **appie-2** (Hetzner VPS): `\u002Froot\u002Fappie-brain\u002F`, `\u002Froot\u002F.hermes\u002F`\n   - **eugi** (Hetzner VPS): `\u002Froot\u002F.openclaw\u002F`, `\u002Froot\u002F.hermes\u002F`\n\n2. **Search remotely** — use `find` with name globs:\n   ```bash\n   ssh \u003Cuser>@\u003Ctailscale-host> \"find \u003Cpath> -iname '*pattern*v4*' -o -iname '*pdf*' 2>\u002Fdev\u002Fnull\"\n   ```\n   - Always use `find` (not `ls -R`) — scales to large directories\n   - Quote paths with spaces: `\"\u002FUsers\u002Fappie\u002Fclawd\u002Fprojects\u002Fopenclaw-guide\u002F\"`\n   - Use wildcards for version numbers: `*v4.5*`\n\n3. **SCP back** — file to local `\u002Ftmp\u002F`:\n   ```bash\n   scp \u003Cuser>@\u003Ctailscale-host>:\"\u003Cremote-path>\" \u002Ftmp\u002F\u003Clocal-name>\n   ```\n   - `scp` via Tailscale IP\u002Fhostname works without extra flags\n   - Use `\u002Ftmp\u002F` for ephemeral copies; move to `~\u002Fclawd\u002F` for permanent storage\n\n4. **Deliver the file**:\n   - **Telegram**: include `MEDIA:\u002Ftmp\u002F\u003Cfile>` in response — sends as native attachment\n   - **Email**: NOT set up on this VPS (no himalaya, mailtools, or SMTP creds). Ask Seyed for creds or an alternative\n   - **Public URL**: upload somewhere if Seyed needs to share the link\n\n5. **Clean up** — remove from `\u002Ftmp\u002F` when no longer needed:\n   ```bash\n   rm \u002Ftmp\u002F\u003Clocal-name>\n   ```\n\n**Pitfall**: macOS paths start with `\u002FUsers\u002F`, not `\u002Froot\u002F`. Check remote OS before constructing search paths.\n\n## SSH Key Inventory\n\nKeys stored in `~\u002F.ssh\u002F`. SSH config (`~\u002F.ssh\u002Fconfig`) has host aliases for fleet machines.  \n**Current reality (2026-06-24):** `appie-2`, `eugi`, `appie-1`, and `eva` all accept Appie-3's key. All other fleet nodes reject it or have no SSH daemon. Deploying the key to remaining BROKEN_KEYS nodes is the next step for fleet-wide SSH management.\n\n| File | Purpose | Status | Last Verified |\n|------|---------|--------|---------------|\n| `~\u002F.ssh\u002Fid_ed25519` | Default key (`appie-3-hermes@tailnet`) | ? appie-2, eugi, appie-1, eva \u002F ? others | 2026-06-24 |\n| `~\u002F.ssh\u002Fid_ed25519_github` | GitHub-only key | ? Works | — |\n| `~\u002F.ssh\u002Fid_ed25519_spark` | Spark Atlas key | ? Stale (node offline) | 2026-06-11 |\n\n### Fleet SSH Access Map (2026-06-23)\n\n| Device | OS | Port 22 | SSH Key | Category | Remedy |\n|--------|----|---------|---------|----------|--------|\n| appie-2 | Linux | ✅ Open | ✅ Root accepted | FLEET ? | — |\n| eugi | Linux | ✅ Open | ✅ Root accepted | FLEET ? | — |\n| appie-1 | macOS | ✅ Open | ✅ `appie@100.101.29.56` | FLEET ? | User `appie`, discovered 2026-06-24 |\n| eva | macOS | ✅ Open | ✅ `eva@100.99.64.92` | FLEET ? | User `eva`, discovered 2026-06-24 |\n| appie-mc-1 | Linux | ✅ Open | ❌ Key rejected | BROKEN_KEYS ? | Deploy pubkey to `root@100.107.179.3` |\n| harry (mac-mini-van-harry) | macOS | ✅ Open | ❌ Key rejected | BROKEN_KEYS ? | Add pubkey to macOS user's authorized_keys |\n| rabi (mac-mini-van-rabi) | macOS | ❌ Closed | N\u002FA | TAILNET_ONLINE ⚪ | Enable Remote Login in Sharing prefs |\n| techwiz-mbp | macOS | ❌ Closed | N\u002FA | TAILNET_ONLINE ⚪ | Enable Remote Login in Sharing prefs |\n| ipad-pro | iOS | N\u002FA | N\u002FA | TAILNET_ONLINE ⚪ | No SSH possible |\n| spark-atlas | Linux | ❌ Offline | N\u002FA | GHOSTS ? | Wait for node to come online |\n| artemis | macOS | ❌ Offline | N\u002FA | GHOSTS ? | Wait for node to come online |\n| mac-studio-luminaire | macOS | ❌ Offline | N\u002FA | GHOSTS ? | Wait for node to come online |\n| iphone181 | iOS | ❌ Offline | N\u002FA | GHOSTS ? | No SSH possible |\n| macbook-air-lorenzo | macOS | ❌ Offline | N\u002FA | GHOSTS ? | Wait for node to come online |\n| wolf-diddy | macOS | ❌ Offline | N\u002FA | GHOSTS ? | External peer, no access |\n\n**Key SSH failure patterns (2026-06-19 audit):**\n- **macOS with port 22 open**: SSH server running but `appie-3-hermes@tailnet` key not in any macOS user's `~\u002F.ssh\u002Fauthorized_keys`. Remedy: deploy the key to the actual macOS user.\n- **Linux with port closed**: SSH daemon not installed\u002Fstarted (`systemctl enable --now sshd` + `apt install openssh-server` if needed).\n- **Linux with `Connection refused` after initial `Permission denied`**: fail2ban likely blocked the source IP (eugi pattern).\n- **macOS with all ports closed**: Remote Login + Screen Sharing both disabled in System Sharing prefs.\n\nSee `references\u002Fssh-connectivity-diagnostics.md` for detailed error transcripts and step-by-step per-failure diagnosis.\n\n### Fleet Node Authorized Keys Audit\n\nCheck how many authorized keys exist per node and who they belong to:\n\n```bash\nfor host in \"root@100.118.143.10\" \"root@100.110.58.73\"; do\n  echo \"=== $host ===\"\n  ssh -o ConnectTimeout=5 -o BatchMode=yes -o StrictHostKeyChecking=no \\\n    -i \"$HOME\u002F.ssh\u002Fid_ed25519\" \"$host\" \\\n    \"cat \u002Froot\u002F.ssh\u002Fauthorized_keys | awk '{print \\$3}'\"\ndone\n```\n\n| Node | Keys | Identities |\n|------|------|------------|\n| appie-2 | 4 | appie@weblyfe-ocean, appie@weblyfe, seyed@Techwiz-MacBook-Pro-8, mc@appie-mc-1 |\n| eugi | 2 | appie@weblyfe, Appie-2@appie-brain |\n\nDocument any unexpected keys. The comment field (3rd column) identifies the key owner. Stale keys (old hostnames, decommissioned users) should be removed.\n\n### Fleet Node Deploy Keys\n\nFleet nodes may carry per-service deploy keys for CI\u002FCD:\n\n```bash\nssh \u003Chost> \"ls -la \u002Froot\u002F.ssh\u002F | grep -v authorized_keys | grep -v known_hosts\"\n```\n\nExample from appie-2:\n```\nprivanotify_admin_deploy     → PrivaNotify admin\nprivanotify_deploy           → PrivaNotify\nweblyfe_ai_deploy            → Weblyfe AI\nweblyfe_ai_deploy_new        → Weblyfe AI (new)\ngithub_do_appie              → GitHub Actions deploy\n```\n\nDocument the purpose of each key. Remove stale ones.\n\n### SSH Config Audit\n\n```bash\nssh \u003Chost> \"cat \u002Froot\u002F.ssh\u002Fconfig\"\n```\n\nCheck for:\n- `PasswordAuthentication no`\n- `PubkeyAuthentication yes`\n- No wildcard `Host *` patterns that expose sensitive hosts\n\nSSH config aliases can drift over time as Tailscale IPs change during reprovisioning. Periodically run `tailscale status` and update SSH config.\n\n### Hermes Agent Detection\n\n```bash\nssh \u003Chost> \"ps aux | grep -iE '(hermes|claude|python.*bot|node.*bot|discord|telegram)' | grep -v grep\"\n```\n\nThe process looks like:\n```\n\u002Fusr\u002Flocal\u002Flib\u002Fhermes-agent\u002Fvenv\u002Fbin\u002Fpython -m hermes_cli.main gateway run --replace\n```\n\nHermes proc count on a healthy node: 2-5 (gateway + workers). Count of 0-1 is a warning.\n\n### Appie-Brain Locations\n\n| Machine | Path |\n|---------|------|\n| appie-3-hermes (deze VPS) | `\u002Froot\u002Fclawd\u002Fappie-brain\u002F` |\n| appie-2 (Hetzner) | `\u002Froot\u002Fappie-brain\u002F` |\n| appie-1 (Mac Mini) | `~\u002Fclawd\u002Fappie-brain\u002F` |\n\n### Fleet Reality-Check (Periodic Inventory Refresh)\n\nFleet node status changes over time — offline nodes come back, new nodes join, nodes get decommissioned. All 4 arrays in the scan script drift from reality.\n\n**Run this check monthly** to verify the script's arrays match real Tailscale status:\n\n```bash\n# 1. Get actual Tailscale online state\ntailscale status | grep -v '^$' | awk '{print $1, $2, $(NF)}'\n\n# 2. Compare against script's FLEET array\ngrep -A20 '^FLEET=(' ~\u002Fclawd\u002Ftools\u002Fappie-3-daily-security-scan.sh\n\n# 3. Check BROKEN_KEYS — are they still online?\ngrep -A15 '^BROKEN_KEYS=(' ~\u002Fclawd\u002Ftools\u002Fappie-3-daily-security-scan.sh\n\n# 4. Check TAILNET_ONLINE — still no SSH?\ngrep -A10 '^TAILNET_ONLINE=(' ~\u002Fclawd\u002Ftools\u002Fappie-3-daily-security-scan.sh\n\n# 5. Check GHOSTS — any back online?\ngrep -A15 '^GHOSTS=(' ~\u002Fclawd\u002Ftools\u002Fappie-3-daily-security-scan.sh\n```\n\n**When to move a node between arrays**:\n- Ghost comes online → move to FLEET (with current SSH key and Tailscale IP)\n- Active node offline >30d → move to GHOSTS\n- Node decommissioned → remove from both arrays\n\n**2026-06-02 update**: `spark-atlas` and `mac-mini-van-eva` both returned online after 51+ days offline. Move from GHOSTS back to FLEET. Verify SSH keys still work before re-adding.\n\n### Fleet Status Categories\n\n15 tailnet nodes (2026-06-23) grouped into 4 arrays:\n\n#### FLEET — SSH-reachable (daily full health check)\n```bash\nFLEET=(       # dagelijks SSH health → ? (full data) \u002F ? (failed)\n    \"appie-2|root@100.118.143.10|$HOME\u002F.ssh\u002Fid_ed25519|Weblyfe VPS\"\n    \"eugi|root@100.110.58.73|$HOME\u002F.ssh\u002Fid_ed25519|Ubuntu VPS (FSN)\"\n    \"appie-1|appie@100.101.29.56|$HOME\u002F.ssh\u002Fid_ed25519|Mac Mini Weblyfe (macOS)\"\n    \"eva|eva@100.99.64.92|$HOME\u002F.ssh\u002Fid_ed25519|Mac Mini Naoufal (macOS)\"\n)\n```\n\n#### BROKEN_KEYS — online, port 22 open, key rejected\n```bash\nBROKEN_KEYS=( # daily nc port check only → ?\n    \"appie-mc-1|root@100.107.179.3|$HOME\u002F.ssh\u002Fid_ed25519|Mission Control v1 (Linux) — key rejected\"\n    \"harry|100.79.180.56|none|Mac Mini Harry (macOS) — key rejected\"\n)\n```\n\n#### TAILNET_ONLINE — online, no SSH daemon at all\n```bash\nTAILNET_ONLINE=( # tailnet status only → ⚪\n    \"rabi|100.67.184.25|macOS|Mac Mini Rabi — Remote Login off\"\n    \"techwiz-mbp|100.87.99.11|macOS|Techwiz MacBook Pro — Remote Login off\"\n    \"ipad-pro|100.105.56.2|iOS|iPad Pro — no SSH\"\n)\n```\n\n#### GHOSTS — offline >7d (logged but no active check)\n```bash\nGHOSTS=(      # archived → ?\n    \"spark-atlas|100.69.197.43|linux|DGX Spark — offline 9d\"\n    \"artemis|100.95.165.116|macOS|Artemis — offline 11d\"\n    \"mac-studio-luminaire|100.126.237.96|macOS|Studio Luminaire — offline 11d\"\n    \"iphone181|100.98.117.8|iOS|iPhone S3YED — offline 4d\"\n    \"macbook-air-lorenzo|100.112.169.28|macOS|Book Air Lorenzo — offline 74d\"\n    \"wolf-diddy|100.102.181.116|macOS|Wolf Diddy — offline 32d\"\n)\n```\n\n**Transition rules:**\n- Ghost comes online → move to BROKEN_KEYS or TAILNET_ONLINE (test SSH first)\n- BROKEN_KEYS node gets SSH key deployed → move to FLEET\n- Online node offline >7d → move to GHOSTS\n- Node decommissioned → remove from all arrays\n- iOS\u002FiPad nodes belong in TAILNET_ONLINE or GHOSTS — never in FLEET (no SSH)\n\nVoorkomt: valse ? elke dag, 5s SSH timeouts per ghost, ruis in CTO notes.\n\n**CRITICAL**: Maintener de arrays actief. Wanneer een ghost node terug online komt (check via `tailscale status`), verplaats hem direct terug naar BROKEN_KEYS of TAILNET_ONLINE. De SSH key en Tailscale IP kunnen veranderd zijn sinds de node offline ging.\n\nPeriodic refresh: zie \"Fleet Reality-Check\" sectie hierboven.\n\n### Fleet Health Report Template\n\n```markdown\n? Weblyfe Tailnet — [DATE]\n\n### ✅ Actieve Bots\nappie-1 | 100.101.29.56 | macOS | ✅\nappie-2 | 100.118.143.10 | Linux | ✅\n\n### ? Gearchiveerd\nspark-atlas — offline >30d\neva — offline >30d\n\n### ? Offline (overige nodes)\nmacbook-air-van-lorenzo — last seen 2026-04-10\n```\n\n### Quick Fleet Scan Pattern (Telegram \u002F on-demand)\n\nWhen Seyed asks for a quick fleet analysis, keep it fast and operational rather than running the full daily scan:\n\n1. **Local health first**: `hostname`, `date -Is`, `uptime`, `df -h \u002F`, `free -m`, Hermes gateway service status, failed SSH logins in 24h, pending apt update count.\n2. **Tailnet state via JSON**: parse `tailscale status --json`; include `Self` and `Peer` separately. Summarize online\u002Foffline, OS, Tailscale IP, and last-seen age.\n3. **Expected-offline context matters**: if Seyed says a device is physically offline\u002Fin suitcase, mark it `expected\u002Fno action`, not an incident. Still include last-seen time.\n4. **Reachability probes**: for online\u002Fcore nodes, run `tailscale ping` and quick TCP checks for `22,80,443,3000,5000,8000,8080,8443,5900`.\n5. **SSH auth check**: test key-based SSH separately from port reachability. Report `port 22 open but key rejected` as an access\u002Fremediation issue, not node downtime.\n6. **Service fingerprints**: for open HTTP(S) ports, use `curl -skI` and a short body\u002Ftitle probe. On macOS, `5000` often fingerprints as AirTunes and `5900` is Screen Sharing\u002FVNC, both tailnet-accessible rather than internet-facing.\n7. **Report concise risk classes**: `healthy`, `expected offline`, `access issue`, `tailnet-exposed service`, `ghost\u002Foffline >30d`. End with the next 1-3 recommended actions.\n\nAvoid over-escalating offline personal devices, iOS nodes, or user-declared travel\u002Fsuitcase devices. The security signal is unexpected offline core infrastructure, key rejection on nodes that should be manageable, public DNS\u002Fservice failure, or exposed services that should not be tailnet-wide.\n\n### Telegram Fleet Output — Grouped by Status Category\n\nThe daily scan Telegram output groups all fleet nodes by their connectivity status for at-a-glance readability. Implemented via `FLEET_CACHE` pipe-separated file and a `case` statement that tracks group transitions:\n\n```\n*Fleet*\n  SSH ✅\n    ? appie-2\n    ? eugi\n\n  SSH key rejected\n    ? appie-mc-1\n    ? appie-1\n    ? eva\n    ? harry\n\n  Online (geen SSH)\n    ⚪ rabi\n    ⚪ techwiz-mbp\n    ⚪ ipad-pro\n\n  Offline\n    ? spark-atlas\n    ? artemis\n    ...\n```\n\n**Implementation pattern** in the script's Telegram generation block:\n\n```bash\ncurrent_group=\"\"\nwhile IFS=\"|\" read -r name status desc; do\n    case \"$status\" in\n        \"?\") group=\"SSH ✅\" ;;\n        \"?\") group=\"SSH ❌\" ;;\n        \"?\") group=\"SSH key rejected\" ;;\n        \"⚪\") group=\"Online (geen SSH)\" ;;\n        \"?\") group=\"Offline\" ;;\n        *) group=\"\" ;;\n    esac\n    if [ \"$group\" != \"$current_group\" ] && [ -n \"$group\" ]; then\n        [ -n \"$current_group\" ] && tg_echo \"\"\n        tg_echo \"  $group\"\n        current_group=\"$group\"\n    fi\n    tg_echo \"    $status $name\"\ndone \u003C \"$FLEET_CACHE\"\n```\n\n**Key constraint**: ALL 4 array types (FLEET, BROKEN_KEYS, TAILNET_ONLINE, GHOSTS) must write to the same FLEET_CACHE in array order. The Telegram block reads once sequentially. This guarantees the Telegram output matches the report and no nodes are missed.\n\n**Cache format** (pipe-separated, no JSON):\n```\nappie-2|?|Weblyfe VPS (Hetzner)\neugi|?|Ubuntu VPS (FSN)\nappie-mc-1|?|Mission Control v1 — key rejected\nrabi|⚪|Mac Mini Rabi — Remote Login off\nspark-atlas|?|DGX Spark — offline 9d\n```\n\n## Watchdog Architecture (separate cron jobs, no_agent=True)\n\nThese run independently from the daily scan to catch problems early. Script-only mode: zero LLM tokens per tick, silent when healthy.\n\n| Watchdog | Schedule | Script | Trigger |\n|----------|----------|--------|---------|\n| Disk | Every 4h | `disk-watchdog.sh` | >80% ⚠️, >90% ? on any fleet node |\n| Tailscale | Every 30min | `tailscale-watchdog.sh` | Core node (appie-1, appie-2, eugi) goes offline |\n| SSH key audit | 1st of month | `ssh-key-audit.sh` | Monthly authorized_keys review per node |\n| Failed login trend | In daily scan | `failed-login-trend.sh` | Spike >5x yesterday or >10\u002Fday |\n| Agent framework CVEs (Python + Go) | Daily 06:30 UTC | `agent-framework-cve-scan.py` (via LLM cron job `c503abd02155`) | Any CVE reported in last 90d for 20 packages (17 Python agent + 3 Go infra). Uses `[SILENT]` when clean. |\n\nCron job setup:\n```bash\n# Scripts must be at ~\u002F.hermes\u002Fscripts\u002F (or the profile-specific scripts dir)\n# Symlinks may be blocked by the cron scheduler — use real files\ncronjob action=create name=\"disk-watchdog\" schedule=\"0 *\u002F4 * * *\" \\\n  no_agent=True script=\"disk-watchdog.sh\" deliver=\"telegram:1817919454\"\n```\n\n## Security Governance & Suggestion Pipeline\n\nA multi-agent governance pattern for human-in-the-loop security improvements. Appie-3 (CTO specialist) creates the suggestion plan, Appie-Opus (orchestrator) presents suggestions to Seyed, Seyed approves before execution.\n\n### When to Use\n\n- After the daily security scan finds issues that need remediation\n- User asks for \"daily security suggestions\", \"action plan for opus\", \"suggestions to present to seyed\"\n- Setting up a security governance workflow where changes require human approval\n- Any recurring task where the CTO recommends but the user decides\n\n### Architecture\n\n```\nAppie-3 (CTO)                Appie-Opus (orchestrator)    Seyed (human)\n      │                              │                        │\n      │  Creates plan ──────────────►│                        │\n      │  DAILY-SECURITY-             │                        │\n      │  SUGGESTIONS.md              │                        │\n      │                              │  Presents S001-S00X ──►│\n      │                              │  \"Wat, waarom,         │\n      │                              │   risico, revert\"      │\n      │                              │◄─────── ? \u002F ? ──────│\n      │                              │                        │\n      │  (Appie-3 only acts          │  Executes approved     │\n      │   when directly asked)       │  suggestions           │\n```\n\n### Suggestion Format\n\nEach suggestion MUST include four fields:\n\n| Field | Description |\n|-------|-------------|\n| **Wat** | What the check\u002Fchange is (1-2 zinnen) |\n| **Waarom** | Why it matters (1 zin) |\n| **Risico** | Risk level: Geen \u002F Laag \u002F Medium |\n| **Revert** | Exact command to undo the change |\n\n### Safety Rules (for Appie-Opus)\n\n1. **Read-only or reversible only** — no `rm -rf`, `chmod -R`, `iptables -F`\n2. **STOP on error** — report to Seyed, do not self-fix\n3. **No lockouts** — always test key-based login before disabling password auth\n4. **No service restarts** without explicit Seyed approval\n5. **Every suggestion has a revert step** — if missing, do not execute\n\n### Suggestion Count\n\nS001-S027 exist (expanded 2026-06-20 met S021-S027: agent framework CVE scan, Headroom install\u002Fverify\u002FMCP, SkillsGuard cloud API, CVE-2026-2256 check, MCP cutover check, SSH key deployment plan).\n\n### Daily Rotation\n\n27 suggestions exist (S001-S027), rotated by day:\n\n| Dag | Category | Sample Suggestions |\n|-----|----------|-------------------|\n| Maandag | Access audit | authorized_keys check (appie-2 + eugi), tailnet status, S027 (SSH key plan) |\n| Dinsdag | Config check | .env perms, open ports on fleet, S025 (CVE-2026-2256 check) |\n| Woensdag | Dependency scan | gitleaks, npm audit, S021 (agent framework CVE scan), S026 (MCP cutover) |\n| Donderdag | Web security | SSL certs, security headers, failed logins, S024 (SkillsGuard) |\n| Vrijdag | System health | disk, pending updates, S022-S023 (Headroom check\u002FMCP) |\n| Weekend | Fleet check | tailnet status, spark-atlas SSH, gateway uptime |\n\n### Plan Location\n\nCanonical plan: `~\u002Fclawd\u002Fappie-3-cto\u002FDAILY-SECURITY-SUGGESTIONS.md`\n\nZie `references\u002Fsecurity-suggestions.md` voor de volledige, actuele suggestielijst.\n\n## Backup Sync (optional, needs approval)\n\n`backup-sync.sh` — rsyncs appie-brain, Hermes config, SSH config, and secrets to appie-2.\nNot active by default. Script exists at `~\u002F.hermes-appie3\u002Fscripts\u002Fbackup-sync.sh`.\n\n## Cross-Platform Detection (macOS vs Linux)\n\nThe daily scan script may run on macOS (Mac Mini) or Linux (Hetzner VPS). Use an `uname` check at the top to branch OS-specific commands:\n\n```bash\nOS=\"$(uname -s)\"\ncase \"$OS\" in\n  Darwin) IS_MACOS=true; IS_LINUX=false ;;\n  Linux)  IS_MACOS=false; IS_LINUX=true  ;;\nesac\n```\n\n### Command Equivalents\n\n| macOS Command | Linux Alternative | When to Use |\n|---|---|---|\n| `vm_stat` | `free` or `\u002Fproc\u002Fmeminfo` | Memory check |\n| `sysctl -n vm.loadavg` | `cat \u002Fproc\u002Floadavg` | Load averages |\n| `log show --predicate ... --last 24h` | `journalctl --since \"24 hours ago\" \\| grep -c \"Failed password\"` | Failed login count |\n| `date -j -f \"%b %d %H:%M:%S %Y %Z\" \"$date\" +%s` | `date -d \"$date\" +%s` | Date parsing (SSL cert expiry) |\n| `date -v-1d +%Y-%m-%d` | `date -d \"yesterday\" +%Y-%m-%d` | Date arithmetic |\n| `\u002Fopt\u002Fhomebrew\u002Fbin\u002Fopenssl` | `\u002Fusr\u002Fbin\u002Fopenssl` | SSL cert check |\n| `pgrep -f \"hermes_cli\"` | `pgrep -f \"hermes gateway\"` | Hermes process detection |\n| `ping` | `ping` (exists on both, but macOS has stricter permissions) | Connectivity check |\n| `trash` | `rm -i` or `\u002Fusr\u002Fbin\u002Ftrash-cli` | Safe delete |\n\n### Branch Template\n\n```bash\nif [ \"$IS_MACOS\" = true ]; then\n    mem_active=$(vm_stat | grep 'pages active' | awk '{print $NF}' | tr -d '.')\n    mem_free=$(vm_stat | grep 'pages free' | awk '{print $NF}' | tr -d '.')\n    load=$(sysctl -n vm.loadavg | tr -d '{}')\n    failed_logins=$(log show --predicate 'eventMessage contains \"Failed to authenticate\"' --last 24h --style compact 2>\u002Fdev\u002Fnull | wc -l | tr -d ' ')\n    ossl=\"\u002Fopt\u002Fhomebrew\u002Fbin\u002Fopenssl\"\n    hermes_pat=\"hermes_cli\"\n    date_parse() { date -j -f \"%b %d %H:%M:%S %Y %Z\" \"$1\" +%s 2>\u002Fdev\u002Fnull; }\n    date_prev() { date -v-1d '+%Y-%m-%dT00:00:00.000' 2>\u002Fdev\u002Fnull; }\nelse\n    mem_active=$(awk '\u002FActive\u002F {print $2}' \u002Fproc\u002Fmeminfo 2>\u002Fdev\u002Fnull || echo 0)\n    mem_free=$(awk '\u002FMemAvailable\u002F {print $2}' \u002Fproc\u002Fmeminfo 2>\u002Fdev\u002Fnull || echo 0)\n    load=$(cat \u002Fproc\u002Floadavg | cut -d' ' -f1-3)\n    failed_logins=$(journalctl --since \"24 hours ago\" 2>\u002Fdev\u002Fnull | grep -c \"Failed password\" || echo 0)\n    ossl=\"\u002Fusr\u002Fbin\u002Fopenssl\"\n    hermes_pat=\"hermes gateway\"\n    date_parse() { date -d \"$1\" +%s 2>\u002Fdev\u002Fnull; }\n    date_prev() { date -d \"yesterday\" '+%Y-%m-%dT00:00:00.000' 2>\u002Fdev\u002Fnull; }\nfi\n```\n\n### Key Pitfall: Memory Calculation Mismatch\n\n`vm_stat` outputs **pages** (4096 bytes each on macOS ARM) while `\u002Fproc\u002Fmeminfo` outputs **kB** on Linux. The percentage calculation may differ. If you only need percentage, use platform-specific thresholds or normalise to MB first.\n\nOn Linux:\n```bash\nmem_total_kb=$(awk '\u002FMemTotal\u002F {print $2}' \u002Fproc\u002Fmeminfo)\nmem_active_kb=$(awk '\u002FActive\u002F {print $2}' \u002Fproc\u002Fmeminfo)\nmem_pct=$(( mem_active_kb * 100 \u002F mem_total_kb ))\n```\n\nOn macOS:\n```bash\npage_size=$(vm_stat | grep 'page size' | awk '{print $8}')\nmem_active=$(vm_stat | grep 'pages active' | awk '{print $NF}' | tr -d '.')\nmem_active_mb=$(( mem_active * page_size \u002F 1048576 ))\n```\n\n### Hermes Process Detection\n\nThe binary path varies between machines. Instead of matching a specific process name, detect Hermes generically:\n\n```bash\nhermes_count=$(pgrep -f \"$hermes_pat\" | wc -l | tr -d ' ')\n# Also try the canonical install path\nif [ \"$hermes_count\" -eq 0 ]; then\n    hermes_count=$(pgrep -af \"\u002Fusr\u002Flocal\u002Flib\u002Fhermes-agent\" | wc -l | tr -d ' ')\nfi\n```\n\n## macOS-Specific Scripting Quirks\n\nAll discovered through trial and error. Encode these in every script.\n\n### Bash 3.x — No Associative Arrays, `local` Only in Functions\n- macOS bash 3.x: `local -A` (associative arrays) fails silently\n- `local` keyword ONLY inside function bodies. Brace blocks `{ }` are NOT functions.\n- The Telegram generation block (brace group at script bottom) must NOT use `local`\n- Use indexed arrays with pipe-separated fields:\n```bash\nlocal fleet=(\n    \"appie-2|root@100.118.143.10|$HOME\u002F.ssh\u002Fid_ed25519\"\n)\nfor entry in \"${fleet[@]}\"; do\n    name=$(echo \"$entry\" | cut -d'|' -f1)\n    ssh_target=$(echo \"$entry\" | cut -d'|' -f2)\ndone\n```\n\n### vm_stat Parsing — Case-Sensitive grep Required (macOS only; irrelevant on Linux)\nmacOS vm_stat outputs uppercase field names:\n```\nPages free:                               96480.\nPages active:                            296328.\n```\n```bash\n# WRONG — awk \u002Fpages active\u002F doesn't match (case)\nmem_active=$(vm_stat | awk '\u002Fpages active\u002F {print $NF}')\n# RIGHT\nmem_active=$(vm_stat | grep 'pages active' | awk '{print $NF}' | tr -d '.')\n```\nThis applies to ALL vm_stat fields. The `-i` flag on grep works too.\n\n### LibreSSL vs OpenSSL (macOS only)\n`\u002Fusr\u002Fbin\u002Fopenssl` is LibreSSL 3.3.6 — silently fails on `x509 -noout -enddate`.\nAlways use brew: `\u002Fopt\u002Fhomebrew\u002Fbin\u002Fopenssl` (OpenSSL 3.x). On Linux `\u002Fusr\u002Fbin\u002Fopenssl` works fine.\n\n### No `2>\u002Fdev\u002Fnull` With openssl in Subshells\n```bash\n# DON'T: cert=$(openssl ... 2>\u002Fdev\u002Fnull)  ← kills cert output!\n# DO:    cert=$(openssl ... 2>&1)\n```\n\n### No `timeout` With openssl\n`timeout 5 openssl s_client` kills the process mid-TLS-handshake. Don't wrap openssl in timeout (it exits naturally after DONE).\n\n### No `ping` Binary (macOS only)\nUse `tailscale ping` instead. On Linux, `ping` is available.\n\n### No `\u002Fdev\u002Ftcp` (macOS only)\nBash's virtual filesystem `\u002Fdev\u002Ftcp` doesn't exist on macOS.\n\n### SSH Key Timeout for Relay Nodes\nNodes behind Tailscale DERP relays take 3-5s per SSH connection. Always use `ConnectTimeout=5`. `ConnectTimeout=3` gives false positives.\n\n### No SSH Private Keys on Linux VPS\nOn the Hetzner VPS where Appie-3 runs, `~\u002F.ssh\u002F` typically only has `authorized_keys` — no `id_*` private keys. Fleet SSH checks that rely on SSH keys will fail. Use the local machine as the SSH client (Mac Mini appie-1) or deploy keys to the VPS if fleet checks must run from there.\n\n## Client Site Reconnaissance & Deployment Inspection\n\nA recurring CTO task: user says \"check out [client site]\" and you need to identify the platform, find the deployment, and inspect the build.\n\n### 1. Platform Identification\n\nWhen visiting an unknown client site, determine what platform it's built on:\n\n| Signal | Platform | How to Check |\n|--------|----------|-------------|\n| Scripts from `cdn.prod.website-files.com` | **Webflow** | `document.querySelectorAll('script[src*=\\\"website-files\\\"]')` via browser_console |\n| `server: Netlify` in HTTP headers | **Netlify** | `curl -sI https:\u002F\u002Fexample.com \\| grep -i server` |\n| `X-NF-Request-Id` \u002F `Netlify Edge` in cache-status | **Netlify** | `curl -sI \\| grep -i 'x-nf\\|netlify'` |\n| `server: cloudflare` only | **Cloudflare proxy** (platform unknown) | `curl -sI \\| grep -i server` — need to dig deeper |\n| WordPress paths (`\u002Fwp-content\u002F`, `\u002Fwp-admin\u002F`) | **WordPress** | Check page source or paths |\n| `meta[name=\"generator\"]` content | Various | `document.querySelector('meta[name=\\\"generator\\\"]')?.content` |\n| Nameservers | Hosting provider | `dig example.com NS +short` |\n\n**Pattern**: always check multiple signals — a single header can be misleading (Cloudflare proxies many platforms).\n\n### 2. Codebase Search for Non-Resolving Subdomains\n\nWhen user gives a subdomain that doesn't resolve (DNS error), search the workspace:\n\n```bash\n# The domain is likely stored somewhere in project configs\nsearch_files(path=\"~\u002Fclawd\", pattern=\"booking.example*\", target=\"content\")\nsearch_files(path=\"~\u002Fclawd\u002Fprojects\", pattern=\"example*\", target=\"files\")\n```\n\nCommon hiding places in the Weblyfe workspace:\n- `projects\u002Fweblyfe-ai-standalone\u002Fscreenshot-tool.js` — `url` keys in the array\n- `projects\u002F*\u002Fnetlify.toml` — custom domain configs\n- `projects\u002F*\u002Ffleet-config.ts` — agent\u002Fclient domain inventory\n- `docs\u002Fopenclaw_clients*.csv` — client domain lists\n\n### 3. Netlify Deployment Inspection\n\nRequires: `NETLIFY_AUTH_TOKEN` in `~\u002F.weblyfe-secrets\u002F.env`.\n\n```bash\n# Source the token\nsource ~\u002F.weblyfe-secrets\u002F.env\n\n# List all sites and find the target\ncurl -s -H \"Authorization: Bearer $NETLIFY_AUTH_TOKEN\" \\\n  \"https:\u002F\u002Fapi.netlify.com\u002Fapi\u002Fv1\u002Fsites?page=1&per_page=100\" | \\\n  python3 -c \"import sys,json; [print(s['name'], s.get('custom_domain','')) for s in json.load(sys.stdin)]\"\n\n# Get site details — includes build_settings (cmd, dir, repo_url, repo_branch)\nSITE_ID=$(curl -s -H \"Authorization: Bearer $NETLIFY_AUTH_TOKEN\" \\\n  \"https:\u002F\u002Fapi.netlify.com\u002Fapi\u002Fv1\u002Fsites?page=1&per_page=100\" | \\\n  python3 -c \"import sys,json; [print(s['id']) for s in json.load(sys.stdin) if 'example' in s['name'].lower()]\")\n\n# Check deploys (last 5)\ncurl -s -H \"Authorization: Bearer $NETLIFY_AUTH_TOKEN\" \\\n  \"https:\u002F\u002Fapi.netlify.com\u002Fapi\u002Fv1\u002Fsites\u002F$SITE_ID\u002Fdeploys?page=1&per_page=5\"\n```\n\n**Key fields from deploy:**\n- `state`: `ready` \u002F `error` — build success\n- `created_at`: deploy timestamp\n- `deploy_time`: seconds\n- `commit_ref`: git commit SHA (first 10 chars for display)\n- `commit_url`: link to GitHub commit\n- `published`: `true` = live version (`None` = not published)\n- `error_message`: build failure reason\n\n**Key fields from build_settings** (in site detail):\n- `cmd`: build command (e.g. `npm run build`)\n- `dir`: publish directory (e.g. `dist`)\n- `repo_url`: linked GitHub repo\n- `repo_branch`: branch for auto-deploys\n- `provider`: git provider (`github`)\n- `allowed_branches`: which branches trigger deploys\n\n### 4. DNS & Nameserver Checks\n\n```bash\n# Check A record\ndig example.com A +short\n\n# Check nameservers (identify hosting provider)\ndig example.com NS +short\n\n# Check if subdomain exists\ndig sub.example.com A +short\n\n# Check HTTP headers (platform identification)\ncurl -sI https:\u002F\u002Fexample.com | grep -iE 'server|x-powered-by|x-served-by'\n```\n\n### 5. GitHub Repo Inspection (if token works)\n\nSource from `~\u002F.weblyfe-secrets\u002F.env` and use:\n```bash\ncurl -s -H \"Authorization: token $GITHUB_TOKEN\" \\\n  \"https:\u002F\u002Fapi.github.com\u002Frepos\u002FOWNER\u002FREPO\"\n```\n\nIf the token returns `401 Bad credentials`, note it and proceed without — the build settings from Netlify usually have enough info.\n\n### 6. Site Reconnaissance Results Template\n\nReport findings in a compact table for Telegram:\n\n```markdown\n**? Site:** `https:\u002F\u002Fexample.com` — description\n**Platform:** Webflow \u002F Netlify \u002F WordPress\n\n**Netlify:** naam | ✅ Live | laatst: datum (Xs)\n**Repo:** `owner\u002Frepo` (branch: main)\n**Build:** `npm run build` → `dist\u002F`\n\n**App details:**\n- Multi-step wizard: Step 1 → Step 2 → ...\n- Key features: feature list\n- Footer: credits, links\n```\n\n## Post-Scan Steps\n\nAfter the scan script finishes:\n\n### 0. Log to Mission Control\n\nLog task lifecycle to the fleet orchestrator dashboard:\n\n```bash\npython3 ~\u002Fclawd\u002Ftools\u002Fmc-log-task.py \"Daily security scan\" --agent Appie-3 --status done\n```\n\nZie `references\u002Fmission-control-integration.md` voor de standing directive, tool setup, en endpoint details.\n\n### 1. Update INDEX.md\nAppend one line to `~\u002Fclawd\u002Fappie-brain\u002Fknowledge\u002Fresearch\u002Fdaily-research\u002FINDEX.md`:\n```\n| YYYY-MM-DD | ?\u002F? Security Scan — key findings | [Report](.\u002FYYYY-MM-DD\u002Fsecurity-scan.md) |\n```\nUse `patch` to append after the last table row — never `write_file` (would overwrite index).\n\n### 2. Add CTO Action Items\nFor every ?\u002F⚠️ finding, append a `## CTO Action Items` section:\n```\n## CTO Action Items\n  ? **finding** — context\n  ├─ Check: command\n  └─ Priority: High\u002FMedium\u002FLow\n```\n\n### 3. Verify Report\nRead file at `~\u002Fclawd\u002Fappie-brain\u002Fknowledge\u002Fresearch\u002Fdaily-research\u002FYYYY-MM-DD\u002Fsecurity-scan.md` before delivering.\n\n## Timing\n\nv2 scan takes ~120-180s (down from 180-300s in v1):\n- SSH fleet: 5-15s\n- SSL certs: 10-15s (4 domains)\n- Gitleaks --no-git: 10-60s\n- Security headers: 10-20s (4 domains)\n- Pending updates: 5-10s (SSH)\n- CVE APIs: 5-15s\n- npm audit: 30-60s\n\n## Pitfalls\n\n### Pending Updates Scorecard Bug — SSH Fail Falsely Reports ✅ (FIXED 2026-06-12)\n\nThe `scan_updates()` function had a logic flaw: when SSH fails (`$updates = \"?\"`), the if-condition fell through to `else` which reported `\"✅ $name — up-to-date\"`. Fixed by adding an explicit `?` check that reports `\"? $name — unreachable\"` instead. See `references\u002Flinux-cross-platform-notes.md` for the cross-platform equivalents used during the port.\n\n**Old behavior**: SSH unreachable → falsely reported as \"up-to-date\"\n**Current behavior**: SSH unreachable → \"? $name — unreachable\"\n- **vm_stat awk bug**: `awk '\u002Fpages active\u002F'` returns empty on macOS. Always use `grep`.\n- **Gitleaks git mode**: 35,399 false positives from history. Always `--no-git` with `.gitleaks.toml`.\n### Cron Workdir Must Exist on the Host\n\nEach cron job can have a `workdir` that Hermes `cd`s into before running the script. If the workdir path doesn't exist on the host (e.g. macOS path `\u002FUsers\u002Fappie\u002Fclawd` on a Linux VPS), the job may fail silently or produce no delivery.\n\n**Best practice**: either omit `workdir` (uses default), or set it to an absolute path that exists on the current host. Check with `ls -d \u002Fpath\u002Fto\u002Fworkdir` before scheduling.\n\n### `no_agent` Script Location\n\nScripts must be at `~\u002F.hermes\u002Fscripts\u002F\u003Cname>` (or the active profile's scripts directory). Hermes resolves no_agent script names from this directory — do not include a path prefix in the cron `script` field, just the filename.\n- **FLEET_CACHE format**: Use pipe-separated, not JSON. JSON escaping of emoji statuses (??) and descriptions with parentheses causes parse failures.\n- **`[]` in fleet cache**: Initialize with `: > \"$FLEET_CACHE\"` (empty file), not `echo \"[]\" > \"$FLEET_CACHE\"`. The Telegram section reads all lines and `[]` appears as garbage output.\n- **Security headers via curl**: Cloudflare\u002Fredirect chains may show intermediate headers. Use `-L` or check the final URL separately.\n- **Pending updates security count**: Use `grep -i security` not `-security` — the dash-prefix format varies by Ubuntu version.\n\n### v1 → v2 What Changed\n- **Telegram\u002Freport divergence**: FIXED. v1 had separate SSH loops for report and Telegram with different ConnectTimeout values. v2 uses shared FLEET_CACHE.\n- **CVE feed**: NVD (rate-limited) → GitHub Advisory API (no auth) + OSV.dev (no auth).\n- **Ghost nodes**: spark-atlas, eva removed from active scan → \"Archived Nodes\" section.\n- **Duplicate macOS quirks**: Removed from bottom of SKILL.md. Now only in the macOS section.\n- **Watchdogs**: Not part of daily scan. Separate cron jobs with no_agent=True.\n\n### v4 — New (2026-06-23)\n- **4-category fleet model**: Added TAILNET_ONLINE array for online nodes without SSH (iOS, Remote Login off). BROKEN_KEYS refactored for port-22-open\u002Fkey-rejected nodes. GHOSTS expanded to ALL offline nodes, not just >30d.\n- **Comprehensive fleet coverage**: Scan now covers all 15 tailnet nodes instead of just 2-3 reachable ones. Telegram output groups by status category.\n- **Grouped Telegram output**: New `case`-based group-tracking pattern for organized fleet display. All 4 array types write to shared FLEET_CACHE.\n- **Fleet SSH Access Map**: Updated from 7 to 15 nodes with category column.\n- **Fleet Reality-Check**: Expanded from 2 arrays to all 4.\n\n## Docker Web Service Hardening\n\nA recurring CTO task: a client-facing web service (often n8n, but the pattern applies to any Docker-based service) that's exposed to the internet via reverse proxy. This section captures the systematic hardening sequence, applied during the 2026-06-15 n8n-weblyfe upgrade.\n\n### Hardening Sequence (ordered by risk)\n\n| Step | Action | Risk if skipped | Revert |\n|------|--------|-----------------|--------|\n| 1 | **Pin Docker images** — never `latest` tag. Use exact semver (e.g. `n8n:2.26.3`, `caddy:2`) | Unpredictable updates break workflows | `docker compose up -d` with old tag |\n| 2 | **Bind internal ports to 127.0.0.1 only** — `127.0.0.1:5678:5678` instead of `5678:5678`. The reverse proxy (Caddy) reaches it via the Docker network, not host interface | Direct HTTP access bypasses TLS\u002FHTTPS | Revert port mapping in compose |\n| 3 | **Persist encryption keys in .env** — extract from container config (e.g. n8n's `\u002Fhome\u002Fnode\u002F.n8n\u002Fconfig` encryptionKey), add to `.env`, reference in compose as `N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}` | On volume rebuild, all encrypted credentials become unrecoverable | Remove env var, config falls back to auto-generated key |\n| 4 | **UFW firewall** — `deny incoming`, allow only 22, 80, 443. Docker's DOCKER-USER chain runs before UFW, so container-networking (Caddy→n8n) stays intact | Exposed SSH + direct service ports | `ufw disable` |\n| 5 | **Fail2ban for SSH** — `maxretry=3`, `bantime=86400` on sshd jail. Pre-installed on many Ubuntu images but often not enabled | Unlimited brute-force attempts | `fail2ban-client stop sshd` |\n| 6 | **SSH key-only** — `PermitRootLogin prohibit-password`, `PasswordAuthentication no`. Verify with `sshd -t && systemctl reload ssh` before disconnecting. **Exception:** Digital Ocean web console requires password login — set `PermitRootLogin yes` + `PasswordAuthentication yes` if DO console access is needed | Password-based attacks | Revert sshd_config changes |\n| 7 | **System updates + reboot** — `apt update && DEBIAN_FRONTEND=noninteractive apt upgrade -y` then reboot for kernel. **Use `systemctl reboot`** — `reboot`\u002F`shutdown -r now` may be blocked by agent security. May leave SSH session in background during long upgrades | Unpatched kernel + CVE-exploitable packages | Rollback via apt snapshots (rarely needed) |\n| 8 | **Clean up old Docker images** — `docker image prune -f`, remove old tags (`docker rmi \u003Cold-tag>`). Reclaim 2-4GB on small droplets | Disk fills up, service degrades | Images can be re-pulled by tag |\n\n### Docker Compose Pitfalls (n8n-specific, but apply generally)\n\n**Docker Compose v2:** Remove the `version:` top-level key. Compose v2 emits `version must be a string` validation errors and ignores it entirely. Use raw services block.\n\n**`.env` variable expansion:** Docker Compose auto-loads `.env` from the compose project directory. But when `docker compose config` shows unresolved paths (e.g. `${DATA_FOLDER}\u002Fx`), switch to **absolute paths** in the compose file to guarantee reliability regardless of env loading order.\n\n**Image registry divergence:** The n8n 1-Click Droplet had two n8n images — `n8nio\u002Fn8n:latest` (Docker Hub) and `docker.n8n.io\u002Fn8nio\u002Fn8n:latest` (official n8n registry). Only one is used by the compose file; the other is orphaned waste. After pinning a specific version, clean up the orphan with `docker rmi`.\n\n**n8n deprecation handling:** After upgrade, check container logs (`docker logs \u003Ccontainer> --tail 20`). Common deprecations to action:\n- `N8N_RUNNERS_ENABLED` → Remove from environment; no longer needed (task runners auto-register)\n- `storage directory rename` → Set `N8N_MIGRATE_FS_STORAGE_PATH=true` to migrate binaryData→storage for n8n v3\n- `pdf-lib not installed` in task runner → Install via Dockerfile or remove from NODE_FUNCTION_ALLOW_EXTERNAL if not used\n\n### n8n-Specific Hardening (see reference)\n\nSee `references\u002Fn8n-droplet-hardening.md` for the full session transcript including version gap (2.13.2 → 2.26.3 = 12+ minor versions), n8n config structure, and the exact docker-compose.yml changes applied.\n\n### Original v1 Pitfalls (still relevant)\n- SSH timeout consistency: all sections must use same ConnectTimeout.\n- Hermes agent count >1 is normal (gateway + workers).\n- macOS load includes disk I\u002FO, expect slightly higher readings vs Linux.\n\n## Reference Files\n### Seyed Communication Pattern — Short Blocker Lists\n\nSeyed responds best to **executive blocker summaries** — not detailed reports. When reporting fleet security status:\n\n- Lead with a **3-6 item checklist** of blockers (? = blocks me, ? = needs his input, ✅ = already working)\n- Each blocker: 1 line description + 1 line remedy\n- End with what's already running without his help\n- Example pattern from 2026-06-20: \"? Blocker 1 — eugi SSH\" → Seyed forwarded the key within minutes\n- Do NOT bury the blocker in prose. Use a compact table or bullet list with urgency emoji\n\nThis pattern is preferred over full scan reports for daily\u002Fstandup comms. Save the full report for when he asks \"run the scan\" or for cron deliveries.\n\n## Reference Files\n\n- `references\u002Fdaily-security-scan-script.md` — annotated v2 script reference (output structure, key implementation details, normal ranges)\n- `references\u002Fmission-control-integration.md` — Mission Control task-logging setup, standing directive, fleet config reference\n- `references\u002Ffleet-snapshot-v2.md` — fleet state after 2026-06-02 update (spark-atlas\u002Feva back online, current node inventory)\n- `references\u002Ffleet-inventory.md` — SSH key inventory, active\u002Fghost node map, latency, and per-machine notes\n- `references\u002Fsecurity-suggestions.md` — daily security suggestion pipeline (S001-S020) voor multi-agent governance, dagrotatie, en veilige\u002Freversible acties\n- `references\u002Fcron-log-self-audit.md` — systematic procedure for auditing cron job health, log anomalies, and script config drift against real Tailscale state\n- `references\u002Fssh-key-deployment.md` — batch deploy Appie-3's SSH public key to the fleet: deploy script template, idempotent key check, non-Tailscale server pattern (public IP \u002F Digital Ocean), post-deployment verification\n- `references\u002Ftailscale-device-cleanup.md` — identify and remove stale\u002Fduplicate Tailscale devices via dashboard\u002FAdmin API, including StableID verification and post-key-deploy SSH probes\n- `references\u002Fnew-host-init.md` — procedure for initializing the CTO agent on a fresh host: cron validation, platform-specific patching, tool installation, pending-items documentation\n- `references\u002Fnew-host-init.md` — procedure for initializing the CTO agent on a fresh host: cron validation, platform-specific patching, tool installation, pending-items documentation\n- `references\u002Fmac-mini-coding-harness-recovery.md` — recover access to an online macOS Mini \u002F coding harness over Tailscale when SSH is listening but Appie-3's key is not authorized.\n- `references\u002Fnew-host-init.md` — procedure for initializing the CTO agent on a fresh host: cron validation, platform-specific patching, tool installation, pending-items documentation\n\n## Scripts (in `~\u002F.hermes\u002Fscripts\u002F`, or profile-specific scripts dir)\n\n- `disk-watchdog.sh` — disk threshold check, silent when healthy\n- `tailscale-watchdog.sh` — core node connectivity, silent when healthy\n- `ssh-key-audit.sh` — monthly authorized_keys review per fleet node\n- `failed-login-trend.sh` — CSV-based daily count with spike detection\n- `backup-sync.sh` — rsync to appie-2 (optional, needs approval)\n- `file-integrity-check.sh` — sha256 baseline for critical system files\n- `appie-3-daily-security-scan.sh` — daily security scan (covers 9 layers)===ME:security-scanning",{"name":5,"title":43,"trigger":44,"description":7},"Daily Security Scanning & Fleet Health Automation (v2)","User asks for security scan, daily briefing, fleet health check, fleet exploration, tailnet reconnaissance, 'scan the fleet', 'check certificates', 'build a security cron job', 'daily security suggestions', 'governance pattern', 'secure all client bots', 'can you access all bots', 'check bot health', 'check client bots', 'youtube deeds', 'explore tailnet', 'inventory fleet', 'improve security scripts', 'daily research', or any request to automate security monitoring, discover fleet topology, or continuously harden the fleet based on research.","master","8ec37df6d71fb664ea19d32c079e7d3ff931a8e0","skills\u002Fmisc\u002Fsecurity-scanning",3,"https:\u002F\u002Fgithub.com\u002FS3YED\u002Fappie-kit","https:\u002F\u002Fweblyfe.ai","https:\u002F\u002Fgithub.com\u002FS3YED","2026-08-27 01:54:02",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add S3YED\u002Fappie-kit --skill security-scanning",{"tool":59,"command":60},"bunx","bunx skills add S3YED\u002Fappie-kit --skill security-scanning",{"tool":62,"command":63},"pnpm","pnpm dlx skills add S3YED\u002Fappie-kit --skill security-scanning","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FS3YED\u002Fappie-kit\u002Fblob\u002Fmaster\u002Fskills\u002Fmisc\u002Fsecurity-scanning\u002FSKILL.md",true,[],[68,93,119,143,169,192],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":38},"01M6JFD4M6N4DSGC7TXEJ5R3J2","ai-music","AI music generation and audio tools: HeartMuLa lyrics-to-music generation, songwriting craft (+ Suno prompts), and audio spectrogram\u002Ffeature visualization.","https:\u002F\u002Fgithub.com\u002FS3YED\u002Fappie-kit\u002Fblob\u002Fmaster\u002Fskills\u002Fwethlete\u002Fai-music\u002FSKILL.md",[],[75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92],"music","ai music","humanizer","visualization","Tools","Audio","hermes","hermes agent","songwriting","suno","lyrics","prompts","heartmula","craft","generation","feature","ai music generation","music generation",{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":38},"01M6JFCZE4XNFQFMNZDHKHT5V5","agentic-webdesign-design-system-ingestion","Use v0 Design Systems 2.0, Bolt Design System Agents, or Lovable to generate production UI from a client's real design system components — not generic Tailwind. Use when building a client website where brand consistency matters.","https:\u002F\u002Fgithub.com\u002FS3YED\u002Fappie-kit\u002Fblob\u002Fmaster\u002Fskills\u002Fweb-design\u002Fagentic-webdesign-design-system-ingestion\u002FSKILL.md",[],[29,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118],"agentic","design system","system","ingestion","webdesign","agentic webdesign design system ingestion","components","generate","design systems","website","ui","Tailwind","bolt","lovable","v0","design-system","wed","design system components","appie",{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":38},"01M6JFCVPX3913CFAS6QQJ33ZB","agentic-webdesign-agent-elements","Use 21st.dev Agent Elements — 25 shadcn\u002Fui components purpose-built for AI agent UIs. Tool cards (Bash, Edit, Search, Plan, Subagent, MCP), chat, input, streaming. Open source, shadcn-registry install, no runtime lock-in.","https:\u002F\u002Fgithub.com\u002FS3YED\u002Fappie-kit\u002Fblob\u002Fmaster\u002Fskills\u002Fweb-design\u002Fagentic-webdesign-agent-elements\u002FSKILL.md",[],[100,126,104,127,128,129,106,130,131,132,133,134,135,136,137,138,139,140,141,142],"elements","agentic webdesign agent elements","MCP","ai agent","registry","search","streaming","open source","open","Bash","plan","subagent","edit","install","input","lock","source",{"skillNo":144,"name":145,"nameZh":6,"description":146,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":147,"categories":148,"keywords":149,"publishedAt":38},"01M6JFCQC7H65M9QJ6TRE71BS1","vercel-deployment","Deploy static sites and frontends to Vercel — handles both CLI and REST API paths, including the CLI token sanitization workaround.","https:\u002F\u002Fgithub.com\u002FS3YED\u002Fappie-kit\u002Fblob\u002Fmaster\u002Fskills\u002Fsoftware-development\u002Fvercel-deployment\u002FSKILL.md",[],[150,151,152,37,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168],"deployment","vercel deployment","vercel","cli","linux","windows","deploy","vercel deploy","REST","api","site","deploy to vercel","token","rest api","host","sites","paths","sanitization","static site",{"skillNo":170,"name":171,"nameZh":6,"description":172,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":173,"categories":174,"keywords":175,"publishedAt":38},"01M6JFCM4SMTXBM5A01BK2YQG1","software-quality-workflows","Umbrella workflow for TDD, debugging, code simplification, spikes, pre-commit review, and debugger-assisted investigation.","https:\u002F\u002Fgithub.com\u002FS3YED\u002Fappie-kit\u002Fblob\u002Fmaster\u002Fskills\u002Fsoftware-development\u002Fsoftware-quality-workflows\u002FSKILL.md",[],[176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,22],"workflows","quality","software","software quality workflows","review","tdd","workflow","commit","debugging","code","debugger","pre-commit","investigation","code simplification","user","simplification",{"skillNo":193,"name":194,"nameZh":6,"description":195,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":196,"categories":197,"keywords":198,"publishedAt":38},"01M6JFCGD0M6CEATY01W7YN6DB","react-component-refactoring","Safely refactor large React components into smaller, maintainable pieces using proven patterns","https:\u002F\u002Fgithub.com\u002FS3YED\u002Fappie-kit\u002Fblob\u002Fmaster\u002Fskills\u002Fsoftware-development\u002Freact-component-refactoring\u002FSKILL.md",[],[199,200,201,202,203,204,205,206,37,207,208,106,209,155,210,185,211,212,213,214],"react","component","refactoring","component refactoring","react component","react component refactoring","frontend","writing","safe","typescript","react components","modular","refactor","simplify","patterns","test-driven-development"]