Skip to content

fix(kit): preserve offline scopes across auth recovery - #37

Merged
rdlabo merged 3 commits into
mainfrom
fix/auth-resume-lease
Jul 25, 2026
Merged

fix(kit): preserve offline scopes across auth recovery#37
rdlabo merged 3 commits into
mainfrom
fix/auth-resume-lease

Conversation

@rdlabo

@rdlabo rdlabo commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve valid offline scope ID 0 instead of silently dropping it
  • issue a post-grant auth lease to remote resume work
  • cover logout/revocation races before user-visible resume effects
  • add an activation-to-resume integration test for scope 0

Compatibility

  • KitRemoteAccessRecovery.resume keeps its parameter optional, so existing zero-argument implementations remain source-compatible
  • nonzero offline scope behavior is unchanged

Validation

  • npx ng test kit --watch=false (35 files / 488 tests)
  • npm run lint
  • npm run prebuild:kit
  • git diff --check

@netlify

netlify Bot commented Jul 25, 2026

Copy link
Copy Markdown

Deploy Preview for rdlabo-ionic-angular-library ready!

Name Link
🔨 Latest commit 5ff1a00
🔍 Latest deploy log https://app.netlify.com/projects/rdlabo-ionic-angular-library/deploys/6a6472c7f9cb37000813f4d4
😎 Deploy Preview https://deploy-preview-37--rdlabo-ionic-angular-library.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@rdlabo rdlabo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

第三者受け入れレビュー: APPROVED(GitHub の制約上、PR 作成者本人のアカウントから Approve を選べないためコメントとして記録)

独立検証結果:

  • scopeIds: [0]OfflineSessionService.activateSession() で除外されず、manifest の [0]getSession().scopes{ userId, groupId: 0 }resumeRemoteSession() の初回 pull まで維持されることを確認しました。
  • guard と API-only recovery の両方で、grantRemote() 後に専用の post-grant lease が発行されます。resume() の await 中に KitAuthAccessService.clear() が走る再現で lease が stale となり、lease を確認する user-visible side effect が実行されないことを確認しました。
  • resume(lease?: KitAuthAccessLease) は optional parameter なので、従来の resume: async () => ... / resume(): Promise<void> 実装と source/runtime compatible です。既存の引数なし実装を含む kit 全テストがコンパイル・pass しています。

ローカル再検証: npx ng test kit --watch=false = 35 files / 488 tests pass、git diff --check pass。GitHub CI も必須ジョブを含め green です。

補足: tipsys 側のリダイレクト等は、受け取った optional lease を resume の各 await 後に確認する実装へ更新する必要があります。これは本PRが提供する契約どおりです。

@rdlabo rdlabo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

再受け入れレビュー(head 6b3dabf): APPROVED

前回承認後に指摘された同期通知 race を独立再検証しました。

  • grantRemote() は publication revision を確定してから mode$.next("remote") を同期通知し、その同じ revision の lease を返します。通知 subscriber が同期的に clear() / logout を開始すると revision が進むため、返却 lease は既に stale です。guard / recovery は新しい beginTransition() を後置せず、この stale lease をそのまま resume() へ渡すので、旧 flight が logout transition を上書きしません。
  • guard と API-only recovery の両方で、remote 通知 subscriber が同期 clear() する再現テストを確認しました。結果は access mode none、guard false、user-visible effect 未実行です。
  • scope 0 は引き続き manifest → remote session → resume → pull { userId, groupId: 0 } まで維持されます。
  • resume(lease?: KitAuthAccessLease) の optional 契約は変わらず、既存の引数なし resume(): Promise<void> 実装もコンパイル・実行されています。grantRemote() の戻り値追加も、既存の戻り値を無視する呼び出しを壊しません。

ローカル再検証: npx ng test kit --watch=false = 35 files / 490 tests pass、git diff --check pass。ブロッカーはありません。

GitHub の自己承認制約があるため、Approve 状態ではなくレビューコメントとして記録します。

@rdlabo rdlabo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

最終再受け入れレビュー(head 5ff1a00): APPROVED

上長2回目指摘への修正を独立再検証しました。

  • guard: grantRemote() が返した publication lease を同期通知直後に検査し、subscriber の clear() / logout で stale なら false を返して resume() を呼びません。
  • API-only recovery: 同じく stale publication lease を検査して return し、resume() を呼びません。
  • 両再現テストで resume spy が未呼び出し、user-visible effect 未実行、access mode none を確認しました。旧 flight が pull・redirect等の resume workを開始する余地を閉じています。
  • 以前確認した scope 0 の manifest → remote session → pull 維持、および optional resume(lease?) による従来の引数なし resume(): Promise<void> 互換に変更はありません。

ローカル再検証: focused 2 files / 56 tests pass、git diff --check clean。新 head にブロッカーはありません。

GitHub の自己承認制約があるため、Approve 状態ではなくレビューコメントとして記録します。

@rdlabo
rdlabo marked this pull request as ready for review July 25, 2026 08:27
@rdlabo
rdlabo merged commit e77caec into main Jul 25, 2026
12 checks passed

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

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