Abilities plan: Astra round 2 fixes (1 P1, 3 P2)
Follow-ups only by a fixed marker list, never by shortness; the chain owns the monthly cap and Before is authorization only; base_apps read under its own bound gate; the search credential carries its value and never prints it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+17
−8
docs/superpowers/plans/2026-11-27-assistant-abilities.md+17 −8
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:28AM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net [90m9:28AM[0m [32mINF[0m [1m1 commits scanned.[0m [90m9:28AM[0m [32mINF[0m [1mscanned ~2575336 bytes (2.58 MB) in 212ms[0m [90m9:28AM[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.7s 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.949s amadan.net/oficina/base/internal/webtest receipt: slow package 574ms amadan.net/oficina/base/internal/operations receipt: slow package 510ms amadan.net/oficina/base/internal/issuer receipt: slow package 169ms amadan.net/oficina/base/internal/consumer receipt: slow package 161ms amadan.net/oficina/base/internal/web receipt: slow test 1.52s 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 270ms 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 405af76..aefee39 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: the bound send gate, the cap, and the per-host pacer. A refusal there stops the chain, so a switch turned off while the primary answers means no request to the fallback. |
| + - `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. |
| - 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. |
| @@ -556,7 +556,7 @@ Only if jobs plan phase 1 has merged by the time `abilities-2` is rebased for me |
| - Produces: MCP plan Task 6's `Inventory`, `Config`, `Response`, `Refusal`, `New` and `Do`, at the new path, with these additions: |
| - `Config.Redirects int` (page reads 5; searches and services 0) and `Config.Timeouts` (page reads: 5 s connect, 10 s to first byte, 15 s per request, 25 s per page including redirects; searches: 10 s); |
| - `Config.UserAgent`; |
| - - `Config.Credential *Credential` with `Credential{Origin, Header, Param string}`. The guard adds the key, as a header or a query parameter, only when the request's origin equals `Origin` exactly, and refuses `Redirects > 0` with a credential. Only the two search clients set it; |
| + - `Config.Credential *Credential` with `Credential{Origin, Header, Param, Value string}`. Exactly one of `Header` and `Param` is set, or `New` refuses. The guard adds `Value`, as that header or query parameter, only when the request's origin equals `Origin` exactly, and refuses `Redirects > 0` with a credential. `Credential` implements `String`, `GoString` and `Format` as `credential(<origin>)`, so the value never prints, and guard errors never include the request URL. Only the two search clients set it; |
| - `func WithDeny(ctx context.Context, hosts []string) context.Context`, which adds per-request denied hosts to `Config.Deny`, each hop included; |
| - decompression with the limit applied after it; |
| - `Response.FinalURL`, plus `Response.Type` sniffed as one of `html`, `text`, `json`, `xml`, `feed`, or `unsupported`; |
| @@ -571,6 +571,7 @@ Only if jobs plan phase 1 has merged by the time `abilities-2` is rebased for me |
| - `TestRedirectsZeroForServices`. |
| - `TestCredentialBoundToOrigin`: a sentinel key goes only to the configured origin, a credential with redirects is refused at `New`, and a 302 from the fake vendor to another host is not followed, so that host receives nothing. |
| - `TestWithDenyEachHop`. |
| + - `TestCredentialRedacted`: `%v`, `%+v`, `%#v` and every guard error with a sentinel value omit it, and `New` refuses a credential with both or neither of `Header` and `Param`. |
| - `TestHTTPTypedTriedAsHTTPSOnce`. |
| - `TestGuardNeverDialsInTests`. |
| - `TestRefusalLogsRuleAndDomainOnly`. |
| @@ -616,7 +617,7 @@ Only if jobs plan phase 1 has merged by the time `abilities-2` is rebased for me |
| - Snippets are cut at 300 bytes and titles at 200, at a rune boundary. Results that aren't https are dropped. |
| - [ ] **Step 1: Failing tests:** |
| - - `TestMojeekParsesFixture` and `TestBraveParsesFixture`. |
| + - `TestMojeekParsesFixture` and `TestBraveParsesFixture`, each through the guard with a sentinel key that reaches the fake vendor as `api_key` and as `X-Subscription-Token` respectively. |
| - `TestMojeekStatusErrorIsLimit` (`"ERROR: Daily Limit Reached"`). |
| - `TestBrave429IsLimit`, `TestBrave401IsAuth`. |
| - `TestChainFallsBackOnError`, `TestChainFallsBackOnEmpty`, `TestChainFallsBackOnCap`. |
| @@ -627,7 +628,8 @@ Only if jobs plan phase 1 has merged by the time `abilities-2` is rebased for me |
| - `TestMisconfiguredBackendLeftOut`: no key or no cap. The log line names the backend and not the value. |
| - `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. |
| + - `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. |
| - [ ] **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. |
| @@ -708,13 +710,13 @@ CREATE INDEX chat_lookup_person ON chat_lookups(person, created_at); |
| `queries` is JSON `[{q, backend}]`. `reads` is JSON `[{url, final_url, status, bytes, sha256, code}]`. `state` is one of `running`, `shown` or `failed`. |
| - `func (t *txn) lookupPack(person string, turn turnRecord, now time.Time) (wire.LookupPack, error)`. It uses this turn's newest person message with `Origin == originComposer` in the Assistant lane, plus earlier lookup questions **only when this message is a follow-up** by `isFollowUp` (below): up to 2 earlier composer messages from turns with a `shown` or `failed` lookup in the last 30 minutes, the newest first, and never from before the person's most recent `reset` command (`notebook.go:134`) or, once MCP Task 34 lands, before the lane epoch. City and date follow AD7, and the pack is cut to 4 KiB, the oldest earlier question first. |
| - - `func isFollowUp(message string) bool` in `chat/lookup_followup.go`, a conservative instance rule. It is true only for a message of at most 6 words that either starts with a fixed follow-up marker (`and`, `what about`, `how about`, `also`, `same for`, `then`, `y`, `¿y`, `qué tal`, `y para`, compared in lower case after leading punctuation) or has at most 3 words ("Tomorrow?", "In Cork?"). Anything else is a new question, and the pack holds no earlier question. The second earlier question goes in only when the first was itself a follow-up. |
| + - `func isFollowUp(message string) bool` in `chat/lookup_followup.go`, a conservative instance rule. It is true only for a message of at most 6 words that starts with one of a fixed list of follow-up markers: `and`, `what about`, `how about`, `and for`, `same for`, `y`, `¿y`, `y para`, `qué tal`, compared in lower case after leading punctuation. Shortness alone never makes a follow-up, and when in doubt it is false. Anything else is a new question, and the pack holds no earlier question. A bare "Tomorrow?" therefore goes without history, and the query step still has the city and the date. The second earlier question goes in only when the first was itself a follow-up. |
| - `func (s *Store) lookupStep(ctx context.Context, person string, step wire.LookupStep) (wire.LookupResult, error)`. It sends on the person's primary runner connection at protocol ≥ 34, waits at most 20 s, and fails `lookup_failed` when the connection ends or the runner restarts. It accepts only a result whose `(Lookup, Attempt, Nonce, Stage)` matches, and it is never written to `runner_commands`. |
| - [ ] **Step 1: Failing tests:** |
| - `TestQuestionPackContents`. |
| - `TestPackExcludesUnrelatedHistory`. |
| - - `TestPackFollowUpOnly`: "And tomorrow?" after "What's the weather in Dublin?" holds the earlier question. "How much is a flight to Lisbon?" after a lookup about a medical clinic holds none. A chain of three follow-ups holds at most 2. |
| + - `TestPackFollowUpOnly`: "And tomorrow?" and "What about Cork?" after "What's the weather in Dublin?" hold the earlier question. After a lookup about a medical clinic, "How much is a flight to Lisbon?", "Bitcoin price?", "Dublin weather?" and "Tomorrow?" hold none. A chain of three follow-ups holds at most 2. |
| - `TestPackZoneCityAndDate` (Review Focus 2). |
| - `TestPackFourKiB`. |
| - `TestLookupStepEphemeral`: page text never appears in `runner_commands` or instance logs; a dropped connection fails the attempt and nothing is resent; a stale answer is ignored. |
| @@ -732,7 +734,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`, `Usage.Take` and the pacer, and calls `assist.Gate` and the pacer before each page read. 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`. That list is read through the base provider and 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 `Before` that calls `assist.Gate` and the pacer (never `Usage`, which the chain owns), and calls `assist.Gate` and the pacer before each page read. 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; |
| @@ -754,7 +756,7 @@ CREATE INDEX chat_lookup_person ON chat_lookups(person, created_at); |
| - `TestLookupAuditNoQuery`. |
| - `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`. |
| + - `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`. |
| - `TestRevokedDuringPrimaryNoFallback`: `web` goes off while the fake primary is answering with an error, and the fake fallback receives zero requests. |
| - `TestLookupUnsupported`: an older runner, a client without `lookup_answers`, no inventory, and no backend each leave it unlisted. |
| - `TestLookupExemptFromOutboundRule`, added with MCP Task 27. Until then it is skipped with that reason. |
| @@ -987,3 +989,10 @@ These go through Task 0.1 with the spec's register. All are DRAFT. |
| - **P2, interfaces.** `store.AbilitySet`; `goLiveByActor` and `goLiveForTask` (Tasks 4.1, 2.11). |
| - **P2, links in answers.** `lookupMarkdown` on the server, in JS and in native (Tasks 1.4 to 1.6). |
| - **P2, prompt transport.** The prompts are constants in `internal/wire/lookup_prompts.go`, selected by stage (Task 3.5). |
| + |
| +**Round 2** (Astra, 2026-11-27): NOT READY, with 1 P1 and 3 P2. All were applied. |
| + |
| +- **P1, short unrelated questions counted as follow-ups.** The three-word rule is gone. Only a fixed list of follow-up markers counts, and "Bitcoin price?" and "Dublin weather?" are negative tests (Task 3.6). |
| +- **P2, cap exhaustion versus refusal.** `Before` is authorization only. `Chain` owns the cap, and a spent cap moves to the fallback (AD3, Task 3.3). |
| +- **P2, `base_apps` under the web gate.** `baseAppOrigins` uses its own gate bound to `base_apps` (Task 3.7). |
| +- **P2, the credential's value.** `Credential.Value`, one of header or param, and redacted formatting (Task 3.1). |