Skip to content

fix(android): bind retained documents to accounts - #447

Open
veryCrunchy wants to merge 32 commits into
feature/account-credential-slotsfrom
fix/document-grant-incarnation
Open

fix(android): bind retained documents to accounts#447
veryCrunchy wants to merge 32 commits into
feature/account-credential-slotsfrom
fix/document-grant-incarnation

Conversation

@veryCrunchy

@veryCrunchy veryCrunchy commented Sep 5, 2026

Copy link
Copy Markdown
Member

Summary

  • Give retained DocumentsProvider grants an account incarnation so removing and re-adding an account invalidates old URIs.
  • Resolve documents through their owning account instead of whichever account is active.
  • Journal grant retirement so interrupted removal can roll forward or back safely.
  • Hold the account-operation lease for retained reads and searches, and reuse held leases for authenticated provider lookups.
  • Close read admission and drain range descriptors before credential reset.
  • Generate retained document IDs from canonical account identity, while accepting compatible IDs for the current raw server spelling.

Validation

The earlier source tree c9a314df55e510df3f1478288955c06c5223e3aa passed the focused eight-class Android provider/removal suite and :androidApp:assembleDebug on the dedicated build host.

Current head 8a804d331cd31b78bedccf29a2cc63d1e1017911 adds reset quiescence, canonical IDs, and short-read lease regressions, then integrates the parent provider-deadlock fix. Full repository and architecture checks and git diff --check pass. File-size baselines only decreased.

The new tests and integrated revision have not yet received direct build-host validation because SSH to that host is unavailable. Hosted checks on this pushed head are pending. The earlier test result does not cover the newest changes.

Dependency and limits

This PR is stacked on #436 and includes main at 92dd2ae9cec1dc7dac16907e66d7b870694ebbbf. No live Android document-provider lifecycle or external-client test is claimed.

@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #447 / NC Native September 5, 2026 15:38 Destroyed
@obiente-cloud

obiente-cloud Bot commented Sep 5, 2026

Copy link
Copy Markdown

Obiente preview

NC Native · 22a87be1a332 · Ready

Open preview

View in Obiente

Obiente updates this comment as the preview changes.

@veryCrunchy
veryCrunchy marked this pull request as ready for review September 5, 2026 15:39
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #447 / NC Native September 5, 2026 15:39 Destroyed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 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-09T06:59:03.680526Z 91eaac0 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.

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

ℹ️ 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".

@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #447 / NC Native September 5, 2026 22:30 Destroyed
@veryCrunchy
veryCrunchy force-pushed the feature/account-credential-slots branch from a80069c to 722eb39 Compare September 5, 2026 22:42
@veryCrunchy
veryCrunchy force-pushed the fix/document-grant-incarnation branch from 00333f6 to 8266aab Compare September 5, 2026 22:53
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #447 / NC Native September 5, 2026 22:53 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: 8266aabbc2

ℹ️ 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".

@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #447 / NC Native September 5, 2026 23:19 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: e6b7830d96

ℹ️ 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".

@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #447 / NC Native September 5, 2026 23: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: 888fbf8e00

ℹ️ 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 feature/account-credential-slots branch 2 times, most recently from dfdae5f to 871e131 Compare September 6, 2026 04:42
@veryCrunchy
veryCrunchy force-pushed the fix/document-grant-incarnation branch from 888fbf8 to 74b43bf Compare September 6, 2026 04:48
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #447 / NC Native September 6, 2026 04:48 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: 74b43bf122

ℹ️ 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 feature/account-credential-slots branch from a10ff29 to 5bd8032 Compare September 6, 2026 05:05
@veryCrunchy
veryCrunchy force-pushed the fix/document-grant-incarnation branch from 74b43bf to b1fc365 Compare September 6, 2026 06:00
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #447 / NC Native September 6, 2026 06:00 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: b1fc365e26

ℹ️ 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".

@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #447 / NC Native September 6, 2026 06:20 Destroyed
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #447 / NC Native September 6, 2026 06:32 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: 904fa387ba

ℹ️ 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/document-grant-incarnation branch from 904fa38 to 8f53cf8 Compare September 6, 2026 07:07
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #447 / NC Native September 6, 2026 07:07 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: 8f53cf8e18

ℹ️ 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/document-grant-incarnation branch from e17cca5 to 8a804d3 Compare September 9, 2026 05:45
@obiente-cloud
obiente-cloud Bot temporarily deployed to Obiente Preview / PR #447 / NC Native September 9, 2026 05:45 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: 8a804d331c

ℹ️ 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".

Comment on lines +84 to +85
private fun NextcloudAccountRecord.documentAccountKeys(): Set<String> =
setOf(canonicalDocumentAccountKey(), NextcloudDocumentIds.accountKey(serverUrl, loginName))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retain prior raw keys for legacy document IDs

When an upgraded account has an nc1 document grant created before this change and is later reauthenticated with a canonically equivalent server spelling, this set contains only the canonical key and the replacement record's raw digest. The old raw digest is therefore unmatched, so requireAccount() rejects the retained document even though accountId and the account incarnation are unchanged. The fresh evidence after the earlier report is that the final resolver retains only the current raw digest rather than preserving or migrating the historical legacy alias.

AGENTS.md reference: AGENTS.md:L410-L411

Useful? React with 👍 / 👎.

Comment on lines +267 to +269
val rootIds = listOf(
NextcloudDocumentIds.rootId(accountIdentity, NextcloudDocumentIncarnation.Legacy),
NextcloudDocumentIds.rootId(accountIdentity, retired),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Revoke grants using the emitted canonical root ID

When account removal cleans up a grant created by this version, callers pass the legacy raw NextcloudDocumentIds.accountKey(session) as accountIdentity, but providerRootId(), documentId(), and rootId(session, ...) now emit the canonical accountId.storageKey.take(32) key. Constructing both retirement roots from the raw key means revokeUriPermission() never targets the actual canonical legacy or versioned URI, leaving the persisted Android grant installed after removal; build the incarnation root from accountStorageKey while retaining the raw form only for pre-migration grants.

AGENTS.md reference: AGENTS.md:L359-L364

Useful? React with 👍 / 👎.

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