Documentation
¶
Index ¶
- Constants
- func Batch(events []QueueEvent) ([]byte, error)
- func ReadFidelityRank(fidelity string) int
- type AgentSession
- type Focus
- type InjectionItem
- type LifecycleEvent
- type LifecyclePublication
- type ManifestPublication
- type QueueEvent
- type ReadSetEntry
- type Store
- func (s *Store) Ack(ctx context.Context, id string) error
- func (s *Store) ActiveAgentSessions(ctx context.Context, workspaceID, vendor, cwd string, activeAfter time.Time) ([]AgentSession, error)
- func (s *Store) ActiveFocus(ctx context.Context, now time.Time) ([]Focus, error)
- func (s *Store) ActiveManifest(ctx context.Context, id string) (int64, string, []byte, error)
- func (s *Store) AgentObserved(ctx context.Context, workspaceID, vendor string) (time.Time, bool, error)
- func (s *Store) Boot(ctx context.Context) (int64, error)
- func (s *Store) ChangedFingerprints(ctx context.Context, workspaceID string, observed map[string]string, ...) ([]string, error)
- func (s *Store) ChangedReadSet(ctx context.Context, workspaceID, sessionWorkstreamID string, ...) ([]ReadSetEntry, error)
- func (s *Store) ClaimInjectionDeliveries(ctx context.Context, sessionKey string, items []InjectionItem, ...) ([]InjectionItem, error)
- func (s *Store) CleanupAcknowledged(ctx context.Context, before time.Time) (int64, error)
- func (s *Store) ClearAgentObservation(ctx context.Context, workspaceID, vendor string) error
- func (s *Store) ClearAllFocus(ctx context.Context) (int, error)
- func (s *Store) ClearFocus(ctx context.Context, sessionKey string) error
- func (s *Store) Close() error
- func (s *Store) Cursor(ctx context.Context, workspaceID string) (int64, error)
- func (s *Store) DeleteWorkspace(ctx context.Context, workspaceID string) error
- func (s *Store) EnqueueEvent(ctx context.Context, workspaceID, eventID, source, kind string, payload any) error
- func (s *Store) FingerprintHash(ctx context.Context, workspaceID, path string) (string, bool, error)
- func (s *Store) FocusedUntil(ctx context.Context, sessionKey string, now time.Time) (time.Time, bool, error)
- func (s *Store) Pending(ctx context.Context) ([]QueueEvent, error)
- func (s *Store) PublishLifecycle(ctx context.Context, publication LifecyclePublication) (revision int64, duplicate bool, err error)
- func (s *Store) PublishManifest(ctx context.Context, publication ManifestPublication) (int64, error)
- func (s *Store) Quarantine(ctx context.Context, id string) error
- func (s *Store) QuarantinedCount(ctx context.Context) (int, error)
- func (s *Store) RebindWorkspace(ctx context.Context, workspaceID, deviceID, backendID string) error
- func (s *Store) RecentAgentSessions(ctx context.Context, workspaceID string, activeAfter time.Time) ([]AgentSession, error)
- func (s *Store) RecordAgentObservation(ctx context.Context, workspaceID, vendor string, observedAt time.Time) error
- func (s *Store) RecordAgentSession(ctx context.Context, session AgentSession) error
- func (s *Store) SetFocus(ctx context.Context, sessionKey string, now time.Time, duration time.Duration) (time.Time, error)
- func (s *Store) SetPaused(ctx context.Context, id string, p bool) error
- func (s *Store) SetProjectPaused(ctx context.Context, projectID string, p bool) (int, error)
- func (s *Store) UndeliveredInjectionItems(ctx context.Context, sessionKey string, items []InjectionItem) ([]InjectionItem, error)
- func (s *Store) UpsertWorkspace(ctx context.Context, w Workspace) error
- func (s *Store) Workspaces(ctx context.Context) ([]Workspace, error)
- type Workspace
Constants ¶
const ( ReadFidelitySelfDeclared = "self_declared" ReadFidelityVendorInferred = "vendor_inferred" ReadFidelityObserved = "observed" )
Read-set fidelities in ascending order of strength (ADR-052).
const ( DefaultFocus = time.Hour MaxFocus = 8 * time.Hour )
Focus suppresses coordination *into* one agent session until a deadline.
It is deliberately the opposite direction from pause. Pausing stops this device's activity reaching the Project, which makes the member invisible and therefore makes their teammates less safe: nobody can avoid work they cannot see. Focus stops the Project reaching one agent's turns and changes nothing about what this device publishes, so the member who wants quiet carries their own risk instead of transferring it to everyone else.
It is local state and never crosses the wire. A teammate does not need to know, because nothing about what they can see has changed.
Every focus expires. A mute that outlives the reason for it is worse than no mute at all in a tool whose value is being told things, so a deadline is required rather than optional and the caller cannot set one beyond MaxFocus.
Variables ¶
This section is empty.
Functions ¶
func Batch ¶
func Batch(events []QueueEvent) ([]byte, error)
func ReadFidelityRank ¶
ReadFidelityRank orders the sources so the strongest evidence for a path wins. An unrecognized value ranks below every known source rather than displacing one.
Types ¶
type AgentSession ¶
type Focus ¶
Focus is an agent session that has asked not to be interrupted, and the moment that request lapses.
type InjectionItem ¶
type LifecycleEvent ¶
type LifecyclePublication ¶
type LifecyclePublication struct {
WorkspaceID, Method, IdempotencyKey, Source, Kind string
Payload any
Additional []LifecycleEvent
ExpectedIntentRevision *int64
IncrementIntentRevision bool
}
type ManifestPublication ¶
type QueueEvent ¶
type ReadSetEntry ¶
type ReadSetEntry struct {
Path string `json:"path"`
FileContractHashAtRead string `json:"fileContractHashAtRead"`
ObservedAt string `json:"observedAt"`
// Fidelity records how this observation was obtained (ADR-052). A read set
// mixes sources of different strength, and a stale-assumption finding
// raised from evidence that is not observed is not deterministic.
Fidelity string `json:"fidelity"`
}
ReadSetEntry is one observation of a fingerprintable path by one agent session, carrying the file contract hash current when the session read it.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) ActiveAgentSessions ¶
func (s *Store) ActiveAgentSessions(ctx context.Context, workspaceID, vendor, cwd string, activeAfter time.Time) ([]AgentSession, error)
ActiveAgentSessions returns only sessions with recent lifecycle evidence. The same thirty-minute window ends silent hosted agent sessions; using it here prevents an abandoned local session from becoming a permanent false ambiguity while still preferring unidentified over a stale guess.
func (*Store) ActiveFocus ¶
ActiveFocus lists the sessions still focused, dropping rows that have lapsed.
func (*Store) ActiveManifest ¶
func (*Store) AgentObserved ¶
func (*Store) ChangedFingerprints ¶
func (s *Store) ChangedFingerprints(ctx context.Context, workspaceID string, observed map[string]string, at time.Time) ([]string, error)
ChangedFingerprints records the observed file contract hash of every path in observed and returns, sorted, only the paths whose hash is new or different. Publishing is therefore proportional to contract drift rather than to how often the manifest pipeline runs.
func (*Store) ChangedReadSet ¶
func (s *Store) ChangedReadSet(ctx context.Context, workspaceID, sessionWorkstreamID string, entries []ReadSetEntry) ([]ReadSetEntry, error)
ChangedReadSet keeps exactly one entry per (session, path): re-observing a path replaces its hash and time rather than appending. It returns only the entries worth publishing, which are the ones that are new or whose hash moved.
func (*Store) ClaimInjectionDeliveries ¶
func (s *Store) ClaimInjectionDeliveries(ctx context.Context, sessionKey string, items []InjectionItem, deliveredAt time.Time) ([]InjectionItem, error)
ClaimInjectionDeliveries atomically returns and records only item revisions this local agent session has not received before. Claiming before the hook response prevents concurrent hook invocations from injecting one revision twice; a newer revision remains independently eligible.
func (*Store) CleanupAcknowledged ¶
func (*Store) ClearAgentObservation ¶
func (*Store) ClearAllFocus ¶
ClearAllFocus lets every quiet session start hearing again. It exists so a focus the member has forgotten is recoverable from wherever they notice it, without first having to remember which session it was on.
func (*Store) DeleteWorkspace ¶ added in v0.1.2
DeleteWorkspace forgets one registered repository and everything recorded against it.
Every table below is keyed by workspace id, and leaving any of them behind is what "I deleted the Project and it came back" is made of: a stale row in `workspaces` republishes the repository on the next boot, and stale rows in `event_queue` keep trying to publish to a Project that no longer exists. The queue is dropped rather than drained on purpose - the destination is gone, so there is nothing those events could still be delivered to.
Rows keyed by session rather than workspace (injection_deliveries, session_focus) are left alone: a session key is not resolvable to a workspace here, and both tables are short-lived local state that expires on its own.
func (*Store) EnqueueEvent ¶
func (*Store) FingerprintHash ¶
func (s *Store) FingerprintHash(ctx context.Context, workspaceID, path string) (string, bool, error)
FingerprintHash returns the last recorded file contract hash for a path. It is the cache consulted when a read is observed for a file that cannot be read from disk at that moment.
func (*Store) FocusedUntil ¶
func (s *Store) FocusedUntil(ctx context.Context, sessionKey string, now time.Time) (time.Time, bool, error)
FocusedUntil reports whether one session is currently focused. An expired row answers false without needing a sweep to have run first, so a deadline that has passed can never keep suppressing corrections.
func (*Store) PublishLifecycle ¶
func (*Store) PublishManifest ¶
func (*Store) Quarantine ¶
Quarantine removes an event from the publish path without recording a delivery. The row is kept: a quarantined event is evidence of a rejected binding, and deleting it would silently destroy the only record that work was observed and refused.
func (*Store) RebindWorkspace ¶ added in v0.1.2
RebindWorkspace points one registered repository at a different backend and makes it introduce itself there.
A workspace is known to a backend only because a "workspace.registered" event reached it, and that event is sent once - `registration_enqueued` is the flag that remembers it was. A repository moving to a new backend has therefore never been seen by it, and every event other than the registration is refused with workspace_not_registered until one arrives. So the flag is cleared here, and the caller's next UpsertWorkspace queues a fresh registration.
The queue is emptied rather than carried over. Unsent events are addressed to a backend this repository is leaving, and sent ones are history the new backend has no way to place: the Project's coordination record starts from the state the next scan reports. Dropping the cursor with them is what lets the sequence be acknowledged from scratch by a backend that has never seen this device.
func (*Store) RecentAgentSessions ¶
func (s *Store) RecentAgentSessions(ctx context.Context, workspaceID string, activeAfter time.Time) ([]AgentSession, error)
RecentAgentSessions returns the locally observed, non-finished agent sessions for one workspace. It powers read-only Project status surfaces and never reads transcripts or session content.
func (*Store) RecordAgentObservation ¶
func (*Store) RecordAgentSession ¶
func (s *Store) RecordAgentSession(ctx context.Context, session AgentSession) error
RecordAgentSession keeps the local lifecycle evidence needed to bind an MCP call to the same per-session workstream as its hooks. The vendor's raw session identifier is deliberately absent: the derived workstream identity is sufficient here and remains local.
func (*Store) SetProjectPaused ¶
SetProjectPaused pauses or resumes every workspace registered to one Project and reports how many it changed.
Pause was reachable only per workspace or, from the menu bar, for every workspace on the machine. Neither matches how anyone reads the product: a member looking at one Project wants to stop sharing that Project, not their work on an unrelated repository. A Project with no registered workspace on this device is not an error - there is simply nothing here to pause - so the count is the answer rather than a failure.
func (*Store) UndeliveredInjectionItems ¶
func (s *Store) UndeliveredInjectionItems(ctx context.Context, sessionKey string, items []InjectionItem) ([]InjectionItem, error)
UndeliveredInjectionItems returns item revisions absent from the local session delivery set. ClaimInjectionDeliveries remains the atomic arbiter if concurrent hook invocations race after this read.
func (*Store) UpsertWorkspace ¶
type Workspace ¶
type Workspace struct {
ID, ProjectID, WorkstreamID, MemberID, DeviceID, SessionID string
Root, Baseline, Fingerprint string
// BackendID names the backend this workspace's Project publishes to
// (ADR-074). It is carried here so a row read back from SQLite says which
// server it belongs to without re-reading the configuration.
BackendID string
Paused bool
Revision int64
}