Skip to content

feat(nemo-relay): accept host-verified human approval - #159

Draft
nathankw wants to merge 13 commits into
feat/relay-native-tool-correlationfrom
feat/relay-host-human-approval
Draft

nathankw wants to merge 13 commits into
feat/relay-native-tool-correlationfrom
feat/relay-host-human-approval

Conversation

@nathankw

@nathankw nathankw commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Let an application keep its existing human-approval workflow while using the generic Nomos Relay worker to dispatch the approved operation through the remaining middleware.

Draft, stacked on #154 (feat/relay-native-tool-correlation). The enabled feature depends on the unreleased execution-context transport in NeMo Relay PR #1749. The SDK, lockfile and manifest now target matching Relay 1.0 source builds; Relay 0.11 installations are incompatible. The Python packages are pinned to public commit 101e1e9e from that PR, and the managed-worker tests use a CLI built from the same revision. Keep this draft until the matching release is available and published-package clean installation is verified. Source-build instructions.

Problem and before/after

A host application may pause a tool call for human approval, end the original model attempt, and execute the approved operation later. That replay need not retain a live model-request snapshot. Treating it as a fresh model proposal either refuses it for missing provenance or asks for another Council decision.

This change provides an explicit alternative for operators who trust the host to perform the required human-approval checks:

Call Behavior
Ordinary guarded proposal, no host-approval claim Existing native correlation, intent validation, Council review and writ verification.
Exact human-approved replay from an explicitly trusted host Validate the separate assertion, journal its approval ID, recheck current central OPA policy, then call the continuation. No model intent or original H2 snapshot is required.
Supplied but invalid, untrusted or mismatched assertion Refuse without calling Council or executing the tool; no fallback to another review path.
Reused approval ID Do not dispatch again; a changed operation conflicts and uncertain outcomes require reconciliation.

H2 is the LLM-execution interceptor that captures request provenance; H3 is the tool-execution interceptor that authorizes dispatch. These are integration labels, not new Relay APIs.

Example

The operator opts in for exact guarded tools whose executor is local:

[plugins.dynamic.config.host_approval]
source = "example.application"
tools = ["write_file"]

After checking its saved human decision, the application supplies separate Relay execution context:

{
  "data": {
    "host_approval": {
      "version": 1,
      "source": "example.application",
      "approval_id": "approval-example",
      "tool_name": "write_file",
      "approved_arguments": {
        "path": "/workspace/project/note.txt",
        "content": "hello"
      }
    }
  }
}

The actual business arguments must match approved_arguments. This object is not a model-generated tool argument, event metadata or a Council writ.

Host verifies the saved human decision
  → Relay carries execution context to H3
  → Nomos validates configured trust, exact operation and approval reuse
  → Authenticated policy-only inspection checks the exact tool and arguments
  → Hard denial or unavailable policy stops; a verified approval can satisfy a human-review requirement
  → Nomos calls next(arguments)
  → Remaining Relay middleware runs
  → Host revalidates the final operation and performs the effect

Policy decisions and the existing approval interface

The core policy API is introduced separately in #160. This worker change does not rebase #154 onto that policy work. Approved replay now requires the core policy-only API and enabled, healthy OPA; it cannot silently use an older service that ignores the new inspection flag.

The worker preserves a single review-outcome status. Successful tool execution still uses its existing executed status; this does not turn the core API's approved response into a tool result before execution.

Non-executing worker result Application behavior
status: requires_human_approval, execution_status: not_executed Use the application's existing approval interface, bind the saved approval to the exact operation, and later replay with separate execution context.
status: denied, execution_status: not_executed Block. Preserve service guidance; never reinterpret denial as a request for a human override.
Service, protocol or policy error Fail closed. Never infer a human-review requirement from error prose or legacy auxiliary fields.

There is no forbidden status, human_approval_required alias, or public policy_decision field. Human-review feedback uses bounded policy.reason, policy.guidance and policy.decision_id; the metadata has no second outcome discriminator. A legacy denied response with human-looking fields remains denied.

On approved replay, the fresh policy-only response must be policy_allowed or requires_human_approval, with no writ or contradictory execution claim. The independently verified host approval is still mandatory. denied always stops; approved, unknown/mixed-contract responses and policy errors cannot pass this inspection boundary.

A human-review request is not a denial or Council vote and does not increment the denial counter. Unified denied results from the Council service include policy prohibitions and count toward the existing consecutive authorization-denial limit; the worker does not guess their origin from text or vote counts. Signed receipts record the actual service outcome, not fabricated member votes. An unsuccessful policy inspection closes the approval's journal attempt without dispatch; retry requires a fresh host approval ID rather than an automatic retry.

Trust and execution contract

  • Disabled unless explicitly configured. Accepted tools must be guarded, local and backed by an operator-derived subject.
  • The source string is an allowlist label, not authentication. The trusted host authenticates the approver and checks authority, approval state, expiry, mandatory policy and durable consumption. The plugin verifies the configured assertion and exact arguments; a compromised trusted host can manufacture assertions.
  • This opt-in replaces model review with the verified host decision, while preserving current central policy. It skips model-intent/origin correlation and Council-member voting, then calls the new core policy-only API for the exact operation. A hard prohibition remains blocked after human approval; disabled, undefined, unavailable or legacy policy responses fail closed. The host must also enforce its mandatory policy and revalidate the final payload.
  • No Council decision, writ or certified execution evidence is fabricated. Outcomes identify authorization_source: host_human_approval, and tool annotations are preserved.
  • Downstream middleware still runs. Operators must keep authorization before caches and prevent later middleware from rewriting approved arguments. The host must check the exact final payload at the execution boundary.
  • Approval reuse is tracked in the existing in-memory journal, scoped to configured source/subject. Cancellation or uncertain effects prevent automatic retry. This is bounded activation-local protection, not durable or distributed exactly-once execution.
  • This migrated worker requires Relay >=1.0.0,<1.1 and the nvidia.nemo.relay.worker.v1 protocol. Ordinary calls still follow Council authorization; host-approved replay remains opt-in. A stale SDK missing execution context fails activation explicitly.

Implementation and review entry points

  • Host-approval contract and release limitations.
  • host_approval.py: required standard assertion fields with additional properties preserved/ignored for authorization, bounded JSON and exact argument matching.
  • plugin.py: explicit branch selection, fresh policy inspection, validation, journaling and continuation.
  • policy.py: bounded typed outcomes; no routing by error text.
  • repository.py: retain host approval scopes across ordinary turn cleanup.
  • settings.py and generated schema: default-off configuration and guarded/local-tool checks.
  • New host-approval tests; generated architecture updates follow the changed source and templates. The earlier interceptor priority and annotation sanitizer from feat(nemo-relay): replace model-carried tokens with native call correlation #154 are retained.

Execution context: Relay envelope, Nomos approval contract

Relay PR #1749 defines a closed ApplicationExecutionContext envelope with an optional data object. Relay transports that object's contents without interpreting application-specific approvals. Nomos owns and validates execution_context.data.host_approval, using its packaged JSON Schema and operational validator.

The five assertion fields remain required; extra assertion properties and other application data are allowed. The obsolete decision property is rejected. Valid shape alone grants nothing: configured source trust, exact tool/arguments, current policy and replay checks remain mandatory. The host must revalidate the final operation before execution.

No context, an omitted data, or valid application data without host_approval follows ordinary Council review. A supplied null/malformed approval, malformed envelope, or legacy flat execution_context.host_approval is refused without fallback. The entire context remains bounded to 16 KiB and 64 container levels. Existing callers must add the data wrapper before enabling this feature.

Validation

Relay 1.0 migration

  • relay-plugin.toml declares the namespaced worker protocol and Relay >=1.0.0,<1.1. SDK/runtime dependencies and uv.lock pin public Relay commit 101e1e9e; no workstation paths are committed.
  • The unreleased CLI is built from that same source. Its Git Python project is only a placeholder, so the test workflow requires NOMOS_TEST_RELAY_BIN rather than installing an executable-less package.
  • Fresh offline worker installation uses the source SDK wheel plus runtime-only locked dependencies. No compatibility or integrity validation is disabled.
  • Full make test: 992 passed, 5 expected skips; 93.08% branch-aware coverage, above the unchanged 90% floor. Includes real managed Python workers and source-built Node-host cases.
  • A new fresh-install remote-worker test verifies data.host_approval, untrusted/malformed/mismatched assertions, replay protection, downstream middleware and current-policy denial after human approval. Council answers and business callbacks are local fixtures.
  • Separate real-core/OPA/source-Relay tier: 6 passed, using a temporary core-dependency overlay. No live model, approval UI, external connector writes or distributed durability claims.

These are macOS ARM64 / Python 3.12 source-build results. They do not establish compatibility with a published Relay 1.0 release. Earlier failed setup attempts and the initial obsolete-context assertion failure were retained; no timeout or coverage threshold was changed.

Previous envelope/schema checkpoint

For the earlier envelope/schema update:

  • Full make test: 986 passed, 10 expected skips; 93.08% branch-aware coverage, above the unchanged 90% floor.
  • make lint passed, including types, generated documentation and repository checks.
  • Source-matched Relay cache test: 1 passed. Combined real core/OPA/source-built Relay tests: 6 passed. Business callbacks were synthetic.
  • Wheel and source archive both include the canonical Nomos approval schema.

The source-matched tests exercise in-process interceptors; they do not establish remote-worker transport, live connector writes, approval UI or multi-replica durability. Those results preceded the Relay 1.0 packaging migration above; published-release validation remains outstanding. Independent review found no actionable issue in the final schema, implementation, packaging or documentation.

Historical checkpoint results

Five-field approval update (9f41d08): the object itself asserts affirmative human approval; the redundant decision field is removed. All legacy decision properties are rejected, including approved, denied and null. Sixty focused host-approval tests passed. A real source-matched Relay cache regression passed: one approved effect, a schema-valid untrusted-source refusal despite a populated cache, and an obsolete-decision schema refusal before middleware. This uses a synthetic callback and does not claim live connector or remote-worker coverage.

The full offline run had 925 passed, 10 skipped and 10 failures; every failure was the published runtime's worker did not start within 10s socket/registration deadline. All ten failed cases passed unchanged in isolation: 21 evidence E2E tests, including nine affected cases, plus one installed-worker test. The original full run remains recorded as failed; the underlying startup delay was not established. No timeout or threshold was changed. Staged integration hooks and independent review passed.

The updated worker is independently reviewed and remains stacked on #154 at f53daa18.

  • Full offline make test with published 0.11.1 dependencies: 926 passed, 10 skipped; 93.12% branch-aware coverage (unchanged 90% floor). Includes installed-worker and enclosing-Nomos contract/evidence tests.
  • 51 host-approval cases cover opt-in, unsupported SDK, missing intent/origin, malformed claims, exact arguments, replay/conflicts, cancellation, callback exceptions, oversized/non-JSON results, reconciliation blocking, expired operator trust and retention during ordinary turn cleanup.
  • Separate matching-source Relay runtime test, using Relay PR #1749 at f1d606de: 1 passed. It runs H3 in process through real Relay execution interceptors and its tool cache, showing a cached result cannot bypass rejection of a later invalid assertion. This is not a remote-worker or approval-UI test.
  • A separate matching-source combined tier: 6 passed, exercising real core CouncilService, loopback OPA and Relay execution context. It proves policy-required human review, hard denials, policy-allowed replay, a satisfied human-review requirement and a hard prohibition that remains blocked after approval. Middleware is in process; this does not claim remote-worker transport or UI coverage.
  • 11 additional policy-contract regressions cover forged/inconsistent results, bounded feedback and signed policy receipts.
  • make lint passed, including formatting, mypy, schema/manifest/lock consistency, generated docs, Markdown links and private-key detection. Independent correctness and security/publication reviews found no blocking issue.
  • Source, package/lockfile and manifest bounds are preserved; the source-build test used a separate environment.

The standard suite skips two live-service checks, two source-runtime modules (run separately), one slow worker test, one Linux /proc case, and four Node-specific installed-worker cases. Unit tests explicitly simulate the new SDK callback field; they do not claim the pinned 0.11.1 SDK can transport it. No live model, host approval UI, external side effects or replicated-service durability were tested. The combined tier uses the real core service and OPA, with synthetic business callbacks.

Related work

Host runtime facts (separate from human approval)

This draft also accepts optional execution_context.data.runtime_context for configured exact tools. For example, a model can target /workspace/project/output while the host resolves execution to /srv/workspaces/project. Without that mapping, reviewers cannot establish that the paths correspond.

# Host-provided Relay execution context; these are not model tool arguments.
data:
  runtime_context:
    version: 1
    source: example.application
    tool_name: files.run
    tool_call_id: provider-call-id
    arguments: {script: mkdir output, directory: /srv/workspaces/project}
    runtime:
      working_directory: /srv/workspaces/project
      workspace_mappings:
        - logical_root: /workspace/project
          execution_root: /srv/workspaces/project

The worker explicitly trusts a configured source and exact guarded local tools, verifies the native call ID and exact canonical argument snapshot, then forwards only {version, source, runtime}. The core support is #178, stacked on #160; it independently checks the authenticated issuer, source and tool. Enable both trust gates for a coordinated rollout. Defaults trust no issuer.

Runtime facts never select the human-approved path, rewrite executable arguments or alter the signed operation digest. OPA denial and required human approval still apply. The full context, including argument snapshots and optional separate host_approval, must fit Relay's 16 KiB budget. Input facts are live-only; reviewer reasoning may still persist quoted paths.

See runtime-context contract and examples. Independent cross-stack review, focused trust/binding tests and a real managed-worker transport test passed; the transport test uses fixture Council responses and makes no live model-quality claim.

Runtime-context validation completed: 1,028 tests passed, 5 documented opt-in/platform skips, 93.15% branch coverage; worker lint, generated-schema/docs and secret-scan checks passed. A live application → Relay → installed Python worker → Council → local executor test also passed: three members approved the mapped directory creation and the executor returned exit code 0. Council rules and thresholds were unchanged. Genuine delayed human-approved replay with runtime facts remains untested live; the installed-worker fixture covers combined runtime/approval transport and current-policy refusal.

Signed-off-by: Nathaniel Watson <nwatson@nvidia.com>
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review: 2

  • main
  • develop

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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