-
Notifications
You must be signed in to change notification settings - Fork 36
Fix broken tests and update models schema #500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -35,6 +35,13 @@ class UserRole(enum.Enum): | |||||
| USER = "user" | ||||||
| OFFICIAL = "official" | ||||||
|
|
||||||
| class VerificationStatus(enum.Enum): | ||||||
| PENDING = "pending" | ||||||
| VERIFIED = "verified" | ||||||
| FLAGGED = "flagged" | ||||||
| FRAUD_DETECTED = "fraud_detected" | ||||||
|
|
||||||
|
|
||||||
| class User(Base): | ||||||
| __tablename__ = "users" | ||||||
|
|
||||||
|
|
@@ -258,10 +265,21 @@ class ResolutionEvidence(Base): | |||||
| __tablename__ = "resolution_evidence" | ||||||
| id = Column(Integer, primary_key=True, index=True) | ||||||
| grievance_id = Column(Integer, ForeignKey("grievances.id"), nullable=False) | ||||||
| file_path = Column(String, nullable=False) | ||||||
| token_id = Column(Integer, nullable=True) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Missing Prompt for AI agents
Suggested change
|
||||||
| evidence_hash = Column(String, nullable=False) | ||||||
|
Comment on lines
+268
to
+269
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Disambiguate and constrain token linkage fields. Line 268 and Line 291 currently define two different Suggested schema adjustment class ResolutionEvidence(Base):
@@
- token_id = Column(Integer, nullable=True)
+ resolution_proof_token_id = Column(Integer, ForeignKey("resolution_proof_tokens.id"), nullable=True, index=True)
@@
- grievance = relationship("Grievance", back_populates="resolution_evidence")
+ grievance = relationship("Grievance", back_populates="resolution_evidence")
+ resolution_proof_token = relationship("ResolutionProofToken", back_populates="evidence_items")
class ResolutionProofToken(Base):
@@
- token_id = Column(String, unique=True, index=True)
+ token_id = Column(String, unique=True, index=True, nullable=False)
@@
- grievance = relationship("Grievance", back_populates="resolution_tokens")
+ grievance = relationship("Grievance", back_populates="resolution_tokens")
+ evidence_items = relationship("ResolutionEvidence", back_populates="resolution_proof_token")Also applies to: 291-291 🤖 Prompt for AI Agents |
||||||
| gps_latitude = Column(Float, nullable=True) | ||||||
| gps_longitude = Column(Float, nullable=True) | ||||||
| capture_timestamp = Column(DateTime, nullable=True) | ||||||
| device_fingerprint_hash = Column(String, nullable=True) | ||||||
| metadata_bundle = Column(JSON, nullable=True) | ||||||
| server_signature = Column(String, nullable=True) | ||||||
| verification_status = Column(Enum(VerificationStatus), default=VerificationStatus.PENDING) | ||||||
|
||||||
| verification_status = Column(Enum(VerificationStatus), default=VerificationStatus.PENDING) | |
| verification_status = Column(Enum(VerificationStatus), default=VerificationStatus.PENDING, nullable=False) |
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline comment # made true to match earlier schema... is confusing since this change makes the column nullable, not "true". Reword to clearly state the intention (e.g., "made nullable" / "optional for backward compatibility").
| file_path = Column(String, nullable=True) # made true to match earlier schema that had it but didn't require it in tests | |
| file_path = Column(String, nullable=True) # kept nullable to match earlier schema where this field was optional in tests |
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ResolutionProofToken.token_id is implicitly nullable here. Since token_id is used as the primary lookup key and should never be NULL, make it nullable=False (and consider adding a DB-level constraint/server_default if needed). Note that unique=True does not prevent multiple NULLs on some DBs (and can cause confusing duplicates in SQLite).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ResolutionEvidence.token_idappears to store the DB PK ofresolution_proof_tokens(see usages that queryResolutionProofToken.id == evidence.token_id). It should be declared as aForeignKey("resolution_proof_tokens.id")(and ideally indexed) to enforce referential integrity and make joins/queries safer.