thekevinscott commited on
Commit
c51ffe0
·
verified ·
1 Parent(s): 537ccc7

Upload experiments v1, v2-models-effort, v2-tests-configuration as on disk 2026-11-11 (part 33)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_graph/graph_node.py +40 -0
  2. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_graph/graph_pointer.py +129 -0
  3. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_graph/parse_state.py +49 -0
  4. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_graph/print.py +77 -0
  5. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_graph/rule_ref.py +36 -0
  6. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_graph/type_guards.py +66 -0
  7. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_graph/types.py +88 -0
  8. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_parser/__init__.py +3 -0
  9. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_parser/__pycache__/__init__.cpython-314.pyc +0 -0
  10. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_parser/__pycache__/build_rule_stack.cpython-314.pyc +0 -0
  11. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_parser/build_rule_stack.py +81 -0
  12. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__init__.py +3 -0
  13. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/__init__.cpython-314.pyc +0 -0
  14. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/is_word_char.cpython-314.pyc +0 -0
  15. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/parse_char.cpython-314.pyc +0 -0
  16. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/parse_name.cpython-314.pyc +0 -0
  17. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/parse_space.cpython-314.pyc +0 -0
  18. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/rules_builder.cpython-314.pyc +0 -0
  19. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/symbol_ids.cpython-314.pyc +0 -0
  20. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/type_guards.cpython-314.pyc +0 -0
  21. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/types.cpython-314.pyc +0 -0
  22. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/is_word_char.py +7 -0
  23. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/parse_char.py +27 -0
  24. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/parse_name.py +27 -0
  25. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/parse_space.py +13 -0
  26. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/rules_builder.py +188 -0
  27. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/symbol_ids.py +58 -0
  28. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/type_guards.py +48 -0
  29. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/types.py +58 -0
  30. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/__init__.py +0 -0
  31. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/__pycache__/__init__.cpython-314.pyc +0 -0
  32. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/__pycache__/is_point_in_range.cpython-314.pyc +0 -0
  33. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/__pycache__/js_compat.cpython-314.pyc +0 -0
  34. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/__init__.py +4 -0
  35. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/__pycache__/__init__.cpython-314.pyc +0 -0
  36. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/__pycache__/build_error_position.cpython-314.pyc +0 -0
  37. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/__pycache__/get_input_as_string.cpython-314.pyc +0 -0
  38. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/__pycache__/grammar_parse_error.cpython-314.pyc +0 -0
  39. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/__pycache__/input_parse_error.cpython-314.pyc +0 -0
  40. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/build_error_position.py +24 -0
  41. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/get_input_as_string.py +13 -0
  42. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/grammar_parse_error.py +28 -0
  43. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/input_parse_error.py +42 -0
  44. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/is_point_in_range.py +7 -0
  45. v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/js_compat.py +82 -0
  46. v2-models-effort/runs/20261016T205207Z_9c5d87a1/proxy.log +35 -0
  47. v2-models-effort/runs/20261016T205207Z_9c5d87a1/run.json +10 -0
  48. v2-models-effort/runs/20261016T205207Z_9c5d87a1/stderr.txt +0 -0
  49. v2-models-effort/runs/20261016T205207Z_9c5d87a1/transcript/.claude/projects/-target/3c26ae17-d4ed-412a-9fb7-89b28f946dc2.jsonl +0 -0
  50. v2-models-effort/runs/20261016T210335Z_4d158ae5/manifest.json +99 -0
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_graph/graph_node.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Generic, TypeVar
4
+
5
+ from .colorize import colorize
6
+ from .print import print_graph_node
7
+
8
+ if TYPE_CHECKING:
9
+ from .colorize import Colorize
10
+ from .types import GraphNodeMeta, Pointers, UnresolvedRule
11
+
12
+ R = TypeVar("R", bound="UnresolvedRule")
13
+
14
+
15
+ class GraphNode(Generic[R]):
16
+ """A single step along one path (alternative) of a rule, linked to the step that follows it."""
17
+
18
+ rule: R
19
+ next: GraphNode | None
20
+ meta: GraphNodeMeta
21
+
22
+ def __init__(self, rule: R, meta: GraphNodeMeta, next: GraphNode | None = None):
23
+ self.rule = rule
24
+ if meta is None:
25
+ raise ValueError("Meta is undefined")
26
+ self.meta = meta
27
+ self.next = next
28
+ self._id: str | None = None
29
+
30
+ @property
31
+ def id(self) -> str:
32
+ if not self._id:
33
+ self._id = f"{self.meta['stack_id']},{self.meta['path_id']},{self.meta['step_id']}"
34
+ return self._id
35
+
36
+ def print(self, colorize: Colorize, show_position: bool = False, pointers: Pointers | None = None) -> str:
37
+ return print_graph_node(self)(colorize=colorize, show_position=show_position, pointers=pointers)
38
+
39
+ def __repr__(self) -> str:
40
+ return self.print(colorize=colorize, show_position=False)
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_graph/graph_pointer.py ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Iterator
4
+ from typing import TYPE_CHECKING
5
+
6
+ from ..utils.js_compat import json_stringify
7
+ from .colorize import colorize
8
+ from .print import print_graph_pointer
9
+ from .type_guards import (
10
+ is_graph_pointer_rule_char,
11
+ is_graph_pointer_rule_char_exclude,
12
+ is_graph_pointer_rule_end,
13
+ is_graph_pointer_rule_ref,
14
+ is_rule_end,
15
+ )
16
+
17
+ if TYPE_CHECKING:
18
+ from .colorize import Colorize
19
+ from .graph_node import GraphNode
20
+ from .types import ResolvedGraphPointer, UnresolvedRule
21
+
22
+ # How far a pointer's parent chain may grow while resolving it. Each rule reference entered
23
+ # without consuming input lengthens the chain, so only a grammar that can loop without consuming
24
+ # input (e.g. left recursion) comes anywhere near this; it stands in for the original's stack overflow.
25
+ MAX_RULE_REF_DEPTH = 10_000
26
+
27
+
28
+ class GraphPointer:
29
+ """A position in the graph: a node, plus the chain of rule references followed to reach it."""
30
+
31
+ node: GraphNode
32
+ parent: GraphPointer | None
33
+
34
+ def __init__(self, node: GraphNode, parent: GraphPointer | None = None):
35
+ if node is None:
36
+ raise ValueError("Node is undefined")
37
+ self.node = node
38
+ self.parent = parent
39
+ self._valid: bool | None = None
40
+ self._id: str | None = None
41
+
42
+ @property
43
+ def id(self) -> str:
44
+ """The node's id, prefixed by its parents' ids: pointers sharing an id are interchangeable."""
45
+ if self._id is None:
46
+ # ids embed the whole parent chain, so they are built on demand (most pointers are only
47
+ # passed through while resolving), oldest ancestor first rather than by recursing up the chain.
48
+ uncached: list[GraphPointer] = []
49
+ pointer: GraphPointer | None = self
50
+ while isinstance(pointer, GraphPointer) and pointer._id is None:
51
+ uncached.append(pointer)
52
+ pointer = pointer.parent
53
+ for pointer in reversed(uncached):
54
+ parent = pointer.parent
55
+ pointer._id = f"{parent.id}-{pointer.node.id}" if parent is not None else pointer.node.id
56
+ return self._id
57
+
58
+ def resolve(self, resolved: bool = False) -> Iterator[ResolvedGraphPointer]:
59
+ """
60
+ 1. If the current node is an end node, and the pointer has a parent, resolve the parent (as resolved); else yield the pointer.
61
+ 2. If the current node is a rule ref, resolve the referenced nodes, _unless_ resolved is true, in which case it resolves the next node.
62
+ 3. If the current node is a char or range, yield the pointer.
63
+
64
+ This walks the graph depth-first with an explicit stack rather than by recursion: parent
65
+ chains grow with every repetition matched, so recursing would exhaust Python's stack.
66
+ """
67
+ # pointers still to visit, next to visit last, each with whether it is resolved and
68
+ # how much longer its parent chain is than this pointer's
69
+ pending: list[tuple[GraphPointer, bool, int]] = [(self, resolved, 0)]
70
+ while pending:
71
+ pointer, resolved, depth = pending.pop()
72
+ if is_graph_pointer_rule_ref(pointer):
73
+ if resolved:
74
+ if pointer.node.next is None:
75
+ raise RuntimeError(f"No next node: {json_stringify(pointer.node)}")
76
+ pending.append((GraphPointer(pointer.node.next, pointer.parent), False, depth))
77
+ else:
78
+ if depth >= MAX_RULE_REF_DEPTH:
79
+ raise RecursionError(
80
+ "Maximum rule reference depth exceeded; does the grammar loop without consuming input?"
81
+ )
82
+ nodes = list(pointer.node.rule.nodes)
83
+ pending.extend((GraphPointer(node, pointer), False, depth + 1) for node in reversed(nodes))
84
+ elif is_graph_pointer_rule_end(pointer):
85
+ if pointer.parent is None:
86
+ yield pointer
87
+ else:
88
+ pending.append((pointer.parent, True, depth - 1))
89
+ elif is_graph_pointer_rule_char(pointer) or is_graph_pointer_rule_char_exclude(pointer):
90
+ yield pointer
91
+ else:
92
+ raise ValueError(f"Unknown rule: {json_stringify(pointer.node.rule)}")
93
+
94
+ def fetch_next(self) -> Iterator[ResolvedGraphPointer]:
95
+ # if this pointer is invalid, then we don't return any new pointers
96
+ if self._valid is False:
97
+ return
98
+
99
+ # if this pointer is an end node, we return the parent's next node. If no parent exists,
100
+ # we return nothing, since it's the end of the line.
101
+ if is_rule_end(self.node.rule):
102
+ if self.parent is not None:
103
+ yield from self.parent.fetch_next()
104
+ else:
105
+ if self.node.next is None:
106
+ raise RuntimeError(f"No next node: {json_stringify(self.node)}")
107
+ pointer = GraphPointer(self.node.next, self.parent)
108
+ yield from pointer.resolve()
109
+
110
+ @property
111
+ def rule(self) -> UnresolvedRule:
112
+ return self.node.rule
113
+
114
+ @property
115
+ def valid(self) -> bool | None:
116
+ return self._valid
117
+
118
+ @valid.setter
119
+ def valid(self, valid: bool) -> None:
120
+ self._valid = valid
121
+
122
+ def print(self, colorize: Colorize) -> str:
123
+ return print_graph_pointer(self)(colorize=colorize)
124
+
125
+ def __repr__(self) -> str:
126
+ return self.print(colorize=colorize)
127
+
128
+
129
+ GraphPointerKey = str
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_graph/parse_state.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Iterator
4
+ from typing import TYPE_CHECKING
5
+
6
+ from ..utils.js_compat import json_stringify
7
+
8
+ if TYPE_CHECKING:
9
+ from .graph import Graph
10
+ from .types import Pointers, ResolvedRule, ValidInput
11
+
12
+
13
+ class ParseState:
14
+ """
15
+ An immutable snapshot of a parse: iterate it for the rules that may match next.
16
+
17
+ Calling the state (or its `add` method) with further input returns a new state.
18
+ """
19
+
20
+ def __init__(self, graph: Graph, pointers: Pointers):
21
+ self._graph = graph
22
+ self._pointers = pointers
23
+
24
+ def __call__(self, src: ValidInput) -> ParseState:
25
+ return self.add(src)
26
+
27
+ def __iter__(self) -> Iterator[ResolvedRule]:
28
+ return self.rules()
29
+
30
+ def rules(self) -> Iterator[ResolvedRule]:
31
+ rules: set[str] = set()
32
+ for pointer in self._pointers:
33
+ rule = pointer.rule
34
+ key = json_stringify(rule)
35
+ if key not in rules:
36
+ rules.add(key)
37
+ yield rule
38
+
39
+ def add(self, src: ValidInput) -> ParseState:
40
+ pointers = self._graph.add(src, self._pointers)
41
+ return ParseState(self._graph, pointers)
42
+
43
+ @property
44
+ def size(self) -> int:
45
+ return len(list(self.rules()))
46
+
47
+ @property
48
+ def grammar(self) -> str:
49
+ return self._graph.grammar
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_graph/print.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Callable
4
+ from typing import TYPE_CHECKING
5
+
6
+ from .colorize import Color
7
+ from .get_parent_stack_id import get_parent_stack_id
8
+ from .type_guards import is_range, is_rule_char, is_rule_ref
9
+
10
+ if TYPE_CHECKING:
11
+ from .colorize import Colorize
12
+ from .graph_node import GraphNode
13
+ from .graph_pointer import GraphPointer
14
+ from .types import Pointers
15
+
16
+
17
+ def print_graph_pointer(pointer: GraphPointer) -> Callable[..., str]:
18
+ def print_pointer(colorize: Colorize) -> str:
19
+ return colorize(f"*{get_parent_stack_id(pointer, colorize)}", Color.RED)
20
+
21
+ return print_pointer
22
+
23
+
24
+ def print_graph_node(node: GraphNode) -> Callable[..., str]:
25
+ def print_node(colorize: Colorize, show_position: bool = False, pointers: Pointers | None = None) -> str:
26
+ col = colorize
27
+ rule = node.rule
28
+
29
+ parts: list[str] = []
30
+ if show_position:
31
+ parts.extend([
32
+ col("{", Color.BLUE),
33
+ col(node.id, Color.GRAY),
34
+ col("}", Color.BLUE),
35
+ ])
36
+ if is_rule_char(rule):
37
+ chars = "".join(
38
+ ",".join(col(_char(bound), Color.YELLOW) for bound in value) if is_range(value) else _get_char(value)
39
+ for value in rule["value"]
40
+ )
41
+ parts.extend([
42
+ col("[", Color.GRAY),
43
+ col(chars, Color.YELLOW),
44
+ col("]", Color.GRAY),
45
+ ])
46
+ elif is_rule_ref(rule):
47
+ parts.append(col("Ref(", Color.GRAY) + col(f"{rule.value}", Color.GREEN) + col(")", Color.GRAY))
48
+ else:
49
+ parts.append(col(rule["type"], Color.YELLOW))
50
+
51
+ for pointer in pointers or ():
52
+ if pointer.node is node:
53
+ parts.extend([
54
+ col("[", Color.GRAY),
55
+ pointer.print(colorize=col),
56
+ col("]", Color.GRAY),
57
+ ])
58
+ next_view = (
59
+ node.next.print(pointers=pointers, colorize=col, show_position=show_position)
60
+ if node.next is not None
61
+ else None
62
+ )
63
+ return col("-> ", Color.GRAY).join(view for view in ("".join(parts), next_view) if view)
64
+
65
+ return print_node
66
+
67
+
68
+ def _char(code_point: int) -> str:
69
+ try:
70
+ return chr(code_point)
71
+ except (TypeError, ValueError, OverflowError):
72
+ return "\N{REPLACEMENT CHARACTER}"
73
+
74
+
75
+ def _get_char(code_point: int) -> str:
76
+ char = _char(code_point)
77
+ return "\\n" if char == "\n" else char
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_graph/rule_ref.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Sequence
4
+ from typing import TYPE_CHECKING
5
+
6
+ if TYPE_CHECKING:
7
+ from .graph_node import GraphNode
8
+
9
+
10
+ class RuleRef:
11
+ """A reference to another rule, resolved to that rule's starting nodes once the graph is built."""
12
+
13
+ def __init__(self, value: int):
14
+ self.value = value
15
+ self._nodes: Sequence[GraphNode] | None = None
16
+
17
+ @property
18
+ def nodes(self) -> Sequence[GraphNode]:
19
+ if self._nodes is None:
20
+ raise RuntimeError("Nodes are not set")
21
+ return self._nodes
22
+
23
+ @nodes.setter
24
+ def nodes(self, nodes: Sequence[GraphNode]) -> None:
25
+ self._nodes = nodes
26
+
27
+ def __eq__(self, other: object) -> bool:
28
+ if isinstance(other, RuleRef):
29
+ return self.value == other.value
30
+ return NotImplemented
31
+
32
+ def __hash__(self) -> int:
33
+ return hash((RuleRef, self.value))
34
+
35
+ def __repr__(self) -> str:
36
+ return f"RuleRef({self.value!r})"
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_graph/type_guards.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import TYPE_CHECKING, Any
5
+
6
+ from .rule_ref import RuleRef
7
+ from .types import RuleType
8
+
9
+ if TYPE_CHECKING:
10
+ from .graph_pointer import GraphPointer
11
+
12
+ _RULE_TYPES = frozenset(RuleType)
13
+
14
+
15
+ def _has_type(rule: Any, rule_type: RuleType) -> bool:
16
+ return isinstance(rule, Mapping) and rule.get("type") == rule_type
17
+
18
+
19
+ # Type Guards
20
+ def is_rule_type(type: Any = None) -> bool:
21
+ return isinstance(type, str) and type in _RULE_TYPES
22
+
23
+
24
+ def is_rule(rule: Any = None) -> bool:
25
+ return isinstance(rule, Mapping) and "type" in rule and is_rule_type(rule["type"])
26
+
27
+
28
+ def is_rule_ref(rule: Any = None) -> bool:
29
+ return isinstance(rule, RuleRef)
30
+
31
+
32
+ def is_rule_end(rule: Any = None) -> bool:
33
+ return _has_type(rule, RuleType.END)
34
+
35
+
36
+ def is_rule_char(rule: Any = None) -> bool:
37
+ return _has_type(rule, RuleType.CHAR)
38
+
39
+
40
+ def is_rule_char_excluded(rule: Any = None) -> bool:
41
+ return _has_type(rule, RuleType.CHAR_EXCLUDE)
42
+
43
+
44
+ def is_range(range: Any = None) -> bool:
45
+ """Whether `range` is a `[start, end]` pair of numbers."""
46
+ return (
47
+ isinstance(range, (list, tuple))
48
+ and len(range) == 2
49
+ and all(isinstance(n, (int, float)) and not isinstance(n, bool) for n in range)
50
+ )
51
+
52
+
53
+ def is_graph_pointer_rule_ref(pointer: GraphPointer) -> bool:
54
+ return is_rule_ref(pointer.rule)
55
+
56
+
57
+ def is_graph_pointer_rule_end(pointer: GraphPointer) -> bool:
58
+ return is_rule_end(pointer.rule)
59
+
60
+
61
+ def is_graph_pointer_rule_char(pointer: GraphPointer) -> bool:
62
+ return is_rule_char(pointer.rule)
63
+
64
+
65
+ def is_graph_pointer_rule_char_exclude(pointer: GraphPointer) -> bool:
66
+ return is_rule_char_excluded(pointer.rule)
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_graph/types.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from enum import StrEnum
4
+ from typing import TYPE_CHECKING, Any, TypeAlias, TypedDict, Union
5
+
6
+ from ..utils.js_compat import Pair
7
+
8
+ if TYPE_CHECKING:
9
+ from .generic_set import GenericSet
10
+ from .graph_pointer import GraphPointer
11
+ from .rule_ref import RuleRef
12
+
13
+
14
+ class RuleType(StrEnum):
15
+ CHAR = "char"
16
+ CHAR_EXCLUDE = "char_exclude"
17
+ END = "end"
18
+
19
+
20
+ class Range(Pair):
21
+ """An inclusive `[start, end]` range of code points."""
22
+
23
+ __slots__ = ()
24
+
25
+ def __new__(cls, start: int, end: int) -> Range:
26
+ return super().__new__(cls, start, end)
27
+
28
+
29
+ class Rule(dict):
30
+ """
31
+ A rule the parser can match next.
32
+
33
+ Rules are plain `{"type": ..., "value": ...}` dicts (so they compare equal to dict
34
+ literals), whose keys can also be read as attributes (`rule.type`, `rule.value`).
35
+ """
36
+
37
+ __slots__ = ()
38
+
39
+ def __getattr__(self, name: str) -> Any:
40
+ try:
41
+ return self[name]
42
+ except KeyError:
43
+ raise AttributeError(name) from None
44
+
45
+
46
+ class RuleChar(Rule):
47
+ """Matches a code point equal to one of `value`'s numbers, or within one of its ranges."""
48
+
49
+ __slots__ = ()
50
+
51
+ def __init__(self, value: list[int | Range], type: RuleType = RuleType.CHAR):
52
+ super().__init__(type=type, value=value)
53
+
54
+
55
+ class RuleCharExclude(Rule):
56
+ """Matches a code point equal to none of `value`'s numbers, and within none of its ranges."""
57
+
58
+ __slots__ = ()
59
+
60
+ def __init__(self, value: list[int | Range], type: RuleType = RuleType.CHAR_EXCLUDE):
61
+ super().__init__(type=type, value=value)
62
+
63
+
64
+ class RuleEnd(Rule):
65
+ """Denotes a valid end of the input."""
66
+
67
+ __slots__ = ()
68
+
69
+ def __init__(self, type: RuleType = RuleType.END):
70
+ super().__init__(type=type)
71
+
72
+
73
+ class GraphNodeMeta(TypedDict):
74
+ stack_id: int
75
+ path_id: int
76
+ step_id: int
77
+
78
+
79
+ UnresolvedRule: TypeAlias = Union[RuleChar, RuleCharExclude, "RuleRef", RuleEnd]
80
+ # RuleRefs should never be exposed to the end user.
81
+ ResolvedRule: TypeAlias = Union[RuleCharExclude, RuleChar, RuleEnd]
82
+ ResolvedGraphPointer: TypeAlias = "GraphPointer"
83
+ Pointers: TypeAlias = "GenericSet[GraphPointer, str]"
84
+
85
+ # ValidInput can either be a string, or a number indicating a code point.
86
+ # It CANNOT be a number representing a number; a number being a "number" (like "8")
87
+ # should be passed in as a string.
88
+ ValidInput: TypeAlias = Union[str, int, list[int]]
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_parser/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from .build_rule_stack import build_rule_stack
2
+
3
+ __all__ = ["build_rule_stack"]
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_parser/__pycache__/__init__.cpython-314.pyc ADDED
Binary file (208 Bytes). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_parser/__pycache__/build_rule_stack.cpython-314.pyc ADDED
Binary file (4.26 kB). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/grammar_parser/build_rule_stack.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from ..grammar_graph.rule_ref import RuleRef
6
+ from ..grammar_graph.type_guards import is_range, is_rule_end
7
+ from ..grammar_graph.types import Range, RuleChar, RuleCharExclude, RuleEnd
8
+ from ..rules_builder.type_guards import (
9
+ is_rule_def_alt,
10
+ is_rule_def_char,
11
+ is_rule_def_char_alt,
12
+ is_rule_def_char_not,
13
+ is_rule_def_char_rng_upper,
14
+ is_rule_def_end,
15
+ is_rule_def_ref,
16
+ )
17
+ from ..utils.js_compat import json_stringify
18
+
19
+ if TYPE_CHECKING:
20
+ from ..grammar_graph.types import UnresolvedRule
21
+ from ..rules_builder.types import InternalRuleDef, InternalRuleDefChar, InternalRuleDefCharNot
22
+
23
+
24
+ def _make_char_rule(rule_def: InternalRuleDefChar | InternalRuleDefCharNot) -> RuleChar | RuleCharExclude:
25
+ char_rule = RuleCharExclude if is_rule_def_char_not(rule_def) else RuleChar
26
+ return char_rule(list(rule_def["value"]))
27
+
28
+
29
+ def build_rule_stack(linear_rules: list[InternalRuleDef]) -> list[list[UnresolvedRule]]:
30
+ """Split a rule's flat definition into its alternate paths, each ending with an end rule."""
31
+ paths: list[UnresolvedRule] = []
32
+
33
+ stack: list[list[UnresolvedRule]] = []
34
+
35
+ idx = 0
36
+ while idx < len(linear_rules):
37
+ rule_def = linear_rules[idx]
38
+ if is_rule_def_char(rule_def) or is_rule_def_char_not(rule_def):
39
+ # this could be a single char, or a range, or a sequence of alts; we don't know until we step through it.
40
+ char_rule = _make_char_rule(rule_def)
41
+ idx += 1
42
+ while idx < len(linear_rules) and (
43
+ is_rule_def_char_rng_upper(rule := linear_rules[idx]) or is_rule_def_char_alt(rule)
44
+ ):
45
+ if is_rule_def_char_rng_upper(rule):
46
+ # previous rule value should be a number
47
+ prev_value = char_rule["value"].pop() if char_rule["value"] else None
48
+ if is_range(prev_value):
49
+ raise ValueError(
50
+ f"Unexpected range, expected a number but got an array: {json_stringify(prev_value)}"
51
+ )
52
+ if prev_value is None:
53
+ raise ValueError("Unexpected undefined value")
54
+ char_rule["value"].append(Range(prev_value, rule["value"]))
55
+ if is_rule_def_char_alt(rule):
56
+ char_rule["value"].append(rule["value"])
57
+ idx += 1
58
+ paths.append(char_rule)
59
+ else:
60
+ if is_rule_def_alt(rule_def):
61
+ if not paths:
62
+ raise ValueError("Encountered alt without anything before it")
63
+ paths.append(RuleEnd())
64
+ stack.append(paths)
65
+ paths = []
66
+ elif is_rule_def_end(rule_def):
67
+ paths.append(RuleEnd())
68
+ elif is_rule_def_ref(rule_def):
69
+ paths.append(RuleRef(rule_def["value"]))
70
+ elif is_rule_def_char_alt(rule_def):
71
+ raise ValueError(f"Encountered char alt, should be handled by above block: {rule_def['type']}")
72
+ else:
73
+ raise ValueError(f"Unsupported rule type: {rule_def['type']}")
74
+ idx += 1
75
+
76
+ if not is_rule_end(paths[-1] if paths else None):
77
+ paths.append(RuleEnd())
78
+
79
+ stack.append(paths)
80
+
81
+ return stack
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from .rules_builder import RulesBuilder
2
+
3
+ __all__ = ["RulesBuilder"]
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/__init__.cpython-314.pyc ADDED
Binary file (218 Bytes). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/is_word_char.cpython-314.pyc ADDED
Binary file (613 Bytes). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/parse_char.cpython-314.pyc ADDED
Binary file (1.73 kB). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/parse_name.cpython-314.pyc ADDED
Binary file (1.74 kB). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/parse_space.cpython-314.pyc ADDED
Binary file (870 Bytes). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/rules_builder.cpython-314.pyc ADDED
Binary file (13.5 kB). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/symbol_ids.cpython-314.pyc ADDED
Binary file (4.97 kB). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/type_guards.cpython-314.pyc ADDED
Binary file (3.98 kB). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/__pycache__/types.cpython-314.pyc ADDED
Binary file (2.68 kB). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/is_word_char.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import re
2
+
3
+ _WORD_CHAR = re.compile(r"[a-zA-Z]")
4
+
5
+
6
+ def is_word_char(c: str) -> bool:
7
+ return _WORD_CHAR.search(c) is not None
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/parse_char.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from ..utils.errors.grammar_parse_error import GrammarParseError
4
+ from ..utils.js_compat import Pair, char_at, parse_hex
5
+
6
+ # The number of characters (including the backslash) taken by each hexadecimal escape.
7
+ _HEX_ESCAPE_LENGTHS = {"x": 4, "u": 6, "U": 10}
8
+ _CONTROL_ESCAPES = {"t": "\t", "r": "\r", "n": "\n"}
9
+
10
+
11
+ def parse_char(src: str, pos: int) -> Pair:
12
+ """Parse the (possibly escaped) character at `pos`, returning `(code point, characters consumed)`."""
13
+ if char_at(src, pos) == "\\":
14
+ escaped = char_at(src, pos + 1)
15
+ if escaped in _HEX_ESCAPE_LENGTHS:
16
+ length = _HEX_ESCAPE_LENGTHS[escaped]
17
+ return Pair(parse_hex(src[pos + 2:pos + length]), length)
18
+ if escaped in _CONTROL_ESCAPES:
19
+ return Pair(ord(_CONTROL_ESCAPES[escaped]), 2)
20
+ if escaped in ('"', "[", "]", "\\"):
21
+ return Pair(ord(escaped), 2)
22
+ raise GrammarParseError(src, pos, f"Unknown escape at {src[pos]}")
23
+
24
+ char = char_at(src, pos)
25
+ if not char:
26
+ raise GrammarParseError(src, pos, "Unexpected end of grammar input, failed to complete parse")
27
+ return Pair(ord(char), 1)
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/parse_name.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import re
4
+
5
+ from ..utils.errors.grammar_parse_error import GrammarParseError
6
+
7
+ PARSE_NAME_ERROR = "Failed to find a valid name"
8
+
9
+
10
+ def GET_INVALID_CHAR_ERROR(char: str) -> str: # noqa: N802 - mirrors the original's exported name
11
+ return f'Invalid character "{char}" when parsing name, only lowercase letters and hyphens are allowed.'
12
+
13
+
14
+ _VALID_CHAR = re.compile(r"[a-zA-Z-]")
15
+ _INVALID_NEXT_CHAR = re.compile(r"[_0-9]")
16
+
17
+
18
+ def parse_name(grammar: str, pos: int) -> str:
19
+ name = ""
20
+ while pos < len(grammar) and _VALID_CHAR.search(grammar[pos]):
21
+ name += grammar[pos]
22
+ pos += 1
23
+ if not name:
24
+ raise GrammarParseError(grammar, pos, PARSE_NAME_ERROR)
25
+ if pos < len(grammar) and _INVALID_NEXT_CHAR.search(grammar[pos]):
26
+ raise GrammarParseError(grammar, pos, GET_INVALID_CHAR_ERROR(grammar[pos]))
27
+ return name
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/parse_space.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from ..utils.js_compat import char_at
4
+
5
+
6
+ def parse_space(src: str, pos: int, newline_ok: bool) -> int:
7
+ while (char := char_at(src, pos)) in (" ", "\t", "#") or (newline_ok and char in ("\r", "\n")):
8
+ if char == "#":
9
+ while char_at(src, pos) not in ("", "\r", "\n"):
10
+ pos += 1
11
+ else:
12
+ pos += 1
13
+ return pos
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/rules_builder.py ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import time
4
+
5
+ from ..utils.errors.grammar_parse_error import GrammarParseError
6
+ from ..utils.js_compat import char_at, is_whitespace
7
+ from .is_word_char import is_word_char
8
+ from .parse_char import parse_char
9
+ from .parse_name import parse_name
10
+ from .parse_space import parse_space
11
+ from .symbol_ids import SymbolIds
12
+ from .types import InternalRuleDef, InternalRuleType
13
+
14
+
15
+ def _now() -> float:
16
+ """The current time in milliseconds."""
17
+ return time.perf_counter() * 1000
18
+
19
+
20
+ class RulesBuilder:
21
+ """Parses a GBNF grammar into a flat list of rule definitions per symbol id."""
22
+
23
+ symbol_ids: SymbolIds
24
+ rules: list[list[InternalRuleDef]]
25
+ src: str
26
+ start: float
27
+
28
+ def __init__(self, src: str, limit: float = 1000):
29
+ self._pos = 0
30
+ self.symbol_ids = SymbolIds()
31
+ self.start = _now()
32
+ self._time_limit = limit
33
+ self.rules = []
34
+ self.src = src
35
+ self._parse(src)
36
+
37
+ def _parse(self, src: str) -> None:
38
+ self._pos = parse_space(src, 0, True) # move cursor forward until we reach non-whitespace content
39
+
40
+ while self._pos < len(src):
41
+ self._parse_rule(src)
42
+
43
+ # Validate the state to ensure that all rules are defined
44
+ for rule in self.rules:
45
+ for elem in rule:
46
+ if elem["type"] == InternalRuleType.RULE_REF:
47
+ # Ensure that the rule at that location exists
48
+ rule_exists = elem["value"] < len(self.rules) and len(self.rules[elem["value"]]) > 0
49
+ if not rule_exists:
50
+ missing_rule_name = self.symbol_ids.reverse_get(elem["value"])
51
+ missing_rule_pos = self.symbol_ids.get_pos(missing_rule_name)
52
+
53
+ # Skip over the ::= and any whitespace
54
+ while missing_rule_pos < len(src) and (
55
+ src[missing_rule_pos] in (":", "=") or is_whitespace(src[missing_rule_pos])
56
+ ):
57
+ missing_rule_pos += 1
58
+
59
+ raise GrammarParseError(src, missing_rule_pos, f'Undefined rule identifier "{missing_rule_name}"')
60
+
61
+ def _parse_rule(self, src: str) -> None:
62
+ name = parse_name(src, self._pos)
63
+ self._pos = parse_space(src, self._pos + len(name), False)
64
+ rule_id = self.get_symbol_id(name, len(name))
65
+
66
+ # Skip over whitespace characters and find the ::= sequence
67
+ self._pos = parse_space(src, self._pos, True)
68
+ if src[self._pos:self._pos + 3] != "::=":
69
+ raise GrammarParseError(src, self._pos, f"Expecting ::= at {self._pos}")
70
+ self._pos = parse_space(src, self._pos + 3, True)
71
+
72
+ self.parse_alternates(name, rule_id)
73
+
74
+ char = char_at(src, self._pos)
75
+ if char == "\r":
76
+ self._pos += 2 if char_at(src, self._pos + 1) == "\n" else 1
77
+ elif char == "\n":
78
+ self._pos += 1
79
+ elif char:
80
+ raise GrammarParseError(src, self._pos, f"Expecting newline or end at {self._pos}")
81
+ self._pos = parse_space(src, self._pos, True)
82
+
83
+ def get_symbol_id(self, src: str, length: int) -> int:
84
+ next_id = self.symbol_ids.size
85
+ key = src[:length]
86
+ if not self.symbol_ids.has(key):
87
+ self.symbol_ids.set(key, next_id, self._pos)
88
+ return self.symbol_ids.get(key)
89
+
90
+ def generate_symbol_id(self, base_name: str) -> int:
91
+ next_id = self.symbol_ids.size
92
+ self.symbol_ids.set(f"{base_name}_{next_id}", next_id, self._pos)
93
+ return next_id
94
+
95
+ def add_rule(self, rule_id: int, rule: list[InternalRuleDef]) -> None:
96
+ # ids may be assigned (by references) before the rules defining them are parsed;
97
+ # empty placeholders stand in for those until then.
98
+ while len(self.rules) <= rule_id:
99
+ self.rules.append([])
100
+ self.rules[rule_id] = rule
101
+
102
+ def check_duration(self) -> None:
103
+ if _now() - self.start > self._time_limit:
104
+ raise GrammarParseError(self.src, self._pos, f"duration of {self._time_limit} exceeded:")
105
+
106
+ def parse_sequence(self, rule_name: str, out_elements: list[InternalRuleDef], depth: int = 0) -> None:
107
+ is_nested = depth != 0
108
+ src = self.src
109
+ last_sym_start = len(out_elements)
110
+ while char := char_at(src, self._pos):
111
+ if char == '"':
112
+ self._pos += 1
113
+ last_sym_start = len(out_elements)
114
+ while char_at(src, self._pos) != '"':
115
+ self.check_duration()
116
+ value, inc_pos = parse_char(src, self._pos)
117
+ out_elements.append({"type": InternalRuleType.CHAR, "value": [value]})
118
+ self._pos += inc_pos # Adjusting pos by the length of parsed characters
119
+ self._pos = parse_space(src, self._pos + 1, is_nested)
120
+ elif char == "[":
121
+ self._pos += 1
122
+ start_type = InternalRuleType.CHAR
123
+ if char_at(src, self._pos) == "^":
124
+ self._pos += 1
125
+ start_type = InternalRuleType.CHAR_NOT
126
+ last_sym_start = len(out_elements)
127
+ while char_at(src, self._pos) != "]":
128
+ self.check_duration()
129
+ rule_type = InternalRuleType.CHAR_ALT if last_sym_start < len(out_elements) else start_type
130
+ start_char_value, inc_pos = parse_char(src, self._pos)
131
+ self._pos += inc_pos
132
+ if rule_type in (InternalRuleType.CHAR, InternalRuleType.CHAR_NOT):
133
+ out_elements.append({"type": rule_type, "value": [start_char_value]})
134
+ else:
135
+ out_elements.append({"type": rule_type, "value": start_char_value})
136
+
137
+ if char_at(src, self._pos) == "-" and char_at(src, self._pos + 1) != "]":
138
+ self._pos += 1
139
+ end_char_value, inc_pos = parse_char(src, self._pos)
140
+ out_elements.append({"type": InternalRuleType.CHAR_RNG_UPPER, "value": end_char_value})
141
+ self._pos += inc_pos
142
+ self._pos = parse_space(src, self._pos + 1, is_nested)
143
+ elif is_word_char(char):
144
+ name = parse_name(src, self._pos)
145
+ ref_rule_id = self.get_symbol_id(name, len(name))
146
+ self._pos += len(name)
147
+ self._pos = parse_space(src, self._pos, is_nested)
148
+
149
+ last_sym_start = len(out_elements)
150
+ out_elements.append({"type": InternalRuleType.RULE_REF, "value": ref_rule_id})
151
+ elif char == "(":
152
+ self._pos = parse_space(src, self._pos + 1, True)
153
+ sub_rule_id = self.generate_symbol_id(rule_name)
154
+ self.parse_alternates(rule_name, sub_rule_id, depth + 1)
155
+ last_sym_start = len(out_elements)
156
+ out_elements.append({"type": InternalRuleType.RULE_REF, "value": sub_rule_id})
157
+ if char_at(src, self._pos) != ")":
158
+ raise GrammarParseError(src, self._pos, f"Expecting ')' at {self._pos}")
159
+ self._pos = parse_space(src, self._pos + 1, is_nested)
160
+ elif char in ("*", "+", "?"):
161
+ if last_sym_start == len(out_elements):
162
+ raise GrammarParseError(src, self._pos, f"Expecting preceding item to */+/? at {self._pos}")
163
+ sub_rule_id = self.generate_symbol_id(rule_name)
164
+ sub_rule = out_elements[last_sym_start:]
165
+ if char in ("*", "+"):
166
+ sub_rule.append({"type": InternalRuleType.RULE_REF, "value": sub_rule_id})
167
+ sub_rule.append({"type": InternalRuleType.ALT})
168
+ if char == "+":
169
+ sub_rule.extend(out_elements[last_sym_start:])
170
+ sub_rule.append({"type": InternalRuleType.END})
171
+ self.add_rule(sub_rule_id, sub_rule)
172
+ del out_elements[last_sym_start:]
173
+ out_elements.append({"type": InternalRuleType.RULE_REF, "value": sub_rule_id})
174
+ self._pos = parse_space(src, self._pos + 1, is_nested)
175
+ else:
176
+ break
177
+
178
+ def parse_alternates(self, rule_name: str, rule_id: int, depth: int = 0) -> None:
179
+ src = self.src
180
+ rule: list[InternalRuleDef] = []
181
+ self.parse_sequence(rule_name, rule, depth)
182
+ while char_at(src, self._pos) == "|":
183
+ self.check_duration()
184
+ rule.append({"type": InternalRuleType.ALT})
185
+ self._pos = parse_space(src, self._pos + 1, True)
186
+ self.parse_sequence(rule_name, rule, depth)
187
+ rule.append({"type": InternalRuleType.END})
188
+ self.add_rule(rule_id, rule)
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/symbol_ids.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import ItemsView, Iterator, KeysView
4
+
5
+ from ..utils.js_compat import Pair
6
+
7
+
8
+ class SymbolIds:
9
+ """Bidirectional mapping between symbol names and ids, remembering where each name was first seen."""
10
+
11
+ # we don't need to delete, just preserve relationships
12
+ def __init__(self) -> None:
13
+ self._map: dict[str, int] = {}
14
+ self._pos: dict[str, int] = {}
15
+ self._reverse_map: dict[int, str] = {}
16
+
17
+ @property
18
+ def size(self) -> int:
19
+ return len(self._map)
20
+
21
+ def __len__(self) -> int:
22
+ return len(self._map)
23
+
24
+ def keys(self) -> KeysView[str]:
25
+ return self._map.keys()
26
+
27
+ def items(self) -> ItemsView[str, int]:
28
+ return self._map.items()
29
+
30
+ def has(self, key: str) -> bool:
31
+ return key in self._map
32
+
33
+ __contains__ = has
34
+
35
+ def get(self, key: str) -> int:
36
+ if key not in self._map:
37
+ raise KeyError(f"SymbolIds does not contain key: {key}")
38
+ return self._map[key]
39
+
40
+ def reverse_get(self, key: int) -> str:
41
+ if key not in self._reverse_map:
42
+ raise KeyError(f"SymbolIds does not contain value: {key}")
43
+ return self._reverse_map[key]
44
+
45
+ def get_pos(self, key: str) -> int:
46
+ if key not in self._pos:
47
+ raise KeyError(f"SymbolIds does not contain key: {key}")
48
+ return self._pos[key]
49
+
50
+ def set(self, key: str, value: int, pos: int) -> None:
51
+ self._map[key] = value
52
+ self._pos[key] = pos
53
+ self._reverse_map[value] = key
54
+
55
+ def __iter__(self) -> Iterator[Pair]:
56
+ """Yield `(name, id)` entries in insertion order."""
57
+ for key, value in self._map.items():
58
+ yield Pair(key, value)
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/type_guards.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import Any
5
+
6
+ from .types import InternalRuleType
7
+
8
+ _RULE_DEF_TYPES = frozenset(InternalRuleType)
9
+
10
+
11
+ def _has_type(rule: Any, rule_type: InternalRuleType) -> bool:
12
+ return isinstance(rule, Mapping) and rule.get("type") == rule_type
13
+
14
+
15
+ def is_rule_def_type(type: Any = None) -> bool:
16
+ return isinstance(type, str) and type in _RULE_DEF_TYPES
17
+
18
+
19
+ def is_rule_def(rule: Any = None) -> bool:
20
+ return isinstance(rule, Mapping) and "type" in rule and is_rule_def_type(rule["type"])
21
+
22
+
23
+ def is_rule_def_alt(rule: Any = None) -> bool:
24
+ return _has_type(rule, InternalRuleType.ALT)
25
+
26
+
27
+ def is_rule_def_ref(rule: Any = None) -> bool:
28
+ return _has_type(rule, InternalRuleType.RULE_REF)
29
+
30
+
31
+ def is_rule_def_end(rule: Any = None) -> bool:
32
+ return _has_type(rule, InternalRuleType.END)
33
+
34
+
35
+ def is_rule_def_char(rule: Any = None) -> bool:
36
+ return _has_type(rule, InternalRuleType.CHAR)
37
+
38
+
39
+ def is_rule_def_char_not(rule: Any = None) -> bool:
40
+ return _has_type(rule, InternalRuleType.CHAR_NOT)
41
+
42
+
43
+ def is_rule_def_char_alt(rule: Any = None) -> bool:
44
+ return _has_type(rule, InternalRuleType.CHAR_ALT)
45
+
46
+
47
+ def is_rule_def_char_rng_upper(rule: Any = None) -> bool:
48
+ return _has_type(rule, InternalRuleType.CHAR_RNG_UPPER)
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/rules_builder/types.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from enum import StrEnum
4
+ from typing import Literal, TypedDict, Union
5
+
6
+
7
+ class InternalRuleType(StrEnum):
8
+ CHAR = "CHAR"
9
+ CHAR_RNG_UPPER = "CHAR_RNG_UPPER"
10
+ # CHAR_RNG = "CHAR_RNG"
11
+ RULE_REF = "RULE_REF"
12
+ ALT = "ALT"
13
+ END = "END"
14
+
15
+ CHAR_NOT = "CHAR_NOT"
16
+ CHAR_ALT = "CHAR_ALT"
17
+
18
+
19
+ class InternalRuleDefWithNumericValue(TypedDict):
20
+ type: Literal[InternalRuleType.RULE_REF, InternalRuleType.CHAR_ALT, InternalRuleType.CHAR_RNG_UPPER]
21
+ value: int
22
+
23
+
24
+ class InternalRuleDefChar(TypedDict):
25
+ type: Literal[InternalRuleType.CHAR]
26
+ value: list[int]
27
+
28
+
29
+ class InternalRuleDefCharNot(TypedDict):
30
+ type: Literal[InternalRuleType.CHAR_NOT]
31
+ value: list[int]
32
+
33
+
34
+ class InternalRuleDefCharAlt(TypedDict):
35
+ type: Literal[InternalRuleType.CHAR_ALT]
36
+ value: int
37
+
38
+
39
+ class InternalRuleDefReference(TypedDict):
40
+ type: Literal[InternalRuleType.RULE_REF]
41
+ value: int
42
+
43
+
44
+ class InternalRuleDefEnd(TypedDict):
45
+ type: Literal[InternalRuleType.END]
46
+
47
+
48
+ class InternalRuleDefWithoutValue(TypedDict):
49
+ type: Literal[InternalRuleType.ALT, InternalRuleType.END]
50
+
51
+
52
+ InternalRuleDef = Union[
53
+ InternalRuleDefChar,
54
+ InternalRuleDefCharNot,
55
+ InternalRuleDefWithNumericValue,
56
+ InternalRuleDefWithoutValue,
57
+ ]
58
+ InternalRuleDefCharOrAltChar = Union[InternalRuleDefChar, InternalRuleDefCharAlt]
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/__init__.py ADDED
File without changes
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/__pycache__/__init__.cpython-314.pyc ADDED
Binary file (129 Bytes). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/__pycache__/is_point_in_range.cpython-314.pyc ADDED
Binary file (681 Bytes). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/__pycache__/js_compat.cpython-314.pyc ADDED
Binary file (5.9 kB). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ from .grammar_parse_error import GrammarParseError
2
+ from .input_parse_error import InputParseError
3
+
4
+ __all__ = ["GrammarParseError", "InputParseError"]
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/__pycache__/__init__.cpython-314.pyc ADDED
Binary file (296 Bytes). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/__pycache__/build_error_position.cpython-314.pyc ADDED
Binary file (1.36 kB). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/__pycache__/get_input_as_string.cpython-314.pyc ADDED
Binary file (1.1 kB). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/__pycache__/grammar_parse_error.cpython-314.pyc ADDED
Binary file (1.97 kB). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/__pycache__/input_parse_error.cpython-314.pyc ADDED
Binary file (2.95 kB). View file
 
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/build_error_position.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ MAXIMUM_NUMBER_OF_ERROR_LINES_TO_SHOW = 3
4
+
5
+
6
+ def build_error_position(src: str, pos: int) -> list[str]:
7
+ if src == "":
8
+ return ["No input provided"]
9
+
10
+ lines = src.split("\n")
11
+
12
+ line_idx = 0
13
+ while line_idx < len(lines) and lines[line_idx] and pos > len(lines[line_idx]) - 1:
14
+ pos -= len(lines[line_idx])
15
+ line_idx += 1
16
+
17
+ lines_to_show = [
18
+ lines[i] if i < len(lines) else ""
19
+ for i in range(max(0, line_idx - (MAXIMUM_NUMBER_OF_ERROR_LINES_TO_SHOW - 1)), line_idx + 1)
20
+ ]
21
+ return [
22
+ *lines_to_show,
23
+ " " * pos + "^",
24
+ ]
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/get_input_as_string.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ if TYPE_CHECKING:
6
+ from ...grammar_graph.types import ValidInput
7
+
8
+
9
+ def get_input_as_string(src: ValidInput) -> str:
10
+ if isinstance(src, str):
11
+ return src
12
+ code_points = src if isinstance(src, (list, tuple)) else [src]
13
+ return "".join(chr(code_point) for code_point in code_points)
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/grammar_parse_error.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from .build_error_position import build_error_position
4
+
5
+
6
+ def GRAMMAR_PARSER_ERROR_HEADER_MESSAGE(reason: str) -> str: # noqa: N802 - mirrors the original's exported name
7
+ return f"Failed to parse grammar: {reason}"
8
+
9
+
10
+ class GrammarParseError(Exception):
11
+ grammar: str
12
+ pos: int
13
+ reason: str
14
+ message: str
15
+
16
+ def __init__(self, grammar: str, pos: int, reason: str):
17
+ super().__init__(grammar, pos, reason)
18
+ self.grammar = grammar
19
+ self.pos = pos
20
+ self.reason = reason
21
+ self.message = "\n".join([
22
+ GRAMMAR_PARSER_ERROR_HEADER_MESSAGE(reason),
23
+ "",
24
+ *build_error_position(grammar, pos),
25
+ ])
26
+
27
+ def __str__(self) -> str:
28
+ return self.message
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/errors/input_parse_error.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from .build_error_position import build_error_position
6
+ from .get_input_as_string import get_input_as_string
7
+
8
+ if TYPE_CHECKING:
9
+ from ...grammar_graph.types import ValidInput
10
+
11
+ INPUT_PARSER_ERROR_HEADER_MESSAGE = "Failed to parse input string:"
12
+
13
+
14
+ class InputParseError(Exception):
15
+ message: str
16
+
17
+ def __init__(self, most_recent_input: ValidInput, pos: int, previous_input: ValidInput = ""):
18
+ super().__init__(most_recent_input, pos, previous_input)
19
+ self._most_recent_input = most_recent_input
20
+ self._pos = pos
21
+ self._previous_input = previous_input
22
+ previous = get_input_as_string(previous_input)
23
+ self.message = "\n".join([
24
+ INPUT_PARSER_ERROR_HEADER_MESSAGE,
25
+ "",
26
+ *build_error_position(f"{previous}{get_input_as_string(most_recent_input)}", pos + len(previous)),
27
+ ])
28
+
29
+ def __str__(self) -> str:
30
+ return self.message
31
+
32
+ @property
33
+ def src(self) -> str:
34
+ return f"{get_input_as_string(self._previous_input)}{get_input_as_string(self._most_recent_input)}"
35
+
36
+ @property
37
+ def error_for_most_recent_input(self) -> str:
38
+ return "\n".join([
39
+ INPUT_PARSER_ERROR_HEADER_MESSAGE,
40
+ "",
41
+ *build_error_position(get_input_as_string(self._most_recent_input), self._pos),
42
+ ])
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/is_point_in_range.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Sequence
4
+
5
+
6
+ def is_point_in_range(point: float, bounds: Sequence[float]) -> bool:
7
+ return bounds[0] <= point <= bounds[1]
v2-models-effort/runs/20261016T205207Z_9c5d87a1/ported_implementation/gbnf/utils/js_compat.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Helpers reproducing the JavaScript semantics the reference implementation relies on."""
2
+ from __future__ import annotations
3
+
4
+ import json
5
+ import math
6
+ import re
7
+ from typing import Any
8
+
9
+ # The characters matched by JavaScript's `\s` regex class.
10
+ _WHITESPACE = "\t\n\v\f\r \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff"
11
+ _WHITESPACE_CHAR = re.compile(f"[{_WHITESPACE}]")
12
+ _LEADING_WHITESPACE = re.compile(f"^[{_WHITESPACE}]+")
13
+ _HEX_DIGITS = re.compile(r"[0-9a-fA-F]*")
14
+
15
+
16
+ class Pair(tuple):
17
+ """
18
+ A tuple that also compares equal to a list holding the same items.
19
+
20
+ The JavaScript original represents fixed-size pairs (ranges, `[codePoint, length]`
21
+ results, `[name, id]` entries) as arrays, so callers may reasonably compare them
22
+ against either tuples or lists.
23
+ """
24
+
25
+ __slots__ = ()
26
+
27
+ def __new__(cls, *items: Any) -> Pair:
28
+ return super().__new__(cls, items)
29
+
30
+ def __getnewargs__(self) -> tuple[Any, ...]:
31
+ return tuple(self)
32
+
33
+ def __eq__(self, other: object) -> bool:
34
+ if isinstance(other, (list, tuple)):
35
+ return tuple(self) == tuple(other)
36
+ return NotImplemented
37
+
38
+ def __ne__(self, other: object) -> bool:
39
+ equal = self.__eq__(other)
40
+ return equal if equal is NotImplemented else not equal
41
+
42
+ __hash__ = tuple.__hash__
43
+
44
+
45
+ def char_at(src: str, pos: int) -> str:
46
+ """Return the character at `pos`, or an empty string when `pos` is out of bounds."""
47
+ return src[pos] if 0 <= pos < len(src) else ""
48
+
49
+
50
+ def is_whitespace(char: str) -> bool:
51
+ """Whether `char` matches JavaScript's `\\s`."""
52
+ return _WHITESPACE_CHAR.match(char) is not None
53
+
54
+
55
+ def parse_hex(text: str) -> int | float:
56
+ """Mirror `parseInt(text, 16)`: parse the longest hexadecimal prefix, or NaN if there is none."""
57
+ text = _LEADING_WHITESPACE.sub("", text)
58
+ sign = 1
59
+ if text[:1] in ("+", "-"):
60
+ sign = -1 if text[0] == "-" else 1
61
+ text = text[1:]
62
+ if text[:2] in ("0x", "0X"):
63
+ text = text[2:]
64
+ digits = _HEX_DIGITS.match(text).group()
65
+ if not digits:
66
+ return math.nan
67
+ return sign * int(digits, 16)
68
+
69
+
70
+ def json_stringify(value: Any) -> str:
71
+ """Serialize like `JSON.stringify`: compact, non-ASCII preserved, objects as their public fields."""
72
+ return json.dumps(value, separators=(",", ":"), ensure_ascii=False, default=_to_json)
73
+
74
+
75
+ def _to_json(obj: Any) -> Any:
76
+ if not hasattr(obj, "__dict__"):
77
+ return {}
78
+ return {
79
+ key: value
80
+ for key, value in vars(obj).items()
81
+ if not key.startswith("_") and value is not None and not callable(value)
82
+ }
v2-models-effort/runs/20261016T205207Z_9c5d87a1/proxy.log ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ NOTICE Oct 16 20:52:18.673 [1]: Initializing tinyproxy ...
2
+ NOTICE Oct 16 20:52:18.674 [1]: Reloading config file (/etc/tinyproxy/tinyproxy.conf)
3
+ INFO Oct 16 20:52:18.675 [1]: Added address [0.0.0.0] to listen addresses.
4
+ INFO Oct 16 20:52:18.676 [1]: Adding Port [443] to the list allowed by CONNECT
5
+ NOTICE Oct 16 20:52:18.678 [1]: Reloading config file finished
6
+ INFO Oct 16 20:52:18.679 [1]: listen_sock called with addr = '0.0.0.0'
7
+ INFO Oct 16 20:52:18.681 [1]: trying to listen on host[0.0.0.0], family[2], socktype[1], proto[6]
8
+ INFO Oct 16 20:52:18.682 [1]: listening on fd [3]
9
+ INFO Oct 16 20:52:18.683 [1]: Not running as root, so not changing UID/GID.
10
+ INFO Oct 16 20:52:18.684 [1]: Setting the various signals.
11
+ INFO Oct 16 20:52:18.686 [1]: Starting main loop. Accepting connections.
12
+ CONNECT Oct 16 20:52:18.955 [1]: Connect (file descriptor 5): 192.168.32.3
13
+ CONNECT Oct 16 20:52:18.957 [1]: Request (file descriptor 5): CONNECT api.anthropic.com:443 HTTP/1.1
14
+ INFO Oct 16 20:52:18.959 [1]: No upstream proxy for api.anthropic.com
15
+ INFO Oct 16 20:52:18.960 [1]: opensock: opening connection to api.anthropic.com:443
16
+ INFO Oct 16 20:52:18.964 [1]: opensock: getaddrinfo returned for api.anthropic.com:443
17
+ CONNECT Oct 16 20:52:18.971 [1]: Established connection to host "api.anthropic.com" using file descriptor 6.
18
+ INFO Oct 16 20:52:18.973 [1]: Not sending client headers to remote machine
19
+ CONNECT Oct 16 20:52:19.081 [1]: Connect (file descriptor 7): 192.168.32.3
20
+ CONNECT Oct 16 20:52:19.083 [1]: Request (file descriptor 7): CONNECT api.anthropic.com:443 HTTP/1.1
21
+ INFO Oct 16 20:52:19.084 [1]: No upstream proxy for api.anthropic.com
22
+ INFO Oct 16 20:52:19.085 [1]: opensock: opening connection to api.anthropic.com:443
23
+ INFO Oct 16 20:52:19.088 [1]: opensock: getaddrinfo returned for api.anthropic.com:443
24
+ CONNECT Oct 16 20:52:19.094 [1]: Established connection to host "api.anthropic.com" using file descriptor 8.
25
+ INFO Oct 16 20:52:19.095 [1]: Not sending client headers to remote machine
26
+ CONNECT Oct 16 20:52:19.123 [1]: Connect (file descriptor 9): 192.168.32.3
27
+ CONNECT Oct 16 20:52:19.125 [1]: Request (file descriptor 9): CONNECT api.anthropic.com:443 HTTP/1.1
28
+ INFO Oct 16 20:52:19.126 [1]: No upstream proxy for api.anthropic.com
29
+ INFO Oct 16 20:52:19.128 [1]: opensock: opening connection to api.anthropic.com:443
30
+ INFO Oct 16 20:52:19.129 [1]: opensock: getaddrinfo returned for api.anthropic.com:443
31
+ CONNECT Oct 16 20:52:19.136 [1]: Established connection to host "api.anthropic.com" using file descriptor 10.
32
+ INFO Oct 16 20:52:19.137 [1]: Not sending client headers to remote machine
33
+ INFO Oct 16 20:52:19.160 [1]: Closed connection between local client (fd:5) and remote client (fd:6)
34
+ INFO Oct 16 20:52:19.318 [1]: Closed connection between local client (fd:7) and remote client (fd:8)
35
+ INFO Oct 16 21:15:40.142 [1]: Closed connection between local client (fd:9) and remote client (fd:10)
v2-models-effort/runs/20261016T205207Z_9c5d87a1/run.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "params": {
3
+ "source-language": "javascript",
4
+ "model": "claude-opus-5-5",
5
+ "effort": "xhigh"
6
+ },
7
+ "created": "2026-10-16T20:52:07Z",
8
+ "ended": "2026-10-16T21:15:41Z",
9
+ "exit_code": 137
10
+ }
v2-models-effort/runs/20261016T205207Z_9c5d87a1/stderr.txt ADDED
File without changes
v2-models-effort/runs/20261016T205207Z_9c5d87a1/transcript/.claude/projects/-target/3c26ae17-d4ed-412a-9fb7-89b28f946dc2.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
v2-models-effort/runs/20261016T210335Z_4d158ae5/manifest.json ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "timestamp": "2026-10-16T21:03:35Z",
3
+ "completed_at": "2026-10-16T22:46:21Z",
4
+ "exit_code": 0,
5
+ "study": "v2-model-effort",
6
+ "condition": {
7
+ "name": "source-python_unit-tests_source-integration-tests_effort-max_model-claude-fable-5-1",
8
+ "source_language": "python",
9
+ "target_language": "javascript",
10
+ "include_unit_tests": true,
11
+ "include_source_integration_tests": true,
12
+ "include_target_integration_tests": false,
13
+ "effort": "max",
14
+ "model": "claude-fable-5-1"
15
+ },
16
+ "derivation": {
17
+ "gbnf_commit": "13f1aca495d11e160fffd68c4ba299a2415909d8"
18
+ },
19
+ "reference_implementation": {
20
+ "included": [
21
+ "python/.gitignore",
22
+ "python/MANIFEST.in",
23
+ "python/Makefile",
24
+ "python/README.md",
25
+ "python/gbnf/GBNF.py",
26
+ "python/gbnf/__init__.py",
27
+ "python/gbnf/grammar_graph/__init__.py",
28
+ "python/gbnf/grammar_graph/colorize.py",
29
+ "python/gbnf/grammar_graph/colorize_test.py",
30
+ "python/gbnf/grammar_graph/get_input_as_code_points.py",
31
+ "python/gbnf/grammar_graph/get_input_as_code_points_test.py",
32
+ "python/gbnf/grammar_graph/get_parent_stack_id.py",
33
+ "python/gbnf/grammar_graph/get_parent_stack_id_test.py",
34
+ "python/gbnf/grammar_graph/get_serialized_rule_key.py",
35
+ "python/gbnf/grammar_graph/get_serialized_rule_key_test.py",
36
+ "python/gbnf/grammar_graph/grammar_graph_types.py",
37
+ "python/gbnf/grammar_graph/graph.py",
38
+ "python/gbnf/grammar_graph/graph_node.py",
39
+ "python/gbnf/grammar_graph/graph_node_test.py",
40
+ "python/gbnf/grammar_graph/graph_pointer.py",
41
+ "python/gbnf/grammar_graph/graph_pointer_test.py",
42
+ "python/gbnf/grammar_graph/graph_test.py",
43
+ "python/gbnf/grammar_graph/parse_state.py",
44
+ "python/gbnf/grammar_graph/parse_state_test.py",
45
+ "python/gbnf/grammar_graph/pointers.py",
46
+ "python/gbnf/grammar_graph/print.py",
47
+ "python/gbnf/grammar_graph/print_test.py",
48
+ "python/gbnf/grammar_graph/rule_ref.py",
49
+ "python/gbnf/grammar_graph/rule_ref_test.py",
50
+ "python/gbnf/grammar_graph/type_guards.py",
51
+ "python/gbnf/grammar_graph/type_guards_test.py",
52
+ "python/gbnf/grammar_parser/__init__.py",
53
+ "python/gbnf/grammar_parser/build_rule_stack.py",
54
+ "python/gbnf/grammar_parser/build_rule_stack_test.py",
55
+ "python/gbnf/rules_builder/__init__.py",
56
+ "python/gbnf/rules_builder/is_word_char.py",
57
+ "python/gbnf/rules_builder/is_word_char_test.py",
58
+ "python/gbnf/rules_builder/parse_char.py",
59
+ "python/gbnf/rules_builder/parse_char_test.py",
60
+ "python/gbnf/rules_builder/parse_name.py",
61
+ "python/gbnf/rules_builder/parse_name_test.py",
62
+ "python/gbnf/rules_builder/parse_space.py",
63
+ "python/gbnf/rules_builder/parse_space_test.py",
64
+ "python/gbnf/rules_builder/rules_builder.py",
65
+ "python/gbnf/rules_builder/rules_builder_test.py",
66
+ "python/gbnf/rules_builder/rules_builder_types.py",
67
+ "python/gbnf/rules_builder/symbol_ids.py",
68
+ "python/gbnf/utils/__init__.py",
69
+ "python/gbnf/utils/errors/__init__.py",
70
+ "python/gbnf/utils/errors/build_error_position.py",
71
+ "python/gbnf/utils/errors/build_error_position_test.py",
72
+ "python/gbnf/utils/errors/errors_types.py",
73
+ "python/gbnf/utils/errors/get_input_as_string.py",
74
+ "python/gbnf/utils/errors/get_input_as_string_test.py",
75
+ "python/gbnf/utils/errors/grammar_parse_error.py",
76
+ "python/gbnf/utils/errors/grammar_parse_error_test.py",
77
+ "python/gbnf/utils/errors/input_parse_error.py",
78
+ "python/gbnf/utils/errors/input_parse_error_test.py",
79
+ "python/gbnf/utils/is_point_in_range.py",
80
+ "python/gbnf/utils/is_point_in_range_test.py",
81
+ "python/gbnf/utils/validate_non_empty.py",
82
+ "python/pyproject.toml",
83
+ "python/requirements.txt",
84
+ "python/tests/generated/iteration/iteration_test.py",
85
+ "python/tests/generated/iteration/iteration_with_additional_strings_test.py",
86
+ "python/tests/generated/iteration/iteration_with_an_initial_string_test.py",
87
+ "python/tests/generated/validation/validate_grammar_test.py",
88
+ "python/tests/generated/validation/validate_input_test.py",
89
+ "python/uv.lock"
90
+ ]
91
+ },
92
+ "sandbox": {
93
+ "image_id": "sha256:99d2df3cc2c08588bec8154bc52c2acd1288d545507ba0393bd46652132f8835"
94
+ },
95
+ "harness": {
96
+ "commit": "9e24e21259430f5e40bca73c392757016eda7cda",
97
+ "dirty": true
98
+ }
99
+ }