Handle zero-token source rows in code trace audit

This commit is contained in:
2026-07-23 23:52:03 +08:00
parent fbaa909723
commit 1d9182f305
5 changed files with 50 additions and 6 deletions

View File

@@ -20,6 +20,21 @@ class CodeTracePreflightTest(unittest.TestCase):
source = root / "051315-051317.jsonl"
with source.open("w") as stream:
for index in range(4501):
if index == 100:
stream.write(
json.dumps(
{
"chat_id": index,
"parent_chat_id": -1,
"timestamp": float(index),
"input_length": 0,
"output_length": 0,
"hash_ids": [],
}
)
+ "\n"
)
continue
input_tokens = 513 if index % 2 else 512
stream.write(
json.dumps(
@@ -53,6 +68,7 @@ class CodeTracePreflightTest(unittest.TestCase):
self.assertEqual(
payload["selected"]["hash_contract"]["exact_source_block_size"], 512
)
self.assertEqual(payload["selected"]["invalid_zero_token_rows"], 1)
self.assertEqual(payload["max_model_len_recommendation"], 40960)
output = root / "window"
subprocess.run(
@@ -74,6 +90,7 @@ class CodeTracePreflightTest(unittest.TestCase):
self.assertEqual(manifest["requests"], len(rows))
self.assertGreaterEqual(manifest["duration_s"], 3600)
self.assertEqual(rows[0]["sampling_u"], rows[1]["sampling_u"])
self.assertNotIn(100, {row["source_index"] for row in rows})
if __name__ == "__main__":