Skip to content

Commit 7bd089e

Browse files
gsmlgGSMLG-BOT
andauthored
feat: expand Caddy.Config.Global with 35+ typed fields and nested structs (#5)
Co-authored-by: Jonathan Gao <[email protected]>
1 parent d1272c1 commit 7bd089e

File tree

19 files changed

+3316
-54
lines changed

19 files changed

+3316
-54
lines changed

.specify/memory/constitution.md

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
<!--
22
Sync Impact Report
33
==================
4-
Version change: N/A → 1.0.0
4+
Version change: 1.0.1 → 1.1.0
5+
Modified principles: None
56
Added sections:
6-
- Core Principles (5 principles)
7-
- Quality Standards
8-
- Development Workflow
9-
- Governance
10-
Modified principles: None (initial version)
11-
Removed sections: None (initial version)
7+
- VI. Caddyfile Structure: Defines mandatory 3-part configuration architecture
8+
(global config, additionals list, site configs list)
9+
Removed sections: None
1210
Templates requiring updates:
13-
- .specify/templates/plan-template.md: ✅ Compatible (Constitution Check section exists)
14-
- .specify/templates/spec-template.md: ✅ Compatible (Requirements align with principles)
15-
- .specify/templates/tasks-template.md: ✅ Compatible (Test-first workflow supported)
11+
- .specify/templates/plan-template.md: ✅ Compatible (no changes needed)
12+
- .specify/templates/spec-template.md: ✅ Compatible (no changes needed)
13+
- .specify/templates/tasks-template.md: ✅ Compatible (no changes needed)
1614
Follow-up TODOs: None
1715
-->
1816

@@ -32,13 +30,20 @@ standardized interfaces that Elixir developers expect from production-grade libr
3230

3331
### II. Observability by Default
3432

35-
Every significant operation MUST emit telemetry events. Logging MUST use telemetry-based
36-
emission rather than direct Logger calls. Events MUST include sufficient metadata for
37-
debugging and monitoring. The `Caddy.Telemetry` module serves as the single source of truth
38-
for all observable events.
33+
Every significant operation MUST emit telemetry events. The `Caddy.Telemetry` module serves
34+
as the single source of truth for all observable events.
3935

40-
**Rationale**: Telemetry enables users to integrate Caddy operations into their existing
41-
monitoring infrastructure without coupling to specific logging implementations.
36+
**Logging Requirements**:
37+
- All logging MUST use `Caddy.Telemetry.log_*` functions (`log_debug/2`, `log_info/2`,
38+
`log_warning/2`, `log_error/2`)
39+
- Direct usage of `Logger` module (Logger.debug, Logger.info, etc.) is PROHIBITED
40+
- The default telemetry handler forwards log events to Elixir's Logger automatically
41+
- Users MAY disable the default handler and attach custom handlers for their needs
42+
43+
**Rationale**: Telemetry-based logging decouples the library from specific logging
44+
implementations. Users can integrate Caddy log events into their existing monitoring
45+
infrastructure, filter events, or route them to external services without modifying
46+
library code.
4247

4348
### III. Test-Driven Quality
4449

@@ -69,13 +74,37 @@ dependencies MUST be isolated from production builds.
6974
**Rationale**: Fewer dependencies reduce security surface, simplify upgrades, and minimize
7075
conflicts with user applications.
7176

77+
### VI. Caddyfile Structure
78+
79+
The `Caddy.Config` module MUST organize Caddyfile configuration into three distinct parts:
80+
81+
1. **Global Config**: Server-wide settings enclosed in `{ }` block at the top of Caddyfile
82+
(e.g., `debug`, `auto_https off`, admin socket configuration)
83+
2. **Additionals Config**: A list of additional configuration blocks that are NOT site
84+
definitions (e.g., named matchers, snippets, import statements). Each additional MUST
85+
be stored and retrievable independently.
86+
3. **Site Configs**: A list of site definitions, where each site has a unique identifier,
87+
address/matcher, and directive block. Sites MUST be independently addable, removable,
88+
and modifiable via API.
89+
90+
**Implementation Requirements**:
91+
- `Caddy.Config` MUST provide separate getter/setter functions for each configuration part
92+
- The generated Caddyfile MUST concatenate parts in order: global → additionals → sites
93+
- Each site MUST be identifiable by a user-provided key for targeted updates
94+
- Configuration changes MUST emit telemetry events per Principle II
95+
96+
**Rationale**: Separating configuration into logical parts enables granular management of
97+
Caddy settings. Users can modify individual sites or global settings without regenerating
98+
the entire configuration, supporting dynamic proxy management in production environments.
99+
72100
## Quality Standards
73101

74102
- **Static Analysis**: All code MUST pass `mix credo --strict` and `mix dialyzer`
75103
- **Formatting**: All code MUST pass `mix format --check-formatted`
76104
- **Documentation**: Public modules MUST have `@moduledoc`, public functions MUST have `@doc`
77105
- **Type Specs**: Public functions SHOULD have `@spec` annotations
78106
- **Test Coverage**: New features MUST include corresponding tests
107+
- **Logging**: All log statements MUST use `Caddy.Telemetry.log_*` functions
79108

80109
## Development Workflow
81110

@@ -100,4 +129,4 @@ with these principles. Reviewers SHOULD reference specific principles when reque
100129
RECOMMENDED. Non-compliant code discovered should be addressed via dedicated refactoring
101130
tasks.
102131

103-
**Version**: 1.0.0 | **Ratified**: 2025-12-15 | **Last Amended**: 2025-12-15
132+
**Version**: 1.1.0 | **Ratified**: 2025-12-15 | **Last Amended**: 2025-12-22

CLAUDE.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,11 @@ A default handler (`Caddy.Logger.Handler`) automatically forwards log events to
178178
config :caddy, attach_default_handler: false
179179
```
180180

181-
Use `Caddy.Telemetry.list_events/0` to see all available events.
181+
Use `Caddy.Telemetry.list_events/0` to see all available events.
182+
183+
## Active Technologies
184+
- Elixir ~> 1.18, OTP 27+ + Jason (JSON), Telemetry (observability), Mox (testing) (001-expand-global-config)
185+
- N/A (in-memory configuration structs) (001-expand-global-config)
186+
187+
## Recent Changes
188+
- 001-expand-global-config: Added Elixir ~> 1.18, OTP 27+ + Jason (JSON), Telemetry (observability), Mox (testing)

0 commit comments

Comments
 (0)