Skip to content

fix(knowledge-base): split aggregate stats from gated filesystem paths - #85

Merged
man4ish merged 1 commit into
mainfrom
fix/knowledge-base-public-aggregate-fields
Sep 13, 2026
Merged

man4ish merged 1 commit into
mainfrom
fix/knowledge-base-public-aggregate-fields

Conversation

@man4ish

@man4ish man4ish commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • GET /knowledge-base was gated entirely behind platform.manage_infra because its response includes pubmed_root/index_root (absolute internal filesystem paths). But generate_report.py's knowledge_base_section_html calls this route with no Authorization header at all (it has no way to authenticate itself) and only ever reads the aggregate fields — abstract/domain counts, index size, rag_status — never the two path fields. The blanket gate meant the AI Knowledge Base section of the ecosystem report always failed with a 401, every generation, not just under load (confirmed live: curl returned 401 in 8ms).
  • Same PUBLIC_FIELDS-style split already used by routes_dashboard.py's GET /dashboard/summary ("knowledge" section): the route no longer hard-Depends()s on require_permission, instead always computes and returns the aggregate fields, and includes pubmed_root/index_root only when the caller's own token carries platform.manage_infra (checked via a non-raising _has_permission, matching that module's own private helper of the same name/shape).

Test plan

  • Added TestKnowledgeBasePublicFields (test_main.py): 200 without a token with aggregate fields present and paths null; paths populated with a valid platform.manage_infra token; a different permission still yields null paths.
  • Removed /knowledge-base from TestPlatformManageInfraAuth's gated-routes list and TestOverGateRegressionGuard.STILL_GATED, with dated notes explaining why (matching this file's existing convention for the 2026-09-02/09-03 decisions).
  • test_routes_llm.py's existing /knowledge-base tests (always sent with a sufficient token) unaffected, still pass.
  • Full backend suite: 1722 tests passed.
  • Live: unauthenticated curl /knowledge-base now returns real aggregate data (28.1M abstracts, 282 domains, 288 FAISS indexes, 234.38 GB) with paths null; authenticated request gets the same data plus both real paths.
  • Re-ran generate_report.py end to end — AI Knowledge Base section now renders all four stat cards with real data instead of the fallback message.

🤖 Generated with Claude Code

https://claude.ai/code/session_011MvEwFRKwmMy94dReYy9LL

GET /knowledge-base was gated entirely behind platform.manage_infra
because its response includes pubmed_root/index_root, absolute internal
filesystem paths. But generate_report.py's knowledge_base_section_html
calls this route with no Authorization header at all (it has no way to
authenticate itself) and only ever reads the aggregate fields --
abstract/domain counts, index size, rag_status -- never the two path
fields. The blanket gate meant the AI Knowledge Base section of the
ecosystem report always failed with a 401, every single generation,
not just under load (confirmed live: curl returned 401 in 8ms).

Same PUBLIC_FIELDS-style split already used by routes_dashboard.py's
GET /dashboard/summary ("knowledge" section): the route no longer hard-
Depends() on require_permission, instead always computes and returns
the aggregate fields, and includes pubmed_root/index_root only when
the caller's own token carries platform.manage_infra (checked via a
non-raising _has_permission, same pattern as routes_dashboard.py's
own private helper of the same name -- duplicated rather than shared,
matching that module's existing convention).

Test changes: added TestKnowledgeBasePublicFields (test_main.py) for
the new split (200 without a token, aggregate fields present, paths
null; paths populated with a valid platform.manage_infra token; a
different permission still yields null paths). Removed /knowledge-base
from TestPlatformManageInfraAuth's gated-routes list and
TestOverGateRegressionGuard.STILL_GATED, since it's no longer a plain
401-without-token case -- both updated with dated notes explaining why,
matching this file's existing convention for the 2026-09-02/09-03
decisions. test_routes_llm.py's existing /knowledge-base tests
(always sent with a sufficient token) are unaffected and still pass.

Verified: full backend suite (1722 tests) passes. Live: unauthenticated
curl to /knowledge-base now returns real aggregate data (28.1M
abstracts, 282 domains, 288 FAISS indexes, 234.38 GB) with pubmed_root/
index_root null; an authenticated platform.manage_infra request gets
the same data plus both real paths. Re-ran generate_report.py end to
end -- AI Knowledge Base section now renders all four stat cards with
real data instead of "Could not reach control center for knowledge
base stats."

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011MvEwFRKwmMy94dReYy9LL
@man4ish
man4ish merged commit 8410ccc into main Sep 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant