agree devlog - 02/05
Starting comparison
Finally getting into the comparison logic. The three mismatch types are: missing, extra, and incorrect.
The approach: hash the source schema and all other schemas into maps, then for each other schema:
- Check against the source map to find
extraormissingattrs - For attrs that exist in both, check if the types match. That's
incorrect.
Results get appended to map[MismatchReason][]Mismatch. At the end, the CLI can filter which mismatches to surface based on the agree_type the user specified.
Optimizing as I go, using make() with a known capacity where possible since that's slightly cheaper than letting Go grow the slice dynamically:
mismatches := make([]Mismatch, 0, len(sourceAttrs))
The consolidation step is probably O(n²), fine for typical repo sizes but worth keeping in mind.
Once all mismatches are collected they get filtered by agree_type. The only one with meaningfully different behavior right now is some, you can be missing fields but the ones that are present need to match, so only incorrect mismatches are kept.
Source-side hashing
Originally the plan was just map[attrName]types. But then I realized I needed a set on the source side anyway to do type comparison efficiently, so it became map[attrName]Set[string]. Keeps the type checking simple, just check if the other schema's types are a subset.