Skip to content

feat(core): preserve non-standard SP registry capabilities in PDPOffering - #687

Merged
hugomrdias merged 1 commit into
masterfrom
rvagg/extra-capabilities
Apr 2, 2026
Merged

feat(core): preserve non-standard SP registry capabilities in PDPOffering#687
hugomrdias merged 1 commit into
masterfrom
rvagg/extra-capabilities

Conversation

@rvagg

@rvagg rvagg commented Mar 23, 2026

Copy link
Copy Markdown
Collaborator

We shouldn't have been stripping theses, there's potentially useful signals in here downstream from our consumption of the capabilities providers publish. One example is FilOzone/dealbot#364 where the "serviceStatus" capability still has some use, but there's plenty more where clients have needs that align with what service providers want to dump in their capabilities field that we don't know or care about.

@rvagg
rvagg requested a review from SgtPooki March 23, 2026 02:56
@rvagg
rvagg requested a review from hugomrdias as a code owner March 23, 2026 02:56
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Mar 23, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 23, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
synapse-dev eca0ad8 Commit Preview URL

Branch Preview URL
Apr 02 2026, 10:21 AM

@rvagg

rvagg commented Mar 23, 2026

Copy link
Copy Markdown
Collaborator Author

CI failing due to ABI changes, fixing that separately #688

@BigLep BigLep moved this from 📌 Triage to 🐱 Todo in FOC Mar 23, 2026
@BigLep BigLep moved this from 🐱 Todo to 🔎 Awaiting review in FOC Mar 27, 2026
@BigLep
BigLep requested a review from Copilot March 27, 2026 15:47

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 updates PDP capability decoding to preserve non-standard Service Provider Registry capability entries (e.g., serviceStatus) so downstream consumers can access them without needing synapse-core to explicitly model every possible capability.

Changes:

  • Allow unknown capability keys through PDP offering schema validation and surface them via PDPOffering.extraCapabilities.
  • Add logic in decodePDPCapabilities to separate known/typed capability fields from extra/untyped ones.
  • Add tests to verify extra capabilities are preserved and omitted when none exist.

Reviewed changes

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

File Description
packages/synapse-core/src/utils/pdp-capabilities.ts Allows unknown capabilities through validation and returns them in extraCapabilities during decode.
packages/synapse-core/src/sp-registry/types.ts Extends PDPOffering with optional extraCapabilities field.
packages/synapse-core/test/pdp-capabilities.test.ts Adds unit tests covering preservation/omission/filtering of extraCapabilities.

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

Comment thread packages/synapse-core/src/utils/pdp-capabilities.ts Outdated
Comment thread packages/synapse-core/src/utils/pdp-capabilities.ts Outdated
Comment thread packages/synapse-core/src/utils/pdp-capabilities.ts Outdated
@SgtPooki

Copy link
Copy Markdown
Contributor

sorry i didn't get to this. heading on vacation so i wont be able to look until 2026 APR 8+

@rjan90 rjan90 added this to the M4.2: mainnet GA milestone Mar 30, 2026
@rvagg
rvagg requested a review from juliangruber March 30, 2026 11:05

@hugomrdias hugomrdias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM but copilot's first suggestion seems to be good

@github-project-automation github-project-automation Bot moved this from 🔎 Awaiting review to ✔️ Approved by reviewer in FOC Mar 30, 2026
Comment thread packages/synapse-core/src/utils/pdp-capabilities.ts Outdated
Comment thread packages/synapse-core/src/utils/pdp-capabilities.ts Outdated

const result = decodePDPCapabilities(capabilities)

assert.strictEqual(result.extraCapabilities, undefined)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
assert.strictEqual(result.extraCapabilities, undefined)
assert.deepStrictEqual(result.extraCapabilities, {})

(if you merge above suggestion)

}

/** Capability keys that are decoded into typed PDPOffering fields, derived from the schema */
const KNOWN_CAPABILITY_KEYS = new Set([...Object.keys(PDPOfferingSchema.shape), CAP_IPNI_PEER_ID_LEGACY])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This array likely becomes a maintenance burden, and is hard to test in integration.

Would it be easier to expose all capabilities in one object, and not differentiate standard and non-standard capabilities?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think that'd be a downgrade, standard fields give us a well formed struct with proper decoding, flattening them would mean a Record<string, something> bucket to go fishing through. At least we can type the known keys and they match the contract; we can expect to find required keys and may expect to find the non-required but known keys, the rest are a wild west.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Some examples of where we'd lose fidelity: provider.pdp.minPieceSizeInBytes (and max) are decoded as bigint, provider.pdp.paymentTokenAddress as Address, provider.pdp.ipniPiece / ipniIpfs as boolean; we know this and when they don't decode like this something is wrong, and it also means we can offer a typed struct for consumers of known fields.

@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to ⌨️ In Progress in FOC Mar 30, 2026
@hugomrdias

Copy link
Copy Markdown
Member

i will rebase and finish this tomorrow

…ring

There's potentially useful signals in here downstream from our consumption of
the capabilities providers publish.
@rvagg
rvagg force-pushed the rvagg/extra-capabilities branch from 62b69fb to eca0ad8 Compare April 2, 2026 10:12
@rvagg

rvagg commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased and addressed all of the suggestions except for the suggestion to flatten everything; we should be clear with the known keys as the other parts of the system are - the registry and Curio

@github-project-automation github-project-automation Bot moved this from ⌨️ In Progress to ✔️ Approved by reviewer in FOC Apr 2, 2026
@hugomrdias
hugomrdias merged commit 716e309 into master Apr 2, 2026
16 checks passed
@hugomrdias
hugomrdias deleted the rvagg/extra-capabilities branch April 2, 2026 14:12
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in FOC Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

7 participants