Skip to content

Grahamc/init pullout - #1

Merged
grahamc merged 15 commits into
mainfrom
grahamc/init-pullout
Aug 4, 2026
Merged

Grahamc/init pullout#1
grahamc merged 15 commits into
mainfrom
grahamc/init-pullout

Conversation

@grahamc

@grahamc grahamc commented Aug 4, 2026

Copy link
Copy Markdown
Member

Types pulled out of our internal cache service.

Summary by CodeRabbit

  • New Features
    • Added utilities for parsing, validating, serializing, and generating SHA-256 hashes.
    • Added validated Nix store path and store path hash types.
    • Added structured error handling for invalid paths, hashes, provenance, I/O, and C++ failures.
    • Added Rust crate packaging, documentation, optional C++ interoperability, and development tooling.
  • Documentation
    • Added usage, installation, development, licensing, and provenance guidance.
  • Chores
    • Added formatting standards, dependency update configuration, security checks, and cross-platform CI validation.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The pull request creates the flakehub-cache-types Rust crate. It adds hash and Nix store types, structured errors, serialization, validation tests, a Nix flake, development tooling, and CI automation.

Changes

Crate and project infrastructure

Layer / File(s) Summary
Crate API and error contracts
Cargo.toml, src/lib.rs, src/error.rs, README.md
Defines crate metadata, lint policies, public modules, StoreError, StoreResult, optional cxx support, and usage documentation.
Hash parsing and serialization
src/hash/*, src/hash/tests/*
Adds SHA-256 hashing, typed hash parsing, hexadecimal and Nix Base32 encoding, Serde support, structured errors, and fixture-backed tests.
Nix store path validation
src/nix_store/*
Adds StorePath, StorePathHash, ValidPathInfo, validation constructors, serialization, accessors, base-name extraction, and validation tests.
Development and repository automation
.editorconfig, .envrc, .gitignore, deny.toml, flake.nix, .github/*
Adds formatting rules, Nix development configuration, dependency policy, reproducible builds, development shells, CI checks, Dependabot updates, and flake-lock validation.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title indicates a pullout but does not identify the extracted cache types or repository.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 23-27: Replace all action references in the workflow
(actions/checkout, DeterminateSystems/nix-installer-action,
DeterminateSystems/flakehub-cache-action, and flake-checker-action) with their
full immutable commit SHAs instead of version tags or branch names like v4 or
main. Add a comment above each uses statement documenting the action name and
version being pinned, since this workflow has elevated permissions (id-token:
write) and requires security-reviewed immutable references.
- Around line 9-11: Update the flake-checker job permissions in the CI workflow
to remove id-token: write, leaving only contents: read. Preserve the OIDC
permission for the checks and cargo-deny jobs where flakehub-cache-action
requires it.

In `@README.md`:
- Around line 7-10: Update the README API summary so StoreError and StoreResult
are described only as errors for Nix store-path operations, and add hash::Error
as the parsing error returned by Hash::from_typed. Keep the existing Hash
description while listing its error type separately.

In `@src/nix_store/mod.rs`:
- Around line 270-276: Update the store-path parsing helper around the existing
STORE_PATH_HASH_LEN check to validate first with StorePath::from_base_name,
rejecting names such as a 32-character hash followed by “-foo@” with
InvalidStorePath instead of returning PathBuf directly. Preserve the existing
short-path error behavior and add a regression test covering this invalid base
name.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1dde4185-eb96-4d95-ac05-9fba3fc1154a

📥 Commits

Reviewing files that changed from the base of the PR and between 3a79ad9 and 7ab605f.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (17)
  • .editorconfig
  • .envrc
  • .github/dependabot.yml
  • .github/workflows/ci.yml
  • .github/workflows/release.yml
  • .gitignore
  • Cargo.toml
  • README.md
  • deny.toml
  • flake.nix
  • src/error.rs
  • src/hash/mod.rs
  • src/hash/tests/.gitattributes
  • src/hash/tests/blob
  • src/hash/tests/mod.rs
  • src/lib.rs
  • src/nix_store/mod.rs

Comment thread .github/workflows/ci.yml Outdated
Comment on lines +9 to +11
permissions:
contents: read
id-token: write

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- workflow ---'
cat -n .github/workflows/ci.yml
printf '%s\n' '--- OIDC and permission references ---'
rg -n -C 3 'id-token|permissions:|DeterminateSystems/flake-checker-action|uses:' .github/workflows/ci.yml
printf '%s\n' '--- repository workflow context ---'
rg -n -C 2 'id-token|aws-actions|azure|google-github-actions|vault|OIDC|oidc|secrets|environment:' .github/workflows .github 2>/dev/null || true

Repository: DeterminateSystems/flakehub-cache-types

Length of output: 3745


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- release workflow ---'
cat -n .github/workflows/release.yml
printf '%s\n' '--- all workflow permissions and referenced actions ---'
for f in .github/workflows/*.yml .github/workflows/*.yaml; do
  [ -f "$f" ] || continue
  printf '\n--- %s ---\n' "$f"
  rg -n -C 2 'permissions:|id-token|uses:' "$f"
done

Repository: DeterminateSystems/flakehub-cache-types

Length of output: 3212


🌐 Web query:

DeterminateSystems flakehub-cache-action GitHub Actions id-token write OIDC requirement

💡 Result:

The Determinate Systems flakehub-cache-action requires the id-token: write permission in your GitHub Actions workflow configuration to authenticate with FlakeHub Cache [1][2][3]. This requirement exists because FlakeHub Cache uses OpenID Connect (OIDC) to securely authenticate your GitHub Actions runner with the FlakeHub service [3]. By setting id-token: write, you grant the workflow the ability to request a JSON Web Token (JWT) from GitHub’s OIDC provider, which FlakeHub then validates to authorize the action [3][4][5]. In your GitHub Actions YAML file, you must include a permissions block within the relevant job [1][3]. The standard configuration recommended by Determinate Systems is [1][6]: permissions: id-token: write contents: read If this permission is omitted or improperly configured, the action will be unable to authenticate, typically resulting in a failure or a warning that FlakeHub Cache is disabled [1][7][8]. Additionally, note that FlakeHub Cache authentication via OIDC is generally not available for pull requests originating from forks of your repository, as the GitHub-provided JWTs in those contexts do not contain the necessary claims for this specific authentication model [3].

Citations:


🌐 Web query:

DeterminateSystems flake-checker-action GitHub Actions permissions id-token OIDC

💡 Result:

The Determinate Systems flake-checker-action does not explicitly require OpenID Connect (OIDC) permissions for its primary function of performing health checks on flake.lock files [1][2][3]. However, it is common to see the id-token: write permission enabled in GitHub Actions workflows that use multiple Determinate Systems actions—such as the flakehub-cache-action—because these actions often work together in a CI pipeline [2][4][5]. OIDC (OpenID Connect) permissions are required by GitHub Actions when an action needs to request a JSON Web Token (JWT) to authenticate with external services (e.g., cloud providers like AWS or specialized services like FlakeHub) [6][7][8]. If your workflow only uses flake-checker-action to validate flake.lock files, you generally do not need to grant id-token permissions. You only need to include: permissions: contents: read If you are using it alongside other actions that require authentication (like those interacting with FlakeHub or other OIDC-protected resources), you will need to include the following in your job or workflow configuration [2][6]: permissions: contents: read id-token: write The id-token: write permission is strictly for allowing the workflow to request a JWT; it does not grant the action write access to your repository contents or other restricted resources [6].

Citations:


Security Misconfiguration (CWE-269): Improper Privilege Management

Reachability: External · Exploitability: Difficult

Remove OIDC permission from flake-checker.

flakehub-cache-action requires id-token: write in checks and cargo-deny, but flake-checker does not. Set flake-checker permissions to contents: read.

🧰 Tools
🪛 zizmor (1.28.0)

[error] 11-11: overly broad permissions (excessive-permissions): id-token: write is overly broad at the workflow level

(excessive-permissions)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 9 - 11, Update the flake-checker job
permissions in the CI workflow to remove id-token: write, leaving only contents:
read. Preserve the OIDC permission for the checks and cargo-deny jobs where
flakehub-cache-action requires it.

Source: Linters/SAST tools

Comment thread .github/workflows/ci.yml
Comment on lines +23 to +27
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
with:
determinate: true
- uses: DeterminateSystems/flakehub-cache-action@main

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- workflow ---'
cat -n .github/workflows/ci.yml
printf '%s\n' '--- action references and permission settings ---'
rg -n 'uses:|permissions:|id-token:|contents:' .github/workflows/ci.yml

Repository: DeterminateSystems/flakehub-cache-types

Length of output: 2272


🏁 Script executed:

#!/bin/bash
set -eu
cat -n .github/workflows/ci.yml
rg -n 'uses:|permissions:|id-token:|contents:' .github/workflows/ci.yml

Repository: DeterminateSystems/flakehub-cache-types

Length of output: 2205


Security Misconfiguration (CWE-829): Inclusion of Functionality from Untrusted Control Sphere

Reachability: External · Exploitability: Difficult

Pin all GitHub Actions to immutable commit SHAs.

This workflow grants id-token: write at lines 9–11. Pin every uses: reference, including actions/checkout, the DeterminateSystems actions, and flake-checker-action, to a reviewed full commit SHA. Document each action version in a comment.

🧰 Tools
🪛 zizmor (1.28.0)

[warning] 23-23: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 23 - 27, Replace all action references
in the workflow (actions/checkout, DeterminateSystems/nix-installer-action,
DeterminateSystems/flakehub-cache-action, and flake-checker-action) with their
full immutable commit SHAs instead of version tags or branch names like v4 or
main. Add a comment above each uses statement documenting the action name and
version being pinned, since this workflow has elevated permissions (id-token:
write) and requires security-reviewed immutable references.

Comment thread README.md Outdated
Comment thread src/nix_store/mod.rs Outdated
cole-h
cole-h previously approved these changes Aug 4, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/nix_store/tests.rs (1)

5-48: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the store-directory boundary case.

to_base_name has a separate error path when path is /nix/store itself. Add a test that asserts InvalidStorePath { reason: "Path is store directory itself", .. }. This protects the empty-relative-path validation branch.

Proposed test
+#[test]
+fn test_to_base_name_is_store_directory() {
+    let e = to_base_name(Path::new(STORE_DIR), Path::new(STORE_DIR)).unwrap_err();
+
+    assert!(matches!(
+        e,
+        StoreError::InvalidStorePath {
+            reason: "Path is store directory itself",
+            ..
+        }
+    ));
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/nix_store/tests.rs` around lines 5 - 48, Add a test alongside the
existing to_base_name tests that calls to_base_name with STORE_DIR itself as the
path and asserts StoreError::InvalidStorePath with reason "Path is store
directory itself".
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/nix_store/tests.rs`:
- Around line 5-48: Add a test alongside the existing to_base_name tests that
calls to_base_name with STORE_DIR itself as the path and asserts
StoreError::InvalidStorePath with reason "Path is store directory itself".

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 612634a4-48b9-4dc0-89b6-d3f3c7c196d9

📥 Commits

Reviewing files that changed from the base of the PR and between 4cc9be3 and fbebd18.

📒 Files selected for processing (5)
  • .github/workflows/ci.yml
  • Cargo.toml
  • README.md
  • src/nix_store/mod.rs
  • src/nix_store/tests.rs
🚧 Files skipped from review as they are similar to previous changes (4)
  • README.md
  • Cargo.toml
  • .github/workflows/ci.yml
  • src/nix_store/mod.rs

@grahamc
grahamc merged commit 0b0dd35 into main Aug 4, 2026
5 checks passed
@cole-h
cole-h deleted the grahamc/init-pullout branch August 4, 2026 16:44
@coderabbitai coderabbitai Bot mentioned this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants