Skip to content

F4: enforce paper folder name == bibtex cite_key - #41

Open
frastlin wants to merge 1 commit into
masterfrom
feat/f4-folder-name-cite-key
Open

F4: enforce paper folder name == bibtex cite_key#41
frastlin wants to merge 1 commit into
masterfrom
feat/f4-folder-name-cite-key

Conversation

@frastlin

Copy link
Copy Markdown
Collaborator

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_key is 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 — new DIR_KEY_MISMATCH violation in lint_paper() when a paper directory's name differs from its derived cite_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. --write renames each mismatched dir to its cite_key and 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 resolved cite_key (born compliant); the metadata rule now requires dir == cite_key instead of permitting divergence.
  • scripts/build_keymap.py — docstring records the new invariant; keymap.tsv is now an identity cache.
  • README — documents 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; --write renames + 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 proper cite_keys (build_keymap.py backfill --write) first, then review rename_to_cite_key.py dry-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

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
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.

F4: Enforce paper folder name == BibTeX cite key

1 participant