Documentation
¶
Overview ¶
Package dataaccess owns shared DataTug access contracts and a bounded, adapter-independent read boundary. DALgo remains the policy evaluator.
Index ¶
- Constants
- type AccessRequest
- type AgentRead
- type Authority
- type CaseRef
- type ConnectionProtection
- type ConnectionRef
- type Database
- type Decision
- type Denial
- type FieldScope
- type Fingerprint
- type Grant
- type GrantScope
- type GrantState
- type ObjectRef
- type Permission
- type ReadPosture
- type RecordScope
- type RequestBinding
- type Resolution
- type ResolveRequest
- type Resolver
- type Selector
- type Subject
- type SubjectKind
Constants ¶
const ObjectsExact = "objects.exact"
ObjectsExact is the only optional scope feature defined for this checkpoint. A future selector feature must have a different name.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessRequest ¶
type AccessRequest struct {
Permissions []Permission `json:"permissions"`
Scope GrantScope `json:"scope"`
Reason string `json:"reason"`
ExpiresAt time.Time `json:"expiresAt"`
CaseRef *CaseRef `json:"caseRef,omitempty"`
PriorGrant string `json:"priorGrant,omitempty"`
}
AccessRequest carries no subject, requester, approval, or identity assertion. The control plane derives those from authenticated host facts.
func DecodeAccessRequest ¶
func DecodeAccessRequest(data []byte) (AccessRequest, error)
DecodeAccessRequest and DecodeGrant are the MVP wire admission points. They reuse the core decoder's duplicate/case-folded key, unknown-field and trailing input checks. Unsupported field presence is refused even when its value is null or an empty collection. Plain json.Unmarshal is not wire admission.
func (AccessRequest) ValidateMVP ¶
func (r AccessRequest) ValidateMVP() error
type Authority ¶
type Authority struct {
// contains filtered or unexported fields
}
Authority binds one host-assigned subject and one resolved connection. It does not accept a caller authorization token or a local-owner boolean.
func NewAuthority ¶
func NewAuthority(subject Subject, connection ConnectionRef, resolve Resolver) (*Authority, error)
type ConnectionProtection ¶
type ConnectionProtection struct {
ID string `json:"id"`
Fingerprint Fingerprint `json:"fingerprint"`
Name string `json:"name"`
Environment string `json:"environment,omitempty"`
ReadOnly bool `json:"readOnly"`
ReadPosture ReadPosture `json:"readPosture"`
AgentRead AgentRead `json:"agentRead"`
MaxDuration map[Permission]int `json:"maxDuration,omitempty"` // seconds
MandatoryFineGrained bool `json:"mandatoryFineGrained"`
Revision int64 `json:"revision"`
}
type ConnectionRef ¶
type ConnectionRef struct {
Space string `json:"space"`
ID string `json:"id"`
Fingerprint Fingerprint `json:"fingerprint"`
}
ConnectionRef includes the Space because protection IDs are Space-local.
type Database ¶
type Database interface {
dal.ReadwriteSession
dal.ReadTransactionCoordinator
}
Database deliberately exposes no Schema, Adapter, native/optional capability, underlying handle, or read-write transaction opener. Those surfaces require separate integration proof. Typed writes remain callable only to return a DALgo policy denial before dispatch. Recordset queries are refused; the query profile currently supports only unqualified, single-source key enumeration. Point reads stage maps, non-nil pointers and fixed-length slices; nil, scalar or inaccessible targets are refused before dispatch. This additive boundary is a Task 4 checkpoint, not whole-task integration.
type Denial ¶
type Denial struct {
Connection string `json:"connection"`
Capability Permission `json:"capability"`
Code string `json:"code"`
}
Denial is safe to show across execution surfaces. It carries no query, credential, policy expression, resolved value, or untrusted upstream error.
type FieldScope ¶
type Fingerprint ¶
type Fingerprint struct {
Engine string `json:"engine"`
Database string `json:"database"`
EngineIdentity string `json:"engineIdentity,omitempty"`
Address string `json:"address,omitempty"`
}
Fingerprint is resolved by the host using the engine's identity facts. Address is a display hint when EngineIdentity is available; without that identity, binding falls back to Address. Identity can name cluster lineage.
type Grant ¶
type Grant struct {
ID string `json:"id"`
Subject Subject `json:"subject"`
RequestedBy Subject `json:"requestedBy"`
Permissions []Permission `json:"permissions"`
Scope GrantScope `json:"scope"`
Reason string `json:"reason"`
CaseRef *CaseRef `json:"caseRef,omitempty"`
NotBefore *time.Time `json:"notBefore,omitempty"`
ExpiresAt time.Time `json:"expiresAt"`
State GrantState `json:"state"`
Decision *Decision `json:"decision,omitempty"`
PriorGrant string `json:"priorGrant,omitempty"`
Revision int64 `json:"revision"`
}
func DecodeGrant ¶
func (Grant) ValidateMVP ¶
type GrantScope ¶
type GrantScope struct {
Connection string `json:"connection"`
Schemas []Selector `json:"schemas,omitempty"`
Objects []ObjectRef `json:"objects,omitempty"`
Exclude []Selector `json:"exclude,omitempty"`
Records *RecordScope `json:"records,omitempty"`
Fields *FieldScope `json:"fields,omitempty"`
Request *RequestBinding `json:"request,omitempty"`
Requires []string `json:"requires"`
}
func (GrantScope) ValidateMVP ¶
func (s GrantScope) ValidateMVP(permissions []Permission) error
ValidateMVP admits connection reads and exact-object read requests. Execution of object grants remains gated until generic scope composition is proven. All not-yet-supported fields and unknown required features fail closed.
type GrantState ¶
type GrantState string
const ( Requested GrantState = "requested" Approved GrantState = "approved" Refused GrantState = "refused" Withdrawn GrantState = "withdrawn" Revoked GrantState = "revoked" // Expired is computed from ExpiresAt; it is never a persisted transition. Expired GrantState = "expired" )
type ObjectRef ¶
ObjectRef contains an already canonical namespace and exact object name. It never contains a wildcard, an identifier expression, or an address.
type Permission ¶
type Permission string
const ( DataRead Permission = "data.read" DataWrite Permission = "data.write" DataInsert Permission = "data.insert" DataUpdate Permission = "data.update" DataDelete Permission = "data.delete" DataReveal Permission = "data.reveal" QueryTugQL Permission = "query.tugql" QueryRaw Permission = "query.raw" )
type ReadPosture ¶
type ReadPosture string
const ( ReadAll ReadPosture = "all" ReadNone ReadPosture = "none" )
type RecordScope ¶
type RecordScope struct {
Language string `json:"language"`
Predicate json.RawMessage `json:"predicate"`
}
type RequestBinding ¶
type RequestBinding struct {
Fingerprint string `json:"fingerprint"`
}
type Resolution ¶
type Resolution struct {
Subject Subject `json:"subject"`
Connection ConnectionRef `json:"connection"`
Protection ConnectionProtection `json:"protection"`
Grants []Grant `json:"grants"`
ServerTime time.Time `json:"serverTime"`
ValidUntil time.Time `json:"validUntil"`
}
Resolution comes only from the injected authenticated authority port. The port verifies current membership and protection state, and refuses failure. ServerTime and ValidUntil are verified server facts, not local clock values. ServerTime must be fresh for this resolve call. A cached response must not be replayed as new authority; a future caching adapter must preserve its original age and deadline rather than rebase either onto the next call's local time.
type ResolveRequest ¶
type ResolveRequest struct {
Subject Subject `json:"subject"`
Connection ConnectionRef `json:"connection"`
}
type Resolver ¶
type Resolver func(context.Context, ResolveRequest) (Resolution, error)
type Selector ¶
Selector, RecordScope, FieldScope and RequestBinding reserve the stored model's later-phase shape. MVP admission refuses their presence.
type Subject ¶
type Subject struct {
Realm string `json:"realm"`
Kind SubjectKind `json:"kind"`
ID string `json:"id"`
}
Subject is assigned by the authenticated host, never by execution input.
type SubjectKind ¶
type SubjectKind string
const ( User SubjectKind = "user" Service SubjectKind = "service" Agent SubjectKind = "agent" )