Skip to content

Keep late class answers scoped to the membership that sent them #747

Open

Description

@lumenpearson

Problem

Source audit for stage5b (#746, parent #273) found that ManageRepositoryImpl.call classifies a token refusal and invokes a parameterless onTokenRejected; DefaultLessonsContainer wires it to sessionRepository.leaveActive(). The request's identity is lost. If a management request is sent for class A, the user selects B while the request is in flight, and A's revoked token is answered later, this closure removes B. The accepted Schedule path already uses rejectRequest(sent) and demonstrates the intended ownership boundary.

The management race now has the deterministic Task4/5 RED observation below. The linking counterpart's class-switch correction passed focused Task2 validation; same-class replacement-token regressions now expose a remaining UI reset boundary. The management and linking ownership corrections are now written and pass the focused validation below; no stage5b correction has reached dev, master or production.

Expected behaviour

Carry the exact address/class bearer actually used at send time through the management call. Only a structured DEVICE_TOKEN_INVALID refusal may trigger rejection of that matching retained membership. A role/link refusal, a generic gateway 401, a request without an observed sent identity, a replaced token or a changed server must not remove the active unrelated membership. Keep network I/O outside the membership persistence gate and preserve cancellation.

Acceptance

  • A regression reproduces the A-request/B-selection/late-A-refusal race before the fix and passes after it.
  • Tests hold changed server, replaced token, role loss, missing observed identity and reasonless401 boundaries.
  • The real management graph uses the existing sent-identity rejection path; existing cache wipe and notification behaviour remains coherent.
  • Full applicable gates, fresh independent whole-branch review, exact-head/dev/master CI and source-matched production/native acceptance are recorded with Move the remaining Android remotes to v2 transports (stage 5b) #746.

Implement with #746 while moving the management area wholesale to v2. Preserve all v1 server compatibility and unfinished work; do not perform any destructive production operation to reproduce this race.

Related late-result boundary

The same audit found that ManagementViewModel resets the shared ManagementPlumbing.state on a class change, while ManagementPlumbing.finish guards only the current gone flag. An older in-flight read can therefore repopulate the new class's empty state or apply its session-ending failure. Fix and test this as part of the same lost-request-ownership defect: capture a generation for each read/write, invalidate it on class/session reset, and apply a result only to the generation that initiated it. Audit token history must reset with that generation. The dedicated Task4/5 ownership tests below now reproduce this boundary before correction.

  • A late success or role/token refusal for A cannot repopulate B's management state, end B's page or restore A's audit token history after a reset.

Linking counterpart found during MeRemote preparation

SettingsDeviceLink.refreshDeviceLink checks the class it asked about before applying a completion, but unlinkDevice has no equivalent check. If the user switches classes while unlink is in flight, its success or failure can overwrite the newly reset class page and remember the old response under the initiating class. Stage5b Task2 must hold this same ownership boundary while composing UnlinkMe/CreateLinkCode: a late unlink completion must not replace the new class's device-link state. Add a deterministic deferred-response regression before the correction. This is source-audit evidence; native reproduction has not been attempted.

Observed Task2 RED (13 November 2026)

One serialized offline command compiled and ran both affected modules: 41 cases, 27 assertion failures, 14 passed, no errors or skips, in 93.73s. The two new SettingsViewModelTest cases reproduce late unlink success replacing the successor's Ready state and late unlink failure replacing the new class's Idle state. Four DeviceLinkRepositoryTest cases also reproduce publication after a class, token or server change; its existing IO/cancellation control passes. The 21 transport instances fail because the current linking boundary still calls v1. All 13 prior settings cases pass. This is deterministic local JVM evidence, not native or production evidence.

  • Deferred unlink success and failure reproduce the stale settings publication before correction.
  • Fresh validation passes with the MeRemote graph, repository ownership check and settings operation-generation correction.

The corrected 29-file cohort passed a separate resource-qualified validation2: exit0 in41.95s, both core:data/app test tasks freshly executed, 73/73 cases passed with no failures/errors/skips, and fresh core:data Detekt reported no findings. App Detekt was UP-TO-DATE from its source-identical prior pass; its report hash was verified, rather than claiming a new execution. This remains focused JVM evidence, with no native or production acceptance. Management rejection and management-page/audit-generation work remains pending in Tasks4–5, so this issue stays open.

Observed Tasks4/5 RED

One freshly admitted serialized offline command compiled data/app and executed all 83 selected cases in 42.25 seconds: 67 behavioural assertion failures (64 AssertionError and three ComparisonFailure), 16 passes, zero compiler/framework failures, errors or skips. The six management membership cases reproduce five failures, including wrong-membership removal, replacement-token/server/missing-observation boundaries and a reasonless gateway 401. All six management UI ownership cases fail: late A success/refusal can affect B, an old write can clear B's working state, same-class credentials do not invalidate an old read, and queued old reads/writes still execute after reset. All three opaque-token navigation cases fail. Two new settings cases reproduce late unlink success/failure after a replacement token for the same class; all 15 prior settings cases still pass.

The remaining binding assertions fail against the unchanged v1 management producer. All 65 source inputs, the declared mapper move/deletion and tracked diff stayed frozen. Fresh two-module reports, raw output and prelaunch process-identity evidence are retained; this is complete local RED, not a corrected implementation, native proof or delivery. The same-class token reset and separate last-role persistence boundary are explicitly audited during the upcoming correction.

Separate role-persistence audit

The current linking repository validates link publication under membershipChanges, but its public rememberRole(classId, role) delegates to DataStore without that request identity. The settings completion calls it after its UI check, so replacement credentials or a server edit between publication and the later persistence call can write an obsolete role. Preserve the API behaviour while requiring the remembered role to belong to the last actual successful owned reply and the still-current class/address/bearer; hold the short membership gate through that local write. Add deterministic repository regressions for an old reply followed by replacement credentials/server change, plus a positive owned-write control, before correcting this path. This is a source audit, not an executed reproduction. Current validation1 inputs are frozen; these tests will be added only after its qualified release.

Two additional server-address UI regressions are written and queued in validation1 before implementing that reset trigger. Their anticipated RED is separate from any compiler/framework/Detekt failure, and no new resource admission is inferred.

Observed validation2: remaining six ownership regressions

The complete implementation cohort now compiles in both modules. One newly admitted serialized offline validation executed224 fresh cases in99.68s:218 passed and exactly six failed with AssertionError, with zero errors/skips/compiler/framework failures. All existing management bindings, sent-identity rejection, opaque audit navigation, Me binding and selected management/settings tests passed. The four new repository assertions demonstrate an obsolete role overwriting the current remembered value after class selection, bearer replacement or server change, and an older role overwriting a later owned role. The two new UI assertions demonstrate a management read and an unlink answer publishing after a server-address change. The corresponding producers remain unchanged until resource release, so this is actual behavioural RED before their correction.

Fresh core:data Detekt has0 findings. App Detekt was UP-TO-DATE from source-identical validation1, whose fresh report had0 findings. All116 exact inputs/two declared absences,19 fresh JUnit reports, raw logs and owned-process evidence are retained. Full gates/review/dev/master/native/production remain pending.

Focused ownership GREEN

After the six actual validation2 RED assertions, only three producer files changed: Settings/Management reset identity now combines address, class and bearer in a cheap observer independent of the suspending server probe; DeviceLinkRepository remembers a role only when it matches the last successful owned reply and still-current request, holding the short membership gate through the local write. No network I/O is held by that gate, and no test/assertion changed.

One fresh serialized command then executed224/224 passing cases, zero failures/errors/skips, exit0 in54.43s. Both data/app test tasks and both Detekt tasks executed freshly; each Detekt report has0 findings. The complete original83-case regression cohort and all six new ownership assertions are included among those selected cases. All116 exact source inputs/two absences,19 fresh JUnit reports, raw output and process evidence remain retained. This is focused local GREEN only; full gates, independent review, dev/master, signed native and production are still required. The separately audited diary persistence defect is tracked by #753 and does not inherit this management proof.

Activity

  1. changed the title [-]Reject the management request's membership instead of whichever class is active later[/-] [+]Keep late management answers scoped to the membership that sent them[/+] on Nov 13, 2026
  2. changed the title [-]Keep late management answers scoped to the membership that sent them[/-] [+]Keep late class answers scoped to the membership that sent them[/+] on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      Now

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions