feat(discovery): network auto-discovery with rule-based provisioning - #41
Merged
Conversation
Scan a network range on a schedule and provision hosts for newly-reachable addresses, optionally applying a template's items — the first half of Phase 5. - DiscoveryRule (CIDR, ping/TCP method + port, optional template, interval). The scan reuses the existing ping/TCP probes, dedupes against existing hosts by address, bounds concurrency, and stamps last_run_at. A per-minute scheduler job scans due rules. - Guardrails: the CIDR is capped at 1024 hosts and validated (schema), so a typo like a /8 can't launch millions of probes; everything is owner-scoped. - REST CRUD + a scan-now endpoint under /api/discovery-rules, with template-ownership validation. The "scale" half (distributed collection, TSDB) is deliberately deferred — premature without real load data (documented in the roadmap). Tests: scan provisions + dedupes (reachability stubbed), due-rule gating, the CIDR cap/validation, and the CRUD + scan API. Full suite 212 passed; ruff + mypy(strict) green; reversible migration (drops its enum on downgrade).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Phase 5 — network auto-discovery (engine + API). The "scale" half (distributed
collection, TSDB) is deliberately deferred (premature without load data; see roadmap).
Changes
DiscoveryRule(CIDR, ping/TCP + port, optional template, interval). A per-minutescheduler job scans due rules; reachable addresses not yet a host are provisioned
(template applied), deduped by address, bounded concurrency, owner-scoped.
/api/discovery-ruleswith template-ownership validation.Tests
Scan provision + dedupe (reachability stubbed), due gating, CIDR cap/validation, CRUD
Next
A web UI for discovery rules (PR B).