feat(learn): metered embeddings and the cache (decision-engine 6.2)

plane/models/openrouter-embedding.yaml: openai/text-embedding-3-small via
OpenRouter (embeddings only), input_per_m 0.02, cache/output 0, egress
openrouter.ai; `openrouter` joins the provider extensions.

plane/budget.py MeteredEmbeddingClient: prompt_tokens priced from the
Model manifest, usd/calls ceilings stop the next call, a priced call that
reports no tokens raises UnmeteredUsage (a silent zero is an instrument
failure). OpenRouterEmbeddingClient keeps one usage row per call
(parse_embedding_payload); its api key is out of repr.

learn/embeddings.py + `ousast learn memory embed`: excerpts embedded in
batches into embeddings/<model-slug>/<excerpt_sha>.json (float32 base64),
cached by content hash so a rerun makes no call; the declared dimension is
checked; --dry-run estimates tokens and cost without a call; a paid run
needs --budget-usd and exits 3 (unfinished) at its ceiling. Not run against
the provider: the store embedding waits for its budget go-ahead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EmM1j46qgKMh3zqD1QMwEo
This commit is contained in:
Marius Ciepluch
2026-10-01 09:56:52 +02:00
co-authored by Claude Opus 5.5
parent 7b81c9ac4e
commit 98fa4ec8cd
11 changed files with 498 additions and 11 deletions
@@ -1,7 +1,7 @@
{
"modules": 146,
"modules": 147,
"counts": {
"load_bearing": 139,
"load_bearing": 140,
"standalone_capability": 7
},
"orphaned": [],
@@ -353,6 +353,7 @@
"importers": [
"cli",
"learn.cli",
"learn.embeddings",
"learn.examples",
"learn.excerpt",
"learn.features",
@@ -370,6 +371,14 @@
"cli"
]
},
{
"module": "learn.embeddings",
"classification": "load_bearing",
"reason": "reachable from gate, map_gate, pair_gate or the CLI",
"importers": [
"learn.cli"
]
},
{
"module": "learn.examples",
"classification": "load_bearing",
@@ -383,6 +392,7 @@
"classification": "load_bearing",
"reason": "reachable from gate, map_gate, pair_gate or the CLI",
"importers": [
"learn.embeddings",
"learn.examples"
]
},
@@ -752,6 +762,7 @@
"cli",
"improve.memory",
"learn.cli",
"learn.embeddings",
"learn.examples",
"plane.egress",
"plane.engine_alerts",
@@ -772,6 +783,8 @@
"classification": "load_bearing",
"reason": "ai-service-plane Req 2.3/2.4: metered chat client with usd and calls ceilings; task integration in tasks 3, 6",
"importers": [
"learn.cli",
"learn.embeddings",
"plane.generate",
"plane.tasks.roles",
"plane.tasks.verify"
@@ -812,6 +825,7 @@
"classification": "load_bearing",
"reason": "ai-service-plane Req 1.1-1.4: ax-shaped Task/Workspace/Model and the Run kind, validated before anything runs",
"importers": [
"learn.cli",
"plane.egress",
"plane.generate",
"plane.reconciler",
@@ -827,6 +841,7 @@
"importers": [
"improve.memory",
"learn.cli",
"learn.embeddings",
"learn.examples",
"plane.generate",
"plane.tasks.loop",
@@ -1036,6 +1051,7 @@
"classification": "load_bearing",
"reason": "reachable from gate, map_gate, pair_gate or the CLI",
"importers": [
"learn.cli",
"model.endpoint",
"tool_hunter"
]
@@ -1045,6 +1061,7 @@
"classification": "load_bearing",
"reason": "reachable from gate, map_gate, pair_gate or the CLI",
"importers": [
"learn.cli",
"model.endpoint",
"tool_hunter"
]