Cross References - johnpeterman72/CursorRIPER.sigma GitHub Wiki

๐Ÿ”— Cross-Reference System

The Cross-Reference System creates intelligent links between different parts of your project, maintaining traceability and relationships across requirements, code, documentation, and issues.

๐ŸŽฏ What are Cross-References?

Cross-references are smart links that connect related elements:

  • Requirements to implementation
  • Issues to fixes
  • Documentation to code
  • Patterns to usage

Without cross-references:

  • ๐Ÿšซ Lost traceability
  • ๐Ÿšซ Orphaned documentation
  • ๐Ÿšซ Unclear relationships
  • ๐Ÿšซ Difficult navigation

๐Ÿ“ Cross-Reference Notation

Basic Syntax

[โ†—๏ธฯƒโ‚™:Xแตข]

Components:

  • โ†—๏ธ = Cross-reference indicator
  • ฯƒโ‚™ = Memory file (ฯƒโ‚-ฯƒโ‚†)
  • Xแตข = Item index (Rโ‚, Fโ‚‚, etc.)

Examples

[โ†—๏ธฯƒโ‚:Rโ‚ƒ]    // Requirement 3 in projectbrief.md
[โ†—๏ธฯƒโ‚‚:Pโ‚]    // Pattern 1 in systemPatterns.md
[โ†—๏ธฯƒโ‚…:Iโ‚‡]    // Issue 7 in progress.md

๐ŸŽจ Cross-Reference Types

1. Simple References

Link to a specific item:

This feature implements [โ†—๏ธฯƒโ‚:Rโ‚ƒ] which requires user authentication.

2. Context-Enhanced References

Include context information:

[โ†—๏ธฯƒโ‚:Rโ‚ƒ|ฮ“โ‚ƒ:validateUser()]

Links requirement Rโ‚ƒ specifically to the validateUser() function.

3. Multi-References

Reference multiple related items:

This addresses [โ†—๏ธฯƒโ‚…:Iโ‚‚], [โ†—๏ธฯƒโ‚…:Iโ‚…], and [โ†—๏ธฯƒโ‚…:Iโ‚‡].

4. Protection References

Combine with protection markers:

[โ†—๏ธฯƒโ‚†:Pโ‚ƒ|ฮจโ‚] - Protected region 3, PROTECTED level

5. Contextual References

Direct context without memory file:

[ฮ“โ‚ƒ:AuthService] - Reference to AuthService code
[ฮ“โ‚:config.json] - Reference to config file

๐Ÿ“‹ Index Naming Convention

Standard Prefixes

Prefix Meaning Example
R Requirement Rโ‚, Rโ‚‚, Rโ‚ƒ
F Feature Fโ‚, Fโ‚‚, Fโ‚ƒ
P Pattern/Protected Pโ‚, Pโ‚‚, Pโ‚ƒ
I Issue Iโ‚, Iโ‚‚, Iโ‚ƒ
M Milestone Mโ‚, Mโ‚‚, Mโ‚ƒ
D Decision Dโ‚, Dโ‚‚, Dโ‚ƒ
T Task Tโ‚, Tโ‚‚, Tโ‚ƒ
C Criteria Cโ‚, Cโ‚‚, Cโ‚ƒ

Memory File Mapping

ฯƒโ‚ (projectbrief.md): R, C, constraints
ฯƒโ‚‚ (systemPatterns.md): P, D, components  
ฯƒโ‚ƒ (techContext.md): stack, env, deps
ฯƒโ‚„ (activeContext.md): current, next, context
ฯƒโ‚… (progress.md): F, I, M, metrics
ฯƒโ‚† (protection.md): P, history, violations

๐Ÿ”„ Cross-Reference Patterns

Requirement Traceability

## Feature: User Authentication

Implements [โ†—๏ธฯƒโ‚:Rโ‚ƒ] (User must authenticate before accessing protected resources)

### Implementation Details
- Login endpoint: [โ†—๏ธฯƒโ‚:Rโ‚ƒ|ฮ“โ‚ƒ:loginUser()]
- Session management: [โ†—๏ธฯƒโ‚:Rโ‚ƒ|ฮ“โ‚ƒ:SessionManager]
- Security: [โ†—๏ธฯƒโ‚‚:Pโ‚…] (JWT pattern)

Issue Resolution

## Bug Fix: Login Timeout

Fixes [โ†—๏ธฯƒโ‚…:Iโ‚โ‚‚] (Users randomly logged out)

### Root Cause
Session timeout was hardcoded [โ†—๏ธฯƒโ‚ƒ:config] instead of using environment variable.

### Solution
Implemented configurable timeout following [โ†—๏ธฯƒโ‚‚:Dโ‚ƒ] (configuration pattern).

Pattern Implementation

## Repository Pattern Implementation

Following [โ†—๏ธฯƒโ‚‚:Pโ‚‚] (Repository Pattern):

```javascript
// Implementation of [โ†—๏ธฯƒโ‚‚:Pโ‚‚]
class UserRepository {
    // Methods as specified in [โ†—๏ธฯƒโ‚‚:Pโ‚‚|components]
}

### Decision Documentation
```markdown
## Architecture Decision

Per [โ†—๏ธฯƒโ‚‚:Dโ‚] (Microservices over Monolith):

### Rationale
- Scalability requirements [โ†—๏ธฯƒโ‚:Rโ‚ˆ]
- Team structure [โ†—๏ธฯƒโ‚:constraints]
- Performance goals [โ†—๏ธฯƒโ‚:Cโ‚‚]

๐ŸŽฏ Advanced Cross-References

Bidirectional References

Create two-way links:

// In implementation file
// Implements [โ†—๏ธฯƒโ‚:Rโ‚ƒ]

// In requirements file  
[Rโ‚ƒ] User authentication - Implemented in [โ†—๏ธฯƒโ‚„:auth.service.js]

Chain References

Link through multiple documents:

[โ†—๏ธฯƒโ‚:Rโ‚ƒ] โ†’ [โ†—๏ธฯƒโ‚‚:Pโ‚…] โ†’ [โ†—๏ธฯƒโ‚…:Fโ‚‡]
(Requirement โ†’ Pattern โ†’ Feature)

Conditional References

Context-dependent links:

If using SQL: See [โ†—๏ธฯƒโ‚‚:Pโ‚ƒ|SQL]
If using NoSQL: See [โ†—๏ธฯƒโ‚‚:Pโ‚ƒ|NoSQL]

Version References

Track changes over time:

Original: [โ†—๏ธฯƒโ‚‚:Dโ‚|v1.0]
Updated: [โ†—๏ธฯƒโ‚‚:Dโ‚|v2.0] per [โ†—๏ธฯƒโ‚…:Iโ‚‚โ‚ƒ]

๐Ÿ’ก Cross-Reference Best Practices

1. Reference at Creation

Add cross-references when creating items:

## [Rโ‚โ‚€] New Requirement
Related to [โ†—๏ธฯƒโ‚:Rโ‚ƒ] and [โ†—๏ธฯƒโ‚:Rโ‚‡]
Addresses [โ†—๏ธฯƒโ‚…:Iโ‚โ‚…]

2. Maintain Bidirectionality

Always create reverse references:

// In source
Implements [โ†—๏ธฯƒโ‚:Rโ‚…]

// In target
[Rโ‚…] Implemented by [โ†—๏ธฯƒโ‚„:feature.js]

3. Use Descriptive Context

Add context to clarify references:

// Less clear
See [โ†—๏ธฯƒโ‚‚:Pโ‚ƒ]

// More clear
Following [โ†—๏ธฯƒโ‚‚:Pโ‚ƒ] (Repository Pattern) for data access

4. Group Related References

Organize multiple references:

### Related Items
- Requirements: [โ†—๏ธฯƒโ‚:Rโ‚ƒ], [โ†—๏ธฯƒโ‚:Rโ‚…], [โ†—๏ธฯƒโ‚:Rโ‚ˆ]
- Patterns: [โ†—๏ธฯƒโ‚‚:Pโ‚], [โ†—๏ธฯƒโ‚‚:Pโ‚„]
- Issues: [โ†—๏ธฯƒโ‚…:Iโ‚‚], [โ†—๏ธฯƒโ‚…:Iโ‚‡]

5. Verify References

Regularly check reference validity:

## Reference Audit
- [โ†—๏ธฯƒโ‚:Rโ‚ƒ] โœ“ Valid
- [โ†—๏ธฯƒโ‚:Rโ‚„] โš ๏ธ Deprecated, see [โ†—๏ธฯƒโ‚:Rโ‚โ‚‚]
- [โ†—๏ธฯƒโ‚‚:Pโ‚‡] โŒ Not found

๐Ÿ” Cross-Reference Usage

In Code Comments

/**
 * User Authentication Service
 * Implements [โ†—๏ธฯƒโ‚:Rโ‚ƒ] (User Authentication)
 * Follows [โ†—๏ธฯƒโ‚‚:Pโ‚…] (JWT Pattern)
 * Addresses [โ†—๏ธฯƒโ‚…:Iโ‚โ‚‚] (Session timeout issue)
 */
class AuthService {
    // Implementation per [โ†—๏ธฯƒโ‚:Rโ‚ƒ|specifications]
}

In Documentation

# API Documentation

## POST /api/auth/login
Implements [โ†—๏ธฯƒโ‚:Rโ‚ƒ] with security measures from [โ†—๏ธฯƒโ‚‚:Dโ‚ˆ].

### Request
Per [โ†—๏ธฯƒโ‚:Rโ‚ƒ|interface], accepts:
- email: string
- password: string

In Test Files

describe('Authentication Tests [โ†—๏ธฯƒโ‚:Rโ‚ƒ]', () => {
    it('should validate credentials per [โ†—๏ธฯƒโ‚:Rโ‚ƒ|validation]', () => {
        // Test implementation
    });
    
    it('should handle edge case [โ†—๏ธฯƒโ‚…:Iโ‚โ‚…]', () => {
        // Regression test for issue
    });
});

In Commit Messages

git commit -m "feat: implement user auth [โ†—๏ธฯƒโ‚:Rโ‚ƒ]

- Add JWT authentication per [โ†—๏ธฯƒโ‚‚:Pโ‚…]
- Fix session timeout [โ†—๏ธฯƒโ‚…:Iโ‚โ‚‚]
- Update tests for [โ†—๏ธฯƒโ‚:Cโ‚ƒ]"

๐Ÿ“Š Cross-Reference Management

Reference Tracking

Maintain reference index:

## Cross-Reference Index

### Requirements โ†’ Implementation
- [Rโ‚] โ†’ auth.service.js, login.component.ts
- [Rโ‚‚] โ†’ user.model.js, validation.js
- [Rโ‚ƒ] โ†’ jwt.utils.js, middleware/auth.js

### Issues โ†’ Fixes  
- [Iโ‚] โ†’ commit:abc123, PR#42
- [Iโ‚‚] โ†’ commit:def456, PR#45

Reference Validation

Check reference integrity:

// Reference validator
function validateReferences() {
    const references = findAllReferences();
    references.forEach(ref => {
        if (!targetExists(ref)) {
            console.warn(`Broken reference: ${ref}`);
        }
    });
}

Reference Refactoring

Update references when restructuring:

## Reference Migration

### Old Structure
[โ†—๏ธฯƒโ‚‚:Pโ‚ƒ] โ†’ Repository Pattern

### New Structure  
[โ†—๏ธฯƒโ‚‚:Pโ‚ƒ] โ†’ DEPRECATED, see [โ†—๏ธฯƒโ‚‚:Pโ‚โ‚‚]
[โ†—๏ธฯƒโ‚‚:Pโ‚โ‚‚] โ†’ Updated Repository Pattern (v2)

๐Ÿšจ Common Cross-Reference Issues

Broken References

Problem: Target doesn't exist Solution: Regular validation, update or remove

Circular References

Problem: Aโ†’Bโ†’Cโ†’A loops Solution: Identify hierarchy, break cycles

Ambiguous References

Problem: Unclear what reference points to Solution: Add context information

Outdated References

Problem: Points to old version Solution: Version tracking, migration notes

๐ŸŽ“ Cross-Reference Examples

Example 1: Feature Development

## Feature: Payment Processing

### Requirements
Implements [โ†—๏ธฯƒโ‚:Rโ‚โ‚…] (Process payments)
Related to [โ†—๏ธฯƒโ‚:Rโ‚โ‚†] (Payment history)

### Design
Following patterns:
- [โ†—๏ธฯƒโ‚‚:Pโ‚ˆ] (Strategy pattern for payment methods)
- [โ†—๏ธฯƒโ‚‚:Pโ‚‰] (Observer pattern for notifications)

### Implementation
- Service: [ฮ“โ‚ƒ:PaymentService]
- Controller: [ฮ“โ‚ƒ:PaymentController]
- Tests: [ฮ“โ‚:tests/payment.test.js]

### Issues Addressed
- [โ†—๏ธฯƒโ‚…:Iโ‚‚โ‚ƒ] (Timeout on large payments)
- [โ†—๏ธฯƒโ‚…:Iโ‚‚โ‚…] (Currency conversion errors)

Example 2: Bug Report

## [Iโ‚„โ‚…] Login fails with special characters

### Description
Users with @ in password cannot login

### Related
- Requirement: [โ†—๏ธฯƒโ‚:Rโ‚ƒ|validation]
- Pattern deviation: [โ†—๏ธฯƒโ‚‚:Pโ‚…|security]
- Similar issues: [โ†—๏ธฯƒโ‚…:Iโ‚โ‚‚], [โ†—๏ธฯƒโ‚…:Iโ‚‚โ‚ƒ]

### Fix
See PR#123 implementing [โ†—๏ธฯƒโ‚‚:Dโ‚โ‚…] (input sanitization)

Example 3: Architecture Decision

## [Dโ‚‚โ‚€] Switch to Event-Driven Architecture

### Rationale
- Performance requirement [โ†—๏ธฯƒโ‚:Cโ‚‚] not met
- Scalability needs [โ†—๏ธฯƒโ‚:Rโ‚‚โ‚‚] increasing
- Current architecture [โ†—๏ธฯƒโ‚‚:Dโ‚] limitations

### Impact
- Deprecates [โ†—๏ธฯƒโ‚‚:Pโ‚-Pโ‚…]
- Introduces [โ†—๏ธฯƒโ‚‚:Pโ‚‚โ‚€-Pโ‚‚โ‚…]
- Addresses [โ†—๏ธฯƒโ‚…:Iโ‚ƒโ‚€], [โ†—๏ธฯƒโ‚…:Iโ‚ƒโ‚], [โ†—๏ธฯƒโ‚…:Iโ‚ƒโ‚…]

๐Ÿ“š Related Topics


โ† Permission System | Home | Backup System โ†’