detective

package
v0.104.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package detective adapts Core's shared Checks and Cases to local storage.

Index

Constants

This section is empty.

Variables

View Source
var ErrCapacity = core.ErrCapacity
View Source
var ErrConflict = core.ErrConflict
View Source
var ErrInvalid = core.ErrInvalid
View Source
var ErrNotFound = core.ErrNotFound
View Source
var ErrOutcomeUncertain = core.ErrOutcomeUncertain

Functions

func AdmittedQueryRevision

func AdmittedQueryRevision(ctx context.Context, queryID string) (string, bool)

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.

Types

type AIPage

type AIPage struct {
	Proposals  []ai.Proposal `json:"proposals"`
	NextCursor string        `json:"nextCursor,omitempty"`
	HasMore    bool          `json:"hasMore"`
}

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 Binding

type Binding = core.Binding

type Capabilities

type Capabilities = core.Capabilities

type Case

type Case = core.Case

type CaseEvent

type CaseEvent = core.CaseEvent

type CaseEventsPage

type CaseEventsPage = core.CaseEventsPage

type Check

type Check = core.Check

type CheckRun

type CheckRun = core.CheckRun

type EvidenceRef

type EvidenceRef = core.EvidenceRef

type ExecutionMetadata

type ExecutionMetadata = core.ExecutionMetadata

type Finding

type Finding = core.Finding

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 Input

type Input = core.Input

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

func (s LocalAIStore) AIReceipt(ctx context.Context, id string) (ai.Receipt, bool, error)

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

func (s LocalAIStore) ConfirmCase(ctx context.Context, command ai.Command) (ai.Receipt, error)

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

func (s LocalAIStore) ConfirmCatalog(ctx context.Context, command ai.Command) (ai.Receipt, error)

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 (s LocalAIStore) ConfirmQuery(ctx context.Context, command ai.Command) (ai.Receipt, error)

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.

func (LocalAIStore) Get

func (s LocalAIStore) Get(ctx context.Context, id string) (ai.Proposal, error)

func (LocalAIStore) Page

func (s LocalAIStore) Page(ctx context.Context, after string) (AIPage, error)

func (LocalAIStore) Save

func (s LocalAIStore) Save(ctx context.Context, proposal ai.Proposal) error

func (LocalAIStore) SavePaste

func (s LocalAIStore) SavePaste(ctx context.Context, text string) (ai.Source, error)

SavePaste retains only a scoped digest and length. Full pasted text remains ephemeral; the proposal itself retains only verified citation spans.

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 (s *LocalStore) AppendCaseEvent(ctx context.Context, id string, event CaseEvent, actor string) (Case, error)

func (*LocalStore) ApplyScenario

func (s *LocalStore) ApplyScenario(ctx context.Context, caseID, scenarioID, actor string) (Case, error)

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

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

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) 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) GetCase

func (s *LocalStore) GetCase(ctx context.Context, id string) (Case, error)

func (*LocalStore) GetCheck

func (s *LocalStore) GetCheck(ctx context.Context, id string) (Check, error)

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

func (s *LocalStore) KnowledgePage(ctx context.Context, after string) (knowledge.Page, error)

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

NativeObservation is authoritative journal lookup only. It never runs a source, claims work, or infers that absence makes dispatch safe.

func (*LocalStore) QueryExists

func (s *LocalStore) QueryExists(_ context.Context, id string) (bool, error)

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 (s *LocalStore) RecordScenarioStep(ctx context.Context, caseID, applicationID, stepID, status, runID, actor string) (Case, error)

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

func (s *LocalStore) SaveCase(ctx context.Context, item Case, actor, action string) (Case, error)

These methods own local flock/file/JSONL mechanics. Core owns the Case transition semantics used identically by the hosted repository adapter.

func (*LocalStore) SaveCheck

func (s *LocalStore) SaveCheck(ctx context.Context, check Check, actor string) (Check, error)

func (*LocalStore) SaveQueryValidators

func (s *LocalStore) SaveQueryValidators(ctx context.Context, item QueryValidators, actor string) (QueryValidators, error)

func (*LocalStore) SaveRun

func (s *LocalStore) SaveRun(ctx context.Context, run CheckRun) error

func (*LocalStore) SaveScenario

func (s *LocalStore) SaveScenario(ctx context.Context, scenario Scenario, actor string) (Scenario, error)

func (*LocalStore) SaveValidator

func (s *LocalStore) SaveValidator(ctx context.Context, item PublishedValidator, actor string) (PublishedValidator, error)

func (*LocalStore) State

func (s *LocalStore) State(ctx context.Context) (State, error)

func (*LocalStore) StatePage

func (s *LocalStore) StatePage(ctx context.Context, cursor string) (State, error)

StatePage returns a bounded latest run page. The opaque cursor orders file write time plus ID, so history does not make the catalog unusable.

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

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

type QueryRevisionLookup func(context.Context, string) (string, error)

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 Scenario

type Scenario = core.Scenario

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 State

type State = core.State

type Step

type Step = core.Step

type StepResult

type StepResult = core.StepResult

type ValidationResult

type ValidationResult = core.ValidationResult

type Validator

type Validator = core.Validator

type Value

type Value = core.Value

The wire contract is owned by Core so terminal and hosted callers share it.

type ValueRange

type ValueRange = core.ValueRange

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL