Skip to content

feat: add project lifecycle status management - #574

Open
ReinaMaze wants to merge 1 commit into
HubDApp:mainfrom
ReinaMaze:feat/project-lifecycle-status
Open

feat: add project lifecycle status management#574
ReinaMaze wants to merge 1 commit into
HubDApp:mainfrom
ReinaMaze:feat/project-lifecycle-status

Conversation

@ReinaMaze

Copy link
Copy Markdown
Contributor

close #155

Add Project Lifecycle Status Management

Feature Description:
Implement comprehensive lifecycle status tracking for projects, allowing owners to signal project maturity, stability, and maintenance status beyond verification status. Projects now have five distinct lifecycle states reflecting their real-world status.

Motivation:
Projects evolve through different phases from active development through sunset. Verification status alone doesn't capture this lifecycle information. Lifecycle status allows:

  • Consumers to understand project stability and activity level
  • Owners to signal maintenance intent
  • Indexers and UIs to filter and display appropriate projects
  • Proper management of deprecated/sunset projects

Implementation:

New Types

  • ProjectLifecycleStatus enum with 5 variants:
    • Active - regularly maintained, recommended for use
    • Beta - under active development, not yet stable
    • Paused - temporarily not maintained
    • Deprecated - no longer recommended for new use
    • Sunset - officially discontinued

Core Changes

  1. Types (src/types.rs):

    • Added ProjectLifecycleStatus enum with Clone, Copy, Debug, Eq, PartialEq
    • Added lifecycle_status: ProjectLifecycleStatus field to Project struct (defaults to Active)
    • Added lifecycle_status: Option<ProjectLifecycleStatus> to ProjectUpdateParams
  2. Storage (src/storage_keys.rs):

    • Added ProjectLifecycleStatus(u64) storage key variant
  3. Events (src/events.rs):

    • New ProjectLifecycleStatusUpdatedEvent struct with:
      • project_id, owner, previous_status, new_status, timestamp
    • New publish_project_lifecycle_status_updated_event() function
    • Emits on status changes with full audit trail
  4. Contract Interface (src/lib.rs):

    • New public method: set_project_lifecycle_status(project_id, caller, status) - owner-only
    • New public method: list_projects_by_lifecycle_status(status, start_id, limit) - filters + pagination
  5. Registry Logic (src/project_registry.rs):

    • Implementation of status update with authorization check
    • Implementation of filtered list with pagination (excludes archived projects)
    • Default lifecycle_status = Active on project registration

API Methods

set_project_lifecycle_status(project_id, caller, status) → Project

  • Owner-only operation
  • Validates project exists
  • Emits event on status change
  • Returns updated project
  • Error: Unauthorized if not owner, ProjectNotFound if ID invalid

list_projects_by_lifecycle_status(status, start_id, limit) → Vec

  • Filters projects by lifecycle status
  • Excludes archived projects
  • ID-based pagination (start_id is cursor, limit defaults to 100)
  • Returns matching projects

Test Coverage (20 test cases)

  • ✅ Project created with Active status
  • ✅ Set status to Beta/Paused/Deprecated/Sunset
  • ✅ Unauthorized users cannot change status
  • ✅ Event emission verification
  • ✅ Multiple sequential transitions
  • ✅ List filtering by Active status
  • ✅ List filtering by Beta status
  • ✅ List pagination
  • ✅ Archived projects excluded from lists
  • ✅ Lifecycle status field in Project struct
  • ✅ Non-owner rejection
  • ✅ Status-unchanged optimization (no event if same)

Backward Compatibility

  • ✅ Existing projects default to Active status
  • ✅ No breaking changes to existing APIs
  • ✅ Lifecycle status is optional in update params
  • ✅ All existing tests continue to pass

Acceptance Criteria Met

  • Project status enum - Five lifecycle states defined
  • Owner can update - set_project_lifecycle_status() restricted to owner
  • List APIs filter by status - list_projects_by_lifecycle_status() with pagination
  • Status changes emit events - ProjectLifecycleStatusUpdatedEvent with audit trail
  • Comprehensive tests - Valid statuses, transitions, filtering, authorization, events

Related Documentation:

Add comprehensive lifecycle status tracking for projects with five states:
- Active: regularly maintained
- Beta: not yet stable for production
- Paused: temporarily not maintained
- Deprecated: no longer recommended
- Sunset: officially discontinued

## Changes

**New Type:**
- ProjectLifecycleStatus enum with 5 variants

**Project struct updates:**
- Add lifecycle_status field (defaults to Active)

**API Methods:**
- set_project_lifecycle_status(project_id, caller, status) - owner-only status changes
- list_projects_by_lifecycle_status(status, start_id, limit) - filter by status with pagination

**Events:**
- ProjectLifecycleStatusUpdatedEvent emitted on status changes
- Captures previous_status and new_status for audit trails

**Storage:**
- ProjectLifecycleStatus storage key added

**Tests (20 test cases):**
- Valid status transitions
- All 5 status values
- Unauthorized update prevention
- Event emission verification
- Multiple sequential transitions
- List filtering by status
- List pagination
- Archived project exclusion
- Non-owner rejection
- Struct field verification

## Acceptance Criteria Met

✅ Project status enum with 5 lifecycle states
✅ Project owner can update status
✅ List APIs can filter by status with pagination
✅ Status changes emit events (with previous/new states)
✅ Comprehensive test coverage including:
   - Valid statuses
   - Status transitions
   - Filtering and pagination
   - Authorization enforcement
   - Event emission
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Project Status Field

1 participant