paper_trail_diff 0.13.1 → 0.15.0

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 (181) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +630 -0
  3. data/QUICKSTART.md +30 -10
  4. data/README.md +91 -13
  5. data/docs/architecture.md +62 -18
  6. data/docs/performance.md +116 -298
  7. data/docs/reference.md +554 -102
  8. data/docs/testing.md +93 -14
  9. data/lib/paper_trail_diff/activity_belongs_to_event_applier.rb +19 -9
  10. data/lib/paper_trail_diff/activity_boundary.rb +83 -26
  11. data/lib/paper_trail_diff/activity_child_candidate_loader.rb +2 -1
  12. data/lib/paper_trail_diff/activity_collection_event_applier.rb +11 -1
  13. data/lib/paper_trail_diff/activity_collection_record_updater.rb +16 -2
  14. data/lib/paper_trail_diff/activity_event.rb +41 -10
  15. data/lib/paper_trail_diff/activity_event_record_resolver.rb +20 -1
  16. data/lib/paper_trail_diff/activity_event_route_finder.rb +2 -1
  17. data/lib/paper_trail_diff/activity_event_snapshot_refresher.rb +1 -1
  18. data/lib/paper_trail_diff/activity_history.rb +34 -9
  19. data/lib/paper_trail_diff/activity_range.rb +32 -5
  20. data/lib/paper_trail_diff/activity_relationship.rb +12 -0
  21. data/lib/paper_trail_diff/activity_root_snapshot_refresher.rb +5 -2
  22. data/lib/paper_trail_diff/activity_snapshot_sequence.rb +76 -37
  23. data/lib/paper_trail_diff/activity_target_candidate_loader.rb +131 -0
  24. data/lib/paper_trail_diff/activity_timeline_builder.rb +281 -120
  25. data/lib/paper_trail_diff/activity_transaction_grouper.rb +2 -1
  26. data/lib/paper_trail_diff/activity_tree_filter.rb +114 -0
  27. data/lib/paper_trail_diff/activity_version_collector.rb +37 -24
  28. data/lib/paper_trail_diff/activity_view.rb +69 -0
  29. data/lib/paper_trail_diff/analysis.rb +13 -1
  30. data/lib/paper_trail_diff/analysis_batch.rb +24 -30
  31. data/lib/paper_trail_diff/approximate_paths.rb +48 -0
  32. data/lib/paper_trail_diff/association_activity_edge.rb +236 -0
  33. data/lib/paper_trail_diff/association_activity_selection.rb +197 -0
  34. data/lib/paper_trail_diff/association_discovery.rb +14 -11
  35. data/lib/paper_trail_diff/association_key.rb +56 -0
  36. data/lib/paper_trail_diff/association_traversal.rb +180 -47
  37. data/lib/paper_trail_diff/batch_boundary_resolver.rb +3 -4
  38. data/lib/paper_trail_diff/batch_preload.rb +53 -0
  39. data/lib/paper_trail_diff/batched_root_analyzer.rb +12 -14
  40. data/lib/paper_trail_diff/batched_root_versions.rb +53 -47
  41. data/lib/paper_trail_diff/change_row.rb +133 -0
  42. data/lib/paper_trail_diff/collection_comparator.rb +5 -32
  43. data/lib/paper_trail_diff/comparison_batch.rb +37 -10
  44. data/lib/paper_trail_diff/configuration.rb +35 -12
  45. data/lib/paper_trail_diff/deleted_analysis_batch.rb +45 -27
  46. data/lib/paper_trail_diff/deleted_root_filter.rb +79 -0
  47. data/lib/paper_trail_diff/deprecation.rb +61 -0
  48. data/lib/paper_trail_diff/diagnostics.rb +105 -102
  49. data/lib/paper_trail_diff/direct_record_state_loader.rb +10 -1
  50. data/lib/paper_trail_diff/endpoint.rb +26 -3
  51. data/lib/paper_trail_diff/errors.rb +5 -2
  52. data/lib/paper_trail_diff/fallback_paths.rb +38 -0
  53. data/lib/paper_trail_diff/habtm_transaction_owners.rb +68 -0
  54. data/lib/paper_trail_diff/historical_association_reifier.rb +34 -6
  55. data/lib/paper_trail_diff/historical_filter.rb +19 -10
  56. data/lib/paper_trail_diff/historical_snapshot_store.rb +63 -76
  57. data/lib/paper_trail_diff/live_endpoint_batch_loader.rb +12 -13
  58. data/lib/paper_trail_diff/live_graph_collector.rb +1 -1
  59. data/lib/paper_trail_diff/nested_comparator.rb +19 -18
  60. data/lib/paper_trail_diff/paper_trail_adapter.rb +136 -125
  61. data/lib/paper_trail_diff/preloaded_endpoint_batch_loader.rb +14 -2
  62. data/lib/paper_trail_diff/prepared_activity_index.rb +110 -36
  63. data/lib/paper_trail_diff/prepared_edge_loader.rb +31 -46
  64. data/lib/paper_trail_diff/prepared_history.rb +70 -53
  65. data/lib/paper_trail_diff/prepared_history_loader.rb +34 -43
  66. data/lib/paper_trail_diff/prepared_record_index.rb +64 -7
  67. data/lib/paper_trail_diff/prepared_snapshot_builder.rb +1 -1
  68. data/lib/paper_trail_diff/prepared_state_association_reader.rb +119 -29
  69. data/lib/paper_trail_diff/recorded_changes.rb +83 -0
  70. data/lib/paper_trail_diff/recorded_class.rb +53 -0
  71. data/lib/paper_trail_diff/root_version_selection.rb +4 -2
  72. data/lib/paper_trail_diff/scope_condition.rb +386 -0
  73. data/lib/paper_trail_diff/scope_ranking.rb +206 -0
  74. data/lib/paper_trail_diff/scoped_analysis.rb +11 -0
  75. data/lib/paper_trail_diff/scoped_analysis_builder.rb +20 -11
  76. data/lib/paper_trail_diff/scoped_root_selection.rb +105 -49
  77. data/lib/paper_trail_diff/snapshot.rb +16 -1
  78. data/lib/paper_trail_diff/snapshot_normalizer.rb +10 -3
  79. data/lib/paper_trail_diff/support.rb +38 -6
  80. data/lib/paper_trail_diff/time_range.rb +37 -18
  81. data/lib/paper_trail_diff/time_version_range.rb +5 -5
  82. data/lib/paper_trail_diff/timeline_builder.rb +7 -7
  83. data/lib/paper_trail_diff/timeline_range.rb +9 -1
  84. data/lib/paper_trail_diff/timeline_snapshot_provider.rb +24 -17
  85. data/lib/paper_trail_diff/transaction_cut.rb +181 -0
  86. data/lib/paper_trail_diff/traversal_preparer.rb +134 -29
  87. data/lib/paper_trail_diff/version.rb +1 -1
  88. data/lib/paper_trail_diff/version_association_candidate_scope.rb +13 -3
  89. data/lib/paper_trail_diff/version_boundary.rb +37 -8
  90. data/lib/paper_trail_diff/version_query.rb +34 -10
  91. data/lib/paper_trail_diff/version_range.rb +8 -15
  92. data/lib/paper_trail_diff/version_scope_filter.rb +20 -13
  93. data/lib/paper_trail_diff/version_sequence_diagnostics.rb +31 -16
  94. data/lib/paper_trail_diff/version_table.rb +60 -0
  95. data/lib/paper_trail_diff.rb +126 -55
  96. data/sig/generated/paper_trail_diff/activity_belongs_to_event_applier.rbs +10 -2
  97. data/sig/generated/paper_trail_diff/activity_boundary.rbs +54 -19
  98. data/sig/generated/paper_trail_diff/activity_collection_event_applier.rbs +5 -0
  99. data/sig/generated/paper_trail_diff/activity_collection_record_updater.rbs +5 -0
  100. data/sig/generated/paper_trail_diff/activity_event.rbs +25 -4
  101. data/sig/generated/paper_trail_diff/activity_event_record_resolver.rbs +7 -0
  102. data/sig/generated/paper_trail_diff/activity_history.rbs +21 -6
  103. data/sig/generated/paper_trail_diff/activity_range.rbs +14 -3
  104. data/sig/generated/paper_trail_diff/activity_relationship.rbs +3 -0
  105. data/sig/generated/paper_trail_diff/activity_root_snapshot_refresher.rbs +2 -0
  106. data/sig/generated/paper_trail_diff/activity_snapshot_sequence.rbs +48 -9
  107. data/sig/generated/paper_trail_diff/activity_target_candidate_loader.rbs +79 -0
  108. data/sig/generated/paper_trail_diff/activity_timeline_builder.rbs +138 -28
  109. data/sig/generated/paper_trail_diff/activity_tree_filter.rbs +73 -0
  110. data/sig/generated/paper_trail_diff/activity_version_collector.rbs +12 -4
  111. data/sig/generated/paper_trail_diff/activity_view.rbs +42 -0
  112. data/sig/generated/paper_trail_diff/analysis.rbs +8 -1
  113. data/sig/generated/paper_trail_diff/analysis_batch.rbs +8 -15
  114. data/sig/generated/paper_trail_diff/approximate_paths.rbs +23 -0
  115. data/sig/generated/paper_trail_diff/association_activity_edge.rbs +148 -0
  116. data/sig/generated/paper_trail_diff/association_activity_selection.rbs +112 -0
  117. data/sig/generated/paper_trail_diff/association_discovery.rbs +8 -5
  118. data/sig/generated/paper_trail_diff/association_key.rbs +29 -0
  119. data/sig/generated/paper_trail_diff/association_traversal.rbs +88 -9
  120. data/sig/generated/paper_trail_diff/batch_preload.rbs +29 -0
  121. data/sig/generated/paper_trail_diff/batched_root_analyzer.rbs +9 -10
  122. data/sig/generated/paper_trail_diff/batched_root_versions.rbs +14 -10
  123. data/sig/generated/paper_trail_diff/change_row.rbs +86 -0
  124. data/sig/generated/paper_trail_diff/collection_comparator.rbs +2 -16
  125. data/sig/generated/paper_trail_diff/comparison_batch.rbs +22 -4
  126. data/sig/generated/paper_trail_diff/configuration.rbs +19 -3
  127. data/sig/generated/paper_trail_diff/deleted_analysis_batch.rbs +20 -8
  128. data/sig/generated/paper_trail_diff/deleted_root_filter.rbs +48 -0
  129. data/sig/generated/paper_trail_diff/deprecation.rbs +35 -0
  130. data/sig/generated/paper_trail_diff/diagnostics.rbs +44 -32
  131. data/sig/generated/paper_trail_diff/direct_record_state_loader.rbs +6 -0
  132. data/sig/generated/paper_trail_diff/endpoint.rbs +11 -2
  133. data/sig/generated/paper_trail_diff/errors.rbs +5 -2
  134. data/sig/generated/paper_trail_diff/fallback_paths.rbs +22 -0
  135. data/sig/generated/paper_trail_diff/habtm_transaction_owners.rbs +40 -0
  136. data/sig/generated/paper_trail_diff/historical_association_reifier.rbs +13 -0
  137. data/sig/generated/paper_trail_diff/historical_filter.rbs +12 -2
  138. data/sig/generated/paper_trail_diff/historical_snapshot_store.rbs +36 -30
  139. data/sig/generated/paper_trail_diff/live_endpoint_batch_loader.rbs +5 -3
  140. data/sig/generated/paper_trail_diff/nested_comparator.rbs +10 -7
  141. data/sig/generated/paper_trail_diff/paper_trail_adapter.rbs +55 -48
  142. data/sig/generated/paper_trail_diff/preloaded_endpoint_batch_loader.rbs +9 -1
  143. data/sig/generated/paper_trail_diff/prepared_activity_index.rbs +52 -10
  144. data/sig/generated/paper_trail_diff/prepared_edge_loader.rbs +4 -12
  145. data/sig/generated/paper_trail_diff/prepared_history.rbs +40 -24
  146. data/sig/generated/paper_trail_diff/prepared_history_loader.rbs +15 -13
  147. data/sig/generated/paper_trail_diff/prepared_record_index.rbs +34 -2
  148. data/sig/generated/paper_trail_diff/prepared_state_association_reader.rbs +56 -11
  149. data/sig/generated/paper_trail_diff/recorded_changes.rbs +47 -0
  150. data/sig/generated/paper_trail_diff/recorded_class.rbs +22 -0
  151. data/sig/generated/paper_trail_diff/root_version_selection.rbs +2 -0
  152. data/sig/generated/paper_trail_diff/scope_condition.rbs +219 -0
  153. data/sig/generated/paper_trail_diff/scope_ranking.rbs +125 -0
  154. data/sig/generated/paper_trail_diff/scoped_analysis.rbs +6 -0
  155. data/sig/generated/paper_trail_diff/scoped_analysis_builder.rbs +8 -3
  156. data/sig/generated/paper_trail_diff/scoped_root_selection.rbs +49 -11
  157. data/sig/generated/paper_trail_diff/snapshot.rbs +8 -0
  158. data/sig/generated/paper_trail_diff/snapshot_normalizer.rbs +6 -0
  159. data/sig/generated/paper_trail_diff/support.rbs +20 -2
  160. data/sig/generated/paper_trail_diff/time_range.rbs +20 -2
  161. data/sig/generated/paper_trail_diff/time_version_range.rbs +4 -4
  162. data/sig/generated/paper_trail_diff/timeline_builder.rbs +2 -2
  163. data/sig/generated/paper_trail_diff/timeline_range.rbs +2 -0
  164. data/sig/generated/paper_trail_diff/timeline_snapshot_provider.rbs +17 -7
  165. data/sig/generated/paper_trail_diff/transaction_cut.rbs +94 -0
  166. data/sig/generated/paper_trail_diff/traversal_preparer.rbs +66 -8
  167. data/sig/generated/paper_trail_diff/version_association_candidate_scope.rbs +7 -0
  168. data/sig/generated/paper_trail_diff/version_boundary.rbs +20 -3
  169. data/sig/generated/paper_trail_diff/version_query.rbs +18 -2
  170. data/sig/generated/paper_trail_diff/version_range.rbs +4 -2
  171. data/sig/generated/paper_trail_diff/version_scope_filter.rbs +7 -4
  172. data/sig/generated/paper_trail_diff/version_sequence_diagnostics.rbs +16 -9
  173. data/sig/generated/paper_trail_diff/version_table.rbs +30 -0
  174. data/sig/generated/paper_trail_diff.rbs +47 -25
  175. metadata +62 -10
  176. data/lib/paper_trail_diff/activity_grouping.rb +0 -38
  177. data/lib/paper_trail_diff/batch_safety.rb +0 -55
  178. data/lib/paper_trail_diff/time_activity_timeline_builder.rb +0 -224
  179. data/sig/generated/paper_trail_diff/activity_grouping.rbs +0 -22
  180. data/sig/generated/paper_trail_diff/batch_safety.rbs +0 -24
  181. data/sig/generated/paper_trail_diff/time_activity_timeline_builder.rbs +0 -92
@@ -6,11 +6,10 @@ module PaperTrailDiff
6
6
  # the only place allowed to know about both PaperTrail and the pure engine.
7
7
  # Reconstruction logic lives in the collaborators it wires together.
8
8
  class PaperTrailAdapter
9
- # The only thing a wall-clock window can close on besides a later version.
10
- CLOSE_ON_CURRENT: ::Symbol
11
-
12
- # : (associations: Array[String | Symbol], ignore: ignore_option, ?reload_live_endpoints: bool, ?allow_expensive: bool) -> void
13
- def initialize: (associations: Array[String | Symbol], ignore: ignore_option, ?reload_live_endpoints: bool, ?allow_expensive: bool) -> void
9
+ # `recorded_changes:` reads what each activity boundary's version recorded.
10
+ # `allow_approximate:` accepts association paths read with PT-AT.
11
+ # : (associations: association_option, ignore: ignore_option, ?reload_live_endpoints: bool, ?recorded_changes: bool, ?allow_approximate: bool) -> void
12
+ def initialize: (associations: association_option, ignore: ignore_option, ?reload_live_endpoints: bool, ?recorded_changes: bool, ?allow_approximate: bool) -> void
14
13
 
15
14
  # : (untyped, untyped) -> Diff
16
15
  def compare: (untyped, untyped) -> Diff
@@ -19,39 +18,49 @@ module PaperTrailDiff
19
18
  # : (Array[comparison_input]) -> comparison_results
20
19
  def compare_many: (Array[comparison_input]) -> comparison_results
21
20
 
22
- # : (untyped, from: untyped, to: untyped, within: untyped, ?version_scope: untyped, ?close_on: Symbol?) -> Array[Step]
23
- def timeline: (untyped, from: untyped, to: untyped, within: untyped, ?version_scope: untyped, ?close_on: Symbol?) -> Array[Step]
21
+ # : (untyped, from: untyped, to: untyped, within: untyped, ?version_scope: untyped) -> Array[Step]
22
+ def timeline: (untyped, from: untyped, to: untyped, within: untyped, ?version_scope: untyped) -> Array[Step]
24
23
 
25
- # : (untyped, from: untyped, to: untyped, within: untyped, ?version_scope: untyped, ?close_on: Symbol?, ?snapshots: bool, ?group: Symbol?) -> Array[ActivityStep]
26
- def activity_timeline: (untyped, from: untyped, to: untyped, within: untyped, ?version_scope: untyped, ?close_on: Symbol?, ?snapshots: bool, ?group: Symbol?) -> Array[ActivityStep]
24
+ # : (untyped, from: untyped, to: untyped, within: untyped, ?version_scope: untyped, ?snapshots: bool, ?group: Symbol?) -> Array[ActivityStep]
25
+ def activity_timeline: (untyped, from: untyped, to: untyped, within: untyped, ?version_scope: untyped, ?snapshots: bool, ?group: Symbol?) -> Array[ActivityStep]
27
26
 
28
- # : (untyped, from: untyped, to: untyped, within: untyped, ?activity: bool, ?version_scope: untyped, ?close_on: Symbol?, ?snapshots: bool, ?group: Symbol?) -> Analysis
29
- def analyze: (untyped, from: untyped, to: untyped, within: untyped, ?activity: bool, ?version_scope: untyped, ?close_on: Symbol?, ?snapshots: bool, ?group: Symbol?) -> Analysis
27
+ # : (untyped, from: untyped, to: untyped, within: untyped, ?activity: bool, ?version_scope: untyped, ?snapshots: bool, ?group: Symbol?) -> Analysis
28
+ def analyze: (untyped, from: untyped, to: untyped, within: untyped, ?activity: bool, ?version_scope: untyped, ?snapshots: bool, ?group: Symbol?) -> Analysis
30
29
 
31
30
  # Analyzes many roots over one shared range, preparing their history once.
32
- # : (Array[untyped], within: untyped, ?activity: bool, ?version_scope: untyped, ?close_on: Symbol?, ?snapshots: bool, ?group: Symbol?) -> Hash[identity, Analysis]
33
- def analyze_many: (Array[untyped], within: untyped, ?activity: bool, ?version_scope: untyped, ?close_on: Symbol?, ?snapshots: bool, ?group: Symbol?) -> Hash[identity, Analysis]
31
+ # : (Array[untyped], within: untyped, ?activity: bool, ?version_scope: untyped, ?snapshots: bool, ?group: Symbol?) -> Hash[identity, Analysis]
32
+ def analyze_many: (Array[untyped], within: untyped, ?activity: bool, ?version_scope: untyped, ?snapshots: bool, ?group: Symbol?) -> Hash[identity, Analysis]
34
33
 
35
34
  # Selects the roots from a relation before running the ordinary batch, so a
36
35
  # caller reporting on a population does not have to rediscover which of its
37
36
  # members changed. The roots the relation could not reach come back named
38
37
  # rather than dropped -- see `PaperTrailDiff.analyze_scope`.
39
- # : (untyped, limit: Integer?, within: untyped, ?activity: bool, ?version_scope: untyped, ?close_on: Symbol?, ?snapshots: bool, ?group: Symbol?, ?historical_filter: untyped, ?max_filter_versions: Integer, ?include_deleted: bool) -> ScopedAnalysis
40
- def analyze_scope: (untyped, limit: Integer?, within: untyped, ?activity: bool, ?version_scope: untyped, ?close_on: Symbol?, ?snapshots: bool, ?group: Symbol?, ?historical_filter: untyped, ?max_filter_versions: Integer, ?include_deleted: bool) -> ScopedAnalysis
38
+ # : (untyped, limit: Integer?, within: untyped, ?activity: bool, ?version_scope: untyped, ?snapshots: bool, ?group: Symbol?, ?historical_filter: untyped, ?max_filter_versions: Integer, ?include_deleted: bool) -> ScopedAnalysis
39
+ def analyze_scope: (untyped, limit: Integer?, within: untyped, ?activity: bool, ?version_scope: untyped, ?snapshots: bool, ?group: Symbol?, ?historical_filter: untyped, ?max_filter_versions: Integer, ?include_deleted: bool) -> ScopedAnalysis
41
40
 
42
41
  private
43
42
 
43
+ # : (bool, bool, Symbol?) -> ActivityView
44
+ def activity_view: (bool, bool, Symbol?) -> ActivityView
45
+
46
+ # : (untyped) -> Hash[Symbol, untyped]
47
+ def model_payload: (untyped) -> Hash[Symbol, untyped]
48
+
49
+ # : (Array[untyped], within: untyped, activity: bool, version_scope: untyped, view: ActivityView) -> Hash[identity, Analysis]
50
+ def analyze_batch: (Array[untyped], within: untyped, activity: bool, version_scope: untyped, view: ActivityView) -> Hash[identity, Analysis]
51
+
52
+ # Analysis reads association history, so a request it would refuse is
53
+ # refused before the first selection query rather than once analysis starts.
54
+ # : (untyped) -> void
55
+ def check_scope: (untyped) -> void
56
+
44
57
  # : (Array[comparison_input], preparer: untyped) -> ComparisonBatch
45
58
  def comparison_batch: (Array[comparison_input], preparer: untyped) -> ComparisonBatch
46
59
 
60
+ # Refused before the current records load, rather than once analysis starts.
47
61
  # : (Array[untyped]) -> Hash[identity, untyped]
48
62
  def load_batch_endpoints: (Array[untyped]) -> Hash[identity, untyped]
49
63
 
50
- # : (untyped, historical: bool) -> void
51
- def prepare_batch_model: (untyped, historical: bool) -> void
52
-
53
- @batch_safety: BatchSafety
54
-
55
64
  # : (untyped, Array[Array[String]], Hash[Symbol, untyped]) -> Hash[Array[String], Analysis?]
56
65
  def analyze_deleted: (untyped, Array[Array[String]], Hash[Symbol, untyped]) -> Hash[Array[String], Analysis?]
57
66
 
@@ -69,6 +78,8 @@ module PaperTrailDiff
69
78
 
70
79
  @normalizer: SnapshotNormalizer
71
80
 
81
+ @recorded: IgnorePolicy?
82
+
72
83
  @snapshot_pool: SnapshotPool
73
84
 
74
85
  @timeline_snapshotter: TimelineSnapshotProvider
@@ -77,24 +88,19 @@ module PaperTrailDiff
77
88
 
78
89
  @traversal_preparer: TraversalPreparer
79
90
 
80
- # : (untyped, from: untyped, to: untyped, within: untyped, version_scope: untyped, live_endpoint: untyped, ?snapshots: bool, ?group: Symbol?) -> Analysis
81
- def analyze_activity: (untyped, from: untyped, to: untyped, within: untyped, version_scope: untyped, live_endpoint: untyped, ?snapshots: bool, ?group: Symbol?) -> Analysis
82
-
83
- # Association membership is resolved by timestamp, so endpoints sharing one
84
- # cannot be told apart and any association change between them is invisible.
85
- # The result may still be correct -- nothing associated may have changed --
86
- # and the gem cannot tell which, since not seeing the change is the symptom.
87
- # So it reports the condition and leaves the judgement to the application.
91
+ # The result may still be correct -- nothing the path reaches may have
92
+ # changed -- and the gem cannot tell which, since not seeing the change is
93
+ # the symptom. So it reports the condition and leaves the judgement to the
94
+ # application.
88
95
  # : (untyped, untyped) -> void
89
96
  def notify_ambiguous_association_boundary: (untyped, untyped) -> void
90
97
 
91
- # A window with nothing recorded after its last change ends at the live
92
- # record, which holds the state that change produced -- whether the window
93
- # ended a moment ago or long before. `close_on: :current` asked for this
94
- # before it was the default and is still accepted. It names what ends a
95
- # wall-clock window, so it is meaningless for explicit endpoints.
96
- # : (Symbol?, untyped) -> bool
97
- def close_on_current?: (Symbol?, untyped) -> bool
98
+ # Loaded history orders two versions that share a timestamp by id, but
99
+ # PT-AT places association changes by timestamp alone, so only a path it
100
+ # reads can lose a change between them. A request the preparer refuses
101
+ # raises here, before anything is reported.
102
+ # : (untyped, untyped) -> bool
103
+ def ambiguous_association_boundary?: (untyped, untyped) -> bool
98
104
 
99
105
  # With neither a window nor endpoints, a range is the record's whole
100
106
  # history through its current saved state; a missing endpoint takes that
@@ -102,26 +108,30 @@ module PaperTrailDiff
102
108
  # : (untyped, untyped, untyped, untyped) -> [untyped, untyped]
103
109
  def default_range: (untyped, untyped, untyped, untyped) -> [ untyped, untyped ]
104
110
 
111
+ # A window with nothing recorded after its last change ends at the live
112
+ # record, which holds the state that change produced -- whether the window
113
+ # ended a moment ago or long before. Explicit endpoints name their own end.
105
114
  # Only a saved row has current state to close on. A destroyed root's own
106
115
  # destroy version already terminates its history, and a reified or unsaved
107
116
  # instance stands for a state that is not in the table.
108
- # : (untyped, Symbol?, untyped) -> untyped
109
- def live_endpoint_for: (untyped, Symbol?, untyped) -> untyped
117
+ # : (untyped, untyped) -> untyped
118
+ def live_endpoint_for: (untyped, untyped) -> untyped
110
119
 
111
120
  # : () -> void
112
121
  def build_snapshotters: () -> void
113
122
 
114
- # : (bool, within: untyped, snapshots: bool, group: Symbol?) -> BatchedRootAnalyzer
115
- def batched_root_analyzer: (bool, within: untyped, snapshots: bool, group: Symbol?) -> BatchedRootAnalyzer
123
+ # : (bool, within: untyped, view: ActivityView) -> BatchedRootAnalyzer
124
+ def batched_root_analyzer: (bool, within: untyped, view: ActivityView) -> BatchedRootAnalyzer
116
125
 
117
126
  # : () -> HistoricalSnapshotStore
118
127
  def build_historical_store: () -> HistoricalSnapshotStore
119
128
 
120
- # : () -> ActivitySnapshotProvider
121
- def build_activity_snapshotter: () -> ActivitySnapshotProvider
129
+ # Refreshes one root's snapshots, reading with the history prepared for it.
130
+ # : (PreparedActivitySnapshots) -> BranchSnapshotRefresher
131
+ def branch_refresher: (PreparedActivitySnapshots) -> BranchSnapshotRefresher
122
132
 
123
- # : (untyped, from: untyped, to: untyped, within: untyped, ?version_scope: untyped, ?live_endpoint: untyped, ?snapshots: bool, ?group: Symbol?) -> ActivityTimelineBuilder
124
- def activity_builder: (untyped, from: untyped, to: untyped, within: untyped, ?version_scope: untyped, ?live_endpoint: untyped, ?snapshots: bool, ?group: Symbol?) -> ActivityTimelineBuilder
133
+ # : (untyped, from: untyped, to: untyped, within: untyped, version_scope: untyped, live_endpoint: untyped, view: ActivityView) -> ActivityTimelineBuilder
134
+ def activity_builder: (untyped, from: untyped, to: untyped, within: untyped, version_scope: untyped, live_endpoint: untyped, view: ActivityView) -> ActivityTimelineBuilder
125
135
 
126
136
  # : (untyped) -> RecordSnapshot?
127
137
  def snapshot_for_endpoint: (untyped) -> RecordSnapshot?
@@ -129,11 +139,8 @@ module PaperTrailDiff
129
139
  # : (untyped) -> RecordSnapshot?
130
140
  def historical_snapshot: (untyped) -> RecordSnapshot?
131
141
 
132
- # : (untyped) -> RecordSnapshot?
133
- def uncached_historical_snapshot: (untyped) -> RecordSnapshot?
134
-
135
- # : (untyped, untyped) -> RecordSnapshot?
136
- def snapshot_at: (untyped, untyped) -> RecordSnapshot?
142
+ # : (untyped, untyped, ?history: PreparedHistory?) -> RecordSnapshot?
143
+ def snapshot_at: (untyped, untyped, ?history: PreparedHistory?) -> RecordSnapshot?
137
144
 
138
145
  # : (untyped) -> RecordSnapshot
139
146
  def live_snapshot: (untyped) -> RecordSnapshot
@@ -1,7 +1,8 @@
1
1
  # Generated from lib/paper_trail_diff/preloaded_endpoint_batch_loader.rb with RBS::Inline
2
2
 
3
3
  module PaperTrailDiff
4
- # Validates and reuses caller-owned live records without issuing association queries.
4
+ # Validates and reuses caller-owned live records, reading again only the
5
+ # associations a preload of many records cannot have loaded correctly.
5
6
  class PreloadedEndpointBatchLoader
6
7
  # : (tree: AssociationTree, traversal: AssociationTraversal) -> void
7
8
  def initialize: (tree: AssociationTree, traversal: AssociationTraversal) -> void
@@ -20,5 +21,12 @@ module PaperTrailDiff
20
21
 
21
22
  # : (untyped, AssociationTree, String, untyped) -> void
22
23
  def validate_association: (untyped, AssociationTree, String, untyped) -> void
24
+
25
+ # Preloading many records applies a limit or offset to all of them
26
+ # together, so what a caller preloaded cannot be trusted: one record keeps
27
+ # another's share, or none. Such an association is read again for each
28
+ # record, as reloading reads it.
29
+ # : (untyped) -> void
30
+ def read_alone: (untyped) -> void
23
31
  end
24
32
  end
@@ -12,15 +12,42 @@ module PaperTrailDiff
12
12
  # : (untyped, Array[untyped]) -> Array[untyped]
13
13
  def versions: (untyped, Array[untyped]) -> Array[untyped]
14
14
 
15
+ # Children are found by key across the whole table, so an association to
16
+ # an STI subclass finds the rows of its siblings too. Only a row that was
17
+ # of the class at some point belongs to it, and of that row only the
18
+ # versions it had the class before or after.
19
+ # : (untyped, Array[untyped]) -> Array[untyped]
20
+ def member_ids: (untyped, Array[untyped]) -> Array[untyped]
21
+
22
+ # : (untyped, Array[untyped], ActivityRange) -> Array[untyped]
23
+ def member_versions: (untyped, Array[untyped], ActivityRange) -> Array[untyped]
24
+
25
+ # The versions of a through's join rows that are on its path. Under
26
+ # `source_type:`, a row is on it only while its type column names that
27
+ # class, so only the versions it had that type before or after count. A
28
+ # version saved before the type column existed has no type to read.
29
+ # : (Hash[Symbol, untyped], untyped) -> Array[untyped]
30
+ def join_versions: (Hash[Symbol, untyped], untyped) -> Array[untyped]
31
+
15
32
  # : (untyped, Array[untyped], untyped, ActivityRange) -> Array[untyped]
16
33
  def child_ids: (untyped, Array[untyped], untyped, ActivityRange) -> Array[untyped]
17
34
 
18
- # : (untyped, Array[untyped], untyped, ?transactions: bool) -> Array[untyped]
19
- def association_rows: (untyped, Array[untyped], untyped, ?transactions: bool) -> Array[untyped]
35
+ # The `belongs_to` targets each owner pointed at in the range: at its start
36
+ # and after each change inside it, plus the live row at a current end.
37
+ # : (untyped, Array[untyped], untyped, ActivityRange) -> Array[ActivityTargetCandidateLoader::Row]
38
+ def target_rows: (untyped, Array[untyped], untyped, ActivityRange) -> Array[ActivityTargetCandidateLoader::Row]
39
+
40
+ # : (untyped, untyped) -> bool
41
+ def loaded?: (untyped, untyped) -> bool
42
+
43
+ # PT-AT records HABTM membership once per transaction, under the
44
+ # association's name, so the rows are keyed by transaction id.
45
+ # : (untyped, Array[untyped], untyped) -> Array[untyped]
46
+ def habtm_rows: (untyped, Array[untyped], untyped) -> Array[untyped]
20
47
 
21
48
  private
22
49
 
23
- @children: Hash[Array[String], untyped]
50
+ @children: Hash[untyped, untyped]
24
51
 
25
52
  @nodes: Hash[String, Array[untyped]]
26
53
 
@@ -30,7 +57,12 @@ module PaperTrailDiff
30
57
 
31
58
  @roots: Hash[Array[String], Array[untyped]]
32
59
 
33
- @rows: Hash[Array[String], Hash[String, Array[untyped]]]
60
+ @rows: Hash[untyped, Hash[String, Array[untyped]]]
61
+
62
+ @targets: Hash[untyped, untyped]
63
+
64
+ # : (untyped, Array[untyped]) -> bool
65
+ def member_class?: (untyped, Array[untyped]) -> bool
34
66
 
35
67
  # : (untyped, Array[untyped], untyped, ActivityRange) -> Array[untyped]
36
68
  def historical_ids: (untyped, Array[untyped], untyped, ActivityRange) -> Array[untyped]
@@ -41,16 +73,26 @@ module PaperTrailDiff
41
73
  # : (untyped, untyped) -> untyped
42
74
  def child_rows: (untyped, untyped) -> untyped
43
75
 
76
+ # : (Hash[String, Array[ActivityTargetCandidateLoader::Row]], Array[untyped]) -> Array[ActivityTargetCandidateLoader::Row]
77
+ def rows_for: (Hash[String, Array[ActivityTargetCandidateLoader::Row]], Array[untyped]) -> Array[ActivityTargetCandidateLoader::Row]
78
+
79
+ # : (untyped, Array[ActivityTargetCandidateLoader::Row], ActivityRange) -> Array[ActivityTargetCandidateLoader::Row]
80
+ def eligible_rows: (untyped, Array[ActivityTargetCandidateLoader::Row], ActivityRange) -> Array[ActivityTargetCandidateLoader::Row]
81
+
82
+ # : (untyped, untyped) -> untyped
83
+ def target_candidates: (untyped, untyped) -> untyped
84
+
44
85
  # Mirrors VersionAssociationCandidateScope's before-window rule. The loaded
45
86
  # series includes changes to other owners too, so an old membership cannot
46
87
  # survive a later pre-window reassignment just because that owner is absent.
47
- # : (untyped, Array[untyped], ActivityRange) -> bool
48
- def eligible_child?: (untyped, Array[untyped], ActivityRange) -> bool
88
+ # : (untyped, untyped, untyped, String?, ActivityRange) -> bool
89
+ def eligible_version?: (untyped, untyped, untyped, String?, ActivityRange) -> bool
49
90
 
50
- # : (untyped, untyped, bool) -> Hash[String, Array[untyped]]
51
- def load_association_rows: (untyped, untyped, bool) -> Hash[String, Array[untyped]]
91
+ # : (untyped, untyped) -> Hash[String, Array[untyped]]
92
+ def load_habtm_rows: (untyped, untyped) -> Hash[String, Array[untyped]]
52
93
 
53
- # : (Array[untyped], bool) -> Array[untyped]
54
- def version_ids: (Array[untyped], bool) -> Array[untyped]
94
+ # A version without a transaction id names no rows, so it can stay in.
95
+ # : (Array[untyped]) -> Array[untyped]
96
+ def transaction_ids: (Array[untyped]) -> Array[untyped]
55
97
  end
56
98
  end
@@ -3,11 +3,10 @@
3
3
  module PaperTrailDiff
4
4
  # Loads every historical identity that can participate in one association edge.
5
5
  class PreparedEdgeLoader
6
- EDGE_LOADERS: untyped
7
-
8
6
  # : (PreparedRecordIndex, Array[untyped], ?start_at: untyped) -> void
9
7
  def initialize: (PreparedRecordIndex, Array[untyped], ?start_at: untyped) -> void
10
8
 
9
+ # HABTM alone also returns each root transaction's members.
11
10
  # : (untyped, Array[untyped], untyped) -> [Hash[String, Hash[Symbol, untyped]], Hash[String, Array[untyped]]?]
12
11
  def call: (untyped, Array[untyped], untyped) -> [ Hash[String, Hash[Symbol, untyped]], Hash[String, Array[untyped]]? ]
13
12
 
@@ -19,21 +18,14 @@ module PaperTrailDiff
19
18
 
20
19
  @transaction_ids: Array[untyped]
21
20
 
22
- # : (untyped, Array[untyped], untyped) -> [Hash[String, Hash[Symbol, untyped]], nil]
23
- def belongs_to_edge: (untyped, Array[untyped], untyped) -> [ Hash[String, Hash[Symbol, untyped]], nil ]
24
-
25
- # : (untyped, Array[untyped], untyped) -> [Hash[String, Hash[Symbol, untyped]], nil]
26
- def child_edge: (untyped, Array[untyped], untyped) -> [ Hash[String, Hash[Symbol, untyped]], nil ]
27
-
28
- # : (untyped, Array[untyped], untyped) -> [Hash[String, Hash[Symbol, untyped]], Hash[String, Array[untyped]]]
29
- def habtm_edge: (untyped, Array[untyped], untyped) -> [ Hash[String, Hash[Symbol, untyped]], Hash[String, Array[untyped]] ]
30
-
31
21
  # : (untyped, Array[untyped], untyped) -> Hash[String, Hash[Symbol, untyped]]
32
22
  def belongs_to_groups: (untyped, Array[untyped], untyped) -> Hash[String, Hash[Symbol, untyped]]
33
23
 
34
24
  # : (untyped, Array[untyped], untyped) -> Hash[String, Hash[Symbol, untyped]]
35
25
  def child_groups: (untyped, Array[untyped], untyped) -> Hash[String, Hash[Symbol, untyped]]
36
26
 
27
+ # A transaction more than one owner recorded members in is left out, so
28
+ # its read falls back to HistoricalAssociationReifier, which raises.
37
29
  # : (untyped, untyped) -> [Hash[String, Hash[Symbol, untyped]], Hash[String, Array[untyped]]]
38
30
  def habtm_groups: (untyped, untyped) -> [ Hash[String, Hash[Symbol, untyped]], Hash[String, Array[untyped]] ]
39
31
 
@@ -64,7 +56,7 @@ module PaperTrailDiff
64
56
  # : (untyped, Array[untyped], ?owners: Hash[String, Array[untyped]]?) -> Hash[String, Hash[Symbol, untyped]]
65
57
  def group_for: (untyped, Array[untyped], ?owners: Hash[String, Array[untyped]]?) -> Hash[String, Hash[Symbol, untyped]]
66
58
 
67
- # Keyed rather than scanned so that a wide edge stays linear in its width.
59
+ # A set rather than a scan, so that a wide edge stays linear in its width.
68
60
  # : (Array[Array[untyped]]) -> Hash[String, Array[untyped]]
69
61
  def group_ids_by_owner: (Array[Array[untyped]]) -> Hash[String, Array[untyped]]
70
62
 
@@ -10,8 +10,9 @@ module PaperTrailDiff
10
10
  # : (PreparedRecordIndex, ?activity_index: PreparedActivityIndex?) -> void
11
11
  def initialize: (PreparedRecordIndex, ?activity_index: PreparedActivityIndex?) -> void
12
12
 
13
- # : (untyped, untyped, Hash[String, Hash[Symbol, untyped]]) -> void
14
- def merge_edge: (untyped, untyped, Hash[String, Hash[Symbol, untyped]]) -> void
13
+ # Returns every group the edge now holds.
14
+ # : (untyped, untyped, Hash[String, Hash[Symbol, untyped]]) -> Hash[String, Hash[Symbol, untyped]]
15
+ def merge_edge: (untyped, untyped, Hash[String, Hash[Symbol, untyped]]) -> Hash[String, Hash[Symbol, untyped]]
15
16
 
16
17
  # : (untyped, untyped) -> Hash[String, Hash[Symbol, untyped]]
17
18
  def edge: (untyped, untyped) -> Hash[String, Hash[Symbol, untyped]]
@@ -31,11 +32,15 @@ module PaperTrailDiff
31
32
  # : (PreparedRecordState, untyped, untyped) -> [bool, Array[PreparedRecordState]]
32
33
  def snapshot_states: (PreparedRecordState, untyped, untyped) -> [ bool, Array[PreparedRecordState] ]
33
34
 
34
- # : (untyped, untyped, untyped, habtm_boundary: untyped) -> [bool, Array[untyped]]
35
- def resolve: (untyped, untyped, untyped, habtm_boundary: untyped) -> [ bool, Array[untyped] ]
35
+ # Unranked, as a part of a has_many through is read, it returns every row
36
+ # the part's conditions admit, a record reached twice appearing twice.
37
+ # : (untyped, untyped, untyped, habtm_boundary: untyped, ?ranked: bool) -> [bool, Array[untyped]]
38
+ def resolve: (untyped, untyped, untyped, habtm_boundary: untyped, ?ranked: bool) -> [ bool, Array[untyped] ]
36
39
 
37
40
  private
38
41
 
42
+ @conditions: ScopeCondition::Cache
43
+
39
44
  @edges: Hash[Array[String], Hash[String, Hash[Symbol, untyped]]]
40
45
 
41
46
  @habtm: Hash[Array[String], Hash[String, Array[untyped]]]
@@ -46,35 +51,46 @@ module PaperTrailDiff
46
51
 
47
52
  @unsupported: Hash[Array[String], bool]
48
53
 
49
- # : (untyped, untyped) -> bool
50
- def supported?: (untyped, untyped) -> bool
54
+ # A polymorphic target's class is known only once a record names it, so
55
+ # belongs_to_records reads its scope for each record instead.
56
+ # : (untyped, untyped, bool) -> bool
57
+ def supported?: (untyped, untyped, bool) -> bool
51
58
 
52
- # : (untyped, untyped, untyped, untyped) -> Array[untyped]?
53
- def direct_records: (untyped, untyped, untyped, untyped) -> Array[untyped]?
59
+ # : (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
60
+ def direct_records: (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
54
61
 
55
- # : (untyped, untyped, untyped, untyped) -> Array[untyped]?
56
- def resolve_belongs_to: (untyped, untyped, untyped, untyped) -> Array[untyped]?
62
+ # : (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
63
+ def resolve_belongs_to: (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
57
64
 
58
- # : (untyped, untyped, untyped, untyped) -> Array[untyped]
59
- def resolve_children: (untyped, untyped, untyped, untyped) -> Array[untyped]
65
+ # : (untyped, untyped, untyped, untyped, bool) -> Array[untyped]
66
+ def resolve_children: (untyped, untyped, untyped, untyped, bool) -> Array[untyped]
60
67
 
61
- # : (untyped, untyped, untyped) -> Array[untyped]?
62
- def belongs_to_records: (untyped, untyped, untyped) -> Array[untyped]?
68
+ # : (untyped, untyped, untyped, bool) -> Array[untyped]?
69
+ def belongs_to_records: (untyped, untyped, untyped, bool) -> Array[untyped]?
63
70
 
64
- # : (untyped, untyped, untyped) -> Array[untyped]
65
- def child_records: (untyped, untyped, untyped) -> Array[untyped]
71
+ # : (untyped, untyped, untyped, bool) -> Array[untyped]
72
+ def child_records: (untyped, untyped, untyped, bool) -> Array[untyped]
66
73
 
67
74
  # : (Hash[Symbol, untyped], untyped) -> Array[untyped]
68
75
  def child_ids_for: (Hash[Symbol, untyped], untyped) -> Array[untyped]
69
76
 
70
- # : (untyped, untyped, untyped, untyped) -> Array[untyped]?
71
- def habtm_records: (untyped, untyped, untyped, untyped) -> Array[untyped]?
72
-
73
- # : (untyped, untyped, untyped, untyped) -> Array[untyped]?
74
- def through_records: (untyped, untyped, untyped, untyped) -> Array[untyped]?
75
-
76
- # : (Array[untyped], untyped, untyped, untyped) -> Array[[bool, Array[untyped]]]
77
- def resolve_sources: (Array[untyped], untyped, untyped, untyped) -> Array[[ bool, Array[untyped] ]]
77
+ # PT-AT records a checkpoint's membership as it is when the checkpoint is
78
+ # saved, so a tag attached earlier in the checkpoint's own transaction is a
79
+ # member there, unlike other associations, which a version reads as they
80
+ # were before its transaction. A member created in that transaction has no
81
+ # earlier state, so it is read as it was created.
82
+ # : (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
83
+ def habtm_records: (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
84
+
85
+ # A has_many through reads its parts unranked, as its query does. Its own
86
+ # scope applies to each row, and a ranked read then keeps a record reached
87
+ # twice as one member.
88
+ # : (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
89
+ def through_records: (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
90
+
91
+ # The source records of each join record, once for each join.
92
+ # : (untyped, untyped, ^(untyped, untyped) -> [bool, Array[untyped]]) -> Array[untyped]?
93
+ def through_rows: (untyped, untyped, ^(untyped, untyped) -> [ bool, Array[untyped] ]) -> Array[untyped]?
78
94
 
79
95
  # : (untyped, untyped, untyped) -> bool
80
96
  def member_of?: (untyped, untyped, untyped) -> bool
@@ -3,19 +3,22 @@
3
3
  module PaperTrailDiff
4
4
  # Expands the explicit association tree into a request-scoped PreparedHistory.
5
5
  class PreparedHistoryLoader
6
- # : (untyped, root_versions: Array[untyped], tree: AssociationTree, traversal: AssociationTraversal, ?root_ids: Array[untyped], ?start_at: untyped, ?end_at: untyped, ?live_records: Array[untyped]) -> void
7
- def initialize: (untyped, root_versions: Array[untyped], tree: AssociationTree, traversal: AssociationTraversal, ?root_ids: Array[untyped], ?start_at: untyped, ?end_at: untyped, ?live_records: Array[untyped]) -> void
6
+ # Without `end_at`, the activity range closes on the last root version.
7
+ # : (untyped, root_ids: Array[untyped], root_versions: Array[untyped], tree: AssociationTree, traversal: AssociationTraversal, start_at: untyped, end_at: untyped, live_records: Array[untyped]) -> void
8
+ def initialize: (untyped, root_ids: Array[untyped], root_versions: Array[untyped], tree: AssociationTree, traversal: AssociationTraversal, start_at: untyped, end_at: untyped, live_records: Array[untyped]) -> void
8
9
 
9
10
  # : () -> PreparedHistory
10
11
  def call: () -> PreparedHistory
11
12
 
12
13
  private
13
14
 
15
+ @activity: PreparedActivityIndex
16
+
14
17
  @edges: PreparedEdgeLoader
15
18
 
16
19
  @history: PreparedHistory
17
20
 
18
- @prepared: Hash[Array[String], Array[String]]
21
+ @prepared: Hash[untyped, Array[String]]
19
22
 
20
23
  @record: untyped
21
24
 
@@ -35,24 +38,26 @@ module PaperTrailDiff
35
38
  # : (untyped, Array[untyped], untyped) -> Hash[String, Hash[Symbol, untyped]]
36
39
  def prepare_reflection: (untyped, Array[untyped], untyped) -> Hash[String, Hash[Symbol, untyped]]
37
40
 
41
+ # Either part can itself be a through, which has no key of its own to
42
+ # read, so each part is prepared as what it is. Like an edge, it returns
43
+ # every group it holds, not only those of these owners.
38
44
  # : (untyped, Array[untyped], untyped) -> Hash[String, Hash[Symbol, untyped]]
39
45
  def prepare_through: (untyped, Array[untyped], untyped) -> Hash[String, Hash[Symbol, untyped]]
40
46
 
41
47
  # : (untyped, Array[untyped], untyped) -> Hash[String, Hash[Symbol, untyped]]
42
48
  def prepare_edge: (untyped, Array[untyped], untyped) -> Hash[String, Hash[Symbol, untyped]]
43
49
 
44
- # : (untyped, Array[untyped], untyped) -> Array[untyped]
45
- def unprepared_ids: (untyped, Array[untyped], untyped) -> Array[untyped]
50
+ # A reflection belongs to the class that declares it, so it alone names
51
+ # the edge; a subclass that inherits it reads the same records.
52
+ # : (Array[untyped], untyped) -> Array[untyped]
53
+ def unprepared_ids: (Array[untyped], untyped) -> Array[untyped]
46
54
 
47
- # : (untyped, Array[untyped], untyped) -> void
48
- def mark_prepared: (untyped, Array[untyped], untyped) -> void
55
+ # : (Array[untyped], untyped) -> void
56
+ def mark_prepared: (Array[untyped], untyped) -> void
49
57
 
50
58
  # : (untyped, untyped, Hash[String, Hash[Symbol, untyped]]) -> void
51
59
  def mark_unsupported: (untyped, untyped, Hash[String, Hash[Symbol, untyped]]) -> void
52
60
 
53
- # : (untyped) -> bool
54
- def deferred_macro?: (untyped) -> bool
55
-
56
61
  # : (Hash[String, Hash[Symbol, untyped]]) -> void
57
62
  def load_groups: (Hash[String, Hash[Symbol, untyped]]) -> void
58
63
 
@@ -62,9 +67,6 @@ module PaperTrailDiff
62
67
  # : (untyped) -> bool
63
68
  def versioned?: (untyped) -> bool
64
69
 
65
- # : (untyped, untyped) -> Array[String]
66
- def edge_key: (untyped, untyped) -> Array[String]
67
-
68
70
  # : (Hash[String, Hash[Symbol, untyped]], Hash[String, Hash[Symbol, untyped]]) -> Hash[String, Hash[Symbol, untyped]]
69
71
  def merge_groups: (Hash[String, Hash[Symbol, untyped]], Hash[String, Hash[Symbol, untyped]]) -> Hash[String, Hash[Symbol, untyped]]
70
72
  end
@@ -68,6 +68,12 @@ module PaperTrailDiff
68
68
  # : (untyped) -> untyped
69
69
  def record_before: (untyped) -> untyped
70
70
 
71
+ # A record created in the boundary's own transaction has no state before
72
+ # it, yet a HABTM checkpoint saved later in that transaction records it as
73
+ # a member. Such a member is read as it was created.
74
+ # : (untyped) -> untyped
75
+ def record_created_in: (untyped) -> untyped
76
+
71
77
  # : (untyped) -> PreparedRecordState?
72
78
  def state_before: (untyped) -> PreparedRecordState?
73
79
 
@@ -81,8 +87,17 @@ module PaperTrailDiff
81
87
  # : () -> Array[PreparedRecordState]
82
88
  def states: () -> Array[PreparedRecordState]
83
89
 
84
- # : (untyped) -> [Hash[untyped, untyped], Hash[untyped, untyped]]?
85
- def transition: (untyped) -> [ Hash[untyped, untyped], Hash[untyped, untyped] ]?
90
+ # The classes the record had at any point, or either side of one version.
91
+ # : (?untyped) -> Array[untyped]
92
+ def model_classes: (?untyped) -> Array[untyped]
93
+
94
+ # The states either side of one version; a create has none before it and a
95
+ # destroy none after.
96
+ # : (untyped) -> Array[PreparedRecordState]
97
+ def states_around: (untyped) -> Array[PreparedRecordState]
98
+
99
+ # : (untyped) -> [PreparedRecordState, PreparedRecordState]?
100
+ def transition: (untyped) -> [ PreparedRecordState, PreparedRecordState ]?
86
101
 
87
102
  private
88
103
 
@@ -135,9 +150,15 @@ module PaperTrailDiff
135
150
  # : (untyped, untyped, untyped) -> untyped
136
151
  def record_before: (untyped, untyped, untyped) -> untyped
137
152
 
153
+ # : (untyped, untyped, untyped) -> untyped
154
+ def record_created_in: (untyped, untyped, untyped) -> untyped
155
+
138
156
  # : (untyped, untyped, untyped) -> [bool, PreparedRecordState?]
139
157
  def snapshot_state_before: (untyped, untyped, untyped) -> [ bool, PreparedRecordState? ]
140
158
 
159
+ # Typed as a reified record's attributes are. A JSON or JSONB `object`
160
+ # column stores times and dates as strings, which PaperTrail does not cast
161
+ # back, and the transition is carried into snapshots built from records.
141
162
  # : (untyped, untyped, untyped) -> [Hash[untyped, untyped], Hash[untyped, untyped]]?
142
163
  def transition: (untyped, untyped, untyped) -> [ Hash[untyped, untyped], Hash[untyped, untyped] ]?
143
164
 
@@ -153,11 +174,22 @@ module PaperTrailDiff
153
174
  # : (untyped, untyped) -> Array[untyped]
154
175
  def versions_for_id: (untyped, untyped) -> Array[untyped]
155
176
 
177
+ # : (untyped, untyped, ?untyped) -> Array[untyped]
178
+ def model_classes: (untyped, untyped, ?untyped) -> Array[untyped]
179
+
180
+ # : (untyped, untyped, untyped) -> Array[PreparedRecordState]
181
+ def states_around: (untyped, untyped, untyped) -> Array[PreparedRecordState]
182
+
156
183
  # : (untyped, untyped) -> bool
157
184
  def loaded?: (untyped, untyped) -> bool
158
185
 
159
186
  private
160
187
 
188
+ # A model whose records need their own initialization is cast by
189
+ # instantiating it, as reify does.
190
+ # : (PreparedRecordState) -> Hash[untyped, untyped]
191
+ def typed_attributes: (PreparedRecordState) -> Hash[untyped, untyped]
192
+
161
193
  # : (untyped, String) -> bool
162
194
  def generated_reader?: (untyped, String) -> bool
163
195