Repository navigation
Description
The composed recurrence step and its modifier contract already exist and behave correctly, but they are not reachable from outside the package. Neither the composed step type nor the modifier abstract type is exported, and every public recurrence constructor builds a plain core step, so the composable path can be reached only by positional construction with an internal type. This issue proposes exporting and documenting the composed step, adding a modifiers keyword to the public constructor (with an empty tuple recovering the plain recurrence exactly), and framing the modifier seam as a provisional extension point rather than a settled contract.
Rationale
The clear part is that the composed recurrence step and its modifier contract exist and are correct but neither the composed step type nor the modifier abstract type is exported, and every public constructor builds a plain core step, so the composable path is reachable only by positional construction with an internal type. Exporting and documenting the recurrence constructor is wanted regardless.
The hesitancy is about the modifier approach itself: whether a modifier seam is the right way to vary a recurrence's mechanism is not settled, so this should expose the existing capability without cementing that design as the way. Frame the modifier seam as a provisional extension point rather than a settled contract, and note the open question of whether mechanism variation belongs in a modifier seam at all, so downstream code does not harden against it before the design is confirmed.
Value / effort
Value high · Effort low · Verdict nearly (design-first on the modifier seam: expose the existing capability, but keep the seam provisional rather than a committed contract).
Illustrative example
Note: this example is schematic; the real type names have been substituted with domain-neutral placeholders.
using ComposableTuringIDModels, Distributions
# The public recurrence constructor always builds a plain core step:
rec = Recurrence([0.2, 0.3, 0.5]; rt = RandomWalk(),
initialisation_prior = Normal())
# rec.recurrent_step isa ComposableTuringIDModels.ConstantRecurrenceStep # plain core
# The composed recurrence path already exists and is correct, but the composed
# step type and the modifier abstract type are NOT exported. Today it is
# reachable only by positional construction with internal, module-qualified
# types — awkward and brittle for downstream code:
core = ComposableTuringIDModels.ConstantRecurrenceStep(reverse([0.2, 0.3, 0.5]))
mods = (some_modifier,) # each <: ComposableTuringIDModels.AbstractRecurrenceModifier
composed = ComposableTuringIDModels.ComposedRecurrenceStep(core, mods)
rec_composed = Recurrence([0.2, 0.3, 0.5], exp, RandomWalk(), Normal(), composed)
# --- Desired ---
# Export `ComposedRecurrenceStep` and `AbstractRecurrenceModifier`, and add a
# `modifiers` keyword to the public constructor. An empty tuple must recover the
# plain recurrence exactly:
rec = Recurrence([0.2, 0.3, 0.5]; rt = RandomWalk(),
initialisation_prior = Normal(), modifiers = ()) # identical to plain
# A non-empty tuple threads the proposed contribution through each modifier,
# every modifier carrying its own substate across the scan:
rec = Recurrence([0.2, 0.3, 0.5]; rt = RandomWalk(),
initialisation_prior = Normal(), modifiers = (some_modifier,))
# Document `AbstractRecurrenceModifier` (its `modifier_init_state` /
# `apply_modifier` contract) as a PROVISIONAL extension point: expose it so the
# composable path is dispatchable from outside, but flag that whether mechanism
# variation belongs in a modifier seam at all is still an open design question,
# so downstream code should not harden against it yet.Part of #165.
This issue was opened by a bot. Please ping @seabbs for any questions.
Activity
seabbs-bot commentedon Aug 4, 2026
Partly resolved — leaving open.
Done: the composed step and its modifiers are now public and documented,
reachable without any internal, module-qualified construction.
RenewalStep,SusceptibleDepletionandImportedCasesare all exported(
src/ComposableTuringIDModels.jl), and the publicRenewalconstructortakes modifiers directly as positional arguments (an empty modifier list
recovers the plain renewal exactly):
(see
docs/src/design.md, "Composing accumulation steps"). The modifiercontract (
modifier_init_state/apply_modifier) is documented onAbstractRenewalModifierinsrc/steps/RenewalStep.jl.Not done:
AbstractRenewalModifieritself is not in the top-levelexportlist, so writing a new modifier from outside the package stillneeds the qualified
ComposableTuringIDModels.AbstractRenewalModifiertosubtype against — the "provisional extension point" isn't fully public
yet.
This was commented on by a bot. Please ping @seabbs for any questions.
seabbs commentedon Aug 5, 2026
is it public not exported that seems the right level no?
seabbs commentedon Aug 5, 2026
maybe true modifier_init_state and apply_modifier as well maybe? f
seabbs-bot commentedon Aug 18, 2026
Verified the composed-step/modifier ask is already fully resolved (via #245,
before this PR):
RenewalStep,SusceptibleDepletionandImportedCasesare exported;
AbstractRenewalModifier,modifier_init_stateandapply_modifierare alreadypublic(not exported — matching your call inthe thread above); and the public
Renewalconstructor already takesmodifiers directly (
Renewal(gen_int, modifiers...; rt = ...), an emptytuple recovering the plain renewal exactly). No code change needed there.
Separately, PR #282 makes the related prior-slot widening seam
(
at/path_prior/prior_order/assert_prior_length, previously_at/_path_prior/_prior_order/_assert_prior_length)publictoo,since it was raised alongside this issue and #184.
Leaving this open per instruction rather than closing outright, but as far
as I can verify every concrete ask in this issue's body and comments is now
met.
This was commented on by a bot. Please ping @seabbs for any questions.
feat(base): make prior-widening helpers public API (#173, #184) (#282)
seabbs-bot commentedon Aug 20, 2026
Re-checked against
mainat 1a3e485 (after #282 merged). Three of the four asks are met, one is not, so this stays open on a much narrower point.Met.
RenewalStepis exported (src/ComposableTuringIDModels.jl:98), andAbstractRenewalModifier,modifier_init_stateandapply_modifierarepublic(:138-140). Confirmed withBase.isexported/Base.ispublic.Renewal(gen_int, modifiers::AbstractRenewalModifier...; ...)exists (src/infection_models/Renewal.jl:170), so no positional construction with an internal type is needed.randonIDModel(Renewal(; generation_time = g, rt = RandomWalk(), initialisation = Normal()), PoissonError())and on the same model built through the varargs constructor with no modifiers give identical draws. The step type differs (ConstantRenewalStepagainstRenewalStep{ConstantRenewalStep, Tuple{}}) but the sampled model does not.AbstractRenewalModifierdocstring (src/steps/RenewalStep.jl) documentsmodifier_init_state,apply_modifierand theas_turing_modelresolution seam, including the positionalmodifier_<i>prefixing.Most of this landed in #245 rather than #282; #282 confirmed it and added the prior-slot helpers.
Not met. The provisional framing. Nothing in
src/ordocs/src/says the modifier seam is a provisional extension point, or notes the open question of whether mechanism variation belongs in a modifier seam at all. Grepping for "provisional", "not settled", "open design question" and "do not harden" over both trees returns no matches. A downstream reader of the docstring today sees a settled contract, which is the thing this issue asked to avoid.Left open for that. It is a sentence or two on the
AbstractRenewalModifierdocstring, and it is coupled to #176.This was written by a bot. Please ping @seabbs for any questions.