feat(core): add note_content tenant schema primitive#719
Conversation
- add the shared note_content model, migration, and repository - cover CRUD, migration, and Postgres-backed repository behavior - fix the Alembic async fallback coroutine warning Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task in 2m 42s —— View job PR Review:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f13742abf8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for column_name in NoteContent.__table__.columns.keys(): | ||
| if column_name == "entity_id": | ||
| continue | ||
| setattr(existing, column_name, getattr(note_content, column_name)) |
There was a problem hiding this comment.
Preserve existing fields when upserting partial payloads
This update path overwrites every column on the existing row with attributes from a transient NoteContent object, but _coerce_note_content only requires entity_id for mapping inputs. If callers pass a partial payload (which the current signature allows), omitted fields resolve to None and non-null columns like markdown_content/db_checksum/file_write_status get clobbered, causing integrity failures or accidental data loss instead of a safe upsert.
Useful? React with 👍 / 👎.
| query = self.select().where(NoteContent.file_path == Path(file_path).as_posix()) | ||
| return await self.find_one(query) |
There was a problem hiding this comment.
Avoid single-row lookup on non-unique file paths
This method relies on find_one() (which uses one_or_none()), so it will raise MultipleResultsFound if more than one row matches a path. The new schema does not enforce (project_id, file_path) uniqueness for note_content, and mirrored paths can drift when an entity path changes before note content is realigned, so duplicate paths are possible in a project and this lookup can fail at runtime.
Useful? React with 👍 / 👎.
Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task in 1m 39s —— View job Re-review:
|
Summary
note_contentmodel, migration, and repository for cloud-facing note materialization statenote_statetonote_contentacross schema, ORM, repository, and testsTesting
uv run ruff check src/basic_memory/models/knowledge.py src/basic_memory/models/__init__.py src/basic_memory/repository/__init__.py src/basic_memory/repository/note_content_repository.py src/basic_memory/alembic/versions/l5g6h7i8j9k0_add_note_content_table.py tests/repository/test_note_content_repository.py tests/test_note_content_migration.pyLOGFIRE_IGNORE_NO_CONFIG=1 uv run pytest -q tests/test_alembic_env.py tests/repository/test_note_content_repository.py tests/test_note_content_migration.pyBASIC_MEMORY_TEST_POSTGRES=1 LOGFIRE_IGNORE_NO_CONFIG=1 uv run pytest -q tests/repository/test_note_content_repository.py