Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@
*.cmd text eol=crlf
*.json text eol=lf
brand/** -text
*.rs text eol=lf
*.html text eol=lf
*.css text eol=lf
*.js text eol=lf
Cargo.lock text eol=lf
*.sqlite3 binary
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ body:
id: environment
attributes:
label: Environment
description: Python version, operating system, and sanitized command. Do not attach a private config.
description: dead-air --version, FFmpeg version, operating system, and sanitized command. Do not attach a private config.
validations:
required: true
- type: checkboxes
Expand Down
111 changes: 54 additions & 57 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,74 +7,71 @@ on:
permissions:
contents: read

env:
CARGO_TERM_COLOR: always

jobs:
source:
name: Source checks (${{ matrix.os }}, Python ${{ matrix.python-version }})
test:
name: fmt, clippy and tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 15
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.11', '3.14']
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1
with:
python-version: ${{ matrix.python-version }}
- name: Install pinned requirements from official PyPI
run: python -m pip install --disable-pip-version-check --index-url https://pypi.org/simple -r requirements.txt
- name: Install package and exercise console entry point outside checkout
run: |
python -m pip install --disable-pip-version-check --index-url https://pypi.org/simple .
python scripts/smoke_install.py
- name: Validate example from a fresh clean copy
run: >-
python -c "import pathlib,shutil,subprocess,sys,tempfile; src=pathlib.Path.cwd(); temporary=tempfile.TemporaryDirectory(); clean=pathlib.Path(temporary.name)/'clean'; clean.mkdir(); shutil.copytree(src/'deadair',clean/'deadair'); [shutil.copy2(src/name,clean/name) for name in ('dead_air.py','dead-air.example.toml','requirements.txt')]; subprocess.run([sys.executable,str(clean/'dead_air.py'),'validate','--config',str(clean/'dead-air.example.toml')],cwd=clean,check=True)"
- name: Run source suite
run: python -m unittest discover -s tests -p test_dead_air.py -v
- name: Run incident suite
run: python -m unittest discover -s tests -p test_incidents.py -v
- name: Run alert suite
run: python -m unittest discover -s tests -p test_alerts.py -v
- name: Run operations and crash-recovery suite
run: python -m unittest discover -s tests -p test_operations.py -v
- name: Run Windows native-media suite when tools are available
if: runner.os == 'Windows'
shell: pwsh
- name: Rust toolchain (preinstalled rustup)
shell: bash
run: |
$ffmpeg = Get-Command ffmpeg -ErrorAction SilentlyContinue
$ffprobe = Get-Command ffprobe -ErrorAction SilentlyContinue
if ($null -eq $ffmpeg -or $null -eq $ffprobe) {
Write-Host "::notice::Native media tests skipped: ffmpeg and ffprobe are not both available on this Windows runner."
} else {
python -m unittest discover -s tests -p test_media.py -v
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}

full-discovery:
name: Full discovery with FFmpeg lavfi (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
python-version: ['3.11', '3.14']
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1
with:
python-version: ${{ matrix.python-version }}
- name: Install system FFmpeg and OpenSSL for local fixtures
rustup toolchain install stable --profile minimal --component rustfmt,clippy
rustup default stable
rustc --version
- name: Install FFmpeg (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y ffmpeg openssl
sudo apt-get install --no-install-recommends -y ffmpeg
- name: Install FFmpeg (macOS)
if: runner.os == 'macOS'
run: brew install ffmpeg
- name: Confirm local media tools
if: runner.os != 'Windows'
run: |
ffmpeg -version
ffprobe -version
openssl version
- name: Install pinned requirements from official PyPI
run: python -m pip install --disable-pip-version-check --index-url https://pypi.org/simple -r requirements.txt
- name: Run full test discovery with synthetic media
run: python -m unittest discover -s tests -v
- name: Format
run: cargo fmt --check
- name: Clippy
run: cargo clippy --all-targets --locked -- -D warnings
- name: Tests (native media and loopback suites required on Linux and macOS)
if: runner.os != 'Windows'
env:
DEAD_AIR_REQUIRE_MEDIA: "1"
run: cargo test --locked
- name: Tests (Windows; native media suites run when FFmpeg is on PATH)
if: runner.os == 'Windows'
run: cargo test --locked
- name: Installer dry runs
shell: bash
run: |
if [ "$RUNNER_OS" = "Windows" ]; then cmd //c "install.cmd /dry-run"; else bash install.sh --dry-run; fi
- name: Installed binary smoke check outside the checkout
shell: bash
run: |
cargo build --release --locked
BIN="$PWD/target/release/dead-air"
[ -f "$BIN.exe" ] && BIN="$BIN.exe"
WORK=$(mktemp -d)
cd "$WORK"
"$BIN" --version | grep -q "dead-air 0.3.0"
"$BIN" init | grep -q '"created": true'
"$BIN" validate --config dead-air.toml | grep -q '"ok": true'
set +e
"$BIN" status --config dead-air.toml --json > status.json
code=$?
set -e
[ "$code" = 2 ]
grep -q '"network_contacted": false' status.json
[ ! -e state ]
"$BIN" tempo policy | grep -q deadair_status
94 changes: 94 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Release

on:
push:
tags: ['v*']

permissions:
contents: read

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
fail-fast: true
matrix:
include:
- { os: ubuntu-latest, target: x86_64-unknown-linux-musl, archive: tar.gz }
- { os: ubuntu-24.04-arm, target: aarch64-unknown-linux-musl, archive: tar.gz }
- { os: windows-latest, target: x86_64-pc-windows-msvc, archive: zip }
- { os: macos-latest, target: aarch64-apple-darwin, archive: tar.gz }
- { os: macos-latest, target: x86_64-apple-darwin, archive: tar.gz }
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
- name: Check the tag matches the crate and installer versions
shell: bash
run: |
VERSION="${GITHUB_REF_NAME#v}"
grep -q "^version = \"$VERSION\"$" Cargo.toml
grep -q "^VERSION=$VERSION$" install.sh
grep -q "set \"VERSION=$VERSION\"" install.cmd
- name: Rust toolchain (preinstalled rustup)
shell: bash
run: |
rustup toolchain install stable --profile minimal --target ${{ matrix.target }}
rustup default stable
- name: musl C toolchain
if: contains(matrix.target, 'musl')
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y musl-tools
- name: Build
shell: bash
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Package
shell: bash
run: |
NAME="dead-air-${GITHUB_REF_NAME}-${{ matrix.target }}"
mkdir -p "dist/$NAME"
EXE=dead-air
[ "${{ matrix.archive }}" = zip ] && EXE=dead-air.exe
cp "target/${{ matrix.target }}/release/$EXE" "dist/$NAME/"
cp README.md LICENSE NOTICE CHANGELOG.md dead-air.example.toml "dist/$NAME/"
cd dist
if [ "${{ matrix.archive }}" = zip ]; then
pwsh -NoProfile -Command "Compress-Archive -Path '$NAME' -DestinationPath '$NAME.zip'"
else
tar -czf "$NAME.tar.gz" "$NAME"
fi
rm -rf "$NAME"
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: dist/*
if-no-files-found: error

publish:
name: publish release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Checksums
run: |
cd dist
sha256sum dead-air-* > SHA256SUMS
cat SHA256SUMS
- name: Publish with gh
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$GITHUB_REF_NAME" dist/* \
--title "DEAD AIR ${GITHUB_REF_NAME}" \
--notes "See CHANGELOG.md for changes and upgrade notes. Verify downloads against SHA256SUMS."
15 changes: 9 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
__pycache__/
*.py[cod]
/target/
dead-air.toml
state/
.venv/
build/
dist/
*.egg-info/
*.sqlite3
*.sqlite3-journal
*.sqlite3.lock
*.db
*.db-journal
*.db.lock
# Left over from Python 0.2.0 checkouts
__pycache__/
*.py[cod]
.venv/
build/
dist/
*.egg-info/
!/tests/fixtures/*.sqlite3
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,68 @@
# Changelog

## 0.3.0

DEAD AIR is now one Rust binary, `dead-air`. The Python implementation is gone;
nothing in the shipped product needs Python.

- Same commands, flags, exit codes (0/1/2/3/130/141/143), TOML keys and on-disk
state (schema 2; schema 1 read by status and migrated by the first writer), and
the same `--json` shapes and formatting. The per-stream config fingerprint is byte
compatible, so stored observations stay fresh across the upgrade.
- Same detection semantics: three independent conditions with their own evidence
and positive recovery; missing or inconclusive samples are UNKNOWN; thumbnail
evidence is DEGRADED at best; the 100 ms acquisition prefix and gap rules.
- Same alert rules: stable event ids, at most three attempts at 0/30/120 s with a
capped Retry-After, at-least-once, each attempt in an owned child process.
- New `incidents` command (incident ids from local state, read-only).
- New optional `[metrics]` table: `watch` serves Prometheus text on
`127.0.0.1` (per-source condition signals, last-cycle duration, open incidents,
delivery failures). See [operations](docs/OPERATIONS.md#metrics).
- New optional `[tempo]` table and `explain` command: an advisory Perennos Tempo
brief about one incident, built from incident metadata only and stored with its
Tempo receipt id; `status`, `incidents` and the page show it. Alerts never wait
on Tempo. New `mcp` command (read-only MCP tools) and `tempo status|policy|mcp-config`.
See [docs/TEMPO.md](docs/TEMPO.md).
- `doctor` adds an `advice` list in plain words and, when Tempo is enabled, a
loopback Tempo probe (warnings only).
- Installers download a release build and check its SHA-256 against the release's
`SHA256SUMS`, fall back to `cargo install --locked`, or print the rustup line.
A release workflow builds Linux (x86_64 and aarch64 musl), Windows (x86_64 MSVC)
and macOS (arm64 and x86_64) binaries; CI runs fmt, clippy and tests on Linux,
macOS and Windows.

Behaviour changes a user may notice:

- `python dead_air.py ...`, `python -m deadair` and the Python import API no
longer exist; call `dead-air`. The installer no longer creates a `.venv` or
installs yt-dlp; install yt-dlp yourself for YouTube sources.
- Added JSON fields: `status --json` adds `briefs` and an `incident_id` on each
open incident; `doctor` adds `advice` (and `tempo`/`loopback_tempo_contacted`
when enabled); the page's state adds incident `id`s and `tempo`. `init` prints
the same keys in sorted order. Readable `status` lines name the incident id.
- The page's Start button no longer refuses to start because the persistent
`.dead-air.lock` guard exists (0.2.0 confused that guard with a live owner). It
now checks the database's OS lock, refuses while any process holds it or while
an unknown legacy guard is present, and never deletes a lock file. Stop gives the
watcher three seconds to clean up before forcing it.
- DNS lookups run on bounded worker threads instead of child interpreters, and
SMTP now connects to the policy-checked addresses (0.2.0 re-resolved the name).
- HTTPS and SMTP trust the operating system's certificate store or
`SSL_CERT_FILE`, with the Mozilla roots as a fallback; the sender child receives
`SSL_CERT_FILE`/`SSL_CERT_DIR` when they are set.
- Hostnames must be ASCII (use the `xn--` form for international names), and URL
hosts may contain only letters, digits, dots, hyphens and underscores.
- Multicast and site-local addresses are treated as non-public, like private ones.
- The GUI binary on Windows is a console program; the shortcut starts it minimized.

Upgrade notes from 0.2.0: stop every Python monitor (and the old page), run
`bash install.sh` or `install.cmd`, update any launcher or service that called
`python dead_air.py` to call `dead-air` with the same arguments, then run
`dead-air status --config dead-air.toml` before `watch`. No state migration is
needed and history, open incidents and pending alerts carry over. To roll back,
stop the Rust monitor, remove any `[tempo]` or `[metrics]` table from the TOML,
and run 0.2.0 against the same database; it ignores the `tempo_briefs` table.

## 0.2.0

- Installable `dead-air` command, `python -m deadair`, bundled starter config,
Expand Down
18 changes: 13 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@ If a secret was exposed, remove it from the working copy and ask the owner to ro

## Local checks

Use the Python environment and setup described by the README. From `repo`, run the focused suites relevant to the change, for example:
DEAD AIR is a Rust crate (edition 2024, minimum Rust 1.85). Run the same gates CI runs:

```text
python -m unittest discover -s tests -p test_dead_air.py -v
python -m unittest discover -s tests -p test_incidents.py -v
python -m unittest discover -s tests -p test_alerts.py -v
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test
```

Tests and examples must use fake clocks, fake senders, and synthetic media/data where applicable. Do not use native media tools, external resolvers, live endpoints, or unbounded continuous runs as a routine contribution check. If a change needs an integration check, describe the authorization and exact boundary; do not put private endpoint details in the public change.
The native media and loopback suites (`tests/media.rs`, `tests/network.rs`) need FFmpeg and
ffprobe on PATH and are skipped without them; set `DEAD_AIR_REQUIRE_MEDIA=1` to make a missing
tool a failure. They generate synthetic media and talk only to listeners they own. A focused
run is `cargo test --test incidents` (or `alerts`, `observations`, `operations`, `gui`).

On Linux, `scripts/check-windows.sh` type-checks the Windows build without a MinGW toolchain;
real Windows builds and tests run on the windows-latest CI runner.

Tests and examples must use fake clocks, fake senders, and synthetic media/data where applicable. Do not use external resolvers, live endpoints, or unbounded continuous runs as a routine contribution check. If a change needs an integration check, describe the authorization and exact boundary; do not put private endpoint details in the public change. Changes to on-disk state or `--json` output must keep `tests/watch.rs`'s Python 0.2.0 fixture checks passing.

## Pull requests

Expand Down
Loading
Loading