// Package evidencecontext owns the durable source evidence-context contract.
package evidencecontext

import (
	"gitea.maximumdirect.net/eric/notarius/internal/core/source"
	"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
)

const (
	ArtifactKind  contracts.ArtifactKind = "source/evidence-context"
	SchemaID                             = "notarius.source.evidence_context"
	SchemaName                           = "notarius_source_evidence_context_v1"
	SchemaVersion                        = "v1"
	MediaType                            = "application/json"
)

// Document is the durable union of direct evidence and surrounding source
// context selected for one accepted source document.
type Document struct {
	SourceID      string    `json:"source_id"`
	SourceDigest  string    `json:"source_digest"`
	WindowUnits   int       `json:"window_units"`
	SelectedLanes []string  `json:"selected_lanes"`
	Contexts      []Context `json:"contexts"`
}

type Context struct {
	ContextRef   source.SourceRef    `json:"context_ref"`
	EvidenceRefs []EvidenceRef       `json:"evidence_refs"`
	Units        []source.SourceUnit `json:"units"`
}

type EvidenceRef struct {
	LaneID    string           `json:"lane_id"`
	SourceRef source.SourceRef `json:"source_ref"`
}

// LaneEvidence attributes direct source references to one selected lane.
type LaneEvidence struct {
	LaneID     string             `json:"lane_id"`
	SourceRefs []source.SourceRef `json:"source_refs"`
}

// BuildRequest supplies accepted source material and direct lane evidence.
type BuildRequest struct {
	Source        *source.SourceDocument
	WindowUnits   int
	SelectedLanes []string
	LaneEvidence  []LaneEvidence
}
