Documentation
¶
Overview ¶
Package engine coordinates shared memory writes across processes. Facts stay authoritative Markdown files; private state lives in a reserved .engine directory beside each scope. Every mutation is one locked transaction.
Index ¶
- Variables
- type AppendRequest
- type AppendResult
- type Config
- type CorrectRequest
- type Cursor
- type DeleteRequest
- type Engine
- func (e *Engine) AppendFact(req AppendRequest) (AppendResult, error)
- func (e *Engine) CorrectFact(req CorrectRequest) (FactResult, error)
- func (e *Engine) DeleteFact(req DeleteRequest) error
- func (e *Engine) Read(scope Scope, name string) (ReadResult, error)
- func (e *Engine) ReadRevision(name string) (Revision, error)
- func (e *Engine) ReadRevisionForScope(scope Scope, name string) (Revision, error)
- func (e *Engine) Recover() error
- func (e *Engine) SaveCursor(cursor Cursor) error
- type FactResult
- type ReadResult
- type Revision
- type Scope
Constants ¶
This section is empty.
Variables ¶
var ( ErrReadRequired = errors.New("read_required") ErrRevisionConflict = errors.New("revision_conflict") ErrBusy = errors.New("busy") ErrConflict = errors.New("conflict") ErrNotFound = errors.New("fact_not_found") ErrReasonRequired = errors.New("reason_required") ErrStaleRequest = errors.New("stale_request") )
Stable engine failures. Callers match them with errors.Is.
Functions ¶
This section is empty.
Types ¶
type AppendRequest ¶
type AppendRequest struct {
RequestID string
Name string
Description string
Body string
Reason string
Scope Scope
// Fact carries full fact metadata (type, scene, links, path, origin) for
// adapters that need more than the default project fact. When set, the
// engine writes this fact after name resolution instead of building a
// default one. Callers that omit it keep the original behavior.
Fact *memory.Fact
}
AppendRequest adds one fact. RequestID makes the append retry-safe.
type AppendResult ¶
type AppendResult struct {
RequestID string `json:"requestID"`
Name string `json:"name"`
Revision Revision `json:"revision"`
}
AppendResult is the durable outcome of an append.
type Config ¶
type Config struct {
Store *memory.Store
ProjectDir string
UserDir string
LockTimeout time.Duration
}
Config binds an engine to one project store and one user store.
type CorrectRequest ¶
type CorrectRequest struct {
RequestID string
Name string
Expected Revision
Description string
Body string
Scope Scope
}
CorrectRequest replaces a fact body after a preceding read. For user scope, Body is the full desired user memory because user.md is one record.
type Cursor ¶
type Cursor struct {
HarnessID string `json:"harnessID"`
SessionID string `json:"sessionID"`
Position int64 `json:"position"`
Phase string `json:"phase"`
}
Cursor is one session's durable position. Harness and session identity keep concurrent sessions from sharing a marker.
type DeleteRequest ¶
DeleteRequest removes a fact after a preceding read.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine owns transactions and scope locks over a memory store.
func Open ¶
Open binds an engine to the configured directories. Missing values fall back to the store's own paths and a five-second lock timeout.
func (*Engine) AppendFact ¶
func (e *Engine) AppendFact(req AppendRequest) (AppendResult, error)
AppendFact adds one fact. A retry with the same RequestID returns the recorded result without writing again.
func (*Engine) CorrectFact ¶
func (e *Engine) CorrectFact(req CorrectRequest) (FactResult, error)
CorrectFact replaces a fact body. An absent revision returns read_required; a revision that is not current returns revision_conflict. Neither changes stored content.
func (*Engine) DeleteFact ¶
func (e *Engine) DeleteFact(req DeleteRequest) error
DeleteFact removes a fact after a preceding read. It shares the revision preconditions of a correction.
func (*Engine) Read ¶
func (e *Engine) Read(scope Scope, name string) (ReadResult, error)
Read recovers pending work, then reads one record and its revision under the same lock. Recovery runs before the read, so the returned bytes and revision both describe the recovered state.
func (*Engine) ReadRevision ¶
ReadRevision returns the revision of the named project fact.
func (*Engine) ReadRevisionForScope ¶
ReadRevisionForScope returns the revision of one record. User scope has one user.md record, so name is ignored. Every read recovers pending work first.
func (*Engine) Recover ¶
Recover settles unfinished transactions in both scopes. User scope is locked first because operations that need both scopes keep that order.
func (*Engine) SaveCursor ¶
SaveCursor writes one session's cursor record. Session records are separate files, so they need no shared lock.
type FactResult ¶
type FactResult struct {
RequestID string `json:"requestID"`
Name string `json:"name"`
Revision Revision `json:"revision"`
}
FactResult is the durable outcome of a correction.
type ReadResult ¶
ReadResult is one record's bytes and the revision of those same bytes.