| id | 2607191918 |
|---|---|
| title | Deduplicate isClaimed between internal/schema and requiredstructure |
| status | ✅ |
| model | haiku |
| summary | internal/rules/requiredstructure/rule.go carries a byte-for-byte copy of internal/schema/validate.go's isClaimed helper, despite already importing internal/schema. Flagged by the 2026-07-19 audit. |
Remove the duplicated isClaimed helper so the claimed-range
check has one implementation.
The 2026-07-19 audit (see the audit log) found this duplication:
- requiredstructure/rule.go
carries a copy of
schema/validate.go's
isClaimedhelper. - Its comment reads "Mirrors internal/schema/validate.go's isClaimed for the identical pattern" instead of reusing it.
requiredstructure/rule.goalready importsinternal/schema. This isn't an import-cycle workaround — it's a plain copy.- go.md's refactor-moves section names this exact shape: "Lift a shared dependency up to an interface... once two rules needed the same shape."
- Export the helper from
internal/schema(e.g.schema.IsClaimed) or move it to a small shared set-helper both packages can import without creating a cycle — checkinternal/schema's existing dependency direction againstrequiredstructurefirst, sincerequiredstructureimportingschemaalready establishes the direction that must hold. - Delete
requiredstructure/rule.go's private copy and call the shared helper instead. - Keep or adapt the existing test coverage for both call sites; do not remove test coverage in the move.
go build ./...passes.go test ./internal/schema/... ./internal/rules/requiredstructure/...passes.
- Only one implementation of the claimed-range check exists in the repository.
-
go test ./...is green. -
mdsmith check .is green.