Skip to content

Commit 788d1a0

Browse files
committed
Merge branch 'upstream-main'
2 parents 6d4c944 + d5e6666 commit 788d1a0

1,821 files changed

Lines changed: 44810 additions & 25474 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Sponsor Priority Label
2+
3+
on:
4+
issues:
5+
types: [opened, reopened]
6+
workflow_dispatch:
7+
inputs:
8+
issue_number:
9+
description: "Issue number to evaluate (manual dry-run)"
10+
required: true
11+
type: number
12+
dry_run:
13+
description: "If true, log the decision without applying the label"
14+
required: false
15+
default: true
16+
type: boolean
17+
18+
permissions:
19+
contents: read
20+
issues: write
21+
22+
jobs:
23+
label-sponsor-issues:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Evaluate sponsorship and label
27+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
28+
env:
29+
SPONSORABLE_LOGIN: ArcadeData
30+
LABEL_NAME: high_priority
31+
# 6-char hex without the leading '#'; that's the form the REST labels API expects.
32+
LABEL_COLOR: B60205
33+
LABEL_DESCRIPTION: Issue opened by a GitHub Sponsor of ArcadeData
34+
with:
35+
script: |
36+
const sponsorable = process.env.SPONSORABLE_LOGIN;
37+
const labelName = process.env.LABEL_NAME;
38+
const labelColor = process.env.LABEL_COLOR;
39+
const labelDescription = process.env.LABEL_DESCRIPTION;
40+
41+
// Resolve the target issue. For issues events, use the payload directly.
42+
// For workflow_dispatch, fetch the issue specified by the input.
43+
let issue;
44+
let dryRun = false;
45+
if (context.eventName === "workflow_dispatch") {
46+
dryRun = context.payload.inputs.dry_run !== "false";
47+
const issueNumber = Number(context.payload.inputs.issue_number);
48+
try {
49+
const { data } = await github.rest.issues.get({
50+
owner: context.repo.owner,
51+
repo: context.repo.repo,
52+
issue_number: issueNumber,
53+
});
54+
issue = data;
55+
} catch (err) {
56+
// audit() needs the issue user/association; on dispatch fetch failure we don't
57+
// have those yet, so emit a substitute info line keyed by issue_number instead.
58+
core.warning(`sponsor-priority: dispatch issues.get failed: ${err.message}`);
59+
core.info(
60+
`sponsor-priority: issue_number=${context.payload.inputs.issue_number}, ` +
61+
`isSponsor=unknown, action=errored` +
62+
(dryRun ? " (dry_run)" : "")
63+
);
64+
return;
65+
}
66+
} else {
67+
issue = context.payload.issue;
68+
}
69+
70+
const login = issue.user.login;
71+
const userType = issue.user.type;
72+
const association = issue.author_association;
73+
74+
const audit = (isSponsor, action) => {
75+
core.info(
76+
`sponsor-priority: user=${login}, association=${association}, ` +
77+
`isSponsor=${isSponsor}, action=${action}` +
78+
(dryRun ? " (dry_run)" : "")
79+
);
80+
};
81+
82+
// Skip bots and internal contributors before any external call.
83+
const isBot = userType === "Bot" || login.endsWith("[bot]");
84+
const isInternal =
85+
association === "OWNER" ||
86+
association === "MEMBER" ||
87+
association === "COLLABORATOR";
88+
if (isBot || isInternal) {
89+
audit("n/a", "skipped");
90+
return;
91+
}
92+
93+
// Probe sponsorship.
94+
let isSponsor = null;
95+
try {
96+
const result = await github.graphql(
97+
`query($login: String!, $sponsorable: String!) {
98+
organization(login: $sponsorable) {
99+
isSponsoredBy(accountLogin: $login)
100+
}
101+
}`,
102+
{ login, sponsorable }
103+
);
104+
isSponsor = Boolean(result?.organization?.isSponsoredBy);
105+
} catch (err) {
106+
core.warning(`sponsor-priority: graphql failed: ${err.message}`);
107+
audit("unknown", "errored");
108+
return;
109+
}
110+
111+
if (!isSponsor) {
112+
audit(false, "skipped");
113+
return;
114+
}
115+
116+
if (dryRun) {
117+
audit(true, "dry_run");
118+
return;
119+
}
120+
121+
// Ensure the label exists, then apply it.
122+
try {
123+
await github.rest.issues.getLabel({
124+
owner: context.repo.owner,
125+
repo: context.repo.repo,
126+
name: labelName,
127+
});
128+
} catch (err) {
129+
if (err.status === 404) {
130+
try {
131+
await github.rest.issues.createLabel({
132+
owner: context.repo.owner,
133+
repo: context.repo.repo,
134+
name: labelName,
135+
color: labelColor,
136+
description: labelDescription,
137+
});
138+
} catch (createErr) {
139+
// 422 = lost the race to a concurrent run; the label now exists, fall through.
140+
if (createErr.status !== 422) {
141+
core.warning(`sponsor-priority: createLabel failed: ${createErr.message}`);
142+
audit(true, "errored");
143+
return;
144+
}
145+
}
146+
} else {
147+
core.warning(`sponsor-priority: getLabel failed: ${err.message}`);
148+
audit(true, "errored");
149+
return;
150+
}
151+
}
152+
153+
try {
154+
await github.rest.issues.addLabels({
155+
owner: context.repo.owner,
156+
repo: context.repo.repo,
157+
issue_number: issue.number,
158+
labels: [labelName],
159+
});
160+
audit(true, "labeled");
161+
} catch (err) {
162+
core.warning(`sponsor-priority: addLabels failed: ${err.message}`);
163+
audit(true, "errored");
164+
}

.github/workflows/test-python-bindings.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6666

6767
- name: Set up Docker Buildx
68-
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
68+
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
6969

7070
- name: Download JARs from ArcadeDB Docker image
7171
shell: bash
@@ -203,7 +203,7 @@ jobs:
203203

204204
- name: Set up Docker Buildx (Linux only)
205205
if: matrix.platform == 'linux/amd64' || matrix.platform == 'linux/arm64'
206-
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
206+
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
207207

208208
- name: Install Python build dependencies
209209
shell: bash

.github/workflows/test-python-examples.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6060

6161
- name: Set up Docker Buildx
62-
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
62+
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
6363

6464
- name: Download JARs from ArcadeDB Docker image
6565
shell: bash
@@ -177,7 +177,7 @@ jobs:
177177

178178
- name: Set up Docker Buildx (Linux only)
179179
if: matrix.platform == 'linux/amd64' || matrix.platform == 'linux/arm64'
180-
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
180+
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
181181

182182
- name: Set up Python
183183
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ dist
560560

561561
notes.txt
562562
/.claude/worktrees
563+
.worktrees/
563564
/server/profiler
564565
/server/chats
565566
config/ai.json

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repos:
2222
- id: check-json
2323
- id: check-xml
2424
- repo: https://github.com/psf/black
25-
rev: 26.3.1
25+
rev: 26.5.1
2626
hooks:
2727
- id: black
2828
language_version: python3
@@ -54,7 +54,7 @@ repos:
5454
types: [ java, xml ]
5555
additional_dependencies:
5656
- prettier@3.8.3
57-
- prettier-plugin-java@2.8.1
57+
- prettier-plugin-java@2.9.7
5858
- prettier-plugin-xml
5959
args:
6060
- --write

bindings/python/examples/11_vector_index_build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,9 +1057,9 @@ def ensure_milvus_compose_file(compose_file: Path, release_tag: str) -> None:
10571057
urlretrieve(url, str(compose_file)) # nosec B310
10581058
raw = compose_file.read_text(encoding="utf-8")
10591059

1060-
sanitized = re.sub(r"(?m)^\s*container_name:\s*.*\n", "", raw)
1060+
sanitized = re.sub(r"(?m)^[ \t]*container_name:[ \t]*[^\n]*\n", "", raw)
10611061
sanitized = re.sub(
1062-
r"(?ms)(^\s*networks:\s*\n(?:.*\n)*?^\s*milvus:\s*\n)(\s*name:\s*milvus\s*\n)",
1062+
r"(?m)(^[ \t]*networks:[ \t]*\n(?:[^\n]*\n)*?^[ \t]*milvus:[ \t]*\n)([ \t]*name:[ \t]*milvus[ \t]*\n)",
10631063
r"\1",
10641064
sanitized,
10651065
)

bindings/python/examples/12_vector_search.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,10 +1248,10 @@ def ensure_milvus_compose_file(compose_file: Path, release_tag: str) -> None:
12481248
urlretrieve(url, str(compose_file)) # nosec B310
12491249
raw = compose_file.read_text(encoding="utf-8")
12501250

1251-
sanitized = re.sub(r"(?m)^\s*version\s*:\s*.*\n", "", raw)
1252-
sanitized = re.sub(r"(?m)^\s*container_name:\s*.*\n", "", sanitized)
1251+
sanitized = re.sub(r"(?m)^[ \t]*version[ \t]*:[ \t]*[^\n]*\n", "", raw)
1252+
sanitized = re.sub(r"(?m)^[ \t]*container_name:[ \t]*[^\n]*\n", "", sanitized)
12531253
sanitized = re.sub(
1254-
r"(?ms)(^\s*networks:\s*\n(?:.*\n)*?^\s*milvus:\s*\n)(\s*name:\s*milvus\s*\n)",
1254+
r"(?m)(^[ \t]*networks:[ \t]*\n(?:[^\n]*\n)*?^[ \t]*milvus:[ \t]*\n)([ \t]*name:[ \t]*milvus[ \t]*\n)",
12551255
r"\1",
12561256
sanitized,
12571257
)

bindings/python/src/arcadedb_embedded/vector.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ class VectorIndex:
144144
The metric used depends on the `distance_function` parameter during index creation:
145145
146146
1. **EUCLIDEAN** (Default):
147-
- Returns **Similarity Score** (Higher is better).
148-
- Formula: $1 / (1 + d^2)$ where $d$ is Euclidean distance.
149-
- Range: (0.0, 1.0]
150-
- 1.0: Identical vectors
151-
- ~0.0: Very distant vectors
147+
- Returns **Squared Euclidean Distance** (Lower is better).
148+
- Formula: $d^2$ where $d$ is the Euclidean distance.
149+
- Range: [0.0, +inf)
150+
- 0.0: Identical vectors
151+
- Larger values: more distant vectors
152152
153153
2. **COSINE**:
154154
- Returns **Cosine Distance** (Lower is better).
@@ -331,16 +331,6 @@ def _wrap_pair_results(self, pairs):
331331

332332
return wrapped_results
333333

334-
def _uses_reverse_score_sort(self):
335-
try:
336-
idx_to_check = self._get_primary_lsm_index()
337-
return bool(
338-
idx_to_check
339-
and str(idx_to_check.getSimilarityFunction()) == "EUCLIDEAN"
340-
)
341-
except Exception:
342-
return False
343-
344334
def _find_neighbor_pairs(
345335
self,
346336
idx,
@@ -369,7 +359,9 @@ def _find_neighbor_pairs(
369359
return idx.findNeighborsFromVector(java_vector, k)
370360

371361
def _sort_results(self, results):
372-
results.sort(key=lambda item: item[1], reverse=self._uses_reverse_score_sort())
362+
# All similarity functions are exposed as distances (lower is better) by the
363+
# engine's findNeighborsFromVector, so the best matches sort ascending by score.
364+
results.sort(key=lambda item: item[1])
373365
return results
374366

375367
def _collect_search_results(

bindings/python/tests/test_vector.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,8 @@ def test_lsm_euclidean_distance(self, test_db):
10001000
# Create vectors:
10011001
# v1: [0.1, 0.1]
10021002
# v2: [3.1, 4.1] -> Distance to v1 is 5. Squared distance is 25.
1003-
# JVector Euclidean Similarity = 1 / (1 + d^2) = 1 / (1 + 25) = 1/26 ~= 0.038
1003+
# The Python API exposes the squared Euclidean distance (lower is better):
1004+
# origin -> 0.0, point_3_4 -> 25.0
10041005

10051006
vectors = [
10061007
("origin", [0.1, 0.1]),
@@ -1034,23 +1035,23 @@ def test_lsm_euclidean_distance(self, test_db):
10341035
print(f" - {n[0].get('name')}: {n[1]}")
10351036

10361037
# 1. Check exact match (origin)
1037-
# Similarity should be 1.0 (1 / (1 + 0))
1038+
# Squared Euclidean distance should be 0.0
10381039
origin = [n for n in neighbors if str(n[0].get("name")) == "origin"]
10391040
assert len(origin) == 1
10401041
assert (
1041-
abs(origin[0][1] - 1.0) < 0.0001
1042-
), f"Origin similarity should be 1.0, got {origin[0][1]}"
1042+
abs(origin[0][1] - 0.0) < 0.0001
1043+
), f"Origin distance should be 0.0, got {origin[0][1]}"
10431044

10441045
# 2. Check distant point
1045-
# Similarity should be ~0.03846
1046+
# Squared Euclidean distance should be ~25.0
10461047
point = [n for n in neighbors if str(n[0].get("name")) == "point_3_4"]
10471048
assert len(point) == 1
1048-
expected_sim = 1.0 / (1.0 + 25.0)
1049+
expected_distance = 25.0
10491050
assert (
1050-
abs(point[0][1] - expected_sim) < 0.0001
1051-
), f"Point similarity should be {expected_sim}, got {point[0][1]}"
1051+
abs(point[0][1] - expected_distance) < 0.0001
1052+
), f"Point distance should be {expected_distance}, got {point[0][1]}"
10521053

1053-
# 3. Check sorting (Higher score first)
1054+
# 3. Check sorting (lower distance first)
10541055
assert neighbors[0][0].get("name") == "origin", "Best match should be first"
10551056
assert (
10561057
neighbors[1][0].get("name") == "point_3_4"

bolt/pom.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,23 @@
4949
</dependency>
5050
<dependency>
5151
<groupId>com.arcadedb</groupId>
52-
<artifactId>arcadedb-test-utils</artifactId>
52+
<artifactId>arcadedb-server</artifactId>
53+
<version>${project.parent.version}</version>
54+
<scope>test</scope>
55+
<type>test-jar</type>
56+
</dependency>
57+
<dependency>
58+
<groupId>com.arcadedb</groupId>
59+
<artifactId>arcadedb-ha-raft</artifactId>
60+
<version>${project.parent.version}</version>
61+
<scope>test</scope>
62+
</dependency>
63+
<dependency>
64+
<groupId>com.arcadedb</groupId>
65+
<artifactId>arcadedb-ha-raft</artifactId>
5366
<version>${project.parent.version}</version>
5467
<scope>test</scope>
68+
<type>test-jar</type>
5569
</dependency>
5670
</dependencies>
5771
<build>

0 commit comments

Comments
 (0)