|
| @@ -96,6 +96,7 @@ func TestImportBoundaryNegativeFixtures(t *testing.T) { |
| 96 | | {"snapshot adapter accepts codec", modulePath + "/internal/adapters/snapshot", modulePath + "/internal/snapshotcodec", false, true}, | 96 | | {"snapshot adapter accepts codec", modulePath + "/internal/adapters/snapshot", modulePath + "/internal/snapshotcodec", false, true}, |
| 97 | | {"daemon accepts snapshot codec", modulePath + "/internal/usecase/daemon", modulePath + "/internal/snapshotcodec", false, true}, | 97 | | {"daemon accepts snapshot codec", modulePath + "/internal/usecase/daemon", modulePath + "/internal/snapshotcodec", false, true}, |
| 98 | | {"other adapter rejects snapshot codec", modulePath + "/internal/adapters/ipc", modulePath + "/internal/snapshotcodec", false, false}, | 98 | | {"other adapter rejects snapshot codec", modulePath + "/internal/adapters/ipc", modulePath + "/internal/snapshotcodec", false, false}, |
| | | 99 | + | {"client rejects snapshot codec", modulePath + "/internal/usecase/client", modulePath + "/internal/snapshotcodec", false, false}, |
| 99 | | {"snapshot codec rejects usecase", modulePath + "/internal/snapshotcodec", modulePath + "/internal/usecase/daemon", false, false}, | 100 | | {"snapshot codec rejects usecase", modulePath + "/internal/snapshotcodec", modulePath + "/internal/usecase/daemon", false, false}, |
| 100 | | {"snapshot codec rejects adapter", modulePath + "/internal/snapshotcodec", modulePath + "/internal/adapters/snapshot", false, false}, | 101 | | {"snapshot codec rejects adapter", modulePath + "/internal/snapshotcodec", modulePath + "/internal/adapters/snapshot", false, false}, |
| 101 | | {"snapshot adapter rejects usecase", modulePath + "/internal/adapters/snapshot", modulePath + "/internal/usecase/daemon", false, false}, | 102 | | {"snapshot adapter rejects usecase", modulePath + "/internal/adapters/snapshot", modulePath + "/internal/usecase/daemon", false, false}, |
|
| @@ -216,8 +217,10 @@ func dependencyAllowed(source, target string, testFile bool) (bool, error) { |
| 216 | | | 217 | | |
| 217 | | // packageImportDenied encodes ADR 001 ownership at package granularity for | 218 | | // packageImportDenied encodes ADR 001 ownership at package granularity for |
| 218 | | // production files. Layer rules alone permit any usecase-to-usecase import; | 219 | | // production files. Layer rules alone permit any usecase-to-usecase import; |
| 219 | - | // other, and keep the broker free of every sibling use case. Test files stay | 220 | + | // this keeps client and daemon from importing each other, keeps the broker |
| 220 | - | // exempt so composition tests can wire adapters and orchestrators together. | 221 | + | // free of every sibling use case, and limits the snapshot codec to the daemon |
| | | 222 | + | // and the snapshot adapter. Test files stay exempt so composition tests can |
| | | 223 | + | // wire adapters and orchestrators together. |
| 221 | | func packageImportDenied(source, target string) bool { | 224 | | func packageImportDenied(source, target string) bool { |
| 222 | | brokerPkg := modulePath + "/internal/usecase/broker" | 225 | | brokerPkg := modulePath + "/internal/usecase/broker" |
| 223 | | clientPkg := modulePath + "/internal/usecase/client" | 226 | | clientPkg := modulePath + "/internal/usecase/client" |
|
| @@ -227,9 +230,14 @@ func packageImportDenied(source, target string) bool { |
| 227 | | return path == root || strings.HasPrefix(path, root+"/") | 230 | | return path == root || strings.HasPrefix(path, root+"/") |
| 228 | | } | 231 | | } |
| 229 | | // The durable snapshot format is shared by the daemon and its one | 232 | | // The durable snapshot format is shared by the daemon and its one |
| 230 | - | // repository adapter; no other adapter may depend on it. | 233 | + | // repository adapter; no other adapter or use case may depend on it. |
| 231 | - | if target == modulePath+"/internal/snapshotcodec" && strings.HasPrefix(source, modulePath+"/internal/adapters/") { | 234 | + | if target == modulePath+"/internal/snapshotcodec" { |
| 232 | - | return source != modulePath+"/internal/adapters/snapshot" | 235 | + | switch { |
| | | 236 | + | case strings.HasPrefix(source, modulePath+"/internal/adapters/"): |
| | | 237 | + | return source != modulePath+"/internal/adapters/snapshot" |
| | | 238 | + | case strings.HasPrefix(source, usecasePrefix): |
| | | 239 | + | return !under(source, daemonPkg) |
| | | 240 | + | } |
| 233 | | } | 241 | | } |
| 234 | | switch { | 242 | | switch { |
| 235 | | case under(source, brokerPkg): | 243 | | case under(source, brokerPkg): |