WeKnora/internal/application/repository
vicfei 2dd36212d6 fix(knowledge): bind extracted images to their document and unscope shared-KB parent lookups
Org-shared KB viewers got 403 for extracted images on current main even
though the retrieving chunk text carried the resource:// handle and the
share grant was valid (#3342, second report after #3022/#3069).

Root cause is a mismatch between ingestion and authorization: document
parses store extracted images through SaveBytes, which registers the
resource but never claims it, while both file proxies (ResolveKBFile and
the message fallback via resourceAccessibleViaSharedKB) authorize through
IsReferencedByKnowledgeBase — which accepts explicit resource_bindings
rows only. The binding-only hardening landed without adding the missing
bindings, so every extracted image became invisible cross-workspace.

Ingestion: bindStoredImages claims each stored image for its knowledge
(ResourceRelationExtractedImage), mirroring bindContentResources — best
effort, same-workspace resources only. Wired into both the file-parse
path (knowledge_process) and manual knowledge (triggerManualProcessing).

Merge: resolveParentChunks fetched parents, grandparents, and image_info
children with the caller's tenant, so shared-KB hits from the sharing
workspace resolved none of them and lost parent context and image_info
(the second defect in the #3342 audit). Those lookups now use the
existing *Only unscoped variants, matching their shared-KB precedent.

Historical documents parsed before this change still carry no bindings;
a backfill is tracked as the follow-up slice.

Verified end-to-end on a fresh stack: publishing a manual document with
an embedded image now records kind=image plus an extracted_image binding
alongside the content-derived attachment binding.
2026-09-22 17:52:49 +08:00
..
retriever fix(qdrant): treat a missing dimension collection as an empty delete target (#3419) 2026-09-20 11:12:18 +08:00
agent_share.go fix(security): close cross-workspace access paths in shared spaces (#3408) 2026-09-18 22:00:02 +08:00
agent_share_source_test.go fix(security): close cross-workspace access paths in shared spaces (#3408) 2026-09-18 22:00:02 +08:00
audit_log.go
…
audit_log_scope_test.go
…
chunk.go fix(knowledge): bind extracted images to their document and unscope shared-KB parent lookups 2026-09-22 17:52:49 +08:00
chunk_faq_diff_test.go
…
chunk_fields_test.go
…
chunk_revision_test.go
…
chunk_sqlite_test.go
…
custom_agent.go
…
datasource_repo.go
…
datasource_repo_test.go
…
embed_channel.go
…
kbshare.go fix(security): close cross-workspace access paths in shared spaces (#3408) 2026-09-18 22:00:02 +08:00
knowledge.go fix(knowledge): recover stranded deleting rows and align the KB count (#3367) 2026-09-18 00:55:44 +08:00
knowledge_create_test.go
…
knowledge_datasource_external_id_test.go
…
knowledge_duplicate_test.go fix(knowledge): recover stranded deleting rows and align the KB count (#3367) 2026-09-18 00:55:44 +08:00
knowledge_finalize_test.go
…
knowledge_folder_move_test.go
…
knowledge_folder_test.go
…
knowledge_list_filter_test.go
…
knowledge_metadata_prefix_test.go
…
knowledge_source_schema_test.go
…
knowledge_span_repo.go
…
knowledge_span_repo_test.go
…
knowledge_tag.go
…
knowledge_tag_test.go
…
knowledge_transfer.go
…
knowledge_transfer_test.go
…
knowledgebase.go
…
knowledgebase_sqlite_test.go
…
mcp_endpoint.go
…
mcp_metadata.go
…
mcp_metadata_test.go
…
mcp_oauth.go
…
mcp_oauth_test.go
…
mcp_service.go
…
mcp_tool_approval_repository.go
…
mcp_tool_approval_repository_test.go
…
memory.go
…
memory_extraction.go
…
memory_lifecycle.go
…
memory_vector.go
…
message.go feat(session): in-place rewind with workspace checkpoint reset (#3469) 2026-09-20 21:01:00 +08:00
message_artifact.go feat(session): in-place rewind with workspace checkpoint reset (#3469) 2026-09-20 21:01:00 +08:00
message_artifact_delete_test.go feat(artifacts): let users delete generated files (#3447) 2026-09-20 13:01:46 +08:00
message_artifact_test.go feat(artifacts): artifacts library page backed by a message_artifacts table (#3384) 2026-09-18 12:10:19 +08:00
message_context_checkpoint_test.go feat(agent): size agent history by the window and calibrate token estimates (#3413) 2026-09-18 22:51:31 +08:00
message_fork_boundary_test.go feat(artifacts): artifacts library page backed by a message_artifacts table (#3384) 2026-09-18 12:10:19 +08:00
message_owner_scope_test.go feat(artifacts): artifacts library page backed by a message_artifacts table (#3384) 2026-09-18 12:10:19 +08:00
message_request_id_test.go
…
message_rewind_boundary_test.go feat(session): in-place rewind with workspace checkpoint reset (#3469) 2026-09-20 21:01:00 +08:00
message_search_test.go feat(artifacts): artifacts library page backed by a message_artifacts table (#3384) 2026-09-18 12:10:19 +08:00
message_suggestion.go feat(session): in-place rewind with workspace checkpoint reset (#3469) 2026-09-20 21:01:00 +08:00
model.go
…
model_usage.go
…
model_usage_test.go
…
organization.go fix(security): close the low-severity shared-space findings (#3416) 2026-09-18 22:58:46 +08:00
organization_member_limit_test.go fix(security): close the low-severity shared-space findings (#3416) 2026-09-18 22:58:46 +08:00
resource.go
…
resource_references.go
…
session.go feat(artifacts): artifacts library page backed by a message_artifacts table (#3384) 2026-09-18 12:10:19 +08:00
session_fork_test.go feat(artifacts): artifacts library page backed by a message_artifacts table (#3384) 2026-09-18 12:10:19 +08:00
session_test.go
…
storagebackend.go
…
system_setting.go
…
tag.go
…
task_queue.go fix(queue): order ClaimBatch by fail_count so retries cannot starve new work (#3444) 2026-09-21 13:00:29 +08:00
task_queue_test.go fix(queue): order ClaimBatch by fail_count so retries cannot starve new work (#3444) 2026-09-21 13:00:29 +08:00
temporary_document.go
…
tenant.go
…
tenant_api_key.go
…
tenant_api_key_test.go
…
tenant_disabled_shared_agent.go
…
tenant_invitation.go
…
tenant_member.go
…
tenant_sandbox_config.go
…
tenant_sandbox_config_test.go
…
tenant_skill.go fix(skills): upgrade outdated sandbox skills without rolling back the catalog or taking them offline (#3406) 2026-09-18 20:27:43 +08:00
tenant_skill_test.go
…
tenant_test.go
…
user.go
…
user_resource_favorite.go
…
user_tenantless_test.go
…
vectorstore.go
…
web_search_provider.go
…
wiki_page.go fix(security): close the low-severity shared-space findings (#3416) 2026-09-18 22:58:46 +08:00
wiki_page_test.go fix(security): close the low-severity shared-space findings (#3416) 2026-09-18 22:58:46 +08:00