Skip to content

Commit 03ae63a

Browse files
committed
fix: rename predicate functions per no-Is/Has/Can convention
Rename isConsumerLayer → consumerLayer in cross_package_types_test.go and isSyncableTool → syncableTool in steering/{format,sync}.go. isNumeric was already removed during earlier migrations. Persist session decisions and learnings. Spec: specs/ast-audit-contributor-guide.md Signed-off-by: Jose Alekhinne <jose@ctx.ist>
1 parent ec10b81 commit 03ae63a

5 files changed

Lines changed: 60 additions & 8 deletions

File tree

.context/DECISIONS.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<!-- INDEX:START -->
44
| Date | Decision |
55
|----|--------|
6+
| 2026-04-04 | TestNoMagicStrings and TestNoMagicValues no longer exempt const/var definitions outside config/ |
7+
| 2026-04-04 | String-typed enums belong in config/, not domain packages |
68
| 2026-04-03 | Output functions belong in write/ (consolidated) |
79
| 2026-04-03 | YAML text externalization pipeline (consolidated) |
810
| 2026-04-03 | Package taxonomy and code placement (consolidated) |
@@ -114,6 +116,34 @@ For significant decisions:
114116
115117
-->
116118

119+
## [2026-04-04-025755] TestNoMagicStrings and TestNoMagicValues no longer exempt const/var definitions outside config/
120+
121+
**Status**: Accepted
122+
123+
**Context**: The isConstDef/isVarDef blanket exemption masked 156+ string and 7 numeric constants in the wrong package
124+
125+
**Decision**: TestNoMagicStrings and TestNoMagicValues no longer exempt const/var definitions outside config/
126+
127+
**Rationale**: Const definitions outside config/ are magic values in the wrong place — naming them does not fix the structural problem
128+
129+
**Consequence**: All new code with string/numeric constants outside config/ fails these tests immediately
130+
131+
---
132+
133+
## [2026-04-04-025746] String-typed enums belong in config/, not domain packages
134+
135+
**Status**: Accepted
136+
137+
**Context**: Debated whether type IssueType string with const values belongs in domain or config. The string value is the same regardless of type annotation.
138+
139+
**Decision**: String-typed enums belong in config/, not domain packages
140+
141+
**Rationale**: Types without behavior belong in config. Promote to entity/ only when methods/interfaces appear.
142+
143+
**Consequence**: All type Foo string + const blocks outside config/ are now caught by TestNoMagicStrings.
144+
145+
---
146+
117147
## [2026-04-03-180000] Output functions belong in write/ (consolidated)
118148

119149
**Status**: Accepted

.context/LEARNINGS.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ DO NOT UPDATE FOR:
1717
<!-- INDEX:START -->
1818
| Date | Learning |
1919
|----|--------|
20+
| 2026-04-04 | Format-verb strings are localizable text, not exempt from magic string checks |
21+
| 2026-04-04 | Agents add allowlist entries to make tests pass — guard every exemption |
2022
| 2026-04-03 | Subagent scope creep and cleanup (consolidated) |
2123
| 2026-04-03 | Bulk rename and replace_all hazards (consolidated) |
2224
| 2026-04-03 | Import cycles and package splits (consolidated) |
@@ -106,6 +108,26 @@ DO NOT UPDATE FOR:
106108

107109
---
108110

111+
## [2026-04-04-025813] Format-verb strings are localizable text, not exempt from magic string checks
112+
113+
**Context**: Strings like '%d entries checked' were passing TestNoMagicStrings because the format-verb exemption was too broad
114+
115+
**Lesson**: Any string containing English words alongside format directives is user-facing text that belongs in YAML assets
116+
117+
**Application**: Removed format-verb, URL-scheme, HTML-entity, and err/ exemptions from TestNoMagicStrings
118+
119+
---
120+
121+
## [2026-04-04-025805] Agents add allowlist entries to make tests pass — guard every exemption
122+
123+
**Context**: Found that every exemption map/allowlist in audit tests is a tempting shortcut for agents
124+
125+
**Lesson**: Added DO NOT widen guard comments to all 10 exemption data structures across 7 test files
126+
127+
**Application**: Every new audit test with an exemption must include the guard comment. Review PRs for drive-by allowlist additions.
128+
129+
---
130+
109131
## [2026-04-03-180000] Subagent scope creep and cleanup (consolidated)
110132

111133
**Consolidated from**: 4 entries (2026-03-06 to 2026-03-23)

internal/audit/cross_package_types_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ func sameModule(a, b string) bool {
205205
}
206206
// cli/* consuming any domain module is the
207207
// standard consumer layer pattern.
208-
if isConsumerLayer(ma) && !isConsumerLayer(mb) {
208+
if consumerLayer(ma) && !consumerLayer(mb) {
209209
return true
210210
}
211-
if isConsumerLayer(mb) && !isConsumerLayer(ma) {
211+
if consumerLayer(mb) && !consumerLayer(ma) {
212212
return true
213213
}
214214
// err/<X> consumed from cli/<X> or <X>.
@@ -278,8 +278,8 @@ func moduleRoot(pkgPath string) string {
278278
return parts[0]
279279
}
280280

281-
// isConsumerLayer returns true if the module root is a
281+
// consumerLayer returns true if the module root is a
282282
// consumer layer that naturally imports domain types.
283-
func isConsumerLayer(mod string) bool {
283+
func consumerLayer(mod string) bool {
284284
return strings.HasPrefix(mod, "cli/")
285285
}

internal/steering/format.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222
ctxIo "github.com/ActiveMemory/ctx/internal/io"
2323
)
2424

25-
// isSyncableTool returns true if the tool supports native-format sync.
26-
func isSyncableTool(tool string) bool {
25+
// syncableTool returns true if the tool supports native-format sync.
26+
func syncableTool(tool string) bool {
2727
for _, t := range syncableTools {
2828
if t == tool {
2929
return true

internal/steering/sync.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var syncableTools = []string{
3636
func SyncTool(
3737
steeringDir, projectRoot, tool string,
3838
) (SyncReport, error) {
39-
if !isSyncableTool(tool) {
39+
if !syncableTool(tool) {
4040
supported := strings.Join(
4141
syncableTools, token.CommaSpace,
4242
)
@@ -116,7 +116,7 @@ func SyncAll(
116116
// Returns nil if no stale files are found or if the steering
117117
// directory cannot be read.
118118
func StaleFiles(steeringDir, projectRoot, tool string) []string {
119-
if !isSyncableTool(tool) {
119+
if !syncableTool(tool) {
120120
return nil
121121
}
122122

0 commit comments

Comments
 (0)