Skip to content

feat: rename evidence to attachments and update schema#121

Merged
aspiers merged 1 commit into
hypercerts-org:developfrom
Kzoeps:fix/attachments-schema-update
Jan 29, 2026
Merged

feat: rename evidence to attachments and update schema#121
aspiers merged 1 commit into
hypercerts-org:developfrom
Kzoeps:fix/attachments-schema-update

Conversation

@Kzoeps
Copy link
Copy Markdown
Contributor

@Kzoeps Kzoeps commented Jan 28, 2026

Summary

Rename evidence records to attachments throughout the SDK to match lexicon updates in beta.13.

Breaking Changes:

  • addEvidence()addAttachment()
  • CreateHypercertEvidenceParamsCreateAttachmentParams
  • evidenceUrisattachmentUris in create results
  • evidenceAddedattachmentAdded event
  • Evidence type exports replaced with Attachment equivalents

Key Updates:

  • Attachment schema now uses subjects (array) instead of subject (single)
  • content is now required and accepts arrays
  • Removed deprecated fields: relationType, contributors, locations
  • Comprehensive test coverage for new attachment API
  • Backward compatibility maintained through type aliases

This aligns the SDK with the latest lexicon definitions and prepares for the beta.13 release.

Summary by CodeRabbit

  • Breaking Changes

    • Renamed addEvidence → addAttachment; evidenceUris → attachmentUris; evidenceAdded → attachmentAdded
    • subject/subjectUri consolidated to subjects (now supports arrays); content is required and normalized to an array of URI/Blob refs
    • Removed schema fields: relationType, contributors, locations
  • New Types

    • Added CreateAttachmentParams, UpdateAttachmentParams, AttachmentParams; HypercertEvidence removed (use HypercertAttachment)
  • Tests & Docs

    • Tests and docs updated to reflect attachment terminology and examples

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 28, 2026

🦋 Changeset detected

Latest commit: 0d250f3

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 Patch

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 28, 2026

📝 Walkthrough

Walkthrough

Renames "evidence" to "attachment" across sdk-core: APIs, types, lexicons, repository implementations, emitted events, schema/examples, and tests; adds CreateAttachmentParams and addAttachment(), removes legacy evidence exports, and normalizes subjects/content to array forms.

Changes

Cohort / File(s) Summary
Changelog & Breaking Change
\.changeset/evidence-to-attachment-rename.md
Adds changeset documenting evidence→attachment rename and schema/API breaking changes.
Public API Exports
packages/sdk-core/src/index.ts, packages/sdk-core/src/types.ts
Removes CreateHypercertEvidenceParams / HypercertEvidence exports; adds CreateAttachmentParams, UpdateAttachmentParams, AttachmentParams; swaps evidence-type exports to attachment equivalents.
Lexicons & Docs
packages/sdk-core/src/lexicons.ts, packages/sdk-core/src/lexicons/sidecar.ts
Removes deprecated EVIDENCE collection alias; updates JSDoc and examples to reference attachments.
Repository Interfaces & Public Surface
packages/sdk-core/src/repository/interfaces.ts, packages/sdk-core/src/repository/Repository.ts
Replaces evidence fields/events/methods with attachments (evidence?attachments?, evidenceUrisattachmentUris, evidenceAddedattachmentAdded, addEvidence()addAttachment()); updates docs/examples.
Implementation & Helpers
packages/sdk-core/src/repository/HypercertOperationsImpl.ts
Introduces addAttachment, renames createEvidenceWithProgresscreateAttachmentsWithProgress, adds helpers resolveAttachmentSubjects, resolveAttachmentContent, buildAttachmentRecord; updates event names, progress steps, collection target, error/messages, and internal flows to use attachments.
Type System
packages/sdk-core/src/services/hypercerts/types.ts
Removes HypercertEvidence alias; adds CreateAttachmentParams, UpdateAttachmentParams, AttachmentParams; enforces subjects and content normalized typings (arrays supported).
Tests
packages/sdk-core/tests/repository/HypercertOperationsImpl.test.ts, packages/sdk-core/tests/repository/Repository.test.ts
Updates tests to attachment terminology and expectations (addAttachment, attachmentUris, attachment collection paths); adjusts fixtures, mocks, and assertions to new record shape and helpers.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant HypercertOps as HypercertOperationsImpl
  participant ATProto as ATProto/Storage
  participant Events as EventEmitter

  Client->>HypercertOps: addAttachment(CreateAttachmentParams)
  HypercertOps->>HypercertOps: resolveAttachmentSubjects()
  HypercertOps->>HypercertOps: resolveAttachmentContent()
  HypercertOps->>HypercertOps: buildAttachmentRecord()
  HypercertOps->>ATProto: create record in ATTACHMENT collection
  ATProto-->>HypercertOps: record URI + CID
  HypercertOps->>Events: emit attachmentAdded {uri, cid}
  HypercertOps-->>Client: Promise<UpdateResult> (attachmentUris)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • aspiers
  • bitbeckers

Poem

🐇 I hopped from Evidence to Attachment today,
I rounded up subjects and bundled content away,
addAttachment now hums where addEvidence once stood,
URIs and CIDs lined up tidy and good,
A carrot of change — small, clever, and spry 🥕✨

🚥 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 accurately and concisely describes the main change: renaming evidence to attachments and updating the schema, which aligns with the comprehensive breaking changes across the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

@Kzoeps Kzoeps self-assigned this Jan 28, 2026
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 @.changeset/evidence-to-attachment-rename.md:
- Around line 5-13: Update the changeset text to explicitly document
schema-level breaking changes in addition to the API renames: state that subject
fields were renamed/removed and content fields were changed/removed (list the
exact fields affected), and show how existing payloads map to the new attachment
schema (e.g., which subject/content properties were removed or renamed). Also
call out the exact symbol renames (addEvidence → addAttachment,
CreateHypercertEvidenceParams → CreateAttachmentParams, evidenceUris →
attachmentUris, evidenceAdded → attachmentAdded) and add a compatibility note
that for pre-1.0 versions minor bumps may introduce breaking changes so
consumers should audit payloads and update code accordingly.
🧹 Nitpick comments (2)
packages/sdk-core/src/repository/HypercertOperationsImpl.ts (2)

481-507: Avoid extra subject lookups when creating attachments during create().
You already have the hypercert CID, so passing a StrongRef avoids redundant getRecord calls and reduces failure points.

♻️ Suggested refactor
-  private async createAttachmentsWithProgress(
-    hypercertUri: string,
+  private async createAttachmentsWithProgress(
+    hypercertRef: StrongRef,
     attachmentItems: Array<Omit<CreateAttachmentParams, "subjects">>,
     onProgress?: (step: ProgressStep) => void,
   ): Promise<string[]> {
@@
-          this.addAttachment({
-            ...attachment,
-            subjects: hypercertUri,
-          } as CreateAttachmentParams).then((result) => result.uri),
+          this.addAttachment({
+            ...attachment,
+            subjects: hypercertRef,
+          } as CreateAttachmentParams).then((result) => result.uri),
@@
-          result.attachmentUris = await this.createAttachmentsWithProgress(
-            hypercertUri,
-            params.attachments,
-            params.onProgress,
-          );
+          const hypercertRef: StrongRef = {
+            $type: "com.atproto.repo.strongRef",
+            uri: hypercertUri,
+            cid: hypercertCid,
+          };
+          result.attachmentUris = await this.createAttachmentsWithProgress(
+            hypercertRef,
+            params.attachments,
+            params.onProgress,
+          );

Also applies to: 624-632


1207-1218: Guard against empty subjects/content arrays for clearer validation.
!contentInput won’t catch [], and empty subjects/content should fail fast with a deterministic ValidationError.

✅ Suggested guard rails
-      if (!contentInput) {
-        throw new ValidationError("content is required for attachments");
-      }
+      if (!contentInput || (Array.isArray(contentInput) && contentInput.length === 0)) {
+        throw new ValidationError("content is required for attachments");
+      }
+      if (!subjectsInput || (Array.isArray(subjectsInput) && subjectsInput.length === 0)) {
+        throw new ValidationError("subjects is required for attachments");
+      }

Comment thread .changeset/evidence-to-attachment-rename.md
@Kzoeps Kzoeps force-pushed the fix/attachments-schema-update branch from e4f585f to 49b9895 Compare January 28, 2026 06:44
@Kzoeps Kzoeps requested a review from aspiers January 28, 2026 06:48
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: 2

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)

556-573: Update the create() example to use content.
The example still shows the old uri field, which is no longer valid for attachments.

✍️ Suggested doc fix
-   attachments: [{ uri: "https://...", description: "Satellite data" }],
+   attachments: [{ content: "https://...", description: "Satellite data" }],
🤖 Fix all issues with AI agents
In @.changeset/evidence-to-attachment-rename.md:
- Around line 17-52: Update the example payload so it matches the new schema:
make "subjects" an array of StrongRefs (not a single string), make "content" an
array of URI/Blob refs (not a single string), and fix the JSON syntax by adding
the missing comma after the "title" field; ensure the example uses the exact
field names "subjects" and "content" to reflect the schema change.

In `@packages/sdk-core/src/repository/HypercertOperationsImpl.ts`:
- Around line 1108-1167: The buildAttachmentRecord currently unconditionally
overwrites $type and createdAt; change it to preserve caller-supplied values by
computing local defaults and only filling when missing (e.g. const type = (rest
as Partial<CreateAttachmentParams>).$type ?? HYPERCERT_COLLECTIONS.ATTACHMENT;
const createdAt = (rest as Partial<CreateAttachmentParams>).createdAt ?? new
Date().toISOString()), then include those computed values in the returned object
instead of hardcoding; also ensure CreateAttachmentParams declares $type and
createdAt as optional so callers can pass them through.

Comment thread .changeset/evidence-to-attachment-rename.md
Comment thread packages/sdk-core/src/repository/HypercertOperationsImpl.ts
@Kzoeps Kzoeps force-pushed the fix/attachments-schema-update branch from 49b9895 to 0d250f3 Compare January 28, 2026 10:35
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 work!

@aspiers aspiers merged commit dc6ed45 into hypercerts-org:develop Jan 29, 2026
3 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Feb 16, 2026
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