From ea247ad7b1c0ad79332e7b1ea8a6be9a52fdd0ee Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 22 Jun 2026 00:07:37 +0000 Subject: [PATCH 1/3] arch: add trivial-accessor exemption comments in workspace.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add `// no test by design — trivial accessor` to every trivial one-liner method in pkg/mdsmith/workspace.go: memFile.Close, memDir.Read and Close, memDirEntry.Name/IsDir/Type/Info, and memFileInfo.Name/Size/Mode/ModTime/IsDir/Sys. Mark plan 2606211910 complete. Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_018UGkejhkQXgkXqgii9tVKw --- pkg/mdsmith/workspace.go | 49 +++++++++++++++---- ...606211910_arch-fix-workspace-exemptions.md | 8 +-- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/pkg/mdsmith/workspace.go b/pkg/mdsmith/workspace.go index 26de66dad..35fd09ea6 100644 --- a/pkg/mdsmith/workspace.go +++ b/pkg/mdsmith/workspace.go @@ -319,7 +319,10 @@ func (f *memFile) Read(p []byte) (int, error) { return n, nil } -func (f *memFile) Close() error { return nil } +func (f *memFile) Close() error { + // no test by design — trivial accessor + return nil +} // memDir is an fs.ReadDirFile for in-memory directories. type memDir struct { @@ -333,10 +336,14 @@ func (d *memDir) Stat() (fs.FileInfo, error) { } func (d *memDir) Read([]byte) (int, error) { + // no test by design — trivial accessor return 0, &fs.PathError{Op: "read", Path: d.name, Err: fs.ErrInvalid} } -func (d *memDir) Close() error { return nil } +func (d *memDir) Close() error { + // no test by design — trivial accessor + return nil +} func (d *memDir) ReadDir(n int) ([]fs.DirEntry, error) { if n <= 0 { @@ -363,15 +370,23 @@ type memDirEntry struct { dir bool } -func (e memDirEntry) Name() string { return e.name } -func (e memDirEntry) IsDir() bool { return e.dir } +func (e memDirEntry) Name() string { + // no test by design — trivial accessor + return e.name +} +func (e memDirEntry) IsDir() bool { + // no test by design — trivial accessor + return e.dir +} func (e memDirEntry) Type() fs.FileMode { + // no test by design — trivial accessor if e.dir { return fs.ModeDir } return 0 } func (e memDirEntry) Info() (fs.FileInfo, error) { + // no test by design — trivial accessor // memDirEntry and memFileInfo share an identical field layout, so // the conversion copies name/size/dir across one-for-one. return memFileInfo(e), nil @@ -384,14 +399,30 @@ type memFileInfo struct { dir bool } -func (i memFileInfo) Name() string { return i.name } -func (i memFileInfo) Size() int64 { return i.size } +func (i memFileInfo) Name() string { + // no test by design — trivial accessor + return i.name +} +func (i memFileInfo) Size() int64 { + // no test by design — trivial accessor + return i.size +} func (i memFileInfo) Mode() fs.FileMode { + // no test by design — trivial accessor if i.dir { return fs.ModeDir | 0o555 } return 0o444 } -func (i memFileInfo) ModTime() time.Time { return time.Time{} } -func (i memFileInfo) IsDir() bool { return i.dir } -func (i memFileInfo) Sys() any { return nil } +func (i memFileInfo) ModTime() time.Time { + // no test by design — trivial accessor + return time.Time{} +} +func (i memFileInfo) IsDir() bool { + // no test by design — trivial accessor + return i.dir +} +func (i memFileInfo) Sys() any { + // no test by design — trivial accessor + return nil +} diff --git a/plan/2606211910_arch-fix-workspace-exemptions.md b/plan/2606211910_arch-fix-workspace-exemptions.md index d9717372d..cd3c16a4d 100644 --- a/plan/2606211910_arch-fix-workspace-exemptions.md +++ b/plan/2606211910_arch-fix-workspace-exemptions.md @@ -3,7 +3,7 @@ id: 2606211910 title: >- arch-fix: add trivial-accessor exemption comments in workspace.go -status: '🔲' +status: '✅' summary: >- Add one-line "no test by design" comments to the trivial one-liner methods in @@ -55,9 +55,9 @@ Future audits pass without flagging them. ## Acceptance Criteria -- [ ] Every trivial one-liner method in +- [x] Every trivial one-liner method in `pkg/mdsmith/workspace.go` carries an exemption comment. -- [ ] `go build ./...` passes. -- [ ] `mdsmith check pkg/mdsmith/workspace.go` +- [x] `go build ./...` passes. +- [x] `mdsmith check pkg/mdsmith/workspace.go` reports no new violations. From d920b52798d8f3a0f8f3fa2c92c7218df535b589 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 22 Jun 2026 00:11:59 +0000 Subject: [PATCH 2/3] test(workspace): add unit tests for Type() and Mode(), remove incorrect trivial-accessor exemption MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both memDirEntry.Type() and memFileInfo.Mode() have if/else branches; the architecture rule (tests.md §Exemptions) restricts the "no test by design" exemption to "trivial accessor with no branch". Remove the incorrect comments and add TestMemDirEntry_Type / TestMemFileInfo_Mode covering both branches of each method. --- pkg/mdsmith/workspace.go | 2 -- pkg/mdsmith/workspace_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/pkg/mdsmith/workspace.go b/pkg/mdsmith/workspace.go index 35fd09ea6..fbdc0bf16 100644 --- a/pkg/mdsmith/workspace.go +++ b/pkg/mdsmith/workspace.go @@ -379,7 +379,6 @@ func (e memDirEntry) IsDir() bool { return e.dir } func (e memDirEntry) Type() fs.FileMode { - // no test by design — trivial accessor if e.dir { return fs.ModeDir } @@ -408,7 +407,6 @@ func (i memFileInfo) Size() int64 { return i.size } func (i memFileInfo) Mode() fs.FileMode { - // no test by design — trivial accessor if i.dir { return fs.ModeDir | 0o555 } diff --git a/pkg/mdsmith/workspace_test.go b/pkg/mdsmith/workspace_test.go index f8e1d6830..a51c1b168 100644 --- a/pkg/mdsmith/workspace_test.go +++ b/pkg/mdsmith/workspace_test.go @@ -266,6 +266,30 @@ func TestMemFSGlobDoublestar(t *testing.T) { } } +// TestMemDirEntry_Type covers both branches of the fs.DirEntry.Type() path. +func TestMemDirEntry_Type(t *testing.T) { + dir := memDirEntry{name: "docs", dir: true} + if got := dir.Type(); got != fs.ModeDir { + t.Errorf("Type() dir = %v, want %v", got, fs.ModeDir) + } + file := memDirEntry{name: "a.md", dir: false} + if got := file.Type(); got != 0 { + t.Errorf("Type() file = %v, want 0", got) + } +} + +// TestMemFileInfo_Mode covers both branches of the fs.FileInfo.Mode() path. +func TestMemFileInfo_Mode(t *testing.T) { + dir := memFileInfo{name: "docs", dir: true} + if got := dir.Mode(); got != fs.ModeDir|0o555 { + t.Errorf("Mode() dir = %v, want %v", got, fs.ModeDir|0o555) + } + file := memFileInfo{name: "a.md", size: 10, dir: false} + if got := file.Mode(); got != 0o444 { + t.Errorf("Mode() file = %v, want 0o444", got) + } +} + // --- indexSlash --- // TestIndexSlash covers the four boundary cases: no slash, slash at From 49b71cb8319f82fc5648de8f91e02be9ecf6eef0 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 22 Jun 2026 00:22:09 +0000 Subject: [PATCH 3/3] fix: regenerate PLAN.md catalog after completing plan 2606211910 --- PLAN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PLAN.md b/PLAN.md index 860996e94..5b194a0cd 100644 --- a/PLAN.md +++ b/PLAN.md @@ -221,5 +221,5 @@ footer: | | 2606211907 | ✅ | | [arch-fix: split internal/engine/runner.go](plan/2606211907_arch-fix-runner-srp-split.md) | | 2606211908 | 🔲 | | [arch-fix: split internal/lint/layer0.go](plan/2606211908_arch-fix-layer0-split.md) | | 2606211909 | 🔲 | | [arch-fix: split internal/lsp/server.go](plan/2606211909_arch-fix-lsp-server-split.md) | -| 2606211910 | 🔲 | | [arch-fix: add trivial-accessor exemption comments in workspace.go](plan/2606211910_arch-fix-workspace-exemptions.md) | +| 2606211910 | ✅ | | [arch-fix: add trivial-accessor exemption comments in workspace.go](plan/2606211910_arch-fix-workspace-exemptions.md) |