telepost-bot 2.84.7__tar.gz → 2.84.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/CHANGELOG.md +14 -0
  2. {telepost_bot-2.84.7/telepost_bot.egg-info → telepost_bot-2.84.9}/PKG-INFO +1 -1
  3. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/database/db_manager.py +9 -0
  4. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/recovery.py +19 -12
  5. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/main.py +9 -1
  6. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/recovery.py +81 -75
  7. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/build_info.py +1 -1
  8. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/sqlite/recovery.py +36 -19
  9. {telepost_bot-2.84.7 → telepost_bot-2.84.9/telepost_bot.egg-info}/PKG-INFO +1 -1
  10. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost_bot.egg-info/SOURCES.txt +2 -0
  11. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_recovery.py +6 -2
  12. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_recovery_answer_first.py +5 -4
  13. telepost_bot-2.84.9/tests/test_recovery_reconciliation.py +69 -0
  14. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_schedule_outcomes.py +28 -0
  15. telepost_bot-2.84.9/tests/test_webhook_registration.py +28 -0
  16. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/api_server.py +11 -0
  17. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/webhook_server.py +46 -0
  18. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/LICENSE +0 -0
  19. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/MANIFEST.in +0 -0
  20. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/README.en.md +0 -0
  21. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/README.md +0 -0
  22. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/config/__init__.py +0 -0
  23. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/config/fly-telepost-policy.example.json +0 -0
  24. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/config/review_policy.md +0 -0
  25. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/config/settings.py +0 -0
  26. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/config.ini.example +0 -0
  27. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/database/__init__.py +0 -0
  28. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/__init__.py +0 -0
  29. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/api_commands.py +0 -0
  30. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/automation.py +0 -0
  31. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/botconfig.py +0 -0
  32. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/callback_handlers.py +0 -0
  33. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/channel_listener.py +0 -0
  34. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/command_handlers.py +0 -0
  35. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/conversation.py +0 -0
  36. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/error_handler.py +0 -0
  37. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/index_handlers.py +0 -0
  38. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/mode_selection.py +0 -0
  39. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/moderation.py +0 -0
  40. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/preview_handlers.py +0 -0
  41. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/publish.py +0 -0
  42. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/reaction_stats.py +0 -0
  43. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/review.py +0 -0
  44. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/schedule_status.py +0 -0
  45. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/search_handlers.py +0 -0
  46. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/stats_handlers.py +0 -0
  47. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/handlers/upload.py +0 -0
  48. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/mcp_server/__init__.py +0 -0
  49. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/mcp_server/review_client.py +0 -0
  50. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/mcp_server/server.py +0 -0
  51. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/models/__init__.py +0 -0
  52. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/models/state.py +0 -0
  53. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/__init__.py +0 -0
  54. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/SOURCES.sha256 +0 -0
  55. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/__init__.py +0 -0
  56. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/error-mapping.json +0 -0
  57. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/fixtures/ackresult.candidate_search.json +0 -0
  58. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/fixtures/capabilities.pixivflow.json +0 -0
  59. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/fixtures/event.job.expired.json +0 -0
  60. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/fixtures/event.job.succeeded.json +0 -0
  61. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/fixtures/eventpage.candidate_search.json +0 -0
  62. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/fixtures/job.cancelled.candidate_search.json +0 -0
  63. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/fixtures/job.failed.no_candidate.json +0 -0
  64. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/fixtures/job.queued.json +0 -0
  65. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/fixtures/job.running.json +0 -0
  66. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/fixtures/job.succeeded.candidate_search.json +0 -0
  67. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/fixtures/jobpage.candidate_search.json +0 -0
  68. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/fixtures/task.candidate_search.json +0 -0
  69. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/fixtures/task.candidate_search.target_only.json +0 -0
  70. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/protocol/v1/protocol.schema.json +0 -0
  71. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/pyproject.toml +0 -0
  72. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/run.py +0 -0
  73. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/services/__init__.py +0 -0
  74. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/services/review_service.py +0 -0
  75. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/setup.cfg +0 -0
  76. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/__init__.py +0 -0
  77. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/api/__init__.py +0 -0
  78. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/__init__.py +0 -0
  79. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/admin_ops.py +0 -0
  80. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/automation.py +0 -0
  81. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/delivery_planner.py +0 -0
  82. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/editorial.py +0 -0
  83. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/hot.py +0 -0
  84. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/novel_fallback_card.py +0 -0
  85. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/novel_preview.py +0 -0
  86. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/pixivflow_jobs.py +0 -0
  87. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/post_media.py +0 -0
  88. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/posts.py +0 -0
  89. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/publication.py +0 -0
  90. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/reaction_backfill.py +0 -0
  91. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/refetch.py +0 -0
  92. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/rerender.py +0 -0
  93. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/resubmit.py +0 -0
  94. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/review_queue.py +0 -0
  95. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/submitter_notify.py +0 -0
  96. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/application/telepress_provider.py +0 -0
  97. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/__init__.py +0 -0
  98. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/automation.py +0 -0
  99. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/delivery.py +0 -0
  100. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/editorial.py +0 -0
  101. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/errors.py +0 -0
  102. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/hot.py +0 -0
  103. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/media.py +0 -0
  104. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/navigation.py +0 -0
  105. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/novel_preview.py +0 -0
  106. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/packing.py +0 -0
  107. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/presentation.py +0 -0
  108. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/presentation_policy.py +0 -0
  109. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/refetch_state.py +0 -0
  110. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/review.py +0 -0
  111. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/review_chat.py +0 -0
  112. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/domain/submission.py +0 -0
  113. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/miniapp/__init__.py +0 -0
  114. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/miniapp/auth.py +0 -0
  115. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/miniapp/rbac.py +0 -0
  116. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/miniapp/role_bindings.py +0 -0
  117. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/miniapp/session.py +0 -0
  118. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/observability/__init__.py +0 -0
  119. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/observability/audit.py +0 -0
  120. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/observability/cli.py +0 -0
  121. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/observability/doctor.py +0 -0
  122. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/observability/errors.py +0 -0
  123. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/observability/redact.py +0 -0
  124. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/__init__.py +0 -0
  125. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/sqlite/__init__.py +0 -0
  126. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/sqlite/automation.py +0 -0
  127. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/sqlite/columns.py +0 -0
  128. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/sqlite/editorial.py +0 -0
  129. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/sqlite/inbox.py +0 -0
  130. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/sqlite/ledger.py +0 -0
  131. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/sqlite/media_assets.py +0 -0
  132. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/sqlite/moderation.py +0 -0
  133. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/sqlite/novel_preview.py +0 -0
  134. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/sqlite/posts.py +0 -0
  135. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/sqlite/protocol_events.py +0 -0
  136. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/sqlite/refetch.py +0 -0
  137. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/sqlite/reviews.py +0 -0
  138. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/storage/sqlite/submitter_notifications.py +0 -0
  139. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/__init__.py +0 -0
  140. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/callback_feedback.py +0 -0
  141. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/capture.py +0 -0
  142. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/delivery/__init__.py +0 -0
  143. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/delivery/discussion.py +0 -0
  144. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/delivery/executor.py +0 -0
  145. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/delivery/gateway.py +0 -0
  146. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/delivery/legacy_runner.py +0 -0
  147. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/delivery/planner.py +0 -0
  148. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/delivery/preparation.py +0 -0
  149. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/delivery/registry.py +0 -0
  150. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/delivery/sender.py +0 -0
  151. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/inbox_worker.py +0 -0
  152. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/review_expiry.py +0 -0
  153. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/review_keyboard.py +0 -0
  154. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/review_media.py +0 -0
  155. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost/telegram/review_stager.py +0 -0
  156. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost_bot.egg-info/dependency_links.txt +0 -0
  157. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost_bot.egg-info/entry_points.txt +0 -0
  158. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost_bot.egg-info/requires.txt +0 -0
  159. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/telepost_bot.egg-info/top_level.txt +0 -0
  160. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_admin_api.py +0 -0
  161. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_anonymous.py +0 -0
  162. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_api_commands.py +0 -0
  163. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_api_server.py +0 -0
  164. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_api_version.py +0 -0
  165. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_architecture_application.py +0 -0
  166. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_architecture_core.py +0 -0
  167. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_automation.py +0 -0
  168. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_backfill_attribution.py +0 -0
  169. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_blacklist.py +0 -0
  170. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_bot_language.py +0 -0
  171. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_bot_token_logging.py +0 -0
  172. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_botconfig.py +0 -0
  173. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_boundary.py +0 -0
  174. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_callback_contract.py +0 -0
  175. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_caption_mentions.py +0 -0
  176. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_compatibility.py +0 -0
  177. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_config_encoding.py +0 -0
  178. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_console_encoding.py +0 -0
  179. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_conversation_flow.py +0 -0
  180. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_data_class_cleanup.py +0 -0
  181. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_database.py +0 -0
  182. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_database_first_start.py +0 -0
  183. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_database_operations.py +0 -0
  184. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_delivery_planner.py +0 -0
  185. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_discussion_uncertainty.py +0 -0
  186. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_disposition.py +0 -0
  187. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_doctor.py +0 -0
  188. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_editorial.py +0 -0
  189. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_file_validator.py +0 -0
  190. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_fly_deploy_contract.py +0 -0
  191. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_frozen_support.py +0 -0
  192. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_handlers.py +0 -0
  193. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_heat_calculator.py +0 -0
  194. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_helper_functions.py +0 -0
  195. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_hot_domain.py +0 -0
  196. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_identity_provenance.py +0 -0
  197. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_install_scripts.py +0 -0
  198. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_integration.py +0 -0
  199. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_legacy_delivery_port_navigation.py +0 -0
  200. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_logic_flow.py +0 -0
  201. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_logical_submissions.py +0 -0
  202. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_maintenance_jobs.py +0 -0
  203. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_manager_notifications.py +0 -0
  204. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_media_decision_audit.py +0 -0
  205. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_media_delivery_pipeline.py +0 -0
  206. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_media_domain.py +0 -0
  207. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_media_preparation.py +0 -0
  208. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_media_proxy_delivery.py +0 -0
  209. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_menu_shortcut_single_reply.py +0 -0
  210. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_messages.py +0 -0
  211. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_miniapp_api.py +0 -0
  212. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_miniapp_auth.py +0 -0
  213. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_miniapp_content.py +0 -0
  214. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_miniapp_entries.py +0 -0
  215. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_miniapp_history.py +0 -0
  216. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_miniapp_rbac.py +0 -0
  217. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_mixed_media_integrity.py +0 -0
  218. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_moderation_and_admin_ux.py +0 -0
  219. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_navigation.py +0 -0
  220. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_no_owner_probe.py +0 -0
  221. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_novel_cover_preview.py +0 -0
  222. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_novel_delivery_semantics.py +0 -0
  223. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_novel_preview.py +0 -0
  224. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_observability.py +0 -0
  225. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_observability_lifecycle.py +0 -0
  226. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_online_reading_root_button.py +0 -0
  227. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_packing_ssot.py +0 -0
  228. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_polling_server.py +0 -0
  229. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_preview_pagination.py +0 -0
  230. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_production_handler_graph.py +0 -0
  231. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_protocol_contract.py +0 -0
  232. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_publication_presentation.py +0 -0
  233. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_publish_idempotency.py +0 -0
  234. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_publish_regressions.py +0 -0
  235. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_publish_reply.py +0 -0
  236. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_reaction_backfill.py +0 -0
  237. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_reaction_stats.py +0 -0
  238. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_refetch.py +0 -0
  239. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_refetch_card_state.py +0 -0
  240. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_refetch_events.py +0 -0
  241. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_refetch_job_lifecycle.py +0 -0
  242. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_refetch_reason_normalization.py +0 -0
  243. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_refetch_replacement.py +0 -0
  244. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_remote_fetch_fallback.py +0 -0
  245. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_rerender.py +0 -0
  246. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_resubmit.py +0 -0
  247. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_review.py +0 -0
  248. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_review_album_payload.py +0 -0
  249. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_review_card_recovery.py +0 -0
  250. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_review_chat_contract.py +0 -0
  251. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_review_consistency.py +0 -0
  252. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_review_expiry_recovery.py +0 -0
  253. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_review_http_mcp.py +0 -0
  254. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_review_media_lifecycle.py +0 -0
  255. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_review_service.py +0 -0
  256. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_robustness.py +0 -0
  257. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_run_dispatcher.py +0 -0
  258. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_run_mode.py +0 -0
  259. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_run_supervisor.py +0 -0
  260. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_search_disabled_hint.py +0 -0
  261. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_search_recovery.py +0 -0
  262. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_security.py +0 -0
  263. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_security_headers.py +0 -0
  264. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_session_database_handles.py +0 -0
  265. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_shutdown.py +0 -0
  266. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_staging_recovery.py +0 -0
  267. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_streaming_uploads.py +0 -0
  268. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_submission_timeout_idempotency.py +0 -0
  269. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_telegram_golden_messages.py +0 -0
  270. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_telegram_media_cache.py +0 -0
  271. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_update_inbox.py +0 -0
  272. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_upload.py +0 -0
  273. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_user_friendly_messages.py +0 -0
  274. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_webhook_payload_admission.py +0 -0
  275. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_webhook_ready.py +0 -0
  276. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_webhook_router.py +0 -0
  277. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_webhook_secret.py +0 -0
  278. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_webhook_secret_logging.py +0 -0
  279. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_webhook_static.py +0 -0
  280. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/tests/test_work_id_wire.py +0 -0
  281. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/ui/__init__.py +0 -0
  282. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/ui/i18n.py +0 -0
  283. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/ui/keyboards.py +0 -0
  284. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/ui/locales/en/LC_MESSAGES/telepost.mo +0 -0
  285. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/ui/locales/en/LC_MESSAGES/telepost.po +0 -0
  286. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/ui/messages.py +0 -0
  287. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/__init__.py +0 -0
  288. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/api_tokens.py +0 -0
  289. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/blacklist.py +0 -0
  290. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/cache.py +0 -0
  291. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/config_wizard.py +0 -0
  292. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/console.py +0 -0
  293. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/database.py +0 -0
  294. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/file_validator.py +0 -0
  295. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/heat_calculator.py +0 -0
  296. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/helper_functions.py +0 -0
  297. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/index_manager.py +0 -0
  298. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/logging_config.py +0 -0
  299. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/maintenance_jobs.py +0 -0
  300. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/polling_server.py +0 -0
  301. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/run_mode.py +0 -0
  302. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/runtime_policy.py +0 -0
  303. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/schedule_watchdog.py +0 -0
  304. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/search_engine.py +0 -0
  305. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/security_headers.py +0 -0
  306. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/utils/submission.py +0 -0
  307. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/webapp/__init__.py +0 -0
  308. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/webapp/dist/assets/2d82b92e720462f8dd3b-Bh4Fahcw.svg +0 -0
  309. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/webapp/dist/assets/index-CLfkW8eZ.css +0 -0
  310. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/webapp/dist/assets/index-CfjBQN_e.js +0 -0
  311. {telepost_bot-2.84.7 → telepost_bot-2.84.9}/webapp/dist/index.html +0 -0
@@ -8,6 +8,20 @@
8
8
  > 发布说明面向普通用户:写「对用户有什么改变」,不写内部实现细节(模块名、函数名、配置键);
9
9
  > 技术细节放进代码注释或 `docs/`。每个 Release 的正文由本文件对应版本段自动生成。
10
10
 
11
+ ## [2.84.9](https://github.com/redtidev1918/TelePost/compare/v2.84.8...v2.84.9) (2026-10-25)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * **recovery:** converge on remote execution truth, drop local age verdicts ([#360](https://github.com/redtidev1918/TelePost/issues/360)) ([bec7bb8](https://github.com/redtidev1918/TelePost/commit/bec7bb80fb99a51721d68ec0d75fef23bff460f3))
17
+
18
+ ## [2.84.8](https://github.com/redtidev1918/TelePost/compare/v2.84.7...v2.84.8) (2026-10-25)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * keep recovery buttons so a failed attempt can be retried ([#358](https://github.com/redtidev1918/TelePost/issues/358)) ([ee92b08](https://github.com/redtidev1918/TelePost/commit/ee92b085e8946ab6b9702515baaa5207dcf667e1))
24
+
11
25
  ## [2.84.7](https://github.com/redtidev1918/TelePost/compare/v2.84.6...v2.84.7) (2026-10-25)
12
26
 
13
27
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: telepost-bot
3
- Version: 2.84.7
3
+ Version: 2.84.9
4
4
  Summary: Telegram submission, review, and publication bot with a Mini App, HTTP API, and multi-bot supervisor.
5
5
  Author: redtidev1918
6
6
  License-Expression: MIT
@@ -602,6 +602,15 @@ async def init_db():
602
602
  "ON recovery_attempts(target_id) "
603
603
  "WHERE state IN ('requested','accepted')"
604
604
  )
605
+ recovery_columns = {r[1] for r in await (await conn.execute(
606
+ 'PRAGMA table_info(recovery_attempts)')).fetchall()}
607
+ for column, ddl in (
608
+ ('remote_state', "TEXT NOT NULL DEFAULT ''"),
609
+ ('last_checked_at', 'REAL'),
610
+ ('reconciliation_required', 'INTEGER NOT NULL DEFAULT 0'),
611
+ ):
612
+ if column not in recovery_columns:
613
+ await conn.execute(f'ALTER TABLE recovery_attempts ADD COLUMN {column} {ddl}')
605
614
  await conn.execute(
606
615
  'CREATE INDEX IF NOT EXISTS idx_recovery_target '
607
616
  'ON recovery_attempts(target_id, created_at DESC)'
@@ -2,9 +2,11 @@
2
2
 
3
3
  ``sched_recover|<target_id>|<normal|relaxed>`` — one button row per FAILED
4
4
  target on the terminal schedule message. Clicking admits a durable recovery
5
- attempt (idempotent per callback id; one active recovery per target), shows the
6
- operator a business-friendly "accepted/queued" answer, and removes the buttons
7
- so the same outcome cannot be re-clicked into a second attempt.
5
+ attempt (idempotent per callback id) and shows the operator a
6
+ business-friendly "accepted/queued" answer. The buttons STAY on the message:
7
+ re-clicks are governed by the data layer (one active attempt per target;
8
+ active →「正在恢复中」, terminal → a fresh attempt), so a failed recovery can
9
+ always be retried from the same message.
8
10
  """
9
11
  from __future__ import annotations
10
12
  from ui.i18n import tr
@@ -89,22 +91,27 @@ async def schedule_recover(update: Update, context: CallbackContext) -> None:
89
91
  # leaves the operator with a dead spinner and dead-letters the update.
90
92
  logger.exception("恢复请求处理异常: target=%s", target_id)
91
93
  await _answer(query, tr('恢复请求处理异常,请稍后重试'), show_alert=True)
92
- return
94
+ raise
93
95
 
94
96
  label = MODE_LABEL.get(mode, tr('重试'))
95
97
  reply = tr('✅ 已提交{p0}:系统会自动继续处理。').format(p0=label)
96
98
  if mode == "relaxed":
97
99
  reply += f"\n{RELAXED_EXPLANATION}"
98
- await _answer(query, reply)
99
100
  if result.get("already_running"):
100
101
  await _answer(query, ALREADY_TEXT)
101
102
  return
102
- # Remove the buttons: the outcome message is terminal history; the recovery
103
- # itself reports through its own schedule-outcome notification.
104
- try:
105
- await query.edit_message_reply_markup(reply_markup=None)
106
- except Exception as exc:
107
- logger.debug("移除恢复按钮失败: %s", exc)
103
+ if result.get('replayed') and result.get('state') != 'requested':
104
+ await _answer(query, str(result['state']))
105
+ return
106
+ await _answer(query, reply)
107
+ # KEEP the buttons (2026-10-25 UX fix): removing them after one click
108
+ # left the operator with no retry entry at all once the attempt
109
+ # terminalized (no_candidate / submit exhausted) — the outcome message is
110
+ # the ONLY surface carrying these buttons, and failed-recovery outcome
111
+ # messages deliberately carry none. Re-clicks are safe and informative:
112
+ # while an attempt is active the partial-UNIQUE answers「正在恢复中」,
113
+ # after a terminal outcome a fresh attempt is admitted, and PixivFlow
114
+ # refuses recovery of already-consumed targets with a clear error.
108
115
  # Out-of-band remote submission (same requestId; idempotent on PixivFlow).
109
116
  # Only for rows still awaiting submission — a replayed/terminal row must
110
117
  # not be resurrected by a second submit.
@@ -142,4 +149,4 @@ async def schedule_recover(update: Update, context: CallbackContext) -> None:
142
149
  tasks.add(task)
143
150
  task.add_done_callback(tasks.discard)
144
151
  except Exception:
145
- logger.exception("创建恢复后台提交任务失败: target=%s", target_id)
152
+ logger.exception("创建恢复后台提交任务失败: target=%s", target_id)
@@ -565,6 +565,14 @@ async def main():
565
565
  sys.exit(1)
566
566
 
567
567
  if success:
568
+ from utils.webhook_server import verify_webhook
569
+ await verify_webhook(application, WEBHOOK_URL, WEBHOOK_PATH, secret_token)
570
+
571
+ async def verify_registration(context):
572
+ await verify_webhook(application, WEBHOOK_URL, WEBHOOK_PATH, secret_token)
573
+
574
+ application.job_queue.run_repeating(
575
+ verify_registration, interval=60, first=60, name='webhook_registration')
568
576
  logger.info("✅ Webhook 模式已启动")
569
577
  logger.info(f" 监听地址: 0.0.0.0:{WEBHOOK_PORT}{WEBHOOK_PATH}")
570
578
  logger.info(f" 外部地址: {WEBHOOK_URL}{WEBHOOK_PATH}")
@@ -882,7 +890,7 @@ def setup_application(application):
882
890
  await poll_refetch_jobs(context.bot, force=True)
883
891
  await reconcile_incomplete_reviews(context.bot)
884
892
  # §manual-recovery answer-first 兜底:后台提交任务随进程死掉时,
885
- # 按 requestId 幂等重投 'requested' 恢复行;超龄终态化(带审计)。
893
+ # 按 requestId 查询执行权威;超龄未确认保留互斥,不能推断远端失败。
886
894
  from telepost.application.recovery import resubmit_pending_recoveries
887
895
  try:
888
896
  await resubmit_pending_recoveries()
@@ -187,11 +187,10 @@ async def submit_recovery(target_id: str, request_id: str,
187
187
  terminal_on_failure: bool = True) -> dict:
188
188
  """POST the durable recovery to PixivFlow and settle the attempt row.
189
189
 
190
- ``terminal_on_failure=False`` (the background/sweep path) keeps TRANSIENT
191
- failures in state ``requested`` so the periodic sweep retries them with
192
- the SAME requestId (PixivFlow converges); non-retryable failures
193
- terminalize either way. The synchronous default preserves the historical
194
- contract of :func:`request_target_recovery` for non-inbox callers.
190
+ Transient failures retain the same requestId. Non-retryable admission
191
+ errors require reconciliation: a previous response may already have been
192
+ lost, so rejection of this HTTP request cannot terminate that execution.
193
+ ``terminal_on_failure`` preserves synchronous error reporting only.
195
194
  """
196
195
  mode = _normalize_mode(retry_mode)
197
196
  # Remote submission is async: the endpoint answers once the attempt is
@@ -228,15 +227,17 @@ async def submit_recovery(target_id: str, request_id: str,
228
227
  except Exception as exc:
229
228
  failure = _classify_recovery_error(exc)
230
229
  code = failure["code"]
231
- terminal = terminal_on_failure or not failure.get("retryable", False)
230
+ # A lost HTTP response is not proof that admission failed. Even the
231
+ # synchronous caller must retain the same durable identity and lock.
232
+ terminal = not failure.get("retryable", False)
232
233
  if terminal:
233
234
  async with db_manager.get_db() as conn:
234
235
  from telepost.storage.sqlite.recovery import RecoveryRepository
235
236
  repo = RecoveryRepository(conn)
236
- await repo.mark_failed(request_id, code)
237
+ await repo.require_reconciliation(request_id)
237
238
  try:
238
239
  await _record_recovery_event(
239
- "schedule.recovery_failed", target_id=target_id,
240
+ "schedule.recovery_reconciliation_required", target_id=target_id,
240
241
  request_id=request_id, retry_mode=mode, schedule_id="",
241
242
  error_class=code,
242
243
  )
@@ -264,6 +265,10 @@ async def submit_recovery(target_id: str, request_id: str,
264
265
  )
265
266
  except Exception:
266
267
  pass
268
+ if terminal_on_failure:
269
+ raise RecoveryError(
270
+ '恢复请求结果尚未确认,系统将按原请求继续对账', code=code,
271
+ retryable=True, hint=failure['hint']) from exc
267
272
  return {
268
273
  "state": "requested",
269
274
  "request_id": request_id,
@@ -298,24 +303,13 @@ async def request_target_recovery(
298
303
  #: A 'requested' row younger than this is owned by its background submit task;
299
304
  #: older ones are fair game for the periodic sweep.
300
305
  RECOVERY_SUBMIT_SWEEP_MIN_AGE = 60.0
301
- #: Give up (terminalize with audit) after this total age — a recovery admit
302
- #: must never run forever.
306
+ #: Stop automatic submission after this age; unresolved requests retain their
307
+ #: identity and exclusion lock while querying the execution owner.
303
308
  RECOVERY_SUBMIT_MAX_AGE = 15 * 60.0
304
- #: An accepted recovery older than this with no outcome terminalizes so the
305
- #: target never stays "正在恢复中" forever.
306
- RECOVERY_ACCEPTED_STALE_MAX_AGE = 30 * 60.0
307
309
 
308
310
 
309
311
  async def resubmit_pending_recoveries(*, now: Optional[float] = None) -> int:
310
- """Crash/transient safety net for admitted-but-unsubmitted recoveries.
311
-
312
- The answer-first callback flow admits durably and submits in a background
313
- task; if that task died with the process (or its transient failure kept
314
- the row 'requested'), this sweep — wired into the 300s runtime cleanup —
315
- re-POSTs with the SAME requestId (idempotent on PixivFlow). Past
316
- ``RECOVERY_SUBMIT_MAX_AGE`` the row terminalizes with an audit instead of
317
- retrying forever.
318
- """
312
+ """Reconcile the existing remote ledger; local age never stops remote work."""
319
313
  now = time.time() if now is None else now
320
314
  if not os.getenv("PIXIVFLOW_REFETCH_BASE_URL") or not os.getenv("PIXIVFLOW_REFETCH_TOKEN"):
321
315
  return 0
@@ -323,56 +317,69 @@ async def resubmit_pending_recoveries(*, now: Optional[float] = None) -> int:
323
317
  rows = []
324
318
  async with db_manager.get_db() as conn:
325
319
  repo = RecoveryRepository(conn)
326
- rows = await repo.list_requested_before(now - RECOVERY_SUBMIT_SWEEP_MIN_AGE)
327
- for row in rows:
328
- if float(row["created_at"]) < now - RECOVERY_SUBMIT_MAX_AGE:
329
- await repo.mark_failed(
330
- row["request_id"], "submit_retry_exhausted")
331
- await _record_recovery_event(
332
- "schedule.recovery_failed", target_id=row["target_id"],
333
- request_id=row["request_id"],
334
- retry_mode=row["retry_mode"] or NORMAL,
335
- schedule_id=row["schedule_id"] or "",
336
- error_class="submit_retry_exhausted",
337
- )
338
- # An ACCEPTED recovery whose outcome never landed (PixivFlow died
339
- # after accepting, outcome notification lost) used to block the
340
- # target's partial-UNIQUE slot FOREVER — every later click answered
341
- # 「正在恢复中」 with nothing running. Terminalize past a staleness
342
- # cap so the operator can click again.
343
- stale_accepted = await repo.list_stale_accepted(
344
- now - RECOVERY_ACCEPTED_STALE_MAX_AGE)
345
- for row in stale_accepted:
346
- await repo.mark_failed(row["request_id"], "accepted_stale")
347
- logger.warning(
348
- "恢复行 accepted 超龄终态化: target=%s request=%s",
349
- row["target_id"], row["request_id"],
350
- )
351
- await _record_recovery_event(
352
- "schedule.recovery_failed", target_id=row["target_id"],
353
- request_id=row["request_id"],
354
- retry_mode=row["retry_mode"] or NORMAL,
355
- schedule_id=row["schedule_id"] or "",
356
- error_class="accepted_stale",
357
- )
320
+ rows = await repo.list_active_before(now - RECOVERY_SUBMIT_SWEEP_MIN_AGE)
358
321
  for row in rows:
359
- if float(row["created_at"]) < now - RECOVERY_SUBMIT_MAX_AGE:
360
- continue
361
322
  try:
362
- await submit_recovery(
363
- row["target_id"], row["request_id"],
364
- row["retry_mode"] or NORMAL,
365
- terminal_on_failure=False,
366
- )
367
- except RecoveryError:
368
- # Non-retryable: already terminalized + audited inside.
369
- pass
323
+ result = await asyncio.to_thread(
324
+ _get_pixivflow_recovery, row["target_id"], row["request_id"])
325
+ if result is not None:
326
+ await reconcile_recovery_result(row["target_id"], row["request_id"], result)
327
+ elif (row["state"] == 'requested' and not row['reconciliation_required']
328
+ and float(row['created_at']) >= now - RECOVERY_SUBMIT_MAX_AGE):
329
+ await submit_recovery(row['target_id'], row['request_id'],
330
+ row['retry_mode'] or NORMAL, terminal_on_failure=False)
331
+ else:
332
+ raise RecoveryError('远端记录未确认', code='reconciliation_required')
370
333
  except Exception:
371
- logger.warning("恢复提交兜底重投失败: request_id=%s",
372
- row["request_id"], exc_info=True)
334
+ async with db_manager.get_db() as conn:
335
+ await RecoveryRepository(conn).require_reconciliation(row['request_id'])
336
+ logger.warning('恢复需要对账: request=%s', row['request_id'])
337
+ # 无进展不重复记账:审计只在首次转入待对账时落一条,
338
+ # 之后每轮仅刷新 last_checked_at(对账进度信号)。
339
+ if not row['reconciliation_required']:
340
+ await _record_recovery_event(
341
+ 'schedule.recovery_reconciliation_required', target_id=row['target_id'],
342
+ request_id=row['request_id'], retry_mode=row['retry_mode'] or NORMAL)
373
343
  return len(rows)
374
344
 
375
345
 
346
+ async def reconcile_recovery_result(target_id: str, request_id: str, result: dict) -> None:
347
+ if result.get('requestId') != request_id:
348
+ raise ValueError('recovery identity mismatch')
349
+ if result.get('targetId', target_id) != target_id:
350
+ raise ValueError('recovery target mismatch')
351
+ remote_state = result.get('state')
352
+ states = {'submitted': 'succeeded', 'failed': 'failed',
353
+ 'no_candidate': 'no_candidate', 'duplicate': 'duplicate',
354
+ 'cancelled': 'cancelled', 'pending': 'accepted', 'running': 'accepted',
355
+ 'selected': 'accepted', 'artifact_ready': 'accepted', 'delivery_pending': 'accepted'}
356
+ if remote_state not in states:
357
+ raise ValueError('unknown remote recovery state')
358
+ from telepost.storage.sqlite.recovery import RecoveryRepository
359
+ async with db_manager.get_db() as conn:
360
+ await RecoveryRepository(conn).apply_remote(
361
+ request_id, target_id, state=states[remote_state], remote_state=remote_state,
362
+ slot_id=str(result.get('slotId') or ''),
363
+ reason=str(result.get('errorCode') or 'remote_execution_failed'))
364
+
365
+
366
+ def _get_pixivflow_recovery(target_id: str, request_id: str) -> Optional[dict]:
367
+ base = os.environ['PIXIVFLOW_REFETCH_BASE_URL'].rstrip('/')
368
+ parsed = urlparse(base)
369
+ if parsed.scheme not in {'http', 'https'} or not parsed.netloc or parsed.username or parsed.password:
370
+ raise ValueError('invalid recovery endpoint')
371
+ request = Request(
372
+ f'{base}/internal/targets/{quote(target_id, safe="")}/recover/{quote(request_id, safe="")}',
373
+ headers={'Authorization': f'Bearer {os.environ["PIXIVFLOW_REFETCH_TOKEN"]}'})
374
+ try:
375
+ with urlopen(request, timeout=30) as response:
376
+ return json.load(response)
377
+ except HTTPError as error:
378
+ if error.code == 404:
379
+ return None
380
+ raise RecoveryError('恢复状态查询暂不可用', code='remote_error') from error
381
+
382
+
376
383
  def _submit_pixivflow_recover(target_id: str, request_id: str,
377
384
  retry_mode: str) -> dict:
378
385
  """POST the durable recovery request to PixivFlow (stdlib only)."""
@@ -396,14 +403,10 @@ def _submit_pixivflow_recover(target_id: str, request_id: str,
396
403
  raise RuntimeError(f"PixivFlow 拒绝恢复(HTTP {response.status})")
397
404
  return result
398
405
  except HTTPError as error:
399
- detail = ""
400
- try:
401
- body_bytes = error.read()
402
- if body_bytes:
403
- detail = " " + body_bytes.decode("utf-8", "replace")[:300]
404
- except Exception:
405
- pass
406
- raise RuntimeError(f"PixivFlow 拒绝恢复(HTTP {error.code}{detail})") from error
406
+ code = {400: 'invalid_request', 401: 'unauthorized', 403: 'unauthorized',
407
+ 404: 'not_found', 409: 'invalid_request'}.get(error.code, 'remote_error')
408
+ raise RecoveryError(f'PixivFlow 拒绝恢复(HTTP {error.code})', code=code,
409
+ retryable=code == 'remote_error') from error
407
410
 
408
411
 
409
412
  _FAILURE_META = {
@@ -417,6 +420,9 @@ _FAILURE_META = {
417
420
 
418
421
 
419
422
  def _classify_recovery_error(exc: Exception) -> dict:
423
+ if isinstance(exc, RecoveryError):
424
+ return {'code': exc.code, 'retryable': exc.retryable,
425
+ 'hint': _FAILURE_META.get(exc.code, {}).get('hint', '')}
420
426
  message = str(exc)
421
427
  lowered = message.lower()
422
428
  if "http 401" in lowered or "http 403" in lowered:
@@ -433,4 +439,4 @@ def _classify_recovery_error(exc: Exception) -> dict:
433
439
  code = "network_error"
434
440
  meta = _FAILURE_META.get(code, {})
435
441
  return {"code": code, "retryable": bool(meta.get("retryable", True)),
436
- "hint": meta.get("hint", "网络或服务异常,稍后重试")}
442
+ "hint": meta.get("hint", "网络或服务异常,稍后重试")}
@@ -8,7 +8,7 @@ to the entry points; when present it overrides these committed defaults.
8
8
  # Bumped automatically by release-please (extra-files in
9
9
  # release-please-config.json). Release bundles and images override it at build
10
10
  # time with the exact version/commit; this constant is the local-dev fallback.
11
- RELEASE_VERSION = "2.84.7" # x-release-please-version
11
+ RELEASE_VERSION = "2.84.9" # x-release-please-version
12
12
  RELEASE_COMMIT = "dev"
13
13
  BUILD_DATE = "dev"
14
14
  SERVICE = "telepost"
@@ -16,6 +16,32 @@ class RecoveryRepository:
16
16
  def __init__(self, conn):
17
17
  self._conn = conn
18
18
 
19
+ async def list_active_before(self, cutoff: float) -> list:
20
+ cur = await self._conn.execute(
21
+ "SELECT * FROM recovery_attempts WHERE state IN ('requested','accepted') "
22
+ "AND created_at <= ? ORDER BY created_at", (cutoff,))
23
+ return list(await cur.fetchall())
24
+
25
+ async def require_reconciliation(self, request_id: str) -> None:
26
+ await self._conn.execute(
27
+ "UPDATE recovery_attempts SET reconciliation_required=1, last_checked_at=? "
28
+ "WHERE request_id=? AND state IN ('requested','accepted')",
29
+ (time.time(), request_id))
30
+
31
+ async def apply_remote(self, request_id: str, target_id: str, *, state: str,
32
+ remote_state: str, slot_id: str = '', reason: str = '') -> None:
33
+ if state not in ('accepted', 'succeeded', 'failed', 'no_candidate', 'duplicate', 'cancelled'):
34
+ raise ValueError('invalid recovery projection')
35
+ await self._conn.execute(
36
+ "UPDATE recovery_attempts SET state=?, remote_state=?, "
37
+ "slot_id=CASE WHEN ?='' THEN slot_id ELSE ? END, "
38
+ "failure_code=?, last_checked_at=?, reconciliation_required=0, finished_at=? "
39
+ "WHERE request_id=? AND target_id=? AND state IN ('requested','accepted') "
40
+ "AND (slot_id='' OR ?='' OR slot_id=?)",
41
+ (state, remote_state, slot_id, slot_id, reason if state == 'failed' else '',
42
+ time.time(), None if state == 'accepted' else time.time(), request_id,
43
+ target_id, slot_id, slot_id))
44
+
19
45
  async def find_by_callback_key(self, callback_key: str) -> Optional[dict]:
20
46
  cur = await self._conn.execute(
21
47
  "SELECT * FROM recovery_attempts WHERE callback_key = ?",
@@ -83,24 +109,6 @@ class RecoveryRepository:
83
109
  )
84
110
  return await cur.fetchone()
85
111
 
86
- async def list_requested_before(self, cutoff: float) -> list:
87
- """'requested' rows older than ``cutoff`` (submit-sweep candidates)."""
88
- cur = await self._conn.execute(
89
- "SELECT * FROM recovery_attempts WHERE state='requested' "
90
- "AND created_at <= ? ORDER BY created_at ASC",
91
- (float(cutoff),),
92
- )
93
- return list(await cur.fetchall())
94
-
95
- async def list_stale_accepted(self, cutoff: float) -> list:
96
- """'accepted' rows older than ``cutoff`` (outcome never landed)."""
97
- cur = await self._conn.execute(
98
- "SELECT * FROM recovery_attempts WHERE state='accepted' "
99
- "AND created_at <= ? ORDER BY created_at ASC",
100
- (float(cutoff),),
101
- )
102
- return list(await cur.fetchall())
103
-
104
112
  async def active_summary(self) -> dict:
105
113
  """{state: count} of ACTIVE (non-terminal) rows, for health output."""
106
114
  cur = await self._conn.execute(
@@ -111,4 +119,13 @@ class RecoveryRepository:
111
119
  rows = list(await cur.fetchall())
112
120
  summary = {str(r["state"]): int(r["n"]) for r in rows}
113
121
  oldest = min((float(r["oldest"]) for r in rows), default=None)
114
- return {"states": summary, "oldest_age_seconds": oldest}
122
+ cur = await self._conn.execute(
123
+ "SELECT COUNT(*) AS n FROM recovery_attempts WHERE reconciliation_required=1 "
124
+ "AND state IN ('requested','accepted')")
125
+ unresolved = await cur.fetchone()
126
+ cur = await self._conn.execute(
127
+ "SELECT MAX(finished_at) AS last_success FROM recovery_attempts WHERE state='succeeded'")
128
+ last_success = await cur.fetchone()
129
+ return {"states": summary, "oldest_age_seconds": oldest,
130
+ "reconciliation_required": int(unresolved['n']),
131
+ "last_success_at": last_success['last_success']}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: telepost-bot
3
- Version: 2.84.7
3
+ Version: 2.84.9
4
4
  Summary: Telegram submission, review, and publication bot with a Mini App, HTTP API, and multi-bot supervisor.
5
5
  Author: redtidev1918
6
6
  License-Expression: MIT
@@ -228,6 +228,7 @@ tests/test_reaction_backfill.py
228
228
  tests/test_reaction_stats.py
229
229
  tests/test_recovery.py
230
230
  tests/test_recovery_answer_first.py
231
+ tests/test_recovery_reconciliation.py
231
232
  tests/test_refetch.py
232
233
  tests/test_refetch_card_state.py
233
234
  tests/test_refetch_events.py
@@ -267,6 +268,7 @@ tests/test_upload.py
267
268
  tests/test_user_friendly_messages.py
268
269
  tests/test_webhook_payload_admission.py
269
270
  tests/test_webhook_ready.py
271
+ tests/test_webhook_registration.py
270
272
  tests/test_webhook_router.py
271
273
  tests/test_webhook_secret.py
272
274
  tests/test_webhook_secret_logging.py
@@ -148,7 +148,11 @@ async def test_schedule_recover_button_handler(monkeypatch, tmp_path,
148
148
  answer = query.answer.await_args.kwargs.get("text") or ""
149
149
  assert "系统会自动继续处理" in answer
150
150
  assert "放宽条件重试" in answer
151
- query.edit_message_reply_markup.assert_awaited_once_with(reply_markup=None)
151
+ # 2026-10-25 UX fix: the buttons STAY — removing them left no retry entry
152
+ # once an attempt terminalized (the outcome message is the only surface
153
+ # carrying them). Re-click safety comes from the one-active-per-target
154
+ # constraint + its「正在恢复中」answer, not from hiding the buttons.
155
+ query.edit_message_reply_markup.assert_not_awaited()
152
156
 
153
157
 
154
158
  @pytest.mark.asyncio
@@ -226,4 +230,4 @@ async def test_schedule_recover_shows_real_failure_reason(monkeypatch, tmp_path,
226
230
  assert "❌ 恢复请求失败" in sent
227
231
  assert "错误码:invalid_request" in sent
228
232
  assert "请求格式或参数被 PixivFlow 拒绝" in sent
229
- assert "requestId must be a UUID" in sent
233
+ assert "HTTP 400" in sent
@@ -33,6 +33,7 @@ def _test_db(monkeypatch, tmp_path):
33
33
  def pixivflow_env(monkeypatch):
34
34
  monkeypatch.setenv("PIXIVFLOW_REFETCH_BASE_URL", "http://pixivflow.test:8090")
35
35
  monkeypatch.setenv("PIXIVFLOW_REFETCH_TOKEN", "recover-secret")
36
+ monkeypatch.setattr('telepost.application.recovery._get_pixivflow_recovery', lambda *args: None)
36
37
  yield
37
38
  monkeypatch.delenv("PIXIVFLOW_REFETCH_BASE_URL", raising=False)
38
39
  monkeypatch.delenv("PIXIVFLOW_REFETCH_TOKEN", raising=False)
@@ -216,8 +217,8 @@ async def test_sweep_terminalizes_stale_accepted(monkeypatch, tmp_path,
216
217
  from telepost.application.recovery import resubmit_pending_recoveries
217
218
  await resubmit_pending_recoveries()
218
219
  row = await _row(request_id)
219
- assert row["state"] == "failed"
220
- assert row["failure_code"] == "accepted_stale"
220
+ assert row["state"] == "accepted"
221
+ assert row["reconciliation_required"] == 1
221
222
 
222
223
 
223
224
  # ---- sweep: crash / transient safety net -----------------------------------
@@ -301,8 +302,8 @@ async def test_sweep_terminalizes_past_max_age(monkeypatch, tmp_path,
301
302
  from telepost.application.recovery import resubmit_pending_recoveries
302
303
  await resubmit_pending_recoveries()
303
304
  row = await _row(request_id)
304
- assert row["state"] == "failed"
305
- assert row["failure_code"] == "submit_retry_exhausted"
305
+ assert row["state"] == "requested"
306
+ assert row["reconciliation_required"] == 1
306
307
  assert calls == []
307
308
 
308
309
 
@@ -0,0 +1,69 @@
1
+ """Remote execution truth must survive lost responses and local age limits."""
2
+ import time
3
+
4
+ import pytest
5
+
6
+ from database import db_manager
7
+ from telepost.application import recovery
8
+ from telepost.storage.sqlite.recovery import RecoveryRepository
9
+
10
+
11
+ @pytest.mark.asyncio
12
+ @pytest.mark.parametrize("initial", ["requested", "accepted"])
13
+ async def test_old_attempt_keeps_target_locked_when_remote_is_running(monkeypatch, tmp_path, initial):
14
+ monkeypatch.setattr(db_manager, "DB_PATH", str(tmp_path / "recovery.db"))
15
+ monkeypatch.setenv("PIXIVFLOW_REFETCH_BASE_URL", "http://example.test")
16
+ monkeypatch.setenv("PIXIVFLOW_REFETCH_TOKEN", "test")
17
+ await db_manager.init_db()
18
+ attempt = await recovery.admit_recovery("safe-test", callback_key="click")
19
+ async with db_manager.get_db() as conn:
20
+ await conn.execute("UPDATE recovery_attempts SET created_at=?, state=?", (time.time() - 7200, initial))
21
+ monkeypatch.setattr(recovery, "_get_pixivflow_recovery", lambda *args: {
22
+ "requestId": attempt["request_id"], "slotId": "test-slot",
23
+ "state": "delivery_pending", "business_state": "recovery_running",
24
+ }, raising=False)
25
+ await recovery.resubmit_pending_recoveries()
26
+ async with db_manager.get_db() as conn:
27
+ row = await RecoveryRepository(conn).find_active_by_target("safe-test")
28
+ assert row is not None, "local age must not release a live remote execution"
29
+ assert row["state"] == "accepted"
30
+ with pytest.raises(recovery.RecoveryAlreadyRunningError):
31
+ await recovery.admit_recovery("safe-test", callback_key="second-click")
32
+
33
+
34
+ @pytest.mark.asyncio
35
+ @pytest.mark.parametrize('remote,terminal', [('submitted', 'succeeded'), ('failed', 'failed'), ('no_candidate', 'no_candidate')])
36
+ async def test_remote_terminal_is_durable_and_late_result_cannot_overwrite(monkeypatch, tmp_path, remote, terminal):
37
+ monkeypatch.setattr(db_manager, 'DB_PATH', str(tmp_path / 'result.db'))
38
+ monkeypatch.setenv('PIXIVFLOW_REFETCH_BASE_URL', 'http://example.test')
39
+ monkeypatch.setenv('PIXIVFLOW_REFETCH_TOKEN', 'test')
40
+ await db_manager.init_db()
41
+ attempt = await recovery.admit_recovery('safe-test', callback_key='click')
42
+ result = {'requestId': attempt['request_id'], 'slotId': 's', 'state': remote}
43
+ await recovery.reconcile_recovery_result('wrong-target', attempt['request_id'], result)
44
+ async with db_manager.get_db() as conn:
45
+ assert await RecoveryRepository(conn).find_active_by_target('safe-test')
46
+ await recovery.reconcile_recovery_result('safe-test', attempt['request_id'], result)
47
+ await recovery.reconcile_recovery_result('safe-test', attempt['request_id'], {**result, 'state': 'pending'})
48
+ async with db_manager.get_db() as conn:
49
+ row = await RecoveryRepository(conn).find_by_callback_key('click')
50
+ assert row['state'] == terminal
51
+ assert row['finished_at'] is not None
52
+
53
+
54
+ @pytest.mark.asyncio
55
+ async def test_lost_response_retains_identity_even_for_synchronous_caller(monkeypatch, tmp_path):
56
+ monkeypatch.setattr(db_manager, 'DB_PATH', str(tmp_path / 'lost.db'))
57
+ monkeypatch.setenv('PIXIVFLOW_REFETCH_BASE_URL', 'http://example.test')
58
+ monkeypatch.setenv('PIXIVFLOW_REFETCH_TOKEN', 'test')
59
+ await db_manager.init_db()
60
+ def lost(*args):
61
+ raise TimeoutError('response lost')
62
+ monkeypatch.setattr(recovery, '_submit_pixivflow_recover', lost)
63
+ with pytest.raises(recovery.RecoveryError):
64
+ await recovery.request_target_recovery('safe-test', callback_key='click')
65
+ async with db_manager.get_db() as conn:
66
+ result = await RecoveryRepository(conn).find_by_callback_key('click')
67
+ assert result['state'] == 'requested'
68
+ with pytest.raises(recovery.RecoveryAlreadyRunningError):
69
+ await recovery.admit_recovery('safe-test', callback_key='second')
@@ -57,6 +57,34 @@ PAYLOAD = {
57
57
  }
58
58
 
59
59
 
60
+ @pytest.mark.asyncio
61
+ async def test_recovery_receipt_converges_even_when_notification_fails(monkeypatch, tmp_path):
62
+ await _db(monkeypatch, tmp_path)
63
+ from telepost.storage.sqlite.recovery import RecoveryRepository
64
+ async with db_manager.get_db() as conn:
65
+ attempt, refused = await RecoveryRepository(conn).create_attempt(
66
+ target_id='safe-test', retry_mode='normal', callback_key='safe-click')
67
+ assert refused is None
68
+ app, application = _make_app(monkeypatch)
69
+ application.bot.send_message.side_effect = [RuntimeError('offline'), MagicMock(message_id=2)]
70
+ client = await _client(app)
71
+ payload = {'schedule_id': 'safe-schedule', 'slot_id': 'safe-slot', 'status': 'success',
72
+ 'recovery': {'requestId': attempt['request_id'], 'mode': 'normal'},
73
+ 'targets': [{'target_id': 'safe-test', 'status': 'submitted'}]}
74
+ try:
75
+ response = await client.post('/api/v1/schedule/outcomes', json=payload)
76
+ assert response.status == 502
77
+ async with db_manager.get_db() as conn:
78
+ row = await RecoveryRepository(conn).find_by_callback_key('safe-click')
79
+ assert row['state'] == 'succeeded'
80
+ for _ in range(2):
81
+ response = await client.post('/api/v1/schedule/outcomes', json=payload)
82
+ assert response.status == 200
83
+ assert application.bot.send_message.await_count == 2
84
+ finally:
85
+ await client.close()
86
+
87
+
60
88
  @pytest.mark.asyncio
61
89
  async def test_requires_service_token(monkeypatch, tmp_path):
62
90
  await _db(monkeypatch, tmp_path)