Spaces:
Running
Running
Publish whole-group split planner with audit examples
Browse files- CONTRACT.md +19 -0
- LICENSE +202 -0
- MANIFEST.json +36 -0
- NOTICE +7 -0
- README.md +142 -6
- SAMPLE-SNAPSHOT.json +5 -0
- SOURCE.json +11 -0
- app.mjs +188 -0
- cli/LICENSE +202 -0
- cli/MANIFEST.json +14 -0
- cli/NOTICE +3 -0
- cli/README.md +72 -0
- cli/example.jsonl +6 -0
- cli/flags.csv +7 -0
- cli/report.json +80 -0
- cli/split_audit.py +112 -0
- cli/test_splits.py +56 -0
- index.html +211 -17
- make_sample.py +15 -0
- oracle_driver.mjs +6 -0
- planner.mjs +339 -0
- reference-results.json +111 -0
- run_plan.mjs +59 -0
- sample-assigned.jsonl +36 -0
- sample-plan.json +698 -0
- sample.jsonl +36 -0
- style.css +250 -24
- test_planner.mjs +156 -0
- verify_reference.py +56 -0
- verify_unicode.py +10 -0
CONTRACT.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Frozen Split Boundary planner0.2 contract
|
| 2 |
+
|
| 3 |
+
2026-11-04 before implementation. ExtendacceptedSplitBoundaryAuditwithtrueStaticbrowsergroup-splitplannerandcompatibleauditJSONLexport;sameworkidentitynotnewproject. Preserveoriginal9fileCLIpackageunchangedundercli/,independentmanifest/hashprovenance. Nooriginalbranch/candidatechanges.
|
| 4 |
+
|
| 5 |
+
InputLF-delimitedJSONL,blanklinescounted/ignored,1..5000validrecords,2MiBrawUTF8max. Exactfields{id,group,label,text};allUnicode-scalarstrings;id/group/labelnonblank<=128UTF16units,textnonblank<=16384units. Uniqueidsrequired,declaredgroupnonempty/mandatory. Missinggroupnotinferredfromlabel/idortext. NativeJSON.parsecannotdetectduplicateobjectkeys,lastkeywinsdocumented. Nomodels/URLfilefollowing. Validatedinputprivateonlylocal;fulltextoutputexplicitlydisclosed.
|
| 6 |
+
|
| 7 |
+
Threepositiveintegerpercentagestrain/validation/test,sum100;seedunsigned32bitinteger. Default80/10/10,seed17. Eachdeclaredgroupisindivisible. Alsoaddexactrawtext-equalityedgesbetweengroupsandunionconnectedcomponents;entireallocationunitstaystogether. Thisco-locationconstraintpreventsidenticaltextcrosssplit,notclaimsemanticidentity. NoNFC/whitespacemerging. Retainsmixedlabelswithinunit;exacttextassignedmultiplelabelsgetsREVIEWwarning,notrelabelled. Atleast3allocationunitsrequiredfor3nonemptyoutputs;otherwiseblockwithoutpartialassignment. Noautomaticrowsdropping/repairexistingdataset.
|
| 8 |
+
|
| 9 |
+
UnitrepresentativeUnicodecodepoint-minimumdeclaredgroupid;unitsorderdescrowcount,thenascFNV1a32UTF8(seeddecimal+NUL+unitkey),thenunitkeycodepointorder. Equalprioritiesnotinputorder. Labelsummationcodepointorder. Allgroup/labelmapsMap/Set,id__proto__safe. Greedyonepass(nohiddenoptimizationrestarts):incrementallyassignunittochoiceminimizingglobalobjectiveincrease;exactscoretiesfixedtrain,validation,test. Remainingunitcount==empty_split_count=>restrictchoicestoemptyones,ensuringnonempty. Labelsarenotrequiredineachsplit,zerosandratioroundingexplicitlyreported.
|
| 10 |
+
|
| 11 |
+
ObjectiveE=sum_s(n_s-N*r_s)^2/[N*max(1,N*r_s)] + (1/L)*sum_l sum_s(n_ls-N_l*r_s)^2/[N_l*max(1,N_l*r_s)],whereNrecords,Ldistinctlabels,rpercent/100. Fixedtargetdenominators,nolearnedweights. Deltaevaluationonlychangedcells,fulllosscalculatedindependentlyforthefinalreport;fixedfinitefloat,same-runtimedeterministic(nooptimalityguarantee). Fullyroundedrowcountsneverusedforlabeltargets. Preserveallrowsandinputrecordorderinexport,assignmentinvarianttoinputpermutation. Reportactualandtargetrowcounts,percentagepointdeviation,perclasscounts/targets,groups/mergedunits,allid/group/label/unit/splitassignments,objectiveandconfiguration.
|
| 12 |
+
|
| 13 |
+
Postplanauditduplicateids/groupcrossing/exacttextcrossingmust0;normalizedNFC+whitespacecrosssplitwithdistinctexacttextsREVIEW-only,notreassign/claimsemanticduplicates. MatchnormalizationmembershipwithoriginalPythonauditthroughindependentactualJSONLexportread. Additionalexacttextlabelconflictwarningdistinctfromsplitfailure. CLEARmeansboundedchecksnotgeneralcontaminationproof. Rowsnotdroppedtoimproveratios.
|
| 14 |
+
|
| 15 |
+
Browser:labelledJSONLtextarea,3ratioinputandseed,Planbutton,plainerrors/targetsvsactual/allclasscounts/linkedgroupunitdisplayandnormalizationwarnings. Exportplanreport(nofulltexts)andassignedJSONL(fullsources,originalCLIprojectionexact{id,split,group,text};labelssavedinplanreport). Input/configeditclearsoldresults/Bloblinks,revokereplacedURLs;asyncSHA256oftheexactrawinputguardedbyrevisionticket. Build/PlanhasnonetworkinitialfixedsampleGETonly,noqueryURL/storage/CDN/telemetry. AllDOMtextContentsafe. Desktopand390pxactualUI+nativeBlobdownloadandPythonCLIrealreadrequired.
|
| 16 |
+
|
| 17 |
+
Tests:handunit/scorefixture,independentPythonobjective/deltaforadditionalcases,numeroussmallgroupassignmentsverifyconservation/constraints/permutation/seed/equalitybridges/rareclasses/nonempty,allscalarJSONLcaps/errors. ComparecompletedassignedJSONLwithread-onlyoriginalCLI(noinfrozencandidatepyc). Observedgreedyvsbruteforceoptimumcounterexamplemustretainifdiscovered,notchangemethodafterseeingit. Ownsynthetic36record/12declaredgroupssamplefreezebeforeimpl,labelsinthreeclasses,noexternaldatasetclaims. Fullsampleassignmentaudit/warningcountsretained,notperformancebenchmark. IndependenttotalreviewprecisioncandidatebeforelaterdailyHFrelease,todaynopublish.
|
| 18 |
+
|
| 19 |
+
Pre-freeze usability addition: run_plan.mjs is a standard-library Node CLI adapter to the exact same planning function, with fatal UTF8 decoding (BOM preserved), explicit file input, fresh output directory and report/assignedJSONL writes. It does not change allocation or schema, and its outputs are compared with actual browser downloads. Exit0completeincludingREVIEW;exit2failure,filesystempartialoutputnotvalid. BrowsersecurecontextfailurehasreadableHTTPS/localhostmessage. Initialassetloadpreserveseditsmadebeforefetchcompletes.
|
LICENSE
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.
|
MANIFEST.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema_version": 1,
|
| 3 |
+
"work_identity": "work:split-boundary-audit:v1",
|
| 4 |
+
"extension_version": "0.2.0",
|
| 5 |
+
"sha256": {
|
| 6 |
+
"CONTRACT.md": "eef855268460caf8c9ed60faaa47f6200ca35b6cc7d44a9b65dfccca0c8428ab",
|
| 7 |
+
"LICENSE": "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30",
|
| 8 |
+
"NOTICE": "7d725231f5125743fed878150500efb40b6beaa11312bed529a609a041a20757",
|
| 9 |
+
"README.md": "dc30ff008a96c8548ad3fb9d227a3dc93fe073e01ab79c5432b7729ea07908ad",
|
| 10 |
+
"SAMPLE-SNAPSHOT.json": "82b5f2cec89ec289e18603a008936b51d5f5c27d5c9ce0b2f7cd7ceb4dd400bc",
|
| 11 |
+
"SOURCE.json": "3c86d3d21dcf6f0ff91158eb5cce5e3da2c158daa42943d98735adf6530ff698",
|
| 12 |
+
"app.mjs": "78bdd621107bcd16b2daf3051fa72d87ef9764f90b1b57eb7efe612bc5122aa8",
|
| 13 |
+
"cli/LICENSE": "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30",
|
| 14 |
+
"cli/MANIFEST.json": "abfa0f42cf8d5607af4faecb4d7f14b856763c5780dc35d31a1d896e1be71a53",
|
| 15 |
+
"cli/NOTICE": "b3374d4fd0d883df260eb9266849735246e182689257ae84069f8f2e78f2edc0",
|
| 16 |
+
"cli/README.md": "b7ec87d92c22bf65fe3232dbeb71d998d5d0166007da26ecd90b2c169eeebde4",
|
| 17 |
+
"cli/example.jsonl": "e3fd9e2cd014ec159f0a9a9f242dd65493d3c3807cf62f9c127de711867dab72",
|
| 18 |
+
"cli/flags.csv": "8fb359ba1b17a4f1bcb43d5e85bffcfec37436ff975c2ac3fffa2253cc95e180",
|
| 19 |
+
"cli/report.json": "8cea2f898ace810e43ec4c8d39d23ba06372cda7fcf1d6f7005f7fd9f9fa8baa",
|
| 20 |
+
"cli/split_audit.py": "9ae25f18112a52f2091d85c5e1cc2683275156f4b398d94579fe70d3fbab8612",
|
| 21 |
+
"cli/test_splits.py": "306b7967257940b282c1882b60e3b0a70a62b5e46b4430936f7ca8ecce56a3ee",
|
| 22 |
+
"index.html": "7165e642072e5c082b6635003e8d87597ce94b971a99d1785e22302db2dc04e1",
|
| 23 |
+
"make_sample.py": "dd79718cf787274bf312a98f16f2bdc306679c725ba49fed4cd1516342b19d98",
|
| 24 |
+
"oracle_driver.mjs": "2af88295fb99f1de98f3139e097f96787cb3dcbc35bfa3ef4265ea93c7d8469a",
|
| 25 |
+
"planner.mjs": "4268ca84d6b6f29fd18c05dabe026d6ce3d9063ef0f2ee978dfac447b54149cd",
|
| 26 |
+
"reference-results.json": "629bbded48b6924745fd56ada8e9ccc931c5bb518084b75ea0ad4f79d93adabc",
|
| 27 |
+
"run_plan.mjs": "ab4d7219b090b90b6fac93e203ee176a05bfeecf3c8e5181983769a954989a2e",
|
| 28 |
+
"sample-assigned.jsonl": "394cc2faf301e9924d372df15e35d347862cf73f3f28c163b467908a49f3b6fa",
|
| 29 |
+
"sample-plan.json": "57724d670030a47d56c61c72935fe845edbc81169c5877a37c7355ef65d20a0f",
|
| 30 |
+
"sample.jsonl": "2816411655d32bd22271476132380572cd9f60f6c2550910fd09a9f412631c62",
|
| 31 |
+
"style.css": "6f98af7b15dd4be7d629b1e7ecabc0977e82f1c9f0664a8b7a6914ef20fa1d9e",
|
| 32 |
+
"test_planner.mjs": "5a02d0420c2c430056b9895751520b1922d3343a50faea2199c9fe790de753f1",
|
| 33 |
+
"verify_reference.py": "9df8392ade2264d553a66035c41784c5619ddf5d2586ef6f7354628226c2a9d7",
|
| 34 |
+
"verify_unicode.py": "e9790dd70ab839299ddd3e3da2b01793d814cf2eac87979f61d5150343e77cf2"
|
| 35 |
+
}
|
| 36 |
+
}
|
NOTICE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Split Boundary Audit · Group Planner0.2
|
| 2 |
+
Copyright2026 Renchao Wu, Apache-2.0.
|
| 3 |
+
|
| 4 |
+
Original same-work planning implementation and authored synthetic fixtures.
|
| 5 |
+
The unchanged accepted0.1 CLI package is preserved under cli/ with its manifest.
|
| 6 |
+
No third-party code, external corpus, model weights or private data bundled.
|
| 7 |
+
SOURCE.json records the original CLI manifest and the synthetic sample hash.
|
README.md
CHANGED
|
@@ -1,12 +1,148 @@
|
|
| 1 |
---
|
| 2 |
-
title: Split Boundary Audit
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
-
|
| 8 |
license: apache-2.0
|
| 9 |
short_description: Whole-group split planning with visible ratio deviations
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Split Boundary Audit · Group Planner
|
| 3 |
+
emoji: 🧩
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: gray
|
| 6 |
sdk: static
|
| 7 |
+
app_file: index.html
|
| 8 |
license: apache-2.0
|
| 9 |
short_description: Whole-group split planning with visible ratio deviations
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Split Boundary Audit · Group Planner
|
| 13 |
+
|
| 14 |
+
## Why keep related examples together?
|
| 15 |
+
|
| 16 |
+
Imagine preparing an exam from a collection of documents. Several questions were written from each document. If questions from the same document appear both in practice and in the final exam, a good score may partly reflect familiarity with that source. This is an illustrative reason to examine a split, not a measured result from a deployed model.
|
| 17 |
+
|
| 18 |
+
Machine-learning experiments often use three collections: training data for fitting, validation data for choosing settings, and test data for final evaluation. Splitting individual rows at random can separate records that the experimenter intended to keep together. I built this planner to make that boundary visible before training starts. You supply each record's group, such as its source document or template family; the tool keeps that group whole.
|
| 19 |
+
|
| 20 |
+
There is another complication: different groups can contain exactly the same source text. The planner connects those groups and assigns the entire connected component together. It keeps every record and leaves conflicting labels visible. Similar-looking text after normalization is only a review warning; the tool does not decide that it means the same thing.
|
| 21 |
+
|
| 22 |
+
The frozen synthetic example shows the trade-off. A requested 80/10/10 split of 36 records suggests 28.8, 3.6 and 3.6 rows. Whole groups cannot be divided into fractional rows: the actual plan is 30/3/3. The report shows that difference instead of dropping records to make the percentages look better. It also keeps one normalized-text warning and one conflicting-label set, so the result needs review.
|
| 23 |
+
|
| 24 |
+
The planning rule makes one greedy pass. I retained a small counterexample where an exhaustive search finds a better balance. This tool therefore offers an inspectable proposal, with downloadable assignments and an audit trail, rather than an optimality certificate. It cannot discover trustworthy groups for you or prove that a test set is independent. The exact method, counterexample and original auditor are below.
|
| 25 |
+
|
| 26 |
+
Create train, validation and test assignments while keeping declared groups together. Exact duplicate source texts also connect groups into indivisible allocation units. Inspect achieved row and per-label ratios, then export all assigned records for the original Python split auditor.
|
| 27 |
+
|
| 28 |
+
This is version 0.2 of the same Split Boundary Audit work. The unchanged, independently accepted 0.1 CLI package is included in `cli/`, with its original manifest. The browser adds planning and a local command-line adapter; it does not claim that a particular split is statistically independent or free of all contamination.
|
| 29 |
+
|
| 30 |
+
## Use the browser
|
| 31 |
+
|
| 32 |
+
```sh
|
| 33 |
+
python3 -m http.server 8000 --bind 127.0.0.1
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
Open the localhost address. Enter grouped JSONL, choose three positive integer percentages totaling 100, and plan. A modern browser with ES modules, Unicode normalization and Web Crypto is required; use HTTPS or localhost for the input digest. This is a static app with no build step, package installation or external scripts. The local preparation checks described here were collected on 2026-11-04 and do not include HF cloud execution.
|
| 37 |
+
|
| 38 |
+
```jsonl
|
| 39 |
+
{"id":"q-1","group":"document-a","label":"question","text":"How does this work?"}
|
| 40 |
+
{"id":"q-2","group":"document-a","label":"question","text":"A sibling from document a."}
|
| 41 |
+
{"id":"b-1","group":"document-b","label":"bug","text":"A different source."}
|
| 42 |
+
{"id":"e-1","group":"document-c","label":"example","text":"An example source."}
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
Every record needs exactly `id`, `group`, `label` and `text`. Ids must be unique. A group is the caller's indivisible evaluation unit, such as a document or template family. Labels and population cohorts are not automatically suitable groups. The planner cannot discover trustworthy groups from ungrouped data.
|
| 46 |
+
|
| 47 |
+
Input limits are 1–5,000 valid records, 2 MiB UTF-8 input, 128 UTF-16 units for each id/group/label, and 16,384 units for each text. Fields must be nonblank Unicode scalar strings. Blank lines are counted and ignored; literal U+2028 within JSON strings is preserved because records split on LF only. Native JSON.parse keeps the last duplicate object key; this input parser does not detect duplicate keys within a line. Percentages and seed must be integers; the seed range is 0–4,294,967,295.
|
| 48 |
+
|
| 49 |
+
Changing data, percentages or seed clears previous results and download links. The input digest is SHA-256 of the exact UTF-8 editor text, including whitespace and blank lines; a revision check prevents an old async digest from installing a plan after an edit.
|
| 50 |
+
|
| 51 |
+
## What stays together
|
| 52 |
+
|
| 53 |
+
The planner starts with declared groups. When two records have exactly equal raw source text, it connects their groups. All groups in a connected component are allocated together. For example, group A shares one exact text with B, and B shares another with C: A, B and C form one allocation unit.
|
| 54 |
+
|
| 55 |
+
This is an explicit co-location constraint on identical strings. No rows are deleted, labels are not changed, and normalization is not used to create those edges. An exact text with different labels remains in the data and produces a review warning.
|
| 56 |
+
|
| 57 |
+
NFC followed by Unicode-whitespace collapse is used only for review candidates across completed splits. Different raw texts with the same normalized form are flagged for inspection. BOM U+FEFF is retained; the whitespace set matches Python's original auditor, including U+0085 and U+001C–U+001F. Such candidates are not automatically merged or declared semantically identical.
|
| 58 |
+
|
| 59 |
+
At least three allocation units are needed for three nonempty splits. If exact-text links leave fewer than three units, planning fails without producing a partial split. Every label need not appear in every split; zero cells remain visible.
|
| 60 |
+
|
| 61 |
+
## Fixed planning method
|
| 62 |
+
|
| 63 |
+
The method uses one deterministic greedy pass, without optimization restarts. Units are ordered by descending row count, then unsigned FNV-1a of UTF-8 `(decimal seed + NUL + unit key)`, then the unit key's Unicode code points. The unit key is its smallest declared group id in code-point order. Label sums use code-point order too.
|
| 64 |
+
|
| 65 |
+
For each unit, the planner chooses the eligible split with the smallest increase in the following fixed balance objective:
|
| 66 |
+
|
| 67 |
+
```text
|
| 68 |
+
E = sum_s (n_s - N*r_s)^2 / (N * max(1, N*r_s))
|
| 69 |
+
+ (1/L) * sum_label sum_s
|
| 70 |
+
(n_label,s - N_label*r_s)^2
|
| 71 |
+
/ (N_label * max(1, N_label*r_s))
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
N is the total record count, L the distinct-label count, and r_s the requested percentage divided by 100. The first term balances total rows; the second balances labels with equal per-label weight. Targets stay fractional. Delta scoring changes only affected cells; the final objective is recalculated from the completed counts.
|
| 75 |
+
|
| 76 |
+
If the remaining units equal the number of empty splits, choices are restricted to those empty splits. This guarantees three nonempty splits when at least three units exist, and can worsen balance. Exact computed-score ties use train, validation, test order. Floating-point algebra or normalization-version changes can affect reproducibility; no bitwise result guarantee is made across implementations. Within this implementation, input row permutation preserves assignments, while exports keep the original input order.
|
| 77 |
+
|
| 78 |
+
The result is not guaranteed to minimize E. `reference-results.json` retains a concrete 13-record, four-group counterexample with targets 34/33/33 and seed 71: greedy E=0.1930676083, exhaustive optimum E=0.1775424801. Both preserve group integrity and nonempty splits. No record or difficult example was removed to improve balance.
|
| 79 |
+
|
| 80 |
+
## Sample result
|
| 81 |
+
|
| 82 |
+
The frozen example has 36 authored synthetic records, 12 declared template-family groups and three labels. Two disjoint exact-text links reduce them to ten allocation units. With targets 80/10/10 and seed 17:
|
| 83 |
+
|
| 84 |
+
| Split | Fractional target rows | Actual rows | Percentage-point deviation |
|
| 85 |
+
| --- | --- | --- | --- |
|
| 86 |
+
| train | 28.8 | 30 | +3.33 |
|
| 87 |
+
| validation | 3.6 | 3 | -1.67 |
|
| 88 |
+
| test | 3.6 | 3 | -1.67 |
|
| 89 |
+
|
| 90 |
+
All 36 records are retained. There are zero declared-group or exact-text crossings, one normalized cross-split candidate set, and one conflicting-label exact-text set. The plan is REVIEW. The unchanged Python auditor also returns REVIEW for its normalized candidate; it does not inspect labels, so the planner's additional label conflict is a separate check.
|
| 91 |
+
|
| 92 |
+
`SAMPLE-SNAPSHOT.json` records the sample hash before implementation. This small constructed example and the arithmetic checks are development evidence, not a general split-quality benchmark. The original 0.1 CLI fixture is a separate synthetic audit example, not extra independent data for this planning result.
|
| 93 |
+
|
| 94 |
+
## Exports and local CLI
|
| 95 |
+
|
| 96 |
+
The plan report includes configuration, objective, actual and target counts, allocation units, every id/group/label/split assignment, review warnings and the greedy trace. It does not contain source texts. Assigned JSONL includes every source text, with exactly the original auditor's fields: `id`, `split`, `group`, `text`. Labels remain in the report, joined by unique id. Review either file before sharing; ids and labels can also be sensitive.
|
| 97 |
+
|
| 98 |
+
Use the same planner headlessly with Node.js standard libraries:
|
| 99 |
+
|
| 100 |
+
```sh
|
| 101 |
+
node run_plan.mjs sample.jsonl --output fresh-plan --percentages 80,10,10 --seed 17
|
| 102 |
+
python3 cli/split_audit.py fresh-plan/assigned-records.jsonl --output fresh-audit
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
The adapter reads only the specified UTF-8 file and writes a new output directory. It rejects invalid UTF-8 and refuses existing output directories. Exit 0 means a complete plan, including REVIEW; exit 2 means input/output failure. If a filesystem write fails, any partial output is not a completed plan. No filenames or URLs inside records are followed.
|
| 106 |
+
|
| 107 |
+
In the browser, inputs and settings stay local. Initial loading requests fixed assets and `sample.jsonl`. Planning, edits and Blob downloads make no network calls. There is no storage, telemetry, model invocation or training. Hosting still receives ordinary asset requests. Downloading assigned JSONL is the explicit action that saves its full source texts.
|
| 108 |
+
|
| 109 |
+
CLEAR only means the shown bounded checks found no flag. It cannot certify correct group design, semantic disjointness, representative class coverage, independence or absence of other data contamination. Retaining whole groups also does not guarantee the requested ratios.
|
| 110 |
+
|
| 111 |
+
## Reproduce checks
|
| 112 |
+
|
| 113 |
+
Node.js and Python standard libraries only:
|
| 114 |
+
|
| 115 |
+
```sh
|
| 116 |
+
node test_planner.mjs
|
| 117 |
+
python3 verify_reference.py
|
| 118 |
+
python3 verify_unicode.py
|
| 119 |
+
cd cli
|
| 120 |
+
python3 -m unittest test_splits -v
|
| 121 |
+
cd ..
|
| 122 |
+
```
|
| 123 |
+
|
| 124 |
+
The unchanged CLI tests expect the `cli/` working directory. Run checks in a working copy: the Node tests and arithmetic verifier regenerate `sample-plan.json`, `sample-assigned.jsonl` and `reference-results.json`. Keep a frozen release candidate unchanged for review.
|
| 125 |
+
|
| 126 |
+
Eight Node groups check linked components, conservation, nonempty outputs, schema/Unicode/byte/row limits, prototype-shaped ids, fixed-score arithmetic and input-order behavior. An additional 100 permutations of the sample preserved all assignments and the objective. The independent Python oracle checked 100 small 3–6-group cases, 1,244 considered deltas, ordering, nonempty constraints and exhaustive best objectives. It found 30 nonoptimal greedy cases in that constructed set; this is not a population failure-rate estimate. The full first counterexample is retained. A separate normalization check compares all 29 Python whitespace code points and seven other boundary vectors.
|
| 127 |
+
|
| 128 |
+
Actual local browser tests planned and downloaded the sample and custom Unicode data, then passed the real JSONL bytes through the unchanged Python CLI. The per-record source strings, normalized-candidate member sets and sample core result matched. Config and data edits cleared exports; invalid ratios and schema left no partial downloads. Script-shaped text was displayed literally. A 5,000-record/5,000-label UI case retained all rows, rendered 5,000 class rows and allocation units, and produced both download links. Desktop and 390-pixel layouts were inspected with no document overflow. These are local checks, not a hosted HF build, universal security assurance or evidence of another user's adoption.
|
| 129 |
+
|
| 130 |
+
## 中文:先把同一本资料里的题留在一起
|
| 131 |
+
|
| 132 |
+
设想你用一批资料出考题,每份资料各出几道。如果同一份资料的题同时进入练习和考试,考试成绩可能部分反映对来源的熟悉。这个例子用于解释为什么要检查数据划分,不是某个模型已经发生泄漏的实测结论。
|
| 133 |
+
|
| 134 |
+
训练资料用于拟合模型,验证资料用于选择设置,测试资料用于最后评估。这个工具要求你先说明哪些记录属于不可拆的一组,例如同一来源文档或模板族,然后整组分配。它不会从没有分组的信息中猜出可靠的组,也不能把类别相同当作来源相同。
|
| 135 |
+
|
| 136 |
+
如果不同组出现完全相同的原文,工具会把这些组连起来,一起分配。全部记录仍然保留,标签冲突也不会自动修掉。规范化后看起来一样的文字只提醒你复核,不据此认定语义相同。
|
| 137 |
+
|
| 138 |
+
固定示例有36条合成记录。目标80/10/10对应28.8、3.6、3.6条,但整组不能切成小数,最终得到30、3、3条。报告把比例偏差、一个规范化候选和一个标签冲突都展示出来,状态是需要复核。它没有通过丢记录把比例修饰得更漂亮。
|
| 139 |
+
|
| 140 |
+
我还保留了一个小反例:穷举能找到比这套单遍贪心规则更好的平衡方案。因此它交付的是可检查、可导出、能交给原审计程序复核的划分建议,不保证最优、统计独立或排除所有污染。下面保留完整方法与限制。
|
| 141 |
+
|
| 142 |
+
## 中文说明
|
| 143 |
+
|
| 144 |
+
给已经声明好group的资料生成训练、验证、测试划分。整组不可拆,完全相同文本会把组连成更大的分配单位;规范化后相同的不同文本只提醒,不自动合并。原样保留全部记录、混合标签和比例偏差,导出的JSONL能交给原Python审计工具继续检查,标签保存在报告里。
|
| 145 |
+
|
| 146 |
+
默认36条合成样本的目标是80/10/10,实际30/3/3,没有为凑比例丢记录。一个规范化候选和一个相同文字标签冲突都保留,显示REVIEW。该单遍贪心方法有已保存的非最优反例,不能宣传成最优划分、语义无泄漏或统计独立证明。group应由资料来源或模板族等不可拆单位决定,缺失时不能随便用类别或每条记录的id冒充。
|
| 147 |
+
|
| 148 |
+
这是Split Boundary Audit同作品的浏览器规划扩展,不另计新项目。本包记录2026-11-04本地制作与验收准备的证据;公开云端运行另以实际发布回执为准。
|
SAMPLE-SNAPSHOT.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"phase": "before planner implementation",
|
| 3 |
+
"scope": "36 synthetic records, 12 declared template-family groups, three labels; two exact-text edges merge two disjoint group pairs into ten allocation units; one exact-text label conflict; one NFC/whitespace candidate pair whose split outcome is not prespecified",
|
| 4 |
+
"sample_sha256": "2816411655d32bd22271476132380572cd9f60f6c2550910fd09a9f412631c62"
|
| 5 |
+
}
|
SOURCE.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"work_identity": "work:split-boundary-audit:v1",
|
| 3 |
+
"extension_version": "0.2.0",
|
| 4 |
+
"origin": "original same-work browser planning implementation plus unchanged accepted CLI package",
|
| 5 |
+
"original_cli_manifest_sha256": "abfa0f42cf8d5607af4faecb4d7f14b856763c5780dc35d31a1d896e1be71a53",
|
| 6 |
+
"original_cli_version": "0.1.0",
|
| 7 |
+
"sample_origin": "36 authored synthetic planning records; not a real-world dataset",
|
| 8 |
+
"sample_sha256": "2816411655d32bd22271476132380572cd9f60f6c2550910fd09a9f412631c62",
|
| 9 |
+
"status": "local candidate; no publication implied",
|
| 10 |
+
"snapshot_date": "2026-11-04"
|
| 11 |
+
}
|
app.mjs
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { parseJSONL, plan } from "./planner.mjs";
|
| 2 |
+
const $ = (id) => document.getElementById(id),
|
| 3 |
+
node = (tag, text) => {
|
| 4 |
+
const e = document.createElement(tag);
|
| 5 |
+
e.textContent = text;
|
| 6 |
+
return e;
|
| 7 |
+
};
|
| 8 |
+
let revision = 0,
|
| 9 |
+
urls = [];
|
| 10 |
+
function clear(
|
| 11 |
+
message = "Inputs changed. Plan again for the current data and settings.",
|
| 12 |
+
) {
|
| 13 |
+
urls.forEach(URL.revokeObjectURL);
|
| 14 |
+
urls = [];
|
| 15 |
+
$("downloads").replaceChildren();
|
| 16 |
+
$("results").hidden = true;
|
| 17 |
+
$("placeholder").hidden = false;
|
| 18 |
+
$("error").hidden = true;
|
| 19 |
+
$("report").textContent = "";
|
| 20 |
+
$("status").textContent = message;
|
| 21 |
+
}
|
| 22 |
+
for (const id of ["data", "train", "validation", "test", "seed"])
|
| 23 |
+
$(id).addEventListener("input", () => {
|
| 24 |
+
revision++;
|
| 25 |
+
clear();
|
| 26 |
+
});
|
| 27 |
+
function number(id) {
|
| 28 |
+
if (!$(id).value.trim()) throw Error("Fill all percentage and seed fields.");
|
| 29 |
+
return Number($(id).value);
|
| 30 |
+
}
|
| 31 |
+
function download(name, value, label, type) {
|
| 32 |
+
const url = URL.createObjectURL(new Blob([value], { type }));
|
| 33 |
+
urls.push(url);
|
| 34 |
+
const a = node("a", label);
|
| 35 |
+
a.href = url;
|
| 36 |
+
a.download = name;
|
| 37 |
+
$("downloads").append(a);
|
| 38 |
+
}
|
| 39 |
+
function render(report, assigned) {
|
| 40 |
+
$("summary").textContent =
|
| 41 |
+
`${report.total_records} records · ${report.declared_groups} declared groups · ${report.allocation_units} allocation units (${"merged: " + report.merged_units})`;
|
| 42 |
+
$("audit-state").textContent =
|
| 43 |
+
report.status === "REVIEW"
|
| 44 |
+
? `REVIEW · ${report.audit.normalized_candidates.length} normalized candidate sets · ${report.audit.exact_text_label_conflicts.length} exact-text label conflict sets`
|
| 45 |
+
: "CLEAR for the bounded post-plan checks. Inspect achieved ratios before using the split.";
|
| 46 |
+
$("audit-counts").textContent =
|
| 47 |
+
`Post-plan crossings: groups ${report.audit.group_cross_split_sets}, exact text ${report.audit.exact_text_cross_split_sets}. Duplicate ids ${report.audit.duplicate_id_records}.`;
|
| 48 |
+
$("objective").textContent =
|
| 49 |
+
`Fixed balance objective: ${report.objective.toFixed(6)}. A lower score describes this formula only; the greedy result may be suboptimal.`;
|
| 50 |
+
$("split-rows").replaceChildren();
|
| 51 |
+
for (const s of report.splits) {
|
| 52 |
+
const tr = node("tr", "");
|
| 53 |
+
for (const text of [
|
| 54 |
+
s.split,
|
| 55 |
+
s.target_records.toFixed(2),
|
| 56 |
+
String(s.actual_records),
|
| 57 |
+
(s.deviation_percentage_points >= 0 ? "+" : "") +
|
| 58 |
+
s.deviation_percentage_points.toFixed(2) +
|
| 59 |
+
" pp",
|
| 60 |
+
])
|
| 61 |
+
tr.append(node("td", text));
|
| 62 |
+
$("split-rows").append(tr);
|
| 63 |
+
}
|
| 64 |
+
$("label-rows").replaceChildren();
|
| 65 |
+
for (const l of report.labels) {
|
| 66 |
+
const tr = node("tr", "");
|
| 67 |
+
for (const text of [
|
| 68 |
+
l.label,
|
| 69 |
+
String(l.total),
|
| 70 |
+
...l.splits.map(
|
| 71 |
+
(s) => `${s.actual_records} / ${s.target_records.toFixed(2)}`,
|
| 72 |
+
),
|
| 73 |
+
])
|
| 74 |
+
tr.append(node("td", text));
|
| 75 |
+
$("label-rows").append(tr);
|
| 76 |
+
}
|
| 77 |
+
$("unit-rows").replaceChildren();
|
| 78 |
+
for (const u of report.units) {
|
| 79 |
+
const tr = node("tr", "");
|
| 80 |
+
for (const value of [
|
| 81 |
+
u.unit,
|
| 82 |
+
u.declared_groups.join(" · "),
|
| 83 |
+
String(u.records),
|
| 84 |
+
u.split,
|
| 85 |
+
])
|
| 86 |
+
tr.append(node("td", value));
|
| 87 |
+
$("unit-rows").append(tr);
|
| 88 |
+
}
|
| 89 |
+
$("warnings").replaceChildren();
|
| 90 |
+
for (const warning of [
|
| 91 |
+
...report.audit.normalized_candidates,
|
| 92 |
+
...report.audit.exact_text_label_conflicts,
|
| 93 |
+
]) {
|
| 94 |
+
const title =
|
| 95 |
+
warning.kind === "normalized_candidate"
|
| 96 |
+
? "NFC/whitespace candidate across splits"
|
| 97 |
+
: "Identical source text has multiple labels";
|
| 98 |
+
$("warnings").append(
|
| 99 |
+
node("h4", title),
|
| 100 |
+
node(
|
| 101 |
+
"p",
|
| 102 |
+
warning.members
|
| 103 |
+
.map(
|
| 104 |
+
(m) =>
|
| 105 |
+
`${m.id} · ${m.group} · ${m.split}${m.label ? " · " + m.label : ""}`,
|
| 106 |
+
)
|
| 107 |
+
.join("\n"),
|
| 108 |
+
),
|
| 109 |
+
);
|
| 110 |
+
}
|
| 111 |
+
if (!$("warnings").childElementCount)
|
| 112 |
+
$("warnings").append(
|
| 113 |
+
node(
|
| 114 |
+
"p",
|
| 115 |
+
"No warnings under these bounded checks. This is not a semantic duplicate audit.",
|
| 116 |
+
),
|
| 117 |
+
);
|
| 118 |
+
$("report").textContent = JSON.stringify(report, null, 2);
|
| 119 |
+
download(
|
| 120 |
+
"split-plan.json",
|
| 121 |
+
JSON.stringify(report, null, 2) + "\n",
|
| 122 |
+
"Download plan report",
|
| 123 |
+
"application/json;charset=utf-8",
|
| 124 |
+
);
|
| 125 |
+
download(
|
| 126 |
+
"assigned-records.jsonl",
|
| 127 |
+
assigned,
|
| 128 |
+
"Download assigned JSONL (full texts)",
|
| 129 |
+
"application/x-ndjson;charset=utf-8",
|
| 130 |
+
);
|
| 131 |
+
$("placeholder").hidden = true;
|
| 132 |
+
$("results").hidden = false;
|
| 133 |
+
$("status").textContent =
|
| 134 |
+
"Plan ready for the current inputs. No records were dropped.";
|
| 135 |
+
}
|
| 136 |
+
$("plan").addEventListener("click", async () => {
|
| 137 |
+
clear("Planning whole allocation units…");
|
| 138 |
+
const ticket = revision;
|
| 139 |
+
$("plan").disabled = true;
|
| 140 |
+
try {
|
| 141 |
+
if (!crypto.subtle)
|
| 142 |
+
throw Error("Use HTTPS or localhost for the input digest.");
|
| 143 |
+
const raw = $("data").value,
|
| 144 |
+
parsed = parseJSONL(raw),
|
| 145 |
+
planned = plan(
|
| 146 |
+
parsed.rows,
|
| 147 |
+
[number("train"), number("validation"), number("test")],
|
| 148 |
+
number("seed"),
|
| 149 |
+
);
|
| 150 |
+
const digest = Array.from(
|
| 151 |
+
new Uint8Array(
|
| 152 |
+
await crypto.subtle.digest("SHA-256", new TextEncoder().encode(raw)),
|
| 153 |
+
),
|
| 154 |
+
(b) => b.toString(16).padStart(2, "0"),
|
| 155 |
+
).join("");
|
| 156 |
+
if (ticket !== revision) return;
|
| 157 |
+
planned.report.input_sha256 = digest;
|
| 158 |
+
planned.report.input_digest_scope = "exact UTF-8 input JSONL editor text";
|
| 159 |
+
planned.report.blank_lines_ignored = parsed.blank_lines_ignored;
|
| 160 |
+
render(planned.report, planned.assigned_jsonl);
|
| 161 |
+
} catch (e) {
|
| 162 |
+
if (ticket === revision) {
|
| 163 |
+
$("error").textContent = e.message || "Could not plan input.";
|
| 164 |
+
$("error").hidden = false;
|
| 165 |
+
$("error").focus();
|
| 166 |
+
$("status").textContent = "No plan for the current inputs.";
|
| 167 |
+
}
|
| 168 |
+
} finally {
|
| 169 |
+
$("plan").disabled = false;
|
| 170 |
+
}
|
| 171 |
+
});
|
| 172 |
+
try {
|
| 173 |
+
const response = await fetch("sample.jsonl", { cache: "no-store" });
|
| 174 |
+
if (!response.ok) throw Error();
|
| 175 |
+
const text = await response.text();
|
| 176 |
+
if (revision === 0) {
|
| 177 |
+
$("data").value = text;
|
| 178 |
+
$("status").textContent =
|
| 179 |
+
"Synthetic example loaded. Plan it or edit the records.";
|
| 180 |
+
} else
|
| 181 |
+
$("status").textContent =
|
| 182 |
+
"Your edits were preserved. Plan the current records.";
|
| 183 |
+
} catch {
|
| 184 |
+
$("status").textContent =
|
| 185 |
+
"Sample could not load. Paste grouped JSONL and plan it locally.";
|
| 186 |
+
} finally {
|
| 187 |
+
$("plan").disabled = false;
|
| 188 |
+
}
|
cli/LICENSE
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.
|
cli/MANIFEST.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"version": "0.1.0",
|
| 3 |
+
"work_identity": "work:split-boundary-audit:v1",
|
| 4 |
+
"sha256": {
|
| 5 |
+
"LICENSE": "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30",
|
| 6 |
+
"NOTICE": "b3374d4fd0d883df260eb9266849735246e182689257ae84069f8f2e78f2edc0",
|
| 7 |
+
"README.md": "b7ec87d92c22bf65fe3232dbeb71d998d5d0166007da26ecd90b2c169eeebde4",
|
| 8 |
+
"example.jsonl": "e3fd9e2cd014ec159f0a9a9f242dd65493d3c3807cf62f9c127de711867dab72",
|
| 9 |
+
"flags.csv": "8fb359ba1b17a4f1bcb43d5e85bffcfec37436ff975c2ac3fffa2253cc95e180",
|
| 10 |
+
"report.json": "8cea2f898ace810e43ec4c8d39d23ba06372cda7fcf1d6f7005f7fd9f9fa8baa",
|
| 11 |
+
"split_audit.py": "9ae25f18112a52f2091d85c5e1cc2683275156f4b398d94579fe70d3fbab8612",
|
| 12 |
+
"test_splits.py": "306b7967257940b282c1882b60e3b0a70a62b5e46b4430936f7ca8ecce56a3ee"
|
| 13 |
+
}
|
| 14 |
+
}
|
cli/NOTICE
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Split Boundary Audit
|
| 2 |
+
Copyright 2026 Renchao Wu
|
| 3 |
+
All included example records are author-constructed synthetic data.
|
cli/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
- zh
|
| 6 |
+
pretty_name: Split Boundary Audit
|
| 7 |
+
size_categories:
|
| 8 |
+
- n<1K
|
| 9 |
+
configs:
|
| 10 |
+
- config_name: synthetic_split_records
|
| 11 |
+
data_files:
|
| 12 |
+
- split: test
|
| 13 |
+
path: example.jsonl
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# Split Boundary Audit
|
| 17 |
+
|
| 18 |
+
Check a declared split inventory before using it to support a model-evaluation claim. The CLI identifies repeated ids, caller-defined groups spanning splits, exact text shared across splits, and a separate list of normalized-text candidates for human review.
|
| 19 |
+
|
| 20 |
+
It reads records and writes a report. It does not train a model, infer exposure to training data, resplit a dataset, delete records or decide that two similar prompts mean the same thing.
|
| 21 |
+
|
| 22 |
+
## Reproduce the example
|
| 23 |
+
|
| 24 |
+
Python standard library only:
|
| 25 |
+
|
| 26 |
+
```sh
|
| 27 |
+
python -m unittest test_splits -v
|
| 28 |
+
python split_audit.py example.jsonl --output fresh-report
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
The six author-constructed records deliberately contain one cross-split group, one exact text overlap and one whitespace-normalized candidate. The CLI writes a FAIL report and exits 1 for this example; that is the expected result. Choose a new output directory. Existing directories are never overwritten and source data is unchanged.
|
| 32 |
+
|
| 33 |
+
The output files are `report.json` and `flags.csv`. Exit 2 means invalid input or an output error. Exit 0 means the valid input produced either CLEAR or REVIEW; inspect the report status to distinguish them.
|
| 34 |
+
|
| 35 |
+
## Three different kinds of evidence
|
| 36 |
+
|
| 37 |
+
| Check | Interpretation under this protocol |
|
| 38 |
+
| --- | --- |
|
| 39 |
+
| Duplicate id | A record identity appears more than once, even within a split. |
|
| 40 |
+
| Group overlap | A declared indivisible unit appears in multiple splits. |
|
| 41 |
+
| Exact text overlap | UTF-8 text bytes hash identically across splits. |
|
| 42 |
+
| Normalized candidate | NFC plus collapsed whitespace agrees across splits, but exact text hashes differ. Requires review. |
|
| 43 |
+
|
| 44 |
+
A group must represent a unit the caller intends to keep together, such as a document or a template family. A demographic cohort or broad class label is a different concept and should not be used as this grouping field. `null` groups are counted as unknown rather than treated as distinct independent units.
|
| 45 |
+
|
| 46 |
+
Normalization is warning-only. Whitespace and Unicode spelling can carry meaning, especially in code and structured text. The tool does not casefold text, assert semantic equivalence or automatically remove candidates. Exact overlap may also be intentional under another evaluation protocol; the tool flags it under the declared disjointness contract rather than proving accidental leakage.
|
| 47 |
+
|
| 48 |
+
## Input
|
| 49 |
+
|
| 50 |
+
One UTF-8 JSON object per LF-delimited line, with exactly four keys:
|
| 51 |
+
|
| 52 |
+
```json
|
| 53 |
+
{"id":"case-1","split":"train","group":"document-a","text":"Synthetic prompt"}
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
`id` and `split` are nonempty strings of at most 128 characters. `group` is a nonempty string up to 128 characters or `null`. `text` is a nonempty string up to 16,384 characters. Limits are 2 MiB and 10,000 records. Blank lines are counted and ignored. CRLF records are accepted. A literal U+2028 character inside a JSON string stays part of that record; it is not treated as a record separator.
|
| 57 |
+
|
| 58 |
+
Duplicate JSON object keys, extra fields, invalid Unicode, malformed JSONL and non-finite constants are rejected. No URLs or file paths in records are followed. Only the explicitly selected local JSONL file is read. No network, keys, dependencies or model calls are required.
|
| 59 |
+
|
| 60 |
+
## Reports and limits
|
| 61 |
+
|
| 62 |
+
The report includes row counts by split, group coverage, missing-group count, explicit issue memberships and normalization candidates. It does not echo the text field; exact/normalized text is represented by SHA-256 hashes. This is not anonymization: identifiers and group names are retained, and predictable text hashes can be guessed. Use the synthetic example for public sharing.
|
| 63 |
+
|
| 64 |
+
FAIL means a duplicate-id, group or exact-text issue was found. REVIEW means only normalization candidates were found. CLEAR means these checks found no flag; it does not prove a dataset is free of all contamination, paraphrases, shared upstream sources or hidden training exposure. Empty input is CLEAR with undefined group coverage.
|
| 65 |
+
|
| 66 |
+
Eight local test groups cover the frozen six-record example, reversed input order, same-split controls, unknown groups, normalization-only status, Unicode variants, malformed records, spreadsheet-safe CSV strings, LF/U+2028 handling and CLI overwrite protection. Recorded local evidence used CPython 3.14.7 on macOS. Other runtimes and large external datasets were not tested. The test corpus is synthetic, not a measured model benchmark.
|
| 67 |
+
|
| 68 |
+
Apache-2.0; copyright 2026 Renchao Wu. `MANIFEST.json` hashes all release files except itself.
|
| 69 |
+
|
| 70 |
+
## 中文说明
|
| 71 |
+
|
| 72 |
+
分别检查重复ID、跨拆分的同组记录、跨拆分完全相同文本,以及需要人工确认的规范化文本候选。group必须是调用者约定不可拆开的文档或模板族等单位;缺失group不能自动当成独立样本。规范化相同只标待复核,不自动认定语义相同或删除记录。CLEAR仅表示��工具未发现这些标记,不证明不存在其他形式的数据污染。
|
cli/example.jsonl
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"id": "t1", "split": "train", "group": "g1", "text": "alpha"}
|
| 2 |
+
{"id": "e1", "split": "test", "group": "g1", "text": "beta"}
|
| 3 |
+
{"id": "t2", "split": "train", "group": "g2", "text": "shared"}
|
| 4 |
+
{"id": "e2", "split": "test", "group": "g3", "text": "shared"}
|
| 5 |
+
{"id": "t3", "split": "train", "group": "g4", "text": " x y"}
|
| 6 |
+
{"id": "e3", "split": "test", "group": "g5", "text": "x y"}
|
cli/flags.csv
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
kind,key,id,split,group
|
| 2 |
+
group_overlap,g1,e1,test,g1
|
| 3 |
+
group_overlap,g1,t1,train,g1
|
| 4 |
+
exact_text_overlap,a4d26868017c0ccffe2efe50944ef4211834660cca834c6e9f86dec6a88246fa,e2,test,g3
|
| 5 |
+
exact_text_overlap,a4d26868017c0ccffe2efe50944ef4211834660cca834c6e9f86dec6a88246fa,t2,train,g2
|
| 6 |
+
normalized_candidate,887fcea6a80333c6c02ae7e79735f0edad8d811f0b61431495f796f4bf6a7c19,e3,test,g5
|
| 7 |
+
normalized_candidate,887fcea6a80333c6c02ae7e79735f0edad8d811f0b61431495f796f4bf6a7c19,t3,train,g4
|
cli/report.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"tool_version": "0.1.0",
|
| 3 |
+
"scope": "declared records only; CLEAR means these checks found no flag, not absence of all contamination",
|
| 4 |
+
"group_contract": "caller declares group as an indivisible evaluation unit, not a cohort label",
|
| 5 |
+
"normalization": "NFC then collapse whitespace; warning-only, no casefold or semantic identity assertion",
|
| 6 |
+
"total_records": 6,
|
| 7 |
+
"blank_lines_ignored": 0,
|
| 8 |
+
"rows_by_split": {
|
| 9 |
+
"test": 3,
|
| 10 |
+
"train": 3
|
| 11 |
+
},
|
| 12 |
+
"group_coverage": {
|
| 13 |
+
"known": 6,
|
| 14 |
+
"total": 6,
|
| 15 |
+
"value": 1.0
|
| 16 |
+
},
|
| 17 |
+
"unknown_group_records": 0,
|
| 18 |
+
"unique_known_groups": 5,
|
| 19 |
+
"status": "FAIL",
|
| 20 |
+
"issue_counts": {
|
| 21 |
+
"exact_text_overlap": 1,
|
| 22 |
+
"group_overlap": 1
|
| 23 |
+
},
|
| 24 |
+
"issues": [
|
| 25 |
+
{
|
| 26 |
+
"kind": "group_overlap",
|
| 27 |
+
"key": "g1",
|
| 28 |
+
"members": [
|
| 29 |
+
{
|
| 30 |
+
"id": "e1",
|
| 31 |
+
"split": "test",
|
| 32 |
+
"group": "g1"
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"id": "t1",
|
| 36 |
+
"split": "train",
|
| 37 |
+
"group": "g1"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"kind": "exact_text_overlap",
|
| 43 |
+
"key": "a4d26868017c0ccffe2efe50944ef4211834660cca834c6e9f86dec6a88246fa",
|
| 44 |
+
"members": [
|
| 45 |
+
{
|
| 46 |
+
"id": "e2",
|
| 47 |
+
"split": "test",
|
| 48 |
+
"group": "g3"
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"id": "t2",
|
| 52 |
+
"split": "train",
|
| 53 |
+
"group": "g2"
|
| 54 |
+
}
|
| 55 |
+
]
|
| 56 |
+
}
|
| 57 |
+
],
|
| 58 |
+
"normalized_candidates": [
|
| 59 |
+
{
|
| 60 |
+
"kind": "normalized_candidate",
|
| 61 |
+
"key": "887fcea6a80333c6c02ae7e79735f0edad8d811f0b61431495f796f4bf6a7c19",
|
| 62 |
+
"exact_hashes": [
|
| 63 |
+
"05361d8ca243d1fb300cc65443de4186b1048b3c2e6cc1dcf069fce4e2778e4d",
|
| 64 |
+
"887fcea6a80333c6c02ae7e79735f0edad8d811f0b61431495f796f4bf6a7c19"
|
| 65 |
+
],
|
| 66 |
+
"members": [
|
| 67 |
+
{
|
| 68 |
+
"id": "e3",
|
| 69 |
+
"split": "test",
|
| 70 |
+
"group": "g5"
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"id": "t3",
|
| 74 |
+
"split": "train",
|
| 75 |
+
"group": "g4"
|
| 76 |
+
}
|
| 77 |
+
]
|
| 78 |
+
}
|
| 79 |
+
]
|
| 80 |
+
}
|
cli/split_audit.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Read-only disjointness checks on declared dataset split records."""
|
| 2 |
+
import argparse
|
| 3 |
+
from collections import Counter,defaultdict
|
| 4 |
+
import csv
|
| 5 |
+
import hashlib
|
| 6 |
+
import io
|
| 7 |
+
import json
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
import unicodedata
|
| 10 |
+
|
| 11 |
+
VERSION='0.1.0';MAX_BYTES=2*1024*1024;MAX_ROWS=10000
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def unique(pairs):
|
| 15 |
+
d={}
|
| 16 |
+
for k,v in pairs:
|
| 17 |
+
if k in d:raise ValueError('duplicate JSON key')
|
| 18 |
+
d[k]=v
|
| 19 |
+
return d
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def text_field(value,limit,identifier=False):
|
| 23 |
+
if not isinstance(value,str) or not value or len(value)>limit or (identifier and not value.strip()):raise ValueError('invalid string field')
|
| 24 |
+
try:value.encode('utf-8')
|
| 25 |
+
except UnicodeError:raise ValueError('invalid Unicode string') from None
|
| 26 |
+
return value
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def validate(rows):
|
| 30 |
+
if not isinstance(rows,list) or len(rows)>MAX_ROWS:raise ValueError('use at most 10000 records')
|
| 31 |
+
for row in rows:
|
| 32 |
+
if not isinstance(row,dict) or set(row)!={'id','split','group','text'}:raise ValueError('each record requires id, split, group, text')
|
| 33 |
+
text_field(row['id'],128,True);text_field(row['split'],128,True)
|
| 34 |
+
if row['group'] is not None:text_field(row['group'],128,True)
|
| 35 |
+
text_field(row['text'],16384)
|
| 36 |
+
return rows
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def read(raw):
|
| 40 |
+
if len(raw)>MAX_BYTES:raise ValueError('input exceeds 2 MiB')
|
| 41 |
+
try:
|
| 42 |
+
text=raw.decode('utf-8');lines=text.split('\n') if text else []
|
| 43 |
+
if text.endswith('\n'):lines.pop()
|
| 44 |
+
except UnicodeError:raise ValueError('input must be UTF-8') from None
|
| 45 |
+
rows=[];blank=0
|
| 46 |
+
def constant(_):raise ValueError('non-finite JSON constant')
|
| 47 |
+
for line in lines:
|
| 48 |
+
if not line.strip():blank+=1;continue
|
| 49 |
+
if len(rows)>=MAX_ROWS:raise ValueError('input exceeds 10000 records')
|
| 50 |
+
try:rows.append(json.loads(line,object_pairs_hook=unique,parse_constant=constant))
|
| 51 |
+
except (ValueError,RecursionError):raise ValueError('invalid JSONL record') from None
|
| 52 |
+
return validate(rows),blank
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def digest(text):return hashlib.sha256(text.encode('utf-8')).hexdigest()
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def audit(rows,blank_lines=0):
|
| 59 |
+
validate(rows);ids=defaultdict(list);groups=defaultdict(list);exact=defaultdict(list);normal=defaultdict(list)
|
| 60 |
+
for row in rows:
|
| 61 |
+
member={'id':row['id'],'split':row['split'],'group':row['group']}
|
| 62 |
+
ids[row['id']].append(member)
|
| 63 |
+
if row['group'] is not None:groups[row['group']].append(member)
|
| 64 |
+
h=digest(row['text']);exact[h].append(member)
|
| 65 |
+
normal[digest(' '.join(unicodedata.normalize('NFC',row['text']).split()))].append((member,h))
|
| 66 |
+
def members(values):return sorted(values,key=lambda x:(x['split'],x['id'],x['group'] is None,x['group'] or ''))
|
| 67 |
+
def crosses(values):return len({m['split'] for m in values})>1
|
| 68 |
+
issues=[];candidates=[]
|
| 69 |
+
for key,values in sorted(ids.items()):
|
| 70 |
+
if len(values)>1:issues.append({'kind':'duplicate_id','key':key,'members':members(values)})
|
| 71 |
+
for key,values in sorted(groups.items()):
|
| 72 |
+
if crosses(values):issues.append({'kind':'group_overlap','key':key,'members':members(values)})
|
| 73 |
+
for key,values in sorted(exact.items()):
|
| 74 |
+
if crosses(values):issues.append({'kind':'exact_text_overlap','key':key,'members':members(values)})
|
| 75 |
+
for key,values in sorted(normal.items()):
|
| 76 |
+
ms=[m for m,h in values];hashes=sorted({h for m,h in values})
|
| 77 |
+
if crosses(ms) and len(hashes)>1:candidates.append({'kind':'normalized_candidate','key':key,'exact_hashes':hashes,'members':members(ms)})
|
| 78 |
+
counts=Counter(r['split'] for r in rows);known=sum(r['group'] is not None for r in rows)
|
| 79 |
+
return {'tool_version':VERSION,'scope':'declared records only; CLEAR means these checks found no flag, not absence of all contamination',
|
| 80 |
+
'group_contract':'caller declares group as an indivisible evaluation unit, not a cohort label',
|
| 81 |
+
'normalization':'NFC then collapse whitespace; warning-only, no casefold or semantic identity assertion',
|
| 82 |
+
'total_records':len(rows),'blank_lines_ignored':blank_lines,'rows_by_split':dict(sorted(counts.items())),
|
| 83 |
+
'group_coverage':{'known':known,'total':len(rows),'value':known/len(rows) if rows else None},
|
| 84 |
+
'unknown_group_records':len(rows)-known,'unique_known_groups':len(groups),
|
| 85 |
+
'status':'FAIL' if issues else ('REVIEW' if candidates else 'CLEAR'),
|
| 86 |
+
'issue_counts':dict(sorted(Counter(x['kind'] for x in issues).items())),
|
| 87 |
+
'issues':issues,'normalized_candidates':candidates}
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def csv_report(report):
|
| 91 |
+
out=io.StringIO(newline='');fields=['kind','key','id','split','group'];w=csv.DictWriter(out,fields,lineterminator='\n');w.writeheader()
|
| 92 |
+
def safe(v):
|
| 93 |
+
if isinstance(v,str) and v.lstrip().startswith(('=','+','-','@')):return "'"+v
|
| 94 |
+
return v
|
| 95 |
+
for issue in report['issues']+report['normalized_candidates']:
|
| 96 |
+
for m in issue['members']:w.writerow({k:safe(v) for k,v in {'kind':issue['kind'],'key':issue['key'],**m}.items()})
|
| 97 |
+
return out.getvalue()
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def main():
|
| 101 |
+
p=argparse.ArgumentParser(description=__doc__);p.add_argument('input',type=Path);p.add_argument('--output',required=True,type=Path);args=p.parse_args()
|
| 102 |
+
try:
|
| 103 |
+
if args.input.stat().st_size>MAX_BYTES:raise ValueError('input exceeds 2 MiB')
|
| 104 |
+
rows,blank=read(args.input.read_bytes());report=audit(rows,blank)
|
| 105 |
+
if args.output.exists():raise ValueError('output already exists')
|
| 106 |
+
args.output.mkdir(parents=True)
|
| 107 |
+
(args.output/'report.json').write_text(json.dumps(report,ensure_ascii=False,allow_nan=False,indent=2)+'\n',encoding='utf-8')
|
| 108 |
+
(args.output/'flags.csv').write_text(csv_report(report),encoding='utf-8')
|
| 109 |
+
except (ValueError,TypeError,OSError) as exc:p.exit(2,'audit failed: '+str(exc)+'\n')
|
| 110 |
+
print(report['status']+':',report['total_records'],'declared records,',len(report['issues']),'issues,',len(report['normalized_candidates']),'normalization candidates.')
|
| 111 |
+
return 1 if report['status']=='FAIL' else 0
|
| 112 |
+
if __name__=='__main__':raise SystemExit(main())
|
cli/test_splits.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from copy import deepcopy
|
| 2 |
+
import json,subprocess,sys,tempfile,unittest
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
from split_audit import audit,read,csv_report
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def sample():
|
| 8 |
+
return [dict(id=i,split=s,group=g,text=t) for i,s,g,t in [('t1','train','g1','alpha'),('e1','test','g1','beta'),('t2','train','g2','shared'),('e2','test','g3','shared'),('t3','train','g4',' x y'),('e3','test','g5','x y')]]
|
| 9 |
+
|
| 10 |
+
class SplitTests(unittest.TestCase):
|
| 11 |
+
def test_frozen_example_and_no_text_echo(self):
|
| 12 |
+
r=audit(sample());self.assertEqual(r['status'],'FAIL');self.assertEqual(r['rows_by_split'],{'test':3,'train':3})
|
| 13 |
+
self.assertEqual(r['issue_counts'],{'group_overlap':1,'exact_text_overlap':1});self.assertEqual(len(r['normalized_candidates']),1)
|
| 14 |
+
self.assertEqual(r,audit(list(reversed(sample()))))
|
| 15 |
+
encoded=json.dumps(r);self.assertNotIn('alpha',encoded);self.assertNotIn('beta',encoded);self.assertNotIn('shared',encoded)
|
| 16 |
+
def test_clean_and_same_split(self):
|
| 17 |
+
rows=sample();
|
| 18 |
+
for row in rows:row['split']='train'
|
| 19 |
+
self.assertEqual(audit(rows)['status'],'CLEAR')
|
| 20 |
+
self.assertEqual(audit([])['status'],'CLEAR');self.assertIsNone(audit([])['group_coverage']['value'])
|
| 21 |
+
def test_normalization_only_is_review(self):
|
| 22 |
+
r=audit(sample()[-2:]);self.assertEqual(r['status'],'REVIEW');self.assertEqual(r['issues'],[])
|
| 23 |
+
d=[dict(id='x',split='train',group='1',text='é'),dict(id='y',split='test',group='2',text='e\u0301')]
|
| 24 |
+
self.assertEqual(audit(d)['status'],'REVIEW')
|
| 25 |
+
d[1]['text']='É';self.assertEqual(audit(d)['status'],'CLEAR')
|
| 26 |
+
def test_missing_groups_and_duplicate_ids(self):
|
| 27 |
+
rows=sample()[:2]
|
| 28 |
+
for row in rows:row['group']=None
|
| 29 |
+
r=audit(rows);self.assertEqual(r['unknown_group_records'],2);self.assertEqual(r['status'],'CLEAR')
|
| 30 |
+
rows[1]['id']=rows[0]['id'];self.assertEqual(audit(rows)['issue_counts'],{'duplicate_id':1})
|
| 31 |
+
def test_invalid_records(self):
|
| 32 |
+
for raw in (b'{"id":1,"id":2}',b'{"x":NaN}',b'\xff'):
|
| 33 |
+
with self.assertRaises(ValueError):read(raw)
|
| 34 |
+
for key in ('id','split','text'):
|
| 35 |
+
rows=sample();rows[0][key]=chr(0xd800)
|
| 36 |
+
with self.assertRaises(ValueError):audit(rows)
|
| 37 |
+
rows=sample();rows[0]['extra']=True
|
| 38 |
+
with self.assertRaises(ValueError):audit(rows)
|
| 39 |
+
rows,blank=read(b'\n \n');self.assertEqual((len(rows),blank),(0,2))
|
| 40 |
+
self.assertEqual(read(b''),([],0))
|
| 41 |
+
def test_unicode_line_separator_is_text_not_record_boundary(self):
|
| 42 |
+
row=dict(id='u',split='test',group=None,text='before'+chr(0x2028)+'after')
|
| 43 |
+
raw=(json.dumps(row,ensure_ascii=False)+'\n').encode('utf-8')
|
| 44 |
+
rows,blank=read(raw);self.assertEqual(rows,[row]);self.assertEqual(blank,0)
|
| 45 |
+
def test_csv_formula_guard(self):
|
| 46 |
+
rows=sample()[:2];rows[0]['id']='=SUM(1,2)';rows[0]['split']='@train'
|
| 47 |
+
r=audit(rows);self.assertIn("'=SUM",csv_report(r));self.assertIn("'@train",csv_report(r));self.assertEqual(r['issues'][0]['members'][0]['id'],'=SUM(1,2)')
|
| 48 |
+
def test_cli_no_overwrite(self):
|
| 49 |
+
with tempfile.TemporaryDirectory() as temp:
|
| 50 |
+
root=Path(temp);source=root/'input.jsonl';source.write_text(''.join(json.dumps(x)+'\n' for x in sample()))
|
| 51 |
+
output=root/'out';cmd=[sys.executable,'split_audit.py',str(source),'--output',str(output)]
|
| 52 |
+
self.assertEqual(subprocess.run(cmd,capture_output=True).returncode,1)
|
| 53 |
+
before={x.name:x.read_bytes() for x in output.iterdir()}
|
| 54 |
+
self.assertEqual(subprocess.run(cmd,capture_output=True).returncode,2)
|
| 55 |
+
self.assertEqual(before,{x.name:x.read_bytes() for x in output.iterdir()})
|
| 56 |
+
if __name__=='__main__':unittest.main(verbosity=2)
|
index.html
CHANGED
|
@@ -1,19 +1,213 @@
|
|
| 1 |
<!doctype html>
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
| 6 |
+
<meta
|
| 7 |
+
http-equiv="Content-Security-Policy"
|
| 8 |
+
content="default-src 'self'; script-src 'self'; style-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'none'"
|
| 9 |
+
/>
|
| 10 |
+
<title>Split Boundary Audit · Group Planner</title>
|
| 11 |
+
<link rel="stylesheet" href="style.css" />
|
| 12 |
+
<script type="module" src="app.mjs"></script>
|
| 13 |
+
</head>
|
| 14 |
+
<body>
|
| 15 |
+
<main>
|
| 16 |
+
<header>
|
| 17 |
+
<p class="eyebrow">WIDECHAOS / SPLIT BOUNDARY AUDIT 0.2</p>
|
| 18 |
+
<h1>Keep groups together.</h1>
|
| 19 |
+
<p class="lede">
|
| 20 |
+
Plan train, validation and test splits while keeping declared groups
|
| 21 |
+
and exact duplicate text together.
|
| 22 |
+
</p>
|
| 23 |
+
<p>
|
| 24 |
+
See the achieved ratios, inspect label coverage, and export every
|
| 25 |
+
record. Targets are approximate; this greedy planner does not promise
|
| 26 |
+
the best possible balance.
|
| 27 |
+
</p>
|
| 28 |
+
</header>
|
| 29 |
+
<div class="workspace">
|
| 30 |
+
<section>
|
| 31 |
+
<h2>1. Describe the indivisible groups</h2>
|
| 32 |
+
<label for="data">Input JSONL</label
|
| 33 |
+
><textarea
|
| 34 |
+
id="data"
|
| 35 |
+
rows="16"
|
| 36 |
+
spellcheck="false"
|
| 37 |
+
aria-describedby="input-help"
|
| 38 |
+
></textarea>
|
| 39 |
+
<p id="input-help" class="hint">
|
| 40 |
+
Each line: id, group, label, text. Up to 5,000 records and 2 MiB
|
| 41 |
+
UTF-8. The bundled 36-record example is synthetic.
|
| 42 |
+
</p>
|
| 43 |
+
<details>
|
| 44 |
+
<summary>What should a group mean?</summary>
|
| 45 |
+
<p>
|
| 46 |
+
A caller-defined indivisible evaluation unit, such as a document
|
| 47 |
+
or a template family. A class label or population cohort usually
|
| 48 |
+
does not describe that unit. Missing groups are rejected; the
|
| 49 |
+
planner cannot infer trustworthy groups for you.
|
| 50 |
+
</p>
|
| 51 |
+
<p>
|
| 52 |
+
Exact text duplicates connect groups into larger allocation units.
|
| 53 |
+
NFC/whitespace matches only produce review warnings; they do not
|
| 54 |
+
connect groups. No rows are discarded.
|
| 55 |
+
</p>
|
| 56 |
+
<p>
|
| 57 |
+
Native JSON.parse keeps the last duplicate object key. This
|
| 58 |
+
application does not detect duplicate keys within a line.
|
| 59 |
+
</p>
|
| 60 |
+
</details>
|
| 61 |
+
<h2 class="config-heading">2. Set approximate targets</h2>
|
| 62 |
+
<fieldset>
|
| 63 |
+
<legend>Row percentages · positive integers, total 100</legend>
|
| 64 |
+
<div class="ratios">
|
| 65 |
+
<div>
|
| 66 |
+
<label for="train">Train %</label
|
| 67 |
+
><input
|
| 68 |
+
id="train"
|
| 69 |
+
type="number"
|
| 70 |
+
min="1"
|
| 71 |
+
max="98"
|
| 72 |
+
step="1"
|
| 73 |
+
value="80"
|
| 74 |
+
/>
|
| 75 |
+
</div>
|
| 76 |
+
<div>
|
| 77 |
+
<label for="validation">Validation %</label
|
| 78 |
+
><input
|
| 79 |
+
id="validation"
|
| 80 |
+
type="number"
|
| 81 |
+
min="1"
|
| 82 |
+
max="98"
|
| 83 |
+
step="1"
|
| 84 |
+
value="10"
|
| 85 |
+
/>
|
| 86 |
+
</div>
|
| 87 |
+
<div>
|
| 88 |
+
<label for="test">Test %</label
|
| 89 |
+
><input
|
| 90 |
+
id="test"
|
| 91 |
+
type="number"
|
| 92 |
+
min="1"
|
| 93 |
+
max="98"
|
| 94 |
+
step="1"
|
| 95 |
+
value="10"
|
| 96 |
+
/>
|
| 97 |
+
</div>
|
| 98 |
+
</div>
|
| 99 |
+
</fieldset>
|
| 100 |
+
<label for="seed">Ordering seed</label
|
| 101 |
+
><input
|
| 102 |
+
id="seed"
|
| 103 |
+
type="number"
|
| 104 |
+
min="0"
|
| 105 |
+
max="4294967295"
|
| 106 |
+
step="1"
|
| 107 |
+
value="17"
|
| 108 |
+
/><button id="plan" disabled>Plan whole groups</button>
|
| 109 |
+
<p id="status" role="status" aria-live="polite">
|
| 110 |
+
Loading synthetic example…
|
| 111 |
+
</p>
|
| 112 |
+
<p id="error" role="alert" tabindex="-1" hidden></p>
|
| 113 |
+
<p class="hint">
|
| 114 |
+
Input and settings stay in your browser. Editing them clears the
|
| 115 |
+
previous plan and download links.
|
| 116 |
+
</p>
|
| 117 |
+
</section>
|
| 118 |
+
<section>
|
| 119 |
+
<h2>3. Review the plan</h2>
|
| 120 |
+
<div id="placeholder" class="placeholder">
|
| 121 |
+
Plan the sample or your own grouped data to inspect its actual
|
| 122 |
+
distribution.
|
| 123 |
+
</div>
|
| 124 |
+
<div id="results" hidden>
|
| 125 |
+
<p id="summary" class="summary"></p>
|
| 126 |
+
<p id="audit-state" class="notice"></p>
|
| 127 |
+
<p id="audit-counts" class="hint"></p>
|
| 128 |
+
<div class="table-wrap">
|
| 129 |
+
<table>
|
| 130 |
+
<caption>
|
| 131 |
+
All declared records, without dropping any
|
| 132 |
+
</caption>
|
| 133 |
+
<thead>
|
| 134 |
+
<tr>
|
| 135 |
+
<th scope="col">Split</th>
|
| 136 |
+
<th scope="col">Target rows</th>
|
| 137 |
+
<th scope="col">Actual rows</th>
|
| 138 |
+
<th scope="col">Deviation</th>
|
| 139 |
+
</tr>
|
| 140 |
+
</thead>
|
| 141 |
+
<tbody id="split-rows"></tbody>
|
| 142 |
+
</table>
|
| 143 |
+
</div>
|
| 144 |
+
<p id="objective" class="hint"></p>
|
| 145 |
+
<h3>Per-label distribution</h3>
|
| 146 |
+
<div class="table-wrap">
|
| 147 |
+
<table>
|
| 148 |
+
<caption>
|
| 149 |
+
Actual rows / fractional target
|
| 150 |
+
</caption>
|
| 151 |
+
<thead>
|
| 152 |
+
<tr>
|
| 153 |
+
<th scope="col">Label</th>
|
| 154 |
+
<th scope="col">Total</th>
|
| 155 |
+
<th scope="col">Train</th>
|
| 156 |
+
<th scope="col">Validation</th>
|
| 157 |
+
<th scope="col">Test</th>
|
| 158 |
+
</tr>
|
| 159 |
+
</thead>
|
| 160 |
+
<tbody id="label-rows"></tbody>
|
| 161 |
+
</table>
|
| 162 |
+
</div>
|
| 163 |
+
<details>
|
| 164 |
+
<summary>Allocation units and linked groups</summary>
|
| 165 |
+
<div class="table-wrap">
|
| 166 |
+
<table>
|
| 167 |
+
<thead>
|
| 168 |
+
<tr>
|
| 169 |
+
<th scope="col">Unit</th>
|
| 170 |
+
<th scope="col">Declared groups</th>
|
| 171 |
+
<th scope="col">Rows</th>
|
| 172 |
+
<th scope="col">Split</th>
|
| 173 |
+
</tr>
|
| 174 |
+
</thead>
|
| 175 |
+
<tbody id="unit-rows"></tbody>
|
| 176 |
+
</table>
|
| 177 |
+
</div>
|
| 178 |
+
</details>
|
| 179 |
+
<details>
|
| 180 |
+
<summary>Review warnings</summary>
|
| 181 |
+
<div id="warnings"></div>
|
| 182 |
+
</details>
|
| 183 |
+
<div id="downloads" class="downloads"></div>
|
| 184 |
+
<p class="hint">
|
| 185 |
+
Assigned JSONL includes every source text. The report includes
|
| 186 |
+
ids, groups and labels. Review either file before sharing. JSONL
|
| 187 |
+
uses the original CLI's audit schema; its labels remain in the
|
| 188 |
+
report.
|
| 189 |
+
</p>
|
| 190 |
+
<details>
|
| 191 |
+
<summary>Full current plan report</summary>
|
| 192 |
+
<pre id="report"></pre>
|
| 193 |
+
</details>
|
| 194 |
+
</div>
|
| 195 |
+
</section>
|
| 196 |
+
</div>
|
| 197 |
+
<footer>
|
| 198 |
+
<p>
|
| 199 |
+
Group integrity and ratio balance are separate checks. CLEAR only
|
| 200 |
+
refers to the bounded checks shown here; it does not establish
|
| 201 |
+
independence or absence of other contamination.
|
| 202 |
+
</p>
|
| 203 |
+
<p>
|
| 204 |
+
Static browser processing · no uploads, models or storage ·
|
| 205 |
+
<a href="README.md">Method and CLI reproduction</a>
|
| 206 |
+
</p>
|
| 207 |
+
<p lang="zh">
|
| 208 |
+
整组分配,保留所有记录和实际偏差。完全相同文本会连接组;规范化候选只提醒,不自动认定语义相同,也不保证全局最优。
|
| 209 |
+
</p>
|
| 210 |
+
</footer>
|
| 211 |
+
</main>
|
| 212 |
+
</body>
|
| 213 |
</html>
|
make_sample.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Create a synthetic planning example; no model or external dataset involved."""
|
| 2 |
+
import hashlib,json
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
r=Path(__file__).resolve().parent
|
| 5 |
+
if (r/'sample.jsonl').exists():raise SystemExit('Frozen sample exists; not overwritten.')
|
| 6 |
+
rows=[]
|
| 7 |
+
for label in ['bug','example','question']:
|
| 8 |
+
for family in range(4):
|
| 9 |
+
for variant in range(3):rows.append({'id':f'{label}-{family}-{variant}','group':f'family-{label}-{family}','label':label,'text':f'Synthetic {label} template family {family}, sibling {variant}. 合成样例。'})
|
| 10 |
+
rows[0]['text']=rows[4]['text']='Exact duplicate: sample payload.'
|
| 11 |
+
rows[12]['text']=rows[24]['text']='Cross-label duplicate: same input.'
|
| 12 |
+
rows[15]['text']='Café note';rows[27]['text']='Cafe\u0301 note'
|
| 13 |
+
(r/'sample.jsonl').write_text(''.join(json.dumps(row,ensure_ascii=False)+'\n' for row in rows))
|
| 14 |
+
(r/'SAMPLE-SNAPSHOT.json').write_text(json.dumps({'phase':'before planner implementation','scope':'36 synthetic records, 12 declared template-family groups, three labels; two exact-text edges merge two disjoint group pairs into ten allocation units; one exact-text label conflict; one NFC/whitespace candidate pair whose split outcome is not prespecified','sample_sha256':hashlib.sha256((r/'sample.jsonl').read_bytes()).hexdigest()},indent=2)+'\n')
|
| 15 |
+
print('Frozen sample',hashlib.sha256((r/'sample.jsonl').read_bytes()).hexdigest())
|
oracle_driver.mjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import fs from "node:fs";
|
| 2 |
+
import { plan } from "./planner.mjs";
|
| 3 |
+
const cases = JSON.parse(fs.readFileSync(0, "utf8"));
|
| 4 |
+
console.log(
|
| 5 |
+
JSON.stringify(cases.map((c) => plan(c.rows, c.percentages, c.seed).report)),
|
| 6 |
+
);
|
planner.mjs
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Whole declared-group allocation with explicit exact-text co-location. */
|
| 2 |
+
export const VERSION = "0.2.0";
|
| 3 |
+
export const SPLITS = Object.freeze(["train", "validation", "test"]);
|
| 4 |
+
const WS =
|
| 5 |
+
/[\u0009-\u000d\u001c-\u0020\u0085\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]+/gu;
|
| 6 |
+
export const normalized = (text) =>
|
| 7 |
+
text.normalize("NFC").replace(WS, " ").replace(/^ | $/g, "");
|
| 8 |
+
export function compare(a, b) {
|
| 9 |
+
const x = Array.from(a, (c) => c.codePointAt(0)),
|
| 10 |
+
y = Array.from(b, (c) => c.codePointAt(0));
|
| 11 |
+
for (let i = 0; i < Math.min(x.length, y.length); i++)
|
| 12 |
+
if (x[i] !== y[i]) return x[i] - y[i];
|
| 13 |
+
return x.length - y.length;
|
| 14 |
+
}
|
| 15 |
+
export function scalar(s) {
|
| 16 |
+
for (const c of s) {
|
| 17 |
+
const x = c.codePointAt(0);
|
| 18 |
+
if (x >= 0xd800 && x <= 0xdfff) return false;
|
| 19 |
+
}
|
| 20 |
+
return true;
|
| 21 |
+
}
|
| 22 |
+
function validString(s, max) {
|
| 23 |
+
return (
|
| 24 |
+
typeof s === "string" &&
|
| 25 |
+
s.length <= max &&
|
| 26 |
+
scalar(s) &&
|
| 27 |
+
normalized(s).length > 0
|
| 28 |
+
);
|
| 29 |
+
}
|
| 30 |
+
export function validate(rows) {
|
| 31 |
+
if (!Array.isArray(rows) || rows.length < 1 || rows.length > 5000)
|
| 32 |
+
throw Error("Use 1–5,000 JSONL records.");
|
| 33 |
+
const ids = new Set();
|
| 34 |
+
return rows.map((r, i) => {
|
| 35 |
+
if (
|
| 36 |
+
!r ||
|
| 37 |
+
Array.isArray(r) ||
|
| 38 |
+
typeof r !== "object" ||
|
| 39 |
+
Object.keys(r).sort().join(",") !== "group,id,label,text"
|
| 40 |
+
)
|
| 41 |
+
throw Error(`Record ${i + 1} needs exactly id, group, label and text.`);
|
| 42 |
+
for (const k of ["id", "group", "label", "text"])
|
| 43 |
+
if (!validString(r[k], k === "text" ? 16384 : 128))
|
| 44 |
+
throw Error(
|
| 45 |
+
`Record ${i + 1}: ${k} must be a nonblank Unicode scalar string within its length limit.`,
|
| 46 |
+
);
|
| 47 |
+
if (ids.has(r.id)) throw Error(`Record ${i + 1}: duplicate id.`);
|
| 48 |
+
ids.add(r.id);
|
| 49 |
+
return { id: r.id, group: r.group, label: r.label, text: r.text };
|
| 50 |
+
});
|
| 51 |
+
}
|
| 52 |
+
export function parseJSONL(raw) {
|
| 53 |
+
if (
|
| 54 |
+
typeof raw !== "string" ||
|
| 55 |
+
raw.length > 2097152 ||
|
| 56 |
+
new TextEncoder().encode(raw).length > 2097152
|
| 57 |
+
)
|
| 58 |
+
throw Error("Input exceeds 2 MiB UTF-8.");
|
| 59 |
+
let lines = raw.split("\n");
|
| 60 |
+
if (raw.endsWith("\n")) lines.pop();
|
| 61 |
+
let blank = 0;
|
| 62 |
+
const rows = [];
|
| 63 |
+
for (const [i, line] of lines.entries()) {
|
| 64 |
+
if (!normalized(line)) {
|
| 65 |
+
blank++;
|
| 66 |
+
continue;
|
| 67 |
+
}
|
| 68 |
+
if (rows.length >= 5000) throw Error("Input exceeds 5,000 records.");
|
| 69 |
+
try {
|
| 70 |
+
rows.push(JSON.parse(line));
|
| 71 |
+
} catch {
|
| 72 |
+
throw Error(`Invalid JSON on line ${i + 1}.`);
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
return { rows: validate(rows), blank_lines_ignored: blank };
|
| 76 |
+
}
|
| 77 |
+
export function settings(percentages, seed) {
|
| 78 |
+
if (
|
| 79 |
+
!Array.isArray(percentages) ||
|
| 80 |
+
percentages.length !== 3 ||
|
| 81 |
+
percentages.some((x) => !Number.isInteger(x) || x <= 0 || x >= 100) ||
|
| 82 |
+
percentages.reduce((a, b) => a + b, 0) !== 100
|
| 83 |
+
)
|
| 84 |
+
throw Error("Use three positive integer percentages that sum to 100.");
|
| 85 |
+
if (!Number.isInteger(seed) || seed < 0 || seed > 4294967295)
|
| 86 |
+
throw Error("Seed must be an integer from 0 to 4,294,967,295.");
|
| 87 |
+
return { percentages: percentages.slice(), seed };
|
| 88 |
+
}
|
| 89 |
+
export function priority(seed, key) {
|
| 90 |
+
let h = 2166136261;
|
| 91 |
+
for (const b of new TextEncoder().encode(String(seed) + "\0" + key)) {
|
| 92 |
+
h = Math.imul(h ^ b, 16777619) >>> 0;
|
| 93 |
+
}
|
| 94 |
+
return h;
|
| 95 |
+
}
|
| 96 |
+
export function makeUnits(rows) {
|
| 97 |
+
const parent = new Map();
|
| 98 |
+
for (const r of rows) parent.set(r.group, r.group);
|
| 99 |
+
const find = (g) => {
|
| 100 |
+
let root = g;
|
| 101 |
+
while (parent.get(root) !== root) root = parent.get(root);
|
| 102 |
+
while (g !== root) {
|
| 103 |
+
const next = parent.get(g);
|
| 104 |
+
parent.set(g, root);
|
| 105 |
+
g = next;
|
| 106 |
+
}
|
| 107 |
+
return root;
|
| 108 |
+
};
|
| 109 |
+
const unite = (a, b) => {
|
| 110 |
+
a = find(a);
|
| 111 |
+
b = find(b);
|
| 112 |
+
if (a !== b) {
|
| 113 |
+
const lo = compare(a, b) < 0 ? a : b,
|
| 114 |
+
hi = lo === a ? b : a;
|
| 115 |
+
parent.set(hi, lo);
|
| 116 |
+
}
|
| 117 |
+
};
|
| 118 |
+
const firstText = new Map();
|
| 119 |
+
for (const r of rows) {
|
| 120 |
+
if (firstText.has(r.text)) unite(firstText.get(r.text), r.group);
|
| 121 |
+
else firstText.set(r.text, r.group);
|
| 122 |
+
}
|
| 123 |
+
const units = new Map();
|
| 124 |
+
for (const r of rows) {
|
| 125 |
+
const key = find(r.group);
|
| 126 |
+
if (!units.has(key))
|
| 127 |
+
units.set(key, { key, groups: new Set(), rows: [], counts: new Map() });
|
| 128 |
+
const u = units.get(key);
|
| 129 |
+
u.groups.add(r.group);
|
| 130 |
+
u.rows.push(r);
|
| 131 |
+
u.counts.set(r.label, (u.counts.get(r.label) || 0) + 1);
|
| 132 |
+
}
|
| 133 |
+
return [...units.values()].map((u) => ({
|
| 134 |
+
...u,
|
| 135 |
+
groups: [...u.groups].sort(compare),
|
| 136 |
+
rows: u.rows.slice().sort((a, b) => compare(a.id, b.id)),
|
| 137 |
+
counts: new Map([...u.counts].sort((a, b) => compare(a[0], b[0]))),
|
| 138 |
+
}));
|
| 139 |
+
}
|
| 140 |
+
export function objective(totals, counts, labelTotals, percentages) {
|
| 141 |
+
const N = [...labelTotals.values()].reduce((a, b) => a + b, 0),
|
| 142 |
+
L = labelTotals.size;
|
| 143 |
+
let loss = 0;
|
| 144 |
+
for (let s = 0; s < 3; s++) {
|
| 145 |
+
const target = (N * percentages[s]) / 100;
|
| 146 |
+
loss += (totals[s] - target) ** 2 / (N * Math.max(1, target));
|
| 147 |
+
}
|
| 148 |
+
for (const [label, n] of [...labelTotals].sort((a, b) =>
|
| 149 |
+
compare(a[0], b[0]),
|
| 150 |
+
)) {
|
| 151 |
+
for (let s = 0; s < 3; s++) {
|
| 152 |
+
const target = (n * percentages[s]) / 100;
|
| 153 |
+
loss +=
|
| 154 |
+
(counts.get(label)[s] - target) ** 2 / (L * n * Math.max(1, target));
|
| 155 |
+
}
|
| 156 |
+
}
|
| 157 |
+
return loss;
|
| 158 |
+
}
|
| 159 |
+
function finalAudit(rows) {
|
| 160 |
+
const groups = new Map(),
|
| 161 |
+
texts = new Map(),
|
| 162 |
+
norm = new Map();
|
| 163 |
+
for (const r of rows) {
|
| 164 |
+
if (!groups.has(r.group)) groups.set(r.group, []);
|
| 165 |
+
groups.get(r.group).push(r);
|
| 166 |
+
if (!texts.has(r.text)) texts.set(r.text, []);
|
| 167 |
+
texts.get(r.text).push(r);
|
| 168 |
+
const n = normalized(r.text);
|
| 169 |
+
if (!norm.has(n)) norm.set(n, []);
|
| 170 |
+
norm.get(n).push(r);
|
| 171 |
+
}
|
| 172 |
+
const crosses = (values) => new Set(values.map((r) => r.split)).size > 1,
|
| 173 |
+
member = (r) => ({ id: r.id, group: r.group, split: r.split });
|
| 174 |
+
const candidates = [...norm.values()]
|
| 175 |
+
.filter((a) => crosses(a) && new Set(a.map((r) => r.text)).size > 1)
|
| 176 |
+
.map((a) => ({
|
| 177 |
+
kind: "normalized_candidate",
|
| 178 |
+
members: a.map(member).sort((a, b) => compare(a.id, b.id)),
|
| 179 |
+
}))
|
| 180 |
+
.sort((a, b) => compare(a.members[0].id, b.members[0].id));
|
| 181 |
+
const conflicts = [...texts.values()]
|
| 182 |
+
.filter((a) => new Set(a.map((r) => r.label)).size > 1)
|
| 183 |
+
.map((a) => ({
|
| 184 |
+
kind: "exact_text_label_conflict",
|
| 185 |
+
members: a
|
| 186 |
+
.map((r) => ({ ...member(r), label: r.label }))
|
| 187 |
+
.sort((a, b) => compare(a.id, b.id)),
|
| 188 |
+
}))
|
| 189 |
+
.sort((a, b) => compare(a.members[0].id, b.members[0].id));
|
| 190 |
+
return {
|
| 191 |
+
duplicate_id_records: rows.length - new Set(rows.map((r) => r.id)).size,
|
| 192 |
+
group_cross_split_sets: [...groups.values()].filter(crosses).length,
|
| 193 |
+
exact_text_cross_split_sets: [...texts.values()].filter(crosses).length,
|
| 194 |
+
normalized_candidates: candidates,
|
| 195 |
+
exact_text_label_conflicts: conflicts,
|
| 196 |
+
};
|
| 197 |
+
}
|
| 198 |
+
export function plan(input, percentages = [80, 10, 10], seed = 17) {
|
| 199 |
+
const rows = validate(input),
|
| 200 |
+
config = settings(percentages, seed),
|
| 201 |
+
units = makeUnits(rows);
|
| 202 |
+
if (units.length < 3)
|
| 203 |
+
throw Error(
|
| 204 |
+
"At least three allocation units are needed for three nonempty splits. Exact duplicates may link declared groups.",
|
| 205 |
+
);
|
| 206 |
+
units.sort(
|
| 207 |
+
(a, b) =>
|
| 208 |
+
b.rows.length - a.rows.length ||
|
| 209 |
+
priority(seed, a.key) - priority(seed, b.key) ||
|
| 210 |
+
compare(a.key, b.key),
|
| 211 |
+
);
|
| 212 |
+
const labelTotals = new Map();
|
| 213 |
+
for (const r of rows)
|
| 214 |
+
labelTotals.set(r.label, (labelTotals.get(r.label) || 0) + 1);
|
| 215 |
+
const labels = [...labelTotals.keys()].sort(compare);
|
| 216 |
+
const counts = new Map(labels.map((l) => [l, [0, 0, 0]])),
|
| 217 |
+
totals = [0, 0, 0],
|
| 218 |
+
unitCounts = [0, 0, 0],
|
| 219 |
+
chosen = new Map(),
|
| 220 |
+
trace = [];
|
| 221 |
+
const N = rows.length,
|
| 222 |
+
L = labels.length;
|
| 223 |
+
for (const [i, u] of units.entries()) {
|
| 224 |
+
const empty = [0, 1, 2].filter((s) => unitCounts[s] === 0),
|
| 225 |
+
forced = units.length - i === empty.length,
|
| 226 |
+
choices = forced ? empty : [0, 1, 2];
|
| 227 |
+
const options = choices.map((s) => {
|
| 228 |
+
const target = (N * percentages[s]) / 100;
|
| 229 |
+
let delta =
|
| 230 |
+
((totals[s] + u.rows.length - target) ** 2 -
|
| 231 |
+
(totals[s] - target) ** 2) /
|
| 232 |
+
(N * Math.max(1, target));
|
| 233 |
+
for (const [l, n] of u.counts) {
|
| 234 |
+
const total = labelTotals.get(l),
|
| 235 |
+
t = (total * percentages[s]) / 100,
|
| 236 |
+
old = counts.get(l)[s];
|
| 237 |
+
delta +=
|
| 238 |
+
((old + n - t) ** 2 - (old - t) ** 2) / (L * total * Math.max(1, t));
|
| 239 |
+
}
|
| 240 |
+
return { split: SPLITS[s], index: s, delta };
|
| 241 |
+
});
|
| 242 |
+
let best = options[0];
|
| 243 |
+
for (const o of options.slice(1)) if (o.delta < best.delta) best = o;
|
| 244 |
+
const s = best.index;
|
| 245 |
+
chosen.set(u.key, SPLITS[s]);
|
| 246 |
+
totals[s] += u.rows.length;
|
| 247 |
+
unitCounts[s]++;
|
| 248 |
+
for (const [l, n] of u.counts) counts.get(l)[s] += n;
|
| 249 |
+
trace.push({
|
| 250 |
+
unit: u.key,
|
| 251 |
+
records: u.rows.length,
|
| 252 |
+
chosen_split: SPLITS[s],
|
| 253 |
+
forced_nonempty: forced,
|
| 254 |
+
considered: options.map(({ split, delta }) => ({ split, delta })),
|
| 255 |
+
});
|
| 256 |
+
}
|
| 257 |
+
const groupUnit = new Map(
|
| 258 |
+
units.flatMap((u) => u.groups.map((g) => [g, u.key])),
|
| 259 |
+
),
|
| 260 |
+
assigned = rows.map((r) => ({
|
| 261 |
+
...r,
|
| 262 |
+
allocation_unit: groupUnit.get(r.group),
|
| 263 |
+
split: chosen.get(groupUnit.get(r.group)),
|
| 264 |
+
}));
|
| 265 |
+
const audit = finalAudit(assigned);
|
| 266 |
+
if (
|
| 267 |
+
audit.duplicate_id_records ||
|
| 268 |
+
audit.group_cross_split_sets ||
|
| 269 |
+
audit.exact_text_cross_split_sets
|
| 270 |
+
)
|
| 271 |
+
throw Error("Internal conservation audit failed.");
|
| 272 |
+
const report = {
|
| 273 |
+
tool_version: VERSION,
|
| 274 |
+
work_identity: "work:split-boundary-audit:v1",
|
| 275 |
+
configuration: {
|
| 276 |
+
...config,
|
| 277 |
+
split_order: SPLITS,
|
| 278 |
+
method:
|
| 279 |
+
"one-pass deterministic greedy; whole declared groups plus exact-text links",
|
| 280 |
+
target_scope:
|
| 281 |
+
"approximate row and per-label ratios; no optimality or independence guarantee",
|
| 282 |
+
},
|
| 283 |
+
scope:
|
| 284 |
+
"bounded declared-group/exact-text/normalized checks only; CLEAR does not establish absence of all contamination",
|
| 285 |
+
total_records: N,
|
| 286 |
+
declared_groups: groupUnit.size,
|
| 287 |
+
allocation_units: units.length,
|
| 288 |
+
merged_units: units.filter((u) => u.groups.length > 1).length,
|
| 289 |
+
status:
|
| 290 |
+
audit.normalized_candidates.length ||
|
| 291 |
+
audit.exact_text_label_conflicts.length
|
| 292 |
+
? "REVIEW"
|
| 293 |
+
: "CLEAR",
|
| 294 |
+
splits: SPLITS.map((split, s) => ({
|
| 295 |
+
split,
|
| 296 |
+
target_records: (N * percentages[s]) / 100,
|
| 297 |
+
actual_records: totals[s],
|
| 298 |
+
allocation_units: unitCounts[s],
|
| 299 |
+
actual_percent: (100 * totals[s]) / N,
|
| 300 |
+
deviation_percentage_points: (100 * totals[s]) / N - percentages[s],
|
| 301 |
+
})),
|
| 302 |
+
labels: labels.map((l) => ({
|
| 303 |
+
label: l,
|
| 304 |
+
total: labelTotals.get(l),
|
| 305 |
+
splits: SPLITS.map((split, s) => ({
|
| 306 |
+
split,
|
| 307 |
+
target_records: (labelTotals.get(l) * percentages[s]) / 100,
|
| 308 |
+
actual_records: counts.get(l)[s],
|
| 309 |
+
})),
|
| 310 |
+
})),
|
| 311 |
+
objective: objective(totals, counts, labelTotals, percentages),
|
| 312 |
+
units: units.map((u) => ({
|
| 313 |
+
unit: u.key,
|
| 314 |
+
declared_groups: u.groups,
|
| 315 |
+
records: u.rows.length,
|
| 316 |
+
split: chosen.get(u.key),
|
| 317 |
+
})),
|
| 318 |
+
assignments: assigned.map(
|
| 319 |
+
({ id, group, label, allocation_unit, split }) => ({
|
| 320 |
+
id,
|
| 321 |
+
group,
|
| 322 |
+
label,
|
| 323 |
+
allocation_unit,
|
| 324 |
+
split,
|
| 325 |
+
}),
|
| 326 |
+
),
|
| 327 |
+
audit,
|
| 328 |
+
allocation_trace: trace,
|
| 329 |
+
};
|
| 330 |
+
return {
|
| 331 |
+
report,
|
| 332 |
+
assigned_jsonl:
|
| 333 |
+
assigned
|
| 334 |
+
.map(({ id, group, text, split }) =>
|
| 335 |
+
JSON.stringify({ id, split, group, text }),
|
| 336 |
+
)
|
| 337 |
+
.join("\n") + "\n",
|
| 338 |
+
};
|
| 339 |
+
}
|
reference-results.json
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"status": "PASS",
|
| 3 |
+
"cases": 100,
|
| 4 |
+
"considered_deltas_checked": 1244,
|
| 5 |
+
"nonoptimal_greedy_cases": 30,
|
| 6 |
+
"counterexample": {
|
| 7 |
+
"case": {
|
| 8 |
+
"rows": [
|
| 9 |
+
{
|
| 10 |
+
"id": "0-0",
|
| 11 |
+
"group": "g0",
|
| 12 |
+
"label": "B",
|
| 13 |
+
"text": "unique 0 0"
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"id": "0-1",
|
| 17 |
+
"group": "g0",
|
| 18 |
+
"label": "B",
|
| 19 |
+
"text": "unique 0 1"
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"id": "0-2",
|
| 23 |
+
"group": "g0",
|
| 24 |
+
"label": "B",
|
| 25 |
+
"text": "unique 0 2"
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"id": "0-3",
|
| 29 |
+
"group": "g0",
|
| 30 |
+
"label": "A",
|
| 31 |
+
"text": "unique 0 3"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"id": "1-0",
|
| 35 |
+
"group": "g1",
|
| 36 |
+
"label": "B",
|
| 37 |
+
"text": "unique 1 0"
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"id": "2-0",
|
| 41 |
+
"group": "g2",
|
| 42 |
+
"label": "A",
|
| 43 |
+
"text": "unique 2 0"
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"id": "2-1",
|
| 47 |
+
"group": "g2",
|
| 48 |
+
"label": "B",
|
| 49 |
+
"text": "unique 2 1"
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"id": "2-2",
|
| 53 |
+
"group": "g2",
|
| 54 |
+
"label": "A",
|
| 55 |
+
"text": "unique 2 2"
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"id": "2-3",
|
| 59 |
+
"group": "g2",
|
| 60 |
+
"label": "A",
|
| 61 |
+
"text": "unique 2 3"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"id": "3-0",
|
| 65 |
+
"group": "g3",
|
| 66 |
+
"label": "B",
|
| 67 |
+
"text": "unique 3 0"
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"id": "3-1",
|
| 71 |
+
"group": "g3",
|
| 72 |
+
"label": "B",
|
| 73 |
+
"text": "unique 3 1"
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"id": "3-2",
|
| 77 |
+
"group": "g3",
|
| 78 |
+
"label": "B",
|
| 79 |
+
"text": "unique 3 2"
|
| 80 |
+
},
|
| 81 |
+
{
|
| 82 |
+
"id": "3-3",
|
| 83 |
+
"group": "g3",
|
| 84 |
+
"label": "A",
|
| 85 |
+
"text": "unique 3 3"
|
| 86 |
+
}
|
| 87 |
+
],
|
| 88 |
+
"percentages": [
|
| 89 |
+
34,
|
| 90 |
+
33,
|
| 91 |
+
33
|
| 92 |
+
],
|
| 93 |
+
"seed": 71
|
| 94 |
+
},
|
| 95 |
+
"greedy_assignment": {
|
| 96 |
+
"g0": 0,
|
| 97 |
+
"g1": 1,
|
| 98 |
+
"g2": 1,
|
| 99 |
+
"g3": 2
|
| 100 |
+
},
|
| 101 |
+
"greedy_objective": 0.19306760829668068,
|
| 102 |
+
"optimal_assignment": {
|
| 103 |
+
"g0": 1,
|
| 104 |
+
"g1": 0,
|
| 105 |
+
"g2": 0,
|
| 106 |
+
"g3": 2
|
| 107 |
+
},
|
| 108 |
+
"optimal_objective": 0.1775424801442901
|
| 109 |
+
},
|
| 110 |
+
"scope": "exhaustive optimality only for these 3\u20136 group synthetic cases; greedy not globally optimal"
|
| 111 |
+
}
|
run_plan.mjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Local CLI adapter for the same browser planning module. */
|
| 2 |
+
import fs from "node:fs";
|
| 3 |
+
import path from "node:path";
|
| 4 |
+
import crypto from "node:crypto";
|
| 5 |
+
import { parseArgs } from "node:util";
|
| 6 |
+
import { parseJSONL, plan } from "./planner.mjs";
|
| 7 |
+
try {
|
| 8 |
+
const { values, positionals } = parseArgs({
|
| 9 |
+
options: {
|
| 10 |
+
percentages: { type: "string", default: "80,10,10" },
|
| 11 |
+
seed: { type: "string", default: "17" },
|
| 12 |
+
output: { type: "string" },
|
| 13 |
+
},
|
| 14 |
+
allowPositionals: true,
|
| 15 |
+
strict: true,
|
| 16 |
+
});
|
| 17 |
+
if (positionals.length !== 1 || !values.output || !values.seed.trim())
|
| 18 |
+
throw Error(
|
| 19 |
+
"Usage: node run_plan.mjs input.jsonl --output NEW_DIRECTORY [--percentages 80,10,10] [--seed 17]",
|
| 20 |
+
);
|
| 21 |
+
const input = path.resolve(positionals[0]),
|
| 22 |
+
out = path.resolve(values.output);
|
| 23 |
+
if (fs.existsSync(out)) throw Error("Output directory already exists.");
|
| 24 |
+
if (fs.statSync(input).size > 2097152)
|
| 25 |
+
throw Error("Input exceeds 2 MiB UTF-8.");
|
| 26 |
+
const bytes = fs.readFileSync(input),
|
| 27 |
+
raw = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(
|
| 28 |
+
bytes,
|
| 29 |
+
),
|
| 30 |
+
parsed = parseJSONL(raw),
|
| 31 |
+
result = plan(
|
| 32 |
+
parsed.rows,
|
| 33 |
+
values.percentages.split(",").map(Number),
|
| 34 |
+
Number(values.seed),
|
| 35 |
+
);
|
| 36 |
+
result.report.input_sha256 = crypto
|
| 37 |
+
.createHash("sha256")
|
| 38 |
+
.update(bytes)
|
| 39 |
+
.digest("hex");
|
| 40 |
+
result.report.input_digest_scope = "exact UTF-8 input JSONL file bytes";
|
| 41 |
+
result.report.blank_lines_ignored = parsed.blank_lines_ignored;
|
| 42 |
+
fs.mkdirSync(out);
|
| 43 |
+
fs.writeFileSync(
|
| 44 |
+
path.join(out, "report.json"),
|
| 45 |
+
JSON.stringify(result.report, null, 2) + "\n",
|
| 46 |
+
{ flag: "wx" },
|
| 47 |
+
);
|
| 48 |
+
fs.writeFileSync(
|
| 49 |
+
path.join(out, "assigned-records.jsonl"),
|
| 50 |
+
result.assigned_jsonl,
|
| 51 |
+
{ flag: "wx" },
|
| 52 |
+
);
|
| 53 |
+
console.log(
|
| 54 |
+
`${result.report.status}: ${result.report.total_records} records retained, ${result.report.allocation_units} allocation units. Reports written to the new directory.`,
|
| 55 |
+
);
|
| 56 |
+
} catch (e) {
|
| 57 |
+
console.error("Plan failed: " + e.message);
|
| 58 |
+
process.exitCode = 2;
|
| 59 |
+
}
|
sample-assigned.jsonl
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"id":"bug-0-0","split":"train","group":"family-bug-0","text":"Exact duplicate: sample payload."}
|
| 2 |
+
{"id":"bug-0-1","split":"train","group":"family-bug-0","text":"Synthetic bug template family 0, sibling 1. 合成样例。"}
|
| 3 |
+
{"id":"bug-0-2","split":"train","group":"family-bug-0","text":"Synthetic bug template family 0, sibling 2. 合成样例。"}
|
| 4 |
+
{"id":"bug-1-0","split":"train","group":"family-bug-1","text":"Synthetic bug template family 1, sibling 0. 合成样例。"}
|
| 5 |
+
{"id":"bug-1-1","split":"train","group":"family-bug-1","text":"Exact duplicate: sample payload."}
|
| 6 |
+
{"id":"bug-1-2","split":"train","group":"family-bug-1","text":"Synthetic bug template family 1, sibling 2. 合成样例。"}
|
| 7 |
+
{"id":"bug-2-0","split":"train","group":"family-bug-2","text":"Synthetic bug template family 2, sibling 0. 合成样例。"}
|
| 8 |
+
{"id":"bug-2-1","split":"train","group":"family-bug-2","text":"Synthetic bug template family 2, sibling 1. 合成样例。"}
|
| 9 |
+
{"id":"bug-2-2","split":"train","group":"family-bug-2","text":"Synthetic bug template family 2, sibling 2. 合成样例。"}
|
| 10 |
+
{"id":"bug-3-0","split":"train","group":"family-bug-3","text":"Synthetic bug template family 3, sibling 0. 合成样例。"}
|
| 11 |
+
{"id":"bug-3-1","split":"train","group":"family-bug-3","text":"Synthetic bug template family 3, sibling 1. 合成样例。"}
|
| 12 |
+
{"id":"bug-3-2","split":"train","group":"family-bug-3","text":"Synthetic bug template family 3, sibling 2. 合成样例。"}
|
| 13 |
+
{"id":"example-0-0","split":"train","group":"family-example-0","text":"Cross-label duplicate: same input."}
|
| 14 |
+
{"id":"example-0-1","split":"train","group":"family-example-0","text":"Synthetic example template family 0, sibling 1. 合成样例。"}
|
| 15 |
+
{"id":"example-0-2","split":"train","group":"family-example-0","text":"Synthetic example template family 0, sibling 2. 合成样例。"}
|
| 16 |
+
{"id":"example-1-0","split":"validation","group":"family-example-1","text":"Café note"}
|
| 17 |
+
{"id":"example-1-1","split":"validation","group":"family-example-1","text":"Synthetic example template family 1, sibling 1. 合成样例。"}
|
| 18 |
+
{"id":"example-1-2","split":"validation","group":"family-example-1","text":"Synthetic example template family 1, sibling 2. 合成样例。"}
|
| 19 |
+
{"id":"example-2-0","split":"train","group":"family-example-2","text":"Synthetic example template family 2, sibling 0. 合成样例。"}
|
| 20 |
+
{"id":"example-2-1","split":"train","group":"family-example-2","text":"Synthetic example template family 2, sibling 1. 合成样例。"}
|
| 21 |
+
{"id":"example-2-2","split":"train","group":"family-example-2","text":"Synthetic example template family 2, sibling 2. 合成样例。"}
|
| 22 |
+
{"id":"example-3-0","split":"train","group":"family-example-3","text":"Synthetic example template family 3, sibling 0. 合成样例。"}
|
| 23 |
+
{"id":"example-3-1","split":"train","group":"family-example-3","text":"Synthetic example template family 3, sibling 1. 合成样例。"}
|
| 24 |
+
{"id":"example-3-2","split":"train","group":"family-example-3","text":"Synthetic example template family 3, sibling 2. 合成样例。"}
|
| 25 |
+
{"id":"question-0-0","split":"train","group":"family-question-0","text":"Cross-label duplicate: same input."}
|
| 26 |
+
{"id":"question-0-1","split":"train","group":"family-question-0","text":"Synthetic question template family 0, sibling 1. 合成样例。"}
|
| 27 |
+
{"id":"question-0-2","split":"train","group":"family-question-0","text":"Synthetic question template family 0, sibling 2. 合成样例。"}
|
| 28 |
+
{"id":"question-1-0","split":"train","group":"family-question-1","text":"Café note"}
|
| 29 |
+
{"id":"question-1-1","split":"train","group":"family-question-1","text":"Synthetic question template family 1, sibling 1. 合成样例。"}
|
| 30 |
+
{"id":"question-1-2","split":"train","group":"family-question-1","text":"Synthetic question template family 1, sibling 2. 合成样例。"}
|
| 31 |
+
{"id":"question-2-0","split":"test","group":"family-question-2","text":"Synthetic question template family 2, sibling 0. 合成样例。"}
|
| 32 |
+
{"id":"question-2-1","split":"test","group":"family-question-2","text":"Synthetic question template family 2, sibling 1. 合成样例。"}
|
| 33 |
+
{"id":"question-2-2","split":"test","group":"family-question-2","text":"Synthetic question template family 2, sibling 2. 合成样例。"}
|
| 34 |
+
{"id":"question-3-0","split":"train","group":"family-question-3","text":"Synthetic question template family 3, sibling 0. 合成样例。"}
|
| 35 |
+
{"id":"question-3-1","split":"train","group":"family-question-3","text":"Synthetic question template family 3, sibling 1. 合成样例。"}
|
| 36 |
+
{"id":"question-3-2","split":"train","group":"family-question-3","text":"Synthetic question template family 3, sibling 2. 合成样例。"}
|
sample-plan.json
ADDED
|
@@ -0,0 +1,698 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"tool_version": "0.2.0",
|
| 3 |
+
"work_identity": "work:split-boundary-audit:v1",
|
| 4 |
+
"configuration": {
|
| 5 |
+
"percentages": [
|
| 6 |
+
80,
|
| 7 |
+
10,
|
| 8 |
+
10
|
| 9 |
+
],
|
| 10 |
+
"seed": 17,
|
| 11 |
+
"split_order": [
|
| 12 |
+
"train",
|
| 13 |
+
"validation",
|
| 14 |
+
"test"
|
| 15 |
+
],
|
| 16 |
+
"method": "one-pass deterministic greedy; whole declared groups plus exact-text links",
|
| 17 |
+
"target_scope": "approximate row and per-label ratios; no optimality or independence guarantee"
|
| 18 |
+
},
|
| 19 |
+
"scope": "bounded declared-group/exact-text/normalized checks only; CLEAR does not establish absence of all contamination",
|
| 20 |
+
"total_records": 36,
|
| 21 |
+
"declared_groups": 12,
|
| 22 |
+
"allocation_units": 10,
|
| 23 |
+
"merged_units": 2,
|
| 24 |
+
"status": "REVIEW",
|
| 25 |
+
"splits": [
|
| 26 |
+
{
|
| 27 |
+
"split": "train",
|
| 28 |
+
"target_records": 28.8,
|
| 29 |
+
"actual_records": 30,
|
| 30 |
+
"allocation_units": 8,
|
| 31 |
+
"actual_percent": 83.33333333333333,
|
| 32 |
+
"deviation_percentage_points": 3.3333333333333286
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"split": "validation",
|
| 36 |
+
"target_records": 3.6,
|
| 37 |
+
"actual_records": 3,
|
| 38 |
+
"allocation_units": 1,
|
| 39 |
+
"actual_percent": 8.333333333333334,
|
| 40 |
+
"deviation_percentage_points": -1.666666666666666
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"split": "test",
|
| 44 |
+
"target_records": 3.6,
|
| 45 |
+
"actual_records": 3,
|
| 46 |
+
"allocation_units": 1,
|
| 47 |
+
"actual_percent": 8.333333333333334,
|
| 48 |
+
"deviation_percentage_points": -1.666666666666666
|
| 49 |
+
}
|
| 50 |
+
],
|
| 51 |
+
"labels": [
|
| 52 |
+
{
|
| 53 |
+
"label": "bug",
|
| 54 |
+
"total": 12,
|
| 55 |
+
"splits": [
|
| 56 |
+
{
|
| 57 |
+
"split": "train",
|
| 58 |
+
"target_records": 9.6,
|
| 59 |
+
"actual_records": 12
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"split": "validation",
|
| 63 |
+
"target_records": 1.2,
|
| 64 |
+
"actual_records": 0
|
| 65 |
+
},
|
| 66 |
+
{
|
| 67 |
+
"split": "test",
|
| 68 |
+
"target_records": 1.2,
|
| 69 |
+
"actual_records": 0
|
| 70 |
+
}
|
| 71 |
+
]
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"label": "example",
|
| 75 |
+
"total": 12,
|
| 76 |
+
"splits": [
|
| 77 |
+
{
|
| 78 |
+
"split": "train",
|
| 79 |
+
"target_records": 9.6,
|
| 80 |
+
"actual_records": 9
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"split": "validation",
|
| 84 |
+
"target_records": 1.2,
|
| 85 |
+
"actual_records": 3
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"split": "test",
|
| 89 |
+
"target_records": 1.2,
|
| 90 |
+
"actual_records": 0
|
| 91 |
+
}
|
| 92 |
+
]
|
| 93 |
+
},
|
| 94 |
+
{
|
| 95 |
+
"label": "question",
|
| 96 |
+
"total": 12,
|
| 97 |
+
"splits": [
|
| 98 |
+
{
|
| 99 |
+
"split": "train",
|
| 100 |
+
"target_records": 9.6,
|
| 101 |
+
"actual_records": 9
|
| 102 |
+
},
|
| 103 |
+
{
|
| 104 |
+
"split": "validation",
|
| 105 |
+
"target_records": 1.2,
|
| 106 |
+
"actual_records": 0
|
| 107 |
+
},
|
| 108 |
+
{
|
| 109 |
+
"split": "test",
|
| 110 |
+
"target_records": 1.2,
|
| 111 |
+
"actual_records": 3
|
| 112 |
+
}
|
| 113 |
+
]
|
| 114 |
+
}
|
| 115 |
+
],
|
| 116 |
+
"objective": 0.3090277777777778,
|
| 117 |
+
"units": [
|
| 118 |
+
{
|
| 119 |
+
"unit": "family-example-0",
|
| 120 |
+
"declared_groups": [
|
| 121 |
+
"family-example-0",
|
| 122 |
+
"family-question-0"
|
| 123 |
+
],
|
| 124 |
+
"records": 6,
|
| 125 |
+
"split": "train"
|
| 126 |
+
},
|
| 127 |
+
{
|
| 128 |
+
"unit": "family-bug-0",
|
| 129 |
+
"declared_groups": [
|
| 130 |
+
"family-bug-0",
|
| 131 |
+
"family-bug-1"
|
| 132 |
+
],
|
| 133 |
+
"records": 6,
|
| 134 |
+
"split": "train"
|
| 135 |
+
},
|
| 136 |
+
{
|
| 137 |
+
"unit": "family-example-3",
|
| 138 |
+
"declared_groups": [
|
| 139 |
+
"family-example-3"
|
| 140 |
+
],
|
| 141 |
+
"records": 3,
|
| 142 |
+
"split": "train"
|
| 143 |
+
},
|
| 144 |
+
{
|
| 145 |
+
"unit": "family-example-2",
|
| 146 |
+
"declared_groups": [
|
| 147 |
+
"family-example-2"
|
| 148 |
+
],
|
| 149 |
+
"records": 3,
|
| 150 |
+
"split": "train"
|
| 151 |
+
},
|
| 152 |
+
{
|
| 153 |
+
"unit": "family-example-1",
|
| 154 |
+
"declared_groups": [
|
| 155 |
+
"family-example-1"
|
| 156 |
+
],
|
| 157 |
+
"records": 3,
|
| 158 |
+
"split": "validation"
|
| 159 |
+
},
|
| 160 |
+
{
|
| 161 |
+
"unit": "family-question-1",
|
| 162 |
+
"declared_groups": [
|
| 163 |
+
"family-question-1"
|
| 164 |
+
],
|
| 165 |
+
"records": 3,
|
| 166 |
+
"split": "train"
|
| 167 |
+
},
|
| 168 |
+
{
|
| 169 |
+
"unit": "family-question-3",
|
| 170 |
+
"declared_groups": [
|
| 171 |
+
"family-question-3"
|
| 172 |
+
],
|
| 173 |
+
"records": 3,
|
| 174 |
+
"split": "train"
|
| 175 |
+
},
|
| 176 |
+
{
|
| 177 |
+
"unit": "family-question-2",
|
| 178 |
+
"declared_groups": [
|
| 179 |
+
"family-question-2"
|
| 180 |
+
],
|
| 181 |
+
"records": 3,
|
| 182 |
+
"split": "test"
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"unit": "family-bug-3",
|
| 186 |
+
"declared_groups": [
|
| 187 |
+
"family-bug-3"
|
| 188 |
+
],
|
| 189 |
+
"records": 3,
|
| 190 |
+
"split": "train"
|
| 191 |
+
},
|
| 192 |
+
{
|
| 193 |
+
"unit": "family-bug-2",
|
| 194 |
+
"declared_groups": [
|
| 195 |
+
"family-bug-2"
|
| 196 |
+
],
|
| 197 |
+
"records": 3,
|
| 198 |
+
"split": "train"
|
| 199 |
+
}
|
| 200 |
+
],
|
| 201 |
+
"assignments": [
|
| 202 |
+
{
|
| 203 |
+
"id": "bug-0-0",
|
| 204 |
+
"group": "family-bug-0",
|
| 205 |
+
"label": "bug",
|
| 206 |
+
"allocation_unit": "family-bug-0",
|
| 207 |
+
"split": "train"
|
| 208 |
+
},
|
| 209 |
+
{
|
| 210 |
+
"id": "bug-0-1",
|
| 211 |
+
"group": "family-bug-0",
|
| 212 |
+
"label": "bug",
|
| 213 |
+
"allocation_unit": "family-bug-0",
|
| 214 |
+
"split": "train"
|
| 215 |
+
},
|
| 216 |
+
{
|
| 217 |
+
"id": "bug-0-2",
|
| 218 |
+
"group": "family-bug-0",
|
| 219 |
+
"label": "bug",
|
| 220 |
+
"allocation_unit": "family-bug-0",
|
| 221 |
+
"split": "train"
|
| 222 |
+
},
|
| 223 |
+
{
|
| 224 |
+
"id": "bug-1-0",
|
| 225 |
+
"group": "family-bug-1",
|
| 226 |
+
"label": "bug",
|
| 227 |
+
"allocation_unit": "family-bug-0",
|
| 228 |
+
"split": "train"
|
| 229 |
+
},
|
| 230 |
+
{
|
| 231 |
+
"id": "bug-1-1",
|
| 232 |
+
"group": "family-bug-1",
|
| 233 |
+
"label": "bug",
|
| 234 |
+
"allocation_unit": "family-bug-0",
|
| 235 |
+
"split": "train"
|
| 236 |
+
},
|
| 237 |
+
{
|
| 238 |
+
"id": "bug-1-2",
|
| 239 |
+
"group": "family-bug-1",
|
| 240 |
+
"label": "bug",
|
| 241 |
+
"allocation_unit": "family-bug-0",
|
| 242 |
+
"split": "train"
|
| 243 |
+
},
|
| 244 |
+
{
|
| 245 |
+
"id": "bug-2-0",
|
| 246 |
+
"group": "family-bug-2",
|
| 247 |
+
"label": "bug",
|
| 248 |
+
"allocation_unit": "family-bug-2",
|
| 249 |
+
"split": "train"
|
| 250 |
+
},
|
| 251 |
+
{
|
| 252 |
+
"id": "bug-2-1",
|
| 253 |
+
"group": "family-bug-2",
|
| 254 |
+
"label": "bug",
|
| 255 |
+
"allocation_unit": "family-bug-2",
|
| 256 |
+
"split": "train"
|
| 257 |
+
},
|
| 258 |
+
{
|
| 259 |
+
"id": "bug-2-2",
|
| 260 |
+
"group": "family-bug-2",
|
| 261 |
+
"label": "bug",
|
| 262 |
+
"allocation_unit": "family-bug-2",
|
| 263 |
+
"split": "train"
|
| 264 |
+
},
|
| 265 |
+
{
|
| 266 |
+
"id": "bug-3-0",
|
| 267 |
+
"group": "family-bug-3",
|
| 268 |
+
"label": "bug",
|
| 269 |
+
"allocation_unit": "family-bug-3",
|
| 270 |
+
"split": "train"
|
| 271 |
+
},
|
| 272 |
+
{
|
| 273 |
+
"id": "bug-3-1",
|
| 274 |
+
"group": "family-bug-3",
|
| 275 |
+
"label": "bug",
|
| 276 |
+
"allocation_unit": "family-bug-3",
|
| 277 |
+
"split": "train"
|
| 278 |
+
},
|
| 279 |
+
{
|
| 280 |
+
"id": "bug-3-2",
|
| 281 |
+
"group": "family-bug-3",
|
| 282 |
+
"label": "bug",
|
| 283 |
+
"allocation_unit": "family-bug-3",
|
| 284 |
+
"split": "train"
|
| 285 |
+
},
|
| 286 |
+
{
|
| 287 |
+
"id": "example-0-0",
|
| 288 |
+
"group": "family-example-0",
|
| 289 |
+
"label": "example",
|
| 290 |
+
"allocation_unit": "family-example-0",
|
| 291 |
+
"split": "train"
|
| 292 |
+
},
|
| 293 |
+
{
|
| 294 |
+
"id": "example-0-1",
|
| 295 |
+
"group": "family-example-0",
|
| 296 |
+
"label": "example",
|
| 297 |
+
"allocation_unit": "family-example-0",
|
| 298 |
+
"split": "train"
|
| 299 |
+
},
|
| 300 |
+
{
|
| 301 |
+
"id": "example-0-2",
|
| 302 |
+
"group": "family-example-0",
|
| 303 |
+
"label": "example",
|
| 304 |
+
"allocation_unit": "family-example-0",
|
| 305 |
+
"split": "train"
|
| 306 |
+
},
|
| 307 |
+
{
|
| 308 |
+
"id": "example-1-0",
|
| 309 |
+
"group": "family-example-1",
|
| 310 |
+
"label": "example",
|
| 311 |
+
"allocation_unit": "family-example-1",
|
| 312 |
+
"split": "validation"
|
| 313 |
+
},
|
| 314 |
+
{
|
| 315 |
+
"id": "example-1-1",
|
| 316 |
+
"group": "family-example-1",
|
| 317 |
+
"label": "example",
|
| 318 |
+
"allocation_unit": "family-example-1",
|
| 319 |
+
"split": "validation"
|
| 320 |
+
},
|
| 321 |
+
{
|
| 322 |
+
"id": "example-1-2",
|
| 323 |
+
"group": "family-example-1",
|
| 324 |
+
"label": "example",
|
| 325 |
+
"allocation_unit": "family-example-1",
|
| 326 |
+
"split": "validation"
|
| 327 |
+
},
|
| 328 |
+
{
|
| 329 |
+
"id": "example-2-0",
|
| 330 |
+
"group": "family-example-2",
|
| 331 |
+
"label": "example",
|
| 332 |
+
"allocation_unit": "family-example-2",
|
| 333 |
+
"split": "train"
|
| 334 |
+
},
|
| 335 |
+
{
|
| 336 |
+
"id": "example-2-1",
|
| 337 |
+
"group": "family-example-2",
|
| 338 |
+
"label": "example",
|
| 339 |
+
"allocation_unit": "family-example-2",
|
| 340 |
+
"split": "train"
|
| 341 |
+
},
|
| 342 |
+
{
|
| 343 |
+
"id": "example-2-2",
|
| 344 |
+
"group": "family-example-2",
|
| 345 |
+
"label": "example",
|
| 346 |
+
"allocation_unit": "family-example-2",
|
| 347 |
+
"split": "train"
|
| 348 |
+
},
|
| 349 |
+
{
|
| 350 |
+
"id": "example-3-0",
|
| 351 |
+
"group": "family-example-3",
|
| 352 |
+
"label": "example",
|
| 353 |
+
"allocation_unit": "family-example-3",
|
| 354 |
+
"split": "train"
|
| 355 |
+
},
|
| 356 |
+
{
|
| 357 |
+
"id": "example-3-1",
|
| 358 |
+
"group": "family-example-3",
|
| 359 |
+
"label": "example",
|
| 360 |
+
"allocation_unit": "family-example-3",
|
| 361 |
+
"split": "train"
|
| 362 |
+
},
|
| 363 |
+
{
|
| 364 |
+
"id": "example-3-2",
|
| 365 |
+
"group": "family-example-3",
|
| 366 |
+
"label": "example",
|
| 367 |
+
"allocation_unit": "family-example-3",
|
| 368 |
+
"split": "train"
|
| 369 |
+
},
|
| 370 |
+
{
|
| 371 |
+
"id": "question-0-0",
|
| 372 |
+
"group": "family-question-0",
|
| 373 |
+
"label": "question",
|
| 374 |
+
"allocation_unit": "family-example-0",
|
| 375 |
+
"split": "train"
|
| 376 |
+
},
|
| 377 |
+
{
|
| 378 |
+
"id": "question-0-1",
|
| 379 |
+
"group": "family-question-0",
|
| 380 |
+
"label": "question",
|
| 381 |
+
"allocation_unit": "family-example-0",
|
| 382 |
+
"split": "train"
|
| 383 |
+
},
|
| 384 |
+
{
|
| 385 |
+
"id": "question-0-2",
|
| 386 |
+
"group": "family-question-0",
|
| 387 |
+
"label": "question",
|
| 388 |
+
"allocation_unit": "family-example-0",
|
| 389 |
+
"split": "train"
|
| 390 |
+
},
|
| 391 |
+
{
|
| 392 |
+
"id": "question-1-0",
|
| 393 |
+
"group": "family-question-1",
|
| 394 |
+
"label": "question",
|
| 395 |
+
"allocation_unit": "family-question-1",
|
| 396 |
+
"split": "train"
|
| 397 |
+
},
|
| 398 |
+
{
|
| 399 |
+
"id": "question-1-1",
|
| 400 |
+
"group": "family-question-1",
|
| 401 |
+
"label": "question",
|
| 402 |
+
"allocation_unit": "family-question-1",
|
| 403 |
+
"split": "train"
|
| 404 |
+
},
|
| 405 |
+
{
|
| 406 |
+
"id": "question-1-2",
|
| 407 |
+
"group": "family-question-1",
|
| 408 |
+
"label": "question",
|
| 409 |
+
"allocation_unit": "family-question-1",
|
| 410 |
+
"split": "train"
|
| 411 |
+
},
|
| 412 |
+
{
|
| 413 |
+
"id": "question-2-0",
|
| 414 |
+
"group": "family-question-2",
|
| 415 |
+
"label": "question",
|
| 416 |
+
"allocation_unit": "family-question-2",
|
| 417 |
+
"split": "test"
|
| 418 |
+
},
|
| 419 |
+
{
|
| 420 |
+
"id": "question-2-1",
|
| 421 |
+
"group": "family-question-2",
|
| 422 |
+
"label": "question",
|
| 423 |
+
"allocation_unit": "family-question-2",
|
| 424 |
+
"split": "test"
|
| 425 |
+
},
|
| 426 |
+
{
|
| 427 |
+
"id": "question-2-2",
|
| 428 |
+
"group": "family-question-2",
|
| 429 |
+
"label": "question",
|
| 430 |
+
"allocation_unit": "family-question-2",
|
| 431 |
+
"split": "test"
|
| 432 |
+
},
|
| 433 |
+
{
|
| 434 |
+
"id": "question-3-0",
|
| 435 |
+
"group": "family-question-3",
|
| 436 |
+
"label": "question",
|
| 437 |
+
"allocation_unit": "family-question-3",
|
| 438 |
+
"split": "train"
|
| 439 |
+
},
|
| 440 |
+
{
|
| 441 |
+
"id": "question-3-1",
|
| 442 |
+
"group": "family-question-3",
|
| 443 |
+
"label": "question",
|
| 444 |
+
"allocation_unit": "family-question-3",
|
| 445 |
+
"split": "train"
|
| 446 |
+
},
|
| 447 |
+
{
|
| 448 |
+
"id": "question-3-2",
|
| 449 |
+
"group": "family-question-3",
|
| 450 |
+
"label": "question",
|
| 451 |
+
"allocation_unit": "family-question-3",
|
| 452 |
+
"split": "train"
|
| 453 |
+
}
|
| 454 |
+
],
|
| 455 |
+
"audit": {
|
| 456 |
+
"duplicate_id_records": 0,
|
| 457 |
+
"group_cross_split_sets": 0,
|
| 458 |
+
"exact_text_cross_split_sets": 0,
|
| 459 |
+
"normalized_candidates": [
|
| 460 |
+
{
|
| 461 |
+
"kind": "normalized_candidate",
|
| 462 |
+
"members": [
|
| 463 |
+
{
|
| 464 |
+
"id": "example-1-0",
|
| 465 |
+
"group": "family-example-1",
|
| 466 |
+
"split": "validation"
|
| 467 |
+
},
|
| 468 |
+
{
|
| 469 |
+
"id": "question-1-0",
|
| 470 |
+
"group": "family-question-1",
|
| 471 |
+
"split": "train"
|
| 472 |
+
}
|
| 473 |
+
]
|
| 474 |
+
}
|
| 475 |
+
],
|
| 476 |
+
"exact_text_label_conflicts": [
|
| 477 |
+
{
|
| 478 |
+
"kind": "exact_text_label_conflict",
|
| 479 |
+
"members": [
|
| 480 |
+
{
|
| 481 |
+
"id": "example-0-0",
|
| 482 |
+
"group": "family-example-0",
|
| 483 |
+
"split": "train",
|
| 484 |
+
"label": "example"
|
| 485 |
+
},
|
| 486 |
+
{
|
| 487 |
+
"id": "question-0-0",
|
| 488 |
+
"group": "family-question-0",
|
| 489 |
+
"split": "train",
|
| 490 |
+
"label": "question"
|
| 491 |
+
}
|
| 492 |
+
]
|
| 493 |
+
}
|
| 494 |
+
]
|
| 495 |
+
},
|
| 496 |
+
"allocation_trace": [
|
| 497 |
+
{
|
| 498 |
+
"unit": "family-example-0",
|
| 499 |
+
"records": 6,
|
| 500 |
+
"chosen_split": "train",
|
| 501 |
+
"forced_nonempty": false,
|
| 502 |
+
"considered": [
|
| 503 |
+
{
|
| 504 |
+
"split": "train",
|
| 505 |
+
"delta": -0.5798611111111112
|
| 506 |
+
},
|
| 507 |
+
{
|
| 508 |
+
"split": "validation",
|
| 509 |
+
"delta": 0.02777777777777779
|
| 510 |
+
},
|
| 511 |
+
{
|
| 512 |
+
"split": "test",
|
| 513 |
+
"delta": 0.02777777777777779
|
| 514 |
+
}
|
| 515 |
+
]
|
| 516 |
+
},
|
| 517 |
+
{
|
| 518 |
+
"unit": "family-bug-0",
|
| 519 |
+
"records": 6,
|
| 520 |
+
"chosen_split": "train",
|
| 521 |
+
"forced_nonempty": false,
|
| 522 |
+
"considered": [
|
| 523 |
+
{
|
| 524 |
+
"split": "train",
|
| 525 |
+
"delta": -0.45833333333333337
|
| 526 |
+
},
|
| 527 |
+
{
|
| 528 |
+
"split": "validation",
|
| 529 |
+
"delta": 0.4444444444444444
|
| 530 |
+
},
|
| 531 |
+
{
|
| 532 |
+
"split": "test",
|
| 533 |
+
"delta": 0.4444444444444444
|
| 534 |
+
}
|
| 535 |
+
]
|
| 536 |
+
},
|
| 537 |
+
{
|
| 538 |
+
"unit": "family-example-3",
|
| 539 |
+
"records": 3,
|
| 540 |
+
"chosen_split": "train",
|
| 541 |
+
"forced_nonempty": false,
|
| 542 |
+
"considered": [
|
| 543 |
+
{
|
| 544 |
+
"split": "train",
|
| 545 |
+
"delta": -0.17708333333333331
|
| 546 |
+
},
|
| 547 |
+
{
|
| 548 |
+
"split": "validation",
|
| 549 |
+
"delta": -0.05555555555555556
|
| 550 |
+
},
|
| 551 |
+
{
|
| 552 |
+
"split": "test",
|
| 553 |
+
"delta": -0.05555555555555556
|
| 554 |
+
}
|
| 555 |
+
]
|
| 556 |
+
},
|
| 557 |
+
{
|
| 558 |
+
"unit": "family-example-2",
|
| 559 |
+
"records": 3,
|
| 560 |
+
"chosen_split": "train",
|
| 561 |
+
"forced_nonempty": false,
|
| 562 |
+
"considered": [
|
| 563 |
+
{
|
| 564 |
+
"split": "train",
|
| 565 |
+
"delta": -0.1076388888888889
|
| 566 |
+
},
|
| 567 |
+
{
|
| 568 |
+
"split": "validation",
|
| 569 |
+
"delta": -0.05555555555555556
|
| 570 |
+
},
|
| 571 |
+
{
|
| 572 |
+
"split": "test",
|
| 573 |
+
"delta": -0.05555555555555556
|
| 574 |
+
}
|
| 575 |
+
]
|
| 576 |
+
},
|
| 577 |
+
{
|
| 578 |
+
"unit": "family-example-1",
|
| 579 |
+
"records": 3,
|
| 580 |
+
"chosen_split": "validation",
|
| 581 |
+
"forced_nonempty": false,
|
| 582 |
+
"considered": [
|
| 583 |
+
{
|
| 584 |
+
"split": "train",
|
| 585 |
+
"delta": -0.03819444444444444
|
| 586 |
+
},
|
| 587 |
+
{
|
| 588 |
+
"split": "validation",
|
| 589 |
+
"delta": -0.05555555555555556
|
| 590 |
+
},
|
| 591 |
+
{
|
| 592 |
+
"split": "test",
|
| 593 |
+
"delta": -0.05555555555555556
|
| 594 |
+
}
|
| 595 |
+
]
|
| 596 |
+
},
|
| 597 |
+
{
|
| 598 |
+
"unit": "family-question-1",
|
| 599 |
+
"records": 3,
|
| 600 |
+
"chosen_split": "train",
|
| 601 |
+
"forced_nonempty": false,
|
| 602 |
+
"considered": [
|
| 603 |
+
{
|
| 604 |
+
"split": "train",
|
| 605 |
+
"delta": -0.1423611111111111
|
| 606 |
+
},
|
| 607 |
+
{
|
| 608 |
+
"split": "validation",
|
| 609 |
+
"delta": 0.08333333333333334
|
| 610 |
+
},
|
| 611 |
+
{
|
| 612 |
+
"split": "test",
|
| 613 |
+
"delta": -0.05555555555555556
|
| 614 |
+
}
|
| 615 |
+
]
|
| 616 |
+
},
|
| 617 |
+
{
|
| 618 |
+
"unit": "family-question-3",
|
| 619 |
+
"records": 3,
|
| 620 |
+
"chosen_split": "train",
|
| 621 |
+
"forced_nonempty": false,
|
| 622 |
+
"considered": [
|
| 623 |
+
{
|
| 624 |
+
"split": "train",
|
| 625 |
+
"delta": -0.07291666666666666
|
| 626 |
+
},
|
| 627 |
+
{
|
| 628 |
+
"split": "validation",
|
| 629 |
+
"delta": 0.08333333333333334
|
| 630 |
+
},
|
| 631 |
+
{
|
| 632 |
+
"split": "test",
|
| 633 |
+
"delta": -0.05555555555555556
|
| 634 |
+
}
|
| 635 |
+
]
|
| 636 |
+
},
|
| 637 |
+
{
|
| 638 |
+
"unit": "family-question-2",
|
| 639 |
+
"records": 3,
|
| 640 |
+
"chosen_split": "test",
|
| 641 |
+
"forced_nonempty": false,
|
| 642 |
+
"considered": [
|
| 643 |
+
{
|
| 644 |
+
"split": "train",
|
| 645 |
+
"delta": -0.0034722222222222203
|
| 646 |
+
},
|
| 647 |
+
{
|
| 648 |
+
"split": "validation",
|
| 649 |
+
"delta": 0.08333333333333334
|
| 650 |
+
},
|
| 651 |
+
{
|
| 652 |
+
"split": "test",
|
| 653 |
+
"delta": -0.05555555555555556
|
| 654 |
+
}
|
| 655 |
+
]
|
| 656 |
+
},
|
| 657 |
+
{
|
| 658 |
+
"unit": "family-bug-3",
|
| 659 |
+
"records": 3,
|
| 660 |
+
"chosen_split": "train",
|
| 661 |
+
"forced_nonempty": false,
|
| 662 |
+
"considered": [
|
| 663 |
+
{
|
| 664 |
+
"split": "train",
|
| 665 |
+
"delta": -0.05555555555555555
|
| 666 |
+
},
|
| 667 |
+
{
|
| 668 |
+
"split": "validation",
|
| 669 |
+
"delta": 0.08333333333333334
|
| 670 |
+
},
|
| 671 |
+
{
|
| 672 |
+
"split": "test",
|
| 673 |
+
"delta": 0.08333333333333334
|
| 674 |
+
}
|
| 675 |
+
]
|
| 676 |
+
},
|
| 677 |
+
{
|
| 678 |
+
"unit": "family-bug-2",
|
| 679 |
+
"records": 3,
|
| 680 |
+
"chosen_split": "train",
|
| 681 |
+
"forced_nonempty": false,
|
| 682 |
+
"considered": [
|
| 683 |
+
{
|
| 684 |
+
"split": "train",
|
| 685 |
+
"delta": 0.013888888888888892
|
| 686 |
+
},
|
| 687 |
+
{
|
| 688 |
+
"split": "validation",
|
| 689 |
+
"delta": 0.08333333333333334
|
| 690 |
+
},
|
| 691 |
+
{
|
| 692 |
+
"split": "test",
|
| 693 |
+
"delta": 0.08333333333333334
|
| 694 |
+
}
|
| 695 |
+
]
|
| 696 |
+
}
|
| 697 |
+
]
|
| 698 |
+
}
|
sample.jsonl
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"id": "bug-0-0", "group": "family-bug-0", "label": "bug", "text": "Exact duplicate: sample payload."}
|
| 2 |
+
{"id": "bug-0-1", "group": "family-bug-0", "label": "bug", "text": "Synthetic bug template family 0, sibling 1. 合成样例。"}
|
| 3 |
+
{"id": "bug-0-2", "group": "family-bug-0", "label": "bug", "text": "Synthetic bug template family 0, sibling 2. 合成样例。"}
|
| 4 |
+
{"id": "bug-1-0", "group": "family-bug-1", "label": "bug", "text": "Synthetic bug template family 1, sibling 0. 合成样例。"}
|
| 5 |
+
{"id": "bug-1-1", "group": "family-bug-1", "label": "bug", "text": "Exact duplicate: sample payload."}
|
| 6 |
+
{"id": "bug-1-2", "group": "family-bug-1", "label": "bug", "text": "Synthetic bug template family 1, sibling 2. 合成样例。"}
|
| 7 |
+
{"id": "bug-2-0", "group": "family-bug-2", "label": "bug", "text": "Synthetic bug template family 2, sibling 0. 合成样例。"}
|
| 8 |
+
{"id": "bug-2-1", "group": "family-bug-2", "label": "bug", "text": "Synthetic bug template family 2, sibling 1. 合成样例。"}
|
| 9 |
+
{"id": "bug-2-2", "group": "family-bug-2", "label": "bug", "text": "Synthetic bug template family 2, sibling 2. 合成样例。"}
|
| 10 |
+
{"id": "bug-3-0", "group": "family-bug-3", "label": "bug", "text": "Synthetic bug template family 3, sibling 0. 合成样例。"}
|
| 11 |
+
{"id": "bug-3-1", "group": "family-bug-3", "label": "bug", "text": "Synthetic bug template family 3, sibling 1. 合成样例。"}
|
| 12 |
+
{"id": "bug-3-2", "group": "family-bug-3", "label": "bug", "text": "Synthetic bug template family 3, sibling 2. 合成样例。"}
|
| 13 |
+
{"id": "example-0-0", "group": "family-example-0", "label": "example", "text": "Cross-label duplicate: same input."}
|
| 14 |
+
{"id": "example-0-1", "group": "family-example-0", "label": "example", "text": "Synthetic example template family 0, sibling 1. 合成样例。"}
|
| 15 |
+
{"id": "example-0-2", "group": "family-example-0", "label": "example", "text": "Synthetic example template family 0, sibling 2. 合成样例。"}
|
| 16 |
+
{"id": "example-1-0", "group": "family-example-1", "label": "example", "text": "Café note"}
|
| 17 |
+
{"id": "example-1-1", "group": "family-example-1", "label": "example", "text": "Synthetic example template family 1, sibling 1. 合成样例。"}
|
| 18 |
+
{"id": "example-1-2", "group": "family-example-1", "label": "example", "text": "Synthetic example template family 1, sibling 2. 合成样例。"}
|
| 19 |
+
{"id": "example-2-0", "group": "family-example-2", "label": "example", "text": "Synthetic example template family 2, sibling 0. 合成样例。"}
|
| 20 |
+
{"id": "example-2-1", "group": "family-example-2", "label": "example", "text": "Synthetic example template family 2, sibling 1. 合成样例。"}
|
| 21 |
+
{"id": "example-2-2", "group": "family-example-2", "label": "example", "text": "Synthetic example template family 2, sibling 2. 合成样例。"}
|
| 22 |
+
{"id": "example-3-0", "group": "family-example-3", "label": "example", "text": "Synthetic example template family 3, sibling 0. 合成样例。"}
|
| 23 |
+
{"id": "example-3-1", "group": "family-example-3", "label": "example", "text": "Synthetic example template family 3, sibling 1. 合成样例。"}
|
| 24 |
+
{"id": "example-3-2", "group": "family-example-3", "label": "example", "text": "Synthetic example template family 3, sibling 2. 合成样例。"}
|
| 25 |
+
{"id": "question-0-0", "group": "family-question-0", "label": "question", "text": "Cross-label duplicate: same input."}
|
| 26 |
+
{"id": "question-0-1", "group": "family-question-0", "label": "question", "text": "Synthetic question template family 0, sibling 1. 合成样例。"}
|
| 27 |
+
{"id": "question-0-2", "group": "family-question-0", "label": "question", "text": "Synthetic question template family 0, sibling 2. 合成样例。"}
|
| 28 |
+
{"id": "question-1-0", "group": "family-question-1", "label": "question", "text": "Café note"}
|
| 29 |
+
{"id": "question-1-1", "group": "family-question-1", "label": "question", "text": "Synthetic question template family 1, sibling 1. 合成样例。"}
|
| 30 |
+
{"id": "question-1-2", "group": "family-question-1", "label": "question", "text": "Synthetic question template family 1, sibling 2. 合成样例。"}
|
| 31 |
+
{"id": "question-2-0", "group": "family-question-2", "label": "question", "text": "Synthetic question template family 2, sibling 0. 合成样例。"}
|
| 32 |
+
{"id": "question-2-1", "group": "family-question-2", "label": "question", "text": "Synthetic question template family 2, sibling 1. 合成样例。"}
|
| 33 |
+
{"id": "question-2-2", "group": "family-question-2", "label": "question", "text": "Synthetic question template family 2, sibling 2. 合成样例。"}
|
| 34 |
+
{"id": "question-3-0", "group": "family-question-3", "label": "question", "text": "Synthetic question template family 3, sibling 0. 合成样例。"}
|
| 35 |
+
{"id": "question-3-1", "group": "family-question-3", "label": "question", "text": "Synthetic question template family 3, sibling 1. 合成样例。"}
|
| 36 |
+
{"id": "question-3-2", "group": "family-question-3", "label": "question", "text": "Synthetic question template family 3, sibling 2. 合成样例。"}
|
style.css
CHANGED
|
@@ -1,28 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
body {
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
}
|
| 5 |
-
|
| 6 |
h1 {
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
.
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
}
|
|
|
|
| 1 |
+
:root {
|
| 2 |
+
color-scheme: light;
|
| 3 |
+
--ink: #332b40;
|
| 4 |
+
--muted: #665e70;
|
| 5 |
+
--accent: #6c437f;
|
| 6 |
+
--line: #ded7e2;
|
| 7 |
+
}
|
| 8 |
+
* {
|
| 9 |
+
box-sizing: border-box;
|
| 10 |
+
}
|
| 11 |
body {
|
| 12 |
+
margin: 0;
|
| 13 |
+
color: var(--ink);
|
| 14 |
+
background: #f7f4f8;
|
| 15 |
+
font:
|
| 16 |
+
16px/1.6 system-ui,
|
| 17 |
+
-apple-system,
|
| 18 |
+
sans-serif;
|
| 19 |
+
}
|
| 20 |
+
main {
|
| 21 |
+
max-width: 1440px;
|
| 22 |
+
margin: auto;
|
| 23 |
+
padding: 48px 32px;
|
| 24 |
+
}
|
| 25 |
+
header {
|
| 26 |
+
max-width: 1000px;
|
| 27 |
+
margin-bottom: 32px;
|
| 28 |
+
}
|
| 29 |
+
.eyebrow {
|
| 30 |
+
font-size: 12px;
|
| 31 |
+
letter-spacing: 0.15em;
|
| 32 |
+
font-weight: 750;
|
| 33 |
+
color: var(--accent);
|
| 34 |
}
|
|
|
|
| 35 |
h1 {
|
| 36 |
+
font-size: clamp(36px, 4.5vw, 62px);
|
| 37 |
+
letter-spacing: -0.04em;
|
| 38 |
+
line-height: 1.1;
|
| 39 |
+
margin: 14px 0;
|
| 40 |
+
}
|
| 41 |
+
.lede {
|
| 42 |
+
font-size: 23px;
|
| 43 |
+
color: var(--muted);
|
| 44 |
+
}
|
| 45 |
+
.workspace {
|
| 46 |
+
display: grid;
|
| 47 |
+
grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
|
| 48 |
+
gap: 26px;
|
| 49 |
+
}
|
| 50 |
+
section {
|
| 51 |
+
min-width: 0;
|
| 52 |
+
background: #fff;
|
| 53 |
+
border: 1px solid var(--line);
|
| 54 |
+
border-radius: 10px;
|
| 55 |
+
padding: 26px;
|
| 56 |
+
}
|
| 57 |
+
h2 {
|
| 58 |
+
font-size: 22px;
|
| 59 |
+
margin: 0 0 20px;
|
| 60 |
+
}
|
| 61 |
+
h3 {
|
| 62 |
+
font-size: 18px;
|
| 63 |
+
margin-top: 28px;
|
| 64 |
+
}
|
| 65 |
+
.config-heading {
|
| 66 |
+
margin-top: 28px;
|
| 67 |
+
}
|
| 68 |
+
label {
|
| 69 |
+
display: block;
|
| 70 |
+
font-weight: 650;
|
| 71 |
+
margin: 14px 0 8px;
|
| 72 |
+
}
|
| 73 |
+
textarea,
|
| 74 |
+
input,
|
| 75 |
+
button {
|
| 76 |
+
font: inherit;
|
| 77 |
+
}
|
| 78 |
+
textarea,
|
| 79 |
+
input {
|
| 80 |
+
width: 100%;
|
| 81 |
+
border: 1px solid #96869f;
|
| 82 |
+
border-radius: 6px;
|
| 83 |
+
padding: 12px;
|
| 84 |
+
background: #fff;
|
| 85 |
+
color: var(--ink);
|
| 86 |
+
}
|
| 87 |
+
textarea {
|
| 88 |
+
font:
|
| 89 |
+
13px/1.6 ui-monospace,
|
| 90 |
+
SFMono-Regular,
|
| 91 |
+
monospace;
|
| 92 |
+
resize: vertical;
|
| 93 |
+
}
|
| 94 |
+
input {
|
| 95 |
+
min-height: 48px;
|
| 96 |
+
}
|
| 97 |
+
fieldset {
|
| 98 |
+
border: 1px solid var(--line);
|
| 99 |
+
border-radius: 6px;
|
| 100 |
+
padding: 12px;
|
| 101 |
+
min-width: 0;
|
| 102 |
+
}
|
| 103 |
+
legend {
|
| 104 |
+
font-size: 14px;
|
| 105 |
+
color: var(--muted);
|
| 106 |
+
padding: 0 5px;
|
| 107 |
+
}
|
| 108 |
+
.ratios {
|
| 109 |
+
display: grid;
|
| 110 |
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
| 111 |
+
gap: 12px;
|
| 112 |
+
}
|
| 113 |
+
.ratios label {
|
| 114 |
+
font-size: 14px;
|
| 115 |
+
margin-top: 0;
|
| 116 |
+
}
|
| 117 |
+
button {
|
| 118 |
+
background: var(--accent);
|
| 119 |
+
border: 0;
|
| 120 |
+
border-radius: 6px;
|
| 121 |
+
color: #fff;
|
| 122 |
+
padding: 12px 20px;
|
| 123 |
+
min-height: 48px;
|
| 124 |
+
font-weight: 650;
|
| 125 |
+
cursor: pointer;
|
| 126 |
+
margin-top: 18px;
|
| 127 |
+
}
|
| 128 |
+
button:disabled {
|
| 129 |
+
background: #9b8aa4;
|
| 130 |
+
cursor: wait;
|
| 131 |
+
}
|
| 132 |
+
.hint,
|
| 133 |
+
footer {
|
| 134 |
+
font-size: 14px;
|
| 135 |
+
color: var(--muted);
|
| 136 |
+
overflow-wrap: anywhere;
|
| 137 |
+
}
|
| 138 |
+
summary {
|
| 139 |
+
cursor: pointer;
|
| 140 |
+
padding: 12px 0;
|
| 141 |
+
font-weight: 600;
|
| 142 |
+
}
|
| 143 |
+
details p {
|
| 144 |
+
font-size: 14px;
|
| 145 |
+
}
|
| 146 |
+
pre {
|
| 147 |
+
white-space: pre-wrap;
|
| 148 |
+
overflow-wrap: anywhere;
|
| 149 |
+
max-height: 320px;
|
| 150 |
+
overflow: auto;
|
| 151 |
+
background: #f7f4f8;
|
| 152 |
+
padding: 14px;
|
| 153 |
+
font:
|
| 154 |
+
13px/1.6 ui-monospace,
|
| 155 |
+
monospace;
|
| 156 |
+
}
|
| 157 |
+
.placeholder {
|
| 158 |
+
padding: 28px;
|
| 159 |
+
border: 1px dashed var(--line);
|
| 160 |
+
border-radius: 8px;
|
| 161 |
+
color: var(--muted);
|
| 162 |
+
}
|
| 163 |
+
.summary {
|
| 164 |
+
font-weight: 650;
|
| 165 |
+
}
|
| 166 |
+
.notice {
|
| 167 |
+
border-left: 4px solid var(--accent);
|
| 168 |
+
background: #f2eaf6;
|
| 169 |
+
padding: 14px;
|
| 170 |
+
}
|
| 171 |
+
.table-wrap {
|
| 172 |
+
overflow: auto;
|
| 173 |
+
max-height: 440px;
|
| 174 |
+
}
|
| 175 |
+
table {
|
| 176 |
+
width: 100%;
|
| 177 |
+
border-collapse: collapse;
|
| 178 |
+
font-size: 14px;
|
| 179 |
+
font-variant-numeric: tabular-nums;
|
| 180 |
+
}
|
| 181 |
+
caption {
|
| 182 |
+
text-align: left;
|
| 183 |
+
padding: 10px 0;
|
| 184 |
+
color: var(--muted);
|
| 185 |
+
}
|
| 186 |
+
th,
|
| 187 |
+
td {
|
| 188 |
+
text-align: left;
|
| 189 |
+
padding: 10px;
|
| 190 |
+
border-bottom: 1px solid var(--line);
|
| 191 |
+
white-space: nowrap;
|
| 192 |
+
}
|
| 193 |
+
th {
|
| 194 |
+
background: #f5eff7;
|
| 195 |
+
}
|
| 196 |
+
th:first-child,
|
| 197 |
+
td:first-child {
|
| 198 |
+
padding-left: 4px;
|
| 199 |
+
}
|
| 200 |
+
.downloads {
|
| 201 |
+
display: flex;
|
| 202 |
+
flex-wrap: wrap;
|
| 203 |
+
gap: 10px;
|
| 204 |
+
margin-top: 20px;
|
| 205 |
+
}
|
| 206 |
+
.downloads a {
|
| 207 |
+
min-height: 48px;
|
| 208 |
+
display: inline-block;
|
| 209 |
+
padding: 10px 14px;
|
| 210 |
+
border: 1px solid var(--line);
|
| 211 |
+
border-radius: 6px;
|
| 212 |
+
color: var(--accent);
|
| 213 |
+
overflow-wrap: anywhere;
|
| 214 |
+
}
|
| 215 |
+
#error {
|
| 216 |
+
background: #fff0e8;
|
| 217 |
+
border-left: 4px solid #a33e25;
|
| 218 |
+
color: #843521;
|
| 219 |
+
padding: 14px;
|
| 220 |
+
}
|
| 221 |
+
#warnings p {
|
| 222 |
+
white-space: pre-wrap;
|
| 223 |
+
overflow-wrap: anywhere;
|
| 224 |
+
}
|
| 225 |
+
footer {
|
| 226 |
+
margin-top: 28px;
|
| 227 |
+
}
|
| 228 |
+
a {
|
| 229 |
+
color: var(--accent);
|
| 230 |
+
}
|
| 231 |
+
:focus-visible {
|
| 232 |
+
outline: 3px solid #b57619;
|
| 233 |
+
outline-offset: 3px;
|
| 234 |
+
}
|
| 235 |
+
[hidden] {
|
| 236 |
+
display: none !important;
|
| 237 |
+
}
|
| 238 |
+
@media (max-width: 950px) {
|
| 239 |
+
main {
|
| 240 |
+
padding: 28px 18px;
|
| 241 |
+
}
|
| 242 |
+
.workspace {
|
| 243 |
+
grid-template-columns: minmax(0, 1fr);
|
| 244 |
+
}
|
| 245 |
+
section {
|
| 246 |
+
padding: 20px;
|
| 247 |
+
}
|
| 248 |
+
.ratios {
|
| 249 |
+
gap: 8px;
|
| 250 |
+
}
|
| 251 |
+
.ratios input {
|
| 252 |
+
padding: 10px;
|
| 253 |
+
}
|
| 254 |
}
|
test_planner.mjs
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import assert from "node:assert/strict";
|
| 2 |
+
import fs from "node:fs";
|
| 3 |
+
import {
|
| 4 |
+
normalized,
|
| 5 |
+
compare,
|
| 6 |
+
parseJSONL,
|
| 7 |
+
plan,
|
| 8 |
+
makeUnits,
|
| 9 |
+
priority,
|
| 10 |
+
settings,
|
| 11 |
+
objective,
|
| 12 |
+
} from "./planner.mjs";
|
| 13 |
+
const row = (id, group, label = "a", text = "text " + id) => ({
|
| 14 |
+
id,
|
| 15 |
+
group,
|
| 16 |
+
label,
|
| 17 |
+
text,
|
| 18 |
+
});
|
| 19 |
+
let groups = 0;
|
| 20 |
+
assert.equal(
|
| 21 |
+
normalized(" \u001cCafe\u0301\u0085\u3000note\u001f"),
|
| 22 |
+
"Café note",
|
| 23 |
+
);
|
| 24 |
+
assert.equal(normalized("\ufeff A\ufeff"), "\ufeff A\ufeff");
|
| 25 |
+
assert.ok(compare("\ue000", "😀") < 0);
|
| 26 |
+
assert.equal(
|
| 27 |
+
makeUnits([row("hi", "😀", "a", "same"), row("lo", "\ue000", "a", "same")])[0]
|
| 28 |
+
.key,
|
| 29 |
+
"\ue000",
|
| 30 |
+
);
|
| 31 |
+
groups++;
|
| 32 |
+
const sample = parseJSONL(
|
| 33 |
+
fs.readFileSync(new URL("./sample.jsonl", import.meta.url), "utf8"),
|
| 34 |
+
);
|
| 35 |
+
assert.equal(sample.rows.length, 36);
|
| 36 |
+
const result = plan(sample.rows);
|
| 37 |
+
assert.equal(result.report.total_records, 36);
|
| 38 |
+
assert.equal(result.report.declared_groups, 12);
|
| 39 |
+
assert.equal(result.report.allocation_units, 10);
|
| 40 |
+
assert.equal(result.report.merged_units, 2);
|
| 41 |
+
assert.equal(result.report.audit.exact_text_label_conflicts.length, 1);
|
| 42 |
+
assert.equal(result.report.audit.exact_text_cross_split_sets, 0);
|
| 43 |
+
assert.equal(result.report.audit.group_cross_split_sets, 0);
|
| 44 |
+
assert.equal(result.report.assignments.length, 36);
|
| 45 |
+
assert.ok(result.report.splits.every((x) => x.actual_records > 0));
|
| 46 |
+
groups++;
|
| 47 |
+
const reverse = plan(sample.rows.slice().reverse());
|
| 48 |
+
assert.deepEqual(
|
| 49 |
+
result.report.assignments.slice().sort((a, b) => a.id.localeCompare(b.id)),
|
| 50 |
+
reverse.report.assignments.slice().sort((a, b) => a.id.localeCompare(b.id)),
|
| 51 |
+
);
|
| 52 |
+
assert.equal(result.report.objective, reverse.report.objective);
|
| 53 |
+
for (let k = 0; k < 100; k++) {
|
| 54 |
+
const rotated = sample.rows
|
| 55 |
+
.slice(k % sample.rows.length)
|
| 56 |
+
.concat(sample.rows.slice(0, k % sample.rows.length))
|
| 57 |
+
.reverse();
|
| 58 |
+
const p = plan(rotated);
|
| 59 |
+
assert.deepEqual(
|
| 60 |
+
result.report.assignments.slice().sort((a, b) => a.id.localeCompare(b.id)),
|
| 61 |
+
p.report.assignments.slice().sort((a, b) => a.id.localeCompare(b.id)),
|
| 62 |
+
);
|
| 63 |
+
assert.equal(result.report.objective, p.report.objective);
|
| 64 |
+
}
|
| 65 |
+
groups++;
|
| 66 |
+
const bridge = [
|
| 67 |
+
row("1", "g1", "a", "shared1"),
|
| 68 |
+
row("2", "g2", "b", "shared1"),
|
| 69 |
+
row("3", "g2", "a", "shared2"),
|
| 70 |
+
row("4", "g3", "a", "shared2"),
|
| 71 |
+
row("5", "g4"),
|
| 72 |
+
row("6", "g5"),
|
| 73 |
+
];
|
| 74 |
+
assert.equal(makeUnits(bridge).length, 3);
|
| 75 |
+
const bp = plan(bridge);
|
| 76 |
+
assert.equal(
|
| 77 |
+
bp.report.splits.reduce((n, s) => n + s.actual_records, 0),
|
| 78 |
+
6,
|
| 79 |
+
);
|
| 80 |
+
assert.equal(
|
| 81 |
+
new Set(
|
| 82 |
+
bp.report.assignments
|
| 83 |
+
.filter((r) => ["g1", "g2", "g3"].includes(r.group))
|
| 84 |
+
.map((r) => r.split),
|
| 85 |
+
).size,
|
| 86 |
+
1,
|
| 87 |
+
);
|
| 88 |
+
groups++;
|
| 89 |
+
assert.throws(() => plan(bridge.slice(0, 4)), /three allocation units/);
|
| 90 |
+
assert.throws(() =>
|
| 91 |
+
plan([row("same", "a"), row("same", "b"), row("other", "c")]),
|
| 92 |
+
);
|
| 93 |
+
assert.throws(() =>
|
| 94 |
+
plan([row("1", "a"), row("2", "b"), { ...row("3", "c"), text: "\ud800" }]),
|
| 95 |
+
);
|
| 96 |
+
assert.throws(() =>
|
| 97 |
+
plan([row("1", "a"), row("2", "b"), { ...row("3", "c"), group: null }]),
|
| 98 |
+
);
|
| 99 |
+
assert.throws(() => settings([80, 10, 11], 17));
|
| 100 |
+
assert.throws(() => settings([100, 0, 0], 17));
|
| 101 |
+
assert.throws(() => settings([80, 10, 10], 2 ** 32));
|
| 102 |
+
groups++;
|
| 103 |
+
const line = JSON.stringify(row("u", "g", "a", "literal U+2028 \u2028 kept"));
|
| 104 |
+
assert.equal(parseJSONL(line + "\n\u0085\n").blank_lines_ignored, 1);
|
| 105 |
+
assert.equal(
|
| 106 |
+
parseJSONL(line + "\n").rows[0].text,
|
| 107 |
+
"literal U+2028 \u2028 kept",
|
| 108 |
+
);
|
| 109 |
+
assert.throws(() => parseJSONL(line + "\n{"));
|
| 110 |
+
assert.throws(() => parseJSONL(" ".repeat(2097153)));
|
| 111 |
+
assert.throws(() =>
|
| 112 |
+
parseJSONL(
|
| 113 |
+
Array.from({ length: 5001 }, (_, i) =>
|
| 114 |
+
JSON.stringify(row(String(i), String(i))),
|
| 115 |
+
).join("\n"),
|
| 116 |
+
),
|
| 117 |
+
);
|
| 118 |
+
groups++;
|
| 119 |
+
const proto = plan([
|
| 120 |
+
row("__proto__", "__proto__"),
|
| 121 |
+
row("2", "constructor"),
|
| 122 |
+
row("3", "toString"),
|
| 123 |
+
]);
|
| 124 |
+
assert.equal(proto.report.assignments.length, 3);
|
| 125 |
+
groups++;
|
| 126 |
+
const exact = objective(
|
| 127 |
+
[1, 1, 1],
|
| 128 |
+
new Map([["a", [1, 1, 1]]]),
|
| 129 |
+
new Map([["a", 3]]),
|
| 130 |
+
[34, 33, 33],
|
| 131 |
+
);
|
| 132 |
+
assert.ok(
|
| 133 |
+
Math.abs(
|
| 134 |
+
exact - 2 * ((1 - 1.02) ** 2 / (3 * 1.02) + (2 * (1 - 0.99) ** 2) / 3),
|
| 135 |
+
) < 1e-12,
|
| 136 |
+
);
|
| 137 |
+
assert.equal(priority(17, "x"), priority(17, "x"));
|
| 138 |
+
groups++;
|
| 139 |
+
fs.writeFileSync(
|
| 140 |
+
new URL("./sample-plan.json", import.meta.url),
|
| 141 |
+
JSON.stringify(result.report, null, 2) + "\n",
|
| 142 |
+
);
|
| 143 |
+
fs.writeFileSync(
|
| 144 |
+
new URL("./sample-assigned.jsonl", import.meta.url),
|
| 145 |
+
result.assigned_jsonl,
|
| 146 |
+
);
|
| 147 |
+
console.log(
|
| 148 |
+
JSON.stringify({
|
| 149 |
+
status: "PASS",
|
| 150 |
+
groups,
|
| 151 |
+
sample_status: result.report.status,
|
| 152 |
+
normalized_candidates: result.report.audit.normalized_candidates.length,
|
| 153 |
+
splits: result.report.splits,
|
| 154 |
+
objective: result.report.objective,
|
| 155 |
+
}),
|
| 156 |
+
);
|
verify_reference.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Independent arithmetic/constraint oracle and small brute-force counterexamples."""
|
| 2 |
+
import collections,itertools,json,math,random,subprocess
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
random.seed(930177)
|
| 5 |
+
cases=[]
|
| 6 |
+
for case in range(100):
|
| 7 |
+
rows=[]
|
| 8 |
+
for g in range(random.randint(3,6)):
|
| 9 |
+
for i in range(random.randint(1,4)):rows.append({'id':f'{g}-{i}','group':f'g{g}','label':random.choice(['A','B']),'text':f'unique {g} {i}'})
|
| 10 |
+
cases.append({'rows':rows,'percentages':random.choice([[80,10,10],[50,25,25],[34,33,33]]),'seed':random.randrange(500)})
|
| 11 |
+
reports=json.loads(subprocess.run(['node','oracle_driver.mjs'],input=json.dumps(cases),text=True,capture_output=True,check=True,cwd=Path(__file__).parent).stdout)
|
| 12 |
+
def objective(rows,assignment,ratios):
|
| 13 |
+
N=len(rows);labels=sorted({r['label'] for r in rows});L=len(labels);ns=collections.Counter(assignment[r['group']] for r in rows);nl=collections.Counter(r['label'] for r in rows);cells=collections.Counter((r['label'],assignment[r['group']])for r in rows)
|
| 14 |
+
total=sum((ns[s]-N*p/100)**2/(N*max(1,N*p/100))for s,p in enumerate(ratios))
|
| 15 |
+
return total+sum((cells[l,s]-nl[l]*p/100)**2/(L*nl[l]*max(1,nl[l]*p/100)) for l in labels for s,p in enumerate(ratios))
|
| 16 |
+
nonoptimal=[];trace_cells=0
|
| 17 |
+
for case,report in zip(cases,reports):
|
| 18 |
+
rows=case['rows'];groups=sorted({r['group']for r in rows});assert report['total_records']==len(rows);assignment={r['group']:['train','validation','test'].index(r['split'])for r in report['assignments']};assert len(assignment)==len(groups)and set(assignment.values())=={0,1,2}
|
| 19 |
+
assert math.isclose(objective(rows,assignment,case['percentages']),report['objective'],abs_tol=1e-12)
|
| 20 |
+
assert {a['id']for a in report['assignments']}=={r['id']for r in rows}
|
| 21 |
+
for g in groups:assert len({a['split']for a in report['assignments']if a['group']==g})==1
|
| 22 |
+
for item in report['labels']:
|
| 23 |
+
for cell in item['splits']:
|
| 24 |
+
s=['train','validation','test'].index(cell['split']);assert cell['actual_records']==sum(r['label']==item['label']and assignment[r['group']]==s for r in rows)
|
| 25 |
+
# Verify each considered incremental objective using only already-allocated rows, fixed final target denominators.
|
| 26 |
+
labels=sorted({r['label']for r in rows});nl=collections.Counter(r['label']for r in rows);N=len(rows);L=len(labels);totals=[0,0,0];cells=collections.Counter();seen=set()
|
| 27 |
+
def fnv(key):
|
| 28 |
+
h=2166136261
|
| 29 |
+
for b in (str(case['seed'])+'\0'+key).encode():h=((h^b)*16777619)&0xffffffff
|
| 30 |
+
return h
|
| 31 |
+
ordered=sorted(groups,key=lambda g:(-sum(r['group']==g for r in rows),fnv(g),g))
|
| 32 |
+
assert [x['unit']for x in report['allocation_trace']]==ordered
|
| 33 |
+
for ordinal,step in enumerate(report['allocation_trace']):
|
| 34 |
+
members=[r for r in rows if r['group']==step['unit']];counts=collections.Counter(r['label'] for r in members)
|
| 35 |
+
empty=[s for s in range(3)if s not in seen];forced=len(groups)-ordinal==len(empty)
|
| 36 |
+
expected=empty if forced else [0,1,2]
|
| 37 |
+
assert step['forced_nonempty']==forced
|
| 38 |
+
assert [x['split']for x in step['considered']]==[['train','validation','test'][s]for s in expected]
|
| 39 |
+
choices=[]
|
| 40 |
+
for s in range(3):
|
| 41 |
+
p=case['percentages'][s]/100;t=N*p;delta=((totals[s]+len(members)-t)**2-(totals[s]-t)**2)/(N*max(1,t))
|
| 42 |
+
delta+=sum(((cells[l,s]+n-nl[l]*p)**2-(cells[l,s]-nl[l]*p)**2)/(L*nl[l]*max(1,nl[l]*p))for l,n in counts.items());choices.append(delta)
|
| 43 |
+
for choice in step['considered']:
|
| 44 |
+
s=['train','validation','test'].index(choice['split']);assert math.isclose(choice['delta'],choices[s],abs_tol=1e-12);trace_cells+=1
|
| 45 |
+
s=['train','validation','test'].index(step['chosen_split']);assert s in expected;assert choices[s]<=min(choices[q]for q in expected)+1e-12;totals[s]+=len(members)
|
| 46 |
+
for l,n in counts.items():cells[l,s]+=n
|
| 47 |
+
seen.add(s)
|
| 48 |
+
best=math.inf;best_assignment=None
|
| 49 |
+
for values in itertools.product(range(3),repeat=len(groups)):
|
| 50 |
+
if set(values)!={0,1,2}:continue
|
| 51 |
+
assign=dict(zip(groups,values));loss=objective(rows,assign,case['percentages'])
|
| 52 |
+
if loss<best:best=loss;best_assignment=assign
|
| 53 |
+
if report['objective']>best+1e-12:nonoptimal.append({'case':case,'greedy_assignment':assignment,'greedy_objective':report['objective'],'optimal_assignment':best_assignment,'optimal_objective':best})
|
| 54 |
+
assert nonoptimal
|
| 55 |
+
out={'status':'PASS','cases':100,'considered_deltas_checked':trace_cells,'nonoptimal_greedy_cases':len(nonoptimal),'counterexample':nonoptimal[0],'scope':'exhaustive optimality only for these 3–6 group synthetic cases; greedy not globally optimal'}
|
| 56 |
+
Path(__file__).with_name('reference-results.json').write_text(json.dumps(out,indent=2)+'\n');print({k:v for k,v in out.items()if k!='counterexample'})
|
verify_unicode.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Compare browser normalization to Python's explicit original-audit semantics."""
|
| 2 |
+
import json,subprocess,unicodedata
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
whitespace=[chr(c)for c in range(0x110000)if chr(c).isspace()]
|
| 5 |
+
values=[c+'Cafe\u0301'+c+'note'+c for c in whitespace]
|
| 6 |
+
values += ['\ufeffBOM kept','\u200bzero width\u200b','\u180eignored?','A\x00B','\ufeff','Cafe\u0301\r\n😀','x\u2028y']
|
| 7 |
+
code="import fs from 'node:fs'; import {normalized} from './planner.mjs'; console.log(JSON.stringify(JSON.parse(fs.readFileSync(0,'utf8')).map(normalized)));"
|
| 8 |
+
result=json.loads(subprocess.run(['node','--input-type=module','-e',code],input=json.dumps(values),text=True,capture_output=True,check=True,cwd=Path(__file__).parent).stdout)
|
| 9 |
+
assert result==[' '.join(unicodedata.normalize('NFC',s).split())for s in values]
|
| 10 |
+
print(json.dumps({'status':'PASS','python_whitespace_codepoints':len(whitespace),'normalization_vectors':len(values),'BOM_not_removed':True}))
|