Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.
Python calibrationclassificationdecision-modelhuggingfacejevmodernbertmultilingualnlppythonpytorchroutingtyped-decisionszero-shot
ci(java): one blocking security job, and the first static analysis this module has had
Adeshina Lasisi228076be0707
diff --git a/.github/workflows/java.yml b/.github/workflows/java.ymlindex 41831ee7..87a19b36 100644--- a/.github/workflows/java.yml+++ b/.github/workflows/java.yml@@ -39,6 +39,75 @@ env:TOKENIZERS_PARALLELISM: "false"jobs:+ # Everything that decides whether what we publish is safe to consume, in ONE job, so a reader+ # asking "is this secure" has one place to look and one status to read.+ #+ # NOT `continue-on-error`. Every other job in this file is advisory, and deliberately so -- the+ # Python package is the product, a port follows it, and a port lagging must not block a Python+ # improvement (see this file's header). A security gate is the opposite case: it is about the+ # artifact this module publishes to Maven Central, where a consumer inherits what we ship and a+ # published version can never be withdrawn. So this one fails the lane.+ #+ # What runs here, and why each earns its place rather than being added for the look of it:+ #+ # * the Gradle wrapper jar, validated against Gradle's published checksums. It is a binary+ # that executes at build time, so it is the one file here a reviewer cannot read.+ # * the folded-comment check. A `run: >` block folds to one line and `#` is not a comment in+ # a YAML scalar, so a comment written inside one reaches the shell and truncates the+ # command -- which silently removed `--min-tests 625 --allow-aborted` from this+ # repository's own release gate. actionlint does not report it.+ # * semgrep, p/java + p/security-audit. Measured 0 findings and 0 scan errors on this module+ # when added, which is the property that makes it a gate worth having: a finding is a+ # regression, not a backlog to triage.+ # * the Java dependency tree against OSV. There was no CVE gate on it at all while the Python+ # tree had pip-audit. Verified against a planted log4j 2.14.1 -- it reports Log4Shell and+ # exits 1 -- and it exits 2 rather than 0 when OSV is unreachable, so a scan that did not+ # run never reads as a clean tree.+ #+ # CodeQL is NOT duplicated here. It lives in `security.yml`, which already has the+ # `security-events: write` permission and the SARIF upload, and it now covers `java-kotlin` as+ # well as `python` -- this module was previously analysed by nothing.+ #+ # SpotBugs/find-sec-bugs was tried and rejected on evidence: 53 findings, of which 47 were+ # EI/EI2 on records holding an array or a map, 4 were false positives from a `require(...)`+ # helper it cannot see through, 2 were redundant `instanceof` checks (fixed directly), and 0+ # were security findings. Its detectors target SQL, XXE, deserialization, crypto, command+ # execution and path traversal; this module has none of those sinks. Gating on it would have+ # meant maintaining a large exclusion filter for no coverage, and a large exclusion filter is+ # how a scanner quietly stops scanning.+ security:+ name: jvm security scan+ runs-on: ubuntu-latest+ timeout-minutes: 20+ steps:+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0+ - uses: gradle/actions/wrapper-validation@0b6dd653ba04f4f93bf581ec31e66cbd7dcb644d # v4+ - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0+ with:+ python-version: "3.12"+ # For resolving the dependency tree only; nothing here compiles the module.+ - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1+ with:+ distribution: temurin+ java-version: "17"+ cache: gradle++ # Standard library only, so no install step.+ - name: No workflow folds a comment into a run block+ run: python laya-java/scripts/check_workflow_folding.py++ - name: Semgrep (java + security-audit)+ run: |+ python -m pip install --quiet semgrep+ semgrep --config p/java --config p/security-audit --error --metrics=off \+ laya-java/laya-java/src/main/java++ - name: Java dependencies have no known advisories+ working-directory: laya-java+ run: >+ ./gradlew --no-daemon -q :laya-java:dependencies --configuration runtimeClasspath+ | python3 scripts/check_java_dependencies.py+build:# Prefixed, because `dotnet.yml` already has jobs called "build + model-free tests" and# "parity (english)": without a prefix the pull request's checks list shows each name twice@@ -72,15 +141,6 @@ jobs:- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0with:python-version: "3.12"- # Before anything expensive: a `run: >` block folds to one line and `#` is not a comment- # inside a YAML scalar, so a comment written in one reaches the shell and truncates the- # command. That silently removed `--min-tests 625 --allow-aborted` from this repository's- # Maven Central release gate, dropping its floor to 1. actionlint does not report it -- the- # YAML is valid and the command is legal -- and the broken form is one character from the- # correct one in a diff. Standard library only, so it needs no install step.- - name: No workflow folds a comment into a run block- run: python laya-java/scripts/check_workflow_folding.py-- name: Install the Python toolchain the fixtures were recorded withrun: |python -m pip install --upgrade pipdiff --git a/laya-java/laya-java/src/main/java/com/convaiinnovations/laya/config/AgentConfig.java b/laya-java/laya-java/src/main/java/com/convaiinnovations/laya/config/AgentConfig.javaindex 14d58c55..cac69eb9 100644--- a/laya-java/laya-java/src/main/java/com/convaiinnovations/laya/config/AgentConfig.java+++ b/laya-java/laya-java/src/main/java/com/convaiinnovations/laya/config/AgentConfig.java@@ -98,7 +98,11 @@ public final class AgentConfig {"temperature must be a list of three values, one per question type, got "+ raw.getClass().getSimpleName());}- if (raw instanceof List) {+ // `raw != null`, not `instanceof List` again: the throw above means any non-null value+ // here is already a List, so a second type test reads as though it could fail on type+ // when the only thing it can distinguish is absence. A static analyser flagged it as+ // always-true, which it is.+ if (raw != null) {List<?> values = (List<?>) raw;if (values.size() != 3) {throw new Json.JsonException(@@ -117,7 +121,8 @@ public final class AgentConfig {"temperature_by_options must be a mapping, got "+ tbo.getClass().getSimpleName());}- if (tbo instanceof Map) {+ // Same here: absence is the only case left, so test for it directly.+ if (tbo != null) {for (Map.Entry<?, ?> entry : ((Map<?, ?>) tbo).entrySet()) {byOptions.put(String.valueOf(entry.getKey()), clampTemperature(entry.getValue()));}diff --git a/laya-java/scripts/check_java_dependencies.py b/laya-java/scripts/check_java_dependencies.pynew file mode 100755index 00000000..fe665ae1--- /dev/null+++ b/laya-java/scripts/check_java_dependencies.py@@ -0,0 +1,108 @@+#!/usr/bin/env python3+"""Fail when any Java dependency this module ships has a known advisory in OSV.++`security.yml` audits the Python dependencies with pip-audit and nothing audited the Java tree at+all, which is the wrong way round for the one artifact in this repository that gets published to+Maven Central: a consumer who adds `com.convaiinnovations:laya-java` inherits its compile and+runtime dependencies, and a version burned on Central cannot be withdrawn.++Reads Gradle's dependency-tree output on stdin and extracts the resolved coordinates, so+TRANSITIVE dependencies are covered rather than only the ones the build file names:++ ./gradlew -q :laya-java:dependencies --configuration runtimeClasspath \\+ | python3 laya-java/scripts/check_java_dependencies.py++Queries https://api.osv.dev, which aggregates GitHub Security Advisories among others and needs+no account or token -- a gate that requires a secret is a gate that silently stops running on a+fork. Exits 1 on any advisory, 0 when the tree is clean, and 2 when the scan itself could not run+(no coordinates found, or OSV unreachable), because "the scanner failed" must not read as "the+dependencies are clean".+"""+import io+import json+import re+import sys+import urllib.error+import urllib.request++OSV = "https://api.osv.dev/v1/querybatch"++# A Gradle tree line, e.g. "+--- com.microsoft.onnxruntime:onnxruntime:1.20.0" or+# "| \\--- org.foo:bar:1.2 -> 1.3" (the arrow means the resolved version differs from the+# requested one, and the RESOLVED version is the one that ships).+COORDINATE = re.compile(+ r"^[|\\+\- ]*"+ r"(?P<group>[A-Za-z0-9_.\-]+):(?P<name>[A-Za-z0-9_.\-]+):"+ r"(?P<requested>[A-Za-z0-9_.\-+]+)"+ r"(?:\s*->\s*(?P<resolved>[A-Za-z0-9_.\-+]+))?")+++def coordinates(text):+ """Every distinct group:name:version in a Gradle dependency tree, resolved versions."""+ found = {}+ for line in text.split("\n"):+ if "(n)" in line or "FAILED" in line:+ # `(n)` marks a configuration that was not resolved, so it carries no real version.+ continue+ match = COORDINATE.match(line.rstrip())+ if match is None:+ continue+ version = match.group("resolved") or match.group("requested")+ name = "%s:%s" % (match.group("group"), match.group("name"))+ found[(name, version)] = True+ return sorted(found)+++def query(pairs):+ """OSV's batch endpoint, one query per coordinate, in the same order."""+ payload = {"queries": [+ {"version": version, "package": {"name": name, "ecosystem": "Maven"}}+ for name, version in pairs]}+ request = urllib.request.Request(+ OSV, data=json.dumps(payload).encode("utf-8"),+ headers={"Content-Type": "application/json"})+ with urllib.request.urlopen(request, timeout=60) as response:+ return json.loads(response.read().decode("utf-8"))+++def main(argv):+ text = io.open(argv[1], encoding="utf-8").read() if len(argv) > 1 else sys.stdin.read()+ pairs = coordinates(text)+ if not pairs:+ print("check_java_dependencies: no coordinates in the input; the dependency tree did not"+ " reach this script, so nothing was audited", file=sys.stderr)+ return 2++ try:+ answer = query(pairs)+ except (urllib.error.URLError, OSError, ValueError) as problem:+ print("check_java_dependencies: could not reach OSV (%s); refusing to report a clean"+ " tree on a scan that did not run" % problem, file=sys.stderr)+ return 2++ results = answer.get("results") or []+ if len(results) != len(pairs):+ print("check_java_dependencies: OSV answered %d of %d queries; refusing to call the"+ " remainder clean" % (len(results), len(pairs)), file=sys.stderr)+ return 2++ total = 0+ for (name, version), result in zip(pairs, results):+ vulns = result.get("vulns") or []+ if vulns:+ total += len(vulns)+ for vuln in vulns:+ print("%s:%s %s" % (name, version, vuln.get("id")), file=sys.stderr)+ else:+ print(" %s:%s clean" % (name, version))+ if total:+ print("check_java_dependencies: %d advisory/advisories across %d dependency/dependencies."+ " See https://osv.dev for each id." % (total, len(pairs)), file=sys.stderr)+ return 1+ print("check_java_dependencies: %d dependency/dependencies, no known advisories"+ % len(pairs))+ return 0+++if __name__ == "__main__":+ sys.exit(main(sys.argv))