Help us shape the future of Go! Take the 2026 Go Developer Survey

runtimeannotate

package
v1.0.65 Latest Latest
Warning

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

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

Documentation

Overview

Package runtimeannotate owns Cobra dws.schema.* annotation writers and the RuntimeSchemaConstraints helpers used by the command framework.

Package boundary:

  • Types / DTO / ProductDecl → internal/corecmd/contract
  • AnnotateRuntime* writers (this package) — no Catalog delivery
  • ContractFinal cobra store + Register seam → internal/corecmd/contractfinal
  • Catalog assembly / ResolveMeta (`RegisterSchemaSourceRoot` → `ResolveSchemaBuild`); go:embed only for reviewed inputs → internal/cli (root)

Dependency direction: corecmd and corecmd/contractfinal import this package. This package must never import internal/cli (root or subpackages). Product / delivery code consumes this package directly, or via the cli root's package-local aliases (internal/cli/runtime_schema_seam.go).

Index

Constants

View Source
const (
	AnnotationProduct      = "dws.schema.product"
	AnnotationTool         = "dws.schema.tool"
	AnnotationSource       = "dws.schema.source"
	AnnotationDescription  = "dws.schema.description"
	AnnotationExclude      = "dws.schema.exclude"
	AnnotationConstraints  = "dws.schema.constraints"
	AnnotationPositionals  = "dws.schema.positionals"
	AnnotationContract     = "dws.schema.contract"
	AnnotationRisk         = "dws.schema.risk"
	AnnotationRuntimeGate  = "dws.schema.runtime_gate"
	AnnotationFlagProperty = "dws.schema.property"
	AnnotationFlagType     = "dws.schema.type"
	AnnotationFlagRequired = "dws.schema.required"
	AnnotationFlagReqWhen  = "dws.schema.required_when"
	AnnotationFlagExample  = "dws.schema.example"
	AnnotationFlagFormat   = "x-cli-format"
	AnnotationFlagAnyOf    = "dws.schema.anyOf"
	AnnotationFlagEnum     = "x-cli-enum"
)

Cobra annotation keys for Schema homology (path A). Writers and readers must share these exact strings; do not re-declare literals in callers.

View Source
const (
	AnnotationFlagAliasOf     = "dws.compat.alias_of"
	AnnotationFlagAliasOrigin = "dws.compat.alias_origin"
	FlagAliasOriginCorecmdV1  = "corecmd.flag_spec_aliases.v1"
)

CLI flag alias evidence is kept in this narrow file so the base-owned Interface Snapshot helper can add the protocol constants to an older stable worktree without replacing that revision's complete runtimeannotate package. Only corecmd.FlagSpec.Aliases writes the exact origin; neither field is a Schema synonym or final payload-equivalence proof.

Variables

This section is empty.

Functions

func AnnotateRuntimeConstraints

func AnnotateRuntimeConstraints(cmd *cobra.Command, constraints RuntimeSchemaConstraints)

AnnotateRuntimeConstraints records command-level parameter relationships.

func AnnotateRuntimeContract

func AnnotateRuntimeContract(cmd *cobra.Command)

AnnotateRuntimeContract marks a command as carrying a command/LeafSpec Contract surface.

func AnnotateRuntimeFlag

func AnnotateRuntimeFlag(cmd *cobra.Command, flagName, propertyName, paramType string, required bool)

AnnotateRuntimeFlag adds parameter metadata to an already-registered flag.

func AnnotateRuntimeFlagDescription

func AnnotateRuntimeFlagDescription(cmd *cobra.Command, flagName, description string)

AnnotateRuntimeFlagDescription records the Schema parameter description.

func AnnotateRuntimeFlagEnum

func AnnotateRuntimeFlagEnum(cmd *cobra.Command, flagName string, values ...string)

AnnotateRuntimeFlagEnum records the accepted values for a flag.

func AnnotateRuntimeFlagExample

func AnnotateRuntimeFlagExample(cmd *cobra.Command, flagName, example string)

AnnotateRuntimeFlagExample records a valid representative CLI value.

func AnnotateRuntimeFlagFormat

func AnnotateRuntimeFlagFormat(cmd *cobra.Command, flagName, format string)

AnnotateRuntimeFlagFormat records a machine-readable value format.

func AnnotateRuntimeFlagInterfaceType

func AnnotateRuntimeFlagInterfaceType(cmd *cobra.Command, flagName, interfaceType string)

AnnotateRuntimeFlagInterfaceType records the wire type for a flag's interface property.

func AnnotateRuntimeFlagProperty

func AnnotateRuntimeFlagProperty(cmd *cobra.Command, flagName, propertyName string)

AnnotateRuntimeFlagProperty records only the stable CLI flag to interface property binding.

func AnnotateRuntimeFlagRequiredValue

func AnnotateRuntimeFlagRequiredValue(cmd *cobra.Command, flagName string, required bool)

AnnotateRuntimeFlagRequiredValue sets an explicit required value on a flag.

func AnnotateRuntimeFlagRequiredWhen

func AnnotateRuntimeFlagRequiredWhen(cmd *cobra.Command, flagName, expression string)

AnnotateRuntimeFlagRequiredWhen records a conditional CLI requirement.

func AnnotateRuntimePositionals

func AnnotateRuntimePositionals(cmd *cobra.Command, positionals ...contract.RuntimeSchemaPositional)

AnnotateRuntimePositionals records ordered positional arguments for agents.

func AnnotateRuntimeRequiredFlags

func AnnotateRuntimeRequiredFlags(cmd *cobra.Command, flagNames ...string)

AnnotateRuntimeRequiredFlags records schema-only required semantics.

func AttachRuntimeSchema

func AttachRuntimeSchema(cmd *cobra.Command, productID, toolName, source string)

AttachRuntimeSchema records optional implementation-side identity evidence on a runnable command. Stable command identity is collected from ContractFinal.Identity on the live Cobra leaves (EffectiveCommandRegistry); the binder accepts an absent annotation and rejects an annotation that disagrees with the collected identity.

func CommandFlag

func CommandFlag(cmd *cobra.Command, name string) *pflag.Flag

CommandFlag resolves local flags plus product/group persistent flags. Root persistent flags are intentionally available only when explicitly requested; they are global execution controls, not tool parameters.

func CommandPositionals

func CommandPositionals(cmd *cobra.Command) []contract.RuntimeSchemaPositional

CommandPositionals reads annotated positionals (nil on miss/error).

func ConstraintsEmpty

func ConstraintsEmpty(constraints RuntimeSchemaConstraints) bool

ConstraintsEmpty reports whether no constraint groups remain.

func RuntimeContractGate

func RuntimeContractGate(cmd *cobra.Command) (string, bool)

RuntimeContractGate returns the annotated runtime confirmation gate when present. Like RuntimeContractRisk it is read-only residual plumbing: the writer is retired and declared Contract SafetySpec is the production path.

func RuntimeContractRisk

func RuntimeContractRisk(cmd *cobra.Command) (string, bool)

RuntimeContractRisk returns the Contract Risk annotation when present. Writers are retired: production leaves declare contract.SafetySpec through ContractFinal, and assembly consults this residual annotation only as the fallback when a leaf carries no ContractFinal Safety.

func SetCommandAnnotation

func SetCommandAnnotation(cmd *cobra.Command, key, value string)

SetCommandAnnotation writes a non-blank command annotation.

func SetFlagAnnotation

func SetFlagAnnotation(flag *pflag.Flag, key, value string)

SetFlagAnnotation writes a single non-blank flag annotation value.

func SetFlagAnnotationValues

func SetFlagAnnotationValues(flag *pflag.Flag, key string, values ...string)

SetFlagAnnotationValues writes a trimmed, non-empty flag annotation list.

Types

type RuntimeSchemaConstraints

type RuntimeSchemaConstraints = contract.RuntimeSchemaConstraints

RuntimeSchemaConstraints is retained here for framework compatibility.

func CommandConstraints

func CommandConstraints(cmd *cobra.Command) RuntimeSchemaConstraints

CommandConstraints reads the annotated constraint payload (empty on miss/error).

func NormalizeConstraints

func NormalizeConstraints(constraints RuntimeSchemaConstraints) RuntimeSchemaConstraints

NormalizeConstraints trims, deduplicates, and drops undersized groups.

Jump to

Keyboard shortcuts

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