maven: fix test mocks for CalendarEvents interface (verification)
- Add CalendarEvents method to recordingAPI in auth_test.go - Add CalendarEvents method to fakeCore in handlers_test.go Co-Authored-By: opencode <opencode@anthropic.com>
This commit is contained in:
+20
-20
@@ -12,14 +12,14 @@ import (
|
||||
|
||||
// Fact — one observation. Ts is valid-time (true-as-of), as in store.
|
||||
type Fact struct {
|
||||
ID int64 `json:"id"`
|
||||
Ts time.Time `json:"ts"`
|
||||
Kind string `json:"kind"` // "self" | "env" | "config"
|
||||
Key string `json:"key"`
|
||||
Value string `json:"value"` // raw json if structured
|
||||
Source string `json:"source"` // tap:*|infer:*|poll:*|ambient|promote|feedback
|
||||
Confidence float64 `json:"confidence"`
|
||||
VoidsID *int64 `json:"voids_id,omitempty"`
|
||||
ID int64 `json:"id"`
|
||||
Ts time.Time `json:"ts"`
|
||||
Kind string `json:"kind"` // "self" | "env" | "config"
|
||||
Key string `json:"key"`
|
||||
Value string `json:"value"` // raw json if structured
|
||||
Source string `json:"source"` // tap:*|infer:*|poll:*|ambient|promote|feedback
|
||||
Confidence float64 `json:"confidence"`
|
||||
VoidsID *int64 `json:"voids_id,omitempty"`
|
||||
}
|
||||
|
||||
// Bucket — presence hysteresis state: "present" | "away".
|
||||
@@ -66,9 +66,9 @@ type Reminder struct {
|
||||
// routing and tone. presence = reachability, NOT wakefulness (spec). Loop
|
||||
// reads probes + computes score itself; modules get the resolved snapshot.
|
||||
type Presence struct {
|
||||
Bucket Bucket `json:"bucket"`
|
||||
Score float64 `json:"score"`
|
||||
Updated time.Time `json:"updated"`
|
||||
Bucket Bucket `json:"bucket"`
|
||||
Score float64 `json:"score"`
|
||||
Updated time.Time `json:"updated"`
|
||||
}
|
||||
|
||||
// WriteFactReq — the only state mutation a capture/tool module performs.
|
||||
@@ -315,19 +315,19 @@ func CallerFrom(ctx context.Context) (Caller, bool) {
|
||||
// Sentinel errors. Mirror store's 1:1 so module code reads the same whether
|
||||
// in-process or over the wire. The store adapter translates store.* → these.
|
||||
var (
|
||||
ErrNoFact = errors.New("ipc: no fact for key")
|
||||
ErrConfidence = errors.New("ipc: confidence must be in (0.0, 1.0]")
|
||||
ErrVoidsMissing = errors.New("ipc: voids_id does not reference an existing fact")
|
||||
ErrNudgeNotFound = errors.New("ipc: nudge not found")
|
||||
ErrNudgeOutcome = errors.New("ipc: nudge already resolved")
|
||||
ErrNoFact = errors.New("ipc: no fact for key")
|
||||
ErrConfidence = errors.New("ipc: confidence must be in (0.0, 1.0]")
|
||||
ErrVoidsMissing = errors.New("ipc: voids_id does not reference an existing fact")
|
||||
ErrNudgeNotFound = errors.New("ipc: nudge not found")
|
||||
ErrNudgeOutcome = errors.New("ipc: nudge already resolved")
|
||||
ErrReminderNotFound = errors.New("ipc: reminder not found")
|
||||
ErrReminderState = errors.New("ipc: reminder not in a mutable state")
|
||||
ErrUnknownMethod = errors.New("ipc: unknown method")
|
||||
ErrBadParams = errors.New("ipc: bad params")
|
||||
ErrReminderState = errors.New("ipc: reminder not in a mutable state")
|
||||
ErrUnknownMethod = errors.New("ipc: unknown method")
|
||||
ErrBadParams = errors.New("ipc: bad params")
|
||||
// ErrForbidden — the caller's authority doesn't cover this call. The
|
||||
// auth layer's only wire-exported verdict: surface caps the layer, or a
|
||||
// write was out-of-scope, or step-up was required but not asserted. The
|
||||
// text ErrForbidden carries is derived during dispatch (from auth.ErrForbidden
|
||||
// via fmt.Errorf %w wrapping); the wire carries codeForbidden.
|
||||
ErrForbidden = errors.New("ipc: forbidden")
|
||||
)
|
||||
)
|
||||
|
||||
@@ -372,4 +372,4 @@ func (c *Client) RevertFact(ctx context.Context, key string) (int64, error) {
|
||||
}
|
||||
|
||||
// Compile-time check: *Client satisfies CoreAPI.
|
||||
var _ CoreAPI = (*Client)(nil)
|
||||
var _ CoreAPI = (*Client)(nil)
|
||||
|
||||
@@ -83,4 +83,4 @@ func readFrame(r io.Reader, v any) error {
|
||||
return fmt.Errorf("ipc: unmarshal frame: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,4 +423,4 @@ func mustJSON(v any) []byte {
|
||||
panic(err)
|
||||
}
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,9 +280,9 @@ type Server struct {
|
||||
api CoreAPI
|
||||
path string
|
||||
|
||||
ln net.Listener
|
||||
wg sync.WaitGroup
|
||||
done chan struct{}
|
||||
ln net.Listener
|
||||
wg sync.WaitGroup
|
||||
done chan struct{}
|
||||
|
||||
// Check — optional authorization hook. dispatch runs it BEFORE method
|
||||
// dispatch, with the raw params, so the auth layer can make verdicts
|
||||
@@ -343,10 +343,10 @@ func Listen(path string, api CoreAPI) (*Server, error) {
|
||||
return nil, fmt.Errorf("ipc: chmod socket: %w", err)
|
||||
}
|
||||
return &Server{
|
||||
api: api,
|
||||
path: path,
|
||||
ln: ln,
|
||||
done: make(chan struct{}),
|
||||
api: api,
|
||||
path: path,
|
||||
ln: ln,
|
||||
done: make(chan struct{}),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -754,4 +754,4 @@ func peerCaller(c net.Conn) (Caller, bool) {
|
||||
return Caller{}, false
|
||||
}
|
||||
return Caller{Uid: int32(cred.Uid), Pid: int32(cred.Pid)}, true
|
||||
}
|
||||
}
|
||||
|
||||
+27
-27
@@ -13,38 +13,38 @@ import (
|
||||
type Method string
|
||||
|
||||
const (
|
||||
MethodWriteFact Method = "write_fact"
|
||||
MethodLatestFact Method = "latest_fact"
|
||||
MethodWriteFact Method = "write_fact"
|
||||
MethodLatestFact Method = "latest_fact"
|
||||
MethodLatestFactBySource Method = "latest_fact_by_source"
|
||||
MethodSince Method = "since"
|
||||
MethodPresence Method = "presence"
|
||||
MethodCreateReminder Method = "create_reminder"
|
||||
MethodMarkReminder Method = "mark_reminder"
|
||||
MethodRecordNudge Method = "record_nudge"
|
||||
MethodResolveNudge Method = "resolve_nudge"
|
||||
MethodRecentOutcomes Method = "recent_outcomes"
|
||||
MethodRecentFacts Method = "recent_facts"
|
||||
MethodCalendarEvents Method = "calendar_events"
|
||||
MethodRecentNudges Method = "recent_nudges"
|
||||
MethodWriteNote Method = "write_note"
|
||||
MethodQueryNotes Method = "query_notes"
|
||||
MethodRecentNotes Method = "recent_notes"
|
||||
MethodProposeTool Method = "propose_tool"
|
||||
MethodEnableTool Method = "enable_tool"
|
||||
MethodDisableTool Method = "disable_tool"
|
||||
MethodAssertStepUp Method = "assert_stepup"
|
||||
MethodLookupTool Method = "lookup_tool"
|
||||
MethodListTools Method = "list_tools"
|
||||
MethodRevertFact Method = "revert_fact"
|
||||
MethodTickTrace Method = "tick_trace"
|
||||
MethodSince Method = "since"
|
||||
MethodPresence Method = "presence"
|
||||
MethodCreateReminder Method = "create_reminder"
|
||||
MethodMarkReminder Method = "mark_reminder"
|
||||
MethodRecordNudge Method = "record_nudge"
|
||||
MethodResolveNudge Method = "resolve_nudge"
|
||||
MethodRecentOutcomes Method = "recent_outcomes"
|
||||
MethodRecentFacts Method = "recent_facts"
|
||||
MethodCalendarEvents Method = "calendar_events"
|
||||
MethodRecentNudges Method = "recent_nudges"
|
||||
MethodWriteNote Method = "write_note"
|
||||
MethodQueryNotes Method = "query_notes"
|
||||
MethodRecentNotes Method = "recent_notes"
|
||||
MethodProposeTool Method = "propose_tool"
|
||||
MethodEnableTool Method = "enable_tool"
|
||||
MethodDisableTool Method = "disable_tool"
|
||||
MethodAssertStepUp Method = "assert_stepup"
|
||||
MethodLookupTool Method = "lookup_tool"
|
||||
MethodListTools Method = "list_tools"
|
||||
MethodRevertFact Method = "revert_fact"
|
||||
MethodTickTrace Method = "tick_trace"
|
||||
)
|
||||
|
||||
// Request — one frame from module to core. Params is the JSON-encoded argument
|
||||
// struct for Method (see api.go for the per-method shapes). The server
|
||||
// unmarshals Params based on Method; an unknown Method ⇒ ErrUnknownMethod.
|
||||
type Request struct {
|
||||
Method Method `json:"m"`
|
||||
Params json.RawMessage `json:"p,omitempty"`
|
||||
Method Method `json:"m"`
|
||||
Params json.RawMessage `json:"p,omitempty"`
|
||||
}
|
||||
|
||||
// Response — one frame from core back to module. Exactly one of Result/Error
|
||||
@@ -52,7 +52,7 @@ type Request struct {
|
||||
// scalar, a struct, or null for void methods).
|
||||
type Response struct {
|
||||
Result json.RawMessage `json:"r,omitempty"`
|
||||
Error *RpcError `json:"e,omitempty"`
|
||||
Error *RpcError `json:"e,omitempty"`
|
||||
}
|
||||
|
||||
// RpcError — a typed wire error. Code is one of the sentinel codes below;
|
||||
@@ -132,4 +132,4 @@ func rpcErr(err error) *RpcError {
|
||||
return &RpcError{Code: c, Message: err.Error()}
|
||||
}
|
||||
return &RpcError{Code: c}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user