サンプル
github.com/mholt/acmez/v3 v3.1.2: acme.Problem
検証済みサンプル — golang github.com/mholt/acmez/v3 v3.1.2: acme.Problem. go 1.26 · linux alpine/x64 · docker で contract を実行し、成功しました: Problem parses RFC 7807 problem…
sha256:8111589e33dd8401ed0f53f54a87af380a1e881a4bcf2fd74d696606b1311457
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
go linux 24 · ubuntu · glibc 2.39 x64 go go go
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-28 |
ケース
HOW- ゴール
- verify github.com/mholt/acmez/v3/acme.Problem in pkg:golang/github.com/mholt/acmez/v3@v3.1.2
- シンボル
-
- github.com/mholt/acmez/v3/acme.Problem
- 環境
- go
- 作成日
- 2026-08-28T01:43:27Z
コントラクト
- Problem parses RFC 7807 problem details JSON with Type, Title, Status, Detail, Instance, and Subproblems.
- Problem.Error formats status code, problem type, detail message, subproblems with identifiers, and instance URL.
- Problem.LogValue produces structured slog.GroupValue attributes containing type, title, detail, instance, and subproblems.
- Subproblem embeds Problem and adds an Identifier with Type and Value fields.
- errors.As matches wrapped acme.Problem errors and enables inspection of standard ACME ProblemType constants.
- Problem omits empty optional fields (title, detail, status, instance, subproblems) and non-exported Resource during JSON marshaling.
ファイル
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- problem_test.go
- 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 github.com/mholt/acmez/v3/acme.Problem in pkg:golang/github.com/mholt/acmez/v3@v3.1.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/mholt/acmez/v3@v3.1.2
Demonstrate these symbols/APIs:
- github.com/mholt/acmez/v3/acme.Problem
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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.
{"case":{"caseId":"case:sha256:837519a93156c6445019fff8959898c2960e050073fc02ab96435a55a0c097ab","contract":["Problem parses RFC 7807 problem details JSON with Type, Title, Status, Detail, Instance, and Subproblems.","Problem.Error formats status code, problem type, detail message, subproblems with identifiers, and instance URL.","Problem.LogValue produces structured slog.GroupValue attributes containing type, title, detail, instance, and subproblems.","Subproblem embeds Problem and adds an Identifier with Type and Value fields.","errors.As matches wrapped acme.Problem errors and enables inspection of standard ACME ProblemType constants.","Problem omits empty optional fields (title, detail, status, instance, subproblems) and non-exported Resource during JSON marshaling."],"goal":"verify github.com/mholt/acmez/v3/acme.Problem in pkg:golang/github.com/mholt/acmez/v3@v3.1.2","kind":"HOW","packages":["pkg:golang/github.com/mholt/acmez/v3@v3.1.2"],"schemaVersion":1,"symbols":["github.com/mholt/acmez/v3/acme.Problem"]},"contractCommand":["go","test","./..."],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","executionContext":"go","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","runtime":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/mholt/acmez/v3@v3.1.2"],"schemaVersion":1,"subject":"pkg:golang/github.com/mholt/acmez/v3@v3.1.2","symbols":["github.com/mholt/acmez/v3/acme.Problem"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/mholt/acmez/v3 v3.1.2
github.com/mholt/acmez/v3 v3.1.2 h1:auob8J/0FhmdClQicvJvuDavgd5ezwLBfKuYmynhYzc=
github.com/mholt/acmez/v3 v3.1.2/go.mod h1:L1wOU06KKvq7tswuMDwKdcHeKpFFgkppZy/y0DFxagQ=
package main
import (
"encoding/json"
"errors"
"fmt"
"os"
"github.com/mholt/acmez/v3/acme"
)
// ParseProblem parses RFC 7807 problem details JSON into an acme.Problem.
func ParseProblem(data []byte) (acme.Problem, error) {
var prob acme.Problem
if err := json.Unmarshal(data, &prob); err != nil {
return acme.Problem{}, fmt.Errorf("decoding problem JSON: %w", err)
}
return prob, nil
}
// IsProblemType checks if an error represents an ACME problem with the specified problem type URI.
func IsProblemType(err error, problemType string) bool {
var prob acme.Problem
if errors.As(err, &prob) {
return prob.Type == problemType
}
return false
}
func main() {
sampleJSON := `{
"type": "urn:ietf:params:acme:error:rateLimited",
"title": "Too Many Requests",
"status": 429,
"detail": "Rate limit exceeded for client",
"instance": "https://example.com/acme/order/100",
"subproblems": [
{
"type": "urn:ietf:params:acme:error:rejectedIdentifier",
"detail": "Domain rate limit exceeded",
"identifier": {
"type": "dns",
"value": "example.com"
}
}
]
}`
prob, err := ParseProblem([]byte(sampleJSON))
if err != nil {
fmt.Fprintf(os.Stderr, "failed to parse problem: %v\n", err)
os.Exit(1)
}
fmt.Printf("Parsed Problem: %s\n", prob.Error())
if IsProblemType(prob, acme.ProblemTypeRateLimited) {
fmt.Println("Error matched rateLimited ACME problem type")
}
}
package main
import (
"encoding/json"
"errors"
"fmt"
"log/slog"
"strings"
"testing"
"github.com/mholt/acmez/v3/acme"
)
func TestProblem_JSONUnmarshal(t *testing.T) {
// Assertion 1: Problem parses RFC 7807 problem details JSON with Type, Title, Status, Detail, Instance, and Subproblems.
rawJSON := `{
"type": "urn:ietf:params:acme:error:rateLimited",
"title": "Too Many Requests",
"status": 429,
"detail": "Error creating new order :: too many requests for this IP",
"instance": "https://example.com/acme/order/123",
"subproblems": [
{
"type": "urn:ietf:params:acme:error:rejectedIdentifier",
"title": "Rejected",
"status": 400,
"detail": "Identifier rejected: example.org",
"identifier": {
"type": "dns",
"value": "example.org"
}
}
]
}`
prob, err := ParseProblem([]byte(rawJSON))
if err != nil {
t.Fatalf("ParseProblem failed: %v", err)
}
if prob.Type != acme.ProblemTypeRateLimited {
t.Errorf("expected Type %q, got %q", acme.ProblemTypeRateLimited, prob.Type)
}
if prob.Title != "Too Many Requests" {
t.Errorf("expected Title %q, got %q", "Too Many Requests", prob.Title)
}
if prob.Status != 429 {
t.Errorf("expected Status 429, got %d", prob.Status)
}
if prob.Detail != "Error creating new order :: too many requests for this IP" {
t.Errorf("expected Detail mismatch, got %q", prob.Detail)
}
if prob.Instance != "https://example.com/acme/order/123" {
t.Errorf("expected Instance %q, got %q", "https://example.com/acme/order/123", prob.Instance)
}
if len(prob.Subproblems) != 1 {
t.Fatalf("expected 1 subproblem, got %d", len(prob.Subproblems))
}
sub := prob.Subproblems[0]
if sub.Type != acme.ProblemTypeRejectedIdentifier {
t.Errorf("expected Subproblem Type %q, got %q", acme.ProblemTypeRejectedIdentifier, sub.Type)
}
if sub.Title != "Rejected" {
t.Errorf("expected Subproblem Title %q, got %q", "Rejected", sub.Title)
}
if sub.Status != 400 {
t.Errorf("expected Subproblem Status 400, got %d", sub.Status)
}
if sub.Detail != "Identifier rejected: example.org" {
t.Errorf("expected Subproblem Detail %q, got %q", "Identifier rejected: example.org", sub.Detail)
}
if sub.Identifier.Type != "dns" || sub.Identifier.Value != "example.org" {
t.Errorf("expected Subproblem Identifier dns:example.org, got %s:%s", sub.Identifier.Type, sub.Identifier.Value)
}
}
func TestProblem_ErrorFormatting(t *testing.T) {
// Assertion 2: Problem.Error formats status code, problem type, detail message, subproblems with identifiers, and instance URL.
probWithSub := acme.Problem{
Type: acme.ProblemTypeCompound,
Title: "Compound Error",
Status: 400,
Detail: "Multiple subproblems occurred",
Instance: "https://example.com/acme/order/999",
Subproblems: []acme.Subproblem{
{
Problem: acme.Problem{
Type: acme.ProblemTypeInvalidContact,
Detail: "Contact email is invalid",
},
Identifier: acme.Identifier{
Type: "mailto",
Value: "admin@example.com",
},
},
},
}
errStr := probWithSub.Error()
expectedSubStr := "HTTP 400 urn:ietf:params:acme:error:compound - Multiple subproblems occurred, problem \"urn:ietf:params:acme:error:invalidContact\": Contact email is invalid (mailto_identifier=admin@example.com), url: https://example.com/acme/order/999"
if errStr != expectedSubStr {
t.Errorf("Error() mismatch:\n got: %q\n want: %q", errStr, expectedSubStr)
}
// Test simple error without subproblems or instance
simpleProb := acme.Problem{
Type: acme.ProblemTypeBadNonce,
Status: 400,
Detail: "JWS has an invalid anti-replay nonce",
}
if simpleProb.Error() != "HTTP 400 urn:ietf:params:acme:error:badNonce - JWS has an invalid anti-replay nonce" {
t.Errorf("simple Error() mismatch: got %q", simpleProb.Error())
}
}
func TestProblem_LogValue(t *testing.T) {
// Assertion 3: Problem.LogValue produces structured slog.GroupValue attributes containing type, title, detail, instance, and subproblems.
prob := acme.Problem{
Type: acme.ProblemTypeUnauthorized,
Title: "Unauthorized",
Status: 401,
Detail: "Account key does not match",
Instance: "https://example.com/acme/authz/1",
Subproblems: []acme.Subproblem{
{
Problem: acme.Problem{
Type: acme.ProblemTypeDNS,
Detail: "DNS query timed out",
},
Identifier: acme.Identifier{
Type: "dns",
Value: "node.example.com",
},
},
},
}
val := prob.LogValue()
if val.Kind() != slog.KindGroup {
t.Fatalf("expected slog.KindGroup, got %v", val.Kind())
}
attrs := val.Group()
attrMap := make(map[string]slog.Value)
for _, a := range attrs {
attrMap[a.Key] = a.Value
}
if attrMap["type"].String() != acme.ProblemTypeUnauthorized {
t.Errorf("log attr 'type' mismatch: %v", attrMap["type"])
}
if attrMap["title"].String() != "Unauthorized" {
t.Errorf("log attr 'title' mismatch: %v", attrMap["title"])
}
if attrMap["detail"].String() != "Account key does not match" {
t.Errorf("log attr 'detail' mismatch: %v", attrMap["detail"])
}
if attrMap["instance"].String() != "https://example.com/acme/authz/1" {
t.Errorf("log attr 'instance' mismatch: %v", attrMap["instance"])
}
// Test Subproblem.LogValue
sub := prob.Subproblems[0]
subVal := sub.LogValue()
if subVal.Kind() != slog.KindGroup {
t.Fatalf("expected subproblem slog.KindGroup, got %v", subVal.Kind())
}
subAttrMap := make(map[string]slog.Value)
for _, a := range subVal.Group() {
subAttrMap[a.Key] = a.Value
}
if subAttrMap["identifier_type"].String() != "dns" {
t.Errorf("sub log attr 'identifier_type' mismatch: %v", subAttrMap["identifier_type"])
}
if subAttrMap["identifier"].String() != "node.example.com" {
t.Errorf("sub log attr 'identifier' mismatch: %v", subAttrMap["identifier"])
}
}
func TestProblem_SubproblemEmbedding(t *testing.T) {
// Assertion 4: Subproblem embeds Problem and adds an Identifier with Type and Value fields.
sub := acme.Subproblem{
Problem: acme.Problem{
Type: acme.ProblemTypeTLS,
Detail: "TLS certificate validation failed",
Status: 400,
},
Identifier: acme.Identifier{
Type: "dns",
Value: "secure.example.com",
},
}
if sub.Type != acme.ProblemTypeTLS {
t.Errorf("embedded Problem Type mismatch: %q", sub.Type)
}
if sub.Status != 400 {
t.Errorf("embedded Problem Status mismatch: %d", sub.Status)
}
if sub.Detail != "TLS certificate validation failed" {
t.Errorf("embedded Problem Detail mismatch: %q", sub.Detail)
}
if sub.Identifier.Type != "dns" || sub.Identifier.Value != "secure.example.com" {
t.Errorf("Identifier mismatch: %v", sub.Identifier)
}
}
func TestProblem_ErrorsAsAndConstants(t *testing.T) {
// Assertion 5: errors.As matches wrapped acme.Problem errors and enables inspection of standard ACME ProblemType constants.
origProb := acme.Problem{
Type: acme.ProblemTypeAccountDoesNotExist,
Status: 404,
Detail: "The requested account does not exist on this server",
}
wrapped := fmt.Errorf("operation failed during registration: %w", origProb)
var extracted acme.Problem
if !errors.As(wrapped, &extracted) {
t.Fatalf("errors.As failed to extract acme.Problem from wrapped error")
}
if extracted.Type != acme.ProblemTypeAccountDoesNotExist {
t.Errorf("extracted Type mismatch: got %q, want %q", extracted.Type, acme.ProblemTypeAccountDoesNotExist)
}
if extracted.Status != 404 {
t.Errorf("extracted Status mismatch: got %d, want 404", extracted.Status)
}
// Verify standard problem types follow namespace convention
standardTypes := []string{
acme.ProblemTypeAccountDoesNotExist,
acme.ProblemTypeAlreadyRevoked,
acme.ProblemTypeBadCSR,
acme.ProblemTypeBadNonce,
acme.ProblemTypeBadPublicKey,
acme.ProblemTypeBadRevocationReason,
acme.ProblemTypeBadSignatureAlgorithm,
acme.ProblemTypeCAA,
acme.ProblemTypeCompound,
acme.ProblemTypeConnection,
acme.ProblemTypeDNS,
acme.ProblemTypeExternalAccountRequired,
acme.ProblemTypeIncorrectResponse,
acme.ProblemTypeInvalidContact,
acme.ProblemTypeMalformed,
acme.ProblemTypeOrderNotReady,
acme.ProblemTypeRateLimited,
acme.ProblemTypeRejectedIdentifier,
acme.ProblemTypeServerInternal,
acme.ProblemTypeTLS,
acme.ProblemTypeUnauthorized,
acme.ProblemTypeUnsupportedContact,
acme.ProblemTypeUnsupportedIdentifier,
acme.ProblemTypeUserActionRequired,
}
for _, pt := range standardTypes {
if !strings.HasPrefix(pt, acme.ProblemTypeNamespace) {
t.Errorf("standard problem type %q does not start with namespace %q", pt, acme.ProblemTypeNamespace)
}
}
}
func TestProblem_JSONMarshalOmitEmpty(t *testing.T) {
// Assertion 6: Problem omits empty optional fields (title, detail, status, instance, subproblems) and non-exported Resource during JSON marshaling.
pMin := acme.Problem{
Type: acme.ProblemTypeMalformed,
Resource: "arbitrary-internal-pointer",
}
data, err := json.Marshal(pMin)
if err != nil {
t.Fatalf("json.Marshal failed: %v", err)
}
expectedJSON := `{"type":"urn:ietf:params:acme:error:malformed"}`
if string(data) != expectedJSON {
t.Errorf("json.Marshal output mismatch:\n got: %s\n want: %s", string(data), expectedJSON)
}
// Ensure unmarshaling back restores Type and leaves other fields empty / nil
var restored acme.Problem
if err := json.Unmarshal(data, &restored); err != nil {
t.Fatalf("json.Unmarshal failed: %v", err)
}
if restored.Type != acme.ProblemTypeMalformed {
t.Errorf("restored Type mismatch: %q", restored.Type)
}
if restored.Resource != nil {
t.Errorf("restored Resource should be nil, got: %v", restored.Resource)
}
if restored.Title != "" || restored.Detail != "" || restored.Status != 0 || len(restored.Subproblems) != 0 {
t.Errorf("optional fields should be empty in restored problem: %+v", restored)
}
}
{
"schemaVersion": 1,
"goal": "verify github.com/mholt/acmez/v3/acme.Problem in pkg:golang/github.com/mholt/acmez/v3@v3.1.2",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/mholt/acmez/v3@v3.1.2"
],
"symbols": [
"github.com/mholt/acmez/v3/acme.Problem"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
オリジンシーダー
匿名