Skip to content

fix(mirror): role and channel order in the shape Fluxer takes - #391

Open
Ferdinand99 wants to merge 2 commits into
feat/53-mirror-bridge-linkfrom
fix/53-mirror-order
Open

Ferdinand99 wants to merge 2 commits into
feat/53-mirror-bridge-linkfrom
fix/53-mirror-order

Conversation

@Ferdinand99

Copy link
Copy Markdown
Owner

Summary

The first live run of the server mirror against a real Fluxer server finished with two failed steps: "Role order: Cannot read properties of undefined (reading 'map')" and "Channel order: Invalid form body.". This fixes both and makes the bridge line of the report readable.

Role order

Fluxer answers PATCH /guilds/{id}/roles with 204 No Content. @fluxerjs/core 3.3.0's guild.setRolePositions() maps over the response as if it were the role list, so it threw after Fluxer had already applied the order. The adapter now calls the route through the SDK's REST client with [{ id, position }].

Channel order

Discord numbers text-like and voice channels separately, so sorting a category by raw position could put a voice channel between text channels. Fluxer applies channel moves one at a time (position = index among the new siblings) and refuses any move that leaves a voice channel above a text channel in a category (400 INVALID_FORM_BODY, VOICE_CHANNELS_CANNOT_BE_ABOVE_TEXT_CHANNELS).

  • channelOrder() now follows Discord's display order: text-like before voice in each category, loose channels before categories. It sends the text moves for every category before the voice moves.
  • New channelPositionUpdates() counts positions only among channels that exist on Fluxer. It places the mirror's voice channels after every text-like channel in the category, including channels made on Fluxer.
  • The body is sent explicitly: [{ id, position, parent_id, lock_permissions: false }].

Failures, Copy again, report

  • A refused order now names Fluxer's reason, taken from the errors field of the 400 response. For roles, it also says the copied roles keep waiting for their powerful permissions. Rate limits, network errors and permission errors are handled as before.
  • A failed order is not recorded as set, so Copy again plans and sends it again. Powerful permissions are still granted only after the order succeeds.
  • The bridge step is summed up in one sentence per run across batches, e.g. "35 channels linked, 2 were linked already, 1 not linked (see the notes)". A channel that could not be linked is noted only once.

Tests

  • test/mirrorFluxerContract.test.js uses the real SDK Guild and REST client against a local recording HTTP server. It checks the method, path, auth header and raw JSON body for both routes, the 204 handling, and that a Fluxer 400 body is classified with its field reason.
  • test/mirrorOrder.test.js covers:
    • layout and position rules
    • a full copy of a category that mixes text and voice channels
    • a failed role order: no powerful permissions, a clear message, and Copy again orders the roles and then grants
    • a 400 role order and a failed channel order, each followed by Copy again
    • a rate limit that is waited out
  • The fake Fluxer now applies channel moves the way Fluxer does: one at a time, with the voice-above-text rule and the 400. Run against the old code, the mixed-category copy fails with the same "Invalid form body." as the live run.
  • Lint, Prettier, the full SQLite and Postgres 16 suites, and test:v2 pass.

Fluxer answers PATCH /guilds/{id}/roles with 204 No Content, and the SDK's guild.setRolePositions() maps over that empty answer as if it were the role list, so the order was set and then reported as failed. The adapter now calls both order routes through the SDK's REST client.

Discord numbers text and voice channels separately, so sorting a category by raw position could put a voice channel between text channels. Fluxer applies channel moves one at a time and refuses a move that leaves a voice channel above a text channel (400 Invalid form body). The order is now built the way Discord shows it (text-like first, then voice; loose channels before categories), sent text moves before voice moves, and positions count only the channels that exist on Fluxer.

A refused order now says what Fluxer said, and that the copied roles keep waiting for their powerful permissions; Copy again sends it again. The bridge step sums itself up in one sentence across batches.

@graphify-labs graphify-labs 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.

Graphify reviewed this change.

Code graph out of date: Health delta baseline: last indexed commit a9ec8af (diverged from this PR's base — delta is approximate). Impact and hotspot numbers below may be wrong.

No verdict: the code graph is out of date. Static checks found no blocking issues, but they compared against an outdated graph. The next push after the repository re-indexes gets a full review.

Not checked: tests were not run; no formal proof of the changed code.


Graphify review — findings

Fixes the mirror's channel ordering so Fluxer gets the order Discord shows (text-like channels before voice inside a category, uncategorised channels before categories), leaving channels made natively on Fluxer where they are. Refused role and channel orders now fail with Fluxer's own reason (including field errors from a 400, which previously said only "Invalid form body"), and the roles stay without their powerful permissions until Copy again resends the order and grants them. The bridge-linking step reports one running sentence for the whole step, e.g. "35 channels linked, 2 were linked already, 1 not linked (see the notes)", even when it runs in several batches, and the report shows only the latest batch's sentence.

Review partial — this diff was larger than one review pass covers, so later files were not reviewed; some findings may be missing.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 95 functions depend on the 88 functions this change touches.

Health — this change adds coupling hotspots:

  • new: scenario() — 4 callers, 8 callees
  • new: buildPlan() — 1 callers, 15 callees
  • new: fakeFluxer() — 3 callers, 5 callees
  • new: createEngine() — 5 callers, 3 callees

Verification — 95 functions in the blast radius were not formally verified this run (proofs are advisory here).

Health delta baseline: last indexed commit a9ec8af (diverged from this PR's base — delta is approximate).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 95 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

697 of 697 test file(s) selected (100%) via static blast radius.

Escalated to a full run for safety (noncode-change, uncovered-code) — the selection is not trustworthy on its own (see below). CI should run the whole suite.

  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Access/DashboardAccessTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Access/Round3Tests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Account/AccountConnectTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Account/AccountModelTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Account/ConnectCallbackSourceTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Account/NoDashboardLinkSourceTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Appeals/AppealsReviewTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Applications/ApplicationFormsTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Applications/ApplicationPassthroughTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Applications/ApplicationSubmissionsTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Applications/ApplicationWireTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Audit/AuditHistoryTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Audit/AuditLogTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Auth/CallbackIssuerAddressTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Auth/CallbackIssuerTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Auth/KeychainTokenStoreTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Auth/PKCETests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Auth/SignInRequestTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Auth/TokenStoreTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Changelog/ChangelogTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Commands/CommandOverridesTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Economy/CollectiblePictureTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Economy/EconomyAdminTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Economy/EconomyMembersTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Economy/InventoryTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Economy/ShopExtrasTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Economy/ShopItemsTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Economy/ShopModelTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Embeds/EmbedDraftTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Embeds/ModuleLimitsTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Events/CommunityReviewFixesTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Events/EventEndpointsTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Giveaways/GiveawayActionsTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/GuildSettings/CommandPrefixTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/GuildSettings/GuildSettingsTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Health/HealthTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Import/P6Tests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Insights/InsightsTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Leaderboard/LeaderboardTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Members/MemberDataTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Members/MemberSearchTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Messages/ComposedMessagesModelTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Messages/ComposedMessagesTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Models/ModelDecodingTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Models/ServerListTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Models/Sylo52PolishTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Models/UnknownKeysTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Models/Utf16TextLimitTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/Moderation/ModerationTests.swift — full-run-safety
  • apps/sylo-ios/SyloKit/Tests/SyloKitTests/ModuleSettings/AfkSettingsTests.swift — full-run-safety
  • … and 647 more

non-code file(s) changed (docs/mirror.md) → running the full suite for safety (a code graph can't see config/fixture/data deps)

changed code file(s) with no mapped test (docs/mirror.md) — a coverage gap or a missing link — running the full suite rather than only the selected tests

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

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