Documentation
¶
Index ¶
- func CloneMetadata(metadata map[string]any) (map[string]any, error)
- func DigestChunk(chunk Chunk) (string, error)
- func DigestChunkPlan(plan ChunkPlan) (string, error)
- func DigestDocument(doc *SourceDocument) (string, error)
- func UnitIndex(doc *SourceDocument, unitID int) (int, bool)
- func ValidateChunkAnnotations(annotations ChunkAnnotations) error
- func ValidateChunkPlan(doc *SourceDocument, plan ChunkPlan) error
- func ValidateDocument(doc *SourceDocument) error
- func ValidateRef(doc *SourceDocument, ref SourceRef) error
- type Chunk
- type ChunkAnnotations
- type ChunkPlan
- type ChunkRange
- type DocumentIndex
- type SourceDocument
- type SourceRef
- type SourceUnit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloneMetadata ¶ added in v0.2.0
CloneMetadata returns an independently owned copy of JSON-shaped metadata. It preserves concrete map, slice, and array types while rejecting values that cannot be safely represented as JSON-shaped metadata.
func DigestChunk ¶ added in v0.2.0
DigestChunk returns a deterministic digest of a chunk, including its source provenance, content, units, and metadata.
func DigestChunkPlan ¶ added in v0.2.0
DigestChunkPlan returns a deterministic digest of the logical plan. Storage schema, producer provenance, warnings, and timestamps are intentionally not part of the digest.
func DigestDocument ¶ added in v0.2.0
func DigestDocument(doc *SourceDocument) (string, error)
DigestDocument returns a deterministic digest of the canonical source document content. The existing Digest field is excluded from its own digest.
func ValidateChunkAnnotations ¶ added in v0.2.0
func ValidateChunkAnnotations(annotations ChunkAnnotations) error
ValidateChunkAnnotations requires annotations to already contain canonical JSON. CanonicalizeChunkAnnotations can be used at producer boundaries.
func ValidateChunkPlan ¶ added in v0.2.0
func ValidateChunkPlan(doc *SourceDocument, plan ChunkPlan) error
ValidateChunkPlan validates a canonical plan against the current source. Ranges may contain gaps or overlap, but their start positions must increase.
func ValidateDocument ¶
func ValidateDocument(doc *SourceDocument) error
func ValidateRef ¶
func ValidateRef(doc *SourceDocument, ref SourceRef) error
Types ¶
type Chunk ¶ added in v0.2.0
type Chunk struct {
ID string `json:"id"`
SourceID string `json:"source_id"`
Index int `json:"index"`
Ref SourceRef `json:"ref"`
Content []byte `json:"-"`
MediaType string `json:"media_type"`
Units []SourceUnit `json:"units"`
Metadata map[string]any `json:"metadata,omitempty"`
Annotations ChunkAnnotations `json:"annotations,omitempty"`
PlanAnnotations ChunkAnnotations `json:"plan_annotations,omitempty"`
}
func MaterializeChunkPlan ¶ added in v0.2.0
func MaterializeChunkPlan(doc *SourceDocument, plan ChunkPlan) ([]Chunk, error)
MaterializeChunkPlan deterministically expands a validated plan into chunks.
type ChunkAnnotations ¶ added in v0.2.0
type ChunkAnnotations map[string]json.RawMessage
func CanonicalizeChunkAnnotations ¶ added in v0.2.0
func CanonicalizeChunkAnnotations(annotations ChunkAnnotations) (ChunkAnnotations, error)
CanonicalizeChunkAnnotations validates annotation namespaces and JSON values and returns an independently owned map whose values use canonical JSON bytes.
func CloneChunkAnnotations ¶ added in v0.2.0
func CloneChunkAnnotations(annotations ChunkAnnotations) ChunkAnnotations
CloneChunkAnnotations returns a deep clone, including every raw JSON value.
type ChunkPlan ¶ added in v0.2.0
type ChunkPlan struct {
SourceDigest string `json:"source_digest"`
Ranges []ChunkRange `json:"ranges"`
Annotations ChunkAnnotations `json:"annotations,omitempty"`
}
func CanonicalizeChunkPlan ¶ added in v0.2.0
CanonicalizeChunkPlan returns a deep clone with canonical annotation bytes.
func CloneChunkPlan ¶ added in v0.2.0
CloneChunkPlan returns a deep clone of a chunk plan.
type ChunkRange ¶ added in v0.2.0
type ChunkRange struct {
StartUnitID int `json:"start_unit_id"`
EndUnitID int `json:"end_unit_id"`
Annotations ChunkAnnotations `json:"annotations,omitempty"`
}
type DocumentIndex ¶ added in v0.2.0
type DocumentIndex struct {
// contains filtered or unexported fields
}
DocumentIndex is an immutable snapshot of a source document's identity and unit positions for repeated source-reference operations.
func NewDocumentIndex ¶ added in v0.2.0
func NewDocumentIndex(doc *SourceDocument) DocumentIndex
NewDocumentIndex snapshots doc without retaining or mutating it.
func (DocumentIndex) DocumentID ¶ added in v0.2.0
func (i DocumentIndex) DocumentID() (string, bool)
DocumentID returns the indexed document identity.
func (DocumentIndex) Position ¶ added in v0.2.0
func (i DocumentIndex) Position(unitID int) (int, bool)
Position returns the indexed document position for unitID.
func (DocumentIndex) ValidateRef ¶ added in v0.2.0
func (i DocumentIndex) ValidateRef(ref SourceRef) error
ValidateRef validates ref against the indexed document snapshot.