refactor(stockholm): extract kiloDefaultValue with provenance comment

The Stockholm "kilo" constant (a7928d7b43dcd49f0af31e5aeed26458) was
duplicated as a string literal in bridge.go and state.go. To a future
reader the hex blob can read like a leaked secret, which it is not —
it's a published default carried over from the upstream
krahl/soundcork-stockholm-app project (BackendApplication.java). The
Stockholm JS expects exactly this value via getConstant("kilo") when
nothing else has stored a different one.

Promote to a named const in util.go with the explanation, and reference
it from both call sites. Tests keep the literal so they continue to
catch any accidental change to the wire value.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tobias Gesellchen
2026-05-17 12:16:00 +02:00
co-authored by Claude Opus 4.7
parent c5ebf3033b
commit 0df32a36e3
3 changed files with 11 additions and 3 deletions
+1 -1
View File
@@ -140,7 +140,7 @@ func (b *Bridge) dispatch(clientID string, req appSendRequest) {
val := b.state.Get("constant." + name)
if val == "" && name == "kilo" {
val = "a7928d7b43dcd49f0af31e5aeed26458"
val = kiloDefaultValue
}
b.enqueueResult(clientID, id, val, "")
+1 -2
View File
@@ -65,9 +65,8 @@ func (s *NativeState) SeedFromEnv(cfg *Config) {
updates["margeAccountID"] = v
}
// Default constant
if s.Get("constant.kilo") == "" {
updates["constant.kilo"] = "a7928d7b43dcd49f0af31e5aeed26458"
updates["constant.kilo"] = kiloDefaultValue
}
// First-run defaults that require a persisted value
+9
View File
@@ -5,6 +5,15 @@ import (
"encoding/hex"
)
// kiloDefaultValue is the published default for the Stockholm "kilo"
// constant, carried over from the upstream krahl/soundcork-stockholm-app
// project (BackendApplication.java). Not a secret — this is the exact
// value the Stockholm JS expects to read via getConstant("kilo") when
// nothing else has stored a different one. Seeded into NativeState on
// first run; also returned by the bridge as a fallback if the state
// entry is missing.
const kiloDefaultValue = "a7928d7b43dcd49f0af31e5aeed26458"
func randomHexUUID() string {
b := make([]byte, 16)
_, _ = rand.Read(b)