Files
ngit-grasp/closed/9f23-archive-services-setting.md

72 lines
3.4 KiB
Markdown

# Archive Services Setting
**ID:** 9f23
## Problem
Operators need a way to backup/archive one or more GRASP servers by domain. Currently, there's no configuration option to selectively accept announcement events based on the services they advertise.
We need an `archive-services` setting that:
- Accepts a list of domain names (GRASP server domains to archive)
- Filters announcement event acceptance based on whether the event lists any of the configured services
- Enables relay operators to act as archival mirrors for specific GRASP servers
## Plan
- [x] Phase 1: Add `archive_grasp_services` configuration option
- Update `src/config.rs` with new field
- Update `docs/reference/configuration.md`
- Update `nix/module.nix`
- Update `.env.example`
- [x] Phase 2: Implement announcement event filtering logic
- Extract service domains from announcement events
- Compare against configured archive-grasp-services list
- Accept/reject based on match
- [x] Phase 3: Add tests for archive-grasp-services functionality
- Unit tests for configuration parsing
- Integration tests for event filtering
## Progress
### 2026-01-21 [Session Start]
- Started: Created issue for archive-services setting feature
- Started work: Created worktree 9f23-archive-services-setting
- Completed Phase 1: Added `archive-grasp-services` configuration option
- Implemented in all four sources (config.rs, docs, nix module, .env.example)
- Added validation for mutual exclusivity with archive-all and archive-whitelist
- Defaults read-only to true
- Added 9 comprehensive tests (all 61 config tests pass)
- Completed Phase 2: Implemented filtering logic
- Added `clone_url_domains()` to extract domains from announcement clone URLs
- Added `matches_grasp_services()` for case-insensitive domain matching
- Integrated filtering into `validate_announcement()` flow
- Added 8 tests for domain extraction and matching (all 390 lib tests pass)
- Decision: Only bare domains accepted (no ws:// or wss:// prefixes)
- Clone URLs use https:// scheme, domain extraction strips that prefix
- Exact case-insensitive matching ensures correct behavior
- Documentation updated to clarify bare domain requirement
- Completed Phase 3: Added integration tests
- Created tests/archive_grasp_services.rs with 4 test scenarios
- Tests matching/non-matching domains, multiple services, case-insensitivity
- All 39 integration tests pass (525 total tests)
- Simplified implementation via rebase:
- Rebased onto master with clean commit history
- Removed complex `matches_grasp_services()` function
- Reused existing `lists_service()` infrastructure
- Added `has_clone_url_with_case()` helper for case-insensitive matching
- Validation logic now uses existing methods: checks clone URLs only (archiving from other services)
- Removed 88 lines of unnecessary code, added 42 lines of simple helpers
- Net improvement: 46 lines less code, much cleaner
- Final commits: 25351fd (test helper fix), f911d00 (complete feature)
- All 39 integration tests pass
### 2026-01-21 [Session End]
- Completed: All phases finished, tests passing, ready to merge
- Merging back to main and cleaning up worktree
## Notes
- This enables relay operators to selectively mirror specific GRASP servers
- Announcement events contain service information that can be matched against the configured list
- Must maintain consistency across all four configuration sources (critical per AGENTS.md)