Skip to content

MF3-M01, M02, M03, L09: feat(app-sessions): remove rebalance feature#806

Open
philanton wants to merge 1 commit into
fix/audit-findings-finalx3from
feat/remove-rebalancing
Open

MF3-M01, M02, M03, L09: feat(app-sessions): remove rebalance feature#806
philanton wants to merge 1 commit into
fix/audit-findings-finalx3from
feat/remove-rebalancing

Conversation

@philanton
Copy link
Copy Markdown
Contributor

@philanton philanton commented Jun 2, 2026

Summary

Removes the app-session rebalancing feature end to end. The endpoint was already disabled in every deployed environment (NITRONODE_MAX_SIGNED_UPDATES=0, route gated on >= 2), so this is effectively dead-code cleanup at runtime plus full removal of the API surface, SDK methods, types, and docs.

Changes by layer

nitronode

  • Delete rebalance_app_sessions.go handler + its 1358-line test
  • Drop MaxSignedUpdates / MaxRebalanceSignedUpdates config and the route gate; remove NITRONODE_MAX_SIGNED_UPDATES from the 3 helm configs
  • Fix NewHandler signature + 35 call sites

pkg/

  • rpc: remove rebalance_app_sessions method const, request/response types, client wrapper
  • app: remove AppStateUpdateIntentRebalance, AppSessionVersionV1, GenerateRebalanceBatchIDV1, GenerateRebalanceTransactionIDV1
  • core: remove TransactionTypeRebalance (42)

SDKs

  • sdk/go, sdk/ts: drop client methods, types, packing helpers, enum members, examples, READMEs
  • Regenerate rpc-drift and public-api-drift snapshots

Docs / misc

  • docs/api.yaml, docs/data_models.mmd, llms-full.txt, MCP categorizer regex, playground history view

Notes

  • The intent (4) and transaction-type (42) enum values were terminal, so removal shifts no other wire values.
  • TransactionTypeRebalance=42 is removed entirely — pre-existing ledger rows tagged 42 (if any) now render as unknown. Chosen deliberately over keeping a display-only mapping.

Verification

  • go vet ./... clean · go test ./... all pass
  • TS SDK: 184 tests pass, snapshots regenerated · tsc + ts-compat typecheck OK
  • MCP build OK · playground typecheck OK

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Breaking Changes

    • Removed rebalance_app_sessions RPC endpoint for atomic multi-session rebalancing
    • Removed rebalance methods from Go and TypeScript SDKs
    • Removed "rebalance" as a supported transaction type and app state update intent
    • Removed related configuration parameters
  • Documentation

    • Updated API specifications, SDK documentation, and deployment guides to reflect removal of rebalancing functionality

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ca42704f-de49-4044-a0aa-6f6d3e0c4fcf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR removes the rebalance_app_sessions RPC endpoint and all supporting infrastructure across the Nitrolite codebase. Domain enums, RPC types, handler implementations, SDK methods, configuration, and tests are comprehensively deleted. The maxSignedUpdates configuration field is replaced with maxSessionKeysPerUser.

Changes

Rebalance Feature Complete Removal

Layer / File(s) Summary
Domain model enums and types removal
pkg/app/app_session_v1.go, pkg/app/app_session_v1_test.go, pkg/core/types.go, sdk/ts/src/app/types.ts, sdk/ts/src/core/types.ts
AppStateUpdateIntentRebalance, TransactionTypeRebalance, and AppSessionVersionV1 are removed from domain models. Enum-to-string converters and intent collections are updated to exclude rebalance.
RPC API types and method constants removal
pkg/rpc/api.go, pkg/rpc/methods.ts, sdk/ts/src/rpc/api.ts, sdk/ts/src/core/types.ts
AppSessionsV1RebalanceAppSessionsRequest/Response types and AppSessionsV1RebalanceAppSessionsMethod constant are deleted from RPC surface.
Handler implementation and route registration removal
nitronode/api/app_session_v1/rebalance_app_sessions.go, nitronode/api/rpc_router.go
The RebalanceAppSessions handler method (355 lines) and its test suite (1358 lines) are completely removed. RPC route registration for the endpoint is deleted.
Handler struct and constructor signature updates
nitronode/api/app_session_v1/handler.go, nitronode/api/rpc_router.go
maxSignedUpdates field is removed from Handler struct and NewHandler constructor parameter list. Constructor's returned struct literal is updated accordingly.
Runtime configuration updates
nitronode/runtime.go, nitronode/main.go, nitronode/api/rpc_router.go, nitronode/chart/config/*/*.gotmpl
MaxSignedUpdates is replaced with MaxSessionKeysPerUser in ValidationLimits. MaxRebalanceSignedUpdates is removed from RPCRouterConfig. Environment variables and Helm template configs are updated to remove rebalance-related settings.
Go SDK method and documentation removal
sdk/go/app_session.go, sdk/go/client_test.go, sdk/go/README.md, sdk/go/examples/app_sessions/lifecycle.go
Client.RebalanceAppSessions method, its test case, and usage examples are removed from the Go SDK.
TypeScript SDK methods, types, and utilities removal
sdk/ts/src/client.ts, sdk/ts/src/app/types.ts, sdk/ts/src/app/packing.ts, sdk/ts/src/rpc/api.ts, sdk/ts/src/rpc/client.ts, sdk/ts/src/rpc/methods.ts, sdk/ts/README.md
Client.rebalanceAppSessions method, request/response RPC types, RPC wrapper, method constant, and ID generator helper functions are removed. TypeScript enums are updated to exclude Rebalance variants.
Test constructor signature updates
nitronode/api/app_session_v1/{create_app_session,submit_app_state,submit_deposit_state,submit_session_key_state}_test.go
All handler test cases are updated to remove the maxSignedUpdates parameter from NewHandler calls. Parameter values change from 16 to 100 in submit_app_state tests; struct literal field removals in deposit/session-key tests.
API documentation and schema updates
docs/api.yaml, docs/data_models.mmd
rebalance is removed from app_state_update.intent description. TransactionType.rebalance enum entry is deleted. The entire rebalance_app_sessions method definition and schema are removed from the OpenAPI spec.
Nitronode V1 API endpoint documentation update
nitronode/api/app_session_v1/README.md
Handler list, file inventory, endpoint numbering, and descriptions are updated to exclude rebalance_app_sessions. Subsequent endpoints are renumbered. ABI encoding and legacy-API comparison sections are adjusted.
SDK examples and user-facing documentation updates
nitronode/README.md, sdk/ts/README.md, sdk/ts/examples/app_sessions/{README.md,lifecycle.ts}, sdk/go/examples/app_sessions/lifecycle.go
Rebalance operations are removed from feature lists, workflow examples, and step-by-step lifecycle narratives. Documentation now flows directly from session state submission to withdrawal.
Reference documentation and MCP categorization update
llms-full.txt, sdk/mcp/src/index.ts, nitronode/metrics/exporter.go
Reference documentation is updated to remove rebalance method entries from RPC and SDK lists. MCP method categorization stops treating rebalance* methods as "App Sessions". Prometheus metric help text excludes rebalance from transaction type enum.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • layer-3/nitrolite#563: Directly extends rebalance test coverage for the exact APIs and types being removed here.
  • layer-3/nitrolite#635: Introduces MCP server that categorizes RPC methods; this PR updates the categorization to exclude rebalance methods.
  • layer-3/nitrolite#701: Maintains RPC-to-SDK method alignment tests that depend on the rebalance method mapping being removed here.

Suggested labels

ready

Suggested reviewers

  • ihsraham
  • nksazonov
  • dimast-x

Poem

🐰 The rebalance dance is done,
Atomic swaps have seen their sun,
Now sessions speak in simpler ways—
One withdraw, and then we graze.
Goodbye to batch IDs and signed arrays,
Hello to cleaner API days! 🍃

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.63% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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 PR title accurately and clearly describes the main objective: removing the rebalance feature from app-sessions. It is concise, specific, and directly addresses the primary change reflected throughout the changeset.

✏️ 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 feat/remove-rebalancing

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/api.yaml (1)

287-301: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Document the legacy transaction-type fallback.

The PR notes say historical ledger rows with value 42 now render as "unknown", but the canonical transaction_type enum no longer admits either "unknown" or the deprecated legacy value. That makes get_transactions responses invalid for strict clients generated or validated from this schema when they encounter old rebalance rows. Please document the legacy response value here, or split request/response enums so the contract matches runtime behavior. As per coding guidelines, docs/api.yaml: API definition and canonical list of all v1 RPC methods, types, and request/response schemas is located in docs/api.yaml.

🤖 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 `@docs/api.yaml` around lines 287 - 301, The API schema currently lists the
canonical transaction_type enum but omits the historical fallback used at
runtime, causing strict clients to fail for old ledger rows; update
docs/api.yaml so the transaction_type used in get_transactions responses
includes the legacy fallback (add "unknown" to the transaction_type enum used
for responses) or alternatively split the type into request vs response variants
and add "unknown" to the response enum only; update the transaction_type
definition and any referenced get_transactions response schema to reflect this
change and add a brief description noting that legacy numeric value 42 maps to
"unknown".
🤖 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.

Outside diff comments:
In `@docs/api.yaml`:
- Around line 287-301: The API schema currently lists the canonical
transaction_type enum but omits the historical fallback used at runtime, causing
strict clients to fail for old ledger rows; update docs/api.yaml so the
transaction_type used in get_transactions responses includes the legacy fallback
(add "unknown" to the transaction_type enum used for responses) or alternatively
split the type into request vs response variants and add "unknown" to the
response enum only; update the transaction_type definition and any referenced
get_transactions response schema to reflect this change and add a brief
description noting that legacy numeric value 42 maps to "unknown".

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d404b6a5-9002-44f9-a39a-bc0cb8da48da

📥 Commits

Reviewing files that changed from the base of the PR and between 0c46c9e and 8679048.

⛔ Files ignored due to path filters (1)
  • sdk/ts/test/unit/__snapshots__/public-api-drift.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (43)
  • docs/api.yaml
  • docs/data_models.mmd
  • llms-full.txt
  • nitronode/README.md
  • nitronode/api/app_session_v1/README.md
  • nitronode/api/app_session_v1/create_app_session_test.go
  • nitronode/api/app_session_v1/handler.go
  • nitronode/api/app_session_v1/rebalance_app_sessions.go
  • nitronode/api/app_session_v1/rebalance_app_sessions_test.go
  • nitronode/api/app_session_v1/submit_app_state_test.go
  • nitronode/api/app_session_v1/submit_deposit_state_test.go
  • nitronode/api/app_session_v1/submit_session_key_state_test.go
  • nitronode/api/rpc_router.go
  • nitronode/chart/config/prod-v1/nitronode.yaml.gotmpl
  • nitronode/chart/config/sandbox-v1/nitronode.yaml.gotmpl
  • nitronode/chart/config/stress-v1/nitronode.yaml.gotmpl
  • nitronode/main.go
  • nitronode/metrics/exporter.go
  • nitronode/runtime.go
  • pkg/app/app_session_v1.go
  • pkg/app/app_session_v1_test.go
  • pkg/core/types.go
  • pkg/rpc/api.go
  • pkg/rpc/client.go
  • pkg/rpc/methods.go
  • playground/mockups/history/history-tab.md
  • playground/src/components/HistoryTab.tsx
  • sdk/go/README.md
  • sdk/go/app_session.go
  • sdk/go/client_test.go
  • sdk/go/examples/app_sessions/lifecycle.go
  • sdk/mcp/src/index.ts
  • sdk/ts/README.md
  • sdk/ts/examples/app_sessions/README.md
  • sdk/ts/examples/app_sessions/lifecycle.ts
  • sdk/ts/src/app/packing.ts
  • sdk/ts/src/app/types.ts
  • sdk/ts/src/client.ts
  • sdk/ts/src/core/types.ts
  • sdk/ts/src/rpc/api.ts
  • sdk/ts/src/rpc/client.ts
  • sdk/ts/src/rpc/methods.ts
  • sdk/ts/test/unit/rpc-drift.test.ts
💤 Files with no reviewable changes (30)
  • sdk/ts/src/rpc/methods.ts
  • sdk/ts/src/core/types.ts
  • nitronode/api/app_session_v1/rebalance_app_sessions.go
  • nitronode/api/app_session_v1/submit_session_key_state_test.go
  • playground/src/components/HistoryTab.tsx
  • sdk/ts/examples/app_sessions/lifecycle.ts
  • nitronode/chart/config/prod-v1/nitronode.yaml.gotmpl
  • pkg/rpc/api.go
  • pkg/rpc/client.go
  • nitronode/README.md
  • nitronode/api/app_session_v1/rebalance_app_sessions_test.go
  • sdk/ts/src/client.ts
  • sdk/go/app_session.go
  • sdk/ts/src/rpc/client.ts
  • sdk/ts/src/rpc/api.ts
  • sdk/ts/test/unit/rpc-drift.test.ts
  • nitronode/runtime.go
  • pkg/rpc/methods.go
  • llms-full.txt
  • sdk/go/README.md
  • nitronode/chart/config/sandbox-v1/nitronode.yaml.gotmpl
  • sdk/ts/src/app/types.ts
  • nitronode/api/app_session_v1/submit_deposit_state_test.go
  • pkg/app/app_session_v1_test.go
  • sdk/ts/README.md
  • sdk/go/client_test.go
  • docs/data_models.mmd
  • sdk/go/examples/app_sessions/lifecycle.go
  • nitronode/chart/config/stress-v1/nitronode.yaml.gotmpl
  • pkg/app/app_session_v1.go

@philanton philanton changed the base branch from main to fix/audit-findings-finalx3 June 2, 2026 14:42
@nksazonov nksazonov changed the title feat(app-sessions): remove rebalance feature MF3: M01, M02, M03, L09: feat(app-sessions): remove rebalance feature Jun 4, 2026
@nksazonov nksazonov changed the title MF3: M01, M02, M03, L09: feat(app-sessions): remove rebalance feature MF3-M01, M02, M03, L09: feat(app-sessions): remove rebalance feature Jun 4, 2026
Remove the app-session rebalancing feature end to end across the
nitronode broker, shared pkg/ packages, Go and TypeScript SDKs,
MCP server, protocol docs, and playground.

- nitronode: delete rebalance_app_sessions handler + tests, drop the
  MaxSignedUpdates/MaxRebalanceSignedUpdates config and route gate
- pkg/rpc: remove rebalance_app_sessions method, request/response types,
  and client wrapper
- pkg/app: remove AppStateUpdateIntentRebalance, AppSessionVersionV1,
  and the GenerateRebalanceBatchIDV1/GenerateRebalanceTransactionIDV1 helpers
- pkg/core: remove TransactionTypeRebalance (value 42)
- sdk/go, sdk/ts: drop client methods, types, packing helpers, enum
  members, examples, and READMEs; regenerate drift snapshots
- docs/api.yaml, data_models.mmd, llms-full.txt, MCP categorizer,
  playground history view: remove all rebalance references

The intent (4) and transaction type (42) enum values were terminal, so
removal shifts no other wire values.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nksazonov nksazonov force-pushed the feat/remove-rebalancing branch from 8679048 to 4b8a96a Compare June 4, 2026 14:58
Copy link
Copy Markdown
Contributor

@nksazonov nksazonov left a comment

Choose a reason for hiding this comment

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

Clean approach and thorough removal across all layers. However, the NewHandler signature change was partially applied — 5 NewHandler call sites and 1 struct literal still reference the removed maxSignedUpdates parameter, causing go test ./nitronode/api/app_session_v1/... to fail to compile. These must be fixed before this can land.


[Bug — compile failure] create_app_session_test.go lines 1198, 1339, 1413

TestCreateAppSession_TotalWeightsOver255, TestCreateAppSession_TotalWeightsWrapToZero, and TestCreateAppSession_QuorumExceedsTotalWeights_Rejected all pass five integer arguments to NewHandler32, 1024, 256, 16, 100 — but the signature now takes four (maxParticipants, maxSessionData, maxSessionKeyIDs, maxSessionKeysPerUser). The maxSignedUpdates arg (16) was not removed here during the bulk update. Compiler error: too many arguments in call to NewHandler.

Suggestion: Remove the 16 from each call so they read 32, 1024, 256, 100.


[Bug — compile failure] submit_app_state_test.go lines 2160, 2272

TestSubmitAppState_VerifyQuorumWeightOver255 and TestSubmitAppState_VerifyQuorumWeightWrapToZero have the same stale five-argument NewHandler call. Same compiler error.

Suggestion: Remove the 16 from each call so they read 32, 1024, 256, 100.


[Bug — compile failure] submit_deposit_state_test.go line 1023

TestSubmitDepositState_VerifyQuorumWeightOver255 initialises Handler via a struct literal rather than NewHandler, so it was not caught by the bulk update. maxSignedUpdates no longer exists as a field on Handler. Compiler error: unknown field maxSignedUpdates in struct literal of type Handler.

Suggestion: Remove the maxSignedUpdates: 16, line from the struct literal.


[Doc] nitronode/README.md line 34

The app_session_v1 entry in the API groups section still lists "Rebalancing" as a capability. Line 9 was correctly cleaned up, but this one was missed.

Suggestion: Change "Advanced application session management (Creation, Deposits, Rebalancing)" to remove "Rebalancing".

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.

2 participants