Skip to content

Commit 2425aae

Browse files
authored
Merge branch 'main' into feat/proximity-forwarding-v2
2 parents 78c4c96 + c8bc483 commit 2425aae

File tree

5 files changed

+133
-6
lines changed

5 files changed

+133
-6
lines changed

.githooks/README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Git Hooks
2+
3+
This directory contains git hooks that enforce code quality and commit message standards.
4+
5+
## Installation
6+
7+
To install these hooks, run from the repository root:
8+
9+
```bash
10+
# Install commit-msg hook
11+
cp .githooks/commit-msg .git/hooks/
12+
chmod +x .git/hooks/commit-msg
13+
14+
# Or configure git to use this hooks directory
15+
git config core.hooksPath .githooks
16+
```
17+
18+
## Available Hooks
19+
20+
### commit-msg
21+
22+
Validates that commit messages follow [Conventional Commits](https://www.conventionalcommits.org/) format.
23+
24+
**Required format:**
25+
```
26+
type(scope): description
27+
28+
[optional body]
29+
30+
[optional footer(s)]
31+
```
32+
33+
**Allowed types:**
34+
- `feat`: New feature
35+
- `fix`: Bug fix
36+
- `docs`: Documentation changes
37+
- `style`: Code style changes (formatting, etc.)
38+
- `refactor`: Code refactoring
39+
- `perf`: Performance improvements
40+
- `test`: Adding or modifying tests
41+
- `build`: Build system or dependency changes
42+
- `ci`: CI/CD changes
43+
44+
**Examples:**
45+
```bash
46+
fix: resolve WebSocket connection timeout
47+
feat(network): add peer reputation scoring
48+
build(deps): bump tokio from 1.0 to 1.1
49+
fix!: breaking change to API
50+
```
51+
52+
**Important:**
53+
- Type must be **lowercase** (e.g., `fix:` not `Fix:`)
54+
- This matches the CI check on GitHub PRs
55+
- Breaking changes can be indicated with `!` after the type
56+
57+
### pre-commit
58+
59+
The pre-commit hook (already installed in `.git/hooks/pre-commit`) checks:
60+
- Code formatting with `cargo fmt`
61+
- Clippy lints
62+
- Special TODO comments that block commits
63+
- Disabled tests using Claude
64+
65+
**Note:** The pre-commit hook is specific to your local setup and is already installed by git hooks installation scripts. It's not included in this directory as it's environment-specific.
66+
67+
## Why This Matters
68+
69+
- **CI Compatibility**: Our GitHub Actions CI checks PR titles for Conventional Commits format
70+
- **Consistency**: Everyone uses the same commit message style
71+
- **Automation**: Makes it easier to generate changelogs and release notes
72+
- **Early Feedback**: Catch issues locally before pushing to GitHub

.githooks/commit-msg

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
# Commit message hook that validates Conventional Commits format
3+
4+
# Colors for output
5+
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[1;33m'
8+
NC='\033[0m' # No Color
9+
10+
# Get the commit message file path (passed as first argument)
11+
COMMIT_MSG_FILE=$1
12+
13+
if [ ! -f "$COMMIT_MSG_FILE" ]; then
14+
echo -e "${RED}Error: Commit message file not found${NC}"
15+
exit 1
16+
fi
17+
18+
# Get the first line of the commit message
19+
FIRST_LINE=$(head -n1 "$COMMIT_MSG_FILE")
20+
21+
# Conventional Commits pattern: type(scope): description OR type: description
22+
# type must be lowercase and from allowed list
23+
# type can optionally be followed by ! for breaking changes
24+
CONVENTIONAL_PATTERN="^(feat|fix|docs|style|refactor|perf|test|build|ci)(\([a-z0-9_-]+\))?!?: .+"
25+
26+
if echo "$FIRST_LINE" | grep -qE "$CONVENTIONAL_PATTERN"; then
27+
exit 0
28+
else
29+
echo -e "${RED}✗ Commit message doesn't follow Conventional Commits format${NC}"
30+
echo -e "${YELLOW}First line must match pattern: type(scope): description${NC}"
31+
echo -e "${YELLOW}Allowed types: feat, fix, docs, style, refactor, perf, test, build, ci${NC}"
32+
echo -e "${YELLOW}Type must be lowercase. Examples:${NC}"
33+
echo -e " ${GREEN}fix: resolve WebSocket connection timeout${NC}"
34+
echo -e " ${GREEN}feat(network): add peer reputation scoring${NC}"
35+
echo -e " ${GREEN}build(deps): bump tokio from 1.0 to 1.1${NC}"
36+
echo -e " ${GREEN}fix!: breaking change to API${NC}"
37+
echo ""
38+
echo -e "${RED}Your commit message:${NC}"
39+
echo -e "${YELLOW}$FIRST_LINE${NC}"
40+
exit 1
41+
fi

.github/workflows/auto-label-issues.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
steps:
2020
- name: Check user account age to prevent spam
21-
uses: actions/github-script@v7
21+
uses: actions/github-script@v8
2222
with:
2323
script: |
2424
// Anti-spam: Only process issues from users with accounts older than 7 days
@@ -51,7 +51,7 @@ jobs:
5151
- name: Analyze issue and suggest labels
5252
if: steps.spam_check.outputs.skip != 'true'
5353
id: analyze
54-
uses: actions/github-script@v7
54+
uses: actions/github-script@v8
5555
env:
5656
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
5757
with:

crates/core/src/operations/subscribe.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,22 @@ pub(crate) async fn request_subscribe(
8484
tracing::debug!(%key, "No remote peers available for subscription, checking locally");
8585

8686
if super::has_contract(op_manager, *key).await? {
87-
// We have the contract locally - complete operation immediately
88-
// Following Nacho's suggestion: use notify_node_event to tap into
89-
// result router directly without state transitions
90-
tracing::info!(%key, tx = %id, "Contract available locally, completing subscription via result router");
87+
// We have the contract locally - register subscription and complete immediately
88+
tracing::info!(%key, tx = %id, "Contract available locally, registering local subscription");
89+
90+
// CRITICAL FIX for issue #2001: Register subscriber in DashMap before completing
91+
// Without this, UPDATE operations won't find subscribers for locally-cached contracts
92+
let subscriber = op_manager.ring.connection_manager.own_location();
93+
if op_manager
94+
.ring
95+
.add_subscriber(key, subscriber.clone())
96+
.is_err()
97+
{
98+
tracing::error!(%key, tx = %id, "Failed to add local subscriber - max subscribers reached");
99+
// Continue anyway - client requested subscription and contract is local
100+
} else {
101+
tracing::debug!(%key, tx = %id, subscriber = %subscriber.peer, "Successfully registered local subscriber");
102+
}
91103

92104
// Use notify_node_event to deliver SubscribeResponse directly to client
93105
// This avoids the problem with notify_op_change overwriting the operation

crates/core/tests/operations.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,8 @@ async fn test_multiple_clients_subscription() -> TestResult {
11481148
}
11491149
}
11501150

1151+
tracing::info!("All clients subscribed, proceeding with UPDATE operation");
1152+
11511153
// Create a new to-do list by deserializing the current state, adding a task, and serializing it back
11521154
let mut todo_list: test_utils::TodoList = serde_json::from_slice(wrapped_state.as_ref())
11531155
.unwrap_or_else(|_| test_utils::TodoList {

0 commit comments

Comments
 (0)