Skip to content

feat: Update measurement API to align with lexicon beta.12+#120

Merged
aspiers merged 2 commits into
developfrom
measurements-migration
Jan 27, 2026
Merged

feat: Update measurement API to align with lexicon beta.12+#120
aspiers merged 2 commits into
developfrom
measurements-migration

Conversation

@Kzoeps
Copy link
Copy Markdown
Contributor

@Kzoeps Kzoeps commented Jan 27, 2026

Summary

Updates the addMeasurement API to align with the lexicon beta.12+ schema changes, introducing breaking changes to improve measurement handling and add new capabilities.

Breaking Changes

  • addMeasurement() now accepts CreateMeasurementParams instead of individual parameters
  • subject field replaces hypercertUri and accepts both string AT-URIs and StrongRefs
  • unit is now a required field (e.g., "tons CO2e", "hectares", "%")
  • measurers is now optional instead of required
  • Field name changes: methodUrimethodURI, evidenceUrisevidenceURI

New Features

  • Support for locations array to specify where measurements were taken
  • Added startDate and endDate for measurement timeframes
  • Added methodType for short methodology identifiers
  • Rich text support via comment and commentFacets fields

Internal Improvements

  • Added resolveToStrongRef utility for handling string/StrongRef conversions
  • Updated evidence handling to use HypercertAttachment schema (beta.13 compatibility)
  • Improved error messages in URI resolution functions
  • Added comprehensive test coverage for the new utility function

Test Results

  • ✅ All 660 tests passing
  • ✅ Fixed 2 addMeasurement tests to use new API parameters
  • ✅ Added 7 new tests for resolveToStrongRef utility

Related

  • Changeset: .changeset/update-measurement-api.md
  • Aligns with lexicon package version 0.10.0-beta.13

Summary by CodeRabbit

  • Breaking Changes

    • Measurement API shapes updated: new param types; unit is required, measurers optional; methodUri → methodURI, evidenceUris → evidenceURI; evidence renamed to attachment; OrgHypercertsDefs removed and workScope simplified to string | StrongRef.
  • New Features

    • Added updateMeasurement & measurementUpdated event, subject as string/StrongRef, locations array, startDate/endDate, methodType, comment and commentFacets, and attachment schema support.
  • Tests

    • Fixtures and tests updated for new shapes, naming, and strong-ref resolution.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 27, 2026

🦋 Changeset detected

Latest commit: 61fe2cf

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

This PR includes changesets to release 2 packages
Name Type
@hypercerts-org/sdk-core Minor
@hypercerts-org/sdk-react 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
Copy link
Copy Markdown

coderabbitai Bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

Updates SDK to lexicon v0.10.0-beta.13: renames evidence→attachment, evolves measurement APIs (Create/UpdateMeasurementParams, required unit, locations[], startDate/endDate, methodType, rich-text comment/commentFacets), adds updateMeasurement, resolveToStrongRef, and makes workScope string | StrongRef.

Changes

Cohort / File(s) Summary
Lexicon Dependency
packages/sdk-core/package.json
Bump @hypercerts-org/lexicon 0.10.0-beta.11 → 0.10.0-beta.13.
Lexicon Config & Collections
packages/sdk-core/src/lexicons.ts
Replace EVIDENCE imports with ATTACHMENT, add deprecated EVIDENCE alias, update HYPERCERT_LEXICONS and HYPERCERT_COLLECTIONS.
Public Re-exports
packages/sdk-core/src/index.ts, packages/sdk-core/src/services/hypercerts/types.ts
Re-export attachment types/aliases (OrgHypercertsClaimAttachment, HypercertAttachment), add measurement types (CreateMeasurementParams, UpdateMeasurementParams, MeasurementParams), deprecate HypercertEvidence.
Repository Interfaces
packages/sdk-core/src/repository/interfaces.ts
Introduce CreateMeasurementParams/UpdateMeasurementParams and StrongRef export; change workScope → `string
Core Implementation
packages/sdk-core/src/repository/HypercertOperationsImpl.ts
Add resolveToStrongRef and update resolveLocation; change addMeasurement to accept CreateMeasurementParams (subject as string
Types & Aliases
packages/sdk-core/src/services/hypercerts/types.ts
Add measurement/location types, export rich-text facet, alias HypercertAttachment, add UpdateMeasurementParams as Partial excluding subject.
Tests (sdk-core)
packages/sdk-core/tests/...
Update fixtures/tests for string workScope, attachment shapes (content arrays), new measurement fields; add tests for resolveToStrongRef and measurement update flows; rename evidence→attachment in tests.
SDK-React Types & Fixtures
packages/sdk-react/src/index.ts, packages/sdk-react/src/types.ts, packages/sdk-react/src/testing/mocks.ts, packages/sdk-react/tests/**
Remove OrgHypercertsDefs export, change UpdateHypercertParams.workScope to `string
Docs / Changelog / Specs
.changeset/update-measurement-api.md, specs/lexicon-sync/...md
Document measurement API changes, attachment rename, required unit, locations[], startDate/endDate, comments/facets, and lexicon sync notes.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant Ops as HypercertOperationsImpl
    participant Resolver as resolveToStrongRef
    participant Lex as LexiconService
    participant Store as ATProtoStore

    Client->>Ops: addMeasurement(CreateMeasurementParams)
    Ops->>Resolver: resolveToStrongRef(params.subject)
    alt subject is string
        Resolver->>Lex: fetchRecord(uri)
        Lex-->>Resolver: StrongRef (uri + cid)
        Resolver-->>Ops: StrongRef
    else subject is StrongRef
        Resolver-->>Ops: StrongRef
    end
    Ops->>Ops: processLocations(params.locations)
    Ops->>Lex: validate ATTACHMENT & MEASUREMENT schemas
    Lex-->>Ops: validation result
    Ops->>Store: createRecord(ATTACHMENT / HypercertMeasurement)
    Store-->>Ops: CreateResult (uri, cid)
    Ops-->>Client: return CreateResult
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • aspiers
  • bitbeckers

Poem

🐰 I hopped through types and swapped evidence for art,
Units and places now each play their part,
Strings stretch to StrongRefs with a gentle resolve,
Dates and comments in new fields evolve,
A rabbit cheers the schema's fresh start. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main objective of the PR - updating the measurement API to align with lexicon beta.12+, which is the primary purpose of all changes across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Caution

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

⚠️ Outside diff range comments (1)
packages/sdk-core/src/repository/HypercertOperationsImpl.ts (1)

1102-1150: Use ATTACHMENT collection constant for createRecord.

The code validates and sets $type with HYPERCERT_COLLECTIONS.ATTACHMENT, but createRecord still uses the deprecated HYPERCERT_COLLECTIONS.EVIDENCE. Both currently reference ATTACHMENT_NSID, so the code works, but this inconsistency should be resolved by using the current constant throughout.

♻️ Proposed fix
       const result = await this.agent.com.atproto.repo.createRecord({
         repo: this.repoDid,
-        collection: HYPERCERT_COLLECTIONS.EVIDENCE,
+        collection: HYPERCERT_COLLECTIONS.ATTACHMENT,
         record: evidenceRecord,
       });
🤖 Fix all issues with AI agents
In `@packages/sdk-core/package.json`:
- Line 91: The package.json entry for dependency "@hypercerts-org/lexicon"
points to non-published version 0.10.0-beta.13; update the dependency to a
published version (e.g., 0.10.0-beta.12 or 0.10.0-beta.11) in package.json or
ensure the project uses the private registry that hosts 0.10.0-beta.13, and then
reconcile code to match the chosen lexicon schema: search for code using lexicon
types/names (imports and usages referencing evidence, subject, content,
relationType, contributors, locations) and either adapt to the older published
schema or apply the breaking-change mappings (evidence → attachment, subject →
subjects array, content → array, remove relationType/contributors/locations) in
functions/classes handling lexicon payloads so runtime and types align with the
selected package version.

In `@packages/sdk-core/src/repository/HypercertOperationsImpl.ts`:
- Around line 1520-1593: Update the addMeasurement JSDoc examples and parameter
descriptions to match the current CreateMeasurementParams and
HypercertMeasurement field names: replace subjectUri with subject (strong ref or
URI per CreateMeasurementParams), methodUri with methodURI, and evidenceUris
with evidenceURI (singular field name used in the measurementRecord), and ensure
other optional fields (locations, measurers, commentFacets) reflect the actual
names used in addMeasurement and HypercertMeasurement; locate these in the
addMeasurement JSDoc block surrounding the addMeasurement function and update
the example payloads and any inline param names to the new identifiers.

In `@packages/sdk-core/src/repository/interfaces.ts`:
- Around line 965-1006: The examples in the addMeasurement JSDoc use outdated
parameter names (subjectUri, methodUri, evidenceUris) that no longer match
CreateMeasurementParams; update both the "Basic measurement" and "Full
measurement" examples to use the current parameter names (subject instead of
subjectUri, methodURI instead of methodUri, and evidenceURI/evidenceURIs as
defined by CreateMeasurementParams) and ensure other fields (unit, value,
locations, measurers, comment, commentFacets) match the type names and casing
used by CreateMeasurementParams so the examples compile and reflect the real API
for the addMeasurement method.
- Around line 230-245: The workScope property currently allows an invalid shape
({ $type: string }) which bypasses compile-time validation; change its type to
the StrongRef type imported from the services types to enforce the proper { uri,
cid, $type } structure—update the import to bring in StrongRef from the services
types module and replace the union on the workScope declaration (the workScope?:
string | { uri: string; cid: string } | { $type: string }; line) with
workScope?: string | StrongRef so the compiler guarantees the correct reference
shape.

In `@packages/sdk-core/src/services/hypercerts/types.ts`:
- Around line 388-446: Update the basic example in the CreateMeasurementParams
docblock to use the correct property name `subject` (not `subjectUri`) to match
the type definition; edit the example object in the comment so it uses `subject:
"at://did:plc:abc/org.hypercerts.claim.activity/xyz"` and keep the rest of the
example fields unchanged to reflect the real `CreateMeasurementParams` shape.

In `@specs/lexicon-sync/v0.10.0-beta.11-v0.10.0-beta.13.md`:
- Around line 90-108: The checklist item referencing "Update
`UpdateMeasurementParams` accordingly ( There is no Update function)" is
ambiguous; either remove this item or reword it to clarify intent — e.g., change
to "Remove/skip UpdateMeasurementParams (no update endpoint exists)" or "Prepare
UpdateMeasurementParams for future update endpoint (no current update
function)"; update the spec text where "UpdateMeasurementParams" and the parent
checklist are listed so readers clearly understand whether an update API is
absent or this is a TODO for a future endpoint.
🧹 Nitpick comments (2)
packages/sdk-core/tests/repository/HypercertValidation.test.ts (1)

8-13: Consider centralizing the workScope test helper.
This helper is duplicated in other tests; a shared utility would reduce drift.

packages/sdk-core/src/repository/HypercertOperationsImpl.ts (1)

1035-1100: Add a null guard in resolveToStrongRef.

typeof input === "object" will throw on null when using "uri" in input; a guard keeps error handling consistent.

♻️ Proposed fix
-    if (typeof input === "object" && "uri" in input && "cid" in input) {
+    if (input && typeof input === "object" && "uri" in input && "cid" in input) {

Comment thread packages/sdk-core/package.json
Comment thread packages/sdk-core/src/repository/HypercertOperationsImpl.ts
Comment thread packages/sdk-core/src/repository/interfaces.ts
Comment thread packages/sdk-core/src/repository/interfaces.ts
Comment thread packages/sdk-core/src/services/hypercerts/types.ts
Comment thread specs/lexicon-sync/v0.10.0-beta.11-v0.10.0-beta.13.md
@Kzoeps Kzoeps force-pushed the measurements-migration branch 2 times, most recently from 2caf565 to d6c0bf0 Compare January 27, 2026 09:50
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
packages/sdk-react/tests/hooks/useHypercerts.test.tsx (1)

219-236: Remove or replace the complex workScope object structure; it doesn't match the type definition.

The workScope type definition in interfaces.ts accepts only string | { uri: string; cid: string } | { $type: string }. The test at lines 223–232 uses an invalid structure with op, args, and nested atom properties that don't conform to this type. Use the correct string format (e.g., "Climate Action" as shown at line 286) or a valid StrongRef object instead.

🤖 Fix all issues with AI agents
In @.changeset/update-measurement-api.md:
- Around line 1-20: Add a short explicit pre-1.0 breaking-change note to the
changeset clarifying that minor version bumps in these 0.x packages can be
breaking; update the changeset text that lists "@hypercerts-org/sdk-core" and
"@hypercerts-org/sdk-react" and the breaking changes (e.g., addMeasurement() →
CreateMeasurementParams, subject replacing hypercertUri, unit required,
measurers optional, methodUri→methodURI, evidenceUris→evidenceURI, removal of
OrgHypercertsDefs) with a single sentence such as “Note: These packages are
pre-1.0; minor version bumps may include breaking changes.” so consumers
immediately see the pre-1.0 expectation.
🧹 Nitpick comments (1)
packages/sdk-core/src/repository/HypercertOperationsImpl.ts (1)

1102-1104: Track the TODO for attachment schema alignment.

Can you open a follow‑up issue and link it here?

If you want, I can draft the attachment‑schema migration plan.

Comment thread .changeset/update-measurement-api.md
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (2)
packages/sdk-core/src/index.ts (1)

147-174: Export HypercertAttachment from the main entrypoint.
types.ts defines HypercertAttachment, but index.ts only re-exports HypercertEvidence. Exposing the new alias from the main entrypoint avoids a leaky public surface.

📝 Suggested export update
 export type {
   StrongRef,
   HypercertClaim,
   HypercertRights,
   HypercertContributionDetails,
   HypercertContributorInformation,
   HypercertContributor,
   HypercertMeasurement,
   HypercertEvaluation,
   HypercertCollection,
   HypercertCollectionItem,
   HypercertWorkScopeTag,
   HypercertLocation,
   BadgeAward,
   BadgeDefinition,
   BadgeResponse,
   FundingReceipt,
   // SDK-specific types
+  HypercertAttachment,
   HypercertEvidence,
   HypercertImage,
   HypercertImageRecord,
   BlobRef,
   HypercertWithMetadata,
   HypercertProject,
   HypercertProjectWithMetadata,
   CreateProjectParams,
   UpdateProjectParams,
 } from "./services/hypercerts/types.js";

As per coding guidelines, ensure all public APIs are exported via the correct entrypoints.

packages/sdk-core/src/repository/HypercertOperationsImpl.ts (1)

1102-1150: Use the non-deprecated ATTACHMENT collection constant instead of EVIDENCE.

The record is validated as HYPERCERT_COLLECTIONS.ATTACHMENT and $type is set to ATTACHMENT, but createRecord still uses the deprecated HYPERCERT_COLLECTIONS.EVIDENCE constant. While both constants currently resolve to the same value (ATTACHMENT_NSID), EVIDENCE is marked as deprecated since beta.13 and should be replaced. Additionally, the TODO comment indicates the migration to the Attachment Lexicon is incomplete—this change would resolve it.

🐛 Proposed fix
       const result = await this.agent.com.atproto.repo.createRecord({
         repo: this.repoDid,
-        collection: HYPERCERT_COLLECTIONS.EVIDENCE,
+        collection: HYPERCERT_COLLECTIONS.ATTACHMENT,
         record: evidenceRecord,
       });
🤖 Fix all issues with AI agents
In `@packages/sdk-core/src/services/hypercerts/types.ts`:
- Around line 382-438: Add two missing types for measurements to follow the SDK
convention: declare a MeasurementParams base type that maps to the lexicon Main
record (e.g., aliasing OrgHypercertsClaimMeasurement.Main or a strict SDK-facing
shape) and declare UpdateMeasurementParams as the update variant that mirrors
CreateMeasurementParams but with fields optional/partial for patch semantics
(ensure subject can still accept string | StrongRef and locations can accept
LocationParams[]). Place the new types alongside CreateMeasurementParams so code
that expects Main/SDK/Create/Update/Params for the measurement entity is
satisfied.
🧹 Nitpick comments (2)
packages/sdk-react/tests/testing/mocks.test.ts (1)

174-181: Consider simplifying the type assertion for workScope override.

The double assertion as unknown as typeof hc.workScope works but is verbose. Since UpdateHypercertParams.workScope accepts string directly, you could simplify this:

  it("should allow overriding hypercert properties", () => {
    const hc = createMockHypercert({
      title: "Custom Hypercert",
-     workScope: "Climate Action" as unknown as typeof hc.workScope,
+     workScope: "Climate Action",
    });

    expect(hc.title).toBe("Custom Hypercert");
    expect(hc.workScope).toBe("Climate Action");
  });

If TypeScript still complains, the assertion may be needed due to Hypercert["workScope"] being a stricter type than what Partial<Hypercert> accepts. In that case, the current approach is acceptable.

.changeset/update-measurement-api.md (1)

14-14: Consider clarifying whether evidenceURI still accepts multiple values.

The rename from evidenceUris (plural) to evidenceURI (singular) could cause confusion about whether the field still accepts an array of URIs or has changed to accept only a single URI. A brief note would help users understand if this is purely a naming change or if the functionality has also changed.

Comment thread packages/sdk-core/src/services/hypercerts/types.ts
@Kzoeps Kzoeps force-pushed the measurements-migration branch from d6c0bf0 to 8977a33 Compare January 27, 2026 11:11
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
packages/sdk-core/src/repository/HypercertOperationsImpl.ts (1)

1124-1144: Filter legacy evidence-only fields before attachment validation.

Spreading ...rest into the new attachment record will propagate deprecated fields (e.g., relationType/contributors/locations) and can fail validation for existing callers. Whitelist only attachment-supported fields before validation to preserve backward compatibility.

🛠️ Suggested fix (whitelist attachment fields)
-      const { subjectUri, content, ...rest } = evidence;
+      const { subjectUri, content, ...rest } = evidence;
+      const {
+        title,
+        shortDescription,
+        description,
+        contentType,
+        location,
+        shortDescriptionFacets,
+        descriptionFacets,
+      } = rest as Partial<HypercertAttachment>;
@@
-      const evidenceRecord: HypercertAttachment = {
-        ...rest,
+      const evidenceRecord: HypercertAttachment = {
+        title,
+        shortDescription,
+        description,
+        contentType,
+        location,
+        shortDescriptionFacets,
+        descriptionFacets,
         $type: HYPERCERT_COLLECTIONS.ATTACHMENT,
         createdAt,
         content: [evidenceContent], // content is now an array
         subjects: [{ uri: subject.uri, cid: subject.cid }], // subject -> subjects array
       };
🤖 Fix all issues with AI agents
In `@packages/sdk-react/src/types.ts`:
- Around line 316-320: The UpdateHypercertParams.workScope union uses an ad-hoc
object type that allows invalid shapes (e.g., { $type: string })—replace the
inline type with the canonical StrongRef from `@hypercerts-org/sdk-core` to match
core validation. Import StrongRef from "@hypercerts-org/sdk-core" and change the
workScope type to string | StrongRef (update any related references or exports
in the same file), ensuring the type now enforces { uri: string; cid: string }
exactly.

Comment thread packages/sdk-react/src/types.ts
@Kzoeps Kzoeps force-pushed the measurements-migration branch from 8977a33 to cd7bdef Compare January 27, 2026 11:25
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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 `@packages/sdk-core/src/repository/HypercertOperationsImpl.ts`:
- Around line 1664-1671: The updateMeasurement method currently accepts any
collection from the parsed URI and may write measurement-shaped data into
arbitrary collections; update the validation after uriMatch (in
updateMeasurement) to assert the parsed collection equals the measurements
collection name (e.g., "measurement" or the repo's measurement collection
constant) and throw a ValidationError if it does not target the measurement
collection so only URIs targeting measurements are allowed.
🧹 Nitpick comments (1)
packages/sdk-core/src/services/hypercerts/types.ts (1)

388-394: Consider consolidating duplicate type aliases.

Both Measurement (line 394) and HypercertMeasurement (line 151) alias OrgHypercertsClaimMeasurement.Main. While the grouping in this section is logical, having two identical exports may confuse SDK consumers.

Consider either removing Measurement in favor of the existing HypercertMeasurement, or adding a @see reference to clarify they're equivalent:

 /**
  * SDK type for measurement records.
  * Alias for the lexicon Main type, used in SDK operations.
  *
- * `@see` HypercertMeasurement - Equivalent alias
+ * `@see` {`@link` HypercertMeasurement} - Identical alias following `Hypercert*` naming convention
  */
 export type Measurement = OrgHypercertsClaimMeasurement.Main;

Comment thread packages/sdk-core/src/repository/HypercertOperationsImpl.ts
@Kzoeps Kzoeps force-pushed the measurements-migration branch from cd7bdef to 7b6f1f5 Compare January 27, 2026 11:39
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
packages/sdk-core/src/repository/HypercertOperationsImpl.ts (1)

1130-1151: Use the attachment collection when creating attachment records.

The record is validated as HYPERCERT_COLLECTIONS.ATTACHMENT (the current collection), but the write operation uses HYPERCERT_COLLECTIONS.EVIDENCE, which is deprecated in favor of ATTACHMENT (as noted in lexicons.ts). Although both currently resolve to the same NSID, using the deprecated constant misaligns with the schema validation and contradicts the code comment stating "evidence is no longer available in the lexicons." Update the collection to use HYPERCERT_COLLECTIONS.ATTACHMENT.

🔧 Suggested fix
       const result = await this.agent.com.atproto.repo.createRecord({
         repo: this.repoDid,
-        collection: HYPERCERT_COLLECTIONS.EVIDENCE,
+        collection: HYPERCERT_COLLECTIONS.ATTACHMENT,
         record: evidenceRecord,
       });
🤖 Fix all issues with AI agents
In @.changeset/update-measurement-api.md:
- Around line 18-20: Update the sdk-react workScope bullet to reflect the
current type for UpdateHypercertParams.workScope: replace the invalid `{ $type:
string }` shape with `StrongRef` (or the inline `{ uri: string; cid: string }`)
and document the union as `string | StrongRef` (or `string | { uri; cid }`) so
the bullet matches the actual type used by UpdateHypercertParams.workScope.

Comment thread .changeset/update-measurement-api.md
@Kzoeps Kzoeps force-pushed the measurements-migration branch from 7b6f1f5 to 61fe2cf Compare January 27, 2026 12:11
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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 `@packages/sdk-core/src/repository/HypercertOperationsImpl.ts`:
- Around line 1103-1105: The addEvidence method currently accepts
CreateHypercertEvidenceParams but transforms it to the lexicon's
HypercertAttachment shape (subjects array, content array) as a temporary
compatibility shim; update the API to align with the Attachment lexicon by
changing the method signature and input type to accept HypercertAttachment
directly (or a clearly-named AttachmentInput that matches the lexicon), remove
the internal transformation logic inside addEvidence, and update any
callers/tests to construct subjects and content as arrays to match
HypercertAttachment; ensure function name addEvidence and types
CreateHypercertEvidenceParams and HypercertAttachment are the points of change
so consumers and implementations use the lexicon schema consistently.
🧹 Nitpick comments (1)
packages/sdk-core/src/services/hypercerts/types.ts (1)

12-12: Align UpdateMeasurementParams with the Create/Update pattern while keeping subject immutable.
Guidelines call for Update*Params = Partial<Create*Params>; you can preserve immutability by adding subject?: never. As per coding guidelines, this keeps the convention consistent.

♻️ Suggested change
-import type { Except, OverrideProperties, SetOptional } from "type-fest";
+import type { OverrideProperties, SetOptional } from "type-fest";

-export type UpdateMeasurementParams = Partial<Except<CreateMeasurementParams, "subject">>;
+export type UpdateMeasurementParams = Partial<CreateMeasurementParams> & { subject?: never };

Also applies to: 471-471

Comment thread packages/sdk-core/src/repository/HypercertOperationsImpl.ts
Copy link
Copy Markdown
Contributor

@aspiers aspiers left a comment

Choose a reason for hiding this comment

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

Awesome thanks!

@aspiers aspiers merged commit 7578756 into develop Jan 27, 2026
4 checks passed
@aspiers aspiers deleted the measurements-migration branch January 27, 2026 21: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.

2 participants