Skip to content

Use authorized remote backends from Rust without Git or Node - #113

Merged
unbraind merged 7 commits into
mainfrom
feat/portable-native-adapter-abi
Oct 24, 2026
Merged

unbraind merged 7 commits into
mainfrom
feat/portable-native-adapter-abi

Conversation

@unbraind

@unbraind unbraind commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Rust consumers need a portable contract for authorized SDK backends. This PR adds the bounded pm-native-adapter/1 JSON byte ABI, explicit NativeAdapterClient, tracker-free offline adapter-check CLI, and a read-only example. The integrating application owns transport and authorization; core owns schema and authoritative mutation/locking semantics. Requests are admitted before one exchange, canonical backend outcomes remain intact, and uncertain mutations are never retried.

The shared check_adapter_reply validates the original reply bytes for both offline and live admission. Transcripts retain reply_bytes; wire-size checks precede parsing. A separate bounded transcript envelope preserves the full 1 MiB frame ceiling.

The recursive strict reader closes the duplicate-key class: before, {"skipped":true,"skipped":false} inside output/details silently became skipped:false. Now duplicate decoded object keys refuse at every depth, including escaped-equal keys and objects inside arrays. strict_json::from_slice/from_str builds one validated value, requires end-of-input, then deserializes typed structs with serde_json::from_value. Even ignored typed fields must pass admission. All 34 JSON value/typed decode sites in 16 production source/example files use this reader: requests, transcripts, settings/schema/config, journals, history, sessions, provenance and cursors/receipts. The decode audit documents each site, existing optional-input fallback behavior and output-only raw-fragment serialization.

Validation at pushed head 6664a9f6cf55ff2a1b99d1dddb9771f8e5d16d6b:

  • strict_json_duplicate_corpus_matches_live_client: 392 added frames, 196 accepted / 196 refused. Shared-validator, offline and live verdicts match independent expectations. Includes envelope depths 0/1, payload depths 0..5, escaped-equal ASCII/Unicode keys, arrays of objects, success output and refusal details, and late duplicates after 16,384 fields. Accepted envelopes remain intact; live refusals retain dispatched uncertainty and reconciliation guidance.
  • raw_frame_seeded_corpus_matches_live_client: unchanged 768 frames, 240 accepted / 528 refused, seed 0x05eed113. Combined differential corpus: 1,160 frames, 436 accepted / 724 refused.
  • strict_json_transcripts_and_requests_reject_escaped_duplicates: four transcript/manifest/request/operation cases checked through SDK and CLI.
  • strict_json_preserves_values_and_rejects_invalid_documents, strict_json_validates_before_typed_fields_are_ignored, and strict_json_tracker_decodes_refuse_duplicates_without_git: valid values/order/integer precision, malformed input and ignored-field admission, plus real non-git settings/history/registry refusals without source rewrites.
  • node scripts/native-adapter-revert.mts: 9/9 independent behavioral proofs, recorded in the PM comment. The three new cases revert only the strict reader to serde's raw default, retaining tests and routed sites; rebuilt tests fail by assertion for recursive receipts, ignored typed fields and tracker input. Exact source bytes are restored. The six earlier proofs also pass. The serial PM-linked rerun completed all nine proofs; its timeout allowance accommodates compilation.
  • cargo +1.90.0 test --locked --test native_adapter_contract --test strict_json_contract: 13 + 3 passed. cargo +1.90.0 test --locked --lib strict_json: 1 passed. Native CLI selection: 2 passed; CLI dispatch: 17 passed. Real shared-tracker tests retain all 12 deterministic ownership interleavings.
  • All 8 PM-linked commands pass. Deny-warning clippy, fmt, private-item documentation, TypeScript, ESLint and regenerated changelog check pass locally. Strict-reader scoped coverage: 100% lines/functions/regions/branches, 50/12/79/6. Full repository coverage is a separate CI gate.

Full gates passed for this exact pushed head in CI run 40114062328: 10/10 jobs successful, including all three platform suites, all three latency gates and all four release aggregates. CodeQL run 40114062346 also passed.

Full release gate Rust normal Rust instrumented Lines/functions/regions/branches Node harness
Linux npm 648 648 100% each 22 passed, 0 skipped
Linux Bun 648 648 100% each 22 passed, 0 skipped
macOS npm 635 635 100% each 13 passed, 9 platform skips
Windows npm 628 628 100% each 12 passed, 10 platform skips

Every Rust count has zero failures and zero ignored tests. Harnesses have zero failures and zero cancellations; platform skips are explicit above. The unchanged aggregate gates also passed formatting, deny-warning clippy, documentation, TypeScript/ESLint, security audit, regenerated changelog and tracked-project health.

Measured source coverage totals (all covered): Linux 14,769 lines / 1,540 functions / 24,571 regions / 3,416 branches; macOS 14,679 / 1,526 / 24,410 / 3,376; Windows 14,675 / 1,525 / 24,408 / 3,378. Skipped optional workflows and unavailable automated reviews are not approval.

PM: pm-rust-portable-native-adapter-abi, remains in progress with the claim released for orchestrator verification. Code, docs and append-only history are committed together.

Public-data evidence retains the prior read-only snapshot measurements: 83 certified items, 172 files, 4,234,972 bytes, 9 pages, 92 adapter calls, 184 JSON/TOON checks and unchanged authoritative SHA-256. No hosted services or private data were used. Production transport acceptance belongs to the integrating backend. No merge or release is requested.

@sourcery-ai

sourcery-ai Bot commented Oct 24, 2026

Copy link
Copy Markdown

Sorry @unbraind, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 days and 11 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 521bcc7d-1601-461d-8b4b-0ad8cb57de16
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Oct 24, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a transport-neutral, strictly bounded native adapter ABI for authorized Rust consumers, with typed read and ownership operations, canonical receipt/refusal preservation, explicit uncertain-outcome handling, offline compatibility validation, a read-only example, and extensive protocol/concurrency evidence without introducing a backend or authorization system.

Sequence diagram for native adapter preflight and single exchange

sequenceDiagram
    participant Caller
    participant Client as NativeAdapterClient
    participant Adapter as NativeAdapter
    participant Backend as AuthorizedBackend

    Caller->>Client: call(request)
    Client->>Client: prepare_adapter_request()
    alt unsupported capability or invalid ABI/frame
        Client-->>Caller: AdapterRefusal(dispatched: false)
    else preflight passes
        Client->>Adapter: exchange(encoded_request, response_limit)
        Adapter->>Backend: authorized SDK operation
        Backend-->>Adapter: canonical output or refusal
        Adapter-->>Client: encoded reply
        Client->>Client: check_adapter_reply()
        Client-->>Caller: AdapterReply or dispatched refusal
    end
Loading

Flow diagram for uncertain native mutation outcomes

flowchart TD
    A[Caller submits claim or release] --> B["prepare_adapter_request()"]
    B -->|Capability or validation failure| C[Refusal: dispatched false]
    B -->|Preflight passes| D["exchange() starts"]
    D --> E{Reply received and correlated?}
    E -->|Yes| F[Preserve canonical receipt or backend refusal]
    E -->|No| G[Refusal: dispatched true]
    G --> H[Reconcile authoritative receipts before retrying]
    F --> I[Caller interprets ownership, skip, or peer-success receipt]
Loading

File-Level Changes

Change Details Files
Introduces a versioned, bounded JSON byte ABI and typed Rust client for explicitly supplied authorized adapters.
  • Defines strict manifest, request, response, capability, refusal, size, correlation, and ABI validation rules.
  • Adds one-shot dispatch with no retries while preserving canonical backend outcomes, receipts, refusals, and uncertain-dispatch state.
  • Exposes get, paginated list, claim, and owner-checked release operations through the NativeAdapter boundary.
src/native_adapter.rs
src/lib.rs
README.md
docs/native-adapter-abi.md
Adds an offline compatibility-checking CLI that does not discover or execute a backend.
  • Adds adapter-check with bounded stdin admission and compact JSON/TOON compatibility receipts.
  • Defers workspace discovery until commands require it so adapter checks work without Git, Node, or a tracker.
  • Adds CLI unit and contract coverage for malformed transcripts, recorded refusals, and no-execution behavior.
src/main.rs
tests/native_adapter_contract.rs
README.md
Provides a compilable read-only adapter example and public real-data validation tooling.
  • Implements an explicitly selected workspace adapter granting only get and list.
  • Validates paginated reads and item identity against the published SDK while checking source immutability and no Git/Node availability.
  • Documents measured evidence, reproduction steps, limits, and integration responsibilities.
examples/native_adapter.rs
scripts/native-adapter-validate.mts
docs/evidence/native-adapter-2026-10-24.md
Adds focused conformance, concurrency, and behavioral-regression tests for adapter safety.
  • Tests capability admission before transport, strict ABI and field limits, canonical outcome preservation, correlation, and frame failures.
  • Exercises claim and release races at six adapter boundaries on a shared tracker, including foreign-release protection.
  • Uses targeted revert proofs to demonstrate that capability checks, ABI checks, and receipt preservation are required.
tests/native_adapter_contract.rs
scripts/native-adapter-revert.mts
Integrates the new feature into project planning and TypeScript validation gates.
  • Adds the feature record and history entry.
  • Includes native adapter scripts in TypeScript compilation and ESLint checks.
.agents/pm/features/pm-rust-portable-native-adapter-abi.toon
.agents/pm/history/pm-rust-portable-native-adapter-abi.jsonl
justfile
tests/harness/eslint.config.mjs
tests/harness/tsconfig.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@unbraind unbraind left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Orchestrator review (built-in Claude review agent, verified by the orchestrator; bots are not waited for since 2026-10-22):

Pre-merge review (codex gpt-6.1-sol read-only review agent; merged by the orchestrator's pipeline after a MERGE verdict and a private-data scan of the added lines).

VERDICT: MERGE
FINDINGS:

  • none
    SUMMARY: The PR adds a bounded native adapter ABI, tracker-free validation CLI, and recursive duplicate-key rejection. Tests thoroughly cover admission, receipt preservation, uncertain outcomes, and non-git ownership interleavings; I reviewed them without rerunning them.

@unbraind
unbraind merged commit 8135545 into main Oct 24, 2026
18 checks passed
@unbraind
unbraind deleted the feat/portable-native-adapter-abi branch October 24, 2026 17:38
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.

1 participant