build_tools.syllable_walk_web.api.walker_common

Shared stateless helper functions for walker API handlers.

This module contains request-coercion and comparison helpers that do not need filesystem access or mutation side effects. It exists to reduce the size and cognitive load of api/walker.py while preserving existing endpoint contracts.

Functions

is_sha256_hex(value)

Return True when value is a lowercase 64-character SHA-256 hash.

reach_cache_verification_from_read(*, cache_status, ...)

Map reach-cache read outcomes to verification status and reason.

resolve_patch_state(body, state)

Resolve request patch to ("a"|"b", PatchState).

coerce_optional_constraint_int(body, field_name, *, ...)

Coerce one optional integer constraint from request payload.

compute_patch_comparison(*, patch_a_manifest_hash, ...)

Compute Patch A/B manifest-hash relation and policy signal.

Module Contents

build_tools.syllable_walk_web.api.walker_common.is_sha256_hex(value)[source]

Return True when value is a lowercase 64-character SHA-256 hash.

build_tools.syllable_walk_web.api.walker_common.reach_cache_verification_from_read(*, cache_status, cache_message, input_hash, output_hash)[source]

Map reach-cache read outcomes to verification status and reason.

This preserves the user-facing semantics consumed by the Walker UI: - cache hit + valid hashes => verified - cache hit + missing hashes => error - invalid/miss/none/error map to deterministic reason strings

build_tools.syllable_walk_web.api.walker_common.resolve_patch_state(body, state)[source]

Resolve request patch to ("a"|"b", PatchState).

Parameters:
Returns:

Tuple of (patch_key, patch_state) when valid; otherwise None.

Return type:

tuple[str, build_tools.syllable_walk_web.state.PatchState] | None

build_tools.syllable_walk_web.api.walker_common.coerce_optional_constraint_int(body, field_name, *, default)[source]

Coerce one optional integer constraint from request payload.

Semantics: - Missing field: use provided default. - Explicit null: disable this constraint (return None). - Provided value: coerce to int or return deterministic error.

build_tools.syllable_walk_web.api.walker_common.compute_patch_comparison(*, patch_a_manifest_hash, patch_b_manifest_hash)[source]

Compute Patch A/B manifest-hash relation and policy signal.