From e0070ac7d511db22a6ea733f0d67837ad26720b8 Mon Sep 17 00:00:00 2001 From: Jan Svabenik Date: Sat, 21 Mar 2026 19:28:57 +0100 Subject: [PATCH] feat: enforce recorder/decode budgets --- cmd/sdrd/decision_budget.go | 29 +++++++++++++++++++++++++++++ cmd/sdrd/pipeline_runtime.go | 3 +++ 2 files changed, 32 insertions(+) create mode 100644 cmd/sdrd/decision_budget.go diff --git a/cmd/sdrd/decision_budget.go b/cmd/sdrd/decision_budget.go new file mode 100644 index 0000000..019b18b --- /dev/null +++ b/cmd/sdrd/decision_budget.go @@ -0,0 +1,29 @@ +package main + +import "sdr-wideband-suite/internal/pipeline" + +func enforceDecisionBudgets(decisions []pipeline.SignalDecision, maxRecord int, maxDecode int) (int, int) { + recorded := 0 + decoded := 0 + for i := range decisions { + if decisions[i].ShouldRecord { + if maxRecord > 0 && recorded >= maxRecord { + decisions[i].ShouldRecord = false + decisions[i].Reason = "recording budget exceeded" + } else { + recorded++ + } + } + if decisions[i].ShouldAutoDecode { + if maxDecode > 0 && decoded >= maxDecode { + decisions[i].ShouldAutoDecode = false + if decisions[i].Reason == "" { + decisions[i].Reason = "decode budget exceeded" + } + } else { + decoded++ + } + } + } + return recorded, decoded +} diff --git a/cmd/sdrd/pipeline_runtime.go b/cmd/sdrd/pipeline_runtime.go index 6843594..a2364ca 100644 --- a/cmd/sdrd/pipeline_runtime.go +++ b/cmd/sdrd/pipeline_runtime.go @@ -360,6 +360,9 @@ func (rt *dspRuntime) refineSignals(art *spectrumArtifacts, input pipeline.Refin } } } + maxRecord := rt.cfg.Resources.MaxRecordingStreams + maxDecode := rt.cfg.Resources.MaxRecordingStreams + enforceDecisionBudgets(decisions, maxRecord, maxDecode) rt.det.UpdateClasses(signals) return pipeline.RefinementResult{Signals: signals, Decisions: decisions, Candidates: selectedCandidates} }