Fix: Distinguish concrete ray failure causes

This commit is contained in:
wyj committed 2026-10-08 05:07:34 -04:00
1 parent 76ed705d37
commit 95c05f84d9
12 files changed
+580 -111

No files matched your search

+41
View File
@@ -1418,6 +1418,10 @@ int main(void) {
.outcome = RAY_OUTCOME_DARK,
.reason = RAY_REASON_REDSHIFT_LIMIT,
.end_id = SPACETIME_END_NONE, .traced = 1};
/* An appended detail reason with its coherent outcome must survive the
* frozen v3 schema exactly. */
dv[2].outcome = RAY_OUTCOME_INCOMPLETE;
dv[2].reason = RAY_REASON_REJECTION_LIMIT;
dv[0].trace_accepted_steps = 11; dv[0].trace_rejected_steps = 2;
dv[0].trace_rhs_evaluations = 79;
dv[1].trace_accepted_steps = 5;
@@ -1458,6 +1462,8 @@ int main(void) {
dloaded.frames[0].mesh.vertices[0].trace_rejected_steps != 2 ||
dloaded.frames[0].mesh.vertices[0].trace_rhs_evaluations != 79 ||
dloaded.frames[0].mesh.vertices[1].trace_accepted_steps != 5 ||
dloaded.frames[0].mesh.vertices[2].outcome != RAY_OUTCOME_INCOMPLETE ||
dloaded.frames[0].mesh.vertices[2].reason != RAY_REASON_REJECTION_LIMIT ||
dloaded.frames[0].mesh.triangles[0].level != 1) {
fputs("lens-map v3 DP54 field round-trip regression failed\n", stderr);
lens_map_destroy(&dloaded); unlink(dp_path); goto done;
@@ -1497,6 +1503,41 @@ int main(void) {
lens_map_destroy(&dloaded);
}
}
/* RAY_REASON_COUNT is a sentinel, never a valid wire reason: a map that
* stores it (or anything above it) must be rejected rather than
* reinterpreted. Vertex 0's reason field starts at byte 304 in this v3
* layout (176 provenance + 48 frame header + 80 vertex prefix). */
{
if (lens_map_write(dp_path, 4, 3, 30.0, &dp, &df, 1)) {
fputs("lens-map sentinel-reason fixture write failed\n", stderr);
unlink(dp_path); goto done;
}
const uint32_t sentinel = (uint32_t)RAY_REASON_COUNT;
FILE *bad = fopen(dp_path, "r+b");
int bad_failed = bad == NULL || fseek(bad, 304, SEEK_SET) ||
fwrite(&sentinel, sizeof sentinel, 1, bad) != 1;
if (bad != NULL && fclose(bad)) bad_failed = 1;
if (bad_failed || !lens_map_read(dp_path, NULL, &dloaded) ||
dloaded.frames != NULL || dloaded.frame_count != 0) {
fputs("lens-map sentinel reason rejection regression failed\n", stderr);
lens_map_destroy(&dloaded); unlink(dp_path); goto done;
}
lens_map_destroy(&dloaded);
}
/* The in-memory writer must also reject the sentinel; the wire test above
* cannot isolate reason validation from the frame CRC. */
{
const RayReason saved_reason = dv[2].reason;
dv[2].reason = (RayReason)RAY_REASON_COUNT;
const int rejected =
lens_map_write(dp_path, 4, 3, 30.0, &dp, &df, 1) != 0;
dv[2].reason = saved_reason;
if (!rejected) {
fputs("lens-map in-memory sentinel reason write regression failed\n",
stderr);
unlink(dp_path); goto done;
}
}
unlink(dp_path);
}
/* Legacy v2 import: a real v2 map (no adaptive fields, no cost counters)