Skip to content

fix(tools/typed-decision): send documented requests to the Jev API - #2023

Merged
potiuk merged 2 commits into
apache:mainfrom
shahar1:fix/typed-decision-jev-model
Nov 9, 2026
Merged

potiuk merged 2 commits into
apache:mainfrom
shahar1:fix/typed-decision-jev-model

Conversation

@shahar1

@shahar1 shahar1 commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • JevProvider could never get an answer from the Jev API. Every choice, score and noul call returned HTTP 400, because it sent operation, prompt, options and scale to POST /v1/systemone, which requires model, state and questions. It also read label, value and probability from the top level of the response, while the API returns them under answers.
  • The pinned model systemone-2026-06-01 is not a model the API documents. It is now jev-1.14.0.
  • The failure stayed hidden on both sides. The tests mocked responses in the same invented shape, and the contract is fail-open, so the pr-triage shadow pre-filter would only have logged fell_through.

The public choice, score and noul contract does not change.

Type of change

  • Skill change (.claude/skills/<name>/) — eval fixtures updated below
  • Tool / bridge contract (tools/<system>/*.md)
  • Python package (tools/*/ with pyproject.toml)
  • Groovy reference impl
  • Cross-cutting (RFC, AGENTS.md, sandbox, privacy-LLM)
  • Documentation (docs/, README.md, CONTRIBUTING.md)
  • Project template (projects/_template/)
  • CI / dev loop (prek, workflows, validators)
  • Other:

Test plan

  • prek run --all-files passes, through the pre-commit hook on this commit
  • For Python packages touched: uv run pytest / ruff check / mypy passes for tools/typed-decision, and test_typed_decision_prefilter.py passes
  • For Groovy bridges touched: command-line invocation tested end-to-end
  • For skill changes: eval suite passes for the affected skill
  • For skill behaviour changes: a new or updated eval fixture is included in this PR
  • Other: live calls against api.typesafe.ai, using made-up text only

The mocks now follow the published OpenAPI schema, so I also ran the provider against the real API. enforce_privacy_gate was patched out in a throwaway script for these calls, because I have no approved privacy-llm.md entry. With the real gate left in place, the same call was still denied with no request sent.

Call main This PR
choice on a crash report, options bug/feature/question HTTP 400 bug, confidence 1.0
noul "Is the sky usually blue on a clear day?" HTTP 400 0.95
noul "Is the sun made of cheese?" HTTP 400 0.02
score full production outage, scale (1, 5) HTTP 400 4.71, confidence 0.74
score typo in a comment, scale 10 HTTP 400 0.81, confidence 0.67

typed_decision_prefilter.py also ran end to end on a synthetic PR, enabled through MAGPIE_ENABLE_TYPED_DECISION_PREFILTER, with the gate patched the same way. It logged outcome: high_confidence, predicted_label: passing, confidence: 0.98.

The updated tests fail against the old provider.

RFC-AI-0004 compliance

  • HITL — any new mutation is gated on explicit user confirmation
  • Sandbox — no new unrestricted host access; network reach declared in the adapter
  • Vendor neutrality — placeholders (<PROJECT>, <tracker>, <upstream>, <security-list>) used in all skill / tool prose (the check-placeholders prek hook is the mechanical gate)
  • Conversational + correctable — agentic-override path documented if behaviour is adopter-tunable
  • Write-access discipline — no autonomous outbound messages; drafts only, sent on confirmation
  • Privacy LLM — private content does not reach a non-approved LLM; redactor invoked where needed. The gate call and its deny-by-default behaviour are unchanged.

Linked issues

Follows #1402 and #1403.

Notes for reviewers (optional)

  • score mapping: the API rates against ordered level descriptions, at most 10, and returns a position starting at zero. The contract takes a numeric scale, so the provider sends numeric levels and maps the position back. Scales wider than 9 steps, such as (0, 10), or with fractional bounds use 10 evenly spaced levels, so the labels are not all whole numbers.
  • Prompt placement: the whole prompt goes in state, with short generic instructions, so fenced contributor text stays data.
  • Removed behaviour: the result and decision envelope handling is gone, because the API does not return those envelopes.

Not in this PR:

  • typed-decision-prefilter.md calls the script at <framework>/skills/pr-management-triage/scripts/. The skills/ symlink exists in a framework checkout, but the one marketplace <framework> copy I checked held only tools/, and it predates fix(marketplace): ship every family's framework tools, not just security's #1937. Other skills use the same <framework>/skills/... form, so this looks like a separate fix.
  • typed_decision_confidence_threshold defaults to 0.85, which was never measured against real Jev answers. This fix makes that measurement possible.

Generated-by: Claude Code (Opus 5.5), reviewed by shahar1 before submission

@shahar1
shahar1 requested review from onlyarnav and potiuk November 7, 2026 08:43
@github-actions github-actions Bot added family:tools tools/* contract:typed-decision family:dev Repo dev: .asf.yaml, spec-loop specs, Node manifests, .claude/settings.json labels Nov 7, 2026

@onlyarnav onlyarnav left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! thanks for catching and fixing the mismatch with the live Typespace System One API.
I didnt cross-check the system against an actual JEV API, while finalizing, which is where I missed it. Really appreciate your help!

Comment thread tools/typed-decision/tool.md Resolved

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rewrite to the documented System One request and response shape looks correct and well tested; before this merges, the three open threads from @onlyarnav need an answer — above all whether the dict form of criteria for choice is documented — and there are two small points on score levels below.

Smaller observations

  • See inline comments on tools/typed-decision/src/typed_decision/providers/jev.py:380, tools/typed-decision/src/typed_decision/providers/jev.py:412.

This review was drafted by an AI-assisted tool and
confirmed by an Apache Magpie maintainer. The findings
below are observations, not blockers; an Apache Magpie
maintainer — a real person — will take the next look at the
PR. If you think a finding is mis-applied, please reply on
the PR and a maintainer will weigh in.

More on how Apache Magpie handles maintainer review:
Contributing guide.

Why: every JevProvider call failed with HTTP 400. It sent operation,
prompt, options and scale, while POST /v1/systemone requires model,
state and questions, and it read answers from the wrong place in the
response. The pinned systemone-2026-06-01 is also not a documented
model. Mocks in the same invented shape kept the tests green, and the
fail-open contract would have left the pr-triage pre-filter logging
fell_through.

Send one typed question per call with the prompt as state, read the
typed answer under answers, and pin jev-1.14.0. score sends at most 10
numeric levels, the API's cap, and maps the returned position back
onto the requested scale. The public contract does not change.

Generated-by: Claude Code (Opus 5.5)
Score level labels were formatted with six significant digits, so scales
such as (1000000, 1000004) or (0.9999999, 1.0) sent identical labels to
the Jev API. Labels now keep 15 significant digits, and a scale whose
labels would still collide is rejected with TypedDecisionUnavailable
before any request is sent.

An out-of-range level position now reports the position, the valid range
and the scale. The tool docs say score levels are bare numbers, so
prompts must define what high and low mean. A test is renamed to match
what it covers.

Generated-by: Claude Code (Sonnet 5.5)
@shahar1
shahar1 force-pushed the fix/typed-decision-jev-model branch from 66ff7fb to c265ab5 Compare November 9, 2026 05:51

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving: the rewrite matches the documented System One request and response shape, and the follow-up commit addresses everything raised — score labels stay distinct (and collide-proof scales are rejected before any request), the out-of-range message names the level position and the scale, the tool docs say score levels are bare numbers, and the test is renamed. The one open question, the dict form of criteria for choice, is confirmed by the API's OpenAPI schema (answered in the thread). Thanks for catching the mismatch and verifying it against the live API!


This review was drafted by an AI-assisted tool and
confirmed by an Apache Magpie maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.

More on how Apache Magpie handles maintainer review:
Contributing guide.

@potiuk
potiuk merged commit 05df617 into apache:main Nov 9, 2026
11 checks passed
@shahar1
shahar1 deleted the fix/typed-decision-jev-model branch November 9, 2026 07:46
potiuk added a commit that referenced this pull request Nov 10, 2026
Brings the specs up to main bfc99bb (37 commits since 1e5c4f9), ahead
of the next dev-version bump:

- security-issue-lifecycle: the import renders the report as defanged
  markdown under a data note, with `description_format: inert` as the
  fenced alternative (#2048).
- adapters: oauth-draft threading by explicit In-Reply-To / References
  (#2051); the typed-decision Jev request shape (#2023).
- adoption-and-setup, marketplace-distribution, codex-runtime: the setup
  sub-action is `update`, and every skill offers the upgrade until it has
  run (#2041); the most specific `sandbox.enabled` wins (#2011); the
  family MCP allows cover single-item reads only (#2020).
- agent-isolation-sandbox: bare `gh auth status` only (#2019); draft
  creation and whole-mailbox search stay prompted (#2020).
- pr-management-family: the CI gate's way out for a non-required check
  (#2029); the adversarial export keeps export-ignore paths (#2030);
  install.md per family (#2031); merge-candidates / thread-mentor names
  (#2025).
- contributor-growth: the candidate-screen committer / PMC headline
  (#2024).
- issue-management-family, repo-health-family: install.md (#2031).
- project-agnosticism: the merge-candidates example path and a re-counted
  example-name gap (#2025).

Generated-by: Claude Opus 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contract:typed-decision family:dev Repo dev: .asf.yaml, spec-loop specs, Node manifests, .claude/settings.json family:tools tools/*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants