From 2eff29d3dc8920824ec90750b2727622f3c6ed29 Mon Sep 17 00:00:00 2001 From: hyperpolymath <6759885+hyperpolymath@users.noreply.github.com> Date: Wed, 20 May 2026 09:56:07 +0100 Subject: [PATCH] fix(mongodb-mcp): add BsonFieldType enum to Zig FFI (standards#155) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes the Class C ABI gap surfaced by the Phase 2 full-tree survey: `MongodbMcp.SafeDatabase.BsonFieldType` (11 BSON wire-protocol field types with explicit `bsonFieldTypeToInt` encoding 1–18 with gaps at 6, 11–15, 17 per the BSON spec) was declared in the Idris2 ABI but absent from `mongodb_mcp_ffi.zig`. Adds the matching `pub const BsonFieldType = enum(c_int)` with the same encoding. Scope is ABI parity only. The wire-protocol encoder/decoder that *uses* these tags is a separate piece of work — declaring the enum here lets `iseriser abi-verify` structurally check the encoding against the Idris2 source, and unblocks mongodb-mcp for the boj-server abi-drift allowlist. ## Verified ``` $ iseriser abi-emit-manifest --idris cartridges/mongodb-mcp/abi/MongodbMcp/SafeDatabase.idr \ --cartridge mongodb-mcp --source-path … --out /tmp/m.json abi-emit-manifest: wrote /tmp/m.json (3 enums, 0 transitions) $ iseriser abi-verify --manifest /tmp/m.json \ --zig-ffi cartridges/mongodb-mcp/ffi/mongodb_mcp_ffi.zig abi-verify: OK — cartridge `mongodb-mcp` ABI manifest agrees with `…/mongodb_mcp_ffi.zig` exit=0 ``` `zig build test` 17/17 green. After merge, mongodb-mcp can join the abi-drift allowlist (currently 56 cartridges per boj-server#115). Closes hyperpolymath/standards#155 Refs hyperpolymath/standards#92 Refs hyperpolymath/standards#89 Co-Authored-By: Claude Opus 4.7 (1M context) --- .../mongodb-mcp/ffi/mongodb_mcp_ffi.zig | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cartridges/mongodb-mcp/ffi/mongodb_mcp_ffi.zig b/cartridges/mongodb-mcp/ffi/mongodb_mcp_ffi.zig index 9fdb10ac..5755d7b0 100644 --- a/cartridges/mongodb-mcp/ffi/mongodb_mcp_ffi.zig +++ b/cartridges/mongodb-mcp/ffi/mongodb_mcp_ffi.zig @@ -43,6 +43,27 @@ pub const MongodbAction = enum(c_int) { list_databases = 15, }; +/// BSON wire-protocol field type tags. Matches Idris2 +/// `MongodbMcp.SafeDatabase.BsonFieldType` + `bsonFieldTypeToInt`. +/// Integer codes follow the BSON spec — gaps (6, 11–15, 17) are by +/// design (reserved / deprecated BSON codes Idris2 does not expose). +/// Declared here so `iseriser abi-verify` can structurally check the +/// encoding against the Idris2 source; the wire-protocol encoder will +/// use these values when introduced. +pub const BsonFieldType = enum(c_int) { + bson_double = 1, + bson_string = 2, + bson_document = 3, + bson_array = 4, + bson_binary = 5, + bson_object_id = 7, + bson_bool = 8, + bson_date_time = 9, + bson_null = 10, + bson_int32 = 16, + bson_int64 = 18, +}; + /// Validate a state transition against the proven Idris2 transition graph. fn isValidTransition(from: ConnState, to: ConnState) bool { return switch (from) {