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
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
xtask = "run --package xtask --"
46 changes: 46 additions & 0 deletions .github/workflows/format-gate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Format gate

# The IR format gate's checks that look at the repository (core#268): the
# seal of every superseded format (core/formats/MANIFEST), and, on a pull
# request, what the change to the format has to come with: a bump of
# CURRENT_IR_FORMAT_VERSION needs its step, its directory, the previous
# format's seal and fixtures; moved golden hashes
# (core/tests/migrations/expected) need a ledger row. See `cargo xtask`.
#
# The tests that need a build (`live == frozen(current)`, the golden fresh
# build) are core's own tests, in the Cargo Build & Test workflow.
on:
push:
branches: [master]
pull_request:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
format_gate:
name: Format gate
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# The merge base with the pull request's base.
fetch-depth: 0
persist-credentials: false
- name: The seals, and what a change to the format comes with
env:
BASE: ${{ github.event.pull_request.base.sha }}
run: |
if [ -n "$BASE" ]; then
cargo xtask check-format-bump --base "$BASE"
else
cargo xtask check-format-bump
fi
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ resolver = "2"
members = [
"core",
"core_stdlib",
"xtask",
]

[profile.release]
Expand Down
7 changes: 7 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ exclude = ["benches/benchmark_results.html", "benches/run_bench.sh", "fuzz/", "o
[dependencies]
# The embedded standard library (`use std::…`)
comline-core-stdlib = { path = "../core_stdlib", version = "0.1.0" }
# The IR formats stored under `.comline/`, frozen: what an older store is
# decoded with, and what the live types are held to. In the IR-only build too.
comline-ir-formats = { path = "formats" }
# The specification's catalog of shared names: guarantees, facts and their
# values, the official encodings' aliases and frozen spellings. no_std and
# dependency-free, so the IR-only build has it too.
Expand Down Expand Up @@ -100,6 +103,10 @@ iai-callgrind = "=0.16.1"
# crate. Exact pin on proptest, like iai-callgrind.
proptest = "=1.5.0"
comline-core-oracle = { path = "oracle", features = ["proptest"] }
# `live == frozen(current)` over values no real build produces
# (tests/migrations/live_frozen.rs).
comline-ir-formats = { path = "formats", features = ["arbitrary"] }
arbitrary = "1"

[[bench]]
name = "parser_benchmark"
Expand Down
30 changes: 30 additions & 0 deletions core/formats/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "comline-ir-formats"
version = "0.0.0"
edition = "2021"
license = "GPL-3.0-only"
publish = false
rust-version = "1.82"
description = "The IR formats comline has stored under .comline/, frozen: types, codec, document and ledger of each (core#268)"

# Internal, never published at first. One module per format (`v3`), each with
# its `SCHEMA.md`, the frozen copies of its types, its codec and its ledger.
# It has no dependency on `comline-core`, the way the oracle has none, so that
# a frozen type can't reach for today's: core depends on it to read old
# stores, and tests that `live == frozen(current)`. Its dependencies are what
# the IR-only (`wasm`) build carries; it never writes a store. See
# SCHEMA.md in each module and `formats/MANIFEST`.

[features]
# `Arbitrary` for the frozen types, for core's `live == frozen` test over
# values no real build produces.
arbitrary = ["dep:arbitrary"]

[dependencies]
serde = "1.0.164"
serde_derive = "1.0.164"
ciborium = "0.2"
arbitrary = { version = "1", features = ["derive"], optional = true }

[dev-dependencies]
toml = "0.8"
5 changes: 5 additions & 0 deletions core/formats/MANIFEST
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# The seal of each superseded IR format (core#268): the blake3 of its
# directory under src/, over every file's relative path and bytes in path
# order. `cargo xtask check-seal` fails when one differs; a format is sealed
# when the next is introduced, with `cargo xtask seal-format <N> --why <text>`,
# which is also the only way to move a seal.
17 changes: 17 additions & 0 deletions core/formats/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//! The IR formats comline has stored under `.comline/`, frozen (core#268).
//!
//! One module per format, `v<N>`, each with its `SCHEMA.md`, `types`, `codec`
//! and `ledger.toml`. Nothing here depends on `comline-core`: a frozen type
//! can't reach for today's. Reading only; nothing in this crate writes a
//! store.
//!
//! A format is held in place by the gate (core#268, step 1.2): the current
//! one by core's `live == frozen(current)` test, and one that a later format
//! superseded by its seal in `formats/MANIFEST`.

pub mod v3;

/// The newest format this crate holds. Core's `CURRENT_IR_FORMAT_VERSION`
/// is tested to be this number: a bump that doesn't add the format here
/// fails.
pub const CURRENT: u32 = v3::FORMAT;
Loading
Loading