Add reputation functions + fork tests (Steps 3-5)#3
Conversation
- 9 reputation functions: giveFeedback, revokeFeedback, appendResponse, getSummary, getClients, readAllFeedback, readFeedback, getLastIndex, getResponseCount - readAllFeedback transforms contract's parallel arrays into structured FeedbackEntry[] objects - Fork test infrastructure: prool-managed Anvil instances forking Base Sepolia, adapted from x402r-sdk patterns - 8 identity fork tests + 9 reputation fork tests (full lifecycle) - 15 reputation unit tests + shared mock helpers extracted - CI: add foundry-toolchain for Anvil binary in fork test job - Scripts: scope test/test:cov to --project unit, add test:fork Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
SDK ReviewFound 7 issues (reviewed: tests, conventions, dead code, CI/coverage, SDK design): 1. [CI/Coverage] Coverage config nested inside project — may be silently ignored by vitest
Lines 9 to 16 in 3d2946c Fix: Move defineConfig({
test: {
coverage: {
provider: 'v8',
reporter: [process.env.CI ? 'lcov' : 'text', 'json', 'html'],
include: ['src/**/*.ts'],
exclude: ['src/**/index.ts', 'src/**/types.ts', 'src/abis/**'],
},
projects: [ ... ],
},
})2. [CI/Coverage] Coverage include/exclude doesn't match codecov ignore — ABI files inflate local numbers vitest Fix: Add 3. [Dead Code] The fork test CI step sets erc8004/.github/workflows/ci.yml Lines 58 to 60 in 3d2946c Fix: Remove 4. [CI] tsup builds 4 entrypoints ( Fix: Add 5. [Tests] Reputation unit tests use identity registry address
Fix: Add 6. [Tests] This is the most transformation-heavy function (7 parallel arrays → structured objects) with a boolean filter. Both unit test cases use Fix: Add a test with 7. [Tests] Fork test The fork test for Fix: Assert all fields of Generated with Claude Code using review-sdk skill |
- Move coverage config to root level (was silently ignored inside project) - Add src/abis/** to coverage exclude (matches codecov.yml ignore) - Remove dead TEST_PRIVATE_KEY from CI (Anvil uses deterministic keys) - Add missing dist/identity/index.js to size-limit - Use REPUTATION_REGISTRY constant in reputation tests (was using identity address) - Add includeRevoked: true test case for readAllFeedback - Assert all 7 fields in fork test readAllFeedback (ABI verification layer) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
All 7 issues addressed in All valid — no pushback needed this time.
Tests: 38 unit + 17 fork, all passing. Build/typecheck/biome/knip/size-limit clean. |
SDK ReviewFound 10 issues (reviewed: tests, conventions, dead code, SDK design): Tests1. [Tests] Both write-function fork tests verify
Fix: After each write, read back the stored data and assert field values. For 2. [Tests] The lifecycle runs with exactly 1 feedback + 1 response, so both should return exactly erc8004/tests/fork/reputation.fork.test.ts Lines 64 to 70 in 7399134 erc8004/tests/fork/reputation.fork.test.ts Lines 140 to 154 in 7399134 Fix: 3. [Tests] Fork tests call erc8004/tests/fork/reputation.fork.test.ts Lines 102 to 121 in 7399134 Fix: After revocation, call Conventions4. [Conventions] The unit test defines erc8004/tests/reputation.test.ts Lines 4 to 5 in 7399134 Fix: 5. [Conventions] Unnecessary spread of
Fix: Pass arrays directly without spreading. Dead Code6. [Dead Code] Only erc8004/tests/setup/constants.ts Lines 24 to 29 in 7399134 7. [Dead Code] After switching to erc8004/tests/setup/constants.ts Lines 7 to 29 in 7399134 Fix: Simplify to 8. [Dead Code]
erc8004/tests/setup/constants.ts Lines 35 to 37 in 7399134 Fix: SDK Design9. [SDK Design] Missing All functions have Fix: Add 10. [SDK Design] The erc8004/src/reputation/readAllFeedback.ts Lines 28 to 51 in 7399134 Fix: Add a length invariant check before the What passes cleanly:
Generated with Claude Code using review-sdk skill |
- Use exact values (toBe(1n)) instead of lower bounds in fork tests - Add post-revocation readAllFeedback tests (includeRevoked false/true) - Replace manual ZERO_HASH with viem's zeroHash - Remove unnecessary spread of readonly arrays (viem accepts them) - Remove unused accounts[2] and dead VITEST_SHARD_ID multiplier Pushed back on: - #1: write tests already verified by subsequent read tests in lifecycle - #7: privateKey removal — forward-compatible, bigger refactor for no benefit - #9: ReturnType aliases — types already well-named, would be boilerplate - #10: array length validation — contract invariant, not our concern Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Addressed in Accepted:
Pushed back:
Tests: 38 unit + 19 fork, all passing. |
SDK Review (Round 3)Found 10 new issues (reviewed: tests, conventions, dead code, SDK design): Dead Code1. [Dead Code]
Line 26 in 413db4f 2. [Dead Code]
Line 37 in 413db4f SDK Design3. [SDK Design] The fork test passes erc8004/src/reputation/types.ts Lines 6 to 16 in 413db4f Fix: Make these 4. [SDK Design] The doc says "Typically called by the agent owner" -- the word "typically" hides that the contract enforces this with a revert. Callers have no SDK-level signal this will fail if they're not the owner. erc8004/src/reputation/appendResponse.ts Lines 7 to 9 in 413db4f Fix: Change to "Reverts if 5. [SDK Design] Every caller must write erc8004/src/reputation/types.ts Line 62 in 413db4f Fix: Conventions6. [Conventions] Fork tests manually lowercase addresses for comparison while the identity fork tests in the same PR use plain erc8004/tests/fork/reputation.fork.test.ts Lines 59 to 61 in 413db4f erc8004/tests/fork/reputation.fork.test.ts Lines 112 to 114 in 413db4f Fix: 7. [Conventions]
erc8004/src/reputation/readAllFeedback.ts Line 14 in 413db4f Fix: Tests8. [Tests] The erc8004/tests/reputation.test.ts Lines 175 to 225 in 413db4f Fix: Add matching 9. [Tests] No negative test for unauthorized The fork suite only tests the happy path (feedback giver revokes their own feedback). No test verifies that a non-author calling erc8004/tests/fork/reputation.fork.test.ts Lines 156 to 175 in 413db4f Fix: Add a one-liner test that 10. [Tests] Feedback was submitted with erc8004/tests/fork/reputation.fork.test.ts Lines 90 to 100 in 413db4f Fix: Add Generated with Claude Code using review-sdk skill |
- Make endpoint/feedbackURI/feedbackHash optional in GiveFeedbackParameters (default to ''/''/ zeroHash — common case) - Make includeRevoked optional (default false) - Return readonly FeedbackEntry[] from readAllFeedback - Fix appendResponse JSDoc: document revert on non-owner - Use isAddressEqual instead of toLowerCase in fork tests - Add summaryValueDecimals assertion to getSummary fork test - Add includeRevoked: false flag assertion to unit test Pushed back on: - #1: getTestClient() — test infra pattern from x402r-sdk, useful for future - #2: forkBlockNumber — optional param on factory, not dead code - #9: unauthorized revoke test — contract doesn't revert (no-op or allows agent owner), assumption was wrong Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Addressed in Accepted:
Pushed back:
#9 — Wrong assumption: Attempted the unauthorized revoke test — the contract does NOT revert when a non-author calls Tests: 38 unit + 19 fork, all passing. |
Nitpicks (non-blocking)Code looks good — consistent with the identity module, all conventions followed. A few minor things for consideration: 1. Fork
2. No
3. Fork test Both fork suites set 4.
Generated with Claude Code using review-sdk skill |
## Summary - Add `pollingInterval: 100` to fork public client — Anvil mines instantly, default 4s polling wastes time per `waitForTransactionReceipt` - Warn when `FORK_URL` not set and falling back to public RPC (rate-limited, flaky) From post-merge nitpick review on PR #3. ## Test plan - [x] `pnpm test` — 38 unit tests pass - [x] `pnpm check` — biome clean 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
FeedbackEntry[]objects--project unit/--project fork)Test plan
pnpm test— 37 unit tests pass (22 identity + 15 reputation)pnpm test:fork— 17 fork tests pass against Anvil fork of Base Sepoliapnpm build && pnpm typecheck— compiles cleanpnpm check— biome lint/format cleanpnpm knip— no unused exportspnpm size-limit— all entries within limits🤖 Generated with Claude Code