client
import "github.com/chuxorg/yanzi/internal/client"
Index
- type ChainResponse
- type Client
- func New(baseURL string) *Client
- func (c *Client) ChainIntent(ctx context.Context, id string) (ChainResponse, error)
- func (c *Client) CreateIntent(ctx context.Context, req CreateIntentRequest) (IntentRecord, error)
- func (c *Client) GetIntent(ctx context.Context, id string) (IntentRecord, error)
- func (c *Client) ListIntents(ctx context.Context, author, source string, limit int, metaFilters map[string]string, includeDeleted bool) (ListResponse, error)
- func (c *Client) VerifyIntent(ctx context.Context, id string) (VerifyResponse, error)
- type CreateIntentRequest
- type IntentRecord
- type ListResponse
- type VerifyResponse
type ChainResponse
ChainResponse is returned by the /chain endpoint.
type ChainResponse struct {
HeadID string `json:"head_id"`
Length int `json:"length"`
Intents []IntentRecord `json:"intents"`
MissingLinks []string `json:"missing_links,omitempty"`
}
type Client
Client is a minimal HTTP client for the Yanzi Library API.
type Client struct {
BaseURL string
HTTPClient *http.Client
}
func New
func New(baseURL string) *Client
New creates an HTTP client for a Yanzi base URL.
The returned client trims any trailing slash from baseURL and sets a default request timeout. It is used when the CLI runs in HTTP mode.
func (*Client) ChainIntent
func (c *Client) ChainIntent(ctx context.Context, id string) (ChainResponse, error)
ChainIntent calls GET /v0/intents/{id}/chain.
func (*Client) CreateIntent
func (c *Client) CreateIntent(ctx context.Context, req CreateIntentRequest) (IntentRecord, error)
CreateIntent posts a new intent record.
func (*Client) GetIntent
func (c *Client) GetIntent(ctx context.Context, id string) (IntentRecord, error)
GetIntent calls GET /v0/intents/{id}.
func (*Client) ListIntents
func (c *Client) ListIntents(ctx context.Context, author, source string, limit int, metaFilters map[string]string, includeDeleted bool) (ListResponse, error)
ListIntents calls GET /v0/intents.
func (*Client) VerifyIntent
func (c *Client) VerifyIntent(ctx context.Context, id string) (VerifyResponse, error)
VerifyIntent calls GET /v0/intents/{id}/verify.
type CreateIntentRequest
CreateIntentRequest is the payload for POST /v0/intents.
type CreateIntentRequest struct {
Author string `json:"author"`
SourceType string `json:"source_type"`
Title string `json:"title,omitempty"`
Prompt string `json:"prompt"`
Response string `json:"response"`
Meta json.RawMessage `json:"meta,omitempty"`
PrevHash string `json:"prev_hash,omitempty"`
}
type IntentRecord
IntentRecord mirrors the server v0 schema.
type IntentRecord = model.IntentRecord
type ListResponse
ListResponse is returned by the /intents endpoint.
type ListResponse struct {
Intents []IntentRecord `json:"intents"`
}
type VerifyResponse
VerifyResponse is returned by the /verify endpoint.
type VerifyResponse struct {
ID string `json:"id"`
Valid bool `json:"valid"`
StoredHash string `json:"stored_hash"`
ComputedHash string `json:"computed_hash"`
PrevHash string `json:"prev_hash"`
Error *string `json:"error"`
}
cmd
import "github.com/chuxorg/yanzi/internal/cmd"
Index
- func RunBootstrap(args []string) error
- func RunCapture(args []string) error
- func RunChain(args []string) error
- func RunCheckpoint(args []string) error
- func RunContext(args []string) error
- func RunDelete(args []string) error
- func RunExport(args []string, cliVersion string) error
- func RunInit(args []string) error
- func RunIntent(args []string) error
- func RunList(args []string) error
- func RunMessage(args []string) error
- func RunMode(args []string) error
- func RunPack(args []string) error
- func RunProject(args []string) error
- func RunRehydrate(args []string) error
- func RunRestore(args []string) error
- func RunRules(args []string, cliVersion string) error
- func RunServe(args []string, version string) error
- func RunShow(args []string) error
- func RunTypes(args []string) error
- func RunVerify(args []string) error
func RunBootstrap
func RunBootstrap(args []string) error
func RunCapture
func RunCapture(args []string) error
RunCapture stores one prompt/response pair as an intent record.
Problem: Captured AI work is easy to lose when prompts and responses only exist in transient chat sessions.
Solution: RunCapture accepts CLI arguments that describe one prompt/response pair and writes the record in local mode or posts it in HTTP mode.
Arguments:
args contains the capture flags, including author, prompt, response, and
optional metadata.
Example:
yanzi capture --author "Ada" --prompt "What changed?" --response "Updated docs."
func RunChain
func RunChain(args []string) error
RunChain prints the intent chain from oldest to newest.
func RunCheckpoint
func RunCheckpoint(args []string) error
RunCheckpoint manages checkpoint creation and listing for the active project.
Problem: Reloading a project from the beginning is unnecessary when a stable boundary already exists.
Solution: RunCheckpoint provides `create` and `list` subcommands for append-only project checkpoint records.
Arguments:
args starts with `create` or `list` followed by that subcommand's flags.
Example:
yanzi checkpoint create --summary "Initial project state"
func RunContext
func RunContext(args []string) error
func RunDelete
func RunDelete(args []string) error
RunDelete tombstones an intent or artifact by id.
func RunExport
func RunExport(args []string, cliVersion string) error
RunExport writes deterministic project exports for history or filtered context.
Problem: Callers sometimes need a full timeline export and sometimes need a filtered retrieval of stored context only.
Solution: RunExport supports log formats plus explicit context export via the claude-context format, with deterministic metadata filtering.
Arguments:
args contains export flags such as format, metadata filters, and output behavior;
cliVersion is written into the rendered export headers.
Example:
yanzi export --format markdown --meta type=context
func RunInit
func RunInit(args []string) error
RunInit creates or reuses a project and binds it to the current directory.
Problem: Local project setup is error-prone when project creation, activation, and directory binding are done as separate steps.
Solution: RunInit ensures a project exists, writes .yanzi/project in the current directory, and makes that project active.
Arguments:
args may contain one optional project name; otherwise the current directory
name is used.
Example:
yanzi init demo
func RunIntent
func RunIntent(args []string) error
func RunList
func RunList(args []string) error
RunList lists intent records.
func RunMessage
func RunMessage(args []string) error
RunMessage stores and retrieves handoff notes through message subcommands.
Problem: Independent agents or operators may need a shared note channel without relying on a separate messaging system.
Solution: RunMessage exposes `send`, `list`, and `pull`, backed by existing capture storage with message metadata.
Arguments:
args starts with `send`, `list`, or `pull` and then that subcommand's
flags.
Example:
yanzi message send --to codex --from operator --channel execution --content "Continue."
func RunMode
func RunMode(args []string) error
RunMode shows or sets the runtime mode.
func RunPack
func RunPack(args []string) error
RunPack applies or exports portable context packs.
Problem: Reusing the same stored context across projects is tedious when each item must be added manually.
Solution: RunPack exposes `apply` for idempotent pack loading and `export` for producing a pack definition plus sidecar files from visible context.
Arguments:
args starts with `apply` or `export` followed by the corresponding flags.
func RunProject
func RunProject(args []string) error
RunProject manages project creation, selection, and inspection.
Arguments:
args starts with `create`, `use`, `current`, or `list`.
Example:
yanzi project use demo
func RunRehydrate
func RunRehydrate(args []string) error
RunRehydrate prints the latest checkpoint and the intent records after it.
Problem: Agents need current project state without reconstructing it manually from all earlier records.
Solution: RunRehydrate loads the active project, resolves the latest checkpoint, and renders either a dry-run summary or the ordered records since that boundary.
Arguments:
args supports `--dry-run`, `--format text|json`, and no positional arguments.
Example:
yanzi rehydrate --dry-run
func RunRestore
func RunRestore(args []string) error
RunRestore removes tombstone metadata from an intent or artifact by id.
func RunRules
func RunRules(args []string, cliVersion string) error
func RunServe
func RunServe(args []string, version string) error
RunServe starts the shared runtime server in the foreground.
func RunShow
func RunShow(args []string) error
RunShow prints full intent details by id.
func RunTypes
func RunTypes(args []string) error
func RunVerify
func RunVerify(args []string) error
RunVerify verifies the stored hash for a given intent id.
config
import "github.com/chuxorg/yanzi/internal/config"
Index
- Constants
- func ConfigPath() (string, error)
- func DefaultDBPath() (string, error)
- func EffectiveLocalDBPath(cfg Config) (string, error)
- func StateDir() (string, error)
- type Config
- func Load() (Config, error)
- type Mode
Constants
LocalDBPathEnvVar is the environment variable that overrides local SQLite resolution.
const LocalDBPathEnvVar = "YANZI_DB_PATH"
func ConfigPath
func ConfigPath() (string, error)
ConfigPath returns the full path to \~/.yanzi/config.yaml.
func DefaultDBPath
func DefaultDBPath() (string, error)
DefaultDBPath returns the default SQLite path under \~/.yanzi.
func EffectiveLocalDBPath
func EffectiveLocalDBPath(cfg Config) (string, error)
EffectiveLocalDBPath resolves the local SQLite path using deterministic precedence.
Precedence:
- YANZI_DB_PATH
- Config.DBPath
- DefaultDBPath()
func StateDir
func StateDir() (string, error)
StateDir returns the \~/.yanzi directory path.
type Config
Config holds CLI configuration values loaded from disk.
type Config struct {
Mode Mode `yaml:"mode"`
DBPath string `yaml:"db_path"`
BaseURL string `yaml:"base_url"`
}
func Load
func Load() (Config, error)
Load reads \~/.yanzi/config.yaml and returns the effective CLI configuration.
Problem: The CLI needs one deterministic source of truth for local and optional HTTP runtime settings.
Solution: Load reads the config file, applies defaults, trims values, and validates mode-specific requirements before returning.
type Mode
Mode controls whether yanzi runs against local storage or HTTP APIs.
type Mode string
const (
ModeLocal Mode = "local"
ModeHTTP Mode = "http"
)
yanzilibrary
import "github.com/chuxorg/yanzi/internal/library"
Index
- Constants
- Variables
- func DecodeArtifactReadMetadata(raw string) (map[string]string, error)
- func HashCheckpoint(checkpoint Checkpoint) (string, error)
- func InitDB() (*sql.DB, error)
- func InitDBAtPath(path string) (*sql.DB, error)
- func Initialize() (bool, error)
- func LoadActiveProject() (string, error)
- func MigrationsFS() fs.FS
- func ProjectExists(name string) (bool, error)
- func RenderOperationalExportLog(ctx context.Context, provider storage.Provider, project, cliVersion string, now time.Time, format ExportLogFormat, metaFilters map[string]string, includeDeleted bool) ([]byte, string, error)
- func ResolvedDBPath() string
- func StatePath() (string, error)
- type Artifact
- func CreateArtifact(projectID, class, artifactType, title, content, metadata string) (Artifact, error)
- func CreateContextArtifact(projectID, artifactType, scope, title, content, metadata string) (Artifact, error)
- func GetVisibleContextArtifact(idPrefix, activeProject string) (Artifact, error)
- func ListArtifacts(projectID, class, artifactType string, includeDeleted bool) ([]Artifact, error)
- func ListArtifactsAllProjects(class, artifactType string, includeDeleted bool) ([]Artifact, error)
- func ListVisibleContextArtifacts(activeProject, artifactType, scopeFilter, projectFilter string, includeDeleted bool) ([]Artifact, error)
- func ListVisibleContextArtifactsAllProjects(artifactType, scopeFilter string, includeDeleted bool) ([]Artifact, error)
- type ArtifactReadQuery
- type ArtifactReadStore
- func NewArtifactReadStore(db *sql.DB) *ArtifactReadStore
- func (s *ArtifactReadStore) GetIntentRecord(ctx context.Context, id string) (model.IntentRecord, error)
- func (s *ArtifactReadStore) ListIntentRecords(ctx context.Context, query ArtifactReadQuery) ([]model.IntentRecord, error)
- type ArtifactWriteStore
- func NewArtifactWriteStore(db *sql.DB) *ArtifactWriteStore
- func (s *ArtifactWriteStore) CreateArtifact(ctx context.Context, input storage.CreateArtifactInput) (Artifact, error)
- func (s *ArtifactWriteStore) CreateCapture(ctx context.Context, input CaptureWriteInput) (model.IntentRecord, error)
- func (s *ArtifactWriteStore) Restore(ctx context.Context, id string) error
- func (s *ArtifactWriteStore) Tombstone(ctx context.Context, id string, cascade, force bool) ([]string, error)
- type CaptureWriteInput
- type ChainResult
- func ChainIntent(ctx context.Context, provider storage.Provider, id string) (ChainResult, error)
- type Checkpoint
- func CreateCheckpoint(ctx context.Context, db *sql.DB, project, summary string, artifactIDs []string) (Checkpoint, error)
- func CreateProjectCheckpoint(project, summary string, artifactIDs []string) (Checkpoint, error)
- func ListAllCheckpoints(ctx context.Context, db *sql.DB) ([]Checkpoint, error)
- func ListAllProjectCheckpoints() ([]Checkpoint, error)
- func ListCheckpoints(ctx context.Context, db *sql.DB, project string) ([]Checkpoint, error)
- func ListProjectCheckpoints(project string) ([]Checkpoint, error)
- func (c Checkpoint) Normalize() Checkpoint
- func (c Checkpoint) Validate() error
- type CheckpointStore
- func NewCheckpointStore(db *sql.DB) *CheckpointStore
- func (s *CheckpointStore) CreateCheckpoint(ctx context.Context, project, summary string, artifactIDs []string) (Checkpoint, error)
- func (s *CheckpointStore) ListCheckpoints(ctx context.Context, project string) ([]Checkpoint, error)
- type CheckpointValidationError
- func (e CheckpointValidationError) Error() string
- type ExportLogFormat
- type Intent
- type Project
- func CreateProject(name string, description string) (*Project, error)
- func ListProjects() ([]Project, error)
- type ProjectNotFoundError
- func (e ProjectNotFoundError) Error() string
- type RehydratePayload
- func RehydrateProject(project string) (*RehydratePayload, error)
- func RehydrateProjectWithFallback(project string, fallbackLimit int) (*RehydratePayload, error)
- type RehydrationService
- func NewRehydrationService(db *sql.DB) *RehydrationService
- func (s *RehydrationService) RehydrateProject(ctx context.Context, project string) (*RehydratePayload, error)
- func (s *RehydrationService) RehydrateProjectWithFallback(ctx context.Context, project string, fallbackLimit int) (*RehydratePayload, error)
- type VerifyResult
- func VerifyIntent(ctx context.Context, provider storage.Provider, id string) (VerifyResult, error)
Constants
const (
ArtifactClassIntent = "intent"
ArtifactClassContext = "context"
ContextScopeGlobal = "global"
ContextScopeProject = "project"
)
DefaultRehydrateFallbackLimit is the deterministic fallback window when no checkpoint exists.
const DefaultRehydrateFallbackLimit = 10
Variables
ErrCheckpointNotFound indicates that no checkpoint exists for the requested project.
var ErrCheckpointNotFound = errors.New("checkpoint not found")
func DecodeArtifactReadMetadata
func DecodeArtifactReadMetadata(raw string) (map[string]string, error)
DecodeArtifactReadMetadata decodes the current artifact read metadata payload.
func HashCheckpoint
func HashCheckpoint(checkpoint Checkpoint) (string, error)
HashCheckpoint computes a deterministic SHA-256 hash for a Checkpoint. The hash preimage excludes the hash field and uses canonical field order.
func InitDB
func InitDB() (*sql.DB, error)
InitDB resolves the database path, ensures migrations, and returns a SQLite handle.
func InitDBAtPath
func InitDBAtPath(path string) (*sql.DB, error)
InitDBAtPath ensures migrations and returns a SQLite handle for the provided path.
func Initialize
func Initialize() (bool, error)
Initialize ensures the default yanzi runtime directory, database, and schema exist. It returns true when this run performed first-time schema initialization.
func LoadActiveProject
func LoadActiveProject() (string, error)
LoadActiveProject resolves the current active project using the same local-state lookup order as the CLI.
func MigrationsFS
func MigrationsFS() fs.FS
MigrationsFS exposes embedded migration files for libraryd.
func ProjectExists
func ProjectExists(name string) (bool, error)
ProjectExists reports whether a project exists in the current local provider.
func RenderOperationalExportLog
func RenderOperationalExportLog(ctx context.Context, provider storage.Provider, project, cliVersion string, now time.Time, format ExportLogFormat, metaFilters map[string]string, includeDeleted bool) ([]byte, string, error)
RenderOperationalExportLog preserves the current deterministic log export behavior.
func ResolvedDBPath
func ResolvedDBPath() string
ResolvedDBPath returns the most recently resolved database path.
func StatePath
func StatePath() (string, error)
StatePath resolves the canonical state.json path used for active project persistence.
type Artifact
Artifact represents an artifact stored in the intents ledger table.
type Artifact struct {
ID string
Class string
Type string
Scope string
Project string
Title string
Content string
Metadata string
CreatedAt string
}
func CreateArtifact
func CreateArtifact(projectID, class, artifactType, title, content, metadata string) (Artifact, error)
CreateArtifact stores a new artifact for a project.
func CreateContextArtifact
func CreateContextArtifact(projectID, artifactType, scope, title, content, metadata string) (Artifact, error)
CreateContextArtifact stores a new context artifact using the Phase 6 scope rules.
func GetVisibleContextArtifact
func GetVisibleContextArtifact(idPrefix, activeProject string) (Artifact, error)
GetVisibleContextArtifact resolves a visible context artifact by full id or unique prefix.
func ListArtifacts
func ListArtifacts(projectID, class, artifactType string, includeDeleted bool) ([]Artifact, error)
ListArtifacts lists artifacts for a project and class, optionally filtered by type.
func ListArtifactsAllProjects
func ListArtifactsAllProjects(class, artifactType string, includeDeleted bool) ([]Artifact, error)
ListArtifactsAllProjects lists artifacts across every project for the requested class.
func ListVisibleContextArtifacts
func ListVisibleContextArtifacts(activeProject, artifactType, scopeFilter, projectFilter string, includeDeleted bool) ([]Artifact, error)
ListVisibleContextArtifacts returns global context plus project context visible to the caller.
func ListVisibleContextArtifactsAllProjects
func ListVisibleContextArtifactsAllProjects(artifactType, scopeFilter string, includeDeleted bool) ([]Artifact, error)
ListVisibleContextArtifactsAllProjects returns global and project-scoped context across every project.
type ArtifactReadQuery
ArtifactReadQuery describes the current local list/show read behavior.
type ArtifactReadQuery struct {
Author string
Source string
Limit int
MetaFilters map[string]string
IncludeDeleted bool
}
type ArtifactReadStore
ArtifactReadStore isolates the legacy SQL-backed list/show read path.
type ArtifactReadStore struct {
// contains filtered or unexported fields
}
func NewArtifactReadStore
func NewArtifactReadStore(db *sql.DB) *ArtifactReadStore
NewArtifactReadStore constructs a read store using the provided database handle.
func (*ArtifactReadStore) GetIntentRecord
func (s *ArtifactReadStore) GetIntentRecord(ctx context.Context, id string) (model.IntentRecord, error)
GetIntentRecord returns the current local show record with existing not-found behavior preserved.
func (*ArtifactReadStore) ListIntentRecords
func (s *ArtifactReadStore) ListIntentRecords(ctx context.Context, query ArtifactReadQuery) ([]model.IntentRecord, error)
ListIntentRecords returns current list/show records with existing filter semantics preserved.
type ArtifactWriteStore
ArtifactWriteStore is the internal write boundary for current local artifact, capture, and tombstone writes.
type ArtifactWriteStore struct {
// contains filtered or unexported fields
}
func NewArtifactWriteStore
func NewArtifactWriteStore(db *sql.DB) *ArtifactWriteStore
NewArtifactWriteStore creates a local artifact write boundary over db.
func (*ArtifactWriteStore) CreateArtifact
func (s *ArtifactWriteStore) CreateArtifact(ctx context.Context, input storage.CreateArtifactInput) (Artifact, error)
CreateArtifact stores an artifact through the provider-compatible SQLite path.
func (*ArtifactWriteStore) CreateCapture
func (s *ArtifactWriteStore) CreateCapture(ctx context.Context, input CaptureWriteInput) (model.IntentRecord, error)
CreateCapture stores a local capture using current intent ledger semantics.
func (*ArtifactWriteStore) Restore
func (s *ArtifactWriteStore) Restore(ctx context.Context, id string) error
Restore removes current tombstone metadata from an intent or artifact.
func (*ArtifactWriteStore) Tombstone
func (s *ArtifactWriteStore) Tombstone(ctx context.Context, id string, cascade, force bool) ([]string, error)
Tombstone marks an intent or artifact deleted using current metadata column rules.
type CaptureWriteInput
CaptureWriteInput captures the current local prompt/response write shape.
type CaptureWriteInput struct {
Author string
SourceType string
Title string
Prompt string
Response string
Meta json.RawMessage
Project string
PrevHash string
}
type ChainResult
ChainResult captures current deterministic chain traversal output.
type ChainResult struct {
HeadID string
Length int
Intents []model.IntentRecord
MissingLinks []string
}
func ChainIntent
func ChainIntent(ctx context.Context, provider storage.Provider, id string) (ChainResult, error)
ChainIntent preserves current provider-backed chain traversal semantics.
type Checkpoint
Checkpoint represents an immutable checkpoint artifact.
type Checkpoint struct {
Project string `json:"project"`
Summary string `json:"summary"`
CreatedAt string `json:"created_at"`
ArtifactIDs []string `json:"artifact_ids"`
PreviousCheckpointID string `json:"previous_checkpoint_id,omitempty"`
Hash string `json:"hash"`
}
func CreateCheckpoint
func CreateCheckpoint(ctx context.Context, db *sql.DB, project, summary string, artifactIDs []string) (Checkpoint, error)
CreateCheckpoint is a convenience wrapper for CheckpointStore.CreateCheckpoint.
func CreateProjectCheckpoint
func CreateProjectCheckpoint(project, summary string, artifactIDs []string) (Checkpoint, error)
CreateProjectCheckpoint creates a checkpoint for the provided project using the current local provider.
func ListAllCheckpoints
func ListAllCheckpoints(ctx context.Context, db *sql.DB) ([]Checkpoint, error)
ListAllCheckpoints is a convenience wrapper for all-project checkpoint listing.
func ListAllProjectCheckpoints
func ListAllProjectCheckpoints() ([]Checkpoint, error)
ListAllProjectCheckpoints lists checkpoints across all projects using the current local provider.
func ListCheckpoints
func ListCheckpoints(ctx context.Context, db *sql.DB, project string) ([]Checkpoint, error)
ListCheckpoints is a convenience wrapper for CheckpointStore.ListCheckpoints.
func ListProjectCheckpoints
func ListProjectCheckpoints(project string) ([]Checkpoint, error)
ListProjectCheckpoints lists checkpoints for a single project using the current local provider.
func (Checkpoint) Normalize
func (c Checkpoint) Normalize() Checkpoint
Normalize returns a copy with normalized fields for deterministic hashing/storage.
func (Checkpoint) Validate
func (c Checkpoint) Validate() error
Validate checks required fields for a checkpoint record.
type CheckpointStore
CheckpointStore provides persistence for checkpoints.
type CheckpointStore struct {
// contains filtered or unexported fields
}
func NewCheckpointStore
func NewCheckpointStore(db *sql.DB) *CheckpointStore
NewCheckpointStore constructs a CheckpointStore using the provided database handle.
func (*CheckpointStore) CreateCheckpoint
func (s *CheckpointStore) CreateCheckpoint(ctx context.Context, project, summary string, artifactIDs []string) (Checkpoint, error)
CreateCheckpoint creates a new checkpoint artifact for a project.
func (*CheckpointStore) ListCheckpoints
func (s *CheckpointStore) ListCheckpoints(ctx context.Context, project string) ([]Checkpoint, error)
ListCheckpoints returns checkpoints for a project ordered by creation time, newest first.
type CheckpointValidationError
CheckpointValidationError reports invalid checkpoint input.
type CheckpointValidationError struct {
Field string
Message string
}
func (CheckpointValidationError) Error
func (e CheckpointValidationError) Error() string
Error returns the validation error as "\<field> \<message>".
type ExportLogFormat
ExportLogFormat is the current API/CLI log export format selector.
type ExportLogFormat string
const (
ExportLogFormatMarkdown ExportLogFormat = "markdown"
ExportLogFormatJSON ExportLogFormat = "json"
ExportLogFormatHTML ExportLogFormat = "html"
)
type Intent
Intent represents an intent artifact loaded from the intents table for rehydration.
type Intent struct {
ID string
CreatedAt time.Time
Author string
SourceType string
Title string
Prompt string
Response string
Meta json.RawMessage
PrevHash string
Hash string
}
type Project
Project represents a named project namespace in the library ledger.
type Project struct {
Name string
Description string
CreatedAt time.Time
}
func CreateProject
func CreateProject(name string, description string) (*Project, error)
CreateProject creates a unique project record and returns the created project.
func ListProjects
func ListProjects() ([]Project, error)
ListProjects returns all projects ordered by creation time, oldest first.
type ProjectNotFoundError
ProjectNotFoundError indicates the referenced project was not found.
type ProjectNotFoundError struct {
Name string
}
func (ProjectNotFoundError) Error
func (e ProjectNotFoundError) Error() string
Error returns the project-not-found message including the project name.
type RehydratePayload
RehydratePayload contains the checkpoint boundary or fallback state and the ordered intents to render.
type RehydratePayload struct {
Project string
LatestCheckpoint *Checkpoint
Intents []Intent
Fallback bool
FallbackReason string
FallbackLimit int
}
func RehydrateProject
func RehydrateProject(project string) (*RehydratePayload, error)
RehydrateProject loads the latest checkpoint and subsequent intents for a project.
If no checkpoint exists, the payload falls back to the latest project intents so operational continuity remains available during recovery.
func RehydrateProjectWithFallback
func RehydrateProjectWithFallback(project string, fallbackLimit int) (*RehydratePayload, error)
RehydrateProjectWithFallback loads checkpoint-based rehydration data or a recent-capture fallback.
type RehydrationService
RehydrationService isolates the current SQL-backed rehydration flow.
type RehydrationService struct {
// contains filtered or unexported fields
}
func NewRehydrationService
func NewRehydrationService(db *sql.DB) *RehydrationService
NewRehydrationService constructs a rehydration service around the provided database handle.
func (*RehydrationService) RehydrateProject
func (s *RehydrationService) RehydrateProject(ctx context.Context, project string) (*RehydratePayload, error)
RehydrateProject loads the latest checkpoint and subsequent intents for a project.
func (*RehydrationService) RehydrateProjectWithFallback
func (s *RehydrationService) RehydrateProjectWithFallback(ctx context.Context, project string, fallbackLimit int) (*RehydratePayload, error)
RehydrateProjectWithFallback loads checkpoint-based rehydration data or a recent-capture fallback.
type VerifyResult
VerifyResult captures current deterministic verification output.
type VerifyResult struct {
ID string
Valid bool
StoredHash string
ComputedHash string
PrevHash string
Error *string
}
func VerifyIntent
func VerifyIntent(ctx context.Context, provider storage.Provider, id string) (VerifyResult, error)
VerifyIntent preserves current provider-backed verification semantics.
projectstate
import "github.com/chuxorg/yanzi/internal/projectstate"
Index
- func LoadActiveProject() (string, error)
- func SaveActiveProject(name string) error
- func WriteProjectBinding(name string) error
func LoadActiveProject
func LoadActiveProject() (string, error)
LoadActiveProject resolves the active project using the current binding and state-file precedence.
func SaveActiveProject
func SaveActiveProject(name string) error
SaveActiveProject persists the active project in the current user state directory.
func WriteProjectBinding
func WriteProjectBinding(name string) error
WriteProjectBinding persists the current working-directory binding used by init and project workflows.
runtime
import "github.com/chuxorg/yanzi/internal/runtime"
Index
- type Instance
- func (i *Instance) Addr() string
- func (i *Instance) Shutdown(ctx context.Context) error
- func (i *Instance) StartedAt() time.Time
- func (i *Instance) Wait() error
- type Options
- type Runtime
- func New(opts Options) *Runtime
- func (r *Runtime) Start() (*Instance, error)
type Instance
Instance represents a started runtime server.
type Instance struct {
// contains filtered or unexported fields
}
func (*Instance) Addr
func (i *Instance) Addr() string
Addr returns the bound listener address.
func (*Instance) Shutdown
func (i *Instance) Shutdown(ctx context.Context) error
Shutdown stops the runtime server with a bounded grace period.
func (*Instance) StartedAt
func (i *Instance) StartedAt() time.Time
StartedAt returns the runtime startup timestamp.
func (*Instance) Wait
func (i *Instance) Wait() error
Wait returns the background server error or nil after shutdown.
type Options
Options captures the minimal runtime bootstrap inputs.
type Options struct {
Addr string
Version string
RuntimeMode string
ShutdownTimeout time.Duration
Dependencies handlers.Dependencies
}
type Runtime
Runtime owns a lightweight shared operational API server.
type Runtime struct {
// contains filtered or unexported fields
}
func New
func New(opts Options) *Runtime
New constructs a runtime bootstrap wrapper around the operational API server.
func (*Runtime) Start
func (r *Runtime) Start() (*Instance, error)
Start binds the runtime listener and begins serving requests in the background.
storage
import "github.com/chuxorg/yanzi/internal/storage"
Index
- Constants
- Variables
- type Artifact
- type ArtifactOperations
- type ArtifactQuery
- type Checkpoint
- type CheckpointOperations
- type CheckpointQuery
- type ContextArtifactQuery
- type CreateArtifactInput
- type CreateCheckpointInput
- type CreateProjectInput
- type ExportCapture
- type ExportItem
- type ExportItemKind
- type ExportMeta
- type ExportQuery
- type Health
- type HealthStatus
- type ImportExportOperations
- type IntentRecord
- type Project
- type ProjectOperations
- type ProjectQuery
- type Provider
- type ProviderName
- type VerificationOperations
- type VerificationQuery
Constants
const (
// ArtifactClassIntent is the current intent artifact class.
ArtifactClassIntent = "intent"
// ArtifactClassContext is the current context artifact class.
ArtifactClassContext = "context"
// ContextScopeGlobal is the current globally visible context scope.
ContextScopeGlobal = "global"
// ContextScopeProject is the current project-visible context scope.
ContextScopeProject = "project"
)
Variables
var (
// ErrProviderUnavailable indicates that a provider cannot service requests.
ErrProviderUnavailable = errors.New("storage provider unavailable")
// ErrUnsupportedProvider indicates that provider selection requested an implementation not present in this build.
ErrUnsupportedProvider = errors.New("unsupported storage provider")
// ErrNotFound indicates that a requested storage record does not exist.
ErrNotFound = errors.New("storage record not found")
)
type Artifact
Artifact is the provider-level artifact record used by current storage behavior.
type Artifact struct {
ID string
Class string
Type string
Scope string
Project string
Title string
Content string
Metadata string
CreatedAt string
}
type ArtifactOperations
ArtifactOperations represents artifact persistence and retrieval capability.
type ArtifactOperations interface {
Artifacts() bool
CreateArtifact(context.Context, CreateArtifactInput) (Artifact, error)
ListArtifacts(context.Context, ArtifactQuery) ([]Artifact, error)
ListVisibleContextArtifacts(context.Context, ContextArtifactQuery) ([]Artifact, error)
GetVisibleContextArtifact(context.Context, string, string) (Artifact, error)
}
type ArtifactQuery
ArtifactQuery captures the current artifact list dimensions.
type ArtifactQuery struct {
Project string
Class string
Type string
IncludeDeleted bool
}
type Checkpoint
Checkpoint is the provider-level checkpoint record used by current storage behavior.
type Checkpoint struct {
Project string
Summary string
CreatedAt string
ArtifactIDs []string
PreviousCheckpointID string
Hash string
}
type CheckpointOperations
CheckpointOperations represents checkpoint persistence and retrieval capability.
type CheckpointOperations interface {
Checkpoints() bool
CreateCheckpoint(context.Context, CreateCheckpointInput) (Checkpoint, error)
ListCheckpoints(context.Context, string) ([]Checkpoint, error)
ListAllCheckpoints(context.Context) ([]Checkpoint, error)
}
type CheckpointQuery
CheckpointQuery captures current checkpoint list dimensions.
type CheckpointQuery struct {
Project string
}
type ContextArtifactQuery
ContextArtifactQuery captures current context visibility dimensions.
type ContextArtifactQuery struct {
ActiveProject string
Type string
Scope string
Project string
IncludeDeleted bool
AllProjects bool
}
type CreateArtifactInput
CreateArtifactInput captures current artifact creation inputs.
type CreateArtifactInput struct {
Project string
Class string
Type string
Scope string
Title string
Content string
Metadata string
}
type CreateCheckpointInput
CreateCheckpointInput captures current checkpoint creation inputs.
type CreateCheckpointInput struct {
Project string
Summary string
ArtifactIDs []string
}
type CreateProjectInput
CreateProjectInput captures current project creation inputs.
type CreateProjectInput struct {
Name string
Description string
}
type ExportCapture
ExportCapture is the provider-level capture payload used by current export renderers.
type ExportCapture struct {
ID string
CreatedAt string
Author string
Source string
Title string
Hash string
Prompt string
Response string
Metadata map[string]string
}
type ExportItem
ExportItem is the provider-level event used by current deterministic exports.
type ExportItem struct {
Kind ExportItemKind
Timestamp string
RowID int64
Capture ExportCapture
Checkpoint Checkpoint
Meta ExportMeta
}
type ExportItemKind
ExportItemKind identifies the current export timeline item category.
type ExportItemKind string
const (
// ExportItemCheckpoint is a checkpoint boundary in a deterministic export.
ExportItemCheckpoint ExportItemKind = "checkpoint"
// ExportItemCapture is a captured prompt/response record in a deterministic export.
ExportItemCapture ExportItemKind = "capture"
// ExportItemMeta is a current meta-command/event record in a deterministic export.
ExportItemMeta ExportItemKind = "meta"
)
type ExportMeta
ExportMeta is the provider-level meta event payload used by current export renderers.
type ExportMeta struct {
CreatedAt string
Command string
Value string
}
type ExportQuery
ExportQuery captures current deterministic local export dimensions.
type ExportQuery struct {
Project string
MetaFilters map[string]string
IncludeDeleted bool
}
type Health
Health describes the internal provider health state.
type Health struct {
Provider ProviderName
Status HealthStatus
Path string
Error string
}
type HealthStatus
HealthStatus reports internal provider readiness without exposing a CLI surface.
type HealthStatus string
const (
HealthReady HealthStatus = "ready"
HealthUnavailable HealthStatus = "unavailable"
)
type ImportExportOperations
ImportExportOperations represents deterministic local import/export capability.
type ImportExportOperations interface {
ImportExport() bool
ListExportItems(context.Context, ExportQuery) ([]ExportItem, int, error)
}
type IntentRecord
IntentRecord is the provider-level form of the current intent record used by verification reads.
type IntentRecord struct {
ID string
CreatedAt string
Author string
SourceType string
Title string
Prompt string
Response string
Meta json.RawMessage
PrevHash string
Hash string
}
type Project
Project is the provider-level project record used by current storage behavior.
type Project struct {
Name string
Description string
CreatedAt time.Time
}
type ProjectOperations
ProjectOperations represents project persistence and retrieval capability.
type ProjectOperations interface {
Projects() bool
CreateProject(context.Context, CreateProjectInput) (Project, error)
ListProjects(context.Context) ([]Project, error)
ProjectExists(context.Context, string) (bool, error)
}
type ProjectQuery
ProjectQuery captures current project lookup dimensions.
type ProjectQuery struct {
Name string
}
type Provider
Provider is the current internal storage boundary.
The SQLDB method intentionally preserves existing SQLite-backed call sites for CAP-001 Phase 1. Future phases can move operations behind narrower methods without changing CLI contracts.
type Provider interface {
ArtifactOperations
ProjectOperations
CheckpointOperations
VerificationOperations
ImportExportOperations
Name() ProviderName
Health(context.Context) Health
SQLDB() *sql.DB
Close() error
}
type ProviderName
ProviderName identifies a storage provider implementation.
type ProviderName string
const (
// ProviderSQLite is the embedded local SQLite provider.
ProviderSQLite ProviderName = "sqlite"
)
type VerificationOperations
VerificationOperations represents local digest verification capability.
type VerificationOperations interface {
Verification() bool
GetVerificationIntent(context.Context, string) (IntentRecord, error)
GetVerificationIntentByHash(context.Context, string) (IntentRecord, error)
}
type VerificationQuery
VerificationQuery captures current hash verification dimensions.
type VerificationQuery struct {
ID string
}
handlers
import "github.com/chuxorg/yanzi/internal/api/handlers"
Index
- func NewArtifactHandler(deps Dependencies) http.Handler
- func NewCheckpointsHandler(deps Dependencies) http.Handler
- func NewCurrentProjectHandler(deps Dependencies) http.Handler
- func NewDeferredRouteHandler(group string) http.Handler
- func NewExportHandler(deps Dependencies) http.Handler
- func NewHealthHandler(deps Dependencies) http.Handler
- func NewProjectsHandler(deps Dependencies) http.Handler
- func NewRehydrateHandler(deps Dependencies) http.Handler
- func NewVerifyHandler(deps Dependencies) http.Handler
- type ActiveProjectLoadFunc
- type ArtifactReadOpenFunc
- type ArtifactReadStore
- type ConfigLoadFunc
- type Dependencies
- type ProviderOpenFunc
- type RuntimeStatusFunc
func NewArtifactHandler
func NewArtifactHandler(deps Dependencies) http.Handler
NewArtifactHandler returns the current artifact capture/read API handler.
func NewCheckpointsHandler
func NewCheckpointsHandler(deps Dependencies) http.Handler
NewCheckpointsHandler returns the provider-backed checkpoint collection handler.
func NewCurrentProjectHandler
func NewCurrentProjectHandler(deps Dependencies) http.Handler
NewCurrentProjectHandler returns the active-project read/write handler.
func NewDeferredRouteHandler
func NewDeferredRouteHandler(group string) http.Handler
NewDeferredRouteHandler returns a deterministic placeholder for deferred route groups.
func NewExportHandler
func NewExportHandler(deps Dependencies) http.Handler
NewExportHandler returns the deterministic export read API handler.
func NewHealthHandler
func NewHealthHandler(deps Dependencies) http.Handler
NewHealthHandler returns the minimal GET /v0/health handler.
func NewProjectsHandler
func NewProjectsHandler(deps Dependencies) http.Handler
NewProjectsHandler returns the provider-backed project collection handler.
func NewRehydrateHandler
func NewRehydrateHandler(deps Dependencies) http.Handler
NewRehydrateHandler returns the deterministic GET /v0/rehydrate handler.
func NewVerifyHandler
func NewVerifyHandler(deps Dependencies) http.Handler
NewVerifyHandler returns the verification read API handler.
type ActiveProjectLoadFunc
ActiveProjectLoadFunc loads the current active project for API handlers.
type ActiveProjectLoadFunc func() (string, error)
type ArtifactReadOpenFunc
ArtifactReadOpenFunc opens the current artifact read boundary for API handlers.
type ArtifactReadOpenFunc func(context.Context, config.Config) (ArtifactReadStore, io.Closer, error)
type ArtifactReadStore
ArtifactReadStore exposes the current read-only behavior required by artifact handlers.
type ArtifactReadStore interface {
ListIntentRecords(context.Context, yanzilibrary.ArtifactReadQuery) ([]model.IntentRecord, error)
GetIntentRecord(context.Context, string) (model.IntentRecord, error)
}
type ConfigLoadFunc
ConfigLoadFunc loads the current Yanzi configuration for API handlers.
type ConfigLoadFunc func() (config.Config, error)
type Dependencies
Dependencies captures the lightweight handler dependencies used by the API foundation.
type Dependencies struct {
Version string
LoadConfig ConfigLoadFunc
OpenProvider ProviderOpenFunc
CreateProject func(string, string) (*yanzilibrary.Project, error)
ListProjects func() ([]yanzilibrary.Project, error)
ProjectExists func(string) (bool, error)
LoadActiveProject ActiveProjectLoadFunc
SaveActiveProject func(string) error
CreateCheckpoint func(string, string, []string) (yanzilibrary.Checkpoint, error)
ListCheckpoints func(string) ([]yanzilibrary.Checkpoint, error)
ListAllCheckpoints func() ([]yanzilibrary.Checkpoint, error)
OpenArtifactReadStore ArtifactReadOpenFunc
Now func() time.Time
RuntimeStatus RuntimeStatusFunc
}
type ProviderOpenFunc
ProviderOpenFunc opens the current storage provider for API handlers.
type ProviderOpenFunc func(context.Context, config.Config) (storage.Provider, error)
type RuntimeStatusFunc
RuntimeStatusFunc reports the currently active runtime bootstrap visibility.
type RuntimeStatusFunc func() *models.RuntimeHealth
middleware
import "github.com/chuxorg/yanzi/internal/api/middleware"
Index
func AllowMethods
func AllowMethods(next http.Handler, methods ...string) http.Handler
AllowMethods restricts a handler to the provided HTTP methods.
models
import "github.com/chuxorg/yanzi/internal/api/models"
Index
- type Artifact
- type ArtifactCaptureRequest
- type ArtifactCaptureResponse
- type ArtifactListResponse
- type ArtifactResponse
- type ArtifactSummary
- type ChainResponse
- type Checkpoint
- type CheckpointCreateRequest
- type CheckpointListResponse
- type CurrentProjectRequest
- type CurrentProjectResponse
- type HealthResponse
- type Project
- type ProjectCreateRequest
- type ProjectListResponse
- type ProviderHealth
- type RehydrateCheckpoint
- type RehydrateIntent
- type RehydrateResponse
- type RuntimeHealth
- type StatusResponse
- type VerifyResponse
type Artifact
Artifact represents the current operational API artifact detail payload.
type Artifact struct {
ID string `json:"id"`
CreatedAt string `json:"created_at"`
Project string `json:"project,omitempty"`
Author string `json:"author"`
Source string `json:"source"`
Title string `json:"title"`
Prompt string `json:"prompt"`
Response string `json:"response"`
Metadata map[string]string `json:"metadata,omitempty"`
PrevHash string `json:"prev_hash,omitempty"`
Hash string `json:"hash"`
}
type ArtifactCaptureRequest
ArtifactCaptureRequest captures the POST /v0/artifacts capture payload.
type ArtifactCaptureRequest struct {
Author string `json:"author"`
SourceType string `json:"source_type,omitempty"`
Title string `json:"title,omitempty"`
Prompt string `json:"prompt"`
Response string `json:"response"`
Metadata map[string]string `json:"metadata,omitempty"`
Project string `json:"project,omitempty"`
PrevHash string `json:"prev_hash,omitempty"`
}
type ArtifactCaptureResponse
ArtifactCaptureResponse is the deterministic capture artifact response.
type ArtifactCaptureResponse struct {
ID string `json:"id"`
CreatedAt string `json:"created_at"`
Author string `json:"author"`
SourceType string `json:"source_type"`
Title string `json:"title,omitempty"`
Prompt string `json:"prompt"`
Response string `json:"response"`
Metadata map[string]string `json:"metadata,omitempty"`
PrevHash string `json:"prev_hash,omitempty"`
Hash string `json:"hash"`
}
type ArtifactListResponse
ArtifactListResponse is the collection response for artifact queries.
type ArtifactListResponse struct {
Artifacts []ArtifactSummary `json:"artifacts"`
}
type ArtifactResponse
ArtifactResponse is the detail response for artifact reads.
type ArtifactResponse struct {
Artifact Artifact `json:"artifact"`
}
type ArtifactSummary
ArtifactSummary represents the current operational API artifact list payload.
type ArtifactSummary struct {
ID string `json:"id"`
CreatedAt string `json:"created_at"`
Project string `json:"project,omitempty"`
Author string `json:"author"`
Source string `json:"source"`
Title string `json:"title"`
Metadata map[string]string `json:"metadata,omitempty"`
}
type ChainResponse
ChainResponse captures deterministic chain traversal output.
type ChainResponse struct {
HeadID string `json:"head_id"`
Length int `json:"length"`
Intents []ArtifactCaptureResponse `json:"intents"`
MissingLinks []string `json:"missing_links,omitempty"`
}
type Checkpoint
Checkpoint represents the current operational API checkpoint payload.
type Checkpoint struct {
Hash string `json:"hash"`
Project string `json:"project"`
Summary string `json:"summary"`
CreatedAt string `json:"created_at"`
ArtifactIDs []string `json:"artifact_ids,omitempty"`
PreviousCheckpointID string `json:"previous_checkpoint_id,omitempty"`
}
type CheckpointCreateRequest
CheckpointCreateRequest captures the current checkpoint creation shape.
type CheckpointCreateRequest struct {
Project string `json:"project"`
Summary string `json:"summary"`
ArtifactIDs []string `json:"artifact_ids,omitempty"`
}
type CheckpointListResponse
CheckpointListResponse is the collection response for checkpoint queries.
type CheckpointListResponse struct {
Checkpoints []Checkpoint `json:"checkpoints"`
}
type CurrentProjectRequest
CurrentProjectRequest captures the active-project update shape.
type CurrentProjectRequest struct {
Name string `json:"name"`
}
type CurrentProjectResponse
CurrentProjectResponse is the active-project read response.
type CurrentProjectResponse struct {
Project *Project `json:"project"`
}
type HealthResponse
HealthResponse is the minimal operational health/status response.
type HealthResponse struct {
Version string `json:"version"`
Mode string `json:"mode"`
Runtime *RuntimeHealth `json:"runtime,omitempty"`
Provider ProviderHealth `json:"provider"`
}
type Project
Project represents the current operational API project payload.
type Project struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
CreatedAt string `json:"created_at"`
}
type ProjectCreateRequest
ProjectCreateRequest captures the current project creation shape.
type ProjectCreateRequest struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
}
type ProjectListResponse
ProjectListResponse is the collection response for project queries.
type ProjectListResponse struct {
Projects []Project `json:"projects"`
}
type ProviderHealth
ProviderHealth represents the current provider health payload for API status reads.
type ProviderHealth struct {
Name string `json:"name"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
}
type RehydrateCheckpoint
RehydrateCheckpoint represents the current operational API rehydration checkpoint payload.
type RehydrateCheckpoint struct {
Hash string `json:"hash"`
Project string `json:"project"`
Summary string `json:"summary"`
CreatedAt string `json:"created_at"`
ArtifactIDs []string `json:"artifact_ids,omitempty"`
PreviousCheckpointID string `json:"previous_checkpoint_id,omitempty"`
}
type RehydrateIntent
RehydrateIntent represents the current operational API rehydration intent payload.
type RehydrateIntent struct {
ID string `json:"id"`
Timestamp string `json:"timestamp"`
Author string `json:"author"`
SourceType string `json:"source_type"`
Title string `json:"title,omitempty"`
Prompt string `json:"prompt"`
Response string `json:"response"`
PromptSnippet string `json:"prompt_snippet"`
ResponseSnippet string `json:"response_snippet"`
Metadata map[string]string `json:"metadata,omitempty"`
Hash string `json:"hash"`
PrevHash string `json:"prev_hash,omitempty"`
}
type RehydrateResponse
RehydrateResponse is the deterministic operational API rehydration payload.
type RehydrateResponse struct {
Project string `json:"project"`
HasCheckpoint bool `json:"has_checkpoint"`
Fallback bool `json:"fallback"`
FallbackReason string `json:"fallback_reason,omitempty"`
FallbackLimit int `json:"fallback_limit,omitempty"`
Checkpoint *RehydrateCheckpoint `json:"checkpoint,omitempty"`
Intents []RehydrateIntent `json:"intents"`
}
type RuntimeHealth
RuntimeHealth represents the current runtime bootstrap visibility payload.
type RuntimeHealth struct {
Mode string `json:"mode"`
StartedAt string `json:"started_at,omitempty"`
}
type StatusResponse
StatusResponse is the generic deterministic status payload for non-CRUD route groups.
type StatusResponse struct {
Status string `json:"status"`
Message string `json:"message"`
}
type VerifyResponse
VerifyResponse captures deterministic verification read output.
type VerifyResponse struct {
ID string `json:"id"`
Valid bool `json:"valid"`
StoredHash string `json:"stored_hash"`
ComputedHash string `json:"computed_hash"`
PrevHash string `json:"prev_hash"`
Error *string `json:"error,omitempty"`
}
responses
import "github.com/chuxorg/yanzi/internal/api/responses"
Index
- func WriteError(w http.ResponseWriter, status int, code, message string)
- func WriteJSON(w http.ResponseWriter, status int, value any)
- type ErrorBody
- type ErrorDetail
func WriteError
func WriteError(w http.ResponseWriter, status int, code, message string)
WriteError writes a deterministic JSON error response.
func WriteJSON
func WriteJSON(w http.ResponseWriter, status int, value any)
WriteJSON writes a JSON response with the provided status code.
type ErrorBody
ErrorBody is the deterministic API error response envelope.
type ErrorBody struct {
Error ErrorDetail `json:"error"`
}
type ErrorDetail
ErrorDetail is the machine-readable operational API error payload.
type ErrorDetail struct {
Code string `json:"code"`
Message string `json:"message"`
}
routes
import "github.com/chuxorg/yanzi/internal/api/routes"
Index
func NewHandler
func NewHandler(deps handlers.Dependencies) http.Handler
NewHandler constructs the operational API route foundation.
server
import "github.com/chuxorg/yanzi/internal/api/server"
Index
- type LocalOptions
- type Options
- type Server
- func New(opts Options) *Server
- func NewLocal(opts LocalOptions) *Server
- func (s *Server) HTTPServer() *http.Server
- func (s *Server) Handler() http.Handler
- func (s *Server) Serve(listener net.Listener) error
- func (s *Server) Shutdown(ctx context.Context) error
type LocalOptions
LocalOptions captures the local-only operational API server construction inputs.
type LocalOptions struct {
Addr string
Version string
ReadHeaderTimeout time.Duration
Dependencies handlers.Dependencies
}
type Options
Options captures the minimal HTTP server configuration for the operational API.
type Options struct {
Addr string
Handler http.Handler
ReadHeaderTimeout time.Duration
}
type Server
Server is the lightweight internal HTTP server foundation for the operational API.
type Server struct {
// contains filtered or unexported fields
}
func New
func New(opts Options) *Server
New constructs an internal operational API server with conservative defaults.
func NewLocal
func NewLocal(opts LocalOptions) *Server
NewLocal constructs a server wired to the current operational API route foundation.
func (*Server) HTTPServer
func (s *Server) HTTPServer() *http.Server
HTTPServer exposes the underlying net/http server for controlled internal use.
func (*Server) Handler
func (s *Server) Handler() http.Handler
Handler returns the server handler used to process HTTP requests.
func (*Server) Serve
func (s *Server) Serve(listener net.Listener) error
Serve starts the HTTP server on the provided listener.
func (*Server) Shutdown
func (s *Server) Shutdown(ctx context.Context) error
Shutdown gracefully stops the HTTP server.
hash
import "github.com/chuxorg/yanzi/internal/core/hash"
Package hash provides deterministic intent hashing logic.
Index
- func CanonicalizeMeta(raw json.RawMessage) (json.RawMessage, error)
- func HashIntent(record model.IntentRecord) (string, error)
func CanonicalizeMeta
func CanonicalizeMeta(raw json.RawMessage) (json.RawMessage, error)
CanonicalizeMeta re-encodes a JSON object with sorted keys.
func HashIntent
func HashIntent(record model.IntentRecord) (string, error)
HashIntent computes a deterministic SHA-256 hash for an IntentRecord. The hash preimage excludes the hash field and uses canonical field order.
model
import "github.com/chuxorg/yanzi/internal/core/model"
Package model provides shared data model types.
Index
- type IntentRecord
- func (r IntentRecord) Normalize() IntentRecord
- func (r IntentRecord) Validate() error
type IntentRecord
IntentRecord represents the v0 intent schema persisted and shared across services.
type IntentRecord struct {
ID string `json:"id"`
CreatedAt string `json:"created_at"`
Author string `json:"author"`
SourceType string `json:"source_type"`
Title string `json:"title,omitempty"`
Prompt string `json:"prompt"`
Response string `json:"response"`
Meta json.RawMessage `json:"meta,omitempty"`
PrevHash string `json:"prev_hash,omitempty"`
Hash string `json:"hash"`
}
func (IntentRecord) Normalize
func (r IntentRecord) Normalize() IntentRecord
Normalize returns a copy with normalized fields for deterministic hashing/storage.
func (IntentRecord) Validate
func (r IntentRecord) Validate() error
Validate checks required fields for the v0 schema.
store
import "github.com/chuxorg/yanzi/internal/core/store"
Package store provides a SQLite persistence layer.
Index
- func FilterIntentsByMeta(intents []model.IntentRecord, filters map[string]string) ([]model.IntentRecord, error)
- type Store
- func Open(path string) (*Store, error)
- func (s *Store) Close() error
- func (s *Store) CreateIntent(ctx context.Context, record model.IntentRecord) error
- func (s *Store) GetIntent(ctx context.Context, id string) (model.IntentRecord, error)
- func (s *Store) GetIntentByHash(ctx context.Context, hash string) (model.IntentRecord, error)
- func (s *Store) ListIntents(ctx context.Context, limit int) ([]model.IntentRecord, error)
- func (s *Store) Migrate(ctx context.Context) error
func FilterIntentsByMeta
func FilterIntentsByMeta(intents []model.IntentRecord, filters map[string]string) ([]model.IntentRecord, error)
FilterIntentsByMeta returns intents that match all meta filters (AND semantics).
type Store
Store provides CRUD and migration operations for intent persistence.
type Store struct {
// contains filtered or unexported fields
}
func Open
func Open(path string) (*Store, error)
Open creates a SQLite-backed Store with required runtime pragmas enabled.
func (*Store) Close
func (s *Store) Close() error
func (*Store) CreateIntent
func (s *Store) CreateIntent(ctx context.Context, record model.IntentRecord) error
func (*Store) GetIntent
func (s *Store) GetIntent(ctx context.Context, id string) (model.IntentRecord, error)
func (*Store) GetIntentByHash
func (s *Store) GetIntentByHash(ctx context.Context, hash string) (model.IntentRecord, error)
GetIntentByHash loads an intent by its hash for chain traversal.
func (*Store) ListIntents
func (s *Store) ListIntents(ctx context.Context, limit int) ([]model.IntentRecord, error)
func (*Store) Migrate
func (s *Store) Migrate(ctx context.Context) error
registry
import "github.com/chuxorg/yanzi/internal/storage/registry"
Index
- func EnsureLocalStateDir() error
- func Open(ctx context.Context, cfg config.Config, opts Options) (storage.Provider, error)
- func OpenAtPath(ctx context.Context, path string, opts Options) (storage.Provider, bool, error)
- func ValidateProviderName(name string) error
- type Options
func EnsureLocalStateDir
func EnsureLocalStateDir() error
EnsureLocalStateDir preserves existing local SQLite directory creation.
func Open
func Open(ctx context.Context, cfg config.Config, opts Options) (storage.Provider, error)
Open returns the configured storage provider.
CAP-001 Phase 1 supports SQLite only and preserves existing local db_path resolution. No provider config key is active yet.
func OpenAtPath
func OpenAtPath(ctx context.Context, path string, opts Options) (storage.Provider, bool, error)
OpenAtPath returns the SQLite provider at a specific path.
func ValidateProviderName
func ValidateProviderName(name string) error
ValidateProviderName rejects future provider names until implementations exist.
type Options
Options contains provider construction inputs that are not user-facing config.
type Options struct {
Migrations fs.FS
}
sqlite
import "github.com/chuxorg/yanzi/internal/storage/sqlite"
Index
- type Provider
- func FromDB(db *sql.DB) *Provider
- func Open(ctx context.Context, path string, migrations fs.FS) (*Provider, bool, error)
- func (p *Provider) Artifacts() bool
- func (p *Provider) Checkpoints() bool
- func (p *Provider) Close() error
- func (p *Provider) CreateArtifact(ctx context.Context, input storage.CreateArtifactInput) (storage.Artifact, error)
- func (p *Provider) CreateCheckpoint(ctx context.Context, input storage.CreateCheckpointInput) (storage.Checkpoint, error)
- func (p *Provider) CreateProject(ctx context.Context, input storage.CreateProjectInput) (storage.Project, error)
- func (p *Provider) GetVerificationIntent(ctx context.Context, id string) (storage.IntentRecord, error)
- func (p *Provider) GetVerificationIntentByHash(ctx context.Context, intentHash string) (storage.IntentRecord, error)
- func (p *Provider) GetVisibleContextArtifact(ctx context.Context, idPrefix, activeProject string) (storage.Artifact, error)
- func (p *Provider) Health(ctx context.Context) storage.Health
- func (p *Provider) ImportExport() bool
- func (p *Provider) ListAllCheckpoints(ctx context.Context) ([]storage.Checkpoint, error)
- func (p *Provider) ListArtifacts(ctx context.Context, query storage.ArtifactQuery) ([]storage.Artifact, error)
- func (p *Provider) ListCheckpoints(ctx context.Context, project string) ([]storage.Checkpoint, error)
- func (p *Provider) ListExportItems(ctx context.Context, query storage.ExportQuery) ([]storage.ExportItem, int, error)
- func (p *Provider) ListProjects(ctx context.Context) ([]storage.Project, error)
- func (p *Provider) ListVisibleContextArtifacts(ctx context.Context, query storage.ContextArtifactQuery) ([]storage.Artifact, error)
- func (p *Provider) Name() storage.ProviderName
- func (p *Provider) ProjectExists(ctx context.Context, name string) (bool, error)
- func (p *Provider) Projects() bool
- func (p *Provider) SQLDB() *sql.DB
- func (p *Provider) Verification() bool
type Provider
Provider is the embedded SQLite storage provider.
type Provider struct {
// contains filtered or unexported fields
}
func FromDB
func FromDB(db *sql.DB) *Provider
FromDB wraps an existing SQLite handle with provider operations.
func Open
func Open(ctx context.Context, path string, migrations fs.FS) (*Provider, bool, error)
Open initializes a SQLite provider at path using the provided migration files.
func (*Provider) Artifacts
func (p *Provider) Artifacts() bool
func (*Provider) Checkpoints
func (p *Provider) Checkpoints() bool
func (*Provider) Close
func (p *Provider) Close() error
Close closes the provider handle.
func (*Provider) CreateArtifact
func (p *Provider) CreateArtifact(ctx context.Context, input storage.CreateArtifactInput) (storage.Artifact, error)
CreateArtifact stores an artifact using current SQLite artifact semantics.
func (*Provider) CreateCheckpoint
func (p *Provider) CreateCheckpoint(ctx context.Context, input storage.CreateCheckpointInput) (storage.Checkpoint, error)
CreateCheckpoint creates a checkpoint using current SQLite checkpoint semantics.
func (*Provider) CreateProject
func (p *Provider) CreateProject(ctx context.Context, input storage.CreateProjectInput) (storage.Project, error)
CreateProject creates a project using current SQLite project semantics.
func (*Provider) GetVerificationIntent
func (p *Provider) GetVerificationIntent(ctx context.Context, id string) (storage.IntentRecord, error)
GetVerificationIntent loads an intent by ID using current verification semantics.
func (*Provider) GetVerificationIntentByHash
func (p *Provider) GetVerificationIntentByHash(ctx context.Context, intentHash string) (storage.IntentRecord, error)
GetVerificationIntentByHash loads an intent by hash using current chain traversal semantics.
func (*Provider) GetVisibleContextArtifact
func (p *Provider) GetVisibleContextArtifact(ctx context.Context, idPrefix, activeProject string) (storage.Artifact, error)
GetVisibleContextArtifact resolves a visible context artifact by full id or unique prefix.
func (*Provider) Health
func (p *Provider) Health(ctx context.Context) storage.Health
Health reports internal readiness for the provider.
func (*Provider) ImportExport
func (p *Provider) ImportExport() bool
func (*Provider) ListAllCheckpoints
func (p *Provider) ListAllCheckpoints(ctx context.Context) ([]storage.Checkpoint, error)
ListAllCheckpoints returns all checkpoints using current CLI all-project ordering.
func (*Provider) ListArtifacts
func (p *Provider) ListArtifacts(ctx context.Context, query storage.ArtifactQuery) ([]storage.Artifact, error)
ListArtifacts lists artifacts using current project/class/type filtering semantics.
func (*Provider) ListCheckpoints
func (p *Provider) ListCheckpoints(ctx context.Context, project string) ([]storage.Checkpoint, error)
ListCheckpoints returns project checkpoints ordered newest first.
func (*Provider) ListExportItems
func (p *Provider) ListExportItems(ctx context.Context, query storage.ExportQuery) ([]storage.ExportItem, int, error)
ListExportItems returns the current SQLite-backed export timeline source data.
func (*Provider) ListProjects
func (p *Provider) ListProjects(ctx context.Context) ([]storage.Project, error)
ListProjects returns projects ordered by creation time, oldest first.
func (*Provider) ListVisibleContextArtifacts
func (p *Provider) ListVisibleContextArtifacts(ctx context.Context, query storage.ContextArtifactQuery) ([]storage.Artifact, error)
ListVisibleContextArtifacts lists context artifacts with current visibility rules.
func (*Provider) Name
func (p *Provider) Name() storage.ProviderName
Name returns the provider identifier.
func (*Provider) ProjectExists
func (p *Provider) ProjectExists(ctx context.Context, name string) (bool, error)
ProjectExists checks whether a project row exists for the provided name.
func (*Provider) Projects
func (p *Provider) Projects() bool
func (*Provider) SQLDB
func (p *Provider) SQLDB() *sql.DB
SQLDB exposes the current SQLite handle for existing local call sites.
func (*Provider) Verification
func (p *Provider) Verification() bool
Generated by gomarkdoc