work

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package work models the human-agent work continuity loop.

Work records are immutable, versioned Source payloads. They deliberately do not form another Artifact family: committed Handoffs remain the durable authority while contracts, boundaries, acknowledgements, and outcomes form an ordered evidence journal around them.

Index

Constants

View Source
const (
	MaxTextLength             = 8_192
	MaxItems                  = 64
	MaxEvidence               = 32
	MaxClaimEvidence          = handoff.MaxCitations - 1
	MaxReceiptEvidence        = (handoff.MaxStateStatements + 1) * handoff.MaxCitations
	MaxContinuityEvents       = 64
	WorkContractSourceKind    = Kind("work-contract")
	HandoffBoundarySourceKind = Kind("handoff-boundary")
	HandoffReceiptSourceKind  = Kind("handoff-receipt")
	TaskOutcomeSourceKind     = Kind("task-outcome")
	WorkContractSchema        = "powercontext.work-contract.v1"
	CurrentWorkHandoffSchema  = "powercontext.current-work-handoff.v1"
	HandoffReceiptSchema      = "powercontext.handoff-receipt.v1"
	TaskOutcomeSchema         = "powercontext.task-outcome.v1"
	WorkContinuitySchema      = "powercontext.work-continuity.v1"
	UntrustedInput            = "untrusted_input"
	UntrustedObservation      = "untrusted_observation"
	UntrustedHistory          = "untrusted_history"
)

Variables

This section is empty.

Functions

func ContentDigest

func ContentDigest(value any) (string, error)

func DecodeRecord

func DecodeRecord(kind Kind, payload []byte) (any, error)

DecodeRecord strictly decodes one Source record selected by its trusted metadata kind. Unknown fields and mismatched schema/trust constants make the record invalid rather than silently expanding history.

func EncodeRecord

func EncodeRecord(value any, pretty bool) ([]byte, error)

EncodeRecord produces the exact schema-specific JSON captured by the Python runtime. pretty controls only the two-space Source representation; digests always use the compact representation.

func PreparedDigest

func PreparedDigest(value handoff.Prepared) (string, error)

Types

type Acknowledge

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

func NewAcknowledge

func NewAcknowledge(
	sourceID, receiver string,
	status ReceiptStatus,
	selection handoff.Selection,
	receiverChecks *ReceiverChecks,
	prepared *handoff.Prepared,
	revision *artifact.Ref,
	message *string,
) (Acknowledge, error)

func (Acknowledge) Message

func (a Acknowledge) Message() *string

func (Acknowledge) Prepared

func (a Acknowledge) Prepared() *handoff.Prepared

func (Acknowledge) Receiver

func (a Acknowledge) Receiver() string

func (Acknowledge) ReceiverChecks

func (a Acknowledge) ReceiverChecks() *ReceiverChecks

func (Acknowledge) Revision

func (a Acknowledge) Revision() *artifact.Ref

func (Acknowledge) Selection

func (a Acknowledge) Selection() handoff.Selection

func (Acknowledge) SourceID

func (a Acknowledge) SourceID() string

func (Acknowledge) Status

func (a Acknowledge) Status() ReceiptStatus

func (Acknowledge) Validate

func (a Acknowledge) Validate() error

type Acknowledgement

type Acknowledgement struct {
	Resolution handoff.Resolution
	Receipt    SourceReceipt
}

type CheckStatus

type CheckStatus string
const (
	CheckPassed      CheckStatus = "passed"
	CheckFailed      CheckStatus = "failed"
	CheckSkipped     CheckStatus = "skipped"
	CheckTimedOut    CheckStatus = "timed_out"
	CheckUnavailable CheckStatus = "unavailable"
	CheckCancelled   CheckStatus = "cancelled"
	CheckUnknown     CheckStatus = "unknown"
)

type Claim

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

func NewClaim

func NewClaim(text string, basis ClaimBasis, evidence []handoff.Citation) (Claim, error)

func (Claim) Basis

func (c Claim) Basis() ClaimBasis

func (Claim) Evidence

func (c Claim) Evidence() []handoff.Citation

func (Claim) Text

func (c Claim) Text() string

func (Claim) Validate

func (c Claim) Validate() error

type ClaimBasis

type ClaimBasis string
const (
	Declared ClaimBasis = "declared"
	Verified ClaimBasis = "verified"
)

type Continuity

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

func ProjectContinuity

func ProjectContinuity(scopeID string, entries []source.JournalEntry, selectedHandoff *artifact.Ref) (Continuity, error)

ProjectContinuity deterministically projects only valid high-level Work records. Ordinary Sources are ignored and malformed Work Sources are counted without making report generation fail.

func (Continuity) Coverage

func (c Continuity) Coverage() Coverage

func (Continuity) Events

func (c Continuity) Events() []Event

func (Continuity) InvalidRecordCount

func (c Continuity) InvalidRecordCount() int

func (Continuity) MarshalJSON

func (c Continuity) MarshalJSON() ([]byte, error)

MarshalJSON preserves the Python WorkContinuity wire shape, including explicit nulls. It is also the value consumed by Handoff Report JCS digests.

func (Continuity) Schema

func (c Continuity) Schema() string

func (Continuity) ScopeID

func (c Continuity) ScopeID() string

func (Continuity) SelectedHandoff

func (c Continuity) SelectedHandoff() *artifact.Ref

func (Continuity) TotalEventCount

func (c Continuity) TotalEventCount() int

func (Continuity) Truncated

func (c Continuity) Truncated() bool

func (Continuity) Trust

func (c Continuity) Trust() string

func (Continuity) Validate

func (c Continuity) Validate() error

Validate protects the report-facing continuity projection from malformed values. Continuity is assembled by ProjectContinuity, but keeping the invariants on the value itself prevents report digests from blessing an internally inconsistent projection.

type Contract

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

func NewContract

func NewContract(
	objective string,
	facts []Claim,
	inScope, exclusions, completionCriteria, authorizationNotes, openQuestions []string,
) (Contract, error)

func (Contract) AuthorizationNotes

func (c Contract) AuthorizationNotes() []string

func (Contract) CompletionCriteria

func (c Contract) CompletionCriteria() []string

func (Contract) Exclusions

func (c Contract) Exclusions() []string

func (Contract) Facts

func (c Contract) Facts() []Claim

func (Contract) InScope

func (c Contract) InScope() []string

func (Contract) Objective

func (c Contract) Objective() string

func (Contract) OpenQuestions

func (c Contract) OpenQuestions() []string

func (Contract) Schema

func (c Contract) Schema() string

func (Contract) Trust

func (c Contract) Trust() string

func (Contract) Validate

func (c Contract) Validate() error

type Coverage

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

func (Coverage) AcknowledgementRecords

func (c Coverage) AcknowledgementRecords() int

func (Coverage) ActiveReceiptRef

func (c Coverage) ActiveReceiptRef() *source.Ref

func (Coverage) ContractRecords

func (c Coverage) ContractRecords() int

func (Coverage) HandoffRecords

func (c Coverage) HandoffRecords() int

func (Coverage) HandoffResultCovered

func (c Coverage) HandoffResultCovered() bool

func (Coverage) OutcomeRecords

func (c Coverage) OutcomeRecords() int

func (Coverage) OutcomeState

func (c Coverage) OutcomeState() OutcomeState

func (Coverage) TransferState

func (c Coverage) TransferState() TransferState

type CreateContract

type CreateContract struct {
	SourceID string
	Contract Contract
}

type CurrentHandoff

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

func NewCurrentHandoff

func NewCurrentHandoff(
	objective string,
	state []Claim,
	disposition handoff.Disposition,
	nextAction *Claim,
	omissions []string,
) (CurrentHandoff, error)

func (CurrentHandoff) Disposition

func (h CurrentHandoff) Disposition() handoff.Disposition

func (CurrentHandoff) NextAction

func (h CurrentHandoff) NextAction() *Claim

func (CurrentHandoff) Objective

func (h CurrentHandoff) Objective() string

func (CurrentHandoff) Omissions

func (h CurrentHandoff) Omissions() []string

func (CurrentHandoff) Schema

func (h CurrentHandoff) Schema() string

func (CurrentHandoff) State

func (h CurrentHandoff) State() []Claim

func (CurrentHandoff) Trust

func (h CurrentHandoff) Trust() string

func (CurrentHandoff) Validate

func (h CurrentHandoff) Validate() error

type Event

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

func (Event) Actor

func (e Event) Actor() *string

func (Event) HandoffReceiptRef

func (e Event) HandoffReceiptRef() *source.Ref

func (Event) Kind

func (e Event) Kind() Kind

func (Event) Position

func (e Event) Position() int64

func (Event) ReceiverChecks

func (e Event) ReceiverChecks() *ReceiverChecks

func (Event) RecordSchema

func (e Event) RecordSchema() string

func (Event) SelectedRevision

func (e Event) SelectedRevision() *artifact.Ref

func (Event) SourceRef

func (e Event) SourceRef() source.Ref

func (Event) Status

func (e Event) Status() EventStatus

func (Event) Summary

func (e Event) Summary() *string

type EventStatus

type EventStatus string

type EvidenceStatus

type EvidenceStatus string
const (
	EvidenceAvailable   EvidenceStatus = "available"
	EvidenceUnavailable EvidenceStatus = "unavailable"
)

type HandoffCurrent

type HandoffCurrent struct {
	SourceID string
	Handoff  CurrentHandoff
}

type HandoffReceipt

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

func NewHandoffReceipt

func NewHandoffReceipt(
	receiver string,
	status ReceiptStatus,
	selection handoff.Selection,
	selectedRevision *artifact.Ref,
	preparedDigest *string,
	receiverChecks *ReceiverChecks,
	evidenceStatus EvidenceStatus,
	unavailableEvidence []handoff.Citation,
	message *string,
) (HandoffReceipt, error)

func (HandoffReceipt) EvidenceStatus

func (r HandoffReceipt) EvidenceStatus() EvidenceStatus

func (HandoffReceipt) Message

func (r HandoffReceipt) Message() *string

func (HandoffReceipt) PreparedDigest

func (r HandoffReceipt) PreparedDigest() *string

func (HandoffReceipt) Receiver

func (r HandoffReceipt) Receiver() string

func (HandoffReceipt) ReceiverChecks

func (r HandoffReceipt) ReceiverChecks() *ReceiverChecks

func (HandoffReceipt) Schema

func (r HandoffReceipt) Schema() string

func (HandoffReceipt) SelectedRevision

func (r HandoffReceipt) SelectedRevision() *artifact.Ref

func (HandoffReceipt) Selection

func (r HandoffReceipt) Selection() handoff.Selection

func (HandoffReceipt) Status

func (r HandoffReceipt) Status() ReceiptStatus

func (HandoffReceipt) Trust

func (r HandoffReceipt) Trust() string

func (HandoffReceipt) UnavailableEvidence

func (r HandoffReceipt) UnavailableEvidence() []handoff.Citation

func (HandoffReceipt) Validate

func (r HandoffReceipt) Validate() error

type InvalidError

type InvalidError struct {
	Field  string
	Detail string
}

InvalidError identifies a domain validation failure without exposing the submitted value. Transport adapters map it to the public invalid_request envelope.

func (*InvalidError) Error

func (e *InvalidError) Error() string

type InvalidRequestError

type InvalidRequestError struct{ Code string }

InvalidRequestError identifies a validly decoded request whose selected history cannot satisfy the Work continuity trust boundary.

func (*InvalidRequestError) Error

func (e *InvalidRequestError) Error() string

type Kind

type Kind string

func (Kind) Validate

func (k Kind) Validate() error

type LiveStateCheckStatus

type LiveStateCheckStatus string
const (
	LiveStateConfirmed  LiveStateCheckStatus = "confirmed"
	LiveStateMismatch   LiveStateCheckStatus = "mismatch"
	LiveStateNotChecked LiveStateCheckStatus = "not_checked"
)

type OutcomeState

type OutcomeState string
const (
	OutcomeNotExpected OutcomeState = "not_expected"
	OutcomeAwaiting    OutcomeState = "awaiting_outcome"
	OutcomeCovered     OutcomeState = "covered"
)

type OutcomeStatus

type OutcomeStatus string
const (
	OutcomeSucceeded OutcomeStatus = "succeeded"
	OutcomePartial   OutcomeStatus = "partial"
	OutcomeBlocked   OutcomeStatus = "blocked"
	OutcomeFailed    OutcomeStatus = "failed"
	OutcomeCancelled OutcomeStatus = "cancelled"
	OutcomeUnknown   OutcomeStatus = "unknown"
)

type PreparedHandoff

type PreparedHandoff struct {
	Boundary SourceReceipt
	Handoff  handoff.Prepared
}

type ReadinessCheckStatus

type ReadinessCheckStatus string
const (
	ReadinessConfirmed    ReadinessCheckStatus = "confirmed"
	ReadinessInsufficient ReadinessCheckStatus = "insufficient"
	ReadinessNotChecked   ReadinessCheckStatus = "not_checked"
)

type ReceiptStatus

type ReceiptStatus string
const (
	ReceiptAccepted           ReceiptStatus = "accepted"
	ReceiptNeedsClarification ReceiptStatus = "needs_clarification"
	ReceiptDeclined           ReceiptStatus = "declined"
)

type ReceiverChecks

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

func NewReceiverChecks

func NewReceiverChecks(live LiveStateCheckStatus, capability, authorization ReadinessCheckStatus) (ReceiverChecks, error)

func (ReceiverChecks) AllConfirmed

func (c ReceiverChecks) AllConfirmed() bool

func (ReceiverChecks) Authorization

func (c ReceiverChecks) Authorization() ReadinessCheckStatus

func (ReceiverChecks) Capability

func (c ReceiverChecks) Capability() ReadinessCheckStatus

func (ReceiverChecks) LiveState

func (c ReceiverChecks) LiveState() LiveStateCheckStatus

func (ReceiverChecks) Validate

func (c ReceiverChecks) Validate() error

type RecordOutcome

type RecordOutcome struct {
	SourceID string
	Outcome  TaskOutcome
}

type SourceReceipt

type SourceReceipt struct {
	Kind          Kind
	SourceRef     source.Ref
	Position      int64
	ContentDigest string
}

type TaskCheck

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

func NewTaskCheck

func NewTaskCheck(name string, status CheckStatus, details *string, basis ClaimBasis, evidence []handoff.Citation) (TaskCheck, error)

func (TaskCheck) Basis

func (c TaskCheck) Basis() ClaimBasis

func (TaskCheck) Details

func (c TaskCheck) Details() *string

func (TaskCheck) Evidence

func (c TaskCheck) Evidence() []handoff.Citation

func (TaskCheck) Name

func (c TaskCheck) Name() string

func (TaskCheck) Status

func (c TaskCheck) Status() CheckStatus

func (TaskCheck) Validate

func (c TaskCheck) Validate() error

type TaskOutcome

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

func NewTaskOutcome

func NewTaskOutcome(
	objective string,
	status OutcomeStatus,
	summary string,
	handoffReceiptRef *source.Ref,
	observations []Claim,
	checks []TaskCheck,
	producedArtifacts []artifact.Ref,
	remainingWork []string,
) (TaskOutcome, error)

func (TaskOutcome) Checks

func (o TaskOutcome) Checks() []TaskCheck

func (TaskOutcome) HandoffReceiptRef

func (o TaskOutcome) HandoffReceiptRef() *source.Ref

func (TaskOutcome) Objective

func (o TaskOutcome) Objective() string

func (TaskOutcome) Observations

func (o TaskOutcome) Observations() []Claim

func (TaskOutcome) ProducedArtifacts

func (o TaskOutcome) ProducedArtifacts() []artifact.Ref

func (TaskOutcome) RemainingWork

func (o TaskOutcome) RemainingWork() []string

func (TaskOutcome) Schema

func (o TaskOutcome) Schema() string

func (TaskOutcome) Status

func (o TaskOutcome) Status() OutcomeStatus

func (TaskOutcome) Summary

func (o TaskOutcome) Summary() string

func (TaskOutcome) Trust

func (o TaskOutcome) Trust() string

func (TaskOutcome) Validate

func (o TaskOutcome) Validate() error

type TransferState

type TransferState string
const (
	TransferNotApplicable      TransferState = "not_applicable"
	TransferAwaitingReceipt    TransferState = "awaiting_receipt"
	TransferNeedsClarification TransferState = "needs_clarification"
	TransferDeclined           TransferState = "declined"
	TransferAccepted           TransferState = "accepted"
)

Jump to

Keyboard shortcuts

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