Skip to content

Conversation

@m-005
Copy link
Member

@m-005 m-005 commented Jan 24, 2026

Part 2 of the Foundation stage for objects-node daemon.

Changes

Implements configuration loading and validation:

  • ConfigError enum with proper error types (IO, Parse, Validation)
  • from_env() - Load configuration from environment variables only
  • load_or_create() - Load from TOML file or create with defaults
  • load() and save() - TOML file I/O with parent directory creation
  • validate() - Comprehensive validation:
    • API port in valid range (1024-65535)
    • Valid IP address for bind address
    • HTTPS-only relay URLs
    • RFC-002 compliant discovery topic format
  • Environment variable overrides with proper precedence

Testing

Uses temp-env for safe environment variable testing (no unsafe blocks):

  • Config file creation and loading
  • Environment variable override tests
  • Validation error cases (invalid port, IP, URL, topic)
  • Round-trip serialization

Dependencies

  • Added temp-env for safe test environment manipulation
  • Added tempfile for temporary test directories

Part of the Foundation stage (2/4). Builds on: #34. Next: State Types (#51).

Continuation of #35 after rebasing to main.
@claude
Copy link

claude bot commented Jan 24, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

m-005 added 2 commits January 24, 2026 07:34
Security improvements:
- Add proper URL parsing and validation for relay and registry URLs
- Validate URLs have valid HTTPS scheme and non-empty hosts
- Reject malformed URLs (empty host, invalid host, malformed syntax)

Observability improvements:
- Add structured tracing logs to all config methods
- Debug logs for normal operations (load, save, validate)
- Error logs for failures with full context
- Info logs for successful operations
- Warning logs for invalid environment variables (e.g., invalid port)

Documentation:
- Remove RFC-002 reference, describe actual validation format
- Discovery topic format: /objects/{network}/{version}/discovery

Tests:
- Add tests for malformed URL validation
- All 14 tests pass with new validation logic
@m-005 m-005 force-pushed the spr/m-005/config-loading-toml-file-io-and-env-overrides branch from 702501f to eecb1d5 Compare January 24, 2026 12:44
@m-005 m-005 merged commit 78f15b8 into main Jan 24, 2026
5 checks passed
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.

2 participants