Skip to main content

hank-model-authority

The model authority every product repository reads: which models exist (registry entries with their execution identity and per-family request facts), which model each capability uses (selection policy), and what each model costs (rate tables). The distribution depends on PyYAML and pydantic only, so Risk, Investment and Edgar take it without the gateway.

Mechanism — one artifact, admission, the host directory, lifecycle, skew — is docs/reference/model-authority.md; the data deploy is docs/runbooks/model-authority-deploy.md.

Layout

Module Owns
authority/model-authority.yaml, authority/rates/*.json the packaged artifact: one model-authority/2.x document (registry models, selection.capabilities, one revision) and per-provider prices
schema.py the version rule (SCHEMA_MAJOR/SCHEMA_MINOR), ModelAuthorityError and its message, protocol families and each family's compat: key set
loader.py HANK_MODEL_AUTHORITY_DIR resolution, the strict load, the directory digest
current.py the process's one import-time load: INITIAL_MODEL_REGISTRY, INITIAL_MODEL_SELECTION_POLICY, RATE_TABLES, HEALTH_FACT, health_fact()
registry.py, selection.py registry entries and selection policy
capabilities.py capability IDs and the process that executes each (a release, not data)
binding.py, bind.py the single resolver and CapabilityBind
rates.py, thinking.py rate tables; effort vocabulary
spend_ledger.py, spend_settings.py, authority/spend/*.json the machine-wide API spend ledger, its ceilings, the vendor billing table and packaged default ceilings (not imported by the package root)
operator_settings.py the operator-settings-file machinery spend_settings and the gateway's run_settings share: env-overridable path, sibling lock, in-place write that keeps the inode, stamp-cached reads, deep merge
deployment_settings.py Deployment-local model-authority-deployment.json default-preset reads and writes under USER_DATA_DIR
key_pool.py the shared PAYG API key pool (<provider>-key-pool.json), its cross-process health/cooldown/re-probe state (<provider>-key-pool-state.json), load-time sk-ant-usr workspace validation, and spend_breaches-aware leasing
__main__.py python -m model_authority check <dir>: the ordinary load of a candidate directory

The package root imports types and the loader, never current, so python -m model_authority check <dir> can check a candidate directory while the host directory is broken.

API spend ledger

model_authority.spend_ledger.record_api_spend writes one row per paid LLM or vendor call to one machine-wide SQLite file; spend_settings.spend_breaches compares it with one set of ceilings. Schema 2 records the admitted run_owner, resolved credential_tier and secret-derived credential_fingerprint; version-1 rows migrate with NULL owner/tier, never fabricated attribution. authority/spend/ sits outside rates/ so the loader neither prices nor digests it. Contract, paths, auth_kind and ceilings: docs/reference/api-spend-ledger.md. Tests set HANK_SPEND_LEDGER_PATH and HANK_SPEND_SETTINGS_PATH to tmp_path.

Hank-paid global/provider/pool/service ceilings count only deployment_payg, including metered calls attributed to a user. per_user_daily_payg_usd supplies a default and overrides by run_owner for that user's daily byok_payg spend; freeze_payg still stops both tiers. User KeyPools carry credential_tier="byok_payg" and a required run_owner, use <provider>-user-keys ledger names and keep state in memory.

Which directory a process loads

HANK_MODEL_AUTHORITY_DIR set: that directory, resolved once at start; missing or unreadable fails the start. Unset: the packaged authority/ directory. Every loading unit sets it — /etc/hank/model-authority in production, and on this Mac the login's model_authority_dir() (scripts/local_machine_paths.py:91-98, derived from the login home, not a literal path) — so the packaged copy is what tests and unwired tools load. Every process reports what it admitted through health_fact(): {"revision", "schema", "sha256", "source", "loader", "admits"}; source is the resolved release path (…/model-authority.d/<revision>-<sha12>/…) or packaged:<path>.

Schema

This loader implements model-authority/2.4 and admits 2.0 through 2.4 artifacts (health_fact()["admits"] is model-authority/2.0-2.4): same major, minor at most its own, every other field and literal strict; each refusal is one ModelAuthorityError naming artifact, revision, schema, loader and admitted range. The required capability set is versioned by schema: 2.4 requires all CAPABILITY_IDS, including memory.embed; pre-2.4 requires exactly that set minus memory.embed. Unknown extra capabilities are refused in every version. Binding memory.embed against an older artifact raises the typed capability_policy_missing refusal, naming the capability, schema and revision.

Each entry's compat: key set is its protocol family's (schema.py): the profile maps to anthropic.messages, openai.chat_completions, openai.responses, openai.embeddings or google.generate_content (PROTOCOL_FAMILY_BY_PROFILE), and COMPAT_MODEL_BY_FAMILY holds each family's frozen key set. embeddings.standard requires only strict positive integer dimensions and context_window (maximum input tokens), not chat output/tool controls. 2.1 adds two anthropic.messages keys, each derived when absent so 2.0 artifacts load unchanged, and each refused when it contradicts the 2.0 key it refines:

Key Values Absent Must agree with
thinking.off_value disabled, between_tools, null (cannot be turned off) disabled if can_disable, else null can_disable is true exactly when off_value is disabled
tool_choice_forcing any, thinking_off_only, never thinking_off_only if forced_tool_choice_requires_thinking_off, else any that flag is false exactly when forcing is any

The 2.0 keys stay required (a minor removes nothing), so an adapter that still reads can_disable or forced_tool_choice_requires_thinking_off keeps working; the gateway's Anthropic adapter reads both new keys. Sonnet 5.5 uses can_disable: false, off_value: between_tools: the legacy bool still means whether the literal thinking.type: disabled is legal.

memory.embed is gateway-executed and programmatic, separate from the agent-only core capabilities. Its concrete default is openai.text-embedding-3-small@none; openai.text-embedding-3-large and openai.text-embedding-ada-002 are also admitted for deliberate operator changes to that concrete authority default, not conversational model overrides. Changing the default changes the vector space and requires re-embedding stored memory. Queries must never use a different embedding model from the stored vectors, even when both models have the same dimensions. Embedding entries have no reasoning or chat features. Ordinary fallback and credit-exhaustion failover projections produce no embedding hops: vectors from different models are not comparable. Projections are pure; the calling transport owns the typed credential-exhaustion refusal.

Tier selection (2.2)

selection.tiers maps arbitrary non-empty role names to a default assignment and an optional allowed_model_keys ceiling. Assignments are one of:

  • {models: [key, ...], effort: high}: ordered, non-empty execution candidates; this tier must declare a ceiling containing every candidate.
  • {alias: deep, effort?: high}: use another tier's assignment, optionally replacing its effort. An absent ceiling inherits the target's ceiling over the base policy alias graph, before any override. Aliases must be acyclic and target an existing tier.
  • {kind: inherit_parent}: copy the existing exact parent bind; no role ceiling.

Capability and channel defaults may be {kind: tier, tier: default, effort?: high}. The static project_tier owner is shared by artifact admission and resolution: first candidate qualified for the capability, in both the slot and referring tier ceilings, and eligible for new selection. Effort is requested effort, then slot-local effort, then resolved tier effort (outer alias effort wins). The chosen candidate on the base tier must support that exact effort (no clamp or next-candidate retry); when a preset/role-map override selects a model that does not support the requested or slot effort, the override's own tier effort applies. Existing entitlement and credential checks follow selection, and their failure never falls through to another candidate.

A reader that needs one capability's concrete no-override default (a startup default entry, a dry-run label, a contract check) calls project_capability_default(registry, policy, capability_id); it returns the kind: model default as written and projects kind: tier through project_tier. Never read .default.model_key directly: it is None for tiers.

resolve_capability_model adds keyword-only requested_role, role_map, role_map_source and requested_role_source. A map's entries replace tier defaults and may replace fallback chains. Omitted roles use policy, except a map that names deep but not default or build routes those roles through deep, and a map that names fast but not judge routes judge through fast, for both the assignment and the fallback chain. Aliases resolve within that effective map. Redirecting an alias cannot widen the referring role's fixed base ceiling. Map values may be TierModelsDefault, TierAliasDefault, TierInheritParentDefault, or their literal mappings.

Existing explicit, saved and authenticated concrete-model inputs win first. Then requested role wins over channel/default tier selection. Selection source is, in order: inherited assignment → parent_binding; explicit-user requested role → explicit_user; an overridden assignment anywhere in its alias chain → role_map_source (saved_preference or internal_policy, required for a supplied map); other requested role → internal_policy; channel tier → channel_default; otherwise the existing capability-default source (capability_default for the driver, internal_policy for other slots). Role/map provenance does not extend concrete-choice permission flags or tools. CapabilityBind stays 1.0 with its existing source literals. Inherited role assignments still enforce both the requested role's fixed ceiling and the slot ceiling against the parent's model. Without a snapshot, concrete selections without their own effort use applicable base-policy tier effort, never map effort.

API credit failover and credential enrollment

Schema 2.4 adds optional tier failover lists and each capability's optional failover_model_keys, independent of ordinary fallback. Pre-2.4 artifacts refuse both fields, even when empty. Only paid Anthropic/OpenAI API-key routes are eligible today; subscription routes are never eligible through list membership. API failover is considered only when every key usable from its configuration at load is out_of_credit. The single owner of the failover trigger is KeyPool.credit_exhaustion(*, now=None), which returns a frozen CreditExhaustion (exhausted, out_of_credit, unusable_at_load, blocking). It is true only when at least one key is usable at load and every such key is out of credit now. "Unusable at load" is configuration-derived only (the constructor's unusable_at_load mapping and config checks): those keys are excluded from the proof and reported in unusable_at_load only; they do not block. Runtime stops, including auth_invalid and unusable_config statuses persisted and reread on reload, still block exhaustion. Rate-limited and healthy keys also block. All-keys-cooling waits, budget/ledger stops and bad requests remain typed stops, not credit-failover triggers. A subscription usage limit never triggers API credit failover; subscription account rotation belongs to its provider-account owner. Failover preserves exactly one credential scope: primary credential_principal=user may use only that same user's target-provider handle; primary service may use only the target service/deployment handle. User and service pools are never merged, and failover never crosses between them.

To add a service/deployment paid API credential, append an entry with key and label to ~/.config/hank/credentials/<provider>-key-pool.json (for example, {"key": "<api-key>", "label": "research"}), then force a probe from the checkout:

python3 scripts/check_key_pool.py --provider <provider> --force-probe

The probe also accepts --pool-file for an explicitly selected pool file. The machine pool above is service/deployment scope, never a shared fallback for a user-scoped call. Subscription accounts do not go in these API key pools. Enroll Claude OAuth with agent auth login anthropic [--user <risk_user_id>], or a CAAM-managed ChatGPT account with agent auth login codex --profile <name> --email <addr>. See gateway provider accounts for the owning enrollment and rotation flows. Product hank login is not subscription enrollment.

Adding a provider/model is explicit operator configuration: add its registry entry and rates, declare the vendor in authority/spend/vendors.json, configure the tier's failover list and each receiving capability's failover_model_keys, and populate its API key pool file. These declarations do not install an adapter or expand today's eligible API provider families; a new provider family needs implementation support before failover admission. Never add a subscription route to those failover lists. memory.embed has no failover allowlist or ordinary fallback hops.

Fallback chains and presets (2.3)

A role policy may declare fallback alongside default and allowed_model_keys:

deep:
  default: {models: ["anthropic.claude-opus-5-5"], effort: high}
  allowed_model_keys: ["anthropic.claude-opus-5-5", "codex.gpt-6-1-sol", "anthropic.claude-sonnet-5-5"]
  fallback:
    - {model: "codex.gpt-6-1-sol"}
    - {model: "anthropic.claude-sonnet-5-5"}

Entries are ordered {model: key, effort?: exact} or {alias: role, effort?: exact}. An absent or empty list means no chain; an alias role with no list inherits its base target's chain, while its own list (including []) replaces inheritance. Entry aliases capture the target role's base-policy assignment, filtered by the target and containing role ceilings, never its fallback chain. Each alias is one hop: project_fallback_chain(registry, policy, capability_id, requested_role) chooses its first slot-qualified candidate inside the slot ceiling. The result contains ordered entries (FallbackModel) and omitted entries with typed reason codes; a slot unable to use an entry does not invalidate the artifact.

Admission checks entry keys, lifecycle, alias resolution, role ceilings and exact effort. An omitted entry effort is checked against the containing role's default effort at load but retained as None, meaning the bound effort at hop time. An explicit entry effort is never clamped. Fallback admission refusals retain a typed ModelAuthorityError.code (capability_model_unavailable, capability_model_not_allowed, capability_role_unknown, capability_role_unavailable, capability_effort_invalid, capability_effort_unsupported or capability_selection_invalid).

selection.presets maps preset names to partial role maps. Entries take the assignment shapes above plus optional fallback; ceilings remain base policy. For example, economy: {default: {models: ["anthropic.claude-sonnet-5-5", "anthropic.claude-sonnet-5-5-sdk"], effort: high}}. The admitted policy.presets and its maps are read-only. Unknown roles, alias cycles, unavailable keys, unsupported efforts and widened ceilings fail at load. Use role_map=policy.presets["economy"] with projection or snapshot capture. A preset entry that omits fallback keeps that role's policy chain; a supplied list replaces it. Fallback aliases remain base-policy assignments even when the preset changes their target's primary assignment.

The packaged artifact publishes a kimi_dev preset whose sole primary on deep, standard, fast, and quant is ollama_cloud.deepseek-v4-1-flash@none. Cloud emergency fallback behind DeepSeek is only Gemini (google_antigravity.gemini-3-8-flash) and Muse (muse.muse-spark-1-3); ollama_cloud.kimi-k3 and kimi_code.k3 are not on kimi_dev. Local Ollama rows close the deep/standard/fast chains and stay off while local fallback is false. economy_dev covers deep, standard, fast and quant with google_antigravity.gemini-3-8-flash@high first, then kimi_code.k3, then the Ollama Cloud pair (fast carries DeepSeek only) and the economic models of the other subscriptions. A partial preset that names fast but not judge or verify routes both through fast, so kimi_dev and economy_dev cover them without naming them.

The packaged artifact's base tiers are Set 2, hank_balanced, the built-in product default. default is the interactive driver (session.driver, and vision by alias): anthropic.claude-fable-5-1 at high. build is the build tail (node.implement, node.mutate): Sonnet 5.5 at xhigh on the base policy, Opus 5.5 at xhigh under hank_premium. deep stays Opus 5.5 at high. standard is Sonnet 5.5 (gateway and -sdk) at high on the base policy and Opus 5.5 then Sonnet 5.5 at xhigh under hank_premium. node.verify binds tier verify: Sonnet 5.5 at high on the base policy and under hank_balanced, Opus 5.5 at high under hank_premium. citation.review and node.choose bind judge: Haiku 5.5 at none. investment.research_agent binds standard at high — Sonnet 5.5 at high on balanced, Opus 5.5 at high on premium — the interim route while Gemini 4 Argon is not publicly registered. fast stays Haiku 5.5 at none on the base policy and rises to high under hank_premium. hank_balanced publishes that base map so a run can name Set 2; hank_premium (Set 1) is opt-in through HANK_MODEL_PRESET.

Fallback chains in that revision: deep and build hop Sonnet 5.5 at xhigh, then Codex Sol, then Muse Spark 1.3 at xhigh, then Kimi and the open-weight none rows (Grok 4.7 and Flash are off those build-bearing chains). default leads with Sonnet 5.5 at high, then the same tail; hank_premium's default leads with Opus 5.5 at high. standard promotes google_antigravity.gemini-3-8-flash at high and Muse Spark 1.3 at xhigh ahead of Grok 4.7 at low. The fast chain includes the programmatic openai.gpt-6-luna-sdk hop. judge leads with Sonnet 5.5 at none, then the fast chain without that programmatic hop. verify follows standard's chain without google.gemini-2-5-flash and without Grok 4.7. quant leads with Sonnet 5.5 at xhigh and Opus 5.5 at xhigh, ahead of Flash and Kimi.

See Default preset setting for model-selection precedence, deployment settings, the writer CLI and selection provenance.

Frozen selection snapshots

capture_selection_snapshot(selection_policy, role_map=..., role_map_source=...) returns an immutable SelectionSnapshot containing every capability's CapabilityDefaults (default plus by_channel, each a CapabilityDefault) and every capture-time tier's alias-resolved {models, effort} or {kind: inherit_parent} assignment, plus its resolved fallback_chains. overridden records roles whose effective alias chain used the winning map, even when that map value equals the policy value. source is the winning map's saved_preference or internal_policy literal exactly when overridden is non-empty; otherwise it is null. Independent captures compare by value.

snapshot.to_json() returns this closed, versioned form:

{"version": 1, "policy_revision": "revision", "assignments": {"default": {"models": ["model-key"], "effort": "high"}}, "fallback_chains": {"default": [{"models": ["fallback-key"], "effort": null}]}, "capabilities": {"session.driver": {"default": {"kind": "tier", "tier": "default"}, "by_channel": {}}}, "overridden": ["default"], "source": "saved_preference"}

The example shows one slot; a snapshot holds every capability that existed at capture. Top-level keys have the order shown; assignments, fallback chains, capabilities, channels and overridden names are sorted, while candidate arrays and chain entries preserve order. SelectionSnapshot.from_json round-trips the value; missing/unknown keys, wrong types, unresolved aliases, unknown efforts and empty candidate arrays raise TierProjectionError with capability_selection_invalid. Older snapshot JSON without fallback_chains loads with empty chains for all captured roles. Each frozen chain entry holds the resolved base candidates for one hop and its optional exact effort. project_fallback_chain accepts the same role_map or selection_snapshot inputs; frozen chains use current slot/role ceilings and qualification, not a later policy's chain.

Pass selection_snapshot=snapshot to resolve_capability_model or project_tier instead of role_map (supplying both raises ValueError). Slot defaults, channel defaults, slot-local effort and tier assignments are frozen; a later slot repoint cannot select a newly published tier or concrete model. The referring tier's ceiling, slot allowance, permission flags, capability exposure, lifecycle, entitlement and credentials remain current. A tier absent from the snapshot or removed from current policy is capability_role_unknown; no currently eligible candidate is capability_role_unavailable. A snapshot is validated on its own contents, not against today's capability set, so one journaled before a release that adds or retires a capability still loads and serves its captured slots; a requested slot it did not capture is capability_policy_missing, and a frozen model key the current registry no longer has is capability_model_unavailable. The exact effort rules and source precedence above still apply: only overridden roles use snapshot.source, while the others retain today's selection-source literal. Concrete explicit, saved or run-override selections without effort use the frozen applicable slot default's effort when a snapshot is supplied. Omitting the snapshot (or passing None) leaves resolution unchanged.

Artifacts declaring 2.0 or 2.1 cannot contain tiers or kind: tier; artifacts older than 2.3 cannot contain fallback or selection.presets. Schema 2.3 keeps fallback and presets without memory.embed or failover declarations. The packaged artifact declares model-authority/2.4 (revision 2026-11-03.3); older loaders refuse it by their schema range. Keep the host artifact on 2.3 until every loading venv has hank-model-authority>=1.7.25, then deploy the 2.4 artifact.

Changing it

  • A data change (a model, a default, a price, a compat value) edits authority/ and ships by scripts/deploy_model_authority.sh, not by a release (runbook). Declare the lowest schema minor that covers the fields the artifact uses.
  • A schema change is a release: additive fields, capabilities or literals are a minor (SCHEMA_MINOR), with older artifact requirements preserved; a removal or redefinition is a major. Deploy loaders before data that uses a new minor: a loader refuses an artifact whose minor is newer than its own, naming both.
  • A capability or its executing process is a release (capabilities.py).

Check a candidate directory with the ordinary load:

python -m model_authority check <dir>   # prints the health fact, or exits 1 with the refusal

Tests: .venv/bin/python3 -m pytest packages/model-authority/tests -q (make test-area AREA=model_authority).

Metadata

Release files for hank-model-authority 1.7.27

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hank-model-authority 1.7.27
File Size Uploaded Provenance Actions
hank_model_authority-1.7.27.tar.gz 191.2 kB Without provenance Details for hank_model_authority-1.7.27.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hank-model-authority 1.7.27
File Interpreter ABI Platform Actions
hank_model_authority-1.7.27-py3-none-any.whl Python 3 none any Details for hank_model_authority-1.7.27-py3-none-any.whl

Total release size: 305.8 kB

Release files / hank_model_authority-1.7.27.tar.gz

Download URL hank_model_authority-1.7.27.tar.gz
Size 191.2 kB
Tags Source
SHA-256 checksum
How to use checksums
99b747a6068fc2f864533fad04560fbe227b9aa8c79cd0a82e0dca802b422d9f
BLAKE2b-256 checksum
How to use checksums
c19e124d132c4836d7898b6eac956fa6dc236bb790195785995f25ac34b174bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / hank_model_authority-1.7.27-py3-none-any.whl

Download URL hank_model_authority-1.7.27-py3-none-any.whl
Size 114.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8e9738e0516289fa39f47aee6a2a2186849c14687b2ac92653f0ad42a058363
BLAKE2b-256 checksum
How to use checksums
d8f6f80e49b9a077fc038b4a60cdc41e6e423bfd110fe35a60e472b4da045c40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Security for hank-model-authority 1.7.27

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.7.27 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page