CareerVector LLM tensor routing

CareerVector applies Sporewright independently of JobCache. Both systems use the same generic addressed-field mathematics, but they have different addresses, observations, persistence, orchestration, and privacy boundaries. The JobCache fleet feeds the shared ad corpus in CrateDB. This system chooses private LLM provider/model calls inside CareerVector and persists only to CareerVector D1.

The platform operator is the root-policy and shared-resource authority: it owns Included AI keys, provider quotas, global quality/privacy floors, and the zero-platform-spend rule. It is deliberately not an address layer or a provider option. Local WebLLM, a trusted workspace peer, a BYOK connector, and the operator-hosted Included AI broker are executors; provider/model pairs are their routable options. See INGESTION-AND-CONSUMER-AI for the complete control-plane diagram and the corresponding JobCache installation.

CareerVector browser / API / server fallback
              |
              v
     semantic LLM route + BYOK keys
              |
              v
      provider attempt / fallback
              |
              v
   receipt-bound normalized outcome
              |
              v
 CareerVector D1 tensor projector + budget

No prompt, output, CV, profile, key, or workspace identity crosses into CrateDB.

Address

The implicit Sporewright root is followed by:

workspace -> capability -> stage -> consumer -> optional instance

system=careervector is constant identity, not a branch. environment is absent because a browser-local BYOK call and the same server fallback have no CORS-style model capability difference. Each workspace serves one person. Instances are only stable recurring configured objects such as a score column or document section.

Capability Stage Consumer Instance
structured-generation extract job-ad-extraction
structured-generation enrich salary-estimation
structured-generation evaluate column-evaluation one column ID for focused calls
structured-generation tailor section-generation cv:section / cl:section
structured-generation tailor section-condensation cv:section / cl:section
structured-generation tailor section-repair cv:section / cl:section
structured-generation tailor document-refinement cv / cl
structured-generation tailor document-critique cv / cl

CloudKeys.chains remains the editable declared-policy store. Its old stage, consumer, and instance keys are policy selectors. resolveLlmRoute projects one or several selectors onto the semantic address, so migration does not discard workspace configuration and a batched evaluation can let several column policies vote additively without losing its routing receipt.

Learning cycle

The root declares weights over route, failure, quality-loss, latency-cost, and token-use. Route rank is top-down policy. The other values are learned belief. Every executed attempt emits sporewright.llm-outcome/v1 with the exact decision revision and address. Skipped attempts are not evidence. A successful parse only updates quality-loss when the product supplied a measurement; unknown quality is not silently recorded as perfect quality.

Today extraction and evaluation can provide bounded structural-completeness measurements. Salary estimation deliberately does not: the model's own confidence is not independent evidence of correctness. Salary routing learns failure, latency, and token use until a market comparison or human correction can provide an honest quality observation.

The D1 host:

  1. bounds and validates the envelope and receipt, canonicalizes it to the numeric routing allowlist (stripping caller-added content), and deduplicates event_id;
  2. projects at most 128 queued events under a short per-workspace lease, aging delayed/offline observations from their occurrence time;
  3. advances an immutable monotonic workspace revision;
  4. writes learned-only workspace-to-root Gaussian messages;
  5. aggregates current visible revisions into 64 bounded SQL buckets every five minutes, first sweeping a bounded set of projection tails left by expired locks, interrupted Workers, or oversized batches; least-recently-projected workspaces go first and one corrupt workspace cannot abort root/budget upkeep;
  6. subtracts the requesting workspace's included message before composing root learning with its current local branch.

Policy is never shared as evidence. One workspace's precision per option/dimension is capped before root aggregation, preventing volume alone from dominating shared learning. The hot decision reads sufficient statistics, not event history.

Drift

Learned precision has a 14-day exponential half-life. Local snapshots use the exact factor. Inactive workspace messages are discounted inside the SQL root projection, and root state is discounted again from its projection time when read. Means remain stable while uncertainty reopens, allowing curiosity to detect a provider/model regime change. Declared policy does not age.

Curiosity and hard budgets

Temperature 0 is deterministic exploitation. Positive temperature admits uncertain options into the ordering. It still cannot spend money by itself.

The workspace separately configures a monthly BYOK exploration budget. Each added probe must atomically reserve a conservative 100,000-token unit against active reservation rows, at most two probes may accompany the primary call, and the account cannot exceed its hard cap. The account counter is a repairable cache, not the admission authority. Selected usage settles the reservation at measured cost, including an overrun beyond the estimate; unknown/failure usage is charged conservatively. Expired reservations are reconciled by the same five-minute scheduled job.

The router exposes an abstract budget controller so future platform-funded calls can use price-versioned currency micro-units without pretending tokens and money are the same unit.

Code map

  • sporewright/packages/router/ — generic semantic resolver, execution, receipts, learning normalization, and budget-controller seam.
  • lib/domain/src/llm-routes.ts — CareerVector route catalogue.
  • lib/domain/src/ai.ts — browser feedback and budget adapter.
  • lib/server/src/llm-tensor.ts — D1 validation, projection, aging, root rollup, and budget authority.
  • migrations/add-llm-tensor-learning.sql — private storage schema.
  • ui/src/lib/components/toolbar/modals/ai/KeysTab.svelte — workspace curiosity and monthly BYOK budget controls.
Source: wiki/content/architecture/LLM-TENSOR-ROUTING.md