From 526e47dfd3552e81177664adcc28f067654b5131 Mon Sep 17 00:00:00 2001
From: Thorsten Fuchs <76904008+ThorFuchs@users.noreply.github.com>
Date: Wed, 14 Oct 2026 16:01:48 +0200
Subject: [PATCH 1/6] feat(cli): add bounded strict JSON command foundation
---
AGENTS.md | 5 +-
.../Architecture/ExtractionManifest.json | 3 +-
.../Architecture/Release1.4/Acceptance.json | 1186 +++++++++++++++++
.../Architecture/Release1.4/Foundation.md | 103 ++
Documentation/Architecture/Release1.4/Plan.md | 40 +
.../Architecture/Release1.4/Progress.json | 41 +
.../Architecture/Release1.4/Qualification.md | 50 +
Documentation/README.md | 2 +
Package.swift | 7 +-
README.md | 16 +
Scripts/ci.py | 20 +-
Scripts/qualify_cli.py | 109 ++
Scripts/qualify_cli_ownership.py | 21 +
Scripts/testing_events.py | 1 +
.../JSON/Documentation.docc/CommandLine.md | 36 +
Sources/JSON/Limits/JSONWorkMeter.swift | 19 +-
Sources/JSON/Pointer/JSONPointer.swift | 29 +-
Sources/JSONCLI/Main.swift | 26 +
Sources/JSONCLIEngine/CLIArguments.swift | 89 ++
Sources/JSONCLIEngine/CLIDiagnostics.swift | 115 ++
Sources/JSONCLIEngine/CLIEngine.swift | 225 ++++
Sources/JSONCLIEngine/CLIFileIO.swift | 154 +++
.../JSONCLIEngine/CLIProcessArguments.swift | 46 +
Sources/JSONFilterRuntime/CLIJobContext.swift | 153 +++
Sources/JSONPatch/JSONPatch.swift | 14 +-
.../Compilation/JSONSchemaCompiler.swift | 7 +
.../Evaluation/JSONSchemaValidator.swift | 6 +-
Tests/JSONCLITests/FoundationTests.swift | 135 ++
28 files changed, 2640 insertions(+), 18 deletions(-)
create mode 100644 Documentation/Architecture/Release1.4/Acceptance.json
create mode 100644 Documentation/Architecture/Release1.4/Foundation.md
create mode 100644 Documentation/Architecture/Release1.4/Plan.md
create mode 100644 Documentation/Architecture/Release1.4/Progress.json
create mode 100644 Documentation/Architecture/Release1.4/Qualification.md
create mode 100644 Scripts/qualify_cli.py
create mode 100644 Scripts/qualify_cli_ownership.py
create mode 100644 Sources/JSON/Documentation.docc/CommandLine.md
create mode 100644 Sources/JSONCLI/Main.swift
create mode 100644 Sources/JSONCLIEngine/CLIArguments.swift
create mode 100644 Sources/JSONCLIEngine/CLIDiagnostics.swift
create mode 100644 Sources/JSONCLIEngine/CLIEngine.swift
create mode 100644 Sources/JSONCLIEngine/CLIFileIO.swift
create mode 100644 Sources/JSONCLIEngine/CLIProcessArguments.swift
create mode 100644 Sources/JSONFilterRuntime/CLIJobContext.swift
create mode 100644 Tests/JSONCLITests/FoundationTests.swift
diff --git a/AGENTS.md b/AGENTS.md
index 443ee58..b8aa949 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -4,8 +4,9 @@ Swift-JSON requires Swift tools/compiler 6.4+, Swift language mode 6 and
macOS/SDK 27+. Read README.md, CONTRIBUTING.md and the relevant contracts in
Documentation/Architecture before changing behavior.
-- Keep five public products: JSON, JSONSchema, JSONStreaming, JSONPatch and JSONHTML.
- JSONHTML depends on JSON only; the maintainer-approved 1.3 addition preserves historical four-product releases.
+- Keep six public products: JSON, JSONSchema, JSONStreaming, JSONPatch, JSONHTML
+ and the swift-json executable. JSONFilterRuntime and JSONCLIEngine are package-private.
+ JSONHTML depends on JSON only. The approved 1.4 CLI addition preserves historical product contracts.
JSONRegexRuntime is package-private. Root package dependencies remain empty.
- Preserve exact bounded decimals, decoded Unicode scalar identity, ordered
objects with order-independent equality, one strict UTF-8 grammar, native
diff --git a/Documentation/Architecture/ExtractionManifest.json b/Documentation/Architecture/ExtractionManifest.json
index 735d569..66bf9f6 100644
--- a/Documentation/Architecture/ExtractionManifest.json
+++ b/Documentation/Architecture/ExtractionManifest.json
@@ -196,7 +196,8 @@
"Schema graph, explicit evaluator, exact sets/assertions and scalar format recognizers are original implementations from Draft 2020-12, RFC3986/3987/3339/3492/5321/5891/5892/5893/6531/6570/6901 and fixed Unicode13 data.",
"Private FIPS 180-4 SHA-256 is an original Swift implementation with checked cumulative production accounting, bounded scratch and inner cancellation. The separate trusted fixture tool mirrors its primitive core byte-for-byte; public_check verifies parity. No CryptoKit fallback or runtime dependency is introduced.",
"JSONHTML formatted rendering, original fixed CSS and shared strict-writer token classification are original Apache-2.0 code. No third-party renderer, browser numeric authority or runtime dependency is adapted.",
- "JSONHTML typed annotations, iterative exact-path binding, static/interactive attachment and coherent JSONDocument span presentation are original Apache-2.0 code. No schema engine, third-party renderer, source archive or new dependency is adapted."
+ "JSONHTML typed annotations, iterative exact-path binding, static/interactive attachment and coherent JSONDocument span presentation are original Apache-2.0 code. No schema engine, third-party renderer, source archive or new dependency is adapted.",
+ "CLI foundation, argv parser, POSIX adapters, prepaid bounded diagnostics and shared-meter package adapters are original Apache-2.0 Swift code. No legacy filter engine or jq source is copied. See Release1.4/Foundation.md for native test-harness reuse provenance."
],
"policy": "Record actual adaptations and retain applicable upstream copyrights and licenses. Reference inputs and comparison experiments are not distributed runtime dependencies.",
"jsonhtml_export_original_contributions": {
diff --git a/Documentation/Architecture/Release1.4/Acceptance.json b/Documentation/Architecture/Release1.4/Acceptance.json
new file mode 100644
index 0000000..5b17493
--- /dev/null
+++ b/Documentation/Architecture/Release1.4/Acceptance.json
@@ -0,0 +1,1186 @@
+{
+ "schema": "swift-json-cli-acceptance/1",
+ "prepared": "2026-10-14",
+ "implementation_status": "foundation boundary only; integration unqualified",
+ "requirements": [
+ {
+ "id": "CL001",
+ "gate": "C0",
+ "title": "Live source/prerequisite reconciliation",
+ "verification": "Record actual main/base/HTML/provider heads and compare pins; preserve active work and dirty state.",
+ "obligation": "mandatory",
+ "status": "passed",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL002",
+ "gate": "C0",
+ "title": "Six public products with correct kinds",
+ "verification": "Package dump contains five libraries plus swift-json executable; private targets have no products.",
+ "obligation": "mandatory",
+ "status": "passed",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL003",
+ "gate": "C0",
+ "title": "Empty root dependency set",
+ "verification": "Dump/package resolution and clean-source build prove no external dependency was introduced.",
+ "obligation": "mandatory",
+ "status": "partial",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL004",
+ "gate": "C0",
+ "title": "Dependency direction and mobile consumers",
+ "verification": "Selected library consumers have no CLI/filter dependencies; core has no HTML/provider/UI imports.",
+ "obligation": "mandatory",
+ "status": "partial",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL005",
+ "gate": "C0",
+ "title": "Forward policy and historical records",
+ "verification": "Update AGENTS/README/CI prospective inventory; historical releases remain accurate.",
+ "obligation": "mandatory",
+ "status": "passed",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL006",
+ "gate": "C0",
+ "title": "Private compiler/IR ownership",
+ "verification": "Compiler probes prove immutable checked-Sendable plans and invocation-owned noncopyable context.",
+ "obligation": "mandatory",
+ "status": "partial",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL007",
+ "gate": "C0",
+ "title": "Attribution and extraction manifest",
+ "verification": "Every actual adaptation has pinned origin/status/notices; inherited files retain identity.",
+ "obligation": "mandatory",
+ "status": "passed",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL008",
+ "gate": "C0",
+ "title": "Prior brief conflict resolution",
+ "verification": "Record reused HTML/tab/provider APIs and authoritative amendments; no duplicate conformance or restarted portability.",
+ "obligation": "mandatory",
+ "status": "passed",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL009",
+ "gate": "C1",
+ "title": "Argv parsing and limits",
+ "verification": "Exercise long equals, grouped Boolean flags, leading-dash filenames, --, duplicates, unknown/conflicting options and bounded args.",
+ "obligation": "mandatory",
+ "status": "partial",
+ "evidence_required": true,
+ "fixture_ids": [
+ "unknown-option"
+ ],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL010",
+ "gate": "C1",
+ "title": "Truthful help/version",
+ "verification": "Only available qualified commands appear; missing command/config/capability is 2; help/version is 0.",
+ "obligation": "mandatory",
+ "status": "partial",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL011",
+ "gate": "C1",
+ "title": "Strict native format",
+ "verification": "Single root, full EOF, native UTF-8/duplicate-key grammar, exact lexemes and default two-space formatting.",
+ "obligation": "mandatory",
+ "status": "passed",
+ "evidence_required": true,
+ "fixture_ids": [
+ "format-preserved-lexemes",
+ "reject-duplicate-key",
+ "reject-trailing-root",
+ "reject-trailing-comma"
+ ],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL012",
+ "gate": "C1",
+ "title": "Explicit presentation options",
+ "verification": "Compact/indent/tab/sort/number-style options preserve library defaults and scalar key order.",
+ "obligation": "mandatory",
+ "status": "passed",
+ "evidence_required": true,
+ "fixture_ids": [
+ "conflicting-style-options"
+ ],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL013",
+ "gate": "C1",
+ "title": "Syntax validation outcomes",
+ "verification": "Completed valid/invalid result and issues; malformed input 5, resource 6, IO 7 are separate.",
+ "obligation": "mandatory",
+ "status": "passed",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL014",
+ "gate": "C1",
+ "title": "Offline schema validation",
+ "verification": "Compile once per job; explicit immutable resources; instance invalid 1; no fetch/default insertion.",
+ "obligation": "mandatory",
+ "status": "partial",
+ "evidence_required": true,
+ "fixture_ids": [
+ "validate-instance-invalid"
+ ],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL015",
+ "gate": "C1",
+ "title": "Pointer presence",
+ "verification": "Present null versus missing, escaped tokens, root pointer, allow-missing exit4 and type/domain errors.",
+ "obligation": "mandatory",
+ "status": "passed",
+ "evidence_required": true,
+ "fixture_ids": [
+ "pointer-present-null",
+ "pointer-missing-allowed",
+ "pointer-escaped-key"
+ ],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL016",
+ "gate": "C1",
+ "title": "Patch transactional candidate",
+ "verification": "Successful operations emit full result; failed test/path never emits staged mutation or changes source.",
+ "obligation": "mandatory",
+ "status": "passed",
+ "evidence_required": true,
+ "fixture_ids": [
+ "patch-success",
+ "patch-failed-test"
+ ],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL017",
+ "gate": "C1",
+ "title": "Incremental local IO",
+ "verification": "Owned chunk reads, explicit closure, split UTF-8 and partial/no-progress writes; no read-to-end job arrays.",
+ "obligation": "mandatory",
+ "status": "partial",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL018",
+ "gate": "C1",
+ "title": "Stdout/stderr separation",
+ "verification": "All data is clean; JSON diagnostics/reports are tagged stderr lines with no ANSI/banner.",
+ "obligation": "mandatory",
+ "status": "passed",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL019",
+ "gate": "C1",
+ "title": "Shared compound accounting",
+ "verification": "Nested parse/validate/patch/write and multiple records cannot reset work or retained overlap; failure latches.",
+ "obligation": "mandatory",
+ "status": "partial",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL020",
+ "gate": "C1",
+ "title": "Every CLI cap boundary",
+ "verification": "Inclusive-cap and cap+1 sweeps for all 16 CLI caps; checked counters and conversion overflow.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL021",
+ "gate": "C1",
+ "title": "Existing native limits preserved",
+ "verification": "49 metric inventory/meaning and existing independent boundary tests remain intact.",
+ "obligation": "mandatory",
+ "status": "passed",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL022",
+ "gate": "C1",
+ "title": "Actual in-loop cancellation",
+ "verification": "Checkpoint rendezvous inside long owned work and source/sink suspend; no further output after terminal failure.",
+ "obligation": "mandatory",
+ "status": "partial",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL023",
+ "gate": "C1",
+ "title": "Atomic file success",
+ "verification": "Owned same-directory stage installed only after EOF/flush/close; report committed completion.",
+ "obligation": "mandatory",
+ "status": "passed",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL024",
+ "gate": "C1",
+ "title": "Atomic file failure",
+ "verification": "Late invalid tail/resource/cancel/IO preserves destination and removes only owned stage.",
+ "obligation": "mandatory",
+ "status": "passed",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL025",
+ "gate": "C1",
+ "title": "Overwrite/path policy",
+ "verification": "Existing file requires --overwrite; input/output alias and output symlink reject; no silent cross-FS fallback.",
+ "obligation": "mandatory",
+ "status": "passed",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL026",
+ "gate": "C1",
+ "title": "Exit precedence",
+ "verification": "Codes0/1/2/3/4/5/6/7/130 and completed-result precedence verified in actual subprocesses.",
+ "obligation": "mandatory",
+ "status": "partial",
+ "evidence_required": true,
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
+ },
+ {
+ "id": "CL027",
+ "gate": "C2",
+ "title": "Native query lexer/literals",
+ "verification": "Exact numbers and scalar text/keys with source byte ranges; malformed source compiles to exit3.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL028",
+ "gate": "C2",
+ "title": "Grammar precedence",
+ "verification": "Pipeline/comma/default/assignment/operator precedence and delimiters tested beyond old parser goldens.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "pipeline-comma-precedence"
+ ]
+ },
+ {
+ "id": "CL029",
+ "gate": "C2",
+ "title": "Pull VM cardinality",
+ "verification": "Empty/one/many outputs without whole-job array; next() demand limits observable reads/retention.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL030",
+ "gate": "C2",
+ "title": "Pipeline and comma order",
+ "verification": "Every upstream result is evaluated and ordered; late errors do not resume a failed branch.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL031",
+ "gate": "C2",
+ "title": "Cartesian operators/constructors",
+ "verification": "No .first collapse; object versus arithmetic nesting orders and shared input effects are tested.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "object-product-order"
+ ]
+ },
+ {
+ "id": "CL032",
+ "gate": "C2",
+ "title": "Navigation and wrong-type",
+ "verification": "Missing/null convention, has, wrong-type error, optional catch and checked indices/slices.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "missing-field-null",
+ "wrong-type-field",
+ "optional-wrong-type-empty",
+ "has-present-null",
+ "negative-index"
+ ]
+ },
+ {
+ "id": "CL033",
+ "gate": "C2",
+ "title": "Exact Unicode identity",
+ "verification": "Scalar-distinct strings/keys, scalar length/slicing/order and non-BMP behavior.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "scalar-key-lookup",
+ "scalar-string-inequality",
+ "scalar-length",
+ "utf8-length",
+ "scalar-slice"
+ ]
+ },
+ {
+ "id": "CL034",
+ "gate": "C2",
+ "title": "Truth/default/Boolean generators",
+ "verification": "Only false/null falsey; // handles full streams; left-driven short-circuit and if generators.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "truthiness",
+ "fallback-whole-generator",
+ "fallback-empty",
+ "Boolean-short-circuit",
+ "if-condition-stream"
+ ]
+ },
+ {
+ "id": "CL035",
+ "gate": "C2",
+ "title": "Constructed duplicate keys",
+ "verification": "Explicit replace-preserve-position policy; parsed exact duplicate keys still reject.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "constructed-key-replacement"
+ ]
+ },
+ {
+ "id": "CL036",
+ "gate": "C2",
+ "title": "Exact comparison/order",
+ "verification": "Metered decimal/string/array/object equality and total order with stable ties.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL037",
+ "gate": "C2",
+ "title": "Common builtin inventory",
+ "verification": "All C2 builtins and type/domain/empty cases; map collects and map_values updates/deletes correctly.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "empty-array-collector",
+ "map-all-results",
+ "map-values-first",
+ "map-values-delete",
+ "normals-nonzero-native"
+ ]
+ },
+ {
+ "id": "CL038",
+ "gate": "C2",
+ "title": "Lexical bindings/arguments",
+ "verification": "as, --arg/argjson/rawfile/slurpfile, $ARGS, duplicate/reserved names, strict auxiliary-file admission.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "binding-original-input",
+ "argjson-exact"
+ ]
+ },
+ {
+ "id": "CL039",
+ "gate": "C2",
+ "title": "Shared input cursor",
+ "verification": "Driver/input/inputs share consumption; EOF catchable only for input; malformed tails/IO remain fatal.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "null-input-once",
+ "shared-inputs"
+ ]
+ },
+ {
+ "id": "CL040",
+ "gate": "C2",
+ "title": "JSON/raw framing",
+ "verification": "values/document/NDJSON and strict raw UTF-8 lines/slurp; files have independent boundaries.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "values-framing",
+ "adjacent-roots-rejected",
+ "ndjson-blank-line-rejected",
+ "raw-line-crlf"
+ ]
+ },
+ {
+ "id": "CL041",
+ "gate": "C2",
+ "title": "Raw output/NUL/join",
+ "verification": "Correct string bytes and nonstring JSON; embedded NUL rejected; delimiters/errors/counts tested.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "raw-lf",
+ "raw-nul-delimiter",
+ "raw-nul-value-rejected",
+ "join-no-delimiter"
+ ]
+ },
+ {
+ "id": "CL042",
+ "gate": "C2",
+ "title": "ASCII output and sort keys",
+ "verification": "Owned escaping, surrogate pairs and exact scalar order; option conflicts tested.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "ascii-surrogate-pair"
+ ]
+ },
+ {
+ "id": "CL043",
+ "gate": "C2",
+ "title": "Query exit-status",
+ "verification": "Final semantic value only after completion; truthy0/empty string/collections; false/null1 and noresult4.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "exit-status-truthy-zero",
+ "exit-status-false",
+ "exit-status-empty"
+ ]
+ },
+ {
+ "id": "CL044",
+ "gate": "C2",
+ "title": "Plan reuse and isolation",
+ "verification": "Concurrent independent invocations share immutable plan only; mutable iterator not concurrently accessed.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL045",
+ "gate": "C3",
+ "title": "Exact add/subtract/multiply",
+ "verification": "Carry/borrow/sign/zero/large integer cases against independent exact expectations.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "Cartesian-add-order",
+ "exact-large-integer",
+ "exact-decimal-add",
+ "exact-borrow",
+ "exact-multiply"
+ ]
+ },
+ {
+ "id": "CL046",
+ "gate": "C3",
+ "title": "Numeric admission and lexemes",
+ "verification": "Computed values normalized with no false originalLexeme; untouched inputs preserve spelling.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL047",
+ "gate": "C3",
+ "title": "Terminating exact division",
+ "verification": "Reduced denominators containing only2/5, large common factors and mixed signs.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "terminating-division"
+ ]
+ },
+ {
+ "id": "CL048",
+ "gate": "C3",
+ "title": "Repeating division default",
+ "verification": "1/3 and repeating values give language inexactDivision; no floating fallback.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "repeating-division-error"
+ ]
+ },
+ {
+ "id": "CL049",
+ "gate": "C3",
+ "title": "Explicit scale/half-even",
+ "verification": "Required option pair, decimal places, finite caps, signed ties and report rounding counts.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "rounded-third",
+ "half-even-ties",
+ "scale-pair-required"
+ ]
+ },
+ {
+ "id": "CL050",
+ "gate": "C3",
+ "title": "Zero division and integral remainder",
+ "verification": "Typed catchable domain errors; signed truncated remainder; fractional remainder rejected.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "negative-remainder",
+ "fractional-remainder-rejected"
+ ]
+ },
+ {
+ "id": "CL051",
+ "gate": "C3",
+ "title": "Exact numeric builtins",
+ "verification": "abs/floor/ceil/trunc/round/range/add with negative and empty/domain cases; round ties away from zero.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "round-away-from-zero",
+ "range-negative-step",
+ "range-zero-step"
+ ]
+ },
+ {
+ "id": "CL052",
+ "gate": "C3",
+ "title": "Exponent/growth preflight",
+ "verification": "Large sparse exponent operations fail finite caps before dense allocation; exact zero shortcut allowed.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "exponent-gap-cap"
+ ]
+ },
+ {
+ "id": "CL053",
+ "gate": "C3",
+ "title": "Numeric work and cancellation",
+ "verification": "Charged GCD/division/carry inner loops; boundaries and checkpoint cancellation; terminal errors not catchable.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL054",
+ "gate": "C3",
+ "title": "32-bit arithmetic safety",
+ "verification": "No Int/UInt64 negation/narrowing/product overflow traps; wasm32 kernel tests or explicit gate blocker.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL055",
+ "gate": "C3",
+ "title": "No Decimal/Double authority",
+ "verification": "Source audit plus precision cases prove no foreign arithmetic/fallback authority.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL056",
+ "gate": "C4",
+ "title": "Reduce/foreach streams",
+ "verification": "Last-update state, every foreach extraction, multiple inits, empty updates and actual evaluation order.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "reduce-last-update",
+ "reduce-empty-update",
+ "foreach-every-update",
+ "reduce-multiple-inits"
+ ]
+ },
+ {
+ "id": "CL057",
+ "gate": "C4",
+ "title": "Lexical filter functions",
+ "verification": "Filter/value parameters, arity/scopes, self-recursion, no forward refs and finite explicit frames.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "filter-parameter-code",
+ "forward-definition-rejected",
+ "recursive-definition"
+ ]
+ },
+ {
+ "id": "CL058",
+ "gate": "C4",
+ "title": "Loops/recurse/walk",
+ "verification": "Correct order/null handling/parent-after-child behavior with bounded frames/work and no fixed hidden10k cap.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "walk-child-before-parent",
+ "recurse-null-leaves"
+ ]
+ },
+ {
+ "id": "CL059",
+ "gate": "C4",
+ "title": "Typed try/catch/optional",
+ "verification": "Catch only language errors; prior yields/handler streams correct; syntax/resource/cancel/IO never suppressed.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "input-eof-catch",
+ "malformed-input-cannot-catch",
+ "repeating-division-caught",
+ "division-zero-caught",
+ "try-prior-yield"
+ ]
+ },
+ {
+ "id": "CL060",
+ "gate": "C4",
+ "title": "Collection builtin inventory",
+ "verification": "sort/group/unique/min/max/by forms, stable ties, multi-key generator lists, finite materialization.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "sort-exact-integers",
+ "total-order",
+ "group-scalar-distinct"
+ ]
+ },
+ {
+ "id": "CL061",
+ "gate": "C4",
+ "title": "Generator first/last/nth",
+ "verification": "Correct pull/empty behavior and completion of remaining input; no hidden job early success.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "first-generator"
+ ]
+ },
+ {
+ "id": "CL062",
+ "gate": "C4",
+ "title": "Flatten/any/all",
+ "verification": "Depth bounds, empty identities, short circuit and explicit deep traversal.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "all-any-empty"
+ ]
+ },
+ {
+ "id": "CL063",
+ "gate": "C4",
+ "title": "Literal string helpers",
+ "verification": "Scalar contains/search/split/join/ASCII trim/case; empty patterns/type errors and bounded scan.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "split-empty-scalars",
+ "index-empty-pattern"
+ ]
+ },
+ {
+ "id": "CL064",
+ "gate": "C4",
+ "title": "Conversions/explode/implode",
+ "verification": "Strict tonumber, preserved tostring, non-BMP scalar ints, invalid surrogate/range/type rejection.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "explode-non-BMP",
+ "implode-surrogate-rejected",
+ "tonumber-exact",
+ "tonumber-whitespace-rejected"
+ ]
+ },
+ {
+ "id": "CL065",
+ "gate": "C4",
+ "title": "Path enumeration/admission",
+ "verification": "Exact segments, missing paths, generated paths, shape/domain restrictions and no Pointer conflation.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "setpath-created-array"
+ ]
+ },
+ {
+ "id": "CL066",
+ "gate": "C4",
+ "title": "Assignment = versus |=",
+ "verification": "Original versus current-value RHS input; generator output, first update/empty delete semantics.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "assignment-set-generator",
+ "assignment-update-first",
+ "assignment-update-delete"
+ ]
+ },
+ {
+ "id": "CL067",
+ "gate": "C4",
+ "title": "Transactional mutation/deletion",
+ "verification": "Stable array removals, deduplicated targets, overlap rejection and input unchanged on failure.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "assignment-overlap-rejected"
+ ]
+ },
+ {
+ "id": "CL068",
+ "gate": "C4",
+ "title": "Sparse path growth",
+ "verification": "setpath container creation/null fill bounded before allocation and overflow.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "sparse-growth-fails"
+ ]
+ },
+ {
+ "id": "CL069",
+ "gate": "C4",
+ "title": "String interpolation streams",
+ "verification": "Cartesian holes/literal identity/empty hole; formatter holes only with no eager unbounded strings.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "interpolation-generators",
+ "interpolation-empty"
+ ]
+ },
+ {
+ "id": "CL070",
+ "gate": "C4",
+ "title": "Bounded format encoders",
+ "verification": "All C4 formatters, strict base64/UTF8, flat CSV/TSV, percent/HTML/POSIX quoting; no shell execution.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "format-html",
+ "format-base64"
+ ]
+ },
+ {
+ "id": "CL071",
+ "gate": "C4",
+ "title": "Regex deferral",
+ "verification": "Compile-time unavailable diagnostics; no ICU/ECMA substitutions or compatibility claim.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "regex-not-advertised"
+ ]
+ },
+ {
+ "id": "CL072",
+ "gate": "C4",
+ "title": "Other exclusions",
+ "verification": "Modules/seq/jq-stream/dates/env/halt/remote/server/converters rejected or absent from truthful help.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "numeric-transcendental-deferred",
+ "env-not-available"
+ ]
+ },
+ {
+ "id": "CL073",
+ "gate": "C4",
+ "title": "Every inherited fixture disposition",
+ "verification": "119+49 originals retained, actual per-row status/reason/gate/claim, exclusions separated from successes.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL074",
+ "gate": "C5",
+ "title": "Stream completion commands",
+ "verification": "Check/cat/root-array reader, strict line/tail behavior and completed summary exactly once.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "stream-root-array",
+ "stream-root-array-bad-tail"
+ ]
+ },
+ {
+ "id": "CL075",
+ "gate": "C5",
+ "title": "Static HTML rendering",
+ "verification": "JSONHTML integration with no script, expanded nodes, exact values/keys, escaping and finite shared accounting.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "render-static-inert"
+ ]
+ },
+ {
+ "id": "CL076",
+ "gate": "C5",
+ "title": "Interactive HTML rendering",
+ "verification": "Approved fixed CSS/JS self-contained document with inert payloads; no server or external assets.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL077",
+ "gate": "C5",
+ "title": "Text/Markdown output",
+ "verification": "Tab pretty body, safe JSON fence and exact tokens; shared qualified writer options/defaults unchanged.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "render-markdown"
+ ]
+ },
+ {
+ "id": "CL078",
+ "gate": "C5",
+ "title": "Offline schema/provider commands",
+ "verification": "Native schema check plus qualified local OpenAI helpers; schema object not quoted string, no network/key.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "schema-provider-object-envelope"
+ ]
+ },
+ {
+ "id": "CL079",
+ "gate": "C5",
+ "title": "Provider incompatibility and availability",
+ "verification": "No constraint loss/lowering; compatibility false exit1; Apple signatures guarded and advertised only when qualified.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": [
+ "schema-provider-optionality-reject"
+ ]
+ },
+ {
+ "id": "CL080",
+ "gate": "C5",
+ "title": "Native macOS executable qualification",
+ "verification": "Actual SDK27/Swift6.4 build/run/subprocess tests at final head.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL081",
+ "gate": "C5",
+ "title": "Linux x86_64 executable qualification",
+ "verification": "Actual Ubuntu24.04 x86_64 runtime and Linux/linux-safety receipts; not crosscompile-only.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL082",
+ "gate": "C5",
+ "title": "Linux ARM64 executable qualification",
+ "verification": "Actual Ubuntu24.04 ARM64 runtime and Linux/linux-safety receipts.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL083",
+ "gate": "C5",
+ "title": "Mobile library compatibility",
+ "verification": "Selected-product iOS/iPadOS consumers and existing mobile qualification preserved; no CLI process support claim.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL084",
+ "gate": "C5",
+ "title": "WASI CLI disposition",
+ "verification": "Explicit final supported/blocked/limited evidence with resources/argv/preopen/counters; no inherited CLI pass.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL085",
+ "gate": "C5",
+ "title": "Baseline WASI/core preservation",
+ "verification": "Existing all-four-product resource/integrity/49metrics/platform lanes retain exact truthful evidence.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL086",
+ "gate": "C5",
+ "title": "Installed resources/clean extraction",
+ "verification": "Source archive rebuilt, executable run outside repo cwd, sibling schema bundle and missing/tampered resource tests.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL087",
+ "gate": "C5",
+ "title": "Fresh oracle and comparisons",
+ "verification": "Pinned jq1.8.2 build/hash; native exact comparison plus byte/exit modes; missing oracle blocks that lane.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL088",
+ "gate": "C5",
+ "title": "Independent exact expectations",
+ "verification": "Integer/rational/Unicode/cardinality expectations separate from native self-comparison and jq floats.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL089",
+ "gate": "C5",
+ "title": "Streaming retention/performance",
+ "verification": "Generated chunks/slow sink/large record counts and bounded collectors; release-mode identities/variance, no blanket speedup.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL090",
+ "gate": "C5",
+ "title": "Six-product CI/documentation",
+ "verification": "Existing native/safety/docs plus affected Linux lanes, exact product kinds and public CLI help/docs/examples.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL091",
+ "gate": "C5",
+ "title": "Final-head review/return evidence",
+ "verification": "Actual PR/base/head topology, nonzero counts, immutable IDs/log hashes/fixture results, blockers and release recommendation.",
+ "obligation": "mandatory",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL092",
+ "gate": "C5",
+ "title": "Optional parallel evaluator",
+ "verification": "Only independent record filters; reserved bounded tasks/reorder buffers, preserved order/errors and measured material gain.",
+ "obligation": "optional-extension",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL093",
+ "gate": "C5",
+ "title": "Optional Apple PDF/RTF CLI export",
+ "verification": "Only after existing export backend qualification; actual host, explicit async preparation/page capabilities and unsupported-host errors.",
+ "obligation": "optional-extension",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ },
+ {
+ "id": "CL094",
+ "gate": "C5",
+ "title": "Optional native binary distribution",
+ "verification": "Explicit packaging policy, architecture/resource/signature receipts; no publication/tag performed by this task.",
+ "obligation": "optional-extension",
+ "status": "not_run",
+ "evidence_required": true,
+ "fixture_ids": []
+ }
+ ],
+ "notes": [
+ "Package integrity is separate from native qualification.",
+ "Optional extensions do not block the scoped candidate when not claimed.",
+ "WASI CLI supported/blocked/limited disposition is mandatory; full CLI support is separately earned."
+ ]
+}
diff --git a/Documentation/Architecture/Release1.4/Foundation.md b/Documentation/Architecture/Release1.4/Foundation.md
new file mode 100644
index 0000000..9d5f7ac
--- /dev/null
+++ b/Documentation/Architecture/Release1.4/Foundation.md
@@ -0,0 +1,103 @@
+# CLI foundation
+
+This feature boundary implements format, strict validation, RFC 6901 selection,
+staged RFC 6902 application and HTML/text/Markdown rendering. It does not advertise
+the query engine, stream/schema command adapters or provider helpers before their
+own increments are qualified. The target release is 1.4.0; this is development source.
+
+## Composition and ownership
+
+`CLIJobContext: ~Copyable` lives in the private runtime target. Argv, native parsing,
+number projection, registry/plan admission, validation, Patch, rendering and writing
+borrow its one `JSONWorkMeter`. Package-only borrowed entry points introduce no new
+public library signatures. Switching the operation domain changes subsystem work
+accounting without replacing health or counters. Only per-value shape capacities
+reset; consumed work never resets. Patch refunds its local staging reservation and
+preserves ownership that preceded its invocation.
+
+CLI policy has 16 additional finite quotas. Core policy keeps exactly 49 metric
+identifiers. Effective work and logical-retention ceilings are the intersection of
+CLI and core ceilings. Configuration bootstraps under the finite offline profile,
+then validates requested caps against already consumed work and admitted capacities.
+Explicit finite overrides reuse the ledger. They cannot erase bootstrap input.
+
+Error/cancellation latches terminal health. Data paths cannot resume after failure.
+Diagnostics reserve finite work and buffer ownership before command execution;
+the bounded terminal serializer spends that reservation and cannot reopen the job.
+Reports distinguish provisional results from fully accepted stdout results and
+atomically installed file results. Logical retained bytes are not process RSS.
+
+## Native I/O
+
+The adapters poll nonblocking POSIX descriptors, check cancellation between polls,
+and handle short reads/writes, EINTR, EAGAIN, EOF and broken pipes explicitly.
+Filesystem/kernel work is foreign work; cancellation does not claim to interrupt
+a filesystem operation already executing in the kernel. Borrowed stdio flags are
+restored. The signal callback is explicitly `@Sendable`; a real subprocess test
+caught and fixed an inferred-actor dispatch assertion on SIGINT.
+
+File output uses an exclusive owned temporary in the destination directory.
+Installation happens after parsing, command evaluation, writing and close succeed.
+No-overwrite installation uses link/unlink; explicit overwrite uses rename.
+Existing destinations, final symlinks and input aliases/hard links are checked.
+Failures remove only the invocation's temporary and preserve the destination.
+Concurrent pathname replacement by another process is outside this adapter's
+transactional guarantee. There is no cross-filesystem fallback, mkdir, fsync or
+power-loss durability claim. Previously accepted stdout bytes cannot be recalled.
+
+## Checks
+
+Twelve meaningful Swift Testing functions include four parameter cases. The executable
+subprocess harness has 53 cases covering exact lexemes/scalar keys, strict errors,
+schema invalidity versus operational failure, bounded issues, Pointer null/absence,
+root removal, failed Patch staging, renderer selection, limits/reports, filesystem
+aliases, atomic cleanup and SIGINT while stdin is idle. The initial failure receipts
+are retained; the corrected subprocess lane passes all 53.
+
+The event receipt reader is reused from the separately qualified 1.3 export work
+at `1e0b86d2580bb9678039597523aa3b99d2905abf`. No export/PDF feature source is copied.
+The six-product checks retain exact target/dependency/toolchain/platform assertions,
+all baseline test bundle counts, 173 inherited parameter cases plus four CLI cases,
+and all 49 cap probe outcomes. Native/safety/docs qualification remains required
+for the committed source.
+
+## Compiler probes and review corrections
+
+The supported native compiler accepts an inout job borrow, rejects consuming the
+same job twice with the expected ownership diagnostic, and rejects access from an
+external package. The noncopyable initializer constructs its meter before the
+other stored assignments; this follows actual Swift 6.4 initialization rules.
+An initial default-CLT/cache attempt is unqualified and retained as blocked evidence;
+its negative exits are not ownership passes.
+
+Strict memory-safety compilation marks individual synchronous POSIX pointer and
+CString expressions `unsafe`. Byte pointers stay within `withUnsafeBytes` scopes;
+counts are checked against the array slice, poll/stat pointers address live local
+structures, and C strings are borrowed only for a synchronous syscall. No pointer
+escapes, suspension crosses a borrow, unsafe compiler option or blanket annotation
+is introduced.
+
+The SIGINT acceptance test waits for its exclusive staging file as a readiness
+signal and holds stdin open until exit. Closing stdin through `communicate()`
+immediately after SIGINT introduced a competing EOF and was corrected. The test
+still requires exit 130, no output, and complete staging cleanup.
+
+The final argument adapter reads process-owned C argv under the finite bootstrap
+ledger, rejects invalid UTF-8 instead of accepting replacement characters, and
+checks each byte before copying. Structured diagnostic preferences survive usage
+errors. Malformed/overflowing limit configuration is usage failure; exhaustion,
+cancellation and I/O remain operational. Missing array Pointer targets use a
+package-only presence adapter over the shared strict index decoder; malformed
+indices and wrong kinds stay errors. Existing public Pointer resolution retains
+its previous error contract. These review findings have dedicated regressions.
+
+Named inputs open with O_NONBLOCK from the initial syscall, so FIFO open does not
+wait indefinitely before cancellation handling begins. Subprocess cancellation
+covers both idle borrowed stdin and an owned named FIFO. Reports include actual
+enforced native caps, remaining cumulative work and profile/override origin.
+
+The terminal diagnostic builder checks each append before growth and discards an
+incomplete report before handoff. Zero forbids diagnostic output; small diagnostic
+quotas cannot produce broken JSONL. HTML-specific quotas map to resource exit 6;
+renderer configuration maps to usage exit 2. Typed schema compile/evaluation errors
+stay operational exit 5, with stable subsystem codes. These have explicit regressions.
diff --git a/Documentation/Architecture/Release1.4/Plan.md b/Documentation/Architecture/Release1.4/Plan.md
new file mode 100644
index 0000000..9ae86d6
--- /dev/null
+++ b/Documentation/Architecture/Release1.4/Plan.md
@@ -0,0 +1,40 @@
+# CLI release plan
+
+The maintainer-approved 1.4.0 train adds `swift-json` as an executable beside the
+five libraries. JSONFilterRuntime and JSONCLIEngine are package-private targets;
+JSONRegexRuntime remains private. Root external dependencies remain empty.
+Historical four/five-product releases and their evidence are unchanged.
+
+The CLI stack starts at the qualified JSONHTML renderer commit
+`3c1e8a1a1bc8d03699665b8ab98f5ece7962aff7`, PR #21. Its native, safety, docs and
+Linux x86_64/arm64 lanes passed. Main at orientation was
+`25fb04f747e583209b4c4511abf39e11ef5b4f80`. This train uses dependent feature
+branches and draft PRs; it does not change the parallel transfer/PDF or 1.2 work.
+
+| Gate | Cohesive implementation and acceptance |
+| --- | --- |
+| C0 | Source/protection/prerequisite audit, executable/private target shapes, one noncopyable job ledger |
+| C1 | Bounded argv/stdio/files, diagnostics/exits, atomic output, format/validate/Pointer/Patch, six-product inventory |
+| C2 | Original flat filter IR and pull VM, input framing, generators/paths/control/bindings/common builtins |
+| C3 | Private exact decimal arithmetic; explicit scale plus half-even division policy |
+| C4 | Qualified richer filters, lexical functions/reductions/path updates; explicit unsupported features |
+| C5 | Qualified renderer/schema/provider adapters, consumers, independent corpus/oracle, platform/distribution and final candidate |
+
+The planned stack is foundation, query-core, arithmetic, richer filters and
+integration. Each has a compiling boundary, exact acceptance receipts and a draft
+PR against its actual dependency. No public query library, eager legacy evaluator,
+remote resolver, shell executor, daemon or release action is introduced.
+
+The input briefing SHA-256 is
+`43f8819c57e3d93bc6f7cf561d2d111442e089f2973cb7c62e16e3bd3fd73d0d`.
+Its structural verifier counted 94 requirements, 111 new cases and 168 inherited
+cases; those are inventory counts, not execution successes. The jq 1.7 observations
+are historical references; differential claims require an actual pinned jq 1.8.2
+runner. Missing provider APIs/platform runners remain explicit blockers.
+
+Swift 6.4, language 6 and macOS/SDK 27 remain the native baseline. Mobile libraries
+must continue to compile independently of the executable. Linux is a process
+host; WASI executable feasibility is separate from the already qualified libraries.
+Native and sanitizer receipts, subprocess outcomes, commands, toolchain, source and
+binary identities accompany every qualified milestone. All 49 baseline probes and
+independent-suite exclusions remain required and separate from CLI additions.
diff --git a/Documentation/Architecture/Release1.4/Progress.json b/Documentation/Architecture/Release1.4/Progress.json
new file mode 100644
index 0000000..176a9e8
--- /dev/null
+++ b/Documentation/Architecture/Release1.4/Progress.json
@@ -0,0 +1,41 @@
+{
+ "schema_version": 1,
+ "target_release": "1.4.0",
+ "renderer_base": "3c1e8a1a1bc8d03699665b8ab98f5ece7962aff7",
+ "main_at_orientation": "25fb04f747e583209b4c4511abf39e11ef5b4f80",
+ "branch": "codex/1.4-json-cli-foundation",
+ "status": "Compiling foundation boundary qualified on native macOS; C0/C1 complete closure and C2-C5 remain pending",
+ "gates": {
+ "C0": "partial",
+ "C1": "partial",
+ "C2": "not_run",
+ "C3": "not_run",
+ "C4": "not_run",
+ "C5": "not_run"
+ },
+ "foundation_functions": 12,
+ "foundation_parameter_cases": 4,
+ "subprocess_cases": 53,
+ "subprocess_passed": 53,
+ "baseline_parameter_cases": 173,
+ "core_metrics": 49,
+ "cli_metrics": 16,
+ "publication_performed": false,
+ "root_test_functions": 232,
+ "root_parameter_cases": 177,
+ "native_source_manifest_sha256": "864d9b3dd8e1d79a0a6cbec862476843ddca2ff8a1582471b80fba54b863459e",
+ "qualified_lanes": [
+ "native",
+ "safety",
+ "docs"
+ ],
+ "remaining_foundation_requirements": [
+ "clean-source reproduction",
+ "selected mobile SDK consumers",
+ "immutable filter-plan compiler probe and implemented IR",
+ "all 16 CLI cap boundaries",
+ "multi-record shared accounting",
+ "slow/partial/no-progress sink probes",
+ "query compile exit 3 and full exit precedence"
+ ]
+}
diff --git a/Documentation/Architecture/Release1.4/Qualification.md b/Documentation/Architecture/Release1.4/Qualification.md
new file mode 100644
index 0000000..460214c
--- /dev/null
+++ b/Documentation/Architecture/Release1.4/Qualification.md
@@ -0,0 +1,50 @@
+# Foundation qualification boundary
+
+The foundation code and harness were qualified together under source manifest
+`864d9b3dd8e1d79a0a6cbec862476843ddca2ff8a1582471b80fba54b863459e`.
+The receipts identify the renderer base HEAD plus the actual edited-file hashes;
+this is pre-commit evidence, not a claim that the parent commit contains the CLI.
+Only this ledger, progress and qualification prose were subsequently updated.
+Production Swift, the package manifest and executed scripts match those receipts.
+
+Native environment: arm64 macOS 27.0; Swift 6.4
+(swiftlang-6.4.0.34.1), language mode 6, Xcode 27.2 (27B5019j), SDK 27.2.
+The configured beta Xcode is required on this host; the default CLT attempt was
+unqualified and is retained separately. No baseline or compiler check was lowered.
+
+| Command | Actual outcome |
+| --- | --- |
+| `python3 Scripts/ci.py --lane native --output .build/ci/cli-c1-reviewed-native` | Exit 0; all 18 commands passed; debug/release each 232 functions, 177 parameter invocations |
+| `python3 Scripts/ci.py --lane safety --output .build/ci/cli-c1-reviewed-safety` | Exit 0; ASan 232 functions/177 parameter invocations; TSan seven shared-state functions; strict-memory-safety build with warnings as errors |
+| `python3 Scripts/ci.py --lane docs --output .build/ci/cli-c1-reviewed-docs` | Exit 0; five DocC catalogues, coverage checks and compiled examples |
+| `python3 Scripts/qualify_cli.py --binary .build/release/swift-json --output …` | Exit 0; 53 real subprocess cases, no exclusions |
+| `python3 Scripts/qualify_cli_ownership.py --output …` | Exit 0; three compiler probes: borrow compiles; double consume and cross-package access fail with required diagnostics |
+
+The inherited 173 parameter cases remain unchanged; four CLI parameter cases are
+additional. All 49 baseline cap probes keep their recorded outcomes. Independent
+syntax qualification observes 318 cases: 287 evaluated successes and 31 policy
+cases. Schema qualification observes 2,337: 2,300 evaluated successes and 37 policy
+cases. Authored suites retain 82 public semantics, nine budget/counter cases and
+4,396 deterministic malformed-input replays. The downstream consumer retains 20
+explicitly rooted outcomes: eight positive, twelve negative, with two operational
+error outcomes distinguished from ordinary invalidity. These do not establish MCP
+server conformance.
+
+The three final lane receipts report unchanged source inputs while running. Earlier
+failed compiler, SIGINT actor-isolation, EOF-race, normalized-spelling expectation
+and strict-pointer-annotation attempts are retained alongside successful corrections.
+The expected normalized `1e-1` spelling follows the existing coefficient/exponent
+contract; no existing test was weakened.
+
+This is a reviewable foundation milestone. All 94 acceptance IDs remain in
+Acceptance.json. Partial/not_run rows are not successes: complete filter IR/VM,
+arithmetic/richer filters, all 16 CLI cap boundaries, split/slow/no-progress I/O,
+selected mobile/portable consumers and clean candidate reproduction remain pending.
+The renderer prerequisite is PR #21 at `3c1e8a1`; transfer/PDF work and the parallel
+1.2 train are unchanged. Provider bridge APIs are absent at this base; qualification
+and integration must precede their advertisement. No tag, merge or publication is
+performed by this boundary.
+
+Materialized receipts and their exact source-input records are in the local
+foundation evidence bundle. Run the listed commands to regenerate evidence; local
+build outputs and private input packets are excluded from public Git/source archives.
diff --git a/Documentation/README.md b/Documentation/README.md
index 44892ae..9e022d6 100644
--- a/Documentation/README.md
+++ b/Documentation/README.md
@@ -33,6 +33,8 @@ Compiled archives and public symbol graphs remain available in CI artifacts.
- [Linux platform and portable schema integrity](Architecture/Linux.md)
- [WebAssembly audit and unresolved qualification boundary](Architecture/WebAssemblyAudit.md)
+- [Prospective 1.4 CLI plan](Architecture/Release1.4/Plan.md) and [foundation contract](Architecture/Release1.4/Foundation.md)
+
## Consumers, qualification and maintenance
- [Five-product compiled example](../Examples/Consumer/README.md)
diff --git a/Package.swift b/Package.swift
index 4fbde36..c68db49 100644
--- a/Package.swift
+++ b/Package.swift
@@ -10,7 +10,8 @@ let package = Package(
.library(name: "JSONSchema", targets: ["JSONSchema"]),
.library(name: "JSONStreaming", targets: ["JSONStreaming"]),
.library(name: "JSONPatch", targets: ["JSONPatch"]),
- .library(name: "JSONHTML", targets: ["JSONHTML"])
+ .library(name: "JSONHTML", targets: ["JSONHTML"]),
+ .executable(name: "swift-json", targets: ["JSONCLI"])
],
targets: [
.target(name: "JSON"),
@@ -19,6 +20,10 @@ let package = Package(
.target(name: "JSONStreaming", dependencies: ["JSON"]),
.target(name: "JSONPatch", dependencies: ["JSON"]),
.target(name: "JSONHTML", dependencies: ["JSON"], exclude: ["Assets"]),
+ .target(name: "JSONFilterRuntime", dependencies: ["JSON"]),
+ .target(name: "JSONCLIEngine", dependencies: ["JSON", "JSONSchema", "JSONStreaming", "JSONPatch", "JSONHTML", "JSONFilterRuntime"]),
+ .executableTarget(name: "JSONCLI", dependencies: ["JSONCLIEngine"]),
+ .testTarget(name: "JSONCLITests", dependencies: ["JSONCLIEngine", "JSONFilterRuntime", "JSON", "JSONPatch", "JSONSchema", "JSONHTML"]),
.testTarget(name: "JSONHTMLTests", dependencies: ["JSONHTML", "JSON"]),
.testTarget(name: "JSONTests", dependencies: ["JSON"], exclude: ["ImplementationPlan.md"]),
.testTarget(name: "JSONSchemaTests", dependencies: ["JSONSchema"], exclude: ["ImplementationPlan.md"]),
diff --git a/README.md b/README.md
index 7ab8d4e..a6a0826 100644
--- a/README.md
+++ b/README.md
@@ -474,3 +474,19 @@ following [SECURITY](SECURITY.md); see [SUPPORT](SUPPORT.md) for maintenance and
Original code is licensed under [Apache-2.0](LICENSE). Adapted code and qualification
inputs retain their applicable [notices](NOTICE), [third-party notices](THIRD_PARTY_NOTICES.md),
[licenses](Licenses) and [extraction provenance](Documentation/Architecture/ExtractionManifest.json).
+
+## Prospective 1.4 command-line tool
+
+This feature train adds `swift-json` beside the five libraries. Its compiling
+foundation provides strict formatting, validation, Pointer selection, staged
+Patch and qualified HTML/text/Markdown rendering. See the [CLI plan](Documentation/Architecture/Release1.4/Plan.md)
+and [foundation contract](Documentation/Architecture/Release1.4/Foundation.md)
+for command semantics, cumulative budgets and qualification boundaries. Query and
+provider commands are advertised only after their separate gates pass.
+
+```sh
+swift build -c release --product swift-json
+.build/release/swift-json format --compact input.json
+.build/release/swift-json validate --schema schema.json input.json
+.build/release/swift-json render input.json --output inspection.html
+```
diff --git a/Scripts/ci.py b/Scripts/ci.py
index 6ed3220..5108e93 100644
--- a/Scripts/ci.py
+++ b/Scripts/ci.py
@@ -25,7 +25,7 @@ def commands(lane, output):
# Root behavior/corpora remain required. SwiftData and Apple SDK/lifetime
# probes are separate Apple acceptance; they never become Linux passes.
return [c for c in commands('native', ROOT / output)
- if not any(x in c for x in ['Tools/MobileQualification', '--mode'])] + [
+ if not any(x in c for x in ['Tools/MobileQualification', '--mode', 'Scripts/qualify_cli_ownership.py'])] + [
['python3', '-B', 'Scripts/qualify_linux_reproduction.py', '--output', str(output / 'reproduction')]]
if lane == 'linux-safety':
# Every behavior case uses Swift Testing. Do not start the generated
@@ -53,6 +53,8 @@ def commands(lane, output):
['swift', 'run', '-c', 'release', '--package-path', 'Tools/JSONHTMLBrowser', 'BrowserFixtures', str(output / 'fixtures')],
['python3', '-B', 'Scripts/qualify_html_browser.py', '--fixtures', str(output / 'fixtures'), '--output', str(output / 'browser')],
]
+ if lane == 'cli':
+ return [['swift', 'build', '-c', 'release', '--product', 'swift-json'], ['swift', 'test', '--filter', 'cli'], ['python3', '-B', 'Scripts/qualify_cli.py', '--binary', '.build/release/swift-json', '--output', str(output / 'subprocess.json')]]
if lane == 'native':
return [
['python3', '-B', 'Scripts/public_check.py'],
@@ -61,6 +63,8 @@ def commands(lane, output):
['swift', 'build', '-c', 'release'],
['python3', '-B', 'Scripts/verify_testing_events.py'],
['swift', 'test'], ['swift', 'test', '-c', 'release'],
+ ['python3', '-B', 'Scripts/qualify_cli.py', '--binary', '.build/release/swift-json', '--output', str(output / 'subprocess.json')],
+ ['python3', '-B', 'Scripts/qualify_cli_ownership.py', '--output', str(output / 'cli-ownership')],
['python3', '-B', 'Scripts/qualify_release_1_1.py', '--mode', 'ownership', '--output', str(output / 'ownership.json')],
['python3', '-B', 'Scripts/qualify_release_1_1.py', '--mode', 'reader', '--output', str(output / 'reader.json')],
['swift', 'run', '-c', 'release', '--package-path', 'Examples/Consumer', 'Consumer'],
@@ -112,10 +116,12 @@ def check_result(command, code, log, events=None):
if events is not None:
counts = events['bundle_counts']
if command[:2] == ['swift', 'test']:
- expected = [38] if 'export|Export|apple' in command else [14] if 'Tools/WasmAudit' in command else [2, 3, 3, 11] if 'qa' in command else [7] if R0_TESTS in command else [3] if 'Tools/MCPReadiness' in command or 'Tools/MobileQualification' in command else [1] if 'Tools/Qualification' in command else [1, 1, 3 if sys.platform == 'linux' else 4, 4] if 'thread' in command else sorted([11, 12, 14, 61 if sys.platform == 'linux' else 75, 51, 107])
+ expected = [12] if 'cli' in command else [38] if 'export|Export|apple' in command else [14] if 'Tools/WasmAudit' in command else [2, 3, 3, 11] if 'qa' in command else [7] if R0_TESTS in command else [3] if 'Tools/MCPReadiness' in command or 'Tools/MobileQualification' in command else [1] if 'Tools/Qualification' in command else [1, 1, 3 if sys.platform == 'linux' else 4, 4] if 'thread' in command else sorted([11, 12, 12, 14, 61 if sys.platform == 'linux' else 75, 51, 107])
passed = passed and sorted(counts) == expected
if '--filter' not in command and not any(x.startswith('Tools/') for x in command):
- passed = passed and (events['parameterized_functions'] == ROOT_PARAMETER_CASES if events is not None else sum(int(n) for n in re.findall(r'with (\d+) test cases passed', log)) == 173)
+ if events is not None:
+ passed = passed and events['module_function_counts'] == {'JSONTests':107,'JSONSchemaTests':51,'JSONStreamingTests':14,'JSONPatchTests':11,'JSONRegexRuntimeTests':12,'JSONHTMLTests':61 if sys.platform == 'linux' else 75,'JSONCLITests':12}
+ passed = passed and (events['parameterized_functions'] == ROOT_PARAMETER_CASES if events is not None else sum(int(n) for n in re.findall(r'with (\d+) test cases passed', log)) == 177)
if 'Tools/Qualification' in command:
probes = re.findall(r'^CAP_PROBE (\w+) (\S+)$', log, re.MULTILINE)
matrix = json.loads((ROOT / 'Documentation/Qualification/LimitsMatrix.json').read_text())
@@ -123,10 +129,10 @@ def check_result(command, code, log, events=None):
passed = passed and len(probes) == 49 and dict(probes) == expected_probes
if command == ['swift', 'package', 'dump-package'] and passed:
d = json.loads(log)
- passed = sorted(p['name'] for p in d['products']) == ['JSON', 'JSONHTML', 'JSONPatch', 'JSONSchema', 'JSONStreaming'] and not d['dependencies'] and d['swiftLanguageVersions'] == ['6'] and d['toolsVersion']['_version'] == '6.4.0' and d['platforms'] == [{'options': [], 'platformName': 'macos', 'version': '27.0'}, {'options': [], 'platformName': 'ios', 'version': '27.0'}]
- passed = passed and {p['name']: p['targets'] for p in d['products']} == {name: [name] for name in ['JSON', 'JSONSchema', 'JSONStreaming', 'JSONPatch', 'JSONHTML']}
+ passed = sorted(p['name'] for p in d['products']) == ['JSON', 'JSONHTML', 'JSONPatch', 'JSONSchema', 'JSONStreaming', 'swift-json'] and not d['dependencies'] and d['swiftLanguageVersions'] == ['6'] and d['toolsVersion']['_version'] == '6.4.0' and d['platforms'] == [{'options': [], 'platformName': 'macos', 'version': '27.0'}, {'options': [], 'platformName': 'ios', 'version': '27.0'}]
+ passed = passed and {p['name']: p['targets'] for p in d['products']} == dict({name: [name] for name in ['JSON', 'JSONSchema', 'JSONStreaming', 'JSONPatch', 'JSONHTML']}, **{'swift-json': ['JSONCLI']})
targets = {t['name']: t for t in d['targets']}
- passed = passed and set(targets) == {'JSON', 'JSONSchema', 'JSONStreaming', 'JSONPatch', 'JSONHTML', 'JSONRegexRuntime', 'JSONTests', 'JSONSchemaTests', 'JSONStreamingTests', 'JSONPatchTests', 'JSONHTMLTests', 'JSONRegexRuntimeTests'} and targets['JSONHTML']['dependencies'] == [{'byName': ['JSON', None]}]
+ passed = passed and set(targets) == {'JSON', 'JSONSchema', 'JSONStreaming', 'JSONPatch', 'JSONHTML', 'JSONRegexRuntime', 'JSONTests', 'JSONSchemaTests', 'JSONStreamingTests', 'JSONPatchTests', 'JSONHTMLTests', 'JSONRegexRuntimeTests', 'JSONFilterRuntime', 'JSONCLIEngine', 'JSONCLI', 'JSONCLITests'} and targets['JSONHTML']['dependencies'] == [{'byName': ['JSON', None]}] and targets['JSONFilterRuntime']['dependencies'] == [{'byName': ['JSON', None]}] and targets['JSONCLI']['type'] == 'executable'
if command == ['swift', 'package', 'show-dependencies', '--format', 'json'] and passed:
passed = json.loads(log)['dependencies'] == []
if command[:2] == ['swift', 'run'] and 'Tools/MobileQualification' in command:
@@ -143,7 +149,7 @@ def check_result(command, code, log, events=None):
def main():
parser = argparse.ArgumentParser(description=__doc__)
- parser.add_argument('--lane', choices=['native', 'safety', 'docs', 'r0', 'qa', 'linux', 'linux-safety', 'wasm', 'browser', 'export'], required=True)
+ parser.add_argument('--lane', choices=['native', 'safety', 'docs', 'r0', 'qa', 'linux', 'linux-safety', 'wasm', 'browser', 'export', 'cli'], required=True)
parser.add_argument('--output')
args = parser.parse_args()
output = ROOT / (args.output or '.build/ci/' + args.lane)
diff --git a/Scripts/qualify_cli.py b/Scripts/qualify_cli.py
new file mode 100644
index 0000000..8ce7f81
--- /dev/null
+++ b/Scripts/qualify_cli.py
@@ -0,0 +1,109 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+"""Exercise the real CLI subprocess, exact bytes, exits, stderr and atomic files."""
+import argparse, hashlib, json, os, pathlib, signal, subprocess, tempfile, time
+
+ROOT = pathlib.Path(__file__).resolve().parents[1]
+
+def main():
+ parser = argparse.ArgumentParser(); parser.add_argument('--binary', required=True); parser.add_argument('--output', required=True)
+ args = parser.parse_args(); binary = (ROOT / args.binary).resolve(); rows = []
+ def run(name, argv, data=b'', exit=0, expected=None, check=None):
+ command = [str(binary), *argv]; process = subprocess.run(command, input=data, capture_output=True, timeout=30)
+ ok = process.returncode == exit and (expected is None or process.stdout == expected)
+ if check: ok = ok and check(process)
+ rows.append({'id': name, 'command': ['swift-json', *[a if isinstance(a,str) else {'bytes_hex':a.hex()} for a in argv]], 'exit_code': process.returncode, 'expected_exit': exit,
+ 'stdout_sha256': hashlib.sha256(process.stdout).hexdigest(), 'stdout_bytes': len(process.stdout),
+ 'stderr_sha256': hashlib.sha256(process.stderr).hexdigest(), 'stderr_bytes': len(process.stderr), 'status': 'passed' if ok else 'failed'})
+ if not ok: print(name, process.returncode, repr(process.stdout[:250]), repr(process.stderr[:500]), flush=True)
+ return process
+ with tempfile.TemporaryDirectory(prefix='swift-json-cli-') as temp:
+ temp = pathlib.Path(temp)
+ def file(name, data):
+ path = temp / name; path.write_bytes(data); return str(path)
+ def limit(**caps): return file('limits.json', json.dumps({'version':1,'cli':caps}).encode())
+ run('help', ['--help'], check=lambda p: b'format' in p.stdout and not p.stderr)
+ run('invalid-argv-utf8', ['format', b'\xff'], exit=2, expected=b'', check=lambda p: b'invalidArgvUTF8' in p.stderr)
+ run('version', ['--version'], expected=b'swift-json 1.4.0-dev\n')
+ run('version-json', ['--version','--json'], check=lambda p: json.loads(p.stdout)['revision'] == 'unknown')
+ run('missing-command', [], exit=2, expected=b'')
+ run('unknown-option', ['format','--unknown'], exit=2, expected=b'')
+ run('usage-json-diagnostic', ['format','--diagnostics=json','--unknown'], exit=2, expected=b'', check=lambda p: json.loads(p.stderr)['kind'] == 'diagnostic' and json.loads(p.stderr)['category'] == 'usage')
+ run('duplicate-option', ['format','--compact','--compact'], exit=2, expected=b'')
+ run('indent-conflict', ['format','--compact','--tab'], exit=2, expected=b'')
+ run('preserved-numbers', ['format','--compact'], b'[9007199254740993,0.10,-0,1e1000]', expected=b'[9007199254740993,0.10,-0,1e1000]\n')
+ run('normalized-numbers', ['format','--compact','--number-style=normalized'], b'[0.10,-0]', expected=b'[1e-1,0]\n')
+ run('tab-indentation', ['format','--tab'], b'{"a":[1]}', expected=b'{\n\t"a": [\n\t\t1\n\t]\n}\n')
+ scalar = '{"é":1,"é":2}'.encode()
+ run('scalar-distinct-keys', ['format','-cS'], scalar, expected='{"é":2,"é":1}\n'.encode())
+ run('duplicate-decoded-key', ['format','--compact'], b'{"a":1,"\\u0061":2}', exit=5, expected=b'')
+ run('malformed-utf8', ['format'], b'"\xff"', exit=5, expected=b'')
+ run('trailing-root', ['format'], b'{} []', exit=5, expected=b'')
+ run('validation-syntax', ['validate'], b'{}', check=lambda p: json.loads(p.stdout) == {'valid':True,'issues':[],'truncated':False})
+ run('validation-malformed', ['validate'], b'{', exit=5, expected=b'')
+ schema = file('schema.json', b'{"type":"integer","minimum":3}')
+ run('schema-valid', ['validate','--schema',schema], b'4', check=lambda p: json.loads(p.stdout)['valid'] is True)
+ run('schema-invalid', ['validate','--schema',schema], b'2', exit=1, check=lambda p: json.loads(p.stdout)['valid'] is False and len(json.loads(p.stdout)['issues']) > 0)
+ run('schema-bounded-issues', ['validate','--schema',schema,'--max-issues','0'], b'2', exit=1, check=lambda p: json.loads(p.stdout) == {'valid':False,'issues':[],'truncated':True})
+ run('pointer-null', ['pointer','/a'], b'{"a":null}', expected=b'null\n')
+ run('pointer-missing', ['pointer','/a'], b'{}', exit=5, expected=b'')
+ run('pointer-allow-missing', ['pointer','/a','--allow-missing'], b'{}', exit=4, expected=b'')
+ run('pointer-array-absence', ['pointer','/0','--allow-missing'], b'[]', exit=4, expected=b'')
+ run('pointer-malformed-index-stays-error', ['pointer','/01','--allow-missing'], b'[]', exit=5, expected=b'')
+ run('pointer-wrong-type', ['pointer','/a','--allow-missing'], b'[]', exit=5, expected=b'')
+ run('pointer-escaped-key', ['pointer','/a~1b~0c'], b'{"a/b~c":1}', expected=b'1\n')
+ patch = file('patch.json', b'[{"op":"remove","path":""}]')
+ run('patch-root-absence', ['patch','--patch',patch], b'null', expected=b'')
+ patch = file('patch.json', b'[{"op":"add","path":"/b","value":9007199254740993}]')
+ run('patch-exact-value', ['patch','--patch',patch], b'{"a":1}', check=lambda p: b'9007199254740993' in p.stdout)
+ patch = file('patch.json', b'[{"op":"add","path":"/b","value":2},{"op":"test","path":"/a","value":0}]')
+ run('patch-failure-no-candidate', ['patch','--patch',patch], b'{"a":1}', exit=5, expected=b'')
+ run('html-invalid-title-is-usage', ['render','--title','\x01'], b'{}', exit=2, expected=b'')
+ run('static-html', ['render'], b'{"x":"\",\"n\":9007199254740993}\n",
+ "expected_exit": 0,
+ "comparison": "process-contract",
+ "status": "not_run",
+ "probe": {
+ "assert_no_script_element": true,
+ "assert_exact_value": true,
+ "assert_no_external_assets": true
+ }
+ },
+ {
+ "id": "render-markdown",
+ "gate": "C5",
+ "requirement_ids": [
+ "CL077"
+ ],
+ "command": "render",
+ "options": [
+ "--format",
+ "markdown"
+ ],
+ "operands": [],
+ "stdin_utf8": "{\"a\":[1.2300e+2]}\n",
+ "expected_exit": 0,
+ "comparison": "stdout-byte-exact",
+ "status": "not_run",
+ "expected_stdout_utf8": "```json\n{\n\t\"a\": [\n\t\t1.2300e+2\n\t]\n}\n```\n"
+ }
+ ]
+}
diff --git a/Tests/JSONCLITests/QueryBudgetTests.swift b/Tests/JSONCLITests/QueryBudgetTests.swift
new file mode 100644
index 0000000..e7e6e2f
--- /dev/null
+++ b/Tests/JSONCLITests/QueryBudgetTests.swift
@@ -0,0 +1,109 @@
+// SPDX-License-Identifier: Apache-2.0
+import Testing
+import JSON
+@testable import JSONFilterRuntime
+
+@Test(arguments: CLIResourceMetric.allCases)
+func cliEveryCounterHasInclusiveCheckedBoundaryAndTerminalFailure(metric: CLIResourceMetric) throws {
+ var limits = CLILimits(); limits[metric] = 3
+ var context = try CLIJobContext(limits: limits)
+ try context.charge(metric, 3)
+ #expect(context.used(metric) == 3)
+ do { try context.charge(metric); Issue.record("Expected cap+1 rejection") }
+ catch let error as CLIError { #expect(error.category == .resource && error.metric == metric.rawValue) }
+ #expect(throws: CLIError.self) { try context.checkpoint() }
+}
+@Test(arguments: [CLIResourceMetric.querySourceBytes, .queryTokens, .astNodes, .queryDepth])
+func cliCompilerEnforcesCapsAtActualSourceTokenAndIRGrowth(metric: CLIResourceMetric) throws {
+ var limits = CLILimits(); limits[metric] = 1
+ var allowed = try CLIJobContext(limits: limits)
+ let program = try FilterCompiler.compile(".", context: &allowed)
+ #expect(program.nodes.count == 1)
+ limits[metric] = 0
+ var blocked = try CLIJobContext(limits: limits)
+ do { _ = try FilterCompiler.compile(".", context: &blocked); Issue.record("Expected actual compiler admission failure") }
+ catch let failure as CLIError { #expect(failure.category == .resource && failure.metric == metric.rawValue) }
+}
+@Test func cliParserDepthUsesConfiguredWorkStackAndRejectsWithoutRecursion() throws {
+ var limits = CLILimits(); limits[.queryDepth] = 64
+ var context = try CLIJobContext(limits: limits)
+ let source = String(repeating: "(", count: 65) + "." + String(repeating: ")", count: 65)
+ do { _ = try FilterCompiler.compile(source, context: &context); Issue.record("Expected depth cap") }
+ catch let failure as CLIError { #expect(failure.metric == "queryDepth") }
+}
+@Test func cliRuntimeFramesAndBindingsAreLiveOwnedCaps() throws {
+ var limits = CLILimits(); limits[.runtimeFrames] = 0
+ var context = try CLIJobContext(limits: limits)
+ let program = try FilterCompiler.compile(".", context: &context)
+ do { _ = try FilterVM(program: program, input: .init(value: .null), context: &context); Issue.record("Expected frame cap before growth") }
+ catch let failure as CLIError { #expect(failure.metric == "runtimeFrames") }
+}
+@Test func cliQueryPlanIsImmutableAndCheckedSendable() throws {
+ func requireSendable(_ value: T) {}
+ var context = try CLIJobContext()
+ let program = try FilterCompiler.compile(".a, .b", context: &context)
+ requireSendable(program)
+ #expect(program.nodes.count > 1 && program.sourceRanges.count == program.nodes.count)
+}
+
+@Test func cliQueryOperationalFailureBypassesTryAndCleansInvocationStorage() throws {
+ var compilation = try CLIJobContext()
+ let program = try FilterCompiler.compile("try [1,2,3] catch null", context: &compilation)
+ var limits = CLILimits(); limits[.collectionValues] = 2
+ var context = try CLIJobContext(limits: limits)
+ let baseline = context.meter.used(.retainedBytes)
+ var vm = try FilterVM(program: program, input: .init(value: .null), context: &context)
+ struct NoInput: FilterInput { mutating func next(context: inout CLIJobContext) throws -> FilterYield? { nil } }
+ var input = NoInput()
+ do { _ = try vm.next(input: &input, context: &context); Issue.record("Resource failure must not become catch null") }
+ catch let failure as CLIError { #expect(failure.category == .resource && failure.metric == "collectionValues") }
+ try vm.close(context: &context)
+ #expect(context.used(.runtimeFrames) == 0 && context.used(.collectionValues) == 0)
+ #expect(context.meter.used(.retainedBytes) == baseline)
+ #expect(throws: CLIError.self) { try context.checkpoint() }
+}
+@Test func cliQueryCancellationHappensInsideOwnedEvaluationAndCleansFrames() async throws {
+ var compilation = try CLIJobContext()
+ let program = try FilterCompiler.compile(".[]", context: &compilation)
+ let task = Task {
+ var context = try CLIJobContext()
+ let baseline = context.meter.used(.retainedBytes)
+ var value = try FilterValues.produced(.array((0..<100).map { .number(JSONNumber(integer: $0)) }), context: &context)
+ var vm = try FilterVM(program: program, input: value, context: &context)
+ try value.release(context: &context)
+ struct NoInput: FilterInput { mutating func next(context: inout CLIJobContext) throws -> FilterYield? { nil } }
+ var input = NoInput()
+ var pending = try vm.next(input: &input, context: &context)
+ var first = try #require(pending); pending = nil
+ try first.release(context: &context)
+ context.meter.checkpointObserver = { _ in withUnsafeCurrentTask { $0?.cancel() } }
+ #expect(throws: CancellationError.self) { _ = try vm.next(input: &input, context: &context) }
+ try vm.close(context: &context)
+ #expect(context.used(.runtimeFrames) == 0 && context.used(.collectionValues) == 0)
+ #expect(context.meter.used(.retainedBytes) == baseline)
+ }
+ try await task.value
+}
+
+@Test func cliQueryConstructorsAndSelectorsReleaseScratchAfterMidOperationFailure() throws {
+ let object = try JSONParser().parse(Array("{\"a\":1,\"b\":2,\"c\":3,\"d\":4,\"e\":5,\"f\":6}".utf8))
+ let array = JSON.array((0..<20).map { .number(JSONNumber(integer: $0)) })
+ struct NoInput: FilterInput { mutating func next(context: inout CLIJobContext) throws -> FilterYield? { nil } }
+ for (source, value) in [("keys", object), (".[1:15]", array), ("map_values(.)", object), ("{a: .a,b: .b}", object), ("try error(.) catch .", object)] {
+ var compilation = try CLIJobContext()
+ let program = try FilterCompiler.compile(source, context: &compilation)
+ var rejected = 0
+ for cap: UInt64 in [360, 720, 1440, 2880] {
+ var limits = CLILimits(); limits[.retainedBytes] = cap
+ var context = try CLIJobContext(limits: limits)
+ var vm = try FilterVM(program: program, input: .init(value: value), context: &context)
+ var input = NoInput()
+ do { while var result = try vm.next(input: &input, context: &context) { try result.release(context: &context) } }
+ catch { rejected += 1 }
+ try vm.close(context: &context)
+ #expect(context.used(.runtimeFrames) == 0 && context.used(.collectionValues) == 0)
+ #expect(context.meter.used(.retainedBytes) == 0, "\(source) cap=\(cap)")
+ }
+ #expect(rejected > 0)
+ }
+}
diff --git a/Tests/JSONCLITests/QueryCoreTests.swift b/Tests/JSONCLITests/QueryCoreTests.swift
new file mode 100644
index 0000000..ef22c05
--- /dev/null
+++ b/Tests/JSONCLITests/QueryCoreTests.swift
@@ -0,0 +1,115 @@
+// SPDX-License-Identifier: Apache-2.0
+import Testing
+import JSON
+@testable import JSONFilterRuntime
+
+private struct EmptyFilterInput: FilterInput {
+ mutating func next(context: inout CLIJobContext) throws -> FilterYield? { nil }
+}
+private func evaluateFilter(_ source: String, input: String = "null") throws -> [JSON] {
+ var context = try CLIJobContext()
+ let program = try FilterCompiler.compile(source, context: &context)
+ let entry = context.meter.used(.retainedBytes)
+ let value = try JSONParser().parse(Array(input.utf8), meter: &context.meter)
+ let owned = context.meter.used(.retainedBytes) - entry
+ let lease = try CLIValueLease(ownedRetained: owned, context: &context)
+ var vm = try FilterVM(program: program, input: .init(value: value, lease: lease), context: &context)
+ defer { try? vm.close(context: &context) }
+ var input = EmptyFilterInput(), values: [JSON] = []
+ while var result = try vm.next(input: &input, context: &context) {
+ values.append(result.value)
+ try result.release(context: &context)
+ }
+ return values
+}
+@Test func cliQueryCommaAndPipeAreOrderedPullStreams() throws {
+ #expect(try evaluateFilter("1,2 | .") == [.number(1), .number(2)])
+ #expect(try evaluateFilter(".[] | .", input: "[1,2,3]") == [.number(1), .number(2), .number(3)])
+ #expect(try evaluateFilter("[1,2,3]") == [.array([.number(1), .number(2), .number(3)])])
+}
+@Test func cliQueryDecodedScalarKeysAndPresenceStayExact() throws {
+ let input = "{\"é\":1,\"é\":2,\"null\":null}"
+ #expect(try evaluateFilter(".[\"é\"], .[\"é\"]", input: input) == [.number(1), .number(2)])
+ #expect(try evaluateFilter("has(\"null\"),has(\"missing\")", input: input) == [.boolean(true), .boolean(false)])
+ #expect(try evaluateFilter(".missing?", input: input) == [.null])
+}
+@Test func cliQueryWrongTypesAreCatchableButEmptyIsNotNull() throws {
+ #expect(try evaluateFilter(".[]?", input: "null").isEmpty)
+ #expect(try evaluateFilter("try .[] catch .", input: "null") == [.string("cannotIterate")])
+ #expect(try evaluateFilter("empty // 9") == [.number(9)])
+ #expect(try evaluateFilter("(false,null,0) // 9") == [.number(0)])
+}
+@Test func cliQueryLogicalShortCircuitAndBranchesUseOriginalInput() throws {
+ #expect(try evaluateFilter("false and error(\"unreachable\")") == [.boolean(false)])
+ #expect(try evaluateFilter("true or error(\"unreachable\")") == [.boolean(true)])
+ #expect(try evaluateFilter("if (true,false) then . else null end", input: "7") == [.number(7), .null])
+ #expect(try evaluateFilter("if . == 0 then 0 elif . == 1 then 2 else 3 end", input: "1") == [.number(2)])
+}
+@Test func cliQueryMapsKeepAllResultsAndFirstUpdatePolicy() throws {
+ #expect(try evaluateFilter("map((.,.))", input: "[1,2]") == [.array([.number(1), .number(1), .number(2), .number(2)])])
+ #expect(try evaluateFilter("map_values((.,9))", input: "[1,2]") == [.array([.number(1), .number(2)])])
+ #expect(try evaluateFilter("map_values(empty)", input: "[1,2]") == [.array([])])
+}
+@Test func cliQueryUnicodeLengthCountsScalarsAndRecursiveNullLeaves() throws {
+ #expect(try evaluateFilter("length,utf8bytelength", input: "\"é🦊\"") == [.number(3), .number(7)])
+ #expect(try evaluateFilter("..", input: "[null,1]") == [.array([.null, .number(1)]), .null, .number(1)])
+}
+@Test func cliQueryAliasesKeepSourceChargedUntilTheirLastRelease() throws {
+ var context = try CLIJobContext()
+ let baseline = context.meter.used(.retainedBytes)
+ var value = try FilterValues.produced(.array([.string(String(repeating: "x", count: 1000))]), context: &context)
+ var alias = value.selecting(value.value.arrayValue![0])
+ try value.release(context: &context)
+ #expect(context.meter.used(.retainedBytes) > baseline)
+ try alias.release(context: &context)
+ #expect(context.meter.used(.retainedBytes) == baseline)
+}
+@Test func cliQueryTerminalQuotaStillReleasesValueStorage() throws {
+ var limits = CLILimits(); limits[.totalWorkUnits] = 2000
+ var context = try CLIJobContext(limits: limits)
+ let baseline = context.meter.used(.retainedBytes)
+ var value = try FilterValues.produced(.string("owned"), context: &context)
+ do { try context.work(2000); Issue.record("Expected terminal work failure") } catch let failure as CLIError { #expect(failure.category == .resource) }
+ try value.release(context: &context)
+ #expect(context.meter.used(.retainedBytes) == baseline)
+ #expect(throws: CLIError.self) { try context.checkpoint() }
+}
+@Test func cliQueryObjectsUseCartesianOrderAndExactReplacement() throws {
+ let values = try evaluateFilter("{a:(1,2),b:(3,4)}")
+ let expected = try ["{\"a\":1,\"b\":3}","{\"a\":1,\"b\":4}","{\"a\":2,\"b\":3}","{\"a\":2,\"b\":4}"].map { try JSONParser().parse($0) }
+ #expect(values == expected)
+ let replacement = try evaluateFilter("{a:1,b:2,a:3}")
+ #expect(replacement[0].objectValue!.members.map(\.key.string) == ["a","b"])
+ #expect(replacement[0].objectValue![JSONKey("a")] == .number(3))
+ #expect(try evaluateFilter("{\"é\":1,\"é\":2}")[0].objectValue!.count == 2)
+}
+@Test func cliQuerySlicesUseScalarBoundariesAndCheckedNegativeIndices() throws {
+ #expect(try evaluateFilter(".[1:3]", input: "\"é🦊x\"") == [.string("́🦊")])
+ #expect(try evaluateFilter(".[-2:]", input: "[1,2,3]") == [.array([.number(2),.number(3)])])
+ #expect(try evaluateFilter(".[-1],.[1e1000]", input: "[1,2,3]") == [.number(3),.null])
+}
+@Test func sharedFilterPlanHasIndependentConcurrentInvocations() async throws {
+ var compilation = try CLIJobContext()
+ let program = try FilterCompiler.compile(".a, .b", context: &compilation)
+ let outputs = try await withThrowingTaskGroup(of: [JSON].self, returning: [[JSON]].self) { group in
+ for _ in 0..<8 {
+ group.addTask {
+ var context = try CLIJobContext()
+ let input = try JSONParser().parse("{\"a\":1,\"b\":2}")
+ var value = try FilterValues.produced(input, context: &context)
+ var vm = try FilterVM(program: program, input: value, context: &context), source = EmptyFilterInput()
+ defer { try? vm.close(context: &context) }
+ try value.release(context: &context)
+ var results: [JSON] = []
+ while var result = try vm.next(input: &source, context: &context) { results.append(result.value); try result.release(context: &context) }
+ #expect(context.used(.totalWorkUnits) > 0)
+ #expect(context.meter.used(.retainedBytes) == 0)
+ return results
+ }
+ }
+ var values: [[JSON]] = []
+ for try await value in group { values.append(value) }
+ return values
+ }
+ #expect(outputs.count == 8 && outputs.allSatisfy { $0 == [.number(1), .number(2)] })
+}
diff --git a/Tests/JSONCLITests/QueryInputTests.swift b/Tests/JSONCLITests/QueryInputTests.swift
new file mode 100644
index 0000000..ab77db2
--- /dev/null
+++ b/Tests/JSONCLITests/QueryInputTests.swift
@@ -0,0 +1,83 @@
+// SPDX-License-Identifier: Apache-2.0
+import Foundation
+import Testing
+import JSON
+@testable import JSONCLIEngine
+@testable import JSONFilterRuntime
+
+private func withInputFile(_ bytes: [UInt8], _ body: (String) throws -> T) throws -> T {
+ let root = FileManager.default.temporaryDirectory.appendingPathComponent("json-query-" + UUID().uuidString)
+ try FileManager.default.createDirectory(at: root, withIntermediateDirectories: false)
+ defer { try? FileManager.default.removeItem(at: root) }
+ let path = root.appendingPathComponent("input.json")
+ try Data(bytes).write(to: path)
+ return try body(path.path)
+}
+@Test func cliQueryValueFramingRequiresWhitespaceAndIndependentFileEOF() throws {
+ try withInputFile(Array("1 2\n{}".utf8)) { path in
+ var context = try CLIJobContext(), cursor = CLIInputCursor(files: [path,path])
+ defer { try? cursor.close(context: &context) }
+ var values: [JSON] = []
+ while var value = try cursor.next(context: &context) { values.append(value.value); try value.release(context: &context) }
+ #expect(values.count == 6 && values[0] == .number(1) && values[3] == .number(1))
+ }
+ try withInputFile(Array("{}[]".utf8)) { path in
+ var context = try CLIJobContext(), cursor = CLIInputCursor(files: [path])
+ defer { try? cursor.close(context: &context) }
+ #expect(throws: JSONFailure.self) { _ = try cursor.next(context: &context) }
+ }
+}
+@Test func cliQueryDocumentWaitsForEOFAndTailErrorsAreTerminal() throws {
+ try withInputFile(Array("1 2".utf8)) { path in
+ var context = try CLIJobContext(), cursor = CLIInputCursor(files: [path], framing: .document)
+ defer { try? cursor.close(context: &context) }
+ #expect(throws: JSONFailure.self) { _ = try cursor.next(context: &context) }
+ #expect(throws: CLIError.self) { _ = try cursor.next(context: &context) }
+ }
+ try withInputFile(Array("1\n{\"bad\":]".utf8)) { path in
+ var context = try CLIJobContext(), cursor = CLIInputCursor(files: [path])
+ defer { try? cursor.close(context: &context) }
+ let maybeFirst = try cursor.next(context: &context); var first = try #require(maybeFirst); #expect(first.value == .number(1)); try first.release(context: &context)
+ #expect(throws: JSONFailure.self) { try cursor.drain(context: &context) }
+ }
+}
+@Test func cliQueryStrictNDJSONAndRawLinesPreserveTheirDifferentContracts() throws {
+ try withInputFile(Array("1\n\n2\n".utf8)) { path in
+ var context = try CLIJobContext(), cursor = CLIInputCursor(files: [path], framing: .ndjson)
+ defer { try? cursor.close(context: &context) }
+ let maybeFirst = try cursor.next(context: &context); var first = try #require(maybeFirst); #expect(first.value == .number(1)); try first.release(context: &context)
+ #expect(throws: JSONFailure.self) { _ = try cursor.next(context: &context) }
+ }
+ try withInputFile(Array("a\r\n\n🦊".utf8)) { path in
+ var context = try CLIJobContext(), cursor = CLIInputCursor(files: [path], framing: .rawLines)
+ defer { try? cursor.close(context: &context) }
+ var values: [JSON] = []
+ while var value = try cursor.next(context: &context) { values.append(value.value); try value.release(context: &context) }
+ #expect(values == [.string("a"), .string(""), .string("🦊")])
+ }
+}
+@Test func cliQueryRootArrayYieldsProvisionallyAndRequiresClosingEOF() throws {
+ try withInputFile(Array("[1,2".utf8)) { path in
+ var context = try CLIJobContext(), cursor = CLIInputCursor(files: [path], framing: .array)
+ defer { try? cursor.close(context: &context) }
+ let maybeFirst = try cursor.next(context: &context); var first = try #require(maybeFirst); #expect(first.value == .number(1)); try first.release(context: &context)
+ let maybeSecond = try cursor.next(context: &context); var second = try #require(maybeSecond); #expect(second.value == .number(2)); try second.release(context: &context)
+ #expect(throws: JSONFailure.self) { _ = try cursor.next(context: &context) }
+ }
+}
+@Test(arguments: [2000, 20000]) func cliQueryManyTinyRecordsDoNotRetainTheWholeInputJob(records: Int) throws {
+ try withInputFile(Array(String(repeating: "0\n", count: records).utf8)) { path in
+ var context = try CLIJobContext(), cursor = CLIInputCursor(files: [path])
+ defer { try? cursor.close(context: &context) }
+ var count = 0
+ while var value = try cursor.next(context: &context) { count += 1; try value.release(context: &context) }
+ #expect(count == records)
+ #expect(context.meter.used(.retainedBytes) == 0)
+ // One 16 KiB syscall buffer may overlap one accepted 16 KiB chunk;
+ // the completed scalar/lease has a small fixed reservation. This bound
+ // follows the actual adapter, rather than an arbitrary RSS threshold.
+ let chunk = min(UInt64(16384), context.limits.core[.chunkBytes])
+ #expect(context.meter.statistics().peakLogicalRetainedBytes <= 2 * chunk + 256)
+ #expect(context.used(.totalRecords) == UInt64(records) && context.used(.totalWorkUnits) > UInt64(records))
+ }
+}
diff --git a/Tools/CLIQualification/Package.swift b/Tools/CLIQualification/Package.swift
new file mode 100644
index 0000000..7d084fa
--- /dev/null
+++ b/Tools/CLIQualification/Package.swift
@@ -0,0 +1,9 @@
+// swift-tools-version: 6.4
+// SPDX-License-Identifier: Apache-2.0
+import PackageDescription
+let package = Package(name: "CLIQualification", platforms: [.macOS("27.0")],
+ products: [.executable(name: "CLIExactCompare", targets: ["CLIExactCompare"])],
+ dependencies: [.package(name: "Swift-JSON", path: "../..")],
+ targets: [.executableTarget(name: "CLIExactCompare", dependencies: [
+ .product(name: "JSON", package: "Swift-JSON"), .product(name: "JSONStreaming", package: "Swift-JSON")])],
+ swiftLanguageModes: [.v6])
diff --git a/Tools/CLIQualification/Sources/CLIExactCompare/Main.swift b/Tools/CLIQualification/Sources/CLIExactCompare/Main.swift
new file mode 100644
index 0000000..8b656bb
--- /dev/null
+++ b/Tools/CLIQualification/Sources/CLIExactCompare/Main.swift
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: Apache-2.0
+import Foundation
+import JSON
+import JSONStreaming
+#if canImport(Darwin)
+import Darwin
+#else
+import Glibc
+#endif
+
+private struct Bytes: AsyncSequence {
+ typealias Element = JSONByteChunk
+ let bytes: [UInt8]
+ struct Iterator: AsyncIteratorProtocol {
+ let bytes: [UInt8]
+ var index = 0
+ mutating func next() async -> JSONByteChunk? {
+ guard index < bytes.count else { return nil }
+ let end = Swift.min(index + 16384, bytes.count)
+ defer { index = end }
+ return .init(Array(bytes[index.. Iterator { .init(bytes: bytes) }
+}
+@main struct CLIExactCompare {
+ static func main() async {
+ do {
+ let arguments = CommandLine.arguments
+ guard arguments.count == 3 else { throw NSError(domain: "qualification", code: 2) }
+ let actual = try bounded(arguments[1]), expected = try bounded(arguments[2])
+ let declaration = try JSONParser().parse(expected)
+ guard case .array(let texts) = declaration else { throw NSError(domain: "qualification", code: 2) }
+ // CLI result streams may be empty. The library's value sequence
+ // requires a record; verify the zero-result contract explicitly.
+ if texts.isEmpty {
+ guard actual.allSatisfy({ [9,10,13,32].contains($0) }) else { throw NSError(domain: "qualification", code: 1) }
+ print("NATIVE_EXACT_COMPARE passed values=0"); return
+ }
+ var iterator = JSONValueSequence(Bytes(bytes: actual), options: .init(framing: .whitespaceSeparatedValues)).makeAsyncIterator()
+ var count = 0
+ for text in texts {
+ guard case .string(let raw) = text, let actual = try await iterator.next() else { throw NSError(domain: "qualification", code: 1) }
+ let expected = try JSONParser().parse(raw)
+ guard try JSONComparison.equals(actual, expected) else { throw NSError(domain: "qualification", code: 1) }
+ count += 1
+ }
+ guard try await iterator.next() == nil else { throw NSError(domain: "qualification", code: 1) }
+ print("NATIVE_EXACT_COMPARE passed values=\(count)")
+ } catch { fputs("NATIVE_EXACT_COMPARE failed\n", stderr); exit(1) }
+ }
+ private static func bounded(_ path: String) throws -> [UInt8] {
+ let handle = try FileHandle(forReadingFrom: URL(fileURLWithPath: path))
+ defer { try? handle.close() }
+ var bytes: [UInt8] = []
+ while let data = try handle.read(upToCount: 16384), !data.isEmpty {
+ guard bytes.count + data.count <= 33554432 else { throw NSError(domain: "qualification", code: 2) }
+ bytes.append(contentsOf: data)
+ }
+ return bytes
+ }
+}
From 1e82158de754888eda1b22566c1e7260470eeaed Mon Sep 17 00:00:00 2001
From: Thorsten Fuchs <76904008+ThorFuchs@users.noreply.github.com>
Date: Wed, 14 Oct 2026 18:09:05 +0200
Subject: [PATCH 3/6] fix(qualification): avoid mutable Glibc stderr in exact
consumer
---
Documentation/Architecture/Release1.4/Qualification.md | 10 ++++++++++
.../Sources/CLIExactCompare/Main.swift | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/Documentation/Architecture/Release1.4/Qualification.md b/Documentation/Architecture/Release1.4/Qualification.md
index ededc33..b3d4622 100644
--- a/Documentation/Architecture/Release1.4/Qualification.md
+++ b/Documentation/Architecture/Release1.4/Qualification.md
@@ -79,3 +79,13 @@ source remains identical; final C5 qualification will use the integration head.
The inherited 168 corpus rows and auxiliary binding modes still need their complete
mode-specific dispositions. Arithmetic and advanced filters have separate gates.
No simulator/device, Linux or WASI CLI success is inferred from this local run.
+
+
+Hosted C2 Linux runs on x86_64/ARM64 passed 256 root functions/199 parameter cases,
+ASan/TSan safety and the 53 CLI subprocess cases, then the comparator failed to
+compile: Glibc's mutable `stderr` global is not concurrency-safe in async main.
+The qualification tool now writes bounded failure text through
+FileHandle.standardError. No unsafe annotation/flag or library behavior changed.
+Failed run 38593758299 and its actual compiler log are retained; a fresh hosted
+run is required before Linux closure. Local comparator rebuild and all 38 C2
+vectors verify the diagnostic-only fix on the supported Mac.
diff --git a/Tools/CLIQualification/Sources/CLIExactCompare/Main.swift b/Tools/CLIQualification/Sources/CLIExactCompare/Main.swift
index 8b656bb..0a9ae2f 100644
--- a/Tools/CLIQualification/Sources/CLIExactCompare/Main.swift
+++ b/Tools/CLIQualification/Sources/CLIExactCompare/Main.swift
@@ -47,7 +47,7 @@ private struct Bytes: AsyncSequence {
}
guard try await iterator.next() == nil else { throw NSError(domain: "qualification", code: 1) }
print("NATIVE_EXACT_COMPARE passed values=\(count)")
- } catch { fputs("NATIVE_EXACT_COMPARE failed\n", stderr); exit(1) }
+ } catch { FileHandle.standardError.write(Data("NATIVE_EXACT_COMPARE failed\n".utf8)); exit(1) }
}
private static func bounded(_ path: String) throws -> [UInt8] {
let handle = try FileHandle(forReadingFrom: URL(fileURLWithPath: path))
From bcb2a9735bb6de67c9096f44d7494d3d5b73fc8a Mon Sep 17 00:00:00 2001
From: Thorsten Fuchs <76904008+ThorFuchs@users.noreply.github.com>
Date: Wed, 14 Oct 2026 19:03:23 +0200
Subject: [PATCH 4/6] feat(cli): add bounded exact decimal arithmetic and pull
range
---
.../Architecture/ExtractionManifest.json | 5 +-
.../Architecture/Release1.4/Acceptance.json | 76 +-
.../Architecture/Release1.4/Arithmetic.md | 59 +
.../Architecture/Release1.4/Progress.json | 34 +-
.../Architecture/Release1.4/Qualification.md | 32 +
README.md | 7 +-
Scripts/ci.py | 20 +-
Scripts/generate_arithmetic_oracle.py | 58 +
Scripts/qualify_cli_cases.py | 12 +-
Scripts/qualify_cli_limits.py | 42 +
.../JSON/Documentation.docc/CommandLine.md | 25 +-
Sources/JSONCLIEngine/CLIDiagnostics.swift | 24 +-
Sources/JSONCLIEngine/CLIEngine.swift | 5 +-
Sources/JSONCLIEngine/CLIQueryCommand.swift | 11 +-
Sources/JSONFilterRuntime/CLIJobContext.swift | 19 +-
.../JSONFilterRuntime/DecimalMagnitude.swift | 160 +
Sources/JSONFilterRuntime/ExactDecimal.swift | 184 +
.../JSONFilterRuntime/FilterCompiler.swift | 22 +-
.../JSONFilterRuntime/FilterOperators.swift | 134 +
Sources/JSONFilterRuntime/FilterVM.swift | 57 +-
Sources/JSONFilterRuntime/FilterValues.swift | 6 +
Sources/JSONFilterRuntime/RangeState.swift | 28 +
Tests/Fixtures/CLI/ArithmeticOracle.json | 5858 +++++++++++++++++
Tests/JSONCLITests/ArithmeticTests.swift | 147 +
24 files changed, 6964 insertions(+), 61 deletions(-)
create mode 100644 Documentation/Architecture/Release1.4/Arithmetic.md
create mode 100644 Scripts/generate_arithmetic_oracle.py
create mode 100644 Scripts/qualify_cli_limits.py
create mode 100644 Sources/JSONFilterRuntime/DecimalMagnitude.swift
create mode 100644 Sources/JSONFilterRuntime/ExactDecimal.swift
create mode 100644 Sources/JSONFilterRuntime/FilterOperators.swift
create mode 100644 Sources/JSONFilterRuntime/RangeState.swift
create mode 100644 Tests/Fixtures/CLI/ArithmeticOracle.json
create mode 100644 Tests/JSONCLITests/ArithmeticTests.swift
diff --git a/Documentation/Architecture/ExtractionManifest.json b/Documentation/Architecture/ExtractionManifest.json
index 4d9844a..8047a0b 100644
--- a/Documentation/Architecture/ExtractionManifest.json
+++ b/Documentation/Architecture/ExtractionManifest.json
@@ -209,5 +209,8 @@
"framework_boundary": "Conditional CoreTransferable/UniformTypeIdentifiers plus a narrow explicit main-actor Apple PDF boundary using WebKit, CoreText, CoreGraphics and AppKit/UIKit paragraph styles. Core JSON imports none of these; no new root dependency.",
"rtf": "Original bounded strict-token emitter; AppKit/UIKit native decoding only in tests and qualification consumers, not generation.",
"pdf": "Original invocation-owned lifecycle, finite adapter accounting and visible-range pagination using Apple SDK APIs. PDFKit is independent qualification only; no third-party renderer adapted."
- }
+ },
+ "original_notes": [
+ "1.4 C3 decimal magnitude, rational/quantization kernel, pull range and type-directed overloads are original Apache-2.0 code. The 738-case deterministic oracle uses Python integer/Fraction arithmetic; no jq/Rhoe arithmetic implementation was copied."
+ ]
}
diff --git a/Documentation/Architecture/Release1.4/Acceptance.json b/Documentation/Architecture/Release1.4/Acceptance.json
index d61ac68..e9dcb45 100644
--- a/Documentation/Architecture/Release1.4/Acceptance.json
+++ b/Documentation/Architecture/Release1.4/Acceptance.json
@@ -1,7 +1,7 @@
{
"schema": "swift-json-cli-acceptance/1",
"prepared": "2026-10-14",
- "implementation_status": "Foundation and pull query-core milestones; complete C0-C5 integration remains unqualified",
+ "implementation_status": "Foundation, query core and exact arithmetic milestones; C4/C5 integration remains unqualified",
"requirements": [
{
"id": "CL001",
@@ -666,7 +666,7 @@
"title": "Exact add/subtract/multiply",
"verification": "Carry/borrow/sign/zero/large integer cases against independent exact expectations.",
"obligation": "mandatory",
- "status": "not_run",
+ "status": "passed",
"evidence_required": true,
"fixture_ids": [
"Cartesian-add-order",
@@ -674,6 +674,10 @@
"exact-decimal-add",
"exact-borrow",
"exact-multiply"
+ ],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Arithmetic.md",
+ "Documentation/Architecture/Release1.4/Qualification.md"
]
},
{
@@ -682,9 +686,13 @@
"title": "Numeric admission and lexemes",
"verification": "Computed values normalized with no false originalLexeme; untouched inputs preserve spelling.",
"obligation": "mandatory",
- "status": "not_run",
+ "status": "passed",
"evidence_required": true,
- "fixture_ids": []
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Arithmetic.md",
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
},
{
"id": "CL047",
@@ -692,10 +700,14 @@
"title": "Terminating exact division",
"verification": "Reduced denominators containing only2/5, large common factors and mixed signs.",
"obligation": "mandatory",
- "status": "not_run",
+ "status": "passed",
"evidence_required": true,
"fixture_ids": [
"terminating-division"
+ ],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Arithmetic.md",
+ "Documentation/Architecture/Release1.4/Qualification.md"
]
},
{
@@ -704,10 +716,14 @@
"title": "Repeating division default",
"verification": "1/3 and repeating values give language inexactDivision; no floating fallback.",
"obligation": "mandatory",
- "status": "not_run",
+ "status": "passed",
"evidence_required": true,
"fixture_ids": [
"repeating-division-error"
+ ],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Arithmetic.md",
+ "Documentation/Architecture/Release1.4/Qualification.md"
]
},
{
@@ -716,12 +732,16 @@
"title": "Explicit scale/half-even",
"verification": "Required option pair, decimal places, finite caps, signed ties and report rounding counts.",
"obligation": "mandatory",
- "status": "not_run",
+ "status": "passed",
"evidence_required": true,
"fixture_ids": [
"rounded-third",
"half-even-ties",
"scale-pair-required"
+ ],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Arithmetic.md",
+ "Documentation/Architecture/Release1.4/Qualification.md"
]
},
{
@@ -730,11 +750,15 @@
"title": "Zero division and integral remainder",
"verification": "Typed catchable domain errors; signed truncated remainder; fractional remainder rejected.",
"obligation": "mandatory",
- "status": "not_run",
+ "status": "passed",
"evidence_required": true,
"fixture_ids": [
"negative-remainder",
"fractional-remainder-rejected"
+ ],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Arithmetic.md",
+ "Documentation/Architecture/Release1.4/Qualification.md"
]
},
{
@@ -743,12 +767,16 @@
"title": "Exact numeric builtins",
"verification": "abs/floor/ceil/trunc/round/range/add with negative and empty/domain cases; round ties away from zero.",
"obligation": "mandatory",
- "status": "not_run",
+ "status": "passed",
"evidence_required": true,
"fixture_ids": [
"round-away-from-zero",
"range-negative-step",
"range-zero-step"
+ ],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Arithmetic.md",
+ "Documentation/Architecture/Release1.4/Qualification.md"
]
},
{
@@ -757,10 +785,14 @@
"title": "Exponent/growth preflight",
"verification": "Large sparse exponent operations fail finite caps before dense allocation; exact zero shortcut allowed.",
"obligation": "mandatory",
- "status": "not_run",
+ "status": "passed",
"evidence_required": true,
"fixture_ids": [
"exponent-gap-cap"
+ ],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Arithmetic.md",
+ "Documentation/Architecture/Release1.4/Qualification.md"
]
},
{
@@ -769,9 +801,13 @@
"title": "Numeric work and cancellation",
"verification": "Charged GCD/division/carry inner loops; boundaries and checkpoint cancellation; terminal errors not catchable.",
"obligation": "mandatory",
- "status": "not_run",
+ "status": "passed",
"evidence_required": true,
- "fixture_ids": []
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Arithmetic.md",
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
},
{
"id": "CL054",
@@ -779,9 +815,13 @@
"title": "32-bit arithmetic safety",
"verification": "No Int/UInt64 negation/narrowing/product overflow traps; wasm32 kernel tests or explicit gate blocker.",
"obligation": "mandatory",
- "status": "not_run",
+ "status": "partial",
"evidence_required": true,
- "fixture_ids": []
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Arithmetic.md",
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
},
{
"id": "CL055",
@@ -789,9 +829,13 @@
"title": "No Decimal/Double authority",
"verification": "Source audit plus precision cases prove no foreign arithmetic/fallback authority.",
"obligation": "mandatory",
- "status": "not_run",
+ "status": "passed",
"evidence_required": true,
- "fixture_ids": []
+ "fixture_ids": [],
+ "evidence": [
+ "Documentation/Architecture/Release1.4/Arithmetic.md",
+ "Documentation/Architecture/Release1.4/Qualification.md"
+ ]
},
{
"id": "CL056",
diff --git a/Documentation/Architecture/Release1.4/Arithmetic.md b/Documentation/Architecture/Release1.4/Arithmetic.md
new file mode 100644
index 0000000..2ec8f69
--- /dev/null
+++ b/Documentation/Architecture/Release1.4/Arithmetic.md
@@ -0,0 +1,59 @@
+# Exact filter arithmetic
+
+C3 builds on query core 6e8f145 / draft PR #24. Original private code implements
+base-ten unsigned working magnitudes plus native sign/coefficient/exponent values.
+No Double, Float or Foundation Decimal is an arithmetic authority. Numeric binary
+operators clear originalLexeme and normalize computed zero. Untouched selected
+values preserve their admitted spelling; null's identity overload selects a value.
+
+Addition bounds exponent alignment before dense storage. Schoolbook multiplication
+uses UInt16: digit product + stored digit + carry <=99; addition <=19. Subtraction
+fits Int16. Long division maintains rd or r*2==d and q%2:q+=1
+ z=Fraction((-q if z<0 else q),10**scale)
+ elif op=='%':
+ q=abs(x.numerator)//abs(y.numerator);q=-q if (x<0)!=(y<0) else q;z=x-q*y
+ elif op=='abs':z=abs(x)
+ elif op=='negate':z=-x
+ elif op=='trunc':z=Fraction(int(x))
+ elif op=='floor':z=Fraction(x.numerator//x.denominator)
+ elif op=='ceil':z=Fraction(-((-x.numerator)//x.denominator))
+ elif op=='round':
+ n,d=abs(x.numerator),x.denominator;q,r=divmod(n,d);q+=r*2>=d;z=Fraction(-q if x<0 else q)
+ row={'id':len(rows),'op':op,'lhs':a,'expected':decimal(z),'rounded':rounded}
+ if b is not None:row['rhs']=b
+ if scale is not None:row['scale']=scale
+ rows.append(row)
+for _ in range(120):
+ a=str(rng.randint(-10**25,10**25))+'e'+str(rng.randint(-6,6));b=str(rng.randint(-10**25,10**25))+'e'+str(rng.randint(-6,6))
+ for op in ('+','-','*'):add(op,a,b)
+for _ in range(80):
+ a=str(rng.randint(-10**18,10**18));b=str((2**rng.randint(0,24)*5**rng.randint(0,24))*rng.choice((-1,1)))
+ add('/',a,b)
+for _ in range(80):
+ a=str(rng.randint(-10**12,10**12))+'e'+str(rng.randint(-3,3));b=str(rng.choice((3,6,7,9,11,13,17))*rng.choice((-1,1)))
+ add('/',a,b,scale=rng.randint(0,8))
+for _ in range(64):add('%',str(rng.randint(-10**30,10**30)),str(rng.randint(1,10**15)*rng.choice((-1,1))))
+for value in ['-0','1.5','-1.5','0.5','-0.5','2.5','-2.5','999.999','-999.999','1e-100','-1e-100','1e100','-1e100','0.1','-0.1','5','-5','2.49','-2.49','2.51','-2.51','9007199254740993.5','-9007199254740993.5','0']:
+ for op in ('abs','negate','floor','ceil','trunc','round'):add(op,value)
+for a,b,scale in [('1','8',2),('3','8',2),('-1','8',2),('5','2',0),('7','2',0),('-5','2',0),('1','3',4),('1','40',2),('1','100',2),('1','100',0)]:add('/',a,b,scale)
+result={'schema_version':1,'oracle':'Python fractions.Fraction and arbitrary-width integers; no float/Decimal','seed':SEED,'count':len(rows),'cases':rows}
+output=pathlib.Path(sys.argv[1]);output.write_text(json.dumps(result,indent=2)+'\n');print(json.dumps({'count':len(rows),'sha256':hashlib.sha256(output.read_bytes()).hexdigest(),'python':sys.version}))
diff --git a/Scripts/qualify_cli_cases.py b/Scripts/qualify_cli_cases.py
index c67fd12..8a18daa 100644
--- a/Scripts/qualify_cli_cases.py
+++ b/Scripts/qualify_cli_cases.py
@@ -11,16 +11,24 @@ def main():
for case in declaration['cases']:
if case['gate']!=a.gate:continue
argv=[case['command'],*case.get('options',[])]
- if case['command']=='query':argv += declaration['default_query_options']+[case['filter']]
+ if case['command']=='query':argv += declaration['default_query_options']+['--',case['filter']]
argv += case.get('operands',[])
+ if 'expected_diagnostic_code' in case: argv.insert(1, '--diagnostics=json')
result=subprocess.run([str(binary),*argv],input=case.get('stdin_utf8','').encode(),capture_output=True,timeout=30)
passed=result.returncode==case['expected_exit'];comparison=None
+ diagnostic=None
+ if 'expected_diagnostic_code' in case:
+ try:
+ diagnostics=[json.loads(line) for line in result.stderr.splitlines()]
+ diagnostic=[row for row in diagnostics if row.get('kind')=='diagnostic']
+ passed=passed and len(diagnostic)==1 and diagnostic[0].get('code')==case['expected_diagnostic_code']
+ except (ValueError,TypeError):passed=False
if 'expected_stdout_utf8' in case:passed=passed and result.stdout==case['expected_stdout_utf8'].encode()
if 'expected_json_values' in case and result.returncode==case['expected_exit']:
actual=directory/'actual.json';expected=directory/'expected.json';actual.write_bytes(result.stdout);expected.write_text(json.dumps(case['expected_json_values'],ensure_ascii=False))
checked=subprocess.run([str(comparator),str(actual),str(expected)],capture_output=True,timeout=30)
comparison={'exit':checked.returncode,'stdout':checked.stdout.decode(),'stderr':checked.stderr.decode()};passed=passed and checked.returncode==0
- row={'id':case['id'],'requirement_ids':case['requirement_ids'],'command':['swift-json',*argv],'exit_code':result.returncode,'expected_exit':case['expected_exit'],'status':'passed' if passed else 'failed','stdout_sha256':hashlib.sha256(result.stdout).hexdigest(),'stderr_sha256':hashlib.sha256(result.stderr).hexdigest(),'comparison':comparison}
+ row={'id':case['id'],'requirement_ids':case['requirement_ids'],'command':['swift-json',*argv],'exit_code':result.returncode,'expected_exit':case['expected_exit'],'status':'passed' if passed else 'failed','stdout_sha256':hashlib.sha256(result.stdout).hexdigest(),'stderr_sha256':hashlib.sha256(result.stderr).hexdigest(),'comparison':comparison,'diagnostic':diagnostic}
if not passed:row.update(stdout=result.stdout.decode(errors='replace'),stderr=result.stderr.decode(errors='replace'));print(json.dumps(row),flush=True)
rows.append(row)
receipt={'schema_version':1,'gate':a.gate,'status':'passed' if all(x['status']=='passed' for x in rows) and rows else 'failed','observed':len(rows),'passed':sum(x['status']=='passed' for x in rows),'failed':sum(x['status']=='failed' for x in rows),'policy':0,'fixture_sha256':hashlib.sha256(fixture.read_bytes()).hexdigest(),'binary_sha256':hashlib.sha256(binary.read_bytes()).hexdigest(),'comparator_sha256':hashlib.sha256(comparator.read_bytes()).hexdigest(),'cases':rows}
diff --git a/Scripts/qualify_cli_limits.py b/Scripts/qualify_cli_limits.py
new file mode 100644
index 0000000..5e3166b
--- /dev/null
+++ b/Scripts/qualify_cli_limits.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+"""Real subprocess rendezvous at the sixteen CLI quota sites and numeric reports."""
+import argparse,hashlib,json,pathlib,subprocess,tempfile
+ROOT=pathlib.Path(__file__).resolve().parents[1]
+def main():
+ p=argparse.ArgumentParser();p.add_argument('--binary',required=True);p.add_argument('--output',required=True);a=p.parse_args();binary=(ROOT/a.binary).resolve();rows=[]
+ with tempfile.TemporaryDirectory(prefix='swift-json-limits-') as directory:
+ directory=pathlib.Path(directory);configuration=directory/'limits.json'
+ probes=[('argvBytes',[],b''),('querySourceBytes',['query','-n','--','.'],b''),('queryTokens',['query','-n','--','.'],b''),('astNodes',['query','-n','--','.'],b''),('queryDepth',['query','-n','--','.'],b''),('runtimeFrames',['query','-n','--','.'],b''),('bindings',['query','-n','--','.'],b''),('collectionValues',['query','-n','--','[1]'],b''),('totalInputBytes',['format'],b'null'),('totalOutputBytes',['query','-n','--','1'],b''),('totalRecords',['format'],b'null'),('totalResults',['query','-n','--','1'],b''),('totalWorkUnits',['format'],b'null'),('retainedBytes',['format'],b'null'),('diskStagingBytes',['format','--output',str(directory/'output.json')],b'null')]
+ for metric,argv,data in probes:
+ configuration.write_text(json.dumps({'cli':{metric:0}}))
+ argv=argv or ['format']
+ command=[str(binary),argv[0],'--diagnostics=json','--limits-file',str(configuration),*argv[1:]]
+ result=subprocess.run(command,input=data,capture_output=True,timeout=30)
+ diagnostic=None
+ try:diagnostic=json.loads(result.stderr)
+ except ValueError:pass
+ passed=result.returncode==6 and not result.stdout and diagnostic is not None and diagnostic.get('metric')==metric and diagnostic.get('limit')==0 and (diagnostic.get('attemptedUsage',0)>0 or diagnostic.get('overflow'))
+ rows.append({'metric':metric,'command':['swift-json',*command[1:]],'exit_code':result.returncode,'status':'passed' if passed else 'failed','diagnostic':diagnostic,'stdout_sha256':hashlib.sha256(result.stdout).hexdigest(),'stderr_sha256':hashlib.sha256(result.stderr).hexdigest()})
+ if not passed:print(metric,result.returncode,result.stdout,result.stderr,flush=True)
+ # Diagnostics cannot erase the originating syntax failure. Find its exact finite
+ # byte boundary, then verify one byte below suppresses a whole JSONL record.
+ initial=subprocess.run([str(binary),'format','--diagnostics=json'],input=b'{',capture_output=True,timeout=30)
+ boundary=len(initial.stderr);outcomes=[]
+ for cap in (boundary,boundary-1):
+ configuration.write_text(json.dumps({'cli':{'diagnosticBytes':cap}}))
+ result=subprocess.run([str(binary),'format','--diagnostics=json','--limits-file',str(configuration)],input=b'{',capture_output=True,timeout=30)
+ outcomes.append({'cap':cap,'exit_code':result.returncode,'bytes':len(result.stderr),'passed':result.returncode==5 and (result.stderr==initial.stderr if cap==boundary else not result.stderr)})
+ rows.append({'metric':'diagnosticBytes','status':'passed' if boundary>0 and all(x['passed'] for x in outcomes) else 'failed','inclusive_boundary':boundary,'cases':outcomes})
+ result=subprocess.run([str(binary),'query','-n','--compact','--report=json','--division-scale','2','--rounding','half-even','--','1/8,3/8,-1/8'],capture_output=True,timeout=30)
+ report=json.loads(result.stderr)
+ needed={'kind','version','completed','inputRecords','outputResults','committedOutputResults','totalInputBytes','totalOutputBytes','totalWorkUnits','peakLogicalRetainedBytes','resolvedLimits','arithmeticPolicy','roundedDivisions','failure','remainingWorkUnits'}
+ good=result.returncode==0 and needed<=report.keys() and report['arithmeticPolicy']=='half-even-scale-2' and report['roundedDivisions']==3 and report['outputResults']==3 and report['committedOutputResults']==3 and report['completed'] and report['failure'] is None
+ rows.append({'id':'explicit-rounded-report','status':'passed' if good else 'failed','exit_code':result.returncode,'report':report})
+ result=subprocess.run([str(binary),'query','-n','--diagnostics=json','--report=json','--','try (1e1000000+1) catch null'],capture_output=True,timeout=30)
+ lines=[json.loads(line) for line in result.stderr.splitlines()]
+ good=result.returncode==6 and not result.stdout and len(lines)==2 and lines[0]['metric']=='numberDigits' and lines[1]['completed'] is False and lines[1]['committedOutputResults']==0 and lines[1]['failure']['category']=='resource'
+ rows.append({'id':'terminal-exact-report','status':'passed' if good else 'failed','exit_code':result.returncode,'records':lines})
+ receipt={'schema_version':1,'status':'passed' if all(r['status']=='passed' for r in rows) else 'failed','observed':len(rows),'passed':sum(r['status']=='passed' for r in rows),'failed':sum(r['status']=='failed' for r in rows),'metrics':len([r for r in rows if 'metric'in r]),'binary_sha256':hashlib.sha256(binary.read_bytes()).hexdigest(),'cases':rows}
+ path=ROOT/a.output;path.parent.mkdir(parents=True,exist_ok=True);path.write_text(json.dumps(receipt,indent=2)+'\n');print(json.dumps({k:v for k,v in receipt.items() if k!='cases'}));return 0 if receipt['status']=='passed' else 1
+if __name__=='__main__':raise SystemExit(main())
diff --git a/Sources/JSON/Documentation.docc/CommandLine.md b/Sources/JSON/Documentation.docc/CommandLine.md
index efc9685..aa46a10 100644
--- a/Sources/JSON/Documentation.docc/CommandLine.md
+++ b/Sources/JSON/Documentation.docc/CommandLine.md
@@ -32,5 +32,26 @@ cannot be recalled. `--report json` writes cumulative accounting to stderr, leav
stdout for result bytes. All profiles are finite. Logical retained bytes describe
owned package state, not process RSS or kernel work.
-The foundation increment advertises only its qualified commands. Query, advanced
-adapters and provider-specific functionality have separate qualification gates.
+Query uses a pull generator over strict whitespace-separated values by default:
+
+```sh
+.build/release/swift-json query --compact -- '.items[] | select(.active) | .name' input.json
+.build/release/swift-json query --null-input -- '0.1 + 0.2' CLIError {
if let error = error as? CLIError { return error }
- if let failure = error as? FilterCompileFailure { return .init(.compile, failure.code) }
+ if let failure = error as? FilterCompileFailure { return .init(.compile, failure.code, byteOffset: UInt64(failure.offset)) }
if let failure = error as? FilterLanguageFailure { return .init(.language, failure.code) }
if error is CancellationError { return .init(.cancelled, "cancelled") }
if let error = error as? JSONFailure {
let category: CLIError.Category = error.category == .resource ? .resource : (error.category == .configuration ? .usage : .input)
- return .init(category, error.code.rawValue, metric: error.resource?.metric.rawValue)
+ return .init(category, error.code.rawValue, metric: error.resource?.metric.rawValue, limit: error.resource?.limit, attemptedUsage: error.resource?.attemptedUsage, overflow: error.resource?.overflow ?? (error.code == .counterOverflow), byteOffset: error.location?.byteOffset)
}
if let failure = error as? JSONHTMLFailure {
switch failure {
case .invalidConfiguration: return .init(.usage, "invalidHTMLConfiguration")
- case .limitExceeded(let metric, _, _): return .init(.resource, "limitExceeded", metric: metric.rawValue)
- case .counterOverflow(let metric): return .init(.resource, "counterOverflow", metric: metric.rawValue)
+ case .limitExceeded(let metric, let limit, let attempted): return .init(.resource, "limitExceeded", metric: metric.rawValue, limit: limit, attemptedUsage: attempted)
+ case .counterOverflow(let metric): return .init(.resource, "counterOverflow", metric: metric.rawValue, overflow: true)
}
}
if let failure = error as? JSONSchemaCompilationFailure { return .init(.input, "schemaCompilation." + failure.category.rawValue) }
@@ -54,7 +54,15 @@ package struct CLIDiagnostics {
}
if let error {
// All codes and metric names are fixed ASCII identifiers, never instance text.
- let parts = json ? ["{\"kind\":\"diagnostic\",\"version\":1,\"category\":\"", error.category.rawValue, "\",\"code\":\"", error.code, "\"}\n"] : ["swift-json: ", error.category.rawValue, ": ", error.code, "\n"]
+ var parts = json ? ["{\"kind\":\"diagnostic\",\"version\":1,\"category\":\"", error.category.rawValue, "\",\"code\":\"", error.code, "\"}\n"] : ["swift-json: ", error.category.rawValue, ": ", error.code, "\n"]
+ if json {
+ parts.removeLast()
+ parts += ["\"", ",\"metric\":", error.metric.map { "\"" + $0 + "\"" } ?? "null",
+ ",\"limit\":", error.limit.map(String.init) ?? "null",
+ ",\"attemptedUsage\":", error.attemptedUsage.map(String.init) ?? "null",
+ ",\"overflow\":", String(error.overflow),
+ ",\"byteOffset\":", error.byteOffset.map(String.init) ?? "null", "}\n"]
+ }
_ = append(parts, to: &output, count: &used, maximum: capacity)
}
if wantsReport {
@@ -67,9 +75,9 @@ package struct CLIDiagnostics {
part(",\"inputRecords\":", String(context.used(.totalRecords)))
part(",\"outputResults\":", String(context.used(.totalResults)))
part(",\"committedOutputResults\":", String(context.committedResults))
- part(",\"inputBytes\":", String(context.used(.totalInputBytes)))
- part(",\"outputBytes\":", String(context.used(.totalOutputBytes)))
- part(",\"workUnits\":", String(context.used(.totalWorkUnits)))
+ part(",\"totalInputBytes\":", String(context.used(.totalInputBytes)))
+ part(",\"totalOutputBytes\":", String(context.used(.totalOutputBytes)))
+ part(",\"totalWorkUnits\":", String(context.used(.totalWorkUnits)))
part(",\"peakLogicalRetainedBytes\":", String(statistics.peakLogicalRetainedBytes))
part(",\"remainingWorkUnits\":", String(remaining))
part(",\"limitsOrigin\":{\"profile\":\"", context.limits.profileName,
diff --git a/Sources/JSONCLIEngine/CLIEngine.swift b/Sources/JSONCLIEngine/CLIEngine.swift
index ae188cb..f903112 100644
--- a/Sources/JSONCLIEngine/CLIEngine.swift
+++ b/Sources/JSONCLIEngine/CLIEngine.swift
@@ -70,7 +70,6 @@ package enum CLIEngine {
default: throw CLIError(.usage, "unknownLimitsField")
}
}
- guard object[JSONKey("version")] != nil else { throw CLIError(.usage, "missingLimitsVersion") }
try context.meter.resetValueBounds()
}
return result
@@ -222,7 +221,9 @@ package enum CLIEngine {
--diagnostics human|json --report none|json stderr only
No online references, shell execution, server or remote providers.
Query core: paths, generators, conditions, bindings, map, presence and exact comparison.
- Arithmetic, richer filters and provider/stream/schema adapters have separate gates.
+ Exact arithmetic includes +, -, *, /, integral %, add and range.
+ Repeating division errors unless --division-scale N --rounding half-even is explicit.
+ Richer filters and provider/stream/schema adapters have separate gates.
"""
}
diff --git a/Sources/JSONCLIEngine/CLIQueryCommand.swift b/Sources/JSONCLIEngine/CLIQueryCommand.swift
index d6f7949..b660989 100644
--- a/Sources/JSONCLIEngine/CLIQueryCommand.swift
+++ b/Sources/JSONCLIEngine/CLIQueryCommand.swift
@@ -13,7 +13,12 @@ package enum CLIQueryCommand {
guard let first = arguments.positionals.first else { throw CLIError(.usage, "missingFilter") }
source = first; files = Array(arguments.positionals.dropFirst())
}
- guard arguments.options["division-scale"] == nil else { throw CLIError(.usage, "arithmeticNotYetQualified") }
+ if let raw = arguments.options["division-scale"] {
+ guard arguments.options["rounding"] == "half-even", !raw.isEmpty,
+ raw.utf8.allSatisfy({ (48...57).contains($0) }),
+ let scale = UInt64(raw), scale <= context.meter.limits[.numberDigits], scale < UInt64(Int.max) else { throw CLIError(.usage, "invalidDivisionPolicy") }
+ context.divisionScale = Int(scale)
+ }
let inputFiles = files.isEmpty ? ["-"] : files
let auxiliary = arguments.repeated.enumerated().compactMap { index, pair -> String? in
guard pair.0 == "bindingValue", index > 0, ["rawfile","slurpfile"].contains(arguments.repeated[index-1].0) else { return nil }
@@ -44,7 +49,9 @@ package enum CLIQueryCommand {
try context.domain(.core)
var vm = try FilterVM(program: program, input: input, bindings: bindings, context: &context)
defer { try? vm.close(context: &context) }
- while var value = try vm.next(input: &cursor, context: &context) {
+ while true {
+ try context.domain(.core)
+ guard var value = try vm.next(input: &cursor, context: &context) else { break }
finalTruth = FilterTruth.test(value.value)
try CLIQueryOutput.emit(value.value, arguments: arguments, output: output, context: &context)
try value.release(context: &context)
diff --git a/Sources/JSONFilterRuntime/CLIJobContext.swift b/Sources/JSONFilterRuntime/CLIJobContext.swift
index c274ad0..79a25c5 100644
--- a/Sources/JSONFilterRuntime/CLIJobContext.swift
+++ b/Sources/JSONFilterRuntime/CLIJobContext.swift
@@ -68,8 +68,14 @@ package struct CLIError: Error, Sendable, Equatable {
package let category: Category
package let code: String
package let metric: String?
- package init(_ category: Category, _ code: String, metric: String? = nil) {
+ package let limit: UInt64?
+ package let attemptedUsage: UInt64?
+ package let overflow: Bool
+ package let byteOffset: UInt64?
+ package init(_ category: Category, _ code: String, metric: String? = nil, limit: UInt64? = nil,
+ attemptedUsage: UInt64? = nil, overflow: Bool = false, byteOffset: UInt64? = nil) {
self.category = category; self.code = code; self.metric = metric
+ self.limit = limit; self.attemptedUsage = attemptedUsage; self.overflow = overflow; self.byteOffset = byteOffset
}
package var exit: Int32 {
switch category {
@@ -127,13 +133,13 @@ package struct CLIJobContext: ~Copyable {
package mutating func require(_ metric: CLIResourceMetric, _ attempted: UInt64) throws {
try checkpoint()
guard attempted <= limits[metric] else {
- let error = CLIError(.resource, "limitExceeded", metric: metric.rawValue)
+ let error = CLIError(.resource, "limitExceeded", metric: metric.rawValue, limit: limits[metric], attemptedUsage: attempted)
latch(error); throw error
}
}
package mutating func charge(_ metric: CLIResourceMetric, _ amount: UInt64 = 1) throws {
let (next, overflow) = used(metric).addingReportingOverflow(amount)
- guard !overflow else { let error = CLIError(.resource, "counterOverflow", metric: metric.rawValue); latch(error); throw error }
+ guard !overflow else { let error = CLIError(.resource, "counterOverflow", metric: metric.rawValue, limit: limits[metric], overflow: true); latch(error); throw error }
try require(metric, next)
switch metric {
case .totalWorkUnits: try meter.work(amount)
@@ -147,7 +153,10 @@ package struct CLIJobContext: ~Copyable {
else { counters[metric.index] -= amount }
}
package mutating func work(_ amount: UInt64 = 1) throws { try charge(.totalWorkUnits, amount) }
- package mutating func domain(_ domain: JSONOperationDomain) throws { try meter.operationDomain(domain) }
+ package mutating func domain(_ domain: JSONOperationDomain) throws {
+ try checkpoint() // Drain finished stage leases before the next retention baseline.
+ try meter.operationDomain(domain)
+ }
/// The only post-terminal accounting mutation spends previously reserved diagnostic work.
/// It cannot reopen data operations, refund work or exceed aggregate diagnostic capacity.
package mutating func acceptTerminalDiagnostics(_ bytes: UInt64) -> Bool {
@@ -158,7 +167,7 @@ package struct CLIJobContext: ~Copyable {
}
package mutating func configure(_ requested: CLILimits) throws {
try requested.validate(); try checkpoint()
- for metric in CLIResourceMetric.allCases { guard used(metric) <= requested[metric] else { throw CLIError(.resource, "limitExceeded", metric: metric.rawValue) } }
+ for metric in CLIResourceMetric.allCases { guard used(metric) <= requested[metric] else { throw CLIError(.resource, "limitExceeded", metric: metric.rawValue, limit: requested[metric], attemptedUsage: used(metric)) } }
try meter.configure(requested.effectiveCore)
limits = requested
}
diff --git a/Sources/JSONFilterRuntime/DecimalMagnitude.swift b/Sources/JSONFilterRuntime/DecimalMagnitude.swift
new file mode 100644
index 0000000..cb1ba7e
--- /dev/null
+++ b/Sources/JSONFilterRuntime/DecimalMagnitude.swift
@@ -0,0 +1,160 @@
+// SPDX-License-Identifier: Apache-2.0
+import JSON
+
+/// Base-ten unsigned working magnitude. Every mutable digit buffer owns an
+/// invocation lease; aliases share that reservation until their last release.
+package struct DecimalMagnitude {
+ private(set) var storage: [UInt8]
+ private var start: Int = 0
+ private let lease: CLIValueLease?
+ package init(borrowing digits: [UInt8]) { storage = digits; lease = nil }
+ private init(storage: [UInt8], lease: CLIValueLease) { self.storage = storage; self.lease = lease }
+ package var count: Int { storage.count - start }
+ package var isZero: Bool { count == 1 && storage[start] == 0 }
+ package subscript(_ index: Int) -> UInt8 { storage[start + index] }
+ package static func zero() -> Self { .init(borrowing: [0]) }
+ package static func allocate(_ count: Int, context: inout CLIJobContext) throws -> Self {
+ try context.checkpoint()
+ guard count > 0, count < Int.max else { throw CLIError(.resource, "counterOverflow", metric: "numberDigits") }
+ let maximum = context.meter.limits[.numberDigits]
+ let (twice, overflow) = maximum.multipliedReportingOverflow(by: 2)
+ let (scratch, extraOverflow) = twice.addingReportingOverflow(2)
+ guard !overflow, !extraOverflow, UInt64(count) <= scratch else { try context.meter.require(.numberDigits, UInt64(count)); throw CLIError(.resource, "limitExceeded", metric: "numberDigits") }
+ try context.meter.retain(UInt64(count))
+ let lease: CLIValueLease
+ do { lease = try .init(ownedRetained: UInt64(count), context: &context) }
+ catch { try context.meter.release(UInt64(count)); throw error }
+ return .init(storage: [UInt8](repeating: 0, count: count), lease: lease)
+ }
+ package static func step(_ context: inout CLIJobContext) throws { try context.meter.work(subsystem: .numericWorkUnits) }
+ private mutating func trim(context: inout CLIJobContext) throws {
+ while start + 1 < storage.count && storage[start] == 0 { try Self.step(&context); start += 1 }
+ }
+ package static func compare(_ a: Self, _ b: Self, context: inout CLIJobContext) throws -> Int {
+ try step(&context)
+ if a.count != b.count { return a.count < b.count ? -1 : 1 }
+ for i in 0.. Self {
+ let count = max(a.count, b.count)
+ var output = try allocate(count + 1, context: &context), carry: UInt16 = 0
+ for offset in 0.. Self {
+ guard try compare(a, b, context: &context) >= 0 else { throw CLIError(.resource, "arithmeticInvariant") }
+ var output = try allocate(a.count, context: &context), borrow: Int16 = 0
+ for offset in 0.. Self {
+ if a.isZero || b.isZero { try step(&context); return .zero() }
+ let (count, overflow) = a.count.addingReportingOverflow(b.count)
+ guard !overflow else { throw CLIError(.resource, "counterOverflow", metric: "numberDigits") }
+ var output = try allocate(count, context: &context)
+ for i in (0.. Self {
+ guard zeros >= 0 else { throw CLIError(.resource, "arithmeticInvariant") }
+ if value.isZero { try step(&context); return .zero() }
+ let (count, overflow) = UInt64(value.count).addingReportingOverflow(UInt64(zeros))
+ guard !overflow, count < UInt64(Int.max) else { throw CLIError(.resource, "counterOverflow", metric: "numberDigits") }
+ var output = try allocate(Int(count), context: &context)
+ for i in 0.. (quotient: Self, remainder: Self) {
+ guard !b.isZero else { throw FilterLanguageFailure("divisionByZero") }
+ if try compare(a, b, context: &context) < 0 { return (.zero(), a) }
+ var quotient = try allocate(a.count, context: &context)
+ var remainder = try allocate(b.count + 1, context: &context), used = 1
+ func remainderCompare(context: inout CLIJobContext) throws -> Int {
+ try step(&context)
+ if used != b.count { return used < b.count ? -1 : 1 }
+ for i in 0..= 0 {
+ var borrow: Int16 = 0
+ for offset in 0.. 1 && remainder.storage[0] == 0 {
+ for j in 1.. Self {
+ var left = a, right = b
+ while !right.isZero {
+ try context.checkpoint(); try step(&context)
+ let next = try divmod(left, right, context: &context).remainder
+ left = right; right = next
+ }
+ return left
+ }
+ package func coefficient(context: inout CLIJobContext) throws -> Self {
+ var output = try Self.allocate(count, context: &context)
+ for i in 0.. Bool {
+ try Self.step(&context)
+ guard count > 1, storage.last == 0 else { return false }
+ storage.removeLast(); return true
+ }
+ package static func prefix(_ digits: [UInt8], count: Int, context: inout CLIJobContext) throws -> Self {
+ guard count > 0, count <= digits.count else { throw CLIError(.resource, "arithmeticInvariant") }
+ var result = try allocate(count, context: &context)
+ for index in 0.. Never {
+ let error = JSONFailure(.resource, code: .counterOverflow, resource: .init(domain: context.meter.domain, metric: metric, limit: context.meter.limits[metric], attemptedUsage: nil, overflow: true))
+ context.latch(error); throw error
+ }
+ private static func addExponent(_ a: Int64, _ b: Int64, context: inout CLIJobContext) throws -> Int64 {
+ let (sum, overflow) = a.addingReportingOverflow(b); if overflow { try failure(&context) }; return sum
+ }
+ private static func subtractExponent(_ a: Int64, _ b: Int64, context: inout CLIJobContext) throws -> Int64 {
+ let (difference, overflow) = a.subtractingReportingOverflow(b); if overflow { try failure(&context) }; return difference
+ }
+ private static func admit(_ number: JSONNumber, context: inout CLIJobContext) throws {
+ try context.meter.resetValueBounds(); try JSONAdmission.value(.number(number), meter: &context.meter)
+ }
+ private static func admitToken(_ number: JSONNumber, context: inout CLIJobContext) throws {
+ let c = number.components
+ var bytes = UInt64(c.digits.count) + (c.negative ? 1 : 0)
+ if c.exponent != 0 { try context.work(20); bytes += 1 + UInt64(String(c.exponent).utf8.count) }
+ try context.meter.require(.numberTokenBytes, bytes)
+ }
+ private static func normalized(_ magnitude: DecimalMagnitude, negative: Bool, exponent: Int64, context: inout CLIJobContext) throws -> Result {
+ if magnitude.isZero { try DecimalMagnitude.step(&context); return Result(JSONNumber(integer: 0)) }
+ var value = try magnitude.coefficient(context: &context), exponent = exponent
+ while try value.removingTrailingZero(context: &context) { exponent = try addExponent(exponent, 1, context: &context) }
+ try context.meter.require(.numberDigits, UInt64(value.count)); try context.meter.require(.absoluteExponent, exponent.magnitude)
+ return Result(.init(components: .init(negative: negative, digits: value.coefficientDigits, exponent: exponent)), storage: value)
+ }
+ package static func binary(_ op: String, _ lhs: JSONNumber, _ rhs: JSONNumber, context: inout CLIJobContext) throws -> FilterYield {
+ try context.checkpoint(); try admit(lhs, context: &context); try admit(rhs, context: &context)
+ let number: Result
+ switch op {
+ case "+", "-": number = try adding(lhs, rhs, subtract: op == "-", context: &context)
+ case "*":
+ let a = lhs.components, b = rhs.components
+ if a.isZero || b.isZero { number = Result(JSONNumber(integer: 0)) }
+ else {
+ let exponent = try addExponent(a.exponent, b.exponent, context: &context)
+ let value = try DecimalMagnitude.multiply(.init(borrowing: a.digits), .init(borrowing: b.digits), context: &context)
+ number = try normalized(value, negative: a.negative != b.negative, exponent: exponent, context: &context)
+ }
+ case "/": number = try dividing(lhs, rhs, context: &context)
+ case "%":
+ guard lhs.isInteger, rhs.isInteger else { throw FilterLanguageFailure("integralOperandsRequired") }
+ guard !rhs.isZero else { throw FilterLanguageFailure("divisionByZero") }
+ let a = lhs.components, b = rhs.components
+ let left = try DecimalMagnitude.shifted(.init(borrowing: a.digits), zeros: a.exponent, context: &context)
+ let right = try DecimalMagnitude.shifted(.init(borrowing: b.digits), zeros: b.exponent, context: &context)
+ let value = try DecimalMagnitude.divmod(left, right, context: &context).remainder
+ number = try normalized(value, negative: a.negative, exponent: 0, context: &context)
+ default: throw FilterLanguageFailure("unknownArithmeticOperator")
+ }
+ return try withExtendedLifetime(number) {
+ try admitToken(number.number, context: &context)
+ return try FilterValues.produced(.number(number.number), context: &context)
+ }
+ }
+ private static func adding(_ lhs: JSONNumber, _ rhs: JSONNumber, subtract: Bool, context: inout CLIJobContext) throws -> Result {
+ let a = lhs.components, originalB = rhs.components
+ let b = DecimalComponents(negative: !originalB.isZero && (originalB.negative != subtract), digits: originalB.digits, exponent: originalB.exponent)
+ if a.isZero { return .init(components: b) }
+ if b.isZero { return .init(components: a) }
+ let exponent = min(a.exponent, b.exponent)
+ let left = try DecimalMagnitude.shifted(.init(borrowing: a.digits), zeros: subtractExponent(a.exponent, exponent, context: &context), context: &context)
+ let right = try DecimalMagnitude.shifted(.init(borrowing: b.digits), zeros: subtractExponent(b.exponent, exponent, context: &context), context: &context)
+ let value: DecimalMagnitude, negative: Bool
+ if a.negative == b.negative { value = try .add(left, right, context: &context); negative = a.negative }
+ else if try DecimalMagnitude.compare(left, right, context: &context) >= 0 { value = try .subtract(left, right, context: &context); negative = a.negative }
+ else { value = try .subtract(right, left, context: &context); negative = b.negative }
+ return try normalized(value, negative: negative, exponent: exponent, context: &context)
+ }
+ private static func discarded(context: inout CLIJobContext) throws {
+ let (next, overflow) = context.roundedDivisions.addingReportingOverflow(1)
+ if overflow { try failure(&context, metric: .workUnits) }; context.roundedDivisions = next
+ }
+ private static func quantized(_ input: Result, scale: Int, context: inout CLIJobContext) throws -> Result {
+ return try withExtendedLifetime(input) {
+ let c = input.number.components, target = -Int64(scale)
+ if c.isZero || c.exponent >= target { return input }
+ let drop = try subtractExponent(target, c.exponent, context: &context)
+ let length = Int64(c.digits.count), prefix = drop >= length ? 0 : Int(length-drop)
+ var quotient: DecimalMagnitude
+ if prefix == 0 { quotient = .zero() }
+ else { quotient = try DecimalMagnitude.prefix(c.digits, count: prefix, context: &context) }
+ var above = false, tie = false
+ if drop <= length {
+ let first = c.digits[prefix]; try DecimalMagnitude.step(&context)
+ var rest = false
+ if prefix+1 < c.digits.count { for digit in c.digits[(prefix+1)...] { try DecimalMagnitude.step(&context); if digit != 0 { rest = true } } }
+ above = first > 5 || first == 5 && rest; tie = first == 5 && !rest
+ }
+ if above || tie && quotient[quotient.count-1] & 1 == 1 {
+ quotient = try .add(quotient, .init(borrowing: [1]), context: &context)
+ }
+ try discarded(context: &context)
+ return try normalized(quotient, negative: c.negative, exponent: target, context: &context)
+ }
+ }
+ private static func dividing(_ lhs: JSONNumber, _ rhs: JSONNumber, context: inout CLIJobContext) throws -> Result {
+ guard !rhs.isZero else { throw FilterLanguageFailure("divisionByZero") }
+ if lhs.isZero { return Result(JSONNumber(integer: 0)) }
+ let a = lhs.components, b = rhs.components
+ let exponent = try subtractExponent(a.exponent, b.exponent, context: &context)
+ let left = DecimalMagnitude(borrowing: a.digits), right = DecimalMagnitude(borrowing: b.digits)
+ let common = try DecimalMagnitude.gcd(left, right, context: &context)
+ let numerator = try DecimalMagnitude.divmod(left, common, context: &context).quotient
+ let denominator = try DecimalMagnitude.divmod(right, common, context: &context).quotient
+ var remaining = denominator, twos: Int64 = 0, fives: Int64 = 0
+ while true {
+ let pair = try DecimalMagnitude.divmod(remaining, .init(borrowing: [2]), context: &context)
+ if !pair.remainder.isZero { break }
+ remaining = pair.quotient; twos = try addExponent(twos, 1, context: &context)
+ }
+ while true {
+ let pair = try DecimalMagnitude.divmod(remaining, .init(borrowing: [5]), context: &context)
+ if !pair.remainder.isZero { break }
+ remaining = pair.quotient; fives = try addExponent(fives, 1, context: &context)
+ }
+ let negative = a.negative != b.negative
+ if remaining.count == 1 && remaining[0] == 1 {
+ let places = max(twos, fives)
+ var coefficient = numerator
+ if twos < places { for _ in twos..= 0 { n = try .shifted(numerator, zeros: shift, context: &context); d = denominator }
+ else { n = numerator; d = try .shifted(denominator, zeros: -shift, context: &context) }
+ let pair = try DecimalMagnitude.divmod(n, d, context: &context)
+ var quotient = pair.quotient
+ if !pair.remainder.isZero {
+ let twice = try DecimalMagnitude.multiply(pair.remainder, .init(borrowing: [2]), context: &context)
+ let order = try DecimalMagnitude.compare(twice, d, context: &context)
+ if order > 0 || order == 0 && quotient[quotient.count-1] & 1 == 1 { quotient = try .add(quotient, .init(borrowing: [1]), context: &context) }
+ try discarded(context: &context)
+ }
+ return try normalized(quotient, negative: negative, exponent: -Int64(scale), context: &context)
+ }
+ package static func unary(_ name: String, _ number: JSONNumber, context: inout CLIJobContext) throws -> FilterYield {
+ try context.checkpoint(); try admit(number, context: &context)
+ let c = number.components, output: Result
+ if name == "positive" { output = .init(components: c) }
+ else if name == "abs" { output = .init(components: .init(negative: false, digits: c.digits, exponent: c.exponent)) }
+ else if name == "negate" { output = .init(components: .init(negative: !c.isZero && !c.negative, digits: c.digits, exponent: c.exponent)) }
+ else if c.isZero || c.exponent >= 0 { output = .init(components: c) }
+ else {
+ let drop = c.exponent.magnitude, length = UInt64(c.digits.count), prefix = drop >= length ? 0 : Int(length-drop)
+ var quotient = prefix == 0 ? DecimalMagnitude.zero() : try DecimalMagnitude.prefix(c.digits, count: prefix, context: &context)
+ let increase: Bool
+ switch name {
+ case "floor": increase = c.negative
+ case "ceil": increase = !c.negative
+ case "trunc": increase = false
+ case "round": increase = drop <= length && c.digits[prefix] >= 5
+ default: throw FilterLanguageFailure("unknownArithmeticBuiltin")
+ }
+ if increase { quotient = try .add(quotient, .init(borrowing: [1]), context: &context) }
+ output = try normalized(quotient, negative: c.negative, exponent: 0, context: &context)
+ }
+ return try withExtendedLifetime(output) {
+ try admitToken(output.number, context: &context)
+ return try FilterValues.produced(.number(output.number), context: &context)
+ }
+ }
+}
diff --git a/Sources/JSONFilterRuntime/FilterCompiler.swift b/Sources/JSONFilterRuntime/FilterCompiler.swift
index df0331f..63a7177 100644
--- a/Sources/JSONFilterRuntime/FilterCompiler.swift
+++ b/Sources/JSONFilterRuntime/FilterCompiler.swift
@@ -14,9 +14,11 @@ package enum FilterCompiler {
"select":[1], "map":[1], "map_values":[1], "has":[1], "length":[0], "utf8bytelength":[0], "type":[0],
"keys":[0], "keys_unsorted":[0], "values":[0], "empty":[0], "not":[0],
"arrays":[0], "objects":[0], "iterables":[0], "booleans":[0], "numbers":[0], "normals":[0], "finites":[0], "strings":[0], "nulls":[0], "scalars":[0],
- "error":[0,1], "input":[0], "inputs":[0]
+ "error":[0,1], "input":[0], "inputs":[0],
+ "add":[0], "abs":[0], "floor":[0], "ceil":[0], "trunc":[0], "round":[0], "range":[1,2,3]
]
package static func compile(_ source: String, variables: Set = ["ARGS"], context: inout CLIJobContext) throws -> FilterProgram {
+ try context.domain(.core)
let tokens = try FilterLexer.lex(source, context: &context)
guard !tokens.isEmpty else { throw FilterCompileFailure("emptyFilter", at: 0) }
var matches: [Int:Int] = [:], nesting: [(Int,String)] = []
@@ -84,7 +86,6 @@ package enum FilterCompiler {
}
}
if found.isEmpty { continue }
- if level == 7 || level == 8 { throw FilterCompileFailure("arithmeticNotYetQualified", at: tokens[found[0]].range.lowerBound) }
if level == 3 { throw FilterCompileFailure("assignmentNotYetQualified", at: tokens[found[0]].range.lowerBound) }
if level == 6 && found.count > 1 { throw FilterCompileFailure("chainedComparison", at: tokens[found[1]].range.lowerBound) }
let position = level == 0 || level == 2 ? found.first! : found.last!, op = tokens[position].text!
@@ -107,11 +108,15 @@ package enum FilterCompiler {
let handler = try caught.map { try child(($0+1).. FilterYield {
+ if case .number(let lhs) = a, case .number(let rhs) = b {
+ return try ExactDecimal.binary(op, lhs, rhs, context: &context)
+ }
+ try context.checkpoint()
+ let entry = context.meter.used(.retainedBytes)
+ var owned: UInt64 = 0, collections: UInt64 = 0, transferred = false
+ defer {
+ try? context.meter.release(context.meter.used(.retainedBytes) - entry - owned)
+ if !transferred { try? context.release(.collectionValues, collections) }
+ }
+ func collect(_ count: UInt64, context: inout CLIJobContext) throws {
+ try context.charge(.collectionValues, count); collections += count
+ try context.meter.require(.arrayItems, collections)
+ try context.meter.retain(count * 16); try context.work(count)
+ }
+ var value: JSON
+ switch (op, a, b) {
+ case ("+", .null, _): value = b
+ case ("+", _, .null): value = a
+ case ("+", .string(let lhs), .string(let rhs)):
+ var text = "", bytes: UInt64 = 0
+ for source in [lhs, rhs] {
+ for scalar in source.unicodeScalars {
+ let size = UInt64(scalar.utf8.count)
+ try context.work(size); try context.meter.require(.stringBytes, bytes + size); try context.meter.retain(size)
+ text.unicodeScalars.append(scalar); bytes += size
+ }
+ }
+ value = .string(text)
+ case ("+", .array(let lhs), .array(let rhs)):
+ try collect(UInt64(lhs.count) + UInt64(rhs.count), context: &context)
+ value = .array(lhs + rhs)
+ case ("-", .array(let lhs), .array(let rhs)):
+ var values: [JSON] = []
+ for candidate in lhs {
+ var excluded = false
+ for match in rhs { try context.work(); if try FilterValues.equals(candidate, match, context: &context) { excluded = true; break } }
+ if !excluded { try collect(1, context: &context); values.append(candidate) }
+ }
+ value = .array(values)
+ case ("+", .object(let lhs), .object(let rhs)), ("*", .object(let lhs), .object(let rhs)):
+ value = try merge(lhs, rhs, recursive: op == "*", context: &context)
+ case ("*", .string(let text), .number(let count)), ("*", .number(let count), .string(let text)):
+ guard count.isInteger, !count.isNegative else { throw FilterLanguageFailure("invalidRepeatCount") }
+ // Check the host index before narrowing a count; no hidden iteration limit.
+ let repeats: Int
+ do { repeats = try count.integer(as: Int.self, meter: &context.meter) }
+ catch let failure as JSONFailure where failure.category == .conversion { throw CLIError(.resource, "counterOverflow", metric: "stringBytes") }
+ var bytes: UInt64 = 0
+ for _ in text.utf8 { try context.work(); bytes += 1 }
+ let (total, overflow) = bytes.multipliedReportingOverflow(by: UInt64(repeats))
+ guard !overflow else { throw CLIError(.resource, "counterOverflow", metric: "stringBytes") }
+ try context.meter.require(.stringBytes, total); try context.meter.retain(total)
+ var output = ""
+ for _ in 0.. JSON {
+ func frame(_ left: JSONObject, _ right: JSONObject, parent: Int?, context: inout CLIJobContext) throws -> MergeFrame {
+ try context.meter.require(.objectMembers, UInt64(left.count)); try context.meter.retain(80 + UInt64(left.count) * 24); try context.work(UInt64(left.count))
+ var index = JSONExactKeyIndex()
+ for position in left.members.indices { _ = try index.insert(left.members[position].key, position: position, meter: &context.meter) }
+ return .init(members: left.members, index: index, right: right, parentPosition: parent)
+ }
+ try context.require(.runtimeFrames, context.used(.runtimeFrames) + 1)
+ var stack = [try frame(left, right, parent: nil, context: &context)]
+ while !stack.isEmpty {
+ try context.work(); try context.require(.runtimeFrames, context.used(.runtimeFrames) + UInt64(stack.count))
+ var current = stack.removeLast()
+ if current.position == current.right.count {
+ let result = JSON.object(JSONObject(admitted: current.members, index: current.index))
+ if let parent = current.parentPosition { stack[stack.count-1].members[parent] = .init(stack[stack.count-1].members[parent].key, value: result) }
+ else { return result }
+ continue
+ }
+ let member = current.right.members[current.position]; current.position += 1
+ if let position = try current.index.find(member.key, meter: &context.meter) {
+ if recursive, case .object(let a) = current.members[position].value, case .object(let b) = member.value {
+ try context.require(.runtimeFrames, context.used(.runtimeFrames) + UInt64(stack.count) + 2)
+ stack.append(current); stack.append(try frame(a, b, parent: position, context: &context)); continue
+ }
+ current.members[position] = .init(current.members[position].key, value: member.value)
+ } else {
+ try context.meter.require(.objectMembers, UInt64(current.members.count) + 1); try context.meter.retain(24)
+ _ = try current.index.insert(member.key, position: current.members.count, meter: &context.meter)
+ current.members.append(member)
+ }
+ stack.append(current)
+ }
+ throw CLIError(.resource, "mergeInvariant")
+ }
+ package static func split(_ text: String, separator: String, context: inout CLIJobContext, collectionCount: inout UInt64) throws -> [JSON] {
+ var pattern: [Unicode.Scalar] = [], scalars: [Unicode.Scalar] = []
+ for scalar in separator.unicodeScalars { try context.work(); try context.meter.retain(4); pattern.append(scalar) }
+ for scalar in text.unicodeScalars { try context.work(); try context.meter.retain(4); scalars.append(scalar) }
+ var results: [JSON] = [], part = "", position = 0
+ func append(_ text: String, context: inout CLIJobContext) throws {
+ try context.charge(.collectionValues); collectionCount += 1
+ try context.meter.require(.arrayItems, collectionCount); try context.meter.retain(16)
+ results.append(.string(text))
+ }
+ while position < scalars.count {
+ try context.work()
+ if pattern.isEmpty { try context.meter.retain(UInt64(scalars[position].utf8.count)); try append(String(scalars[position]), context: &context); position += 1; continue }
+ var matches = position + pattern.count <= scalars.count
+ if matches { for offset in pattern.indices { try context.work(); if scalars[position+offset].value != pattern[offset].value { matches = false; break } } }
+ if matches { try append(part, context: &context); part = ""; position += pattern.count }
+ else { let scalar = scalars[position]; try context.meter.retain(UInt64(scalar.utf8.count)); part.unicodeScalars.append(scalar); position += 1 }
+ }
+ if !pattern.isEmpty { try append(part, context: &context) }
+ return results
+ }
+}
diff --git a/Sources/JSONFilterRuntime/FilterVM.swift b/Sources/JSONFilterRuntime/FilterVM.swift
index 4bc87af..0ebdc5e 100644
--- a/Sources/JSONFilterRuntime/FilterVM.swift
+++ b/Sources/JSONFilterRuntime/FilterVM.swift
@@ -24,6 +24,7 @@ package struct FilterVM {
var bindingSlots: UInt64 = 0
var scopeBytes: UInt64 = 0
var index = 0
+ var range: FilterRangeState?
var current: FilterYield?
var flag = false
var groups: [[FilterYield]] = []
@@ -272,10 +273,8 @@ package struct FilterVM {
switch incoming {
case .end: return .emit(.end)
case .value(let value):
- guard op == "-", case .number(let n) = value.value else { throw FilterLanguageFailure("expectedNumber") }
- let c = n.components, negative = !c.isZero && !c.negative
- let result = JSON.number(JSONNumber(components: .init(negative: negative, digits: c.digits, exponent: c.exponent)))
- return .emit(.value(try FilterValues.produced(result, context: &context)))
+ guard case .number(let n) = value.value else { throw FilterLanguageFailure("expectedNumber") }
+ return .emit(.value(try ExactDecimal.unary(op == "-" ? "negate" : "positive", n, context: &context)))
case .failure(let failure): throw failure
}
}
@@ -322,8 +321,9 @@ package struct FilterVM {
let lhs = frame.values[frame.index], rhs = frame.current!; frame.index += 1
if case .index = node { return .emit(.value(lhs.selecting(try FilterValues.index(lhs.value, key: rhs.value, context: &context)))) }
guard case .binary(let op, _, _) = node else { throw FilterLanguageFailure("invalidState") }
+ if ["+","-","*","/","%"].contains(op) { return .emit(.value(try FilterOperators.apply(op, lhs.value, rhs.value, context: &context))) }
let result: Bool
- if op == "==" || op == "!=" { let equal = try JSONComparison.equals(lhs.value, rhs.value, meter: &context.meter); result = op == "==" ? equal : !equal }
+ if op == "==" || op == "!=" { let equal = try FilterValues.equals(lhs.value, rhs.value, context: &context); result = op == "==" ? equal : !equal }
else {
let order = try FilterValues.compare(lhs.value, rhs.value, context: &context)
switch op { case "<": result = order < 0; case ">": result = order > 0; case "<=": result = order <= 0; case ">=": result = order >= 0; default: throw FilterCompileFailure("arithmeticNotYetQualified", at: program.sourceRanges[frame.node].lowerBound) }
@@ -447,6 +447,7 @@ package struct FilterVM {
return .emit(.value(result))
}
private mutating func call(_ name: String, arguments: [Int], frame: inout Frame, incoming: Event?, input: inout Input, context: inout CLIJobContext) throws -> Action {
+ if name == "range" { return try range(arguments, frame: &frame, incoming: incoming, context: &context) }
if name == "input" || name == "inputs" {
if name == "input" && frame.phase > 0 { return .emit(.end) }
frame.phase += 1
@@ -456,6 +457,16 @@ package struct FilterVM {
}
if arguments.isEmpty {
if frame.phase > 0 { return .emit(.end) }; frame.phase = 1
+ if ["abs","floor","ceil","trunc","round"].contains(name) {
+ guard case .number(let number) = frame.input.value else { throw FilterLanguageFailure("expectedNumber") }
+ return .emit(.value(try ExactDecimal.unary(name, number, context: &context)))
+ }
+ if name == "add" {
+ guard case .array(let values) = frame.input.value else { throw FilterLanguageFailure("expectedArray") }
+ var result = FilterYield(value: .null)
+ for value in values { try context.work(); result = try FilterOperators.apply("+", result.value, value, context: &context) }
+ return .emit(.value(result))
+ }
if name == "error" { throw try languageError(frame.input.value, frame: &frame, context: &context) }
if let value = try FilterPrimitiveBuiltins.apply(name, value: frame.input.value, context: &context) {
// Selectors borrow the original input's lifetime; constructed values
@@ -534,6 +545,42 @@ package struct FilterVM {
}
throw FilterCompileFailure("unsupportedBuiltin", at: program.sourceRanges[frame.node].lowerBound)
}
+ private mutating func range(_ arguments: [Int], frame: inout Frame, incoming: Event?, context: inout CLIJobContext) throws -> Action {
+ if frame.phase == 0 {
+ let bytes = UInt64(arguments.count) * 32
+ try context.meter.retain(bytes); frame.slots += bytes
+ frame.groups = Array(repeating: [], count: arguments.count)
+ frame.selections = Array(repeating: 0, count: arguments.count); frame.phase = 1
+ }
+ if let incoming {
+ switch incoming {
+ case .value(let value): try captureGroup(value, group: frame.index, frame: &frame, context: &context); return .pull(frame.children.last!)
+ case .end: try dispose(frame.children.removeLast(), context: &context); frame.index += 1
+ case .failure(let failure): throw failure
+ }
+ }
+ if frame.phase == 1 {
+ if frame.index < arguments.count { return .pull(try child(arguments[frame.index], frame: &frame, context: &context)) }
+ if frame.groups.contains(where: { $0.isEmpty }) { frame.phase = 99; return .emit(.end) }
+ frame.phase = 2
+ }
+ while true {
+ try context.work()
+ if frame.range == nil {
+ if frame.flag { frame.phase = 99; return .emit(.end) }
+ func number(_ index: Int) throws -> JSONNumber {
+ guard case .number(let n) = frame.groups[index][frame.selections[index]].value else { throw FilterLanguageFailure("expectedNumber") }; return n
+ }
+ let start = arguments.count == 1 ? JSONNumber(integer: 0) : try number(0)
+ let end = try number(arguments.count == 1 ? 0 : 1)
+ let step = arguments.count == 3 ? try number(2) : JSONNumber(integer: 1)
+ frame.range = try FilterRangeState(start: start, end: end, step: step, context: &context)
+ }
+ if let value = try frame.range!.next(context: &context) { return .emit(.value(value)) }
+ frame.range = nil
+ frame.flag = try !advance(&frame.selections, counts: frame.groups.map(\.count), context: &context)
+ }
+ }
private func languageError(_ value: JSON, frame: inout Frame, context: inout CLIJobContext) throws -> FilterLanguageFailure {
try context.checkpoint()
let entry = context.meter.used(.retainedBytes)
diff --git a/Sources/JSONFilterRuntime/FilterValues.swift b/Sources/JSONFilterRuntime/FilterValues.swift
index 2beaacc..562e35f 100644
--- a/Sources/JSONFilterRuntime/FilterValues.swift
+++ b/Sources/JSONFilterRuntime/FilterValues.swift
@@ -45,6 +45,12 @@ package enum FilterValues {
default:throw FilterLanguageFailure("invalidIndexKind")
}
}
+ package static func equals(_ a: JSON, _ b: JSON, context: inout CLIJobContext) throws -> Bool {
+ try context.checkpoint()
+ let entry = context.meter.used(.retainedBytes)
+ defer { try? context.meter.release(context.meter.used(.retainedBytes) - entry) }
+ return try JSONComparison.equals(a, b, meter: &context.meter)
+ }
package static func has(_ value:JSON,key:JSON,context:inout CLIJobContext)throws->Bool {
switch (value,key) {
case (.object(let object),.string(let text)):return try object.lookup(text,meter:&context.meter) != nil
diff --git a/Sources/JSONFilterRuntime/RangeState.swift b/Sources/JSONFilterRuntime/RangeState.swift
new file mode 100644
index 0000000..847282e
--- /dev/null
+++ b/Sources/JSONFilterRuntime/RangeState.swift
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: Apache-2.0
+import JSON
+
+/// One bounded exact progression, with no host-int iteration guard or eager array.
+package struct FilterRangeState {
+ private var current: FilterYield
+ private let end: JSONNumber
+ private let step: JSONNumber
+ private var advance = false
+ package init(start: JSONNumber, end: JSONNumber, step: JSONNumber, context: inout CLIJobContext) throws {
+ guard !step.isZero else { throw FilterLanguageFailure("zeroRangeStep") }
+ // Admission precedes sparse progression, including a range with no results.
+ for number in [start,end,step] { try context.meter.resetValueBounds(); try JSONAdmission.value(.number(number), meter: &context.meter) }
+ current = try FilterValues.produced(.number(start), context: &context)
+ self.end = end; self.step = step
+ }
+ package mutating func next(context: inout CLIJobContext) throws -> FilterYield? {
+ try context.work()
+ if advance {
+ guard case .number(let number) = current.value else { throw CLIError(.resource, "rangeInvariant") }
+ current = try ExactDecimal.binary("+", number, step, context: &context)
+ }
+ guard case .number(let number) = current.value else { throw CLIError(.resource, "rangeInvariant") }
+ let order = try number.compare(to: end, meter: &context.meter)
+ if step.isNegative ? order != .orderedDescending : order != .orderedAscending { try current.release(context: &context); return nil }
+ advance = true; return current
+ }
+}
diff --git a/Tests/Fixtures/CLI/ArithmeticOracle.json b/Tests/Fixtures/CLI/ArithmeticOracle.json
new file mode 100644
index 0000000..398a021
--- /dev/null
+++ b/Tests/Fixtures/CLI/ArithmeticOracle.json
@@ -0,0 +1,5858 @@
+{
+ "schema_version": 1,
+ "oracle": "Python fractions.Fraction and arbitrary-width integers; no float/Decimal",
+ "seed": 82115,
+ "count": 738,
+ "cases": [
+ {
+ "id": 0,
+ "op": "+",
+ "lhs": "-8595624772995493818525462e-2",
+ "expected": "-86950354149884251451405.0257",
+ "rounded": 0,
+ "rhs": "-9941064199293132661504057e-4"
+ },
+ {
+ "id": 1,
+ "op": "-",
+ "lhs": "-8595624772995493818525462e-2",
+ "expected": "-84962141310025624919104.2143",
+ "rounded": 0,
+ "rhs": "-9941064199293132661504057e-4"
+ },
+ {
+ "id": 2,
+ "op": "*",
+ "lhs": "-8595624772995493818525462e-2",
+ "expected": "85449657701382663954667648138370147399998870.799334",
+ "rounded": 0,
+ "rhs": "-9941064199293132661504057e-4"
+ },
+ {
+ "id": 3,
+ "op": "+",
+ "lhs": "2874435027637710824082715e1",
+ "expected": "-59460404154133765063102620",
+ "rounded": 0,
+ "rhs": "-8820475443051087330392977e1"
+ },
+ {
+ "id": 4,
+ "op": "-",
+ "lhs": "2874435027637710824082715e1",
+ "expected": "116949104706887981544756920",
+ "rounded": 0,
+ "rhs": "-8820475443051087330392977e1"
+ },
+ {
+ "id": 5,
+ "op": "*",
+ "lhs": "2874435027637710824082715e1",
+ "expected": "-2535388357392430183650695436543821529501650309255500",
+ "rounded": 0,
+ "rhs": "-8820475443051087330392977e1"
+ },
+ {
+ "id": 6,
+ "op": "+",
+ "lhs": "-3622642127631275563086307e-3",
+ "expected": "-3107805917851484558519.6222",
+ "rounded": 0,
+ "rhs": "5148362097797910045666848e-4"
+ },
+ {
+ "id": 7,
+ "op": "-",
+ "lhs": "-3622642127631275563086307e-3",
+ "expected": "-4137478337411066567652.9918",
+ "rounded": 0,
+ "rhs": "5148362097797910045666848e-4"
+ },
+ {
+ "id": 8,
+ "op": "*",
+ "lhs": "-3622642127631275563086307e-3",
+ "expected": "-1865067342378283804624879378398203540394679.2650336",
+ "rounded": 0,
+ "rhs": "5148362097797910045666848e-4"
+ },
+ {
+ "id": 9,
+ "op": "+",
+ "lhs": "9325895258443537766832244e0",
+ "expected": "9031669284107396904803412.6",
+ "rounded": 0,
+ "rhs": "-2942259743361408620288314e-1"
+ },
+ {
+ "id": 10,
+ "op": "-",
+ "lhs": "9325895258443537766832244e0",
+ "expected": "9620121232779678628861075.4",
+ "rounded": 0,
+ "rhs": "-2942259743361408620288314e-1"
+ },
+ {
+ "id": 11,
+ "op": "*",
+ "lhs": "9325895258443537766832244e0",
+ "expected": "-2743920618972346094815804065332490522324975159661.6",
+ "rounded": 0,
+ "rhs": "-2942259743361408620288314e-1"
+ },
+ {
+ "id": 12,
+ "op": "+",
+ "lhs": "5316620605909094804418083e-6",
+ "expected": "-2630991976746011682910986.581917",
+ "rounded": 0,
+ "rhs": "-2630997293366617592005791e0"
+ },
+ {
+ "id": 13,
+ "op": "-",
+ "lhs": "5316620605909094804418083e-6",
+ "expected": "2631002609987223501100595.418083",
+ "rounded": 0,
+ "rhs": "-2630997293366617592005791e0"
+ },
+ {
+ "id": 14,
+ "op": "*",
+ "lhs": "5316620605909094804418083e-6",
+ "expected": "-13988014424004014878651102671273607118728521.118653",
+ "rounded": 0,
+ "rhs": "-2630997293366617592005791e0"
+ },
+ {
+ "id": 15,
+ "op": "+",
+ "lhs": "1756686888944210427534172e2",
+ "expected": "175527963870610989839592479.3",
+ "rounded": 0,
+ "rhs": "-1407250238100529138247207e-1"
+ },
+ {
+ "id": 16,
+ "op": "-",
+ "lhs": "1756686888944210427534172e2",
+ "expected": "175809413918231095667241920.7",
+ "rounded": 0,
+ "rhs": "-1407250238100529138247207e-1"
+ },
+ {
+ "id": 17,
+ "op": "*",
+ "lhs": "1756686888944210427534172e2",
+ "expected": "-24720980427348179119852738002587892038631760576040",
+ "rounded": 0,
+ "rhs": "-1407250238100529138247207e-1"
+ },
+ {
+ "id": 18,
+ "op": "+",
+ "lhs": "-2674017692929723703671605e5",
+ "expected": "-267401769388609734133753506352.0501",
+ "rounded": 0,
+ "rhs": "-9563736376659300635205010e-5"
+ },
+ {
+ "id": 19,
+ "op": "-",
+ "lhs": "-2674017692929723703671605e5",
+ "expected": "-267401769197335006600567493647.9499",
+ "rounded": 0,
+ "rhs": "-9563736376659300635205010e-5"
+ },
+ {
+ "id": 20,
+ "op": "*",
+ "lhs": "-2674017692929723703671605e5",
+ "expected": "25573600281702578159931575712236243664458890741050",
+ "rounded": 0,
+ "rhs": "-9563736376659300635205010e-5"
+ },
+ {
+ "id": 21,
+ "op": "+",
+ "lhs": "-3366193670800077789383504e2",
+ "expected": "-336619365934203228303093624.229681",
+ "rounded": 0,
+ "rhs": "1145804550635256775770319e-6"
+ },
+ {
+ "id": 22,
+ "op": "-",
+ "lhs": "-3366193670800077789383504e2",
+ "expected": "-336619368225812329573607175.770319",
+ "rounded": 0,
+ "rhs": "1145804550635256775770319e-6"
+ },
+ {
+ "id": 23,
+ "op": "*",
+ "lhs": "-3366193670800077789383504e2",
+ "expected": "-385700002632232860936047260667313911187971141.7776",
+ "rounded": 0,
+ "rhs": "1145804550635256775770319e-6"
+ },
+ {
+ "id": 24,
+ "op": "+",
+ "lhs": "-5239748017626352462683274e0",
+ "expected": "-5239746147611358466520153.64851",
+ "rounded": 0,
+ "rhs": "187001499399616312035149e-5"
+ },
+ {
+ "id": 25,
+ "op": "-",
+ "lhs": "-5239748017626352462683274e0",
+ "expected": "-5239749887641346458846394.35149",
+ "rounded": 0,
+ "rhs": "187001499399616312035149e-5"
+ },
+ {
+ "id": 26,
+ "op": "*",
+ "lhs": "-5239748017626352462683274e0",
+ "expected": "-9798407357722951112214396684488822426763423.97826",
+ "rounded": 0,
+ "rhs": "187001499399616312035149e-5"
+ },
+ {
+ "id": 27,
+ "op": "+",
+ "lhs": "-9471291229703956939119415e1",
+ "expected": "-95209893528521967078181474.6",
+ "rounded": 0,
+ "rhs": "-4969812314823976869873246e-1"
+ },
+ {
+ "id": 28,
+ "op": "-",
+ "lhs": "-9471291229703956939119415e1",
+ "expected": "-94215931065557171704206825.4",
+ "rounded": 0,
+ "rhs": "-4969812314823976869873246e-1"
+ },
+ {
+ "id": 29,
+ "op": "*",
+ "lhs": "-9471291229703956939119415e1",
+ "expected": "47070539790667052671670810400256810770069907671090",
+ "rounded": 0,
+ "rhs": "-4969812314823976869873246e-1"
+ },
+ {
+ "id": 30,
+ "op": "+",
+ "lhs": "5961287589668891699461299e3",
+ "expected": "-5229081050958844291729779701000",
+ "rounded": 0,
+ "rhs": "-5235042338548513183429241e6"
+ },
+ {
+ "id": 31,
+ "op": "-",
+ "lhs": "5961287589668891699461299e3",
+ "expected": "5241003626138182075128702299000",
+ "rounded": 0,
+ "rhs": "-5235042338548513183429241e6"
+ },
+ {
+ "id": 32,
+ "op": "*",
+ "lhs": "5961287589668891699461299e3",
+ "expected": "-31207592924180464281363182805907923241773184444059000000000",
+ "rounded": 0,
+ "rhs": "-5235042338548513183429241e6"
+ },
+ {
+ "id": 33,
+ "op": "+",
+ "lhs": "-2846139285353146441657775e6",
+ "expected": "-2847044374375572127502491025100",
+ "rounded": 0,
+ "rhs": "-9050890224256858447160251e2"
+ },
+ {
+ "id": 34,
+ "op": "-",
+ "lhs": "-2846139285353146441657775e6",
+ "expected": "-2845234196330720755813058974900",
+ "rounded": 0,
+ "rhs": "-9050890224256858447160251e2"
+ },
+ {
+ "id": 35,
+ "op": "*",
+ "lhs": "-2846139285353146441657775e6",
+ "expected": "2576009423467619443367833780927651926239752510152500000000",
+ "rounded": 0,
+ "rhs": "-9050890224256858447160251e2"
+ },
+ {
+ "id": 36,
+ "op": "+",
+ "lhs": "-9061846603300107658812108e1",
+ "expected": "-951719785694614681142534421080",
+ "rounded": 0,
+ "rhs": "-9516291672285816800659463e5"
+ },
+ {
+ "id": 37,
+ "op": "-",
+ "lhs": "-9061846603300107658812108e1",
+ "expected": "951538548762548678989358178920",
+ "rounded": 0,
+ "rhs": "-9516291672285816800659463e5"
+ },
+ {
+ "id": 38,
+ "op": "*",
+ "lhs": "-9061846603300107658812108e1",
+ "expected": "86235175366516330234479139530413843406817609178004000000",
+ "rounded": 0,
+ "rhs": "-9516291672285816800659463e5"
+ },
+ {
+ "id": 39,
+ "op": "+",
+ "lhs": "-6123671684709733145050565e0",
+ "expected": "-695191870651081741506752",
+ "rounded": 0,
+ "rhs": "5428479814058651403543813e0"
+ },
+ {
+ "id": 40,
+ "op": "-",
+ "lhs": "-6123671684709733145050565e0",
+ "expected": "-11552151498768384548594378",
+ "rounded": 0,
+ "rhs": "5428479814058651403543813e0"
+ },
+ {
+ "id": 41,
+ "op": "*",
+ "lhs": "-6123671684709733145050565e0",
+ "expected": "-33242228128369320766383457878384782254002077904345",
+ "rounded": 0,
+ "rhs": "5428479814058651403543813e0"
+ },
+ {
+ "id": 42,
+ "op": "+",
+ "lhs": "-3048052221082042117734051e-2",
+ "expected": "-33950310732635862590804.595",
+ "rounded": 0,
+ "rhs": "-3469788521815441413464085e-3"
+ },
+ {
+ "id": 43,
+ "op": "-",
+ "lhs": "-3048052221082042117734051e-2",
+ "expected": "-27010733689004979763876.425",
+ "rounded": 0,
+ "rhs": "-3469788521815441413464085e-3"
+ },
+ {
+ "id": 44,
+ "op": "*",
+ "lhs": "-3048052221082042117734051e-2",
+ "expected": "105760966106045319508236248190599974218626700.58335",
+ "rounded": 0,
+ "rhs": "-3469788521815441413464085e-3"
+ },
+ {
+ "id": 45,
+ "op": "+",
+ "lhs": "8459304254462562190065808e-4",
+ "expected": "-3110298646482270731623968993.4192",
+ "rounded": 0,
+ "rhs": "-3110299492412696177880188e3"
+ },
+ {
+ "id": 46,
+ "op": "-",
+ "lhs": "8459304254462562190065808e-4",
+ "expected": "3110300338343121624136407006.5808",
+ "rounded": 0,
+ "rhs": "-3110299492412696177880188e3"
+ },
+ {
+ "id": 47,
+ "op": "*",
+ "lhs": "8459304254462562190065808e-4",
+ "expected": "-2631096972881946844612240276756133602896565941190.4",
+ "rounded": 0,
+ "rhs": "-3110299492412696177880188e3"
+ },
+ {
+ "id": 48,
+ "op": "+",
+ "lhs": "-974437170174381635628181e-4",
+ "expected": "979732059888395337829093437.1819",
+ "rounded": 0,
+ "rhs": "979732157332112355267257e3"
+ },
+ {
+ "id": 49,
+ "op": "-",
+ "lhs": "-974437170174381635628181e-4",
+ "expected": "-979732254775829372705420562.8181",
+ "rounded": 0,
+ "rhs": "979732157332112355267257e3"
+ },
+ {
+ "id": 50,
+ "op": "*",
+ "lhs": "-974437170174381635628181e-4",
+ "expected": "-95468743091954560966176062158293880906933576951.7",
+ "rounded": 0,
+ "rhs": "979732157332112355267257e3"
+ },
+ {
+ "id": 51,
+ "op": "+",
+ "lhs": "-1968494674103724818228910e5",
+ "expected": "-196840649325045420287714183832",
+ "rounded": 0,
+ "rhs": "8818085327061535176816168e0"
+ },
+ {
+ "id": 52,
+ "op": "-",
+ "lhs": "-1968494674103724818228910e5",
+ "expected": "-196858285495699543358067816168",
+ "rounded": 0,
+ "rhs": "8818085327061535176816168e0"
+ },
+ {
+ "id": 53,
+ "op": "*",
+ "lhs": "-1968494674103724818228910e5",
+ "expected": "-1735835400211283436350275110832274286258241301688000000",
+ "rounded": 0,
+ "rhs": "8818085327061535176816168e0"
+ },
+ {
+ "id": 54,
+ "op": "+",
+ "lhs": "-683011596707208478846647e4",
+ "expected": "-6830047485650634701211321685.45",
+ "rounded": 0,
+ "rhs": "6848142145008725514831455e-2"
+ },
+ {
+ "id": 55,
+ "op": "-",
+ "lhs": "-683011596707208478846647e4",
+ "expected": "-6830184448493534875721618314.55",
+ "rounded": 0,
+ "rhs": "6848142145008725514831455e-2"
+ },
+ {
+ "id": 56,
+ "op": "*",
+ "lhs": "-683011596707208478846647e4",
+ "expected": "-467736050094033723710818882126110214803099688138500",
+ "rounded": 0,
+ "rhs": "6848142145008725514831455e-2"
+ },
+ {
+ "id": 57,
+ "op": "+",
+ "lhs": "8178843845282739595941841e5",
+ "expected": "-7168185723337206990644972900000",
+ "rounded": 0,
+ "rhs": "-7986070107865480950239157e6"
+ },
+ {
+ "id": 58,
+ "op": "-",
+ "lhs": "8178843845282739595941841e5",
+ "expected": "8803954492393754909833341100000",
+ "rounded": 0,
+ "rhs": "-7986070107865480950239157e6"
+ },
+ {
+ "id": 59,
+ "op": "*",
+ "lhs": "8178843845282739595941841e5",
+ "expected": "-6531682034971205319328938116225163184697561286803700000000000",
+ "rounded": 0,
+ "rhs": "-7986070107865480950239157e6"
+ },
+ {
+ "id": 60,
+ "op": "+",
+ "lhs": "4839261254680575376667205e-1",
+ "expected": "-912383294131110163217450579.5",
+ "rounded": 0,
+ "rhs": "-9128672202565782207551173e2"
+ },
+ {
+ "id": 61,
+ "op": "-",
+ "lhs": "4839261254680575376667205e-1",
+ "expected": "913351146382046278292784020.5",
+ "rounded": 0,
+ "rhs": "-9128672202565782207551173e2"
+ },
+ {
+ "id": 62,
+ "op": "*",
+ "lhs": "4839261254680575376667205e-1",
+ "expected": "-441760296965561787459376288487020943215052283814650",
+ "rounded": 0,
+ "rhs": "-9128672202565782207551173e2"
+ },
+ {
+ "id": 63,
+ "op": "+",
+ "lhs": "8583913171865179344728939e4",
+ "expected": "85838664088344538968102538539.8",
+ "rounded": 0,
+ "rhs": "-4676303072544791868514602e-1"
+ },
+ {
+ "id": 64,
+ "op": "-",
+ "lhs": "8583913171865179344728939e4",
+ "expected": "85839599348959047926476241460.2",
+ "rounded": 0,
+ "rhs": "-4676303072544791868514602e-1"
+ },
+ {
+ "id": 65,
+ "op": "*",
+ "lhs": "8583913171865179344728939e4",
+ "expected": "-40140979540050848235654419438438667652624253467278000",
+ "rounded": 0,
+ "rhs": "-4676303072544791868514602e-1"
+ },
+ {
+ "id": 66,
+ "op": "+",
+ "lhs": "-7836603013926718039877092e4",
+ "expected": "-78366157705840150017429628314",
+ "rounded": 0,
+ "rhs": "-1275665729696186587083140e-1"
+ },
+ {
+ "id": 67,
+ "op": "-",
+ "lhs": "-7836603013926718039877092e4",
+ "expected": "-78365902572694210780112211686",
+ "rounded": 0,
+ "rhs": "-1275665729696186587083140e-1"
+ },
+ {
+ "id": 68,
+ "op": "*",
+ "lhs": "-7836603013926718039877092e4",
+ "expected": "9996885902100161827508352111451297916800385428880000",
+ "rounded": 0,
+ "rhs": "-1275665729696186587083140e-1"
+ },
+ {
+ "id": 69,
+ "op": "+",
+ "lhs": "4558074426078354610184368e4",
+ "expected": "4960993936232656210203153680000",
+ "rounded": 0,
+ "rhs": "4915413191971872664101310e6"
+ },
+ {
+ "id": 70,
+ "op": "-",
+ "lhs": "4558074426078354610184368e4",
+ "expected": "-4869832447711089117999466320000",
+ "rounded": 0,
+ "rhs": "4915413191971872664101310e6"
+ },
+ {
+ "id": 71,
+ "op": "*",
+ "lhs": "4558074426078354610184368e4",
+ "expected": "224048191639351665861207254970408493648741303220800000000000",
+ "rounded": 0,
+ "rhs": "4915413191971872664101310e6"
+ },
+ {
+ "id": 72,
+ "op": "+",
+ "lhs": "-6582972736648659385232274e-5",
+ "expected": "-148790224216877363611.7326",
+ "rounded": 0,
+ "rhs": "-8296049685039076975940986e-5"
+ },
+ {
+ "id": 73,
+ "op": "-",
+ "lhs": "-6582972736648659385232274e-5",
+ "expected": "17130769483904175907.08712",
+ "rounded": 0,
+ "rhs": "-8296049685039076975940986e-5"
+ },
+ {
+ "id": 74,
+ "op": "*",
+ "lhs": "-6582972736648659385232274e-5",
+ "expected": "5461266889849494131577868679968200234056.3326582164",
+ "rounded": 0,
+ "rhs": "-8296049685039076975940986e-5"
+ },
+ {
+ "id": 75,
+ "op": "+",
+ "lhs": "-4427874145474139495226075e-1",
+ "expected": "45339288791114075097544907392.5",
+ "rounded": 0,
+ "rhs": "4533973157852862251149443e4"
+ },
+ {
+ "id": 76,
+ "op": "-",
+ "lhs": "-4427874145474139495226075e-1",
+ "expected": "-45340174365943169925443952607.5",
+ "rounded": 0,
+ "rhs": "4533973157852862251149443e4"
+ },
+ {
+ "id": 77,
+ "op": "*",
+ "lhs": "-4427874145474139495226075e-1",
+ "expected": "-20075862521930428220544044564577380906979895326225000",
+ "rounded": 0,
+ "rhs": "4533973157852862251149443e4"
+ },
+ {
+ "id": 78,
+ "op": "+",
+ "lhs": "-5556169769837107434641373e-5",
+ "expected": "-5097808915355320920583.05173",
+ "rounded": 0,
+ "rhs": "-5042247217656949846236638e-3"
+ },
+ {
+ "id": 79,
+ "op": "-",
+ "lhs": "-5556169769837107434641373e-5",
+ "expected": "4986685519958578771890.22427",
+ "rounded": 0,
+ "rhs": "-5042247217656949846236638e-3"
+ },
+ {
+ "id": 80,
+ "op": "*",
+ "lhs": "-5556169769837107434641373e-5",
+ "expected": "280155815627908103816096164785767594866972.23223974",
+ "rounded": 0,
+ "rhs": "-5042247217656949846236638e-3"
+ },
+ {
+ "id": 81,
+ "op": "+",
+ "lhs": "-4408604786169015208535331e3",
+ "expected": "-4479191047590721547288624880",
+ "rounded": 0,
+ "rhs": "-7058626142170633875329388e1"
+ },
+ {
+ "id": 82,
+ "op": "-",
+ "lhs": "-4408604786169015208535331e3",
+ "expected": "-4338018524747308869782037120",
+ "rounded": 0,
+ "rhs": "-7058626142170633875329388e1"
+ },
+ {
+ "id": 83,
+ "op": "*",
+ "lhs": "-4408604786169015208535331e3",
+ "expected": "311186929941511881008227759104959581844466606074280000",
+ "rounded": 0,
+ "rhs": "-7058626142170633875329388e1"
+ },
+ {
+ "id": 84,
+ "op": "+",
+ "lhs": "-2071218021775656574470249e3",
+ "expected": "-2071214229579469121519847025.906",
+ "rounded": 0,
+ "rhs": "3792196187452950401974094e-3"
+ },
+ {
+ "id": 85,
+ "op": "-",
+ "lhs": "-2071218021775656574470249e3",
+ "expected": "-2071221813971844027420650974.094",
+ "rounded": 0,
+ "rhs": "3792196187452950401974094e-3"
+ },
+ {
+ "id": 86,
+ "op": "*",
+ "lhs": "-2071218021775656574470249e3",
+ "expected": "-7854465085561486866666831227888685062371871729406",
+ "rounded": 0,
+ "rhs": "3792196187452950401974094e-3"
+ },
+ {
+ "id": 87,
+ "op": "+",
+ "lhs": "5079752697676676814749933e-3",
+ "expected": "2103204858609379009766398814749.933",
+ "rounded": 0,
+ "rhs": "2103204853529626312089722e6"
+ },
+ {
+ "id": 88,
+ "op": "-",
+ "lhs": "5079752697676676814749933e-3",
+ "expected": "-2103204848449873614413045185250.067",
+ "rounded": 0,
+ "rhs": "2103204853529626312089722e6"
+ },
+ {
+ "id": 89,
+ "op": "*",
+ "lhs": "5079752697676676814749933e-3",
+ "expected": "10683760528483799189292955948377710014210089488626000",
+ "rounded": 0,
+ "rhs": "2103204853529626312089722e6"
+ },
+ {
+ "id": 90,
+ "op": "+",
+ "lhs": "-1261310557054748205482688e0",
+ "expected": "-1260620208984569038219554.2274",
+ "rounded": 0,
+ "rhs": "6903480701791672631337726e-4"
+ },
+ {
+ "id": 91,
+ "op": "-",
+ "lhs": "-1261310557054748205482688e0",
+ "expected": "-1262000905124927372745821.7726",
+ "rounded": 0,
+ "rhs": "6903480701791672631337726e-4"
+ },
+ {
+ "id": 92,
+ "op": "*",
+ "lhs": "-1261310557054748205482688e0",
+ "expected": "-870743308959355868460170448967316812635697428.7488",
+ "rounded": 0,
+ "rhs": "6903480701791672631337726e-4"
+ },
+ {
+ "id": 93,
+ "op": "+",
+ "lhs": "-3555628809775349555782706e-3",
+ "expected": "-253319588879102341478318.406",
+ "rounded": 0,
+ "rhs": "-2497639600693269919225357e-1"
+ },
+ {
+ "id": 94,
+ "op": "-",
+ "lhs": "-3555628809775349555782706e-3",
+ "expected": "246208331259551642366752.994",
+ "rounded": 0,
+ "rhs": "-2497639600693269919225357e-1"
+ },
+ {
+ "id": 95,
+ "op": "*",
+ "lhs": "-3555628809775349555782706e-3",
+ "expected": "888067932066079065211360433717630602006333727.6042",
+ "rounded": 0,
+ "rhs": "-2497639600693269919225357e-1"
+ },
+ {
+ "id": 96,
+ "op": "+",
+ "lhs": "-4358019892914371083355858e-3",
+ "expected": "-4298247999584844330144.06094",
+ "rounded": 0,
+ "rhs": "5977189332952675321179706e-5"
+ },
+ {
+ "id": 97,
+ "op": "-",
+ "lhs": "-4358019892914371083355858e-3",
+ "expected": "-4417791786243897836567.65506",
+ "rounded": 0,
+ "rhs": "5977189332952675321179706e-5"
+ },
+ {
+ "id": 98,
+ "op": "*",
+ "lhs": "-4358019892914371083355858e-3",
+ "expected": "-260487100167233392301136636175320857472859.65817748",
+ "rounded": 0,
+ "rhs": "5977189332952675321179706e-5"
+ },
+ {
+ "id": 99,
+ "op": "+",
+ "lhs": "2244949611632579218813827e0",
+ "expected": "-9163469573646737460489193186173",
+ "rounded": 0,
+ "rhs": "-9163471818596349093068412e6"
+ },
+ {
+ "id": 100,
+ "op": "-",
+ "lhs": "2244949611632579218813827e0",
+ "expected": "9163474063545960725647630813827",
+ "rounded": 0,
+ "rhs": "-9163471818596349093068412e6"
+ },
+ {
+ "id": 101,
+ "op": "*",
+ "lhs": "2244949611632579218813827e0",
+ "expected": "-20571532500363958307134331462448768276826402532724000000",
+ "rounded": 0,
+ "rhs": "-9163471818596349093068412e6"
+ },
+ {
+ "id": 102,
+ "op": "+",
+ "lhs": "-4374259384653192273767262e0",
+ "expected": "-4374251251857090681996889.204291",
+ "rounded": 0,
+ "rhs": "8132796101591770372795709e-6"
+ },
+ {
+ "id": 103,
+ "op": "-",
+ "lhs": "-4374259384653192273767262e0",
+ "expected": "-4374267517449293865537634.795709",
+ "rounded": 0,
+ "rhs": "8132796101591770372795709e-6"
+ },
+ {
+ "id": 104,
+ "op": "*",
+ "lhs": "-4374259384653192273767262e0",
+ "expected": "-35574959670858698468059061218583247446128538.278758",
+ "rounded": 0,
+ "rhs": "8132796101591770372795709e-6"
+ },
+ {
+ "id": 105,
+ "op": "+",
+ "lhs": "-6277384710103686378784432e3",
+ "expected": "-6989461652598854749504625432000",
+ "rounded": 0,
+ "rhs": "-6983184267888751063125841e6"
+ },
+ {
+ "id": 106,
+ "op": "-",
+ "lhs": "-6277384710103686378784432e3",
+ "expected": "6976906883178647376747056568000",
+ "rounded": 0,
+ "rhs": "-6983184267888751063125841e6"
+ },
+ {
+ "id": 107,
+ "op": "*",
+ "lhs": "-6277384710103686378784432e3",
+ "expected": "43836134151081450993784198605598786585443827707312000000000",
+ "rounded": 0,
+ "rhs": "-6983184267888751063125841e6"
+ },
+ {
+ "id": 108,
+ "op": "+",
+ "lhs": "-3045077954302574678753718e0",
+ "expected": "-3098337269096212263060520.75",
+ "rounded": 0,
+ "rhs": "-5325931479363758430680275e-2"
+ },
+ {
+ "id": 109,
+ "op": "-",
+ "lhs": "-3045077954302574678753718e0",
+ "expected": "-2991818639508937094446915.25",
+ "rounded": 0,
+ "rhs": "-5325931479363758430680275e-2"
+ },
+ {
+ "id": 110,
+ "op": "*",
+ "lhs": "-3045077954302574678753718e0",
+ "expected": "162178765339366787502789458999533128059319255124.5",
+ "rounded": 0,
+ "rhs": "-5325931479363758430680275e-2"
+ },
+ {
+ "id": 111,
+ "op": "+",
+ "lhs": "-7918772583550420137800879e-2",
+ "expected": "-1640850277880597926397041.79",
+ "rounded": 0,
+ "rhs": "-1561662552045093725019033e0"
+ },
+ {
+ "id": 112,
+ "op": "-",
+ "lhs": "-7918772583550420137800879e-2",
+ "expected": "1482474826209589523641024.21",
+ "rounded": 0,
+ "rhs": "-1561662552045093725019033e0"
+ },
+ {
+ "id": 113,
+ "op": "*",
+ "lhs": "-7918772583550420137800879e-2",
+ "expected": "123664506018920692864411925348943780888670391300.07",
+ "rounded": 0,
+ "rhs": "-1561662552045093725019033e0"
+ },
+ {
+ "id": 114,
+ "op": "+",
+ "lhs": "2634904777842202655433755e6",
+ "expected": "2634990852467634338928177716790",
+ "rounded": 0,
+ "rhs": "8607462543168349442271679e1"
+ },
+ {
+ "id": 115,
+ "op": "-",
+ "lhs": "2634904777842202655433755e6",
+ "expected": "2634818703216770971939332283210",
+ "rounded": 0,
+ "rhs": "8607462543168349442271679e1"
+ },
+ {
+ "id": 116,
+ "op": "*",
+ "lhs": "2634904777842202655433755e6",
+ "expected": "226798441800920804710498986565715476974402971246450000000",
+ "rounded": 0,
+ "rhs": "8607462543168349442271679e1"
+ },
+ {
+ "id": 117,
+ "op": "+",
+ "lhs": "6341466339340874411783342e1",
+ "expected": "-79423577784937085636281546580",
+ "rounded": 0,
+ "rhs": "-7948699244833049438039938e4"
+ },
+ {
+ "id": 118,
+ "op": "-",
+ "lhs": "6341466339340874411783342e1",
+ "expected": "79550407111723903124517213420",
+ "rounded": 0,
+ "rhs": "-7948699244833049438039938e4"
+ },
+ {
+ "id": 119,
+ "op": "*",
+ "lhs": "6341466339340874411783342e1",
+ "expected": "-5040640870265301086557829344901873747311959911279600000",
+ "rounded": 0,
+ "rhs": "-7948699244833049438039938e4"
+ },
+ {
+ "id": 120,
+ "op": "+",
+ "lhs": "-975678526475414071118757e3",
+ "expected": "-975678477497252687096057154.42076",
+ "rounded": 0,
+ "rhs": "4897816138402269984557924e-5"
+ },
+ {
+ "id": 121,
+ "op": "-",
+ "lhs": "-975678526475414071118757e3",
+ "expected": "-975678575453575455141456845.57924",
+ "rounded": 0,
+ "rhs": "4897816138402269984557924e-5"
+ },
+ {
+ "id": 122,
+ "op": "*",
+ "lhs": "-975678526475414071118757e3",
+ "expected": "-47786940328638294835364906100880521607047493804.68",
+ "rounded": 0,
+ "rhs": "4897816138402269984557924e-5"
+ },
+ {
+ "id": 123,
+ "op": "+",
+ "lhs": "-2121343856760769164649420e-6",
+ "expected": "-58971422513062081321.66524",
+ "rounded": 0,
+ "rhs": "-5685007865630131215701582e-5"
+ },
+ {
+ "id": 124,
+ "op": "-",
+ "lhs": "-2121343856760769164649420e-6",
+ "expected": "54728734799540542992.3664",
+ "rounded": 0,
+ "rhs": "-5685007865630131215701582e-5"
+ },
+ {
+ "id": 125,
+ "op": "*",
+ "lhs": "-2121343856760769164649420e-6",
+ "expected": "120598565113911311078631787714573080257.1836938244",
+ "rounded": 0,
+ "rhs": "-5685007865630131215701582e-5"
+ },
+ {
+ "id": 126,
+ "op": "+",
+ "lhs": "3218360614302157455689811e1",
+ "expected": "32119207459063567206109364.77",
+ "rounded": 0,
+ "rhs": "-6439868395800735078874523e-2"
+ },
+ {
+ "id": 127,
+ "op": "-",
+ "lhs": "3218360614302157455689811e1",
+ "expected": "32248004826979581907686855.23",
+ "rounded": 0,
+ "rhs": "-6439868395800735078874523e-2"
+ },
+ {
+ "id": 128,
+ "op": "*",
+ "lhs": "3218360614302157455689811e1",
+ "expected": "-2072581880633430301955032312777477299951247858515.3",
+ "rounded": 0,
+ "rhs": "-6439868395800735078874523e-2"
+ },
+ {
+ "id": 129,
+ "op": "+",
+ "lhs": "-2671118715863643810773062e-6",
+ "expected": "-91830548554326207928.592542",
+ "rounded": 0,
+ "rhs": "-8915942983846256411781948e-5"
+ },
+ {
+ "id": 130,
+ "op": "-",
+ "lhs": "-2671118715863643810773062e-6",
+ "expected": "86488311122598920307.046418",
+ "rounded": 0,
+ "rhs": "-8915942983846256411781948e-5"
+ },
+ {
+ "id": 131,
+ "op": "*",
+ "lhs": "-2671118715863643810773062e-6",
+ "expected": "238155421737248771594038338586432651341.46856284776",
+ "rounded": 0,
+ "rhs": "-8915942983846256411781948e-5"
+ },
+ {
+ "id": 132,
+ "op": "+",
+ "lhs": "-3931990094538315355844628e2",
+ "expected": "-393198919802824084794190548.919",
+ "rounded": 0,
+ "rhs": "8965100745079027225108100e-5"
+ },
+ {
+ "id": 133,
+ "op": "-",
+ "lhs": "-3931990094538315355844628e2",
+ "expected": "-393199099104838986374735051.081",
+ "rounded": 0,
+ "rhs": "8965100745079027225108100e-5"
+ },
+ {
+ "id": 134,
+ "op": "*",
+ "lhs": "-3931990094538315355844628e2",
+ "expected": "-35250687326188805694051513435014740371964104286.8",
+ "rounded": 0,
+ "rhs": "8965100745079027225108100e-5"
+ },
+ {
+ "id": 135,
+ "op": "+",
+ "lhs": "8932767857261295215058765e1",
+ "expected": "89327681976417529681263851.813856",
+ "rounded": 0,
+ "rhs": "3403804577530676201813856e-6"
+ },
+ {
+ "id": 136,
+ "op": "-",
+ "lhs": "8932767857261295215058765e1",
+ "expected": "89327675168808374619911448.186144",
+ "rounded": 0,
+ "rhs": "3403804577530676201813856e-6"
+ },
+ {
+ "id": 137,
+ "op": "*",
+ "lhs": "8932767857261295215058765e1",
+ "expected": "304053961225648866561415447572735170804986312.4784",
+ "rounded": 0,
+ "rhs": "3403804577530676201813856e-6"
+ },
+ {
+ "id": 138,
+ "op": "+",
+ "lhs": "4733452712511092921984326e-2",
+ "expected": "455884280758907748924180219843.26",
+ "rounded": 0,
+ "rhs": "4558842334243806238132510e5"
+ },
+ {
+ "id": 139,
+ "op": "-",
+ "lhs": "4733452712511092921984326e-2",
+ "expected": "-455884186089853498702321780156.74",
+ "rounded": 0,
+ "rhs": "4558842334243806238132510e5"
+ },
+ {
+ "id": 140,
+ "op": "*",
+ "lhs": "4733452712511092921984326e-2",
+ "expected": "21579064612936747156565359570769154940117731038260000",
+ "rounded": 0,
+ "rhs": "4558842334243806238132510e5"
+ },
+ {
+ "id": 141,
+ "op": "+",
+ "lhs": "9380137055551307946779326e3",
+ "expected": "278978540573565914412647926000",
+ "rounded": 0,
+ "rhs": "2695984035180146064658686e5"
+ },
+ {
+ "id": 142,
+ "op": "-",
+ "lhs": "9380137055551307946779326e3",
+ "expected": "-260218266462463298519089274000",
+ "rounded": 0,
+ "rhs": "2695984035180146064658686e5"
+ },
+ {
+ "id": 143,
+ "op": "*",
+ "lhs": "9380137055551307946779326e3",
+ "expected": "2528869974956802912440237499729749588170515112563600000000",
+ "rounded": 0,
+ "rhs": "2695984035180146064658686e5"
+ },
+ {
+ "id": 144,
+ "op": "+",
+ "lhs": "67329183235314698543671e3",
+ "expected": "-4951394952489570592083073000",
+ "rounded": 0,
+ "rhs": "-5018724135724885290626744e3"
+ },
+ {
+ "id": 145,
+ "op": "-",
+ "lhs": "67329183235314698543671e3",
+ "expected": "5086053318960199989170415000",
+ "rounded": 0,
+ "rhs": "-5018724135724885290626744e3"
+ },
+ {
+ "id": 146,
+ "op": "*",
+ "lhs": "67329183235314698543671e3",
+ "expected": "-337906596941717196458563394312310605923644537224000000",
+ "rounded": 0,
+ "rhs": "-5018724135724885290626744e3"
+ },
+ {
+ "id": 147,
+ "op": "+",
+ "lhs": "-41290603436543390493496e5",
+ "expected": "-3183223254490570521087413000",
+ "rounded": 0,
+ "rhs": "9458370891637685282621870e2"
+ },
+ {
+ "id": 148,
+ "op": "-",
+ "lhs": "-41290603436543390493496e5",
+ "expected": "-5074897432818107577611787000",
+ "rounded": 0,
+ "rhs": "9458370891637685282621870e2"
+ },
+ {
+ "id": 149,
+ "op": "*",
+ "lhs": "-41290603436543390493496e5",
+ "expected": "-3905418416423569804241884198561003541720623575200000000",
+ "rounded": 0,
+ "rhs": "9458370891637685282621870e2"
+ },
+ {
+ "id": 150,
+ "op": "+",
+ "lhs": "-8824114394782957376389881e3",
+ "expected": "-42158066033831094414223841000",
+ "rounded": 0,
+ "rhs": "-3333395163904813703783396e4"
+ },
+ {
+ "id": 151,
+ "op": "-",
+ "lhs": "-8824114394782957376389881e3",
+ "expected": "24509837244265179661444079000",
+ "rounded": 0,
+ "rhs": "-3333395163904813703783396e4"
+ },
+ {
+ "id": 152,
+ "op": "*",
+ "lhs": "-8824114394782957376389881e3",
+ "expected": "294142602493123621814451471929834856761736702158760000000",
+ "rounded": 0,
+ "rhs": "-3333395163904813703783396e4"
+ },
+ {
+ "id": 153,
+ "op": "+",
+ "lhs": "-3196970987318163079669208e4",
+ "expected": "-31890736572324497354349015350",
+ "rounded": 0,
+ "rhs": "7897330085713344234306465e1"
+ },
+ {
+ "id": 154,
+ "op": "-",
+ "lhs": "-3196970987318163079669208e4",
+ "expected": "-32048683174038764239035144650",
+ "rounded": 0,
+ "rhs": "7897330085713344234306465e1"
+ },
+ {
+ "id": 155,
+ "op": "*",
+ "lhs": "-3196970987318163079669208e4",
+ "expected": "-2524753516130042357705634665650485300235749582972000000",
+ "rounded": 0,
+ "rhs": "7897330085713344234306465e1"
+ },
+ {
+ "id": 156,
+ "op": "+",
+ "lhs": "-5189626408879391197893455e6",
+ "expected": "-5189626408943245935955914829959.51335",
+ "rounded": 0,
+ "rhs": "-6385473806245982995951335e-5"
+ },
+ {
+ "id": 157,
+ "op": "-",
+ "lhs": "-5189626408879391197893455e6",
+ "expected": "-5189626408815536459830995170040.48665",
+ "rounded": 0,
+ "rhs": "-6385473806245982995951335e-5"
+ },
+ {
+ "id": 158,
+ "op": "*",
+ "lhs": "-5189626408879391197893455e6",
+ "expected": "331382234981017581592999397616654753770456950124250",
+ "rounded": 0,
+ "rhs": "-6385473806245982995951335e-5"
+ },
+ {
+ "id": 159,
+ "op": "+",
+ "lhs": "-8712489956326170140015014e1",
+ "expected": "-82644810327178599318741896",
+ "rounded": 0,
+ "rhs": "4480089236083102081408244e0"
+ },
+ {
+ "id": 160,
+ "op": "-",
+ "lhs": "-8712489956326170140015014e1",
+ "expected": "-91604988799344803481558384",
+ "rounded": 0,
+ "rhs": "4480089236083102081408244e0"
+ },
+ {
+ "id": 161,
+ "op": "*",
+ "lhs": "-8712489956326170140015014e1",
+ "expected": "-390327324728190109990050027029150340372844233754160",
+ "rounded": 0,
+ "rhs": "4480089236083102081408244e0"
+ },
+ {
+ "id": 162,
+ "op": "+",
+ "lhs": "-260861643411100791213675e6",
+ "expected": "-324214483353683309594613380000",
+ "rounded": 0,
+ "rhs": "-6335283994258251838093838e4"
+ },
+ {
+ "id": 163,
+ "op": "-",
+ "lhs": "-260861643411100791213675e6",
+ "expected": "-197508803468518272832736620000",
+ "rounded": 0,
+ "rhs": "-6335283994258251838093838e4"
+ },
+ {
+ "id": 164,
+ "op": "*",
+ "lhs": "-260861643411100791213675e6",
+ "expected": "16526325942182504033958271652465466955305588346500000000000",
+ "rounded": 0,
+ "rhs": "-6335283994258251838093838e4"
+ },
+ {
+ "id": 165,
+ "op": "+",
+ "lhs": "-8961349617150612919680692e-4",
+ "expected": "68821626839341695910613.0308",
+ "rounded": 0,
+ "rhs": "6971776180105675720258110e-2"
+ },
+ {
+ "id": 166,
+ "op": "-",
+ "lhs": "-8961349617150612919680692e-4",
+ "expected": "-70613896762771818494549.1692",
+ "rounded": 0,
+ "rhs": "6971776180105675720258110e-2"
+ },
+ {
+ "id": 167,
+ "op": "*",
+ "lhs": "-8961349617150612919680692e-4",
+ "expected": "-62476523802449759701107231009927863997897023.41212",
+ "rounded": 0,
+ "rhs": "6971776180105675720258110e-2"
+ },
+ {
+ "id": 168,
+ "op": "+",
+ "lhs": "2689070651659818725506400e0",
+ "expected": "2689060715175300785852533.025558",
+ "rounded": 0,
+ "rhs": "-9936484517939653866974442e-6"
+ },
+ {
+ "id": 169,
+ "op": "-",
+ "lhs": "2689070651659818725506400e0",
+ "expected": "2689080588144336665160266.974442",
+ "rounded": 0,
+ "rhs": "-9936484517939653866974442e-6"
+ },
+ {
+ "id": 170,
+ "op": "*",
+ "lhs": "2689070651659818725506400e0",
+ "expected": "-26719908897863684753420647950634778646262307.4288",
+ "rounded": 0,
+ "rhs": "-9936484517939653866974442e-6"
+ },
+ {
+ "id": 171,
+ "op": "+",
+ "lhs": "9287562816166498513451478e-3",
+ "expected": "9362681214353583153622.25338",
+ "rounded": 0,
+ "rhs": "7511839818708464017077538e-5"
+ },
+ {
+ "id": 172,
+ "op": "-",
+ "lhs": "9287562816166498513451478e-3",
+ "expected": "9212444417979413873280.70262",
+ "rounded": 0,
+ "rhs": "7511839818708464017077538e-5"
+ },
+ {
+ "id": 173,
+ "op": "*",
+ "lhs": "9287562816166498513451478e-3",
+ "expected": "697666841812356217125839101746552846002031.26701164",
+ "rounded": 0,
+ "rhs": "7511839818708464017077538e-5"
+ },
+ {
+ "id": 174,
+ "op": "+",
+ "lhs": "5843763718675397424125252e4",
+ "expected": "28661084958070725587866550000",
+ "rounded": 0,
+ "rhs": "-2977655222868324865338597e4"
+ },
+ {
+ "id": 175,
+ "op": "-",
+ "lhs": "5843763718675397424125252e4",
+ "expected": "88214189415437222894638490000",
+ "rounded": 0,
+ "rhs": "-2977655222868324865338597e4"
+ },
+ {
+ "id": 176,
+ "op": "*",
+ "lhs": "5843763718675397424125252e4",
+ "expected": "-1740071355812222140696129871084318472760751795144400000000",
+ "rounded": 0,
+ "rhs": "-2977655222868324865338597e4"
+ },
+ {
+ "id": 177,
+ "op": "+",
+ "lhs": "-9404348901590880687171629e3",
+ "expected": "-96486493030706402310496919000",
+ "rounded": 0,
+ "rhs": "-8708214412911552162332529e4"
+ },
+ {
+ "id": 178,
+ "op": "-",
+ "lhs": "-9404348901590880687171629e3",
+ "expected": "77677795227524640936153661000",
+ "rounded": 0,
+ "rhs": "-8708214412911552162332529e4"
+ },
+ {
+ "id": 179,
+ "op": "*",
+ "lhs": "-9404348901590880687171629e3",
+ "expected": "818950866488826315043751544410896060440363926197410000000",
+ "rounded": 0,
+ "rhs": "-8708214412911552162332529e4"
+ },
+ {
+ "id": 180,
+ "op": "+",
+ "lhs": "9121327878563190006791742e4",
+ "expected": "91222011481867800316903481224",
+ "rounded": 0,
+ "rhs": "8732696235900248986061224e0"
+ },
+ {
+ "id": 181,
+ "op": "-",
+ "lhs": "9121327878563190006791742e4",
+ "expected": "91204546089395999818931358776",
+ "rounded": 0,
+ "rhs": "8732696235900248986061224e0"
+ },
+ {
+ "id": 182,
+ "op": "*",
+ "lhs": "9121327878563190006791742e4",
+ "expected": "796537856315407727561083569110681215936494296122080000",
+ "rounded": 0,
+ "rhs": "8732696235900248986061224e0"
+ },
+ {
+ "id": 183,
+ "op": "+",
+ "lhs": "-2542826781108001871176634e0",
+ "expected": "-6408791265378409856071243634",
+ "rounded": 0,
+ "rhs": "-6406248438597301854200067e3"
+ },
+ {
+ "id": 184,
+ "op": "-",
+ "lhs": "-2542826781108001871176634e0",
+ "expected": "6403705611816193852328890366",
+ "rounded": 0,
+ "rhs": "-6406248438597301854200067e3"
+ },
+ {
+ "id": 185,
+ "op": "*",
+ "lhs": "-2542826781108001871176634e0",
+ "expected": "16289980096096540047791786202102899260040131634478000",
+ "rounded": 0,
+ "rhs": "-6406248438597301854200067e3"
+ },
+ {
+ "id": 186,
+ "op": "+",
+ "lhs": "3498188459592448298342895e-6",
+ "expected": "339402405264456639106.632595",
+ "rounded": 0,
+ "rhs": "3359042168048641908082897e-4"
+ },
+ {
+ "id": 187,
+ "op": "-",
+ "lhs": "3498188459592448298342895e-6",
+ "expected": "-332406028345271742509.946805",
+ "rounded": 0,
+ "rhs": "3359042168048641908082897e-4"
+ },
+ {
+ "id": 188,
+ "op": "*",
+ "lhs": "3498188459592448298342895e-6",
+ "expected": "1175056254755215649000177574455394683763.1390966815",
+ "rounded": 0,
+ "rhs": "3359042168048641908082897e-4"
+ },
+ {
+ "id": 189,
+ "op": "+",
+ "lhs": "2282809756344512549892609e-4",
+ "expected": "6215451026965738452461513254989.2609",
+ "rounded": 0,
+ "rhs": "6215451026737457476827062e6"
+ },
+ {
+ "id": 190,
+ "op": "-",
+ "lhs": "2282809756344512549892609e-4",
+ "expected": "-6215451026509176501192610745010.7391",
+ "rounded": 0,
+ "rhs": "6215451026737457476827062e6"
+ },
+ {
+ "id": 191,
+ "op": "*",
+ "lhs": "2282809756344512549892609e-4",
+ "expected": "1418869224391778566068991721306276674273416498475800",
+ "rounded": 0,
+ "rhs": "6215451026737457476827062e6"
+ },
+ {
+ "id": 192,
+ "op": "+",
+ "lhs": "-1476066933242639290730976e-1",
+ "expected": "-11715569511439484633187193097.6",
+ "rounded": 0,
+ "rhs": "-1171542190474616036925812e4"
+ },
+ {
+ "id": 193,
+ "op": "-",
+ "lhs": "-1476066933242639290730976e-1",
+ "expected": "11715274298052836105329046902.4",
+ "rounded": 0,
+ "rhs": "-1171542190474616036925812e4"
+ },
+ {
+ "id": 194,
+ "op": "*",
+ "lhs": "-1476066933242639290730976e-1",
+ "expected": "1729274688258230474135872889821261738561362352512000",
+ "rounded": 0,
+ "rhs": "-1171542190474616036925812e4"
+ },
+ {
+ "id": 195,
+ "op": "+",
+ "lhs": "-5941757339862312947620277e4",
+ "expected": "-59417573388718244915782357388.560441",
+ "rounded": 0,
+ "rhs": "9904884560420412611439559e-6"
+ },
+ {
+ "id": 196,
+ "op": "-",
+ "lhs": "-5941757339862312947620277e4",
+ "expected": "-59417573408528014036623182611.439559",
+ "rounded": 0,
+ "rhs": "9904884560420412611439559e-6"
+ },
+ {
+ "id": 197,
+ "op": "*",
+ "lhs": "-5941757339862312947620277e4",
+ "expected": "-588524205373668857605638526815838053070562683378.43",
+ "rounded": 0,
+ "rhs": "9904884560420412611439559e-6"
+ },
+ {
+ "id": 198,
+ "op": "+",
+ "lhs": "6323520167593430122151360e1",
+ "expected": "63235194010177443156431311.221224",
+ "rounded": 0,
+ "rhs": "-7665756858065082288778776e-6"
+ },
+ {
+ "id": 199,
+ "op": "-",
+ "lhs": "6323520167593430122151360e1",
+ "expected": "63235209341691159286595888.778776",
+ "rounded": 0,
+ "rhs": "-7665756858065082288778776e-6"
+ },
+ {
+ "id": 200,
+ "op": "*",
+ "lhs": "6323520167593430122151360e1",
+ "expected": "-484745680918421954802712952621823511279202275.3536",
+ "rounded": 0,
+ "rhs": "-7665756858065082288778776e-6"
+ },
+ {
+ "id": 201,
+ "op": "+",
+ "lhs": "-1908448470993969814671152e-1",
+ "expected": "-190840840699850037767153.00633",
+ "rounded": 0,
+ "rhs": "4006399546943699962193670e-6"
+ },
+ {
+ "id": 202,
+ "op": "-",
+ "lhs": "-1908448470993969814671152e-1",
+ "expected": "-190848853498943925167077.39367",
+ "rounded": 0,
+ "rhs": "4006399546943699962193670e-6"
+ },
+ {
+ "id": 203,
+ "op": "*",
+ "lhs": "-1908448470993969814671152e-1",
+ "expected": "-764600708955563758416178414380870731890358.600784",
+ "rounded": 0,
+ "rhs": "4006399546943699962193670e-6"
+ },
+ {
+ "id": 204,
+ "op": "+",
+ "lhs": "-6396782145952171930390226e-1",
+ "expected": "-639744583216046797142526.19215",
+ "rounded": 0,
+ "rhs": "-6636862082960410350359215e-5"
+ },
+ {
+ "id": 205,
+ "op": "-",
+ "lhs": "-6396782145952171930390226e-1",
+ "expected": "-639611845974387588935519.00785",
+ "rounded": 0,
+ "rhs": "-6636862082960410350359215e-5"
+ },
+ {
+ "id": 206,
+ "op": "*",
+ "lhs": "-6396782145952171930390226e-1",
+ "expected": "42454560877428095452317131028294994029214225.03259",
+ "rounded": 0,
+ "rhs": "-6636862082960410350359215e-5"
+ },
+ {
+ "id": 207,
+ "op": "+",
+ "lhs": "-145865588975290146336224e5",
+ "expected": "-14586220965085633891230829856.3",
+ "rounded": 0,
+ "rhs": "3379324433807423915701437e-1"
+ },
+ {
+ "id": 208,
+ "op": "-",
+ "lhs": "-145865588975290146336224e5",
+ "expected": "-14586896829972395376013970143.7",
+ "rounded": 0,
+ "rhs": "3379324433807423915701437e-1"
+ },
+ {
+ "id": 209,
+ "op": "*",
+ "lhs": "-145865588975290146336224e5",
+ "expected": "-4929271488759087897946723255107694827726019538880000",
+ "rounded": 0,
+ "rhs": "3379324433807423915701437e-1"
+ },
+ {
+ "id": 210,
+ "op": "+",
+ "lhs": "4176527395853926454160468e-2",
+ "expected": "9557806258734039775928454.68",
+ "rounded": 0,
+ "rhs": "951604098477550051138685e1"
+ },
+ {
+ "id": 211,
+ "op": "-",
+ "lhs": "4176527395853926454160468e-2",
+ "expected": "-9474275710816961246845245.32",
+ "rounded": 0,
+ "rhs": "951604098477550051138685e1"
+ },
+ {
+ "id": 212,
+ "op": "*",
+ "lhs": "4176527395853926454160468e-2",
+ "expected": "397440058729836549464187196702644644587911250458",
+ "rounded": 0,
+ "rhs": "951604098477550051138685e1"
+ },
+ {
+ "id": 213,
+ "op": "+",
+ "lhs": "-7058966144814317888942368e-2",
+ "expected": "-30539164983990471234092.14",
+ "rounded": 0,
+ "rhs": "4005049646415270765533154e-2"
+ },
+ {
+ "id": 214,
+ "op": "-",
+ "lhs": "-7058966144814317888942368e-2",
+ "expected": "-110640157912295886544755.22",
+ "rounded": 0,
+ "rhs": "4005049646415270765533154e-2"
+ },
+ {
+ "id": 215,
+ "op": "*",
+ "lhs": "-7058966144814317888942368e-2",
+ "expected": "-2827150986234595087166975688146834304003269926.8672",
+ "rounded": 0,
+ "rhs": "4005049646415270765533154e-2"
+ },
+ {
+ "id": 216,
+ "op": "+",
+ "lhs": "5018503374150084603329513e3",
+ "expected": "4722243910558852751835260100",
+ "rounded": 0,
+ "rhs": "-2962594635912318514942529e2"
+ },
+ {
+ "id": 217,
+ "op": "-",
+ "lhs": "5018503374150084603329513e3",
+ "expected": "5314762837741316454823765900",
+ "rounded": 0,
+ "rhs": "-2962594635912318514942529e2"
+ },
+ {
+ "id": 218,
+ "op": "*",
+ "lhs": "5018503374150084603329513e3",
+ "expected": "-1486779117656491187615879451598092084359524455837700000",
+ "rounded": 0,
+ "rhs": "-2962594635912318514942529e2"
+ },
+ {
+ "id": 219,
+ "op": "+",
+ "lhs": "-5280684141086143229122393e-4",
+ "expected": "7554937593428082132760254.7607",
+ "rounded": 0,
+ "rhs": "7555465661842190747083167e0"
+ },
+ {
+ "id": 220,
+ "op": "-",
+ "lhs": "-5280684141086143229122393e-4",
+ "expected": "-7555993730256299361406079.2393",
+ "rounded": 0,
+ "rhs": "7555465661842190747083167e0"
+ },
+ {
+ "id": 221,
+ "op": "*",
+ "lhs": "-5280684141086143229122393e-4",
+ "expected": "-3989802769901097773245346649309206458903399305.8631",
+ "rounded": 0,
+ "rhs": "7555465661842190747083167e0"
+ },
+ {
+ "id": 222,
+ "op": "+",
+ "lhs": "607635156327622844729792e1",
+ "expected": "-822638571987772820389404102080",
+ "rounded": 0,
+ "rhs": "-8226446483393360966178514e5"
+ },
+ {
+ "id": 223,
+ "op": "-",
+ "lhs": "607635156327622844729792e1",
+ "expected": "822650724690899372846298697920",
+ "rounded": 0,
+ "rhs": "-8226446483393360966178514e5"
+ },
+ {
+ "id": 224,
+ "op": "*",
+ "lhs": "607635156327622844729792e1",
+ "expected": "-4998678094957548098954918600704784254603166089088000000",
+ "rounded": 0,
+ "rhs": "-8226446483393360966178514e5"
+ },
+ {
+ "id": 225,
+ "op": "+",
+ "lhs": "-2947293349326970406356576e4",
+ "expected": "-29525820241924199854516425590",
+ "rounded": 0,
+ "rhs": "-5288674865449579095066559e1"
+ },
+ {
+ "id": 226,
+ "op": "-",
+ "lhs": "-2947293349326970406356576e4",
+ "expected": "-29420046744615208272615094410",
+ "rounded": 0,
+ "rhs": "-5288674865449579095066559e1"
+ },
+ {
+ "id": 227,
+ "op": "*",
+ "lhs": "-2947293349326970406356576e4",
+ "expected": "1558727625769225453158296683108166550865540734198400000",
+ "rounded": 0,
+ "rhs": "-5288674865449579095066559e1"
+ },
+ {
+ "id": 228,
+ "op": "+",
+ "lhs": "-6859000587653102818386149e6",
+ "expected": "-6905772117060269159486038030000",
+ "rounded": 0,
+ "rhs": "-4677152940716634109988903e4"
+ },
+ {
+ "id": 229,
+ "op": "-",
+ "lhs": "-6859000587653102818386149e6",
+ "expected": "-6812229058245936477286259970000",
+ "rounded": 0,
+ "rhs": "-4677152940716634109988903e4"
+ },
+ {
+ "id": 230,
+ "op": "*",
+ "lhs": "-6859000587653102818386149e6",
+ "expected": "320805947689188313286832068480995230429667589045470000000000",
+ "rounded": 0,
+ "rhs": "-4677152940716634109988903e4"
+ },
+ {
+ "id": 231,
+ "op": "+",
+ "lhs": "660363185971838533930150e5",
+ "expected": "66036252126594911771058691160",
+ "rounded": 0,
+ "rhs": "-6647058894162195630884e1"
+ },
+ {
+ "id": 232,
+ "op": "-",
+ "lhs": "660363185971838533930150e5",
+ "expected": "66036385067772795014971308840",
+ "rounded": 0,
+ "rhs": "-6647058894162195630884e1"
+ },
+ {
+ "id": 233,
+ "op": "*",
+ "lhs": "660363185971838533930150e5",
+ "expected": "-4389472988691393384053594901922282319238752600000000",
+ "rounded": 0,
+ "rhs": "-6647058894162195630884e1"
+ },
+ {
+ "id": 234,
+ "op": "+",
+ "lhs": "-9609847204698661497572069e5",
+ "expected": "-960966503992008515576275959300",
+ "rounded": 0,
+ "rhs": "1821647785763418093094070e1"
+ },
+ {
+ "id": 235,
+ "op": "-",
+ "lhs": "-9609847204698661497572069e5",
+ "expected": "-961002936947723783938137840700",
+ "rounded": 0,
+ "rhs": "1821647785763418093094070e1"
+ },
+ {
+ "id": 236,
+ "op": "*",
+ "lhs": "-9609847204698661497572069e5",
+ "expected": "-17505756881964089537453373498392161133121021530830000000",
+ "rounded": 0,
+ "rhs": "1821647785763418093094070e1"
+ },
+ {
+ "id": 237,
+ "op": "+",
+ "lhs": "-796173187155390613831511e4",
+ "expected": "-7961732859233923164424855841.3471",
+ "rounded": 0,
+ "rhs": "-9876800170261097458413471e-4"
+ },
+ {
+ "id": 238,
+ "op": "-",
+ "lhs": "-796173187155390613831511e4",
+ "expected": "-7961730883873889112205364158.6529",
+ "rounded": 0,
+ "rhs": "-9876800170261097458413471e-4"
+ },
+ {
+ "id": 239,
+ "op": "*",
+ "lhs": "-796173187155390613831511e4",
+ "expected": "7863643470453682626730697460291663674890566684681",
+ "rounded": 0,
+ "rhs": "-9876800170261097458413471e-4"
+ },
+ {
+ "id": 240,
+ "op": "+",
+ "lhs": "-4962022084458595205957820e1",
+ "expected": "-49619954559182551844117933.0144",
+ "rounded": 0,
+ "rhs": "2662854034002154602669856e-4"
+ },
+ {
+ "id": 241,
+ "op": "-",
+ "lhs": "-4962022084458595205957820e1",
+ "expected": "-49620487129989352275038466.9856",
+ "rounded": 0,
+ "rhs": "2662854034002154602669856e-4"
+ },
+ {
+ "id": 242,
+ "op": "*",
+ "lhs": "-4962022084458595205957820e1",
+ "expected": "-13213140524408350136188900744400923881169721473.92",
+ "rounded": 0,
+ "rhs": "2662854034002154602669856e-4"
+ },
+ {
+ "id": 243,
+ "op": "+",
+ "lhs": "6735739249125454042309166e5",
+ "expected": "673573419402180958137105330697.8",
+ "rounded": 0,
+ "rhs": "-5055103644460938112693022e-1"
+ },
+ {
+ "id": 244,
+ "op": "-",
+ "lhs": "6735739249125454042309166e5",
+ "expected": "673574430422909850324727869302.2",
+ "rounded": 0,
+ "rhs": "-5055103644460938112693022e-1"
+ },
+ {
+ "id": 245,
+ "op": "*",
+ "lhs": "6735739249125454042309166e5",
+ "expected": "-340498600263926654795157951445130795076437748396520000",
+ "rounded": 0,
+ "rhs": "-5055103644460938112693022e-1"
+ },
+ {
+ "id": 246,
+ "op": "+",
+ "lhs": "-2521919603729086018091471e-4",
+ "expected": "-176281825794353670731.05104",
+ "rounded": 0,
+ "rhs": "7591013457855493107809606e-5"
+ },
+ {
+ "id": 247,
+ "op": "-",
+ "lhs": "-2521919603729086018091471e-4",
+ "expected": "-328102094951463532887.24316",
+ "rounded": 0,
+ "rhs": "7591013457855493107809606e-5"
+ },
+ {
+ "id": 248,
+ "op": "*",
+ "lhs": "-2521919603729086018091471e-4",
+ "expected": "-19143925651537084185083067644509268150753.360470426",
+ "rounded": 0,
+ "rhs": "7591013457855493107809606e-5"
+ },
+ {
+ "id": 249,
+ "op": "+",
+ "lhs": "5001999380162000242895419e-1",
+ "expected": "-69913559911503218095156.9",
+ "rounded": 0,
+ "rhs": "-5701134979277032423846988e-1"
+ },
+ {
+ "id": 250,
+ "op": "-",
+ "lhs": "5001999380162000242895419e-1",
+ "expected": "1070313435943903266674240.7",
+ "rounded": 0,
+ "rhs": "-5701134979277032423846988e-1"
+ },
+ {
+ "id": 251,
+ "op": "*",
+ "lhs": "5001999380162000242895419e-1",
+ "expected": "-285170736325636142837449800105817597228997421479.72",
+ "rounded": 0,
+ "rhs": "-5701134979277032423846988e-1"
+ },
+ {
+ "id": 252,
+ "op": "+",
+ "lhs": "-7480201513224421828503928e1",
+ "expected": "311094929886152102909471120",
+ "rounded": 0,
+ "rhs": "3858969450183963211945104e2"
+ },
+ {
+ "id": 253,
+ "op": "-",
+ "lhs": "-7480201513224421828503928e1",
+ "expected": "-460698960150640539479549680",
+ "rounded": 0,
+ "rhs": "3858969450183963211945104e2"
+ },
+ {
+ "id": 254,
+ "op": "*",
+ "lhs": "-7480201513224421828503928e1",
+ "expected": "-28865869120752896726479189331144127888799184368512000",
+ "rounded": 0,
+ "rhs": "3858969450183963211945104e2"
+ },
+ {
+ "id": 255,
+ "op": "+",
+ "lhs": "-6571298834648554286210321e-5",
+ "expected": "-385074964243407761937845.00321",
+ "rounded": 0,
+ "rhs": "-3850092512550612763949829e-1"
+ },
+ {
+ "id": 256,
+ "op": "-",
+ "lhs": "-6571298834648554286210321e-5",
+ "expected": "384943538266714790852120.79679",
+ "rounded": 0,
+ "rhs": "-3850092512550612763949829e-1"
+ },
+ {
+ "id": 257,
+ "op": "*",
+ "lhs": "-6571298834648554286210321e-5",
+ "expected": "25300108441012966023049992549517511314043785.985109",
+ "rounded": 0,
+ "rhs": "-3850092512550612763949829e-1"
+ },
+ {
+ "id": 258,
+ "op": "+",
+ "lhs": "9842489457677748076412781e-4",
+ "expected": "4429944609658158332423747807641.2781",
+ "rounded": 0,
+ "rhs": "4429944608673909386655973e6"
+ },
+ {
+ "id": 259,
+ "op": "-",
+ "lhs": "9842489457677748076412781e-4",
+ "expected": "-4429944607689660440888198192358.7219",
+ "rounded": 0,
+ "rhs": "4429944608673909386655973e6"
+ },
+ {
+ "id": 260,
+ "op": "*",
+ "lhs": "9842489457677748076412781e-4",
+ "expected": "4360168310896933032627866270229411176519118719091300",
+ "rounded": 0,
+ "rhs": "4429944608673909386655973e6"
+ },
+ {
+ "id": 261,
+ "op": "+",
+ "lhs": "-7196948874468804023145557e2",
+ "expected": "-719694891886622258538387868.212941",
+ "rounded": 0,
+ "rhs": "-4439741856223832168212941e-6"
+ },
+ {
+ "id": 262,
+ "op": "-",
+ "lhs": "-7196948874468804023145557e2",
+ "expected": "-719694883007138546090723531.787059",
+ "rounded": 0,
+ "rhs": "-4439741856223832168212941e-6"
+ },
+ {
+ "id": 263,
+ "op": "*",
+ "lhs": "-7196948874468804023145557e2",
+ "expected": "3195259515508214765891055993647984580037021405.3137",
+ "rounded": 0,
+ "rhs": "-4439741856223832168212941e-6"
+ },
+ {
+ "id": 264,
+ "op": "+",
+ "lhs": "-5305671250650438611050478e-3",
+ "expected": "-819719877523653904064644.478",
+ "rounded": 0,
+ "rhs": "-8144142062730034654535940e-1"
+ },
+ {
+ "id": 265,
+ "op": "-",
+ "lhs": "-5305671250650438611050478e-3",
+ "expected": "809108535022353026842543.522",
+ "rounded": 0,
+ "rhs": "-8144142062730034654535940e-1"
+ },
+ {
+ "id": 266,
+ "op": "*",
+ "lhs": "-5305671250650438611050478e-3",
+ "expected": "4321014040343970582955491756144570835247100517.932",
+ "rounded": 0,
+ "rhs": "-8144142062730034654535940e-1"
+ },
+ {
+ "id": 267,
+ "op": "+",
+ "lhs": "-8814558536523217471308994e5",
+ "expected": "-881461553430434839031443699051",
+ "rounded": 0,
+ "rhs": "-5699778113091900544299051e0"
+ },
+ {
+ "id": 268,
+ "op": "-",
+ "lhs": "-8814558536523217471308994e5",
+ "expected": "-881450153874208655230355100949",
+ "rounded": 0,
+ "rhs": "-5699778113091900544299051e0"
+ },
+ {
+ "id": 269,
+ "op": "*",
+ "lhs": "-8814558536523217471308994e5",
+ "expected": "5024102782304240878656853956039772764870516196469400000",
+ "rounded": 0,
+ "rhs": "-5699778113091900544299051e0"
+ },
+ {
+ "id": 270,
+ "op": "+",
+ "lhs": "8203047772759765983695506e4",
+ "expected": "82029846798706921874758432453",
+ "rounded": 0,
+ "rhs": "-630928890737962196627547e0"
+ },
+ {
+ "id": 271,
+ "op": "-",
+ "lhs": "8203047772759765983695506e4",
+ "expected": "82031108656488397799151687547",
+ "rounded": 0,
+ "rhs": "-630928890737962196627547e0"
+ },
+ {
+ "id": 272,
+ "op": "*",
+ "lhs": "8203047772759765983695506e4",
+ "expected": "-51755398319378305421792676049944486668613397037820000",
+ "rounded": 0,
+ "rhs": "-630928890737962196627547e0"
+ },
+ {
+ "id": 273,
+ "op": "+",
+ "lhs": "7924614862589871917316169e-3",
+ "expected": "7921966003421720893052.864194",
+ "rounded": 0,
+ "rhs": "-2648859168151024263304806e-6"
+ },
+ {
+ "id": 274,
+ "op": "-",
+ "lhs": "7924614862589871917316169e-3",
+ "expected": "7927263721758022941579.473806",
+ "rounded": 0,
+ "rhs": "-2648859168151024263304806e-6"
+ },
+ {
+ "id": 275,
+ "op": "*",
+ "lhs": "7924614862589871917316169e-3",
+ "expected": "-20991188732837051573725624045671031860837.919208214",
+ "rounded": 0,
+ "rhs": "-2648859168151024263304806e-6"
+ },
+ {
+ "id": 276,
+ "op": "+",
+ "lhs": "3472149433630704541127407e-6",
+ "expected": "40710910325855597078988424541.127407",
+ "rounded": 0,
+ "rhs": "4071091032238344764535772e4"
+ },
+ {
+ "id": 277,
+ "op": "-",
+ "lhs": "3472149433630704541127407e-6",
+ "expected": "-40710910318911298211727015458.872593",
+ "rounded": 0,
+ "rhs": "4071091032238344764535772e4"
+ },
+ {
+ "id": 278,
+ "op": "*",
+ "lhs": "3472149433630704541127407e-6",
+ "expected": "141354364218454090964171861904779539487558611032.04",
+ "rounded": 0,
+ "rhs": "4071091032238344764535772e4"
+ },
+ {
+ "id": 279,
+ "op": "+",
+ "lhs": "-2961984558101905819179208e5",
+ "expected": "-296198455734739620861270187186.16697",
+ "rounded": 0,
+ "rhs": "7545096105665061281383303e-5"
+ },
+ {
+ "id": 280,
+ "op": "-",
+ "lhs": "-2961984558101905819179208e5",
+ "expected": "-296198455885641542974571412813.83303",
+ "rounded": 0,
+ "rhs": "7545096105665061281383303e-5"
+ },
+ {
+ "id": 281,
+ "op": "*",
+ "lhs": "-2961984558101905819179208e5",
+ "expected": "-22348458154374737035014686557503653247254295964024",
+ "rounded": 0,
+ "rhs": "7545096105665061281383303e-5"
+ },
+ {
+ "id": 282,
+ "op": "+",
+ "lhs": "-1583342220508566434595940e-6",
+ "expected": "442306451401305130432.93106",
+ "rounded": 0,
+ "rhs": "4438897936218136968675270e-4"
+ },
+ {
+ "id": 283,
+ "op": "-",
+ "lhs": "-1583342220508566434595940e-6",
+ "expected": "-445473135842322263302.12294",
+ "rounded": 0,
+ "rhs": "4438897936218136968675270e-4"
+ },
+ {
+ "id": 284,
+ "op": "*",
+ "lhs": "-1583342220508566434595940e-6",
+ "expected": "-702829451494251788920410666129198831299.95204038",
+ "rounded": 0,
+ "rhs": "4438897936218136968675270e-4"
+ },
+ {
+ "id": 285,
+ "op": "+",
+ "lhs": "-7501474427723326492316677e3",
+ "expected": "-7501474340287329417282134842.31557",
+ "rounded": 0,
+ "rhs": "8743599707503454215768443e-5"
+ },
+ {
+ "id": 286,
+ "op": "-",
+ "lhs": "-7501474427723326492316677e3",
+ "expected": "-7501474515159323567351219157.68443",
+ "rounded": 0,
+ "rhs": "8743599707503454215768443e-5"
+ },
+ {
+ "id": 287,
+ "op": "*",
+ "lhs": "-7501474427723326492316677e3",
+ "expected": "-655898896120863191204019118584546313301788592239.11",
+ "rounded": 0,
+ "rhs": "8743599707503454215768443e-5"
+ },
+ {
+ "id": 288,
+ "op": "+",
+ "lhs": "-731761388248579088633916e0",
+ "expected": "-731425903554421866949223.9727",
+ "rounded": 0,
+ "rhs": "3354846941572216846920273e-4"
+ },
+ {
+ "id": 289,
+ "op": "-",
+ "lhs": "-731761388248579088633916e0",
+ "expected": "-732096872942736310318608.0273",
+ "rounded": 0,
+ "rhs": "3354846941572216846920273e-4"
+ },
+ {
+ "id": 290,
+ "op": "*",
+ "lhs": "-731761388248579088633916e0",
+ "expected": "-245494745532638509738166459957829448578333577.9068",
+ "rounded": 0,
+ "rhs": "3354846941572216846920273e-4"
+ },
+ {
+ "id": 291,
+ "op": "+",
+ "lhs": "-5602808315411414887838000e-1",
+ "expected": "-8147790493211561329860120",
+ "rounded": 0,
+ "rhs": "-758750966167041984107632e1"
+ },
+ {
+ "id": 292,
+ "op": "-",
+ "lhs": "-5602808315411414887838000e-1",
+ "expected": "7027228830129278352292520",
+ "rounded": 0,
+ "rhs": "-758750966167041984107632e1"
+ },
+ {
+ "id": 293,
+ "op": "*",
+ "lhs": "-5602808315411414887838000e-1",
+ "expected": "4251136222567147951154926135223958397799779616000",
+ "rounded": 0,
+ "rhs": "-758750966167041984107632e1"
+ },
+ {
+ "id": 294,
+ "op": "+",
+ "lhs": "-8487250777615930833346683e-4",
+ "expected": "-787227136466931325531350783334.6683",
+ "rounded": 0,
+ "rhs": "-7872271356182062477697577e5"
+ },
+ {
+ "id": 295,
+ "op": "-",
+ "lhs": "-8487250777615930833346683e-4",
+ "expected": "787227134769481170008164616665.3317",
+ "rounded": 0,
+ "rhs": "-7872271356182062477697577e5"
+ },
+ {
+ "id": 296,
+ "op": "*",
+ "lhs": "-8487250777615930833346683e-4",
+ "expected": "668139411893598281740457456563889074896472700870910",
+ "rounded": 0,
+ "rhs": "-7872271356182062477697577e5"
+ },
+ {
+ "id": 297,
+ "op": "+",
+ "lhs": "2711903069110406138536185e-2",
+ "expected": "5386740573301371604800306385361.85",
+ "rounded": 0,
+ "rhs": "5386740546182340913696245e6"
+ },
+ {
+ "id": 298,
+ "op": "-",
+ "lhs": "2711903069110406138536185e-2",
+ "expected": "-5386740519063310222592183614638.15",
+ "rounded": 0,
+ "rhs": "5386740546182340913696245e6"
+ },
+ {
+ "id": 299,
+ "op": "*",
+ "lhs": "2711903069110406138536185e-2",
+ "expected": "146083182196933557804574033331112771783620311253250000",
+ "rounded": 0,
+ "rhs": "5386740546182340913696245e6"
+ },
+ {
+ "id": 300,
+ "op": "+",
+ "lhs": "5743043180405668707806402e5",
+ "expected": "574304317959256470577155112786.8679",
+ "rounded": 0,
+ "rhs": "-8131040020348508721313210e-5"
+ },
+ {
+ "id": 301,
+ "op": "-",
+ "lhs": "5743043180405668707806402e5",
+ "expected": "574304318121877270984125287213.1321",
+ "rounded": 0,
+ "rhs": "-8131040020348508721313210e-5"
+ },
+ {
+ "id": 302,
+ "op": "*",
+ "lhs": "5743043180405668707806402e5",
+ "expected": "-46696913938468072733285271491250231372603885170420",
+ "rounded": 0,
+ "rhs": "-8131040020348508721313210e-5"
+ },
+ {
+ "id": 303,
+ "op": "+",
+ "lhs": "-7362566788135282957063434e5",
+ "expected": "-736251574871747538219885213210",
+ "rounded": 0,
+ "rhs": "510394178075748645818679e1"
+ },
+ {
+ "id": 304,
+ "op": "-",
+ "lhs": "-7362566788135282957063434e5",
+ "expected": "-736261782755309053192801586790",
+ "rounded": 0,
+ "rhs": "510394178075748645818679e1"
+ },
+ {
+ "id": 305,
+ "op": "*",
+ "lhs": "-7362566788135282957063434e5",
+ "expected": "-3757811224358112361618629266520205620552665083686000000",
+ "rounded": 0,
+ "rhs": "510394178075748645818679e1"
+ },
+ {
+ "id": 306,
+ "op": "+",
+ "lhs": "144886498912794917597488e-1",
+ "expected": "3582905943387699457391468.8",
+ "rounded": 0,
+ "rhs": "356841729349641996563172e1"
+ },
+ {
+ "id": 307,
+ "op": "-",
+ "lhs": "144886498912794917597488e-1",
+ "expected": "-3553928643605140473871971.2",
+ "rounded": 0,
+ "rhs": "356841729349641996563172e1"
+ },
+ {
+ "id": 308,
+ "op": "*",
+ "lhs": "144886498912794917597488e-1",
+ "expected": "51701548831456763372817608269909768239260511936",
+ "rounded": 0,
+ "rhs": "356841729349641996563172e1"
+ },
+ {
+ "id": 309,
+ "op": "+",
+ "lhs": "8357601859455755116548892e3",
+ "expected": "8357595532248986056848287594.05",
+ "rounded": 0,
+ "rhs": "-6327206769059700604405950e-3"
+ },
+ {
+ "id": 310,
+ "op": "-",
+ "lhs": "8357601859455755116548892e3",
+ "expected": "8357608186662524176249496405.95",
+ "rounded": 0,
+ "rhs": "-6327206769059700604405950e-3"
+ },
+ {
+ "id": 311,
+ "op": "*",
+ "lhs": "8357601859455755116548892e3",
+ "expected": "-52880275058254394311828333548430071037493790707400",
+ "rounded": 0,
+ "rhs": "-6327206769059700604405950e-3"
+ },
+ {
+ "id": 312,
+ "op": "+",
+ "lhs": "-7667963032441113522580896e4",
+ "expected": "-76675797798567753802152543638",
+ "rounded": 0,
+ "rhs": "3832525843381423656416362e0"
+ },
+ {
+ "id": 313,
+ "op": "-",
+ "lhs": "-7667963032441113522580896e4",
+ "expected": "-76683462850254516649465376362",
+ "rounded": 0,
+ "rhs": "3832525843381423656416362e0"
+ },
+ {
+ "id": 314,
+ "op": "*",
+ "lhs": "-7667963032441113522580896e4",
+ "expected": "-293876664879239574480872325267024188165646030203520000",
+ "rounded": 0,
+ "rhs": "3832525843381423656416362e0"
+ },
+ {
+ "id": 315,
+ "op": "+",
+ "lhs": "5647499022269180692258839e0",
+ "expected": "3202371454376331264875115839",
+ "rounded": 0,
+ "rhs": "3196723955354062084182857e3"
+ },
+ {
+ "id": 316,
+ "op": "-",
+ "lhs": "5647499022269180692258839e0",
+ "expected": "-3191076456331792903490598161",
+ "rounded": 0,
+ "rhs": "3196723955354062084182857e3"
+ },
+ {
+ "id": 317,
+ "op": "*",
+ "lhs": "5647499022269180692258839e0",
+ "expected": "18053495412326533651412586945377047777604850523023000",
+ "rounded": 0,
+ "rhs": "3196723955354062084182857e3"
+ },
+ {
+ "id": 318,
+ "op": "+",
+ "lhs": "-3776514288912781822166476e1",
+ "expected": "-56104575543684717606779740",
+ "rounded": 0,
+ "rhs": "-1833943265455689938511498e1"
+ },
+ {
+ "id": 319,
+ "op": "-",
+ "lhs": "-3776514288912781822166476e1",
+ "expected": "-19425710234570918836549780",
+ "rounded": 0,
+ "rhs": "-1833943265455689938511498e1"
+ },
+ {
+ "id": 320,
+ "op": "*",
+ "lhs": "-3776514288912781822166476e1",
+ "expected": "692591294704877995927909551068501855059299614104800",
+ "rounded": 0,
+ "rhs": "-1833943265455689938511498e1"
+ },
+ {
+ "id": 321,
+ "op": "+",
+ "lhs": "7792676115505526403523527e5",
+ "expected": "779571217502957974751879041500",
+ "rounded": 0,
+ "rhs": "3036059524053343995263415e2"
+ },
+ {
+ "id": 322,
+ "op": "-",
+ "lhs": "7792676115505526403523527e5",
+ "expected": "778964005598147305952826358500",
+ "rounded": 0,
+ "rhs": "3036059524053343995263415e2"
+ },
+ {
+ "id": 323,
+ "op": "*",
+ "lhs": "7792676115505526403523527e5",
+ "expected": "236590285383435699898459253083289632442545148647050000000",
+ "rounded": 0,
+ "rhs": "3036059524053343995263415e2"
+ },
+ {
+ "id": 324,
+ "op": "+",
+ "lhs": "-2154025487428370543189041e-1",
+ "expected": "-329255238075368884811740418904.1",
+ "rounded": 0,
+ "rhs": "-3292550226728201419746861e5"
+ },
+ {
+ "id": 325,
+ "op": "-",
+ "lhs": "-2154025487428370543189041e-1",
+ "expected": "329254807270271399137631781095.9",
+ "rounded": 0,
+ "rhs": "-3292550226728201419746861e5"
+ },
+ {
+ "id": 326,
+ "op": "*",
+ "lhs": "-2154025487428370543189041e-1",
+ "expected": "70922371070106060089050834252475666937058893503010000",
+ "rounded": 0,
+ "rhs": "-3292550226728201419746861e5"
+ },
+ {
+ "id": 327,
+ "op": "+",
+ "lhs": "-3634745721564088893052816e1",
+ "expected": "-36949645101339968137713521.3",
+ "rounded": 0,
+ "rhs": "-6021878856990792071853613e-1"
+ },
+ {
+ "id": 328,
+ "op": "-",
+ "lhs": "-3634745721564088893052816e1",
+ "expected": "-35745269329941809723342798.7",
+ "rounded": 0,
+ "rhs": "-6021878856990792071853613e-1"
+ },
+ {
+ "id": 329,
+ "op": "*",
+ "lhs": "-3634745721564088893052816e1",
+ "expected": "21887998411224527398108737154855879689287429424208",
+ "rounded": 0,
+ "rhs": "-6021878856990792071853613e-1"
+ },
+ {
+ "id": 330,
+ "op": "+",
+ "lhs": "-767336845605895786790154e2",
+ "expected": "-132639326900197376545443415400",
+ "rounded": 0,
+ "rhs": "-1325625932156367869667644e5"
+ },
+ {
+ "id": 331,
+ "op": "-",
+ "lhs": "-767336845605895786790154e2",
+ "expected": "132485859531076197388085384600",
+ "rounded": 0,
+ "rhs": "-1325625932156367869667644e5"
+ },
+ {
+ "id": 332,
+ "op": "*",
+ "lhs": "-767336845605895786790154e2",
+ "expected": "10172016212342425349234549636376854178375515771760000000",
+ "rounded": 0,
+ "rhs": "-1325625932156367869667644e5"
+ },
+ {
+ "id": 333,
+ "op": "+",
+ "lhs": "9693877086029268583517500e4",
+ "expected": "96938040334583742732492766773.4",
+ "rounded": 0,
+ "rhs": "-7305257089431026822332266e-1"
+ },
+ {
+ "id": 334,
+ "op": "-",
+ "lhs": "9693877086029268583517500e4",
+ "expected": "96939501386001628937857233226.6",
+ "rounded": 0,
+ "rhs": "-7305257089431026822332266e-1"
+ },
+ {
+ "id": 335,
+ "op": "*",
+ "lhs": "9693877086029268583517500e4",
+ "expected": "-70816264306788298217696967430962090561556025655000000",
+ "rounded": 0,
+ "rhs": "-7305257089431026822332266e-1"
+ },
+ {
+ "id": 336,
+ "op": "+",
+ "lhs": "-8671027911300851319762908e-4",
+ "expected": "-472789494753069597757.4388",
+ "rounded": 0,
+ "rhs": "3943132963770155342188520e-4"
+ },
+ {
+ "id": 337,
+ "op": "-",
+ "lhs": "-8671027911300851319762908e-4",
+ "expected": "-1261416087507100666195.1428",
+ "rounded": 0,
+ "rhs": "3943132963770155342188520e-4"
+ },
+ {
+ "id": 338,
+ "op": "*",
+ "lhs": "-8671027911300851319762908e-4",
+ "expected": "-341910159868214655170732908744379942604562.3941616",
+ "rounded": 0,
+ "rhs": "3943132963770155342188520e-4"
+ },
+ {
+ "id": 339,
+ "op": "+",
+ "lhs": "-529547516522559228093358e-1",
+ "expected": "-394086615920939569210285.9",
+ "rounded": 0,
+ "rhs": "-3411318642686836464009501e-1"
+ },
+ {
+ "id": 340,
+ "op": "-",
+ "lhs": "-529547516522559228093358e-1",
+ "expected": "288177112616427723591614.3",
+ "rounded": 0,
+ "rhs": "-3411318642686836464009501e-1"
+ },
+ {
+ "id": 341,
+ "op": "*",
+ "lhs": "-529547516522559228093358e-1",
+ "expected": "18064553153019218521173696491885283058322269943.58",
+ "rounded": 0,
+ "rhs": "-3411318642686836464009501e-1"
+ },
+ {
+ "id": 342,
+ "op": "+",
+ "lhs": "3870743005566660959720879e-3",
+ "expected": "8580704523377772935408.763",
+ "rounded": 0,
+ "rhs": "4709961517811111975687884e-3"
+ },
+ {
+ "id": 343,
+ "op": "-",
+ "lhs": "3870743005566660959720879e-3",
+ "expected": "-839218512244451015967.005",
+ "rounded": 0,
+ "rhs": "4709961517811111975687884e-3"
+ },
+ {
+ "id": 344,
+ "op": "*",
+ "lhs": "3870743005566660959720879e-3",
+ "expected": "18231050601555495905096859698249257622042662.130036",
+ "rounded": 0,
+ "rhs": "4709961517811111975687884e-3"
+ },
+ {
+ "id": 345,
+ "op": "+",
+ "lhs": "-6228540743514587851988485e-2",
+ "expected": "-62344476353926148018894.10127",
+ "rounded": 0,
+ "rhs": "-5906891878026949900925127e-5"
+ },
+ {
+ "id": 346,
+ "op": "-",
+ "lhs": "-6228540743514587851988485e-2",
+ "expected": "-62226338516365609020875.59873",
+ "rounded": 0,
+ "rhs": "-5906891878026949900925127e-5"
+ },
+ {
+ "id": 347,
+ "op": "*",
+ "lhs": "-6228540743514587851988485e-2",
+ "expected": "3679131672982625871337408319960255458764805.1162595",
+ "rounded": 0,
+ "rhs": "-5906891878026949900925127e-5"
+ },
+ {
+ "id": 348,
+ "op": "+",
+ "lhs": "-8441589363862433743079167e-3",
+ "expected": "1308231605739159315324010920.833",
+ "rounded": 0,
+ "rhs": "1308240047328523177757754e3"
+ },
+ {
+ "id": 349,
+ "op": "-",
+ "lhs": "-8441589363862433743079167e-3",
+ "expected": "-1308248488917887040191497079.167",
+ "rounded": 0,
+ "rhs": "1308240047328523177757754e3"
+ },
+ {
+ "id": 350,
+ "op": "*",
+ "lhs": "-8441589363862433743079167e-3",
+ "expected": "-11043625268907348184722419191853433323906770110918",
+ "rounded": 0,
+ "rhs": "1308240047328523177757754e3"
+ },
+ {
+ "id": 351,
+ "op": "+",
+ "lhs": "-677519400463992068964276e-3",
+ "expected": "-655468199229026655432.41254",
+ "rounded": 0,
+ "rhs": "2205120123496541353186346e-5"
+ },
+ {
+ "id": 352,
+ "op": "-",
+ "lhs": "-677519400463992068964276e-3",
+ "expected": "-699570601698957482496.13946",
+ "rounded": 0,
+ "rhs": "2205120123496541353186346e-5"
+ },
+ {
+ "id": 353,
+ "op": "*",
+ "lhs": "-677519400463992068964276e-3",
+ "expected": "-14940116640224608481019212556296019797886.44975496",
+ "rounded": 0,
+ "rhs": "2205120123496541353186346e-5"
+ },
+ {
+ "id": 354,
+ "op": "+",
+ "lhs": "4075424977604888896794173e-1",
+ "expected": "1138624412364093749749248",
+ "rounded": 0,
+ "rhs": "7310819146036048600698307e-1"
+ },
+ {
+ "id": 355,
+ "op": "-",
+ "lhs": "4075424977604888896794173e-1",
+ "expected": "-323539416843115970390413.4",
+ "rounded": 0,
+ "rhs": "7310819146036048600698307e-1"
+ },
+ {
+ "id": 356,
+ "op": "*",
+ "lhs": "4075424977604888896794173e-1",
+ "expected": "297946949545073563375792433773575695756614485651.11",
+ "rounded": 0,
+ "rhs": "7310819146036048600698307e-1"
+ },
+ {
+ "id": 357,
+ "op": "+",
+ "lhs": "8013892045054873860387414e-6",
+ "expected": "4337092703599545495.527457",
+ "rounded": 0,
+ "rhs": "-3676799341455328364859957e-6"
+ },
+ {
+ "id": 358,
+ "op": "-",
+ "lhs": "8013892045054873860387414e-6",
+ "expected": "11690691386510202225.247371",
+ "rounded": 0,
+ "rhs": "-3676799341455328364859957e-6"
+ },
+ {
+ "id": 359,
+ "op": "*",
+ "lhs": "8013892045054873860387414e-6",
+ "expected": "-29465472993751854879749622366359993783.167875381198",
+ "rounded": 0,
+ "rhs": "-3676799341455328364859957e-6"
+ },
+ {
+ "id": 360,
+ "op": "/",
+ "lhs": "966883368793384177",
+ "expected": "6043021054.95865110625",
+ "rounded": 0,
+ "rhs": "160000000"
+ },
+ {
+ "id": 361,
+ "op": "/",
+ "lhs": "-801481617541172059",
+ "expected": "400740808770.5860295",
+ "rounded": 0,
+ "rhs": "-2000000"
+ },
+ {
+ "id": 362,
+ "op": "/",
+ "lhs": "466581608944396573",
+ "expected": "17798675878.31102649688720703125",
+ "rounded": 0,
+ "rhs": "26214400"
+ },
+ {
+ "id": 363,
+ "op": "/",
+ "lhs": "596607577723782499",
+ "expected": "-0.372879736077364061875",
+ "rounded": 0,
+ "rhs": "-1600000000000000000"
+ },
+ {
+ "id": 364,
+ "op": "/",
+ "lhs": "387295314517075090",
+ "expected": "-253817.8573219103309824",
+ "rounded": 0,
+ "rhs": "-1525878906250"
+ },
+ {
+ "id": 365,
+ "op": "/",
+ "lhs": "386805836923455068",
+ "expected": "-60438.412019289854375",
+ "rounded": 0,
+ "rhs": "-6400000000000"
+ },
+ {
+ "id": 366,
+ "op": "/",
+ "lhs": "-655382799396854315",
+ "expected": "-4.09614249623033946875",
+ "rounded": 0,
+ "rhs": "160000000000000000"
+ },
+ {
+ "id": 367,
+ "op": "/",
+ "lhs": "916054755345530978",
+ "expected": "-14313355552273.92153125",
+ "rounded": 0,
+ "rhs": "-64000"
+ },
+ {
+ "id": 368,
+ "op": "/",
+ "lhs": "-321315653623721899",
+ "expected": "-4112840366.3836403072",
+ "rounded": 0,
+ "rhs": "78125000"
+ },
+ {
+ "id": 369,
+ "op": "/",
+ "lhs": "-510818350014508360",
+ "expected": "-15963073437953386.25",
+ "rounded": 0,
+ "rhs": "32"
+ },
+ {
+ "id": 370,
+ "op": "/",
+ "lhs": "-24536501795932490",
+ "expected": "748794610471.57257080078125",
+ "rounded": 0,
+ "rhs": "-32768"
+ },
+ {
+ "id": 371,
+ "op": "/",
+ "lhs": "8779479890726153",
+ "expected": "143842.998529657290752",
+ "rounded": 0,
+ "rhs": "61035156250"
+ },
+ {
+ "id": 372,
+ "op": "/",
+ "lhs": "-987462815093590433",
+ "expected": "-4937314075467.952165",
+ "rounded": 0,
+ "rhs": "200000"
+ },
+ {
+ "id": 373,
+ "op": "/",
+ "lhs": "989095023570992796",
+ "expected": "0.506416652068348311552",
+ "rounded": 0,
+ "rhs": "1953125000000000000"
+ },
+ {
+ "id": 374,
+ "op": "/",
+ "lhs": "538788270527820903",
+ "expected": "3288.502627733281878662109375",
+ "rounded": 0,
+ "rhs": "163840000000000"
+ },
+ {
+ "id": 375,
+ "op": "/",
+ "lhs": "-651109706558136899",
+ "expected": "-5.461904093311239656046592",
+ "rounded": 0,
+ "rhs": "119209289550781250"
+ },
+ {
+ "id": 376,
+ "op": "/",
+ "lhs": "768173124086352792",
+ "expected": "786609.279064425259008",
+ "rounded": 0,
+ "rhs": "976562500000"
+ },
+ {
+ "id": 377,
+ "op": "/",
+ "lhs": "658088558416131629",
+ "expected": "-65.8088558416131629",
+ "rounded": 0,
+ "rhs": "-10000000000000000"
+ },
+ {
+ "id": 378,
+ "op": "/",
+ "lhs": "-870789812996481318",
+ "expected": "-2853404.0592268699828224",
+ "rounded": 0,
+ "rhs": "305175781250"
+ },
+ {
+ "id": 379,
+ "op": "/",
+ "lhs": "-826627011571045628",
+ "expected": "630666.3601463665985107421875",
+ "rounded": 0,
+ "rhs": "-1310720000000"
+ },
+ {
+ "id": 380,
+ "op": "/",
+ "lhs": "-131921031992677461",
+ "expected": "10.55368255941419688",
+ "rounded": 0,
+ "rhs": "-12500000000000000"
+ },
+ {
+ "id": 381,
+ "op": "/",
+ "lhs": "-879493261143949742",
+ "expected": "-1758986.522287899484",
+ "rounded": 0,
+ "rhs": "500000000000"
+ },
+ {
+ "id": 382,
+ "op": "/",
+ "lhs": "-389645617681727993",
+ "expected": "-15959.88450024357859328",
+ "rounded": 0,
+ "rhs": "24414062500000"
+ },
+ {
+ "id": 383,
+ "op": "/",
+ "lhs": "-38972364113800493",
+ "expected": "-319261.606820253638656",
+ "rounded": 0,
+ "rhs": "122070312500"
+ },
+ {
+ "id": 384,
+ "op": "/",
+ "lhs": "-290034309677975796",
+ "expected": "608.246032609786296532992",
+ "rounded": 0,
+ "rhs": "-476837158203125"
+ },
+ {
+ "id": 385,
+ "op": "/",
+ "lhs": "-149227537791252445",
+ "expected": "71157235.046030256748199462890625",
+ "rounded": 0,
+ "rhs": "-2097152000"
+ },
+ {
+ "id": 386,
+ "op": "/",
+ "lhs": "899583091661832437",
+ "expected": "702799.29036080659140625",
+ "rounded": 0,
+ "rhs": "1280000000000"
+ },
+ {
+ "id": 387,
+ "op": "/",
+ "lhs": "-41773466069864890",
+ "expected": "407944004.58852431640625",
+ "rounded": 0,
+ "rhs": "-102400000"
+ },
+ {
+ "id": 388,
+ "op": "/",
+ "lhs": "450229220652260148",
+ "expected": "-0.059012444409333042118656",
+ "rounded": 0,
+ "rhs": "-7629394531250000000"
+ },
+ {
+ "id": 389,
+ "op": "/",
+ "lhs": "-233148513359101291",
+ "expected": "-59686019419.929930496",
+ "rounded": 0,
+ "rhs": "3906250"
+ },
+ {
+ "id": 390,
+ "op": "/",
+ "lhs": "645453140010603882",
+ "expected": "-66094401537.0858375168",
+ "rounded": 0,
+ "rhs": "-9765625"
+ },
+ {
+ "id": 391,
+ "op": "/",
+ "lhs": "68437111398867373",
+ "expected": "4.485094532636172156928",
+ "rounded": 0,
+ "rhs": "15258789062500000"
+ },
+ {
+ "id": 392,
+ "op": "/",
+ "lhs": "-468964085335116405",
+ "expected": "0.000468964085335116405",
+ "rounded": 0,
+ "rhs": "-1000000000000000000000"
+ },
+ {
+ "id": 393,
+ "op": "/",
+ "lhs": "48995203854923952",
+ "expected": "5017108874.7442126848",
+ "rounded": 0,
+ "rhs": "9765625"
+ },
+ {
+ "id": 394,
+ "op": "/",
+ "lhs": "829992035701380909",
+ "expected": "-0.0026559745142444189088",
+ "rounded": 0,
+ "rhs": "-312500000000000000000"
+ },
+ {
+ "id": 395,
+ "op": "/",
+ "lhs": "-573482840962637207",
+ "expected": "-0.000004587862727701097656",
+ "rounded": 0,
+ "rhs": "125000000000000000000000"
+ },
+ {
+ "id": 396,
+ "op": "/",
+ "lhs": "-641582174094849744",
+ "expected": "256632869.6379398976",
+ "rounded": 0,
+ "rhs": "-2500000000"
+ },
+ {
+ "id": 397,
+ "op": "/",
+ "lhs": "-773152639160752658",
+ "expected": "117973730340.69101837158203125",
+ "rounded": 0,
+ "rhs": "-6553600"
+ },
+ {
+ "id": 398,
+ "op": "/",
+ "lhs": "-845272487056605883",
+ "expected": "692447.2213967715393536",
+ "rounded": 0,
+ "rhs": "-1220703125000"
+ },
+ {
+ "id": 399,
+ "op": "/",
+ "lhs": "-90912878061916643",
+ "expected": "3723791.48541610569728",
+ "rounded": 0,
+ "rhs": "-24414062500"
+ },
+ {
+ "id": 400,
+ "op": "/",
+ "lhs": "-363483201561263387",
+ "expected": "3634832.01561263387",
+ "rounded": 0,
+ "rhs": "-100000000000"
+ },
+ {
+ "id": 401,
+ "op": "/",
+ "lhs": "150336872057545010",
+ "expected": "-1174.506812949570390625",
+ "rounded": 0,
+ "rhs": "-128000000000000"
+ },
+ {
+ "id": 402,
+ "op": "/",
+ "lhs": "-535632704350052671",
+ "expected": "-13076970.3210462077880859375",
+ "rounded": 0,
+ "rhs": "40960000000"
+ },
+ {
+ "id": 403,
+ "op": "/",
+ "lhs": "678445695922014583",
+ "expected": "-69472839262.4142932992",
+ "rounded": 0,
+ "rhs": "-9765625"
+ },
+ {
+ "id": 404,
+ "op": "/",
+ "lhs": "-492147446363062904",
+ "expected": "0.64506750089699380953088",
+ "rounded": 0,
+ "rhs": "-762939453125000000"
+ },
+ {
+ "id": 405,
+ "op": "/",
+ "lhs": "-340267523860041240",
+ "expected": "-13610700.9544016496",
+ "rounded": 0,
+ "rhs": "25000000000"
+ },
+ {
+ "id": 406,
+ "op": "/",
+ "lhs": "-308093042941870476",
+ "expected": "-38511630367733.8095",
+ "rounded": 0,
+ "rhs": "8000"
+ },
+ {
+ "id": 407,
+ "op": "/",
+ "lhs": "842638063336441527",
+ "expected": "-4018011395.15133632183074951171875",
+ "rounded": 0,
+ "rhs": "-209715200"
+ },
+ {
+ "id": 408,
+ "op": "/",
+ "lhs": "-540067994653128162",
+ "expected": "7078.7792195174814449664",
+ "rounded": 0,
+ "rhs": "-76293945312500"
+ },
+ {
+ "id": 409,
+ "op": "/",
+ "lhs": "-989110637357217312",
+ "expected": "-98911063.7357217312",
+ "rounded": 0,
+ "rhs": "10000000000"
+ },
+ {
+ "id": 410,
+ "op": "/",
+ "lhs": "-97039827111408684",
+ "expected": "-0.24259956777852171",
+ "rounded": 0,
+ "rhs": "400000000000000000"
+ },
+ {
+ "id": 411,
+ "op": "/",
+ "lhs": "361187180442462342",
+ "expected": "-2889.497443539698736",
+ "rounded": 0,
+ "rhs": "-125000000000000"
+ },
+ {
+ "id": 412,
+ "op": "/",
+ "lhs": "529266658867433415",
+ "expected": "26463332943371.67075",
+ "rounded": 0,
+ "rhs": "20000"
+ },
+ {
+ "id": 413,
+ "op": "/",
+ "lhs": "-52465987348300549",
+ "expected": "214900684.178639048704",
+ "rounded": 0,
+ "rhs": "-244140625"
+ },
+ {
+ "id": 414,
+ "op": "/",
+ "lhs": "-504380386103116808",
+ "expected": "246.27948540191250390625",
+ "rounded": 0,
+ "rhs": "-2048000000000000"
+ },
+ {
+ "id": 415,
+ "op": "/",
+ "lhs": "-380994876672911569",
+ "expected": "99.875520950543730343936",
+ "rounded": 0,
+ "rhs": "-3814697265625000"
+ },
+ {
+ "id": 416,
+ "op": "/",
+ "lhs": "-426358958877001943",
+ "expected": "203303794325.352641582489013671875",
+ "rounded": 0,
+ "rhs": "-2097152"
+ },
+ {
+ "id": 417,
+ "op": "/",
+ "lhs": "537628189495831202",
+ "expected": "-3523.4001026798793654272",
+ "rounded": 0,
+ "rhs": "-152587890625000"
+ },
+ {
+ "id": 418,
+ "op": "/",
+ "lhs": "-775951536573256472",
+ "expected": "-592004040.964703729248046875",
+ "rounded": 0,
+ "rhs": "1310720000"
+ },
+ {
+ "id": 419,
+ "op": "/",
+ "lhs": "368385528148577110",
+ "expected": "1.8861339041207148032",
+ "rounded": 0,
+ "rhs": "195312500000000000"
+ },
+ {
+ "id": 420,
+ "op": "/",
+ "lhs": "18822041954042360",
+ "expected": "-0.000120461068505871104",
+ "rounded": 0,
+ "rhs": "-156250000000000000000"
+ },
+ {
+ "id": 421,
+ "op": "/",
+ "lhs": "-8887648719282863",
+ "expected": "-108491805.65530838623046875",
+ "rounded": 0,
+ "rhs": "81920000"
+ },
+ {
+ "id": 422,
+ "op": "/",
+ "lhs": "682951468631394408",
+ "expected": "-218544469.96204621056",
+ "rounded": 0,
+ "rhs": "-3125000000"
+ },
+ {
+ "id": 423,
+ "op": "/",
+ "lhs": "452723981972830620",
+ "expected": "-2263619909864.1531",
+ "rounded": 0,
+ "rhs": "-200000"
+ },
+ {
+ "id": 424,
+ "op": "/",
+ "lhs": "-326069109012507351",
+ "expected": "1243854938554.791835784912109375",
+ "rounded": 0,
+ "rhs": "-262144"
+ },
+ {
+ "id": 425,
+ "op": "/",
+ "lhs": "729719950700743207",
+ "expected": "-0.005837759605605945656",
+ "rounded": 0,
+ "rhs": "-125000000000000000000"
+ },
+ {
+ "id": 426,
+ "op": "/",
+ "lhs": "-551867909608402187",
+ "expected": "-176597731.07468869984",
+ "rounded": 0,
+ "rhs": "3125000000"
+ },
+ {
+ "id": 427,
+ "op": "/",
+ "lhs": "942755330569029991",
+ "expected": "-0.003861525834010746843136",
+ "rounded": 0,
+ "rhs": "-244140625000000000000"
+ },
+ {
+ "id": 428,
+ "op": "/",
+ "lhs": "-695001386414056467",
+ "expected": "43437586650878.5291875",
+ "rounded": 0,
+ "rhs": "-16000"
+ },
+ {
+ "id": 429,
+ "op": "/",
+ "lhs": "647063699280472766",
+ "expected": "-3949363398.92866678466796875",
+ "rounded": 0,
+ "rhs": "-163840000"
+ },
+ {
+ "id": 430,
+ "op": "/",
+ "lhs": "442168022398071385",
+ "expected": "-16867371.45988736667633056640625",
+ "rounded": 0,
+ "rhs": "-26214400000"
+ },
+ {
+ "id": 431,
+ "op": "/",
+ "lhs": "-577848269385453123",
+ "expected": "-3786986.4182445055868928",
+ "rounded": 0,
+ "rhs": "152587890625"
+ },
+ {
+ "id": 432,
+ "op": "/",
+ "lhs": "253182018691429621",
+ "expected": "-39559690.42053587828125",
+ "rounded": 0,
+ "rhs": "-6400000000"
+ },
+ {
+ "id": 433,
+ "op": "/",
+ "lhs": "325653583651473412",
+ "expected": "38820932346.758057117462158203125",
+ "rounded": 0,
+ "rhs": "8388608"
+ },
+ {
+ "id": 434,
+ "op": "/",
+ "lhs": "459650266967372502",
+ "expected": "8.9775442767064941796875",
+ "rounded": 0,
+ "rhs": "51200000000000000"
+ },
+ {
+ "id": 435,
+ "op": "/",
+ "lhs": "288630592952922220",
+ "expected": "-18472.35794898702208",
+ "rounded": 0,
+ "rhs": "-15625000000000"
+ },
+ {
+ "id": 436,
+ "op": "/",
+ "lhs": "62888818771592287",
+ "expected": "-1572.220469289807175",
+ "rounded": 0,
+ "rhs": "-40000000000000"
+ },
+ {
+ "id": 437,
+ "op": "/",
+ "lhs": "480338827720973660",
+ "expected": "-19213553.1088389464",
+ "rounded": 0,
+ "rhs": "-25000000000"
+ },
+ {
+ "id": 438,
+ "op": "/",
+ "lhs": "777681157042411782",
+ "expected": "-65.23662375415231813779456",
+ "rounded": 0,
+ "rhs": "-11920928955078125"
+ },
+ {
+ "id": 439,
+ "op": "/",
+ "lhs": "-216579338909074491",
+ "expected": "-0.00006930538845090383712",
+ "rounded": 0,
+ "rhs": "3125000000000000000000"
+ },
+ {
+ "id": 440,
+ "op": "/",
+ "lhs": "-804268414313e-3",
+ "expected": "-134044735.719",
+ "rounded": 1,
+ "rhs": "6",
+ "scale": 3
+ },
+ {
+ "id": 441,
+ "op": "/",
+ "lhs": "-417146588829e-3",
+ "expected": "59592369.8327143",
+ "rounded": 1,
+ "rhs": "-7",
+ "scale": 7
+ },
+ {
+ "id": 442,
+ "op": "/",
+ "lhs": "-729058754570e1",
+ "expected": "-2430195848567",
+ "rounded": 1,
+ "rhs": "3",
+ "scale": 0
+ },
+ {
+ "id": 443,
+ "op": "/",
+ "lhs": "386469706301e-1",
+ "expected": "2972843895",
+ "rounded": 1,
+ "rhs": "13",
+ "scale": 0
+ },
+ {
+ "id": 444,
+ "op": "/",
+ "lhs": "-36213443434e2",
+ "expected": "517334906200",
+ "rounded": 0,
+ "rhs": "-7",
+ "scale": 0
+ },
+ {
+ "id": 445,
+ "op": "/",
+ "lhs": "-600237289787e-1",
+ "expected": "8574818426",
+ "rounded": 1,
+ "rhs": "-7",
+ "scale": 0
+ },
+ {
+ "id": 446,
+ "op": "/",
+ "lhs": "-731750292973e2",
+ "expected": "-12195838216216.666667",
+ "rounded": 1,
+ "rhs": "6",
+ "scale": 6
+ },
+ {
+ "id": 447,
+ "op": "/",
+ "lhs": "286091321025e-1",
+ "expected": "1682890123.676471",
+ "rounded": 1,
+ "rhs": "17",
+ "scale": 6
+ },
+ {
+ "id": 448,
+ "op": "/",
+ "lhs": "-407588122001e2",
+ "expected": "-2397577188241.176",
+ "rounded": 1,
+ "rhs": "17",
+ "scale": 3
+ },
+ {
+ "id": 449,
+ "op": "/",
+ "lhs": "-494733071630e1",
+ "expected": "291019453900",
+ "rounded": 0,
+ "rhs": "-17",
+ "scale": 6
+ },
+ {
+ "id": 450,
+ "op": "/",
+ "lhs": "55367219981e-3",
+ "expected": "-4259016.92162",
+ "rounded": 1,
+ "rhs": "-13",
+ "scale": 5
+ },
+ {
+ "id": 451,
+ "op": "/",
+ "lhs": "451466409901e-1",
+ "expected": "5016293443.34",
+ "rounded": 1,
+ "rhs": "9",
+ "scale": 2
+ },
+ {
+ "id": 452,
+ "op": "/",
+ "lhs": "-540648193545e2",
+ "expected": "4158832258038.4615385",
+ "rounded": 1,
+ "rhs": "-13",
+ "scale": 7
+ },
+ {
+ "id": 453,
+ "op": "/",
+ "lhs": "454174873373e2",
+ "expected": "-2671616902194.118",
+ "rounded": 1,
+ "rhs": "-17",
+ "scale": 3
+ },
+ {
+ "id": 454,
+ "op": "/",
+ "lhs": "-640393059692e-2",
+ "expected": "492610045.92",
+ "rounded": 1,
+ "rhs": "-13",
+ "scale": 2
+ },
+ {
+ "id": 455,
+ "op": "/",
+ "lhs": "-253715266383e-3",
+ "expected": "42285877.73",
+ "rounded": 1,
+ "rhs": "-6",
+ "scale": 3
+ },
+ {
+ "id": 456,
+ "op": "/",
+ "lhs": "268067214304e-1",
+ "expected": "-2062055494.6",
+ "rounded": 1,
+ "rhs": "-13",
+ "scale": 1
+ },
+ {
+ "id": 457,
+ "op": "/",
+ "lhs": "-718488651539e-2",
+ "expected": "798320723.93222",
+ "rounded": 1,
+ "rhs": "-9",
+ "scale": 5
+ },
+ {
+ "id": 458,
+ "op": "/",
+ "lhs": "-172536435677e-3",
+ "expected": "-19170715.0752222",
+ "rounded": 1,
+ "rhs": "9",
+ "scale": 7
+ },
+ {
+ "id": 459,
+ "op": "/",
+ "lhs": "-586030774296e-3",
+ "expected": "195343591.432",
+ "rounded": 0,
+ "rhs": "-3",
+ "scale": 5
+ },
+ {
+ "id": 460,
+ "op": "/",
+ "lhs": "693441307770e-1",
+ "expected": "-6304011888.81818182",
+ "rounded": 1,
+ "rhs": "-11",
+ "scale": 8
+ },
+ {
+ "id": 461,
+ "op": "/",
+ "lhs": "308696918322e-2",
+ "expected": "440995597.603",
+ "rounded": 1,
+ "rhs": "7",
+ "scale": 3
+ },
+ {
+ "id": 462,
+ "op": "/",
+ "lhs": "338855574740e1",
+ "expected": "484079392486",
+ "rounded": 1,
+ "rhs": "7",
+ "scale": 0
+ },
+ {
+ "id": 463,
+ "op": "/",
+ "lhs": "420994288906e3",
+ "expected": "70165714817666.667",
+ "rounded": 1,
+ "rhs": "6",
+ "scale": 3
+ },
+ {
+ "id": 464,
+ "op": "/",
+ "lhs": "702614679e1",
+ "expected": "-1003735255.71429",
+ "rounded": 1,
+ "rhs": "-7",
+ "scale": 5
+ },
+ {
+ "id": 465,
+ "op": "/",
+ "lhs": "480556438271e-1",
+ "expected": "4368694893.3727",
+ "rounded": 1,
+ "rhs": "11",
+ "scale": 4
+ },
+ {
+ "id": 466,
+ "op": "/",
+ "lhs": "-94255443986e-2",
+ "expected": "134650634.2657143",
+ "rounded": 1,
+ "rhs": "-7",
+ "scale": 7
+ },
+ {
+ "id": 467,
+ "op": "/",
+ "lhs": "-470675427047e-3",
+ "expected": "67239346.721",
+ "rounded": 0,
+ "rhs": "-7",
+ "scale": 3
+ },
+ {
+ "id": 468,
+ "op": "/",
+ "lhs": "-15528601253e-2",
+ "expected": "-22183716",
+ "rounded": 1,
+ "rhs": "7",
+ "scale": 0
+ },
+ {
+ "id": 469,
+ "op": "/",
+ "lhs": "113994162247e0",
+ "expected": "10363105658.818182",
+ "rounded": 1,
+ "rhs": "11",
+ "scale": 6
+ },
+ {
+ "id": 470,
+ "op": "/",
+ "lhs": "-813713765747e-1",
+ "expected": "-9041264063.85556",
+ "rounded": 1,
+ "rhs": "9",
+ "scale": 5
+ },
+ {
+ "id": 471,
+ "op": "/",
+ "lhs": "-139305102348e2",
+ "expected": "819441778517.6471",
+ "rounded": 1,
+ "rhs": "-17",
+ "scale": 4
+ },
+ {
+ "id": 472,
+ "op": "/",
+ "lhs": "691260961670e-1",
+ "expected": "-7680677351.88889",
+ "rounded": 1,
+ "rhs": "-9",
+ "scale": 5
+ },
+ {
+ "id": 473,
+ "op": "/",
+ "lhs": "-454506391342e-3",
+ "expected": "34962030.1",
+ "rounded": 1,
+ "rhs": "-13",
+ "scale": 2
+ },
+ {
+ "id": 474,
+ "op": "/",
+ "lhs": "-435217885410e3",
+ "expected": "-62173983630000",
+ "rounded": 0,
+ "rhs": "7",
+ "scale": 5
+ },
+ {
+ "id": 475,
+ "op": "/",
+ "lhs": "-457029401329e3",
+ "expected": "-26884082431118",
+ "rounded": 1,
+ "rhs": "17",
+ "scale": 0
+ },
+ {
+ "id": 476,
+ "op": "/",
+ "lhs": "463610104260e1",
+ "expected": "272711826035",
+ "rounded": 1,
+ "rhs": "17",
+ "scale": 0
+ },
+ {
+ "id": 477,
+ "op": "/",
+ "lhs": "511650558465e-3",
+ "expected": "73092936.9235714",
+ "rounded": 1,
+ "rhs": "7",
+ "scale": 7
+ },
+ {
+ "id": 478,
+ "op": "/",
+ "lhs": "-407764996524e-2",
+ "expected": "370695451.3854545",
+ "rounded": 1,
+ "rhs": "-11",
+ "scale": 7
+ },
+ {
+ "id": 479,
+ "op": "/",
+ "lhs": "-544359783343e2",
+ "expected": "-18145326111433.333",
+ "rounded": 1,
+ "rhs": "3",
+ "scale": 3
+ },
+ {
+ "id": 480,
+ "op": "/",
+ "lhs": "-837290343378e-1",
+ "expected": "13954839056.3",
+ "rounded": 0,
+ "rhs": "-6",
+ "scale": 5
+ },
+ {
+ "id": 481,
+ "op": "/",
+ "lhs": "-343916098933e-3",
+ "expected": "-20230358.7607647",
+ "rounded": 1,
+ "rhs": "17",
+ "scale": 7
+ },
+ {
+ "id": 482,
+ "op": "/",
+ "lhs": "-470878262110e-1",
+ "expected": "-4280711473.727",
+ "rounded": 1,
+ "rhs": "11",
+ "scale": 3
+ },
+ {
+ "id": 483,
+ "op": "/",
+ "lhs": "30843707026e3",
+ "expected": "2372592848153.8",
+ "rounded": 1,
+ "rhs": "13",
+ "scale": 1
+ },
+ {
+ "id": 484,
+ "op": "/",
+ "lhs": "-978860944500e-3",
+ "expected": "75296995.73",
+ "rounded": 1,
+ "rhs": "-13",
+ "scale": 2
+ },
+ {
+ "id": 485,
+ "op": "/",
+ "lhs": "-73475629534e-1",
+ "expected": "565197150.26154",
+ "rounded": 1,
+ "rhs": "-13",
+ "scale": 5
+ },
+ {
+ "id": 486,
+ "op": "/",
+ "lhs": "218590933986e3",
+ "expected": "19871903089636.364",
+ "rounded": 1,
+ "rhs": "11",
+ "scale": 3
+ },
+ {
+ "id": 487,
+ "op": "/",
+ "lhs": "520521875811e2",
+ "expected": "8675364596850",
+ "rounded": 0,
+ "rhs": "6",
+ "scale": 3
+ },
+ {
+ "id": 488,
+ "op": "/",
+ "lhs": "887914374467e3",
+ "expected": "147985729077833.333333",
+ "rounded": 1,
+ "rhs": "6",
+ "scale": 6
+ },
+ {
+ "id": 489,
+ "op": "/",
+ "lhs": "961544380043e-3",
+ "expected": "-56561434.12017647",
+ "rounded": 1,
+ "rhs": "-17",
+ "scale": 8
+ },
+ {
+ "id": 490,
+ "op": "/",
+ "lhs": "-639085229284e2",
+ "expected": "4916040225261.5384615",
+ "rounded": 1,
+ "rhs": "-13",
+ "scale": 7
+ },
+ {
+ "id": 491,
+ "op": "/",
+ "lhs": "-680360018597e-1",
+ "expected": "22678667286.56667",
+ "rounded": 1,
+ "rhs": "-3",
+ "scale": 5
+ },
+ {
+ "id": 492,
+ "op": "/",
+ "lhs": "-500487352461e0",
+ "expected": "-45498850223.72727273",
+ "rounded": 1,
+ "rhs": "11",
+ "scale": 8
+ },
+ {
+ "id": 493,
+ "op": "/",
+ "lhs": "931599654525e0",
+ "expected": "133085664932.143",
+ "rounded": 1,
+ "rhs": "7",
+ "scale": 3
+ },
+ {
+ "id": 494,
+ "op": "/",
+ "lhs": "-304188524774e0",
+ "expected": "50698087462.33333333",
+ "rounded": 1,
+ "rhs": "-6",
+ "scale": 8
+ },
+ {
+ "id": 495,
+ "op": "/",
+ "lhs": "-25880545144e-2",
+ "expected": "-86268483.8133333",
+ "rounded": 1,
+ "rhs": "3",
+ "scale": 7
+ },
+ {
+ "id": 496,
+ "op": "/",
+ "lhs": "-502670490057e-3",
+ "expected": "-71810070.0081",
+ "rounded": 1,
+ "rhs": "7",
+ "scale": 4
+ },
+ {
+ "id": 497,
+ "op": "/",
+ "lhs": "573084097790e1",
+ "expected": "-955140162983.333",
+ "rounded": 1,
+ "rhs": "-6",
+ "scale": 3
+ },
+ {
+ "id": 498,
+ "op": "/",
+ "lhs": "-301972255514e2",
+ "expected": "-3355247283488.9",
+ "rounded": 1,
+ "rhs": "9",
+ "scale": 1
+ },
+ {
+ "id": 499,
+ "op": "/",
+ "lhs": "95228483448e-3",
+ "expected": "-31742827.816",
+ "rounded": 0,
+ "rhs": "-3",
+ "scale": 4
+ },
+ {
+ "id": 500,
+ "op": "/",
+ "lhs": "556619107165e3",
+ "expected": "61846567462778",
+ "rounded": 1,
+ "rhs": "9",
+ "scale": 0
+ },
+ {
+ "id": 501,
+ "op": "/",
+ "lhs": "7523345335e3",
+ "expected": "2507781778333.3333333",
+ "rounded": 1,
+ "rhs": "3",
+ "scale": 7
+ },
+ {
+ "id": 502,
+ "op": "/",
+ "lhs": "38707223780e-1",
+ "expected": "-1290240792.6667",
+ "rounded": 1,
+ "rhs": "-3",
+ "scale": 4
+ },
+ {
+ "id": 503,
+ "op": "/",
+ "lhs": "-176524727959e-3",
+ "expected": "-25217818.279857",
+ "rounded": 1,
+ "rhs": "7",
+ "scale": 6
+ },
+ {
+ "id": 504,
+ "op": "/",
+ "lhs": "-66302683111e-2",
+ "expected": "51002063.931538",
+ "rounded": 1,
+ "rhs": "-13",
+ "scale": 6
+ },
+ {
+ "id": 505,
+ "op": "/",
+ "lhs": "960330968119e-1",
+ "expected": "-5649005694.8176",
+ "rounded": 1,
+ "rhs": "-17",
+ "scale": 4
+ },
+ {
+ "id": 506,
+ "op": "/",
+ "lhs": "-610601730589e-3",
+ "expected": "67844636.7321111",
+ "rounded": 1,
+ "rhs": "-9",
+ "scale": 7
+ },
+ {
+ "id": 507,
+ "op": "/",
+ "lhs": "-472472767450e-2",
+ "expected": "-787454612.417",
+ "rounded": 1,
+ "rhs": "6",
+ "scale": 3
+ },
+ {
+ "id": 508,
+ "op": "/",
+ "lhs": "-301748152251e-1",
+ "expected": "-1774989130.888235",
+ "rounded": 1,
+ "rhs": "17",
+ "scale": 6
+ },
+ {
+ "id": 509,
+ "op": "/",
+ "lhs": "-994981289836e-3",
+ "expected": "110553476.6484444",
+ "rounded": 1,
+ "rhs": "-9",
+ "scale": 7
+ },
+ {
+ "id": 510,
+ "op": "/",
+ "lhs": "964043804496e0",
+ "expected": "-87640345863.27272727",
+ "rounded": 1,
+ "rhs": "-11",
+ "scale": 8
+ },
+ {
+ "id": 511,
+ "op": "/",
+ "lhs": "364797099137e-3",
+ "expected": "-121599033.04566667",
+ "rounded": 1,
+ "rhs": "-3",
+ "scale": 8
+ },
+ {
+ "id": 512,
+ "op": "/",
+ "lhs": "491895961921e0",
+ "expected": "70270851703",
+ "rounded": 0,
+ "rhs": "7",
+ "scale": 4
+ },
+ {
+ "id": 513,
+ "op": "/",
+ "lhs": "-733241774588e-3",
+ "expected": "66658343.144364",
+ "rounded": 1,
+ "rhs": "-11",
+ "scale": 6
+ },
+ {
+ "id": 514,
+ "op": "/",
+ "lhs": "-917228793929e1",
+ "expected": "1310326848470",
+ "rounded": 0,
+ "rhs": "-7",
+ "scale": 5
+ },
+ {
+ "id": 515,
+ "op": "/",
+ "lhs": "-116487842453e3",
+ "expected": "19414640408833.3333",
+ "rounded": 1,
+ "rhs": "-6",
+ "scale": 4
+ },
+ {
+ "id": 516,
+ "op": "/",
+ "lhs": "864109911448e0",
+ "expected": "144018318575",
+ "rounded": 1,
+ "rhs": "6",
+ "scale": 0
+ },
+ {
+ "id": 517,
+ "op": "/",
+ "lhs": "21638692854e3",
+ "expected": "1272864285529.4",
+ "rounded": 1,
+ "rhs": "17",
+ "scale": 1
+ },
+ {
+ "id": 518,
+ "op": "/",
+ "lhs": "-175382009406e0",
+ "expected": "19486889934",
+ "rounded": 0,
+ "rhs": "-9",
+ "scale": 4
+ },
+ {
+ "id": 519,
+ "op": "/",
+ "lhs": "-525798416097e3",
+ "expected": "175266138699000",
+ "rounded": 0,
+ "rhs": "-3",
+ "scale": 0
+ },
+ {
+ "id": 520,
+ "op": "%",
+ "lhs": "596918426082156650403446530866",
+ "expected": "51118251151532",
+ "rounded": 0,
+ "rhs": "542642220322169"
+ },
+ {
+ "id": 521,
+ "op": "%",
+ "lhs": "762197442886574545869730682961",
+ "expected": "176926728146382",
+ "rounded": 0,
+ "rhs": "-194604969530091"
+ },
+ {
+ "id": 522,
+ "op": "%",
+ "lhs": "51075847658868118681640949550",
+ "expected": "69840568372921",
+ "rounded": 0,
+ "rhs": "141067574321119"
+ },
+ {
+ "id": 523,
+ "op": "%",
+ "lhs": "207285368260016641002186493574",
+ "expected": "140148617102947",
+ "rounded": 0,
+ "rhs": "643346312297249"
+ },
+ {
+ "id": 524,
+ "op": "%",
+ "lhs": "909758691269319965846923396760",
+ "expected": "562418399623550",
+ "rounded": 0,
+ "rhs": "937337089717633"
+ },
+ {
+ "id": 525,
+ "op": "%",
+ "lhs": "-603712845171263022563467631009",
+ "expected": "-387678438203213",
+ "rounded": 0,
+ "rhs": "-592994904129252"
+ },
+ {
+ "id": 526,
+ "op": "%",
+ "lhs": "577295170249162673806806409825",
+ "expected": "417522672898697",
+ "rounded": 0,
+ "rhs": "435773146573676"
+ },
+ {
+ "id": 527,
+ "op": "%",
+ "lhs": "818382924943724286437301685052",
+ "expected": "141353190108467",
+ "rounded": 0,
+ "rhs": "286069578588765"
+ },
+ {
+ "id": 528,
+ "op": "%",
+ "lhs": "772526718892932051107800089595",
+ "expected": "422552108539873",
+ "rounded": 0,
+ "rhs": "-664585376224113"
+ },
+ {
+ "id": 529,
+ "op": "%",
+ "lhs": "368003633489831099253843575005",
+ "expected": "334333558534621",
+ "rounded": 0,
+ "rhs": "381408832775016"
+ },
+ {
+ "id": 530,
+ "op": "%",
+ "lhs": "-211272106549045673938896136276",
+ "expected": "-60153846244525",
+ "rounded": 0,
+ "rhs": "-802475835760669"
+ },
+ {
+ "id": 531,
+ "op": "%",
+ "lhs": "-460643194392997480315908757016",
+ "expected": "-310079432119446",
+ "rounded": 0,
+ "rhs": "582118567789102"
+ },
+ {
+ "id": 532,
+ "op": "%",
+ "lhs": "246276800069675127098857688144",
+ "expected": "134647011025264",
+ "rounded": 0,
+ "rhs": "-341539900140664"
+ },
+ {
+ "id": 533,
+ "op": "%",
+ "lhs": "391957577188594822636074884710",
+ "expected": "38222237243926",
+ "rounded": 0,
+ "rhs": "-161830128780496"
+ },
+ {
+ "id": 534,
+ "op": "%",
+ "lhs": "339223332485487844094750656202",
+ "expected": "656776412186172",
+ "rounded": 0,
+ "rhs": "707028156743182"
+ },
+ {
+ "id": 535,
+ "op": "%",
+ "lhs": "-497976911858426744991769652899",
+ "expected": "-512134669839041",
+ "rounded": 0,
+ "rhs": "-749381496966763"
+ },
+ {
+ "id": 536,
+ "op": "%",
+ "lhs": "-254122998448272604970606078828",
+ "expected": "-173146763203182",
+ "rounded": 0,
+ "rhs": "631375523058466"
+ },
+ {
+ "id": 537,
+ "op": "%",
+ "lhs": "-175623645614310261211535268578",
+ "expected": "-218236288999082",
+ "rounded": 0,
+ "rhs": "601318074284296"
+ },
+ {
+ "id": 538,
+ "op": "%",
+ "lhs": "175705246581220578920830709112",
+ "expected": "19581515763336",
+ "rounded": 0,
+ "rhs": "-885718013158032"
+ },
+ {
+ "id": 539,
+ "op": "%",
+ "lhs": "-881410444445963391125621896667",
+ "expected": "-274069677135480",
+ "rounded": 0,
+ "rhs": "509526648682601"
+ },
+ {
+ "id": 540,
+ "op": "%",
+ "lhs": "609844523217363385061201986177",
+ "expected": "70337365325821",
+ "rounded": 0,
+ "rhs": "-72539044692371"
+ },
+ {
+ "id": 541,
+ "op": "%",
+ "lhs": "-832259997326373662053057211816",
+ "expected": "-351185704809368",
+ "rounded": 0,
+ "rhs": "559462560852528"
+ },
+ {
+ "id": 542,
+ "op": "%",
+ "lhs": "-948478193648855270111443177863",
+ "expected": "-547820333303263",
+ "rounded": 0,
+ "rhs": "736493933861302"
+ },
+ {
+ "id": 543,
+ "op": "%",
+ "lhs": "544177005427394848605611180566",
+ "expected": "210082085138251",
+ "rounded": 0,
+ "rhs": "-268619803162119"
+ },
+ {
+ "id": 544,
+ "op": "%",
+ "lhs": "38030330675540439817750702358",
+ "expected": "569085662713211",
+ "rounded": 0,
+ "rhs": "-790612404496551"
+ },
+ {
+ "id": 545,
+ "op": "%",
+ "lhs": "647947887699487416417957420094",
+ "expected": "222866244710606",
+ "rounded": 0,
+ "rhs": "864494573948893"
+ },
+ {
+ "id": 546,
+ "op": "%",
+ "lhs": "-983879153179613550385246022781",
+ "expected": "-83655183473956",
+ "rounded": 0,
+ "rhs": "-807295863698485"
+ },
+ {
+ "id": 547,
+ "op": "%",
+ "lhs": "-302506867916522857744417358853",
+ "expected": "-96268334506127",
+ "rounded": 0,
+ "rhs": "106973814774121"
+ },
+ {
+ "id": 548,
+ "op": "%",
+ "lhs": "-373214385847694923683808485395",
+ "expected": "-150857163476504",
+ "rounded": 0,
+ "rhs": "-699470768008893"
+ },
+ {
+ "id": 549,
+ "op": "%",
+ "lhs": "-989451605318053163822989866502",
+ "expected": "-295747567907566",
+ "rounded": 0,
+ "rhs": "-933790457432476"
+ },
+ {
+ "id": 550,
+ "op": "%",
+ "lhs": "-556647240205367110750139735396",
+ "expected": "-88961539801166",
+ "rounded": 0,
+ "rhs": "-788855241140330"
+ },
+ {
+ "id": 551,
+ "op": "%",
+ "lhs": "358423837088047262180650771913",
+ "expected": "55087191146789",
+ "rounded": 0,
+ "rhs": "-76573178421756"
+ },
+ {
+ "id": 552,
+ "op": "%",
+ "lhs": "-849448038355553546926884177132",
+ "expected": "-146931400434782",
+ "rounded": 0,
+ "rhs": "-154872836224025"
+ },
+ {
+ "id": 553,
+ "op": "%",
+ "lhs": "-90332000418620602989024159770",
+ "expected": "-104074588077645",
+ "rounded": 0,
+ "rhs": "167325311897885"
+ },
+ {
+ "id": 554,
+ "op": "%",
+ "lhs": "854211849606807526176967172069",
+ "expected": "67962912573077",
+ "rounded": 0,
+ "rhs": "-119551457784033"
+ },
+ {
+ "id": 555,
+ "op": "%",
+ "lhs": "536139778608975345596940741354",
+ "expected": "153071502604700",
+ "rounded": 0,
+ "rhs": "-232494992937398"
+ },
+ {
+ "id": 556,
+ "op": "%",
+ "lhs": "291323586522381418224533207455",
+ "expected": "598875039609276",
+ "rounded": 0,
+ "rhs": "-884997699352859"
+ },
+ {
+ "id": 557,
+ "op": "%",
+ "lhs": "179967351936669784962791125222",
+ "expected": "763782312473662",
+ "rounded": 0,
+ "rhs": "900542263364724"
+ },
+ {
+ "id": 558,
+ "op": "%",
+ "lhs": "-525646686041716597456265733245",
+ "expected": "-89298983859660",
+ "rounded": 0,
+ "rhs": "113966667574471"
+ },
+ {
+ "id": 559,
+ "op": "%",
+ "lhs": "59442555262576318083786099139",
+ "expected": "2514436992364",
+ "rounded": 0,
+ "rhs": "-990857377030985"
+ },
+ {
+ "id": 560,
+ "op": "%",
+ "lhs": "414813790828954947904705277094",
+ "expected": "343471524497000",
+ "rounded": 0,
+ "rhs": "947787072485081"
+ },
+ {
+ "id": 561,
+ "op": "%",
+ "lhs": "-532944467017531868357716861704",
+ "expected": "-20541761265459",
+ "rounded": 0,
+ "rhs": "117521808679959"
+ },
+ {
+ "id": 562,
+ "op": "%",
+ "lhs": "-954438739700315380028580082753",
+ "expected": "-124909005047517",
+ "rounded": 0,
+ "rhs": "129111058155028"
+ },
+ {
+ "id": 563,
+ "op": "%",
+ "lhs": "-123106089478524916712865794164",
+ "expected": "-400486395638625",
+ "rounded": 0,
+ "rhs": "440524893803399"
+ },
+ {
+ "id": 564,
+ "op": "%",
+ "lhs": "868338407478703425579695275668",
+ "expected": "52323317727388",
+ "rounded": 0,
+ "rhs": "-88998725892254"
+ },
+ {
+ "id": 565,
+ "op": "%",
+ "lhs": "320731064002490352994046453684",
+ "expected": "363530203877460",
+ "rounded": 0,
+ "rhs": "-425047070805088"
+ },
+ {
+ "id": 566,
+ "op": "%",
+ "lhs": "120987415694143218907121315301",
+ "expected": "43973085842368",
+ "rounded": 0,
+ "rhs": "-144306975910309"
+ },
+ {
+ "id": 567,
+ "op": "%",
+ "lhs": "947493862417356566796603998053",
+ "expected": "127354860666428",
+ "rounded": 0,
+ "rhs": "394942292547715"
+ },
+ {
+ "id": 568,
+ "op": "%",
+ "lhs": "-853707411518096593685168425938",
+ "expected": "-800860151726562",
+ "rounded": 0,
+ "rhs": "901843655650736"
+ },
+ {
+ "id": 569,
+ "op": "%",
+ "lhs": "-58740896417283479524735166057",
+ "expected": "-5711536768067",
+ "rounded": 0,
+ "rhs": "-29619435522870"
+ },
+ {
+ "id": 570,
+ "op": "%",
+ "lhs": "-313692509660637705824340837835",
+ "expected": "-3731062750241",
+ "rounded": 0,
+ "rhs": "213149852558357"
+ },
+ {
+ "id": 571,
+ "op": "%",
+ "lhs": "527119651477881390313891492439",
+ "expected": "418311476855039",
+ "rounded": 0,
+ "rhs": "620893690369400"
+ },
+ {
+ "id": 572,
+ "op": "%",
+ "lhs": "19996809743614280016638930445",
+ "expected": "15652133298042",
+ "rounded": 0,
+ "rhs": "-510206680555049"
+ },
+ {
+ "id": 573,
+ "op": "%",
+ "lhs": "-969450926524154055185058536525",
+ "expected": "-52056653171527",
+ "rounded": 0,
+ "rhs": "-417938867833238"
+ },
+ {
+ "id": 574,
+ "op": "%",
+ "lhs": "-432839599066409845176915525267",
+ "expected": "-136657983142453",
+ "rounded": 0,
+ "rhs": "729348268015754"
+ },
+ {
+ "id": 575,
+ "op": "%",
+ "lhs": "455819921460997385703396266294",
+ "expected": "102816312942926",
+ "rounded": 0,
+ "rhs": "441867052734014"
+ },
+ {
+ "id": 576,
+ "op": "%",
+ "lhs": "-825049713575053264001605487208",
+ "expected": "-72795472298568",
+ "rounded": 0,
+ "rhs": "-106950139816680"
+ },
+ {
+ "id": 577,
+ "op": "%",
+ "lhs": "487617702617887397521912454186",
+ "expected": "83281765318391",
+ "rounded": 0,
+ "rhs": "-911226512879565"
+ },
+ {
+ "id": 578,
+ "op": "%",
+ "lhs": "-683990708120773668974890331927",
+ "expected": "-337302381790587",
+ "rounded": 0,
+ "rhs": "688141385358556"
+ },
+ {
+ "id": 579,
+ "op": "%",
+ "lhs": "-999567256648739081261108542973",
+ "expected": "-436404305969223",
+ "rounded": 0,
+ "rhs": "-451165295468425"
+ },
+ {
+ "id": 580,
+ "op": "%",
+ "lhs": "866772975560689071456897803402",
+ "expected": "383776924988283",
+ "rounded": 0,
+ "rhs": "467409797068159"
+ },
+ {
+ "id": 581,
+ "op": "%",
+ "lhs": "18483481522992105497810082225",
+ "expected": "416994085757578",
+ "rounded": 0,
+ "rhs": "739321984213079"
+ },
+ {
+ "id": 582,
+ "op": "%",
+ "lhs": "-616480241846624788354766849587",
+ "expected": "-278943132947537",
+ "rounded": 0,
+ "rhs": "667209897303275"
+ },
+ {
+ "id": 583,
+ "op": "%",
+ "lhs": "339618714736198735717652914533",
+ "expected": "165964759043813",
+ "rounded": 0,
+ "rhs": "169625555363504"
+ },
+ {
+ "id": 584,
+ "op": "abs",
+ "lhs": "-0",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 585,
+ "op": "negate",
+ "lhs": "-0",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 586,
+ "op": "floor",
+ "lhs": "-0",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 587,
+ "op": "ceil",
+ "lhs": "-0",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 588,
+ "op": "trunc",
+ "lhs": "-0",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 589,
+ "op": "round",
+ "lhs": "-0",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 590,
+ "op": "abs",
+ "lhs": "1.5",
+ "expected": "1.5",
+ "rounded": 0
+ },
+ {
+ "id": 591,
+ "op": "negate",
+ "lhs": "1.5",
+ "expected": "-1.5",
+ "rounded": 0
+ },
+ {
+ "id": 592,
+ "op": "floor",
+ "lhs": "1.5",
+ "expected": "1",
+ "rounded": 0
+ },
+ {
+ "id": 593,
+ "op": "ceil",
+ "lhs": "1.5",
+ "expected": "2",
+ "rounded": 0
+ },
+ {
+ "id": 594,
+ "op": "trunc",
+ "lhs": "1.5",
+ "expected": "1",
+ "rounded": 0
+ },
+ {
+ "id": 595,
+ "op": "round",
+ "lhs": "1.5",
+ "expected": "2",
+ "rounded": 0
+ },
+ {
+ "id": 596,
+ "op": "abs",
+ "lhs": "-1.5",
+ "expected": "1.5",
+ "rounded": 0
+ },
+ {
+ "id": 597,
+ "op": "negate",
+ "lhs": "-1.5",
+ "expected": "1.5",
+ "rounded": 0
+ },
+ {
+ "id": 598,
+ "op": "floor",
+ "lhs": "-1.5",
+ "expected": "-2",
+ "rounded": 0
+ },
+ {
+ "id": 599,
+ "op": "ceil",
+ "lhs": "-1.5",
+ "expected": "-1",
+ "rounded": 0
+ },
+ {
+ "id": 600,
+ "op": "trunc",
+ "lhs": "-1.5",
+ "expected": "-1",
+ "rounded": 0
+ },
+ {
+ "id": 601,
+ "op": "round",
+ "lhs": "-1.5",
+ "expected": "-2",
+ "rounded": 0
+ },
+ {
+ "id": 602,
+ "op": "abs",
+ "lhs": "0.5",
+ "expected": "0.5",
+ "rounded": 0
+ },
+ {
+ "id": 603,
+ "op": "negate",
+ "lhs": "0.5",
+ "expected": "-0.5",
+ "rounded": 0
+ },
+ {
+ "id": 604,
+ "op": "floor",
+ "lhs": "0.5",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 605,
+ "op": "ceil",
+ "lhs": "0.5",
+ "expected": "1",
+ "rounded": 0
+ },
+ {
+ "id": 606,
+ "op": "trunc",
+ "lhs": "0.5",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 607,
+ "op": "round",
+ "lhs": "0.5",
+ "expected": "1",
+ "rounded": 0
+ },
+ {
+ "id": 608,
+ "op": "abs",
+ "lhs": "-0.5",
+ "expected": "0.5",
+ "rounded": 0
+ },
+ {
+ "id": 609,
+ "op": "negate",
+ "lhs": "-0.5",
+ "expected": "0.5",
+ "rounded": 0
+ },
+ {
+ "id": 610,
+ "op": "floor",
+ "lhs": "-0.5",
+ "expected": "-1",
+ "rounded": 0
+ },
+ {
+ "id": 611,
+ "op": "ceil",
+ "lhs": "-0.5",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 612,
+ "op": "trunc",
+ "lhs": "-0.5",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 613,
+ "op": "round",
+ "lhs": "-0.5",
+ "expected": "-1",
+ "rounded": 0
+ },
+ {
+ "id": 614,
+ "op": "abs",
+ "lhs": "2.5",
+ "expected": "2.5",
+ "rounded": 0
+ },
+ {
+ "id": 615,
+ "op": "negate",
+ "lhs": "2.5",
+ "expected": "-2.5",
+ "rounded": 0
+ },
+ {
+ "id": 616,
+ "op": "floor",
+ "lhs": "2.5",
+ "expected": "2",
+ "rounded": 0
+ },
+ {
+ "id": 617,
+ "op": "ceil",
+ "lhs": "2.5",
+ "expected": "3",
+ "rounded": 0
+ },
+ {
+ "id": 618,
+ "op": "trunc",
+ "lhs": "2.5",
+ "expected": "2",
+ "rounded": 0
+ },
+ {
+ "id": 619,
+ "op": "round",
+ "lhs": "2.5",
+ "expected": "3",
+ "rounded": 0
+ },
+ {
+ "id": 620,
+ "op": "abs",
+ "lhs": "-2.5",
+ "expected": "2.5",
+ "rounded": 0
+ },
+ {
+ "id": 621,
+ "op": "negate",
+ "lhs": "-2.5",
+ "expected": "2.5",
+ "rounded": 0
+ },
+ {
+ "id": 622,
+ "op": "floor",
+ "lhs": "-2.5",
+ "expected": "-3",
+ "rounded": 0
+ },
+ {
+ "id": 623,
+ "op": "ceil",
+ "lhs": "-2.5",
+ "expected": "-2",
+ "rounded": 0
+ },
+ {
+ "id": 624,
+ "op": "trunc",
+ "lhs": "-2.5",
+ "expected": "-2",
+ "rounded": 0
+ },
+ {
+ "id": 625,
+ "op": "round",
+ "lhs": "-2.5",
+ "expected": "-3",
+ "rounded": 0
+ },
+ {
+ "id": 626,
+ "op": "abs",
+ "lhs": "999.999",
+ "expected": "999.999",
+ "rounded": 0
+ },
+ {
+ "id": 627,
+ "op": "negate",
+ "lhs": "999.999",
+ "expected": "-999.999",
+ "rounded": 0
+ },
+ {
+ "id": 628,
+ "op": "floor",
+ "lhs": "999.999",
+ "expected": "999",
+ "rounded": 0
+ },
+ {
+ "id": 629,
+ "op": "ceil",
+ "lhs": "999.999",
+ "expected": "1000",
+ "rounded": 0
+ },
+ {
+ "id": 630,
+ "op": "trunc",
+ "lhs": "999.999",
+ "expected": "999",
+ "rounded": 0
+ },
+ {
+ "id": 631,
+ "op": "round",
+ "lhs": "999.999",
+ "expected": "1000",
+ "rounded": 0
+ },
+ {
+ "id": 632,
+ "op": "abs",
+ "lhs": "-999.999",
+ "expected": "999.999",
+ "rounded": 0
+ },
+ {
+ "id": 633,
+ "op": "negate",
+ "lhs": "-999.999",
+ "expected": "999.999",
+ "rounded": 0
+ },
+ {
+ "id": 634,
+ "op": "floor",
+ "lhs": "-999.999",
+ "expected": "-1000",
+ "rounded": 0
+ },
+ {
+ "id": 635,
+ "op": "ceil",
+ "lhs": "-999.999",
+ "expected": "-999",
+ "rounded": 0
+ },
+ {
+ "id": 636,
+ "op": "trunc",
+ "lhs": "-999.999",
+ "expected": "-999",
+ "rounded": 0
+ },
+ {
+ "id": 637,
+ "op": "round",
+ "lhs": "-999.999",
+ "expected": "-1000",
+ "rounded": 0
+ },
+ {
+ "id": 638,
+ "op": "abs",
+ "lhs": "1e-100",
+ "expected": "0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
+ "rounded": 0
+ },
+ {
+ "id": 639,
+ "op": "negate",
+ "lhs": "1e-100",
+ "expected": "-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
+ "rounded": 0
+ },
+ {
+ "id": 640,
+ "op": "floor",
+ "lhs": "1e-100",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 641,
+ "op": "ceil",
+ "lhs": "1e-100",
+ "expected": "1",
+ "rounded": 0
+ },
+ {
+ "id": 642,
+ "op": "trunc",
+ "lhs": "1e-100",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 643,
+ "op": "round",
+ "lhs": "1e-100",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 644,
+ "op": "abs",
+ "lhs": "-1e-100",
+ "expected": "0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
+ "rounded": 0
+ },
+ {
+ "id": 645,
+ "op": "negate",
+ "lhs": "-1e-100",
+ "expected": "0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
+ "rounded": 0
+ },
+ {
+ "id": 646,
+ "op": "floor",
+ "lhs": "-1e-100",
+ "expected": "-1",
+ "rounded": 0
+ },
+ {
+ "id": 647,
+ "op": "ceil",
+ "lhs": "-1e-100",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 648,
+ "op": "trunc",
+ "lhs": "-1e-100",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 649,
+ "op": "round",
+ "lhs": "-1e-100",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 650,
+ "op": "abs",
+ "lhs": "1e100",
+ "expected": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "rounded": 0
+ },
+ {
+ "id": 651,
+ "op": "negate",
+ "lhs": "1e100",
+ "expected": "-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "rounded": 0
+ },
+ {
+ "id": 652,
+ "op": "floor",
+ "lhs": "1e100",
+ "expected": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "rounded": 0
+ },
+ {
+ "id": 653,
+ "op": "ceil",
+ "lhs": "1e100",
+ "expected": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "rounded": 0
+ },
+ {
+ "id": 654,
+ "op": "trunc",
+ "lhs": "1e100",
+ "expected": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "rounded": 0
+ },
+ {
+ "id": 655,
+ "op": "round",
+ "lhs": "1e100",
+ "expected": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "rounded": 0
+ },
+ {
+ "id": 656,
+ "op": "abs",
+ "lhs": "-1e100",
+ "expected": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "rounded": 0
+ },
+ {
+ "id": 657,
+ "op": "negate",
+ "lhs": "-1e100",
+ "expected": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "rounded": 0
+ },
+ {
+ "id": 658,
+ "op": "floor",
+ "lhs": "-1e100",
+ "expected": "-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "rounded": 0
+ },
+ {
+ "id": 659,
+ "op": "ceil",
+ "lhs": "-1e100",
+ "expected": "-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "rounded": 0
+ },
+ {
+ "id": 660,
+ "op": "trunc",
+ "lhs": "-1e100",
+ "expected": "-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "rounded": 0
+ },
+ {
+ "id": 661,
+ "op": "round",
+ "lhs": "-1e100",
+ "expected": "-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "rounded": 0
+ },
+ {
+ "id": 662,
+ "op": "abs",
+ "lhs": "0.1",
+ "expected": "0.1",
+ "rounded": 0
+ },
+ {
+ "id": 663,
+ "op": "negate",
+ "lhs": "0.1",
+ "expected": "-0.1",
+ "rounded": 0
+ },
+ {
+ "id": 664,
+ "op": "floor",
+ "lhs": "0.1",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 665,
+ "op": "ceil",
+ "lhs": "0.1",
+ "expected": "1",
+ "rounded": 0
+ },
+ {
+ "id": 666,
+ "op": "trunc",
+ "lhs": "0.1",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 667,
+ "op": "round",
+ "lhs": "0.1",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 668,
+ "op": "abs",
+ "lhs": "-0.1",
+ "expected": "0.1",
+ "rounded": 0
+ },
+ {
+ "id": 669,
+ "op": "negate",
+ "lhs": "-0.1",
+ "expected": "0.1",
+ "rounded": 0
+ },
+ {
+ "id": 670,
+ "op": "floor",
+ "lhs": "-0.1",
+ "expected": "-1",
+ "rounded": 0
+ },
+ {
+ "id": 671,
+ "op": "ceil",
+ "lhs": "-0.1",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 672,
+ "op": "trunc",
+ "lhs": "-0.1",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 673,
+ "op": "round",
+ "lhs": "-0.1",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 674,
+ "op": "abs",
+ "lhs": "5",
+ "expected": "5",
+ "rounded": 0
+ },
+ {
+ "id": 675,
+ "op": "negate",
+ "lhs": "5",
+ "expected": "-5",
+ "rounded": 0
+ },
+ {
+ "id": 676,
+ "op": "floor",
+ "lhs": "5",
+ "expected": "5",
+ "rounded": 0
+ },
+ {
+ "id": 677,
+ "op": "ceil",
+ "lhs": "5",
+ "expected": "5",
+ "rounded": 0
+ },
+ {
+ "id": 678,
+ "op": "trunc",
+ "lhs": "5",
+ "expected": "5",
+ "rounded": 0
+ },
+ {
+ "id": 679,
+ "op": "round",
+ "lhs": "5",
+ "expected": "5",
+ "rounded": 0
+ },
+ {
+ "id": 680,
+ "op": "abs",
+ "lhs": "-5",
+ "expected": "5",
+ "rounded": 0
+ },
+ {
+ "id": 681,
+ "op": "negate",
+ "lhs": "-5",
+ "expected": "5",
+ "rounded": 0
+ },
+ {
+ "id": 682,
+ "op": "floor",
+ "lhs": "-5",
+ "expected": "-5",
+ "rounded": 0
+ },
+ {
+ "id": 683,
+ "op": "ceil",
+ "lhs": "-5",
+ "expected": "-5",
+ "rounded": 0
+ },
+ {
+ "id": 684,
+ "op": "trunc",
+ "lhs": "-5",
+ "expected": "-5",
+ "rounded": 0
+ },
+ {
+ "id": 685,
+ "op": "round",
+ "lhs": "-5",
+ "expected": "-5",
+ "rounded": 0
+ },
+ {
+ "id": 686,
+ "op": "abs",
+ "lhs": "2.49",
+ "expected": "2.49",
+ "rounded": 0
+ },
+ {
+ "id": 687,
+ "op": "negate",
+ "lhs": "2.49",
+ "expected": "-2.49",
+ "rounded": 0
+ },
+ {
+ "id": 688,
+ "op": "floor",
+ "lhs": "2.49",
+ "expected": "2",
+ "rounded": 0
+ },
+ {
+ "id": 689,
+ "op": "ceil",
+ "lhs": "2.49",
+ "expected": "3",
+ "rounded": 0
+ },
+ {
+ "id": 690,
+ "op": "trunc",
+ "lhs": "2.49",
+ "expected": "2",
+ "rounded": 0
+ },
+ {
+ "id": 691,
+ "op": "round",
+ "lhs": "2.49",
+ "expected": "2",
+ "rounded": 0
+ },
+ {
+ "id": 692,
+ "op": "abs",
+ "lhs": "-2.49",
+ "expected": "2.49",
+ "rounded": 0
+ },
+ {
+ "id": 693,
+ "op": "negate",
+ "lhs": "-2.49",
+ "expected": "2.49",
+ "rounded": 0
+ },
+ {
+ "id": 694,
+ "op": "floor",
+ "lhs": "-2.49",
+ "expected": "-3",
+ "rounded": 0
+ },
+ {
+ "id": 695,
+ "op": "ceil",
+ "lhs": "-2.49",
+ "expected": "-2",
+ "rounded": 0
+ },
+ {
+ "id": 696,
+ "op": "trunc",
+ "lhs": "-2.49",
+ "expected": "-2",
+ "rounded": 0
+ },
+ {
+ "id": 697,
+ "op": "round",
+ "lhs": "-2.49",
+ "expected": "-2",
+ "rounded": 0
+ },
+ {
+ "id": 698,
+ "op": "abs",
+ "lhs": "2.51",
+ "expected": "2.51",
+ "rounded": 0
+ },
+ {
+ "id": 699,
+ "op": "negate",
+ "lhs": "2.51",
+ "expected": "-2.51",
+ "rounded": 0
+ },
+ {
+ "id": 700,
+ "op": "floor",
+ "lhs": "2.51",
+ "expected": "2",
+ "rounded": 0
+ },
+ {
+ "id": 701,
+ "op": "ceil",
+ "lhs": "2.51",
+ "expected": "3",
+ "rounded": 0
+ },
+ {
+ "id": 702,
+ "op": "trunc",
+ "lhs": "2.51",
+ "expected": "2",
+ "rounded": 0
+ },
+ {
+ "id": 703,
+ "op": "round",
+ "lhs": "2.51",
+ "expected": "3",
+ "rounded": 0
+ },
+ {
+ "id": 704,
+ "op": "abs",
+ "lhs": "-2.51",
+ "expected": "2.51",
+ "rounded": 0
+ },
+ {
+ "id": 705,
+ "op": "negate",
+ "lhs": "-2.51",
+ "expected": "2.51",
+ "rounded": 0
+ },
+ {
+ "id": 706,
+ "op": "floor",
+ "lhs": "-2.51",
+ "expected": "-3",
+ "rounded": 0
+ },
+ {
+ "id": 707,
+ "op": "ceil",
+ "lhs": "-2.51",
+ "expected": "-2",
+ "rounded": 0
+ },
+ {
+ "id": 708,
+ "op": "trunc",
+ "lhs": "-2.51",
+ "expected": "-2",
+ "rounded": 0
+ },
+ {
+ "id": 709,
+ "op": "round",
+ "lhs": "-2.51",
+ "expected": "-3",
+ "rounded": 0
+ },
+ {
+ "id": 710,
+ "op": "abs",
+ "lhs": "9007199254740993.5",
+ "expected": "9007199254740993.5",
+ "rounded": 0
+ },
+ {
+ "id": 711,
+ "op": "negate",
+ "lhs": "9007199254740993.5",
+ "expected": "-9007199254740993.5",
+ "rounded": 0
+ },
+ {
+ "id": 712,
+ "op": "floor",
+ "lhs": "9007199254740993.5",
+ "expected": "9007199254740993",
+ "rounded": 0
+ },
+ {
+ "id": 713,
+ "op": "ceil",
+ "lhs": "9007199254740993.5",
+ "expected": "9007199254740994",
+ "rounded": 0
+ },
+ {
+ "id": 714,
+ "op": "trunc",
+ "lhs": "9007199254740993.5",
+ "expected": "9007199254740993",
+ "rounded": 0
+ },
+ {
+ "id": 715,
+ "op": "round",
+ "lhs": "9007199254740993.5",
+ "expected": "9007199254740994",
+ "rounded": 0
+ },
+ {
+ "id": 716,
+ "op": "abs",
+ "lhs": "-9007199254740993.5",
+ "expected": "9007199254740993.5",
+ "rounded": 0
+ },
+ {
+ "id": 717,
+ "op": "negate",
+ "lhs": "-9007199254740993.5",
+ "expected": "9007199254740993.5",
+ "rounded": 0
+ },
+ {
+ "id": 718,
+ "op": "floor",
+ "lhs": "-9007199254740993.5",
+ "expected": "-9007199254740994",
+ "rounded": 0
+ },
+ {
+ "id": 719,
+ "op": "ceil",
+ "lhs": "-9007199254740993.5",
+ "expected": "-9007199254740993",
+ "rounded": 0
+ },
+ {
+ "id": 720,
+ "op": "trunc",
+ "lhs": "-9007199254740993.5",
+ "expected": "-9007199254740993",
+ "rounded": 0
+ },
+ {
+ "id": 721,
+ "op": "round",
+ "lhs": "-9007199254740993.5",
+ "expected": "-9007199254740994",
+ "rounded": 0
+ },
+ {
+ "id": 722,
+ "op": "abs",
+ "lhs": "0",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 723,
+ "op": "negate",
+ "lhs": "0",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 724,
+ "op": "floor",
+ "lhs": "0",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 725,
+ "op": "ceil",
+ "lhs": "0",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 726,
+ "op": "trunc",
+ "lhs": "0",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 727,
+ "op": "round",
+ "lhs": "0",
+ "expected": "0",
+ "rounded": 0
+ },
+ {
+ "id": 728,
+ "op": "/",
+ "lhs": "1",
+ "expected": "0.12",
+ "rounded": 1,
+ "rhs": "8",
+ "scale": 2
+ },
+ {
+ "id": 729,
+ "op": "/",
+ "lhs": "3",
+ "expected": "0.38",
+ "rounded": 1,
+ "rhs": "8",
+ "scale": 2
+ },
+ {
+ "id": 730,
+ "op": "/",
+ "lhs": "-1",
+ "expected": "-0.12",
+ "rounded": 1,
+ "rhs": "8",
+ "scale": 2
+ },
+ {
+ "id": 731,
+ "op": "/",
+ "lhs": "5",
+ "expected": "2",
+ "rounded": 1,
+ "rhs": "2",
+ "scale": 0
+ },
+ {
+ "id": 732,
+ "op": "/",
+ "lhs": "7",
+ "expected": "4",
+ "rounded": 1,
+ "rhs": "2",
+ "scale": 0
+ },
+ {
+ "id": 733,
+ "op": "/",
+ "lhs": "-5",
+ "expected": "-2",
+ "rounded": 1,
+ "rhs": "2",
+ "scale": 0
+ },
+ {
+ "id": 734,
+ "op": "/",
+ "lhs": "1",
+ "expected": "0.3333",
+ "rounded": 1,
+ "rhs": "3",
+ "scale": 4
+ },
+ {
+ "id": 735,
+ "op": "/",
+ "lhs": "1",
+ "expected": "0.02",
+ "rounded": 1,
+ "rhs": "40",
+ "scale": 2
+ },
+ {
+ "id": 736,
+ "op": "/",
+ "lhs": "1",
+ "expected": "0.01",
+ "rounded": 0,
+ "rhs": "100",
+ "scale": 2
+ },
+ {
+ "id": 737,
+ "op": "/",
+ "lhs": "1",
+ "expected": "0",
+ "rounded": 1,
+ "rhs": "100",
+ "scale": 0
+ }
+ ]
+}
diff --git a/Tests/JSONCLITests/ArithmeticTests.swift b/Tests/JSONCLITests/ArithmeticTests.swift
new file mode 100644
index 0000000..11b622e
--- /dev/null
+++ b/Tests/JSONCLITests/ArithmeticTests.swift
@@ -0,0 +1,147 @@
+// SPDX-License-Identifier: Apache-2.0
+import Foundation
+import Testing
+import JSON
+@testable import JSONCLIEngine
+@testable import JSONFilterRuntime
+
+private struct ArithmeticEmptyInput: FilterInput { mutating func next(context: inout CLIJobContext) throws -> FilterYield? { nil } }
+private func numericQuery(_ source: String, scale: Int? = nil) throws -> [JSON] {
+ var context = try CLIJobContext(); context.divisionScale = scale
+ let program = try FilterCompiler.compile(source, context: &context)
+ var vm = try FilterVM(program: program, input: .init(value: .null), context: &context)
+ defer { try? vm.close(context: &context) }
+ var input = ArithmeticEmptyInput(), values: [JSON] = []
+ while var value = try vm.next(input: &input, context: &context) { values.append(value.value); try value.release(context: &context) }
+ return values
+}
+@Test func cliArithmeticMatchesIndependentIntegerRationalOracle() throws {
+ let url = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent().appendingPathComponent("Fixtures/CLI/ArithmeticOracle.json")
+ let root = try JSONParser().parse(Array(Data(contentsOf: url)))
+ guard case .object(let fixture) = root, case .array(let cases) = fixture[JSONKey("cases")] else { Issue.record("Missing oracle fixture"); return }
+ #expect(cases.count == 738)
+ for row in cases {
+ guard case .object(let item) = row, case .string(let op) = item[JSONKey("op")], case .string(let lhs) = item[JSONKey("lhs")], case .string(let expected) = item[JSONKey("expected")] else { Issue.record("Malformed oracle row"); continue }
+ var context = try CLIJobContext()
+ if case .number(let scale) = item[JSONKey("scale")] { context.divisionScale = try scale.integer(as: Int.self, meter: &context.meter) }
+ var result: FilterYield
+ if case .string(let rhs) = item[JSONKey("rhs")] { result = try ExactDecimal.binary(op, JSONNumber(parsing: lhs), JSONNumber(parsing: rhs), context: &context) }
+ else { result = try ExactDecimal.unary(op, JSONNumber(parsing: lhs), context: &context) }
+ guard case .number(let actual) = result.value else { Issue.record("Non-number arithmetic result"); continue }
+ #expect(try actual.compare(to: JSONNumber(parsing: expected), meter: &context.meter) == .orderedSame, "\(op) \(lhs) expected \(expected)")
+ #expect(actual.originalLexeme == nil)
+ if case .number(let rounded) = item[JSONKey("rounded")] { #expect(context.roundedDivisions == (try rounded.integer(as: UInt64.self, meter: &context.meter))) }
+ try result.release(context: &context)
+ #expect(context.meter.used(.retainedBytes) == 0)
+ }
+}
+@Test func cliArithmeticOperatorsKeepCartesianOrderAndPipelinePrecedence() throws {
+ var argvContext = try CLIJobContext()
+ let argv = try CLIArguments(["query","--","-7%3"], context: &argvContext)
+ #expect(argv.positionals == ["-7%3"])
+ #expect(try numericQuery("(1,2)+(10,20)") == [.number(11),.number(12),.number(21),.number(22)])
+ #expect(try numericQuery("1,2 | .+10") == [.number(11),.number(12)])
+ #expect(try numericQuery("+(-0), -(-0), 0*1e1000000") == [.number(0),.number(0),.number(0)])
+ #expect(try numericQuery("{\"é\":1,\"é\":2} | .\"é\", .\"é\"") == [.number(1),.number(2)])
+}
+@Test func cliArithmeticLanguageErrorsAreCatchableAndRoundedPolicyExplicit() throws {
+ #expect(try numericQuery("try (1/3) catch .") == [.string("inexactDivision")])
+ #expect(try numericQuery("try (1/0) catch .") == [.string("divisionByZero")])
+ #expect(try numericQuery("try (1.5%1) catch .") == [.string("integralOperandsRequired")])
+ #expect(try numericQuery("1/8,3/8,-1/8", scale: 2) == [.number(JSONNumber(parsing:"0.12")),.number(JSONNumber(parsing:"0.38")),.number(JSONNumber(parsing:"-0.12"))])
+ #expect(try numericQuery("1e-1000000/3", scale: 2) == [.number(0)])
+ #expect(try numericQuery("2.5|round") == [.number(3)])
+ #expect(try numericQuery("2.5/1", scale: 0) == [.number(2)])
+}
+@Test func cliArithmeticNonNumericOverloadsPreserveScalarAndContainerIdentity() throws {
+ #expect(try numericQuery("\"é\"+\"é\"") == [.string("éé")])
+ #expect(try numericQuery("[1,2,3,2]-[2]") == [.array([.number(1),.number(3)])])
+ #expect(try numericQuery("\"éé\"/\"é\"") == [.array([.string(""),.string(""),.string("")])])
+ #expect(try numericQuery("\"🦊\"*3") == [.string("🦊🦊🦊")])
+ #expect(try numericQuery("({a:{x:1,y:2}}*{a:{y:3,z:4}}).a") == [try JSONParser().parse(Array("{\"x\":1,\"y\":3,\"z\":4}".utf8))])
+ #expect(try numericQuery("[1,2,3]|add") == [.number(6)])
+ #expect(try numericQuery("[]|add") == [.null])
+}
+@Test func cliArithmeticRangeIsExactDemandDrivenAndZeroStepErrors() throws {
+ #expect(try numericQuery("[range(5;0;-2)]") == [.array([.number(5),.number(3),.number(1)])])
+ #expect(try numericQuery("[range(0;0.3;0.1)]") == [.array([.number(0),.number(JSONNumber(parsing:"0.1")),.number(JSONNumber(parsing:"0.2"))])])
+ #expect(try numericQuery("try range(0;10;0) catch .") == [.string("zeroRangeStep")])
+}
+@Test func cliArithmeticExponentGapFailsBeforeDenseAllocationAndCannotBeCaught() throws {
+ var compilation = try CLIJobContext()
+ let program = try FilterCompiler.compile("try (1e1000000+1) catch null", context: &compilation)
+ var context = try CLIJobContext(), input = ArithmeticEmptyInput()
+ var vm = try FilterVM(program: program, input: .init(value: .null), context: &context)
+ do { _ = try vm.next(input: &input, context: &context); Issue.record("Expected checked dense-growth cap") }
+ catch let failure as JSONFailure { #expect(failure.category == .resource && failure.resource?.metric == .numberDigits) }
+ try vm.close(context: &context)
+ #expect(context.meter.statistics().peakLogicalRetainedBytes < 20000)
+ #expect(context.meter.used(.retainedBytes) == 0)
+}
+
+@Test func cliArithmeticActualDigitExponentTokenWorkAndRetentionCapsAreInclusive() throws {
+ let a = try JSONNumber(parsing: "99"), b = try JSONNumber(parsing: "99")
+ for (metric, boundary, lhs, rhs) in [(JSONResourceMetric.numberDigits, UInt64(4), a, b), (.absoluteExponent, 20, try JSONNumber(parsing:"1e10"), try JSONNumber(parsing:"1e10")), (.numberTokenBytes, 4, a, b)] {
+ for allowed in [true,false] {
+ var limits = CLILimits(); limits.core[metric] = boundary - (allowed ? 0 : 1)
+ var context = try CLIJobContext(limits: limits)
+ do {
+ var result = try ExactDecimal.binary("*",lhs,rhs,context:&context)
+ #expect(allowed); try result.release(context:&context)
+ } catch let failure as JSONFailure { #expect(!allowed && failure.category == .resource && failure.resource?.metric == metric) }
+ try context.reclaimValueLeases()
+ #expect(context.meter.used(.retainedBytes) == 0)
+ }
+ }
+ var measured = try CLIJobContext()
+ var value = try ExactDecimal.binary("*",a,b,context:&measured)
+ let work = measured.meter.used(.numericWorkUnits), peak = measured.meter.statistics().peakLogicalRetainedBytes
+ try value.release(context:&measured)
+ for metric in [JSONResourceMetric.numericWorkUnits,.retainedBytes] {
+ for allowed in [true,false] {
+ var limits = CLILimits(); limits.core[metric] = (metric == .numericWorkUnits ? work : peak) - (allowed ? 0 : 1)
+ var context = try CLIJobContext(limits:limits)
+ do { var result = try ExactDecimal.binary("*",a,b,context:&context); #expect(allowed); try result.release(context:&context) }
+ catch let failure as JSONFailure { #expect(!allowed && failure.category == .resource && failure.resource?.metric == metric) }
+ try context.reclaimValueLeases(); #expect(context.meter.used(.retainedBytes) == 0)
+ }
+ }
+}
+@Test func cliArithmeticCancellationRendezvousIsInsideLongMultiply() async throws {
+ let a = try JSONNumber(parsing:String(repeating:"9",count:300))
+ let task = Task {
+ var context = try CLIJobContext()
+ context.meter.checkpointObserver = { work in if work >= 5000 { withUnsafeCurrentTask { $0?.cancel() } } }
+ #expect(throws:CancellationError.self) { _ = try ExactDecimal.binary("*",a,a,context:&context) }
+ #expect(context.meter.used(.numericWorkUnits) >= 5000)
+ try context.reclaimValueLeases(); #expect(context.meter.used(.retainedBytes) == 0)
+ #expect(throws:CancellationError.self) { try context.checkpoint() }
+ }
+ try await task.value
+}
+@Test func cliArithmeticHostIndexNarrowingIsCheckedAndFiniteConfigurationsStayDistinct() throws {
+ var context = try CLIJobContext()
+ let count = try JSONNumber(parsing:"18446744073709551616")
+ do { _ = try FilterOperators.apply("*",.string("x"),.number(count),context:&context); Issue.record("Expected checked host index overflow") }
+ catch let error as CLIError { #expect(error.category == .resource && error.code == "counterOverflow") }
+ try context.reclaimValueLeases(); #expect(context.meter.used(.retainedBytes) == 0)
+ var limits = CLILimits(); limits.core[.numberDigits] = UInt64(Int.max)-1
+ var overflow = try CLIJobContext(limits:limits)
+ var buffer: DecimalMagnitude? = try DecimalMagnitude.allocate(10,context:&overflow)
+ #expect(buffer?.count == 10); buffer = nil
+ try overflow.reclaimValueLeases(); #expect(overflow.meter.used(.retainedBytes) == 0)
+ #expect(throws:CLIError.self) { _ = try DecimalMagnitude.allocate(Int.max,context:&overflow) }
+}
+
+@Test func cliArithmeticDomainHandoffDrainsDeadScratchBeforeOutputBaseline() throws {
+ var context = try CLIJobContext()
+ var result = try ExactDecimal.binary("+",JSONNumber(parsing:"0.1"),JSONNumber(parsing:"0.2"),context:&context)
+ // The result is live; only dead coefficient drafts may refund here.
+ try context.domain(.writing)
+ let entry = context.meter.used(.retainedBytes)
+ #expect(entry == result.lease?.retained)
+ try context.work()
+ #expect(context.meter.used(.retainedBytes) == entry)
+ try result.release(context:&context)
+ #expect(context.meter.used(.retainedBytes) == 0)
+}
From b06b52f76982022b3383efd424f98988c4b16961 Mon Sep 17 00:00:00 2001
From: Thorsten Fuchs <76904008+ThorFuchs@users.noreply.github.com>
Date: Thu, 15 Oct 2026 08:27:27 +0200
Subject: [PATCH 5/6] docs: reconcile CLI product acceptance with merged native
bridges
---
.../Architecture/Release1.4/Acceptance.json | 15 ++++++++++-----
Documentation/Architecture/Release1.4/Plan.md | 6 ++++--
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/Documentation/Architecture/Release1.4/Acceptance.json b/Documentation/Architecture/Release1.4/Acceptance.json
index 5b17493..e0743ac 100644
--- a/Documentation/Architecture/Release1.4/Acceptance.json
+++ b/Documentation/Architecture/Release1.4/Acceptance.json
@@ -19,15 +19,19 @@
{
"id": "CL002",
"gate": "C0",
- "title": "Six public products with correct kinds",
- "verification": "Package dump contains five libraries plus swift-json executable; private targets have no products.",
+ "title": "Seven public products with correct kinds after E2 reconciliation",
+ "verification": "Package dump contains six libraries, including merged opt-in JSONBridges, plus swift-json executable; private targets have no products.",
"obligation": "mandatory",
"status": "passed",
"evidence_required": true,
"fixture_ids": [],
"evidence": [
"Documentation/Architecture/Release1.4/Qualification.md"
- ]
+ ],
+ "historical_six_product_contract": {
+ "title": "Six public products with correct kinds",
+ "verification": "Package dump contains five libraries plus swift-json executable; private targets have no products."
+ }
},
{
"id": "CL003",
@@ -1130,7 +1134,7 @@
{
"id": "CL090",
"gate": "C5",
- "title": "Six-product CI/documentation",
+ "title": "Combined E2/CLI product CI and documentation",
"verification": "Existing native/safety/docs plus affected Linux lanes, exact product kinds and public CLI help/docs/examples.",
"obligation": "mandatory",
"status": "not_run",
@@ -1181,6 +1185,7 @@
"notes": [
"Package integrity is separate from native qualification.",
"Optional extensions do not block the scoped candidate when not claimed.",
- "WASI CLI supported/blocked/limited disposition is mandatory; full CLI support is separately earned."
+ "WASI CLI supported/blocked/limited disposition is mandatory; full CLI support is separately earned.",
+ "Main e8c3e4b added the approved JSONBridges product before CLI merge. Current integration preserves six libraries plus the CLI; original briefing/product evidence remains historical."
]
}
diff --git a/Documentation/Architecture/Release1.4/Plan.md b/Documentation/Architecture/Release1.4/Plan.md
index 9ae86d6..0beabd8 100644
--- a/Documentation/Architecture/Release1.4/Plan.md
+++ b/Documentation/Architecture/Release1.4/Plan.md
@@ -1,7 +1,7 @@
# CLI release plan
The maintainer-approved 1.4.0 train adds `swift-json` as an executable beside the
-five libraries. JSONFilterRuntime and JSONCLIEngine are package-private targets;
+six libraries, including the independently merged opt-in JSONBridges. JSONFilterRuntime and JSONCLIEngine are package-private targets;
JSONRegexRuntime remains private. Root external dependencies remain empty.
Historical four/five-product releases and their evidence are unchanged.
@@ -14,7 +14,7 @@ branches and draft PRs; it does not change the parallel transfer/PDF or 1.2 work
| Gate | Cohesive implementation and acceptance |
| --- | --- |
| C0 | Source/protection/prerequisite audit, executable/private target shapes, one noncopyable job ledger |
-| C1 | Bounded argv/stdio/files, diagnostics/exits, atomic output, format/validate/Pointer/Patch, six-product inventory |
+| C1 | Bounded argv/stdio/files, diagnostics/exits, atomic output, format/validate/Pointer/Patch, seven-product inventory |
| C2 | Original flat filter IR and pull VM, input framing, generators/paths/control/bindings/common builtins |
| C3 | Private exact decimal arithmetic; explicit scale plus half-even division policy |
| C4 | Qualified richer filters, lexical functions/reductions/path updates; explicit unsupported features |
@@ -38,3 +38,5 @@ host; WASI executable feasibility is separate from the already qualified librari
Native and sanitizer receipts, subprocess outcomes, commands, toolchain, source and
binary identities accompany every qualified milestone. All 49 baseline probes and
independent-suite exclusions remain required and separate from CLI additions.
+
+Main reconciliation for merging PR23–PR27 preserves E2 main e8c3e4b and its public bridges, ergonomics behavior, six DocC catalogs and compiler consumers. Only the CLI executable is added to those six libraries. Exact combined module inventories and all 49 baseline probes remain mandatory.
From 83f83f60a6bea3fc84fa2a7030273a9427d02517 Mon Sep 17 00:00:00 2001
From: Thorsten Fuchs <76904008+ThorFuchs@users.noreply.github.com>
Date: Thu, 15 Oct 2026 08:30:19 +0200
Subject: [PATCH 6/6] fix(ci): preserve the combined shared-state sanitizer
inventory
---
Scripts/ci.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Scripts/ci.py b/Scripts/ci.py
index e60ba4b..0d04736 100644
--- a/Scripts/ci.py
+++ b/Scripts/ci.py
@@ -119,7 +119,7 @@ def check_result(command, code, log, events=None):
if events is not None:
counts = events['bundle_counts']
if command[:2] == ['swift', 'test']:
- expected = [36] if 'cli|sharedFilterPlan' in command else [38] if 'export|Export|apple' in command else [14] if 'Tools/WasmAudit' in command else [2, 3, 3, 11] if 'qa' in command else [7] if R0_TESTS in command else [3] if 'Tools/MCPReadiness' in command or 'Tools/MobileQualification' in command else [1] if 'Tools/Qualification' in command else sorted([119, 55, 14, 11, 12, 61 if sys.platform == 'linux' else 75, 36, 10])
+ expected = [36] if 'cli|sharedFilterPlan' in command else [38] if 'export|Export|apple' in command else [14] if 'Tools/WasmAudit' in command else [2, 3, 3, 11] if 'qa' in command else [7] if R0_TESTS in command else [3] if 'Tools/MCPReadiness' in command or 'Tools/MobileQualification' in command else [1] if 'Tools/Qualification' in command else sorted([1, 1, 3 if sys.platform == 'linux' else 4, 1, 2, 4]) if 'thread' in command else sorted([119, 55, 14, 11, 12, 61 if sys.platform == 'linux' else 75, 36, 10])
passed = passed and sorted(counts) == expected
if '--filter' not in command and not any(x.startswith('Tools/') for x in command):
if events is not None: