From b93f5d8390ce41c944a017e515ff2f8f5a4d2a0a Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 15:54:42 +0000 Subject: [PATCH 1/3] fix(ci): pin container digests, wrap deed line, sync FFI main.zig with template - build/container/Containerfile: pin both wolfi-base FROMs by digest (scripts/pin-container-digests.sh; digest resolved from cgr.dev). - Apodeixis.jl_chora.deed: break the container-templates directory entry between attributes so no line exceeds 998 octets. - src/interface/ffi/src/main.zig: bring up to the template's dupeZ helper (Allocator.dupeZ removed in Zig 0.17), matching tests/ffi_strings_test.sh. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_0136P7Zk4qddXgo6Xwsqn8iz --- Apodeixis.jl_chora.deed | 3 ++- build/container/Containerfile | 4 ++-- src/interface/ffi/src/main.zig | 30 ++++++++++++++++++++++++------ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Apodeixis.jl_chora.deed b/Apodeixis.jl_chora.deed index b6d0338d..10e34406 100644 --- a/Apodeixis.jl_chora.deed +++ b/Apodeixis.jl_chora.deed @@ -225,7 +225,8 @@ (directory :id "automation-unit-forge" :ply 3 :path ".machine_readable/scripts/forge" :description "Internal automation logic for project forge.") (directory :id "automation-unit-lifecycle" :ply 3 :path ".machine_readable/scripts/lifecycle" :description "Internal automation logic for project lifecycle.") (directory :id "automation-unit-verification" :ply 3 :path ".machine_readable/scripts/verification" :description "Internal automation logic for project verification."))) - (directory :id "container-templates" :ply 1 :path "build/container" :version "1.0.0" :description "Container templates for the stapeln container ecosystem. This directory\nprovides Podman-Chainguard-stapeln templates that are customised via\n`just container-init` or `just repo-init` during project bootstrap.\n\nAll files use {{PLACEHOLDER}} tokens that are substituted with project-\nspecific values during initialisation." :purpose "Provide a complete, security-first container deployment story for any\nRSR-compliant repository. The templates cover the full lifecycle:\nbuild, sign, verify, deploy, monitor, and govern." :overview "The stapeln container ecosystem comprises six tools:\n\nselur — Container orchestration with zero-copy IPC. Reads compose.toml.\ncerro-torre — Verified container packaging (.ctp bundles), Ed25519 signing.\nsvalinn — Policy-driven edge gateway (auth, rate limits, CORS, trust).\nvordr — Runtime monitoring (health, crashes, resources, logs).\nrokur — Secrets management (runtime injection, no baked secrets).\nk9-svc — Nickel deployment components (Kennel/Yard/Hunt trust levels)." + (directory :id "container-templates" :ply 1 :path "build/container" :version "1.0.0" :description "Container templates for the stapeln container ecosystem. This directory\nprovides Podman-Chainguard-stapeln templates that are customised via\n`just container-init` or `just repo-init` during project bootstrap.\n\nAll files use {{PLACEHOLDER}} tokens that are substituted with project-\nspecific values during initialisation." + :purpose "Provide a complete, security-first container deployment story for any\nRSR-compliant repository. The templates cover the full lifecycle:\nbuild, sign, verify, deploy, monitor, and govern." :overview "The stapeln container ecosystem comprises six tools:\n\nselur — Container orchestration with zero-copy IPC. Reads compose.toml.\ncerro-torre — Verified container packaging (.ctp bundles), Ed25519 signing.\nsvalinn — Policy-driven edge gateway (auth, rate limits, CORS, trust).\nvordr — Runtime monitoring (health, crashes, resources, logs).\nrokur — Secrets management (runtime injection, no baked secrets).\nk9-svc — Nickel deployment components (Kennel/Yard/Hunt trust levels)." :context ("https://stapeln.dev/ns/v1") (canonical-locations :build_pipeline "build/container/stapeln/ct-build.sh" :compose "build/container/stapeln/compose.toml" :compose_example "build/container/stapeln/compose.example.toml" :compose_portable "build/container/compose.yaml" :compose_portable_example "build/container/compose.example.yaml" :containerfile "build/container/Containerfile" :containerignore "build/container/.containerignore" :deployment "build/container/stapeln/deploy.k9.ncl" :entrypoint "build/container/entrypoint.sh" :gatekeeper "build/container/stapeln/.gatekeeper.yaml" :just_module "build/just/container.just" :manifest "build/container/stapeln/manifest.toml" :monitoring "build/container/stapeln/vordr.toml" :secrets_gate "build/container/stapeln/rokur.toml") :invariants ("Base images MUST be cgr.dev/chainguard/wolfi-base or cgr.dev/chainguard/static" "Container runtime is Podman — never Docker" "Containerfile — never Dockerfile" "All images run as non-root (appuser or project-specific user)" ".ctp bundles are signed with Ed25519 via cerro-torre" "Health endpoints (/health, /ready) must always be public (no auth)") diff --git a/build/container/Containerfile b/build/container/Containerfile index 691ec193..b00245f8 100644 --- a/build/container/Containerfile +++ b/build/container/Containerfile @@ -61,7 +61,7 @@ # chain integrity, e.g.: # FROM cgr.dev/chainguard/wolfi-base:latest@sha256: AS builder # (cerro-torre's .ctp signing in build/container/stapeln/ records the resolved digest.) -FROM cgr.dev/chainguard/wolfi-base:latest AS builder +FROM cgr.dev/chainguard/wolfi-base@sha256:1f6b749929164c3d9e7cad0289254f39b2ba51e1dddaeb0fa57532ea03f2db31 AS builder # TODO: Install your language toolchain RUN apk add --no-cache build-base @@ -79,7 +79,7 @@ COPY . . # Minimal production image. Only the compiled binary/release and runtime # dependencies are included. No compilers, no source code, no build tools. # -FROM cgr.dev/chainguard/wolfi-base:latest +FROM cgr.dev/chainguard/wolfi-base@sha256:1f6b749929164c3d9e7cad0289254f39b2ba51e1dddaeb0fa57532ea03f2db31 # OCI image labels (compatible with cerro-torre .ctp bundle metadata) LABEL org.opencontainers.image.title="Apodeixis.jl" \ diff --git a/src/interface/ffi/src/main.zig b/src/interface/ffi/src/main.zig index 6f4db637..9b8177d6 100644 --- a/src/interface/ffi/src/main.zig +++ b/src/interface/ffi/src/main.zig @@ -25,6 +25,16 @@ fn clearError() void { last_error = null; } +/// Duplicate a byte slice as a NUL-terminated buffer across Zig 0.15/0.16/0.17 +/// (`Allocator.dupeZ` was removed in Zig 0.17). +/// The caller owns the returned slice and must free it with `allocator`. +/// Propagates allocation failure. +fn dupeZ(allocator: std.mem.Allocator, bytes: []const u8) ![:0]u8 { + const buf = try allocator.allocSentinel(u8, bytes.len, 0); + @memcpy(buf[0..bytes.len], bytes); + return buf; +} + //============================================================================== // Core Types (must match src/abi/Types.idr) //============================================================================== @@ -110,7 +120,9 @@ export fn apodeixis_jl_process(handle: ?*Handle, input: u32) Result { //============================================================================== /// Get a string result (example) -/// Caller must free the returned string +/// Return a NUL-terminated "Example result" owned by the caller; free it with +/// `apodeixis_jl_free_string`. Return null and set the thread-local error for a +/// null or uninitialized handle, or allocation failure. Clear the error on success. export fn apodeixis_jl_get_string(handle: ?*Handle) ?[*:0]const u8 { const h = handle orelse { setError("Null handle"); @@ -123,7 +135,7 @@ export fn apodeixis_jl_get_string(handle: ?*Handle) ?[*:0]const u8 { } // Example: allocate and return a string - const result = h.allocator.dupeZ(u8, "Example result") catch { + const result = dupeZ(h.allocator, "Example result") catch { setError("Failed to allocate string"); return null; }; @@ -180,14 +192,15 @@ export fn apodeixis_jl_process_array( // Error Handling //============================================================================== -/// Get the last error message -/// Returns null if no error +/// Get the last error message. +/// Return an allocated NUL-terminated copy of the current thread's error, or +/// null if no error is set or allocation fails. Leave the stored error unchanged. +/// Caller must free a non-null returned string with `apodeixis_jl_free_string`. export fn apodeixis_jl_last_error() ?[*:0]const u8 { const err = last_error orelse return null; - // Return C string (static storage, no need to free) const allocator = std.heap.c_allocator; - const c_str = allocator.dupeZ(u8, err) catch return null; + const c_str = dupeZ(allocator, err) catch return null; return c_str.ptr; } @@ -258,6 +271,10 @@ test "lifecycle" { defer apodeixis_jl_free(handle); try std.testing.expect(apodeixis_jl_is_initialized(handle) == 1); + + const str = apodeixis_jl_get_string(handle) orelse return error.StringFailed; + defer apodeixis_jl_free_string(str); + try std.testing.expectEqualStrings("Example result", std.mem.span(str)); } test "error handling" { @@ -265,6 +282,7 @@ test "error handling" { try std.testing.expectEqual(Result.null_pointer, result); const err = apodeixis_jl_last_error(); + defer apodeixis_jl_free_string(err); try std.testing.expect(err != null); } From eba57b3b33a9c5420187db1a197e0cf0e0721688 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 16:00:23 +0000 Subject: [PATCH 2/3] fix(ci): add the hand-authored Proofs section to CLAUDE.md (template 48671ce) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests/workflows/governance_policy_test.sh reads '## Proofs — which prover for which obligation' from CLAUDE.md. In the template it is hand-authored text below the ARRIVAL-PACK:END marker, not part of the generated region, so the arrival pack is not the stale side and is left untouched. The text is copied from rsr-template-repo's CLAUDE.md; the generated region is byte-identical (verify.sh: in sync with the deed). Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_0136P7Zk4qddXgo6Xwsqn8iz --- CLAUDE.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index e64f889a..1eb6a8b9 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -124,3 +124,34 @@ hand; that migration is done per repo (ADR-008 phase P3). In deed files use **ENFORCEMENT:** these rulings are recorded on `standards#787`. Some are ruled but not yet gated: check the gate on `standards` main before relying on it. + +## Proofs — which prover for which obligation + +Normative source: `3-practice/PROOF-POLICY.adoc` in `hyperpolymath/standards`. +Read it there; `verification/proofs/README.adoc` maps it onto this repo. + +| Code or obligation | Verifier | +|---|---| +| Rust code | **Creusot** with **Pearlite** contracts, and **Verus**, by default and on the code (§1.2). Kani for `unsafe`/FFI seams and Aeneas for Rust that implements an Agda theorem run alongside, never instead | +| Ada code | **SPARK** | +| APIs, ABIs, engineering properties | **Idris2** | +| Theory | **Agda**, rechecked in **Rocq** and **Lean** (no Mathlib) | + +Always name Creusot, Pearlite and Verus in Rust verification plans and in +`docs/status/PROOF-STATUS.adoc`. Pearlite is Creusot's specification +language, not a third verifier. Plan scopes for both verifiers, and record +any that is unsupported, inapplicable or not yet run, with its reason; never +present an unexecuted check as a pass. Using both does not make two +independent witnesses (policy §1.2). + +Third-party code (crates such as Bevy, libraries, forks) is **not** converted +or re-proved. State what a proof relies on as an `ASSUMED` boundary +specification, and when choosing between dependencies that fit equally well, +prefer one that carries its own verification. A preference, not a gate. + +Proof grades are policy §8, *Proof Witness Grades*: `PWG-3` < `PWG-2i` < +`PWG-2ii` < `PWG-1`, where `PWG-1` is strongest. A grade is derived from +receipts, never asserted. A "verified" or "machine-checked" claim needs +current receipts. Report a census with its denominator, never a +percentage. Always write the `PWG-` prefix: CRG, TRG, ARG and FRG letters, +and ECHIDNA's `TrustLevel`, are different schemes. From 849f6e222d0b364273435136f7912d56e05b8d2a Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 16:00:54 +0000 Subject: [PATCH 3/3] revert(ci): drop changes owned by #15, #18 and #23 The owner chose #15 (deed line), #18 (main.zig dupeZ) and #23 (delete the Containerfile instead of pinning it). This PR keeps only the CLAUDE.md Proofs section, which no other open PR carries. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_0136P7Zk4qddXgo6Xwsqn8iz --- Apodeixis.jl_chora.deed | 3 +-- build/container/Containerfile | 4 ++-- src/interface/ffi/src/main.zig | 30 ++++++------------------------ 3 files changed, 9 insertions(+), 28 deletions(-) diff --git a/Apodeixis.jl_chora.deed b/Apodeixis.jl_chora.deed index 10e34406..b6d0338d 100644 --- a/Apodeixis.jl_chora.deed +++ b/Apodeixis.jl_chora.deed @@ -225,8 +225,7 @@ (directory :id "automation-unit-forge" :ply 3 :path ".machine_readable/scripts/forge" :description "Internal automation logic for project forge.") (directory :id "automation-unit-lifecycle" :ply 3 :path ".machine_readable/scripts/lifecycle" :description "Internal automation logic for project lifecycle.") (directory :id "automation-unit-verification" :ply 3 :path ".machine_readable/scripts/verification" :description "Internal automation logic for project verification."))) - (directory :id "container-templates" :ply 1 :path "build/container" :version "1.0.0" :description "Container templates for the stapeln container ecosystem. This directory\nprovides Podman-Chainguard-stapeln templates that are customised via\n`just container-init` or `just repo-init` during project bootstrap.\n\nAll files use {{PLACEHOLDER}} tokens that are substituted with project-\nspecific values during initialisation." - :purpose "Provide a complete, security-first container deployment story for any\nRSR-compliant repository. The templates cover the full lifecycle:\nbuild, sign, verify, deploy, monitor, and govern." :overview "The stapeln container ecosystem comprises six tools:\n\nselur — Container orchestration with zero-copy IPC. Reads compose.toml.\ncerro-torre — Verified container packaging (.ctp bundles), Ed25519 signing.\nsvalinn — Policy-driven edge gateway (auth, rate limits, CORS, trust).\nvordr — Runtime monitoring (health, crashes, resources, logs).\nrokur — Secrets management (runtime injection, no baked secrets).\nk9-svc — Nickel deployment components (Kennel/Yard/Hunt trust levels)." + (directory :id "container-templates" :ply 1 :path "build/container" :version "1.0.0" :description "Container templates for the stapeln container ecosystem. This directory\nprovides Podman-Chainguard-stapeln templates that are customised via\n`just container-init` or `just repo-init` during project bootstrap.\n\nAll files use {{PLACEHOLDER}} tokens that are substituted with project-\nspecific values during initialisation." :purpose "Provide a complete, security-first container deployment story for any\nRSR-compliant repository. The templates cover the full lifecycle:\nbuild, sign, verify, deploy, monitor, and govern." :overview "The stapeln container ecosystem comprises six tools:\n\nselur — Container orchestration with zero-copy IPC. Reads compose.toml.\ncerro-torre — Verified container packaging (.ctp bundles), Ed25519 signing.\nsvalinn — Policy-driven edge gateway (auth, rate limits, CORS, trust).\nvordr — Runtime monitoring (health, crashes, resources, logs).\nrokur — Secrets management (runtime injection, no baked secrets).\nk9-svc — Nickel deployment components (Kennel/Yard/Hunt trust levels)." :context ("https://stapeln.dev/ns/v1") (canonical-locations :build_pipeline "build/container/stapeln/ct-build.sh" :compose "build/container/stapeln/compose.toml" :compose_example "build/container/stapeln/compose.example.toml" :compose_portable "build/container/compose.yaml" :compose_portable_example "build/container/compose.example.yaml" :containerfile "build/container/Containerfile" :containerignore "build/container/.containerignore" :deployment "build/container/stapeln/deploy.k9.ncl" :entrypoint "build/container/entrypoint.sh" :gatekeeper "build/container/stapeln/.gatekeeper.yaml" :just_module "build/just/container.just" :manifest "build/container/stapeln/manifest.toml" :monitoring "build/container/stapeln/vordr.toml" :secrets_gate "build/container/stapeln/rokur.toml") :invariants ("Base images MUST be cgr.dev/chainguard/wolfi-base or cgr.dev/chainguard/static" "Container runtime is Podman — never Docker" "Containerfile — never Dockerfile" "All images run as non-root (appuser or project-specific user)" ".ctp bundles are signed with Ed25519 via cerro-torre" "Health endpoints (/health, /ready) must always be public (no auth)") diff --git a/build/container/Containerfile b/build/container/Containerfile index b00245f8..691ec193 100644 --- a/build/container/Containerfile +++ b/build/container/Containerfile @@ -61,7 +61,7 @@ # chain integrity, e.g.: # FROM cgr.dev/chainguard/wolfi-base:latest@sha256: AS builder # (cerro-torre's .ctp signing in build/container/stapeln/ records the resolved digest.) -FROM cgr.dev/chainguard/wolfi-base@sha256:1f6b749929164c3d9e7cad0289254f39b2ba51e1dddaeb0fa57532ea03f2db31 AS builder +FROM cgr.dev/chainguard/wolfi-base:latest AS builder # TODO: Install your language toolchain RUN apk add --no-cache build-base @@ -79,7 +79,7 @@ COPY . . # Minimal production image. Only the compiled binary/release and runtime # dependencies are included. No compilers, no source code, no build tools. # -FROM cgr.dev/chainguard/wolfi-base@sha256:1f6b749929164c3d9e7cad0289254f39b2ba51e1dddaeb0fa57532ea03f2db31 +FROM cgr.dev/chainguard/wolfi-base:latest # OCI image labels (compatible with cerro-torre .ctp bundle metadata) LABEL org.opencontainers.image.title="Apodeixis.jl" \ diff --git a/src/interface/ffi/src/main.zig b/src/interface/ffi/src/main.zig index 9b8177d6..6f4db637 100644 --- a/src/interface/ffi/src/main.zig +++ b/src/interface/ffi/src/main.zig @@ -25,16 +25,6 @@ fn clearError() void { last_error = null; } -/// Duplicate a byte slice as a NUL-terminated buffer across Zig 0.15/0.16/0.17 -/// (`Allocator.dupeZ` was removed in Zig 0.17). -/// The caller owns the returned slice and must free it with `allocator`. -/// Propagates allocation failure. -fn dupeZ(allocator: std.mem.Allocator, bytes: []const u8) ![:0]u8 { - const buf = try allocator.allocSentinel(u8, bytes.len, 0); - @memcpy(buf[0..bytes.len], bytes); - return buf; -} - //============================================================================== // Core Types (must match src/abi/Types.idr) //============================================================================== @@ -120,9 +110,7 @@ export fn apodeixis_jl_process(handle: ?*Handle, input: u32) Result { //============================================================================== /// Get a string result (example) -/// Return a NUL-terminated "Example result" owned by the caller; free it with -/// `apodeixis_jl_free_string`. Return null and set the thread-local error for a -/// null or uninitialized handle, or allocation failure. Clear the error on success. +/// Caller must free the returned string export fn apodeixis_jl_get_string(handle: ?*Handle) ?[*:0]const u8 { const h = handle orelse { setError("Null handle"); @@ -135,7 +123,7 @@ export fn apodeixis_jl_get_string(handle: ?*Handle) ?[*:0]const u8 { } // Example: allocate and return a string - const result = dupeZ(h.allocator, "Example result") catch { + const result = h.allocator.dupeZ(u8, "Example result") catch { setError("Failed to allocate string"); return null; }; @@ -192,15 +180,14 @@ export fn apodeixis_jl_process_array( // Error Handling //============================================================================== -/// Get the last error message. -/// Return an allocated NUL-terminated copy of the current thread's error, or -/// null if no error is set or allocation fails. Leave the stored error unchanged. -/// Caller must free a non-null returned string with `apodeixis_jl_free_string`. +/// Get the last error message +/// Returns null if no error export fn apodeixis_jl_last_error() ?[*:0]const u8 { const err = last_error orelse return null; + // Return C string (static storage, no need to free) const allocator = std.heap.c_allocator; - const c_str = dupeZ(allocator, err) catch return null; + const c_str = allocator.dupeZ(u8, err) catch return null; return c_str.ptr; } @@ -271,10 +258,6 @@ test "lifecycle" { defer apodeixis_jl_free(handle); try std.testing.expect(apodeixis_jl_is_initialized(handle) == 1); - - const str = apodeixis_jl_get_string(handle) orelse return error.StringFailed; - defer apodeixis_jl_free_string(str); - try std.testing.expectEqualStrings("Example result", std.mem.span(str)); } test "error handling" { @@ -282,7 +265,6 @@ test "error handling" { try std.testing.expectEqual(Result.null_pointer, result); const err = apodeixis_jl_last_error(); - defer apodeixis_jl_free_string(err); try std.testing.expect(err != null); }