Documentation
¶
Overview ¶
Package sharedtask is the in-memory reference fold for collaborative task records. It is deliberately off the hot path: adapters can reuse its patch, conflict, scope, event, and journal semantics without each inventing a separate task-state contract.
Index ¶
- Constants
- func ComputeRev(record TaskRecord) string
- func ContractJSONFiles(path string) ([]string, error)
- func EventRef(event Event) (abi.Ref, error)
- func EventTopic(taskID string) a2achan.ChannelKey
- func FormatContractCounts(counts map[string]int) string
- func LoadContractSchema(schemaDir, name string) (map[string]any, error)
- func PublishEvent(ctx context.Context, bus *a2achan.Bus, from string, event Event, ...) (abi.Verdict, int, error)
- func PublishEventScoped(ctx context.Context, bus *a2achan.Bus, from string, event Event, ...) (abi.Verdict, int, error)
- func ScopedEventTopic(taskID string, maxScope Scope) a2achan.ChannelKey
- func ValidateContractDoc(schemaDir, docPath string) (map[string]int, error)
- func ValidateContractFiles(schemaDir string, paths []string) (map[string]int, error)
- func ValidateContractSequence(schemaDir, path string) (map[string]int, error)
- func ValidateContractVerdicts(schemaDir, path string) (map[string]int, error)
- func ValidateEnvelope(envelope map[string]any, schemaDir string) (string, error)
- type Actor
- type Approval
- type ArtifactRef
- type BodyRef
- type Conflict
- type Decision
- type Denial
- type Durability
- type Event
- type EventLogView
- type Journal
- type JournalEntry
- type Note
- type Op
- type Patch
- type PatchResult
- type Policy
- type Quarantine
- type Scope
- type Store
- func (s *Store) Apply(patch Patch) PatchResult
- func (s *Store) ApplyAndPublish(ctx context.Context, bus *a2achan.Bus, from string, patch Patch, ...) (PatchResult, abi.Verdict, int, error)
- func (s *Store) ApplyAndPublishScoped(ctx context.Context, bus *a2achan.Bus, from string, patch Patch, ...) (PatchResult, abi.Verdict, int, error)
- func (s *Store) Create(record TaskRecord) (TaskRecord, error)
- func (s *Store) Event(taskID, eventID string) (Event, bool)
- func (s *Store) Events(taskID string) []Event
- func (s *Store) EventsView(taskID string, policy ViewPolicy) (EventLogView, bool)
- func (s *Store) Get(taskID string) (TaskRecord, bool)
- func (s *Store) Journal(taskID string) (Journal, bool)
- func (s *Store) SubscribeScopedView(bus *a2achan.Bus, taskID string, policy ViewPolicy) (TaskSubscription, bool)
- func (s *Store) SubscribeView(bus *a2achan.Bus, taskID string, policy ViewPolicy) (TaskSubscription, bool)
- func (s *Store) View(taskID string, policy ViewPolicy) (TaskView, bool)
- type Taint
- type TaskRecord
- type TaskSubscription
- type TaskView
- type Verdict
- type ViewPolicy
Constants ¶
const ( SchemaTaskJournal = "fak.shared-task-journal.v1" SchemaJournal = SchemaTaskJournal )
const ( SchemaTask = "fak.shared-task.v1" SchemaEvent = "fak.shared-event.v1" SchemaPatch = "fak.shared-patch.v1" SchemaPatchResult = "fak.shared-patch-result.v1" )
const ( ReasonApprovalRequired = "APPROVAL_REQUIRED" ReasonArtifactQuarantine = "ARTIFACT_QUARANTINED" ReasonArtifactWitness = "ARTIFACT_WITNESS_MISSING" ReasonBodyQuarantine = "BODY_QUARANTINED" ReasonBodyWitness = "BODY_WITNESS_MISSING" ReasonMissingDecision = "MISSING_DECISION" ReasonScopeDenied = "SCOPE_WIDEN_FORBIDDEN" ReasonStaleBase = "STALE_BASE" ReasonUnsupportedPatch = "UNSUPPORTED_PATCH" )
const SchemaArtifactRef = "fak.shared-artifact-ref.v1"
SchemaArtifactRef is the envelope schema name for a standalone disaggregated artifact reference — the sixth contract schema; the other five are declared in sharedtask.go and journal.go.
Variables ¶
This section is empty.
Functions ¶
func ComputeRev ¶
func ComputeRev(record TaskRecord) string
func ContractJSONFiles ¶ added in v0.37.0
ContractJSONFiles lists the JSON files to validate: the path itself when it is a file, else every *.json under the directory in stable sorted order.
func EventTopic ¶
func EventTopic(taskID string) a2achan.ChannelKey
func FormatContractCounts ¶ added in v0.37.0
FormatContractCounts renders per-schema counts as the stable "name=n, ..." summary line the contract recipes print.
func LoadContractSchema ¶ added in v0.37.0
LoadContractSchema reads and parses the named contract schema from schemaDir.
func PublishEvent ¶
func PublishEventScoped ¶
func ScopedEventTopic ¶
func ScopedEventTopic(taskID string, maxScope Scope) a2achan.ChannelKey
func ValidateContractDoc ¶ added in v0.37.0
ValidateContractDoc validates every ```json``` example block in the contract doc and returns per-schema counts, so the prose examples can never drift from the schemas they illustrate.
func ValidateContractFiles ¶ added in v0.37.0
ValidateContractFiles envelope-validates each file and returns per-schema counts.
func ValidateContractSequence ¶ added in v0.37.0
ValidateContractSequence checks the full collaborative-sequence fixture shape: a task record, at least one materialized journal bound to the same task with accepted-event snapshots, at least one accepted patch result, and a title replacement patch (the canonical co-edit the example narrates).
func ValidateContractVerdicts ¶ added in v0.37.0
ValidateContractVerdicts checks the non-acceptance fixture shape: every non-accepted verdict a UI must render (needs_approval, denied, quarantined) is present, each carries a reason, and none advances the task revision.
Types ¶
type ArtifactRef ¶
type BodyRef ¶
type BodyRef struct {
Kind string `json:"kind"`
Digest string `json:"digest"`
Bytes int64 `json:"bytes"`
Taint Taint `json:"taint"`
Scope Scope `json:"scope"`
Durability Durability `json:"durability"`
Store string `json:"store,omitempty"`
DeletionCertificate string `json:"deletion_certificate,omitempty"`
}
type Durability ¶
type Durability string
const ( DurabilityTurn Durability = "turn" DurabilitySession Durability = "session" DurabilityBounded Durability = "bounded" DurabilityDurable Durability = "durable" )
type Event ¶
type Event struct {
Schema string `json:"schema"`
EventID string `json:"event_id"`
TaskID string `json:"task_id"`
PrevEvent string `json:"prev_event"`
EventKind string `json:"event_kind"`
Actor Actor `json:"actor"`
BaseRev string `json:"base_rev"`
NextRev string `json:"next_rev"`
Scope Scope `json:"scope"`
Durability Durability `json:"durability"`
Taint Taint `json:"taint"`
PatchDigest string `json:"patch_digest"`
Verdict Verdict `json:"verdict"`
Reason string `json:"reason"`
TS string `json:"ts"`
}
type EventLogView ¶
type Journal ¶
type Journal struct {
Schema string `json:"schema"`
TaskID string `json:"task_id"`
Initial TaskRecord `json:"initial"`
Entries []JournalEntry `json:"entries"`
Digest string `json:"digest"`
}
func (Journal) ComputeDigest ¶
func (Journal) CurrentRecord ¶
func (j Journal) CurrentRecord() (TaskRecord, bool)
type JournalEntry ¶
type JournalEntry struct {
Event Event `json:"event"`
Record TaskRecord `json:"record"`
RecordDigest string `json:"record_digest"`
}
type PatchResult ¶
type PatchResult struct {
Schema string `json:"schema"`
TaskID string `json:"task_id"`
BaseRev string `json:"base_rev"`
CurrentRev string `json:"current_rev"`
Verdict Verdict `json:"verdict"`
Reason string `json:"reason"`
EventID string `json:"event_id,omitempty"`
RecordRef string `json:"record_ref,omitempty"`
Approval *Approval `json:"approval,omitempty"`
Denial *Denial `json:"denial,omitempty"`
Quarantine *Quarantine `json:"quarantine,omitempty"`
Conflict *Conflict `json:"conflict,omitempty"`
}
type Quarantine ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) Apply ¶
func (s *Store) Apply(patch Patch) PatchResult
func (*Store) ApplyAndPublish ¶
func (*Store) ApplyAndPublishScoped ¶
func (*Store) Create ¶
func (s *Store) Create(record TaskRecord) (TaskRecord, error)
func (*Store) EventsView ¶
func (s *Store) EventsView(taskID string, policy ViewPolicy) (EventLogView, bool)
func (*Store) SubscribeScopedView ¶
func (s *Store) SubscribeScopedView(bus *a2achan.Bus, taskID string, policy ViewPolicy) (TaskSubscription, bool)
func (*Store) SubscribeView ¶
func (s *Store) SubscribeView(bus *a2achan.Bus, taskID string, policy ViewPolicy) (TaskSubscription, bool)
type TaskRecord ¶
type TaskRecord struct {
Schema string `json:"schema"`
TaskID string `json:"task_id"`
Rev string `json:"rev"`
State string `json:"state"`
Title string `json:"title"`
BodyRef BodyRef `json:"body_ref"`
Artifacts []ArtifactRef `json:"artifacts"`
Notes []Note `json:"notes"`
OpenDecisions []Decision `json:"open_decisions"`
UpdatedBy Actor `json:"updated_by"`
UpdatedAt string `json:"updated_at"`
}
type TaskSubscription ¶
type TaskSubscription struct {
Topic a2achan.ChannelKey
Inbox a2achan.ChannelKey
View TaskView
Cancel func()
}
type TaskView ¶
type TaskView struct {
Record TaskRecord
BodyVisible bool
RedactedArtifacts int
RedactedNotes int
}