feat(orm): BaseModel CreatedUid/UpdatedUid/DeletedUid audit columns - #265
Conversation
- Add matching Go pkg/meta.BaseModel columns and SavedFilter create_uid rename migration. - Stamp actor uids on Create/Update/soft-delete/restore via TimestampUtils and soft-delete writes. - Fold SavedFilter CreateUid into BaseModel CreatedUid across RR, FE, and SF11 tests. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 36 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThe PR adds ChangesAudit UID model contract
Audit UID persistence flow
Model and SavedFilter integration
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant RequestContext
participant ModelWriteFlow
participant AuditUidUtils
participant Repository
participant Database
RequestContext->>ModelWriteFlow: submit create or update
ModelWriteFlow->>Repository: prepare write payload
Repository->>AuditUidUtils: apply actor audit fields
AuditUidUtils-->>Repository: return stamped payload
Repository->>Database: validate, encode, and persist payload
Database-->>Repository: return write result
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
- Skip legacy create_uid → created_uid compatibility; fresh CreatedUid columns are enough. Co-authored-by: Cursor <cursoragent@cursor.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- Keep TimestampUtils for *At columns only; add AuditUidUtils for *Uid create/update/soft-delete. - Wire Create/Update/instance/soft-delete paths through the new helper. Co-authored-by: Cursor <cursoragent@cursor.com>
- Move CreatedAt/UpdatedAt and audit uid stamping from the model layer into create/update repository prepare so soft-delete cascade and other write enrich share one path. - Keep soft-delete SET stamping in place and update write tests plus util/SavedFilter comments for the new call sites. Co-authored-by: Cursor <cursoragent@cursor.com>
- Add created_uid/updated_uid/deleted_uid to auth_role_ui_resource Go test tables so GORM inserts match BaseModel. - Stop expecting model Create follow-up updates to set UpdatedAt; repository prepare owns the stamp. Co-authored-by: Cursor <cursoragent@cursor.com>
- Relax create/update orchestration assertions so validate and SQL payloads may include repository-prepare CreatedAt/UpdatedAt. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
modules/web/web/composables/search/useSavedFilters.ts (1)
79-87: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd
CreatedUidtoSavedFilterRow.
SavedFilterRowdoes not declareCreatedUid, but these lines request and read it through(r as any). The cast prevents TypeScript from checking the creator identity used for shared-filter deletion eligibility.Proposed fix
export type SavedFilterRow = { Id?: string; Name?: string; Condition?: any; IsDefault?: boolean; UserId?: string | null; + CreatedUid?: string | null; };🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@modules/web/web/composables/search/useSavedFilters.ts` around lines 79 - 87, Update the SavedFilterRow type to declare the CreatedUid field, then access CreatedUid directly in the saved-filter mapping logic instead of casting each row to any. Preserve the existing trimming and fallback behavior used when deriving createUid.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@modules/core/service/orm/model/model_create.ts`:
- Around line 256-259: Update the relevant build and test workflow
configuration, not the model creation logic around repository.create: make
prepare-root-node-modules depend on prepare-embedded-assets, then enforce the
sequence of CLI build, test typecheck core, and test unit core, followed by
impact-routed E2E jobs. Locate the workflow job definitions and dependency
configuration for these named steps and preserve the existing impact routing
behavior.
In `@modules/core/service/orm/utils/audit_uid.ts`:
- Around line 27-33: The create preparation logic in addCreateUids must ignore
any client-provided CreatedUid, remove it before stamping, and set CreatedUid to
the current actor whenever one exists; update
modules/core/service/orm/utils/audit_uid.ts lines 27-33 accordingly. Update
modules/core/service/orm/utils/audit_uid.test.ts lines 15-25 and
modules/core/service/orm/repository/write/tests/create_helpers.test.ts lines
350-357 to expect U-ACTOR for CreatedUid.
---
Nitpick comments:
In `@modules/web/web/composables/search/useSavedFilters.ts`:
- Around line 79-87: Update the SavedFilterRow type to declare the CreatedUid
field, then access CreatedUid directly in the saved-filter mapping logic instead
of casting each row to any. Preserve the existing trimming and fallback behavior
used when deriving createUid.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2a4a1f17-67c1-4052-b583-5a3674f83298
📒 Files selected for processing (30)
internal/module/artifact/build/web/webBuilder_test.gomodules/base/service/tests/basemodel_audit_uid.test.tsmodules/core/service/orm/model/basemodel_audit_uid_fields.test.tsmodules/core/service/orm/model/model.tsmodules/core/service/orm/model/model_copy.test.tsmodules/core/service/orm/model/model_create.tsmodules/core/service/orm/model/model_instance.tsmodules/core/service/orm/model/model_internal_public_bridge.test.tsmodules/core/service/orm/model/model_update.tsmodules/core/service/orm/repository/authz/field_rule_helpers.tsmodules/core/service/orm/repository/authz/tests/field_rule_helpers.test.tsmodules/core/service/orm/repository/repository.test.tsmodules/core/service/orm/repository/write/create_helpers.tsmodules/core/service/orm/repository/write/delete.tsmodules/core/service/orm/repository/write/tests/create.test.tsmodules/core/service/orm/repository/write/tests/create_helpers.test.tsmodules/core/service/orm/repository/write/tests/delete.test.tsmodules/core/service/orm/repository/write/tests/update.test.tsmodules/core/service/orm/repository/write/update.tsmodules/core/service/orm/utils/audit_uid.test.tsmodules/core/service/orm/utils/audit_uid.tsmodules/core/service/orm/utils/timestamp.test.tsmodules/core/service/orm/utils/timestamp.tsmodules/web/data/bootstrap.jsonmodules/web/service/models/saved_filter.tsmodules/web/service/tests/saved_filter.test.tsmodules/web/web/composables/search/useSavedFilters.test.tsmodules/web/web/composables/search/useSavedFilters.tspkg/meta/model.gopkg/meta/model_test.go
…tedUid - Always strip client UpdatedUid on update prepare, then stamp from actor when present, so no-actor requests cannot forge write_uid. - Keep create CreatedUid setdefault per design; force UpdatedUid from actor; type SavedFilterRow.CreatedUid and drop as-any reads. Co-authored-by: Cursor <cursoragent@cursor.com>
|
LGTM! The addition of 🤖 Reviewed by codereviewbot.ai - Catch bugs before your team does. |
- Exercise addCreateUids/addUpdateUid with non-object input so asObjectRecord fallbacks are covered. - Hit UpdateOperations empty repository.update when attachment clear has no scalar payload. Co-authored-by: Cursor <cursoragent@cursor.com>
Review SummaryThe changes successfully introduce Key Observations:
One minor issue was found in 🤖 Reviewed by codereviewbot.ai - Catch bugs before your team does. |
- When applyOnUpdate sees a non-null DeletedAt, set DeletedUid from the actor (and strip client values without an actor), matching restore clearing and Delete soft-delete SET semantics. Co-authored-by: Cursor <cursoragent@cursor.com>
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
Summary
CreatedUid/UpdatedUid/DeletedUidto TSBaseModel(ManyToOneRef → auth.User) and Gopkg/meta.BaseModel.DeletedAt: null) clearsDeletedUidand refreshesUpdatedUid; strip clientCreatedUidwrites.CreateUidinto BaseModelCreatedUid(bootstrap RR, FEuseSavedFilters, SF11); keep orphan ids on User delete (no CASCADE). No legacycreate_uidrename migration.Test plan
go test ./pkg/meta/ ./internal/module/evolution/schema/ -count=1./choysum test typecheck core web base./choysum test unit core --be(timestamp / audit uid / soft-delete stamp / FieldsGet / field-rule system fields)./choysum test unit base --be --pattern 'soft_delete|audit_uid'./choysum test unit web --be --pattern 'SavedFilter|SF11|AU9|SF13'./choysum test unit web --fe --pattern 'useSavedFilters'Summary by CodeRabbit
New Features
Bug Fixes