contract

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountPreserveFuncs

func CountPreserveFuncs(dir string) int

CountPreserveFuncs counts all preserved functions and files in a directory.

func Hash7

func Hash7(input string) string

Hash7 computes a 7-character SHA-256 hash.

func HashClaims

func HashClaims(claims map[string]manifest.ClaimDef) string

HashClaims computes a contract hash for middleware claims (CurrentUser). Based on: sorted field:key:type triples.

func HashModelMethod

func HashModelMethod(name string, params []string, returns []string) string

HashModelMethod computes a contract hash for a model implementation method. Based on: method name + parameter types + return types.

func HashServiceFunc

func HashServiceFunc(sf ssacparser.ServiceFunc) string

HashServiceFunc computes a contract hash for an SSaC service function. The hash is derived from: operationId + sequence types + request fields + response fields.

func HashStateDiagram

func HashStateDiagram(sd *statemachine.StateDiagram) string

HashStateDiagram computes a contract hash for a state machine. Based on: sorted states + sorted transitions (from:event:to).

func IsDirective

func IsDirective(comment string) bool

IsDirective checks if a comment line is a fullend directive.

func Summary

func Summary(funcs []FuncStatus) (gen, preserve, broken, orphan int)

Summary returns counts by status.

Types

type Directive

type Directive struct {
	Ownership string // "gen" or "preserve"
	SSOT      string // SSOT file relative path (e.g. "service/gig/create_gig.ssac")
	Contract  string // 7-char SHA256 hex prefix
}

Directive represents a //fullend: ownership directive attached to generated code.

func Parse

func Parse(comment string) (*Directive, error)

Parse extracts a Directive from a Go comment string. Expected format: "//fullend:gen ssot=service/gig/create_gig.ssac contract=a3f8c1"

func (*Directive) String

func (d *Directive) String() string

String returns the directive as a Go comment.

func (*Directive) StringJS

func (d *Directive) StringJS() string

StringJS returns the directive as a JS comment (with space after //).

type FuncStatus

type FuncStatus struct {
	File      string // relative path from artifacts dir
	Function  string
	Directive Directive
	Status    string // "gen", "preserve", "broken", "orphan"
	Detail    string // violation detail
}

FuncStatus describes the contract status of a single function.

func ScanDir

func ScanDir(artifactsDir string) ([]FuncStatus, error)

ScanDir scans artifacts directory for all Go files with //fullend: directives.

func Verify

func Verify(specsDir string, funcs []FuncStatus) []FuncStatus

Verify checks each FuncStatus against the current SSOT files. Updates Status to "broken" (hash mismatch) or "orphan" (SSOT deleted).

type PreserveSnapshot

type PreserveSnapshot struct {
	FilePreserves map[string]string                    // path → saved whole file content
	FuncPreserves map[string]map[string]*PreservedFunc // path → funcName → preserved body
}

PreserveSnapshot captures all preserved functions/files before code generation.

func ScanPreserveSnapshot

func ScanPreserveSnapshot(dir string) *PreserveSnapshot

ScanPreserveSnapshot walks a directory and captures all preserved content.

type PreservedFunc

type PreservedFunc struct {
	Directive Directive
	BodyText  string // raw source between { and }, excluding the braces themselves
}

PreservedFunc holds a preserved function's directive and body text.

type SpliceResult

type SpliceResult struct {
	Content  string
	Warnings []Warning
}

SpliceResult holds the merged content and any warnings.

func SpliceWithPreserved

func SpliceWithPreserved(newContent string, preserved map[string]*PreservedFunc, filePath string) (*SpliceResult, error)

SpliceWithPreserved merges preserved function bodies into new content.

type Warning

type Warning struct {
	File        string
	Function    string
	OldContract string
	NewContract string
}

Warning records a contract mismatch between preserved body and regenerated contract.

func RestorePreserved

func RestorePreserved(snap *PreserveSnapshot) []Warning

RestorePreserved restores all preserved content after code generation.

Jump to

Keyboard shortcuts

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