cc-session-tools 2.11.2__tar.gz → 2.12.0__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 (276) hide show
  1. {cc_session_tools-2.11.2/src/cc_session_tools.egg-info → cc_session_tools-2.12.0}/PKG-INFO +1 -1
  2. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/pyproject.toml +1 -1
  3. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/cli/ccst.py +513 -1
  4. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/config/hooks-bundle.json +18 -0
  5. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/hook_registry.py +2 -0
  6. cc_session_tools-2.12.0/src/cc_session_tools/lib/machine_identity.py +73 -0
  7. cc_session_tools-2.12.0/src/cc_session_tools/lib/occupancy.py +83 -0
  8. cc_session_tools-2.12.0/src/cc_session_tools/lib/pdata/dump.py +284 -0
  9. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/init_service.py +121 -24
  10. cc_session_tools-2.12.0/src/cc_session_tools/lib/pdata/rehydrate.py +172 -0
  11. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/repository.py +28 -5
  12. cc_session_tools-2.12.0/src/cc_session_tools/lib/pdata/resolve.py +686 -0
  13. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/service.py +30 -4
  14. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/store.py +20 -0
  15. cc_session_tools-2.12.0/src/cc_session_tools/lib/pdata/sync_check.py +178 -0
  16. cc_session_tools-2.12.0/src/cc_session_tools/lib/pdata/sync_lock.py +24 -0
  17. cc_session_tools-2.12.0/src/cc_session_tools/lib/pdata/sync_notify.py +79 -0
  18. cc_session_tools-2.12.0/src/cc_session_tools/lib/pdata/vector_clock.py +39 -0
  19. cc_session_tools-2.12.0/src/cc_session_tools/lib/pdata/vector_clock_store.py +34 -0
  20. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/bundled_jobs.py +35 -0
  21. cc_session_tools-2.12.0/src/cc_session_tools/skills/pm-pdata-conflict-resolution/SKILL.md +173 -0
  22. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0/src/cc_session_tools.egg-info}/PKG-INFO +1 -1
  23. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools.egg-info/SOURCES.txt +15 -0
  24. cc_session_tools-2.12.0/src/cccs_hooks/pdata_sync.py +216 -0
  25. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_doctor.py +3 -1
  26. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_hook_dispatcher.py +1 -0
  27. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_hooks_install_zero_arg.py +4 -1
  28. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_install_everything.py +34 -12
  29. cc_session_tools-2.12.0/tests/test_ccst_machine_identity_cli.py +68 -0
  30. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_pdata_init_cli.py +31 -0
  31. cc_session_tools-2.12.0/tests/test_ccst_pdata_sync_cli.py +802 -0
  32. cc_session_tools-2.12.0/tests/test_machine_identity.py +97 -0
  33. cc_session_tools-2.12.0/tests/test_occupancy.py +123 -0
  34. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_scheduler_bundled_jobs.py +55 -0
  35. cc_session_tools-2.11.2/src/cc_session_tools/skills/pm-pdata-conflict-resolution/SKILL.md +0 -67
  36. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/LICENSE +0 -0
  37. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/README.md +0 -0
  38. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/setup.cfg +0 -0
  39. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/__init__.py +0 -0
  40. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/cli/__init__.py +0 -0
  41. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/cli/ccd.py +0 -0
  42. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/cli/ccmsg.py +0 -0
  43. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/cli/ccr.py +0 -0
  44. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/cli/ccs.py +0 -0
  45. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/cli/ccsched.py +0 -0
  46. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/cli/migrate_ccmsg.py +0 -0
  47. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/cli/migrate_ccsched.py +0 -0
  48. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/cli/migrate_sessions_db.py +0 -0
  49. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/cli/migrate_telemetry.py +0 -0
  50. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/config/session-tag-hook.json +0 -0
  51. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/hooks_install.py +0 -0
  52. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/__init__.py +0 -0
  53. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/claude_flags.py +0 -0
  54. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/claude_md_install.py +0 -0
  55. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/context_overrides.py +0 -0
  56. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/db.py +0 -0
  57. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/debug.py +0 -0
  58. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/doctor.py +0 -0
  59. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/doctor_mutes.py +0 -0
  60. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/install_sync.py +0 -0
  61. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/levenshtein.py +0 -0
  62. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/messaging/__init__.py +0 -0
  63. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/messaging/addressing.py +0 -0
  64. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/messaging/cursor.py +0 -0
  65. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/messaging/lock.py +0 -0
  66. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/messaging/message.py +0 -0
  67. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/messaging/move_safety.py +0 -0
  68. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/messaging/repository.py +0 -0
  69. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/messaging/retention.py +0 -0
  70. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/messaging/service.py +0 -0
  71. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/messaging/store.py +0 -0
  72. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/paths.py +0 -0
  73. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/__init__.py +0 -0
  74. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/backup.py +0 -0
  75. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/classify.py +0 -0
  76. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/cutover.py +0 -0
  77. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/formatting.py +0 -0
  78. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/importers.py +0 -0
  79. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/init_paths.py +0 -0
  80. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/manifest.py +0 -0
  81. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/naming.py +0 -0
  82. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/rename_group.py +0 -0
  83. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/reorganize.py +0 -0
  84. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/session_output.py +0 -0
  85. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/verify.py +0 -0
  86. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/pdata/write_log.py +0 -0
  87. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/picker.py +0 -0
  88. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/proc_lock.py +0 -0
  89. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/prompts.py +0 -0
  90. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/roots.py +0 -0
  91. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/rules.py +0 -0
  92. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/__init__.py +0 -0
  93. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/cadence.py +0 -0
  94. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/cursor.py +0 -0
  95. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/digest.py +0 -0
  96. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/due.py +0 -0
  97. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/duration.py +0 -0
  98. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/jobspec.py +0 -0
  99. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/ledger.py +0 -0
  100. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/lock.py +0 -0
  101. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/notify.py +0 -0
  102. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/reconcile.py +0 -0
  103. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/registry.py +0 -0
  104. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/runner.py +0 -0
  105. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/state.py +0 -0
  106. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/store.py +0 -0
  107. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/surface.py +0 -0
  108. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/throttle.py +0 -0
  109. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/scheduler/worker.py +0 -0
  110. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/session_gc.py +0 -0
  111. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/sessions.py +0 -0
  112. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/sessions_db.py +0 -0
  113. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/sessions_repair.py +0 -0
  114. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/shell_install.py +0 -0
  115. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/tasklist.py +0 -0
  116. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/lib/telemetry_store.py +0 -0
  117. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/prompts/pdata-migration-claude-md-update.md +0 -0
  118. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/prompts/pdata-migration-skills-update.md +0 -0
  119. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/analyse-cc-usage/SKILL.md +0 -0
  120. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/clean-hook-sessions/SKILL.md +0 -0
  121. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/clean-hook-sessions/scripts/clean-hook-sessions.py +0 -0
  122. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/context-override/SKILL.md +0 -0
  123. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/delete-sessions/SKILL.md +0 -0
  124. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/delete-sessions/scripts/delete_sessions.py +0 -0
  125. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/do-executor-critic-assessor-loop/SKILL.md +0 -0
  126. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/find-claude-code-session/SKILL.md +0 -0
  127. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/generate-8digit-code/SKILL.md +0 -0
  128. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/generate-8digit-code/scripts/generate_8digit_code.py +0 -0
  129. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/list-empty-sessions/SKILL.md +0 -0
  130. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/list-empty-sessions/scripts/list_empty_sessions.py +0 -0
  131. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/manage-recurring-cc-jobs-using-ccsched/SKILL.md +0 -0
  132. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/move-session/SKILL.md +0 -0
  133. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/move-session/hooks/sessionstart-pending-rename.sh +0 -0
  134. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/move-session/scripts/cc_session_rules.py +0 -0
  135. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/move-session/scripts/move_session.py +0 -0
  136. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/pm-pdata-schema-design/SKILL.md +0 -0
  137. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/pm-project-init/SKILL.md +0 -0
  138. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/pm-project-layout-reference/SKILL.md +0 -0
  139. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/pm-update-central-files/SKILL.md +0 -0
  140. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/reduce-persistent-context/CALIBRATION.md +0 -0
  141. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/reduce-persistent-context/SKILL.md +0 -0
  142. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/reduce-persistent-context/scripts/analyze_context.py +0 -0
  143. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/reduce-persistent-context/scripts/duplicates.py +0 -0
  144. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/reduce-persistent-context/scripts/measure.py +0 -0
  145. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/reduce-persistent-context/scripts/report.py +0 -0
  146. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/reduce-persistent-context/scripts/tokens.py +0 -0
  147. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/reduce-persistent-context/scripts/usage.py +0 -0
  148. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/select-agent-model/SKILL.md +0 -0
  149. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/send-session-message/SKILL.md +0 -0
  150. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/update-command-cache/SKILL.md +0 -0
  151. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools/skills/update-command-cache/scripts/update_command_cache.py +0 -0
  152. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools.egg-info/dependency_links.txt +0 -0
  153. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools.egg-info/entry_points.txt +0 -0
  154. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools.egg-info/requires.txt +0 -0
  155. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cc_session_tools.egg-info/top_level.txt +0 -0
  156. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/__init__.py +0 -0
  157. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/after_response.py +0 -0
  158. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/bash_hard_deny.py +0 -0
  159. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/bash_security_review.py +0 -0
  160. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/cache.py +0 -0
  161. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/catchup.py +0 -0
  162. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/confirm_8digit.py +0 -0
  163. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/context_window_warning.py +0 -0
  164. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/last_screenshot.py +0 -0
  165. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/marker_allow.py +0 -0
  166. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/markers.py +0 -0
  167. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/messaging_deliver.py +0 -0
  168. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/model_info.py +0 -0
  169. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/normalise.py +0 -0
  170. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/pending_migration.py +0 -0
  171. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/pending_rename.py +0 -0
  172. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/session_tag.py +0 -0
  173. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/stats.py +0 -0
  174. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/telemetry.py +0 -0
  175. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/telemetry_query.py +0 -0
  176. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/telemetry_trim.py +0 -0
  177. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/transcript.py +0 -0
  178. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/cccs_hooks/worklog_guard.py +0 -0
  179. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/claude_code_usage/__init__.py +0 -0
  180. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/claude_code_usage/attribution.py +0 -0
  181. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/claude_code_usage/cache.py +0 -0
  182. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/claude_code_usage/ccusage_wrapper.py +0 -0
  183. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/claude_code_usage/cli.py +0 -0
  184. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/claude_code_usage/data/pricing.json +0 -0
  185. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/claude_code_usage/parent_inference.py +0 -0
  186. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/claude_code_usage/parser.py +0 -0
  187. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/claude_code_usage/pricing.py +0 -0
  188. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/claude_code_usage/query.py +0 -0
  189. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/claude_code_usage/report.py +0 -0
  190. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/claude_code_usage/schema.py +0 -0
  191. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/src/claude_code_usage/session_names.py +0 -0
  192. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_after_response.py +0 -0
  193. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_attribution.py +0 -0
  194. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_bash_hard_deny.py +0 -0
  195. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_bash_security_review.py +0 -0
  196. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_cache.py +0 -0
  197. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_cache_sqlite.py +0 -0
  198. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccr_orphans.py +0 -0
  199. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccs_emptiness.py +0 -0
  200. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccs_eta.py +0 -0
  201. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccs_list_mode.py +0 -0
  202. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccs_scope_flags.py +0 -0
  203. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccs_sentinel_sort.py +0 -0
  204. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccs_session_counts.py +0 -0
  205. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_bundle_discovery.py +0 -0
  206. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_ccsched_jobs_cli.py +0 -0
  207. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_cli.py +0 -0
  208. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_context_override_cli.py +0 -0
  209. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_gc_prune.py +0 -0
  210. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_gc_report.py +0 -0
  211. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_hooks_install_prune.py +0 -0
  212. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_hooks_uninstall.py +0 -0
  213. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_main_gate.py +0 -0
  214. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_pdata_cli.py +0 -0
  215. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_pdata_reconcile_cli.py +0 -0
  216. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_pdata_rename_group_cli.py +0 -0
  217. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_pdata_reorganize_cli.py +0 -0
  218. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_pdata_verify_cli.py +0 -0
  219. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_repair_sessions_cli.py +0 -0
  220. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_sessions_cli.py +0 -0
  221. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_shell_install.py +0 -0
  222. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_skills_install.py +0 -0
  223. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_skills_uninstall.py +0 -0
  224. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_telemetry_query.py +0 -0
  225. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccst_telemetry_trim.py +0 -0
  226. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_ccusage_wrapper.py +0 -0
  227. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_claude_flags.py +0 -0
  228. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_claude_md_install.py +0 -0
  229. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_cli.py +0 -0
  230. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_cli_ccd.py +0 -0
  231. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_cli_ccd_dry_run.py +0 -0
  232. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_cli_ccr.py +0 -0
  233. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_cli_ccs.py +0 -0
  234. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_cli_version.py +0 -0
  235. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_confirm_8digit.py +0 -0
  236. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_context_overrides.py +0 -0
  237. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_context_window_warning.py +0 -0
  238. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_db.py +0 -0
  239. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_debug.py +0 -0
  240. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_doctor_mutes.py +0 -0
  241. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_empty_session.py +0 -0
  242. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_hook_cache.py +0 -0
  243. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_hooks_install.py +0 -0
  244. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_install_sync.py +0 -0
  245. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_last_screenshot.py +0 -0
  246. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_levenshtein.py +0 -0
  247. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_marker_allow.py +0 -0
  248. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_migrate_ccmsg.py +0 -0
  249. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_migrate_ccsched.py +0 -0
  250. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_migrate_sessions_db.py +0 -0
  251. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_migrate_telemetry.py +0 -0
  252. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_model_info.py +0 -0
  253. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_normalise.py +0 -0
  254. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_parent_inference.py +0 -0
  255. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_parser.py +0 -0
  256. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_paths.py +0 -0
  257. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_pending_migration_hook.py +0 -0
  258. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_picker.py +0 -0
  259. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_pricing.py +0 -0
  260. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_proc_lock.py +0 -0
  261. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_prompts.py +0 -0
  262. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_query.py +0 -0
  263. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_report.py +0 -0
  264. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_roots.py +0 -0
  265. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_rules.py +0 -0
  266. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_schema.py +0 -0
  267. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_session_names.py +0 -0
  268. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_session_tag.py +0 -0
  269. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_sessions.py +0 -0
  270. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_sessions_db.py +0 -0
  271. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_sessions_repair.py +0 -0
  272. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_tasklist.py +0 -0
  273. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_telemetry.py +0 -0
  274. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_telemetry_store.py +0 -0
  275. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_transcript.py +0 -0
  276. {cc_session_tools-2.11.2 → cc_session_tools-2.12.0}/tests/test_worklog_guard.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cc-session-tools
3
- Version: 2.11.2
3
+ Version: 2.12.0
4
4
  Summary: Claude Code session management CLI tools (ccd, ccr, ccs, claude-code-usage, ccst) and hook library (cccs_hooks)
5
5
  Author: raffishquartan
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cc-session-tools"
7
- version = "2.11.2"
7
+ version = "2.12.0"
8
8
  description = "Claude Code session management CLI tools (ccd, ccr, ccs, claude-code-usage, ccst) and hook library (cccs_hooks)"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -45,6 +45,23 @@ Current subcommands:
45
45
  pdata verify Run the integrity-check backstop (row-count parity, file_path
46
46
  resolution, suspicious double-updates) for --project NAME or
47
47
  --all-projects and persist the result for ccst doctor.
48
+ pdata dump Publish the current local DB state to
49
+ .pdata-db-dump/latest.sql for --project NAME or
50
+ --all-projects. Refuses (unless --force) to overwrite an
51
+ unresolved cross-machine fork.
52
+ pdata rehydrate Fast-forward the local DB from the published dump for
53
+ --project NAME or --all-projects, if it's ahead. --force
54
+ fast-forwards even over a diverged local revision.
55
+ pdata resolve Diagnose (default, prints the diff) or apply per-record
56
+ --choice ID=local|dump resolutions for a cross-machine fork.
57
+ pdata sync-check Do whichever of rehydrate/dump each project needs, in that
58
+ order, for --project NAME or --all-projects. The unattended
59
+ trigger behind the hourly pdata-sync-hourly ccsched job:
60
+ skips an unchanged republish and never overrides a fork.
61
+ machine-identity show Print this laptop's resolved machine id and whether it's
62
+ confirmed.
63
+ machine-identity confirm Store this laptop's confirmed machine id (--name NAME), used
64
+ by pdata's cross-machine vector clock.
48
65
  migrate ccsched Migrate ccsched flat-file stores into ccsched.db
49
66
  (verify + tar-backup old files before removal).
50
67
  migrate ccmsg Migrate the flat-file message store into ccmsg.db
@@ -81,7 +98,7 @@ import os
81
98
  import sys
82
99
  from enum import Enum
83
100
  from pathlib import Path
84
- from typing import Any, TextIO, cast
101
+ from typing import TYPE_CHECKING, Any, TextIO, cast
85
102
 
86
103
  from cc_session_tools import __version__
87
104
  from cc_session_tools.hooks_install import (
@@ -90,8 +107,16 @@ from cc_session_tools.hooks_install import (
90
107
  prune_stale_hooks,
91
108
  write_json_atomic,
92
109
  )
110
+ from cc_session_tools.lib import machine_identity
93
111
  from cc_session_tools.lib.hook_registry import HOOK_DESCRIPTIONS, HOOK_VERBS
94
112
 
113
+ if TYPE_CHECKING:
114
+ # Type-only, so the handler's own lazy `from ... import sync_check` (this file's convention:
115
+ # pdata modules are imported inside the handler that needs them, never at module scope) is
116
+ # still the only runtime import.
117
+ from cc_session_tools.lib.pdata.resolve import RecordPayload
118
+ from cc_session_tools.lib.pdata.sync_check import SyncCheckResult
119
+
95
120
 
96
121
  # ---------- path discovery ----------
97
122
 
@@ -1161,6 +1186,16 @@ def _cmd_pdata_init(args: argparse.Namespace) -> int:
1161
1186
  print(f"ERROR: verification failed ({len(write_result.failure.reasons)} reason(s))")
1162
1187
  return 1
1163
1188
 
1189
+ if write_result.adopted_from_dump:
1190
+ # A second machine's first-ever init for an already-migrated project - nothing was
1191
+ # classified or cut over here, so the ordinary "Wrote N records"/"Backup: ..."/
1192
+ # doc-update-reminders below would be actively misleading (they read as if nothing
1193
+ # happened, or that something went wrong, rather than "adoption succeeded").
1194
+ print(write_result.report)
1195
+ print(f"\nVerify: ccst pdata verify --project {args.project} --full")
1196
+ print("SUCCESS")
1197
+ return 0
1198
+
1164
1199
  print(
1165
1200
  f"Wrote {len(write_result.created_record_ids)} record(s) across "
1166
1201
  f"{len(write_result.entries_written)} file(s)."
@@ -1393,6 +1428,393 @@ def _cmd_pdata_verify(args: argparse.Namespace) -> int:
1393
1428
  return worst
1394
1429
 
1395
1430
 
1431
+ def _cmd_pdata_dump(args: argparse.Namespace) -> int:
1432
+ from cc_session_tools.lib import machine_identity
1433
+ from cc_session_tools.lib.pdata import (
1434
+ dump, repository, store, sync_notify, vector_clock_store, verify,
1435
+ )
1436
+
1437
+ projects = verify.discover_projects() if args.all_projects else [args.project]
1438
+ if not projects:
1439
+ print("ccst pdata dump: no project databases found", file=sys.stderr)
1440
+ return 2
1441
+
1442
+ machine_id = machine_identity.resolve().machine_id
1443
+ compact = args.all_projects
1444
+ published = 0
1445
+ refused = 0
1446
+ errors = 0
1447
+
1448
+ for project in projects:
1449
+ try:
1450
+ project_root = store.project_root(project)
1451
+ conn = repository.connect(project)
1452
+ except ValueError as exc:
1453
+ # Matches the sibling _cmd_pdata_rehydrate/_cmd_pdata_resolve handlers: record and
1454
+ # continue rather than abort the whole --all-projects loop on one bad project.
1455
+ print(f"ccst pdata dump: {project}: {exc}", file=sys.stderr)
1456
+ errors += 1
1457
+ continue
1458
+ try:
1459
+ local_vector = vector_clock_store.read_vector(conn)
1460
+ existing = dump.read_latest(project_root)
1461
+ # Shared with the SessionEnd hook (cccs_hooks.pdata_sync) - the spec's dump trigger
1462
+ # is one rule, so it lives in one function rather than inline in both callers.
1463
+ # `None` means safe to publish; anything else is the Comparison that refuses it.
1464
+ comparison = dump.decide_publish(local_vector=local_vector, existing=existing)
1465
+ if comparison is not None and not args.force:
1466
+ refused += 1
1467
+ detail = dump.refusal_detail(project)
1468
+ sync_notify.notify_conflict(project, outcome=comparison.value, detail=detail)
1469
+ if not compact:
1470
+ print(f"ccst pdata dump: {project}: {detail}", file=sys.stderr)
1471
+ continue
1472
+ dump.write_latest(
1473
+ conn, project_root=project_root, machine_id=machine_id, vector=local_vector,
1474
+ )
1475
+ finally:
1476
+ conn.close()
1477
+ published += 1
1478
+ if not compact:
1479
+ print(f"ccst pdata dump: {project}: published (machine_id={machine_id})")
1480
+
1481
+ if compact:
1482
+ if refused or errors:
1483
+ print(
1484
+ f"ccst pdata dump --all-projects: published {published}, refused {refused} "
1485
+ f"(unresolved fork), errors {errors} of {len(projects)} project(s) - see "
1486
+ f"`ccst pdata resolve --project NAME` for each"
1487
+ )
1488
+ else:
1489
+ print(
1490
+ f"ccst pdata dump --all-projects: published {published} of "
1491
+ f"{len(projects)} project(s)"
1492
+ )
1493
+
1494
+ return 2 if errors else (1 if refused else 0)
1495
+
1496
+
1497
+ def _cmd_pdata_rehydrate(args: argparse.Namespace) -> int:
1498
+ from cc_session_tools.lib.pdata import rehydrate, sync_notify, verify
1499
+
1500
+ projects = verify.discover_projects() if args.all_projects else [args.project]
1501
+ if not projects:
1502
+ print("ccst pdata rehydrate: no project databases found", file=sys.stderr)
1503
+ return 2
1504
+
1505
+ compact = args.all_projects
1506
+ counts = {outcome.value: 0 for outcome in rehydrate.RehydrateOutcome}
1507
+ worst = 0
1508
+
1509
+ for project in projects:
1510
+ try:
1511
+ result = rehydrate.rehydrate(project, force=args.force)
1512
+ except ValueError as exc:
1513
+ print(f"ccst pdata rehydrate: {project}: {exc}", file=sys.stderr)
1514
+ worst = max(worst, 2)
1515
+ continue
1516
+ counts[result.outcome.value] += 1
1517
+
1518
+ if result.outcome is rehydrate.RehydrateOutcome.FAST_FORWARDED:
1519
+ if not compact:
1520
+ print(
1521
+ f"ccst pdata rehydrate: {project}: fast-forwarded from "
1522
+ f"{result.from_machine}"
1523
+ )
1524
+ elif result.outcome is rehydrate.RehydrateOutcome.NO_OP:
1525
+ if not compact:
1526
+ print(f"ccst pdata rehydrate: {project}: already up to date")
1527
+ elif result.outcome in (
1528
+ rehydrate.RehydrateOutcome.FORK, rehydrate.RehydrateOutcome.CHECKSUM_INVALID,
1529
+ ):
1530
+ worst = max(worst, 1)
1531
+ # Shared with the SessionStart hook (cccs_hooks.pdata_sync) so the CLI and the hook
1532
+ # can never describe the same conflict two different ways.
1533
+ detail = rehydrate.conflict_detail(result, project=project)
1534
+ sync_notify.notify_conflict(project, outcome=result.outcome.value, detail=detail)
1535
+ if not compact:
1536
+ print(f"ccst pdata rehydrate: {project}: {detail}", file=sys.stderr)
1537
+ else:
1538
+ # DEFERRED - another writer holds sync_lock right now. Expected and transient, not
1539
+ # an error (rehydrate.py's own RehydrateOutcome docstring: "retry later" rather than
1540
+ # "surfaced, nothing written" like FORK/CHECKSUM_INVALID above) - exit 0, and never
1541
+ # point at `ccst pdata resolve`, which would misdescribe this as a conflict.
1542
+ if not compact:
1543
+ print(
1544
+ f"ccst pdata rehydrate: {project}: another writer holds the lock - "
1545
+ f"retry later"
1546
+ )
1547
+
1548
+ if compact:
1549
+ print(
1550
+ "ccst pdata rehydrate --all-projects: "
1551
+ f"fast-forwarded {counts[rehydrate.RehydrateOutcome.FAST_FORWARDED.value]}, "
1552
+ f"no-op {counts[rehydrate.RehydrateOutcome.NO_OP.value]}, "
1553
+ f"fork {counts[rehydrate.RehydrateOutcome.FORK.value]}, "
1554
+ f"checksum-invalid {counts[rehydrate.RehydrateOutcome.CHECKSUM_INVALID.value]}, "
1555
+ f"deferred {counts[rehydrate.RehydrateOutcome.DEFERRED.value]} of "
1556
+ f"{len(projects)} project(s)"
1557
+ )
1558
+
1559
+ return worst
1560
+
1561
+
1562
+ def _parse_resolve_choice(raw: str) -> tuple[int, str]:
1563
+ """Parse "ID=local|dump" into (record_id, choice). Only checks the shape - whether choice is
1564
+ actually 'local'/'dump' is apply_resolution's own job (its error message is printed verbatim,
1565
+ not re-derived here). Raises ValueError on malformed input."""
1566
+ id_str, sep, choice = raw.partition("=")
1567
+ if not sep or not id_str or not choice:
1568
+ raise ValueError(f"malformed --choice (want ID=local|dump): {raw!r}")
1569
+ try:
1570
+ record_id = int(id_str)
1571
+ except ValueError:
1572
+ raise ValueError(f"malformed --choice (want ID=local|dump): {raw!r}") from None
1573
+ return record_id, choice
1574
+
1575
+
1576
+ def _resolve_deleted_at(payload: RecordPayload) -> int | None:
1577
+ return payload["base"]["deleted_at"]
1578
+
1579
+
1580
+ def _cmd_pdata_resolve(args: argparse.Namespace) -> int:
1581
+ from cc_session_tools.lib.pdata import resolve, verify
1582
+
1583
+ if args.choice:
1584
+ if args.all_projects:
1585
+ print(
1586
+ "ccst pdata resolve: --choice requires --project (not --all-projects)",
1587
+ file=sys.stderr,
1588
+ )
1589
+ return 2
1590
+ try:
1591
+ raw_choices = dict(_parse_resolve_choice(raw) for raw in args.choice)
1592
+ except ValueError as exc:
1593
+ print(f"ccst pdata resolve: {exc}", file=sys.stderr)
1594
+ return 2
1595
+ try:
1596
+ # narrow_choices raises the same "invalid choice" ValueError apply_resolution's own
1597
+ # runtime check does, from the same helper - so an unusable choice value still
1598
+ # reports exactly one way, whichever of the two sees it first.
1599
+ choices = resolve.narrow_choices(raw_choices)
1600
+ outcome = resolve.apply_resolution(args.project, choices)
1601
+ except ValueError as exc:
1602
+ print(f"ccst pdata resolve: {exc}", file=sys.stderr)
1603
+ return 1
1604
+ if outcome is resolve.ApplyOutcome.LOCKED:
1605
+ # Another writer holds sync_lock right now. Expected and transient, exactly like
1606
+ # rehydrate's DEFERRED above - exit 0, nothing written, and never point at `ccst pdata
1607
+ # resolve`, which would misdescribe lock contention as a conflict.
1608
+ print(
1609
+ f"ccst pdata resolve: {args.project}: another writer holds the lock - retry later"
1610
+ )
1611
+ return 0
1612
+ print(f"ccst pdata resolve: {args.project}: resolved {len(choices)} record(s)")
1613
+ return 0
1614
+
1615
+ projects = verify.discover_projects() if args.all_projects else [args.project]
1616
+ if not projects:
1617
+ print("ccst pdata resolve: no project databases found", file=sys.stderr)
1618
+ return 2
1619
+
1620
+ compact = args.all_projects
1621
+ outstanding = 0
1622
+
1623
+ for project in projects:
1624
+ try:
1625
+ diff = resolve.diff_against_dump(project)
1626
+ except ValueError as exc:
1627
+ print(f"ccst pdata resolve: {project}: {exc}", file=sys.stderr)
1628
+ outstanding += 1
1629
+ continue
1630
+
1631
+ has_diff = bool(diff.records) or bool(diff.schema_fields)
1632
+ if has_diff:
1633
+ outstanding += 1
1634
+
1635
+ if compact:
1636
+ if has_diff:
1637
+ print(
1638
+ f"{project}: {len(diff.records)} record(s) + "
1639
+ f"{len(diff.schema_fields)} schema field(s) outstanding"
1640
+ )
1641
+ else:
1642
+ print(f"{project}: clean")
1643
+ continue
1644
+
1645
+ if not has_diff:
1646
+ print(f"{project}: clean - nothing to resolve")
1647
+ continue
1648
+
1649
+ print(
1650
+ f"{project}: {len(diff.records)} record(s) + {len(diff.schema_fields)} schema "
1651
+ f"field(s) to resolve"
1652
+ )
1653
+ for rd in diff.records:
1654
+ if rd.id_collision:
1655
+ print(
1656
+ f" record {rd.record_id} (group={rd.record_group}): id collision - "
1657
+ f"this id was independently assigned to two unrelated records on "
1658
+ f"different machines, not a genuine edit conflict; `ccst pdata resolve` "
1659
+ f"cannot apply a local/dump choice to this one, it needs manual, "
1660
+ f"out-of-band reconciliation"
1661
+ )
1662
+ continue
1663
+ if rd.group_mismatch:
1664
+ # Both sides' own group names, not rd.record_group: that field carries whichever
1665
+ # side happened to be available, and RecordDiff's docstring says so - printing it
1666
+ # alone in the one line whose whole point is which two names disagree would tell
1667
+ # the reader neither which side they are seeing nor what the other side's is.
1668
+ print(
1669
+ f" record {rd.record_id} (local group={rd.local_record_group}, "
1670
+ f"dump group={rd.dump_record_group}): group mismatch - same id and "
1671
+ f"created_at, but local and dump disagree on record_group; compare "
1672
+ f"content/file_path on each side before assuming this is a safe "
1673
+ f"`ccst pdata rename-group` rather than a same-second id collision - "
1674
+ f"`ccst pdata resolve` cannot apply a local/dump choice to this one"
1675
+ )
1676
+ continue
1677
+ if rd.is_delete_vs_update:
1678
+ assert rd.local is not None and rd.dump is not None
1679
+ local_deleted = _resolve_deleted_at(rd.local) is not None
1680
+ side = (
1681
+ "local deleted this record, dump has a live edit to it" if local_deleted
1682
+ else "dump deleted this record, local has a live edit to it"
1683
+ )
1684
+ print(
1685
+ f" record {rd.record_id} (group={rd.record_group}): delete-vs-update - "
1686
+ f"{side}"
1687
+ )
1688
+ continue
1689
+ if rd.local is None:
1690
+ print(
1691
+ f" record {rd.record_id} (group={rd.record_group}): dump-only "
1692
+ f"(not present locally)"
1693
+ )
1694
+ elif rd.dump is None:
1695
+ print(
1696
+ f" record {rd.record_id} (group={rd.record_group}): local-only "
1697
+ f"(not present in the dump)"
1698
+ )
1699
+ else:
1700
+ print(
1701
+ f" record {rd.record_id} (group={rd.record_group}): content differs "
1702
+ f"between local and dump"
1703
+ )
1704
+
1705
+ for fd in diff.schema_fields:
1706
+ side = "local only" if fd.present_locally else "dump only"
1707
+ print(f" schema field {fd.record_group}.{fd.field_name}: {side}")
1708
+
1709
+ return 1 if outstanding else 0
1710
+
1711
+
1712
+ def _cmd_pdata_sync_check(args: argparse.Namespace) -> int:
1713
+ """The spec's "Hourly `ccsched` job" trigger: per project, rehydrate-check and - only if no
1714
+ rehydrate happened - dump-check. The whole decision lives in `pdata.sync_check` (shared with
1715
+ nothing else today, but kept out of this handler for the same reason `dump.decide_publish`
1716
+ and `rehydrate.rehydrate` are: this file holds argparse plumbing and printing, not sync
1717
+ rules). This handler is the loop, the printing, and the exit-code mapping."""
1718
+ import sqlite3
1719
+
1720
+ from cc_session_tools.lib.pdata import sync_check, verify
1721
+
1722
+ projects = verify.discover_projects() if args.all_projects else [args.project]
1723
+ if not projects:
1724
+ print("ccst pdata sync-check: no project databases found", file=sys.stderr)
1725
+ return 2
1726
+
1727
+ compact = args.all_projects
1728
+ counts = {outcome.value: 0 for outcome in sync_check.SyncOutcome}
1729
+ errors = 0
1730
+ worst = 0
1731
+
1732
+ for project in projects:
1733
+ try:
1734
+ result = sync_check.check_project(project)
1735
+ except (OSError, ValueError, sqlite3.Error) as exc:
1736
+ # Record and continue, matching _cmd_pdata_dump/_cmd_pdata_rehydrate: one bad or
1737
+ # unreadable project must not abort the whole batch. The caught set is wider than
1738
+ # those two siblings' bare ValueError, and matches `cccs_hooks.pdata_sync`'s instead,
1739
+ # for the reason that module documents: this command's real caller is an unattended
1740
+ # ccsched job, where an uncaught sqlite3.Error on project 3 of 12 both loses the
1741
+ # other nine projects' cycle and counts as a crash toward auto-suspend. A genuinely
1742
+ # corrupt <project>.db is the concrete case - discover_projects() finds it by
1743
+ # filename, and opening it raises sqlite3.DatabaseError, not ValueError.
1744
+ print(f"ccst pdata sync-check: {project}: {exc}", file=sys.stderr)
1745
+ errors += 1
1746
+ worst = max(worst, 2)
1747
+ continue
1748
+ counts[result.outcome.value] += 1
1749
+
1750
+ if result.outcome is sync_check.SyncOutcome.CONFLICT:
1751
+ # sync_check.check_project has already pushed this through notify_conflict - the only
1752
+ # channel that reaches anyone when this runs unattended. Printing it too is for the
1753
+ # human who ran the command by hand.
1754
+ worst = max(worst, 1)
1755
+ if not compact:
1756
+ print(f"ccst pdata sync-check: {project}: {result.detail}", file=sys.stderr)
1757
+ elif not compact:
1758
+ print(f"ccst pdata sync-check: {project}: {_sync_check_line(result)}")
1759
+
1760
+ if compact:
1761
+ print(
1762
+ "ccst pdata sync-check --all-projects: "
1763
+ f"fast-forwarded {counts[sync_check.SyncOutcome.FAST_FORWARDED.value]}, "
1764
+ f"published {counts[sync_check.SyncOutcome.PUBLISHED.value]}, "
1765
+ f"unchanged {counts[sync_check.SyncOutcome.UNCHANGED.value]}, "
1766
+ f"conflict {counts[sync_check.SyncOutcome.CONFLICT.value]}, "
1767
+ f"deferred {counts[sync_check.SyncOutcome.DEFERRED.value]}, "
1768
+ f"occupied {counts[sync_check.SyncOutcome.OCCUPIED.value]}, "
1769
+ f"errors {errors} of {len(projects)} project(s)"
1770
+ )
1771
+
1772
+ # Same convention as _cmd_pdata_rehydrate's `worst`: 2 for a hard error, 1 for an unresolved
1773
+ # conflict, 0 otherwise. DEFERRED and OCCUPIED are transient, self-resolving states, not
1774
+ # findings, and contribute 0 - exactly as DEFERRED does there.
1775
+ return worst
1776
+
1777
+
1778
+ def _sync_check_line(result: SyncCheckResult) -> str:
1779
+ """The one-line, --project-mode wording for each non-conflict sync-check outcome."""
1780
+ from cc_session_tools.lib.pdata import sync_check
1781
+
1782
+ if result.outcome is sync_check.SyncOutcome.FAST_FORWARDED:
1783
+ return f"fast-forwarded from {result.from_machine}"
1784
+ if result.outcome is sync_check.SyncOutcome.PUBLISHED:
1785
+ return f"published (machine_id={result.machine_id})"
1786
+ if result.outcome is sync_check.SyncOutcome.UNCHANGED:
1787
+ return "unchanged - nothing new to publish"
1788
+ if result.outcome is sync_check.SyncOutcome.DEFERRED:
1789
+ return "another writer holds the lock - retry later"
1790
+ return "a live session is working in this project - skipped"
1791
+
1792
+
1793
+ # ---------- machine-identity show / confirm ----------
1794
+
1795
+
1796
+ def _cmd_machine_identity_show(args: argparse.Namespace) -> int:
1797
+ identity = machine_identity.resolve()
1798
+ if identity.confirmed:
1799
+ print(f"{identity.machine_id} (confirmed)")
1800
+ else:
1801
+ print(
1802
+ f"{identity.machine_id} (unconfirmed - run "
1803
+ "'ccst machine-identity confirm --name <name>')"
1804
+ )
1805
+ return 0
1806
+
1807
+
1808
+ def _cmd_machine_identity_confirm(args: argparse.Namespace) -> int:
1809
+ try:
1810
+ machine_identity.confirm(args.name)
1811
+ except ValueError as exc:
1812
+ print(f"ccst machine-identity: {exc}", file=sys.stderr)
1813
+ return 2
1814
+ print(f"Confirmed machine id: {args.name}")
1815
+ return 0
1816
+
1817
+
1396
1818
  # ---------- hooks run ----------
1397
1819
 
1398
1820
 
@@ -2508,6 +2930,82 @@ def _build_parser() -> argparse.ArgumentParser:
2508
2930
  "the default one-line summary (--project always prints full detail)",
2509
2931
  )
2510
2932
 
2933
+ pdata_dump_parser = pdata_sub.add_parser(
2934
+ "dump", help="Publish the current local DB state to .pdata-db-dump/latest.sql"
2935
+ )
2936
+ dump_target = pdata_dump_parser.add_mutually_exclusive_group(required=True)
2937
+ dump_target.add_argument("--project", metavar="NAME")
2938
+ dump_target.add_argument(
2939
+ "--all-projects", action="store_true",
2940
+ help="Dump every project with a .db under project-db/",
2941
+ )
2942
+ pdata_dump_parser.add_argument(
2943
+ "--force", action="store_true",
2944
+ help="Publish even if this would overwrite an unresolved fork, or a dump that's "
2945
+ "ahead of local (the checksum-invalid-dump recovery path)",
2946
+ )
2947
+
2948
+ pdata_rehydrate_parser = pdata_sub.add_parser(
2949
+ "rehydrate", help="Fast-forward the local DB from the published dump, if it's ahead"
2950
+ )
2951
+ rehydrate_target = pdata_rehydrate_parser.add_mutually_exclusive_group(required=True)
2952
+ rehydrate_target.add_argument("--project", metavar="NAME")
2953
+ rehydrate_target.add_argument(
2954
+ "--all-projects", action="store_true",
2955
+ help="Rehydrate every project with a .db under project-db/",
2956
+ )
2957
+ pdata_rehydrate_parser.add_argument(
2958
+ "--force", action="store_true",
2959
+ help="Fast-forward even over a local revision the dump doesn't dominate",
2960
+ )
2961
+
2962
+ pdata_resolve_parser = pdata_sub.add_parser(
2963
+ "resolve",
2964
+ help="Diagnose (default) or apply per-record local/dump choices for a "
2965
+ "cross-machine fork",
2966
+ )
2967
+ resolve_target = pdata_resolve_parser.add_mutually_exclusive_group(required=True)
2968
+ resolve_target.add_argument("--project", metavar="NAME")
2969
+ resolve_target.add_argument(
2970
+ "--all-projects", action="store_true",
2971
+ help="Diagnose every project with a .db under project-db/ (diagnostic mode only - "
2972
+ "--choice requires --project)",
2973
+ )
2974
+ pdata_resolve_parser.add_argument(
2975
+ "--choice", action="append", default=[], metavar="ID=local|dump",
2976
+ help="Apply a per-record resolution; may repeat. Requires --project. Without any "
2977
+ "--choice, resolve runs in diagnostic (dry-run) mode and prints the diff.",
2978
+ )
2979
+
2980
+ pdata_sync_check_parser = pdata_sub.add_parser(
2981
+ "sync-check",
2982
+ help="Rehydrate-check then (only if no rehydrate happened) dump-check - the unattended "
2983
+ "trigger behind the hourly pdata-sync-hourly ccsched job",
2984
+ )
2985
+ sync_check_target = pdata_sync_check_parser.add_mutually_exclusive_group(required=True)
2986
+ sync_check_target.add_argument("--project", metavar="NAME")
2987
+ sync_check_target.add_argument(
2988
+ "--all-projects", action="store_true",
2989
+ help="Sync-check every project with a .db under project-db/",
2990
+ )
2991
+ # Deliberately no --force. This is the automatic, repeating trigger: overriding a fork or a
2992
+ # checksum failure is a decision a human makes with `ccst pdata dump/rehydrate --force`,
2993
+ # never one an hourly cron job makes on their behalf.
2994
+
2995
+ # ---- machine-identity ----
2996
+ machine_identity_parser = sub.add_parser(
2997
+ "machine-identity", help="This laptop's identity for pdata's cross-machine vector clock"
2998
+ )
2999
+ machine_identity_sub = machine_identity_parser.add_subparsers(dest="verb", metavar="<verb>")
3000
+ machine_identity_sub.required = True
3001
+
3002
+ machine_identity_sub.add_parser("show", help="Print the resolved machine id and its confirmed state")
3003
+
3004
+ machine_identity_confirm_parser = machine_identity_sub.add_parser(
3005
+ "confirm", help="Store this laptop's confirmed machine id"
3006
+ )
3007
+ machine_identity_confirm_parser.add_argument("--name", required=True, metavar="NAME")
3008
+
2511
3009
  # ---- sessions ----
2512
3010
  sessions_parser = sub.add_parser("sessions", help="sessions.db management commands")
2513
3011
  sessions_sub = sessions_parser.add_subparsers(dest="verb", metavar="<verb>")
@@ -2797,6 +3295,20 @@ def main() -> None:
2797
3295
  sys.exit(_cmd_pdata_reconcile_session_output(args))
2798
3296
  if args.verb == "verify":
2799
3297
  sys.exit(_cmd_pdata_verify(args))
3298
+ if args.verb == "dump":
3299
+ sys.exit(_cmd_pdata_dump(args))
3300
+ if args.verb == "rehydrate":
3301
+ sys.exit(_cmd_pdata_rehydrate(args))
3302
+ if args.verb == "resolve":
3303
+ sys.exit(_cmd_pdata_resolve(args))
3304
+ if args.verb == "sync-check":
3305
+ sys.exit(_cmd_pdata_sync_check(args))
3306
+
3307
+ if args.noun == "machine-identity":
3308
+ if args.verb == "show":
3309
+ sys.exit(_cmd_machine_identity_show(args))
3310
+ if args.verb == "confirm":
3311
+ sys.exit(_cmd_machine_identity_confirm(args))
2800
3312
 
2801
3313
  if args.noun == "sessions":
2802
3314
  if args.verb == "migrate":
@@ -32,6 +32,24 @@
32
32
  "command": "ccst hooks run pending-rename",
33
33
  "timeout": 10,
34
34
  "statusMessage": "Checking for pending session-renames..."
35
+ },
36
+ {
37
+ "type": "command",
38
+ "command": "ccst hooks run pdata-sync",
39
+ "timeout": 10,
40
+ "statusMessage": "Checking for cross-machine pdata updates..."
41
+ }
42
+ ]
43
+ }
44
+ ],
45
+ "SessionEnd": [
46
+ {
47
+ "hooks": [
48
+ {
49
+ "type": "command",
50
+ "command": "ccst hooks run pdata-sync",
51
+ "timeout": 10,
52
+ "statusMessage": "Publishing pdata updates for other machines..."
35
53
  }
36
54
  ]
37
55
  }
@@ -33,6 +33,7 @@ HOOK_VERBS: dict[str, str] = {
33
33
  "pending-migration": "cccs_hooks.pending_migration",
34
34
  "context-window-warning": "cccs_hooks.context_window_warning",
35
35
  "pending-rename": "cccs_hooks.pending_rename",
36
+ "pdata-sync": "cccs_hooks.pdata_sync",
36
37
  }
37
38
 
38
39
 
@@ -50,6 +51,7 @@ HOOK_DESCRIPTIONS: dict[str, str] = {
50
51
  "pending-migration": "Detects legacy pre-1.0.0 flat-file data left unmigrated (ccmsg/ccsched/sessions/telemetry) and surfaces a FAIL digest pointing at `ccst migrate all`; honours `ccst doctor --mute` (SessionStart)",
51
52
  "context-window-warning": "Nudges toward /compact when the context window passes 150k/200k tokens; silenced for the session by /context-override (Stop)",
52
53
  "pending-rename": "Surfaces `.pending-rename` markers left by the move-session skill, skipping those whose /rename already landed and collapsing the list above 3; self-times-out at 5s with a visible notice (SessionStart)",
54
+ "pdata-sync": "Multi-laptop `ccst pdata` sync: rehydrates this project's DB from the published dump when it dominates local and the project isn't occupied by another live session (SessionStart), and publishes a fresh dump when local has new writes (SessionEnd); surfaces forks/checksum failures via Telegram + the catch-up digest",
53
55
  }
54
56
 
55
57
  # Every settings.json hook entry CCST owns is spelled `ccst hooks run <name>`.