Goal
Add Rust/WASM acceleration coverage for every eligible tsb core function while keeping the existing TypeScript implementations as the default-compatible fallback.
Completion Contract
The Goal workflow should add goal-completed and remove goal only when:
- The repository has a Rust/WASM implementation layer that builds to WebAssembly and can be loaded from a Node/Bun environment.
- Existing TypeScript core implementations remain present and usable as fallbacks; the public
tsb API remains backward compatible for current callers.
- Every public core export from
src/core/index.ts, plus every top-level core export re-exported through src/index.ts, is represented in a machine-checkable Rust/WASM coverage manifest.
- The coverage manifest classifies each core function or method as either:
rust-wasm: implemented in Rust, exported through WASM, wired into the Node/Bun-accessible accelerated path, and covered by parity tests; or
ts-only-ineligible: explicitly not suitable for Rust/WASM with a concrete reason, such as arbitrary JS callback semantics, JS object identity behavior, external I/O, or another specific incompatibility.
- There are no
todo, unknown, unclassified, or missing entries in the coverage manifest.
- Every
rust-wasm entry has parity tests showing the Rust/WASM path returns the same observable result as the existing TypeScript path for representative normal, edge, missing-value, and dtype cases.
- The accelerated path can be selected from Node/Bun without replacing the TypeScript implementation. A caller should be able to use the TypeScript path and the Rust/WASM path in the same environment for comparison and fallback.
- Benchmark coverage is added for every
rust-wasm entry or for a documented benchmark group that covers that entry, and the benchmark output compares TypeScript tsb against Rust/WASM tsb.
- Benchmark results are written to a stable JSON artifact, and any Rust/WASM case that is slower than the TypeScript baseline is explicitly identified in the output or in the coverage report with a short explanation.
- The TypeScript test suite, strict typecheck, lint, Rust tests, WASM build, WASM parity tests, Rust/WASM coverage check, and Rust/WASM benchmark command all pass.
Evidence / Verification
The workflow should add any missing package scripts needed by this contract. At completion, this script must pass from the repository root:
set -euo pipefail
bun install
bun run typecheck
bun run lint
bun test ./tests/core/
# Added by the workflow as part of this goal.
bun run wasm:build
bun run wasm:test
bun run wasm:coverage
BENCHMARK_WORKERS=2 BENCHMARK_TIMEOUT=60 bun run bench:wasm-core
python3 - <<'PY'
import json
from pathlib import Path
coverage_path = Path("benchmarks/results-wasm-core.json")
if not coverage_path.is_file():
raise SystemExit("benchmarks/results-wasm-core.json was not written")
results = json.loads(coverage_path.read_text())
benchmarks = results.get("benchmarks")
if not isinstance(benchmarks, list) or not benchmarks:
raise SystemExit("Rust/WASM benchmark output has no benchmark entries")
missing = [b for b in benchmarks if "tsb" not in b or "tsb_wasm" not in b]
if missing:
raise SystemExit(f"Benchmark entries missing tsb/tsb_wasm comparison: {missing[:5]}")
coverage_summary = results.get("coverage")
if not isinstance(coverage_summary, dict):
raise SystemExit("Benchmark output must include a coverage summary")
if coverage_summary.get("unclassified", 1) != 0:
raise SystemExit("Rust/WASM coverage still has unclassified entries")
if coverage_summary.get("eligible_missing", 1) != 0:
raise SystemExit("Rust/WASM coverage still has eligible functions without implementations")
if coverage_summary.get("total_core_entries", 0) <= 0:
raise SystemExit("Rust/WASM coverage summary did not count core entries")
PY
Completion also requires the final PR body or issue comment to include:
- The path to the coverage manifest.
- The number of total core entries,
rust-wasm entries, and ts-only-ineligible entries.
- The Rust/WASM benchmark artifact path.
- A short summary of fastest wins and any slower-than-TypeScript cases.
Scope and Constraints
The workflow may change:
Cargo.toml, Cargo.lock, Rust crate files, and Rust/WASM build configuration.
- New Rust/WASM source and generated bindings under a clearly named path such as
rust/, wasm/, src/wasm/, or src/core/wasm/.
- TypeScript glue code needed to expose the accelerated path from Node/Bun while preserving the current TypeScript behavior.
src/core/** only where needed for optional dispatch/fallback glue.
tests/core/** and new Rust/WASM parity tests.
benchmarks/run_benchmarks.sh, new benchmarks/tsb-wasm/** files, and benchmark result/runner files needed for Rust/WASM comparisons.
package.json scripts needed for wasm:build, wasm:test, wasm:coverage, and bench:wasm-core.
- Documentation or machine-readable manifests that explain Rust/WASM eligibility and coverage.
The workflow must not change:
README.md.
.autoloop/programs/**.
- The public
tsb API in a breaking way.
- Existing TypeScript implementations by deleting or replacing them outright.
- Core runtime JS dependencies. Any new JS dependency must be build/test tooling only and justified. Rust dependencies must be limited to necessary WASM binding/build support or low-level utilities, not dataframe/numeric algorithm libraries that replace first-principles implementations.
- Strict TypeScript rules: no
any, no as casts, no @ts-ignore, and no escape hatches.
Context To Read First
AGENTS.md
package.json
src/core/index.ts
src/index.ts
src/core/**
tests/core/**
benchmarks/run_benchmarks.sh
benchmarks/tsb/**
- Existing benchmark result shape in
benchmarks/results.json
Iteration Policy
Work in small checkpoints. This goal must advance piecemeal across multiple Goal runs rather than trying to build the full Rust/WASM layer in one pass.
Each run should complete one small, reviewable checkpoint and then stop after reporting the evidence. The first checkpoint should make the goal measurable before porting broadly:
- Create the Rust/WASM coverage inventory and define the eligibility rules.
- Add the build/test/coverage/benchmark command scaffolding needed by the evidence script, even if many entries are initially classified as not yet ported.
- Open or update the draft PR with that checkpoint before broadening implementation.
After the measurement checkpoint, port one coherent group per run, prioritizing CPU-heavy core operations such as numeric reductions, search/sort helpers, align/reindex/index operations, and vectorized scalar transforms.
For every run:
- Keep the change set small enough to review as a single checkpoint.
- Do not delegate the entire goal to one broad background agent. If a sub-agent is used, scope it to the current checkpoint only.
- If a background agent is still running after one status read, stop the parent turn and wait for the completion notification instead of repeatedly polling.
- Execute the narrowest relevant parity tests and benchmark subset before broadening to the full evidence script.
- Report what changed, what was verified, what remains, and whether any functions were marked
ts-only-ineligible.
Do not mark the goal complete from intent or partial coverage. Completion requires the manifest and evidence script to prove there are no unclassified entries and no eligible missing Rust/WASM implementations.
Blocked Stop Condition
Stop substantive work and comment instead of guessing if:
- The Rust/WASM toolchain cannot be installed or used in the GitHub Actions environment.
- The workflow cannot load the generated WASM from Node/Bun without adding unsupported runtime dependencies.
- A core function's eligibility cannot be decided from the code and tests alone.
- Meeting the coverage contract would require deleting the TypeScript implementation or breaking the public API.
- The benchmark harness cannot produce stable TypeScript vs Rust/WASM comparisons after reasonable retries.
The blocked comment should include the exact command output, the functions or files affected, what is known, and the smallest maintainer decision or environment change needed to continue.
Goal
Add Rust/WASM acceleration coverage for every eligible
tsbcore function while keeping the existing TypeScript implementations as the default-compatible fallback.Completion Contract
The Goal workflow should add
goal-completedand removegoalonly when:tsbAPI remains backward compatible for current callers.src/core/index.ts, plus every top-level core export re-exported throughsrc/index.ts, is represented in a machine-checkable Rust/WASM coverage manifest.rust-wasm: implemented in Rust, exported through WASM, wired into the Node/Bun-accessible accelerated path, and covered by parity tests; orts-only-ineligible: explicitly not suitable for Rust/WASM with a concrete reason, such as arbitrary JS callback semantics, JS object identity behavior, external I/O, or another specific incompatibility.todo,unknown,unclassified, or missing entries in the coverage manifest.rust-wasmentry has parity tests showing the Rust/WASM path returns the same observable result as the existing TypeScript path for representative normal, edge, missing-value, and dtype cases.rust-wasmentry or for a documented benchmark group that covers that entry, and the benchmark output compares TypeScripttsbagainst Rust/WASMtsb.Evidence / Verification
The workflow should add any missing package scripts needed by this contract. At completion, this script must pass from the repository root:
Completion also requires the final PR body or issue comment to include:
rust-wasmentries, andts-only-ineligibleentries.Scope and Constraints
The workflow may change:
Cargo.toml,Cargo.lock, Rust crate files, and Rust/WASM build configuration.rust/,wasm/,src/wasm/, orsrc/core/wasm/.src/core/**only where needed for optional dispatch/fallback glue.tests/core/**and new Rust/WASM parity tests.benchmarks/run_benchmarks.sh, newbenchmarks/tsb-wasm/**files, and benchmark result/runner files needed for Rust/WASM comparisons.package.jsonscripts needed forwasm:build,wasm:test,wasm:coverage, andbench:wasm-core.The workflow must not change:
README.md..autoloop/programs/**.tsbAPI in a breaking way.any, noascasts, no@ts-ignore, and no escape hatches.Context To Read First
AGENTS.mdpackage.jsonsrc/core/index.tssrc/index.tssrc/core/**tests/core/**benchmarks/run_benchmarks.shbenchmarks/tsb/**benchmarks/results.jsonIteration Policy
Work in small checkpoints. This goal must advance piecemeal across multiple Goal runs rather than trying to build the full Rust/WASM layer in one pass.
Each run should complete one small, reviewable checkpoint and then stop after reporting the evidence. The first checkpoint should make the goal measurable before porting broadly:
After the measurement checkpoint, port one coherent group per run, prioritizing CPU-heavy core operations such as numeric reductions, search/sort helpers, align/reindex/index operations, and vectorized scalar transforms.
For every run:
ts-only-ineligible.Do not mark the goal complete from intent or partial coverage. Completion requires the manifest and evidence script to prove there are no unclassified entries and no eligible missing Rust/WASM implementations.
Blocked Stop Condition
Stop substantive work and comment instead of guessing if:
The blocked comment should include the exact command output, the functions or files affected, what is known, and the smallest maintainer decision or environment change needed to continue.