Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,30 @@ jobs:
run: >-
cargo run --locked -q -- --strict src tests ../codeupipe-rs/src
../codeupipe-rs/examples ../codeupipe-rs/tests ../../conformance/runners/rust/src
../codeupipe-compile-rs/src ../codeupipe-compile-rs/tests ../codeupipe-compile-rs/examples
- name: The oldest Rust that the crate supports (rust-version)
run: |
rustup toolchain install 1.75 --profile minimal
cargo +1.75 test --locked

rust-compile:
name: Rust compiler
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/codeupipe-compile-rs
steps:
- uses: actions/checkout@v5
# A workspace of its own: it downloads syn, quote and prettyplease
# from crates.io, at the versions in its Cargo.lock.
- name: Format
run: cargo fmt --check
- name: Clippy
run: cargo clippy --locked --all-targets -- -D warnings
- name: Tests
run: cargo test --locked
- name: Compiled against the pipeline (numbers only)
run: cargo run --locked --release -q --example bench
- name: The oldest Rust that the crate supports (rust-version)
run: |
rustup toolchain install 1.75 --profile minimal
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ node_modules/

/target/
/packages/codeupipe-lint-rs/target/
/packages/codeupipe-compile-rs/target/
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ This repository has seven packages.
| `codeupipe` for TypeScript | The eight primitives. No dependencies | [packages/codeupipe-ts/README.md](packages/codeupipe-ts/README.md) |
| `codeupipe-lint` for TypeScript | A linter for pipeline code in TypeScript | [packages/codeupipe-lint-ts/README.md](packages/codeupipe-lint-ts/README.md) |
| `codeupipe-compile` for TypeScript | Writes a pipeline as plain TypeScript with no import of codeupipe | [packages/codeupipe-compile-ts/README.md](packages/codeupipe-compile-ts/README.md) |
| `codeupipe` for Rust | The primitives, 0.1.0. No dependencies. No compiler yet | [packages/codeupipe-rs/README.md](packages/codeupipe-rs/README.md) |
| `codeupipe` for Rust | The primitives, 0.1.0. No dependencies | [packages/codeupipe-rs/README.md](packages/codeupipe-rs/README.md) |
| `codeupipe-lint` for Rust | A linter for pipeline code in Rust, for the rules that the compiler does not check | [packages/codeupipe-lint-rs/README.md](packages/codeupipe-lint-rs/README.md) |
| `codeupipe-compile` for Rust | Writes a pipeline as plain Rust: a struct and functions, with no codeupipe | [packages/codeupipe-compile-rs/README.md](packages/codeupipe-compile-rs/README.md) |

## Install

Expand Down Expand Up @@ -208,6 +209,7 @@ An editable install needs pip 21.3 or later.
| `packages/codeupipe-compile-ts/` | The TypeScript compiler, with its tests |
| `packages/codeupipe-rs/` | The Rust runtime, with its tests and its examples |
| `packages/codeupipe-lint-rs/` | The Rust linter, with its tests. A Cargo workspace of its own |
| `packages/codeupipe-compile-rs/` | The Rust compiler, with its tests. A Cargo workspace of its own |
| `conformance/` | The contract ([API.md](conformance/API.md)), the cases, the runners, the benchmark |
| `tests/` | The tests for the two Python packages |
| `examples/pricing/` | The example, with its test in `tests/examples/` |
Expand Down
2 changes: 1 addition & 1 deletion conformance/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ map and fails the comparison.
| Run | `run` is sync. `run_async` is opt-in | One `run`. It returns a Promise. A step can be sync or async | `run` is sync, and `run_with_state` for the caller's State. No async run yet |
| Absent | `None` | `null` | `None` from `get`; `Value::Null` is a JSON null |
| Label of a step | `type(step).__name__` | `step.constructor.name` | The name of the step's type, from `std::any::type_name` |
| Compile | `codeupipe.compile` | `packages/codeupipe-compile-ts` | None yet |
| Compile | `codeupipe.compile` | `packages/codeupipe-compile-ts` | `packages/codeupipe-compile-rs`: a struct with one field for each key. No conformance target yet |
| Linter | `packages/codeupipe-lint` | `packages/codeupipe-lint-ts` | None yet. The compiler refuses several of the shapes that the linters find |
| A type of your own | Any object with `copy()` | `class Order implements PipelineData<Order>`, then `new Pipeline<Order>()`, `Filter<Order>` | `impl PipelineData for Order {}`, then `Pipeline<Order>`, `Filter<Order>` |

Expand Down
22 changes: 21 additions & 1 deletion docs/rust-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,26 @@ core, a dynamic step costs about 25 ns, and the dynamic run is faster than
compiled Python in four of the five scenarios. The compiler waits until a
real pipeline shows a need.

**Started (2026-10-28), as a struct and not a value type.** Hand-compiled
forms were measured against `Pipeline::run`, on the five scenarios, the
pricing example and a step of real text work. Plain functions on a Payload
(the shape that this plan first had in mind, with a `Value` in the module)
gain 1.1 to 1.7 times: about 10 ns a step. A static pipeline from generics
reaches the same with no compiler. The large gain is the data: with a struct
that has one field for each key, the pricing example runs in about 2 ns, and
work on text 3 times faster. So the first version of the compiler writes a
struct, and keeps the rest of this section's rules: the same output, a
refusal with the place, a codeupipe pipeline itself. It is in
`packages/codeupipe-compile-rs/` ([README](../packages/codeupipe-compile-rs/README.md)).
Not in it yet: the conformance target `rust:static`, and nested pipelines.

The next gain was measured by hand before it was built: the compiled code
reads the caller's text where it is, and copies only the text that no step
writes, so signup went from 3.1 to 5.9 times faster than `Pipeline::run`.
Computing only the keys that the caller keeps would gain more where an
output that nobody keeps is expensive. It waits for a real pipeline that
shows the need: [#25](https://github.com/orchestrate-solutions/codeupipe/issues/25).

### The value type in compiled code

Plain Python has `dict`, and plain TypeScript has `Map`. Plain Rust has no
Expand Down Expand Up @@ -537,7 +557,7 @@ correctness. The others are about form.
| 0 | Settle D1 to D10 | One review of this page |
| 1 | Core crate, example, README | About 600 lines with tests (TypeScript: 415 lines of source) |
| 2 | Runner, `run.py`, bench, CI, documents | About 400 lines, most of it the JSON reader and the `cup_ops` |
| 3 | Compiler and `rust:static`, if the benchmark says so | About 1,000 lines (TypeScript: 851 lines of source) |
| 3 | Compiler and `rust:static`. **Started**: the compiler, as a struct; `rust:static` not yet | About 1,000 lines (TypeScript: 851 lines of source). Written: 1,471 of source, 268 of tests |
| 4 | Linter. **Done** | About 1,200 lines (written: 2,060 of source with its comments, 950 of tests) |

Phases 1 and 2 are one release: `codeupipe` 0.1.0 for Rust, in the
Expand Down
63 changes: 63 additions & 0 deletions packages/codeupipe-compile-rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions packages/codeupipe-compile-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "codeupipe-compile"
version = "0.1.0"
edition = "2021"
rust-version = "1.75"
description = "Writes a codeupipe pipeline in Rust as plain Rust: a struct and functions, with no codeupipe."
license = "Apache-2.0"
repository = "https://github.com/orchestrate-solutions/codeupipe"
readme = "README.md"
keywords = ["pipeline", "filter", "payload", "compiler"]
# Not on crates.io yet. A version below 1.0 is not stable.
publish = false

[[bin]]
name = "codeupipe-compile"
path = "src/main.rs"

[dependencies]
codeupipe = { path = "../codeupipe-rs" }
# Lines and columns of the syntax tree, outside a procedural macro.
proc-macro2 = { version = "1.0.80", default-features = false, features = ["span-locations"] }
quote = { version = "1.0.35", default-features = false }
syn = { version = "2.0.60", default-features = false, features = ["full", "parsing", "printing", "clone-impls", "visit", "visit-mut"] }
prettyplease = "0.2.20"

# A workspace of its own, as the linter: the crates of the root workspace
# have no dependencies and build with no download.
[workspace]
177 changes: 177 additions & 0 deletions packages/codeupipe-compile-rs/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS
4 changes: 4 additions & 0 deletions packages/codeupipe-compile-rs/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
codeupipe
Copyright 2026 Orchestrate LLC

Licensed under the Apache License, Version 2.0. See LICENSE.
Loading
Loading