graph

package
v0.3.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	AgentMaxResources = 1000
	AgentMaxBytes     = 2_000_000
	AgentMaxDepth     = 16
)
View Source
const ContextTokenTTL = 5 * time.Minute
View Source
const ManifestKind = "scenery.manifest"

Variables

View Source
var (
	ManifestSchemaRevision = "sha256:d5b3c19523c452c5fafe25bceac20c42ab1d6de2d285a11615c7d24f21c2c3c7"
	DiagnosticCatalog      = string(spec.SchemaRevision(spec.DiagnosticDefinitions()))
)

Functions

func AppendUniqueString

func AppendUniqueString(values []string, value string) []string

func CanonicalResources

func CanonicalResources(resources []Resource) ([]byte, error)

func ContractProjectionHash

func ContractProjectionHash(manifest *Manifest) string

ContractProjectionHash identifies the canonical contract projection without folding in the current specification revision. It is used only to prove a revision-scheme rebind; executable artifacts remain bound to ContractRevision.

func ContractRevision

func ContractRevision(resources []Resource, appName string) (string, error)

func EnsureFieldProvenance

func EnsureFieldProvenance(resource *Resource, path, stage string)

func IsCanonicalSHA256Digest

func IsCanonicalSHA256Digest(value string) bool

func KindForBlock

func KindForBlock(blockType string) string

func MarkExpansionFieldProvenance

func MarkExpansionFieldProvenance(resource *Resource, generator Resource)

func ModuleResourceAddress

func ModuleResourceAddress(instance string) string

func ProvenanceChildPath

func ProvenanceChildPath(parent, name string) string

func RebaseFieldProvenance

func RebaseFieldProvenance(origin *Origin, from, to string)

func ResourceAddress

func ResourceAddress(module, blockType, name string) string

func RevisionHash

func RevisionHash(prefix string, value any) string

func SetFieldProvenance

func SetFieldProvenance(origin *Origin, path string, value any, field FieldProvenance)

func SetFieldProvenanceTree

func SetFieldProvenanceTree(origin *Origin, value any, path string, field FieldProvenance)

SetFieldProvenanceTree applies provenance to every non-scalar descendant.

func ValidateManifest

func ValidateManifest(manifest *Manifest) error

func WalkReferences

func WalkReferences(value any, path string, visit func(string, string))

Types

type ApplicationIdentity

type ApplicationIdentity struct {
	Name string `json:"name"`
}

type ContextBundle

type ContextBundle struct {
	machine.ArtifactIdentity
	WorkspaceRevision string                    `json:"workspace_revision"`
	ContractRevision  string                    `json:"contract_revision"`
	View              string                    `json:"view"`
	Resources         []Resource                `json:"resources"`
	Schemas           map[string]map[string]any `json:"schemas,omitempty"`
	Diagnostics       []Diagnostic              `json:"diagnostics,omitempty"`
	Provenance        map[string]Origin         `json:"provenance,omitempty"`
	Truncated         bool                      `json:"truncated"`
	ContinuationToken string                    `json:"continuation_token,omitempty"`
}

func Context

func Context(manifest *Manifest, options ContextOptions) (ContextBundle, error)

func ContextAt

func ContextAt(manifest *Manifest, workspaceRevision string, diagnostics []Diagnostic, options ContextOptions, now time.Time) (ContextBundle, error)

func ContextSnapshot

func ContextSnapshot(manifest *Manifest, workspaceRevision string, options ContextOptions) (ContextBundle, error)

func ContextSnapshotWithDiagnostics

func ContextSnapshotWithDiagnostics(manifest *Manifest, workspaceRevision string, diagnostics []Diagnostic, options ContextOptions) (ContextBundle, error)

type ContextOptions

type ContextOptions struct {
	Focus             []string `json:"focus"`
	Include           []string `json:"include,omitempty"`
	Depth             int      `json:"depth,omitempty"`
	MaxResources      int      `json:"max_resources,omitempty"`
	MaxBytes          int      `json:"max_bytes,omitempty"`
	View              string   `json:"view,omitempty"`
	ContinuationToken string   `json:"continuation_token,omitempty"`
}

type ContextToken

type ContextToken struct {
	WorkspaceRevision string `json:"w"`
	ContractRevision  string `json:"c"`
	QueryDigest       string `json:"q"`
	Offset            int    `json:"o"`
	ExpiresUnix       int64  `json:"e"`
}

func ParseContextToken

func ParseContextToken(token string) (ContextToken, error)

type Diagnostic

type Diagnostic struct {
	Code        string         `json:"code"`
	Severity    string         `json:"severity"`
	Message     string         `json:"message"`
	ReportToken string         `json:"report_token,omitempty"`
	Address     string         `json:"address,omitempty"`
	Path        string         `json:"path,omitempty"`
	Range       *scn.Range     `json:"range,omitempty"`
	Related     []Related      `json:"related,omitempty"`
	Suggestions []string       `json:"suggestions,omitempty"`
	Details     map[string]any `json:"details,omitempty"`
}

type ExpansionStep

type ExpansionStep struct {
	Generator               string     `json:"generator"`
	GeneratorSchemaRevision string     `json:"generator_schema_revision"`
	Key                     string     `json:"key"`
	SourceRange             *scn.Range `json:"source_range,omitempty"`
	ParentAddress           string     `json:"parent_address"`
	Output                  string     `json:"output"`
}

type FieldProvenance

type FieldProvenance struct {
	Kind            string     `json:"kind"`
	DeclaredAt      *scn.Range `json:"declared_at,omitempty"`
	Input           string     `json:"input,omitempty"`
	ProvidedBy      string     `json:"provided_by,omitempty"`
	SourceAddress   string     `json:"source_address,omitempty"`
	Transformations []string   `json:"transformations,omitempty"`
}

func NearestFieldProvenance

func NearestFieldProvenance(origin Origin, path string) FieldProvenance

type GraphEdge

type GraphEdge struct {
	From string `json:"from"`
	To   string `json:"to"`
	Path string `json:"path"`
}

func ResourceEdges

func ResourceEdges(resources []Resource) []GraphEdge

type GraphOptions

type GraphOptions struct {
	Direction    string `json:"direction,omitempty"`
	Depth        int    `json:"depth,omitempty"`
	MaxResources int    `json:"max_resources,omitempty"`
}

type Manifest

type Manifest struct {
	Kind              string                  `json:"kind"`
	SchemaRevision    string                  `json:"schema_revision"`
	SpecRevision      string                  `json:"spec_revision"`
	Producer          machine.Producer        `json:"producer"`
	DiagnosticCatalog string                  `json:"diagnostic_catalog"`
	Application       ApplicationIdentity     `json:"application"`
	ContractRevision  string                  `json:"contract_revision"`
	Resources         []Resource              `json:"resources"`
	SourceMap         map[string]SourceRecord `json:"source_map"`
	Diagnostics       []Diagnostic            `json:"diagnostics"`
}

func DecodeManifest

func DecodeManifest(encoded []byte) (*Manifest, error)

func ManifestForView

func ManifestForView(expanded *Manifest, views map[string]*Manifest, view string) (*Manifest, error)

ManifestForView selects one immutable compiler graph view.

type Origin

type Origin struct {
	Kind             string                     `json:"kind"`
	SourceID         string                     `json:"source_id,omitempty"`
	Patches          []string                   `json:"patches,omitempty"`
	DeclarationRange *scn.Range                 `json:"declaration_range,omitempty"`
	AttributeRanges  map[string]scn.Range       `json:"attribute_ranges,omitempty"`
	ModuleChain      []string                   `json:"module_instantiation_chain,omitempty"`
	ExpansionLineage []ExpansionStep            `json:"expansion_lineage,omitempty"`
	FieldProvenance  map[string]FieldProvenance `json:"field_provenance,omitempty"`
}

type PartialGraph

type PartialGraph struct {
	Deployable  bool                    `json:"deployable"`
	Application ApplicationIdentity     `json:"application"`
	Resources   []Resource              `json:"resources"`
	SourceMap   map[string]SourceRecord `json:"source_map"`
}
type Related struct {
	Address string `json:"address,omitempty"`
	Path    string `json:"path,omitempty"`
}

type Resource

type Resource struct {
	Address string         `json:"address"`
	Kind    string         `json:"kind"`
	Name    string         `json:"name"`
	Module  string         `json:"module"`
	Spec    map[string]any `json:"spec"`
	Origin  Origin         `json:"origin"`
}

func ContractResourceProjection

func ContractResourceProjection(resource Resource) (Resource, bool)

type ResourceGraph

type ResourceGraph struct {
	machine.ArtifactIdentity
	Focus     string      `json:"focus"`
	Direction string      `json:"direction"`
	Resources []Resource  `json:"resources"`
	Edges     []GraphEdge `json:"edges"`
	Truncated bool        `json:"truncated"`
}

func Graph

func Graph(manifest *Manifest, focus string, options GraphOptions) (ResourceGraph, error)

type SourceRecord

type SourceRecord struct {
	URI string `json:"uri"`
}

Jump to

Keyboard shortcuts

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