CodeSampleX

샘플

github.com/google/uuid v1.6.0: Generate DCE Security version 2 UUIDs with uuid.NewDCESecurity, uuid.NewDCEPerson, and uuid.NewDCEGroup and extract domain and local ID

검증된 샘플 — golang github.com/google/uuid v1.6.0: Generate DCE Security version 2 UUIDs with uuid.NewDCESecurity, uuid.NewDCEPerson, and uuid.NewDCEGroup and…

sha256:f044aab8470502c56a265bab0cd6494a2d23624dacab295f5c316958bfe6a938

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
2
빌드한 서명 키
2
선언된 환경 linux 24 · ubuntu · glibc 2.39 x64 go wsl

검증 실행 환경

환경 컨트랙트 단계 실행일
go 1.26 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1
2026-08-19
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-07

케이스

HOW
목표
Generate DCE Security version 2 UUIDs with uuid.NewDCESecurity, uuid.NewDCEPerson, and uuid.NewDCEGroup and extract domain and local ID
패키지
심벌
  • uuid.Domain
  • uuid.NewDCEGroup
  • uuid.NewDCEPerson
  • uuid.NewDCESecurity
  • uuid.UUID.Domain
  • uuid.UUID.ID
생성일
2026-08-18T20:18:35Z

컨트랙트

  1. assert NewDCESecurity creates Version 2 UUID with RFC4122 variant for given Domain and ID
  2. assert Domain and ID methods correctly extract embedded domain and local ID from UUIDv2
  3. assert NewDCEPerson creates UUIDv2 with Person domain and current process UID
  4. assert NewDCEGroup creates UUIDv2 with Group domain and current process GID

파일

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract.go

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
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: Generate DCE Security version 2 UUIDs with uuid.NewDCESecurity, uuid.NewDCEPerson, and uuid.NewDCEGroup and extract domain and local ID
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/google/uuid@v1.6.0
Demonstrate these symbols/APIs:
  - uuid.Domain
  - uuid.NewDCEGroup
  - uuid.NewDCEPerson
  - uuid.NewDCESecurity
  - uuid.UUID.Domain
  - uuid.UUID.ID

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.
csx.json
{"case":{"caseId":"case:sha256:3e72c72f85d9ff9b3ff6f02050f8fc29ffd2db696a449728745f9cddf10e8af5","contract":["assert NewDCESecurity creates Version 2 UUID with RFC4122 variant for given Domain and ID","assert Domain and ID methods correctly extract embedded domain and local ID from UUIDv2","assert NewDCEPerson creates UUIDv2 with Person domain and current process UID","assert NewDCEGroup creates UUIDv2 with Group domain and current process GID"],"goal":"Generate DCE Security version 2 UUIDs with uuid.NewDCESecurity, uuid.NewDCEPerson, and uuid.NewDCEGroup and extract domain and local ID","kind":"HOW","packages":["pkg:golang/github.com/google/uuid@v1.6.0"],"schemaVersion":1,"symbols":["uuid.Domain","uuid.NewDCEGroup","uuid.NewDCEPerson","uuid.NewDCESecurity","uuid.UUID.Domain","uuid.UUID.ID"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1,"virtualization":"wsl"},"license":"MIT-0","packages":["pkg:golang/github.com/google/uuid@v1.6.0"],"schemaVersion":1,"symbols":["uuid.Domain","uuid.NewDCEGroup","uuid.NewDCEPerson","uuid.NewDCESecurity","uuid.UUID.Domain","uuid.UUID.ID"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.22

require github.com/google/uuid v1.6.0
go.sum
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
main.go
package main

import (
	"fmt"

	"github.com/google/uuid"
)

func main() {
	// 1. Generate DCE Security (UUIDv2) with explicit Domain and ID
	const customID uint32 = 1001
	dceUUID, err := uuid.NewDCESecurity(uuid.Person, customID)
	if err != nil {
		fmt.Printf("Failed to generate DCE UUID: %v\n", err)
		return
	}

	fmt.Printf("DCE UUID:      %s\n", dceUUID.String())
	fmt.Printf("Version:       %d\n", dceUUID.Version())
	fmt.Printf("Variant:       %s\n", dceUUID.Variant())
	fmt.Printf("Domain:        %s (%d)\n", dceUUID.Domain(), dceUUID.Domain())
	fmt.Printf("Local ID:      %d\n", dceUUID.ID())

	// 2. Generate DCE UUID for current process user (Person domain)
	personUUID, err := uuid.NewDCEPerson()
	if err != nil {
		fmt.Printf("Failed to generate DCE Person UUID: %v\n", err)
		return
	}
	fmt.Printf("Person UUID:   %s (UID=%d, Domain=%s)\n", personUUID.String(), personUUID.ID(), personUUID.Domain())

	// 3. Generate DCE UUID for current process group (Group domain)
	groupUUID, err := uuid.NewDCEGroup()
	if err != nil {
		fmt.Printf("Failed to generate DCE Group UUID: %v\n", err)
		return
	}
	fmt.Printf("Group UUID:    %s (GID=%d, Domain=%s)\n", groupUUID.String(), groupUUID.ID(), groupUUID.Domain())
}
spec.json
{
  "schemaVersion": 1,
  "goal": "Generate DCE Security version 2 UUIDs with uuid.NewDCESecurity, uuid.NewDCEPerson, and uuid.NewDCEGroup and extract domain and local ID",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/google/uuid@v1.6.0"
  ],
  "symbols": [
    "uuid.Domain",
    "uuid.NewDCEGroup",
    "uuid.NewDCEPerson",
    "uuid.NewDCESecurity",
    "uuid.UUID.Domain",
    "uuid.UUID.ID"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"github.com/google/uuid"
)

func main() {
	// 1. assert NewDCESecurity creates Version 2 UUID with RFC4122 variant for given Domain and ID
	const testID uint32 = 42000
	u, err := uuid.NewDCESecurity(uuid.Org, testID)
	if err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: uuid.NewDCESecurity failed: %v\n", err)
		os.Exit(1)
	}

	if u.Version() != 2 {
		fmt.Fprintf(os.Stderr, "FAIL: expected Version 2, got %d\n", u.Version())
		os.Exit(1)
	}

	if u.Variant() != uuid.RFC4122 {
		fmt.Fprintf(os.Stderr, "FAIL: expected Variant RFC4122, got %s\n", u.Variant())
		os.Exit(1)
	}

	// 2. assert Domain and ID methods correctly extract embedded domain and local ID from UUIDv2
	if u.Domain() != uuid.Org {
		fmt.Fprintf(os.Stderr, "FAIL: expected Domain Org (%d), got %s (%d)\n", uuid.Org, u.Domain(), u.Domain())
		os.Exit(1)
	}

	if u.ID() != testID {
		fmt.Fprintf(os.Stderr, "FAIL: expected ID %d, got %d\n", testID, u.ID())
		os.Exit(1)
	}

	// Also verify Person domain with explicit ID
	uPerson, err := uuid.NewDCESecurity(uuid.Person, 12345)
	if err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: uuid.NewDCESecurity(Person) failed: %v\n", err)
		os.Exit(1)
	}
	if uPerson.Domain() != uuid.Person || uPerson.ID() != 12345 {
		fmt.Fprintf(os.Stderr, "FAIL: uPerson Domain/ID mismatch: domain=%s, id=%d\n", uPerson.Domain(), uPerson.ID())
		os.Exit(1)
	}

	// 3. assert NewDCEPerson creates UUIDv2 with Person domain and current process UID
	personUUID, err := uuid.NewDCEPerson()
	if err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: uuid.NewDCEPerson failed: %v\n", err)
		os.Exit(1)
	}

	if personUUID.Version() != 2 {
		fmt.Fprintf(os.Stderr, "FAIL: personUUID version expected 2, got %d\n", personUUID.Version())
		os.Exit(1)
	}
	if personUUID.Variant() != uuid.RFC4122 {
		fmt.Fprintf(os.Stderr, "FAIL: personUUID variant expected RFC4122, got %s\n", personUUID.Variant())
		os.Exit(1)
	}
	if personUUID.Domain() != uuid.Person {
		fmt.Fprintf(os.Stderr, "FAIL: personUUID expected Domain Person, got %s\n", personUUID.Domain())
		os.Exit(1)
	}
	expectedUID := uint32(os.Getuid())
	if personUUID.ID() != expectedUID {
		fmt.Fprintf(os.Stderr, "FAIL: personUUID expected ID %d (UID), got %d\n", expectedUID, personUUID.ID())
		os.Exit(1)
	}

	// 4. assert NewDCEGroup creates UUIDv2 with Group domain and current process GID
	groupUUID, err := uuid.NewDCEGroup()
	if err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: uuid.NewDCEGroup failed: %v\n", err)
		os.Exit(1)
	}

	if groupUUID.Version() != 2 {
		fmt.Fprintf(os.Stderr, "FAIL: groupUUID version expected 2, got %d\n", groupUUID.Version())
		os.Exit(1)
	}
	if groupUUID.Variant() != uuid.RFC4122 {
		fmt.Fprintf(os.Stderr, "FAIL: groupUUID variant expected RFC4122, got %s\n", groupUUID.Variant())
		os.Exit(1)
	}
	if groupUUID.Domain() != uuid.Group {
		fmt.Fprintf(os.Stderr, "FAIL: groupUUID expected Domain Group, got %s\n", groupUUID.Domain())
		os.Exit(1)
	}
	expectedGID := uint32(os.Getgid())
	if groupUUID.ID() != expectedGID {
		fmt.Fprintf(os.Stderr, "FAIL: groupUUID expected ID %d (GID), got %d\n", expectedGID, groupUUID.ID())
		os.Exit(1)
	}

	fmt.Println("PASS: all uuid.NewDCESecurity contract assertions satisfied")
}

오리진 시더

익명