thekevinscott commited on
Commit
e01b78a
·
verified ·
1 Parent(s): ae5a374

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

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-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/rules-builder/parse-space.ts +17 -0
  2. v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/rules-builder/rules-builder-types.ts +64 -0
  3. v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/rules-builder/rules-builder.ts +255 -0
  4. v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/rules-builder/symbol-ids.ts +47 -0
  5. v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/errors/build-error-position.ts +32 -0
  6. v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/errors/errors-types.ts +1 -0
  7. v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/errors/get-input-as-string.ts +11 -0
  8. v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/errors/grammar-parse-error.ts +28 -0
  9. v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/errors/index.ts +2 -0
  10. v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/errors/input-parse-error.ts +38 -0
  11. v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/is-point-in-range.ts +8 -0
  12. v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/validate-non-empty.ts +6 -0
  13. v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/tsconfig.json +14 -0
  14. v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/vitest.config.integration.ts +21 -0
  15. v2-tests-configuration/runs/20261012T045715Z_96a77204/proxy.log +19 -0
  16. v2-tests-configuration/runs/20261012T045715Z_96a77204/result.json +1 -0
  17. v2-tests-configuration/runs/20261012T045715Z_96a77204/run.json +11 -0
  18. v2-tests-configuration/runs/20261012T045715Z_96a77204/stderr.txt +0 -0
  19. v2-tests-configuration/runs/20261012T045715Z_96a77204/transcript/.claude/projects/-target/afe0780f-9d02-4bec-ab19-b199608eaac1.jsonl +0 -0
  20. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/manifest.json +113 -0
  21. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/.gitignore +1 -0
  22. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/.lock +0 -0
  23. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/CACHEDIR.TAG +1 -0
  24. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate +130 -0
  25. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate.bat +71 -0
  26. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate.csh +76 -0
  27. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate.fish +127 -0
  28. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate.nu +104 -0
  29. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate.ps1 +82 -0
  30. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate.xsh +102 -0
  31. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate_this.py +59 -0
  32. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/deactivate.bat +39 -0
  33. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/pydoc.bat +22 -0
  34. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/lib/python3.14/site-packages/_virtualenv.pth +3 -0
  35. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/lib/python3.14/site-packages/_virtualenv.py +121 -0
  36. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/pyvenv.cfg +6 -0
  37. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/Makefile +52 -0
  38. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/README.md +52 -0
  39. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/__init__.py +22 -0
  40. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/gbnf.py +28 -0
  41. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/gbnf_test.py +105 -0
  42. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/__init__.py +3 -0
  43. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/colorize.py +18 -0
  44. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/colorize_test.py +13 -0
  45. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/generic_set.py +40 -0
  46. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/generic_set_test.py +38 -0
  47. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/get_input_as_code_points.py +7 -0
  48. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/get_input_as_code_points_test.py +13 -0
  49. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/get_parent_stack_id.py +18 -0
  50. v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/get_parent_stack_id_test.py +52 -0
v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/rules-builder/parse-space.ts ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export const parseSpace = (src: string, pos: number, newlineOk: boolean): number => {
2
+ while (pos < src.length && (
3
+ src[pos] === ' '
4
+ || src[pos] === '\t'
5
+ || src[pos] === '#'
6
+ || (newlineOk && (src[pos] === '\r' || src[pos] === '\n'))
7
+ )) {
8
+ if (src[pos] === '#') {
9
+ while (pos < src.length && src[pos] !== '\r' && src[pos] !== '\n') {
10
+ pos += 1;
11
+ }
12
+ } else {
13
+ pos += 1;
14
+ }
15
+ }
16
+ return pos;
17
+ };
v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/rules-builder/rules-builder-types.ts ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export const InternalRuleType = {
2
+ CHAR: 'char',
3
+ CHAR_RNG_UPPER: 'char_rng_upper',
4
+ CHAR_ALT: 'char_alt',
5
+ CHAR_NOT: 'char_not',
6
+ REF: 'ref',
7
+ ALT: 'alt',
8
+ END: 'end',
9
+ } as const;
10
+
11
+ export interface InternalRuleDefChar {
12
+ type: typeof InternalRuleType.CHAR;
13
+ value: number[];
14
+ }
15
+ export interface InternalRuleDefCharNot {
16
+ type: typeof InternalRuleType.CHAR_NOT;
17
+ value: number[];
18
+ }
19
+ export interface InternalRuleDefCharAlt {
20
+ type: typeof InternalRuleType.CHAR_ALT;
21
+ value: number;
22
+ }
23
+ export interface InternalRuleDefCharRngUpper {
24
+ type: typeof InternalRuleType.CHAR_RNG_UPPER;
25
+ value: number;
26
+ }
27
+ export interface InternalRuleDefReference {
28
+ type: typeof InternalRuleType.REF;
29
+ value: number;
30
+ }
31
+ export interface InternalRuleDefAlt {
32
+ type: typeof InternalRuleType.ALT;
33
+ }
34
+ export interface InternalRuleDefEnd {
35
+ type: typeof InternalRuleType.END;
36
+ }
37
+
38
+ export type InternalRuleDef =
39
+ | InternalRuleDefChar
40
+ | InternalRuleDefCharNot
41
+ | InternalRuleDefCharAlt
42
+ | InternalRuleDefCharRngUpper
43
+ | InternalRuleDefReference
44
+ | InternalRuleDefAlt
45
+ | InternalRuleDefEnd;
46
+
47
+ export type InternalRuleDefCharOrAltChar = InternalRuleDefChar | InternalRuleDefCharAlt;
48
+
49
+ export type InternalRuleTypeValue = InternalRuleDef['type'];
50
+
51
+ export const isRuleDefAlt = (rule?: InternalRuleDef): rule is InternalRuleDefAlt =>
52
+ rule?.type === InternalRuleType.ALT;
53
+ export const isRuleDefRef = (rule?: InternalRuleDef): rule is InternalRuleDefReference =>
54
+ rule?.type === InternalRuleType.REF;
55
+ export const isRuleDefEnd = (rule?: InternalRuleDef): rule is InternalRuleDefEnd =>
56
+ rule?.type === InternalRuleType.END;
57
+ export const isRuleDefChar = (rule?: InternalRuleDef): rule is InternalRuleDefChar =>
58
+ rule?.type === InternalRuleType.CHAR;
59
+ export const isRuleDefCharNot = (rule?: InternalRuleDef): rule is InternalRuleDefCharNot =>
60
+ rule?.type === InternalRuleType.CHAR_NOT;
61
+ export const isRuleDefCharAlt = (rule?: InternalRuleDef): rule is InternalRuleDefCharAlt =>
62
+ rule?.type === InternalRuleType.CHAR_ALT;
63
+ export const isRuleDefCharRngUpper = (rule?: InternalRuleDef): rule is InternalRuleDefCharRngUpper =>
64
+ rule?.type === InternalRuleType.CHAR_RNG_UPPER;
v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/rules-builder/rules-builder.ts ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { GrammarParseError, } from '../utils/errors/index.ts';
2
+ import { isWordChar, } from './is-word-char.ts';
3
+ import { parseChar, } from './parse-char.ts';
4
+ import { parseName, } from './parse-name.ts';
5
+ import { parseSpace, } from './parse-space.ts';
6
+ import {
7
+ type InternalRuleDef,
8
+ InternalRuleType,
9
+ isRuleDefRef,
10
+ } from './rules-builder-types.ts';
11
+ import { SymbolIds, } from './symbol-ids.ts';
12
+
13
+ type CharStartType =
14
+ | typeof InternalRuleType.CHAR
15
+ | typeof InternalRuleType.CHAR_NOT
16
+ | typeof InternalRuleType.CHAR_ALT;
17
+
18
+ const getOutElements = (type: CharStartType, startcharValue: number): InternalRuleDef => {
19
+ if (type === InternalRuleType.CHAR) {
20
+ return { type: InternalRuleType.CHAR, value: [startcharValue,], };
21
+ }
22
+ if (type === InternalRuleType.CHAR_NOT) {
23
+ return { type: InternalRuleType.CHAR_NOT, value: [startcharValue,], };
24
+ }
25
+ if (type === InternalRuleType.CHAR_ALT) {
26
+ return { type: InternalRuleType.CHAR_ALT, value: startcharValue, };
27
+ }
28
+ throw new Error(`Invalid type: ${type as string}`);
29
+ };
30
+
31
+ const isSpace = (c: string): boolean => /\s/.test(c);
32
+
33
+ export class RulesBuilder {
34
+ pos = 0;
35
+ symbolIds = new SymbolIds();
36
+ rules: InternalRuleDef[][] = [];
37
+ src: string;
38
+ start: number;
39
+ timeLimit: number;
40
+
41
+ constructor(src: string, limit = 1000) {
42
+ this.src = src;
43
+ this.start = performance.now();
44
+ this.timeLimit = limit;
45
+ this.parse(src);
46
+ }
47
+
48
+ parse(src: string): void {
49
+ this.pos = parseSpace(src, 0, true);
50
+ while (this.pos < src.length) {
51
+ this.parseRule(src);
52
+ }
53
+
54
+ // Validate the state to ensure that all rules are defined
55
+ for (const rule of this.rules) {
56
+ for (const elem of rule) {
57
+ if (isRuleDefRef(elem)) {
58
+ const ruleExists = elem.value < this.rules.length && this.rules[elem.value].length > 0;
59
+ if (!ruleExists) {
60
+ const missingRuleName = this.symbolIds.reverseGet(elem.value);
61
+ let missingRulePos = this.symbolIds.getPos(missingRuleName);
62
+
63
+ // Skip over the ::= and any whitespace
64
+ while (missingRulePos < src.length && (
65
+ src[missingRulePos] === ':'
66
+ || src[missingRulePos] === '='
67
+ || isSpace(src[missingRulePos])
68
+ )) {
69
+ missingRulePos += 1;
70
+ }
71
+
72
+ throw new GrammarParseError(
73
+ src,
74
+ missingRulePos,
75
+ `Undefined rule identifier "${missingRuleName}"`,
76
+ );
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+
83
+ parseRule(src: string): void {
84
+ const name = parseName(src, this.pos);
85
+ this.pos = parseSpace(src, this.pos + name.length, false);
86
+ const ruleId = this.getSymbolId(name, name.length);
87
+
88
+ this.pos = parseSpace(src, this.pos, true);
89
+ if (!(
90
+ this.pos + 2 < src.length
91
+ && src[this.pos] === ':'
92
+ && src[this.pos + 1] === ':'
93
+ && src[this.pos + 2] === '='
94
+ )) {
95
+ throw new GrammarParseError(src, this.pos, `Expecting ::= at ${this.pos}`);
96
+ }
97
+ this.pos += 3;
98
+ this.pos = parseSpace(src, this.pos, true);
99
+
100
+ this.parseAlternates(name, ruleId);
101
+
102
+ if (this.pos < src.length && src[this.pos] === '\r') {
103
+ this.pos += src[this.pos + 1] === '\n' ? 2 : 1;
104
+ } else if (this.pos < src.length && src[this.pos] === '\n') {
105
+ this.pos += 1;
106
+ } else if (this.pos < src.length && src[this.pos]) {
107
+ throw new GrammarParseError(
108
+ src,
109
+ this.pos,
110
+ `Expecting newline or end at ${this.pos}`,
111
+ );
112
+ }
113
+ this.pos = parseSpace(src, this.pos, true);
114
+ }
115
+
116
+ getSymbolId(src: string, length: number): number {
117
+ const nextId = this.symbolIds.size;
118
+ const key = src.slice(0, length);
119
+ if (!this.symbolIds.has(key)) {
120
+ this.symbolIds.set(key, nextId, this.pos);
121
+ }
122
+ return this.symbolIds.get(key) as number;
123
+ }
124
+
125
+ generateSymbolId(baseName: string): number {
126
+ const nextId = this.symbolIds.size;
127
+ this.symbolIds.set(`${baseName}_${nextId}`, nextId, this.pos);
128
+ return nextId;
129
+ }
130
+
131
+ addRule(ruleId: number, rule: InternalRuleDef[]): void {
132
+ while (this.rules.length <= ruleId) {
133
+ this.rules.push([]);
134
+ }
135
+ this.rules[ruleId] = rule;
136
+ }
137
+
138
+ checkDuration(): void {
139
+ if ((performance.now() - this.start) / 1000 > this.timeLimit) {
140
+ throw new GrammarParseError(
141
+ this.src,
142
+ this.pos,
143
+ `Duration of ${this.timeLimit} exceeded`,
144
+ );
145
+ }
146
+ }
147
+
148
+ parseSequence(ruleName: string, outElements: InternalRuleDef[], depth = 0): void {
149
+ const isNested = depth !== 0;
150
+ const src = this.src;
151
+ let lastSymStart = outElements.length;
152
+
153
+ while (this.pos < src.length) {
154
+ const c = src[this.pos];
155
+ if (c === '"') {
156
+ this.pos += 1;
157
+ lastSymStart = outElements.length;
158
+ while (src[this.pos] !== '"') {
159
+ this.checkDuration();
160
+ const [value, incPos,] = parseChar(src, this.pos);
161
+ outElements.push({ type: InternalRuleType.CHAR, value: [value,], });
162
+ this.pos += incPos;
163
+ }
164
+ this.pos = parseSpace(src, this.pos + 1, isNested);
165
+ } else if (c === '[') {
166
+ this.pos += 1;
167
+ let startType: CharStartType = InternalRuleType.CHAR;
168
+ if (src[this.pos] === '^') {
169
+ this.pos += 1;
170
+ startType = InternalRuleType.CHAR_NOT;
171
+ }
172
+ lastSymStart = outElements.length;
173
+ while (src[this.pos] !== ']') {
174
+ this.checkDuration();
175
+ const type: CharStartType = lastSymStart < outElements.length
176
+ ? InternalRuleType.CHAR_ALT
177
+ : startType;
178
+ const [startcharValue, incPos,] = parseChar(src, this.pos);
179
+ this.pos += incPos;
180
+ outElements.push(getOutElements(type, startcharValue));
181
+
182
+ if (src[this.pos] === '-' && src[this.pos + 1] !== ']') {
183
+ this.pos += 1;
184
+ const [endcharValue, endIncPos,] = parseChar(src, this.pos);
185
+ outElements.push({ type: InternalRuleType.CHAR_RNG_UPPER, value: endcharValue, });
186
+ this.pos += endIncPos;
187
+ }
188
+ }
189
+ this.pos = parseSpace(src, this.pos + 1, isNested);
190
+ } else if (isWordChar(c)) {
191
+ const name = parseName(src, this.pos);
192
+ const refRuleId = this.getSymbolId(name, name.length);
193
+ this.pos += name.length;
194
+ this.pos = parseSpace(src, this.pos, isNested);
195
+
196
+ lastSymStart = outElements.length;
197
+ outElements.push({ type: InternalRuleType.REF, value: refRuleId, });
198
+ } else if (c === '(') {
199
+ this.pos = parseSpace(src, this.pos + 1, true);
200
+ const subRuleId = this.generateSymbolId(ruleName);
201
+ this.parseAlternates(ruleName, subRuleId, depth + 1);
202
+ lastSymStart = outElements.length;
203
+ outElements.push({ type: InternalRuleType.REF, value: subRuleId, });
204
+ if (src[this.pos] !== ')') {
205
+ throw new GrammarParseError(
206
+ src,
207
+ this.pos,
208
+ `Expecting ')' at ${this.pos}`,
209
+ );
210
+ }
211
+ this.pos = parseSpace(src, this.pos + 1, isNested);
212
+ } else if (c === '*' || c === '+' || c === '?') {
213
+ if (lastSymStart === outElements.length) {
214
+ throw new GrammarParseError(
215
+ src,
216
+ this.pos,
217
+ `Expecting preceding item to */+/? at ${this.pos}`,
218
+ );
219
+ }
220
+ const subRuleId = this.generateSymbolId(ruleName);
221
+ const subRule = outElements.slice(lastSymStart);
222
+ if (c === '*' || c === '+') {
223
+ subRule.push({ type: InternalRuleType.REF, value: subRuleId, });
224
+ }
225
+ subRule.push({ type: InternalRuleType.ALT, });
226
+ if (c === '+') {
227
+ subRule.push(...outElements.slice(lastSymStart));
228
+ }
229
+ subRule.push({ type: InternalRuleType.END, });
230
+ this.addRule(subRuleId, subRule);
231
+ outElements.splice(lastSymStart, outElements.length - lastSymStart, {
232
+ type: InternalRuleType.REF,
233
+ value: subRuleId,
234
+ });
235
+ this.pos = parseSpace(src, this.pos + 1, isNested);
236
+ } else {
237
+ break;
238
+ }
239
+ }
240
+ }
241
+
242
+ parseAlternates(ruleName: string, ruleId: number, depth = 0): void {
243
+ const src = this.src;
244
+ const rule: InternalRuleDef[] = [];
245
+ this.parseSequence(ruleName, rule, depth);
246
+ while (this.pos < src.length && src[this.pos] === '|') {
247
+ this.checkDuration();
248
+ rule.push({ type: InternalRuleType.ALT, });
249
+ this.pos = parseSpace(src, this.pos + 1, true);
250
+ this.parseSequence(ruleName, rule, depth);
251
+ }
252
+ rule.push({ type: InternalRuleType.END, });
253
+ this.addRule(ruleId, rule);
254
+ }
255
+ }
v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/rules-builder/symbol-ids.ts ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export class SymbolIds {
2
+ #map = new Map<string, number>();
3
+ #pos = new Map<string, number>();
4
+ #reverseMap = new Map<number, string>();
5
+
6
+ entries() {
7
+ return this.#map.entries();
8
+ }
9
+
10
+ [Symbol.iterator]() {
11
+ return this.#map.entries();
12
+ }
13
+
14
+ get size(): number {
15
+ return this.#map.size;
16
+ }
17
+
18
+ get(key: string): number | undefined {
19
+ return this.#map.get(key);
20
+ }
21
+
22
+ set(key: string, value: number, pos: number): void {
23
+ this.#map.set(key, value);
24
+ this.#reverseMap.set(value, key);
25
+ this.#pos.set(key, pos);
26
+ }
27
+
28
+ has(key: string): boolean {
29
+ return this.#map.has(key);
30
+ }
31
+
32
+ reverseGet(key: number): string {
33
+ const val = this.#reverseMap.get(key);
34
+ if (val === undefined) {
35
+ throw new Error(`SymbolIds does not contain value: ${key}`);
36
+ }
37
+ return val;
38
+ }
39
+
40
+ getPos(key: string): number {
41
+ const val = this.#pos.get(key);
42
+ if (val === undefined) {
43
+ throw new Error(`SymbolIds does not contain key: ${key}`);
44
+ }
45
+ return val;
46
+ }
47
+ }
v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/errors/build-error-position.ts ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export const MAXIMUM_NUMBER_OF_ERROR_LINES_TO_SHOW = 3;
2
+
3
+ export const buildErrorPosition = (src: string, pos: number): string[] => {
4
+ if (src === '') {
5
+ return [
6
+ 'No input provided',
7
+ ];
8
+ }
9
+ const lines = src.split('\n');
10
+
11
+ let lineIdx = 0;
12
+ while (lines[lineIdx] && pos > lines[lineIdx].length - 1 && pos < src.length) {
13
+ pos -= lines[lineIdx].length;
14
+ lineIdx += 1;
15
+ }
16
+
17
+ const linesToShow: string[] = [];
18
+ for (
19
+ let i = Math.max(0, lineIdx - (MAXIMUM_NUMBER_OF_ERROR_LINES_TO_SHOW - 1));
20
+ i < lineIdx + 1;
21
+ i++
22
+ ) {
23
+ if (i < lines.length) {
24
+ linesToShow.push(lines[i]);
25
+ }
26
+ }
27
+
28
+ return [
29
+ ...linesToShow,
30
+ `${' '.repeat(Math.max(0, pos))}^`,
31
+ ];
32
+ };
v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/errors/errors-types.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export type ValidInput = string | number | number[];
v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/errors/get-input-as-string.ts ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { ValidInput, } from './errors-types.ts';
2
+
3
+ export const getInputAsString = (src: ValidInput): string => {
4
+ if (typeof src === 'string') {
5
+ return src;
6
+ }
7
+ if (typeof src === 'number') {
8
+ return String.fromCodePoint(src);
9
+ }
10
+ return src.map((cp) => String.fromCodePoint(cp)).join('');
11
+ };
v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/errors/grammar-parse-error.ts ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { buildErrorPosition, } from './build-error-position.ts';
2
+
3
+ export const GRAMMAR_PARSER_ERROR_HEADER_MESSAGE = (reason: string): string =>
4
+ `Failed to parse grammar: ${reason}`;
5
+
6
+ const buildMessage = (grammar: string, pos: number, reason: string): string => [
7
+ GRAMMAR_PARSER_ERROR_HEADER_MESSAGE(reason),
8
+ '',
9
+ ...buildErrorPosition(grammar, pos),
10
+ ].join('\n');
11
+
12
+ export class GrammarParseError extends Error {
13
+ grammar: string;
14
+ pos: number;
15
+ reason: string;
16
+
17
+ constructor(grammar: string, pos: number, reason: string) {
18
+ super(buildMessage(grammar, pos, reason));
19
+ this.name = 'GrammarParseError';
20
+ this.grammar = grammar;
21
+ this.pos = pos;
22
+ this.reason = reason;
23
+ }
24
+
25
+ toString(): string {
26
+ return buildMessage(this.grammar, this.pos, this.reason);
27
+ }
28
+ }
v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/errors/index.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ export { GrammarParseError, } from './grammar-parse-error.ts';
2
+ export { InputParseError, } from './input-parse-error.ts';
v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/errors/input-parse-error.ts ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { buildErrorPosition, } from './build-error-position.ts';
2
+ import type { ValidInput, } from './errors-types.ts';
3
+ import { getInputAsString, } from './get-input-as-string.ts';
4
+
5
+ export const INPUT_PARSER_ERROR_HEADER_MESSAGE = 'Failed to parse input string:';
6
+
7
+ const buildMessage = (src: string, pos: number): string => [
8
+ INPUT_PARSER_ERROR_HEADER_MESSAGE,
9
+ '',
10
+ ...buildErrorPosition(src, pos),
11
+ ].join('\n');
12
+
13
+ export class InputParseError extends Error {
14
+ mostRecentInput: ValidInput;
15
+ pos: number;
16
+ previousInput: ValidInput;
17
+
18
+ constructor(mostRecentInput: ValidInput, pos: number, previousInput: ValidInput = '') {
19
+ const previous = getInputAsString(previousInput);
20
+ super(buildMessage(`${previous}${getInputAsString(mostRecentInput)}`, pos + previous.length));
21
+ this.name = 'InputParseError';
22
+ this.mostRecentInput = mostRecentInput;
23
+ this.pos = pos;
24
+ this.previousInput = previousInput;
25
+ }
26
+
27
+ get src(): string {
28
+ return `${getInputAsString(this.previousInput)}${getInputAsString(this.mostRecentInput)}`;
29
+ }
30
+
31
+ get errorForMostRecentInput(): string {
32
+ return buildMessage(getInputAsString(this.mostRecentInput), this.pos);
33
+ }
34
+
35
+ toString(): string {
36
+ return this.message;
37
+ }
38
+ }
v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/is-point-in-range.ts ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import type { Range, } from '../grammar-graph/grammar-graph-types.ts';
2
+
3
+ export const isPointInRange = (point: number, range: Range): boolean => {
4
+ if (!Number.isInteger(point)) {
5
+ throw new Error('point must be an integer');
6
+ }
7
+ return point >= range[0] && point <= range[1];
8
+ };
v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/src/utils/validate-non-empty.ts ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ export const validateNonEmpty = <T>(value: T[]): T[] => {
2
+ if (!value || value.length === 0) {
3
+ throw new Error('Value cannot be empty.');
4
+ }
5
+ return value;
6
+ };
v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/tsconfig.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "strict": true,
7
+ "allowImportingTsExtensions": true,
8
+ "verbatimModuleSyntax": true,
9
+ "erasableSyntaxOnly": true,
10
+ "noEmit": true,
11
+ "skipLibCheck": true
12
+ },
13
+ "include": ["src"]
14
+ }
v2-tests-configuration/runs/20261012T045715Z_96a77204/ported_implementation/vitest.config.integration.ts ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { fileURLToPath, } from 'node:url';
2
+
3
+ // Plain config object (no `vitest/config` import) so that it loads with a
4
+ // globally installed vitest as well as a locally installed one.
5
+ export default {
6
+ resolve: {
7
+ alias: {
8
+ gbnf: fileURLToPath(new URL('./src/index.ts', import.meta.url)),
9
+ },
10
+ },
11
+ test: {
12
+ include: [
13
+ 'integration-tests/**/*.test.ts',
14
+ 'generated-integration-tests/**/*.test.ts',
15
+ ],
16
+ exclude: [
17
+ 'src/**/*.ts',
18
+ ],
19
+ globals: true,
20
+ },
21
+ };
v2-tests-configuration/runs/20261012T045715Z_96a77204/proxy.log ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ NOTICE Oct 12 04:57:25.866 [1]: Initializing tinyproxy ...
2
+ NOTICE Oct 12 04:57:25.868 [1]: Reloading config file (/etc/tinyproxy/tinyproxy.conf)
3
+ INFO Oct 12 04:57:25.869 [1]: Added address [0.0.0.0] to listen addresses.
4
+ INFO Oct 12 04:57:25.870 [1]: Adding Port [443] to the list allowed by CONNECT
5
+ NOTICE Oct 12 04:57:25.871 [1]: Reloading config file finished
6
+ INFO Oct 12 04:57:25.873 [1]: listen_sock called with addr = '0.0.0.0'
7
+ INFO Oct 12 04:57:25.874 [1]: trying to listen on host[0.0.0.0], family[2], socktype[1], proto[6]
8
+ INFO Oct 12 04:57:25.876 [1]: listening on fd [3]
9
+ INFO Oct 12 04:57:25.877 [1]: Not running as root, so not changing UID/GID.
10
+ INFO Oct 12 04:57:25.878 [1]: Setting the various signals.
11
+ INFO Oct 12 04:57:25.879 [1]: Starting main loop. Accepting connections.
12
+ CONNECT Oct 12 04:57:26.324 [1]: Connect (file descriptor 5): 192.168.32.3
13
+ CONNECT Oct 12 04:57:26.325 [1]: Request (file descriptor 5): CONNECT api.anthropic.com:443 HTTP/1.1
14
+ INFO Oct 12 04:57:26.328 [1]: No upstream proxy for api.anthropic.com
15
+ INFO Oct 12 04:57:26.330 [1]: opensock: opening connection to api.anthropic.com:443
16
+ INFO Oct 12 04:57:26.332 [1]: opensock: getaddrinfo returned for api.anthropic.com:443
17
+ CONNECT Oct 12 04:57:26.360 [1]: Established connection to host "api.anthropic.com" using file descriptor 6.
18
+ INFO Oct 12 04:57:26.362 [1]: Not sending client headers to remote machine
19
+ INFO Oct 12 05:01:26.769 [1]: Closed connection between local client (fd:5) and remote client (fd:6)
v2-tests-configuration/runs/20261012T045715Z_96a77204/result.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"duration_api_ms":238000,"stop_reason":"end_turn","session_id":"afe0780f-9d02-4bec-ab19-b199608eaac1","total_cost_usd":1.1743611999999997,"usage":{"input_tokens":36,"cache_creation_input_tokens":78814,"cache_read_input_tokens":1022636,"output_tokens":28781,"output_tokens_details":{"thinking_tokens":5273},"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":78814},"inference_geo":"global","iterations":[],"speed":"standard","fallback_credit":null},"modelUsage":{"claude-opus-5-5":{"inputTokens":36,"outputTokens":28781,"cacheReadInputTokens":1022636,"cacheCreationInputTokens":78814,"webSearchRequests":0,"costUSD":1.1743611999999997,"contextWindow":1000000,"maxOutputTokens":128000,"thinkingTokens":5273,"canonicalModel":"claude-opus-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":0,"requested":{"background":0,"foreground":0,"unset":0},"started_in_background":0,"max_depth":0,"spawned_by_subagents":0,"completed":0,"failed":0,"killed":{"parent":0,"user":0,"system":0},"refused":{"depth_limit":0,"concurrency_limit":0,"budget":0},"by_type":{}},"safety_stops":0,"is_error":false,"num_turns":19,"subtype":"success","api_error_status":null,"result":"The TypeScript port is in `/target`, and all 773 tests in the provided integration suite pass (6 files).\n\n**How it's laid out**\n- `src/` has the same module structure as the Python package: `grammar-graph/`, `grammar-parser/`, `rules-builder/` and `utils/errors/`. `src/index.ts` exports `GBNF` as the default export, plus `ParseState`, `RuleChar`, `RuleCharExclude`, `RuleEnd`, `RuleType`, `GrammarParseError` and `InputParseError`.\n- The parse state is iterable, and the rules it yields look like `{ type: 'char' | 'char_exclude' | 'end', value }`, which is the shape the tests expect.\n- `InputParseError` has `errorForMostRecentInput` and builds the same messages as the Python version.\n\n**Setup changes you might trip over**\n- There's no TypeScript compiler and no network, so there's no build step. `package.json` points `gbnf` straight at `src/index.ts`. The source avoids TypeScript-only syntax like `enum`, so Node 24 can import it directly; I checked this with a quick script.\n- vitest is only installed globally, so `vitest.config.integration.ts` exports a plain object instead of importing from `vitest/config`, which wouldn't resolve here. It also maps `gbnf` to `src/index.ts`. The tests also pass with a minimal config that has no such mapping.\n- I copied the generated tests into `/target/integration-tests/generated/`. Run them with `vitest run --config vitest.config.integration.ts`.\n\n**Where it differs from the Python on purpose**\n- **Ordering:** a referenced rule's alternatives are stored in a JS `Set`, so they come out in insertion order. Python's `set` order isn't predictable, and the expected test outputs assume insertion order.\n- **Unicode:** characters outside the Basic Multilingual Plane (e.g. emoji) are read by code point when parsing a grammar, to make up for JS strings being UTF-16.\n- **Bad escapes:** an invalid `\\x`/`\\u` escape in a grammar raises `GrammarParseError`; the Python raises a plain `ValueError`.\n- **Edge cases:** where the Python would crash on an out-of-range position while building an error message, the port clamps the position and builds the message anyway.","ttft_ms":1715,"type":"result","duration_ms":240473,"uuid":"b19cdc1c-be00-4e94-b9ca-15d7e36686da","ttft_stream_ms":1518,"time_to_request_ms":45,"first_content_frame_ms":1518,"queued_turn_count":0,"result_index":0}
v2-tests-configuration/runs/20261012T045715Z_96a77204/run.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "params": {
3
+ "source-language": "python",
4
+ "include-unit-tests": false,
5
+ "include-source-integration-tests": false,
6
+ "include-target-integration-tests": true
7
+ },
8
+ "created": "2026-10-12T04:57:15Z",
9
+ "ended": "2026-10-12T05:01:27Z",
10
+ "exit_code": 0
11
+ }
v2-tests-configuration/runs/20261012T045715Z_96a77204/stderr.txt ADDED
File without changes
v2-tests-configuration/runs/20261012T045715Z_96a77204/transcript/.claude/projects/-target/afe0780f-9d02-4bec-ab19-b199608eaac1.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/manifest.json ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "timestamp": "2026-10-12T04:58:51Z",
3
+ "completed_at": "2026-10-12T05:05:55Z",
4
+ "exit_code": 0,
5
+ "study": "v2-test-configurations",
6
+ "condition": {
7
+ "name": "source-javascript_unit-tests_source-integration-tests_target-integration-tests_effort-medium_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": true,
13
+ "effort": "medium",
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
+ "python/Makefile",
97
+ "python/pyproject.toml",
98
+ "python/tests/generated/iteration/iteration_test.py",
99
+ "python/tests/generated/iteration/iteration_with_additional_strings_test.py",
100
+ "python/tests/generated/iteration/iteration_with_an_initial_string_test.py",
101
+ "python/tests/generated/validation/validate_grammar_test.py",
102
+ "python/tests/generated/validation/validate_input_test.py",
103
+ "python/uv.lock"
104
+ ]
105
+ },
106
+ "sandbox": {
107
+ "image_id": "sha256:fef66e757bac84d9615fe6080e2616945978225431d1ba6d165ca1bd688f3374"
108
+ },
109
+ "harness": {
110
+ "commit": "353d5b38f59a4ff542135ffe337cbfdf9199c5c5",
111
+ "dirty": true
112
+ }
113
+ }
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ *
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/.lock ADDED
File without changes
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/CACHEDIR.TAG ADDED
@@ -0,0 +1 @@
 
 
1
+ Signature: 8a477f597d28d172789f06886806bc55
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020-202x The virtualenv developers
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # This file must be used with "source bin/activate" *from bash*
23
+ # you cannot run it directly
24
+
25
+ if ! [ -z "${SCRIPT_PATH+_}" ] ; then
26
+ _OLD_SCRIPT_PATH="$SCRIPT_PATH"
27
+ fi
28
+
29
+ # Get script path (only used if environment is relocatable).
30
+ if [ -n "${BASH_VERSION:+x}" ] ; then
31
+ SCRIPT_PATH="${BASH_SOURCE[0]}"
32
+ if [ "$SCRIPT_PATH" = "$0" ]; then
33
+ # Only bash has a reasonably robust check for source'dness.
34
+ echo "You must source this script: \$ source $0" >&2
35
+ exit 33
36
+ fi
37
+ elif [ -n "${ZSH_VERSION:+x}" ] ; then
38
+ SCRIPT_PATH="${(%):-%x}"
39
+ elif [ -n "${KSH_VERSION:+x}" ] ; then
40
+ SCRIPT_PATH="${.sh.file}"
41
+ fi
42
+
43
+ deactivate () {
44
+ unset -f pydoc >/dev/null 2>&1 || true
45
+
46
+ # reset old environment variables
47
+ # ! [ -z ${VAR+_} ] returns true if VAR is declared at all
48
+ if ! [ -z "${_OLD_VIRTUAL_PATH:+_}" ] ; then
49
+ PATH="$_OLD_VIRTUAL_PATH"
50
+ export PATH
51
+ unset _OLD_VIRTUAL_PATH
52
+ fi
53
+ if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then
54
+ PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
55
+ export PYTHONHOME
56
+ unset _OLD_VIRTUAL_PYTHONHOME
57
+ fi
58
+
59
+ # The hash command must be called to get it to forget past
60
+ # commands. Without forgetting past commands the $PATH changes
61
+ # we made may not be respected
62
+ hash -r 2>/dev/null
63
+
64
+ if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then
65
+ PS1="$_OLD_VIRTUAL_PS1"
66
+ export PS1
67
+ unset _OLD_VIRTUAL_PS1
68
+ fi
69
+
70
+ unset VIRTUAL_ENV
71
+ unset VIRTUAL_ENV_PROMPT
72
+ if [ ! "${1-}" = "nondestructive" ] ; then
73
+ # Self destruct!
74
+ unset -f deactivate
75
+ fi
76
+ }
77
+
78
+ # unset irrelevant variables
79
+ deactivate nondestructive
80
+
81
+ VIRTUAL_ENV='/target/.venv'
82
+ if ([ "$OSTYPE" = "cygwin" ] || [ "$OSTYPE" = "msys" ]) && $(command -v cygpath &> /dev/null) ; then
83
+ VIRTUAL_ENV=$(cygpath -u "$VIRTUAL_ENV")
84
+ fi
85
+ export VIRTUAL_ENV
86
+
87
+ # Unset the `SCRIPT_PATH` variable, now that the `VIRTUAL_ENV` variable
88
+ # has been set. This is important for relocatable environments.
89
+ if ! [ -z "${_OLD_SCRIPT_PATH+_}" ] ; then
90
+ SCRIPT_PATH="$_OLD_SCRIPT_PATH"
91
+ export SCRIPT_PATH
92
+ unset _OLD_SCRIPT_PATH
93
+ else
94
+ unset SCRIPT_PATH
95
+ fi
96
+
97
+ _OLD_VIRTUAL_PATH="$PATH"
98
+ PATH="$VIRTUAL_ENV/bin:$PATH"
99
+ export PATH
100
+
101
+ if [ "xgbnf" != x ] ; then
102
+ VIRTUAL_ENV_PROMPT="gbnf"
103
+ else
104
+ VIRTUAL_ENV_PROMPT=$(basename "$VIRTUAL_ENV")
105
+ fi
106
+ export VIRTUAL_ENV_PROMPT
107
+
108
+ # unset PYTHONHOME if set
109
+ if ! [ -z "${PYTHONHOME+_}" ] ; then
110
+ _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
111
+ unset PYTHONHOME
112
+ fi
113
+
114
+ if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
115
+ _OLD_VIRTUAL_PS1="${PS1-}"
116
+ PS1="(${VIRTUAL_ENV_PROMPT}) ${PS1-}"
117
+ export PS1
118
+ fi
119
+
120
+ # Make sure to unalias pydoc if it's already there
121
+ alias pydoc 2>/dev/null >/dev/null && unalias pydoc || true
122
+
123
+ pydoc () {
124
+ python -m pydoc "$@"
125
+ }
126
+
127
+ # The hash command must be called to get it to forget past
128
+ # commands. Without forgetting past commands the $PATH changes
129
+ # we made may not be respected
130
+ hash -r 2>/dev/null || true
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate.bat ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @REM Copyright (c) 2020-202x The virtualenv developers
2
+ @REM
3
+ @REM Permission is hereby granted, free of charge, to any person obtaining
4
+ @REM a copy of this software and associated documentation files (the
5
+ @REM "Software"), to deal in the Software without restriction, including
6
+ @REM without limitation the rights to use, copy, modify, merge, publish,
7
+ @REM distribute, sublicense, and/or sell copies of the Software, and to
8
+ @REM permit persons to whom the Software is furnished to do so, subject to
9
+ @REM the following conditions:
10
+ @REM
11
+ @REM The above copyright notice and this permission notice shall be
12
+ @REM included in all copies or substantial portions of the Software.
13
+ @REM
14
+ @REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ @REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ @REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ @REM NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ @REM LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ @REM OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ @REM WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ @REM This file is UTF-8 encoded, so we need to update the current code page while executing it
23
+ @for /f "tokens=2 delims=:." %%a in ('"%SystemRoot%\System32\chcp.com"') do @set _OLD_CODEPAGE=%%a
24
+
25
+ @if defined _OLD_CODEPAGE (
26
+ "%SystemRoot%\System32\chcp.com" 65001 > nul
27
+ )
28
+
29
+ @for %%i in ("/target/.venv") do @set "VIRTUAL_ENV=%%~fi"
30
+
31
+ @set "VIRTUAL_ENV_PROMPT=gbnf"
32
+ @if NOT DEFINED VIRTUAL_ENV_PROMPT (
33
+ @for %%d in ("%VIRTUAL_ENV%") do @set "VIRTUAL_ENV_PROMPT=%%~nxd"
34
+ )
35
+
36
+ @if defined _OLD_VIRTUAL_PROMPT (
37
+ @set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
38
+ ) else (
39
+ @if not defined PROMPT (
40
+ @set "PROMPT=$P$G"
41
+ )
42
+ @if not defined VIRTUAL_ENV_DISABLE_PROMPT (
43
+ @set "_OLD_VIRTUAL_PROMPT=%PROMPT%"
44
+ )
45
+ )
46
+ @if not defined VIRTUAL_ENV_DISABLE_PROMPT (
47
+ @set "PROMPT=(%VIRTUAL_ENV_PROMPT%) %PROMPT%"
48
+ )
49
+
50
+ @REM Don't use () to avoid problems with them in %PATH%
51
+ @if defined _OLD_VIRTUAL_PYTHONHOME @goto ENDIFVHOME
52
+ @set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%"
53
+ :ENDIFVHOME
54
+
55
+ @set PYTHONHOME=
56
+
57
+ @REM if defined _OLD_VIRTUAL_PATH (
58
+ @if not defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH1
59
+ @set "PATH=%_OLD_VIRTUAL_PATH%"
60
+ :ENDIFVPATH1
61
+ @REM ) else (
62
+ @if defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH2
63
+ @set "_OLD_VIRTUAL_PATH=%PATH%"
64
+ :ENDIFVPATH2
65
+
66
+ @set "PATH=%VIRTUAL_ENV%\bin;%PATH%"
67
+
68
+ @if defined _OLD_CODEPAGE (
69
+ "%SystemRoot%\System32\chcp.com" %_OLD_CODEPAGE% > nul
70
+ @set _OLD_CODEPAGE=
71
+ )
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate.csh ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020-202x The virtualenv developers
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # This file must be used with "source bin/activate.csh" *from csh*.
23
+ # You cannot run it directly.
24
+ # Created by Davide Di Blasi <davidedb@gmail.com>.
25
+
26
+ set newline='\
27
+ '
28
+
29
+ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH:q" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT:q" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'
30
+
31
+ # Unset irrelevant variables.
32
+ deactivate nondestructive
33
+
34
+ setenv VIRTUAL_ENV '/target/.venv'
35
+
36
+ set _OLD_VIRTUAL_PATH="$PATH:q"
37
+ setenv PATH "$VIRTUAL_ENV:q/bin:$PATH:q"
38
+
39
+
40
+
41
+ if ('gbnf' != "") then
42
+ setenv VIRTUAL_ENV_PROMPT 'gbnf'
43
+ else
44
+ setenv VIRTUAL_ENV_PROMPT "$VIRTUAL_ENV:t:q"
45
+ endif
46
+
47
+ if ( $?VIRTUAL_ENV_DISABLE_PROMPT ) then
48
+ if ( $VIRTUAL_ENV_DISABLE_PROMPT == "" ) then
49
+ set do_prompt = "1"
50
+ else
51
+ set do_prompt = "0"
52
+ endif
53
+ else
54
+ set do_prompt = "1"
55
+ endif
56
+
57
+ if ( $do_prompt == "1" ) then
58
+ # Could be in a non-interactive environment,
59
+ # in which case, $prompt is undefined and we wouldn't
60
+ # care about the prompt anyway.
61
+ if ( $?prompt ) then
62
+ set _OLD_VIRTUAL_PROMPT="$prompt:q"
63
+ if ( "$prompt:q" =~ *"$newline:q"* ) then
64
+ :
65
+ else
66
+ set prompt = '('"$VIRTUAL_ENV_PROMPT:q"') '"$prompt:q"
67
+ endif
68
+ endif
69
+ endif
70
+
71
+ unset env_name
72
+ unset do_prompt
73
+
74
+ alias pydoc python -m pydoc
75
+
76
+ rehash
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate.fish ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020-202x The virtualenv developers
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # This file must be used using `source bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
23
+ # Do not run it directly.
24
+
25
+ function _bashify_path -d "Converts a fish path to something bash can recognize"
26
+ set fishy_path $argv
27
+ set bashy_path $fishy_path[1]
28
+ for path_part in $fishy_path[2..-1]
29
+ set bashy_path "$bashy_path:$path_part"
30
+ end
31
+ echo $bashy_path
32
+ end
33
+
34
+ function _fishify_path -d "Converts a bash path to something fish can recognize"
35
+ echo $argv | tr ':' '\n'
36
+ end
37
+
38
+ function deactivate -d 'Exit virtualenv mode and return to the normal environment.'
39
+ # reset old environment variables
40
+ if test -n "$_OLD_VIRTUAL_PATH"
41
+ # https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
42
+ if test (string sub -s 1 -l 1 $FISH_VERSION) -lt 3
43
+ set -gx PATH (_fishify_path "$_OLD_VIRTUAL_PATH")
44
+ else
45
+ set -gx PATH $_OLD_VIRTUAL_PATH
46
+ end
47
+ set -e _OLD_VIRTUAL_PATH
48
+ end
49
+
50
+ if test -n "$_OLD_VIRTUAL_PYTHONHOME"
51
+ set -gx PYTHONHOME "$_OLD_VIRTUAL_PYTHONHOME"
52
+ set -e _OLD_VIRTUAL_PYTHONHOME
53
+ end
54
+
55
+ if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
56
+ and functions -q _old_fish_prompt
57
+ # Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`.
58
+ set -l fish_function_path
59
+
60
+ # Erase virtualenv's `fish_prompt` and restore the original.
61
+ functions -e fish_prompt
62
+ functions -c _old_fish_prompt fish_prompt
63
+ functions -e _old_fish_prompt
64
+ set -e _OLD_FISH_PROMPT_OVERRIDE
65
+ end
66
+
67
+ set -e VIRTUAL_ENV
68
+ set -e VIRTUAL_ENV_PROMPT
69
+
70
+ if test "$argv[1]" != 'nondestructive'
71
+ # Self-destruct!
72
+ functions -e pydoc
73
+ functions -e deactivate
74
+ functions -e _bashify_path
75
+ functions -e _fishify_path
76
+ end
77
+ end
78
+
79
+ # Unset irrelevant variables.
80
+ deactivate nondestructive
81
+
82
+ set -gx VIRTUAL_ENV '/target/.venv'
83
+ if string match -qr 'CYGWIN|MSYS|MINGW' (uname); and command -s cygpath >/dev/null
84
+ set -gx VIRTUAL_ENV (cygpath -u "$VIRTUAL_ENV")
85
+ end
86
+
87
+ # https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
88
+ if test (string sub -s 1 -l 1 $FISH_VERSION) -lt 3
89
+ set -gx _OLD_VIRTUAL_PATH (_bashify_path $PATH)
90
+ else
91
+ set -gx _OLD_VIRTUAL_PATH $PATH
92
+ end
93
+ set -gx PATH "$VIRTUAL_ENV"'/bin' $PATH
94
+
95
+ # Prompt override provided?
96
+ # If not, just use the environment name.
97
+ if test -n 'gbnf'
98
+ set -gx VIRTUAL_ENV_PROMPT 'gbnf'
99
+ else
100
+ set -gx VIRTUAL_ENV_PROMPT (basename "$VIRTUAL_ENV")
101
+ end
102
+
103
+ # Unset `$PYTHONHOME` if set.
104
+ if set -q PYTHONHOME
105
+ set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
106
+ set -e PYTHONHOME
107
+ end
108
+
109
+ function pydoc
110
+ python -m pydoc $argv
111
+ end
112
+
113
+ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
114
+ # Copy the current `fish_prompt` function as `_old_fish_prompt`.
115
+ functions -c fish_prompt _old_fish_prompt
116
+
117
+ function fish_prompt
118
+ # Run the user's prompt first; it might depend on (pipe)status.
119
+ set -l prompt (_old_fish_prompt)
120
+
121
+ printf '(%s) ' $VIRTUAL_ENV_PROMPT
122
+
123
+ string join -- \n $prompt # handle multi-line prompts
124
+ end
125
+
126
+ set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
127
+ end
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate.nu ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020-202x The virtualenv developers
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # virtualenv activation module:
23
+ # - Activate with `overlay use activate.nu`
24
+ # - Deactivate with `deactivate`, as usual
25
+ #
26
+ # To customize the overlay name, call `overlay use activate.nu as foo`, but then `deactivate` won't work -
27
+ # you'd need to run `overlay hide foo` manually. Do not activate with `use activate.nu *`; that does not
28
+ # create an overlay and deactivation will fail.
29
+
30
+ module warning {
31
+ export-env {
32
+ const file = path self
33
+ error make -u {
34
+ msg: $"`($file | path basename)` is meant to be used with `overlay use`, not `source`"
35
+ }
36
+ }
37
+
38
+ }
39
+
40
+ use warning
41
+
42
+ export-env {
43
+
44
+ let nu_ver = (version | get version | split row '.' | take 2 | each { into int })
45
+ if $nu_ver.0 == 0 and $nu_ver.1 < 106 {
46
+ error make {
47
+ msg: 'virtualenv Nushell activation requires Nushell 0.106 or greater.'
48
+ }
49
+ }
50
+
51
+ def is-string [x] {
52
+ ($x | describe) == 'string'
53
+ }
54
+
55
+ def has-env [...names] {
56
+ $names | each {|n| $n in $env } | all {|i| $i }
57
+ }
58
+
59
+ def is-env-true [name: string] {
60
+ if (has-env $name) {
61
+ let val = ($env | get --optional $name)
62
+ if ($val | describe) == 'bool' {
63
+ $val
64
+ } else {
65
+ not ($val | is-empty)
66
+ }
67
+ } else {
68
+ false
69
+ }
70
+ }
71
+
72
+ let virtual_env = '/target/.venv'
73
+ let bin = 'bin'
74
+ let path_name = if (has-env 'Path') { 'Path' } else { 'PATH' }
75
+ let venv_path = ([$virtual_env $bin] | path join)
76
+ let new_path = ($env | get $path_name | prepend $venv_path)
77
+ let virtual_env_prompt = if ('gbnf' | is-empty) {
78
+ ($virtual_env | path basename)
79
+ } else {
80
+ 'gbnf'
81
+ }
82
+ let new_env = { $path_name: $new_path VIRTUAL_ENV: $virtual_env VIRTUAL_ENV_PROMPT: $virtual_env_prompt }
83
+ let old_prompt_command = if (has-env 'PROMPT_COMMAND') { $env.PROMPT_COMMAND } else { '' }
84
+ let new_env = if (is-env-true 'VIRTUAL_ENV_DISABLE_PROMPT') {
85
+ $new_env
86
+ } else {
87
+ let virtual_prefix = $'(char lparen)($virtual_env_prompt)(char rparen) '
88
+ let new_prompt = if (has-env 'PROMPT_COMMAND') {
89
+ if ('closure' in ($old_prompt_command | describe)) {
90
+ {|| $'($virtual_prefix)(do $old_prompt_command)' }
91
+ } else {
92
+ {|| $'($virtual_prefix)($old_prompt_command)' }
93
+ }
94
+ } else {
95
+ {|| $'($virtual_prefix)' }
96
+ }
97
+ $new_env | merge { PROMPT_COMMAND: $new_prompt VIRTUAL_PREFIX: $virtual_prefix }
98
+ }
99
+ load-env $new_env
100
+ }
101
+
102
+ export alias pydoc = python -m pydoc
103
+ # If deactivate errors "not an active overlay": activate with `overlay use activate.nu` not `use activate.nu *`; for custom names use `overlay hide NAME`
104
+ export alias deactivate = overlay hide activate
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate.ps1 ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020-202x The virtualenv developers
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ $script:THIS_PATH = $myinvocation.mycommand.path
23
+ $script:BASE_DIR = Split-Path (Resolve-Path "$THIS_PATH/..") -Parent
24
+
25
+ function global:deactivate([switch] $NonDestructive) {
26
+ if (Test-Path variable:_OLD_VIRTUAL_PATH) {
27
+ $env:PATH = $variable:_OLD_VIRTUAL_PATH
28
+ Remove-Variable "_OLD_VIRTUAL_PATH" -Scope global
29
+ }
30
+
31
+ if (Test-Path function:_old_virtual_prompt) {
32
+ $function:prompt = $function:_old_virtual_prompt
33
+ Remove-Item function:\_old_virtual_prompt
34
+ }
35
+
36
+ if ($env:VIRTUAL_ENV) {
37
+ Remove-Item env:VIRTUAL_ENV -ErrorAction SilentlyContinue
38
+ }
39
+
40
+ if ($env:VIRTUAL_ENV_PROMPT) {
41
+ Remove-Item env:VIRTUAL_ENV_PROMPT -ErrorAction SilentlyContinue
42
+ }
43
+
44
+ if (!$NonDestructive) {
45
+ # Self destruct!
46
+ Remove-Item function:deactivate
47
+ Remove-Item function:pydoc
48
+ }
49
+ }
50
+
51
+ function global:pydoc {
52
+ & python -m pydoc $args
53
+ }
54
+
55
+ # unset irrelevant variables
56
+ deactivate -nondestructive
57
+
58
+ $VIRTUAL_ENV = $BASE_DIR
59
+ $env:VIRTUAL_ENV = $VIRTUAL_ENV
60
+
61
+ if ("gbnf" -ne "") {
62
+ $env:VIRTUAL_ENV_PROMPT = "gbnf"
63
+ }
64
+ else {
65
+ $env:VIRTUAL_ENV_PROMPT = $( Split-Path $env:VIRTUAL_ENV -Leaf )
66
+ }
67
+
68
+ New-Variable -Scope global -Name _OLD_VIRTUAL_PATH -Value $env:PATH
69
+
70
+ $env:PATH = "$env:VIRTUAL_ENV/bin:" + $env:PATH
71
+ if (!$env:VIRTUAL_ENV_DISABLE_PROMPT) {
72
+ function global:_old_virtual_prompt {
73
+ ""
74
+ }
75
+ $function:_old_virtual_prompt = $function:prompt
76
+
77
+ function global:prompt {
78
+ # Add the custom prefix to the existing prompt
79
+ $previous_prompt_value = & $function:_old_virtual_prompt
80
+ ("(" + $env:VIRTUAL_ENV_PROMPT + ") " + $previous_prompt_value)
81
+ }
82
+ }
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate.xsh ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020-202x The virtualenv developers
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # This file must be used with "source bin/activate.xsh" *from xonsh*.
23
+ # You cannot run it directly.
24
+
25
+
26
+ class _VirtualEnvActivator:
27
+ """xonsh activation for virtualenv."""
28
+
29
+ # Stashed in _OLD_VIRTUAL_{name} when the variable was not set before
30
+ # activation. deactivate treats this as "unset" rather than "restore to
31
+ # this string".
32
+ _UNSET_SENTINEL = "__virtualenv_was_not_set__"
33
+
34
+ def __init__(self):
35
+ from os.path import dirname, realpath
36
+
37
+ self.env = __xonsh__.env
38
+ self.embedded_virtual_env = dirname(dirname(realpath(__file__)))
39
+ self.embedded_virtual_prompt = b"gbnf".decode("utf-8")
40
+ self.embedded_bin_name = __import__("os").fsdecode(b"bin")
41
+ self.managed_vars = ("PATH", "PYTHONHOME")
42
+
43
+ def _backup_name(self, name):
44
+ return f"_OLD_VIRTUAL_{name}"
45
+
46
+ def _save(self, name):
47
+ backup = self._backup_name(name)
48
+ self.env[backup] = self.env[name] if name in self.env else self._UNSET_SENTINEL
49
+
50
+ def _override(self, name, value):
51
+ self._save(name)
52
+ self.env[name] = value
53
+
54
+ def _drop(self, name):
55
+ self._save(name)
56
+ self.env.pop(name, None)
57
+
58
+ def register_pydoc(self):
59
+ aliases["pydoc"] = ["python", "-m", "pydoc"]
60
+
61
+ def unregister_pydoc(self):
62
+ aliases.pop("pydoc", None)
63
+
64
+ def activate(self):
65
+ from os.path import basename, join
66
+
67
+ aliases["deactivate"] = self.deactivate
68
+ self.deactivate(["nondestructive"]) # wipe any stale state from a prior activation
69
+
70
+ $VIRTUAL_ENV = self.embedded_virtual_env
71
+ $VIRTUAL_ENV_PROMPT = self.embedded_virtual_prompt or basename($VIRTUAL_ENV)
72
+
73
+ self._override("PATH", [join($VIRTUAL_ENV, self.embedded_bin_name), *$PATH])
74
+ self._drop("PYTHONHOME")
75
+ self.register_pydoc()
76
+
77
+ def deactivate(self, args=None):
78
+ for name in self.managed_vars:
79
+ backup = self._backup_name(name)
80
+ if backup not in self.env:
81
+ continue
82
+ previous = self.env[backup]
83
+ del self.env[backup]
84
+ if previous == self._UNSET_SENTINEL:
85
+ self.env.pop(name, None)
86
+ else:
87
+ self.env[name] = previous
88
+ for name in ("VIRTUAL_ENV", "VIRTUAL_ENV_PROMPT"):
89
+ self.env.pop(name, None)
90
+ self.unregister_pydoc()
91
+ if args is None or "nondestructive" not in args:
92
+ del aliases["deactivate"]
93
+ try:
94
+ del __xonsh__.xontrib.virtualenv
95
+ except AttributeError:
96
+ pass
97
+
98
+
99
+ if not hasattr(__xonsh__, "xontrib"):
100
+ __xonsh__.xontrib = __xonsh__.imp.types.SimpleNamespace()
101
+ __xonsh__.xontrib.virtualenv = _VirtualEnvActivator()
102
+ __xonsh__.xontrib.virtualenv.activate()
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/activate_this.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020-202x The virtualenv developers
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ """
23
+ Activate virtualenv for current interpreter:
24
+
25
+ import runpy
26
+ runpy.run_path(this_file)
27
+
28
+ This can be used when you must use an existing Python interpreter, not the virtualenv bin/python.
29
+ """ # noqa: D415
30
+
31
+ from __future__ import annotations
32
+
33
+ import os
34
+ import site
35
+ import sys
36
+
37
+ try:
38
+ abs_file = os.path.abspath(__file__)
39
+ except NameError as exc:
40
+ msg = "You must use import runpy; runpy.run_path(this_file)"
41
+ raise AssertionError(msg) from exc
42
+
43
+ bin_dir = os.path.dirname(abs_file)
44
+ base = bin_dir[: -len("bin") - 1] # strip away the bin part from the __file__, plus the path separator
45
+
46
+ # prepend bin to PATH (this file is inside the bin directory)
47
+ os.environ["PATH"] = os.pathsep.join([bin_dir, *os.environ.get("PATH", "").split(os.pathsep)])
48
+ os.environ["VIRTUAL_ENV"] = base # virtual env is right above bin directory
49
+ os.environ["VIRTUAL_ENV_PROMPT"] = "gbnf" or os.path.basename(base) # noqa: SIM222
50
+
51
+ # add the virtual environments libraries to the host python import mechanism
52
+ prev_length = len(sys.path)
53
+ for lib in "../lib/python3.14/site-packages".split(os.pathsep):
54
+ path = os.path.realpath(os.path.join(bin_dir, lib))
55
+ site.addsitedir(path)
56
+ sys.path[:] = sys.path[prev_length:] + sys.path[0:prev_length]
57
+
58
+ sys.real_prefix = sys.prefix
59
+ sys.prefix = base
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/deactivate.bat ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @REM Copyright (c) 2020-202x The virtualenv developers
2
+ @REM
3
+ @REM Permission is hereby granted, free of charge, to any person obtaining
4
+ @REM a copy of this software and associated documentation files (the
5
+ @REM "Software"), to deal in the Software without restriction, including
6
+ @REM without limitation the rights to use, copy, modify, merge, publish,
7
+ @REM distribute, sublicense, and/or sell copies of the Software, and to
8
+ @REM permit persons to whom the Software is furnished to do so, subject to
9
+ @REM the following conditions:
10
+ @REM
11
+ @REM The above copyright notice and this permission notice shall be
12
+ @REM included in all copies or substantial portions of the Software.
13
+ @REM
14
+ @REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ @REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ @REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ @REM NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ @REM LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ @REM OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ @REM WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ @set VIRTUAL_ENV=
23
+ @set VIRTUAL_ENV_PROMPT=
24
+
25
+ @REM Don't use () to avoid problems with them in %PATH%
26
+ @if not defined _OLD_VIRTUAL_PROMPT @goto ENDIFVPROMPT
27
+ @set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
28
+ @set _OLD_VIRTUAL_PROMPT=
29
+ :ENDIFVPROMPT
30
+
31
+ @if not defined _OLD_VIRTUAL_PYTHONHOME @goto ENDIFVHOME
32
+ @set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
33
+ @set _OLD_VIRTUAL_PYTHONHOME=
34
+ :ENDIFVHOME
35
+
36
+ @if not defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH
37
+ @set "PATH=%_OLD_VIRTUAL_PATH%"
38
+ @set _OLD_VIRTUAL_PATH=
39
+ :ENDIFVPATH
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/bin/pydoc.bat ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @REM Copyright (c) 2020-202x The virtualenv developers
2
+ @REM
3
+ @REM Permission is hereby granted, free of charge, to any person obtaining
4
+ @REM a copy of this software and associated documentation files (the
5
+ @REM "Software"), to deal in the Software without restriction, including
6
+ @REM without limitation the rights to use, copy, modify, merge, publish,
7
+ @REM distribute, sublicense, and/or sell copies of the Software, and to
8
+ @REM permit persons to whom the Software is furnished to do so, subject to
9
+ @REM the following conditions:
10
+ @REM
11
+ @REM The above copyright notice and this permission notice shall be
12
+ @REM included in all copies or substantial portions of the Software.
13
+ @REM
14
+ @REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ @REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ @REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ @REM NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ @REM LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ @REM OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ @REM WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ "python.exe" -m pydoc %*
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/lib/python3.14/site-packages/_virtualenv.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:69ac3d8f27e679c81b94ab30b3b56e9cd138219b1ba94a1fa3606d5a76a1433d
3
+ size 18
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/lib/python3.14/site-packages/_virtualenv.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Patches that are applied at runtime to the virtual environment."""
2
+
3
+ import contextlib
4
+ import os
5
+ import sys
6
+
7
+ VIRTUALENV_PATCH_FILE = os.path.abspath(__file__)
8
+
9
+
10
+ def patch_dist(dist):
11
+ """
12
+ Distutils allows user to configure some arguments via a configuration file:
13
+ https://docs.python.org/3.11/install/index.html#distutils-configuration-files.
14
+
15
+ Some of this arguments though don't make sense in context of the virtual environment files, let's fix them up.
16
+ """ # noqa: D205
17
+ # we cannot allow some install config as that would get packages installed outside of the virtual environment
18
+ old_parse_config_files = dist.Distribution.parse_config_files
19
+
20
+ def parse_config_files(self, *args, **kwargs):
21
+ result = old_parse_config_files(self, *args, **kwargs)
22
+ install = self.get_option_dict("install")
23
+
24
+ if "prefix" in install: # the prefix governs where to install the libraries
25
+ install["prefix"] = VIRTUALENV_PATCH_FILE, os.path.abspath(sys.prefix)
26
+ for base in ("purelib", "platlib", "headers", "scripts", "data"):
27
+ key = f"install_{base}"
28
+ if key in install: # do not allow global configs to hijack venv paths
29
+ install.pop(key, None)
30
+ return result
31
+
32
+ dist.Distribution.parse_config_files = parse_config_files
33
+
34
+
35
+ # Import hook that patches some modules to ignore configuration values that break package installation in case
36
+ # of virtual environments.
37
+ _DISTUTILS_PATCH = "distutils.dist", "setuptools.dist"
38
+ # https://docs.python.org/3/library/importlib.html#setting-up-an-importer
39
+
40
+
41
+ class _Finder:
42
+ """A meta path finder that allows patching the imported distutils modules."""
43
+
44
+ fullname = None
45
+
46
+ # lock[0] is threading.Lock(), but initialized lazily to avoid importing threading very early at startup,
47
+ # because there are gevent-based applications that need to be first to import threading by themselves.
48
+ # See https://github.com/pypa/virtualenv/issues/1895 for details.
49
+ lock = [] # noqa: RUF012
50
+
51
+ def find_spec(self, fullname, path, target=None): # noqa: ARG002
52
+ # Guard against race conditions during file rewrite by checking if _DISTUTILS_PATCH is defined.
53
+ # This can happen when the file is being overwritten while it's being imported by another process.
54
+ # See https://github.com/pypa/virtualenv/issues/2969 for details.
55
+ try:
56
+ distutils_patch = _DISTUTILS_PATCH
57
+ except NameError:
58
+ return None
59
+ if fullname in distutils_patch and self.fullname is None:
60
+ # initialize lock[0] lazily
61
+ if len(self.lock) == 0:
62
+ import threading
63
+
64
+ lock = threading.Lock()
65
+ # there is possibility that two threads T1 and T2 are simultaneously running into find_spec,
66
+ # observing .lock as empty, and further going into hereby initialization. However due to the GIL,
67
+ # list.append() operation is atomic and this way only one of the threads will "win" to put the lock
68
+ # - that every thread will use - into .lock[0].
69
+ # https://docs.python.org/3/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe
70
+ self.lock.append(lock)
71
+
72
+ from functools import partial
73
+ from importlib.util import find_spec
74
+
75
+ with self.lock[0]:
76
+ self.fullname = fullname
77
+ try:
78
+ spec = find_spec(fullname, path)
79
+ if spec is not None:
80
+ # https://www.python.org/dev/peps/pep-0451/#how-loading-will-work
81
+ is_new_api = hasattr(spec.loader, "exec_module")
82
+ func_name = "exec_module" if is_new_api else "load_module"
83
+ old = getattr(spec.loader, func_name)
84
+ func = self.exec_module if is_new_api else self.load_module
85
+ if old is not func:
86
+ try: # noqa: SIM105
87
+ setattr(spec.loader, func_name, partial(func, old))
88
+ except AttributeError:
89
+ pass # C-Extension loaders are r/o such as zipimporter with <3.7
90
+ return spec
91
+ finally:
92
+ self.fullname = None
93
+ return None
94
+
95
+ @staticmethod
96
+ def exec_module(old, module):
97
+ old(module)
98
+ try:
99
+ distutils_patch = _DISTUTILS_PATCH
100
+ except NameError:
101
+ return
102
+ if module.__name__ in distutils_patch:
103
+ # patch_dist or its dependencies may not be defined during file rewrite
104
+ with contextlib.suppress(NameError):
105
+ patch_dist(module)
106
+
107
+ @staticmethod
108
+ def load_module(old, name):
109
+ module = old(name)
110
+ try:
111
+ distutils_patch = _DISTUTILS_PATCH
112
+ except NameError:
113
+ return module
114
+ if module.__name__ in distutils_patch:
115
+ # patch_dist or its dependencies may not be defined during file rewrite
116
+ with contextlib.suppress(NameError):
117
+ patch_dist(module)
118
+ return module
119
+
120
+
121
+ sys.meta_path.insert(0, _Finder())
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/.venv/pyvenv.cfg ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ home = /usr/local/share/uv/python/cpython-3.14-linux-x86_64-gnu/bin
2
+ implementation = CPython
3
+ uv = 0.12.10
4
+ version_info = 3.14
5
+ include-system-site-packages = false
6
+ prompt = gbnf
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/Makefile ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ SHELL := /bin/bash
2
+
3
+ init:
4
+ uv venv --python python3.12 && uv sync
5
+
6
+ lint:
7
+ uvx ruff check . --fix
8
+
9
+ copy_assets:
10
+ cp ../../../LICENSE ./
11
+
12
+ build_all:
13
+ make copy_assets && make build_package
14
+
15
+ build_package:
16
+ uv run --with build -m build
17
+
18
+ upgrade_dev_dependencies:
19
+ ./upgrade_dev_dependencies.sh
20
+
21
+ build_test_writer:
22
+ cd ../../test-writer && pnpm build
23
+
24
+ write_integration_tests:
25
+ @echo "Writing integration tests..."
26
+ @$(MAKE) -s build_test_writer
27
+ @node --no-warnings ../../test-writer/dist/test-writer.mjs \
28
+ validation \
29
+ iteration/iteration \
30
+ --testDir ../test \
31
+ --targetDir ./tests/generated \
32
+ --language python
33
+
34
+ test_integration:
35
+ @$(MAKE) -s write_integration_tests
36
+ @$(MAKE) -s test_integration_only
37
+
38
+
39
+ test_integration_only:
40
+ uv run pytest ./tests/generated
41
+
42
+ # test_integration_watch:
43
+ # uv run ptw --now tests/generated
44
+
45
+ test:
46
+ make test_unit
47
+
48
+ test_unit:
49
+ uv run pytest ./gbnf/**/*_test.py
50
+
51
+ test_unit_watch:
52
+ uv run ptw --now .
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/README.md ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GBNF
2
+
3
+ A library for parsing `.gbnf` grammar files in Python. (Python port of the `gbnf` Javascript package.)
4
+
5
+ ## Usage
6
+
7
+ Pass your grammar to `GBNF`:
8
+
9
+ ```python
10
+ from gbnf import GBNF
11
+
12
+ state = GBNF("""
13
+ root ::= "yes" | "no"
14
+ """)
15
+ ```
16
+
17
+ If the grammar is invalid, `GBNF` raises a `GrammarParseError`.
18
+
19
+ `GBNF` returns a `ParseState` representing the parsed state:
20
+
21
+ ```python
22
+ for rule in state:
23
+ print(rule)
24
+ # RuleChar(value=[121], type=<RuleType.CHAR: 'char'>)
25
+ # RuleChar(value=[110], type=<RuleType.CHAR: 'char'>)
26
+ ```
27
+
28
+ `state` can be iterated over (you can also call `state.rules()` directly) and cast to a list with `[*state]`.
29
+
30
+ States are _immutable_. To parse a new token, call `state.add()` (or equivalently `state + "..."` or `state("...")`):
31
+
32
+ ```python
33
+ state = GBNF('root ::= "I like green eggs and ham"')
34
+ state = state.add("I li")
35
+ print([*state]) # [RuleChar(value=[ord("k")])]
36
+ state = state + "ke gree"
37
+ print([*state]) # [RuleChar(value=[ord("n")])]
38
+ ```
39
+
40
+ Invalid input raises an `InputParseError`.
41
+
42
+ The possible rules returned include:
43
+
44
+ - `RuleChar` (`type == "char"`) - contains a list of either code points to match, _or_ a two-element list denoting an inclusive range within which a code point may appear.
45
+ - `RuleCharExclude` (`type == "char_exclude"`) - contains a list of code points _not_ to match, _or_ two-element ranges within which a code point may _not_ appear.
46
+ - `RuleEnd` (`type == "end"`) - denotes a valid end of a string.
47
+
48
+ ## Tests
49
+
50
+ ```bash
51
+ pytest
52
+ ```
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/__init__.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .gbnf import GBNF
2
+ from .grammar_graph.parse_state import ParseState
3
+ from .grammar_graph.type_guards import is_range
4
+ from .grammar_graph.types import Range, ResolvedRule, RuleChar, RuleCharExclude, RuleEnd, RuleType
5
+ from .utils.errors.grammar_parse_error import GrammarParseError
6
+ from .utils.errors.input_parse_error import InputParseError
7
+
8
+ Rule = ResolvedRule
9
+
10
+ __all__ = [
11
+ "GBNF",
12
+ "GrammarParseError",
13
+ "InputParseError",
14
+ "ParseState",
15
+ "Range",
16
+ "Rule",
17
+ "RuleChar",
18
+ "RuleCharExclude",
19
+ "RuleEnd",
20
+ "RuleType",
21
+ "is_range",
22
+ ]
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/gbnf.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ from .grammar_graph.graph import Graph
4
+ from .grammar_graph.parse_state import ParseState
5
+ from .grammar_graph.types import ValidInput
6
+ from .grammar_parser.build_rule_stack import build_rule_stack
7
+ from .rules_builder import RulesBuilder
8
+ from .utils.errors.grammar_parse_error import GrammarParseError
9
+
10
+
11
+ def GBNF(input: object, initial_string: ValidInput = "") -> ParseState: # noqa: N802, A002
12
+ grammar = input if isinstance(input, str) else str(input)
13
+ rules_builder = RulesBuilder(grammar)
14
+ rules = rules_builder.rules
15
+ symbol_ids = rules_builder.symbol_ids
16
+ if len(rules) == 0:
17
+ raise GrammarParseError(grammar, 0, "No rules were found")
18
+ if not symbol_ids.has("root"):
19
+ raise GrammarParseError(
20
+ grammar,
21
+ 0,
22
+ f"Grammar does not contain a root symbol. Available symbols are: {json.dumps(list(symbol_ids.keys()))}",
23
+ )
24
+ root_id = symbol_ids.get("root")
25
+
26
+ stacked_rules = [build_rule_stack(rule) for rule in rules]
27
+ graph = Graph(grammar, stacked_rules, root_id)
28
+ return ParseState(graph, graph.add(initial_string))
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/gbnf_test.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from unittest.mock import MagicMock
3
+
4
+ import pytest
5
+
6
+ from . import gbnf as gbnf_module
7
+ from .gbnf import GBNF
8
+ from .rules_builder.symbol_ids import SymbolIds
9
+ from .rules_builder.types import InternalRuleDef, InternalRuleType
10
+ from .utils.errors.grammar_parse_error import GrammarParseError
11
+
12
+
13
+ class MockRulesBuilder:
14
+ def __init__(self, rules=None, symbol_ids=None):
15
+ self.rules = rules if rules is not None else []
16
+ self.symbol_ids = symbol_ids if symbol_ids is not None else SymbolIds()
17
+
18
+
19
+ @pytest.fixture
20
+ def mocks(monkeypatch):
21
+ """Mirror the JS vi.mock calls for RulesBuilder, build_rule_stack, Graph and ParseState."""
22
+ m = MagicMock()
23
+ m.RulesBuilder.side_effect = lambda _grammar: MockRulesBuilder()
24
+ m.build_rule_stack.side_effect = lambda rule: rule
25
+ m.mock_graph = MagicMock()
26
+ m.mock_graph.add.return_value = "foo"
27
+ m.Graph.return_value = m.mock_graph
28
+ m.mock_parse_state = object()
29
+ m.ParseState.return_value = m.mock_parse_state
30
+ for name in ("RulesBuilder", "build_rule_stack", "Graph", "ParseState"):
31
+ monkeypatch.setattr(gbnf_module, name, getattr(m, name))
32
+ return m
33
+
34
+
35
+ def make_symbol_ids(**entries):
36
+ symbol_ids = SymbolIds()
37
+ for pos, (key, value) in enumerate(entries.items()):
38
+ symbol_ids.set(key, value, pos)
39
+ return symbol_ids
40
+
41
+
42
+ def test_should_throw_if_rules_are_empty(mocks):
43
+ with pytest.raises(GrammarParseError) as exc_info:
44
+ GBNF("")
45
+ assert exc_info.value == GrammarParseError("", 0, "No rules were found")
46
+ assert str(exc_info.value) == str(GrammarParseError("", 0, "No rules were found"))
47
+
48
+
49
+ def test_should_throw_if_symbol_ids_does_not_have_root(mocks):
50
+ symbol_ids = make_symbol_ids(root1=1, root2=1)
51
+ mocks.RulesBuilder.side_effect = lambda _grammar: MockRulesBuilder(
52
+ [[InternalRuleDef(InternalRuleType.END)]],
53
+ symbol_ids,
54
+ )
55
+ # JS renders JSON.stringify(map.keys()) as "{}"; the Python port renders the actual list of keys.
56
+ expected = GrammarParseError(
57
+ "",
58
+ 0,
59
+ f"Grammar does not contain a root symbol. Available symbols are: {json.dumps(['root1', 'root2'])}",
60
+ )
61
+ with pytest.raises(GrammarParseError) as exc_info:
62
+ GBNF("")
63
+ assert exc_info.value == expected
64
+ assert exc_info.value.message == expected.message
65
+
66
+
67
+ def test_it_builds_parse_state(mocks):
68
+ grammar = "grammar"
69
+ initial_string = "foo"
70
+ symbol_ids = make_symbol_ids(root=1)
71
+ rules = [
72
+ [InternalRuleDef(InternalRuleType.END)],
73
+ [InternalRuleDef(InternalRuleType.CHAR, [97])],
74
+ ]
75
+ mocks.RulesBuilder.side_effect = lambda _grammar: MockRulesBuilder(rules, symbol_ids)
76
+
77
+ assert GBNF(grammar, initial_string) is mocks.mock_parse_state
78
+ mocks.RulesBuilder.assert_called_once_with(grammar)
79
+ # JS's Array.map passes (el, idx, arr); the Python port calls build_rule_stack(rule) only.
80
+ mocks.build_rule_stack.assert_any_call(rules[0])
81
+ mocks.build_rule_stack.assert_any_call(rules[1])
82
+ assert mocks.build_rule_stack.call_count == 2
83
+ mocks.Graph.assert_called_once_with(grammar, rules, 1)
84
+ mocks.mock_graph.add.assert_called_once_with(initial_string)
85
+ mocks.ParseState.assert_called_once_with(mocks.mock_graph, "foo")
86
+
87
+
88
+ def test_it_builds_parse_state_with_a_non_string_input(mocks):
89
+ # Adapted: the JS test uses the `g` template tag from ./builder/template-tags.js, which does not exist in
90
+ # the reference source. Any object with a string representation exercises the same code path.
91
+ class FakeGBNFRule:
92
+ def __str__(self) -> str:
93
+ return 'root ::= "foo"'
94
+
95
+ grammar = FakeGBNFRule()
96
+ symbol_ids = make_symbol_ids(root=1)
97
+ rules = [
98
+ [InternalRuleDef(InternalRuleType.END)],
99
+ [InternalRuleDef(InternalRuleType.CHAR, [97])],
100
+ ]
101
+ mocks.RulesBuilder.side_effect = lambda _grammar: MockRulesBuilder(rules, symbol_ids)
102
+
103
+ assert GBNF(grammar, "foo") is mocks.mock_parse_state
104
+ mocks.RulesBuilder.assert_called_once_with(str(grammar))
105
+ mocks.Graph.assert_called_once_with(str(grammar), rules, 1)
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from .graph import Graph
2
+
3
+ __all__ = ["Graph"]
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/colorize.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections.abc import Callable
2
+ from enum import StrEnum
3
+
4
+
5
+ class Color(StrEnum):
6
+ BLUE = "\x1b[34m"
7
+ CYAN = "\x1b[36m"
8
+ GREEN = "\x1b[32m"
9
+ RED = "\x1b[31m"
10
+ GRAY = "\x1b[90m"
11
+ YELLOW = "\x1b[33m"
12
+
13
+
14
+ def colorize(s: str | int, color: Color) -> str:
15
+ return f"{color}{s}"
16
+
17
+
18
+ Colorize = Callable[[str | int, Color], str]
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/colorize_test.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .colorize import Color, colorize
2
+
3
+
4
+ def test_should_colorize_strings_correctly():
5
+ assert colorize("hello", Color.BLUE) == "\x1b[34mhello"
6
+ assert colorize("test", Color.CYAN) == "\x1b[36mtest"
7
+ assert colorize("example", Color.GREEN) == "\x1b[32mexample"
8
+
9
+
10
+ def test_should_colorize_numbers_correctly():
11
+ assert colorize(123, Color.RED) == "\x1b[31m123"
12
+ assert colorize(456, Color.GRAY) == "\x1b[90m456"
13
+ assert colorize(789, Color.YELLOW) == "\x1b[33m789"
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/generic_set.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections.abc import Callable, Iterator
2
+ from typing import Generic, TypeVar
3
+
4
+ T = TypeVar("T")
5
+ K = TypeVar("K")
6
+
7
+
8
+ class GenericSet(Generic[T, K]):
9
+ """An insertion-ordered set whose uniqueness is determined by a key function."""
10
+
11
+ def __init__(self, get_key: Callable[[T], K]):
12
+ self.get_key = get_key
13
+ self._keys: dict[K, T] = {}
14
+
15
+ def add(self, el: T) -> None:
16
+ key = self.get_key(el)
17
+ if key not in self._keys:
18
+ self._keys[key] = el
19
+
20
+ def delete(self, el: T) -> None:
21
+ key = self.get_key(el)
22
+ if key not in self._keys:
23
+ raise KeyError("Could not get ref")
24
+ del self._keys[key]
25
+
26
+ def has(self, el: T) -> bool:
27
+ return any(v is el for v in self._keys.values())
28
+
29
+ def get(self, el: T) -> T | None:
30
+ return self._keys.get(self.get_key(el))
31
+
32
+ def __iter__(self) -> Iterator[T]:
33
+ yield from list(self._keys.values())
34
+
35
+ def __len__(self) -> int:
36
+ return len(self._keys)
37
+
38
+ @property
39
+ def size(self) -> int:
40
+ return len(self._keys)
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/generic_set_test.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .generic_set import GenericSet
2
+
3
+
4
+ def test_it_instantiates():
5
+ assert isinstance(GenericSet(lambda _el: "foo"), GenericSet)
6
+
7
+
8
+ def test_it_iterates():
9
+ s = GenericSet(lambda el: el)
10
+ s.add(1)
11
+ s.add(2)
12
+ s.add(3)
13
+ assert list(s) == [1, 2, 3]
14
+
15
+
16
+ def test_it_skips_duplicates():
17
+ s = GenericSet(lambda el: el)
18
+ s.add(1)
19
+ s.add(1)
20
+ s.add(1)
21
+ assert list(s) == [1]
22
+
23
+
24
+ def test_it_skips_duplicates_based_on_a_given_key():
25
+ s = GenericSet(lambda el: el["id"])
26
+ s.add({"id": 1})
27
+ s.add({"id": 1, "foo": "foo"})
28
+ s.add({"id": 1, "bar": "bar"})
29
+ assert list(s) == [{"id": 1}]
30
+
31
+
32
+ def test_can_delete():
33
+ s = GenericSet(lambda el: el["id"])
34
+ s.add({"id": 1})
35
+ s.delete({"id": 1})
36
+ s.add({"id": 2, "foo": "foo"})
37
+ s.add({"id": 2, "bar": "bar"})
38
+ assert list(s) == [{"id": 2, "foo": "foo"}]
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/get_input_as_code_points.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from .types import ValidInput
2
+
3
+
4
+ def get_input_as_code_points(src: ValidInput) -> list[int]:
5
+ if not isinstance(src, str):
6
+ return list(src) if isinstance(src, (list, tuple)) else [src]
7
+ return [ord(char) for char in src]
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/get_input_as_code_points_test.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .get_input_as_code_points import get_input_as_code_points
2
+
3
+
4
+ def test_it_returns_code_points_for_string():
5
+ assert get_input_as_code_points("abc") == [97, 98, 99]
6
+
7
+
8
+ def test_it_returns_code_points_for_number():
9
+ assert get_input_as_code_points(99) == [99]
10
+
11
+
12
+ def test_it_returns_code_points_for_array_of_number():
13
+ assert get_input_as_code_points([99, 100, 101]) == [99, 100, 101]
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/get_parent_stack_id.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from .colorize import Color, Colorize
6
+
7
+ if TYPE_CHECKING:
8
+ from .graph_pointer import GraphPointer
9
+
10
+
11
+ def get_parent_stack_id(pointer: GraphPointer, col: Colorize) -> str:
12
+ stack_ids: list[str] = []
13
+ parent = pointer.parent
14
+ while parent:
15
+ meta = parent.node.meta
16
+ stack_ids.append(f"{meta['stack_id']},{meta['path_id']},{meta['step_id']}")
17
+ parent = parent.parent
18
+ return col("<-", Color.GRAY).join(col(id_, Color.RED) for id_ in stack_ids)
v2-tests-configuration/runs/20261012T045851Z_820d0eb1/ported_implementation/gbnf/grammar_graph/get_parent_stack_id_test.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from types import SimpleNamespace
3
+
4
+ from .colorize import Color
5
+ from .get_parent_stack_id import get_parent_stack_id
6
+
7
+
8
+ def s(string: str) -> str:
9
+ return json.dumps(string)
10
+
11
+
12
+ def mock_colorize(text, color):
13
+ return f"[{s(color)}]:{text}"
14
+
15
+
16
+ red = s(Color.RED)
17
+ gray = s(Color.GRAY)
18
+
19
+
20
+ def create_mock_pointer(stack_id, path_id, step_id, parent=None):
21
+ return SimpleNamespace(
22
+ node=SimpleNamespace(meta={"stack_id": stack_id, "path_id": path_id, "step_id": step_id}),
23
+ parent=parent,
24
+ )
25
+
26
+
27
+ def test_returns_an_empty_string_if_no_parents():
28
+ pointer = create_mock_pointer(1, 1, 1)
29
+ assert get_parent_stack_id(pointer, mock_colorize) == ""
30
+
31
+
32
+ def test_returns_a_single_parent_id_colored_correctly():
33
+ parent_pointer = create_mock_pointer(1, 1, 1)
34
+ pointer = create_mock_pointer(2, 2, 2, parent_pointer)
35
+ assert get_parent_stack_id(pointer, mock_colorize) == f"[{red}]:1,1,1"
36
+
37
+
38
+ def test_returns_multiple_parent_ids_separated_by_colored_arrows():
39
+ grandparent_pointer = create_mock_pointer(0, 0, 0)
40
+ parent_pointer = create_mock_pointer(1, 1, 1, grandparent_pointer)
41
+ pointer = create_mock_pointer(2, 2, 2, parent_pointer)
42
+ expected = f"[{red}]:1,1,1[{gray}]:<-[{red}]:0,0,0"
43
+ assert get_parent_stack_id(pointer, mock_colorize) == expected
44
+
45
+
46
+ def test_handles_deep_nesting_of_pointers():
47
+ great_grandparent_pointer = create_mock_pointer(0, 0, 0)
48
+ grandparent_pointer = create_mock_pointer(1, 1, 1, great_grandparent_pointer)
49
+ parent_pointer = create_mock_pointer(2, 2, 2, grandparent_pointer)
50
+ pointer = create_mock_pointer(3, 3, 3, parent_pointer)
51
+ expected = f"[{red}]:2,2,2[{gray}]:<-[{red}]:1,1,1[{gray}]:<-[{red}]:0,0,0"
52
+ assert get_parent_stack_id(pointer, mock_colorize) == expected