Skip to content

Commit 7ceedcc

Browse files
committed
Initial store-mysql plugin: generic-credentials Store trait against MySQL/MariaDB
New plugin repo, scaffolded from store-postgres's two-crate structure (busbar-store-mysql logic crate + busbar-store-mysql-plugin cdylib adapter). Implements busbar 1.5.0's post-redesign Store trait: api_keys (renamed from `keys`, a MySQL/MariaDB reserved word), kind-polymorphic credentials (sigv4 today), tombstone-delete semantics, denylist, usage windows/metering, audit log. Design decisions specific to this backend: - store_sequence: single-row revision counter, bumped first in every control-plane transaction, fixed lock order (store_sequence -> api_keys -> credentials -> denylist) makes deadlock structurally impossible. - ascii_bin collation on every opaque identifier column -- MySQL's default collation is case-insensitive, a real security footgun for credential lookup handles. - Boot-time probes hard-fail (not warn) if CHECK constraints aren't actually enforced (MySQL < 8.0.16, Aurora MySQL 2.x parse but don't enforce) or sql_mode lacks STRICT_ALL_TABLES. - Explicit SELECT ... FOR UPDATE existence checks before every conditional mutation, since MySQL's rows_affected() reports rows changed, not matched. - VALUES(...) row-constructor literals clamped with GREATEST(0, ...) separately from the UPDATE arithmetic, since MySQL type-checks the full INSERT row shape against UNSIGNED columns even when ON DUPLICATE KEY UPDATE is what actually fires. 18 unit tests + 1 real end-to-end test (loads the actual compiled cdylib over the real loader ABI, mints a key, reopens fresh to prove no in-process caching, then independently reconnects via the plain MysqlStore bypassing the ABI entirely to prove real MySQL rows were written) all pass against a live mysql:8 container. cargo fmt/clippy -D warnings both clean. MariaDB compatibility is validated by schema/query design (standard SQL, no MySQL-8-only syntax) but not yet exercised against a live MariaDB container -- flagged in the README as a follow-up, not a guarantee. Also required adding a `mysql` service option to busbarAI core's shared plugin-ci.yml reusable workflow (separate commit there, cb300dc).
0 parents  commit 7ceedcc

16 files changed

Lines changed: 4036 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Calls the canonical plugin-ci reusable workflow (GetBusbar/busbar/.github/workflows/plugin-ci.yml)
2+
# instead of hand-copying build/test/signoff steps here — see that file for what actually runs.
3+
name: ci
4+
5+
on:
6+
push:
7+
branches: [main, dev]
8+
pull_request:
9+
branches: [main, dev]
10+
11+
jobs:
12+
ci:
13+
uses: GetBusbar/busbar/.github/workflows/plugin-ci.yml@dev
14+
with:
15+
plugin_crate: busbar-store-mysql-plugin
16+
plugin_kind: store
17+
plugin_alias: mysql
18+
service: mysql
19+
busbar_ref: dev

.github/workflows/release.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# Release: on a version tag (e.g. v1.0.0), build the store-mysql plugin cdylib for all 5
2+
# supported targets, pack + sign each into a loadable busbar plugin tarball, and publish them to
3+
# THIS repo's own GitHub Release.
4+
#
5+
# Same 5-target matrix, same busbar-plugin-pack pack/sign step (built from a sibling busbar
6+
# checkout), same BUSBAR_SIGN_KEY-or-`--allow-unsigned` fallback, same `gh release upload` +
7+
# build-provenance attestation pattern busbar's own plugins use — but every plugin (including this
8+
# one) now releases from its own repo; busbarAI no longer has a combined `store-plugins` release
9+
# job to mirror.
10+
#
11+
# This plugin's own version (the `v*` tag pushed here) is NOT tied to busbar's version number —
12+
# it is independently versioned starting at 0.5.0 (see README), separate from whichever busbar
13+
# commit it happens to build against via BUSBAR_REF below.
14+
name: release
15+
16+
on:
17+
push:
18+
tags:
19+
- "v*"
20+
21+
permissions:
22+
contents: write # create the Release + upload assets
23+
id-token: write # OIDC identity for keyless Sigstore signing (provenance)
24+
attestations: write # record the build-provenance attestation
25+
26+
env:
27+
# Which busbar commit to check out as the sibling path dependency (used only to build
28+
# busbar-plugin-pack, which then packs + signs this plugin under BUSBAR_SIGN_KEY) — same
29+
# BUSBAR_REF convention ci.yml / plugin-ci.yml already established. Pinned to a commit SHA on
30+
# the 1.5.0-dev branch, not the branch name itself, since a mutable branch checked out while
31+
# holding the signing key is a supply-chain foot-gun. To bump deliberately: confirm the new SHA
32+
# builds busbar-plugin-pack cleanly, then update this value in a reviewed PR — never track the
33+
# branch automatically. Update to a `main` SHA once busbar 1.5.0 actually ships; until then the
34+
# plugin ABI surface this crate depends on only exists on 1.5.0-dev.
35+
BUSBAR_REF: 86d0b8397cc67bc8d27d5726d8f2766200728541 # dev, as of 2026-07-31
36+
37+
jobs:
38+
# Create the Release first so the parallel per-target upload jobs have something to attach to
39+
# (uploading from a matrix without a pre-existing release races -> "release not found").
40+
create-release:
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v7
44+
- name: Create GitHub Release
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
run: |
48+
set -euo pipefail
49+
if ! out=$(gh release create "${GITHUB_REF_NAME}" \
50+
--repo "${GITHUB_REPOSITORY}" \
51+
--title "busbar-store-mysql ${GITHUB_REF_NAME}" \
52+
--verify-tag --generate-notes 2>&1); then
53+
if echo "$out" | grep -qi "already exists"; then
54+
echo "$out"
55+
echo "Release ${GITHUB_REF_NAME} already exists — reusing it (parallel matrix re-run or race)."
56+
gh release view "${GITHUB_REF_NAME}" --repo "${GITHUB_REPOSITORY}"
57+
else
58+
echo "$out" >&2
59+
exit 1
60+
fi
61+
else
62+
echo "$out"
63+
fi
64+
65+
# One signed .tar.gz per target: {cdylib + manifest.json}, packed by busbar-plugin-pack and
66+
# signed with the busbar release PRIVATE key (BUSBAR_SIGN_KEY secret) so it verifies as
67+
# first-party against the PUBLIC key embedded in busbar's own release binaries. If that secret
68+
# isn't provisioned on this repo, falls back to an UNSIGNED tarball (loadable only under
69+
# plugins.trust.allow_unsigned) rather than blocking the release — same seam busbarAI's own
70+
# release.yml documents (TODO(release-keys)).
71+
store-plugin:
72+
needs: create-release
73+
name: store-plugin (${{ matrix.target }})
74+
runs-on: ${{ matrix.os }}
75+
strategy:
76+
fail-fast: false
77+
matrix:
78+
include:
79+
- target: x86_64-unknown-linux-gnu
80+
os: ubuntu-latest
81+
libext: so
82+
libprefix: lib
83+
- target: aarch64-unknown-linux-gnu
84+
os: ubuntu-24.04-arm
85+
libext: so
86+
libprefix: lib
87+
- target: x86_64-apple-darwin
88+
os: macos-latest
89+
libext: dylib
90+
libprefix: lib
91+
- target: aarch64-apple-darwin
92+
os: macos-latest
93+
libext: dylib
94+
libprefix: lib
95+
- target: x86_64-pc-windows-msvc
96+
os: windows-latest
97+
libext: dll
98+
libprefix: ""
99+
steps:
100+
- name: Checkout store-mysql
101+
uses: actions/checkout@v7
102+
with:
103+
path: store-mysql
104+
105+
- name: Checkout busbar (sibling path dependency)
106+
uses: actions/checkout@v7
107+
with:
108+
repository: GetBusbar/busbar
109+
ref: ${{ env.BUSBAR_REF }}
110+
path: busbarAI
111+
112+
- uses: dtolnay/rust-toolchain@stable
113+
with:
114+
targets: ${{ matrix.target }}
115+
- uses: Swatinem/rust-cache@v2
116+
117+
- name: Build the store-mysql plugin cdylib
118+
working-directory: store-mysql
119+
run: cargo build --release --target ${{ matrix.target }}
120+
shell: bash
121+
122+
- name: Build busbar-plugin-pack (from the sibling busbar checkout)
123+
working-directory: busbarAI
124+
run: cargo build --release --target ${{ matrix.target }} -p busbar-plugin-pack
125+
shell: bash
126+
127+
- name: Package + sign the plugin tarball
128+
env:
129+
BUSBAR_SIGN_KEY: ${{ secrets.BUSBAR_SIGN_KEY }}
130+
run: |
131+
set -euo pipefail
132+
ver="${GITHUB_REF_NAME#v}"
133+
target="${{ matrix.target }}"
134+
outdir="plugin-dist"; mkdir -p "$outdir"
135+
pack="busbarAI/target/${target}/release/busbar-plugin-pack"
136+
[ -x "$pack" ] || pack="busbarAI/target/${target}/release/busbar-plugin-pack.exe"
137+
unsigned_flag=""
138+
if [ -z "${BUSBAR_SIGN_KEY:-}" ]; then
139+
echo "::warning::BUSBAR_SIGN_KEY secret is not provisioned — packaging an UNSIGNED plugin tarball (loadable only under plugins.trust.allow_unsigned). See busbarAI's release.yml TODO(release-keys) seam."
140+
unsigned_flag="--allow-unsigned"
141+
fi
142+
lib="store-mysql/target/${target}/release/${{ matrix.libprefix }}busbar_store_mysql_plugin.${{ matrix.libext }}"
143+
"$pack" pack \
144+
--lib "$lib" \
145+
--name "busbar-store-mysql-plugin" --alias "mysql" --kind store \
146+
--version "$ver" --publisher busbar \
147+
--description "First-party signed kind:store plugin cdylib: the MySQL/MariaDB backend for busbar's durable governance store, exported over the store C ABI. Drop the built library into the plugins folder and set store.module: mysql to share virtual keys, budgets, and usage across a fleet of busbar nodes." \
148+
--license Apache-2.0 \
149+
--out "${outdir}/busbar-store-mysql-${ver}-${target}.tar.gz" \
150+
$unsigned_flag
151+
ls -l "$outdir"
152+
shell: bash
153+
154+
- name: Attach plugin tarball to Release
155+
env:
156+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157+
run: gh release upload "${GITHUB_REF_NAME}" plugin-dist/*.tar.gz --repo "${GITHUB_REPOSITORY}" --clobber
158+
shell: bash
159+
160+
# Keyless (Sigstore/OIDC) build-provenance attestation binding this tarball's digest to this
161+
# workflow run + commit — `gh attestation verify <tarball> --repo ${{ github.repository }}`.
162+
- name: Attest plugin build provenance
163+
uses: actions/attest-build-provenance@v4
164+
with:
165+
subject-path: "plugin-dist/*.tar.gz"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

CODE_OF_CONDUCT.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
6+
7+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8+
9+
## Our Standards
10+
11+
Examples of behavior that contributes to a positive environment for our community include:
12+
13+
* Demonstrating empathy and kindness toward other people
14+
* Being respectful of differing opinions, viewpoints, and experiences
15+
* Giving and gracefully accepting constructive feedback
16+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17+
* Focusing on what is best not just for us as individuals, but for the overall community
18+
19+
Examples of unacceptable behavior include:
20+
21+
* The use of sexualized language or imagery, and sexual attention or advances of any kind
22+
* Trolling, insulting or derogatory comments, and personal or political attacks
23+
* Public or private harassment
24+
* Publishing others' private information, such as a physical or email address, without their explicit permission
25+
* Other conduct which could reasonably be considered inappropriate in a professional setting
26+
27+
## Enforcement Responsibilities
28+
29+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
32+
33+
## Scope
34+
35+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
36+
37+
## Enforcement
38+
39+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at conduct@getbusbar.com. All complaints will be reviewed and investigated promptly and fairly.
40+
41+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
42+
43+
## Enforcement Guidelines
44+
45+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
46+
47+
### 1. Correction
48+
49+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
50+
51+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
52+
53+
### 2. Warning
54+
55+
**Community Impact**: A violation through a single incident or series of actions.
56+
57+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
58+
59+
### 3. Temporary Ban
60+
61+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
62+
63+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
64+
65+
### 4. Permanent Ban
66+
67+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
68+
69+
**Consequence**: A permanent ban from any sort of public interaction within the community.
70+
71+
## Attribution
72+
73+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
74+
75+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
76+
77+
For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations].
78+
79+
[homepage]: https://www.contributor-covenant.org
80+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
81+
[Mozilla CoC]: https://github.com/mozilla/diversity
82+
[FAQ]: https://www.contributor-covenant.org/faq
83+
[translations]: https://www.contributor-covenant.org/translations

CONTRIBUTING.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Contributing to store-postgres
2+
3+
Thanks for your interest in improving `store-postgres`. This document covers
4+
how to build, test, and submit changes.
5+
6+
## Ground rules
7+
8+
- Be respectful and constructive in all project spaces (see
9+
[CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)).
10+
- By contributing, you agree your contributions are licensed under the project's
11+
[Apache-2.0](LICENSE) license.
12+
- Security issues go through [SECURITY.md](SECURITY.md), **not** public issues.
13+
14+
## Development setup
15+
16+
`store-postgres` is a Rust `cdylib` plugin. You need a recent stable toolchain
17+
(`rustup` recommended), and — until [busbarAI](https://github.com/GetBusbar/busbar)
18+
ships publicly — a sibling checkout of it at `../busbarAI`, since this crate's
19+
`Cargo.toml` points at busbar's crates as local path dependencies. See the
20+
README's [Dependencies](README.md#dependencies) section for the exact layout;
21+
CI checks out `GetBusbar/busbar` at the branch named in the reusable
22+
`plugin-ci.yml` workflow reference in [`ci.yml`](.github/workflows/ci.yml).
23+
24+
The meaningful test coverage here needs a **live Postgres** — see the README's
25+
[Tests need a real Postgres](README.md#tests-need-a-real-postgres) section.
26+
Locally, `cargo test` skips that coverage cleanly if `BUSBAR_TEST_POSTGRES_URL`
27+
is unset; set it to point at a real Postgres 16+ database to exercise it:
28+
29+
```bash
30+
export BUSBAR_TEST_POSTGRES_URL=postgres://busbar:busbar@localhost:5432/busbar_test
31+
cargo build --release # cdylib
32+
cargo test # unit tests + the e2e dlopen/live-Postgres test
33+
cargo clippy --all-targets -- -D warnings # lints must be clean
34+
cargo fmt --all -- --check # format before committing
35+
```
36+
37+
## Before you open a pull request
38+
39+
1. **`cargo fmt --all`** — code must be rustfmt-clean.
40+
2. **`cargo clippy --all-targets -- -D warnings`** — no warnings.
41+
3. **`cargo build && cargo test`** — green, including the live-Postgres
42+
end-to-end test in `tests/e2e.rs` (it hard-fails under `CI=1` rather than
43+
silently skipping — never let that coverage quietly vanish).
44+
4. Add or update tests for any behavior change.
45+
5. Update documentation (`README.md`, doc comments) when you change behavior or config.
46+
47+
## Architecture
48+
49+
This repo is deliberately a thin adapter (`src/lib.rs`): it turns the engine's
50+
JSON `open` config into a `PostgresStore` and hands the trait object to
51+
[`busbar-plugin-sdk`](https://github.com/GetBusbar/busbar/tree/main/crates/plugin-sdk),
52+
which emits the C ABI symbols the loader resolves. All the SQL and schema logic
53+
lives in the `busbar-store-postgres` library crate this plugin wraps, in the
54+
`busbarAI` monorepo — most substantive changes belong there, not here.
55+
56+
## Commit & PR conventions
57+
58+
- Keep commits focused; squash noisy WIP commits before opening the PR.
59+
- Write a clear PR description: what changed, why, and how it was verified.
60+
- Reference any related issue.
61+
- Stage files by name; avoid sweeping `git add -A` that pulls in unrelated changes.
62+
63+
## Questions
64+
65+
Open a discussion or issue. We're happy to help you get oriented.

0 commit comments

Comments
 (0)