Files
ruflo/plugins/ruflo-browser/scripts/smoke.sh
T
ReuvenandRuFlo b5b6fb3fbe feat(ruflo-browser): v0.2.0 session-as-skill architecture + ADR-0001
Refactors ruflo-browser around recordable, replayable RVF cognitive
containers. Implements ADR-0001 (Proposed). Pre-Accept gate is a 10-site
replay-fidelity spike (≥80% pass) — harness shipped, run pending.

Plugin (plugins/ruflo-browser/):
- bump 0.1.0 → 0.2.0; new keywords (rvf, replay, trajectory, agentdb, aidefence)
- ADR-0001: session-as-skill architecture, 4 AgentDB namespaces, 3 AIDefence
  gates, 7 verb dispatcher, 5 new MCP lifecycle tools, 7+1 skill catalog,
  load-bearing replay-fidelity assumption flagged in Verification §4
- agent: rewritten with session contract, RVF allocation, ruvector
  trajectory-begin/step/end hooks, 4 namespaced AgentDB writes, 3
  mandatory AIDefence gates
- /ruflo-browser command: verb dispatcher (ls/show/replay/export/fork/purge/doctor)
- 7 new skills: browser-record (primitive), browser-replay, browser-extract,
  browser-login, browser-form-fill, browser-screenshot-diff, browser-auth-flow
- browser-test kept; rewritten to compose record+replay
- browser-scrape becomes a deprecation shim (removed in v0.3.0)
- scripts/smoke.sh: 13 structural checks; scripts/replay-spike.sh + SITES.txt:
  10-site interactive harness writing STATUS.md per run

CLI (v3/@claude-flow/cli/):
- src/mcp-tools/browser-session-tools.ts: 5 new lifecycle tools
  (browser_session_record / _end / _replay / browser_template_apply /
  browser_cookie_use). Each shells out to pinned ruvector@0.2.25 + the
  existing agent-browser CLI + bridged claude-flow memory; missing deps
  degrade with structured success:false rather than crash.
- src/mcp-client.ts: registers browserSessionTools alongside existing
  browserTools.
- TypeScript clean (npx tsc --noEmit reports zero errors against the
  new files).

Borrows from Browserbase skills/skill repo (verified 2026-05-04):
trace-as-firehose with per-page bisection (browser-trace/SKILL.md);
outer/inner self-improving loop (autobrowse/SKILL.md); sessions+contexts
as separately addressable artifacts (browser/REFERENCE.md + cookie-sync).
Adapted to use Ruflo's substrates (RVF, ruvector, AgentDB, AIDefence,
federation) rather than Browserbase's hosted backend.

Verification:
- bash plugins/ruflo-browser/scripts/smoke.sh → 13 passed, 0 failed.
- replay spike runnable via scripts/replay-spike.sh (network-dependent;
  not part of the smoke contract). ADR remains Proposed until ≥80% pass
  recorded under spike-results/<timestamp>/STATUS.md.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-04 16:47:37 -04:00

144 lines
5.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Structural smoke test for ruflo-browser plugin v0.2.0.
# Verifies the file inventory, frontmatter, ADR cross-references, and
# AgentDB-namespace coverage that ADR-0001 contracts. Does NOT exercise
# the live MCP browser tools — the full Verification §1-§7 contract
# requires the planned browser_session_* tools and the replay spike,
# both pending.
set -u
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
PASS=0
FAIL=0
step() { printf "→ %s ... " "$1"; }
ok() { printf "PASS\n"; PASS=$((PASS+1)); }
bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }
# 1. plugin.json version + keywords
step "plugin.json declares version 0.2.0 with new keywords"
v=$(grep -E '"version"[[:space:]]*:' "$ROOT/.claude-plugin/plugin.json" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
if [[ "$v" != "0.2.0" ]]; then
bad "expected 0.2.0, got '$v'"
else
missing=""
for kw in rvf replay trajectory agentdb aidefence; do
grep -q "\"$kw\"" "$ROOT/.claude-plugin/plugin.json" || missing="$missing $kw"
done
[[ -z "$missing" ]] && ok || bad "missing keywords:$missing"
fi
# 2. All 8 skills present
step "all 8 skills (browser-record/replay/extract/login/form-fill/screenshot-diff/auth-flow/test) exist"
missing=""
for s in browser-record browser-replay browser-extract browser-login browser-form-fill browser-screenshot-diff browser-auth-flow browser-test; do
[[ -f "$ROOT/skills/$s/SKILL.md" ]] || missing="$missing $s"
done
[[ -z "$missing" ]] && ok || bad "missing:$missing"
# 3. Each skill has valid YAML frontmatter (name + description + allowed-tools)
step "every skill has name/description/allowed-tools frontmatter"
bad_skills=""
for f in "$ROOT"/skills/*/SKILL.md; do
for k in "name:" "description:" "allowed-tools:"; do
grep -q "^$k" "$f" || bad_skills="$bad_skills $(basename $(dirname "$f"))(missing-$k)"
done
done
[[ -z "$bad_skills" ]] && ok || bad "$bad_skills"
# 4. browser-scrape is a deprecation shim (must mention "deprecated")
step "browser-scrape is a deprecation shim pointing at browser-extract"
if grep -qi "deprecated" "$ROOT/skills/browser-scrape/SKILL.md" \
&& grep -q "browser-extract" "$ROOT/skills/browser-scrape/SKILL.md"; then
ok
else
bad "shim does not flag deprecation or does not reference browser-extract"
fi
# 5. Verb-dispatcher command covers all 7 verbs
step "/ruflo-browser command covers ls/show/replay/export/fork/purge/doctor"
missing=""
for v in 'ls' 'show' 'replay' 'export' 'fork' 'purge' 'doctor'; do
grep -qE "\\*\\*$v\b" "$ROOT/commands/ruflo-browser.md" || missing="$missing $v"
done
[[ -z "$missing" ]] && ok || bad "missing verbs:$missing"
# 6. Agent references the 4 AgentDB namespaces
step "browser-agent references all 4 AgentDB namespaces"
missing=""
for n in browser-sessions browser-selectors browser-templates browser-cookies; do
grep -q "$n" "$ROOT/agents/browser-agent.md" || missing="$missing $n"
done
[[ -z "$missing" ]] && ok || bad "missing namespaces:$missing"
# 7. Agent enforces the 3 AIDefence gates
step "browser-agent declares the 3 AIDefence gates"
missing=""
for g in aidefence_has_pii aidefence_scan aidefence_is_safe; do
grep -q "$g" "$ROOT/agents/browser-agent.md" || missing="$missing $g"
done
[[ -z "$missing" ]] && ok || bad "missing gate refs:$missing"
# 8. Agent uses ruvector trajectory hooks
step "browser-agent wires ruvector trajectory-begin/step/end"
missing=""
for h in trajectory-begin trajectory-step trajectory-end; do
grep -q "$h" "$ROOT/agents/browser-agent.md" || missing="$missing $h"
done
[[ -z "$missing" ]] && ok || bad "missing trajectory hooks:$missing"
# 9. ADR file exists with status Proposed
step "ADR-0001 exists and is Proposed"
adr="$ROOT/docs/adrs/0001-browser-skills-architecture.md"
if [[ -f "$adr" ]] && grep -qE "^status:[[:space:]]*Proposed" "$adr"; then
ok
else
bad "ADR missing or status != Proposed"
fi
# 10. ADR documents the load-bearing replay risk
step "ADR Verification §4 flags the replay-fidelity risk"
if grep -q "load-bearing" "$adr" && grep -q "replay" "$adr" && grep -q "drift" "$adr"; then
ok
else
bad "ADR Verification §4 missing the replay risk callout"
fi
# 11. README enumerates all 8 skills + verb dispatcher
step "README enumerates all 8 skills + verb dispatcher"
missing=""
for tok in browser-record browser-replay browser-extract browser-login browser-form-fill browser-screenshot-diff browser-auth-flow browser-test 'ls' 'doctor'; do
grep -q "$tok" "$ROOT/README.md" || missing="$missing $tok"
done
[[ -z "$missing" ]] && ok || bad "missing:$missing"
# 12. The 5 browser_session_* lifecycle tools are present in the CLI source
step "5 browser_session_* lifecycle tools registered in mcp-tools"
TOOLS_FILE="$ROOT/../../v3/@claude-flow/cli/src/mcp-tools/browser-session-tools.ts"
if [[ ! -f "$TOOLS_FILE" ]]; then
bad "browser-session-tools.ts not found at $TOOLS_FILE"
else
missing=""
for t in browser_session_record browser_session_end browser_session_replay browser_template_apply browser_cookie_use; do
grep -q "name: '$t'" "$TOOLS_FILE" || missing="$missing $t"
done
if [[ -n "$missing" ]]; then
bad "missing tool definitions:$missing"
else
grep -q 'browserSessionTools' "$ROOT/../../v3/@claude-flow/cli/src/mcp-client.ts" \
&& ok || bad "browserSessionTools not imported in mcp-client.ts"
fi
fi
# 13. allowed-tools enumerated explicitly per skill (no skill claims '*' or omits the list)
step "no skill grants wildcard tool access"
bad_skills=""
for f in "$ROOT"/skills/*/SKILL.md; do
if grep -q '^allowed-tools:[[:space:]]*\*' "$f"; then
bad_skills="$bad_skills $(basename $(dirname "$f"))"
fi
done
[[ -z "$bad_skills" ]] && ok || bad "wildcard:$bad_skills"
printf "\n%s passed, %s failed\n" "$PASS" "$FAIL"
[[ $FAIL -eq 0 ]] || exit 1