build_tools.syllable_walk_web.api.walker ======================================== .. py:module:: build_tools.syllable_walk_web.api.walker .. autoapi-nested-parse:: Walker API handlers for the web application. Handles corpus loading, walk generation, name generation, analysis, and walker state queries. Functions --------- .. autoapisummary:: build_tools.syllable_walk_web.api.walker.handle_load_corpus build_tools.syllable_walk_web.api.walker.handle_walk build_tools.syllable_walk_web.api.walker.handle_stats build_tools.syllable_walk_web.api.walker.handle_save_session build_tools.syllable_walk_web.api.walker.handle_sessions build_tools.syllable_walk_web.api.walker.handle_load_session build_tools.syllable_walk_web.api.walker.handle_rebuild_reach_cache build_tools.syllable_walk_web.api.walker.handle_session_lock_heartbeat build_tools.syllable_walk_web.api.walker.handle_session_lock_release build_tools.syllable_walk_web.api.walker.handle_reach_syllables build_tools.syllable_walk_web.api.walker.handle_combine build_tools.syllable_walk_web.api.walker.handle_select build_tools.syllable_walk_web.api.walker.handle_export build_tools.syllable_walk_web.api.walker.handle_package build_tools.syllable_walk_web.api.walker.handle_analysis Module Contents --------------- .. py:function:: handle_load_corpus(body, state) Handle POST /api/walker/load-corpus. Loads syllables from a discovered pipeline run and initialises the SyllableWalker in a background thread. :param body: Request body with ``patch`` ("a" or "b") and ``run_id``. :param state: Global server state. :returns: Immediate response with syllable count and loading status. .. py:function:: handle_walk(body, state) Handle POST /api/walker/walk. Generates walks for a specified patch. :param body: Request body with walk parameters. :param state: Global server state. :returns: Walk results with formatted walks. .. py:function:: handle_stats(state) Handle GET /api/walker/stats. Returns current walker state for both patches. :param state: Global server state. :returns: State summary for patches A and B. .. py:function:: handle_save_session(body, state) Handle POST /api/walker/save-session. Persists one dual-patch session artifact under the runtime-resolved sessions base directory. .. py:function:: handle_sessions(state) Handle GET /api/walker/sessions. Returns saved session artifacts ordered newest-first with verification metadata so clients can decide what is safe to load. .. py:function:: handle_load_session(body, state) Handle POST /api/walker/load-session. Verifies one persisted session payload and triggers corpus loading for each referenced patch run. This reuses the existing corpus-load API semantics rather than mutating state via internal shortcuts. .. py:function:: handle_rebuild_reach_cache(body, state) Handle POST /api/walker/rebuild-reach-cache. Recomputes profile reach tables for one loaded patch and rewrites the run-local IPC cache artifact. .. py:function:: handle_session_lock_heartbeat(body, state) Handle POST /api/walker/session-lock/heartbeat. Refreshes a session lock lease for the caller's holder id. This is cooperative multi-tab coordination, not an auth/security layer. .. py:function:: handle_session_lock_release(body, state) Handle POST /api/walker/session-lock/release. Releases the current lease when called by lock owner. .. py:function:: handle_reach_syllables(body, state) Handle POST /api/walker/reach-syllables. Returns the list of reachable syllables for a given profile and patch, sorted alphabetically with frequency data. :param body: Request body with ``patch`` and ``profile``. :param state: Global server state. :returns: Dict with ``profile``, ``reach``, ``total``, and ``syllables`` list. .. py:function:: handle_combine(body, state) Handle POST /api/walker/combine. Generates name candidates from the loaded corpus syllables. Supports two generation modes selected by the ``profile`` parameter: - **Flat** (``profile`` absent or ``"flat"``): Independent random sampling using ``frequency_weight`` (0.0–1.0). No walker required. - **Walk-based** (``profile`` is a named profile or ``"custom"``): Graph traversal using the walker's neighbor graph. Requires the walker to be initialised (``walker_ready``). :param body: Request body with ``patch``, ``count``, ``syllables``, ``seed``, ``frequency_weight``, and optionally ``profile``, ``max_flips``, ``temperature``. :param state: Global server state. :returns: Candidate generation summary with count and sample. .. py:function:: handle_select(body, state) Handle POST /api/walker/select. Selects names from candidates using a name class policy. :param body: Request body with ``patch``, ``name_class``, ``count``, ``mode``, ``seed``. :param state: Global server state. :returns: Selection results with names and metadata. .. py:function:: handle_export(body, state) Handle POST /api/walker/export. Returns selected names as a downloadable list. :param body: Request body with ``patch``. :param state: Global server state. :returns: Dict with names list for client-side download. .. py:function:: handle_package(body, state) Handle POST /api/walker/package. Builds a ZIP archive from in-memory walker state. :param body: Request body with ``name``, ``version``, and include flags. :param state: Global server state. :returns: Tuple of (zip_bytes, filename, error_message_or_none). .. py:function:: handle_analysis(patch_key, state) Handle GET /api/walker/analysis/. Computes corpus shape metrics for a patch. :param patch_key: ``"a"`` or ``"b"``. :param state: Global server state. :returns: Corpus analysis metrics (inventory, frequency, terrain).