Skip to content

Audit fixes: C-shim NaN guards, checker stray-end-if gate, doc corrections#45

Draft
SethMorrowSoftware wants to merge 1 commit into
mainfrom
claude/hopeful-gauss-e4vnz4
Draft

Audit fixes: C-shim NaN guards, checker stray-end-if gate, doc corrections#45
SethMorrowSoftware wants to merge 1 commit into
mainfrom
claude/hopeful-gauss-e4vnz4

Conversation

@SethMorrowSoftware

Copy link
Copy Markdown
Owner

Context

Output of a full multi-agent audit of the whole project (11 parallel Opus agents across the C shim, LCB binding, the Kit, the 6 example stacks, tooling/CI, docs, and assets/security). The audit found zero Critical issues — the foundation layers and cross-layer seams are essentially flawless (370↔370 C↔LCB binding bijection, 6/6 embedded-Kit copies byte-identical, warning-clean C build, 55/55 smoke tests, no secrets, no missing assets). This PR lands the low-risk, agreed-upon fixes.

No Kit/example source changed, so the embedded copies stay in sync. The C guards are behavior-preserving for valid input, so the ABI is unchanged (no LC_ABI_VERSION bump).

Changes

C shim (src/box2d_lc.c) — close a NaN/Inf-guard inconsistency flagged by two independent agents. The shape-level paths already reject non-finite/negative input; the chain and query paths did not. Now guarded:

  • b2lc_chain_add_point (NaN/Inf points poison the broadphase AABB)
  • b2lc_chain_create friction/restitution + b2lc_chain_set_friction/set_restitution
  • b2lc_query_overlap_circle / overlap_shape / shapecast radius (+ shapecast dx,dy)
  • b2lc_cast_ray_closest / query_raycast_all / shape_raycast endpoints

Build stays warning-clean; all smoke assertions pass.

Static checker (tools/check-livecodescript.py) — close a gate blind spot: a stray/extra end if (more closes than block-if opens) now fails the gate. Verified no regression on all 7 .livecodescript files, and that valid hybrid if/else-if/end if and nested patterns stay clean.

Docs & comments — factual corrections found by the docs/cross-layer agents:

  • kit-guide.md: b2Version() returns 4, not 3 (a correct library was being described as wrong); fix the [f]-vs-command call-style guidance (the spawn/joint commands are called as statements with the result, not function-called — per CLAUDE.md gotcha 7); fix a paren typo; complete the b2kPlayerAnims index.
  • CLAUDE.md / expansion-prep.md: self-test harness is v18 / 177 assertions (was "v12/~125"); the Kit is 300+ handlers (was "260+").
  • api-reference.md / architecture.md / box2dxt.lcb: de-stale the "as of ABI 3" prose (current ABI is 4).
  • Gotcha 11 softened to match the in-use OXT build: a nested local compiles in practice (several ship in the contraption builder/demo), so it's documented as house-style rather than a hard compiler rule, and the checker deliberately does not flag it.

Verification

  • cmake --build warning-clean; ctest 100% pass
  • python3 tools/check-livecodescript.py — all gates pass, embedded Kit in sync
  • No src/box2dxt-kit.livecodescript or examples/ changes → embedded copies unaffected

Not included (audit findings deferred for your call)

Higher-effort / additive items the audit surfaced but this PR does not touch: Kit sprite-clock vs sim-clock determinism under hand-step; expanding smoke-test + self-test coverage (notably the force/impulse/torque/explode conversion API); pinning CI action SHAs and running make-release.py --check in CI; ~22 unused spritesheets; and the missing CONTRIBUTING.md (referenced by CLAUDE.md and .gitignore). Happy to follow up on any of these.

https://claude.ai/code/session_01WoWN59TxvPRFSxYXDJ6srV


Generated by Claude Code

…tions

From a full multi-agent audit of the project. No Kit/example source changed,
so embedded copies stay in sync; the ABI is unchanged (the guards are
behavior-preserving for valid input, so no LC_ABI_VERSION bump).

C shim (src/box2d_lc.c): reject NaN/Inf/negative on chain points, chain
friction/restitution (create + setters), and the query/raycast radius +
endpoints -- matching the finite() discipline the shape paths already use.
Build stays warning-clean and all smoke assertions pass.

Static checker (tools/check-livecodescript.py): flag a stray/extra 'end if'
(more closes than block-if opens). Verified no regression on all 7
.livecodescript files; valid hybrid/nested if-chains stay clean.

Docs/comments: b2Version() returns 4 not 3 (kit-guide); the self-test harness
is v18 with 177 assertions and the Kit is 300+ handlers (CLAUDE.md,
expansion-prep); correct the [f]-vs-command call-style guidance and a paren
typo (kit-guide); de-stale the "ABI 3" prose (api-reference, architecture,
box2dxt.lcb). Soften gotcha 11 to match the in-use OXT build (a nested local
compiles; the checker deliberately does not flag it).

https://claude.ai/code/session_01WoWN59TxvPRFSxYXDJ6srV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants