Skip to content

feat: align lexicons with ATProto style guide - #103

Merged
aspiers merged 5 commits into
developfrom
style-fix
Feb 26, 2026
Merged

feat: align lexicons with ATProto style guide#103
aspiers merged 5 commits into
developfrom
style-fix

Conversation

@s-adamantine

@s-adamantine s-adamantine commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Best-of-breed synthesis of #112 and the original work in this PR, fixing issues in both:

  • Fix style checker bug (check-lexicon-style.js): skip format, enum, and knownValues fields — stops false warnings that caused Fix lexicon style guide violations #112's overcorrection
  • Fix rightsDescription ratio: corrected to 10:1 (maxLength: 10000, maxGraphemes: 1000) per style guide — was 5:1 in the original PR
  • Add maxLength/maxGraphemes to all unconstrained string and array fields across badge, activity, collection, rights, receipt, and contributor lexicons
  • Change badge response enumknownValues for schema evolution compliance
  • Add app.certified.defs categorization in schema generator
  • Upgrade changeset from patch to minor (new constraints are additive but affect validation)
  • Add STRING_CONSTRAINTS.md documenting rationale for every constraint value

Closes #111
Closes #112

What was wrong with #112?

  • Added maxLength to 24 format-typed fields (datetime, at-uri, etc.) which the style guide explicitly forbids
  • Modified a third-party lexicon (com.atproto.repo.strongRef)
  • Root cause: style checker bug (now fixed) was warning on format-typed fields

What was wrong with the original PR?

  • rightsDescription had 5:1 byte:grapheme ratio (maxLength: 5000, maxGraphemes: 1000) instead of style guide's 10:1
  • Changeset used patch severity instead of minor

Test plan

  • node scripts/check-lexicon-style.js — 0 errors, 0 string-max-length warnings
  • npm run gen-schemas-md — SCHEMAS.md regenerated and up to date
  • npm test — 7/7 tests pass
  • npm run check — full pipeline (gen-api, lint, typecheck, build, test) passes
  • No format-typed fields have maxLength (verified via diff)

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Jan 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f01f294

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hypercerts-org/lexicon Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jan 21, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds string/array validation metadata and new common defs across lexicons, converts a badge response enum to knownValues, updates style-check and schema generation scripts, and adds documentation and a changeset to reflect ATProto Lexicon style-guide compliance. (48 words)

Changes

Cohort / File(s) Summary
Badge lexicons
lexicons/app/certified/badge/award.json, lexicons/app/certified/badge/definition.json, lexicons/app/certified/badge/response.json
Added maxLength/maxGraphemes constraints (e.g., badgeType:100, title:256, description:5000/maxGraphemes:500); response changed from enum to knownValues; award.note maxLength:500; weight maxLength:50.
Hypercerts claim schemas
lexicons/org/hypercerts/claim/activity.json, lexicons/org/hypercerts/claim/collection.json, lexicons/org/hypercerts/claim/contributorInformation.json, lexicons/org/hypercerts/claim/rights.json
Added array/string constraints (contributors/locations maxLength:1000, contributionWeight/itemWeight maxLength:100, collection.type:64, rightsDescription maxLength:10000/maxGraphemes:1000, identifier maxLength:2048).
Funding receipt
lexicons/org/hypercerts/funding/receipt.json
Added maxLength constraints to to (2048), amount (50), currency (10), paymentRail (50), paymentNetwork (50), transactionId (256).
Shared type defs & schemas doc
lexicons/org/hypercerts/defs.json, SCHEMAS.md
Added/expanded common type definitions; changed uri constraint from maxGraphemes:1024 to maxLength:2048; added top-level description and new app.certified.defs.
Style & generation scripts
scripts/check-lexicon-style.js, scripts/generate-schemas.js
Style checker no longer warns if field has maxLength, maxGraphemes, format, enum, or knownValues; generator treats app.certified.defs as a defs lexicon.
Docs & changeset
STRING_CONSTRAINTS.md, .changeset/style-guide-compliance.md
New document codifying string/grapheme constraints across lexicons; changeset for minor version bump and style-guide alignment.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • #41 — Overlaps badge lexicon changes and shared defs for app.certified badge schemas.
  • #102 — Related to contributor schema changes in org.hypercerts.claim.activity (contributors/contributor fields).
  • #37 — Introduced the funding receipt schema that this PR tightens with maxLength constraints.

Suggested reviewers

  • bitbeckers

Poem

🐰 I hopped through schemas, tidy and neat,
Counting graphemes with careful feet,
Badges and receipts now trimmed and bright,
Defs in their burrow, snug and right,
A tiny rabbit cheers this style-guide flight!

🚥 Pre-merge checks | ✅ 8
✅ Passed checks (8 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: align lexicons with ATProto style guide' accurately and concisely summarizes the main objective of the PR, which is to align the lexicons with the ATProto style guide standards.
Linked Issues check ✅ Passed The PR addresses all coding requirements from issue #111: fixes the style checker bug to skip format/enum/knownValues fields, adds maxLength/maxGraphemes constraints to unconstrained fields, and converts enum to knownValues for compatibility.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the stated objectives: lexicon constraint additions, style checker fixes, schema generator updates, and documentation of the rationale for constraints.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into develop
Lexicon Documentation Sync ✅ Passed Git output confirms README.md and ERD.puml were updated in the same commit as lexicon changes, with file references verifying documentation synchronization.
Lexicons Styleguide Compliance ✅ Passed Lexicon files comply with ATProto style guide: string constraints properly added, enum converted to knownValues, naming conventions followed, and format-typed fields correctly exclude maxLength.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch style-fix

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@s-adamantine s-adamantine changed the title chore: improve lexicon style guide compliance chore: run all lexicons against the ATProto lexicon style guide Jan 21, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@SCHEMAS.md`:
- Around line 177-191: Create a new ATProto lexicon v1 JSON file named
lexicons/org/hypercerts/claim/acknowledgement.json that defines the record
"org.hypercerts.acknowledgement" with the properties listed in SCHEMAS.md:
subjects (ref, required), context (ref, required), given (boolean, required),
comment (string, optional, maxLength 1000), and createdAt (string, required);
ensure the lexicon includes proper ids, defs, record key, and required array per
ATProto lexicon schema v1 and mirrors the table types and descriptions. Then
update README.md to list and briefly describe the new acknowledgement lexicon
alongside the existing claim-related records so it appears in the lexicon
index/documentation.

Comment thread SCHEMAS.md Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
SCHEMAS.md (1)

186-194: Update SCHEMAS.md to document the URI maxLength constraint.

The defs.json file correctly contains maxLength: 2048 for the URI definition, but SCHEMAS.md does not reflect this constraint in the Comments column. The table shows only "Has 'uri' property (string, format uri)" without documenting the maxLength. Regenerate or update SCHEMAS.md to include this constraint and keep it in sync with the source lexicon.

@aspiers

aspiers commented Jan 25, 2026

Copy link
Copy Markdown
Contributor

@copilot This needs rebasing

Copilot AI commented Jan 25, 2026

Copy link
Copy Markdown
Contributor

@aspiers I've opened a new pull request, #130, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns the repository’s ATProto lexicons and schema documentation with the ATProto Lexicon Style Guide (per #66), primarily by tightening string constraints and improving schema evolution compatibility.

Changes:

  • Replaced enum with knownValues for badge response values to support schema evolution.
  • Added maxLength constraints to multiple unconstrained string fields across badge, rights, and funding receipt lexicons.
  • Updated schema docs (SCHEMAS.md) and added a changeset entry describing the compliance changes.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lexicons/org/hypercerts/funding/receipt.json Adds maxLength constraints to several string properties for tighter validation.
lexicons/org/hypercerts/defs.json Updates URI definition to use maxLength (instead of maxGraphemes).
lexicons/org/hypercerts/claim/rights.json Adds maxLength and maxGraphemes constraints to rightsDescription.
lexicons/app/certified/badge/response.json Switches from enum to knownValues and constrains weight length.
lexicons/app/certified/badge/definition.json Adds maxLength constraints to badge text fields.
lexicons/app/certified/badge/award.json Adds a maxLength constraint to the optional note.
SCHEMAS.md Updates generated schema documentation tables to reflect new constraints/known values.
.changeset/style-guide-compliance-fixes.md Adds release notes for the style guide compliance updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

aspiers added a commit that referenced this pull request Feb 14, 2026
Synthesize correct parts of PRs #103 and #112 into a single commit:

- Fix style checker to skip format-typed, enum, and knownValues fields
- Fix rightsDescription byte:grapheme ratio to 10:1 (was 5:1)
- Add maxLength/maxGraphemes to all unconstrained string and array fields
- Add app.certified.defs to schema generator categorization
- Change badge response enum to knownValues
- Add top-level description to org.hypercerts.defs
- Upgrade changeset severity from patch to minor
- Add STRING_CONSTRAINTS.md documenting rationale for every constraint

Co-Authored-By: Sharfy Adamantine <s-adamantine@users.noreply.github.com>
Co-Authored-By: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@aspiers aspiers changed the title chore: run all lexicons against the ATProto lexicon style guide feat: align lexicons with ATProto style guide Feb 14, 2026
aspiers added a commit that referenced this pull request Feb 14, 2026
Synthesize correct parts of PRs #103 and #112 into a single commit:

- Fix style checker to skip format-typed, enum, and knownValues fields
- Fix rightsDescription byte:grapheme ratio to 10:1 (was 5:1)
- Add maxLength/maxGraphemes to all unconstrained string and array fields
- Add app.certified.defs to schema generator categorization
- Change badge response enum to knownValues
- Add top-level description to org.hypercerts.defs
- Upgrade changeset severity from patch to minor
- Add STRING_CONSTRAINTS.md documenting rationale for every constraint

Co-Authored-By: Sharfy Adamantine <s-adamantine@users.noreply.github.com>
Co-Authored-By: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 14, 2026 08:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings February 14, 2026 11:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

scripts/check-lexicon-style.js:389

  • checkStringProperty now skips the maxLength/maxGraphemes warning when format, enum, or knownValues are present, but the repo’s LEXICON_STYLE_GUIDE.md currently documents that the checker enforces "String properties have maxLength constraints". Please update the style guide documentation (or adjust the checker) so the documented automated checks match actual behavior.
  checkStringProperty(prop, path, fileResult) {
    // Check for maxLength
    if (
      !prop.maxLength &&
      !prop.maxGraphemes &&
      !prop.format &&
      !prop.enum &&
      !prop.knownValues
    ) {
      fileResult.issues.push({
        severity: SEVERITY.WARNING,
        rule: "string-max-length",
        message: "String property should have maxLength or maxGraphemes",
        location: `${path}.maxLength`,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .husky/pre-commit Outdated
Comment thread lexicons/org/hypercerts/defs.json
Comment thread STRING_CONSTRAINTS.md
Copilot AI review requested due to automatic review settings February 14, 2026 22:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lexicons/org/hypercerts/funding/receipt.json
Comment thread .husky/pre-commit Outdated
Comment thread STRING_CONSTRAINTS.md Outdated
s-adamantine and others added 2 commits February 14, 2026 22:37
- Change enum to knownValues in badge/response.json for schema evolution
- Add maxLength constraints to string fields without format:
  - badge/definition.json: badgeType (100), title (256), description (1000)
  - badge/award.json: note (500)
  - badge/response.json: weight (50)
  - rights.json: rightsDescription (5000/1000 graphemes)
  - funding/receipt.json: to, amount, currency, paymentRail, paymentNetwork, transactionId
- Remove maxGraphemes from format-typed URI field in defs.json
Synthesize correct parts of PRs #103 and #112 into a single commit:

- Fix style checker to skip format-typed, enum, and knownValues fields
- Fix rightsDescription byte:grapheme ratio to 10:1 (was 5:1)
- Add maxLength/maxGraphemes to all unconstrained string and array fields
- Add app.certified.defs to schema generator categorization
- Change badge response enum to knownValues
- Add top-level description to org.hypercerts.defs
- Upgrade changeset severity from patch to minor
- Add STRING_CONSTRAINTS.md documenting rationale for every constraint
- Document format/enum/knownValues exception in LEXICON_STYLE_GUIDE.md

Co-Authored-By: Sharfy Adamantine <s-adamantine@users.noreply.github.com>
Co-Authored-By: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 14, 2026 22:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .husky/pre-commit
Comment thread .husky/pre-commit
aspiers and others added 3 commits February 17, 2026 15:45
Replace mutating gen-schemas-md call with a validate-only check that
regenerates, diffs, and restores if stale.  The rest of the pipeline
(npm run check) already runs prettier --check, so no writes are needed.

Added comments explaining the rationale so this doesn't get reverted.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add missing descriptions, replace vague text with concrete guidance
and examples, clarify numeric string fields, fix punctuation spacing,
and standardize createdAt wording.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Without this patch, the style checker output showed aggregate severity
counts but didn't break down which specific rules were triggered and
how many times, making it harder to identify the most common issues.

This is a problem because developers need to prioritize which style
issues to address first, and a per-rule breakdown makes patterns more
visible.

This patch solves the problem by:
- Adding formatRuleBreakdown() method showing count per rule type
  (e.g., 'strongref-documentation: 6'), sorted by severity then count
- Refactoring monolithic formatResults() into 5 focused helpers:
  formatHeader(), formatSummary(), formatFileDetails(),
  formatRuleBreakdown(), formatFooter()
- Extracting SEVERITY_ICONS and SEPARATOR as shared module constants,
  eliminating duplicated icon lookup table

Co-authored-by: Claude Code <claude-code@noreply.anthropic.com>
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.

fix warnings from lexicon style checker

4 participants