Skip to content

chore: add local CI scripts, metrics gate, and pre-commit hook#144

Merged
Keith-CY merged 6 commits intodevelopfrom
chore/local-dev-scripts
Mar 19, 2026
Merged

chore: add local CI scripts, metrics gate, and pre-commit hook#144
Keith-CY merged 6 commits intodevelopfrom
chore/local-dev-scripts

Conversation

@dev01lay2
Copy link
Collaborator

Summary

Extract CI workflow steps into local scripts for fast iteration without pushing to GitHub.

New files (scripts/)

Script Purpose
_common.sh Shared helpers (repo root resolution, require_command, section output)
ci-frontend.sh bun install → typecheck → build
ci-rust.sh cargo fmt --check → clippy → tests → perf_metrics
ci-metrics.sh Full metrics report with hard/soft gate evaluation (402 lines)
ci-coverage.sh cargo llvm-cov for clawpal-core + clawpal-cli
ci-all.sh Run all scripts in sequence, stop on first failure
pre-commit Git hook: frontend → rust (staged fmt) → metrics gate
install-hooks.sh One-command symlink of pre-commit hook
README.md Documentation for all scripts

Gate behavior

Hard gates (block commit):

  • JS bundle gzip ≤ 512 KB
  • cargo test -p clawpal --test perf_metrics passes
  • cargo test -p clawpal --test command_perf_e2e passes

Soft gates (report only):

  • Individual commit size ≤ 500 changed lines
  • Source files > 500 lines listed as warnings

Pre-commit hook optimization

CLAWPAL_FMT_SCOPE=staged narrows cargo fmt to staged .rs files only.

Skips Docker/SSH remote perf, Playwright, and system deps installation (those need CI infra).

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

📊 Test Coverage Report

Metric Base (develop) PR (chore/local-dev-scripts) Delta
Lines 74.34% (6134/8251) 74.44% (6142/8251) 🟢 +0.10%
Functions 68.88% (704/1022) 68.98% (705/1022) 🟢 +0.10%
Regions 75.86% (10156/13388) 75.97% (10171/13388) 🟢 +0.11%

Coverage measured by cargo llvm-cov (clawpal-core + clawpal-cli).

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

📏 Metrics Gate Report

Status: ✅ All gates passed

Commit Size ❌

Metric Value Limit Status
Commits checked 4
All within limit 3/4 ≤ 500 lines
Largest commit 628 lines ≤ 500

Bundle Size ✅

Metric Value Limit Status
JS bundle (raw) 918 KB
JS bundle (gzip) 289 KB ≤ 350 KB
JS initial load (gzip) 164 KB ≤ 180 KB

Perf Metrics E2E ✅

Metric Value Limit Status
Tests 10 passed, 0 failed 0 failures
RSS (test process) 3.1 MB ≤ 20 MB
VMS (test process) 269.9 MB ℹ️
Command P50 latency 31 µs ≤ 1000 µs
Command P95 latency 38 µs ≤ 5000 µs
Command max latency 69 µs ≤ 50000 µs

Command Perf (local) ✅

Metric Value Status
Tests 4 passed, 0 failed
Commands measured 5 ℹ️
RSS (test process) 4.4 MB ℹ️
Local command timings
Command P50 (µs) P95 (µs) Max (µs)
local_openclaw_config_exists 2 9 9
list_ssh_hosts 2 10 10
get_app_preferences 17 46 46
read_app_log 60 80 80
read_error_log 6 29 29

Command Perf (remote SSH) ✅

Metric Value Status
SSH transport OK
Command failures 12/15 runs ℹ️ Docker (no gateway)
Remote command timings (via Docker SSH)
Command Median Max
openclaw_status 2105 ms 2117 ms
cat__root_.openclaw_openclaw.json 255 ms 256 ms
openclaw_gateway 2281 ms 2300 ms
openclaw_cron 2174 ms 2192 ms
openclaw_agent 2285 ms 2451 ms

Home Page Render Probes (real IPC) ✅

Probe Value Limit Status
status 29 ms ≤ 500 ms
version 131 ms ≤ 500 ms
agents 29 ms ≤ 500 ms
models 147 ms ≤ 500 ms
settled 163 ms ≤ 500 ms

Code Readability

File Lines Target Status
commands/doctor_assistant.rs 5636 ≤ 3000 ⚠️
commands/rescue.rs 3402 ≤ 2000 ⚠️
commands/profiles.rs 2477 ≤ 1500 ⚠️
cli_runner.rs 1915 ≤ 1200 ⚠️
commands/credentials.rs 1629 ≤ 1000 ⚠️
openclaw_doc_resolver.rs 1362 ≤ 800 ⚠️
commands/ssh.rs 1232 ≤ 700 ⚠️
commands/doctor.rs 1168 ≤ 700 ⚠️
commands/sessions.rs 905 ≤ 500 ⚠️
pages/StartPage.tsx 898 ≤ 500 ⚠️
pages/Settings.tsx 897 ≤ 500 ⚠️
commands/discovery.rs 878 ≤ 500 ⚠️
pages/Home.tsx 875 ≤ 500 ⚠️
install/commands.rs 839 ≤ 500 ⚠️
ssh.rs 826 ≤ 500 ⚠️
lib/use-api.ts 674 ≤ 500 ⚠️
commands/model.rs 645 ≤ 500 ⚠️
bridge_client.rs 645 ≤ 500 ⚠️
components/InstallHub.tsx 619 ≤ 500 ⚠️
agent_fallback.rs 609 ≤ 500 ⚠️
install/runners/docker.rs 525 ≤ 500 ⚠️
commands/types.rs 518 ≤ 500 ⚠️
commands/overview.rs 508 ≤ 500 ⚠️
components/SessionAnalysisPanel.tsx 503 ≤ 500 ⚠️
commands/instance.rs 501 ≤ 500 ⚠️
App.tsx 498 ≤ 500
lib/types.ts 490 ≤ 500
pages/Doctor.tsx 479 ≤ 500
commands/agent.rs 475 ≤ 500
pages/Channels.tsx 460 ≤ 500
commands/backup.rs 459 ≤ 500
lib/api.ts 453 ≤ 500
node_client.rs 452 ≤ 500
commands/discover_local.rs 441 ≤ 500
pages/Cron.tsx 429 ≤ 500
components/__tests__/DoctorRecoveryOverview.test.tsx 429 ≤ 500
commands/config.rs 419 ≤ 500
bug_report/queue.rs 409 ≤ 500
commands/channels.rs 405 ≤ 500
lib/api-read-cache.ts 401 ≤ 500
components/__tests__/InstanceCard.test.tsx 400 ≤ 500
lib/__tests__/guidance.test.ts 399 ≤ 500
components/DoctorRecoveryOverview.tsx 383 ≤ 500
lib/use-cached-query.ts 353 ≤ 500
hooks/useSshConnection.ts 352 ≤ 500
components/DoctorTempProviderDialog.tsx 349 ≤ 500
bug_report/collector.rs 335 ≤ 500
components/InstanceCard.tsx 334 ≤ 500
lib.rs 333 ≤ 500
hooks/useWorkspaceTabs.ts 331 ≤ 500
lib/doctor-report-i18n.ts 328 ≤ 500
recipe.rs 325 ≤ 500
pages/__tests__/overview-loading.test.ts 318 ≤ 500
components/__tests__/SshFormWidget.test.tsx 312 ≤ 500
doctor.rs 303 ≤ 500
Files > 500 lines 25 trend ↓
Files over target 25 0 ⚠️

📊 Metrics defined in docs/architecture/metrics.md

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

📦 PR Build Artifacts

Platform Download Size
Windows-x64 📥 clawpal-Windows-x64 15.7 MB
Linux-x64 📥 clawpal-Linux-x64 102.9 MB
macOS-ARM64 📥 clawpal-macOS-ARM64 12.3 MB
macOS-x64 📥 clawpal-macOS-x64 12.9 MB

🔨 Built from 6691eef · View workflow run
⚠️ Unsigned development builds — for testing only

@dev01lay2 dev01lay2 force-pushed the chore/local-dev-scripts branch from e7555b8 to 8de3904 Compare March 19, 2026 12:08
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

📸 UI Screenshots

Commit: 7a699c6688a6c205fadc367fe4f328d91cdb17fb | Screenshots: Download artifact

Light Mode — Core Pages

Start Page Home Channels
start home channels
Recipes Cron Doctor
recipes cron doctor
Context History Chat Panel
context history chat
Settings (4 scroll positions)
Main Appearance Advanced Bottom
s1 s2 s3 s4
Start Page Sections
Overview Profiles Settings
sp1 sp2 sp3

Dark Mode

Start Home Channels Doctor
d1 d2 d3 d4
Dark mode — more pages
Recipes Cron Settings
d5 d6 d7

Responsive + Dialogs

Home 1024×680 Chat 1024×680 Create Agent
r1 r2 d1

🔧 Harness: Docker + Xvfb + tauri-driver + Selenium | 28 screenshots, 13 flows

Copy link
Collaborator

@Keith-CY Keith-CY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 tests/e2e/perf/ipc-bridge-server.mjs:76
The new "real IPC" bridge still fabricates a healthy runtime/status snapshot when the live gateway call fails. Both get_instance_runtime_snapshot() and get_status_light() await gatewayFetch("/api/status") and then ignore the result, returning healthy: true plus config-derived agents either way. src/lib/api.ts:89-94 shows those are exactly the Home reads being measured, and .github/workflows/metrics.yml:414-420 now treats any non-null snapshot as readiness. So this can still report green "real IPC" probe numbers without ever receiving a successful gateway-backed runtime response.

P1 scripts/ci-metrics.sh:13
The new local metrics/pre-commit path no longer matches the GitHub metrics gate this PR introduces. CI lowered the bundle cap to 350 KB in .github/workflows/metrics.yml:80-96, but scripts/ci-metrics.sh still uses BUNDLE_LIMIT_KB=512. The drift continues for perf metrics: src-tauri/tests/perf_metrics.rs:197-199 now emits cmd_*_us, while scripts/ci-metrics.sh:204-206 still parses cmd_*_ms, so the local script drops those numbers entirely instead of enforcing the same thresholds CI uses. That means scripts/pre-commit can go green on a branch that GitHub will still reject, which defeats the point of adding local CI parity.

Copy link
Collaborator Author

@dev01lay2 dev01lay2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1-2 fixed in 0a943c1: ci-metrics.sh now uses BUNDLE_LIMIT_KB=350 and parses cmd_*_us metrics, matching CI exactly.

P1-1 (ipc-bridge-server.mjs): This file is not modified by this PR — it comes from the develop merge commit. The fabricated-healthy-on-failure issue is a pre-existing bug in fix/home-probe-real-ipc (#141). Happy to fix it in a separate PR, but it's out of scope here.

Requesting re-review.

Copy link
Collaborator

@Keith-CY Keith-CY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 scripts/ci-metrics.sh:382
The follow-up fixed the 350 KB constant and the cmd_*_us parsing, but the local metrics script still does not enforce the same hard gates that the GitHub metrics workflow enforces locally-measurable inputs for. scripts/ci-metrics.sh only fails on three conditions: total bundle gzip pass/fail, perf_metrics test exit, and command_perf_e2e test exit. By contrast, .github/workflows/metrics.yml:486-494 also hard-fails when initial-load gzip exceeds 180 KB and when cmd_p50_us exceeds 1000. Those values are already computed and printed by scripts/ci-metrics.sh:347 and scripts/ci-metrics.sh:352, but they never affect hard_failures. So scripts/pre-commit can still go green on a branch that GitHub rejects, which is still a correctness gap for a PR whose stated goal is local CI parity.

Non-blocking: scripts/README.md:31 still documents the old <= 512 KB bundle cap, so the docs no longer match either the script or CI.

- Add initial-load gzip <= 180 KB hard gate (matches .github/workflows/metrics.yml:486)
- Add cmd_p50 <= 1000 µs hard gate (matches .github/workflows/metrics.yml:493)
- Update README bundle cap from 512 KB to 350 KB to match script and CI
@dev01lay2
Copy link
Collaborator Author

P1 fixed in 6691eef: scripts/ci-metrics.sh now enforces initial-load gzip ≤ 180 KB and cmd_p50 ≤ 1000 µs as hard failures, matching CI exactly. scripts/README.md updated from 512 KB → 350 KB.

Requesting re-review.

Copy link
Collaborator Author

@dev01lay2 dev01lay2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both issues addressed in 6691eef:

P1: Added hard-failure gates for initial-load gzip > 180 KB and cmd_p50_us > 1000 in scripts/ci-metrics.sh, matching the CI workflow thresholds exactly.

Non-blocking: Updated scripts/README.md to document the correct <= 350 KB bundle cap.

Requesting re-review.

Copy link
Collaborator

@Keith-CY Keith-CY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The remaining local CI parity blocker is fixed on this head. I do not see further blocking issues in the current scripts-only diff.

@Keith-CY Keith-CY merged commit 8528c0e into develop Mar 19, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants