Skip to content

refactor(sdk): hold discovery observations beside their queries - #12686

Merged
kaofelix merged 55 commits into
v1from
discovery-observations-map
Oct 7, 2026
Merged

kaofelix merged 55 commits into
v1from
discovery-observations-map

Conversation

@kaofelix

@kaofelix kaofelix commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

DiscoveryObservations now lives in nemoclaw_sdk::discovery beside DiscoveryQuery, and a Query trait pairs each query kind with its observation type. Authoring no longer depends on nemoclaw-discovery. This is the follow-up #12579 names under "Not in this PR". #12579 has merged, so this targets v1 directly.

Changes

  • One get<Q: Query>(&Q) -> Option<&Q::Observation> replaces the engine, inference and credential getters, and assess_target uses typed lookups instead of matching both enums.
  • The four inline query variants become HardwareRequest, FabricRequest, GatewayRequest and CredentialRequest, like DiscoveryRequest and EndpointRequest.
  • A shared distinct helper replaces the three duplicate-skipping loops.
  • observe stays in nemoclaw-discovery and returns the SDK type.
  • The collection stays a Vec in recording order, not a BTreeMap. A keyed map needs Ord, and FabricRequirements holds a serde_json::Value, which has none.

Evidence

  • Behavior is unchanged. The existing tests pin it and changed only where they named a removed getter, the moved path, or built an inline variant. The round-trip test and the podman-only.json replay fixture are untouched, so the list format and JSON shape are the same.
  • Authoring no longer depends on the read crate. cargo tree -p nemoclaw-authoring no longer lists nemoclaw-discovery.
  • Correction to the premise: authoring still links bollard, tonic, reqwest and hyper. They arrive through nemoclaw-sdk, so this removes the read crate's own code and the layering inversion, not those transitive crates.
  • Native CI passed on macOS through the cargo ci expansion, and GitHub CI passed on Windows and Linux, which a local run cannot cover.

Not in this PR

Shrinking the image query's key to {engine, image} changes when an image counts as unobserved, so it is a behavior change and needs a decision first.

kaofelix and others added 30 commits October 2, 2026 16:18
Authoring and onboarding build their own discovery queries and have
drifted from the plan path: an Anthropic provider without an explicit API
is probed with a different API in onboarding than in plan. The SDK plan
path is the reference for those inputs, but only `is_object()` assertions
covered it, so a refactor of its query construction could change what is
probed without a test failing.

Pin the engine, Fabric, endpoint, and hardware data-source inputs and the
discovery outputs for the onboarding example and for a service-backed
route, which plan deliberately does not probe as an endpoint. The fixtures
were generated from the unmodified SDK, so this characterizes existing
behavior and passes without any code change. Later commits that extract
shared query construction must leave these fixtures byte-identical.

Validated with `cargo test -p nemoclaw-sdk --test discovery_graph`.
`endpoint_requests` resolved each selected provider's endpoint, API
default, and credential inline, so a caller holding one provider, such as
authoring, had to repeat that logic. Authoring repeated it with a different
API default, which probes an Anthropic provider as OpenAI completions.

Move the per-provider step into `EndpointRequest::for_external_provider`.
It needs only the provider: an external endpoint never consulted the
document, and a service-backed provider returns `None` exactly where the
loop skipped it. Validation, deduplication, and ordering stay in
`endpoint_requests`, and the skip still precedes `target()`, so no
provider that was skipped before can now fail.

This changes no plan behavior: the pinned discovery graph fixtures and the
460 existing SDK tests pass unchanged.
Onboarding built its model-catalog request with its own copy of the
SDK's rule and a different API default. A provider without an explicit
`api` was probed as OpenAI completions in onboarding but as its protocol
default in plan, so an Anthropic provider listed models over the wrong
protocol and the endpoint evidence could not match the plan's read.

Authoring now resolves the selected route's provider and builds the
request with `EndpointRequest::for_external_provider`, the same function
`endpoint_requests` uses. The new test fails before this change with
`OpenaiCompletions` where `AnthropicMessages` is expected.

Authoring also stopped incidentally fetching models from the endpoint of
a managed service. Planning deliberately skips those, because the service
owner checks readiness, and reading external catalogs during onboarding
should be an explicit feature rather than a side effect. A service-backed
route now has no endpoint request, so `inference_request_for_document`
returns `Option`; suggestions do not apply to it, bulk delegation reports
that there is no catalog to verify, and the TUI skips the inference query
without dropping engine or image evidence. The managed Ollama test now
asserts this instead of the old service-endpoint probe.

Validated with `cargo test -p nemoclaw-authoring -p nemoclaw-onboarding`
(182 passed), the SDK suite, and clippy on all three crates.
…urces

Authoring keeps what it learns about the target in two partial structs,
`AuthoringFacts` and `DiscoveryEvidence`, that are matched back to a
document by key, and the TUI decides what to query. Decisions therefore
cannot be tested without a live bundle, and a new interface would repeat
the orchestration.

Add `FactSheet`, a serializable record of facts keyed by the query that
produced them, so a fact for one engine, image, or endpoint can never be
read as a fact about another. A recorded attempt with no observation is
distinct from a query never asked, so a failed read is not repeated
forever. `FactSource` answers queries: `DiscoverySession` implements it
over the same provider plan and gateway read the TUI used, and
`FixtureFacts` replays a recorded sheet, which lets decisions be tested
against any hardware. `gather` runs the observe-and-merge loop, lets a
read depend on an earlier fact, and gives up after a bounded number of
rounds.

Nothing consumes the module yet; authoring and the TUI move to it in the
following commits. The provider-backed source reuses `DiscoverySession`
unchanged and is covered by its existing live tests; the new tests cover
the sheet, the fixture source, and the gather loop.

Validated with `cargo test -p nemoclaw-sdk --test facts` and clippy.
The TUI decided what to query for a document in `discovery_queries` and
`observe_target`, so another interface would have to repeat it and nothing
checked it against what planning reads for the same document.

Add `fact_needs`, which returns the `FactQuery` list for an SDK-valid
document: the engine, image, hardware, endpoint, gateway, and credential
reads. The endpoint request is the SDK's per-provider construction, and
the rest come from the engine, image, and gateway the document names.

Conformance tests compare these queries with the data-source inputs that
`compile::compile` produces for the same documents. A managed gateway with
a hosted route and an external gateway read exactly what plan reads. Two
differences are deliberate and now named in tests: plan also reads the
hardware of each managed service's engine, which onboarding skips until a
decision consumes it, and plan compiles an image read with an empty engine
for an external gateway with none, only to fail with "set
spec.gateway.engine", where onboarding makes no read and reports it.

The TUI still builds its own queries; it moves to `fact_needs` with the
rest of its fact handling in a following commit.

Validated with `cargo test -p nemoclaw-authoring --test fact_needs`.
Authoring kept target facts in `DiscoveryEvidence` and `AuthoringFacts`,
matched to a document by key, and the TUI decided what to query and built
both from provider results. Decisions could not be tested without a live
bundle, and every fact needed hand-written key bookkeeping to avoid being
applied to the wrong engine, image, or endpoint.

`JourneyState::resolve_with_facts` and `delegate_remaining` now read an SDK
`FactSheet`, and `assess_target` replaces `DiscoveryEvidence`. Facts are
keyed by their query, so a fact read for another engine, image, driver, or
endpoint is not found rather than filtered out. The TUI holds one sheet,
asks `fact_needs` for what the document requires, and reads it through
`DiscoverySession` in one provider round, replacing `observe_models`,
`observe_target`'s result handling, `discovery_queries`, and the removed
evidence types. It still re-reads the whole set at delegation and at review,
and asks for a route's model catalog once per endpoint.

Two behaviors change deliberately. A read that was attempted and observed
nothing is now unverified and is not asked again, as the previous doc
comment already described, where before it was indistinguishable from a read
never made. An empty sheet leaves the resolution unchanged, as passing no
evidence did.

The authoring tests that built evidence by hand now build sheets, and the
cases that depended on key mismatch now assess a changed document against
the old sheet. The two TUI tests of `discovery_queries` are covered by the
conformance tests of `fact_needs`.

Validated with `cargo test -p nemoclaw-authoring -p nemoclaw-onboarding
-p nemoclaw-sdk --test facts` (151, 35, and 8 passed) and clippy on the
three crates.
The runtime question took its suggestion from the template, so a host that
only runs Podman was offered Docker by default. Nothing about the machine
was known before the first question, because every fact was read from an
SDK-valid document that the early answers had not yet produced.

`environment_needs` names the reads that need no answers: whether the
local Docker and Podman engines are available. The TUI reads them once,
before the first question, with the intro screen already drawn, and records
a failed attempt so it is not repeated. When exactly one engine is
available, `resolve_with_facts` makes that runtime the suggestion, even over
a supplied value, and the user still decides; with both or neither the
template's runtime stays. The engine sockets now live in one place that the
gateway-engine sync, the probe, and the suggestion share.

The decision is tested without any engine by replaying recorded sheets
through `FixtureFacts` and `gather`, for a host with only Docker, only
Podman, both, and nothing, and the wizard test shows Enter accepting the
Podman suggestion. The candidates are the two local default sockets.
Neither V0 nor V1 detects SSH hosts, so none is invented here.

Validated with `cargo test -p nemoclaw-authoring --test environment_facts`
and the wizard test in `cargo test -p nemoclaw-onboarding`.
The SDK's convention is that a read which could not be made is returned as
an unknown observation with its reason, never as absence, but only some
observation kinds could say so: endpoint observation had a private
constructor, gateway observation built one only from a read error, and
engine and Fabric observations had none. Callers that needed to record a
failure invented their own way to say "nothing observed".

Give engine, Fabric, gateway, endpoint, and hardware observations a public
unknown form that carries a reason, and add `Credential` to
`DiscoveryObservation` so credential availability travels in the same enum
as every other observation. The plan report and the CLI formatting each get
the matching arm; the plan never produces a credential observation, so
their output does not change.

This is groundwork for one observation vocabulary: the next commit uses
these constructors to replace a parallel set of types.

Validated with `cargo test -p nemoclaw-sdk --test unknown_observations`
and a build of every workspace target.
The SDK already names a typed result of a read an observation, the activity
discovery, and a read that could not be made an unknown observation, but the
previous commits added a parallel set of types for the same things:
`FactQuery` and `Fact` duplicated `DiscoveryQuery` and `DiscoveryObservation`,
`facts.rs` carried glue to translate between them, authoring kept its own
`DiscoveryQuery` for pending reads, and a failed read had a second spelling,
"attempted without an observation". `DiscoverySession` also kept typed
methods for each read that only the e2e test called.

Use the existing vocabulary and delete the duplicates. `DiscoveryQuery` gains
the gateway and credential reads and `DiscoveryObservation` already carries
their results. `DiscoveryObservations` is the one new concept: observations
keyed by the query that produced them, so a lookup by inputs cannot return an
observation about another engine, image, or endpoint. `DiscoverySource`,
`RecordedDiscovery`, and `discover` replace the fact source, its fixture, and
the gather loop, and live beside the session that implements the source.
The `facts` module is gone, along with the session's typed methods and
single-query helper.

A failed read is now an unknown observation with its reason, the SDK's existing
convention, so `assess_target` loses its two "attempted but empty" arms, the
TUI loses its separate "unavailable" results, and `assessment.pending` holds
the real SDK queries still to ask. In authoring, `facts.rs`, `evidence.rs`, and
the evidence module of the journey state become `discovery_queries.rs`,
`target_assessment.rs`, and `observations.rs`; `fact_needs`,
`environment_needs`, and `resolve_with_facts` become `discovery_queries`,
`environment_queries`, and `resolve_with_observations`, and the recorded
fixtures move to `tests/fixtures/observations`. The e2e discovery test reads
through `observe`, so the real source now has end-to-end coverage.

Behavior changes: with no provider session the TUI records unknown
observations, so delegation reports that compatibility is not verified instead
of a separate "target discovery is unavailable" message. The SDK's public
`DiscoverySession` methods and `DiscoveryQuery` shape change, and
`DiscoveryObservation` gains a `Credential` variant. The plan graph is
unchanged, which the pinned discovery snapshot confirms.

Validated with the SDK (471), authoring and TUI (191) test suites, clippy and a
build of every workspace target.
A plan's discovery reads were built by hand in `discovery_graph::populate`:
the endpoint, hardware, engine, and image data-source inputs were each
written out as JSON, duplicating how `DiscoveryQuery::data` maps the same
reads to data-source inputs for an onboarding session, with a second copy of
the `literal` escape. Which reads a document needs was likewise implicit in
that function, so nothing but a comparison test could say that onboarding and
planning ask the same questions.

Add `plan_queries`, which lists the reads a plan makes for a document as
`DiscoveryQuery` values: the gateway, each external inference endpoint, the
hardware of every service and managed gateway engine, a managed gateway's
engine, and one image read per sandbox in name order. `populate` now walks
that list and takes each read's inputs from `DiscoveryQuery::data`, adding
only what a plan needs on top: the lifecycle postconditions, and for each
sandbox its Fabric requirements and the engine's platform. The compute
drivers the gateway must support come from one `gateway_drivers`, which
`graph_base` shares, and `literal` is defined once.

The plan does not change. Three pinned graphs, for a managed gateway with a
hosted route, a service-backed route, and an external gateway with a service
on another engine and no image engine, are byte-identical before and after,
and the 471 existing SDK tests pass unchanged. Tests also pin the query list
for each of those documents.

Validated with `cargo test -p nemoclaw-sdk` (476 passed).
Onboarding derived its own list of queries for a document, separately from
the list a plan compiles, and a test compared the two by parsing the compiled
graph. The two could only be kept in step by that comparison.

`discovery_queries` now starts from the SDK's `plan_queries` and applies
three named exclusions, then adds the credential checks. Only the selected
route's inference catalog is read, because the journey edits one route at a
time. Hardware is read only for the managed gateway's engine, not for each
managed service's, until a decision consumes it. And a query for an
unresolved engine is dropped, because there is nowhere to read an image from
and the TUI never targets a local daemon for one; the target assessment
reports the missing engine instead. Everything else is the plan's, so
the same document yields the same reads in the same order by construction.

The tests no longer parse the compiled plan: they assert that onboarding asks
what `plan_queries` returns plus credentials for a managed and an external
gateway, that only the selected route's catalog is read, and each named
exclusion. The graph comparison now lives once in the SDK's pinned snapshots.

Validated with `cargo test -p nemoclaw-authoring -p nemoclaw-onboarding`
(191 passed), clippy, and a build of every workspace target.
v1 now builds each crate's integration tests as a single binary from
`tests/main.rs` with `autotests = false`, so a test file that is not declared
there is neither built nor run. Git merged the branch without a textual
conflict, but the merge left this branch's tests unregistered and
`authoring/tests/main.rs` pointing at `discovery_graph.rs`, which this
branch renamed to `target_assessment.rs`.

Register the SDK's `discovery_graph`, `discovery_observations`, and
`unknown_observations` tests, and the authoring crate's `discovery_queries`,
`environment_observations`, and `target_assessment` tests, so they are built
and run. No other file needed a hand edit.

Validated with the SDK (467), authoring, and onboarding suites, clippy, and a
build of every workspace target; the new test modules were checked by name to
confirm they execute.
Bring in the five e2e service-lifecycle commits that landed on v1 after the
previous merge. They touch only the e2e crate and none of this branch's files.
Checked that every single-binary test crate has no unregistered or dangling
test module from this branch, and that the workspace builds and lints clean.

Validated with the SDK, authoring, and onboarding suites (696 passed) and a
clippy run over every workspace target.
…essment

`assess_target` returned a `pending` list of the queries that were never
asked, computed so that the image read would wait for the engine read. Its
only consumer outside tests was `check_delegation`, which used it to say that
target discovery was missing; the TUI never used it. It asks the whole
`discovery_queries` set in one round, and nothing fed `pending` into
`discover` to sequence reads, so the dependency ordering it computed drove
nothing.

Remove the field and its bookkeeping. An observation that was never made is
already reported as unverified with a reason, as is a read that failed, so
delegation still refuses either way. The one visible change is the message for
a never-observed target, which now reads "Target engine and image
compatibility is not verified" instead of "Target discovery is missing or
stale"; no test asserted either text.

The assessment tests that compared `pending` now assert the reasons the
assessment still gives: an observation made for another engine or image "has
not been observed", while a failed read "remains unverified", which keeps the
distinction those tests were written to protect.

Validated with `cargo test -p nemoclaw-authoring -p nemoclaw-onboarding`
(229 passed) and clippy on both crates.
… field

`DiscoveryKey` was a public bag of the engine, image, compute driver, and
harness a document's target is read through. It once matched stored evidence
to a document, but that matching is gone: the observations are now found by
the query that produced them. Its `harness` field was never read, only
populated, and the key was public mostly so tests could build fixtures. It
duplicated what the queries from `plan_queries` already carry.

Make it a crate-private `Target` with the four fields that are used, read by
`assess_target` and `discovery_queries`, and stop exporting it and
`discovery_key_for_document`. Dropping the harness field also drops the
harness lookup that populated it; that lookup only surfaced an error that the
Fabric requirements built for the same document report anyway.

The tests no longer reach into the crate for the engine, driver, and image:
the authoring tests read them directly through one small `support::target`,
declared once in the single test binary, and the TUI test takes its engine
query from the public `discovery_queries`, the same list the TUI asks.

Validated with `cargo test -p nemoclaw-authoring -p nemoclaw-onboarding`
(229 passed) and clippy over every workspace target.
…uses it

The Docker and Podman socket table lived in `discovery_queries.rs` because
`environment_queries` is built from it. Two other things used it: the
gateway-engine sync in `authored_values.rs`, and `reachable_runtimes`, which
reads observations to suggest a runtime. So the runtime decision was asked in
one file, interpreted in a second, and applied in a third, and
`discovery_queries.rs` held a function that reads observations.

Move the table, `local_engine`, `environment_queries`, and `reachable_runtimes`
into `local_runtimes.rs`, a module for which local runtimes exist, how to ask
whether each is available, and which the observations show reachable.
`discovery_queries.rs` is left with the queries a document needs and nothing
that interprets an answer. Behavior is unchanged: `environment_queries` is
still exported from the crate root, and the callers only changed their module
path.

Validated with `cargo test -p nemoclaw-authoring -p nemoclaw-onboarding`
(229 passed) and clippy over every workspace target.
The consolidation retired "fact" and "evidence" as names for observations, but
tests still carried them: three assessment tests and a helper said "facts",
two journey tests, one prerequisite test, and one session test said
"evidence", and two doc comments were stale or garbled ("fact sheet"; "hold
the observations ... as a / a journey's"). Rename them to say observations.

The assessment tests assert on the reasons the assessment gives, but a failing
`assert!(says(..))` printed only `false`, so the failure did not show what the
reasons actually were. Replace those with `assert_says` and `assert_silent`,
which print the expected text and the reasons given, and which report the
failing test's own line; the two direct scans of the reasons use them too.

No behavior is asserted differently.

Validated with the authoring integration tests and the session unit tests, and
clippy on both crates.
…ssessment tests

Three test files each hand-built the same engine, image, and Fabric catalog
observations, with `installed_catalog` duplicated: the assessment tests, the
prerequisite tests, and the delegation test. The next change to an
observation's shape would have needed three edits.

Move them into `support.rs`: `installed_catalog`, `available_engine`,
`rejecting_engine`, `installed_image`, and `target_observations`, which records
an engine and an image under a document's own queries. The three files use
them, and the assessment tests keep a small `Observed` wrapper for tweaking one
observation at a time.

Tidy the assessment file while there. Two tests of how the endpoint request is
built, one for a service-backed route and one for the provider's API default,
tested `inference_request_for_document`, not the assessment, so they move to
`discovery_queries.rs`. The bundled test that checked three unrelated outcomes
in sequence is split into three named tests: a catalog without the document's
adapter is a conflict, an image that is not present is unverified rather than
a conflict, and an unknown engine is unverified and says so. A fourth test
repeated the first of those outcomes with a different leftover adapter, so it
is retired; the split test protects the same promise.

Validated with the authoring integration tests (154 passed, one more than
before from the split) and clippy; about 109 fewer lines of test code.
The runtime-suggestion tests used a template that names Docker. Three of the
four hosts expected Docker, so a suggestion that ignored the host, or never ran,
agreed with the template and passed; only the Podman-only host proved the
feature did anything.

Run every host against a template that names Docker and one that names Podman.
A host that has only the other runtime must now override the template in both
directions, a host that has only the template's own runtime confirms it, and a
host with both runtimes or with nothing recorded keeps the template's, so each
policy is checked from both sides. The fixtures are named constants and the
template is a parameter of the helper, replacing the four near-identical
tests with eight that say which case they cover.

Validated with the eight environment tests and clippy.
`DiscoverySession::observe` is the real source for onboarding, and its
convention is that a read that could not be made is an unknown observation, not
a missing one. Its unit tests covered only an engine query and cancellation, so
the failure path, the gateway read, the local credential check, and a round that
mixes them were untested here; a regression that dropped failed reads would
have left them "unasked" and made the TUI retry on every pass.

Add three tests over the existing fake `tofu`, which now serves different output
per call from JSON the test writes. A failed provider plan leaves the engine,
hardware, and gateway queries recorded as unknown with a reason. Credential
availability is read from the process environment without launching OpenTofu,
uses `PATH` and a name that is never set, and the recorded observations never
contain the credential's value. One round that mixes an engine query, the
gateway query, and a credential returns each observation intact and uses a
single initialization for both plans.

Validated with the session unit tests (6 passed) and clippy.
The environment probe and the model-catalog read lived inline in the TUI's
event loop, so nothing could check that they ran, ran only once, or kept what
they learned. A regression that forgot to merge the answers into the
questionnaire, or asked again on every pass, would have passed every test.

Move the decisions and the step out of the loop without changing what it does.
`environment_probe` returns the engines not yet asked about, and
`model_catalog_probe` returns the selected route's catalog query once the
journey is at its model question and that catalog has not been read. `ask_target`
asks the target through the same cancellable wait the loop used and merges the
answers, reporting whether the user escaped. The loop calls them in the same
order, still drawing the screen before the environment probe and not before the
model read.

Two tests drive them without a terminal, using a bundle that does not exist so
every read is recorded as unknown deterministically. A new questionnaire asks
this machine's engines exactly once and records each, and the model catalog is
asked when the model question arrives, not before, and not a second time.

Validated with the TUI tests (72 passed, two new) and clippy.
`discover` repeated observe and merge until a closure's queries were all
answered, so one read could depend on an earlier one. It existed to let the
target assessment's `pending` list sequence reads. That list is gone, and the
TUI asks its queries through `observe` directly, so nothing outside tests
called `discover`: two tests of its own, and the environment tests, which used
it as plumbing where a single `observe` would do. Its dependent-read test also
asserted how many times its closure ran, which pinned the loop's internals and
needed a counter and an inline dependency rule to set up.

Remove `discover` and its round limit, its two tests, and the sentence that
described it. The environment tests ask the recorded source for the
environment queries directly, as the TUI asks the real one. If reads that
depend on earlier reads are wanted later, they can be built against a real
consumer.

Validated with the SDK and authoring tests, clippy over every workspace
target, and a build of all of them; 79 fewer lines.
…bound layers

Plan and onboarding must decide from the same facts, but the SDK holds every read in one enum and computes some judgments in several places. The note maps each DiscoveryObservation variant and related data source to a layer, lists where layers are fused, and lists the duplicated judgments. It describes revision 478f318 and changes no behavior. Validation: nemoclaw-build schema --check and docs --check passed, and git diff --check is clean. The Fern link check did not run because npx timed out fetching fern-api.
DiscoveryObservations::hardware and ::gateway had no caller outside tests, and onboarding asks for both without reading them. Leaving them suggested capabilities the code does not use. The six test call sites now look the observation up by query with get, so the tests assert the same outcomes. Validation: cargo clippy on the sdk and authoring crates is clean, and the sdk discovery tests pass (12 unit, 37 integration).
Plan::discovery_deferred re-parsed each read's raw JSON by name to decide whether it gates the plan, duplicating DiscoveryReport::deferred. Both callers build the typed report first, which fails on any read that does not decode, and every Fabric read is named sandbox_N. For any plan that reaches the classifier the two therefore agree. discovery_deferred now takes the plan's report and adds only the one case the report cannot express: a discovery output OpenTofu cannot compute yet. Its tests now encode typed observations instead of partial JSON the report would reject, and assert the same deferrals. Validation: the 60 deployment unit tests pass and cargo clippy on the sdk is clean.
DiscoveryObservation held both facts a query can establish and reads only a plan can make. RuntimeImage checks an image a resource in the same apply acquires, Service is readiness after install, and Unresolved marks a value OpenTofu computes at apply. Onboarding's DiscoveryObservations could therefore name observations no discovery session ever produces. DiscoveryObservation now has the six query-answerable variants and a status accessor. The plan-only three move to PlanObservation, and DiscoveryReport holds ReportedObservation, an untagged union of the two. The CLI prints this report, so each kind keeps its tag. A new test pins the report encoding for every kind; it passed before and after the split. Validation: cargo clippy on the workspace is clean, and the sdk, cli, and authoring tests pass.
The note described one enum for all layers and three deferral classifiers. Plan-only reads are now PlanObservation, and plan defers only from its typed report, so the note names both types and drops the implications those commits delivered. It now records that a query-keyed report would change CLI output, which is a public contract. Validation: git diff --check is clean.
Onboarding read a sandbox image with only its engine and reference, then recomputed compatibility in authoring with assess_image, gathering requirements and the engine platform itself. Plan instead gave the provider the sandbox's requirements and referenced the engine read's platform in the same graph, so the provider computed the verdict. Both used assess_image, but they assembled its inputs separately.

DiscoveryQuery::Fabric now carries the sandbox's FabricRequirements and, for a managed gateway, the engine request whose platform the image must run on. DiscoveryQuery::data emits both. A discovery session round adds the platform's engine read and references it, the way plan's populate references its engine read, so one round serves the image read. assess_target now looks up the plan's own queries and relays the provider's compatibility, without calling assess_image. Target drops compute_driver and image, and the DiscoveryObservations::fabric getter is gone because it could not build the full key.

Because the image read is now keyed by the sandbox's requirements, an edit that changes them leaves the cached read unobserved until the next read. The TUI already reads the whole target again before it delegates or finishes. assess_target also now requires an SDK-valid document, which its callers already pass. Two tests used image references the schema rejects, and now use valid digests.

Validation: a new session test fails before the change and passes after. It asserts that onboarding's image read has the plan graph's inputs, without plan gating, for a managed and an external gateway. The pinned plan discovery graphs are unchanged. cargo clippy on the workspace is clean, and the sdk, cli, authoring, and onboarding tests pass. The e2e image query keeps a minimal requirement and no platform, so its request count is unchanged; it runs under cargo ci.
The note defined a layer-3 read as one whose inputs reference resources or outputs in the same graph. That wording made the image read layer 3 because it references the engine read, although a discovery session can make both reads. A layer-3 read now references a resource, or a resource consumes its result. The note now records that onboarding relays the image verdict the provider computes from the same query inputs. docs/sdk.md listed session methods that no longer exist and said onboarding ran its own assessment; it now describes observe and the shared image read.

Validation: nemoclaw-build docs and docs --check pass, and git diff --check is clean.
Eight near-identical tests (four hosts by two templates) covered one
three-branch rule: when exactly one runtime answered it is the suggestion
even over the template; when both or none answered the template's runtime
stays. Two of the three hand-written JSON fixtures duplicated what a few
lines of code can build.

One table over (host, template) -> suggestion now covers the rule, and its
failure message names the row. Hosts are built in code from each engine's
answer. podman-only.json stays: the onboarding TUI test includes it, and a
single authoring test replays it to keep the recorded format exercised.
docker-only.json and both-engines.json are deleted; the JSON shape of
DiscoveryObservations is also pinned by the round-trip in
nemoclaw-discovery/tests/observations.rs.

Validation: inverting the availability filter in use_local_engines made the
table fail on "docker only with a docker template" (left podman, right
docker) and the recorded-host test fail; the production file was restored.
Authoring and onboarding crate tests and clippy pass.
…er their own query

observe dispatched Inference and Credential queries with no test after the
DiscoverySession tests were deleted, so a mis-routed query, a wrong reference,
or a leaked secret would pass unnoticed.

One test now asks an Inference query against a served /models catalog and two
Credential queries (one resolvable, one not) through a fake Secrets. It asserts
each answer is recorded under its own query, the model list is the served one,
and the serialized credential observations never contain the secret value.

Gateway is not covered: answering it needs a gateway configuration and
discovery of a real gateway, which cannot be made deterministic here. The
provider-versus-observe image verdict contract test is skipped because it
needs the provider data source wired to an engine fixture.

Validation: breaking the Credential dispatch to resolve a fixed reference made
the new test fail (Unavailable vs Available); restored, cargo test and clippy
for nemoclaw-discovery pass.
The external-gateway test kept an amd64 architecture on the managed-gateway
engine probe to show the probe cannot place the image's platform. Once the
authoring tests feed hand-built verdicts instead of computing them, that
assertion can no longer fail: assess_target never reads the engine's
architecture, and the platform an image is judged on is fixed by the query,
which discovery_graph.rs and the discovery observe tests pin. The test now
names only what it still proves: an unavailable managed-gateway probe does
not disqualify an external gateway.

Also merge the split nemoclaw_sdk import in the discovery observe test.

Validation: cargo fmt --check and cargo clippy -D warnings on the authoring,
discovery, and SDK crates are clean.
The authoring test that showed a catalog without the document's adapter is a
conflict was retired once authoring stopped computing image verdicts. Its
promise then had no native pin: fabric_planner only asserted that planning
against a catalog without the adapter fails. Reclassifying Fabric's
UnknownAdapter as unverified would have kept every native test green, and an
image that can never run the chosen harness would have stopped blocking
onboarding's ready document unless a journey required target prerequisites.

A new planner test asks assess_fabric for an adapter the image catalog lacks
and asserts the report is unsupported, with a check whose reason names
harness.adapter_id.

Validation: with UnknownAdapter mapped to Unverified in fabric_capabilities.rs,
the test failed with left Unknown, right Unsupported; the file was restored.
The 13 fabric_planner tests pass, and clippy on the SDK tests is clean.
v1 moved the compute driver from each sandbox to spec.gateway.runtime.provider
(#12663). This branch read the driver per sandbox in plan_queries and its
gateway query, and its tests set or asked the sandbox path.

- plan_queries takes the managed gateway engine's driver from the gateway, and
  the gateway query asks for that one driver, as v1's graph base does.
  gateway_drivers is removed, since one gateway has one driver.
- discovery_graph.rs and the onboarding terminal keep this branch's versions:
  the graph is built from plan_queries, and the terminal's discovery tests went
  with the API they used. v1's change to both was only the driver's path.
- evidence.rs and authoring's discovery_graph.rs stay deleted; their v1 edit
  was the same path change, carried into target_assessment.rs and support.rs.
- Tests ask /spec/gateway/runtime/provider, which authoring already asks.
- The open question on early target observation now says this machine's
  engines are read before the first question, leaving the image catalog open.
  The renamed heading takes v1's title case.

The pinned discovery graphs are unchanged after the merge, so the plan's reads
did not move.
… answered for

Choosing Podman on a machine where only Docker answered withdrew the generated
gateway engine, as intended. A few questions later the gateway engine question
suggested the schema default, Docker's socket, whatever the runtime. Accepting
it authored that socket under a Podman runtime, and because the engine was now
authored, the review gave only "The selected engine has not been observed"
instead of saying no Podman engine answered. A tmux run of nemoclaw onboard on
a machine with Docker Desktop and no Podman showed it.

When the machine was asked and no engine answered for the chosen runtime, the
engine question now has no suggestion, so accepting it leaves the engine
unauthored and the assessment's first reason names the missing engine. A
machine that was never asked keeps the schema default suggestion.

Validation: accepting_suggestions_never_points_a_runtime_without_a_local_engine_at_dockers_socket
failed first with the engine authored as unix:///var/run/docker.sock. Rerun in
tmux, the engine question is empty and the review leads with "No podman engine
answered on this machine". The rendered document still shows the SDK schema's
default engine for an omitted managed-gateway engine, which a plan rejects for
Podman; that default is unchanged here.
…sport uses it

Test / windows_amd64 failed clippy with "associated function `new` is never used" in nemoclaw-discovery's engine.rs. Both callers, the Unix socket and SSH connections, are Unix-only, so on Windows nothing constructs an engine client and Engine::connect returns its unsupported-platform error. The constructor is now compiled only on Unix, like its callers.

Validation: clippy with -D warnings is clean for nemoclaw-discovery and nemoclaw-provider on macOS. The Windows target is not installed locally, so the Windows job is the check.
Authoring depended on the read crate, nemoclaw-discovery, only to name
DiscoveryObservations, so every consumer of the collection also linked
the engine, SSH and gateway readers. The query and observation enums
were parallel and nothing paired a query with its answer, so each named
getter was a lookup plus a match that turned a mismatch into None, and
assess_target matched both enums by hand. The duplicate-skipping loop
was written three times.

DiscoveryObservations now lives in nemoclaw_sdk::discovery. A Query
trait pairs each request type with its observation type, and one
get<Q: Query> replaces engine, inference and credential and the matches
in assess_target. The four inline query variants become HardwareRequest,
FabricRequest, GatewayRequest and CredentialRequest, like the existing
DiscoveryRequest and EndpointRequest; the JSON is unchanged. A shared
distinct helper replaces the three loops.

The collection stays a Vec in recording order. A map keyed by query
needs Ord, and FabricRequirements holds a serde_json::Value, which has
none; the list format of the replay fixture is untouched.

Authoring drops nemoclaw-discovery from its dependencies. It still links
the same transport crates through nemoclaw-sdk, so only the read crate's
own code leaves its tree.
@copy-pr-bot

copy-pr-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

Base automatically changed from worktree-discovery-query-alignment to v1 October 6, 2026 17:01
@wscurran wscurran added area: architecture Architecture, design debt, major refactors, or maintainability area: security Security controls, permissions, secrets, or hardening needs: rebase PR needs rebase or conflict resolution platform: container Affects Docker, containerd, Podman, or images labels Oct 6, 2026
#12579 was squash-merged, so Git saw its content as added on both sides.
The result is this branch's refactor applied on v1, which a cherry-pick
of the refactor commit onto v1 reproduced without conflicts.
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

The Kubernetes change added metadata_env to the Fabric query while this
branch turned that variant into FabricRequest. The field now lives on
FabricRequest, and the read, the plan graph and the tests use it there.
…it found

Review of the typed lookup found two places where the refactor was not
quite behavior-preserving. contains was built on the typed get, so a
query whose recorded answer was of another kind counted as unasked,
where it used to count as asked. assess_target assigned the result of
each lookup, so a later query with no answer would have reset an earlier
one to None; the old arms assigned only on an answer. The second cannot
happen today because guided discovery requires one sandbox, and so one
engine and one image query.

contains now looks for the query alone, and assess_target keeps an
earlier answer when a later lookup finds none. A test pins the first.
@kaofelix
kaofelix marked this pull request as ready for review October 7, 2026 11:24
@kaofelix
kaofelix enabled auto-merge (squash) October 7, 2026 11:25
The walkthrough test added to nemoclaw-cli on v1 matched the Fabric
query by its struct fields, which this branch moved into FabricRequest.
Git merged the two cleanly, so the break appeared only when the merged
tree was built, and GitHub's test merge failed to compile on every
platform. The test now reads the engine from the request.
@kaofelix
kaofelix merged commit 3e54f0c into v1 Oct 7, 2026
14 checks passed
@kaofelix
kaofelix deleted the discovery-observations-map branch October 7, 2026 12:24
@cv cv added the v1 NemoClaw v1 branch label Oct 12, 2026
@wscurran wscurran added the refactor PR restructures code without intended behavior change label Oct 28, 2026
@cv cv added this to the Roadmap: GTC DC 2026 milestone Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: architecture Architecture, design debt, major refactors, or maintainability area: security Security controls, permissions, secrets, or hardening needs: rebase PR needs rebase or conflict resolution platform: container Affects Docker, containerd, Podman, or images refactor PR restructures code without intended behavior change v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants