Skip to content

Commit 9734054

Browse files
committed
Improve strict sync-eval caching and harden primitive semantics
- fix strict cache root eviction so cached graphs do not accumulate after LRU eviction - harden strict sync-eval caching with loader/env reuse and cache/overlay cleanup - extract cache and overlay machinery into a dedicated module to simplify runtime structure - broaden sync predicate and digest primitive behavior for byte-vectors and refresh help text - add focused primitive integration tests and update the package version to 1.1.3
1 parent c0c2072 commit 9734054

12 files changed

Lines changed: 1932 additions & 609 deletions

File tree

.github/workflows/all.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ jobs:
1515
runs-on: ubuntu-latest
1616
permissions: write-all
1717
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
1820
- name: Install dependencies
1921
run: |
2022
sudo apt update
2123
sudo apt install -y llvm-dev libclang-dev clang
2224
- name: Install rust
2325
uses: moonrepo/setup-rust@v1
24-
- name: Checkout code
25-
uses: actions/checkout@v4
26+
- name: Cache Rust build artifacts
27+
uses: Swatinem/rust-cache@v2
2628
- name: Build project
2729
run: cargo build
2830
- name: Test project
@@ -65,6 +67,8 @@ jobs:
6567
push: false
6668
load: false
6769
tags: ghcr.io/${{ github.repository }}/journal-sdk:ci
70+
cache-from: type=gha,scope=journal-sdk-docker
71+
cache-to: type=gha,mode=max,scope=journal-sdk-docker
6872
- name: Build and push multi-arch Docker images
6973
if: github.ref == 'refs/heads/main'
7074
uses: docker/build-push-action@v6
@@ -77,3 +81,5 @@ jobs:
7781
ghcr.io/${{ github.repository }}/journal-sdk:${{ steps.version.outputs.value }}
7882
labels: |
7983
org.opencontainers.image.source=https://github.com/${{ github.repository }}
84+
cache-from: type=gha,scope=journal-sdk-docker
85+
cache-to: type=gha,mode=max,scope=journal-sdk-docker

CHANGELOG

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
The purpose of this changelog is to document new features and breaking changes that are most likely to affect developers
33
------------------------------------------------------------------------------------------------------------------------
44

5+
--- v1.2.0 (2026.03.29) ---
6+
7+
- Fix strict sync-eval cache root eviction so cached graphs do not accumulate after LRU eviction
8+
- Reuse strict sync-eval state more efficiently and split cache/overlay code into a dedicated module
9+
- Allow `sync-null?`, `sync-pair?`, `sync-stub?`, and `sync-digest` to operate cleanly on byte-vectors
10+
- Add primitive integration sanity tests and refresh primitive help text
11+
- Remove stale profiling/debug instrumentation after validating cache behavior
12+
513
--- v1.1.0 (2026.03.08) ---
614

715
- Add `system-time-utc` and `system-time-unix` primitives for UTC/unix conversion

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "journal-sdk"
3-
version = "1.1.2"
3+
version = "1.2.0"
44
edition = "2024"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -28,6 +28,7 @@ sha2 = "0.10.8"
2828
libc = "0.2"
2929
log = "0.4.21"
3030
env_logger = "0.10"
31+
lru = "0.12.5"
3132
crystals-dilithium = "1.0.0"
3233
pqcrypto = "0.17.0"
3334
tokio = { version = "1.0", features = ["time", "rt", "rt-multi-thread", "macros"] }

Dockerfile

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# --- Build ---
1+
# syntax=docker/dockerfile:1.7
22

3-
FROM alpine:3.23.3 AS builder
3+
# --- Build base ---
4+
5+
FROM alpine:3.23.3 AS chef
46

57
ARG RUST_LOG=info
68
ARG CUSTOM_SETUP=""
@@ -17,19 +19,50 @@ RUN set -eu; \
1719
rm -f /tmp/custom-setup.sh; \
1820
fi
1921

20-
# Install OS dependencies
21-
RUN apk update
22-
RUN apk add cargo
23-
RUN apk add clang
24-
RUN apk add clang-dev
25-
RUN apk add openssl-dev
26-
RUN apk add build-base
27-
RUN apk add linux-headers
22+
RUN apk update && apk add --no-cache \
23+
build-base \
24+
cargo \
25+
clang \
26+
clang-dev \
27+
linux-headers \
28+
openssl-dev
29+
30+
RUN --mount=type=cache,target=/root/.cargo/registry \
31+
--mount=type=cache,target=/root/.cargo/git \
32+
cargo install cargo-chef --locked
2833

29-
# Build SDK
3034
WORKDIR /srv
31-
COPY . .
32-
RUN cargo build --release
35+
36+
# --- Dependency planning ---
37+
38+
FROM chef AS planner
39+
40+
COPY . .
41+
42+
RUN cargo chef prepare --recipe-path recipe.json
43+
44+
# --- Dependency build ---
45+
46+
FROM chef AS cacher
47+
48+
COPY --from=planner /srv/recipe.json recipe.json
49+
50+
RUN --mount=type=cache,target=/root/.cargo/registry \
51+
--mount=type=cache,target=/root/.cargo/git \
52+
--mount=type=cache,target=/srv/target \
53+
cargo chef cook --release --recipe-path recipe.json
54+
55+
# --- Application build ---
56+
57+
FROM chef AS builder
58+
59+
COPY . .
60+
61+
RUN --mount=type=cache,target=/root/.cargo/registry \
62+
--mount=type=cache,target=/root/.cargo/git \
63+
--mount=type=cache,target=/srv/target \
64+
cargo build --release && \
65+
cp /srv/target/release/journal-sdk /tmp/journal-sdk
3366

3467
# --- Deploy ---
3568

@@ -48,7 +81,7 @@ RUN set -eu; \
4881

4982
COPY --from=builder /usr/lib/libgcc_s.so.1 /usr/lib/
5083
COPY --from=builder /usr/lib/libstdc++.so.6* /usr/lib/
51-
COPY --from=builder /srv/target/release/journal-sdk .
84+
COPY --from=builder /tmp/journal-sdk ./journal-sdk
5285

5386
ENTRYPOINT ["./journal-sdk"]
5487

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,14 @@ There is only one structural constraint on the form of the record: for a record
9090

9191
`(lambda (*sync-state* query) (cons ... *sync-state*))`
9292

93-
The `*sync-state*` parameter is the root node of the record while the `query` parameter is the expression provided through the `/interface` endpoint.
94-
The function returns a Scheme pair where the first item is the response to the `/inferface` call and the second item is the new root node.
93+
At request time, the journal supplies the current record root as the `*sync-state*` argument and also exposes `(sync-state)` as a primitive that returns the current session root as a `sync-node`.
94+
The `query` parameter is the expression provided through the `/interface` endpoint.
95+
The function returns a Scheme pair where the first item is the response to the `/interface` call and the second item is the new root node.
9596
For example, the default function is the following:
9697

9798
`(lambda (*sync-state* query) (cons (eval query) *sync-state*))`
9899

99-
This function simply evaluates any user query.
100+
This function simply evaluates any user query against the current state binding.
100101
From this highly generic and permissive functionality, it is possible to construct arbitrarily specific and controlled interfaces.
101102
The [./lisp](./lisp) folder provides some examples.
102103

lisp/state.scm

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)