Task 2: Architecture guard — keep internal/sync pure #2
Labels
No labels
data-integrity
engine
platform
procurement
remote
scaffold
ui
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Cordy/cairn-desktop#2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Depends on Task 1.
Goal
A test that fails the build if anyone imports the OS, the network, or a UI package into the sync engine. Written before there is anything to guard, so it can never regress.
Files
internal/sync/arch_test.goWhy this matters
This single constraint is what lets the whole engine be tested on the Alpine/arm64 CI runner with no network and no disk, and what keeps the UI framework swappable (Wails v3 is beta — see
docs/design-spec.md§3). If a later task appears to needos, the design is wrong. Stop and ask rather than deleting a line fromforbidden.Steps
go test ./internal/sync/ -run TestEngineHasNoForbiddenImports -v— expect PASS (nothing imported yet).git commit -s -m "test: guard internal/sync against os, net and UI imports"Note
build.ImportDirinspects non-test imports only, so test files in this package may useosfreely.Acceptance criteria
import "os"to any non-test file ininternal/syncmakes it fail.Cordy referenced this issue2026-09-10 17:45:57 +00:00
Done
What was built
internal/sync/arch_test.gowithTestEngineHasNoForbiddenImports, usinggo/buildto inspectinternal/sync's non-test imports against a forbidden list, exactly as written in the issuebuild.ImportDir(mode 0) misses files excluded by GOOS/GOARCH suffix or a build tag; switched tobuild.DefaultwithUseAllFiles = trueso those files are seen tooforbiddento also covernet,io/ioutil, andgolang.org/x/sys(previously open next tonet/http,path/filepath,syscall, wails)Tests
go vet ./...clean,go test -count=1 ./...→ok cairn.ch/desktop/internal/sync, jobtestsucceeded — green.osprobe failed before the guard existed (R7); aprobe_windows.go/osfile and a//go:build integration/net/httpfile both passed the unfixed guard and failed after theUseAllFilesfix;netandio/ioutilprobes passed before the forbidden-list extension and failed after; anx/sys/windowsprobe failed once both fixes were in place.Acceptance criteria
internal/synccontained only the test file at the first commit.import \"os\"to any non-test file makes it fail" — met for the plain case atfae5f26; the GOOS/build-tag bypass found in review was closed by42fffb1.Rulings
os, observe it fail, then remove it (not committed).git commit -s, plus Co-Authored-By trailer.build.ImportDir(".",0)misses GOOS/build-tag-excluded files; switched tobuild.Default+UseAllFiles, verified with windows- and tag-suffixed probes.forbiddenleftnet,io/ioutil,golang.org/x/sysopen; added, verified with probes for each.Deferred
forbiddennow contains bothnetandnet/http; an import ofnet/httpmatches both the exact entry and thenetprefix, sot.Errorflogs the same violation twice. Outcome (fail) is unchanged; deferred to the final review as harmless duplication.Implemented and reviewed by Claude (subagent-driven), landed on main after review and green CI.