Documentation
¶
Overview ¶
Package devcontract defines native-independent development workspace contracts.
Index ¶
- Constants
- func CanonicalPath(path string) (string, error)
- func EnsureDefaultProfileOwnership(home, workspaceID string) error
- func ExitCode(err error) int
- func FailedReadinessStage(build, vite, rpc, controllers string) string
- func LockProfile(ctx context.Context, home, workspaceID string) (func() error, error)
- func ProfileGuardPath(home, workspaceID string) (string, error)
- func ProfilePathsOverlap(a, b string) (bool, error)
- func ReadCustomProfileBinding(root, workspaceID, home string) (string, bool, error)
- func ValidateCustomProfileClaim(stateRoot, workspaceID, home string) error
- func ValidateDefaultProfileOwnership(home, workspaceID string) error
- func ValidateProductionProfileIsolation(stateRoot, home string) error
- type BootIdentity
- type Discovery
- type Endpoints
- type Error
- type InstanceDescriptor
- type Links
- type Plugin
- type PluginState
- type PortPolicy
- type ProcessIdentity
- type Profile
- type Repository
- type RepositoryResolution
- type RepositoryUpstream
- type Request
- type ResolveOptions
- type ResolvedWorkspace
- type Response
- type WorkspaceManifest
Constants ¶
const ProtocolVersion = 1
const SchemaVersion = 1
const WorkspaceEnvironment = "OMNIVIEW_WORKSPACE_FILE"
Variables ¶
This section is empty.
Functions ¶
func CanonicalPath ¶
CanonicalPath resolves existing symlink ancestors even for not-yet-created paths.
func EnsureDefaultProfileOwnership ¶
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 FailedReadinessStage ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
ValidateProductionProfileIsolation rejects production state overlapping any durable custom development container, including reservations retained after rebinding. Existing claim and owner evidence must be valid even when disjoint. 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 Discovery ¶
type Discovery struct {
InstanceDescriptor
TokenFile string `json:"tokenFile"`
}
type Error ¶
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 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 ProcessIdentity ¶
type Repository ¶
type RepositoryResolution ¶
type RepositoryUpstream ¶ added in v0.8.0
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 ¶
type ResolveOptions ¶
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