feat(repo_models): Add RepositoryAgentMdSnapshot model - #822
Conversation
This change adds a new SQLModel class `RepositoryAgentMdSnapshot` to the `repo_models.py` file. This model represents a table in the `code_confluence` schema that stores the agent metadata snapshot for a given repository. The new model includes the following fields: - `repository_name`: The name of the repository - `repository_owner_name`: The name of the repository owner - `agent_md_output`: A JSONB field that stores the complete final payload from the `generate_sse_events()` function, containing per-codebase agent data - `created_at`: The timestamp when the row was first inserted - `modified_at`: The timestamp when the latest overwrite occurred The model also includes a one-to-one relationship with the `Repository` model, allowing easy access to the repository information associated with the agent metadata snapshot. This change is important as it provides a way to store and retrieve the agent metadata for a given repository, which is crucial for various analysis and reporting tasks within the code confluence system.
|
Connected to Huly®: UNOPL-959 |
|
Claude finished @JayGhiya's task —— View job Code Review Complete ✅Reviewing the PR for code quality, potential issues, performance, security, and test coverage:
Code Review Feedback✅ Strengths
🔍 Areas for ImprovementCode Quality & Best Practices
Performance Considerations
Security Considerations
Missing Test Coverage
📝 Suggested Test Casesdef test_repository_agent_md_snapshot_creation():
"""Test basic model creation and field validation."""
def test_repository_relationship():
"""Test one-to-one relationship with Repository model."""
def test_cascade_delete():
"""Test that snapshot is deleted when repository is deleted."""
def test_timestamp_auto_update():
"""Test created_at and modified_at behavior."""
def test_jsonb_storage():
"""Test storing and retrieving complex JSON data."""🎯 Overall AssessmentQuality Score: 8/10 The implementation is solid and follows established patterns well. The main areas for improvement are:
This is a well-designed addition that fits cleanly into the existing architecture. The one-to-one relationship design is appropriate for storing agent metadata snapshots. |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||
There was a problem hiding this comment.
Codex Review: Here are some suggestions.
Reply with @codex fix comments to fix any unresolved comments.
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, or 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 fix this CI failure" or "@codex address that feedback".
| agent_md_snapshot: Mapped[Optional["RepositoryAgentMdSnapshot"]] = relationship( | ||
| back_populates="repository", | ||
| cascade="all, delete-orphan", | ||
| passive_deletes=True, | ||
| uselist=False, |
There was a problem hiding this comment.
[P1] Add single_parent for delete-orphan one-to-one relationship
The new Repository.agent_md_snapshot relationship uses cascade="all, delete-orphan" with uselist=False but omits single_parent=True. SQLAlchemy raises an ArgumentError for delete‑orphan cascades on one-to-one mappings without single_parent, so importing these models will fail before any runtime code executes. Adding single_parent=True (or removing delete-orphan) is necessary for the mapping to work.
Useful? React with 👍 / 👎.
User description
This change adds a new SQLModel class
RepositoryAgentMdSnapshotto therepo_models.pyfile. This model represents a table in thecode_confluenceschema that stores the agent metadata snapshot for a given repository.The new model includes the following fields:
repository_name: The name of the repositoryrepository_owner_name: The name of the repository owneragent_md_output: A JSONB field that stores the complete final payload from thegenerate_sse_events()function, containing per-codebase agent datacreated_at: The timestamp when the row was first insertedmodified_at: The timestamp when the latest overwrite occurredThe model also includes a one-to-one relationship with the
Repositorymodel, allowing easy access to the repository information associated with the agent metadata snapshot.This change is important as it provides a way to store and retrieve the agent metadata for a given repository, which is crucial for various analysis and reporting tasks within the code confluence system.
PR Type
Enhancement
Description
Add new
RepositoryAgentMdSnapshotSQLModel for storing agent metadataEstablish one-to-one relationship with
RepositorymodelInclude JSONB field for complete agent data payload
Add automatic timestamp tracking for creation and updates
Diagram Walkthrough
File Walkthrough
__init__.py
Export new RepositoryAgentMdSnapshot modelunoplat-code-confluence-commons/src/unoplat_code_confluence_commons/init.py
RepositoryAgentMdSnapshotmodel fromrepo_models__all__exports list for public APIrepo_models.py
Create RepositoryAgentMdSnapshot model with relationshipsunoplat-code-confluence-commons/src/unoplat_code_confluence_commons/repo_models.py
RepositoryAgentMdSnapshotSQLModel class with compositeprimary key
created_atandmodified_atfields
RepositorymodelThis is part 2 of 2 in a stack made with GitButler: