Conversation
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
🤖 Augment PR SummarySummary: This PR updates the search index ranking so schema “health” scores influence result ordering. Changes:
Technical Notes: Health is used as a sort key during index construction; the serialized JSONL payload format returned by 🤖 Was this summary useful? React with 👍 or 👎 |
| std::string path; | ||
| std::string title; | ||
| std::string description; | ||
| std::uint8_t health; |
There was a problem hiding this comment.
SearchEntry::health is currently left uninitialized for default-constructed entries (e.g., SearchEntry e;), and make_search() reads it during sorting, which can be UB. Consider giving health a default initializer (e.g., std::uint8_t health{0};) so callers that don’t explicitly set it get deterministic behavior.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
src/index/explorer.h
Outdated
| : "", | ||
| directory_entry.defines("health") | ||
| ? static_cast<std::uint8_t>( | ||
| directory_entry.at("health").to_integer()) |
There was a problem hiding this comment.
When converting JSON health to std::uint8_t, out-of-range (or negative) integers will truncate/wrap, which could silently mis-rank results. Consider validating/clamping the integer value before casting so unexpected input can’t distort ordering.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/search/include/sourcemeta/one/search.h">
<violation number="1" location="src/search/include/sourcemeta/one/search.h:25">
P1: `health` has no default member initializer, so a default-constructed `SearchEntry` leaves it indeterminate. Reading it in the `make_search()` comparator is undefined behavior. Initialize it: `std::uint8_t health{0};`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| std::string path; | ||
| std::string title; | ||
| std::string description; | ||
| std::uint8_t health; |
There was a problem hiding this comment.
P1: health has no default member initializer, so a default-constructed SearchEntry leaves it indeterminate. Reading it in the make_search() comparator is undefined behavior. Initialize it: std::uint8_t health{0};.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/search/include/sourcemeta/one/search.h, line 25:
<comment>`health` has no default member initializer, so a default-constructed `SearchEntry` leaves it indeterminate. Reading it in the `make_search()` comparator is undefined behavior. Initialize it: `std::uint8_t health{0};`.</comment>
<file context>
@@ -22,6 +22,7 @@ struct SearchEntry {
std::string path;
std::string title;
std::string description;
+ std::uint8_t health;
};
</file context>
| std::uint8_t health; | |
| std::uint8_t health{0}; |
There was a problem hiding this comment.
Benchmark Index (community)
Details
| Benchmark suite | Current: 1b87016 | Previous: dd5d964 | Ratio |
|---|---|---|---|
Add one schema (0 existing) |
20 ms |
25 ms |
0.80 |
Add one schema (100 existing) |
25 ms |
26 ms |
0.96 |
Add one schema (1000 existing) |
83 ms |
87 ms |
0.95 |
Add one schema (10000 existing) |
718 ms |
904 ms |
0.79 |
Update one schema (1 existing) |
18 ms |
20 ms |
0.90 |
Update one schema (101 existing) |
26 ms |
27 ms |
0.96 |
Update one schema (1001 existing) |
85 ms |
90 ms |
0.94 |
Update one schema (10001 existing) |
724 ms |
766 ms |
0.95 |
Cached rebuild (1 existing) |
10 ms |
11 ms |
0.91 |
Cached rebuild (101 existing) |
13 ms |
13 ms |
1 |
Cached rebuild (1001 existing) |
37 ms |
38 ms |
0.97 |
Cached rebuild (10001 existing) |
304 ms |
311 ms |
0.98 |
Index 100 schemas |
131 ms |
150 ms |
0.87 |
Index 1000 schemas |
1096 ms |
1004 ms |
1.09 |
Index 10000 schemas |
13885 ms |
14287 ms |
0.97 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Benchmark Index (enterprise)
Details
| Benchmark suite | Current: 1b87016 | Previous: dd5d964 | Ratio |
|---|---|---|---|
Add one schema (0 existing) |
21 ms |
22 ms |
0.95 |
Add one schema (100 existing) |
26 ms |
27 ms |
0.96 |
Add one schema (1000 existing) |
78 ms |
86 ms |
0.91 |
Add one schema (10000 existing) |
667 ms |
867 ms |
0.77 |
Update one schema (1 existing) |
20 ms |
20 ms |
1 |
Update one schema (101 existing) |
26 ms |
26 ms |
1 |
Update one schema (1001 existing) |
78 ms |
87 ms |
0.90 |
Update one schema (10001 existing) |
663 ms |
707 ms |
0.94 |
Cached rebuild (1 existing) |
11 ms |
11 ms |
1 |
Cached rebuild (101 existing) |
13 ms |
14 ms |
0.93 |
Cached rebuild (1001 existing) |
35 ms |
38 ms |
0.92 |
Cached rebuild (10001 existing) |
271 ms |
303 ms |
0.89 |
Index 100 schemas |
119 ms |
131 ms |
0.91 |
Index 1000 schemas |
1098 ms |
1120 ms |
0.98 |
Index 10000 schemas |
13774 ms |
13941 ms |
0.99 |
This comment was automatically generated by workflow using github-action-benchmark.
Signed-off-by: Juan Cruz Viotti jv@jviotti.com