Files
mcdsl/PROGRESS.md
Kyle Isom 96d420ac82 Add config package: TOML loading with env overrides
- Base type with standard sections (Server, Database, MCIAS, Log)
- Duration wrapper type for TOML string→time.Duration decoding
- Generic Load[T] with TOML parse, reflection-based env overrides,
  defaults, required field validation, optional Validator interface
- Env overrides: PREFIX_SECTION_FIELD for string, duration, bool,
  []string (comma-separated)
- WebConfig exported for services with web UIs (not embedded in Base)
- 16 tests covering full/minimal configs, defaults, env overrides,
  validation, error cases

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 15:06:45 -07:00

2.7 KiB

MCDSL Progress

Current State

Phase 3 complete. The db, auth, and config packages are implemented and tested.

Completed

Phase 0: Project Setup (2026-03-25)

  • Initialized Go module (git.wntrmute.dev/kyle/mcdsl)
  • Created .golangci.yaml matching platform standard (with exported rule enabled since this is a shared library)
  • Created Makefile with standard targets (build, test, vet, lint, all)
  • Created .gitignore
  • Created doc.go package doc
  • make all passes clean

Phase 1: db — SQLite Foundation (2026-03-25)

  • Open(path string) (*sql.DB, error) — opens with WAL, FK, busy timeout 5000ms, 0600 permissions, creates parent dirs
  • Migration type with Version, Name, SQL fields
  • Migrate(database *sql.DB, migrations []Migration) error — sequential, transactional, idempotent, records name and timestamp in schema_migrations
  • SchemaVersion(database *sql.DB) (int, error) — highest applied version
  • Snapshot(database *sql.DB, destPath string) error — VACUUM INTO with 0600 permissions, creates parent dirs
  • 11 tests covering open, migrate, and snapshot

Phase 2: auth — MCIAS Token Validation (2026-03-25)

  • Config type matching [mcias] TOML section
  • TokenInfo type (Username, Roles, IsAdmin)
  • New(cfg, logger) — MCIAS client with TLS 1.3, custom CA, 10s timeout
  • Login, ValidateToken (30s SHA-256 cache), Logout
  • Error types, context helpers
  • 14 tests with mock MCIAS server and injectable clock

Phase 3: config — TOML Configuration (2026-03-25)

  • Base type embedding standard sections (Server, Database, MCIAS, Log)
  • ServerConfig with Duration wrapper type for TOML string decoding (go-toml v2 does not natively decode strings to time.Duration)
  • DatabaseConfig, LogConfig, WebConfig (non-embedded, for web UIs)
  • Duration type with TextUnmarshaler/TextMarshaler for TOML compatibility
  • Load[T any](path, envPrefix) — generic loader with TOML parse, env overrides via reflection, defaults, required field validation
  • Validator interface for service-specific validation
  • Environment overrides: PREFIX_SECTION_FIELD for strings, durations, bools, and comma-separated string slices
  • Defaults: ReadTimeout=30s, WriteTimeout=30s, IdleTimeout=120s, ShutdownTimeout=60s, Log.Level="info"
  • Required: listen_addr, tls_cert, tls_key
  • 16 tests: minimal/full config, defaults (applied and not overriding explicit), missing required fields (3 cases), env overrides (string, duration, slice, bool, service-specific), Validator interface (pass/fail), nonexistent file, invalid TOML, empty prefix
  • make all passes clean (vet, lint 0 issues, 41 total tests, build)

Next Steps

  • Phase 4: httpserver package (TLS HTTP server, middleware, JSON helpers)