Skip to content

fix(accounts): retire dynamic memory on removal - #455

Open
veryCrunchy wants to merge 13 commits into
fix/durable-upload-scheduling-recovery-stackfrom
fix/dynamic-memory-account-retirement
Open

fix(accounts): retire dynamic memory on removal#455
veryCrunchy wants to merge 13 commits into
fix/durable-upload-scheduling-recovery-stackfrom
fix/dynamic-memory-account-retirement

Conversation

@veryCrunchy

@veryCrunchy veryCrunchy commented Sep 6, 2026

Copy link
Copy Markdown
Member

Outcome

Clear account-scoped dynamic app memory and pending dynamic mutation state during account removal. Dynamic activation reopens caches only after the exact saved session is still current, so late responses from a removed account cannot repopulate a replacement account.

Pending cleanup blocks account activation until it is safe. Known legacy cleanup entries now block only their recorded account identity, while unknown or malformed entries continue to fail closed. Canonical identity matching is preserved for newer journal formats.

Verification

On the dedicated Linux build host, exact head 944dea1a9c4d6c71c9488fec1517569f4aafcafd, source tree 233f61df950656510ec7dbc19574826e028ab1a5:

  • DesktopAccountMemoryRetirementTest: 7 tests passed.
  • DesktopAccountOperationGuardTest: 41 tests passed.
  • No failures, errors, or skips. Production desktop code and the desktop test suite compiled successfully.
  • bash tools/check-repository.sh and git diff --check passed.

The latest regression coverage exercises all four legacy cleanup encodings, verifies that the owning account stays blocked, allows unrelated accounts to load and publish, and retains the pending journal.

Hosted Android, Windows, and remaining integration checks are separate merge gates. This focused Linux run does not establish live multi-account behavior on a device.

Restacked head 9e6259b488312612eb6c4198f407d81feaebec17 preserves all 11 layer commits and inherits the newer provider-deadlock and terminal-cleanup fixes from #439. Full repository checks and git diff --check pass on the integrated tree. The focused desktop result above covers the unchanged #455 behavior, not the newly inherited Android fixes. Latest-head hosted checks remain required.

Compatibility and risk

Android and desktop account removal and activation are affected. There is no server schema, DAV, or wire-protocol change. This PR is stacked on #439 and includes main at 92dd2ae9cec1dc7dac16907e66d7b870694ebbbf.

No visual changes.

@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #455 / NC Native September 6, 2026 04:48 Destroyed
@obiente-cloud

obiente-cloud Bot commented Sep 6, 2026

Copy link
Copy Markdown

Obiente preview

NC Native · 41120a5181e2 · Ready

Open preview

View in Obiente

Obiente updates this comment as the preview changes.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-09T07:12:56.522111Z 07ba4cd New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@veryCrunchy veryCrunchy changed the title fix/dynamic memory account retirement fix(accounts): retire dynamic memory on removal Sep 6, 2026
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #455 / NC Native September 6, 2026 04:55 Destroyed

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39af1ccc0e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@veryCrunchy
veryCrunchy force-pushed the fix/dynamic-memory-account-retirement branch from bd62702 to 83f3347 Compare September 6, 2026 06:38
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #455 / NC Native September 6, 2026 06:38 Destroyed
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #455 / NC Native September 6, 2026 06:45 Destroyed
@veryCrunchy
veryCrunchy force-pushed the fix/dynamic-memory-account-retirement branch from df787cc to e946520 Compare September 6, 2026 12:45
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #455 / NC Native September 6, 2026 12:45 Destroyed
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #455 / NC Native September 6, 2026 12:52 Destroyed

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e946520e23

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@veryCrunchy
veryCrunchy force-pushed the fix/dynamic-memory-account-retirement branch from 671af04 to 944dea1 Compare September 9, 2026 05:11
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #455 / NC Native September 9, 2026 05:11 Destroyed
@veryCrunchy
veryCrunchy force-pushed the fix/dynamic-memory-account-retirement branch from 944dea1 to 9e6259b Compare September 9, 2026 05:49
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #455 / NC Native September 9, 2026 05:49 Destroyed

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e6259b488

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (malformedEntryFound) recordMalformedOnce()
return when {
malformedEntryFound -> DesktopAccountActivationBlock.UnknownJournalData
matchingEntryFound -> DesktopAccountActivationBlock.PendingCleanup

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Recover pending cleanup before rejecting session loading

When a restart follows a crash after a Prepared journal entry was persisted but before the credential was removed, this now classifies the existing account as blocked, so loadDesktopSessionAfterCleanupGate() throws before loading it. In the inspected desktop startup flow, Main.kt starts the cleanup lifecycle only after two session-dependent startup calls, while NextcloudSessionLoading.kt does not catch this generic IllegalStateException; the concurrent session-loading effect can therefore fail permanently or terminate the application instead of waiting for the background recovery that would detect Present ownership and clear the journal. Recover supported pending entries before session loading, or expose a handled retryable load state.

AGENTS.md reference: AGENTS.md:L447-L449

Useful? React with 👍 / 👎.

Comment on lines +94 to +95
if (previewCacheIdentity == null) {
DynamicNativeMemoryAccountLifecycle.retireAccount(session.accountId.storageKey)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Fence legacy dynamic API state using the available session

When retrying a two-field legacy removal journal, previewCacheIdentity is null even though this overload has the exact session; this branch therefore retires only process memory and skips both the request-coalescer fence and dynamicApiState.cache.invalidateAccount(). saveSession() can then clear the cleanup journal and reactivate the account while its persisted dynamic responses under NextcloudDocumentIds.cacheAccountId(session) remain available, allowing private data from the prior account incarnation to be shown after the same server/login identity is added again. Derive the full cache identity from session and run the normal fenced cleanup for this legacy case.

AGENTS.md reference: AGENTS.md:L410-L413

Useful? React with 👍 / 👎.

@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #455 / NC Native September 9, 2026 07:05 Destroyed
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