Agent Skillsborglab/gtsam › annotate-pybind-adapters

annotate-pybind-adapters

GitHub

诊断 pybind11 因包装器接口与 C++ 声明签名不一致导致的编译失败,对受影响方法添加 @pybind_lambda 注解以生成 lambda 适配器,解决参数省略、引用/值差异及模板类型不匹配等问题。

wrap/.agents/skills/annotate-pybind-adapters/SKILL.md borglab/gtsam

Trigger Scenarios

pybind11 编译报错 C++ 签名与 Python 包装器不匹配

Install

npx skills add borglab/gtsam --skill annotate-pybind-adapters -g -y
More Options

Non-standard path

npx skills add https://github.com/borglab/gtsam/tree/develop/wrap/.agents/skills/annotate-pybind-adapters -g -y

Use without installing

npx skills use borglab/gtsam@annotate-pybind-adapters

指定 Agent (Claude Code)

npx skills add borglab/gtsam --skill annotate-pybind-adapters -a claude-code -g -y

安装 repo 全部 skill

npx skills add borglab/gtsam --all -g -y

预览 repo 内 skill

npx skills add borglab/gtsam --list

SKILL.md

Frontmatter
{
    "name": "annotate-pybind-adapters",
    "description": "Diagnose generated pybind compilation failures caused by wrapper interface signatures that differ from their C++ declarations, then apply the wrap `@pybind_lambda` annotation to only the affected methods, static methods, or global functions. Use for compile-annotate-regenerate migrations with full-signature callable-pointer casts, especially for omitted parameters, value\/reference differences, synthetic container accessors, incompatible types, inheritance, or templates."
}

Annotate Pybind Adapters

Use @pybind_lambda as an explicit escape hatch when a wrapper declaration is an adapter rather than the exact C++ callable signature. Keep full-signature callable-pointer casts as the default.

Read the repository instructions and the Pybind Callable Adapters section in DOCS.md before editing an interface file.

Workflow

  1. Reproduce the generated pybind compilation failure with the narrowest available build target.

  2. Locate the failing binding in generated C++ and map it back to one callable declaration in the wrapper .i file.

  3. Inspect the real C++ header. Do not infer signature equivalence from the .i file or from generator heuristics.

  4. Confirm that the old forwarding call is valid even though the generated full-signature static_cast does not match the C++ declaration.

  5. Add the marker after any template<...> prefix and immediately before that callable:

    @pybind_lambda
    ReturnType method(Arguments...);
    
    template<T = {double}>
    @pybind_lambda
    T templatedMethod(T value);
    
  6. Regenerate the binding and verify the annotated declaration emits a lambda while nearby unannotated declarations still emit full-signature casts.

  7. Re-run the failing compile target, relevant wrapper tests, and the full test suite prescribed by the repository.

  8. Report each annotation and the concrete C++ signature mismatch that requires it.

Use the py312 conda environment for Python commands in this workspace. In the standalone wrap repository, run focused pytest tests and then:

conda run -n py312 python -m pytest tests

When working in an integrated build that provides the repository-prescribed target, run its make -j6 testXXX.run target with the required permissions.

Decision Rules

Annotate when the wrapper intentionally differs from C++, including:

  • omitted underlying parameters with C++ defaults;
  • wrapper values that bind to C++ references;
  • synthetic value-returning interfaces such as at or front over reference returns;
  • incompatible types or inherited/template declarations whose pointer signature does not match the wrapper spelling.

Do not annotate merely because a callable is overloaded or templated. A full-signature cast selects an exact overload even when other overloads appear only in the C++ header. The generator also retains its existing automatic template-specialization and adapter cases.

Guardrails

  • Annotate one callable declaration at a time; never annotate a class or file in bulk.
  • Do not add symbol-name lists, GTSAM-specific heuristics, or guessed mismatch detection to wrap.
  • Do not change declaration/binding order or type-registration behavior while fixing an adapter compile failure.
  • Preserve Python names, defaults, policies, docstrings, and overload exposure.
  • Treat the marker as pybind-only. MATLAB output must remain unchanged.
  • Remove no existing automatic lambdas unless the task explicitly changes their semantics.

Version History

  • 8dab78d Current 2026-08-28 13:52

Metadata

Files
0
Version
8dab78d
Hash
17e26155
Indexed
2026-08-28 13:52

trang chủ - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-03 02:52
浙ICP备14020137号-1 $bản đồ khách truy cập$