Skip to content

fix: cross-project context traversal#874

Open
sourrris wants to merge 1 commit into
basicmachines-co:mainfrom
sourrris:sourrris/fix-873-cross-project-context
Open

fix: cross-project context traversal#874
sourrris wants to merge 1 commit into
basicmachines-co:mainfrom
sourrris:sourrris/fix-873-cross-project-context

Conversation

@sourrris
Copy link
Copy Markdown

@sourrris sourrris commented May 31, 2026

Summary

Fixes #873.

This updates build_context relation traversal so an explicit wiki-link/relation can cross from the selected project into another project, and then continue along the reached project’s own relation edges. The seed entity still has to belong to the requested project, and unrelated incoming links from other projects are not pulled into the context.

Root Cause

The recursive context CTE forced every reached entity through the seed project filter. That meant a valid relation from project A to an entity in project B could be returned as a relation row, but the target entity could not be expanded or hydrated as graph context.

Changes

  • Keep the starting entity project-scoped, but carry each reached entity’s project_id through traversal.
  • Follow only relation rows owned by the currently reached entity’s project.
  • Allow graph hydration to opt into cross-project entity IDs that were already reached by validated traversal.
  • Add a visited-entity path guard so cyclic note graphs do not repeatedly revisit the same entity until the depth cap.
  • Add regression coverage for cross-project expansion, unrelated incoming-link isolation, API hydration, and cycle traversal.

Validation

  • just install
  • TZ=UTC PYTHONPATH=/Users/sourrrish/Documents/Opensource/basic-memory/src DOCKER_HOST=unix:///Users/sourrrish/.colima/default/docker.sock TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock just check-all
    • Lint, format, and typecheck passed.
    • SQLite unit: 2685 passed, 31 skipped.
    • SQLite integration: 322 passed, 4 skipped, 20 deselected.
    • Postgres unit: 2669 passed, 47 skipped.
    • Semantic integration: 19 passed, 1 skipped.
    • The Postgres integration wrapper in just check-all hit its 600s timeout at 86%, so I reran the exact suite without that timeout.
  • TZ=UTC PYTHONPATH=/Users/sourrrish/Documents/Opensource/basic-memory/src DOCKER_HOST=unix:///Users/sourrrish/.colima/default/docker.sock TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock BASIC_MEMORY_ENV=test BASIC_MEMORY_TEST_POSTGRES=1 uv run pytest -p pytest_mock -v --no-cov -m "not semantic" test-int
    • Postgres integration: 313 passed, 13 skipped, 20 deselected.

Signed-off-by: sourrrish <officialsourish0@gmail.com>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 31, 2026

CLA assistant check
All committers have signed the CLA.

@sourrris sourrris changed the title [codex] fix cross-project context traversal fix cross-project context traversal May 31, 2026
@sourrris sourrris changed the title fix cross-project context traversal fix: cross-project context traversal May 31, 2026
@sourrris sourrris marked this pull request as ready for review May 31, 2026 11:04
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.

[BUG] build_context fails to expand cross-project wiki-links even when no project is specified

2 participants