Skip to content

CE Refactor Part 1: create the Models package#338

Merged
mushrafmim merged 14 commits intomainfrom
337-ce-refactor-part-1
Nov 27, 2025
Merged

CE Refactor Part 1: create the Models package#338
mushrafmim merged 14 commits intomainfrom
337-ce-refactor-part-1

Conversation

@ginaxu1
Copy link
Copy Markdown
Collaborator

@ginaxu1 ginaxu1 commented Nov 22, 2025

For CE Refactor Plan, see https://docs.google.com/document/d/1dLXTVaaMW095MZTpu34cvhbIGenb0ZsBv6-moqvGRXE/edit?tab=t.0#heading=h.tgfrgqvunxrb. This first PR gets the models package in place and ready for PR 2 (Service Package). Models contains domain types, DTOs, constants

Notes:

  • Backward compatibility: Maintained via type aliases in engine.go
  • No breaking changes: All existing code continues to work

Testing

go mod tidy && go build . && go test ./... -count=1

Related to #337

@ginaxu1 ginaxu1 force-pushed the 337-ce-refactor-part-1 branch from 84b78ed to b461b69 Compare November 25, 2025 18:12
@ginaxu1 ginaxu1 force-pushed the 337-ce-refactor-part-1 branch from b461b69 to be186ad Compare November 25, 2025 18:19
@ginaxu1 ginaxu1 force-pushed the 337-ce-refactor-part-1 branch from be186ad to 0c99888 Compare November 25, 2025 18:20
@ginaxu1 ginaxu1 changed the title CE Refactor PR 1: create the Models package CE Refactor Part 1: create the Models package Nov 25, 2025
@ginaxu1
Copy link
Copy Markdown
Collaborator Author

ginaxu1 commented Nov 26, 2025

@sthanikan2000 - now ConsentRecord has 2 expiredAt fields: PendingExpiresAt *time.Time and GrantExpiresAt *time.Timewith PendingTimeoutDuration config (e.g., default "24h" or "P1D").

  1. when consent record created, set PendingExpiresAt = now + PendingTimeoutDuration when creating pending consent. Don't set GrantExpiresAt until approved

  2. when status changes to "approved", set GrantExpiresAt = now + GrantDuration. Clear PendingExpiresAt

  3. when update CheckConsentExpiry, first check pending records: PendingExpiresAt < now → set status to "expired". then check approved records: GrantExpiresAt < now → set status to "expired".

Database migration: need to add pending_expires_at and grant_expires_at columns (nullable)

other changes

  • consent_id now uuid like policy_metadata, using GORM to define all consent record fields
  • enum for ConsentErrorCode constants

Copy link
Copy Markdown
Member

@sthanikan2000 sthanikan2000 left a comment

Choose a reason for hiding this comment

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

The reason for suggesting the pointers is when we are referring to these variables without pointers the variable will be the null value of that data type instead of the null data type
Correct the indentations after doing these changes

@mushrafmim mushrafmim merged commit bff1aa2 into main Nov 27, 2025
2 checks passed
@mushrafmim mushrafmim deleted the 337-ce-refactor-part-1 branch November 27, 2025 05:36
sthanikan2000 added a commit that referenced this pull request Jan 13, 2026
* PR 1 update models and create error codes

* Redo changes but in v1 directory per Thanikan suggestion

* Address Thanikan feedback

* Rename v1/models/types.go → v1/models/consent.go

* Clean up

* Update exchange/consent-engine/v1/models/dtos.go

Co-authored-by: Thanikan Sivatheepan <sthanikan2000@gmail.com>

* Update exchange/consent-engine/v1/models/consent.go

Co-authored-by: Thanikan Sivatheepan <sthanikan2000@gmail.com>

* Update exchange/consent-engine/v1/models/constants.go

Co-authored-by: Thanikan Sivatheepan <sthanikan2000@gmail.com>

* resolve merge conflicts and address other comment around v1/models

* Clarify comments in ExpiresAt and GrantDuration

* Address Thanikan comments around errormessage enums and expiresAt

* Clean up

* Address remaining comments

* fix wrong type make sure that we are consistently using  in

---------

Co-authored-by: Thanikan Sivatheepan <sthanikan2000@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Priority/Normal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants