Repository navigation
Move compile-time evaluation to DSPy's TypeSafe adapter without losing budget, identity and consent guarantees #91
Description
Blocked by: #90
Problem and outcome
We maintain our own native TypeSafe adapter (TypeSafeBackend over typesafe-sdk). DSPy 3.4 now ships dspy.experimental.TypeSafe, an upstream Jev client behind the normal lm= interface with request translation, probability-evidence decoding, shared cache, usage tracking, callbacks and async. Keeping a parallel adapter duplicates upstream work and risks drift from the native contract.
The decision is to move compile-time evaluation to DSPy's adapter, while keeping the guarantees this project exists to provide. Upstream's PR #10463 leaves several of those guarantees unaddressed or not described, so the move is a wrapper plus a gap analysis, not a drop-in swap:
| Our guarantee (AGENTS.md / docs) | Upstream status per PR #10463 |
|---|---|
| Pinned versioned model; fail on returned-model mismatch | Not described; client accepts aliases such as jev-latest |
| Budget counted before dispatch; SDK retries disabled | Not addressed ("follow-up work") |
| Explicit paid consent; no silent retry or downgrade | Not addressed |
| Sensitive-output cache off by default | Cache on by default |
| Unknown cost reported as null | Not described |
| Attempt receipts for hierarchy evidence and resume | Not applicable upstream |
Also from that PR: nested decision outputs warn, generative optimizers are unsupported with the TypeSafe client (so teacher traffic must stay on a generative LM, as today), and the API is explicitly experimental and may change without warning.
Decision required, not assumed: AGENTS.md and the README state that the frozen runtime must not import DSPy. Either the runtime keeps a direct SDK backend (two paths, tested equivalent) or that invariant is changed deliberately with a documented rationale. Do not weaken it silently.
Implementation tasks
- Complete Verify compatibility with DSPy 3.4 and decide the supported version range #90 first and pin the verified DSPy version.
- Write the gap analysis above against the actual 3.4.x code, replacing "not described" with what the code does.
- Prototype a backend implementing our existing backend protocol on top of
dspy.experimental.TypeSafe, still enforcing: versioned model pin and returned-model equality,ManagedBackendbudget before dispatch, no automatic retries,allow_paidconsent, our cache policy, and null-cost reporting. - Offline equivalence tests with labeled test doubles: for the same projected state and questions, the native request and the normalized
Responsematch the current adapter. Check that DSPy's decision-type mapping does not alter our question dictionaries (instructions, criteria, Score levels). - Hierarchy: confirm per-leaf requests, attempt reservation and settlement, the evidence ledger, resume and replay behave identically.
- Decide the runtime boundary (see above) and record the decision in
AGENTS.md,README.mdanddocs/ARCHITECTURE.md. - Remove or deprecate the old adapter only after equivalence passes and the decision is recorded. Update
docs/INTEGRATIONS.md(TypeSafe contract) anddocs/SECURITY.md.
Acceptance criteria
- All existing tests pass; budget, identity and consent behavior is preserved, or changed explicitly with updated docs and tests.
- No live calls without explicit consent; offline tests are labeled as test doubles, not Jev results.
- The experimental status and the pinned upstream version are documented.
Source anchors
- DSPy PR #10463: decision types and System One clients
- DSPy Jev decision tutorial
src/typewright/backends.py,src/typewright/runtime.py,src/typewright/hierarchy_runtime.py,src/typewright/hierarchy_evidence.py,docs/INTEGRATIONS.md,AGENTS.md. Paths use thetypewrightlayout from PR Rename the project to Typewright #89.
Activity
Position Typewright against DSPy 3.4 in the README and roadmap
Rename the project to Typewright (#89)
CompleteDotTech commentedon Oct 3, 2026
Owner decision in the current orchestration session, 2026-10-03: approve a compile-time DSPy TypeSafe adapter while keeping frozen programs on the direct SDK backend. Preserve the no-DSPy/no-GEPA runtime invariant. Adapter equivalence must prove exact native question/response semantics, identity, paid consent, pre-dispatch budget accounting, zero retries, cache/history policy, unknown cost, hierarchy reservations and settlement/replay/resume. Current upstream TypeSafe defaults and dropped metadata are gaps to wrap and verify, not equivalence evidence. This authorizes scoped offline implementation/installed-package doubles; no paid dispatch, teacher upload, runtime activation or gain claim is authorized. #90 is already merged; its historical blocked-by wording is not an active implementation dependency.
CompleteDotTech commentedon Oct 3, 2026
Delivered in PR #103, merge
821b29d627b602b0b042b474fd5a2248febd5c74, fromde7c82dd3fe5ba3b81ceceb49cab07db206c4bae. All 10 exact-head checks and all five actual merge checks passed (merge run). Independent source/wiring/dependency review passed.Local full verification: 685 passed on DSPy 3.4.0; 667 passed and 18 explicit native-version skips on DSPy 3.3.1. Ruff, build and fresh installed-wheel checks passed: 51 source members, all four entrypoints, no-key demos and synthetic study journey. Package/runtime/adapter-module import isolation and frozen direct-SDK routing passed. Runtime remains DSPy/GEPA-free; obsolete or modified live manifests are refused before construction.
No paid inference, private sharing, provider qualification or production activation occurred. Exact native profile is required for compile; the existing teacher compatibility range remains supported. Local main matches the merged public commit, with original user edits and prior packet evidence preserved.