Skip to content

Commit a5825e6

Browse files
authored
Merge pull request #205 from PracticalParticle/dev
Dev
2 parents 525a2cd + ee6195b commit a5825e6

27 files changed

Lines changed: 368 additions & 405 deletions

.github/workflows/release-please.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,4 @@ jobs:
4141
manifest-file: .release-please-manifest.json
4242
token: ${{ secrets.GITHUB_TOKEN }}
4343

44-
# Note: Contract version constants are automatically synced via the
45-
# sync-contract-versions.yml workflow when Release Please creates a PR
44+
# Note: sync-contract-versions.yml verifies EngineBlox.VERSION mirror on release-please PRs
Lines changed: 8 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
name: Sync Contract Versions
1+
name: Verify Protocol Version
22

33
on:
44
pull_request:
55
types: [opened, synchronize, reopened]
66
branches:
77
- main
8-
# - dev
98

109
permissions:
11-
contents: write
12-
pull-requests: write
10+
contents: read
11+
pull-requests: read
1312

1413
jobs:
15-
sync-contract-versions:
16-
# Only run on PRs created by release-please
14+
verify-protocol-version:
15+
# Release Please PRs: ensure EngineBlox.VERSION matches in .sol and .tsx
1716
if: "contains(github.event.pull_request.head.ref, 'release-please') || contains(github.event.pull_request.title, 'chore: release')"
1817
runs-on: ubuntu-latest
19-
18+
2019
steps:
2120
- name: Checkout PR branch
2221
uses: actions/checkout@v4
@@ -33,98 +32,5 @@ jobs:
3332
- name: Install dependencies
3433
run: npm ci
3534

36-
- name: Check for uncommitted changes in version files
37-
id: check-uncommitted
38-
run: |
39-
SOL_CHANGED=false
40-
TSX_CHANGED=false
41-
if ! git diff --quiet HEAD -- contracts/core/lib/EngineBlox.sol; then
42-
SOL_CHANGED=true
43-
fi
44-
if ! git diff --quiet HEAD -- sdk/typescript/lib/EngineBlox.tsx; then
45-
TSX_CHANGED=true
46-
fi
47-
if [ "$SOL_CHANGED" = true ] || [ "$TSX_CHANGED" = true ]; then
48-
echo "❌ ERROR: Version files have uncommitted changes!"
49-
echo ""
50-
echo "The workflow cannot safely update version constants when there are uncommitted changes."
51-
echo "Please commit or stash your changes before this workflow runs."
52-
echo ""
53-
if [ "$SOL_CHANGED" = true ]; then
54-
echo "Uncommitted changes in contracts/core/lib/EngineBlox.sol:"
55-
git diff HEAD -- contracts/core/lib/EngineBlox.sol
56-
fi
57-
if [ "$TSX_CHANGED" = true ]; then
58-
echo "Uncommitted changes in sdk/typescript/lib/EngineBlox.tsx:"
59-
git diff HEAD -- sdk/typescript/lib/EngineBlox.tsx
60-
fi
61-
exit 1
62-
else
63-
echo "✓ EngineBlox.sol and EngineBlox.tsx are clean, safe to proceed with version sync"
64-
echo "uncommitted=false" >> $GITHUB_OUTPUT
65-
fi
66-
67-
- name: Sync versions (including contract constants)
68-
run: npm run release:sync-versions
69-
70-
- name: Check for contract version changes
71-
id: check-changes
72-
run: |
73-
SOL_CHANGED=false
74-
TSX_CHANGED=false
75-
if ! git diff --quiet contracts/core/lib/EngineBlox.sol; then
76-
SOL_CHANGED=true
77-
fi
78-
if ! git diff --quiet sdk/typescript/lib/EngineBlox.tsx; then
79-
TSX_CHANGED=true
80-
fi
81-
if [ "$SOL_CHANGED" = true ] || [ "$TSX_CHANGED" = true ]; then
82-
echo "changed=true" >> $GITHUB_OUTPUT
83-
echo "Version changes detected:"
84-
[ "$SOL_CHANGED" = true ] && git diff contracts/core/lib/EngineBlox.sol
85-
[ "$TSX_CHANGED" = true ] && git diff sdk/typescript/lib/EngineBlox.tsx
86-
else
87-
echo "changed=false" >> $GITHUB_OUTPUT
88-
echo "✓ Contract and SDK version constants already in sync"
89-
fi
90-
91-
- name: Verify only version constants changed
92-
if: steps.check-changes.outputs.changed == 'true'
93-
id: verify-changes
94-
run: |
95-
# Get the diff for both version files
96-
DIFF_OUTPUT=$(git diff contracts/core/lib/EngineBlox.sol sdk/typescript/lib/EngineBlox.tsx)
97-
98-
# All added/removed lines must be a VERSION constant change (.sol: constant VERSION = ... or .tsx: static readonly VERSION: string = ...)
99-
ADDED_OR_REMOVED=$(echo "$DIFF_OUTPUT" | grep -E "^[-+]" | grep -v -E "^\+\+\+|^---")
100-
OTHER_CHANGES=$(echo "$ADDED_OR_REMOVED" | grep -v -E "constant\s+VERSION\s*=" | grep -v -E "static readonly VERSION: string =")
101-
102-
if [ -n "$OTHER_CHANGES" ]; then
103-
echo "❌ ERROR: Changes are not limited to VERSION constants!"
104-
echo ""
105-
echo "The workflow detected changes beyond the VERSION constant in EngineBlox.sol or EngineBlox.VERSION in EngineBlox.tsx."
106-
echo "This could indicate uncommitted changes were accidentally included."
107-
echo ""
108-
echo "Full diff:"
109-
echo "$DIFF_OUTPUT"
110-
exit 1
111-
fi
112-
113-
# Require at least one VERSION change (sol or tsx)
114-
if ! echo "$DIFF_OUTPUT" | grep -qE "^[-+].*constant\s+VERSION\s*=" && \
115-
! echo "$DIFF_OUTPUT" | grep -qE "^[-+].*static readonly VERSION: string ="; then
116-
echo "❌ ERROR: No VERSION constant changes found in diff."
117-
exit 1
118-
fi
119-
120-
echo "✓ Only version constants changed (contract + SDK), safe to commit"
121-
echo "safe=true" >> $GITHUB_OUTPUT
122-
123-
- name: Commit and push contract version updates
124-
if: steps.check-changes.outputs.changed == 'true' && steps.verify-changes.outputs.safe == 'true'
125-
run: |
126-
git config user.name "github-actions[bot]"
127-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
128-
git add contracts/core/lib/EngineBlox.sol sdk/typescript/lib/EngineBlox.tsx
129-
git commit -m "chore: sync contract version constants with package version"
130-
git push
35+
- name: Verify EngineBlox.VERSION mirror
36+
run: node scripts/sync-versions.cjs --verify

.release-please-manifest.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
".": "1.0.0",
32
"package": "1.0.0",
43
"sdk/typescript": "1.0.0"
54
}

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ When you need more context:
167167
- `README.md`
168168
- `docs/index.md`
169169
- `docs/getting-started.md`
170+
- `docs/VERSIONING.md` (npm vs on-chain protocol version)
170171
- `docs/account-pattern.md`
171172
- Look at:
172173
- Existing tests under `scripts/sanity-sdk`

CHANGELOG.md

Lines changed: 11 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,20 @@
1-
# Changelog
1+
# Repository changelog (monorepo)
22

3-
All notable changes to this project will be documented in this file.
3+
This file is **not** an npm product changelog. Release history for published packages:
44

5-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5+
- [@bloxchain/contracts](./package/CHANGELOG.md)
6+
- [@bloxchain/sdk](./sdk/typescript/CHANGELOG.md)
77

8-
## [Unreleased]
8+
See [docs/VERSIONING.md](./docs/VERSIONING.md) for the full versioning model.
99

10-
### Added
11-
- Initial changelog automation with Release Please
12-
- Automated release workflow via GitHub Actions
10+
## Experimental alpha line (not documented here)
1311

14-
### Changed
15-
- Version synchronization across monorepo packages
12+
Prior npm publishes used `1.0.0-alpha.N` with dist-tag `alpha.24` for development and testing only. That line is **not** listed in the per-package changelogs.
1613

17-
## [1.0.0] - 2025-01-26
14+
## Stable line
1815

19-
### Added
20-
- Initial release of Bloxchain Protocol
21-
- Core state machine engine (EngineBlox)
22-
- Base state machine contract (BaseStateMachine)
23-
- Secure ownership implementation (SecureOwnable)
24-
- Dynamic RBAC system (RuntimeRBAC)
25-
- Guard controller for execution protection
26-
- TypeScript SDK for contract interaction
27-
- Comprehensive test suite with fuzzing and invariant testing
28-
- Documentation and examples
16+
The first documented stable releases are **`1.0.0`** on dist-tag **`latest`** for both packages. On-chain `EngineBlox.VERSION` remains **`"1.0.0"`** for the v1 protocol line until a deliberate protocol version change.
2917

30-
### Security
31-
- Multi-phase security operations with time-locks
32-
- Reentrancy protection patterns
33-
- Input validation with custom errors
34-
- Comprehensive security testing
18+
## Protocol version (`EngineBlox.VERSION`)
3519

36-
---
37-
38-
## Release Types
39-
40-
- **Major** (x.0.0): Breaking changes that require migration
41-
- **Minor** (x.y.0): New features, backward compatible
42-
- **Patch** (x.y.z): Bug fixes, backward compatible
43-
44-
## Commit Message Format
45-
46-
This project uses [Conventional Commits](https://www.conventionalcommits.org/) for automated changelog generation via [Release Please](https://github.com/googleapis/release-please).
47-
48-
**Version Bumps** (Release Please default behavior for `node` release type):
49-
- `feat:` New features **[Minor]** - Triggers version bump
50-
- `feat!:` Breaking changes **[Major]** - Triggers version bump
51-
- `fix:` Bug fixes **[Patch]** - Triggers version bump
52-
- `BREAKING CHANGE:` in commit footer **[Major]** - Triggers version bump
53-
54-
**No Version Bump** (appear in changelog but don't trigger releases):
55-
- `docs:` Documentation changes
56-
- `style:` Code style changes (formatting, etc.)
57-
- `refactor:` Code refactoring
58-
- `perf:` Performance improvements
59-
- `test:` Test additions or changes
60-
- `chore:` Maintenance tasks
61-
- `ci:` CI/CD changes
62-
- `build:` Build system changes
63-
- `revert:` Revert previous commit
64-
65-
**Breaking Changes:**
66-
67-
Breaking changes can be indicated in two ways:
68-
1. Use `!` after the type: `feat!: change API signature`
69-
2. Include `BREAKING CHANGE:` in the commit footer:
70-
```text
71-
feat(contracts): update interface
72-
73-
BREAKING CHANGE: The transferOwnership function now requires an additional parameter
74-
```
75-
76-
**Note:** This follows Release Please's default configuration for the `node` release type, which implements the [Conventional Commits](https://www.conventionalcommits.org/) specification. Releases are only created when there are commits that trigger version bumps (`feat`, `fix`, or breaking changes). Other commit types are included in the changelog but don't trigger new releases on their own.
77-
78-
Example: `feat(contracts): add PayBlox contract implementation`
20+
On-chain / EIP-712 protocol version bumps are **manual** and rare. Document them here when they occur (in addition to updating `contracts/core/lib/EngineBlox.sol` and `sdk/typescript/lib/EngineBlox.tsx`).

CONTRIBUTING.md

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -615,14 +615,30 @@ This project uses [Conventional Commits](https://www.conventionalcommits.org/) f
615615
- **`build`**: Build system or external dependencies changes
616616
- **`revert`**: Revert a previous commit
617617

618-
### Scope (Optional)
618+
### Scope (recommended for publishable changes)
619619

620-
The scope should be the name of the package or area affected:
621-
- `contracts`: Smart contract changes
622-
- `sdk`: TypeScript SDK changes
623-
- `docs`: Documentation changes
624-
- `ci`: CI/CD changes
625-
- `scripts`: Script changes
620+
Use a **scope** on every commit that affects a release-managed npm package so history and Release Please attribution stay clear. Allowed scopes (enforced by commitlint): `contracts`, `sdk`, `examples`, `docs`, `ci`, `scripts`, `deps`, `release`.
621+
622+
| Scope | Use when you change… | Release Please package |
623+
|-------|-------------------|-------------------------|
624+
| **`contracts`** | `contracts/`, `package/`, Foundry tests for core Solidity, ABI extract affecting the contracts npm artifact | `@bloxchain/contracts`[package/CHANGELOG.md](./package/CHANGELOG.md) |
625+
| **`sdk`** | `sdk/typescript/` (sources, build, SDK tests) | `@bloxchain/sdk`[sdk/typescript/CHANGELOG.md](./sdk/typescript/CHANGELOG.md) |
626+
| **`examples`** | `contracts/examples/` (sample apps, templates, example tests) | — (not an npm package; no Release Please bump alone) |
627+
| **`docs`** | `docs/`, root or package README (no semver bump alone) ||
628+
| **`ci`** | `.github/workflows/`, CI config ||
629+
| **`scripts`** | `scripts/` (release, deploy, sanity runners) ||
630+
| **`deps`** | Dependency version bumps at root or in packages | Usually no release unless combined with `feat`/`fix` on a package path |
631+
| **`release`** | Version manifests, release-please config, changelog policy ||
632+
633+
Release Please also uses **changed file paths**. If a single commit touches both `package/` and `sdk/typescript/`, both packages may receive changelog entries when their release PRs are cut. Prefer **focused commits** per package when possible.
634+
635+
**Avoid** unscoped `feat:` / `fix:` on publishable paths — use `feat(contracts):` or `feat(sdk):` instead.
636+
637+
### Release attribution (Release Please)
638+
639+
- **Independent semver:** `@bloxchain/contracts` and `@bloxchain/sdk` version separately within major `1` ([docs/VERSIONING.md](./docs/VERSIONING.md)).
640+
- **On-chain protocol** `EngineBlox.VERSION` is **not** bumped by npm patch releases; it is updated only for deliberate protocol releases.
641+
- **Changelogs:** npm consumers should read package changelogs, not the repo root [CHANGELOG.md](./CHANGELOG.md).
626642

627643
### Examples
628644

@@ -663,7 +679,7 @@ BREAKING CHANGE: The transferOwnership function now requires an additional param
663679

664680
### Benefits
665681

666-
- **Automatic changelog generation**: Your commits automatically populate the CHANGELOG.md
682+
- **Automatic changelog generation**: Release Please updates [package/CHANGELOG.md](./package/CHANGELOG.md) and [sdk/typescript/CHANGELOG.md](./sdk/typescript/CHANGELOG.md) per publishable package (use scopes like `feat(contracts):` or `feat(sdk):`)
667683
- **Semantic versioning**: Version bumps are determined by commit types
668684
- **Better git history**: Clear, searchable commit history
669685
- **Automated releases**: Release PRs are created automatically
@@ -683,26 +699,28 @@ npm run test:truffle
683699

684700
# Commit changes
685701
git add .
686-
git commit -m "feat: add new feature"
702+
git commit -m "feat(sdk): add new feature"
687703

688704
# Push and create PR
689705
git push origin feature/new-feature
690706
```
691707

692708
### Release Process
693709

694-
Releases are **automated** using Release Please. The process works as follows:
710+
Releases use **Release Please** on `main`, then **human npm publish** after the release line is on `main`.
711+
712+
1. **Merge feature/fix PRs to `main`** using scoped conventional commits (`feat(contracts):`, `fix(sdk):`, etc.).
713+
2. **Release Please** opens one or two release PRs (`@bloxchain/contracts`, `@bloxchain/sdk`) with updated versions and per-package changelogs.
714+
3. **Review and merge** the release PR(s) on `main`. Tags/GitHub releases are created per package.
715+
4. **Publish to npm** (maintainers, after `main` contains the release versions) — three commands only:
716+
717+
```bash
718+
npm run release:prepare # gate: protocol VERSION, build, tests
719+
npm run publish:contracts # @bloxchain/contracts @ latest
720+
npm run publish:sdk # @bloxchain/sdk @ latest
721+
```
695722

696-
1. **Merge PRs to main**: All PRs merged to `main` are analyzed for conventional commits
697-
2. **Automatic release PR**: Release Please creates a release PR with:
698-
- Updated version numbers (semantic versioning based on commit types)
699-
- Generated changelog entries
700-
- All package versions synchronized
701-
3. **Review and merge**: Review the release PR, ensure changelog is accurate
702-
4. **Automatic tag and release**: When the release PR is merged:
703-
- A git tag is created
704-
- GitHub release is created
705-
- Package versions are synced across monorepo
723+
The first stable **`1.0.0`** npm publish happens **after** the versioning baseline PR is on `main`, not from long-lived feature branches. See [docs/VERSIONING.md](./docs/VERSIONING.md#publishing-stable-100-to-npm).
706724

707725
#### Manual Release (if needed)
708726

@@ -713,8 +731,9 @@ If you need to create a release manually:
713731
git checkout main
714732
git pull
715733

716-
# Run release-please locally (requires token)
717-
npx release-please release-pr --repo-url=github.com/PracticalParticle/Bloxchain-Protocol --token=YOUR_TOKEN
734+
# Preview Release Please release PR locally (requires token)
735+
npm run release:please-pr
736+
# or: npx release-please release-pr --repo-url=github.com/PracticalParticle/Bloxchain-Protocol --token=YOUR_TOKEN
718737
```
719738

720739
#### Version Bumping Rules

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ npm run docgen # docs
229229
## 📚 Documentation
230230

231231
- **[Codebase documentation process & audit checklist](CODEBASE_DOCUMENTATION.md)** – Source of truth, how to update docs, audit-ready checklist
232+
- **[Versioning & releases](docs/VERSIONING.md)** – npm packages, on-chain `EngineBlox.VERSION`, Release Please
232233
- [Protocol Architecture](./docs/bloxchain-architecture.md) · [State Machine](./docs/state-machine-engine.md) · [Getting Started](./docs/getting-started.md) · [API Reference](./docs/api-reference.md) · [SecureOwnable](./docs/secure-ownable.md) · [RuntimeRBAC](./docs/runtime-rbac.md) · [Best Practices](./docs/best-practices.md) · [Examples](./docs/examples-basic.md)
233234
- **Contract API (generated):** [docs/](docs/) – generated from Solidity NatSpec via `npm run docgen`
234235

SETUP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Bloxchain Setup Guide
22

3-
> **Note:** This file is legacy-oriented. For current protocol + SDK setup, prefer **[docs/getting-started.md](./docs/getting-started.md)**, **`env.example`**, and **`npm run release:prepare`** before publishing `@bloxchain/contracts` / `@bloxchain/sdk`.
3+
> **Note:** This file is legacy-oriented. For current protocol + SDK setup, prefer **[docs/getting-started.md](./docs/getting-started.md)**, **[docs/VERSIONING.md](./docs/VERSIONING.md)** (npm vs on-chain version), **`env.example`**, and **`npm run release:prepare`** before publishing `@bloxchain/contracts` / `@bloxchain/sdk` on `main`.
44
55
## Quick Start
66

commitlint.config.cjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,11 @@ module.exports = {
2828
'body-max-line-length': [2, 'always', 1000],
2929
'body-leading-blank': [2, 'always'],
3030
'footer-leading-blank': [2, 'always'],
31+
// Scopes for Release Please / per-package changelogs
32+
'scope-enum': [
33+
2,
34+
'always',
35+
['contracts', 'sdk', 'examples', 'docs', 'ci', 'scripts', 'deps', 'release'],
36+
],
3137
},
3238
};

docs/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Welcome to the Bloxchain TypeScript SDK documentation. This guide covers SDK usa
55
## 📚 **Documentation Structure**
66

77
### **Core SDK**
8+
- [**Versioning & releases**](./VERSIONING.md) – npm `@bloxchain/contracts` / `@bloxchain/sdk`, on-chain protocol version, publishing
89
- [**Getting Started**](./getting-started.md) – Quick setup, basic usage, and [deployment / initializer checklist](./getting-started.md#deployment-and-initialization) (upgradeable Account contracts)
910
- [**API Reference**](./api-reference.md) – Core SDK classes and types
1011
- [**SecureOwnable**](./secure-ownable.md) – SecureOwnable contract integration
@@ -78,5 +79,5 @@ console.log('Contract owner:', owner)
7879

7980
---
8081

81-
**Version**: 1.0.0-alpha.16 (see [package.json](../sdk/typescript/package.json))
82+
**Version**: 1.x stable line (see [sdk/typescript/package.json](../sdk/typescript/package.json) and [VERSIONING.md](./VERSIONING.md))
8283
**License**: MPL-2.0

0 commit comments

Comments
 (0)