proxy-pilot 0.7.0

Core-agnostic proxy health monitor, automatic failover daemon, and multi-channel alerting tool for Linux servers.
Documentation
# AGENTS.md

This guide applies to the entire `proxy-pilot` repository. `proxy-pilot` is a core-agnostic Rust daemon and CLI tool for monitoring proxy health, performing automatic failover with anti-flapping, and sending VPN-independent alerts on Linux servers.

Use this file as a router and read the linked owner documents before changing code, configuration, or Git history.

## Owner approval for Git and GitHub

- Inspect `git status` and relevant diffs before editing. Preserve the owner's staged, unstaged, and untracked work.
- **Perform a Git commit, push, merge, tag, or pull request creation only when the owner explicitly requests that specific action.**
- Authorization for one action grants only that action. A request to implement, fix, or verify authorizes working-tree edits and local checks, not Git history or remote changes.
- Include only in-scope files in an authorized commit. Never move, delete, or re-create a pushed release tag (`v*`).

## Owner approval for data deletion and live server actions

- **Never delete, truncate, or overwrite live server configurations, runtime state, or user data without explicit owner approval.**
- Never use real credentials (Bale bot tokens, SMS keys, live proxy configs), touch live servers, or send live alerts without explicit authorization for that action.
- Never commit secrets or live `config.yaml` files; only commit `config.example.yaml` with placeholders.

## Behavioral guidelines

Favor care over speed and use judgment for straightforward tasks:

1. **Think before coding.** Check assumptions against code and documentation. State assumptions that affect behavior, flag avoidable tradeoffs, and ask before acting on ambiguity that materially changes scope.
2. **Simplicity first.** Use the least code that fully solves the task. Keep features, options, and abstractions tied to the current request. Never add catch-all `utils.rs` or `helpers.rs` modules.
3. **Surgical changes.** Follow existing style and keep edits tied to the request. Preserve unrelated code, comments, and formatting. Remove imports, variables, and functions made unused by your change.
4. **Goal-driven execution.** Define observable success criteria and pair each step with a check. Reproduce bugs with a failing test before fixing them, and whenever a feature is added or behavior is modified, update unit tests to cover all valid, invalid, and edge-case inputs.

## Architecture and contracts

- `src/engine/` owns the watchdog loop, anti-flapping state machine, failover selection, auto-recovery, and alert cooldowns. It must depend **only** on traits (`ProxyCore`, `HealthProbe`, `Notifier`) — never on concrete cores or notification channels.
- `src/core/` owns the `ProxyCore` trait, core binary installation, and concrete adapters (`xray`, future `singbox`). Config file updates must be atomic (write temp file + rename).
- `src/probe/` owns the `HealthProbe` trait and proxy-routed checks that distinguish `Healthy`, `GeoBlocked` (`403`/`429`), and `Unreachable`.
- `src/notify/` owns the `Notifier` trait and concrete channels (`bale`, future `heartbeat`, `sms`, `email`).
- `src/cli/` owns CLI argument parsing (`clap`), the interactive `setup` wizard, and wiring concrete implementations into `engine`.
- Never use `.unwrap()` or `.expect()` in non-test runtime code (`src/`); propagate typed errors via `PilotError`.

## Temporary files

- Put scratch scripts, temporary logs, and generated test data in `tmp/` (ignored by Git). Never leave temporary files in the repository root or committed directories.

## Verification

Run applicable checks from the repository root before considering a code task complete (also enforced by `.pre-commit-config.yaml` and `.github/workflows/ci.yml`):

```bash
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-targets
```

Unit tests must be deterministic and offline (use mocks and `tempfile`; never call live internet endpoints or real Bale/SMS APIs). See [Coding Standards](docs/standards/coding.md) and [Testing Standards](docs/standards/testing.md) for full rules. Report which checks ran and any gaps (e.g. if `cargo` is not installed in the current environment).

## Task -> document

| Task | Read (repository-relative path) |
| --- | --- |
| Understand module boundaries, state machine, or Linux FHS paths | `docs/architecture.md` |
| Configure `config.yaml`, routing modes, or env vars | `docs/guides/configuration.md` |
| Change CLI commands, flags, or exit codes | `docs/guides/cli.md` |
| Deploy on Linux, integrate Docker/GitLab Runner, rollback, or troubleshoot | `docs/guides/operations.md` |
| Write or modify Rust code or Linux daemon behavior | `docs/standards/coding.md` |
| Write or run tests, mocks, or bug reproductions | `docs/standards/testing.md` |
| Handle secrets, config permissions, checksums, or live server safety | `docs/standards/security.md` |
| Create branches, commits, tags, or releases | `docs/standards/git.md` |
| Add a new proxy core (`sing-box`, etc.) or notifier (SMS, Email, Heartbeat) | `docs/guides/extending.md` |
| Browse all technical documentation | `docs/README.md` |

## Stop and ask the owner when

- Sources conflict or completing a task requires an unapproved rule exception.
- A new top-level directory, dependency, or config schema breaking change lies outside the approved task.
- Real credentials, live server deployment, or Git/GitHub write actions lack explicit authorization.