feat(kb-open): P0-B 9 个开放 API 端点#445
Conversation
|
感谢这 9 个开放端点的实现 🙏 鉴权矩阵很干净:9 个端点全部带 合并前有几个阻塞项: 1. 2. 内联全限定名(违反 CLAUDE.md「禁止内联 FQN」)。 3. 非阻塞建议:
P0-B 跟着 P0-A 的修改 rebase 即可,上面 3 个阻塞项改好后合并 🙏 |
BLOCKERS: - stats.pagesWithLinks always returned 0 because listByKbId() nulls out content. Switch to listByKbIdWithContent() so [[wiki link]] detection works. - Test file: replace inline java.util.List.of() FQN with import + simple name (sync-opensource would expose the unidiomatic style). NITS (inherited from P0-A rebase): - V162→V164, prefix VARCHAR(12), FQN imports, parseScopes trim, ?token= fallback removal, design doc moved to rfcs/ — all now in ancestor commit 6fd6244. EXTRA: - whatsNew staleReason: hardcoded Chinese "上游 fact 页面变更" → English "Upstream fact page changed" (external-facing API response).
3b78663 to
d3679ea
Compare
|
Fixed. Rebased onto P0-A (inherits V164 + FQN + parseScopes + design doc move) and addressed all 3 blockers + nits in commit Blockers:
Nits (all inherited from P0-A rebase):
Extra:
21 tests pass (13 service + 4 rate limiter + 4 controller). Ready for re-review 🙏 |
|
P0-B 这版的 review 已经通过 ✅ 三个阻塞项都改好了( #444(P0-A)已经合并进 麻烦把分支变基到最新 # 若还没有上游远端:
git remote add upstream https://github.com/mateaix/mateclaw.git
git fetch upstream dev
git checkout feat/kb-open-api-p0b
# 把 6fd62440(P0-A 的 fix 提交,已并入 dev)之后的 P0-B 两个提交
# 搬到最新 dev 之上:
git rebase --onto upstream/dev 6fd62440d
git push --force-with-lease说明:
推上来变绿后我这边就合并 🙏 后续 #446(Deep Research)也建议等这条合并完再 rebase 到它上面。 |
Implements the 9 read-only KB Open API endpoints on top of the P0-A auth skeleton (mateaix#441). Each returns an explicit DTO (A5: never raw entities) and delegates assembly to service-layer methods that return pure DTOs (A6: no HTTP coupling, MCP-ready). Endpoints: - GET /pages/{slug} entity card (mode=summary/full/section:{heading}) - POST /search hybrid retrieval (granularity=entity/chunk) - POST /search/chunks chunk-level semantic search - POST /pages/{slug}/traverse entity relation graph (depth ≤ 2) - GET /pages/{slug}/trace provenance (page → chunk → raw) - GET /taxonomy pageType/entityType/relationType enumeration - GET /whats-new recent changes + stale pages - GET /stats KB statistics - GET /pages lightweight page list Components: - KbOpenApiController: 9 endpoints, each @RequireKbScope annotated - KbOpenApiService: assembly layer (card, traverse BFS, metadata parsing) - KbOpenApiDtos: all response DTOs as records (PageCard, TraceResult, TaxonomyResult, KbStats, WhatsNewResult, TraverseResult, PageList) Traverse (pragmatic version): - depth ≤ 2 with explosion guard, predicate LIKE matching - slug → pageId → mention → primaryEntity (salience-highest) - neighbor nodes echo slug when available (R11) - edge sourceHandle via evidenceChunkId → citing page Tests (4 new, all green): - KbOpenApiControllerTest: 404 on missing page/slug, delegation to service Closes mateaix#442
BLOCKERS: - stats.pagesWithLinks always returned 0 because listByKbId() nulls out content. Switch to listByKbIdWithContent() so [[wiki link]] detection works. - Test file: replace inline java.util.List.of() FQN with import + simple name (sync-opensource would expose the unidiomatic style). NITS (inherited from P0-A rebase): - V162→V164, prefix VARCHAR(12), FQN imports, parseScopes trim, ?token= fallback removal, design doc moved to rfcs/ — all now in ancestor commit 6fd6244. EXTRA: - whatsNew staleReason: hardcoded Chinese "上游 fact 页面变更" → English "Upstream fact page changed" (external-facing API response).
d3679ea to
9d13fcc
Compare
|
已按你的 rebase 零冲突,编译通过。PR 状态已变回 |
…x#449 nit) Per mateaix#449 review (4825113234): the internal RFC-012 reference should not appear in code. progressPhase/progressTotal/progressDone Javadocs still carried the "RFC-012 M2 v2 UI:" prefix after mateaix#449's English translation pass — drop it now that these lines are touched. Zero behavior change.
Per mateaix#444 review (4825157096): parseScopes used `.collect(java.util.stream.Collectors.toUnmodifiableSet())` while `Collectors` is already imported at the top of the file. Use the simple name. Zero behavior change.
Closes #442 · Part of #440 · Builds on #441 (P0-A)
改动
在 P0-A 认证骨架之上,实现 9 个知识库开放 API 端点。
9 个端点
/pages/{slug}/search/search/chunks/pages/{slug}/traverse/pages/{slug}/trace/taxonomy/whats-new/stats/pages架构约束
HttpServletRequest/R<T>不漏进 service)traverse(务实版)
测试
依赖
此 PR 包含 P0-A 的 cherry-pick commit(认证骨架)。若 #444(P0-A)先合并,rebase 后此 PR 只剩 P0-B 的 4 个文件。