Skip to content

feat: live-node hook integration tests + useAsyncResource staleness guard#38

Open
rtb-12 wants to merge 3 commits into
mainfrom
feat/integration-tests-and-useasyncresource
Open

feat: live-node hook integration tests + useAsyncResource staleness guard#38
rtb-12 wants to merge 3 commits into
mainfrom
feat/integration-tests-and-useasyncresource

Conversation

@rtb-12

@rtb-12 rtb-12 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Brings mero-react under live-node integration testing (the existing suites only mock mero-js) and fixes the recurring stale-data bug class those tests target.

Integration harness + tests (Phase 0/1/4)

  • Render hooks through MeroContext with a real authenticated MeroJs against a booted merod, asserting the live wire — tests/e2e/**, vitest.e2e.config.ts.
  • 22 tests: every read hook (settles with no error + fixture data), create/subgroup mutations, group-metadata round-trip, and a kv-store execute set→get.
  • e2e CI job mirroring mero-js: downloads the latest released merod, boots embedded auth, runs test:e2e with a vacuous-pass guard + log artifacts.
  • Unit run scoped to exclude e2e (vitest.config.ts); bumped mero-js dep 3.0.0 → 6.1.0 (node_modules was stale).

useAsyncResource — kills the stale-data race (Phase 2)

  • One hook owns loading/error/data + a latest-request-wins token + synchronous reset-on-deps. ~14 read hooks migrated to it.
  • useGroupCapabilities keeps an inline guard (read+write hybrid); useMemberMetadata (already abort-signal-guarded) and useContextDiscovery (imperative poll) left as-is.
  • Deterministic race test (single-object + mapped-list variants): red against the old hooks, green after.
  • hooks/index.ts: 1952 → 1540 LOC.

What surfaced

The group-metadata round-trip is skipped, referencing an upstream mero-js getGroupMetadata over-unwrap (returns the bare data map, not the MetadataRecord) — fixed in calimero-network/mero-js#65. Re-enable here after that publishes + a dep bump.

Verification

typecheck · lint · unit (101, incl. race test) · e2e (21 + 1 skip vs a live merod 0.11.0-rc.8) · build — all green locally.

🤖 Generated with Claude Code

…uard

Stand up real-node integration tests for the hooks (the prior suites only
mocked mero-js) and fix the recurring stale-data bug class they target.

Integration harness + tests
- boot a real merod, render hooks through MeroContext with an authenticated
  MeroJs, assert against the live wire (vitest.e2e.config.ts + tests/e2e/**)
- 22 tests across read hooks, mutations, and execute round-trips
- e2e CI job mirroring mero-js (released merod + vacuous-pass guard + logs)
- unit run scoped to exclude e2e (vitest.config.ts)
- bump mero-js dep to 6.1.0 (node_modules was stale at 3.0.0)

useAsyncResource (kills the stale-data race)
- one hook owning loading/error/data + a latest-request-wins token +
  synchronous reset-on-deps; ~14 read hooks migrated to it
- useGroupCapabilities keeps an inline guard (read+write hybrid);
  useMemberMetadata (abort-signal guarded) and useContextDiscovery
  (imperative) left as-is
- deterministic race test (single-object + mapped-list) proves the fix
- hooks/index.ts 1952 -> 1540 LOC

The group-metadata round-trip is skipped pending the mero-js getGroupMetadata
over-unwrap fix; re-enable after that publishes + a dep bump.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cursor

cursor Bot commented Jun 27, 2026

Copy link
Copy Markdown

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

@meroreviewer meroreviewer 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.

🤖 AI Code Reviewer

Reviewed by 3 agents | Quality score: 69% | Review time: 171.1s

🟡 4 warnings, 💡 1 suggestions. See inline comments.


🤖 Generated by AI Code Reviewer | Review ID: review-8706b8cf

Comment thread tests/e2e/hooks.read.test.tsx
Comment thread src/hooks/index.ts
Comment thread tests/e2e/harness.ts
Comment thread src/hooks/index.ts
Comment thread .github/workflows/ci.yml
@meroreviewer

meroreviewer Bot commented Jun 27, 2026

Copy link
Copy Markdown

Documentation Review

The following documentation may need updates based on the changes in this PR:

  • 🟡 docs/: Static HTML docs in docs/ may need updating — architecture-impacting changes detected. On merge, update-docs will scan this directory and open a PR if any pages need to change.

Drop the `as any` casts in hooks.read.test.tsx so a hook field rename can't
pass vacuously — settle()'s generic already infers each hook's real return
type. Wire tests/** into `pnpm typecheck` (tsconfig.typecheck.json, no
rootDir/emit) so this is enforced in CI; add @types/node for the harness.

Typing immediately caught a latent harness bug: createNamespace was passed
`alias` (not a CreateNamespaceRequest field — core silently dropped it);
corrected to `name`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@meroreviewer meroreviewer 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.

🤖 AI Code Reviewer

Reviewed by 3 agents | Quality score: 42% | Review time: 191.0s

🟡 10 warnings, 💡 2 suggestions. See inline comments.


🤖 Generated by AI Code Reviewer | Review ID: review-39c1ebf3

Comment thread tests/e2e/hooks.write.test.tsx Outdated
Comment thread tests/e2e/render.tsx
Comment thread tests/e2e/hooks.write.test.tsx
Comment thread src/hooks/index.ts
Comment thread src/hooks/index.ts
Comment thread src/hooks/index.ts
Comment thread tests/e2e/harness.ts
Comment thread src/hooks/index.ts
Comment thread tests/e2e/render.tsx
Comment thread .github/workflows/ci.yml
…ment

- type the createGroupInNamespace mutation result (no `any`)
- render.tsx: nodeUrl is unused by hooks, set null instead of reaching into
  MeroJs private internals via a double cast
- correct the useAsyncResource ref comment: initialRef is captured once
  (constant per hook), only fetcherRef is refreshed

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@meroreviewer meroreviewer 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.

🤖 AI Code Reviewer

Reviewed by 3 agents | Quality score: 64% | Review time: 173.4s

🟡 5 warnings, 💡 3 suggestions. See inline comments.


🤖 Generated by AI Code Reviewer | Review ID: review-1ac9b26d

Comment thread tests/e2e/harness.ts
Comment thread src/hooks/index.ts
Comment thread tests/e2e/harness.ts
Comment thread tests/e2e/harness.ts
Comment thread src/hooks/index.ts
Comment thread tests/e2e/harness.ts
Comment thread .github/workflows/ci.yml
Comment thread tests/e2e/harness.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant