샘플
cel.dev/expr v0.24.0: Constant, Expr, ParsedExpr
검증된 샘플 — golang cel.dev/expr v0.24.0: Constant, Expr, ParsedExpr. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: expr.Constant represents typed…
sha256:5f2494510c703d49dd2e8ef62a92dbaf505c15e12eb459a88104391d93b1d596
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-15 |
케이스
HOW- 목표
- verify pkg:golang/cel.dev/expr@v0.24.0
- 심벌
-
- cel.dev/expr.Constant
- cel.dev/expr.Expr
- cel.dev/expr.ParsedExpr
- cel.dev/expr.Type
- cel.dev/expr.CheckedExpr
- 환경
- go 1.26.6
- 생성일
- 2026-09-15T19:25:23Z
컨트랙트
- expr.Constant represents typed constant values such as bool, int64, and string
- expr.Expr constructs abstract syntax tree nodes for expressions including ident and call
- expr.ParsedExpr holds parsed expression AST and source info serializable via protobuf
- expr.Type defines primitive, list, and map type specifications
- expr.CheckedExpr associates AST nodes with resolved types and reference maps
파일
- PROMPT.md
- contract_test.go
- csx.json
- go.mod
- go.sum
- spec.json
소스
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:golang/cel.dev/expr@v0.24.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/cel.dev/expr@v0.24.0
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
package sample_test
import (
"testing"
expr "cel.dev/expr"
"google.golang.org/protobuf/proto"
)
func TestConstantConstruction(t *testing.T) {
// 1. Construct constant values of different types
boolConst := &expr.Constant{
ConstantKind: &expr.Constant_BoolValue{BoolValue: true},
}
if !boolConst.GetBoolValue() {
t.Fatal("expected GetBoolValue() to be true")
}
intConst := &expr.Constant{
ConstantKind: &expr.Constant_Int64Value{Int64Value: 42},
}
if intConst.GetInt64Value() != 42 {
t.Fatalf("expected GetInt64Value() == 42, got %d", intConst.GetInt64Value())
}
strConst := &expr.Constant{
ConstantKind: &expr.Constant_StringValue{StringValue: "hello cel"},
}
if strConst.GetStringValue() != "hello cel" {
t.Fatalf("expected GetStringValue() == 'hello cel', got %s", strConst.GetStringValue())
}
}
func TestExprAstConstruction(t *testing.T) {
// 2. Build an AST expression node: id == 1
lhs := &expr.Expr{
Id: 1,
ExprKind: &expr.Expr_IdentExpr{
IdentExpr: &expr.Expr_Ident{
Name: "x",
},
},
}
rhs := &expr.Expr{
Id: 2,
ExprKind: &expr.Expr_ConstExpr{
ConstExpr: &expr.Constant{
ConstantKind: &expr.Constant_Int64Value{Int64Value: 100},
},
},
}
root := &expr.Expr{
Id: 3,
ExprKind: &expr.Expr_CallExpr{
CallExpr: &expr.Expr_Call{
Function: "_==_",
Args: []*expr.Expr{lhs, rhs},
},
},
}
call := root.GetCallExpr()
if call == nil {
t.Fatal("expected GetCallExpr() to return non-nil")
}
if call.GetFunction() != "_==_" {
t.Fatalf("expected function '_==_', got %s", call.GetFunction())
}
if len(call.GetArgs()) != 2 {
t.Fatalf("expected 2 args, got %d", len(call.GetArgs()))
}
if call.GetArgs()[0].GetIdentExpr().GetName() != "x" {
t.Fatalf("expected arg[0] ident 'x', got %s", call.GetArgs()[0].GetIdentExpr().GetName())
}
if call.GetArgs()[1].GetConstExpr().GetInt64Value() != 100 {
t.Fatalf("expected arg[1] const 100, got %d", call.GetArgs()[1].GetConstExpr().GetInt64Value())
}
}
func TestParsedExprSerialization(t *testing.T) {
// 3. Construct ParsedExpr and serialize/deserialize via protobuf
parsed := &expr.ParsedExpr{
Expr: &expr.Expr{
Id: 1,
ExprKind: &expr.Expr_ConstExpr{
ConstExpr: &expr.Constant{
ConstantKind: &expr.Constant_StringValue{StringValue: "sample"},
},
},
},
SourceInfo: &expr.SourceInfo{
Location: "sample.cel",
LineOffsets: []int32{0, 10, 25},
Positions: map[int64]int32{
1: 0,
},
},
}
data, err := proto.Marshal(parsed)
if err != nil {
t.Fatalf("proto.Marshal failed: %v", err)
}
var unmarshaled expr.ParsedExpr
if err := proto.Unmarshal(data, &unmarshaled); err != nil {
t.Fatalf("proto.Unmarshal failed: %v", err)
}
if unmarshaled.GetSourceInfo().GetLocation() != "sample.cel" {
t.Fatalf("expected location 'sample.cel', got %s", unmarshaled.GetSourceInfo().GetLocation())
}
if unmarshaled.GetExpr().GetConstExpr().GetStringValue() != "sample" {
t.Fatalf("expected const value 'sample', got %s", unmarshaled.GetExpr().GetConstExpr().GetStringValue())
}
}
func TestTypeConstruction(t *testing.T) {
// 4. Construct primitive and composite Type definitions
primitiveType := &expr.Type{
TypeKind: &expr.Type_Primitive{
Primitive: expr.Type_INT64,
},
}
if primitiveType.GetPrimitive() != expr.Type_INT64 {
t.Fatalf("expected Primitive INT64, got %v", primitiveType.GetPrimitive())
}
listType := &expr.Type{
TypeKind: &expr.Type_ListType_{
ListType: &expr.Type_ListType{
ElemType: primitiveType,
},
},
}
if listType.GetListType() == nil || listType.GetListType().GetElemType().GetPrimitive() != expr.Type_INT64 {
t.Fatal("expected ListType with INT64 element type")
}
mapType := &expr.Type{
TypeKind: &expr.Type_MapType_{
MapType: &expr.Type_MapType{
KeyType: &expr.Type{
TypeKind: &expr.Type_Primitive{
Primitive: expr.Type_STRING,
},
},
ValueType: primitiveType,
},
},
}
if mapType.GetMapType() == nil || mapType.GetMapType().GetKeyType().GetPrimitive() != expr.Type_STRING {
t.Fatal("expected MapType with STRING key type")
}
}
func TestCheckedExprConstruction(t *testing.T) {
// 5. Construct CheckedExpr with TypeMap and ReferenceMap
checked := &expr.CheckedExpr{
Expr: &expr.Expr{
Id: 1,
ExprKind: &expr.Expr_IdentExpr{
IdentExpr: &expr.Expr_Ident{Name: "authenticated"},
},
},
TypeMap: map[int64]*expr.Type{
1: {
TypeKind: &expr.Type_Primitive{
Primitive: expr.Type_BOOL,
},
},
},
ReferenceMap: map[int64]*expr.Reference{
1: {
Name: "authenticated",
},
},
SourceInfo: &expr.SourceInfo{
Location: "auth_rule.cel",
},
}
if checked.GetTypeMap()[1].GetPrimitive() != expr.Type_BOOL {
t.Fatalf("expected TypeMap[1] to be BOOL, got %v", checked.GetTypeMap()[1].GetPrimitive())
}
if checked.GetReferenceMap()[1].GetName() != "authenticated" {
t.Fatalf("expected ReferenceMap[1] name 'authenticated', got %s", checked.GetReferenceMap()[1].GetName())
}
}
{"case":{"caseId":"case:sha256:43102c3e399776b929c0e08e01a9642e9e2d61cf21fb8d9e0b1f3f2e23394add","contract":["expr.Constant represents typed constant values such as bool, int64, and string","expr.Expr constructs abstract syntax tree nodes for expressions including ident and call","expr.ParsedExpr holds parsed expression AST and source info serializable via protobuf","expr.Type defines primitive, list, and map type specifications","expr.CheckedExpr associates AST nodes with resolved types and reference maps"],"goal":"verify pkg:golang/cel.dev/expr@v0.24.0","kind":"HOW","packages":["pkg:golang/cel.dev/expr@v0.24.0"],"schemaVersion":1,"symbols":["cel.dev/expr.Constant","cel.dev/expr.Expr","cel.dev/expr.ParsedExpr","cel.dev/expr.Type","cel.dev/expr.CheckedExpr"]},"contractCommand":["go","test","-v","./..."],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/cel.dev/expr@v0.24.0"],"schemaVersion":1,"subject":"pkg:golang/cel.dev/expr@v0.24.0","symbols":["cel.dev/expr.Constant","cel.dev/expr.Expr","cel.dev/expr.ParsedExpr","cel.dev/expr.Type","cel.dev/expr.CheckedExpr"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require (
cel.dev/expr v0.24.0
google.golang.org/protobuf v1.34.2
)
cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY=
cel.dev/expr v0.24.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
{
"schemaVersion": 1,
"goal": "verify pkg:golang/cel.dev/expr@v0.24.0",
"kind": "HOW",
"packages": [
"pkg:golang/cel.dev/expr@v0.24.0"
]
}
오리진 시더
익명