Repository navigation
docs: add citation metadata - #180
Conversation
Add CITATION.cff (CFF 1.2.0) for the GitHub citation entry and Zenodo, with the authors who committed at least 100 lines to dev (there is no release yet), ordered by lines, then commits, and describe in the contributing docs how contributors add or correct their entry. Closes #174 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Validate CITATION.cff with cffconvert in CI. Add scripts/citation.py to set version and date-released before a release (Zenodo archives the file of the tagged commit) and to check them in the release workflow, which fails if the file has another version; document the step under "Versioning and releases". Co-Authored-By: Claude Opus 5.5 <[email protected]>
Address review findings: set and check fail on duplicate (also quoted) or unparsable version/date-released lines instead of appending a second key; dates must be YYYY-MM-DD; a comment needs whitespace before #. Document the check before tagging and that each pre-release needs its own citation change; point the CFF message to the docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Round-2 review: set and check fail when version or date-released is empty or continued on an indented next line (a YAML plain scalar), instead of rewriting only the first line or misreading the value. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideAdds and documents CFF citation metadata, including contributor attribution, then provides a tested standard-library utility to set and verify release version/date fields. CI validates the CFF schema, while the release workflow prevents publishing tags whose citation metadata is missing, mismatched, malformed, or future-dated. Sequence diagram for citation metadata release validationsequenceDiagram
participant Maintainer
participant Dev
participant CI
participant ReleaseWorkflow
participant CitationScript
participant Zenodo
Maintainer->>CitationScript: set X.Y.Z
CitationScript-->>Maintainer: Update version and date-released
Maintainer->>Dev: Merge updated CITATION.cff
Dev->>CI: Run cffconvert --validate
CI-->>Dev: Validate CITATION.cff schema
Maintainer->>ReleaseWorkflow: Push signed tag vX.Y.Z
ReleaseWorkflow->>CitationScript: check X.Y.Z
CitationScript-->>ReleaseWorkflow: Verify version and UTC date
ReleaseWorkflow->>Zenodo: Publish release metadata
Flow diagram for citation metadata validationflowchart TD
A[CITATION.cff] --> B[pipx run --spec cffconvert==2.0.0 cffconvert --validate]
A --> C[python scripts/citation.py check X.Y.Z]
C --> D{Version matches and date is valid?}
D -->|Yes| E[Release workflow continues]
D -->|No| F[Release fails]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #180 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 11 12 +1
Lines 737 813 +76
=========================================
+ Hits 737 813 +76 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="scripts/citation.py" line_range="72" />
<code_context>
+ The pattern.
+ """
+ escaped = re.escape(name)
+ return re.compile(rf"^(?:{escaped}|\"{escaped}\"|'{escaped}')[ \t]*:", re.MULTILINE)
+
+
</code_context>
<issue_to_address>
**Duplicate release keys are appended**
When an existing top-level `version` or `date-released` key has whitespace before its colon, `_any_key` and `_key` fail to recognize the existing key, so `set_release` appends another key instead of updating it, leaving duplicate release metadata.
Allow whitespace before the colon when matching top-level release keys.
</issue_to_address>
### Comment 2
<location path="scripts/citation.py" line_range="156" />
<code_context>
+ line = f'{name}: "{value}"'
+ if _value(text, name) is None:
+ body = text.rstrip("\n")
+ text = f"{body}\n{line}\n"
+ else:
+ text = _key(name).sub(line, text)
</code_context>
<issue_to_address>
**Release keys follow document terminator**
When a valid citation file ends with an explicit YAML document terminator (`...`) and lacks a release key, `set_release` appends missing keys after `...`, outside the YAML document, so `set` exits successfully but leaves invalid citation metadata.
Insert missing keys before an explicit document terminator.
</issue_to_address>
### Comment 3
<location path="tests/test_citation.py" line_range="154-156" />
<code_context>
+ assert citation.main(["set", "1.0.0"], path) == 0
+ after = datetime.datetime.now(datetime.UTC).date()
+ text = path.read_text(encoding="utf-8")
+ assert any(
+ f'\ndate-released: "{date.isoformat()}"\n' in text for date in (before, after)
+ )
+
+
</code_context>
<issue_to_address>
**Local-date bug goes undetected**
When the test runs where the local calendar date matches UTC, the UTC `before`/`after` bounds in `test_main_default_date` (lines 150–155) equal the local date in a UTC-configured environment, so an implementation using the local clock instead of UTC still satisfies the assertion and the regression passes unnoticed.
Control the timezone or mock the clock so the test asserts the UTC date differs from the local date.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 3 findings to address first, and GitHub can use the new file to generate citations, and Zenodo can archive its author and release metadata; incorrect attribution could therefore be copied into citations or persist in a release archive after a revert. The scope is bounded, and the metadata can be corrected, but reverting alone would not undo those copies.
Blocking findings: scripts/citation.py:72, scripts/citation.py:156, tests/test_citation.py:156
Sourcery review: set writes a temporary file and replaces CITATION.cff only once it is complete, so a failed write never leaves it truncated. The default-date test now pins the clock at a time whose UTC date differs from the local one, so a local-clock regression fails. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Closes #174
CITATION.cff(CFF 1.2.0): title, abstract,type: software,license: Apache-2.0,repository-code,url(docs), keywords, and the authors below. Themessageexplains the order and the convention for equal contributors (an asterisk; there are no ties now). There is no release yet, soversionanddate-releasedare left out:scripts/citation.py setadds them when the first release is prepared. No DOI yet (docs: add the Zenodo DOI and badge #177).scripts/citation.py(stdlib only, likerelease_version.py):set X.Y.Z [--date YYYY-MM-DD]sets, or adds,versionanddate-releasedbefore a release;check X.Y.Zruns in the release workflow (preparejob, after the tag checks). The release fails if the file has another version, or a missing, invalid or future date (UTC). Zenodo archives each release with theCITATION.cffof the tagged commit, so the file must be updated in a PR todevbefore tagging. "Versioning and releases" indocs/development.mddocuments this step.Static code analysis) validates the file:pipx run --spec cffconvert==2.0.0 cffconvert --validate. It runs in its own environment because cffconvert 2.0.0 pins jsonschema 3.2. The cffconvert pre-commit hook only exists on its unreleased main branch, so I didn't use it.tests/test_citation.py: tests the script (scripts/coverage stays at 100%), and checks that the file has no e-mail addresses.docs/contributing.md: new section "Citation metadata", on how contributors add or correct their entry.Authors
There are no releases yet, so lines are counted on
dev(the maintainer's clarification). Lines added per GitHub account, fromgit log --numstat. Not counted:cloud_registry/api/20201108.*;LICENSE,CODE_OF_CONDUCT.md, lock files;The only revision in
.git-blame-ignore-revs(971abded, "Format code using black") isn't ondev. It was a commit of PR #37, which was squash-merged asdc32e2a("ci: check format with black"). I treated the reformatted Python files ofdc32e2aas that reformat and didn't count them (235 lines). Its other 15 lines (CI step, config,.git-blame-ignore-revs) count.Names and ORCID iDs come from the maintainer's contributor list. Affiliations come only from public ORCID records (see below).
dc32e2awere excluded entirely (then not included), 348 if counted in full.Light lane?
No. This changes the release workflow and CI, so the full process applies: adversarial and quality reviewer subagents, and the Sourcery review.
Verification
.[dev]):coverage run -m pytest(800 passed, 145 skipped),coverage report100% (incl.scripts/citation.py),mypy(incl.scripts), ruff 0.17.1check/format --check,ast-grep scan,semgrep --config=.semgrep: clean.cffconvert --validate(2.0.0): valid.mkdocs build --strict: no warnings.editorconfig-checkeron the changed files: clean.Review
Round 1 (adversarial + quality reviewers) found no high findings. Fixed:
setsilently appended a second key when an existingversion/date-releasedline had another format (block scalar, mismatched quotes, quoted key,#in values). It now fails with an error.checkaccepted ISO 8601 dates that CFF rejects (e.g.20261023). Dates must now beYYYY-MM-DD, also for--date.#, as in YAML.python scripts/citation.py check X.Y.Zbefore tagging, ask forsetshortly before the release, and say that each pre-release needs its own citation change.messageand the docs gave different branches. Themessageis now shorter and points to the docs section, which states the full rule.--date, duplicate/quoted keys, the hint text,set+checkon the real file, an e-mail regex instead of@).chr(10)trick; comment fixes.scripts/citation.py.Round 2 (adversarial reviewer only, as the fixes changed logic): one low finding, fixed. Empty values, and values continued on an indented next line (a YAML plain scalar), are now rejected; before,
setrewrote only the first line, orcheckmisread the value.Sourcery: three findings. Fixed (1b77f4d): the default-date test now pins the clock at a time whose UTC date differs from the local one. Also applied FOCA's Sourcery finding: atomic write.
Declined review findings
date-releasedis the date of thesetchange, not of the tag: by design (the file must be committed before tagging). The docs say to runsetshortly before the release.release_version.py: declined. Incheck, the version comes from the tag thatrelease_version.pyhas already validated, so a divergence could only makecheckfail loudly, never accept a wrong release. The comment says where the version is validated.version : xis detected as an existing key and rejected as an unsupported format....): CFF files don't use document markers, and such a file would failcffconvert --validatein CI.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Add citation metadata and integrate its validation into contributor guidance, CI, and release workflows.
New Features:
Enhancements:
CI:
Documentation:
Tests: