Skip to content

feat(jq): own the experimental value boundary and native validation - #3018

Merged
chaliy merged 12 commits into
mainfrom
feat/experimental-jq-ownership
Nov 26, 2026
Merged

chaliy merged 12 commits into
mainfrom
feat/experimental-jq-ownership

Conversation

@chaliy

@chaliy chaliy commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Add opt-in experimental_jq ownership of array/object storage for both jq and yq, while reusing jaq's parser, evaluator and standard library. Checked construction/mutation owns depth, memory admission, COW and iterator lifetime accounting. The feature is off by default and forwarded by every embedding crate.

Optimize checked array growth, COW copying, object updates and polling. Independently fix interruptibility of shared-tree comparison, hashing, containment, byte conversion and formatting in both backends.

Give the experiment first-class native validation: required Linux/macOS/Windows storage × execution-plan matrix with pinned jq 1.8.1, binding/browser tests, model properties, structured lifecycle fuzzing, coverage, ASan, Miri and reproducible paired benchmarks.

Why

Make the jq resource/value boundary a maintained Bashkit component before considering deeper evaluator ownership. An experimental feature lets us measure compatibility, safety and performance without changing release defaults.

Before / After

Shared generated trees could require exponential traversal despite a depth limit; both backends now interrupt those traversals and recover for the next request.
The initial owned implementation paid for repeated growth/scans/lookups. Alternating development measurements lowered owned array updates by 6.1%, object updates by 11.4%, array COW by 8.7%, and object COW by 4.8% against the prior owned implementation. A pinned fat-LTO stable-versus-owned benchmark shows parity on array updates/COW, object updates 1.7% faster, object COW 2.6% faster, and explicit tradeoffs for concat (+12.1%) and sort/unique (+7.2%). Raw results and methodology are committed in crates/bashkit/benches/results/criterion-jq-paired-linux-x86_64-1795651774.{json,md}.

Risk

  • Medium: new storage and mutation boundary, deliberately experimental and disabled by default.
  • Resource limits may reject earlier because owned growth/scratch/COW admission is conservative.
  • In-process interruption still requires unwinding; this does not replace or certify the evaluator.

Checklist

  • Tests added or updated
  • Backward compatibility considered

Validation: all four jq/yq native configurations passed (1,766 tests total); script tests passed (282, 4 skipped), Miri passed 7 lifecycle cases, and the owned ASan slice passed 47 integration cases. All 12 jq/yq/lifecycle fuzz smoke configurations passed; longer owned lifecycle campaigns completed 3,620 and 2,752 executions without crashes. All-feature Clippy, Python lint, 30 security properties, 19 failpoint tests, browser Wasm and C API examples. Broad interpreter benchmarking matched Bash output on all 96 cases; parallel scaling measured 2.62×–2.97× speedups across 50-session workloads. Reports and the generated site timeline are committed. The pre-artifact CI head was green (118 passed, 1 skipped); final CI is running on the reviewed return-path and depth-inventory fixes. The canary jobs visibly fall back to stable 2.x only while Deno's canary binary URL returns 404. Both review findings were fixed; the inline thread is resolved. Local full-workspace tests hit four process cleanup assertions in this sandbox, while standard CI passed them. Local WASI needed an unavailable clang; CI WASI passed.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 8096b3d Commit Preview URL

Branch Preview URL
Nov 26 2026, 12:19 AM

@chaliy
chaliy force-pushed the feat/experimental-jq-ownership branch from f308835 to 8096b3d Compare November 26, 2026 00:18
@chaliy
chaliy marked this pull request as ready for review November 26, 2026 00:29

@bashkit-pr-reviewer bashkit-pr-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed the experimental owned jq container boundary (head 8096b3d). The core design is sound: depth + memory admission on every attach path, COW charging through require, charge-transferring iterators, resync reconciliation after growth, sticky trip checks per-output and after the run, and the feature strictly opt-in everywhere. No blocking issues. Two robustness notes below.

Comments outside the diff

crates/bashkit/src/builtins/jq/mod.rs line 671: [P2] The recorded host-budget error is never consulted when evaluation completes normally. The tick closure stores the error in interruption and returns true, but the Ok path here only checks meter.tripped() and input_error. On unwind builds this is unreachable (tick's abort(Abort::Interrupted) unwinds first), but under cfg(not(panic = "unwind")) abort() is a silent no-op for Interrupted/Recursion, so on such targets a budget overrun would be recorded and then silently dropped while evaluation continues uninterruptible. Since the wasm/browser CI rows enable experimental_jq, consider also checking the interruption cell on this path so the new hook fails closed everywhere, not just where unwinding is available. Evidence: jaq_json/meter.rs abort() only trips for Memory | Depth and only unwinds under panic = "unwind"; docs/jq.md already discloses the unwind requirement for untrusted filters.

@bashkit-pr-reviewer

bashkit-pr-reviewer Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Review summary (head 4ebe786, re-review)

Verdict: No findings. Both prior P2s remain resolved; nothing outstanding.

What changed since 298d867: jq_value_depth_tests.rs (+95/−1, was +91/−1) only — four added comment lines in the REVIEWED mutation-site inventory documenting why the read.rs Rc::new sites are safe (checked push/insert + debug-build depth verification) and the owned.rs take-then-restore pattern. Documentation only; the exact-set scan semantics, the get_mut(/iter_mut(/values_mut( watch, and all scanned source files are untouched. (Note: this checkout pass also reported 11 transient message-store write failures on unrelated bash-oracle scripts; none are in this PR's scope.)

Coverage notes: reviewed from the checked-out head; realfs.rs (+7/−1) hunk still not isolated via the diff cutoff and the file has no jq references; bench data/timeline skimmed only; no build or test run; mergeable_state remains blocked.

@chaliy
chaliy force-pushed the feat/experimental-jq-ownership branch from 8096b3d to a8cac95 Compare November 26, 2026 00:59
@chaliy
chaliy merged commit f2bb6b0 into main Nov 26, 2026
119 checks passed
@chaliy
chaliy deleted the feat/experimental-jq-ownership branch November 26, 2026 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant