Repository navigation
✨ ask: hive backend and hub relay for optional Ask AI help - #19204
clubanderson wants to merge 8 commits into
Conversation
Adds the ask config block and HIVE_ASK_* env (off by default, inert when unconfigured, key only from a file under the allowed secret dirs), the pkg/askai service (Kapa Chat API client pinned to the published QueryResponse schema, per-person consent store, credential-shape refusal, source allowlist, plain-text answers, per-person/per-hive/hub-wide limits, circuit breaker, content-free audit lines) and the hub routes GET /api/ask/status, PUT/DELETE /api/ask/consent, POST /api/ask and GET /api/ask/stats. Routes are registered only when the feature is on. Fixes #19180 Signed-off-by: Andy Anderson <andy@clubanderson.com>
…sleep The Kapa Chat request is a model request (machine, reasonModelPrompt) in the new outbound-sites inventory from v5. The in-flight test now waits on a channel instead of polling with time.Sleep, keeping the sleep ratchet. Signed-off-by: Andy Anderson <andy@clubanderson.com>
Lifts pkg/askai over the 90% package floor: bad vendor JSON, an invalid thread id dropped, cancellation, the half-open breaker's single trial, handle eviction, idle-counter pruning, corrupt consent records and the service defaults. Signed-off-by: Andy Anderson <andy@clubanderson.com>
Adds the ask block to hive.yaml (vendor ids never serialised to JSON and redacted in the config export), the hive dashboard routes GET /api/ask/status, PUT/DELETE /api/ask/consent and POST /api/ask (404 while off), per-person consent on the hive keyed by dashboard identity, direct mode with the hive's own key, and hub mode through a new POST /api/hub/ask/relay on the hub. The relay authenticates the hive with its per-hive heartbeat bearer, serves hosted hives only in this round, honours a per-hive disable list and an hourly per-hive quota, and binds conversation handles to the hive. Settings, Features gains the Ask switch, mode and section-label toggle. Fixes #19183 Signed-off-by: Andy Anderson <andy@clubanderson.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. ℹ️ Sentinel: informational, author is trusted (owner), merge is not blocked. Head
No @clubanderson this PR is held at Failing checks:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. |
Open PR overlap checkBase branch:
Conflicts are checked with every PR merged onto the current tip of
|
Signed-off-by: Andy Anderson <andy@clubanderson.com>
UI render evidenceRender evidence captured. Built from
These are fixture renders, not live data: the page was built from the PR head and filled with synthetic data from |
Signed-off-by: Andy Anderson <andy@clubanderson.com>
There was a problem hiding this comment.
Read pkg/askai/consent.go, pkg/dashboard/api_ask.go and the shared ask-panel.js at this head. The consent path is bounded to one safe path segment, the person comes from the authenticated request and never the body, every route 404s while Ask is off, and the panel renders only with textContent plus https allowlisted links. Looks sound to me; one low-severity note is on the line below. I did not read the relay (relay.go, hub/ask_relay.go) or the hub-side limits in depth.
-- hive: agent=reviewer backend=claude model=claude-sonnet-5-5 claude=2.1.327
| if identity == "" { | ||
| return "" | ||
| } | ||
| if consentStemPattern.MatchString(identity) { |
There was a problem hiding this comment.
Low: PersonKey returns the identity itself when it already matches the safe-stem pattern, and otherwise h- plus 40 hex of a hash. A username that is literally h-<40 hex> shares a stem with the hashed form of some other identity (an email), so the two would read and write the same consent file. It needs a username shaped like that, so the risk is small, but a one-line fix is to hash every identity, or to reject safe-stem identities that start with h-.
… in the dashboard ratchet Signed-off-by: Andy Anderson <andy@clubanderson.com>
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Merge state is dirty (conflicts with v5). This is a human-authored branch, so the scanner will not push to it; please rebase onto v5 (stacked phases may need rebasing in order). 🐝 Hive Agent: |
|
scanner: this PR is CONFLICTING with v5 (stacked Ask AI phases). Human-authored, so deferring: rebase onto v5 once the earlier phase merges. Not pushing to this branch. 🐝 Hive Agent: |
|
hive/scanner: this PR has merge conflicts with v5 (mergeable_state=dirty). It is human-authored, so the hive will not push to it. Please rebase or merge v5 (stacked Ask AI phases usually need rebasing in order). Deferred until the conflict is resolved. 🐝 Hive Agent: |
|
Scanner: this PR is in a conflicting (dirty) state against its base. Not rebasing from here since it is a human-authored branch; please rebase/merge the base and push. Note that #19202, #19204 and #19206 look like a stack, so rebase in order. 🐝 Hive Agent: |
Phase 4 of the Ask AI help design (
src/docs/design/dashboard-ask-ai-help.md): the hive backend and the hub relay. Builds on #19200 (phase 1:pkg/askai, theaskconfig type and the hub service), so until #19200 merges this diff also shows phase 1; merge #19200 first. The phase 4 changes are the commit "ask: hive backend and hub relay for optional Ask AI help". Independent of the hub panel (#19202).Fixes #19183
What it does
ask:is now ahive.yamlblock (ask.enabled,ask.mode,ask.kapa.*,ask.send_section_label,ask.limits.*), env wins as for the other feature switches.ask.kapa.project_idandask.kapa.integration_idarejson:"-", so no API that encodes the config returns them, and the config export redacts everyask.kapavalue. The hub-only relay settings stay env (HIVE_ASK_RELAY_*); the hub has nohive.yaml.GET /api/ask/status,PUT/DELETE /api/ask/consent,POST /api/ask. Every one answers404while Ask is off or not fully configured. The person is the authenticated dashboard identity (session, or the hub-verified identity on a hosted spoke), never a body field. Consent is one0600file per person under/data/ask-consents/, keyed by the identity (hashed when it is not a safe file name).direct(a self-hosted hive with its own key file, same service as the hub) andhub(a hosted hive). In hub mode the hive validates the question, refuses credential-shaped input, checks consent and its own per-person limits, then posts only{question, section, conversation}toPOST /api/hub/ask/relaywith its per-hive heartbeat bearer andX-Hive-ID. It never holds or sends a vendor key, re-filters the hub's answer (sources allowlist, plain text, its own docs link and AI label) and keeps the hub's conversation handle behind a local one bound to the person. A relay refusal (404/401/403) becomes the docs-link fallback; it never falls back to a key.byo-) hives only in this round (HIVE_ASK_RELAY_HIVES, defaulthosted;noneturns it off;registeredis accepted and treated ashosted, with aTODO(#19177)and a one-time warning: self-hosted registered hives later);HIVE_ASK_RELAY_DISABLED_HIVESrefuses single hives; per-hive hourly quota (60,HIVE_ASK_LIMIT_HIVE_PER_HOUR) inside the hub-wide limits; conversation handles are bound to the hive, so hive B cannot continue hive A's thread.hub).Tests (behaviour)
{integration_id, query}with the closed-list label, seeded login and hive id never appear, credential-shaped questions refused, person from the request only, withdrawal blocks; key and vendor ids never in logs.X-API-KEY; self-hosted or hub-less hives stay off with a reason.byo-hives getrelay_disabled(or 401) with zero vendor calls; hive B cannot reuse hive A's handle; the per-hive quota charges hive A only;noneandregisteredmodes.RelayAsker: exact body, re-filtering of hostile sources, links, label and docs URL, unknown outcomes and hub errors as fallbacks, local per-person limits;Service.Relayskips person caps but not the hive cap.ask.kapa.Docs: new operator guide
src/docs/ask-ai-help.md(linked from the documentation map and Settings), relay section inhub-deployment.md, API reference rows (hive and hub), OpenAPI for the four hive operations, telemetry row updated.static/index.htmlregenerated fromstatic-src/(manifest concatenation).