Skip to content

fix(data): isolate trusted owner grants and dispose replicas locally - #2997

Merged
trueadm merged 5 commits into
octanejs:mainfrom
openai-oss-forks:fix/data-owner-account-lifecycle
Nov 16, 2026
Merged

trueadm merged 5 commits into
octanejs:mainfrom
openai-oss-forks:fix/data-owner-account-lifecycle

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add trusted, explicit account activation for a shared data owner and isolate each durable grant from stale replicas and in-flight writes.
  • Add local store and replica disposal that preserves peers and persistence; skip quota estimation for fixed persistence budgets.

Why

A replica could previously reclaim the account fence after another account became active, and retiring a window cleared persistence used by peers. An old owner's delayed commit could also reach a newly activated account's cache. Separately, a fixed numeric budget unnecessarily blocked a first read on quota estimation (fixes #2992).

Changes

  • fence: 'explicit' makes DataOwner.activate(account | null) the trusted control path. Replica joins cannot activate accounts or request global erasure. Explicit mode uses its own fence namespace and a generation-specific persisted partition.
  • dispose() releases local store or replica resources without signing out other replicas or clearing their cache. retire() retains its existing global account-lifecycle meaning where supported.
  • Numeric budgets skip device-hint lookup. Automatic and callback budgets retain their existing behavior.
  • Add regression coverage for stale reconnects, failed/concurrent activation, delayed or missed grant notifications, old writes, mixed-version isolation, in-flight and queued disposal, peer retirement with offline restart, and fixed-budget reads. Update Shelf's shared-worker test keeper to the current protocol.

Validation

  • pnpm format:check (repo-wide; scoped formatting passed)
  • pnpm typecheck (repo-wide; scoped TypeScript check passed)
  • pnpm test (repo-wide; owning suites run locally)
  • Targeted owner and persistence suites: 122 passed; existing data-store suite: 50 passed. Six timing-sensitive disposal and grant regressions also passed independently.
  • Shelf production-preview browser journeys: 5 passed, covering shared-tab rollback, signout, worker crash/reconnect, and cache reload.
  • Motion Vite SSR/hydration integration target passed independently. Its single-test timeout is 15 seconds: the unchanged base passed in 5.001 seconds under the previous 5-second default, and CI exceeded that limit. Assertions and cleanup are unchanged. Broader Motion validation is left to CI because the local narrowed config had fixture/runtime wiring differences.
  • pnpm run sync completed with dependency-state warnings for unrelated prepared workspace modules; generated tracked files remained clean.
  • perf-review: node scripts/perf-review-scan.mjs --base upstream/main --json returned []. Admission runs per replica, activation per trusted account transition, budget selection once per persistence instance, and disposal on a cold lifecycle path. No new render, DOM, per-item allocation, recurring task path, or ordinary store initialization transaction. Same browser esbuild comparison against 0.19.2: direct store +377 minified bytes (+161 gzip); owner exports +2,962 minified bytes (+871 gzip). No remaining must-fix or needs-evidence findings.
  • concise-code: runtime source +287/-70 lines. Explicit activation and local disposal are required by the reproductions; generation-specific partitions prevent delayed writes from contaminating a new grant. Automatic fencing for independent stores was rejected because it cannot establish trusted admission. No new module or generic checkpoint API.
  • Independent complexity review and git diff --check passed.

Risk / follow-ups

  • The host must authorize and sequence activation. Independent stores still cannot coordinate account-wide logout by themselves.
  • Old-owner writes are isolated from the new grant immediately, but physical deletion can lag until old owners drain. Hosts requiring deletion by logout completion must stop and await those writers.
  • Explicit mode uses a separate namespace and starts with a cold cache when migrating from the legacy owner.

Provenance

  • An agent produced this diff (agent-authored)

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Note

High Risk
Changes account fencing, trusted activation, and persistence lifecycle; incorrect host sequencing could leave stale grants or cross-generation cache contamination.

Overview
Adds dispose() so a tab or replica can shut down locally—flushing queued saves when persistence is up—without retire()’s account-wide sign-out or cache wipe. Replicas send disconnect instead of retiring peers; owner protocol bumps to v5.

Introduces fence: 'explicit' with trusted DataOwner.activate(account | null): separate IndexedDB/BroadcastChannel namespace, generation-scoped persistence partitions, and admission only for activated grants. Replica retire / persist clear no longer revoke other tabs in this mode.

Fixed numeric persistence budgets skip deviceHints() so first reads are not blocked on quota estimation.

Reviewed by Cursor Bugbot for commit 304540d. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Nov 16, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review November 16, 2026 20:52

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit ad707f5. Configure here.

Comment thread packages/octane/src/data/persist.ts Resolved
Comment thread packages/octane/src/data/owner.ts Resolved
Comment thread packages/octane/src/data/owner.ts Resolved
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No byte growth, no added work, and no timing changes beyond ±3%.

Compares 522496375, the merge commit's first parent with df37b884e on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 5.808 5.158 +2.0% −5.4% … +14.1% ⚪ within noise
octane-tsrx replace 13.142 15.058 +17.7% +2.3% … +33.3% ⚪ within noise
octane-tsrx add 4.333 4.425 +4.5% −9.6% … +14.0% ⚪ within noise
octane-tsrx update 0.129 0.115 −4.6% −8.7% … ±0.0% ⚪ within noise
octane-tsrx select 0.009 0.008 −12.9% −20.0% … −1.6% ⚪ within noise
octane-tsrx swap 0.030 0.028 −3.6% −6.2% … +3.2% ⚪ within noise
octane-tsrx remove 0.025 0.026 ±0.0% −7.4% … +3.1% ⚪ within noise
octane-tsrx runlots 35.425 32.683 +2.7% −8.8% … +14.7% ⚪ within noise
octane-tsrx select_lots 0.010 0.010 +1.3% −5.4% … +13.1% ⚪ within noise
octane-tsrx clear 60.542 62.683 +7.4% −10.6% … +13.6% ⚪ within noise
octane-jsx run 5.833 5.500 +0.9% −10.1% … +8.7% ⚪ within noise
octane-jsx replace 14.583 15.267 −3.8% −11.9% … +6.3% ⚪ within noise
octane-jsx add 6.300 6.667 +8.3% −10.8% … +30.4% ⚪ within noise
octane-jsx update 0.269 0.274 −3.6% −9.3% … +9.9% ⚪ within noise
octane-jsx select 0.134 0.138 −2.4% −8.5% … +7.5% ⚪ within noise
octane-jsx swap 0.190 0.195 +10.3% +2.5% … +29.0% ⚪ within noise
octane-jsx remove 0.183 0.175 −3.4% −8.4% … +9.9% ⚪ within noise
octane-jsx runlots 44.200 46.800 +6.8% −8.6% … +22.0% ⚪ within noise
octane-jsx select_lots 1.481 1.597 +3.5% −9.5% … +12.5% ⚪ within noise
octane-jsx clear 70.942 69.317 +2.9% −5.0% … +23.0% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 111 measured values.

Public-import reachability bundles (bytes)

No changes across 141 measured values.

@trueadm
trueadm merged commit 32e6a02 into octanejs:main Nov 16, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

data: fixed persistence budget unnecessarily blocks first read on storage quota estimate

2 participants