| id | 2606111048 | |
|---|---|---|
| title | Consolidate tinygo compat stubs into internal/oscompat | |
| status | ✅ | |
| summary | Sixteen build-tagged compat files wrapping os.Chmod, os.SameFile, and filepath.EvalSymlinks are scattered across six packages. Consolidate them into a single internal/oscompat package. | |
| model | ||
| depends-on |
|
Move every _tinygo.go / _notinygo.go
build-tagged pair into internal/oscompat. Each
OS-compat decision lives in one place, and future
tinygo target gaps are patched there.
Plan 247 added build-tagged seams for os.Chmod,
os.SameFile, and filepath.EvalSymlinks. Seams
were added package-by-package to keep that PR
small. The result is sixteen files across six
packages:
internal/fix/chmod_tinygo.go+chmod_notinygo.gointernal/schema/chmod_tinygo.go+chmod_notinygo.gointernal/schema/evalsymlinks_tinygo.go+evalsymlinks_notinygo.gointernal/githooks/compat_tinygo.go+compat_notinygo.gointernal/rules/requiredstructure/compat_tinygo.go+compat_notinygo.gointernal/rules/crossfilereferenceintegrity/evalsymlinks_tinygo.go+evalsymlinks_notinygo.gointernal/lsp/evalsymlinks_tinygo.go+evalsymlinks_notinygo.gointernal/rules/build/evalsymlinks_tinygo.go+evalsymlinks_notinygo.go
There are also inconsistencies. The githooks
package calls its chmod var chmodFn. The fix
and schema packages call theirs chmodFile.
The two sameFile stubs return opposite values.
That difference is correct for each caller, but
there is no comment cross-referencing the two.
Create internal/oscompat with one file pair per
wrapped call:
chmod.go/chmod_tinygo.go— exportsChmod(path string, mode os.FileMode) errorsamefile.go/samefile_tinygo.go— exportsSameFile(fi1, fi2 os.FileInfo) boolevalsymlinks.go/evalsymlinks_tinygo.go— exportsEvalSymlinks(path string) (string, error)
Tinygo stubs follow the same contracts as today.
Calling packages import internal/oscompat and
delete their own pairs.
The requiredstructure caller logic stays
package-local. It returns false from
oscompat.SameFile on tinygo, then falls back to
path equality — that is correct behavior.
The TOCTOU shortcut in githooks is also
expressed by the caller, not the stub.
- Create
internal/oscompat/with the three exported wrappers and their tinygo stubs. - Update
internal/fixto importoscompat.Chmod. Deletefix/chmod_tinygo.goandfix/chmod_notinygo.go. - Update
internal/schemathe same way. Delete both chmod and evalsymlinks file pairs. AddchmodFileMu sync.Mutexif plan 2606111050 has not yet landed. - Update
internal/githooksto useoscompat.Chmod. RenamechmodFntochmodFileto match the other packages. ForsameFile, keep the caller-level tinygo seam rather than delegating tooscompat.SameFile. Delete the existing pair. - Update
internal/rules/requiredstructureto useoscompat.SameFile. Delete its pair. - Update
internal/rules/crossfilereferenceintegrityto useoscompat.EvalSymlinks. Delete its pair. - Update
internal/lspandinternal/rules/buildthe same way. - Verify the wasm build compiles and all tests pass.
-
internal/oscompatcontains the three exported wrappers; no other package has its own_tinygo.go/_notinygo.gopair for these three calls (exception:internal/githookskeeps a caller-levelsameFileseam whose tinygo stub returnstrue— a deliberate TOCTOU trade-off that cannot delegate tooscompat.SameFilewhose tinygo stub returnsfalse) -
go build ./...succeeds with the standard toolchain -
tinygo build -target wasm -o /dev/null ./cmd/mdsmith-wasm/compiles without errors - No
chmodFn/chmodFilenaming split; all packages usechmodFile - All tests pass:
go test ./... -
go tool golangci-lint runreports no issues