Expand description
Job routing / placement policy — decide where a curated job is processed.
Given a curated job, this module answers one narrow question: should the work run on the person’s local, in-process inference engine, or be sent to an external provider reached over MCP? It is transport / placement policy only. It performs no I/O, no async work, and no cryptography — it is a pure decision function over a small set of inputs so it is trivially testable and auditable.
§Privacy-first, fail-closed ordering
The directive being implemented (Timothy): local inference is PREFERRED when the person can run it; costly external MCP services are used only when wanted/needed and consented; sanctuary/private data must never leave the device.
The rules are therefore evaluated in a deliberate order so that the most protective outcome always wins:
- Classified / sanctuary data → local only. Such data must never leave the device,
regardless of consent or policy. If no local engine is available the job is
RoutingDecision::Blockedrather than sent out. - Policy forbids external → stay local. If the person’s
RoutingPolicydisables external providers, the job runs locally (or is blocked if no local engine exists). - Capability gap → external needed. If the job needs a capability the local engine
lacks, an external provider is required — but only with explicit consent. Otherwise
the caller is told consent is needed (
RoutingDecision::NeedsConsent). - No local engine → external fallback. For non-classified data, if no local engine is available the job goes external with explicit consent, else consent is requested.
- Cost ceiling. A remote path that would exceed the policy’s cost ceiling requires
consent for the spend. Cost is only meaningful on a remote path — a
RoutingDecision::Localdecision has no metered cost, so the ceiling is never applied to it. - Default → local. With a local engine available and nothing forcing a remote hop, the job runs locally.
§Relationship to the authority check
This is placement policy, not an authority check. Whether the requesting agent is
permitted to run the job at all is decided separately and complementarily by
[qualia_cooperative_core::agency_delegation::delegation_permits] (a fail-closed ABAC
evaluator). The caller runs both: delegation_permits answers “is this allowed?”, and
route_job answers “where should it run?”. This module deliberately does not
reimplement or second-guess that authority decision.
Structs§
- Routing
Inputs - The inputs to a routing decision for a single curated job.
- Routing
Policy - The person’s placement policy — the guard rails
route_jobevaluates against.
Enums§
- Routing
Decision - The placement decision for a curated job.
Constants§
- DEFAULT_
COST_ CEILING_ MICROCENTS - A modest default per-job cost ceiling: 10 US cents expressed in microcents
(1 cent = 1_000_000 microcents, so 10 cents =
10_000_000).
Functions§
- route_
job - Decide where a curated job should run.