Skip to content

Authorize knowledge uploads by Knowledge Space - #11

Merged
kl3inIT merged 3 commits into
mainfrom
feat/knowledge-space-upload-authz
Jul 22, 2026
Merged

Authorize knowledge uploads by Knowledge Space#11
kl3inIT merged 3 commits into
mainfrom
feat/knowledge-space-upload-authz

Conversation

@kl3inIT

@kl3inIT kl3inIT commented Jul 22, 2026

Copy link
Copy Markdown
Owner

What changed

  • add Knowledge Spaces as the required parent container for uploaded knowledge
  • list upload targets through OpenFGA ListObjects(can_create_asset) and recheck permission before storage
  • propagate knowledge_space_id through source, revision, ingestion, asset, and publication records
  • publish Space-to-Asset and uploader-owner tuples through the authorization outbox
  • derive source ACLs from the selected Space and document classification
  • add the authorized Space selector to the document upload UI
  • fix the browser CSRF wrapper so generated multipart requests retain their method and headers

Why

Uploads previously had no explicit destination boundary. This makes knowledge placement permission-aware at creation time while retaining source ACL and classification checks for retrieval.

Validation

  • fga model validate
  • fga model test — 6/6 tests, 29/29 checks, 5/5 ListObjects assertions
  • ./gradlew --no-daemon clean test
  • corepack pnpm -C web check:api
  • corepack pnpm -C web build
  • browser upload smoke test: authorized Space filtering and real multipart upload returned 201 Created

Summary by CodeRabbit

  • New Features
    • Added Knowledge Space selection to document/source uploads, including a Knowledge Space selector with loading, error, retry, and no-permission states.
    • Uploaders can only select Knowledge Spaces they’re authorized to upload to, and the chosen space is used for access control.
    • Added a new Knowledge Space upload-targets API to populate the selector.
  • Bug Fixes
    • Improved CSRF header handling when requests already include headers/methods.
    • Hardened permission checks so unauthorized uploads are blocked before any data is written, and visible sources are permission-aware.
  • Documentation
    • Updated ingestion, authorization, and roadmap documentation for Knowledge Space–targeted, permission-aware behavior.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kl3inIT, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 37 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 98d5ed84-d5ce-45d2-b593-92deaaf43f2c

📥 Commits

Reviewing files that changed from the base of the PR and between 18d8e6d and 3acec97.

📒 Files selected for processing (6)
  • apps/api/src/test/java/com/orgmemory/api/source/SourceUploadIntegrationTests.java
  • apps/worker/src/test/java/com/orgmemory/worker/ingestion/SourceIngestionPipelineIntegrationTests.java
  • core/src/main/resources/db/migration/V18__knowledge_space_upload_authorization.sql
  • core/src/main/resources/db/migration/V18__knowledge_space_upload_authorization.sql.conf
  • docs/conventions.md
  • integrations/authorization-openfga/src/test/openfga/store.fga.yaml
📝 Walkthrough

Walkthrough

Adds Knowledge Spaces with OpenFGA-based upload authorization, persists space identity through source ingestion and publication, adds authorization-aware source listing, updates upload UI/API flows, and documents related ACL and retrieval behavior.

Changes

Knowledge Space security flow

Layer / File(s) Summary
Space persistence and data contracts
core/src/main/java/com/orgmemory/core/knowledge/*, core/src/main/resources/db/migration/*
Adds the knowledge_spaces schema, active-space queries, validated targets, and knowledgeSpaceId across source, asset, and publication records.
Upload-target authorization API
core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpace*.java, apps/api/src/main/java/com/orgmemory/api/knowledge/*, integrations/authorization-openfga/src/test/openfga/store.fga.yaml
Lists OpenFGA-authorized upload spaces, rechecks selected spaces, exposes targets through REST, and handles unresolved authorization with service-unavailable responses.
Targeted upload flow
apps/api/src/main/java/com/orgmemory/api/source/SourceController.java, core/src/main/java/com/orgmemory/core/knowledge/SourceUpload*.java, web/src/features/sources/*
Requires a Knowledge Space during upload, authorizes it before object-storage writes, persists its identity, and adds selection, loading, error, and retry states to the upload dialog.
Space-aware ingestion publication
core/src/main/java/com/orgmemory/core/knowledge/KnowledgeIngestion*.java, apps/worker/src/main/java/com/orgmemory/worker/ingestion/*
Carries space identity through promotion and worker claims, publishes space and owner tuples, and derives source ACLs from declared access.
Authorization-aware source listing
core/src/main/java/com/orgmemory/core/knowledge/SourceQueryService.java, core/src/main/java/com/orgmemory/core/knowledge/SecureKnowledgeRetrievalStore.java, apps/api/src/main/java/com/orgmemory/api/source/SourceController.java
Lists sources visible to the actor by combining authorized assets with SQL visibility filtering and batched summary loading.
Authorization adapter reliability
integrations/authorization-openfga/src/main/java/.../*Authorization*Adapter.java, integrations/authorization-openfga/src/test/...
Adds warning logging for OpenFGA failures and explicit correlation IDs for batch-check response mapping.
Documented and runtime support
ARCHITECTURE.md, docs/specs/domains/knowledge-ingestion.md, docs/roadmap.md, apps/*/src/main/resources/application.yml, .env.example, demo/fixtures/*
Updates authorization and retrieval documentation, fixtures, retrieval-property binding, OpenAI routing defaults, and worker runtime settings.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SourceUploadDialog
  participant SourceController
  participant SourceUploadService
  participant KnowledgeSpaceService
  participant ObjectStoragePort
  participant Worker
  participant OpenFGA

  User->>SourceUploadDialog: Select Knowledge Space and file
  SourceUploadDialog->>SourceController: Submit upload with knowledgeSpaceId
  SourceController->>SourceUploadService: CreateUploadSourceCommand
  SourceUploadService->>KnowledgeSpaceService: Recheck can_create_asset
  KnowledgeSpaceService->>OpenFGA: Check selected Knowledge Space
  OpenFGA-->>KnowledgeSpaceService: Authorization decision
  SourceUploadService->>ObjectStoragePort: Write authorized upload
  Worker->>OpenFGA: Publish space and owner relationships
Loading

Possibly related PRs

  • kl3inIT/OrgMemory#7: Extends the source upload and ingestion paths that now carry knowledgeSpaceId.
  • kl3inIT/OrgMemory#9: Touches the OpenFGA-gated knowledge asset publication and tuple-writing flow.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: knowledge uploads are now authorized by Knowledge Space.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/knowledge-space-upload-authz

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/api/src/test/java/com/orgmemory/api/source/SourceUploadIntegrationTests.java`:
- Around line 80-90: Update the stubbing in the upload test around
uploads.upload and knowledgeSpaces.requireUploadTarget to match ACTOR and
SALES_SPACE_ID explicitly instead of accepting any values. Add assertions that
the persisted source contains the expected knowledge_space_id and department_id
from the resolved KnowledgeSpaceTarget.

In
`@apps/worker/src/test/java/com/orgmemory/worker/ingestion/SourceIngestionPipelineIntegrationTests.java`:
- Around line 237-246: Update the assertions in
SourceIngestionPipelineIntegrationTests around writeRequest to also verify that
the Space tuple’s object equals "knowledge_asset:" plus
revision.get("knowledge_asset_id"), while preserving the existing principal and
relation checks and the separate user-owner tuple assertions.

In
`@core/src/main/resources/db/migration/V18__knowledge_space_upload_authorization.sql`:
- Around line 77-102: Make the V18 migration online-safe by using an explicitly
non-transactional expand/backfill/validate rollout for source_objects and the
affected asset tables: add nullable columns with NOT VALID foreign keys, perform
bounded batch backfills, then validate and finalize constraints without
immediate blocking checks. Build indexes on populated existing tables
concurrently, preserving tenant-scoped foreign keys, uniqueness, and append-only
evidence semantics while remaining compatible with PostgreSQL 18 and pgvector.

In `@integrations/authorization-openfga/src/test/openfga/store.fga.yaml`:
- Around line 167-200: Add a negative direct check for user:minh on
knowledge_space:company with can_create_asset set to false in the “Upload
targets are authorized on the parent Knowledge Space” test case. Keep the
existing finance check and empty list_objects assertion unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b77d6a2f-bd81-441b-aa79-47754a45796e

📥 Commits

Reviewing files that changed from the base of the PR and between 874759a and 605248a.

⛔ Files ignored due to path filters (2)
  • contracts/openapi.json is excluded by !contracts/openapi.json
  • integrations/authorization-openfga/src/main/openfga/local-demo-tuples.csv is excluded by !**/*.csv
📒 Files selected for processing (40)
  • ARCHITECTURE.md
  • apps/api/src/main/java/com/orgmemory/api/ApiExceptionHandler.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/KnowledgeSpaceController.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/KnowledgeSpaceResponse.java
  • apps/api/src/main/java/com/orgmemory/api/source/SourceController.java
  • apps/api/src/test/java/com/orgmemory/api/knowledge/KnowledgeIngestionIntegrationTests.java
  • apps/api/src/test/java/com/orgmemory/api/source/SourceUploadIntegrationTests.java
  • apps/worker/src/main/java/com/orgmemory/worker/ingestion/SourceIngestionProcessor.java
  • apps/worker/src/test/java/com/orgmemory/worker/ingestion/SourceIngestionPipelineIntegrationTests.java
  • core/src/main/java/com/orgmemory/core/knowledge/ClaimedSourceRevision.java
  • core/src/main/java/com/orgmemory/core/knowledge/CreateUploadSourceCommand.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAsset.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationCoordinator.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationOutbox.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationService.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationState.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeIngestionService.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpace.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceRepository.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceService.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceTarget.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceUnavailableException.java
  • core/src/main/java/com/orgmemory/core/knowledge/PromoteNormalizedRecordCommand.java
  • core/src/main/java/com/orgmemory/core/knowledge/PublishKnowledgeAssetCommand.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceIngestionCoordinator.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceObject.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceRevision.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceUploadRegistrationService.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceUploadService.java
  • core/src/main/resources/db/migration/V18__knowledge_space_upload_authorization.sql
  • core/src/test/java/com/orgmemory/core/knowledge/KnowledgeSpaceServiceTests.java
  • core/src/test/java/com/orgmemory/core/knowledge/SourceUploadServiceTests.java
  • docs/increments/active/2026-07-22-secure-hybrid-retrieval/plan.md
  • docs/roadmap.md
  • docs/specs/domains/knowledge-ingestion.md
  • integrations/authorization-openfga/src/test/openfga/store.fga.yaml
  • web/src/features/session/csrf-fetch.ts
  • web/src/features/sources/api/upload-source.ts
  • web/src/features/sources/components/source-upload-dialog.tsx
  • web/src/features/sources/components/sources-page.tsx
📜 Review details
🧰 Additional context used
📓 Path-based instructions (14)
**/*

📄 CodeRabbit inference engine (CLAUDE.md)

**/*: Before changing unfamiliar Spring Boot 4, Spring Modulith 2, Spring AI 2, Gradle, React, Vite, Tailwind, or TypeScript APIs, consult Context7/current official documentation and the project orgmemory-* verification skills.
Read docs/guidelines/agent-safety.md before retrieval, AI, MCP, permission, upload, graph, or export work.
Never commit .env files, provider keys, tokens, or customer data.
Run the relevant gates from docs/guidelines/testing-harness.md; use a terminating clean test as the context gate, and do not treat bootRun as verification.
Current behavior belongs in architecture/specs only after it exists in code; intent belongs in vision, roadmap, or an active increment, and repository state must not be duplicated across documents.

Files:

  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceTarget.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceUnavailableException.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/KnowledgeSpaceResponse.java
  • docs/increments/active/2026-07-22-secure-hybrid-retrieval/plan.md
  • core/src/main/java/com/orgmemory/core/knowledge/ClaimedSourceRevision.java
  • core/src/test/java/com/orgmemory/core/knowledge/SourceUploadServiceTests.java
  • core/src/main/java/com/orgmemory/core/knowledge/PromoteNormalizedRecordCommand.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpace.java
  • core/src/main/java/com/orgmemory/core/knowledge/PublishKnowledgeAssetCommand.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceRepository.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceIngestionCoordinator.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationState.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationCoordinator.java
  • apps/api/src/main/java/com/orgmemory/api/ApiExceptionHandler.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationService.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/KnowledgeSpaceController.java
  • web/src/features/sources/api/upload-source.ts
  • apps/api/src/main/java/com/orgmemory/api/source/SourceController.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationOutbox.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceRevision.java
  • web/src/features/session/csrf-fetch.ts
  • core/src/main/resources/db/migration/V18__knowledge_space_upload_authorization.sql
  • integrations/authorization-openfga/src/test/openfga/store.fga.yaml
  • core/src/main/java/com/orgmemory/core/knowledge/CreateUploadSourceCommand.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeIngestionService.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceObject.java
  • core/src/test/java/com/orgmemory/core/knowledge/KnowledgeSpaceServiceTests.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAsset.java
  • docs/roadmap.md
  • core/src/main/java/com/orgmemory/core/knowledge/SourceUploadRegistrationService.java
  • apps/worker/src/main/java/com/orgmemory/worker/ingestion/SourceIngestionProcessor.java
  • apps/api/src/test/java/com/orgmemory/api/knowledge/KnowledgeIngestionIntegrationTests.java
  • docs/specs/domains/knowledge-ingestion.md
  • web/src/features/sources/components/source-upload-dialog.tsx
  • web/src/features/sources/components/sources-page.tsx
  • apps/worker/src/test/java/com/orgmemory/worker/ingestion/SourceIngestionPipelineIntegrationTests.java
  • apps/api/src/test/java/com/orgmemory/api/source/SourceUploadIntegrationTests.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceUploadService.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceService.java
  • ARCHITECTURE.md
**/*.{java,sql}

📄 CodeRabbit inference engine (CLAUDE.md)

Pair JPA schema changes with a Flyway migration.

Files:

  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceTarget.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceUnavailableException.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/KnowledgeSpaceResponse.java
  • core/src/main/java/com/orgmemory/core/knowledge/ClaimedSourceRevision.java
  • core/src/test/java/com/orgmemory/core/knowledge/SourceUploadServiceTests.java
  • core/src/main/java/com/orgmemory/core/knowledge/PromoteNormalizedRecordCommand.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpace.java
  • core/src/main/java/com/orgmemory/core/knowledge/PublishKnowledgeAssetCommand.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceRepository.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceIngestionCoordinator.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationState.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationCoordinator.java
  • apps/api/src/main/java/com/orgmemory/api/ApiExceptionHandler.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationService.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/KnowledgeSpaceController.java
  • apps/api/src/main/java/com/orgmemory/api/source/SourceController.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationOutbox.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceRevision.java
  • core/src/main/resources/db/migration/V18__knowledge_space_upload_authorization.sql
  • core/src/main/java/com/orgmemory/core/knowledge/CreateUploadSourceCommand.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeIngestionService.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceObject.java
  • core/src/test/java/com/orgmemory/core/knowledge/KnowledgeSpaceServiceTests.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAsset.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceUploadRegistrationService.java
  • apps/worker/src/main/java/com/orgmemory/worker/ingestion/SourceIngestionProcessor.java
  • apps/api/src/test/java/com/orgmemory/api/knowledge/KnowledgeIngestionIntegrationTests.java
  • apps/worker/src/test/java/com/orgmemory/worker/ingestion/SourceIngestionPipelineIntegrationTests.java
  • apps/api/src/test/java/com/orgmemory/api/source/SourceUploadIntegrationTests.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceUploadService.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceService.java
**/*.java

📄 CodeRabbit inference engine (CLAUDE.md)

JetBrains IDE inspection is a Java-backend gate only.

Files:

  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceTarget.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceUnavailableException.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/KnowledgeSpaceResponse.java
  • core/src/main/java/com/orgmemory/core/knowledge/ClaimedSourceRevision.java
  • core/src/test/java/com/orgmemory/core/knowledge/SourceUploadServiceTests.java
  • core/src/main/java/com/orgmemory/core/knowledge/PromoteNormalizedRecordCommand.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpace.java
  • core/src/main/java/com/orgmemory/core/knowledge/PublishKnowledgeAssetCommand.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceRepository.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceIngestionCoordinator.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationState.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationCoordinator.java
  • apps/api/src/main/java/com/orgmemory/api/ApiExceptionHandler.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationService.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/KnowledgeSpaceController.java
  • apps/api/src/main/java/com/orgmemory/api/source/SourceController.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationOutbox.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceRevision.java
  • core/src/main/java/com/orgmemory/core/knowledge/CreateUploadSourceCommand.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeIngestionService.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceObject.java
  • core/src/test/java/com/orgmemory/core/knowledge/KnowledgeSpaceServiceTests.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAsset.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceUploadRegistrationService.java
  • apps/worker/src/main/java/com/orgmemory/worker/ingestion/SourceIngestionProcessor.java
  • apps/api/src/test/java/com/orgmemory/api/knowledge/KnowledgeIngestionIntegrationTests.java
  • apps/worker/src/test/java/com/orgmemory/worker/ingestion/SourceIngestionPipelineIntegrationTests.java
  • apps/api/src/test/java/com/orgmemory/api/source/SourceUploadIntegrationTests.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceUploadService.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceService.java
core/src/main/java/com/orgmemory/core/{authorization,knowledge,permission}/**/*.java

⚙️ CodeRabbit configuration file

core/src/main/java/com/orgmemory/core/{authorization,knowledge,permission}/**/*.java: Treat PostgreSQL ACL evidence as canonical and OpenFGA as the relationship
authorization decision point. Authorization must fail closed. Filtering
must happen before ranking, LIMIT, graph traversal, answer generation,
export, and citation rendering. Flag metadata or timing leak paths.

Files:

  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceTarget.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceUnavailableException.java
  • core/src/main/java/com/orgmemory/core/knowledge/ClaimedSourceRevision.java
  • core/src/main/java/com/orgmemory/core/knowledge/PromoteNormalizedRecordCommand.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpace.java
  • core/src/main/java/com/orgmemory/core/knowledge/PublishKnowledgeAssetCommand.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceRepository.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceIngestionCoordinator.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationState.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationCoordinator.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationService.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationOutbox.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceRevision.java
  • core/src/main/java/com/orgmemory/core/knowledge/CreateUploadSourceCommand.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeIngestionService.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceObject.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAsset.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceUploadRegistrationService.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceUploadService.java
  • core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceService.java
apps/api/src/main/java/**/*.java

⚙️ CodeRabbit configuration file

apps/api/src/main/java/**/*.java: Enforce the browser-BFF and resource-server boundaries. Authentication
must resolve an active internal actor through the explicit issuer and
subject binding. Reject identity, tenant, roles, or permissions supplied
by request payloads, JWT email, or untrusted JWT role claims.

Files:

  • apps/api/src/main/java/com/orgmemory/api/knowledge/KnowledgeSpaceResponse.java
  • apps/api/src/main/java/com/orgmemory/api/ApiExceptionHandler.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/KnowledgeSpaceController.java
  • apps/api/src/main/java/com/orgmemory/api/source/SourceController.java
docs/**/*.md

📄 CodeRabbit inference engine (docs/conventions.md)

docs/**/*.md: Keep ARCHITECTURE.md and specification documents limited to implemented facts; record intent in vision/roadmap documents, keep active increment plans separate, and explicitly supersede append-only decisions.
Do not create status-summary documents that duplicate existing sources of truth.

Files:

  • docs/increments/active/2026-07-22-secure-hybrid-retrieval/plan.md
  • docs/roadmap.md
  • docs/specs/domains/knowledge-ingestion.md

⚙️ CodeRabbit configuration file

docs/**/*.md: Preserve the thin-map documentation harness. Current facts belong in
architecture, specs, and tests only after implementation; future intent
belongs in vision, roadmap, or one active increment. Flag duplicated or
contradictory sources of truth.

Files:

  • docs/increments/active/2026-07-22-secure-hybrid-retrieval/plan.md
  • docs/roadmap.md
  • docs/specs/domains/knowledge-ingestion.md
docs/**/*

📄 CodeRabbit inference engine (docs/conventions.md)

Keep provider credentials out of clients, logs, documentation, and git.

Files:

  • docs/increments/active/2026-07-22-secure-hybrid-retrieval/plan.md
  • docs/roadmap.md
  • docs/specs/domains/knowledge-ingestion.md
docs/increments/active/**/*.md

📄 CodeRabbit inference engine (CLAUDE.md)

For each increment, create docs/increments/active/YYYY-MM-DD-slug/design.md followed by plan.md; execute one coherent slice, consolidate current facts/specs/tests/decisions, and move the increment to completed.

Files:

  • docs/increments/active/2026-07-22-secure-hybrid-retrieval/plan.md
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

For frontend files, use Oxlint, TypeScript typecheck, the production build, and browser tests when the UI flow matters.

Files:

  • web/src/features/sources/api/upload-source.ts
  • web/src/features/session/csrf-fetch.ts
  • web/src/features/sources/components/source-upload-dialog.tsx
  • web/src/features/sources/components/sources-page.tsx
**/*.{ts,tsx,js,jsx,json,html,css,scss}

📄 CodeRabbit inference engine (CLAUDE.md)

Do not run JetBrains IDE inspection on TypeScript, TSX, or web configuration files.

Files:

  • web/src/features/sources/api/upload-source.ts
  • web/src/features/session/csrf-fetch.ts
  • web/src/features/sources/components/source-upload-dialog.tsx
  • web/src/features/sources/components/sources-page.tsx
web/src/**/*.{ts,tsx}

⚙️ CodeRabbit configuration file

web/src/**/*.{ts,tsx}: OAuth access and refresh tokens must never enter browser JavaScript or
browser storage. Use the HttpOnly BFF session, CSRF-protected mutations,
generated Hey API data clients, accessible states, and both light and
dark themes. Handwritten transport is reserved for documented protocol
flows such as navigation redirects and streaming.

Files:

  • web/src/features/sources/api/upload-source.ts
  • web/src/features/session/csrf-fetch.ts
  • web/src/features/sources/components/source-upload-dialog.tsx
  • web/src/features/sources/components/sources-page.tsx
core/src/main/resources/db/migration/*.sql

⚙️ CodeRabbit configuration file

core/src/main/resources/db/migration/*.sql: Flyway migrations are immutable after release. Check tenant isolation,
foreign keys, uniqueness, indexes, append-only evidence semantics, safe
defaults, and compatibility with PostgreSQL 18 plus pgvector.

Files:

  • core/src/main/resources/db/migration/V18__knowledge_space_upload_authorization.sql
**/*.{yml,yaml,properties}

📄 CodeRabbit inference engine (CLAUDE.md)

Keep ddl-auto=validate in application configuration.

Files:

  • integrations/authorization-openfga/src/test/openfga/store.fga.yaml
integrations/authorization-openfga/**/*

⚙️ CodeRabbit configuration file

integrations/authorization-openfga/**/*: Source-native ACL is a hard ceiling. Flag any parent, organization, role,
or wildcard relation that can broaden source access. Require negative
Check and ListObjects coverage for every new permission path.

Files:

  • integrations/authorization-openfga/src/test/openfga/store.fga.yaml
🪛 PMD (7.26.0)
core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceService.java

[Medium] 61-62: PreserveStackTrace (Best Practices): Thrown exception does not preserve the stack trace of exception 'invalidProjection' on all code paths

(PreserveStackTrace (Best Practices))

🪛 SQLFluff (4.2.2)
core/src/main/resources/db/migration/V18__knowledge_space_upload_authorization.sql

[error] 163-164: CREATE INDEX should use CONCURRENTLY to avoid locking the table during the build.

(PG01)


[error] 165-166: CREATE INDEX should use CONCURRENTLY to avoid locking the table during the build.

(PG01)


[error] 167-168: CREATE INDEX should use CONCURRENTLY to avoid locking the table during the build.

(PG01)

🪛 Squawk (2.59.0)
core/src/main/resources/db/migration/V18__knowledge_space_upload_authorization.sql

[warning] 5-5: Changing the size of a varchar field requires an ACCESS EXCLUSIVE lock, that will prevent all reads and writes to the table. Use a TEXT field with a CHECK constraint.

(prefer-text-field)


[warning] 6-6: Changing the size of a varchar field requires an ACCESS EXCLUSIVE lock, that will prevent all reads and writes to the table. Use a TEXT field with a CHECK constraint.

(prefer-text-field)


[warning] 99-99: Setting a column NOT NULL blocks reads while the table is scanned. Make the field nullable and use a CHECK constraint instead.

(adding-not-nullable-field)


[warning] 100-102: By default new constraints require a table scan and block writes to the table while that scan occurs. Use NOT VALID with a later VALIDATE CONSTRAINT call.

(constraint-missing-not-valid)


[warning] 100-102: Adding a foreign key constraint requires a table scan and a SHARE ROW EXCLUSIVE lock on both tables, which blocks writes to each table. Add NOT VALID to the constraint in one transaction and then VALIDATE the constraint in a separate transaction.

(adding-foreign-key-constraint)


[warning] 114-114: Setting a column NOT NULL blocks reads while the table is scanned. Make the field nullable and use a CHECK constraint instead.

(adding-not-nullable-field)


[warning] 115-117: By default new constraints require a table scan and block writes to the table while that scan occurs. Use NOT VALID with a later VALIDATE CONSTRAINT call.

(constraint-missing-not-valid)


[warning] 115-117: Adding a foreign key constraint requires a table scan and a SHARE ROW EXCLUSIVE lock on both tables, which blocks writes to each table. Add NOT VALID to the constraint in one transaction and then VALIDATE the constraint in a separate transaction.

(adding-foreign-key-constraint)


[warning] 143-143: Setting a column NOT NULL blocks reads while the table is scanned. Make the field nullable and use a CHECK constraint instead.

(adding-not-nullable-field)


[warning] 144-146: By default new constraints require a table scan and block writes to the table while that scan occurs. Use NOT VALID with a later VALIDATE CONSTRAINT call.

(constraint-missing-not-valid)


[warning] 144-146: Adding a foreign key constraint requires a table scan and a SHARE ROW EXCLUSIVE lock on both tables, which blocks writes to each table. Add NOT VALID to the constraint in one transaction and then VALIDATE the constraint in a separate transaction.

(adding-foreign-key-constraint)


[warning] 158-158: Setting a column NOT NULL blocks reads while the table is scanned. Make the field nullable and use a CHECK constraint instead.

(adding-not-nullable-field)


[warning] 159-161: By default new constraints require a table scan and block writes to the table while that scan occurs. Use NOT VALID with a later VALIDATE CONSTRAINT call.

(constraint-missing-not-valid)


[warning] 159-161: Adding a foreign key constraint requires a table scan and a SHARE ROW EXCLUSIVE lock on both tables, which blocks writes to each table. Add NOT VALID to the constraint in one transaction and then VALIDATE the constraint in a separate transaction.

(adding-foreign-key-constraint)


[warning] 165-166: During normal index creation, table updates are blocked, but reads are still allowed. Use concurrently to avoid blocking writes.

(require-concurrent-index-creation)


[warning] 167-168: During normal index creation, table updates are blocked, but reads are still allowed. Use concurrently to avoid blocking writes.

(require-concurrent-index-creation)

🔇 Additional comments (38)
core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationService.java (1)

43-46: LGTM!

core/src/main/java/com/orgmemory/core/knowledge/KnowledgeIngestionService.java (1)

42-68: LGTM!

Also applies to: 268-314

core/src/main/java/com/orgmemory/core/knowledge/SourceIngestionCoordinator.java (1)

137-137: LGTM!

core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationCoordinator.java (1)

33-36: LGTM!

Also applies to: 132-132

apps/worker/src/main/java/com/orgmemory/worker/ingestion/SourceIngestionProcessor.java (1)

179-179: LGTM!

Also applies to: 266-287

apps/worker/src/test/java/com/orgmemory/worker/ingestion/SourceIngestionPipelineIntegrationTests.java (1)

89-89: LGTM!

Also applies to: 154-163, 373-382

apps/api/src/test/java/com/orgmemory/api/knowledge/KnowledgeIngestionIntegrationTests.java (1)

54-54: LGTM!

Also applies to: 91-93, 196-199, 481-481

ARCHITECTURE.md (1)

62-62: LGTM!

Also applies to: 78-83, 97-98, 107-116

docs/increments/active/2026-07-22-secure-hybrid-retrieval/plan.md (1)

40-42: LGTM!

docs/roadmap.md (1)

13-14: LGTM!

Also applies to: 29-30

docs/specs/domains/knowledge-ingestion.md (1)

6-18: LGTM!

Also applies to: 31-40

core/src/main/java/com/orgmemory/core/knowledge/CreateUploadSourceCommand.java (1)

5-13: LGTM!

core/src/main/java/com/orgmemory/core/knowledge/PromoteNormalizedRecordCommand.java (1)

6-10: LGTM!

core/src/main/java/com/orgmemory/core/knowledge/PublishKnowledgeAssetCommand.java (1)

7-35: LGTM!

core/src/main/java/com/orgmemory/core/knowledge/ClaimedSourceRevision.java (1)

8-27: LGTM!

apps/api/src/main/java/com/orgmemory/api/knowledge/KnowledgeSpaceController.java (1)

24-31: LGTM!

apps/api/src/main/java/com/orgmemory/api/ApiExceptionHandler.java (1)

58-61: LGTM!

core/src/test/java/com/orgmemory/core/knowledge/KnowledgeSpaceServiceTests.java (1)

24-100: LGTM!

core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpace.java (1)

9-43: LGTM!

core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceRepository.java (1)

9-18: LGTM!

core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceTarget.java (2)

6-16: LGTM!


18-23: 🎯 Functional Correctness

No need to expose requireText KnowledgeSpaceTarget.requireText(...) is only used by the record itself; KnowledgeIngestionService defines a separate helper with the same name.

			> Likely an incorrect or invalid review comment.
core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceUnavailableException.java (1)

3-7: LGTM!

core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAsset.java (1)

24-25: LGTM!

Also applies to: 76-80, 127-129

core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationOutbox.java (1)

20-21: LGTM!

Also applies to: 74-102, 135-136

core/src/main/java/com/orgmemory/core/knowledge/KnowledgeAssetPublicationState.java (1)

5-17: LGTM!

core/src/main/java/com/orgmemory/core/knowledge/SourceObject.java (1)

20-21: LGTM!

Also applies to: 60-81, 91-92

core/src/main/java/com/orgmemory/core/knowledge/SourceRevision.java (1)

21-22: LGTM!

Also applies to: 99-119, 172-173

core/src/main/java/com/orgmemory/core/knowledge/KnowledgeSpaceService.java (1)

19-110: LGTM!

apps/api/src/main/java/com/orgmemory/api/knowledge/KnowledgeSpaceResponse.java (1)

6-15: LGTM!

apps/api/src/main/java/com/orgmemory/api/source/SourceController.java (1)

12-12: LGTM!

Also applies to: 53-64

core/src/main/java/com/orgmemory/core/knowledge/SourceUploadService.java (1)

29-59: LGTM!

Also applies to: 83-83, 118-121

core/src/main/java/com/orgmemory/core/knowledge/SourceUploadRegistrationService.java (1)

40-49: LGTM!

core/src/test/java/com/orgmemory/core/knowledge/SourceUploadServiceTests.java (1)

20-51: LGTM!

web/src/features/session/csrf-fetch.ts (1)

29-36: LGTM!

web/src/features/sources/api/upload-source.ts (1)

6-15: LGTM!

web/src/features/sources/components/source-upload-dialog.tsx (1)

19-68: LGTM!

Also applies to: 104-151, 173-176

web/src/features/sources/components/sources-page.tsx (1)

20-24: LGTM!

Also applies to: 37-37, 77-80

Comment thread apps/api/src/test/java/com/orgmemory/api/source/SourceUploadIntegrationTests.java Outdated
Comment thread integrations/authorization-openfga/src/test/openfga/store.fga.yaml

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/src/features/sources/components/source-upload-dialog.tsx (1)

43-45: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clear or reject a space that becomes ineligible.

A no-department space selected under INTERNAL remains selected after switching to PUBLIC or RESTRICTED, even though availableSpaces removes it. If another eligible space exists, submit remains enabled and sends the now-hidden ID.

Proposed fix
 onValueChange={(value: string) => {
   const next = value as UploadSourceInput["classification"]
   setClassification(next)
   const selected = spaces.find((space) => space.id === knowledgeSpaceId)
-  if (next === "CONFIDENTIAL" && !selected?.departmentId) setKnowledgeSpaceId("")
+  const stillEligible =
+    selected?.id &&
+    selected.name &&
+    (next === "INTERNAL" || Boolean(selected.departmentId))
+  if (!stillEligible) setKnowledgeSpaceId("")
 }}

Also applies to: 54-64, 146-151

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/features/sources/components/source-upload-dialog.tsx` around lines 43
- 45, Update the source selection state alongside the availableSpaces filtering
so a selected space that becomes ineligible after classification changes is
cleared or rejected. Ensure the submit flow uses only currently eligible spaces,
including the related selection initialization and submit logic around the
source upload dialog.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@integrations/authorization-openfga/src/test/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationSetAdapterTests.java`:
- Around line 75-80: Capture the ClientBatchCheckRequest passed to
client.batchCheck in the test, then assert its outgoing checks use correlation
IDs "0" and "1" before validating the mocked response. Keep the existing
allowedItem and deniedItem response assertions unchanged.

---

Outside diff comments:
In `@web/src/features/sources/components/source-upload-dialog.tsx`:
- Around line 43-45: Update the source selection state alongside the
availableSpaces filtering so a selected space that becomes ineligible after
classification changes is cleared or rejected. Ensure the submit flow uses only
currently eligible spaces, including the related selection initialization and
submit logic around the source upload dialog.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b5453427-2c43-436d-bc10-e65d99502432

📥 Commits

Reviewing files that changed from the base of the PR and between 605248a and 18d8e6d.

⛔ Files ignored due to path filters (1)
  • demo/fixtures/openfga/dataset-tuples.csv is excluded by !**/*.csv
📒 Files selected for processing (20)
  • .env.example
  • apps/api/src/main/java/com/orgmemory/api/source/SourceController.java
  • apps/api/src/main/resources/application.yml
  • apps/worker/src/main/java/com/orgmemory/worker/OrgMemoryWorkerApplication.java
  • apps/worker/src/main/java/com/orgmemory/worker/ingestion/SourceIngestionProcessor.java
  • apps/worker/src/main/resources/application.yml
  • core/src/main/java/com/orgmemory/core/knowledge/SecureKnowledgeRetrievalStore.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceObjectRepository.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceQueryService.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceUploadService.java
  • core/src/test/java/com/orgmemory/core/knowledge/SourceQueryServiceTests.java
  • demo/fixtures/postgres/directory.sql
  • docs/specs/domains/knowledge-ingestion.md
  • integrations/ai-openai-compatible/src/main/java/com/orgmemory/integrations/ai/openai/AiGatewayProperties.java
  • integrations/ai-openai-compatible/src/test/java/com/orgmemory/integrations/ai/openai/AiGatewayPropertiesTests.java
  • integrations/authorization-openfga/src/main/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationAdapter.java
  • integrations/authorization-openfga/src/main/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationSetAdapter.java
  • integrations/authorization-openfga/src/test/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationSetAdapterTests.java
  • web/src/features/sources/api/upload-source.ts
  • web/src/features/sources/components/source-upload-dialog.tsx
💤 Files with no reviewable changes (1)
  • core/src/main/java/com/orgmemory/core/knowledge/SourceUploadService.java
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Backend · Java 25
🧰 Additional context used
📓 Path-based instructions (12)
**/*

📄 CodeRabbit inference engine (CLAUDE.md)

**/*: Before changing unfamiliar Spring Boot 4, Spring Modulith 2, Spring AI 2, Gradle, React, Vite, Tailwind, or TypeScript APIs, consult Context7/current official documentation and the project orgmemory-* verification skills.
Read docs/guidelines/agent-safety.md before retrieval, AI, MCP, permission, upload, graph, or export work.
Never commit .env files, provider keys, tokens, or customer data.
Run the relevant gates from docs/guidelines/testing-harness.md; use a terminating clean test as the context gate, and do not treat bootRun as verification.
Current behavior belongs in architecture/specs only after it exists in code; intent belongs in vision, roadmap, or an active increment, and repository state must not be duplicated across documents.

Files:

  • apps/worker/src/main/resources/application.yml
  • core/src/main/java/com/orgmemory/core/knowledge/SourceObjectRepository.java
  • core/src/main/java/com/orgmemory/core/knowledge/SecureKnowledgeRetrievalStore.java
  • demo/fixtures/postgres/directory.sql
  • apps/worker/src/main/java/com/orgmemory/worker/OrgMemoryWorkerApplication.java
  • apps/api/src/main/java/com/orgmemory/api/source/SourceController.java
  • web/src/features/sources/api/upload-source.ts
  • integrations/ai-openai-compatible/src/main/java/com/orgmemory/integrations/ai/openai/AiGatewayProperties.java
  • integrations/ai-openai-compatible/src/test/java/com/orgmemory/integrations/ai/openai/AiGatewayPropertiesTests.java
  • integrations/authorization-openfga/src/main/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationAdapter.java
  • docs/specs/domains/knowledge-ingestion.md
  • core/src/test/java/com/orgmemory/core/knowledge/SourceQueryServiceTests.java
  • integrations/authorization-openfga/src/test/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationSetAdapterTests.java
  • integrations/authorization-openfga/src/main/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationSetAdapter.java
  • apps/worker/src/main/java/com/orgmemory/worker/ingestion/SourceIngestionProcessor.java
  • web/src/features/sources/components/source-upload-dialog.tsx
  • apps/api/src/main/resources/application.yml
  • core/src/main/java/com/orgmemory/core/knowledge/SourceQueryService.java
**/*.{yml,yaml,properties}

📄 CodeRabbit inference engine (CLAUDE.md)

Keep ddl-auto=validate in application configuration.

Files:

  • apps/worker/src/main/resources/application.yml
  • apps/api/src/main/resources/application.yml
**/*.{java,sql}

📄 CodeRabbit inference engine (CLAUDE.md)

Pair JPA schema changes with a Flyway migration.

Files:

  • core/src/main/java/com/orgmemory/core/knowledge/SourceObjectRepository.java
  • core/src/main/java/com/orgmemory/core/knowledge/SecureKnowledgeRetrievalStore.java
  • demo/fixtures/postgres/directory.sql
  • apps/worker/src/main/java/com/orgmemory/worker/OrgMemoryWorkerApplication.java
  • apps/api/src/main/java/com/orgmemory/api/source/SourceController.java
  • integrations/ai-openai-compatible/src/main/java/com/orgmemory/integrations/ai/openai/AiGatewayProperties.java
  • integrations/ai-openai-compatible/src/test/java/com/orgmemory/integrations/ai/openai/AiGatewayPropertiesTests.java
  • integrations/authorization-openfga/src/main/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationAdapter.java
  • core/src/test/java/com/orgmemory/core/knowledge/SourceQueryServiceTests.java
  • integrations/authorization-openfga/src/test/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationSetAdapterTests.java
  • integrations/authorization-openfga/src/main/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationSetAdapter.java
  • apps/worker/src/main/java/com/orgmemory/worker/ingestion/SourceIngestionProcessor.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceQueryService.java
**/*.java

📄 CodeRabbit inference engine (CLAUDE.md)

JetBrains IDE inspection is a Java-backend gate only.

Files:

  • core/src/main/java/com/orgmemory/core/knowledge/SourceObjectRepository.java
  • core/src/main/java/com/orgmemory/core/knowledge/SecureKnowledgeRetrievalStore.java
  • apps/worker/src/main/java/com/orgmemory/worker/OrgMemoryWorkerApplication.java
  • apps/api/src/main/java/com/orgmemory/api/source/SourceController.java
  • integrations/ai-openai-compatible/src/main/java/com/orgmemory/integrations/ai/openai/AiGatewayProperties.java
  • integrations/ai-openai-compatible/src/test/java/com/orgmemory/integrations/ai/openai/AiGatewayPropertiesTests.java
  • integrations/authorization-openfga/src/main/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationAdapter.java
  • core/src/test/java/com/orgmemory/core/knowledge/SourceQueryServiceTests.java
  • integrations/authorization-openfga/src/test/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationSetAdapterTests.java
  • integrations/authorization-openfga/src/main/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationSetAdapter.java
  • apps/worker/src/main/java/com/orgmemory/worker/ingestion/SourceIngestionProcessor.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceQueryService.java
core/src/main/java/com/orgmemory/core/{authorization,knowledge,permission}/**/*.java

⚙️ CodeRabbit configuration file

core/src/main/java/com/orgmemory/core/{authorization,knowledge,permission}/**/*.java: Treat PostgreSQL ACL evidence as canonical and OpenFGA as the relationship
authorization decision point. Authorization must fail closed. Filtering
must happen before ranking, LIMIT, graph traversal, answer generation,
export, and citation rendering. Flag metadata or timing leak paths.

Files:

  • core/src/main/java/com/orgmemory/core/knowledge/SourceObjectRepository.java
  • core/src/main/java/com/orgmemory/core/knowledge/SecureKnowledgeRetrievalStore.java
  • core/src/main/java/com/orgmemory/core/knowledge/SourceQueryService.java
apps/api/src/main/java/**/*.java

⚙️ CodeRabbit configuration file

apps/api/src/main/java/**/*.java: Enforce the browser-BFF and resource-server boundaries. Authentication
must resolve an active internal actor through the explicit issuer and
subject binding. Reject identity, tenant, roles, or permissions supplied
by request payloads, JWT email, or untrusted JWT role claims.

Files:

  • apps/api/src/main/java/com/orgmemory/api/source/SourceController.java
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

For frontend files, use Oxlint, TypeScript typecheck, the production build, and browser tests when the UI flow matters.

Files:

  • web/src/features/sources/api/upload-source.ts
  • web/src/features/sources/components/source-upload-dialog.tsx
**/*.{ts,tsx,js,jsx,json,html,css,scss}

📄 CodeRabbit inference engine (CLAUDE.md)

Do not run JetBrains IDE inspection on TypeScript, TSX, or web configuration files.

Files:

  • web/src/features/sources/api/upload-source.ts
  • web/src/features/sources/components/source-upload-dialog.tsx
web/src/**/*.{ts,tsx}

⚙️ CodeRabbit configuration file

web/src/**/*.{ts,tsx}: OAuth access and refresh tokens must never enter browser JavaScript or
browser storage. Use the HttpOnly BFF session, CSRF-protected mutations,
generated Hey API data clients, accessible states, and both light and
dark themes. Handwritten transport is reserved for documented protocol
flows such as navigation redirects and streaming.

Files:

  • web/src/features/sources/api/upload-source.ts
  • web/src/features/sources/components/source-upload-dialog.tsx
integrations/authorization-openfga/**/*

⚙️ CodeRabbit configuration file

integrations/authorization-openfga/**/*: Source-native ACL is a hard ceiling. Flag any parent, organization, role,
or wildcard relation that can broaden source access. Require negative
Check and ListObjects coverage for every new permission path.

Files:

  • integrations/authorization-openfga/src/main/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationAdapter.java
  • integrations/authorization-openfga/src/test/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationSetAdapterTests.java
  • integrations/authorization-openfga/src/main/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationSetAdapter.java
docs/**/*.md

📄 CodeRabbit inference engine (docs/conventions.md)

docs/**/*.md: Keep ARCHITECTURE.md and specification documents limited to implemented facts; record intent in vision/roadmap documents, keep active increment plans separate, and explicitly supersede append-only decisions.
Do not create status-summary documents that duplicate existing sources of truth.

Files:

  • docs/specs/domains/knowledge-ingestion.md

⚙️ CodeRabbit configuration file

docs/**/*.md: Preserve the thin-map documentation harness. Current facts belong in
architecture, specs, and tests only after implementation; future intent
belongs in vision, roadmap, or one active increment. Flag duplicated or
contradictory sources of truth.

Files:

  • docs/specs/domains/knowledge-ingestion.md
docs/**/*

📄 CodeRabbit inference engine (docs/conventions.md)

Keep provider credentials out of clients, logs, documentation, and git.

Files:

  • docs/specs/domains/knowledge-ingestion.md
🪛 PMD (7.26.0)
integrations/authorization-openfga/src/main/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationAdapter.java

[Low] 59-64: InvalidLogMessageFormat (Error Prone): Too many arguments, expected 3 arguments but found 4

(InvalidLogMessageFormat (Error Prone))

integrations/authorization-openfga/src/main/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationSetAdapter.java

[Low] 64-69: InvalidLogMessageFormat (Error Prone): Too many arguments, expected 3 arguments but found 4

(InvalidLogMessageFormat (Error Prone))


[Low] 116-120: InvalidLogMessageFormat (Error Prone): Too many arguments, expected 2 arguments but found 3

(InvalidLogMessageFormat (Error Prone))

core/src/main/java/com/orgmemory/core/knowledge/SourceQueryService.java

[Medium] 96-97: PreserveStackTrace (Best Practices): Thrown exception does not preserve the stack trace of exception 'invalidResource' on all code paths

(PreserveStackTrace (Best Practices))

🔇 Additional comments (20)
integrations/authorization-openfga/src/main/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationAdapter.java (1)

15-21: LGTM!

Also applies to: 59-64

integrations/authorization-openfga/src/main/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationSetAdapter.java (1)

17-31: LGTM!

Also applies to: 64-91, 116-120

integrations/authorization-openfga/src/test/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationSetAdapterTests.java (1)

95-95: LGTM!

Also applies to: 149-154

apps/api/src/main/java/com/orgmemory/api/source/SourceController.java (1)

41-44: LGTM!

Also applies to: 53-64

web/src/features/sources/api/upload-source.ts (1)

3-7: LGTM!

web/src/features/sources/components/source-upload-dialog.tsx (1)

104-139: LGTM!

Also applies to: 157-160, 175-178

apps/worker/src/main/java/com/orgmemory/worker/ingestion/SourceIngestionProcessor.java (1)

177-187: LGTM!

Also applies to: 248-285

core/src/main/java/com/orgmemory/core/knowledge/SecureKnowledgeRetrievalStore.java (1)

220-230: LGTM!

core/src/main/java/com/orgmemory/core/knowledge/SourceObjectRepository.java (1)

3-3: LGTM!

Also applies to: 13-14

core/src/main/java/com/orgmemory/core/knowledge/SourceQueryService.java (1)

23-140: LGTM!

core/src/test/java/com/orgmemory/core/knowledge/SourceQueryServiceTests.java (1)

52-107: LGTM!

apps/worker/src/main/java/com/orgmemory/worker/OrgMemoryWorkerApplication.java (1)

3-3: LGTM!

Also applies to: 20-24

docs/specs/domains/knowledge-ingestion.md (1)

5-22: LGTM!

Also applies to: 31-41

demo/fixtures/postgres/directory.sql (1)

10-17: LGTM!

integrations/ai-openai-compatible/src/main/java/com/orgmemory/integrations/ai/openai/AiGatewayProperties.java (1)

90-98: LGTM!

integrations/ai-openai-compatible/src/test/java/com/orgmemory/integrations/ai/openai/AiGatewayPropertiesTests.java (1)

47-53: LGTM!

.env.example (1)

5-6: LGTM!

apps/api/src/main/resources/application.yml (2)

11-11: LGTM!

Also applies to: 59-65


58-58: 🎯 Functional Correctness

No change needed for the OpenAI base URL

The /v1 default belongs to orgmemory.ai.gateways.openai.base-url in both files; there is no spring.ai.openai.base-url here, so this change is not needed.

			> Likely an incorrect or invalid review comment.
apps/worker/src/main/resources/application.yml (1)

6-6: LGTM!

Also applies to: 37-43

Comment on lines +75 to +80
ClientBatchCheckItem allowedItem = item(allowed, "0");
ClientBatchCheckItem deniedItem = item(denied, "1");
when(client.batchCheck(any(ClientBatchCheckRequest.class))).thenReturn(
CompletableFuture.completedFuture(new ClientBatchCheckResponse(List.of(
new ClientBatchCheckSingleResponse(true, allowedItem, allowed.openFgaObject(), null),
new ClientBatchCheckSingleResponse(false, deniedItem, denied.openFgaObject(), null)))));
new ClientBatchCheckSingleResponse(true, allowedItem, "0", null),
new ClientBatchCheckSingleResponse(false, deniedItem, "1", null)))));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the outgoing correlation IDs as well.

Because client.batchCheck(any(...)) ignores the request, this test would still pass if the adapter sent incorrect correlation IDs. Capture the ClientBatchCheckRequest and assert that its checks use "0" and "1" before validating the mocked response.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@integrations/authorization-openfga/src/test/java/com/orgmemory/integrations/authorization/openfga/OpenFgaRelationshipAuthorizationSetAdapterTests.java`
around lines 75 - 80, Capture the ClientBatchCheckRequest passed to
client.batchCheck in the test, then assert its outgoing checks use correlation
IDs "0" and "1" before validating the mocked response. Keep the existing
allowedItem and deniedItem response assertions unchanged.

@kl3inIT
kl3inIT merged commit acf767a into main Jul 22, 2026
5 checks passed
@kl3inIT
kl3inIT deleted the feat/knowledge-space-upload-authz branch July 22, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant