Skip to content

Conversation

@m-005
Copy link
Member

@m-005 m-005 commented Jan 21, 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 (#36).

Created using jj-spr 0.1.0
@m-005 m-005 closed this Jan 21, 2026
m-005 added a commit that referenced this pull request Jan 21, 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 (#36).

Pull Request: #39
@m-005 m-005 deleted the spr/m-005/config-loading-toml-file-io-and-env-overrides-1 branch January 23, 2026 23:26
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