|
4 | 4 |
|
5 | 5 | This directory contains ~60 sub-packages, each holding constants, |
6 | 6 | compiled regexes, type definitions, or text keys for a single |
7 | | -domain. This looks unusual. It's intentional. |
| 7 | +domain. This looks unusual. **It's intentional**. |
8 | 8 |
|
9 | 9 | ### The problem it solves |
10 | 10 |
|
11 | 11 | A monolithic `config` package creates a false dependency: importing |
12 | 12 | `config` to use `config.TokenBudget` also imports every regex |
13 | 13 | pattern, every MCP constant, every entry type, and every CLI flag |
14 | | -name. In Go, the package is the dependency unit — importing one |
| 14 | +name. In Go, the package is the dependency unit: importing one |
15 | 15 | symbol imports the whole package. A change to any constant in the |
16 | 16 | package marks every consumer as stale for recompilation and makes |
17 | 17 | the blast radius of any change the entire codebase. |
@@ -44,7 +44,7 @@ import "github.com/ActiveMemory/ctx/internal/config" // everything |
44 | 44 |
|
45 | 45 | - Surgical dependency tracking (change `config/mcp/tool` and only |
46 | 46 | MCP packages recompile) |
47 | | -- Zero import cycles (all sub-packages are leaves — zero internal |
| 47 | +- Zero import cycles (all sub-packages are leaves: zero internal |
48 | 48 | dependencies) |
49 | 49 | - Clear ownership (each file belongs to one domain) |
50 | 50 | - Safe to modify (changing a constant in `config/agent` cannot |
@@ -138,12 +138,12 @@ method receivers, interface participation, or business logic. A |
138 | 138 | type with `func (t IssueType) Severity() int` has outgrown |
139 | 139 | `config/` and belongs in `entity/`. |
140 | 140 |
|
141 | | -| Stage | Home | Example | |
142 | | -|-------|------|---------| |
143 | | -| Pure value enum | `config/<domain>/` | `type IssueType string` with const values | |
144 | | -| Cross-package value enum | `config/<domain>/` | Same — `config/` is already importable everywhere | |
145 | | -| Type with methods | `entity/` | `func (t IssueType) Severity() int` | |
146 | | -| Type implementing interfaces | `entity/` | `var _ fmt.Stringer = IssueType("")` | |
| 141 | +| Stage | Home | Example | |
| 142 | +|------------------------------|--------------------|---------------------------------------------------| |
| 143 | +| Pure value enum | `config/<domain>/` | `type IssueType string` with const values | |
| 144 | +| Cross-package value enum | `config/<domain>/` | Same — `config/` is already importable everywhere | |
| 145 | +| Type with methods | `entity/` | `func (t IssueType) Severity() int` | |
| 146 | +| Type implementing interfaces | `entity/` | `var _ fmt.Stringer = IssueType("")` | |
147 | 147 |
|
148 | 148 | The migration path is natural: start in `config/`, promote to |
149 | 149 | `entity/` when behavior appears. `TestCrossPackageTypes` catches |
|
0 commit comments