fact

package
v0.34.5 Latest Latest
Warning

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

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

Documentation

Overview

Package fact defines the SpecScore Studio fact model — the single record shape every ingestion adapter emits and the fact store persists — plus the stable-ID helpers used to mint entity references.

Feature: cli/studio/index (REQ: fact-shape)

The package depends on nothing else in studio: adapters and the store both consume it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DomainID

func DomainID(fqdn string) string

DomainID returns the stable ID of a domain: the lower-cased fqdn without a trailing dot.

func PackageID

func PackageID(module, version string) string

PackageID returns the stable ID of a package/module from its registry coordinates: `<module>@<version>`, or just the module when the version is unknown.

func SpecID

func SpecID(repoID, pathSlug string) string

SpecID returns the stable ID of a spec artifact: `<repo>#<path-slug>`.

Types

type Adapter

type Adapter struct {
	ID      string `json:"id"`
	Version string `json:"version"`
}

Adapter identifies the ingestion adapter (and its version) that emitted a fact.

type Class

type Class string

Class is the evidence class of a fact: how directly the artifact asserts it.

const (
	// Declared facts are asserted verbatim by an artifact (e.g. a spec's
	// `**Status:**` line, a registry entry).
	Declared Class = "declared"
	// Derived facts are computed from an artifact (e.g. an import edge read
	// out of a codegraph snapshot, a dependency parsed from go.mod).
	Derived Class = "derived"
	// VerifiedBehavior facts are produced by executing the system and
	// observing its outcome — the top rung of the evidence ladder, above
	// declared and derived.
	//
	// Feature: cli/rehearse/evidence (REQ: verified-behavior-class)
	VerifiedBehavior Class = "verified-behavior"
)

type Evidence

type Evidence struct {
	Class   Class  `json:"evidence_class"`
	Pointer string `json:"evidence_pointer"`
}

Evidence is the provenance of a fact: its class plus a pointer to the artifact that yielded it. Pointer is a repo-relative file path, optionally suffixed with a `:<line>` or `:<record>` locator where one is cheap.

type Fact

type Fact struct {
	Subject   string `json:"subject"`
	Predicate string `json:"predicate"`
	Object    string `json:"object"`
	Evidence
	Adapter    Adapter `json:"adapter"`
	ObservedAt string  `json:"observed_at"`
	// VerifiedAt is the timestamp of the fact's most recent successful
	// re-verification, distinct from ObservedAt (when the behavior was first
	// observed). On first write the two are equal; re-verifying an unchanged
	// fact refreshes VerifiedAt while preserving the original ObservedAt.
	//
	// Feature: cli/studio/probe (REQ: verified-at-field)
	VerifiedAt string `json:"verified_at"`
	Ecosystem  string `json:"ecosystem"`
}

Fact is one subject–predicate–object triple with full provenance. Evidence is embedded so its fields marshal flat (evidence_class, evidence_pointer) per the fact-shape REQ.

type Warning

type Warning struct {
	Repo    string `json:"repo"`
	Adapter string `json:"adapter"`
	Message string `json:"message"`
}

Warning is a non-fatal ingestion problem: a file, adapter, or repo that could not be ingested and was skipped at the smallest possible granularity (REQ: partial-tolerance). Adapters fill Message only; the pipeline stamps Repo (slug) and Adapter (id) centrally. The type lives here — not in the adapters package — so adapter implementations depend only on this leaf package while the adapters registry can import them without a cycle.

Jump to

Keyboard shortcuts

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