Skip to content

feat: Pi readiness — structured logging, proxy routing, daemon verification#15

Merged
alderpath merged 2 commits into
masterfrom
pi-ready-logging
Jun 16, 2026
Merged

feat: Pi readiness — structured logging, proxy routing, daemon verification#15
alderpath merged 2 commits into
masterfrom
pi-ready-logging

Conversation

@alderpath

Copy link
Copy Markdown
Contributor

Summary

Three layers of Pi readiness improvements:

1. Structured logging

  • New log.rs module: tracing + tracing-subscriber with env-filter
  • RUST_LOG / RELIARY_LOG env vars: error/warn/info/debug/trace
  • RELIARY_LOG_FILE for file logging with 10MB rotation
  • All operational eprintln! replaced with tracing macros
  • logs --tail and logs --level support

2. Pi proxy routing

  • init now prompts to configure proxy routing for Pi after gate.js install
  • Scans Pi settings.json + env vars for API keys
  • Writes proxy-routes.json — auth-based routing works automatically

3. Daemon service verification

  • After systemctl enable/launchctl load, verifies the service is running
  • Prints warning + recovery command on silent failure

4. gate.js improvements

  • RELIARY_LOG level filtering (default: info — quiet unless something's wrong)
  • Binary discovery via RELIARY_BIN_PATH → PATH → hardcoded paths

….js level filtering

Three layers of improvements for Pi readiness:

## 1. Structured logging (tracing)
- New  module: tracing + tracing-subscriber with env-filter
-  and  env vars control verbosity (error/warn/info/debug/trace)
-  for optional file logging with 10MB rotation
- All operational  replaced with  macros
- Tracing writes to stderr (not stdout) — MCP JSON protocol on stdout stays clean
-  and  for real-time log following and level filtering

## 2. gate.js logging levels
-  env var controls gate.js verbosity (default: info)
- 5 levels: error (⛔), warn (⚠), info (•), debug (↓), trace (·)
- 'info' level shows: startup banner, turn count, safety changes
- 'debug' level shows: compression ratios, tool redirects, dedup hits, heal events
- 'trace' would show every daemon command (future use)

## 3. Pi proxy routing in init
- After gate.js install, prompts: 'Configure proxy routing for Pi?'
- Scans Pi settings.json + env vars for API keys
- Writes proxy-routes.json so auth-based routing works for Pi providers
- No manual env var setting needed

## 4. Daemon service verification
- After systemctl enable/launchctl load, verifies the service is actually active
- Prints warning and manual recovery command if service failed silently

## 5. Binary discovery in gate.js
- Checks RELIARY_BIN_PATH env var first (set by init)
- Falls back to reliary-agent not found on PATH
- Hardcoded paths as last resort (was the only fallback before)

92 tests pass (0 regressions).
…inary discovery

## Rust unit tests (10 new, 37 total in log.rs + init.rs)

### log.rs (4 new tests)
- test_file_logger_rotation: verifies log file rotation at 10-byte threshold
- test_level_value_boundary_conditions: tests empty/uppercase/leading-space inputs
- test_resolve_reliary_log_levels: confirm filter string format
- test_resolve_reliary_log_unexpected_values: non-standard values pass through

### init.rs (6 new tests)
- test_install_pi_proxy_routes_empty: no Pi settings → 0 routes
- test_install_pi_proxy_routes_from_env: env vars → proxy-routes.json written
- test_install_pi_proxy_routes_from_settings: Pi settings.json → routes extracted
- test_install_pi_proxy_routes_multiple_keys: 2 env vars → both in proxy-routes.json
- test_inject_mcp_server_stdio: verify stdio MCP entry format
- test_inject_sse_mcp_server: verify SSE MCP entry format (url-based)
- test_remove_mcp_server: verify clean removal of MCP entries
- test_inject_mcp_server_existing_servers: verify existing entries preserved

## gate.js tests (20 via Node.js, scripts/test_gate_levels.js)
- 8 log level filtering tests (default, each level, invalid, RUST_LOG, override)
- 5 binary discovery tests (env var, PATH, hardcoded, priority ordering)
- 5 feature flag parsing tests (-/+/no prefix, unknown features)
- 1 syntax validation test (gate.js is valid JS)
- Added to CI workflow

## CI guardrails
- Node.js gate.js test step added to CI
- Test count threshold raised from 75 to 96
@alderpath alderpath merged commit 7ec75b8 into master Jun 16, 2026
@alderpath alderpath deleted the pi-ready-logging branch June 16, 2026 23:15
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.

1 participant