Documentation
¶
Index ¶
- Constants
- Variables
- func JSONEncodedSize(value any, maxBytes int) (int, error)
- func MarshalJSONBounded(value any, maxBytes int) (json.RawMessage, error)
- func RegisterTyped[TReq any, TResp any](router *sessionrpc.Router, typeID uint32, runtime *Runtime, ...)
- type Admission
- type CommandError
- type CommandKind
- type CommandResult
- type Coordinator
- type FilesystemEffect
- type FilesystemMutationCoordinator
- type Lease
- type RPCSpec
- type RepositoryIdentity
- type RequestSpec
- type ResponseSpec
- type Runtime
- func (r *Runtime) AcquireCapture(ctx context.Context) (*Admission, error)
- func (r *Runtime) AcquireDestructiveScan(ctx context.Context) (*Admission, error)
- func (r *Runtime) AcquireMutation(ctx context.Context, id RepositoryIdentity) (Lease, error)
- func (r *Runtime) AcquireRPCStream(ctx context.Context) (*Admission, error)
- func (r *Runtime) AcquireRead(ctx context.Context, id RepositoryIdentity) (Lease, error)
- func (r *Runtime) AcquireRequestDecode(ctx context.Context) (*Admission, error)
- func (r *Runtime) AcquireResponseBuild(ctx context.Context) (*Admission, error)
- func (r *Runtime) CoordinateFilesystemMutation(ctx context.Context, effect FilesystemEffect, fn func() error) error
- func (r *Runtime) CoordinateTopologyMutation(ctx context.Context, effect FilesystemEffect, fn func(context.Context) error) error
- func (r *Runtime) Invalidate(id RepositoryIdentity)
- func (r *Runtime) NewSession() *Session
- func (r *Runtime) RepositoryIdentityCurrent(id RepositoryIdentity) bool
- func (r *Runtime) ReservePublishedSnapshot(bytes int64) (*Admission, error)
- func (r *Runtime) ResolveRepositoryIdentity(ctx context.Context, path string) (RepositoryIdentity, bool, error)
- func (r *Runtime) RetainRepository(ctx context.Context, id RepositoryIdentity) (*Admission, error)
- func (r *Runtime) RunCapture(ctx context.Context, repoRoot string, env []string, args ...string) (CommandResult, error)
- func (r *Runtime) RunMutation(ctx context.Context, repoRoot string, env []string, args ...string) (CommandResult, error)
- func (r *Runtime) RunRead(ctx context.Context, repoRoot string, env []string, args ...string) (CommandResult, error)
- func (r *Runtime) RunReadAllowExitCodes(ctx context.Context, repoRoot string, env []string, allowedExitCodes []int, ...) (CommandResult, error)
- func (r *Runtime) StreamCapture(ctx context.Context, repoRoot string, env []string, ...) (CommandResult, error)
- func (r *Runtime) StreamRead(ctx context.Context, repoRoot string, env []string, ...) (CommandResult, error)
- func (r *Runtime) TryAcquireRPCStream() (*Admission, error)
- type Session
Constants ¶
const ( MaxReadProcesses = 8 MaxWorkspaceCaptures = 2 MaxMutationProcesses = 4 MaxDestructiveScans = 1 MaxRequestDecodes = 16 MaxResponseBuilds = 8 MaxRPCStreams = 4 MaxConcurrentRPCRequests = 4 MaxQueuedRPCRequests = 8 MaxQueuedRPCNotifications = 4 RequestReservation = 8 << 20 ResponseReservation = 12 << 20 StreamReservation = 32 << 20 CaptureReservation = 8 << 20 MaxRequestReservations = MaxRequestDecodes * RequestReservation MaxResponseReservations = MaxResponseBuilds * ResponseReservation MaxCaptureReservations = MaxWorkspaceCaptures * CaptureReservation MaxRPCStreamReservations = MaxRPCStreams * StreamReservation MaxPublishedSnapshotBytes = 128 << 20 MaxRawRequestBytes = 768 << 10 MaxResponsePayload = 768 << 10 MaxSyntheticEnvelope = 768 << 10 MaxJSONDepth = 32 MaxJSONTokens = 32_768 MaxJSONRecords = 8_192 MaxJSONStringBytes = 640 << 10 MaxJSONTotalStringBytes = 2 << 20 )
const ( ErrorResponseBudget uint32 = 41305 ErrorResourceLimit uint32 = 41306 ErrorRequestBudget uint32 = 41307 )
const ( MaxGitStdoutBytes = 1 << 20 MaxGitStderrBytes = 64 << 10 )
Variables ¶
Functions ¶
func JSONEncodedSize ¶
JSONEncodedSize returns the exact encoding/json-compatible size of value while failing as soon as the output would exceed maxBytes. The closed encoder intentionally supports only the DTO shapes used by Git RPCs.
func MarshalJSONBounded ¶
func MarshalJSONBounded(value any, maxBytes int) (json.RawMessage, error)
MarshalJSONBounded encodes value without allowing either the returned slice or an intermediate encoding buffer to grow beyond maxBytes.
func RegisterTyped ¶
func RegisterTyped[TReq any, TResp any]( router *sessionrpc.Router, typeID uint32, runtime *Runtime, spec RPCSpec[TReq, TResp], gate *accessgate.Gate, meta *session.Meta, policy accessgate.RPCAccessPolicy, handler func(context.Context, *TReq) (*TResp, error), )
RegisterTyped applies the closed Git-domain request and response budgets. The decode reservation remains held until the handler and response guard finish, so the decoded DTO cannot outlive its admission.
Types ¶
type Admission ¶
type Admission struct {
// contains filtered or unexported fields
}
Admission is an idempotently released runtime reservation.
type CommandError ¶
func (*CommandError) Error ¶
func (e *CommandError) Error() string
func (*CommandError) Unwrap ¶
func (e *CommandError) Unwrap() error
type CommandResult ¶
type Coordinator ¶
type Coordinator interface {
AcquireRead(context.Context, RepositoryIdentity) (Lease, error)
AcquireMutation(context.Context, RepositoryIdentity) (Lease, error)
Invalidate(RepositoryIdentity)
}
Coordinator is the narrow contract used by repository services.
type FilesystemEffect ¶
FilesystemEffect describes the paths whose topology or content will change.
type FilesystemMutationCoordinator ¶
type FilesystemMutationCoordinator interface {
CoordinateFilesystemMutation(context.Context, FilesystemEffect, func() error) error
}
FilesystemMutationCoordinator is the only Git runtime contract exposed to the filesystem service.
type Lease ¶
Lease covers the topology and common-repository gates in their required acquisition order.
type RPCSpec ¶
type RPCSpec[TReq any, TResp any] struct { Request RequestSpec[TReq] Response ResponseSpec[TResp] }
func DefaultRPCSpec ¶
type RepositoryIdentity ¶
type RepositoryIdentity struct {
CommonRepoKey string
WorktreeKey string
WorktreeRoot string
CommonDir string
GitDir string
}
RepositoryIdentity separates shared-ref coordination from worktree-local index and snapshot identity.
type RequestSpec ¶
type ResponseSpec ¶
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
func (*Runtime) AcquireCapture ¶
func (*Runtime) AcquireDestructiveScan ¶
func (*Runtime) AcquireMutation ¶
func (*Runtime) AcquireRPCStream ¶
func (*Runtime) AcquireRead ¶
func (*Runtime) AcquireRequestDecode ¶
func (*Runtime) AcquireResponseBuild ¶
func (*Runtime) CoordinateFilesystemMutation ¶
func (r *Runtime) CoordinateFilesystemMutation(ctx context.Context, effect FilesystemEffect, fn func() error) error
CoordinateFilesystemMutation serializes a Files-owned effect with every registered worktree or Git metadata root that overlaps an effect path.
func (*Runtime) CoordinateTopologyMutation ¶
func (r *Runtime) CoordinateTopologyMutation(ctx context.Context, effect FilesystemEffect, fn func(context.Context) error) error
CoordinateTopologyMutation owns the topology-exclusive/shared gate and every overlapping common-repository mutation gate through the supplied effect. The callback context may safely resolve repository identities without recursively acquiring the topology gate.
func (*Runtime) Invalidate ¶
func (r *Runtime) Invalidate(id RepositoryIdentity)
func (*Runtime) NewSession ¶
func (*Runtime) RepositoryIdentityCurrent ¶
func (r *Runtime) RepositoryIdentityCurrent(id RepositoryIdentity) bool
RepositoryIdentityCurrent verifies that every filesystem object bound into an admitted repository identity still resolves to the same stable identity. Callers that already hold a topology lease may use this without reacquiring the topology gate.
func (*Runtime) ReservePublishedSnapshot ¶
ReservePublishedSnapshot accounts retained snapshot capacity across every direct-session cache. Cache eviction must release the returned admission.
func (*Runtime) ResolveRepositoryIdentity ¶
func (r *Runtime) ResolveRepositoryIdentity(ctx context.Context, path string) (RepositoryIdentity, bool, error)
ResolveRepositoryIdentity resolves and admits an identity before exposing it. A successful identity remains in the bounded inactive registry after this call; operations and snapshots retain their own explicit leases.
func (*Runtime) RetainRepository ¶
RetainRepository pins the registry entry and its common-repository epoch owner without holding a read/write gate. Published snapshots and in-flight singleflight generations must keep this admission until their references are released.
func (*Runtime) RunCapture ¶
func (*Runtime) RunMutation ¶
func (*Runtime) RunReadAllowExitCodes ¶
func (*Runtime) StreamCapture ¶
func (r *Runtime) StreamCapture(ctx context.Context, repoRoot string, env []string, consume func(io.Reader) error, args ...string) (CommandResult, error)
StreamCapture acquires the capture reservation in addition to read-process admission. Callers that retain the reservation through cache publication should acquire it explicitly and use StreamRead instead.
func (*Runtime) StreamRead ¶
func (r *Runtime) StreamRead(ctx context.Context, repoRoot string, env []string, consume func(io.Reader) error, args ...string) (CommandResult, error)
StreamRead runs a read-only Git command with bounded process admission and containment while the caller incrementally consumes stdout.
func (*Runtime) TryAcquireRPCStream ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session owns one explicit reference for every worktree resolved by a direct session. Close releases all references; repeated resolves are deduplicated.
func (*Session) RetainRepository ¶
func (s *Session) RetainRepository(ctx context.Context, id RepositoryIdentity) error