fix: prevent metadata entity ID collisions for repeated CIDs in one transaction - #15
Open
Jay-Gould7 wants to merge 1 commit into
Open
fix: prevent metadata entity ID collisions for repeated CIDs in one transaction#15Jay-Gould7 wants to merge 1 commit into
Jay-Gould7 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prevent IPFS metadata entity ID collisions when multiple events in one transaction reference the same CID.
The existing ID is
transactionHash:cid, while each file data source carries an agent- or feedback-specific context. For example, two registrations for different agents in one transaction can create distinct file data sources that both write an immutableAgentRegistrationFilewith the same ID. This can stop indexing with:The feedback path uses the same ID construction and has the same collision risk. The observed deployment error specifically concerned registration files.
Changes
transactionHash:logIndex:cidinhandleAgentRegistered,handleUriUpdated, andhandleNewFeedback.fileIdthrough the file data source context; both file handlers consume it instead of independently rebuilding an ID.No registry addresses, network configuration, start blocks, reputation features, or analytics logic are changed. Agent and Feedback IDs and the existing data-URI file ID format are unchanged.
Validation
npm run validatepassed.npx --no-install graph codegen deployments/generated/erc-8004-eth-sepolia/subgraph.yamlpassed.npx --no-install graph build deployments/generated/erc-8004-eth-sepolia/subgraph.yamlpassed for all four mappings.git diff --checkpassed.The regression cases cover registrations sharing a CID, repeated URI updates, registration plus URI update in one transaction, shared-CID feedback events, different transactions with the same log index, and both parsers consuming opaque context IDs.
Test limitations
Matchstick 0.6 cannot serialize the production analytics Int8/Timestamp values. These focused tests therefore use an unsupported mock network (chain ID 0), which skips the existing analytics branch without modifying production code. File contexts are supplied explicitly because Matchstick does not schedule IPFS templates. These are handler/parser tests, not PostgreSQL uniqueness, asynchronous file scheduling, or aggregation tests.
The tests reproduce the ID collision mechanism with synthetic events; they do not claim to reconstruct the exact historical transaction that triggered the deployment error.
Sepolia deployment observation
Our Studio deployment based on upstream
909a9d4518432c641e06fdb731b480fb0e9340ddstopped with the duplicate registration-file key error above. Its recorded fatal-error block was10429684.After deploying this fix as a new version and reindexing, the deployment passed that block and reached the chain head. On 2026-09-07, the indexer status API reported:
{ "subgraph": "QmadC5SMGW53ucHqrDSgVLJPaSzDNnTZsFn3TodaUiVTYV", "synced": true, "health": "healthy", "fatalError": null, "latestBlock": "11654483", "chainHeadBlock": "11654483" }Queries for
_meta,agents, andfeedbacksalso succeeded, with_meta.hasIndexingErrors = false.This is evidence from our own deployment. We have not confirmed whether any official Agent0 deployment failure has the same cause.
Compatibility
IPFS
AgentRegistrationFile.idandFeedbackFile.idchange format. Deploy as a new version and reindex; existing indexed IDs are not migrated in place. Consumers that persist or construct file IDs must account for the new format. TheAgent.registrationFileandFeedback.feedbackFilelinks continue to point to their corresponding file entities.