Skip to content

refactor: convert measurement subject to subjects array - #143

Merged
aspiers merged 5 commits into
developfrom
refactor/measurement-subjects-array
Mar 2, 2026
Merged

refactor: convert measurement subject to subjects array#143
aspiers merged 5 commits into
developfrom
refactor/measurement-subjects-array

Conversation

@holkexyz

@holkexyz holkexyz commented Feb 25, 2026

Copy link
Copy Markdown
Member

Summary

  • Convert subject (single strongRef) to subjects (array of strongRef, maxLength: 100) in the measurement lexicon
  • Update record-level description to reflect multi-subject support

Test plan

  • npm run check passes (gen-api, lint, typecheck, build, test)
  • Verify SCHEMAS.md reflects the updated field

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor

    • Reorganized measurement schema to support multiple subjects and locations instead of single references
    • Added optional metadata fields including start/end dates, units, method information, evidence URIs, and comments
  • New Features

    • Introduced rights schema for tracking rights information with properties for name, type, description, and attachments

@changeset-bot

changeset-bot Bot commented Feb 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: efafb8f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai

coderabbitai Bot commented Feb 25, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@aspiers has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 14 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d620a99 and efafb8f.

📒 Files selected for processing (5)
  • .changeset/refactor-measurement-schema.md
  • ERD.puml
  • SCHEMAS.md
  • lexicons/org/hypercerts/context/evaluation.json
  • lexicons/org/hypercerts/context/measurement.json
📝 Walkthrough

Walkthrough

The measurement schema is relocated from org.hypercerts.claim.measurement to org.hypercerts.context.measurement and restructured with a subject-to-subjects array replacement, new fields (unit, startDate, endDate, locations, comment), and updated field requirements. All related schema files and references are updated accordingly.

Changes

Cohort / File(s) Summary
Measurement Schema Relocation & Restructuring
lexicons/org/hypercerts/context/measurement.json, SCHEMAS.md, ERD.puml
Moves measurement schema from claim to context namespace, replaces single subject with subjects array (maxLength 100), adds unit, startDate, endDate, locations array, comment, and commentFacets. Makes measurers optional and updates relationship mappings.
Schema Reference Updates
lexicons/org/hypercerts/claim/evaluation.json
Updates measurements property description to reference org.hypercerts.context.measurement instead of the previous claim namespace location.
Schema Documentation
.changeset/refactor-measurement-schema.md
Documents the refactoring with migration details, field additions/changes, and namespace relocation specifics.
Build Configuration
.prettierignore
Adds four new directory patterns (.opencode/, .claude/, .codex/, .gemini/) to ignore rules.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • s-adamantine
  • bitbeckers

Poem

🐰 A hop through the schema so grand,
From claim to context, a migration so planned,
One subject becomes many more,
With dates and locations we now explore,
The lexicon grows, the structure stays true,
Measurement's home gets a fresh point of view!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: converting the measurement subject field from a single reference to a subjects array, which is the primary refactoring objective of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Lexicon Documentation Sync ✅ Passed Pull request successfully maintains synchronization across all documentation files. Measurement lexicon properly moved to correct namespace with all field changes implemented, evaluation.json correctly references new location, ERD.puml updated with accurate relationships, and SCHEMAS.md regenerated with accurate documentation.
Lexicons Styleguide Compliance ✅ Passed Both lexicon files fully comply with atproto style guide: proper reverse domain notation, camelCase fields, complete descriptions, appropriate constraints (maxLength, maxGraphemes, format specifications), correct record types with tid keys, and proper cross-references.

✏️ 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 refactor/measurement-subjects-array

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.

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

Caution

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

⚠️ Outside diff range comments (1)
lexicons/org/hypercerts/claim/measurement.json (1)

1-107: ⚠️ Potential issue | 🟠 Major

Update SCHEMAS.md and ERD.puml to reflect the subjectsubjects rename and type change.

SCHEMAS.md line 212 documents subject (singular) for org.hypercerts.claim.measurement, but the lexicon now defines subjects as an array. ERD.puml line 293 shows measurement::subject --> activity, which should be updated to measurement::subjects. The cardinality changed from a single reference to an array.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lexicons/org/hypercerts/claim/measurement.json` around lines 1 - 107, Update
the documentation and diagram to reflect that org.hypercerts.claim.measurement
now uses the property "subjects" (array of refs) instead of "subject" (single
ref): edit SCHEMAS.md to replace the singular "subject" entry for
org.hypercerts.claim.measurement with "subjects" and document its array type and
maxLength 100, and edit ERD.puml to change the relationship line from
measurement::subject --> activity to measurement::subjects (and adjust
cardinality to indicate multiple references); ensure the textual description and
cardinality notes match the lexicon's "subjects" array and its max cardinality.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@lexicons/org/hypercerts/claim/measurement.json`:
- Around line 1-107: Update the documentation and diagram to reflect that
org.hypercerts.claim.measurement now uses the property "subjects" (array of
refs) instead of "subject" (single ref): edit SCHEMAS.md to replace the singular
"subject" entry for org.hypercerts.claim.measurement with "subjects" and
document its array type and maxLength 100, and edit ERD.puml to change the
relationship line from measurement::subject --> activity to
measurement::subjects (and adjust cardinality to indicate multiple references);
ensure the textual description and cardinality notes match the lexicon's
"subjects" array and its max cardinality.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2bb200c and 27d59a4.

📒 Files selected for processing (2)
  • .changeset/refactor-measurement-schema.md
  • lexicons/org/hypercerts/claim/measurement.json

aspiers added a commit that referenced this pull request Feb 26, 2026
- Regenerate SCHEMAS.md to reflect subject -> subjects rename (now an
  array of refs with maxLength 100) and updated description
- Update ERD.puml to use measurement::subjects relationship
- Add AI tool directories to .prettierignore to avoid local noise

Addresses CodeRabbit feedback on PR #143.
@aspiers
aspiers force-pushed the refactor/measurement-subjects-array branch from 27d59a4 to ee4a6f9 Compare February 26, 2026 16:20

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

Caution

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

⚠️ Outside diff range comments (2)
ERD.puml (1)

86-99: ⚠️ Potential issue | 🟠 Major

Measurement entity fields are out of sync with schema changes.

The relationship arrow at line 293 was correctly updated to measurement::subjects, but the measurement dataclass definition still shows the old field structure. Per coding guidelines, ERD.puml must be kept in sync with lexicon changes.

Fields needing update:

  • subject?subjects[]?
  • measurers[]measurers[]? (now optional)
  • location?locations[]?
  • Add missing: unit, startDate?, endDate?, comment?

Note: commentFacets should remain omitted per guidelines (facet fields excluded from ERD).

🔧 Proposed fix
 ' org.hypercerts.claim.measurement
 dataclass measurement {
     !if (SHOW_FIELDS == "true")
-    subject?
-    measurers[]
+    subjects[]?
     metric
+    unit
     value
+    startDate?
+    endDate?
+    locations[]?
     methodType?
     methodURI?
     evidenceURI[]?
-    location?
+    measurers[]?
+    comment?
     createdAt
     !endif
 }

As per coding guidelines: "Verify that JSON lexicons, README.md, and ERD.puml are kept in sync when lexicon files are added, modified, or deleted."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ERD.puml` around lines 86 - 99, The measurement dataclass in ERD.puml is out
of sync with the updated lexicon: update the dataclass measurement definition
(the block starting with "dataclass measurement") to reflect the new field
shapes and names by changing subject? to subjects[]?, making measurers[]
optional (measurers[]?), changing location? to locations[]?, and adding the new
fields unit, startDate?, endDate?, and comment? (do not add commentFacets). Keep
the existing SHOW_FIELDS conditional and createdAt field as-is and ensure array
and optional syntax matches the rest of the file.
.changeset/refactor-measurement-schema.md (1)

1-3: ⚠️ Potential issue | 🔴 Critical

Use major version bump for these breaking changes.

The changeset documents breaking modifications to the measurement schema but is marked minor. Per the repository's versioning policy (documented in docs/PUBLISHING.md):

  • Major: Breaking changes
  • Minor: New features
  • Patch: Bug fixes and minor updates

The documented changes include:

  • Field rename: subjectsubjects (with type change to array)
  • Field rename: locationlocations (with type change to array)
  • Required field changes: removed measurers, added unit as required

These warrant a major version bump to alert consumers of incompatible API changes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/refactor-measurement-schema.md around lines 1 - 3, Change the
changeset entry that currently sets "@hypercerts-org/lexicon": minor to use a
major bump instead; update the YAML header value from minor to major in the
refactor-measurement-schema changeset so consumers are alerted to the breaking
measurement-schema changes (subject→subjects array, location→locations array,
measurers removed, unit added required).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In @.changeset/refactor-measurement-schema.md:
- Around line 1-3: Change the changeset entry that currently sets
"@hypercerts-org/lexicon": minor to use a major bump instead; update the YAML
header value from minor to major in the refactor-measurement-schema changeset so
consumers are alerted to the breaking measurement-schema changes
(subject→subjects array, location→locations array, measurers removed, unit added
required).

In `@ERD.puml`:
- Around line 86-99: The measurement dataclass in ERD.puml is out of sync with
the updated lexicon: update the dataclass measurement definition (the block
starting with "dataclass measurement") to reflect the new field shapes and names
by changing subject? to subjects[]?, making measurers[] optional (measurers[]?),
changing location? to locations[]?, and adding the new fields unit, startDate?,
endDate?, and comment? (do not add commentFacets). Keep the existing SHOW_FIELDS
conditional and createdAt field as-is and ensure array and optional syntax
matches the rest of the file.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 27d59a4 and ee4a6f9.

📒 Files selected for processing (5)
  • .changeset/refactor-measurement-schema.md
  • .prettierignore
  • ERD.puml
  • SCHEMAS.md
  • lexicons/org/hypercerts/claim/measurement.json
✅ Files skipped from review due to trivial changes (1)
  • .prettierignore
🚧 Files skipped from review as they are similar to previous changes (1)
  • lexicons/org/hypercerts/claim/measurement.json

Comment thread SCHEMAS.md Outdated
@aspiers aspiers self-assigned this Feb 27, 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.

🧹 Nitpick comments (1)
.changeset/refactor-measurement-schema.md (1)

7-19: Consider adding a concise migration snippet for the breaking rename.

Since this is a breaking change, adding a short before/after payload example for subject -> subjects[] and location -> locations[] would reduce upgrade risk for downstream consumers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/refactor-measurement-schema.md around lines 7 - 19, Add a short
migration example showing how to transform existing measurement payloads to the
new schema: demonstrate replacing the single "subject" strongRef with a
"subjects" array (wrapping the previous value as a single-element array) and
similarly wrapping "location" into "locations" array; show before and after
minimal JSON snippets for org.hypercerts.context.measurement that include the
new required "unit" field and optional "startDate"/"endDate" where applicable,
and mention that "measurers" is now optional so existing values can remain
untouched.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.changeset/refactor-measurement-schema.md:
- Around line 7-19: Add a short migration example showing how to transform
existing measurement payloads to the new schema: demonstrate replacing the
single "subject" strongRef with a "subjects" array (wrapping the previous value
as a single-element array) and similarly wrapping "location" into "locations"
array; show before and after minimal JSON snippets for
org.hypercerts.context.measurement that include the new required "unit" field
and optional "startDate"/"endDate" where applicable, and mention that
"measurers" is now optional so existing values can remain untouched.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 340cd5d and d620a99.

📒 Files selected for processing (5)
  • .changeset/refactor-measurement-schema.md
  • ERD.puml
  • SCHEMAS.md
  • lexicons/org/hypercerts/claim/evaluation.json
  • lexicons/org/hypercerts/context/measurement.json

holkexyz and others added 5 commits March 2, 2026 00:27
Allow a measurement to reference multiple records by changing `subject`
(single strongRef) to `subjects` (array of strongRefs).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Regenerate SCHEMAS.md to reflect subject -> subjects rename (now an
  array of refs with maxLength 100) and updated description
- Update ERD.puml to use measurement::subjects relationship
- Add AI tool directories to .prettierignore to avoid local noise

Addresses CodeRabbit feedback on PR #143.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update measurement dataclass: subject?→subjects[]?, measurers[]→measurers[]?,
  location?→locations[]?, add unit, startDate?, endDate?, comment?
- Update measurement::location→measurement::locations arrow
- Regenerate SCHEMAS.md
@aspiers
aspiers force-pushed the refactor/measurement-subjects-array branch from d620a99 to efafb8f Compare March 2, 2026 00:28
@aspiers
aspiers merged commit ee144e4 into develop Mar 2, 2026
5 checks passed
@aspiers
aspiers deleted the refactor/measurement-subjects-array branch March 2, 2026 00:32
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.

3 participants