Repository navigation
fix(contract): keep recorded evidence apart from current metadata - #13
Merged
Merged
Conversation
tests/registry.test.cjs had no script and nothing ran it. Add `npm test` (the Node test runner over tests/**/*.test.cjs) and a GitHub Actions workflow that runs npm ci, lint, build and test on Node 24 for pull requests and pushes to main. AGENTS.md lists `npm test` with the other checks. `node --test tests/` fails on Node 24 (the directory is loaded as a module), so the script passes an explicit glob. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Evidence tab and the source tree took the repository, commit and contract path from the contract's current NEP-330 metadata, so after a redeploy they showed the new build next to the old verification. The registry records only the snapshot (cid), code hash and block, so the recorded repository now comes from the record's github field or from the git checkout stored in the recorded snapshot. The current metadata stays on the Build tab, labelled as current, and picks the tree folder only when it names the same repository and commit; otherwise the folder is offered as a labelled choice. NEP-330 metadata is parsed once into a typed shape. Fields with the wrong type are flagged instead of rendered, duplicate standards are collapsed, and each workspace pane has an error boundary. A metadata read that fails (RPC failure or a panic in the method) is unknown with a retry and is never cached. Only MethodNotFound, missing code or a missing account count as "no metadata". Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The classifier searched the whole error text for MethodNotFound and CodeDoesNotExist, so a panic whose message mentioned either became a cacheable "doesn't expose contract_source_metadata". Structured errors are now classified by their cause name, and a contract execution error by the top-level FunctionCallError variant in vm_error (or after the legacy message prefix), matched as a whole. Legacy messages are matched whole, never as fragments. Anything else is a failed call: unknown, with a retry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d crate Review of #13 found that the same repository and commit don't identify the crate: one commit can hold several, and the registry records none. The source tree now opens the folder from the contract's current metadata only under a "current metadata" label, even when the commit matches, and Evidence no longer links an entry file. - The folder choice depends only on the current metadata, the ?file= link and the reader's choice. A link opens its own folder without waiting for the metadata, and a linked file that the listing doesn't show is opened directly; failing that, the tree says it couldn't open it rather than that it is absent. - The snapshot's git checkout is read only for the Evidence and Build tabs, with a 10 s timeout, and parsed strictly: one exact [remote "origin"] with one plain GitHub repository URL and a detached HEAD, else "Not recorded" with the reason. - A folder listing that isn't a listing is unreadable (unknown, retried), not an empty folder; failed and partial listings are never cached. Each folder is listed once and shared, and .git is never listed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Re-check of #13 at 5c66f38: - A checkout read that timed out left its unanswered root listing in the shared cache, so Try again waited on the same request. A listing that hasn't answered when the read times out is now dropped, and a failed request only removes its own cache entry. - A listing entry with a name but no valid UnixFS type (for example {"Name":".git","Hash":"unused"}) was skipped, so the folder looked like it had no git checkout and that absence was cached. Every entry must now be a complete link (string name, integer type 0-5, or the older name/type/path shape, with no lone surrogates); otherwise the reply is unreadable: unknown, with a retry. - Remove githubEntryPath, unused since the Evidence entry-file link went. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hen unknown Re-check of #13 at 5c66f38: - Picking a file in the tree updates ?file=, which was then read as a deep link and moved the tree into that file's folder. Only the ?file= the workspace was opened with may choose the folder now, and only when the default folder wouldn't list it, so a pick (or a reload with it) never moves the tree. From a linked file's folder, "Show snapshot root" is always offered. - With the metadata read failed and nothing listable at the root, the tree said "No .rs or .toml files at the snapshot root". It now says the source folder is unknown until the metadata can be read, with a retry. - A contract_path with a lone surrogate passed validation and made the GitHub folder link throw, replacing the Build pane with its error. Such a path is now not a folder (flagged and unused), and the link builder returns no link rather than throw. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Final re-check of #13 at 54b701f: the workspace is keyed by account, so the ?file= link it was opened with survived a network switch for the same account. A Mainnet link with ?file=contracts/ft/src/lib.rs, then Check Testnet, still rooted the Testnet tree at contracts/ft/. The opened-with link and the folder choice now belong to one record view (network + account): the same view keeps them while the reader picks files, and a switch starts fresh from the address it lands on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch was successfully deployed
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.
Why
QA of
mainat c63cdc6 found four problems on the contract page. Each one breaks the AGENTS.md rule that a recorded verification stays distinct from what is deployed now, and that a failed read shows as unknown.contract_pathfrom the contract's NEP-330 metadata read at the latest final block. That metadata describes the code deployed now. The registry record (set_contractin verifier-back) stores onlycid,code_hash,block_heightandlang. None of the 276 live records on either network has agithubfield, and no record names the crate that was built. So after a redeploy, "How this verdict was reached" named the new commit, and the source tree opened the new build's folder as if it were the verified one. Of the 117 records whose snapshot keeps a git checkout and whose contract still publishes metadata, 22 now name a different commit. For example, intents.near was verified fromnear/intents@a2dd140, but the Evidence tab showed@16d04f6.main,{"version":{},"standards":[null]}produces Next's "Application error" page withTypeError: Cannot read properties of null (reading 'standard').unavailablewas mapped to "doesn't expose contract_source_metadata" and cached for 60 s. That includes a panic inside the method. A failed read also fell back torootPath='/', so the tree could state facts about the wrong folder and ignore a?file=link.testscript and no CI.Change
Recorded evidence comes only from the record (fixes 1).
github(validated), or else from the git checkout stored in the recorded snapshot. The backend clones and checks out the verified commit before adding the folder to IPFS, so the checkout is part of the content-addressed record, not live data..git/HEAD(40 lowercase hex) and exactly one[remote "origin"]with exactly one plainurl, and that URL must name a GitHub repository (https://github.com/o/r,[email protected]:o/r,ssh://[email protected]/o/r, optional.git). Anything else gives Not recorded, with the reason; nothing is guessed. That includes:Origin, a second origin or a second url;[url …]rewrites, includes, or the old[remote.origin]syntax;/o/r/tree/main.contracts/defuse/, the folder named in the contract's current metadata. The verification record doesn't name the crate that was built, so this may not be the verified crate." This applies even when the commit matches. "Show snapshot root" switches to the root, and from there "Open contracts/defuse/" returns.Records with no
githubfield. That is every current record, so this decides what every page shows:Rejected alternatives:
UNKNOWN_BLOCK, and the provider is out of scope.Typed NEP-330 metadata and an error boundary (fixes 2).
utils/contractMetadata.tsparses the metadata once. Fields with the wrong type are dropped and flagged ("Published with the wrong type; not shown"), standards are de-duplicated so React keys stay unique,build_commandmust be all strings, andcontract_pathmust be a plain relative path.PaneBoundarywraps each workspace pane, so a render error shows "Couldn't display …" with a retry while the verdict, header and tabs stay.Unknown reads stay unknown (fixes 3).
utils/near/view.tsclassifies a structured error by its cause name. A contract execution error is classified by the top-level FunctionCallError variant invm_error(or after the legacy message prefix), matched whole:MethodResolveError(MethodNotFound)meansmethod_not_found,CompilationError(CodeDoesNotExist { … })means no code. Legacy messages are matched whole, never as fragments, so aGuestPanicwhose message mentionsMethodNotFoundis a failed call.unknown: it gets "Try again" and is never cached.?file=link the workspace was opened with, and the reader's choice.?file=but never moves the tree.{ structure: [...] }(or a bare array) whose every entry is a complete link: a string name and an integer UnixFS type 0–5, or the older name/type/path shape, with no lone surrogates. An unreadable reply means unknown with a retry, never an empty folder, so a malformed.gitentry can't become "no git checkout". Failed and partial listings (a sub-folder couldn't be read) are never cached; a partial listing says so, with a retry.contract_paththat isn't text (a lone surrogate) is flagged and not used, and the Build tab's GitHub folder link returns no link rather than throwing.Fewer requests; nothing waits on the checkout read.
.gitis never listed. A failed request removes only its own cache entry.Tests and CI (fixes 4).
npm test..github/workflows/ci.yml: pull requests and pushes tomain, Node 24.x,actions/checkout@v4andactions/setup-node@v4in the verifier-back style, runningnpm ci, lint, build and test withcontents: read.npm test.node --test "tests/**/*.test.cjs".node --test tests/fails on Node 24.22.3 (Cannot find module …/tests) because Node loads the directory as a module.tests/metadata.test.cjs: parsing (including lone-surrogate paths), load states, error classification including panics that mentionMethodNotFound, caching.tests/evidence.test.cjs: snapshot and checkout parsing including the ambiguous cases, the same-source rule, folder choice, links and in-tree picks, the unknown-folder state.tests/sourceFiles.test.cjs: malformed vs empty listings and malformed entries, no caching of failures, the timeout and an expired stalled root listing, the shared root listing, never listing.git, partial listings.@/imports.Production notes.
enginesor env changes.Review fixes
Round 1 (review of
1a29685):?file=link with metadata unavailable. The link opens its own folder and its file; there is no empty-state claim..gitis never listed.Round 2 (re-check of
5c66f38):contract_pathbroke the Build pane. The path is rejected, and the link builder is guarded.githubEntryPathwas unused. It is removed.Before pushing round 2, I checked my diff against
mainfor other navigation and caching regressions. That found one more: a link's own folder had no way back to the snapshot root, whilemainalways showed the root there. Fixed: "Show snapshot root" is offered there. I missed one: the opened-with link survived a network switch for the same account (round 3).Round 3 (final re-check of
54b701f):?file=contracts/ft/src/lib.rslink followed by "Check Testnet" still rooted the Testnet tree atcontracts/ft/, showing an empty state. The opened-with link and the folder choice are now keyed by network + account, so a switch starts fresh, as at5c66f38. The other record state was already keyed by network: the record, metadata and code-check hooks by network + account, the panes bynetwork:cid:tab, and the recorded-source read bynetwork:cid.Validation
All in the OrbStack VM
ss-front-evidence-1128(Ubuntu 24.04, Node 24.22.3, npm 11.19.1; disk 73 GB free, host load about 3–4), on a fresh tree fromgit archiveof the pushed HEADc55dd7a:npm ci,npm run lint(no warnings),npm run buildandnpm testall pass: 44 tests, the 13 existing plus 31 new.main: lint, build and the 13 tests pass with an explicit glob;node --test tests/fails.Browser checks:
next startwithNEXT_PUBLIC_API_HOST=https://api.sourcescan.dev, headless Chromium (Playwright 1.65.1, VM only), live public dRPC and IPFS reads. 142/142 checks pass atc55dd7a, in one full run. In round 2 one check had failed: a test artifact where the script clicked the file that was already open, which is a no-op by design. The script now picks another file. On each network, Mainnet and Testnet:contracts/near/eth-prover/near/omni-bridge): the Evidence repository is unchanged with no entry-file link, Build says same commit, and the tree folder is labelled as current metadata..git, and "Open …/" returns;a2dd140892b6,9783ca494c2c), not the live one, and Build says it differs;.git(pyth-oracle.near, repro-fct-67.testnet): Evidence says "Not recorded … the snapshot has no git checkout", and the tree folder is labelled./code/<account>: the workspace renders and stays on/code/./code/<account>?file=<crate>/src/lib.rswithcontract_source_metadatablocked: the file opens; there is no "No .rs or .toml files" claim, and the folder-unknown notice shows.view_codeandcontract_source_metadatablocked: the verdict is "Deployed code status unknown", the folder is unknown with a retry, Build is unknown with "Try again", and the retry loads the metadata..git/HEADheld unanswered: source browsing (with a?file=link) isn't blocked; Evidence shows "Reading the snapshot…", then after the timeout "Unknown: the snapshot couldn't be read" with "Try again", and the retry reads it.structurereplied with HTTP 200{"status":"temporarily unavailable"}: Evidence shows unknown with "Try again", not "Not recorded"; it isn't cached, and the retry reads it.?file=keeps it too.{"Name":".git","Hash":"unused"}: unknown with retry, not "no git checkout"; the retry reads it.contract_pathof"contracts/\ud800": Build renders with the path flagged, and no pane error.0us40y…, Testnet record only):?network=mainnet&file=contracts/ft/src/lib.rsshows no Mainnet record. "Check Testnet" opens the Testnet record with the file link dropped, and the tree starts fresh at the metadata folder (contract/, 3 files) instead ofcontracts/ft/.9873182a…, Mainnet record only): the same flow; the tree starts at the snapshot root (7 files).54b701f, the same two cases fail (the tree is rooted atcontracts/ft/with 0 files), so the check catches the regression.Once, on Mainnet:
contract_source_metadataall show as unknown with a working retry, not "doesn't expose". Cases: a generic panic, a legacyGuestPanicwhose message says "Unexpected MethodNotFound from lookup", and the same panic as a structuredCONTRACT_EXECUTION_ERROR.MethodResolveError(MethodNotFound)shows as "doesn't expose".IPFS proxy requests per visit, counted in the browser at
c55dd7a(origin/mainmeasured the same way in the same VM):main.git/HEAD,.git/config; once per snapshot)mainmakes no Evidence requests because it shows the live metadata's repository there. At1a29685the review measured 6 and 16 for the same Source visits.Against
origin/main, the same script reproduces the review's link and panic cases. The?file=link with metadata unavailable doesn't open, and the "no .rs or .toml files" claim appears. A generic panic shows "doesn't expose".The new CI workflow passed on this PR at
1a29685(run 46156984291), at5c66f38(run 46160699103) at54b701f(run 46162181525) and atc55dd7a(run 46162975573): install, lint, build, test. GitHub annotatesactions/checkout@v4andactions/setup-node@v4as targeting the deprecated Node 20 runtime. They are kept at@v4to match verifier-back; moving both repos to newer majors is a separate change.Follow-ups, not in this PR:
.gitin snapshots on purpose, so older records can name their repository and the crate can be shown as verified./api/proxy-ipfsturns upstream 404s into 500s.🤖 Generated with Claude Code