Skip to content

[codex] Fix suite session recovery - #98

Closed
dijia702 wants to merge 35 commits into
sallowayma-git:feature/multi-device-easy-deployfrom
dijia702:codex/fix-suite-session-recovery
Closed

[codex] Fix suite session recovery#98
dijia702 wants to merge 35 commits into
sallowayma-git:feature/multi-device-easy-deployfrom
dijia702:codex/fix-suite-session-recovery

Conversation

@dijia702

@dijia702 dijia702 commented Aug 3, 2026

Copy link
Copy Markdown

Summary

  • Persist suite sessions immediately when a suite is created.
  • Restore active sessions from sessionStorage or localStorage and reopen the current passage after a main-page refresh.
  • Preserve drafts, timers, completed entries, sequence index, and suiteSessionId across navigation and file:// fallback paths.
  • Keep the suite snapshot when the active child window is closed; ignore stale-window close events from previous passages.
  • Add recovery/close regression coverage and rebuild runtime bundles.

Root cause

The parent page only mirrored suite state after later events, while child-window closure called _abortSuiteSession, which cleared the persisted snapshot. Refreshes and file:// storage differences could therefore lose the active suite.

Validation

  • Suite recovery, flow, state-machine, storage-fallback, inline fallback, and unified-reading regression tests pass.
  • file:// suite E2E flow passes.
  • Browser verification passes for close -> refresh -> resume.
  • JavaScript syntax checks pass.

The repository's existing static CI baseline still reports unrelated failures in CSS convergence, settings-button coverage, on-demand test mocks, service-facade CSS checks, and IndexedDB shadow cleanup.

lake0000 and others added 10 commits July 14, 2026 17:28
…e-london-shoes

修复语言的起源和伦敦鞋子
…q25-answer

修复交易的本能第25题答案
…field-feedback

修复Katherine Mansfield第6题答案
…explanation

修复羊毛产业的历史解析
- 依据「八月高频表格(2).xlsx」的「八月高频文章」本月频次更新 85 条 frequency
- A 组(在八月表内不一致)更新为八月本月频次;B 组按「全部文章」表频率;C 组(疑似过度标注)改为 low
- examId 保持不变;同步重建 core-foundation.bundle.js

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

ℹ️ 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 thread js/app/suitePracticeMixin.js Outdated
Comment thread js/app/suitePracticeMixin.js Outdated
Comment thread js/app/suitePracticeMixin.js Outdated
Comment thread developer/tests/ci/run_static_suite.py Outdated
Comment thread js/app/examSessionMixin.js Outdated

@k-undurkhaan-2 k-undurkhaan-2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Found three additional recovery regressions not covered by the current tests: a stale close watcher can detach a newly resumed window, a permanently invalid snapshot can trap suite mode in an endless retry loop, and the close path reports persistence success even when neither storage backend accepted the snapshot. Details are inline.

Comment thread js/app/examSessionMixin.js Outdated
Comment thread js/app/suitePracticeMixin.js
Comment thread js/app/examSessionMixin.js Outdated
@sallowayma-git
sallowayma-git changed the base branch from main to opensource August 3, 2026 14:50
@sallowayma-git

Copy link
Copy Markdown
Owner

已经针对审计出的八个comment进行了修复并提交,请PR owner在本地环境执行对抗审计 @dijia702

githubSINGLE and others added 2 commits August 5, 2026 21:51
…tmp-migration

1.升级v2数据层
2. 草稿与提交后注释持久化
3. 阅读显示控制
@k-undurkhaan-2

Copy link
Copy Markdown
Collaborator

协作者第二次独立审查结论报告:
5/8 条修复验证通过,均已回复并标记 resolved
3/8 条仍可复现,已在原线程补充证据并保持 unresolved

附加审查意见@dijia702 作为此PR之发起者,应保持对此PR状态的关注并适当地给予反馈并推动问题解决,因PR的发起者拥有对设计实现的最佳理解,亦可促进bug修复与开发协作。

已经针对审计出的八个comment进行了修复并提交,请PR owner在本地环境执行对抗审计 @dijia702

备注:PR owner仍需在本地环境执行此PR的代码审计操作

lake0000 and others added 2 commits August 7, 2026 01:07
* fix vocabulary list for v2 data layer

* fix legacy progress envelope handling
@sallowayma-git
sallowayma-git force-pushed the codex/fix-suite-session-recovery branch from 196aa17 to 738de54 Compare August 6, 2026 18:57

@k-undurkhaan-2 k-undurkhaan-2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The three previously open recovery fixes now pass revalidation. One new P2 persistence race remains.

Comment thread js/app/examSessionMixin.js Outdated
…ock, completed close

- G1: converge a recovered active-complete multi-suite session before a new run
- G5: keep window-WAL fallback when a durable recovery entry exists but is corrupt
- F3: set multi-suite recovery write-block on stale/group-conflict and short-circuit
- H1: mark a completed suite exam close as completed, not interrupted

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@k-undurkhaan-2 k-undurkhaan-2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-reviewed 48a7b4b. The previous in-flight draft race remains reproducible. This update also leaves two P2 recovery/ownership failures: a preserved multi-suite WAL cannot pass its next durable CAS after corrupt-durable fallback, and delayed completed-suite teardown can detach a newer ordinary practice session.

Comment thread js/app/suitePracticeMixin.js Outdated
Comment thread js/app/examSessionMixin.js
@k-undurkhaan-2

Copy link
Copy Markdown
Collaborator

@codex review

@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: 617b82221e

ℹ️ 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 thread js/app/suitePracticeMixin.js Outdated

@k-undurkhaan-2 k-undurkhaan-2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Found two additional recovery failures beyond the existing Codex cross-tab ownership finding. Both are reproducible with focused adversarial cases: exact cleanup misses the fallback-created recovery identity, and unsafe-revision repair is applied only to multi-suite recovery.

Comment thread js/app/examSessionMixin.js
Comment thread js/app/suitePracticeMixin.js

@k-undurkhaan-2 k-undurkhaan-2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two new P2 ownership races remain on 6a6e2c8: copied sessionStorage is not an exclusive tab lease, and a startup ownership failure is not propagated to the enclosing openExam flow. Both were reproduced with focused adversarial harnesses; the existing regression suites still pass.

Comment thread js/app/suitePracticeMixin.js Outdated
Comment thread js/app/examSessionMixin.js

@k-undurkhaan-2 k-undurkhaan-2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-reviewed e58f9ba. The two previously reported ownership races pass revalidation. One new P2 startup-recovery lock-order race remains; details are inline.

Comment thread js/app/suitePracticeMixin.js Outdated
@k-undurkhaan-2

Copy link
Copy Markdown
Collaborator

@codex review

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

ℹ️ 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 thread js/app/suitePracticeMixin.js

@k-undurkhaan-2 k-undurkhaan-2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the e58f9ba..bd6fe43 delta for merge blockers. Both addressed recovery defects pass independent revalidation, the affected regression suites and generated-bundle parity checks pass, and I found no new blocking regression in this update. Per review scope, systemic legacy debt is left for a separate PR; no new inline comments.

@githubSINGLE
githubSINGLE changed the base branch from opensource to feature/multi-device-easy-deploy August 9, 2026 02:57
@githubSINGLE

githubSINGLE commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

状态说明:当前 PR 的定位与 base 分支不匹配

核心修复有效

  • 原始 bug 确实修好了:套题会话在打开第一篇文章之前就已持久化到 AppData v2;每篇文章的结果在 ACK / 推进之前先提交到 v2。file:// 场景和刷新场景下的套题会话丢失,路径上已经堵住。
  • 相关测试通过suiteModeRegressionsuiteSessionRecoveryV2appDataV2suiteModeFlowunifiedReadingPageInlineSuiteRegression
  • round-8 的 P1(G1:恢复出来的 active-complete 多套题会话会阻塞下一轮)已经闭环,修在 js/app/suitePracticeMixin.js:5594,走的是幂等收敛(结果已齐但未 finalize 时先收敛再判断),处理方式是对的。

当前 PR 的定位与 base 分支不匹配

js/app/suitePracticeMixin.js:445_acquireSuiteRecoveryClaim 是一个约 100 行、基于 Web Locks(navigator.locks)的分布式租约管理器:pending / held / released 状态机、竞争检测、孤儿锁回收、级联释放、按 session 与按 id 双索引。配套的还有一整组同族方法——_releaseSuiteRecoveryClaim_transferSuiteRecoveryClaim_ownsSuiteRecoveryClaim_readSuiteRecoveryFence_markSuiteRecoveryLeaseContended_acquireMultiSuiteBaseClaim_releaseMultiSuiteBaseClaim_transferMultiSuiteBaseClaim_rejectMultiSuiteBaseClaimSession

数据层同步长出了配套原语(js/data/v2/appData.js,净 +289):recovery tombstones、getActiveSessionFence()cleanupForRetry()exclusiveGroup、以及 expectedEntityRevision 的 CAS 校验。

租约、fence、tombstone、exclusiveGroup、CAS——这些是**多写者(multiple writers)**场景的并发控制设施。而 opensource 当前是单机、单页的产品形态,README 第 221 行:

套题模式不适合在多个浏览器窗口中并行操作同一套题。并行操作会增加窗口引用、状态同步和记录归并的复杂度。

建议:本 PR 改指向 feature/multi-device-easy-deploy

上游已存在 feature/multi-device-easy-deploy0f0a04e2c944ed667566c2fe91a6b05c1cccfee3),方向上正是多设备 / 共享部署。在那条线上,多写者协调是真实需求而不是假想威胁,本 PR 的租约层、fence、tombstone、exclusiveGroup、CAS 都能各归其位,评审时也能按「它是否正确解决了多写者问题」来判定,而不是像现在这样卡在「这个问题在本分支存不存在」。

单机路线将另开一个 PR 指向 opensource

我会另外开一个指向 opensource 的、最小化的 PR(尚未创建),只包含单机核心修复:

  1. 打开首篇文章前先持久化套题会话(persist-before-open)
  2. 每篇结果在 ACK 前完成持久化提交(per-passage durable commit before ACK)
  3. 恢复时给出显式的「继续 / 放弃」选择
  4. 子窗口在最终 ACK 之后自行退出

不包含租约层。 目标是让 opensource 只承担它实际承诺的那部分复杂度。


小结:核心修复有效、测试可信、round-8 P1 已闭环;分歧只在落点——建议本 PR 改指向 feature/multi-device-easy-deploy,单机最小修复另起一个 PR 指向 opensource

@k-undurkhaan-2

Copy link
Copy Markdown
Collaborator

单机分离PR已提交为#106 PR,当前CI通过,从临时codex/分支指向open source,merge完成后删除此codex/临时分支,并计划关闭当前#98 PR

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.

5 participants