application

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 37 Imported by: 0

Documentation

Overview

Package application owns SDD's protocol-neutral runtime, public request and result types, and the infrastructure ports implemented by embedding hosts.

Index

Constants

View Source
const (
	DefaultShowUpDepth   = query.DefaultUpDepth
	DefaultShowDownDepth = query.DefaultDownDepth
)

Default show expansion depths favor grounding context while keeping the typically wider consumer side shallow.

View Source
const (
	LegacyPreparedTransitionVersion uint32 = 1
	PreparedTransitionVersion       uint32 = 2
)
View Source
const (
	WorkflowEventCode = "workflow_event"

	BranchBoundEventCode   = "branchBound"
	BranchClearedEventCode = "branchCleared"
	DefaultShellCanonical  = "user-dialogue"
	WorkflowMaxLabelLength = 120
	ExecutionForkPreferred = "fork-preferred"
)
View Source
const FirstSessionCodecVersion uint32 = 1

FirstSessionCodecVersion is the oldest persisted session codec this binary still reads.

View Source
const NewSessionNote = "" /* 219-byte string literal not displayed */

NewSessionNote is the single statement of the way on from a dialogue that has ended: concluding is terminal, so continuing means a new session under a new handle rather than a revival of the spent one (d-tac-k4q). It is composed into the conclude serve and into every refusal an ended session answers with, so each surface names the same one path that works.

View Source
const RecordedStateOnlyNote = "" /* 127-byte string literal not displayed */

RecordedStateOnlyNote is the single statement of the takeover fidelity limit, composed into the consent refusal and the successful-attach note so both runtime surfaces read identically.

View Source
const SessionCodecVersion uint32 = 1
View Source
const SessionRecencyWindow = 15 * time.Minute

SessionRecencyWindow is the single threshold separating an active attachment from an idle one. Erring long is cheap, so it is generous.

Variables

View Source
var ErrSessionNotFound = errors.New("sdd: session not found")

Functions

func AttachmentDirRelPath

func AttachmentDirRelPath(entryID string) (string, error)

AttachmentDirRelPath returns the graph-relative attachment directory for an entry ID.

func ClientLabel

func ClientLabel(name string) string

ClientLabel names a client for a conflict or consent message, falling back when the transport carried no client name (e.g. bare stdio).

func MutationBatchDigest

func MutationBatchDigest(batch MutationBatch) (string, error)

MutationBatchDigest returns the SDD-owned digest over a storage-neutral batch. The Digest field itself is excluded.

func ProcedureRegistry

func ProcedureRegistry() (*engine.Registry, error)

ProcedureRegistry returns the engine registration procedure specs load and size against — the same bounds the runtime serves with (d-tac-rzi). Composition helper for the transitional CLI write path and `sdd lint`; the application's own flows wire it internally.

func SupportedSessionCodecVersion

func SupportedSessionCodecVersion(version uint32) bool

SupportedSessionCodecVersion reports whether a persisted codec version is one this binary can read. Read-compatibility with every shape sdd has written is permanent (d-cpt-i2x), so the whole range through the current version is accepted and superseded shapes are converted at decode; only a version this binary predates is a migration error.

Types

type Access

type Access string

Access is the permission required for the current operation.

const (
	AccessRead  Access = "read"
	AccessWrite Access = "write"
)

type AccessResolver

type AccessResolver interface {
	ResolvePrincipal(context.Context, RequestIdentity) (Principal, error)
	ListProjects(context.Context, Principal) (ProjectList, error)
	ResolveProject(context.Context, Principal, ProjectID, Access) (*ProjectRuntime, error)
	ResolveDependency(context.Context, Principal, ProjectID, string) (*ProjectRuntime, error)
}

AccessResolver is the single identity, project-access, and dependency authorization boundary. Implementations must resolve current authorization from ctx on every call; previously returned principals and runtimes are not proof of current access.

type AcquiredTarget

type AcquiredTarget struct {
	Target     MutationTarget
	Graph      GraphStore
	Finalizers []MutationFinalizer
	Release    func() error
}

AcquiredTarget contains target-scoped adapters for one short operation. Release is mandatory and is called on every success and failure path.

type Application

type Application struct {
	// contains filtered or unexported fields
}

Application resolves current access and dispatches protocol-neutral SDD operations. Every method resolves identity and project afresh.

func NewApplication

func NewApplication(access AccessResolver) (*Application, error)

func (*Application) AbandonWorkflowSession

func (a *Application) AbandonWorkflowSession(ctx context.Context, identity RequestIdentity, project ProjectID, request WorkflowResumeRequest, reason string) (WorkflowAbandonResult, error)

AbandonWorkflowSession tears down a session by handle without ever becoming its attachment: it replays into a buffering sink (no claim, no stamp, no displacement), abandons the instances, then records the terminal abandon and drops whatever stamp was held in one final append. A mid-teardown failure returns before that append, so the victim's attachment stays intact — honest state, no phantom hold. A session another client is actively driving is refused: destruction must not be cheaper than attachment (I5).

func (*Application) ApplyPrepared

func (a *Application) ApplyPrepared(ctx context.Context, identity RequestIdentity, project ProjectID, binding SessionBinding, prepared PreparedTransition) (TransitionResult, error)

ApplyPrepared durably records intent before canonical apply and outcome afterward. Unknown apply outcomes retain staged blobs for reconciliation; definitive outcomes release them after all applied finalizers succeed.

func (*Application) CollectSessions

func (a *Application) CollectSessions(
	ctx context.Context,
	identity RequestIdentity,
	project ProjectID,
	cmd CollectSessionsCmd,
) (CollectSessionsResult, error)

CollectSessions removes the sessions that are safe to remove and drains the pending declarations that can never converge.

The pass is lock-free and optimistic. An ended session is never written to again, so two processes starting at once derive the same target set and both simply delete; an already-deleted target is success. The target set is recomputed from scratch every run, so a partially removed session is finished by the next pass and there is nothing to reconcile after an interruption.

What it protects, and the whole of it: it never removes a session that has not ended, one inside its retention window, one an in-flight declaration still claims, or one this binary cannot read — an unreadable log may belong to a newer version, so it is left alone rather than treated as garbage.

func (*Application) CreateEntry

func (a *Application) CreateEntry(ctx context.Context, identity RequestIdentity, project ProjectID, binding SessionBinding, draft EntryDraft) (CreateEntryResult, error)

CreateEntry runs SDD-owned validation and pre-flight, prepares canonical document/blob facts, then enters the durable transition protocol.

func (*Application) CurrentSnapshot

func (a *Application) CurrentSnapshot(ctx context.Context, identity RequestIdentity, project ProjectID) (*Snapshot, error)

CurrentSnapshot resolves current read access and returns the opaque canonical snapshot for protocol adapters that host SDD's engine.

func (*Application) FinishWIP

func (a *Application) FinishWIP(ctx context.Context, identity RequestIdentity, project ProjectID, binding SessionBinding, target MutationTarget, markerID string) (MutationResult, error)

func (*Application) Info

func (a *Application) Info(ctx context.Context, identity RequestIdentity, project ProjectID, _ InfoRequest) (InfoResult, error)

func (*Application) Lint

func (a *Application) Lint(ctx context.Context, identity RequestIdentity, project ProjectID, request types.LintQuery) (result *types.LintResult, err error)

Lint runs the categorized lint providers over the project's graph — the composition-root lint query (d-cpt-xc3): shells render the findings by category and derive their exit state from LintResult.Errors alone. Index findings need shell-resolved inputs (IndexLintQuery) and stay a shell concern.

func (*Application) ListRecoveries

func (a *Application) ListRecoveries(ctx context.Context, identity RequestIdentity, project ProjectID, includeClosed bool) (RecoveryList, error)

ListRecoveries is a free read projection. Closed terminal history is included only when requested; actionable states never perform acquisition or replay.

func (*Application) ListWorkflowSessions

func (a *Application) ListWorkflowSessions(ctx context.Context, identity RequestIdentity, project ProjectID) ([]WorkflowSessionSummary, error)

func (*Application) OpenStagedBlob

func (a *Application) OpenStagedBlob(ctx context.Context, identity RequestIdentity, project ProjectID, ref SessionRef, blobID string) (io.ReadCloser, error)

OpenStagedBlob resolves read access and session ownership, then streams a staged blob's bytes — the read-side counterpart of StageBlob.

func (*Application) OpenWorkflow

func (a *Application) OpenWorkflow(ctx context.Context, identity RequestIdentity, project ProjectID, request WorkflowOpenRequest) (*WorkflowSession, *WorkflowServe, error)

func (*Application) Procedures

func (*Application) ReadAttachment

func (a *Application) ReadAttachment(ctx context.Context, identity RequestIdentity, project ProjectID, request ReadAttachmentRequest) (ReadAttachmentResult, error)

func (*Application) ReconcileMutation

func (a *Application) ReconcileMutation(ctx context.Context, identity RequestIdentity, project ProjectID, request RecoveryReconcileRequest) (result RecoveryResult, err error)

ReconcileMutation refreshes one actionable recovery projection without choosing a terminal or graph-affecting verb. It exists for interactive clients that must present actions from current target evidence instead of guessing from a durable projection that may predate reconciliation.

func (*Application) RecoverMutation

func (a *Application) RecoverMutation(ctx context.Context, identity RequestIdentity, project ProjectID, request RecoveryRequest) (result RecoveryResult, err error)

RecoverMutation performs exactly one explicitly authorized verb. It always reconciles a freshly acquired concrete target before any graph-affecting or terminal action and never runs from startup, resume, or read surfaces.

func (*Application) ReleaseSession

func (a *Application) ReleaseSession(ctx context.Context, identity RequestIdentity, project ProjectID, binding SessionBinding) error

ReleaseSession clears this connection's own live attachment stamp so the session stops reading held. Nothing is recorded: stepping away is transport, not an act on the dialogue (d-cpt-rw7). Releasing means "clear MY stamp", so when the current attachment is absent or belongs to another MCP session — already displaced, ended, or taken over — it is a no-op.

func (*Application) ReplaceSummary

func (a *Application) ReplaceSummary(ctx context.Context, identity RequestIdentity, project ProjectID, binding SessionBinding, target MutationTarget, entryID, summary string) (MutationResult, error)

func (*Application) ResumeWorkflow

ResumeWorkflow attaches this connection to an existing session, enforcing structural consent (I5): crossing into a session this connection does not already hold requires the user's verbatim ask, and displacing a recent attachment additionally requires an explicit takeover.

func (*Application) Search

func (a *Application) Search(ctx context.Context, identity RequestIdentity, project ProjectID, request SearchRequest) (result SearchResult, err error)

func (*Application) Show

func (a *Application) Show(ctx context.Context, identity RequestIdentity, project ProjectID, request ShowRequest) (result ShowResult, err error)

func (*Application) StageBlob

func (a *Application) StageBlob(ctx context.Context, identity RequestIdentity, project ProjectID, ref SessionRef, filename string, content []byte) (StagedBlob, error)

StageBlob resolves current read access before placing immutable bytes in session-scoped scratch. Canonical write access is checked later at the mutation gate, so read-only principals can still conduct dialogue.

func (*Application) StartWIP

func (a *Application) StartWIP(ctx context.Context, identity RequestIdentity, project ProjectID, binding SessionBinding, target MutationTarget, entryID, description string) (string, MutationResult, error)

func (*Application) View

func (a *Application) View(ctx context.Context, identity RequestIdentity, project ProjectID, request ViewRequest) (result ViewResult, err error)

func (*Application) Vocabulary

func (a *Application) Vocabulary(ctx context.Context, identity RequestIdentity, project ProjectID) (string, error)

func (*Application) WritingGuideCheck

func (a *Application) WritingGuideCheck(ctx context.Context, identity RequestIdentity, project ProjectID, draft EntryDraft) ([]GuideFinding, error)

WritingGuideCheck runs the writing guide against a draft in isolation — the pre-playback half of the capture-guide architecture (d-cpt-20r). The draft's own fields feed the prompt and refs stay unresolved, because the guide's scope is the entry as a stranger reads it. The single exception is the draft's closure edges, described one summary sentence deep: which act an entry performs is not inferable from the body alone, and a guide that cannot see it misreads correct entries (s-tac-fu8). Findings are drafting input for the dialogue, never a gate.

type ApplicationError

type ApplicationError struct {
	Code       ErrorCode
	Message    string
	Project    ProjectRef
	Action     *ProjectAction
	ApplyState ApplyState
	Revision   string
	Version    uint32
	Cause      error
	// Attachment and Ended carry the interpreted conflict on an
	// ErrorSessionDisplaced, ErrorConsentRequired or ErrorSessionEnded: who holds
	// the session now, or the act that ended it, so the caller can be told
	// who/when/why.
	Attachment *Attachment
	Ended      *SessionEnd
}

func (*ApplicationError) Error

func (e *ApplicationError) Error() string

func (*ApplicationError) Unwrap

func (e *ApplicationError) Unwrap() error

type AppliedMutation

type AppliedMutation struct {
	Project  ProjectID
	BatchID  string
	Revision string
	Batch    MutationBatch
}

type ApplyResult

type ApplyResult struct {
	State    ApplyState
	Revision string
}

type ApplyState

type ApplyState string
const (
	MutationNotApplied ApplyState = "not_applied"
	MutationApplied    ApplyState = "applied"
	MutationUnknown    ApplyState = "unknown"
)

type Attachment

type Attachment struct {
	Subject       string
	ClientName    string
	ClientVersion string
	MCPSessionID  string
	LastActivity  time.Time
	UserWords     string `json:",omitempty"`
}

Attachment is the ephemeral stamp of the client currently driving the session: integrity comes from CAS on append, and status is derived from LastActivity recency. UserWords records the user's verbatim ask that authorized this attachment.

type AttachmentMaterialization

type AttachmentMaterialization struct {
	BlobID      string
	Digest      BlobDigest
	Size        int64
	SourceName  string
	LogicalPath string
}

type AttachmentPage

type AttachmentPage struct {
	Filename   string
	Content    []byte
	Offset     int64
	NextOffset int64
	TotalSize  int64
	More       bool
	Digest     BlobDigest
}

type Author

type Author struct {
	Name  string
	Email string
}

type BlobDigest

type BlobDigest struct {
	Algorithm string
	Value     string
}

type BranchValidator

type BranchValidator interface {
	ValidateBranch(context.Context, MutationTarget) error
}

BranchValidator resolves branch authority without opening graph adapters or finalizers. It is the declare-time half of TargetAcquirer: local compositions use the same live checkout rule for both.

type BranchValidatorFunc

type BranchValidatorFunc func(context.Context, MutationTarget) error

BranchValidatorFunc adapts a function to BranchValidator.

func (BranchValidatorFunc) ValidateBranch

func (f BranchValidatorFunc) ValidateBranch(ctx context.Context, target MutationTarget) error

type CanonicalChunk

type CanonicalChunk struct {
	ID      string
	EntryID string
	Ordinal int
	// Revision is deprecated: graph revision is a mutation-concurrency token,
	// never a vector-freshness token (d-cpt-65i). Reconciliation and hit
	// validity ignore it. Retained only for source compatibility.
	Revision    string
	ContentHash string
	Text        string
	// The following persisted citation and identity fields carry everything a
	// store needs to render a citation and answer entry-presence queries
	// without re-deriving chunks. Both the CLI indexer and the application
	// vector search populate them through the shared chunk-derivation helper.
	Body                 string
	Breadcrumb           []string
	Depth                int
	IsSummary            bool
	IsAttachment         bool
	SourceAttachmentPath string
	// EntryHash is the entry-state hash (entry content + summary + attachment
	// bytes) — the same definition as the CLI manifest state hash.
	EntryHash string
}

type ChooserKind

type ChooserKind string

ChooserKind classifies who answers a pending chooser, mirrored from the engine for the served workflow response.

type CollectSessionsCmd

type CollectSessionsCmd struct {
	Retention time.Duration
}

CollectSessionsCmd asks for one reclamation pass over a project's session store. Retention is how long an ended session is kept; zero means remove as soon as it has ended.

type CollectSessionsResult

type CollectSessionsResult struct {
	RemovedSessions []SessionID
	RemovedStaged   []SessionRef
	DrainedIntents  int
	Skipped         []SessionID
}

CollectSessionsResult reports what one pass did. Nothing here is actionable — the pass either removed something or deliberately left it, and the skips say which sessions it could not read so a caller can log them.

type CreateEntryResult

type CreateEntryResult struct {
	Project  ProjectRef
	Binding  SessionBinding
	EntryID  string
	Summary  string
	Findings []Finding
}

type DocumentChange

type DocumentChange struct {
	LogicalPath    string
	Document       *EntryDocument
	CanonicalBytes []byte
	Delete         bool
}

DocumentChange is storage-neutral. CanonicalBytes are rendered once by SDD; Document is present when the logical artifact has structured entry form.

type DocumentIssue

type DocumentIssue struct {
	LogicalPath string
	Message     string
}

DocumentIssue names one document a store could not decode: its logical path and the decode error message.

type EmbeddingExecutor

type EmbeddingExecutor interface {
	Spec(context.Context) (EmbeddingSpec, error)
	Embed(context.Context, []EmbeddingInput) ([]EmbeddingVector, error)
}

type EmbeddingExecutorFuncs

type EmbeddingExecutorFuncs struct {
	SpecFunc  func(context.Context) (EmbeddingSpec, error)
	EmbedFunc func(context.Context, []EmbeddingInput) ([]EmbeddingVector, error)
}

EmbeddingExecutorFuncs adapts mechanical embedding functions to the public executor port.

func (EmbeddingExecutorFuncs) Embed

func (EmbeddingExecutorFuncs) Spec

type EmbeddingInput

type EmbeddingInput struct {
	ID      string
	Text    string
	Purpose EmbeddingPurpose
}

type EmbeddingPurpose

type EmbeddingPurpose string
const (
	EmbeddingDocument EmbeddingPurpose = "document"
	EmbeddingQuery    EmbeddingPurpose = "query"
)

type EmbeddingSpec

type EmbeddingSpec struct {
	Fingerprint string
}

EmbeddingSpec identifies the vector space an executor embeds into. The fingerprint must uniquely determine the embedding model and with it the vector dimensionality — dimensionality itself is discovered from the vectors on first real use, so lazy providers (ollama reports dimensions only with its first response) satisfy the contract without a probe call.

type EmbeddingVector

type EmbeddingVector struct {
	ID     string
	Values []float32
}

type EntryDocument

type EntryDocument struct {
	LogicalPath string
	Frontmatter map[string]any
	Body        string
	Attachments []string
}

EntryDocument is the storage-neutral form of an entry. Frontmatter carries the canonical graph schema as structured values; SDD validates and normalizes it before constructing a Snapshot.

type EntryDraft

type EntryDraft struct {
	Target            MutationTarget
	Kind              string
	Layer             string
	Intent            string
	Body              string
	Refs              []EntryRef
	Closes            []string
	Supersedes        []string
	Participants      []string
	Confidence        string
	Topics            []string
	Index             *FactIndex
	AttachmentHandles []string
	// Canonical and Aliases carry a kind: actor signal's identity; Actor carries
	// a kind: role decision's bound actor canonical; Class carries a
	// kind: procedure decision's execution role. Mirrors the CLI-side
	// NewEntryCmd fields — a value on the wrong kind is a blocking finding at
	// the construction boundary.
	Canonical string
	Aliases   []string
	Actor     string
	Class     string
	// ProcedureSpec carries a kind: procedure decision's workflow declaration
	// as one structured document — {params?, state?, steps, framing?} —
	// converted strictly at draft-to-entry assembly. Interpretation stays
	// with the engine.
	ProcedureSpec map[string]any
	// FocusActors, FocusWhen, and Involvement carry a kind: focus decision's
	// advances list and its focus-level defaults. Mirrors the CLI-side
	// NewEntryCmd fields — ignored on other kinds, written onto the entry so
	// the model-layer validator sees the required involvement frontmatter.
	FocusActors   []string
	FocusWhen     *types.FocusWhen
	Involvement   []types.Involvement
	SkipPreflight bool
}

type EntryRef

type EntryRef struct {
	ID   string
	Kind string
	Desc string
}

type ErrorCode

type ErrorCode string
const (
	ErrorAuthenticationRequired ErrorCode = "authentication_required"
	ErrorInvalidArgument        ErrorCode = "invalid_argument"
	ErrorProjectRequired        ErrorCode = "project_required"
	ErrorProjectUnavailable     ErrorCode = "project_unavailable"
	ErrorActionRequired         ErrorCode = "action_required"
	ErrorReadDenied             ErrorCode = "read_denied"
	ErrorWriteDenied            ErrorCode = "write_denied"
	ErrorBranchUnavailable      ErrorCode = "branch_unavailable"
	ErrorSessionOwnership       ErrorCode = "session_ownership_mismatch"
	ErrorSessionConflict        ErrorCode = "session_conflict"
	ErrorSessionDisplaced       ErrorCode = "session_displaced"
	ErrorSessionEnded           ErrorCode = "session_ended"
	ErrorConsentRequired        ErrorCode = "consent_required"
	ErrorGraphConflict          ErrorCode = "graph_conflict"
	ErrorMigrationRequired      ErrorCode = "migration_required"
	ErrorRecoveryRequired       ErrorCode = "recovery_required"
)

type FactIndex

type FactIndex struct {
	Title string `json:"title"`
	Topic string `json:"topic"`
}

type FactIndexRow

type FactIndexRow struct {
	ID    string
	Title string
	Topic string
}

FactIndexRow is the application-boundary shape of an indexed fact: plain, serializable strings only. Topic carries the canonical slash-joined form (e.g. "cli/view"). ID and Title match the template keys the user-dialogue procedure renders from the factIndex inject result.

type FinalizerOutcome

type FinalizerOutcome struct {
	Name      string
	Succeeded bool
	Message   string
}

type Finding

type Finding struct {
	Severity    string
	Category    string
	Observation string
}

type FixedTargetAcquirer

type FixedTargetAcquirer struct {
	Target     MutationTarget
	Graph      GraphStore
	Finalizers []MutationFinalizer
}

FixedTargetAcquirer is a small composition adapter for stores whose one configured runtime already represents a concrete target. It exact-matches the target and never interprets cwd.

func (FixedTargetAcquirer) Acquire

type GraphStore

type GraphStore interface {
	Current(context.Context) (*Snapshot, error)
	Apply(context.Context, string, MutationBatch, StagedBlobReader) (ApplyResult, error)
	Reconcile(context.Context, string, string) (ApplyResult, error)
	ReadAttachmentPage(context.Context, string, string, int64, int) (AttachmentPage, error)
}

GraphStore is the canonical graph authority: snapshot reads, atomic mutation, reconciliation, and canonical attachment bytes.

type GuideFinding

type GuideFinding struct {
	Reasoning string
	Axis      string
	Quote     string
	Repair    string
	Severity  string
}

GuideFinding mirrors query.GuideFinding at the API boundary.

type IndexNamespace

type IndexNamespace struct {
	Project     ProjectID
	Fingerprint string
	Metric      string
}

IndexNamespace keys one reconciled vector index. The fingerprint pins the embedding model (and thus the dimensionality), so dimensions are not part of the identity — stores enforce vector-length consistency per namespace at reconcile and query time instead.

type IndexedChunk

type IndexedChunk struct {
	Chunk  CanonicalChunk
	Vector []float32
}

type InfoRequest

type InfoRequest struct{}

type InfoResult

type InfoResult struct {
	Project     ProjectRef
	Participant string
	Language    string
	Search      string
	Recovery    string
}

type MutationBatch

type MutationBatch struct {
	ID          string
	Digest      string
	Changes     []DocumentChange
	Attachments []AttachmentMaterialization
	Message     string
	Author      Author
}

type MutationFinalizer

type MutationFinalizer interface {
	Name() string
	Finalize(context.Context, AppliedMutation) error
}

MutationFinalizer is a named, idempotent post-apply effect. It cannot redefine or roll back the canonical MutationBatch.

type MutationResult

type MutationResult struct {
	Project ProjectRef
	Binding SessionBinding
}

type MutationTarget

type MutationTarget struct {
	Project ProjectID `json:"project"`
	Branch  string    `json:"branch"`
}

MutationTarget is the immutable canonical authority for one graph mutation. Project identifies the session project in this delivery; Branch names the concrete Git branch whose registered checkout owns the write.

func (MutationTarget) Validate

func (t MutationTarget) Validate(project ProjectID) error

type PreparedTransition

type PreparedTransition struct {
	Version uint32
	Target  MutationTarget
	// ExpectedGraphRevision is prepare-time provenance only. The apply CAS
	// operand is the freshly revalidated revision (see applyOnAcquired), so a
	// concurrent unrelated append merges cleanly instead of failing the pin.
	ExpectedGraphRevision string
	Batch                 MutationBatch
	// Staged keeps its persisted name so an in-flight intent stays replayable
	// across an upgrade.
	Staged  SessionRef `json:"BlobOwner"`
	BlobIDs []string
}

PreparedTransition is the storage-neutral write-gate output. It contains only pinned v1 facts; adapters never reconstruct application intent.

type Principal

type Principal struct {
	Subject     string
	Participant string
}

Principal is the stable identity and graph participant resolved from a current request. It is binding and audit data, never cached authorization.

type ProcedureListRequest

type ProcedureListRequest struct{}

type ProcedureListResult

type ProcedureListResult struct {
	Project    ProjectRef
	Procedures string
}

type ProjectAction

type ProjectAction struct {
	ID          string
	DisplayName string
	State       ProjectState
	ActionURL   string
	Reason      string
}

type ProjectConfigDocument

type ProjectConfigDocument struct {
	LogicalPath string
	Fields      map[string]any
}

type ProjectID

type ProjectID string

ProjectID is a composition's stable project identity.

type ProjectList

type ProjectList struct {
	Actions  []ProjectAction
	Projects []ProjectSummary
}

type ProjectRef

type ProjectRef struct {
	ID          ProjectID
	DisplayName string
}

ProjectRef is the only project identity exposed in project-scoped results.

type ProjectRuntime

type ProjectRuntime struct {
	// contains filtered or unexported fields
}

ProjectRuntime owns the immutable ports and project configuration resolved for one application operation.

func NewProjectRuntime

func NewProjectRuntime(options ProjectRuntimeOptions) (*ProjectRuntime, error)

func (*ProjectRuntime) Project

func (r *ProjectRuntime) Project() ProjectRef

type ProjectRuntimeOptions

type ProjectRuntimeOptions struct {
	Project       ProjectRef
	DefaultBranch string
	Language      string
	Dependencies  []string
	Graph         GraphStore
	Targets       TargetAcquirer
	Branches      BranchValidator
	Recovery      RecoveryAuthorizer
	Sessions      SessionStore
	StagedBlobs   StagedBlobStore
	Embeddings    EmbeddingExecutor
	SearchIndex   SearchIndexStore
	// LLM is the single LLM dependency: a pkg/llm Runner, injected as an
	// instance that arrives already composed — observed and bounded by the
	// host's decorators. Routing, deadlines, and recording are the host's
	// composition duty (20260830-234501-d-cpt-q6n); application contributes
	// only the facts it alone holds, the Purpose and the prompts.
	LLM        llm.Runner
	Finalizers []MutationFinalizer
	Now        func() time.Time
	// ExcludeEmbeddedFromIndex mirrors the CLI's excludeEmbedded semantics for
	// the vector index: connected-repo runtimes set it so binary-shipped base
	// entries embed once per machine (in the base store) rather than once per
	// connected repo. The base runtime leaves it false — its store includes
	// embedded entries. The rule is applied identically at index and read time.
	ExcludeEmbeddedFromIndex bool
}

type ProjectState

type ProjectState string

ProjectState describes whether a listed project can be used immediately.

const (
	ProjectReady          ProjectState = "ready"
	ProjectActionRequired ProjectState = "action_required"
	ProjectUnavailable    ProjectState = "unavailable"
)

type ProjectSummary

type ProjectSummary struct {
	ProjectRef
	SourceID string
	CanRead  bool
	CanWrite bool
	State    ProjectState
}

type ReadAttachmentRequest

type ReadAttachmentRequest struct {
	EntryID  string
	Filename string
	Offset   int64
	MaxBytes int
}

type ReadAttachmentResult

type ReadAttachmentResult struct {
	Project   ProjectRef
	Page      AttachmentPage
	Available []string
}

type RecoveryAccessRequest

type RecoveryAccessRequest struct {
	Actor           Principal
	Target          MutationTarget
	Verb            RecoveryVerb
	OriginalSubject string
	OriginalSession SessionID
}

type RecoveryAuthorizer

type RecoveryAuthorizer interface {
	AuthorizeRecovery(context.Context, RecoveryAccessRequest) error
}

type RecoveryAuthorizerFunc

type RecoveryAuthorizerFunc func(context.Context, RecoveryAccessRequest) error

func (RecoveryAuthorizerFunc) AuthorizeRecovery

func (f RecoveryAuthorizerFunc) AuthorizeRecovery(ctx context.Context, request RecoveryAccessRequest) error

type RecoveryItem

type RecoveryItem struct {
	Session         SessionID
	MutationID      string
	Digest          string
	Target          MutationTarget
	OriginalSubject string
	State           RecoveryState
	// Reason qualifies State: what delivery waits on while pending, or which
	// decision ended it while abandoned. Empty when delivered.
	Reason RecoveryReason
	// Recovered records that recovery machinery touched this mutation — a
	// reconciliation or a verb. It is provenance, not state: a recovered write is
	// delivered exactly like one that never needed help.
	Recovered        bool
	LegacyUnroutable bool
	EntryIDs         []string
	LastEvidence     string
	// Cause is the terminal's structured cause (e.g. graph-contention for an
	// engine-recorded discard), empty for participant decisions and open items.
	Cause string
}

func (RecoveryItem) Actionable

func (i RecoveryItem) Actionable() bool

Actionable reports whether this item awaits a recovery decision. It is derived from State rather than stored beside it, so the two cannot disagree.

type RecoveryList

type RecoveryList struct {
	Project ProjectRef
	Items   []RecoveryItem
}

type RecoveryReason

type RecoveryReason string

RecoveryReason qualifies a state that does not explain itself: what delivery is waiting on, or which decision ended it.

const (
	RecoveryReasonOutcomeUnknown   RecoveryReason = "outcome-unknown"
	RecoveryReasonNotApplied       RecoveryReason = "not-applied"
	RecoveryReasonFinalizationOwed RecoveryReason = "finalization-owed"
	RecoveryReasonDiscarded        RecoveryReason = "discarded"
	RecoveryReasonAbandonedUnknown RecoveryReason = "abandoned-unknown"
)

type RecoveryReconcileRequest

type RecoveryReconcileRequest struct {
	Session    SessionID
	MutationID string
}

type RecoveryRequest

type RecoveryRequest struct {
	Session    SessionID
	MutationID string
	Verb       RecoveryVerb
	Reason     string
	Target     MutationTarget
}

type RecoveryResult

type RecoveryResult struct {
	Project    ProjectRef
	Item       RecoveryItem
	Transition TransitionResult
}

type RecoveryState

type RecoveryState string
const (
	// RecoveryDelivered means the write reached its desired state: the batch
	// applied and finalization is proven. Nothing is owed.
	RecoveryDelivered RecoveryState = "delivered"
	// RecoveryPending means delivery is not proven yet. Pending is exactly the
	// actionable condition, and Reason names what is owed.
	RecoveryPending RecoveryState = "pending"
	// RecoveryAbandoned means a participant decided to stop pursuing delivery.
	// Reason names the decision.
	RecoveryAbandoned RecoveryState = "abandoned"
)

State answers one question — has delivery been reached — so it carries the two durable conditions of the delivery contract plus the one outcome that is a participant's decision rather than a delivery result.

type RecoveryVerb

type RecoveryVerb string

RecoveryVerb is deliberately finer-grained than write access. Runtime compositions authorize each recovery action and the nonterminal reconcile refresh afresh.

const (
	RecoveryReconcile      RecoveryVerb = "reconcile"
	RecoveryApply          RecoveryVerb = "apply"
	RecoveryDiscard        RecoveryVerb = "discard"
	RecoveryFinalizeRetry  RecoveryVerb = "finalize-retry"
	RecoveryAbandonUnknown RecoveryVerb = "abandon-unknown"
	RecoveryBindTarget     RecoveryVerb = "bind-target"
)

type RegistryFunction

type RegistryFunction struct {
	Name   string
	Class  string
	Doc    string
	Reads  []string
	Writes []string
}

func WorkflowRegistryDocs

func WorkflowRegistryDocs(class string) ([]RegistryFunction, error)

type RequestIdentity

type RequestIdentity struct {
	Subject    string
	Scopes     []string
	Attributes map[string]any
}

RequestIdentity is current-request authentication material supplied by a transport composition. SDD treats Subject as opaque and does not interpret application-specific roles.

type ScoredChunkHit

type ScoredChunkHit struct {
	Namespace IndexNamespace
	ChunkID   string
	EntryID   string
	// EntryHash is the version this hit belongs to, resolved by the store (row
	// metadata, or the manifest for a legacy row). Read-time filtering keeps
	// the hit only when it equals the current entry's state hash. Empty means
	// the store cannot report a version, so the hit is not version-filtered.
	EntryHash string
	// Revision is deprecated and ignored by hit validity (see CanonicalChunk).
	Revision    string
	ContentHash string
	Score       float64
	// Persisted citation fields, rendered directly into search citations so a
	// hit needs no re-derivation of its source chunk.
	Body                 string
	Breadcrumb           []string
	Depth                int
	IsSummary            bool
	IsAttachment         bool
	SourceAttachmentPath string
}

type SearchIndexEntryManifest

type SearchIndexEntryManifest interface {
	IndexedEntries(context.Context, IndexNamespace) ([]StoredEntryRef, error)
}

SearchIndexEntryManifest is an optional capability a persistent store implements so the application can reconcile on entry presence (monotonic accumulation of immutable-entry chunks) instead of chunk-identity comparison. A store that does not implement it falls back to the compatibility reconciliation path in vector search.

type SearchIndexStoreFuncs

type SearchIndexStoreFuncs struct {
	ManifestFunc  func(context.Context, IndexNamespace) ([]StoredChunkRef, error)
	ReconcileFunc func(context.Context, IndexNamespace, string, []IndexedChunk, []string) error
	NearestFunc   func(context.Context, []IndexNamespace, []float32, int) ([]ScoredChunkHit, error)
}

SearchIndexStoreFuncs adapts an index implementation while SDD retains chunking, embedding input, reconciliation decisions, filtering, and ranking.

func (SearchIndexStoreFuncs) Manifest

func (f SearchIndexStoreFuncs) Manifest(ctx context.Context, namespace IndexNamespace) ([]StoredChunkRef, error)

func (SearchIndexStoreFuncs) Nearest

func (f SearchIndexStoreFuncs) Nearest(ctx context.Context, namespaces []IndexNamespace, vector []float32, limit int) ([]ScoredChunkHit, error)

func (SearchIndexStoreFuncs) Reconcile

func (f SearchIndexStoreFuncs) Reconcile(ctx context.Context, namespace IndexNamespace, revision string, upserts []IndexedChunk, deletes []string) error

type SearchRequest

type SearchRequest struct {
	Terms             []string
	Phrase            string
	Branch            string
	BranchFromSession bool
	Type              string
	Layer             string
	Kind              string
	IncludeSuperseded bool
	Limit             int
	MaxCitations      int
	Repos             []string
	AllRepos          bool
}

type SearchResult

type SearchResult struct {
	Project  ProjectRef
	Results  string
	EntryIDs []string
}

type SessionAppend

type SessionAppend struct {
	Metadata *SessionMetadata
	Events   []StoredEvent
}

type SessionBinding

type SessionBinding struct {
	SessionID    SessionID
	Subject      string
	Project      ProjectID
	MCPSessionID string
	Version      uint64
}

SessionBinding is a connection's write token for a durable session: identity plus the attachment it drives and the version it last observed. Append CAS on the version is the sole integrity mechanism.

type SessionEnd

type SessionEnd struct {
	Act     SessionEndAct
	EndedAt time.Time
	Reason  string `json:",omitempty"`
}

SessionEnd records the participant act that ended a session, written once and never revised. Reason records the abandon note, so a displaced writer's next call can be told why. Who ended it is the session's own participant; the ending client's stamp is transport and does not enter the durable record.

type SessionEndAct

type SessionEndAct string

SessionEndAct is the closed set of participant acts that end a dialogue.

const (
	SessionConcluded SessionEndAct = "concluded"
	SessionAbandoned SessionEndAct = "abandoned"
)

type SessionFilter

type SessionFilter struct {
	Subject string
	Project ProjectID
}

type SessionID

type SessionID string

type SessionMetadata

type SessionMetadata struct {
	ID          SessionID
	Subject     string
	Project     ProjectID
	Participant string
	Label       string
	// Branch is the session's explicit branch binding. Empty means unbound;
	// compositions without a branch concept leave it empty.
	Branch     string `json:"branch,omitempty"`
	Attachment *Attachment
	// Ended is the session's single terminal record. Its presence is what makes
	// a session ended; nothing else about a session ends it (d-cpt-rw7).
	Ended     *SessionEnd `json:",omitempty"`
	UpdatedAt time.Time
}

SessionMetadata is structured routing and ownership data. Dialogue events remain opaque to the store. The type itself is the metadata contract: its evolution is the Go type's own, and how a store survives that is the adapter's concern — schema migrations, or format discrimination in its persisted record (d-tac-8js).

func (*SessionMetadata) UnmarshalJSON

func (m *SessionMetadata) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes stored metadata, recovering the terminal record from the attachment history superseded shapes carried it in. Decoding stays lenient about every other field in both directions (d-cpt-i2x).

type SessionRef

type SessionRef struct {
	Subject string
	Session SessionID
}

SessionRef addresses one session inside a subject's namespace. Staged blobs are scoped to a session, so this is what names their area — there is no owner entity, just the two fields that identify whose scaffolding this is.

type SessionStore

SessionStore persists structured metadata plus ordered opaque events. Append is the sole mutation primitive and must compare ExpectedVersion atomically.

Compositions must not run mixed engine versions against one session store: metadata carries no version guard (d-tac-8js), so an older engine reading metadata a newer one wrote is undetected there — only a session the newer engine actually advanced fails closed, through StoredEvent.CodecVersion.

List is also the enumeration collection sweeps over, and Delete is what makes them possible against any implementation rather than only the local one. Delete must be idempotent: removing a session that is already gone is success, since two sweeps may derive the same target set.

type ShowRequest

type ShowRequest struct {
	IDs               []string
	UpDepth           int
	DownDepth         int
	Branch            string
	BranchFromSession bool
	// Budget bounds each direction's chain expansion on the serve path; the
	// zero value is unbounded — explicit pulls arrive complete (d-tac-rzi).
	Budget types.ShowTreeBudget
}

type ShowResult

type ShowResult struct {
	Project    ProjectRef
	Entries    string
	FullIDs    []string
	SummaryIDs []string
}

type Snapshot

type Snapshot struct {
	// contains filtered or unexported fields
}

Snapshot is an immutable, validated SDD graph snapshot. Its indexed model remains private; structured and filesystem stores both enter through SnapshotData. The finder is the shared read authority over the snapshot's graph; the private graph field mirrors it so in-package seams (write-side resolution, the engine graph provider) keep reading a *model.Graph directly.

func BuildSnapshot

func BuildSnapshot(_ context.Context, data SnapshotData) (*Snapshot, error)

BuildSnapshot is the single in-memory graph construction path. It adapts the canonical documents into a storage-neutral source and hands them to the shared GraphFinder, which applies the one semantic gate (parse, embedded-base merge, partial-read load issues) and holds the resulting graph. A malformed entry document no longer aborts the build — it surfaces as a load issue on the snapshot's graph (Snapshot.Health). Structural failures stay hard: missing project/revision, a malformed logical path, a WIP document outside wip/, and base-entry assembly.

func LoadSnapshotFS

func LoadSnapshotFS(ctx context.Context, project ProjectID, revision string, fsys fs.FS, graphDir string) (*Snapshot, error)

LoadSnapshotFS parses canonical filesystem documents into SnapshotData and delegates all validation and indexing to BuildSnapshot.

func (*Snapshot) Health

func (s *Snapshot) Health() types.GraphHealth

Health reports the snapshot graph's integrity problems — parse-failed (unreadable) documents and per-entry validation warnings — so external hosts can render graph health without reaching into the private model. A clean graph reports zero of each.

func (*Snapshot) Project

func (s *Snapshot) Project() ProjectID

func (*Snapshot) Revision

func (s *Snapshot) Revision() string

type SnapshotData

type SnapshotData struct {
	Project  ProjectID
	Revision string
	Config   ProjectConfigDocument
	Entries  []EntryDocument
	WIP      []WIPDocument
	// Unreadable records documents a store could not decode into structured
	// form — a file whose YAML frontmatter would not parse, for example. They
	// are carried as data rather than aborting the load: BuildSnapshot turns
	// each into a graph load issue surfaced through Snapshot.Health, so one
	// malformed file no longer makes an entire graph (and every session over
	// it) unopenable.
	Unreadable []DocumentIssue
}

SnapshotData contains canonical stored document facts, never derived graph indexes, status, or traversal state.

type StagedBlob

type StagedBlob struct {
	ID        string
	Session   SessionRef
	Digest    BlobDigest
	Size      int64
	Filename  string
	CreatedAt time.Time
}

type StagedBlobReader

type StagedBlobReader interface {
	Open(context.Context, string) (io.ReadCloser, error)
}

StagedBlobReader limits Apply to the blobs named by its prepared batch.

type StagedBlobStore

StagedBlobStore owns immutable session-scoped scratch bytes and the retentions holding them. Nothing here is durable: a staged blob lives as long as its session does, and durability is earned only by a captured entry.

StagedSessions and DeleteStaged put reclamation inside the published contract, so a sweep enumerates staging areas and drops the ones whose session is gone through this interface rather than through local-only code. DeleteStaged must be idempotent, and removes a session's blobs together with its retentions.

type StoredChunkRef

type StoredChunkRef struct {
	ID string
	// Revision is deprecated and ignored by reconciliation (see CanonicalChunk).
	Revision    string
	ContentHash string
}

type StoredEntryRef

type StoredEntryRef struct {
	EntryID string
	// EntryHash is the entry-state hash of this stored version — the same
	// definition as CanonicalChunk.EntryHash and the CLI manifest hash. Empty
	// only for a store that cannot report per-version identity.
	EntryHash string
}

StoredEntryRef identifies one stored (entry, version) pair in a persistent index. Presence is keyed by the pair: a store returns one ref per stored version of an entry, so a changed entry (a new EntryHash) reads as absent and is embedded as an added version rather than overwriting the old one.

type StoredEvent

type StoredEvent struct {
	CodecVersion uint32
	Code         string
	Payload      json.RawMessage
}

type StoredSession

type StoredSession struct {
	Metadata SessionMetadata
	Version  uint64
	Events   []StoredEvent
}

type TargetAcquirer

type TargetAcquirer interface {
	Acquire(context.Context, MutationTarget) (*AcquiredTarget, error)
}

TargetAcquirer resolves a concrete mutation authority to short-lived, target-scoped graph and finalizer adapters. Implementations rediscover the target on every call; checkout paths are not durable intent.

type TargetAcquirerFunc

type TargetAcquirerFunc func(context.Context, MutationTarget) (*AcquiredTarget, error)

TargetAcquirerFunc adapts a function to TargetAcquirer.

func (TargetAcquirerFunc) Acquire

type TransitionResult

type TransitionResult struct {
	Project    ProjectRef
	Binding    SessionBinding
	Apply      ApplyResult
	Finalizers []FinalizerOutcome
}

type ValidationError

type ValidationError struct {
	Warnings []types.Warning
}

ValidationError reports that model.ValidateEntry rejected a draft at the write gate. It carries the structural warnings so the workflow gate can re-serve them as actionable findings — naming the violated rule and the field — and route the instance back to a step that can fix it, rather than wedging behind an opaque hard error (closes half of s-prc-g0j).

func (*ValidationError) Error

func (e *ValidationError) Error() string

type ViewRequest

type ViewRequest struct {
	Layout            string
	Branch            string
	BranchFromSession bool
	Repos             []string
	AllRepos          bool
	// Budget bounds the view's scaling parts on the serve path; the zero
	// value is unbounded — explicit pulls arrive complete (d-tac-rzi).
	Budget types.ViewBudget
	// OmitRecovery skips the appended recovery notices — for injected lanes
	// whose session already carries them via sessionInfo, so a pending
	// recovery is served once, not once per lane.
	OmitRecovery bool
}

type ViewResult

type ViewResult struct {
	Project  ProjectRef
	Sections string
	// MatchedCount is the total primary units the layout produced across the
	// local graph and any queried dependency repos. Zero means the pipeline
	// matched nothing — surfaces distinguish an empty result from a failure
	// (an agent over MCP cannot tell a blank string from a broken call).
	MatchedCount int
	// KnownParticipants names the graph's canonical participants, populated
	// only when the result was empty and the layout carried a participant
	// filter — so an empty participant() view can say what names exist rather
	// than leaving an exact-match miss indistinguishable from no data.
	KnownParticipants []string
}

type WIPDocument

type WIPDocument struct {
	LogicalPath string
	Content     string
}

type WorkflowAbandonResult

type WorkflowAbandonResult struct {
	Abandoned   bool
	Session     SessionID
	Label       string
	Discarded   []WorkflowInstanceSummary
	HeldMarkers []string
	Base        *WorkflowServe
}

type WorkflowAdvanceRequest

type WorkflowAdvanceRequest struct {
	Instance string
	Report   map[string]any
	Label    string
}

type WorkflowChooser

type WorkflowChooser struct {
	Chooser string
	Kind    ChooserKind
	Options []WorkflowChooserOption
}

type WorkflowChooserOption

type WorkflowChooserOption struct {
	Choice  string
	Collect []string
}

type WorkflowInstanceSummary

type WorkflowInstanceSummary struct {
	Instance  string
	Procedure string
	Step      string
}

type WorkflowOpenRequest

type WorkflowOpenRequest struct {
	MCPSessionID  string
	ClientName    string
	ClientVersion string
	Shell         string
	Label         string
}

type WorkflowParkResult

type WorkflowParkResult struct {
	Instance  string
	Procedure string
	Step      string
	Base      *WorkflowServe
}

type WorkflowResumeRequest

type WorkflowResumeRequest struct {
	SessionID     SessionID
	MCPSessionID  string
	ClientName    string
	ClientVersion string
	// UserWords is the user's verbatim request to move into the session, required
	// to attach to a session this connection does not already hold. Takeover
	// additionally authorizes displacing an attachment that is still recent.
	UserWords string
	Takeover  bool
}

type WorkflowResumeResult

type WorkflowResumeResult struct {
	Session      SessionID
	Participant  string
	Label        string
	Branch       string
	Open         []WorkflowServe
	Instructions string
	// Displaced names the attachment this attach ended (nil when the session was
	// unheld); TookOver is true when that displaced attachment was still recent,
	// so the caller can surface the fidelity limit of a takeover.
	Displaced *Attachment
	TookOver  bool
}

type WorkflowServe

type WorkflowServe struct {
	Session        SessionID
	Branch         string
	Instance       string
	Procedure      string
	Status         string
	Step           string
	Goal           string
	Instructions   string
	Missing        []string
	ReportSchema   map[string]any
	PendingChooser *WorkflowChooser
	Execution      string
	Produced       map[string]any
	Diagnostics    []string
	// InstructionLanes are the unit's rendered lanes in order — what the MCP
	// layer dedups independently; Instructions is their join plus diagnostics.
	InstructionLanes []types.ServeLane
	// Sizes is the engine's per-part byte accounting for this serve, read by
	// the serve-budget measurement (d-tac-qwc).
	Sizes []types.PartSize
	Base  *WorkflowServe
	// Collected is the instance's already-gathered param and state values,
	// projected only onto resume serves so a newly attached or reoriented
	// agent sees what this instance holds — the anchor, chosen scope, and
	// reported judgments that persist across a handover (d-cpt-0tm). Empty on
	// door, next, and base-junction serves, which stay unchanged.
	Collected map[string]any
}

func (*WorkflowServe) ComposeInstructions

func (s *WorkflowServe) ComposeInstructions(unitText string) string

ComposeInstructions joins host-recomposed unit text (e.g. the deduped lane subset) with this serve's diagnostics — the engine's one composition rule applied host-side.

func (*WorkflowServe) ReminderInstructions

func (s *WorkflowServe) ReminderInstructions() string

ReminderInstructions composes the short reminder used when a host has already served this instruction unit, while retaining any gate diagnostics. The stub assumes the caller still holds the earlier full text; if a context compaction dropped it, the breadcrumb names the one-shot escape so an amnesiac agent is not left following instructions it no longer has.

type WorkflowSession

type WorkflowSession struct {
	// contains filtered or unexported fields
}

WorkflowSession is a protocol-neutral, durable engine session. It stores no authorization proof: every operation receives the current request identity and resolves access again before touching project state.

func (*WorkflowSession) Abandon

func (w *WorkflowSession) Abandon(ctx context.Context, identity RequestIdentity, instance, reason string) (WorkflowAbandonResult, error)

func (*WorkflowSession) Advance

func (*WorkflowSession) BindBranch

func (w *WorkflowSession) BindBranch(ctx context.Context, identity RequestIdentity, branch string, clear bool) error

BindBranch changes the durable session-level branch declaration. Setting a binding resolves the branch against the runtime's live branch capability before the CAS append; clearing is store-only and works without that capability.

func (*WorkflowSession) Binding

func (w *WorkflowSession) Binding() SessionBinding

func (*WorkflowSession) Branch

func (w *WorkflowSession) Branch() string

func (*WorkflowSession) EditStagedAttachment

func (w *WorkflowSession) EditStagedAttachment(ctx context.Context, identity RequestIdentity, handle string, pairs []types.PatchPair) error

EditStagedAttachment applies ordered exact search-replace pairs to a staged file addressed by its handle and stages the result under the same handle, so a small correction costs neither a full re-stage nor a full re-read (20260826-120330-d-tac-8f8). Atomic: a failing pair names itself and the staged file stays unchanged.

func (*WorkflowSession) Finished

func (w *WorkflowSession) Finished() bool

Finished reports whether this dialogue is over: the shell has left running, which is the act that wrote the terminal record. A finished session is spent — the door opens a new one rather than re-serving it, and no move may carry it on.

func (*WorkflowSession) Framing

func (w *WorkflowSession) Framing(ctx context.Context, identity RequestIdentity) ([]string, error)

Framing composes the session framing as ordered, independently dedupable blocks: the engine-supplied info block (participant, language, search modes) first, then one block per declared shell lane, rendered through the injection mechanism. Returning the lanes as separate blocks — not one joined string — lets the host dedup each on its own, so a graph write that changes only the recent-moves lane re-serves that lane alone, never the stable aspirations or directives (I6, A1). A shell with no declared lanes yields the info block alone; there is no Go-constant fallback.

func (*WorkflowSession) ID

func (w *WorkflowSession) ID() SessionID

func (*WorkflowSession) IsShell

func (w *WorkflowSession) IsShell(instance string) bool

func (*WorkflowSession) Leave

func (w *WorkflowSession) Leave(ctx context.Context, identity RequestIdentity) error

Leave clears the connection's attachment stamp when it steps away. A quiescent session — shell only, no open moves — auto-concludes its shell so it does not linger as an empty parked dialogue.

func (*WorkflowSession) LogRead

func (w *WorkflowSession) LogRead(ctx context.Context, identity RequestIdentity, tool string, full, summary []string) error

func (*WorkflowSession) OpenInstances

func (w *WorkflowSession) OpenInstances() []WorkflowInstanceSummary

func (*WorkflowSession) Park

func (w *WorkflowSession) Park(ctx context.Context, identity RequestIdentity, instance, note string) (WorkflowParkResult, error)

func (*WorkflowSession) Project

func (w *WorkflowSession) Project() ProjectID

func (*WorkflowSession) ReadStagedAttachment

func (w *WorkflowSession) ReadStagedAttachment(ctx context.Context, identity RequestIdentity, handle string, offset int64, maxBytes int) (AttachmentPage, []string, error)

ReadStagedAttachment returns one bounded page of a staged file by handle, plus the session's staged handles as the discovery surface.

func (*WorkflowSession) Reopen

func (w *WorkflowSession) Reopen(ctx context.Context, identity RequestIdentity, label string) (*WorkflowServe, error)

func (*WorkflowSession) ServeAll

func (*WorkflowSession) ServeShell

func (w *WorkflowSession) ServeShell(ctx context.Context, identity RequestIdentity) (*WorkflowServe, error)

func (*WorkflowSession) StageAttachment

func (w *WorkflowSession) StageAttachment(ctx context.Context, identity RequestIdentity, filename string, content []byte) (string, error)

func (*WorkflowSession) StagedHandles

func (w *WorkflowSession) StagedHandles() []string

StagedHandles lists the session's staged file handles, sorted.

func (*WorkflowSession) Start

func (*WorkflowSession) StillHeld

func (w *WorkflowSession) StillHeld(ctx context.Context, identity RequestIdentity) (bool, error)

StillHeld reports whether this connection is still the store's current attachment. A false answer means the cached binding is stale — displaced by another client or torn down — so the connection must re-establish through the attach path rather than serve its now-poisoned in-memory session.

type WorkflowSessionSummary

type WorkflowSessionSummary struct {
	Session      SessionID
	Label        string
	Participant  string
	Branch       string
	Anchor       string
	Open         []WorkflowInstanceSummary
	LastActivity time.Time
	Attachment   *Attachment
	Active       bool
}

type WorkflowStartRequest

type WorkflowStartRequest struct {
	Canonical string
	Params    map[string]any
	Label     string
	Parent    string
}

Directories

Path Synopsis
Package types holds the plain data types the public application surface shares with the internal packages that produce them.
Package types holds the plain data types the public application surface shares with the internal packages that produce them.

Jump to

Keyboard shortcuts

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