2 Commits
Author SHA1 Message Date
viettranx dd65fbcba0 test(integration): fix pre-existing bugs + post-Phase-4 contract update
Three fixes required to run the integration suite after Phase 4:

1. v3_vault_store_test.go makeVaultDoc: AgentID is *string (nullable),
   not string — was a pre-existing type error from v3 commit 8f56ddaa
   that blocked the test binary build. Pass &agentID.

2. vault_classify_test.go imports: remove unused `store/pg` import —
   pre-existing from v3 commit 4b7a2e6e.

3. TestVaultClassify_DeleteDocLinksByTypes_MultipleTypes: fix off-by-one
   in target-doc loop. Pre-existing runtime panic from v3 commit — loop
   created 7 targets but linkTypes slice has 8 entries, accessing docs[8]
   on a len-8 slice. Changed loop to `range 8`.

4. TestVaultClassify_DeleteDocLinksByTypes_NonExistentDoc: swap
   "fake-doc-id-12345" placeholder for a well-formed but unused UUID.
   Post-Phase-4, parseUUID rejects bare strings at the caller boundary;
   the "non-existent = no-op" contract requires a syntactically valid
   UUID. Per Q7 documented contract change.

Phase 4 Step 4g integration gate.
2026-04-11 21:22:23 +07:00
viettranx 4b7a2e6e58 feat(vault): replace auto-linking with LLM-classified relationship types
Replace vector-similarity-only auto-linking (creating generic "semantic"
links) with an LLM classification step that determines actual relationship
types (reference, depends_on, extends, related, supersedes, contradicts)
and generates meaningful context descriptions.

- Add enrich_classify.go: orchestration, retry with escalating timeouts,
  candidate gathering with bidirectional dedup, 20-doc cap per batch
- Add enrich_classify_prompt.go: system prompt, JSON parsing with partial
  success model, UTF-8 safe truncation
- Restructure processBatch: summarize → embed → classify → dedup+wikilinks
- Move dedup recording after classify (failed classify allows re-enrichment)
- Remove autoLink method (fully replaced by classifyLinks)
- Add DeleteDocLinksByTypes to VaultStore interface + PG/SQLite (IN clause)
- Guard old link deletion behind len(newLinks) > 0 (no data loss on all-SKIP)
2026-04-10 09:54:02 +07:00