Documentation
¶
Overview ¶
Package notification owns the canonical local notification projection, personal project registry, independent delivery leases, and trusted route ledger. Native adapters only render this protocol.
Index ¶
- Constants
- Variables
- func ValidChannel(channel Channel) bool
- type AckRequest
- type AckResult
- type Channel
- type ChannelResult
- type ClaimRequest
- type ClaimResult
- type ComponentHealth
- type ComponentManager
- type ComponentOptions
- type ComponentProbe
- type Controller
- func (c *Controller) Ack(ctx context.Context, request AckRequest) (AckResult, error)
- func (c *Controller) Claim(ctx context.Context, request ClaimRequest) (ClaimResult, error)
- func (c *Controller) Install(ctx context.Context, request InstallRequest) (OperationResult, error)
- func (c *Controller) Open(ctx context.Context, request OpenRequest) (OpenResult, error)
- func (c *Controller) Preference(ctx context.Context, request PreferenceRequest) (PreferenceResult, error)
- func (c *Controller) Status(ctx context.Context, request StatusRequest) (Status, error)
- func (c *Controller) Test(ctx context.Context, request TestRequest) (OperationResult, error)
- func (c *Controller) Uninstall(ctx context.Context, request UninstallRequest) (OperationResult, error)
- type DeliveryStore
- type DetailedComponentProbe
- type Entry
- type InstallRequest
- type Lease
- type Level
- type Offer
- type OpenRequest
- type OpenResult
- type OperationResult
- type PreferenceRequest
- type PreferenceResult
- type Project
- type ProjectConfigurator
- type ProjectSource
- type Projection
- type Registry
- func (r *Registry) Enroll(root string, channels []Channel) (Project, error)
- func (r *Registry) FindByID(id string) (Project, error)
- func (r *Registry) FindByRoot(root string) (Project, error)
- func (r *Registry) ForgetComponent(channel Channel, profile, codePath string) error
- func (r *Registry) Offer(project Project, available []Channel) (Offer, error)
- func (r *Registry) Preference(root string, remindInDays int, never, reset, global bool) error
- func (r *Registry) Projects() ([]Project, error)
- func (r *Registry) PurgeChannels(channels []Channel) error
- func (r *Registry) Register(root string) (Project, bool, error)
- func (r *Registry) RememberComponent(channel Channel, profile, codePath, productVersion string) error
- type Route
- type RouteOpener
- type Service
- func (s *Service) Ack(ctx context.Context, token string, entries []string) (AckResult, error)
- func (s *Service) Claim(ctx context.Context, channel Channel, consumer, projectID string, limit int) (ClaimResult, error)
- func (s *Service) ResolveRoute(token string) (Route, Project, error)
- func (s *Service) Status(ctx context.Context, root string, probe bool) (Status, error)
- type SourceFactory
- type Status
- type StatusRequest
- type TestRequest
- type UninstallRequest
Constants ¶
const SchemaVersion = 1
SchemaVersion is the notification adapter protocol version.
Variables ¶
var ( // ErrInvalidConsumer rejects unsafe or unbounded adapter identities. ErrInvalidConsumer = errors.New("invalid notification consumer") // ErrInvalidLimit rejects unbounded adapter claims. ErrInvalidLimit = errors.New("notification claim limit must be between 1 and 50") // ErrDeliveryStateMismatch rejects state owned by another consumer/channel. ErrDeliveryStateMismatch = errors.New("notification delivery state identity mismatch") // ErrLeaseNotFound rejects unknown or expired lease identities. ErrLeaseNotFound = errors.New("notification lease not found") // ErrEntryNotLeased rejects acknowledgement outside the leased batch. ErrEntryNotLeased = errors.New("notification entry was not leased") )
var ( ErrComponentsUnavailable = errors.New("notification components unavailable") // ErrInvalidAck rejects incomplete acknowledgement requests. ErrInvalidAck = errors.New("notification ack requires lease and entries") // ErrUninstallAffectsProjects requires confirmation for global impact. ErrUninstallAffectsProjects = errors.New("notification uninstall affects other projects") )
var ( // ErrProjectNotFound means the requested registration does not exist. ErrProjectNotFound = errors.New("notification project not found") // ErrInvalidChannel rejects an unknown presentation channel. ErrInvalidChannel = errors.New("invalid notification channel") // ErrInvalidPreference rejects ambiguous setup-offer transitions. ErrInvalidPreference = errors.New("invalid notification preference") )
var ErrChannelNotEnrolled = fmt.Errorf("notification channel not enrolled")
ErrChannelNotEnrolled rejects claims for a project-disabled channel.
var ErrRouteNotFound = errors.New("notification route not found")
ErrRouteNotFound rejects unknown or malformed trusted-route tokens.
Functions ¶
func ValidChannel ¶
ValidChannel reports whether channel is implemented by P49.
Types ¶
type AckRequest ¶
AckRequest acknowledges accepted entries under one lease.
type AckResult ¶
type AckResult struct {
Acked []string `json:"acked"`
AlreadyAcked []string `json:"already_acked"`
}
AckResult distinguishes newly and previously accepted entries.
type ChannelResult ¶
type ChannelResult struct {
Channel Channel `json:"channel"`
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
}
ChannelResult reports one component lifecycle outcome.
type ClaimRequest ¶
ClaimRequest is the adapter-only transition delivery request.
type ClaimResult ¶
ClaimResult contains an optional lease and its bounded entries.
type ComponentHealth ¶
type ComponentHealth struct {
Channel Channel `json:"channel"`
Available bool `json:"available"`
Installed bool `json:"installed"`
Version string `json:"version,omitempty"`
Protocol int `json:"protocol,omitempty"`
Profile string `json:"profile,omitempty"`
CodePath string `json:"code_path,omitempty"`
Permission string `json:"permission,omitempty"`
LoginItem string `json:"login_item,omitempty"`
Handshake string `json:"handshake,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Detail string `json:"detail,omitempty"`
}
ComponentHealth is additive detail behind the stable installed-channel summary. Platform probes may leave fields empty when a bounded status read cannot determine them without launching UI or prompting.
type ComponentManager ¶
type ComponentManager interface {
ComponentProbe
Install(context.Context, Channel, ComponentOptions) (ChannelResult, error)
Test(context.Context, Channel, Project) (ChannelResult, error)
Uninstall(context.Context, Channel, ComponentOptions, bool) (ChannelResult, error)
}
ComponentManager owns platform application state. It never owns project semantics or delivery cursors.
type ComponentOptions ¶
ComponentOptions identifies an exact VS Code installation/profile.
type ComponentProbe ¶
type ComponentProbe interface {
Available(context.Context) ([]Channel, error)
Installed(context.Context) ([]Channel, error)
}
ComponentProbe reports basic platform availability and installation state.
type Controller ¶
type Controller struct {
Service *Service
Components ComponentManager
OpenRoute RouteOpener
}
Controller is the application service behind the thin CLI family.
func (*Controller) Ack ¶
func (c *Controller) Ack(ctx context.Context, request AckRequest) (AckResult, error)
Ack accepts only entries covered by a live or completed lease.
func (*Controller) Claim ¶
func (c *Controller) Claim(ctx context.Context, request ClaimRequest) (ClaimResult, error)
Claim leases one adapter consumer's bounded transition batch.
func (*Controller) Install ¶
func (c *Controller) Install(ctx context.Context, request InstallRequest) (OperationResult, error)
Install prepares adapter config, repairs components, then enrolls only channels whose component mutation succeeded. A failed install therefore cannot leave registry truth claiming that a channel is enabled.
func (*Controller) Open ¶
func (c *Controller) Open(ctx context.Context, request OpenRequest) (OpenResult, error)
Open resolves a core-minted route and invokes the local HTML opener.
func (*Controller) Preference ¶
func (c *Controller) Preference(ctx context.Context, request PreferenceRequest) (PreferenceResult, error)
Preference applies one validated setup-offer transition.
func (*Controller) Status ¶
func (c *Controller) Status(ctx context.Context, request StatusRequest) (Status, error)
Status returns project signals and bounded platform component health.
func (*Controller) Test ¶
func (c *Controller) Test(ctx context.Context, request TestRequest) (OperationResult, error)
Test sends a synthetic readiness request without advancing delivery state.
func (*Controller) Uninstall ¶
func (c *Controller) Uninstall(ctx context.Context, request UninstallRequest) (OperationResult, error)
Uninstall removes components and optionally purges selected machine state.
type DeliveryStore ¶
type DeliveryStore struct {
Root string
Now func() time.Time
LeaseTTL time.Duration
Mint func() (string, error)
}
DeliveryStore persists channel/consumer-specific at-least-once state.
func NewDeliveryStore ¶
func NewDeliveryStore(root string, now func() time.Time) *DeliveryStore
NewDeliveryStore constructs a delivery store rooted in disposable cache.
func (*DeliveryStore) Ack ¶
func (s *DeliveryStore) Ack(ctx context.Context, token string, entryIDs []string) (AckResult, error)
Ack idempotently accepts only entries owned by the supplied lease.
func (*DeliveryStore) Claim ¶
func (s *DeliveryStore) Claim(ctx context.Context, channel Channel, consumer, projectID string, current []Entry, limit int) (ClaimResult, error)
Claim leases a bounded batch after establishing a no-history baseline.
func (*DeliveryStore) PurgeChannels ¶
func (s *DeliveryStore) PurgeChannels(channels []Channel) error
PurgeChannels removes only disposable delivery state for explicitly selected channels. The fixed channel directory is derived after validation; project truth and the human inbox cursor are outside this root and cannot be touched.
type DetailedComponentProbe ¶
type DetailedComponentProbe interface {
Health(context.Context) ([]ComponentHealth, error)
}
DetailedComponentProbe reports bounded platform-specific health.
type Entry ¶
type Entry struct {
SchemaVersion int `json:"schema_version"`
EntryID string `json:"entry_id"`
ProjectID string `json:"project_id"`
SpaceID string `json:"space_id,omitempty"`
ArtifactID string `json:"artifact_id,omitempty"`
EventID string `json:"event_id,omitempty"`
Kind string `json:"kind"`
Severity string `json:"severity"`
Title string `json:"title"`
Summary string `json:"summary"`
OccurredAt time.Time `json:"occurred_at"`
SourceRevision string `json:"source_revision,omitempty"`
CoalesceKey string `json:"coalesce_key"`
RouteToken string `json:"route_token"`
}
Entry is one sanitized, qualified, lease-delivered transition signal.
type InstallRequest ¶
type InstallRequest struct {
Root string
Channels []Channel
All bool
Profile string
CodePath string
}
InstallRequest enrolls a project and installs selected components.
type Lease ¶
type Lease struct {
Token string `json:"token"`
ConsumerID string `json:"consumer_id"`
Channel Channel `json:"channel"`
ProjectID string `json:"project_id"`
ExpiresAt time.Time `json:"expires_at"`
}
Lease grants one consumer temporary ownership of a project batch.
type Level ¶
type Level struct {
Line string `json:"line"`
New int `json:"new"`
Urgent int `json:"urgent"`
Stale int `json:"stale"`
Update string `json:"update"`
Severity string `json:"severity"`
Quiet bool `json:"quiet"`
RouteToken string `json:"route_token,omitempty"`
}
Level is the persistent aggregate status rendered by every channel.
type Offer ¶
type Offer struct {
State string `json:"state"`
Scope string `json:"scope"`
RemindAfter *time.Time `json:"remind_after"`
}
Offer is the effective notification setup prompt state.
type OpenRequest ¶
type OpenRequest struct {
RouteToken string
}
OpenRequest carries a core-minted trusted route token.
type OpenResult ¶
type OpenResult struct {
ProjectID string `json:"project_id"`
Root string `json:"root"`
SpaceID string `json:"space_id,omitempty"`
ArtifactID string `json:"artifact_id,omitempty"`
Kind string `json:"kind"`
}
OpenResult reports the project-local destination opened for a route.
type OperationResult ¶
type OperationResult struct {
Project *Project `json:"project"`
Results []ChannelResult `json:"results"`
Failed bool `json:"failed"`
}
OperationResult aggregates deterministic per-channel lifecycle outcomes.
type PreferenceRequest ¶
PreferenceRequest changes project or global setup-offer policy.
type PreferenceResult ¶
PreferenceResult returns the effective setup-offer state.
type Project ¶
type Project struct {
ID string `json:"id"`
Root string `json:"root"`
Channels []Channel `json:"channels"`
LastSeen time.Time `json:"last_seen"`
}
Project is one stable machine-local notification registration.
type ProjectConfigurator ¶
ProjectConfigurator refreshes adapter-owned project configuration.
type ProjectSource ¶
type ProjectSource interface {
NotificationSnapshot(context.Context) (cache.NotificationSnapshot, error)
}
ProjectSource is the consumer-side interface implemented by cache.Store.
type Projection ¶
Projection is the canonical level, transition-entry, and route snapshot.
func BuildProjection ¶
func BuildProjection(ctx context.Context, project Project, source ProjectSource, now time.Time) (Projection, error)
BuildProjection derives sanitized notification state from cursor-neutral cache truth.
type Registry ¶
Registry owns machine-local project enrollment and setup preferences.
func NewRegistry ¶
NewRegistry constructs a registry backed by typed machine config.
func (*Registry) FindByRoot ¶
FindByRoot resolves one canonical registered project root.
func (*Registry) ForgetComponent ¶
ForgetComponent drops only the matching ownership marker; application uninstall and project enrollment remain separate lifecycle operations.
func (*Registry) Offer ¶
Offer computes effective prompt state using project-before-global precedence.
func (*Registry) Preference ¶
Preference applies one project or global setup-offer policy change.
func (*Registry) PurgeChannels ¶
PurgeChannels deletes the selected notification registry state after an explicitly confirmed --purge. Purging both channels resets the whole P49 config while preserving unrelated machine defaults and credentials.
type Route ¶
type Route struct {
Token string `json:"token"`
ProjectID string `json:"project_id"`
SpaceID string `json:"space_id,omitempty"`
ArtifactID string `json:"artifact_id,omitempty"`
Kind string `json:"kind"`
CreatedAt time.Time `json:"created_at"`
}
Route is a core-minted local HTML destination.
type RouteOpener ¶
RouteOpener opens a previously resolved trusted local route.
type Service ¶
type Service struct {
Registry *Registry
Delivery *DeliveryStore
Sources SourceFactory
Probe ComponentProbe
}
Service composes registry, projection, delivery, routes, and component health.
func (*Service) Claim ¶
func (s *Service) Claim(ctx context.Context, channel Channel, consumer, projectID string, limit int) (ClaimResult, error)
Claim projects and leases transition entries for one enrolled consumer.
func (*Service) ResolveRoute ¶
ResolveRoute resolves a ledger-backed token and its registered project.
type SourceFactory ¶
type SourceFactory func(project Project) (ProjectSource, error)
SourceFactory resolves cursor-neutral cache truth for one project.
type Status ¶
type Status struct {
AvailableChannels []Channel `json:"available_channels"`
InstalledChannels []Channel `json:"installed_channels"`
Project *Project `json:"project"`
Level Level `json:"level"`
Offer Offer `json:"offer"`
Components []ComponentHealth `json:"components"`
}
Status is the additive JSON contract shared by skill and adapters.
type StatusRequest ¶
StatusRequest selects one project and optional channel health view.
type TestRequest ¶
TestRequest asks selected adapters for a synthetic readiness proof.