feat: integrate Ash framework #706
Labels
No labels
1week
2weeks
Failed compliance check
IP cameras
NATS
Possible security concern
Review effort 1/5
Review effort 2/5
Review effort 3/5
Review effort 4/5
Review effort 5/5
UI
aardvark
accessibility
amd64
api
arm64
auth
back-end
bgp
blog
bug
build
checkers
ci-cd
cleanup
cnpg
codex
core
dependencies
device-management
documentation
duplicate
dusk
ebpf
enhancement
eta 1d
eta 1hr
eta 3d
eta 3hr
feature
fieldsurvey
github_actions
go
good first issue
help wanted
invalid
javascript
k8s
log-collector
mapper
mtr
needs-triage
netflow
network-sweep
observability
oracle
otel
plug-in
proton
python
question
reddit
redhat
research
rperf
rperf-checker
rust
sdk
security
serviceradar-agent
serviceradar-agent-gateway
serviceradar-web
serviceradar-web-ng
siem
snmp
sysmon
topology
ubiquiti
wasm
wontfix
zen-engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
carverauto/serviceradar#706
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from GitHub.
Original GitHub issue: #2205
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/issues/2205
Original created: 2025-12-23T21:23:44Z
Is your feature request related to a problem?
Describe the solution you'd like
Recommendation for the Rewrite
pollers_registry,agents_registry, andcheckers_registrytables in CNPG as outlined in yourservice-registry-design.md.This approach gives you the "One Big Brain" feel (cluster-wide process management) with the industrial-strength scheduling of Oban and the low-level performance of your existing Go agents.
Using Ash Framework for ServiceRadar would be a significant architectural "force multiplier," especially given your requirements for multi-tenancy, identity reconciliation, and a "distributed brain."
Ash is a declarative, resource-based framework for Elixir. Instead of writing boilerplate CRUD and complex scoping logic, you define "Resources" (Devices, Pollers, Agents) and the rules that govern them.
Here is how Ash would specifically solve your ServiceRadar rewrite challenges:
1. First-Class Multi-Tenancy (The "Partition" Problem)
Your docs mention the need to support multi-tenancy and overlapping IP spaces via partitions. In a standard Elixir app, you'd have to remember to add
where tenant_id = ...to every query.multitenant. When the Poller or Web UI requests data, Ash automatically enforces the tenant/partition scope at the engine level. It is nearly impossible to accidentally leak data between tenants.2. AshOban: Declarative Scheduling
Since you are already considering Oban, AshOban is a game-changer.
Monitoring.Checkresource (e.g.,:run_check).pending->active->failed).3. Identity Reconciliation (The "Canonical ID" Problem)
Your Go core currently does complex "device identity and reconciliation."
Deviceis unique based on a combination of(mac, partition_id)or(armis_id, tenant_id).canonical_statusthat runs the reconciliation logic you currently have in Go, but exposes it as a simple field that can be sorted and filtered in your Phoenix LiveView.4. Aggregating the "Distributed Brain"
If you want multiple Elixir nodes to act as one, Ash's Actions and Relationships help model the cluster:
ServiceRadar.Topology.Agent.has_many :checkers, ServiceRadar.Topology.Checker.5. AshGraphql & AshJsonApi (The gRPC/API Bridge)
Your current system relies heavily on gRPC. While Elixir handles gRPC well, Ash can automatically generate a GraphQL or JSON:API layer from your resources.
6. The "Outdated Docs" Problem
You mentioned your documentation is a bit outdated.
Comparison: Standard Elixir vs. Elixir + Ash
whereclauses / Ecto prefixesAshObanactionsIdentitiesandChangesetsservice-registry-design.mdHow to start the rewrite with Ash:
Inventorydomain for Devices/Interfaces and aMonitoringdomain for Pollers/Agents/Checkers.service-registry-design.mdand turn those SQL tables into Ash Resources.AshObanto handle the recurring "Check Heartbeat" and "Run Sweep" tasks.AshAdmin). You can immediately see and edit all your pollers/agents/tenants in a GUI while you are still building the main Phoenix LiveView frontend.Verdict: If your goal is to build a "big brain" that handles complex identities, multi-tenancy, and high-scale polling coordination, Ash is the correct tool. It will reduce the amount of Go code you are porting by roughly 60-70% because the framework handles the "plumbing" of a Service Oriented Architecture for you.
Yes, absolutely. In fact, Ash is arguably the best tool for this because it allows you to separate your business logic (how ServiceRadar behaves) from your data layout (the OCSF schema).
You don't have to choose between "The Ash Way" and "The OCSF Way." Ash's
AshPostgres.DataLayeris designed to map Elixir resources to any existing database schema, no matter how rigid or standardized it is.Here is how you implement OCSF within Ash for ServiceRadar:
1. Mapping Elixir Attributes to OCSF Columns
OCSF uses specific field names (e.g.,
type_id,uid,device_id). If your database already has these columns, you use thesourceoption in Ash to point your attributes to the correct OCSF field names.2. Handling Nested OCSF Objects (JSONB)
OCSF relies heavily on nested structures like
os,hw_info, andnetwork_interfaces. Ash handles these perfectly using Embedded Resources. This allows you to have full validation and typing on the OCSF JSON blobs.3. SRQL vs. Ash Query
You currently have a custom SRQL (ServiceRadar Query Language) engine. Ash effectively provides a standardized version of this.
in:devices status:online, you can translate that into an Ash query:Device |> Ash.Query.filter(status == :online).SELECT * FROM ocsf_device_inventory WHERE status_id = 1.4. TimescaleDB Integration (Hypertables)
Since your OCSF data (especially
flowsandactivity) lives in TimescaleDB hypertables, Ash handles this transparently.time_bucket.5. Multi-Tenancy & Partitions
OCSF doesn't have a native "Partition" concept for overlapping IP spaces, but ServiceRadar does. You can use Ash's attribute-based multi-tenancy to keep OCSF clean while enforcing ServiceRadar rules.
6. The "One Big Brain" Debugger
Because Ash resources are highly structured, when you open the Elixir Observer or a debugger, you won't just see raw maps or tuples. You will see formal
ServiceRadar.Inventory.Devicerecords.If you use AshGraphql, you can also use Apollo Studio or GraphQL Voyager to visually see your entire OCSF-aligned "brain" and how every poller, agent, and device relates to one another.
Summary: Why Ash + OCSF is a win:
Does this align with how you were envisioning the OCSF integration, or are you worried about the complexity of mapping the more obscure OCSF classes?
Imported GitHub comment.
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/issues/2205#issuecomment-3713810315
Original created: 2026-01-06T09:07:34Z
closing as completed