Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162package main
import ( "maps" "strings" "testing")
// A wire client can call HEAD just like GET. Its declared recovery policy// and audience reference must both follow it into the generated outputs.func TestHeadOperationMetadata(t *testing.T) { operation := map[string]any{"operationId": "probe", "x-albedo-audience": "client", "x-albedo-recovery": "safe-read"} outputs, err := contractMetadata(map[string]any{"paths": map[string]any{"/probe": map[string]any{"head": operation}}}) if err != nil { t.Fatal(err) } if !strings.Contains(outputs["docs/api-client.gen.md"], "HEAD /probe") || !strings.Contains(outputs["cli/internal/daemon/protocol/recovery.gen.go"], "case \"probe\":") { t.Fatal("HEAD /probe missing from generated metadata") }}
// Every change under one session declares whether clients other than an ACP// session's editor may make it, so a new route cannot skip the question the// ACP ownership sweep (e2e/acp_daemon_test.py) checks.func TestSessionChangesDeclareACPOwnership(t *testing.T) { declare := func(path, method string, extra map[string]any) error { operation := map[string]any{"operationId": "probe", "x-albedo-audience": "client", "x-albedo-recovery": "safe-read"} maps.Copy(operation, extra) _, err := contractMetadata(map[string]any{"paths": map[string]any{path: map[string]any{method: operation}}}) return err } refused := map[string]any{"x-albedo-acp-other-clients": "refused"} allowed := map[string]any{"x-albedo-acp-other-clients": "allowed", "x-albedo-acp-reason": "it only reads"} for _, accepted := range []struct { extra map[string]any path, method string }{ {refused, "/sessions/{session_id}/probe", "post"}, {allowed, "/sessions/{session_id}", "delete"}, {nil, "/sessions/{session_id}/probe", "get"}, {nil, "/sessions", "post"}, } { if err := declare(accepted.path, accepted.method, accepted.extra); err != nil { t.Errorf("%s %s %v: %v", accepted.method, accepted.path, accepted.extra, err) } } for _, rejected := range []struct { extra map[string]any path, method string }{ {nil, "/sessions/{session_id}/probe", "post"}, {map[string]any{"x-albedo-acp-other-clients": "allowed"}, "/sessions/{session_id}/probe", "patch"}, {map[string]any{"x-albedo-acp-other-clients": "maybe"}, "/sessions/{session_id}/probe", "put"}, {refused, "/sessions/{session_id}/probe", "get"}, {refused, "/sessions", "post"}, } { if err := declare(rejected.path, rejected.method, rejected.extra); err == nil { t.Errorf("%s %s %v was accepted", rejected.method, rejected.path, rejected.extra) } }}