Contributing

Thanks for contributing! Here's how to get started:

  1. Open an issue to discuss the proposed change
  2. Fork the repo and create a branch from main
  3. Implement the change with tests
  4. Make sure bundle exec fluence-ci all passes
  5. Open a pull request targeting main

Setup

git clone git@github.com:fluence-eu/ledger-sdk.git
cd ledger-sdk
bin/setup

Requires Ruby 3.2+.

Development

Running tests and linting

bundle exec fluence-ci all      # full catalog (lint + security + codequality + tests)
bundle exec fluence-ci lint     # rubocop only
bundle exec fluence-ci tests    # minitest only (auto-detected from test/test_helper.rb)
bundle exec rubocop -a          # auto-fix linting (no fluence-ci equivalent)

Interactive console

APPCENTER_CLIENT_ID=your_id APPCENTER_CLIENT_SECRET=your_secret bin/console

Commit Convention

This project follows Conventional Commits.

Format

<type>(<scope>): <description>

[body]

[footer(s)]

Types

Type Description
feat New feature
fix Bug fix
docs Documentation only changes
style Formatting changes (whitespace, commas, etc.) — no logic
refactor Code change that neither fixes a bug nor adds a feature
perf Performance improvement
test Adding or updating tests
build Changes to build system or dependencies
ci CI/CD configuration changes
chore Other changes that don't modify source or tests
revert Revert a previous commit

Scope

Optional — indicates the area of the project affected:

  • feat(container): add list method
  • fix(balance): build account-scoped paths correctly
  • refactor(base): extract build_instance logic

Description

  • Imperative mood ("add", not "adds" or "added")
  • No capital letter at the start
  • No period at the end
  • Maximum 72 characters

Body (optional)

  • Use bullet points with - for multiple items
  • Explain why, not what (the diff speaks for itself)

Breaking Changes

Non-backward-compatible changes must be flagged with:

  • A ! after the type/scope: feat(balance)!: change list parameters
  • And/or a BREAKING CHANGE: footer in the body

Examples

feat(container): add accounts association
fix(balance): build account-scoped paths correctly

- account_id was ignored when present in the chain context
- container-level paths were generated for account balances
feat(base)!: remove create from collections

BREAKING CHANGE: the SDK is read-only, create is no longer
available on any resource collection.

Branching Model

  • main — default branch. All feature branches are created from here, and all PRs target this branch.
  • Never push directly to main — always create a feature branch and open a PR.

Pull Request Convention

PR Title

  • Same format as commits: <type>(<scope>): <description>
  • Under 72 characters

PR Classification

Level Criteria Description requirements
Critical Breaking change, security fix, data migration Full description — summary, changes, impact, rollback plan, how to test
Major New feature, new endpoint, significant refactor Summary + changes + how to test
Minor Small bug fix, config tweak, dependency bump Summary + changes (1-2 lines each)
Trivial Documentation, formatting, comment update One-line summary is enough

PR Description by Level

Critical / Major

## Summary
<What and why in 2-3 sentences>

## Changes
- <change 1>
- <change 2>

## How to Test
1. <step 1>
2. <step 2>

For Critical PRs, also add:

## Impact
- <what parts of the system are affected>

## Rollback Plan
- <how to safely revert if something goes wrong>

Minor

## Summary
<One sentence>

## Changes
- <change 1>

Trivial

A one-line summary in the PR body is sufficient.

Rules

  • One topic per PR — don't mix unrelated changes
  • All tests must pass (bundle exec fluence-ci all)
  • New code must include tests
  • Never commit secrets or credentials

Architecture

lib/ledger/sdk/
  models/
    base.rb          # Abstract class: list, associations, lazy loading
    container.rb
    .rb
    position.rb
    inventory.rb
    balance.rb
  client.rb          # HTTP client (get, post, put, patch, delete)
  configuration.rb   # SDK configuration (gateway service)
  version.rb
  • Base provides list — the SDK is read-only, no resource exposes create
  • Base::Instance handles lazy loading and chainable associations via self.association
  • Association chain: Container -> Account -> Position -> Inventory
  • Balances are reached by name from containers and accounts: balances('official')
  • Context propagated via @extra hash (e.g. container_id, account_id)
  • HTTP calls are routed through the Fluence API gateway with service: :ledger (paths are prefixed with /backend/ledger/ by fluence-gateway-client)

Tests

  • Framework: Minitest (test/**/test_*.rb)
  • HTTP stubs via ClientStub in test/test_helper.rb — no real HTTP requests
  • Minimum coverage: 95% overall, 70% per file
  • All new code must be tested
  • Coverage checked on PRs via undercover (diff-based)

Code Conventions

  • frozen_string_literal: true on every Ruby file
  • Strings: single quotes (unless interpolation is needed)
  • RuboCop: no rule disabling without justification
  • Version in lib/ledger/sdk/version.rb — do not modify unless for an explicit release
  • YARD-style doc comments on all public methods

CI

GitHub Actions:

  • main.yml — runs on every PR: RuboCop + Minitest + coverage check
  • docs-deploy.yml — builds the YARD site and publishes to GitHub Pages on main
  • docs-measure.yml, docs-pr.yml — yardstick baseline on main + sticky coverage-delta comment on PRs
  • rubocop-measure.yml, rubocop-pr.yml — RuboCop offense baseline + sticky offense-delta comment on PRs
  • coverage-measure.yml, coverage-pr.yml — coverage baseline + undercover regression check
  • codequality-measure.yml, codequality-pr.yml — reek/flog/flay advisory deltas
  • prepare-release.ymlworkflow_dispatch bump (patch/minor/major) opens an auto-merged release PR
  • release.yml — on release PR merge, creates the tag + GitHub Release with the .gem attached
  • publish.yml — on Release published, pushes the gem to GitHub Packages

AI-Assisted Contributions

When using AI tools (Claude, Copilot, etc.) to generate commits or PRs:

  • Classify first — determine if the change is critical, major, minor, or trivial
  • Focus on the "why" — the diff already shows the "what"
  • Skip boilerplate — don't add empty sections or placeholder text

The person opening the PR takes full responsibility for the code. Before submitting:

  • [ ] I have read and understood every line of code in this PR
  • [ ] I can explain why each change was made
  • [ ] I have tested the changes locally

Do not add AI co-author lines (Co-Authored-By), "Generated with" footers, or any AI attribution in commits or PR descriptions.


License

By contributing, you agree that your contributions will be licensed under the MIT License.