Skip to content

Calvin determinism gate misses indented #[cfg(test)] — confusing error for contributors #290

Description

@EnRaiha

Summary

scripts/ci/check_calvin_determinism.sh skips test helpers by anchoring on ^#\[cfg(test)\] (no leading whitespace). An indented #[cfg(test)] on an item inside a scanned path — e.g. a test-only dummy task builder under nodedb/src/data/executor/handlers/transaction/ — is never recognised as a skip, so the gate flags Instant::now (or similar) even though the helper is test-only. Contributors see a generic FAIL: 1 non-deterministic site(s) with no hint that indentation is the cause.

Reproduction

In nodedb/src/data/executor/handlers/transaction/sub_plan.rs, the test helper build_dummy_task is indented inside impl:

    #[cfg(test)]
    pub(super) fn build_dummy_task(...) { /Instant::now()/ }

Run:

bash scripts/ci/check_calvin_determinism.sh
# → FAIL: 1 non-deterministic site(s) in Calvin write path: nodedb/src/data/executor/handlers/transaction/sub_plan.rs:122

The existing doc-block // no-determinism: ... six lines above is also ignored (gate requires same or directly preceding line).

Expected

The gate should recognise indented #[cfg(test)] (e.g. ^[[:space:]]*#\[cfg(test)\]) and handle it as a skip. When it still must flag a site, the error should direct the contributor to add a // no-determinism: <reason> marker on the same/preceding line.

Proposal

  • Change the skip anchor from ^#\[cfg(test)\] to ^[[:space:]]*#\[cfg(test)\] in check_calvin_determinism.sh (and same for the closing } anchor).
  • Keep the failure message focused on the // no-determinism: <reason> marker for indented helpers.

Fact — verified

Unindenting #[cfg(test)] to #[cfg(test)] at column 0 inside an impl breaks cargo fmt. cargo fmt formats the attribute indented to match the item, and cargo fmt --check fails on the unindented form and re-indents it. Verified locally: moving the attribute to column 0 → cargo fmt --check reports Diff and rewrites it back. Therefore the gate must handle indented form itself; contributors should not be told to unindent indented helpers.

Impact

Without this, every test-only helper added under a scanned Calvin path trips the gate, as seen in PRs #270/284/288.

Area

CI / Calvin determinism

Before submitting

  • I searched existing issues and discussions for this proposal.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:choreBuild, CI, refactor, or maintenance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions