feat(peat-ffi): ADR-074 schema alignment — shrink FFI types to proto-backed fields#1022
Conversation
…age types Establishes that all mesh document schemas must originate in peat-schema protos. Sub-crates derive types at build time via From impls rather than maintaining hand-written parallel structs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ields (ADR-074) Eliminates schema drift between peat-ffi's hand-written document types and peat-schema's protobuf definitions. FFI types now contain only fields that exist in the corresponding proto messages; drifted fields are dropped, not backfilled into protos. Removed entirely: - CommandInfo struct, CommandStatus enum, get_commands/put_command, parse/serialize helpers, JNI fn + registrations, Dart FFI bindings - NodeStatus enum (replaced by HealthStatus wrapper over proto) - CellStatus enum - Battery/heart-rate/last-heartbeat parsing helpers and ~15 tests Field changes: - NodeInfo: drop name/readiness/battery_percent/heart_rate/last_heartbeat; status→health (HealthStatus), hae→altitude (f64) - TrackInfo: drop cell_id/formation_id; hae→altitude, cep to f64 - CellInfo: drop name/status/center_lat/center_lon/scenario_command; formation_id→cohort_id Added: - peat-schema dependency for proto type bridging - From<Node/Track/CellState> for FFI types + From<i32> for HealthStatus - Rewritten node_tests covering proto-backed field set Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
peat-bot
left a comment
There was a problem hiding this comment.
Peat QA Review (SHA: ad64fe7)
Scope: ADR-074 schema alignment for peat-ffi — shrinks NodeInfo/TrackInfo/CellInfo to proto-backed field sets, removes MarkerInfo/CommandInfo/NodeStatus/CellStatus/TrackCategory, adds From<proto> bridges from peat-schema, and drops the corresponding JNI/UniFFI/Dart FFI symbols. Net −1,849 lines.
Assessment: Field-set alignment is defensible and the JSON codec paths (parse_node_json / serialize_node_json / parse_node_publish_json / serialize_nodes_get_json) still have solid round-trip coverage in the rewritten node_tests module. Removal of MarkerInfo / CommandInfo / TrackCategory / NodeStatus / dropped fields is a breaking change; the author has already listed this under Breaking changes for consumers in the PR body and marked the peat-atak-plugin migration as an unchecked pre-merge item — so consumer coordination is tracked, not a fresh finding. The hae→altitude Option-to-scalar collapse (also cep) matches peat-schema/proto/track.proto:68 (float altitude) and :71 (float cep_m) proto3 scalars, so semantic alignment with the proto is intentional under ADR-074 — not a regression to flag.
FIPS posture, Automerge / Iroh transport semantics, OTA safety, and BLE platform bindings are unaffected — this PR touches only FFI type-shape and JSON codecs.
Findings
[WARNING] From<peat_schema::*> for FfiType bridges are unused and untested — peat-ffi/src/lib.rs:2784 (From<Node> for NodeInfo), :2806 (From<Track> for TrackInfo), :2839 (From<CellState> for CellInfo). A repo-wide grep for NodeInfo::from, TrackInfo::from, and CellInfo::from returns zero call sites — the only invocation is HealthStatus::from(state.health) at :2792, internal to the From<Node> impl itself. The actual FFI data path is still parse_node_json / serialize_node_json (the ~600 lines of manual JSON codec ADR-074 §Consequences promised would collapse). Compile-time field-rename drift protection does fire (the impls reference proto field names by identifier), but semantic-mapping bugs (swapped lat/lon, wrong enum variant mapping, off-by-one on HealthStatus::try_from) cannot be caught by the compiler and would ship undetected because nothing exercises the bridges. Action: either add unit tests that construct a representative peat_schema::node::v1::Node / Track / CellState and assert the derived FFI value field-for-field, or wire the bridges into the actual data path (proto→FfiType) so cargo test covers them via the existing codec suites. Without one of those, the PR delivers ADR-074's letter (field sets align with protos) but not its spirit (the "single auditable conversion layer" isn't audited by CI).
- Remove stale `node.name` reference in publishNodeJni android_log (lib.rs:8517) - Fix `p.name` → `p.id` in dual_test_peer example - Update JNI method count assertion from 30 → 27 (3 methods removed) - Run cargo fmt to fix formatting diffs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
peat-bot
left a comment
There was a problem hiding this comment.
Peat QA Review (SHA: c684f80)
Scope: Incremental review over the CI-fix push on the ADR-074 schema-alignment PR. Base branch state (ad64fe7) already reviewed. The new commit is c684f807 fix(ci): resolve schema-alignment CI failures — four small changes: stale node.name reference removed from publishNodeJni android_log (now logs node.node_type), p.name → p.id in dual_test_peer and iroh_test_peer println paths, JNI native-method-table count assertion updated from 30 → 27 to match the removal of getCommandsJni / getMarkersJni / publishMarkerJni, and cargo fmt fixups. Total delta: 4 files, +14 / −21.
Assessment: The CI fix is mechanical and consistent — the node.name field no longer exists on the shrunk NodeInfo, so the log-line update is correct; the JNI count arithmetic (30 − 3 removed methods = 27) tracks the diff exactly. cargo fmt and log-string edits don't touch protocol, transport, FFI ABI shape, or crypto surface. FIPS posture, Automerge / Iroh semantics, OTA safety, and BLE bindings remain unaffected by this push.
The prior QA review at ad64fe7 raised one [WARNING] finding: the From<peat_schema::*> for FfiType bridges (From<Node> for NodeInfo at peat-ffi/src/lib.rs:2784, From<Track> for TrackInfo at :2802, From<CellState> for CellInfo at :2835) are unused and untested — the actual FFI data path still runs through parse_node_json / serialize_node_json, so a semantic bug in the derived conversions would ship undetected. This push does not modify the bridge code, so per incremental-review rules the finding is considered known-to-author (the CI-fix scope narrows the intent of this push, and the author can address the coverage gap in a follow-up push or a subsequent PR under ADR-074's ongoing migration).
No findings.
Summary
peat-schemaprotobuf definitions as the single source of truth for all message types. This PR eliminates schema drift inpeat-ffiby shrinking FFI document types (NodeInfo,TrackInfo,CellInfo) to only contain fields that exist in their corresponding proto messages.CommandInfo/CommandStatus,NodeStatus,CellStatus,MarkerInfo,TrackCategory— types and enums with no proto backing or that belong at the consumer level.peat-schemadependency andFrom<proto> for FfiTypebridges (From<Node> for NodeInfo,From<Track> for TrackInfo,From<CellState> for CellInfo,From<i32> for HealthStatus).Field changes
NodeInfoname,readiness,battery_percent,heart_rate,last_heartbeatstatus→health(HealthStatus enum),hae→altitudeTrackInfocell_id,formation_idhae→altitudeCellInfoname,status,center_lat,center_lon,scenario_commandformation_id→cohort_idCommandInfoBreaking changes for consumers
MarkerInfo,TrackCategory,CommandInfo, or any dropped field must define their own types. Seepeat-atak-plugin/docs/SCHEMA-MIGRATION-NOVEL-TYPES.mdfor migration guidance.NodeStatusenum replaced byHealthStatus(Unspecified/Nominal/Degraded/Critical/Failed) matchingnode.protoHealthStatus.Test plan
cargo check -p peat-ffi(lib, tests, examples) — cleancargo test -p peat-ffi --lib— 84 tests passNodeStatus,CommandInfo,CommandStatus,CellStatus,MarkerInfo,TrackCategory,battery_percent,heart_rate,last_heartbeatinpeat-ffi/src/,examples/,tests/peat-atak-plugin) defines its ownMarkerInfo/TrackCategorybefore pulling this dependency🤖 Generated with Claude Code