Skip to content

Add AGENTS.md with code generation conventions - #5105

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:agent/agents-md-codegen-conventions
Sep 10, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:agent/agents-md-codegen-conventions

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

What changed and why

Adds a root AGENTS.md — the repository had none. It records three code-generation
conventions raised in review of #5045:

  1. Never gensym a name that ends up in generated code. A gensym embeds a
    process-global counter, so the same system lowers to a different Expr in the
    precompile process than in the user session, defeating the
    RuntimeGeneratedFunctions Expr-hash cache. Use a fixed sentinel (__mtk_ prefix
    as in generated_argument_name, or the ₘₜₖ suffix as in HOMOTOPY_LAMBDA).
  2. Build Exprs by pushing onto args, not splatting.
  3. Keep codegen-side containers concretely typed vectors, not tuples of tuples.

@ChrisRackauckas asked for the gensym rule to be written down in
#5045 (comment) ("Yeah we
do want to avoid gensym, good catch, should probably agents.md that"). The other two
come from @AayushSabharwal's review comments on the same PR.

The gensym claim is not just style — it is measured. On #5045, before that PR's
gensyms were replaced with fixed sentinels, building the same system twice produced
two distinct RuntimeGeneratedFunction types:

RuntimeGeneratedFunction{(Symbol("##problem#280"), Symbol("##initialization_solution#281")), …, (0x8298bbd3, 0xbcbc4d5b, 0x7a096718, 0x43533499, 0x57e4022b), Nothing}
RuntimeGeneratedFunction{(Symbol("##problem#287"), Symbol("##initialization_solution#288")), …, (0x44632bf6, 0x42fe7ec6, 0x4d5618c1, 0xb6d83a49, 0x2afa037a), Nothing}

After the fixed sentinels, the two types are identical.

Verification

Documentation only — no code changes, so no test suite applies.

$ typos AGENTS.md
$ echo $?
0
$ git diff --check

What I did not verify

Nothing was run beyond typos and git diff --check; there is no executable content
in this PR. No docs build was run — AGENTS.md is not part of the rendered
documentation.

Anything a reviewer should push back on

  • Whether the root is the right home for this, versus a nested AGENTS.md under
    lib/ModelingToolkitBase/src/systems/. The rules are about codegen specifically, but
    codegen lives in more than one directory.
  • The gensym rule carves out an exception for names that never reach generated code
    (e.g. the default name of a modelingtoolkitized system). If that exception is
    wrong, the wording needs tightening — src/systems/problem_utils.jl:2638 and
    src/systems/abstractsystem.jl still gensym in places I have not audited.

Ignore this draft until reviewed by @ChrisRackauckas.

🤖 Generated with Claude Code (model: claude-opus-5[1m])

https://claude.ai/code/session_01GdSpCLd7NBZuuePJmcDzU7

Records three conventions that came up in review of SciML#5045: no `gensym` in
names that reach generated code (it defeats the RuntimeGeneratedFunctions
Expr-hash cache), build `Expr`s by pushing onto `args` instead of splatting,
and keep codegen-side containers concretely typed vectors rather than tuples.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Agent-Harness: Claude Code 2.0.14
Agent-Model: claude-opus-5[1m]
Agent-Session: https://claude.ai/code/session_01GdSpCLd7NBZuuePJmcDzU7
Claude-Session: https://claude.ai/code/session_01GdSpCLd7NBZuuePJmcDzU7
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review September 10, 2026 15:53
@ChrisRackauckas
ChrisRackauckas merged commit 2c1ee5c into SciML:master Sep 10, 2026
79 of 85 checks passed
ChrisRackauckas added a commit that referenced this pull request Sep 11, 2026
- Add AGENTS.md with code generation conventions (#5105)
- Fall back to the solver default when an integrator carries no tolerances (#5106)



Agent-Harness: Claude Code
Agent-Model: claude-opus-5[1m]
Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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