TypeSafe/Jev HTTP Adapter & Wire Primitives Validation #19
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implement the direct Rust HTTP client adapter for TypeSafe/Jev (
POST https://api.typesafe.ai/v1/systemone) usingreqwestandrustls. Strictly enforce the pinned model versionjev-1.13.0, validate wire primitives (choice,score,noul) against exact mathematical and structural constraints, reject malformed payloads asjudgment_invalid, and handle provider transport and rate-limit errors gracefully asjudgment_unavailable.Background & Technical Rationale
The Life service delegates advisory semantic evaluation (such as candidate reference matching, priority alignment, consequence scoring, and context retention triage) to TypeSafe/Jev System One. Jev operates as an external, typed probabilistic reasoning engine. To maintain security, determinism, and system integrity, the integration adheres to rigorous architectural invariants:
jev-1.13.0.jev-latestis strictly rejected. If the upstream provider returns an unpinned model string, substitutes a model, or deprecates the version, the response must be rejected asjudgment_invalid, and semantic judgments disabled visibly. No silent model substitution is permitted under any circumstances.choice,score, andnoul.type: "choice",choice: String,probabilities: HashMap<String, f64>, andconfidence: f64. Probabilities must be valid finite floats summing to1.0within a tolerance of\pm 10^{-6}. The selectedchoicemust correspond to the option with the highest probability (or within\pm 10^{-6}of the maximum). The provider limit is 255 options; Life caps candidate lists at at most 20 deterministic items plus a fixedno_matchoption.type: "score", a probability-weighted numericscore(a floating-point index, not necessarily an integer),legend: Vec<String>,probabilities: Vec<f64>, andconfidence: f64. Probabilities must sum to1.0 \pm 10^{-6}. The reportedscoremust match the probability-weighted level index\sum_{i=0}^{n-1} (i \times p_i)within a tolerance of\pm 10^{-6}.noul(a continuous probability of "yes" in[0.0, 1.0]). Output containstype: "noul"and numericnoul: f64. NouL answers strictly contain NOconfidencefield; any presence of aconfidencefield or a boolean representation must be rejected as malformed.Retry-Afterheaders within the request deadline (default 10s). If retries exhaust or fail, the adapter maps the error to structuredjudgment_unavailablewarnings, allowing deterministic core functions to proceed uninterrupted.judgment_invalid.statemust be redacted from diagnostic logs; raw payloads must never be written to telemetry.Exact Technical References & Specifications
Normative Wire Primitives Table
From
docs/technical/jev.md(lines 9–14):Normative Model & Validation Rules
From
docs/technical/jev.md(lines 7, 15–18):Complete Fictional Wire Example
From
docs/technical/jev.md(lines 45–55):Request:
Illustrative Response:
Verification Scenarios
From
docs/technical/verification.md:judgment_invalid; clarification/unavailability, no calendar mutation.judgment_unavailable, no moving-alias fallback; deterministic commands still work.Configuration Contract
From
docs/technical/operations-security.md(lines 22, 33):[jev]enabled(boolean),base_url,bearer_token_file,model = "jev-1.13.0".request_timeout_seconds = 10.What to Build
1.
src/jev/primitives.rsChoiceAnswer: checkschoiceis a key in question'scriteria,probabilitieskeys match criteria keys,\sum p_k \approx 1.0 \pm 10^{-6}, andp_{\text{choice}} \ge \max(p) - 10^{-6}.ScoreAnswer: checkslegendmatches questioncriteria,probabilities.len() == legend.len(),\sum p_i \approx 1.0 \pm 10^{-6}(abs(sum(p_i) - 1.0) <= 1e-6), and\text{score} \approx \sum_{i=0}^{n-1} (i \times p_i) \pm 10^{-6}.NouLAnswer: checks0.0 \le \text{noul} \le 1.0. Use#[serde(deny_unknown_fields)]to reject any payload containingconfidenceor unexpected fields.2.
src/jev/client.rsJevClientwrappingreqwest::Clientconfigured withrustls-tls:bearer_token_fileat initialization.pub async fn execute(&self, state: Value, questions: HashMap<String, JevQuestion>) -> Result<HashMap<String, JevAnswer>, JevError>.Authorization: Bearer <token>.model: "jev-1.13.0".{base_url}/v1/systemone.Retry-Afterheader, backs off withinrequest_timeout_seconds, never switches models.jev-1.13.0.JevError::Unavailable("judgment_unavailable").JevError::Invalid("judgment_invalid").3. Unit and Fixture Tests (
tests/jev_fixtures.rs)choice,score, andnoul.jev-latestorjev-1.12.0\rightarrowreturnsjudgment_invalid.0.98\rightarrowreturnsjudgment_invalid.\rightarrowreturnsjudgment_invalid.\rightarrowreturnsjudgment_invalid."confidence": 0.85\rightarrowdeserialization rejected asjudgment_invalid.\rightarrowreturnsjudgment_unavailable.Acceptance Criteria
choice,score, andnoulwire fixtures (Scenario I08).jev-1.13.0; any other model string (includingjev-latest) is rejected asjudgment_invalid(Scenario I06).choiceprobabilities sum to1.0 \pm 10^{-6}and selected choice matches highest probability.scorereported matches the weighted mean of probabilities against the criteria index within\pm 10^{-6}tolerance.noulcontains noconfidencefield and returns a float in[0.0, 1.0].judgment_unavailablewithout service panic (Scenario I07).Notes
Cargo.tomlauthors chore stays pending.Blocked by
Issue #019: TypeSafe/Jev HTTP Adapter & Wire Primitives Validationto TypeSafe/Jev HTTP Adapter & Wire Primitives Validation