OpenGraph Logic and In-Memory Tracking, Error Handling, and DRY implementation
Summary
Major update to the OpenGraph metadata processing and filesystem observer logic in the
tidyverse submodule, including in-memory session-based file tracking, improved error handling, and aggressive, DRY code commenting.Why Care
These changes eliminate redundant OpenGraph API calls, prevent infinite file processing loops, improve debugging and data traceability, and bring documentation and code samples into alignment with actual implementation. This ensures data integrity, system stability, and maintainability.
Implementation
Changes Made
- Modified:
tidyverse/observers/fileSystemObserver.ts- Added a static in-memory
Setto track processed files in the current session. - Updated
onChangemethod to skip files already processed in the session. - Aggressive logging for file events and skip logic.
- Modified:
tidyverse/observers/services/openGraphService.ts- Updated
needsOpenGraphfunction to only trigger fetches for missing or out-of-date OpenGraph fields. - Improved error handling: logs and records errors in frontmatter, updates
og_last_fetchon error. - DRY, aggressive commenting throughout OpenGraph-related logic.
- Documentation:
content/lost-in-public/prompts/data-integrity/Enhanced-Filesystem-Observer-with-Prompts-Support.md- Added/updated sections and code samples to reflect new logic, rationale, and best practices.
Technical Details
- Session-Based File Tracking:
FileSystemObservernow uses a staticSet(processedFiles) to prevent repeated processing of the same file within a single Node.js process.- Ensures each file is only processed once per session.
- OpenGraph Processing:
needsOpenGraphchecks for both presence and correctness of all required OG fields before triggering fetch.- Skips unnecessary API calls and file writes.
- Error Handling:
- All OpenGraph fetch errors are logged and recorded in frontmatter (
og_error). og_last_fetchis updated on error for traceability.
- Documentation:
- Aggressive, DRY code samples and rationale blocks added to project documentation for maintainability.
Integration Points
- No breaking changes to external APIs or interfaces.
- All changes are internal to the observer and OpenGraph service logic.
- Documentation now matches implementation, supporting onboarding and future development.
Documentation
- See:
content/lost-in-public/prompts/data-integrity/Enhanced-Filesystem-Observer-with-Prompts-Support.mdfor updated code samples and rationale. - Related: OpenGraph API integration and environment variable requirements documented in the same file.