Skip to content

fix(codegen,smt): declare sysml_parse_rec in generated C; order a witnessed sensitivity's values - #2170

Closed
devin-ai-integration[bot] wants to merge 1 commit into
developfrom
fix/codegen-c-rec-parse-declaration
Closed

devin-ai-integration[bot] wants to merge 1 commit into
developfrom
fix/codegen-c-rec-parse-declaration

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What and why

When ubuntu-latest moved to ubuntu-26.04 (gcc 15, z3 4.13.3) the merge queue went red on three tests that pass on 24.04 (gcc 13, z3 4.8.12). #2165 pins the image back; this fixes the two latent bugs and the one solver-specific assertion the newer image exposed, so the suite is correct on either.

  • Generated C (internal/translate/codegen/emit_fn.go): the collection runtime instantiated over records (cRecSeqRuntime) calls sysml_parse_rec, which nothing declared. gcc ≤ 13 warned and dropped the unused parser; gcc 14+ makes the implicit declaration an error, failing TestCompiledCalcsAgreeWithInterpreter/c and TestCompiledStepBudgetMatchesInterpreter on Rec::InSeq. It is now declared as the record counterpart of sysml_parse_fn. CFlags gains -Werror=implicit-function-declaration so every compiler rejects the next one.
  • SMT sensitivity (internal/exec/smt/twocopy.go): DecodePair spelt the output's two values in the order the solver's model put the two copies, so x ends as 1 or 2 became x ends as 2 or 1 under z3 4.13 (TestEngineSMTDecidesSensitivity). The pair is now ordered as the check engine orders a Divergence (lexically), swapping the runs with the values so witness A is still the run ending with the first value.
  • Open-bound optimum test (internal/frontend/repl/optimize_test.go): asserted the z3 4.8 rendering only (no optimum reported). z3 4.13 names the bound it approaches, which optimumLines already renders as no greatest value, approaching 10.5 without attaining it. The test now accepts either rendering and asserts the contract in the test's name: the bound is never reported as a value (`margin`: 10.5 rejected).

How it was verified

  • Added -Werror=implicit-function-declaration first, without the fix: go test ./tests/codegen -run 'TestCompiledCalcsAgreeWithInterpreter/c$' reproduces the CI error on local gcc 11 (implicit declaration of function ‘sysml_parse_rec’). With the fix the package passes.
  • go test -count=1 ./internal/translate/codegen ./internal/exec/smt ./internal/frontend/repl ./tests/codegen and go test ./cmd/sysml -run 'SMT|Sensitiv': pass (local z3 4.8.12, so the 4.8 branch of the optimum test; the 4.13 branch is the string CI printed).
  • go build ./..., go vet, gofmt -l, staticcheck on the three packages: clean.

Checklist

  • make test and make lint pass locally (affected packages; staticcheck clean)
  • Tests added or updated for the change
  • Documentation extended where it already covers the surface (docs/project/native-compilation.md flag list)
  • Changelog entry added as changes/unreleased/<slug>.<section>.md, not as an edit to CHANGELOG.md
  • baselines regenerated and make docs-counts run if a gate count moved (none moved)
  • No internal work-item labels (waves, slices, F4, K5) in the body, docs, or changelog

Link to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/a22ac6bb49a04224941818e07d42bed9
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/a22ac6bb49a04224941818e07d42bed9?variant=devin
Requested by: @HuiJun


🟢 Devin Review found nothing to fix · View findings · Follow Devin's work

Devin Review

…nessed sensitivity's values

The collection runtime instantiated over records calls sysml_parse_rec, which nothing declared: gcc 14 rejects the implicit declaration where gcc 13 warned. Declare it as the record counterpart of sysml_parse_fn and ask every C compiler to reject implicit declarations, so the gate catches the next one on any image.

The SMT engine spelt a divergence's two values in the order the solver's model put the copies, which differs between z3 4.8 and 4.13. Order them as the check engine does, swapping the two runs with the values so witness A stays the run that ends with the first.

The open-bound optimum test accepted only the z3 4.8 rendering (nothing reported); it now accepts the approached bound 4.13 reports and rejects the bound as a value under either.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Superseded: #2167 (codegen) and #2168 (smt/optimize test) carry the same fixes and were opened first; #2167 also adds a regression test and -Werror=int-conversion. Closing to avoid duplicate CI.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

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.

1 participant