access-engine/internal/decision/json_profile.go
tegwick ca0cb75729
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s
Build and Publish Container Image / build-and-push (push) Successful in 1m22s
Add producer-owned authenticated Go decision client and validated Forgejo profile
Assistant: codex
Assistant-Model: gpt-6.1-sol
Assistant-Session: 01a14bfc-9643-7872-aa12-98326dcf25e7
2026-10-18 01:20:05 +02:00

25 lines
959 B
Go

package decision
import "context"
// LosslessJSONProfile is an explicit optional wire decoder profile for the
// normal /v1/check handler. Legacy callers retain their original float64
// projection. The canonical request and signature algorithms are unchanged.
const LosslessJSONProfile = "lossless-json-v1"
const losslessStandaloneMode = "standalone/lossless-json-v1"
type jsonProfileContextKey struct{}
// WithLosslessJSONProfile is called only by the producer after selecting its
// UseNumber decoder. No request/body flag can install this context key. The
// signed provenance mode authenticates which decoder produced the decision.
func WithLosslessJSONProfile(ctx context.Context) context.Context {
return context.WithValue(ctx, jsonProfileContextKey{}, LosslessJSONProfile)
}
func envelopeMode(ctx context.Context) string {
if ctx.Value(jsonProfileContextKey{}) == LosslessJSONProfile {
return losslessStandaloneMode
}
return "standalone"
}