Skip to content

Threat model

Mendari engine, dashboard and registry, as of Phase 4b (2026-10-02), with registry agents on the bounded engine (LP-16, 2026-10-08), and a registry that shows only what it checked, with recalls and the cap on pulled agents (LP-18, 2026-10-17), and CDS clients' own signed tokens, with open mode's CDS Hooks on this machine only and CORS for their registered origins (LP-23b and LP-23c, 2026-10-18), and the EHR pilot's reads and answers: recorded abstentions, data coverage, card feedback, linked reads and site code maps (LP-23, 2026-11-06). Reviewed before the public launch; update it with any change to a trust boundary. The checks named here run in CI. Ids are stable: a new threat takes the next number in its letter, and a removed one leaves a gap. The packet for the external review is review-packet.md.

Wave 6 (2026-11-24) removed the five former reference agents and every feature only they used (among them community agents, hidden evaluation sets and the scoreboard, Jev, CQL, Da Vinci CRD, DTR and PAS, OMOP and the guard route), with the pre-release migrations and the compatibility with old names. Rows S13, S20, T4, T6, T8, R4, I12, I13, I14, I15, I22, E11 and E14 went with them; rows that mixed a kept subject with a removed one now speak of the kept one. Record reading stays (LP-23).

What we protect

Asset Why it matters
Decision inputs (messages, records; PHI in a real deployment) Patient privacy.
Decisions, reviews, outcomes and the audit hash chain Clinical accountability: what was decided, by what, and who changed it.
Governance approvals They lift the automation cap at risk levels 2–3.
Sessions, API keys, OIDC and SMART tokens Whoever holds them acts as a clinician, an integration or an admin.
Provider credentials (LLM gateway keys) Cost, and a channel to send data out.
Agent integrity (signed archives, publisher keys) A tampered agent changes clinical logic at every site that pulls it.
PHI encryption key It opens every stored input.

Trust boundaries

  1. Browser ↔ engine: the dashboard and the API.
  2. EHR ↔ engine: CDS Hooks, SMART launch and FHIR decide.
  3. Engine → outside servers: FHIR servers, the identity provider, alert webhooks, and the registries a server reads its pulled agents' recalls from.
  4. Engine → model providers: LLMs through a gateway.
  5. Registry ↔ clients: publishing, pulling and recalling agents, and the Hub website, which shows the registry's agents to anyone.
  6. Engine ↔ database: SQLite or Postgres.
  7. Contributors ↔ repository: changes arrive by pull request, from forks too, and CI runs on each (T5).

Threats and mitigations (STRIDE)

# Threat Boundary Mitigation Checked by
S1 Someone uses the API or dashboard without an account 1, 2 With sign-in configured, every route has a permission and unlisted routes need admin (deny by default). The project's production deployment has sign-in on (Google); Vercel Authentication protects its Preview deployments only. test_every_route_has_the_permission_it_should; ZAP scan with sign-in on
S2 A forged id_token, replayed sign-in or open redirect 1 PKCE S256, state and nonce used once, id_token verified with the issuer's JWKS, next limited to a path on this site (not //host, nothing with a backslash or a control character, which a browser may read as another host). tests/test_auth.py, test_the_return_address_with_a_backslash_or_a_tab_stays_on_this_site; pilot-check against a real OIDC provider
S3 A stolen API key 2 Keys are stored as SHA-256, shown once, bound to one organization and a machine's role (viewer or service; review and approval are a person's), and revocable, and rotate with a bounded overlap (POST /api/auth/keys/{id}/rotate: the old key keeps working at most 168 hours, then expires; a leaked one rotates with none). They expire: 90 days unless asked, 365 at most. Expired and revoked keys are refused in the lookup itself, as is a key with no expiry. Optional scopes narrow a key to the routes they name (a scoped key reaches nothing else). Managing keys and clients is a people-only permission (keys), so no key, an old admin key included, can mint a credential that outlives it, and creating, rotating and revoking a key are chained (key:<id>, without the key); a key's history (GET /api/auth/keys/{id}/history) reads that chain, never the key or its hash. In an incident the operator revokes any organization's key or client, or all of one organization's, and ends every person's or EHR launch's session, from the command line with the server down (mendari access revoke, mendari access end-sessions, LP-21l), each chained with who and why. The dashboard's Access view shows a new or rotated key once, in an input's value only (never markup, a toast, storage or the console), and takes it off the page when its dialog closes or the view is left. Keys are accepted in the Authorization header only, never in a URL or a form, and /api answers are no-store. test_api_keys_work_for_machines_are_hashed_and_revocable, test_keys_are_managed_by_people_only, test_new_keys_are_for_machines_only, test_an_expired_key_is_refused_like_any_credential_that_is_not_valid, tests/test_api_keys.py (SQLite and Postgres), test_a_credential_in_a_url_or_a_form_is_refused, test_api_answers_are_never_stored, tests/test_rotation.py, test_a_keys_history_is_its_chain_in_order, tests/test_break_glass.py (SQLite and Postgres), browser tests (test_a_key_is_shown_once_and_kept_nowhere)
S4 A forged agent or publisher 5 Ed25519-signed deterministic archives, keys pinned on first use, and immutable versions; a recall is a signed record too (S19). tests/test_archive.py, tests/test_hub_client.py
S5 Credential confusion: a junk, foreign or revoked bearer credential falls back to a session cookie or an EHR launch's cookie 1, 2 An Authorization header decides alone, on every route /api/smart/* included (the launch cookie riding along is never read), the scheme is matched in any case, and the credential's prefix picks the one store it is checked against (ohk_ keys; mat_ access tokens, refused unless SMART Backend Services is on; on /cds-services only, a JWT is a CDS client's token, checked against the registry, S21); anything else is a 401 with error="invalid_token", one generic answer that never echoes the credential. A valid key on a launch's route is a key, which no launch route admits (403). test_a_credential_that_is_not_valid_never_falls_back_to_the_session, test_a_bearer_header_never_falls_back_to_the_launch_cookie, test_a_refusal_never_echoes_the_credential
S6 A public logout deletes another kind of row (a pending sign-in, an EHR launch's session, a one-time claim such as an assertion's jti, which would let it be replayed) by a cookie value the caller chooses 1 Session-table rows are keyed by sha256(kind ‖ 0x00 ‖ value), and every take and delete is scoped to its kind; one-time claims (smart_claim) are a single INSERT … ON CONFLICT, atomic across instances. test_a_public_logout_deletes_only_its_own_kind_of_row, test_a_claim_is_atomic_across_connections (SQLite and Postgres), test_a_replayed_assertion_is_refused_and_a_jti_is_per_client
S7 Scope escalation: a scoped credential reaches more than its scopes name, or a scope widens a role 1, 2 One scope language for keys and tokens (server/scopes.py): SMART v2 system/ read scopes for the FHIR types served, Mendari's decide and outcome URIs. Effective permissions are the role's intersected with the scopes'; each route a scope can reach names its one scope, and a scoped principal gets 403 insufficient_scope (with the scope it lacks) everywhere else, every other /api route and the dashboard included. A key's scopes, and a client's, are parsed strictly (a scope not granted, or one its role cannot use, is a 422), and a stored scope that no longer parses refuses the credential. An access token gets what it asked for within what its client registered, and on every request that is narrowed again by the client's registration as it is then, so a token never outlives a narrowing. test_every_route_principal_role_and_scope_gets_what_it_should (keys and tokens), tests/test_scopes.py, test_a_scoped_key_reaches_only_what_its_scopes_name, test_a_scope_never_widens_a_role, test_the_scope_granted_is_what_was_asked_within_what_was_registered, test_a_token_reaches_only_what_its_scope_names
S8 A forged or replayed client assertion at POST /auth/token 1, 2 Off unless MENDARI_BACKEND_SERVICES=on, which refuses to start without sign-in and MENDARI_PUBLIC_URL (https, or plain http on a loopback or single-label host: the CDS clients' rule, S21). Only RS384 and ES384, only the alg, kid and typ header fields (no jku, x5u, x5c, jwk or crit: Mendari fetches no key), exactly one registered key for the kid and key type, aud exactly {MENDARI_PUBLIC_URL}/auth/token (never the Host header), exp required and at most five minutes ahead (30 s skew), iss = sub. Every check runs before the jti is claimed, the one write an assertion can cause, and the client lookup is the one read an unsigned request can cause. The claim is atomic across instances, per client, until the assertion expires. Every failure is one invalid_client; the reason goes to the security log with the client's id only (once it is known), never the assertion. The endpoint takes 60 requests a minute per address, and after 10 failed assertions in 10 minutes from one address for one client that pair gets a 429 (D5). test_every_assertion_that_does_not_authenticate_gets_one_answer_and_writes_nothing (37 kinds, SQLite and Postgres), test_a_replayed_assertion_is_refused_and_a_jti_is_per_client, test_refusals_are_logged_by_client_id_only, test_the_server_refuses_to_start_without_what_it_needs, test_failed_assertions_are_limited_per_address_and_client
S9 A stolen access token 1, 2 Tokens are opaque (mat_…), live five minutes with no refresh token, are stored as SHA-256 and sent only in the Authorization header (never a URL or form), and token answers are no-store. Each request reads the client's role, scopes, organization and revocation (one join), so revoking a client stops its tokens at once; turning Backend Services off stops every token. Replacing a client's key set drops its tokens in the same transaction, and each token carries the version of the key set its assertion was checked against (keys_version), so one issued while a replacement ran is refused. A token reaches only what its scopes name, in its client's organization. test_each_request_reads_the_client_as_it_is_now, test_a_token_acts_in_its_clients_organization_only, test_tokens_stop_working_when_backend_services_is_turned_off, test_an_expired_token_is_refused_and_purged, test_replacing_a_clients_key_set_keeps_its_id_and_drops_its_tokens, test_a_token_verified_against_the_old_key_set_is_refused_after_a_replacement, test_a_token_raced_against_a_replacement_at_the_endpoint_is_refused (SQLite and Postgres)
S10 Persistence: a stolen key or token registers a client (or key) that outlives it, or gives someone a membership 1 Registering clients, replacing their key sets and revoking them, and in memberships mode inviting, changing and removing memberships and handling requests to join, need the people-only keys permission, so no key or token can, an old admin key included; nor can one accept an invitation (a person's own route). Clients are viewer or service, with a public JWK Set only (a private or symmetric key is refused, never stored), and registering, replacing keys and revoking are chained (client:<id>, with the keys' ids and thumbprints). The dashboard refuses the pasted private keys it recognises (a PEM PRIVATE KEY block, JSON with a private or symmetric JWK member, a private key's DER) before anything is sent. test_clients_are_managed_by_people_with_the_keys_permission_only, test_a_jwks_with_anything_but_public_signing_keys_is_refused, test_a_person_registers_a_client_and_the_chain_records_it, test_a_key_never_manages_people, test_what_a_key_set_replacement_refuses, browser tests (test_a_private_key_is_refused_before_it_leaves_the_browser)
S11 A session left open on a shared workstation, or a role taken away that still works 1 A session ends after 30 minutes without a request and 8 hours after sign-in (MENDARI_SESSION_IDLE_MINUTES, 5 to 120; MENDARI_SESSION_MAX_HOURS, 1 to 12; a bad value stops startup), both held in the row's expires_at: a request moves it to now + idle at most once every 5 minutes, never past the absolute limit and never back (one conditional UPDATE, right across instances), so a session ends early, never late. An EHR launch's also ends with the EHR's token, when the EHR answers 401 to it, and at its absolute_at, which is sealed in the row (I11), whatever the row's clear expiry says. Cookies have no Max-Age, so closing the browser ends them. Roles are worked out on every request from the claims kept at sign-in and the settings as they are then; no role is a 401. The dashboard says "Your session ended. Sign in again." In memberships mode the session keeps no role: each request reads the membership it chose, so a removed membership, or changed roles, apply at the next request; signing in again ends the browser's earlier session. test_a_session_ends_after_the_idle_time, test_activity_extends_it_up_to_the_absolute_limit, test_a_touch_writes_at_most_once_per_interval, test_concurrent_touches_never_shorten_a_session (SQLite and Postgres), test_a_role_removed_from_the_map_ends_access_at_once, test_a_removed_membership_ends_access_at_the_next_request, test_signing_out_and_signing_in_again_end_the_browsers_session, test_a_launch_session_ends_when_idle, test_a_launch_ends_at_its_sealed_absolute_limit, test_an_ehr_that_refuses_the_token_ends_the_launch (SQLite and Postgres), test_a_session_that_ended_says_so_and_offers_the_way_back (browser)
S12 Login or launch CSRF: someone sends the callback URL of their own sign-in (or EHR launch) to a victim, who then works in the sender's session, or with the sender's patient in context 1 /auth/login and /smart/launch set a random ten-minute __Host-mendari_signin (__Host-mendari_launch) cookie, HttpOnly and SameSite=Lax. A pending sign-in keeps the cookie's SHA-256, and the callback takes the row (once) and compares the digests in constant time; a pending launch is sealed under the cookie itself (I11), with neither the state nor a digest in it, so the callback takes the row (once) and it opens only with the cookie of the browser that started the launch. The callback then clears the cookie. A refusal is logged with reason browser. The cookie is host-only and the callback comes back to MENDARI_PUBLIC_URL, so a sign-in or launch that reaches another origin (an alias, a second name) is first sent there with a 302, before anything is bound or stored; a moved mark in the query makes that happen once, so a proxy that rewrites Host cannot loop it. test_a_callback_from_another_browser_is_refused, test_a_launch_finished_in_another_browser_is_refused, test_a_pending_launch_row_holds_no_readable_verifier_or_state, test_a_sign_in_started_on_another_name_moves_to_the_public_url_first, test_a_launch_on_another_name_moves_to_the_public_url_first, test_a_proxy_that_rewrites_the_host_gets_one_move_never_a_loop, test_the_binding_cookie_is_short_lived_and_cleared_after_use; pilot-check
S14 An invitation link used by someone it was not for, or used again (memberships mode, LP-12f) 1 The token (ohi_ and 256 random bits) is shown once, in the answer that makes it, and stored as SHA-256 only; it is used once, expires after 7 days unless asked (30 at most) and can be revoked. Accepting needs a person signed in whose identity provider verified the address it names (403 otherwise, and it stays open), checked in one exclusive transaction, whose update takes it only while it is still unaccepted, unrevoked and unexpired, so accepts of one link at once make one membership. Unknown, used, revoked and expired get one 404; someone already a member gets a 409 and nothing is written, and removing a member revokes their organization's open invitations made out to their address, so a link left open that way never brings them back. The person is recorded only after every check, in the same transaction. Accepting counts against the per-address signin limit. The link carries the token in its fragment (/invite#<token>), which a browser never sends to a server; the token travels only in that and in a POST body, is never echoed (a malformed one is a 422 without it) and is never a log field. The link is relative, never built from a request's Host. The link opens /invite (memberships mode only: 404 otherwise), a public, static page that is never a redirect (a redirect keeps a fragment, so a signed-out browser sent to sign in would carry it on to the identity provider). Its first script, allowed by hash, takes the token out of the address (history.replaceState) before anything else loads, and again for a link opened in the same tab (a fragment change, which loads no new page: the page then starts over with that token), and keeps it in that tab's sessionStorage only, until a final answer (joined, not valid, already a member, malformed) clears it; signing in comes back by a fixed next=/invite, never the page's address. The page is no-store, no-referrer (also as a meta tag), unframeable, with its own CSP (no inline style, no other script), and accepts only when its button is pressed. Every name, address and organization name it and the Access view show is escaped (a requester's name is any account's claim). In the Access view a new link is shown once, only as a dialog input's value, removed when the dialog closes or the view is left. The browser's own history may keep the address as first opened: the token there is single-use, expiring and bound to one verified address. test_an_invited_person_with_no_record_accepts_and_is_recorded_once, test_a_bogus_or_used_link_records_no_one, test_an_expired_link_is_not_valid, test_a_used_link_is_not_valid, test_a_revoked_link_is_not_valid, test_another_address_keeps_the_invitation_open, test_an_unverified_address_cannot_accept, test_a_member_accepting_again_is_refused_and_the_link_stays_open, test_the_invitation_token_is_shown_once_and_never_logged_or_echoed, test_accepting_counts_as_signing_in, test_accepting_needs_a_person_from_this_site, test_accepting_with_an_asker_records_the_person_only_on_success, test_two_accepts_of_one_link_make_one_membership (SQLite and Postgres), test_a_removed_member_cannot_rejoin_with_an_invitation_left_open, test_removing_a_member_revokes_the_invitations_made_out_to_them, test_the_invite_page_is_public_static_and_never_redirects, test_the_invite_page_has_its_own_policy, test_the_fragment_leaves_the_address_before_anything_loads, test_the_invite_page_is_served_only_in_memberships_mode, browser tests (test_a_signed_out_invitee_signs_in_and_the_token_never_leaves_the_page, test_an_administrator_invites_and_the_invitee_joins, test_a_link_is_never_kept_or_logged, test_a_second_link_in_the_same_tab_starts_over_with_it, test_a_malformed_link_clears_the_token_and_sends_nothing, test_names_and_addresses_render_as_text)
S15 A pulled agent passes as a bundled agent to run on re (the maintained engine, with no caps or budget): its manifest keeps a bundled agent's id, version and publisher.type, a registry records a bundled agent's digest for it, or a .mendari-verified marker names one 5 The engine is chosen from the digest load_agent hashed from the agent's own files, never from metadata: the manifest, the registry's recorded digest and the marker are not read for it (Agent.bounded, ADR-0009). A pulled agent keeps the maintained engine only when that digest is one of the installed release's bundled agents' (core/reference.py). The digest covers every file in the agent except those under its evals/, any DECISION_CARD.md, and hidden entries and __pycache__ at any depth, and the files it leaves out are never read on the decide path (Agent.read_bytes reads only the files and bytes the digest hashed), so equal digests mean equal behaviour, and one changed byte puts a copy on the bounded engine (at another version; at the bundled agent's own, it is refused: S16). Every load path passes the origin: archive.extract takes it as a required keyword (the registry's publish, mendari pull, mendari archive verify), and Decision.from_path takes the origin of its path. Only the operator can make a pulled agent owned: a copy in MENDARI_AGENTS_PATH is a local agent, and there is no setting for it. test_the_engine_follows_the_bytes_not_the_manifest, test_one_changed_byte_puts_a_reference_copy_on_the_bounded_engine, test_a_pulled_copy_of_a_reference_agent_keeps_the_maintained_engine, test_the_reference_digests_are_the_installed_releases, test_pulling_a_reference_agent_keeps_the_maintained_engine, test_the_registry_publishes_the_reference_agents_of_its_own_release, test_owned_agents_stay_on_re, test_agent_verify_checks_an_archive_as_a_puller_loads_it, test_a_pulled_agent_never_takes_a_reference_agents_name_and_version, test_the_reference_index_is_each_bundled_agents_id_version_and_digest
S16 A pulled agent takes a bundled agent's place: it has a bundled agent's id and a version that ties its, but other files. The search path serves the first of two tying versions and the registry cache comes before the bundled agents, so it was served (on the bounded engine, but under the bundled agent's name and version) where the bundled agent was asked for 5 Refused at load for every origin the deployment does not own (core/agent.py _shadow_problem, reading core/reference.py reference_agents: each bundled agent's id, version and digest): an agent from a registry whose id is a bundled agent's, whose version ties its as the search path orders versions (version_key: 0.4.1-x and 0.04.1 tie 0.4.1) and whose digest is no bundled agent's. So the registry refuses its publish (422, with the reason), mendari pull refuses it before it is cached, and mendari archive verify fails; one cached before this release is listed under /api/health invalid, the pull's cache hit and Decision.from_path refuse it, the reason names the directory to remove, and the bundled agent is served by its id and version. An identical copy is the bundled agent (S15); a copy at another version runs on the bounded engine (D8); a copy in MENDARI_AGENTS_PATH is the operator's own (owned, on re). test_a_pulled_agent_never_takes_a_reference_agents_name_and_version, test_a_version_that_ties_a_reference_agents_is_refused_too, test_a_pulled_copy_of_a_reference_agent_and_a_newer_version_still_load, test_a_shadow_in_the_cache_is_listed_and_the_reference_agent_is_served, test_decision_from_path_refuses_a_cached_shadow, test_a_pull_of_a_shadow_is_refused_and_nothing_is_cached, test_a_shadow_cached_before_this_release_is_refused_on_the_cache_hit_path, test_a_publish_that_shadows_a_reference_agent_is_refused, test_agent_verify_refuses_a_shadow_without_a_traceback, test_the_engine_follows_the_bytes_not_the_manifest, test_one_changed_byte_puts_a_reference_copy_on_the_bounded_engine
S17 Someone posts to the operator's alert channel as Mendari (a forged "all clear", or false alerts), or replays an old alert 3 With MENDARI_ALERT_SECRET set, every alert is signed: Mendari-Signature: t=<unix seconds>,v1=<HMAC-SHA256 of "<t>." + the body>, with Mendari-Delivery and Mendari-Event; the documented receiver recomputes it over the raw body, compares in constant time and refuses one more than five minutes old. Without a secret the server warns at startup. A secret shorter than 32 characters, or a format Mendari does not render, stops the server and the command. The delivery record (alert_deliveries) and the log name an alert by its id and an error code, never the webhook's URL (which carries its token) or the secret. test_the_signature_verifies_with_the_documented_recipe, test_without_a_secret_nothing_is_signed_and_the_server_warns, test_a_bad_format_or_secret_fails_at_startup_and_before_a_command, test_no_url_or_secret_reaches_a_record_or_the_log, test_a_pending_alert_is_sent_again_until_it_is_delivered_or_gives_up
S18 A publisher passes its own claims off as the registry's checks: an uploaded Decision Card, benchmark or leaderboard (a risk-2 agent whose card says risk 1, a 99.9% accuracy), Markdown in its manifest's text that reads as the registry's headings, tables or a review claim, or a pulled agent's uploaded benchmark shown or used as a reference by the engine that serves it 5 The registry renders each version's card itself, from the files the agent digest covers, and stores and serves no uploaded card, benchmark or leaderboard (they stay in the signed archive, unread). Every version answers checked (the signing key's id, the archive's SHA-256, the digest, the engine, card: rendered, the status label, the review, the namespace's publisher type) apart from claimed (the publisher, the risk level declared_by: publisher, licence and summary); a registry reviewer's review records the level it found beside the declared one (claimed.risk.confirmed). In the registry's card publisher text is one line with Markdown's punctuation escaped, every name a code span, an evidence link only an http(s) address, and only the changelog's versions headings. The registry's one figure is its own regression check on the agent's test set, labelled "publisher's own test set: regression check, not a ranking", never in figures and never ranked. Where the engine serves or names a pulled agent it shows the registry's card (card_of), no uploaded benchmark or leaderboard, and neither its monitor (benchmark.reason: from_registry) nor its evaluation route, mendari eval and mendari demo (a comparison that says why) compare with the benchmark the agent carries (ADR-0012) test_a_forged_card_benchmark_and_leaderboard_show_only_what_the_registry_rendered, test_uploaded_attestations_of_any_shape_are_never_read, test_every_version_answers_what_the_registry_checked_and_what_the_publisher_claims, test_publisher_text_in_the_registrys_card_is_plain_text, test_a_review_confirms_or_corrects_the_declared_risk_level, test_a_publish_is_checked_on_its_own_test_set_and_shown_as_no_ranking, test_the_raw_check_is_never_served_beside_its_figure, test_a_pulled_agents_uploaded_figures_are_not_shown_where_it_is_served, test_search_shows_no_figure_a_registry_sends, test_a_pulled_agents_uploaded_benchmark_is_never_compared_or_monitored_against, test_an_agent_from_a_registry_is_never_compared_with_the_benchmark_it_carries (SQLite and Postgres)
S19 A forged, replayed or cross-version recall: a record for another version, digest or archive, one signed long ago, a second recall of a version, one signed by another namespace's key or passing as the registry's, or a record edited after signing 5 A mendari.yank/1 record is stored only if it names exactly that version (agent, version, digest and archive), its time is within ten minutes of the registry's clock and its Ed25519 signature over its canonical JSON holds with a key of that namespace's, or with the registry's own key (MENDARI_REGISTRY_SIGNING_KEY, GET /v1/registry-key) for a recall an administrator makes; a version is recalled once (409), and the route reads its body only after its sender is checked. A client checks a record again: it must name the pulled agent, version and digest, and mendari pull says whether its signature holds with a key it pinned (the registry's pinned at first contact as @registry). A recall it cannot verify is still honoured, since a recall only lowers automation (E12) test_a_forged_or_replayed_yank_is_refused, test_a_yank_whose_text_was_changed_after_signing_is_refused, test_only_the_namespace_or_the_registry_recalls, test_the_registry_signs_its_own_recall, test_a_pull_shows_a_recall_and_whether_its_signature_holds, test_a_recall_body_is_read_only_after_its_sender_is_checked
S21 A forged, replayed or misaddressed CDS client token, or a spoofed EHR: a JWT signed with another key, unsigned (alg: none), MACed with the EHR's public key (HS384) or under another algorithm; one whose header names a key or a certificate (jwk, x5u, x5c) or a jku of the sender's; a valid token sent again, to another service or deployment, or made to live for hours; a token naming another tenant of a shared EHR; an open-mode server answering a JWT it never verified 2 Off until MENDARI_CDS_CLIENTS is set (LP-23b, ADR-0014): unset, a JWT on /cds-services is refused in every mode, open mode included (before, a forged token got cards there). The registry is checked at startup: unique ids and issuers; keys by value public only (RSA of 2048 to 8192 bits or EC P-384, distinct kids, as Backend Services checks them) or one jwks_uri whose origin is on MENDARI_FHIR_ALLOWED_SERVERS; FHIR bases on that list, and of the same organization as any MENDARI_SMART_EHRS registration of them; default only with sign-in off; and MENDARI_PUBLIC_URL set, https or plain http on a loopback or single-label host only (a compose service, such as the sandbox's http://engine-signin:8000; LP-23e, before: localhost and 127.0.0.1), by the one rule SMART Backend Services checks it with (origin.checked_public_url). A refusal names the entry and the field, never a value or key material. A token is checked in order, each step before anything that costs more: at most 8 KiB, three base64url segments; a header of alg, kid, typ and jku only, alg RS384 or ES384 and typ JWT; iss a registered client (the one lookup an unsigned token causes, in memory); jku exactly the registered jwks_uri, and none for keys given by value; exactly one key for the kid and key type; the signature; aud exactly MENDARI_PUBLIC_URL and the path called, never the Host header; exp, iat and jti required, 30 s of skew, iat not ahead, at most 330 s between iat and exp and from now to exp; a pinned sub and tenant exactly, and any tenant refused when none is pinned (no shared EHR); then the guard's own checks, the client's organization's record (memberships mode) and the route's permission. Only then is the jti claimed, once per client and across instances, until the token expires: the session table's cds-jti claims, which the break-glass never ends and each later claim's bounded purge removes once expired. The table keys any string, so a jti holding a lone surrogate is claimed as any other, never an error. Every refusal of the token is the one invalid_token 401, never an error, an integer past a float's range included; the security log says why (cds_<reason>, from a closed set), naming cds:<id> once the iss names a client, never the token or a claim. test_a_valid_token_is_accepted, test_a_wrong_issuer_is_refused, test_a_wrong_audience_is_refused, test_an_expired_token_is_refused, test_a_replayed_jti_is_refused_and_a_jti_is_per_client (two instances, SQLite and Postgres), test_an_unregistered_jku_is_refused, test_a_header_outside_alg_kid_typ_jku_is_refused, test_none_hs384_and_rs256_are_refused, test_a_token_from_the_future_or_living_too_long_is_refused, test_a_subject_or_tenant_other_than_registered_is_refused, test_a_refused_token_claims_no_jti, test_a_jti_holding_a_lone_surrogate_is_claimed_once, test_a_session_row_is_keyed_for_any_string, test_each_refusal_reason_comes_from_a_closed_set, test_the_registry_is_checked_at_startup, test_the_registry_needs_its_public_url_and_matching_organizations, test_the_public_url_is_plain_http_only_for_a_loopback_or_single_label_host, test_unset_means_no_cds_client, test_open_mode_refuses_an_unverified_jwt_on_cds_services, test_wrong_iss_wrong_aud_expired_replayed_and_unregistered_jku_are_each_refused_over_http, test_each_refusal_is_logged_with_its_reason_and_no_token_or_claim, test_expired_claims_are_purged_in_bounded_batches, test_every_session_kind_the_server_writes_is_in_a_group_but_claims
S22 A publisher token that outlives its owner or its purpose: one copied from a CI log or a laptop, one whose holder left the organization, or one nobody remembers making, publishing to a namespace for good 5 An owned publisher token (LP-19b, ADR-0015) names the person and the organization it belongs to, lives 1 to 365 days and can be revoked: a revoked or expired token is refused at the registry's next request, in one read, with the answer any wrong token gets. The registry keeps a token's SHA-256, never the token, and shows it once, when it is made. A token publishes only to its own namespace. An organization lists and revokes its own tokens only: another's answers as one that does not exist. The last day a token was used is kept, so an idle one can be found and revoked. A registry nobody signs in to (self-hosted, CI) mints one from the operator's command on its database, recorded as operator with a reason. Under the engine (LP-19d, MENDARI_REGISTRY=on) only a signed-in person with the keys permission mints one, for a namespace their own organization claimed, behind the origin check: never a key, a client, a publisher token or another site's page, and a body that names another organization changes nothing. Credentials are not confused there: the engine's guard reads none under /registry/ and the registry never reads a session cookie, so a signed-in browser publishes nothing; an engine key (ohk_) or access token is to the registry an unknown token, a publisher token (ohr_) is refused by the engine everywhere else, and no registry has a shared administrator token (LP-19g). The token is in the minting answer only (no-store), never in a log line, the chain or a later list. A namespace has 20 working tokens at most through those routes and an organization mints 50 a day at most; the registry's write limit is per namespace, so a new token is no new budget. tests/test_registry_tokens.py (test_a_token_names_its_owner_organization_and_expiry_and_never_its_secret, test_an_expired_token_is_refused, test_a_revoked_token_is_refused_at_once_and_revoking_is_chained, test_a_token_publishes_only_to_its_namespace, test_a_token_lives_1_to_365_days, test_another_organization_neither_lists_nor_revokes_it, test_no_shared_secret_publishes_creates_reviews_or_deletes); tests/test_registry_mount.py (test_a_member_claims_mints_publishes_and_only_to_the_claimed_namespace, test_a_session_cookie_is_not_a_publish_credential, test_an_engine_key_is_refused_by_the_registry_and_a_publisher_token_by_the_engine, test_the_mounted_registry_has_no_administrator_token, test_a_key_or_a_client_cannot_mint_a_publisher_token, test_a_viewer_cannot_claim_or_mint, test_one_organization_never_sees_or_revokes_anothers_tokens_or_claims, test_a_person_of_no_organization_is_refused, test_another_sites_page_cannot_claim_or_mint)
S23 A namespace squatted or impersonated: someone claims mendari, openhealth or a name that starts with one, takes a name another organization holds, hoards names, or publishes under a new name an agent that reaches pullers before anyone looked at who publishes there 5 A namespace is claimed for an organization (LP-19c, ADR-0015), and the claim is its link to the namespace. mendari, openhealth and every name that starts with either and a dash are refused: only the operator's command on the registry's database claims one, with a reason on the chain. A name that exists is never claimed again (409), whoever made it and whatever its claim's state; a refused name stays taken. An organization holds three pending claims at most. A claim is pending until it is decided, once, and approval needs a published version that is not deleted: until then the publisher registers keys, mints tokens and publishes as usual, and nothing of the namespace is served to anyone but its own token and a reviewer (I19). Approved, later versions and new agent names list at once: the regression check, recalls and each deploying organization's own approval still stand between a version and automation (E12). Other lookalikes are a reviewer's to refuse. Nothing over HTTP makes a namespace without a claim since LP-19g (the shared administrator token's POST /v1/namespaces is gone). tests/test_registry_claims.py (test_a_reserved_namespace_is_never_claimed, test_a_claimed_name_is_not_claimed_twice, test_an_organization_holds_three_pending_claims_at_most, test_a_claim_without_a_publish_cannot_be_approved, test_approved_it_is_listed_and_pulls, test_a_refused_namespace_never_lists_and_its_archive_is_kept)
S24 An upload passed off as another organization's or another author's: a body, a path or a query naming another organization, an archive signed by a key another organization registered or by none, or an agent named in another organization's namespace 1 Every store route acts for the organization the guard let the signed-in person through for (org_of), never one a request names; another organization's version, key or upload answers 404. An upload must be signed by one of the caller's organization's author keys that is not revoked (store_keys, registered by its administrators, chained store_key.added|revoked): the signature says which key holder built the archive, the session who sent it, and both are on the chain (store_version.created names the person by id). A store agent's id is <organization>/<name> (or a namespace the organization holds by an approved registry claim, with the registry mounted); mendari and openhealth are refused, and a copy is renamed on the way in (LP-20f). Residual: an organization's administrators choose its authors and keys; a key copied off an author's machine signs until it is revoked. tests/test_store_uploads.py (test_an_archive_signed_by_no_key_of_this_organization_is_refused, test_a_draft_in_organization_a_is_invisible_to_organization_b, test_a_copy_takes_a_new_id_in_the_organizations_namespace_and_records_its_source); tests/test_two_organizations.py
S25 A promotion forged or replayed: one claimed for another digest, another organization's version, a report that is not an evaluation of the version, or a promotion made by a key, a client or open mode 1, 6 Promotion is its own record (store_promotions, LP-20h), never the automation approval: POST /api/store/promotions needs promote (governance and admin, people only, never open mode), acts for the caller's organization, and names a version by its digest and the reports it relied on; each report must be that organization's evaluation of exactly that digest, or the promotion is refused. The chained store_version.promoted carries the digest, the authors, the approver and the report ids. tests/test_store_promotion.py (test_a_promotion_names_reports_of_this_digest_and_this_organization, test_promotion_is_bound_to_the_digest, test_a_key_a_client_and_an_author_without_the_role_never_promote)
S26 A site report forged or sent under another site's name: a signature forged or made with a key that is not the site's (a publisher's, another site's, one unregistered or revoked), a valid signature over another body, or a publisher token sharing a report 5 A site signs (LP-22, ADR-0017): a mendari.site-submission/1 is Ed25519 over a prefix and format of its own and every other field, checked against a live key of the ticket's verified site, after the ticket's one-time secret was checked and before anything is written (hub/site_reports.py). A site key is added only with its holder's proof (its own signature over the site's id and its id), is never a publisher's key nor another site's, and only the key is stored. No recall, acceptance or archive signature is a site's. A publisher token no longer shares a report. tests/test_site_reports.py (test_a_forged_signature_is_rejected, test_an_unregistered_or_revoked_key_is_rejected, test_a_valid_signature_over_a_different_body_is_rejected, test_a_publisher_token_no_longer_shares_a_report), tests/test_registry_sites.py (test_a_site_key_is_ed25519_and_never_a_publishers_or_another_sites, test_a_key_is_added_only_with_its_holders_proof_and_stored_as_the_key_alone)
S27 A site that is not who it says obtains tickets or shares reports: an unverified, refused or closed site, a ticket request forged or signed with a revoked key, or a site registered and verified by someone who may not 5 A site is a record of an organization, pending until a registry reviewer (never for their own organization or registration) or the operator's command with a reason verifies it, once; only a live key of a verified site gets a ticket, signed, within 10 minutes of the registry's clock, with a nonce used once, and a report answers only its ticket. A pending, refused or closed site answers as one that does not exist. Residual: a site's name is as good as the reviewer's check of who it is, done outside Mendari. tests/test_site_tickets.py (test_a_ticket_request_with_a_forged_signature_or_an_unregistered_key_is_refused, test_a_revoked_key_and_a_pending_site_get_no_ticket), tests/test_registry_sites.py (test_a_site_belongs_to_an_organization_and_is_pending_until_verified, test_a_pending_or_closed_site_answers_as_one_that_does_not_exist), tests/test_registry_site_accounts.py (test_a_member_registers_a_site_and_a_reviewer_verifies_it, test_a_reviewer_does_not_verify_their_own_organizations_site)
S28 A publisher evaluation (ADR-0020) that is not the publisher's, or not now: one forged, signed by another namespace's key or a revoked one, sent without the namespace's publisher token, an old one replayed to take a newer one's place, or another Mendari signature passed off as one 5 POST …/{version}/evaluations reads no body before the namespace's own publisher token; the record must be signed by a live key of that namespace over its own prefix and format (hub/evaluations.py: no archive, yank or site signature is over those bytes), within 10 minutes of the registry's clock. Its id is the SHA-256 of the signed record: the same record again is idempotent while live and refused once superseded, and one signed before the live evaluation of its configuration and dataset is refused. A key revoked later (mendari registry revoke-key, chained key.revoked) signs nothing more, and its evaluations stay listed, left out of the comparison. tests/test_publisher_evaluations.py (test_a_wrong_signature_is_refused, test_another_namespaces_key_is_refused, test_a_non_publisher_token_is_refused_before_the_body_is_read, test_a_revoked_keys_evaluations_are_listed_and_left_out, test_the_same_body_again_is_idempotent_and_a_superseded_one_is_refused, test_a_record_of_another_kind_or_time_is_refused)
T1 The audit trail is edited after the fact 6 Every event is hash-chained, and mendari audit verify detects any change, opening the database read-only (it creates, migrates and marks nothing, and a database that is not there is refused, never created empty). PHI inputs and notes live outside the chain, so retention and erasure can delete them without breaking it; each note is bound to its event by a salted commitment, and mendari audit verify --notes detects a note changed, moved or removed without a chained note.erased. Each event names the organization of the row it is about in its hashed payload, and verify detects a row moved to another organization or deleted ("reason": "organization"). Someone who can write the database can still rewrite the whole chain and every hash in it: checkpoints (audit_checkpoints, LP-21j) catch a rewrite that leaves one in place, and the signed daily checkpoint (MENDARI_CHECKPOINT_KEY, LP-21k), published at /api/audit/checkpoint and kept by anyone, catches one that rewrites them too (mendari audit verify --against). tests/test_audit.py, tests/test_phi.py, test_verify_notes_finds_a_note_changed_moved_or_removed, test_verify_finds_a_row_moved_to_another_organization_or_removed, tests/test_checkpoints.py, tests/test_signed_checkpoint.py (SQLite and Postgres)
T2 An agent's logic is swapped at a site; or a file of a loaded agent is edited in place (same file on disk, other bytes) between the load and its first read, or while the load runs, so decisions use logic the digest they record does not describe 5, 6 The agent digest is recorded on every decision and deployment. A governance approval is bound to the digest. load_agent keeps the SHA-256 of every file it hashed, and every read of an agent file (Agent.read_bytes, under read_text, read_yaml, read_json, the provider fingerprints and the datasets) checks the bytes it read against it and parses those bytes, so an edited file is refused naming it (422), never used; the server builds every agent's providers at start-up (LP-16d), so a file edited after that is never read, and a running server keeps deciding with the content its digest describes; loading the agent again picks the edit up under its new digest. tests/test_governance.py, test_a_file_edited_in_place_after_the_load_is_refused_not_used, test_a_rules_file_edited_in_place_is_refused_though_its_parse_is_kept, test_a_file_edited_while_the_agent_loads_is_refused
T3 Free text (possibly PHI) written for good into the chain and the FHIR export through a downstream outcome 1, 2 An outcome's source must be a system identifier (^[A-Za-z0-9][A-Za-z0-9._:/@-]{0,99}$) and its label one of the decision's question's labels (at most 200 characters, as for reviews); a refused label is not echoed. In FHIR the recorder is the agent and the source a source.site. tests/test_outcomes.py
T5 A pull request from a fork reaches past its diff: its code runs with the repository's secrets or a token that can write, or a required check does not run on it 7 The CI job that checks agents runs on every pull request (pull_request, never pull_request_target; no secrets, a read-only token), with no path filter that would leave it pending, and no workflow is triggered so that a fork's code runs in the base repository's context. A workflow change in a fork's pull request still runs as written (inherent to pull_request), so the owner reads every diff before approving. test_no_trigger_runs_fork_code_in_the_base_context, test_agent_check_runs_on_every_pull_request
T7 A row of the registry written past its API: a planted token, key or review, a namespace made verified, a version's metadata, a report or a review changed, a row removed, an archive's bytes replaced, or the chain emptied so planted rows pass 5 Every registry write (a namespace, its publisher type, a token, a key, a publish, a site report, a review, a recall, a deletion) appends a hash-chained event in its own transaction (hub_events, hashed as the audit chain is) holding the hash of the row it left. mendari registry verify --db (read-only, exit 1 when broken) checks every event's hash and order, that every row is the one its newest event hashed, both ways, re-hashes every archive and recomputes every key's id. The chain is unkeyed, so one rewritten whole verifies: with a signing key the registry signs its head for a day (mendari registry checkpoint, a mendari.registry-checkpoint/1 statement by MENDARI_REGISTRY_SIGNING_KEY, hub/checkpoint.py; its format is inside what is signed, so no recall, acceptance or engine checkpoint signature is one), printed for the operator to keep where the registry cannot write and never stored in the database, and mendari registry verify --checkpoint requires the chain to still hold the head a kept statement names, so a chain rewritten or cut short from before it fails; the command refuses to sign a chain that does not verify or, given the last statement, one that no longer holds its head. Residual: a checkpoint says nothing about events appended after it (verify prints how many), nothing shows a rewrite made before the first one or signed over by a later one taken without the last, whoever holds the key can sign any head, and keeping the statements is the operator's routine, not something the registry enforces; without a key only the unsigned head (GET /v1/chain/head) can be kept (residual risks) tests/test_registry_checkpoint.py (test_a_checkpoint_states_the_head_and_the_chain_holds_it, test_a_rewritten_chain_verifies_alone_and_fails_against_an_earlier_checkpoint, test_a_chain_cut_short_of_the_checkpoint_fails_against_it, test_a_statement_by_another_key_or_of_another_format_is_refused, test_a_checkpoint_needs_the_key_a_chain_that_verifies_and_a_database_that_is_there, test_taking_and_checking_a_checkpoint_leaves_the_database_as_it_was), test_every_write_is_chained_and_the_chain_verifies, test_the_command_line_verifies_read_only, test_a_changed_chain_or_a_row_written_past_the_api_does_not_verify, test_a_key_whose_id_is_not_its_key_does_not_verify, test_a_review_is_chained_and_planted_reviews_do_not_verify, test_every_state_changing_route_is_in_the_inventory, test_a_deleted_version_is_never_served_and_its_bytes_are_gone
T9 A wrong or swapped site code map: a translation that reads a site's code as an agent code it is not, one organization's map applied to another's decisions, a map changed with nothing on the record to tell, or one that names a code set no agent has, so a decision reads a record as something it does not say, and automates on it 2 MENDARI_SITE_CODES (LP-23i, core/site_codes.py) is read and checked at startup: its shape, each key given once in an object, each code set it names declared by an agent found here, and each translation's as a code that set declares; anything wrong stops the server, named by organization, code set and position, never by a system or a code. Each map belongs to one organization, and a decision reads only the map of the organization it acts for (tenancy.current(); with sign-in off the one organization is default), never another's. Each FHIR decision records its map's version and the SHA-256 of its canonical form (mendari.site-codes/1, the organization in it) in its chained record, so a changed map, or one organization's given to another, has another digest there, and /api/health shows the caller's. A translation only fills in where the agent's own codes give nothing: a coding of the set's own system wins over a translated one wherever the field finds it, on any of its paths, so a wrong translation never overrides a record's own code. A decision whose input took a value through a translation never automates, and an agent rule's BLOCK on it, final at once, becomes HUMAN_REVIEW too (the site_code cap in core/policy.py, which nothing in an agent or a setting lifts, a governance approval included), so a wrong translation reaches a person, never an AUTO or an unreviewed BLOCK. The data-coverage record is read with the same translations, so it counts what the input read. Residual: Mendari cannot tell a wrong translation into a declared code from a right one; the cap and the recorded digest are what holds until the site validates its map (G5-6 site-validation) and the owner decides about the cap. Whoever can set the server's environment can change the map, as any setting, and the change shows as a new digest on every decision after it test_the_map_is_checked_at_startup, test_a_site_code_is_translated_only_into_a_code_its_set_declares, test_each_decision_records_the_maps_version_and_digest_for_its_organization, test_another_organizations_map_is_never_applied, test_a_changed_map_is_told_apart_by_digest, test_a_decision_made_through_a_site_code_is_never_automated, test_the_data_coverage_reads_with_the_same_translations_as_the_input, tests/test_site_codes.py (SQLite and Postgres)
T10 A wrong, stale or swapped declaration that an EHR does not offer a resource type: a source the EHR does hold is never read, so what the list's other sources lack reads as complete ("no insulin among the orders" as "off insulin"); one organization's declaration applied to another's decisions; a declaration changed with nothing on the record to tell; or one that leaves a list or a field with no source at all 2 MENDARI_EHR_DECLARATIONS (standards/ehr_declarations.py) is off unless set, and then read and checked at startup: its shape, each key given once in an object, each base normalized, unique, on the FHIR allow-list and registered (MENDARI_SMART_EHRS, or a CDS client's fhir_servers) to the declaration's organization (default with sign-in off), each entry naming who attested it and where it is recorded, and each declared type an R4 type that an agent found here reads as one of several sources of a list beside a source not declared; anything wrong stops the server, named by the setting, the base and the field. A declaration applies only to its base and organization (a launch's iss, a hook's fhirServer, the organization the call acts for), never to fhir/decide, $decide or the command line, and for an agent only to a type that is one source of a multi-source list whose other, undeclared source is read, which the agent reads nowhere else (its focus, a resources rule, a top-level field, a single-source list, a follow's target); declaring every source of a list excuses none. A CDS client that sends a declared key with entries has them used as sent; sent null, empty or as a search with no entries, the key is not offered under the declaration, recorded and capped, never read as "read and empty". A decision that left a declared source out records the declaration's version, SHA-256 (of its canonical form, mendari.ehr-declarations/1, base and organization in it), who attested it and where in its chained record, marks the source and the list not_offered in its data-coverage record, and never automates: AUTO, and a rule's BLOCK, become HUMAN_REVIEW, the limitation and who attested it a reason whatever the outcome (core/policy.py); /api/health shows the caller's organization's declarations. Without a declaration a source that cannot be read abstains the decision, as before. Residual: Mendari cannot tell a true declaration from a false one; the claim that the other sources are complete (for an agent that reads a medication list, that every medication is a MedicationRequest the search returns, with an intent the list keeps) is the site's, attested and recorded, and the cap holds until the owner decides otherwise. Without a declaration, a CDS client that sends a source as null ("no data", CDS Hooks 2.0) or as an empty search has it read as empty, as before, with no limitation recorded: the client's statement. Whoever can set the server's environment can change a declaration, as any setting, and the change shows as a new digest on every decision after it test_an_undeclared_medication_statement_refusal_never_reads_as_off_insulin, test_a_declared_not_offered_type_is_not_requested_and_the_decision_records_it, test_a_declaration_never_applies_to_another_base_or_organization, test_a_hook_reads_the_declaration_for_its_fhir_server_and_organization, test_a_launch_reads_the_declaration_for_its_issuer_and_organization, test_a_declaration_never_automates, test_a_declared_type_an_agent_reads_elsewhere_is_read_as_without_the_declaration, test_a_cds_client_may_still_send_a_declared_key, test_the_declaration_setting_is_checked_at_startup, test_each_declaration_is_checked_against_the_deployment, test_health_shows_the_organizations_declarations (SQLite and Postgres)
T11 A version the registry never accepted, served as one it did: a row written straight into the registry's database (by a stolen database credential, or an injection), a compromised registry process or host serving another archive or digest under a real version, or one version's record moved onto another 5 With a signing key (MENDARI_REGISTRY_SIGNING_KEY) the registry counter-signs each version when it becomes listed (LP-19i, ADR-0015, hub/acceptance.py): an Ed25519 mendari.registry-acceptance/1 record naming the agent, version, digest, archive SHA-256 and the publisher key that signed the archive, chained agent.accepted. The record's format is inside what is signed, so a recall or a checkpoint signed by the same key is never one. mendari pull checks it before it fetches the archive, with a key shipped with the client (registry_keys.json, public keys only, never a hostname) or the one pinned for that registry on first use: a version whose record is missing, does not verify or names another agent, version, digest, archive or publisher key is refused and nothing is cached, and so is a registry that published a key before and now publishes none or another. Then the archive must hash to the recorded SHA-256, be signed by the publisher key the record names and load with its digest. A pending namespace's versions are signed at approval, a refused one's never. The backfill (mendari registry countersign) and an approval sign after the fact, so each checks a version again from what is stored (its archive, signed by a key of its namespace, naming this agent, version and digest) and skips one that fails, and the backfill refuses to run on a chain that does not verify. A pin file that cannot be read is refused, never read as empty, is written whole, and files one registry under one address however it is typed. Residual: the record proves the registry's key signed, not that the key is safe, so whoever holds the key (it lives in the registry's environment) can sign anything, and the namespace's own signature, pinned separately, is still required; a registry that has never published a key to a machine is pulled from as before (accepted: null, said at the pull), so a machine's first contact with a registry whose key is not shipped trusts what it is shown, as with a first SSH connection; a shipped key does not make a signature required: with no pin, a registry that shows no key, or any other valid key, is accepted on first contact before the shipped keys count, so shipping the key adds nothing against a first contact with an impostor unless the machine sets MENDARI_REGISTRY_COUNTERSIGNATURE (required: a registry that shows no key is refused; shipped: only a shipped key is trusted, nothing on first use), which is off unless set; a running server closes the gap for a copy already in the cache: the read it makes of each registry's recalls also asks whether the registry publishes a key (GET /v1/registry-key), and once it does, a copy whose marker does not record accepted: true stops automating as a recalled one does, with a reason that says to pull it again, until mendari pull fetches it counter-signed (a registry with no key changes nothing, one that cannot be read keeps what was known until it is stale, and the copy is never removed); Decision.from_hub and mendari decide still load a cached copy without this check; there is no freshness or revocation: a deleted version's record still verifies and a writer of the database can serve an older accepted version as the latest; a writer of the database who also rewrites the unkeyed chain and plants a namespace key can have the backfill sign a planted version: mendari registry countersign --checkpoint FILE refuses to sign when the chain no longer holds the head of a signed checkpoint kept outside the database (T7), so that needs a run without one (which says so in its output) or a checkpoint taken after the rewrite; a writer who appends the key and the version to the chain instead of rewriting it is not shown by any checkpoint, only bounded to the events since the last one, which verify --checkpoint counts for the operator to read; the shipped file holds the Mendari registry's key (2026-11-15); there is no rotation path yet. tests/test_registry_acceptance.py (test_an_accepted_version_carries_a_record_that_verifies, test_a_version_planted_in_the_database_has_no_record_and_is_not_pulled, test_a_record_for_another_version_digest_archive_or_key_is_refused, test_a_recall_or_a_checkpoint_signature_is_not_an_acceptance, test_a_pending_version_is_signed_at_approval_and_a_refused_one_never, test_a_registry_that_drops_or_changes_its_key_is_refused, test_a_shipped_key_is_trusted_without_first_use, test_without_a_key_pull_works_and_says_not_counter_signed, test_countersign_signs_what_was_published_before_and_twice_changes_nothing, test_the_shipped_file_holds_public_keys_only, test_countersign_refuses_a_broken_chain_and_never_signs_a_planted_version, test_approval_never_signs_a_version_planted_while_the_claim_was_pending, test_a_signing_key_that_is_not_one_is_a_clear_error_and_never_shown, test_a_pin_file_that_cannot_be_read_is_refused_and_is_written_whole, test_one_registry_has_one_pin_however_its_address_is_typed, test_a_machine_can_require_the_counter_signature), tests/test_registry_checkpoint.py (test_a_rewritten_chain_verifies_alone_and_fails_against_an_earlier_checkpoint, test_countersign_takes_a_checkpoint_and_says_which), tests/test_registry_recalls.py (test_a_running_server_holds_a_copy_its_registry_never_counter_signed, SQLite and Postgres, test_once_its_registry_has_a_key_a_copy_it_never_counter_signed_is_held)
T12 A stored agent version changed in place: its files, its id or its state rewritten in the database, so what an organization tested, or later approved, is not what runs 6 A version is keyed by the digest load_agent hashed from the files it was given (LP-20e, core/agent_store.py), never one it is told, and is written once: a second write of the same digest is refused (409), and an edit is a new version with a parent. Its row's columns that never change are hashed into its store_version.created event, and each state is one chained event: mendari audit verify fails (reason: "store") on a row changed past the store, a state no event moved it to, or a version with no event. Each file is kept once by its SHA-256, and a version loaded from the database is checked against its digest before it is used; mendari store verify re-hashes every kept file and version. Residual: whoever can write the whole database can rewrite the chain too (the chain is unkeyed; the signed checkpoint, LP-21k, covers it). tests/test_agent_store.py (test_a_version_is_keyed_by_the_digest_the_loader_hashed_and_never_one_it_is_told, test_a_stored_version_never_changes, test_a_fresh_process_loads_a_version_from_the_database_alone, test_audit_verify_passes_after_every_store_event)
T13 A served version that is not the promoted bytes, or one served to an organization that did not promote it, or in place of an agent on disk 1, 6 A request is served the agents read from disk at start-up and its own organization's promoted versions only (served_here, by tenancy.current(), cached a few seconds per organization and cleared at once by a promotion or retirement in the process); each promoted version is loaded from the database and checked against its digest before it is built, and its Decision is kept by digest and promotion. A version whose id the deployment serves from disk is never promoted, and a disk agent is never shadowed. Promoting a new version retires the one before in the same transaction; retiring stops serving at once in the process, within seconds elsewhere. tests/test_store_promotion.py (test_a_promoted_version_is_served_to_its_organization_and_to_no_other, test_a_store_agent_never_replaces_an_agent_the_deployment_serves_from_disk, test_promoting_retires_the_version_before_and_both_are_chained, test_a_retired_promotion_stops_serving_at_once_in_this_process)
T14 A site result picked after the fact or replayed: several runs and the best one shared, a run on other data than its ticket's, the same submission or ticket request sent again, a bad result withdrawn and run again, or a report quietly replaced 5 A ticket comes first (LP-22e): bound to the site, the agent's digest, the configuration, the dataset's size and an HMAC of the dataset file under a secret only the site holds; one live result per site, digest, configuration and dataset; a ticket takes one report, once, and the report must be the ticket's (digest, configuration, n, consent). Nonces are used once. An expired ticket is not withdrawn, and a withdrawn one keeps its dataset's slot spent. A correction names the report it supersedes, and both stay listed; unreported, withdrawn and superseded counts are served beside the pooled figures. Residual: a ticket binds a dataset before its run, not how its cases were chosen, and a correction may use other data than the report it replaces (an open owner decision). tests/test_site_tickets.py (test_one_live_ticket_per_site_digest_configuration_and_commitment, test_a_replayed_ticket_request_is_refused, test_an_expired_ticket_is_not_withdrawn_and_a_withdrawal_is_one_field), tests/test_site_reports.py (test_a_replay_is_rejected, test_a_report_for_another_digest_configuration_size_or_site_than_its_ticket_is_rejected, test_a_correction_supersedes_and_both_stay_listed), tests/test_site_evidence.py (test_unreported_tickets_and_superseded_reports_are_counted_beside_the_figures)
T15 Site evidence that does not mean what it says: rows of sites, keys, tickets or reports written past the API, reports pooled across agent versions or configurations, a recalled version still taking reports, or a report under a compromised key still pooled 5 Every site write is chained with its row's hash (site.*, report.shared; ROWS covers sites, site keys, tickets, corrections and signed reports), so mendari registry verify finds a row planted or changed past the API. Evidence is worked out per digest, configuration and consent, never across them; a version recalled, deleted or unlisted after a ticket takes no report; the publisher's own site, compromised keys' reports and superseded reports are listed and left out of the pool. tests/test_registry_chain.py (test_a_changed_chain_or_a_row_written_past_the_api_does_not_verify), tests/test_site_reports.py (test_the_registry_chain_verifies_after_a_ticket_a_report_and_a_supersession, test_a_recalled_version_takes_no_report_on_a_ticket_issued_before), tests/test_site_evidence.py (test_two_digests_or_two_configurations_are_never_pooled, test_the_publishers_own_site_is_listed_and_left_out_of_the_pool, test_reports_under_a_compromised_key_leave_the_pool)
T16 A publisher evaluation that flatters: counts the run did not give, a dataset or digest other than the version's, a configuration the agent does not have, a rate in place of counts, or a figure the Hub shows that the registry did not compute 5 Counts in, rates out: the record holds mendari.site-report/1 counts, whole, adding up to the totals they state, under the agent's own policy, and the registry computes every figure it serves. It is bound to the signed archive: the version listed (not recalled or deleted), its digest, a dataset its manifest declares with that SHA-256 and n, every slot with a declared variant. A configuration whose providers are all local is re-run in the regression check's isolated child and refused unless the counts match exactly; with re-runs off it is refused, never taken unchecked. One that calls a model is not re-run, and the Hub says so on its row. Residual: a model-backed row is the publisher's word, and any row may be tuned to the publisher's own public set; the page says both. tests/test_publisher_evaluations.py (test_a_local_evaluation_with_one_count_changed_is_refused, test_a_digest_that_is_not_the_versions_is_refused, test_a_dataset_not_in_the_archive_is_refused, test_an_unknown_slot_or_variant_is_refused, test_a_recalled_or_deleted_version_is_refused, test_with_re_runs_off_a_local_configuration_is_refused, test_the_figures_are_the_registrys_from_the_counts)
T17 A judge of written output presented as validated when it is not: a closed round's stored report or a stored grade edited in the database; a state decided on a handful of bootstrap draws, or on a seed picked after the grades were in; outputs the judge could not grade left out of the count 1 A closed round's report is served only while its hash, recomputed from the stored report, is the one its closing chained; a full audit verify checks every closed round's report, every stored grade's salted commitment and the grader its event names, and a grade or closed round no event accounts for. A state is never decided on fewer than 2,000 resamples, refused by the command line and the store before anything changes; the bootstrap's seed is a constant for a command and, for a round, the seed chained when it was made. An output the judge could not grade is counted: never a pass, a failure not found on a must-not-fail criterion, and against a ceiling a manifest may only lower. tests/test_written_store.py (test_a_stored_report_edited_in_the_database_is_not_served_and_breaks_verification, test_verify_checks_every_stored_grade_and_closed_round_against_the_chain, test_verify_finds_a_grade_no_event_accounts_for, test_closing_checks_its_arguments_before_it_changes_anything, test_a_rounds_seed_is_fixed_when_it_is_made_and_is_the_reports), tests/test_written_report.py (test_a_state_is_never_decided_on_a_handful_of_resamples, test_a_failure_the_judge_could_not_grade_is_a_failure_it_did_not_find, test_a_scored_criterion_is_held_to_agreement_on_pass_or_fail_too)
R1 Someone denies a review, an outcome, an approval or a decision they asked for 1 With sign-in on, the reviewer, reporter, outcome recorder (recorded_by), approver, input reader and key or client creator are the signed-in principal, whatever the request body says, and every new decision.created names who asked for it (requested_by: the person, key, client or EHR launch, set by the guard with the organization; the FHIR exports show it as the AuditEvent's requestor and a Provenance agent of role "requester"; events chained before are never rewritten), chained under an identity the identity provider vouches for: a person's verified email (email_verified: true), else their subject qualified by the issuer, never a display name anyone can change; a key as key <id> (its name is free text an admin may reuse), a client as client <id>. In open mode the names the client gives must be identifiers (no spaces, at most 100 characters). test_reviews_and_ratings_are_recorded_for_whoever_is_signed_in, test_people_are_chained_by_verified_email_else_by_issuer_and_subject, test_an_outcome_is_recorded_for_whoever_sends_it, test_open_mode_names_are_identifiers, test_decision_created_names_who_asked, test_a_decision_names_who_asked_for_it
R2 Someone's actions can't be traced after an incident (who signed in, what was refused or limited, who changed a key, client or approval, who exported or read inputs) 1, 2 A security log on stdout (server/security_log.py), into Vercel's runtime logs or the site's log system: one access line per /api, /fhir, /cds-services, /auth and /smart request (the route's template, never its query), and an event for each sign-in and EHR launch (and refusal, with its reason: smart.launch.ok|refused for a launch), refused credential or permission (a CDS client's token refused names its reason, cds_<reason>, and the client once its iss names one, S21), a CDS client's keys refused (cds.jwks.refused), token issued or refused, rate limit hit (once per bucket and window), quota reached, refused request from another site (auth.origin.refused, E6), key, client (admin.client.registered|keys_replaced|revoked) and governance change, invitation and membership change (memberships mode: admin.invitation.*, admin.membership.*, admin.access.*, auth.invitation.accepted), export, evaluation and, under hash or encrypt, the decisions whose input or notes a reader was shown (their ids and a count, matching the chain's input.read). Each line names the caller by an opaque id (user:<hash>, key:<id>, client:<id>, ehr:<hash> for an EHR launch, whose smart.launch.ok line also carries it and, with sign-in on, its organization; cds:<id> for a CDS client's verified token, whose decisions the chain names cds <id>) and carries the request id that the response returns in X-Request-Id (and JSON errors as request_id). The chain keeps what must last; the log's retention is the platform's (a day on Vercel Pro) unless a drain or the site keeps it longer. tests/test_security_log.py, test_each_administrators_change_is_logged_by_its_ids, test_refusals_are_logged_by_client_id_only, test_a_refusal_is_logged_with_its_reason_and_answered_with_a_request_id, test_a_note_read_without_its_input_is_logged_as_the_chain_has_it, test_each_ehr_launch_is_logged_with_its_reason_and_never_its_values, test_a_launch_decides_in_its_registered_organization, test_each_refusal_is_logged_with_its_reason_and_no_token_or_claim, test_a_valid_token_reads_discovery_and_calls_the_hook
R3 Someone denies a registry write: a publish, a key added, a site report, a review, a recall or a deletion 5 A site report is signed by its site and kept as received (R9). Each registry event names who acted: a person by id (user:<hash>: a reviewer, or an organization's administrator under the engine), the operator's command with who ran it and, where it asks, why, or a publisher token by its id (token:<id>, the start of its SHA-256, never the token, which is stored hashed); an owned token names its owner and organization in its own token.issued. A publisher's recall is also signed with one of its namespace's keys, and a publish with the key that signed its archive. There is no shared administrator token (LP-19g): events from before it that name admin stay as they were. Residual: on a registry nobody signs in to, the operator's commands name the command line's user, which is only as true as the machine that ran them (residual risks) test_every_write_is_chained_and_the_chain_verifies, test_tokens_are_stored_hashed, test_a_review_confirms_or_corrects_the_declared_risk_level, test_only_the_namespace_or_the_registry_recalls, test_approval_refusal_review_recall_and_deletion_are_chained_by_the_reviewers_id, test_no_shared_secret_publishes_creates_reviews_or_deletes
R5 Card feedback that names another organization's decision, another agent's, or one another caller asked for, to put words in the chain about it, or to learn by its answer that it exists 1, 2 POST /cds-services/{id}/feedback (LP-23f) is a decide route of its own (its rule sits before the catch-all that needs admin, its scope is DECIDE), and the store records every item or none, in one transaction (AuditStore.record_card_feedback): each card must be a decision of that service's agent, in the organization the request acts for, and, when the caller is named (sign-in on, or a CDS client's verified token), one whose chained decision.created names that same caller as requested_by. Anything else is one 404 for the whole request, whichever it is, repeating only the ids sent, and nothing is chained. What a card did not offer (a suggestion other than its own, a reason outside Mendari's override CodeSystem), any field CDS Hooks 2.0 does not define (a Coding is system, code and display; extension, which CDS Hooks 2.0 reserves for implementations, is accepted on any object and never kept) and an outcomeTimestamp with no time in UTC are a 422 before anything is looked up. Each card.feedback names who sent it (reporter) and, on every database, its decision's organization, which verify checks. tests/test_cds_feedback.py (test_feedback_naming_another_organizations_agents_or_callers_decision_answers_as_unknown, test_an_override_reason_or_suggestion_the_card_did_not_offer_is_refused_and_nothing_is_written, test_an_extension_is_taken_on_any_object_and_never_kept, test_audit_verify_passes_after_feedback, SQLite and Postgres), test_every_route_called_as_two_organizations_shows_neither_the_others_data, test_every_route_has_the_permission_it_should
R6 Nobody can say who made or revoked a publisher token, who claimed a namespace or approved it, or for which organization, after an agent was published with it 5 Minting an owned token and revoking it are events in the registry's chain (token.issued, token.revoked), each with the token's id (never the token), its namespace, its organization, its owner or who revoked it, its expiry, and, for the operator's command, who ran it and why. Each event holds the hash of the row it left, so mendari registry verify finds a token planted, changed or un-revoked past the API. A publish names the token that made it (token:<id>). The last day a token was used is outside the chain (a row that changes without an event would break it) and is a convenience, never evidence. A claim and its decision are chained too (LP-19c): namespace.created and namespace.claimed with the organization and who claimed, namespace.approved or namespace.refused with who decided and their note, and every agent.published with the organization its namespace is linked to and whether it was listed then. The claim's row is hashed into each event, so a claim planted, removed or approved past the API does not verify. A reviewer's acts (LP-19e) are the same events by the same store methods, naming the reviewer by id (user:<hash>) where the shared administrator token wrote admin: a claim's decision, a publisher type, a review, a registry recall and a deletion, and the operator's commands for each name who ran them. test_a_revoked_token_is_refused_at_once_and_revoking_is_chained, test_the_operators_token_records_operator_and_why, test_using_a_token_records_the_day_and_the_chain_still_verifies, test_claim_approval_and_publish_are_chained_with_the_organization, test_the_operators_commands_claim_approve_refuse_and_list, test_a_changed_chain_or_a_row_written_past_the_api_does_not_verify, test_approval_refusal_review_recall_and_deletion_are_chained_by_the_reviewers_id, test_the_operators_commands_set_a_type_review_recall_and_delete
R7 Nobody can say who promoted a version, on what evidence, or which promotion let a decision's version serve 6 Each promotion is a row and a chained store_version.promoted event naming the digest, everyone who made a version on its chain, the approver and the report ids; a retirement is store_version.retired. Every decision a store version makes records the promotion's id beside the agent's digest, so the trail leads from a decision to who signed its version off and on which reports. audit verify checks each version's state against its newest event. tests/test_store_promotion.py (test_a_decision_names_the_promotion_that_let_its_version_serve, test_audit_verify_passes_after_a_promotion)
R9 A site denies what it shared, or that it registered, verified or revoked a key 5 The registry keeps each signed submission as it was received and serves it (GET …/reports/{id}), so anyone checks it against the site's public key (GET /v1/sites/{id}); report.shared holds the site, key, ticket and the body's SHA-256. Registering, verifying, refusing and closing a site, adding and revoking a key (with whether it is compromised), issuing, withdrawing and reporting a ticket are chained with the organization and who acted. tests/test_site_reports.py (test_a_verified_report_names_its_site_key_and_ticket_and_its_signature_checks), tests/test_registry_sites.py (test_registration_verification_keys_and_revocation_are_chained_with_the_organization, test_the_operators_site_records_operator_and_why)
I1 PHI leaks through storage 6 PHI mode hash stores no input, no evidence and no note (a note is refused with 422). encrypt uses AES-256-GCM bound to the decision id for inputs, to the decision for an input's sealed evidence (mendari-details-v1), and to the note's kind, id and decision for notes, apart from the chain, with a retention purge for all three, run daily on Vercel (CRON_SECRET), and mendari phi erase (or an admin's POST /api/audit/{id}/erase) for one decision on request. The hosted site runs encrypt by default and refuses off; elsewhere sign-in refuses off too, set or unset, on SQLite and Postgres alike, and the EHR launch without sign-in needs a chosen mode (off written out starts with a warning); and a database once kept under hash or encrypt never takes plaintext again (a server under off refuses to start on it, a command refuses to write). What an older record holds itself (an input kept under off) opens only for a reader, each read chained; a test asks every read route as every kind of principal. The PHI key rotates in place: a ring (MENDARI_PHI_READ_KEYS), values re-sealed in chained batches (mendari phi rotate) and a check that everything opens with the new key alone before the old one is dropped; a key a rotation moved values off seals nothing more. tests/test_hosted_data.py, tests/test_phi.py, test_phi_mode_hash_refuses_a_note_and_keeps_nothing, test_a_sealed_note_opens_only_as_itself, test_sealed_details_open_only_for_their_own_decision, tests/test_rotation.py
I2 PHI leaks to someone who shouldn't read it 1 Encrypted inputs and notes open only for signed-in reviewers and admins, and every read is chained (one input.read per decision, naming the notes). Lists never carry inputs. test_signed_in_reviewers_read_inputs_and_each_read_is_chained, test_viewers_never_see_a_note_and_reviewers_do
I3 PHI leaks into reports, errors or exports all Reports carry ids and metrics, never case text. Provider errors are stable codes without remote bodies. A shared report is a closed format of names and whole counts (mendari.site-report/1, the same model and the same suppression function on the client and the registry, which checks the token before reading at most 2 MB and never echoes what it refuses): no case id, subgroup, dataset name, approver or rate, cells of 1 to 9 suppressed with their complements, nothing shared under 100 cases; population reports suppress cells under 10. The FHIR audit export carries codes and hashes. tests/test_share.py, tests/test_audit_fhir.py
I4 One organization sees another's data 1 Tenancy lives in a context variable. The store filters every read and stamps every write. An EHR launch acts for the organization its EHR's FHIR base is registered to (MENDARI_SMART_EHRS, the whole base, so two tenants of one EHR host are two organizations), never the default one; one FHIR base serving several organizations is not supported. In memberships mode (MENDARI_ACCOUNTS=memberships, ADR-0008) a person's organization is the membership they chose, read on every request, never a claim: a sign-in without one acts for no organization, never default, and is refused (NoOrganization, 403) in the guard before every route but the public ones, the pages and their own three (choosing one of theirs, asking to join, accepting an invitation for their verified address), whatever roles it holds, before any body, limit or stream; the guard then acts for nobody, so organization data reached through tenancy is refused too. The routes that manage an organization's invitations, members and requests to join act on the organization the guard let the administrator through for, never one a body or a path names: another organization's id is a 404, and its lists are never shown. A key's or a client's history and replacing a client's keys are attributed through the key's or client's row: another organization's ("" included) is the same 404 as an unknown one, never data. Keys, clients and EHR launches of an organization with no record are refused there. An organization's administrators read and export its administrative events (/api/audit/administrative, LP-12g) through the rows it owns, never by chain id alone: no other organization's events, no deployment's own, no seq; a cursor or subject of another organization is refused as an unknown one is. In memberships mode the deployment-wide views (the whole chain's verification, the deployment records, call totals, the operator's hold reasons) are the operator's. Residual: an organization's own decision trail shows each event's seq, prev_hash and hash, and its administrative events their hash; from them it can tell when two of its events are adjacent in the deployment's one chain, and confirm a guessed event between them (a purge's counts, a user.recorded, a notice.acknowledged), never read one. test_organizations_never_see_each_others_work, test_every_route_called_as_two_organizations_shows_neither_the_others_data (every mounted route, called as two organizations in both account modes, with the other's live ids and with its own; its reviewed allow-list of deployment-wide routes and fields is DEPLOYMENT_WIDE and FIELDS in tests/test_two_organizations.py), test_an_organization_reads_only_its_own_administrative_events, test_a_cursor_of_another_organization_is_refused_as_any_other, test_memberships_mode_leaves_the_deployment_wide_views_to_the_operator, test_a_sign_in_without_a_membership_acts_for_no_organization_never_default, test_a_principal_of_no_organization_is_refused_before_every_route_that_takes_one, test_no_route_serves_a_principal_of_no_organization, test_a_person_of_no_organization_acts_for_nobody, test_a_key_of_an_organization_with_no_record_is_refused, test_a_client_of_an_organization_with_no_record_is_refused, test_a_launch_of_an_organization_with_no_record_is_refused, test_a_route_reached_without_an_organization_is_refused_never_widened, test_another_organizations_invitation_member_or_request_is_not_found, test_a_launch_decides_in_its_registered_organization, test_two_tenants_on_one_origin_map_to_two_organizations, test_history_is_read_through_its_rows_organization, test_a_clients_history_is_its_chain_in_order_and_its_organizations_only, test_claims_mode_reads_its_own_organizations_credential_history, test_an_empty_organization_is_one_not_every (SQLite and Postgres)
I5 Data goes to a model provider unexpectedly 4 Remote providers are off until configured. A remote model variant sends only the input fields its state_fields names, and nothing else: an owned agent (maintained or local) that omits them sends the whole input, its operator's choice; an agent the deployment does not own (a registry agent whose digest is no bundled agent's) must name at least one on every llm variant and composite member, or it is refused at load (LP-16e). Where the data may go is the deployment's too: with MENDARI_PROVIDER_ALLOWED_ORIGINS set, a request to any origin it does not list (the AI Gateway's default included) is refused before a credential is read or a connection opened (invalid_endpoint, so the decision goes to a person), an LLM_BASE_URL off it stops startup, and signed-in /api/health shows the list (provider_allowed_origins); unset, nothing changes. tests/test_llm.py, test_a_registry_agents_remote_variant_needs_state_fields, test_a_call_outside_the_allow_list_is_refused_before_it_leaves, test_an_llm_off_the_allow_list_reads_no_key_and_spends_no_budget, test_health_reports_the_provider_allow_list
I6 The browser leaks a session or page, or another subdomain plants or shadows a session cookie 1 HttpOnly, Secure cookies that say SameSite=Lax explicitly (so Chrome's two-minute exception for cookies without the attribute never applies), with Path=/, no Domain and no Max-Age, named __Host-mendari_session and __Host-mendari_smart, so only this exact host can set them (the plain names on loopback and dotless hosts, where browsers may refuse the prefix over http). On any other host the plain names are never read (since 2026-11-22), so a cookie a sibling subdomain plants under one names nothing. HSTS (two years) on every host but this machine. Headers on every response, with no page exempt: a CSP with each page's own inline scripts by hash only and nothing from another origin, frame-ancestors 'none', nosniff, no referrer, COOP/COEP/CORP. The API reference (/docs/reference) is Swagger UI vendored at a pinned version, never loaded from a CDN, under a CSP with no inline script or style; it never calls Swagger's online validator. The public developer landing (/docs) is built once at startup from settings (never from a request's Host), under a CSP with no inline style, and with sign-in on shows nothing that differs with the agents installed: no agent, provider, count or record. tests/test_security_headers.py, tests/test_vendor.py, tests/browser/test_docs.py, tests/test_landing.py, tests/browser/test_landing.py, test_hsts_on_every_host_but_this_machine, test_cookies_of_a_sign_in_say_samesite_lax_explicitly, test_signing_in_starts_a_session_with_the_mapped_role, test_a_plain_name_cookie_reaches_no_row, test_the_old_cookie_name_is_ignored, test_local_and_dotless_hosts_keep_the_plain_names; ZAP
I7 Public health or metadata tells a stranger how the deployment is set up (agents, providers, the LLM endpoint and model, FHIR servers it calls, PHI mode, today's usage) 1 Without a credential /api/health is {status, version, sign_in}, enough for a load balancer; readiness (/api/health/ready) adds two fixed codes (the database ok or unreachable; the agents ok, degraded or none), never an error's text, an agent id or a count. The rest needs a principal that may read (everyone in open mode); a credential that is not valid, or a key scoped away from reads, gets the three fields. With sign-in on, the public CapabilityStatement (/fhir/metadata) names no agent: it says the agents are listed for signed-in callers. The operations it offers are the ones the served agents use, so they still tell whether any served agent takes FHIR input. test_anonymous_health_is_three_fields_and_no_database_work, test_the_settings_in_health_need_the_read_permission, test_readiness_tells_no_error_text, test_agents_that_did_not_load_make_readiness_degraded_and_no_agent_unready, test_with_sign_in_on_the_statement_names_no_agent
I8 Free text (a review or rating note) kept for good in the chain, where it can never be erased 1, 6 Commit, don't copy: notes are kept in a notes table (sealed under encrypt, refused under hash), and the chain keeps note: null and a commitment, sha256(prefix ‖ salt ‖ text), whose 32-byte salt is only in the note's row, so the commitment says nothing about the text and is noise once the note is erased. Retention (mendari phi purge) and mendari notes erase chain note.erased. The FHIR exports carry codes only: no note. Backups, the database's history and earlier exports keep an erased note until they expire. tests/test_notes.py (SQLite and Postgres)
I9 Values of the input kept for good in the chained decision record, or recovered from its hash 1, 6 Under hash and encrypt, and for an agent that keeps only the hash, the record's evidence is empty (under encrypt it is sealed beside the input and opens with it); in every mode, an input issue and the reason refusing an input name a resource by type and position (Patient (entry 2)), never its logical id; the input hash is hmac-sha256:<key id>:<hex> under MENDARI_INPUT_HASH_KEY, without which the engine refuses to start in those modes (so does mendari decide --db, which records under the deployment's PHI mode as the server does), so a dictionary of guesses matches nothing. The caller's own answer keeps evidence and ids. tests/test_record_hygiene.py (SQLite and Postgres), test_a_dictionary_of_guesses_finds_nothing_against_a_keyed_hash, test_decide_records_under_the_deployments_phi_mode
I10 Secrets or PHI written to logs (a credential, a callback's code, a search value, a body, an exception's message quoting the input), or a forged line injected all Security log fields come from an allow-list (no free text: a fixed reason code, a route's template rather than its path, opaque ids), values are JSON-escaped on one line, and a client's X-Request-Id is used only when it is 8 to 128 of A-Za-z0-9._:-. An unhandled exception is logged as its type and frames; under PHI mode hash or encrypt the exception the server prints is replaced by one naming only the type. mendari serve turns off uvicorn's access log (it prints query strings). Libraries that log a URL or a connection at INFO (httpx: a FHIR read's Patient id, the alert webhook's secret path; psycopg's pool) are held at WARNING by every app, since Vercel's runtime gives the root logger INFO and a handler; the alert webhook URL is treated as a secret. Vercel's own request log still records paths with their query strings, so credentials are refused in URLs and search criteria can go in a POST form. An invitation's token travels only in its link's fragment and a POST body, never in a path, a query or a log field (S14). The invitation page holds the token only in its tab's sessionStorage and sends it only in the accept request's body; the page itself is never logged (it is no API route) and never holds a token (S14). test_every_line_is_json_with_allowed_keys_and_never_a_secret, test_the_invitation_token_is_shown_once_and_never_logged_or_echoed, test_a_newline_in_a_value_stays_inside_its_line, test_every_response_carries_a_request_id_and_errors_repeat_it, test_an_unhandled_error_logs_its_type_and_frames_never_its_message, test_mendari_serve_trusts_forwarded_addresses_only_from_the_proxies_given, test_no_library_logs_a_url_when_the_host_logs_info, test_the_invite_page_is_never_logged_and_holds_no_token, test_a_link_is_never_kept_or_logged
I11 An EHR launch's rows read or changed at rest: its access token (anyone holding it acts at the EHR as the clinician until it expires), the patient and encounter in context, the pending launch's PKCE verifier and nonce, read from the database, a backup, its WAL or point-in-time history, a replica or a read-only connection; or a database writer who edits a row, swaps two rows' data, or pushes a row's expiry 6 The session and pending rows of the session table are sealed (core/session_seal.py, ADR-0006): AES-256-GCM under a key derived with HKDF-SHA256 from the secret that names the row (salt mendari-session-seal-v1, info the kind), which only the browser holds: the session cookie for a session, the launch's binding cookie for a pending launch (never its state, which travels in URLs). The table keeps sha256(kind ‖ 0x00 ‖ value) as the key, so it cannot derive the seal's key. The associated data binds each sealed value to its kind and row. Stored as {"sealed":"s1:…"}, so a release from before fails closed on it. A row that does not open (a changed byte, another row's or kind's data, plaintext from before sealing) is deleted and read as absent, so the launch ends; a session ends at its sealed absolute_at. The access token must be printable ASCII without spaces, at most 16 KiB; refresh tokens and the id_token are never kept, and offline_access in MENDARI_SMART_SCOPES refuses the launch (never startup). No key to provision, rotate or lose, in every PHI mode. People's sign-in rows (user, oidc-pending) hold no token and are not sealed (residual risks). test_a_launch_session_row_holds_nothing_readable, test_a_pending_launch_row_holds_no_readable_verifier_or_state, test_a_sealed_row_opens_only_in_its_own_row_and_kind, test_a_tampered_or_plaintext_launch_row_ends_the_launch, test_a_launch_ends_at_its_sealed_absolute_limit, test_a_token_outside_the_oauth_syntax_is_refused_at_launch, test_offline_access_is_refused_at_launch, test_sign_in_sessions_are_untouched (SQLite and Postgres)
I16 Another site's page reads hook answers through CORS: a page on any origin, or on one CDS client's registered origin with another client's token, calls /cds-services from a browser and reads the cards (a patient's decision and its reasons), or rides the browser's Mendari cookie to call as the person signed in 1, 2 Off until a CDS client registers origins (MENDARI_CDS_CLIENTS, LP-23c, ADR-0014): with none, no answer carries a CORS header and no preflight is granted, as before. Then CORS (server/cors.py) serves /cds-services and its children only, and only the exact origins the registry lists: a preflight from one is answered before the guard (204, GET, POST, OPTIONS, the headers authorization and content-type only, ten minutes), and each answer to one names it in Access-Control-Allow-Origin, with Vary: Origin on every answer there. Access-Control-Allow-Credentials is never sent, so a browser can read no answer to a request that carried a cookie. Any other origin gets no CORS header, and its preflight and calls are refused by the origin check as before (403, auth.origin.refused). The origin check lets a registered origin through on /cds-services only, and never with a Mendari cookie, so a page there cannot call as the person signed in. With sign-in on the guard still needs a credential; a CDS client's token from a browser page must come from one of that client's own origins or from this site, else 403 (cds_origin, with cds:<id>) before its jti is claimed, so another client's registered origin cannot use it. In open mode the services answer this machine only (E16). Cross-Origin-Resource-Policy: same-origin stays on every answer: it governs no-cors loads, and a browser test shows a CORS read works beside it. test_a_registered_origin_gets_cors_on_cds_services_only, test_a_preflight_is_answered_before_the_guard_without_credentials, test_an_unregistered_origin_gets_no_cors_and_is_refused_as_before, test_an_origin_registered_for_another_client_is_refused, test_another_sites_requests_reach_exactly_the_public_routes_and_pages, test_every_route_and_kind_of_request_gets_what_it_should; browser suite: test_a_page_on_a_registered_origin_reads_a_hook_answer
I17 Patient data kept for good in a FHIR decision's chained record through its data-coverage record or the reasons it abstains with: a value, an id, a note's text or link, a patient's code, a site's own code system (an EHR's OID can name its customer), the URL or query a read used (it holds the patient's id), or what a FHIR server answered 2, 3, 6 The data-coverage record (standards/data_coverage.py, mendari.data-coverage/1, LP-23d) is built from counts and the agent's own words only: the paths and resource types the mapping names, the code systems the agent declares (code_systems, and of those only the ones a field selects on, when it selects on any), the codes the agent itself looks for (its focus_where values, a field's map keys and a code set's codes), counts of the references a follow found and reached, and reason codes from a closed set (errors.ReadReason, a type mypy holds every raise in fhir_client to). A coding from any other system, or with none, counts as other, never by name. A decision that could not read part of its record abstains with could not read <key>: <reason>, where the key is a prefetch key or a mapped field the agent names; its card says so in fixed words with the same keys and codes (cds_hooks.UNREADABLE_SUMMARY). A read's error message, which can name an HTTP status, never reaches a decision. The record is the same for the caller and the trail, in every PHI mode. tests/test_data_coverage.py (test_codings_are_counted_by_declared_system_and_others_only_as_a_number, test_no_note_text_patient_code_or_id_reaches_the_record_or_the_chain, SQLite and Postgres; test_a_mapping_is_counted_against_what_each_field_looks_for), tests/test_cds_unreadable.py (test_the_reason_holds_no_url_query_or_server_text, test_an_operation_outcome_in_prefetch_abstains), test_no_lab_value_date_or_patient_id_is_stored
I18 A card's uuid that says more than it should, or feedback that keeps what a clinician wrote 2, 6 A card's uuid is its decision's id (LP-23f), which the card already showed (extension.mendari.decision_id) and which names no patient: a random UUID 4 the engine made, not the EHR's ids, the patient's or the order's. Its suggestion's uuid is a UUID 5 of it, so nothing is stored to check feedback, and the decision id reads a decision only with read in its organization, as before. Card feedback chains codes and ids only (the service, the outcome, the suggestion taken, the reason's system and code, the time, the sender's chain name): userComment is free text and is accepted but never kept, in any PHI mode (owner decision 7), nor is an extension the EHR adds, and a refusal repeats nothing sent but ids. The AuditEvent export shows the same codes. tests/test_cds_feedback.py (test_the_comment_is_not_kept, test_an_extension_is_taken_on_any_object_and_never_kept, test_feedback_for_an_accepted_and_an_overridden_card_is_recorded_and_chained), tests/test_cds_cards.py (test_the_card_uuid_is_its_decision_id_and_suggestion_ids_are_stable)
I19 Enumeration of what is not yet listed: someone learns which namespaces are claimed and waiting, by whom, or reads an agent nobody reviewed, from a read, a search, the recall list, the agent count or the difference between two refusals 5 One rule, in the registry's store and not per route (LP-19c): a namespace is listed when its claim is approved or it has none, and every read (latest and so search and health's count, an agent's versions, a version, its archive, the namespace and its keys, site reports, the recall list) takes who is asking. To anyone but the namespace's own token and a reviewer, a pending or refused namespace answers as one that does not exist: the same status and the same body, for every read and for a site report sent to one of its versions; its publisher routes refuse another token as they refuse it for no namespace at all. A token that is revoked, expired or made up reads as the public. Health counts listed agents whoever asks. The claim's organization is shown to the namespace's own token and a reviewer only. Under the engine (LP-19d) the registry shares the dashboard's origin, so its answers are made inert there: JSON or an archive sent as an attachment, each under a CSP that loads nothing, nosniff, no-store and COEP, on every kind of answer, the engine's own refusals under /registry/ included, and the registry serves no page. Its reads take no session: a signed-in administrator's browser reads a pending namespace as the public does, and an organization's claims and tokens are read only through the people's routes, by its own administrators, never another organization's and never from another site's page. The engine's access line for a registry request holds the route's template, never the path or a token. Still open: claiming a name that exists answers 409, so a claimant learns a name is taken (never by whom, or whether it is listed); the chain's head counts events; answers are not made equal in time. tests/test_registry_claims.py (test_a_first_publish_is_invisible_to_search_pull_the_namespace_the_recall_list_and_health, test_a_pending_namespace_answers_as_one_that_does_not_exist, test_its_own_token_reads_its_pending_version, test_a_refused_namespace_never_lists_and_its_archive_is_kept); tests/test_registry_mount.py (test_public_reads_need_no_sign_in_and_carry_the_registrys_headers, test_one_organization_never_sees_or_revokes_anothers_tokens_or_claims, test_another_sites_page_cannot_claim_or_mint)
I21 Real patients' details uploaded into an organization's agent store (LP-20f) or a dataset there, kept in the engine's database, or a detector that leaks what it found: a report, a log line or an error that repeats the matched value 1, 6 The PHI detector (core/phi_detect.py, LP-20d) reads every text file of an upload line by line and reports kinds, files and lines only, never the matched text (mendari.phi-check/1): a Social Security number the SSA could issue, a phone number outside 555-0100 to 555-0199 (ten bare digits only beside a phone word), a medical record number, a date beside a birth word or a name, an e-mail address outside the reserved documentation domains, a street address, and a listed common name (core/phi_names.txt) on a line that also holds another kind or a person's word. Any of the first six rejects an upload alone, a name from one finding; measured on every shipped agent file and synthetic dataset, none is found. Every pattern runs on RE2, so a hostile line costs one pass (a long line is read in overlapping pieces). No file goes unread: one that is not UTF-8 is read as UTF-16 or Latin-1; the string values a JSON, JSON Lines or YAML file decodes to are read too, so an escape hides nothing; each file's path is read; and a file whose decoded values cannot all be read (an alias bomb) is refused. Residual: a filter, not a guarantee: it finds shapes and listed names, not people, so a name the list does not hold, a record number written another way or free-text history passes, and the store's terms must still forbid real data. tests/test_phi_detect.py (test_each_kind_is_found_with_its_file_and_line, test_no_report_log_or_error_holds_a_matched_value, test_every_shipped_synthetic_dataset_and_agent_file_passes, test_a_name_alone_is_not_a_finding_and_a_name_beside_a_birth_date_is, test_a_long_hostile_line_costs_one_pass, test_re2_and_pythons_engine_agree_on_every_shipped_line, test_no_file_goes_unread_and_no_escape_hides_a_value)
I23 A draft, its files, its card or its keys read by another organization, or by anyone but its organization's authors 1, 6 The store's routes are mounted only in memberships mode with MENDARI_AGENT_STORE=on, need author (the agent_author role, people only; never a key, a client, an EHR launch or open mode) and act for the caller's organization alone: lists, reads, tests, edits, withdrawals and uploads of another organization's digest answer 404, a copy is made only from an agent this deployment serves from disk, and the authors' keys are its administrators'. A decide route serves a version only once it is promoted, and only to its organization (LP-20h, T13), so /api/agents lists no draft. An organization's datasets, jobs, their reports and comparisons (LP-20g) are its own in the same way: another organization's id answers 404, a comparison pairs two of the caller's own finished jobs, and the changed cases are listed by the uploader's own ids. An uploaded dataset passes the PHI detector as a version does, and is kept sealed under the PHI policy (encrypt), re-sealed by a key rotation. The improvement dataset (LP-20i) holds the organization's own reviewed decisions' inputs: building it needs author and the permission to read inputs, each read is chained, it is sealed, no route returns a case, and it is never written into an agent's files. Running a version over it reads its inputs, since what a version decides of a case is a function of the input that the version's author chose: its proposed tests, accepting one, the accepted ones in a draft's tests, and a job or a comparison on it need the permission to read inputs too, and each case decided is chained as the runner's read of its decision's input. tests/test_store_uploads.py (test_a_draft_in_organization_a_is_invisible_to_organization_b); tests/test_store_improvement.py (test_another_organizations_corrections_are_never_in_it, test_the_dataset_is_sealed_and_no_route_returns_its_cases, test_an_author_who_may_not_read_inputs_cannot_build_it, test_an_author_who_may_not_read_inputs_runs_no_version_over_it, test_running_a_version_over_it_chains_each_case_as_the_readers_read, test_no_chained_event_or_log_holds_an_input); tests/test_store_jobs.py (test_another_organization_reads_no_job_report_dataset_or_comparison, test_a_dataset_is_sealed_and_a_phi_key_rotation_reseals_it); tests/test_two_organizations.py
I24 A shared site report reveals a person: a small cell of a confusion matrix, a calibration bin or an outcome, worked out by subtraction from the totals or bounds, or a rate whose digits say something about one case 5 Counts in, rates out (LP-22c): mendari.site-report/1 holds whole counts only, counted from the run's ledger; one suppression function, run by the sender and again by the registry (which refuses a payload it would change), nulls cells of 1 to 9 and complements them until no null can take only one value under the equations and bounds the payload states; nothing is shared under 100 cases; counts that cannot add up are refused. Safety counts (critical labels, false automation) are shared exactly by a stated rule. Subgroups, calibration error, Brier, latency, cost, error counts and the sweep's finer rows stay with the site. tests/test_share.py (test_a_shared_report_holds_whole_counts_and_no_rate, test_a_suppressed_cell_cannot_be_recovered_from_the_totals, test_safety_counts_are_shared_exactly_and_small_runs_are_not_shared, test_the_receiver_refuses_what_suppression_would_change, test_every_field_has_a_written_suppression_rule, test_counts_that_do_not_add_up_are_refused_at_once)
I25 A site's dataset identified from what it shares: its file hash, a guessable commitment, or the commitment read from the registry 5 The commitment is HMAC-SHA256 of the dataset file under a 32-byte secret that never leaves the site; the file's own hash is never sent; the registry stores the commitment only to refuse a second live result on the same data and never serves it (owner decision 12's default). tests/test_site_tickets.py (test_the_commitment_is_keyed_and_the_plain_hash_is_never_sent, test_a_ticket_with_no_result_is_listed_as_unreported_and_an_expired_one_stays_listed)
I26 A site's private key, commitment secret or a ticket's submission secret leaks: from the site's files, the registry's database, a listing, or a body read before its sender is known 5 The site's key and secret are written 0600, whole, in the client's configuration directory, and never typed into the dashboard (it takes the public key file). A ticket's one-time secret is shown once and stored as its SHA-256, compared in constant time and looked up by index before a byte of a report's body is read; no listing serves a secret, commitment or nonce; ticket files the command line keeps are 0600 and named only after an id that is one. tests/test_site_tickets.py (test_the_sites_key_and_secret_are_written_private, test_a_ticket_binds_site_digest_configuration_size_and_commitment), tests/test_site_reports.py (test_nothing_is_read_past_the_limit_and_nothing_before_the_tickets_secret)
I27 What an agent wrote about a case, or the context a grader reads beside it, disclosed: in a report, a ledger, a log line, the audit chain, a table, or to someone it was not assigned to; or a grader shown a judge's grade or another grader's before theirs is in 1 A decision returns what the agent wrote and stores none of it. A grading round keeps its sampled texts sealed under the PHI key, bound to their own row (refused under PHI mode hash, never plaintext in a protected database), re-sealed by a key rotation, erased by retention and erased when the round closes. A ledger and a report hold hashes, counts and coefficients; an item's id is keyed by the dataset. A grader's answer is a closed model: the text, the context the rubric names and the rubric's words. Each showing is chained before it is answered, one submission an assignment, and no report exists until the round closes. The routes take a person holding label only, in their own organization. tests/test_written_leaks.py (test_no_report_log_table_or_answer_holds_a_text_but_the_graders_own, test_under_off_the_items_hold_the_texts_and_nothing_else_does), tests/test_written_store.py (test_the_second_graders_view_is_the_same_before_and_after_the_first_grades, test_a_planted_judge_never_reaches_a_grader, test_closing_computes_the_report_and_erases_every_text, test_texts_follow_notes_under_each_phi_mode), tests/test_written_routes.py (test_only_a_person_holding_label_reaches_a_graders_routes), tests/test_agent_outputs.py (test_decide_returns_what_was_written_and_keeps_none_of_it)
D1 Oversized or slow upstream answers hold the server 3 One outbound client: allow-listed origins, no redirects, timeouts and size caps. tests/test_fhir_client.py
D2 Provider costs run away, or one organization (or one leaked key) spends the deployment's day 4 Daily call budgets per provider type across the deployment, and per-organization daily quotas (MENDARI_ORG_DAILY_LIMITS: decisions and the remote calls they make), each one atomic upsert shared by every instance. An organization's evaluations count against their own quotas (eval_llm), never its decisions' ones, and still spend the deployment's budgets, which live decisions share: one organization's evaluations cannot spend everyone's day once those quotas are set below the budgets (the server warns at startup when one is not). Over either, no provider runs and the decision falls back to human review (policy only lowers automation); the first time a quota is reached each day, one alert goes to the webhook (ids and numbers, no case data). A daily cap per principal (MENDARI_PRINCIPAL_DAILY_LIMIT, off unless set) counts the decisions one person, key, client or EHR launch asks for (a CDS Hooks order hook's draft orders each, all or none) and refuses its requests past it (429 until local midnight) before any provider call or chain write, so one leaked key cannot spend its organization's quota. A client's cap survives replacing its keys (same id); a rotated key is a new principal with a cap of its own. The project's public deployment launches with finite ceilings (LLM 200 and 5,000 decisions per organization a day). All visible in /api/health to a principal that may read. test_daily_budget_is_enforced (tests/test_audit.py), test_each_organization_has_its_own_quota_and_evaluations_spend_their_own (SQLite and Postgres), test_an_evaluation_over_its_quota_never_lowers_a_live_decision, test_over_its_quota_a_decision_falls_back_to_human_review_with_one_alert, test_a_quota_alert_that_fails_never_fails_the_decision, test_each_principal_has_its_own_daily_cap_shared_by_every_instance (SQLite and Postgres), test_a_capped_request_does_no_work_and_is_logged_once, test_each_draft_order_counts_against_the_cap_all_or_none, test_every_principal_kind_is_capped_on_the_routes_it_decides_on, test_only_what_decides_counts_against_the_cap, test_sixteen_threads_never_count_past_the_cap (SQLite and Postgres), test_a_clients_daily_cap_survives_a_key_set_replacement
D3 A caller makes the server read large bodies 1 No request body is read before the sign-in check; routes read bodies with a cap (the token form 16 KiB, a search form 256 KiB), a chunked one only up to it. A credential in a form is refused by the route that reads it. No body on any route passes MENDARI_MAX_BODY_BYTES (4 MiB unless set, at least 64 KiB; a bad value fails at startup): a declared length over it is a 413 before anything is read, and a chunked body is counted as it arrives and stops with a 413 once over (an OperationOutcome too-costly on FHIR routes), after the sign-in check. test_no_body_is_read_before_the_sign_in_check, test_a_chunked_body_is_read_only_until_it_passes_the_limit, test_a_search_form_is_read_only_up_to_its_limit, test_a_declared_body_over_the_cap_is_refused_unread, test_sign_in_answers_before_the_cap_and_reads_nothing, test_a_chunked_body_is_refused_once_it_passes_the_cap, test_a_three_mebibyte_bundle_is_taken_by_default
D4 Anonymous amplifiers: a public route makes each call hold the chain's lock, fetch from another server or scan a table, so a caller without a credential slows every decision 1, 3, 6 The CapabilityStatement's date is kept per process and its version read without a lock; only a new version takes the chain's lock, once. The identity provider's configuration is kept an hour per issuer (re-checked against the allow-list on each use, a failed fetch never kept). Each sign-in's row purges at most 100 expired rows, on an index. Anonymous /api/health does no database work. Readiness (/api/health/ready, public) reads the database at most once every 5 seconds per instance whoever asks and keeps the answer, a failure too. The read runs in a thread of its own, waited for about 3.5 s at most; one the database never answers (a black hole) holds that thread and no second read starts until it returns, and a caller during a check gets the last answer at once, so readiness holds one request thread at most and a flood of it never starves liveness. It has no per-address limit, which would fail a probe sharing its address with other callers; floods are the edge's, as for /api/health. The sign-in check runs in the thread pool, off the event loop. test_the_capability_statement_never_takes_the_chain_lock, test_the_capability_statement_answers_while_the_chain_is_locked (Postgres), test_ten_sign_ins_fetch_the_identity_providers_configuration_once, test_a_put_purges_at_most_a_batch_of_expired_rows (SQLite and Postgres), test_anonymous_health_is_three_fields_and_no_database_work, test_readiness_reads_the_database_once_per_window_whoever_asks, test_a_read_that_never_returns_is_waited_for_once_and_never_twice, test_callers_during_a_check_get_the_last_answer_at_once, test_a_flood_of_readiness_during_a_black_hole_never_starves_liveness, test_a_frozen_postgres_is_unreachable_within_the_bound (Postgres), test_the_sign_in_check_runs_off_the_event_loop
D5 A caller floods the costly routes (decisions call paid models and write rows that are kept for good; evaluations, exports), or guesses at sign-in and the token endpoint 1, 2, 4, 6 Two layers. At the edge, one Vercel firewall rule (or the site's proxy) limits /auth/ and /smart/ per IP, started in log mode, never on /api or /fhir (a hospital is one address). In the app (MENDARI_RATE_LIMITS, on with sign-in): GCRA buckets in the database, shared by every instance, per principal on decisions (600/min, bursts of 100, every entry point, an EHR launch's per ehr:<hash>; a CDS Hooks order hook decides at most 50 draft orders a request, each one decision charged before any is made), evaluations (6/h) and exports (10/h), and per address on sign-in (300/min, bursts of 120: never below the edge's 120/min, since a hospital signs in from one address; in memberships mode choosing an organization, asking to join and accepting an invitation count there too) and the token endpoint (60/min) plus failed assertions per address and client (10 per 10 min; never per client alone). The check runs after the sign-in check and before any body read, provider call or chain write; a 429 carries Retry-After and no-store in the route's shape. Bucket names hold opaque ids, never a credential. log mode counts without refusing (CI's ZAP scan). Self-hosted, X-Forwarded-For counts only from proxies the server is told to trust; the compose template fixes its network's gateway (where a proxy on the host connects from) and trusts it, and signed-in /api/health shows the address seen on the request and whether X-Forwarded-For gave it. test_two_app_instances_share_one_count, test_sixteen_threads_never_exceed_the_limit (SQLite and Postgres), test_a_refused_request_calls_no_provider_and_writes_nothing, test_each_refusal_says_when_to_retry_in_the_routes_own_shape, test_failed_assertions_are_limited_per_address_and_client, test_bucket_keys_hold_no_secret, test_a_forwarded_address_counts_only_where_it_is_trusted, test_log_mode_counts_and_never_refuses, test_costly_routes_have_their_class_reads_none_and_one_call_of_each_passes, test_the_firewall_rule_starts_in_log_mode_on_signed_out_routes_only, test_sign_in_allows_at_least_what_the_edge_does, test_an_order_hook_counts_one_decision_per_draft_order, test_an_order_hook_decides_at_most_fifty_orders_a_request, test_a_weighted_take_counts_all_or_nothing, test_health_shows_the_address_seen_and_whether_x_forwarded_for_gave_it, test_compose_trusts_x_forwarded_for_from_the_gateway_a_proxy_on_the_host_comes_from, test_accepting_counts_as_signing_in
D6 A small archive exhausts memory: the registry (any namespace token can publish), mendari pull or mendari archive verify decompressed the whole gzip before checking its size (a 1 MB gzip of zeros took about 2 GB; the 100 MB the registry accepts, about 100 GB), and read PAX sparse members as regular files of their declared size (2,000 in 46 KB: about 100 GB), all before the signature was checked 5 hub/archive.py reads an archive as a stream (tarfile r| over a gzip reader that stops at its cap): the gzip expands to at most 100 times the archive's size (64 MB for any archive) and 400 MB in all; at most 2,000 members of at most 50 MB each, whose declared sizes may not add up past the cap, checked before a member is read; only regular files (a sparse member, a symbolic or hard link, a device or a FIFO is refused); a manifest or signature that is not a JSON object, or a file list of the wrong shape, is refused, never a raw error. test_sparse_members_are_refused_before_anything_is_read, test_a_gzip_bomb_is_refused_while_it_expands, test_expansion_is_capped_by_ratio_and_in_all, test_only_regular_files_are_read, test_a_truncated_archive_is_not_gzip, test_a_malformed_manifest_is_refused_not_a_server_error, test_size_caps
D7 One agent stops or stalls the server: an outside agent whose content makes loading raise something other than a Mendari error (YAML or JSON nested too deep, a file that is not UTF-8, a $ref pointer on which the resolver raises) failed startup, every Vercel cold start included, so no agent was served; a few lines of YAML aliases ("a billion laughs") made loading exponential, or, aliasing one long string, made a 1 MB tests file a 100 MB /openapi.json (each level more, ten times that), and, the cap counting characters, a 2 MB tests file of "\0" (six bytes each as JSON) a 180 MB one; an explicitly tagged scalar (!!bool maybe, !!float '') raised a KeyError or IndexError and mendari validate printed a traceback; a base-60 integer (1:1:1:…) was built in quadratic time (480 KB took 23.6 s), and a hexadecimal, octal, binary or base-60 integer escaped Python's 4,300-digit refusal (a long hexadecimal one in a test made mendari validate print a traceback); a lone surrogate or !!binary in a test input made GET /api/agents/{id}/examples a 500; a lone surrogate in an agent's name made GET /api/agents a 500 for every agent, and one in the input schema, a variant or a rule name made the agent's detail or its decisions a 500, while mendari validate said ok; a behaviour test of the wrong shape (expect: [1]) made /openapi.json a 500 for every agent and mendari validate and test print a traceback, as did an unreadable agent file; a malformed benchmark, leaderboard or CHANGELOG.md made the agent's detail a 500, and a bad dataset line GET …/datasets; a version of 5,000 digits made comparing versions raise at startup (and, published, broke registry search); one served agent whose providers could not be built made /api/health a 422 or 500 for every reader; a malformed evals/benchmark.json or card made a registry publish a 500, and a benchmark value or leaderboard nested 300 levels was stored, then made /v1/search a 500 for everyone 1, 5 load_agent turns these into an AgentValidationError (core/agent.py): YAML is parsed with a safe loader and, in a file that uses anchors, its graph checked before it is built: at most 1,000,000 nodes and 32,000,000 characters of scalar text as JSON writes it (a control character counts six) with aliases expanded (counted visiting each node once) and no alias inside its own anchor; a number of more than 4,300 characters (underscores removed) or 4 : parts, or an integer of more than 4,300 decimal digits, is refused before it is built, in every base; any value the safe loader cannot build (a date such as 2024-02-30, a tagged !!bool maybe, an unknown tag) is the agent's error too, named by file, error type and the value's line and column, never the value (a file that does not parse keeps the parser's message); in every YAML file of an agent a string with a lone surrogate and !!binary, !!set, !!omap and !!pairs are refused by the loader, by file, line and column, and every JSON file of an agent (the input schema, a calibration) is walked for lone surrogates and numbers that are not finite (parse_json); a JSON file that is not JSON, nested too deep or holding an integer of more than 4,300 digits, a file that is not UTF-8 (Agent.read_text) and a file that cannot be read, even while hashing, are named by file; a behaviour test must be a mapping with an input mapping, an optional text name and an expect mapping of at least one known key and no other (its answers a non-empty mapping, its outcome_in a non-empty list, every value one the agent can decide), and one of the wrong shape or that is not JSON (a date, a number that is not finite) is a validation problem named by case number, which mendari validate and test report and GET …/examples answers with a 422; evaluation.benchmark must be in evals/; a benchmark or leaderboard that is not JSON or not the report the card shows is treated as absent and the card says why, a CHANGELOG.md that is not UTF-8 is a 422, and a dataset line that is not UTF-8 or JSON is a Mendari error naming file and line; a version has at most 64 characters, and version_key compares numbers without int(). Whatever loading an agent or building its terminology raises, the agent is listed in /api/health (invalid; an error that is not Mendari's by its type alone) and every other agent is served (core/registry.py discover, standards/terminology.py); every served agent's providers are built at start-up, never in a request, and /api/health reads that state (it builds no agent and records no deployment, so it chains nothing, and that state has no lock for it to wait on; the deployment record is made on an agent's first use): an agent whose providers cannot be built is listed there too, is never built again and answers 422 with its reason on every use, never failing the start or /api/health (server/app.py). Health answers within its bound with any agent loaded, and while a decision on an agent the deployment does not own runs (its patterns run on RE2, outside the interpreter lock, within its budget); an owned agent's patterns run on re, which holds that lock while it backtracks. The API reference picks each agent's example under its own guard, and skips an agent whose tests do not load, or whose example is over 64 KB as JSON. The registry refuses an agent that does not load, or whose card is not UTF-8, with a 422 naming why; a benchmark of the wrong shape is shown as none (its dataset name only a string of at most 200 characters, n an integer, accuracy a finite number), a leaderboard deeper than 32 levels or larger than 1 MB too, and the metadata is serialized as answers will serialize it before anything is stored. test_an_agent_whose_content_raises_while_loading_is_listed_and_the_others_decide, test_any_error_loading_one_agent_lists_it_by_type_and_serves_the_others, test_an_unexpected_error_building_terminology_is_named_and_the_agent_still_served, test_an_agent_whose_providers_cannot_be_built_never_fails_health, test_health_builds_no_agent_in_the_request, test_health_records_no_deployment, test_health_answers_within_its_bound_with_a_pathological_agent_loaded, test_health_answers_within_its_bound_while_a_registry_agents_decision_runs, test_an_unbuildable_agent_is_built_once, test_an_agent_whose_tests_do_not_load_never_fails_the_api_reference, test_an_over_long_version_is_refused_at_load_and_never_stops_startup, test_versions_compare_as_numbers_whatever_their_length, test_a_billion_laughs_in_a_rules_file_is_refused_in_milliseconds, test_a_long_scalar_aliased_through_lists_is_refused_by_its_expanded_text, test_a_tests_file_that_expands_past_the_cap_never_reaches_the_api_reference, test_a_yaml_value_python_cannot_build_is_the_agents_problem, test_a_number_is_bounded_before_it_is_built_in_every_base, test_numbers_within_the_bounds_still_load, test_a_constructor_error_names_its_type_and_place_never_the_value, test_a_test_input_that_is_not_json_is_a_validation_problem, test_control_characters_count_at_their_json_length, test_an_example_over_64_kb_as_json_is_left_out_of_the_api_reference, test_a_deeply_nested_attestation_is_shown_as_none_and_search_keeps_working, test_metadata_that_cannot_be_served_is_refused_before_it_is_stored, test_an_agent_that_fails_to_load_in_any_way_is_refused_not_a_server_error, test_uploaded_attestations_of_any_shape_are_never_read, test_an_over_long_version_is_refused_and_search_keeps_working, test_a_behaviour_test_of_the_wrong_shape_is_named_never_a_500, test_one_agents_tests_can_never_fail_the_api_reference, test_a_yaml_value_json_cannot_hold_is_refused_at_load_with_its_place, test_a_json_value_json_cannot_send_is_refused_at_load, test_an_unreadable_file_while_hashing_is_named, test_the_benchmark_must_be_in_evals, test_a_malformed_attestation_is_absent_with_its_problem_noted, test_a_changelog_that_is_not_utf8_is_a_422_never_a_500, test_a_bad_dataset_line_is_named_by_file_and_line
D8 An agent the deployment does not own (one pulled from a registry) stalls the server that runs it with a pattern (a regular expression that backtracks for seconds on a long message) 5 Every agent the deployment does not own runs on the bounded engine below: an agent pulled from a registry unless its digest is a bundled agent's of the installed release (Agent.bounded, ADR-0009; the registry checks a publish, and mendari pull an agent before it is cached, on the same engine, and a refused one is never cached). Such an agent's patterns (its rules and its input schema's) run on RE2 (google-re2), which never backtracks, so a pattern that backtracks for seconds is impossible by construction: a pattern's time grows with the text's length times its compiled size, never exponentially ((a+)+$ and the slow patterns the earlier static check and probe missed take at most about 0.3 s on 10,000 characters, most of them milliseconds). Each is rewritten to mean what it means in re (core/re2_syntax.py); a pattern RE2 cannot run (a lookaround, a back reference, a conditional or atomic group, a possessive quantifier, counts nested past 1,000, or one larger than RE2's 8 MiB once compiled), one longer than 2,000 characters, or more than 500 in an agent makes the agent invalid at load; no pattern is timed at load or in CI (the heuristic static check and probe are gone; at run time the budget below bounds them). At run time such an agent refuses an input whose texts and keys (keys where its schema runs patterns on them), alone or together, are longer than 10,000 characters before a pattern runs, and its typo correction never lengthens a text past that. The settings that multiply the work are capped at load (core/caps.py): a field named twice in a text_fields, a negation_window over 200 characters or more than 50 negation_cues, an input schema that runs more than 50 patterns on one value or key (schema references that double) or refers back to itself where patterns run, more than 500 patterns run by the rules on an input (each once per question it answers and per composite member holding it) and the schema on one value together, and those runs' patterns coming to a size over 3,000 together (re2_syntax.size: the characters, classes and .s each holds, as often as its counts repeat them; RE2's time on a character grows with it, and 500 patterns of size 2,001 within every other cap took 148 s on 10,000 characters). The patterns of the five agents measured when the caps were set (sizes 1,200 to 2,600) took milliseconds. The caps alone are not a hard bound (one search on 10,000 characters of emoji can take about 2.5 s; a crafted agent within every cap took 5.5 s, 17.5 s with negated patterns rescanned at each match; typo tolerance's keyword list, the negation check and a schema whose keywords fan out, $refs that double or an enum on many items, add more), so such an agent's patterns and schema checks share a time budget of one second per decision, in the CPU time of the decision's thread (patterns.time_budget): checked before each search, at each match, at each word typo correction looks at, at each schema applied and after each error a schema check finds, it stops the agent's rules or its schema check (time_budget; the decision abstains, for a person, and a valid input is never refused for it; an input the schema had already found wrong is refused), so one decision runs them for at most the budget plus one step under way (about 3.5 s of CPU at worst). Waiting for a model or for other requests costs the budget nothing, so the same input decides the same way on a busy server. Its schema's validator keeps its own class (built without the root's $schema, which jsonschema picks a validator by), stops collecting at 100 errors (a registry agent's; every other agent's reasons are as before), and its schema uses only keywords whose work stays within the budget, $ref only to its own $defs (names of letters, digits, _, . and -, so a $ref names exactly one), required at most 100 names and enum at most 500 flat values, texts of at most 200 characters (jsonschema works unevaluatedProperties, unevaluatedItems and contains out on its own, outside any check, and uniqueItems compares every pair of items at once: refused); an input holds at most 10,000 values nested at most 32 deep, and a schema that cannot check an input (a number past a float, nesting past Python's limit) refuses it rather than failing the request. An agent from a registry that runs out on ordinary text is removed by deleting its version from the agent cache (agents/<namespace>/<name>/<version> under MENDARI_CACHE_DIR, ~/.cache/mendari by default) or by not pulling it. test_a_bounded_agents_rules_decide_slow_patterns_fast, test_a_bounded_agents_schema_patterns_decide_slow_patterns_fast, test_a_pattern_re2_cannot_run_makes_a_bounded_agent_invalid, test_every_maintained_pattern_means_the_same_on_re2, test_a_bounded_agent_may_not_name_a_text_field_twice, test_a_bounded_agents_negation_window_is_at_most_200_characters, test_the_doubling_schema_from_the_finding_is_refused, test_a_reference_cycle_that_reaches_a_pattern_is_refused, test_the_rules_and_the_schema_run_at_most_max_agent_patterns_together, test_keys_are_counted_only_when_the_schema_runs_patterns_on_them, test_patterns_whose_sizes_come_to_more_than_3000_are_refused, test_the_schema_patterns_size_counts_on_one_value, test_a_bounded_agents_rules_stop_at_the_budget_and_a_person_decides, test_negated_patterns_stop_at_the_budget_too, test_a_bounded_agents_schema_patterns_stop_at_the_budget, test_the_budget_belongs_to_one_decision, test_a_schema_that_fans_out_without_patterns_stops_at_the_budget, test_an_enum_is_short_and_stops_at_the_budget_on_many_items, test_a_bounded_agents_schema_uses_only_the_keywords_mendari_bounds, test_a_bounded_agents_ref_names_one_of_its_defs, test_lists_and_values_a_schema_compares_at_once_are_short_and_flat, test_a_defs_name_is_one_a_ref_names_exactly, test_enum_and_const_errors_do_not_copy_the_schema_or_the_input, test_a_root_id_that_is_not_text_is_refused, test_a_refused_keyword_says_why_and_what_instead, test_a_schemas_texts_are_short, test_the_error_limit_and_short_reasons_are_a_bounded_agents_only, test_validate_called_alone_holds_a_bounded_agents_text_to_its_length, test_the_budget_counts_the_decisions_own_cpu_time_not_waiting, test_an_agent_test_that_runs_out_of_time_says_so, test_keywords_jsonschema_walks_on_its_own_are_refused, test_a_bounded_agents_input_holds_a_bounded_number_of_values, test_a_bounded_agents_input_is_nested_at_most_32_deep, test_the_bounded_validator_keeps_its_class_on_the_root, test_a_number_past_checking_is_refused_not_a_crash, test_errors_found_before_the_budget_runs_out_still_refuse_the_input, test_an_agent_from_a_registry_runs_on_the_bounded_engine, test_a_registry_copy_decides_the_shipped_inputs_as_the_reference_does, test_one_changed_byte_puts_a_reference_copy_on_the_bounded_engine, test_a_registry_agent_reads_at_most_10000_characters, test_a_registry_agents_rules_stop_at_the_budget_and_a_person_decides, test_a_registry_agents_schema_uses_only_the_keywords_mendari_bounds, test_a_registry_agents_caps_are_checked_at_load, test_discover_lists_a_refused_registry_agent_and_serves_the_others, test_decision_from_path_takes_the_origin_of_the_path, test_mendari_test_runs_a_registry_agent_on_its_engine, test_a_publish_is_checked_on_the_engine_its_pullers_run, test_a_pull_the_engine_refuses_leaves_nothing_in_the_cache, test_extract_needs_an_origin, test_extract_on_the_hub_engine_refuses_a_changed_reference_agent, test_a_registry_agent_refuses_an_input_too_large_before_its_schema_runs, test_a_registry_agents_typo_corrections_never_lengthen_its_text_past_the_length, test_a_registry_agents_schema_errors_stop_at_100_with_short_reasons, test_mendari_test_stops_a_registry_agent_at_the_budget
D9 A decision holds its request past the platform's limit through slow remote providers: each remote call has a timeout of its own and some retry, so several in one decision, a slow key fetch or an answer that arrives a little at a time could outlast Vercel's maxDuration (300 s), which stops the function before the audit is written 3, 4 One wall-clock deadline per decision across its remote calls (MENDARI_DECISION_DEADLINE_S, whole seconds 10 to 270, 120 unless set; a bad value stops the server at startup; an agent cannot set it), on time.monotonic in a context variable each decision sets for itself, never on the Decision every thread shares (providers/deadline.py). Its clock starts at the provider loop, or before a CDS hook's or SMART decide's linked reads (D14). The LLM checks it before it fetches a key or charges a budget, so a call that would start after it is not made; under way, each HTTP attempt's timeouts are clamped to what remains, no retry is waited past it, and a provider's answer read in chunks stops at it. Each is the provider error timeout (the closed set; FHIR issue timeout), which caps AUTO, and a missing primary answer abstains. Local providers never look at it, so a keyword screen still flags a possible emergency, and what an agent decides offline does not change. It is not the CPU budget of an agent the deployment does not own (D8), which waiting never spends. Each step of an attempt (connecting, the TLS handshake, each write and each read) waits at most what remains of it and none starts after it (providers/http.py Budgeted), so a server that answers a little inside each wait no longer holds an attempt for a timeout per step. Residual: looking up a host's name is not bounded, and a host with several addresses is tried address by address, each up to what remains; each decision of a request that makes several (a CDS Hooks order hook's draft orders) has a deadline of its own. test_a_remote_call_after_the_deadline_is_not_made_and_uses_no_budget, test_local_providers_answer_after_the_deadline, test_a_deadline_never_automates, test_the_deadline_belongs_to_one_decision, test_reference_decisions_never_see_the_deadline, test_the_cpu_budget_is_not_the_deadline, test_post_json_clamps_its_timeout_to_what_remains, test_no_retry_is_waited_past_the_deadline, test_a_slow_response_stops_at_the_deadline, test_the_deadline_setting_is_validated, test_a_bad_deadline_setting_stops_the_server_at_startup, test_an_attempt_ends_at_its_time_whatever_the_server_waits_before_each_part
D10 The input schema of an agent the deployment owns multiplies the work of checking an input, or cannot be checked: $refs that fan out (allOf over two $refs to a schema holding two more: 28 such steps apply one schema 2**28 times to one value, and such an agent has no time budget), a schema that applies itself to the same value (jsonschema recurses until Python stops it), unevaluatedProperties or unevaluatedItems nested below another (to find what is unevaluated, jsonschema validates again every schema below one, so each one more multiplies the work: three $defs of 13 each, within every other bound, took over 60 s on {"a": 1}, where one took 7 ms and two 3.5 s), a long chain of $refs, or a document nested deep 1, 5 At load (core/input_schema.py expansion_problems, over core/schema_graph.py's graph of the schema's objects, walked without recursion), a bundled agent's or a local agent's input schema nests at most 32 deep, chains at most 16 $refs on any path, and applies at most 1,000 schema objects to one value (a schema reached twice counts twice, as the bounded engine's caps count patterns). A schema may refer back to itself only as a recursive list or tree does: each schema of the loop leads back into it once, the loop passes through properties or items, and it leads to no other loop; an in-place loop, a node that applies its child twice and a binary-tree recursion are refused. A schema holding unevaluatedProperties or unevaluatedItems may not lead, through any applicator, to another that holds one (or back to itself), so every schema is validated again by at most one such check. One beyond the bounds is refused by path, never its content (listed under /api/health invalid). The bundled agent, the scaffolds and the test fixtures nest at most 6 deep, chain at most 1 $ref and apply at most 2. An agent the deployment does not own keeps the caps, the schema keyword list and the time budget instead (D8). test_a_nested_ref_schema_is_refused_at_load, test_a_wide_fan_out_is_refused_at_load, test_a_ref_cycle_in_place_is_refused_at_load, test_a_binary_tree_recursion_is_refused_at_load, test_a_recursive_schema_that_reaches_another_is_refused_at_load, test_nested_unevaluated_keywords_are_refused_at_load_and_quickly, test_one_unevaluated_keyword_on_a_path_still_loads, test_a_long_ref_chain_is_refused_at_load, test_a_schema_nested_past_32_levels_is_refused_at_load, test_a_recursive_list_schema_still_loads_and_decides, test_every_shipped_schema_is_within_the_expansion_bounds, test_a_schema_that_fans_out_without_patterns_stops_at_the_budget
D11 The registry flooded, or held by its own regression check: many reads or writes, a fresh made-up token on each, large bodies, a burst of publishes, a check that runs to its limit, or an existing version sent again to run its check again 5 Reads are limited per address (600 a minute, burst 200), writes (120 an hour, burst 30) and site reports (60 an hour, burst 10) per namespace (since LP-19d every token of a namespace shares its bucket), a token the registry did not issue counting against its sender's address, in the registry's own database (MENDARI_REGISTRY_RATE_LIMITS), off the event loop and before a body is read: a refusal is 429 with Retry-After, nothing stored. An archive is read to its size cap (413); a recall's body only after its sender is checked, at most 16 KB. The regression check runs in the thread pool, at most two at once (else 503), in a child process (python -I, five fixed environment variables, no credential, 180 s of wall clock and CPU, a file-size limit, 2 GB of memory where the system bounds it), its answer read to 1 MB; an existing version is refused before any work test_writes_are_limited_per_namespace_before_their_body_is_read, test_made_up_tokens_share_their_senders_bucket, test_reads_are_limited_per_address_and_log_mode_never_refuses, test_a_bad_setting_stops_the_registry, test_a_burst_of_publishes_is_told_to_try_again, test_the_check_runs_isolated, test_a_recall_body_is_read_only_after_its_sender_is_checked (SQLite and Postgres)
D12 A server's reads of its registries' recalls hold or misdirect it: a registry (slow, hostile, or a wrong URL in a pulled agent's marker) that answers a byte at a time, never answers, sends a huge or malformed answer, or redirects the read elsewhere 3, 5 server/recalls.py reads each registry's GET /v1/yanks in a thread of its own, one read a registry at a time, so no decision waits for it: https only (plain http to this machine), no redirects, 5 s to connect and per read, the whole answer within 20 s, at most 5 MB (refused by its declared length or as it streams), a read in flight over 60 s taken as lost and started again, and the answer checked as data. A failed read keeps what was known until stale, then holds the registry's agents (E12): a registry can stop automation, never start it. The marker keeps the registry's URL without user, password or query test_a_registry_is_read_over_https_only, test_a_registrys_answer_is_bounded_in_size_time_and_shape, test_a_lost_read_is_started_again_and_one_reads_at_a_time, test_what_the_watch_holds_and_when, test_the_settings_are_checked_together, test_the_marker_never_records_a_registrys_credentials
D13 A flood of tokens with made-up kids makes Mendari fetch an EHR's keys for each, or holds requests on a slow key server 2, 3 Keys from a jwks_uri are fetched only through the allow-listed client (no redirects, a timeout, a size cap, JSON only) and kept an hour. A kid the kept keys do not hold fetches them again at most once per client a minute, whatever the tokens claim, so a flood costs the EHR one request a minute from each instance. The keys are each instance's own (each Vercel function instance), so a new instance fetches them at its first token, and the EHR sees up to one request a minute from each instance running. The checks that need no key (size, shape, header, a registered iss, jku) come first, in memory. One fetch per client runs at a time: while the kept keys are fresh no request waits for it, and at a cold start the others wait for it (15 s at most) rather than fetch again. An answer that is not a set of public signing keys (a key of the wrong JSON shape among them) keeps nothing and drops what was kept; a failed fetch (an answer that is not JSON, or nested too deep to read, among them) keeps what was kept until it is stale; each is one cds.jwks.refused line and the one 401, never an error. The registry is bounded (50 clients, 20 bases each), and so is what is kept. test_an_unknown_kid_refetches_at_most_once_a_minute, test_a_jwks_answer_with_a_private_key_is_refused_and_nothing_is_cached, test_a_jwks_answer_of_the_wrong_shape_is_a_refusal_never_an_error, test_two_requests_share_one_fetch, test_failures_fail_closed_without_echoing_the_server
D14 Linked-read volume: a record whose notes and references hold many links, or links to large Binaries, makes Mendari read from the EHR without end for one decision (hundreds of note urls, every MedicationRequest naming the same drug, a Binary of many megabytes, an order hook of 50 draft orders each reading it all again), or makes it read elsewhere than the EHR 2, 3 Only an agent whose mapping reads a note's text or follows a reference (attachment_text, follow, LP-23k) reaches anything by a link, and only a CDS hook with a fhirServer and the SMART launch's decide read one (standards/linked.py, LP-23h); fhir/decide, $decide and mendari decide --fhir never fetch, and a link there is not_fetched. A decision reads at most 50 note Binaries (linked.MAX_NOTE_READS) and 50 followed references (linked.MAX_FOLLOW_READS), each budget its own (2026-11-08: one budget of 20 let a chart's notes leave nothing for its drugs): past its budget a link is cap and is not read. A note field whose text read so far is already longer than the agent's input takes reads no more of its notes, which abstain too_large with it. One request sends at most 100 reads (linked.MAX_REQUEST_READS), its decisions together, and spends at most 60 s in them (linked.LINK_SECONDS, added up read by read); a link past either is cap or timeout and nothing is sent. The decision's deadline (MENDARI_DECISION_DEADLINE_S, at most 270 s) starts before its linked reads and its providers share what they leave, so a decision's reads and remote calls together stay inside it: each read waits at most what remains of the client's timeout, the request's seconds and the deadline, each step (connecting, then the answer's headers), and an answer still arriving when one runs out stops. A read the clocks stopped is not kept for the request's later decisions; a read never sent counts against nothing. Each read is one GET of one resource by Type/id, of the type the field reads (a Binary for a note's url), no page followed, through the allow-listed client under the request's fhirServer (no redirects; a link elsewhere is off_server, E1). Its answer stops arriving past 1 MiB for a resource or 2 MiB for a Binary, whose content past 1 MiB decoded is too_large, so a request holds at most 100 answers of at most 2 MiB (about 200 MiB at worst). A link is read once a request, whatever its spelling (relative, or an absolute URL under the base): the draft orders of one order hook share what was read, and each order is a decision against the rate limit and the daily cap. Nothing a resource its list leaves out links to is read (a MedicationRequest entered in error, when the list derives its period). Of a note's renditions (a DocumentReference's content, a DiagnosticReport's presentedForm) none is read once one reads. A link that is not read makes the decision ABSTAIN with its field and reason, which only lowers automation. Residual: the prefetch reads themselves are under no clock (each has the client's timeouts, 10 s a step, and a search at most 11 pages), so a slow EHR can still hold a request for its prefetch; when an EHR is slow, the linked reads use the deadline and the remote providers get less of it, fail with timeout, and the policy holds the decision for a person. test_linked_reads_are_capped_per_decision_and_in_size, test_linked_reads_are_capped_per_purpose_per_decision_and_per_request, test_linked_reads_stop_at_the_deadline_and_the_request_clock, test_a_note_field_stops_reading_once_its_text_is_longer_than_the_input_takes, test_a_medication_reference_is_read_once, test_one_drug_ordered_many_times_is_read_once, test_a_request_its_list_leaves_out_is_not_read_for_its_links, test_without_a_server_a_link_is_not_fetched_and_says_so, test_html_is_read_as_text_and_rtf_abstains
D15 The registry under the engine takes the engine down with it: publisher archives fill the engine's database or a function's memory, a publish holds a function for minutes, unauthenticated reads or made-up tokens flood the engine's origin, or an organization hoards names 5 The mount is off unless MENDARI_REGISTRY=on (LP-19d): without it nothing is mounted, no registry table is made and those paths answer as before; turning it off again loses no row. Under it every request body is the engine's limit at most (MENDARI_MAX_BODY_BYTES, 4 MiB by default), refused with a 413 before anything is read when its length is declared and as it arrives when it is not, so the registry's own 100 MB never applies there. The registry's own rate limits stand in front of every route, before any body is read: reads per address, writes and site reports per namespace (every token of a namespace shares one budget, so minting buys none), a made-up token against its sender's address. Publishing needs a token, a token needs a claimed namespace, and an organization holds three pending claims at most; through the people's routes a namespace has 20 working tokens and 20 keys at most, and an organization mints 50 tokens a day at most. At most two regression checks run at once per instance, each within its time and memory limits, outside any transaction. Still open: the checks share the engine's functions and the archives its database (the agent store, LP-20, keeps its own files in the same database, under each organization's bytes, D16); the two stores each hold a connection pool; a publisher token registers keys under the write limit only, with no cap; a token minted while a claim was pending still publishes after the claim is refused (never listed). tests/test_registry_mount.py (test_without_the_switch_nothing_is_mounted_and_no_hub_table_is_made, test_an_archive_over_the_engines_body_limit_is_a_413_that_names_it, test_a_site_report_is_counted_as_one_under_the_mount, test_a_namespaces_tokens_share_one_write_budget, test_an_organization_makes_a_bounded_number_of_tokens_and_keys); tests/test_registry_limits.py; tests/test_registry_claims.py
D16 An agent store fills the engine's database or an instance's scratch disk: large or many versions or datasets, many uploads a day, or many versions loaded at once 6 An organization's store keeps at most MENDARI_STORE_ORG_BYTES of files and datasets together (256 MiB by default; a file counted once however many versions hold it, a dataset as kept) and adds at most its store_uploads quota of versions and its store_datasets quota of datasets a day (MENDARI_ORG_DAILY_LIMITS; 429 past a quota, 413 past the bytes); a version has at most 2,000 files of at most 50 MB each, an archive's own limits (LP-20e). Withdrawn versions' files are freed after 30 days (mendari store purge). A process keeps at most 32 loaded versions and 256 MiB of their files on its scratch disk, the least recently used removed first. Each loaded store agent runs on the bounded engine (one second of CPU per decision). Residual: the quotas and bytes are per organization, so a deployment with many organizations needs the database for all of them; the store is off unless MENDARI_AGENT_STORE=on (LP-20f). tests/test_agent_store.py (test_an_organization_over_its_bytes_or_its_daily_uploads_is_refused, test_a_datasets_bytes_count_against_the_organizations_store_with_the_files, test_an_organizations_datasets_a_day_are_bounded_and_checked_before_the_costly_work, test_the_same_file_is_kept_once_and_removed_with_its_last_version, test_a_store_agent_runs_on_the_bounded_engine_and_its_rules_stop_at_the_budget)
D17 Upload flooding and archive bombs through the store: many or large uploads, parts that never finish, an archive that expands without bound, a copy or a test run that holds a function 1, 6 A whole upload is the engine's body limit at most; a larger archive goes in parts, each under the body limit, declared first (size and SHA-256, at most MENDARI_STORE_MAX_ARCHIVE_BYTES, 32 MiB by default), refused past its declared size, joined and checked on completion, and dropped after a day; an organization has three uploads under way at most. The archive's own checks bound its expansion, files and names (hub/archive.py). Each new version counts against the organization's store_uploads quota and its bytes, each new dataset against its store_datasets quota and the same bytes (D16), each quota checked before the archive or dataset is loaded, run through the PHI detector and validated, and again in the write's transaction; writes are rate limited per person (store class). Behaviour tests run on the bounded engine, 500 at most a run, each decision within its CPU budget. Evaluation jobs (LP-20g) run only when a caller asks, one slice at a time of about 20 s (well under a function's limit), claimed in one transaction so a slice is never run twice at once; a job counts against the organization's store_jobs quota a day, runs 5,000 cases at most, and a remote variant needs the organization's evaluation quota set and runs 200 cases at most. tests/test_store_uploads.py (test_an_archive_in_parts_is_joined_checked_and_bounded); tests/test_agent_store.py (test_an_organization_over_its_bytes_or_its_daily_uploads_is_refused, test_the_daily_versions_quota_is_checked_before_the_archive_is_loaded, test_an_organizations_datasets_a_day_are_bounded_and_checked_before_the_costly_work); tests/test_store_jobs.py (test_a_slice_called_twice_evaluates_each_case_once, test_a_remote_arm_needs_the_organizations_quota_and_stops_at_it, test_a_draft_runs_under_the_budget_and_a_slow_rule_ends_as_a_persons_decision)
D18 The site network exhausted: ticket requests flooding a registry or locking a site out, reports or counts that keep the registry's write lock, or public reads of site evidence redoing exact or permutation tests 5 Ticket requests and withdrawals are read to 8 KB and limited per address before the signature and per site key after, counting only a record whose time and nonce hold, so an old or replayed record locks no one out; nonces past twice the skew are forgotten. A report is read only after its ticket's secret, to 2 MB; every check that needs no lock runs before the write lock, and suppression always ends. The homogeneity test enumerates at most 1,000,000 tables, else 10,000 seeded resamples, cached per set of counts. tests/test_site_tickets.py (test_a_ticket_request_is_read_to_8_kb_and_limited_per_address_and_key, test_an_old_or_replayed_record_never_counts_against_the_sites_key), tests/test_site_reports.py (test_counts_that_cannot_add_up_are_refused_without_holding_the_registry), tests/test_site_evidence.py (test_two_reads_give_the_same_bytes_and_the_seed_is_in_the_answer)
E1 SSRF: making the engine call internal addresses 3 Every outbound call (FHIR, OIDC, webhook, and a CDS client's keys from its jwks_uri) goes through the allow-list. A CDS client's jwks_uri must be on MENDARI_FHIR_ALLOWED_SERVERS at startup, so one list governs every call to an EHR, and a token's jku is never followed: it must equal that URL exactly (S21). A server's reads of its registries' recalls do not: each goes only to the registry a pulled agent's marker names (from the registry URL the pull used, without user, password or query), over https (plain http to this machine), with no redirects and bounded in time and size (D12), and is not under MENDARI_PROVIDER_ALLOWED_ORIGINS. Webhooks must use https. A remote provider's endpoint comes only from the deployment's own variables (E8), over https (plain http to this machine only); a deployment may also list the origins its providers may be called at (MENDARI_PROVIDER_ALLOWED_ORIGINS, off unless set): then every LLM or agent request to another origin, the AI Gateway's default included, is refused before it is opened (invalid_endpoint), and an endpoint variable set off the list stops startup. A CDS Hooks prefetch template is a read or search relative to the EHR's FHIR server (Type/<id>, Type/{{context.<name>}} or Type?<query>; no absolute URL, //, .., operation, fragment or whitespace): an agent the deployment does not own is refused at load for one that is not, an owned agent warned, and the fetch stays under the server's base URL whatever it says. A link a mapping reaches that the record does not hold (a note's Binary, a followed reference: LP-23h) is read only from the request's fhirServer, through the same client and under its base, whatever the record says: a link to another server, outside the base (.. included) or of another scheme (its scheme matched in any case) is off_server and never fetched, and a hook whose fhirServer is off the allow-list is refused (422) for an agent that reads links before anything is decided, with nothing fetched or recorded, as for its prefetch (D14). tests/test_fhir_client.py, tests/test_monitoring.py, test_a_provider_endpoint_outside_the_allow_list_stops_the_start, test_a_call_outside_the_allow_list_is_refused_before_it_leaves, test_no_allow_list_keeps_todays_endpoints, test_a_prefetch_template_must_be_a_relative_read_or_search, test_a_registry_is_read_over_https_only, test_an_unregistered_jku_is_refused, test_the_registry_is_checked_at_startup, test_an_attachment_off_the_fhir_server_is_never_fetched_and_counts_unreadable, test_a_fhir_server_off_the_allow_list_reads_no_link
E2 A role does more than it may 1 A role table grants permissions, a matrix test covers every route for every principal kind (an EHR launch at each level, alone, with a person's session and with a bearer header, included), role and scope, and the dashboard hides what the server would refuse. Verifying and exporting the whole chain need admin. Machines are viewer or service. In memberships mode a member is let through exactly as a person of the same role signed in by claims, on every route; the role and organization claims give nothing; choosing an organization needs a membership of it in force (refused, and the session as it was, otherwise), and a request that names another organization than the one chosen since (X-Mendari-Org, which every dashboard request sends, downloads included) is refused (409), and the window says so; switching first sends what the window holds (a review override in its undo window) in the organization it was made in; a person of no organization sees the access page only, with no section and no agent (an EHR launch in that browser shows its own patient view beside it, as the launch's principal). If the dashboard cannot read who is signed in, it shows nothing. Only a person with keys (an administrator who signed in) invites, changes roles, removes members and handles requests to join; the reserved role agent_author grants nothing and labeller grants label only, and an organization always keeps an administrator who signed in (removing or demoting the last one is a 409). Accepting an invitation never changes the roles of a membership one holds (409). The dashboard's Access view is shown and reached only by an administrator who signed in: its members, invitations and requests to join in memberships mode only, its API keys and (with Backend Services on) clients in claims mode too; in open mode, or for anyone else, #admin is the overview and no list is fetched. tests/test_auth.py, test_every_route_principal_role_and_scope_gets_what_it_should, test_a_member_is_let_through_exactly_as_a_claims_person_of_the_same_role, test_role_and_org_claims_are_ignored_in_memberships_mode, test_one_membership_is_chosen_at_sign_in_and_several_wait_for_a_choice, test_a_window_on_another_organization_than_the_one_chosen_is_refused, test_only_an_administrator_manages_people, test_reserved_roles_may_be_given, test_labeller_grants_label_only, test_an_organization_keeps_a_signed_in_administrator, test_a_member_accepting_again_is_refused_and_the_link_stays_open, browser tests (test_a_person_of_no_organization_sees_the_access_page_and_nothing_else, test_every_request_names_the_organization_the_window_shows, test_a_window_on_an_organization_changed_since_says_so, test_the_access_view_is_hidden_from_everyone_but_administrators, test_open_mode_has_no_access_view, test_a_viewer_by_claims_has_no_access_view, test_claims_mode_shows_keys_and_clients_but_not_people, test_the_clients_tab_is_absent_without_backend_services)
E3 Automation beyond what the risk allows runtime Policy only lowers automation. Level 4 is never automated, and levels 2–3 only under a recorded, unexpired approval of that digest. An agent pulled from a registry automates at any level only once its organization approves its digest, and never while recalled (E12). An automation hold (deployment, organization, agent or digest; chained, set without a redeploy) turns any AUTO into a person's review, and so does an organization's used-up quota, and an input read through a site's code translation (T9). tests/test_policy.py, tests/test_hold.py, tests/test_governance.py, tests/test_registry_origin.py, tests/test_site_codes.py
E4 Injection (SQL, template, command) all SQL is parameterised everywhere (the one dynamic part, a schema name, is checked). No shell. Prefetch templates fill only FHIR ids into queries. A wording template (card summaries, FHIR Task text) names only {recommendation}, {priority} and the agent's questions, and each placeholder is a bare name: no conversion, format spec (which pads a label to any length), attribute or index. An agent the deployment does not own is refused at load for one that is not (its Task text included); an owned agent's card summaries are warned of, its Task text renders as it always did, and mendari validate refuses both. tests/test_fhir_client.py, test_a_wording_template_takes_bare_placeholders_only, test_every_shipped_template_is_bare, test_unknown_placeholders_are_refused_when_the_agent_loads; ZAP active rules
E5 A vulnerable or tampered dependency, action or image all pip-audit (Python lockfile, the tool itself locked) and npm audit (Hub site) in CI. Actions are pinned to commit SHAs and checkouts keep no credentials; images (CI, Dockerfile, compose) are pinned by digest; downloads are checked against a pinned sha256, the FHIR packages the HL7 validator loads among them (scripts/fhir_packages.lock: each package and every one it needs), and the validator runs with no HTTP access, so it can load no other. The API reference's Swagger UI is vendored from npm, checked against its lockfile's integrity value and each file's sha256, and a Dependabot update fails CI until it is vendored again. The Docker image installs uv.lock exactly (uv sync --frozen), and the build backend is pinned. Dependabot proposes updates monthly, of versions at least 7 days old (security updates at once), with no Vercel preview for its branches. Release images are deployed by digest (deploy/). CI job security; tests/test_supply_chain.py, tests/test_vendor.py, tests/test_fhir_packages.py; CI jobs docker, fhir-conformance
E6 Cross-site request forgery: a page on another site (or a sibling subdomain, which is same-site) makes a signed-in browser act here: sign out, decide in an EHR launch, or open the review queue, which under PHI encrypt chains an input.read per input in the reader's name 1 Before anything else in the guard (no session lookup, no body read), a request without an Authorization header that carries a Mendari cookie or uses an unsafe method (POST, PUT, PATCH, DELETE), and in open mode every request, is checked (server/origin.py). Unsafe methods are checked with no cookie too: a browser leaves the SameSite=Lax session cookie off another site's form POST, yet the answer to /auth/logout (or /api/smart/logout) would still clear it. With Sec-Fetch-Site cross-site, same-site or an unknown value, it reaches only public and page routes (from the route permissions, so there is no list to keep) and only with GET or HEAD: links to the dashboard, the API reference, the capability statement and the sign-in and launch callbacks work; a link to an API route does not, an EHR launch's patient and items to decide about included (they need the launch, E7). none (the address bar) passes to read only. Without Fetch Metadata, an Origin that is null or not the request's own host, MENDARI_PUBLIC_URL or one of MENDARI_TRUSTED_ORIGINS counts as cross-site. With neither, an unsafe method is not from a browser (curl, ZAP, pilot-check) and passes; a read with a Mendari cookie may be an older browser (Safari before 16.4) following another site's link, so beyond public and page routes it needs X-Mendari-Request, which only Mendari's own pages send (every dashboard, invitation, landing and API reference request, downloads fetched rather than linked) and which another site cannot add without a CORS preflight; scripts that read with a session cookie send it too (pilot-check, ZAP), and such a browser's address bar is refused an API route like a link (no_fetch_metadata). Refusals are a 403 (an OperationOutcome on FHIR routes) that echoes nothing, logged as auth.origin.refused with a fixed reason code, never the header's value. JSON routes also refuse non-JSON bodies (FastAPI >= 0.132), and no route grants a CORS preflight but /cds-services and its children, for the origins CDS clients registered, without credentials, and there the origin check lets such an origin through only without a Mendari cookie (I16). tests/test_origin.py: every route x 15 kinds of request x each mode, test_a_refused_request_never_reaches_the_store_a_body_or_a_handler, test_a_link_to_the_review_queue_from_another_site_is_refused_and_nothing_is_chained (in an older browser too), test_signing_out_from_another_site_is_refused, test_a_refusal_is_logged_with_its_reason_and_answered_with_a_request_id, test_scripts_with_a_cookie_and_no_browser_headers_keep_working, test_every_page_sends_mendaris_own_header; browser suite (real Fetch Metadata and SameSite): test_a_form_on_another_site_cannot_sign_you_out, and, with Fetch Metadata taken off every request, test_the_dashboard_works_in_a_browser_without_fetch_metadata
E7 An EHR launch acts outside what Mendari grants: it decides with no principal and outside roles, into the default organization, attributed to no one; a signed-in viewer decides through a launch cookie; a patient portal's user, or any EHR on the FHIR allow-list, launches and decides; a launch made while sign-in was off decides once it is on; a launch outlives its EHR's registration, or a later launch in the same browser; a window shows a replacing launch's patient; launched decisions land in an organization no reviewer belongs to 1, 2 A launch is a principal of kind ehr (server/auth.py, ADR-0006): the EHR's verified id_token names the clinician (ehr:<hash> of its issuer and subject; for the chain a verified email, else <issuer>|<subject>, sealed in the launch's row, I11), in the organization registered for the launch's FHIR base, normalized (MENDARI_SMART_EHRS, <base>=<org>:view or :decide). It holds launch (the patient and the items to decide about) and, registered to decide, launch_decide, and nothing else; no other principal holds either. Its credential is the launch cookie on /api/smart/ (and the dashboard page) only; a person's session is no credential there, and an Authorization header decides alone (S5). MENDARI_SMART_EHRS is read at startup and every request checks the launch against it (never against what was stored with the launch), so unregistering an EHR, or registering it to view, takes effect for its live launches at the next restart or redeploy. With sign-in on (or any EHR registered), a launch from an unregistered base is refused before any request leaves (unregistered); with sign-in on, also scopes without openid fhirUser (configuration), an id_token without a subject (id_token) and a user who is not a Practitioner or PractitionerRole (user_type). The session row records that these checks ran (identified, sealed): with sign-in on, a launch without it, made while sign-in was off, is no principal and starts again. These refuse the launch, never startup: only a malformed MENDARI_SMART_EHRS, or a base off the FHIR allow-list, stops the server. Signing out of Mendari ends the browser's launch too, and a later launch's callback deletes the launch the browser held, so a copy of the earlier cookie reaches nothing. The dashboard shows a browser that only launched the patient view alone, the agents from the launch's session and the decision in place, with no link into the audit trail; a 401 from the launch's routes says the launch ended and to open Mendari again from the EHR, never to sign in. Each launch has an id (launch_id, not a secret) and the window it opens is pinned to it (#patient/<launch_id>): the browser holds one launch at a time, and a window whose launch a later one replaced says so before every render and every decision, and never shows the other launch's patient: the window sends its launch (X-Mendari-Launch) with the patient, items and decide requests, and the server answers 409, before any EHR read, when the browser's launch is another one now. Open mode with no EHR registered launches as before. Before go-live, mendari smart check <base> reports what a launch from that base would meet with the deployment's settings (the registration key, the allow-list, the registration, the scopes, the EHR's discovery, PKCE S256 and keys), so a registration that does not match the iss the EHR sends is found before a clinician is refused, and, with sign-in on, one to an organization nobody signs in to (any but default without MENDARI_OIDC_ORG_CLAIM) fails, since its decisions would reach no reviewer (a warning in open mode). CI's sandbox-e2e launches from smart-launcher-v2 into an engine with sign-in on and checks each decision is the registered organization's and chained as the launcher's <issuer>|<subject>. test_a_launch_decides_in_its_registered_organization, test_two_tenants_on_one_origin_map_to_two_organizations, test_an_unregistered_ehr_is_refused_before_any_call, test_a_view_level_launch_cannot_decide, test_a_patient_or_related_person_cannot_launch_with_sign_in_on, test_scopes_that_do_not_say_who_launched_are_refused_with_sign_in_on, test_unregistering_an_ehr_ends_its_launches_at_the_next_restart, test_signing_out_of_mendari_ends_the_launch, test_a_later_launch_in_the_same_browser_ends_the_earlier_one, test_a_launch_made_with_sign_in_off_is_refused_once_sign_in_is_on, test_a_window_pinned_to_a_replaced_launch_reads_nothing, test_a_launch_opens_the_dashboard_page_and_nothing_else, test_each_launch_names_itself_and_the_window_it_opens, test_open_mode_launches_as_before, test_a_malformed_or_unlisted_registration_fails_at_startup, test_a_registered_ehr_ready_to_launch_passes_every_check, test_settings_that_would_refuse_a_launch_fail, test_an_ehr_configuration_that_would_refuse_a_launch_fails, test_a_registration_to_an_organization_nobody_signs_in_to_fails, test_who_asked_reads_the_chain_as_the_expected_organization, test_every_route_principal_role_and_scope_gets_what_it_should; browser: test_a_launch_alone_opens_the_patient_view_only, test_an_ended_launch_says_to_open_mendari_again_from_the_ehr, test_a_window_whose_launch_was_replaced_says_so, test_a_launch_that_replaces_the_window_s_mid_render_is_never_shown; CI: sandbox-e2e (sign-in on, smart-launch --expect-org)
E8 An agent's provider config names the environment variables a provider reads its endpoint, model or key from, so a validated agent sends a deployment secret (any process variable) as a bearer token to an address the agent chose 4, 5 The variable names are fixed constants in providers/llm.py and providers/agent.py, and belong to the deployment. An llm or agent variant that sets api_key_env, base_url_env, local_key_env, model_env, endpoint_env or token_env (a composite's members included) makes the agent invalid at load (core/spec.py): mendari validate refuses it, and a server lists it under /api/health invalid and does not serve it, naming the variant and the keys, never their values; no request is made. A provider built from such a config directly refuses it too. Every variant and member is also checked at load against its provider's closed config and its agent files (providers.config_problems; the configs are published as docs/spec/provider-configs.schema.json): any key its provider does not read, or a value it refuses, refuses an agent the deployment does not own and is a warning for an owned one (mendari list, the start-up log, /api/health agent_warnings), and mendari validate refuses both, so load and validate agree; a generated agent, owned or not, whatever its variants say, reaches only the deployment's endpoints, with the deployment's keys. test_a_variant_or_member_naming_the_deployment_s_variables_is_refused_at_load, test_every_variant_is_checked_at_load_against_its_closed_config, test_load_and_validate_agree_on_provider_configs, test_a_generated_agent_only_reaches_the_deployments_endpoints_with_its_credentials, test_an_agent_may_not_choose_the_variables_an_llm_reads, test_an_agent_cannot_send_a_process_secret_to_its_own_endpoint
E9 An agent reaches outside its own directory: a signed archive entry named agent//<absolute path> is written at that path on the registry host and on every machine that pulls the agent (a .pth file in site-packages runs code); a compromised registry answers a version such as ../../x and mendari pull deletes and replaces that directory; an input schema's $ref makes the server fetch any URL (a request to an address the agent chose, and validation rules outside the signed agent) or read any local file on every check, with no timeout; a symbolic link in a directory agent (CHANGELOG.md to /proc/self/environ) puts a host file in the card GET /api/agents/{id} returns; a manifest path through a hidden entry (config: .logic/triage_rules.yaml) or into evals/ is read and decides, but the digest skips it, so the logic changes without voiding a governance approval bound to the digest; with refusals compared by spelling, a case variant on a case-insensitive filesystem (EVALS/t.yaml, __PYCACHE__/t.yaml, logic/decision_card.md on macOS or Windows) read a file the digest skips; an archive with names that are one file where case is not significant (A and a/x.yaml, published from Linux) made mendari pull on a Mac print a traceback, or the last of two colliding files win 3, 5 Archive names are read as written, not normalised: agent/ and then plain segments (none empty, ., .. or hidden, no backslash), no two of them equal once case-folded and NFC-normalized and no file named as another's folded directory (verify), and extract checks that every file resolves inside the destination before it writes any, and names a file it cannot write. pull requires the registry's version to be a semantic version, the cache path to stay inside the cache, and the signed manifest to name that agent and version, before it touches the disk. An input schema's $ref, $dynamicRef and $recursiveRef must point inside it (#...) and resolve to a schema there, $schema and $id may appear only at the root, $dynamicAnchor and format: regex not at all, checked at load (core/input_schema.py), and the validator's registry retrieves nothing. load_agent refuses a directory agent with a symbolic link that resolves outside it (hidden entries and __pycache__, which are not part of an agent and never digested, archived or read, are skipped, so a .venv beside its files is fine), load_agent hashes the agent first, and every file it or a provider then reads (Agent.path) must be one of the files hashed, compared by device and inode, not by spelling: a case variant, a link, a file added after the load or a key the load does not list cannot reach a file the digest leaves out. The written path is still checked for a clear message, naming the manifest field (inputs.schema, inputs.fhir, policy, tests, evaluation.datasets.*, and a provider's config and calibration): through a hidden entry or __pycache__, in evals/ or a DECISION_CARD.md, or not a file the digest covers. Attestations are read only through Agent.attestation, by their fixed names and evaluation.benchmark, which must be in evals/; mendari card --write does not write through a link. test_names_with_empty_or_dot_segments_are_refused, test_extract_writes_nothing_outside_the_destination, test_links_are_refused, test_a_registry_cannot_choose_where_a_pull_writes, test_a_registry_cannot_serve_one_version_as_another, test_a_reference_outside_the_schema_fails_to_load_and_fetches_nothing, test_a_schema_that_is_not_self_contained_fails_to_load, test_a_symbolic_link_out_of_the_agent_is_refused, test_a_virtualenv_or_cache_in_the_agent_folder_is_not_part_of_the_agent, test_the_card_reads_the_changelog_only_inside_the_agent, test_card_write_never_writes_through_a_symbolic_link, test_paths_cannot_escape_the_agent, test_a_manifest_path_through_a_hidden_entry_is_refused, test_a_manifest_path_to_an_attestation_is_refused, test_a_link_into_a_hidden_entry_is_refused, test_the_refusal_names_the_manifest_field, test_a_case_variant_of_a_left_out_path_is_refused, test_agent_path_refuses_a_case_variant_of_an_attestation, test_agent_path_accepts_only_a_file_the_digest_hashed, test_the_benchmark_must_be_an_attestation, test_the_benchmark_must_be_in_evals, test_every_shipped_agent_reads_only_digested_files, test_names_that_are_one_file_where_case_is_not_significant_are_refused, test_a_file_extract_cannot_write_is_a_hub_error
E10 An agent the deployment does not own spends beyond what it was granted: it pins a model, asks for a long answer, a long timeout or a high reasoning effort, or sends a model the whole input 4, 5 For an agent the deployment does not own (any agent on the bounded engine, Agent.bounded), the model is the deployment's (its model is dropped), max_tokens and timeout_ms are held to the provider defaults (LLM 4,096 tokens and 30 s; a lower value of its own stands) and a reasoning_effort above low is dropped (core/origin.py deployment_config), its own values checked at load first, and every model variant and member must name its state_fields (LP-16e). test_a_registry_agents_pinned_model_gives_way_to_the_deployments, test_a_registry_agents_answer_length_timeout_and_effort_are_capped
E12 An agent pulled from a registry automates, or blocks alone, before its deploying organization approved it, or after its registry recalled or deleted it runtime, 5 Served, an agent from a registry never automates until its organization approves its exact digest (registry_approvals, POST/DELETE /api/registry-approvals, the approve permission, chained registry_agent.approved and .revoked; one live approval a digest, so revoking stops it at once), at every risk level (2 and 3 need their governance approval too, and 4 never), and its own rule's BLOCK goes to a person until then. A recall recorded at pull, or listed by its registry and read by a running server, holds it the same way, approved or not (a decision for one of the registry's agents starts a read, in a thread of its own, once the last is older than MENDARI_REGISTRY_RECALL_CHECK_S, five minutes unless set; that decision, and any made while the read runs, use the list read before); so does a registry not read for a day (MENDARI_REGISTRY_RECALL_STALE_S), one not read since the server started, and a marker that names no registry; and, once the registry publishes a signing key, a copy it never counter-signed (T11). The cap follows where the agent came from, not its bytes: nothing in the agent lifts it, a copy of a bundled agent included. mendari decide --db honours the trail's approvals and is capped without one; a library caller is capped unless it passes origin_approval. The Decision Card shows where the agent came from, a recall and the approval, and asks before approving (ADR-0012) test_a_pulled_agent_never_automates_before_its_digest_is_approved, test_risk_level_4_never_automates_even_approved, test_nothing_in_the_agent_lifts_the_cap, test_an_unapproved_pulled_agents_own_block_goes_to_a_person, test_an_organization_approves_a_pulled_digest_and_can_revoke_it, test_an_approval_is_one_organizations_and_one_a_digest, test_the_command_line_decides_a_pulled_agent_capped_unless_its_trail_approved_it, test_a_recall_recorded_at_pull_holds_even_an_approved_agent, test_a_running_server_stops_automating_an_agent_its_registry_recalls, test_a_watched_recall_stops_automation_and_its_own_block, test_an_agent_that_names_no_registry_is_held_and_others_are_not, test_what_the_watch_holds_and_when, browser tests (test_an_unapproved_agent_says_so_and_is_approved_through_the_dialog, test_a_recall_is_said_and_holds_even_an_approved_agent)
E13 Script injection on the Hub through publisher text: a script tag, an onerror image or a javascript: link in an agent's card, name, summary or changelog 5 The registry's card is plain publisher text (S18). The Hub renders it with remark-gfm and skipHtml (no raw HTML), no image, and react-markdown's URL check, which drops a javascript: link; other publisher text is React text. Every page has a CSP with a fresh nonce (script-src 'self' 'nonce-…' 'strict-dynamic', object-src 'none', base-uri 'none', frame-ancestors 'none') and the isolation headers (hub/proxy.ts). CI's hub-site seeds an agent whose text tries all three (hub_seed.py --hostile-example), runs the Hub's Playwright tests (hub/tests/smoke.spec.ts: no script runs, no unsafe link; hub/tests/headers.spec.ts: every page's headers by value), then the pinned OWASP ZAP baseline, failing on a medium or high risk test_publisher_text_in_the_registrys_card_is_plain_text, test_a_changelog_that_is_not_utf8_is_refused_and_a_huge_card_too, test_the_hub_site_job_runs_the_hubs_tests_and_the_pinned_scanner, test_zap_check_fails_on_a_medium_or_high_risk_only
E15 A CDS client's token used beyond /cds-services: on the REST, FHIR, audit or administrative routes, as a person's or an administrator's credential, in another organization, or to make Mendari read a FHIR server the client did not register 1, 2, 3 A verified token is a principal of kind cds (cds:<id>, in the chain cds <id>) in its registered organization, holding discover and decide and nothing else. Only the guard's CDS branch, on /cds-services and its children, makes one, and should one reach any other path it is refused there (403, cds_only). Anywhere else a JWT is never read as a credential: with sign-in on, past the 512-character bearer cap it is malformed, under it an unknown_prefix; in open mode, which reads no credential off /cds-services, it is ignored and the caller is open mode's, as any caller is there. Mendari's own ohk_ keys and mat_ tokens do not change. With an Authorization header there is no fallback to a session cookie (S5). In memberships mode a client of an organization with no record is refused, before its jti is claimed. The fhirServer a cds principal sends must normalize to one of its registered bases (and, with iss_is_fhir_server, be its iss), else 403 (cds_fhir_server_not_registered) before anything is charged, fetched or decided. It is rate limited and capped daily as cds:<id>, as any principal is, and the notice acknowledgement is a person's only. test_a_cds_client_reaches_nothing_but_cds_services (the route inventory), test_every_route_principal_role_and_scope_gets_what_it_should, test_the_principal_is_confined_to_cds_services, test_a_long_jwt_elsewhere_is_still_malformed, test_a_fhir_server_the_client_did_not_register_is_refused_before_any_read, test_a_fhir_server_is_one_the_client_registered, test_a_cds_client_decides_in_its_registered_organization, test_every_principal_kind_is_capped_on_the_routes_it_decides_on, test_health_shows_client_ids_to_read_principals_only
E16 Open mode answering CDS Hooks from a network: a sandbox or demo with sign-in off, reached from another machine (an open port, a proxy in front of it, the compose sandbox published beyond loopback), or from a page that points its own name at 127.0.0.1 (DNS rebinding), lists the services and decides on whatever record it is sent, as open mode's one principal, with a forged or a valid EHR token 1, 2 With sign-in off, before any credential is read, a request to /cds-services or a child goes on only from this machine (cds_clients.on_this_machine, LP-23c, ADR-0014): the caller's address is a loopback address (limits.client_ip: the connection's, or the one uvicorn takes from a proxy it trusts), no forwarding header is present (Forwarded, X-Forwarded-For, X-Forwarded-Host, X-Real-IP: a proxy on this machine connects from loopback too), and the one Host header names this machine (localhost, a .localhost name or a loopback address), which a rebinding page cannot make its browser send. Anything else is a 403 with fixed words, logged as open_mode_remote, whatever the request carries: a verified token does not lift it, and nothing is verified, claimed or decided. MENDARI_CDS_SANDBOX=1 lifts the rule for a sandbox on synthetic data, with a warning at startup; 0 is off, as unset is, and any other value, or 1 on Vercel or with sign-in on, stops the server. Only the compose sandbox's open engine sets it; its signed-in engine, the on-prem and Kubernetes templates and the hosted site do not, and a test pins that. The rest of open mode is unchanged, and still answers any host: open mode is for synthetic data on a machine of one's own, and a site puts sign-in on (§2 of the PHI guide). Residual: a proxy on this machine that adds no forwarding header makes every request it forwards this machine's, wherever it came from. nginx's default is one: proxy_pass http://127.0.0.1:8000 sends Host: 127.0.0.1:8000, a loopback address, and no forwarding header. Behind any proxy, turn sign-in on. test_open_mode_answers_cds_hooks_on_this_machine_only, test_a_spoofed_host_or_forwarded_header_is_not_this_machine, test_the_sandbox_flag_answers_from_anywhere_and_stops_startup_on_vercel_or_with_sign_in, test_a_verified_token_does_not_lift_the_rule_in_open_mode, test_the_rest_of_open_mode_is_unchanged, test_only_the_sandbox_engine_answers_cds_hooks_from_the_network, test_every_route_principal_role_and_scope_gets_what_it_should
E17 Someone who is not one of the registry's reviewers approves a namespace, sets a publisher type, records a review, recalls or deletes a version through the engine: an administrator who gives the reviewer role in their own organization and approves their own first publish, a member whose role was written past the routes, a key, a client, a publisher token, open mode or claims mode, another site's page driving a reviewer's browser, or a reviewer deciding the claim they filed 5 The reviewers' routes (/api/registry/review/..., LP-19e) need registry_review, a people-only permission that open mode never holds and that one reserved membership role grants, registry_reviewer, and only for a membership of the one organization MENDARI_REGISTRY_REVIEW_ORG names (Auth._member): held in any other organization it grants nothing, and giving it there is refused (422) at an invitation, a role change and a granted request to join. The review organization's administrators are not reviewers until they hold the role. Claims mode never reads the role from the identity provider, and the routes are not mounted there, without the setting, without MENDARI_REGISTRY=on, or when the organization named has no record (the server says so at startup and leaves reviewing off). Each route checks the person, the organization and the role again itself. A reviewer never acts on a namespace they claimed themselves (403): not its decision, its publisher type, a review, a recall or a deletion, so nobody writes what the registry shows as checked about their own agents. The queue carries no card, whose size a publisher chooses. The engine's origin check stands in front of every route, and the mounted registry still reads no session cookie. A recall is signed with the registry's key or not made. Residual: whoever administers the review organization chooses the reviewers, so its administrators are trusted as the shared administrator token's holder was; a reviewer may act on a namespace claimed by someone else of an organization they also belong to; a membership that already held the role in an organization later named as the review organization reviews from the restart, which the server logs test_an_administrator_of_another_organization_is_not_a_reviewer, test_the_reviewer_role_cannot_be_granted_outside_the_review_organization, test_without_a_review_organization_nobody_reviews_and_nothing_lists, test_a_reviewer_does_not_decide_their_own_claim, test_a_key_a_client_open_mode_and_claims_mode_never_review, test_another_sites_page_cannot_review, test_the_recall_needs_the_signing_key_and_says_so
E18 The author role reaching beyond the store: an agent author reading cases, deciding or approving; an administrator writing agents unseen; another site's page driving an author's browser 1 agent_author grants author and nothing else (no read, no decide, no approval), a people-only permission that open mode never holds; admin does not hold it (owner decision 4), so an administrator who writes agents gives themself the role, and it shows on their membership. The route rules put /api/store/keys under keys and the rest of /api/store under author, before the catch-all read. The engine's origin check stands in front of every store route. Running a version over the improvement dataset reads cases (what it decides of each is a function of the input that its author chose), so it also needs the permission to read inputs (I23). tests/test_store_improvement.py (test_an_author_who_may_not_read_inputs_runs_no_version_over_it); tests/test_store_uploads.py (test_a_key_a_client_and_an_ehr_launch_never_author, test_a_viewer_a_reviewer_and_an_administrator_without_the_role_cannot_upload, test_another_sites_page_cannot_upload); tests/test_memberships.py (test_agent_author_grants_author_only)
E19 An author promoting their own work, alone or through a second account, or a promotion letting an agent automate beyond its risk level 1 The store refuses an approver who made the version or any version on the chain of edits it was made from (an edit by a second person frees nobody). Promotion only makes a version served: at risk levels 2 and 3 it still automates only with the automation approval of its digest, the hold and the kill switch still stop it, and an agent of level 4 or above never automates (ADR-0002). A one-person organization cannot promote, with no way round (owner decision 11). A promotion to recommend only never automates, and a version's author is refused the automation approval of it too. Residual: a person who controls two accounts in one organization, each with its own membership, can author with one and promote with the other; the chain names both. An author key is the organization's, not one person's: a key holder who did not upload a version is not counted among its authors. tests/test_store_promotion.py (test_the_author_cannot_approve_their_own_promotion, test_the_automation_approval_is_not_a_promotion_and_a_promotion_is_not_one, test_a_held_agent_and_the_kill_switch_still_stop_a_store_agent)
E20 Someone who may not registers a site, adds or revokes its keys, or verifies it: another organization's administrator, a key, a client, a viewer, another site's page, or a reviewer deciding their own organization's site 5 The people's site routes (/api/registry/sites, LP-22i) need keys, people only, and act for the organization the guard let through: another organization's site answers as one that does not exist, to read or to change. The reviewers' site routes need registry_review in the review organization, as E17's do, and a reviewer never decides a site they registered or their own organization's (the store requires the organization, so no caller can forget it). The engine's origin check stands in front of every route. The operator's commands on the registry's database are the way where nobody signs in, each with a reason. tests/test_registry_site_accounts.py (test_one_organization_never_sees_or_changes_anothers_sites, test_a_key_a_client_and_a_viewer_cannot_register_a_site, test_an_administrator_elsewhere_is_not_a_site_reviewer, test_another_sites_page_cannot_register_or_verify), tests/test_registry_sites.py (test_another_organization_neither_sees_nor_changes_a_site_or_its_keys)

Agent content

What an agent can set, which agents the deployment owns, and what an agent can and cannot do with what it sets (LP-16, ADR-0009). Each limit names the row above that holds it; each thing an agent can do names the row that bounds it, or why it is left as it is.

Inputs

An agent is a directory, or a signed archive of one (S4). Mendari reads it as data (YAML, JSON and text): nothing in it is imported or run as Python. Its digest covers every file but those under evals/, any DECISION_CARD.md, and hidden entries and __pycache__ (S15); a file it decides or tests with is read only if the digest covers it, and only as hashed (T2, E9). What an agent sets:

Input What it sets Checked
agent.yaml The manifest: spec_version, id, version, name, summary, license, publisher, risk level, card, code_systems, the questions (their instructions and criteria are the prompt its model variants send), the provider slots and their variants, audit.store_input, cds_hooks, evaluation, the actions it may propose (each with its effect and an arguments schema), and the texts it writes (outputs) with their rubrics At load, as a closed model but for the variant keys (core/spec.py AgentManifest)
policy Thresholds, rules, label policies and automation_requires, a section of the manifest At load; policy only lowers automation (E3)
inputs.schema The JSON Schema every input is checked against At load (core/input_schema.py): self-contained (E9); for an agent the deployment does not own, its keywords and the caps (D8); for an owned one, the expansion bounds (D10)
inputs.fhir The FHIR mapping: how a record becomes an input, and the Task a decision writes, with [system=…] predicates, fallback paths, follow (a path of the field's own type read in place, LP-23k), attachment_text, code_sets and the code_set selector (for focus_where too, LP-23k), list resources and medication_period (LP-23g) At load, that it is a file the digest covers (E9); its content at load for an agent the deployment does not own, for an owned one where it is used, and by mendari validate. Its paths are of the subset, and its [system=…] predicates and code sets name systems its code_systems declares; for an agent the deployment does not own, and every agent in mendari validate, at most 4 paths a field and 200 codes a code set. A follow is one hop for every agent, resolved once a field, and the mapping resolves it and an attachment's url inside the record only, each by one lookup in the indexed record, so a mapping's work grows with the record, not with its square. What the record lacks, a CDS hook or the SMART launch's decide reads first from the request's fhirServer only, under its base, at most 50 notes and 50 followed references a decision and 100 reads a request (E1, D14)
tests Behaviour tests (mendari test, the examples in the API reference) At load, only that it is a file the digest covers; a case's shape where it is read (D7); its input against the schema by mendari validate
evaluation.datasets JSON Lines datasets (mendari eval, POST /api/agents/{namespace}/{name}/evals) At load, only that each is a file the digest covers; each line where it is read (D7); its input and labels by mendari validate
config, calibration, mock_file A variant's or composite member's agent file: a rules config, an LLM's or an agent's calibration, or an agent offline mock fixture At load: a file the digest covers, named by its field (E9), and read by its provider's check (E8)
rubrics.<name>.judge.mock_file, evaluation.grades.<rubric>.file A judge's canned grades, and clinicians' grades of written output At load: a file the digest covers, named by its field (E9); a judge's canned grades read by its check at load (refused for an agent the deployment does not own, a warning for an owned one); a grades file by mendari validate and where it is read (D7)
Variant keys Everything else a variant or composite member sets, by provider type (below) At load, against its type's closed config (providers.config_problems, published as docs/spec/provider-configs.schema.json): refused for an agent the deployment does not own, a warning for an owned one; an llm or agent variant or member that sets api_key_env, base_url_env, local_key_env, model_env, endpoint_env or token_env is refused for every agent (core/spec.py) (E8)
Wording templates cds_hooks.card.summaries and also_show's summaries, and the FHIR mapping's task.description and task.performer A card summary's placeholder names at load, a Task text's where it is used (at load for an agent the deployment does not own); bare placeholders for an agent the deployment does not own (E4)
cds_hooks.prefetch What a CDS Hooks service needs from the EHR, read from the EHR's FHIR server when the request leaves it out At load: a relative read or search, refused for an agent the deployment does not own, a warning for an owned one (E1)
CHANGELOG.md The history the card shows In the digest; UTF-8 where it is read (D7)
Attestations: evals/ (evaluation.benchmark, evals/leaderboard.json) and DECISION_CARD.md What the agent says about itself Outside the digest; their shape where they are shown (D7); never read to decide (E9); never read or shown by a registry, nor shown or compared with by the engine for a pulled agent (S18)

Every provider type the engine has (providers.PROVIDER_TYPES), and the keys its closed config takes beside type:

Provider type Decides Variant keys
rules On this machine, by weighted patterns in its config config
llm At a chat model, through the AI Gateway or at LLM_BASE_URL model, timeout_ms, max_tokens, temperature, reasoning_effort, state_fields, calibration, batch, repeat
agent At an external HTTP AI agent (MENDARI_AGENT_URL, or endpoint on an owned agent) or offline via mock_file endpoint, service_id, system_prompt, instructions, timeout_seconds, state_fields, mock_file, calibration, repeat
check By its first member; its second member is asked the same and can only send the decision to a person (spec §14.4) members

Trust boundary

Whether the deployment owns an agent decides most of what follows. It is read from where the agent was found and the digest load_agent hashed, never from a registry's record or a marker file (core/origin.py bounded, read as Agent.bounded; S15):

  • Owned: the agents this release bundles (maintained); an operator's own agents (local: in MENDARI_AGENTS_PATH, or a path given on the command line), a copy of a pulled agent included, which is how an operator says it trusts one; and an agent pulled from a registry whose digest is one of the bundled agents', which is that agent. Installing an owned agent means trusting its author, as with any plugin.
  • Not owned: every other agent pulled from a registry (hub), and a version in an organization's agent store (store, LP-20e). These run on the bounded engine (D8), and what only warns for an owned agent refuses them at load.

The API, the dashboard and the SMART patient view label every agent by its origin, and the Decision Card names the source only of a maintained agent. An agent from outside comes in across boundary 5 (a registry) above, and every agent reaches out through 3 (FHIR servers) and 4 (model providers), only at addresses the deployment sets or allows (E1, E8).

What an agent can do

  • An owned agent chooses what its model calls send and ask for. An llm variant without state_fields sends the whole input. A pinned model is used: an llm variant's wins over LLM_MODEL. It may ask for up to 32,000 tokens, an LLM timeout of up to 120 s and any reasoning_effort, each call within the decision's deadline (D9). This is the operator's choice (I5); an agent the deployment does not own can do none of it (I5, E10). test_a_registry_agents_remote_variant_needs_state_fields, test_a_registry_agents_pinned_model_gives_way_to_the_deployments.
  • Any agent turns batching off or sets a temperature. A model variant with batch: false is asked in a call of its own instead of sharing one with the decision's other questions, so a decision makes more calls, each counted against the budgets and quotas (D2) and made within the deadline (D9). An llm variant's temperature (0 to 2) is sent as the agent sets it. An agent from a registry keeps both, and an agent from a store keeps neither (LP-20e). Residual for an agent from a registry (tasks/todo.md, LP-16 conflict 24).
  • An agent from a registry is chosen for as an owned agent is. The deployment's unscoped MENDARI_PROVIDERS settings (slot=variant) apply to it. And POST /api/agents/{namespace}/{name}/evals runs any variant of it that a caller with the evaluate permission names, a remote one on up to 200 cases. Residual (conflict 24), for an agent from a registry; an agent from a store takes only the settings that name it (LP-20e).
  • An agent from a registry automates only once its organization approves it. Served, it never automates until its organization approves its exact digest, at any risk level, and its own rules' BLOCK goes to a person until then; a recall recorded at pull or read by a running server, and a registry not read for a day, hold it the same way, approved or not (E12). Approved, it automates as an owned agent does: by its own thresholds at risk levels 0 and 1, at levels 2 and 3 only under an approval of its digest too, and never at level 4 (E3). Its risk level, for policy, is what its publisher declares; a registry reviewer's review shows whether it found the same (S18) and changes nothing here. Pulling it is the operator's choice (ADR-0009). test_a_pulled_agent_never_automates_before_its_digest_is_approved, test_a_running_server_stops_automating_an_agent_its_registry_recalls.
  • An owned agent runs its patterns on re. Its rules' and input schema's patterns run with no time limit, so one that backtracks stalls the worker that runs it while holding the interpreter. Accepted (ADR-0009, and the residual risks below). Its schema's shape is bounded at load (D10); an agent the deployment does not own runs on RE2 within a budget (D8). test_owned_agents_stay_on_re, test_health_answers_within_its_bound_with_a_pathological_agent_loaded.
  • An owned agent's content problems only warn. A variant or member its provider's closed config refuses (a key nothing reads, a value out of range, an agent file the provider cannot use), a prefetch template that is not a relative read or search, and a card summary placeholder that is not bare: the agent loads with them as Agent.warnings (mendari list, the start-up log, /api/health agent_warnings) and decides as its manifest says, each variant building, or failing, when it is built. A Task text placeholder that is not bare is not warned of, and renders as it is written. mendari validate refuses all of them, and the prefetch still reads only from the EHR's FHIR server (E1). An agent the deployment does not own is refused for any of them (E1, E4, E8). Conflicts 17 and 21: making owned agents refuse is a one-line change, for the owner. test_an_owned_agents_unread_key_warns_and_it_still_serves, test_a_broken_non_default_variant_is_refused_for_a_registry_agent_and_warned_for_an_owned_one, test_a_prefetch_template_must_be_a_relative_read_or_search, test_a_wording_template_takes_bare_placeholders_only.
  • An agent's tests, datasets and attestations are its publisher's word. Loading, a registry's publish and mendari pull check only that its tests and datasets are files the digest covers; mendari validate checks their inputs against the schema and their labels against the questions, and loading does not (conflict 17). Its benchmark, leaderboard and card are outside the digest, so they change without changing it. A registry never reads or shows the ones an agent uploads: it renders the card itself from the files the digest covers, and its only figure is its own regression check on the agent's test set, labelled the publisher's own and never a ranking (S18). Where the engine serves a pulled agent it shows the registry's card and no uploaded benchmark or leaderboard, and neither its monitor nor its evaluations compare with the benchmark the agent carries (S18). None of them is read to decide (E9). test_a_forged_card_benchmark_and_leaderboard_show_only_what_the_registry_rendered, test_a_pulled_agents_uploaded_benchmark_is_never_compared_or_monitored_against.
  • An agent's slow decisions can keep health waiting. /api/health, and the sign-in check that runs before every request, use the same thread pool as the decide routes (AnyIO's default, 40 threads), and a decision waiting on remote providers holds its thread until they answer or its deadline passes (MENDARI_DECISION_DEADLINE_S, 120 s unless set; D9). Forty such decisions at once make health, and every other request, wait for a thread. Health itself does no agent work (D7). Residual (conflict 23), not in LP-16.

What an agent cannot do

Whatever it says, and whoever wrote it, an agent cannot:

  • Pass for another agent or another origin. Its origin is where it was found, and every surface labels it by origin. An agent from a registry keeps the maintained engine only with a bundled agent's digest (S15), and one with a bundled agent's id, a version that ties its and other files is refused at load, publish and pull (S16).
  • Change what it decides behind its digest. Every file it decides with is in its digest and read as hashed, so a file edited after the load is refused, never used, and a governance approval is bound to the digest (T2). It reads nothing outside its directory or its digest: no link out of the agent, no hidden entry, nothing in evals/ on the decide path, and no $ref to a URL or a local file (E9).
  • Stop the server. Whatever its content, an agent that fails to load or build is listed under /api/health invalid and every other agent is served, and health builds no agent in the request (D7). An agent the deployment does not own runs its patterns on RE2, within caps and a budget of one second of CPU per decision, so about 3.5 s at worst (D8); a decision's remote calls stop at its deadline, which an agent cannot set (D9). An owned agent's input schema is bounded at load (D10), but its patterns run on re with no time limit, so one that backtracks can stall its instance (above, and the residual risks).
  • Choose where its data goes, or with which credentials. The variables a remote provider reads its endpoint, model and key from are fixed in the code and are the deployment's, a variant that names one is refused at load, and every call goes to the deployment's endpoints with its keys (E8); with MENDARI_PROVIDER_ALLOWED_ORIGINS set, an LLM call goes only to the origins it lists (E1, I5). A prefetch read stays on the EHR's FHIR server and fills in FHIR ids only (E1, E4), and its FHIR mapping fetches nothing itself: a follow or an attachment's url resolves inside the record it is given, or to nothing. What the record lacks, a CDS hook or the SMART launch's decide reads from the request's fhirServer only, under its base, at most 50 notes and 50 followed references a decision and 100 reads a request, of at most 2 MiB each, inside the decision's deadline (E1, D14).
  • Inject through its wording. A wording template names only {recommendation}, {priority} and the agent's questions, and in an agent the deployment does not own each is a bare name (E4).
  • Automate beyond its risk level. Policy only lowers automation: level 4 is never automated, and levels 2 and 3 only under an approval of the agent's digest (E3).
  • Choose its model, the length of its answers, its timeouts or its reasoning effort, or send a model more than it names, if the deployment does not own it. Its model is the deployment's, its max_tokens and timeout_ms are held to the provider defaults and a reasoning_effort above low is dropped (E10), every model variant and member names its state_fields (I5), and its configs are checked at load first (E8). Its questions' text, sent with every call, is its own, up to the provider's request limit (LLM 100,000 characters).

Residual risks and assumptions

  • The patterns of the agents a deployment owns run on re with no time limit (those of an agent it does not own, such as one pulled from a registry, on RE2: D8, S15). Their input schemas are bounded at load (D10), so a schema's shape cannot multiply the work of checking an input; a pattern in it still runs on re. Installing an agent means trusting its author, as with any plugin. Rules patterns, input-schema patterns and patternProperties keys are compiled at load (core/patterns.py: valid under re, at most 2,000 characters, at most 500 per agent), but a pattern that backtracks ((a+)+$ takes seconds on 27 characters, doubling with each more) can slow or stall the worker that runs it, holding the interpreter while it does; compiling a large case-ignored class at load also costs CPU (an agent at the caps can add seconds to a start). The bundled agent is the owner's and reviewed; accepted with ADR-0009, a crafted 10,000-character message to an owned agent whose pattern backtracks can hold the interpreter on re, stalling its instance (the rate limits bound how often). The patterns of every agent the deployment does not own run on RE2, which never backtracks, on texts of at most 10,000 characters (D8), with the settings that multiply that work capped at load (core/caps.py, their size together included) and a time budget of one second of CPU per decision for their patterns and schema checks (D8), in the server's process (no isolated worker process: ADR-0009). A local copy of a pulled agent (in MENDARI_AGENTS_PATH) is owned: it runs on re, as the operator's own. A time limit inside the regex module was tried for every agent and dropped (it could not match re's semantics exactly, and its clock was the process's, not the thread's).
  • The deployment is the site's. TLS termination, network placement, backups, the database's own access control and the PHI key's custody (a KMS or secret manager) belong to the deploying organization (docs/deploying-with-phi.md).
  • Open mode trusts its network. Without sign-in the server is open. Production has sign-in on (Vercel Authentication protects its Preview deployments only), and the sandbox listens on 127.0.0.1 only. Its CDS Hooks services alone answer this machine only (E16), since an EHR is what reaches them over a network; the rest of open mode answers any host.
  • An EHR launch trusts the EHR's sign-in. A launch is a principal of its registered organization (E7) on the strength of the id_token the EHR signs: a site registers only an EHR whose sign-in it trusts, and one FHIR base for one organization (an EHR instance shared by several organizations, such as Epic Community Connect, cannot be split by base and is not supported). Whether each EHR binds its launch to the user who started it is the EHR's. Most EHRs send no email_verified, so the chain will mostly name launched clinicians <issuer>|<subject>. A browser holds one launch at a time: two charts launched one after the other in one browser end the first launch and leave its window saying it was replaced (it shows no patient, and the server refuses its reads), and the clinician launches it again from the EHR. Unregistering an EHR takes effect at the next restart or redeploy, not at once. In open mode with no EHR registered, a launch is as before: anyone the EHR lets launch decides in open mode's one organization. The launch is off unless configured (off in production, read in its signed-in /api/health on 2026-10-03).
  • People's sign-in rows are not sealed. A user row keeps the person's name, verified email, issuer and subject and the claims their roles come from; an oidc-pending row keeps the sign-in's PKCE verifier for ten minutes. Neither holds a token. Sealing them would sign everyone out once; it is deferred to the PHI keyring work (ADR-0006).
  • The EHR's token stays valid at the EHR after a launch ends here (logout, idle, a sealed row that does not open) until it expires: nothing is revoked at the EHR. The copy Mendari held is sealed, and an EHR that answers 401 ends the launch here too.
  • The feedback export's log line lists exported records only. A rating left out of the export because its input was not kept, but whose note was opened, is chained (input.read) without a phi.inputs.read log line. The chain is the record that lasts.
  • A registry nobody signs in to is run by command. Since LP-19g there is no shared administrator token: on a registry of its own, claims, publisher types, reviews, the registry's recalls and deletions are the operator's commands on its database, chained with the command line's user and the reason given, which are only as true as the machine that ran them (R3). Under the engine a reviewer acts as a person, by id. Events from before LP-19g that name admin stay as they were written.
  • What a signed site report still does not show (LP-22). A ticket binds a dataset before its run; it cannot show how the site chose its cases before it asked for one, so a site's evidence is shown apart from every rank, with the unreported tickets beside it. The registry's chain is still unkeyed (T7). A site's name is as good as the reviewer's check of who it is, done outside Mendari. A correction may use other data than the report it supersedes; both stay listed.
  • A registry that cannot be read holds its agents, after a while. A server holds every agent pulled from a registry it has not read for a day (MENDARI_REGISTRY_RECALL_STALE_S), so an outage of the registry stops their automation (the safe direction). A server reads a registry's recalls only when a decision for one of its agents finds the last read older than the check interval (300 s), and that decision, like any made while the read runs, uses the list read before. A server that decides steadily has a recall within about the interval, or later while reads fail; after a quiet spell the first decision after a recall can still automate, and health's checked_s_ago shows the last read, not the registry's list. A hold (POST /api/holds) stops an agent within seconds, with no read. A serverless instance starts unread, so its pulled agents wait for its first read. mendari decide and Decision.from_hub know only the recall the last pull recorded. GET /v1/yanks is not paged: past a reader's 5 MB cap every read fails, and a day later every agent from that registry is held.
  • The registry's chain is unkeyed. Whoever can write the whole registry database can rewrite the chain with it; only a head kept elsewhere shows that (T7). The registry signs one on request (mendari registry checkpoint) and checks a kept one (mendari registry verify --checkpoint), but keeping it, daily and where the registry cannot write, is the operator's routine: nothing publishes or schedules it, a checkpoint says nothing about events appended after it, and whoever holds the signing key can sign any head. A review's note stays in the chain for good (a reviewer's or the operator's words about an agent, never case text).
  • The registry's signing key has no rotation path. A client pins it at first contact (@registry). A recall it cannot verify is still honoured: safe for patients, but a forged recall can stop an agent's automation until someone looks (S19).
  • The regression check measures the publisher's own test set. The publisher chooses the set, so the check can be gamed; it shows a regression and never refuses a version, and a first version has nothing to compare with. An agent whose default providers call a model is not measured (needs_remote). It runs in a child process of the registry's own user (python -I, a fixed environment of five variables, limits on CPU, file size and, where the system bounds it, memory: macOS does not), with no network or filesystem sandbox: accepted, since an agent's content is data and only local providers run (D11).
  • Smaller registry residuals. An approval of a pulled agent's digest lasts until revoked; the publisher type the registry shows is the namespace's as it stands now, not when the version was published; and the Hub's own checks (its Playwright tests and the ZAP baseline in CI's hub-site, and the dashboard's approval screen in browser) are not required checks on main, so a pull request can merge with them failing.
  • Namespaces once taken stay taken (LP-19). A refused claim keeps its name, and releasing a name or moving a namespace to another organization is not built; a lookalike that is not a reserved name is the reviewer's to refuse (S23). A publisher token is the organization's and keeps working when the person who made it leaves it: the revoking-access runbook says to revoke it (S22).
  • Clinical content (agent criteria, rules, thresholds) is outside a security review. It needs clinician review and local validation, and every agent's card says so.
  • A CSP does not stop navigation. A compromised script in a page could still navigate away carrying what it read. The vendored Swagger UI is protected by its pin, the integrity check and a review of each update (scripts/vendor_docs_ui.py lists the hosts a new bundle names), not by the CSP alone.
  • Synthetic data only until the owner's go-ahead for real patients, after this review.
  • Limits are per instance clock and per region at the edge. The app's buckets use each instance's clock (a skew of a second or two shifts a refill by as much), and Vercel's firewall counts per region. Neither matters at these limits.
  • One database, one public URL. Tokens and jti claims are rows in the deployment's database. Two deployments that share a database and a MENDARI_PUBLIC_URL (a preview pointed at production's database, say) accept each other's tokens and assertions. Give preview its own database, or keep Backend Services off there.
  • Raw intervals on sets built from templates look narrower than they are. Every figure on a public set is raw k of n with its exact 95% interval, and Clopper-Pearson takes the n cases as independent. A set generated from templates repeats its inputs: a test set of 600 cases may hold far fewer distinct inputs under norm/v1, and its positives fewer distinct ones still. Its intervals are as narrow as 600 independent cases would give, so they overstate how sure each figure is. Against it: each scope names the set's distinct inputs beside n, the evidence rule and the grade's bound count distinct positives (a group detected only when every positive case in it is), the insufficient-evidence banner shows where they fall short, and nothing is ranked or graded on a public set (ADR-0013). The raw interval itself is not widened: that would change every published figure (mendari.eval/1, Proportion.to_dict).
  • Trust in the EHR's key, and its rotation. A token that verifies is the registered client's word (S21): Mendari checks that the client's key signed it, for the URL it was sent to, once, and nothing about who or what at the EHR made the call (a CDS Hooks token names the EHR, not a person, and sub is checked only when pinned). Whoever holds the EHR's private key can call as the client: the EHR's own systems and staff, its vendor's, or anyone who takes the key from them. What holds then is the client's confinement (E15): discover and decide on /cds-services only, in its one organization, reading only its registered FHIR bases, feedback only on the cards it asked for (R5), its rate limit and daily cap as cds:<id>, and each call chained as cds <id>; it reads no decision, no audit trail and no other route. Mendari learns that a key was retired only when it fetches the keys again. Keys from a jwks_uri are kept an hour on each instance (D13), so a key the EHR takes out of its JWK Set, a stolen one included, still verifies there for up to an hour, unless a token under a kid the kept keys do not hold makes that instance fetch sooner (at most once a minute) or it restarts; keys given by value verify until the registry is changed and the server redeployed. A key the EHR rotates in verifies from the first fetch after it: an instance that fetched in the last minute refuses its tokens (cds_key) until that minute has passed, so an EHR that switches keys at once can see up to a minute of 401s on each instance, and a hook that gets one shows no card. To stop a client at once, take it out of MENDARI_CDS_CLIENTS and redeploy.
  • A compromised jku host. A client registered by jwks_uri trusts whatever public keys that URL serves: the URL is pinned, its origin is on MENDARI_FHIR_ALLOWED_SERVERS, each token's jku must equal it exactly, and it is fetched through the allow-listed client (https but for a loopback or single-label host, no redirects, a size cap, public signing keys only). None of that tells a key the EHR published from one someone else put there. Whoever controls that host, its DNS or a certificate for its name can publish a key of their own; the next fetch (when the kept keys are an hour old, or at once for a token under a new kid, at most once a minute) keeps it, and their tokens are then the client's, with the confinement above and no more. A successful fetch is not logged, so nothing in Mendari shows the change. A client whose tokens carry no jku can be registered with its keys by value, which takes the host out of the trust at the cost of a redeploy for each rotation; a client registered so refuses any token that names a jku, and Epic's tokens name one (ADR-0014), so the Epic pilot trusts its host. The sandbox run records the jku Epic sends and whether it is always the same (notes/epic-sandbox-checklist.md).
  • The decision id disclosed to the EHR. A card's uuid is its decision's id (I18), and with MENDARI_PUBLIC_URL set its link opens /?agent=<agent id>#audit/<id>, so the EHR holds each id beside the patient and the order it sent, in whatever it keeps of the call (its logs, its own audit, its feedback, a vendor's copies), for as long as it keeps them. The id names no one (a random UUID 4 the engine made) and opens nothing by itself: a decision is read only with read in its organization, feedback on it is taken only from the client that asked for it (R5), and the trail holds no patient id (I17). The link is the EHR's: whoever holds the EHR's record of the call and Mendari's trail, or a copy of the chain, can tie each chained decision record (its agent, outcome, reasons and data-coverage counts, kept for good) to a patient, after Mendari's retention has removed the decision's input. Mendari's retention never reaches the EHR's copy. Treat a pilot's chain, exported or archived, as identifiable beside the EHR's records, under the site's agreements (B39).
  • A misconfigured site map. MENDARI_SITE_CODES is checked at startup for its shape and its codes, not for its meaning (T9), and three mistakes pass. A translation into the wrong declared code reads a record as saying what it does not: the decision is capped at HUMAN_REVIEW, a rule's BLOCK included, so it reaches a person, whose recommendation is still built on the wrong code; its reason (site code translated (<code set>): a person decides) says that a translation was used, not that it was right. A site code the map leaves out reads as it would with no map, as no value: nothing was translated, so nothing is capped, and the agent decides (and may automate) as on a record without that code; only the decision's data-coverage record shows it, counting the coding under other. A map under another organization's key is applied to that organization's decisions (capped, as above) and missing from the intended one's (as a gap). Against these: each decision records its map's version and digest, /api/health shows the caller's, the cap holds until the site validates on its own chart-reviewed data (G5-6 site-validation, owner decision 2), and the bundled demo agent declares no code set, so a map reaches only an agent of the deployment's own that declares one.
  • A wrong declaration of what an EHR does not offer. MENDARI_EHR_DECLARATIONS is checked at startup for its shape, its bases and the agents it applies to, not for its truth (T10). A declaration that MedicationStatement is not offered says the medications an agent should see are all MedicationRequests the EHR returns; if some are not (patient-reported home medications kept elsewhere, or as requests the list leaves out), a missing drug reads as not taken, for a person to check: the decision is capped at HUMAN_REVIEW, its reason names the limitation and who attested it, and its record the declaration's digest. Before setting it for Epic the site checks what docs/guides/connecting-an-ehr.md lists (where Epic keeps reported medications and with which intent, whether its search returns stopped and inpatient orders, whether a drug's name carries its generic name).
  • Frequent abstention on RTF-heavy records. An agent reads a note as text only when it is text/plain or text/html (owner decision 9). An RTF, PDF or CDA note is unsupported_type, and a note none of whose renditions reads makes its decision ABSTAIN (could not read notes: unsupported_type). On the vendor-shaped profile, whose notes are links, a patient with a text/plain or text/html note is decided on it since LP-23k, and one with an RTF note abstains (test_html_is_read_as_text_and_rtf_abstains, tests/test_ehr_profile.py::test_the_shipped_agents_read_the_profiles_linked_notes_through_the_allow_listed_client). If Epic sends many notes as RTF, as the plan expects and only the sandbox run will show, an agent that reads notes may abstain on most patients with a note. RTF is not the only cause on a real record. A hook reads every clinical note of the patient (DocumentReference?patient=…&category=clinical-note) and, for an agent that reads medications, every MedicationRequest, and past a decision's budget (50 note Binaries, and apart from them 50 followed references: linked.MAX_NOTE_READS, MAX_FOLLOW_READS) each further link is cap and the decision abstains; and notes longer in all than the agent's input allows are left out of the input, never cut, and abstain (too_large, fhir.overlong, LP-23k; the notes past that point are not read), rather than let the schema refuse the whole input (a BLOCK, which shows no card). On a long history either may be the commoner cause. The first SMART launch on Epic's sandbox (2026-11-08) showed both kinds: the test patient abstained with notes: cap and notes: unsupported_type, the second most likely the RTF twin of each capped HTML note (assumed: each Epic note an HTML and an RTF Binary, which the run's counts fit but cannot confirm, since they give no content types; a note's renditions now count once, by its text rendition's reason, fhir.unread_notes); its drugs were cap too, behind one budget of 20 that the notes had used. A note counted unsupported_type now has its format counted (unread_formats: rtf, pdf, xml, image, none, other), so a run with unread notes says how many of Epic's notes are RTF only (the 2026-11-10 run read all 3 of its notes, too few to say). Each abstention goes to a person, which only lowers automation, and shows an info card whatever the agent's show says (owner decision 6), so the risk is workload and cards clinicians learn to pass over, not a wrong AUTO. Each decision's data-coverage record counts its unreadable notes by reason, so the sandbox run shows how often it happens; LP-23 computes no rate from them. Reading RTF is not built: it waits on what the sandbox shows (owner decision 9).

Reporting a vulnerability

See SECURITY.md.