Repository navigation
Add a Java runtime built on generated models - #444
Seth Juarez (sethjuarez) merged 5 commits into
Conversation
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
785d645 to
4594f56
Compare
* fix(python): eliminate ReDoS in chat parser role-boundary regex Unquoted, unterminated attributes let the value class in the role-boundary regex overlap with the `,` separator and closing `]`, giving the backtracking engine an exponential number of equivalent splits to try on a failing match. Rewrite the attribute group as a quoted/unquoted alternation with no shared characters between branches, plus possessive quantifiers (Python 3.11+), matching the fix already applied to the Java parser in #444. Fixes #446 * fix(python): address ReDoS test review feedback Test through the public parse() API instead of importing the module-private _BOUNDARY_RE, and replace the fixed wall-clock assertion with a doubling-input comparison so the test can't flake on a slow CI runner while still catching a regression to exponential behavior. * docs(python): clarify the ReDoS test's absolute floor is a noise guard The docstring said the assertion avoids an absolute wall-clock budget, but it does include a 0.1s floor. Clarify that the floor only keeps the relative comparison from collapsing to noise on a very fast run and is not itself the enforced budget. * docs(python): state the Python 3.11+ floor next to the possessive regex The automated reviewer keeps flagging the possessive quantifiers as a pre-3.11 risk because it only sees this diff, not pyproject.toml. Say the constraint explicitly at the point of use so it's obvious without cross-referencing another file. * test(python): use best-of-20 timing in the ReDoS regression test A single sample per size is susceptible to a scheduler blip or first-run JIT/cache noise. Take the minimum of 20 samples instead so an occasional slow tick can't cause a false failure, without weakening what the test actually catches (exponential blowup still dwarfs this noise floor by orders of magnitude).
|
Stale against current |
….9.2 Add a Java emit target to tspconfig.yaml and bump the Typra emitter pin to ^0.9.2, which fixes the Java model test-emitter so string-literal enum scalar-coercion assertions (e.g. McpApprovalMode) wrap the expected value in <EnumKind>.fromValue(...) instead of a bare string. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Implements the Java runtime for Prompty with full parity to the other runtimes. The model layer is generated from the shared TypeSpec via the Typra emitter; the editable seams (MessageMethods, ToolResultMethods) are filled to mirror the Rust model_ext behavior. Providers (openai, anthropic, foundry) build request wire payloads and are validated against the shared conformance vectors plus provider-specific wire tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Runs ./gradlew build (all four modules) on JDK 21 across ubuntu and windows, mirroring the Rust runtime check. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
31f4962 to
d58e2ec
Compare
The Unix gradlew script was committed without the executable bit, so ./gradlew build failed with permission denied on ubuntu-latest. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…-port + open-union contracts Brings the Java runtime up to parity with main after PRs #447 (engine ports, open-union Connection, stream-failure) and #439 (Swift) landed. - Resolve schema conflicts: union tspconfig.yaml (Java + Swift targets), pin @typra/emitter ^0.9.3, take main's package-lock + export-surfaces. - Regenerate: adds Engine{Durability,Permission,PostCommit,Tool}Port, FailureChunk, StreamFailure(Outcome), UnknownConnection (+ generated round-trip tests); Connection becomes an open union, StreamChunk gains the failure case. - Rewrite the hand-written unknown-connection-kind test to assert the new open-union round-trip (UnknownConnection preserves kind + extra keys) instead of expecting a throw. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add a Java runtime built on generated models
This is the Java runtime for Prompty, at parity with the other language runtimes. Like Rust, Python, C#, TypeScript, Go and Swift, the model layer is generated from the shared TypeSpec via
@typra/emitter; the hand-written surface is the provider wire code plus the editable model seams.What's here
runtime/java/prompty/.../model) emitted by@typra/emitter@0.9.2fromschema/model/**, registered as a Java emit target inschema/tspconfig.yaml.MessageMethodsandToolResultMethodsmirror the Rustmodel_extbehavior (textjoinsTextPart.valuewith newlines;toTextContentreturns a bare string when all parts are text, else the saved part list). These live in Typra's// <typra-editable-seam>regions and survive regeneration.prompty-openai,prompty-anthropic,prompty-foundrybuild request wire payloads and interpret responses.vectors.json(166 vectors) is graded by the Java suites (WireVectorsTest,ProcessVectorsTest,DiscoveryVectorsTest, load/parse/render, etc.), the same fixtures every other runtime is measured by..github/workflows/prompty-java-check.ymlruns./gradlew build(all four modules, live provider tests excluded) on JDK 21 across ubuntu and windows.Emitter bump
@typra/emitter^0.9.0→^0.9.2. 0.9.2 fixes the Java test-emitter so string-literal enum assertions coerce through<EnumKind>.fromValue(...)(McpApprovalModeGeneratedTest). Regenerating at 0.9.2 changes only the Java output and the three.typra-generatedmetadata files — no other runtime's generated code moves, andvectors.jsonis unchanged. Theschema generated-code reproducibilitygate passes, confirming the committed tree matches a clean regeneration.Tests
./gradlew build— 701 tests, 0 failures: prompty 442, openai 68, anthropic 67, foundry 124.Follow-up: move provider wire coverage into shared vectors
Per maintainer direction, provider-specific wire behavior should be covered by the shared conformance vectors (to enforce cross-runtime parity) rather than by per-runtime hand-written tests. This runtime intentionally follows the existing repo pattern — hand-written provider wire tests (
WireSchemaTest,WireMessageTest) alongside the shared vectors — exactly as Python, C#, TypeScript and Rust already do, so Java is consistent with its peers. Migrating that coverage into shared vectors is a repo-wide effort (each new vector must be registered in every runtime's harness) and is deliberately not bundled here.While scoping that work, a genuine parity divergence surfaced that the migration should resolve:
input_schema) is implemented in Java and TypeScript only. Rust, Python and C# wire all declared parameters. A shared vector for this edge would fail three runtimes until their wire mappers agree — this is exactly the kind of gap shared vectors are meant to catch, and it wants a deliberate decision (align the three, or the two) in its own PR.Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com