normalize

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package normalize renders filesystem wiki documents into canonical source mirrors.

Index

Constants

View Source
const (
	// FormatVersion identifies the deterministic generic filesystem rendering contract.
	FormatVersion = "filesystem-wiki-v2"
	// OKFFormatVersion identifies the strict OKF filesystem rendering contract.
	OKFFormatVersion = "filesystem-okf-v1"
)

Variables

View Source
var (
	// ErrInvalid reports malformed catalog or render identity input.
	ErrInvalid = errors.New("invalid source normalization input")
	// ErrLimit reports bounded normalizer input or output overflow.
	ErrLimit = errors.New("source normalization exceeds a limit")
)

Functions

func MirrorDigest

func MirrorDigest(identity MirrorIdentity) (string, error)

MirrorDigest returns the canonical digest for one rendered source document.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter implements app.SourceNormalizer over the catalog and render core.

func NewAdapter

func NewAdapter(limits Limits) *Adapter

NewAdapter returns a bounded application normalizer adapter.

func NewDefaultAdapter

func NewDefaultAdapter() *Adapter

NewDefaultAdapter returns an adapter with conservative default bounds.

func (*Adapter) NormalizeSource

func (adapter *Adapter) NormalizeSource(ctx context.Context, input app.SourceNormalizationInput) (app.SourceNormalizationResult, error)

NormalizeSource renders one raw document deterministically into detached canonical write mutations and independent format, catalog, and mirror identities. Context is validated before and after the bounded work.

type Catalog

type Catalog struct {
	// contains filtered or unexported fields
}

Catalog is an immutable deterministic resolution index for one source scan.

func BuildCatalog

func BuildCatalog(refs []knowl.DocumentRef, limits Limits) (Catalog, error)

BuildCatalog validates, sorts, and indexes one complete descriptor set.

func (Catalog) Digest

func (catalog Catalog) Digest() string

Digest returns the canonical SHA-256 catalog identity.

func (Catalog) Entries

func (catalog Catalog) Entries() []Entry

Entries returns a detached sorted catalog snapshot.

func (Catalog) ResolveAsset

func (catalog Catalog) ResolveAsset(raw string) (string, bool)

ResolveAsset resolves an exact or unique-basename asset reference to its source-relative target path.

func (Catalog) ResolveNote

func (catalog Catalog) ResolveNote(raw string) (string, bool)

ResolveNote resolves an exact or unique-basename Markdown reference to a source-local page ID without its Markdown extension.

type Entry

type Entry struct {
	DocumentID knowl.DocumentID `json:"document_id"`
	Path       string           `json:"path"`
	Kind       EntryKind        `json:"kind"`
}

Entry is one canonical source-local catalog member.

type EntryKind

type EntryKind string

EntryKind classifies one catalog entry.

const (
	// EntryMarkdown identifies a Markdown page.
	EntryMarkdown EntryKind = "markdown"
	// EntryAsset identifies an auxiliary asset.
	EntryAsset EntryKind = "asset"
)

type Limits

type Limits struct {
	MaxDocuments     int
	MaxPathBytes     int
	MaxMetadataBytes int
	MaxRenderedBytes int
}

Limits bounds catalog construction and rendered values.

func DefaultLimits

func DefaultLimits() Limits

DefaultLimits returns conservative source normalizer bounds.

type MirrorIdentity

type MirrorIdentity struct {
	FormatVersion string
	SourceID      knowl.SourceID
	DocumentID    knowl.DocumentID
	Revision      string
	RawSource     knowl.AcceptedSource
	CatalogDigest string
	Files         []RenderedFile
}

MirrorIdentity contains every independent input to a mirror digest.

type RenderInput

type RenderInput struct {
	Source    knowl.Source
	Document  knowl.Document
	RawSource knowl.AcceptedSource
	Catalog   Catalog
}

RenderInput contains one fetched or restored raw document and its complete source-local catalog.

type RenderedFile

type RenderedFile struct {
	// contains filtered or unexported fields
}

RenderedFile is one immutable deterministic normalizer output.

func NewRenderedFile

func NewRenderedFile(filePath string, content []byte, limits Limits) (RenderedFile, error)

NewRenderedFile validates and copies one rendered output.

func (RenderedFile) Content

func (file RenderedFile) Content() []byte

Content returns a detached copy of the rendered bytes.

func (RenderedFile) Digest

func (file RenderedFile) Digest() string

Digest returns the rendered content SHA-256.

func (RenderedFile) Path

func (file RenderedFile) Path() string

Path returns the canonical rendered target path.

type Result

type Result struct {
	// contains filtered or unexported fields
}

Result is one immutable deterministic normalization result.

func Render

func Render(input RenderInput, limits Limits) (Result, error)

Render normalizes one Markdown page or auxiliary asset without mutating a workspace or source.

func (Result) CatalogDigest

func (result Result) CatalogDigest() string

CatalogDigest returns the catalog identity used for rendering.

func (Result) Diagnostics

func (result Result) Diagnostics() []knowl.SourceDiagnostic

Diagnostics returns detached, bounded non-fatal compatibility observations.

func (Result) Files

func (result Result) Files() []RenderedFile

Files returns detached immutable rendered file values.

func (Result) FormatVersion

func (result Result) FormatVersion() string

FormatVersion returns the rendering contract version.

func (Result) MirrorDigest

func (result Result) MirrorDigest() string

MirrorDigest returns the independent mirror render identity.

Jump to

Keyboard shortcuts

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