From 48f27cc7ea18ae135d9d8746a5afa2cbca5dfb63 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Thu, 1 Oct 2026 19:09:29 -0400 Subject: [PATCH] chore(client): remove retry docs and benchmark harness Delete the added Markdown files and benchmark tests, and remove the dangling documentation link. --- cli/test/manual/retry_benchmark.md | 30 ------ .../manual/retry_benchmark_adapter_test.go | 18 ---- cli/test/manual/retry_benchmark_test.go | 97 ------------------- robot-docs/auth.md | 2 - robot-docs/client-requests.md | 27 ------ 5 files changed, 174 deletions(-) delete mode 100644 cli/test/manual/retry_benchmark.md delete mode 100644 cli/test/manual/retry_benchmark_adapter_test.go delete mode 100644 cli/test/manual/retry_benchmark_test.go delete mode 100644 robot-docs/client-requests.md diff --git a/cli/test/manual/retry_benchmark.md b/cli/test/manual/retry_benchmark.md deleted file mode 100644 index fe0fb7e5a..000000000 --- a/cli/test/manual/retry_benchmark.md +++ /dev/null @@ -1,30 +0,0 @@ -# Operation recovery benchmark - -Baseline: `23e4018`. Candidate: task 1a based on that revision, measured before rebasing onto main. - -Go 1.26.7, linux/amd64, AMD Ryzen 5 5600X, 12 logical CPUs. Each revision ran sequentially: one 300 ms warm-up, then five 500 ms measurements per scenario. The fixture is a local HTTP server, not the daemon; E2E tests establish real admission and durable effects. - -| Scenario | Baseline µs/op, median [range] | Candidate µs/op, median [range] | B/op, baseline → candidate | Allocs/op, baseline → candidate | Requests/effects per op, baseline → candidate | Health probes/op, baseline → candidate | -| --- | --- | --- | --- | --- | --- | --- | -| healthy-read | 67.45 [66.87–68.87] | 69.40 [67.37–70.25] | 7760 → 7761 | 91 → 91 | 1/0 → 1/0 | 0 → 0 | -| healthy-mutation | 72.82 [71.84–75.83] | 72.22 [70.95–72.39] | 9037 → 9027 | 108 → 107 | 1/1 → 1/1 | 0 → 0 | -| read-recovery | 442.25 [437.67–456.81] | 450.95 [447.11–454.75] | 54897 → 55523 | 371 → 381 | 2/0 → 2/0 | 1 → 1 | -| auth-recovery | 348.45 [348.41–351.60] | 239.84 [239.53–249.63] | 39921 → 27802 | 358 → 316 | 2/1 → 2/1 | 1 → 1 | -| lost-mutation-ack | 361.61 [358.29–367.90] | 181.22 [179.24–183.84] | 46341 → 28751 | 338 → 148 | 2/2 → 1/1 | 1 → 0 | - -Healthy-read median overhead is 1.95 µs (2.9%); healthy mutations are 0.60 µs faster, with no allocation increase in either case. A lost mutation acknowledgement now returns uncertainty after one execution; the baseline acknowledged a second execution. Its table latency is the time until that return, not daemon execution time. Auth recovery still rejects once and admits once. - -The read-recovery fixture closes successful responses, forcing the next dropped request onto a fresh socket. Both revisions perform one discovery health probe per operation, establishing that this scenario measures application recovery rather than Go’s pooled-connection retry. - -Policy and snapshot work is O(1); bounded encoding/decoding remains O(payload bytes). Recovery costs include discovery, health validation, request construction, and a second connection when needed. Explicit read recovery costs 10 additional allocations and 626 additional bytes per operation; the healthy path does not. - -Reproduce from the repository root: - -```sh -go -C cli test ./test/manual -run '^$' -bench BenchmarkOperation -benchtime=300ms -count=1 -go -C cli test ./test/manual -run '^$' -bench BenchmarkOperation -benchmem -benchtime=500ms -count=5 -``` - -For a baseline measurement, archive its `cli` tree into `/tmp`, copy `retry_benchmark_test.go` unchanged, and replace only `benchmarkRequest` with `daemon.RequestMethod[map[string]any](ctx, connection, method, "/operation", body)`. This adapter is measurement setup, not a retained compatibility test. - -Raw measurements: `/tmp/albedo-retry-baseline.txt`, `/tmp/albedo-retry-candidate.txt`; toolchain: `/tmp/albedo-retry-go-version.txt`; parsed values: `/tmp/albedo-retry-benchmark-results.json`. diff --git a/cli/test/manual/retry_benchmark_adapter_test.go b/cli/test/manual/retry_benchmark_adapter_test.go deleted file mode 100644 index 7a82cdcab..000000000 --- a/cli/test/manual/retry_benchmark_adapter_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package manual - -import ( - "albedo/cli/internal/daemon" - "context" -) - -func benchmarkRequest(ctx context.Context, connection *daemon.Connection, method string, body any, read bool) error { - policy := daemon.AuthRecovery - if read { - policy = daemon.ReadRecovery - } - result, err := daemon.RequestOperation[map[string]any](ctx, connection, daemon.Operation{ - Name: "benchmark operation", Method: method, Path: "/operation", Body: body, Policy: policy, - }) - _ = result - return err -} diff --git a/cli/test/manual/retry_benchmark_test.go b/cli/test/manual/retry_benchmark_test.go deleted file mode 100644 index ff7fa19f8..000000000 --- a/cli/test/manual/retry_benchmark_test.go +++ /dev/null @@ -1,97 +0,0 @@ -// These opt-in benchmarks isolate client recovery costs from daemon execution. -// The same bounded local HTTP fixture counts requests and mutation effects in -// every revision; real admission and persistence are exercised by E2E scenarios. -package manual - -import ( - "context" - "encoding/json" - "io" - "net" - "net/http" - "net/http/httptest" - "os" - "path/filepath" - "runtime" - "sync/atomic" - "testing" - - "albedo/cli/internal/daemon" -) - -func BenchmarkOperation(b *testing.B) { - for _, scenario := range []string{"healthy-read", "healthy-mutation", "read-recovery", "auth-recovery", "lost-mutation-ack"} { - b.Run(scenario, func(b *testing.B) { benchmarkOperation(b, scenario) }) - } -} - -func benchmarkOperation(b *testing.B, scenario string) { - var requests, effects, healthProbes atomic.Int64 - var drop atomic.Bool - server := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) { - if request.URL.Path == "/health" { - healthProbes.Add(1) - _, _ = io.WriteString(writer, `{"version":2}`) - return - } - requests.Add(1) - if request.Header.Get("Authorization") != "Bearer fixture-token" { - writer.Header().Set("Albedo-Error-Code", "authentication_required") - writer.WriteHeader(http.StatusForbidden) - _, _ = io.WriteString(writer, `{"error":"forbidden","code":"authentication_required"}`) - return - } - if request.Method == http.MethodPost { - effects.Add(1) - } - _, _ = io.Copy(io.Discard, request.Body) - if drop.Swap(false) { - socket, _, err := writer.(http.Hijacker).Hijack() - if err == nil { - _ = socket.Close() - } - return - } - if scenario == "read-recovery" { - writer.Header().Set("Connection", "close") - } - _, _ = io.WriteString(writer, `{"ok":true}`) - })) - defer server.Close() - snapshot := daemon.ConnectionSnapshot{Port: server.Listener.Addr().(*net.TCPAddr).Port, Token: "fixture-token", Version: 2} - home := b.TempDir() - encoded, err := json.Marshal(snapshot) - if err != nil { - b.Fatal(err) - } - if err := os.WriteFile(filepath.Join(home, "daemon.json"), encoded, 0o600); err != nil { - b.Fatal(err) - } - connection := daemon.NewConnection(snapshot, home) - defer connection.HTTPClient().CloseIdleConnections() - method := http.MethodPost - var payload any = map[string]string{"text": "bounded fixture mutation"} - read := scenario == "healthy-read" || scenario == "read-recovery" - if read { - method, payload = http.MethodGet, nil - } - b.ReportAllocs() - b.ResetTimer() - for range b.N { - if scenario == "auth-recovery" { - stale := snapshot - stale.Token = "expired-token" - connection.Update(daemon.NewConnection(stale, home)) - } - drop.Store(scenario == "read-recovery" || scenario == "lost-mutation-ack") - err := benchmarkRequest(context.Background(), connection, method, payload, read) - if scenario != "lost-mutation-ack" && err != nil { - b.Fatal(err) - } - runtime.KeepAlive(err) - } - b.StopTimer() - b.ReportMetric(float64(requests.Load())/float64(b.N), "requests/op") - b.ReportMetric(float64(effects.Load())/float64(b.N), "effects/op") - b.ReportMetric(float64(healthProbes.Load())/float64(b.N), "health-probes/op") -} diff --git a/robot-docs/auth.md b/robot-docs/auth.md index 83c2a3a90..d7c718d98 100644 --- a/robot-docs/auth.md +++ b/robot-docs/auth.md @@ -1,7 +1,5 @@ # model authentication -Client retry and admission rules are documented in [client request recovery](client-requests.md). - model authentication is supplied by model-provider extensions rather than the daemon configuration loader. ## credentials diff --git a/robot-docs/client-requests.md b/robot-docs/client-requests.md deleted file mode 100644 index 394f57c87..000000000 --- a/robot-docs/client-requests.md +++ /dev/null @@ -1,27 +0,0 @@ -# Client request recovery - -The daemon owns admission and execution. Clients choose a retry policy for each operation through `Operation` and `RequestOperation`. An operation without a policy uses `NoRecovery`. The contract was reviewed against `23e4018861b9dbfcf56774995db3a1af01229283`. - -| Policy | Operations | Automatic application recovery | -| --- | --- | --- | -| `ReadRecovery` | Audited core reads: health, settings, sessions, history, context, catalogs, status, authentication status, and stream establishment | At most one retry after a connection failure or a marked authentication refusal | -| `AuthRecovery` | Audited core mutations: submissions, session changes, commands, credentials, settings, and sign-in operations | At most one retry after a marked authentication refusal and changed connection credentials or address | -| `NoRecovery` | Shutdown, open-count increments, and unclassified extension operations | None | - -HTTP method and a replayable body do not establish operation safety. A command that displays a page still uses the mutation policy because the shared command endpoint also executes actions. No mutation retries follow an ambiguous network failure, and this contract introduces no operation receipts or idempotency keys. Go's HTTP transport can independently reconnect a read-only GET on a reused connection; the client does not make audited mutations replayable. - -## Admission and connection identity - -Core routes reject invalid bearer credentials before dispatch with HTTP 403 and `code: "authentication_required"`. The same marker is available in `Albedo-Error-Code` for streams that inspect error status without reading a body. An Origin refusal does not carry either marker. Extension services have their own ingress and cannot inherit this core admission guarantee merely by returning 401 or 403. - -Each attempt captures one immutable connection snapshot and derives both its address and bearer token from that value. Recovery retains the original operation context and payload. Refresh uses discovery and compatibility checks; it does not launch or replace a daemon. Failed refresh, unchanged address and token, and a second refusal return the rejection without another mutation attempt. - -Read recovery covers connection failures, including failures while reading a bounded response body. A successful stream response ends establishment recovery: errors after consuming events return to the existing stream owner, without replaying delivered events. - -## Uncertain results - -`UncertainOutcomeError` means the mutation may have been accepted. It wraps the original cause, including cancellation and HTTP errors, for `errors.Is` and `errors.As`. It contains an operation label rather than credentials or submitted content. Losing the acknowledgement does not undo execution, and cancelling a request does not prove the daemon cancelled its work. - -For a message, inspect the active conversation and its subsequent stream events before resending. For session creation, list sessions before creating another. For a command or settings change, read the affected state before repeating it. For sign-in, check the current login or accounts when its identity is available; a lost start response can leave an unknown flow that cannot be conclusively reconciled through the current API. - -Clients preserve an uncertain pending submission for stream reconciliation and do not restore it as a definitely failed send. A definite local construction error or cancellation before dispatch remains an ordinary failure. Known authentication refusals remain rejections when recovery is unavailable. Acknowledgements describe the endpoint's existing acceptance or result contract, not a new durability guarantee. -- knotmirror 0.0.1