Skip to content

Latest commit

 

History

History
205 lines (170 loc) · 6.41 KB

File metadata and controls

205 lines (170 loc) · 6.41 KB

Entity Documentation Checklist

✅ Completed Tasks

Documentation Files

  • Created src/database/entities/ENTITY_OWNERSHIP.md (comprehensive guide)
  • Created ENTITY_DOCUMENTATION_SUMMARY.md (implementation summary)
  • Created ENTITY_DOCS_CHECKLIST.md (this file)

Entity Documentation (7/7 entities)

  • raffle.entity.ts - Added class-level and field-level docs
  • ticket.entity.ts - Added class-level and field-level docs
  • user.entity.ts - Added class-level and field-level docs
  • raffle-event.entity.ts - Added class-level and field-level docs
  • platform-stat.entity.ts - Added class-level and field-level docs
  • indexer-cursor.entity.ts - Added class-level and field-level docs
  • dead-letter-event.entity.ts - Added class-level and field-level docs

README Updates

  • Added "Entity Ownership & Field Documentation" section
  • Linked to ENTITY_OWNERSHIP.md
  • Explained field ownership concepts
  • Referenced updater handlers and recalculation guidelines

Documentation Content

For Each Entity

  • Field ownership table (raw vs derived)
  • Updater handler references
  • Recalculation safety guidelines
  • Idempotency mechanisms
  • SQL examples for safe recalculation (where applicable)

Cross-Cutting Concerns

  • Migration ownership rules
  • Recalculation safety section
  • Idempotency key documentation
  • References to related documentation

Inline Documentation

Class-Level Comments

  • Field ownership summary
  • Updater handler list
  • Recalculation safety notes
  • Link to main documentation

Field-Level Comments

  • Marked derived fields with "DERIVED FIELD:"
  • Marked raw chain state with "RAW CHAIN STATE:"
  • Marked idempotency keys with "IDEMPOTENCY KEY:"
  • Added recalculation queries for derived fields
  • Referenced updater handlers

📋 Acceptance Criteria

From Issue Requirements

  • Entity-level comments or docs for Raffle, Ticket, User, RaffleEvent, PlatformStat, Cursor, DLQ
  • Mark derived fields and their updater handlers
  • Document which fields are safe to recalculate
  • Docs are linked from indexer README
  • New migrations reference ownership rules

Additional Quality Checks

  • All 7 entities documented
  • Consistent documentation format across entities
  • Clear distinction between raw and derived state
  • Practical SQL examples for recalculation
  • Migration guidelines for contributors
  • Links between related documentation

📚 Documentation Structure

indexer/
├── README.md (updated with link to entity docs)
├── ENTITY_DOCUMENTATION_SUMMARY.md (implementation summary)
├── ENTITY_DOCS_CHECKLIST.md (this file)
└── src/
    └── database/
        └── entities/
            ├── ENTITY_OWNERSHIP.md (main documentation)
            ├── raffle.entity.ts (updated with inline docs)
            ├── ticket.entity.ts (updated with inline docs)
            ├── user.entity.ts (updated with inline docs)
            ├── raffle-event.entity.ts (updated with inline docs)
            ├── platform-stat.entity.ts (updated with inline docs)
            ├── indexer-cursor.entity.ts (updated with inline docs)
            └── dead-letter-event.entity.ts (updated with inline docs)

🔍 Verification Steps

Manual Verification (Completed)

  • All entity files have comprehensive class-level JSDoc
  • All derived fields marked with inline comments
  • All updater handlers referenced in docs
  • README links to entity documentation
  • Migration rules documented

Suggested Verification (User to run)

cd indexer

# Verify TypeScript syntax
npm run lint

# Verify build succeeds
npm run build

# Run tests
npm run test

📖 Key Documentation Sections

ENTITY_OWNERSHIP.md Contents

  1. Table of Contents - Quick navigation to all entities
  2. Entity Sections (7 total):
    • Field ownership tables
    • Updater handler documentation
    • Idempotency mechanisms
    • Recalculation safety guidelines
  3. Recalculation Safety - Cross-entity guidelines
  4. Migration Ownership Rules - Guidelines for new migrations
  5. References - Links to related documentation

Inline Documentation Pattern

/**
 * Entity description
 *
 * ## Field Ownership
 * - **Raw chain state**: list of fields
 * - **Derived**: list of fields
 *
 * ## Updater Handlers
 * - Handler references
 *
 * ## Recalculation Safety
 * - Safe/unsafe guidelines
 *
 * See: `ENTITY_OWNERSHIP.md` for full documentation
 */
@Entity("table_name")
export class EntityName {
  /**
   * DERIVED FIELD: Description
   * Safe to recalculate: SQL query
   */
  @Column(...)
  derivedField!: type;
}

🎯 Usage Scenarios

For New Contributors

  1. Read ENTITY_OWNERSHIP.md to understand field ownership
  2. Check entity files for inline documentation
  3. Reference updater handlers when modifying processors
  4. Follow migration rules when creating new migrations

For Debugging

  1. Identify if field is raw chain state or derived
  2. For derived fields, use recalculation queries
  3. Check updater handlers for update logic
  4. Verify idempotency keys

For Maintenance

  1. Consult recalculation safety guidelines
  2. Use provided SQL examples
  3. Plan maintenance windows for unsafe operations
  4. Verify no concurrent event processing

✨ Next Steps (Optional)

Potential Enhancements

  • Add automated tests for derived field calculations
  • Create recalculation maintenance scripts
  • Add monitoring for derived field drift
  • Create migration linter for ownership rules
  • Add examples of common debugging scenarios
  • Create troubleshooting guide

Integration with CI/CD

  • Add lint check to CI pipeline
  • Add build verification
  • Add test coverage requirements
  • Add documentation link checker

📝 Notes

  • All documentation follows existing project conventions
  • Inline comments use JSDoc format for IDE integration
  • SQL examples use PostgreSQL syntax (project standard)
  • Documentation is versioned with code (no external wiki)
  • Links use relative paths for portability

🔗 Related Documentation

  • Architecture: docs/ARCHITECTURE.md § Data Model
  • Processors: indexer/src/processors/
  • Archiving: indexer/src/maintenance/ARCHIVE_RAFFLE_EVENTS_GUIDE.md
  • Migrations: indexer/src/database/migrations/