internal/rosa: read-only access to built-ins

This removes potential footguns caused by mutable builtins without requiring unnecessary clones.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
cat
2026-08-25 14:00:42 +09:00
parent 7ee5d5368d
commit ac7abbbe3f
16 changed files with 123 additions and 94 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ var (
// handleInfo writes constant system information.
func handleInfo(w http.ResponseWriter, _ *http.Request) {
infoPayloadOnce.Do(func() {
infoPayload.Count = len(rosa.Native().Collect())
infoPayload.Count = len(rosa.Collect())
infoPayload.HakureiVersion = info.Version()
})
// TODO(mae): cache entire response if no additional fields are planned
+2 -2
View File
@@ -31,7 +31,7 @@ func TestAPIInfo(t *testing.T) {
checkPayload(t, resp, struct {
Count int `json:"count"`
HakureiVersion string `json:"hakurei_version"`
}{len(rosa.Native().Collect()), info.Version()})
}{len(rosa.Collect()), info.Version()})
}
func TestAPIGet(t *testing.T) {
@@ -92,7 +92,7 @@ func TestAPIGet(t *testing.T) {
)
})
count := len(rosa.Native().Collect())
count := len(rosa.Collect())
t.Run("index", func(t *testing.T) {
t.Parallel()
checkValidate(
+2 -2
View File
@@ -56,12 +56,12 @@ func (index *packageIndex) populate(report *rosa.Report) (err error) {
index.handleAccess = report.HandleAccess
}
handles := rosa.Native().Collect()
handles := rosa.Collect()
work := make([]*metadata, len(handles))
index.names = make(map[string]*metadata)
ir := pkg.NewIR()
for i, handle := range handles {
meta, a := rosa.Native().Std().MustLoad(handle)
meta, a := rosa.MustLoad(handle)
m := metadata{
handle: handle,