mateclaw/mateclaw-server/src/main/java/vip/mate/wiki
倪程伟 9d292a9893
feat(kb-open): P0-B 9 个开放 API 端点 (#445)
* feat(kb-open): P0-B 9 open API endpoints

Implements the 9 read-only KB Open API endpoints on top of the P0-A
auth skeleton (#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 #442

* fix(kb-open): address review feedback on #445

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
  6fd62440.

EXTRA:
- whatsNew staleReason: hardcoded Chinese "上游 fact 页面变更" → English
  "Upstream fact page changed" (external-facing API response).

* chore(wiki): drop RFC-012 prefix from progress field Javadocs (#449 nit)

Per #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 #449's English translation
pass — drop it now that these lines are touched.

Zero behavior change.

* chore(kb-open): drop inline FQN in parseScopes (#444 nit)

Per #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.
2026-06-30 09:36:55 +08:00
..
controller fix(wiki): close IDOR in WikiRelationController & WikiEntityController (cross-KB id binding) 2026-06-28 14:41:19 +08:00
dto feat(wiki): KB processing-failure visibility (error-code chain + silent sub-step alerts + cross-KB failure center) 2026-06-28 13:07:34 +08:00
event feat(wiki): pipeline definition CRUD/YAML API, run query API, page-created trigger 2026-05-31 07:59:41 +08:00
hotcache feat(wiki): admin endpoints for hot cache — get / regenerate / reset 2026-05-02 21:46:02 +08:00
job feat(wiki): route cheap ingest steps to a configurable light model 2026-06-29 14:10:57 +08:00
metrics feat(wiki): add WikiMetrics gateway for compile/relation/retrieval/vision 2026-05-02 19:03:59 +08:00
model feat(kb-open): P0-B 9 个开放 API 端点 (#445) 2026-06-30 09:36:55 +08:00
pipeline feat(wiki): pipeline definition CRUD/YAML API, run query API, page-created trigger 2026-05-31 07:59:41 +08:00
profile fix(wiki): replace broken @JsonCreator with custom StdDeserializer for StageInstructions (#424) 2026-06-26 14:33:32 +08:00
relation chore: sync multiple commits from private dev 2026-04-19 18:37:44 +08:00
repository feat(wiki): KB processing-failure visibility (error-code chain + silent sub-step alerts + cross-KB failure center) 2026-06-28 13:07:34 +08:00
retrieval chore: sync multiple commits from private dev 2026-04-19 18:37:44 +08:00
service fix(wiki): make built-in transformation starter pack visible in every workspace 2026-06-29 14:35:09 +08:00
source feat(wiki): pluggable ingest-source SPI + source-watcher status API 2026-05-31 07:59:34 +08:00
sse feat(wiki): KB processing-failure visibility (error-code chain + silent sub-step alerts + cross-KB failure center) 2026-06-28 13:07:34 +08:00
tool feat(webchat): expose agent-bound wiki pages to API-Key callers 2026-06-20 07:21:07 +08:00
WikiAutoConfiguration.java fix(wiki): recover raw materials stuck in processing on server restart 2026-04-19 19:37:50 +08:00
WikiProperties.java fix(wiki): dedup pages by title and bound route prompt growth (#321) 2026-06-12 15:17:32 +08:00