Repository navigation
Conversation
Adds the hub backend for the optional Ask AI help, off by default and inert: - `ask:` config block and HIVE_ASK_* env overrides; if enabled but a value is missing or the key file is unusable it stays off and logs one warning without values. The key file must sit under the allowed secret directory. Project and integration ids are redacted from the config export and never appear in JSON. - pkg/ask: vendor Chat API client (non-streamed, key in X-API-KEY, only integration_id and query sent, response shape pinned by a contract test), source allowlist, limits (person, hive, hub-wide per minute, in flight, daily), circuit breaker, server-side thread handles bound to the person with a TTL, and audit lines with outcome and counts only. - Hub: per-person consent record (own file, atomic, 0600, text_version, grant and withdraw, deleted with the user), POST /api/ask behind a browser session that refuses credential-shaped input with FindSecret, and an admin counter. With the switch off every route answers 404. Tests use a fake vendor server and assert the exact request body, that seeded secrets, repo and hive names and logins never leave, and that consent, limits and the breaker hold. Closes #19180 Hive-Run: #19180 Hive-Plan: dashboard-ask-ai-help phase 1 (hub backend) Hive-Spec: dashboard-ask-ai-help#phase-1 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Danathar <Danathar@users.noreply.github.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 |
Open PR overlap checkBase branch:
Conflicts are checked with every PR merged onto the current tip of
|
…oute registration The Ask AI routes shifted pkg/hub/server.go registration lines, so 34 citations in api-reference/hub-server.md drifted. Rewritten with src/scripts/check-api-reference-citations.sh --fix; the checker now passes. Hive-Run: #19180 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Danathar <Danathar@users.noreply.github.com>
|
Follow-up on the two failing checks:
The other prow notice is only the pending OWNERS approval, which needs a maintainer. 🤖 Generated with Claude Code 🐝 Hive Agent: |
|
@Danathar this PR is back in your court ( Review asks:
Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path. Your relay session received this as a |
There was a problem hiding this comment.
Decision needed: @clubanderson should decide which Ask AI phase 1 backend survives, #19200 (pkg/askai) or this one (pkg/ask), since both close #19180 and cannot both merge.
This conflicts with #19200 rather than complementing it. Both implement phase 1 of the Ask AI help backend for #19180 (the body of #19200 says Fixes #19180), and I compared the two diffs' file sets, routes, env constants and bodies, not every line of the roughly 3,000 lines each.
What I verified:
- Both add
src/pkg/config/ask.go,src/pkg/hub/ask.go, and edits tosrc/pkg/hub/saas.go,server.goandsaas_users_admin.go, with the sameHIVE_ASK_ENABLED/HIVE_ASK_KAPA_*/HIVE_ASK_MODEenv contract. - The implementations differ: this PR puts the service in
pkg/askand registersGET /api/saas/admin/ask/statsplusGET/PUT/DELETE /api/ask/consentandPOST /api/ask. #19200 puts it inpkg/askai, registersGET /api/ask/statusandGET /api/ask/stats, and adds relay-hive env (HIVE_ASK_RELAY_HIVES). - #19202 (phase 2 panel) says it builds on #19200 and calls
/api/ask/statusand/api/ask/stats. Neither route exists in this PR (/api/ask/statusappears 0 times in this diff), so the panel cannot sit on this backend without rework.
Suggested survivor: #19200, because the phase 2 panel already targets its routes. Counterpoint for the maintainer: this PR has the fuller CI run (a few test (rest …), test (dashboard …) and coverage jobs failed on this head), while #19200 shows only the early gate jobs since it is also conflicting. Both are CONFLICTING against v5.
If you agree, this one could be closed in favour of #19200. I have not closed anything. I did not assess code quality in this PR in depth.
-- hive: agent=reviewer-2 backend=claude model=claude-sonnet-5-5 claude=2.1.327
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from This looks like a competing implementation of #19200, not a complement. I read both diffs; neither is reviewed line by line here, only compared. What I verified:
Differences that matter for the choice:
Flagging for a maintainer: if you agree, one of the two could be closed in favour of the other; I have not closed anything. Which one survives is your call (author, issue linkage and the config-export shape are the real differences). I have not judged the code quality of either beyond the comparison above. |
What
Phase 1 of the Ask AI help design (
src/docs/design/dashboard-ask-ai-help.md): the hub backend only, no panel. Off by default and inert.pkg/config/ask.go):ask:block andHIVE_ASK_*env overrides (env wins). Enabled but a value missing, an unusable mode or a key file outside the allowed secret directory means it stays off with one warning that names a reason and no value.project_id,integration_idand the key path arejson:"-"and redacted from the config export.pkg/ask/client.go):POST /query/v1/projects/{project_id}/chat/(and/query/v1/threads/{thread_id}/chat/for follow-ups), key inX-API-KEY, non-streaming. The body is exactlyintegration_idandquery. The 200 shape (answer,thread_id,question_answer_id,is_uncertain,relevant_sources[{source_url,title,contains_internal_data}]) was confirmed against the vendor API reference and is pinned by a contract test. Redirects are not followed with the key, and errors carry no URL, id or key.pkg/ask): credential-shaped input refused withFindSecret; length caps; source allowlist (docs site host, and the GitHub docs path underhivecommons/hive), with no allowlisted source giving a "no cited answer" result; closed-vocabulary section label; vendor thread ids kept server-side behind opaque handles bound to the person with a TTL; limits (per person burst and hourly, per hive, hub-wide per minute, in flight, daily budget); circuit breaker; 429 and timeout fall back to a fixed message; audit lines with outcome and counts only; counters by outcome.pkg/hub/ask.go): per-person consent record (own file keyed like the user record, atomic, 0600,text_version, grant and withdraw, removed with the user),GET/PUT/DELETE /api/ask/consent,POST /api/askbehind a browser session (no bearer fallback, no impersonation), andGET /api/saas/admin/ask/stats. With the switch off every route answers 404 and nothing is written or sent. No CSP is touched.env-vars.md,hive.yaml.example, the design record's verification note, and a changelog fragment.Tests
Fake vendor server asserts the exact request body and that seeded secrets, repo names, hive names and logins never appear on the wire, in a response or in a log; off means 404 and no vendor call; consent gates every request (missing, withdrawn, old text version, another person); limits, breaker and thread binding hold; credentials never appear in any response, log or export.
I did not run the test suite locally (AGENTS.md: CI is the verdict); only
gofmt -lon the changed files.Closes #19180
🤖 Generated with Claude Code
-- hive: backend=claude model=claude-sonnet-5-5
🐝 Hive Agent:
contributor| SHA:8050f6d54