diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-10 22:05:33 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-10 22:05:33 +0000 |
| commit | 3ac8c0cc93b7e07881ce9ba036dd9d8f8b09cb4c (patch) | |
| tree | c00a0bd8dd9b50dec0831866fe76c13749ab428a | |
| parent | fe40518a2d2d30f29b8b668c42ce2afa059d95a8 (diff) | |
docs: add 4-way config sync requirement to AGENTS.md
- Add Configuration Management section documenting 4-way sync
- Config must be consistent across: src/config.rs, docs/reference/configuration.md, nix/module.nix, and .env.example
- Include complete example showing all four formats
- Add to Critical Gotchas list (#8)
- Ensures .env.example stays accurate for development and Docker deployments
| -rw-r--r-- | AGENTS.md | 67 |
1 files changed, 67 insertions, 0 deletions
| @@ -170,6 +170,72 @@ fn test_audit_tags_automatically_added() { | |||
| 170 | - Tags enable production relay cleanup scripts | 170 | - Tags enable production relay cleanup scripts |
| 171 | - No special handling needed in test code - tags are automatic | 171 | - No special handling needed in test code - tags are automatic |
| 172 | 172 | ||
| 173 | ## Configuration Management | ||
| 174 | |||
| 175 | **⚠️ CRITICAL: Keep Configuration in Sync Across All Four Sources** | ||
| 176 | |||
| 177 | Configuration options must be consistent across four locations: | ||
| 178 | |||
| 179 | 1. **Source code** (`src/config.rs`) - Defines actual config structs, env vars, and defaults | ||
| 180 | 2. **Documentation** (`docs/reference/configuration.md`) - User-facing reference for all options | ||
| 181 | 3. **NixOS module** (`nix/module.nix`) - NixOS deployment configuration | ||
| 182 | 4. **Example env file** (`.env.example`) - Template for development and Docker deployments | ||
| 183 | |||
| 184 | **When adding/modifying ANY configuration option:** | ||
| 185 | |||
| 186 | 1. **Update `src/config.rs`** - Add/modify the field with proper env var name | ||
| 187 | 2. **Update `docs/reference/configuration.md`** - Document the option with examples and defaults | ||
| 188 | 3. **Update `nix/module.nix`** - Add/modify the NixOS option in `instanceOptions` | ||
| 189 | 4. **Update `.env.example`** - Add the option with comments explaining usage and defaults | ||
| 190 | 5. **Verify consistency** - Check env var names, defaults, and descriptions match exactly | ||
| 191 | |||
| 192 | **Critical consistency checks:** | ||
| 193 | |||
| 194 | - Environment variable names must match: `NGIT_*` in code, docs, module, and .env.example | ||
| 195 | - Default values must match across all four sources | ||
| 196 | - Option names should be consistent (snake_case in code, camelCase in NixOS) | ||
| 197 | - Descriptions should be similar (can be more detailed in docs) | ||
| 198 | |||
| 199 | **Example: Adding a new config option** | ||
| 200 | |||
| 201 | ```rust | ||
| 202 | // 1. src/config.rs | ||
| 203 | #[arg(long, env = "NGIT_NEW_OPTION", default_value_t = 42)] | ||
| 204 | pub new_option: u32, | ||
| 205 | ``` | ||
| 206 | |||
| 207 | ```markdown | ||
| 208 | <!-- 2. docs/reference/configuration.md --> | ||
| 209 | #### `NGIT_NEW_OPTION` | ||
| 210 | **Description:** What this option does | ||
| 211 | **Type:** Integer | ||
| 212 | **Default:** `42` | ||
| 213 | **Required:** No | ||
| 214 | ``` | ||
| 215 | |||
| 216 | ```nix | ||
| 217 | # 3. nix/module.nix (in instanceOptions) | ||
| 218 | newOption = mkOption { | ||
| 219 | type = types.int; | ||
| 220 | default = 42; | ||
| 221 | description = "What this option does"; | ||
| 222 | }; | ||
| 223 | |||
| 224 | # Also add to environment mapping in mkService: | ||
| 225 | environment = { | ||
| 226 | # ... | ||
| 227 | NGIT_NEW_OPTION = toString cfg.newOption; | ||
| 228 | }; | ||
| 229 | ``` | ||
| 230 | |||
| 231 | ```bash | ||
| 232 | # 4. .env.example | ||
| 233 | # What this option does | ||
| 234 | # CLI: --new-option <value> | ||
| 235 | # Default: 42 | ||
| 236 | # NGIT_NEW_OPTION=42 | ||
| 237 | ``` | ||
| 238 | |||
| 173 | ## Documentation | 239 | ## Documentation |
| 174 | 240 | ||
| 175 | **⚠️ CRITICAL: Keep Architecture Docs Updated** | 241 | **⚠️ CRITICAL: Keep Architecture Docs Updated** |
| @@ -205,6 +271,7 @@ This was a key learning from GRASP-01: docs described plans, not implementation, | |||
| 205 | 5. **Work directory:** All session docs go in `work/`, NOT root | 271 | 5. **Work directory:** All session docs go in `work/`, NOT root |
| 206 | 6. **Archive naming:** Use `YYYY-MM-DD-description.md` format | 272 | 6. **Archive naming:** Use `YYYY-MM-DD-description.md` format |
| 207 | 7. **test-ngit-relay.sh tests ngit-relay**: This script tests the reference implementation, NOT ngit-grasp | 273 | 7. **test-ngit-relay.sh tests ngit-relay**: This script tests the reference implementation, NOT ngit-grasp |
| 274 | 8. **Configuration sync:** Config changes MUST be updated in all four places: `src/config.rs`, `docs/reference/configuration.md`, `nix/module.nix`, AND `.env.example` | ||
| 208 | 275 | ||
| 209 | ## File Restrictions by Mode | 276 | ## File Restrictions by Mode |
| 210 | 277 | ||