Original Question: "After a placeholder is created, when do we go and get the real content for that noun and update it?"
The placeholder resolution system has been fully implemented to automatically fetch and update placeholder nouns with real GitHub data. Here's exactly when and how it happens:
- Frequency: Every 6 hours by default
- Configuration: Set via
PLACEHOLDER_RESOLUTION_SCHEDULEenvironment variable - Process: Automatically scans all nouns, identifies placeholders, and resolves them
- API Endpoint:
POST /api/placeholder-resolution/resolve-all - Trigger: Can be called manually or via automation
- Use Case: When immediate resolution is needed
- API Endpoint:
POST /api/placeholder-resolution/resolve-immediate - Parameters: Array of specific placeholder IDs
- Use Case: When specific placeholders need urgent resolution
File: src/services/PlaceholderResolutionService.ts
Key Methods:
findPlaceholders()- Identifies all placeholder nounsresolvePlaceholder()- Resolves a specific placeholderresolveAllPlaceholders()- Resolves all found placeholdersresolveImmediately()- Resolves specific placeholders immediately
Features:
- Scheduled resolution using node-cron
- Rate limiting to respect GitHub API limits
- Error handling and retry logic
- Comprehensive logging and monitoring
- GitHubService: Fetches real data from GitHub API
- GitHubMappingService: Transforms GitHub data to Brainy format
- BrainyData: Stores and updates noun data
1. Scheduled Trigger (every 6 hours)
↓
2. Find All Placeholders
- Query BrainyData for nouns with placeholder: true
- Filter by metadata flags (is_placeholder, placeholder)
↓
3. Extract GitHub Information
- Parse placeholder IDs (github_user_12345, github_repo_999)
- Extract metadata (github_id, entity_type)
↓
4. Fetch Real Data
- Call GitHubService.fetchUserProfile()
- Call GitHubService.fetchRepositoryDetails()
- Handle rate limits and errors
↓
5. Transform Data
- Use GitHubMappingService to convert to Brainy format
- Create standardized nouns and verbs
↓
6. Update Placeholder
- Store real data in BrainyData
- Overwrites placeholder with real content
- Log successful resolution
GET /api/placeholder-resolution/statsResponse:
{
"success": true,
"data": {
"totalPlaceholders": 15,
"isResolving": false,
"lastResolutionTime": "2025-08-02T16:45:00Z"
},
"timestamp": "2025-08-02T16:45:00Z"
}POST /api/placeholder-resolution/resolve-allResponse:
{
"success": true,
"data": {
"total": 15,
"resolved": 12,
"failed": 3
},
"message": "Resolved 12/15 placeholders",
"timestamp": "2025-08-02T16:45:00Z"
}POST /api/placeholder-resolution/resolve-immediate
Content-Type: application/json
{
"placeholderIds": ["github_user_12345", "github_user_67890"]
}# Placeholder resolution schedule (cron format)
PLACEHOLDER_RESOLUTION_SCHEDULE="0 */6 * * *" # Every 6 hours (default)
# Examples:
# PLACEHOLDER_RESOLUTION_SCHEDULE="0 */2 * * *" # Every 2 hours
# PLACEHOLDER_RESOLUTION_SCHEDULE="0 0 * * *" # Daily at midnight
# PLACEHOLDER_RESOLUTION_SCHEDULE="*/30 * * * *" # Every 30 minutesThe PlaceholderResolutionService is automatically initialized when the application starts:
// In src/index.ts
const placeholderResolutionService = new PlaceholderResolutionService(
brainyData,
logger,
githubService,
mappingService
)
await placeholderResolutionService.initialize()- Scans all nouns for placeholder flags
- Supports multiple placeholder identification methods:
placeholder: truein propertiesis_placeholder: truein metadata- Standardized ID patterns (
github_user_*,github_repo_*)
- Fetches user profiles via GraphQL API
- Retrieves repository details
- Handles rate limiting automatically
- Respects GitHub API best practices
- Graceful handling of API failures
- Retry logic for network errors
- Detailed logging for troubleshooting
- Continues processing even if individual placeholders fail
- Rate limiting to prevent API abuse
- Batch processing with delays
- Concurrent processing with limits
- Memory-efficient placeholder scanning
The service provides comprehensive logging:
- Placeholder discovery and resolution attempts
- API call success/failure rates
- Performance metrics and timing
- Error details and stack traces
- Tracks resolution success rates
- Monitors API rate limit usage
- Provides recommendations for optimization
- Alerts on high failure rates
# Get current statistics
curl -X GET http://localhost:8080/api/placeholder-resolution/stats
# Trigger full resolution
curl -X POST http://localhost:8080/api/placeholder-resolution/resolve-all
# Resolve specific placeholders
curl -X POST http://localhost:8080/api/placeholder-resolution/resolve-immediate \
-H "Content-Type: application/json" \
-d '{"placeholderIds": ["github_user_12345", "github_user_67890"]}'// Get resolution service instance
const resolutionService = placeholderResolutionService
// Find all placeholders
const placeholders = await resolutionService.findPlaceholders()
// Resolve all placeholders
const result = await resolutionService.resolveAllPlaceholders()
// Get statistics
const stats = await resolutionService.getResolutionStats()All existing tests continue to pass (57/57 tests successful), confirming that the implementation:
- Doesn't break existing functionality
- Integrates properly with existing services
- Maintains backward compatibility
- Follows established patterns and conventions
The question "After a placeholder is created, when do we go and get the real content for that noun and update it?" is now fully answered:
- Automatically every 6 hours via scheduled resolution
- On-demand via API endpoints for manual triggering
- Immediately for specific placeholders when needed
- Comprehensively monitored with statistics and health checks
- Fully integrated with existing GitHub data fetching and storage systems
The system ensures that placeholder nouns are systematically resolved with real GitHub data, maintaining data quality and completeness in the Brainy knowledge graph.