Datasets:

Modalities:
Tabular
Text
Formats:
parquet
Languages:
English
ArXiv:
License:
William-Li commited on
Commit
9379442
·
verified ·
1 Parent(s): b34004b

Upload folder using huggingface_hub

Browse files
Files changed (41) hide show
  1. .gitattributes +0 -59
  2. .gitignore +4 -0
  3. CHANGELOG.md +7 -0
  4. LICENSE +22 -0
  5. LICENSES/Apache-2.0.txt +202 -0
  6. LICENSES/CC-BY-4.0.txt +396 -0
  7. LICENSES/CC-BY-NC-4.0.txt +408 -0
  8. NOTICE.md +14 -0
  9. README.md +78 -1
  10. data/kodcode/rl/train.parquet +3 -0
  11. data/kodcode/rl/validation.parquet +3 -0
  12. data/kodcode/sft/train.parquet +3 -0
  13. data/kodcode/sft/validation.parquet +3 -0
  14. data/taco_leetcode/rl/train.parquet +3 -0
  15. data/taco_leetcode/rl/validation.parquet +3 -0
  16. data/taco_leetcode/sft/train.parquet +3 -0
  17. data/taco_leetcode/sft/validation.parquet +3 -0
  18. docs/kodcode.md +18 -0
  19. docs/rl_verification.md +24 -0
  20. docs/taco_leetcode.md +26 -0
  21. metadata/content_preservation.json +29 -0
  22. metadata/kodcode/ablation_membership.json +0 -0
  23. metadata/kodcode/dataset_manifest.json +156 -0
  24. metadata/kodcode/source_manifest.json +63 -0
  25. metadata/kodcode/taxonomy.json +84 -0
  26. metadata/release_files.json +165 -0
  27. metadata/taco_leetcode/ablation_membership.json +0 -0
  28. metadata/taco_leetcode/dataset_manifest.json +129 -0
  29. metadata/taco_leetcode/source_manifest.json +98 -0
  30. metadata/taco_leetcode/taxonomy.json +31 -0
  31. metadata/validation_report.json +69 -0
  32. requirements.txt +3 -0
  33. scripts/build_kodcode.py +70 -0
  34. scripts/build_taco_leetcode.py +141 -0
  35. scripts/release_utils.py +87 -0
  36. scripts/validate_release.py +174 -0
  37. verification/kodcode_reward.py +254 -0
  38. verification/requirements.txt +9 -0
  39. verification/smoke_test.py +20 -0
  40. verification/stage3_reward_base.py +540 -0
  41. verification/taco_leetcode_reward.py +541 -0
.gitattributes CHANGED
@@ -1,60 +1 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.avro filter=lfs diff=lfs merge=lfs -text
4
- *.bin filter=lfs diff=lfs merge=lfs -text
5
- *.bz2 filter=lfs diff=lfs merge=lfs -text
6
- *.ckpt filter=lfs diff=lfs merge=lfs -text
7
- *.ftz filter=lfs diff=lfs merge=lfs -text
8
- *.gz filter=lfs diff=lfs merge=lfs -text
9
- *.h5 filter=lfs diff=lfs merge=lfs -text
10
- *.joblib filter=lfs diff=lfs merge=lfs -text
11
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
12
- *.lz4 filter=lfs diff=lfs merge=lfs -text
13
- *.mds filter=lfs diff=lfs merge=lfs -text
14
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
15
- *.model filter=lfs diff=lfs merge=lfs -text
16
- *.msgpack filter=lfs diff=lfs merge=lfs -text
17
- *.npy filter=lfs diff=lfs merge=lfs -text
18
- *.npz filter=lfs diff=lfs merge=lfs -text
19
- *.onnx filter=lfs diff=lfs merge=lfs -text
20
- *.ot filter=lfs diff=lfs merge=lfs -text
21
  *.parquet filter=lfs diff=lfs merge=lfs -text
22
- *.pb filter=lfs diff=lfs merge=lfs -text
23
- *.pickle filter=lfs diff=lfs merge=lfs -text
24
- *.pkl filter=lfs diff=lfs merge=lfs -text
25
- *.pt filter=lfs diff=lfs merge=lfs -text
26
- *.pth filter=lfs diff=lfs merge=lfs -text
27
- *.rar filter=lfs diff=lfs merge=lfs -text
28
- *.safetensors filter=lfs diff=lfs merge=lfs -text
29
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
30
- *.tar.* filter=lfs diff=lfs merge=lfs -text
31
- *.tar filter=lfs diff=lfs merge=lfs -text
32
- *.tflite filter=lfs diff=lfs merge=lfs -text
33
- *.tgz filter=lfs diff=lfs merge=lfs -text
34
- *.wasm filter=lfs diff=lfs merge=lfs -text
35
- *.xz filter=lfs diff=lfs merge=lfs -text
36
- *.zip filter=lfs diff=lfs merge=lfs -text
37
- *.zst filter=lfs diff=lfs merge=lfs -text
38
- *tfevents* filter=lfs diff=lfs merge=lfs -text
39
- # Audio files - uncompressed
40
- *.pcm filter=lfs diff=lfs merge=lfs -text
41
- *.sam filter=lfs diff=lfs merge=lfs -text
42
- *.raw filter=lfs diff=lfs merge=lfs -text
43
- # Audio files - compressed
44
- *.aac filter=lfs diff=lfs merge=lfs -text
45
- *.flac filter=lfs diff=lfs merge=lfs -text
46
- *.mp3 filter=lfs diff=lfs merge=lfs -text
47
- *.ogg filter=lfs diff=lfs merge=lfs -text
48
- *.wav filter=lfs diff=lfs merge=lfs -text
49
- # Image files - uncompressed
50
- *.bmp filter=lfs diff=lfs merge=lfs -text
51
- *.gif filter=lfs diff=lfs merge=lfs -text
52
- *.png filter=lfs diff=lfs merge=lfs -text
53
- *.tiff filter=lfs diff=lfs merge=lfs -text
54
- # Image files - compressed
55
- *.jpg filter=lfs diff=lfs merge=lfs -text
56
- *.jpeg filter=lfs diff=lfs merge=lfs -text
57
- *.webp filter=lfs diff=lfs merge=lfs -text
58
- # Video files - compressed
59
- *.mp4 filter=lfs diff=lfs merge=lfs -text
60
- *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  *.parquet filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ .cache/
CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Changes
2
+
3
+ ## 1.0.0 — 2026-09-07
4
+
5
+ - Four Parquet configurations with train and validation splits.
6
+ - Added a fixed 100-problem TACO SFT holdout; preserved historical memberships.
7
+ - Included taxonomies, source/file manifests, reward code, and validation scripts.
LICENSE ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ SOURCE-SPECIFIC DATA LICENSES
2
+
3
+ This dataset combines separately licensed sources. No single permissive license
4
+ replaces the terms of the underlying records.
5
+
6
+ KodCode-derived data (data/kodcode/): Creative Commons Attribution-
7
+ NonCommercial 4.0 International (CC BY-NC 4.0).
8
+ https://creativecommons.org/licenses/by-nc/4.0/legalcode
9
+
10
+ TACO-derived data (TACO records in data/taco_leetcode/): the upstream release
11
+ states Apache License 2.0, with additional source-specific MIT / CC BY 4.0
12
+ material and source-rights qualifications. Those upstream terms remain.
13
+ https://huggingface.co/datasets/BAAI/TACO#license
14
+ https://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ LeetCodeDataset-derived data (leetcode2k records in data/taco_leetcode/):
17
+ the upstream release declares Apache License 2.0; preserve source attribution.
18
+ https://huggingface.co/datasets/newfacade/LeetCodeDataset
19
+
20
+ Source attribution and references are in NOTICE.md. Packaging and metadata do
21
+ not remove upstream conditions. No separate code license is asserted here.
22
+ Copies of the Apache 2.0, CC BY-NC 4.0 and CC BY 4.0 texts are in LICENSES/.
LICENSES/Apache-2.0.txt ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
LICENSES/CC-BY-4.0.txt ADDED
@@ -0,0 +1,396 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Attribution 4.0 International
2
+
3
+ =======================================================================
4
+
5
+ Creative Commons Corporation ("Creative Commons") is not a law firm and
6
+ does not provide legal services or legal advice. Distribution of
7
+ Creative Commons public licenses does not create a lawyer-client or
8
+ other relationship. Creative Commons makes its licenses and related
9
+ information available on an "as-is" basis. Creative Commons gives no
10
+ warranties regarding its licenses, any material licensed under their
11
+ terms and conditions, or any related information. Creative Commons
12
+ disclaims all liability for damages resulting from their use to the
13
+ fullest extent possible.
14
+
15
+ Using Creative Commons Public Licenses
16
+
17
+ Creative Commons public licenses provide a standard set of terms and
18
+ conditions that creators and other rights holders may use to share
19
+ original works of authorship and other material subject to copyright
20
+ and certain other rights specified in the public license below. The
21
+ following considerations are for informational purposes only, are not
22
+ exhaustive, and do not form part of our licenses.
23
+
24
+ Considerations for licensors: Our public licenses are
25
+ intended for use by those authorized to give the public
26
+ permission to use material in ways otherwise restricted by
27
+ copyright and certain other rights. Our licenses are
28
+ irrevocable. Licensors should read and understand the terms
29
+ and conditions of the license they choose before applying it.
30
+ Licensors should also secure all rights necessary before
31
+ applying our licenses so that the public can reuse the
32
+ material as expected. Licensors should clearly mark any
33
+ material not subject to the license. This includes other CC-
34
+ licensed material, or material used under an exception or
35
+ limitation to copyright. More considerations for licensors:
36
+ wiki.creativecommons.org/Considerations_for_licensors
37
+
38
+ Considerations for the public: By using one of our public
39
+ licenses, a licensor grants the public permission to use the
40
+ licensed material under specified terms and conditions. If
41
+ the licensor's permission is not necessary for any reason--for
42
+ example, because of any applicable exception or limitation to
43
+ copyright--then that use is not regulated by the license. Our
44
+ licenses grant only permissions under copyright and certain
45
+ other rights that a licensor has authority to grant. Use of
46
+ the licensed material may still be restricted for other
47
+ reasons, including because others have copyright or other
48
+ rights in the material. A licensor may make special requests,
49
+ such as asking that all changes be marked or described.
50
+ Although not required by our licenses, you are encouraged to
51
+ respect those requests where reasonable. More considerations
52
+ for the public:
53
+ wiki.creativecommons.org/Considerations_for_licensees
54
+
55
+ =======================================================================
56
+
57
+ Creative Commons Attribution 4.0 International Public License
58
+
59
+ By exercising the Licensed Rights (defined below), You accept and agree
60
+ to be bound by the terms and conditions of this Creative Commons
61
+ Attribution 4.0 International Public License ("Public License"). To the
62
+ extent this Public License may be interpreted as a contract, You are
63
+ granted the Licensed Rights in consideration of Your acceptance of
64
+ these terms and conditions, and the Licensor grants You such rights in
65
+ consideration of benefits the Licensor receives from making the
66
+ Licensed Material available under these terms and conditions.
67
+
68
+
69
+ Section 1 -- Definitions.
70
+
71
+ a. Adapted Material means material subject to Copyright and Similar
72
+ Rights that is derived from or based upon the Licensed Material
73
+ and in which the Licensed Material is translated, altered,
74
+ arranged, transformed, or otherwise modified in a manner requiring
75
+ permission under the Copyright and Similar Rights held by the
76
+ Licensor. For purposes of this Public License, where the Licensed
77
+ Material is a musical work, performance, or sound recording,
78
+ Adapted Material is always produced where the Licensed Material is
79
+ synched in timed relation with a moving image.
80
+
81
+ b. Adapter's License means the license You apply to Your Copyright
82
+ and Similar Rights in Your contributions to Adapted Material in
83
+ accordance with the terms and conditions of this Public License.
84
+
85
+ c. Copyright and Similar Rights means copyright and/or similar rights
86
+ closely related to copyright including, without limitation,
87
+ performance, broadcast, sound recording, and Sui Generis Database
88
+ Rights, without regard to how the rights are labeled or
89
+ categorized. For purposes of this Public License, the rights
90
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
91
+ Rights.
92
+
93
+ d. Effective Technological Measures means those measures that, in the
94
+ absence of proper authority, may not be circumvented under laws
95
+ fulfilling obligations under Article 11 of the WIPO Copyright
96
+ Treaty adopted on December 20, 1996, and/or similar international
97
+ agreements.
98
+
99
+ e. Exceptions and Limitations means fair use, fair dealing, and/or
100
+ any other exception or limitation to Copyright and Similar Rights
101
+ that applies to Your use of the Licensed Material.
102
+
103
+ f. Licensed Material means the artistic or literary work, database,
104
+ or other material to which the Licensor applied this Public
105
+ License.
106
+
107
+ g. Licensed Rights means the rights granted to You subject to the
108
+ terms and conditions of this Public License, which are limited to
109
+ all Copyright and Similar Rights that apply to Your use of the
110
+ Licensed Material and that the Licensor has authority to license.
111
+
112
+ h. Licensor means the individual(s) or entity(ies) granting rights
113
+ under this Public License.
114
+
115
+ i. Share means to provide material to the public by any means or
116
+ process that requires permission under the Licensed Rights, such
117
+ as reproduction, public display, public performance, distribution,
118
+ dissemination, communication, or importation, and to make material
119
+ available to the public including in ways that members of the
120
+ public may access the material from a place and at a time
121
+ individually chosen by them.
122
+
123
+ j. Sui Generis Database Rights means rights other than copyright
124
+ resulting from Directive 96/9/EC of the European Parliament and of
125
+ the Council of 11 March 1996 on the legal protection of databases,
126
+ as amended and/or succeeded, as well as other essentially
127
+ equivalent rights anywhere in the world.
128
+
129
+ k. You means the individual or entity exercising the Licensed Rights
130
+ under this Public License. Your has a corresponding meaning.
131
+
132
+
133
+ Section 2 -- Scope.
134
+
135
+ a. License grant.
136
+
137
+ 1. Subject to the terms and conditions of this Public License,
138
+ the Licensor hereby grants You a worldwide, royalty-free,
139
+ non-sublicensable, non-exclusive, irrevocable license to
140
+ exercise the Licensed Rights in the Licensed Material to:
141
+
142
+ a. reproduce and Share the Licensed Material, in whole or
143
+ in part; and
144
+
145
+ b. produce, reproduce, and Share Adapted Material.
146
+
147
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
148
+ Exceptions and Limitations apply to Your use, this Public
149
+ License does not apply, and You do not need to comply with
150
+ its terms and conditions.
151
+
152
+ 3. Term. The term of this Public License is specified in Section
153
+ 6(a).
154
+
155
+ 4. Media and formats; technical modifications allowed. The
156
+ Licensor authorizes You to exercise the Licensed Rights in
157
+ all media and formats whether now known or hereafter created,
158
+ and to make technical modifications necessary to do so. The
159
+ Licensor waives and/or agrees not to assert any right or
160
+ authority to forbid You from making technical modifications
161
+ necessary to exercise the Licensed Rights, including
162
+ technical modifications necessary to circumvent Effective
163
+ Technological Measures. For purposes of this Public License,
164
+ simply making modifications authorized by this Section 2(a)
165
+ (4) never produces Adapted Material.
166
+
167
+ 5. Downstream recipients.
168
+
169
+ a. Offer from the Licensor -- Licensed Material. Every
170
+ recipient of the Licensed Material automatically
171
+ receives an offer from the Licensor to exercise the
172
+ Licensed Rights under the terms and conditions of this
173
+ Public License.
174
+
175
+ b. No downstream restrictions. You may not offer or impose
176
+ any additional or different terms or conditions on, or
177
+ apply any Effective Technological Measures to, the
178
+ Licensed Material if doing so restricts exercise of the
179
+ Licensed Rights by any recipient of the Licensed
180
+ Material.
181
+
182
+ 6. No endorsement. Nothing in this Public License constitutes or
183
+ may be construed as permission to assert or imply that You
184
+ are, or that Your use of the Licensed Material is, connected
185
+ with, or sponsored, endorsed, or granted official status by,
186
+ the Licensor or others designated to receive attribution as
187
+ provided in Section 3(a)(1)(A)(i).
188
+
189
+ b. Other rights.
190
+
191
+ 1. Moral rights, such as the right of integrity, are not
192
+ licensed under this Public License, nor are publicity,
193
+ privacy, and/or other similar personality rights; however, to
194
+ the extent possible, the Licensor waives and/or agrees not to
195
+ assert any such rights held by the Licensor to the limited
196
+ extent necessary to allow You to exercise the Licensed
197
+ Rights, but not otherwise.
198
+
199
+ 2. Patent and trademark rights are not licensed under this
200
+ Public License.
201
+
202
+ 3. To the extent possible, the Licensor waives any right to
203
+ collect royalties from You for the exercise of the Licensed
204
+ Rights, whether directly or through a collecting society
205
+ under any voluntary or waivable statutory or compulsory
206
+ licensing scheme. In all other cases the Licensor expressly
207
+ reserves any right to collect such royalties.
208
+
209
+
210
+ Section 3 -- License Conditions.
211
+
212
+ Your exercise of the Licensed Rights is expressly made subject to the
213
+ following conditions.
214
+
215
+ a. Attribution.
216
+
217
+ 1. If You Share the Licensed Material (including in modified
218
+ form), You must:
219
+
220
+ a. retain the following if it is supplied by the Licensor
221
+ with the Licensed Material:
222
+
223
+ i. identification of the creator(s) of the Licensed
224
+ Material and any others designated to receive
225
+ attribution, in any reasonable manner requested by
226
+ the Licensor (including by pseudonym if
227
+ designated);
228
+
229
+ ii. a copyright notice;
230
+
231
+ iii. a notice that refers to this Public License;
232
+
233
+ iv. a notice that refers to the disclaimer of
234
+ warranties;
235
+
236
+ v. a URI or hyperlink to the Licensed Material to the
237
+ extent reasonably practicable;
238
+
239
+ b. indicate if You modified the Licensed Material and
240
+ retain an indication of any previous modifications; and
241
+
242
+ c. indicate the Licensed Material is licensed under this
243
+ Public License, and include the text of, or the URI or
244
+ hyperlink to, this Public License.
245
+
246
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
247
+ reasonable manner based on the medium, means, and context in
248
+ which You Share the Licensed Material. For example, it may be
249
+ reasonable to satisfy the conditions by providing a URI or
250
+ hyperlink to a resource that includes the required
251
+ information.
252
+
253
+ 3. If requested by the Licensor, You must remove any of the
254
+ information required by Section 3(a)(1)(A) to the extent
255
+ reasonably practicable.
256
+
257
+ 4. If You Share Adapted Material You produce, the Adapter's
258
+ License You apply must not prevent recipients of the Adapted
259
+ Material from complying with this Public License.
260
+
261
+
262
+ Section 4 -- Sui Generis Database Rights.
263
+
264
+ Where the Licensed Rights include Sui Generis Database Rights that
265
+ apply to Your use of the Licensed Material:
266
+
267
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
268
+ to extract, reuse, reproduce, and Share all or a substantial
269
+ portion of the contents of the database;
270
+
271
+ b. if You include all or a substantial portion of the database
272
+ contents in a database in which You have Sui Generis Database
273
+ Rights, then the database in which You have Sui Generis Database
274
+ Rights (but not its individual contents) is Adapted Material; and
275
+
276
+ c. You must comply with the conditions in Section 3(a) if You Share
277
+ all or a substantial portion of the contents of the database.
278
+
279
+ For the avoidance of doubt, this Section 4 supplements and does not
280
+ replace Your obligations under this Public License where the Licensed
281
+ Rights include other Copyright and Similar Rights.
282
+
283
+
284
+ Section 5 -- Disclaimer of Warranties and Limitation of Liability.
285
+
286
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
287
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
288
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
289
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
290
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
291
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
292
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
293
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
294
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
295
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
296
+
297
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
298
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
299
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
300
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
301
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
302
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
303
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
304
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
305
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
306
+
307
+ c. The disclaimer of warranties and limitation of liability provided
308
+ above shall be interpreted in a manner that, to the extent
309
+ possible, most closely approximates an absolute disclaimer and
310
+ waiver of all liability.
311
+
312
+
313
+ Section 6 -- Term and Termination.
314
+
315
+ a. This Public License applies for the term of the Copyright and
316
+ Similar Rights licensed here. However, if You fail to comply with
317
+ this Public License, then Your rights under this Public License
318
+ terminate automatically.
319
+
320
+ b. Where Your right to use the Licensed Material has terminated under
321
+ Section 6(a), it reinstates:
322
+
323
+ 1. automatically as of the date the violation is cured, provided
324
+ it is cured within 30 days of Your discovery of the
325
+ violation; or
326
+
327
+ 2. upon express reinstatement by the Licensor.
328
+
329
+ For the avoidance of doubt, this Section 6(b) does not affect any
330
+ right the Licensor may have to seek remedies for Your violations
331
+ of this Public License.
332
+
333
+ c. For the avoidance of doubt, the Licensor may also offer the
334
+ Licensed Material under separate terms or conditions or stop
335
+ distributing the Licensed Material at any time; however, doing so
336
+ will not terminate this Public License.
337
+
338
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
339
+ License.
340
+
341
+
342
+ Section 7 -- Other Terms and Conditions.
343
+
344
+ a. The Licensor shall not be bound by any additional or different
345
+ terms or conditions communicated by You unless expressly agreed.
346
+
347
+ b. Any arrangements, understandings, or agreements regarding the
348
+ Licensed Material not stated herein are separate from and
349
+ independent of the terms and conditions of this Public License.
350
+
351
+
352
+ Section 8 -- Interpretation.
353
+
354
+ a. For the avoidance of doubt, this Public License does not, and
355
+ shall not be interpreted to, reduce, limit, restrict, or impose
356
+ conditions on any use of the Licensed Material that could lawfully
357
+ be made without permission under this Public License.
358
+
359
+ b. To the extent possible, if any provision of this Public License is
360
+ deemed unenforceable, it shall be automatically reformed to the
361
+ minimum extent necessary to make it enforceable. If the provision
362
+ cannot be reformed, it shall be severed from this Public License
363
+ without affecting the enforceability of the remaining terms and
364
+ conditions.
365
+
366
+ c. No term or condition of this Public License will be waived and no
367
+ failure to comply consented to unless expressly agreed to by the
368
+ Licensor.
369
+
370
+ d. Nothing in this Public License constitutes or may be interpreted
371
+ as a limitation upon, or waiver of, any privileges and immunities
372
+ that apply to the Licensor or You, including from the legal
373
+ processes of any jurisdiction or authority.
374
+
375
+
376
+ =======================================================================
377
+
378
+ Creative Commons is not a party to its public
379
+ licenses. Notwithstanding, Creative Commons may elect to apply one of
380
+ its public licenses to material it publishes and in those instances
381
+ will be considered the “Licensor.” The text of the Creative Commons
382
+ public licenses is dedicated to the public domain under the CC0 Public
383
+ Domain Dedication. Except for the limited purpose of indicating that
384
+ material is shared under a Creative Commons public license or as
385
+ otherwise permitted by the Creative Commons policies published at
386
+ creativecommons.org/policies, Creative Commons does not authorize the
387
+ use of the trademark "Creative Commons" or any other trademark or logo
388
+ of Creative Commons without its prior written consent including,
389
+ without limitation, in connection with any unauthorized modifications
390
+ to any of its public licenses or any other arrangements,
391
+ understandings, or agreements concerning use of licensed material. For
392
+ the avoidance of doubt, this paragraph does not form part of the
393
+ public licenses.
394
+
395
+ Creative Commons may be contacted at creativecommons.org.
396
+
LICENSES/CC-BY-NC-4.0.txt ADDED
@@ -0,0 +1,408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Attribution-NonCommercial 4.0 International
2
+
3
+ =======================================================================
4
+
5
+ Creative Commons Corporation ("Creative Commons") is not a law firm and
6
+ does not provide legal services or legal advice. Distribution of
7
+ Creative Commons public licenses does not create a lawyer-client or
8
+ other relationship. Creative Commons makes its licenses and related
9
+ information available on an "as-is" basis. Creative Commons gives no
10
+ warranties regarding its licenses, any material licensed under their
11
+ terms and conditions, or any related information. Creative Commons
12
+ disclaims all liability for damages resulting from their use to the
13
+ fullest extent possible.
14
+
15
+ Using Creative Commons Public Licenses
16
+
17
+ Creative Commons public licenses provide a standard set of terms and
18
+ conditions that creators and other rights holders may use to share
19
+ original works of authorship and other material subject to copyright
20
+ and certain other rights specified in the public license below. The
21
+ following considerations are for informational purposes only, are not
22
+ exhaustive, and do not form part of our licenses.
23
+
24
+ Considerations for licensors: Our public licenses are
25
+ intended for use by those authorized to give the public
26
+ permission to use material in ways otherwise restricted by
27
+ copyright and certain other rights. Our licenses are
28
+ irrevocable. Licensors should read and understand the terms
29
+ and conditions of the license they choose before applying it.
30
+ Licensors should also secure all rights necessary before
31
+ applying our licenses so that the public can reuse the
32
+ material as expected. Licensors should clearly mark any
33
+ material not subject to the license. This includes other CC-
34
+ licensed material, or material used under an exception or
35
+ limitation to copyright. More considerations for licensors:
36
+ wiki.creativecommons.org/Considerations_for_licensors
37
+
38
+ Considerations for the public: By using one of our public
39
+ licenses, a licensor grants the public permission to use the
40
+ licensed material under specified terms and conditions. If
41
+ the licensor's permission is not necessary for any reason--for
42
+ example, because of any applicable exception or limitation to
43
+ copyright--then that use is not regulated by the license. Our
44
+ licenses grant only permissions under copyright and certain
45
+ other rights that a licensor has authority to grant. Use of
46
+ the licensed material may still be restricted for other
47
+ reasons, including because others have copyright or other
48
+ rights in the material. A licensor may make special requests,
49
+ such as asking that all changes be marked or described.
50
+ Although not required by our licenses, you are encouraged to
51
+ respect those requests where reasonable. More considerations
52
+ for the public:
53
+ wiki.creativecommons.org/Considerations_for_licensees
54
+
55
+ =======================================================================
56
+
57
+ Creative Commons Attribution-NonCommercial 4.0 International Public
58
+ License
59
+
60
+ By exercising the Licensed Rights (defined below), You accept and agree
61
+ to be bound by the terms and conditions of this Creative Commons
62
+ Attribution-NonCommercial 4.0 International Public License ("Public
63
+ License"). To the extent this Public License may be interpreted as a
64
+ contract, You are granted the Licensed Rights in consideration of Your
65
+ acceptance of these terms and conditions, and the Licensor grants You
66
+ such rights in consideration of benefits the Licensor receives from
67
+ making the Licensed Material available under these terms and
68
+ conditions.
69
+
70
+
71
+ Section 1 -- Definitions.
72
+
73
+ a. Adapted Material means material subject to Copyright and Similar
74
+ Rights that is derived from or based upon the Licensed Material
75
+ and in which the Licensed Material is translated, altered,
76
+ arranged, transformed, or otherwise modified in a manner requiring
77
+ permission under the Copyright and Similar Rights held by the
78
+ Licensor. For purposes of this Public License, where the Licensed
79
+ Material is a musical work, performance, or sound recording,
80
+ Adapted Material is always produced where the Licensed Material is
81
+ synched in timed relation with a moving image.
82
+
83
+ b. Adapter's License means the license You apply to Your Copyright
84
+ and Similar Rights in Your contributions to Adapted Material in
85
+ accordance with the terms and conditions of this Public License.
86
+
87
+ c. Copyright and Similar Rights means copyright and/or similar rights
88
+ closely related to copyright including, without limitation,
89
+ performance, broadcast, sound recording, and Sui Generis Database
90
+ Rights, without regard to how the rights are labeled or
91
+ categorized. For purposes of this Public License, the rights
92
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
93
+ Rights.
94
+ d. Effective Technological Measures means those measures that, in the
95
+ absence of proper authority, may not be circumvented under laws
96
+ fulfilling obligations under Article 11 of the WIPO Copyright
97
+ Treaty adopted on December 20, 1996, and/or similar international
98
+ agreements.
99
+
100
+ e. Exceptions and Limitations means fair use, fair dealing, and/or
101
+ any other exception or limitation to Copyright and Similar Rights
102
+ that applies to Your use of the Licensed Material.
103
+
104
+ f. Licensed Material means the artistic or literary work, database,
105
+ or other material to which the Licensor applied this Public
106
+ License.
107
+
108
+ g. Licensed Rights means the rights granted to You subject to the
109
+ terms and conditions of this Public License, which are limited to
110
+ all Copyright and Similar Rights that apply to Your use of the
111
+ Licensed Material and that the Licensor has authority to license.
112
+
113
+ h. Licensor means the individual(s) or entity(ies) granting rights
114
+ under this Public License.
115
+
116
+ i. NonCommercial means not primarily intended for or directed towards
117
+ commercial advantage or monetary compensation. For purposes of
118
+ this Public License, the exchange of the Licensed Material for
119
+ other material subject to Copyright and Similar Rights by digital
120
+ file-sharing or similar means is NonCommercial provided there is
121
+ no payment of monetary compensation in connection with the
122
+ exchange.
123
+
124
+ j. Share means to provide material to the public by any means or
125
+ process that requires permission under the Licensed Rights, such
126
+ as reproduction, public display, public performance, distribution,
127
+ dissemination, communication, or importation, and to make material
128
+ available to the public including in ways that members of the
129
+ public may access the material from a place and at a time
130
+ individually chosen by them.
131
+
132
+ k. Sui Generis Database Rights means rights other than copyright
133
+ resulting from Directive 96/9/EC of the European Parliament and of
134
+ the Council of 11 March 1996 on the legal protection of databases,
135
+ as amended and/or succeeded, as well as other essentially
136
+ equivalent rights anywhere in the world.
137
+
138
+ l. You means the individual or entity exercising the Licensed Rights
139
+ under this Public License. Your has a corresponding meaning.
140
+
141
+
142
+ Section 2 -- Scope.
143
+
144
+ a. License grant.
145
+
146
+ 1. Subject to the terms and conditions of this Public License,
147
+ the Licensor hereby grants You a worldwide, royalty-free,
148
+ non-sublicensable, non-exclusive, irrevocable license to
149
+ exercise the Licensed Rights in the Licensed Material to:
150
+
151
+ a. reproduce and Share the Licensed Material, in whole or
152
+ in part, for NonCommercial purposes only; and
153
+
154
+ b. produce, reproduce, and Share Adapted Material for
155
+ NonCommercial purposes only.
156
+
157
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
158
+ Exceptions and Limitations apply to Your use, this Public
159
+ License does not apply, and You do not need to comply with
160
+ its terms and conditions.
161
+
162
+ 3. Term. The term of this Public License is specified in Section
163
+ 6(a).
164
+
165
+ 4. Media and formats; technical modifications allowed. The
166
+ Licensor authorizes You to exercise the Licensed Rights in
167
+ all media and formats whether now known or hereafter created,
168
+ and to make technical modifications necessary to do so. The
169
+ Licensor waives and/or agrees not to assert any right or
170
+ authority to forbid You from making technical modifications
171
+ necessary to exercise the Licensed Rights, including
172
+ technical modifications necessary to circumvent Effective
173
+ Technological Measures. For purposes of this Public License,
174
+ simply making modifications authorized by this Section 2(a)
175
+ (4) never produces Adapted Material.
176
+
177
+ 5. Downstream recipients.
178
+
179
+ a. Offer from the Licensor -- Licensed Material. Every
180
+ recipient of the Licensed Material automatically
181
+ receives an offer from the Licensor to exercise the
182
+ Licensed Rights under the terms and conditions of this
183
+ Public License.
184
+
185
+ b. No downstream restrictions. You may not offer or impose
186
+ any additional or different terms or conditions on, or
187
+ apply any Effective Technological Measures to, the
188
+ Licensed Material if doing so restricts exercise of the
189
+ Licensed Rights by any recipient of the Licensed
190
+ Material.
191
+
192
+ 6. No endorsement. Nothing in this Public License constitutes or
193
+ may be construed as permission to assert or imply that You
194
+ are, or that Your use of the Licensed Material is, connected
195
+ with, or sponsored, endorsed, or granted official status by,
196
+ the Licensor or others designated to receive attribution as
197
+ provided in Section 3(a)(1)(A)(i).
198
+
199
+ b. Other rights.
200
+
201
+ 1. Moral rights, such as the right of integrity, are not
202
+ licensed under this Public License, nor are publicity,
203
+ privacy, and/or other similar personality rights; however, to
204
+ the extent possible, the Licensor waives and/or agrees not to
205
+ assert any such rights held by the Licensor to the limited
206
+ extent necessary to allow You to exercise the Licensed
207
+ Rights, but not otherwise.
208
+
209
+ 2. Patent and trademark rights are not licensed under this
210
+ Public License.
211
+
212
+ 3. To the extent possible, the Licensor waives any right to
213
+ collect royalties from You for the exercise of the Licensed
214
+ Rights, whether directly or through a collecting society
215
+ under any voluntary or waivable statutory or compulsory
216
+ licensing scheme. In all other cases the Licensor expressly
217
+ reserves any right to collect such royalties, including when
218
+ the Licensed Material is used other than for NonCommercial
219
+ purposes.
220
+
221
+
222
+ Section 3 -- License Conditions.
223
+
224
+ Your exercise of the Licensed Rights is expressly made subject to the
225
+ following conditions.
226
+
227
+ a. Attribution.
228
+
229
+ 1. If You Share the Licensed Material (including in modified
230
+ form), You must:
231
+
232
+ a. retain the following if it is supplied by the Licensor
233
+ with the Licensed Material:
234
+
235
+ i. identification of the creator(s) of the Licensed
236
+ Material and any others designated to receive
237
+ attribution, in any reasonable manner requested by
238
+ the Licensor (including by pseudonym if
239
+ designated);
240
+
241
+ ii. a copyright notice;
242
+
243
+ iii. a notice that refers to this Public License;
244
+
245
+ iv. a notice that refers to the disclaimer of
246
+ warranties;
247
+
248
+ v. a URI or hyperlink to the Licensed Material to the
249
+ extent reasonably practicable;
250
+
251
+ b. indicate if You modified the Licensed Material and
252
+ retain an indication of any previous modifications; and
253
+
254
+ c. indicate the Licensed Material is licensed under this
255
+ Public License, and include the text of, or the URI or
256
+ hyperlink to, this Public License.
257
+
258
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
259
+ reasonable manner based on the medium, means, and context in
260
+ which You Share the Licensed Material. For example, it may be
261
+ reasonable to satisfy the conditions by providing a URI or
262
+ hyperlink to a resource that includes the required
263
+ information.
264
+
265
+ 3. If requested by the Licensor, You must remove any of the
266
+ information required by Section 3(a)(1)(A) to the extent
267
+ reasonably practicable.
268
+
269
+ 4. If You Share Adapted Material You produce, the Adapter's
270
+ License You apply must not prevent recipients of the Adapted
271
+ Material from complying with this Public License.
272
+
273
+
274
+ Section 4 -- Sui Generis Database Rights.
275
+
276
+ Where the Licensed Rights include Sui Generis Database Rights that
277
+ apply to Your use of the Licensed Material:
278
+
279
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
280
+ to extract, reuse, reproduce, and Share all or a substantial
281
+ portion of the contents of the database for NonCommercial purposes
282
+ only;
283
+
284
+ b. if You include all or a substantial portion of the database
285
+ contents in a database in which You have Sui Generis Database
286
+ Rights, then the database in which You have Sui Generis Database
287
+ Rights (but not its individual contents) is Adapted Material; and
288
+
289
+ c. You must comply with the conditions in Section 3(a) if You Share
290
+ all or a substantial portion of the contents of the database.
291
+
292
+ For the avoidance of doubt, this Section 4 supplements and does not
293
+ replace Your obligations under this Public License where the Licensed
294
+ Rights include other Copyright and Similar Rights.
295
+
296
+
297
+ Section 5 -- Disclaimer of Warranties and Limitation of Liability.
298
+
299
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
300
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
301
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
302
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
303
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
304
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
305
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
306
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
307
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
308
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
309
+
310
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
311
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
312
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
313
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
314
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
315
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
316
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
317
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
318
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
319
+
320
+ c. The disclaimer of warranties and limitation of liability provided
321
+ above shall be interpreted in a manner that, to the extent
322
+ possible, most closely approximates an absolute disclaimer and
323
+ waiver of all liability.
324
+
325
+
326
+ Section 6 -- Term and Termination.
327
+
328
+ a. This Public License applies for the term of the Copyright and
329
+ Similar Rights licensed here. However, if You fail to comply with
330
+ this Public License, then Your rights under this Public License
331
+ terminate automatically.
332
+
333
+ b. Where Your right to use the Licensed Material has terminated under
334
+ Section 6(a), it reinstates:
335
+
336
+ 1. automatically as of the date the violation is cured, provided
337
+ it is cured within 30 days of Your discovery of the
338
+ violation; or
339
+
340
+ 2. upon express reinstatement by the Licensor.
341
+
342
+ For the avoidance of doubt, this Section 6(b) does not affect any
343
+ right the Licensor may have to seek remedies for Your violations
344
+ of this Public License.
345
+
346
+ c. For the avoidance of doubt, the Licensor may also offer the
347
+ Licensed Material under separate terms or conditions or stop
348
+ distributing the Licensed Material at any time; however, doing so
349
+ will not terminate this Public License.
350
+
351
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
352
+ License.
353
+
354
+
355
+ Section 7 -- Other Terms and Conditions.
356
+
357
+ a. The Licensor shall not be bound by any additional or different
358
+ terms or conditions communicated by You unless expressly agreed.
359
+
360
+ b. Any arrangements, understandings, or agreements regarding the
361
+ Licensed Material not stated herein are separate from and
362
+ independent of the terms and conditions of this Public License.
363
+
364
+
365
+ Section 8 -- Interpretation.
366
+
367
+ a. For the avoidance of doubt, this Public License does not, and
368
+ shall not be interpreted to, reduce, limit, restrict, or impose
369
+ conditions on any use of the Licensed Material that could lawfully
370
+ be made without permission under this Public License.
371
+
372
+ b. To the extent possible, if any provision of this Public License is
373
+ deemed unenforceable, it shall be automatically reformed to the
374
+ minimum extent necessary to make it enforceable. If the provision
375
+ cannot be reformed, it shall be severed from this Public License
376
+ without affecting the enforceability of the remaining terms and
377
+ conditions.
378
+
379
+ c. No term or condition of this Public License will be waived and no
380
+ failure to comply consented to unless expressly agreed to by the
381
+ Licensor.
382
+
383
+ d. Nothing in this Public License constitutes or may be interpreted
384
+ as a limitation upon, or waiver of, any privileges and immunities
385
+ that apply to the Licensor or You, including from the legal
386
+ processes of any jurisdiction or authority.
387
+
388
+ =======================================================================
389
+
390
+ Creative Commons is not a party to its public
391
+ licenses. Notwithstanding, Creative Commons may elect to apply one of
392
+ its public licenses to material it publishes and in those instances
393
+ will be considered the “Licensor.” The text of the Creative Commons
394
+ public licenses is dedicated to the public domain under the CC0 Public
395
+ Domain Dedication. Except for the limited purpose of indicating that
396
+ material is shared under a Creative Commons public license or as
397
+ otherwise permitted by the Creative Commons policies published at
398
+ creativecommons.org/policies, Creative Commons does not authorize the
399
+ use of the trademark "Creative Commons" or any other trademark or logo
400
+ of Creative Commons without its prior written consent including,
401
+ without limitation, in connection with any unauthorized modifications
402
+ to any of its public licenses or any other arrangements,
403
+ understandings, or agreements concerning use of licensed material. For
404
+ the avoidance of doubt, this paragraph does not form part of the
405
+ public licenses.
406
+
407
+ Creative Commons may be contacted at creativecommons.org.
408
+
NOTICE.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Sources
2
+
3
+ - [KodCode](https://arxiv.org/abs/2503.02951), Xu et al., 2025.
4
+ Sources: [V1-SFT-4o](https://huggingface.co/datasets/KodCode/KodCode-V1-SFT-4o)
5
+ and [Light-RL-10K](https://huggingface.co/datasets/KodCode/KodCode-Light-RL-10K).
6
+ - [TACO](https://arxiv.org/abs/2312.14852), Li et al., 2023.
7
+ Source: [BAAI/TACO](https://huggingface.co/datasets/BAAI/TACO).
8
+ - [LeetCodeDataset](https://arxiv.org/abs/2504.14655), 2025.
9
+ Source: [newfacade/LeetCodeDataset](https://huggingface.co/datasets/newfacade/LeetCodeDataset).
10
+
11
+ This release packages filtered project snapshots, preserves reference answers
12
+ and RL tests, carries category labels, and adds a TACO SFT holdout.
13
+ Upstream authors retain attribution. Exact revisions and file identities are
14
+ recorded under metadata/. TACO's own source acknowledgments also apply.
README.md CHANGED
@@ -1,3 +1,80 @@
1
  ---
2
- license: unknown
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ pretty_name: Code Reasoning Data
3
+ language:
4
+ - en
5
+ task_categories:
6
+ - text-generation
7
+ tags:
8
+ - code
9
+ - sft
10
+ - reinforcement-learning
11
+ license: other
12
+ license_name: source-specific-licenses
13
+ license_link: LICENSE
14
+ size_categories:
15
+ - 10K<n<100K
16
+ configs:
17
+ - config_name: kodcode_sft
18
+ default: true
19
+ data_files:
20
+ - split: train
21
+ path: data/kodcode/sft/train.parquet
22
+ - split: validation
23
+ path: data/kodcode/sft/validation.parquet
24
+ - config_name: kodcode_rl
25
+ data_files:
26
+ - split: train
27
+ path: data/kodcode/rl/train.parquet
28
+ - split: validation
29
+ path: data/kodcode/rl/validation.parquet
30
+ - config_name: taco_leetcode_sft
31
+ data_files:
32
+ - split: train
33
+ path: data/taco_leetcode/sft/train.parquet
34
+ - split: validation
35
+ path: data/taco_leetcode/sft/validation.parquet
36
+ - config_name: taco_leetcode_rl
37
+ data_files:
38
+ - split: train
39
+ path: data/taco_leetcode/rl/train.parquet
40
+ - split: validation
41
+ path: data/taco_leetcode/rl/validation.parquet
42
  ---
43
+
44
+ # Code Reasoning Data
45
+
46
+ Code-training data with SFT answers, executable RL tests, and category labels.
47
+
48
+ | Configuration | Train | Validation |
49
+ |---|---:|---:|
50
+ | `kodcode_sft` | 35,974 | 100 |
51
+ | `kodcode_rl` | 35,974 | 100 |
52
+ | `taco_leetcode_sft` | 21,779 | 100 |
53
+ | `taco_leetcode_rl` | 17,249 | 100 |
54
+
55
+ ```python
56
+ from datasets import load_dataset
57
+
58
+ ds = load_dataset("./dataset", "kodcode_sft")
59
+ # After upload, replace ./dataset with your Hugging Face dataset repository ID.
60
+ ```
61
+
62
+ SFT: use `messages` or `prompt` / `response`. RL: use `prompt` and
63
+ `reward_model.ground_truth`. Apply the target model's template at training time.
64
+ Use only the documented input/target fields; labels and tests are metadata.
65
+
66
+ KodCode uses ten primary categories; TACO/LeetCode uses seven category-removal
67
+ groups. Their taxonomies and historical ablation memberships are separate.
68
+
69
+ The TACO SFT validation split is new in this release. Other splits are historical.
70
+ These configurations are separate experiments, not a joint SFT-to-RL split.
71
+ Historical TACO RL validation overlaps the original SFT pool on 71 problems.
72
+ See [TACO/LeetCode notes](docs/taco_leetcode.md) for historical export.
73
+
74
+ ```bash
75
+ pip install -r requirements.txt
76
+ python scripts/validate_release.py --hf
77
+ ```
78
+
79
+ Source-specific licenses apply; see [LICENSE](LICENSE) and [NOTICE](NOTICE.md).
80
+ Reward scripts require Linux; usage and limits are in [verification notes](docs/rl_verification.md).
data/kodcode/rl/train.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a23ea34d57279ae59d7068c4bbd55df08df49b3d4ca42853a49302365d54f224
3
+ size 31938297
data/kodcode/rl/validation.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:380992eb51a792f641d31306704e5eb58f26ef53e4d81ee4757c5552cf046ece
3
+ size 127880
data/kodcode/sft/train.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f28beea278bfc762fad78a3cb11041380e765cbb0c328104b34a0023e202001c
3
+ size 45871516
data/kodcode/sft/validation.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:12b191279320d21ef8ca008e9ca75fa39cc41d061880f62ac0a142a139bcc232
3
+ size 160105
data/taco_leetcode/rl/train.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9cda87499760450fa89755a8b61c821b6f58a7421b15e8a8f1ca636705130b3f
3
+ size 458373045
data/taco_leetcode/rl/validation.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d049040b92177b9f5651a1db465545bfd0ff44cc6075e0726c19b4e6ceea3441
3
+ size 1224277
data/taco_leetcode/sft/train.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0de1e7a0341bc9e735427d35761b53d6918f66b9cb750f4f8cbe26e5965403ef
3
+ size 38500020
data/taco_leetcode/sft/validation.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f637a2b0f6e466335dddd08834fa56d1eaabf7b1792bf9cbbda21c95501e362
3
+ size 195929
docs/kodcode.md ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # KodCode
2
+
3
+ The released pool contains 36,074 distinct problems: 35,974 train and 100 fixed
4
+ validation, shared by SFT and RL. It follows the project's deduplication,
5
+ interface repair, execution checks, and reviewed category mapping.
6
+ The earlier 37,881-answer diagnostic pool is not included as another configuration.
7
+
8
+ `primary_category` is the ten-category v2 label. `v1_*` fields preserve the
9
+ older reviewed labels; `v1_alternative_category` belongs to that older taxonomy.
10
+ `techniques` retains auxiliary text tags, not extra v2 primary labels.
11
+ Historical main ablations remove the primary category only.
12
+
13
+ ```bash
14
+ python scripts/build_kodcode.py --arm no_dynamic_programming --output arm.parquet
15
+ ```
16
+
17
+ Frozen labeled source exports can be repackaged with `--source DIR`.
18
+ File and membership hashes are in metadata/kodcode/.
docs/rl_verification.md ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RL verification
2
+
3
+ Call the appropriate module's `compute_score(data_source, solution_str,
4
+ ground_truth)`, passing `reward_model.ground_truth` from an RL row.
5
+
6
+ | Family | Tests | Reward |
7
+ |---|---|---|
8
+ | KodCode | Python test module and named test functions | 1 only if every test passes; otherwise 0 |
9
+ | TACO/LeetCode | Standard-input or function-call cases | 1 for full pass; otherwise 0.8 × pass fraction |
10
+
11
+ The bundled code preserves the historical scorer. KodCode defaults to 1 second
12
+ per test and 180 seconds per completion; TACO defaults to 2 and 6 seconds.
13
+ Both default to 2 GiB memory and 16 MiB file-output limits. Training runs may
14
+ override these arguments; record any changes when comparing results.
15
+
16
+ Execution requires Linux. Install `verification/requirements.txt` for the
17
+ third-party modules recorded by the KodCode tests; solutions may need other imports.
18
+ Process resource limits are not a security isolation boundary; run untrusted
19
+ generated code in an isolated container without credentials or network access.
20
+ Dataset loading and structural validation do not execute problem code.
21
+
22
+ ```bash
23
+ python verification/smoke_test.py
24
+ ```
docs/taco_leetcode.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TACO + LeetCode
2
+
3
+ The historical SFT pool has 21,879 rows (19,493 TACO; 2,386 LeetCodeDataset).
4
+ This release holds out 100 unique-prompt problems using seed 20260907 and
5
+ source/category stratification, leaving 21,779 training rows.
6
+ The original order and all original SFT fields remain recoverable.
7
+
8
+ RL retains the original 17,249 train / 100 validation split and all reward tests.
9
+ Its training metadata marks 11,587 reference-execution-verified rows and 5,662
10
+ structural-only rows; validation has 71 and 29 respectively.
11
+ The two task configurations were not built as a shared SFT-to-RL partition.
12
+
13
+ Seven removal categories use `overlap_categories`; `no_tags` marks unlabeled
14
+ rows. Original detailed SFT labels remain in `raw_*` columns. Recorded historical SFT
15
+ arms have 14,043 rows and RL arms have 12,168. Release SFT arm exports exclude
16
+ the new holdout and therefore need not remain equal-size.
17
+
18
+ ```bash
19
+ # Original 21,879-row SFT pool, in original order:
20
+ python scripts/build_taco_leetcode.py --arm full_sft --historical --output original.parquet
21
+ # Historical RL arm:
22
+ python scripts/build_taco_leetcode.py --kind rl --arm no_graph --output arm.parquet
23
+ ```
24
+
25
+ The build script also accepts a frozen source export through `--source DIR`.
26
+ Source records, IDs, and split hashes are documented in metadata/taco_leetcode/.
metadata/content_preservation.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "status": "PASS",
3
+ "source_transfer": {
4
+ "files": 15,
5
+ "sha256_matches": 15
6
+ },
7
+ "historical_sft_original_fields_and_order_restored": true,
8
+ "taco_rl_prompts_and_all_reward_payloads_unchanged": {
9
+ "train": true,
10
+ "validation": true
11
+ },
12
+ "sft_holdout_recomputed_identically": true,
13
+ "reward_smoke_linux": {
14
+ "status": "PASS",
15
+ "synthetic_only": true,
16
+ "kodcode_full_and_half": [
17
+ 1.0,
18
+ 0.0
19
+ ],
20
+ "taco_full_and_half": [
21
+ 1.0,
22
+ 0.4
23
+ ]
24
+ },
25
+ "runtime": {
26
+ "python": "3.12.10",
27
+ "pyarrow": "23.0.1"
28
+ }
29
+ }
metadata/kodcode/ablation_membership.json ADDED
The diff for this file is too large to render. See raw diff
 
metadata/kodcode/dataset_manifest.json ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1.0.0",
3
+ "family": "kodcode",
4
+ "split_policy": {
5
+ "train": "historical",
6
+ "validation": "historical fixed 100; shared SFT/RL"
7
+ },
8
+ "files": {
9
+ "sft/train": {
10
+ "path": "data/kodcode/sft/train.parquet",
11
+ "rows": 35974,
12
+ "bytes": 45871516,
13
+ "sha256": "f28beea278bfc762fad78a3cb11041380e765cbb0c328104b34a0023e202001c",
14
+ "problem_id_set_sha256": "8f99c9121ffedf641bd6176e23ab29b973c06bcbc22433f159d4507887d133e7",
15
+ "columns": [
16
+ "problem_id",
17
+ "original_question_id",
18
+ "source_dataset",
19
+ "subset",
20
+ "style",
21
+ "difficulty",
22
+ "entry_point",
23
+ "test_count_used",
24
+ "test_code_repaired",
25
+ "reference_full_execution_verified",
26
+ "messages",
27
+ "prompt",
28
+ "response",
29
+ "response_source",
30
+ "quality_status",
31
+ "v1_primary_category",
32
+ "v1_subcategory",
33
+ "v1_confidence",
34
+ "v1_alternative_category",
35
+ "techniques",
36
+ "rationale",
37
+ "classifier_model",
38
+ "classification_stage",
39
+ "v1_taxonomy_version",
40
+ "was_reviewed",
41
+ "v1_first_pass_category",
42
+ "review_changed",
43
+ "primary_category",
44
+ "subcategory",
45
+ "confidence",
46
+ "taxonomy_version",
47
+ "mapping_method"
48
+ ]
49
+ },
50
+ "sft/validation": {
51
+ "path": "data/kodcode/sft/validation.parquet",
52
+ "rows": 100,
53
+ "bytes": 160105,
54
+ "sha256": "12b191279320d21ef8ca008e9ca75fa39cc41d061880f62ac0a142a139bcc232",
55
+ "problem_id_set_sha256": "f755bf33f003a79bc14d90fdd573ba39234afc2e2e750d6e99788c1de6c91401",
56
+ "columns": [
57
+ "problem_id",
58
+ "original_question_id",
59
+ "source_dataset",
60
+ "subset",
61
+ "style",
62
+ "difficulty",
63
+ "entry_point",
64
+ "test_count_used",
65
+ "test_code_repaired",
66
+ "reference_full_execution_verified",
67
+ "messages",
68
+ "prompt",
69
+ "response",
70
+ "response_source",
71
+ "quality_status",
72
+ "v1_primary_category",
73
+ "v1_subcategory",
74
+ "v1_confidence",
75
+ "v1_alternative_category",
76
+ "techniques",
77
+ "rationale",
78
+ "classifier_model",
79
+ "classification_stage",
80
+ "v1_taxonomy_version",
81
+ "was_reviewed",
82
+ "v1_first_pass_category",
83
+ "review_changed",
84
+ "primary_category",
85
+ "subcategory",
86
+ "confidence",
87
+ "taxonomy_version",
88
+ "mapping_method"
89
+ ]
90
+ },
91
+ "rl/train": {
92
+ "path": "data/kodcode/rl/train.parquet",
93
+ "rows": 35974,
94
+ "bytes": 31938297,
95
+ "sha256": "a23ea34d57279ae59d7068c4bbd55df08df49b3d4ca42853a49302365d54f224",
96
+ "problem_id_set_sha256": "8f99c9121ffedf641bd6176e23ab29b973c06bcbc22433f159d4507887d133e7",
97
+ "columns": [
98
+ "prompt",
99
+ "data_source",
100
+ "ability",
101
+ "reward_model",
102
+ "extra_info",
103
+ "problem_id",
104
+ "v1_primary_category",
105
+ "v1_subcategory",
106
+ "v1_confidence",
107
+ "v1_alternative_category",
108
+ "techniques",
109
+ "rationale",
110
+ "classifier_model",
111
+ "classification_stage",
112
+ "v1_taxonomy_version",
113
+ "was_reviewed",
114
+ "v1_first_pass_category",
115
+ "review_changed",
116
+ "primary_category",
117
+ "subcategory",
118
+ "confidence",
119
+ "taxonomy_version",
120
+ "mapping_method"
121
+ ]
122
+ },
123
+ "rl/validation": {
124
+ "path": "data/kodcode/rl/validation.parquet",
125
+ "rows": 100,
126
+ "bytes": 127880,
127
+ "sha256": "380992eb51a792f641d31306704e5eb58f26ef53e4d81ee4757c5552cf046ece",
128
+ "problem_id_set_sha256": "f755bf33f003a79bc14d90fdd573ba39234afc2e2e750d6e99788c1de6c91401",
129
+ "columns": [
130
+ "prompt",
131
+ "data_source",
132
+ "ability",
133
+ "reward_model",
134
+ "extra_info",
135
+ "problem_id",
136
+ "v1_primary_category",
137
+ "v1_subcategory",
138
+ "v1_confidence",
139
+ "v1_alternative_category",
140
+ "techniques",
141
+ "rationale",
142
+ "classifier_model",
143
+ "classification_stage",
144
+ "v1_taxonomy_version",
145
+ "was_reviewed",
146
+ "v1_first_pass_category",
147
+ "review_changed",
148
+ "primary_category",
149
+ "subcategory",
150
+ "confidence",
151
+ "taxonomy_version",
152
+ "mapping_method"
153
+ ]
154
+ }
155
+ }
156
+ }
metadata/kodcode/source_manifest.json ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1.0.0",
3
+ "snapshot": "kodcode_clean_36074_v2",
4
+ "upstream": [
5
+ {
6
+ "repo_id": "KodCode/KodCode-V1-SFT-4o",
7
+ "revision": "14f8782fb7787c7e31dd4a1372518bc10fedb66e",
8
+ "license": "cc-by-nc-4.0"
9
+ },
10
+ {
11
+ "repo_id": "KodCode/KodCode-Light-RL-10K",
12
+ "revision": "dcf78a8bbba9a613b596ce993c4921a38687dfcc",
13
+ "license": "cc-by-nc-4.0"
14
+ }
15
+ ],
16
+ "processing": [
17
+ "37,881 source answer rows / 36,446 original questions",
18
+ "original-question deduplication and fixed validation exclusion",
19
+ "interface repair, static checks and exact-reward reference verification",
20
+ "36,074 accepted problems; 35,974 train / 100 validation",
21
+ "reviewed v1 labels mapped deterministically to v2 ten-category taxonomy"
22
+ ],
23
+ "source_files": {
24
+ "memberships.json": {
25
+ "bytes": 8027652,
26
+ "sha256": "b436b9bcdc3e03d540d52b6be06eb153ca0a3e9e53c151e7dc1126d089ed8790"
27
+ },
28
+ "original_arm_manifest.json": {
29
+ "bytes": 14333,
30
+ "sha256": "e675e9af6c96d1f9936ba5ee7ea2754a087675a238628f21572781694ce080f2"
31
+ },
32
+ "rl_train.parquet": {
33
+ "bytes": 31938297,
34
+ "sha256": "a23ea34d57279ae59d7068c4bbd55df08df49b3d4ca42853a49302365d54f224"
35
+ },
36
+ "rl_validation.parquet": {
37
+ "bytes": 127880,
38
+ "sha256": "380992eb51a792f641d31306704e5eb58f26ef53e4d81ee4757c5552cf046ece"
39
+ },
40
+ "sft_train.parquet": {
41
+ "bytes": 45871516,
42
+ "sha256": "f28beea278bfc762fad78a3cb11041380e765cbb0c328104b34a0023e202001c"
43
+ },
44
+ "sft_validation.parquet": {
45
+ "bytes": 160105,
46
+ "sha256": "12b191279320d21ef8ca008e9ca75fa39cc41d061880f62ac0a142a139bcc232"
47
+ },
48
+ "taxonomy.json": {
49
+ "bytes": 4000,
50
+ "sha256": "905e6c82e9acbe795234f33f1b14c3a0a414c5f4c995fc269fc97b37ad77cce2"
51
+ }
52
+ },
53
+ "release_data_transform": "The four labeled Parquet payloads are byte-identical to the frozen source.",
54
+ "build_source_layout": [
55
+ "sft_train.parquet",
56
+ "sft_validation.parquet",
57
+ "rl_train.parquet",
58
+ "rl_validation.parquet",
59
+ "taxonomy.json",
60
+ "memberships.json",
61
+ "original_arm_manifest.json"
62
+ ]
63
+ }
metadata/kodcode/taxonomy.json ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "kodcode_capability_taxonomy_balanced",
3
+ "version": "2.0.0",
4
+ "derivation": "Deterministic mapping from reviewed taxonomy v1.1.0; no API calls.",
5
+ "primary_label_policy": "Use exactly one v2 category derived from the reviewed v1 primary category and subcategory.",
6
+ "categories": [
7
+ {
8
+ "id": "hashing_counting_and_sets",
9
+ "definition": "Hash maps, hash sets, membership, frequency counting, deduplication, and collection counting.",
10
+ "v1_sources": ["array_hashing_and_sorting/hashing_counting"]
11
+ },
12
+ {
13
+ "id": "sequence_transformations",
14
+ "definition": "Direct transformations, scans, filtering, rearrangement, and construction of sequences.",
15
+ "v1_sources": ["array_hashing_and_sorting/sequence_transformation"]
16
+ },
17
+ {
18
+ "id": "sorting_and_ordered_processing",
19
+ "definition": "Sorting and order-dependent collection processing without an essential greedy proof.",
20
+ "v1_sources": ["array_hashing_and_sorting/sorting"]
21
+ },
22
+ {
23
+ "id": "range_window_and_matrix_processing",
24
+ "definition": "Sliding windows, two pointers, prefix computations, matrix operations, and local range processing.",
25
+ "v1_sources": [
26
+ "array_hashing_and_sorting/sliding_window",
27
+ "array_hashing_and_sorting/two_pointers",
28
+ "array_hashing_and_sorting/prefix_sum",
29
+ "array_hashing_and_sorting/matrix"
30
+ ]
31
+ },
32
+ {
33
+ "id": "string_and_parsing",
34
+ "definition": "Textual structure, parsing, matching, tokenization, encoding, and string transformation.",
35
+ "v1_sources": ["string_and_parsing/*"]
36
+ },
37
+ {
38
+ "id": "dynamic_programming",
39
+ "definition": "State transitions, memoization, overlapping subproblems, and optimal substructure.",
40
+ "v1_sources": ["dynamic_programming/*"]
41
+ },
42
+ {
43
+ "id": "graph_structures_and_stateful_systems",
44
+ "definition": "Graphs, trees, explicit data structures, repeated queries, and evolving stateful systems.",
45
+ "v1_sources": [
46
+ "graph_and_tree_algorithms/*",
47
+ "data_structures_and_queries/*",
48
+ "simulation_and_stateful_logic/*"
49
+ ]
50
+ },
51
+ {
52
+ "id": "greedy_search_and_optimization",
53
+ "definition": "Greedy decisions, monotone or combinatorial search, backtracking, scheduling, and optimization.",
54
+ "v1_sources": ["greedy_search_and_optimization/*"]
55
+ },
56
+ {
57
+ "id": "math_and_number_theory",
58
+ "definition": "Arithmetic, algebra, number theory, combinatorics, geometry, probability, and numerical reasoning.",
59
+ "v1_sources": ["math_and_number_theory/*"]
60
+ },
61
+ {
62
+ "id": "direct_implementation_and_utilities",
63
+ "definition": "Direct implementation, aggregation, validation, conversion, formatting, library, file, and date utilities.",
64
+ "v1_sources": ["direct_implementation_and_utilities/*"]
65
+ }
66
+ ],
67
+ "mapping": {
68
+ "array_hashing_and_sorting/hashing_counting": "hashing_counting_and_sets",
69
+ "array_hashing_and_sorting/sequence_transformation": "sequence_transformations",
70
+ "array_hashing_and_sorting/sorting": "sorting_and_ordered_processing",
71
+ "array_hashing_and_sorting/sliding_window": "range_window_and_matrix_processing",
72
+ "array_hashing_and_sorting/two_pointers": "range_window_and_matrix_processing",
73
+ "array_hashing_and_sorting/prefix_sum": "range_window_and_matrix_processing",
74
+ "array_hashing_and_sorting/matrix": "range_window_and_matrix_processing",
75
+ "string_and_parsing/*": "string_and_parsing",
76
+ "dynamic_programming/*": "dynamic_programming",
77
+ "graph_and_tree_algorithms/*": "graph_structures_and_stateful_systems",
78
+ "data_structures_and_queries/*": "graph_structures_and_stateful_systems",
79
+ "simulation_and_stateful_logic/*": "graph_structures_and_stateful_systems",
80
+ "greedy_search_and_optimization/*": "greedy_search_and_optimization",
81
+ "math_and_number_theory/*": "math_and_number_theory",
82
+ "direct_implementation_and_utilities/*": "direct_implementation_and_utilities"
83
+ }
84
+ }
metadata/release_files.json ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1.0.0",
3
+ "files": {
4
+ ".gitattributes": {
5
+ "bytes": 46,
6
+ "sha256": "30129f61f2a1b984b358279fb24769ff73836dc7f839a765b67775ae2af04a13"
7
+ },
8
+ ".gitignore": {
9
+ "bytes": 38,
10
+ "sha256": "6c1257632e97376c4342ba9ce2d0a6a1c84d7c2519a0711a29969970c6e3cd6c"
11
+ },
12
+ "CHANGELOG.md": {
13
+ "bytes": 263,
14
+ "sha256": "145e44726deacf49a583b76c618c287a5659464702929b4bc562dc559669dcf6"
15
+ },
16
+ "data/kodcode/rl/train.parquet": {
17
+ "bytes": 31938297,
18
+ "sha256": "a23ea34d57279ae59d7068c4bbd55df08df49b3d4ca42853a49302365d54f224"
19
+ },
20
+ "data/kodcode/rl/validation.parquet": {
21
+ "bytes": 127880,
22
+ "sha256": "380992eb51a792f641d31306704e5eb58f26ef53e4d81ee4757c5552cf046ece"
23
+ },
24
+ "data/kodcode/sft/train.parquet": {
25
+ "bytes": 45871516,
26
+ "sha256": "f28beea278bfc762fad78a3cb11041380e765cbb0c328104b34a0023e202001c"
27
+ },
28
+ "data/kodcode/sft/validation.parquet": {
29
+ "bytes": 160105,
30
+ "sha256": "12b191279320d21ef8ca008e9ca75fa39cc41d061880f62ac0a142a139bcc232"
31
+ },
32
+ "data/taco_leetcode/rl/train.parquet": {
33
+ "bytes": 458373045,
34
+ "sha256": "9cda87499760450fa89755a8b61c821b6f58a7421b15e8a8f1ca636705130b3f"
35
+ },
36
+ "data/taco_leetcode/rl/validation.parquet": {
37
+ "bytes": 1224277,
38
+ "sha256": "d049040b92177b9f5651a1db465545bfd0ff44cc6075e0726c19b4e6ceea3441"
39
+ },
40
+ "data/taco_leetcode/sft/train.parquet": {
41
+ "bytes": 38500020,
42
+ "sha256": "0de1e7a0341bc9e735427d35761b53d6918f66b9cb750f4f8cbe26e5965403ef"
43
+ },
44
+ "data/taco_leetcode/sft/validation.parquet": {
45
+ "bytes": 195929,
46
+ "sha256": "3f637a2b0f6e466335dddd08834fa56d1eaabf7b1792bf9cbbda21c95501e362"
47
+ },
48
+ "docs/kodcode.md": {
49
+ "bytes": 823,
50
+ "sha256": "f3f28f4e7e6d0d1f0ad3bd435725b893efbc18cf92e27a3554c7ebec5ce7d170"
51
+ },
52
+ "docs/rl_verification.md": {
53
+ "bytes": 1147,
54
+ "sha256": "958f38e86ff1429bc7063e58d359a39aa2358f1a3c3d2444d42ae7d9539b89c1"
55
+ },
56
+ "docs/taco_leetcode.md": {
57
+ "bytes": 1320,
58
+ "sha256": "d090f3850464245cc2c2d407c23886cba8c9d38573df4c6de85b0c1318dfb3bf"
59
+ },
60
+ "LICENSE": {
61
+ "bytes": 1094,
62
+ "sha256": "b7b3bf61277c2f6891b3a714ddd0f8dbde92a343f50ac3718afe88c0de2fef18"
63
+ },
64
+ "LICENSES/Apache-2.0.txt": {
65
+ "bytes": 11358,
66
+ "sha256": "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30"
67
+ },
68
+ "LICENSES/CC-BY-4.0.txt": {
69
+ "bytes": 18657,
70
+ "sha256": "9ba9550ad48438d0836ddab3da480b3b69ffa0aac7b7878b5a0039e7ab429411"
71
+ },
72
+ "LICENSES/CC-BY-NC-4.0.txt": {
73
+ "bytes": 19347,
74
+ "sha256": "41003d4a74749c0220e33dd415042164b5a1093ed401f36277234f772d22d3d0"
75
+ },
76
+ "metadata/content_preservation.json": {
77
+ "bytes": 597,
78
+ "sha256": "0006c07f61d6d0e34d3c94ae324500175e00a4f437e0238ec2456c21d91e9b39"
79
+ },
80
+ "metadata/kodcode/ablation_membership.json": {
81
+ "bytes": 8030134,
82
+ "sha256": "f38870deb54eabfa13d68f5afb9f7177c26eb4b81b50fc632fe45899fdc6e593"
83
+ },
84
+ "metadata/kodcode/dataset_manifest.json": {
85
+ "bytes": 4503,
86
+ "sha256": "419528e755bfabe417c2db63d494ec13d026ba23e47bd30f191745eebf5696dd"
87
+ },
88
+ "metadata/kodcode/source_manifest.json": {
89
+ "bytes": 2173,
90
+ "sha256": "70f39a27ef00fdccfc5f769ed6818e092c93d4eaa4f8d34c8db31a11e878587e"
91
+ },
92
+ "metadata/kodcode/taxonomy.json": {
93
+ "bytes": 4000,
94
+ "sha256": "905e6c82e9acbe795234f33f1b14c3a0a414c5f4c995fc269fc97b37ad77cce2"
95
+ },
96
+ "metadata/taco_leetcode/ablation_membership.json": {
97
+ "bytes": 7429861,
98
+ "sha256": "cc60808c1344a6d3095f57f3c653b68027a7ef2bec3495c45dc6b6fb8f024ea9"
99
+ },
100
+ "metadata/taco_leetcode/dataset_manifest.json": {
101
+ "bytes": 3880,
102
+ "sha256": "762f94c43f5f3acd7e2ebd6d1c8b4ba2c029e0071daaf547ace8f15e98bacd9f"
103
+ },
104
+ "metadata/taco_leetcode/source_manifest.json": {
105
+ "bytes": 3337,
106
+ "sha256": "e1f1aba4bb4149303694a8e99a177a0eca8e71ad0e8bd27dc2290f388a005aa8"
107
+ },
108
+ "metadata/taco_leetcode/taxonomy.json": {
109
+ "bytes": 991,
110
+ "sha256": "e28786f2f9d89723d0fe2ef33ae3f2df95a1b09f10f9d784d3b9b6bf155124dd"
111
+ },
112
+ "metadata/validation_report.json": {
113
+ "bytes": 1802,
114
+ "sha256": "e1aff965903d91f5f489463c4acac910e30be9f5ffc90104e7d3f788f99b5bfd"
115
+ },
116
+ "NOTICE.md": {
117
+ "bytes": 823,
118
+ "sha256": "6480096e84a44838ce4e5d6aaf7dee78be3037bd93a625c032c39cc2fedf4d88"
119
+ },
120
+ "README.md": {
121
+ "bytes": 2397,
122
+ "sha256": "6ce733786d33625e55f3f4e1c546db0d23f41a3369199c7f52e9445509cabc3d"
123
+ },
124
+ "requirements.txt": {
125
+ "bytes": 46,
126
+ "sha256": "f099c62b8f276a0de63c9b76c820e07b76fa3bb6b4c24c2e1760af1a5e9f4a49"
127
+ },
128
+ "scripts/build_kodcode.py": {
129
+ "bytes": 3176,
130
+ "sha256": "2383109536a512555a7d57af608cadf06c4c4d179c411e977b7d7d40ddfaed4b"
131
+ },
132
+ "scripts/build_taco_leetcode.py": {
133
+ "bytes": 8344,
134
+ "sha256": "e9a14358a2d83fd6e966b9b3cba6f02da2b5de8d9df34c5504894384b8e8b010"
135
+ },
136
+ "scripts/release_utils.py": {
137
+ "bytes": 2995,
138
+ "sha256": "9d8d4ef4c509818376987acb2969efe9437732a26e7713c5942f51bb7fe83bcf"
139
+ },
140
+ "scripts/validate_release.py": {
141
+ "bytes": 9964,
142
+ "sha256": "6eb536a434802a79f582aec1912a641cc88785e201c07dc9abc52aa5c0d01f8d"
143
+ },
144
+ "verification/kodcode_reward.py": {
145
+ "bytes": 8324,
146
+ "sha256": "236efba226c40e2b3678ddf54f03d43fd9d968b6a56bf375bb7a07d9066a860c"
147
+ },
148
+ "verification/requirements.txt": {
149
+ "bytes": 210,
150
+ "sha256": "e22fa8f19e502cd2244a89c5c7856621562f207a4fed88ef68bedbf2a8f98127"
151
+ },
152
+ "verification/smoke_test.py": {
153
+ "bytes": 1125,
154
+ "sha256": "3fc784f834a9ec8d004c524071c69cfdcc0d7779e5abffe776d4be0897f29a82"
155
+ },
156
+ "verification/stage3_reward_base.py": {
157
+ "bytes": 17604,
158
+ "sha256": "36e1ec828d7532c6a0a99e978470e2ef135bc8beabdfdcec8672fc006ea69b02"
159
+ },
160
+ "verification/taco_leetcode_reward.py": {
161
+ "bytes": 17700,
162
+ "sha256": "eec5f4e9c426edb48486e1e0e9179856157a3ccb769dd54a2ff4d55e0577c033"
163
+ }
164
+ }
165
+ }
metadata/taco_leetcode/ablation_membership.json ADDED
The diff for this file is too large to render. See raw diff
 
metadata/taco_leetcode/dataset_manifest.json ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1.0.0",
3
+ "family": "taco_leetcode",
4
+ "split_policy": {
5
+ "sft": {
6
+ "seed": 20260907,
7
+ "rows": 100,
8
+ "method": "source/category largest remainder; SHA256(seed:id) rank; unique prompts only",
9
+ "strata": {
10
+ "leetcode2k::data_structure": 6,
11
+ "leetcode2k::dynamic_programming": 2,
12
+ "leetcode2k::graph": 2,
13
+ "leetcode2k::greedy_search": 0,
14
+ "leetcode2k::math_number_theory": 1,
15
+ "leetcode2k::other_algorithm": 0,
16
+ "taco::data_structure": 15,
17
+ "taco::dynamic_programming": 8,
18
+ "taco::graph": 5,
19
+ "taco::greedy_search": 9,
20
+ "taco::implementation_simulation": 8,
21
+ "taco::math_number_theory": 17,
22
+ "taco::no_tags": 21,
23
+ "taco::other_algorithm": 6
24
+ },
25
+ "origin": "Added for this release; not the historical experiment validation set.",
26
+ "historical_sft_rows": 21879,
27
+ "historical_rl_validation_overlap_with_original_sft_train": 71
28
+ },
29
+ "rl": "Original 17,249 train + 100 validation"
30
+ },
31
+ "files": {
32
+ "sft/train": {
33
+ "path": "data/taco_leetcode/sft/train.parquet",
34
+ "rows": 21779,
35
+ "bytes": 38500020,
36
+ "sha256": "0de1e7a0341bc9e735427d35761b53d6918f66b9cb750f4f8cbe26e5965403ef",
37
+ "problem_id_set_sha256": "a86bdadb6164700a5c3f130d6f7fae13cdbaaa1b5060eddcf9e2319c233df553",
38
+ "columns": [
39
+ "id",
40
+ "dataset",
41
+ "arm",
42
+ "source_bucket",
43
+ "removed_category",
44
+ "primary_category",
45
+ "overlap_categories",
46
+ "source",
47
+ "difficulty",
48
+ "name",
49
+ "task_id",
50
+ "tags",
51
+ "raw_tags",
52
+ "skill_types",
53
+ "prompt",
54
+ "answer",
55
+ "messages",
56
+ "raw_primary_category",
57
+ "raw_overlap_categories",
58
+ "problem_id",
59
+ "response",
60
+ "source_row_index"
61
+ ]
62
+ },
63
+ "sft/validation": {
64
+ "path": "data/taco_leetcode/sft/validation.parquet",
65
+ "rows": 100,
66
+ "bytes": 195929,
67
+ "sha256": "3f637a2b0f6e466335dddd08834fa56d1eaabf7b1792bf9cbbda21c95501e362",
68
+ "problem_id_set_sha256": "faaadbec2f35ac2cae8ea3557c3e16c9836ee21d66855810c571fd762be1aac1",
69
+ "columns": [
70
+ "id",
71
+ "dataset",
72
+ "arm",
73
+ "source_bucket",
74
+ "removed_category",
75
+ "primary_category",
76
+ "overlap_categories",
77
+ "source",
78
+ "difficulty",
79
+ "name",
80
+ "task_id",
81
+ "tags",
82
+ "raw_tags",
83
+ "skill_types",
84
+ "prompt",
85
+ "answer",
86
+ "messages",
87
+ "raw_primary_category",
88
+ "raw_overlap_categories",
89
+ "problem_id",
90
+ "response",
91
+ "source_row_index"
92
+ ]
93
+ },
94
+ "rl/train": {
95
+ "path": "data/taco_leetcode/rl/train.parquet",
96
+ "rows": 17249,
97
+ "bytes": 458373045,
98
+ "sha256": "9cda87499760450fa89755a8b61c821b6f58a7421b15e8a8f1ca636705130b3f",
99
+ "problem_id_set_sha256": "e6c155b05f012fefb7ad768459e629e89d90dc22566fb2570b43685f7b7509eb",
100
+ "columns": [
101
+ "prompt",
102
+ "data_source",
103
+ "ability",
104
+ "reward_model",
105
+ "extra_info",
106
+ "problem_id",
107
+ "primary_category",
108
+ "overlap_categories"
109
+ ]
110
+ },
111
+ "rl/validation": {
112
+ "path": "data/taco_leetcode/rl/validation.parquet",
113
+ "rows": 100,
114
+ "bytes": 1224277,
115
+ "sha256": "d049040b92177b9f5651a1db465545bfd0ff44cc6075e0726c19b4e6ceea3441",
116
+ "problem_id_set_sha256": "546e314b99d913a2c6b658114ef67512805ddff33274152b6e8419e9059ff087",
117
+ "columns": [
118
+ "prompt",
119
+ "data_source",
120
+ "ability",
121
+ "reward_model",
122
+ "extra_info",
123
+ "problem_id",
124
+ "primary_category",
125
+ "overlap_categories"
126
+ ]
127
+ }
128
+ }
129
+ }
metadata/taco_leetcode/source_manifest.json ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1.0.0",
3
+ "snapshot": "legacy_full_archive_20260729",
4
+ "upstream": [
5
+ {
6
+ "repo_id": "BAAI/TACO",
7
+ "split": "train",
8
+ "revision": null,
9
+ "revision_note": "Exact upstream revision unrecovered; frozen archive identity retained.",
10
+ "license": "apache-2.0 and upstream source-specific terms"
11
+ },
12
+ {
13
+ "repo_id": "newfacade/LeetCodeDataset",
14
+ "split": "train",
15
+ "revision_prefix": "34803eb64eab",
16
+ "revision_note": "Prefix preserved in the historical source path.",
17
+ "license": "apache-2.0"
18
+ }
19
+ ],
20
+ "archive_part_sha256_recorded": {
21
+ "sft/component_03644": "8856b89b5f01a948f959418e41af6ad5afb28b0bff6f1aa88195090684d41c88",
22
+ "rl/component_03651": "9f8d120bf38eff7e894d15f45aa56ef590f57eaa800d4845786dd018e8e66d43",
23
+ "rl_membership/component_03649": "c1aaa251e432b8b309668f6b01e92e4f844953b8ec2a9b11b821600fa2b4eed7",
24
+ "category_index/component_03642": "7d4637071c2b8d92a2dd424f9b9d8740aff4124bf05267da2a6da5c6c34bef55"
25
+ },
26
+ "source_files": {
27
+ "category_index.json": {
28
+ "bytes": 3485312,
29
+ "sha256": "d459c28e2858bda78e1fadba67cdb58616f819be4a3d98d7df81b9077704f101"
30
+ },
31
+ "memberships.json": {
32
+ "bytes": 4495036,
33
+ "sha256": "082b38d7497da162c5d39706ae011b3723b55a02f5a9ab4321ab0be14be12a25"
34
+ },
35
+ "rl_original_manifest.json": {
36
+ "bytes": 7316,
37
+ "sha256": "86147098122a2b2169867fca28f5285b552b9edc9fe67f555642e1e7bba13c96"
38
+ },
39
+ "rl_train.parquet": {
40
+ "bytes": 458101723,
41
+ "sha256": "1855443b5d49036778acf363790a10245d11956f43950dfdd6ef4d47094563e9"
42
+ },
43
+ "rl_validation.parquet": {
44
+ "bytes": 1222408,
45
+ "sha256": "92ef07f0114717d9724119c8dba29243b3406586bd6ee187e4fe606bbe3ae023"
46
+ },
47
+ "sft_original.parquet": {
48
+ "bytes": 33896246,
49
+ "sha256": "e97678b23a4c696820c1b021edbe8cafa42438fe6f4b2026eebbb33f25582e98"
50
+ },
51
+ "sft_original_identity.json": {
52
+ "bytes": 39,
53
+ "sha256": "c1fbe205bb747152f72189f81272af3c913df913adebe77dcc5f6b4862ead0e7"
54
+ },
55
+ "sft_original_manifest.json": {
56
+ "bytes": 3835894,
57
+ "sha256": "a9b0e9dd3d1fb1447badc2f9044aedaefbbd3b578c2a874c6bcb1eb75acb3309"
58
+ }
59
+ },
60
+ "sft": {
61
+ "historical_rows": 21879,
62
+ "taco": 19493,
63
+ "leetcode": 2386,
64
+ "data_seed": 20260603,
65
+ "release_rows": {
66
+ "train": 21779,
67
+ "validation": 100
68
+ },
69
+ "release_split_seed": 20260907,
70
+ "release_changes": [
71
+ "new fixed holdout",
72
+ "formal category aliases; original labels in raw_*",
73
+ "problem_id/response aliases and original row order index"
74
+ ]
75
+ },
76
+ "rl": {
77
+ "train": 17249,
78
+ "validation": 100,
79
+ "split_seed": 20260609,
80
+ "matched_arm_seed": 20260610,
81
+ "reference_verified_train": 11587,
82
+ "structural_only_train": 5662,
83
+ "reference_verified_validation": 71,
84
+ "structural_only_validation": 29,
85
+ "release_changes": [
86
+ "add ID and formal category columns",
87
+ "replace model directory keys with model names"
88
+ ],
89
+ "reward": "1 if all pass; otherwise 0.8 * passed_tests / total_tests"
90
+ },
91
+ "build_source_layout": [
92
+ "sft_original.parquet",
93
+ "rl_train.parquet",
94
+ "rl_validation.parquet",
95
+ "category_index.json",
96
+ "memberships.json"
97
+ ]
98
+ }
metadata/taco_leetcode/taxonomy.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "taco_leetcode_legacy_7",
3
+ "version": "1.0.0",
4
+ "categories": [
5
+ "math_number_theory",
6
+ "data_structure",
7
+ "dynamic_programming",
8
+ "greedy_search",
9
+ "implementation_simulation",
10
+ "graph",
11
+ "other_algorithm"
12
+ ],
13
+ "unlabeled_value": "no_tags",
14
+ "raw_to_formal": {
15
+ "math_number_theory": "math_number_theory",
16
+ "data_structure": "data_structure",
17
+ "dynamic_programming": "dynamic_programming",
18
+ "greedy_search": "greedy_search",
19
+ "implementation_simulation": "implementation_simulation",
20
+ "graph": "graph",
21
+ "other_algorithm": "other_algorithm",
22
+ "no_tags": "no_tags",
23
+ "sorting": "other_algorithm",
24
+ "string": "other_algorithm",
25
+ "bit_manipulation": "other_algorithm",
26
+ "recursion_backtracking": "other_algorithm",
27
+ "geometry": "other_algorithm",
28
+ "other_tagged": "other_algorithm"
29
+ },
30
+ "ablation_rule": "Remove any row whose overlap_categories contains the selected category."
31
+ }
metadata/validation_report.json ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "status": "PASS",
3
+ "configs": {
4
+ "kodcode_sft": {
5
+ "train_rows": 35974,
6
+ "validation_rows": 100,
7
+ "train_validation_id_overlap": 0,
8
+ "train_validation_prompt_overlap": 0,
9
+ "huggingface_load": "PASS"
10
+ },
11
+ "kodcode_rl": {
12
+ "train_rows": 35974,
13
+ "validation_rows": 100,
14
+ "train_validation_id_overlap": 0,
15
+ "train_validation_prompt_overlap": 0,
16
+ "test_cases": {
17
+ "train": 210741,
18
+ "validation": 572
19
+ },
20
+ "verification": {
21
+ "train": {},
22
+ "validation": {}
23
+ },
24
+ "huggingface_load": "PASS"
25
+ },
26
+ "taco_leetcode_sft": {
27
+ "train_rows": 21779,
28
+ "validation_rows": 100,
29
+ "train_validation_id_overlap": 0,
30
+ "train_validation_prompt_overlap": 0,
31
+ "huggingface_load": "PASS"
32
+ },
33
+ "taco_leetcode_rl": {
34
+ "train_rows": 17249,
35
+ "validation_rows": 100,
36
+ "train_validation_id_overlap": 0,
37
+ "train_validation_prompt_overlap": 0,
38
+ "test_cases": {
39
+ "train": 993732,
40
+ "validation": 5433
41
+ },
42
+ "verification": {
43
+ "train": {
44
+ "reference_execution": 11587,
45
+ "structural_only": 5662
46
+ },
47
+ "validation": {
48
+ "structural_only": 29,
49
+ "reference_execution": 71
50
+ }
51
+ },
52
+ "huggingface_load": "PASS"
53
+ }
54
+ },
55
+ "checks": [
56
+ "hashes",
57
+ "every-row schema",
58
+ "split IDs",
59
+ "split prompts",
60
+ "original question IDs",
61
+ "reward test structure",
62
+ "all ablation memberships"
63
+ ],
64
+ "cross_config_id_overlap": {
65
+ "taco_sft_train_vs_rl_validation": 71,
66
+ "taco_sft_validation_vs_rl_train": 48,
67
+ "note": "Independent historical experiments; not a joint multi-stage holdout."
68
+ }
69
+ }
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ datasets==4.8.5
2
+ pyarrow==23.0.1
3
+ PyYAML==6.0.2
scripts/build_kodcode.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Build from the frozen labeled snapshot, or export a recorded ablation arm."""
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import shutil
6
+ from pathlib import Path
7
+
8
+ import pyarrow.parquet as pq
9
+
10
+ from release_utils import ROOT, export_rows, load_json, make_manifest, member_record, sha256, write_json
11
+
12
+ EXPECTED = {
13
+ 'sft_train': 'f28beea278bfc762fad78a3cb11041380e765cbb0c328104b34a0023e202001c',
14
+ 'rl_train': 'a23ea34d57279ae59d7068c4bbd55df08df49b3d4ca42853a49302365d54f224',
15
+ 'sft_validation': '12b191279320d21ef8ca008e9ca75fa39cc41d061880f62ac0a142a139bcc232',
16
+ 'rl_validation': '380992eb51a792f641d31306704e5eb58f26ef53e4d81ee4757c5552cf046ece',
17
+ }
18
+
19
+
20
+ def build(source, root):
21
+ for name, expected in EXPECTED.items():
22
+ kind, split = name.split('_')
23
+ path = source / (name + '.parquet')
24
+ if sha256(path) != expected:
25
+ raise ValueError(f'Frozen source identity mismatch: {name}')
26
+ dest = root / 'data/kodcode' / kind / (split + '.parquet')
27
+ dest.parent.mkdir(parents=True, exist_ok=True)
28
+ shutil.copyfile(path, dest)
29
+ metadata = root / 'metadata/kodcode'
30
+ metadata.mkdir(parents=True, exist_ok=True)
31
+ shutil.copyfile(source / 'taxonomy.json', metadata / 'taxonomy.json')
32
+ recorded = load_json(source / 'original_arm_manifest.json')
33
+ ids = load_json(source / 'memberships.json')
34
+ arms = {}
35
+ for item in recorded['arms']:
36
+ arm = member_record(ids[item['name']], item['removed_category'])
37
+ if arm['rows'] != item['rows'] or arm['problem_id_set_sha256'] != item['problem_id_set_sha256']:
38
+ raise ValueError('Historical arm identity mismatch: ' + item['name'])
39
+ arm['sampling_seed'] = item.get('sampling_seed')
40
+ arms[item['name']] = arm
41
+ write_json(metadata / 'ablation_membership.json', {
42
+ 'version': '1.0.0', 'data_seed': recorded['data_seed'],
43
+ 'rule': 'Remove the primary category only, then use the frozen equal-size sample.',
44
+ 'applies_to': ['kodcode_sft/train', 'kodcode_rl/train'], 'arms': arms,
45
+ }, compact=True)
46
+ make_manifest(root, 'kodcode', {'train': 'historical', 'validation': 'historical fixed 100; shared SFT/RL'})
47
+
48
+
49
+ def main():
50
+ parser = argparse.ArgumentParser(description=__doc__)
51
+ parser.add_argument('--source', type=Path, help='Frozen source export with sft_train.parquet, etc.')
52
+ parser.add_argument('--root', type=Path, default=ROOT)
53
+ parser.add_argument('--arm')
54
+ parser.add_argument('--kind', choices=['sft', 'rl'], default='sft')
55
+ parser.add_argument('--output', type=Path)
56
+ args = parser.parse_args()
57
+ if args.arm:
58
+ if args.output is None:
59
+ parser.error('--output is required with --arm')
60
+ membership = load_json(args.root / 'metadata/kodcode/ablation_membership.json')['arms'][args.arm]
61
+ table = pq.read_table(args.root / 'data/kodcode' / args.kind / 'train.parquet')
62
+ export_rows(table, membership['problem_ids'], args.output)
63
+ elif args.source:
64
+ build(args.source, args.root)
65
+ else:
66
+ parser.error('Use --source to build or --arm NAME --output FILE to export.')
67
+
68
+
69
+ if __name__ == '__main__':
70
+ main()
scripts/build_taco_leetcode.py ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Build the legacy family, add a fixed SFT holdout, or export historical arms."""
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import hashlib
6
+ from collections import Counter, defaultdict
7
+ from pathlib import Path
8
+
9
+ import pyarrow as pa
10
+ import pyarrow.parquet as pq
11
+
12
+ from release_utils import (ROOT, export_rows, load_json, make_manifest, member_record,
13
+ normalized_prompt, write_json, write_parquet)
14
+
15
+ SPLIT_SEED = 20260907
16
+ CATEGORIES = ['math_number_theory', 'data_structure', 'dynamic_programming', 'greedy_search',
17
+ 'implementation_simulation', 'graph', 'other_algorithm']
18
+ RAW_TO_FORMAL = {x: x for x in CATEGORIES + ['no_tags']}
19
+ RAW_TO_FORMAL.update({x: 'other_algorithm' for x in
20
+ ['sorting', 'string', 'bit_manipulation', 'recursion_backtracking', 'geometry', 'other_tagged']})
21
+
22
+
23
+ def formal(value):
24
+ return RAW_TO_FORMAL.get(value, 'other_algorithm') if value else 'no_tags'
25
+
26
+
27
+ def choose_validation(rows, count=100):
28
+ """Largest-remainder source/category allocation, hash-ranked unique prompts."""
29
+ multiplicity = Counter(normalized_prompt(r['prompt']) for r in rows)
30
+ strata = defaultdict(list)
31
+ full_counts = Counter((r['dataset'], r['primary_category']) for r in rows)
32
+ for row in rows:
33
+ if multiplicity[normalized_prompt(row['prompt'])] == 1:
34
+ strata[row['dataset'], row['primary_category']].append(row)
35
+ quotas = {key: count * n // len(rows) for key, n in full_counts.items()}
36
+ remaining = count - sum(quotas.values())
37
+ order = sorted(full_counts, key=lambda key: (-(count * full_counts[key] % len(rows)), key))
38
+ for key in order[:remaining]:
39
+ quotas[key] += 1
40
+ selected = []
41
+ for key in sorted(quotas):
42
+ if len(strata[key]) < quotas[key]:
43
+ raise ValueError(f'Insufficient unique prompts for stratum {key}')
44
+ ranked = sorted(strata[key], key=lambda r: hashlib.sha256(f'{SPLIT_SEED}:{r["id"]}'.encode()).hexdigest())
45
+ selected.extend(r['id'] for r in ranked[:quotas[key]])
46
+ assert len(selected) == count
47
+ return set(selected), {'seed': SPLIT_SEED, 'rows': count,
48
+ 'method': 'source/category largest remainder; SHA256(seed:id) rank; unique prompts only',
49
+ 'strata': {'::'.join(k): v for k, v in sorted(quotas.items())}}
50
+
51
+
52
+ def build(source, root):
53
+ rows = pq.read_table(source / 'sft_original.parquet').to_pylist()
54
+ if len(rows) != 21879 or len({r['id'] for r in rows}) != 21879:
55
+ raise ValueError('Expected the original 21,879 distinct SFT rows')
56
+ for row in rows:
57
+ row['raw_primary_category'] = row['primary_category']
58
+ row['raw_overlap_categories'] = row['overlap_categories']
59
+ row['primary_category'] = formal(row['primary_category'])
60
+ row['overlap_categories'] = sorted({formal(x) for x in
61
+ (row['raw_overlap_categories'] or [row['raw_primary_category']])})
62
+ selected, policy = choose_validation(rows)
63
+ full_table = pa.Table.from_pylist(rows)
64
+ full_table = full_table.append_column('problem_id', full_table['id'])
65
+ full_table = full_table.append_column('response', full_table['answer'])
66
+ full_table = full_table.append_column('source_row_index', pa.array(range(len(rows)), type=pa.int32()))
67
+ for split in ['train', 'validation']:
68
+ indices = [i for i, r in enumerate(rows) if (r['id'] in selected) == (split == 'validation')]
69
+ write_parquet(root / 'data/taco_leetcode/sft' / (split + '.parquet'), full_table.take(pa.array(indices)))
70
+ categories = load_json(source / 'category_index.json')
71
+ rl_ids = {}
72
+ for split in ['train', 'validation']:
73
+ table = pq.read_table(source / ('rl_' + split + '.parquet'))
74
+ infos = table['extra_info'].to_pylist()
75
+ ids = [info['problem_id'] for info in infos]
76
+ rl_ids[split] = ids
77
+ if not set(ids) <= categories.keys():
78
+ raise ValueError('Missing original RL category index')
79
+ # Retain model names and counts, without machine-specific filesystem paths.
80
+ for info in infos:
81
+ token_counts = info.get('prompt_tokens_by_model')
82
+ if token_counts:
83
+ info['prompt_tokens_by_model'] = {Path(k).name: v for k, v in token_counts.items()}
84
+ table = table.set_column(table.schema.get_field_index('extra_info'), 'extra_info', pa.array(infos))
85
+ table = table.append_column('problem_id', pa.array(ids))
86
+ table = table.append_column('primary_category', pa.array([formal(categories[x]['primary_category']) for x in ids]))
87
+ table = table.append_column('overlap_categories', pa.array([
88
+ sorted({formal(v) for v in (categories[x]['overlap_categories'] or [categories[x]['primary_category']])})
89
+ for x in ids], type=pa.list_(pa.string())))
90
+ write_parquet(root / 'data/taco_leetcode/rl' / (split + '.parquet'), table)
91
+ recorded = load_json(source / 'memberships.json')
92
+ membership = {'version': '1.0.0', 'sft_historical': {}, 'sft_release': {}, 'rl_historical': {},
93
+ 'sft_rule': 'Frozen original arms, followed by removal of the new SFT holdout for release arms.',
94
+ 'rl_rule': 'Remove every intersecting overlap category; frozen seed-20260610 12,168-row samples.',
95
+ 'split_seed': SPLIT_SEED, 'validation_ids': sorted(selected)}
96
+ for arm, ids in recorded['sft'].items():
97
+ removed = arm[3:] if arm.startswith('no_') else None
98
+ membership['sft_historical'][arm] = member_record(ids, removed)
99
+ membership['sft_release'][arm] = member_record([x for x in ids if x not in selected], removed)
100
+ membership['rl_historical']['full_dapo'] = member_record(rl_ids['train'])
101
+ for arm, ids in recorded['rl'].items():
102
+ membership['rl_historical'][arm] = member_record(ids, arm[3:] if arm.startswith('no_') else None)
103
+ metadata = root / 'metadata/taco_leetcode'
104
+ write_json(metadata / 'ablation_membership.json', membership, compact=True)
105
+ write_json(metadata / 'taxonomy.json', {'name': 'taco_leetcode_legacy_7', 'version': '1.0.0',
106
+ 'categories': CATEGORIES, 'unlabeled_value': 'no_tags', 'raw_to_formal': RAW_TO_FORMAL,
107
+ 'ablation_rule': 'Remove any row whose overlap_categories contains the selected category.'})
108
+ policy['origin'] = 'Added for this release; not the historical experiment validation set.'
109
+ policy['historical_sft_rows'] = 21879
110
+ policy['historical_rl_validation_overlap_with_original_sft_train'] = len(set(rl_ids['validation']) & {r['id'] for r in rows})
111
+ make_manifest(root, 'taco_leetcode', {'sft': policy, 'rl': 'Original 17,249 train + 100 validation'})
112
+
113
+
114
+ def main():
115
+ parser = argparse.ArgumentParser(description=__doc__)
116
+ parser.add_argument('--source', type=Path, help='Frozen source export directory')
117
+ parser.add_argument('--root', type=Path, default=ROOT)
118
+ parser.add_argument('--arm')
119
+ parser.add_argument('--kind', choices=['sft', 'rl'], default='sft')
120
+ parser.add_argument('--historical', action='store_true', help='Restore original SFT membership including the new holdout')
121
+ parser.add_argument('--output', type=Path)
122
+ args = parser.parse_args()
123
+ if args.arm:
124
+ if args.output is None:
125
+ parser.error('--output is required with --arm')
126
+ members = load_json(args.root / 'metadata/taco_leetcode/ablation_membership.json')
127
+ kind = 'rl_historical' if args.kind == 'rl' else 'sft_historical' if args.historical else 'sft_release'
128
+ table = pq.read_table(args.root / 'data/taco_leetcode' / args.kind / 'train.parquet')
129
+ if args.kind == 'sft' and args.historical:
130
+ table = pa.concat_tables([table, pq.read_table(args.root / 'data/taco_leetcode/sft/validation.parquet')])
131
+ table = table.set_column(table.schema.get_field_index('primary_category'), 'primary_category', table['raw_primary_category'])
132
+ table = table.set_column(table.schema.get_field_index('overlap_categories'), 'overlap_categories', table['raw_overlap_categories'])
133
+ export_rows(table, members[kind][args.arm]['problem_ids'], args.output)
134
+ elif args.source:
135
+ build(args.source, args.root)
136
+ else:
137
+ parser.error('Use --source to build or --arm NAME --output FILE to export.')
138
+
139
+
140
+ if __name__ == '__main__':
141
+ main()
scripts/release_utils.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Small, deterministic helpers for the four dataset configurations."""
2
+ from __future__ import annotations
3
+
4
+ import hashlib
5
+ import json
6
+ from pathlib import Path
7
+
8
+ import pyarrow as pa
9
+ import pyarrow.parquet as pq
10
+
11
+ ROOT = Path(__file__).resolve().parents[1]
12
+
13
+
14
+ def load_json(path):
15
+ return json.loads(Path(path).read_text(encoding='utf-8'))
16
+
17
+
18
+ def write_json(path, value, *, compact=False):
19
+ path = Path(path)
20
+ path.parent.mkdir(parents=True, exist_ok=True)
21
+ path.write_text(json.dumps(value, ensure_ascii=False, indent=None if compact else 2,
22
+ separators=(',', ':') if compact else None) + '\n', encoding='utf-8')
23
+
24
+
25
+ def sha256(path):
26
+ result = hashlib.sha256()
27
+ with Path(path).open('rb') as handle:
28
+ for block in iter(lambda: handle.read(4194304), b''):
29
+ result.update(block)
30
+ return result.hexdigest()
31
+
32
+
33
+ def id_hash(ids):
34
+ return hashlib.sha256(('\n'.join(sorted(ids)) + '\n').encode()).hexdigest()
35
+
36
+
37
+ def normalized_prompt(text):
38
+ return ' '.join(text.split())
39
+
40
+
41
+ def ids_from_table(table):
42
+ if 'problem_id' in table.column_names:
43
+ return table['problem_id'].to_pylist()
44
+ return [row['problem_id'] for row in table['extra_info'].to_pylist()]
45
+
46
+
47
+ def write_parquet(path, table):
48
+ path = Path(path)
49
+ path.parent.mkdir(parents=True, exist_ok=True)
50
+ pq.write_table(table, path, compression='zstd', row_group_size=1024)
51
+
52
+
53
+ def describe_file(path, root):
54
+ path = Path(path)
55
+ parquet = pq.ParquetFile(path)
56
+ columns = ['problem_id'] if 'problem_id' in parquet.schema_arrow.names else ['extra_info']
57
+ ids = ids_from_table(parquet.read(columns=columns))
58
+ return {'path': path.relative_to(root).as_posix(), 'rows': parquet.metadata.num_rows,
59
+ 'bytes': path.stat().st_size, 'sha256': sha256(path),
60
+ 'problem_id_set_sha256': id_hash(ids), 'columns': parquet.schema_arrow.names}
61
+
62
+
63
+ def make_manifest(root, family, split_policy):
64
+ files = {}
65
+ for kind in ['sft', 'rl']:
66
+ for split in ['train', 'validation']:
67
+ path = root / 'data' / family / kind / (split + '.parquet')
68
+ files[f'{kind}/{split}'] = describe_file(path, root)
69
+ result = {'version': '1.0.0', 'family': family, 'split_policy': split_policy, 'files': files}
70
+ write_json(root / 'metadata' / family / 'dataset_manifest.json', result)
71
+ return result
72
+
73
+
74
+ def member_record(ids, removed_category=None):
75
+ return {'rows': len(ids), 'problem_ids': ids, 'problem_id_set_sha256': id_hash(ids),
76
+ 'removed_category': removed_category}
77
+
78
+
79
+ def export_rows(table, ids, destination):
80
+ all_ids = ids_from_table(table)
81
+ lookup = {v: i for i, v in enumerate(all_ids)}
82
+ if len(lookup) != len(all_ids):
83
+ raise ValueError('Duplicate source IDs')
84
+ missing = set(ids) - lookup.keys()
85
+ if missing:
86
+ raise ValueError(f'{len(missing)} arm IDs absent from this split')
87
+ write_parquet(destination, table.take(pa.array([lookup[v] for v in ids], type=pa.int64())))
scripts/validate_release.py ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Validate every row and recorded identity; optionally load all HF configs."""
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import json
6
+ import sys
7
+ from collections import Counter
8
+ from pathlib import Path
9
+
10
+ import pyarrow.parquet as pq
11
+ import yaml
12
+
13
+ from release_utils import ROOT, id_hash, load_json, normalized_prompt, sha256, write_json
14
+
15
+ EXPECTED = {'kodcode_sft': (35974, 100), 'kodcode_rl': (35974, 100),
16
+ 'taco_leetcode_sft': (21779, 100), 'taco_leetcode_rl': (17249, 100)}
17
+
18
+
19
+ def check_file(path, family, kind, allowed):
20
+ parquet = pq.ParquetFile(path)
21
+ cols = ['problem_id', 'primary_category', 'prompt']
22
+ cols += ['response', 'messages'] if kind == 'sft' else ['reward_model', 'extra_info']
23
+ if family == 'kodcode' and kind == 'sft':
24
+ cols += ['original_question_id']
25
+ if family == 'taco_leetcode':
26
+ cols += ['overlap_categories']
27
+ ids, prompts, originals, categories, overlaps = [], {}, set(), {}, {}
28
+ verification = Counter()
29
+ tests_total = 0
30
+ for batch in parquet.iter_batches(batch_size=64, columns=cols):
31
+ for row in batch.to_pylist():
32
+ problem_id = row['problem_id']
33
+ assert isinstance(problem_id, str) and problem_id
34
+ assert row['primary_category'] in allowed, (problem_id, row['primary_category'])
35
+ ids.append(problem_id)
36
+ categories[problem_id] = row['primary_category']
37
+ if family == 'taco_leetcode':
38
+ assert row['overlap_categories'] and set(row['overlap_categories']) <= allowed
39
+ overlaps[problem_id] = row['overlap_categories']
40
+ if kind == 'sft':
41
+ assert isinstance(row['prompt'], str) and row['prompt'].strip()
42
+ assert isinstance(row['response'], str) and row['response'].strip()
43
+ messages = row['messages']
44
+ assert messages and messages[-1]['role'] == 'assistant'
45
+ assert messages[-1]['content'] == row['response']
46
+ users = [m['content'] for m in messages if m['role'] == 'user']
47
+ assert users and users[-1] == row['prompt']
48
+ text = row['prompt']
49
+ if family == 'kodcode':
50
+ originals.add(row['original_question_id'])
51
+ else:
52
+ messages = row['prompt']
53
+ assert messages and all(m['role'] in ('user', 'system') for m in messages)
54
+ assert any(m['role'] == 'user' and m['content'].strip() for m in messages)
55
+ info = row['extra_info']
56
+ assert info['problem_id'] == problem_id
57
+ ground = row['reward_model']['ground_truth']
58
+ ground = json.loads(ground) if isinstance(ground, str) else ground
59
+ assert ground['problem_id'] == problem_id
60
+ if family == 'kodcode':
61
+ assert ground['test_code'].strip() and ground['test_functions']
62
+ n = len(ground['test_functions'])
63
+ assert info['source_full_execution_verified'] is True
64
+ originals.add(info['original_question_id'])
65
+ else:
66
+ assert ground['tests']
67
+ assert ground['mode'] in ('stdin', 'function'), ground['mode']
68
+ n = len(ground['tests'])
69
+ verification['reference_execution' if info['canonical_verified'] else 'structural_only'] += 1
70
+ assert n == info['test_count_used'], (problem_id, n, info['test_count_used'])
71
+ tests_total += n
72
+ text = '\n'.join(m['content'] for m in messages if m['role'] == 'user')
73
+ prompts[problem_id] = normalized_prompt(text)
74
+ assert len(set(ids)) == len(ids), f'Duplicate IDs in {path}'
75
+ return {'ids': ids, 'prompts': prompts, 'originals': originals, 'categories': categories,
76
+ 'overlaps': overlaps, 'verification': dict(verification), 'tests': tests_total}
77
+
78
+
79
+ def check_members(members, pool, *, overlap_removal=False):
80
+ for name, item in members.items():
81
+ ids = item['problem_ids']
82
+ assert len(ids) == item['rows'] == len(set(ids))
83
+ assert id_hash(ids) == item['problem_id_set_sha256']
84
+ assert set(ids) <= pool['categories'].keys(), name
85
+ removed = item['removed_category']
86
+ if removed:
87
+ for pid in ids:
88
+ labels = pool['overlaps'][pid] if overlap_removal else [pool['categories'][pid]]
89
+ assert removed not in labels, (name, pid)
90
+
91
+
92
+ def main():
93
+ parser = argparse.ArgumentParser(description=__doc__)
94
+ parser.add_argument('--root', type=Path, default=ROOT)
95
+ parser.add_argument('--hf', action='store_true', help='Load all four configurations using datasets')
96
+ parser.add_argument('--cache-dir', type=Path, help='HF cache outside the release directory')
97
+ parser.add_argument('--report', type=Path)
98
+ args = parser.parse_args()
99
+ root = args.root.resolve()
100
+ file_index = root / 'metadata/release_files.json'
101
+ if file_index.exists():
102
+ for relpath, identity in load_json(file_index)['files'].items():
103
+ path = root / relpath
104
+ assert path.is_file() and path.stat().st_size == identity['bytes'], relpath
105
+ assert sha256(path) == identity['sha256'], relpath
106
+ print('RELEASE_FILE_INDEX_PASS', flush=True)
107
+ header = root.joinpath('README.md').read_text(encoding='utf-8').split('---', 2)[1]
108
+ configs = yaml.safe_load(header)['configs']
109
+ assert {x['config_name'] for x in configs} == set(EXPECTED)
110
+ report = {'status': 'PASS', 'configs': {}, 'checks': ['hashes', 'every-row schema', 'split IDs',
111
+ 'split prompts', 'original question IDs', 'reward test structure', 'all ablation memberships']}
112
+ checked = {}
113
+ for family in ['kodcode', 'taco_leetcode']:
114
+ manifest = load_json(root / 'metadata' / family / 'dataset_manifest.json')
115
+ taxonomy = load_json(root / 'metadata' / family / 'taxonomy.json')
116
+ allowed = {x['id'] for x in taxonomy['categories']} if family == 'kodcode' else set(taxonomy['categories']) | {'no_tags'}
117
+ for kind in ['sft', 'rl']:
118
+ name = family + '_' + kind
119
+ results = {}
120
+ for split, expected_rows in zip(['train', 'validation'], EXPECTED[name]):
121
+ item = manifest['files'][kind + '/' + split]
122
+ path = root / item['path']
123
+ assert path.stat().st_size == item['bytes']
124
+ assert sha256(path) == item['sha256'], path
125
+ result = check_file(path, family, kind, allowed)
126
+ assert len(result['ids']) == expected_rows == item['rows']
127
+ assert id_hash(result['ids']) == item['problem_id_set_sha256']
128
+ results[split] = result
129
+ checked[name, split] = result
130
+ assert not set(results['train']['ids']) & set(results['validation']['ids'])
131
+ assert not results['train']['originals'] & results['validation']['originals']
132
+ shared_prompts = set(results['train']['prompts'].values()) & set(results['validation']['prompts'].values())
133
+ assert not shared_prompts, (name, 'duplicate prompts across splits', len(shared_prompts))
134
+ report['configs'][name] = {'train_rows': len(results['train']['ids']),
135
+ 'validation_rows': len(results['validation']['ids']),
136
+ 'train_validation_id_overlap': 0, 'train_validation_prompt_overlap': 0}
137
+ if kind == 'rl':
138
+ report['configs'][name]['test_cases'] = {s: r['tests'] for s, r in results.items()}
139
+ report['configs'][name]['verification'] = {s: r['verification'] for s, r in results.items()}
140
+ print(name, 'PASS', flush=True)
141
+ for split in ['train', 'validation']:
142
+ assert set(checked['kodcode_sft', split]['ids']) == set(checked['kodcode_rl', split]['ids'])
143
+ kod_members = load_json(root / 'metadata/kodcode/ablation_membership.json')['arms']
144
+ check_members(kod_members, checked['kodcode_sft', 'train'])
145
+ legacy = load_json(root / 'metadata/taco_leetcode/ablation_membership.json')
146
+ original_sft = {key: {**checked['taco_leetcode_sft', 'train'][key], **checked['taco_leetcode_sft', 'validation'][key]}
147
+ for key in ['categories', 'overlaps']}
148
+ check_members(legacy['sft_historical'], original_sft, overlap_removal=True)
149
+ check_members(legacy['sft_release'], checked['taco_leetcode_sft', 'train'], overlap_removal=True)
150
+ check_members(legacy['rl_historical'], checked['taco_leetcode_rl', 'train'], overlap_removal=True)
151
+ report['cross_config_id_overlap'] = {
152
+ 'taco_sft_train_vs_rl_validation': len(set(checked['taco_leetcode_sft', 'train']['ids']) & set(checked['taco_leetcode_rl', 'validation']['ids'])),
153
+ 'taco_sft_validation_vs_rl_train': len(set(checked['taco_leetcode_sft', 'validation']['ids']) & set(checked['taco_leetcode_rl', 'train']['ids'])),
154
+ 'note': 'Independent historical experiments; not a joint multi-stage holdout.',
155
+ }
156
+ if args.hf:
157
+ from datasets import get_dataset_config_names, load_dataset
158
+ cache = str(args.cache_dir.resolve()) if args.cache_dir else None
159
+ assert set(get_dataset_config_names(str(root), cache_dir=cache)) == set(EXPECTED)
160
+ for name, sizes in EXPECTED.items():
161
+ ds = load_dataset(str(root), name, cache_dir=cache)
162
+ assert set(ds) == {'train', 'validation'}
163
+ for split, expected in zip(['train', 'validation'], sizes):
164
+ assert len(ds[split]) == expected
165
+ assert ds[split][0]['problem_id']
166
+ report['configs'][name]['huggingface_load'] = 'PASS'
167
+ print(name, 'HF_LOAD_PASS', flush=True)
168
+ if args.report:
169
+ write_json(args.report, report)
170
+ print(json.dumps({'status': report['status'], 'configs': len(report['configs'])}))
171
+
172
+
173
+ if __name__ == '__main__':
174
+ main()
verification/kodcode_reward.py ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Sandboxed strict all-tests-pass reward for the verified KodCode RL-10K subset."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import json
7
+ import importlib.util
8
+ import os
9
+ import subprocess
10
+ import sys
11
+ import tempfile
12
+ from pathlib import Path
13
+ from typing import Any
14
+
15
+ _BASE_PATH = Path(__file__).with_name("stage3_reward_base.py")
16
+ _BASE_SPEC = importlib.util.spec_from_file_location("diagnose_dapo_stage3_reward_base", _BASE_PATH)
17
+ if _BASE_SPEC is None or _BASE_SPEC.loader is None:
18
+ raise ImportError(f"cannot load reward base: {_BASE_PATH}")
19
+ _BASE = importlib.util.module_from_spec(_BASE_SPEC)
20
+ _BASE_SPEC.loader.exec_module(_BASE)
21
+ _kill_process_group = _BASE._kill_process_group
22
+ _set_eval_limits = _BASE._set_eval_limits
23
+ extract_code = _BASE.extract_code
24
+
25
+
26
+ STATUS = {
27
+ "passed": 0,
28
+ "wrong_answer": 1,
29
+ "syntax_error": 2,
30
+ "runtime_error": 3,
31
+ "timeout": 4,
32
+ "sandbox_error": 5,
33
+ }
34
+
35
+ SANDBOX = r'''
36
+ import contextlib
37
+ import io
38
+ import json
39
+ import signal
40
+ import sys
41
+ import types
42
+
43
+ payload = json.loads(sys.stdin.read())
44
+ code = payload["code"]
45
+ test_code = payload["test_code"]
46
+ test_names = payload["test_functions"]
47
+ per_test_timeout = float(payload["per_test_timeout"])
48
+
49
+ def emit(status, passed_tests, total_tests, **extra):
50
+ result = {
51
+ "status": status,
52
+ "passed_tests": passed_tests,
53
+ "total_tests": total_tests,
54
+ **extra,
55
+ }
56
+ sys.__stdout__.write(json.dumps(result, ensure_ascii=False) + "\n")
57
+ sys.__stdout__.flush()
58
+
59
+ def on_timeout(signum, frame):
60
+ raise TimeoutError("per-test timeout")
61
+
62
+ total = len(test_names)
63
+ try:
64
+ module = types.ModuleType("solution")
65
+ module.__dict__["__name__"] = "solution"
66
+ captured_out, captured_err = io.StringIO(), io.StringIO()
67
+ with contextlib.redirect_stdout(captured_out), contextlib.redirect_stderr(captured_err):
68
+ exec(compile(code, "<generated_solution>", "exec"), module.__dict__)
69
+ sys.modules["solution"] = module
70
+ test_ns = dict(module.__dict__)
71
+ test_ns["__name__"] = "kodcode_hidden_tests"
72
+ with contextlib.redirect_stdout(captured_out), contextlib.redirect_stderr(captured_err):
73
+ exec(compile(test_code, "<hidden_tests>", "exec"), test_ns)
74
+ except SyntaxError as exc:
75
+ emit("syntax_error", 0, total, error=str(exc)[:500])
76
+ raise SystemExit
77
+ except BaseException as exc:
78
+ emit("runtime_error", 0, total, error=f"{type(exc).__name__}: {exc}"[:500])
79
+ raise SystemExit
80
+
81
+ signal.signal(signal.SIGALRM, on_timeout)
82
+ passed = 0
83
+ wrong = 0
84
+ runtime = 0
85
+ timeouts = 0
86
+ errors = []
87
+ for index, name in enumerate(test_names):
88
+ function = test_ns.get(name)
89
+ if not callable(function):
90
+ runtime += 1
91
+ errors.append({"test": name, "error": "missing test function"})
92
+ continue
93
+ try:
94
+ signal.setitimer(signal.ITIMER_REAL, per_test_timeout)
95
+ with contextlib.redirect_stdout(captured_out), contextlib.redirect_stderr(captured_err):
96
+ function()
97
+ passed += 1
98
+ except (AssertionError,) as exc:
99
+ wrong += 1
100
+ errors.append({"test": name, "error": f"AssertionError: {exc}"[:300]})
101
+ except TimeoutError as exc:
102
+ timeouts += 1
103
+ errors.append({"test": name, "error": str(exc)})
104
+ except BaseException as exc:
105
+ runtime += 1
106
+ errors.append({"test": name, "error": f"{type(exc).__name__}: {exc}"[:300]})
107
+ finally:
108
+ signal.setitimer(signal.ITIMER_REAL, 0)
109
+ if timeouts >= 3:
110
+ remaining = total - (index + 1)
111
+ timeouts += remaining
112
+ break
113
+
114
+ status = "passed" if passed == total else "timeout" if timeouts else "runtime_error" if runtime else "wrong_answer"
115
+ emit(
116
+ status,
117
+ passed,
118
+ total,
119
+ wrong_answers=wrong,
120
+ runtime_errors=runtime,
121
+ timeouts=timeouts,
122
+ errors=errors[:5],
123
+ )
124
+ '''
125
+
126
+
127
+ def _ground_truth(value: Any) -> dict[str, Any]:
128
+ if isinstance(value, str):
129
+ return json.loads(value)
130
+ if isinstance(value, dict):
131
+ return value
132
+ raise TypeError(f"unsupported ground truth type: {type(value).__name__}")
133
+
134
+
135
+ def _run(
136
+ code: str,
137
+ ground_truth: dict[str, Any],
138
+ exec_timeout: float,
139
+ per_test_timeout: float,
140
+ memory_limit_gib: float,
141
+ output_limit_mib: float,
142
+ ) -> dict[str, Any]:
143
+ payload = {
144
+ "code": code,
145
+ "test_code": ground_truth["test_code"],
146
+ "test_functions": ground_truth["test_functions"],
147
+ "per_test_timeout": per_test_timeout,
148
+ }
149
+ with tempfile.TemporaryDirectory(prefix="kodcode_reward_") as temp_dir:
150
+ proc = subprocess.Popen(
151
+ [sys.executable, "-I", "-c", SANDBOX],
152
+ stdin=subprocess.PIPE,
153
+ stdout=subprocess.PIPE,
154
+ stderr=subprocess.PIPE,
155
+ text=True,
156
+ cwd=temp_dir,
157
+ start_new_session=True,
158
+ preexec_fn=lambda: _set_eval_limits(
159
+ memory_limit_gib, exec_timeout, output_limit_mib
160
+ ),
161
+ )
162
+ try:
163
+ stdout, stderr = proc.communicate(
164
+ input=json.dumps(payload, ensure_ascii=False),
165
+ timeout=exec_timeout,
166
+ )
167
+ except subprocess.TimeoutExpired:
168
+ _kill_process_group(proc)
169
+ stdout, stderr = proc.communicate()
170
+ return {
171
+ "status": "timeout",
172
+ "passed_tests": 0,
173
+ "total_tests": len(ground_truth["test_functions"]),
174
+ "error": "completion hard timeout",
175
+ }
176
+ finally:
177
+ if proc.poll() is None:
178
+ _kill_process_group(proc)
179
+ lines = [line for line in stdout.splitlines() if line.strip()]
180
+ if not lines:
181
+ return {
182
+ "status": "sandbox_error",
183
+ "passed_tests": 0,
184
+ "total_tests": len(ground_truth["test_functions"]),
185
+ "error": stderr[-500:],
186
+ }
187
+ try:
188
+ return json.loads(lines[-1])
189
+ except json.JSONDecodeError:
190
+ return {
191
+ "status": "sandbox_error",
192
+ "passed_tests": 0,
193
+ "total_tests": len(ground_truth["test_functions"]),
194
+ "error": (stdout + "\n" + stderr)[-500:],
195
+ }
196
+
197
+
198
+ def compute_score(
199
+ data_source: str,
200
+ solution_str: str,
201
+ ground_truth: Any,
202
+ exec_timeout: float = 180.0,
203
+ per_test_timeout: float = 1.0,
204
+ memory_limit_gib: float = 2.0,
205
+ output_limit_mib: float = 16.0,
206
+ **_: Any,
207
+ ) -> dict[str, float]:
208
+ del data_source
209
+ truth = _ground_truth(ground_truth)
210
+ starter = ""
211
+ code = extract_code(solution_str, starter)
212
+ result = _run(
213
+ code,
214
+ truth,
215
+ float(exec_timeout),
216
+ float(per_test_timeout),
217
+ float(memory_limit_gib),
218
+ float(output_limit_mib),
219
+ )
220
+ passed_tests = int(result.get("passed_tests") or 0)
221
+ total_tests = int(result.get("total_tests") or len(truth["test_functions"]))
222
+ pass_frac = passed_tests / max(total_tests, 1)
223
+ passed = total_tests > 0 and passed_tests == total_tests
224
+ # Training reward is deliberately binary. pass_frac remains diagnostic only.
225
+ score = 1.0 if passed else 0.0
226
+ status = str(result.get("status") or "sandbox_error")
227
+ return {
228
+ "score": float(score),
229
+ "passed": float(passed),
230
+ "pass_frac": float(pass_frac),
231
+ "status_code": float(STATUS.get(status, STATUS["sandbox_error"])),
232
+ "passed_tests": float(passed_tests),
233
+ "total_tests": float(total_tests),
234
+ "wrong_answers": float(result.get("wrong_answers") or 0),
235
+ "runtime_errors": float(result.get("runtime_errors") or 0),
236
+ "timeouts": float(result.get("timeouts") or 0),
237
+ }
238
+
239
+
240
+ if __name__ == "__main__":
241
+ truth = {
242
+ "test_code": (
243
+ "from solution import add\n"
244
+ "def test_one():\n assert add(1, 2) == 3\n"
245
+ "def test_two():\n assert add(-1, 1) == 0\n"
246
+ ),
247
+ "test_functions": ["test_one", "test_two"],
248
+ }
249
+ good = compute_score("selftest", "def add(a, b):\n return a + b\n", truth)
250
+ bad = compute_score("selftest", "def add(a, b):\n return 0\n", truth)
251
+ assert good["score"] == 1.0 and good["passed"] == 1.0, good
252
+ assert bad["score"] == 0.0 and bad["passed"] == 0.0, bad
253
+ assert bad["pass_frac"] == 0.5, bad
254
+ print(json.dumps({"good": good, "bad": bad}, indent=2))
verification/requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Reward modules use the Python standard library on Linux.
2
+ # Some dataset tests additionally import these common packages.
3
+ numpy>=1.26
4
+ pandas>=2.2
5
+ pytest>=8
6
+ scipy>=1.11
7
+ scikit-learn>=1.3
8
+ sympy>=1.12
9
+ Pillow>=10
verification/smoke_test.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Check both reward formulas using tiny, self-contained synthetic tasks."""
2
+ import json
3
+
4
+ import kodcode_reward
5
+ import taco_leetcode_reward
6
+
7
+ truth = {'test_code': 'from solution import add\ndef test_one():\n assert add(1,2)==3\ndef test_two():\n assert add(-1,1)==0\n',
8
+ 'test_functions': ['test_one', 'test_two']}
9
+ good = 'def add(a,b):\n return a+b\n'
10
+ bad = 'def add(a,b):\n return 0\n'
11
+ k_good = kodcode_reward.compute_score('smoke', good, truth)
12
+ k_bad = kodcode_reward.compute_score('smoke', bad, truth)
13
+ assert k_good['score'] == 1 and k_bad['score'] == 0 and k_bad['pass_frac'] == 0.5
14
+ truth = {'mode': 'function', 'entry_point': 'add', 'tests': [
15
+ {'args': [1, 2], 'output': 3}, {'args': [-1, 1], 'output': 0}]}
16
+ t_good = taco_leetcode_reward.compute_score('smoke', good, truth)
17
+ t_bad = taco_leetcode_reward.compute_score('smoke', bad, truth)
18
+ assert t_good['score'] == 1 and t_bad['score'] == 0.4, (t_good, t_bad)
19
+ print(json.dumps({'kodcode': {'full': k_good['score'], 'half': k_bad['score']},
20
+ 'taco_leetcode': {'full': t_good['score'], 'half': t_bad['score']}, 'status': 'PASS'}))
verification/stage3_reward_base.py ADDED
@@ -0,0 +1,540 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Rule-based code reward for Stage 3 verl/DAPO smoke tests."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import ast
7
+ import json
8
+ import os
9
+ import re
10
+ import resource
11
+ import signal
12
+ import subprocess
13
+ import sys
14
+ import tempfile
15
+ from typing import Any
16
+
17
+
18
+ FENCE_RE = re.compile(r"```(?:python|py)?\s*(.*?)```", re.DOTALL | re.IGNORECASE)
19
+ MAX_PARSE_CODE_CHARS = 65_536
20
+ MAX_PARSE_TRIM_ATTEMPTS = 64
21
+
22
+ STATUS_CODE = {
23
+ "passed": 0,
24
+ "syntax_error": 1,
25
+ "missing_entry_point": 2,
26
+ "entry_point_not_callable": 3,
27
+ "wrong_answer": 4,
28
+ "runtime_error": 5,
29
+ "timeout": 6,
30
+ "harness_error": 7,
31
+ "no_tests": 8,
32
+ "eval_error": 9,
33
+ }
34
+
35
+ EVAL_HARNESS = r'''
36
+ import ast
37
+ import io
38
+ import json
39
+ import math
40
+ import signal
41
+ import sys
42
+ import traceback
43
+ from bisect import *
44
+ from collections import *
45
+ from functools import *
46
+ from heapq import *
47
+ from itertools import *
48
+ from math import *
49
+ from operator import *
50
+ from string import *
51
+ from typing import *
52
+
53
+ payload = json.loads(sys.stdin.read())
54
+ code = payload["code"]
55
+ mode = payload["mode"]
56
+ entry_point = payload.get("entry_point")
57
+ tests = payload.get("tests") or []
58
+ per_test_timeout = float(payload.get("per_test_timeout", 2.0))
59
+
60
+ class FakeStdin:
61
+ def __init__(self, text):
62
+ self._text = io.StringIO(str(text))
63
+ self.buffer = io.BytesIO(str(text).encode())
64
+ def read(self, *args):
65
+ return self._text.read(*args)
66
+ def readline(self, *args):
67
+ return self._text.readline(*args)
68
+ def readlines(self, *args):
69
+ return self._text.readlines(*args)
70
+ def __iter__(self):
71
+ return iter(self._text)
72
+
73
+ def norm_text(value):
74
+ text = "" if value is None else str(value)
75
+ return "\n".join(line.rstrip() for line in text.strip().splitlines()).strip()
76
+
77
+ def stdout_equal(got, expected):
78
+ a, b = norm_text(got), norm_text(expected)
79
+ return a == b or a.split() == b.split()
80
+
81
+ def value_equal(a, b):
82
+ if isinstance(a, bool) or isinstance(b, bool):
83
+ return a == b
84
+ if isinstance(a, (int, float)) and isinstance(b, (int, float)):
85
+ return math.isclose(float(a), float(b), rel_tol=1e-6, abs_tol=1e-6)
86
+ if isinstance(a, (list, tuple)) and isinstance(b, (list, tuple)):
87
+ return len(a) == len(b) and all(value_equal(x, y) for x, y in zip(a, b))
88
+ if isinstance(a, dict) and isinstance(b, dict):
89
+ return set(a.keys()) == set(b.keys()) and all(value_equal(a[k], b[k]) for k in a)
90
+ return str(a) == str(b)
91
+
92
+ def result(**kwargs):
93
+ print(json.dumps(kwargs, ensure_ascii=False))
94
+
95
+ def timeout_handler(signum, frame):
96
+ raise TimeoutError("per-test timeout")
97
+
98
+ try:
99
+ ast.parse(code)
100
+ except (SyntaxError, ValueError, MemoryError, RecursionError) as exc:
101
+ result(
102
+ passed=False,
103
+ status="syntax_error",
104
+ interface_ok=False,
105
+ passed_tests=0,
106
+ total_tests=len(tests),
107
+ wrong_answers=0,
108
+ runtime_errors=0,
109
+ timeouts=0,
110
+ error=str(exc)[:300],
111
+ )
112
+ raise SystemExit
113
+
114
+ try:
115
+ if not tests:
116
+ result(
117
+ passed=False,
118
+ status="no_tests",
119
+ interface_ok=False,
120
+ passed_tests=0,
121
+ total_tests=0,
122
+ wrong_answers=0,
123
+ runtime_errors=0,
124
+ timeouts=0,
125
+ )
126
+ raise SystemExit
127
+
128
+ if mode == "function":
129
+ ns = {"__name__": "__main__"}
130
+ signal.signal(signal.SIGALRM, timeout_handler)
131
+ try:
132
+ signal.setitimer(signal.ITIMER_REAL, per_test_timeout)
133
+ exec(compile(code, "<solution>", "exec"), ns)
134
+ except TimeoutError as exc:
135
+ result(
136
+ passed=False,
137
+ status="timeout",
138
+ interface_ok=False,
139
+ passed_tests=0,
140
+ total_tests=len(tests),
141
+ wrong_answers=0,
142
+ runtime_errors=0,
143
+ timeouts=len(tests),
144
+ error=str(exc)[:300],
145
+ )
146
+ raise SystemExit
147
+ finally:
148
+ signal.setitimer(signal.ITIMER_REAL, 0)
149
+ try:
150
+ candidate = eval(entry_point, ns)
151
+ except Exception as exc:
152
+ result(
153
+ passed=False,
154
+ status="missing_entry_point",
155
+ interface_ok=False,
156
+ passed_tests=0,
157
+ total_tests=len(tests),
158
+ wrong_answers=0,
159
+ runtime_errors=0,
160
+ timeouts=0,
161
+ error=str(exc)[:300],
162
+ )
163
+ raise SystemExit
164
+ if not callable(candidate):
165
+ result(
166
+ passed=False,
167
+ status="entry_point_not_callable",
168
+ interface_ok=False,
169
+ passed_tests=0,
170
+ total_tests=len(tests),
171
+ wrong_answers=0,
172
+ runtime_errors=0,
173
+ timeouts=0,
174
+ )
175
+ raise SystemExit
176
+
177
+ passed_tests = 0
178
+ wrong_answers = 0
179
+ runtime_errors = 0
180
+ timeouts = 0
181
+ for idx, test in enumerate(tests):
182
+ args = test.get("args") or []
183
+ kwargs = test.get("kwargs") or {}
184
+ expected = test.get("output")
185
+ try:
186
+ signal.setitimer(signal.ITIMER_REAL, per_test_timeout)
187
+ got = candidate(*args, **kwargs)
188
+ if value_equal(got, expected):
189
+ passed_tests += 1
190
+ else:
191
+ wrong_answers += 1
192
+ except TimeoutError:
193
+ timeouts += 1
194
+ except Exception:
195
+ runtime_errors += 1
196
+ finally:
197
+ signal.setitimer(signal.ITIMER_REAL, 0)
198
+ if timeouts >= 3:
199
+ break
200
+ skipped_after_timeout = len(tests) - (passed_tests + wrong_answers + runtime_errors + timeouts)
201
+ timeouts += max(skipped_after_timeout, 0)
202
+ passed = passed_tests == len(tests)
203
+ status = "passed" if passed else "timeout" if timeouts else "runtime_error" if runtime_errors else "wrong_answer"
204
+ result(
205
+ passed=passed,
206
+ status=status,
207
+ interface_ok=True,
208
+ passed_tests=passed_tests,
209
+ total_tests=len(tests),
210
+ wrong_answers=wrong_answers,
211
+ runtime_errors=runtime_errors,
212
+ timeouts=timeouts,
213
+ )
214
+ else:
215
+ signal.signal(signal.SIGALRM, timeout_handler)
216
+ passed_tests = 0
217
+ wrong_answers = 0
218
+ runtime_errors = 0
219
+ timeouts = 0
220
+ for idx, test in enumerate(tests):
221
+ old_stdin, old_stdout = sys.stdin, sys.stdout
222
+ fake_out = io.StringIO()
223
+ ns = {"__name__": "__main__"}
224
+ case_failed = False
225
+ try:
226
+ sys.stdin = FakeStdin(test.get("input", ""))
227
+ sys.stdout = fake_out
228
+ try:
229
+ signal.setitimer(signal.ITIMER_REAL, per_test_timeout)
230
+ exec(compile(code, "<solution>", "exec"), ns)
231
+ except SystemExit:
232
+ pass
233
+ except TimeoutError:
234
+ timeouts += 1
235
+ case_failed = True
236
+ except Exception:
237
+ runtime_errors += 1
238
+ case_failed = True
239
+ finally:
240
+ signal.setitimer(signal.ITIMER_REAL, 0)
241
+ finally:
242
+ sys.stdin, sys.stdout = old_stdin, old_stdout
243
+ if not case_failed:
244
+ got = fake_out.getvalue()
245
+ expected = test.get("output", "")
246
+ if stdout_equal(got, expected):
247
+ passed_tests += 1
248
+ else:
249
+ wrong_answers += 1
250
+ if timeouts >= 3:
251
+ break
252
+ skipped_after_timeout = len(tests) - (passed_tests + wrong_answers + runtime_errors + timeouts)
253
+ timeouts += max(skipped_after_timeout, 0)
254
+ passed = passed_tests == len(tests)
255
+ status = "passed" if passed else "timeout" if timeouts else "runtime_error" if runtime_errors else "wrong_answer"
256
+ result(
257
+ passed=passed,
258
+ status=status,
259
+ interface_ok=True,
260
+ passed_tests=passed_tests,
261
+ total_tests=len(tests),
262
+ wrong_answers=wrong_answers,
263
+ runtime_errors=runtime_errors,
264
+ timeouts=timeouts,
265
+ )
266
+ except TimeoutError as exc:
267
+ result(
268
+ passed=False,
269
+ status="timeout",
270
+ interface_ok=True,
271
+ passed_tests=0,
272
+ total_tests=len(tests),
273
+ wrong_answers=0,
274
+ runtime_errors=0,
275
+ timeouts=len(tests),
276
+ error=str(exc)[:300],
277
+ )
278
+ except Exception as exc:
279
+ result(
280
+ passed=False,
281
+ status="runtime_error",
282
+ interface_ok=True,
283
+ passed_tests=0,
284
+ total_tests=len(tests),
285
+ wrong_answers=0,
286
+ runtime_errors=len(tests),
287
+ timeouts=0,
288
+ error=str(exc)[:300],
289
+ traceback=traceback.format_exc()[-500:],
290
+ )
291
+ '''
292
+
293
+
294
+ def _json_loads_maybe(value: Any) -> Any:
295
+ if isinstance(value, str):
296
+ try:
297
+ return json.loads(value)
298
+ except Exception:
299
+ return {}
300
+ return value if isinstance(value, dict) else {}
301
+
302
+
303
+ def _trim_parseable_code(code: str) -> str:
304
+ # Generated text can contain NUL bytes, which make ast.parse raise
305
+ # ValueError instead of SyntaxError. They are never valid Python source.
306
+ text = code.replace("\x00", "").strip()[:MAX_PARSE_CODE_CHARS]
307
+ if not text:
308
+ return text
309
+ lines = text.splitlines()
310
+ first_end = max(1, len(lines) - MAX_PARSE_TRIM_ATTEMPTS + 1)
311
+ for end in range(len(lines), first_end - 1, -1):
312
+ candidate = "\n".join(lines[:end]).strip()
313
+ if not candidate:
314
+ continue
315
+ try:
316
+ ast.parse(candidate)
317
+ return candidate
318
+ except (SyntaxError, ValueError, MemoryError, RecursionError):
319
+ continue
320
+ return text
321
+
322
+
323
+ def extract_code(text: str, starter_code: str = "") -> str:
324
+ text = text or ""
325
+ fenced = FENCE_RE.findall(text)
326
+ if fenced:
327
+ code = fenced[0].strip()
328
+ else:
329
+ lines = text.splitlines()
330
+ start = None
331
+ for idx, line in enumerate(lines):
332
+ stripped = line.strip()
333
+ if re.match(r"(from\s+\S+\s+import\s+|import\s+\S+|class\s+\w+|def\s+\w+|if\s+__name__)", stripped):
334
+ start = idx
335
+ break
336
+ code = "\n".join(lines[start:]).strip() if start is not None else text.strip()
337
+
338
+ starter = (starter_code or "").strip()
339
+ if starter and "class Solution" in code and starter not in code:
340
+ code = starter.rstrip() + "\n\n" + code
341
+ return _trim_parseable_code(code)
342
+
343
+
344
+ def _format_ok(solution_str: str) -> bool:
345
+ text = (solution_str or "").strip()
346
+ if not text:
347
+ return False
348
+ if "```" in text:
349
+ return False
350
+ prose_markers = ["Here is", "Explanation", "```python", "The solution"]
351
+ return not any(marker.lower() in text[:160].lower() for marker in prose_markers)
352
+
353
+
354
+ def _set_eval_limits(memory_limit_gib: float, exec_timeout: float, output_limit_mib: float) -> None:
355
+ memory_bytes = max(1, int(memory_limit_gib * 1024**3))
356
+ output_bytes = max(1, int(output_limit_mib * 1024**2))
357
+ cpu_seconds = max(1, int(exec_timeout) + 1)
358
+ resource.setrlimit(resource.RLIMIT_AS, (memory_bytes, memory_bytes))
359
+ resource.setrlimit(resource.RLIMIT_CPU, (cpu_seconds, cpu_seconds))
360
+ resource.setrlimit(resource.RLIMIT_FSIZE, (output_bytes, output_bytes))
361
+ resource.setrlimit(resource.RLIMIT_NOFILE, (128, 128))
362
+ resource.setrlimit(resource.RLIMIT_NPROC, (256, 256))
363
+
364
+
365
+ def _kill_process_group(proc: subprocess.Popen[str]) -> None:
366
+ try:
367
+ os.killpg(proc.pid, signal.SIGKILL)
368
+ except ProcessLookupError:
369
+ pass
370
+
371
+
372
+ def _run_eval(
373
+ code: str,
374
+ meta: dict[str, Any],
375
+ exec_timeout: float,
376
+ per_test_timeout: float,
377
+ memory_limit_gib: float,
378
+ output_limit_mib: float,
379
+ ) -> dict[str, Any]:
380
+ payload = {
381
+ "code": code,
382
+ "mode": meta.get("mode"),
383
+ "entry_point": meta.get("entry_point"),
384
+ "tests": meta.get("tests") or [],
385
+ "per_test_timeout": per_test_timeout,
386
+ }
387
+ proc = None
388
+ try:
389
+ with (
390
+ tempfile.TemporaryFile(mode="w+t", encoding="utf-8") as stdout_file,
391
+ tempfile.TemporaryFile(mode="w+t", encoding="utf-8") as stderr_file,
392
+ ):
393
+ proc = subprocess.Popen(
394
+ [sys.executable, "-c", EVAL_HARNESS],
395
+ stdin=subprocess.PIPE,
396
+ stdout=stdout_file,
397
+ stderr=stderr_file,
398
+ text=True,
399
+ start_new_session=True,
400
+ preexec_fn=lambda: _set_eval_limits(memory_limit_gib, exec_timeout, output_limit_mib),
401
+ )
402
+ try:
403
+ proc.communicate(input=json.dumps(payload, ensure_ascii=False), timeout=exec_timeout)
404
+ except subprocess.TimeoutExpired:
405
+ _kill_process_group(proc)
406
+ proc.communicate()
407
+ raise
408
+ _kill_process_group(proc)
409
+ stdout_file.seek(0)
410
+ stdout = stdout_file.read()
411
+
412
+ parsed = None
413
+ for line in reversed(stdout.strip().splitlines()):
414
+ candidate = _json_loads_maybe(line)
415
+ if isinstance(candidate, dict) and "passed" in candidate and "total_tests" in candidate:
416
+ parsed = candidate
417
+ break
418
+ if parsed is None:
419
+ return {
420
+ "passed": False,
421
+ "status": "harness_error",
422
+ "interface_ok": False,
423
+ "passed_tests": 0,
424
+ "total_tests": len(payload["tests"]),
425
+ "wrong_answers": 0,
426
+ "runtime_errors": len(payload["tests"]),
427
+ "timeouts": 0,
428
+ }
429
+ return parsed
430
+ except subprocess.TimeoutExpired:
431
+ return {
432
+ "passed": False,
433
+ "status": "timeout",
434
+ "interface_ok": True,
435
+ "passed_tests": 0,
436
+ "total_tests": len(payload["tests"]),
437
+ "wrong_answers": 0,
438
+ "runtime_errors": 0,
439
+ "timeouts": len(payload["tests"]),
440
+ }
441
+ except Exception:
442
+ return {
443
+ "passed": False,
444
+ "status": "eval_error",
445
+ "interface_ok": False,
446
+ "passed_tests": 0,
447
+ "total_tests": len(payload["tests"]),
448
+ "wrong_answers": 0,
449
+ "runtime_errors": len(payload["tests"]),
450
+ "timeouts": 0,
451
+ }
452
+
453
+
454
+ def compute_score(
455
+ data_source: str,
456
+ solution_str: str,
457
+ ground_truth: Any,
458
+ extra_info: dict[str, Any] | None = None,
459
+ exec_timeout: float = 6.0,
460
+ per_test_timeout: float = 2.0,
461
+ memory_limit_gib: float = 2.0,
462
+ output_limit_mib: float = 16.0,
463
+ ) -> dict[str, float]:
464
+ """Return a strict binary all-tests-pass execution reward."""
465
+ del data_source
466
+ meta = _json_loads_maybe(ground_truth)
467
+ if not meta and extra_info:
468
+ meta = _json_loads_maybe(extra_info)
469
+
470
+ tests = meta.get("tests") or []
471
+ format_ok = _format_ok(solution_str)
472
+ try:
473
+ code = extract_code(solution_str, meta.get("starter_code") or "")
474
+ ast.parse(code)
475
+ parse_ok = True
476
+ except (SyntaxError, ValueError, MemoryError, RecursionError):
477
+ code = ""
478
+ parse_ok = False
479
+
480
+ if not tests:
481
+ eval_result = {
482
+ "passed": False,
483
+ "status": "no_tests",
484
+ "interface_ok": False,
485
+ "passed_tests": 0,
486
+ "total_tests": 0,
487
+ }
488
+ elif not parse_ok:
489
+ eval_result = {
490
+ "passed": False,
491
+ "status": "syntax_error",
492
+ "interface_ok": False,
493
+ "passed_tests": 0,
494
+ "total_tests": len(tests),
495
+ }
496
+ else:
497
+ try:
498
+ eval_result = _run_eval(
499
+ code,
500
+ meta,
501
+ exec_timeout=exec_timeout,
502
+ per_test_timeout=per_test_timeout,
503
+ memory_limit_gib=memory_limit_gib,
504
+ output_limit_mib=output_limit_mib,
505
+ )
506
+ except (Exception, MemoryError) as exc:
507
+ eval_result = {
508
+ "passed": False,
509
+ "status": "eval_error",
510
+ "interface_ok": False,
511
+ "passed_tests": 0,
512
+ "total_tests": len(tests),
513
+ "error": str(exc)[:300],
514
+ }
515
+
516
+ total_tests = int(eval_result.get("total_tests") or len(tests) or 0)
517
+ passed_tests = int(eval_result.get("passed_tests") or 0)
518
+ pass_frac = passed_tests / max(total_tests, 1)
519
+ interface_ok = bool(eval_result.get("interface_ok"))
520
+ passed = bool(eval_result.get("passed"))
521
+ status = str(eval_result.get("status") or "eval_error")
522
+
523
+ # pass_frac is retained for diagnostics only and never shapes the reward.
524
+ score = 1.0 if total_tests > 0 and passed else 0.0
525
+
526
+ return {
527
+ "score": score,
528
+ "acc": 1.0 if passed else 0.0,
529
+ "format_ok": float(format_ok),
530
+ "parse_ok": float(parse_ok),
531
+ "interface_ok": float(interface_ok),
532
+ "pass_frac": float(pass_frac),
533
+ "passed": 1.0 if passed else 0.0,
534
+ "passed_tests": float(passed_tests),
535
+ "total_tests": float(total_tests),
536
+ "wrong_answers": float(eval_result.get("wrong_answers") or 0),
537
+ "runtime_errors": float(eval_result.get("runtime_errors") or 0),
538
+ "timeouts": float(eval_result.get("timeouts") or 0),
539
+ "status_code": float(STATUS_CODE.get(status, STATUS_CODE["eval_error"])),
540
+ }
verification/taco_leetcode_reward.py ADDED
@@ -0,0 +1,541 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Rule-based code reward for Stage 3 verl/DAPO smoke tests."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import ast
7
+ import json
8
+ import os
9
+ import re
10
+ import resource
11
+ import signal
12
+ import subprocess
13
+ import sys
14
+ import tempfile
15
+ from typing import Any
16
+
17
+
18
+ FENCE_RE = re.compile(r"```(?:python|py)?\s*(.*?)```", re.DOTALL | re.IGNORECASE)
19
+ MAX_PARSE_CODE_CHARS = 65_536
20
+ MAX_PARSE_TRIM_ATTEMPTS = 64
21
+
22
+ STATUS_CODE = {
23
+ "passed": 0,
24
+ "syntax_error": 1,
25
+ "missing_entry_point": 2,
26
+ "entry_point_not_callable": 3,
27
+ "wrong_answer": 4,
28
+ "runtime_error": 5,
29
+ "timeout": 6,
30
+ "harness_error": 7,
31
+ "no_tests": 8,
32
+ "eval_error": 9,
33
+ }
34
+
35
+ EVAL_HARNESS = r'''
36
+ import ast
37
+ import io
38
+ import json
39
+ import math
40
+ import signal
41
+ import sys
42
+ import traceback
43
+ from bisect import *
44
+ from collections import *
45
+ from functools import *
46
+ from heapq import *
47
+ from itertools import *
48
+ from math import *
49
+ from operator import *
50
+ from string import *
51
+ from typing import *
52
+
53
+ payload = json.loads(sys.stdin.read())
54
+ code = payload["code"]
55
+ mode = payload["mode"]
56
+ entry_point = payload.get("entry_point")
57
+ tests = payload.get("tests") or []
58
+ per_test_timeout = float(payload.get("per_test_timeout", 2.0))
59
+
60
+ class FakeStdin:
61
+ def __init__(self, text):
62
+ self._text = io.StringIO(str(text))
63
+ self.buffer = io.BytesIO(str(text).encode())
64
+ def read(self, *args):
65
+ return self._text.read(*args)
66
+ def readline(self, *args):
67
+ return self._text.readline(*args)
68
+ def readlines(self, *args):
69
+ return self._text.readlines(*args)
70
+ def __iter__(self):
71
+ return iter(self._text)
72
+
73
+ def norm_text(value):
74
+ text = "" if value is None else str(value)
75
+ return "\n".join(line.rstrip() for line in text.strip().splitlines()).strip()
76
+
77
+ def stdout_equal(got, expected):
78
+ a, b = norm_text(got), norm_text(expected)
79
+ return a == b or a.split() == b.split()
80
+
81
+ def value_equal(a, b):
82
+ if isinstance(a, bool) or isinstance(b, bool):
83
+ return a == b
84
+ if isinstance(a, (int, float)) and isinstance(b, (int, float)):
85
+ return math.isclose(float(a), float(b), rel_tol=1e-6, abs_tol=1e-6)
86
+ if isinstance(a, (list, tuple)) and isinstance(b, (list, tuple)):
87
+ return len(a) == len(b) and all(value_equal(x, y) for x, y in zip(a, b))
88
+ if isinstance(a, dict) and isinstance(b, dict):
89
+ return set(a.keys()) == set(b.keys()) and all(value_equal(a[k], b[k]) for k in a)
90
+ return str(a) == str(b)
91
+
92
+ def result(**kwargs):
93
+ print(json.dumps(kwargs, ensure_ascii=False))
94
+
95
+ def timeout_handler(signum, frame):
96
+ raise TimeoutError("per-test timeout")
97
+
98
+ try:
99
+ ast.parse(code)
100
+ except (SyntaxError, ValueError, MemoryError, RecursionError) as exc:
101
+ result(
102
+ passed=False,
103
+ status="syntax_error",
104
+ interface_ok=False,
105
+ passed_tests=0,
106
+ total_tests=len(tests),
107
+ wrong_answers=0,
108
+ runtime_errors=0,
109
+ timeouts=0,
110
+ error=str(exc)[:300],
111
+ )
112
+ raise SystemExit
113
+
114
+ try:
115
+ if not tests:
116
+ result(
117
+ passed=False,
118
+ status="no_tests",
119
+ interface_ok=False,
120
+ passed_tests=0,
121
+ total_tests=0,
122
+ wrong_answers=0,
123
+ runtime_errors=0,
124
+ timeouts=0,
125
+ )
126
+ raise SystemExit
127
+
128
+ if mode == "function":
129
+ ns = {"__name__": "__main__"}
130
+ signal.signal(signal.SIGALRM, timeout_handler)
131
+ try:
132
+ signal.setitimer(signal.ITIMER_REAL, per_test_timeout)
133
+ exec(compile(code, "<solution>", "exec"), ns)
134
+ except TimeoutError as exc:
135
+ result(
136
+ passed=False,
137
+ status="timeout",
138
+ interface_ok=False,
139
+ passed_tests=0,
140
+ total_tests=len(tests),
141
+ wrong_answers=0,
142
+ runtime_errors=0,
143
+ timeouts=len(tests),
144
+ error=str(exc)[:300],
145
+ )
146
+ raise SystemExit
147
+ finally:
148
+ signal.setitimer(signal.ITIMER_REAL, 0)
149
+ try:
150
+ candidate = eval(entry_point, ns)
151
+ except Exception as exc:
152
+ result(
153
+ passed=False,
154
+ status="missing_entry_point",
155
+ interface_ok=False,
156
+ passed_tests=0,
157
+ total_tests=len(tests),
158
+ wrong_answers=0,
159
+ runtime_errors=0,
160
+ timeouts=0,
161
+ error=str(exc)[:300],
162
+ )
163
+ raise SystemExit
164
+ if not callable(candidate):
165
+ result(
166
+ passed=False,
167
+ status="entry_point_not_callable",
168
+ interface_ok=False,
169
+ passed_tests=0,
170
+ total_tests=len(tests),
171
+ wrong_answers=0,
172
+ runtime_errors=0,
173
+ timeouts=0,
174
+ )
175
+ raise SystemExit
176
+
177
+ passed_tests = 0
178
+ wrong_answers = 0
179
+ runtime_errors = 0
180
+ timeouts = 0
181
+ for idx, test in enumerate(tests):
182
+ args = test.get("args") or []
183
+ kwargs = test.get("kwargs") or {}
184
+ expected = test.get("output")
185
+ try:
186
+ signal.setitimer(signal.ITIMER_REAL, per_test_timeout)
187
+ got = candidate(*args, **kwargs)
188
+ if value_equal(got, expected):
189
+ passed_tests += 1
190
+ else:
191
+ wrong_answers += 1
192
+ except TimeoutError:
193
+ timeouts += 1
194
+ except Exception:
195
+ runtime_errors += 1
196
+ finally:
197
+ signal.setitimer(signal.ITIMER_REAL, 0)
198
+ if timeouts >= 3:
199
+ break
200
+ skipped_after_timeout = len(tests) - (passed_tests + wrong_answers + runtime_errors + timeouts)
201
+ timeouts += max(skipped_after_timeout, 0)
202
+ passed = passed_tests == len(tests)
203
+ status = "passed" if passed else "timeout" if timeouts else "runtime_error" if runtime_errors else "wrong_answer"
204
+ result(
205
+ passed=passed,
206
+ status=status,
207
+ interface_ok=True,
208
+ passed_tests=passed_tests,
209
+ total_tests=len(tests),
210
+ wrong_answers=wrong_answers,
211
+ runtime_errors=runtime_errors,
212
+ timeouts=timeouts,
213
+ )
214
+ else:
215
+ signal.signal(signal.SIGALRM, timeout_handler)
216
+ passed_tests = 0
217
+ wrong_answers = 0
218
+ runtime_errors = 0
219
+ timeouts = 0
220
+ for idx, test in enumerate(tests):
221
+ old_stdin, old_stdout = sys.stdin, sys.stdout
222
+ fake_out = io.StringIO()
223
+ ns = {"__name__": "__main__"}
224
+ case_failed = False
225
+ try:
226
+ sys.stdin = FakeStdin(test.get("input", ""))
227
+ sys.stdout = fake_out
228
+ try:
229
+ signal.setitimer(signal.ITIMER_REAL, per_test_timeout)
230
+ exec(compile(code, "<solution>", "exec"), ns)
231
+ except SystemExit:
232
+ pass
233
+ except TimeoutError:
234
+ timeouts += 1
235
+ case_failed = True
236
+ except Exception:
237
+ runtime_errors += 1
238
+ case_failed = True
239
+ finally:
240
+ signal.setitimer(signal.ITIMER_REAL, 0)
241
+ finally:
242
+ sys.stdin, sys.stdout = old_stdin, old_stdout
243
+ if not case_failed:
244
+ got = fake_out.getvalue()
245
+ expected = test.get("output", "")
246
+ if stdout_equal(got, expected):
247
+ passed_tests += 1
248
+ else:
249
+ wrong_answers += 1
250
+ if timeouts >= 3:
251
+ break
252
+ skipped_after_timeout = len(tests) - (passed_tests + wrong_answers + runtime_errors + timeouts)
253
+ timeouts += max(skipped_after_timeout, 0)
254
+ passed = passed_tests == len(tests)
255
+ status = "passed" if passed else "timeout" if timeouts else "runtime_error" if runtime_errors else "wrong_answer"
256
+ result(
257
+ passed=passed,
258
+ status=status,
259
+ interface_ok=True,
260
+ passed_tests=passed_tests,
261
+ total_tests=len(tests),
262
+ wrong_answers=wrong_answers,
263
+ runtime_errors=runtime_errors,
264
+ timeouts=timeouts,
265
+ )
266
+ except TimeoutError as exc:
267
+ result(
268
+ passed=False,
269
+ status="timeout",
270
+ interface_ok=True,
271
+ passed_tests=0,
272
+ total_tests=len(tests),
273
+ wrong_answers=0,
274
+ runtime_errors=0,
275
+ timeouts=len(tests),
276
+ error=str(exc)[:300],
277
+ )
278
+ except Exception as exc:
279
+ result(
280
+ passed=False,
281
+ status="runtime_error",
282
+ interface_ok=True,
283
+ passed_tests=0,
284
+ total_tests=len(tests),
285
+ wrong_answers=0,
286
+ runtime_errors=len(tests),
287
+ timeouts=0,
288
+ error=str(exc)[:300],
289
+ traceback=traceback.format_exc()[-500:],
290
+ )
291
+ '''
292
+
293
+
294
+ def _json_loads_maybe(value: Any) -> Any:
295
+ if isinstance(value, str):
296
+ try:
297
+ return json.loads(value)
298
+ except Exception:
299
+ return {}
300
+ return value if isinstance(value, dict) else {}
301
+
302
+
303
+ def _trim_parseable_code(code: str) -> str:
304
+ # Generated text can contain NUL bytes, which make ast.parse raise
305
+ # ValueError instead of SyntaxError. They are never valid Python source.
306
+ text = code.replace("\x00", "").strip()[:MAX_PARSE_CODE_CHARS]
307
+ if not text:
308
+ return text
309
+ lines = text.splitlines()
310
+ first_end = max(1, len(lines) - MAX_PARSE_TRIM_ATTEMPTS + 1)
311
+ for end in range(len(lines), first_end - 1, -1):
312
+ candidate = "\n".join(lines[:end]).strip()
313
+ if not candidate:
314
+ continue
315
+ try:
316
+ ast.parse(candidate)
317
+ return candidate
318
+ except (SyntaxError, ValueError, MemoryError, RecursionError):
319
+ continue
320
+ return text
321
+
322
+
323
+ def extract_code(text: str, starter_code: str = "") -> str:
324
+ text = text or ""
325
+ fenced = FENCE_RE.findall(text)
326
+ if fenced:
327
+ code = fenced[0].strip()
328
+ else:
329
+ lines = text.splitlines()
330
+ start = None
331
+ for idx, line in enumerate(lines):
332
+ stripped = line.strip()
333
+ if re.match(r"(from\s+\S+\s+import\s+|import\s+\S+|class\s+\w+|def\s+\w+|if\s+__name__)", stripped):
334
+ start = idx
335
+ break
336
+ code = "\n".join(lines[start:]).strip() if start is not None else text.strip()
337
+
338
+ starter = (starter_code or "").strip()
339
+ if starter and "class Solution" in code and starter not in code:
340
+ code = starter.rstrip() + "\n\n" + code
341
+ return _trim_parseable_code(code)
342
+
343
+
344
+ def _format_ok(solution_str: str) -> bool:
345
+ text = (solution_str or "").strip()
346
+ if not text:
347
+ return False
348
+ if "```" in text:
349
+ return False
350
+ prose_markers = ["Here is", "Explanation", "```python", "The solution"]
351
+ return not any(marker.lower() in text[:160].lower() for marker in prose_markers)
352
+
353
+
354
+ def _set_eval_limits(memory_limit_gib: float, exec_timeout: float, output_limit_mib: float) -> None:
355
+ memory_bytes = max(1, int(memory_limit_gib * 1024**3))
356
+ output_bytes = max(1, int(output_limit_mib * 1024**2))
357
+ cpu_seconds = max(1, int(exec_timeout) + 1)
358
+ resource.setrlimit(resource.RLIMIT_AS, (memory_bytes, memory_bytes))
359
+ resource.setrlimit(resource.RLIMIT_CPU, (cpu_seconds, cpu_seconds))
360
+ resource.setrlimit(resource.RLIMIT_FSIZE, (output_bytes, output_bytes))
361
+ resource.setrlimit(resource.RLIMIT_NOFILE, (128, 128))
362
+ resource.setrlimit(resource.RLIMIT_NPROC, (256, 256))
363
+
364
+
365
+ def _kill_process_group(proc: subprocess.Popen[str]) -> None:
366
+ try:
367
+ os.killpg(proc.pid, signal.SIGKILL)
368
+ except ProcessLookupError:
369
+ pass
370
+
371
+
372
+ def _run_eval(
373
+ code: str,
374
+ meta: dict[str, Any],
375
+ exec_timeout: float,
376
+ per_test_timeout: float,
377
+ memory_limit_gib: float,
378
+ output_limit_mib: float,
379
+ ) -> dict[str, Any]:
380
+ payload = {
381
+ "code": code,
382
+ "mode": meta.get("mode"),
383
+ "entry_point": meta.get("entry_point"),
384
+ "tests": meta.get("tests") or [],
385
+ "per_test_timeout": per_test_timeout,
386
+ }
387
+ proc = None
388
+ try:
389
+ with (
390
+ tempfile.TemporaryFile(mode="w+t", encoding="utf-8") as stdout_file,
391
+ tempfile.TemporaryFile(mode="w+t", encoding="utf-8") as stderr_file,
392
+ ):
393
+ proc = subprocess.Popen(
394
+ [sys.executable, "-c", EVAL_HARNESS],
395
+ stdin=subprocess.PIPE,
396
+ stdout=stdout_file,
397
+ stderr=stderr_file,
398
+ text=True,
399
+ start_new_session=True,
400
+ preexec_fn=lambda: _set_eval_limits(memory_limit_gib, exec_timeout, output_limit_mib),
401
+ )
402
+ try:
403
+ proc.communicate(input=json.dumps(payload, ensure_ascii=False), timeout=exec_timeout)
404
+ except subprocess.TimeoutExpired:
405
+ _kill_process_group(proc)
406
+ proc.communicate()
407
+ raise
408
+ _kill_process_group(proc)
409
+ stdout_file.seek(0)
410
+ stdout = stdout_file.read()
411
+
412
+ parsed = None
413
+ for line in reversed(stdout.strip().splitlines()):
414
+ candidate = _json_loads_maybe(line)
415
+ if isinstance(candidate, dict) and "passed" in candidate and "total_tests" in candidate:
416
+ parsed = candidate
417
+ break
418
+ if parsed is None:
419
+ return {
420
+ "passed": False,
421
+ "status": "harness_error",
422
+ "interface_ok": False,
423
+ "passed_tests": 0,
424
+ "total_tests": len(payload["tests"]),
425
+ "wrong_answers": 0,
426
+ "runtime_errors": len(payload["tests"]),
427
+ "timeouts": 0,
428
+ }
429
+ return parsed
430
+ except subprocess.TimeoutExpired:
431
+ return {
432
+ "passed": False,
433
+ "status": "timeout",
434
+ "interface_ok": True,
435
+ "passed_tests": 0,
436
+ "total_tests": len(payload["tests"]),
437
+ "wrong_answers": 0,
438
+ "runtime_errors": 0,
439
+ "timeouts": len(payload["tests"]),
440
+ }
441
+ except Exception:
442
+ return {
443
+ "passed": False,
444
+ "status": "eval_error",
445
+ "interface_ok": False,
446
+ "passed_tests": 0,
447
+ "total_tests": len(payload["tests"]),
448
+ "wrong_answers": 0,
449
+ "runtime_errors": len(payload["tests"]),
450
+ "timeouts": 0,
451
+ }
452
+
453
+
454
+ def compute_score(
455
+ data_source: str,
456
+ solution_str: str,
457
+ ground_truth: Any,
458
+ extra_info: dict[str, Any] | None = None,
459
+ exec_timeout: float = 6.0,
460
+ per_test_timeout: float = 2.0,
461
+ memory_limit_gib: float = 2.0,
462
+ output_limit_mib: float = 16.0,
463
+ ) -> dict[str, float]:
464
+ """Return full-pass bonus or capped partial-credit execution reward."""
465
+ del data_source
466
+ meta = _json_loads_maybe(ground_truth)
467
+ if not meta and extra_info:
468
+ meta = _json_loads_maybe(extra_info)
469
+
470
+ tests = meta.get("tests") or []
471
+ format_ok = _format_ok(solution_str)
472
+ try:
473
+ code = extract_code(solution_str, meta.get("starter_code") or "")
474
+ ast.parse(code)
475
+ parse_ok = True
476
+ except (SyntaxError, ValueError, MemoryError, RecursionError):
477
+ code = ""
478
+ parse_ok = False
479
+
480
+ if not tests:
481
+ eval_result = {
482
+ "passed": False,
483
+ "status": "no_tests",
484
+ "interface_ok": False,
485
+ "passed_tests": 0,
486
+ "total_tests": 0,
487
+ }
488
+ elif not parse_ok:
489
+ eval_result = {
490
+ "passed": False,
491
+ "status": "syntax_error",
492
+ "interface_ok": False,
493
+ "passed_tests": 0,
494
+ "total_tests": len(tests),
495
+ }
496
+ else:
497
+ try:
498
+ eval_result = _run_eval(
499
+ code,
500
+ meta,
501
+ exec_timeout=exec_timeout,
502
+ per_test_timeout=per_test_timeout,
503
+ memory_limit_gib=memory_limit_gib,
504
+ output_limit_mib=output_limit_mib,
505
+ )
506
+ except (Exception, MemoryError) as exc:
507
+ eval_result = {
508
+ "passed": False,
509
+ "status": "eval_error",
510
+ "interface_ok": False,
511
+ "passed_tests": 0,
512
+ "total_tests": len(tests),
513
+ "error": str(exc)[:300],
514
+ }
515
+
516
+ total_tests = int(eval_result.get("total_tests") or len(tests) or 0)
517
+ passed_tests = int(eval_result.get("passed_tests") or 0)
518
+ pass_frac = passed_tests / max(total_tests, 1)
519
+ interface_ok = bool(eval_result.get("interface_ok"))
520
+ passed = bool(eval_result.get("passed"))
521
+ status = str(eval_result.get("status") or "eval_error")
522
+
523
+ # A fully correct solution gets 1.0. Any imperfect solution is capped at
524
+ # 0.8 and scaled by its test pass fraction. For example, 70/80 -> 0.7.
525
+ score = 1.0 if total_tests > 0 and passed else 0.8 * pass_frac
526
+
527
+ return {
528
+ "score": score,
529
+ "acc": 1.0 if passed else 0.0,
530
+ "format_ok": float(format_ok),
531
+ "parse_ok": float(parse_ok),
532
+ "interface_ok": float(interface_ok),
533
+ "pass_frac": float(pass_frac),
534
+ "passed": 1.0 if passed else 0.0,
535
+ "passed_tests": float(passed_tests),
536
+ "total_tests": float(total_tests),
537
+ "wrong_answers": float(eval_result.get("wrong_answers") or 0),
538
+ "runtime_errors": float(eval_result.get("runtime_errors") or 0),
539
+ "timeouts": float(eval_result.get("timeouts") or 0),
540
+ "status_code": float(STATUS_CODE.get(status, STATUS_CODE["eval_error"])),
541
+ }