Abilities plan: Astra round 5 fixes (1 P1, 1 P2)
Searches get the bound gate at the last hop, after pacing and DNS, with the cap reservation returned on refusal; Settings and abilities_off read Equipo's effective board with the member's own bearer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+16
−5
docs/superpowers/plans/2026-11-27-assistant-abilities.md+16 −5
CI passed — run details
CI log
=== build === CGO_ENABLED=0 go build ./... === vet === go vet ./... === fmt-check === === staticcheck === go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 ./... === govulncheck === go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./... No vulnerabilities found. === gitleaks === [90m9:38AM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net [90m9:38AM[0m [32mINF[0m [1m1 commits scanned.[0m [90m9:38AM[0m [32mINF[0m [1mscanned ~2584497 bytes (2.58 MB) in 220ms[0m [90m9:38AM[0m [32mINF[0m [1mno leaks found[0m === budget === go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget size budget size: 22 directories within budget === script-test === scripts/prepare-apps_test.sh ok releases lookup failure stops before ship ok app owned elsewhere stops the script ok apps listing failure stops before create ok ambiguous release dir is refused ok explicit version resolves the ambiguity ok releases match is exact, not substring ok shipped version is only promoted, existing app not created ok fresh account creates, ships, promotes to edge, enables ok failing promote stops the script ok ship is retried while uploads are rate limited all passed hack/fonts_test.sh fonts_test: ok === test === go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -count=1 ./... receipt: test step 6.62s against a 60s target (the gate's other steps are not in this figure) receipt: 16 packages ran, 0 cached, 6 without tests, 0 failed receipt: slow package 5.91s amadan.net/oficina/base/internal/webtest receipt: slow package 714ms amadan.net/oficina/base/internal/issuer receipt: slow package 580ms amadan.net/oficina/base/internal/operations receipt: slow package 170ms amadan.net/oficina/base/internal/consumer receipt: slow package 162ms amadan.net/oficina/base/internal/web receipt: slow test 1.51s amadan.net/oficina/base/internal/webtest TestHomeDoesNotWaitOnAStalledSnapshot receipt: slow test 1.07s amadan.net/oficina/base/internal/webtest TestAskZoneIsToldOnce receipt: slow test 510ms amadan.net/oficina/base/internal/operations TestOperationsRefusals receipt: slow test 480ms amadan.net/oficina/base/internal/issuer TestAuthorizeSignsForInstalledApp receipt: slow test 220ms amadan.net/oficina/base/internal/webtest TestAskZoneAgainOnANewConnection === native === strings: copy review's strings.json is not here (git-ignored); its comparison skipped strings: 119 in the catalog, 116 used worktree-lib_test: ok
diff --git a/docs/superpowers/plans/2026-11-27-assistant-abilities.md b/docs/superpowers/plans/2026-11-27-assistant-abilities.md| index 9223781..b7bef67 100644 |
| --- a/docs/superpowers/plans/2026-11-27-assistant-abilities.md |
| +++ b/docs/superpowers/plans/2026-11-27-assistant-abilities.md |
| @@ -66,7 +66,7 @@ Neither the jobs plan nor the MCP plan has landed any code on either main. |
| - **AD3 One search interface; Mojeek first, Brave as fallback (Ruling Q1).** New Equipo package `internal/websearch`: |
| - `type Searcher interface { Name() string; Search(ctx context.Context, query string, n int) ([]Result, error) }` with `Result{Title, URL, Snippet, Date string}`, and failures as `*websearch.Error{Backend, Class string}`, where `Class` is one of `limit`, `auth`, `unavailable`, `bad_response`. An `Error` never carries a URL, a query or a key, because Go's `*url.Error` would print the Mojeek key, which travels in the query string. |
| - Backends: `mojeek` (`GET https://www.mojeek.com/search?api_key=…&q=…&fmt=json&t=8&date=1`. `response.status` is `"OK"`, or an error text such as `"ERROR: Daily Limit Reached"`, which counts as `limit`. Results come from `response.results[]` `{url, title, desc, date}`) and `brave` (`GET https://api.search.brave.com/res/v1/web/search?q=…&count=8` with `X-Subscription-Token`. Results come from `web.results[]` `{title, url, description, age}`. 429 counts as `limit`, 401 and 403 as `auth`). Both go through the guarded client (Task 3.1). The executor confirms the field names against each vendor's API docs before writing the fixtures. |
| - - `Chain{Primary, Fallback Searcher; Usage Usage}` tries the fallback, once per query, when the primary fails for any class, when its monthly cap is spent, or when it returns no results. A failed fallback means no more tries. `Chain.Search` takes a `Before` hook that runs immediately before **each** backend request, the fallback's included. `Before` is authorization only, meaning the bound send gate and the per-host pacer, and any refusal from it stops the whole chain, so a switch turned off while the primary answers means no request to the fallback. The cap belongs to `Chain` alone: after `Before` passes, `Chain` reserves one query on that backend with `Usage.Take`, which is atomic. A spent cap is not a refusal but a reason to try the fallback (its own `Before`, then its own `Take`). A reservation is made only for a request that is about to be sent. |
| + - `Chain{Primary, Fallback Searcher; Usage Usage}` tries the fallback, once per query, when the primary fails for any class, when its monthly cap is spent, or when it returns no results. A failed fallback means no more tries. `Chain.Search` takes a `Before` hook that runs immediately before **each** backend request, the fallback's included. `Before` is authorization only, meaning the bound send gate and the per-host pacer, and any refusal from it stops the whole chain, so a switch turned off while the primary answers means no request to the fallback. The cap belongs to `Chain` alone: after `Before` passes, `Chain` reserves one query on that backend with `Usage.Take`, which is atomic. A spent cap is not a refusal but a reason to try the fallback (its own `Before`, then its own `Take`). The **final** authorization is the bound gate installed with `guard.WithBeforeHop` on the context the lookup passes to `Chain.Search`. The search client's guard calls it after pacing, DNS and address checks, immediately before sending, for primary and fallback alike. If it refuses, nothing is sent, `Chain` returns the reservation with `Usage.Return`, and the chain stops. So each request actually sent holds exactly one reservation. |
| - Search requests use their own guarded client: `Redirects: 0`, so a 3xx is `bad_response` and never followed, and the key is set only on a request to the backend's fixed origin (`https://www.mojeek.com`, `https://api.search.brave.com`). The page-reading client carries no key and allows no extra headers. |
| - Config, all operator-held: `EQUIPO_WEB_SEARCH` (`mojeek` or `brave`), `EQUIPO_WEB_SEARCH_FALLBACK` (`brave`, `mojeek` or empty), `EQUIPO_MOJEEK_KEY`, `EQUIPO_BRAVE_KEY`, `EQUIPO_MOJEEK_MONTHLY_CAP` and `EQUIPO_BRAVE_MONTHLY_CAP` (queries per UTC calendar month, an integer above 0). Keys are stored with `carlos secrets set` from 1Password (vault "Oficina") and never committed. Swapping the backend is a config change. A backend that is named but has no key or no cap is left out. The instance logs `web_search.misconfigured backend=<name>`, never the value. With no usable backend, `web_lookup` isn't listed. |
| - The cap is counted on the instance in `chat_web_search_usage(backend, month, used)` (Task 3.3), incremented in the gate transaction before each request, so it holds even where a vendor has no cap of its own. Once both caps are spent the lookup fails `lookup_limit`. The operator also sets the vendor-side cap where the vendor offers one. |
| @@ -625,7 +625,7 @@ Only if jobs plan phase 1 has merged by the time `abilities-2` is rebased for me |
| **Interfaces:** |
| - Produces: |
| - `func NewMojeek(key string, g guard.Config) (Searcher, error)` and `func NewBrave(key string, g guard.Config) (Searcher, error)`, each building its own guarded client from a copy of `g` with `Redirects: 0` and its `Credential` (Mojeek: param `api_key` on `https://www.mojeek.com`; Brave: header `X-Subscription-Token` on `https://api.search.brave.com`); |
| - - `type Usage interface { Take(ctx context.Context, backend string) (ok bool, err error) }`, backed by `chat_web_search_usage(backend text, month text, used integer, PRIMARY KEY(backend, month))` with `month` as `2006-01` UTC, where `Take` increments only while `used < cap`; |
| + - `type Usage interface { Take(ctx context.Context, backend string) (ok bool, err error); Return(ctx context.Context, backend string) error }`, backed by `chat_web_search_usage(backend text, month text, used integer, PRIMARY KEY(backend, month))` with `month` as `2006-01` UTC, where `Take` increments only while `used < cap`; |
| - `type Before func(ctx context.Context, backend string) error` and `func (c Chain) Search(ctx context.Context, q string, n int, before Before) (results []Result, backend string, err error)`, which calls `before` immediately before each backend request; |
| - `func FromConfig(cfg Config, g guard.Config, usage Usage) (Chain, bool, error)`, where `g` is the base guard configuration (inventory, deny list, resolver) shared with the page client, `false` means no usable backend, and an error means a constructor refused its configuration (a code bug, so boot fails); |
| - `websearchtest.Fake{Results map[string][]Result; Fail map[string]*Error; Calls []string}`. |
| @@ -644,7 +644,7 @@ Only if jobs plan phase 1 has merged by the time `abilities-2` is rebased for me |
| - `TestSearchErrorsNeverCarryKey` (Review Focus 1). |
| - `TestNoPersonDataInSearchRequest`: the request carries only `q`, the count, the format and the key. |
| - `TestBeforeRunsForEachBackend`: `before` is called once for the primary and once for the fallback, and a refusal from it for the fallback means no fallback request and no reservation. |
| - - `TestCapReservedOncePerRequest`: the primary is spent and the fallback is free, so there is one fallback request and one reservation; both spent gives `lookup_limit` with no request; a refused `before` reserves nothing. |
| + - `TestCapReservedOncePerRequest`: the primary is spent and the fallback is free, so there is one fallback request and one reservation; both spent gives `lookup_limit` with no request; a refused `before` reserves nothing; a refusal at the final hop gate returns its reservation. |
| - [ ] **Step 2:** Run `CGO_ENABLED=0 go test ./internal/websearch/... ./internal/equipo -run 'Mojeek|Brave|Chain|MonthlyCap|BackendSwap|Misconfigured|SearchErrors|NoPersonData' -count=1`. Expected: FAIL. |
| - [ ] **Step 3:** Implement. |
| - [ ] **Step 4:** Run. Expected: PASS. |
| @@ -749,7 +749,7 @@ CREATE INDEX chat_lookup_person ON chat_lookups(person, created_at); |
| - Consumes: `assist.Gate` (Task 2.7), `guard.Client` (3.1), `websource.Readable` (3.2), `websearch.Chain` (3.3), `lookupPack` and `lookupStep` (3.6), and `callFrom(ctx)` for the call row. |
| - Produces: |
| - Provider `web`, with one operation: `web_lookup`, `ReadOnly: true`, input schema `{"type":"object","additionalProperties":false}`, and description exactly as in spec §4.1. |
| - - `func (s *Store) webLookup(ctx context.Context, call toolCallRecord) (json.RawMessage, error)` runs spec §4.2 steps 1 to 8. It reads `websource.Mentions` first, at most 3, from the composer message (step 2). It refuses a query that `websource.LooksSecret` flags. It passes `Chain.Search` a `Before` that calls `assist.Gate` and the pacer (never `Usage`, which the chain owns), and reads each page with `guard.WithBeforeHop` set to the pacer for that host, then `assist.Gate`, so every hop of a redirect chain is paced and gated, not just the first. It builds the per-lookup deny list with `func (s *Store) lookupDeny(ctx context.Context, person string) ([]string, error)`: the instance origin, every `EQUIPO_ASSISTANT_HOSTS` origin, oficina-connect's origin and the forge host from config, plus the origins of the person's Oficina apps from `base_apps`. The app origins come from `func (s *Store) baseAppOrigins(ctx context.Context, person string) ([]string, error)`, an instance-owned call to `Registry.Invoke` for `base_apps` on a context carrying its **own** gate, `assist.WithGate(ctx, s.sendGate(person, baseAppsOp))`, bound to that operation. The lookup's web gate is kept for searches and reads only. The list is cached per person in memory, refreshed when older than 60 s and kept for at most 10 minutes. With no list available, the lookup fails `lookup_failed`. The list is passed through `guard.WithDeny`. It enforces 1 request per second per host through `type hostPacer struct` on the Store (keyed by host, in memory) and the 40 s limit through the context. It returns only the fixed `shown` result, or a failure code, as model-facing text. |
| + - `func (s *Store) webLookup(ctx context.Context, call toolCallRecord) (json.RawMessage, error)` runs spec §4.2 steps 1 to 8. It reads `websource.Mentions` first, at most 3, from the composer message (step 2). It refuses a query that `websource.LooksSecret` flags. It passes `Chain.Search` a context carrying `guard.WithBeforeHop` (the bound `assist.Gate`, the final check before each search request is sent) and a `Before` that waits on the pacer and then runs an early `assist.Gate` to stop the chain (never `Usage`, which the chain owns), and reads each page with `guard.WithBeforeHop` set to the pacer for that host, then `assist.Gate`, so every hop of a redirect chain is paced and gated, not just the first. It builds the per-lookup deny list with `func (s *Store) lookupDeny(ctx context.Context, person string) ([]string, error)`: the instance origin, every `EQUIPO_ASSISTANT_HOSTS` origin, oficina-connect's origin and the forge host from config, plus the origins of the person's Oficina apps from `base_apps`. The app origins come from `func (s *Store) baseAppOrigins(ctx context.Context, person string) ([]string, error)`, an instance-owned call to `Registry.Invoke` for `base_apps` on a context carrying its **own** gate, `assist.WithGate(ctx, s.sendGate(person, baseAppsOp))`, bound to that operation. The lookup's web gate is kept for searches and reads only. The list is cached per person in memory, refreshed when older than 60 s and kept for at most 10 minutes. With no list available, the lookup fails `lookup_failed`. The list is passed through `guard.WithDeny`. It enforces 1 request per second per host through `type hostPacer struct` on the Store (keyed by host, in memory) and the 40 s limit through the context. It returns only the fixed `shown` result, or a failure code, as model-facing text. |
| - Listed only when all of these hold: |
| - the turn's kind is `person`; |
| - the primary speaks protocol 34 or later; |
| @@ -772,6 +772,7 @@ CREATE INDEX chat_lookup_person ON chat_lookups(person, created_at); |
| - `TestAnswerStepBudget`. |
| - `TestRevokedMidLookupStopsNextRequest` (Review Focus 5). |
| - `TestOficinaAppOriginRefused`: a publicly addressed app origin from `base_apps` is refused when typed and when reached by a redirect. `TestDenyUnavailableFailsClosed`. `TestLookupDenyReadsBaseAppsThroughOwnGate`: with the real registry and Base HTTP provider and an empty cache, the lookup reads `base_apps` and proceeds, with no `operation_changed` or `ability_unmapped`. |
| + - `TestRevokedWhileSearchWaits`: `web` goes off while a search waits on the pacer, and again while it waits on the resolver. Neither the primary nor the fallback receives a request. |
| - `TestRevokedDuringRedirectStops`: `web` goes off while the first response (a 302) arrives, and the redirect's target receives nothing. |
| - `TestSameHostRedirectPaced`: a same-host redirect waits for the 1-second pace. |
| - `TestRevokedDuringPrimaryNoFallback`: `web` goes off while the fake primary is answering with an error, and the fake fallback receives zero requests. |
| @@ -936,10 +937,15 @@ Planning only: the executor runs this with the operator. No key is printed. |
| ### Task 4.6 (Base): The person's own line, on the web and in the app |
| -**Files:** `internal/web/settings.go`, `internal/web/templates/settings.html` (a row in the Ask Base section), `internal/web/api.go` (`/api/v1/me` gains `abilities_off`, a list of plain names), `native/apple/Sources/BaseKit/` (the Settings row), `Localizable.xcstrings`, `internal/webtest/settings_test.go`, `internal/webtest/api_test.go`, native tests. |
| +**Files:** `internal/web/settings.go`, `internal/web/templates/settings.html` (a row in the Ask Base section), `internal/web/api.go` (`/api/v1/me` gains `abilities_off`, a list of plain names), |
| + |
| +**Interfaces:** Both the Settings line and `abilities_off` come from Equipo's effective board, `OwnAbilities` (Task 4.3) with the **signed-in member's** Equipo bearer, never from Base's stored rows, so operator-fixed and implied keys are included (spec §5.5). When Equipo can't be reached or the member has no Equipo connection, the row isn't shown and `abilities_off` is omitted. Nothing claims everything is on without Equipo saying so. The owner gets no row. |
| + |
| +**Files (cont.):** `native/apple/Sources/BaseKit/` (the Settings row), `Localizable.xcstrings`, `internal/webtest/settings_test.go`, `internal/webtest/api_test.go`, native tests. |
| - [ ] **Step 1: Failing tests:** |
| - `TestSettingsOwnLine`: "all", "some" with names and the owner, and nothing for the owner. |
| + - `TestSettingsLineFromEquipo`: with operator-fixed `web=off`, the line names web; with `apps_read` off, it names apps_write as well; with Equipo unavailable, there is no row and `abilities_off` is absent. |
| - `TestApiMeAbilitiesOff`. |
| - Native: `testSettingsAbilitiesLine`, `testAbilityOffStopRow` and `testReadyGoLiveOff`. The last two draw the stop and ready details from the card's own fields. |
| - [ ] **Step 2:** Run `go test ./internal/webtest -run 'SettingsOwnLine|ApiMeAbilitiesOff' -count=1` and `make native-check`. Expected: FAIL. |
| @@ -1030,3 +1036,8 @@ These go through Task 0.1 with the spec's register. All are DRAFT. |
| - **P2, a check package `equipo` couldn't call.** `chat.Store.Allowed`, exported, reached through `s.Chat()`, and given to the Oficina provider as a callback (Tasks 2.7 and 2.8). |
| - **P2, the search constructors.** `guard.New` returns an error, and `FromConfig` takes a `guard.Config` (Tasks 3.1 and 3.3, with MCP's handover in 5.3). |
| - **P2, zero retention.** Mojeek's written confirmation is part of Task 0.2's done condition, and Task 3.11 checks it before lookups go on. |
| + |
| +**Round 5** (Astra, 2026-11-27): NOT READY, with 1 P1 and 1 P2. Both were applied. |
| + |
| +- **P1, a search could pass authorization and then wait.** The bound gate also runs through the search client's `WithBeforeHop`, right before sending, with the reservation returned on a refusal (AD3, Tasks 3.3 and 3.7). |
| +- **P2, the Settings line's source.** It reads `OwnAbilities` with the member's own bearer, and shows nothing when Equipo is unavailable (Task 4.6). |