detached 7ebc8f8

test(boundary): limit the snapshot codec to the daemon among use cases

commit
7ebc8f82128d39400439382709af6656b7513753
author
brice · · 2026-10-08 09:03 UTC
committer
brice · · 2026-10-08 09:31 UTC
parent
b034df2
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +13 -5
M boundary_test.go +13 -5
@@ -96,6 +96,7 @@ func TestImportBoundaryNegativeFixtures(t *testing.T) {
9696 {"snapshot adapter accepts codec", modulePath + "/internal/adapters/snapshot", modulePath + "/internal/snapshotcodec", false, true},
9797 {"daemon accepts snapshot codec", modulePath + "/internal/usecase/daemon", modulePath + "/internal/snapshotcodec", false, true},
9898 {"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},
99100 {"snapshot codec rejects usecase", modulePath + "/internal/snapshotcodec", modulePath + "/internal/usecase/daemon", false, false},
100101 {"snapshot codec rejects adapter", modulePath + "/internal/snapshotcodec", modulePath + "/internal/adapters/snapshot", false, false},
101102 {"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) {
216217
217218 // packageImportDenied encodes ADR 001 ownership at package granularity for
218219 // 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-// exempt so composition tests can wire adapters and orchestrators together.
220+// this keeps client and daemon from importing each other, keeps the broker
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.
221224 func packageImportDenied(source, target string) bool {
222225 brokerPkg := modulePath + "/internal/usecase/broker"
223226 clientPkg := modulePath + "/internal/usecase/client"
@@ -227,9 +230,14 @@ func packageImportDenied(source, target string) bool {
227230 return path == root || strings.HasPrefix(path, root+"/")
228231 }
229232 // The durable snapshot format is shared by the daemon and its one
230- // repository adapter; no other adapter may depend on it.
231- if target == modulePath+"/internal/snapshotcodec" && strings.HasPrefix(source, modulePath+"/internal/adapters/") {
232- return source != modulePath+"/internal/adapters/snapshot"
233+ // repository adapter; no other adapter or use case may depend on it.
234+ if target == modulePath+"/internal/snapshotcodec" {
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+ }
233241 }
234242 switch {
235243 case under(source, brokerPkg):
@@ -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 for218 // 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 stay220+// 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 one232 // 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):

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 12

Tags 11

↑↓ moveenter openesc close