- 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>
2.7 KiB
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.yamlmatching platform standard (withexportedrule enabled since this is a shared library) - Created
Makefilewith standard targets (build, test, vet, lint, all) - Created
.gitignore - Created
doc.gopackage doc make allpasses 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 dirsMigrationtype with Version, Name, SQL fieldsMigrate(database *sql.DB, migrations []Migration) error— sequential, transactional, idempotent, records name and timestamp in schema_migrationsSchemaVersion(database *sql.DB) (int, error)— highest applied versionSnapshot(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)
Configtype matching[mcias]TOML sectionTokenInfotype (Username, Roles, IsAdmin)New(cfg, logger)— MCIAS client with TLS 1.3, custom CA, 10s timeoutLogin,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)
Basetype embedding standard sections (Server, Database, MCIAS, Log)ServerConfigwithDurationwrapper type for TOML string decoding (go-toml v2 does not natively decode strings to time.Duration)DatabaseConfig,LogConfig,WebConfig(non-embedded, for web UIs)Durationtype with TextUnmarshaler/TextMarshaler for TOML compatibilityLoad[T any](path, envPrefix)— generic loader with TOML parse, env overrides via reflection, defaults, required field validationValidatorinterface 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 allpasses clean (vet, lint 0 issues, 41 total tests, build)
Next Steps
- Phase 4:
httpserverpackage (TLS HTTP server, middleware, JSON helpers)