schemedecl

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package schemedecl implements the CLC-1.19 scheme declaration pilot: the `quantity` domain and the declaration validation it depends on.

The pilot deliberately stays outside the core comparison code. A declaration is applied as a *normalization layer*: each declared `quantity` value is checked against the declaration's fixed unit and rewritten as its normalized number before the ordinary CLC relations run. That keeps `Entails` and `Contains` untouched while making the new domain testable end to end.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DigestOf

func DigestOf(raw []byte) (string, error)

DigestOf computes the declaration's digest for a raw object (test helper).

Types

type Capability

type Capability struct {
	Params map[string]Param `json:"params"`
}

Capability is one capability's parameter declarations.

type Declaration

type Declaration struct {
	Version         string                `json:"@version"`
	Scheme          string                `json:"scheme"`
	DeclarationID   string                `json:"declaration_id"`
	CLCRevision     string                `json:"clc_revision"`
	Digest          string                `json:"digest"`
	Capabilities    map[string]Capability `json:"capabilities"`
	ConstraintTypes []string              `json:"constraint_types,omitempty"`
}

Declaration is a CLC-SCHEME-v1 artifact.

func Load

func Load(path string) (*Declaration, error)

Load reads a declaration file.

func (*Declaration) Authorize

func (d *Declaration) Authorize(capability string, grants []semantics.Grant, op semantics.Operation) semantics.Decision

Authorize applies the declaration's quantity normalization, then runs the ordinary multi-grant authorization.

func (*Declaration) Contains

func (d *Declaration) Contains(capability string, parent, child semantics.Grant) (bool, string)

Contains applies the same normalization and then the ordinary relation. A unit mismatch is a containment failure (`params_not_narrower`), per §13.4.3.

func (*Declaration) DomainMap

func (d *Declaration) DomainMap(capability string) semantics.DomainMap

DomainMap exposes the declaration's per-parameter domain spec for one capability. Callers outside this package use it to drive the CLC-1.19 `*WithDomains` relations; an unknown capability yields nil, which restores the shape-inferred default.

func (*Declaration) Validate

func (d *Declaration) Validate() error

Validate checks the closed shape, the known domains, the quantity unit rule and the digest.

type Param

type Param struct {
	Domain   string `json:"domain"`
	Unit     string `json:"unit,omitempty"`
	Optional bool   `json:"optional,omitempty"`
}

Param is one declared parameter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL