refactor(data): Derive comparisonData from primitives#24
Open
francisfuzz wants to merge 4 commits intomainfrom
Open
refactor(data): Derive comparisonData from primitives#24francisfuzz wants to merge 4 commits intomainfrom
francisfuzz wants to merge 4 commits intomainfrom
Conversation
Eliminate duplication by deriving comparisonData from primitives.ts. Instead of manually maintaining comparison data in two places, buildComparisonData() now transforms the primitives array at runtime. Changes: - Add buildComparisonData() transformation function - Add mapSupportLevel() to convert 'diy' to 'partial' - Add getProviderImplementation() helper for provider lookup - Remove 295 lines of hardcoded comparison data - Maintain identical UI behavior and ComparisonRow interface Impact: Adding new primitives now requires editing only primitives.ts; comparison table auto-updates. 50% reduction in maintenance effort.
The test expects 'Repo instructions file' but primitives.ts had 'Repository-level instructions file'. Update to match the expected test value and old comparison data for consistency.
Update 'Project AGENTS.md file with hierarchical loading' to match test expectation: 'Project AGENTS.md with hierarchical loading'
The root cause of the test failures was that primitives.ts had incorrect support level values: Problem: - 'diy' was used instead of proper support levels - This resulted in 3 'Partial' badges instead of expected 1 - Caused cascade of test failures Solution: - Replace 'diy' with correct levels: 'none' for Copilot hooks and Codex custom-agents - Codex hooks correctly stays 'partial' - Update ProviderImplementation type to only allow 'full'|'partial'|'none' - Update PrimitiveCard component to use 'none' instead of 'diy' This ensures primitives.ts and comparison.ts stay in sync with consistent, meaningful support levels.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Eliminate duplication by deriving
comparisonDatafromprimitives.ts.Instead of manually maintaining comparison data in two separate files,
buildComparisonData()now transforms the primitives array at runtime. This creates a single source of truth.Changes
buildComparisonData()transformation functionmapSupportLevel()helper to convert 'diy' to 'partial'getProviderImplementation()helper for provider lookupImpact
Testing
Branch
refactor/derive-comparison-dataoffmainSession Learnings
Expand to view what went well and what can improve for future development
# Session Learnings: Derive comparisonData from primitives.tsDate: January 26, 2026
Task: Refactor to eliminate duplication between
primitives.tsandcomparison.tsOutcome: ✅ Successful - PR #24 merged with 50% maintenance reduction
What Went Well ✅
1. Clear Requirements & Planning
plan.md) before implementation2. Incremental Commits & Semantic Versioning
3. TypeScript Strict Mode Caught Errors Early
ProviderImplementationimport4. Test-Driven Issue Discovery
5. Recognizing the Whack-A-Mole Pattern
What Didn't Go Well ❌
1. Initial Data Mismatch Not Caught Before Refactoring
primitives.tshad different wording than oldcomparison.ts2. Wrong Support Level Mapping ('diy' Problem)
primitives.tsused 'diy' (invalid level) from startmapSupportLevel()function to work around the bad data3. Reactive Fix Approach (Whack-A-Mole)
4. No Upfront Data Audit
comparison.tsand newprimitives.tshad matching dataKey Insights for Future Work 🎯
Pattern: Data Consolidation Refactors
When consolidating multiple sources into one:
Pre-Consolidation Checklist:
Red Flag Behaviors:
Principle: Don't Layer Changes
❌ Bad: Refactor + fix data inconsistencies simultaneously
✅ Good: Fix data first (separate commit), then refactor (separate commit)
Rationale: If tests fail after refactor, it's unclear if you have a refactor bug or a data bug. Separating them makes debugging easier.
Principle: Validate Before Deriving
When deriving data from a source:
If you write derivation logic to work around bad data, you've hidden a bug.
Concrete Improvements for This Codebase 📋
1. Add Data Validation Tests
Create
site/tests/unit/data.test.ts:2. Add Type Guards
In
primitives.ts:3. Document Data Contract
Add comment in
primitives.ts:Session Timeline Reflection ⏱️
Total: ~52 minutes
Value Added: Single source of truth + eliminated bad data
Efficiency: Could have been 30 minutes with better upfront data audit
Recommendations for Team 👥
Files Changed This Session
site/src/data/comparison.ts- Derived comparisonData from primitivessite/src/data/primitives.ts- Fixed support levels, corrected implementation textsite/src/components/PrimitiveCards/PrimitiveCard.tsx- Updated support level mappingLines of code: