Skip to content

Add rollout sharding, firewall management, and encrypted config#2

Merged
TsekNet merged 2 commits intomainfrom
shard-firewall
Mar 15, 2026
Merged

Add rollout sharding, firewall management, and encrypted config#2
TsekNet merged 2 commits intomainfrom
shard-firewall

Conversation

@TsekNet
Copy link
Copy Markdown
Owner

@TsekNet TsekNet commented Mar 15, 2026

Summary

  • r.InShard(percent): percentage-based rollout sharding by hardware serial (stable, deterministic)
  • r.Firewall(name, opts): cross-platform firewall rules via native APIs (Windows COM, Linux nftables netlink, macOS pf)
  • r.Secret(key): AES-256-GCM encrypted config with compiled-in key, zero external deps
  • Renamed docs/guide.md to docs/examples.md with per-platform examples for every resource

Ref #1

Test plan

  • go test ./... passes on Linux
  • Table-driven tests cover sharding edge cases (0%, 100%, boundary)
  • Firewall rule validation rejects invalid ports/protocols
  • Config decryption fails closed on bad key/ciphertext

TsekNet added 2 commits March 15, 2026 08:34
Three new DSL capabilities:

- r.InShard(percent): percentage-based rollout sharding by hardware serial
- r.Firewall(name, opts): cross-platform firewall rules (nftables, pf, Windows registry)
- r.Secret(key): AES-256-GCM encrypted config with fail-closed decryption

Includes full test suites, input validation, platform examples, and updated docs.
Rename docs/guide.md to docs/examples.md with per-platform examples for every resource.
- Move injection-prevention comment above the validName regex where it belongs
- Rename logging_linux.go to logging_unix.go so macOS also gets syslog
- Fix design.md to say compiled-in key, not environment variable
@TsekNet TsekNet merged commit 3d6c167 into main Mar 15, 2026
1 check passed
TsekNet added a commit that referenced this pull request Mar 16, 2026
CRITICAL (#1):
- Fix kqueue fd leak in darwin file/plist watchers: explicit fd management
  instead of defer capturing stale fd

HIGH (#2-3): Shared watcher multiplexer
- New internal/watch/inotify_linux.go: single inotify+epoll fd for all file
  and sysctl watchers. Prevents hitting inotify_max_user_instances (128) at
  2000+ resources. 5 tests.
- File and sysctl watchers refactored to use shared multiplexer

HIGH (#4-6): Graph scaling
- AddEdge is now O(1) with lazy cycle detection via TopologicalLayers
- Duplicate edges silently deduplicated via edge set
- Auto-edge serviceToConfigFile uses exact config extension matching
- WouldCycle() BFS for auto-edge cycle avoidance

HIGH (#7-8): Daemon correctness
- Default Timeout to 5m when unset (prevents instant context expiry)
- Nil checks in retryManager for unknown resource IDs

HIGH (#9): DSL simplification
- Extract r.require() helper, cutting ~50 lines of boilerplate

HIGH (#10): Watcher dedup (via shared multiplexer above)

HIGH (#11): Unsafe pointer bounds
- Use unsafe.Offsetof for Windows FILE_NOTIFY_INFORMATION headerSize

HIGH (#12): DAG-aware drift remediation
- After successful Apply, schedule Check for dependent resources via Children()

MEDIUM (#13-20): Simplification + security
- Remove dead Nodes() allocation
- Systemd: NoNewPrivileges=yes, remove ProtectSystem=full
- eventMeta stores EventKind not full Event
- Remove retryManager.mu (states map is write-once)
- ResourceMeta struct embedded in all Opts (DependsOn+Critical consolidated)
- Error accumulation: []error with errors.Join, not single error
- Move isRoot() to internal/platform/root.go
- Registry watcher: re-register before sending event

LOW (#21-25): Tests, docs, minor
- Cycle detection test via TopologicalLayers
- Log dropped coalescer events
- Document Event struct and EventKind in extending.md
- Document default blueprint in Service Installation
- Rename coal -> coalescer

Ref #4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant