Commit Graph

34 Commits

Author SHA1 Message Date
92a8027dd4 feat(server): wire sampler hot-reload callback (ADR-0023 Phase 3, sub-phase 3.3) (#49)
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 14s
CI/CD Pipeline / Trigger Docker Push (push) Has been cancelled
CI/CD Pipeline / CI Pipeline (push) Has been cancelled
Co-authored-by: Gabriel Radureau <arcodange@gmail.com>
Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
2026-05-05 09:42:38 +02:00
3c73ca39d6 feat(auth): JWT TTL hot-reload + fix hardcoded 24h bug (ADR-0023 Phase 2) (#44)
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 23s
CI/CD Pipeline / CI Pipeline (push) Failing after 5m23s
CI/CD Pipeline / Trigger Docker Push (push) Has been skipped
Co-authored-by: Gabriel Radureau <arcodange@gmail.com>
Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
2026-05-05 09:09:22 +02:00
b33ad236e1 feat(config): hot-reload Phase 1 — logging.level (ADR-0023) (#42)
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 59s
CI/CD Pipeline / CI Pipeline (push) Failing after 4m3s
CI/CD Pipeline / Trigger Docker Push (push) Has been skipped
Co-authored-by: Gabriel Radureau <arcodange@gmail.com>
Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
2026-05-05 08:45:19 +02:00
03ea2a7b89 feat(auth): JWT secret retention policy + automatic cleanup loop (ADR-0021) (#41)
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 13s
CI/CD Pipeline / Trigger Docker Push (push) Has been cancelled
CI/CD Pipeline / CI Pipeline (push) Has been cancelled
Co-authored-by: Gabriel Radureau <arcodange@gmail.com>
Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
2026-05-05 08:40:27 +02:00
a2beadc458 feat(server): /api/info aggregator + frontend version footer (#40)
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 9s
CI/CD Pipeline / CI Pipeline (push) Failing after 4m48s
CI/CD Pipeline / Trigger Docker Push (push) Has been skipped
Co-authored-by: Gabriel Radureau <arcodange@gmail.com>
Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
2026-05-05 08:29:26 +02:00
ee4e8b2ee1 🎨 chore(server): apply swag fmt alignment to swagger annotations (#37)
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 8s
CI/CD Pipeline / CI Pipeline (push) Failing after 4m10s
CI/CD Pipeline / Trigger Docker Push (push) Has been skipped
Co-authored-by: Gabriel Radureau <arcodange@gmail.com>
Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
2026-05-04 07:58:51 +02:00
82feaec51f feat(bdd): parallel-safe schema-per-package isolation (T12 stage 2/2) — 2.85x speedup (#35)
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 7s
CI/CD Pipeline / CI Pipeline (push) Failing after 3m58s
CI/CD Pipeline / Trigger Docker Push (push) Has been skipped
Per-package isolated Postgres schema with migrations. Local benchmark: 12.87s sequential → 4.51s parallel = 2.85x. ADR-0025 status to Implemented. CI uses BDD_SCHEMA_ISOLATION=true.

Co-authored-by: Gabriel Radureau <arcodange@gmail.com>
Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
2026-05-03 19:42:09 +02:00
301471f728 feat(server): cache /api/v1/greet responses + admin cache flush endpoint (#29)
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 13s
CI/CD Pipeline / Trigger Docker Push (push) Has been cancelled
CI/CD Pipeline / CI Pipeline (push) Has been cancelled
Extends cache service to /api/v1/greet (per-name 60s) and adds POST /api/admin/cache/flush. ~95% Mistral autonomous via ICM workspace, trainer finalized commit/PR (test scaffold did not compile).

Co-authored-by: Gabriel Radureau <arcodange@gmail.com>
Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
2026-05-03 16:33:02 +02:00
93bd384ca8 🐛 fix(bdd): revert PR #26 schema isolation + cache flush + sequential CI tests (#28)
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 11s
CI/CD Pipeline / Trigger Docker Push (push) Has been cancelled
CI/CD Pipeline / CI Pipeline (push) Has been cancelled
Reverts PR #26 (BDD_SCHEMA_ISOLATION caused empty schemas with no tables, 500 errors). Adds sequential package execution (-p 1) + cache flush AfterScenario. AuthBDD goes from 0/5 PASS to 5/5 PASS deterministically. Parallel BDD deferred as architectural follow-up (requires per-schema migrations + dedicated connection pools).

Co-authored-by: Gabriel Radureau <arcodange@gmail.com>
Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
2026-05-03 16:28:57 +02:00
358e3df38b feat(cache): add in-memory cache service (ADR-0022 Phase 1 part 2) (#23)
All checks were successful
CI/CD Pipeline / Build Docker Cache (push) Successful in 50s
CI/CD Pipeline / CI Pipeline (push) Successful in 4m22s
CI/CD Pipeline / Trigger Docker Push (push) Successful in 6s
Phase 1 part 2 of ADR-0022 (companion to PR #22 rate-limit). In-memory cache service via go-cache, used by /api/version (60s TTL).

6/6 unit tests pass. ~95% Mistral autonomous via ICM workspace, cost €2.50 stages 01-02 (50% reduction vs T5 thanks to pre-extracted snippets in shared/).

Co-authored-by: Gabriel Radureau <arcodange@gmail.com>
Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
2026-05-03 13:24:17 +02:00
54dd0cc80f feat(server): add per-IP rate limit middleware on /api/v1/greet (#22)
All checks were successful
CI/CD Pipeline / Build Docker Cache (push) Successful in 1m3s
CI/CD Pipeline / CI Pipeline (push) Successful in 4m4s
CI/CD Pipeline / Trigger Docker Push (push) Successful in 6s
Phase 1 of ADR-0022. In-memory per-IP rate limiter on golang.org/x/time/rate. Returns 429 with Retry-After when exceeded. 7 unit tests pass. BDD scenario @skip until testserver rework. Closes #13.

~95% Mistral Vibe autonomous via ICM workspace. Cost ~6.5€ (T5 + resume + trainer commit/PR).

Co-authored-by: Gabriel Radureau <arcodange@gmail.com>
Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
2026-05-03 13:16:29 +02:00
045823ec8e feat(server): add /api/healthz endpoint with rich health info (#20)
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 17s
CI/CD Pipeline / CI Pipeline (push) Failing after 4m28s
CI/CD Pipeline / Trigger Docker Push (push) Has been skipped
Adds Kubernetes-style /api/healthz endpoint with status/version/uptime_seconds/timestamp.

Non-breaking — /api/health preserved. Includes unit test (passes locally) and BDD scenario (validated by CI).

Généré ~95% en autonomie par Mistral Vibe via workspace ICM ~/Work/Vibe/workspaces/healthz-feature/.

Co-authored-by: Gabriel Radureau <arcodange@gmail.com>
Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
2026-05-03 12:25:54 +02:00
c17fb4f9b4 🐛 fix: emit all config-loading logs in correct JSON format from the start (#16)
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 10s
CI/CD Pipeline / CI Pipeline (push) Failing after 4m14s
CI/CD Pipeline / Trigger Docker Push (push) Has been skipped
## Summary

Closes #15

When `logging.json: true` (or `DLC_LOGGING_JSON=true`), the logger was unconditionally initialised to console/text format at the top of `LoadConfig()`, so early log lines — most visibly **"Config file loaded"** — were always written as human-readable text regardless of configuration.

## Root cause

Classic chicken-and-egg: the format flag lives inside the config that is being loaded. The format-switch block only ran *after* `v.Unmarshal()`, too late for the config-file log.

## Changes

### `pkg/config/config.go`
- Add `peekJSONLogging()`: resolves the JSON flag **before** any log is emitted by (1) checking `DLC_LOGGING_JSON` directly via `os.Getenv`, then (2) doing a minimal throwaway Viper pre-read of the config file for the `logging.json` key. This mirrors Viper's own priority order without parsing the full config twice.
- Apply the resolved format immediately and emit **"Logging configured"** as the very first log line.
- Remove the now-redundant format-switch block that ran after `Unmarshal()`.

### `scripts/start-server.sh`, `test-graceful-shutdown.sh`, `test-opentelemetry.sh`
- Replace hardcoded `PROJECT_DIR` path with a dynamic `SCRIPTS_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))` derivation so scripts work from any worktree or clone location.

## Test plan
- [x] `go test ./pkg/...` — all pass
- [x] `scripts/test-graceful-shutdown.sh` — all JSON valid, all startup logs present
- [x] Manual smoke test: first line is `{"level":"info",...,"message":"Logging configured"}`, every line is valid JSON

Reviewed-on: #16
Co-authored-by: Gabriel Radureau <arcodange@gmail.com>
Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
2026-04-12 23:28:35 +02:00
5eec64e5e8 🧪 test: add JWT secret rotation BDD scenarios and step implementations (#12)
All checks were successful
CI/CD Pipeline / Build Docker Cache (push) Successful in 9s
CI/CD Pipeline / CI Pipeline (push) Successful in 4m15s
CI/CD Pipeline / Trigger Docker Push (push) Has been skipped
 merge: implement JWT secret rotation with BDD scenario isolation

- Implement JWT secret rotation mechanism (closes #8)
- Add per-scenario state isolation for BDD tests (closes #14)
- Validate password reset workflow via BDD tests (closes #7)
- Fix port conflicts in test validation
- Add state tracer for debugging test execution
- Document BDD isolation strategies in ADR 0025
- Fix PostgreSQL configuration environment variables

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Co-authored-by: Gabriel Radureau <arcodange@gmail.com>
Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
2026-04-11 17:56:45 +02:00
c1e628f339 📝 docs: update comprehensive documentation and project infrastructure
Documentation Updates:
- Enhanced AGENTS.md with user authentication details
- Updated README.md with authentication API documentation
- Added CONTRIBUTING.md guidelines for BDD testing
- Version management guide improvements
- Local CI/CD testing documentation

Project Infrastructure:
- Updated .gitignore for new file patterns
- Enhanced git hooks documentation
- YAML linting configuration
- Script improvements and organization
- Configuration management updates

API Enhancements:
- Greet service integration with authentication
- Server middleware for JWT validation
- Telemetry improvements
- Version management utilities

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-04-09 00:26:15 +02:00
a17eebc8f2 🧪 test: add comprehensive BDD test suite for user authentication
Added BDD test scenarios covering:
- User registration with validation
- Successful and failed authentication
- Admin authentication with master password
- JWT token generation and validation
- Password reset workflow
- Edge cases and error handling

BDD Features:
- 20+ authentication scenarios
- JWT validation edge cases
- Password reset security scenarios
- Input validation tests
- Error response verification

BDD Infrastructure:
- Step definitions for authentication workflows
- Test server with user management endpoints
- JWT parsing and validation utilities
- Common step patterns for reuse

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-04-09 00:25:48 +02:00
157d8e2d19 🔧 chore: update all references from DanceLessonsCoach to dance-lessons-coach
Some checks failed
CI/CD Pipeline / CI Pipeline (push) Failing after 4m0s
2026-04-06 17:27:07 +02:00
183933b43e feat: integrate swag fmt and improve CI/CD workflows
Some checks failed
Go CI/CD Pipeline / Lint and Format (push) Successful in 4m51s
Docker Build and Publish / Version Bump (push) Successful in 4m54s
Docker Build and Publish / Build and Push Docker Image (push) Failing after 2m51s
Go CI/CD Pipeline / Build and Test (push) Successful in 9m47s
Go CI/CD Pipeline / Version Management (push) Successful in 12s
- Add swag fmt to git pre-commit hook and CI/CD pipeline
- Create comprehensive CONTRIBUTING.md guide with AI section
- Update ADR-0013 with swag fmt documentation
- Fix swagger generation to include all endpoints
- Improve local testing scripts and workflows
- Update Dockerfile for better swagger handling
- Fix CI/CD workflow file references
2026-04-06 15:36:55 +02:00
e55c92735d 📊 feat: include package version in OpenTelemetry telemetry resource
- Add Version field to telemetry.Setup struct
- Include service.version attribute in OpenTelemetry resource
- Pass version.Short() from server to telemetry initialization
- Follows OpenTelemetry semantic conventions for better observability
- Enables version tracking in production traces

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-04-05 11:40:21 +02:00
a5344d6ed8 📝 docs: add comprehensive version management and CLI documentation 2026-04-05 11:28:11 +02:00
3e8c50d80a 📝 docs: comprehensive Swagger documentation skill with hierarchical tagging 2026-04-05 10:37:48 +02:00
b279a31f88 feat: implement OpenAPI/Swagger documentation with swaggo/swag
📝 docs: add comprehensive API documentation
📦 dependencies: add swaggo/swag to go.mod
🔧 chore: add go:generate directive for documentation

- Add comprehensive API documentation using swaggo/swag
- Embed OpenAPI spec in binary using go:embed
- Add Swagger UI at /swagger/
- Document all endpoints, models, and validation rules
- Add go:generate directive for easy regeneration
- Update README, AGENTS, CHANGELOG with documentation
- Finalize ADR 0013 with implementation details
- Gitignore generated docs directory

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-04-05 00:45:40 +02:00
9336178d73 📝 docs: add ADR for staged-only Git hooks formatting
- Add ADR-0012 documenting the decision to format only staged Go files
- Update ADR README.md with new entry
- Document rationale, alternatives, and verification results
- Include future considerations for monitoring and CI/CD integration

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-04-04 21:36:57 +02:00
d3b6d190d1 feat: implement input validation for API v2
- Added go-playground/validator dependency

- Created pkg/validation/ package with custom validator wrapper

- Implemented request validation for v2 greet endpoint

- Added structured validation error responses

- Extended BDD tests to cover validation scenarios

- Updated AGENTS.md with v2 API documentation

- Created ADR 0011-validation-library-selection.md

- Simplified server handler creation code

- Updated CHANGELOG with implementation details
2026-04-04 21:08:13 +02:00
875eb09fb7 feat: implement API v2 with feature flag control
- Added /api/v2/greet POST endpoint with JSON request/response

- Implemented ServiceV2 with Hello my friend <name>! greeting format

- Added api.v2_enabled feature flag (default: false)

- Extended BDD tests to cover v2 scenarios

- Maintained full backward compatibility with v1 API

- Added DLC_API_V2_ENABLED environment variable support

- Created ADR 0010-api-v2-feature-flag.md

- Updated configuration system to support API versioning
2026-04-04 20:39:46 +02:00
3c1aaea789 🔧 refactor: move log output setup to config package and change server logs to Trace level 2026-04-04 14:05:06 +02:00
7197f82f02 chore: remove unnecessary time.Sleep for log flushing
The time.Sleep(100ms) after OpenTelemetry shutdown was removed as it's
not necessary for proper log writing. Zerolog automatically flushes logs
on program exit, and the remaining 1-second sleep for readiness
propagation is sufficient.

Tested that all shutdown logs are properly written without the sleep.
2026-04-04 13:35:10 +02:00
9855f521f3 Refactor server architecture: move internal logic to pkg/server package
- Simplify cmd/server/main.go from 158 to 57 lines (64% reduction)

- Move HTTP server creation, graceful shutdown, and context management to pkg/server

- Add Run() method to encapsulate server lifecycle management

- Maintain all existing functionality and OpenTelemetry integration

- Improve separation of concerns and code organization

This refactoring makes cmd/server/main.go a thin entrypoint while moving all server implementation details to the pkg/server package, following Go best practices for package organization.

Add server and greet binaries to .gitignore
2026-04-04 12:48:51 +02:00
Mistral Vibe
36f0b79b90 Add OpenTelemetry instrumentation with middleware-only approach 2026-04-04 12:19:48 +02:00
Gabriel Radureau
f986711974 Add readiness endpoint for graceful shutdown coordination
Implement readiness endpoint (/api/ready) that returns:
- {"ready":true} (HTTP 200) during normal operation
- {"ready":false} (HTTP 503) during graceful shutdown

Key changes:
- Added readiness context to control readiness state
- Modified server.NewServer() to accept readiness context
- Implemented handleReadiness() with context-aware logic
- Updated cmd/server/main.go to manage readiness state
- Readiness set to false when shutdown signal received
- Updated test script to validate readiness behavior
- Added comprehensive documentation for readiness endpoint

This allows Kubernetes/service meshes to stop routing traffic
to the pod during graceful shutdown while allowing existing
requests to complete. Health endpoint continues to return
happy status during shutdown for proper orchestration.
2026-04-03 19:53:14 +02:00
Gabriel Radureau
7c5e61c386 Implement comprehensive graceful shutdown with JSON logging
- Added signal.NotifyContext for modern signal handling in cmd/server/main.go
- Implemented BaseContext for proper context propagation to HTTP handlers
- Added readiness drain delay before shutdown for graceful degradation
- Fixed PID detection in start-server.sh to target actual server process
- Added Logging.JSON configuration option with DLC_LOGGING_JSON environment variable
- Created comprehensive test script that validates entire server lifecycle
- Updated documentation with JSON logging configuration examples
- All shutdown logs now appear correctly in JSON format
- Server terminates gracefully on SIGTERM with proper log flushing

The graceful shutdown implementation follows VictoriaMetrics best practices:
1. Catches termination signals (SIGTERM, SIGINT)
2. Stops accepting new requests but allows ongoing requests to complete
3. Waits for active requests to finish within configured timeout
4. Releases resources and performs cleanup
5. Logs all shutdown steps for observability

Test script validates:
- Server startup and API functionality
- Graceful shutdown sequence
- JSON log format validation
- Complete log sequence verification
- Proper signal handling and context propagation

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-04-03 19:23:23 +02:00
Gabriel Radureau
736ec9c996 Add server control script and improve logging
\n- Add scripts/start-server.sh for easy server management\n- Add DLC_NO_COLOR environment variable support for clean logs\n- Update server.go to handle color/no-color logging\n- Add server.log and server.pid to .gitignore\n- Update README.md and AGENTS.md with server control documentation\n- Test all server control functions (start, stop, restart, status, logs, test)
2026-04-03 16:06:00 +02:00
Gabriel Radureau
e52870480d Enhance server with context initialization and graceful shutdown
- Added context-aware server initialization in cmd/server/main.go
- Implemented graceful shutdown handling with SIGINT/SIGTERM signals
- Added 30-second shutdown timeout for active connections
- Updated Greet service to use context.Context as first parameter
- Enhanced Zerolog integration with Trace level logging
- Added context-aware logging in Greet function calls
- Fixed route structure to use /api/v1/greet/* prefix
- Updated all handlers and tests to use context
- Comprehensive AGENTS.md documentation with verified commands
- Added server context management architecture section
- Updated API endpoint documentation with working examples

Changes:
- cmd/server/main.go: Complete rewrite with context and graceful shutdown
- pkg/greet/greet.go: Added context parameter and trace logging
- pkg/greet/api_v1.go: Updated interface and handlers for context
- pkg/greet/greet_test.go: Updated tests to use context
- cmd/greet/main.go: Updated CLI to use context
- pkg/server/server.go: Trace level config and context logging
- AGENTS.md: Comprehensive documentation update
- go.mod/go.sum: Added Zerolog dependency

All tests passing, server working with graceful shutdown verified.
2026-04-03 13:39:50 +02:00
Gabriel Radureau
6365f92359 Refactor to JSON API with Chi router and interface-based design
- Add pkg/greet/api_v1.go with ApiV1Greet interface and handler
- Implement Greeter interface for dependency injection
- Return JSON responses with proper Content-Type headers
- Move greet service instantiation to server package
- Separate v1 route registration into registerApiV1Routes function
- Health endpoint at /api level, greet endpoints at /api/v1/greet
- Simplify server entrypoint by removing external dependencies
2026-04-03 13:04:33 +02:00