clickwrap 0.2.1 → 0.3.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.
@@ -21,14 +21,18 @@ module Clickwrap
21
21
  # - Every hook defaults to a no-op, so the gem works untouched and a host
22
22
  # wires hooks only as needed.
23
23
  # - Nothing here collects personal data by default. Every `record_*` flag
24
- # starts false, and turning one on without a purpose and a retention
25
- # decision is a configuration error, not a warning.
24
+ # starts false. Turning one on takes one line and nothing else; the
25
+ # purpose and the disposal answer have honest gem-supplied defaults, and
26
+ # a host who wants reviewed ones writes them.
26
27
  #
27
28
  # One setting deserves its own note: there is deliberately no
28
29
  # `gdpr_compliant_mode`, `maximum_evidence`, `full_evidence`, or
29
- # `legal_proof`. An option that silently enables a category of personal data
30
- # is exactly the thing this gem exists not to do, and no runtime flag can
31
- # make a legal determination on your behalf.
30
+ # `legal_proof`. Those names hide what they collect and pretend to make a
31
+ # legal determination, which is exactly the thing this gem exists not to do.
32
+ # `record_request_evidence_by_default` is the opposite kind of switch: it
33
+ # says out loud what it records (an IP address, a browser user agent, and a
34
+ # coarse country/region/city estimate), it enables nothing finer, and it
35
+ # claims nothing about the law.
32
36
  class Configuration
33
37
  DOCUMENT_STORES = %i[database active_storage resolver].freeze
34
38
  DIGEST_ALGORITHMS = %i[sha256 sha384 sha512].freeze
@@ -246,6 +250,8 @@ module Clickwrap
246
250
 
247
251
  @ip_geolocation_resolver = nil
248
252
  @ip_geolocation_resolvers = {}
253
+ @automatically_adopted_ip_geolocation_resolver = nil
254
+ @considered_automatic_ip_geolocation_resolver = false
249
255
  @fail_capture_when_ip_geolocation_is_unavailable = false
250
256
 
251
257
  # The keyed annex digest carries a key ID so a host can rotate keys
@@ -612,6 +618,49 @@ module Clickwrap
612
618
 
613
619
  # --- Request-evidence setters --------------------------------------------
614
620
 
621
+ # The one switch.
622
+ #
623
+ # config.record_request_evidence_by_default = true
624
+ #
625
+ # Records, on every policy: the IP address the request arrived from, the
626
+ # browser user agent it sent, and a coarse country/region/city estimate for
627
+ # that address. Nothing finer — a postal code, coordinates, a timezone, a
628
+ # metro code — and nothing else at all. The purpose and the disposal answer
629
+ # have honest gem defaults (see `Vocabulary::DEFAULT_REQUEST_EVIDENCE_PURPOSE`
630
+ # and the keep-indefinitely posture below), so this line is genuinely the
631
+ # whole first step.
632
+ #
633
+ # It is a fan-out setter, not a mode: it writes the individual
634
+ # `record_*_by_default` flags, which means it composes with them in reading
635
+ # order. Write the switch first and a narrower flag after it to carve one
636
+ # field back out —
637
+ #
638
+ # config.record_request_evidence_by_default = true
639
+ # config.record_browser_user_agent_by_default = false
640
+ #
641
+ # — and any policy can still override all of it with `record_ip_address`,
642
+ # `do_not_record_ip_address`, and their siblings. Setting it to false turns
643
+ # the same three fields off and leaves the finer geolocation fields alone,
644
+ # because it never turned those on.
645
+ def record_request_evidence_by_default=(value)
646
+ enabled = ensure_boolean(value, "record_request_evidence_by_default")
647
+
648
+ @record_ip_address_by_default = enabled
649
+ @record_browser_user_agent_by_default = enabled
650
+ Vocabulary::COARSE_IP_GEOLOCATION_DATA_FIELDS.each do |field|
651
+ instance_variable_set(:"@record_ip_geolocation_#{field}_by_default", enabled)
652
+ end
653
+ end
654
+
655
+ # Reads back what the switch describes rather than a remembered assignment:
656
+ # true when all three coarse fields are on, however they were turned on.
657
+ def record_request_evidence_by_default
658
+ record_ip_address_by_default && record_browser_user_agent_by_default &&
659
+ Vocabulary::COARSE_IP_GEOLOCATION_DATA_FIELDS.all? do |field|
660
+ public_send(:"record_ip_geolocation_#{field}_by_default")
661
+ end
662
+ end
663
+
615
664
  def record_ip_address_by_default=(value)
616
665
  @record_ip_address_by_default = ensure_boolean(value, "record_ip_address_by_default")
617
666
  end
@@ -715,11 +764,36 @@ module Clickwrap
715
764
  end
716
765
 
717
766
  def ip_geolocation_resolver_for(name = nil)
718
- return ip_geolocation_resolver if name.blank? || name.to_s == "application_default"
767
+ return application_default_ip_geolocation_resolver if name.blank? || name.to_s == "application_default"
719
768
 
720
769
  @ip_geolocation_resolvers[name.to_s]
721
770
  end
722
771
 
772
+ # What a policy gets when it does not name a resolver: the host's own, or —
773
+ # when they never set one and their bundle already carries `trackdown` 0.4
774
+ # or newer — the official adapter for it. That is the whole "trackdown plus
775
+ # Cloudflare just works" path, and it is deliberately not a silent
776
+ # collection decision: nothing calls this until a policy has already
777
+ # enabled an IP-geolocation field.
778
+ #
779
+ # An installed-but-too-old trackdown is NOT hidden here. The adapter's own
780
+ # sentence about upgrading is more useful than pretending the gem is
781
+ # missing.
782
+ def application_default_ip_geolocation_resolver
783
+ @ip_geolocation_resolver || automatically_adopted_ip_geolocation_resolver
784
+ end
785
+
786
+ # The resolver actually in force, for anything that only wants to describe
787
+ # the configuration (the privacy inventory, `clickwrap:doctor`). Unlike the
788
+ # reader above it never adopts one as a side effect of being asked.
789
+ def ip_geolocation_resolver_in_force
790
+ @ip_geolocation_resolver || @automatically_adopted_ip_geolocation_resolver
791
+ end
792
+
793
+ def ip_geolocation_resolver_was_adopted_automatically?
794
+ @ip_geolocation_resolver.nil? && !@automatically_adopted_ip_geolocation_resolver.nil?
795
+ end
796
+
723
797
  def ip_geolocation_resolver_names = @ip_geolocation_resolvers.keys.sort.freeze
724
798
 
725
799
  # Plain-English key-rotation API. The ID is evidence and must stay stable;
@@ -842,7 +916,6 @@ module Clickwrap
842
916
  # caught the typos; these are the things that need the whole block resolved.
843
917
  def validate!
844
918
  validate_request_evidence_defaults!
845
- validate_trusted_proxy_configuration!
846
919
  validate_ip_geolocation_resolver!
847
920
  true
848
921
  end
@@ -870,6 +943,15 @@ module Clickwrap
870
943
  Reference.record(actor)
871
944
  end
872
945
 
946
+ # Enabling a category by default needs nothing else. A purpose the host did
947
+ # not write falls back to Clickwrap's own stated one, and a disposal answer
948
+ # nobody gave means the corroboration keeps pace with the evidence it
949
+ # corroborates — which is what core evidence has done since 0.2.0.
950
+ #
951
+ # Two things still fail here, and both are the host contradicting
952
+ # themselves rather than merely leaving a blank: scaffolding text standing
953
+ # in for a purpose, and a deletion clock set alongside a declaration to
954
+ # keep the same category forever.
873
955
  def validate_request_evidence_defaults!
874
956
  {
875
957
  ip_address: [record_ip_address_by_default,
@@ -884,37 +966,20 @@ module Clickwrap
884
966
  }.each do |category, (enabled, reason, delete_after)|
885
967
  next unless enabled
886
968
 
887
- if reason.to_s.strip.empty?
888
- raise ConfigurationError,
889
- "Clickwrap is set to record #{category} for every policy by default, but " \
890
- "`reason_for_recording_#{plural_for(category)}_by_default` is blank. Say in one " \
891
- "plain sentence why the application needs it. If only some policies need it, " \
892
- "turn the default off and enable it in those policies instead."
893
- end
894
-
895
969
  if ReviewedText.placeholder?(reason)
896
970
  raise ConfigurationError,
897
971
  "Clickwrap is set to record #{category} for every policy by default, but its " \
898
972
  "reason is still scaffolding text (#{reason.inspect}). Replace it with the " \
899
- "application's reviewed, present-tense reason, or turn that default off."
973
+ "application's reviewed, present-tense reason, or delete the line and let " \
974
+ "Clickwrap record its own stated purpose."
900
975
  end
901
976
 
902
- if delete_after.present? && keeps_recorded_request_evidence_indefinitely?(category)
903
- raise ConfigurationError,
904
- "Clickwrap is told both to delete recorded #{category} after " \
905
- "#{delete_after.inspect} and to keep it indefinitely. Those are opposite " \
906
- "decisions — keep exactly one."
907
- end
908
-
909
- next if delete_after.present? || keeps_recorded_request_evidence_indefinitely?(category)
977
+ next unless delete_after.present? && keeps_recorded_request_evidence_indefinitely?(category)
910
978
 
911
979
  raise ConfigurationError,
912
- "Clickwrap is set to record #{category} for every policy by default, but nothing " \
913
- "says how long to keep it. Either set a reviewed period with " \
914
- "`delete_recorded_#{plural_for(category)}_after`, or keep it as long as the " \
915
- "evidence it corroborates with " \
916
- "`keep_recorded_#{plural_for(category)}_indefinitely!(because: \"…\")` — or turn " \
917
- "the default off and let each policy choose its own retention rule."
980
+ "Clickwrap is told both to delete recorded #{category} after " \
981
+ "#{delete_after.inspect} and to keep it indefinitely. Those are opposite " \
982
+ "decisions keep exactly one."
918
983
  end
919
984
  end
920
985
 
@@ -926,41 +991,27 @@ module Clickwrap
926
991
  end
927
992
  end
928
993
 
929
- def declare_indefinite_request_evidence!(category, because)
930
- if because.to_s.strip.empty?
931
- raise ConfigurationError,
932
- "keep_recorded_#{plural_for(category)}_indefinitely! needs a `because:` " \
933
- "explaining the reviewed decision."
934
- end
935
-
936
- @keep_recorded_request_evidence_indefinitely[category] = because
994
+ def host_reason_for_recording_by_default(category)
995
+ public_send(:"reason_for_recording_#{plural_for(category.to_sym)}_by_default").presence
937
996
  end
938
997
 
939
- def validate_trusted_proxy_configuration!
940
- records_ip_derived_evidence =
941
- record_ip_address_by_default || enabled_default_ip_geolocation_fields.any?
942
- return unless records_ip_derived_evidence
943
- return if trusted_proxy_configuration_digest.present?
944
-
945
- raise ConfigurationError,
946
- "Clickwrap is set to record an IP address or derive IP geolocation for every " \
947
- "policy, but `trusted_proxy_configuration_digest` is blank. Review and test the " \
948
- "deployment's trusted-proxy topology, digest that exact configuration, and set " \
949
- "the complete prefixed SHA-2 digest (for example `sha256:...`). This records which " \
950
- "proxy decision produced the address; it does not claim that decision was correct."
998
+ def declare_indefinite_request_evidence!(category, because)
999
+ @keep_recorded_request_evidence_indefinitely[category] =
1000
+ because.presence || Vocabulary::DEFAULT_REASON_FOR_KEEPING_REQUEST_EVIDENCE_INDEFINITELY
951
1001
  end
952
1002
 
953
1003
  def validate_ip_geolocation_resolver!
954
- return if ip_geolocation_resolver
955
1004
  return if enabled_default_ip_geolocation_fields.empty? && !fail_capture_when_ip_geolocation_is_unavailable
1005
+ return if application_default_ip_geolocation_resolver
956
1006
 
957
1007
  if enabled_default_ip_geolocation_fields.any?
958
1008
  raise ConfigurationError,
959
1009
  "Clickwrap is set to record the IP-geolocation fields " \
960
1010
  "#{enabled_default_ip_geolocation_fields.join(", ")} but no " \
961
- "`ip_geolocation_resolver` is configured, so there is nothing to resolve them. " \
962
- "Set one (for example Clickwrap::IpGeolocation::TrackdownResolver.new) or turn " \
963
- "the fields off."
1011
+ "`ip_geolocation_resolver` is configured and the `trackdown` gem is not " \
1012
+ "installed, so there is nothing to resolve them. Run " \
1013
+ "`bundle add trackdown --version \">= 0.4\"` and Clickwrap will use it, set " \
1014
+ "`config.ip_geolocation_resolver` to your own adapter, or turn the fields off."
964
1015
  end
965
1016
 
966
1017
  raise ConfigurationError,
@@ -968,6 +1019,22 @@ module Clickwrap
968
1019
  "`ip_geolocation_resolver` is configured, so every capture would fail."
969
1020
  end
970
1021
 
1022
+ # Considered once, at the first moment something actually needs geolocation
1023
+ # resolved, and remembered either way — including the "no trackdown here"
1024
+ # answer, so a host without it does not pay for a failed `require` on every
1025
+ # policy compile.
1026
+ def automatically_adopted_ip_geolocation_resolver
1027
+ return @automatically_adopted_ip_geolocation_resolver if @considered_automatic_ip_geolocation_resolver
1028
+
1029
+ # Remembered only once the adapter has actually been built. An installed
1030
+ # trackdown too old to use raises out of here, and a host who fixes their
1031
+ # bundle and asks again must not be told the gem is missing because a
1032
+ # failed attempt got memoized as "no".
1033
+ resolver = (IpGeolocation::TrackdownResolver.new if IpGeolocation::TrackdownResolver.installed?)
1034
+ @considered_automatic_ip_geolocation_resolver = true
1035
+ @automatically_adopted_ip_geolocation_resolver = resolver
1036
+ end
1037
+
971
1038
  # --- Setter helpers -------------------------------------------------------
972
1039
 
973
1040
  def ensure_callable(value, name)
@@ -1118,24 +1185,25 @@ module Clickwrap
1118
1185
 
1119
1186
  public
1120
1187
 
1121
- # The deliberate, named escape hatch referenced by `ensure_encryption_choice`.
1122
- # It exists so that turning encryption off is a sentence a reviewer can find
1123
- # in a diff, with the host's own reason attached, rather than a `false`.
1124
- # The named escape hatch for by-default request evidence with no deletion
1125
- # clock: request evidence exists to corroborate evidence that (since 0.2.0)
1126
- # keeps indefinitely by default, and a corroboration that expires before
1127
- # the thing it corroborates is a scheduled weakening of the record. Same
1128
- # rule as every escape hatch here: keeping forever must be a sentence a
1129
- # reviewer can find in a diff, with the host's own reason attached.
1130
- def keep_recorded_ip_addresses_indefinitely!(because:)
1188
+ # Says out loud what an absent deletion clock already means: this category
1189
+ # keeps pace with the evidence it corroborates. Request evidence exists to
1190
+ # corroborate evidence that (since 0.2.0) keeps indefinitely by default,
1191
+ # and a corroboration that expires before the thing it corroborates is a
1192
+ # scheduled weakening of the record.
1193
+ #
1194
+ # Saying it explicitly is worth doing it puts the decision and its reason
1195
+ # in the initializer where a reviewer finds them but since 0.3.0 it is no
1196
+ # longer the price of admission, and `because:` is optional. What a host
1197
+ # writes is kept as their own words; what they leave out gets Clickwrap's.
1198
+ def keep_recorded_ip_addresses_indefinitely!(because: nil)
1131
1199
  declare_indefinite_request_evidence!(:ip_address, because)
1132
1200
  end
1133
1201
 
1134
- def keep_recorded_browser_user_agents_indefinitely!(because:)
1202
+ def keep_recorded_browser_user_agents_indefinitely!(because: nil)
1135
1203
  declare_indefinite_request_evidence!(:browser_user_agent, because)
1136
1204
  end
1137
1205
 
1138
- def keep_recorded_ip_geolocation_indefinitely!(because:)
1206
+ def keep_recorded_ip_geolocation_indefinitely!(because: nil)
1139
1207
  declare_indefinite_request_evidence!(:ip_geolocation, because)
1140
1208
  end
1141
1209
 
@@ -1143,6 +1211,18 @@ module Clickwrap
1143
1211
  @keep_recorded_request_evidence_indefinitely.key?(category.to_sym)
1144
1212
  end
1145
1213
 
1214
+ # The purpose that will actually be recorded for a category enabled
1215
+ # application-wide, and which of the two wrote it. The inventory reports
1216
+ # both, so a reviewer can tell a sentence their team signed off on from the
1217
+ # one the gem supplied.
1218
+ def reason_for_recording_by_default(category)
1219
+ host_reason_for_recording_by_default(category) || Vocabulary::DEFAULT_REQUEST_EVIDENCE_PURPOSE
1220
+ end
1221
+
1222
+ def reason_for_recording_by_default_source(category)
1223
+ host_reason_for_recording_by_default(category) ? "host" : "gem_default"
1224
+ end
1225
+
1146
1226
  def reason_for_keeping_recorded_request_evidence_indefinitely(category)
1147
1227
  @keep_recorded_request_evidence_indefinitely[category.to_sym]
1148
1228
  end
@@ -271,7 +271,8 @@ module Clickwrap
271
271
  end
272
272
 
273
273
  def resolver_findings
274
- configured = Clickwrap.config.ip_geolocation_resolver
274
+ config = Clickwrap.config
275
+ configured = config.ip_geolocation_resolver_in_force
275
276
  wanted = Clickwrap.policies.values.select { |policy| policy.request_evidence.records_ip_geolocation? }
276
277
 
277
278
  if configured.nil?
@@ -285,7 +286,11 @@ module Clickwrap
285
286
  "as unavailable")]
286
287
  end
287
288
 
288
- [ok("an IP-geolocation resolver is configured (#{configured.class.name})")]
289
+ return [ok("an IP-geolocation resolver is configured (#{configured.class.name})")] unless
290
+ config.ip_geolocation_resolver_was_adopted_automatically?
291
+
292
+ [ok("IP geolocation resolves through #{configured.class.name}, which Clickwrap adopted " \
293
+ "because this application bundles trackdown and named no resolver of its own")]
289
294
  end
290
295
 
291
296
  # An IP address read from a forwarded header is only as good as the proxy
@@ -83,6 +83,22 @@ module Clickwrap
83
83
 
84
84
  attr_reader :capabilities
85
85
 
86
+ # Whether the host's bundle carries `trackdown` at all. The configuration
87
+ # asks this before adopting the adapter for a policy that enabled
88
+ # IP-geolocation fields without naming a resolver, so the common case —
89
+ # trackdown plus Cloudflare, already bundled — needs no wiring line.
90
+ #
91
+ # It answers the narrow question it is named after and nothing else. An
92
+ # installed release older than 0.4 answers `true` here and then fails in
93
+ # the constructor with the sentence about upgrading, which is far more
94
+ # useful to that host than being told the gem is missing.
95
+ def self.installed?
96
+ require "trackdown" unless defined?(::Trackdown)
97
+ true
98
+ rescue ::LoadError
99
+ false
100
+ end
101
+
86
102
  # Trust is per request in Trackdown 0.4. A host registers its verifier with
87
103
  # Trackdown, Trackdown runs it against the same request that supplied the
88
104
  # CDN headers, and this adapter copies the result's explicit trust state.
@@ -125,7 +125,7 @@ module Clickwrap
125
125
  "browser_user_agent" => default_category(config, :browser_user_agent),
126
126
  "ip_geolocation" => default_category(config, :ip_geolocation).merge(
127
127
  "fields" => config.enabled_default_ip_geolocation_fields,
128
- "resolver" => describe_resolver(config.ip_geolocation_resolver),
128
+ "resolver" => describe_resolver(config),
129
129
  "fail_capture_when_unavailable" => config.fail_capture_when_ip_geolocation_is_unavailable
130
130
  ),
131
131
  "review_default_request_evidence_configuration_on" =>
@@ -138,14 +138,25 @@ module Clickwrap
138
138
  }
139
139
  end
140
140
 
141
+ # `because` is the purpose that will actually be recorded, and
142
+ # `purpose_source` says who wrote it. A `"gem_default"` purpose is a real
143
+ # purpose and it is stored with the evidence — but nobody should mistake
144
+ # Clickwrap's own sentence for one the host's team reviewed, so the
145
+ # inventory never lets the two look alike.
141
146
  def default_category(config, category)
147
+ recorded = default_recorded?(config, category)
148
+
142
149
  {
143
- "recorded_by_default" => default_recorded?(config, category),
144
- "because" => config.public_send(:"reason_for_recording_#{plural_for(category)}_by_default"),
150
+ "recorded_by_default" => recorded,
151
+ "because" => recorded ? config.reason_for_recording_by_default(category) : nil,
152
+ "purpose_source" => (config.reason_for_recording_by_default_source(category) if recorded),
145
153
  "legal_basis_reference" =>
146
154
  config.public_send(:"legal_basis_reference_for_recording_#{plural_for(category)}_by_default"),
147
155
  "encrypted" => config.public_send(:"encrypt_recorded_#{plural_for(category)}"),
148
- "delete_after_seconds" => config.public_send(:"delete_recorded_#{plural_for(category)}_after")&.to_i
156
+ "delete_after_seconds" => config.public_send(:"delete_recorded_#{plural_for(category)}_after")&.to_i,
157
+ "kept_indefinitely" => config.keeps_recorded_request_evidence_indefinitely?(category),
158
+ "reason_for_keeping_indefinitely" =>
159
+ config.reason_for_keeping_recorded_request_evidence_indefinitely(category)
149
160
  }
150
161
  end
151
162
 
@@ -186,6 +197,7 @@ module Clickwrap
186
197
  entry = {
187
198
  "recorded" => setting.record?,
188
199
  "because" => setting.because,
200
+ "purpose_source" => policy.request_evidence.purpose_source_for(category),
189
201
  "legal_basis_reference" => setting.legal_basis_reference,
190
202
  "data_protection_impact_assessment_reference" =>
191
203
  setting.data_protection_impact_assessment_reference,
@@ -201,7 +213,7 @@ module Clickwrap
201
213
  entry.merge(
202
214
  "fields" => policy.request_evidence.enabled_ip_geolocation_fields,
203
215
  "resolver_named_by_policy" => policy.request_evidence.ip_geolocation_resolver_name&.to_s,
204
- "resolver" => describe_resolver(Clickwrap.config.ip_geolocation_resolver)
216
+ "resolver" => describe_resolver(Clickwrap.config)
205
217
  )
206
218
  end
207
219
 
@@ -283,10 +295,19 @@ module Clickwrap
283
295
  }
284
296
  end
285
297
 
286
- def describe_resolver(resolver)
298
+ # Reports the resolver in force, and whether the host named it or
299
+ # Clickwrap adopted the official trackdown adapter because their bundle
300
+ # already carried it. Asking never causes that adoption to happen — an
301
+ # inventory describes a configuration, it does not make one.
302
+ def describe_resolver(config)
303
+ resolver = config.ip_geolocation_resolver_in_force
287
304
  return { "configured" => false } if resolver.nil?
288
305
 
289
- { "configured" => true, "class" => resolver.class.name }
306
+ {
307
+ "configured" => true,
308
+ "class" => resolver.class.name,
309
+ "source" => config.ip_geolocation_resolver_was_adopted_automatically? ? "gem_default" : "host"
310
+ }
290
311
  end
291
312
 
292
313
  def plural_for(category)
@@ -244,7 +244,10 @@ module Clickwrap
244
244
 
245
245
  # Provenance is recorded even when the value is not, because "which reader
246
246
  # was asked, under which reviewed proxy configuration" is what tells a
247
- # later reader how much the address is worth.
247
+ # later reader how much the address is worth. A nil digest is part of
248
+ # that answer rather than a hole in it: it says no reviewed proxy
249
+ # configuration was recorded when this address was observed, which is
250
+ # exactly what a reader should know about it.
248
251
  provenance = {
249
252
  ip_address_reader_name: ip_address_reader_name,
250
253
  trusted_proxy_configuration_digest: policy.trusted_proxy_configuration_digest
@@ -484,13 +487,17 @@ module Clickwrap
484
487
  # --- Retention ------------------------------------------------------------
485
488
 
486
489
  # Every recorded field leaves here with a disposal answer: a date, the name
487
- # of a host rule that will produce one, or the explicit reviewed decision
488
- # to keep it as long as the evidence it corroborates. Keeping forever is
489
- # never a silent default it is a named declaration in the retention class
490
- # (`keep_recorded_..._indefinitely`) or the initializer
491
- # (`keep_recorded_..._indefinitely!(because: "…")`) and a recorded field
492
- # with no answer at all is a configuration bug caught before the row is
493
- # written rather than a row nobody ever decided about.
490
+ # of a host rule that will produce one, or no schedule at all — which means
491
+ # it keeps pace with the evidence it corroborates, exactly like an
492
+ # indefinite core event. A blank schedule is the answer, not a gap: the
493
+ # planner never lists these rows, and the receipt reports them as recorded
494
+ # rather than as anything pending.
495
+ #
496
+ # Until 0.3.0 this raised when nothing had named a schedule, on the theory
497
+ # that keeping forever must never be silent. The theory held; the cost did
498
+ # not. It refused captures for hosts who had simply not written a sentence,
499
+ # and pushed integrators toward recording nothing — which is worse evidence
500
+ # than evidence kept under the same posture as the agreement it belongs to.
494
501
  #
495
502
  # `retain_until` names a host calculation instead of a duration because real
496
503
  # record-keeping schedules are not always durations — "five years, or three
@@ -504,15 +511,7 @@ module Clickwrap
504
511
  return { "#{category}_delete_after": now + class_rule.duration } if class_rule&.duration?
505
512
  return { "#{category}_retain_until_rule": class_rule.host_event_name.to_s } if class_rule&.host_event?
506
513
 
507
- # Indefinite — declared in the class or application-wide — stamps
508
- # nothing: the blank schedule plus the recorded declaration IS the
509
- # disposal answer, exactly like an indefinite core event.
510
- if class_rule&.indefinite? ||
511
- Clickwrap.config.keeps_recorded_request_evidence_indefinitely?(category)
512
- return {}
513
- end
514
-
515
- raise ConfigurationError, missing_retention_message(category)
514
+ {}
516
515
  end
517
516
 
518
517
  def retention_class_rule_for(category)
@@ -521,16 +520,6 @@ module Clickwrap
521
520
  Clickwrap.retention_class!(policy.retention_class_key).rule_for(category)
522
521
  end
523
522
 
524
- def missing_retention_message(category)
525
- "Clickwrap is about to record #{category} for policy #{policy_key} and nothing says what " \
526
- "should ever happen to it. Give the policy a rule — `delete_after:` with a reviewed " \
527
- "period, or `retain_until:` naming a host retention calculation — add a #{category} " \
528
- "rule (or `keep_recorded_#{category}_indefinitely`) to retention class " \
529
- "#{policy.retention_class_key.inspect}, or answer it application-wide with " \
530
- "`keep_recorded_..._indefinitely!(because: \"…\")`. Keeping forever is never silent, " \
531
- "and Clickwrap will not choose for you."
532
- end
533
-
534
523
  # --- Failing closed -------------------------------------------------------
535
524
 
536
525
  # A policy can decide that evidence it cannot get is worse than no capture