Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
harden(build): pin --locked in release/docker/install + guard strict-schema drift (#628)
AkitaOnRailsd492ee50446b
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex aa9da971..99e1837b 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -85,7 +85,7 @@ jobs:- name: Build release binaryenv:TAILWIND_SKIP: "1"- run: cargo build --release -p ai-memory-cli+ run: cargo build --locked --release -p ai-memory-cli- name: Create release tarballenv:@@ -142,7 +142,7 @@ jobs:- name: Build release binaryenv:TAILWIND_SKIP: "1"- run: cargo build --release -p ai-memory-cli+ run: cargo build --locked --release -p ai-memory-cli# Mirrors the Linux tarball, swapping the Linux-only service assets# (packaging/systemd|sysusers|tmpfiles|env) for the macOS-only@@ -216,7 +216,7 @@ jobs:- name: Build release binaryenv:TAILWIND_SKIP: "1"- run: cargo build --release -p ai-memory-cli+ run: cargo build --locked --release -p ai-memory-cli# Mirrors the Linux tarball, minus the Linux-only service assets# (packaging/systemd|sysusers|tmpfiles|env). Ships the `.exe`, the full@@ -549,7 +549,7 @@ jobs:echo "# extract it, and follow the bundled docs/windows.md." >> body.mdecho "" >> body.mdecho "# From source" >> body.md- echo "cargo install --git https://github.com/akitaonrails/ai-memory --tag ${GITHUB_REF_NAME}" >> body.md+ echo "cargo install --locked --git https://github.com/akitaonrails/ai-memory --tag ${GITHUB_REF_NAME}" >> body.mdecho '```' >> body.md- name: Create GitHub Releasediff --git a/CHANGELOG.md b/CHANGELOG.mdindex 6a1d6792..158469ae 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]### Changed+- Release, Docker, and the `cargo install --git` snippet now build with+ `--locked` (#628). Without it `cargo install` re-resolves dependencies and+ ignores the committed `Cargo.lock`, so a source install could silently pull+ a different `schemars` than the one tested — a plausible source of+ build-to-build structured-output schema drift. A unit guard also asserts the+ strict-schema normalizer keeps `required` equal to `properties` (and closes+ open maps), catching that drift class at build time rather than in+ production.- The `_pending/auto-improve/` sidecar no longer renders a `status:` line(#624). It was written once at staging and could never change from`pending` — no code path updates or garbage-collects the sidecar — so itdiff --git a/crates/ai-memory-llm/src/openai.rs b/crates/ai-memory-llm/src/openai.rsindex e8b9304e..0d89ffe2 100644--- a/crates/ai-memory-llm/src/openai.rs+++ b/crates/ai-memory-llm/src/openai.rs@@ -716,6 +716,79 @@ mod tests {assert_eq!(names.len(), 3);}+ /// Recursively assert every object node an enforced schema produces has+ /// `additionalProperties: false` and a `required` array that is exactly+ /// its `properties` keys — no key in `required` that `properties` lacks.+ fn assert_strict_invariant(node: &serde_json::Value) {+ if let Some(map) = node.as_object() {+ if map.contains_key("$ref") {+ return;+ }+ if let Some(props) = map.get("properties").and_then(|p| p.as_object()) {+ assert_eq!(+ map.get("additionalProperties"),+ Some(&json!(false)),+ "every object must set additionalProperties:false; got {map:?}"+ );+ let required: std::collections::BTreeSet<&str> = map+ .get("required")+ .and_then(|r| r.as_array())+ .into_iter()+ .flatten()+ .filter_map(|v| v.as_str())+ .collect();+ let keys: std::collections::BTreeSet<&str> =+ props.keys().map(String::as_str).collect();+ assert_eq!(+ required, keys,+ "required must equal properties keys (the #628 drift symptom is required \+ carrying a key properties lacks)"+ );+ }+ for v in map.values() {+ assert_strict_invariant(v);+ }+ } else if let Some(items) = node.as_array() {+ for v in items {+ assert_strict_invariant(v);+ }+ }+ }++ /// #628 guard: a `BTreeMap`-typed field (schemars emits+ /// `additionalProperties: {schema}`, an open map) is normalized to+ /// `additionalProperties: false`, NOT recursed into. OpenAI strict mode+ /// forbids open/arbitrary-key maps — emitting `additionalProperties:{schema}`+ /// would 400 on every strict provider. This test pins that behavior so the+ /// map value-schema is never "revived": the correct way to make a map field+ /// model-producible under strict mode is a fixed-shape array of objects, not+ /// an open map.+ #[test]+ fn enforce_strict_closes_open_maps_and_keeps_required_consistent() {+ // Shape mirrors ConsolidatedPage: scalar fields plus a `relations`+ // BTreeMap<String, Vec<String>> rendered as an open map.+ let mut schema = json!({+ "type": "object",+ "properties": {+ "title": { "type": "string" },+ "body_markdown": { "type": "string" },+ "relations": {+ "type": "object",+ "additionalProperties": { "type": "array", "items": { "type": "string" } }+ }+ }+ });+ enforce_strict_object_schemas(&mut schema);+ // The map field is closed, not preserved as an open map.+ assert_eq!(+ schema["properties"]["relations"]["additionalProperties"],+ json!(false),+ "an open map must be closed for strict mode, not left as additionalProperties:{{schema}}"+ );+ // And the whole schema satisfies the strict invariant end to end.+ assert_strict_invariant(&schema);+ }+#[test]fn enforce_strict_overwrites_incomplete_required() {// OpenAI strict mode rejects partial `required` arrays — even andiff --git a/docker/Dockerfile b/docker/Dockerfileindex f73c87c6..8207b461 100644--- a/docker/Dockerfile+++ b/docker/Dockerfile@@ -28,7 +28,7 @@ COPY evals ./evalsCOPY docs ./docsRUN --mount=type=cache,target=/usr/local/cargo/registry \--mount=type=cache,target=/work/target \- TAILWIND_SKIP=1 cargo build --release -p ai-memory-cli \+ TAILWIND_SKIP=1 cargo build --locked --release -p ai-memory-cli \&& cp target/release/ai-memory /usr/local/bin/ai-memoryFROM debian:bookworm-slim AS runtime-base