thekevinscott commited on
Commit
f63a8a8
·
verified ·
1 Parent(s): 3f30f23

Upload folder using huggingface_hub (part 11)

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/20261116-123314-shrill-sea/ported_implementation/tests/unit/test_gbnf.py +208 -0
  2. v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/test_public_api.py +235 -0
  3. v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/test_thread_safety.py +45 -0
  4. v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/__init__.py +0 -0
  5. v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/errors/__init__.py +0 -0
  6. v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/errors/test_build_error_position.py +110 -0
  7. v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/errors/test_get_input_as_string.py +27 -0
  8. v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/errors/test_grammar_parse_error.py +78 -0
  9. v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/errors/test_input_parse_error.py +144 -0
  10. v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/test_attr_dict.py +30 -0
  11. v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/test_camel_case.py +71 -0
  12. v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/test_is_point_in_range.py +32 -0
  13. v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/test_js_compat.py +145 -0
  14. v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/test_pair.py +28 -0
  15. v2-models-effort/runs/20261116-123314-shrill-sea/proxy.log +42 -0
  16. v2-models-effort/runs/20261116-123314-shrill-sea/result.json +1 -0
  17. v2-models-effort/runs/20261116-123314-shrill-sea/run.json +28 -0
  18. v2-models-effort/runs/20261116-123314-shrill-sea/run.lock +0 -0
  19. v2-models-effort/runs/20261116-123314-shrill-sea/stderr.log +0 -0
  20. v2-models-effort/runs/20261116-123314-shrill-sea/stderr.txt +0 -0
  21. v2-models-effort/runs/20261116-123314-shrill-sea/stdout.log +1 -0
  22. v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/e1098157-528d-4b45-b968-fd5fca4ac1e8.jsonl +0 -0
  23. v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/e1098157-528d-4b45-b968-fd5fca4ac1e8/subagents/agent-a3644837b6c44547e.jsonl +0 -0
  24. v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/e1098157-528d-4b45-b968-fd5fca4ac1e8/subagents/agent-a3644837b6c44547e.meta.json +1 -0
  25. v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/e1098157-528d-4b45-b968-fd5fca4ac1e8/subagents/agent-a7965f7d736f23a9a.jsonl +0 -0
  26. v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/e1098157-528d-4b45-b968-fd5fca4ac1e8/subagents/agent-a7965f7d736f23a9a.meta.json +1 -0
  27. v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/e1098157-528d-4b45-b968-fd5fca4ac1e8/subagents/agent-abd2f9d0af86b2b0c.jsonl +0 -0
  28. v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/e1098157-528d-4b45-b968-fd5fca4ac1e8/subagents/agent-abd2f9d0af86b2b0c.meta.json +1 -0
  29. v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/memory/MEMORY.md +1 -0
  30. v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/memory/gbnf-python-port.md +17 -0
  31. v2-models-effort/runs/20261116-123314-spring-meadow/credentials.log +95 -0
  32. v2-models-effort/runs/20261116-123314-spring-meadow/git-diff.patch +0 -0
  33. v2-models-effort/runs/20261116-123314-spring-meadow/git-sha.txt +1 -0
  34. v2-models-effort/runs/20261116-123314-spring-meadow/manifest.json +105 -0
  35. v2-models-effort/runs/20261116-123314-spring-meadow/memory.jsonl +669 -0
  36. v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/.gitignore +6 -0
  37. v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/README.md +82 -0
  38. v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/conftest.py +5 -0
  39. v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/__init__.py +56 -0
  40. v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/_compat.py +52 -0
  41. v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/gbnf.py +35 -0
  42. v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/__init__.py +3 -0
  43. v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/colorize.py +24 -0
  44. v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/generic_set.py +47 -0
  45. v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/get_input_as_code_points.py +18 -0
  46. v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/get_parent_stack_id.py +24 -0
  47. v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/get_serialized_rule_key.py +38 -0
  48. v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/graph.py +207 -0
  49. v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/graph_node.py +50 -0
  50. v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/graph_pointer.py +155 -0
v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/test_gbnf.py ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from types import SimpleNamespace
3
+ from unittest.mock import MagicMock, call, patch
4
+
5
+ import pytest
6
+
7
+ from gbnf import GBNF, GrammarParseError, InputParseError, ParseState
8
+ from gbnf.rules_builder.symbol_ids import SymbolIds
9
+ from gbnf.rules_builder.types import InternalRuleType
10
+
11
+
12
+ # The original mocks the collaborators of `GBNF` for the whole of its test file. Here each is a fixture, patched on
13
+ # the `gbnf.gbnf` module that `GBNF` looks them up on, that a test asks for when it wants it replaced.
14
+ @pytest.fixture
15
+ def mock_rules_builder():
16
+ """`RulesBuilder`, which by default builds no rules and knows no symbols."""
17
+ with patch("gbnf.gbnf.RulesBuilder") as mock:
18
+ mock.return_value = SimpleNamespace(rules=[], symbol_ids={})
19
+ yield mock
20
+
21
+
22
+ @pytest.fixture
23
+ def mock_build_rule_stack():
24
+ with patch("gbnf.gbnf.build_rule_stack") as mock:
25
+ yield mock
26
+
27
+
28
+ @pytest.fixture
29
+ def mock_graph_class():
30
+ with patch("gbnf.gbnf.Graph") as mock:
31
+ yield mock
32
+
33
+
34
+ @pytest.fixture
35
+ def mock_parse_state_class():
36
+ with patch("gbnf.gbnf.ParseState") as mock:
37
+ yield mock
38
+
39
+
40
+ def _mapping_of_symbols_without_root():
41
+ return {"root1": 1, "root2": 1}
42
+
43
+
44
+ def _symbol_ids_without_root():
45
+ symbol_ids = SymbolIds()
46
+ symbol_ids.set("root1", 1, 0)
47
+ symbol_ids.set("root2", 1, 0)
48
+ return symbol_ids
49
+
50
+
51
+ def describe_gbnf():
52
+ def it_should_throw_if_rules_are_empty(mock_rules_builder, mock_graph_class, mock_parse_state_class):
53
+ with pytest.raises(GrammarParseError) as excinfo:
54
+ GBNF("")
55
+ assert str(excinfo.value) == str(GrammarParseError("", 0, "No rules were found"))
56
+ mock_rules_builder.assert_called_once_with("")
57
+ mock_graph_class.assert_not_called()
58
+ mock_parse_state_class.assert_not_called()
59
+
60
+ @pytest.mark.parametrize(
61
+ "make_symbol_ids",
62
+ [_mapping_of_symbols_without_root, _symbol_ids_without_root],
63
+ ids=["mapping", "SymbolIds"],
64
+ )
65
+ def it_should_throw_if_symbol_ids_does_not_have_root(
66
+ make_symbol_ids, mock_rules_builder, mock_graph_class, mock_parse_state_class
67
+ ):
68
+ symbol_ids = make_symbol_ids()
69
+ mock_rules_builder.return_value = SimpleNamespace(
70
+ rules=[[{"type": InternalRuleType.END}]],
71
+ symbol_ids=symbol_ids,
72
+ )
73
+ with pytest.raises(GrammarParseError) as excinfo:
74
+ GBNF("")
75
+ reason = f"Grammar does not contain a root symbol. Available symbols are: {json.dumps(list(symbol_ids.keys()))}"
76
+ assert str(excinfo.value) == str(GrammarParseError("", 0, reason))
77
+ assert excinfo.value.reason == (
78
+ 'Grammar does not contain a root symbol. Available symbols are: ["root1", "root2"]'
79
+ )
80
+ mock_graph_class.assert_not_called()
81
+ mock_parse_state_class.assert_not_called()
82
+
83
+ def it_builds_parse_state(
84
+ mock_rules_builder, mock_build_rule_stack, mock_graph_class, mock_parse_state_class
85
+ ):
86
+ grammar = "grammar"
87
+ initial_string = "foo"
88
+ symbol_ids = {"root": 1}
89
+ rules = [
90
+ [{"type": InternalRuleType.END}],
91
+ [{"type": InternalRuleType.CHAR, "value": [97]}],
92
+ ]
93
+ mock_rules_builder.return_value = SimpleNamespace(rules=rules, symbol_ids=symbol_ids)
94
+ mock_graph = MagicMock()
95
+ mock_graph.add.return_value = "foo"
96
+ mock_graph_class.return_value = mock_graph
97
+ mock_parse_state = MagicMock()
98
+ mock_parse_state_class.return_value = mock_parse_state
99
+ mock_build_rule_stack.side_effect = lambda rule: rule
100
+
101
+ assert GBNF(grammar, initial_string) is mock_parse_state
102
+ mock_rules_builder.assert_called_once_with(grammar)
103
+ assert mock_build_rule_stack.call_args_list == [call(rules[0]), call(rules[1])]
104
+ mock_graph_class.assert_called_once_with(grammar, rules, 1)
105
+ mock_graph.add.assert_called_once_with(initial_string)
106
+ mock_parse_state_class.assert_called_once_with(mock_graph, "foo")
107
+
108
+ def it_adds_an_empty_initial_string_by_default(
109
+ mock_rules_builder, mock_build_rule_stack, mock_graph_class, mock_parse_state_class
110
+ ):
111
+ rules = [[{"type": InternalRuleType.END}]]
112
+ mock_rules_builder.return_value = SimpleNamespace(rules=rules, symbol_ids={"root": 0})
113
+ mock_build_rule_stack.side_effect = lambda rule: rule
114
+
115
+ GBNF("grammar")
116
+ mock_graph_class.assert_called_once_with("grammar", rules, 0)
117
+ mock_graph_class.return_value.add.assert_called_once_with("")
118
+
119
+ def describe_with_real_collaborators():
120
+ @pytest.mark.parametrize(
121
+ "grammar",
122
+ ["", " ", "\n\n", "# only a comment", " # a comment\n\n"],
123
+ ids=repr,
124
+ )
125
+ def it_should_throw_if_there_are_no_rules(grammar):
126
+ with pytest.raises(GrammarParseError) as excinfo:
127
+ GBNF(grammar)
128
+ assert str(excinfo.value) == str(GrammarParseError(grammar, 0, "No rules were found"))
129
+ assert excinfo.value.pos == 0
130
+ assert excinfo.value.reason == "No rules were found"
131
+
132
+ cases_without_a_root_rule = [
133
+ ('foo ::= "foo"', ["foo"]),
134
+ ('foo ::= bar\nbar ::= "bar"', ["foo", "bar"]),
135
+ ('foo ::= "a"*', ["foo", "foo_1"]),
136
+ ('roots ::= "foo"', ["roots"]),
137
+ ('Root ::= "foo"', ["Root"]),
138
+ ]
139
+
140
+ @pytest.mark.parametrize(
141
+ ("grammar", "symbols"),
142
+ cases_without_a_root_rule,
143
+ ids=[repr(grammar) for grammar, _ in cases_without_a_root_rule],
144
+ )
145
+ def it_should_throw_if_the_grammar_does_not_have_a_root_rule(grammar, symbols):
146
+ with pytest.raises(GrammarParseError) as excinfo:
147
+ GBNF(grammar)
148
+ reason = f"Grammar does not contain a root symbol. Available symbols are: {json.dumps(symbols)}"
149
+ assert excinfo.value.reason.startswith("Grammar does not contain a root symbol")
150
+ assert excinfo.value.reason == reason
151
+ assert str(excinfo.value) == str(GrammarParseError(grammar, 0, reason))
152
+
153
+ def it_returns_a_parse_state_for_the_grammar():
154
+ grammar = 'root ::= "ab"'
155
+ state = GBNF(grammar)
156
+ assert isinstance(state, ParseState)
157
+ assert state.grammar == grammar
158
+ assert [*state] == [{"type": "char", "value": [ord("a")]}]
159
+
160
+ @pytest.mark.parametrize("initial_string", ["a", ord("a"), [ord("a")]], ids=repr)
161
+ def it_consumes_the_initial_string(initial_string):
162
+ state = GBNF('root ::= "ab"', initial_string)
163
+ assert [*state] == [{"type": "char", "value": [ord("b")]}]
164
+
165
+ def it_should_throw_if_the_initial_string_does_not_match_the_grammar():
166
+ with pytest.raises(InputParseError) as excinfo:
167
+ GBNF('root ::= "ab"', "x")
168
+ assert str(excinfo.value) == str(InputParseError("x", 0))
169
+
170
+ def it_finds_the_root_rule_wherever_it_is_defined():
171
+ state = GBNF('foo ::= "a"\nroot ::= foo "b"')
172
+ assert [*state] == [{"type": "char", "value": [ord("a")]}]
173
+ assert [*state.add("a")] == [{"type": "char", "value": [ord("b")]}]
174
+
175
+ def it_accepts_an_object_that_renders_as_a_grammar():
176
+ class RenderedGrammar:
177
+ def __str__(self):
178
+ return 'root ::= "a"'
179
+
180
+ state = GBNF(RenderedGrammar())
181
+ assert state.grammar == 'root ::= "a"'
182
+ assert [*state] == [{"type": "char", "value": [ord("a")]}]
183
+
184
+ def describe_the_state():
185
+ @pytest.fixture
186
+ def state():
187
+ return GBNF('root ::= "ab"')
188
+
189
+ def it_returns_a_new_state_when_it_is_called(state):
190
+ next_state = state("a")
191
+ assert isinstance(next_state, ParseState)
192
+ assert next_state is not state
193
+ assert [*next_state] == [{"type": "char", "value": [ord("b")]}]
194
+
195
+ def it_returns_a_new_state_when_a_string_is_added(state):
196
+ next_state = state.add("a")
197
+ assert isinstance(next_state, ParseState)
198
+ assert next_state is not state
199
+ assert [*next_state] == [{"type": "char", "value": [ord("b")]}]
200
+
201
+ def it_does_not_change_the_state_that_input_is_added_to(state):
202
+ state.add("a")
203
+ state("a")
204
+ assert [*state] == [{"type": "char", "value": [ord("a")]}]
205
+
206
+ def it_returns_equal_states_whether_it_is_called_or_added_to(state):
207
+ assert [*state("a")] == [*state.add("a")]
208
+ assert [*state("a")("b")] == [*state.add("a").add("b")] == [{"type": "end"}]
v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/test_public_api.py ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+ import sys
3
+
4
+ import pytest
5
+
6
+ import gbnf
7
+ from gbnf import (
8
+ GBNF,
9
+ GBNFError,
10
+ GrammarParseError,
11
+ InputParseError,
12
+ ParseState,
13
+ Range,
14
+ RuleChar,
15
+ RuleType,
16
+ is_range,
17
+ )
18
+
19
+
20
+ def describe_public_api():
21
+ def it_exports_the_same_names_as_the_javascript_package():
22
+ for name in (
23
+ "GBNF", "is_range", "RuleType", "Rule", "RuleChar", "RuleCharExclude", "RuleEnd", "Range",
24
+ "ParseState", "InputParseError", "GrammarParseError",
25
+ ):
26
+ assert hasattr(gbnf, name), name
27
+
28
+ def it_resolves_the_original_camel_case_names():
29
+ assert gbnf.isRange is is_range
30
+
31
+ def it_has_a_version():
32
+ assert gbnf.__version__ == "0.1.41"
33
+
34
+ def describe_readme_examples():
35
+ def it_iterates_the_rules_of_a_state():
36
+ state = GBNF("""
37
+ root ::= "yes" | "no"
38
+ """)
39
+ assert [*state] == [
40
+ {"type": "char", "value": [ord("y")]},
41
+ {"type": "char", "value": [ord("n")]},
42
+ ]
43
+
44
+ def it_adds_input_to_get_a_new_state():
45
+ state = GBNF("""
46
+ root ::= "I like green eggs and ham"
47
+ """)
48
+ assert [*state] == [{"type": "char", "value": [ord("I")]}]
49
+ state = state.add("I li")
50
+ assert [*state] == [{"type": "char", "value": [ord("k")]}]
51
+ state = state("ke gree")
52
+ assert [*state] == [{"type": "char", "value": [ord("n")]}]
53
+
54
+ def it_leaves_the_previous_state_untouched():
55
+ state = GBNF('root ::= "ab"')
56
+ after_a = state.add("a")
57
+ assert [*state] == [{"type": "char", "value": [ord("a")]}]
58
+ assert [*after_a] == [{"type": "char", "value": [ord("b")]}]
59
+
60
+ def describe_parse_state():
61
+ def it_is_a_parse_state():
62
+ assert isinstance(GBNF('root ::= "a"'), ParseState)
63
+
64
+ def it_is_truthy():
65
+ assert GBNF('root ::= "a"')
66
+
67
+ def it_exposes_the_grammar():
68
+ assert GBNF('root ::= "a"').grammar == 'root ::= "a"'
69
+
70
+ def it_counts_unique_rules():
71
+ assert GBNF('root ::= "a" | "b"').size == 2
72
+ assert GBNF('root ::= "a" | "a"').size == 1
73
+ assert GBNF('root ::= "a" | "a"').size() == 1
74
+
75
+ def it_returns_new_states_from_add_and_call():
76
+ state = GBNF('root ::= "abc"')
77
+ assert isinstance(state.add("a"), ParseState)
78
+ assert isinstance(state("a"), ParseState)
79
+ assert state.add("a") is not state
80
+
81
+ def it_accepts_code_points_and_lists_of_code_points():
82
+ state = GBNF('root ::= "abc"')
83
+ assert [*state.add(97)] == [*state.add("a")]
84
+ assert [*state.add([97, 98])] == [*state.add("ab")]
85
+ assert [*GBNF('root ::= "abc"', [97, 98])] == [*state.add("ab")]
86
+ assert [*GBNF('root ::= "abc"', 97)] == [*state.add("a")]
87
+
88
+ def it_returns_each_rule_once():
89
+ state = GBNF('root ::= "a" | "a"')
90
+ assert [*state] == [{"type": "char", "value": [97]}]
91
+
92
+ def it_gives_the_rules_as_an_iterator():
93
+ assert list(GBNF('root ::= "a"').rules()) == [{"type": "char", "value": [97]}]
94
+
95
+ def describe_rules():
96
+ def it_compares_equal_to_plain_dicts_and_strings():
97
+ (rule,) = GBNF("root ::= [a-z]")
98
+ assert rule == {"type": "char", "value": [[97, 122]]}
99
+ assert rule["type"] == RuleType.CHAR == "char"
100
+
101
+ def it_exposes_ranges_as_pairs_of_numbers():
102
+ (rule,) = GBNF("root ::= [a-z0-9_]")
103
+ assert rule.value == [[97, 122], [48, 57], 95]
104
+ assert [is_range(value) for value in rule.value] == [True, True, False]
105
+ assert isinstance(rule.value[0], Range)
106
+ assert rule.value[0] == (97, 122)
107
+
108
+ def it_exposes_the_rule_types():
109
+ assert [*GBNF("root ::= [^a]")] == [{"type": "char_exclude", "value": [97]}]
110
+ assert [*GBNF('root ::= "a"', "a")] == [{"type": RuleType.END}]
111
+ (rule,) = GBNF("root ::= [^a]")
112
+ assert isinstance(rule, RuleChar.__mro__[1])
113
+
114
+ def it_allows_reading_rule_fields_as_attributes():
115
+ (rule,) = GBNF('root ::= "a"')
116
+ assert (rule.type, rule.value) == ("char", [97])
117
+
118
+ def describe_unicode():
119
+ def it_matches_characters_of_the_basic_multilingual_plane():
120
+ state = GBNF("root ::= [ぁ-ゟ]+").add("あい")
121
+ assert [*state][-1] == {"type": "end"}
122
+
123
+ def it_matches_characters_beyond_the_basic_multilingual_plane_as_one_code_point():
124
+ state = GBNF('root ::= "\U0001F600" "x"')
125
+ assert [*state] == [{"type": "char", "value": [0x1F600]}]
126
+ state = state.add("\U0001F600")
127
+ assert [*state] == [{"type": "char", "value": [ord("x")]}]
128
+ assert [*GBNF('root ::= "\\U0001F4A9"').add("\U0001F4A9")] == [{"type": "end"}]
129
+
130
+ def describe_errors():
131
+ def it_raises_a_grammar_parse_error_with_the_position():
132
+ with pytest.raises(GrammarParseError) as excinfo:
133
+ GBNF("root = x")
134
+ assert excinfo.value.pos == 5
135
+ assert excinfo.value.reason == "Expecting ::= at 5"
136
+ assert excinfo.value.grammar == "root = x"
137
+ assert excinfo.value.name == "GrammarParseError"
138
+ assert str(excinfo.value) == excinfo.value.message == "\n".join([
139
+ "Failed to parse grammar: Expecting ::= at 5",
140
+ "",
141
+ "root = x",
142
+ " ^",
143
+ ])
144
+
145
+ def it_raises_an_input_parse_error_with_the_position():
146
+ state = GBNF('root ::= "bar"').add("b")
147
+ with pytest.raises(InputParseError) as excinfo:
148
+ state.add("x")
149
+ assert excinfo.value.name == "InputParseError"
150
+ assert excinfo.value.src == "bx"
151
+ assert str(excinfo.value) == "\n".join(["Failed to parse input string:", "", "bx", " ^"])
152
+ assert excinfo.value.error_for_most_recent_input == "\n".join(
153
+ ["Failed to parse input string:", "", "x", "^"])
154
+ assert excinfo.value.errorForMostRecentInput == excinfo.value.error_for_most_recent_input
155
+
156
+ def it_derives_every_error_from_gbnf_error():
157
+ assert issubclass(GrammarParseError, GBNFError)
158
+ assert issubclass(InputParseError, GBNFError)
159
+
160
+ def it_pickles_errors():
161
+ for error in (GrammarParseError("root = x", 5, "reason"), InputParseError("z", 0, "ba")):
162
+ copy = pickle.loads(pickle.dumps(error))
163
+ assert type(copy) is type(error)
164
+ assert str(copy) == str(error)
165
+
166
+ def it_reports_the_input_of_every_failed_add_in_the_history():
167
+ # the graph remembers all input that was ever added to it, whichever state it was added to
168
+ state = GBNF('root ::= "foo" | "bar"')
169
+ state.add("f")
170
+ state_b = state.add("b")
171
+ with pytest.raises(InputParseError) as excinfo:
172
+ state_b.add("z")
173
+ assert excinfo.value.src == "fbz"
174
+
175
+ def it_reports_undefined_rules_inside_repetitions():
176
+ with pytest.raises(GrammarParseError) as excinfo:
177
+ GBNF("root ::= a*")
178
+ assert excinfo.value.reason == 'Undefined rule identifier "a"'
179
+
180
+ def it_reports_a_missing_root_rule():
181
+ with pytest.raises(GrammarParseError) as excinfo:
182
+ GBNF('foo ::= "a"')
183
+ assert excinfo.value.reason == 'Grammar does not contain a root symbol. Available symbols are: ["foo"]'
184
+
185
+ @pytest.mark.parametrize("grammar", [
186
+ 'root ::= root "a" | "b"',
187
+ 'root ::= ("a"?)*',
188
+ 'root ::= a\na ::= b\nb ::= a',
189
+ ])
190
+ def it_gives_up_on_grammars_that_recurse_without_consuming_input(grammar):
191
+ with pytest.raises(RecursionError):
192
+ GBNF(grammar)
193
+
194
+ def it_rejects_invalid_code_points_in_input():
195
+ state = GBNF('root ::= "a"')
196
+ with pytest.raises(ValueError, match="Invalid code point -1"):
197
+ state.add(-1)
198
+
199
+ def describe_long_input():
200
+ def it_handles_long_repetitions_without_hitting_the_recursion_limit():
201
+ state = GBNF("root ::= [a-z]*")
202
+ for _ in range(1500):
203
+ state = state.add("a")
204
+ assert [*state] == [{"type": "char", "value": [[97, 122]]}, {"type": "end"}]
205
+
206
+ def it_handles_deeply_nested_groups():
207
+ depth = 150
208
+ grammar = "root ::= " + "(" * depth + '"a"' + ")" * depth
209
+ assert [*GBNF(grammar).add("a")] == [{"type": "end"}]
210
+
211
+ def it_handles_a_long_chain_of_rules_that_start_with_a_rule():
212
+ names = ["a" * (i + 1) for i in range(400)]
213
+ rules = [f"{name} ::= {next_name}" for name, next_name in zip(names, names[1:])]
214
+ grammar = "\n".join([f"root ::= {names[0]}", *rules, f'{names[-1]} ::= "z"'])
215
+ assert [*GBNF(grammar)] == [{"type": "char", "value": [ord("z")]}]
216
+
217
+
218
+ def describe_deeply_nested_grammars():
219
+ def it_parses_groups_nested_far_deeper_than_pythons_recursion_limit():
220
+ depth = 3000
221
+ assert depth > sys.getrecursionlimit()
222
+ grammar = "root ::= " + "(" * depth + '"a"' + ")" * depth
223
+ assert [*GBNF(grammar).add("a")] == [{"type": "end"}]
224
+
225
+ def it_parses_nested_repetitions():
226
+ depth = 1500
227
+ grammar = "root ::= " + '("a" ' * depth + '"b"' + ")*" * depth
228
+ assert [*GBNF(grammar)] == [{"type": "char", "value": [ord("a")]}, {"type": "end"}]
229
+
230
+ def it_still_reports_errors_at_the_right_place_when_deeply_nested():
231
+ depth = 2000
232
+ grammar = "root ::= " + "(" * depth + '"a"' + ")" * (depth - 1)
233
+ with pytest.raises(GrammarParseError) as excinfo:
234
+ GBNF(grammar)
235
+ assert excinfo.value.reason == f"Expecting ')' at {len(grammar)}"
v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/test_thread_safety.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import threading
3
+
4
+ from gbnf import GBNF
5
+
6
+
7
+ def describe_a_shared_state():
8
+ def it_can_be_added_to_from_several_threads_at_once():
9
+ # Every thread adds a different letter to the same state: what comes next must only depend on that letter.
10
+ grammar = 'root ::= "a" "x" | "b" "y" | "c" "z" | "d" "w"'
11
+ state = GBNF(grammar)
12
+ expected = {
13
+ letter: [{"type": "char", "value": [ord(follower)]}]
14
+ for letter, follower in zip("abcd", "xyzw")
15
+ }
16
+ mismatches: list[tuple[str, list]] = []
17
+ failures: list[BaseException] = []
18
+
19
+ def add_repeatedly(letter: str) -> None:
20
+ try:
21
+ for _ in range(1500):
22
+ rules = [*state.add(letter)]
23
+ if rules != expected[letter]:
24
+ mismatches.append((letter, rules))
25
+ except BaseException as error: # noqa: BLE001
26
+ failures.append(error)
27
+
28
+ previous_interval = sys.getswitchinterval()
29
+ sys.setswitchinterval(1e-6) # switch threads as often as possible
30
+ try:
31
+ threads = [threading.Thread(target=add_repeatedly, args=(letter,)) for letter in "abcd"]
32
+ for thread in threads:
33
+ thread.start()
34
+ for thread in threads:
35
+ thread.join()
36
+ finally:
37
+ sys.setswitchinterval(previous_interval)
38
+
39
+ assert failures == []
40
+ assert mismatches == []
41
+
42
+ def it_does_not_have_its_pointers_marked_by_adding_to_it():
43
+ state = GBNF('root ::= "a" | "b"')
44
+ state.add("a")
45
+ assert [pointer.valid for pointer in state._pointers] == [None, None]
v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/__init__.py ADDED
File without changes
v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/errors/__init__.py ADDED
File without changes
v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/errors/test_build_error_position.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ from gbnf.utils.errors.build_error_position import (
4
+ MAXIMUM_NUMBER_OF_ERROR_LINES_TO_SHOW,
5
+ build_error_position,
6
+ )
7
+
8
+ # (grammar, pos, expected lines of the grammar, expected line of the caret)
9
+ # `\n` stands for a newline, as it does in the original test: it is swapped for a real one before the call
10
+ CASES = [
11
+ (
12
+ 'root ::= "foo"',
13
+ 1,
14
+ 'root ::= "foo"',
15
+ " ^",
16
+ ),
17
+ (
18
+ 'root ::= "foo"',
19
+ 5,
20
+ 'root ::= "foo"',
21
+ " ^",
22
+ ),
23
+ # multi line grammars with pos on first line
24
+ (
25
+ "aa\\nbb",
26
+ 1,
27
+ "aa",
28
+ " ^",
29
+ ),
30
+ # multi line grammars with pos on second line, first character
31
+ (
32
+ "aa\\nbb",
33
+ 2,
34
+ "aa\\nbb",
35
+ "^",
36
+ ),
37
+ # multi line grammars with pos on second line, second character
38
+ (
39
+ "aa\\nbb",
40
+ 2 + 1,
41
+ "aa\\nbb",
42
+ " ^",
43
+ ),
44
+ # multi line grammars beyond error with pos on second line
45
+ (
46
+ "aa\\nbb\\ncc",
47
+ 2 + 1,
48
+ "aa\\nbb",
49
+ " ^",
50
+ ),
51
+ # multi line grammars beyond error with pos on third line, first char
52
+ (
53
+ "aa\\nbb\\ncc",
54
+ 2 + 2 + 0,
55
+ "aa\\nbb\\ncc",
56
+ "^",
57
+ ),
58
+ # multi line grammars beyond error with pos on third line, second char
59
+ (
60
+ "aa\\nbb\\ncc",
61
+ 2 + 2 + 1,
62
+ "aa\\nbb\\ncc",
63
+ " ^",
64
+ ),
65
+ # multi line grammars beyond error with pos on fourth line, first char
66
+ (
67
+ "aa\\nbb\\ncc\\ndd",
68
+ 2 + 2 + 2 + 0,
69
+ "bb\\ncc\\ndd",
70
+ "^",
71
+ ),
72
+ # multi line grammars beyond error with pos on fifth line, second char
73
+ (
74
+ "aa\\nbb\\ncc\\ndd\\nee",
75
+ 2 + 2 + 2 + 2 + 1,
76
+ "cc\\ndd\\nee",
77
+ " ^",
78
+ ),
79
+ ]
80
+
81
+
82
+ def describe_build_error_position():
83
+ @pytest.mark.parametrize(
84
+ ("grammar", "pos", "grammar_out", "pos_out"),
85
+ CASES,
86
+ ids=[f"{grammar}@{pos}" for grammar, pos, *_ in CASES],
87
+ )
88
+ def it_correctly_shows_position(grammar, pos, grammar_out, pos_out):
89
+ result = build_error_position(grammar.replace("\\n", "\n"), pos)
90
+ assert result == [
91
+ *grammar_out.split("\\n"),
92
+ pos_out,
93
+ ]
94
+
95
+ def it_renders_a_message_for_empty_input():
96
+ result = build_error_position("", 0)
97
+ assert result == ["No input provided"]
98
+
99
+ def it_shows_at_most_the_maximum_number_of_lines_before_the_caret():
100
+ assert MAXIMUM_NUMBER_OF_ERROR_LINES_TO_SHOW == 3
101
+ src = "\n".join(["aa", "bb", "cc", "dd", "ee", "ff"])
102
+ # the caret is on the last line (`ff`, second character): 5 lines of 2 characters precede it
103
+ result = build_error_position(src, 5 * 2 + 1)
104
+ assert result == ["dd", "ee", "ff", " ^"]
105
+ assert len(result) - 1 == MAXIMUM_NUMBER_OF_ERROR_LINES_TO_SHOW
106
+
107
+ def it_renders_an_empty_line_when_the_position_is_past_the_end_of_the_input():
108
+ # the original pushes `undefined` for the line that is not there, which renders as an empty line
109
+ assert build_error_position("a", 1) == ["a", "", "^"]
110
+ assert build_error_position("root ::= foo", 12) == ["root ::= foo", "", "^"]
v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/errors/test_get_input_as_string.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ from gbnf.utils.errors.get_input_as_string import get_input_as_string
4
+
5
+
6
+ def describe_get_input_as_string():
7
+ @pytest.mark.parametrize(
8
+ ("input_", "expected"),
9
+ [
10
+ ("hello", "hello"),
11
+ ([104, 101, 108, 108, 111], "hello"),
12
+ (104, "h"),
13
+ (0x1F600, "😀"),
14
+ ([0x1F600, 0x1F601], "😀😁"),
15
+ ],
16
+ ids=repr,
17
+ )
18
+ def it_correctly_converts_input_to_string(input_, expected):
19
+ result = get_input_as_string(input_)
20
+ assert result == expected
21
+
22
+ def it_converts_a_tuple_of_code_points_like_a_list():
23
+ assert get_input_as_string((104, 105)) == "hi"
24
+
25
+ def it_converts_no_code_points_to_an_empty_string():
26
+ assert get_input_as_string([]) == ""
27
+ assert get_input_as_string("") == ""
v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/errors/test_grammar_parse_error.py ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+
3
+ import pytest
4
+
5
+ from gbnf.utils.errors.gbnf_error import GBNFError
6
+ from gbnf.utils.errors.grammar_parse_error import (
7
+ GRAMMAR_PARSER_ERROR_HEADER_MESSAGE,
8
+ GrammarParseError,
9
+ )
10
+
11
+
12
+ def describe_grammar_parse_error():
13
+ def it_renders_a_message():
14
+ grammar = "aa\\nbb\\ncc\\ndd\\nee"
15
+ pos = 5
16
+ reason = "reason"
17
+ err = GrammarParseError(grammar.replace("\\n", "\n"), pos, reason)
18
+ assert err.message == "\n".join([
19
+ GRAMMAR_PARSER_ERROR_HEADER_MESSAGE(reason),
20
+ "",
21
+ "aa",
22
+ "bb",
23
+ "cc",
24
+ " ^",
25
+ ])
26
+
27
+ def it_renders_a_header_message_from_a_reason():
28
+ assert GRAMMAR_PARSER_ERROR_HEADER_MESSAGE("some reason") == "Failed to parse grammar: some reason"
29
+
30
+ def it_renders_a_message_for_an_empty_grammar():
31
+ err = GrammarParseError("", 0, "No rules were found")
32
+ assert err.message == "\n".join([
33
+ GRAMMAR_PARSER_ERROR_HEADER_MESSAGE("No rules were found"),
34
+ "",
35
+ "No input provided",
36
+ ])
37
+
38
+ def it_uses_the_message_as_its_string_form():
39
+ err = GrammarParseError('root ::= "foo"', 5, "reason")
40
+ assert str(err) == err.message
41
+
42
+ def it_exposes_the_grammar_the_position_and_the_reason():
43
+ err = GrammarParseError('root ::= "foo"', 5, "reason")
44
+ assert err.grammar == 'root ::= "foo"'
45
+ assert err.pos == 5
46
+ assert err.reason == "reason"
47
+
48
+ def it_is_a_named_gbnf_error():
49
+ err = GrammarParseError('root ::= "foo"', 5, "reason")
50
+ assert err.name == "GrammarParseError"
51
+ assert isinstance(err, GBNFError)
52
+ assert isinstance(err, Exception)
53
+
54
+ @pytest.mark.parametrize(
55
+ ("grammar", "pos", "reason"),
56
+ [
57
+ ("aa\nbb\ncc", 3, "reason"),
58
+ ('root ::= "foo"', 5, "Expecting ::= at 5"),
59
+ ("", 0, "No rules were found"),
60
+ ],
61
+ ids=repr,
62
+ )
63
+ def it_survives_pickling(grammar, pos, reason):
64
+ err = GrammarParseError(grammar, pos, reason)
65
+ restored = pickle.loads(pickle.dumps(err))
66
+ assert type(restored) is GrammarParseError
67
+ assert str(restored) == str(err)
68
+ assert restored.message == err.message
69
+ assert restored.grammar == err.grammar
70
+ assert restored.pos == err.pos
71
+ assert restored.reason == err.reason
72
+
73
+ @pytest.mark.parametrize("protocol", range(pickle.HIGHEST_PROTOCOL + 1))
74
+ def it_survives_pickling_with_every_protocol(protocol):
75
+ err = GrammarParseError("aa\nbb\ncc", 3, "reason")
76
+ restored = pickle.loads(pickle.dumps(err, protocol=protocol))
77
+ assert type(restored) is GrammarParseError
78
+ assert str(restored) == str(err)
v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/errors/test_input_parse_error.py ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+
3
+ import pytest
4
+
5
+ from gbnf.utils.errors.gbnf_error import GBNFError
6
+ from gbnf.utils.errors.input_parse_error import (
7
+ INPUT_PARSER_ERROR_HEADER_MESSAGE,
8
+ InputParseError,
9
+ )
10
+
11
+
12
+ def describe_input_parse_error():
13
+ def it_renders_a_message():
14
+ input_ = "some input"
15
+ pos = 1
16
+ err = InputParseError(input_, pos)
17
+ assert err.message == "\n".join([
18
+ INPUT_PARSER_ERROR_HEADER_MESSAGE,
19
+ "",
20
+ input_,
21
+ " ^",
22
+ ])
23
+
24
+ def it_renders_a_message_for_code_point():
25
+ pos = 0
26
+ err = InputParseError("a", pos)
27
+ assert err.message == "\n".join([
28
+ INPUT_PARSER_ERROR_HEADER_MESSAGE,
29
+ "",
30
+ "a",
31
+ "^",
32
+ ])
33
+
34
+ def it_renders_a_message_for_code_points():
35
+ pos = 2
36
+ err = InputParseError("abcd", pos)
37
+ assert err.message == "\n".join([
38
+ INPUT_PARSER_ERROR_HEADER_MESSAGE,
39
+ "",
40
+ "abcd",
41
+ " ^",
42
+ ])
43
+
44
+ def it_renders_the_same_message_for_input_given_as_code_points():
45
+ expected = InputParseError("abcd", 2).message
46
+ assert InputParseError([97, 98, 99, 100], 2).message == expected
47
+ assert InputParseError(ord("a"), 0).message == InputParseError("a", 0).message
48
+
49
+ def it_uses_the_message_as_its_string_form():
50
+ err = InputParseError("abcd", 2)
51
+ assert str(err) == err.message
52
+
53
+ def it_has_a_header_message():
54
+ assert INPUT_PARSER_ERROR_HEADER_MESSAGE == "Failed to parse input string:"
55
+
56
+ def it_is_a_named_gbnf_error():
57
+ err = InputParseError("abcd", 2)
58
+ assert err.name == "InputParseError"
59
+ assert isinstance(err, GBNFError)
60
+ assert isinstance(err, Exception)
61
+
62
+ def it_exposes_the_inputs_and_the_position():
63
+ err = InputParseError("cd", 1, "ab")
64
+ assert err.most_recent_input == "cd"
65
+ assert err.pos == 1
66
+ assert err.previous_input == "ab"
67
+ assert InputParseError("cd", 1).previous_input == ""
68
+
69
+ def describe_previous_input():
70
+ def it_renders_the_previous_input_in_front_of_the_most_recent_input():
71
+ err = InputParseError("cd", 1, "ab")
72
+ # the position is relative to the most recent input, so the caret is shifted by the previous input
73
+ assert err.message == "\n".join([
74
+ INPUT_PARSER_ERROR_HEADER_MESSAGE,
75
+ "",
76
+ "abcd",
77
+ " ^",
78
+ ])
79
+
80
+ def it_accepts_the_previous_input_as_code_points():
81
+ err = InputParseError([99, 100], 1, [97, 98])
82
+ assert err.message == InputParseError("cd", 1, "ab").message
83
+
84
+ def describe_src():
85
+ def it_is_the_most_recent_input_when_there_is_no_previous_input():
86
+ assert InputParseError("some input", 1).src == "some input"
87
+
88
+ def it_is_the_previous_input_followed_by_the_most_recent_input():
89
+ assert InputParseError("cd", 1, "ab").src == "abcd"
90
+
91
+ def it_converts_code_points_to_a_string():
92
+ assert InputParseError([99, 100], 1, [97, 98]).src == "abcd"
93
+ assert InputParseError(ord("a"), 0).src == "a"
94
+
95
+ def describe_error_for_most_recent_input():
96
+ def it_renders_a_message_for_only_the_most_recent_input():
97
+ err = InputParseError("cd", 1, "ab")
98
+ assert err.error_for_most_recent_input == "\n".join([
99
+ INPUT_PARSER_ERROR_HEADER_MESSAGE,
100
+ "",
101
+ "cd",
102
+ " ^",
103
+ ])
104
+
105
+ def it_matches_the_message_when_there_is_no_previous_input():
106
+ err = InputParseError("abcd", 2)
107
+ assert err.error_for_most_recent_input == err.message
108
+
109
+ def it_renders_code_points():
110
+ err = InputParseError([99, 100], 1, [97, 98])
111
+ assert err.error_for_most_recent_input == InputParseError("cd", 1).message
112
+
113
+ def it_answers_to_its_original_camel_case_name_too():
114
+ err = InputParseError("cd", 1, "ab")
115
+ assert err.errorForMostRecentInput == err.error_for_most_recent_input
116
+
117
+ @pytest.mark.parametrize(
118
+ ("most_recent_input", "pos", "previous_input"),
119
+ [
120
+ ("cd", 1, "ab"),
121
+ ("some input", 1, ""),
122
+ ([99, 100], 0, [97, 98]),
123
+ (0x1F600, 0, [97]),
124
+ ],
125
+ ids=repr,
126
+ )
127
+ def it_survives_pickling(most_recent_input, pos, previous_input):
128
+ err = InputParseError(most_recent_input, pos, previous_input)
129
+ restored = pickle.loads(pickle.dumps(err))
130
+ assert type(restored) is InputParseError
131
+ assert str(restored) == str(err)
132
+ assert restored.message == err.message
133
+ assert restored.most_recent_input == err.most_recent_input
134
+ assert restored.pos == err.pos
135
+ assert restored.previous_input == err.previous_input
136
+ assert restored.src == err.src
137
+ assert restored.error_for_most_recent_input == err.error_for_most_recent_input
138
+
139
+ @pytest.mark.parametrize("protocol", range(pickle.HIGHEST_PROTOCOL + 1))
140
+ def it_survives_pickling_with_every_protocol(protocol):
141
+ err = InputParseError("cd", 1, "ab")
142
+ restored = pickle.loads(pickle.dumps(err, protocol=protocol))
143
+ assert type(restored) is InputParseError
144
+ assert str(restored) == str(err)
v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/test_attr_dict.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ import pytest
4
+
5
+ from gbnf.utils.attr_dict import AttrDict
6
+
7
+
8
+ def describe_attr_dict():
9
+ def it_reads_keys_as_attributes():
10
+ rule = AttrDict(type="char", value=[97])
11
+ assert rule.type == "char"
12
+ assert rule.value == [97]
13
+ assert rule["type"] == "char"
14
+
15
+ def it_raises_attribute_error_for_missing_keys():
16
+ with pytest.raises(AttributeError):
17
+ AttrDict().missing
18
+ assert not hasattr(AttrDict(), "missing")
19
+
20
+ def it_compares_like_a_plain_dict():
21
+ assert AttrDict(type="end") == {"type": "end"}
22
+ assert {"type": "end"} == AttrDict(type="end")
23
+
24
+ def it_serializes_like_a_plain_dict():
25
+ assert json.dumps(AttrDict(type="char", value=[97])) == '{"type": "char", "value": [97]}'
26
+
27
+ def it_keeps_dict_methods():
28
+ rule = AttrDict(type="char", value=[97])
29
+ assert list(rule.keys()) == ["type", "value"]
30
+ assert rule.get("nope") is None
v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/test_camel_case.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ from gbnf.utils.camel_case import CamelCaseAliases, install_module_aliases, to_snake_case
4
+
5
+
6
+ def describe_to_snake_case():
7
+ @pytest.mark.parametrize(
8
+ ("name", "expected"),
9
+ [
10
+ ("isRuleChar", "is_rule_char"),
11
+ ("getInputAsCodePoints", "get_input_as_code_points"),
12
+ ("errorForMostRecentInput", "error_for_most_recent_input"),
13
+ ("isGraphPointerRuleCharExclude", "is_graph_pointer_rule_char_exclude"),
14
+ ("symbolIds", "symbol_ids"),
15
+ ("already_snake", "already_snake"),
16
+ ("GBNF", "gbnf"),
17
+ ("KEY_TRANSLATION", "key_translation"),
18
+ ],
19
+ )
20
+ def it_converts_camel_case(name, expected):
21
+ assert to_snake_case(name) == expected
22
+
23
+
24
+ def describe_camel_case_aliases():
25
+ class Thing(CamelCaseAliases):
26
+ def __init__(self):
27
+ self.some_value = 1
28
+
29
+ def do_something(self):
30
+ return "done"
31
+
32
+ @property
33
+ def another_property(self):
34
+ return 2
35
+
36
+ def it_resolves_attributes():
37
+ assert Thing().someValue == 1
38
+
39
+ def it_resolves_methods_and_properties():
40
+ assert Thing().doSomething() == "done"
41
+ assert Thing().anotherProperty == 2
42
+
43
+ def it_still_raises_for_unknown_attributes():
44
+ with pytest.raises(AttributeError):
45
+ Thing().unknownThing
46
+ with pytest.raises(AttributeError):
47
+ Thing().unknown_thing
48
+
49
+ def it_leaves_hasattr_working():
50
+ assert hasattr(Thing(), "someValue")
51
+ assert not hasattr(Thing(), "nothingHere")
52
+
53
+
54
+ def describe_install_module_aliases():
55
+ def it_resolves_camel_case_names_in_every_module_of_the_package():
56
+ from gbnf.grammar_graph import type_guards
57
+ from gbnf.grammar_graph.type_guards import isRuleChar
58
+ from gbnf.utils.errors.build_error_position import buildErrorPosition
59
+
60
+ assert isRuleChar({"type": "char", "value": []})
61
+ assert buildErrorPosition("", 0) == ["No input provided"]
62
+ assert type_guards.isRange([1, 2])
63
+
64
+ def it_keeps_raising_for_names_that_do_not_exist():
65
+ from gbnf.grammar_graph import type_guards
66
+
67
+ with pytest.raises(AttributeError):
68
+ type_guards.isNothing
69
+
70
+ def it_ignores_other_packages(monkeypatch):
71
+ install_module_aliases("a_package_that_is_not_loaded")
v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/test_is_point_in_range.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ from gbnf.grammar_graph.types import Range
4
+ from gbnf.utils.is_point_in_range import is_point_in_range
5
+
6
+
7
+ def describe_is_point_in_range():
8
+ @pytest.mark.parametrize(
9
+ ("point", "expectation", "range_"),
10
+ [
11
+ (96, False, [97, 122]),
12
+ (97, True, [97, 122]),
13
+ (98, True, [97, 122]),
14
+ (122, True, [97, 122]),
15
+ (123, False, [97, 122]),
16
+ ],
17
+ ids=str,
18
+ )
19
+ def it_checks_if_point_is_in_range(point, expectation, range_):
20
+ assert is_point_in_range(point, range_) == expectation
21
+
22
+ @pytest.mark.parametrize("range_", [(97, 122), Range([97, 122])], ids=["tuple", "Range"])
23
+ def it_accepts_any_two_element_sequence_as_the_range(range_):
24
+ assert is_point_in_range(96, range_) is False
25
+ assert is_point_in_range(97, range_) is True
26
+ assert is_point_in_range(122, range_) is True
27
+ assert is_point_in_range(123, range_) is False
28
+
29
+ def it_treats_a_single_point_range_as_inclusive_on_both_ends():
30
+ assert is_point_in_range(5, [5, 5]) is True
31
+ assert is_point_in_range(4, [5, 5]) is False
32
+ assert is_point_in_range(6, [5, 5]) is False
v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/test_js_compat.py ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import math
2
+
3
+ import pytest
4
+
5
+ from gbnf.utils.js_compat import (
6
+ JS_WHITESPACE,
7
+ Size,
8
+ char_at,
9
+ from_char_code,
10
+ get_field,
11
+ is_js_whitespace,
12
+ json_stringify,
13
+ parse_int_hex,
14
+ )
15
+
16
+
17
+ def describe_char_at():
18
+ def it_returns_the_character_at_a_position():
19
+ assert char_at("abc", 1) == "b"
20
+
21
+ @pytest.mark.parametrize("pos", [-1, 3, 100])
22
+ def it_returns_an_empty_string_out_of_range(pos):
23
+ assert char_at("abc", pos) == ""
24
+ assert not char_at("abc", pos)
25
+
26
+
27
+ def describe_is_js_whitespace():
28
+ @pytest.mark.parametrize("char", list(JS_WHITESPACE))
29
+ def it_accepts_the_whitespace_javascript_does(char):
30
+ assert is_js_whitespace(char)
31
+
32
+ @pytest.mark.parametrize("char", ["", "a", "0", "-", "\x85", "\x1c", "​"])
33
+ def it_rejects_everything_else(char):
34
+ assert not is_js_whitespace(char)
35
+
36
+
37
+ def describe_parse_int_hex():
38
+ @pytest.mark.parametrize(
39
+ ("text", "expected"),
40
+ [
41
+ ("2A", 42),
42
+ ("2a", 42),
43
+ ("006F", 111),
44
+ ("0001F4A9", 128169),
45
+ ("7F", 127),
46
+ ("2G", 2), # the longest valid prefix
47
+ ("2\"", 2),
48
+ (" 1", 1), # leading whitespace is skipped
49
+ (" 1", 1),
50
+ ("+1", 1),
51
+ ("-1", -1),
52
+ ("0x1", 1), # a 0x prefix is allowed
53
+ ("0X1F", 31),
54
+ ],
55
+ )
56
+ def it_parses_the_longest_hex_prefix(text, expected):
57
+ assert parse_int_hex(text) == expected
58
+
59
+ @pytest.mark.parametrize("text", ["", "ZZ", "g1", "0x", "-", " ", "x1"])
60
+ def it_returns_nan_without_digits(text):
61
+ assert math.isnan(parse_int_hex(text))
62
+
63
+
64
+ def describe_from_char_code():
65
+ def it_converts_code_points():
66
+ assert from_char_code(97) == "a"
67
+ assert from_char_code(0x1F4A9) == "\U0001F4A9"
68
+
69
+ def it_wraps_out_of_range_values_like_javascript():
70
+ assert from_char_code(0x10000 + 97) == chr(0x10000 + 97)
71
+ assert from_char_code(0x110000 + 97) == "a"
72
+ assert from_char_code(-1) == "￿"
73
+
74
+ def it_maps_nan_to_nul():
75
+ assert from_char_code(math.nan) == "\x00"
76
+ assert from_char_code(math.inf) == "\x00"
77
+
78
+
79
+ def describe_json_stringify():
80
+ def it_uses_compact_separators():
81
+ assert json_stringify({"type": "char", "value": [[97, 122], 65]}) == '{"type":"char","value":[[97,122],65]}'
82
+
83
+ def it_keeps_non_ascii_characters():
84
+ assert json_stringify(["é", "漫"]) == '["é","漫"]'
85
+
86
+ def it_serializes_the_public_attributes_of_objects():
87
+ class Thing:
88
+ def __init__(self):
89
+ self.visible = 1
90
+ self.hidden = None
91
+ self._private = 2
92
+ self.func = lambda: None
93
+
94
+ assert json_stringify(Thing()) == '{"visible":1}'
95
+
96
+ def it_rejects_what_has_no_json_form():
97
+ with pytest.raises(TypeError):
98
+ json_stringify({1, 2})
99
+
100
+
101
+ def describe_get_field():
102
+ def it_reads_mappings_and_attributes():
103
+ class Thing:
104
+ value = 2
105
+
106
+ assert get_field({"value": 1}, "value") == 1
107
+ assert get_field(Thing(), "value") == 2
108
+
109
+ def it_tries_the_names_in_order():
110
+ assert get_field({"stack_id": 1}, "stackId", "stack_id") == 1
111
+ assert get_field({"stackId": 2, "stack_id": 1}, "stackId", "stack_id") == 2
112
+
113
+ def it_returns_the_default_when_nothing_is_found():
114
+ assert get_field({}, "a", "b") is None
115
+ assert get_field({}, "a", default=3) == 3
116
+
117
+ def it_can_skip_values_of_an_unexpected_type():
118
+ class Auto:
119
+ def __getattr__(self, name):
120
+ return object()
121
+
122
+ assert get_field(Auto(), "a", expect=int) is None
123
+
124
+
125
+ def describe_size():
126
+ def it_is_an_int():
127
+ assert Size(3) == 3
128
+ assert isinstance(Size(3), int)
129
+
130
+ def it_can_also_be_called():
131
+ assert Size(3)() == 3
132
+
133
+
134
+ def describe_json_stringify_like_javascript():
135
+ def it_writes_non_finite_numbers_as_null():
136
+ assert json_stringify({"value": [math.nan, 1, math.inf, -math.inf]}) == '{"value":[null,1,null,null]}'
137
+ assert json_stringify(math.nan) == "null"
138
+
139
+ def it_keeps_numeric_values_that_can_be_called():
140
+ # `Size` is an int that is callable, which must not make it look like a function
141
+ class Holder:
142
+ def __init__(self):
143
+ self.value = Size(1)
144
+
145
+ assert json_stringify(Holder()) == '{"value":1}'
v2-models-effort/runs/20261116-123314-shrill-sea/ported_implementation/tests/unit/utils/test_pair.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from gbnf.utils.pair import Pair
2
+
3
+
4
+ def describe_pair():
5
+ def it_is_a_tuple():
6
+ pair = Pair((1, 2))
7
+ assert isinstance(pair, tuple)
8
+ assert pair == (1, 2)
9
+ a, b = pair
10
+ assert (a, b) == (1, 2)
11
+
12
+ def it_equals_the_same_pair_as_a_list():
13
+ pair = Pair(("root", 0))
14
+ assert pair == ["root", 0]
15
+ assert ["root", 0] == pair
16
+ assert [pair] == [["root", 0]]
17
+ assert [["root", 0]] == [pair]
18
+
19
+ def it_does_not_equal_a_different_pair():
20
+ pair = Pair((1, 2))
21
+ assert pair != [1, 3]
22
+ assert pair != (2, 1)
23
+ assert not pair == [1, 2, 3]
24
+ assert pair != "12"
25
+
26
+ def it_hashes_like_a_tuple():
27
+ assert hash(Pair((1, 2))) == hash((1, 2))
28
+ assert {Pair((1, 2)): "x"}[(1, 2)] == "x"
v2-models-effort/runs/20261116-123314-shrill-sea/proxy.log ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ NOTICE Nov 16 17:46:20.861 [7]: Initializing tinyproxy ...
2
+ NOTICE Nov 16 17:46:20.861 [7]: Reloading config file (/etc/tinyproxy/tinyproxy.conf)
3
+ INFO Nov 16 17:46:20.861 [7]: Added address [127.0.0.1] to listen addresses.
4
+ INFO Nov 16 17:46:20.861 [7]: Adding Port [443] to the list allowed by CONNECT
5
+ NOTICE Nov 16 17:46:20.861 [7]: Reloading config file finished
6
+ INFO Nov 16 17:46:20.861 [7]: listen_sock called with addr = '127.0.0.1'
7
+ INFO Nov 16 17:46:20.861 [7]: trying to listen on host[127.0.0.1], family[2], socktype[1], proto[6]
8
+ INFO Nov 16 17:46:20.861 [7]: listening on fd [3]
9
+ INFO Nov 16 17:46:20.861 [7]: Not running as root, so not changing UID/GID.
10
+ INFO Nov 16 17:46:20.861 [7]: Setting the various signals.
11
+ INFO Nov 16 17:46:20.861 [7]: Starting main loop. Accepting connections.
12
+ botbox-proxy: listening
13
+ CONNECT Nov 16 17:46:25.315 [7]: Connect (file descriptor 4): 127.0.0.1
14
+ CONNECT Nov 16 17:46:25.316 [7]: Request (file descriptor 4): CONNECT api.anthropic.com:443 HTTP/1.1
15
+ NOTICE Nov 16 17:46:25.316 [7]: Proxying refused on filtered url "api.anthropic.com:443"
16
+ CONNECT Nov 16 18:34:57.602 [7]: Connect (file descriptor 4): 127.0.0.1
17
+ CONNECT Nov 16 18:34:57.603 [7]: Request (file descriptor 4): CONNECT registry.npmjs.org:443 HTTP/1.1
18
+ NOTICE Nov 16 18:34:57.604 [7]: Proxying refused on filtered url "registry.npmjs.org:443"
19
+ CONNECT Nov 16 19:45:08.076 [7]: Connect (file descriptor 4): 127.0.0.1
20
+ CONNECT Nov 16 19:45:08.076 [7]: Request (file descriptor 4): CONNECT releases.astral.sh:443 HTTP/1.1
21
+ NOTICE Nov 16 19:45:08.077 [7]: Proxying refused on filtered url "releases.astral.sh:443"
22
+ CONNECT Nov 16 19:45:08.081 [7]: Connect (file descriptor 4): 127.0.0.1
23
+ CONNECT Nov 16 19:45:08.081 [7]: Request (file descriptor 4): CONNECT github.com:443 HTTP/1.1
24
+ NOTICE Nov 16 19:45:08.081 [7]: Proxying refused on filtered url "github.com:443"
25
+ CONNECT Nov 16 19:45:09.567 [7]: Connect (file descriptor 4): 127.0.0.1
26
+ CONNECT Nov 16 19:45:09.567 [7]: Request (file descriptor 4): CONNECT releases.astral.sh:443 HTTP/1.1
27
+ NOTICE Nov 16 19:45:09.567 [7]: Proxying refused on filtered url "releases.astral.sh:443"
28
+ CONNECT Nov 16 19:45:09.569 [7]: Connect (file descriptor 4): 127.0.0.1
29
+ CONNECT Nov 16 19:45:09.582 [7]: Request (file descriptor 4): CONNECT github.com:443 HTTP/1.1
30
+ NOTICE Nov 16 19:45:09.582 [7]: Proxying refused on filtered url "github.com:443"
31
+ CONNECT Nov 16 19:45:12.962 [7]: Connect (file descriptor 4): 127.0.0.1
32
+ CONNECT Nov 16 19:45:12.962 [7]: Request (file descriptor 4): CONNECT releases.astral.sh:443 HTTP/1.1
33
+ NOTICE Nov 16 19:45:12.962 [7]: Proxying refused on filtered url "releases.astral.sh:443"
34
+ CONNECT Nov 16 19:45:12.969 [7]: Connect (file descriptor 4): 127.0.0.1
35
+ CONNECT Nov 16 19:45:12.969 [7]: Request (file descriptor 4): CONNECT github.com:443 HTTP/1.1
36
+ NOTICE Nov 16 19:45:12.969 [7]: Proxying refused on filtered url "github.com:443"
37
+ CONNECT Nov 16 19:45:17.038 [7]: Connect (file descriptor 4): 127.0.0.1
38
+ CONNECT Nov 16 19:45:17.038 [7]: Request (file descriptor 4): CONNECT releases.astral.sh:443 HTTP/1.1
39
+ NOTICE Nov 16 19:45:17.038 [7]: Proxying refused on filtered url "releases.astral.sh:443"
40
+ CONNECT Nov 16 19:45:17.040 [7]: Connect (file descriptor 4): 127.0.0.1
41
+ CONNECT Nov 16 19:45:17.040 [7]: Request (file descriptor 4): CONNECT github.com:443 HTTP/1.1
42
+ NOTICE Nov 16 19:45:17.040 [7]: Proxying refused on filtered url "github.com:443"
v2-models-effort/runs/20261116-123314-shrill-sea/result.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"duration_api_ms":7509718,"stop_reason":"end_turn","session_id":"e1098157-528d-4b45-b968-fd5fca4ac1e8","total_cost_usd":28.048367099999997,"usage":{"input_tokens":294,"cache_creation_input_tokens":567697,"cache_read_input_tokens":56991304,"output_tokens":374094,"output_tokens_details":{"thinking_tokens":251000},"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":567697,"ephemeral_5m_input_tokens":0},"inference_geo":"global","iterations":[],"speed":"standard","fallback_credit":null},"modelUsage":{"claude-sonnet-5-5":{"inputTokens":874,"outputTokens":948375,"cacheReadInputTokens":117952786,"cacheCreationInputTokens":2372424,"webSearchRequests":0,"costUSD":28.048367099999997,"contextWindow":1000000,"maxOutputTokens":128000,"thinkingTokens":584122,"canonicalModel":"claude-sonnet-5-5","provider":"firstParty","costBasis":"list"}},"permission_denials":[],"terminal_reason":"completed","fast_mode_state":"off","fast_mode_disabled_reason":"sdk_opt_in_required","subagent_stats":{"spawned":3,"requested":{"background":0,"foreground":0,"unset":3},"started_in_background":3,"max_depth":1,"spawned_by_subagents":0,"completed":3,"failed":0,"killed":{"parent":0,"user":0,"system":0},"refused":{"depth_limit":0,"concurrency_limit":0,"budget":0},"by_type":{"general-purpose":3}},"safety_stops":0,"is_error":false,"num_turns":183,"subtype":"success","api_error_status":null,"result":"The Python port is complete in `/target`. It matches the JS reference on every check I could run, apart from the deliberate differences below.\n\n**What's there**\n- **The package:** `/target/gbnf` mirrors the TS module tree in snake_case, using the same file and directory names. `GBNF(\"…\")` returns an immutable `ParseState` that you iterate for the next rules, call or `.add()` to advance, and it raises `GrammarParseError` or `InputParseError` with the same messages and positions as the original.\n- **Tests:** `/target/tests` has 1,454 pytest tests, all passing, also under `-W error -X dev`.\n - 773 integration tests, with the same count as JS and data extracted by running the TS tables.\n - Unit tests ported in pytest-describe style, plus some for the Python-specific helpers.\n\n**How I verified it**\n- **JS oracle:** I ran the real JS code through vitest and compared it with the port on about 12,000 cases:\n - every grammar and input from the TS integration tests;\n - hand-written edge cases;\n - branching states and numeric inputs;\n - fuzzed and mutated grammars.\n\n Per-step rules, error messages, error positions, debug `Graph.print` output, and the intermediate rule structures were identical. Earlier fuzz rounds, about 27,000 cases, also matched.\n- **Independent review:** a separate reviewer read both sources line by line and found three real issues, now fixed:\n - Two threads adding to the same state could corrupt each other's results (606 wrong out of 6,000 before, 0 now).\n - Deeply nested groups hit Python's recursion limit about 4× sooner than JS. They now parse to 5,000 levels.\n - A callable count leaked into rule ids, and `meta` key casing and NaN rendering differed from JS in debug JSON.\n\n**Deliberate differences from JS (documented in the README)**\n- Strings are code points, not UTF-16 units, so emoji in grammars and input are one unit.\n- `root ::= a*` with `a` undefined, and a grammar with no `root` rule, raise a proper `GrammarParseError`. JS crashes with an unrelated `TypeError` or `Error` there.\n- Rules that recurse without consuming input raise `RecursionError`, where JS overflows its stack.\n\n**Unverified or guessed**\n- I couldn't see the hidden tests, so naming and layout are a best guess:\n - snake_case with camelCase aliases;\n - rules as `dict` subclasses that also compare equal to plain dicts;\n - a `src/gbnf` symlink alongside the flat `gbnf/` package.\n- Only Python 3.14 was available, so 3.11–3.13 compatibility is untested, and I couldn't test building a wheel offline (no setuptools).","ttft_ms":1264,"type":"result","duration_ms":8961448,"uuid":"5dedeecd-0a31-4549-bcd2-38975a40e080","ttft_stream_ms":1149,"time_to_request_ms":93,"first_content_frame_ms":1150,"queued_turn_count":0,"result_index":0}
v2-models-effort/runs/20261116-123314-shrill-sea/run.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "params": {
3
+ "source-language": "javascript",
4
+ "model": "claude-sonnet-5-5",
5
+ "effort": "max"
6
+ },
7
+ "command": "uv run --project packages/gbnf_experiment run_gbnf_experiment --include-unit-tests 1 --include-source-integration-tests 1 --include-target-integration-tests 0 --output /home/duncan/work/code/research/ports/experiments/v2-models-effort/runs/20261116-123314-shrill-sea --source-language javascript --model claude-sonnet-5-5 --effort max --auth subscription --memory 24g",
8
+ "created": "2026-11-16T17:45:33Z",
9
+ "ended": "2026-11-16T20:16:00Z",
10
+ "exit_code": 0,
11
+ "error": null,
12
+ "ended_by": null,
13
+ "signal": null,
14
+ "git": {
15
+ "commit": "de0adfc3cc14248bd942ba8357f62da0a4da3250",
16
+ "dirty": true
17
+ },
18
+ "labnotes_version": "0.2.39.dev307",
19
+ "labnotes_command": "labnotes experiments v2-models-effort run --concurrency 1 -- --auth subscription --memory 24g",
20
+ "args": [
21
+ "--auth",
22
+ "subscription",
23
+ "--memory",
24
+ "24g"
25
+ ],
26
+ "pid": 133417,
27
+ "pid_created": 1794851133.52
28
+ }
v2-models-effort/runs/20261116-123314-shrill-sea/run.lock ADDED
File without changes
v2-models-effort/runs/20261116-123314-shrill-sea/stderr.log ADDED
File without changes
v2-models-effort/runs/20261116-123314-shrill-sea/stderr.txt ADDED
File without changes
v2-models-effort/runs/20261116-123314-shrill-sea/stdout.log ADDED
@@ -0,0 +1 @@
 
 
1
+ *** auth: subscription ***
v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/e1098157-528d-4b45-b968-fd5fca4ac1e8.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/e1098157-528d-4b45-b968-fd5fca4ac1e8/subagents/agent-a3644837b6c44547e.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/e1098157-528d-4b45-b968-fd5fca4ac1e8/subagents/agent-a3644837b6c44547e.meta.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"agentType":"general-purpose","description":"Line-by-line TS vs Python review","toolUseId":"toolu_01W4QcvcCmFfppKp588hWYZy","spawnDepth":1,"requestShape":"background","requestNonInteractive":true}
v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/e1098157-528d-4b45-b968-fd5fca4ac1e8/subagents/agent-a7965f7d736f23a9a.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/e1098157-528d-4b45-b968-fd5fca4ac1e8/subagents/agent-a7965f7d736f23a9a.meta.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"agentType":"general-purpose","description":"Port rules_builder and utils unit tests","toolUseId":"toolu_01WqVZoG6aExK16aSZAuwD3T","spawnDepth":1,"requestShape":"background","requestNonInteractive":true}
v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/e1098157-528d-4b45-b968-fd5fca4ac1e8/subagents/agent-abd2f9d0af86b2b0c.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/e1098157-528d-4b45-b968-fd5fca4ac1e8/subagents/agent-abd2f9d0af86b2b0c.meta.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"agentType":"general-purpose","description":"Port grammar_graph unit tests","toolUseId":"toolu_01B1Nc5sujqSANHtnjKvcBhN","spawnDepth":1,"requestShape":"background","requestNonInteractive":true}
v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/memory/MEMORY.md ADDED
@@ -0,0 +1 @@
 
 
1
+ - [GBNF Python port](gbnf-python-port.md) — layout, hedges for hidden tests, verification method, intentional deviations from the JS original
v2-models-effort/runs/20261116-123314-shrill-sea/transcript/.claude/projects/-target/memory/gbnf-python-port.md ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: gbnf-python-port
3
+ description: "The GBNF JS->Python port at /target — layout, design choices, how it was verified, intentional deviations"
4
+ metadata:
5
+ node_type: memory
6
+ type: project
7
+ originSessionId: e1098157-528d-4b45-b968-fd5fca4ac1e8
8
+ modified: 2026-11-16T19:30:33.722Z
9
+ ---
10
+
11
+ Task (Nov 2026): port `/input/javascript` (npm `gbnf`, a GBNF grammar parser; vitest unit tests colocated + generated integration tests) to Python at `/target`. Hidden tests are presumably Python translations of those suites (pytest + pytest-describe are installed in the sandbox), so the port mirrors the TS module tree in snake_case under `/target/gbnf/` (flat layout; `/target/src/gbnf` is a symlink for src-layout harnesses; `conftest.py` + `pyproject.toml` put the root on sys.path).
12
+
13
+ **Why:** the hidden test layout/API names are unknown, so the port hedges: rules are `dict` subclasses with attribute access (tests compare to `{type: 'char', value: [...]}` literals), `RuleType` is a `StrEnum`, ranges/pairs compare equal as list or tuple (`Range`, `Pair`), JS camelCase names resolve to snake_case (module/class `__getattr__` in `gbnf/utils/camel_case.py`), print/option functions accept a dict or kwargs, `size` works as property and call.
14
+
15
+ **How to apply:** when touching the port keep these properties. Verified by (a) ~1,450 pytest tests under `/target/tests` (773 integration tests extracted from the TS tables + ported unit tests, pytest-describe style) and (b) differential fuzzing against the real JS code run through vitest (~30k random/mutated grammars, per-step rules, error messages/positions, `Graph.print`, RulesBuilder internals identical). The harness lived in `/tmp/diff` + `/tmp/jsref` (ephemeral; rebuild by copying `/input/javascript` to a scratch dir, aliasing `gbnf` to `src/index.ts` in a vitest config, and driving it with a JSON case file).
16
+
17
+ Intentional deviations from JS (documented in README): code points instead of UTF-16 units (astral chars); `root ::= a*` with undefined `a` -> GrammarParseError (JS: TypeError on a sparse array); missing `root` -> GrammarParseError (JS: unreachable branch, throws SymbolIds error); runaway recursion -> RecursionError at pointer depth 10,000 (JS: RangeError ~2,100 levels); `resolve`/`fetch_next`/`fetch_nodes_for_root_node` are iterative and the grammar parser is a generator trampoline (Python recursion limit); `Graph.parse` never writes to shared pointers (an independent review found the JS-style `valid` flag races across threads: it tracks rejected pointer ids locally); pointer ids are built lazily with cached checkpoints (O(depth) strings otherwise blow memory quadratically); `Size` (callable int) must never leak into data (rule ids are `int(...)`).
v2-models-effort/runs/20261116-123314-spring-meadow/credentials.log ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [2026-11-16 13:45:18.146][30][warning][main] [source/server/server.cc:1012] There is no configured limit to the number of allowed active downstream connections. Configure a limit in `envoy.resource_monitors.global_downstream_max_connections` resource monitor.
2
+ [2026-11-16T13:45:21.536Z] POST /v1/messages?beta=true 200 - 2928ms
3
+ [2026-11-16T13:45:24.792Z] POST /v1/messages?beta=true 200 - 2543ms
4
+ [2026-11-16T13:45:27.393Z] POST /v1/messages?beta=true 200 - 2646ms
5
+ [2026-11-16T13:45:30.205Z] POST /v1/messages?beta=true 200 - 5878ms
6
+ [2026-11-16T13:45:36.164Z] POST /v1/messages?beta=true 200 - 13224ms
7
+ [2026-11-16T13:45:49.454Z] POST /v1/messages?beta=true 200 - 2464ms
8
+ [2026-11-16T13:45:52.105Z] POST /v1/messages?beta=true 200 - 2938ms
9
+ [2026-11-16T13:45:55.266Z] POST /v1/messages?beta=true 200 - 8536ms
10
+ [2026-11-16T13:46:03.853Z] POST /v1/messages?beta=true 200 - 7274ms
11
+ [2026-11-16T13:46:11.166Z] POST /v1/messages?beta=true 200 - 2208ms
12
+ [2026-11-16T13:46:13.506Z] POST /v1/messages?beta=true 200 - 2001ms
13
+ [2026-11-16T13:46:15.556Z] POST /v1/messages?beta=true 200 - 19058ms
14
+ [2026-11-16T13:46:35.052Z] POST /v1/messages?beta=true 200 - 2082ms
15
+ [2026-11-16T13:46:39.637Z] POST /v1/messages?beta=true 200 - 80529ms
16
+ [2026-11-16T13:48:00.554Z] POST /v1/messages?beta=true 200 - 5683ms
17
+ [2026-11-16T13:48:06.458Z] POST /v1/messages?beta=true 200 - 308090ms
18
+ [2026-11-16T13:53:15.046Z] POST /v1/messages?beta=true 200 - 3267ms
19
+ [2026-11-16T13:53:22.428Z] POST /v1/messages?beta=true 200 - 5502ms
20
+ [2026-11-16T13:53:28.454Z] POST /v1/messages?beta=true 200 - 304679ms
21
+ [2026-11-16T13:58:33.933Z] POST /v1/messages?beta=true 200 - 20816ms
22
+ [2026-11-16T13:58:57.216Z] POST /v1/messages?beta=true 200 - 325600ms
23
+ [2026-11-16T14:04:23.215Z] POST /v1/messages?beta=true 200 - 2514ms
24
+ [2026-11-16T14:04:25.828Z] POST /v1/messages?beta=true 200 - 6698ms
25
+ [2026-11-16T14:04:32.776Z] POST /v1/messages?beta=true 200 - 10102ms
26
+ [2026-11-16T14:04:43.019Z] POST /v1/messages?beta=true 200 - 6690ms
27
+ [2026-11-16T14:04:50.818Z] POST /v1/messages?beta=true 200 - 134557ms
28
+ [2026-11-16T14:07:06.886Z] POST /v1/messages?beta=true 200 - 17776ms
29
+ [2026-11-16T14:07:25.197Z] POST /v1/messages?beta=true 200 - 21724ms
30
+ [2026-11-16T14:07:47.147Z] POST /v1/messages?beta=true 200 - 8331ms
31
+ [2026-11-16T14:07:55.894Z] POST /v1/messages?beta=true 200 - 10267ms
32
+ [2026-11-16T14:08:06.534Z] POST /v1/messages?beta=true 200 - 8763ms
33
+ [2026-11-16T14:08:15.471Z] POST /v1/messages?beta=true 200 - 23518ms
34
+ [2026-11-16T14:08:39.302Z] POST /v1/messages?beta=true 200 - 5954ms
35
+ [2026-11-16T14:08:45.827Z] POST /v1/messages?beta=true 200 - 8103ms
36
+ [2026-11-16T14:08:54.064Z] POST /v1/messages?beta=true 200 - 47049ms
37
+ [2026-11-16T14:09:41.993Z] POST /v1/messages?beta=true 200 - 15108ms
38
+ [2026-11-16T14:09:57.756Z] POST /v1/messages?beta=true 200 - 50513ms
39
+ [2026-11-16T14:10:49.001Z] POST /v1/messages?beta=true 200 - 13660ms
40
+ [2026-11-16T14:11:03.577Z] POST /v1/messages?beta=true 200 - 27878ms
41
+ [2026-11-16T14:11:31.761Z] POST /v1/messages?beta=true 200 - 17880ms
42
+ [2026-11-16T14:11:49.947Z] POST /v1/messages?beta=true 200 - 14761ms
43
+ [2026-11-16T14:12:07.514Z] POST /v1/messages?beta=true 200 - 12837ms
44
+ [2026-11-16T14:12:21.033Z] POST /v1/messages?beta=true 200 - 2842ms
45
+ [2026-11-16T14:12:24.109Z] POST /v1/messages?beta=true 200 - 26067ms
46
+ [2026-11-16T14:12:50.540Z] POST /v1/messages?beta=true 200 - 40345ms
47
+ [2026-11-16T14:13:31.361Z] POST /v1/messages?beta=true 200 - 5575ms
48
+ [2026-11-16T14:13:41.656Z] POST /v1/messages?beta=true 200 - 52001ms
49
+ [2026-11-16T14:14:34.722Z] POST /v1/messages?beta=true 200 - 20564ms
50
+ [2026-11-16T14:14:56.714Z] POST /v1/messages?beta=true 200 - 22999ms
51
+ [2026-11-16T14:15:22.373Z] POST /v1/messages?beta=true 200 - 32806ms
52
+ [2026-11-16T14:15:56.554Z] POST /v1/messages?beta=true 200 - 1755ms
53
+ [2026-11-16T14:15:59.200Z] POST /v1/messages?beta=true 200 - 5779ms
54
+ [2026-11-16T14:16:09.411Z] POST /v1/messages?beta=true 200 - 37799ms
55
+ [2026-11-16T14:16:50.392Z] POST /v1/messages?beta=true 200 - 61064ms
56
+ [2026-11-16T14:18:29.258Z] POST /v1/messages?beta=true 200 - 3129ms
57
+ [2026-11-16T14:19:05.650Z] POST /v1/messages?beta=true 200 - 66228ms
58
+ [2026-11-16T14:20:19.616Z] POST /v1/messages?beta=true 200 - 4118ms
59
+ [2026-11-16T14:20:30.236Z] POST /v1/messages?beta=true 200 - 17596ms
60
+ [2026-11-16T14:20:48.412Z] POST /v1/messages?beta=true 200 - 6264ms
61
+ [2026-11-16T14:21:02.787Z] POST /v1/messages?beta=true 200 - 65356ms
62
+ [2026-11-16T14:22:09.219Z] POST /v1/messages?beta=true 200 - 35233ms
63
+ [2026-11-16T14:22:51.407Z] POST /v1/messages?beta=true 200 - 19591ms
64
+ [2026-11-16T14:23:11.702Z] POST /v1/messages?beta=true 200 - 37986ms
65
+ [2026-11-16T14:24:52.191Z] POST /v1/messages?beta=true 200 - 17841ms
66
+ [2026-11-16T14:25:55.193Z] POST /v1/messages?beta=true 200 - 6160ms
67
+ [2026-11-16T14:27:34.859Z] POST /v1/messages?beta=true 200 - 8038ms
68
+ [2026-11-16T14:28:24.699Z] POST /v1/messages?beta=true 200 - 8154ms
69
+ [2026-11-16T14:29:19.632Z] POST /v1/messages?beta=true 200 - 4869ms
70
+ [2026-11-16T14:29:24.674Z] POST /v1/messages?beta=true 200 - 20417ms
71
+ [2026-11-16T14:29:49.617Z] POST /v1/messages?beta=true 200 - 13364ms
72
+ [2026-11-16T14:30:03.434Z] POST /v1/messages?beta=true 200 - 29978ms
73
+ [2026-11-16T14:30:33.780Z] POST /v1/messages?beta=true 200 - 8118ms
74
+ [2026-11-16T14:30:46.066Z] POST /v1/messages?beta=true 200 - 3793ms
75
+ [2026-11-16T14:31:50.591Z] POST /v1/messages?beta=true 200 - 4036ms
76
+ [2026-11-16T14:31:54.811Z] POST /v1/messages?beta=true 200 - 14215ms
77
+ [2026-11-16T14:32:09.199Z] POST /v1/messages?beta=true 200 - 7677ms
78
+ [2026-11-16T14:32:17.558Z] POST /v1/messages?beta=true 200 - 42792ms
79
+ [2026-11-16T14:33:04.901Z] POST /v1/messages?beta=true 200 - 9363ms
80
+ [2026-11-16T14:33:15.360Z] POST /v1/messages?beta=true 200 - 4390ms
81
+ [2026-11-16T14:33:20.916Z] POST /v1/messages?beta=true 200 - 7482ms
82
+ [2026-11-16T14:33:44.401Z] POST /v1/messages?beta=true 200 - 32442ms
83
+ [2026-11-16T14:34:17.747Z] POST /v1/messages?beta=true 200 - 2773ms
84
+ [2026-11-16T14:34:51.133Z] POST /v1/messages?beta=true 200 - 16636ms
85
+ [2026-11-16T14:36:09.978Z] POST /v1/messages?beta=true 200 - 5097ms
86
+ [2026-11-16T14:36:16.515Z] POST /v1/messages?beta=true 200 - 7857ms
87
+ [2026-11-16T14:36:26.810Z] POST /v1/messages?beta=true 200 - 11402ms
88
+ [2026-11-16T14:36:49.455Z] POST /v1/messages?beta=true 200 - 30189ms
89
+ [2026-11-16T14:37:20.134Z] POST /v1/messages?beta=true 200 - 26269ms
90
+ [2026-11-16T14:37:46.933Z] POST /v1/messages?beta=true 200 - 3848ms
91
+ [2026-11-16T14:37:51.007Z] POST /v1/messages?beta=true 200 - 7558ms
92
+ [2026-11-16T14:39:57.659Z] POST /v1/messages?beta=true 200 - 4474ms
93
+ [2026-11-16T14:40:02.573Z] POST /v1/messages?beta=true 200 - 20628ms
94
+ [2026-11-16T14:40:28.365Z] POST /v1/messages?beta=true 200 - 12117ms
95
+ [2026-11-16 14:40:43.521][30][warning][main] [source/server/server.cc:981] caught ENVOY_SIGTERM
v2-models-effort/runs/20261116-123314-spring-meadow/git-diff.patch ADDED
The diff for this file is too large to render. See raw diff
 
v2-models-effort/runs/20261116-123314-spring-meadow/git-sha.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ de0adfc3cc14248bd942ba8357f62da0a4da3250
v2-models-effort/runs/20261116-123314-spring-meadow/manifest.json ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "timestamp": "2026-11-16T13:44:32Z",
3
+ "completed_at": "2026-11-16T14:40:47Z",
4
+ "exit_code": 0,
5
+ "oom_killed": false,
6
+ "condition": {
7
+ "name": "source-javascript_unit-tests_source-integration-tests_effort-max_model-claude-opus-5-5",
8
+ "source_language": "javascript",
9
+ "target_language": "python",
10
+ "include_unit_tests": true,
11
+ "include_source_integration_tests": true,
12
+ "include_target_integration_tests": false,
13
+ "effort": "max",
14
+ "model": "claude-opus-5-5"
15
+ },
16
+ "derivation": {
17
+ "gbnf_commit": "13f1aca495d11e160fffd68c4ba299a2415909d8"
18
+ },
19
+ "reference_implementation": {
20
+ "included": [
21
+ "javascript/.eslintrc.cjs",
22
+ "javascript/.gitignore",
23
+ "javascript/.npmignore",
24
+ "javascript/README.md",
25
+ "javascript/integration-tests/.gitignore",
26
+ "javascript/integration-tests/generated/iteration/grammars.test.ts",
27
+ "javascript/integration-tests/generated/iteration/iteration-with-additional-strings.test.ts",
28
+ "javascript/integration-tests/generated/iteration/iteration-with-an-initial-string.test.ts",
29
+ "javascript/integration-tests/generated/iteration/iteration.test.ts",
30
+ "javascript/integration-tests/generated/validation/validate-grammar.test.ts",
31
+ "javascript/integration-tests/generated/validation/validate-input.test.ts",
32
+ "javascript/package.json",
33
+ "javascript/src/gbnf.test.ts",
34
+ "javascript/src/gbnf.ts",
35
+ "javascript/src/grammar-graph/colorize.test.ts",
36
+ "javascript/src/grammar-graph/colorize.ts",
37
+ "javascript/src/grammar-graph/generic-set.test.ts",
38
+ "javascript/src/grammar-graph/generic-set.ts",
39
+ "javascript/src/grammar-graph/get-input-as-code-points.test.ts",
40
+ "javascript/src/grammar-graph/get-input-as-code-points.ts",
41
+ "javascript/src/grammar-graph/get-parent-stack-id.test.ts",
42
+ "javascript/src/grammar-graph/get-parent-stack-id.ts",
43
+ "javascript/src/grammar-graph/get-serialized-rule-key.test.ts",
44
+ "javascript/src/grammar-graph/get-serialized-rule-key.ts",
45
+ "javascript/src/grammar-graph/graph-node.test.ts",
46
+ "javascript/src/grammar-graph/graph-node.ts",
47
+ "javascript/src/grammar-graph/graph-pointer.test.ts",
48
+ "javascript/src/grammar-graph/graph-pointer.ts",
49
+ "javascript/src/grammar-graph/graph.test.ts",
50
+ "javascript/src/grammar-graph/graph.ts",
51
+ "javascript/src/grammar-graph/index.ts",
52
+ "javascript/src/grammar-graph/parse-state.test.ts",
53
+ "javascript/src/grammar-graph/parse-state.ts",
54
+ "javascript/src/grammar-graph/print.test.ts",
55
+ "javascript/src/grammar-graph/print.ts",
56
+ "javascript/src/grammar-graph/rule-ref.test.ts",
57
+ "javascript/src/grammar-graph/rule-ref.ts",
58
+ "javascript/src/grammar-graph/type-guards.test.ts",
59
+ "javascript/src/grammar-graph/type-guards.ts",
60
+ "javascript/src/grammar-graph/types.ts",
61
+ "javascript/src/grammar-parser/build-rule-stack.test.ts",
62
+ "javascript/src/grammar-parser/build-rule-stack.ts",
63
+ "javascript/src/index.ts",
64
+ "javascript/src/rules-builder/index.ts",
65
+ "javascript/src/rules-builder/is-word-char.test.ts",
66
+ "javascript/src/rules-builder/is-word-char.ts",
67
+ "javascript/src/rules-builder/parse-char.test.ts",
68
+ "javascript/src/rules-builder/parse-char.ts",
69
+ "javascript/src/rules-builder/parse-name.test.ts",
70
+ "javascript/src/rules-builder/parse-name.ts",
71
+ "javascript/src/rules-builder/parse-space.test.ts",
72
+ "javascript/src/rules-builder/parse-space.ts",
73
+ "javascript/src/rules-builder/rules-builder.test.ts",
74
+ "javascript/src/rules-builder/rules-builder.ts",
75
+ "javascript/src/rules-builder/symbol-ids.ts",
76
+ "javascript/src/rules-builder/type-guards.ts",
77
+ "javascript/src/rules-builder/types.ts",
78
+ "javascript/src/umd.ts",
79
+ "javascript/src/utils/errors/build-error-position.test.ts",
80
+ "javascript/src/utils/errors/build-error-position.ts",
81
+ "javascript/src/utils/errors/get-input-as-string.test.ts",
82
+ "javascript/src/utils/errors/get-input-as-string.ts",
83
+ "javascript/src/utils/errors/grammar-parse-error.test.ts",
84
+ "javascript/src/utils/errors/grammar-parse-error.ts",
85
+ "javascript/src/utils/errors/input-parse-error.test.ts",
86
+ "javascript/src/utils/errors/input-parse-error.ts",
87
+ "javascript/src/utils/is-point-in-range.test.ts",
88
+ "javascript/src/utils/is-point-in-range.ts",
89
+ "javascript/tsconfig.json",
90
+ "javascript/tsconfig.test.json",
91
+ "javascript/vite.config.esm.ts",
92
+ "javascript/vite.config.ts",
93
+ "javascript/vite.config.umd.ts",
94
+ "javascript/vitest.config.integration.ts",
95
+ "javascript/vitest.config.unit.ts"
96
+ ]
97
+ },
98
+ "sandbox": {
99
+ "image_id": "sha256:451c337f0a125af9f046e197fa1e0dd695956bf3bd4326245fa7a9e31c4a30d9"
100
+ },
101
+ "harness": {
102
+ "commit": "de0adfc3cc14248bd942ba8357f62da0a4da3250",
103
+ "dirty": true
104
+ }
105
+ }
v2-models-effort/runs/20261116-123314-spring-meadow/memory.jsonl ADDED
@@ -0,0 +1,669 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"time": 1794836672.1236882, "rss": 25665536, "processes": 3}
2
+ {"time": 1794836677.1428654, "rss": 110563328, "processes": 5}
3
+ {"time": 1794836682.1636815, "rss": 107839488, "processes": 5}
4
+ {"time": 1794836687.1814969, "rss": 103460864, "processes": 5}
5
+ {"time": 1794836692.1994603, "rss": 77463552, "processes": 5}
6
+ {"time": 1794836697.217914, "rss": 77524992, "processes": 5}
7
+ {"time": 1794836702.2388504, "rss": 76083200, "processes": 5}
8
+ {"time": 1794836707.261579, "rss": 75931648, "processes": 5}
9
+ {"time": 1794836712.287333, "rss": 75563008, "processes": 5}
10
+ {"time": 1794836717.311882, "rss": 68956160, "processes": 4}
11
+ {"time": 1794836722.3456295, "rss": 309628928, "processes": 6}
12
+ {"time": 1794836727.3725553, "rss": 267137024, "processes": 6}
13
+ {"time": 1794836732.395038, "rss": 281542656, "processes": 6}
14
+ {"time": 1794836737.4144773, "rss": 278429696, "processes": 6}
15
+ {"time": 1794836742.431026, "rss": 270798848, "processes": 6}
16
+ {"time": 1794836747.5628722, "rss": 230862848, "processes": 6}
17
+ {"time": 1794836752.588352, "rss": 250998784, "processes": 6}
18
+ {"time": 1794836757.6235044, "rss": 249765888, "processes": 6}
19
+ {"time": 1794836762.6488996, "rss": 247025664, "processes": 6}
20
+ {"time": 1794836768.2096763, "rss": 247963648, "processes": 6}
21
+ {"time": 1794836773.2555187, "rss": 250138624, "processes": 6}
22
+ {"time": 1794836778.271579, "rss": 255651840, "processes": 6}
23
+ {"time": 1794836783.2956696, "rss": 235085824, "processes": 6}
24
+ {"time": 1794836788.3169005, "rss": 225505280, "processes": 6}
25
+ {"time": 1794836793.364626, "rss": 225656832, "processes": 6}
26
+ {"time": 1794836798.4033616, "rss": 274198528, "processes": 6}
27
+ {"time": 1794836803.4269366, "rss": 229679104, "processes": 6}
28
+ {"time": 1794836808.6320002, "rss": 223301632, "processes": 6}
29
+ {"time": 1794836813.6640635, "rss": 218296320, "processes": 6}
30
+ {"time": 1794836818.6887307, "rss": 212168704, "processes": 6}
31
+ {"time": 1794836823.7125533, "rss": 211787776, "processes": 6}
32
+ {"time": 1794836828.8539546, "rss": 212946944, "processes": 6}
33
+ {"time": 1794836833.882217, "rss": 209489920, "processes": 6}
34
+ {"time": 1794836838.9530017, "rss": 211320832, "processes": 6}
35
+ {"time": 1794836843.9939742, "rss": 210612224, "processes": 6}
36
+ {"time": 1794836849.0151176, "rss": 211730432, "processes": 6}
37
+ {"time": 1794836854.0322592, "rss": 208723968, "processes": 6}
38
+ {"time": 1794836859.049806, "rss": 212385792, "processes": 6}
39
+ {"time": 1794836864.0732598, "rss": 211267584, "processes": 6}
40
+ {"time": 1794836869.0934186, "rss": 213385216, "processes": 6}
41
+ {"time": 1794836874.1095302, "rss": 213749760, "processes": 6}
42
+ {"time": 1794836879.1267645, "rss": 222101504, "processes": 6}
43
+ {"time": 1794836884.1501422, "rss": 224878592, "processes": 6}
44
+ {"time": 1794836889.174707, "rss": 237785088, "processes": 6}
45
+ {"time": 1794836894.196863, "rss": 216686592, "processes": 6}
46
+ {"time": 1794836899.2234461, "rss": 220680192, "processes": 6}
47
+ {"time": 1794836904.244319, "rss": 220925952, "processes": 6}
48
+ {"time": 1794836909.2920399, "rss": 218476544, "processes": 6}
49
+ {"time": 1794836914.3186545, "rss": 215195648, "processes": 6}
50
+ {"time": 1794836919.3791637, "rss": 211697664, "processes": 6}
51
+ {"time": 1794836924.4001343, "rss": 210563072, "processes": 6}
52
+ {"time": 1794836929.642438, "rss": 211697664, "processes": 6}
53
+ {"time": 1794836934.730569, "rss": 214151168, "processes": 6}
54
+ {"time": 1794836939.7496567, "rss": 212430848, "processes": 6}
55
+ {"time": 1794836944.777763, "rss": 212492288, "processes": 6}
56
+ {"time": 1794836949.7974749, "rss": 211558400, "processes": 6}
57
+ {"time": 1794836954.8234603, "rss": 213147648, "processes": 6}
58
+ {"time": 1794836959.8513112, "rss": 211296256, "processes": 6}
59
+ {"time": 1794836964.8664114, "rss": 210825216, "processes": 6}
60
+ {"time": 1794836969.912767, "rss": 211062784, "processes": 6}
61
+ {"time": 1794836974.9347348, "rss": 210509824, "processes": 6}
62
+ {"time": 1794836979.9623437, "rss": 210681856, "processes": 6}
63
+ {"time": 1794836985.1255116, "rss": 210169856, "processes": 6}
64
+ {"time": 1794836990.1465588, "rss": 211251200, "processes": 6}
65
+ {"time": 1794836995.1797664, "rss": 213639168, "processes": 6}
66
+ {"time": 1794837000.2035127, "rss": 212836352, "processes": 6}
67
+ {"time": 1794837005.219882, "rss": 212443136, "processes": 6}
68
+ {"time": 1794837010.2978404, "rss": 210808832, "processes": 6}
69
+ {"time": 1794837015.3215342, "rss": 215113728, "processes": 6}
70
+ {"time": 1794837020.3417819, "rss": 214466560, "processes": 6}
71
+ {"time": 1794837025.4119358, "rss": 210440192, "processes": 6}
72
+ {"time": 1794837030.4306026, "rss": 208424960, "processes": 6}
73
+ {"time": 1794837035.4519315, "rss": 209952768, "processes": 6}
74
+ {"time": 1794837040.472385, "rss": 210604032, "processes": 6}
75
+ {"time": 1794837045.4982908, "rss": 209055744, "processes": 6}
76
+ {"time": 1794837050.5568714, "rss": 207716352, "processes": 6}
77
+ {"time": 1794837055.5806692, "rss": 208244736, "processes": 6}
78
+ {"time": 1794837060.6403394, "rss": 207536128, "processes": 6}
79
+ {"time": 1794837065.663128, "rss": 206864384, "processes": 6}
80
+ {"time": 1794837070.7732003, "rss": 207298560, "processes": 6}
81
+ {"time": 1794837075.8086069, "rss": 208580608, "processes": 6}
82
+ {"time": 1794837080.8267255, "rss": 205799424, "processes": 6}
83
+ {"time": 1794837085.8799577, "rss": 205680640, "processes": 6}
84
+ {"time": 1794837090.9753277, "rss": 206868480, "processes": 6}
85
+ {"time": 1794837096.006148, "rss": 208015360, "processes": 6}
86
+ {"time": 1794837101.0227253, "rss": 205828096, "processes": 6}
87
+ {"time": 1794837106.0547001, "rss": 207376384, "processes": 6}
88
+ {"time": 1794837111.0818696, "rss": 209457152, "processes": 6}
89
+ {"time": 1794837116.1580982, "rss": 210268160, "processes": 6}
90
+ {"time": 1794837121.2007442, "rss": 208863232, "processes": 6}
91
+ {"time": 1794837126.2275746, "rss": 211996672, "processes": 6}
92
+ {"time": 1794837131.2550764, "rss": 211259392, "processes": 6}
93
+ {"time": 1794837136.282561, "rss": 210120704, "processes": 6}
94
+ {"time": 1794837141.3060265, "rss": 210313216, "processes": 6}
95
+ {"time": 1794837146.34549, "rss": 209272832, "processes": 6}
96
+ {"time": 1794837151.3749382, "rss": 209252352, "processes": 6}
97
+ {"time": 1794837156.544213, "rss": 209920000, "processes": 6}
98
+ {"time": 1794837161.660685, "rss": 209653760, "processes": 6}
99
+ {"time": 1794837166.685111, "rss": 208433152, "processes": 6}
100
+ {"time": 1794837172.0897188, "rss": 206987264, "processes": 6}
101
+ {"time": 1794837177.1234064, "rss": 206577664, "processes": 6}
102
+ {"time": 1794837182.1676393, "rss": 210714624, "processes": 6}
103
+ {"time": 1794837187.1911128, "rss": 212180992, "processes": 6}
104
+ {"time": 1794837192.224169, "rss": 207650816, "processes": 6}
105
+ {"time": 1794837197.259139, "rss": 221556736, "processes": 6}
106
+ {"time": 1794837202.3371317, "rss": 242937856, "processes": 6}
107
+ {"time": 1794837207.3556793, "rss": 229412864, "processes": 6}
108
+ {"time": 1794837212.3834436, "rss": 232202240, "processes": 6}
109
+ {"time": 1794837217.400389, "rss": 223072256, "processes": 6}
110
+ {"time": 1794837222.4148183, "rss": 217812992, "processes": 6}
111
+ {"time": 1794837227.434188, "rss": 216092672, "processes": 6}
112
+ {"time": 1794837232.4676833, "rss": 219205632, "processes": 6}
113
+ {"time": 1794837237.5334187, "rss": 218357760, "processes": 6}
114
+ {"time": 1794837242.5538976, "rss": 218767360, "processes": 6}
115
+ {"time": 1794837247.573343, "rss": 218755072, "processes": 6}
116
+ {"time": 1794837252.5891283, "rss": 218558464, "processes": 6}
117
+ {"time": 1794837257.6064687, "rss": 218796032, "processes": 6}
118
+ {"time": 1794837262.6306398, "rss": 215887872, "processes": 6}
119
+ {"time": 1794837267.6575193, "rss": 216997888, "processes": 6}
120
+ {"time": 1794837272.7013035, "rss": 216055808, "processes": 6}
121
+ {"time": 1794837277.7301712, "rss": 218152960, "processes": 6}
122
+ {"time": 1794837282.7499464, "rss": 216670208, "processes": 6}
123
+ {"time": 1794837287.7694988, "rss": 217071616, "processes": 6}
124
+ {"time": 1794837292.7891324, "rss": 216088576, "processes": 6}
125
+ {"time": 1794837297.9022927, "rss": 214962176, "processes": 6}
126
+ {"time": 1794837302.9582496, "rss": 217055232, "processes": 6}
127
+ {"time": 1794837307.9792593, "rss": 215105536, "processes": 6}
128
+ {"time": 1794837312.9974241, "rss": 213700608, "processes": 6}
129
+ {"time": 1794837318.0235605, "rss": 212635648, "processes": 6}
130
+ {"time": 1794837323.0442464, "rss": 213188608, "processes": 6}
131
+ {"time": 1794837328.0640922, "rss": 214102016, "processes": 6}
132
+ {"time": 1794837333.0806992, "rss": 214474752, "processes": 6}
133
+ {"time": 1794837338.1041114, "rss": 213594112, "processes": 6}
134
+ {"time": 1794837343.1219068, "rss": 213999616, "processes": 6}
135
+ {"time": 1794837348.221455, "rss": 215425024, "processes": 6}
136
+ {"time": 1794837353.2426538, "rss": 215863296, "processes": 6}
137
+ {"time": 1794837358.2677898, "rss": 217313280, "processes": 6}
138
+ {"time": 1794837363.2840195, "rss": 215605248, "processes": 6}
139
+ {"time": 1794837368.3059018, "rss": 214732800, "processes": 6}
140
+ {"time": 1794837373.3266063, "rss": 217141248, "processes": 6}
141
+ {"time": 1794837378.346037, "rss": 213880832, "processes": 6}
142
+ {"time": 1794837383.4029593, "rss": 216739840, "processes": 6}
143
+ {"time": 1794837388.5958557, "rss": 217133056, "processes": 6}
144
+ {"time": 1794837393.7224312, "rss": 217710592, "processes": 6}
145
+ {"time": 1794837398.7857206, "rss": 214151168, "processes": 6}
146
+ {"time": 1794837403.8041441, "rss": 211615744, "processes": 6}
147
+ {"time": 1794837408.8203804, "rss": 211210240, "processes": 6}
148
+ {"time": 1794837413.84674, "rss": 211902464, "processes": 6}
149
+ {"time": 1794837418.87348, "rss": 210874368, "processes": 6}
150
+ {"time": 1794837423.9457927, "rss": 211787776, "processes": 6}
151
+ {"time": 1794837428.9705377, "rss": 211140608, "processes": 6}
152
+ {"time": 1794837433.995657, "rss": 211632128, "processes": 6}
153
+ {"time": 1794837439.023498, "rss": 210726912, "processes": 6}
154
+ {"time": 1794837444.0475893, "rss": 209637376, "processes": 6}
155
+ {"time": 1794837449.0742512, "rss": 211013632, "processes": 6}
156
+ {"time": 1794837454.08938, "rss": 209977344, "processes": 6}
157
+ {"time": 1794837459.1141717, "rss": 210092032, "processes": 6}
158
+ {"time": 1794837464.140968, "rss": 210432000, "processes": 6}
159
+ {"time": 1794837469.2850232, "rss": 212385792, "processes": 6}
160
+ {"time": 1794837474.3112025, "rss": 212889600, "processes": 6}
161
+ {"time": 1794837479.5361874, "rss": 215293952, "processes": 6}
162
+ {"time": 1794837484.6123857, "rss": 213491712, "processes": 6}
163
+ {"time": 1794837489.6333027, "rss": 213536768, "processes": 6}
164
+ {"time": 1794837494.9393337, "rss": 213581824, "processes": 6}
165
+ {"time": 1794837500.0495784, "rss": 210657280, "processes": 6}
166
+ {"time": 1794837505.1637049, "rss": 210743296, "processes": 6}
167
+ {"time": 1794837510.3395412, "rss": 214577152, "processes": 6}
168
+ {"time": 1794837515.3857377, "rss": 243867648, "processes": 6}
169
+ {"time": 1794837520.4114907, "rss": 223662080, "processes": 6}
170
+ {"time": 1794837525.5142252, "rss": 218267648, "processes": 6}
171
+ {"time": 1794837530.5385427, "rss": 214618112, "processes": 6}
172
+ {"time": 1794837535.5656843, "rss": 342818816, "processes": 6}
173
+ {"time": 1794837540.5905318, "rss": 225337344, "processes": 6}
174
+ {"time": 1794837545.6095233, "rss": 221216768, "processes": 6}
175
+ {"time": 1794837550.7796216, "rss": 216002560, "processes": 6}
176
+ {"time": 1794837555.8129487, "rss": 215728128, "processes": 6}
177
+ {"time": 1794837560.8296127, "rss": 215265280, "processes": 6}
178
+ {"time": 1794837565.8514075, "rss": 214081536, "processes": 6}
179
+ {"time": 1794837570.8673975, "rss": 213557248, "processes": 6}
180
+ {"time": 1794837575.923282, "rss": 215445504, "processes": 6}
181
+ {"time": 1794837580.9635892, "rss": 213413888, "processes": 6}
182
+ {"time": 1794837585.9776075, "rss": 214536192, "processes": 6}
183
+ {"time": 1794837591.0494425, "rss": 217427968, "processes": 6}
184
+ {"time": 1794837596.0689287, "rss": 217255936, "processes": 6}
185
+ {"time": 1794837601.0933702, "rss": 216764416, "processes": 6}
186
+ {"time": 1794837606.1150901, "rss": 217423872, "processes": 6}
187
+ {"time": 1794837611.142073, "rss": 215515136, "processes": 6}
188
+ {"time": 1794837616.2505956, "rss": 216420352, "processes": 6}
189
+ {"time": 1794837621.2726889, "rss": 215154688, "processes": 6}
190
+ {"time": 1794837626.3021543, "rss": 215863296, "processes": 6}
191
+ {"time": 1794837631.3200164, "rss": 214323200, "processes": 6}
192
+ {"time": 1794837636.3445506, "rss": 216973312, "processes": 6}
193
+ {"time": 1794837641.3701766, "rss": 213880832, "processes": 6}
194
+ {"time": 1794837646.4327602, "rss": 213508096, "processes": 6}
195
+ {"time": 1794837651.5001156, "rss": 214233088, "processes": 6}
196
+ {"time": 1794837656.5240288, "rss": 214876160, "processes": 6}
197
+ {"time": 1794837661.5731502, "rss": 216104960, "processes": 6}
198
+ {"time": 1794837666.848916, "rss": 218263552, "processes": 6}
199
+ {"time": 1794837671.8725746, "rss": 216502272, "processes": 6}
200
+ {"time": 1794837676.8902915, "rss": 214040576, "processes": 6}
201
+ {"time": 1794837681.910572, "rss": 216252416, "processes": 6}
202
+ {"time": 1794837686.9267268, "rss": 214667264, "processes": 6}
203
+ {"time": 1794837691.944419, "rss": 213622784, "processes": 6}
204
+ {"time": 1794837696.968432, "rss": 215711744, "processes": 6}
205
+ {"time": 1794837701.994294, "rss": 212860928, "processes": 6}
206
+ {"time": 1794837707.0189338, "rss": 214515712, "processes": 6}
207
+ {"time": 1794837712.0989814, "rss": 216031232, "processes": 6}
208
+ {"time": 1794837717.1770823, "rss": 216530944, "processes": 6}
209
+ {"time": 1794837722.199319, "rss": 215691264, "processes": 6}
210
+ {"time": 1794837727.2411005, "rss": 219799552, "processes": 6}
211
+ {"time": 1794837732.2799895, "rss": 216748032, "processes": 6}
212
+ {"time": 1794837737.3049803, "rss": 215134208, "processes": 6}
213
+ {"time": 1794837742.325752, "rss": 215248896, "processes": 6}
214
+ {"time": 1794837747.342333, "rss": 215355392, "processes": 6}
215
+ {"time": 1794837752.3630583, "rss": 214188032, "processes": 6}
216
+ {"time": 1794837757.9380534, "rss": 215367680, "processes": 6}
217
+ {"time": 1794837762.9630659, "rss": 214396928, "processes": 6}
218
+ {"time": 1794837767.990742, "rss": 213176320, "processes": 6}
219
+ {"time": 1794837773.0158343, "rss": 213991424, "processes": 6}
220
+ {"time": 1794837778.0350215, "rss": 214953984, "processes": 6}
221
+ {"time": 1794837783.0506127, "rss": 214724608, "processes": 6}
222
+ {"time": 1794837788.1592371, "rss": 213929984, "processes": 6}
223
+ {"time": 1794837793.1801367, "rss": 213549056, "processes": 6}
224
+ {"time": 1794837798.271588, "rss": 213749760, "processes": 6}
225
+ {"time": 1794837803.3053427, "rss": 213790720, "processes": 6}
226
+ {"time": 1794837808.3323445, "rss": 213245952, "processes": 6}
227
+ {"time": 1794837813.3498583, "rss": 213082112, "processes": 6}
228
+ {"time": 1794837818.37644, "rss": 215310336, "processes": 6}
229
+ {"time": 1794837823.3936856, "rss": 212824064, "processes": 6}
230
+ {"time": 1794837828.4132233, "rss": 213766144, "processes": 6}
231
+ {"time": 1794837833.4348497, "rss": 215977984, "processes": 6}
232
+ {"time": 1794837838.5520627, "rss": 215801856, "processes": 6}
233
+ {"time": 1794837843.5924256, "rss": 215318528, "processes": 6}
234
+ {"time": 1794837848.6102579, "rss": 214368256, "processes": 6}
235
+ {"time": 1794837853.630956, "rss": 213516288, "processes": 6}
236
+ {"time": 1794837858.6678157, "rss": 212742144, "processes": 6}
237
+ {"time": 1794837863.684782, "rss": 247410688, "processes": 6}
238
+ {"time": 1794837868.7128649, "rss": 245039104, "processes": 6}
239
+ {"time": 1794837873.7534282, "rss": 253890560, "processes": 6}
240
+ {"time": 1794837878.852577, "rss": 223510528, "processes": 6}
241
+ {"time": 1794837883.8721375, "rss": 224878592, "processes": 6}
242
+ {"time": 1794837889.092032, "rss": 224292864, "processes": 6}
243
+ {"time": 1794837894.1130974, "rss": 233807872, "processes": 6}
244
+ {"time": 1794837899.2362711, "rss": 232120320, "processes": 6}
245
+ {"time": 1794837904.269685, "rss": 225898496, "processes": 6}
246
+ {"time": 1794837909.2903924, "rss": 222380032, "processes": 6}
247
+ {"time": 1794837914.312219, "rss": 221884416, "processes": 6}
248
+ {"time": 1794837919.335594, "rss": 220356608, "processes": 6}
249
+ {"time": 1794837924.3529572, "rss": 219246592, "processes": 6}
250
+ {"time": 1794837929.3691695, "rss": 218750976, "processes": 6}
251
+ {"time": 1794837934.3927326, "rss": 220229632, "processes": 6}
252
+ {"time": 1794837939.5061994, "rss": 219938816, "processes": 6}
253
+ {"time": 1794837944.5476558, "rss": 219566080, "processes": 6}
254
+ {"time": 1794837949.5647254, "rss": 221011968, "processes": 6}
255
+ {"time": 1794837954.586134, "rss": 223707136, "processes": 6}
256
+ {"time": 1794837959.6097817, "rss": 218550272, "processes": 6}
257
+ {"time": 1794837964.7583807, "rss": 218095616, "processes": 6}
258
+ {"time": 1794837969.8024428, "rss": 215277568, "processes": 6}
259
+ {"time": 1794837974.8279102, "rss": 217526272, "processes": 6}
260
+ {"time": 1794837979.8437898, "rss": 220422144, "processes": 6}
261
+ {"time": 1794837984.8703566, "rss": 213721088, "processes": 6}
262
+ {"time": 1794837989.9015217, "rss": 215109632, "processes": 6}
263
+ {"time": 1794837994.9247115, "rss": 213065728, "processes": 6}
264
+ {"time": 1794837999.9446404, "rss": 215629824, "processes": 6}
265
+ {"time": 1794838004.9705133, "rss": 214147072, "processes": 6}
266
+ {"time": 1794838010.034499, "rss": 213590016, "processes": 6}
267
+ {"time": 1794838015.0539675, "rss": 214224896, "processes": 6}
268
+ {"time": 1794838020.0803158, "rss": 219025408, "processes": 6}
269
+ {"time": 1794838025.122371, "rss": 216137728, "processes": 6}
270
+ {"time": 1794838030.141895, "rss": 236752896, "processes": 6}
271
+ {"time": 1794838035.1690586, "rss": 225284096, "processes": 6}
272
+ {"time": 1794838040.1965337, "rss": 219353088, "processes": 6}
273
+ {"time": 1794838045.2134387, "rss": 255782912, "processes": 6}
274
+ {"time": 1794838050.2302682, "rss": 229806080, "processes": 6}
275
+ {"time": 1794838055.2538218, "rss": 220409856, "processes": 6}
276
+ {"time": 1794838060.4333239, "rss": 219648000, "processes": 6}
277
+ {"time": 1794838065.4534545, "rss": 218902528, "processes": 6}
278
+ {"time": 1794838070.8506327, "rss": 230141952, "processes": 6}
279
+ {"time": 1794838075.8810666, "rss": 255901696, "processes": 6}
280
+ {"time": 1794838080.9146295, "rss": 252841984, "processes": 6}
281
+ {"time": 1794838085.9407136, "rss": 238366720, "processes": 6}
282
+ {"time": 1794838090.9671428, "rss": 242892800, "processes": 6}
283
+ {"time": 1794838096.305456, "rss": 239898624, "processes": 6}
284
+ {"time": 1794838101.3311594, "rss": 235384832, "processes": 6}
285
+ {"time": 1794838106.3531241, "rss": 218505216, "processes": 6}
286
+ {"time": 1794838111.4437568, "rss": 218652672, "processes": 6}
287
+ {"time": 1794838116.4788897, "rss": 216453120, "processes": 6}
288
+ {"time": 1794838121.4955468, "rss": 235372544, "processes": 6}
289
+ {"time": 1794838126.5829935, "rss": 252051456, "processes": 6}
290
+ {"time": 1794838131.5997667, "rss": 237182976, "processes": 6}
291
+ {"time": 1794838136.6198533, "rss": 257298432, "processes": 6}
292
+ {"time": 1794838141.6454418, "rss": 245161984, "processes": 6}
293
+ {"time": 1794838146.6655235, "rss": 245473280, "processes": 6}
294
+ {"time": 1794838151.6969829, "rss": 225054720, "processes": 6}
295
+ {"time": 1794838156.7359538, "rss": 222023680, "processes": 6}
296
+ {"time": 1794838161.7634761, "rss": 225792000, "processes": 6}
297
+ {"time": 1794838166.7824895, "rss": 217845760, "processes": 6}
298
+ {"time": 1794838171.806673, "rss": 218685440, "processes": 6}
299
+ {"time": 1794838176.8295162, "rss": 222359552, "processes": 6}
300
+ {"time": 1794838181.8487716, "rss": 226754560, "processes": 6}
301
+ {"time": 1794838186.868829, "rss": 228499456, "processes": 6}
302
+ {"time": 1794838191.892616, "rss": 225153024, "processes": 6}
303
+ {"time": 1794838196.9091997, "rss": 240820224, "processes": 6}
304
+ {"time": 1794838202.0239942, "rss": 236093440, "processes": 6}
305
+ {"time": 1794838207.0498564, "rss": 239366144, "processes": 6}
306
+ {"time": 1794838212.1166782, "rss": 225021952, "processes": 6}
307
+ {"time": 1794838217.1363275, "rss": 226254848, "processes": 6}
308
+ {"time": 1794838222.1611085, "rss": 226107392, "processes": 6}
309
+ {"time": 1794838227.187931, "rss": 223490048, "processes": 6}
310
+ {"time": 1794838232.2106159, "rss": 224575488, "processes": 6}
311
+ {"time": 1794838237.2436564, "rss": 226463744, "processes": 6}
312
+ {"time": 1794838242.2683752, "rss": 224546816, "processes": 6}
313
+ {"time": 1794838247.5188167, "rss": 224206848, "processes": 6}
314
+ {"time": 1794838252.5370512, "rss": 234070016, "processes": 6}
315
+ {"time": 1794838257.6472516, "rss": 231440384, "processes": 6}
316
+ {"time": 1794838262.6668448, "rss": 233132032, "processes": 6}
317
+ {"time": 1794838267.759366, "rss": 222650368, "processes": 6}
318
+ {"time": 1794838272.784196, "rss": 219811840, "processes": 6}
319
+ {"time": 1794838277.8336408, "rss": 219181056, "processes": 6}
320
+ {"time": 1794838283.1644702, "rss": 219009024, "processes": 6}
321
+ {"time": 1794838288.1866846, "rss": 224346112, "processes": 6}
322
+ {"time": 1794838293.2168255, "rss": 236793856, "processes": 6}
323
+ {"time": 1794838298.327356, "rss": 229494784, "processes": 6}
324
+ {"time": 1794838303.351629, "rss": 223297536, "processes": 6}
325
+ {"time": 1794838308.3735557, "rss": 223641600, "processes": 6}
326
+ {"time": 1794838313.4877687, "rss": 242327552, "processes": 6}
327
+ {"time": 1794838318.7987263, "rss": 237715456, "processes": 6}
328
+ {"time": 1794838323.8181143, "rss": 232013824, "processes": 6}
329
+ {"time": 1794838328.8495736, "rss": 251817984, "processes": 6}
330
+ {"time": 1794838333.8784146, "rss": 238505984, "processes": 6}
331
+ {"time": 1794838338.895355, "rss": 230432768, "processes": 6}
332
+ {"time": 1794838343.9417548, "rss": 245854208, "processes": 6}
333
+ {"time": 1794838348.9690723, "rss": 252915712, "processes": 6}
334
+ {"time": 1794838353.9903874, "rss": 235732992, "processes": 6}
335
+ {"time": 1794838359.0144794, "rss": 231178240, "processes": 6}
336
+ {"time": 1794838364.4023292, "rss": 240033792, "processes": 6}
337
+ {"time": 1794838369.415712, "rss": 229908480, "processes": 6}
338
+ {"time": 1794838374.43415, "rss": 242393088, "processes": 6}
339
+ {"time": 1794838379.457671, "rss": 239697920, "processes": 6}
340
+ {"time": 1794838384.4780343, "rss": 234557440, "processes": 6}
341
+ {"time": 1794838389.497477, "rss": 230391808, "processes": 6}
342
+ {"time": 1794838394.5328238, "rss": 228270080, "processes": 6}
343
+ {"time": 1794838399.550644, "rss": 229511168, "processes": 6}
344
+ {"time": 1794838404.576764, "rss": 228392960, "processes": 6}
345
+ {"time": 1794838409.595576, "rss": 228630528, "processes": 6}
346
+ {"time": 1794838414.6208067, "rss": 245927936, "processes": 6}
347
+ {"time": 1794838419.6605172, "rss": 280158208, "processes": 6}
348
+ {"time": 1794838425.2132015, "rss": 246083584, "processes": 6}
349
+ {"time": 1794838430.2308297, "rss": 237858816, "processes": 6}
350
+ {"time": 1794838435.354353, "rss": 237965312, "processes": 6}
351
+ {"time": 1794838440.3802474, "rss": 234516480, "processes": 6}
352
+ {"time": 1794838445.3968832, "rss": 235679744, "processes": 6}
353
+ {"time": 1794838450.418593, "rss": 230125568, "processes": 6}
354
+ {"time": 1794838455.4354868, "rss": 230739968, "processes": 6}
355
+ {"time": 1794838460.4982505, "rss": 232054784, "processes": 6}
356
+ {"time": 1794838465.6037889, "rss": 227381248, "processes": 6}
357
+ {"time": 1794838470.627442, "rss": 229584896, "processes": 6}
358
+ {"time": 1794838475.6711032, "rss": 268197888, "processes": 6}
359
+ {"time": 1794838480.690957, "rss": 237858816, "processes": 6}
360
+ {"time": 1794838485.7112453, "rss": 234807296, "processes": 6}
361
+ {"time": 1794838490.7386537, "rss": 231682048, "processes": 6}
362
+ {"time": 1794838495.7558925, "rss": 277803008, "processes": 6}
363
+ {"time": 1794838500.7901945, "rss": 248668160, "processes": 6}
364
+ {"time": 1794838505.8181624, "rss": 239820800, "processes": 6}
365
+ {"time": 1794838510.916865, "rss": 235532288, "processes": 6}
366
+ {"time": 1794838515.9536932, "rss": 234967040, "processes": 6}
367
+ {"time": 1794838520.9774473, "rss": 280457216, "processes": 6}
368
+ {"time": 1794838526.004621, "rss": 248688640, "processes": 6}
369
+ {"time": 1794838531.028305, "rss": 249774080, "processes": 6}
370
+ {"time": 1794838536.119013, "rss": 240226304, "processes": 6}
371
+ {"time": 1794838541.1457, "rss": 235253760, "processes": 6}
372
+ {"time": 1794838546.2291987, "rss": 233054208, "processes": 6}
373
+ {"time": 1794838551.2638023, "rss": 234835968, "processes": 6}
374
+ {"time": 1794838556.2808158, "rss": 300253184, "processes": 6}
375
+ {"time": 1794838561.3302138, "rss": 251310080, "processes": 6}
376
+ {"time": 1794838567.083026, "rss": 285310976, "processes": 6}
377
+ {"time": 1794838572.1084225, "rss": 259186688, "processes": 6}
378
+ {"time": 1794838577.126638, "rss": 248434688, "processes": 6}
379
+ {"time": 1794838582.1464021, "rss": 238080000, "processes": 6}
380
+ {"time": 1794838587.1754484, "rss": 237948928, "processes": 6}
381
+ {"time": 1794838592.201554, "rss": 238428160, "processes": 6}
382
+ {"time": 1794838597.2250156, "rss": 241938432, "processes": 6}
383
+ {"time": 1794838602.2506533, "rss": 237375488, "processes": 6}
384
+ {"time": 1794838607.3549087, "rss": 252030976, "processes": 6}
385
+ {"time": 1794838612.3882847, "rss": 260730880, "processes": 6}
386
+ {"time": 1794838617.482527, "rss": 264642560, "processes": 6}
387
+ {"time": 1794838622.5048356, "rss": 263139328, "processes": 6}
388
+ {"time": 1794838627.5577214, "rss": 248246272, "processes": 6}
389
+ {"time": 1794838632.684745, "rss": 241201152, "processes": 6}
390
+ {"time": 1794838637.7127824, "rss": 237010944, "processes": 6}
391
+ {"time": 1794838642.770626, "rss": 236335104, "processes": 6}
392
+ {"time": 1794838647.792595, "rss": 235040768, "processes": 6}
393
+ {"time": 1794838652.8164752, "rss": 237064192, "processes": 6}
394
+ {"time": 1794838657.835645, "rss": 236916736, "processes": 6}
395
+ {"time": 1794838662.863858, "rss": 237072384, "processes": 6}
396
+ {"time": 1794838667.910319, "rss": 237498368, "processes": 6}
397
+ {"time": 1794838672.9774292, "rss": 301076480, "processes": 6}
398
+ {"time": 1794838677.998455, "rss": 322654208, "processes": 6}
399
+ {"time": 1794838683.0692768, "rss": 328843264, "processes": 6}
400
+ {"time": 1794838688.0984194, "rss": 332996608, "processes": 6}
401
+ {"time": 1794838693.121407, "rss": 344399872, "processes": 6}
402
+ {"time": 1794838698.192451, "rss": 346669056, "processes": 6}
403
+ {"time": 1794838703.2184982, "rss": 355946496, "processes": 6}
404
+ {"time": 1794838708.2432494, "rss": 281366528, "processes": 6}
405
+ {"time": 1794838713.2669191, "rss": 287260672, "processes": 6}
406
+ {"time": 1794838718.2957509, "rss": 309800960, "processes": 6}
407
+ {"time": 1794838723.3302402, "rss": 313597952, "processes": 6}
408
+ {"time": 1794838728.3583221, "rss": 318709760, "processes": 6}
409
+ {"time": 1794838733.396377, "rss": 328736768, "processes": 6}
410
+ {"time": 1794838738.4222043, "rss": 342077440, "processes": 6}
411
+ {"time": 1794838743.452834, "rss": 354267136, "processes": 6}
412
+ {"time": 1794838748.4753044, "rss": 241229824, "processes": 6}
413
+ {"time": 1794838753.6675234, "rss": 233222144, "processes": 6}
414
+ {"time": 1794838758.7165785, "rss": 231342080, "processes": 6}
415
+ {"time": 1794838763.776096, "rss": 229281792, "processes": 6}
416
+ {"time": 1794838768.7981825, "rss": 228671488, "processes": 6}
417
+ {"time": 1794838773.8223214, "rss": 231845888, "processes": 6}
418
+ {"time": 1794838778.8957949, "rss": 227557376, "processes": 6}
419
+ {"time": 1794838783.9178996, "rss": 227110912, "processes": 6}
420
+ {"time": 1794838788.9436982, "rss": 228069376, "processes": 6}
421
+ {"time": 1794838793.9695842, "rss": 228560896, "processes": 6}
422
+ {"time": 1794838798.9941478, "rss": 229650432, "processes": 6}
423
+ {"time": 1794838804.038275, "rss": 229322752, "processes": 6}
424
+ {"time": 1794838809.066931, "rss": 229126144, "processes": 6}
425
+ {"time": 1794838814.1167095, "rss": 259092480, "processes": 6}
426
+ {"time": 1794838819.1372368, "rss": 251981824, "processes": 6}
427
+ {"time": 1794838824.1630242, "rss": 274083840, "processes": 6}
428
+ {"time": 1794838829.296271, "rss": 256815104, "processes": 6}
429
+ {"time": 1794838834.3131418, "rss": 258162688, "processes": 6}
430
+ {"time": 1794838839.3363452, "rss": 237035520, "processes": 6}
431
+ {"time": 1794838844.3653176, "rss": 234614784, "processes": 6}
432
+ {"time": 1794838849.3869658, "rss": 259559424, "processes": 6}
433
+ {"time": 1794838854.4186053, "rss": 250933248, "processes": 6}
434
+ {"time": 1794838859.4407587, "rss": 273039360, "processes": 6}
435
+ {"time": 1794838864.4704108, "rss": 259289088, "processes": 6}
436
+ {"time": 1794838869.541437, "rss": 243605504, "processes": 6}
437
+ {"time": 1794838874.606115, "rss": 237293568, "processes": 6}
438
+ {"time": 1794838879.6316202, "rss": 233349120, "processes": 6}
439
+ {"time": 1794838884.6505544, "rss": 232587264, "processes": 6}
440
+ {"time": 1794838889.6906264, "rss": 233664512, "processes": 6}
441
+ {"time": 1794838894.763441, "rss": 232263680, "processes": 6}
442
+ {"time": 1794838899.7849696, "rss": 232026112, "processes": 6}
443
+ {"time": 1794838904.8065379, "rss": 231428096, "processes": 6}
444
+ {"time": 1794838909.8751125, "rss": 232235008, "processes": 6}
445
+ {"time": 1794838914.8929036, "rss": 234844160, "processes": 6}
446
+ {"time": 1794838919.9169831, "rss": 234782720, "processes": 6}
447
+ {"time": 1794838924.9471068, "rss": 236367872, "processes": 6}
448
+ {"time": 1794838929.9725945, "rss": 246599680, "processes": 6}
449
+ {"time": 1794838934.9958415, "rss": 241831936, "processes": 6}
450
+ {"time": 1794838940.0219467, "rss": 236818432, "processes": 6}
451
+ {"time": 1794838945.0525374, "rss": 236408832, "processes": 6}
452
+ {"time": 1794838950.1362038, "rss": 235900928, "processes": 6}
453
+ {"time": 1794838955.1639652, "rss": 231624704, "processes": 6}
454
+ {"time": 1794838960.1827052, "rss": 231747584, "processes": 6}
455
+ {"time": 1794838965.2103055, "rss": 260722688, "processes": 6}
456
+ {"time": 1794838970.247953, "rss": 302481408, "processes": 6}
457
+ {"time": 1794838975.2696536, "rss": 256761856, "processes": 6}
458
+ {"time": 1794838980.2917225, "rss": 257155072, "processes": 6}
459
+ {"time": 1794838985.4182782, "rss": 240451584, "processes": 6}
460
+ {"time": 1794838990.4470105, "rss": 238174208, "processes": 6}
461
+ {"time": 1794838995.4738297, "rss": 258662400, "processes": 6}
462
+ {"time": 1794839000.4915946, "rss": 249118720, "processes": 6}
463
+ {"time": 1794839005.5280747, "rss": 242995200, "processes": 6}
464
+ {"time": 1794839010.5687966, "rss": 247193600, "processes": 6}
465
+ {"time": 1794839015.6020916, "rss": 242556928, "processes": 6}
466
+ {"time": 1794839020.6213021, "rss": 235540480, "processes": 6}
467
+ {"time": 1794839025.6531332, "rss": 234258432, "processes": 6}
468
+ {"time": 1794839030.688062, "rss": 260919296, "processes": 6}
469
+ {"time": 1794839035.7168207, "rss": 294694912, "processes": 6}
470
+ {"time": 1794839040.7376404, "rss": 391303168, "processes": 6}
471
+ {"time": 1794839045.7617147, "rss": 523354112, "processes": 6}
472
+ {"time": 1794839050.79105, "rss": 540151808, "processes": 6}
473
+ {"time": 1794839055.8172138, "rss": 579104768, "processes": 6}
474
+ {"time": 1794839060.8491614, "rss": 588222464, "processes": 6}
475
+ {"time": 1794839065.868642, "rss": 590200832, "processes": 6}
476
+ {"time": 1794839070.894899, "rss": 582381568, "processes": 6}
477
+ {"time": 1794839075.92182, "rss": 589406208, "processes": 6}
478
+ {"time": 1794839081.3850434, "rss": 631660544, "processes": 6}
479
+ {"time": 1794839086.413678, "rss": 296284160, "processes": 6}
480
+ {"time": 1794839091.437686, "rss": 356081664, "processes": 6}
481
+ {"time": 1794839096.4651628, "rss": 258359296, "processes": 6}
482
+ {"time": 1794839101.4837673, "rss": 249819136, "processes": 6}
483
+ {"time": 1794839106.5085137, "rss": 243138560, "processes": 6}
484
+ {"time": 1794839111.5491133, "rss": 321101824, "processes": 6}
485
+ {"time": 1794839116.5679379, "rss": 384356352, "processes": 6}
486
+ {"time": 1794839121.588193, "rss": 725450752, "processes": 6}
487
+ {"time": 1794839126.6231177, "rss": 1070555136, "processes": 6}
488
+ {"time": 1794839131.6421633, "rss": 1085329408, "processes": 6}
489
+ {"time": 1794839136.65825, "rss": 1234034688, "processes": 6}
490
+ {"time": 1794839141.6778853, "rss": 1325993984, "processes": 6}
491
+ {"time": 1794839146.751738, "rss": 1383305216, "processes": 6}
492
+ {"time": 1794839151.7765615, "rss": 1384181760, "processes": 6}
493
+ {"time": 1794839156.814437, "rss": 251375616, "processes": 6}
494
+ {"time": 1794839161.904746, "rss": 262414336, "processes": 6}
495
+ {"time": 1794839166.9324903, "rss": 360873984, "processes": 6}
496
+ {"time": 1794839171.9605932, "rss": 637968384, "processes": 6}
497
+ {"time": 1794839177.035261, "rss": 969785344, "processes": 6}
498
+ {"time": 1794839182.1789129, "rss": 1085272064, "processes": 6}
499
+ {"time": 1794839187.2000978, "rss": 1236226048, "processes": 6}
500
+ {"time": 1794839192.3004198, "rss": 1321361408, "processes": 6}
501
+ {"time": 1794839197.3838508, "rss": 1378971648, "processes": 6}
502
+ {"time": 1794839202.440272, "rss": 1374957568, "processes": 6}
503
+ {"time": 1794839207.4711525, "rss": 447340544, "processes": 6}
504
+ {"time": 1794839212.4960327, "rss": 919764992, "processes": 6}
505
+ {"time": 1794839217.5124302, "rss": 1715597312, "processes": 6}
506
+ {"time": 1794839222.532313, "rss": 354349056, "processes": 6}
507
+ {"time": 1794839227.5530238, "rss": 435851264, "processes": 6}
508
+ {"time": 1794839232.5700057, "rss": 724971520, "processes": 6}
509
+ {"time": 1794839237.7426322, "rss": 1264107520, "processes": 6}
510
+ {"time": 1794839242.7721117, "rss": 1685590016, "processes": 6}
511
+ {"time": 1794839247.81308, "rss": 2135896064, "processes": 6}
512
+ {"time": 1794839252.8333228, "rss": 2397962240, "processes": 6}
513
+ {"time": 1794839257.857908, "rss": 238682112, "processes": 6}
514
+ {"time": 1794839262.883486, "rss": 241422336, "processes": 6}
515
+ {"time": 1794839267.9165943, "rss": 1052102656, "processes": 6}
516
+ {"time": 1794839272.958227, "rss": 1746685952, "processes": 6}
517
+ {"time": 1794839277.9741774, "rss": 374267904, "processes": 6}
518
+ {"time": 1794839282.9975338, "rss": 820006912, "processes": 6}
519
+ {"time": 1794839288.2805758, "rss": 1259106304, "processes": 6}
520
+ {"time": 1794839293.3039742, "rss": 1713741824, "processes": 6}
521
+ {"time": 1794839298.3215032, "rss": 2058067968, "processes": 6}
522
+ {"time": 1794839303.3407984, "rss": 2329255936, "processes": 6}
523
+ {"time": 1794839308.4611256, "rss": 244641792, "processes": 6}
524
+ {"time": 1794839313.4856474, "rss": 333586432, "processes": 6}
525
+ {"time": 1794839318.5063384, "rss": 337600512, "processes": 6}
526
+ {"time": 1794839323.5223386, "rss": 424177664, "processes": 6}
527
+ {"time": 1794839328.54118, "rss": 399425536, "processes": 6}
528
+ {"time": 1794839333.563715, "rss": 286846976, "processes": 6}
529
+ {"time": 1794839338.6598387, "rss": 395145216, "processes": 6}
530
+ {"time": 1794839343.7409708, "rss": 319217664, "processes": 6}
531
+ {"time": 1794839348.7635589, "rss": 416542720, "processes": 6}
532
+ {"time": 1794839353.780882, "rss": 389595136, "processes": 6}
533
+ {"time": 1794839358.810097, "rss": 257085440, "processes": 6}
534
+ {"time": 1794839363.8284805, "rss": 244064256, "processes": 6}
535
+ {"time": 1794839368.8460941, "rss": 242614272, "processes": 6}
536
+ {"time": 1794839373.9063268, "rss": 234737664, "processes": 6}
537
+ {"time": 1794839378.9251962, "rss": 232427520, "processes": 6}
538
+ {"time": 1794839383.9461596, "rss": 230780928, "processes": 6}
539
+ {"time": 1794839389.021396, "rss": 352538624, "processes": 6}
540
+ {"time": 1794839394.049981, "rss": 258281472, "processes": 6}
541
+ {"time": 1794839399.0715415, "rss": 240795648, "processes": 6}
542
+ {"time": 1794839404.1087613, "rss": 276017152, "processes": 6}
543
+ {"time": 1794839409.12896, "rss": 409120768, "processes": 6}
544
+ {"time": 1794839414.151552, "rss": 417140736, "processes": 6}
545
+ {"time": 1794839419.1872036, "rss": 374804480, "processes": 6}
546
+ {"time": 1794839424.205464, "rss": 283725824, "processes": 6}
547
+ {"time": 1794839429.2336674, "rss": 473239552, "processes": 6}
548
+ {"time": 1794839434.3145962, "rss": 550010880, "processes": 6}
549
+ {"time": 1794839439.3356423, "rss": 387948544, "processes": 6}
550
+ {"time": 1794839444.4343534, "rss": 651198464, "processes": 6}
551
+ {"time": 1794839449.4816008, "rss": 322777088, "processes": 6}
552
+ {"time": 1794839454.9386911, "rss": 385855488, "processes": 6}
553
+ {"time": 1794839460.0161085, "rss": 581611520, "processes": 6}
554
+ {"time": 1794839465.044229, "rss": 313581568, "processes": 6}
555
+ {"time": 1794839470.2996304, "rss": 338153472, "processes": 6}
556
+ {"time": 1794839475.3164666, "rss": 659238912, "processes": 6}
557
+ {"time": 1794839480.3389602, "rss": 1195065344, "processes": 6}
558
+ {"time": 1794839485.3744705, "rss": 452440064, "processes": 6}
559
+ {"time": 1794839490.4191678, "rss": 550567936, "processes": 6}
560
+ {"time": 1794839495.5061748, "rss": 632504320, "processes": 6}
561
+ {"time": 1794839500.54633, "rss": 436805632, "processes": 6}
562
+ {"time": 1794839505.569941, "rss": 434216960, "processes": 6}
563
+ {"time": 1794839510.597191, "rss": 460529664, "processes": 6}
564
+ {"time": 1794839515.6173003, "rss": 450121728, "processes": 6}
565
+ {"time": 1794839520.6449113, "rss": 453214208, "processes": 6}
566
+ {"time": 1794839525.7252076, "rss": 626491392, "processes": 6}
567
+ {"time": 1794839530.7448611, "rss": 644411392, "processes": 6}
568
+ {"time": 1794839535.768616, "rss": 820219904, "processes": 6}
569
+ {"time": 1794839540.792868, "rss": 450502656, "processes": 6}
570
+ {"time": 1794839545.815948, "rss": 272842752, "processes": 6}
571
+ {"time": 1794839550.8424103, "rss": 669110272, "processes": 6}
572
+ {"time": 1794839555.8706906, "rss": 564695040, "processes": 6}
573
+ {"time": 1794839560.9648716, "rss": 626454528, "processes": 6}
574
+ {"time": 1794839565.9860578, "rss": 724860928, "processes": 6}
575
+ {"time": 1794839571.0128498, "rss": 709431296, "processes": 6}
576
+ {"time": 1794839576.0405135, "rss": 1324609536, "processes": 6}
577
+ {"time": 1794839581.2497857, "rss": 612171776, "processes": 6}
578
+ {"time": 1794839586.28322, "rss": 511049728, "processes": 6}
579
+ {"time": 1794839591.3133047, "rss": 636104704, "processes": 6}
580
+ {"time": 1794839596.3284879, "rss": 440401920, "processes": 6}
581
+ {"time": 1794839601.4086006, "rss": 596074496, "processes": 6}
582
+ {"time": 1794839606.4339519, "rss": 438362112, "processes": 6}
583
+ {"time": 1794839611.4529312, "rss": 699920384, "processes": 6}
584
+ {"time": 1794839616.4826274, "rss": 465080320, "processes": 6}
585
+ {"time": 1794839621.501158, "rss": 283807744, "processes": 6}
586
+ {"time": 1794839626.5332563, "rss": 248008704, "processes": 6}
587
+ {"time": 1794839631.5558186, "rss": 250118144, "processes": 6}
588
+ {"time": 1794839636.6548858, "rss": 250085376, "processes": 6}
589
+ {"time": 1794839641.6990073, "rss": 247185408, "processes": 6}
590
+ {"time": 1794839646.7170076, "rss": 243785728, "processes": 6}
591
+ {"time": 1794839651.7381423, "rss": 246235136, "processes": 6}
592
+ {"time": 1794839656.7710063, "rss": 243245056, "processes": 6}
593
+ {"time": 1794839661.8212543, "rss": 259133440, "processes": 6}
594
+ {"time": 1794839666.862362, "rss": 253743104, "processes": 6}
595
+ {"time": 1794839671.8904192, "rss": 243314688, "processes": 6}
596
+ {"time": 1794839676.9099038, "rss": 246935552, "processes": 6}
597
+ {"time": 1794839681.9351554, "rss": 247062528, "processes": 6}
598
+ {"time": 1794839686.9602292, "rss": 240472064, "processes": 6}
599
+ {"time": 1794839692.0070798, "rss": 269258752, "processes": 6}
600
+ {"time": 1794839697.033989, "rss": 248709120, "processes": 6}
601
+ {"time": 1794839702.0558248, "rss": 240136192, "processes": 6}
602
+ {"time": 1794839707.078343, "rss": 233000960, "processes": 6}
603
+ {"time": 1794839712.1182463, "rss": 877711360, "processes": 6}
604
+ {"time": 1794839717.1800013, "rss": 989896704, "processes": 6}
605
+ {"time": 1794839722.1969452, "rss": 512274432, "processes": 6}
606
+ {"time": 1794839727.2420907, "rss": 1062031360, "processes": 6}
607
+ {"time": 1794839732.267247, "rss": 2195640320, "processes": 6}
608
+ {"time": 1794839737.2852774, "rss": 3345002496, "processes": 6}
609
+ {"time": 1794839742.318038, "rss": 542666752, "processes": 6}
610
+ {"time": 1794839747.3379066, "rss": 437886976, "processes": 6}
611
+ {"time": 1794839752.3579605, "rss": 429064192, "processes": 6}
612
+ {"time": 1794839757.3778543, "rss": 727666688, "processes": 6}
613
+ {"time": 1794839762.403647, "rss": 2268700672, "processes": 6}
614
+ {"time": 1794839767.4237194, "rss": 3221536768, "processes": 6}
615
+ {"time": 1794839772.4405296, "rss": 249044992, "processes": 6}
616
+ {"time": 1794839777.4651153, "rss": 259981312, "processes": 6}
617
+ {"time": 1794839782.4958694, "rss": 256000000, "processes": 6}
618
+ {"time": 1794839787.5250463, "rss": 277696512, "processes": 6}
619
+ {"time": 1794839792.5498726, "rss": 245698560, "processes": 6}
620
+ {"time": 1794839797.57218, "rss": 237563904, "processes": 6}
621
+ {"time": 1794839802.5916426, "rss": 322154496, "processes": 6}
622
+ {"time": 1794839807.622639, "rss": 425914368, "processes": 6}
623
+ {"time": 1794839812.6380723, "rss": 245305344, "processes": 6}
624
+ {"time": 1794839817.7762203, "rss": 244805632, "processes": 6}
625
+ {"time": 1794839822.798171, "rss": 241881088, "processes": 6}
626
+ {"time": 1794839827.8406868, "rss": 237613056, "processes": 6}
627
+ {"time": 1794839832.8935401, "rss": 238858240, "processes": 6}
628
+ {"time": 1794839837.918592, "rss": 238346240, "processes": 6}
629
+ {"time": 1794839842.9410248, "rss": 248733696, "processes": 6}
630
+ {"time": 1794839847.9642594, "rss": 244969472, "processes": 6}
631
+ {"time": 1794839852.984439, "rss": 239185920, "processes": 6}
632
+ {"time": 1794839858.0504048, "rss": 239296512, "processes": 6}
633
+ {"time": 1794839863.0775502, "rss": 241127424, "processes": 6}
634
+ {"time": 1794839868.1033638, "rss": 250011648, "processes": 6}
635
+ {"time": 1794839873.1198962, "rss": 255590400, "processes": 6}
636
+ {"time": 1794839878.2177172, "rss": 255909888, "processes": 6}
637
+ {"time": 1794839883.2389421, "rss": 432762880, "processes": 6}
638
+ {"time": 1794839888.3945994, "rss": 333529088, "processes": 6}
639
+ {"time": 1794839893.44171, "rss": 422400000, "processes": 6}
640
+ {"time": 1794839898.4695036, "rss": 495931392, "processes": 6}
641
+ {"time": 1794839903.5074327, "rss": 589312000, "processes": 6}
642
+ {"time": 1794839908.6191373, "rss": 435073024, "processes": 6}
643
+ {"time": 1794839913.6358142, "rss": 412553216, "processes": 6}
644
+ {"time": 1794839918.6575525, "rss": 288305152, "processes": 6}
645
+ {"time": 1794839923.6786718, "rss": 547975168, "processes": 6}
646
+ {"time": 1794839928.7043777, "rss": 1517367296, "processes": 6}
647
+ {"time": 1794839933.72922, "rss": 3063885824, "processes": 6}
648
+ {"time": 1794839938.7600827, "rss": 4323700736, "processes": 6}
649
+ {"time": 1794839943.7788033, "rss": 5518880768, "processes": 6}
650
+ {"time": 1794839948.800318, "rss": 1003401216, "processes": 6}
651
+ {"time": 1794839953.8187518, "rss": 586280960, "processes": 6}
652
+ {"time": 1794839958.8433683, "rss": 682766336, "processes": 6}
653
+ {"time": 1794839963.8601625, "rss": 463712256, "processes": 6}
654
+ {"time": 1794839968.8785155, "rss": 1692262400, "processes": 6}
655
+ {"time": 1794839973.9054375, "rss": 3146174464, "processes": 6}
656
+ {"time": 1794839978.9350264, "rss": 4423598080, "processes": 6}
657
+ {"time": 1794839983.9537444, "rss": 5414301696, "processes": 6}
658
+ {"time": 1794839988.9773495, "rss": 583184384, "processes": 6}
659
+ {"time": 1794839993.9982321, "rss": 288989184, "processes": 6}
660
+ {"time": 1794839999.019173, "rss": 274980864, "processes": 6}
661
+ {"time": 1794840004.1001232, "rss": 261181440, "processes": 6}
662
+ {"time": 1794840009.2843018, "rss": 248627200, "processes": 6}
663
+ {"time": 1794840014.311389, "rss": 243318784, "processes": 6}
664
+ {"time": 1794840019.337622, "rss": 242585600, "processes": 6}
665
+ {"time": 1794840024.362137, "rss": 281673728, "processes": 6}
666
+ {"time": 1794840029.380967, "rss": 271872000, "processes": 6}
667
+ {"time": 1794840034.4354053, "rss": 250753024, "processes": 6}
668
+ {"time": 1794840039.4586213, "rss": 250691584, "processes": 6}
669
+ {"time": 1794840044.4887638, "rss": 88506368, "processes": 6}
v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/.gitignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ __pycache__/
2
+ *.py[cod]
3
+ .pytest_cache/
4
+ *.egg-info/
5
+ build/
6
+ dist/
v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/README.md ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GBNF
2
+
3
+ A library for parsing `.gbnf` grammar files in Python.
4
+
5
+ This is a Python port of the [`gbnf`](https://www.npmjs.com/package/gbnf) javascript library.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install .
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Pass your grammar to `GBNF`:
16
+
17
+ ```python
18
+ from gbnf import GBNF
19
+
20
+ state = GBNF('''
21
+ root ::= "yes" | "no"
22
+ ''')
23
+ ```
24
+
25
+ If the grammar is invalid, `GBNF` will raise a `GrammarParseError`.
26
+
27
+ `GBNF` returns a state representing the parsed state:
28
+
29
+ ```python
30
+ from gbnf import GBNF
31
+
32
+ state = GBNF('''
33
+ root ::= "yes" | "no"
34
+ ''')
35
+ for rule in state:
36
+ print(rule)
37
+ # RuleChar(type='char', value=[121]) ("y")
38
+ # RuleChar(type='char', value=[110]) ("n")
39
+ ```
40
+
41
+ `state` can be iterated over. (You can also call the iterator method directly with `state.rules()`). `state` cannot be indexed directly, but can easily be cast to a list with `list(state)` and indexed that way.
42
+
43
+ States are _immutable_. To parse a new token, call `state.add()` (or call the state itself, `state(...)`):
44
+
45
+ ```python
46
+ from gbnf import GBNF
47
+
48
+ state = GBNF('''
49
+ root ::= "I like green eggs and ham"
50
+ ''')
51
+ print(list(state)) # [RuleChar(type='char', value=[73])] ("I")
52
+ state = state.add("I li")
53
+ print(list(state)) # [RuleChar(type='char', value=[107])] ("k")
54
+ state = state.add("ke gree")
55
+ print(list(state)) # [RuleChar(type='char', value=[110])] ("n")
56
+ ```
57
+
58
+ If the input does not satisfy the grammar, `add` raises an `InputParseError`. An initial string can also be passed as the second argument of `GBNF`. Input can be given as a string, a code point, or a list of code points.
59
+
60
+ The possible rules returned include:
61
+
62
+ - `char` (`RuleType.CHAR`) - contains a list of either numbers representing code points to match, _or_ ranges (pairs of numbers) denoting a range within which a code point may appear.
63
+ - `char_exclude` (`RuleType.CHAR_EXCLUDE`) - contains a list of numbers representing code points _not_ to match, _or_ ranges (pairs of numbers) denoting a range within which a code point may _not_ appear.
64
+ - `end` (`RuleType.END`) - denotes a valid end of a string.
65
+
66
+ Rules are dictionaries (`{'type': 'char', 'value': [121]}`) whose fields are also available as attributes (`rule.type`, `rule.value`). Use `is_range` to tell a range apart from a single code point.
67
+
68
+ The library's names follow Python conventions, but the javascript library's camelCase names work as well (`isRange`, `error.errorForMostRecentInput`, ...).
69
+
70
+ ## Differences from the javascript library
71
+
72
+ - Strings are read as sequences of Unicode code points, where javascript reads UTF-16 code units. The two only differ for characters outside the Basic Multilingual Plane (such as emoji), which are a single code point in Python.
73
+ - Long inputs are handled in linear time, and are not limited by the call stack: javascript runs out of stack after a few thousand repetitions of a rule.
74
+ - A left recursive grammar (a rule that refers to itself before matching any input) raises a `RecursionError`, where javascript raises a `RangeError`.
75
+
76
+ ## Development
77
+
78
+ ```bash
79
+ pytest
80
+ ```
81
+
82
+ The unit tests live in `tests/` (mirroring the javascript `src/` tests), and the integration tests in `integration_tests/`.
v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/conftest.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+
4
+ # Make the `gbnf` package importable however the tests are run.
5
+ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/__init__.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """A library for parsing GBNF grammars.
2
+
3
+ from gbnf import GBNF
4
+
5
+ state = GBNF('root ::= "yes" | "no"')
6
+ list(state) # [RuleChar(type='char', value=[121]), RuleChar(type='char', value=[110])]
7
+ state = state.add('ye')
8
+ list(state) # [RuleChar(type='char', value=[115])]
9
+ """
10
+ import sys
11
+ import types
12
+ from typing import Any
13
+
14
+ from ._compat import module_getattr
15
+ from .gbnf import GBNF
16
+ from .grammar_graph.parse_state import ParseState
17
+ from .grammar_graph.type_guards import is_range
18
+ from .grammar_graph.types import (
19
+ Range,
20
+ RuleChar,
21
+ RuleCharExclude,
22
+ RuleEnd,
23
+ RuleType,
24
+ )
25
+ from .grammar_graph.types import (
26
+ ResolvedRule as Rule,
27
+ )
28
+ from .utils.errors.grammar_parse_error import GrammarParseError
29
+ from .utils.errors.input_parse_error import InputParseError
30
+
31
+ __version__ = '0.1.41'
32
+
33
+ __all__ = [
34
+ 'GBNF',
35
+ 'GrammarParseError',
36
+ 'InputParseError',
37
+ 'ParseState',
38
+ 'Range',
39
+ 'Rule',
40
+ 'RuleChar',
41
+ 'RuleCharExclude',
42
+ 'RuleEnd',
43
+ 'RuleType',
44
+ 'is_range',
45
+ ]
46
+
47
+ __getattr__ = module_getattr(__name__)
48
+
49
+
50
+ class _GBNFModule(types.ModuleType):
51
+ # Like the default export of the javascript library, the module can be called to parse a grammar: `gbnf(grammar)`.
52
+ def __call__(self, input: Any, initial_string: Any = '') -> ParseState:
53
+ return GBNF(input, initial_string)
54
+
55
+
56
+ sys.modules[__name__].__class__ = _GBNFModule
v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/_compat.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Name compatibility with the javascript library.
2
+
3
+ The library is a port of the javascript `gbnf` package. Its API uses idiomatic
4
+ snake_case names, but every module and object also answers to the original
5
+ camelCase names (`parseChar`, `pointer.fetchNext()`, `error.errorForMostRecentInput`, ...),
6
+ which makes it easy to follow along with code written against the javascript API.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import re
11
+ import sys
12
+ from collections.abc import Callable
13
+ from typing import Any
14
+
15
+ _CAMEL_HUMP = re.compile(r'(?<=[a-z0-9])([A-Z])')
16
+
17
+
18
+ def to_snake_case(name: str) -> str:
19
+ """Converts a camelCase name (`getRootNode`) to its snake_case equivalent (`get_root_node`)."""
20
+ return _CAMEL_HUMP.sub(r'_\1', name).lower()
21
+
22
+
23
+ def _snake_case_alias(name: str) -> str | None:
24
+ if name.startswith('_'):
25
+ return None
26
+ snake = to_snake_case(name)
27
+ return snake if snake != name else None
28
+
29
+
30
+ def module_getattr(module_name: str) -> Callable[[str], Any]:
31
+ """Builds a module level `__getattr__` that resolves camelCase names to their snake_case equivalents."""
32
+
33
+ def __getattr__(name: str) -> Any:
34
+ snake = _snake_case_alias(name)
35
+ if snake is not None:
36
+ try:
37
+ return getattr(sys.modules[module_name], snake)
38
+ except AttributeError:
39
+ pass
40
+ raise AttributeError(f'module {module_name!r} has no attribute {name!r}')
41
+
42
+ return __getattr__
43
+
44
+
45
+ class CamelCaseAliases:
46
+ """Mixin resolving camelCase attribute names to their snake_case equivalents."""
47
+
48
+ def __getattr__(self, name: str) -> Any:
49
+ snake = _snake_case_alias(name)
50
+ if snake is not None:
51
+ return getattr(self, snake)
52
+ raise AttributeError(f'{type(self).__name__!r} object has no attribute {name!r}')
v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/gbnf.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from typing import Any
5
+
6
+ from ._compat import module_getattr
7
+ from .grammar_graph.graph import Graph
8
+ from .grammar_graph.parse_state import ParseState
9
+ from .grammar_graph.types import UnresolvedRule, ValidInput
10
+ from .grammar_parser.build_rule_stack import build_rule_stack
11
+ from .rules_builder import RulesBuilder
12
+ from .utils.errors.grammar_parse_error import GrammarParseError
13
+
14
+
15
+ def GBNF(input: str | Any, initial_string: ValidInput = '') -> ParseState:
16
+ """Parses a GBNF grammar, returning the parse state after the (optional) initial string.
17
+
18
+ Raises a `GrammarParseError` if the grammar is invalid, and an `InputParseError` if the
19
+ initial string does not satisfy the grammar.
20
+ """
21
+ grammar = input if isinstance(input, str) else str(input)
22
+ rules_builder = RulesBuilder(grammar)
23
+ rules, symbol_ids = rules_builder.rules, rules_builder.symbol_ids
24
+ if len(rules) == 0:
25
+ raise GrammarParseError(grammar, 0, 'No rules were found')
26
+ if symbol_ids.get('root') is None:
27
+ raise GrammarParseError(grammar, 0, f'Grammar does not contain a root symbol. Available symbols are: {json.dumps(list(symbol_ids.keys()))}')
28
+ root_id = symbol_ids.get('root')
29
+
30
+ stacked_rules: list[list[list[UnresolvedRule]]] = [build_rule_stack(rule) for rule in rules]
31
+ graph = Graph(grammar, stacked_rules, root_id)
32
+ return ParseState(graph, graph.add(initial_string))
33
+
34
+
35
+ __getattr__ = module_getattr(__name__)
v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from .graph import Graph
2
+
3
+ __all__ = ['Graph']
v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/colorize.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Callable
4
+ from enum import StrEnum
5
+
6
+ from .._compat import module_getattr
7
+
8
+
9
+ class Color(StrEnum):
10
+ BLUE = '\x1b[34m'
11
+ CYAN = '\x1b[36m'
12
+ GREEN = '\x1b[32m'
13
+ RED = '\x1b[31m'
14
+ GRAY = '\x1b[90m'
15
+ YELLOW = '\x1b[33m'
16
+
17
+
18
+ def colorize(str: str | int, color: Color) -> str:
19
+ return f'{color}{str}'
20
+
21
+
22
+ Colorize = Callable[[str | int, Color], str]
23
+
24
+ __getattr__ = module_getattr(__name__)
v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/generic_set.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Callable, Iterator
4
+ from typing import Generic, TypeVar
5
+
6
+ from .._compat import CamelCaseAliases
7
+
8
+ T = TypeVar('T')
9
+ K = TypeVar('K')
10
+
11
+
12
+ class GenericSet(CamelCaseAliases, Generic[T, K]):
13
+ """An insertion ordered set, whose members are distinguished by the key `get_key` computes for them."""
14
+
15
+ def __init__(self, get_key: Callable[[T], K]) -> None:
16
+ self.get_key = get_key
17
+ self._keys: dict[K, T] = {}
18
+
19
+ def add(self, el: T) -> None:
20
+ key = self.get_key(el)
21
+ if key not in self._keys:
22
+ self._keys[key] = el
23
+
24
+ def delete(self, el: T) -> None:
25
+ key = self.get_key(el)
26
+ if key not in self._keys:
27
+ raise ValueError('Could not get ref')
28
+ del self._keys[key]
29
+
30
+ def has(self, el: T) -> bool:
31
+ return any(member is el for member in self._keys.values())
32
+
33
+ def get(self, el: T) -> T | None:
34
+ return self._keys.get(self.get_key(el))
35
+
36
+ def __iter__(self) -> Iterator[T]:
37
+ return iter(self._keys.values())
38
+
39
+ def __contains__(self, el: object) -> bool:
40
+ return self.has(el) # type: ignore[arg-type]
41
+
42
+ def __len__(self) -> int:
43
+ return len(self._keys)
44
+
45
+ @property
46
+ def size(self) -> int:
47
+ return len(self._keys)
v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/get_input_as_code_points.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from .._compat import module_getattr
6
+
7
+ if TYPE_CHECKING:
8
+ from .types import ValidInput
9
+
10
+
11
+ def get_input_as_code_points(src: ValidInput) -> list[int]:
12
+ if not isinstance(src, str):
13
+ return src if isinstance(src, list) else list(src) if isinstance(src, tuple) else [src]
14
+
15
+ return [ord(char) for char in src]
16
+
17
+
18
+ __getattr__ = module_getattr(__name__)
v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/get_parent_stack_id.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from .._compat import module_getattr
6
+ from .colorize import Color
7
+ from .types import get_meta_ids
8
+
9
+ if TYPE_CHECKING:
10
+ from .colorize import Colorize
11
+ from .graph_pointer import GraphPointer
12
+
13
+
14
+ def get_parent_stack_id(pointer: GraphPointer, col: Colorize) -> str:
15
+ stack_ids: list[str] = []
16
+ parent = pointer.parent
17
+ while parent:
18
+ stack_id, path_id, step_id = get_meta_ids(parent.node.meta)
19
+ stack_ids.append(f'{stack_id},{path_id},{step_id}')
20
+ parent = parent.parent
21
+ return col('<-', Color.GRAY).join(col(stack_id, Color.RED) for stack_id in stack_ids)
22
+
23
+
24
+ __getattr__ = module_getattr(__name__)
v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/get_serialized_rule_key.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from .._compat import module_getattr
6
+ from ..utils.js_compat import json_stringify
7
+ from .type_guards import (
8
+ get_rule_type,
9
+ get_rule_value,
10
+ is_rule_char,
11
+ is_rule_char_excluded,
12
+ is_rule_end,
13
+ is_rule_ref,
14
+ )
15
+ from .types import RuleType
16
+
17
+ if TYPE_CHECKING:
18
+ from .types import UnresolvedRule
19
+
20
+ KEY_TRANSLATION = {
21
+ RuleType.END: 0,
22
+ RuleType.CHAR: 1,
23
+ RuleType.CHAR_EXCLUDE: 2,
24
+ }
25
+
26
+
27
+ def get_serialized_rule_key(rule: UnresolvedRule) -> str:
28
+ if is_rule_end(rule):
29
+ return f'{KEY_TRANSLATION[RuleType.END]}'
30
+
31
+ if is_rule_char(rule) or is_rule_char_excluded(rule):
32
+ return f'{KEY_TRANSLATION[get_rule_type(rule)]}-{json_stringify(get_rule_value(rule))}'
33
+ if is_rule_ref(rule):
34
+ return f'3-{rule.value}'
35
+ raise ValueError(f'Unknown rule type: {json_stringify(rule)}')
36
+
37
+
38
+ __getattr__ = module_getattr(__name__)
v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/graph.py ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Iterator, Mapping, Sequence
4
+ from typing import TYPE_CHECKING, Any
5
+
6
+ from .._compat import CamelCaseAliases, module_getattr
7
+ from ..utils.errors.input_parse_error import InputParseError
8
+ from ..utils.is_point_in_range import is_point_in_range
9
+ from ..utils.js_compat import json_stringify
10
+ from .colorize import colorize
11
+ from .generic_set import GenericSet
12
+ from .get_input_as_code_points import get_input_as_code_points
13
+ from .get_serialized_rule_key import get_serialized_rule_key
14
+ from .graph_node import GraphNode
15
+ from .graph_pointer import GraphPointer
16
+ from .rule_ref import RuleRef
17
+ from .type_guards import (
18
+ get_rule_value,
19
+ is_range,
20
+ is_rule_char,
21
+ is_rule_char_excluded,
22
+ is_rule_end,
23
+ is_rule_ref,
24
+ )
25
+ from .types import GraphNodeMeta
26
+
27
+ if TYPE_CHECKING:
28
+ from .types import Pointers, ResolvedGraphPointer, UnresolvedRule, ValidInput
29
+
30
+ class RootNode(dict[int, GraphNode]):
31
+ """The first node of each of a rule's alternatives, by alternative."""
32
+
33
+ @property
34
+ def size(self) -> int:
35
+ return len(self)
36
+
37
+
38
+ def make_pointers() -> Pointers:
39
+ return GenericSet(lambda pointer: pointer.id)
40
+
41
+
42
+ class Graph(CamelCaseAliases):
43
+ """The grammar as a graph: for every rule, the chain of nodes of each of its alternatives."""
44
+
45
+ grammar: str
46
+
47
+ def __init__(self, grammar: str, stacked_rules: Sequence[Sequence[Sequence[UnresolvedRule]]], root_id: int) -> None:
48
+ self.grammar = grammar
49
+ self.roots: dict[int, RootNode] = {}
50
+ self.previous_code_points: list[int] = []
51
+ rule_refs: list[RuleRef] = []
52
+ unique_rules: GenericSet[UnresolvedRule, str] = GenericSet(get_serialized_rule_key)
53
+ for stack_id, stack in enumerate(stacked_rules):
54
+ nodes = RootNode()
55
+ for path_id, path in enumerate(stack):
56
+ node: GraphNode | None = None
57
+ for step_id in range(len(path) - 1, -1, -1):
58
+ next_node = node
59
+ rule = path[step_id]
60
+ unique_rules.add(rule)
61
+ if is_rule_ref(rule):
62
+ rule_refs.append(rule)
63
+ # rules coming in may be identical but have different references.
64
+ # here, we ensure we always use the same reference for an identical rule.
65
+ # this makes future comparisons easier.
66
+ unique_rule = unique_rules.get(rule)
67
+ if unique_rule is None:
68
+ raise ValueError('Could not get unique rule')
69
+ node = GraphNode(unique_rule, GraphNodeMeta(stack_id, path_id, step_id), next_node)
70
+ if node is None:
71
+ raise ValueError('Could not get node')
72
+ nodes[path_id] = node
73
+
74
+ self.roots[stack_id] = nodes
75
+ root_node = self.roots.get(root_id)
76
+ if root_node is None:
77
+ raise ValueError(f'Root node not found for value: {root_id}')
78
+ self._root_node: RootNode | None = root_node
79
+
80
+ for rule_ref in rule_refs:
81
+ rule_ref.nodes = list(self.get_root_node(rule_ref.value).values())
82
+
83
+ def get_root_node(self, value: int) -> RootNode:
84
+ root_node = self.roots.get(value)
85
+ if root_node is None:
86
+ raise ValueError(f'Root node not found for value: {value}')
87
+ return root_node
88
+
89
+ def get_initial_pointers(self) -> Pointers:
90
+ pointers = make_pointers()
91
+
92
+ root_node = self._root_node
93
+ if root_node is None:
94
+ raise ValueError('Root node is not defined')
95
+
96
+ for node, parent in self.fetch_nodes_for_root_node(root_node):
97
+ pointer = GraphPointer(node, parent)
98
+ for resolved_pointer in self.resolve_pointer(pointer):
99
+ pointers.add(resolved_pointer)
100
+ return pointers
101
+
102
+ # (`get_root_node` and `get_initial_pointers` are private in javascript)
103
+ _get_root_node = get_root_node
104
+ _get_initial_pointers = get_initial_pointers
105
+
106
+ def set_valid(self, pointers: list[GraphPointer], valid: bool) -> None:
107
+ for pointer in pointers:
108
+ pointer.valid = valid
109
+
110
+ def parse(self, current_pointers: Pointers, code_point: int) -> Pointers:
111
+ for rule, graph_pointers in self.iterate_over_pointers(current_pointers):
112
+ if is_rule_char(rule):
113
+ valid = any(
114
+ is_point_in_range(code_point, possible_code_point) if is_range(possible_code_point)
115
+ else code_point == possible_code_point
116
+ for possible_code_point in get_rule_value(rule)
117
+ )
118
+ self.set_valid(graph_pointers, valid)
119
+ elif is_rule_char_excluded(rule):
120
+ valid = all(
121
+ not is_point_in_range(code_point, possible_code_point) if is_range(possible_code_point)
122
+ else code_point != possible_code_point
123
+ for possible_code_point in get_rule_value(rule)
124
+ )
125
+ self.set_valid(graph_pointers, valid)
126
+ elif not is_rule_end(rule):
127
+ raise ValueError(f'Unsupported rule: {json_stringify(rule)}')
128
+
129
+ # a pointer's id is the sum of its node's id and its parent's id chain.
130
+ # if two pointers share the same id, it means they point to the same node and have identical parent chains.
131
+ # for the purposes of walking the graph, we only need to keep one of them.
132
+ next_pointers = make_pointers()
133
+ for current_pointer in current_pointers:
134
+ for unresolved_next_pointer in current_pointer.fetch_next():
135
+ for resolved_next_pointer in self.resolve_pointer(unresolved_next_pointer):
136
+ next_pointers.add(resolved_next_pointer)
137
+ return next_pointers
138
+
139
+ def resolve_pointer(self, unresolved_pointer: GraphPointer) -> Iterator[ResolvedGraphPointer]:
140
+ for resolved_pointer in unresolved_pointer.resolve():
141
+ if is_rule_ref(resolved_pointer.node.rule):
142
+ raise ValueError('Encountered a reference rule when building pointers to the graph')
143
+ if is_rule_end(resolved_pointer.node.rule) and resolved_pointer.parent:
144
+ raise ValueError('Encountered an ending rule with a parent when building pointers to the graph')
145
+ yield resolved_pointer
146
+
147
+ def add(self, src: ValidInput, pointers: Pointers | None = None) -> Pointers:
148
+ if pointers is None:
149
+ pointers = self.get_initial_pointers()
150
+ code_points = get_input_as_code_points(src)
151
+ for code_point_pos, code_point in enumerate(code_points):
152
+ pointers = self.parse(pointers, code_point)
153
+ if pointers.size == 0:
154
+ raise InputParseError(code_points, code_point_pos, self.previous_code_points)
155
+ self.previous_code_points.extend(code_points)
156
+ return pointers
157
+
158
+ # generator that yields either the node, or if a reference rule, the referenced node
159
+ # we need these function, as distinct from leveraging the logic in GraphPointer,
160
+ # because that needs a rule ref with already defined nodes; this function is used to _set_ those nodes
161
+ def fetch_nodes_for_root_node(
162
+ self,
163
+ root_nodes: RootNode,
164
+ parent: GraphPointer | None = None,
165
+ ) -> Iterator[tuple[GraphNode, GraphPointer | None]]:
166
+ for node in root_nodes.values():
167
+ if is_rule_ref(node.rule):
168
+ yield from self.fetch_nodes_for_root_node(self.get_root_node(node.rule.value), GraphPointer(node, parent))
169
+ else:
170
+ yield node, parent
171
+
172
+ def __repr__(self) -> str:
173
+ return self.print(colors=True)
174
+
175
+ def print(self, opts: Mapping[str, Any] | None = None, /, *, pointers: Pointers | None = None, colors: bool = False) -> str:
176
+ if opts is not None:
177
+ pointers = opts.get('pointers', pointers)
178
+ colors = opts.get('colors', colors)
179
+ col = colorize if colors else lambda str, _color: f'{str}'
180
+ graph_view = [
181
+ node.print(
182
+ pointers=pointers,
183
+ show_position=True,
184
+ colorize=col,
185
+ )
186
+ for nodes in self.roots.values()
187
+ for node in nodes.values()
188
+ ]
189
+ return '\n' + '\n'.join(graph_view)
190
+
191
+ def iterate_over_pointers(self, pointers: Pointers) -> Iterator[tuple[UnresolvedRule, list[GraphPointer]]]:
192
+ # pointers are grouped by their rule; identical rules are the same object, so rules are compared by identity
193
+ seen_rules: dict[int, tuple[UnresolvedRule, list[GraphPointer]]] = {}
194
+ for pointer in pointers:
195
+ rule = pointer.rule
196
+ if is_rule_ref(rule):
197
+ raise ValueError('Encountered a reference rule in the graph, this should not happen')
198
+ seen_rule = seen_rules.get(id(rule))
199
+ if seen_rule is None:
200
+ seen_rules[id(rule)] = (rule, [pointer])
201
+ else:
202
+ seen_rule[1].append(pointer)
203
+
204
+ yield from seen_rules.values()
205
+
206
+
207
+ __getattr__ = module_getattr(__name__)
v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/graph_node.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import TYPE_CHECKING, Any, Generic, TypeVar
5
+
6
+ from .._compat import CamelCaseAliases, module_getattr
7
+ from .colorize import colorize
8
+ from .print import print_graph_node
9
+ from .rule_ref import RuleRef
10
+ from .types import GraphNodeMeta, get_meta_ids
11
+
12
+ if TYPE_CHECKING:
13
+ from .types import UnresolvedRule
14
+
15
+ R = TypeVar('R', bound='UnresolvedRule')
16
+
17
+ __all__ = ['GraphNode', 'GraphNodeMeta', 'GraphNodeRuleRef']
18
+
19
+
20
+ class GraphNode(CamelCaseAliases, Generic[R]):
21
+ """A step in one of a rule's alternatives, linked to the `next` step."""
22
+
23
+ def __init__(self, rule: R, meta: GraphNodeMeta | None = None, next: GraphNode | None = None) -> None:
24
+ self.rule = rule
25
+ if meta is None:
26
+ raise ValueError('Meta is undefined')
27
+ self.meta = meta
28
+ self.next = next
29
+ self._id: str | None = None
30
+
31
+ @property
32
+ def id(self) -> str:
33
+ if not self._id:
34
+ stack_id, path_id, step_id = get_meta_ids(self.meta)
35
+ self._id = f'{stack_id},{path_id},{step_id}'
36
+ return self._id
37
+
38
+ def print(self, opts: Mapping[str, Any] | None = None, /, **kwargs: Any) -> str:
39
+ return print_graph_node(self)(opts, **kwargs)
40
+
41
+ def to_json(self) -> dict[str, Any]:
42
+ return {'rule': self.rule, 'meta': self.meta, 'next': self.next}
43
+
44
+ def __repr__(self) -> str:
45
+ return self.print(colorize=colorize, show_position=False)
46
+
47
+
48
+ GraphNodeRuleRef = GraphNode[RuleRef]
49
+
50
+ __getattr__ = module_getattr(__name__)
v2-models-effort/runs/20261116-123314-spring-meadow/ported_implementation/gbnf/grammar_graph/graph_pointer.py ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+ from collections.abc import Iterator, Mapping, Sequence
5
+ from typing import TYPE_CHECKING, Any, Generic, TypeVar
6
+
7
+ from .._compat import CamelCaseAliases, module_getattr
8
+ from ..utils.js_compat import json_stringify
9
+ from .colorize import colorize
10
+ from .print import print_graph_pointer
11
+ from .type_guards import (
12
+ is_graph_pointer_rule_char,
13
+ is_graph_pointer_rule_char_exclude,
14
+ is_graph_pointer_rule_end,
15
+ is_graph_pointer_rule_ref,
16
+ is_rule_end,
17
+ )
18
+
19
+ if TYPE_CHECKING:
20
+ from .graph_node import GraphNode
21
+ from .types import ResolvedGraphPointer, UnresolvedRule
22
+
23
+ R = TypeVar('R', bound='UnresolvedRule')
24
+
25
+
26
+ class GraphPointer(CamelCaseAliases, Generic[R]):
27
+ """Points at a node of the graph. Its `parent` chain records the rule references followed to reach the node."""
28
+
29
+ def __init__(self, node: GraphNode[R] | None = None, parent: GraphPointer | None = None) -> None:
30
+ if node is None:
31
+ raise ValueError('Node is undefined')
32
+ self.node = node
33
+ self.parent = parent
34
+ self._valid: bool | None = None
35
+ self._id: str | None = None
36
+ self._following_pointers: list[ResolvedGraphPointer] | None = None
37
+
38
+ @property
39
+ def id(self) -> str:
40
+ # A pointer's id is its parent's id followed by its node's id. It is computed when first needed, as
41
+ # building it for every pointer made while walking a long chain of parents would be costly.
42
+ if self._id is None:
43
+ # (the parents' ids are computed top down, as the chain of parents can be deep)
44
+ pointers_without_id: list[GraphPointer] = []
45
+ pointer: GraphPointer | None = self
46
+ while isinstance(pointer, GraphPointer) and pointer._id is None:
47
+ pointers_without_id.append(pointer)
48
+ pointer = pointer.parent
49
+ for pointer in reversed(pointers_without_id):
50
+ pointer._id = f'{pointer.parent.id}-{pointer.node.id}' if pointer.parent else pointer.node.id
51
+ return self._id
52
+
53
+ @id.setter
54
+ def id(self, id: str) -> None:
55
+ self._id = id
56
+
57
+ def resolve(self, resolved: bool = False) -> Iterator[ResolvedGraphPointer]:
58
+ """
59
+ 1. If the current node is an end node, and the pointer has a parent, resolve the parent (with resolved set); else yield the pointer.
60
+ 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.
61
+ 3. If the current node is a char or a char exclude, yield the pointer.
62
+ """
63
+ # Pointers are resolved depth first from an explicit stack, rather than recursively: a pointer's chain of
64
+ # parents grows with every repetition it matches, and can grow far deeper than python's recursion limit.
65
+ #
66
+ # The pointers that follow a rule reference (resolving it with `resolved` set) depend only on the
67
+ # reference's pointer, so they are collected the first time they are resolved and reused afterwards.
68
+ # Otherwise, every step through a long repetition would walk back up its whole chain of parents.
69
+ #
70
+ # `depth` counts the rule references followed since resolution began, as a rule referencing itself
71
+ # before matching anything (a left recursive rule) would otherwise be followed forever.
72
+ max_depth = sys.getrecursionlimit()
73
+ # (an entry without `resolved` marks the end of the pointers following a rule reference)
74
+ stack: list[tuple[GraphPointer, bool | None, int]] = [(self, bool(resolved), 0)]
75
+ collecting: list[list[ResolvedGraphPointer]] = []
76
+ while stack:
77
+ pointer, resolved, depth = stack.pop()
78
+ if resolved is None:
79
+ pointer._following_pointers = collecting.pop()
80
+ continue
81
+
82
+ resolved_pointers: Sequence[ResolvedGraphPointer] = ()
83
+ if is_graph_pointer_rule_ref(pointer):
84
+ if resolved:
85
+ following_pointers = getattr(pointer, '_following_pointers', None)
86
+ if following_pointers is not None:
87
+ resolved_pointers = following_pointers
88
+ else:
89
+ if not pointer.node.next:
90
+ raise ValueError(f'No next node: {json_stringify(pointer.node)}')
91
+ if isinstance(pointer, GraphPointer):
92
+ collecting.append([])
93
+ stack.append((pointer, None, depth))
94
+ stack.append((GraphPointer(pointer.node.next, pointer.parent), False, depth))
95
+ else:
96
+ if depth >= max_depth:
97
+ raise RecursionError('maximum recursion depth exceeded while resolving the grammar, is it left recursive?')
98
+ nodes = list(pointer.node.rule.nodes)
99
+ stack.extend((GraphPointer(node, pointer), False, depth + 1) for node in reversed(nodes))
100
+ elif is_graph_pointer_rule_end(pointer):
101
+ if not pointer.parent:
102
+ resolved_pointers = (pointer,)
103
+ else:
104
+ stack.append((pointer.parent, True, depth - 1))
105
+ elif is_graph_pointer_rule_char(pointer) or is_graph_pointer_rule_char_exclude(pointer):
106
+ resolved_pointers = (pointer,)
107
+ else:
108
+ raise ValueError(f'Unknown rule: {json_stringify(pointer.node.rule)}')
109
+
110
+ for resolved_pointer in resolved_pointers:
111
+ for following_pointers in collecting:
112
+ following_pointers.append(resolved_pointer)
113
+ yield resolved_pointer
114
+
115
+ def fetch_next(self) -> Iterator[ResolvedGraphPointer]:
116
+ pointer: GraphPointer = self
117
+ while True:
118
+ # if this pointer is invalid, then we don't return any new pointers
119
+ if getattr(pointer, '_valid', None) is False:
120
+ return
121
+
122
+ if not is_rule_end(pointer.node.rule):
123
+ break
124
+ # if this pointer is an end node, we return the parent's next node. If no parent exists,
125
+ # we return nothing, since it's the end of the line.
126
+ if not pointer.parent:
127
+ return
128
+ pointer = pointer.parent
129
+
130
+ if not pointer.node.next:
131
+ raise ValueError(f'No next node: {json_stringify(pointer.node)}')
132
+ yield from GraphPointer(pointer.node.next, pointer.parent).resolve()
133
+
134
+ @property
135
+ def rule(self) -> R:
136
+ return self.node.rule
137
+
138
+ @property
139
+ def valid(self) -> bool | None:
140
+ return self._valid
141
+
142
+ @valid.setter
143
+ def valid(self, valid: bool) -> None:
144
+ self._valid = valid
145
+
146
+ def print(self, opts: Mapping[str, Any] | None = None, /, **kwargs: Any) -> str:
147
+ return print_graph_pointer(self)(opts, **kwargs)
148
+
149
+ def __repr__(self) -> str:
150
+ return self.print(colorize=colorize)
151
+
152
+
153
+ GraphPointerKey = str
154
+
155
+ __getattr__ = module_getattr(__name__)