Documentation
¶
Overview ¶
Package detective adapts Core's shared Checks and Cases to local storage.
Index ¶
- Variables
- func AdmittedQueryRevision(ctx context.Context, queryID string) (string, bool)
- func NativeAcceptedQuery(ctx context.Context, id string) (sessioncontext.DetectiveAcceptedQueryPin, bool)
- func WithWatchAcceptedQueries(ctx context.Context, ...) context.Context
- type AIPage
- type ActionRequest
- type ActionResponse
- type AuditEvent
- type AuditStore
- type Binding
- type Capabilities
- type Case
- type CaseEvent
- type CaseEventsPage
- type Check
- type CheckRun
- type EvidenceRef
- type ExecutionMetadata
- type Finding
- type IncidentOperation
- type Input
- type InputValue
- type LocalAIStore
- func (s LocalAIStore) AIReceipt(ctx context.Context, id string) (ai.Receipt, bool, error)
- func (s LocalAIStore) AuthorizeSources(ctx context.Context, scope ai.Scope, sources []ai.SourceEvidence) error
- func (s LocalAIStore) BeginAIGeneration(ctx context.Context, id string, binding core.OperationBinding) (ai.Response, bool, error)
- func (s LocalAIStore) CompleteAIGeneration(ctx context.Context, id string, binding core.OperationBinding, ...) error
- func (s LocalAIStore) ConfirmCase(ctx context.Context, command ai.Command) (ai.Receipt, error)
- func (s LocalAIStore) ConfirmCatalog(ctx context.Context, command ai.Command) (ai.Receipt, error)
- func (s LocalAIStore) ConfirmQuery(ctx context.Context, command ai.Command) (ai.Receipt, error)
- func (s LocalAIStore) ConfirmRun(ctx context.Context, command ai.Command, runner QueryRunner, ...) (ai.Receipt, error)
- func (s LocalAIStore) Get(ctx context.Context, id string) (ai.Proposal, error)
- func (s LocalAIStore) Page(ctx context.Context, after string) (AIPage, error)
- func (s LocalAIStore) Save(ctx context.Context, proposal ai.Proposal) error
- func (s LocalAIStore) SavePaste(ctx context.Context, text string) (ai.Source, error)
- type LocalStore
- func (s *LocalStore) ActionBinding(req ActionRequest, actor string) (core.OperationBinding, error)
- func (s *LocalStore) ActionLinkStatus(ctx context.Context, id, actor string, req ActionRequest) (string, error)
- func (s *LocalStore) Append(ctx context.Context, event AuditEvent) error
- func (s *LocalStore) AppendCaseEvent(ctx context.Context, id string, event CaseEvent, actor string) (Case, error)
- func (s *LocalStore) ApplyScenario(ctx context.Context, caseID, scenarioID, actor string) (Case, error)
- func (s *LocalStore) BeginIncidentOperation(ctx context.Context, id string, binding core.OperationBinding, caseID string, ...) (IncidentOperation, bool, error)
- func (s *LocalStore) CaptureNativeInput(ctx context.Context, req NativeCaptureRequest, ...) (NativeCapture, error)
- func (s *LocalStore) CaseEventsPage(ctx context.Context, id string, before int) (CaseEventsPage, error)
- func (s *LocalStore) CompleteIncidentOperation(ctx context.Context, id string, binding core.OperationBinding, ...) (Case, error)
- func (s *LocalStore) ConfigureNativeFence(check func(context.Context, sessioncontext.DetectiveFence) error) error
- func (s *LocalStore) DeliverNativeHandoff(ctx context.Context, id sessioncontext.DetectiveIdentity, ...) (string, error)
- func (s *LocalStore) ExecuteAction(ctx context.Context, operationID, actor string, req ActionRequest, ...) (ActionResponse, error)
- func (s *LocalStore) ExecuteNativePin(ctx context.Context, fence sessioncontext.DetectiveFence, ...) (ActionResponse, error)
- func (s *LocalStore) ExecuteWatchAction(ctx context.Context, operationID, actor string, req ActionRequest, ...) (ActionResponse, string, error)
- func (s *LocalStore) FinalizeNativeProduced(ctx context.Context, id sessioncontext.DetectiveIdentity) (ActionResponse, error)
- func (s *LocalStore) GetCase(ctx context.Context, id string) (Case, error)
- func (s *LocalStore) GetCheck(ctx context.Context, id string) (Check, error)
- func (s *LocalStore) GetPublishedValidator(_ context.Context, id string) (PublishedValidator, error)
- func (s *LocalStore) GetQueryValidators(_ context.Context, id string) (QueryValidators, bool, error)
- func (s *LocalStore) KnowledgeAction(ctx context.Context, request knowledge.Action, actor string) (knowledge.Response, error)
- func (s *LocalStore) KnowledgePage(ctx context.Context, after string) (knowledge.Page, error)
- func (s *LocalStore) MarkSessionReferenceUnavailable(ctx context.Context, id sessioncontext.DetectiveIdentity) (bool, error)
- func (s *LocalStore) NativeObservation(ctx context.Context, id sessioncontext.DetectiveIdentity) (sessioncontext.DetectiveObservation, error)
- func (s *LocalStore) QueryExists(_ context.Context, id string) (bool, error)
- func (s *LocalStore) RecordIncidentCreated(ctx context.Context, id string, binding core.OperationBinding, ref string) error
- func (s *LocalStore) RecordScenarioQueryStep(ctx context.Context, caseID, applicationID, stepID string, ...) (Case, error)
- func (s *LocalStore) RecordScenarioStep(ctx context.Context, ...) (Case, error)
- func (s *LocalStore) Run(ctx context.Context, checkID, environment, caseID, actor string, ...) (CheckRun, error)
- func (s *LocalStore) RunQueryValidators(ctx context.Context, queryID, environment, caseID, actor string, ...) (CheckRun, error)
- func (s *LocalStore) RunQueryValidatorsForResult(ctx context.Context, queryID, environment, caseID, actor string, ...) (CheckRun, error)
- func (s *LocalStore) SaveCase(ctx context.Context, item Case, actor, action string) (Case, error)
- func (s *LocalStore) SaveCheck(ctx context.Context, check Check, actor string) (Check, error)
- func (s *LocalStore) SaveQueryValidators(ctx context.Context, item QueryValidators, actor string) (QueryValidators, error)
- func (s *LocalStore) SaveRun(ctx context.Context, run CheckRun) error
- func (s *LocalStore) SaveScenario(ctx context.Context, scenario Scenario, actor string) (Scenario, error)
- func (s *LocalStore) SaveValidator(ctx context.Context, item PublishedValidator, actor string) (PublishedValidator, error)
- func (s *LocalStore) State(ctx context.Context) (State, error)
- func (s *LocalStore) StatePage(ctx context.Context, cursor string) (State, error)
- type NativeCapture
- type NativeCaptureRequest
- type NativeQuerySnapshot
- type PublishedValidator
- type QueryFailure
- type QueryRevisionLookup
- type QueryRunner
- type QueryValidators
- type Scenario
- type ScenarioApplication
- type ScenarioQueryProof
- type ScenarioStep
- type ScenarioStepReceipt
- type State
- type Step
- type StepResult
- type ValidationResult
- type Validator
- type Value
- type ValueRange
Constants ¶
This section is empty.
Variables ¶
var ErrCapacity = core.ErrCapacity
var ErrConflict = core.ErrConflict
var ErrInvalid = core.ErrInvalid
var ErrNotFound = core.ErrNotFound
var ErrOutcomeUncertain = core.ErrOutcomeUncertain
Functions ¶
func AdmittedQueryRevision ¶
AdmittedQueryRevision returns the revision captured with the sealed catalog.
func NativeAcceptedQuery ¶ added in v0.90.0
func NativeAcceptedQuery(ctx context.Context, id string) (sessioncontext.DetectiveAcceptedQueryPin, bool)
NativeAcceptedQuery returns an owned exact accepted saved-query snapshot to the ordinary query executor, which must still enforce its current policy.
func WithWatchAcceptedQueries ¶ added in v0.117.0
func WithWatchAcceptedQueries(ctx context.Context, queries map[string]sessioncontext.DetectiveAcceptedQueryPin) context.Context
WithWatchAcceptedQueries is a trusted daemon adapter for an already verified immutable cloud bundle. The ordinary query runner still checks local source admission; this context never grants access to a source or local Check asset.
Types ¶
type ActionRequest ¶
type ActionRequest = core.ActionRequest
type ActionResponse ¶
type ActionResponse = core.ActionResponse
type AuditEvent ¶
type AuditEvent = core.AuditEvent
type AuditStore ¶
type AuditStore interface {
Append(context.Context, AuditEvent) error
}
type Capabilities ¶
type Capabilities = core.Capabilities
type CaseEventsPage ¶
type CaseEventsPage = core.CaseEventsPage
type EvidenceRef ¶
type EvidenceRef = core.EvidenceRef
type ExecutionMetadata ¶
type ExecutionMetadata = core.ExecutionMetadata
type IncidentOperation ¶
type IncidentOperation struct {
Receipt core.OperationReceipt `json:"receipt"`
// CreatedRef records the external create before attempting the Case CAS. A
// stale Case version can then be recovered with a separate authorized link.
CreatedRef string `json:"createdRef,omitempty"`
Done bool `json:"done"`
Case *Case `json:"case,omitempty"`
Context map[string]InputValue `json:"context,omitempty"`
Audit *AuditEvent `json:"audit,omitempty"`
Before int64 `json:"before"`
}
IncidentOperation is a private, payload-bound local admission record. It is written before touching Incidentius so an interrupted cross-store create can resume with the same mutation ID and cannot be replayed with new content.
type InputValue ¶
type InputValue = core.InputValue
type LocalAIStore ¶
type LocalAIStore struct {
Store *LocalStore
Scope ai.Scope
// BasisVerifier rebuilds the authorized snapshot from a State captured
// under the local mutation lock, immediately before durable admission.
BasisVerifier func(context.Context, ai.Snapshot, State) error
}
LocalAIStore binds private proposals and paste evidence to the authenticated local actor. The model receives source text, while the shared proposal keeps only verified citation spans and source digests.
func (LocalAIStore) AIReceipt ¶
AIReceipt returns a previously accepted confirmation and finishes an interrupted local Case/audit write before revealing the replay receipt.
func (LocalAIStore) AuthorizeSources ¶
func (s LocalAIStore) AuthorizeSources(ctx context.Context, scope ai.Scope, sources []ai.SourceEvidence) error
func (LocalAIStore) BeginAIGeneration ¶
func (s LocalAIStore) BeginAIGeneration(ctx context.Context, id string, binding core.OperationBinding) (ai.Response, bool, error)
BeginAIGeneration durably accepts an LLM call before network dispatch. An interrupted call is reported as uncertain; it is never silently repeated under the same operation ID.
func (LocalAIStore) CompleteAIGeneration ¶
func (s LocalAIStore) CompleteAIGeneration(ctx context.Context, id string, binding core.OperationBinding, result ai.Response) error
func (LocalAIStore) ConfirmCase ¶
ConfirmCase applies only reviewed editable fields to the current Case. The prepared Core transition, metadata audit and scoped AI receipt are journaled before the Case file is replaced, making exact retries resumable.
func (LocalAIStore) ConfirmCatalog ¶
ConfirmCatalog journals the already-reviewed shared Core draft, the exact previous definition and an audit intent before replacing a project file. A crash between any two writes can be reconciled by the same operation ID.
func (LocalAIStore) ConfirmQuery ¶
func (LocalAIStore) ConfirmRun ¶
func (s LocalAIStore) ConfirmRun(ctx context.Context, command ai.Command, runner QueryRunner, metadata ExecutionMetadata, revisions ...QueryRevisionLookup) (ai.Receipt, error)
ConfirmRun accepts the confirmed intent before any query dispatch. An interrupted network call remains uncertain and is never silently repeated. Once evaluation returns, its exact result is journaled before run/evidence and Case writes, so those writes can be reconciled without re-execution.
type LocalStore ¶
type LocalStore struct {
// contains filtered or unexported fields
}
LocalStore keeps reviewable definitions in the project and sensitive case, run and audit material in a separate server-private directory.
func NewLocalStore ¶
func NewLocalStore(projectID, projectDir, privateBase string) (*LocalStore, error)
func NewLocalStoreWithAudit ¶
func NewLocalStoreWithAudit(projectID, projectDir, privateBase string, audit AuditStore) (*LocalStore, error)
NewLocalStoreWithAudit replaces the JSONL adapter for a trusted server configuration. The same mutation paths use the supplied adapter.
func (*LocalStore) ActionBinding ¶
func (s *LocalStore) ActionBinding(req ActionRequest, actor string) (core.OperationBinding, error)
ActionBinding omits the ephemeral securityContextId; the endpoint verifies the current session and actor before every call, including exact replay.
func (*LocalStore) ActionLinkStatus ¶
func (s *LocalStore) ActionLinkStatus(ctx context.Context, id, actor string, req ActionRequest) (string, error)
ActionLinkStatus reads only the caller's payload-bound completed operation.
func (*LocalStore) Append ¶
func (s *LocalStore) Append(ctx context.Context, event AuditEvent) error
func (*LocalStore) AppendCaseEvent ¶
func (*LocalStore) ApplyScenario ¶
func (*LocalStore) BeginIncidentOperation ¶
func (s *LocalStore) BeginIncidentOperation(ctx context.Context, id string, binding core.OperationBinding, caseID string, ifMatch int64, create bool) (IncidentOperation, bool, error)
func (*LocalStore) CaptureNativeInput ¶ added in v0.90.0
func (s *LocalStore) CaptureNativeInput(ctx context.Context, req NativeCaptureRequest, querySnapshot NativeQuerySnapshot) (NativeCapture, error)
CaptureNativeInput captures the existing native catalog and Case under native admission. Session Pin must run after this method releases admission, then execution uses only its sealed snapshot through the existing Core evaluator.
func (*LocalStore) CaseEventsPage ¶
func (s *LocalStore) CaseEventsPage(ctx context.Context, id string, before int) (CaseEventsPage, error)
CaseEventsPage returns up to 100 immutable timeline events, newest page first by cursor while preserving chronological order inside the page.
func (*LocalStore) CompleteIncidentOperation ¶
func (s *LocalStore) CompleteIncidentOperation(ctx context.Context, id string, binding core.OperationBinding, caseID, incidentRef, actor string, ifMatch int64, create *Case) (Case, error)
CompleteIncidentOperation applies the Core Case transition under the local private lock, then stores a replayable response. If a prior write succeeded but the final receipt did not, its accepted operation can resume safely.
func (*LocalStore) ConfigureNativeFence ¶ added in v0.90.0
func (s *LocalStore) ConfigureNativeFence(check func(context.Context, sessioncontext.DetectiveFence) error) error
ConfigureNativeFence is a trusted host boundary. The checker reads the session owner's durable fence while native admission is held; its repository View must not acquire admission again. Never expose this as client transport.
func (*LocalStore) DeliverNativeHandoff ¶ added in v0.90.0
func (s *LocalStore) DeliverNativeHandoff(ctx context.Context, id sessioncontext.DetectiveIdentity, handoff sessioncontext.EvidenceHandoff, reference apicontract.SessionInputReference, authorize func(context.Context, sessioncontext.DetectiveFence, sessioncontext.EvidenceHandoff) error) (string, error)
DeliverNativeHandoff records a metadata reference to separately owned Case evidence. It never reads source rows or mutates CaseRunLink. The host must reauthorize both resources; session references resolve unavailable after scrub.
func (*LocalStore) ExecuteAction ¶
func (s *LocalStore) ExecuteAction(ctx context.Context, operationID, actor string, req ActionRequest, runner QueryRunner, metadata ExecutionMetadata, result *apicontract.Result, proof *ScenarioQueryProof, revisions ...QueryRevisionLookup) (ActionResponse, error)
ExecuteAction owns all ordinary local Detective mutations and manual runs. The caller must authorize the current session, query and execution receipt before entering this method. A missing operation ID is a contract error.
func (*LocalStore) ExecuteNativePin ¶ added in v0.90.0
func (s *LocalStore) ExecuteNativePin(ctx context.Context, fence sessioncontext.DetectiveFence, pin sessioncontext.DetectiveInputPin, first bool, runner QueryRunner, metadata ExecutionMetadata) (ActionResponse, error)
ExecuteNativePin is called only with the sealed Core pin and first-claim discriminator. Recovery with first=false cannot manufacture native acceptance. The source runs outside admission; every finalization path rechecks the fence.
func (*LocalStore) ExecuteWatchAction ¶ added in v0.114.0
func (s *LocalStore) ExecuteWatchAction(ctx context.Context, operationID, actor string, req ActionRequest, version, fingerprint string, runner QueryRunner, metadata ExecutionMetadata, revisions QueryRevisionLookup) (ActionResponse, string, error)
ExecuteWatchAction reuses ordinary Check admission and execution, adding a version pin checked under the same lock that snapshots its transitive catalog. A changed Check requires an explicit Watch edit, which resets its baseline.
func (*LocalStore) FinalizeNativeProduced ¶ added in v0.90.0
func (s *LocalStore) FinalizeNativeProduced(ctx context.Context, id sessioncontext.DetectiveIdentity) (ActionResponse, error)
FinalizeNativeProduced is reconciliation only: it can finish a durable known result under the existing fence, but never claims work or invokes an evaluator.
func (*LocalStore) GetPublishedValidator ¶
func (s *LocalStore) GetPublishedValidator(_ context.Context, id string) (PublishedValidator, error)
func (*LocalStore) GetQueryValidators ¶
func (s *LocalStore) GetQueryValidators(_ context.Context, id string) (QueryValidators, bool, error)
func (*LocalStore) KnowledgeAction ¶
func (s *LocalStore) KnowledgeAction(ctx context.Context, request knowledge.Action, actor string) (knowledge.Response, error)
KnowledgeAction uses Core's portable transitions and reference validation. The local lock serializes the proposal, metadata-only audit and replay receipt. The accepted operation ID is bound to project, actor and payload.
func (*LocalStore) KnowledgePage ¶
KnowledgePage reads only this project's private proposals and returns a bounded, stable ID page. No proposal or handoff enters the project Git tree.
func (*LocalStore) MarkSessionReferenceUnavailable ¶ added in v0.90.0
func (s *LocalStore) MarkSessionReferenceUnavailable(ctx context.Context, id sessioncontext.DetectiveIdentity) (bool, error)
MarkSessionReferenceUnavailable is a trusted redaction continuation. The caller must prove the permanent Core session marker before invoking it. It alters only a session-owned metadata reference, preserving Case/run evidence.
func (*LocalStore) NativeObservation ¶ added in v0.90.0
func (s *LocalStore) NativeObservation(ctx context.Context, id sessioncontext.DetectiveIdentity) (sessioncontext.DetectiveObservation, error)
NativeObservation is authoritative journal lookup only. It never runs a source, claims work, or infers that absence makes dispatch safe.
func (*LocalStore) QueryExists ¶
func (*LocalStore) RecordIncidentCreated ¶
func (s *LocalStore) RecordIncidentCreated(ctx context.Context, id string, binding core.OperationBinding, ref string) error
func (*LocalStore) RecordScenarioQueryStep ¶
func (s *LocalStore) RecordScenarioQueryStep(ctx context.Context, caseID, applicationID, stepID string, proof core.ScenarioQueryProof, actor string) (Case, error)
RecordScenarioQueryStep attaches an authorized ordinary saved-query receipt to manual guidance without creating a synthetic Check or positive assertion.
func (*LocalStore) RecordScenarioStep ¶
func (*LocalStore) Run ¶
func (s *LocalStore) Run(ctx context.Context, checkID, environment, caseID, actor string, inputs map[string]InputValue, runner QueryRunner, metadata ...ExecutionMetadata) (CheckRun, error)
func (*LocalStore) RunQueryValidators ¶
func (s *LocalStore) RunQueryValidators(ctx context.Context, queryID, environment, caseID, actor string, inputs map[string]InputValue, runner QueryRunner, metadata ...ExecutionMetadata) (CheckRun, error)
func (*LocalStore) RunQueryValidatorsForResult ¶
func (s *LocalStore) RunQueryValidatorsForResult(ctx context.Context, queryID, environment, caseID, actor string, inputs map[string]InputValue, result apicontract.Result, runner QueryRunner, metadata ...ExecutionMetadata) (CheckRun, error)
RunQueryValidatorsForResult evaluates the authorized retained rows of an existing execution. Its caller must verify the receipt and current policy.
func (*LocalStore) SaveCase ¶
These methods own local flock/file/JSONL mechanics. Core owns the Case transition semantics used identically by the hosted repository adapter.
func (*LocalStore) SaveQueryValidators ¶
func (s *LocalStore) SaveQueryValidators(ctx context.Context, item QueryValidators, actor string) (QueryValidators, error)
func (*LocalStore) SaveScenario ¶
func (*LocalStore) SaveValidator ¶
func (s *LocalStore) SaveValidator(ctx context.Context, item PublishedValidator, actor string) (PublishedValidator, error)
type NativeCapture ¶ added in v0.90.0
type NativeCapture struct {
Pin sessioncontext.DetectiveInputPin
Case *core.Case
Binding core.OperationBinding
}
type NativeCaptureRequest ¶ added in v0.90.0
type NativeCaptureRequest struct {
CheckID, CaseID, NativeOperationID, Actor string
Inputs map[string]InputValue
Reference apicontract.SessionInputReference
}
type NativeQuerySnapshot ¶ added in v0.90.0
type NativeQuerySnapshot func(context.Context, string) (sessioncontext.DetectiveAcceptedQueryPin, error)
NativeQuerySnapshot must load the saved definition and revision together. It performs no source execution. The resulting bytes are privately pinned.
type PublishedValidator ¶
type PublishedValidator = core.PublishedValidator
type QueryFailure ¶
type QueryFailure = core.QueryFailure
type QueryRevisionLookup ¶
QueryRevisionLookup resolves the saved-query revision at run admission. The endpoint checks the same revision when it loads the query for execution.
type QueryRunner ¶
type QueryRunner = core.QueryRunner
type QueryValidators ¶
type QueryValidators = core.QueryValidators
type ScenarioApplication ¶
type ScenarioApplication = core.ScenarioApplication
type ScenarioQueryProof ¶
type ScenarioQueryProof = core.ScenarioQueryProof
type ScenarioStep ¶
type ScenarioStep = core.ScenarioStep
type ScenarioStepReceipt ¶
type ScenarioStepReceipt = core.ScenarioStepReceipt
type StepResult ¶
type StepResult = core.StepResult
type ValidationResult ¶
type ValidationResult = core.ValidationResult
type ValueRange ¶
type ValueRange = core.ValueRange