mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-10-06 11:48:24 +00:00
Build items 11 and 12. JCS lands in quartz/utils as a generic primitive since
ContextVM needs it twice (CEP-8's canonical invocation identity, CEP-15's
schema hash) and nothing about it is ContextVM-specific.
The number rule is the whole difficulty: RFC 8785 requires ECMAScript's
Number::toString, which no JVM/Kotlin toString produces -- 1.0E30 where
ECMAScript says 1e+30. The (s, n, k) formulation is implemented directly,
including the exponential boundaries at 1e21 and 1e-7 and the plus sign on a
positive exponent.
A real divergence surfaced here and the edge-case test is what caught it: JVM
prints Double.MIN_VALUE as 4.9E-324 while ECMAScript requires 5e-324, so the
initial "trust the platform to already be shortest" approach would have hashed
differently from every other conformant implementation. Digits are now
shortened explicitly until the shortest form that still round-trips is found,
which also removes the platform assumption entirely.
CEP-15 sits on top: annotation keywords (title, description, examples, default,
deprecated, readOnly, writeOnly) and x-* vendor extensions are stripped at
every nesting level including inside arrays, then {name, inputSchema,
outputSchema?} is canonicalized and hashed. The client-side rule is that the
advertised schemaHash is a verification target rather than a label, so verify()
recomputes from the tool definition and returns false on a mismatch instead of
trusting it.
Also replaced a raw U+000C that the editor had normalised into the source with
its escape, per the CLAUDE.md rule, and scanned the rest of the new files.
13 CVM-15-* tests plus 17 JCS conformance tests. Module suite at 89.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012BfD4txdnsaPRXmNXbup9n