You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Correct core-ring reflect policy: bare reflect is fine, serialization isn't
Empirically verified crypto/rand (which transitively imports reflect)
builds and links under real TinyGo (0.41.1). The old archtest rule
banned "reflect" itself as a proxy for "TinyGo doesn't support this";
that proxy was wrong — TinyGo's reflect works, it's generic
reflection-based *serialization* (struct-tag walking to encode/decode
arbitrary types) that's unreliable there. Narrowed core/internal/archtest's
forbidden list accordingly: dropped the blanket "reflect" ban, kept
encoding/json, encoding/binary, and database/sql banned by name (with
corrected rationale), and documented why fmt still isn't explicitly
banned (crypto/rand itself transitively imports fmt, so banning it would
break the very fix this commit makes).
Two concrete consequences, found by grepping every "reflect" comment in
core/adapter/client for places functionality was pushed out of core
specifically because of the old (over-broad) rule:
- core/csnet.RandomMAC is now the canonical implementation (moved from
client/link, which keeps a thin wrapper for its existing callers/API).
- core/auth gains NewCredential, generating its own random salt via
crypto/rand instead of requiring every caller to generate one and pass
it to DeriveCredential. adapter/auth/local's Store now calls it instead
of hand-rolling salt generation; that package still lives in the
adapter ring, but now correctly for its own reason (file I/O), not a
stale crypto/rand rationale.
Also, per direct instruction: core/port.ParseMAC now delegates to
core/csnet.ParseMAC (net.ParseMAC) instead of its own hand-rolled parser,
so it matches every other MAC parser in the codebase exactly. This is a
deliberate behavior change: a single-nibble octet like "0:11:22:aa:bb:cc"
is no longer accepted (net.ParseMAC has always rejected it).
Surveyed the rest of the "reflection-free" comments across core/protocol/*
et al. (hand-rolled big-endian codecs, hex formatting) — these remain
correctly scoped: encoding/binary is still banned (Read/Write are the
actual generic-serialization concern), so core/binaryprimitives and
similar hand-rolled helpers are unaffected by this policy correction.
Verified: go build/vet/test -tags all, TestCoreImportGraph (archtest),
and a real TinyGo (0.41.1) build of cmd/cs-tinygo's linux/amd64 target.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
0 commit comments