UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

216 lines (215 loc) • 11.4 kB
export const ROUTE_ADJUDICATION_CONFORMANCE_CORPUS = [ { name: "per-model-on-root", intent: "a per-model credential not bound yet is servable, on the deployment root", model: { id: "m-main", baseUrl: "https://gw.example.com" }, credential: { source: "per-model", apiKey: "k-main" }, config: { baseUrl: "https://gw.example.com" }, expect: { ok: true, posture: "per-model" }, }, { name: "per-model-off-root", intent: "a per-model credential not bound yet is servable off the deployment root too (the resolver was asked about THIS entry)", model: { id: "m-third", baseUrl: "https://third-party.example.net/v1" }, credential: { source: "per-model", apiKey: "k-third" }, config: { baseUrl: "https://gw.example.com" }, expect: { ok: true, posture: "per-model" }, }, { name: "per-model-headers-borne", intent: "an entry-declared auth header is a per-model credential (headers-borne)", model: { id: "m-hdr", baseUrl: "https://third-party.example.net" }, credential: { source: "per-model", headersBorne: true, carrierBag: "model" }, config: { baseUrl: "https://gw.example.com" }, expect: { ok: true, posture: "per-model" }, }, { name: "per-model-empty-string-key", intent: "an empty-string per-model key is the keyless door: it keeps the per-model rank (never falls to the deployment key) and no key header is written for it", model: { id: "m-degraded", baseUrl: "https://third-party.example.net" }, credential: { source: "per-model", apiKey: "" }, config: { baseUrl: "https://gw.example.com" }, expect: { ok: true, posture: "per-model" }, }, { name: "deployment-paired", intent: "the main-gateway pass: entry URL === declared config root, deployment credential allowed", model: { id: "m-main", baseUrl: "https://gw.example.com" }, credential: { source: "deployment-config", apiKey: "k-gw" }, config: { baseUrl: "https://gw.example.com" }, expect: { ok: true, posture: "paired" }, }, { name: "deployment-paired-empty-entry", intent: "an entry with an empty baseUrl targets the config root — deployment credential paired", model: { id: "m-implicit", baseUrl: "" }, credential: { source: "deployment-config", apiKey: "k-gw" }, config: { baseUrl: "https://gw.example.com" }, expect: { ok: true, posture: "paired" }, }, { name: "deployment-paired-slash-normalized", intent: "trailing slashes do not break the pairing (both halves normalize before compare)", model: { id: "m-main", baseUrl: "https://gw.example.com/" }, credential: { source: "deployment-config", apiKey: "k-gw" }, config: { baseUrl: "https://gw.example.com" }, expect: { ok: true, posture: "paired" }, }, { name: "deployment-mismatch", intent: "THE torn pair: deployment credential + entry URL off the declared root = refusal, not a silently-followed key", model: { id: "m-third", baseUrl: "https://third-party.example.net/v1" }, credential: { source: "deployment-config", apiKey: "k-gw" }, config: { baseUrl: "https://gw.example.com" }, expect: { ok: false, code: "route.credential_mismatch" }, leg: "named", }, { name: "deployment-mismatch-path-differs", intent: "a differing path is a differing root (no prefix leniency — the credential goes to the exact declared root only)", model: { id: "m-path", baseUrl: "https://gw.example.com/other" }, credential: { source: "deployment-config", apiKey: "k-gw" }, config: { baseUrl: "https://gw.example.com/v1" }, expect: { ok: false, code: "route.credential_mismatch" }, leg: "named", }, { name: "deployment-mismatch-query-differs", intent: "two roots differing only in a QUERY parameter are two routes — the deployment credential is not paired with the second", model: { id: "m-tenant", baseUrl: "https://gw.example.com/v1?tenant=b-corp" }, credential: { source: "deployment-config", apiKey: "k-boot" }, config: { baseUrl: "https://gw.example.com/v1?tenant=a-corp" }, expect: { ok: false, code: "route.credential_mismatch" }, leg: "named", }, { name: "deployment-mismatch-derived-leg", intent: "the same torn pair on a DERIVED model: same verdict; the engine disposes of it as fallback-to-primary + notice", model: { id: "m-summarize", baseUrl: "https://third-party.example.net" }, credential: { source: "deployment-config", apiKey: "k-gw" }, config: { baseUrl: "https://gw.example.com" }, expect: { ok: false, code: "route.credential_mismatch" }, leg: "derived", }, { name: "deployment-headers-borne-mismatch", intent: "a deployment auth HEADER is the same fallback arm: off the declared root it is refused, not sent", model: { id: "m-third", baseUrl: "https://third-party.example.net" }, credential: { source: "deployment-config", headersBorne: true, carrierBag: "config" }, config: { baseUrl: "https://gw.example.com" }, expect: { ok: false, code: "route.credential_mismatch" }, leg: "named", }, { name: "deployment-undeclared-entry-root", intent: "a config key with NO declared root and an entry carrying its own root: nothing says the key belongs there — refused, never sent (declare config.baseUrl, or give the entry its own credential)", model: { id: "m-catalogue", baseUrl: "https://api.example.com/v1" }, credential: { source: "deployment-config", apiKey: "k-deployment" }, config: {}, expect: { ok: false, code: "route.credential_mismatch" }, leg: "named", }, { name: "deployment-lane-default", intent: "a config key with no declared root is paired with the lane's own default endpoint — a request there is paired", model: { id: "m-vendor", baseUrl: "https://api.vendor.example" }, credential: { source: "deployment-config", apiKey: "k-vendor" }, config: { laneDefault: "https://api.vendor.example" }, expect: { ok: true, posture: "paired" }, }, { name: "deployment-lane-default-entry-elsewhere", intent: "the same key with an entry rooted away from the lane default is refused, exactly like a declared root", model: { id: "m-catalogue", baseUrl: "https://third-party.example.net/v1" }, credential: { source: "deployment-config", apiKey: "k-vendor" }, config: { laneDefault: "https://api.vendor.example" }, expect: { ok: false, code: "route.credential_mismatch" }, leg: "named", }, { name: "absent-keyless-on-root", intent: "a keyless deployment on its own root has nothing to protect — allowed", model: { id: "m-local", baseUrl: "http://127.0.0.1:8000/v1" }, credential: { source: "absent" }, config: { baseUrl: "http://127.0.0.1:8000/v1" }, expect: { ok: true, posture: "keyless" }, }, { name: "absent-keyless-undeclared", intent: "keyless with no declared config root (URL only on the model) — allowed", model: { id: "m-local", baseUrl: "http://127.0.0.1:8000/v1" }, credential: { source: "absent" }, config: {}, expect: { ok: true, posture: "keyless" }, }, { name: "absent-missing-off-root", intent: "an entry declaring its OWN URL away from a DECLARED deployment root with no credential anywhere is a configuration hole — loud refusal beats an unauthenticated request to a third-party host", model: { id: "m-third", baseUrl: "https://third-party.example.net" }, credential: { source: "absent" }, config: { baseUrl: "https://gw.example.com" }, expect: { ok: false, code: "route.credential_missing" }, leg: "named", }, { name: "absent-missing-derived-leg", intent: "the same hole on a DERIVED model: same verdict; engine disposition is fallback-to-primary + notice", model: { id: "m-summarize", baseUrl: "https://third-party.example.net" }, credential: { source: "absent" }, config: { baseUrl: "https://gw.example.com" }, expect: { ok: false, code: "route.credential_missing" }, leg: "derived", }, { name: "required-absent-on-root", intent: "no credential anywhere, on the deployment's own root, under a brain that requires one — refused where it would have been keyless", model: { id: "m-req", baseUrl: "" }, credential: { source: "absent" }, config: { baseUrl: "https://gw.example.com", requireCredential: true }, expect: { ok: false, code: "route.credential_missing" }, leg: "named", }, { name: "required-keyless-door-per-model", intent: "a per-model answer that holds its rank and carries nothing (a blank key) under a brain that requires a credential — refused; the deployment's key does not ride in its place", model: { id: "m-req", baseUrl: "https://gw.example.com" }, credential: { source: "per-model" }, config: { baseUrl: "https://gw.example.com", requireCredential: true }, expect: { ok: false, code: "route.credential_missing" }, leg: "named", }, { name: "required-keyless-door-deployment", intent: "a deployment credential that is blank, on its own root, under a brain that requires one — refused where it would have been paired", model: { id: "m-req", baseUrl: "" }, credential: { source: "deployment-config" }, config: { baseUrl: "https://gw.example.com", requireCredential: true }, expect: { ok: false, code: "route.credential_missing" }, leg: "named", }, { name: "required-credential-carried", intent: "a credential that rides is servable under a brain that requires one: the declaration refuses nothing else", model: { id: "m-req", baseUrl: "https://gw.example.com" }, credential: { source: "per-model", apiKey: "k-req" }, config: { baseUrl: "https://gw.example.com", requireCredential: true }, expect: { ok: true, posture: "per-model" }, }, { name: "plaintext-credential-off-machine", intent: "a credential (here the deployment key, on its own paired root) to a plain-http root off this machine is refused: it would cross the network in the clear — a private-range address is not exempt", model: { id: "m-lan", baseUrl: "" }, credential: { source: "deployment-config", apiKey: "k-lan" }, config: { baseUrl: "http://10.0.0.5:8150/v1" }, expect: { ok: false, code: "config.protocol_plaintext_credentials" }, leg: "named", }, { name: "plaintext-credential-loopback", intent: "the same credential over plain http to this machine is servable: loopback is the one plain-http root a credential may ride to", model: { id: "m-local", baseUrl: "http://127.0.0.1:8000/v1" }, credential: { source: "per-model", apiKey: "k-local" }, config: {}, expect: { ok: true, posture: "per-model" }, }, ];