Abilities spec: Astra round 4 fixes (2 P1, 2 P2)
The send gate covers MCP's SendPrepared and recovery sends; every authenticated service and Oficina request checks the switch first and the registry skips switched-off providers before listing; a stored ability hold with a Try again path that resumes undispatched work; lookups only in person turns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+38
−8
docs/superpowers/specs/2026-11-26-assistant-abilities-design.md+38 −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 === [90m12:10PM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net [90m12:10PM[0m [32mINF[0m [1m1 commits scanned.[0m [90m12:10PM[0m [32mINF[0m [1mscanned ~2468126 bytes (2.47 MB) in 333ms[0m [90m12:10PM[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 10.941s 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 9.635s amadan.net/oficina/base/internal/webtest receipt: slow package 1.475s amadan.net/oficina/base/internal/issuer receipt: slow package 613ms amadan.net/oficina/base/internal/operations receipt: slow package 261ms amadan.net/oficina/base/internal/consumer receipt: slow package 173ms amadan.net/oficina/base/internal/web receipt: slow test 1.52s amadan.net/oficina/base/internal/webtest TestHomeDoesNotWaitOnAStalledSnapshot receipt: slow test 1.25s amadan.net/oficina/base/internal/webtest TestAskZoneIsToldOnce receipt: slow test 1.03s amadan.net/oficina/base/internal/issuer TestAuthorizeSignsForInstalledApp receipt: slow test 520ms amadan.net/oficina/base/internal/operations TestOperationsRefusals receipt: slow test 410ms amadan.net/oficina/base/internal/issuer TestAuthorizeRefusals === 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/specs/2026-11-26-assistant-abilities-design.md b/docs/superpowers/specs/2026-11-26-assistant-abilities-design.md| index 8aa9a1e..e9c67ea 100644 |
| --- a/docs/superpowers/specs/2026-11-26-assistant-abilities-design.md |
| +++ b/docs/superpowers/specs/2026-11-26-assistant-abilities-design.md |
| @@ -1,6 +1,6 @@ |
| # Base's Assistant can do things out of the box; admins can limit it per person |
| -Status: **draft for Paul's review**, revision 4, 2026-11-26 (after Astra rounds 1 to 3, see Review). Design only: no implementation, merge or deploy. |
| +Status: **draft for Paul's review**, revision 5, 2026-11-26 (after Astra rounds 1 to 4, see Review). Design only: no implementation, merge or deploy. |
| Paul, 2026-11-26, after asking Base "What's the weather in Dublin?" and being sent to met.ie: |
| @@ -133,7 +133,7 @@ The instance runs it in the remote-call path (`ServeRemoteCalls`, outside any tr |
| **Turns, caps and older parts.** |
| -- `web_lookup` runs only in a turn the person started, or in the resume turn after a connect that acts for one (`asked`, extended to it). A `team_update` turn can't look anything up. |
| +- `web_lookup` runs only in a turn the person started (`kind = person`), whose composer message is the pack's question. It never runs in a `team_update` turn, the resume turn after a connect included (round 4, finding 4). Those turns have no composer message of their own. If the resumed request needs a lookup, the Assistant asks the person in a line, and their reply is a person turn. |
| - Caps: 2 lookups per turn, 100 per person in a rolling 24 hours, and from the instance at most one request a second to any one host. |
| - Time: about 15 s end to end is the target, and 40 s is the limit. The reply's activity line shows meanwhile (§4.5). |
| - On a runner below `ProtocolLookup`, `web_lookup` isn't listed. |
| @@ -346,7 +346,18 @@ The two halves differ in authority and are kept apart on purpose. `Can` comes fr |
| - the gate is one short transaction that reads `switches` and checks the operation is the one bound. A switch update is a write transaction, and SQLite orders the two. |
| A call counts as **in flight** once its gate has passed. A switch turned off after that doesn't stop that one request, which finishes and is reported. Every later request is refused, including the next request of the same lookup. An operation resolved differently from the one bound is refused `operation_changed`. |
| -- **MCP's once-only dispatcher** (MCP plan Task 25, outside `ServeRemoteCalls`) reads `switches` inside its claim transaction, before anything is sent. An approved go-ahead whose person has since lost the ability expires with `ability_off`, and isn't dispatched (§7.2). |
| +- **Every send path gets the gate** (round 4, finding 1). `Registry.Invoke` isn't the only way an operation leaves. MCP's once-only dispatcher sends approved calls with `SendPrepared`, and its recovery path sends again after a restart (MCP plan Tasks 24 and 25). Each of these: |
| + - reads `switches` in its claim transaction, where an approved go-ahead whose person has since lost the ability expires with `ability_off`; |
| + - installs the same bound gate, called immediately before the operation's request, after any token refresh or other preparation. |
| + |
| + A new send path must do the same, which a test pins: every provider request that performs an operation passes through `assist.Gate`. |
| +- **Authenticated requests a person didn't ask for** (round 4, finding 2). Some requests run on a person's connection outside any `use`: |
| + - MCP's identity read after a publish (MCP plan Task 28); |
| + - `tools/list` for `look`; |
| + - Oficina's connection read; |
| + - token refresh. |
| + |
| + Each provider's authenticated client, for both services and Oficina, checks `switches` for the person, under the provider's key (`services` or `apps_read`), before **any** authenticated request. Only revocation and Disconnect are exempt, since they end access. `Registry.list` also skips a provider whose key is off before calling its `List` (`equipo:internal/equipo/assist/registry.go:78-89`), so a paused connection is never used to list either. |
| - **The refusal** answers code `ability_off` with fixed instance text naming the ability in plain words and `ask`: "Not available: <ability> is turned off for this person by <ask>. Tell them in one short line that you can't do that here and that <ask> can turn it on. Don't suggest a way round it." The audit `assistant.use` records the code. |
| - **Team operations** run on the instance inside a transaction. Each one in the `build` row checks `switches` in that transaction as its first step. |
| - **Connect cards.** `OnUnconnected` (`equipo:internal/equipo/chat_wiring.go:75-94`) raises the Oficina card only with `apps_read`, and a service card only with `services`. `POST /oficina/connect` and `/oficina/connect/finish` refuse 403 `ability_off` without `apps_read`. MCP's `/services/*` routes check through D6 (§7.2). |
| @@ -377,7 +388,13 @@ So a Research step dispatched before the switch went off doesn't start, and one |
| - **The pill says why.** The job reads `stopped`, with a new K6 row, cause `ability_off`: |
| - status: "Stopped" (approved); |
| - detail: "Building is turned off for you. <Owner> can turn it back on, or you can drop this." (DRAFT); |
| - - actions: Drop it and Dismiss. Once `build` is on again, also Try again (`retry`, K6's path), which starts the next step afresh. Drop it succeeds in this state, so T1 (no dead ends) holds. |
| + - actions: Drop it and Dismiss. Once `build` is on again, also Try again. Drop it succeeds in this state, so T1 (no dead ends) holds. |
| +- **The stop is stored, and Try again resumes it** (round 4, finding 3). A step that was never dispatched leaves no failed attempt, so K6's `retryFailed` (`equipo:internal/equipo/chat/handoff.go:1723-1752`, which needs `NeedsRetry`) can't resume it. So: |
| + - the hand-off records `ability_held_at` (a new `chat_handoffs` column) the first time the dispatcher skips one of its steps, or `Authorize` refuses one, for `ability_off`; |
| + - the job card reads that, not an attempt, for its stop row; |
| + - Try again on such a job is a new act path, `resumeAbilityHold`. In one transaction it checks the person holds `build`, clears `ability_held_at`, and puts every held task back where the dispatcher picks it up: a refused attempt becomes a fresh attempt, and an undispatched step is simply eligible again. It is idempotent per card revision and key, like every K2 action. |
| + |
| + Nothing resumes by itself. An owner turning `build` back on doesn't restart someone's work without them. |
| - **Act endpoint.** `answer`, `build`, `again` and `retry` answer 403 `ability_off` with the card as it is now, like the 409 path (jobs plan PD5). |
| ### 6.4 Equipo: going live when `go_live` is off |
| @@ -437,11 +454,12 @@ The capability gate stays what it is: a presentation switch carried by `Base-Cap |
| - D6's matrix gains `Use` as a requirement for `request`, `connect`, `use`, and managing one's own allowances. `disconnect` doesn't need it. `set_permissions` leaves the matrix, because Base sets the permissions. |
| - "Owners always hold add and review" becomes "the Base owner always holds every ability and is the admin" (§5.1). |
| - The tests keep their intent: `TestPermsDefaults` (member use and add on, review off), `TestPermsDenyWins` (an admin's off wins), `TestOwnerCannotLoseBoth`, and `TestPermissionReadInsideTx`, which now reads `switches` inside the transaction. |
| -- **Task 25 (once-only dispatch).** The claim transaction reads `switches`: no `services` (for a service) or no `apps_write` (for an Oficina go-ahead) expires the confirm with `ability_off`, and nothing is sent (§6.1). |
| +- **Tasks 24 and 25 (prepare, once-only dispatch, recovery).** The claim transaction reads `switches`: no `services` (for a service) or no `apps_write` (for an Oficina go-ahead) expires the confirm with `ability_off`, and nothing is sent. `SendPrepared` and the recovery send install the bound send gate, called right before the operation request, after any token refresh (§6.1). |
| +- **Task 28 (the account a change acts as).** The identity read after a publish goes through the service client's switch check, so it isn't made for a person without `services`. Their account label is read when the switch is next on. |
| - **Task 6 (guarded client)** moves to `internal/websource/guard` with a redirect option (§4.3). Services keep "no redirects". Whichever of lookups and MCP S1 comes first builds it. |
| - **Task 7 (instance inventory)** is shared as it is. Lookups wait for it too. |
| - **Tasks 17 and 18 (the service provider and the registry).** Service operations map to `services` in `abilityFor`. `look` leaves them out without it, and connect cards aren't raised. Their requests go through §6.1's send gate. |
| -- **Task 15 (refresh).** No refresh is attempted for a person without `services`. |
| +- **Tasks 8 and 15 (the MCP client, refresh).** The authenticated service client checks `services` before every request: list, call, identity read and refresh. Only revocation and Disconnect are exempt (§6.1). |
| - **Task 27 (outbound rule in `use`).** `web_lookup` is exempt from the allow prompt and sets no mark (§4.4). The ability check comes before the outbound rule. |
| - **Task 38 (Settings, Connections).** A connection whose person lacks `services` shows the paused line (§6.5). Disconnect stays. |
| - **Task 40 (People, service permissions)** is replaced by §8.1: the add permission is a row on the person's page, with no team-wide modes. Review stays the owner's. |
| @@ -496,6 +514,7 @@ CREATE TABLE chat_lookups (id text PRIMARY KEY, person text NOT NULL, turn_id te |
| seq integer NOT NULL, call_id text NOT NULL, state text NOT NULL, queries text, reads text, answer text, |
| sources text, code text, created_at datetime NOT NULL); |
| CREATE INDEX chat_lookup_turn ON chat_lookups(turn_id, attempt, seq); |
| +ALTER TABLE chat_handoffs ADD COLUMN ability_held_at datetime; -- §6.3 |
| ``` |
| A reply's lookups are the `shown` rows of its turn's final attempt, in `seq` order, so the message needs no column of its own. `chat_assistant_abilities` keeps one row per person in practice (§5.3, "One Base at a time"). The origin stays in the key so that a move is explicit. |
| @@ -552,9 +571,13 @@ Tests come first, and each phase follows Equipo's "headless first" rule (thin v1 |
| - `TestGateBindsOperation`: an operation that resolves differently at send is refused `operation_changed`. |
| - `TestUnmappedOperationRefused`, `TestOficinaConnectNeedsAppsRead`, `TestAppsWriteImpliesRead`. |
| - `TestApprovedConfirmExpiresWhenOff`: with MCP Task 25, a tap, then the switch off, then dispatch sends nothing. |
| + - `TestSendPreparedGate`: the switch goes off after the claim, during the token refresh, and before a recovered send. Each time nothing is sent. |
| + - `TestEveryOperationRequestGated`: walks every provider's request paths and fails if one that performs an operation skips `assist.Gate`. |
| + - `TestPausedConnectionMakesNoRequest`: with `services` off and an access token still cached, publishing a service revision makes no identity read, `look` makes no `tools/list`, and no refresh runs. Disconnect still revokes. The same holds for Oficina with `apps_read` off. |
| - **Jobs.** |
| - `TestBuildOffRefusesStart`: a step dispatched before the switch went off isn't granted. A running step keeps its grant and finishes. No later step and no housekeeping retry starts. Run now can't release it. |
| - - `TestBuildBackOnOffersRetry`, `TestBuildOffStopRowHasDrop` (T1). |
| + - `TestAbilityHoldResumes`: `build` goes off and the current step finishes. The next step stays undispatched and `ability_held_at` is set. With `build` on again, Try again dispatches it. A refused attempt resumes the same way. Turning the switch on alone resumes nothing. A double tap resumes once. |
| + - `TestBuildOffStopRowHasDrop` (T1). |
| - `TestGoLiveOffRefusesEveryPath` (answerMerge, answerPublish, MergeTask, act), `TestGoLiveOffNoAutoMerge`. |
| - `TestGoLiveOffAfterApproval`: a go-ahead, then the switch off, then `authorizeMergeLease` for `merge_request` is refused, and nothing reaches the hub. A Publish answer, then the switch off, then `authorizePublish` is refused for the start and for the deploy check. |
| - `TestResearchNeedsWeb`: `toolResearch` is refused, and so is `authorizeResearch` for a step dispatched before the switch went off. |
| @@ -577,7 +600,7 @@ Tests come first, and each phase follows Equipo's "headless first" rule (thin v1 |
| - `TestFetchSSRF`: every IP literal form, a private DNS answer among public ones, metadata, a Control-hook rebind, a redirect to a private address, https to http, a sixth redirect, `.ts.net`, the instance and Base origins, an Oficina app origin, and the inventory. |
| - `TestFetchBounds` (header, body, decompressed body, time, type sniffing), `TestNoCredentialsSent` (no cookie, Authorization, Referer or environment proxy). |
| - `TestAnswerStepBudget`: maximum-length snippets, text heavy with escaping, and multibyte titles all fit in 56 KiB serialized, with `truncated` set. |
| - - `TestLookupCaps`, `TestSecretLookingQueryRefused`, `TestLookupsOnlyInPersonTurns`, `TestLookupPageTextNotStored`, `TestLookupAuditNoQuery`. |
| + - `TestLookupCaps`, `TestSecretLookingQueryRefused`, `TestLookupsOnlyInPersonTurns` (a connect's resume turn included: refused), `TestLookupPageTextNotStored`, `TestLookupAuditNoQuery`. |
| - **Conversations against a fake backend, fake pages and a fake runner.** |
| - "What's the weather in Dublin?" gets a forecast, a sources line, and no card. |
| - "And tomorrow?" searches with the earlier question's words. |
| @@ -727,3 +750,10 @@ Model-facing instance texts (not copy; reviewed as code): the two isolated steps |
| - **P2, old clients losing answers.** A read-time plain-text fallback, never stored and never given to the Assistant (§4.6). |
| - **P2, two lookups and one reply.** An ordered list of at most 2, from the final attempt (§4.2 step 7, §4.6). |
| - **P2, page text in the persistent command queue.** `lookup_step` is a live-only frame bound to its attempt, with no transcript (§4.2 step 3). |
| + |
| +**Round 4** (Astra, 2026-11-26): NOT READY, with 2 P1 and 2 P2. All were applied in revision 5. |
| + |
| +- **P1, approved writes sent without the gate.** `SendPrepared` and recovery sends install the bound gate, and a test pins that every operation request passes through it (§6.1, §7.2). |
| +- **P1, background service calls bypassing the switch.** Authenticated clients check the switch before any request, and `Registry.list` skips switched-off providers before listing (§6.1, §7.2). |
| +- **P2, Try again for undispatched work.** `ability_held_at` on the hand-off and a `resumeAbilityHold` act path (§6.3). |
| +- **P2, lookups in a connect's resume turn.** Not allowed: lookups run only in person turns (§4.2). |