F4: enforce paper folder name == bibtex cite_key - #41
Open
frastlin wants to merge 1 commit into
Open
Conversation
Overturns the B5 dir/cite_key decoupling (signed off 2026-06-30): a paper's directory name must now equal its cite_key. - lint_paper_schema.py: new DIR_KEY_MISMATCH violation (exit 2) when a paper dir name != its derived cite_key. - rename_to_cite_key.py: dry-run-by-default migration that renames mismatched dirs to their cite_key and rewrites every reference (index.md, _reader_done.tsv, keymap.tsv, ../<dir>/notes.md links and [[dir]] wikilinks in sibling files). - paper-reader/SKILL.md: name new paper dirs from the cite_key so they are born compliant; metadata rule now requires dir == cite_key. - build_keymap.py: docstring records the new invariant; keymap.tsv is now an identity cache. - README: document rename_to_cite_key.py. Tests: DirKeyMismatchTests (mismatch reported, match passes, year-differs-but- key-matches, main() exits 2) + test_rename_to_cite_key.py (plan, dry-run touches nothing, write renames + rewrites refs with no dangling links, idempotent). Closes #34 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012MKtQ1Dfg5qYWhobNKk7jP
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.
Resolves #34.
What & why
Overturns the B5 decision that intentionally decoupled a paper's directory name from its bibtex
cite_key(the dir encoded a preprint/first-seen year, the key the published year). Per the 2026-06-30 sign-off,dir == cite_keyis now a required corpus invariant. Folders had drifted from their keys; this makes the divergence both detectable (a hard lint) and fixable (a migration), and makes new papers born compliant.Changes
scripts/lint_paper_schema.py— newDIR_KEY_MISMATCHviolation inlint_paper()when a paper directory's name differs from its derivedcite_key. Ships inside the existing exit-2 gate, so it is enforced wherever that gate runs.scripts/rename_to_cite_key.py(new) — dry-run-by-default migration.--writerenames each mismatched dir to itscite_keyand rewrites every reference:papers/index.md,papers/_reader_done.tsv,papers/keymap.tsv, and relative cross-links (../<dir>/notes.md) + wikilinks ([[<dir>]]) in sibling notes/citations. Guards against target collisions; idempotent.skills/paper-reader/SKILL.md— name new paper dirs from the resolvedcite_key(born compliant); the metadata rule now requiresdir == cite_keyinstead of permitting divergence.scripts/build_keymap.py— docstring records the new invariant;keymap.tsvis now an identity cache.rename_to_cite_key.py.Tests (TDD)
DirKeyMismatchTests: mismatch reported; match passes; year-differs-but-key-matches stays clean;main()exits 2 on a mismatched corpus.test_rename_to_cite_key.py: plan lists only mismatches; dry-run touches nothing;--writerenames + rewrites all refs with no dangling links; idempotent on a compliant corpus.Full suite green:
173 passed, 41 subtests.Operator note
This PR ships the rule + tool, not a live rename of the user's
papers/collection. Running the migration on real data is interactive: author propercite_keys (build_keymap.py backfill --write) first, then reviewrename_to_cite_key.pydry-run output before--write, since the fallback key generator would otherwise truncate dir names.Dependencies
First in the build order F4 → F3 → F2 → F7 → F5 → F1 → F6. F1/F2/F3/F6 build on this invariant.
🤖 Generated with Claude Code