paper_trail_diff 0.16.0 → 0.17.1

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 (206) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +581 -1
  3. data/README.md +42 -7
  4. data/docs/architecture.md +7 -5
  5. data/docs/performance.md +86 -38
  6. data/docs/reference.md +309 -92
  7. data/docs/testing.md +240 -32
  8. data/lib/paper_trail_diff/activity_belongs_to_event_applier.rb +2 -16
  9. data/lib/paper_trail_diff/activity_boundary.rb +55 -34
  10. data/lib/paper_trail_diff/activity_child_candidate_loader.rb +46 -57
  11. data/lib/paper_trail_diff/activity_collection_event_applier.rb +3 -13
  12. data/lib/paper_trail_diff/activity_collection_route_updater.rb +1 -1
  13. data/lib/paper_trail_diff/activity_event.rb +33 -21
  14. data/lib/paper_trail_diff/activity_event_record_resolver.rb +16 -116
  15. data/lib/paper_trail_diff/activity_event_route_finder.rb +29 -29
  16. data/lib/paper_trail_diff/activity_event_snapshot_refresher.rb +2 -7
  17. data/lib/paper_trail_diff/activity_history.rb +90 -49
  18. data/lib/paper_trail_diff/activity_range.rb +9 -35
  19. data/lib/paper_trail_diff/activity_root_snapshot_refresher.rb +74 -40
  20. data/lib/paper_trail_diff/activity_root_steps.rb +10 -13
  21. data/lib/paper_trail_diff/activity_scope_filter.rb +77 -0
  22. data/lib/paper_trail_diff/activity_snapshot_delta.rb +12 -15
  23. data/lib/paper_trail_diff/activity_snapshot_sequence.rb +37 -15
  24. data/lib/paper_trail_diff/activity_target_candidate_loader.rb +35 -43
  25. data/lib/paper_trail_diff/activity_timeline_builder.rb +194 -249
  26. data/lib/paper_trail_diff/activity_transaction_grouper.rb +3 -1
  27. data/lib/paper_trail_diff/activity_tree_filter.rb +54 -13
  28. data/lib/paper_trail_diff/activity_version_collector.rb +72 -138
  29. data/lib/paper_trail_diff/activity_view.rb +22 -11
  30. data/lib/paper_trail_diff/analysis.rb +19 -5
  31. data/lib/paper_trail_diff/analysis_batch.rb +16 -58
  32. data/lib/paper_trail_diff/approximate_paths.rb +4 -8
  33. data/lib/paper_trail_diff/association_activity_edge.rb +5 -24
  34. data/lib/paper_trail_diff/association_activity_selection.rb +10 -18
  35. data/lib/paper_trail_diff/association_discovery.rb +1 -6
  36. data/lib/paper_trail_diff/association_key.rb +9 -6
  37. data/lib/paper_trail_diff/association_traversal.rb +49 -6
  38. data/lib/paper_trail_diff/batch_boundary_resolver.rb +33 -42
  39. data/lib/paper_trail_diff/batch_preload.rb +2 -12
  40. data/lib/paper_trail_diff/batched_root_analyses.rb +72 -0
  41. data/lib/paper_trail_diff/batched_root_analyzer.rb +16 -14
  42. data/lib/paper_trail_diff/batched_root_versions.rb +25 -20
  43. data/lib/paper_trail_diff/branch_snapshot_refresher.rb +27 -31
  44. data/lib/paper_trail_diff/change_attribution.rb +329 -0
  45. data/lib/paper_trail_diff/change_row.rb +30 -10
  46. data/lib/paper_trail_diff/comparison_batch.rb +3 -4
  47. data/lib/paper_trail_diff/configuration.rb +1 -1
  48. data/lib/paper_trail_diff/deleted_analysis_batch.rb +22 -37
  49. data/lib/paper_trail_diff/deleted_root_filter.rb +3 -6
  50. data/lib/paper_trail_diff/deprecation.rb +4 -43
  51. data/lib/paper_trail_diff/diagnostics.rb +1 -2
  52. data/lib/paper_trail_diff/direct_record_state_loader.rb +8 -1
  53. data/lib/paper_trail_diff/endpoint.rb +78 -44
  54. data/lib/paper_trail_diff/errors.rb +2 -9
  55. data/lib/paper_trail_diff/fallback_paths.rb +2 -5
  56. data/lib/paper_trail_diff/habtm_transaction_owners.rb +5 -3
  57. data/lib/paper_trail_diff/historical_association_reifier.rb +3 -1
  58. data/lib/paper_trail_diff/historical_filter.rb +40 -15
  59. data/lib/paper_trail_diff/historical_snapshot_store.rb +80 -38
  60. data/lib/paper_trail_diff/instrumentation.rb +0 -8
  61. data/lib/paper_trail_diff/live_endpoint_batch_loader.rb +11 -7
  62. data/lib/paper_trail_diff/live_endpoint_provider.rb +7 -23
  63. data/lib/paper_trail_diff/live_graph_collector.rb +3 -3
  64. data/lib/paper_trail_diff/nested_comparator.rb +46 -19
  65. data/lib/paper_trail_diff/net_change.rb +276 -0
  66. data/lib/paper_trail_diff/own_window.rb +35 -0
  67. data/lib/paper_trail_diff/paper_trail_adapter.rb +40 -45
  68. data/lib/paper_trail_diff/prepared_activity_index.rb +197 -45
  69. data/lib/paper_trail_diff/prepared_child_candidates.rb +58 -0
  70. data/lib/paper_trail_diff/prepared_edge_loader.rb +43 -107
  71. data/lib/paper_trail_diff/prepared_history.rb +20 -31
  72. data/lib/paper_trail_diff/prepared_history_loader.rb +46 -9
  73. data/lib/paper_trail_diff/prepared_record_index.rb +137 -47
  74. data/lib/paper_trail_diff/prepared_snapshot_builder.rb +16 -0
  75. data/lib/paper_trail_diff/prepared_state_association_reader.rb +17 -19
  76. data/lib/paper_trail_diff/read_snapshot.rb +41 -19
  77. data/lib/paper_trail_diff/recorded_changes.rb +10 -11
  78. data/lib/paper_trail_diff/recorded_changes_reader.rb +60 -0
  79. data/lib/paper_trail_diff/recorded_class.rb +14 -19
  80. data/lib/paper_trail_diff/recorded_columns.rb +33 -0
  81. data/lib/paper_trail_diff/root_version_plan.rb +20 -22
  82. data/lib/paper_trail_diff/root_version_selection.rb +39 -29
  83. data/lib/paper_trail_diff/scope_condition.rb +7 -17
  84. data/lib/paper_trail_diff/scope_ranking.rb +16 -22
  85. data/lib/paper_trail_diff/scoped_analysis.rb +27 -4
  86. data/lib/paper_trail_diff/scoped_analysis_builder.rb +4 -3
  87. data/lib/paper_trail_diff/scoped_root_selection.rb +60 -41
  88. data/lib/paper_trail_diff/snapshot_normalizer.rb +18 -3
  89. data/lib/paper_trail_diff/stored_json_values.rb +52 -0
  90. data/lib/paper_trail_diff/stored_time_precision.rb +30 -18
  91. data/lib/paper_trail_diff/stored_values.rb +20 -0
  92. data/lib/paper_trail_diff/support.rb +185 -35
  93. data/lib/paper_trail_diff/time_of_day.rb +39 -0
  94. data/lib/paper_trail_diff/time_range.rb +37 -20
  95. data/lib/paper_trail_diff/time_version_range.rb +5 -10
  96. data/lib/paper_trail_diff/timeline_builder.rb +3 -3
  97. data/lib/paper_trail_diff/timeline_range.rb +18 -12
  98. data/lib/paper_trail_diff/timeline_snapshot_provider.rb +1 -1
  99. data/lib/paper_trail_diff/total_order.rb +55 -0
  100. data/lib/paper_trail_diff/transaction_cut.rb +192 -91
  101. data/lib/paper_trail_diff/traversal_preparer.rb +5 -8
  102. data/lib/paper_trail_diff/value_objects.rb +8 -4
  103. data/lib/paper_trail_diff/version.rb +1 -1
  104. data/lib/paper_trail_diff/version_association_candidate_scope.rb +27 -16
  105. data/lib/paper_trail_diff/version_boundary.rb +37 -21
  106. data/lib/paper_trail_diff/version_query.rb +25 -25
  107. data/lib/paper_trail_diff/version_range.rb +12 -16
  108. data/lib/paper_trail_diff/version_sequence_diagnostics.rb +32 -0
  109. data/lib/paper_trail_diff/version_table.rb +12 -8
  110. data/lib/paper_trail_diff.rb +28 -42
  111. data/sig/generated/paper_trail_diff/activity_belongs_to_event_applier.rbs +0 -8
  112. data/sig/generated/paper_trail_diff/activity_boundary.rbs +39 -17
  113. data/sig/generated/paper_trail_diff/activity_child_candidate_loader.rbs +19 -22
  114. data/sig/generated/paper_trail_diff/activity_collection_event_applier.rbs +0 -5
  115. data/sig/generated/paper_trail_diff/activity_event.rbs +25 -9
  116. data/sig/generated/paper_trail_diff/activity_event_record_resolver.rbs +6 -34
  117. data/sig/generated/paper_trail_diff/activity_event_route_finder.rbs +11 -4
  118. data/sig/generated/paper_trail_diff/activity_event_snapshot_refresher.rbs +0 -3
  119. data/sig/generated/paper_trail_diff/activity_history.rbs +54 -19
  120. data/sig/generated/paper_trail_diff/activity_range.rbs +6 -20
  121. data/sig/generated/paper_trail_diff/activity_root_snapshot_refresher.rbs +36 -2
  122. data/sig/generated/paper_trail_diff/activity_root_steps.rbs +6 -6
  123. data/sig/generated/paper_trail_diff/activity_scope_filter.rbs +51 -0
  124. data/sig/generated/paper_trail_diff/activity_snapshot_delta.rbs +5 -3
  125. data/sig/generated/paper_trail_diff/activity_snapshot_sequence.rbs +21 -3
  126. data/sig/generated/paper_trail_diff/activity_target_candidate_loader.rbs +19 -24
  127. data/sig/generated/paper_trail_diff/activity_timeline_builder.rbs +121 -127
  128. data/sig/generated/paper_trail_diff/activity_tree_filter.rbs +41 -8
  129. data/sig/generated/paper_trail_diff/activity_version_collector.rbs +42 -35
  130. data/sig/generated/paper_trail_diff/activity_view.rbs +16 -8
  131. data/sig/generated/paper_trail_diff/analysis.rbs +15 -6
  132. data/sig/generated/paper_trail_diff/analysis_batch.rbs +6 -24
  133. data/sig/generated/paper_trail_diff/association_activity_edge.rbs +0 -13
  134. data/sig/generated/paper_trail_diff/association_activity_selection.rbs +6 -9
  135. data/sig/generated/paper_trail_diff/association_discovery.rbs +0 -3
  136. data/sig/generated/paper_trail_diff/association_key.rbs +5 -0
  137. data/sig/generated/paper_trail_diff/association_traversal.rbs +26 -2
  138. data/sig/generated/paper_trail_diff/batch_boundary_resolver.rbs +17 -17
  139. data/sig/generated/paper_trail_diff/batch_preload.rbs +0 -4
  140. data/sig/generated/paper_trail_diff/batched_root_analyses.rbs +47 -0
  141. data/sig/generated/paper_trail_diff/batched_root_analyzer.rbs +9 -8
  142. data/sig/generated/paper_trail_diff/batched_root_versions.rbs +10 -6
  143. data/sig/generated/paper_trail_diff/branch_snapshot_refresher.rbs +11 -5
  144. data/sig/generated/paper_trail_diff/change_attribution.rbs +194 -0
  145. data/sig/generated/paper_trail_diff/change_row.rbs +22 -7
  146. data/sig/generated/paper_trail_diff/deleted_analysis_batch.rbs +11 -12
  147. data/sig/generated/paper_trail_diff/deleted_root_filter.rbs +0 -2
  148. data/sig/generated/paper_trail_diff/deprecation.rbs +4 -24
  149. data/sig/generated/paper_trail_diff/direct_record_state_loader.rbs +4 -0
  150. data/sig/generated/paper_trail_diff/endpoint.rbs +40 -16
  151. data/sig/generated/paper_trail_diff/errors.rbs +2 -11
  152. data/sig/generated/paper_trail_diff/habtm_transaction_owners.rbs +2 -1
  153. data/sig/generated/paper_trail_diff/historical_filter.rbs +20 -9
  154. data/sig/generated/paper_trail_diff/historical_snapshot_store.rbs +40 -10
  155. data/sig/generated/paper_trail_diff/instrumentation.rbs +0 -3
  156. data/sig/generated/paper_trail_diff/live_endpoint_batch_loader.rbs +3 -0
  157. data/sig/generated/paper_trail_diff/live_endpoint_provider.rbs +5 -8
  158. data/sig/generated/paper_trail_diff/live_graph_collector.rbs +2 -2
  159. data/sig/generated/paper_trail_diff/nested_comparator.rbs +20 -4
  160. data/sig/generated/paper_trail_diff/net_change.rbs +168 -0
  161. data/sig/generated/paper_trail_diff/own_window.rbs +22 -0
  162. data/sig/generated/paper_trail_diff/paper_trail_adapter.rbs +9 -6
  163. data/sig/generated/paper_trail_diff/prepared_activity_index.rbs +114 -14
  164. data/sig/generated/paper_trail_diff/prepared_child_candidates.rbs +39 -0
  165. data/sig/generated/paper_trail_diff/prepared_edge_loader.rbs +18 -35
  166. data/sig/generated/paper_trail_diff/prepared_history.rbs +9 -12
  167. data/sig/generated/paper_trail_diff/prepared_history_loader.rbs +28 -3
  168. data/sig/generated/paper_trail_diff/prepared_record_index.rbs +68 -14
  169. data/sig/generated/paper_trail_diff/prepared_snapshot_builder.rbs +12 -0
  170. data/sig/generated/paper_trail_diff/prepared_state_association_reader.rbs +6 -7
  171. data/sig/generated/paper_trail_diff/read_snapshot.rbs +27 -8
  172. data/sig/generated/paper_trail_diff/recorded_changes.rbs +4 -2
  173. data/sig/generated/paper_trail_diff/recorded_changes_reader.rbs +41 -0
  174. data/sig/generated/paper_trail_diff/recorded_class.rbs +7 -6
  175. data/sig/generated/paper_trail_diff/recorded_columns.rbs +21 -0
  176. data/sig/generated/paper_trail_diff/root_version_plan.rbs +8 -4
  177. data/sig/generated/paper_trail_diff/root_version_selection.rbs +27 -13
  178. data/sig/generated/paper_trail_diff/scope_condition.rbs +0 -2
  179. data/sig/generated/paper_trail_diff/scope_ranking.rbs +10 -10
  180. data/sig/generated/paper_trail_diff/scoped_analysis.rbs +19 -0
  181. data/sig/generated/paper_trail_diff/scoped_analysis_builder.rbs +2 -2
  182. data/sig/generated/paper_trail_diff/scoped_root_selection.rbs +37 -14
  183. data/sig/generated/paper_trail_diff/snapshot_normalizer.rbs +7 -0
  184. data/sig/generated/paper_trail_diff/stored_json_values.rbs +35 -0
  185. data/sig/generated/paper_trail_diff/stored_time_precision.rbs +19 -5
  186. data/sig/generated/paper_trail_diff/stored_values.rbs +13 -0
  187. data/sig/generated/paper_trail_diff/support.rbs +120 -23
  188. data/sig/generated/paper_trail_diff/time_of_day.rbs +21 -0
  189. data/sig/generated/paper_trail_diff/time_range.rbs +15 -8
  190. data/sig/generated/paper_trail_diff/time_version_range.rbs +2 -5
  191. data/sig/generated/paper_trail_diff/timeline_builder.rbs +2 -2
  192. data/sig/generated/paper_trail_diff/timeline_range.rbs +12 -7
  193. data/sig/generated/paper_trail_diff/total_order.rbs +32 -0
  194. data/sig/generated/paper_trail_diff/transaction_cut.rbs +111 -52
  195. data/sig/generated/paper_trail_diff/traversal_preparer.rbs +2 -2
  196. data/sig/generated/paper_trail_diff/value_objects.rbs +5 -1
  197. data/sig/generated/paper_trail_diff/version_association_candidate_scope.rbs +10 -9
  198. data/sig/generated/paper_trail_diff/version_boundary.rbs +15 -8
  199. data/sig/generated/paper_trail_diff/version_query.rbs +17 -10
  200. data/sig/generated/paper_trail_diff/version_range.rbs +6 -9
  201. data/sig/generated/paper_trail_diff/version_sequence_diagnostics.rbs +13 -0
  202. data/sig/generated/paper_trail_diff/version_table.rbs +3 -0
  203. data/sig/generated/paper_trail_diff.rbs +16 -16
  204. metadata +28 -6
  205. data/lib/paper_trail_diff/preloaded_endpoint_batch_loader.rb +0 -60
  206. data/sig/generated/paper_trail_diff/preloaded_endpoint_batch_loader.rbs +0 -32
@@ -2,9 +2,11 @@
2
2
 
3
3
  module PaperTrailDiff
4
4
  # Collects root and selected-descendant versions relevant to one root history range.
5
+ # Descendants are found in the root's prepared history.
5
6
  class ActivityVersionCollector
6
- # : (untyped, root_versions: Array[untyped], tree: AssociationTree, ?range_start: untyped, ?range_end: untyped, ?prepared: PreparedActivityIndex?) -> void
7
- def initialize: (untyped, root_versions: Array[untyped], tree: AssociationTree, ?range_start: untyped, ?range_end: untyped, ?prepared: PreparedActivityIndex?) -> void
7
+ # `traversal` holds the tree whose descendants are collected.
8
+ # : (untyped, root_versions: Array[untyped], traversal: AssociationTraversal, range_start: untyped, range_end: untyped, prepared: PreparedActivityIndex?) -> void
9
+ def initialize: (untyped, root_versions: Array[untyped], traversal: AssociationTraversal, range_start: untyped, range_end: untyped, prepared: PreparedActivityIndex?) -> void
8
10
 
9
11
  # A tie between version tables, or between ids that do not count up,
10
12
  # raises rather than building a timeline in an arbitrary order.
@@ -13,7 +15,7 @@ module PaperTrailDiff
13
15
 
14
16
  private
15
17
 
16
- @prepared: PreparedActivityIndex?
18
+ @prepared: PreparedActivityIndex
17
19
 
18
20
  @range: ActivityRange
19
21
 
@@ -25,48 +27,53 @@ module PaperTrailDiff
25
27
 
26
28
  @traversal: AssociationTraversal
27
29
 
28
- @tree: AssociationTree
29
-
30
- # : (untyped, Array[untyped], AssociationTree, path: String, branch: String?) -> void
31
- def collect_tree: (untyped, Array[untyped], AssociationTree, path: String, branch: String?) -> void
30
+ # Each event is credited to the top-level association it was reached
31
+ # through.
32
+ # : (Hash[Symbol, untyped], AssociationTree, path: String, branch: String?) -> void
33
+ def collect_tree: (Hash[Symbol, untyped], AssociationTree, path: String, branch: String?) -> void
32
34
 
33
35
  # : (Hash[Symbol, untyped], untyped, AssociationTree, String, String) -> void
34
36
  def collect_reflection: (Hash[Symbol, untyped], untyped, AssociationTree, String, String) -> void
35
37
 
36
- # : (Hash[Symbol, untyped], untyped, String) -> Hash[String, untyped]
37
- def edge_groups: (Hash[Symbol, untyped], untyped, String) -> Hash[String, untyped]
38
+ # The groups of records an edge leads to, one for each class.
39
+ # : (Hash[Symbol, untyped], untyped, String) -> Array[Hash[Symbol, untyped]]
40
+ def edge_groups: (Hash[Symbol, untyped], untyped, String) -> Array[Hash[Symbol, untyped]]
38
41
 
39
- # : (Hash[Symbol, untyped], untyped, String) -> Hash[String, untyped]
40
- def through_groups: (Hash[Symbol, untyped], untyped, String) -> Hash[String, untyped]
42
+ # A through's join part is one class, never polymorphic, so one group of
43
+ # join rows leads to its targets.
44
+ # : (Hash[Symbol, untyped], untyped, String) -> Array[Hash[Symbol, untyped]]
45
+ def through_groups: (Hash[Symbol, untyped], untyped, String) -> Array[Hash[Symbol, untyped]]
41
46
 
42
47
  # Every target the owners pointed at in the range, not only those their own
43
48
  # changes there recorded: an author renamed under an article nobody edited
44
- # is still that article's activity.
45
- # : (untyped, Array[untyped], untyped) -> Hash[String, untyped]
46
- def belongs_to_groups: (untyped, Array[untyped], untyped) -> Hash[String, untyped]
47
-
48
- # : (untyped, Array[untyped], untyped) -> Hash[String, untyped]
49
- def unprepared_belongs_to_groups: (untyped, Array[untyped], untyped) -> Hash[String, untyped]
50
-
51
- # : (untyped, Array[untyped], untyped) -> Hash[String, untyped]
52
- def direct_child_groups: (untyped, Array[untyped], untyped) -> Hash[String, untyped]
53
-
54
- # : (untyped, Array[untyped], untyped) -> Hash[String, untyped]
55
- def habtm_groups: (untyped, Array[untyped], untyped) -> Hash[String, untyped]
56
-
57
- # : (Array[untyped], untyped) ?{ (untyped, untyped) -> bool } -> Hash[String, untyped]
58
- def identity_groups: (Array[untyped], untyped) ?{ (untyped, untyped) -> bool } -> Hash[String, untyped]
49
+ # is still that article's activity. Prepared history holds every target its
50
+ # snapshots can contain. One it did not load -- a key changed without a
51
+ # version -- has no state to compare.
52
+ # : (untyped, Array[untyped], untyped) -> Array[Hash[Symbol, untyped]]
53
+ def belongs_to_groups: (untyped, Array[untyped], untyped) -> Array[Hash[Symbol, untyped]]
54
+
55
+ # With no children, nothing below them is read: prepared history registers
56
+ # only the classes it loaded records of.
57
+ # : (untyped, Array[untyped], untyped) -> Array[Hash[Symbol, untyped]]
58
+ def direct_child_groups: (untyped, Array[untyped], untyped) -> Array[Hash[Symbol, untyped]]
59
+
60
+ # : (untyped, Array[untyped], untyped) -> Array[Hash[Symbol, untyped]]
61
+ def habtm_groups: (untyped, Array[untyped], untyped) -> Array[Hash[Symbol, untyped]]
62
+
63
+ # A type a polymorphic row stored that names no class has no versions to
64
+ # read.
65
+ # : (Array[untyped], untyped) ?{ (untyped, untyped) -> bool } -> Array[Hash[Symbol, untyped]]
66
+ def identity_groups: (Array[untyped], untyped) ?{ (untyped, untyped) -> bool } -> Array[Hash[Symbol, untyped]]
67
+
68
+ # Each target once, however many rows name it, and none for a row that
69
+ # names none. The registry keeps a version once, and a missing target has
70
+ # no versions, so this only saves reading them again, which is why mutant
71
+ # leaves it alone.
72
+ # mutant:disable
73
+ # : (Array[untyped]) -> Array[untyped]
74
+ def target_ids: (Array[untyped]) -> Array[untyped]
59
75
 
60
76
  # : (untyped, Array[untyped]) -> Hash[Symbol, untyped]
61
77
  def group: (untyped, Array[untyped]) -> Hash[Symbol, untyped]
62
-
63
- # : (Hash[String, untyped], Hash[String, untyped]) -> void
64
- def merge_groups!: (Hash[String, untyped], Hash[String, untyped]) -> void
65
-
66
- # : (untyped, Array[untyped]) -> Array[untyped]
67
- def versions_for: (untyped, Array[untyped]) -> Array[untyped]
68
-
69
- # : (untyped, untyped) -> untyped
70
- def target_class: (untyped, untyped) -> untyped
71
78
  end
72
79
  end
@@ -8,20 +8,26 @@ module PaperTrailDiff
8
8
  # history would read differently depending on how it was asked for.
9
9
  class ActivityView
10
10
  # Options only an activity view uses are refused without one.
11
- # : (activity: bool, snapshots: bool, group: Symbol?, recorded: IgnorePolicy?) -> ActivityView
12
- def self.build: (activity: bool, snapshots: bool, group: Symbol?, recorded: IgnorePolicy?) -> ActivityView
11
+ # : (activity: bool, snapshots: bool, group: Symbol?, recorded: IgnorePolicy?, ?version_scope: untyped) -> ActivityView
12
+ def self.build: (activity: bool, snapshots: bool, group: Symbol?, recorded: IgnorePolicy?, ?version_scope: untyped) -> ActivityView
13
13
 
14
- # : (?snapshots: bool, ?group: Symbol?, ?recorded: IgnorePolicy?) -> void
15
- def initialize: (?snapshots: bool, ?group: Symbol?, ?recorded: IgnorePolicy?) -> void
14
+ # : (?snapshots: bool, ?group: Symbol?, ?recorded: IgnorePolicy?, ?version_scope: untyped) -> void
15
+ def initialize: (?snapshots: bool, ?group: Symbol?, ?recorded: IgnorePolicy?, ?version_scope: untyped) -> void
16
+
17
+ # Which events of activity on associations a `version_scope:` reports,
18
+ # answered once for the whole request; nil without one.
19
+ attr_reader version_filter: ActivityScopeFilter?
16
20
 
17
21
  # Merging a group compares its outer states, so the snapshots must survive
18
22
  # the build even when the caller did not ask to keep them.
19
23
  # : () -> bool
20
24
  def retain?: () -> bool
21
25
 
22
- # The attributes a boundary's version recorded, when they were asked for.
23
- # : (root: bool) -> Array[String]?
24
- def recorded_attributes: (root: bool) -> Array[String]?
26
+ # Reads what a boundary's version recorded, once per version for the whole
27
+ # request, when they were asked for. The root's own versions leave out the
28
+ # names ignored on its path as well.
29
+ # : (root: bool) -> RecordedChangesReader?
30
+ def recorded_reader: (root: bool) -> RecordedChangesReader?
25
31
 
26
32
  # Applied last, to finished steps, so grouping sees the same timeline the
27
33
  # caller would otherwise have received.
@@ -32,10 +38,12 @@ module PaperTrailDiff
32
38
 
33
39
  @group: Symbol?
34
40
 
35
- @recorded: IgnorePolicy?
41
+ @readers: Hash[bool, RecordedChangesReader]?
36
42
 
37
43
  @snapshots: bool
38
44
 
45
+ @version_filter: ActivityScopeFilter?
46
+
39
47
  # : () -> bool
40
48
  def grouping?: () -> bool
41
49
  end
@@ -13,10 +13,10 @@ module PaperTrailDiff
13
13
 
14
14
  attr_reader to_snapshot: RecordSnapshot?
15
15
 
16
- # The time window the analysis covers, or nil without one. It is the
17
- # window asked for unless a transaction crossed an edge, which moves the
18
- # edge back to where that transaction began.
19
- attr_reader window: Range[Time]?
16
+ # The time window the analysis covers, or nil without one; a report's has
17
+ # no end. It is the window asked for unless a transaction crossed an edge,
18
+ # which moves the edge back to where that transaction began.
19
+ attr_reader window: Range[Time?]?
20
20
 
21
21
  # The result for a record whose requested history contains no versions,
22
22
  # which is an empty history rather than a failed request. Its snapshots
@@ -29,8 +29,8 @@ module PaperTrailDiff
29
29
 
30
30
  # The reconstructed states the diff was taken between. A report that has to
31
31
  # render unchanged columns needs the whole final state, not only what moved.
32
- # : (diff: Diff, timeline: Array[Step], ?activity_timeline: Array[ActivityStep]?, ?from_snapshot: RecordSnapshot?, ?to_snapshot: RecordSnapshot?, ?window: Range[Time]?) -> void
33
- def initialize: (diff: Diff, timeline: Array[Step], ?activity_timeline: Array[ActivityStep]?, ?from_snapshot: RecordSnapshot?, ?to_snapshot: RecordSnapshot?, ?window: Range[Time]?) -> void
32
+ # : (diff: Diff, timeline: Array[Step], ?activity_timeline: Array[ActivityStep]?, ?from_snapshot: RecordSnapshot?, ?to_snapshot: RecordSnapshot?, ?window: Range[Time?]?) -> void
33
+ def initialize: (diff: Diff, timeline: Array[Step], ?activity_timeline: Array[ActivityStep]?, ?from_snapshot: RecordSnapshot?, ?to_snapshot: RecordSnapshot?, ?window: Range[Time?]?) -> void
34
34
 
35
35
  # The same result for the window it was read in, which the caller knows
36
36
  # once it has moved the window's edges to transactions.
@@ -42,6 +42,15 @@ module PaperTrailDiff
42
42
  # : () -> Array[ChangeRow]
43
43
  def change_rows: () -> Array[ChangeRow]
44
44
 
45
+ # One entry for each record the activity's change rows are about: its
46
+ # state before them, and that state with only the kept changes made (see
47
+ # NetChange). The block picks the rows to keep, such as those with an
48
+ # author; without one, every row is kept. The states come from the
49
+ # steps' snapshots, so this needs `snapshots: true` as well as
50
+ # `activity: true`.
51
+ # : () ?{ (ChangeRow) -> boolish } -> Array[NetChange]
52
+ def net_changes: () ?{ (ChangeRow) -> boolish } -> Array[NetChange]
53
+
45
54
  # Reconstructed endpoint states are opt-in, because they carry the whole
46
55
  # selected graph whether or not anything changed, which dwarfs the rest of
47
56
  # the payload for a wide graph.
@@ -5,8 +5,10 @@ module PaperTrailDiff
5
5
  # versions and preparing their association history once for the whole batch
6
6
  # rather than once per root.
7
7
  class AnalysisBatch
8
- # : (Array[untyped], time_range: TimeRange?, live_loader: untyped, history_preparer: untyped, analyzer: untyped, ?version_scope: untyped, ?context_required: bool) -> void
9
- def initialize: (Array[untyped], time_range: TimeRange?, live_loader: untyped, history_preparer: untyped, analyzer: untyped, ?version_scope: untyped, ?context_required: bool) -> void
8
+ # `traversal` names the requested paths, which decide where a window's
9
+ # edges move (see TransactionCut).
10
+ # : (Array[untyped], time_range: TimeRange?, live_loader: untyped, history_preparer: untyped, analyzer: untyped, version_scope: untyped, context_required: bool, traversal: AssociationTraversal?) -> void
11
+ def initialize: (Array[untyped], time_range: TimeRange?, live_loader: untyped, history_preparer: untyped, analyzer: untyped, version_scope: untyped, context_required: bool, traversal: AssociationTraversal?) -> void
10
12
 
11
13
  # : () -> Hash[identity, Analysis]
12
14
  def call: () -> Hash[identity, Analysis]
@@ -25,31 +27,11 @@ module PaperTrailDiff
25
27
 
26
28
  @time_range: TimeRange?
27
29
 
30
+ @traversal: AssociationTraversal?
31
+
28
32
  @version_scope: untyped
29
33
 
30
34
  # : () -> Array[untyped]
31
35
  def validated_records: () -> Array[untyped]
32
-
33
- # Association history is prepared per model class across every selected root
34
- # version, which is the work that would otherwise repeat for each record.
35
- # The roots are preloaded first, because preparation reads their current
36
- # association state as a fallback and would otherwise walk it one root at a
37
- # time.
38
- # : (Array[untyped], Hash[Array[String], RootVersionPlan], Hash[Array[String], untyped], Hash[Array[String], TimeRange]) -> void
39
- def prepare: (Array[untyped], Hash[Array[String], RootVersionPlan], Hash[Array[String], untyped], Hash[Array[String], TimeRange]) -> void
40
-
41
- # : (Array[untyped], Hash[Array[String], RootVersionPlan]) -> bool
42
- def closes_live?: (Array[untyped], Hash[Array[String], RootVersionPlan]) -> bool
43
-
44
- # A plan closing on the live record reads history up to now; the others
45
- # stop at the window, so a past window does not load everything since.
46
- # : (Array[untyped], Hash[Array[String], TimeRange], live: bool) -> Hash[Symbol, untyped]
47
- def preparation_range: (Array[untyped], Hash[Array[String], TimeRange], live: bool) -> Hash[Symbol, untyped]
48
-
49
- # A root with no versions in range has nothing to report, which is an empty
50
- # result rather than a failed request -- unless an activity view closes it
51
- # on current state, where its descendants may still have moved.
52
- # : (untyped, RootVersionPlan, TimeRange?) -> Analysis
53
- def analysis_for: (untyped, RootVersionPlan, TimeRange?) -> Analysis
54
36
  end
55
37
  end
@@ -113,19 +113,6 @@ module PaperTrailDiff
113
113
  # mutant:disable
114
114
  # : () -> untyped
115
115
  def quoted_owner_column: () -> untyped
116
-
117
- # Arel ships no signatures; see VersionQuery. Any spelling of the
118
- # constant finds the same module.
119
- # mutant:disable
120
- # : () -> untyped
121
- def arel: () -> untyped
122
-
123
- # Active Record 7.1 has no `with_connection`; see VersionAssociationCandidateScope.
124
- # Only that version takes the fallback, so no spec run on a newer one can
125
- # tell its mutations apart.
126
- # mutant:disable
127
- # : [T] () { (untyped) -> T } -> T
128
- def connected: [T] () { (untyped) -> T } -> T
129
116
  end
130
117
 
131
118
  # The owners whose versions PT-AT recorded a HABTM target with, keyed by
@@ -14,8 +14,6 @@ module PaperTrailDiff
14
14
  # per root. Ids stay in a subquery while the columns compared share a type;
15
15
  # otherwise they are read and the edge runs over them in slices.
16
16
  class AssociationActivitySelection
17
- SLICE: ::Integer
18
-
19
17
  # The ids a one-column subquery selects, with that column's type: a
20
18
  # database compares columns of one type only, and PostgreSQL rejects an
21
19
  # integer key against a string item_id outright.
@@ -44,8 +42,10 @@ module PaperTrailDiff
44
42
  # : (Array[source]) -> Array[untyped]
45
43
  def self.values: (Array[source]) -> Array[untyped]
46
44
 
47
- # : (untyped, tree: AssociationTree, time_range: TimeRange?) -> void
48
- def initialize: (untyped, tree: AssociationTree, time_range: TimeRange?) -> void
45
+ # Only the versions `version_scope` keeps select a root, on its
46
+ # associations as on its own versions.
47
+ # : (untyped, tree: AssociationTree, time_range: TimeRange?, ?version_scope: untyped) -> void
48
+ def initialize: (untyped, tree: AssociationTree, time_range: TimeRange?, ?version_scope: untyped) -> void
49
49
 
50
50
  # The roots' ids, each source a subquery or an array of values.
51
51
  # : () -> Array[source]
@@ -59,6 +59,8 @@ module PaperTrailDiff
59
59
 
60
60
  @traversal: AssociationTraversal
61
61
 
62
+ @version_scope: untyped
63
+
62
64
  # Ids of `model` records with a change somewhere below them in `tree`: the
63
65
  # targets that changed, or that reach a change further down.
64
66
  # : (untyped, AssociationTree, String) -> Array[source]
@@ -103,10 +105,5 @@ module PaperTrailDiff
103
105
  # mutant:disable
104
106
  # : (source, Symbol?) -> Query?
105
107
  def subquery: (source, Symbol?) -> Query?
106
-
107
- # A type naming no class has no versions to read; `changed` skips one that
108
- # names an unversioned class.
109
- # : (String) -> untyped
110
- def target_class: (String) -> untyped
111
108
  end
112
109
  end
@@ -59,8 +59,5 @@ module PaperTrailDiff
59
59
 
60
60
  # : (untyped) -> String?
61
61
  def reflection_target_name: (untyped) -> String?
62
-
63
- # : (String, String) -> String
64
- def association_path: (String, String) -> String
65
62
  end
66
63
  end
@@ -10,6 +10,11 @@ module PaperTrailDiff
10
10
  # : (untyped) -> String?
11
11
  def self.unsupported_reason: (untyped) -> String?
12
12
 
13
+ # The association's foreign key column, or nil for a composite key, which
14
+ # loaded history cannot index. Active Record names a column as a string.
15
+ # : (untyped) -> String?
16
+ def self.scalar_foreign_key: (untyped) -> String?
17
+
13
18
  # The reflection, or the first part of a through, keyed on a column other
14
19
  # than its owner's or target's primary key.
15
20
  # : (untyped) -> untyped
@@ -19,6 +19,11 @@ module PaperTrailDiff
19
19
  # : (untyped, untyped) -> bool
20
20
  def self.source_type_member?: (untyped, untyped) -> bool
21
21
 
22
+ # Every part a through passes, at any depth: its through part and that
23
+ # part's own parts, then its source part and that part's own parts.
24
+ # : (untyped) -> Array[untyped]
25
+ def self.through_parts: (untyped) -> Array[untyped]
26
+
22
27
  # The class a stored type names, or nil when it names none.
23
28
  # This class defines no constants of its own, so the one mutation left,
24
29
  # `const_get` on it rather than on Object, finds the same class.
@@ -26,6 +31,11 @@ module PaperTrailDiff
26
31
  # : (String) -> untyped
27
32
  def self.named_class: (String) -> untyped
28
33
 
34
+ # The class a belongs_to's target is, given the type a polymorphic one
35
+ # stored: nil when that names no class.
36
+ # : (untyped, untyped) -> untyped
37
+ def self.stored_target: (untyped, untyped) -> untyped
38
+
29
39
  # A type left by a renamed or removed model names no class. Active Record
30
40
  # and PT-AT raise a bare NameError for it, which does not say where it is.
31
41
  # : (untyped, untyped, String) -> untyped
@@ -91,9 +101,20 @@ module PaperTrailDiff
91
101
  # : (untyped) -> Array[Array[untyped]]
92
102
  def selected_reflections: (untyped) -> Array[Array[untyped]]
93
103
 
104
+ # The names the versions of the records on the requested paths are stored
105
+ # under: each association's class and every part a through passes. A
106
+ # polymorphic belongs_to names its target's class only in each record, so
107
+ # it adds none.
108
+ # : (untyped) -> Array[String]
109
+ def path_types: (untyped) -> Array[String]
110
+
94
111
  # : (untyped, untyped) -> void
95
112
  def ensure_habtm_history!: (untyped, untyped) -> void
96
113
 
114
+ # Every snapshot of a version asks, so each class's answer is kept; the
115
+ # tree and the class decide it. Reading it again each time answers the
116
+ # same, which is why mutant leaves the cache alone.
117
+ # mutant:disable
97
118
  # : (untyped) -> Array[String]
98
119
  def habtm_paths: (untyped) -> Array[String]
99
120
 
@@ -106,7 +127,8 @@ module PaperTrailDiff
106
127
  # A model and a tree resolve to the same reflections wherever they are
107
128
  # read: a tree is only ever walked from one place, the root tree at the
108
129
  # root and a subtree below it. Beyond that, the path only names a failure,
109
- # and a failure is not cached.
130
+ # and a failure is not cached. Each record is read at every boundary, so
131
+ # the lookup builds no key.
110
132
  # : (untyped, AssociationTree, path: String) -> Array[untyped]
111
133
  def reflections_for: (untyped, AssociationTree, path: String) -> Array[untyped]
112
134
 
@@ -117,7 +139,9 @@ module PaperTrailDiff
117
139
 
118
140
  private
119
141
 
120
- @reflection_cache: Hash[Array[untyped], Array[untyped]]
142
+ @habtm_paths: Hash[untyped, Array[String]]
143
+
144
+ @reflection_cache: Hash[AssociationTree, Hash[untyped, Array[untyped]]]
121
145
 
122
146
  @tree: AssociationTree
123
147
 
@@ -1,9 +1,9 @@
1
1
  # Generated from lib/paper_trail_diff/batch_boundary_resolver.rb with RBS::Inline
2
2
 
3
3
  module PaperTrailDiff
4
- # Resolves `:first` endpoints for a whole batch in a fixed number of queries per
5
- # model class. Left to the caller this is a per-root lookup, which reintroduces
6
- # exactly the queries a batched comparison exists to remove.
4
+ # Resolves `:first` endpoints for a whole batch in one query per 500 roots
5
+ # of a model class. Left to the caller this is a per-root lookup, which
6
+ # reintroduces exactly the queries a batched comparison exists to remove.
7
7
  class BatchBoundaryResolver
8
8
  BOUNDARIES: untyped
9
9
 
@@ -26,34 +26,34 @@ module PaperTrailDiff
26
26
  # : (untyped) -> bool
27
27
  def symbolic?: (untyped) -> bool
28
28
 
29
- # : (untyped, untyped, Hash[Array[String], Hash[Symbol, untyped]]) -> untyped
30
- def resolve: (untyped, untyped, Hash[Array[String], Hash[Symbol, untyped]]) -> untyped
29
+ # : (untyped, untyped, Hash[Array[String], untyped]) -> untyped
30
+ def resolve: (untyped, untyped, Hash[Array[String], untyped]) -> untyped
31
31
 
32
32
  # A symbol carries no identity of its own, so the pair's other endpoint has
33
33
  # to say which record is meant.
34
34
  # : (untyped) -> Array[String]?
35
35
  def anchor_identity: (untyped) -> Array[String]?
36
36
 
37
- # : () -> Hash[Array[String], Hash[Symbol, untyped]]
38
- def boundary_index: () -> Hash[Array[String], Hash[Symbol, untyped]]
37
+ # Each named record's earliest version, by the record's identity, in one
38
+ # statement for each 500 records of a model class.
39
+ # : () -> Hash[Array[String], untyped]
40
+ def first_versions: () -> Hash[Array[String], untyped]
39
41
 
42
+ # The model of each endpoint that names a record, with the record or its
43
+ # versions' id: a query reads a record's own id, as BatchedRootVersions'
44
+ # does. A version of a model that no longer exists names none, so its pair
45
+ # keeps its symbol.
40
46
  # : () -> Array[[untyped, untyped]]
41
47
  def anchors: () -> Array[[ untyped, untyped ]]
42
48
 
43
49
  # : (untyped) -> [untyped, untyped]?
44
50
  def anchor: (untyped) -> [ untyped, untyped ]?
45
51
 
46
- # : (Hash[Array[String], Hash[Symbol, untyped]], untyped, Array[untyped]) -> void
47
- def add_model_boundaries: (Hash[Array[String], Hash[Symbol, untyped]], untyped, Array[untyped]) -> void
48
-
49
- # Each root's earliest version by time, in one query whatever the size of
50
- # the batch. The lowest id is not the earliest version when ids are not
52
+ # Each root's earliest version by time, in one query for every 500 roots.
53
+ # The lowest id is not the earliest version when ids are not
51
54
  # sequential, as with UUIDs, so time decides and the usual ordering breaks
52
55
  # a tie -- refusing one that ids cannot order.
53
- # : (untyped, Array[untyped]) -> Hash[String, untyped]
54
- def first_versions: (untyped, Array[untyped]) -> Hash[String, untyped]
55
-
56
- # : (untyped, untyped) -> Array[String]
57
- def identity_key: (untyped, untyped) -> Array[String]
56
+ # : (untyped, Array[untyped]) -> Hash[Array[String], untyped]
57
+ def first_versions_of: (untyped, Array[untyped]) -> Hash[Array[String], untyped]
58
58
  end
59
59
  end
@@ -21,9 +21,5 @@ module PaperTrailDiff
21
21
 
22
22
  # : (untyped) -> bool
23
23
  def self.cut_part?: (untyped) -> bool
24
-
25
- # Every part a through passes, at any depth.
26
- # : (untyped) -> Array[untyped]
27
- def self.through_parts: (untyped) -> Array[untyped]
28
24
  end
29
25
  end
@@ -0,0 +1,47 @@
1
+ # Generated from lib/paper_trail_diff/batched_root_analyses.rb with RBS::Inline
2
+
3
+ module PaperTrailDiff
4
+ # Prepares the association history of a batch's roots, once per model class
5
+ # across every version the batch replays, then analyzes each root from its
6
+ # plan over its own window. AnalysisBatch and DeletedAnalysisBatch differ
7
+ # only in how they find their roots and plans.
8
+ class BatchedRootAnalyses
9
+ # A root whose window moved to the start of a transaction crossing its
10
+ # edge has its window in `windows`; the others take `time_range`.
11
+ # : (time_range: TimeRange?, windows: Hash[Array[String], TimeRange], history_preparer: untyped, analyzer: untyped) -> void
12
+ def initialize: (time_range: TimeRange?, windows: Hash[Array[String], TimeRange], history_preparer: untyped, analyzer: untyped) -> void
13
+
14
+ # Preparation reads the roots' current association state as a fallback,
15
+ # so a batch that has already loaded them passes them as `loaded`, rather
16
+ # than have preparation walk that state one root at a time.
17
+ # : (Array[untyped], Hash[Array[String], RootVersionPlan], ?loaded: Hash[Array[String], untyped]) -> Hash[Array[String], Analysis]
18
+ def call: (Array[untyped], Hash[Array[String], RootVersionPlan], ?loaded: Hash[Array[String], untyped]) -> Hash[Array[String], Analysis]
19
+
20
+ private
21
+
22
+ @analyzer: untyped
23
+
24
+ @history_preparer: untyped
25
+
26
+ @time_range: TimeRange?
27
+
28
+ @windows: Hash[Array[String], TimeRange]
29
+
30
+ # Roots that close on their current state are prepared even without a
31
+ # version in the window, since their descendants may have changed there.
32
+ # : (Array[untyped], Hash[Array[String], RootVersionPlan], Hash[Array[String], untyped]) -> void
33
+ def prepare: (Array[untyped], Hash[Array[String], RootVersionPlan], Hash[Array[String], untyped]) -> void
34
+
35
+ # A plan closing on the live record reads history up to now; the others
36
+ # stop at the window's end or at the last version they replay past it, so
37
+ # a past window does not load everything since.
38
+ # : (Array[untyped], live: bool) -> Hash[Symbol, untyped]
39
+ def preparation_range: (Array[untyped], live: bool) -> Hash[Symbol, untyped]
40
+
41
+ # A root with no versions in range has nothing to report, which is an
42
+ # empty result rather than a failed request -- unless it closes on its
43
+ # current state, where its descendants may still have moved.
44
+ # : (untyped, RootVersionPlan, TimeRange?) -> Analysis
45
+ def analysis: (untyped, RootVersionPlan, TimeRange?) -> Analysis
46
+ end
47
+ end
@@ -4,12 +4,15 @@ module PaperTrailDiff
4
4
  # Builds one root's Analysis inside a batch, from versions the batch already
5
5
  # selected and history it already prepared.
6
6
  class BatchedRootAnalyzer
7
- # : (tree: AssociationTree, timeline_snapshotter: untyped, activity_snapshotter: untyped, preparer: untyped, activity: bool, view: ActivityView, ?within: untyped) -> void
8
- def initialize: (tree: AssociationTree, timeline_snapshotter: untyped, activity_snapshotter: untyped, preparer: untyped, activity: bool, view: ActivityView, ?within: untyped) -> void
7
+ # `traversal` holds the tree and reads its reflections for every root of
8
+ # the batch.
9
+ # : (timeline_snapshotter: untyped, activity_snapshotter: untyped, preparer: untyped, activity: bool, view: ActivityView, traversal: AssociationTraversal) -> void
10
+ def initialize: (timeline_snapshotter: untyped, activity_snapshotter: untyped, preparer: untyped, activity: bool, view: ActivityView, traversal: AssociationTraversal) -> void
9
11
 
10
- # `window` is the root's window as the batch moved it to transaction edges.
11
- # : (untyped, RootVersionPlan, ?TimeRange?) -> Analysis
12
- def call: (untyped, RootVersionPlan, ?TimeRange?) -> Analysis
12
+ # `window` is the root's window as the batch moved it to transaction edges,
13
+ # or nil when the batch reads each root's whole history.
14
+ # : (untyped, RootVersionPlan, TimeRange?) -> Analysis
15
+ def call: (untyped, RootVersionPlan, TimeRange?) -> Analysis
13
16
 
14
17
  # The result for a root with nothing to read.
15
18
  # : () -> Analysis
@@ -25,12 +28,10 @@ module PaperTrailDiff
25
28
 
26
29
  @timeline_snapshotter: untyped
27
30
 
28
- @tree: AssociationTree
31
+ @traversal: AssociationTraversal
29
32
 
30
33
  @view: ActivityView
31
34
 
32
- @within: untyped
33
-
34
35
  # : (untyped, RootVersionPlan, TimeRange?) -> Analysis
35
36
  def activity_analysis: (untyped, RootVersionPlan, TimeRange?) -> Analysis
36
37
  end
@@ -2,11 +2,12 @@
2
2
 
3
3
  module PaperTrailDiff
4
4
  # Selects each root's versions for a batched range in a fixed number of
5
- # queries. Only the range forms that mean the same thing for every root are
6
- # supported: a shared wall-clock window, or each root's own whole history.
5
+ # queries per 500 roots. Only the range forms that mean the same thing for
6
+ # every root are supported: a shared wall-clock window, or each root's own
7
+ # whole history.
7
8
  class BatchedRootVersions
8
- # : (Array[untyped], time_range: TimeRange?, version_scope: untyped, live_endpoints: Hash[Array[String], untyped]?, context_required: bool, windows: Hash[Array[String], TimeRange]) -> void
9
- def initialize: (Array[untyped], time_range: TimeRange?, version_scope: untyped, live_endpoints: Hash[Array[String], untyped]?, context_required: bool, windows: Hash[Array[String], TimeRange]) -> void
9
+ # : (Array[untyped], time_range: TimeRange?, version_scope: untyped, live_endpoints: Hash[Array[String], untyped]?, context_required: bool, whole: bool, windows: Hash[Array[String], TimeRange]) -> void
10
+ def initialize: (Array[untyped], time_range: TimeRange?, version_scope: untyped, live_endpoints: Hash[Array[String], untyped]?, context_required: bool, whole: bool, windows: Hash[Array[String], TimeRange]) -> void
10
11
 
11
12
  # Returns a plan per record identity.
12
13
  # : () -> Hash[Array[String], RootVersionPlan]
@@ -24,13 +25,15 @@ module PaperTrailDiff
24
25
 
25
26
  @version_scope: untyped
26
27
 
28
+ @whole: bool
29
+
27
30
  @windows: Hash[Array[String], TimeRange]
28
31
 
32
+ # Each statement reads the versions of 500 roots.
29
33
  # : (untyped, Array[untyped], Hash[Array[String], RootVersionPlan]) -> void
30
34
  def select_model: (untyped, Array[untyped], Hash[Array[String], RootVersionPlan]) -> void
31
35
 
32
- # Moved windows only start and end earlier, so the versions read for the
33
- # widest of them hold each root's own, and the first left past a moved end.
36
+ # Each root's own versions, and the first after its window (see OwnWindow).
34
37
  # : (Array[String], String, Hash[String, Array[untyped]], Hash[String, untyped]) -> [Array[untyped], untyped]
35
38
  def own_window: (Array[String], String, Hash[String, Array[untyped]], Hash[String, untyped]) -> [ Array[untyped], untyped ]
36
39
 
@@ -53,6 +56,7 @@ module PaperTrailDiff
53
56
  # : (untyped, Array[untyped], TimeRange?) -> Set[untyped]?
54
57
  def chosen_version_ids: (untyped, Array[untyped], TimeRange?) -> Set[untyped]?
55
58
 
59
+ # RootVersionSelection puts each root's versions in order.
56
60
  # : (untyped, Array[untyped], TimeRange?) -> Hash[String, Array[untyped]]
57
61
  def grouped_versions: (untyped, Array[untyped], TimeRange?) -> Hash[String, Array[untyped]]
58
62
 
@@ -3,9 +3,13 @@
3
3
  module PaperTrailDiff
4
4
  # Reconstructs selected root branches and merges them into a prior immutable snapshot.
5
5
  class BranchSnapshotRefresher
6
- # : (tree: AssociationTree, ignore_policy: IgnorePolicy, traversal: AssociationTraversal, pool: SnapshotPool, normalizer: SnapshotNormalizer, full_snapshotter: untyped, partial_snapshotter: untyped, association_reader: untyped, record_transition: untyped, ?prepared_record_after: untyped) -> void
7
- def initialize: (tree: AssociationTree, ignore_policy: IgnorePolicy, traversal: AssociationTraversal, pool: SnapshotPool, normalizer: SnapshotNormalizer, full_snapshotter: untyped, partial_snapshotter: untyped, association_reader: untyped, record_transition: untyped, ?prepared_record_after: untyped) -> void
6
+ # : (ignore_policy: IgnorePolicy, traversal: AssociationTraversal, pool: SnapshotPool, normalizer: SnapshotNormalizer, full_snapshotter: untyped, partial_snapshotter: untyped, association_reader: untyped, record_transition: untyped, ?prepared_record_after: untyped, ?root_state: untyped) -> void
7
+ def initialize: (ignore_policy: IgnorePolicy, traversal: AssociationTraversal, pool: SnapshotPool, normalizer: SnapshotNormalizer, full_snapshotter: untyped, partial_snapshotter: untyped, association_reader: untyped, record_transition: untyped, ?prepared_record_after: untyped, ?root_state: untyped) -> void
8
8
 
9
+ # Without associations there is no prepared history, so nothing but the
10
+ # version's own record could say what it left, and that misses a change
11
+ # saved after it without a version. A full snapshot reads the next
12
+ # recorded state instead, and with no branches to carry it costs no more.
9
13
  # : (untyped, untyped, RecordSnapshot?, event: ActivityEvent) -> RecordSnapshot?
10
14
  def advance_root: (untyped, untyped, RecordSnapshot?, event: ActivityEvent) -> RecordSnapshot?
11
15
 
@@ -38,12 +42,14 @@ module PaperTrailDiff
38
42
  # : (untyped, untyped, Array[String]) -> Array[String]
39
43
  def with_habtm: (untyped, untyped, Array[String]) -> Array[String]
40
44
 
41
- # : (Array[untyped], RecordSnapshot, Array[String], ActivityEvent?, bool) -> [bool, RecordSnapshot?]
42
- def incremental_event: (Array[untyped], RecordSnapshot, Array[String], ActivityEvent?, bool) -> [ bool, RecordSnapshot? ]
43
-
44
45
  # : (untyped, untyped, RecordSnapshot, Array[String], ActivityEvent) -> RecordSnapshot?
45
46
  def refresh_independent_branches: (untyped, untyped, RecordSnapshot, Array[String], ActivityEvent) -> RecordSnapshot?
46
47
 
48
+ # The snapshot with these branches read again from history, or a full
49
+ # snapshot when they cannot be read alone.
50
+ # : (untyped, untyped, RecordSnapshot, Array[String]) -> RecordSnapshot?
51
+ def refreshed: (untyped, untyped, RecordSnapshot, Array[String]) -> RecordSnapshot?
52
+
47
53
  # : (untyped, untyped, Array[String]) -> RecordSnapshot?
48
54
  def partial_snapshot: (untyped, untyped, Array[String]) -> RecordSnapshot?
49
55