Documentation
¶
Overview ¶
Package sessionwire projects Harness events onto Core's public session wire.
Index ¶
- func ProjectGatePage(scope ReadScope, gates []OpenGate, journalTip, openGateCount uint64, ...) (coresessionwire.GatePage, error)
- func ProjectJournalPage(scope ReadScope, records []JournalRecord, capturedTip, coveredThrough uint64, ...) (coresessionwire.JournalPage, error)
- func ProjectSessionPage(authority ReadAuthority, records []CatalogRecord, ...) (coresessionwire.SessionPage, error)
- func ProjectSessionStatus(scope ReadScope, record CatalogRecord) (coresessionwire.SessionStatus, error)
- func ProjectSessionSummary(scope ReadScope, record CatalogRecord) (coresessionwire.SessionSummary, error)
- func ValidateReadAuthority(authority ReadAuthority) error
- func ValidateReadScope(scope ReadScope) error
- type CatalogRecord
- type CatalogState
- type EventClass
- type JournalRecord
- type OpenGate
- type Projection
- type ProjectionError
- type ProjectionErrorReason
- type ReadAuthority
- type ReadProjectionError
- type ReadScope
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProjectGatePage ¶
func ProjectGatePage(scope ReadScope, gates []OpenGate, journalTip, openGateCount uint64, next, previous coresessionwire.Cursor) (coresessionwire.GatePage, error)
ProjectGatePage maps already selected open gates into Core's presentation-safe projection. Harness Gate.Subject and ResponsePolicy are intentionally absent.
func ProjectJournalPage ¶
func ProjectJournalPage(scope ReadScope, records []JournalRecord, capturedTip, coveredThrough uint64, next, previous coresessionwire.Cursor) (coresessionwire.JournalPage, error)
ProjectJournalPage converts public Harness events to canonical Core records. CapturedTip and CoveredThrough are authenticated provider metadata and are never inferred from the visible event count.
func ProjectSessionPage ¶
func ProjectSessionPage(authority ReadAuthority, records []CatalogRecord, next, previous coresessionwire.Cursor) (coresessionwire.SessionPage, error)
ProjectSessionPage converts an already bounded, recent-first catalog window. Cursor creation remains the storage/read provider's responsibility.
func ProjectSessionStatus ¶
func ProjectSessionStatus(scope ReadScope, record CatalogRecord) (coresessionwire.SessionStatus, error)
ProjectSessionStatus converts replay-free catalog state to Core's durable status while preserving the caller-supplied residency dimension.
func ProjectSessionSummary ¶
func ProjectSessionSummary(scope ReadScope, record CatalogRecord) (coresessionwire.SessionSummary, error)
ProjectSessionSummary converts one durable catalog entry to Core's recent session record without consulting or restoring a runtime.
func ValidateReadAuthority ¶
func ValidateReadAuthority(authority ReadAuthority) error
ValidateReadAuthority validates caller-owned multi-session authority before a catalog provider is touched.
func ValidateReadScope ¶
ValidateReadScope validates caller-owned single-session authority and residency before a session provider is touched.
Types ¶
type CatalogRecord ¶
type CatalogRecord struct {
SessionID coresessionwire.SessionID
State CatalogState
Title string
CreatedAt time.Time
LastActiveAt time.Time
LastJournalSeq uint64
WaitingGateID coresessionwire.GateID
}
CatalogRecord is the narrow Harness read-domain record needed to produce Core summaries/status. It intentionally excludes runtime and storage types.
type CatalogState ¶
type CatalogState string
CatalogState is the closed Harness catalog vocabulary accepted by this projection boundary. It is local to the adapter so pkg/sessionwire remains below pkg/sessionstore and can later be called from the persistence path.
const ( CatalogStateRunning CatalogState = "running" CatalogStateWaitingOnGate CatalogState = "waiting_on_gate" CatalogStateIdle CatalogState = "idle" CatalogStateFailed CatalogState = "failed" CatalogStateInterrupted CatalogState = "interrupted" CatalogStateStopped CatalogState = "stopped" )
type EventClass ¶
type EventClass string
EventClass is the adapter's closed publication policy for a concrete Harness event. PrivateRejected is also the fail-closed result for values outside the sealed event union.
const ( PublicEnduring EventClass = "public_enduring" PublicEphemeral EventClass = "public_ephemeral" PrivateRejected EventClass = "private_rejected" )
type JournalRecord ¶
JournalRecord pairs a public Harness event with the sequence assigned by its successful enduring append.
type OpenGate ¶
type OpenGate struct {
Event event.GateOpened
JournalSeq uint64
Deadline time.Time
Answerability coresessionwire.GateAnswerability
}
OpenGate supplies the read-plane facts not owned by a GateOpened event: the append sequence, effective deadline, and current answerability.
type Projection ¶
type Projection struct {
TenantID coresessionwire.TenantID
SessionID coresessionwire.SessionID
EventID coresessionwire.EventID
Class EventClass
Body json.RawMessage
}
Projection is a canonical public event before an enduring append assigns its journal sequence. EventID is empty for ephemeral events, matching Core's EphemeralPublication contract. Body is owned by the returned value.
func Project ¶
func Project(tenantID coresessionwire.TenantID, sessionID coresessionwire.SessionID, value any) (Projection, error)
Project converts one explicitly admitted Harness event to a canonical Core public body. It deliberately accepts any so private persistence records and live command payloads reach a typed rejection instead of a generic JSON path. It never assigns a journal sequence; only a successful append may do that.
It is deliberately NARROWER than event.ValidateEvent on one rule, and that difference is load-bearing to state: every public event now reaches the durable append through this function, so an event Harness's own validator calls VALID can be refused here. The rule is reply correlation — an event.Reply whose ReplyTo() (its Header.Cause.CommandID) is zero is rejected as malformed, while ValidateEvent imposes no such requirement on the Reply set. A caller sees the refusal as a *journal.MarshalRecordError from the append, not as a validation failure at construction.
The members of that set are deliberately NOT enumerated here. The set is sealed by event.Reply's isReply method, Project matches on the interface, and TestReplyProjectionCasesMatchSealedReplyUnion derives the union from pkg/event source — so the interface is the authority and a prose list here can only drift out of it. One did: it named five members while seven implement isReply. Read the members off event.Reply (pkg/event/README.md lists them).
Every production construction site of those events sets the causing command id, so no live path emits a zero today. A NEW emitter that leaves Header.Cause.CommandID unset will pass ValidateEvent and fail the append: correlate the reply with the command it answers, or relax this rule — do not discover the difference from a fixture.
type ProjectionError ¶
type ProjectionError struct {
Type string
Reason ProjectionErrorReason
Cause error
}
ProjectionError reports a failed public projection without including event payloads, credentials, grant material, or gate answers in its text.
func (*ProjectionError) Error ¶
func (e *ProjectionError) Error() string
func (*ProjectionError) Unwrap ¶
func (e *ProjectionError) Unwrap() error
type ProjectionErrorReason ¶
type ProjectionErrorReason string
ProjectionErrorReason is a stable failure category for callers that must distinguish a private value from malformed public data.
const ( ProjectionRejected ProjectionErrorReason = "rejected" ProjectionMalformed ProjectionErrorReason = "malformed" ProjectionEncoding ProjectionErrorReason = "encoding" )
type ReadAuthority ¶
type ReadAuthority struct {
TenantID coresessionwire.TenantID
AgentID coresessionwire.AgentID
}
ReadAuthority is the caller-owned authorization scope used for multi-session catalog projections. Tenant identity is deliberately required even though a Core SessionSummary does not repeat it: the adapter must never silently manufacture tenancy from a Harness UUID.
type ReadProjectionError ¶
ReadProjectionError reports a malformed or mismatched read projection. Its text names only the projection and field; it never includes catalog, event, prompt, tool, or authorization payload bytes.
func (*ReadProjectionError) Error ¶
func (e *ReadProjectionError) Error() string
func (*ReadProjectionError) Unwrap ¶
func (e *ReadProjectionError) Unwrap() error
type ReadScope ¶
type ReadScope struct {
TenantID coresessionwire.TenantID
SessionID coresessionwire.SessionID
AgentID coresessionwire.AgentID
Residency coresessionwire.SessionResidency
}
ReadScope binds one durable Harness session to its caller-owned Core identity and current residency. Execution State and Residency remain independent: a running durable projection can be read while cold without restoring it.