Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: give the tool-call strip one owner and one scan order (#8427)
Daniel Han48cf5ff213f6
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.pyindex 1cbd03f9719..8428d4f4867 100644--- a/studio/backend/core/inference/llama_cpp.py+++ b/studio/backend/core/inference/llama_cpp.py@@ -76,14 +76,9 @@ from core.inference.llama_server_args import (from core.inference.tool_call_parser import (_GEMMA_BARE_TC_PREFIX_RE,_GEMMA_BARE_TC_RE,- _TOOL_ALL_PATS as _PARSER_TOOL_ALL_PATS,- _TOOL_CLOSED_PATS as _PARSER_TOOL_CLOSED_PATS,_balanced_brace_end,- _strip_function_xml_calls,- _strip_gemma_wrapperless_calls,- _strip_glm_calls,- _strip_mistral_closed_calls,TOOL_XML_SIGNALS as _SHARED_TOOL_XML_SIGNALS,+ strip_segment as _parser_strip_segment,RAG_MAX_SEARCHES_PER_TURN,RAG_SEARCH_CAP_NUDGE,parse_tool_calls_from_text as _shared_parse_tool_calls_from_text,@@ -92,14 +87,8 @@ from core.inference.tool_call_parser import (strip_tool_markup as _shared_strip_tool_markup,)-# The healer owns the bracket-tag + rehearsal strip helpers and their name-gated-# pattern lists, so the GGUF streaming strip stays aligned with the parser.-from core.tool_healing import (- _REHEARSAL_TAIL_STRIP_RE,- _strip_bracket_tag_calls,- apply_tool_strip_patterns,- strip_outside_think,-)+# The strip arms moved into the parser's ``strip_segment``; only think splitting is here.+from core.tool_healing import strip_outside_thinkfrom utils.native_path_leases import child_env_without_native_path_secretfrom utils.child_stdio import utf8_child_envfrom utils.hf_xet_fallback import hf_hub_download_with_xet_fallback@@ -141,11 +130,17 @@ class LlamaServerNotFoundError(RuntimeError):"""GGUF model needs the llama.cpp runtime but no llama-server is installed.Subclasses RuntimeError so existing handlers still catch it."""+ __slots__ = ()+class _LlamaStreamCancelled(Exception):"""Internal signal for an expected client/request cancellation."""+ __slots__ = ()++# Deliberately NOT ``slots=True``: it drops ``__dict__``, so ``vars(intent)`` raises and+# every GGUF load breaks. Reflection over this dataclass is part of how it is used.@dataclass(frozen = True)class GgufLoadIntent:"""Immutable caller intent replayed by retries and recovery."""@@ -3145,6 +3140,11 @@ def _llama_lib_dir(binary: str) -> Path:_CPU_RUNTIME_OWNER_FILE = "UNSLOTH_OWNER_PID"+# GPU backends the staged CPU-only runtime must not carry over. Module level: compiled once.+_GGML_GPU_BACKEND_RE = re.compile(+ r"^(?:lib)?ggml-(?:cuda|hip|vulkan|metal|sycl|opencl|musa|cann|virtgpu)"+)+def _cpu_runtime_owner_alive(staged_dir: Path) -> bool:"""Whether a live process still owns this staged CPU-fallback runtime."""@@ -3250,6 +3250,8 @@ def _coerce_reasoning_effort(architecture, kwargs: dict) -> dict:class CountAborted(Exception):"""A token count stood down mid-flight because its answer stopped mattering."""+ __slots__ = ()+class LlamaCppBackend:"""Manages a llama-server subprocess for GGUF model inference.@@ -9805,9 +9807,7 @@ class LlamaCppBackend:# and let the next stage collect what no live Studio holds.(staged_dir / _CPU_RUNTIME_OWNER_FILE).write_text(str(os.getpid()), encoding = "utf-8")lib_dir = _llama_lib_dir(str(source_binary))- gpu_backend = re.compile(- r"^(?:lib)?ggml-(?:cuda|hip|vulkan|metal|sycl|opencl|musa|cann|virtgpu)"- )+ gpu_backend = _GGML_GPU_BACKEND_REcpu_library_present = Falsefor source in lib_dir.iterdir():try:@@ -16155,26 +16155,12 @@ class LlamaCppBackend:return textdef _seg(segment: str, is_last: bool) -> str:- # Same scan order as the parser's _strip_segment (seg_final -> is_last): balanced- # strips first (nested JSON removed whole; literal markup inside a value is that- # call's data), then the guarded function-XML / GLM scans, then the regex arms- # (DeepSeek / Kimi / closed forms). EOS-anchored tail arms run only on the last- # segment (a bare ``foo[ARGS]`` before <think> is prose). Rehearsal + markerless- # strips are name-gated on the ORIGINAL list (strip/detect aligned).- seg = _strip_mistral_closed_calls(segment)- seg = _strip_bracket_tag_calls(seg, enabled_tool_names = _enabled_names_gate)- if is_last:- seg = _strip_gemma_wrapperless_calls(seg, _enabled_names_gate)- seg = _strip_function_xml_calls(seg, final = is_last)- seg = _strip_glm_calls(seg, final = is_last)- pats = _PARSER_TOOL_ALL_PATS if is_last else _PARSER_TOOL_CLOSED_PATS- for pat in pats:- seg = pat.sub("", seg)- if is_last:- seg = apply_tool_strip_patterns(- seg, [_REHEARSAL_TAIL_STRIP_RE], enabled_tool_names = _enabled_names_gate- )- return seg+ # Scan order lives in the parser's ``strip_segment`` so this path, the+ # safetensors loop and ``strip_tool_markup`` cannot drift. No separate+ # final pass here, so the last segment takes the end-of-turn arms.+ return _parser_strip_segment(+ segment, seg_final = is_last, enabled_tool_names = _enabled_names_gate+ )# Preserve think blocks verbatim (a rehearsed call inside one must not be deleted).return strip_outside_think(text, _seg)diff --git a/studio/backend/core/inference/safetensors_agentic.py b/studio/backend/core/inference/safetensors_agentic.pyindex 9667c49aa9b..73d03f7d3f2 100644--- a/studio/backend/core/inference/safetensors_agentic.py+++ b/studio/backend/core/inference/safetensors_agentic.py@@ -25,14 +25,9 @@ from loggers import get_loggerfrom core.inference.tool_call_parser import (_GEMMA_BARE_TC_PREFIX_RE,_GEMMA_BARE_TC_RE,- _TOOL_ALL_PATS as _PARSER_TOOL_ALL_PATS,- _TOOL_CLOSED_PATS as _PARSER_TOOL_CLOSED_PATS,_balanced_brace_end,- _strip_function_xml_calls,- _strip_gemma_wrapperless_calls,- _strip_glm_calls,- _strip_mistral_closed_calls,_strip_mistral_reasoning,+ strip_segment as _parser_strip_segment,BUDGET_EXHAUSTED_NUDGE,MAX_ACT_REPROMPTS,NUDGE_TOOL_CALLS_STATUS,@@ -48,14 +43,9 @@ from core.inference.tool_call_parser import (strip_tool_markup,)-# The healer owns the bracket-tag + rehearsal strip helpers and their name-gated-# pattern lists, so the safetensors streaming strip stays aligned with the parser.from core.tool_healing import (- _REHEARSAL_TAIL_STRIP_RE,_THINK_CLOSE_RE,- _strip_bracket_tag_calls,_think_spans_outside_tool_markup,- apply_tool_strip_patterns,strip_outside_think,)from core.inference.tool_loop_controller import (@@ -271,24 +261,12 @@ def strip_tool_markup_streaming(text = _strip_mistral_reasoning(text)def _seg(segment: str, is_last: bool) -> str:- # Same scan order as the parser's _strip_segment (seg_final -> is_last): balanced- # strips first, then the guarded function-XML / GLM scans, then the regex arms- # (DeepSeek / Kimi / closed forms). EOS-anchored tail arms run only on the last- # segment (a bare ``foo[ARGS]`` before <think> is prose). Rehearsal strips are name-gated.- seg = _strip_mistral_closed_calls(segment)- seg = _strip_bracket_tag_calls(seg, enabled_tool_names = enabled_tool_names)- if is_last:- seg = _strip_gemma_wrapperless_calls(seg, enabled_tool_names)- seg = _strip_function_xml_calls(seg, final = is_last)- seg = _strip_glm_calls(seg, final = is_last)- pats = _PARSER_TOOL_ALL_PATS if is_last else _PARSER_TOOL_CLOSED_PATS- for pat in pats:- seg = pat.sub("", seg)- if is_last:- seg = apply_tool_strip_patterns(- seg, [_REHEARSAL_TAIL_STRIP_RE], enabled_tool_names = enabled_tool_names- )- return seg+ # Scan order lives in the parser's ``strip_segment`` so this path, the GGUF+ # streaming path and ``strip_tool_markup`` cannot drift. Its end-of-turn arms+ # run only on the last segment.+ return _parser_strip_segment(+ segment, seg_final = is_last, enabled_tool_names = enabled_tool_names+ )# Preserve think blocks verbatim: stripping a rehearsed call inside one shrinks then# regrows the cumulative text, corrupting append-by-length consumers.diff --git a/studio/backend/core/inference/tool_call_parser.py b/studio/backend/core/inference/tool_call_parser.pyindex 070e5aa3a2d..e493efb5b97 100644--- a/studio/backend/core/inference/tool_call_parser.py+++ b/studio/backend/core/inference/tool_call_parser.py@@ -271,7 +271,8 @@ _TC_FUNC_START_RE = re.compile(r'<function(?:=([\w\.\-]+)|\s+name="([\w\.\-]+)")# Body ends at ``</tool_call>`` (Hermes) or ``</function>`` (Qwen3.5 / MiniCPM-5)# so it stops at the close even when prose follows (else prose leaked into args)._TC_END_TAG_RE = re.compile(r"</(?:tool_call|function)>")-_TC_FUNC_CLOSE_RE = re.compile(r"\s*</function>\s*$")+# Byte-identical to the healer's; shared so the pair cannot drift.+_TC_FUNC_CLOSE_RE = _tool_healing._TC_FUNC_CLOSE_RE# Horizontal whitespace only (``[^\S\n]*``, not ``\s*``) so the wrapping newline +# first-line indentation survive; ``_trim_param_value`` trims one newline, preserving# code indentation (SGLang qwen3_coder).@@ -361,34 +362,10 @@ _GEMMA_BARE_TC_PREFIX_RE = re.compile(r"(?<!\w)call\s*(?::\s*[\w\.\-]*)?$")_GEMMA_KEY_RE = re.compile(r"\s*([A-Za-z_][\w.\-]*)\s*:")-def _balanced_bracket_end(text: str, start: int) -> int | None:- """Index of the ``]`` matching ``[`` at ``text[start]`` (ignores brackets in JSON strings)."""- if start >= len(text) or text[start] != "[":- return None- depth = 0- in_string = False- esc = False- i = start- while i < len(text):- ch = text[i]- if in_string:- if esc:- esc = False- elif ch == "\\":- esc = True- elif ch == '"':- in_string = False- else:- if ch == '"':- in_string = True- elif ch == "[":- depth += 1- elif ch == "]":- depth -= 1- if depth == 0:- return i- i += 1- return None+# Shared with the healer, but brackets-only depth: a stray ``}`` must not end the span+# early and leave the rest of a malformed call on screen.+def _balanced_bracket_end(src: str, start: int) -> "int | None":+ return _tool_healing._balanced_bracket_end(src, start, braces_count = False)def _skip_mistral_call_id(text: str, pos: int) -> int:@@ -694,6 +671,45 @@ def _strip_glm_calls(text: str, *, final: bool) -> str:return "".join(out)+def strip_segment(+ segment: str,+ *,+ seg_final: bool,+ enabled_tool_names: Optional[set] = None,+) -> str:+ """Strip tool-call markup from one non-``<think>`` segment.++ The single definition of the scan order, shared by the GGUF and safetensors paths.+ ``routes/inference.py`` keeps a deliberately different order for the passthrough+ path, pinned by ``tests/test_route_strip_drift.py``. ``seg_final`` enables the+ end-of-turn arms (markerless Gemma, open tails, trailing partial rehearsal).+ """+ seg = _strip_mistral_closed_calls(segment)+ # Bare rehearsal ``name[ARGS]{json}`` and the Mistral name form, through the shared+ # balanced scan. Name-gated: an inactive ``foo[ARGS]{..}`` is prose and is kept.+ seg = _tool_healing._strip_bracket_tag_calls(seg, enabled_tool_names = enabled_tool_names)+ if seg_final:+ # Markerless Gemma ``call:NAME{...}``, name-gated like the parse gate.+ seg = _strip_gemma_wrapperless_calls(seg, enabled_tool_names)+ # Scan, not regex, so a literal ``<function=...>`` inside a value stays data.+ seg = _strip_function_xml_calls(seg, final = seg_final)+ # GLM 4.x: scan to the call's real </tool_call>, so a literal one inside a value is+ # data. Qwen <tool_call>{json} is left to the regex arms.+ seg = _strip_glm_calls(seg, final = seg_final)+ pats = _TOOL_ALL_PATS if seg_final else _TOOL_CLOSED_PATS+ for pat in pats:+ seg = pat.sub("", seg)+ if seg_final:+ # Trailing partial rehearsal the balanced scan cannot close; gated so prose+ # ``foo[ARGS] ...`` survives.+ seg = _tool_healing.apply_tool_strip_patterns(+ seg,+ [_tool_healing._REHEARSAL_TAIL_STRIP_RE],+ enabled_tool_names = enabled_tool_names,+ )+ return seg++def strip_tool_markup(text: str,*,@@ -713,33 +729,11 @@ def strip_tool_markup(text = _strip_mistral_reasoning(text)def _strip_segment(segment: str, is_last: bool) -> str:- seg_final = final and is_last- seg = _strip_mistral_closed_calls(segment)- # Bare reasoning-rehearsal ``name[ARGS]{json}`` and the Mistral name form promote through- # the shared balanced scan, so strip them the same way (any nesting depth removed whole).- # The rehearsal arm is name-gated: an inactive ``foo[ARGS]{..}`` is prose and is kept.- seg = _tool_healing._strip_bracket_tag_calls(seg, enabled_tool_names = enabled_tool_names)- if seg_final:- # Markerless Gemma ``call:NAME{...}`` (name-gated, mirrors the parse gate); end-of-turn only.- seg = _strip_gemma_wrapperless_calls(seg, enabled_tool_names)- # Scan-strip the function-XML form (parser-accurate: a literal ``<function=...>`` in a- # value is data, not a call); the regex arms below cover the other formats.- seg = _strip_function_xml_calls(seg, final = seg_final)- # GLM 4.x: scan to the call's real </tool_call> so a literal one inside a value is data,- # not a leak. Qwen <tool_call>{json} is left to the regex arms.- seg = _strip_glm_calls(seg, final = seg_final)- pats = _TOOL_ALL_PATS if seg_final else _TOOL_CLOSED_PATS- for pat in pats:- seg = pat.sub("", seg)- if seg_final:- # Drop a trailing partial bare rehearsal (``name[ARGS]`` with a truncated or absent- # body) the balanced scan cannot close; gated so prose ``foo[ARGS] ...`` survives.- seg = _tool_healing.apply_tool_strip_patterns(- seg,- [_tool_healing._REHEARSAL_TAIL_STRIP_RE],- enabled_tool_names = enabled_tool_names,- )- return seg+ return strip_segment(+ segment,+ seg_final = final and is_last,+ enabled_tool_names = enabled_tool_names,+ )# ``<think>`` / ``[THINK]`` reasoning is preserved verbatim (a rehearsed call inside it is# not executed, so it must not be stripped from display either); a literal think marker@@ -1282,51 +1276,24 @@ def _parse_tool_call_json(return out-def _trim_param_value(val: str) -> str:- """Trim one wrapping newline the template adds around an XML parameter value- (``<parameter=k>\nVALUE\n</parameter>``), preserving inner indentation.- ``str.strip()`` destroyed code/diff indentation; SGLang's qwen3_coder trims only- the wrapping newline."""- if val.startswith("\n"):- val = val[1:]- if val.endswith("\n"):- val = val[:-1]- return val+# Identical to the healer's copy; imported so the two cannot drift.+_trim_param_value = _tool_healing._trim_param_valuedef _inside_open_parameter(text: str, pos: int) -> bool:"""True if ``pos`` sits inside an unclosed ``<parameter>``/``<param>`` block --i.e. a ``<function>`` / ``<parameter>`` opener at ``pos`` is a literal inside anargument value (e.g. code that prints tool-call XML), not a real nested call.- Compares the last parameter opener before ``pos`` against the last- parameter/function close before it."""- last_param_open = -1- for m in _TC_PARAM_START_RE.finditer(text, 0, pos):- last_param_open = m.start()- if last_param_open < 0:- return False- # The parameter's OWN close tag decides: while it closes after ``pos`` the position is- # argument data, even across several literal function closes. Only an unclosed- # parameter (heal mode) falls back to the first function close.- own_closes = [- c- for c in (- text.find("</parameter>", last_param_open),- text.find("</param>", last_param_open),- )- if c >= 0- ]- if own_closes:- return min(own_closes) > pos- func_closes = [- c- for c in (- text.find("</function>", last_param_open),- text.find("</tool_call>", last_param_open),- )- if c >= 0- ]- return not func_closes or pos < min(func_closes)++ The healer's algorithm over a wider vocabulary (``<param name="...">`` openers,+ ``</tool_call>`` closers for GLM 4.x / Kimi K2); only that is passed in."""+ return _tool_healing._inside_open_parameter(+ text,+ pos,+ param_start_re = _TC_PARAM_START_RE,+ param_closers = ("</parameter>", "</param>"),+ func_closers = ("</function>", "</tool_call>"),+ )def _parse_function_xml(@@ -1966,34 +1933,8 @@ def _parse_gemma_tool_calls(return out-def _balanced_brace_end(text: str, brace_pos: int) -> int | None:- """Index of the ``}`` matching ``{`` at ``brace_pos`` (ignores braces in JSON strings)."""- if brace_pos >= len(text) or text[brace_pos] != "{":- return None- depth = 0- in_string = False- esc = False- i = brace_pos- while i < len(text):- ch = text[i]- if in_string:- if esc:- esc = False- elif ch == "\\":- esc = True- elif ch == '"':- in_string = False- else:- if ch == '"':- in_string = True- elif ch == "{":- depth += 1- elif ch == "}":- depth -= 1- if depth == 0:- return i- i += 1- return None+# Shared with the healer; its Gemma quoting sits behind a flag this module never sets.+_balanced_brace_end = _tool_healing._balanced_brace_enddef _gemma_body_brace_end(text: str, brace_pos: int) -> int | None:diff --git a/studio/backend/core/tool_healing.py b/studio/backend/core/tool_healing.pyindex bbee6b3eb7e..28f5644a08f 100644--- a/studio/backend/core/tool_healing.py+++ b/studio/backend/core/tool_healing.py@@ -256,7 +256,14 @@ def _balanced_brace_end(brace_start: int,*,gemma_quotes: bool = False,-) -> int:+) -> int | None:+ """Index of the ``}`` matching the ``{`` at ``brace_start``, or None.++ Shared with ``core/inference/tool_call_parser.py``. The guard makes a mispositioned+ call return None instead of reporting an unrelated brace.+ """+ if brace_start >= len(content) or content[brace_start] != "{":+ return Nonedepth = 0i = brace_startin_string = False@@ -285,12 +292,27 @@ def _balanced_brace_end(if depth == 0:return ii += 1- return -1+ return None-def _balanced_bracket_end(src: str, start: int) -> int:- """Index of the ``]`` matching the ``[`` at ``start``, or -1. Tracks nested- ``[]``/``{}`` and double-quoted strings."""+def _balanced_bracket_end(+ src: str,+ start: int,+ *,+ braces_count: bool = True,+) -> int | None:+ """Index of the ``]`` matching the ``[`` at ``start``, or None. Tracks nesting and+ double-quoted strings.++ With ``braces_count`` (the default) braces count toward the same depth, so a+ truncated object cannot close an array early; the Gemma array normalizer needs that.+ The display strip in ``tool_call_parser.py`` counts brackets only, so a stray ``}``+ cannot end the span early and leave the rest of a malformed call visible.+ """+ if start >= len(src) or src[start] != "[":+ return None+ openers = "[{" if braces_count else "["+ closers = "]}" if braces_count else "]"depth = 0i = startin_string = False@@ -304,14 +326,14 @@ def _balanced_bracket_end(src: str, start: int) -> int:in_string = Falseelif ch == '"':in_string = True- elif ch in "[{":+ elif ch in openers:depth += 1- elif ch in "]}":+ elif ch in closers:depth -= 1if depth == 0:return ii += 1- return -1+ return Nonedef _decode_array_items(text: str, body_start: int, body_end: int):@@ -409,7 +431,6 @@ def _iter_bracket_spans(kind, m = min(live, key = lambda km: km[1].start())if kind == "array":end = _balanced_bracket_end(text, m.end())- end = None if end < 0 else endelse:end = _balanced_json_span(text, m.end())if end is None:@@ -571,7 +592,7 @@ def _quote_gemma_object_keys(src: str) -> str:# Array value: quote bare string elements (e.g. labels:[bug,ui])# so json.loads succeeds instead of dropping the call.arr_end = _balanced_bracket_end(src, i)- if arr_end < 0:+ if arr_end is None:parts.append(src[i:])i = len(src)else:@@ -611,20 +632,42 @@ def _gemma_arguments_to_json(args_src: str) -> dict:return json.loads(src)-def _inside_open_parameter(content: str, pos: int) -> bool:- """Return True when ``pos`` falls inside an unclosed parameter value."""+def _inside_open_parameter(+ content: str,+ pos: int,+ *,+ param_start_re = None,+ param_closers = (_PARAM_CLOSE_TAG,),+ func_closers = (_FUNC_CLOSE_TAG,),+) -> bool:+ """Return True when ``pos`` falls inside an unclosed parameter value.++ The opener regex and closer tags are parameters so+ ``core/inference/tool_call_parser.py`` can share this body with its wider vocabulary+ (``<param name="...">`` openers, ``</param>`` / ``</tool_call>`` closers).+ """+ if param_start_re is None:+ param_start_re = _TC_PARAM_START_RElast_param_start = -1- for match in _TC_PARAM_START_RE.finditer(content, 0, pos):+ for match in param_start_re.finditer(content, 0, pos):last_param_start = match.start()if last_param_start < 0:return False# The parameter's OWN close tag decides: if it closes after ``pos`` the position is# argument data (even across literal function closes); an unclosed one falls back to func close.- own_close = content.find(_PARAM_CLOSE_TAG, last_param_start)- if own_close >= 0:- return own_close > pos- func_close = content.find(_FUNC_CLOSE_TAG, last_param_start)- return func_close < 0 or pos < func_close+ own_closes = [+ found+ for found in (content.find(tag, last_param_start) for tag in param_closers)+ if found >= 0+ ]+ if own_closes:+ return min(own_closes) > pos+ func_closes = [+ found+ for found in (content.find(tag, last_param_start) for tag in func_closers)+ if found >= 0+ ]+ return not func_closes or pos < min(func_closes)def _func_close_index(content: str, body_start: int, body: str) -> int:@@ -701,7 +744,8 @@ def _build_markers(content: str):if _inside_open_parameter(content, m.start()):continuebrace_end = _balanced_brace_end(content, m.end() - 1, gemma_quotes = gemma)- markers.append((m.start(), brace_end, kind, m))+ # Keep the ``-1`` sentinel: ``marker_coverage`` consumers test ``brace_end < 0``.+ markers.append((m.start(), -1 if brace_end is None else brace_end, kind, m))markers.sort(key = lambda c: c[0])return markers@@ -1057,7 +1101,7 @@ def _strip_gemma_native_spans(text: str, *, final: bool) -> str:if start < cursor:continuebrace_end = _balanced_brace_end(text, match.end() - 1, gemma_quotes = True)- if brace_end < 0:+ if brace_end is None:# Unbalanced: nothing completes from here on. Drop the rest if final,# else keep it; stop either way (rescanning would be quadratic).if final:@@ -1088,7 +1132,7 @@ def _gemma_span_ranges(text: str) -> list:if start < cursor:continuebrace_end = _balanced_brace_end(text, match.end() - 1, gemma_quotes = True)- if brace_end < 0:+ if brace_end is None:breakclose = _TC_GEMMA_END_TAG_RE.search(text, brace_end + 1)if close is None:diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.pyindex 055bf9b4d04..889be03341a 100644--- a/studio/backend/routes/inference.py+++ b/studio/backend/routes/inference.py@@ -37,7 +37,7 @@ import threadingimport weakreffrom concurrent.futures import ThreadPoolExecutorfrom contextlib import ExitStack, contextmanager-from dataclasses import replace+from dataclasses import fields as dataclass_fields, replaceimport re as _re@@ -4198,9 +4198,10 @@ def _gguf_request_intent(n_parallel: int,**changes,) -> GgufLoadIntent:+ # ``dataclass_fields``, not ``vars``: same names, but no reliance on ``__dict__``.settings = {name: getattr(request, name)- for name in vars(source)+ for name in (f.name for f in dataclass_fields(source))if hasattr(request, name) and (name != "hf_token" or source.hf_repo)}settings.update(diff --git a/studio/backend/tests/data/refactor_guard/ast_inventory.json b/studio/backend/tests/data/refactor_guard/ast_inventory.jsonnew file mode 100644index 00000000000..642ce965108--- /dev/null+++ b/studio/backend/tests/data/refactor_guard/ast_inventory.json@@ -0,0 +1,1687 @@+{+ "core.inference.inference": {+ "symbols": {+ "HarmonyTextStreamer": {+ "kind": "class"+ },+ "InferenceBackend": {+ "kind": "class"+ },+ "ReasoningTextIteratorStreamer": {+ "kind": "class"+ },+ "_GenerationThreadError": {+ "kind": "class"+ },+ "get_inference_backend": {+ "kind": "def"+ },+ "inference_backend": {+ "kind": "assign"+ },+ "logger": {+ "kind": "assign"+ }+ }+ },+ "core.inference.llama_cpp": {+ "symbols": {+ "CountAborted": {+ "kind": "class"+ },+ "GgufLoadIntent": {+ "kind": "class"+ },+ "LLAMA_SERVER_NOT_FOUND_DETAIL": {+ "kind": "assign"+ },+ "LlamaCppBackend": {+ "kind": "class"+ },+ "LlamaServerNotFoundError": {+ "kind": "class"+ },+ "ParavirtualPlacement": {+ "kind": "class"+ },+ "_ANSWER_PIVOT": {+ "kind": "assign"+ },+ "_APPLE_UNIFIED_MEMORY_FRACTION": {+ "kind": "assign"+ },+ "_BIG_ENDIAN_GGUF_FILENAME_RE": {+ "kind": "assign"+ },+ "_BOOTSTRAP_SWA_DEFAULTS": {+ "kind": "assign"+ },+ "_CANONICAL_SPEC_MODES": {+ "kind": "assign"+ },+ "_CHAT_LOADS_IN_FLIGHT": {+ "kind": "assign"+ },+ "_CPU_DEVICE_VALUES": {+ "kind": "assign"+ },+ "_CPU_MOE_COUNT_FLAGS": {+ "kind": "assign"+ },+ "_CPU_PLACEMENT_FLAGS": {+ "kind": "assign"+ },+ "_CPU_PLACEMENT_PRESENCE_FLAGS": {+ "kind": "assign"+ },+ "_CPU_RUNTIME_OWNER_FILE": {+ "kind": "assign"+ },+ "_CTX_FIT_VRAM_FRACTION": {+ "kind": "assign"+ },+ "_CpuFallbackRuntime": {+ "kind": "class"+ },+ "_DEFAULT_FIRST_TOKEN_TIMEOUT_S": {+ "kind": "assign"+ },+ "_DEFAULT_LLAMA_N_BATCH": {+ "kind": "assign"+ },+ "_DEFAULT_LLAMA_N_UBATCH": {+ "kind": "assign"+ },+ "_DEFAULT_MAX_TOKENS_FLOOR": {+ "kind": "assign"+ },+ "_DEFAULT_STREAM_STALL_TIMEOUT_S": {+ "kind": "assign"+ },+ "_DEVICE_ROW_RE": {+ "kind": "assign"+ },+ "_DRAFTER_DIR_KINDS": {+ "kind": "assign"+ },+ "_DRAFTER_DISPLAY_LABELS": {+ "kind": "assign"+ },+ "_DRAFTER_KINDS": {+ "kind": "assign"+ },+ "_FINAL_ANSWER_SIGNAL": {+ "kind": "assign"+ },+ "_FORCED_PLAN_INTENT": {+ "kind": "assign"+ },+ "_GEMMA_MTP_FAMILY_RE": {+ "kind": "assign"+ },+ "_GGML_GPU_BACKEND_RE": {+ "kind": "assign"+ },+ "_GGUF_AUDIO_READ_TIMEOUT": {+ "kind": "assign"+ },+ "_GGUF_KNOWN_QUANT_RE": {+ "kind": "assign"+ },+ "_GGUF_REHEARSAL_ARGS_RE": {+ "kind": "assign"+ },+ "_GPU_DEVICE_PREFIXES": {+ "kind": "assign"+ },+ "_GPU_OFFLOAD_MARKERS": {+ "kind": "assign"+ },+ "_GPU_OFFLOAD_OVERRIDE_FLAGS": {+ "kind": "assign"+ },+ "_IGPU_HOST_RESERVE_MIB": {+ "kind": "assign"+ },+ "_INKLING_REASONING_EFFORT": {+ "kind": "assign"+ },+ "_LEGACY_SPEC_MODE_MAP": {+ "kind": "assign"+ },+ "_LLAMA_ARG_AUTO_VALUES": {+ "kind": "assign"+ },+ "_LLAMA_ARG_FALSE_VALUES": {+ "kind": "assign"+ },+ "_LLAMA_ARG_TRUE_FALSE_AUTO_VALUES": {+ "kind": "assign"+ },+ "_LLAMA_ARG_TRUE_OR_AUTO_VALUES": {+ "kind": "assign"+ },+ "_LLAMA_ARG_TRUE_VALUES": {+ "kind": "assign"+ },+ "_LOADS_IN_FLIGHT": {+ "kind": "assign"+ },+ "_LOADS_IN_FLIGHT_LOCK": {+ "kind": "assign"+ },+ "_LlamaStreamCancelled": {+ "kind": "class"+ },+ "_MAX_TOOL_CALLS_PER_TURN": {+ "kind": "assign"+ },+ "_MTP_MIN_SIZE_B": {+ "kind": "assign"+ },+ "_MTP_VRAM_RESERVE_FRAC": {+ "kind": "assign"+ },+ "_OFFLOADED_LAYERS_RE": {+ "kind": "assign"+ },+ "_OVERRIDE_TENSOR_FLAGS": {+ "kind": "assign"+ },+ "_PARAVIRTUAL_DIFFUSION_NO_NGL_ERROR": {+ "kind": "assign"+ },+ "_PERMANENT_HUB_ERRORS": {+ "kind": "assign"+ },+ "_PROVISIONAL_ARGS_MIN_CHARS": {+ "kind": "assign"+ },+ "_REASONING_EFFORT_SCALE": {+ "kind": "assign"+ },+ "_RESPAWN_REAP_GRACE_S": {+ "kind": "assign"+ },+ "_SHARD_FULL_RE": {+ "kind": "assign"+ },+ "_SHARD_RE": {+ "kind": "assign"+ },+ "_SPEC_ENV_VARS": {+ "kind": "assign"+ },+ "_SPEC_KIND_CAPABILITY": {+ "kind": "assign"+ },+ "_SWA_CACHE": {+ "kind": "assign"+ },+ "_SWA_CACHE_LOCK": {+ "kind": "assign"+ },+ "_SWA_PATTERN_SOURCE_RE": {+ "kind": "assign"+ },+ "_TEXT_TOOL_GEMMA_RE": {+ "kind": "assign"+ },+ "_TEXT_TOOL_NAME_RE": {+ "kind": "assign"+ },+ "_TEXT_TOOL_REHEARSAL_RE": {+ "kind": "assign"+ },+ "_THREAD_OVERRIDE_FLAGS": {+ "kind": "assign"+ },+ "_TOOL_TEMPLATE_MARKERS": {+ "kind": "assign"+ },+ "_UNRECOVERABLE_LOCAL_ERRNOS": {+ "kind": "assign"+ },+ "_VULKAN_DIFFUSION_GPU_IDS_ERROR": {+ "kind": "assign"+ },+ "_accumulated_spec_types": {+ "kind": "def"+ },+ "_apply_igpu_host_reserve_mib": {+ "kind": "def"+ },+ "_arch_aliases": {+ "kind": "def"+ },+ "_args_place_tensors_on_cpu": {+ "kind": "def"+ },+ "_auto_mode_drops_mtp": {+ "kind": "def"+ },+ "_backfill_usage_from_timings": {+ "kind": "def"+ },+ "_build_ngram_mod_flags": {+ "kind": "def"+ },+ "_bundled_hip_present": {+ "kind": "def"+ },+ "_cached_candidate_matches_revision_size": {+ "kind": "def"+ },+ "_cached_colocated_split_main": {+ "kind": "def"+ },+ "_cached_complete_candidate": {+ "kind": "def"+ },+ "_cached_hf_snapshot_file": {+ "kind": "def"+ },+ "_cached_variant_candidates": {+ "kind": "def"+ },+ "_cached_variant_resolution": {+ "kind": "def"+ },+ "_canonicalize_spec_mode": {+ "kind": "def"+ },+ "_child_spec_env": {+ "kind": "def"+ },+ "_coerce_reasoning_effort": {+ "kind": "def"+ },+ "_companion_snapshot_sibling": {+ "kind": "def"+ },+ "_cpu_runtime_owner_alive": {+ "kind": "def"+ },+ "_device_selection_is_cpu": {+ "kind": "def"+ },+ "_diffusion_manual_ngl": {+ "kind": "def"+ },+ "_drafter_path_kind": {+ "kind": "def"+ },+ "_drafter_set_bytes": {+ "kind": "def"+ },+ "_effective_main_cache_types": {+ "kind": "def"+ },+ "_effective_spec_type": {+ "kind": "def"+ },+ "_emitted_n_batch": {+ "kind": "def"+ },+ "_env_main_cache_type_for_budget": {+ "kind": "def"+ },+ "_env_places_tensors_on_cpu": {+ "kind": "def"+ },+ "_extra_args_device": {+ "kind": "def"+ },+ "_extra_args_draft_cache_types": {+ "kind": "def"+ },+ "_extra_args_draft_device": {+ "kind": "def"+ },+ "_extra_args_draft_device_pin": {+ "kind": "def"+ },+ "_extra_args_draft_offloaded_to_cpu": {+ "kind": "def"+ },+ "_extra_args_main_cache_type_for_budget": {+ "kind": "def"+ },+ "_extra_args_main_device": {+ "kind": "def"+ },+ "_extra_args_mtp_draft_path": {+ "kind": "def"+ },+ "_extra_args_n_ubatch": {+ "kind": "def"+ },+ "_extra_args_requests_dflash": {+ "kind": "def"+ },+ "_extra_args_requests_dspark": {+ "kind": "def"+ },+ "_extra_args_requests_mtp": {+ "kind": "def"+ },+ "_extra_args_requests_separate_draft": {+ "kind": "def"+ },+ "_extra_args_set_any_flag": {+ "kind": "def"+ },+ "_extra_args_set_spec_type": {+ "kind": "def"+ },+ "_extra_args_spec_draft_n_max": {+ "kind": "def"+ },+ "_extract_model_size_b": {+ "kind": "def"+ },+ "_extract_reasoning_effort_levels": {+ "kind": "def"+ },+ "_fetch_swa_entry_from_hf": {+ "kind": "def"+ },+ "_finalize_reasoning_only_cumulative": {+ "kind": "def"+ },+ "_flash_attn_enabled_from_args": {+ "kind": "def"+ },+ "_gguf_active_tool_names": {+ "kind": "def"+ },+ "_gguf_extra_shards": {+ "kind": "def"+ },+ "_gguf_files_for_variant": {+ "kind": "def"+ },+ "_gguf_has_genuine_tool_signal": {+ "kind": "def"+ },+ "_gguf_rehearsal_signal_pos": {+ "kind": "def"+ },+ "_gguf_snapshot_files": {+ "kind": "def"+ },+ "_held_rehearsal_tail_len": {+ "kind": "def"+ },+ "_hf_endpoint_host": {+ "kind": "def"+ },+ "_hf_env_offline": {+ "kind": "def"+ },+ "_hf_offline_if_unreachable": {+ "kind": "def"+ },+ "_hf_offline_if_unreachable_for": {+ "kind": "def"+ },+ "_hf_repo_from_url": {+ "kind": "def"+ },+ "_hf_unreachable": {+ "kind": "def"+ },+ "_hub_cache_dir_for_snapshot_path": {+ "kind": "def"+ },+ "_hub_download_blocks_gguf_load": {+ "kind": "def"+ },+ "_hub_download_in_flight": {+ "kind": "def"+ },+ "_is_big_endian_gguf_path": {+ "kind": "def"+ },+ "_is_companion_gguf_path": {+ "kind": "def"+ },+ "_is_dflash_drafter_path": {+ "kind": "def"+ },+ "_is_dspark_drafter_path": {+ "kind": "def"+ },+ "_is_external_link": {+ "kind": "def"+ },+ "_is_gemma_mtp_family": {+ "kind": "def"+ },+ "_is_gemma_mtp_name": {+ "kind": "def"+ },+ "_is_mtp_model_name": {+ "kind": "def"+ },+ "_is_mtp_only_drafter_path": {+ "kind": "def"+ },+ "_is_positive_int": {+ "kind": "def"+ },+ "_is_rehearsal_prefix": {+ "kind": "def"+ },+ "_is_root_dflash_drafter_path": {+ "kind": "def"+ },+ "_kv_bytes_per_elem": {+ "kind": "def"+ },+ "_kv_cache_cell_layout": {+ "kind": "def"+ },+ "_kv_offload_from_args": {+ "kind": "def"+ },+ "_kv_unified_from_args": {+ "kind": "def"+ },+ "_lib_dir_has_ggml_backend": {+ "kind": "def"+ },+ "_llama_lib_dir": {+ "kind": "def"+ },+ "_load_swa_cache": {+ "kind": "def"+ },+ "_metal_device_is_paravirtual": {+ "kind": "def"+ },+ "_mla_mtp_auto_enabled": {+ "kind": "def"+ },+ "_native_linux_system_rocm_lib_dirs": {+ "kind": "def"+ },+ "_pad_kv_cells": {+ "kind": "def"+ },+ "_paravirtual_draft_ngl_flag": {+ "kind": "def"+ },+ "_paravirtual_mmproj_pinnable": {+ "kind": "def"+ },+ "_paravirtual_probe_answered": {+ "kind": "def"+ },+ "_paravirtual_split_mode_pin": {+ "kind": "def"+ },+ "_paravirtual_strip_gpu_overrides": {+ "kind": "def"+ },+ "_period_from_layer_types": {+ "kind": "def"+ },+ "_pick_mmproj": {+ "kind": "def"+ },+ "_pipeline_parallel_disabled_by_args": {+ "kind": "def"+ },+ "_planned_main_cache_types": {+ "kind": "def"+ },+ "_probe_dns_dead": {+ "kind": "def"+ },+ "_quant_label_for_endian": {+ "kind": "def"+ },+ "_resolve_llama_binary": {+ "kind": "def"+ },+ "_resolve_repo_id_casing": {+ "kind": "def"+ },+ "_resolve_swa_entry_from_transformers": {+ "kind": "def"+ },+ "_resolve_swa_pattern": {+ "kind": "def"+ },+ "_save_swa_cache": {+ "kind": "def"+ },+ "_scale_diffusion_required_gb": {+ "kind": "def"+ },+ "_shim_supports_ngl": {+ "kind": "def"+ },+ "_should_suppress_forced_no_tool_output": {+ "kind": "def"+ },+ "_snapshot_dir_of": {+ "kind": "def"+ },+ "_snapshot_has_all_shards": {+ "kind": "def"+ },+ "_sniff_text_tool_name": {+ "kind": "def"+ },+ "_source_declares_option": {+ "kind": "def"+ },+ "_strip_flag_pairs": {+ "kind": "def"+ },+ "_swa_cache_path": {+ "kind": "def"+ },+ "_swa_entry_from_config_obj": {+ "kind": "def"+ },+ "_swa_entry_from_layer_types": {+ "kind": "def"+ },+ "_swa_full_from_args_or_env": {+ "kind": "def"+ },+ "_sweep_abandoned_cpu_runtimes": {+ "kind": "def"+ },+ "_with_gguf_load_marker": {+ "kind": "def"+ },+ "_without_subsequence": {+ "kind": "def"+ },+ "_wsl_system_rocm_lib_dirs": {+ "kind": "def"+ },+ "cached_gguf_for_load": {+ "kind": "def"+ },+ "chat_load_active": {+ "kind": "def"+ },+ "chat_load_in_flight": {+ "kind": "def"+ },+ "classify_gpu_offload_lines": {+ "kind": "def"+ },+ "detect_reasoning_flags": {+ "kind": "def"+ },+ "gguf_load_in_flight": {+ "kind": "def"+ },+ "hf_gguf_load_in_flight": {+ "kind": "def"+ },+ "logger": {+ "kind": "assign"+ },+ "paravirtual_normalized_request": {+ "kind": "def"+ },+ "zero_vram_chat_load": {+ "kind": "def"+ }+ }+ },+ "core.inference.safetensors_agentic": {+ "symbols": {+ "_FUNCTION_SIGNAL_RE": {+ "kind": "assign"+ },+ "_MAX_BARE_JSON_BUFFER": {+ "kind": "assign"+ },+ "_MAX_BUFFER_CHARS": {+ "kind": "assign"+ },+ "_MAX_TOOL_CALLS_PER_TURN": {+ "kind": "assign"+ },+ "_MISTRAL_RENDER_NAME_RE": {+ "kind": "assign"+ },+ "_REHEARSAL_RENDER_NAME_RE": {+ "kind": "assign"+ },+ "_TOOL_CALL_NAME_RE": {+ "kind": "assign"+ },+ "_UNRESTRICTED_REHEARSAL_RE": {+ "kind": "assign"+ },+ "_accepts_output_callback": {+ "kind": "def"+ },+ "_active_tool_names": {+ "kind": "def"+ },+ "_call_single_turn": {+ "kind": "def"+ },+ "_coerce_arguments": {+ "kind": "def"+ },+ "_coerce_arguments_with_provenance": {+ "kind": "def"+ },+ "_detect_render_html_tool_start": {+ "kind": "def"+ },+ "_earliest_tool_signal": {+ "kind": "def"+ },+ "_has_genuine_tool_signal": {+ "kind": "def"+ },+ "_held_rehearsal_tail_len": {+ "kind": "def"+ },+ "_is_rehearsal_prefix": {+ "kind": "def"+ },+ "_looks_like_enabled_bare_json": {+ "kind": "def"+ },+ "_rehearsal_name_start": {+ "kind": "def"+ },+ "_reprompt_intent_text": {+ "kind": "def"+ },+ "_status_for_tool": {+ "kind": "def"+ },+ "_strip_tool_markup_final": {+ "kind": "def"+ },+ "_tool_event_provenance": {+ "kind": "def"+ },+ "logger": {+ "kind": "assign"+ },+ "run_safetensors_tool_loop": {+ "kind": "def"+ },+ "strip_tool_markup_streaming": {+ "kind": "def"+ }+ }+ },+ "core.inference.tool_call_parser": {+ "compiled": {+ "INTENT_SIGNAL": "\"(?im)(\\\\b(i['\\\\u2019](ll|m going to|m gonna)|i am (going to|gonna)|i will|i shall)\\\\b(?!\\\\s+(?:not|never)\\\\b)(?!\\\\s+(?:do(?:ing)?\\\\s+my\\\\s+best|try\\\\s+my\\\\s+best|be\\\\s+(?:able|happy|glad)\\\\s+to\\\\b|assist\\\\b|help\\\\s+you\\\\b(?!\\\\s+(?:search|check|look|find|fetch|get|call|use|run|query|invoke|analy[sz]e|review|inspect|read|gather|examine|retrieve|browse|consult|verify|confirm|compute|calculate|determine|identify|render))|give\\\\s+you\\\\s+accurate\\\\b))|\\\\b(?:let me|allow me)\\\\b(?!\\\\s+(?:not|never|know)\\\\b)(?!\\\\s+to\\\\s+(?:do(?:ing)?\\\\s+my\\\\s+best|try\\\\s+my\\\\s+best|be\\\\s+(?:able|happy|glad)\\\\s+to\\\\b|assist\\\\b|help\\\\s+you\\\\b(?!\\\\s+(?:search|check|look|find|fetch|get|call|use|run|query|invoke|analy[sz]e|review|inspect|read|gather|examine|retrieve|browse|consult|verify|confirm|compute|calculate|determine|identify|render))|give\\\\s+you\\\\s+accurate\\\\b))|(?:^|[.!?]\\\\s+)\\\\s*(?:the\\\\s+)?first\\\\s+step\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+(?:my|our)\\\\s+(?:plan|approach|step)\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+(?:i|we|let['’]?s|let us)\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+(?:search|check|look|find|fetch|get|call|use|run|query|invoke|analy[sz]e|review|inspect|read|gather|examine|retrieve|browse|consult|verify|confirm|compute|calculate|determine|identify|render)\\\\b|\\\\b(?:step \\\\d+:?|here['\\\\u2019]?s (?:my |the |a )?(?:plan|approach))|\\\\b(?:now i|next i)\\\\b)\" flags=42",+ "_ATTR_FUNC_OPEN_RE": "'<function\\\\s+name=\"' flags=32",+ "_BARE_JSON_NAME_RE": "'\"name\"\\\\s*:\\\\s*\"([^\"]+)\"' flags=32",+ "_DEEPSEEK_BEGIN_RE": "'<|(?:tool▁calls▁begin|tool_calls_begin|tool calls begin|tool\\\\\\\\_calls\\\\\\\\_begin|tool▁calls)|>' flags=32",+ "_DEEPSEEK_R1_CLOSE_RE": "'```[\\\\s\\\\r\\\\n]*<|tool▁call▁end|>' flags=32",+ "_EMBEDDED_MARKER_RE": "'<|(?:tool▁calls▁begin|tool_calls_begin|tool calls begin|tool\\\\\\\\_calls\\\\\\\\_begin|tool▁calls)|>|<\\\\|tool_calls_section_begin\\\\|>|<\\\\|tool_call_begin\\\\|>' flags=32",+ "_FUNC_CLOSE_TAG_RE": "'</function>' flags=32",+ "_GEMMA_BARE_TC_PREFIX_RE": "'(?<!\\\\w)call\\\\s*(?::\\\\s*[\\\\w\\\\.\\\\-]*)?$' flags=32",+ "_GEMMA_BARE_TC_RE": "'(?<!\\\\w)call\\\\s*:\\\\s*([\\\\w\\\\.\\\\-]+)\\\\s*\\\\{' flags=32",+ "_GEMMA_KEY_RE": "'\\\\s*([A-Za-z_][\\\\w.\\\\-]*)\\\\s*:' flags=32",+ "_GEMMA_TC_RE": "'<\\\\|tool_call>\\\\s*call\\\\s*:\\\\s*([\\\\w\\\\.\\\\-]+)\\\\s*\\\\{' flags=32",+ "_GLM_JSON_NUMERIC_RE": "'-?\\\\d+(?:\\\\.\\\\d+)?(?:[eE][+-]?\\\\d+)?' flags=32",+ "_GLM_TC_OPEN_RE": "'<tool_call>\\\\s*([\\\\w.\\\\-]+)\\\\s*(?=\\\\n|<arg_key>|</tool_call>)' flags=32",+ "_KIMI_ID_RE": "'^(?:functions\\\\.)?([\\\\w\\\\.\\\\-]+)(?::(\\\\d+))?$' flags=32",+ "_LLAMA3_CALL_CHAIN_RE": "'\\\\s*;\\\\s*([\\\\w\\\\.\\\\-]+)\\\\s*\\\\.\\\\s*call\\\\s*\\\\(' flags=32",+ "_LLAMA3_KEY_RE": "'\\\\w+' flags=32",+ "_LLAMA3_LIT_RE": "'true|false|null' flags=32",+ "_LLAMA3_NUM_RE": "'-?(?:\\\\d+(?:\\\\.\\\\d*)?|\\\\.\\\\d+)(?:[eE][+-]?\\\\d+)?(?![\\\\w.])' flags=32",+ "_LLAMA3_PY_CALL_HEAD_RE": "'\\\\s*([\\\\w\\\\.\\\\-]+)\\\\s*\\\\.\\\\s*call\\\\s*\\\\(' flags=32",+ "_LLAMA3_PY_CALL_RE": "'<\\\\|python_tag\\\\|>\\\\s*([\\\\w\\\\.\\\\-]+)\\\\s*\\\\.\\\\s*call\\\\s*\\\\(' flags=32",+ "_LLAMA3_WS_RE": "'\\\\s*' flags=32",+ "_MISTRAL_V11_NAME_RE": "'\\\\s*([\\\\w\\\\.\\\\-]+)\\\\s*' flags=32",+ "_OUTER_ENVELOPE_CLOSED_PATS[0]": "'<tool_call>(?:(?!<tool_call>).)*</tool_call>' flags=48",+ "_OUTER_ENVELOPE_CLOSED_PATS[1]": "'<function(?:=[\\\\w.\\\\-]+|\\\\s+name=\"[\\\\w.\\\\-]+\")>(?:(?!<function(?:=[\\\\w.\\\\-]+|\\\\s+name=\"[\\\\w.\\\\-]+\")>).)*</function>' flags=48",+ "_OUTER_ENVELOPE_CLOSED_PATS[2]": "'<\\\\|tool_call>.*?<tool_call\\\\|>' flags=48",+ "_OUTER_ENVELOPE_OPEN_RE": "'<tool_call>|<function(?:=|\\\\s+name=\")|<\\\\|tool_call>|<\\\\|python_tag\\\\|>(?=\\\\s*(?:\\\\{|[A-Za-z_][\\\\w.]*\\\\())' flags=32",+ "_TC_END_TAG_RE": "'</(?:tool_call|function)>' flags=32",+ "_TC_FUNC_CLOSE_RE": "'\\\\s*</function>\\\\s*$' flags=32",+ "_TC_FUNC_START_RE": "'<function(?:=([\\\\w\\\\.\\\\-]+)|\\\\s+name=\"([\\\\w\\\\.\\\\-]+)\")>\\\\s*' flags=32",+ "_TC_JSON_START_RE": "'<tool_call>\\\\s*\\\\{' flags=32",+ "_TC_PARAM_CLOSE_RE": "'\\\\s*</(?:parameter|param)>\\\\s*$' flags=32",+ "_TC_PARAM_START_RE": "'<(?:parameter|param)(?:=([\\\\w\\\\.\\\\-]+)|\\\\s+name=\"([\\\\w\\\\.\\\\-]+)\")>[^\\\\S\\\\n]*' flags=32",+ "_TOOL_ALL_PATS[0]": "'<tool_call>.*?</tool_call>' flags=48",+ "_TOOL_ALL_PATS[10]": "'<\\\\|tool_call>(?=\\\\s*call\\\\s*:|\\\\s*$).*$' flags=48",+ "_TOOL_ALL_PATS[11]": "'\\\\[TOOL_CALLS\\\\](?=\\\\s*(?:[\\\\[{]|[A-Za-z_][\\\\w.\\\\-]*(?:[\\\\[{]|\\\\s*$))|\\\\s*$).*$' flags=48",+ "_TOOL_ALL_PATS[12]": "'<\\\\|python_tag\\\\|>(?=\\\\s*(?:\\\\{|[A-Za-z_][\\\\w.]*\\\\()|\\\\s*$).*$' flags=48",+ "_TOOL_ALL_PATS[13]": "'<|(?:tool▁calls▁begin|tool_calls_begin|tool calls begin|tool\\\\\\\\_calls\\\\\\\\_begin|tool▁calls)|>(?=\\\\s*(?:<|tool▁call▁begin|>|function)|\\\\s*$).*$' flags=48",+ "_TOOL_ALL_PATS[14]": "'<|tool▁call▁begin|>(?=\\\\s*function|\\\\s*$).*$' flags=48",+ "_TOOL_ALL_PATS[15]": "'<\\\\|tool_calls_section_begin\\\\|>(?=\\\\s*<\\\\|tool_call_begin\\\\|>|\\\\s*$).*$' flags=48",+ "_TOOL_ALL_PATS[16]": "'<\\\\|tool_call_begin\\\\|>(?=\\\\s*[A-Za-z_][\\\\w.\\\\-]*:\\\\d|\\\\s*$).*$' flags=48",+ "_TOOL_ALL_PATS[1]": "'<function(?:=[\\\\w.\\\\-]+|\\\\s+name=\"[\\\\w.\\\\-]+\")>(?:(?!<function(?:=[\\\\w.\\\\-]+|\\\\s+name=\"[\\\\w.\\\\-]+\")>).)*</function>' flags=48",+ "_TOOL_ALL_PATS[2]": "'<\\\\|tool_call>.*?<tool_call\\\\|>' flags=48",+ "_TOOL_ALL_PATS[3]": "'\\\\[TOOL_CALLS\\\\]\\\\s*\\\\[.*?\\\\](?:\\\\s*</s>)?' flags=48",+ "_TOOL_ALL_PATS[4]": "'\\\\[TOOL_CALLS\\\\]\\\\s*[\\\\w\\\\.\\\\-]+\\\\s*(?:\\\\[ARGS\\\\])?\\\\s*\\\\{.*?\\\\}' flags=48",+ "_TOOL_ALL_PATS[5]": "'<|(?:tool▁calls▁begin|tool_calls_begin|tool calls begin|tool\\\\\\\\_calls\\\\\\\\_begin|tool▁calls)|>.*?<|tool▁calls▁end|>' flags=48",+ "_TOOL_ALL_PATS[6]": "'<\\\\|tool_calls_section_begin\\\\|>.*?<\\\\|tool_calls_section_end\\\\|>' flags=48",+ "_TOOL_ALL_PATS[7]": "'<\\\\|tool_call_begin\\\\|>.*?<\\\\|tool_call_end\\\\|>' flags=48",+ "_TOOL_ALL_PATS[8]": "'<tool_call>.*$' flags=48",+ "_TOOL_ALL_PATS[9]": "'<function(?:=[\\\\w.\\\\-]+|\\\\s+name=\"[\\\\w.\\\\-]+\")>.*$' flags=48",+ "_TOOL_CLOSED_PATS[0]": "'<tool_call>.*?</tool_call>' flags=48",+ "_TOOL_CLOSED_PATS[1]": "'<function(?:=[\\\\w.\\\\-]+|\\\\s+name=\"[\\\\w.\\\\-]+\")>(?:(?!<function(?:=[\\\\w.\\\\-]+|\\\\s+name=\"[\\\\w.\\\\-]+\")>).)*</function>' flags=48",+ "_TOOL_CLOSED_PATS[2]": "'<\\\\|tool_call>.*?<tool_call\\\\|>' flags=48",+ "_TOOL_CLOSED_PATS[3]": "'\\\\[TOOL_CALLS\\\\]\\\\s*\\\\[.*?\\\\](?:\\\\s*</s>)?' flags=48",+ "_TOOL_CLOSED_PATS[4]": "'\\\\[TOOL_CALLS\\\\]\\\\s*[\\\\w\\\\.\\\\-]+\\\\s*(?:\\\\[ARGS\\\\])?\\\\s*\\\\{.*?\\\\}' flags=48",+ "_TOOL_CLOSED_PATS[5]": "'<|(?:tool▁calls▁begin|tool_calls_begin|tool calls begin|tool\\\\\\\\_calls\\\\\\\\_begin|tool▁calls)|>.*?<|tool▁calls▁end|>' flags=48",+ "_TOOL_CLOSED_PATS[6]": "'<\\\\|tool_calls_section_begin\\\\|>.*?<\\\\|tool_calls_section_end\\\\|>' flags=48",+ "_TOOL_CLOSED_PATS[7]": "'<\\\\|tool_call_begin\\\\|>.*?<\\\\|tool_call_end\\\\|>' flags=48"+ },+ "regexes": {+ "re.compile(\"(?im)(\\\\b(i['\\\\u2019](ll|m going to|m gonna)|i am (going to|gonna)|i will|i shall)\\\\b(?!\\\\s+(?:not|never)\\\\b)(?!\\\\s+\" + _HELP_OFFER + ')|\\\\b(?:let me|allow me)\\\\b(?!\\\\s+(?:not|never|know)\\\\b)(?!\\\\s+to\\\\s+' + _HELP_OFFER + \")|(?:^|[.!?]\\\\s+)\\\\s*(?:the\\\\s+)?first\\\\s+step\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+(?:my|our)\\\\s+(?:plan|approach|step)\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+(?:i|we|let['’]?s|let us)\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+\" + _ACTION_VERB + \"\\\\b|\\\\b(?:step \\\\d+:?|here['\\\\u2019]?s (?:my |the |a )?(?:plan|approach))|\\\\b(?:now i|next i)\\\\b)\")": 1,+ "re.compile('\"name\"\\\\s*:\\\\s*\"([^\"]+)\"')": 1,+ "re.compile('(?<!\\\\w)call\\\\s*(?::\\\\s*[\\\\w\\\\.\\\\-]*)?$')": 1,+ "re.compile('(?<!\\\\w)call\\\\s*:\\\\s*([\\\\w\\\\.\\\\-]+)\\\\s*\\\\{')": 1,+ "re.compile('-?(?:\\\\d+(?:\\\\.\\\\d*)?|\\\\.\\\\d+)(?:[eE][+-]?\\\\d+)?(?![\\\\w.])')": 1,+ "re.compile('-?\\\\d+(?:\\\\.\\\\d+)?(?:[eE][+-]?\\\\d+)?')": 1,+ "re.compile('<(?:parameter|param)(?:=([\\\\w\\\\.\\\\-]+)|\\\\s+name=\"([\\\\w\\\\.\\\\-]+)\")>[^\\\\S\\\\n]*')": 1,+ "re.compile('</(?:tool_call|function)>')": 1,+ "re.compile('</function>')": 1,+ "re.compile('<\\\\|python_tag\\\\|>(?=\\\\s*(?:\\\\{|[A-Za-z_][\\\\w.]*\\\\()|\\\\s*$).*$', re.DOTALL)": 1,+ "re.compile('<\\\\|python_tag\\\\|>\\\\s*([\\\\w\\\\.\\\\-]+)\\\\s*\\\\.\\\\s*call\\\\s*\\\\(')": 1,+ "re.compile('<\\\\|tool_call>(?=\\\\s*call\\\\s*:|\\\\s*$).*$', re.DOTALL)": 1,+ "re.compile('<\\\\|tool_call>.*?<tool_call\\\\|>', re.DOTALL)": 2,+ "re.compile('<\\\\|tool_call>\\\\s*call\\\\s*:\\\\s*([\\\\w\\\\.\\\\-]+)\\\\s*\\\\{')": 1,+ "re.compile('<\\\\|tool_call_begin\\\\|>(?=\\\\s*[A-Za-z_][\\\\w.\\\\-]*:\\\\d|\\\\s*$).*$', re.DOTALL)": 1,+ "re.compile('<\\\\|tool_call_begin\\\\|>.*?<\\\\|tool_call_end\\\\|>', re.DOTALL)": 1,+ "re.compile('<\\\\|tool_calls_section_begin\\\\|>(?=\\\\s*<\\\\|tool_call_begin\\\\|>|\\\\s*$).*$', re.DOTALL)": 1,+ "re.compile('<\\\\|tool_calls_section_begin\\\\|>.*?<\\\\|tool_calls_section_end\\\\|>', re.DOTALL)": 1,+ "re.compile('<function(?:=([\\\\w\\\\.\\\\-]+)|\\\\s+name=\"([\\\\w\\\\.\\\\-]+)\")>\\\\s*')": 1,+ "re.compile('<function(?:=[\\\\w.\\\\-]+|\\\\s+name=\"[\\\\w.\\\\-]+\")>(?:(?!<function(?:=[\\\\w.\\\\-]+|\\\\s+name=\"[\\\\w.\\\\-]+\")>).)*</function>', re.DOTALL)": 1,+ "re.compile('<function(?:=[\\\\w.\\\\-]+|\\\\s+name=\"[\\\\w.\\\\-]+\")>.*$', re.DOTALL)": 1,+ "re.compile('<function\\\\s+name=\"')": 1,+ "re.compile('<tool_call>(?:(?!<tool_call>).)*</tool_call>', re.DOTALL)": 1,+ "re.compile('<tool_call>.*$', re.DOTALL)": 1,+ "re.compile('<tool_call>.*?</tool_call>', re.DOTALL)": 1,+ "re.compile('<tool_call>\\\\s*([\\\\w.\\\\-]+)\\\\s*(?=\\\\n|<arg_key>|</tool_call>)')": 1,+ "re.compile('<tool_call>\\\\s*\\\\{')": 1,+ "re.compile('<tool_call>|<function(?:=|\\\\s+name=\")|<\\\\|tool_call>|<\\\\|python_tag\\\\|>(?=\\\\s*(?:\\\\{|[A-Za-z_][\\\\w.]*\\\\())')": 1,+ "re.compile('<|tool▁call▁begin|>(?=\\\\s*function|\\\\s*$).*$', re.DOTALL)": 1,+ "re.compile('\\\\[TOOL_CALLS\\\\](?=\\\\s*(?:[\\\\[{]|[A-Za-z_][\\\\w.\\\\-]*(?:[\\\\[{]|\\\\s*$))|\\\\s*$).*$', re.DOTALL)": 1,+ "re.compile('\\\\[TOOL_CALLS\\\\]\\\\s*[\\\\w\\\\.\\\\-]+\\\\s*(?:\\\\[ARGS\\\\])?\\\\s*\\\\{.*?\\\\}', re.DOTALL)": 1,+ "re.compile('\\\\[TOOL_CALLS\\\\]\\\\s*\\\\[.*?\\\\](?:\\\\s*</s>)?', re.DOTALL)": 1,+ "re.compile('\\\\s*')": 1,+ "re.compile('\\\\s*([A-Za-z_][\\\\w.\\\\-]*)\\\\s*:')": 1,+ "re.compile('\\\\s*([\\\\w\\\\.\\\\-]+)\\\\s*')": 1,+ "re.compile('\\\\s*([\\\\w\\\\.\\\\-]+)\\\\s*\\\\.\\\\s*call\\\\s*\\\\(')": 1,+ "re.compile('\\\\s*;\\\\s*([\\\\w\\\\.\\\\-]+)\\\\s*\\\\.\\\\s*call\\\\s*\\\\(')": 1,+ "re.compile('\\\\s*</(?:parameter|param)>\\\\s*$')": 1,+ "re.compile('\\\\w+')": 1,+ "re.compile('^(?:functions\\\\.)?([\\\\w\\\\.\\\\-]+)(?::(\\\\d+))?$')": 1,+ "re.compile('```[\\\\s\\\\r\\\\n]*' + re.escape(_DEEPSEEK_CALL_END))": 1,+ "re.compile('true|false|null')": 1,+ "re.compile(_DEEPSEEK_OPEN_RE_SRC + '(?=\\\\s*(?:<|tool▁call▁begin|>|function)|\\\\s*$).*$', re.DOTALL)": 1,+ "re.compile(_DEEPSEEK_OPEN_RE_SRC + '.*?<|tool▁calls▁end|>', re.DOTALL)": 1,+ "re.compile(_DEEPSEEK_OPEN_RE_SRC + '|' + re.escape(_KIMI_SECTION_BEGIN) + '|' + re.escape(_KIMI_CALL_BEGIN))": 1,+ "re.compile(_DEEPSEEK_OPEN_RE_SRC)": 1+ },+ "symbols": {+ "BUDGET_EXHAUSTED_NUDGE": {+ "kind": "assign"+ },+ "DUPLICATE_CALL_NUDGE": {+ "kind": "assign"+ },+ "INTENT_SIGNAL": {+ "kind": "assign"+ },+ "MAX_ACT_REPROMPTS": {+ "kind": "assign"+ },+ "NUDGE_TOOL_CALLS_STATUS": {+ "kind": "assign"+ },+ "RAG_MAX_SEARCHES_PER_TURN": {+ "kind": "assign"+ },+ "RAG_SEARCH_CAP_NUDGE": {+ "kind": "assign"+ },+ "RENDER_HTML_REPEAT_NUDGE": {+ "kind": "assign"+ },+ "REPROMPT_MAX_CHARS": {+ "kind": "assign"+ },+ "TOOL_ERROR_NUDGE": {+ "kind": "assign"+ },+ "TOOL_ERROR_PREFIXES": {+ "kind": "assign"+ },+ "TOOL_XML_SIGNALS": {+ "kind": "assign"+ },+ "_ACTION_VERB": {+ "kind": "assign"+ },+ "_ATTR_FUNC_OPEN_RE": {+ "kind": "assign"+ },+ "_BARE_JSON_NAME_RE": {+ "kind": "assign"+ },+ "_DEEPSEEK_BEGIN_RE": {+ "kind": "assign"+ },+ "_DEEPSEEK_CALL_BEGIN": {+ "kind": "assign"+ },+ "_DEEPSEEK_CALL_END": {+ "kind": "assign"+ },+ "_DEEPSEEK_END": {+ "kind": "assign"+ },+ "_DEEPSEEK_OPEN_ALT": {+ "kind": "assign"+ },+ "_DEEPSEEK_OPEN_RE_SRC": {+ "kind": "assign"+ },+ "_DEEPSEEK_R1_CLOSE_RE": {+ "kind": "assign"+ },+ "_DEEPSEEK_R1_FENCE": {+ "kind": "assign"+ },+ "_DEEPSEEK_R1_FUNC_MARKER": {+ "kind": "assign"+ },+ "_DEEPSEEK_SEP": {+ "kind": "assign"+ },+ "_EMBEDDED_MARKER_RE": {+ "kind": "assign"+ },+ "_FUNC_CLOSE_TAG_RE": {+ "kind": "assign"+ },+ "_GEMMA_ANCHOR_CLOSERS": {+ "kind": "assign"+ },+ "_GEMMA_BARE_TC_PREFIX_RE": {+ "kind": "assign"+ },+ "_GEMMA_BARE_TC_RE": {+ "kind": "assign"+ },+ "_GEMMA_KEY_RE": {+ "kind": "assign"+ },+ "_GEMMA_STR_BEGIN": {+ "kind": "assign"+ },+ "_GEMMA_STR_END": {+ "kind": "assign"+ },+ "_GEMMA_TC_END": {+ "kind": "assign"+ },+ "_GEMMA_TC_RE": {+ "kind": "assign"+ },+ "_GLM_ARG_KEY_CLOSE": {+ "kind": "assign"+ },+ "_GLM_ARG_KEY_OPEN": {+ "kind": "assign"+ },+ "_GLM_ARG_VAL_CLOSE": {+ "kind": "assign"+ },+ "_GLM_ARG_VAL_OPEN": {+ "kind": "assign"+ },+ "_GLM_JSON_NUMERIC_RE": {+ "kind": "assign"+ },+ "_GLM_TC_CLOSE": {+ "kind": "assign"+ },+ "_GLM_TC_OPEN_RE": {+ "kind": "assign"+ },+ "_HELP_OFFER": {+ "kind": "assign"+ },+ "_KIMI_ARG_BEGIN": {+ "kind": "assign"+ },+ "_KIMI_CALL_BEGIN": {+ "kind": "assign"+ },+ "_KIMI_CALL_END": {+ "kind": "assign"+ },+ "_KIMI_ID_RE": {+ "kind": "assign"+ },+ "_KIMI_SECTION_BEGIN": {+ "kind": "assign"+ },+ "_KIMI_SECTION_END": {+ "kind": "assign"+ },+ "_LLAMA3_BARE_JSON_SENTINELS": {+ "kind": "assign"+ },+ "_LLAMA3_CALL_CHAIN_RE": {+ "kind": "assign"+ },+ "_LLAMA3_HEADER_ROLES": {+ "kind": "assign"+ },+ "_LLAMA3_KEY_RE": {+ "kind": "assign"+ },+ "_LLAMA3_LIT_RE": {+ "kind": "assign"+ },+ "_LLAMA3_NUM_RE": {+ "kind": "assign"+ },+ "_LLAMA3_PYTHON_TAG": {+ "kind": "assign"+ },+ "_LLAMA3_PY_CALL_HEAD_RE": {+ "kind": "assign"+ },+ "_LLAMA3_PY_CALL_RE": {+ "kind": "assign"+ },+ "_LLAMA3_WS_RE": {+ "kind": "assign"+ },+ "_MISTRAL_ARGS_MARKER": {+ "kind": "assign"+ },+ "_MISTRAL_CALL_ID_MARKER": {+ "kind": "assign"+ },+ "_MISTRAL_THINK_CLOSE": {+ "kind": "assign"+ },+ "_MISTRAL_THINK_OPEN": {+ "kind": "assign"+ },+ "_MISTRAL_TRIGGER": {+ "kind": "assign"+ },+ "_MISTRAL_V11_NAME_RE": {+ "kind": "assign"+ },+ "_OUTER_ENVELOPE_CLOSED_PATS": {+ "kind": "assign"+ },+ "_OUTER_ENVELOPE_OPEN_RE": {+ "kind": "assign"+ },+ "_REPEAT_LEAD_PUNCT": {+ "kind": "assign"+ },+ "_REPEAT_TRAIL_PUNCT": {+ "kind": "assign"+ },+ "_TC_END_TAG_RE": {+ "kind": "assign"+ },+ "_TC_FUNC_CLOSE_RE": {+ "kind": "assign"+ },+ "_TC_FUNC_START_RE": {+ "kind": "assign"+ },+ "_TC_JSON_START_RE": {+ "kind": "assign"+ },+ "_TC_PARAM_CLOSE_RE": {+ "kind": "assign"+ },+ "_TC_PARAM_START_RE": {+ "kind": "assign"+ },+ "_TOOL_ALL_PATS": {+ "kind": "assign"+ },+ "_TOOL_CLOSED_PATS": {+ "kind": "assign"+ },+ "_balanced_brace_end": {+ "kind": "assign"+ },+ "_balanced_bracket_end": {+ "decorators": [],+ "kind": "def",+ "signature": "src: str, start: int"+ },+ "_bare_json_call_shaped": {+ "decorators": [],+ "kind": "def",+ "signature": "obj"+ },+ "_consume_mistral_call": {+ "decorators": [],+ "kind": "def",+ "signature": "obj_text: str, out: list[dict], id_offset: int"+ },+ "_disabled_gemma_call_end_containing_signal": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, enabled_tool_names: Optional[set]"+ },+ "_find_outside_json_strings": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, needle: str, start: int"+ },+ "_first_foreign_tool_signal": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str"+ },+ "_gemma_balanced_brace_end": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, brace_pos: int, hard_stop: int"+ },+ "_gemma_body_brace_end": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, brace_pos: int"+ },+ "_gemma_call_is_anchored": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, start: int, floor: int"+ },+ "_gemma_coerce_scalar": {+ "decorators": [],+ "kind": "def",+ "signature": "raw: str"+ },+ "_gemma_parse_array": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, start: int"+ },+ "_gemma_parse_mapping": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, start: int"+ },+ "_gemma_parse_stripped_body": {+ "decorators": [],+ "kind": "def",+ "signature": "body: str"+ },+ "_gemma_parse_value": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, i: int, *, in_mapping: bool=False"+ },+ "_gemma_strip_quoted_leaves": {+ "decorators": [],+ "kind": "def",+ "signature": "value: Any"+ },+ "_glm_value_close": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, vs: int, *, strict: bool=False"+ },+ "_inside_open_parameter": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, pos: int"+ },+ "_leading_json_value_end": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str"+ },+ "_llama3_kv_value": {+ "decorators": [],+ "kind": "def",+ "signature": "body: str, p: int, n: int"+ },+ "_marker_inside_leading_envelope": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, enabled_tool_names: Optional[set]=None"+ },+ "_mistral_region_end": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, idx: int"+ },+ "_normalize_for_repeat": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str"+ },+ "_parse_bare_rehearsals": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, *, id_offset: int=0, enabled_tool_names: Optional[set]=None"+ },+ "_parse_deepseek_tool_calls": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, *, id_offset: int, allow_incomplete: bool=True"+ },+ "_parse_function_xml": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, *, id_offset: int, allow_incomplete: bool=True"+ },+ "_parse_gemma_tool_calls": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, *, id_offset: int, allow_incomplete: bool=True, enabled_tool_names: Optional[set]=None"+ },+ "_parse_glm_tool_calls": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, *, id_offset: int, allow_incomplete: bool=True"+ },+ "_parse_kimi_section_body": {+ "decorators": [],+ "kind": "def",+ "signature": "body: str, *, id_offset: int, allow_incomplete: bool=True"+ },+ "_parse_kimi_tool_calls": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, *, id_offset: int, allow_incomplete: bool=True"+ },+ "_parse_llama3_bare_json": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, *, id_offset: int, allow_incomplete: bool=True, enabled_tool_names: Optional[set]=None"+ },+ "_parse_llama3_kv_args": {+ "decorators": [],+ "kind": "def",+ "signature": "body: str"+ },+ "_parse_llama3_python_tag": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, *, id_offset: int, allow_incomplete: bool=True"+ },+ "_parse_mistral_array": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, start: int, id_offset: int, allow_incomplete: bool=True"+ },+ "_parse_mistral_tool_calls": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, *, id_offset: int, allow_incomplete: bool=True"+ },+ "_parse_tool_call_json": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, *, id_offset: int, allow_incomplete: bool=True"+ },+ "_signal_inside_leading_wrapperless_gemma": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, enabled_tool_names: Optional[set]"+ },+ "_skip_mistral_call_id": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, pos: int"+ },+ "_strip_function_xml_calls": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, *, final: bool"+ },+ "_strip_gemma_wrapperless_calls": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, enabled_tool_names: Optional[set]=None"+ },+ "_strip_glm_calls": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, *, final: bool"+ },+ "_strip_mistral_closed_calls": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str"+ },+ "_strip_mistral_reasoning": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str"+ },+ "_top_level_bare_json_name": {+ "decorators": [],+ "kind": "def",+ "signature": "probe: str"+ },+ "_trim_param_value": {+ "kind": "assign"+ },+ "_whole_content_is_json_value": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str"+ },+ "_xml_signal_inside_leading_bare_json": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str"+ },+ "_xml_signal_inside_leading_mistral": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str"+ },+ "has_tool_signal": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str"+ },+ "is_reprompt_repeat": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, previous: str"+ },+ "is_reprompt_restatement": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, previous: str"+ },+ "is_short_intent_without_action": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str"+ },+ "parse_tool_calls_from_text": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, *, id_offset: int=0, allow_incomplete: bool=True, enabled_tool_names: Optional[set]=None"+ },+ "reprompt_to_act_message": {+ "decorators": [],+ "kind": "def",+ "signature": "tool_hint: str"+ },+ "strip_leading_bare_json_call": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, enabled_tool_names: Optional[set]=None"+ },+ "strip_llama3_leading_sentinels": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str"+ },+ "strip_segment": {+ "decorators": [],+ "kind": "def",+ "signature": "segment: str, *, seg_final: bool, enabled_tool_names: Optional[set]=None"+ },+ "strip_tool_markup": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, *, final: bool=False, enabled_tool_names: Optional[set]=None"+ }+ }+ },+ "core.tool_healing": {+ "compiled": {+ "_CODE_SPAN_RE": "'^[ \\\\t]*(?:>[ \\\\t]*)*(?:```+[^`\\\\n]*|~~~+[^\\\\n]*)$.*?(?:^[ \\\\t]*(?:>[ \\\\t]*)*(?:```+|~~~+)[ \\\\t\\\\r]*$|\\\\Z)|``(?:[^`]|`(?!`))*?``|`[^`\\\\n]*`' flags=56",+ "_GEMMA_NEXT_KEY_RE": "'\\\\s*[A-Za-z_][\\\\w.\\\\-]*\\\\s*:' flags=32",+ "_MISTRAL_ARRAY_RE": "'\\\\[TOOL_CALLS\\\\]\\\\s*(?=\\\\[)' flags=32",+ "_MISTRAL_BRACKET_RE": "'\\\\[TOOL_CALLS\\\\]\\\\s*([\\\\w-]+)(?:\\\\[CALL_ID\\\\][\\\\w-]+)?(?:\\\\[ARGS\\\\])?\\\\s*(?=\\\\{)' flags=32",+ "_REHEARSAL_CLOSED_STRIP_RE": "'(?<!\\\\[CALL_ID\\\\])\\\\b([\\\\w-]+)\\\\[ARGS\\\\]\\\\s*\\\\{[^{}]*(?:\\\\{[^{}]*\\\\}[^{}]*)*\\\\}' flags=48",+ "_REHEARSAL_RE": "'(?<!\\\\[CALL_ID\\\\])\\\\b([\\\\w-]+)\\\\[ARGS\\\\]\\\\s*(?=\\\\{)' flags=32",+ "_REHEARSAL_TAIL_STRIP_RE": "'(?<!\\\\[CALL_ID\\\\])\\\\b([\\\\w-]+)\\\\[ARGS\\\\]\\\\s*(?:\\\\{.*)?$' flags=48",+ "_TC_END_TAG_RE": "'</tool_call>|<\\\\|end_message\\\\|>' flags=32",+ "_TC_FUNC_CLOSED_PAT": "'<function=[\\\\w-]+>.*?</function>' flags=48",+ "_TC_FUNC_CLOSE_RE": "'\\\\s*</function>\\\\s*$' flags=32",+ "_TC_FUNC_START_RE": "'<function=([\\\\w-]+)>\\\\s*' flags=32",+ "_TC_GEMMA_CLOSED_PAT": "'<\\\\|tool_call>.*?<tool_call\\\\|>' flags=48",+ "_TC_GEMMA_END_TAG_RE": "'<tool_call\\\\|>' flags=32",+ "_TC_GEMMA_START_RE": "'<\\\\|tool_call>\\\\s*call\\\\s*:\\\\s*([\\\\w.\\\\-]+)\\\\s*\\\\{' flags=32",+ "_TC_JSON_CLOSED_PAT": "'<tool_call>.*?</tool_call>' flags=48",+ "_TC_JSON_START_RE": "'(?:<tool_call>|<\\\\|content_invoke_tool_json\\\\|>)\\\\s*\\\\{' flags=32",+ "_TC_PARAM_CLOSE_RE": "'\\\\s*</parameter>\\\\s*$' flags=32",+ "_TC_PARAM_START_RE": "'<parameter=([\\\\w-]+)>[^\\\\S\\\\n]*' flags=32",+ "_THINK_CLOSE_RE": "'</think>|\\\\[/THINK\\\\]' flags=32",+ "_THINK_OPEN_RE": "'<think>|\\\\[THINK\\\\]' flags=32",+ "_THINK_TAG_RE": "'<think>.*?(?:</think>|$)|\\\\[THINK\\\\].*?(?:\\\\[/THINK\\\\]|$)' flags=48",+ "_TOOL_ALL_PATS[0]": "'<tool_call>.*?</tool_call>' flags=48",+ "_TOOL_ALL_PATS[10]": "'\\\\[TOOL_CALLS\\\\].*$' flags=48",+ "_TOOL_ALL_PATS[11]": "'(?<!\\\\[CALL_ID\\\\])\\\\b([\\\\w-]+)\\\\[ARGS\\\\]\\\\s*(?:\\\\{.*)?$' flags=48",+ "_TOOL_ALL_PATS[1]": "'<\\\\|tool_call>.*?<tool_call\\\\|>' flags=48",+ "_TOOL_ALL_PATS[2]": "'<tool_call\\\\|>' flags=32",+ "_TOOL_ALL_PATS[3]": "'<function=[\\\\w-]+>.*?</function>' flags=48",+ "_TOOL_ALL_PATS[4]": "'\\\\[TOOL_CALLS\\\\]\\\\s*[\\\\w-]+(?:\\\\[CALL_ID\\\\][\\\\w-]+)?(?:\\\\[ARGS\\\\])?\\\\s*\\\\{[^{}]*(?:\\\\{[^{}]*\\\\}[^{}]*)*\\\\}' flags=48",+ "_TOOL_ALL_PATS[5]": "'(?<!\\\\[CALL_ID\\\\])\\\\b([\\\\w-]+)\\\\[ARGS\\\\]\\\\s*\\\\{[^{}]*(?:\\\\{[^{}]*\\\\}[^{}]*)*\\\\}' flags=48",+ "_TOOL_ALL_PATS[6]": "'\\\\[/TOOL_CALLS\\\\]' flags=32",+ "_TOOL_ALL_PATS[7]": "'<tool_call>.*$' flags=48",+ "_TOOL_ALL_PATS[8]": "'<\\\\|tool_call>.*$' flags=48",+ "_TOOL_ALL_PATS[9]": "'<function=[\\\\w-]+>.*$' flags=48",+ "_TOOL_CLOSED_BLOCK_PATS[0]": "'<tool_call>.*?</tool_call>' flags=48",+ "_TOOL_CLOSED_BLOCK_PATS[1]": "'<function=[\\\\w-]+>.*?</function>' flags=48",+ "_TOOL_CLOSED_PATS[0]": "'<tool_call>.*?</tool_call>' flags=48",+ "_TOOL_CLOSED_PATS[1]": "'<\\\\|tool_call>.*?<tool_call\\\\|>' flags=48",+ "_TOOL_CLOSED_PATS[2]": "'<tool_call\\\\|>' flags=32",+ "_TOOL_CLOSED_PATS[3]": "'<function=[\\\\w-]+>.*?</function>' flags=48",+ "_TOOL_CLOSED_PATS[4]": "'\\\\[TOOL_CALLS\\\\]\\\\s*[\\\\w-]+(?:\\\\[CALL_ID\\\\][\\\\w-]+)?(?:\\\\[ARGS\\\\])?\\\\s*\\\\{[^{}]*(?:\\\\{[^{}]*\\\\}[^{}]*)*\\\\}' flags=48",+ "_TOOL_CLOSED_PATS[5]": "'(?<!\\\\[CALL_ID\\\\])\\\\b([\\\\w-]+)\\\\[ARGS\\\\]\\\\s*\\\\{[^{}]*(?:\\\\{[^{}]*\\\\}[^{}]*)*\\\\}' flags=48",+ "_TOOL_CLOSED_PATS[6]": "'\\\\[/TOOL_CALLS\\\\]' flags=32",+ "_TOOL_OPEN_XML_TAIL_PATS[0]": "'<tool_call>.*$' flags=48",+ "_TOOL_OPEN_XML_TAIL_PATS[1]": "'<\\\\|tool_call>.*$' flags=48",+ "_TOOL_OPEN_XML_TAIL_PATS[2]": "'<function=[\\\\w-]+>.*$' flags=48"+ },+ "regexes": {+ "re.compile('(?:<tool_call>|<\\\\|content_invoke_tool_json\\\\|>)\\\\s*\\\\{')": 1,+ "re.compile('(?<!\\\\[CALL_ID\\\\])\\\\b([\\\\w-]+)\\\\[ARGS\\\\]\\\\s*' + _BRACKETED_JSON_ONE_LEVEL, re.DOTALL)": 1,+ "re.compile('(?<!\\\\[CALL_ID\\\\])\\\\b([\\\\w-]+)\\\\[ARGS\\\\]\\\\s*(?:\\\\{.*)?$', re.DOTALL)": 1,+ "re.compile('(?<!\\\\[CALL_ID\\\\])\\\\b([\\\\w-]+)\\\\[ARGS\\\\]\\\\s*(?=\\\\{)')": 1,+ "re.compile('</think>|\\\\[/THINK\\\\]')": 1,+ "re.compile('</tool_call>|<\\\\|end_message\\\\|>')": 1,+ "re.compile('<\\\\|tool_call>.*$', re.DOTALL)": 1,+ "re.compile('<\\\\|tool_call>.*?<tool_call\\\\|>', re.DOTALL)": 1,+ "re.compile('<\\\\|tool_call>\\\\s*call\\\\s*:\\\\s*([\\\\w.\\\\-]+)\\\\s*\\\\{')": 1,+ "re.compile('<function=([\\\\w-]+)>\\\\s*')": 1,+ "re.compile('<function=[\\\\w-]+>.*$', re.DOTALL)": 1,+ "re.compile('<function=[\\\\w-]+>.*?</function>', re.DOTALL)": 1,+ "re.compile('<parameter=([\\\\w-]+)>[^\\\\S\\\\n]*')": 1,+ "re.compile('<think>.*?(?:</think>|$)|\\\\[THINK\\\\].*?(?:\\\\[/THINK\\\\]|$)', re.DOTALL)": 1,+ "re.compile('<think>|\\\\[THINK\\\\]')": 1,+ "re.compile('<tool_call>.*$', re.DOTALL)": 1,+ "re.compile('<tool_call>.*?</tool_call>', re.DOTALL)": 1,+ "re.compile('<tool_call\\\\|>')": 2,+ "re.compile('\\\\[/TOOL_CALLS\\\\]')": 1,+ "re.compile('\\\\[TOOL_CALLS\\\\].*$', re.DOTALL)": 1,+ "re.compile('\\\\[TOOL_CALLS\\\\]\\\\s*(?=\\\\[)')": 1,+ "re.compile('\\\\[TOOL_CALLS\\\\]\\\\s*([\\\\w-]+)(?:\\\\[CALL_ID\\\\][\\\\w-]+)?(?:\\\\[ARGS\\\\])?\\\\s*(?=\\\\{)')": 1,+ "re.compile('\\\\[TOOL_CALLS\\\\]\\\\s*[\\\\w-]+(?:\\\\[CALL_ID\\\\][\\\\w-]+)?(?:\\\\[ARGS\\\\])?\\\\s*' + _BRACKETED_JSON_ONE_LEVEL, re.DOTALL)": 1,+ "re.compile('\\\\s*</function>\\\\s*$')": 1,+ "re.compile('\\\\s*</parameter>\\\\s*$')": 1,+ "re.compile('\\\\s*[A-Za-z_][\\\\w.\\\\-]*\\\\s*:')": 1,+ "re.compile('^[ \\\\t]*(?:>[ \\\\t]*)*(?:```+[^`\\\\n]*|~~~+[^\\\\n]*)$.*?(?:^[ \\\\t]*(?:>[ \\\\t]*)*(?:```+|~~~+)[ \\\\t\\\\r]*$|\\\\Z)|``(?:[^`]|`(?!`))*?``|`[^`\\\\n]*`', re.DOTALL | re.MULTILINE)": 1,+ "re.match('\\\\s*</tool_call>', content[span_end:])": 1,+ "re.match('\\\\s*\\\\[/TOOL_CALLS\\\\]', content[end:])": 1,+ "re.search('<tool_call>\\\\s*$', content[:span_start])": 1+ },+ "symbols": {+ "_BRACKETED_JSON_ONE_LEVEL": {+ "kind": "assign"+ },+ "_CODE_SPAN_RE": {+ "kind": "assign"+ },+ "_FUNC_CLOSE_TAG": {+ "kind": "assign"+ },+ "_GEMMA_NEXT_KEY_RE": {+ "kind": "assign"+ },+ "_GEMMA_QUOTE": {+ "kind": "assign"+ },+ "_MAX_BRACKET_SCAN_CHARS": {+ "kind": "assign"+ },+ "_MISTRAL_ARRAY_RE": {+ "kind": "assign"+ },+ "_MISTRAL_BRACKET_RE": {+ "kind": "assign"+ },+ "_PARAM_CLOSE_TAG": {+ "kind": "assign"+ },+ "_PAT_REQUIRED_TOKEN": {+ "kind": "assign"+ },+ "_REHEARSAL_CLOSED_STRIP_RE": {+ "kind": "assign"+ },+ "_REHEARSAL_RE": {+ "kind": "assign"+ },+ "_REHEARSAL_STRIP_PATS": {+ "kind": "assign"+ },+ "_REHEARSAL_TAIL_STRIP_RE": {+ "kind": "assign"+ },+ "_TC_END_TAG_RE": {+ "kind": "assign"+ },+ "_TC_FUNC_CLOSED_PAT": {+ "kind": "assign"+ },+ "_TC_FUNC_CLOSE_RE": {+ "kind": "assign"+ },+ "_TC_FUNC_START_RE": {+ "kind": "assign"+ },+ "_TC_GEMMA_CLOSED_PAT": {+ "kind": "assign"+ },+ "_TC_GEMMA_END_TAG_RE": {+ "kind": "assign"+ },+ "_TC_GEMMA_START_RE": {+ "kind": "assign"+ },+ "_TC_JSON_CLOSED_PAT": {+ "kind": "assign"+ },+ "_TC_JSON_START_RE": {+ "kind": "assign"+ },+ "_TC_PARAM_CLOSE_RE": {+ "kind": "assign"+ },+ "_TC_PARAM_START_RE": {+ "kind": "assign"+ },+ "_THINK_CLOSE_RE": {+ "kind": "assign"+ },+ "_THINK_OPEN_RE": {+ "kind": "assign"+ },+ "_THINK_TAG_RE": {+ "kind": "assign"+ },+ "_TOOL_ALL_PATS": {+ "kind": "assign"+ },+ "_TOOL_CLOSED_BLOCK_PATS": {+ "kind": "assign"+ },+ "_TOOL_CLOSED_PATS": {+ "kind": "assign"+ },+ "_TOOL_OPEN_XML_TAIL_PATS": {+ "kind": "assign"+ },+ "_balanced_brace_end": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, brace_start: int, *, gemma_quotes: bool=False"+ },+ "_balanced_bracket_end": {+ "decorators": [],+ "kind": "def",+ "signature": "src: str, start: int, *, braces_count: bool=True"+ },+ "_balanced_json_span": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, start: int"+ },+ "_build_markers": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str"+ },+ "_code_spans": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str"+ },+ "_decode_array_items": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, body_start: int, body_end: int"+ },+ "_func_close_index": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, body_start: int, body: str"+ },+ "_gemma_arguments_to_json": {+ "decorators": [],+ "kind": "def",+ "signature": "args_src: str"+ },+ "_gemma_span_ranges": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str"+ },+ "_in_code": {+ "decorators": [],+ "kind": "def",+ "signature": "spans, pos: int"+ },+ "_inside_open_parameter": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, pos: int, *, param_start_re=None, param_closers=(_PARAM_CLOSE_TAG,), func_closers=(_FUNC_CLOSE_TAG,)"+ },+ "_iter_bracket_spans": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, start: int=0, enabled_tool_names=None"+ },+ "_marker_coverage": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, markers"+ },+ "_normalise_gemma_quoted_strings": {+ "decorators": [],+ "kind": "def",+ "signature": "src: str"+ },+ "_quote_gemma_array_elements": {+ "decorators": [],+ "kind": "def",+ "signature": "body: str"+ },+ "_quote_gemma_object_keys": {+ "decorators": [],+ "kind": "def",+ "signature": "src: str"+ },+ "_rehearsal_strip": {+ "decorators": [],+ "kind": "def",+ "signature": "m, pat, text, spans, enabled_tool_names"+ },+ "_split_top_level_commas": {+ "decorators": [],+ "kind": "def",+ "signature": "src: str"+ },+ "_strip_bracket_tag_calls": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, enabled_tool_names=None"+ },+ "_strip_closed_blocks_outside_gemma": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str"+ },+ "_strip_gemma_native_spans": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, *, final: bool"+ },+ "_strip_markup_segment": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, *, final: bool, enabled_tool_names=None"+ },+ "_think_spans_outside_tool_markup": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str"+ },+ "_tool_call_markup_spans": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str"+ },+ "_trim_param_value": {+ "decorators": [],+ "kind": "def",+ "signature": "val: str"+ },+ "apply_tool_strip_patterns": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, patterns, enabled_tool_names=None"+ },+ "marker_coverage": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str"+ },+ "parse_tool_calls_from_text": {+ "decorators": [],+ "kind": "def",+ "signature": "content: str, *, id_offset: int=0, allow_incomplete: bool=True, enabled_tool_names=None, with_spans: bool=False"+ },+ "strip_outside_think": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, strip_segment"+ },+ "strip_tool_call_markup": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, *, final: bool=False, enabled_tool_names=None"+ },+ "strip_tool_patterns": {+ "decorators": [],+ "kind": "def",+ "signature": "text: str, patterns"+ }+ }+ }+}diff --git a/studio/backend/tests/data/refactor_guard/golden_outputs.json b/studio/backend/tests/data/refactor_guard/golden_outputs.jsonnew file mode 100644index 00000000000..a64c9a9b41a--- /dev/null+++ b/studio/backend/tests/data/refactor_guard/golden_outputs.json@@ -0,0 +1,90 @@+{+ "core.inference.tool_call_parser": {+ "_balanced_bracket_end": "71894e38351000138fd3990364d38154b8b52a398c4747f75a5c9cde20e446c5",+ "_consume_mistral_call": "2e6380147a9bd200d8cff68778fa5b7fb65f320d64807db51ef1db9136bfd1f0",+ "_disabled_gemma_call_end_containing_signal": "0c729e5b5d323409e5cd1faa4f12bf74ce36d3262a53ca33ac4f1abdf1528611",+ "_find_outside_json_strings": "f7a4f18776183812e63cae649a827973ca39ab2062f398840ed8bedc6e8c6aea",+ "_first_foreign_tool_signal": "9c097a395b83ce19b9433c4a043986a50c4c2b310dc8018c52bb79e29a8ae816",+ "_gemma_balanced_brace_end": "9c9a8cd028e69b56a15f17d2a7ce65ea04f75f09b618f6e91baa758cebc701fb",+ "_gemma_body_brace_end": "ddae97cf5311cb80b9b8e8ace5c1e9dbd4a6cccd2fe49c1c790968a527e344c0",+ "_gemma_call_is_anchored": "7b3e7bd82e97757f6369bfb0420a4c6c72570b1ed950b7e07480f05109a7f354",+ "_gemma_coerce_scalar": "329027adb79b31dd020281ca77b202941aa513a1709a35a01cdb74f6b70ea4be",+ "_gemma_parse_array": "f80a03b4b5c86108d656cb4e661fe3d8badc80e0b7b574c5e843d4d184a8a0b5",+ "_gemma_parse_mapping": "c49a6bbe71d20ff0baf6fbeb077878eda618cd916db0c8114e0a16335bb11527",+ "_gemma_parse_stripped_body": "ea9fb606df5eeb5837d3b21f548df04ab255211e51bdfc0cf8bcf75afecd5545",+ "_gemma_parse_value": "51efb0454a30a6238dcb05b641b24b4e9954ba498b9d3cadd85a2d8e6fc754e4",+ "_glm_value_close": "0e1b8de8b3632f135803573d4dd807bb3094bb17eef851a300d5a815360cac9a",+ "_inside_open_parameter": "3ae52bcd608a5a31a0d7b2e520d91c612e4a17c4c678e99f971e627391d404a4",+ "_leading_json_value_end": "91cda3d5eaa095f7f39776e836dbd8d4fa39e06b6f856d795cdb472013e4e217",+ "_llama3_kv_value": "a736ea7b33cc5cdf1cc3e39a37e74cf6bc04462510e61ec67dbd0fb883f04a66",+ "_marker_inside_leading_envelope": "c1d295882b8a347dd53f4091f22b07cc5209d6589d2b26a88fbc2fcd83d0ba60",+ "_mistral_region_end": "39541d6b4e2063ff3438dd7bfeb5b66f22a02dcc045fcb0dbe10bbbc2c8e373a",+ "_normalize_for_repeat": "9a77f50477a495993546f6dfda80972ee289da59adb8386e4f450ddb423dc8ef",+ "_parse_bare_rehearsals": "3ec57f0bff0dba6dd333f1ffec92bcb23e4e1808787cc39889af4397799e854e",+ "_parse_deepseek_tool_calls": "5884a1713f07187c3b6219e159e571172394b1fafaf493d05099ed3326ec75ff",+ "_parse_function_xml": "ae8c49727589de63f2d42733c08c404a7ce811720f7f06f8f9bb8a348ec5690b",+ "_parse_gemma_tool_calls": "a1a85db29ebc821d2ab7784c464e9ba0c7d2cbd7c1328f400b725256508d3a19",+ "_parse_glm_tool_calls": "4e29b1e0cdf7503e0547e833a47e3f9161f245831a19273e9eeed04959d32c8b",+ "_parse_kimi_section_body": "5d96a8dc0b62e0bad613093aadf276802dcd7df2e4d133eb426a569cd6c4a61f",+ "_parse_kimi_tool_calls": "5d96a8dc0b62e0bad613093aadf276802dcd7df2e4d133eb426a569cd6c4a61f",+ "_parse_llama3_bare_json": "796209b417f02ccbbce14cd6759227d270191cbfee73c02e21d5f4f2938eaf0c",+ "_parse_llama3_kv_args": "47d0001a06342506877d1255e8c760ab4ba382b38dbc99630d379af19c601b53",+ "_parse_llama3_python_tag": "662442866c0dc944a6760a06d2ebbd02b9378e7af2102f45dcd3bd0ce282f071",+ "_parse_mistral_array": "0bd038fd65d4bb4d239a56d4518453e6fd051c052c7aaa81e342c6e2fd18596d",+ "_parse_mistral_tool_calls": "2ae4da3184a1dc1bc51112d518b74a802e0555562e7256a471bade7d486ab2d1",+ "_parse_tool_call_json": "06430b767c1bd5b8d2b05ba783d95e04b9e8573331d2d4df561d55a57732ac9c",+ "_signal_inside_leading_wrapperless_gemma": "b0c119aa9207f580333210185d4abbe6fd84d936fbacb181f8cf9e4bc7271916",+ "_skip_mistral_call_id": "00bd559e1139e3a728f3deed4fdc6da5ada6307a1a5661fbc74cd5cf1fd9850c",+ "_strip_function_xml_calls": "a7aaa09ef7a2e5baa5213c0e188d62eae99d5959fc64c862adad6b8fb1c08a98",+ "_strip_gemma_wrapperless_calls": "44c1ac243fc0bb4b20b2cf57eb3ee4b844bc306992244068d96d2b089e433e9d",+ "_strip_glm_calls": "794021ec8b5665ac8594ac750b50098849e117d1ffabc146be602753b5cf7caa",+ "_strip_mistral_closed_calls": "7ebf4866dba733c640847d5c9229b97e37537114cd89dfbd7b05b14c810e1aba",+ "_strip_mistral_reasoning": "d887d6a2447d5ffc1bd33ee864f8d7b659dce4d7d19748bb3efec882d38c3f36",+ "_top_level_bare_json_name": "c163fc1b44ef9e8ca9f0b89e39d6549926b76ddef667fca061ed07f1c5080773",+ "_whole_content_is_json_value": "84a53ad03ec850e98790b989a61241aea5883935c617943c9a89a810f8ed1f16",+ "_xml_signal_inside_leading_bare_json": "e2f035c2538e13b465b6e9356549d4447ef6c7f2ed615edf59d3b2d62e5ad244",+ "_xml_signal_inside_leading_mistral": "27154f3fd8e5919e0af7dbc2d5fe07cc6719f37b62ccc9f743eb084da1b9a7e5",+ "has_tool_signal": "c80bb287b17f27ec3698d82f5711a742b906a98fc557dcf80cb2813fa8f2fec1",+ "is_reprompt_repeat": "8bec9da2bf58bada77617c893169063c29d5ed8ef3ffe96c12c70755bfcea0be",+ "is_reprompt_restatement": "8bec9da2bf58bada77617c893169063c29d5ed8ef3ffe96c12c70755bfcea0be",+ "is_short_intent_without_action": "de99e25b81def8c5ac63b03718b84c3525f49e5f31598555fb183f7637959340",+ "parse_tool_calls_from_text": "19077dca174b78f6d41a710beb02bd3875752343c2a6b35f00ec4805cb5595f7",+ "reprompt_to_act_message": "53b231a1489544f480ae21ab5e3b461e0eff072564f582dae0df55938779b445",+ "strip_leading_bare_json_call": "4dfe14fa258e30d340cfa8400eec6dde4cbbcdbaba20ac5ace312d54176c83d3",+ "strip_llama3_leading_sentinels": "7ba3f83eee7f9c5aed00d24c8cc26e5cdd82cdca7e8aca747f02566c417eef9d",+ "strip_segment": "6feb0ddeab2929915953a9a806766a07fba35be1e96bff66563128364daded17",+ "strip_tool_markup": "fb2df4ad97d8e280dec296b615ab454b8990e1bcb3ad1caad1bfc7b4a73fd573"+ },+ "core.tool_healing": {+ "_balanced_brace_end": "0b82a90811adc2196cb441d8bc569ab360aafa2552bb4093ab5b2777d9cf3a18",+ "_balanced_bracket_end": "a0fc5265e3cd4f89d2b008a03f86cb848964aa6b21c7905bb6e8cdcb12eeade5",+ "_balanced_json_span": "7bac75b00e2713176db78cdbe3e3ee2d824b96f50868a7c1c663d5c72924b2e8",+ "_build_markers": "df3f8c59c6987c9f146183fa2aaf107e43ba505d6c104043d03393a769147785",+ "_code_spans": "d2374de006d1ed16d03df4090819c8d0ea7aa1217a3c3b1c444bdaf0f04dd0d0",+ "_decode_array_items": "f167505c0386e88f9d0dbc9807ec791a84f022201fe5e1ceaf1ac8fb46fd5143",+ "_func_close_index": "a49eae803ee6143b0571bc8fac954a4b131d8ed2c4d45c50cb6018d40baab806",+ "_gemma_arguments_to_json": "44a371bfee44ed7f4ce6c74ee8e8449f98dc1d2e3dad5b124ce31e7720078279",+ "_gemma_span_ranges": "21b7dcad00a481cbc4068abb0b6dab1db859ecbd2d2da8fa268ff72930aac863",+ "_inside_open_parameter": "365304ee0b937ce16c0f04e3a0a0925c4f16998ad4a02c3eea7f2903e86646f1",+ "_iter_bracket_spans": "b5d717df12303999da807dd3289d6c17207be1782aa091e51eaa629598ffb703",+ "_marker_coverage": "598f1082bce68116d480bac3d3c00e13ace048602f1d0043c11defe42181bcb2",+ "_normalise_gemma_quoted_strings": "fe635033335bbae6dc2f2ac0ce955bf6267513b799b693f991fdb821ac7e9a16",+ "_quote_gemma_array_elements": "0f29df15aef0bf76cadef7b6690dc5bd972fca8fad7bd281b5ea217aeb5af076",+ "_quote_gemma_object_keys": "185054ca8a54154564cfc1e62e34a3a782c92a5311bddcff21de01ff2a1ad302",+ "_split_top_level_commas": "6ed35e6796a0ed774bdfb10042c9d7b2846c5bc21e5d65956d9e8ca402b04b33",+ "_strip_bracket_tag_calls": "64ff33fa93cedbaf8a78ac01dd365a7f86cf0975c66983bc0c02bda719dd8b5c",+ "_strip_closed_blocks_outside_gemma": "41195d67fab19a4d0cd7616ee9844e1053f91b7f51464c9a634891666c55153e",+ "_strip_gemma_native_spans": "7894bf2a19dd468eea3a78e367c39024967fc7d9fb5f32fe0bfb573c35f59607",+ "_strip_markup_segment": "3e7485b243047d89270535f9c3576ff9ecc402beb31adc77bef24129a462cdc6",+ "_think_spans_outside_tool_markup": "a460e6199ccf63181dc2b3a2df91ec9d0343bbc5d6f7b2f9c88eb58080895624",+ "_tool_call_markup_spans": "53e2324fb9ee343b8781a8fc9b2a7fccd80764fb18f40a8923a88a221667db70",+ "_trim_param_value": "20db8b88d3755a29038cd4874a952de75e003c84cd0f03589fe95ee9e49c2ad5",+ "apply_tool_strip_patterns": "935b0d6136baae498c141197c95e41eb0da3bfd2334fee2e103be3038237575d",+ "marker_coverage": "598f1082bce68116d480bac3d3c00e13ace048602f1d0043c11defe42181bcb2",+ "parse_tool_calls_from_text": "774adb48e160ec8da4f378442d57ca799cc297c6c770ec8f89f71c9651a3856e",+ "strip_outside_think": "d887d6a2447d5ffc1bd33ee864f8d7b659dce4d7d19748bb3efec882d38c3f36",+ "strip_tool_call_markup": "0468d8e52d46c8231be103832a192a93976b6d9090a2140eb17fdfc2b601a2db",+ "strip_tool_patterns": "974b320634ca31e0262a384fa55e7d2f66330863a10f8eaeccc87ece0cb9fc4f"+ },+ "corpus": "fd80a31cdc4c8c2961064be34ec509e4cdc3766932fbf334b9ea72b323f6d31c"+}diff --git a/studio/backend/tests/data/refactor_guard/idempotence_baseline.json b/studio/backend/tests/data/refactor_guard/idempotence_baseline.jsonnew file mode 100644index 00000000000..8455f1ce847--- /dev/null+++ b/studio/backend/tests/data/refactor_guard/idempotence_baseline.json@@ -0,0 +1,66 @@+[+ {+ "function": "_strip_markup_segment",+ "input": "get_weather[ARGS]get_weather[ARGS]{",+ "module": "core.tool_healing",+ "once": "get_weather[ARGS]",+ "twice": "",+ "variant": "{\"final\": true}"+ },+ {+ "function": "apply_tool_strip_patterns",+ "input": "get_weather[ARGS]get_weather[ARGS]{",+ "module": "core.tool_healing",+ "once": "get_weather[ARGS]",+ "twice": "",+ "variant": ""+ },+ {+ "function": "strip_tool_call_markup",+ "input": "get_weather[ARGS]get_weather[ARGS]{",+ "module": "core.tool_healing",+ "once": "get_weather[ARGS]",+ "twice": "",+ "variant": "{\"final\": true}"+ },+ {+ "function": "strip_tool_patterns",+ "input": "get_weather[ARGS]get_weather[ARGS]{",+ "module": "core.tool_healing",+ "once": "get_weather[ARGS]",+ "twice": "",+ "variant": ""+ },+ {+ "function": "strip_segment",+ "input": "<tool_call>{\"name\": \"get_weather\", \"arguments\": {\"city\": \"Paris\"}}</tool_call>call:get_weather{city:<|\"|>Paris<|\"|>}",+ "module": "core.inference.tool_call_parser",+ "once": "call:get_weather{city:<|\"|>Paris<|\"|>}",+ "twice": "",+ "variant": "{\"seg_final\": true}"+ },+ {+ "function": "strip_segment",+ "input": "<|tool▁calls▁begin|>function<|tool▁sep|>get_weather\n```json\n{\"city\": \"Paris\"}\n```<|tool▁calls▁end|>get_weather[ARGS]{\"city\": \"Paris\"}",+ "module": "core.inference.tool_call_parser",+ "once": "get_weather[ARGS]{\"city\": \"Paris\"}",+ "twice": "",+ "variant": "{\"seg_final\": false}"+ },+ {+ "function": "strip_tool_markup",+ "input": "<tool_call>{\"name\": \"get_weather\", \"arguments\": {\"city\": \"Paris\"}}</tool_call>call:get_weather{city:<|\"|>Paris<|\"|>}",+ "module": "core.inference.tool_call_parser",+ "once": "call:get_weather{city:<|\"|>Paris<|\"|>}",+ "twice": "",+ "variant": "{\"final\": true}"+ },+ {+ "function": "strip_tool_markup",+ "input": "<|tool▁calls▁begin|>function<|tool▁sep|>get_weather\n```json\n{\"city\": \"Paris\"}\n```<|tool▁calls▁end|>get_weather[ARGS]{\"city\": \"Paris\"}",+ "module": "core.inference.tool_call_parser",+ "once": "get_weather[ARGS]{\"city\": \"Paris\"}",+ "twice": "",+ "variant": "{\"final\": false}"+ }+]diff --git a/studio/backend/tests/data/refactor_guard/patch_targets.json b/studio/backend/tests/data/refactor_guard/patch_targets.jsonnew file mode 100644index 00000000000..529beaa20ca--- /dev/null+++ b/studio/backend/tests/data/refactor_guard/patch_targets.json@@ -0,0 +1,1559 @@+{+ "core.export.get_export_backend": [+ "tests/test_diffusion_training.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_raw_support.py"+ ],+ "core.inference.chat_template_helpers.apply_chat_template_for_generation": [+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py"+ ],+ "core.inference.chat_template_helpers.detect_think_prefill": [+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py"+ ],+ "core.inference.chat_template_helpers.render_with_native_template_fallback": [+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py",+ "tests/test_mlx_inference_backend.py"+ ],+ "core.inference.defaults.get_default_models": [+ "tests/test_warm_window_review_fixes.py",+ "tests/test_warm_window_review_fixes.py",+ "tests/test_warm_window_review_fixes.py",+ "tests/test_warm_window_review_fixes.py"+ ],+ "core.inference.diffusion.Path": [+ "tests/test_diffusion_gated_base.py"+ ],+ "core.inference.diffusion._assert_base_repo_accessible": [+ "tests/test_diffusion_compat_preflight.py",+ "tests/test_diffusion_compat_preflight.py",+ "tests/test_diffusion_compat_preflight.py",+ "tests/test_diffusion_compat_preflight.py"+ ],+ "core.inference.diffusion._hf_base_model": [+ "tests/test_diffusion_backend.py"+ ],+ "core.inference.diffusion._is_trusted_diffusion_repo": [+ "tests/test_cached_gguf_routes.py"+ ],+ "core.inference.diffusion._resolve_base_repo": [+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_compat_preflight.py",+ "tests/test_diffusion_compat_preflight.py",+ "tests/test_diffusion_compat_preflight.py",+ "tests/test_diffusion_compat_preflight.py",+ "tests/test_diffusion_gated_base.py",+ "tests/test_diffusion_gated_base.py",+ "tests/test_diffusion_gated_base.py",+ "tests/test_diffusion_gated_base.py",+ "tests/test_diffusion_gated_base.py",+ "tests/test_diffusion_gated_base.py"+ ],+ "core.inference.diffusion._uncached_prequant_repo": [+ "tests/test_diffusion_backend.py"+ ],+ "core.inference.diffusion.apply_memory_plan": [+ "tests/test_diffusion_backend.py"+ ],+ "core.inference.diffusion.clear_gpu_cache": [+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_saved_image_metadata_precision_contract.py"+ ],+ "core.inference.diffusion.detect_family_for_pick": [+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_gated_base.py",+ "tests/test_diffusion_gated_base.py"+ ],+ "core.inference.diffusion.estimate_gguf_resident_mib": [+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py"+ ],+ "core.inference.diffusion.hub_cache_dir": [+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_gated_base.py",+ "tests/test_diffusion_gated_base.py",+ "tests/test_diffusion_gated_base.py",+ "tests/test_diffusion_gated_base.py",+ "tests/test_diffusion_gated_base.py",+ "tests/test_diffusion_gated_base.py",+ "tests/test_diffusion_h3_trainer.py",+ "tests/test_diffusion_h3_trainer.py"+ ],+ "core.inference.diffusion.load_ideogram4_pipeline": [+ "tests/test_diffusion_backend.py"+ ],+ "core.inference.diffusion.plan_diffusion_memory": [+ "tests/test_diffusion_backend.py"+ ],+ "core.inference.diffusion.prequant_checkpoint_cached": [+ "tests/test_diffusion_backend.py"+ ],+ "core.inference.diffusion.restore_backend_flags": [+ "tests/test_diffusion_backend.py"+ ],+ "core.inference.diffusion.settled_snapshot_device_memory": [+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py"+ ],+ "core.inference.diffusion.usable_prequant_source": [+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py"+ ],+ "core.inference.diffusion_compat.flux2_inner_dim_for_pick": [+ "tests/test_gguf_variant_dependency_key.py",+ "tests/test_gguf_variant_dependency_key.py"+ ],+ "core.inference.diffusion_engine_router.get_active_diffusion_engine": [+ "tests/test_diffusion_training.py"+ ],+ "core.inference.diffusion_families._upstream_is_cached": [+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_sd_cpp_backend.py"+ ],+ "core.inference.diffusion_families.detect_family_for_pick": [+ "tests/test_gguf_variant_dependency_key.py"+ ],+ "core.inference.diffusion_families.family_pipeline_available": [+ "tests/test_cached_gguf_routes.py",+ "tests/test_diffusion_dit_trainer_ltx2.py"+ ],+ "core.inference.diffusion_krea2.load_krea2_text_encoder": [+ "tests/test_diffusion_krea2.py"+ ],+ "core.inference.diffusion_krea2.load_krea2_tokenizer": [+ "tests/test_diffusion_krea2.py"+ ],+ "core.inference.diffusion_lora.loras_dir": [+ "tests/test_diffusion_dit_trainer_ltx2.py"+ ],+ "core.inference.diffusion_te_prequant.te_prequant_budget_scale": [+ "tests/test_diffusion_backend.py"+ ],+ "core.inference.diffusion_te_prequant.te_prequant_sources": [+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py"+ ],+ "core.inference.diffusion_transformer_quant.apply_small_m_padding": [+ "tests/test_diffusion_h3_trainer.py",+ "tests/test_diffusion_prequant.py",+ "tests/test_diffusion_prequant.py"+ ],+ "core.inference.diffusion_transformer_quant.auto_scheme_candidates": [+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py"+ ],+ "core.inference.get_inference_backend": [+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_raw_support.py"+ ],+ "core.inference.llama_cpp.LlamaCppBackend._is_vulkan_backend": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "core.inference.llama_cpp.LlamaCppBackend.vulkan_device_inventory": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "core.inference.llama_cpp._apply_igpu_host_reserve_mib": [+ "tests/test_gpu_selection.py"+ ],+ "core.inference.llama_cpp._hub_download_blocks_gguf_load": [+ "tests/test_gguf_load_cache_reuse.py"+ ],+ "core.inference.llama_cpp._llama_lib_dir": [+ "tests/test_llama_cpp_placement.py",+ "tests/test_llama_cpp_placement.py",+ "tests/test_llama_cpp_placement.py"+ ],+ "core.inference.llama_cpp.begin_tool_decision": [+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py"+ ],+ "core.inference.llama_cpp.cached_gguf_for_load": [+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py"+ ],+ "core.inference.llama_cpp.child_env_without_native_path_secret": [+ "tests/test_llama_cpp_mtp_detection.py",+ "tests/test_llama_cpp_mtp_detection.py"+ ],+ "core.inference.llama_cpp.hf_hub_download_with_xet_fallback": [+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_xet_fallback_integration.py",+ "tests/test_gguf_xet_fallback_integration.py",+ "tests/test_gguf_xet_fallback_integration.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py"+ ],+ "core.inference.llama_cpp.httpx.get": [+ "tests/test_offline_gguf_cache_fallback.py"+ ],+ "core.inference.llama_cpp.new_approval_id": [+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py"+ ],+ "core.inference.llama_cpp.shutil.disk_usage": [+ "tests/test_gguf_load_cache_reuse.py"+ ],+ "core.inference.llama_cpp.subprocess.run": [+ "tests/test_amd_apu_unified_memory.py",+ "tests/test_amd_apu_unified_memory.py",+ "tests/test_llama_cpp_mtp_detection.py",+ "tests/test_llama_cpp_mtp_detection.py",+ "tests/test_llama_cpp_mtp_detection.py",+ "tests/test_llama_cpp_mtp_detection.py",+ "tests/test_llama_cpp_mtp_detection.py",+ "tests/test_llama_cpp_mtp_detection.py",+ "tests/test_metal_paravirtual_guard.py",+ "tests/test_metal_paravirtual_guard.py",+ "tests/test_metal_paravirtual_guard.py",+ "tests/test_metal_paravirtual_guard.py",+ "tests/test_metal_paravirtual_guard.py",+ "tests/test_metal_paravirtual_guard.py",+ "tests/test_metal_paravirtual_guard.py",+ "tests/test_metal_paravirtual_guard.py"+ ],+ "core.inference.llama_cpp.sys.platform": [+ "tests/test_llama_cpp_mtp_detection.py",+ "tests/test_llama_cpp_mtp_detection.py"+ ],+ "core.inference.llama_cpp.time.monotonic": [+ "tests/test_llama_cpp_mtp_detection.py",+ "tests/test_llama_cpp_mtp_detection.py",+ "tests/test_llama_cpp_mtp_detection.py"+ ],+ "core.inference.llama_cpp.wait_tool_decision": [+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py"+ ],+ "core.inference.llama_keepwarm.other_inference_request_count": [+ "tests/test_diffusion_training.py",+ "tests/test_diffusion_training.py"+ ],+ "core.inference.local_model_resolver.resolve_local_gguf": [+ "tests/test_openai_auto_download.py",+ "tests/test_openai_auto_download.py",+ "tests/test_openai_auto_download.py",+ "tests/test_openai_auto_download.py",+ "tests/test_openai_auto_download.py",+ "tests/test_openai_auto_download.py",+ "tests/test_openai_auto_download.py",+ "tests/test_openai_auto_download.py",+ "tests/test_openai_auto_download.py"+ ],+ "core.inference.orchestrator.prepare_gpu_selection": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "core.inference.orchestrator.threading.Thread": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "core.inference.sd_cpp_backend.sd_cpp_text_encoders_for": [+ "tests/test_diffusion_gated_base.py"+ ],+ "core.inference.stt_download_worker.reap_download": [+ "tests/test_stt_http_downloads.py",+ "tests/test_stt_http_downloads.py"+ ],+ "core.inference.stt_download_worker.spawn_download": [+ "tests/test_stt_http_downloads.py",+ "tests/test_stt_http_downloads.py",+ "tests/test_stt_install_and_snapshot_validation.py",+ "tests/test_stt_sidecar.py"+ ],+ "core.inference.stt_ggml_sidecar.get_ggml_stt_sidecar": [+ "tests/test_stt_ggml_sidecar.py"+ ],+ "core.inference.stt_mtmd_sidecar.get_mtmd_stt_sidecar": [+ "tests/test_stt_mtmd_sidecar.py",+ "tests/test_stt_mtmd_sidecar.py"+ ],+ "core.inference.stt_sidecar._active_hf_hub_cache": [+ "tests/test_stt_mtmd_sidecar.py"+ ],+ "core.inference.stt_sidecar.get_stt_sidecar": [+ "tests/test_stt_ggml_sidecar.py"+ ],+ "core.inference.tool_stream_exec._WORKER_JOIN_TIMEOUT_S": [+ "tests/test_tool_output_streaming.py",+ "tests/test_tool_output_streaming.py"+ ],+ "core.inference.tools._fetch_url_raw": [+ "tests/test_web_fetch_extraction.py",+ "tests/test_web_fetch_extraction.py",+ "tests/test_web_fetch_extraction.py",+ "tests/test_web_fetch_extraction.py",+ "tests/test_web_fetch_extraction.py",+ "tests/test_web_fetch_extraction.py",+ "tests/test_web_fetch_extraction.py",+ "tests/test_web_fetch_extraction.py",+ "tests/test_web_fetch_extraction.py",+ "tests/test_web_fetch_extraction.py",+ "tests/test_web_fetch_extraction.py",+ "tests/test_web_fetch_extraction.py",+ "tests/test_web_fetch_extraction.py",+ "tests/test_web_fetch_extraction.py"+ ],+ "core.inference.tools._validate_and_resolve_host": [+ "tests/test_web_fetch_extraction.py"+ ],+ "core.inference.tools.build_rag_autoinject": [+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_safetensors_tool_loop.py",+ "tests/test_safetensors_tool_loop.py"+ ],+ "core.inference.tools.execute_tool": [+ "tests/test_gguf_route_cursor_reset.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_llama_cpp_tool_loop.py",+ "tests/test_tool_output_streaming.py"+ ],+ "core.inference.video._detect_load_family": [+ "tests/test_video_prequant.py"+ ],+ "core.inference.video._ensure_mp4_encoder_available": [+ "tests/test_video_backend.py"+ ],+ "core.inference.video._is_trusted_video_repo": [+ "tests/test_video_prequant.py"+ ],+ "core.inference.video.clear_gpu_cache": [+ "tests/test_video_backend.py"+ ],+ "core.inference.video.contextlib": [+ "tests/test_video_backend.py"+ ],+ "core.inference.video.get_video_backend": [+ "tests/test_diffusion_training.py"+ ],+ "core.inference.video.hub_cache_dir": [+ "tests/test_video_backend.py",+ "tests/test_video_backend.py",+ "tests/test_video_backend.py"+ ],+ "core.inference.video.precision_fallback_allowed": [+ "tests/test_video_h3_te_quant.py"+ ],+ "core.inference.video.resolve_diffusion_device_target": [+ "tests/test_video_backend.py",+ "tests/test_video_backend.py",+ "tests/test_video_prequant.py",+ "tests/test_video_prequant.py",+ "tests/test_video_prequant.py"+ ],+ "core.inference.video.settled_snapshot_device_memory": [+ "tests/test_video_backend.py"+ ],+ "core.inference.video.te_quant_supported": [+ "tests/test_video_h3_te_quant.py"+ ],+ "core.inference.video_families.detect_video_family": [+ "tests/test_cached_gguf_routes.py"+ ],+ "core.rag.parsers.parse_pdf_bytes": [+ "tests/test_web_fetch_binary_guard.py",+ "tests/test_web_fetch_binary_guard.py",+ "tests/test_web_fetch_binary_guard.py"+ ],+ "core.training.diffusion_checkpoint.read_checkpoint": [+ "tests/test_diffusion_train_perf.py"+ ],+ "core.training.diffusion_dit_trainer._assert_gated_access": [+ "tests/test_diffusion_dit_trainer.py"+ ],+ "core.training.diffusion_train_common.discover_image_caption_pairs": [+ "tests/test_diffusion_checkpoint_resume.py",+ "tests/test_diffusion_training.py",+ "tests/test_diffusion_training.py",+ "tests/test_diffusion_training.py"+ ],+ "core.training.diffusion_train_common.training_precision_preflight_error": [+ "tests/test_diffusion_training.py",+ "tests/test_diffusion_training.py"+ ],+ "core.training.diffusion_training_service.get_diffusion_training_service": [+ "tests/test_diffusion_checkpoint_resume.py",+ "tests/test_diffusion_train_perf.py",+ "tests/test_diffusion_training.py",+ "tests/test_diffusion_training.py",+ "tests/test_diffusion_training.py",+ "tests/test_video_routes.py"+ ],+ "core.training.get_training_backend": [+ "tests/test_gpu_selection.py"+ ],+ "core.training.provenance.normalize_worker_provenance_event": [+ "tests/test_training_provenance.py"+ ],+ "core.training.provenance.os.walk": [+ "tests/test_training_provenance.py"+ ],+ "core.training.resume.get_resume_checkpoint_path": [+ "tests/test_training_cached_start.py",+ "tests/test_training_history_delete.py"+ ],+ "core.training.trainer.format_and_template_dataset": [+ "tests/test_training_preflight.py"+ ],+ "core.training.trainer.load_dataset": [+ "tests/test_training_preflight.py",+ "tests/test_training_preflight.py",+ "tests/test_training_preflight.py",+ "tests/test_training_preflight.py",+ "tests/test_training_preflight.py",+ "tests/test_training_preflight.py",+ "tests/test_training_preflight.py",+ "tests/test_training_preflight.py"+ ],+ "core.training.training._CTX.Process": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_training_before_spawn.py",+ "tests/test_training_before_spawn.py",+ "tests/test_training_before_spawn.py",+ "tests/test_training_before_spawn.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_start_idempotency.py",+ "tests/test_training_start_idempotency.py",+ "tests/test_training_start_idempotency.py"+ ],+ "core.training.training._CTX.Queue": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_training_before_spawn.py",+ "tests/test_training_before_spawn.py",+ "tests/test_training_before_spawn.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_start_idempotency.py",+ "tests/test_training_start_idempotency.py",+ "tests/test_training_start_idempotency.py"+ ],+ "core.training.training._resolve_model_snapshot": [+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py"+ ],+ "core.training.training.get_device": [+ "tests/test_training_cached_start.py"+ ],+ "core.training.training.prepare_gpu_selection": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_training_before_spawn.py",+ "tests/test_training_before_spawn.py",+ "tests/test_training_before_spawn.py",+ "tests/test_training_before_spawn.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_start_idempotency.py",+ "tests/test_training_start_idempotency.py",+ "tests/test_training_start_idempotency.py"+ ],+ "core.training.training.threading.Thread": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_training_before_spawn.py",+ "tests/test_training_before_spawn.py",+ "tests/test_training_before_spawn.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_raw_support.py",+ "tests/test_training_start_idempotency.py"+ ],+ "core.training.training.time.sleep": [+ "tests/test_training_provenance.py",+ "tests/test_training_provenance.py"+ ],+ "hub.services.models.deletion.delete_cached_model_response": [+ "tests/test_cached_gguf_routes.py"+ ],+ "hub.services.models.downloads.get_download_progress_response": [+ "tests/test_cached_gguf_routes.py"+ ],+ "hub.services.models.downloads.get_gguf_download_progress_response": [+ "tests/test_cached_gguf_routes.py"+ ],+ "hub.services.models.gguf_variants.iter_hf_cache_snapshots": [+ "tests/test_cached_gguf_routes.py"+ ],+ "hub.utils.dataset_cache.latest_cached_dataset_path": [+ "tests/test_training_cached_start.py"+ ],+ "hub.utils.dataset_cache.load_cached_hf_dataset": [+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py"+ ],+ "hub.utils.dataset_cache.training_dataset_cache_pin": [+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py"+ ],+ "hub.utils.download_manifest.build_variant_state_index": [+ "tests/test_cached_gguf_routes.py"+ ],+ "hub.utils.download_registry.existing_blob_bytes": [+ "tests/test_openai_auto_download.py"+ ],+ "hub.utils.download_registry.get_models_registry": [+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py"+ ],+ "hub.utils.download_registry.prepare_cache_for_transport": [+ "tests/test_hf_xet_fallback.py",+ "tests/test_hf_xet_fallback.py"+ ],+ "hub.utils.gguf.iter_hf_cache_snapshots": [+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py"+ ],+ "hub.utils.hf_cache_state.hf_cache_root": [+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py"+ ],+ "hub.utils.hf_cache_state.hf_cache_roots": [+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py"+ ],+ "hub.utils.hf_cache_state.iter_repo_cache_dirs": [+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py"+ ],+ "hub.utils.hf_cache_state.latest_snapshot_from_cache_path": [+ "tests/test_models_get_model_config_case_resolution.py"+ ],+ "hub.utils.inventory_scan.invalidate_hf_cache_scans": [+ "tests/test_hf_cache_settings.py"+ ],+ "hub.utils.paths.hf_default_cache_dir": [+ "tests/test_models_get_model_config_case_resolution.py",+ "tests/test_models_get_model_config_case_resolution.py"+ ],+ "hub.utils.paths.legacy_hf_cache_dir": [+ "tests/test_models_get_model_config_case_resolution.py",+ "tests/test_models_get_model_config_case_resolution.py"+ ],+ "picker.service._build_browse_allowlist": [+ "tests/test_picker_service.py",+ "tests/test_picker_service.py"+ ],+ "picker.service.active_hf_hub_cache": [+ "tests/test_picker_service.py"+ ],+ "picker.service.iter_snapshots_preferring_whole": [+ "tests/test_picker_service.py",+ "tests/test_picker_service.py"+ ],+ "picker.service.read_gguf_chat_template": [+ "tests/test_picker_service.py",+ "tests/test_picker_service.py",+ "tests/test_picker_service.py",+ "tests/test_picker_service.py"+ ],+ "picker.service.resolve_cached_repo_id_case": [+ "tests/test_picker_service.py",+ "tests/test_picker_service.py"+ ],+ "routes.inference.get_llama_cpp_backend": [+ "tests/test_consent_gate.py"+ ],+ "routes.models._cached_repo_task": [+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py"+ ],+ "routes.models._repo_gguf_task": [+ "tests/test_cached_gguf_routes.py"+ ],+ "routes.training_vram.summarize_resident_chat": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "storage.studio_db.add_scan_folder_with_status": [+ "tests/test_openai_auto_switch.py"+ ],+ "storage.studio_db.finish_run": [+ "tests/test_training_provenance.py",+ "tests/test_training_provenance.py",+ "tests/test_training_provenance.py"+ ],+ "storage.studio_db.get_app_setting": [+ "tests/test_hf_cache_settings.py",+ "tests/test_model_memory_settings.py",+ "tests/test_model_memory_settings.py",+ "tests/test_model_memory_settings.py",+ "tests/test_model_memory_settings.py",+ "tests/test_model_memory_settings.py",+ "tests/test_model_memory_settings.py",+ "tests/test_model_memory_settings.py",+ "tests/test_personalization_settings.py",+ "tests/test_personalization_settings.py",+ "tests/test_personalization_settings.py",+ "tests/test_personalization_settings.py",+ "tests/test_personalization_settings.py",+ "tests/test_personalization_settings.py"+ ],+ "storage.studio_db.list_scan_folders": [+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_mtp_drafter_companion.py",+ "tests/test_openai_auto_switch.py"+ ],+ "storage.studio_db.mark_run_cancel_requested": [+ "tests/test_training_status_terminal.py"+ ],+ "storage.studio_db.remove_scan_folder": [+ "tests/test_openai_auto_switch.py",+ "tests/test_openai_auto_switch.py",+ "tests/test_openai_auto_switch.py"+ ],+ "storage.studio_db.update_run_config_json": [+ "tests/test_training_provenance.py",+ "tests/test_training_provenance.py",+ "tests/test_training_provenance.py",+ "tests/test_training_provenance.py",+ "tests/test_training_provenance.py"+ ],+ "storage.studio_db.upsert_app_settings": [+ "tests/test_hf_cache_settings.py",+ "tests/test_model_memory_settings.py",+ "tests/test_model_memory_settings.py",+ "tests/test_model_memory_settings.py",+ "tests/test_model_memory_settings.py",+ "tests/test_model_memory_settings.py",+ "tests/test_personalization_settings.py",+ "tests/test_personalization_settings.py",+ "tests/test_personalization_settings.py",+ "tests/test_personalization_settings.py"+ ],+ "utils.coding_agents.shutil.which": [+ "tests/test_coding_agents.py",+ "tests/test_coding_agents.py",+ "tests/test_coding_agents.py",+ "tests/test_coding_agents.py"+ ],+ "utils.hardware.apple.read_gpu_power_w": [+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.apple.read_gpu_temperature_c": [+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.auto_select_gpu_ids": [+ "tests/test_chat_load_during_training.py",+ "tests/test_chat_load_during_training.py",+ "tests/test_chat_load_during_training.py",+ "tests/test_chat_load_during_training.py",+ "tests/test_chat_load_during_training.py",+ "tests/test_training_vram_coexistence.py",+ "tests/test_training_vram_coexistence.py",+ "tests/test_training_vram_coexistence.py"+ ],+ "utils.hardware.ensure_hardware_detected": [+ "tests/test_training_cached_start.py",+ "tests/test_training_start_offload.py"+ ],+ "utils.hardware.estimate_required_model_memory_gb": [+ "tests/test_chat_load_during_training.py",+ "tests/test_chat_load_during_training.py",+ "tests/test_training_vram_coexistence.py",+ "tests/test_training_vram_coexistence.py"+ ],+ "utils.hardware.get_device": [+ "tests/test_chat_load_during_training.py",+ "tests/test_chat_load_during_training.py",+ "tests/test_chat_load_during_training.py",+ "tests/test_chat_load_during_training.py",+ "tests/test_chat_load_during_training.py",+ "tests/test_chat_load_during_training.py",+ "tests/test_chat_load_during_training.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_training_vram_coexistence.py",+ "tests/test_training_vram_coexistence.py",+ "tests/test_training_vram_coexistence.py",+ "tests/test_training_vram_coexistence.py",+ "tests/test_utils.py",+ "tests/test_utils.py",+ "tests/test_utils.py"+ ],+ "utils.hardware.get_visible_gpu_utilization": [+ "tests/test_chat_load_during_training.py",+ "tests/test_chat_load_during_training.py",+ "tests/test_chat_load_during_training.py",+ "tests/test_training_vram_coexistence.py"+ ],+ "utils.hardware.hardware.DEVICE": [+ "tests/test_training_before_spawn.py",+ "tests/test_training_before_spawn.py",+ "tests/test_training_before_spawn.py"+ ],+ "utils.hardware.hardware._determine_attention_impl_for_gpu_estimate": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware._estimate_fp16_model_size_bytes_from_config": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware._estimate_fp16_model_size_bytes_from_vllm_utils": [+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware._get_hf_safetensors_total_params": [+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware._get_local_weight_size_bytes": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware._get_parent_visible_gpu_spec": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware._has_mlx": [+ "tests/test_utils.py",+ "tests/test_utils.py"+ ],+ "utils.hardware.hardware._has_torch": [+ "tests/test_utils.py",+ "tests/test_utils.py",+ "tests/test_utils.py",+ "tests/test_utils.py"+ ],+ "utils.hardware.hardware._has_usable_mlx_stack": [+ "tests/test_utils.py"+ ],+ "utils.hardware.hardware._load_config_for_gpu_estimate": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware._read_apple_gpu_stats": [+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware._resolve_model_identifier_for_gpu_estimate": [+ "tests/test_export_size_estimate.py",+ "tests/test_export_size_estimate.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware._smi_query": [+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware._torch_get_per_device_info": [+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware._torch_get_physical_gpu_count": [+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware.auto_select_gpu_ids": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware.estimate_fp16_model_size_bytes": [+ "tests/test_export_size_estimate.py",+ "tests/test_export_size_estimate.py",+ "tests/test_export_size_estimate.py",+ "tests/test_export_size_estimate.py",+ "tests/test_export_size_estimate.py",+ "tests/test_export_size_estimate.py",+ "tests/test_export_size_estimate.py",+ "tests/test_export_size_estimate.py",+ "tests/test_export_size_estimate.py",+ "tests/test_export_size_estimate.py",+ "tests/test_export_size_estimate.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection_sandbox.py",+ "tests/test_gpu_selection_sandbox.py",+ "tests/test_gpu_selection_sandbox.py",+ "tests/test_gpu_selection_sandbox.py",+ "tests/test_gpu_selection_sandbox.py"+ ],+ "utils.hardware.hardware.estimate_required_model_memory_gb": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware.get_device": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_utils.py",+ "tests/test_utils.py",+ "tests/test_utils.py",+ "tests/test_utils.py",+ "tests/test_utils.py",+ "tests/test_utils.py",+ "tests/test_utils.py",+ "tests/test_utils.py",+ "tests/test_utils.py"+ ],+ "utils.hardware.hardware.get_gpu_memory_info": [+ "tests/test_gpu_selection.py",+ "tests/test_utils.py",+ "tests/test_utils.py"+ ],+ "utils.hardware.hardware.get_parent_visible_gpu_ids": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware.get_physical_gpu_count": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection_sandbox.py",+ "tests/test_gpu_selection_sandbox.py",+ "tests/test_gpu_selection_sandbox.py",+ "tests/test_gpu_selection_sandbox.py",+ "tests/test_gpu_selection_sandbox.py"+ ],+ "utils.hardware.hardware.get_visible_gpu_count": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware.get_visible_gpu_utilization": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.hardware.is_apple_silicon": [+ "tests/test_utils.py",+ "tests/test_utils.py",+ "tests/test_utils.py",+ "tests/test_utils.py"+ ],+ "utils.hardware.hardware.platform": [+ "tests/test_utils.py",+ "tests/test_utils.py",+ "tests/test_utils.py"+ ],+ "utils.hardware.hardware.resolve_requested_gpu_ids": [+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.nvidia.get_backend_visible_gpu_info": [+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.nvidia.subprocess.run": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py"+ ],+ "utils.hardware.resolve_requested_gpu_ids": [+ "tests/test_chat_load_during_training.py",+ "tests/test_chat_load_during_training.py",+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_training_vram_coexistence.py",+ "tests/test_training_vram_coexistence.py"+ ],+ "utils.hardware.vram_estimation.compute_gradient_bytes": [+ "tests/test_vram_estimation.py"+ ],+ "utils.hf_cache_settings.active_hf_hub_cache": [+ "tests/test_diffusion_backend.py",+ "tests/test_rag_embeddings.py",+ "tests/test_sd_cpp_backend.py",+ "tests/test_sd_cpp_backend.py",+ "tests/test_sd_cpp_backend.py",+ "tests/test_third_party_source.py"+ ],+ "utils.hf_cache_settings.get_hf_cache_paths": [+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_dataset_cache_paths.py",+ "tests/test_dataset_cache_paths.py",+ "tests/test_dataset_cache_paths.py",+ "tests/test_dataset_cache_paths.py",+ "tests/test_diffusion_gated_base.py",+ "tests/test_diffusion_gated_base.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_load_cache_reuse.py",+ "tests/test_gguf_variants_local_resolution.py",+ "tests/test_hf_cache_dangling_refs.py",+ "tests/test_hf_cache_dangling_refs.py",+ "tests/test_hf_cache_dangling_refs.py",+ "tests/test_hf_cache_dangling_refs.py",+ "tests/test_hf_cache_dangling_refs.py",+ "tests/test_hf_cache_dangling_refs.py",+ "tests/test_hf_cache_dangling_refs.py",+ "tests/test_hf_cache_dangling_refs.py",+ "tests/test_hf_cache_dangling_refs.py",+ "tests/test_hf_cache_dangling_refs.py",+ "tests/test_hf_cache_dangling_refs.py",+ "tests/test_hf_cache_dangling_refs.py",+ "tests/test_model_update_robustness.py",+ "tests/test_model_update_robustness.py",+ "tests/test_offline_embedding_minimal.py",+ "tests/test_offline_embedding_minimal.py",+ "tests/test_offline_embedding_minimal.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_stt_http_downloads.py"+ ],+ "utils.hf_cache_settings.known_hf_hub_caches": [+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_models_get_model_config_case_resolution.py",+ "tests/test_models_get_model_config_case_resolution.py",+ "tests/test_models_get_model_config_case_resolution.py",+ "tests/test_resolve_quant_gguf.py"+ ],+ "utils.hf_xet_fallback.hf_hub_download_with_xet_fallback": [+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_diffusion_backend.py",+ "tests/test_sd_cpp_backend.py",+ "tests/test_video_backend.py",+ "tests/test_video_backend.py",+ "tests/test_video_backend.py",+ "tests/test_video_backend.py",+ "tests/test_video_backend.py",+ "tests/test_video_backend.py",+ "tests/test_video_backend.py",+ "tests/test_video_backend.py",+ "tests/test_video_backend.py",+ "tests/test_video_backend.py",+ "tests/test_video_backend.py"+ ],+ "utils.llama_cpp_freshness.read_install_marker": [+ "tests/test_llama_cpp_mtp_detection.py"+ ],+ "utils.models.gguf_metadata.read_gguf_context_length": [+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py"+ ],+ "utils.models.gguf_metadata.read_gguf_general_metadata": [+ "tests/test_video_backend.py",+ "tests/test_video_backend.py",+ "tests/test_video_backend.py"+ ],+ "utils.models.model_config._env_offline": [+ "tests/test_vision_cache.py"+ ],+ "utils.models.model_config._is_vision_model_subprocess": [+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py"+ ],+ "utils.models.model_config._is_vision_model_uncached": [+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py"+ ],+ "utils.models.model_config._iter_gguf_files": [+ "tests/test_cached_gguf_routes.py"+ ],+ "utils.models.model_config._iter_hf_cache_snapshots": [+ "tests/test_mtp_drafter_companion.py",+ "tests/test_mtp_drafter_companion.py",+ "tests/test_mtp_drafter_companion.py",+ "tests/test_mtp_drafter_companion.py",+ "tests/test_mtp_drafter_companion.py",+ "tests/test_mtp_drafter_companion.py",+ "tests/test_mtp_drafter_companion.py",+ "tests/test_mtp_drafter_companion.py",+ "tests/test_mtp_drafter_companion.py",+ "tests/test_mtp_drafter_companion.py",+ "tests/test_mtp_drafter_companion.py"+ ],+ "utils.models.model_config._raw_config_has_vision_config": [+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py"+ ],+ "utils.models.model_config.detect_audio_type": [+ "tests/test_trained_model_scan.py"+ ],+ "utils.models.model_config.get_base_model_from_lora_identifier": [+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py"+ ],+ "utils.models.model_config.is_audio_input_type": [+ "tests/test_trained_model_scan.py"+ ],+ "utils.models.model_config.is_local_path": [+ "tests/test_capability_detection.py",+ "tests/test_capability_detection.py"+ ],+ "utils.models.model_config.is_vision_model": [+ "tests/test_trained_model_scan.py"+ ],+ "utils.models.model_config.list_gguf_variants": [+ "tests/test_batch_sizes_per_load.py",+ "tests/test_batch_sizes_per_load.py",+ "tests/test_batch_sizes_per_load.py",+ "tests/test_batch_sizes_per_load.py",+ "tests/test_batch_sizes_per_load.py",+ "tests/test_batch_sizes_per_load.py"+ ],+ "utils.models.model_config.load_model_config": [+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py"+ ],+ "utils.models.model_config.subprocess.run": [+ "tests/test_vision_cache.py"+ ],+ "utils.models.model_config.without_hf_auth": [+ "tests/test_capability_detection.py"+ ],+ "utils.native_path_leases.run_without_native_path_secret": [+ "tests/test_diffusion_training.py"+ ],+ "utils.native_tls.activate_native_tls": [+ "tests/test_diffusion_training.py"+ ],+ "utils.openai_auto_switch_settings.get_openai_auto_download_enabled": [+ "tests/test_openai_auto_switch.py"+ ],+ "utils.openai_auto_switch_settings.get_openai_auto_switch_enabled": [+ "tests/test_openai_auto_download.py",+ "tests/test_openai_auto_download.py",+ "tests/test_openai_auto_download.py",+ "tests/test_openai_auto_download.py",+ "tests/test_openai_auto_download.py",+ "tests/test_openai_auto_download.py"+ ],+ "utils.paths.exports_root": [+ "tests/test_export_size_estimate.py"+ ],+ "utils.paths.hf_default_cache_dir": [+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py"+ ],+ "utils.paths.is_local_path": [+ "tests/test_file_security.py",+ "tests/test_file_security.py",+ "tests/test_file_security.py",+ "tests/test_trc_approval_cache.py"+ ],+ "utils.paths.legacy_hf_cache_dir": [+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py"+ ],+ "utils.paths.lmstudio_model_dirs": [+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py",+ "tests/test_cached_gguf_routes.py"+ ],+ "utils.paths.normalize_path": [+ "tests/test_consent_gate.py"+ ],+ "utils.paths.outputs_root": [+ "tests/test_export_size_estimate.py"+ ],+ "utils.paths.resolve_cached_repo_id_case": [+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py"+ ],+ "utils.paths.storage_roots.cache_root": [+ "tests/test_dataset_cache_paths.py",+ "tests/test_dataset_cache_paths.py",+ "tests/test_dataset_cache_paths.py",+ "tests/test_dataset_cache_paths.py",+ "tests/test_export_size_estimate.py"+ ],+ "utils.paths.storage_roots.exports_root": [+ "tests/test_export_absolute_paths.py",+ "tests/test_export_absolute_paths.py"+ ],+ "utils.paths.studio_root": [+ "tests/test_export_size_estimate.py"+ ],+ "utils.process_lifetime.adopt_pid": [+ "tests/test_stt_http_downloads.py",+ "tests/test_training_start_idempotency.py",+ "tests/test_training_start_idempotency.py"+ ],+ "utils.process_lifetime.child_popen_kwargs": [+ "tests/test_stt_http_downloads.py"+ ],+ "utils.process_lifetime.forget_pid": [+ "tests/test_stt_mtmd_sidecar.py"+ ],+ "utils.security.consent._config_has_auto_map": [+ "tests/test_openai_auto_download.py",+ "tests/test_openai_auto_download.py",+ "tests/test_openai_auto_download.py"+ ],+ "utils.security.evaluate_file_security": [+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py"+ ],+ "utils.security.evaluate_remote_code_consent_for_targets": [+ "tests/test_training_cached_start.py"+ ],+ "utils.security.file_security._fetch_security_status": [+ "tests/test_file_security.py",+ "tests/test_file_security.py",+ "tests/test_file_security.py"+ ],+ "utils.security.security_load_subdirs": [+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py"+ ],+ "utils.security.trusted_org.is_local_path": [+ "tests/test_consent_gate.py"+ ],+ "utils.transformers_version._check_config_needs_510": [+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py"+ ],+ "utils.transformers_version._check_config_needs_550": [+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py"+ ],+ "utils.transformers_version._check_tokenizer_config_needs_v5": [+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py"+ ],+ "utils.transformers_version._ensure_venv_t5_510_exists": [+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py"+ ],+ "utils.transformers_version._ensure_venv_t5_530_exists": [+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py"+ ],+ "utils.transformers_version._ensure_venv_t5_550_exists": [+ "tests/test_transformers_version.py"+ ],+ "utils.transformers_version._install_to_dir": [+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py"+ ],+ "utils.transformers_version._load_config_json": [+ "tests/test_capability_detection.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py"+ ],+ "utils.transformers_version._probe_tier": [+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py"+ ],+ "utils.transformers_version._resolve_base_model": [+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py"+ ],+ "utils.transformers_version._venv_dir_is_valid": [+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py"+ ],+ "utils.transformers_version.get_hf_cache_paths": [+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py"+ ],+ "utils.transformers_version.get_transformers_activation_tier": [+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py"+ ],+ "utils.transformers_version.get_transformers_tier": [+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_vision_cache.py"+ ],+ "utils.transformers_version.latest_tier_active_for": [+ "tests/test_chat_load_during_training.py",+ "tests/test_chat_load_during_training.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py"+ ],+ "utils.transformers_version.logger": [+ "tests/test_transformers_version.py"+ ],+ "utils.transformers_version.needs_transformers_5": [+ "tests/test_gpu_selection.py",+ "tests/test_gpu_selection.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py",+ "tests/test_vision_cache.py"+ ],+ "utils.transformers_version.sidecar_swap_in_progress": [+ "tests/test_training_cached_start.py"+ ],+ "utils.transformers_version.subprocess.run": [+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py",+ "tests/test_transformers_version.py"+ ],+ "utils.utils.hf_cache_snapshot_dir": [+ "tests/test_file_security.py"+ ],+ "utils.utils.hf_dns_dead": [+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py"+ ],+ "utils.utils.hf_env_offline": [+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py",+ "tests/test_training_cached_start.py"+ ],+ "utils.utils.hf_proxy_configured": [+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py"+ ],+ "utils.utils.hf_tcp_reachable": [+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py",+ "tests/test_offline_gguf_cache_fallback.py"+ ],+ "utils.utils.hf_unreachable": [+ "tests/test_offline_gguf_cache_fallback.py"+ ]+}diff --git a/studio/backend/tests/data/refactor_guard/runtime_inventory.json b/studio/backend/tests/data/refactor_guard/runtime_inventory.jsonnew file mode 100644index 00000000000..089f31ba00a--- /dev/null+++ b/studio/backend/tests/data/refactor_guard/runtime_inventory.json@@ -0,0 +1,311 @@+{+ "core.inference.tool_call_parser": {+ "dir": [+ "Any",+ "BUDGET_EXHAUSTED_NUDGE",+ "DUPLICATE_CALL_NUDGE",+ "INTENT_SIGNAL",+ "MAX_ACT_REPROMPTS",+ "NUDGE_TOOL_CALLS_STATUS",+ "Optional",+ "RAG_MAX_SEARCHES_PER_TURN",+ "RAG_SEARCH_CAP_NUDGE",+ "RENDER_HTML_REPEAT_NUDGE",+ "REPROMPT_MAX_CHARS",+ "TOOL_ERROR_NUDGE",+ "TOOL_ERROR_PREFIXES",+ "TOOL_XML_SIGNALS",+ "_ACTION_VERB",+ "_ATTR_FUNC_OPEN_RE",+ "_BARE_JSON_NAME_RE",+ "_DEEPSEEK_BEGIN_RE",+ "_DEEPSEEK_CALL_BEGIN",+ "_DEEPSEEK_CALL_END",+ "_DEEPSEEK_END",+ "_DEEPSEEK_OPEN_ALT",+ "_DEEPSEEK_OPEN_RE_SRC",+ "_DEEPSEEK_R1_CLOSE_RE",+ "_DEEPSEEK_R1_FENCE",+ "_DEEPSEEK_R1_FUNC_MARKER",+ "_DEEPSEEK_SEP",+ "_EMBEDDED_MARKER_RE",+ "_FUNC_CLOSE_TAG_RE",+ "_GEMMA_ANCHOR_CLOSERS",+ "_GEMMA_BARE_TC_PREFIX_RE",+ "_GEMMA_BARE_TC_RE",+ "_GEMMA_KEY_RE",+ "_GEMMA_STR_BEGIN",+ "_GEMMA_STR_END",+ "_GEMMA_TC_END",+ "_GEMMA_TC_RE",+ "_GLM_ARG_KEY_CLOSE",+ "_GLM_ARG_KEY_OPEN",+ "_GLM_ARG_VAL_CLOSE",+ "_GLM_ARG_VAL_OPEN",+ "_GLM_JSON_NUMERIC_RE",+ "_GLM_TC_CLOSE",+ "_GLM_TC_OPEN_RE",+ "_HELP_OFFER",+ "_KIMI_ARG_BEGIN",+ "_KIMI_CALL_BEGIN",+ "_KIMI_CALL_END",+ "_KIMI_ID_RE",+ "_KIMI_SECTION_BEGIN",+ "_KIMI_SECTION_END",+ "_LLAMA3_BARE_JSON_SENTINELS",+ "_LLAMA3_CALL_CHAIN_RE",+ "_LLAMA3_HEADER_ROLES",+ "_LLAMA3_KEY_RE",+ "_LLAMA3_LIT_RE",+ "_LLAMA3_NUM_RE",+ "_LLAMA3_PYTHON_TAG",+ "_LLAMA3_PY_CALL_HEAD_RE",+ "_LLAMA3_PY_CALL_RE",+ "_LLAMA3_WS_RE",+ "_MISTRAL_ARGS_MARKER",+ "_MISTRAL_CALL_ID_MARKER",+ "_MISTRAL_THINK_CLOSE",+ "_MISTRAL_THINK_OPEN",+ "_MISTRAL_TRIGGER",+ "_MISTRAL_V11_NAME_RE",+ "_OUTER_ENVELOPE_CLOSED_PATS",+ "_OUTER_ENVELOPE_OPEN_RE",+ "_REPEAT_LEAD_PUNCT",+ "_REPEAT_TRAIL_PUNCT",+ "_TC_END_TAG_RE",+ "_TC_FUNC_CLOSE_RE",+ "_TC_FUNC_START_RE",+ "_TC_JSON_START_RE",+ "_TC_PARAM_CLOSE_RE",+ "_TC_PARAM_START_RE",+ "_TOOL_ALL_PATS",+ "_TOOL_CLOSED_PATS",+ "_balanced_brace_end",+ "_balanced_bracket_end",+ "_bare_json_call_shaped",+ "_consume_mistral_call",+ "_disabled_gemma_call_end_containing_signal",+ "_find_outside_json_strings",+ "_first_foreign_tool_signal",+ "_gemma_balanced_brace_end",+ "_gemma_body_brace_end",+ "_gemma_call_is_anchored",+ "_gemma_coerce_scalar",+ "_gemma_parse_array",+ "_gemma_parse_mapping",+ "_gemma_parse_stripped_body",+ "_gemma_parse_value",+ "_gemma_strip_quoted_leaves",+ "_glm_value_close",+ "_inside_open_parameter",+ "_leading_json_value_end",+ "_llama3_kv_value",+ "_marker_inside_leading_envelope",+ "_mistral_region_end",+ "_normalize_for_repeat",+ "_parse_bare_rehearsals",+ "_parse_deepseek_tool_calls",+ "_parse_function_xml",+ "_parse_gemma_tool_calls",+ "_parse_glm_tool_calls",+ "_parse_kimi_section_body",+ "_parse_kimi_tool_calls",+ "_parse_llama3_bare_json",+ "_parse_llama3_kv_args",+ "_parse_llama3_python_tag",+ "_parse_mistral_array",+ "_parse_mistral_tool_calls",+ "_parse_tool_call_json",+ "_signal_inside_leading_wrapperless_gemma",+ "_skip_mistral_call_id",+ "_strip_function_xml_calls",+ "_strip_gemma_wrapperless_calls",+ "_strip_glm_calls",+ "_strip_mistral_closed_calls",+ "_strip_mistral_reasoning",+ "_tool_healing",+ "_top_level_bare_json_name",+ "_trim_param_value",+ "_whole_content_is_json_value",+ "_xml_signal_inside_leading_bare_json",+ "_xml_signal_inside_leading_mistral",+ "annotations",+ "has_tool_signal",+ "is_reprompt_repeat",+ "is_reprompt_restatement",+ "is_short_intent_without_action",+ "json",+ "parse_tool_calls_from_text",+ "re",+ "reprompt_to_act_message",+ "strip_leading_bare_json_call",+ "strip_llama3_leading_sentinels",+ "strip_segment",+ "strip_tool_markup"+ ],+ "functions": {+ "_balanced_brace_end": "core.tool_healing._balanced_brace_end(content: 'str', brace_start: 'int', *, gemma_quotes: 'bool' = False) -> 'int | None'",+ "_balanced_bracket_end": "core.inference.tool_call_parser._balanced_bracket_end(src: 'str', start: 'int') -> \"'int | None'\"",+ "_bare_json_call_shaped": "core.inference.tool_call_parser._bare_json_call_shaped(obj) -> 'bool'",+ "_consume_mistral_call": "core.inference.tool_call_parser._consume_mistral_call(obj_text: 'str', out: 'list[dict]', id_offset: 'int') -> 'None'",+ "_disabled_gemma_call_end_containing_signal": "core.inference.tool_call_parser._disabled_gemma_call_end_containing_signal(content: 'str', enabled_tool_names: 'Optional[set]') -> 'int | None'",+ "_find_outside_json_strings": "core.inference.tool_call_parser._find_outside_json_strings(text: 'str', needle: 'str', start: 'int') -> 'int'",+ "_first_foreign_tool_signal": "core.inference.tool_call_parser._first_foreign_tool_signal(content: 'str') -> 'int | None'",+ "_gemma_balanced_brace_end": "core.inference.tool_call_parser._gemma_balanced_brace_end(text: 'str', brace_pos: 'int', hard_stop: 'int') -> 'int | None'",+ "_gemma_body_brace_end": "core.inference.tool_call_parser._gemma_body_brace_end(text: 'str', brace_pos: 'int') -> 'int | None'",+ "_gemma_call_is_anchored": "core.inference.tool_call_parser._gemma_call_is_anchored(text: 'str', start: 'int', floor: 'int') -> 'bool'",+ "_gemma_coerce_scalar": "core.inference.tool_call_parser._gemma_coerce_scalar(raw: 'str') -> 'Any'",+ "_gemma_parse_array": "core.inference.tool_call_parser._gemma_parse_array(text: 'str', start: 'int')",+ "_gemma_parse_mapping": "core.inference.tool_call_parser._gemma_parse_mapping(text: 'str', start: 'int')",+ "_gemma_parse_stripped_body": "core.inference.tool_call_parser._gemma_parse_stripped_body(body: 'str') -> 'dict[str, Any]'",+ "_gemma_parse_value": "core.inference.tool_call_parser._gemma_parse_value(text: 'str', i: 'int', *, in_mapping: 'bool' = False)",+ "_gemma_strip_quoted_leaves": "core.inference.tool_call_parser._gemma_strip_quoted_leaves(value: 'Any') -> 'Any'",+ "_glm_value_close": "core.inference.tool_call_parser._glm_value_close(text: 'str', vs: 'int', *, strict: 'bool' = False) -> 'int'",+ "_inside_open_parameter": "core.inference.tool_call_parser._inside_open_parameter(text: 'str', pos: 'int') -> 'bool'",+ "_leading_json_value_end": "core.inference.tool_call_parser._leading_json_value_end(text: 'str') -> 'int | None'",+ "_llama3_kv_value": "core.inference.tool_call_parser._llama3_kv_value(body: 'str', p: 'int', n: 'int') -> 'tuple[Any, int | None]'",+ "_marker_inside_leading_envelope": "core.inference.tool_call_parser._marker_inside_leading_envelope(content: 'str', enabled_tool_names: 'Optional[set]' = None) -> 'bool'",+ "_mistral_region_end": "core.inference.tool_call_parser._mistral_region_end(text: 'str', idx: 'int') -> 'int | None'",+ "_normalize_for_repeat": "core.inference.tool_call_parser._normalize_for_repeat(text: 'str') -> 'str'",+ "_parse_bare_rehearsals": "core.inference.tool_call_parser._parse_bare_rehearsals(content: 'str', *, id_offset: 'int' = 0, enabled_tool_names: 'Optional[set]' = None) -> 'list[dict]'",+ "_parse_deepseek_tool_calls": "core.inference.tool_call_parser._parse_deepseek_tool_calls(content: 'str', *, id_offset: 'int', allow_incomplete: 'bool' = True) -> 'list[dict]'",+ "_parse_function_xml": "core.inference.tool_call_parser._parse_function_xml(content: 'str', *, id_offset: 'int', allow_incomplete: 'bool' = True) -> 'list[dict]'",+ "_parse_gemma_tool_calls": "core.inference.tool_call_parser._parse_gemma_tool_calls(content: 'str', *, id_offset: 'int', allow_incomplete: 'bool' = True, enabled_tool_names: 'Optional[set]' = None) -> 'list[dict]'",+ "_parse_glm_tool_calls": "core.inference.tool_call_parser._parse_glm_tool_calls(content: 'str', *, id_offset: 'int', allow_incomplete: 'bool' = True) -> 'list[dict]'",+ "_parse_kimi_section_body": "core.inference.tool_call_parser._parse_kimi_section_body(body: 'str', *, id_offset: 'int', allow_incomplete: 'bool' = True) -> 'list[dict]'",+ "_parse_kimi_tool_calls": "core.inference.tool_call_parser._parse_kimi_tool_calls(content: 'str', *, id_offset: 'int', allow_incomplete: 'bool' = True) -> 'list[dict]'",+ "_parse_llama3_bare_json": "core.inference.tool_call_parser._parse_llama3_bare_json(content: 'str', *, id_offset: 'int', allow_incomplete: 'bool' = True, enabled_tool_names: 'Optional[set]' = None) -> 'list[dict]'",+ "_parse_llama3_kv_args": "core.inference.tool_call_parser._parse_llama3_kv_args(body: 'str') -> 'dict[str, Any]'",+ "_parse_llama3_python_tag": "core.inference.tool_call_parser._parse_llama3_python_tag(content: 'str', *, id_offset: 'int', allow_incomplete: 'bool' = True) -> 'list[dict]'",+ "_parse_mistral_array": "core.inference.tool_call_parser._parse_mistral_array(content: 'str', start: 'int', id_offset: 'int', allow_incomplete: 'bool' = True) -> 'list[dict]'",+ "_parse_mistral_tool_calls": "core.inference.tool_call_parser._parse_mistral_tool_calls(content: 'str', *, id_offset: 'int', allow_incomplete: 'bool' = True) -> 'list[dict]'",+ "_parse_tool_call_json": "core.inference.tool_call_parser._parse_tool_call_json(content: 'str', *, id_offset: 'int', allow_incomplete: 'bool' = True) -> 'list[dict]'",+ "_signal_inside_leading_wrapperless_gemma": "core.inference.tool_call_parser._signal_inside_leading_wrapperless_gemma(content: 'str', enabled_tool_names: 'Optional[set]') -> 'bool'",+ "_skip_mistral_call_id": "core.inference.tool_call_parser._skip_mistral_call_id(text: 'str', pos: 'int') -> 'int'",+ "_strip_function_xml_calls": "core.inference.tool_call_parser._strip_function_xml_calls(text: 'str', *, final: 'bool') -> 'str'",+ "_strip_gemma_wrapperless_calls": "core.inference.tool_call_parser._strip_gemma_wrapperless_calls(text: 'str', enabled_tool_names: 'Optional[set]' = None) -> 'str'",+ "_strip_glm_calls": "core.inference.tool_call_parser._strip_glm_calls(text: 'str', *, final: 'bool') -> 'str'",+ "_strip_mistral_closed_calls": "core.inference.tool_call_parser._strip_mistral_closed_calls(text: 'str') -> 'str'",+ "_strip_mistral_reasoning": "core.inference.tool_call_parser._strip_mistral_reasoning(content: 'str') -> 'str'",+ "_top_level_bare_json_name": "core.inference.tool_call_parser._top_level_bare_json_name(probe: 'str') -> 'Optional[str]'",+ "_trim_param_value": "core.tool_healing._trim_param_value(val: 'str') -> 'str'",+ "_whole_content_is_json_value": "core.inference.tool_call_parser._whole_content_is_json_value(text: 'str') -> 'bool'",+ "_xml_signal_inside_leading_bare_json": "core.inference.tool_call_parser._xml_signal_inside_leading_bare_json(content: 'str') -> 'bool'",+ "_xml_signal_inside_leading_mistral": "core.inference.tool_call_parser._xml_signal_inside_leading_mistral(content: 'str') -> 'bool'",+ "has_tool_signal": "core.inference.tool_call_parser.has_tool_signal(text: 'str') -> 'bool'",+ "is_reprompt_repeat": "core.inference.tool_call_parser.is_reprompt_repeat(text: 'str', previous: 'str') -> 'bool'",+ "is_reprompt_restatement": "core.inference.tool_call_parser.is_reprompt_restatement(text: 'str', previous: 'str') -> 'bool'",+ "is_short_intent_without_action": "core.inference.tool_call_parser.is_short_intent_without_action(text: 'str') -> 'bool'",+ "parse_tool_calls_from_text": "core.inference.tool_call_parser.parse_tool_calls_from_text(content: 'str', *, id_offset: 'int' = 0, allow_incomplete: 'bool' = True, enabled_tool_names: 'Optional[set]' = None) -> 'list[dict]'",+ "reprompt_to_act_message": "core.inference.tool_call_parser.reprompt_to_act_message(tool_hint: 'str') -> 'str'",+ "strip_leading_bare_json_call": "core.inference.tool_call_parser.strip_leading_bare_json_call(text: 'str', enabled_tool_names: 'Optional[set]' = None) -> 'str'",+ "strip_llama3_leading_sentinels": "core.inference.tool_call_parser.strip_llama3_leading_sentinels(content: 'str') -> 'str'",+ "strip_segment": "core.inference.tool_call_parser.strip_segment(segment: 'str', *, seg_final: 'bool', enabled_tool_names: 'Optional[set]' = None) -> 'str'",+ "strip_tool_markup": "core.inference.tool_call_parser.strip_tool_markup(text: 'str', *, final: 'bool' = False, enabled_tool_names: 'Optional[set]' = None) -> 'str'"+ }+ },+ "core.tool_healing": {+ "dir": [+ "_BRACKETED_JSON_ONE_LEVEL",+ "_CODE_SPAN_RE",+ "_FUNC_CLOSE_TAG",+ "_GEMMA_NEXT_KEY_RE",+ "_GEMMA_QUOTE",+ "_MAX_BRACKET_SCAN_CHARS",+ "_MISTRAL_ARRAY_RE",+ "_MISTRAL_BRACKET_RE",+ "_PARAM_CLOSE_TAG",+ "_PAT_REQUIRED_TOKEN",+ "_REHEARSAL_CLOSED_STRIP_RE",+ "_REHEARSAL_RE",+ "_REHEARSAL_STRIP_PATS",+ "_REHEARSAL_TAIL_STRIP_RE",+ "_TC_END_TAG_RE",+ "_TC_FUNC_CLOSED_PAT",+ "_TC_FUNC_CLOSE_RE",+ "_TC_FUNC_START_RE",+ "_TC_GEMMA_CLOSED_PAT",+ "_TC_GEMMA_END_TAG_RE",+ "_TC_GEMMA_START_RE",+ "_TC_JSON_CLOSED_PAT",+ "_TC_JSON_START_RE",+ "_TC_PARAM_CLOSE_RE",+ "_TC_PARAM_START_RE",+ "_THINK_CLOSE_RE",+ "_THINK_OPEN_RE",+ "_THINK_TAG_RE",+ "_TOOL_ALL_PATS",+ "_TOOL_CLOSED_BLOCK_PATS",+ "_TOOL_CLOSED_PATS",+ "_TOOL_OPEN_XML_TAIL_PATS",+ "_balanced_brace_end",+ "_balanced_bracket_end",+ "_balanced_json_span",+ "_build_markers",+ "_code_spans",+ "_decode_array_items",+ "_func_close_index",+ "_gemma_arguments_to_json",+ "_gemma_span_ranges",+ "_in_code",+ "_inside_open_parameter",+ "_iter_bracket_spans",+ "_marker_coverage",+ "_normalise_gemma_quoted_strings",+ "_quote_gemma_array_elements",+ "_quote_gemma_object_keys",+ "_rehearsal_strip",+ "_split_top_level_commas",+ "_strip_bracket_tag_calls",+ "_strip_closed_blocks_outside_gemma",+ "_strip_gemma_native_spans",+ "_strip_markup_segment",+ "_think_spans_outside_tool_markup",+ "_tool_call_markup_spans",+ "_trim_param_value",+ "annotations",+ "apply_tool_strip_patterns",+ "bisect",+ "json",+ "marker_coverage",+ "parse_tool_calls_from_text",+ "re",+ "strip_outside_think",+ "strip_tool_call_markup",+ "strip_tool_patterns"+ ],+ "functions": {+ "_balanced_brace_end": "core.tool_healing._balanced_brace_end(content: 'str', brace_start: 'int', *, gemma_quotes: 'bool' = False) -> 'int | None'",+ "_balanced_bracket_end": "core.tool_healing._balanced_bracket_end(src: 'str', start: 'int', *, braces_count: 'bool' = True) -> 'int | None'",+ "_balanced_json_span": "core.tool_healing._balanced_json_span(text: 'str', start: 'int') -> 'int | None'",+ "_build_markers": "core.tool_healing._build_markers(content: 'str')",+ "_code_spans": "core.tool_healing._code_spans(text: 'str') -> 'list[tuple[int, int]]'",+ "_decode_array_items": "core.tool_healing._decode_array_items(text: 'str', body_start: 'int', body_end: 'int')",+ "_func_close_index": "core.tool_healing._func_close_index(content: 'str', body_start: 'int', body: 'str') -> 'int'",+ "_gemma_arguments_to_json": "core.tool_healing._gemma_arguments_to_json(args_src: 'str') -> 'dict'",+ "_gemma_span_ranges": "core.tool_healing._gemma_span_ranges(text: 'str') -> 'list'",+ "_in_code": "core.tool_healing._in_code(spans, pos: 'int') -> 'bool'",+ "_inside_open_parameter": "core.tool_healing._inside_open_parameter(content: 'str', pos: 'int', *, param_start_re=None, param_closers=('</parameter>',), func_closers=('</function>',)) -> 'bool'",+ "_iter_bracket_spans": "core.tool_healing._iter_bracket_spans(text: 'str', start: 'int' = 0, enabled_tool_names=None)",+ "_marker_coverage": "core.tool_healing._marker_coverage(content: 'str', markers) -> 'list[tuple[int, int]]'",+ "_normalise_gemma_quoted_strings": "core.tool_healing._normalise_gemma_quoted_strings(src: 'str') -> 'str'",+ "_quote_gemma_array_elements": "core.tool_healing._quote_gemma_array_elements(body: 'str') -> 'str'",+ "_quote_gemma_object_keys": "core.tool_healing._quote_gemma_object_keys(src: 'str') -> 'str'",+ "_rehearsal_strip": "core.tool_healing._rehearsal_strip(m, pat, text, spans, enabled_tool_names) -> 'str'",+ "_split_top_level_commas": "core.tool_healing._split_top_level_commas(src: 'str') -> 'list'",+ "_strip_bracket_tag_calls": "core.tool_healing._strip_bracket_tag_calls(text: 'str', enabled_tool_names=None) -> 'str'",+ "_strip_closed_blocks_outside_gemma": "core.tool_healing._strip_closed_blocks_outside_gemma(text: 'str') -> 'str'",+ "_strip_gemma_native_spans": "core.tool_healing._strip_gemma_native_spans(text: 'str', *, final: 'bool') -> 'str'",+ "_strip_markup_segment": "core.tool_healing._strip_markup_segment(text: 'str', *, final: 'bool', enabled_tool_names=None) -> 'str'",+ "_think_spans_outside_tool_markup": "core.tool_healing._think_spans_outside_tool_markup(text: 'str') -> 'list[tuple[int, int]]'",+ "_tool_call_markup_spans": "core.tool_healing._tool_call_markup_spans(text: 'str') -> 'list[tuple[int, int]]'",+ "_trim_param_value": "core.tool_healing._trim_param_value(val: 'str') -> 'str'",+ "apply_tool_strip_patterns": "core.tool_healing.apply_tool_strip_patterns(text: 'str', patterns, enabled_tool_names=None) -> 'str'",+ "marker_coverage": "core.tool_healing.marker_coverage(content: 'str') -> 'list[tuple[int, int]]'",+ "parse_tool_calls_from_text": "core.tool_healing.parse_tool_calls_from_text(content: 'str', *, id_offset: 'int' = 0, allow_incomplete: 'bool' = True, enabled_tool_names=None, with_spans: 'bool' = False)",+ "strip_outside_think": "core.tool_healing.strip_outside_think(text: 'str', strip_segment) -> 'str'",+ "strip_tool_call_markup": "core.tool_healing.strip_tool_call_markup(text: 'str', *, final: 'bool' = False, enabled_tool_names=None) -> 'str'",+ "strip_tool_patterns": "core.tool_healing.strip_tool_patterns(text: 'str', patterns) -> 'str'"+ }+ }+}diff --git a/studio/backend/tests/test_gguf_load_intent_slots.py b/studio/backend/tests/test_gguf_load_intent_slots.pynew file mode 100644index 00000000000..12c4acc7c40--- /dev/null+++ b/studio/backend/tests/test_gguf_load_intent_slots.py@@ -0,0 +1,122 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""``GgufLoadIntent`` stays reflectable, and the signal exceptions stay slotted.++``@dataclass(slots=True)`` was tried on the intent and reverted: it removes the instance+``__dict__``, so ``vars(intent)`` raises ``TypeError`` and every GGUF load through+``_gguf_request_intent`` (plus the MTP recovery assertions in ``test_tensor_parallel.py``)+broke. Both halves of that conclusion are pinned here.+"""++import copy+import dataclasses+import pickle+import sys+from pathlib import Path++import pytest++BACKEND_ROOT = Path(__file__).resolve().parents[1]+if str(BACKEND_ROOT) not in sys.path:+ sys.path.insert(0, str(BACKEND_ROOT))++from core.inference.llama_cpp import ( # noqa: E402+ CountAborted,+ GgufLoadIntent,+ LlamaServerNotFoundError,+ _LlamaStreamCancelled,+)+++def intent():+ # Lists in: __post_init__ freezes them to tuples so the intent stays hashable.+ return GgufLoadIntent(+ model_identifier = "unsloth/gemma-4-E2B-it-GGUF",+ gpu_ids = [0, 1],+ extra_args = ["--flash-attn"],+ tensor_split = [0.5, 0.5],+ )+++def test_intent_keeps_its_instance_dict(intent):+ """The revert, pinned: several callers enumerate the intent through ``vars()``."""+ assert not hasattr(GgufLoadIntent, "__slots__")+ assert set(vars(intent)) == {f.name for f in dataclasses.fields(intent)}+++def test_post_init_freezes_sequences(intent):+ assert intent.gpu_ids == (0, 1)+ assert intent.extra_args == ("--flash-attn",)+ assert intent.tensor_split == (0.5, 0.5)+++def test_empty_gpu_ids_normalizes_to_none():+ assert GgufLoadIntent(model_identifier = "m", gpu_ids = []).gpu_ids is None+++def test_replace_preserves_the_rest(intent):+ """Retries rebuild the intent with one field changed."""+ replaced = dataclasses.replace(intent, n_ctx = 8192)++ assert replaced.n_ctx == 8192+ assert replaced.model_identifier == intent.model_identifier+ assert replaced.gpu_ids == intent.gpu_ids+++def test_equality_ignores_whether_sequences_arrived_as_lists(intent):+ assert intent == GgufLoadIntent(+ model_identifier = "unsloth/gemma-4-E2B-it-GGUF",+ gpu_ids = (0, 1),+ extra_args = ("--flash-attn",),+ tensor_split = (0.5, 0.5),+ )+++def test_copy_and_pickle_round_trip(intent):+ """``slots=True`` changes the pickle protocol used, so both are exercised."""+ assert copy.deepcopy(intent) == intent+ assert pickle.loads(pickle.dumps(intent)) == intent+++def test_still_frozen(intent):+ with pytest.raises(dataclasses.FrozenInstanceError):+ intent.n_ctx = 1+++def test_fields_and_asdict_are_unaffected(intent):+ names = [f.name for f in dataclasses.fields(intent)]++ assert "model_identifier" in names+ assert dataclasses.asdict(intent)["gpu_ids"] == (0, 1)+++ "exception", [CountAborted, LlamaServerNotFoundError, _LlamaStreamCancelled]+)+def test_signal_exceptions_carry_empty_slots(exception):+ """These only ever signal, and the empty ``__slots__`` records that.++ It does not remove the instance dict (``BaseException`` declares one itself); what it+ buys is the intent plus the guarantee that the class carries no slot of its own.+ """+ assert exception.__slots__ == ()+ assert "__dict__" in vars(BaseException)++ with pytest.raises(exception, match = "boom"):+ raise exception("boom")+++def test_llama_server_not_found_is_still_a_runtime_error():+ """Existing handlers catch RuntimeError; adding slots must not change the MRO."""+ assert issubclass(LlamaServerNotFoundError, RuntimeError)+++def test_field_names_are_enumerable_without_reflection(intent):+ """``dataclasses.fields`` answers the same question ``vars()`` does.++ What ``_gguf_request_intent`` uses now: equivalent on this class, and independent of+ the instance ``__dict__`` that slots would have removed.+ """+ assert [f.name for f in dataclasses.fields(intent)] == list(vars(intent))diff --git a/studio/backend/tests/test_refactor_guard.py b/studio/backend/tests/test_refactor_guard.pynew file mode 100644index 00000000000..156fdd0eb7a--- /dev/null+++ b/studio/backend/tests/test_refactor_guard.py@@ -0,0 +1,208 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""Runs the refactor guard in CI.++``tests/tools/refactor_guard.py`` pins the tool-call parsing / stripping stack three ways:+module AST and runtime surface, a digest of every guarded function's output over a+1,833-input corpus, and the test suite's string patch targets. Re-baseline with+``python tests/tools/refactor_guard.py snapshot`` and review the diff.+"""++import sys+from pathlib import Path++import pytest++BACKEND_ROOT = Path(__file__).resolve().parents[1]+if str(BACKEND_ROOT) not in sys.path:+ sys.path.insert(0, str(BACKEND_ROOT))+sys.path.insert(0, str(BACKEND_ROOT / "tests" / "tools"))++import refactor_guard # noqa: E402++[email protected](scope = "module")+def corpus():+ return refactor_guard.build_corpus()+++def test_ast_inventory_matches_the_baseline():+ """A dropped or re-signatured top-level name is an import break for some caller."""+ # Same helper ``verify`` uses, so CI and the CLI agree.+ problems = refactor_guard._ast_problems()++ assert not problems, "\n".join(problems[:40])+++def test_runtime_surface_matches_the_baseline():+ """Catches re-export aliasing and decorator changes the AST cannot see."""+ problems = refactor_guard._diff(+ "runtime",+ refactor_guard._read("runtime_inventory.json"),+ refactor_guard.runtime_inventory(),+ )++ assert not problems, "\n".join(problems[:40])+++def test_guarded_functions_produce_the_same_bytes(corpus):+ problems = refactor_guard._diff(+ "golden",+ refactor_guard._read("golden_outputs.json"),+ refactor_guard.golden_outputs(corpus),+ )++ assert not problems, "\n".join(problems[:40])+++def test_no_new_non_idempotent_strip(corpus):+ """``strip(strip(x)) == strip(x)``, or display text depends on stream chunking.++ Known failures are recorded in the baseline, one entry per boolean variant; the check+ is that the set does not grow. Keyed by variant, so a ``final = True`` failure is no+ licence for the ``final = False`` streaming path to start.+ """+ baseline = {+ (entry["module"], entry["function"], entry.get("variant", ""))+ for entry in refactor_guard._read("idempotence_baseline.json")+ }+ new = [+ f"{entry['module']}.{entry['function']}[{entry['variant']}] for {entry['input']!r}"+ for entry in refactor_guard.idempotence_failures(corpus)+ if (entry["module"], entry["function"], entry["variant"]) not in baseline+ ]++ assert not new, "\n".join(new)+++def test_every_string_patch_target_still_resolves():+ """A moved symbol leaves ``patch("mod.NAME")`` pointing at a namespace nobody reads,+ so the test passes while exercising unpatched code."""+ live = refactor_guard.patch_targets()+ broken = [+ entry+ for entry in refactor_guard.unresolvable_patch_targets(live)+ if not entry.get("environment")+ ]++ assert not broken, "\n".join(f"{e['target']}: {e['reason']} ({e['tests'][0]})" for e in broken)+++def test_the_recorded_patch_target_inventory_still_matches():+ """Resolving is not enough: the recorded routing has to be the live routing.++ A patch repointed at another resolvable namespace, or dropped, resolves fine. CI runs+ pytest and never the ``verify`` CLI, so the comparison has to live here.+ """+ recorded = {+ target: sorted(tests)+ for target, tests in refactor_guard._read("patch_targets.json").items()+ }+ live = {target: sorted(tests) for target, tests in refactor_guard.patch_targets().items()}++ problems = refactor_guard._diff("patch-targets", recorded, live, additions_matter = False)++ assert not problems, "\n".join(problems[:20])+++def test_a_deleted_patch_target_is_not_written_off_as_environmental():+ """The ``environment`` escape hatch must not swallow a genuinely dead target.++ ``importlib.import_module("mod.attr")`` raises ``ModuleNotFoundError`` for a deleted+ attribute just as it does for a missing optional dependency, and the check above+ filters environmental entries out, so conflating the two would make it vacuous.+ """+ broken = refactor_guard.unresolvable_patch_targets(+ {+ "core.tool_healing.deleted_name": ["fake_test.py"],+ "core.inference.deleted_name": ["fake_test.py"],+ }+ )++ assert {entry["target"] for entry in broken} == {+ "core.tool_healing.deleted_name",+ "core.inference.deleted_name",+ }+ assert not any(entry.get("environment") for entry in broken)+++def test_no_guarded_function_is_driven_by_a_sentinel():+ """Every guarded function has to be actually called, or its golden digest pins+ nothing and an arbitrary rewrite of it passes."""+ # The whole corpus, not a slice: several functions are constant over any small prefix+ # and only vary once the rarer serializations appear, so a slice reports false gaps.+ corpus = refactor_guard.build_corpus()+ undrivable = sorted(+ name+ for module in refactor_guard.BEHAVIOUR_MODULES+ for name, func in refactor_guard._guarded_functions(module)+ if refactor_guard._drive(func, corpus[0]) == "<undrivable>"+ )++ assert not undrivable, f"no argument fixture for: {undrivable}"++ constant = sorted(+ name+ for module in refactor_guard.BEHAVIOUR_MODULES+ for name, func in refactor_guard._guarded_functions(module)+ if len({repr(refactor_guard._drive(func, text)) for text in corpus}) == 1+ )++ assert len(constant) <= 4, f"too many functions pin a single value: {constant}"+++def test_a_dropped_lazy_export_is_not_written_off_as_environmental():+ """``core.inference`` resolves through a PEP 562 ``__getattr__``: a missing optional+ dependency surfaces as ImportError, a dropped export as AttributeError, and only the+ first is an environment gap."""+ broken = refactor_guard.unresolvable_patch_targets(+ {"core.inference.no_such_lazy_export": ["fake_test.py"]}+ )++ assert [entry["target"] for entry in broken] == ["core.inference.no_such_lazy_export"]+ assert not any(entry.get("environment") for entry in broken)+++def test_the_scan_order_inside_strip_segment_is_pinned():+ """The arm order in ``strip_segment`` is what this branch unified.++ Swapping the function-XML and GLM arms passed the guard: the corpus only concatenated+ whole calls, and the order shows up only when an arm can eat a later arm's opener.+ """+ from core.inference.tool_call_parser import strip_segment++ text = "<function=x><tool_call> txt <arg_key>c</arg_key></function><parameter=p>"++ assert strip_segment(text, seg_final = True, enabled_tool_names = {"x"}) == "<parameter=p>"+++def test_strip_tool_markup_is_pinned_at_both_final_values():+ """``final = False`` is the streaming path, and it was driven at one value only."""+ from core.inference.tool_call_parser import strip_tool_markup++ text = (+ '<function=get_weather><parameter=q><tool_call>{"a":1}</tool_call>'+ "</parameter></function> tail"+ )+ names = {"get_weather"}++ assert strip_tool_markup(text, final = False, enabled_tool_names = names) == " tail"+ assert strip_tool_markup(text, final = True, enabled_tool_names = names) == "tail"+++def test_an_unrelated_addition_elsewhere_does_not_fail_the_guard():+ """Additions are not regressions, and a guard that cries on them gets re-snapshotted+ blind. A dropped symbol still has to fail."""+ import copy++ base = refactor_guard.ast_inventory()+ wide = "core.inference.llama_cpp"++ added = copy.deepcopy(base[wide])+ added["symbols"]["_SOMETHING_A_LATER_PR_ADDS"] = {"kind": "assign"}+ assert not refactor_guard._diff("ast", base[wide], added, additions_matter = False)++ dropped = copy.deepcopy(base[wide])+ dropped["symbols"].pop(next(iter(dropped["symbols"])))+ assert refactor_guard._diff("ast", base[wide], dropped, additions_matter = False)diff --git a/studio/backend/tests/test_route_strip_drift.py b/studio/backend/tests/test_route_strip_drift.pynew file mode 100644index 00000000000..a0b48372117--- /dev/null+++ b/studio/backend/tests/test_route_strip_drift.py@@ -0,0 +1,61 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""Pins the known divergence between the route display strip and the canonical one.++``routes/inference.py::_strip_tool_xml_for_display`` predates the parser and never picked+up the markdown-code gating in ``core/tool_healing.py``, so it deletes a rehearsal inside+a fenced code block that the canonical strip keeps.++Changing a shipped streaming route changes what users see, so it is pinned rather than+fixed here: this test fails if either side moves, making the follow-up deliberate.+"""++import sys+from pathlib import Path++import pytest++BACKEND_ROOT = Path(__file__).resolve().parents[1]+if str(BACKEND_ROOT) not in sys.path:+ sys.path.insert(0, str(BACKEND_ROOT))++from core.inference.tool_call_parser import strip_tool_markup # noqa: E402++ENABLED = {"get_weather", "search"}++[email protected](scope = "module")+def route_strip():+ routes_inference = pytest.importorskip("routes.inference")+ return routes_inference._strip_tool_xml_for_display+++def test_route_strip_deletes_a_fenced_rehearsal_canonical_keeps_it(route_strip):+ """The concrete user-visible symptom of the drift."""+ text = '```\nget_weather[ARGS]{"city": "Paris"}\n```'++ assert route_strip(text, auto_heal_tool_calls = True, enabled_tool_names = ENABLED) == "```\n\n```"+ assert strip_tool_markup(text, final = True, enabled_tool_names = ENABLED) == text+++def test_route_strip_deletes_an_inline_code_rehearsal(route_strip):+ text = "`get_weather[ARGS]{}`"++ assert route_strip(text, auto_heal_tool_calls = True, enabled_tool_names = ENABLED) == "``"+ assert strip_tool_markup(text, final = True, enabled_tool_names = ENABLED) == text+++def test_route_strip_still_removes_a_real_call(route_strip):+ """Whatever else differs, the route strip must keep doing its actual job."""+ text = 'Here you go. <tool_call>{"name": "get_weather", "arguments": {"city": "Paris"}}</tool_call>'+ stripped = route_strip(text, auto_heal_tool_calls = True, enabled_tool_names = ENABLED)++ assert "<tool_call>" not in stripped+ assert "Here you go." in stripped+++def test_route_strip_is_disabled_when_healing_is_off(route_strip):+ text = '<tool_call>{"name": "get_weather", "arguments": {}}</tool_call>'++ assert route_strip(text, auto_heal_tool_calls = False, enabled_tool_names = ENABLED) == textdiff --git a/studio/backend/tests/test_tool_strip_guard.py b/studio/backend/tests/test_tool_strip_guard.pyindex dfa31018826..0777b255a9e 100644--- a/studio/backend/tests/test_tool_strip_guard.py+++ b/studio/backend/tests/test_tool_strip_guard.py@@ -74,3 +74,22 @@ def test_no_quadratic_blowup_on_unclosed_markers():out = strip_tool_call_markup(big, final = True)assert time.perf_counter() - t0 < 2.0assert out == ""+++def test_the_two_bracket_depth_rules_stay_separate():+ """The scanner is shared; the depth rule is not, and both callers need their own.++ The healer counts braces toward the bracket depth (its Gemma array normalizer needs+ that); the display strip counts brackets only, or a stray ``}`` would end the span+ early and leave the rest of a malformed call on screen.+ """+ from core import tool_healing+ from core.inference.tool_call_parser import _balanced_bracket_end, strip_tool_markup++ truncated = '[{"name": "x", "arguments": {"a": 1}]'+ assert tool_healing._balanced_bracket_end(truncated, 0) is None+ assert tool_healing._balanced_bracket_end(truncated, 0, braces_count = False) == 36+ assert _balanced_bracket_end(truncated, 0) == 36++ assert strip_tool_markup("[TOOL_CALLS] [} prose ] tail", final = True) == "tail"+ assert tool_healing.strip_tool_call_markup("[TOOL_CALLS] [} prose ] tail") == " prose ] tail"diff --git a/studio/backend/tests/tools/refactor_guard.py b/studio/backend/tests/tools/refactor_guard.pynew file mode 100644index 00000000000..dd5aae078f5--- /dev/null+++ b/studio/backend/tests/tools/refactor_guard.py@@ -0,0 +1,866 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""Deterministic guard for refactors of the tool-call parsing / stripping stack.++Three independent checks, none of which trusts a reading of the diff:++1. **AST inventory** - every top-level name, signature, decorator and ``re.compile``+ literal per guarded module, so a dropped or renamed symbol shows up as a diff.+2. **Golden outputs** - every guarded function driven over a corpus of tool-call text,+ its output recorded, and the strip functions asserted idempotent.+3. **Patch-target routing** - the test suite patches module globals by string+ (``patch("core.inference.llama_cpp.subprocess.run")``). A moved function leaves those+ pointing at a namespace nobody reads, so the test passes while exercising unpatched+ code; this asserts every target still resolves.++Usage::++ python tests/tools/refactor_guard.py snapshot # record the baseline+ python tests/tools/refactor_guard.py verify # compare against it+ python tests/tools/refactor_guard.py twins # report healing/parser divergence++``test_refactor_guard.py`` runs ``verify`` in CI.+"""++from __future__ import annotations++import ast+import hashlib+import importlib+import inspect+import json+import random+import re+import sys+from collections import Counter+from pathlib import Path++BACKEND_ROOT = Path(__file__).resolve().parents[2]+if str(BACKEND_ROOT) not in sys.path:+ sys.path.insert(0, str(BACKEND_ROOT))++BASELINE_DIR = BACKEND_ROOT / "tests" / "data" / "refactor_guard"++# Modules whose top-level surface is pinned. Import path -> file path.+GUARDED_MODULES = {+ "core.tool_healing": BACKEND_ROOT / "core" / "tool_healing.py",+ "core.inference.tool_call_parser": BACKEND_ROOT / "core" / "inference" / "tool_call_parser.py",+ "core.inference.llama_cpp": BACKEND_ROOT / "core" / "inference" / "llama_cpp.py",+ "core.inference.inference": BACKEND_ROOT / "core" / "inference" / "inference.py",+ "core.inference.safetensors_agentic": (+ BACKEND_ROOT / "core" / "inference" / "safetensors_agentic.py"+ ),+}++# Modules whose behaviour is pinned by golden outputs. Importing these must not pull in+# the inference stack, so llama_cpp is deliberately absent.+BEHAVIOUR_MODULES = ("core.tool_healing", "core.inference.tool_call_parser")+++# ─────────────────────────── 1. AST inventory ───────────────────────────+++# Every ``re`` entry point carrying a pattern, not just ``compile``: an inline+# ``re.match(r"...")`` is as load-bearing as a compiled constant.+_RE_CALLS = frozenset(+ {"compile", "match", "search", "fullmatch", "sub", "subn", "split", "findall", "finditer"}+)+++def _compiled_patterns(mod_name: str) -> dict:+ """Every compiled pattern reachable in the module's namespace, by its actual text.++ The AST half records call *source*, so a pattern interpolating a constant pins only+ that constant's name. ``.pattern`` off the live object pins what was compiled.+ """+ module = importlib.import_module(mod_name)+ out = {}+ for name in dir(module):+ obj = getattr(module, name, None)+ for index, item in enumerate(obj if isinstance(obj, (list, tuple)) else [obj]):+ if isinstance(item, re.Pattern):+ key = name if not isinstance(obj, (list, tuple)) else f"{name}[{index}]"+ out[key] = f"{item.pattern!r} flags={item.flags}"+ return out+++def _pattern_literals(tree: ast.Module) -> dict:+ """Every ``re.compile(...)`` call in the module, as a multiset of its source.++ A regex rewrite is the easiest silent change to stripping behaviour, so the literals+ are pinned separately. Keyed by call text, so moving unrelated code is not a change.+ """+ calls = []+ for node in ast.walk(tree):+ if (+ isinstance(node, ast.Call)+ and isinstance(node.func, ast.Attribute)+ and node.func.attr in _RE_CALLS+ and isinstance(node.func.value, ast.Name)+ and node.func.value.id == "re"+ ):+ calls.append(ast.unparse(node))+ counts = {}+ for call in calls:+ counts[call] = counts.get(call, 0) + 1+ return counts+++def ast_inventory() -> dict:+ """Top-level surface per guarded module, at the detail that module needs.++ The two restructured modules are pinned in full: signatures, decorators, methods and+ every ``re.compile`` literal. The rest are pinned by name and kind only, which is all+ "did this drop a symbol" needs; pinning their signatures too would fail on every+ later unrelated change to files as busy as ``llama_cpp.py``, and a baseline that gets+ regenerated reflexively guards nothing.+ """+ inventory = {}+ for mod_name, path in GUARDED_MODULES.items():+ detailed = mod_name in BEHAVIOUR_MODULES+ tree = ast.parse(path.read_text(encoding = "utf-8"))+ symbols = {}+ for node in tree.body:+ if not detailed:+ if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):+ symbols[node.name] = {+ "kind": "class" if isinstance(node, ast.ClassDef) else "def"+ }+ elif isinstance(node, ast.Assign):+ for target in node.targets:+ if isinstance(target, ast.Name):+ symbols[target.id] = {"kind": "assign"}+ # An annotated global is an AnnAssign, not an Assign, so it needs its own arm.+ elif isinstance(node, ast.AnnAssign) and isinstance(node.target, ast.Name):+ symbols[node.target.id] = {"kind": "assign"}+ continue+ if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):+ symbols[node.name] = {+ "kind": "async def" if isinstance(node, ast.AsyncFunctionDef) else "def",+ "signature": ast.unparse(node.args),+ "decorators": [ast.unparse(d) for d in node.decorator_list],+ }+ elif isinstance(node, ast.ClassDef):+ methods = {}+ for sub in node.body:+ if isinstance(sub, (ast.FunctionDef, ast.AsyncFunctionDef)):+ methods[sub.name] = {+ "signature": ast.unparse(sub.args),+ "decorators": [ast.unparse(d) for d in sub.decorator_list],+ }+ symbols[node.name] = {+ "kind": "class",+ "bases": [ast.unparse(b) for b in node.bases],+ "decorators": [ast.unparse(d) for d in node.decorator_list],+ "methods": methods,+ }+ elif isinstance(node, ast.Assign):+ for target in node.targets:+ if isinstance(target, ast.Name):+ symbols[target.id] = {"kind": "assign"}+ elif isinstance(node, ast.AnnAssign) and isinstance(node.target, ast.Name):+ symbols[node.target.id] = {"kind": "assign"}+ entry = {"symbols": symbols}+ if detailed:+ entry["regexes"] = _pattern_literals(tree)+ entry["compiled"] = _compiled_patterns(mod_name)+ inventory[mod_name] = entry+ return inventory+++def runtime_inventory() -> dict:+ """``dir()`` plus signatures, which catches re-export aliasing the AST cannot see."""+ out = {}+ for mod_name in BEHAVIOUR_MODULES:+ module = importlib.import_module(mod_name)+ entry = {"dir": sorted(n for n in dir(module) if not n.startswith("__"))}+ signatures = {}+ for name in entry["dir"]:+ obj = getattr(module, name)+ if inspect.isfunction(obj):+ signatures[name] = f"{obj.__module__}.{obj.__qualname__}{inspect.signature(obj)}"+ entry["functions"] = signatures+ out[mod_name] = entry+ return out+++# ─────────────────────────── 2. Corpus + golden outputs ───────────────────────────++# Fragments spliced by the fuzzer: every serialization the parsers claim to handle, plus+# the shapes that historically broke them.+_FRAGMENTS = (+ '<tool_call>{"name": "get_weather", "arguments": {"city": "Paris"}}</tool_call>',+ '<tool_call>{"name": "search", "arguments": {"q": "</tool_call> literal"}}</tool_call>',+ '<tool_call>{"name": "trunc", "arguments": {"a": ',+ "<function=get_weather><parameter=city>Paris</parameter></function>",+ '<function name="get_weather"><parameter=city>Paris</parameter></function>',+ "<function=broken><parameter=city>Paris",+ '<|tool_call>call:get_weather{city:<|"|>Paris<|"|>}<tool_call|>',+ "<|tool_call>call:get_weather{city:Paris",+ 'call:get_weather{city:<|"|>Paris<|"|>}',+ '[TOOL_CALLS]get_weather{"city": "Paris"}',+ '[TOOL_CALLS] [{"name": "get_weather", "arguments": {"city": "Paris"}}]',+ '[TOOL_CALLS]get_weather[ARGS]{"city": "Paris"}',+ 'get_weather[ARGS]{"city": "Paris"}',+ "get_weather[ARGS]{",+ "get_weather[ARGS]",+ 'unlisted_tool[ARGS]{"city": "Paris"}',+ '<|python_tag|>{"name": "get_weather", "parameters": {"city": "Paris"}}',+ '<|python_tag|>get_weather.call(city="Paris")',+ '{"name": "get_weather", "parameters": {"city": "Paris"}}',+ "<|message_model|>get_weather<|content_invoke_tool_json|>"+ '{"name": "get_weather", "args": {"city": "Paris"}}<|end_message|>',+ "<|tool▁calls▁begin|><|tool▁call▁begin|>get_weather<|tool▁sep|>"+ '{"city": "Paris"}<|tool▁call▁end|><|tool▁calls▁end|>',+ "<|tool▁calls▁begin|>function<|tool▁sep|>get_weather\n"+ '```json\n{"city": "Paris"}\n```<|tool▁calls▁end|>',+ "<|tool_calls_section_begin|><|tool_call_begin|>functions.get_weather:0"+ '<|tool_call_argument_begin|>{"city": "Paris"}<|tool_call_end|>'+ "<|tool_calls_section_end|>",+ "<tool_call>get_weather\n<arg_key>city</arg_key>\n<arg_value>Paris</arg_value>\n</tool_call>",+ # One format's markup inside another's argument value: without these, a swap of two+ # arms inside ``strip_segment`` is invisible.+ "<function=x><tool_call> txt <arg_key>c</arg_key></function><parameter=p>",+ '<tool_call>{"name": "search", "arguments": {"q": "<function=get_weather>"}}</tool_call>',+ '<tool_call>{"name": "search", "arguments": {"q": "[TOOL_CALLS]other[ARGS]{}"}}</tool_call>',+ "<function=get_weather><parameter=city><|tool_call>call:search{q:1}<tool_call|></parameter></function>",+ '[TOOL_CALLS]search[ARGS]{"q": "<tool_call>{}</tool_call>"}',+ '<|tool_call>call:search{q:<|"|><think>x</think><|"|>}<tool_call|>',+ '<function=x><parameter=p>get_weather[ARGS]{"a": 1}</parameter></function> tail',+ "<tool_call>get_weather\n<arg_key>c</arg_key>\n<arg_value><function=y></arg_value>\n</tool_call>",+ "<think>I should call get_weather[ARGS]{} but not really</think>",+ "<think>unclosed reasoning",+ '```\nget_weather[ARGS]{"city": "Paris"}\n```',+ "`get_weather[ARGS]{}`",+ "Sure, let me look that up for you.",+ "The weather in Paris is 18 degrees.",+ "",+ "{",+ "}",+ "[",+ "]",+ '[{"a": 1}]',+ "[}]",+ '["a}b"]',+ "\\",+ '{"a": "\\""}',+)++_ENABLED_NAMES = ("get_weather", "search", "trunc", "broken")+++def build_corpus(seed: int = 20260811, count: int = 600) -> list:+ """Deterministic corpus: every fragment alone, every ordered pair, then random splices."""+ corpus = list(_FRAGMENTS)+ for left in _FRAGMENTS:+ for right in _FRAGMENTS:+ corpus.append(left + right)+ rng = random.Random(seed)+ joiners = ("", " ", "\n", "\n\n", " and then ", "\n```\n")+ for _ in range(count):+ parts = [rng.choice(_FRAGMENTS) for _ in range(rng.randint(2, 5))]+ corpus.append(rng.choice(joiners).join(parts))+ # Dedupe while keeping order so the golden file is stable across runs.+ return list(dict.fromkeys(corpus))+++# One fixture per required positional parameter beyond the text. Offsets are derived from+# the text so the balanced scanners start on a real delimiter; without these the driver+# returns ``<undrivable>`` and the digest pins nothing.+_ARG_FIXTURES = {+ "brace_start": lambda text: max(text.find("{"), 0),+ "brace_pos": lambda text: max(text.find("{"), 0),+ "start": lambda text: max(text.find("["), 0),+ "pos": lambda text: len(text),+ "body_start": lambda text: max(text.find("[") + 1, 0),+ "body_end": lambda text: len(text),+ "body": lambda text: text,+ "hard_stop": lambda text: len(text),+ "i": lambda text: 0,+ "idx": lambda text: 0,+ # Scan origin of a strip pass, 0 as the Gemma strip does.+ "floor": lambda text: 0,+ "p": lambda text: 0,+ "n": lambda text: len(text),+ "vs": lambda text: 0,+ "needle": lambda text: "[",+ "out": lambda text: [],+ "previous": lambda text: text,+ "markers": lambda text: _tool_healing_build_markers(text),+ "patterns": lambda text: _tool_healing_all_pats(),+ "strip_segment": lambda text: (lambda segment, is_last: segment),+}+++# Offsets a predicate is asked about. One offset is not coverage for a function whose job+# is to answer differently at different positions.+_SWEEP_PARAMS = frozenset({"pos"})++# Marks a driver result that holds one entry per boolean variant.+_VARIANTS_KEY = "@variants"++# Boolean parameters driven at both values rather than at one.+_BOTH_WAYS = ("final", "seg_final", "with_spans", "allow_incomplete", "gemma_quotes")++# Function name -> what to hand it in place of the raw corpus entry.+_TEXT_ADAPTERS = {"_gemma_arguments_to_json": lambda text: _gemma_argument_body(text)}+++def _sweep_offsets(text: str):+ n = len(text)+ return sorted({0, n // 4, n // 2, (3 * n) // 4, n})+++def _gemma_argument_body(text: str) -> str:+ """A raw Gemma argument body out of ``text``, which is what this parser takes.++ Handed a whole corpus entry it almost always raises ``JSONDecodeError``, so its digest+ pinned the exception rather than the key quoting and array normalization it exists for.+ """+ from core import tool_healing++ brace = text.find("{")+ if brace >= 0:+ end = tool_healing._balanced_brace_end(text, brace)+ if end is not None:+ return text[brace + 1 : end]+ return "city:Paris, n:2, tags:[a, b]"+++def _parser_first_sentinel(text: str):+ from core.inference import tool_call_parser+ return tool_call_parser._first_sentinel(text, 0)+++def _tool_healing_build_markers(text: str):+ from core import tool_healing+ return tool_healing._build_markers(text)+++def _tool_healing_all_pats():+ from core import tool_healing+ return tool_healing._TOOL_ALL_PATS+++def _drive(func, text: str):+ """Call ``func`` with ``text`` however its signature wants it.++ Returns a JSON-safe result, or a marker string when the function raises: a refactor+ that stops raising, or starts, is a change.+ """+ params = inspect.signature(func).parameters+ names = list(params)+ kwargs = {}+ if "enabled_tool_names" in params:+ kwargs["enabled_tool_names"] = set(_ENABLED_NAMES)+ # Keyword-only, so the positional loop below skips them. Driven at BOTH values:+ # pinning ``final = True`` says nothing about the streaming path.+ combos = [{}]+ for flag in _BOTH_WAYS:+ if flag in params:+ combos = [dict(combo, **{flag: value}) for combo in combos for value in (True, False)]+ if "id_offset" in params:+ kwargs["id_offset"] = 0++ # A few take something derived from the text; a whole corpus entry only pins a raise.+ adapter = _TEXT_ADAPTERS.get(getattr(func, "__name__", ""))+ args = [adapter(text) if adapter else text]+ sweep = None+ # Index arguments come from the first plausible offset, not 0, so the balanced+ # scanners are exercised on a real opening delimiter.+ for extra in names[1:]:+ if extra in kwargs or params[extra].kind == inspect.Parameter.KEYWORD_ONLY:+ continue+ if params[extra].default is not inspect.Parameter.empty:+ continue+ fixture = _ARG_FIXTURES.get(extra)+ if fixture is None:+ return "<undrivable>"+ if extra in _SWEEP_PARAMS:+ sweep = extra+ args.append(None)+ continue+ args.append(fixture(text))++ def _call(extra):+ merged = dict(kwargs, **extra)+ if sweep is not None:+ slot = names.index(sweep)+ results = []+ for offset in _sweep_offsets(text):+ args[slot] = offset+ try:+ results.append(_jsonable(func(*args, **merged)))+ except Exception as exc: # noqa: BLE001+ results.append(f"<raised {type(exc).__name__}>")+ return results+ try:+ outcome = func(*args, **merged)+ except Exception as exc: # noqa: BLE001 - the exception type is the pinned value+ return f"<raised {type(exc).__name__}>"+ if "out" in names and args[names.index("out")]:+ return [_jsonable(outcome), _jsonable(args[names.index("out")])]+ return _jsonable(outcome)++ if len(combos) > 1:+ # Tagged: plenty of guarded functions return a dict of their own.+ return {_VARIANTS_KEY: {json.dumps(c, sort_keys = True): _call(c) for c in combos}}+ return _call(combos[0])+++def _jsonable(value):+ if isinstance(value, (str, int, float, bool)) or value is None:+ return value+ if isinstance(value, (list, tuple)):+ return [_jsonable(v) for v in value]+ if isinstance(value, (set, frozenset)):+ return sorted(_jsonable(v) for v in value)+ if isinstance(value, dict):+ return {str(k): _jsonable(v) for k, v in value.items()}+ if inspect.isgenerator(value):+ # A generator's repr carries its address; the yielded values are the behaviour.+ try:+ return [_jsonable(item) for item in value]+ except Exception as exc: # noqa: BLE001 - raising mid-iteration is pinned too+ return f"<raised {type(exc).__name__}>"+ return repr(value)+++def _guarded_functions(mod_name):+ """Single-text-argument functions in a behaviour module, in a stable order."""+ module = importlib.import_module(mod_name)+ out = []+ for name in sorted(dir(module)):+ if name.startswith("__"):+ continue+ obj = getattr(module, name)+ if not inspect.isfunction(obj) or obj.__module__ != mod_name:+ continue+ params = list(inspect.signature(obj).parameters.values())+ if not params:+ continue+ if params[0].annotation not in (str, "str"):+ continue+ out.append((name, obj))+ return out+++def golden_outputs(corpus) -> dict:+ """A digest per guarded function over the whole corpus.++ Storing every output would be a 7 MB file for no extra guarantee. The corpus is+ rebuilt from ``build_corpus`` rather than checked in, so its own digest is recorded+ too and a corpus edit reports as that instead of as 40 behaviour changes.+ """+ out = {"corpus": _digest([len(corpus), corpus])}+ for mod_name in BEHAVIOUR_MODULES:+ per_module = {}+ for name, func in _guarded_functions(mod_name):+ per_module[name] = _digest([_drive(func, text) for text in corpus])+ out[mod_name] = per_module+ return out+++def _digest(value) -> str:+ payload = json.dumps(value, sort_keys = True, ensure_ascii = False, default = repr)+ return hashlib.sha256(payload.encode()).hexdigest()+++def first_divergence(corpus, mod_name, func_name):+ """Recompute one function's outputs so a digest mismatch can be localised.++ Run it on both sides of the revision that moved the digest and compare.+ """+ module = importlib.import_module(mod_name)+ func = getattr(module, func_name)+ return [{"input": text, "output": _drive(func, text)} for text in corpus]+++def _variants(result):+ """``(label, value)`` per boolean variant the driver produced, or one unlabelled pair.++ Keyed off the tag, not off "is it a dict": a parser returning ``{}`` is a result, not+ a set of variants, and reading it as one reports a meaningless failure.+ """+ if isinstance(result, dict) and set(result) == {_VARIANTS_KEY}:+ return sorted(result[_VARIANTS_KEY].items())+ return [("", result)]+++def idempotence_failures(corpus) -> list:+ """``f(f(x)) != f(x)`` for the str -> str functions.++ A stripper that is not idempotent produces different display text depending on how a+ stream is chunked.+ """+ failures = []+ for mod_name in BEHAVIOUR_MODULES:+ for name, func in _guarded_functions(mod_name):+ # Only the strip family is a text -> text projection; feeding a parser's+ # output back into it proves nothing.+ if "strip" not in name or "parse" in name:+ continue+ witnessed = set()+ labels = None+ for text in corpus:+ # One entry per variant; skipping non-strings here would skip the+ # centralized strippers this check is for.+ results = _variants(_drive(func, text))+ if labels is None:+ labels = {variant for variant, _ in results}+ for variant, once in results:+ # One witness per (function, variant): a ``final = True`` failure must+ # not stand in for the streaming path.+ if variant in witnessed:+ continue+ if not isinstance(once, str) or once.startswith("<raised "):+ continue+ twice = dict(_variants(_drive(func, once))).get(variant)+ if twice != once:+ failures.append(+ {+ "module": mod_name,+ "function": name,+ "variant": variant,+ "input": text,+ "once": once,+ "twice": twice,+ }+ )+ witnessed.add(variant)+ if labels is not None and witnessed >= labels:+ break # every variant already has a witness+ return failures+++# ─────────────────────────── 3. Patch-target routing ───────────────────────────++# Every first-party top-level package: stopping at core/routes/utils/state silently+# skipped 32 live targets under hub, storage and picker.+_PATCH_TARGET_RE = re.compile(+ r"""(?:mock\.)?(?:patch|monkeypatch\.setattr)\(\s*"""+ r"""["']((?:core|routes|utils|state|hub|storage|picker)\.[\w.]+)["']"""+)+++def patch_targets(tests_dir = None) -> dict:+ """String patch targets found in the test suite, grouped by module."""+ tests_dir = tests_dir or (BACKEND_ROOT / "tests")+ targets = {}+ for path in sorted(tests_dir.rglob("test_*.py")):+ for match in _PATCH_TARGET_RE.finditer(path.read_text(encoding = "utf-8", errors = "ignore")):+ dotted = match.group(1)+ # ``as_posix``: the native form gives backslashes on Windows, so an identical+ # checkout would read as a changed inventory.+ targets.setdefault(dotted, []).append(path.relative_to(BACKEND_ROOT).as_posix())+ return targets+++def unresolvable_patch_targets(targets = None) -> list:+ """Targets that no longer resolve to an attribute of an importable module.++ Splits ``a.b.c`` at every dot: the longest importable prefix is the module, the+ remainder must be reachable by ``getattr``.+ """+ targets = targets if targets is not None else patch_targets()+ broken = []+ for dotted, users in sorted(targets.items()):+ parts = dotted.split(".")+ obj = None+ last_error = None+ for split in range(len(parts) - 1, 0, -1):+ try:+ obj = importlib.import_module(".".join(parts[:split]))+ except Exception as exc: # noqa: BLE001 - an unimportable prefix is not the module+ last_error = exc+ continue+ rest = parts[split:]+ break+ else:+ # Nothing imported, and *why* decides what this is: a ModuleNotFoundError+ # naming a prefix of the target means the module is gone, naming anything+ # else means a dependency is absent here. A package whose ``__init__`` pulls+ # in an optional dependency makes every prefix raise.+ environment = not (+ isinstance(last_error, ModuleNotFoundError)+ and last_error.name in {".".join(parts[:i]) for i in range(1, len(parts))}+ )+ entry = {+ "target": dotted,+ "reason": (+ f"no importable module prefix, unimportable here: {last_error!r}"+ if environment+ else "no importable module prefix"+ ),+ "tests": users,+ }+ if environment:+ entry["environment"] = True+ broken.append(entry)+ continue+ for attr in rest:+ # ``core.inference`` resolves attributes through a PEP 562 ``__getattr__``, so+ # a missing optional dependency surfaces as ImportError, not AttributeError.+ try:+ found = hasattr(obj, attr)+ except Exception as exc: # noqa: BLE001+ # AttributeError = not exported, a dead target. Only ImportError is an+ # environment gap.+ environment = not isinstance(exc, AttributeError)+ entry = {+ "target": dotted,+ "reason": (+ f"unresolvable in this environment: {type(exc).__name__}"+ if environment+ else f"lazy export {attr!r} is gone: {exc}"+ ),+ "tests": users,+ }+ if environment:+ entry["environment"] = True+ broken.append(entry)+ break+ if not found:+ # A missing name on a package is ambiguous: gone, or defined in a+ # submodule that is unimportable here. Import it directly to tell apart.+ reason = f"missing attribute {attr!r}"+ environment = False+ if inspect.ismodule(obj) and hasattr(obj, "__path__"):+ candidate = f"{obj.__name__}.{attr}"+ try:+ importlib.import_module(candidate)+ except ModuleNotFoundError as exc:+ # Only a failure to import something *else* is environmental.+ if exc.name and exc.name != candidate:+ reason = f"submodule {attr!r} needs {exc.name!r}, absent here"+ environment = True+ except ImportError as exc:+ reason = f"submodule {attr!r} is unimportable here: {exc}"+ environment = True+ except Exception:+ pass+ else:+ found = True+ if not found:+ entry = {"target": dotted, "reason": reason, "tests": users}+ if environment:+ entry["environment"] = True+ broken.append(entry)+ break+ obj = getattr(obj, attr, None)+ return broken+++# ─────────────────────────── twins ───────────────────────────++# Names defined in both modules. Unifying them is the point of the refactor; this reports+# where they disagree on real input.+TWIN_NAMES = (+ "_balanced_brace_end",+ "_balanced_bracket_end",+ "_inside_open_parameter",+ "_trim_param_value",+ "parse_tool_calls_from_text",+)+++def twin_divergence(corpus) -> dict:+ healing = importlib.import_module("core.tool_healing")+ parser = importlib.import_module("core.inference.tool_call_parser")+ report = {}+ for name in TWIN_NAMES:+ h_func, p_func = getattr(healing, name, None), getattr(parser, name, None)+ if h_func is None or p_func is None:+ report[name] = {"status": "unified" if h_func is p_func else "missing"}+ continue+ if h_func is p_func:+ report[name] = {"status": "unified"}+ continue+ examples = []+ for text in corpus:+ h_out, p_out = _drive(h_func, text), _drive(p_func, text)+ # -1 and None are both "no match"; equate them so only real disagreement shows.+ if (h_out in (-1, None)) and (p_out in (-1, None)):+ continue+ if h_out != p_out:+ examples.append({"input": text, "healing": h_out, "parser": p_out})+ report[name] = {+ "status": "diverges" if examples else "equivalent",+ "count": len(examples),+ "examples": examples[:5],+ }+ return report+++# ─────────────────────────── CLI ───────────────────────────+++def _write(name, payload):+ BASELINE_DIR.mkdir(parents = True, exist_ok = True)+ path = BASELINE_DIR / name+ path.write_text(+ json.dumps(payload, indent = 2, sort_keys = True, ensure_ascii = False) + "\n",+ encoding = "utf-8",+ )+ return path+++def _read(name):+ return json.loads((BASELINE_DIR / name).read_text(encoding = "utf-8"))+++def _diff(+ label,+ old,+ new,+ *,+ additions_matter = True,+):+ """Report the first differing JSON path, which is enough to locate the change.++ ``additions_matter = False`` reports only what changed or disappeared. The question+ these surfaces are asked is "did this refactor drop or alter something", and a later+ unrelated commit adding a symbol or a patch is not a regression; a guard that fails+ on those trains everyone to re-snapshot without reading.+ """+ if old == new:+ return []+ problems = []+ if isinstance(old, dict) and isinstance(new, dict):+ for key in sorted(set(old) | set(new)):+ if key not in old:+ if additions_matter:+ problems.append(f"{label}.{key}: added")+ elif key not in new:+ problems.append(f"{label}.{key}: REMOVED")+ else:+ problems.extend(+ _diff(f"{label}.{key}", old[key], new[key], additions_matter = additions_matter)+ )+ elif isinstance(old, list) and isinstance(new, list) and len(old) == len(new):+ for index, (a, b) in enumerate(zip(old, new)):+ problems.extend(_diff(f"{label}[{index}]", a, b, additions_matter = additions_matter))+ elif (+ isinstance(old, list)+ and isinstance(new, list)+ and all(isinstance(v, str) for v in old + new)+ ):+ # A name or occurrence list: report what joined or left, not both full lists.+ # Counted, not set-compared, so dropping one of several identical entries (a+ # partial repoint) is not read as "unchanged".+ old_counts, new_counts = Counter(old), Counter(new)+ for name in sorted(set(old) | set(new)):+ delta = new_counts[name] - old_counts[name]+ if delta > 0:+ if additions_matter:+ problems.append(f"{label}: added {name!r}")+ elif delta < 0:+ if new_counts[name]:+ problems.append(f"{label}: {old_counts[name]} -> {new_counts[name]} x {name!r}")+ else:+ problems.append(f"{label}: REMOVED {name!r}")+ else:+ problems.append(f"{label}: {old!r} -> {new!r}")+ return problems+++def snapshot():+ corpus = build_corpus()+ _write("ast_inventory.json", ast_inventory())+ _write("runtime_inventory.json", runtime_inventory())+ _write("golden_outputs.json", golden_outputs(corpus))+ _write("patch_targets.json", patch_targets())+ failures = idempotence_failures(corpus)+ _write("idempotence_baseline.json", failures)+ print(f"baseline written to {BASELINE_DIR}")+ print(f" corpus: {len(corpus)} inputs")+ print(f" patch targets: {len(patch_targets())}")+ print(f" pre-existing idempotence failures: {len(failures)}")+ for failure in failures:+ print(f" {failure['module']}.{failure['function']}")+++def _ast_problems() -> list:+ """AST diff, strict for the modules this branch owns and additive-tolerant elsewhere."""+ recorded = _read("ast_inventory.json")+ live = ast_inventory()+ problems = []+ for mod_name in sorted(set(recorded) | set(live)):+ problems += _diff(+ f"ast.{mod_name}",+ recorded.get(mod_name, {}),+ live.get(mod_name, {}),+ additions_matter = mod_name in BEHAVIOUR_MODULES,+ )+ return problems+++def verify() -> int:+ corpus = build_corpus()+ problems = []+ problems += _ast_problems()+ problems += _diff("runtime", _read("runtime_inventory.json"), runtime_inventory())+ problems += _diff("golden", _read("golden_outputs.json"), golden_outputs(corpus))++ # Keyed by variant: a ``final = True`` failure is no licence for a new one on the+ # ``final = False`` streaming path.+ baseline_idempotence = {+ (f["module"], f["function"], f.get("variant", ""))+ for f in _read("idempotence_baseline.json")+ }+ for failure in idempotence_failures(corpus):+ key = (failure["module"], failure["function"], failure["variant"])+ if key not in baseline_idempotence:+ problems.append(+ f"idempotence.{failure['module']}.{failure['function']}"+ f"{'[' + failure['variant'] + ']' if failure['variant'] else ''}: "+ f"f(f(x)) != f(x) for {failure['input']!r}"+ )++ # The recorded set matters too: a patch repointed at another resolvable namespace, or+ # dropped, resolves fine and would otherwise pass.+ recorded = {target: sorted(tests) for target, tests in _read("patch_targets.json").items()}+ live = {target: sorted(tests) for target, tests in patch_targets().items()}+ problems += _diff("patch-targets", recorded, live, additions_matter = False)++ for broken in unresolvable_patch_targets(live):+ # An uninstalled optional backend is not a broken target: ``verify`` has to stay+ # usable in a slim environment.+ if not broken.get("environment"):+ problems.append(+ f"patch-target {broken['target']}: {broken['reason']} ({broken['tests'][0]})"+ )++ if problems:+ print(f"FAIL: {len(problems)} difference(s)")+ for problem in problems[:60]:+ print(f" {problem}")+ if len(problems) > 60:+ print(f" ... and {len(problems) - 60} more")+ return 1+ print("OK: inventory, golden outputs, idempotence and patch targets all match")+ return 0+++def twins():+ report = twin_divergence(build_corpus())+ print(json.dumps(report, indent = 2, ensure_ascii = False))+++def main() -> int:+ command = sys.argv[1] if len(sys.argv) > 1 else "verify"+ if command == "snapshot":+ snapshot()+ return 0+ if command == "verify":+ return verify()+ if command == "twins":+ twins()+ return 0+ print(f"unknown command {command!r}; expected snapshot, verify or twins")+ return 2+++if __name__ == "__main__":+ raise SystemExit(main())