Merge origin/master into v1: proxy test fix, helpers_test.go given

This commit is contained in:
2026-09-25 04:56:33 -07:00
4 changed files with 55 additions and 1 deletions
+3 -1
View File
@@ -22,6 +22,7 @@ real `store`, `lease.Table`, `limiter` and `health.Table`.
## Files ## Files
- Copy (**replaces** v0's file): `internal/proxy/proxy_test.go` - Copy (**replaces** v0's file): `internal/proxy/proxy_test.go`
- Copy: `internal/proxy/helpers_test.go` (the `fakeHealth` helper that v0's `proxy_test.go` held and `recorder_test.go` still needs)
- Modify: `internal/proxy/proxy.go` (split into more files if it passes 400 lines: `proxy.go`, `tee.go`, `hosts.go`), `docs/implementer-log.md` - Modify: `internal/proxy/proxy.go` (split into more files if it passes 400 lines: `proxy.go`, `tee.go`, `hosts.go`), `docs/implementer-log.md`
- Keep: `internal/proxy/recorder_test.go` from v0.1 — it must still pass. Its `proxy.New(cfg, h, nil)` - Keep: `internal/proxy/recorder_test.go` from v0.1 — it must still pass. Its `proxy.New(cfg, h, nil)`
call no longer compiles, so **this is the one given test you edit**: change that call to call no longer compiles, so **this is the one given test you edit**: change that call to
@@ -97,7 +98,8 @@ func SplitRoute(path string) (route, rest string, ok bool)
## Steps ## Steps
- [ ] **1. Copy (replace).** `git switch v1`; `cp docs/plans/v1/_files/internal/proxy/proxy_test.go internal/proxy/proxy_test.go`. - [ ] **1. Copy (replace).** `git switch v1`; `cp docs/plans/v1/_files/internal/proxy/proxy_test.go internal/proxy/proxy_test.go`;
`cp docs/plans/v1/_files/internal/proxy/helpers_test.go internal/proxy/`.
Edit the one call in `internal/proxy/recorder_test.go` as described above. Edit the one call in `internal/proxy/recorder_test.go` as described above.
- [ ] **2. See it fail** (compile). **3. Write the code.** `gofmt -w internal/proxy/`. - [ ] **2. See it fail** (compile). **3. Write the code.** `gofmt -w internal/proxy/`.
- [ ] **4. See it pass.** `go test -race -count=1 ./internal/proxy/`. `TestDifferentConversationsSpreadByFreeSlots` - [ ] **4. See it pass.** `go test -race -count=1 ./internal/proxy/`. `TestDifferentConversationsSpreadByFreeSlots`
+10
View File
@@ -92,3 +92,13 @@ tools/run-plan.sh docs/plans/v1 # from a clean checkout on master
`lease.Table.Candidates` and has the admin and `main` register configured hosts; `lease.Table.Candidates` and has the admin and `main` register configured hosts;
`TestQueueFullIs503` read the store right after the responses without the retry loop the `TestQueueFullIs503` read the store right after the responses without the retry loop the
accounting test has. Task 05 restarted from a clean tree on the corrected files. accounting test has. Task 05 restarted from a clean tree on the corrected files.
- 2026-09-25, task 05, first session: ended after ~25 min without a commit or a row, 6 of 8 given
tests passing. Three things happened. (a) My replacement `proxy_test.go` dropped the
`fakeHealth` helper that v0.1's `recorder_test.go` uses; Ornith recreated it as
`helpers_test.go` — right call, unlisted file; it is now a given file (task fault). (b) My
fake upstream's `/v1/models` handler did not record requests, so `TestV0BehaviourStillHolds`
read an empty record — test fault, fixed. (c) Ornith tried to write an experiment under `/tmp`,
the sandbox refused, and it ended its turn with "Let me experiment…" and no tool call — the
known Ornith failure mode (I9), here triggered by a denied tool. Model fault; task 05 now says
a refusal is not a reason to stop. The tee's token extraction (`TestAccountingRows…`) was the
genuinely unfinished part. Resumed from the working tree.
@@ -0,0 +1,39 @@
package proxy_test
import (
"sync"
"git.wntrmute.dev/kyle/crossbar/internal/health"
)
// fakeHealth is a hand-set health table that also records MarkDown calls. It lived in the v0
// proxy_test.go; the v1 given test replaces that file, so recorder_test.go (which still exercises
// the nil-lease path through proxy.New) needs it here.
type fakeHealth struct {
mu sync.Mutex
st map[string]health.Status
marked []string
}
func (f *fakeHealth) Get(name string) (health.Status, bool) {
f.mu.Lock()
defer f.mu.Unlock()
s, ok := f.st[name]
return s, ok
}
func (f *fakeHealth) MarkDown(name, reason string) {
f.mu.Lock()
defer f.mu.Unlock()
f.marked = append(f.marked, name)
s := f.st[name]
s.Healthy = false
s.LastErr = reason
f.st[name] = s
}
func (f *fakeHealth) markedHosts() []string {
f.mu.Lock()
defer f.mu.Unlock()
return append([]string{}, f.marked...)
}
@@ -43,6 +43,9 @@ func newUpstream(t *testing.T, name string) *upstream {
mux := http.NewServeMux() mux := http.NewServeMux()
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, `{"status":"ok"}`) }) mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, `{"status":"ok"}`) })
mux.HandleFunc("/v1/models", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("/v1/models", func(w http.ResponseWriter, r *http.Request) {
u.mu.Lock()
u.last = recorded{r.Method, r.URL.RequestURI(), r.Host, r.Header.Get("X-Forwarded-For"), ""}
u.mu.Unlock()
fmt.Fprint(w, `{"object":"list","data":[{"id":"shared"},{"id":"`+name+`-only"}]}`) fmt.Fprint(w, `{"object":"list","data":[{"id":"shared"},{"id":"`+name+`-only"}]}`)
}) })
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {