Observe nextMetaId across a multi-event, multi-board matchstick run - #289
Open
thedavidmeister wants to merge 2 commits into
Open
Observe nextMetaId across a multi-event, multi-board matchstick run#289thedavidmeister wants to merge 2 commits into
thedavidmeister wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 52 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
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. Comment |
#282 and #291 landed the id-scoping work this branch was written alongside. Both sides appended a describe block to metaBoard.test.ts; the resolution is the union. The utils.ts and address.ts hunks here were written byte-identically to #282's and reached main with it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Closes #229.
The matchstick suite never ran a second
handleMetaV1_2event against one store, and never loaded aMetaBoardback to look atnextMetaId. So everything the counter does — start at zero, advance by one per meta, persist that advance, and count only the metas of the board it belongs to — was unobserved. Two tests now observe it.What changed
Test-only.
subgraph/src/metaBoard.tsis untouched.subgraph/tests/metaBoard.test.ts:Test MetaBoard nextMetaId counter, two tests, both driving their batch throughhandleNewMetaV1Events— the helpersubgraph/tests/utils.tshas exported since it was written and no test ever called, which is the issue's observation 3.nextMetaId counts one per meta the board has seen: three events on one board, thenMetaBoard.load(...).nextMetaId == 3andentityCount(MetaV1) == 3.Each metaboard counts only its own metas: two events on one board and one on another, thenentityCount(MetaBoard) == 2and each board's own counter,2and1.subgraph/tests/utils.ts,subgraph/tests/address.ts:createNewMetaV1Eventtakes the emitting board instead of hardcodingCONTRACT_ADDRESS, and there is a second board address to hand it. A test cannot reach a two-board store otherwise. These two hunks are byte-identical to Scope the MetaV1 entity id to its metaboard #282's — see below.The
prettier-rainixpre-commit hook collapsed a pre-existing multi-lineimport { MetaV1_2 }in the test file. That is the hook's rewrite, not an edit of mine; the commit does not land without it.How this stacks on #282
#282 (issue #206) changes the
MetaV1id from the bare counter to<board>-<counter>and adds two tests of its own. The overlap, and what I did about it:subgraph/tests/utils.tsandsubgraph/tests/address.ts: I made the same change Scope the MetaV1 entity id to its metaboard #282 makes, byte for byte, comment included. Both branches need the board parameter to reach a two-board store at all, and identical hunks merge without conflict in either direction — whichever lands first, the other rebases through those two files untouched. Deliberate, not accidental convergence.subgraph/tests/metaBoard.test.ts: both PRs append adescribeat the end and both widen the./utilsimport, so those two spots do conflict textually. The resolution is to keep both describes and union the import; the two describes share no name and no constant.MetaV1id hardcoded to"0"survives — is killed here byentityCount(MetaV1) == 3after three events on one board (M4 below), not by an id literal. Scope the MetaV1 entity id to its metaboard #282 kills the same mutant by loading at literal ids. The two are complementary: this one says N metas produced N entities without naming them, Scope the MetaV1 entity id to its metaboard #282 says which names they got.MetaV1claim. On main, two boards' first metas collide on id"0"and the store keeps one — exactly the MetaV1 entity id collides across metaboards: the indexer implied by IDescribedByMetaV1 can lose retrieval-by-hash #206 defect Scope the MetaV1 entity id to its metaboard #282 fixes — so asserting the count main actually produces would write that defect into the suite. Cross-boardMetaV1identity stays Scope the MetaV1 entity id to its metaboard #282's.metaV1.metaBoard) is untouched here.QA
subgraph-testruns matchstick underdocker composeand there is no docker on this machine. I ran the matchstick0.6.0binary-linux-22release directly againstsubgraph/instead — the versionmatchstick-as@0.6.0-beta.2insubgraph/package.jsontargets — afterforge soldeer install && forge build && npm ci && graph codegen. TheMetaBoard Subgraph CIlane on this branch is the authority, and it has since run green on this commit — the docker matchstick reports the sameAll 12 tests passed, the two new tests included. Baseline before the change (direct binary):All 10 tests passed.nextMetaId counts one per meta the board has seenandEach metaboard counts only its own metas. Neither can fail on base, because the behaviour they assert is not a defect — base is correct and unobserved. So each was verified against mutants of the base behaviour instead, below: M1/M2/M3 fail both, M4 fails only the first, M5 fails only the second. Every one of the 10 pre-existing tests stays green under M1–M5, which is the gap the issue filed.subgraph/src/metaBoard.tson this branch; "existing" = the 10 tests already in the file):metaBoard.nextMetaId = metaBoard.nextMetaId.plus(BigInt.fromI32(1))-> line deleted -> 2 failed, 10 passed. Killed by both new tests (entityCount(MetaV1)3 != 1, andnextMetaId0 != 2); every existing test green. The issue's mutant 1.plus(BigInt.fromI32(2))-> 2 failed, 10 passed. Killed by both new tests (nextMetaId6 != 3and4 != 2); every existing test green. The issue's mutant 1.metaBoard.save();-> deleted -> 2 failed, 10 passed. Killed by both new tests; every existing test green. The issue's mutant 1.new MetaV1(metaBoard.nextMetaId.toString())->new MetaV1("0")-> 1 failed, 11 passed. Killed bynextMetaId counts one per meta the board has seenonentityCount(MetaV1)3 != 1— three events, one surviving entity. The issue's mutant 2. The two-board test correctly does not fire: it makes no MetaV1 claim.MetaBoard.load(event.address)->MetaBoard.load(Bytes.fromHexString("0xfb84…6928")), i.e. one global board rather than one per emitting address -> 1 failed, 11 passed. Killed byEach metaboard counts only its own metasonentityCount(MetaBoard)2 != 1. The issue's observation 4. The single-board test correctly does not fire.metaBoard.nextMetaId = BigInt.fromI32(0)->BigInt.fromI32(1)-> 3 failed, 9 passed. Killed by both new tests and by the existingChecks MetaV1 entity data.metaBoard.save();inside theif (!metaBoard)block -> deleted -> 12 passed, SURVIVES. Equivalent mutant: themetaBoard.save()at the end of the handler persists the same entity, so the inner save is unobservable by construction. Recorded as equivalent, not claimed as covered.subgraph/schema.graphql, wherenextMetaId: BigInt!sits onMetaBoardand so counts per board, and the handler's one-event-one-MetaV1contract. The expected values are literals (3,2,1) read off the number of events each test emits, not computed the way the mapping computes them, so a test cannot agree with the mapping by restating it. Nothing here reads back a value the mapping wrote to decide what it should be.nextMetaId's increment and its finalsave()observed, (2) theMetaV1id not collapsible to a constant, (3) the unusedhandleNewMetaV1Eventsbatch helper exercised, (4) the two-board path exercised. Covered: (1) by M1/M2/M3, (2) by M4 viaentityCountrather than an id literal — deliberately, so the assertion survives Scope the MetaV1 entity id to its metaboard #282's id-scheme change — (3) both new tests drive their batch through it, (4) by the second test and M5. The issue's closing line also floats asserting "the secondMetaV1id"; that literal is the one assertion that would pin the id scheme Scope the MetaV1 entity id to its metaboard #282 is changing, so it is left to Scope the MetaV1 entity id to its metaboard #282, which already spells outFIRST_BOARD_SECOND_META_ID. Cross-boardMetaV1identity is likewise out of scope here: on main those ids collide, and asserting the count main produces would write MetaV1 entity id collides across metaboards: the indexer implied by IDescribedByMetaV1 can lose retrieval-by-hash #206's defect into the suite.subgraph/tests/.bin/metaboard.wasmis a tracked matchstick build artifact last written in 2024 and already stale against test changes since. My runs rewrote it; I restored it rather than commit a rebuild, as Scope the MetaV1 entity id to its metaboard #282 did.🤖 Generated with Claude Code