fix: harden runtime cancellation, reloads, and decoding - #228
Open
renyijiu wants to merge 14 commits into
Open
Conversation
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.
Summary
Runtime faults now fail safely instead of crashing the daemon, losing queued rule work, accepting partial configuration, reporting false readiness, or allocating directly from untrusted CDR lengths.
The important behavior change is end-to-end completion tracking: a listened file is marked
processedonly after every emitted rule item has completed synchronousConsumeNexthandling. Cancellation leaves unfinished files retryable, while permanently malformed individual MCAP/ROS1 messages remain best-effort skips so healthy messages are not replayed forever.Safety guarantees
RWMutex; persistence and traversal operate on lock-protected snapshots.net.Listensucceeds; bind failures propagate to the command lifecycle so a later authorized status can retry.Compatibility notes
Validation
go test ./...go test -race ./cmd/coscout/commands ./internal/config ./internal/daemon ./internal/master ./internal/mod/rule/... ./pkg/mcap_ros2 -count=1go vet ./...git diff --check origin/main...HEADNew concepts
Last-known-good configuration
A last-known-good reload keeps serving the most recent complete configuration when a new candidate cannot be fully read or parsed.
flowchart LR A["Load candidate"] --> B{"All declared inputs valid?"} B -- "yes" --> C["Replace last-known-good"] B -- "no" --> D["Return error + existing last-known-good"]This is used here because runtime configuration spans a base file plus local and remote imports. Accepting only the pieces that happen to be available would silently change collection, upload, or rule behavior.
The startup loader seeds an explicit local baseline; only a complete runtime merge may replace it.
Do not use this pattern when stale configuration is more dangerous than downtime—for example, when a revoked security policy must take effect immediately.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.