Skip to content

feat(typesafe): bundle TypeSafe AI decision models - #152298

Merged
steipete merged 24 commits into
mainfrom
openclaw/jev-bundled-typesafe
Sep 19, 2026
Merged

steipete merged 24 commits into
mainfrom
openclaw/jev-bundled-typesafe

Conversation

@jalehman

@jalehman jalehman commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Related: #152234

What Problem This Solves

Makes TypeSafe AI’s Jev models available as an official bundled plugin for fast typed choices, scores, and boolean probabilities.

User Impact

Select typesafe/jev-latest or typesafe/jev-1.13.0 through the global or per-agent decisionModel setting and configure the plugin’s API-key SecretRef. The role stays disabled until selected. Evaluations send the consumer’s supplied state to TypeSafe and use its normal API billing. The optional typesafe_evaluate tool remains available with its own default model.

Why This Change Was Made

Builds on Josh Lehman’s bundled adapter while adopting the generic decisions contract from #152237. Vendor translation, validation, credentials, and transport stay in extensions/typesafe; Jev appears in the separate decision-model catalog. Native evaluations always use the host-selected model.

The adapter uses OpenClaw’s guarded HTTP helpers against the documented fixed HTTPS endpoint, with bounded input/output, a deadline covering the whole request, cancellation and release that both settle, and sanitized errors. No new vendor SDK dependency, redirects, automatic retries, or dependency cooldown exception is needed. Provider-reported probabilities and scores remain intact after structural and range validation.

Thanks @jalehman for the adapter, expressive schemas, optional tool, lifecycle integration, and follow-up validation work. The SecretRef prerequisite #152236 and decisionModel foundation #152237 are merged. This PR targets main. Separate Workshop and memory consumers are outside this change.

Evidence

All 107 TypeSafe tests and 49 package-manifest tests passed, alongside production/test typechecks, type-aware lint, a full integrated build, generated metadata checks, and docs validation. Independent P0–P2 review is clean. Five captured-response cancellation/release regressions fail before the fix and pass afterward.

Live proof used the actual built isolated Gateway, normal bundled loading, a prepared SecretRef, a separate consumer plugin, and the public Gateway client. Inherited and per-agent pinned selections both returned valid Choice, Score, and Boolean results (373 ms and 189 ms); a disabled agent made no provider call. Inspection recorded two successes and zero active requests, and Jev appeared only in the decision-model catalog. Shutdown completed cleanly in 42 ms. These two synthetic batches verify the live contract, not general model quality or a latency benchmark.

The fixed input/result schemas are compiled once per module. Two A/B runs through the registered adapter measured 57–79% lower local overhead across four synthetic workloads; the largest median fell from 8.80 to 2.20 ms. All validation bounds and correspondence checks remain intact. A 1,024-request synthetic transport stress run at up to 64 concurrent operations completed all releases and body cancellations, covered 16 credential loss/recovery cycles, and left zero active requests. No vendor traffic was used for this load test. The incremental performance change passed independent P0–P2 review and all 107 adapter tests.

After integrating the landed foundation, all 107 TypeSafe tests and a fresh independent P0–P2 review passed. The adapter runtime and tests remain byte-for-byte identical to the stress-tested candidate. Exact-head hosted CI and native landing gates remain required before merge. The foundation’s approved SDK surface increment is applied and its guard passes.

Current-main CI exposed an existing transcript auto-start fixture race: its status polling deadline started before SQLite admission reached the provider. An unchanged-file reproduction and paired delayed-admission probe established the cause. The six-line fixture repair waits for provider readiness without changing production code, assertions, or polling deadlines. All 83 lifecycle/occupancy tests, the final nine-test file, typecheck, lint, and independent P0–P2 review pass.

Maintainer compatibility assessment: the audited prototype's authored configuration schema is unchanged, including the apiKey SecretRef, model, timeoutMs, defaults, and bounds. Plugin ID, activation, secret-input declarations, optional tool contract, and skill declaration are preserved. The existing built-Gateway proof exercises that authored SecretRef through normal preparation and the registered adapter. The new native decision role remains opt-in. extensions/typesafe/src/schema.ts validates transient API requests and responses; it creates no stored data, database schema, or migration requirement.

Source selection follows the existing duplicate-ID precedence contract: explicit plugins.load.paths overrides keep precedence, tracked global installs override ordinary bundles, and source-checkout bundles precede tracked globals. All 118 canonical manifest-registry tests pass, including those source-selection cases. To retain an external implementation, keep its explicit path. To adopt the bundled implementation, preserve the authored entry and its SecretRef, change the selected source, refresh secrets/reload, and verify the selected plugin and an evaluation. No plugin files or credentials are deleted by this PR.

If removing an external package with the plugin management flow, save and reapply the entry and re-enable the bundled plugin afterward: --keep-files preserves files but does not preserve the configuration or policy entry. The supported transition preserves the audited authored contract; no compatibility shim or storage migration is needed. This resolves the review's prototype-transition question and its heuristic stored-schema flag.

@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XL maintainer Maintainer-authored PR labels Sep 19, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 19, 2026
@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 19, 2026, 6:36 PM ET / 22:36 UTC (Revision 10).

ClawSweeper review

What this changes

Adds an opt-in TypeSafe AI plugin for typed decisions and an optional evaluation tool, with documentation, credential handling, validation, and focused test-fixture repairs.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains useful, maintainer-sponsored work absent from current main. No blocking defect was found; the updated compatibility assessment resolves the previous review’s prototype-transition concern.

Priority: P2
Reviewed head: 871cf0796b5685de527e54dfcc667cfa7dae7fd1

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong production-path evidence, bounded plugin ownership, and the resolved compatibility assessment support a clean review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured live Gateway observations exercise normal bundled registration, prepared credentials, and the registered adapter through a separate consumer and public client: inherited and pinned selections return all three answer types, disabled selection makes no call, and requests settle before clean shutdown. Synthetic stress tests and foundation screenshots are supplemental.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured live Gateway observations exercise normal bundled registration, prepared credentials, and the registered adapter through a separate consumer and public client: inherited and pinned selections return all three answer types, disabled selection makes no call, and requests settle before clean shutdown. Synthetic stress tests and foundation screenshots are supplemental.
Evidence reviewed 7 items Introduced scope and continued necessity: The pinned merge-base delta adds the adapter and two test-fixture repairs; it does not introduce the already-landed decision runtime. Searches of fetched main found no TypeSafe/Jev implementation under extensions or plugin docs, and the supplied latest release has no extensions/typesafe tree. The stale test-merge ref was not used to infer removals.
Prototype configuration preserved: Read the original proposal’s configuration and manifest through GitHub after historical blob retrieval failed locally. Its authored SecretRef shape, model default, timeout default and bounds match the reviewed head. The captured PR body explicitly records the supported transition and explains preserving/reapplying configuration when uninstalling an external copy.
Existing source-selection and uninstall contracts: The registry preserves explicit path overrides, then prioritizes source-checkout bundles, tracked global installs, ordinary bundles, workspace copies, and untracked globals. The existing management documentation confirms that --keep-files does not retain plugin configuration. These contracts match the updated compatibility assessment and do not require a new migration or compatibility reader.
Findings None None.
Security None None.

How this fits together

OpenClaw’s decision runtime sends explicitly selected evidence and questions to a configured provider. The TypeSafe adapter translates those requests into Jev evaluations and returns validated choices, scores, and Boolean probabilities to consumers.

flowchart LR
  A[Agent decision selection] --> C[Decision runtime]
  B[Consumer evidence and questions] --> C
  C --> D[TypeSafe adapter]
  E[Prepared credential] --> D
  D --> F[Guarded TypeSafe request]
  F --> G[Validated typed answers]
  G --> C
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +935, Tests +1303, Docs +214, Config +24, Generated 0, Other +10. Total +2486 across 37 files.

View PR surface stats
Area Files Added Removed Net
Source 11 935 0 +935
Tests 11 1308 5 +1303
Docs 10 217 3 +214
Config 2 24 0 +24
Generated 2 3 3 0
Other 1 10 0 +10
Total 37 2497 11 +2486

Review metrics

Metric Value Why it matters
TypeScript growth by responsibility Production +719 lines; tests and test support +1303 net lines Production growth implements vendor translation, bounded validation, and shared transport inside one plugin without expanding the core SDK.
Opt-in configuration 3 plugin settings; 2 decision-model catalog entries Credential, tool-model, and timeout settings remain separate from native agent selection, with the plugin disabled by default.

Stored data model

Persistent data-model change detected: unknown-data-model-change: extensions/typesafe/src/schema.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep vendor translation in this opt-in plugin, reuse host-owned lifecycle and credentials, and retain the documented external-install transition.

Do we have a high-confidence way to reproduce the issue?

Not applicable to the primary feature request; the supplied Gateway observations exercise the new adapter, and no introduced failure was established.

Is this the best way to solve the issue?

Yes. The adapter consumes the merged generic decision contract and shares transport between native evaluations and the optional tool; the configuration comparison supports the stated prototype transition.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c5ad7506abae.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster. Replaced prior rating: 🐚 platinum hermit.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This is a bounded, opt-in provider integration with concrete maintainer sponsorship and live contract evidence.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster. Replaced prior rating: 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured live Gateway observations exercise normal bundled registration, prepared credentials, and the registered adapter through a separate consumer and public client: inherited and pinned selections return all three answer types, disabled selection makes no call, and requests settle before clean shutdown. Synthetic stress tests and foundation screenshots are supplemental.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured live Gateway observations exercise normal bundled registration, prepared credentials, and the registered adapter through a separate consumer and public client: inherited and pinned selections return all three answer types, disabled selection makes no call, and requests settle before clean shutdown. Synthetic stress tests and foundation screenshots are supplemental.

Evidence

What I checked:

  • Introduced scope and continued necessity: The pinned merge-base delta adds the adapter and two test-fixture repairs; it does not introduce the already-landed decision runtime. Searches of fetched main found no TypeSafe/Jev implementation under extensions or plugin docs, and the supplied latest release has no extensions/typesafe tree. The stale test-merge ref was not used to infer removals. (extensions/typesafe/index.ts:8, c5ad7506abae)
  • Prototype configuration preserved: Read the original proposal’s configuration and manifest through GitHub after historical blob retrieval failed locally. Its authored SecretRef shape, model default, timeout default and bounds match the reviewed head. The captured PR body explicitly records the supported transition and explains preserving/reapplying configuration when uninstalling an external copy. (extensions/typesafe/src/config.ts:4, e5f354d4fb1b)
  • Existing source-selection and uninstall contracts: The registry preserves explicit path overrides, then prioritizes source-checkout bundles, tracked global installs, ordinary bundles, workspace copies, and untracked globals. The existing management documentation confirms that --keep-files does not retain plugin configuration. These contracts match the updated compatibility assessment and do not require a new migration or compatibility reader. (src/plugins/manifest-registry.ts:182, 871cf0796b56)
  • Production boundary and security controls: The adapter reads host-prepared credentials per invocation, uses the host-selected native model, rejects unsupported rubrics locally, and shares one transport with the optional tool. Transport fixes the HTTPS destination, rejects redirects, checks cancellation immediately before dispatch, bounds bodies, joins release, and sanitizes errors. The package adds no vendor SDK or lifecycle script; the lockfile adds only its workspace importer. (extensions/typesafe/src/transport.ts:95, 871cf0796b56)
  • Supplied real Gateway observations: The complete captured body, sourceRevision 54fecbc01161a6a7036f82c4b44e20b1127c457ef2da636280585aec4f15fa8a, reports normal bundled loading in an isolated built Gateway, a prepared SecretRef, a separate consumer plugin, and public Gateway-client calls. Inherited and pinned selections returned all three answer types; a disabled agent made no provider call; inspection showed two successes and zero active requests; shutdown completed in 42 ms. The reported 1,024-request synthetic stress run is supplemental. Inspected downloaded screenshots show the merged foundation’s picker, not transport proof. (871cf0796b56)
  • Merged foundation and routing history: GitHub verifies feat(plugins): add decision models with per-agent selection #152237 merged as cde6bbd. Current-main history and blame connect the host admission implementation to that commit; its raw parent was inspected and the provider-host path is absent there. GitHub also identifies steipete as the current assignee. The foundation supplies the generic contract rather than superseding this vendor adapter. (src/decisions/provider-host.ts:220, cde6bbdcfe84)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-19T15:56:27.540Z sha 0229e6d :: blocked before merge. :: none
  • reviewed 2026-09-19T16:31:02.442Z sha 0229e6d :: needs real behavior proof before merge. :: [P2] Validate live instance authority before returning prepared credentials | [P2] Settle provider work independently of instance disposal
  • reviewed 2026-09-19T17:24:58.344Z sha 9d3181c :: blocked before merge. :: none
  • reviewed 2026-09-19T19:39:08.344Z sha 82d7ecf :: blocked before merge. :: none
  • reviewed 2026-09-19T20:23:43.285Z sha 3d20fb3 :: blocked before merge. :: none
  • reviewed 2026-09-19T20:47:05.102Z sha 8db84cf :: blocked before merge. :: none
  • reviewed 2026-09-19T21:53:17.451Z sha 0d3b945 :: blocked before merge. :: none
  • reviewed 2026-09-19T22:08:13.772Z sha 871cf07 :: blocked before merge. :: none

@steipete steipete self-assigned this Sep 19, 2026
@socket-security

socket-security Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 19, 2026
Add an opt-in decisionModel role for typed choices, scores, and boolean
probabilities, with global defaults and per-agent inheritance or disablement.
Keep provider lifecycle and prepared credentials host-owned, and expose
manifest-only decision choices separately from conversational model catalogs.

Adapt the provider foundation from #152237 to the decisions contract. Existing
configurations keep decision calls disabled until a model is selected.

Co-authored-by: Josh Lehman <[email protected]>
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 19, 2026
@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Security-sensitive guard cleared

Current revision: 871cf0796b5685de527e54dfcc667cfa7dae7fd1

This PR no longer changes files in the maintainer security-review tier.

Separate CODEOWNERS requirements still apply to security policy and enforcement files.

Preserve the reviewed adapter and contributor ancestry while targeting main. Keep TypeSafe documentation additions and regenerate config metadata after resolving the stack integration.

Validation: all 107 TypeSafe tests, glossary check, generated metadata, and clean managed P0-P2 review. Adapter production and test files are identical to the stress-tested candidate.

Co-authored-by: Josh Lehman <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot removed app: web-ui App: web-ui scripts Repository scripts agents Agent runtime and tooling plugin: file-transfer labels Sep 19, 2026
The auto-stop fixture polled active status before SQLite-backed admission reached the provider. Wait for each existing start fixture with the test abort signal, then release its gate and keep the original assertions and polling deadlines.

The unchanged file and a controlled admission delay reproduced the failure; the synchronized version passes the same delayed proof. Validation: 83 sibling tests, final 9-test file, owning typecheck, lint, formatting, and clean managed P0-P2 review.
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Sep 19, 2026
@steipete
steipete merged commit fbb6624 into main Sep 19, 2026
225 checks passed
@steipete
steipete deleted the openclaw/jev-bundled-typesafe branch September 19, 2026 22:43
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 20, 2026
Bundle TypeSafe AI's Jev models as an opt-in decisionModel provider, with global and per-agent selection and the optional typesafe_evaluate tool. Keep vendor translation, fixed-endpoint transport, validation, and prepared credential consumption inside the plugin while reusing the host's decision and lifecycle contracts.

Compile fixed schemas once, reducing paired local adapter overhead by 57–79%. Preserve provider-reported probabilities, authored SecretRefs, and the existing tool configuration. A transcript CI fixture now awaits provider readiness before its unchanged status assertions.

Validation includes 107 adapter tests, 1,024 synthetic concurrent transport operations with complete cleanup, live evaluations through a built isolated Gateway, 118 source-selection tests, and clean independent P0–P2 reviews. Exact-head CI and its required gate passed on 871cf07.

Thanks @jalehman for the adapter, expressive schemas, optional tool, and lifecycle validation work.

Co-authored-by: Josh Lehman <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling dependencies-changed PR changes dependency-related files docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants