From a95b06ca0233019f5a7fba6f32fac7a5de8ab2d5 Mon Sep 17 00:00:00 2001 From: "anna.cai" Date: Thu, 9 Jul 2026 15:50:24 -0400 Subject: [PATCH] Change Policy.id from UUID struct to string --- fbs-schema/policy.fbs | 12 ++++------- go/schema/dd/wls/Policy.go | 21 ++++++++---------- go/schema/dd/wls/UUID.go | 44 -------------------------------------- 3 files changed, 13 insertions(+), 64 deletions(-) delete mode 100644 go/schema/dd/wls/UUID.go diff --git a/fbs-schema/policy.fbs b/fbs-schema/policy.fbs index 9516148..b558277 100644 --- a/fbs-schema/policy.fbs +++ b/fbs-schema/policy.fbs @@ -9,11 +9,6 @@ include "nodes.fbs"; namespace dd.wls; -/// unfortunetly flatbuffers doesnt support fixed size arrays in go so we can't use it -/// the solution is to split it into two unsigned longs :( -/// this should be populate after caculation, and removed prior to verification. -struct UUID { hi:ulong; lo:ulong; } - /// Represents a policy that contains rules and actions. /// The rules are represented as a tree structure where each node can be a leaf (with an evaluator) or a root (with child nodes). table Policy { @@ -23,9 +18,10 @@ table Policy { rules: NodeTypeWrapper; // this is a tree /// The actions are taken post evaluation of the policy. actions: [Action]; - /// 128 bit UUID represented as 16 raw bytes - /// this can be used to verify integrity (but NOT origin - this is not a signature!) - id:UUID; + /// Stable identifier for this policy, used to attribute an evaluation outcome + /// back to its source. For Remote Config policies this is the rule's UUID; + /// for hardcoded/built-in policies it is the sentinel "hardcoded". + id:string; /// used to track the version number of this policy version: long=0; } diff --git a/go/schema/dd/wls/Policy.go b/go/schema/dd/wls/Policy.go index 51d2b26..d3c66ef 100644 --- a/go/schema/dd/wls/Policy.go +++ b/go/schema/dd/wls/Policy.go @@ -90,23 +90,20 @@ func (rcv *Policy) ActionsLength() int { } /// The actions are taken post evaluation of the policy. -/// 128 bit UUID represented as 16 raw bytes -/// this can be used to verify integrity (but NOT origin - this is not a signature!) -func (rcv *Policy) Id(obj *UUID) *UUID { +/// Stable identifier for this policy, used to attribute an evaluation outcome +/// back to its source. For Remote Config policies this is the rule's UUID; +/// for hardcoded/built-in policies it is the sentinel "hardcoded". +func (rcv *Policy) Id() []byte { o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) if o != 0 { - x := o + rcv._tab.Pos - if obj == nil { - obj = new(UUID) - } - obj.Init(rcv._tab.Bytes, x) - return obj + return rcv._tab.ByteVector(o + rcv._tab.Pos) } return nil } -/// 128 bit UUID represented as 16 raw bytes -/// this can be used to verify integrity (but NOT origin - this is not a signature!) +/// Stable identifier for this policy, used to attribute an evaluation outcome +/// back to its source. For Remote Config policies this is the rule's UUID; +/// for hardcoded/built-in policies it is the sentinel "hardcoded". /// used to track the version number of this policy func (rcv *Policy) Version() int64 { o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) @@ -137,7 +134,7 @@ func PolicyStartActionsVector(builder *flatbuffers.Builder, numElems int) flatbu return builder.StartVector(4, numElems, 4) } func PolicyAddId(builder *flatbuffers.Builder, id flatbuffers.UOffsetT) { - builder.PrependStructSlot(3, flatbuffers.UOffsetT(id), 0) + builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(id), 0) } func PolicyAddVersion(builder *flatbuffers.Builder, version int64) { builder.PrependInt64Slot(4, version, 0) diff --git a/go/schema/dd/wls/UUID.go b/go/schema/dd/wls/UUID.go deleted file mode 100644 index f8a9a24..0000000 --- a/go/schema/dd/wls/UUID.go +++ /dev/null @@ -1,44 +0,0 @@ -// Code generated by the FlatBuffers compiler. DO NOT EDIT. - -package wls - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -/// unfortunetly flatbuffers doesnt support fixed size arrays in go so we can't use it -/// the solution is to split it into two unsigned longs :( -/// this should be populate after caculation, and removed prior to verification. -type UUID struct { - _tab flatbuffers.Struct -} - -func (rcv *UUID) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *UUID) Table() flatbuffers.Table { - return rcv._tab.Table -} - -func (rcv *UUID) Hi() uint64 { - return rcv._tab.GetUint64(rcv._tab.Pos + flatbuffers.UOffsetT(0)) -} -func (rcv *UUID) MutateHi(n uint64) bool { - return rcv._tab.MutateUint64(rcv._tab.Pos+flatbuffers.UOffsetT(0), n) -} - -func (rcv *UUID) Lo() uint64 { - return rcv._tab.GetUint64(rcv._tab.Pos + flatbuffers.UOffsetT(8)) -} -func (rcv *UUID) MutateLo(n uint64) bool { - return rcv._tab.MutateUint64(rcv._tab.Pos+flatbuffers.UOffsetT(8), n) -} - -func CreateUUID(builder *flatbuffers.Builder, hi uint64, lo uint64) flatbuffers.UOffsetT { - builder.Prep(8, 16) - builder.PrependUint64(lo) - builder.PrependUint64(hi) - return builder.Offset() -}