storagecensus

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package storagecensus builds the census of every write of stored entity state in the module: each Badger write, classified by the key it writes, and each change of a field that holds entity state, counts or quota; and it checks that each effect runs under the acquisition its class requires, on every path from an entry point. The census is generated from the fully type-checked module as SSA, with a VTA call graph (docs/generated/stored-entity-census.json and .md); its tests fail when the artifact is stale, when the module does not type-check, or when an effect escapes its acquisition.

Index

Constants

View Source
const Module = "github.com/orneryd/nornicdb/"

Module is the import path prefix of the analysed module.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decision

type Decision struct {
	Func string `json:"func"`
	Pos  string `json:"pos"`
	// Gates is the write the branch decides: the instruction in Func and
	// the path from it to the Badger write.
	Gates  string   `json:"gates"`
	Owners []string `json:"owners,omitempty"`
	// contains filtered or unexported fields
}

Decision is a branch on hidden state (or on a read that sees hidden entities) that decides whether ordered state is written: a hidden-ID disposition, a suppression change, an accounting choice.

type FieldWriteRow

type FieldWriteRow struct {
	Field string `json:"field"`
	Class string `json:"class"`
	Func  string `json:"func"`
	Pos   string `json:"pos"`
}

FieldWriteRow is a classified field change.

type NamedReason

type NamedReason struct {
	Name   string `json:"name"`
	Reason string `json:"reason"`
}

type Report

type Report struct {
	Rules []string `json:"rules"`
	// Spaces are the key spaces, with their class and how many writes the
	// census found to each.
	Spaces []SpaceRow `json:"spaces"`
	// Acquisitions are the owners of ordered writes; Exempt the functions
	// whose own writes need none, with the reason.
	Acquisitions []NamedReason `json:"acquisitions"`
	Exempt       []NamedReason `json:"exempt"`
	// Writes are every Badger write found, per calling context that names
	// its key.
	Writes []write `json:"writes"`
	// FieldWrites are the changes of classified state fields.
	FieldWrites []FieldWriteRow `json:"fieldWrites"`
	// Decisions are the branches on hidden state that decide a write;
	// Disposition the functions where such a decision belongs.
	Decisions   []Decision    `json:"decisions"`
	Disposition []NamedReason `json:"disposition"`
	// Pending are second interpretations of the write transition that a
	// stacked change removes; each must still exist.
	Pending []NamedReason `json:"pending"`
	// Violations are entry points that reach a write of ordered state no
	// acquisition covers, writes whose key the census cannot classify, and
	// table rows that no longer match the code.
	Violations []string `json:"violations"`
	// Unordered details the unordered-write violations.
	Unordered []UnorderedRow `json:"unordered"`
}

Report is the census.

func Census

func Census(root string, overlay map[string][]byte) (*Report, error)

Census analyses the module rooted at root, with overlay replacing or adding files (absolute path to contents).

func (*Report) JSON

func (r *Report) JSON() ([]byte, error)

JSON is the census as indented JSON.

func (*Report) Markdown

func (r *Report) Markdown() []byte

Markdown is the census for reading.

type SpaceRow

type SpaceRow struct {
	Space  string `json:"space"`
	Class  string `json:"class"`
	Writes int    `json:"writes"`
}

type UnorderedRow

type UnorderedRow struct {
	Space   string   `json:"space"`
	Class   string   `json:"class"`
	Origin  string   `json:"origin"`
	Entries []string `json:"entries"`
	Chain   []string `json:"chain"`
	// Chains is each entry point's shortest path, for diagnosis only
	// (NORNICDB_CENSUS_CHAINS); the artifact keeps the shortest overall.
	Chains map[string][]string `json:"-"`
}

UnorderedRow is a write of ordered state that entry points reach with no acquisition: every such entry point, and the shortest path.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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