src/lightspeed@tooling@developer_productivity.erl

-module(lightspeed@tooling@developer_productivity).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/lightspeed/tooling/developer_productivity.gleam").
-export([profile_version_label/0, default_suite/0, monorepo_suite/0, plugin_suite/0, reference_suites/0, name/1, diagnostics/1, profiling/1, quality_gates/1, refactor_workflows/1, editor_diagnostics/1, navigation_contracts/1, diagnostics_domain_label/1, profiling_dimension_label/1, diagnostics_signature/1, profiling_signature/1, quality_gate_signature/1, patch_churn_reduction_percent/1, refactor_workflow_signature/1, editor_diagnostic_signature/1, navigation_signature/1, diagnosable_without_custom_instrumentation/1, workflows_reduce_patch_churn/1, supports_editor_navigation/1, stable_quality_signals/1, valid_suite/1, signature/1, fixture_snapshots/0, snapshot_signature/0]).
-export_type([diagnostics_domain/0, runtime_diagnostics_surface/0, profiling_dimension/0, profiling_surface/0, tooling_quality_gate/0, refactor_workflow/0, editor_diagnostic_contract/0, navigation_contract/0, productivity_suite/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(" Developer tooling polish and productivity contracts for M59.\n").

-type diagnostics_domain() :: session_diagnostics |
    event_diagnostics |
    diff_diagnostics |
    transport_diagnostics.

-type runtime_diagnostics_surface() :: {runtime_diagnostics_surface,
        diagnostics_domain(),
        binary(),
        list(binary()),
        binary(),
        boolean()}.

-type profiling_dimension() :: latency_hotspot |
    allocation_hotspot |
    render_hotspot.

-type profiling_surface() :: {profiling_surface,
        profiling_dimension(),
        binary(),
        binary(),
        binary(),
        boolean()}.

-type tooling_quality_gate() :: {tooling_quality_gate,
        binary(),
        binary(),
        binary(),
        boolean()}.

-type refactor_workflow() :: {refactor_workflow,
        binary(),
        integer(),
        integer(),
        list(binary()),
        boolean()}.

-type editor_diagnostic_contract() :: {editor_diagnostic_contract,
        binary(),
        binary(),
        binary(),
        binary(),
        binary()}.

-type navigation_contract() :: {navigation_contract,
        binary(),
        binary(),
        binary(),
        binary()}.

-type productivity_suite() :: {productivity_suite,
        binary(),
        list(runtime_diagnostics_surface()),
        list(profiling_surface()),
        list(tooling_quality_gate()),
        list(refactor_workflow()),
        list(editor_diagnostic_contract()),
        list(navigation_contract())}.

-file("src/lightspeed/tooling/developer_productivity.gleam", 102).
?DOC(" Stable M59 profile version label.\n").
-spec profile_version_label() -> binary().
profile_version_label() ->
    <<"m59.profile.v"/utf8, (erlang:integer_to_binary(1))/binary>>.

-file("src/lightspeed/tooling/developer_productivity.gleam", 572).
-spec default_navigation_contracts() -> list(navigation_contract()).
default_navigation_contracts() ->
    [{navigation_contract,
            <<"lightspeed/transport/matrix"/utf8>>,
            <<"validate_transition_order"/utf8>>,
            <<"src/lightspeed/transport/matrix.gleam"/utf8>>,
            <<"jump_to_symbol"/utf8>>},
        {navigation_contract,
            <<"lightspeed/component/template_ergonomics"/utf8>>,
            <<"apply_keyed_hint"/utf8>>,
            <<"src/lightspeed/component/template_ergonomics.gleam"/utf8>>,
            <<"jump_to_symbol"/utf8>>},
        {navigation_contract,
            <<"lightspeed/tooling/generator"/utf8>>,
            <<"validate_scaffold_quality"/utf8>>,
            <<"src/lightspeed/tooling/generator.gleam"/utf8>>,
            <<"jump_to_symbol"/utf8>>}].

-file("src/lightspeed/tooling/developer_productivity.gleam", 546).
-spec default_editor_diagnostics() -> list(editor_diagnostic_contract()).
default_editor_diagnostics() ->
    [{editor_diagnostic_contract,
            <<"LS5901"/utf8>>,
            <<"warning"/utf8>>,
            <<"lightspeed/transport/matrix"/utf8>>,
            <<"stabilize transition ordering helper"/utf8>>,
            <<"validate_transition_order"/utf8>>},
        {editor_diagnostic_contract,
            <<"LS5902"/utf8>>,
            <<"error"/utf8>>,
            <<"lightspeed/component/template_ergonomics"/utf8>>,
            <<"replace broad selector with keyed node lookup"/utf8>>,
            <<"apply_keyed_hint"/utf8>>},
        {editor_diagnostic_contract,
            <<"LS5903"/utf8>>,
            <<"warning"/utf8>>,
            <<"lightspeed/tooling/generator"/utf8>>,
            <<"regenerate scaffold with deterministic lint profile"/utf8>>,
            <<"validate_scaffold_quality"/utf8>>}].

-file("src/lightspeed/tooling/developer_productivity.gleam", 520).
-spec default_refactor_workflows() -> list(refactor_workflow()).
default_refactor_workflows() ->
    [{refactor_workflow,
            <<"extract_event_dispatch_path"/utf8>>,
            142,
            88,
            [<<"make generator-fixture-gate"/utf8>>,
                <<"make hot-path-fixture-gate"/utf8>>,
                <<"make protocol-contract-fixture-gate"/utf8>>],
            true},
        {refactor_workflow,
            <<"stabilize_template_diff_helpers"/utf8>>,
            110,
            66,
            [<<"make render-churn-fixture-gate"/utf8>>,
                <<"make template-ergonomics-fixture-gate"/utf8>>],
            true}].

-file("src/lightspeed/tooling/developer_productivity.gleam", 497).
-spec default_quality_gates() -> list(tooling_quality_gate()).
default_quality_gates() ->
    [{tooling_quality_gate,
            <<"generator_quality_gate"/utf8>>,
            <<"make generator-fixture-gate"/utf8>>,
            <<"m25.snapshot.v"/utf8>>,
            true},
        {tooling_quality_gate,
            <<"hot_path_quality_gate"/utf8>>,
            <<"make hot-path-fixture-gate"/utf8>>,
            <<"m35.snapshot.v"/utf8>>,
            true},
        {tooling_quality_gate,
            <<"render_churn_quality_gate"/utf8>>,
            <<"make render-churn-fixture-gate"/utf8>>,
            <<"m36.snapshot.v"/utf8>>,
            true}].

-file("src/lightspeed/tooling/developer_productivity.gleam", 471).
-spec default_profiling_surfaces() -> list(profiling_surface()).
default_profiling_surfaces() ->
    [{profiling_surface,
            latency_hotspot,
            <<"make hot-path-fixture-gate"/utf8>>,
            <<"p95_event_latency_ms<=75"/utf8>>,
            <<"use hot-path snapshots to localize latency drift"/utf8>>,
            true},
        {profiling_surface,
            allocation_hotspot,
            <<"make perf-report"/utf8>>,
            <<"session_memory_units<=2200"/utf8>>,
            <<"use performance report allocations to reduce transient buffers"/utf8>>,
            true},
        {profiling_surface,
            render_hotspot,
            <<"make render-churn-fixture-gate"/utf8>>,
            <<"root_churn_total<=2"/utf8>>,
            <<"use render-churn signatures to reduce root replacement churn"/utf8>>,
            true}].

-file("src/lightspeed/tooling/developer_productivity.gleam", 432).
-spec default_runtime_diagnostics() -> list(runtime_diagnostics_surface()).
default_runtime_diagnostics() ->
    [{runtime_diagnostics_surface,
            session_diagnostics,
            <<"make load-fixture-gate"/utf8>>,
            [<<"session_lifecycle_transition_failures"/utf8>>,
                <<"session_reconnect_drift"/utf8>>],
            <<"review runtime/session signatures and lifecycle transitions"/utf8>>,
            false},
        {runtime_diagnostics_surface,
            event_diagnostics,
            <<"make protocol-contract-fixture-gate"/utf8>>,
            [<<"event_order_violation"/utf8>>,
                <<"event_codec_contract_regression"/utf8>>],
            <<"review protocol/event matrix and replay evidence signatures"/utf8>>,
            false},
        {runtime_diagnostics_surface,
            diff_diagnostics,
            <<"make render-churn-fixture-gate"/utf8>>,
            [<<"root_churn_regression"/utf8>>, <<"patch_volume_spike"/utf8>>],
            <<"review keyed diff boundaries and render churn counters"/utf8>>,
            false},
        {runtime_diagnostics_surface,
            transport_diagnostics,
            <<"make transport-expansion-fixture-gate"/utf8>>,
            [<<"fallback_transition_regression"/utf8>>,
                <<"reconnect_mode_drift"/utf8>>],
            <<"review transport capability negotiation and reconnect signatures"/utf8>>,
            false}].

-file("src/lightspeed/tooling/developer_productivity.gleam", 107).
?DOC(" Default developer tooling suite.\n").
-spec default_suite() -> productivity_suite().
default_suite() ->
    {productivity_suite,
        <<"default_productivity"/utf8>>,
        default_runtime_diagnostics(),
        default_profiling_surfaces(),
        default_quality_gates(),
        default_refactor_workflows(),
        default_editor_diagnostics(),
        default_navigation_contracts()}.

-file("src/lightspeed/tooling/developer_productivity.gleam", 120).
?DOC(" Monorepo-focused suite.\n").
-spec monorepo_suite() -> productivity_suite().
monorepo_suite() ->
    {productivity_suite,
        <<"monorepo_productivity"/utf8>>,
        default_runtime_diagnostics(),
        default_profiling_surfaces(),
        default_quality_gates(),
        [{refactor_workflow,
                <<"extract_transport_validation"/utf8>>,
                180,
                112,
                [<<"make generator-fixture-gate"/utf8>>,
                    <<"make hot-path-fixture-gate"/utf8>>,
                    <<"make render-churn-fixture-gate"/utf8>>],
                true},
            {refactor_workflow,
                <<"normalize_template_diagnostics"/utf8>>,
                120,
                78,
                [<<"make generator-fixture-gate"/utf8>>,
                    <<"make template-ergonomics-fixture-gate"/utf8>>,
                    <<"make render-churn-fixture-gate"/utf8>>],
                true}],
        default_editor_diagnostics(),
        default_navigation_contracts()}.

-file("src/lightspeed/tooling/developer_productivity.gleam", 156).
?DOC(" Plugin-heavy suite.\n").
-spec plugin_suite() -> productivity_suite().
plugin_suite() ->
    {productivity_suite,
        <<"plugin_productivity"/utf8>>,
        default_runtime_diagnostics(),
        default_profiling_surfaces(),
        default_quality_gates(),
        [{refactor_workflow,
                <<"plugin_registry_refactor"/utf8>>,
                96,
                60,
                [<<"make generator-fixture-gate"/utf8>>,
                    <<"make hot-path-fixture-gate"/utf8>>],
                true},
            {refactor_workflow,
                <<"editor_navigation_hint_refactor"/utf8>>,
                84,
                52,
                [<<"make protocol-contract-fixture-gate"/utf8>>,
                    <<"make render-churn-fixture-gate"/utf8>>],
                true}],
        default_editor_diagnostics(),
        default_navigation_contracts()}.

-file("src/lightspeed/tooling/developer_productivity.gleam", 190).
?DOC(" Deterministic M59 reference suites.\n").
-spec reference_suites() -> list(productivity_suite()).
reference_suites() ->
    [default_suite(), monorepo_suite(), plugin_suite()].

-file("src/lightspeed/tooling/developer_productivity.gleam", 195).
?DOC(" Suite name accessor.\n").
-spec name(productivity_suite()) -> binary().
name(Suite) ->
    erlang:element(2, Suite).

-file("src/lightspeed/tooling/developer_productivity.gleam", 200).
?DOC(" Diagnostics accessor.\n").
-spec diagnostics(productivity_suite()) -> list(runtime_diagnostics_surface()).
diagnostics(Suite) ->
    erlang:element(3, Suite).

-file("src/lightspeed/tooling/developer_productivity.gleam", 207).
?DOC(" Profiling accessor.\n").
-spec profiling(productivity_suite()) -> list(profiling_surface()).
profiling(Suite) ->
    erlang:element(4, Suite).

-file("src/lightspeed/tooling/developer_productivity.gleam", 212).
?DOC(" Quality-gates accessor.\n").
-spec quality_gates(productivity_suite()) -> list(tooling_quality_gate()).
quality_gates(Suite) ->
    erlang:element(5, Suite).

-file("src/lightspeed/tooling/developer_productivity.gleam", 217).
?DOC(" Refactor-workflows accessor.\n").
-spec refactor_workflows(productivity_suite()) -> list(refactor_workflow()).
refactor_workflows(Suite) ->
    erlang:element(6, Suite).

-file("src/lightspeed/tooling/developer_productivity.gleam", 222).
?DOC(" Editor-diagnostics accessor.\n").
-spec editor_diagnostics(productivity_suite()) -> list(editor_diagnostic_contract()).
editor_diagnostics(Suite) ->
    erlang:element(7, Suite).

-file("src/lightspeed/tooling/developer_productivity.gleam", 229).
?DOC(" Navigation-contract accessor.\n").
-spec navigation_contracts(productivity_suite()) -> list(navigation_contract()).
navigation_contracts(Suite) ->
    erlang:element(8, Suite).

-file("src/lightspeed/tooling/developer_productivity.gleam", 236).
?DOC(" Diagnostics domain label.\n").
-spec diagnostics_domain_label(diagnostics_domain()) -> binary().
diagnostics_domain_label(Domain) ->
    case Domain of
        session_diagnostics ->
            <<"session"/utf8>>;

        event_diagnostics ->
            <<"event"/utf8>>;

        diff_diagnostics ->
            <<"diff"/utf8>>;

        transport_diagnostics ->
            <<"transport"/utf8>>
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 246).
?DOC(" Profiling dimension label.\n").
-spec profiling_dimension_label(profiling_dimension()) -> binary().
profiling_dimension_label(Dimension) ->
    case Dimension of
        latency_hotspot ->
            <<"latency"/utf8>>;

        allocation_hotspot ->
            <<"allocation"/utf8>>;

        render_hotspot ->
            <<"render"/utf8>>
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 748).
-spec bool_label(boolean()) -> binary().
bool_label(Value) ->
    case Value of
        true ->
            <<"true"/utf8>>;

        false ->
            <<"false"/utf8>>
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 755).
-spec join_with(binary(), list(binary())) -> binary().
join_with(Separator, Values) ->
    case Values of
        [] ->
            <<""/utf8>>;

        [First | Rest] ->
            gleam@list:fold(
                Rest,
                First,
                fun(Accumulator, Value) ->
                    <<<<Accumulator/binary, Separator/binary>>/binary,
                        Value/binary>>
                end
            )
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 255).
?DOC(" Stable diagnostics-surface signature.\n").
-spec diagnostics_signature(runtime_diagnostics_surface()) -> binary().
diagnostics_signature(Surface) ->
    <<<<<<<<<<<<(diagnostics_domain_label(erlang:element(2, Surface)))/binary,
                            ":command="/utf8>>/binary,
                        (erlang:element(3, Surface))/binary>>/binary,
                    ":signals="/utf8>>/binary,
                (join_with(<<","/utf8>>, erlang:element(4, Surface)))/binary>>/binary,
            ":custom_instrumentation="/utf8>>/binary,
        (bool_label(erlang:element(6, Surface)))/binary>>.

-file("src/lightspeed/tooling/developer_productivity.gleam", 266).
?DOC(" Stable profiling-surface signature.\n").
-spec profiling_signature(profiling_surface()) -> binary().
profiling_signature(Surface) ->
    <<<<<<<<<<<<(profiling_dimension_label(erlang:element(2, Surface)))/binary,
                            ":command="/utf8>>/binary,
                        (erlang:element(3, Surface))/binary>>/binary,
                    ":budget="/utf8>>/binary,
                (erlang:element(4, Surface))/binary>>/binary,
            ":deterministic="/utf8>>/binary,
        (bool_label(erlang:element(6, Surface)))/binary>>.

-file("src/lightspeed/tooling/developer_productivity.gleam", 277).
?DOC(" Stable quality-gate signature.\n").
-spec quality_gate_signature(tooling_quality_gate()) -> binary().
quality_gate_signature(Gate) ->
    <<<<<<<<<<<<(erlang:element(2, Gate))/binary, ":command="/utf8>>/binary,
                        (erlang:element(3, Gate))/binary>>/binary,
                    ":snapshot_prefix="/utf8>>/binary,
                (erlang:element(4, Gate))/binary>>/binary,
            ":deterministic="/utf8>>/binary,
        (bool_label(erlang:element(5, Gate)))/binary>>.

-file("src/lightspeed/tooling/developer_productivity.gleam", 327).
?DOC(" Patch-churn reduction percentage for one workflow.\n").
-spec patch_churn_reduction_percent(refactor_workflow()) -> integer().
patch_churn_reduction_percent(Workflow) ->
    case erlang:element(3, Workflow) =< 0 of
        true ->
            0;

        false ->
            Reduced = erlang:element(3, Workflow) - erlang:element(4, Workflow),
            case Reduced =< 0 of
                true ->
                    0;

                false ->
                    case erlang:element(3, Workflow) of
                        0 -> 0;
                        Gleam@denominator -> Reduced * 100 div Gleam@denominator
                    end
            end
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 288).
?DOC(" Stable refactor-workflow signature.\n").
-spec refactor_workflow_signature(refactor_workflow()) -> binary().
refactor_workflow_signature(Workflow) ->
    <<<<<<<<<<<<<<<<<<<<(erlang:element(2, Workflow))/binary,
                                            ":baseline="/utf8>>/binary,
                                        (erlang:integer_to_binary(
                                            erlang:element(3, Workflow)
                                        ))/binary>>/binary,
                                    ":polished="/utf8>>/binary,
                                (erlang:integer_to_binary(
                                    erlang:element(4, Workflow)
                                ))/binary>>/binary,
                            ":reduction="/utf8>>/binary,
                        (erlang:integer_to_binary(
                            patch_churn_reduction_percent(Workflow)
                        ))/binary>>/binary,
                    "%:gates="/utf8>>/binary,
                (join_with(<<","/utf8>>, erlang:element(5, Workflow)))/binary>>/binary,
            ":deterministic="/utf8>>/binary,
        (bool_label(erlang:element(6, Workflow)))/binary>>.

-file("src/lightspeed/tooling/developer_productivity.gleam", 303).
?DOC(" Stable editor-diagnostic signature.\n").
-spec editor_diagnostic_signature(editor_diagnostic_contract()) -> binary().
editor_diagnostic_signature(Contract) ->
    <<<<<<<<<<<<(erlang:element(2, Contract))/binary, ":"/utf8>>/binary,
                        (erlang:element(3, Contract))/binary>>/binary,
                    ":module="/utf8>>/binary,
                (erlang:element(4, Contract))/binary>>/binary,
            ":symbol="/utf8>>/binary,
        (erlang:element(6, Contract))/binary>>.

-file("src/lightspeed/tooling/developer_productivity.gleam", 316).
?DOC(" Stable navigation-contract signature.\n").
-spec navigation_signature(navigation_contract()) -> binary().
navigation_signature(Contract) ->
    <<<<<<<<<<<<(erlang:element(2, Contract))/binary, ":"/utf8>>/binary,
                        (erlang:element(3, Contract))/binary>>/binary,
                    ":path="/utf8>>/binary,
                (erlang:element(4, Contract))/binary>>/binary,
            ":command="/utf8>>/binary,
        (erlang:element(5, Contract))/binary>>.

-file("src/lightspeed/tooling/developer_productivity.gleam", 651).
-spec profiling_actionable(list(profiling_surface())) -> boolean().
profiling_actionable(Profiling) ->
    case Profiling of
        [] ->
            true;

        [Surface | Rest] ->
            ((((erlang:element(3, Surface) /= <<""/utf8>>) andalso (erlang:element(
                4,
                Surface
            )
            /= <<""/utf8>>))
            andalso (erlang:element(5, Surface) /= <<""/utf8>>))
            andalso erlang:element(6, Surface))
            andalso profiling_actionable(Rest)
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 637).
-spec has_profiling_dimension(list(profiling_surface()), profiling_dimension()) -> boolean().
has_profiling_dimension(Profiling, Dimension) ->
    case Profiling of
        [] ->
            false;

        [Surface | Rest] ->
            case erlang:element(2, Surface) =:= Dimension of
                true ->
                    true;

                false ->
                    has_profiling_dimension(Rest, Dimension)
            end
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 631).
-spec profiling_dimensions_coverage(list(profiling_surface())) -> boolean().
profiling_dimensions_coverage(Profiling) ->
    (has_profiling_dimension(Profiling, latency_hotspot) andalso has_profiling_dimension(
        Profiling,
        allocation_hotspot
    ))
    andalso has_profiling_dimension(Profiling, render_hotspot).

-file("src/lightspeed/tooling/developer_productivity.gleam", 618).
-spec diagnostics_deterministic(list(runtime_diagnostics_surface())) -> boolean().
diagnostics_deterministic(Diagnostics) ->
    case Diagnostics of
        [] ->
            true;

        [Surface | Rest] ->
            (((erlang:element(3, Surface) /= <<""/utf8>>) andalso (erlang:element(
                4,
                Surface
            )
            /= []))
            andalso not erlang:element(6, Surface))
            andalso diagnostics_deterministic(Rest)
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 604).
-spec has_diagnostics_domain(
    list(runtime_diagnostics_surface()),
    diagnostics_domain()
) -> boolean().
has_diagnostics_domain(Diagnostics, Domain) ->
    case Diagnostics of
        [] ->
            false;

        [Surface | Rest] ->
            case erlang:element(2, Surface) =:= Domain of
                true ->
                    true;

                false ->
                    has_diagnostics_domain(Rest, Domain)
            end
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 595).
-spec diagnostics_domain_coverage(list(runtime_diagnostics_surface())) -> boolean().
diagnostics_domain_coverage(Diagnostics) ->
    ((has_diagnostics_domain(Diagnostics, session_diagnostics) andalso has_diagnostics_domain(
        Diagnostics,
        event_diagnostics
    ))
    andalso has_diagnostics_domain(Diagnostics, diff_diagnostics))
    andalso has_diagnostics_domain(Diagnostics, transport_diagnostics).

-file("src/lightspeed/tooling/developer_productivity.gleam", 343).
?DOC(" True when runtime/performance issues are diagnosable without custom instrumentation.\n").
-spec diagnosable_without_custom_instrumentation(productivity_suite()) -> boolean().
diagnosable_without_custom_instrumentation(Suite) ->
    ((diagnostics_domain_coverage(erlang:element(3, Suite)) andalso diagnostics_deterministic(
        erlang:element(3, Suite)
    ))
    andalso profiling_dimensions_coverage(erlang:element(4, Suite)))
    andalso profiling_actionable(erlang:element(4, Suite)).

-file("src/lightspeed/tooling/developer_productivity.gleam", 676).
-spec workflows_have_churn_reduction(list(refactor_workflow())) -> boolean().
workflows_have_churn_reduction(Workflows) ->
    case Workflows of
        [] ->
            true;

        [Workflow | Rest] ->
            (((((erlang:element(2, Workflow) /= <<""/utf8>>) andalso (erlang:element(
                3,
                Workflow
            )
            > erlang:element(4, Workflow)))
            andalso (patch_churn_reduction_percent(Workflow) >= 20))
            andalso erlang:element(6, Workflow))
            andalso (erlang:element(5, Workflow) /= []))
            andalso workflows_have_churn_reduction(Rest)
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 353).
?DOC(" True when representative refactor workflows reduce patch churn.\n").
-spec workflows_reduce_patch_churn(productivity_suite()) -> boolean().
workflows_reduce_patch_churn(Suite) ->
    workflows_have_churn_reduction(erlang:element(6, Suite)).

-file("src/lightspeed/tooling/developer_productivity.gleam", 734).
-spec navigation_has_symbol(list(navigation_contract()), binary()) -> boolean().
navigation_has_symbol(Navigation, Symbol) ->
    case Navigation of
        [] ->
            false;

        [Contract | Rest] ->
            case erlang:element(3, Contract) =:= Symbol of
                true ->
                    true;

                false ->
                    navigation_has_symbol(Rest, Symbol)
            end
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 722).
-spec editor_diagnostics_have_navigation(
    list(editor_diagnostic_contract()),
    list(navigation_contract())
) -> boolean().
editor_diagnostics_have_navigation(Diagnostics, Navigation) ->
    case Diagnostics of
        [] ->
            true;

        [Diagnostic | Rest] ->
            navigation_has_symbol(Navigation, erlang:element(6, Diagnostic))
            andalso editor_diagnostics_have_navigation(Rest, Navigation)
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 367).
?DOC(" True when editor diagnostics and navigation metadata are coherent.\n").
-spec supports_editor_navigation(productivity_suite()) -> boolean().
supports_editor_navigation(Suite) ->
    editor_diagnostics_have_navigation(
        erlang:element(7, Suite),
        erlang:element(8, Suite)
    ).

-file("src/lightspeed/tooling/developer_productivity.gleam", 710).
-spec navigation_contracts_valid(list(navigation_contract())) -> boolean().
navigation_contracts_valid(Contracts) ->
    case Contracts of
        [] ->
            true;

        [Contract | Rest] ->
            ((((erlang:element(2, Contract) /= <<""/utf8>>) andalso (erlang:element(
                3,
                Contract
            )
            /= <<""/utf8>>))
            andalso (erlang:element(4, Contract) /= <<""/utf8>>))
            andalso (erlang:element(5, Contract) =:= <<"jump_to_symbol"/utf8>>))
            andalso navigation_contracts_valid(Rest)
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 697).
-spec editor_contracts_valid(list(editor_diagnostic_contract())) -> boolean().
editor_contracts_valid(Contracts) ->
    case Contracts of
        [] ->
            true;

        [Contract | Rest] ->
            (((((erlang:element(2, Contract) /= <<""/utf8>>) andalso (erlang:element(
                3,
                Contract
            )
            /= <<""/utf8>>))
            andalso (erlang:element(4, Contract) /= <<""/utf8>>))
            andalso (erlang:element(5, Contract) /= <<""/utf8>>))
            andalso (erlang:element(6, Contract) /= <<""/utf8>>))
            andalso editor_contracts_valid(Rest)
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 689).
-spec workflows_deterministic(list(refactor_workflow())) -> boolean().
workflows_deterministic(Workflows) ->
    case Workflows of
        [] ->
            true;

        [Workflow | Rest] ->
            erlang:element(6, Workflow) andalso workflows_deterministic(Rest)
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 663).
-spec quality_gates_valid(list(tooling_quality_gate())) -> boolean().
quality_gates_valid(Gates) ->
    case Gates of
        [] ->
            true;

        [Gate | Rest] ->
            (((((erlang:element(2, Gate) /= <<""/utf8>>) andalso (erlang:element(
                3,
                Gate
            )
            /= <<""/utf8>>))
            andalso (erlang:element(4, Gate) /= <<""/utf8>>))
            andalso gleam_stdlib:string_starts_with(
                erlang:element(4, Gate),
                <<"m"/utf8>>
            ))
            andalso erlang:element(5, Gate))
            andalso quality_gates_valid(Rest)
    end.

-file("src/lightspeed/tooling/developer_productivity.gleam", 358).
?DOC(" True when tooling quality signals are stable enough for CI gating.\n").
-spec stable_quality_signals(productivity_suite()) -> boolean().
stable_quality_signals(Suite) ->
    (((quality_gates_valid(erlang:element(5, Suite)) andalso workflows_deterministic(
        erlang:element(6, Suite)
    ))
    andalso editor_contracts_valid(erlang:element(7, Suite)))
    andalso navigation_contracts_valid(erlang:element(8, Suite)))
    andalso supports_editor_navigation(Suite).

-file("src/lightspeed/tooling/developer_productivity.gleam", 375).
?DOC(" Validate one M59 suite contract.\n").
-spec valid_suite(productivity_suite()) -> boolean().
valid_suite(Suite) ->
    (((((((((erlang:element(2, Suite) /= <<""/utf8>>) andalso (erlang:length(
        erlang:element(3, Suite)
    )
    >= 4))
    andalso (erlang:length(erlang:element(4, Suite)) >= 3))
    andalso (erlang:length(erlang:element(5, Suite)) >= 3))
    andalso (erlang:length(erlang:element(6, Suite)) >= 2))
    andalso (erlang:length(erlang:element(7, Suite)) >= 3))
    andalso (erlang:length(erlang:element(8, Suite)) >= 3))
    andalso diagnosable_without_custom_instrumentation(Suite))
    andalso workflows_reduce_patch_churn(Suite))
    andalso stable_quality_signals(Suite).

-file("src/lightspeed/tooling/developer_productivity.gleam", 389).
?DOC(" Stable suite signature.\n").
-spec signature(productivity_suite()) -> binary().
signature(Suite) ->
    Diagnostics_entries = gleam@list:map(
        erlang:element(3, Suite),
        fun diagnostics_signature/1
    ),
    Profiling_entries = gleam@list:map(
        erlang:element(4, Suite),
        fun profiling_signature/1
    ),
    Gate_entries = gleam@list:map(
        erlang:element(5, Suite),
        fun quality_gate_signature/1
    ),
    Workflow_entries = gleam@list:map(
        erlang:element(6, Suite),
        fun refactor_workflow_signature/1
    ),
    Editor_entries = gleam@list:map(
        erlang:element(7, Suite),
        fun editor_diagnostic_signature/1
    ),
    Navigation_entries = gleam@list:map(
        erlang:element(8, Suite),
        fun navigation_signature/1
    ),
    <<<<<<<<<<<<<<<<<<<<<<<<<<"suite:"/utf8, (erlang:element(2, Suite))/binary>>/binary,
                                                    "|diagnostics="/utf8>>/binary,
                                                (join_with(
                                                    <<";"/utf8>>,
                                                    Diagnostics_entries
                                                ))/binary>>/binary,
                                            "|profiling="/utf8>>/binary,
                                        (join_with(
                                            <<";"/utf8>>,
                                            Profiling_entries
                                        ))/binary>>/binary,
                                    "|quality_gates="/utf8>>/binary,
                                (join_with(<<";"/utf8>>, Gate_entries))/binary>>/binary,
                            "|workflows="/utf8>>/binary,
                        (join_with(<<";"/utf8>>, Workflow_entries))/binary>>/binary,
                    "|editor="/utf8>>/binary,
                (join_with(<<";"/utf8>>, Editor_entries))/binary>>/binary,
            "|navigation="/utf8>>/binary,
        (join_with(<<";"/utf8>>, Navigation_entries))/binary>>.

-file("src/lightspeed/tooling/developer_productivity.gleam", 417).
?DOC(" Deterministic fixture snapshots for M59 drift gates.\n").
-spec fixture_snapshots() -> list({binary(), binary()}).
fixture_snapshots() ->
    gleam@list:map(
        reference_suites(),
        fun(Suite) -> {erlang:element(2, Suite), signature(Suite)} end
    ).

-file("src/lightspeed/tooling/developer_productivity.gleam", 422).
?DOC(" Deterministic M59 snapshot signature.\n").
-spec snapshot_signature() -> binary().
snapshot_signature() ->
    Entries = gleam@list:map(
        fixture_snapshots(),
        fun(Entry) ->
            {Label, Value} = Entry,
            <<<<Label/binary, "="/utf8>>/binary, Value/binary>>
        end
    ),
    <<<<(profile_version_label())/binary, "|"/utf8>>/binary,
        (join_with(<<";"/utf8>>, Entries))/binary>>.