I was tracing processAuditRequested and noticed something that looks like a unit-conversion bug between the off-chain scorer and the V2 contract schema.
In sandbox/src/audit/dimensionalScoring.ts:107-113, each per-dimension score is an integer in the range 0..100:
for (const dim of ALL_DIMENSIONS) {
const scores = dimensionScores[dim];
if (scores.length > 0) {
const avg = scores.reduce((sum, s) => sum + s, 0) / scores.length;
dimensions[dim] = Math.round(avg);
}
}
Then processAuditRequested.ts:67-74 multiplies each by 100 before writeback:
dimensionalScores = {
security: dimScores.dimensions.security * 100,
taskExecution: dimScores.dimensions.task_execution * 100,
...
};
But DimensionalScores in contracts/src/AgentAuditRegistryV2.sol:22-29 is declared as:
struct DimensionalScores {
uint16 security; // 0-10000 basis points
uint16 taskExecution;
...
}
So a score of 100 (i.e. "100%") becomes 10000 basis points, which is the documented max — that part is fine. But a score of 100 already represents 100%; multiplying every dimension by 100 means a 47% score gets written as 4700, which the radar chart then reads back via useAgentRiskProfile and passes to RadarScoreChart whose PolarRadiusAxis domain={[0, 100]}. The radar will saturate at 100 for almost every audit.
Either:
- the contract comment should say "0-10000 basis points" but the off-chain computation should produce 0-100 percent and have the writeback step do the ×100, and the frontend (
RiskProfileCard.toRadarData) should divide by 100 before passing to the chart, or
- the multiplication in
processAuditRequested.ts should be removed and the contract field renamed to 0..100.
Right now there is no division anywhere in the frontend before the radar render. Could you clarify which side owns the unit conversion?
I was tracing
processAuditRequestedand noticed something that looks like a unit-conversion bug between the off-chain scorer and the V2 contract schema.In
sandbox/src/audit/dimensionalScoring.ts:107-113, each per-dimension score is an integer in the range0..100:Then
processAuditRequested.ts:67-74multiplies each by 100 before writeback:But
DimensionalScoresincontracts/src/AgentAuditRegistryV2.sol:22-29is declared as:So a score of
100(i.e. "100%") becomes10000basis points, which is the documented max — that part is fine. But a score of100already represents 100%; multiplying every dimension by 100 means a 47% score gets written as4700, which the radar chart then reads back viauseAgentRiskProfileand passes toRadarScoreChartwhosePolarRadiusAxisdomain={[0, 100]}. The radar will saturate at 100 for almost every audit.Either:
RiskProfileCard.toRadarData) should divide by 100 before passing to the chart, orprocessAuditRequested.tsshould be removed and the contract field renamed to0..100.Right now there is no division anywhere in the frontend before the radar render. Could you clarify which side owns the unit conversion?