feat(identity): web metadata enrichment for titles missing on TMDB (META-1)

- metadata.enrich (propose, low, replay safe): normalized-title cache (kv_cache
  region enrich, 7 days) -> daily budget -> web.search (title + 短剧 / 电视剧 平台,
  second query limited to whitelist via site:) -> web.fetch of up to 3 relevant
  whitelisted pages (registered site domains never read, redirects out of the
  whitelist dropped) -> upstream model extraction with rule fallback -> server-side
  evidence check (rule_confirmed / multi_evidence / needs_review). Suggestion only.
- POST /identity-pool/{id}/enrich (suggest) and /enrich/apply (console session):
  provisional entity or same-title merge, season/episode units, field-level
  metadata with source web/agent + evidence, aliases, release assignment.
  Poster proxy GET /img/enrich/{id} (og:image from whitelisted pages only).
- Auto-enrich once per pool entry when subscription/rule lookups find nothing on
  TMDB (identity.autoEnrich, off by default); identity.enrichDailyBudget,
  identity.enrichDomains settings; web.fetch now returns og:image.
- Pool sheet "元数据补全" section; entity detail shows evidence links.
- Migration 0049_enrichment (metadata_enrichment, metadata_field.evidence, source
  web). Requires image rebuild / api + worker restart to take effect.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-09-29 15:57:48 +08:00
1 parent 18a5cf1de7
commit f4666a4671
36 files changed
+2514 -25

No files matched your search

+4
View File
@@ -95,6 +95,8 @@ const ROWS: Record<string, { row: Obj; dbOnly?: string[]; apiOnly?: string[] }>
IdentityCandidate: { row: C.IdentityCandidate },
IdentityRedirect: { row: C.IdentityRedirect },
MetadataField: { row: C.MetadataField },
// META-1 元数据补全记录(0049)
MetadataEnrichment: { row: C.MetadataEnrichment },
ResolutionAttempt: { row: C.ResolutionAttempt },
SiteSnapshot: { row: C.SiteSnapshot },
// W4-C 浏览器实体(0023)
@@ -265,6 +267,8 @@ const ENUMS: Record<string, z.ZodEnum> = {
IdentityCandidateReason: C.IdentityCandidateReason,
IdentityRedirectActorType: C.ActorType,
MetadataFieldSource: C.MetadataSource,
MetadataEnrichmentStatus: C.EnrichmentStatus,
MetadataEnrichmentTrigger: C.EnrichmentTrigger,
ResolutionAttemptOutcome: C.ResolutionOutcome,
ResolutionAttemptActorType: C.ActorType,
SiteSnapshotKind: C.SiteSnapshotKind,
+3 -2
View File
@@ -104,6 +104,7 @@ const OVERRIDES: Record<string, (v: Record<string, unknown>) => Record<string, u
IdentityResolveInput: (v) => v,
AssetLocationCreate: (v) => v,
ReleaseIdentityAssign: (v) => ({ ...v, external: undefined, candidateIndex: undefined }),
MetadataEnrichInput: (v) => ({ ...v, title: undefined }),
CacheSettings: (v) => ({ ...v, hardThresholdPercent: 90, resumePercent: 85, cleanupTargetPercent: 80 }),
GlobalSettings: () => C.DEFAULT_SETTINGS,
// 方案至少 2 个(id 不同)
@@ -215,8 +216,8 @@ describe("关键合同行为", () => {
expect(spec).toMatchObject(meta);
expect(spec.inputSchema).toBe(C.CAPABILITY_IO[id].input);
expect(spec.outputSchema).toBe(C.CAPABILITY_IO[id].output);
// 例外:site.health_check 只读首页并写回健康列,幂等可重跑
if (spec.kind !== "read" && spec.kind !== "preview" && id !== "site.health_check")
// 例外:site.health_check 只读首页并写回健康列,幂等可重跑;metadata.enrich 只存补全建议(7 天标题缓存),重跑无副作用
if (spec.kind !== "read" && spec.kind !== "preview" && id !== "site.health_check" && id !== "metadata.enrich")
expect(spec.replay, id).toBe("never");
}
});