shikibu 0.2.0 → 0.4.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 (138) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +121 -0
  3. data/lib/shikibu/activity.rb +84 -48
  4. data/lib/shikibu/actors.rb +129 -0
  5. data/lib/shikibu/app.rb +45 -19
  6. data/lib/shikibu/blobs.rb +42 -0
  7. data/lib/shikibu/channels.rb +240 -64
  8. data/lib/shikibu/constants.rb +8 -0
  9. data/lib/shikibu/context.rb +184 -14
  10. data/lib/shikibu/errors.rb +56 -0
  11. data/lib/shikibu/fs.rb +93 -0
  12. data/lib/shikibu/integrations/sidekiq.rb +9 -13
  13. data/lib/shikibu/middleware/rack_app.rb +17 -1
  14. data/lib/shikibu/replay.rb +248 -100
  15. data/lib/shikibu/storage/actor_ops.rb +331 -0
  16. data/lib/shikibu/storage/channel_ops.rb +421 -0
  17. data/lib/shikibu/storage/cursor_ops.rb +37 -0
  18. data/lib/shikibu/storage/sequel_storage.rb +400 -324
  19. data/lib/shikibu/storage/sqlite_ops.rb +58 -0
  20. data/lib/shikibu/supervisor.rb +279 -0
  21. data/lib/shikibu/tasks.rb +193 -0
  22. data/lib/shikibu/typed_payload.rb +189 -0
  23. data/lib/shikibu/version.rb +1 -1
  24. data/lib/shikibu/worker.rb +155 -73
  25. data/lib/shikibu/workflow.rb +203 -50
  26. data/lib/shikibu.rb +5 -0
  27. data/schema/SEMANTICS.md +351 -0
  28. data/schema/db/migrations/mysql/20261123000000_outbox_claimed_at.sql +5 -0
  29. data/schema/db/migrations/mysql/20261201000000_actor_registry.sql +24 -0
  30. data/schema/db/migrations/mysql/20261202000000_actor_capabilities.sql +15 -0
  31. data/schema/db/migrations/mysql/20261203000000_payload_blobs.sql +11 -0
  32. data/schema/db/migrations/mysql/20261204000000_actor_fs.sql +13 -0
  33. data/schema/db/migrations/mysql/20261205000000_actor_tasks.sql +15 -0
  34. data/schema/db/migrations/mysql/20261206000000_actor_tasks_claimed_at.sql +7 -0
  35. data/schema/db/migrations/mysql/20261207000000_add_sandboxed.sql +5 -0
  36. data/schema/db/migrations/mysql/20261208000000_widen_actor_owner_columns.sql +15 -0
  37. data/schema/db/migrations/postgresql/20261123000000_outbox_claimed_at.sql +5 -0
  38. data/schema/db/migrations/postgresql/20261201000000_actor_registry.sql +23 -0
  39. data/schema/db/migrations/postgresql/20261202000000_actor_capabilities.sql +15 -0
  40. data/schema/db/migrations/postgresql/20261203000000_payload_blobs.sql +11 -0
  41. data/schema/db/migrations/postgresql/20261204000000_actor_fs.sql +13 -0
  42. data/schema/db/migrations/postgresql/20261205000000_actor_tasks.sql +15 -0
  43. data/schema/db/migrations/postgresql/20261206000000_actor_tasks_claimed_at.sql +7 -0
  44. data/schema/db/migrations/postgresql/20261207000000_add_sandboxed.sql +5 -0
  45. data/schema/db/migrations/postgresql/20261208000000_widen_actor_owner_columns.sql +7 -0
  46. data/schema/db/migrations/sqlite/20261123000000_outbox_claimed_at.sql +5 -0
  47. data/schema/db/migrations/sqlite/20261201000000_actor_registry.sql +23 -0
  48. data/schema/db/migrations/sqlite/20261202000000_actor_capabilities.sql +15 -0
  49. data/schema/db/migrations/sqlite/20261203000000_payload_blobs.sql +11 -0
  50. data/schema/db/migrations/sqlite/20261204000000_actor_fs.sql +13 -0
  51. data/schema/db/migrations/sqlite/20261205000000_actor_tasks.sql +15 -0
  52. data/schema/db/migrations/sqlite/20261206000000_actor_tasks_claimed_at.sql +7 -0
  53. data/schema/db/migrations/sqlite/20261207000000_add_sandboxed.sql +5 -0
  54. data/schema/db/migrations/sqlite/20261208000000_widen_actor_owner_columns.sql +7 -0
  55. data/schema/docs/column-values.md +10 -0
  56. data/schema/spec/ActorFS.tla +117 -0
  57. data/schema/spec/ActorFS_lww_monotonic.cfg +7 -0
  58. data/schema/spec/ActorFS_new.cfg +8 -0
  59. data/schema/spec/ActorFS_old.cfg +7 -0
  60. data/schema/spec/CompetingMessageClaim.tla +127 -0
  61. data/schema/spec/CompetingMessageClaimSplit.tla +132 -0
  62. data/schema/spec/CompetingMessageClaimSplit_atomic_lost.cfg +7 -0
  63. data/schema/spec/CompetingMessageClaimSplit_atomic_once.cfg +7 -0
  64. data/schema/spec/CompetingMessageClaimSplit_fixed.cfg +7 -0
  65. data/schema/spec/CompetingMessageClaimSplit_split_lost.cfg +7 -0
  66. data/schema/spec/CompetingMessageClaimSplit_split_once.cfg +7 -0
  67. data/schema/spec/CompetingMessageClaimSplit_waitonly_lost.cfg +7 -0
  68. data/schema/spec/CompetingMessageClaimSplit_waitonly_once.cfg +7 -0
  69. data/schema/spec/CompetingMessageClaim_new.cfg +10 -0
  70. data/schema/spec/CompetingMessageClaim_old.cfg +11 -0
  71. data/schema/spec/EpochFencing.tla +87 -0
  72. data/schema/spec/EpochFencingRuns.tla +107 -0
  73. data/schema/spec/EpochFencingRuns_epoch.cfg +6 -0
  74. data/schema/spec/EpochFencingRuns_none.cfg +6 -0
  75. data/schema/spec/EpochFencingRuns_witness.cfg +6 -0
  76. data/schema/spec/EpochFencingRuns_worker.cfg +6 -0
  77. data/schema/spec/EpochFencingRuns_worker1.cfg +6 -0
  78. data/schema/spec/EpochFencing_new.cfg +8 -0
  79. data/schema/spec/EpochFencing_old.cfg +9 -0
  80. data/schema/spec/InstanceClaim.tla +196 -0
  81. data/schema/spec/InstanceClaimVerdict.tla +116 -0
  82. data/schema/spec/InstanceClaimVerdict_changedrows.cfg +6 -0
  83. data/schema/spec/InstanceClaimVerdict_changedrows_live.cfg +6 -0
  84. data/schema/spec/InstanceClaimVerdict_foundrows.cfg +6 -0
  85. data/schema/spec/InstanceClaimVerdict_foundrows_live.cfg +6 -0
  86. data/schema/spec/InstanceClaim_atomic_unfenced.cfg +9 -0
  87. data/schema/spec/InstanceClaim_live.cfg +9 -0
  88. data/schema/spec/InstanceClaim_new.cfg +9 -0
  89. data/schema/spec/InstanceClaim_old.cfg +11 -0
  90. data/schema/spec/InstanceClaim_racy_fenced.cfg +9 -0
  91. data/schema/spec/README.md +97 -0
  92. data/schema/spec/SupervisorRestart.tla +108 -0
  93. data/schema/spec/SupervisorRestartCAS.tla +84 -0
  94. data/schema/spec/SupervisorRestartCAS_nonsticky.cfg +6 -0
  95. data/schema/spec/SupervisorRestartCAS_snapshot.cfg +6 -0
  96. data/schema/spec/SupervisorRestartCAS_sticky.cfg +6 -0
  97. data/schema/spec/SupervisorRestart_racy.cfg +7 -0
  98. data/schema/spec/SupervisorRestart_strict.cfg +7 -0
  99. data/schema/spec/TaskClaim.tla +92 -0
  100. data/schema/spec/TaskClaimReadBack.tla +84 -0
  101. data/schema/spec/TaskClaimReadBack_byid.cfg +6 -0
  102. data/schema/spec/TaskClaimReadBack_order.cfg +6 -0
  103. data/schema/spec/TaskClaim_new.cfg +8 -0
  104. data/schema/spec/TaskClaim_old.cfg +9 -0
  105. data/schema/spec/TaskReclaim.tla +110 -0
  106. data/schema/spec/TaskReclaimAttempts.tla +73 -0
  107. data/schema/spec/TaskReclaimAttempts_attempt.cfg +6 -0
  108. data/schema/spec/TaskReclaimAttempts_claimant.cfg +6 -0
  109. data/schema/spec/TaskReclaim_new.cfg +8 -0
  110. data/schema/spec/TaskReclaim_old.cfg +8 -0
  111. data/schema/spec/WaitRegistration.tla +170 -0
  112. data/schema/spec/WaitRegistrationSub.tla +133 -0
  113. data/schema/spec/WaitRegistrationSub_fixed.cfg +6 -0
  114. data/schema/spec/WaitRegistrationSub_fixed_guarded.cfg +6 -0
  115. data/schema/spec/WaitRegistrationSub_guardonly_reg.cfg +6 -0
  116. data/schema/spec/WaitRegistrationSub_guardonly_res.cfg +6 -0
  117. data/schema/spec/WaitRegistrationSub_head_reg.cfg +6 -0
  118. data/schema/spec/WaitRegistrationSub_head_res.cfg +6 -0
  119. data/schema/spec/WaitRegistrationSub_noclear_reg.cfg +6 -0
  120. data/schema/spec/WaitRegistrationSub_noclear_res.cfg +6 -0
  121. data/schema/spec/WaitRegistrationSub_unfencedreg_reg.cfg +6 -0
  122. data/schema/spec/WaitRegistrationSub_unfencedreg_res.cfg +6 -0
  123. data/schema/spec/WaitRegistration_new.cfg +10 -0
  124. data/schema/spec/WaitRegistration_old.cfg +11 -0
  125. data/schema/spec/WaitRegistration_residual.cfg +11 -0
  126. data/schema/spec/WaitRegistration_sweep.cfg +11 -0
  127. data/schema/spec/actorfs_check_test.go +165 -0
  128. data/schema/spec/claim_check_test.go +387 -0
  129. data/schema/spec/competing_claim_test.go +194 -0
  130. data/schema/spec/epoch_check_test.go +128 -0
  131. data/schema/spec/go.mod +3 -0
  132. data/schema/spec/supervisorrestart_check_test.go +131 -0
  133. data/schema/spec/taskclaim_check_test.go +135 -0
  134. data/schema/spec/taskreclaim_check_test.go +125 -0
  135. data/schema/spec/tlc-check.sh +45 -0
  136. data/schema/spec/tlc-matrix.txt +68 -0
  137. data/schema/spec/wait_check_test.go +256 -0
  138. metadata +136 -2
@@ -59,6 +59,85 @@ module Shikibu
59
59
  end
60
60
  end
61
61
 
62
+ # Set the input type for this workflow
63
+ # @param type_class [Class, nil] A Dry::Struct, Data, or duck-typed class
64
+ # @example
65
+ # class OrderSaga < Shikibu::Workflow
66
+ # input OrderInput
67
+ # output OrderResult
68
+ # end
69
+ def input(type_class = nil)
70
+ if type_class
71
+ unless TypedPayload.typed_class?(type_class)
72
+ raise ArgumentError, "#{type_class} must be a Dry::Struct, Data, or respond to .new and #to_h"
73
+ end
74
+
75
+ @input_type = type_class
76
+ else
77
+ @input_type
78
+ end
79
+ end
80
+
81
+ # Set the output type for this workflow (optional)
82
+ # @param type_class [Class, nil] A Dry::Struct, Data, or duck-typed class
83
+ def output(type_class = nil)
84
+ if type_class
85
+ unless TypedPayload.typed_class?(type_class)
86
+ raise ArgumentError, "#{type_class} must be a Dry::Struct, Data, or respond to .new and #to_h"
87
+ end
88
+
89
+ @output_type = type_class
90
+ else
91
+ @output_type
92
+ end
93
+ end
94
+
95
+ # Check if this workflow has typed input
96
+ # @return [Boolean]
97
+ def typed_input?
98
+ !@input_type.nil?
99
+ end
100
+
101
+ # Check if this workflow has typed output
102
+ # @return [Boolean]
103
+ def typed_output?
104
+ !@output_type.nil?
105
+ end
106
+
107
+ # Serialize input for storage
108
+ # @param input_value [Object] Input to serialize
109
+ # @return [Hash] Serialized hash
110
+ def serialize_input(input_value)
111
+ TypedPayload.to_h(input_value)
112
+ end
113
+
114
+ # Deserialize input from storage
115
+ # @param data [Hash] Stored data
116
+ # @return [Object] Typed input or hash
117
+ def deserialize_input(data)
118
+ return data unless typed_input?
119
+ return data unless data.is_a?(Hash)
120
+
121
+ TypedPayload.from_h(data, @input_type)
122
+ end
123
+
124
+ # Serialize output for storage
125
+ # @param output_value [Object] Output to serialize
126
+ # @return [Hash, Object] Serialized output
127
+ def serialize_output(output_value)
128
+ TypedPayload.to_h(output_value)
129
+ end
130
+
131
+ # Deserialize output from storage
132
+ # @param data [Object] Stored data
133
+ # @return [Object] Typed output or original data
134
+ def deserialize_output(data)
135
+ return data unless typed_output?
136
+ return data unless data.is_a?(Hash)
137
+
138
+ TypedPayload.from_h(data, @output_type)
139
+ end
140
+
62
141
  # Get the source hash for this workflow
63
142
  def source_hash
64
143
  @source_hash ||= begin
@@ -88,8 +167,8 @@ module Shikibu
88
167
  # @param input [Hash] Input parameters
89
168
  # @param instance_id [String, nil] Optional custom instance ID
90
169
  # @return [String] The instance ID
91
- def start(app, instance_id: nil, **input)
92
- app.start_workflow(self, instance_id: instance_id, **input)
170
+ def start(app, instance_id: nil, sandboxed: false, **input)
171
+ app.start_workflow(self, instance_id: instance_id, sandboxed: sandboxed, **input)
93
172
  end
94
173
 
95
174
  # Run workflow using global Shikibu.app
@@ -130,18 +209,34 @@ module Shikibu
130
209
  # Execute an activity with automatic retry and history tracking
131
210
  # @param name [Symbol, String] Activity name
132
211
  # @param retry_policy [RetryPolicy] Retry policy
212
+ # @param returns [Class, nil] Return type class for type restoration during replay
133
213
  # @param block [Proc] Activity logic
134
214
  # @return [Object] Activity result
135
- def activity(name, retry_policy: nil, &)
215
+ # @raise [ArgumentError] If returns is not a valid typed class
216
+ def activity(name, retry_policy: nil, returns: nil, &)
217
+ ctx.raise_if_run_aborted!
218
+ if returns && !TypedPayload.typed_class?(returns)
219
+ raise ArgumentError, "returns: must be a typed class (Dry::Struct, Data, or duck-typed), got #{returns.inspect}"
220
+ end
221
+
136
222
  activity_id = ctx.generate_activity_id(name.to_s)
137
- ctx.current_activity_id = activity_id
138
223
 
139
224
  # Check for cached result during replay
140
225
  if ctx.replaying? && ctx.cached_result?(activity_id)
141
226
  cached = ctx.get_cached_result(activity_id)
142
227
  handle_cached_result(activity_id, cached)
143
228
  ctx.record_last_activity_id(activity_id)
144
- return cached[:result] if cached[:event_type] == EventType::ACTIVITY_COMPLETED
229
+
230
+ if cached[:event_type] == EventType::ACTIVITY_COMPLETED
231
+ result = cached[:result]
232
+
233
+ # Restore type if specified
234
+ if returns && TypedPayload.typed_class?(returns) && result.is_a?(Hash)
235
+ result = TypedPayload.from_h(result, returns)
236
+ end
237
+
238
+ return result
239
+ end
145
240
 
146
241
  # Re-raise cached error
147
242
  raise reconstruct_error(cached)
@@ -151,8 +246,6 @@ module Shikibu
151
246
  result = execute_activity(activity_id, name.to_s, retry_policy || RetryPolicy.default, &)
152
247
  ctx.record_last_activity_id(activity_id)
153
248
  result
154
- ensure
155
- ctx.current_activity_id = nil
156
249
  end
157
250
 
158
251
  # Register a compensation action to run on failure (Romancy/Edda compatible)
@@ -212,20 +305,20 @@ module Shikibu
212
305
  ctx.unsubscribe(channel)
213
306
  end
214
307
 
215
- def receive(channel, timeout: nil, mode: ChannelMode::BROADCAST)
216
- ctx.receive(channel, timeout: timeout, mode: mode)
308
+ def receive(channel, timeout: nil, mode: ChannelMode::BROADCAST, capability_token: nil)
309
+ ctx.receive(channel, timeout: timeout, mode: mode, capability_token: capability_token)
217
310
  end
218
311
 
219
- def try_receive(channel, mode: ChannelMode::BROADCAST)
220
- ctx.try_receive(channel, mode: mode)
312
+ def try_receive(channel, mode: ChannelMode::BROADCAST, capability_token: nil)
313
+ ctx.try_receive(channel, mode: mode, capability_token: capability_token)
221
314
  end
222
315
 
223
- def publish(channel, data, metadata: nil)
224
- ctx.publish(channel, data, metadata: metadata)
316
+ def publish(channel, data, metadata: nil, capability_token: nil)
317
+ ctx.publish(channel, data, metadata: metadata, capability_token: capability_token)
225
318
  end
226
319
 
227
- def send_to(target_instance_id, channel, data)
228
- ctx.send_to(target_instance_id, channel, data)
320
+ def send_to(target_instance_id, channel, data, metadata: nil, capability_token: nil)
321
+ ctx.send_to(target_instance_id, channel, data, metadata: metadata, capability_token: capability_token)
229
322
  end
230
323
 
231
324
  def recur(**new_input)
@@ -281,10 +374,18 @@ module Shikibu
281
374
  def execute_single_compensation(comp, compensation_id)
282
375
  # Execute compensation and record result atomically in a transaction
283
376
  ctx.storage.transaction do
284
- comp[:block].call
377
+ # Mark as in-activity so FS ops are allowed inside compensations
378
+ prev_activity_id = ctx.current_activity_id
379
+ ctx.current_activity_id = "compensation:#{compensation_id || comp[:activity_id]}"
380
+ begin
381
+ comp[:block].call
382
+ ensure
383
+ ctx.current_activity_id = prev_activity_id
384
+ end
285
385
 
286
386
  # Record successful compensation (Romancy/Edda compatible format)
287
387
  ctx.storage.append_history(
388
+ lock_id: ctx.lock_id,
288
389
  instance_id: ctx.instance_id,
289
390
  activity_id: "compensation:#{compensation_id || comp[:activity_id]}",
290
391
  event_type: EventType::COMPENSATION_EXECUTED,
@@ -298,6 +399,7 @@ module Shikibu
298
399
  rescue StandardError => e
299
400
  # Record failed compensation but continue with others (outside transaction)
300
401
  ctx.storage.append_history(
402
+ lock_id: ctx.lock_id,
301
403
  instance_id: ctx.instance_id,
302
404
  activity_id: "compensation:#{compensation_id || comp[:activity_id]}",
303
405
  event_type: EventType::COMPENSATION_FAILED,
@@ -311,6 +413,17 @@ module Shikibu
311
413
  )
312
414
  end
313
415
 
416
+ # Record a completed activity in history, fenced by the lock epoch
417
+ def record_activity_completed(ctx, activity_id, event_data:)
418
+ ctx.storage.append_history(
419
+ lock_id: ctx.lock_id,
420
+ instance_id: ctx.instance_id,
421
+ activity_id: activity_id,
422
+ event_type: EventType::ACTIVITY_COMPLETED,
423
+ event_data: event_data
424
+ )
425
+ end
426
+
314
427
  def execute_activity(activity_id, name, retry_policy, &block)
315
428
  attempt = 0
316
429
  started_at = Time.now
@@ -318,20 +431,27 @@ module Shikibu
318
431
 
319
432
  loop do
320
433
  attempt += 1
434
+ # Only an error from the body is the activity's outcome. One while
435
+ # beginning, recording or committing the attempt is a storage error:
436
+ # the run ends instead and a later run executes the activity again.
437
+ phase = :body # a hook error stays an activity failure
321
438
 
322
439
  begin
323
440
  # Call hooks
324
441
  ctx.hooks&.on_activity_start&.call(ctx.instance_id, activity_id, name, attempt)
325
442
 
326
- # Execute activity and record result atomically in a transaction
327
- result = ctx.storage.transaction do
328
- res = block.call
443
+ # Execute activity and record result atomically in a transaction.
444
+ # current_activity_id marks the executing body (FS gate, direct
445
+ # kernel calls).
446
+ phase = :begin
447
+ result = ctx.storage.attempt_transaction do
448
+ phase = :body
449
+ res = with_activity_body(activity_id, &block)
450
+ phase = :record
329
451
 
330
452
  # Record successful result (atomic with activity execution)
331
- ctx.storage.append_history(
332
- instance_id: ctx.instance_id,
333
- activity_id: activity_id,
334
- event_type: EventType::ACTIVITY_COMPLETED,
453
+ record_activity_completed(
454
+ ctx, activity_id,
335
455
  event_data: { result: res }
336
456
  )
337
457
 
@@ -348,33 +468,22 @@ module Shikibu
348
468
  ctx.hooks&.on_activity_complete&.call(ctx.instance_id, activity_id, name, result, false)
349
469
 
350
470
  return result
471
+ rescue LockLostError => e
472
+ # Lease lost: abort the run without retrying or further writes
473
+ ctx.poison_run!(e)
474
+ raise
475
+ rescue WorkflowCancelledError
476
+ # Cancellation ends the run; it is never an activity failure.
477
+ raise
351
478
  rescue StandardError => e
479
+ raise if ctx.storage.nested_write_conflict?(e) # the outer attempt restarts
480
+
481
+ ctx.abort_run!(e) unless phase == :body
352
482
  last_error = e
353
483
 
354
484
  # Check if retryable
355
485
  unless retry_policy.retryable?(e) && retry_policy.should_retry?(attempt, started_at)
356
- # Record failure
357
- ctx.storage.append_history(
358
- instance_id: ctx.instance_id,
359
- activity_id: activity_id,
360
- event_type: EventType::ACTIVITY_FAILED,
361
- event_data: {
362
- error_type: e.class.name,
363
- error_message: e.message,
364
- attempts: attempt
365
- }
366
- )
367
-
368
- # Cache for replay
369
- ctx.cache_result(activity_id, {
370
- event_type: EventType::ACTIVITY_FAILED,
371
- error_type: e.class.name,
372
- error_message: e.message
373
- })
374
-
375
- # Call hooks
376
- ctx.hooks&.on_activity_failed&.call(ctx.instance_id, activity_id, name, e, attempt)
377
-
486
+ record_activity_failure(activity_id, name, e, attempt)
378
487
  raise
379
488
  end
380
489
 
@@ -388,19 +497,63 @@ module Shikibu
388
497
  end
389
498
  end
390
499
 
500
+ # Record the failure the activity gave up with. Failing to record it is
501
+ # a storage error, not an outcome: the run ends (lock loss included).
502
+ def record_activity_failure(activity_id, name, error, attempt)
503
+ begin
504
+ ctx.storage.append_history(
505
+ lock_id: ctx.lock_id,
506
+ instance_id: ctx.instance_id,
507
+ activity_id: activity_id,
508
+ event_type: EventType::ACTIVITY_FAILED,
509
+ event_data: {
510
+ error_type: error.class.name,
511
+ error_message: error.message,
512
+ attempts: attempt
513
+ }
514
+ )
515
+ rescue LockLostError => e
516
+ ctx.poison_run!(e)
517
+ raise
518
+ rescue StandardError => e
519
+ ctx.abort_run!(e)
520
+ end
521
+ ctx.cache_result(activity_id, {
522
+ event_type: EventType::ACTIVITY_FAILED,
523
+ error_type: error.class.name,
524
+ error_message: error.message
525
+ })
526
+ ctx.hooks&.on_activity_failed&.call(ctx.instance_id, activity_id, name, error, attempt)
527
+ end
528
+
529
+ def with_activity_body(activity_id)
530
+ previous = ctx.current_activity_id
531
+ ctx.current_activity_id = activity_id
532
+ yield
533
+ ensure
534
+ ctx.current_activity_id = previous
535
+ end
536
+
391
537
  def handle_cached_result(activity_id, cached)
392
538
  name = activity_id.split(':').first
393
539
  ctx.hooks&.on_activity_complete&.call(ctx.instance_id, activity_id, name, cached[:result], true)
394
540
  end
395
541
 
542
+ # Rebuild a recorded activity failure as its error class; a name that is
543
+ # not a StandardError class (or cannot take just a message) replays as a
544
+ # StandardError with the recorded message.
396
545
  def reconstruct_error(cached)
397
546
  error_class = begin
398
- Object.const_get(cached[:error_type])
399
- rescue StandardError
400
- StandardError
547
+ Object.const_get(cached[:error_type].to_s)
548
+ rescue NameError
549
+ nil
550
+ end
551
+ error_class = StandardError unless error_class.is_a?(Class) && error_class <= StandardError
552
+ begin
553
+ error_class.new(cached[:error_message])
554
+ rescue ArgumentError
555
+ StandardError.new(cached[:error_message])
401
556
  end
402
-
403
- error_class.new(cached[:error_message])
404
557
  end
405
558
  end
406
559
  end
data/lib/shikibu.rb CHANGED
@@ -131,7 +131,12 @@ require_relative 'shikibu/notify/notify_base'
131
131
  require_relative 'shikibu/notify/wake_event'
132
132
  require_relative 'shikibu/locking'
133
133
  require_relative 'shikibu/channels'
134
+ require_relative 'shikibu/actors'
135
+ require_relative 'shikibu/blobs'
136
+ require_relative 'shikibu/fs'
137
+ require_relative 'shikibu/tasks'
134
138
  require_relative 'shikibu/context'
139
+ require_relative 'shikibu/typed_payload'
135
140
  require_relative 'shikibu/workflow'
136
141
  require_relative 'shikibu/activity'
137
142
  require_relative 'shikibu/storage/migrations'