Documentation
¶
Overview ¶
Package dataroles classifies a database family's collections by data role (reference, master, configuration, transactional, event) and suggests a default consistency rule for each, with provenance and review state.
Classification is separate from consistency: a role describes what a dataset is, a reconcile.Rules describes where it must agree. Suggestions never take effect until a person confirms them. Suggest reads schema only, never record values.
Index ¶
Constants ¶
const FileName = "datatug-data-roles.json"
FileName is the project file beside datatug-labels.json.
const Format = "datatug-data-roles/v1"
Format identifies the document stored as FileName in a project.
const HeuristicVersion = "dataroles-heuristic/1"
HeuristicVersion names the deterministic suggester recorded in provenance.
Variables ¶
var Roles = []Role{RoleReference, RoleMaster, RoleConfiguration, RoleTransactional, RoleEvent, RoleUnknown}
Roles lists every role.
Functions ¶
This section is empty.
Types ¶
type Classification ¶
type Classification struct {
Target Target `json:"target"`
Role Role `json:"role"`
Consistency *reconcile.Rules `json:"consistency,omitempty"`
Origin Origin `json:"origin"`
Version string `json:"version,omitempty"` // suggester or model version
State State `json:"state"`
Confidence Confidence `json:"confidence,omitempty"`
Evidence []string `json:"evidence,omitempty"`
By string `json:"by,omitempty"`
At time.Time `json:"at"`
Reason string `json:"reason,omitempty"`
}
Classification is one role assignment with provenance.
func FromMeaning ¶
func FromMeaning(target Target, d MeaningDefault, at time.Time) (Classification, error)
FromMeaning converts a Meaning Graph default into a classification with origin `imported`. It takes effect without confirmation, below a confirmed project classification (see Resolve), because Meaning Graph is an authoritative, reviewed specification rather than a suggestion.
func Resolve ¶
func Resolve(doc Document, target Target, meaning *Classification) (Classification, bool)
Resolve returns the effective classification for a target, most specific first: the project's confirmed classification, then the Meaning Graph default when one is given. A profile's own rule outranks both and is applied by the caller. Suggestions never take effect.
func Suggest ¶
func Suggest(family string, collections []Collection, at time.Time) []Classification
Suggest classifies collections of one family from schema alone and returns suggestions with evidence. It reads no record values.
func (Classification) Validate ¶
func (c Classification) Validate() error
Validate checks one entry.
type Collection ¶
type Collection struct {
Name string `json:"name"`
Columns []Column `json:"columns"`
ReferencedBy int `json:"referencedBy"`
References int `json:"references"`
}
Collection is the schema-only shape of one collection. ReferencedBy counts foreign keys from other collections pointing at it; References counts its own foreign keys.
type Column ¶
type Column struct {
Name string `json:"name"`
Type string `json:"type"`
PrimaryKey bool `json:"primaryKey,omitempty"`
Unique bool `json:"unique,omitempty"`
}
Column describes a column for schema-only classification.
type Confidence ¶
type Confidence string
Confidence is a word tied to evidence, never a probability.
const ( ConfidenceLikely Confidence = "likely" ConfidencePossible Confidence = "possible" )
type Document ¶
type Document struct {
Format string `json:"format"`
Classifications []Classification `json:"classifications"`
}
Document is the stored file.
func (*Document) Decide ¶
func (d *Document) Decide(target Target, state State, by string, at time.Time, role Role, consistency *reconcile.Rules, reason string) error
Decide confirms or dismisses an entry on a person's behalf. Confirming may replace the role or the consistency rule the person reviewed.
func (Document) Effective ¶
func (d Document) Effective(target Target) (Classification, bool)
Effective returns the confirmed classification for a target, if any. Suggested and dismissed entries never take effect.
func (*Document) Merge ¶
func (d *Document) Merge(suggestions []Classification) (added int)
Merge adds suggestions for targets the document does not classify yet. Existing entries — confirmed, dismissed or suggested — are never replaced, so a person's decision survives every rescan.
type Expectation ¶
type Expectation string
Expectation is a Meaning Graph consistency expectation.
const ( ExpectIdentical Expectation = "identical" ExpectNormalized Expectation = "normalized" ExpectPartial Expectation = "partial" ExpectInstanceSpecific Expectation = "instance-specific" ExpectUnrestricted Expectation = "unrestricted" )
type MeaningDefault ¶
type MeaningDefault struct {
Concept string `json:"concept"` // the concept's address, for provenance
Role Role `json:"role"`
Scope string `json:"scope,omitempty"` // global | application
Expectation Expectation `json:"expectation,omitempty"`
Key []string `json:"key,omitempty"`
Properties map[string]Expectation `json:"properties,omitempty"`
}
MeaningDefault is the reusable default a Meaning Graph concept declares (`data-role` and `consistency`), resolved for one bound collection: Key holds the columns bound with role `identifier`, Properties the expectations of bound property concepts by column name.