Flesh out domain objects and their attributes (SZ-23)
rk@tigase.net opened 3 weeks ago

Summary

Flesh out all core domain model classes (User, Role, Project, Issue, PullRequest, GitRepo) with the full set of attributes expected in a production-grade project management system.

This step ensures each entity has all fields necessary for real-world use — including audit, visibility, and metadata fields — even if some attributes are not yet consumed by the UI or API.


Goals

  1. Bring all model classes to a stable, production-ready state.
  2. Add commonly expected attributes (timestamps, ownership, visibility, etc.).
  3. Prepare a clean base for the next phase: finalizing entity relationships and authorization rules.
  4. Introduce a reusable value object for comments.

Acceptance Criteria

  •  User
    Includes displayName, avatarUrl, isActive, lastLoginAt, locale, timezone.

  •  Project
    Includes visibility (enum: PUBLIC, PRIVATE, INTERNAL), archived, createdBy, updatedBy.

  •  Issue
    Includes tags, dueDate, closedAt, duplicateOf.

  •  PullRequest
    Includes isDraft, reviewStatus, mergeStatus, reviewers.

  •  GitRepo
    Includes createdAt, updatedAt, createdBy, updatedBy, repoType.

  •  All entities
    Include createdAt and updatedAt with lifecycle hooks (@PrePersist, @PreUpdate).

  •  Comment value object
    Created as a lightweight value object (not a JPA entity) with:

    • String text
    • User author
    • Instant createdAt

  •  Javadoc comments added for all new fields.

  •  Enum classes created under com.sztab.model.enums for any new enumerations.


Notes

  • Comment is modeled as a value object, not a JPA entity.
    It can later be embedded inside an entity like IssueComment or PullRequestComment if persistence is needed.
  • This work lays the groundwork for upcoming defects:
    • Finalizing entity relationships
    • Expanding domain queries
    • Adding richer AuthZ rules

Dependencies / Next Steps

  1. Next Defect: Finalize JPA entity relationships.
  2. Then: Add JPA Specifications for advanced domain queries.
  3. Finally: Proceed to AuthZ implementation.

This work is part of a broader effort to make Sztab a professional-grade project management system — not just an internal prototype.
It ensures the domain model is expressive, maintainable, and ready for realistic use cases.

  • rk@tigase.net commented 3 weeks ago

    Work Estimates

    TaskEstimated TimeNotes
    Review current model classes15 minQuick scan of all domain objects to identify missing attributes
    Add new fields to all model classes1–1.25 hoursIncludes new enums, annotations, and getters/setters
    Implement Comment value object10 minLightweight POJO with text, author, createdAt
    Add lifecycle hooks (@PrePersist, @PreUpdate)20 minFor createdAt / updatedAt handling
    Add Javadoc for new fields30–40 minFocused only on new attributes
    Fix compilation + update failing tests1 hourAdjust test data, assertions, etc.
    Git workflow (commit, push, PR)10–15 minClean, reviewable commit history

    Total Estimate: ~3.5 to 4 hours


  • rk@tigase.net changed state to 'In Progress' 3 weeks ago
    Previous Value Current Value
    Open
    In Progress
  • rk@tigase.net commented 3 weeks ago
     % git checkout -b bugfix/sz23-improve-domain-model
     Switched to a new branch 'bugfix/sz23-improve-domain-model'
     % 
    
  • rk@tigase.net commented 3 weeks ago

    Pull Request Domain Model — Concepts and Structure

    This document outlines the core concepts and design of the Pull Request (PR) domain model for the Sztab project, with support for both simple and enterprise-grade workflows.


    What Is a Pull Request?

    A Pull Request (PR) is a proposal to merge changes from a source branch into a target branch. It typically includes:

    • The code diffs
    • Discussion threads (inline comments)
    • Review decisions from peers or approvers

    PullRequest Entity — Key Attributes

    FieldDescription
    idUnique identifier
    titleConcise title of the PR
    descriptionOptional longer explanation
    sourceSource branch (Branch)
    targetTarget branch (Branch)
    authorThe user who opened the PR (User)
    issueThe issue this PR addresses (Issue)
    statusStatus of the PR (e.g., OPEN, MERGED, CLOSED)
    reviewersA set of users invited to review
    mandatoryReviewersSubset of reviewers required for merge approval
    reviewsCollection of Review entries (1 per reviewer)
    createdAt, updatedAtTimestamps
    comments (deprecated)Now modeled inside Review → Comment trees

    Review Model

    Each invited reviewer may submit a Review object, which captures:

    FieldDescription
    reviewerThe user submitting the review
    decisionThe review decision (see below)
    commentsA tree of threaded Comments

    ReviewDecision Enum

    • COMMENTED — Non-blocking comments
    • LGTM — "Looks Good To Me" (may not be sufficient to merge)
    • APPROVED — Explicit approval to merge
    • CHANGES_REQUESTED — Blocking rejection

    Comment Tree Structure

    • Comments inside a Review form a tree
    • A Comment may have:
      • A parent (for replies)
      • A list of children (nested responses)
    • This enables rich conversational flows like:
    Comment 1:
      Rk: This might cause perf issues
        Author: Binary search may be overkill
        John: Spot on Rk, but let's defer post-MVP
          Rk: Agreed — created follow-up issue
    
    Comment 2:
      Mary: Does this scale on mobile?
        Author: UX review in progress
          UX Lead: Reviewing now
    

    Mandatory Reviewers

    • Not all reviewers may be mandatory
    • PR merge logic can enforce:
      • "Any one approval is enough"
      • "All mandatory reviewers must approve"
    • In some workflows, all reviewers are mandatory (e.g., leave mandatoryReviewers = {} but interpret it as "ALL")

    UI may highlight mandatory reviewers (e.g., boldface or badge)


    Typical Merge Scenarios

    ScenarioreviewersmandatoryReviewersMerge Policy
    Solo developer PR[][]Auto-merge or self-merge
    Lightweight teams[rk][]Any reviewer may approve
    Required domain expert[rk, uma][uma]Only uma must approve
    Multi-domain approval (DB + UX)[rk, uma, john][uma, john]All must approve
    All reviewers must approve[rk, uma, john][rk, uma, john]Consensus required

    Interpretation when mandatoryReviewers = {}:

    • May mean "ALL reviewers must approve"
    • Should be configurable per project

    LGTM vs Approval

    • LGTM = Reviewer has scanned and has no objections. Does not imply permission to merge.
    • Approval = Explicit sign-off to allow merge.
    • Both can exist separately in the UI and model:
      • LGTM = "I'm okay with this"
      • APPROVED = "I'm approving this for merge"

    Summary

    This model:

    • Works for MVPs and small teams
    • Scales to complex org workflows
    • Encodes LGTM, Approval, Comment trees, and Merge Policy logic
    • Leaves flexibility for UI and API enforcement
  • rk@tigase.net commented 3 weeks ago

    Work log — SZ-23: Flesh out domain objects and their attributes

    Total time logged: 6 hours
    (actual time spent ≈ 10.5h; capping to 6h due to missteps on 10/26 and cleanup overhead)

    TimeTaskDetails
    1.5hDomain model refactor – core entity fields- Added @Size, @NotBlank, and other validation annotations across all entities (Role, User, GitRepo, Project, Issue, Branch, PullRequest, Review, Comment)
    - Extracted ReviewDecision and other enums to separate files
    - Used @Builder, @PrePersist, @PreUpdate hooks consistently
    - Introduced createdAt and updatedAt to all major domain classes
    1.0hLifecycle and timestamps- Added and tested @PrePersist / @PreUpdate lifecycle hooks
    - Verified timestamp auto-population in unit tests
    1.0hValidation test suite- Added new validation test classes: RoleValidationTest, UserValidationTest, ProjectValidationTest, PullRequestValidationTest, ReviewValidationTest, etc.
    - Added edge cases for @NotBlank, @Size, null, etc.
    - Verified test coverage and constraint triggers
    0.5hDistinct branch validation- Added custom @DistinctBranches annotation and DistinctBranchesValidator to ensure base and compare branches differ in PRs
    - Wrote unit test DistinctBranchesValidatorTest
    1.0hSwagger annotations & cleanup- Ensured @Schema annotations present where needed (e.g., @Schema(format = "date") on LocalDate)
    - Verified Swagger UI loads cleanly
    - Reorganized validation test filenames (PullRequestValidationTest.java, etc.)
    - Applied consistent formatting
    1.0hFinal polish + GitOps- Validated all tests pass (mvn clean verify)
    - Squashed and committed to branch bugfix/sz23-improve-domain-model-new
    - Created PR, then merged into wolnosc via fast-forward
    - Tagged for future traceability

    Notes

    • Although this ended up taking ~10.5h over 2.5 days due to test missteps on 10/26, I’m capping it at 6h in good faith.
    • The extra effort led to long-term cleanup of technical debt and makes all domain models consistent and robust.
  • rk@tigase.net changed state to 'Closed' 3 weeks ago
    Previous Value Current Value
    In Progress
    Closed
  • rk@tigase.net referenced from other issue 3 days ago
issue 1 of 1
Type
Improvement
Priority
Normal
Assignee
Version
1.0
Sprints
n/a
Customer
n/a
Issue Votes (0)
Watchers (3)
Reference
SZ-23
Please wait...
Page is in error, reload to recover