safety

package
v0.7.1 Latest Latest
Warning

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

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

Documentation

Overview

Package safety adapts the unity-fileid-graph safety kernel for unity-ctx write paths. It is the only package in unity-ctx allowed to import github.com/Kubonsang/unity-fileid-graph.

Index

Constants

View Source
const (
	StatusOK    = "OK"
	StatusWarn  = "WARN"
	StatusError = "ERROR"

	CodeParseFailed      = "PARSE_FAILED"
	CodeGraphBuildFailed = "GRAPH_BUILD_FAILED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Finding

type Finding struct {
	Severity string
	Code     string
	Detail   string
}

type Phase

type Phase string
const (
	PhasePre   Phase = "pre_check"
	PhaseTemp  Phase = "temp_check"
	PhaseFinal Phase = "final_check"
)

type Ref

type Ref struct {
	Block   int64
	Class   string
	Field   string
	FileID  int64
	GUID    string
	HasGUID bool
	Type    int
	HasType bool
}

Ref is one PPtr/GUID reference extracted from a Unity YAML block.

type RefIssue

type RefIssue struct {
	Code    string
	FileID  int64
	Message string
}

RefIssue is a structured warning from refs extraction, mirroring the fields uyaml emits in its refs JSON issues[] (severity is always WARN).

type RefsReport

type RefsReport struct {
	Status   string // "OK" | "WARN"
	Refs     []Ref
	Warnings []RefIssue
}

func ExtractRefs

func ExtractRefs(data []byte, namespace, file string) (RefsReport, error)

ExtractRefs extracts PPtr/GUID reference evidence from raw Unity YAML bytes. It errors only when the bytes cannot be block-parsed.

type Report

type Report struct {
	Status      string
	Blocks      int
	GameObjects int
	Components  int
	Transforms  int
	Findings    []Finding
}

func CheckBytes

func CheckBytes(data []byte) Report

CheckBytes runs the fileid-graph safety kernel (parse, graph build, integrity check) over raw Unity YAML bytes. It never returns an error: parse or build failures are reported as blocking findings.

func (Report) Blocking

func (r Report) Blocking() bool

func (Report) Lines

func (r Report) Lines(phase Phase) []string

Lines renders detail lines for a non-OK report: "CHECK phase=... status=... errors=N warnings=M" followed by one "ERROR code=..."/"WARN code=..." line per finding. Empty for OK.

Jump to

Keyboard shortcuts

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