app

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 36 Imported by: ? modules, 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 app owns Knowl application policy and its consuming ports.

Index

Constants

View Source
const (
	MaxCorrectionOutputBytes   = 1 << 20
	MaxCorrectionDeadline      = 5 * time.Minute
	MaxCorrectionFeedbackBytes = 128
)
View Source
const (

	// CanonicalProvenanceCodePageMalformed identifies invalid canonical page structure.
	CanonicalProvenanceCodePageMalformed = "retirement.page_malformed"
	// CanonicalProvenanceCodeRefMalformed identifies a malformed accepted-ref key.
	CanonicalProvenanceCodeRefMalformed = "retirement.ref_malformed"
	// CanonicalProvenanceCodeRefUnowned identifies a ref without an exact accepted owner.
	CanonicalProvenanceCodeRefUnowned = "retirement.unowned_ref"
	// CanonicalProvenanceCodeLimit identifies a finite pager ceiling.
	CanonicalProvenanceCodeLimit = "retirement.provenance_limit"
	// CanonicalProvenanceCodeCursor identifies an invalid internal keyset cursor.
	CanonicalProvenanceCodeCursor = "retirement.provenance_cursor"
	// CanonicalProvenanceCodeRestart identifies a round invalidated by canonical mutation.
	CanonicalProvenanceCodeRestart = "retirement.provenance_restart"
)
View Source
const (

	// RetirementReferencesRemainCode reports a completed discovery round that
	// found current canonical references and therefore requires page work.
	RetirementReferencesRemainCode = "retirement.refs_remaining"
	// RetirementWorkPendingCode reports durable page work not yet terminal.
	RetirementWorkPendingCode = "retirement.work_pending"
	// RetirementWorkFailedCode reports page work awaiting supported retry.
	RetirementWorkFailedCode = "retirement.work_failed"
)
View Source
const (
	// RetirementMaintenanceContractVersion identifies the page-scoped provider contract.
	RetirementMaintenanceContractVersion = "source-retirement-v1"
	// MaxRetirementEvidenceBytes is the aggregate raw active-evidence ceiling.
	MaxRetirementEvidenceBytes = 4 << 20

	CitationPlanMissingCode             = "citation.plan_missing"
	CitationSourceRetiringCode          = "citation.source_retiring"
	RetirementMaintainerUnavailableCode = "retirement.maintainer_unavailable"
	RetirementMaintainerFailedCode      = "retirement.maintainer_failed"
	RetirementLifecycleConflictCode     = "retirement.lifecycle_conflict"
	RetirementPageStaleCode             = "retirement.page_stale"
	RetirementEvidenceLimitCode         = "retirement.evidence_limit"
	RetirementEvidenceUnavailableCode   = "retirement.evidence_unavailable"
	RetirementEvidenceUnsupportedCode   = "retirement.evidence_unsupported"
	RetirementRequestLimitCode          = "retirement.request_limit"
	RetirementOutputLimitCode           = "retirement.output_limit"
	RetirementPageMalformedCode         = "retirement.page_malformed"
	RetirementPlanInvalidCode           = "retirement.plan_invalid"
	RetirementEvidenceInvalidCode       = "retirement.evidence_invalid"
)
View Source
const (
	RetirementProjectionFailedCode = "retirement.projection_failed"
	RetirementCommitFailedCode     = "retirement.commit_failed"
	RetirementStagingFailedCode    = "retirement.staging_failed"
)
View Source
const (
	// RetirementCatalogClosureLimitCode identifies a page unit whose smallest
	// required navigation closure does not fit the existing plan bounds.
	RetirementCatalogClosureLimitCode = "retirement.catalog_closure_limit"
	// RetirementCatalogMixedItemCode identifies a catalog item that combines
	// a retiring target with semantics that cannot be removed independently.
	RetirementCatalogMixedItemCode = "retirement.catalog_mixed_item"
)
View Source
const (
	SourceLifecycleUnownedCode         = "retirement.unowned_ref"
	CitationSourceAuthorityChangedCode = "citation.source_authority_changed"
)
View Source
const (
	// MaxLegacySourceRefCandidates bounds compatibility decoding of persisted
	// delimiter-based refs. New delimiter-bearing identities use canonical v2.
	MaxLegacySourceRefCandidates = 16
	// MaxAcceptedSourceResolveRefs bounds one page-scoped exact-ref lookup.
	MaxAcceptedSourceResolveRefs = 128
	// MaxAcceptedSourceResolveProbes bounds all candidate manifest paths in one lookup.
	MaxAcceptedSourceResolveProbes = 256
	// MaxAcceptedSourceResolveBytes bounds all requested manifests in one lookup.
	MaxAcceptedSourceResolveBytes = 4 << 20
)
View Source
const DefaultHierarchyPlannerVersion = "hierarchy-v3"
View Source
const MaxMaintenanceRequestBytes = 4 << 20

MaxMaintenanceRequestBytes is the supported local current-prompt ceiling.

View Source
const MaxOperationCorrectionReportBytes = 1024
View Source
const (

	// RetirementReplacementNotReadyCode is the stable replacement gate blocker.
	RetirementReplacementNotReadyCode = "retirement.replacement_not_ready"
)
View Source
const SourceMaintenanceContractVersion = "source-maintenance-v6"

SourceMaintenanceContractVersion identifies the output-affecting maintainer and validation contract. Compatibility-only changes must retain this value.

Variables

View Source
var (
	// ErrHierarchyPlanInvalid reports malformed or incomplete semantic output.
	ErrHierarchyPlanInvalid = errors.New("invalid hierarchy plan")
	// ErrHierarchyDigestMismatch reports a plan made for other canonical inputs.
	ErrHierarchyDigestMismatch = errors.New("hierarchy plan digest mismatch")
	// ErrHierarchyLimitExceeded reports a configured hierarchy bound violation.
	ErrHierarchyLimitExceeded = errors.New("hierarchy plan exceeds a limit")
	// ErrHierarchyForbiddenPath reports a path outside the managed catalog boundary.
	ErrHierarchyForbiddenPath = errors.New("hierarchy plan targets a forbidden path")
)
View Source
var (
	ErrOperationNotApplyable = errors.New("operation is not ready to apply")
	ErrMaintainerUnavailable = errors.New("knowl maintainer is unavailable")
	ErrProjection            = errors.New("canonical content committed but projection failed")
)
View Source
var (
	// ErrMaintenanceInputLimit identifies input that cannot fit its request budget.
	ErrMaintenanceInputLimit = errors.New("maintenance input exceeds budget")
	// ErrMaintenanceInputInvalid identifies invalid limits or unencodable input.
	ErrMaintenanceInputInvalid = errors.New("invalid maintenance input")
)
View Source
var (
	ErrOperatorInvalidRequest         = errors.New("invalid operator request")
	ErrOperatorLimitInvalid           = errors.New("invalid operator limit")
	ErrOperatorCursorInvalid          = errors.New("invalid operator cursor")
	ErrOperatorCatalogNotFound        = errors.New("operator catalog not found")
	ErrOperatorDirectoryNotFound      = errors.New("operator wiki directory not found")
	ErrOperatorSourceRevisionNotFound = errors.New("operator source revision not found")
	ErrOperatorSnapshotChanged        = errors.New("operator canonical snapshot changed")
	ErrOperatorReadLimitExceeded      = errors.New("operator read limit exceeded")
	ErrOperatorUnsupportedFormat      = errors.New("operator unsupported format")
	ErrOperatorCapabilityUnavailable  = errors.New("operator read capability unavailable")
	ErrOperatorNotReady               = errors.New("operator runtime not ready")
	ErrOperatorWorkspaceUnavailable   = errors.New("operator workspace unavailable")
)
View Source
var (
	ErrOutputCorrectionExhausted error = outputCorrectionFailure("provider_output_exhausted")
	ErrCorrectionOutputLimit     error = outputCorrectionFailure("provider_output_limit")
	ErrCorrectionDeadline        error = outputCorrectionFailure("provider_output_deadline")
)
View Source
var (
	ErrPlanInvalid       = errors.New("invalid maintainer edit plan")
	ErrSchemaMismatch    = errors.New("edit plan schema digest mismatch")
	ErrForbiddenEdit     = errors.New("edit plan targets a forbidden path")
	ErrPlanLimitExceeded = errors.New("edit plan exceeds a limit")
)
View Source
var (
	// ErrNoReadyOperation reports that durable work inspection found no claimable operation.
	ErrNoReadyOperation = errors.New("no ready Knowl operation")
	// ErrExecutionDescriptorUnavailable reports missing or invalid durable execution inputs.
	ErrExecutionDescriptorUnavailable = errors.New("knowl execution descriptor is unavailable")
	// ErrWorkLeaseConflict reports that another worker owns or replaced a work lease.
	ErrWorkLeaseConflict = errors.New("knowl operation work lease conflicts")
	// ErrStageNotFound reports that no complete staged artifact exists for an operation.
	ErrStageNotFound = errors.New("knowl staged artifact not found")
	// ErrApplyLeaseConflict reports that canonical application is still owned by another attempt.
	ErrApplyLeaseConflict = errors.New("knowl operation application lease conflicts")
)
View Source
var (
	// ErrCanonicalProvenanceInvalid reports malformed pager inputs or state.
	ErrCanonicalProvenanceInvalid = errors.New("invalid canonical provenance request")
	// ErrCanonicalProvenanceLimit reports a finite page, byte, ref, or round ceiling.
	ErrCanonicalProvenanceLimit = errors.New("retirement.provenance_limit")
	// ErrCanonicalProvenanceMalformed reports malformed canonical page provenance.
	ErrCanonicalProvenanceMalformed = errors.New("retirement.provenance_malformed")
	// ErrCanonicalProvenanceCursor reports an invalid or non-progressing internal cursor.
	ErrCanonicalProvenanceCursor = errors.New("retirement.provenance_cursor")
	// ErrCanonicalProvenanceRestart requires discarding the cursor and restarting the round.
	ErrCanonicalProvenanceRestart = errors.New("retirement.provenance_restart")
)
View Source
var (
	ErrQueryInvalid      = errors.New("invalid Knowl query")
	ErrPageNotFound      = errors.New("knowl page not found")
	ErrOperationNotFound = errors.New("knowl operation not found")
	ErrFilingInvalid     = errors.New("invalid explicit wiki filing")
)
View Source
var (
	// ErrRetirementReferencesRemain reports a non-zero authoritative scan round.
	ErrRetirementReferencesRemain = errors.New(RetirementReferencesRemainCode)
	// ErrRetirementWorkPending reports page work that can still publish.
	ErrRetirementWorkPending = errors.New(RetirementWorkPendingCode)
	// ErrRetirementWorkFailed reports terminal page work awaiting operator retry.
	ErrRetirementWorkFailed = errors.New(RetirementWorkFailedCode)
)
View Source
var (
	ErrRetirementMaintainerUnavailable = errors.New(RetirementMaintainerUnavailableCode)
	ErrRetirementMaintainerFailed      = errors.New(RetirementMaintainerFailedCode)
	ErrRetirementLifecycleConflict     = errors.New(RetirementLifecycleConflictCode)
	ErrRetirementPageStale             = errors.New(RetirementPageStaleCode)
	ErrRetirementEvidenceLimit         = errors.New(RetirementEvidenceLimitCode)
	ErrRetirementEvidenceUnavailable   = errors.New(RetirementEvidenceUnavailableCode)
	ErrRetirementEvidenceUnsupported   = errors.New(RetirementEvidenceUnsupportedCode)
	ErrRetirementRequestLimit          = errors.New(RetirementRequestLimitCode)
	ErrRetirementOutputLimit           = errors.New(RetirementOutputLimitCode)
	ErrRetirementPlanInvalid           = errors.New(RetirementPlanInvalidCode)
)
View Source
var (
	ErrRetirementCatalogClosureLimit = errors.New(RetirementCatalogClosureLimitCode)
	ErrRetirementCatalogMixedItem    = errors.New(RetirementCatalogMixedItemCode)
)
View Source
var (
	ErrSourceInvalid         = errors.New("invalid Knowl source")
	ErrSourceRefAmbiguous    = errors.New("ambiguous Knowl source reference")
	ErrSourceRefDuplicate    = errors.New("duplicate Knowl source reference")
	ErrSourceRefLimit        = errors.New("knowl source reference exceeds compatibility limit")
	ErrSourceNotFound        = errors.New("knowl source not found")
	ErrSyncRunNotFound       = errors.New("knowl sync run not found")
	ErrSyncConflict          = errors.New("knowl sync state conflict")
	ErrSyncStateTransition   = errors.New("invalid Knowl sync state transition")
	ErrSourceMutationInvalid = errors.New("invalid Knowl source mutation")
	ErrSourceMutationLimit   = errors.New("knowl source mutation exceeds a limit")
	ErrSourceRetryConflict   = errors.New("knowl source maintenance retry conflicts")
	ErrSourceLineageConflict = errors.New("knowl source repository identity conflicts")
)
View Source
var (
	// ErrSourceLifecycleInvalid reports malformed exact-owner lifecycle input or state.
	ErrSourceLifecycleInvalid = errors.New("invalid Knowl source lifecycle")
	// ErrSourceLifecycleConflict reports a stale or invalid lifecycle transition.
	ErrSourceLifecycleConflict = errors.New("knowl source lifecycle conflicts")
	// ErrSourceLifecycleUnowned reports a ref without an observed exact owner.
	ErrSourceLifecycleUnowned = errors.New(SourceLifecycleUnownedCode)
	// ErrSourceReplacementNotReady reports a same-rollout addition whose exact
	// current configuration has not completed source readiness.
	ErrSourceReplacementNotReady = errors.New(RetirementReplacementNotReadyCode)
)
View Source
var ErrEmbedding = errors.New("embedding failure")
View Source
var ErrMaintenanceAuthorityRejected = errors.New("maintenance source authority rejected")
View Source
var ErrMaintenanceDiagnosticInvalid = errors.New("invalid maintenance diagnostic")
View Source
var ErrMaintenancePolicyMismatch error = maintenancePolicyMismatch{}

ErrMaintenancePolicyMismatch rejects unplanned work reserved under a different effective source-maintenance contract or policy.

View Source
var ErrOperationContextReportInvalid = errors.New("invalid operation context report")
View Source
var ErrOperationCorrectionReportInvalid = errors.New("invalid operation correction report")
View Source
var ErrOutputCorrectionInvalid = errors.New("invalid output correction policy")
View Source
var ErrRetrievalReportInvalid = errors.New("invalid retrieval report")

Functions

func AddSyncCounts added in v0.3.0

func AddSyncCounts(left, right knowl.SyncCounts) (knowl.SyncCounts, error)

AddSyncCounts accumulates reconciliation counters without permitting signed integer overflow to become valid-looking durable state.

func BoundOperationContextReport added in v0.6.0

func BoundOperationContextReport(report knowl.OperationContextReport) (knowl.OperationContextReport, error)

BoundOperationContextReport omits diagnostic entries, never model pages or measured counts.

func DecodeMaintenanceDiagnostics added in v0.5.0

func DecodeMaintenanceDiagnostics(payload string) ([]knowl.MaintenanceDiagnostic, error)

DecodeMaintenanceDiagnostics fails closed on malformed or non-canonical durable payloads.

func DecodeOperationContextReport added in v0.6.0

func DecodeOperationContextReport(payload string, workAttempt int) (*knowl.OperationContextReport, error)

DecodeOperationContextReport preserves missing and historical evidence and rejects corruption.

func DecodeOperationCorrectionReport added in v0.6.0

func DecodeOperationCorrectionReport(payload string, workAttempt int) (*knowl.OperationCorrectionReport, error)

DecodeOperationCorrectionReport preserves absent legacy facts and measured zeros.

func DecodeOperationRetrieval added in v0.6.0

func DecodeOperationRetrieval(encoded string, attempt, workAttempt int) (*knowl.RetrievalReport, int, error)

DecodeOperationRetrieval preserves historical attempt evidence for recovery while identifying which attempt produced it. Corrupt/future attempts fail closed.

func DecodeRetrievalReport added in v0.6.0

func DecodeRetrievalReport(encoded string) (*knowl.RetrievalReport, error)

DecodeRetrievalReport accepts legacy null/empty fields and otherwise fails closed on malformed, oversized, unknown-field or invalid report data.

func DefaultCatalogLimits added in v0.6.0

func DefaultCatalogLimits() knowl.CatalogLimits

DefaultCatalogLimits returns finite local catalog-context ceilings. These limits are independent of the number of selected factual pages.

func DefaultHierarchyLimits added in v0.4.0

func DefaultHierarchyLimits() knowl.HierarchyLimits

DefaultHierarchyLimits returns bounded defaults large enough for local multi-source workspaces while remaining below repository hard ceilings.

func DefaultReadLimits

func DefaultReadLimits() knowl.ReadLimits

DefaultReadLimits returns the local bounded context defaults.

func EffectiveOutputCorrectionPolicy added in v0.6.0

func EffectiveOutputCorrectionPolicy(settings knowl.OutputSettings, supported bool) (knowl.OutputCorrectionPolicy, error)

func EncodeMaintenanceDiagnostics added in v0.5.0

func EncodeMaintenanceDiagnostics(input []knowl.MaintenanceDiagnostic) (string, error)

EncodeMaintenanceDiagnostics returns the canonical bounded persistence form.

func EncodeOperationContextReport added in v0.6.0

func EncodeOperationContextReport(report knowl.OperationContextReport) (string, error)

EncodeOperationContextReport validates before publishing or storing evidence.

func EncodeOperationCorrectionReport added in v0.6.0

func EncodeOperationCorrectionReport(report knowl.OperationCorrectionReport) (string, error)

EncodeOperationCorrectionReport validates content-free evidence before storage.

func EncodeOperatorOperationPosition added in v0.6.0

func EncodeOperatorOperationPosition(position OperatorOperationPosition) (string, error)

EncodeOperatorOperationPosition creates the backend continuation key.

func EncodeRetirementMaintenanceRequest added in v0.7.0

func EncodeRetirementMaintenanceRequest(ctx context.Context, input knowl.RetirementInput) ([]byte, error)

EncodeRetirementMaintenanceRequest returns the canonical provider envelope.

func EncodeRetrievalReport added in v0.6.0

func EncodeRetrievalReport(report knowl.RetrievalReport) (string, error)

EncodeRetrievalReport produces bounded redacted JSON for an actual attempt.

func EncodeSourceMaintenanceRequest added in v0.6.0

func EncodeSourceMaintenanceRequest(ctx context.Context, input knowl.MaintenanceInput) ([]byte, error)

EncodeSourceMaintenanceRequest is the shared source envelope representation. It preserves full Content once, without changing application snapshots. The cap covers envelope bytes here; runtime sizing also counts its wrapper.

func EncodeSourceRef added in v0.7.0

func EncodeSourceRef(identity SourceRefIdentity) (string, error)

EncodeSourceRef returns the stable citation spelling for one exact source. Existing unambiguous refs retain their legacy adapter:id@revision spelling; delimiter-bearing identities use the collision-free v2 percent encoding.

func ExecutionDescriptorFromMeta

func ExecutionDescriptorFromMeta(id knowl.OperationID, key knowl.OperationKey, meta knowl.OperationMeta) (knowl.ExecutionDescriptor, error)

ExecutionDescriptorFromMeta validates reservation inputs and builds the bounded descriptor that operational stores persist atomically.

func FailedRetrievalReport added in v0.6.0

func FailedRetrievalReport(ctx context.Context, report knowl.RetrievalReport, cause error) knowl.RetrievalReport

FailedRetrievalReport marks a failed hybrid read without publishing unsafe causes.

func HierarchyOutputPlannerVersion added in v0.6.0

func HierarchyOutputPlannerVersion(base string, policy knowl.OutputCorrectionPolicy) (string, error)

HierarchyOutputPlannerVersion binds planning identity to its effective policy.

func HierarchyPlanDigest added in v0.4.0

func HierarchyPlanDigest(plan knowl.ValidatedHierarchyPlan) (string, error)

HierarchyPlanDigest returns a deterministic SHA-256 digest of a normalized validated hierarchy plan.

func IsManagedHierarchyCatalog added in v0.4.0

func IsManagedHierarchyCatalog(candidate string) bool

IsManagedHierarchyCatalog reports whether a canonical workspace path is owned by hierarchy reconciliation.

func MaintenanceGenerationPrefix added in v0.5.0

func MaintenanceGenerationPrefix(generation string) (string, error)

MaintenanceGenerationPrefix returns the bounded operator-facing portion of a generation while retaining the empty legacy sentinel.

func MaintenancePolicyGeneration added in v0.5.0

func MaintenancePolicyGeneration(policy MaintenancePolicy) (string, error)

MaintenancePolicyGeneration returns the full lowercase SHA-256 digest of a canonical, allow-listed policy payload.

func MaxSourceMaintenanceRetryResultIDs added in v0.4.0

func MaxSourceMaintenanceRetryResultIDs() int

MaxSourceMaintenanceRetryResultIDs is the public bound for affected IDs.

func NormalizeCatalogLimits added in v0.6.0

func NormalizeCatalogLimits(limits knowl.CatalogLimits) (knowl.CatalogLimits, error)

NormalizeCatalogLimits supplies defaults only for an entirely zero value.

func NormalizeHierarchyInput added in v0.4.0

func NormalizeHierarchyInput(input knowl.HierarchyInput) (knowl.HierarchyInput, error)

NormalizeHierarchyInput validates and deterministically orders the complete bounded semantic input before it crosses the provider trust boundary.

func NormalizeMaintenanceDiagnostics added in v0.5.0

func NormalizeMaintenanceDiagnostics(input []knowl.MaintenanceDiagnostic) ([]knowl.MaintenanceDiagnostic, error)

NormalizeMaintenanceDiagnostics validates, de-duplicates, sorts, and copies the bounded redacted diagnostics attached to one maintenance operation.

func NormalizeMaintenanceInputLimits added in v0.6.0

func NormalizeMaintenanceInputLimits(limits knowl.MaintenanceInputLimits) (knowl.MaintenanceInputLimits, error)

NormalizeMaintenanceInputLimits selects the finite default or validates a cap.

func NormalizeOutputSettings added in v0.6.0

func NormalizeOutputSettings(settings knowl.OutputSettings) (knowl.OutputCorrectionLimits, error)

NormalizeOutputSettings applies the fixed sequence ceilings and explicit allowance.

func NormalizeRetryFailureClasses added in v0.4.0

func NormalizeRetryFailureClasses(classes []string) ([]string, error)

NormalizeRetryFailureClasses validates, de-duplicates, and sorts the operator-selected stable failure identifiers.

func NormalizeSourceMutationPlan added in v0.3.0

func NormalizeSourceMutationPlan(plan knowl.SourceMutationPlan) (knowl.SourceMutationPlan, error)

NormalizeSourceMutationPlan validates, copies, and deterministically orders a source-owned canonical plan before it reaches a content store.

func NormalizeSourcesFilter added in v0.3.0

func NormalizeSourcesFilter(sources []knowl.SourceID) ([]knowl.SourceID, error)

NormalizeSourcesFilter returns a canonical bounded source identity filter. Empty input means unfiltered retrieval.

func OperationIDForIdentity added in v0.4.0

func OperationIDForIdentity(identity knowl.OperationIdentity) (knowl.OperationID, error)

OperationIDForIdentity returns the deterministic ID used by non-legacy generic work. Legacy source reservations keep their historical ID format.

func PlanDigest

func PlanDigest(plan knowl.ValidatedEditPlan) (string, error)

PlanDigest returns a deterministic digest of a validated plan.

func PreparedSyncDigest added in v0.3.0

func PreparedSyncDigest(prepared PreparedSyncState) (string, error)

PreparedSyncDigest returns the canonical lowercase SHA-256 candidate digest of one prepared payload. The reconciliation service and both concrete stores recompute it so an arbitrary caller-supplied digest cannot bless different durable candidates. Timing fields are excluded; deleted timestamps are encoded at microsecond precision for backend parity.

func PreparedSyncDigestVersioned added in v0.7.0

func PreparedSyncDigestVersioned(prepared PreparedSyncState, version PreparedSyncDigestVersion) (string, error)

PreparedSyncDigestVersioned returns the canonical digest for one explicit durable encoding version. Legacy v0 implies MaintenanceReady=false.

func PublicOperationDetails added in v0.6.0

func PublicOperationDetails(operation knowl.Operation) *knowl.OperationDetails

PublicOperationDetails publishes only validated, bounded application facts.

func PublicRetrievalStatus added in v0.6.0

func PublicRetrievalStatus(report *knowl.RetrievalReport) *knowl.RetrievalStatus

PublicRetrievalStatus excludes internal selection counts and model identity. Missing legacy evidence remains missing; invalid evidence is never published.

func ResolveSourceDocument added in v0.3.0

func ResolveSourceDocument(sourceID knowl.SourceID, accepted knowl.AcceptedSource, fallback knowl.SourceDocument) (knowl.SourceDocument, error)

ResolveSourceDocument returns persisted configured-source provenance, or a validated deterministic fallback for a legacy accepted manifest.

func RetirementPageOperationIdentity added in v0.7.0

func RetirementPageOperationIdentity(scope knowl.ScopeRef, generation string, pageID knowl.PageID) knowl.OperationIdentity

RetirementPageOperationIdentity returns the deterministic identity for one page in one retirement generation. The triggering owner is deliberately not part of the identity: a page is reconciled once even when it cites multiple retiring owners.

func RevalidateRetirementStage added in v0.7.0

func RevalidateRetirementStage(ctx context.Context, lifecycles SourceLifecycleReader, staged knowl.StagedChange) error

RevalidateRetirementStage checks one stage against the lifecycle state read while a bound RetirementCommitter holds its shared apply fence.

func SourceConfigDigest added in v0.3.0

func SourceConfigDigest(source knowl.Source) (string, error)

SourceConfigDigest returns a deterministic one-way digest of normalized config.

func SourceLifecycleGeneration added in v0.7.0

func SourceLifecycleGeneration(desired []DesiredSourceOwner) string

SourceLifecycleGeneration returns the deterministic digest of one desired exact-owner inventory. The persisted authority epoch distinguishes later reconciliations that intentionally return to the same inventory.

func SourceOperationID added in v0.5.0

func SourceOperationID(key knowl.OperationKey) (knowl.OperationID, error)

SourceOperationID returns the historical source ID for a legacy empty generation and a generation-discriminated ID for current maintenance work.

func SourceOwnerFromType added in v0.7.0

func SourceOwnerFromType(sourceType knowl.SourceType, sourceID knowl.SourceID) (knowl.SourceOwner, error)

SourceOwnerFromType returns the provenance owner for a configured source type.

func SourceRefAliases added in v0.7.0

func SourceRefAliases(source knowl.AcceptedSource) []string

SourceRefAliases returns the canonical key and, when it differs, the legacy surface spelling retained for reading already-persisted pages.

func SourceRefKey

func SourceRefKey(source knowl.AcceptedSource) string

SourceRefKey is the stable citation key required in a plan.

func SourceRefMatches added in v0.7.0

func SourceRefMatches(ref string, source knowl.AcceptedSource) bool

SourceRefMatches reports whether a canonical or legacy citation denotes the exact accepted identity. A colliding legacy spelling is intentionally not disambiguated here; trusted resolution must establish uniqueness first.

func SourceTransitionTime added in v0.7.0

func SourceTransitionTime(candidate time.Time, predecessors ...time.Time) time.Time

SourceTransitionTime returns a UTC timestamp that cannot precede any supplied durable predecessor. Callers still validate required non-zero candidate timestamps before normalization.

func ValidOperationPlanDigest added in v0.6.0

func ValidOperationPlanDigest(digest string) bool

ValidOperationPlanDigest keeps opaque legacy/custom digests out of public summaries.

func ValidOperatorReadPath added in v0.6.0

func ValidOperatorReadPath(relative string) bool

ValidOperatorReadPath checks literal canonical relative paths before a descriptor-relative open. Percent is permitted in real filenames, except alias-shaped escapes that could become separators or dot segments after an extra URL decode. Windows colons remain forbidden because of ADS semantics.

func ValidOutputValidationCode added in v0.6.0

func ValidOutputValidationCode(code knowl.OutputValidationCode) bool

func ValidRetrievalFailure added in v0.6.0

func ValidRetrievalFailure(code knowl.RetrievalFailure) bool

ValidRetrievalFailure rejects arbitrary upstream strings from safe reports.

func ValidateAcceptedSourceDescriptor added in v0.7.0

func ValidateAcceptedSourceDescriptor(source knowl.AcceptedSource) error

ValidateAcceptedSourceDescriptor validates complete configured-source provenance before immutable bytes are exposed to maintenance providers.

func ValidateDocument added in v0.3.0

func ValidateDocument(document knowl.Document, maxContentBytes int) error

ValidateDocument validates one fetched adapter result against an explicit content limit and the common source metadata bounds.

func ValidateDocumentID added in v0.3.0

func ValidateDocumentID(id knowl.DocumentID) error

ValidateDocumentID validates a canonical relative logical document identity.

func ValidateDocumentPage added in v0.3.0

func ValidateDocumentPage(page knowl.DocumentPage, maxDocuments int) error

ValidateDocumentPage validates a bounded descriptor page returned by an adapter.

func ValidateDocumentRef added in v0.3.0

func ValidateDocumentRef(ref knowl.DocumentRef) error

ValidateDocumentRef validates one untrusted source descriptor.

func ValidateExecutionDescriptor

func ValidateExecutionDescriptor(key knowl.OperationKey, descriptor knowl.ExecutionDescriptor) error

ValidateExecutionDescriptor verifies durable execution identity and bounded schema content without exposing descriptor data in errors.

func ValidateExecutionSchema added in v0.5.0

func ValidateExecutionSchema(scope knowl.ScopeRef, schema knowl.SchemaDocument) error

ValidateExecutionSchema verifies that a schema snapshot is safe to persist as a durable execution input.

func ValidateGenericExecutionDescriptor added in v0.4.0

func ValidateGenericExecutionDescriptor(scope knowl.ScopeRef, descriptor knowl.ExecutionDescriptor) error

ValidateGenericExecutionDescriptor validates a descriptor read from durable storage when its original identity fields are no longer needed by callers.

func ValidateHierarchyPlan added in v0.4.0

func ValidateHierarchyPlan(ctx context.Context, input knowl.HierarchyInput, model knowl.HierarchyModelPlan, options HierarchyValidationOptions) (knowl.ValidatedHierarchyPlan, error)

ValidateHierarchyPlan validates a complete semantic graph and renders the desired managed OKF catalogs. It never accepts provider-supplied file bytes.

func ValidateMaintenanceAuthority added in v0.7.0

func ValidateMaintenanceAuthority(ctx context.Context, reader SourceLifecycleReader, content RetirementContentReader, scope knowl.ScopeRef, edits []knowl.FileEdit, declared []string, expected *maintenanceauthority.Stamp) (*maintenanceauthority.Stamp, []knowl.MaintenanceDiagnostic, error)

ValidateMaintenanceAuthority authenticates exact configured owners against active lifecycle authority. Revalidation compares only applicable owner configuration/activation stamps, so unrelated inventory changes remain safe.

func ValidateMaintenanceGeneration added in v0.5.0

func ValidateMaintenanceGeneration(generation string) error

ValidateMaintenanceGeneration accepts the legacy empty sentinel or one canonical full policy digest.

func ValidateMaintenancePlan added in v0.6.0

func ValidateMaintenancePlan(ctx context.Context, input knowl.MaintenanceInput, model knowl.ModelEditPlan, inspection knowl.WorkspaceInspection, catalogLimits knowl.CatalogLimits, planLimits PlanLimits) (knowl.ValidatedEditPlan, error)

ValidateMaintenancePlan renders bounded navigation intents from authoritative originals before validating the combined concrete file edits. StagePlan owns prospective canonical validation and digest preconditions.

func ValidateOperationDescriptor added in v0.4.0

func ValidateOperationDescriptor(identity knowl.OperationIdentity, descriptor knowl.ExecutionDescriptor) error

ValidateOperationDescriptor verifies one generic identity and descriptor.

func ValidateOutputCorrectionLimits added in v0.6.0

func ValidateOutputCorrectionLimits(limits knowl.OutputCorrectionLimits) error

ValidateOutputCorrectionLimits enforces hard ceilings on a planning request.

func ValidateOwnedSourceDocument added in v0.3.0

func ValidateOwnedSourceDocument(sourceID knowl.SourceID, document knowl.SourceDocument) error

ValidateOwnedSourceDocument validates provenance against its configured owner.

func ValidatePlan

func ValidatePlan(ctx context.Context, input knowl.MaintenanceInput, plan knowl.ModelEditPlan, limits PlanLimits) (knowl.ValidatedEditPlan, error)

ValidatePlan turns provider data into an application-owned plan.

func ValidateRepositoryIdentity added in v0.4.0

func ValidateRepositoryIdentity(identity string) error

ValidateRepositoryIdentity accepts the bounded SHA-256 lineage binding used by durable source state without exposing the repository URL.

func ValidateRetirementOperationAssociation added in v0.7.0

func ValidateRetirementOperationAssociation(scope knowl.ScopeRef, id knowl.OperationID, owner knowl.SourceOwner, retirementGeneration string, pageID knowl.PageID) error

ValidateRetirementOperationAssociation validates one exact owner binding.

func ValidateRetirementOperationReadRequest added in v0.7.0

func ValidateRetirementOperationReadRequest(request RetirementOperationReadRequest) error

ValidateRetirementOperationReadRequest validates one finite durable-operation page.

func ValidateRetirementOperationRetry added in v0.7.0

func ValidateRetirementOperationRetry(scope knowl.ScopeRef, id knowl.OperationID, retirementGeneration string, retriedAt time.Time) error

ValidateRetirementOperationRetry validates one single-row retry CAS.

func ValidateRetirementPlanContext added in v0.7.0

func ValidateRetirementPlanContext(retirement *knowl.RetirementPlanContext) error

ValidateRetirementPlanContext validates the bounded exact page and owner authority encoded in a plan or authenticated stage.

func ValidateRetrievalReport added in v0.6.0

func ValidateRetrievalReport(report knowl.RetrievalReport) error

ValidateRetrievalReport enforces the allowlisted modes/reasons and finite producer counters before durable or transport publication.

func ValidateSafeFailure added in v0.4.0

func ValidateSafeFailure(failure knowl.Failure, requireReason bool) bool

ValidateSafeFailure verifies bounded metadata before it crosses a durable store boundary. A reason is required for retry scheduling, while terminal legacy failures may omit it.

func ValidateScanDocumentLimit added in v0.3.0

func ValidateScanDocumentLimit(limit int) error

ValidateScanDocumentLimit validates one bounded descriptor read limit.

func ValidateSource added in v0.3.0

func ValidateSource(source knowl.Source) error

ValidateSource validates the source discriminator, identity, and digest shape.

func ValidateSourceDigestLimit added in v0.3.0

func ValidateSourceDigestLimit(limit int) error

ValidateSourceDigestLimit validates one bounded canonical inventory limit.

func ValidateSourceDocument added in v0.3.0

func ValidateSourceDocument(document knowl.SourceDocument) error

ValidateSourceDocument validates complete bounded canonical provenance.

func ValidateSourceID added in v0.3.0

func ValidateSourceID(id knowl.SourceID) error

ValidateSourceID validates a canonical configured source identifier.

func ValidateSourceLifecycle added in v0.7.0

func ValidateSourceLifecycle(state knowl.SourceLifecycle) error

ValidateSourceLifecycle verifies a decoded durable row before it is trusted.

func ValidateSourceLifecycleReadyUpdate added in v0.7.0

func ValidateSourceLifecycleReadyUpdate(update SourceLifecycleReadyUpdate) error

ValidateSourceLifecycleReadyUpdate validates one readiness CAS.

func ValidateSourceOwner added in v0.7.0

func ValidateSourceOwner(owner knowl.SourceOwner) error

ValidateSourceOwner accepts only configured-source provenance adapters.

func ValidateSourceRefIdentity added in v0.7.0

func ValidateSourceRefIdentity(identity SourceRefIdentity) error

ValidateSourceRefIdentity validates the bounded opaque parts accepted by the citation codec and workspace address derivation.

func ValidateSourceRetirementFinalization added in v0.7.0

func ValidateSourceRetirementFinalization(finalization SourceRetirementFinalization) error

ValidateSourceRetirementFinalization validates one zero-ref deletion CAS.

func ValidateSourceRetirementUpdate added in v0.7.0

func ValidateSourceRetirementUpdate(update SourceRetirementUpdate) error

ValidateSourceRetirementUpdate validates one bounded scan progress CAS.

func ValidateSyncCounts added in v0.3.0

func ValidateSyncCounts(counts knowl.SyncCounts) error

ValidateSyncCounts rejects negative reconciliation counters.

func ValidateSyncRun added in v0.3.0

func ValidateSyncRun(run knowl.SyncRun) error

ValidateSyncRun validates one bounded redacted sync-run read model.

func ValidateSyncRunID added in v0.3.0

func ValidateSyncRunID(id knowl.SyncRunID) error

ValidateSyncRunID validates one bounded opaque durable run identifier.

Types

type AcceptedMaintenanceRequest added in v0.3.0

type AcceptedMaintenanceRequest struct {
	Source                      knowl.AcceptedSource `json:"source"`
	SourceDocument              knowl.SourceDocument `json:"source_document"`
	ContentType                 string               `json:"content_type"`
	PreviousMaintenanceRevision string               `json:"previous_maintenance_revision,omitempty"`
	PreviousOperationID         knowl.OperationID    `json:"previous_operation_id,omitempty"`
	PreviousGeneration          string               `json:"previous_generation,omitempty"`
}

AcceptedMaintenanceRequest identifies one configured textual source revision that has already been accepted into immutable raw storage.

type ApplyCoordinator added in v0.6.0

type ApplyCoordinator interface {
	Acquire(ctx context.Context) (release func(), err error)
}

ApplyCoordinator orders accepted-source ownership, canonical commits, and full projection publication. Standalone services may omit it; a Host shares one coordinator between every supported publisher and finalization fence.

type ApplyResult

type ApplyResult struct {
	Operation knowl.Operation
	Commit    *knowl.ContentCommit
}

ApplyResult contains the durable operation and the canonical commit, when one occurred.

type BeginSyncRequest added in v0.3.0

type BeginSyncRequest struct {
	Run                knowl.SyncRun
	Type               knowl.SourceType
	RepositoryIdentity string
	AllowRebind        bool
}

BeginSyncRequest begins or idempotently replays one durable run.

type CanonicalPageProvenance added in v0.7.0

type CanonicalPageProvenance struct {
	ID         knowl.PageID `json:"id"`
	Path       string       `json:"path"`
	Digest     string       `json:"digest"`
	SourceRefs []string     `json:"source_refs"`
}

CanonicalPageProvenance is the exact current precondition and provenance of one matching canonical page.

type CanonicalProvenanceCursor added in v0.7.0

type CanonicalProvenanceCursor string

CanonicalProvenanceCursor is an opaque, round-bound keyset position. A cooperating publication invalidates it with ErrCanonicalProvenanceRestart.

type CanonicalProvenanceFailure added in v0.7.0

type CanonicalProvenanceFailure struct {
	Code      string
	Path      string
	SourceRef string
	Cause     error
}

CanonicalProvenanceFailure carries stable machine-readable failure context.

func (*CanonicalProvenanceFailure) Error added in v0.7.0

func (failure *CanonicalProvenanceFailure) Error() string

func (*CanonicalProvenanceFailure) Unwrap added in v0.7.0

func (failure *CanonicalProvenanceFailure) Unwrap() error

type CanonicalProvenanceLimits added in v0.7.0

type CanonicalProvenanceLimits struct {
	Returned   int `json:"returned"`
	Examined   int `json:"examined"`
	PathBytes  int `json:"path_bytes"`
	PageBytes  int `json:"page_bytes"`
	TotalBytes int `json:"total_bytes"`
	SourceRefs int `json:"source_refs"`
	RoundPages int `json:"round_pages"`
}

CanonicalProvenanceLimits independently bound one call and one complete scan round.

func NormalizeCanonicalProvenanceLimits added in v0.7.0

func NormalizeCanonicalProvenanceLimits(limits CanonicalProvenanceLimits) (CanonicalProvenanceLimits, error)

NormalizeCanonicalProvenanceLimits supplies finite defaults only for an all-zero value.

type CanonicalProvenancePage added in v0.7.0

type CanonicalProvenancePage struct {
	Items         []CanonicalPageProvenance `json:"items"`
	NextCursor    CanonicalProvenanceCursor `json:"next_cursor,omitempty"`
	EOF           bool                      `json:"eof"`
	Authoritative bool                      `json:"authoritative"`
	Examined      int                       `json:"examined"`
	Returned      int                       `json:"returned"`
	RoundPages    int                       `json:"round_pages"`
}

CanonicalProvenancePage is one bounded deterministic keyset window. Examined counts parsed page bodies, not names scanned by bounded selection. Authoritative is true only when EOF completes an unchanged publisher generation in the supported single-Host writer model. Direct filesystem and shared multi-process mutations are outside this authority guarantee. It does not protect changes after PageProvenance returns; zero-reference finalization uses the ApplyCoordinator protocol on CanonicalProvenanceReader.

type CanonicalProvenanceReader added in v0.7.0

type CanonicalProvenanceReader interface {
	PageProvenance(ctx context.Context, scope knowl.ScopeRef, owner knowl.SourceOwner, cursor CanonicalProvenanceCursor, limits CanonicalProvenanceLimits) (CanonicalProvenancePage, error)
}

CanonicalProvenanceReader enumerates only bounded canonical provenance for one exact configured-source owner. It deliberately does not expose page bodies. Earlier windows do not require the Host's in-process ApplyCoordinator: a cooperating publication invalidates their cursor. Before relying on a final continuation as authoritative EOF, the caller must acquire ApplyCoordinator before that PageProvenance call and retain it through EOF and Authoritative validation and the lifecycle zero-reference CAS.

type CatalogReader added in v0.6.0

type CatalogReader interface {
	CatalogChildren(ctx context.Context, scope knowl.ScopeRef, parent knowl.PageID, options OperatorReadOptions) (OperatorCatalogRead, error)
}

CatalogReader is an optional consistent canonical catalog capability.

type Citation

type Citation struct {
	Kind      string       `json:"kind"`
	Reference string       `json:"reference"`
	PageID    knowl.PageID `json:"page_id,omitempty"`
	Path      string       `json:"path,omitempty"`
	SourceRef string       `json:"source_ref,omitempty"`
	Untrusted bool         `json:"untrusted"`
}

Citation is an untrusted wiki or raw-source reference assembled from query results.

type ClassifiedExecutionError added in v0.4.0

type ClassifiedExecutionError interface {
	error
	FailureClass() string
	FailureReason() string
	Retryable() bool
}

ClassifiedExecutionError is a safely renderable execution failure whose retry policy does not depend on parsing its Error string.

type ContentStore

type ContentStore interface {
	AcceptSource(ctx context.Context, envelope knowl.SourceEnvelope) (knowl.AcceptedSource, error)
	ReadSource(ctx context.Context, source knowl.AcceptedSource, limits knowl.ReadLimits) ([]byte, error)
	Schema(ctx context.Context, scope knowl.ScopeRef) (knowl.SchemaDocument, error)
	ReadPages(ctx context.Context, scope knowl.ScopeRef, ids []knowl.PageID, limits knowl.ReadLimits) ([]knowl.PageSnapshot, error)
	HierarchySnapshotDigest(ctx context.Context, scope knowl.ScopeRef) (string, error)
	StagePlan(ctx context.Context, plan knowl.ValidatedEditPlan) (knowl.StagedChange, error)
	LoadStage(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID) (knowl.StagedChange, error)
	Commit(ctx context.Context, staged knowl.StagedChange) (knowl.ContentCommit, error)
	StageHierarchyPlan(ctx context.Context, id knowl.OperationID, plan knowl.ValidatedHierarchyPlan) (knowl.StagedChange, error)
	LoadHierarchyStage(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID) (knowl.StagedChange, error)
	CommitHierarchy(ctx context.Context, staged knowl.StagedChange) (knowl.ContentCommit, error)
	Recover(ctx context.Context) ([]knowl.RecoveryResult, error)
	Snapshot(ctx context.Context, scope knowl.ScopeRef) (knowl.WorkspaceSnapshot, error)
	Inspect(ctx context.Context, scope knowl.ScopeRef) (knowl.WorkspaceInspection, error)
}

ContentStore owns canonical workspace content and recovery.

type DesiredSourceOwner added in v0.7.0

type DesiredSourceOwner struct {
	Owner        knowl.SourceOwner `json:"owner"`
	ConfigDigest string            `json:"config_digest"`
}

DesiredSourceOwner binds one desired exact owner to its normalized config digest.

type DiagnosticContextIndex added in v0.6.0

type DiagnosticContextIndex interface {
	SelectContextWithDiagnostics(ctx context.Context, scope knowl.ScopeRef, summary knowl.SourceSummary, limits knowl.ReadLimits) ([]knowl.PageID, knowl.RetrievalReport, knowl.ContextSelectionDiagnostics, error)
}

DiagnosticContextIndex preserves base ports while reporting actual selection.

type DocumentListOptions added in v0.3.0

type DocumentListOptions struct {
	IncludeDeleted bool
	Limit          int
}

DocumentListOptions bounds source document-state reads.

func ValidateDocumentListOptions added in v0.3.0

func ValidateDocumentListOptions(options DocumentListOptions) (DocumentListOptions, error)

ValidateDocumentListOptions validates and defaults a bounded state read.

type EmbeddingError added in v0.6.0

type EmbeddingError struct{ Code knowl.RetrievalFailure }

EmbeddingError contains only a stable redacted reason, never upstream text.

func (*EmbeddingError) Error added in v0.6.0

func (err *EmbeddingError) Error() string

func (*EmbeddingError) Unwrap added in v0.6.0

func (*EmbeddingError) Unwrap() error

type EmbeddingFailurePolicy added in v0.6.0

type EmbeddingFailurePolicy string

EmbeddingFailurePolicy controls an unavailable semantic retrieval channel.

const (
	EmbeddingFallbackLexical EmbeddingFailurePolicy = "lexical"
	EmbeddingStrict          EmbeddingFailurePolicy = "strict"
)

type EmbeddingOptions added in v0.6.0

type EmbeddingOptions struct {
	Provider      EmbeddingProvider
	Space         EmbeddingSpace
	FailurePolicy EmbeddingFailurePolicy
}

EmbeddingOptions configures one immutable store lifetime. Zero disables embeddings; HTTP endpoint/credentials belong to the provider, not the index.

type EmbeddingProvider added in v0.6.0

type EmbeddingProvider interface {
	Embed(ctx context.Context, inputs []string) ([][]float32, error)
}

EmbeddingProvider returns normalized vectors in one configured model space. Text preparation/prefixes belong to its caller, not the provider.

type EmbeddingSpace added in v0.6.0

type EmbeddingSpace struct {
	Model         string `json:"model"`
	Revision      string `json:"revision"`
	Dimensions    int    `json:"dimensions"`
	QueryPrefix   string `json:"query_prefix"`
	PassagePrefix string `json:"passage_prefix"`
}

EmbeddingSpace identifies the operator-declared immutable model contract. It intentionally cannot carry endpoints, credentials or runtime settings.

func NormalizeEmbeddingSpace added in v0.6.0

func NormalizeEmbeddingSpace(space EmbeddingSpace) (EmbeddingSpace, error)

NormalizeEmbeddingSpace validates shared nonsecret model/preprocessing input.

type ExecutionFailureInfo added in v0.4.0

type ExecutionFailureInfo struct {
	Class     string
	Reason    string
	Retryable bool
}

ExecutionFailureInfo is the validated, redacted policy carried by a ClassifiedExecutionError.

func ClassifyExecutionFailure added in v0.4.0

func ClassifyExecutionFailure(err error) (ExecutionFailureInfo, bool)

ClassifyExecutionFailure returns only bounded identifier-shaped metadata. Invalid implementations are ignored rather than trusted as safe output.

type FilingRequest

type FilingRequest struct {
	Query  string              `json:"query"`
	Result QueryResult         `json:"result"`
	Plan   knowl.ModelEditPlan `json:"plan"`
}

FilingRequest explicitly submits a query result and typed edit plan to the normal filing gate.

type HierarchyMaintainer added in v0.4.0

type HierarchyMaintainer interface {
	PlanHierarchy(ctx context.Context, input knowl.HierarchyInput) (knowl.HierarchyModelPlan, error)
}

HierarchyMaintainer produces a structured semantic catalog graph. The application remains responsible for graph validation and Markdown rendering.

type HierarchyOptions added in v0.4.0

type HierarchyOptions struct {
	ApplyCoordinator ApplyCoordinator
	Output           knowl.OutputSettings
	Limits           knowl.HierarchyLimits
	PlannerVersion   string
	LeaseDuration    time.Duration
}

HierarchyOptions configures explicit hierarchy reconciliation.

type HierarchyService added in v0.4.0

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

HierarchyService coordinates durable, explicit catalog-only reconciliation.

func NewHierarchyService added in v0.4.0

func NewHierarchyService(content ContentStore, operations OperationStore, index SearchIndex, maintainer HierarchyMaintainer, options HierarchyOptions) (*HierarchyService, error)

func (*HierarchyService) Reconcile added in v0.4.0

func (service *HierarchyService) Reconcile(ctx context.Context, scope knowl.ScopeRef) (IngestResult, error)

Reconcile reserves, exclusively claims, and synchronously executes the hierarchy operation for an explicit trusted mutation workflow.

func (*HierarchyService) Reserve added in v0.4.0

func (service *HierarchyService) Reserve(ctx context.Context, scope knowl.ScopeRef) (OperationReservation, error)

Reserve captures immutable execution identity without invoking the provider.

func (*HierarchyService) RunToTerminal added in v0.4.0

func (service *HierarchyService) RunToTerminal(ctx context.Context, claim knowl.WorkClaim) (IngestResult, error)

RunToTerminal executes one exclusively claimed hierarchy operation.

type HierarchyValidationOptions added in v0.4.0

type HierarchyValidationOptions struct {
	// ForbiddenCatalogTerms are configured source IDs or source-native namespace
	// names. A nested catalog path segment or complete title may not equal one.
	ForbiddenCatalogTerms []string
}

HierarchyValidationOptions contains application-only policy that must not be exposed as semantic provider context.

type InferenceFreeProjection added in v0.6.0

type InferenceFreeProjection interface {
	ProjectWithoutInference(ctx context.Context, commit knowl.ContentCommit) error
}

InferenceFreeProjection preserves concrete historical stages without running a newly configured model. Dense readiness is repaired separately at startup or by an explicit rebuild; canonical authority and lexical projection remain.

type IngestOptions

type IngestOptions struct {
	ApplyCoordinator ApplyCoordinator
	// CatalogLimits bounds complete navigation independently of ReadLimits.Pages.
	// An entirely zero value selects defaults; custom values must set every field.
	CatalogLimits knowl.CatalogLimits
	Output        knowl.OutputSettings
	// InputLimits bounds the complete source request; zero selects 4 MiB.
	InputLimits   knowl.MaintenanceInputLimits
	PlanLimits    PlanLimits
	ReadLimits    knowl.ReadLimits
	LeaseDuration time.Duration
	AutoApply     bool
}

IngestOptions configures bounded planning and the review gate.

type IngestResult

type IngestResult struct {
	Operation knowl.Operation
	Plan      knowl.ValidatedEditPlan
	Staged    knowl.StagedChange
	Commit    *knowl.ContentCommit
	// Budget is transient for this planning call; replay does not reconstruct it.
	Budget *knowl.MaintenanceBudgetReport
	// Retrieval is transient when a custom operation store cannot persist reports.
	Retrieval *knowl.RetrievalReport
	// Context is transient when a custom operation store cannot persist snapshots.
	Context    *knowl.OperationContextReport
	Correction *knowl.OperationCorrectionReport
}

IngestResult contains the durable operation and any plan or commit produced by this call.

type IngestService

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

IngestService coordinates source acceptance, planning, review, commit, and projection.

func NewIngestService

func NewIngestService(content ContentStore, operations OperationStore, index SearchIndex, maintainer Maintainer, options IngestOptions) (*IngestService, error)

NewIngestService constructs the application workflow with conservative defaults.

func (*IngestService) Apply

func (service *IngestService) Apply(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID) (ApplyResult, error)

Apply explicitly applies a planned operation after review.

func (*IngestService) CurrentMaintenancePolicy added in v0.5.0

func (service *IngestService) CurrentMaintenancePolicy(ctx context.Context, scope knowl.ScopeRef) (knowl.SchemaDocument, string, error)

CurrentMaintenancePolicy returns the current schema snapshot and its effective source-maintenance generation for an explicit manual transition.

func (*IngestService) Execute

func (service *IngestService) Execute(ctx context.Context, submission IngestSubmission) (IngestResult, error)

Execute runs host-owned maintenance for a previously accepted source revision.

func (*IngestService) FailSubmission

func (service *IngestService) FailSubmission(ctx context.Context, submission IngestSubmission, class string) error

FailSubmission records a failure after durable submission could not be scheduled.

func (*IngestService) FilePlan

func (service *IngestService) FilePlan(ctx context.Context, envelope knowl.SourceEnvelope, plan knowl.ModelEditPlan) (IngestResult, error)

FilePlan files an explicitly supplied query or maintenance plan through the same ingest gate.

func (*IngestService) Ingest

func (service *IngestService) Ingest(ctx context.Context, envelope knowl.SourceEnvelope) (IngestResult, error)

Ingest is a synchronous application convenience that submits then executes one source revision.

func (*IngestService) Preview

func (service *IngestService) Preview(ctx context.Context, envelope knowl.SourceEnvelope) (IngestResult, error)

Preview accepts and stages one source revision without applying it, even when auto-apply is enabled.

func (*IngestService) Recover

func (service *IngestService) Recover(ctx context.Context) ([]knowl.RecoveryResult, error)

Recover rolls back prepared canonical commits before the caller announces readiness.

func (*IngestService) ReserveAccepted added in v0.3.0

func (service *IngestService) ReserveAccepted(ctx context.Context, request AcceptedMaintenanceRequest) (MaintenanceReservation, error)

ReserveAccepted reserves maintenance for one structured textual revision without accepting or reading the raw bytes again.

func (*IngestService) RunToTerminal

func (service *IngestService) RunToTerminal(ctx context.Context, claim knowl.WorkClaim) (IngestResult, error)

RunToTerminal reconciles one exclusively claimed durable operation through the public sidecar path. Review is an internal convenience, not a runner stop.

func (*IngestService) Submit

func (service *IngestService) Submit(ctx context.Context, envelope knowl.SourceEnvelope) (IngestSubmission, error)

Submit accepts one immutable source revision and reserves its durable operation. It does not invoke the maintainer or make canonical workspace changes.

type IngestSubmission

type IngestSubmission struct {
	Operation knowl.Operation
	// contains filtered or unexported fields
}

IngestSubmission is the durable handoff from request-time source acceptance to host-owned maintenance execution.

func (IngestSubmission) NeedsExecution

func (submission IngestSubmission) NeedsExecution() bool

NeedsExecution reports whether this submission created work for the host queue.

type LintOptions

type LintOptions struct {
	ReadLimits knowl.ReadLimits
	Maintainer Maintainer
}

LintOptions configures deterministic lint and optional suggestion-only model lint.

type LintService

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

LintService inspects canonical workspace metadata without mutating it.

func NewLintService

func NewLintService(content ContentStore, index SearchIndex, options LintOptions) (*LintService, error)

NewLintService constructs a deterministic lint service.

func (*LintService) Lint

func (service *LintService) Lint(ctx context.Context, scope knowl.ScopeRef) (knowl.LintReport, error)

Lint returns deterministic structural, provenance, index, log, and projection findings.

type Maintainer

type Maintainer interface {
	Plan(ctx context.Context, input knowl.MaintenanceInput) (knowl.ModelEditPlan, error)
}

Maintainer produces structured data-only edit plans.

type MaintenanceAuthorityError added in v0.7.0

type MaintenanceAuthorityError struct{ Diagnostics []knowl.MaintenanceDiagnostic }

MaintenanceAuthorityError exposes bounded page/owner diagnostics without leaking lifecycle-store errors or source content.

func (*MaintenanceAuthorityError) Error added in v0.7.0

func (err *MaintenanceAuthorityError) Error() string

func (*MaintenanceAuthorityError) MaintenanceDiagnostics added in v0.7.0

func (err *MaintenanceAuthorityError) MaintenanceDiagnostics() []knowl.MaintenanceDiagnostic

func (*MaintenanceAuthorityError) SafeDetail added in v0.7.0

func (err *MaintenanceAuthorityError) SafeDetail() string

func (*MaintenanceAuthorityError) Unwrap added in v0.7.0

func (err *MaintenanceAuthorityError) Unwrap() error

type MaintenanceOutcome added in v0.5.0

type MaintenanceOutcome string

MaintenanceOutcome is the bounded decision made while reconciling accepted source work against its current effective maintenance policy.

const (
	MaintenanceQueued     MaintenanceOutcome = "queued"
	MaintenanceReplayed   MaintenanceOutcome = "replayed"
	MaintenanceConverged  MaintenanceOutcome = "converged"
	MaintenanceManualGate MaintenanceOutcome = "manual_gate"
)

type MaintenancePolicy added in v0.5.0

type MaintenancePolicy struct {
	Output               *knowl.OutputCorrectionPolicy
	RequestReservedBytes int
	Retrieval            *MaintenanceRetrievalPolicy
	CatalogLimits        knowl.CatalogLimits
	InputLimits          knowl.MaintenanceInputLimits
	RequestFormatVersion string
	ContractVersion      string
	SchemaDigest         string
	ReadLimits           knowl.ReadLimits
	PlanLimits           PlanLimits
}

MaintenancePolicy is the explicit non-secret input to source-maintenance generation. It intentionally cannot carry provider or runtime configuration.

func SourceMaintenancePolicy added in v0.5.0

func SourceMaintenancePolicy(schemaDigest string, readLimits knowl.ReadLimits, planLimits PlanLimits) MaintenancePolicy

SourceMaintenancePolicy constructs the effective policy used by ingestion.

type MaintenanceRequestSizer added in v0.6.0

type MaintenanceRequestSizer interface {
	RequestBudget() knowl.MaintenanceRequestBudget
	RequestBytes(ctx context.Context, input knowl.MaintenanceInput) (int, error)
}

MaintenanceRequestSizer declares a pure, finite source request budget and measures the same representation that Plan will send, including its wrapper. Capacity and format identity are captured once before durable reservation. Implementations must not initialize providers, download, or infer here. A maintainer without this port assumes only the shared JSON envelope; custom wrappers must implement it to cover the complete current request.

type MaintenanceReservation added in v0.3.0

type MaintenanceReservation struct {
	OperationID      knowl.OperationID  `json:"operation_id"`
	Generation       string             `json:"generation,omitempty"`
	PolicyGeneration string             `json:"-"`
	Outcome          MaintenanceOutcome `json:"outcome,omitempty"`
	Replayed         bool               `json:"replayed"`
}

MaintenanceReservation is the bounded durable handoff returned to source reconciliation. Replayed reports that the operation already existed.

type MaintenanceRetrievalPolicy added in v0.6.0

type MaintenanceRetrievalPolicy struct {
	Mode                knowl.RetrievalMode    `json:"mode"`
	ModelSpace          string                 `json:"model_space"`
	Preprocessing       string                 `json:"preprocessing"`
	VectorNormalization string                 `json:"vector_normalization"`
	Fusion              string                 `json:"fusion"`
	RankConstant        int                    `json:"rank_constant"`
	MinimumCandidates   int                    `json:"minimum_candidates"`
	MaximumCandidates   int                    `json:"maximum_candidates"`
	CandidateMultiplier int                    `json:"candidate_multiplier"`
	MaxChunks           int                    `json:"max_chunks"`
	MaxProjectionBytes  int                    `json:"max_projection_bytes"`
	FailurePolicy       EmbeddingFailurePolicy `json:"failure_policy"`
}

MaintenanceRetrievalPolicy contains only output-affecting retrieval choices. Endpoints, credentials, inference timeout/concurrency and deployment cannot enter maintenance identity through this allowlisted shape.

type MaintenanceRetrievalPolicyProvider added in v0.6.0

type MaintenanceRetrievalPolicyProvider interface {
	MaintenanceRetrievalPolicy() *MaintenanceRetrievalPolicy
}

type OperationContextReportStore added in v0.6.0

type OperationContextReportStore interface {
	SaveOperationContextReport(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, attempt int, report knowl.OperationContextReport) error
}

OperationContextReportStore persists one immutable snapshot for the current attempt.

type OperationCorrectionReportStore added in v0.6.0

type OperationCorrectionReportStore interface {
	SaveOperationCorrectionReport(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, attempt int, report knowl.OperationCorrectionReport) error
}

OperationCorrectionReportStore preserves one finalized report per work attempt.

type OperationDiagnosticStore added in v0.7.0

type OperationDiagnosticStore interface {
	SaveOperationDiagnostics(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, workAttempt int, diagnostics []knowl.MaintenanceDiagnostic) error
}

OperationDiagnosticStore persists bounded page-local failure evidence separately from commit-bound plan diagnostics.

type OperationKind

type OperationKind string

OperationKind identifies the policy operation being authorized.

const (
	OperationRead   OperationKind = "read"
	OperationWrite  OperationKind = "write"
	OperationReview OperationKind = "review"
)

type OperationLister added in v0.6.0

type OperationLister interface {
	ListOperations(ctx context.Context, scope knowl.ScopeRef, options OperatorOperationReadOptions) (OperatorReadPage[knowl.OperatorOperationSummary], error)
}

OperationLister is an optional scoped, filterable durable read capability. Continuation keys must describe the immutable operation creation tuple.

type OperationReservation

type OperationReservation struct {
	knowl.Operation
	Descriptor knowl.ExecutionDescriptor
	New        bool
}

OperationReservation is the durable result of reserving one immutable source revision. New reports whether this call created the operation rather than replaying it.

type OperationStore

type OperationStore interface {
	Reserve(ctx context.Context, key knowl.OperationKey, meta knowl.OperationMeta) (OperationReservation, error)
	ReserveOperation(ctx context.Context, identity knowl.OperationIdentity, descriptor knowl.ExecutionDescriptor) (OperationReservation, error)
	Execution(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID) (knowl.ExecutionDescriptor, error)
	ResumeReady(ctx context.Context, scope knowl.ScopeRef, limit int) ([]knowl.OperationID, error)
	ClaimReady(ctx context.Context, scope knowl.ScopeRef, lease knowl.WorkLease) (knowl.WorkClaim, error)
	ClaimOperation(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, lease knowl.WorkLease) (knowl.WorkClaim, error)
	RenewClaim(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, currentToken string, next knowl.WorkLease) error
	ReleaseClaim(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, token string) error
	ScheduleRetry(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, token string, failure knowl.Failure, readyAt time.Time) error
	DescriptorFailures(ctx context.Context, scope knowl.ScopeRef, limit int) ([]knowl.OperationID, error)
	SavePlan(ctx context.Context, id knowl.OperationID, summary knowl.PlanSummary) error
	MarkAwaitingReview(ctx context.Context, id knowl.OperationID) error
	MarkApplying(ctx context.Context, id knowl.OperationID, lease knowl.Lease) error
	CommitOutcome(ctx context.Context, id knowl.OperationID, commit knowl.ContentCommit) error
	Fail(ctx context.Context, id knowl.OperationID, failure knowl.Failure) error
	FailClaim(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, token string, failure knowl.Failure) error
	Operation(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID) (knowl.Operation, error)
}

OperationStore owns durable operation state, leases, and redacted outcomes.

type OperatorCatalogRead added in v0.6.0

type OperatorCatalogRead struct {
	Parent   knowl.OperatorCatalogSummary
	Children OperatorReadPage[knowl.OperatorCatalogChild]
}

OperatorCatalogRead contains one parent and its bounded direct child page.

type OperatorContinuation added in v0.6.0

type OperatorContinuation struct {
	Key             string
	SnapshotVersion string
}

OperatorContinuation is a verified backend position. Canonical readers bind Key to SnapshotVersion. Operation readers use an immutable created_at + operation_id tuple; mutable status/updated_at values cannot be positions. Readers never receive or decode an untrusted public cursor.

type OperatorListOptions added in v0.6.0

type OperatorListOptions struct {
	Limit  int
	Cursor string
}

OperatorListOptions specifies bounded pagination without a scope selector. Zero Limit means omitted; HTTP adapters reject explicitly supplied zero.

type OperatorOperationListOptions added in v0.6.0

type OperatorOperationListOptions struct {
	OperatorListOptions
	Status   knowl.OperationStatus
	SourceID knowl.SourceID
}

OperatorOperationListOptions filters durable facts by status and stored source association.

type OperatorOperationPosition added in v0.6.0

type OperatorOperationPosition struct {
	CreatedAt   time.Time         `json:"created_at"`
	OperationID knowl.OperationID `json:"operation_id"`
}

OperatorOperationPosition is the immutable durable operation creation tuple. Stores use the shared codec rather than selecting mutable status/update keys.

func DecodeOperatorOperationPosition added in v0.6.0

func DecodeOperatorOperationPosition(key string) (OperatorOperationPosition, error)

DecodeOperatorOperationPosition decodes a verified backend key, not a public cursor.

type OperatorOperationReadOptions added in v0.6.0

type OperatorOperationReadOptions struct {
	OperatorReadOptions
	Status   knowl.OperationStatus
	SourceID knowl.SourceID
}

OperatorOperationReadOptions adds normalized stored-association filters.

type OperatorOptions added in v0.6.0

type OperatorOptions struct{ ReadLimits knowl.ReadLimits }

OperatorOptions contains trusted host-owned read bounds.

type OperatorReadOptions added in v0.6.0

type OperatorReadOptions struct {
	Limit        int
	Continuation OperatorContinuation
	ReadLimits   knowl.ReadLimits
}

OperatorReadOptions bounds one reader call under a finite read deadline.

type OperatorReadPage added in v0.6.0

type OperatorReadPage[T any] struct {
	Items           []T
	NextKey         string
	SnapshotVersion string
}

OperatorReadPage is a backend result, not a public cursor envelope. Canonical readers supply a SHA-256 SnapshotVersion even for a successful empty list. NextKey is immutable, bounded, and empty when there is no next page.

type OperatorReaders added in v0.6.0

type OperatorReaders struct {
	Catalogs    CatalogReader
	Directories WikiDirectoryReader
	Pages       PageSummaryReader
	Page        PageReader
	Revisions   SourceRevisionReader
	Sources     OperatorSourceReader
	Documents   SourceDocumentLister
	Operations  OperationLister
	Retirements SourceRetirementReader
}

OperatorReaders contains only independently optional read capabilities.

type OperatorService added in v0.6.0

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

OperatorService dispatches narrow read capabilities under one host-bound scope. It has no mutation, scheduling, model-provider or maintenance dependencies.

func NewOperatorService added in v0.6.0

func NewOperatorService(scope knowl.ScopeRef, readers OperatorReaders, options OperatorOptions) (*OperatorService, error)

NewOperatorService binds independently optional readers to a trusted host scope. Its random signing key lives only for this service's lifetime.

func (*OperatorService) CatalogChildren added in v0.6.0

func (service *OperatorService) CatalogChildren(ctx context.Context, parent knowl.PageID, options OperatorListOptions) (knowl.OperatorCatalog, error)

CatalogChildren reads the root (empty parent) or one validated direct catalog.

func (*OperatorService) Operations added in v0.6.0

Operations reads durable summaries with normalized stored-association filters.

func (*OperatorService) Page added in v0.6.0

func (service *OperatorService) Page(ctx context.Context, id knowl.PageID) (knowl.OperatorPage, error)

Page returns detached current Markdown, metadata and resolved page-level provenance.

func (*OperatorService) PageSummaries added in v0.6.0

PageSummaries reads a consistent bounded factual-page inventory.

func (*OperatorService) Source added in v0.6.0

Source reads safe configured status plus independently optional document summaries.

func (*OperatorService) SourceRetirement added in v0.7.0

func (service *OperatorService) SourceRetirement(ctx context.Context, owner knowl.SourceOwner) (knowl.SourceRetirementStatus, error)

SourceRetirement returns one detached adapter-qualified lifecycle view.

func (*OperatorService) SourceRevision added in v0.6.0

func (service *OperatorService) SourceRevision(ctx context.Context, ref string) (knowl.OperatorSourceRevision, error)

SourceRevision returns an accepted immutable text revision, never adapter fetches.

func (*OperatorService) Sources added in v0.6.0

Sources returns configured identities and safe durable status projections.

func (*OperatorService) WikiDirectoryChildren added in v0.6.0

func (service *OperatorService) WikiDirectoryChildren(ctx context.Context, directory string, options OperatorListOptions) (knowl.OperatorList[knowl.OperatorWikiEntry], error)

WikiDirectoryChildren reads one bounded branch of the published wiki path tree. The empty directory selects the root, not a page-path alias.

type OperatorSourceReader added in v0.6.0

type OperatorSourceReader interface {
	ListSources(ctx context.Context, scope knowl.ScopeRef, options OperatorReadOptions) (OperatorReadPage[knowl.OperatorSourceSummary], error)
	Source(ctx context.Context, scope knowl.ScopeRef, id knowl.SourceID) (knowl.OperatorSourceSummary, error)
}

OperatorSourceReader composes configured source identities and durable status. It must return safe detached projections, never source configuration.

type PageReader added in v0.6.0

type PageReader interface {
	Page(ctx context.Context, scope knowl.ScopeRef, id knowl.PageID, limits knowl.ReadLimits) (knowl.OperatorPage, error)
}

PageReader is an optional bounded current canonical page capability.

type PageSummaryReader added in v0.6.0

type PageSummaryReader interface {
	PageSummaries(ctx context.Context, scope knowl.ScopeRef, options OperatorReadOptions) (OperatorReadPage[knowl.OperatorPageSummary], error)
}

PageSummaryReader is an optional consistent factual-page inventory capability.

type PlanLimits

type PlanLimits struct {
	MaxFiles         int
	MaxFileBytes     int
	MaxSourceRefs    int
	MaxRationaleSize int
}

PlanLimits bounds model output before it reaches a content adapter.

func DefaultPlanLimits

func DefaultPlanLimits() PlanLimits

DefaultPlanLimits returns conservative local plan limits.

type PreparedDocumentState added in v0.3.0

type PreparedDocumentState struct {
	Action SyncDocumentAction
	State  knowl.DocumentState
}

PreparedDocumentState is one durable candidate applied only at finalization.

func NormalizePreparedDocuments added in v0.3.0

func NormalizePreparedDocuments(scope knowl.ScopeRef, sourceID knowl.SourceID, runID knowl.SyncRunID, documents []PreparedDocumentState) ([]PreparedDocumentState, error)

NormalizePreparedDocuments copies, deterministically orders, and validates the candidate set of one complete-scan prepared state against its owning run.

type PreparedSyncDigestVersion added in v0.7.0

type PreparedSyncDigestVersion uint8

PreparedSyncDigestVersion identifies the canonical prepared-payload encoding.

const (
	// PreparedSyncDigestLegacyV0 is the pre-maintenance-readiness encoding.
	PreparedSyncDigestLegacyV0 PreparedSyncDigestVersion = iota
	// PreparedSyncDigestMaintenanceV1 binds maintenance readiness into the digest.
	PreparedSyncDigestMaintenanceV1
)

type PreparedSyncRead added in v0.3.0

type PreparedSyncRead struct {
	RunID            knowl.SyncRunID         `json:"run_id"`
	Scope            knowl.ScopeRef          `json:"scope"`
	SourceID         knowl.SourceID          `json:"source_id"`
	MaintenanceReady bool                    `json:"maintenance_ready"`
	Checkpoint       string                  `json:"checkpoint,omitempty"`
	Counts           knowl.SyncCounts        `json:"counts"`
	Documents        []PreparedDocumentState `json:"documents,omitempty"`
	CandidateDigest  string                  `json:"candidate_digest"`
}

PreparedSyncRead is the immutable prepared-scan result restored from durable state.

type PreparedSyncState added in v0.3.0

type PreparedSyncState struct {
	RunID            knowl.SyncRunID
	Scope            knowl.ScopeRef
	SourceID         knowl.SourceID
	CompleteScan     bool
	MaintenanceReady bool
	Checkpoint       string
	Counts           knowl.SyncCounts
	Documents        []PreparedDocumentState
	CandidateDigest  string
	PreparedAt       time.Time
}

PreparedSyncState is the immutable complete-scan result prepared for commit.

type QueryOptions

type QueryOptions struct {
	ReadLimits knowl.ReadLimits
}

QueryOptions configures bounded wiki-first reads.

type QueryResult

type QueryResult struct {
	Retrieval *knowl.RetrievalReport `json:"retrieval,omitempty"`
	Scope     knowl.ScopeRef         `json:"scope"`
	Query     string                 `json:"query"`
	Pages     []knowl.PageReference  `json:"pages"`
	Links     []knowl.LinkReference  `json:"links"`
	Citations []Citation             `json:"citations"`
}

QueryResult is a bounded, read-only composition of wiki references and raw citations.

type QueryService

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

QueryService owns bounded wiki-first reads and explicit filing.

func NewQueryService

func NewQueryService(content ContentStore, operations OperationStore, index SearchIndex, filer *IngestService, options QueryOptions) (*QueryService, error)

NewQueryService constructs a read service. Filing is available when filer is non-nil.

func (*QueryService) File

func (service *QueryService) File(ctx context.Context, scope knowl.ScopeRef, request FilingRequest) (IngestResult, error)

File explicitly files a query result through the standard immutable-source and plan/apply workflow.

func (service *QueryService) Links(ctx context.Context, scope knowl.ScopeRef, page knowl.PageID, limits knowl.ReadLimits) ([]knowl.LinkReference, error)

Links returns bounded, untrusted graph references for one page.

func (*QueryService) Operation

func (service *QueryService) Operation(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID) (knowl.Operation, error)

Operation returns the redacted durable status for one scoped operation.

func (*QueryService) Page

func (service *QueryService) Page(ctx context.Context, scope knowl.ScopeRef, id knowl.PageID, limits knowl.ReadLimits) (knowl.PageSnapshot, error)

Page returns one bounded, untrusted canonical page read.

func (*QueryService) Query

func (service *QueryService) Query(ctx context.Context, scope knowl.ScopeRef, query string, limits knowl.ReadLimits, sources []knowl.SourceID) (QueryResult, error)

Query assembles page references, link context, and page/raw citations without mutating state.

func (*QueryService) Search

func (service *QueryService) Search(ctx context.Context, scope knowl.ScopeRef, query string, limits knowl.ReadLimits, sources []knowl.SourceID) ([]knowl.PageReference, error)

Search returns bounded, untrusted page references from the projection.

type ReportedSearchIndex added in v0.6.0

type ReportedSearchIndex interface {
	SearchWithReport(ctx context.Context, scope knowl.ScopeRef, query string, limits knowl.ReadLimits, sources []knowl.SourceID) ([]knowl.PageReference, knowl.RetrievalReport, error)
	SelectContextWithReport(ctx context.Context, scope knowl.ScopeRef, source knowl.SourceSummary, limits knowl.ReadLimits) ([]knowl.PageID, knowl.RetrievalReport, error)
}

ReportedSearchIndex preserves the base port while returning per-call reports.

type RetirementCommitter added in v0.7.0

type RetirementCommitter interface {
	RunRetirementApply(
		ctx context.Context,
		staged knowl.StagedChange,
		prepare func(context.Context) (bool, error),
		complete func(context.Context, knowl.ContentCommit) error,
	) (knowl.ContentCommit, error)
}

RetirementCommitter is one structurally bound capability that owns the complete fenced retirement apply session. The callbacks cannot publish canonical content and run only before and after the sealed canonical step.

type RetirementContentReader added in v0.7.0

type RetirementContentReader interface {
	ReadPages(ctx context.Context, scope knowl.ScopeRef, ids []knowl.PageID, limits knowl.ReadLimits) ([]knowl.PageSnapshot, error)
	ResolveAcceptedSources(ctx context.Context, scope knowl.ScopeRef, refs []string) (map[string]knowl.AcceptedSource, error)
	ReadSource(ctx context.Context, source knowl.AcceptedSource, limits knowl.ReadLimits) ([]byte, error)
}

RetirementContentReader is the narrow existing content capability required to re-read one current page and immutable accepted evidence.

type RetirementMaintainer added in v0.7.0

type RetirementMaintainer interface {
	PlanRetirement(ctx context.Context, input knowl.RetirementInput) (knowl.RetirementModelPlan, error)
}

RetirementMaintainer is an optional, retirement-only multi-evidence provider. It is deliberately separate from Maintainer so ordinary source planning stays one-source and existing providers fail closed for mixed retirement work.

type RetirementOperationAssociator added in v0.7.0

type RetirementOperationAssociator interface {
	AssociateRetirementOperation(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, owner knowl.SourceOwner, retirementGeneration string, pageID knowl.PageID) error
}

RetirementOperationAssociator records that one exact retiring owner is blocked by an already deterministic page operation shared with another owner.

type RetirementOperationContent added in v0.7.0

type RetirementOperationContent interface {
	RetirementContentReader
	Schema(ctx context.Context, scope knowl.ScopeRef) (knowl.SchemaDocument, error)
	Inspect(ctx context.Context, scope knowl.ScopeRef) (knowl.WorkspaceInspection, error)
	StagePlan(ctx context.Context, plan knowl.ValidatedEditPlan) (knowl.StagedChange, error)
	LoadStage(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID) (knowl.StagedChange, error)
	Snapshot(ctx context.Context, scope knowl.ScopeRef) (knowl.WorkspaceSnapshot, error)
}

RetirementOperationContent is the narrow canonical capability used by the durable page runner. It intentionally omits ordinary source acceptance and unrestricted commit authority.

type RetirementOperationError added in v0.7.0

type RetirementOperationError struct {
	Stage       string
	Code        string
	Diagnostics []knowl.MaintenanceDiagnostic
	Cause       error
}

RetirementOperationError carries retry policy and bounded page diagnostics without exposing provider or storage error text as durable metadata.

func (*RetirementOperationError) Error added in v0.7.0

func (failure *RetirementOperationError) Error() string

func (*RetirementOperationError) FailureClass added in v0.7.0

func (failure *RetirementOperationError) FailureClass() string

func (*RetirementOperationError) FailureReason added in v0.7.0

func (failure *RetirementOperationError) FailureReason() string

func (*RetirementOperationError) Retryable added in v0.7.0

func (*RetirementOperationError) Retryable() bool

func (*RetirementOperationError) Unwrap added in v0.7.0

func (failure *RetirementOperationError) Unwrap() error

type RetirementOperationPage added in v0.7.0

type RetirementOperationPage struct {
	Items []RetirementOperationRecord
	Next  knowl.OperationID
}

RetirementOperationPage is a bounded operation-id ordered page.

type RetirementOperationReadRequest added in v0.7.0

type RetirementOperationReadRequest struct {
	Scope                knowl.ScopeRef
	Owner                knowl.SourceOwner
	RetirementGeneration string
	After                knowl.OperationID
	Limit                int
}

RetirementOperationReadRequest is an internal keyset page for one owner and generation.

type RetirementOperationRecord added in v0.7.0

type RetirementOperationRecord struct {
	Operation            knowl.Operation
	Owner                knowl.SourceOwner
	RetirementGeneration string
	PageID               knowl.PageID
}

RetirementOperationRecord is one bounded detached retirement operation row.

type RetirementOperationStore added in v0.7.0

type RetirementOperationStore interface {
	RetirementOperations(ctx context.Context, request RetirementOperationReadRequest) (RetirementOperationPage, error)
	RetryRetirementOperation(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, retirementGeneration string, retriedAt time.Time) (bool, error)
}

RetirementOperationStore exposes only the enumeration and single-row retry mutations needed by source retirement orchestration.

type RetirementPageOptions added in v0.7.0

type RetirementPageOptions struct {
	Planner       RetirementPlannerOptions
	LeaseDuration time.Duration
}

RetirementPageOptions contains the established bounded planner and apply settings for one durable page operation.

type RetirementPageReserver added in v0.7.0

type RetirementPageReserver interface {
	Reserve(ctx context.Context, scope knowl.ScopeRef, owner knowl.SourceOwner, retirementGeneration string, pageID knowl.PageID) (OperationReservation, error)
}

RetirementPageReserver is the page-only durable reservation capability.

type RetirementPageService added in v0.7.0

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

RetirementPageService reserves and executes one idempotent page-scoped retirement unit through the existing generic operation lifecycle.

func NewRetirementPageService added in v0.7.0

func NewRetirementPageService(
	content RetirementOperationContent,
	operations OperationStore,
	index SearchIndex,
	lifecycles SourceLifecycleReader,
	committer RetirementCommitter,
	maintainer Maintainer,
	options RetirementPageOptions,
) (*RetirementPageService, error)

NewRetirementPageService constructs the durable page runner.

func (*RetirementPageService) Reserve added in v0.7.0

func (service *RetirementPageService) Reserve(
	ctx context.Context,
	scope knowl.ScopeRef,
	owner knowl.SourceOwner,
	retirementGeneration string,
	pageID knowl.PageID,
) (OperationReservation, error)

Reserve persists one immutable page identity before discovery may advance.

func (*RetirementPageService) RunToTerminal added in v0.7.0

func (service *RetirementPageService) RunToTerminal(ctx context.Context, claim knowl.WorkClaim) (IngestResult, error)

RunToTerminal executes one exclusively claimed retirement-page operation.

type RetirementPlanner added in v0.7.0

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

RetirementPlanner creates one validated replacement/delete decision without staging or mutating canonical content.

func NewRetirementPlanner added in v0.7.0

func NewRetirementPlanner(content RetirementContentReader, lifecycles SourceLifecycleReader, maintainer Maintainer, options RetirementPlannerOptions) (*RetirementPlanner, error)

NewRetirementPlanner constructs a bounded page-scoped retirement planner.

func (*RetirementPlanner) BuildRetirementEditPlan added in v0.7.0

func (planner *RetirementPlanner) BuildRetirementEditPlan(ctx context.Context, operationID string, request RetirementPlanningRequest, result knowl.RetirementPlanResult) (knowl.ValidatedEditPlan, error)

BuildRetirementEditPlan converts one already application-validated recomputation result into one page-scoped staged-plan unit. A delete includes only catalogs that directly reference the removed page.

func (*RetirementPlanner) PlanRetirement added in v0.7.0

PlanRetirement re-reads and classifies the page, loads only active accepted evidence, invokes the optional retirement provider, and validates its single page decision. It never stages or publishes content.

type RetirementPlannerOptions added in v0.7.0

type RetirementPlannerOptions struct {
	InputLimits   knowl.MaintenanceInputLimits
	CatalogLimits knowl.CatalogLimits
	PlanLimits    PlanLimits
	ReadLimits    knowl.ReadLimits
}

RetirementPlannerOptions contains only finite local bounds. An all-zero field selects the corresponding established default.

type RetirementPlanningRequest added in v0.7.0

type RetirementPlanningRequest struct {
	Scope      knowl.ScopeRef
	Page       CanonicalPageProvenance
	SourceRefs []string
	Retiring   []knowl.SourceLifecycle
	Authority  knowl.SourceLifecycleAuthority
	Schema     knowl.SchemaDocument
	Catalogs   []knowl.HierarchyCatalog
}

RetirementPlanningRequest binds one current canonical precondition to the exact source refs requested by the caller. Full accepted descriptors are resolved from the trusted content store before lifecycle classification.

type RetirementProjectionReader added in v0.7.0

type RetirementProjectionReader interface {
	RetirementProjectionPending(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID) (bool, error)
}

RetirementProjectionReader distinguishes canonical-committed work awaiting projection/outcome replay from other applying operations.

type RetirementRequestSizer added in v0.7.0

type RetirementRequestSizer interface {
	RetirementRequestBudget() knowl.MaintenanceRequestBudget
	RetirementRequestBytes(ctx context.Context, input knowl.RetirementInput) (int, error)
}

RetirementRequestSizer measures the provider's complete retirement request, including any custom wrapper. Implementations must be pure and finite.

type RetirementUnitError added in v0.7.0

type RetirementUnitError struct {
	Code        string
	Diagnostics []knowl.MaintenanceDiagnostic
	Cause       error
}

RetirementUnitError preserves bounded path-bearing diagnostics for a page unit that cannot be constructed safely.

func (*RetirementUnitError) Error added in v0.7.0

func (failure *RetirementUnitError) Error() string

func (*RetirementUnitError) Unwrap added in v0.7.0

func (failure *RetirementUnitError) Unwrap() error

type RetrievalReportStore added in v0.6.0

type RetrievalReportStore interface {
	SaveRetrievalReport(ctx context.Context, scope knowl.ScopeRef, id knowl.OperationID, attempt int, report knowl.RetrievalReport) error
}

RetrievalReportStore persists selection evidence for one execution attempt. Scope, current attempt and terminal state must be checked atomically.

type ScanPageRecord added in v0.3.0

type ScanPageRecord struct {
	RunID             knowl.SyncRunID
	Scope             knowl.ScopeRef
	SourceID          knowl.SourceID
	ExpectedPageToken string
	NextPageToken     string
	Documents         []knowl.DocumentRef
	AttemptCheckpoint string
	RecordedAt        time.Time
}

ScanPageRecord atomically records one listed descriptor page and next token.

type ScopeAuthorizer

type ScopeAuthorizer interface {
	Authorize(ctx context.Context, scope knowl.ScopeRef, operation OperationKind) error
}

ScopeAuthorizer enforces the host's trusted scope boundary.

type SearchIndex

type SearchIndex interface {
	SelectContext(ctx context.Context, scope knowl.ScopeRef, source knowl.SourceSummary, limits knowl.ReadLimits) ([]knowl.PageID, error)
	Search(ctx context.Context, scope knowl.ScopeRef, query string, limits knowl.ReadLimits, sources []knowl.SourceID) ([]knowl.PageReference, error)
	Links(ctx context.Context, scope knowl.ScopeRef, page knowl.PageID, limits knowl.ReadLimits) ([]knowl.LinkReference, error)
	Project(ctx context.Context, commit knowl.ContentCommit) error
	Rebuild(ctx context.Context, snapshot knowl.WorkspaceSnapshot) error
}

SearchIndex owns rebuildable context, text, and link projections.

type SnapshotPreparation added in v0.4.0

type SnapshotPreparation struct {
	PageToken  string
	Checkpoint string
}

SnapshotPreparation pins one source scan to an immutable adapter checkpoint.

type SnapshotSourceAdapter added in v0.4.0

type SnapshotSourceAdapter interface {
	PrepareSnapshot(ctx context.Context, source knowl.Source, previousCheckpoint string) (SnapshotPreparation, error)
}

SnapshotSourceAdapter prepares an immutable scan before descriptor paging. Reconciliation uses this optional capability for moving remote sources.

type SourceAdapter added in v0.3.0

type SourceAdapter interface {
	List(ctx context.Context, source knowl.Source, pageToken string) (knowl.DocumentPage, error)
	Fetch(ctx context.Context, source knowl.Source, ref knowl.DocumentRef) (knowl.Document, error)
}

SourceAdapter lists cheap descriptors and fetches only selected documents.

type SourceContentStore added in v0.3.0

type SourceContentStore interface {
	SourceDigests(ctx context.Context, scope knowl.ScopeRef, sourceID knowl.SourceID, limit int) ([]SourceDigestEntry, error)
	StageSourcePlan(ctx context.Context, plan knowl.SourceMutationPlan) (knowl.StagedSourceMutation, error)
	LoadSourceStage(ctx context.Context, scope knowl.ScopeRef, sourceID knowl.SourceID, runID knowl.SyncRunID) (knowl.StagedSourceMutation, error)
	CommitSource(ctx context.Context, staged knowl.StagedSourceMutation) (knowl.ContentCommit, error)
}

SourceContentStore owns deterministic canonical source mirrors and assets.

type SourceDigestEntry added in v0.3.0

type SourceDigestEntry struct {
	Path   string `json:"path"`
	Digest string `json:"digest"`
}

SourceDigestEntry is the exact write precondition of one canonical source file.

type SourceDocumentLister added in v0.6.0

type SourceDocumentLister interface {
	ListSourceDocuments(ctx context.Context, scope knowl.ScopeRef, id knowl.SourceID, options OperatorReadOptions) (OperatorReadPage[knowl.OperatorDocumentSummary], error)
}

SourceDocumentLister is an optional scoped durable document read capability.

type SourceLifecycleListOptions added in v0.7.0

type SourceLifecycleListOptions struct {
	State knowl.SourceLifecycleState
	After knowl.SourceOwner
	Limit int
}

SourceLifecycleListOptions bounds deterministic owner-order reads.

func NormalizeSourceLifecycleListOptions added in v0.7.0

func NormalizeSourceLifecycleListOptions(options SourceLifecycleListOptions) (SourceLifecycleListOptions, error)

NormalizeSourceLifecycleListOptions validates one finite keyset page.

type SourceLifecycleReader added in v0.7.0

type SourceLifecycleReader interface {
	SourceLifecycleAuthority(ctx context.Context, scope knowl.ScopeRef) (knowl.SourceLifecycleAuthority, error)
	SourceLifecycle(ctx context.Context, scope knowl.ScopeRef, owner knowl.SourceOwner) (knowl.SourceLifecycle, error)
}

SourceLifecycleReader is the read-only lifecycle capability used while planning.

type SourceLifecycleReadyUpdate added in v0.7.0

type SourceLifecycleReadyUpdate struct {
	Scope               knowl.ScopeRef
	Owner               knowl.SourceOwner
	AuthorityGeneration string
	AuthorityEpoch      uint64
	ActivatedEpoch      uint64
	ConfigDigest        string
	ReadyAt             time.Time
}

SourceLifecycleReadyUpdate marks successful readiness for one exact active config.

type SourceLifecycleReconcileRequest added in v0.7.0

type SourceLifecycleReconcileRequest struct {
	Scope                  knowl.ScopeRef       `json:"scope"`
	Desired                []DesiredSourceOwner `json:"desired"`
	AuthorityGeneration    string               `json:"authority_generation"`
	ExpectedAuthorityEpoch uint64               `json:"expected_authority_epoch"`
	UpdatedAt              time.Time            `json:"updated_at"`
}

SourceLifecycleReconcileRequest is one bounded desired-source inventory generation.

func NormalizeSourceLifecycleReconcile added in v0.7.0

func NormalizeSourceLifecycleReconcile(request SourceLifecycleReconcileRequest) (SourceLifecycleReconcileRequest, error)

NormalizeSourceLifecycleReconcile validates and deterministically orders a desired exact-owner inventory without merging equal SourceIDs across adapters.

type SourceLifecycleStore added in v0.7.0

type SourceLifecycleStore interface {
	ReconcileSourceLifecycles(ctx context.Context, request SourceLifecycleReconcileRequest) error
	SourceLifecycleAuthority(ctx context.Context, scope knowl.ScopeRef) (knowl.SourceLifecycleAuthority, error)
	SourceLifecycle(ctx context.Context, scope knowl.ScopeRef, owner knowl.SourceOwner) (knowl.SourceLifecycle, error)
	SourceLifecycles(ctx context.Context, scope knowl.ScopeRef, options SourceLifecycleListOptions) ([]knowl.SourceLifecycle, error)
	MarkSourceLifecycleReady(ctx context.Context, update SourceLifecycleReadyUpdate) (knowl.SourceLifecycle, error)
	UpdateSourceRetirement(ctx context.Context, update SourceRetirementUpdate) (knowl.SourceLifecycle, error)
	FinalizeSourceRetirement(ctx context.Context, finalization SourceRetirementFinalization) (knowl.SourceLifecycle, error)
}

SourceLifecycleStore owns durable state for exact adapter-qualified owners.

type SourceMaintenanceQueue added in v0.3.0

type SourceMaintenanceQueue interface {
	ReserveAccepted(ctx context.Context, request AcceptedMaintenanceRequest) (MaintenanceReservation, error)
}

SourceMaintenanceQueue reserves already accepted source revisions for the existing host-owned operation scheduler.

type SourceMaintenanceRetryRequest added in v0.4.0

type SourceMaintenanceRetryRequest struct {
	Scope                 knowl.ScopeRef       `json:"scope"`
	SourceID              knowl.SourceID       `json:"source_id"`
	FailureClasses        []string             `json:"failure_classes"`
	MaintenanceGeneration string               `json:"maintenance_generation,omitempty"`
	Schema                knowl.SchemaDocument `json:"-"`
	DryRun                bool                 `json:"dry_run"`
}

SourceMaintenanceRetryRequest selects terminal current-revision maintenance operations for explicit operator recovery.

type SourceMaintenanceRetryResult added in v0.4.0

type SourceMaintenanceRetryResult struct {
	SourceID     knowl.SourceID      `json:"source_id"`
	DryRun       bool                `json:"dry_run"`
	Matched      int64               `json:"matched"`
	Requeued     int64               `json:"requeued"`
	Rejected     int64               `json:"rejected"`
	OperationIDs []knowl.OperationID `json:"operation_ids"`
	Truncated    bool                `json:"truncated"`
}

SourceMaintenanceRetryResult is bounded even when the selected source has more matching operations than can be listed individually.

type SourceNormalizationInput added in v0.3.0

type SourceNormalizationInput struct {
	Source    knowl.Source
	Document  knowl.Document
	RawSource knowl.AcceptedSource
	Catalog   []knowl.DocumentRef
}

SourceNormalizationInput requests deterministic normalization of one fetched or restored raw document against its complete descriptor catalog.

type SourceNormalizationResult added in v0.3.0

type SourceNormalizationResult struct {
	FormatVersion string
	CatalogDigest string
	MirrorDigest  string
	Mutations     []knowl.SourceMutation
	Diagnostics   []knowl.SourceDiagnostic
}

SourceNormalizationResult carries immutable identities plus detached, deterministically ordered canonical write mutations.

type SourceNormalizer added in v0.3.0

type SourceNormalizer interface {
	NormalizeSource(ctx context.Context, input SourceNormalizationInput) (SourceNormalizationResult, error)
}

SourceNormalizer renders raw source documents into canonical mirrors without exposing any concrete catalog representation.

type SourceRefDuplicateError added in v0.7.0

type SourceRefDuplicateError struct {
	Ref string
}

SourceRefDuplicateError identifies the deterministic second spelling of an already requested accepted-source identity. Ref is safe to use as a typed diagnostic target; Error deliberately does not render it into logs.

func (*SourceRefDuplicateError) Error added in v0.7.0

func (*SourceRefDuplicateError) Unwrap added in v0.7.0

func (*SourceRefDuplicateError) Unwrap() error

type SourceRefIdentity added in v0.7.0

type SourceRefIdentity struct {
	Source   knowl.SourceRef
	Revision string
}

SourceRefIdentity is the reversible identity encoded by a citation ref.

func ParseSourceRefCandidates added in v0.7.0

func ParseSourceRefCandidates(ref string) ([]SourceRefIdentity, error)

ParseSourceRefCandidates decodes one canonical ref or enumerates identities represented by a legacy ref whose opaque parts contain @. Legacy spellings with more than MaxLegacySourceRefCandidates delimiter splits fail closed; canonical v2 is the compatibility path for identities beyond that boundary.

type SourceRefNotFoundError added in v0.7.0

type SourceRefNotFoundError struct{ Ref string }

SourceRefNotFoundError identifies the exact missing accepted citation without exposing adapter/storage details. It preserves ErrSourceNotFound identity.

func (*SourceRefNotFoundError) Error added in v0.7.0

func (err *SourceRefNotFoundError) Error() string

func (*SourceRefNotFoundError) Unwrap added in v0.7.0

func (err *SourceRefNotFoundError) Unwrap() error

type SourceRetirementAdvanceResult added in v0.7.0

type SourceRetirementAdvanceResult struct {
	Owner                 knowl.SourceOwner          `json:"owner"`
	State                 knowl.SourceLifecycleState `json:"state"`
	Reserved              int                        `json:"reserved"`
	DiscoveryEOF          bool                       `json:"discovery_eof"`
	VerificationRestarted bool                       `json:"verification_restarted"`
	Finalized             bool                       `json:"finalized"`
	BlockerCode           string                     `json:"blocker_code,omitempty"`
}

SourceRetirementAdvanceResult describes one bounded coordinator step.

type SourceRetirementCoordinator added in v0.7.0

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

SourceRetirementCoordinator advances exact owners in bounded windows.

func NewSourceRetirementCoordinator added in v0.7.0

func NewSourceRetirementCoordinator(dependencies SourceRetirementCoordinatorDependencies) (*SourceRetirementCoordinator, error)

NewSourceRetirementCoordinator constructs the bounded orchestrator.

func (*SourceRetirementCoordinator) Advance added in v0.7.0

Advance advances one rotating bounded owner window, preserving independent progress.

func (*SourceRetirementCoordinator) AdvanceOwner added in v0.7.0

AdvanceOwner performs at most one provenance window or one lifecycle step.

func (*SourceRetirementCoordinator) Retry added in v0.7.0

Retry requeues only failed page work for the current exact retirement generation.

func (*SourceRetirementCoordinator) Status added in v0.7.0

Status returns the detached bounded view for one exact owner.

type SourceRetirementCoordinatorDependencies added in v0.7.0

type SourceRetirementCoordinatorDependencies struct {
	Scope            knowl.ScopeRef
	Lifecycles       SourceLifecycleStore
	Provenance       CanonicalProvenanceReader
	Pages            RetirementPageReserver
	Operations       RetirementOperationStore
	Projection       RetirementProjectionReader
	ApplyCoordinator ApplyCoordinator
	Limits           CanonicalProvenanceLimits
	Now              func() time.Time
	Wake             func(knowl.OperationID)
}

SourceRetirementCoordinatorDependencies are host-owned orchestration capabilities.

type SourceRetirementFinalization added in v0.7.0

type SourceRetirementFinalization struct {
	Scope                knowl.ScopeRef
	Owner                knowl.SourceOwner
	AuthorityGeneration  string
	AuthorityEpoch       uint64
	RetirementGeneration string
	RetirementEpoch      uint64
	FinalizedAt          time.Time
}

SourceRetirementFinalization requests deletion after a completed zero-ref scan.

type SourceRetirementReader added in v0.7.0

type SourceRetirementReader interface {
	SourceRetirement(ctx context.Context, scope knowl.ScopeRef, owner knowl.SourceOwner) (knowl.SourceRetirementStatus, error)
}

SourceRetirementReader is the exact-owner typed retirement status capability.

type SourceRetirementReadiness added in v0.7.0

type SourceRetirementReadiness struct {
	Ready        bool                `json:"ready"`
	BlockerCode  string              `json:"blocker_code,omitempty"`
	PendingCount int                 `json:"pending_count"`
	Pending      []knowl.SourceOwner `json:"pending,omitempty"`
}

SourceRetirementReadiness is the bounded gate for one retiring owner.

func EvaluateSourceRetirementReadiness added in v0.7.0

func EvaluateSourceRetirementReadiness(retiring knowl.SourceLifecycle, states []knowl.SourceLifecycle) (SourceRetirementReadiness, error)

EvaluateSourceRetirementReadiness gates one retiring owner on additions first observed in the same desired-inventory transition. Active config refreshes retain their activation epoch, so a stale prior config cannot open this gate.

type SourceRetirementRetryRequest added in v0.7.0

type SourceRetirementRetryRequest struct {
	Owner  knowl.SourceOwner `json:"owner"`
	PageID knowl.PageID      `json:"page_id,omitempty"`
	DryRun bool              `json:"dry_run"`
}

SourceRetirementRetryRequest selects one failed page or all failed pages for an owner.

type SourceRetirementRetryResult added in v0.7.0

type SourceRetirementRetryResult struct {
	Owner        knowl.SourceOwner   `json:"owner"`
	PageID       knowl.PageID        `json:"page_id,omitempty"`
	DryRun       bool                `json:"dry_run"`
	Matched      int                 `json:"matched"`
	Requeued     int                 `json:"requeued"`
	OperationIDs []knowl.OperationID `json:"operation_ids"`
	Truncated    bool                `json:"truncated"`
}

SourceRetirementRetryResult is a bounded supported-recovery result.

type SourceRetirementUpdate added in v0.7.0

type SourceRetirementUpdate struct {
	Scope                knowl.ScopeRef
	Owner                knowl.SourceOwner
	AuthorityGeneration  string
	AuthorityEpoch       uint64
	RetirementGeneration string
	RetirementEpoch      uint64
	ExpectedCursor       string
	Cursor               string
	RoundMatches         int64
	ScanComplete         bool
	BlockerCode          string
	UpdatedAt            time.Time
}

SourceRetirementUpdate compare-and-sets one bounded retirement scan step.

type SourceRevisionReader added in v0.6.0

type SourceRevisionReader interface {
	SourceRevision(ctx context.Context, scope knowl.ScopeRef, ref string, limits knowl.ReadLimits) (knowl.OperatorSourceRevision, error)
}

SourceRevisionReader is an optional bounded immutable accepted-text capability.

type SourceStateStore added in v0.3.0

type SourceStateStore interface {
	BeginSync(ctx context.Context, request BeginSyncRequest) (run knowl.SyncRun, replay bool, err error)
	SyncRun(ctx context.Context, scope knowl.ScopeRef, id knowl.SyncRunID) (knowl.SyncRun, error)
	ScanDocuments(ctx context.Context, scope knowl.ScopeRef, id knowl.SyncRunID, limit int) ([]knowl.DocumentRef, error)
	RecordScanPage(ctx context.Context, record ScanPageRecord) (knowl.SyncRun, error)
	PrepareSync(ctx context.Context, prepared PreparedSyncState) (knowl.SyncRun, error)
	PreparedSync(ctx context.Context, scope knowl.ScopeRef, id knowl.SyncRunID) (PreparedSyncRead, error)
	MarkContentCommitted(ctx context.Context, generation SyncGeneration) (knowl.SyncRun, error)
	MarkProjected(ctx context.Context, generation SyncGeneration) (knowl.SyncRun, error)
	FinalizeSync(ctx context.Context, finalization SyncFinalization) (knowl.SyncRun, error)
	FailSync(ctx context.Context, scope knowl.ScopeRef, id knowl.SyncRunID, failureClass string, failedAt time.Time) (knowl.SyncRun, error)
	DocumentState(ctx context.Context, scope knowl.ScopeRef, sourceID knowl.SourceID, documentID knowl.DocumentID) (knowl.DocumentState, error)
	DocumentStates(ctx context.Context, scope knowl.ScopeRef, sourceID knowl.SourceID, options DocumentListOptions) ([]knowl.DocumentState, error)
	SourceStatus(ctx context.Context, scope knowl.ScopeRef, sourceID knowl.SourceID) (knowl.SourceStatus, error)
	RetrySourceMaintenance(ctx context.Context, request SourceMaintenanceRetryRequest) (SourceMaintenanceRetryResult, error)
	ResumableSyncRuns(ctx context.Context, scope knowl.ScopeRef, limit int) ([]knowl.SyncRun, error)
}

SourceStateStore owns durable sync runs, document heads, and checkpoints.

type SyncDocumentAction added in v0.3.0

type SyncDocumentAction string

SyncDocumentAction identifies the prepared active or tombstone outcome.

const (
	SyncDocumentActive    SyncDocumentAction = "active"
	SyncDocumentTombstone SyncDocumentAction = "tombstone"
)

type SyncFinalization added in v0.3.0

type SyncFinalization struct {
	RunID           knowl.SyncRunID
	Scope           knowl.ScopeRef
	SourceID        knowl.SourceID
	CandidateDigest string
	Generation      string
	Checkpoint      string
	Counts          knowl.SyncCounts
	FinalizedAt     time.Time
}

SyncFinalization atomically publishes prepared document heads and checkpoint.

type SyncGeneration added in v0.3.0

type SyncGeneration struct {
	RunID      knowl.SyncRunID
	Scope      knowl.ScopeRef
	SourceID   knowl.SourceID
	Generation string
	UpdatedAt  time.Time
}

SyncGeneration records a canonical or projection generation transition.

type ValidatingHierarchyMaintainer added in v0.6.0

type ValidatingHierarchyMaintainer interface {
	PlanHierarchyValidated(ctx context.Context, input knowl.HierarchyInput, limits knowl.OutputCorrectionLimits, validate func(knowl.HierarchyModelPlan) error) (knowl.HierarchyModelPlan, knowl.OperationCorrectionReport, error)
}

type ValidatingMaintainer added in v0.6.0

type ValidatingMaintainer interface {
	PlanValidated(ctx context.Context, input knowl.MaintenanceInput, limits knowl.OutputCorrectionLimits, validate func(knowl.ModelEditPlan) error) (knowl.ModelEditPlan, knowl.OperationCorrectionReport, error)
}

ValidatingMaintainer shares one correction allowance with the app validator.

type WikiDirectoryReader added in v0.6.0

type WikiDirectoryReader interface {
	WikiDirectoryChildren(ctx context.Context, scope knowl.ScopeRef, directory string, options OperatorReadOptions) (OperatorReadPage[knowl.OperatorWikiEntry], error)
}

WikiDirectoryReader is an optional direct-child path inventory, independent of authored catalog links and the concept-only page inventory.

type WorkspaceReader added in v0.6.0

type WorkspaceReader interface {
	CatalogReader
	PageSummaryReader
	PageReader
	SourceRevisionReader
}

WorkspaceReader composes optional canonical capabilities without extending ContentStore. A host may also provide each capability independently.

Jump to

Keyboard shortcuts

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