JsonRemedy.LayerBehaviour behaviour (json_remedy v0.1.3)
View SourceDefines the contract that all repair layers must implement.
Each layer is responsible for one specific type of repair concern and should be composable with other layers in the pipeline.
Summary
Callbacks
Return a human-readable name for this layer. Used in logging and debugging.
Return the priority order for this layer (lower = earlier). Used to determine layer execution order.
Process input string and apply layer-specific repairs.
Check if this layer can handle the given input. Used for optimization and layer selection.
Validate layer configuration and options. Called during pipeline setup.
Functions
Check if a position in the input is inside a string literal. Used to avoid applying repairs to string content.
Types
@type layer_result() :: {:ok, String.t(), repair_context()} | {:continue, String.t(), repair_context()} | {:error, String.t()}
@type repair_action() :: %{ layer: atom(), action: String.t(), position: non_neg_integer() | nil, original: String.t() | nil, replacement: String.t() | nil }
@type repair_context() :: %{ repairs: [repair_action()], options: keyword(), metadata: map() }
Callbacks
@callback name() :: String.t()
Return a human-readable name for this layer. Used in logging and debugging.
@callback priority() :: non_neg_integer()
Return the priority order for this layer (lower = earlier). Used to determine layer execution order.
@callback process(input :: String.t(), context :: repair_context()) :: layer_result()
Process input string and apply layer-specific repairs.
Returns:
{:ok, processed_input, updated_context}
- Layer completed successfully{:continue, input, context}
- Layer doesn't apply, pass to next layer{:error, reason}
- Layer failed, stop pipeline
Check if this layer can handle the given input. Used for optimization and layer selection.
Validate layer configuration and options. Called during pipeline setup.
Functions
@spec inside_string?(input :: String.t(), position :: non_neg_integer()) :: boolean()
Check if a position in the input is inside a string literal. Used to avoid applying repairs to string content.