Skip to content

test(fork): add FORK_VAULT_COUNT enumeration to lock vault table length - #209

Open
thedavidmeister wants to merge 6 commits into
mainfrom
2026-06-20-issue-139-fork-vault-enumeration
Open

test(fork): add FORK_VAULT_COUNT enumeration to lock vault table length#209
thedavidmeister wants to merge 6 commits into
mainfrom
2026-06-20-issue-139-fork-vault-enumeration

Conversation

@thedavidmeister

@thedavidmeister thedavidmeister commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds FORK_VAULT_COUNT = 15 constant to test/lib/LibFork.sol — the canonical count of WT_* vault address constants.
  • Adds testForkVaultEnumeration() which builds a fixed-size address[FORK_VAULT_COUNT] table of all 15 vaults and runs checkVault over each.
  • Because Solidity fixed-size array literals must have exactly FORK_VAULT_COUNT entries, adding a new WT_* address without bumping the constant (and adding it to the table) causes a compile error — a new address cannot ship without a corresponding test entry.

Refs #139.

Why this is needed

After PR #184 merged, expected values are now derived from the vault oracle rather than hand-typed. But the vault address list itself remains unchecked: adding a WT_* constant without a test lets the address ship untested, silently. FORK_VAULT_COUNT enforces structural completeness at compile time.

Test plan

  • forge build succeeds (fixed-size array initializer count matches FORK_VAULT_COUNT)
  • Fork CI (FORK_RPC_URL_BASE set): testForkVaultEnumeration passes for all 15 vaults
  • Temporarily change FORK_VAULT_COUNT to 16: forge build fails (compile error on array initializer length)

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

Summary by CodeRabbit

  • Tests
    • Expanded coverage for vault registry enumeration.
    • Added checks confirming the registry is populated, contains valid addresses, and has no duplicates.
    • Updated fork-based tests to derive coverage and labels directly from the registered vault set, helping ensure consistent validation as the registry changes.

@thedavidmeister thedavidmeister self-assigned this Jun 20, 2026
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 81a4df9b-59a5-4b00-9b58-df1bbc513523

📥 Commits

Reviewing files that changed from the base of the PR and between f85d1a4 and 089b4ba.

📒 Files selected for processing (3)
  • test/lib/LibFork.sol
  • test/lib/LibFork.t.sol
  • test/src/concrete/ERC4626Words.fork.t.sol

Walkthrough

Replaces the exported WT_* vault constants with direct entries in the allForkVaults() registry. Updates registry documentation and adds tests for non-empty, nonzero, duplicate-free enumeration.

Changes

Fork vault registry

Layer / File(s) Summary
Canonical vault registry and enumeration documentation
test/lib/LibFork.sol, test/src/concrete/ERC4626Words.fork.t.sol
allForkVaults() now stores the 15 existing vault addresses directly. The fork test documentation describes registry-based enumeration and address-derived labels.
Registry validation
test/lib/LibFork.t.sol
Adds LibForkTest.testAllForkVaultsEnumeration(). The test checks that the registry is non-empty, contains no zero addresses, and contains no duplicates.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • rainlanguage/rain.erc4626.words#247: Extends the allForkVaults() registry pattern by hardcoding vault entries, removing the old constants, and adding registry validation tests.

Suggested reviewers: siddharth2207

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title says the PR adds FORK_VAULT_COUNT, but the changes remove the count and use allForkVaults() as the single source of vault addresses. Rename the title to describe the single-source allForkVaults() registry and its enumeration validation without mentioning FORK_VAULT_COUNT.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-06-20-issue-139-fork-vault-enumeration

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/lib/LibFork.sol`:
- Line 25: The FORK_VAULT_COUNT constant at line 25 is a manual source of truth
that can drift from the actual number of WT_* vault constants defined above it.
Instead of maintaining separate WT_* constants and a manual count, consolidate
all vault definitions into a single canonical registry (such as an array or
mapping) that contains all the WT_* vault identifiers, and then derive
FORK_VAULT_COUNT mechanically from the length or size of this registry. This
ensures the count is always in sync with the actual number of vaults defined and
cannot accidentally drift out of sync.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 670937f4-6488-4ba1-8e0a-c778436ab244

📥 Commits

Reviewing files that changed from the base of the PR and between dec96d6 and f85d1a4.

📒 Files selected for processing (2)
  • test/lib/LibFork.sol
  • test/src/concrete/ERC4626Words.fork.t.sol

Comment thread test/lib/LibFork.sol Outdated
…fork-vault-enumeration

# Conflicts:
#	test/lib/LibFork.sol
#	test/src/concrete/ERC4626Words.fork.t.sol
@thedavidmeister

Copy link
Copy Markdown
Contributor Author

Rework note (human reject, 2026-07-04): the enumeration lock is circular — adding a WT_* constant to LibFork without bumping FORK_VAULT_COUNT compiles and passes with the new vault unchecked (the fixed-size array only pins THIS test's own hand-list against THIS PR's own count, both hand-maintained), and the test adds a third and fourth hand-synced copy of the vault list (addresses + labels) — worsening exactly the multiple-sources hazard #139 flags — while duplicating the existing allForkVaults() loop at double fork cost. Wanted direction: allForkVaults() as the SINGLE source (tests never import per-vault constants; count = .length; labels via vm.toString as the existing loop already does). The issue's remaining legs (hand-pinned 1:1 expected rates, fork-block pin) need issue refinement or a design ruling, not a mechanical test PR — do not re-attempt #139 with list-copy tests.

@thedavidmeister thedavidmeister added the human:needs-work Human reviewer: needs rework label Jul 6, 2026
thedavidmeister and others added 2 commits July 6, 2026 13:15
… source (rework)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@thedavidmeister

Copy link
Copy Markdown
Contributor Author

🤖 ai:producer
Producer note: reworked per the rework note — the enumeration is now genuinely single-source.

  • Removed the hand-synced copies the PR had added: FORK_VAULT_COUNT, the per-vault WT_* imports, and testForkVaultEnumeration's parallel address + label tables (which also duplicated the existing allForkVaults() loop at double fork cost).
  • allForkVaults() is now literally the single source: the WT_* constants had no consumer other than the registry itself, so their addresses were inlined into allForkVaults(). A vault address can now only exist in the one list that every consuming loop iterates — adding a vault is one edit and it is automatically fork-tested. Count is .length, labels come from vm.toString in the existing testAllForkVaults loop (unchanged).
  • Added test/lib/LibFork.t.sol with testAllForkVaultsEnumeration: asserts the registry is non-empty with no zero and no duplicate addresses. This is a real single-source lock without hand-copies, and it runs on every CI pass (no fork needed).
  • Verified locally: full forge build clean, new enumeration test passes. The fork loop itself rides on fork CI as before.
  • Per the note, 15 vault addresses + a pinned fork block + hand-computed expected outputs are three independent sources of truth with no enforced agreement #139's remaining legs (hand-pinned expected rates, fork-block pin policy) are left for issue refinement / a design ruling, not this mechanical test PR.

Branch also carries the previously-unpushed merge of origin/main (conflict resolution), now pushed.

@thedavidmeister thedavidmeister added ai:relink AI vetter: sound code, needs Closes→Refs linkage fix and removed human:needs-work Human reviewer: needs rework labels Jul 19, 2026
@thedavidmeister

Copy link
Copy Markdown
Contributor Author

🤖 ai:vetter
Reviewed 2d25832: relink — refs #139 — single-source allForkVaults registry + enumeration sanity test is sound and exactly the human-directed shape, but the human rework note keeps #139's remaining legs (hand-pinned expected rates, fork-block pin policy) open for issue refinement/design ruling, so Closes #139 must become Refs #139 before merge
cost 180 — single-source registry, linkage fix

@thedavidmeister thedavidmeister added ai:needs-work Needs rework — the producer's inbox (vetter verdict or human ruling) and removed ai:relink AI vetter: sound code, needs Closes→Refs linkage fix labels Jul 31, 2026
@thedavidmeister

Copy link
Copy Markdown
Contributor Author

🤖 ai:producer
Linkage repair: weakened Closes #139 to Refs #139 in the PR body via pr-review-report weaken-closes. Every byte outside that keyword is unchanged, and the ## QA section was not touched.

thedavidmeister and others added 2 commits August 12, 2026 16:38
The needs-work work order on 2d25832 was a PR-body linkage defect only
(Closes #139 -> Refs #139), which moves no commit. Un-vetting is keyed
off a head move, so this empty commit re-arms the vetter.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:needs-work Needs rework — the producer's inbox (vetter verdict or human ruling)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants