Skip to content

Guard legacy export with structural cosine and norm checks - #16

Merged
initial-d merged 2 commits into
mainfrom
codex/guard-legacy-merge-20261023
Oct 23, 2026
Merged

initial-d merged 2 commits into
mainfrom
codex/guard-legacy-merge-20261023

Conversation

@initial-d

Copy link
Copy Markdown
Owner

The legacy .z exporter previously merged on norm ratio alone: opposite vectors with equal norms could share a row, and trie traversal did not verify structural ancestry. Both export overloads now require whole-key prefix/suffix ancestry plus cosine >= 0.99 and norm ratio >= 0.99. Every original row is checked against its final representative after both passes to reject transitive drift. The first visited key retains its own ID, and row strides/copies follow the model dimension.

Production merge callbacks are extracted into a testable header. Sanitized regressions cover direction, magnitude, structural ancestry, UTF-8 reversal, first-key IDs, 1/2/64/128/256 dimensions and final-representative drift. Linux CI also syntax-checks the complete exporter translation unit. Documentation maps paper-related claims to implementation and outstanding evidence.

Validation: clean Python 3.12.14/PyTorch 2.14.1 on macOS/Apple M5 passed all 36 unit tests; native C library/example build passed. The callbacks pass ASan/UBSan. Full legacy syntax requires a temporary macOS malloc-header compatibility shim locally; unmodified headers are checked on Linux CI. A full linked legacy exporter/reader run is not claimed.

The format is unchanged, but regenerated row counts/vectors can change. This remains approximate compression and does not reproduce paper-scale savings or downstream quality. The final guard adds an O(rows + key bytes) builder map and another traversal. Legacy serving helpers still contain 128-element buffers. Existing Engram byte-exact storage remains independent.

@initial-d
initial-d merged commit a5880a2 into main Oct 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant