Skip to content

[codex] Archive NLnet proposal reference and harden Coop sync#19

Merged
Oba-One merged 2 commits into
mainfrom
codex/code-root-cleanup-coop
Jun 19, 2026
Merged

[codex] Archive NLnet proposal reference and harden Coop sync#19
Oba-One merged 2 commits into
mainfrom
codex/code-root-cleanup-coop

Conversation

@Oba-One

@Oba-One Oba-One commented Jun 18, 2026

Copy link
Copy Markdown
Member

Summary

  • Move the NLnet Fediversity Coop proposal into docs/reference and index it.
  • Align the Coop docs React runtime pin with the lockfile.
  • Harden invite handoff startup with a wake message, bounded retries, and failure coverage.
  • Reject invalid remote Coop sync updates without persisting corrupted Y.Doc state.

Validation

  • GitHub CI passed before the CodeRabbit review fixes: Quick Validation, Unit Coverage, Build, and Core Loop E2E.
  • Latest push includes CodeRabbit-requested rejection semantics and exhausted retry test; CI is rerunning on the updated commit.
  • Local Bun test execution is blocked in this sandbox by tempdir permission errors, so GitHub Actions is the proof gate.

@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
coop Ready Ready Preview, Comment Jun 19, 2026 6:42am
coop-docs Error Error Jun 19, 2026 6:42am

Request Review

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Oba-One, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 7 minutes and 5 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 311983cb-a745-42c8-baef-5aab458ab1c3

📥 Commits

Reviewing files that changed from the base of the PR and between 666c081 and 35f37de.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • docs/package.json
  • packages/extension/src/background/handler-registry.ts
  • packages/extension/src/background/handlers/__tests__/coop-handlers.test.ts
  • packages/extension/src/background/handlers/coop.ts
  • packages/shared/src/modules/coop/__tests__/sync-collections.test.ts
  • packages/shared/src/modules/storage/__tests__/db-crud-content-sync.test.ts
  • packages/shared/src/modules/storage/db-crud-content.ts
  • packages/shared/src/modules/sync-core/doc.ts
📝 Walkthrough

Walkthrough

Two independent functional areas are changed. The CRDT merge function mergeCoopStateUpdate is hardened to throw on Zod validation failure instead of persisting invalid state, and the invite handoff IPC gains a runtime wake step plus a retrying sender with [100, 250, 500, 1000]ms backoff. The now-obsolete _validationWarning surface is removed. Separately, a NLnet Fediversity grant proposal document is added to the reference docs, and react/react-dom are pinned to 19.2.4.

Changes

CRDT Merge Hardening and Invite Handoff Retry

Layer / File(s) Summary
mergeCoopStateUpdate: reject-on-invalid and profile ID check
packages/shared/src/modules/storage/db-crud-content.ts, packages/shared/src/modules/storage/__tests__/db-crud-content-sync.test.ts
On Zod parse failure, the function now loads the previously persisted coop state and throws instead of continuing with persistence. On success it additionally validates parsed.profile.id === coopId before persisting. Test for R7 is updated to assert the stored encodedState is unchanged after an invalid remote update.
Remove _validationWarning from persist-coop-state handler
packages/extension/src/background/handler-registry.ts
The handler no longer captures or logs the _validationWarning return field, reflecting that mergeCoopStateUpdate now throws on invalid state.
Invite handoff: wake runtime and retry with backoff
packages/extension/src/background/handlers/coop.ts, packages/extension/src/background/handlers/__tests__/coop-handlers.test.ts
Adds InviteHandoffResponseData type, backoff delays [100, 250, 500, 1000], wakeCoopSyncRuntimeForInviteHandoff (best-effort refresh message), and sendInviteHandoffRequest (retrying IPC). requestInviteHandoff now wakes the runtime before delegating. Tests verify wake message ordering and retry behavior under two initial undefined responses.

Grant Proposal Docs and Dependency Pin

Layer / File(s) Summary
NLnet proposal doc, reference index, and react version pin
docs/reference/nlnet-fediversity-coop-proposal-2026-05-31.md, docs/reference/index.md, docs/package.json
New 123-line proposal draft document covers fund parameters, go/no-go verdict, pre-submit checklist, full /propose form draft, and grounding notes table. Reference index gains a Funding & Grants row. react and react-dom are pinned from ^19.0.0 to 19.2.4.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 Hoppity-hop through the CRDT maze,
Invalid merges now meet a firm gaze—
The handoff retries with backoff in tow,
A runtime awakened, three tries in a row.
Grant docs are drafted, react pinned just right,
The coop stays safe through the long coding night! 🌙

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title accurately captures the two main changes: archiving the NLnet proposal reference and hardening Coop sync resilience.
Description check ✅ Passed The description clearly relates to the changeset, detailing documentation archival, dependency alignment, and Coop sync robustness improvements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/code-root-cleanup-coop

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 and usage tips.

@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: 2

🧹 Nitpick comments (1)
packages/extension/src/background/handlers/__tests__/coop-handlers.test.ts (1)

799-858: 💤 Low value

Consider adding a test for exhausted retries.

The retry success path is well covered. For completeness, a test that mocks 5+ undefined responses to verify the fallback error message when all retries are exhausted would strengthen coverage of the failure path.

🤖 Prompt for 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.

In `@packages/extension/src/background/handlers/__tests__/coop-handlers.test.ts`
around lines 799 - 858, Add a new test alongside the existing "retries external
invite handoff while the offscreen sync runtime wakes" test that covers the
failure path. Create a test that follows the same pattern with handleJoinCoop,
but instead of mocking three sendMessage calls (with the third returning
success), mock 5 or more consecutive undefined responses to simulate all retries
being exhausted. Verify that the joinResult.ok is false and that the appropriate
error message or fallback behavior is returned when all retry attempts are
depleted.
🤖 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 `@packages/shared/src/modules/storage/__tests__/db-crud-content-sync.test.ts`:
- Around line 403-407: The test for mergeCoopStateUpdate with
invalidRemoteUpdate should assert that an error is thrown rather than expecting
a successful result. Refactor the test around the mergeCoopStateUpdate call to
use expect().rejects pattern to verify the promise rejection occurs, then keep
an assertion comparing the original state to prove it was not modified during
the failed merge operation. Remove the current success assertions on
result.profile.id and result.rituals, replacing them with error handling
verification.

In `@packages/shared/src/modules/storage/db-crud-content.ts`:
- Around line 243-257: The mergeCoopStateUpdate function is returning stale
state when an invalid remote update is detected (when parseResult.success is
false), which makes the invalid merge appear successful and violates
error-handling semantics. Remove the return path that returns
readCoopState(existingDoc) in the if (existing) block when parsing fails,
ensuring the error is always thrown via throw parseResult.error at the end
instead. The function should never return a successful result when
parseResult.success is false, even if existing data is available.

---

Nitpick comments:
In `@packages/extension/src/background/handlers/__tests__/coop-handlers.test.ts`:
- Around line 799-858: Add a new test alongside the existing "retries external
invite handoff while the offscreen sync runtime wakes" test that covers the
failure path. Create a test that follows the same pattern with handleJoinCoop,
but instead of mocking three sendMessage calls (with the third returning
success), mock 5 or more consecutive undefined responses to simulate all retries
being exhausted. Verify that the joinResult.ok is false and that the appropriate
error message or fallback behavior is returned when all retry attempts are
depleted.
🪄 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: CHILL

Plan: Pro

Run ID: bca84281-b2b8-4442-b372-b36963b08c0a

📥 Commits

Reviewing files that changed from the base of the PR and between a623e7b and 666c081.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • docs/package.json
  • docs/reference/index.md
  • docs/reference/nlnet-fediversity-coop-proposal-2026-05-31.md
  • packages/extension/src/background/handler-registry.ts
  • packages/extension/src/background/handlers/__tests__/coop-handlers.test.ts
  • packages/extension/src/background/handlers/coop.ts
  • packages/shared/src/modules/storage/__tests__/db-crud-content-sync.test.ts
  • packages/shared/src/modules/storage/db-crud-content.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Unit Coverage
🧰 Additional context used
📓 Path-based instructions (5)
**/package.json

📄 CodeRabbit inference engine (CLAUDE.md)

**/package.json: Use internal workspace dependencies with workspace:* (never workspace:^) in package.json
Pin exact versions for critical dependencies: viem, permissionless, react, dexie, yjs due to breaking changes between minors
Use ranges for dev dependencies: vitest ^, typescript ~, @types/* ^ in package.json

Files:

  • docs/package.json
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Prefer interface over type for defining object shapes in TypeScript
Use Dexie for structured data, Yjs for CRDT sync, y-webrtc for direct peer transport, and y-websocket for server-assisted document sync

Files:

  • packages/shared/src/modules/storage/db-crud-content.ts
  • packages/extension/src/background/handlers/__tests__/coop-handlers.test.ts
  • packages/extension/src/background/handler-registry.ts
  • packages/shared/src/modules/storage/__tests__/db-crud-content-sync.test.ts
  • packages/extension/src/background/handlers/coop.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: Use barrel imports from @coop/shared or @coop/shared/app, never import from deep source paths
All frontend environment variables must use the VITE_ prefix for access via import.meta.env
Never swallow errors; always surface failures to the user

**/*.{ts,tsx,js,jsx}: Import from shared public surfaces only: @coop/shared for general consumers, @coop/shared/app for the app shell
Never use deep import paths like @coop/shared/modules/auth/...; use public API surfaces only
All environment variables require VITE_ prefix for frontend access
Surface all errors to the user; never swallow errors
Set chain via VITE_COOP_CHAIN environment variable: sepolia (default) or arbitrum (production)
Set onchain integration mode via VITE_COOP_ONCHAIN_MODE: mock (default) or live
Set archive mode via VITE_COOP_ARCHIVE_MODE: mock (default) or live
Set session mode via VITE_COOP_SESSION_MODE: mock, live, or off (default)

Files:

  • packages/shared/src/modules/storage/db-crud-content.ts
  • packages/extension/src/background/handlers/__tests__/coop-handlers.test.ts
  • packages/extension/src/background/handler-registry.ts
  • packages/shared/src/modules/storage/__tests__/db-crud-content-sync.test.ts
  • packages/extension/src/background/handlers/coop.ts
packages/extension/src/**/*.{ts,tsx,css}

📄 CodeRabbit inference engine (CLAUDE.md)

Reuse existing CSS classes from packages/extension/src/global.css and design tokens from shared/src/styles/tokens.css instead of duplicating styles

Files:

  • packages/extension/src/background/handlers/__tests__/coop-handlers.test.ts
  • packages/extension/src/background/handler-registry.ts
  • packages/extension/src/background/handlers/coop.ts
packages/extension/src/background/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

packages/extension/src/background/**/*.ts: Use chrome.alarms for timers in background worker; never use setInterval
Never use window in service worker context

Files:

  • packages/extension/src/background/handlers/__tests__/coop-handlers.test.ts
  • packages/extension/src/background/handler-registry.ts
  • packages/extension/src/background/handlers/coop.ts
🪛 LanguageTool
docs/reference/nlnet-fediversity-coop-proposal-2026-05-31.md

[grammar] ~26-~26: Ensure spelling is correct
Context: ...sskey identity + export are real today; onchain anchoring + Filecoin archival are **moc...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[grammar] ~74-~74: Ensure spelling is correct
Context: ...ludes moving the currently mock-default onchain/archival rails toward a production path...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[grammar] ~89-~89: Ensure spelling is correct
Context: ...ction-hardening currently-mock rails**: onchain anchoring and Filecoin archival are moc...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[style] ~94-~94: Consider an alternative for the overused word “exactly”.
Context: ... waste, education, and solar. These are exactly the contexts that most need self-owned,...

(EXACTLY_PRECISELY)

🪛 markdownlint-cli2 (0.22.1)
docs/reference/nlnet-fediversity-coop-proposal-2026-05-31.md

[warning] 46-46: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)

🔇 Additional comments (10)
docs/reference/index.md (1)

34-34: LGTM!

docs/package.json (1)

23-24: LGTM!

packages/extension/src/background/handlers/coop.ts (5)

63-72: LGTM!


74-80: LGTM!


82-91: LGTM!


93-129: LGTM!


131-144: LGTM!

packages/extension/src/background/handlers/__tests__/coop-handlers.test.ts (1)

735-735: LGTM!

Also applies to: 769-773

packages/shared/src/modules/storage/db-crud-content.ts (1)

259-269: LGTM!

packages/extension/src/background/handler-registry.ts (1)

571-581: LGTM!

Comment thread packages/shared/src/modules/storage/__tests__/db-crud-content-sync.test.ts Outdated
Comment thread packages/shared/src/modules/storage/db-crud-content.ts
@Oba-One Oba-One force-pushed the codex/code-root-cleanup-coop branch from 666c081 to 3eefb88 Compare June 19, 2026 06:13
@Oba-One Oba-One changed the title [codex] Archive NLnet Fediversity Coop proposal reference [codex] Archive NLnet proposal reference and harden Coop sync Jun 19, 2026
@Oba-One Oba-One force-pushed the codex/code-root-cleanup-coop branch from 0ac6bf4 to 35f37de Compare June 19, 2026 06:42
@Oba-One Oba-One merged commit 901f578 into main Jun 19, 2026
8 checks passed
@Oba-One Oba-One deleted the codex/code-root-cleanup-coop branch June 19, 2026 06:55
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