Skip to content

impl(011): the service registers local backends from configuration and joins the local-embed case (3.17.3, 3.17.5) - #535

Merged
bartekus merged 2 commits into
mainfrom
impl/011-serve-local-embed
Nov 6, 2026
Merged

bartekus merged 2 commits into
mainfrom
impl/011-serve-local-embed

Conversation

@bartekus

@bartekus bartekus commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Spec 011 3.17.3 and the service half of 3.17.5. Stacked on #534 (the manifest half: the local-embed feature and its optional dependency).

  • Configuration at startup (3.17.3). With local-embed, rustev-serve --config FILE --local-embed FILE opens spec 011's local embedding backend once per entry of the second file: a JSON object from binding name to bundle_dir, optional runtime_path, expected_artifact, workers and max_queued (3.7.1's members the backend takes today; unknown members refused, so embedding_cache is refused until the configuration takes it). Each name must be a backend_bindings entry of rustev.serve-config/1 whose backend is {"compiled": {"feature": "local-embed"}}, and every such binding must be configured. The service then checks the opened descriptor against the binding's expected DescriptorId, as for any compiled backend. Bundles are verified on a blocking thread before any listener starts; a setup refusal stops startup, naming the binding and its 3.7.2 code. Embedding hosts use local_embed::open_all with sinks::standalone_with_backends.
  • No request names a bundle, path or runtime. Registration binds a plan's backend id to a binding name, and every service document refuses unknown members.
  • Without the feature (3.20.2). A configured local backend is refused feature_disabled. The resolved graph holds no crate of the 3.18 family. The image build is unchanged and does not enable the feature.
  • Parity (3.17.5). The case local-embed.support-routing now names serve-http and serve-grpc; the case file and manifest were re-blessed. Only the surfaces list changed; no fixture or expected output changed. The service's conformance runner (tests/conformance/local_embed.rs) opens the committed SYNTHETIC bundle through the same local_embed::open. It decides the five requests one after another on the manual clock over the mutual-TLS TCP listener and the Unix socket, through HTTP and gRPC, and compares each result, judgment and delivered run record byte for byte with the case's bytes. Those are the bytes the Rust API and the native binding produce. Per listener the HTTP and gRPC answers are byte-identical. Without the feature the runner checks that the case's backend is refused feature_disabled.
  • make conformance runs cargo test -p rustev-serve --locked --features local-embed --lib local_embed.
  • Spec 011 gains an additive extends edge on integrations/rustev-serve/ (owned by 010) and a dated 2026-11-06 Implementation record paragraph. The implementation: frontmatter is untouched.

Checks (local, darwin-arm64)

  • cargo fmt --all --check
  • cargo clippy -p rustev-serve --all-targets --locked -- -D warnings, with and without --features local-embed
  • cargo test -p rustev-serve --locked, with and without --features local-embed
  • cargo test -p rustev-conformance --locked
  • cargo test -p rustev-backend-embed-linear --locked --test bundle support_routing::conformance::
  • make boundaries (cargo run -p rustev-boundaries) and cargo test -p rustev-boundaries --locked
  • cargo tree -p rustev-serve -e normal,build without the feature: no family crate
  • The binary: without the feature, --local-embed stops startup with feature_disabled; with it, the bundle opens and the binding's expected descriptor is enforced
  • make gate

@bartekus bartekus added the statecraft:stacked-ci Run the full CI matrix on a stacked pull request label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff against the governance context and the spec text.

Code analysis

local_embed.rs — open_all, parse, open: Logic is correct. The two-loop cross-check (every local-embed binding must have a configured backend, every configured backend must be a local-embed binding) is symmetric and matches the spec text. The two cfg-gated open functions compile cleanly under their respective conditions.

main.rs — argument parsing: The slice pattern handles exactly the two documented invocation forms. args[1] is the config path in both branches. No path confusion.

local_embed.rs — base64url: Manual base64url implementation verified: 3-byte → 4 chars, 2-byte → 3 chars, 1-byte → 2 chars, correct 6-bit extraction via shift and mask. Round-trip test covers the helper.

runner.rs — principal header override: The header is emitted once from extra or the default, then extra is filtered before the loop. Correct; no duplicate header.

Spec update: The new extends edge (010-integrations, integrations/rustev-serve/, additive) is consistent with spec 010 owning that directory and 011 adding to it. The increment paragraph follows the established narrative format.


Finding

Makefile line 108 — conformance command targets only lib tests, not the transport integration tests.

cargo test -p rustev-serve --locked --features local-embed --lib local_embed

--lib runs tests in the library target (src/local_embed.rs, the mod tests block). The comment immediately above says "the same cases through the service's transports" and the spec increment text states both integrations/rustev-serve/src/local_embed.rs and tests/conformance/local_embed.rs are covered. The transport-level tests — every_local_embed_case_through_both_transports_and_listeners and the feature-disabled check in tests/conformance/local_embed.rs — live in the conformance integration-test binary and require --test conformance, not --lib. As written the command never exercises the HTTP or gRPC transports the comment claims to cover.

The correct invocation to also cover the conformance integration tests would be cargo test -p rustev-serve --locked --features local-embed --test conformance local_embed:: (or equivalently a combined invocation).

{"head": "34773443953586e5610964a83a2060805af3e38e", "verdict": "findings", "findings": [{"path": "Makefile", "line": 108, "severity": "medium", "category": "correctness", "summary": "The conformance command uses --lib which only runs src/local_embed.rs unit tests; the transport-level integration tests in tests/conformance/local_embed.rs require --test conformance and are never executed by this target, contrary to the comment and spec text."}]}

Subject: 230fa18...3477344, diff digest 63910ef5d50fd5702e8302b28725946ff1605407d1441df6a2a0f4baa5418796, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 6, 2026 19:04 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff for bugs, security issues, and inconsistencies.

integrations/rustev-serve/src/local_embed.rs — open_all: The two-pass validation is correctly bi-directional: the first loop ensures every local-embed binding in the config has a corresponding entry in local; the second loop ensures every entry in local is backed by a local-embed binding. When the feature is off and local backends are configured, the #[cfg(not(feature = "local-embed"))] open variant returns Err("feature_disabled: …"), propagating correctly to main. No defect.

integrations/rustev-serve/src/main.rs — argument parsing: Both match arms correctly identify args[1] as the config file. The --local-embed FILE path is args[3]. Empty local (no --local-embed) flows correctly to open_all returning an empty map, preserving the existing default path. No defect.

integrations/rustev-serve/tests/conformance/local_embed.rs — base64url: The fold packs bytes into bits 23..0, then 0..=chunk.len() extracts the right number of 6-bit groups. Round-trip is verified by the_principal_header_round_trips. No defect.

integrations/rustev-serve/tests/conformance/runner.rs line ~913: The assertion guard now reads c.command == "run" || c.runtime.is_some() || c.local_embed.is_some(), but the function is still named every_serve_case_is_a_run_or_a_runtime_case. The name now misclassifies the third accepted category. This is a low-severity naming inconsistency.

specs/011-semantic-backend/spec.md — extends edge: The additive extends edge toward 010-integrations over integrations/rustev-serve/ is consistent with how spec 011 extends spec 027's directories, and with the files this PR adds. No defect.

No security issues found: the config file is host-controlled, deny_unknown_fields on LocalEmbedConfig prevents field smuggling, the MAX_CONFIG_BYTES and MAX_BACKENDS guards limit resource use, and no request path can name a bundle or runtime path.

{"head": "95aa4b84555c1c6f06dd455c4c319ea375fb4357", "verdict": "findings", "findings": [{"path": "integrations/rustev-serve/tests/conformance/runner.rs", "line": 913, "severity": "low", "category": "correctness", "summary": "Function is still named every_serve_case_is_a_run_or_a_runtime_case after a third accepted category (local_embed.is_some()) was added, making the name inconsistent with the guard."}]}

Subject: 230fa18...95aa4b8, diff digest 55118ffae8e8d9e1f88fc35f591d49c01cd2788a8dd75f2a3a2cced37247a337, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 6, 2026 19:16 — with GitHub Actions Inactive
@bartekus
bartekus temporarily deployed to statecraft-review-exception November 6, 2026 19:17 — with GitHub Actions Inactive
@bartekus

bartekus commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Review note: the low-severity naming finding on every_serve_case_is_a_run_or_a_runtime_case (runner.rs) is left as is on purpose: spec 042's implementation record cites the test by that name, so renaming it means a 042 text edit for no behavioral gain. The guard itself is correct: a serve case is a run case, a runtime case or (now) a local-embed case. The exception is approved once this PR targets main.

Base automatically changed from impl/011-serve-features to main November 6, 2026 19:52
@bartekus
bartekus force-pushed the impl/011-serve-local-embed branch from 95aa4b8 to 421d7ab Compare November 6, 2026 19:53
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff across all changed files for correctness, security, and consistency with the governance context.

integrations/rustev-serve/src/local_embed.rs

  • open_all is not feature-gated but calls the feature-gated open(). Both variants of open() are defined (cfg(feature) / cfg(not(feature))), so the call always resolves. The symmetry check (every local-embed binding must be in local; every entry in local must be a local-embed binding) is correct.
  • Paths are passed through to the backend, which the test confirms refuses relative paths (bundle_missing). The host-only path model is enforced: the config is read once at startup, service documents use deny_unknown_fields, so no request can supply a bundle path.
  • #[serde(deny_unknown_fields)] on LocalEmbedConfig correctly refuses embedding_cache until it is added.
  • MAX_CONFIG_BYTES and MAX_BACKENDS provide reasonable resource guards.

integrations/rustev-serve/src/main.rs

  • Argument parsing accepts exactly --config FILE or --config FILE --local-embed FILE in that order. Positional access args[1] is consistent with both match arms. Order-fixed CLI is a mild UX issue but not a defect.
  • Blocking I/O (bundle reads) is correctly moved to spawn_blocking before listeners start.

tests/conformance/local_embed.rs

  • base64url implementation: for a chunk of k bytes, 0..=k produces k+1 output characters (4 for 3 bytes, 3 for 2 bytes, 2 for 1 byte). The index arithmetic correctly extracts successive 6-bit groups from the 24-bit integer. Standard unpadded base64url output lengths match.
  • The rustev-principal header override in runner.rs (find in extra, fall back to PRINCIPAL, then filter duplicates) is correct.
  • every_local_embed_case_names_both_serve_transports runs unconditionally; every_local_embed_case_through_both_transports_and_listeners is #[cfg(feature = "local-embed")]; without_the_feature_… is #[cfg(not(feature = "local-embed"))]. The gate pairing is correct.
  • drive_local calls local_embed::open(FEATURE, &c) using the constant string "local-embed" as the binding name; this is used only in error messages inside open, not in any validation path, so it is cosmetically inconsistent but not a defect.

specs/011-semantic-backend/spec.md

  • Adds an extends edge to integrations/rustev-serve/ owned by spec 010 with nature: additive. This is the correct instrument (not establishes/amends) for a secondary spec extending a directory it does not own.
  • The new increment paragraph documents behaviour that matches the code (feature flag, symmetry validation, blocking open, feature_disabled for no-feature builds, case surface additions).
  • No frontmatter (status/implementation) is changed in this diff; no ratification claim is made.

backends/rustev-backend-embed-linear/tests/support_routing/conformance.rs

  • Adds "serve-http" and "serve-grpc" to the case's surfaces list, consistent with the new conformance runner that now drives those transports.

No concrete defects found.

{"head": "421d7ab02b3079b974b7b26b6fe0f85f9a1825a6", "verdict": "no-findings", "findings": []}

Subject: 101bbd8...421d7ab, diff digest 55118ffae8e8d9e1f88fc35f591d49c01cd2788a8dd75f2a3a2cced37247a337, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 6, 2026
@bartekus
bartekus removed this pull request from the merge queue due to a manual request Nov 6, 2026
…d joins the local-embed case (3.17.3, 3.17.5)

With its `local-embed` feature, `rustev-serve --config FILE --local-embed
FILE` opens spec 011's local embedding backend once per entry of the
second file (binding name to bundle_dir, runtime_path, expected_artifact,
workers, max_queued; unknown members refused), each bound under a
`backend_bindings` entry whose backend is the compiled feature
`local-embed`. Bundles are verified on a blocking thread before any
listener starts; a setup refusal stops startup with its 3.7.2 code. Only
the host names a bundle, path or runtime. Without the feature a
configured local backend is refused `feature_disabled`, and the resolved
graph holds no crate of the local inference family (3.20.2).

The case `local-embed.support-routing` now names `serve-http` and
`serve-grpc`. The service's conformance runner opens the committed
SYNTHETIC bundle through the same code, decides the five requests over
both transports and both listeners on the manual clock, and compares each
result, judgment and delivered record byte for byte with the case's
bytes, the same the Rust API and the native binding produce. `make
conformance` runs it with the feature. Spec 011 gains the extends edge on
the service and a dated record paragraph.
@bartekus
bartekus force-pushed the impl/011-serve-local-embed branch from 421d7ab to a75a1f2 Compare November 6, 2026 20:56
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff for bugs, security issues, and inconsistencies.

integrations/rustev-serve/src/local_embed.rs

open_all bijection logic: The two-loop design correctly enforces the bijection — first loop ensures every local-embed binding has a configured backend; second loop ensures every configured backend is a local-embed binding. The unit test covers all four cases (missing config, unbound name, wrong feature, empty/empty). ✓

LocalEmbedConfig / parse: deny_unknown_fields correctly enforces the spec's requirement that embedding_cache is refused until the configuration supports it. The 64 KiB cap and 16-backend cap are both checked. ✓

open feature-gating: Both variants (#[cfg(feature)] / #[cfg(not(feature))]) compile cleanly and return the same Result shape. Without the feature the error carries feature_disabled as required. ✓

integrations/rustev-serve/src/main.rs

Argument parsing: Only --config FILE and --config FILE --local-embed FILE (in that order) are accepted; args[1] is the config path in both matched arms. The reverse order is rejected with a usage error — consistent with the stated usage string. ✓

spawn_blocking for open_all: Correctly offloads the bundle-verification I/O off the async executor before any listener starts. ✓

integrations/rustev-serve/tests/conformance/local_embed.rs

base64url: 0..=chunk.len() produces 4 chars for a 3-byte chunk, 3 for 2, 2 for 1 — correct unpadded base64url. The bit-math n | (*b as u32) << (16 - 8*i) packs bytes at bits 23-16, 15-8, 7-0; extraction at shifts 18, 12, 6, 0 covers all 6-bit groups. The round-trip assertion covers the edge cases. ✓

drive_local calls open(FEATURE, &c): FEATURE ("local-embed") is passed as the binding name. In the conformance setup backends: vec![(FEATURE.into(), …)] registers the backend under that same name, so the name is consistent throughout. ✓

differential check: Called after all listener/transport combinations, ensuring byte-identity across HTTP and gRPC answers per listener. ✓

backends/rustev-backend-embed-linear/tests/support_routing/conformance.rs

Adding "serve-http" and "serve-grpc" to the case's surfaces is consistent with every_local_embed_case_names_both_serve_transports asserting both transports are present, and with the spec text. ✓

specs/011-semantic-backend/spec.md

The additive extends over integrations/rustev-serve/ through spec 010-integrations follows the same pattern already used for integrations/rustev-node/ and tools/rustev-conformance/. The increment text accurately describes the implementation: --local-embed FILE, the bijection check, open_all / spawn_blocking, feature_disabled without the feature, and the case surface addition. ✓

Makefile

cargo test -p rustev-serve --locked --features local-embed --lib local_embed runs unit tests in src/local_embed.rs and, via the existing lib-module include established by spec 042 increment 5, the conformance tests under conformance::local_embed::. The comment references that prior increment correctly. ✓

No concrete defects found.

{"head": "a75a1f28abdeb0d090ff2c86e1170805096da28a", "verdict": "no-findings", "findings": []}

Subject: 61260fb...a75a1f2, diff digest 1d669f5a234475e43ab4af9726dbd5695633e96b3e5b668cc3376f8f4070d142, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit 7964d55 Nov 6, 2026
47 checks passed
@bartekus
bartekus deleted the impl/011-serve-local-embed branch November 6, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

statecraft:stacked-ci Run the full CI matrix on a stacked pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant