Skip to content

feat(ops): add manifest per-type schema hashes, HandleExhausted checks, and DTO vectors (#274) - #517

Merged
eric8810 merged 1 commit into
arcships:masterfrom
cunninghamcard-bit:feat/ops-manifest-and-dto-vectors
Nov 26, 2026
Merged

eric8810 merged 1 commit into
arcships:masterfrom
cunninghamcard-bit:feat/ops-manifest-and-dto-vectors

Conversation

@cunninghamcard-bit

Copy link
Copy Markdown
Contributor

Summary

Implements per-type manifest schemaHash negotiation, sources metadata, HandleExhausted contract matrix coverage, RFC-0042 §3.2 tool-input & negative DTO vectors, Rust decode round-trip tests, and conformance/release-matrix docs (refs #274, RFC-0039 & RFC-0042).

  • Per-type schemaHash, generatorVersion, and sources (aimux-ops, tools/aimux-codegen):
    • Adds "revision": "1" and cycle-safe transitive "schemaHash" per entry in manifest.types, plus "generatorVersion" and "sources" (aimux-ops/src/sources.rs generated from fixtures/aisdk/VERSIONS.json so cargo package -p aimux-ops remains self-contained).
    • Emits schema/manifest.json and TYPE_SCHEMA_HASHES across all 7 generated binding constant files (go, java, kotlin, swift, flutter, node, python), verified by cargo run -p aimux-codegen -- --check.
  • Load-time manifest negotiation (node, python, go, java, swift, flutter):
    • Keeps abiVersion and opsVersion strict.
    • Fast-paths exact manifest.digest == MANIFEST_DIGEST (preserving minimal C ABI fixtures and Python's explicit expected_digest pin checks), and falls back to verifying every entry in TYPE_SCHEMA_HASHES against manifest.types[].schemaHash.
  • HandleExhausted contract matrix (aimux-ops/tests/ops_matrix.rs):
    • Subprocess-isolated handle_exhausted_negative_state_behaves_per_contract verifies protocol code 306 across all 20 handle-allocating ops, code 203 on invalid handles, continued queries on pre-existing handles, zero provider reach, and allocator recovery on RAII guard drop.
  • RFC-0042 §3.2 tool-input & negative DTO vectors (contract-tests/dto):
    • Adds positive vectors RawToolCall/002..010.json and ToolCall/003..010.json.
    • Extends contract-tests/dto/index.json, scripts/check_dto_vectors.py, aimux-ops/src/dto_vectors.rs, and codegen emitters to validate "expectError": true negative vectors (while keeping ErrorEnvelope open for forward compatibility), plus encoded_positive_dto_vectors_decode_through_rust in aimux-ops/tests/manifest_contract.rs.
  • Docs:
    • Updates R128 -> gap in docs/rfc-0039-conformance.md, registers D20 in docs/rfc-0039-implementation.md, and adds docs/release-matrix.md.

Type of change

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change
  • New provider
  • New / updated binding
  • Docs / RFC

Checklist

  • cargo fmt --all -- --check passes
  • cargo clippy --workspace --all-targets -- -D warnings passes (cargo clippy -p aimux-ops -p aimux-codegen --all-targets -- -D warnings passed locally; full workspace runs in CI)
  • cargo test --workspace passes (cargo test -p aimux-ops -p aimux-codegen + Node/Go/Swift/Python checks passed locally; Java/Kotlin/Flutter/pytest run in CI)
  • Added or updated cassette tests / contract fixtures for behavior changes
  • Updated relevant docs (README.md, docs/, rfc/, bindings/README.md)
  • Commit messages follow Conventional Commits

Verification

  • cargo run -p aimux-codegen -- --check — passed (on 4e6ed9843)
  • Pre-rebase (bede841de, disjoint from #507):
    • cargo fmt --all -- --check — passed
    • cargo clippy -p aimux-ops -p aimux-codegen --all-targets -- -D warnings — passed
    • cargo test -p aimux-ops -p aimux-codegen — 311 passed, 1 ignored (run_shared_driver)
    • cargo package --list -p aimux-ops — passed
    • Node (23 tests + 270 DTO vectors), Go (test-abi.sh + 270 DTO vectors), Swift (33 checks + 270 DTO vectors), Python test_manifest_negotiation.py — passed (Java/Kotlin/Flutter/pytest run in CI)

Notes for reviewers

  • If #509 or #510 lands first, rerunning cargo run -p aimux-codegen cleanly regenerates schema/manifest.json, MANIFEST_DIGEST, and TYPE_SCHEMA_HASHES.
  • aimux-ops/src/dto_vectors.rs remains #[cfg(test)]-gated (compatible with #513).

cunninghamcard-bit added a commit to cunninghamcard-bit/aimux that referenced this pull request Nov 18, 2026

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

schemaHash 算法/95 个哈希/manifest digest/7 个绑定表/HandleExhausted 矩阵都独立复算通过。但 docs 仍直接说“没有 per-type revision/hash / 只有 exact digest”,与实现矛盾(conformance/implementation/upgrading/node/swift/0.6);另外 inputHash 后插入使自校验需要同时剔 digest 和 inputHash,未文档化无测试。请修文档并补自校验测试。

@cunninghamcard-bit
cunninghamcard-bit force-pushed the feat/ops-manifest-and-dto-vectors branch from 4def62d to 4dffcaa Compare November 25, 2026 03:39
@cunninghamcard-bit

Copy link
Copy Markdown
Contributor Author

@eric8810 Ready for re-review at 4dffcaa9f (rebased onto master a3b29f182 / v0.7.0, Cargo.toml and CHANGELOG.md untouched):

  • Rebase & codegen refresh: Regenerated schema/manifest.json, schema/types/*, aimux-ops/src/sources.rs, C headers, and all 7 language bindings (aimux-codegen --check green) for the 76 ops and 16 C ABI exports on v0.7.0, preserving Node/Python lazy manifest fast paths with full TYPE_SCHEMA_HASHES fallback.
  • Manifest self-verification & docs: Kept digest/inputHash self-verification tests across Rust/Node/Python/Go/Swift/Java/Flutter, aligned ABI version and C callback ownership docs (docs/api/c.md, docs/rfc-0039-implementation.md, docs/upgrading-to-ops-abi.md, binding READMEs), and renumbered the RFC-0039 implementation entry to D21.
  • Audit fixes:
    • trace.create / trace.clear: bounded capacity (1..=1_048_576) in schema and runtime, fallible RingTraceStore::try_with_capacity, in-place TraceStore::clear, and handle reservation before store allocation.
    • recorder.create / registry.update: reserve handles before disk/writer or metadata side effects; expanded HandleExhausted matrix to derive allocating ops from manifest typeDefs (covering registry.update derive: true and in-place derive: false).
    • aimux-codegen: removed post-digest generatorVersion mutation and enforced prefix + dangling-leaf symlink rejection in write, check, and write_sources.
    • Bindings: Node early ABI/ops check, manifest.digest consistency check, and exact JSON integer/float validation (dto_vectors.ts); Go non-null required-field checks on closed structs/variants; Java DtoJson.u64Input for *Input wrappers; Python DEFAULT_PIN explicit-pin enforcement and ops.py staleness check.

Verified locally: cargo fmt --all -- --check, aimux-codegen --check, cargo clippy -p aimux-core -p aimux-ops -p aimux-codegen --all-targets -- -D warnings, cargo test -p aimux-core --lib trace::store, cargo test -p aimux-ops -p aimux-codegen, Python test_manifest_negotiation.py (5/5), Node facade.test.ts + dto.test.ts (27/27) + 270 DTO vectors, Go test-abi.sh + 270 DTO vectors, Swift test-standalone.sh (35/35) + 270 DTO vectors.

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

4dffcaa 复审通过:schemaHash 是 BFS + BTreeSet 的 cycle-safe 实现,独立复算 SHA-256 匹配;sources.rs 由 codegen 从 VERSIONS.json 生成且在 src/ 下,cargo package 自包含;六个 binding 的协商路径(abi/ops 严格、digest 快路径、逐项 TYPE_SCHEMA_HASHES 校验)无 fail-open;HandleExhausted 矩阵的子进程隔离和 306/203 断言正确;上次两个问题(文档仍说无 per-type hash、inputHash 自校验未文档化/未测试)都已解决。Approve。

但 #537 刚合入,两者都改 aimux-ops/src/manifest.rs,现在 CONFLICTING。rebase 后请确认 codegen --check 通过(#537 后 manifest 走嵌入式快照)并重跑 CI,绿了我直接合。非阻塞:rfc-0039-conformance.md:300/305 写 101 而 R121/R126 写 102;Java 测试名 declaresOnlyTheFourteenPrimitives 已过时(16 个)。

@eric8810

Copy link
Copy Markdown
Contributor

@cunninghamcard-bit 我把这个 PR rebase 到了 0.7.0 master(解了和 #537 的 manifest 快照冲突,重跑了 codegen),但 rebase 改写了历史,推你的分支需要 force-push,我没有动。rebase 后的提交放在 #548,作者信息保留,可以直接从那里合。原分支可以关掉。详见 #548 描述。

@eric8810

Copy link
Copy Markdown
Contributor

更正:我之前开的 #548(rebase 版本)已关闭,那是我越界做的,这个 PR 仍以你的分支为准。

rebase 到 0.7.0 master 时的冲突点,供你参考:

注意:默认 feature 关闭时,只被 generate_manifest() 用的 import / helper 要跟着 runtime-manifest 门控,否则 clippy --no-default-features -D warnings 会红。

@cunninghamcard-bit
cunninghamcard-bit force-pushed the feat/ops-manifest-and-dto-vectors branch from 4dffcaa to 352ac49 Compare November 26, 2026 11:33
@cunninghamcard-bit

Copy link
Copy Markdown
Contributor Author

@eric8810 Rebased onto latest master (6c2954e9a, including #537) at 352ac4990:

  • Merged schemaHash, sources, and generatorVersion into aimux_ops::manifest::generate_manifest() under runtime-manifest, gated mod sources; and generator-only imports/helpers so --no-default-features builds cleanly with -D warnings, and kept canonical_digest() + hash helpers.
  • Kept aimux-ops/src/manifest.json.zlib and manifest.digest alongside aimux-ops/src/sources.rs and schema/manifest.json in aimux-codegen (lib.rs, main.rs, generated-files.json), keeping VERSIONS.json ↔ sources.rs sync checks active.
  • Re-ran cargo run -p aimux-codegen to refresh the embedded compressed snapshot, schema/manifest.json, and all 7 language bindings.
  • Updated docs/rfc-0039-conformance.md:300,305 (101 → 102). Left Java declaresOnlyTheFourteenPrimitivesWithPortableSizeT unchanged because AimuxFFI JNA still declares those exact 14 synchronous primitives (and docs/rfc-0039-conformance.md:63 cites it).

Verified locally: cargo fmt --all -- --check, cargo run -p aimux-codegen -- --check, cargo clippy -p aimux-ops -p aimux-ffi --no-default-features --all-targets -- -D warnings, cargo clippy -p aimux-ops -p aimux-ffi -p aimux-codegen --all-targets -- -D warnings, cargo test -p aimux-ops --no-default-features, cargo test -p aimux-ops --features runtime-manifest, cargo test -p aimux-codegen, Python (5/5), Node (27/27 + 270 vectors), Go (ABI + 270 vectors), and Swift standalone (35/35). Ready to merge once CI is green.

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

352ac49 复审通过。rebase 到 0.7.0 后的处理核对:generate_manifest() 与 #537 的嵌入式快照共存,manifest.digest = schema/manifest.json 的 digest/inputHash = 7 个 binding 的 MANIFEST_DIGEST(cd147fa9…);schema/manifest.json 作为生成镜像加回(index 已登记),Go/Node/Python/Swift 的合同测试读得到;版本号未动,[0.7.0] 段未碰;20/20 CI 绿。之前的审查结论(schemaHash 实现、六 binding 协商无 fail-open、HandleExhausted 矩阵、上轮两个问题已解)不变。Approve,可合。

非阻塞,可合后补:缺 CHANGELOG [Unreleased] 条目(manifest 新增 schemaHash/sources/generatorVersion、inputHash 自校验、HandleExhausted 覆盖);rfc-0039-conformance.md:300,305 写 101 而 R121/R126 写 102;Java 测试名 declaresOnlyTheFourteenPrimitives 已过时(16 个导出)。

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