-module(lightspeed@ops@operations_kit). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/lightspeed/ops/operations_kit.gleam"). -export([canonical_runbooks/0, required_workflows/0, workflow_contract/1, workflow_plans/0, dashboards/0, drill_scenarios/0, runbook_valid/1, runbooks_cover_domains/0, workflow_contracts_safe/0, dashboards_cover_alert_contracts/0, drills_reproducible/0, operations_kit_ready/0, domain_label/1, workflow_label/1, runbook_signature/1, workflow_plan_signature/1, dashboard_signature/1, drill_signature/1, operations_kit_signature/0]). -export_type([domain/0, workflow_action/0, step/0, runbook/0, workflow_plan/0, alert_contract/0, dashboard/0, drill_scenario/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC(" Production app operations-kit contracts for M40.\n"). -type domain() :: runtime | transport | data | etl. -type workflow_action() :: rollout | rollback | drain | replay | recover. -type step() :: {step, binary(), binary(), binary(), boolean()}. -type runbook() :: {runbook, domain(), binary(), binary(), list(step())}. -type workflow_plan() :: {workflow_plan, workflow_action(), boolean(), boolean(), list(binary()), list(binary()), list(binary())}. -type alert_contract() :: {alert_contract, binary(), binary(), binary(), binary(), binary()}. -type dashboard() :: {dashboard, binary(), list(binary()), list(alert_contract())}. -type drill_scenario() :: {drill_scenario, binary(), domain(), workflow_action(), binary(), list(binary()), binary()}. -file("src/lightspeed/ops/operations_kit.gleam", 603). -spec etl_reliability_runbook() -> runbook(). etl_reliability_runbook() -> {runbook, etl, <<"etl_reliability"/utf8>>, <<"slo_budget_failure_or_poison_message_escalation"/utf8>>, [{step, <<"pause_affected_pipelines"/utf8>>, <<"Pause affected pipelines and capture backlog profile."/utf8>>, <<"audit.etl.pause"/utf8>>, true}, {step, <<"classify_failure_path"/utf8>>, <<"Classify outage, poison, replay, or schema fault class."/utf8>>, <<"audit.etl.classification"/utf8>>, false}, {step, <<"apply_recovery_strategy"/utf8>>, <<"Apply drain or replay strategy with checkpoint evidence."/utf8>>, <<"audit.etl.recovery_strategy"/utf8>>, true}, {step, <<"verify_slo_recovery"/utf8>>, <<"Verify lag, throughput, retry-rate, and replay SLO recovery."/utf8>>, <<"dashboard.etl.slo_recovery"/utf8>>, false}, {step, <<"resume_and_handoff"/utf8>>, <<"Resume flows and publish on-call handoff summary."/utf8>>, <<"audit.etl.handoff"/utf8>>, true}]}. -file("src/lightspeed/ops/operations_kit.gleam", 563). -spec data_integrity_runbook() -> runbook(). data_integrity_runbook() -> {runbook, data, <<"data_integrity"/utf8>>, <<"checkpoint_drift_or_schema_quality_failure"/utf8>>, [{step, <<"freeze_mutating_writes"/utf8>>, <<"Freeze mutating writes for affected streams."/utf8>>, <<"audit.data.freeze"/utf8>>, true}, {step, <<"select_replay_checkpoint"/utf8>>, <<"Select replay checkpoint and validate idempotency scope."/utf8>>, <<"audit.data.checkpoint"/utf8>>, true}, {step, <<"run_quality_guard"/utf8>>, <<"Run payload-quality and schema compatibility guards."/utf8>>, <<"audit.data.quality_guard"/utf8>>, false}, {step, <<"execute_replay"/utf8>>, <<"Replay affected windows with duplicate-sink suppression."/utf8>>, <<"audit.data.replay"/utf8>>, true}, {step, <<"thaw_writes"/utf8>>, <<"Thaw writes after deterministic reconciliation checks."/utf8>>, <<"audit.data.thaw"/utf8>>, true}]}. -file("src/lightspeed/ops/operations_kit.gleam", 523). -spec transport_degradation_runbook() -> runbook(). transport_degradation_runbook() -> {runbook, transport, <<"transport_degradation"/utf8>>, <<"ack_latency_or_receive_errors_over_budget"/utf8>>, [{step, <<"confirm_transport_profile"/utf8>>, <<"Confirm active transport profile and fallback state."/utf8>>, <<"audit.transport.profile"/utf8>>, false}, {step, <<"drain_high_risk_topics"/utf8>>, <<"Drain high-risk channels and freeze high-churn pushes."/utf8>>, <<"audit.transport.drain"/utf8>>, true}, {step, <<"activate_fallback_mode"/utf8>>, <<"Activate progressive fallback and rate controls."/utf8>>, <<"audit.transport.fallback"/utf8>>, true}, {step, <<"verify_ack_recovery"/utf8>>, <<"Verify p95 ack-latency and receive-error recovery."/utf8>>, <<"dashboard.transport.recovery"/utf8>>, false}, {step, <<"resume_normal_flow"/utf8>>, <<"Resume normal transport profile after guard checks."/utf8>>, <<"audit.transport.resume"/utf8>>, true}]}. -file("src/lightspeed/ops/operations_kit.gleam", 483). -spec runtime_incident_runbook() -> runbook(). runtime_incident_runbook() -> {runbook, runtime, <<"runtime_incident"/utf8>>, <<"crash_rate_or_heartbeat_timeout_spike"/utf8>>, [{step, <<"capture_release_fingerprint"/utf8>>, <<"Capture deploy digest and scope impacted sessions."/utf8>>, <<"audit.release.digest"/utf8>>, false}, {step, <<"enable_guardrails"/utf8>>, <<"Enable mitigation controls for high-risk routes."/utf8>>, <<"audit.runtime.guardrail_change"/utf8>>, true}, {step, <<"execute_safe_rollback"/utf8>>, <<"Rollback to last known good artifact with dual control."/utf8>>, <<"audit.runtime.rollback"/utf8>>, true}, {step, <<"verify_session_recovery"/utf8>>, <<"Verify reconnect and patch-ack recovery across canary set."/utf8>>, <<"trace.runtime.recovery"/utf8>>, false}, {step, <<"publish_handoff_summary"/utf8>>, <<"Publish incident timeline and next actions."/utf8>>, <<"audit.incident.handoff"/utf8>>, false}]}. -file("src/lightspeed/ops/operations_kit.gleam", 73). ?DOC(" Canonical M40 runbooks.\n"). -spec canonical_runbooks() -> list(runbook()). canonical_runbooks() -> [runtime_incident_runbook(), transport_degradation_runbook(), data_integrity_runbook(), etl_reliability_runbook()]. -file("src/lightspeed/ops/operations_kit.gleam", 83). ?DOC(" Required operator-safe workflows for M40.\n"). -spec required_workflows() -> list(workflow_action()). required_workflows() -> [rollout, rollback, drain, replay, recover]. -file("src/lightspeed/ops/operations_kit.gleam", 99). ?DOC(" Contract for one operator workflow.\n"). -spec workflow_contract(workflow_action()) -> workflow_plan(). workflow_contract(Action) -> case Action of rollout -> {workflow_plan, rollout, true, true, [<<"change_ticket_linked"/utf8>>, <<"canary_budget_green"/utf8>>, <<"rollback_artifact_ready"/utf8>>], [<<"operator_identity"/utf8>>, <<"approver_identity"/utf8>>, <<"artifact_digest"/utf8>>], [<<"synthetic_smoke_green"/utf8>>, <<"error_budget_guard_green"/utf8>>, <<"customer_path_sample_green"/utf8>>]}; rollback -> {workflow_plan, rollback, true, true, [<<"incident_ticket_linked"/utf8>>, <<"last_known_good_digest_available"/utf8>>, <<"data_migration_guard_confirmed"/utf8>>], [<<"operator_identity"/utf8>>, <<"rollback_reason"/utf8>>, <<"rollback_target_digest"/utf8>>], [<<"crash_rate_recovered"/utf8>>, <<"latency_budget_recovered"/utf8>>, <<"drift_gate_revalidated"/utf8>>]}; drain -> {workflow_plan, drain, true, true, [<<"backlog_depth_measured"/utf8>>, <<"downstream_sinks_healthy"/utf8>>, <<"replay_window_checkpointed"/utf8>>], [<<"operator_identity"/utf8>>, <<"drain_scope"/utf8>>, <<"checkpoint_revision"/utf8>>], [<<"in_flight_zero"/utf8>>, <<"queue_depth_flat"/utf8>>, <<"replay_window_consistent"/utf8>>]}; replay -> {workflow_plan, replay, true, true, [<<"checkpoint_revision_selected"/utf8>>, <<"payload_quality_gate_green"/utf8>>, <<"idempotency_keys_confirmed"/utf8>>], [<<"operator_identity"/utf8>>, <<"replay_start_checkpoint"/utf8>>, <<"replay_target_scope"/utf8>>], [<<"replay_completion_green"/utf8>>, <<"duplicate_sink_guard_green"/utf8>>, <<"etl_budget_recovered"/utf8>>]}; recover -> {workflow_plan, recover, true, true, [<<"incident_classified"/utf8>>, <<"safe_mode_controls_applied"/utf8>>, <<"communications_window_open"/utf8>>], [<<"operator_identity"/utf8>>, <<"recovery_strategy"/utf8>>, <<"timeline_reference"/utf8>>], [<<"all_alerts_acknowledged"/utf8>>, <<"runbook_followups_created"/utf8>>, <<"handoff_note_published"/utf8>>]} end. -file("src/lightspeed/ops/operations_kit.gleam", 88). ?DOC(" M40 workflow plans.\n"). -spec workflow_plans() -> list(workflow_plan()). workflow_plans() -> [workflow_contract(rollout), workflow_contract(rollback), workflow_contract(drain), workflow_contract(replay), workflow_contract(recover)]. -file("src/lightspeed/ops/operations_kit.gleam", 214). ?DOC(" Standardized M40 dashboards and alert contracts.\n"). -spec dashboards() -> list(dashboard()). dashboards() -> [{dashboard, <<"runtime_transport_baseline"/utf8>>, [<<"lightspeed.session.crashed_total"/utf8>>, <<"lightspeed.session.heartbeat_timeout_total"/utf8>>, <<"lightspeed.transport.receive.error_total"/utf8>>, <<"lightspeed.transport.ack_latency_p95_ms"/utf8>>], [{alert_contract, <<"lightspeed.session.crashed_total"/utf8>>, <<">=3"/utf8>>, <<"5m"/utf8>>, <<"page"/utf8>>, <<"runtime_incident"/utf8>>}, {alert_contract, <<"lightspeed.transport.ack_latency_p95_ms"/utf8>>, <<">=250"/utf8>>, <<"10m"/utf8>>, <<"ticket"/utf8>>, <<"transport_degradation"/utf8>>}]}, {dashboard, <<"data_pipeline_baseline"/utf8>>, [<<"lightspeed.pipeline.lag_ms"/utf8>>, <<"lightspeed.pipeline.retry_total"/utf8>>, <<"lightspeed.pipeline.dead_letter_total"/utf8>>, <<"lightspeed.pipeline.checkpoint_drift_total"/utf8>>], [{alert_contract, <<"lightspeed.pipeline.checkpoint_drift_total"/utf8>>, <<">=1"/utf8>>, <<"5m"/utf8>>, <<"page"/utf8>>, <<"data_integrity"/utf8>>}, {alert_contract, <<"lightspeed.pipeline.lag_ms"/utf8>>, <<">=120000"/utf8>>, <<"15m"/utf8>>, <<"ticket"/utf8>>, <<"etl_reliability"/utf8>>}]}, {dashboard, <<"etl_reliability_baseline"/utf8>>, [<<"lightspeed.etl.slo_budget_failures_total"/utf8>>, <<"lightspeed.etl.replay_recovery_ms"/utf8>>, <<"lightspeed.etl.poison_message_total"/utf8>>, <<"lightspeed.etl.schema_quality_failures_total"/utf8>>], [{alert_contract, <<"lightspeed.etl.slo_budget_failures_total"/utf8>>, <<">=1"/utf8>>, <<"5m"/utf8>>, <<"page"/utf8>>, <<"etl_reliability"/utf8>>}, {alert_contract, <<"lightspeed.etl.schema_quality_failures_total"/utf8>>, <<">=1"/utf8>>, <<"10m"/utf8>>, <<"ticket"/utf8>>, <<"data_integrity"/utf8>>}]}]. -file("src/lightspeed/ops/operations_kit.gleam", 295). ?DOC(" Deterministic M40 operations drills.\n"). -spec drill_scenarios() -> list(drill_scenario()). drill_scenarios() -> [{drill_scenario, <<"runtime_rollback_drill"/utf8>>, runtime, rollback, <<"runtime_incident"/utf8>>, [<<"audit.runtime.rollback.timeline"/utf8>>, <<"trace.runtime.recovery.span"/utf8>>, <<"dashboard.runtime_transport_baseline.snapshot"/utf8>>], <<"m40-runtime-rollback-001"/utf8>>}, {drill_scenario, <<"transport_drain_recover_drill"/utf8>>, transport, drain, <<"transport_degradation"/utf8>>, [<<"audit.transport.drain.timeline"/utf8>>, <<"queue.transport.backlog.snapshot"/utf8>>, <<"dashboard.runtime_transport_baseline.snapshot"/utf8>>], <<"m40-transport-drain-001"/utf8>>}, {drill_scenario, <<"data_replay_integrity_drill"/utf8>>, data, replay, <<"data_integrity"/utf8>>, [<<"audit.data.replay.timeline"/utf8>>, <<"checkpoint.data.replay.selection"/utf8>>, <<"dashboard.data_pipeline_baseline.snapshot"/utf8>>], <<"m40-data-replay-001"/utf8>>}, {drill_scenario, <<"etl_recovery_drill"/utf8>>, etl, recover, <<"etl_reliability"/utf8>>, [<<"audit.etl.recovery.timeline"/utf8>>, <<"slo.etl.budget.after_mitigation"/utf8>>, <<"dashboard.etl_reliability_baseline.snapshot"/utf8>>], <<"m40-etl-recovery-001"/utf8>>}]. -file("src/lightspeed/ops/operations_kit.gleam", 654). -spec has_reversible_step(list(step())) -> boolean(). has_reversible_step(Steps) -> case Steps of [] -> false; [Step | Rest] -> erlang:element(5, Step) orelse has_reversible_step(Rest) end. -file("src/lightspeed/ops/operations_kit.gleam", 643). -spec steps_valid(list(step())) -> boolean(). steps_valid(Steps) -> case Steps of [] -> true; [Step | Rest] -> (((erlang:element(2, Step) /= <<""/utf8>>) andalso (erlang:element( 3, Step ) /= <<""/utf8>>)) andalso (erlang:element(4, Step) /= <<""/utf8>>)) andalso steps_valid(Rest) end. -file("src/lightspeed/ops/operations_kit.gleam", 349). ?DOC(" Validate one runbook contract.\n"). -spec runbook_valid(runbook()) -> boolean(). runbook_valid(Runbook) -> ((((erlang:element(3, Runbook) /= <<""/utf8>>) andalso (erlang:element( 4, Runbook ) /= <<""/utf8>>)) andalso (erlang:length(erlang:element(5, Runbook)) >= 4)) andalso steps_valid(erlang:element(5, Runbook))) andalso has_reversible_step(erlang:element(5, Runbook)). -file("src/lightspeed/ops/operations_kit.gleam", 668). -spec all_runbooks_valid(list(runbook())) -> boolean(). all_runbooks_valid(Runbooks) -> case Runbooks of [] -> true; [Runbook | Rest] -> runbook_valid(Runbook) andalso all_runbooks_valid(Rest) end. -file("src/lightspeed/ops/operations_kit.gleam", 661). -spec has_domain(list(runbook()), domain()) -> boolean(). has_domain(Runbooks, Domain) -> case Runbooks of [] -> false; [Runbook | Rest] -> (erlang:element(2, Runbook) =:= Domain) orelse has_domain( Rest, Domain ) end. -file("src/lightspeed/ops/operations_kit.gleam", 358). ?DOC(" Validate M40 runbook-domain coverage.\n"). -spec runbooks_cover_domains() -> boolean(). runbooks_cover_domains() -> Runbooks = canonical_runbooks(), (((has_domain(Runbooks, runtime) andalso has_domain(Runbooks, transport)) andalso has_domain(Runbooks, data)) andalso has_domain(Runbooks, etl)) andalso all_runbooks_valid(Runbooks). -file("src/lightspeed/ops/operations_kit.gleam", 832). -spec string_entries_non_empty(list(binary())) -> boolean(). string_entries_non_empty(Values) -> case Values of [] -> true; [Value | Rest] -> (Value /= <<""/utf8>>) andalso string_entries_non_empty(Rest) end. -file("src/lightspeed/ops/operations_kit.gleam", 683). -spec workflow_plan_valid(workflow_plan()) -> boolean(). workflow_plan_valid(Plan) -> ((((((erlang:element(3, Plan) andalso erlang:element(4, Plan)) andalso (erlang:length( erlang:element(5, Plan) ) >= 3)) andalso (erlang:length(erlang:element(6, Plan)) >= 3)) andalso (erlang:length(erlang:element(7, Plan)) >= 3)) andalso string_entries_non_empty(erlang:element(5, Plan))) andalso string_entries_non_empty(erlang:element(6, Plan))) andalso string_entries_non_empty(erlang:element(7, Plan)). -file("src/lightspeed/ops/operations_kit.gleam", 675). -spec all_workflow_plans_valid(list(workflow_plan())) -> boolean(). all_workflow_plans_valid(Plans) -> case Plans of [] -> true; [Plan | Rest] -> workflow_plan_valid(Plan) andalso all_workflow_plans_valid(Rest) end. -file("src/lightspeed/ops/operations_kit.gleam", 368). ?DOC(" Validate operator-safe workflow contracts.\n"). -spec workflow_contracts_safe() -> boolean(). workflow_contracts_safe() -> _pipe = workflow_plans(), all_workflow_plans_valid(_pipe). -file("src/lightspeed/ops/operations_kit.gleam", 739). -spec has_runbook(list(runbook()), binary()) -> boolean(). has_runbook(Runbooks, Name) -> case Runbooks of [] -> false; [Runbook | Rest] -> (erlang:element(3, Runbook) =:= Name) orelse has_runbook(Rest, Name) end. -file("src/lightspeed/ops/operations_kit.gleam", 734). -spec known_runbook(binary()) -> boolean(). known_runbook(Name) -> _pipe = canonical_runbooks(), has_runbook(_pipe, Name). -file("src/lightspeed/ops/operations_kit.gleam", 730). -spec standard_window(binary()) -> boolean(). standard_window(Window) -> ((Window =:= <<"5m"/utf8>>) orelse (Window =:= <<"10m"/utf8>>)) orelse (Window =:= <<"15m"/utf8>>). -file("src/lightspeed/ops/operations_kit.gleam", 825). -spec has_string(list(binary()), binary()) -> boolean(). has_string(Values, Target) -> case Values of [] -> false; [Value | Rest] -> (Value =:= Target) orelse has_string(Rest, Target) end. -file("src/lightspeed/ops/operations_kit.gleam", 718). -spec alert_valid(alert_contract(), list(binary())) -> boolean(). alert_valid(Alert, Metrics) -> ((((((((erlang:element(2, Alert) /= <<""/utf8>>) andalso (erlang:element( 3, Alert ) /= <<""/utf8>>)) andalso (erlang:element(4, Alert) /= <<""/utf8>>)) andalso (erlang:element(5, Alert) /= <<""/utf8>>)) andalso (erlang:element(6, Alert) /= <<""/utf8>>)) andalso has_string(Metrics, erlang:element(2, Alert))) andalso ((erlang:element(5, Alert) =:= <<"page"/utf8>>) orelse (erlang:element( 5, Alert ) =:= <<"ticket"/utf8>>))) andalso standard_window(erlang:element(4, Alert))) andalso known_runbook(erlang:element(6, Alert)). -file("src/lightspeed/ops/operations_kit.gleam", 710). -spec alerts_valid(list(alert_contract()), list(binary())) -> boolean(). alerts_valid(Alerts, Metrics) -> case Alerts of [] -> true; [Alert | Rest] -> alert_valid(Alert, Metrics) andalso alerts_valid(Rest, Metrics) end. -file("src/lightspeed/ops/operations_kit.gleam", 702). -spec dashboard_valid(dashboard()) -> boolean(). dashboard_valid(Contract) -> ((((erlang:element(2, Contract) /= <<""/utf8>>) andalso (erlang:length( erlang:element(3, Contract) ) >= 4)) andalso (erlang:length(erlang:element(4, Contract)) >= 2)) andalso string_entries_non_empty(erlang:element(3, Contract))) andalso alerts_valid( erlang:element(4, Contract), erlang:element(3, Contract) ). -file("src/lightspeed/ops/operations_kit.gleam", 694). -spec all_dashboards_valid(list(dashboard())) -> boolean(). all_dashboards_valid(Contracts) -> case Contracts of [] -> true; [Contract | Rest] -> dashboard_valid(Contract) andalso all_dashboards_valid(Rest) end. -file("src/lightspeed/ops/operations_kit.gleam", 374). ?DOC(" Validate dashboard + alert contracts.\n"). -spec dashboards_cover_alert_contracts() -> boolean(). dashboards_cover_alert_contracts() -> Contracts = dashboards(), (erlang:length(Contracts) >= 3) andalso all_dashboards_valid(Contracts). -file("src/lightspeed/ops/operations_kit.gleam", 814). -spec unique_strings_loop(list(binary()), list(binary())) -> boolean(). unique_strings_loop(Values, Seen) -> case Values of [] -> true; [Value | Rest] -> case has_string(Seen, Value) of true -> false; false -> unique_strings_loop(Rest, [Value | Seen]) end end. -file("src/lightspeed/ops/operations_kit.gleam", 810). -spec unique_strings(list(binary())) -> boolean(). unique_strings(Values) -> unique_strings_loop(Values, []). -file("src/lightspeed/ops/operations_kit.gleam", 800). -spec collect_drill_seeds(list(drill_scenario()), list(binary())) -> list(binary()). collect_drill_seeds(Drills, Acc) -> case Drills of [] -> lists:reverse(Acc); [Drill | Rest] -> collect_drill_seeds(Rest, [erlang:element(7, Drill) | Acc]) end. -file("src/lightspeed/ops/operations_kit.gleam", 784). -spec unique_drill_seeds(list(drill_scenario())) -> boolean(). unique_drill_seeds(Drills) -> _pipe = Drills, _pipe@1 = collect_drill_seeds(_pipe, []), unique_strings(_pipe@1). -file("src/lightspeed/ops/operations_kit.gleam", 790). -spec collect_drill_names(list(drill_scenario()), list(binary())) -> list(binary()). collect_drill_names(Drills, Acc) -> case Drills of [] -> lists:reverse(Acc); [Drill | Rest] -> collect_drill_names(Rest, [erlang:element(2, Drill) | Acc]) end. -file("src/lightspeed/ops/operations_kit.gleam", 778). -spec unique_drill_names(list(drill_scenario())) -> boolean(). unique_drill_names(Drills) -> _pipe = Drills, _pipe@1 = collect_drill_names(_pipe, []), unique_strings(_pipe@1). -file("src/lightspeed/ops/operations_kit.gleam", 768). -spec has_workflow(list(workflow_action()), workflow_action()) -> boolean(). has_workflow(Workflows, Action) -> case Workflows of [] -> false; [Workflow | Rest] -> (Workflow =:= Action) orelse has_workflow(Rest, Action) end. -file("src/lightspeed/ops/operations_kit.gleam", 763). -spec required_workflow(workflow_action()) -> boolean(). required_workflow(Action) -> _pipe = required_workflows(), has_workflow(_pipe, Action). -file("src/lightspeed/ops/operations_kit.gleam", 753). -spec drill_valid(drill_scenario()) -> boolean(). drill_valid(Drill) -> ((((((erlang:element(2, Drill) /= <<""/utf8>>) andalso (erlang:element( 5, Drill ) /= <<""/utf8>>)) andalso (erlang:element(7, Drill) /= <<""/utf8>>)) andalso (erlang:length(erlang:element(6, Drill)) >= 3)) andalso string_entries_non_empty(erlang:element(6, Drill))) andalso known_runbook(erlang:element(5, Drill))) andalso required_workflow(erlang:element(4, Drill)). -file("src/lightspeed/ops/operations_kit.gleam", 746). -spec all_drills_valid(list(drill_scenario())) -> boolean(). all_drills_valid(Drills) -> case Drills of [] -> true; [Drill | Rest] -> drill_valid(Drill) andalso all_drills_valid(Rest) end. -file("src/lightspeed/ops/operations_kit.gleam", 380). ?DOC(" Validate deterministic and reproducible drill contracts.\n"). -spec drills_reproducible() -> boolean(). drills_reproducible() -> Drills = drill_scenarios(), (((erlang:length(Drills) >= 4) andalso all_drills_valid(Drills)) andalso unique_drill_names( Drills )) andalso unique_drill_seeds(Drills). -file("src/lightspeed/ops/operations_kit.gleam", 389). ?DOC(" Full M40 readiness guard.\n"). -spec operations_kit_ready() -> boolean(). operations_kit_ready() -> ((runbooks_cover_domains() andalso workflow_contracts_safe()) andalso dashboards_cover_alert_contracts( )) andalso drills_reproducible(). -file("src/lightspeed/ops/operations_kit.gleam", 397). ?DOC(" Domain label.\n"). -spec domain_label(domain()) -> binary(). domain_label(Domain) -> case Domain of runtime -> <<"runtime"/utf8>>; transport -> <<"transport"/utf8>>; data -> <<"data"/utf8>>; etl -> <<"etl"/utf8>> end. -file("src/lightspeed/ops/operations_kit.gleam", 407). ?DOC(" Workflow label.\n"). -spec workflow_label(workflow_action()) -> binary(). workflow_label(Action) -> case Action of rollout -> <<"rollout"/utf8>>; rollback -> <<"rollback"/utf8>>; drain -> <<"drain"/utf8>>; replay -> <<"replay"/utf8>>; recover -> <<"recover"/utf8>> end. -file("src/lightspeed/ops/operations_kit.gleam", 867). -spec bool_label(boolean()) -> binary(). bool_label(Value) -> case Value of true -> <<"true"/utf8>>; false -> <<"false"/utf8>> end. -file("src/lightspeed/ops/operations_kit.gleam", 839). -spec step_signature(step()) -> binary(). step_signature(Step) -> <<<<<<<<(erlang:element(2, Step))/binary, ":reversible="/utf8>>/binary, (bool_label(erlang:element(5, Step)))/binary>>/binary, ":evidence="/utf8>>/binary, (erlang:element(4, Step))/binary>>. -file("src/lightspeed/ops/operations_kit.gleam", 859). -spec join_with(binary(), list(binary())) -> binary(). join_with(Separator, Values) -> case Values of [] -> <<""/utf8>>; [Value] -> Value; [Value@1 | Rest] -> <<<>/binary, (join_with(Separator, Rest))/binary>> end. -file("src/lightspeed/ops/operations_kit.gleam", 418). ?DOC(" Stable runbook signature.\n"). -spec runbook_signature(runbook()) -> binary(). runbook_signature(Runbook) -> <<<<<<<<<<<<<<"runbook:"/utf8, (domain_label(erlang:element(2, Runbook)))/binary>>/binary, ":"/utf8>>/binary, (erlang:element(3, Runbook))/binary>>/binary, "|trigger="/utf8>>/binary, (erlang:element(4, Runbook))/binary>>/binary, "|steps="/utf8>>/binary, (join_with( <<";"/utf8>>, gleam@list:map(erlang:element(5, Runbook), fun step_signature/1) ))/binary>>. -file("src/lightspeed/ops/operations_kit.gleam", 430). ?DOC(" Stable workflow-plan signature.\n"). -spec workflow_plan_signature(workflow_plan()) -> binary(). workflow_plan_signature(Plan) -> <<<<<<<<<<<<<<<<<<<<<<"workflow:"/utf8, (workflow_label( erlang:element(2, Plan) ))/binary>>/binary, "|dual_control="/utf8>>/binary, (bool_label(erlang:element(3, Plan)))/binary>>/binary, "|reversible="/utf8>>/binary, (bool_label(erlang:element(4, Plan)))/binary>>/binary, "|preflight="/utf8>>/binary, (join_with(<<","/utf8>>, erlang:element(5, Plan)))/binary>>/binary, "|audit="/utf8>>/binary, (join_with(<<","/utf8>>, erlang:element(6, Plan)))/binary>>/binary, "|post="/utf8>>/binary, (join_with(<<","/utf8>>, erlang:element(7, Plan)))/binary>>. -file("src/lightspeed/ops/operations_kit.gleam", 847). -spec alert_signature(alert_contract()) -> binary(). alert_signature(Alert) -> <<<<<<<<<<<<<<<<(erlang:element(2, Alert))/binary, ":threshold="/utf8>>/binary, (erlang:element(3, Alert))/binary>>/binary, ":window="/utf8>>/binary, (erlang:element(4, Alert))/binary>>/binary, ":severity="/utf8>>/binary, (erlang:element(5, Alert))/binary>>/binary, ":runbook="/utf8>>/binary, (erlang:element(6, Alert))/binary>>. -file("src/lightspeed/ops/operations_kit.gleam", 446). ?DOC(" Stable dashboard signature.\n"). -spec dashboard_signature(dashboard()) -> binary(). dashboard_signature(Dashboard) -> <<<<<<<<<<"dashboard:"/utf8, (erlang:element(2, Dashboard))/binary>>/binary, "|metrics="/utf8>>/binary, (join_with(<<","/utf8>>, erlang:element(3, Dashboard)))/binary>>/binary, "|alerts="/utf8>>/binary, (join_with( <<";"/utf8>>, gleam@list:map(erlang:element(4, Dashboard), fun alert_signature/1) ))/binary>>. -file("src/lightspeed/ops/operations_kit.gleam", 456). ?DOC(" Stable drill signature.\n"). -spec drill_signature(drill_scenario()) -> binary(). drill_signature(Drill) -> <<<<<<<<<<<<<<<<<<<<<<"drill:"/utf8, (erlang:element(2, Drill))/binary>>/binary, "|domain="/utf8>>/binary, (domain_label(erlang:element(3, Drill)))/binary>>/binary, "|workflow="/utf8>>/binary, (workflow_label(erlang:element(4, Drill)))/binary>>/binary, "|runbook="/utf8>>/binary, (erlang:element(5, Drill))/binary>>/binary, "|seed="/utf8>>/binary, (erlang:element(7, Drill))/binary>>/binary, "|evidence="/utf8>>/binary, (join_with(<<","/utf8>>, erlang:element(6, Drill)))/binary>>. -file("src/lightspeed/ops/operations_kit.gleam", 472). ?DOC(" Stable full-kit signature for deterministic M40 fixtures.\n"). -spec operations_kit_signature() -> binary(). operations_kit_signature() -> <<<<<<<<<<<<<<"runbooks="/utf8, (join_with( <<";"/utf8>>, gleam@list:map( canonical_runbooks(), fun runbook_signature/1 ) ))/binary>>/binary, "|workflows="/utf8>>/binary, (join_with( <<";"/utf8>>, gleam@list:map( workflow_plans(), fun workflow_plan_signature/1 ) ))/binary>>/binary, "|dashboards="/utf8>>/binary, (join_with( <<";"/utf8>>, gleam@list:map(dashboards(), fun dashboard_signature/1) ))/binary>>/binary, "|drills="/utf8>>/binary, (join_with( <<";"/utf8>>, gleam@list:map(drill_scenarios(), fun drill_signature/1) ))/binary>>.