smoke-test
Post-restart smoke tests + auto-fix for gbrain and OpenClaw environments. Tests critical services, auto-fixes known issues, extensible via user-defined test scripts in ~/.gbrain/smoke-tests.d/*.sh.
- License 许可
- MIT
- 最近更新
- 2026-04-26
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- smoke-test
- tools
- [ "exec", "read" ]
- version
- 1.0.0
- mutating
- true
- triggers
- [ "smoke test", "run smoke tests", "container restart check", "health check", "did the restart break anything", "did the container restart break anything" ]
- description
- Post-restart smoke tests + auto-fix for gbrain and OpenClaw environments. Tests critical services, auto-fixes known issues, extensible via user-defined test scripts in ~/.gbrain/smoke-tests.d/*.sh.
03 SKILL.md 正文
<!-- QMD-adapted: QMD uses QMD+SQLite instead of PGLite/Postgres. GBRAIN_DATABASE_URL and Minions worker references retained as informational context. OpenClaw-specific tests may not apply. -->
Smoke Test Skillpack
Run
gbrain smoke-testorbash scripts/smoke-test.shafter any container restart.
Contract
This skill guarantees:
- 8 core tests verify gbrain + OpenClaw health after restart
- Known failures are auto-fixed before reporting
- User-extensible via
~/.gbrain/smoke-tests.d/*.shdrop-in scripts - Results logged to
/tmp/gbrain-smoke-test.log - Exit code = number of unfixed failures (0 = all pass)
Built-in Tests
| # | Test | Auto-Fix |
|---|---|---|
| 1 | Bun runtime | Install from bun.sh |
| 2 | GBrain CLI loads | Reinstall deps |
| 3 | GBrain database (doctor) | — |
| 4 | GBrain worker process | Start worker |
| 5 | OpenClaw Codex plugin (Zod CJS) | npm install zod@4 --force |
| 6 | OpenClaw gateway | — (may not be started yet) |
| 7 | Embedding API key | — (check .env) |
| 8 | Brain repo exists | — |
Usage
CLI
gbrain smoke-test
Direct
bash scripts/smoke-test.sh
From OpenClaw bootstrap
Add to your ensure-services.sh or equivalent:
bash /path/to/gbrain/scripts/smoke-test.sh >> /tmp/bootstrap.log 2>&1
From an agent
exec: bash /data/gbrain/scripts/smoke-test.sh
Adding Custom Tests
Create executable scripts in ~/.gbrain/smoke-tests.d/:
# ~/.gbrain/smoke-tests.d/check-redis.sh
#!/bin/bash
redis-cli ping | grep -q PONG
Rules:
- Exit 0 = pass, non-zero = fail
- Filename becomes the test name (e.g.
check-redisfromcheck-redis.sh) - Keep tests fast (< 10s each)
- Tests run in alphabetical order
Adding Built-in Tests
Edit scripts/smoke-test.sh. Follow this pattern:
# ── N. [Service Name] ──────────────────────────────────────
if [test condition]; then
pass "[Service Name]"
else
# Auto-fix attempt
[fix command]
if [re-test condition]; then
fixed "[What was fixed]"
pass "[Service Name] (after fix)"
else
fail "[Service Name] — [error detail]"
fi
fi
Design rules:
- Test first — never fix without confirming broken
- Re-test after fix — verify the fix worked
- Timeout everything —
timeout Non any command that could hang - Use helpers —
pass(),fail(),fixed(),skip() - Idempotent fixes — safe to run repeatedly
- Skip gracefully —
skip()when a prerequisite is missing, don't fail
Environment Variables
| Var | Default | Description |
|---|---|---|
GBRAIN_SMOKE_LOG |
/tmp/gbrain-smoke-test.log |
Log file path |
GBRAIN_DIR_OVERRIDE |
(auto-detect) | Force gbrain install path |
GBRAIN_DATABASE_URL |
(from .env) | Database connection URL |
OPENCLAW_GATEWAY_PORT |
18789 |
Gateway port to test |
GBRAIN_BRAIN_PATH |
/data/brain |
Brain repo path |
Known Issues & Their Auto-Fixes
Codex Zod core.cjs Missing (discovered 2026-04-23)
- Symptom:
Cannot find module './core.cjs'→ all Codex ACP sessions fail - Cause: Zod v4 npm package ships without
core.cjsin some installs - Auto-fix:
npm install zod@4 --forcein the codex extension's zod dir - Persistence: Does NOT survive container restart (gateway reinstalls deps)
- This is why smoke tests must run on every restart
GBrain Worker Auth Failure
- Symptom: Worker can't connect to DB
- Cause:
GBRAIN_DATABASE_URLnot propagated to worker subprocess - Auto-fix: Script explicitly passes both
DATABASE_URLandGBRAIN_DATABASE_URL
Anti-Patterns
- ❌ Running smoke tests on every chat turn. Once per container restart (or on user request) is plenty. The script is cheap but it's not free.
- ❌ Writing a user drop-in without
timeout Naround any command that could hang. A single hung drop-in stalls every subsequent run. - ❌ Auto-fixing without confirming the check is actually broken first.
The
pass → fail-detected → fix → re-testloop is the contract; fixes that skip the re-test can report success on a still-broken state. - ❌ Treating
skipasfail. Missing prerequisites (no OpenClaw installed, no brain repo configured) are skips, not failures. Exit code = count of real failures, not skipped checks. - ❌ Hardcoding paths in a user drop-in. Read env vars
(
GBRAIN_DATABASE_URL,HOME, etc.) so the script travels across container rebuilds.
Output Format
The script writes a one-line status per check to stdout (✅/❌/?/⏭️) plus a
final summary line: Results: N/M passed, F auto-fixed, S skipped. A
structured timestamped log appends to $GBRAIN_SMOKE_LOG
(default /tmp/gbrain-smoke-test.log) for post-run forensics. Exit code
equals the count of unfixed failures (0 = all pass, positive integer =
count of remaining failures).
04 同仓库更多 Skills
webhook-transforms
Generic framework for converting external events (SMS, meetings, social mentions) into brain-ingestible signals. Define a transform function, register a webhook URL, and incoming events get processed through the brain pipeline.
testing
Skill validation framework. Validates every skill has SKILL.md with frontmatter, every reference exists, every env var is declared. The testing contract for the skill system itself.
soul-audit
6-phase interactive interview that generates the agent's identity (SOUL.md), user profile (USER.md), access control (ACCESS_POLICY.md), and operational cadence (HEARTBEAT.md). Re-runnable anytime to update any section.
skillpack-check
Run `gbrain skillpack-check` to produce an agent-readable JSON health report for the gbrain install. Wraps `gbrain doctor` + `gbrain apply-migrations --list` so a host agent (your OpenClaw's morning-briefing, any OpenClaw cron) can see at a glance whether the skillpack needs attention. Use when the user asks "is gbrain healthy?", when a cron fires a morning check, or proactively when something seems off (jobs not running, brain not updating, autopilot silent).
skillify
The meta skill. Turn any raw feature or script into a properly-skilled, tested, resolvable, evaled unit of agent-visible capability. Use when the user says "skillify this", "is this a skill?", "make this proper", or after a new feature is built without the full skill infrastructure. Paired with `gbrain check-resolvable`, skillify gives a user-controllable equivalent of Hermes' auto-skill-creation: you build, skillify checks the checklist, check-resolvable verifies nothing is orphaned. The human keeps judgment; the tooling keeps the checklist honest.
skill-creator
Create new skills following the GBrain conformance standard. Generates SKILL.md with frontmatter, Contract, Phases, Output Format, and Anti-Patterns. Checks MECE against existing skills. Updates manifest and resolver.