devcontract

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package devcontract defines native-independent development workspace contracts.

Index

Constants

View Source
const ProtocolVersion = 1
View Source
const SchemaVersion = 1
View Source
const WorkspaceEnvironment = "OMNIVIEW_WORKSPACE_FILE"

Variables

This section is empty.

Functions

func CanonicalPath

func CanonicalPath(path string) (string, error)

CanonicalPath resolves existing symlink ancestors even for not-yet-created paths.

func EnsureDefaultProfileOwnership

func EnsureDefaultProfileOwnership(home, workspaceID string) error

EnsureDefaultProfileOwnership establishes the existing schema-1 .workspace-owner.json contract. Caller MUST hold LockProfile's stable UUID guard; this helper deliberately acquires no nested flock. Only an absent or empty canonical default profile, or its matching existing marker, is accepted. State/runtime/webview children are never created here.

func ExitCode

func ExitCode(err error) int

func FailedReadinessStage

func FailedReadinessStage(build, vite, rpc, controllers string) string

FailedReadinessStage names a terminal producer stage, independently of the caller's generation, LastError, managed mode, and aggregate ready observation. Pending, stopped, and inapplicable capabilities are not producer failures.

func LockProfile

func LockProfile(ctx context.Context, home, workspaceID string) (func() error, error)

LockProfile serializes startup, baseline publication and profile deletion. Its inode is outside the profile tree and must never be removed by cleanup. Acquire this guard before an existing state/.lock; startup may release it only after acquiring that root flock. A missing state root remains missing.

func ProfileGuardPath

func ProfileGuardPath(home, workspaceID string) (string, error)

ProfileGuardPath returns the canonical stable UUID guard location without creating directories or files. Native lifecycle callers open this same inode as LockProfile; no cleanup operation may remove it.

func ProfilePathsOverlap

func ProfilePathsOverlap(a, b string) (bool, error)

ProfilePathsOverlap compares canonical profile paths lexically and by existing directory identity. Endpoint-versus-ancestor checks in both directions detect filesystem case aliases without conflating distinct case-sensitive siblings. Missing endpoints are allowed; other filesystem errors fail closed. It reads only the endpoints and their ancestors, never directory descendants.

func ReadCustomProfileBinding

func ReadCustomProfileBinding(root, workspaceID, home string) (string, bool, error)

ReadCustomProfileBinding validates only the machine-local binding and its durable claim/owner. Lifecycle cleanup supplies the UUID from its ownership receipt, so this reader deliberately does not require a manifest or journal. It creates nothing, and a missing binding is reported separately from invalid or incomplete ownership. Root must be the canonical workspace/retirement path.

func ValidateCustomProfileClaim

func ValidateCustomProfileClaim(stateRoot, workspaceID, home string) error

ValidateCustomProfileClaim validates the durable reservation and external owner for a state root retained in a lifecycle receipt after local binding removal. It deliberately reads no workspace files and creates no state or metadata.

func ValidateDefaultProfileOwnership

func ValidateDefaultProfileOwnership(home, workspaceID string) error

ValidateDefaultProfileOwnership reads the existing shared owner marker only. An absent profile/marker returns an os.IsNotExist-compatible error; callers deciding whether to purge may explicitly skip an absent profile. Writers must not treat absence as ownership or create children before Ensure succeeds.

func ValidateProductionProfileIsolation

func ValidateProductionProfileIsolation(stateRoot, home string) error

ValidateProductionProfileIsolation rejects production state overlapping any durable custom development container, including reservations retained after rebinding. Claims remain authoritative without owner markers. Existing owner evidence must be valid even when disjoint; an absent disjoint marker is allowed. stateRoot must be canonical. This reads metadata only: it creates no locks or files, repairs nothing, and never scans directory descendants.

Types

type BootIdentity

type BootIdentity struct {
	SchemaVersion int    `json:"schemaVersion"`
	InstanceID    string `json:"instanceID"`
	DisplayName   string `json:"displayName"`
	Generation    string `json:"generation"`
	Kind          string `json:"kind"`
}

type Discovery

type Discovery struct {
	InstanceDescriptor
	TokenFile string `json:"tokenFile"`
}

type Endpoints

type Endpoints struct {
	Browser *string `json:"browser"`
	Vite    *string `json:"vite"`
	HMR     *string `json:"hmr"`
	MCP     *string `json:"mcp"`
	Control *string `json:"control"`
	Health  *string `json:"health"`
}

type Error

type Error struct {
	Code    string         `json:"code"`
	Message string         `json:"message"`
	Details map[string]any `json:"details,omitempty"`
	Exit    int            `json:"-"`
}

func Fail

func Fail(exit int, code, message string) *Error

func (*Error) Error

func (e *Error) Error() string

type InstanceDescriptor

type InstanceDescriptor struct {
	SchemaVersion int                    `json:"schemaVersion"`
	WorkspaceID   string                 `json:"workspaceID"`
	InstanceID    string                 `json:"instanceID"`
	Generation    string                 `json:"generation"`
	Kind          string                 `json:"kind"`
	Channel       string                 `json:"channel"`
	DisplayName   string                 `json:"displayName"`
	StateRoot     string                 `json:"stateRoot"`
	Process       ProcessIdentity        `json:"process"`
	Version       string                 `json:"version"`
	Commit        string                 `json:"commit"`
	Repositories  []RepositoryResolution `json:"repositories"`
	Endpoints     Endpoints              `json:"endpoints"`
	Plugins       []PluginState          `json:"plugins"`
	Readiness     string                 `json:"readiness"`
	LastError     *Error                 `json:"lastError,omitempty"`
	StartedAt     time.Time              `json:"startedAt"`
}

InstanceDescriptor contains no credentials; the token value is never part of discovery.

func (InstanceDescriptor) BootIdentity

func (d InstanceDescriptor) BootIdentity() BootIdentity
type Links struct {
	UIRepositoryID  *string `json:"uiRepositoryID"`
	SDKRepositoryID *string `json:"sdkRepositoryID"`
	HostPackages    bool    `json:"hostPackages"`
}

type Plugin

type Plugin struct {
	ID           string `json:"id"`
	RepositoryID string `json:"repositoryID"`
	Mode         string `json:"mode"`
}

type PluginState

type PluginState struct {
	ID               string `json:"id"`
	Version          string `json:"version"`
	Source           string `json:"source"`
	Generation       string `json:"generation"`
	Mode             string `json:"mode"`
	BuildStatus      string `json:"buildStatus"`
	ViteStatus       string `json:"viteStatus"`
	RPCStatus        string `json:"rpcStatus"`
	ControllerStatus string `json:"controllerStatus"`
	OperationID      string `json:"operationID,omitempty"`
	LastError        *Error `json:"lastError,omitempty"`
}

type PortPolicy

type PortPolicy struct {
	Policy    string         `json:"policy"`
	Overrides map[string]int `json:"overrides"`
}

type ProcessIdentity

type ProcessIdentity struct {
	PID           int    `json:"pid"`
	StartIdentity string `json:"startIdentity"`
	Executable    string `json:"executable"`
	WorkspaceID   string `json:"workspaceID"`
	Generation    string `json:"generation"`
	Role          string `json:"role"`
	Source        string `json:"source,omitempty"`
}

type Profile

type Profile struct {
	Kind     string  `json:"kind"`
	Baseline *string `json:"baseline"`
}

type Repository

type Repository struct {
	ID         string              `json:"id"`
	Directory  string              `json:"directory"`
	BaseRef    string              `json:"baseRef"`
	BaseCommit string              `json:"baseCommit"`
	Branch     string              `json:"branch"`
	Upstream   *RepositoryUpstream `json:"upstream,omitempty"`
}

type RepositoryResolution

type RepositoryResolution struct {
	ID     string `json:"id"`
	Path   string `json:"path"`
	Ref    string `json:"ref"`
	Commit string `json:"commit"`
}

type RepositoryUpstream added in v0.8.0

type RepositoryUpstream struct {
	Remote string `json:"remote"`
	Branch string `json:"branch"`
}

func (RepositoryUpstream) Validate added in v0.8.0

func (u RepositoryUpstream) Validate() error

Validate accepts only named remotes and fully qualified branch references.

type Request

type Request struct {
	ProtocolVersion int             `json:"protocolVersion"`
	RequestID       string          `json:"requestID"`
	WorkspaceID     string          `json:"workspaceID"`
	Generation      string          `json:"generation"`
	Operation       string          `json:"operation"`
	Params          json.RawMessage `json:"params"`
}

func (Request) ValidateTarget

func (r Request) ValidateTarget(workspaceID, generation string) error

type ResolveOptions

type ResolveOptions struct {
	CWD                 string
	Explicit            string
	EnvironmentManifest string
	StateRoot           string
	Home                string
}

type ResolvedWorkspace

type ResolvedWorkspace struct {
	ManifestPath string            `json:"manifestPath"`
	Root         string            `json:"root"`
	StateRoot    string            `json:"stateRoot"`
	Manifest     WorkspaceManifest `json:"manifest"`
}

func ResolveWorkspace

func ResolveWorkspace(opts ResolveOptions) (ResolvedWorkspace, error)

func SetCustomProfile

func SetCustomProfile(ctx context.Context, w ResolvedWorkspace, path, home string) (ResolvedWorkspace, error)

SetCustomProfile persistently binds a stopped workspace to an owned custom container. It never creates state: baseline publication may atomically create that directory later. Claims and owner markers survive rebinding, so old state cannot silently become another workspace's profile. Retrying the same request resumes a durable claim interrupted before marker or binding publication.

func (ResolvedWorkspace) RepositoryPath

func (w ResolvedWorkspace) RepositoryPath(id string) (string, error)

type Response

type Response struct {
	ProtocolVersion int             `json:"protocolVersion"`
	RequestID       string          `json:"requestID"`
	WorkspaceID     string          `json:"workspaceID"`
	Generation      string          `json:"generation"`
	OperationID     string          `json:"operationID,omitempty"`
	Status          string          `json:"status"`
	Result          json.RawMessage `json:"result,omitempty"`
	Error           *Error          `json:"error,omitempty"`
}

type WorkspaceManifest

type WorkspaceManifest struct {
	SchemaVersion int          `json:"schemaVersion"`
	WorkspaceID   string       `json:"workspaceID"`
	Slug          string       `json:"slug"`
	DisplayName   string       `json:"displayName"`
	Repositories  []Repository `json:"repositories"`
	Plugins       []Plugin     `json:"plugins"`
	Links         Links        `json:"links"`
	Profile       Profile      `json:"profile"`
	Ports         PortPolicy   `json:"ports"`
}

func (WorkspaceManifest) Validate

func (m WorkspaceManifest) Validate() error

Jump to

Keyboard shortcuts

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