Documentation
¶
Overview ¶
Package dataaccess owns shared DataTug access contracts and a bounded, adapter-independent read boundary. DALgo remains the policy evaluator.
Index ¶
- Constants
- func Covers(r Resolution, scope GrantScope) (bool, error)
- type AccessRequest
- type AgentRead
- type AgentSession
- type Authority
- func (a *Authority) CaptureResult(ctx context.Context, request ResultRequest, ...) (*Result, error)
- func (a *Authority) ImportResult(ctx context.Context, request ResultRequest, requestStarted time.Time, ...) (*Result, error)
- func (a *Authority) ImportStructuredResult(ctx context.Context, request ResultRequest, started time.Time, ...) (*Result, error)
- func (a *Authority) ImportTableResult(ctx context.Context, request ResultRequest, started time.Time, ...) (*Result, error)
- func (a *Authority) ReadStructuredResult(ctx context.Context, request ResultRequest, operation StructuredRead, ...) (*Result, error)
- func (a *Authority) ReadTableResult(ctx context.Context, request ResultRequest, operation TableRead, ...) (*Result, error)
- func (a *Authority) SecureDB(db dal.DB) (Database, error)
- func (a *Authority) SecureDBWithTableIdentity(db dal.DB, verifier TableIdentityVerifier) (Database, error)
- type CaseRef
- type ConnectionProtection
- type ConnectionRef
- type Database
- type Decision
- type Denial
- type ExactReadPolicy
- type ExactReadSnapshot
- func (s *ExactReadSnapshot) BindContext(ctx context.Context, subject Subject) (context.Context, error)
- func (ExactReadSnapshot) Format(state fmt.State, _ rune)
- func (ExactReadSnapshot) GoString() string
- func (ExactReadSnapshot) LogValue() slog.Value
- func (*ExactReadSnapshot) MarshalJSON() ([]byte, error)
- func (s *ExactReadSnapshot) RequestableObjects() []ObjectRef
- func (ExactReadSnapshot) String() string
- type FieldScope
- type Fingerprint
- type Forwarding
- type Grant
- type GrantScope
- type GrantState
- type InspectedAssessment
- type InspectedPolicy
- type Lifetime
- type LocalConnectionRef
- type ObjectRef
- type Permission
- type ReadPosture
- type RecordScope
- type RequestBinding
- type Resolution
- func ProjectAgentExactRead(ctx context.Context, user Resolution, agent Subject, s *ExactReadSnapshot) (Resolution, error)
- func ProjectAgentResolution(ctx context.Context, user Resolution, agent Subject, grants []Grant, ...) (Resolution, error)
- func ProjectExactRead(ctx context.Context, r Resolution, s *ExactReadSnapshot) (Resolution, error)
- type ResolveRequest
- type Resolver
- type Result
- type ResultEnvelope
- type ResultLease
- type ResultRequest
- type Selector
- type StructuredIdentityFacts
- type StructuredIdentityRequest
- type StructuredRead
- type StructuredReadSource
- type StructuredReadSpan
- type StructuredResourceIdentity
- type StructuredResultEnvelope
- type StructuredResultLease
- type Subject
- type SubjectKind
- type TableIdentityFacts
- type TableIdentityRequest
- type TableIdentityVerifier
- type TableRead
- type TableReadInspection
- type TableReadSource
- type TableReadSpan
- type TableResultEnvelope
- type TableResultLease
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.
const StructuredReadProfile = "structured-recordset/1"
StructuredReadProfile is a single-connection structured recordset operation. It is distinct from the closed all-column table preview and from raw SQL.
const TableReadProfile = "table-recordset/1"
TableReadProfile admits only a Core-constructed, qualified, unconditional all-column recordset preview. It does not enable arbitrary structured queries.
Variables ¶
This section is empty.
Functions ¶
func Covers ¶ added in v0.139.0
func Covers(r Resolution, scope GrantScope) (bool, error)
Covers reports whether r, as of its own ServerTime, lets its subject (a person, never an agent) read every object of scope, or the whole connection for a connection-wide scope. It runs the same admission as a real read, at that one instant. Hosts use it for decisions about an agent (Perimeter REQ:agent-asks-its-user: the user's access path, and whether an own-agent approval is dormant). It never authorizes a read; execution re-checks the agent against its user at every authorization.
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"`
// Lifetime is the requested lifetime; the decider may narrow it, never widen it.
Lifetime Lifetime `json:"lifetime,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 AgentSession ¶ added in v0.140.0
AgentSession is the live agent session a control plane authorized an agent's call under (Perimeter REQ:agent-sessions). It is an evaluator input, set only on an agent's resolution: session-bound grants count only for this session and never beyond EndsAt (the earlier of its idle and absolute ends).
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)
func NewLocalAuthority ¶ added in v0.135.0
func NewLocalAuthority(subject Subject, connection LocalConnectionRef, resolve Resolver) (*Authority, error)
NewLocalAuthority uses the same resolver/evaluator/lease boundary for a source with no enrolled Space. The trusted host resolver supplies its current baseline and source facts and refuses lost local ownership. Local resolutions cannot carry grants; no control-plane decision is fabricated for this route.
func (*Authority) CaptureResult ¶ added in v0.131.0
func (a *Authority) CaptureResult(ctx context.Context, request ResultRequest, read func(context.Context) ([]byte, error)) (*Result, error)
CaptureResult is a trusted host composition point. read must use the secured database for this Authority and transfer ownership of the complete serialized JSON payload buffer (Core clears it, including on read/validation failure). The first resolve precedes I/O, and neither I/O nor later release renews it. This transport checkpoint requires connection-wide read authority; object-only results require a separately reviewed resource-bound transport contract.
func (*Authority) ImportResult ¶ added in v0.131.0
func (a *Authority) ImportResult(ctx context.Context, request ResultRequest, requestStarted time.Time, envelope ResultEnvelope) (*Result, error)
ImportResult requires an authenticated trusted server envelope and independently expected subject, connection/scope, request digest and fresh nonce. The host pins the actual source identity from that trusted transport before constructing Authority. requestStarted MUST be captured before the HTTP request. The caller must bound ctx by the verified ORIGINAL credential deadline, not its refresh. Object grants never substitute for current connection-wide result authority. Ownership of envelope.Payload transfers to Core; it is cleared on every path and immediately after compaction, before any authority network I/O.
func (*Authority) ImportStructuredResult ¶ added in v0.135.0
func (a *Authority) ImportStructuredResult(ctx context.Context, request ResultRequest, started time.Time, expected StructuredRead, envelope StructuredResultEnvelope) (*Result, error)
ImportStructuredResult requires authenticated transport and independently expected original intent, subject, source, nonce and original credential deadline. Started is recorded BEFORE the network request. Payload ownership transfers to Core and is cleared before fresh authority I/O on every path.
func (*Authority) ImportTableResult ¶ added in v0.134.0
func (a *Authority) ImportTableResult(ctx context.Context, request ResultRequest, started time.Time, expected TableRead, envelope TableResultEnvelope) (*Result, error)
ImportTableResult requires the same authenticated transport and original credential/context/deadline discipline as ImportResult, plus an independently expected closed operation. The host pins actual server source identity first; the client never fabricates native span facts. Ownership of Payload transfers to Core, and caller bytes are cleared before any fresh authority network I/O.
func (*Authority) ReadStructuredResult ¶ added in v0.135.0
func (a *Authority) ReadStructuredResult(ctx context.Context, request ResultRequest, operation StructuredRead, source StructuredReadSource) (*Result, error)
ReadStructuredResult freezes serialized intent before resolving authority, opens only after every resource is a candidate, and retains the same original authority ceiling through native reads, serialization and guarded output. Additional DALgo context policies remain restrictive subordinate constraints.
func (*Authority) ReadTableResult ¶ added in v0.134.0
func (a *Authority) ReadTableResult(ctx context.Context, request ResultRequest, operation TableRead, source TableReadSource) (*Result, error)
ReadTableResult constructs and executes its own frozen operation, secures the supplied native session with DALgo, serializes actual cells into private bytes and returns a version2 retained result. Existing v1 capture stays connection- wide. The authenticated host computes ResultRequest from the actual complete command/scope; the client computes its expected digest independently.
func (*Authority) SecureDB ¶
SecureDB is a trusted composition point: the host supplies the database that corresponds to the resolved ConnectionRef. Only the secured interface leaves it. Production opener wiring and its architecture ratchet are later work.
func (*Authority) SecureDBWithTableIdentity ¶ added in v0.133.2
func (a *Authority) SecureDBWithTableIdentity(db dal.DB, verifier TableIdentityVerifier) (Database, error)
SecureDBWithTableIdentity opts one actual opened DB into the bounded explicit- schema key-enumeration profile. The host owns the verifier's execution-span invariants; all permission decisions remain in Core and DALgo. Point keys, transactions and result transport retain their connection-wide requirements. Core permission candidacy and its selected ceiling precede fact lookup. Additional DALgo context policies still intersect before data dispatch; their denial may follow trusted identity-metadata lookup.
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"`
// LocalAuthorityID is host-owned local authority, mutually exclusive with
// Space. Its presence never asserts enrollment or control-plane approval.
LocalAuthorityID string `json:"localAuthorityId,omitempty"`
}
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 supports only frozen, unconditional single-source key enumeration, with an explicit schema required for exact-object grants. Object-only retained result transport and transactions remain unavailable at this checkpoint. 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 Decision ¶
type Decision struct {
By Subject `json:"by"`
At time.Time `json:"at"`
Note string `json:"note,omitempty"`
Self bool `json:"self"`
Narrowed bool `json:"narrowed"`
// ForOwnAgent marks a decision the agent's user made for their own agent
// (Perimeter REQ:agent-asks-its-user). It never widens the user: the agent
// stays capped at the user's access at every authorization.
ForOwnAgent bool `json:"forOwnAgent,omitempty"`
// Dormant records that the user could not read every covered object when
// approving for their own agent; the approval takes effect only once they
// can (Grant.EffectiveAt, event access.agent_grant.effective).
Dormant bool `json:"dormant,omitempty"`
// ByAgentUser marks the agent's user declining their own agent's request.
ByAgentUser bool `json:"byAgentUser,omitempty"`
}
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 ExactReadPolicy ¶ added in v0.136.0
type ExactReadPolicy struct {
Version int `json:"version"`
Subject Subject `json:"subject"`
Connection ConnectionRef `json:"connection"`
Baseline []ObjectRef `json:"baseline"`
}
ExactReadPolicy contains only the subject's effective standing table scope. It is an authenticated authority projection, never stored policy or native identity proof. Private policy generations and denied names are not wire data.
func (*ExactReadPolicy) UnmarshalJSON ¶ added in v0.136.0
func (p *ExactReadPolicy) UnmarshalJSON(data []byte) error
type ExactReadSnapshot ¶ added in v0.136.0
type ExactReadSnapshot struct {
// contains filtered or unexported fields
}
ExactReadSnapshot is sealed private host configuration. Ordinary JSON encoding exposes no private facts. Only DecodeExactReadSnapshot creates a valid value. Hosts must collect ALL standing/catalog/mandatory/native facts from one owned generation and exclude old writers before enabling exact mode. This type does not establish that deployment fence or discover policies in unrelated handles.
func DecodeExactReadSnapshot ¶ added in v0.136.0
func DecodeExactReadSnapshot(data []byte) (*ExactReadSnapshot, error)
DecodeExactReadSnapshot admits only this bounded table-local deny profile. Unknown policy kinds, permissions, expressions or fields refuse; there is no custom-policy escape hatch. Names must match the trusted native inventory byte-for-byte, including namespace. Folded collisions conservatively refuse.
func (*ExactReadSnapshot) BindContext ¶ added in v0.136.0
func (s *ExactReadSnapshot) BindContext(ctx context.Context, subject Subject) (context.Context, error)
BindContext installs the SAME trusted namespace and compiled mandatory rules for actual secured native execution. Hosts must use this snapshot's closed configuration in both projection and execution, not an untracked source.
func (ExactReadSnapshot) Format ¶ added in v0.136.0
func (ExactReadSnapshot) Format(state fmt.State, _ rune)
func (ExactReadSnapshot) GoString ¶ added in v0.136.0
func (ExactReadSnapshot) GoString() string
func (ExactReadSnapshot) LogValue ¶ added in v0.136.0
func (ExactReadSnapshot) LogValue() slog.Value
func (*ExactReadSnapshot) MarshalJSON ¶ added in v0.136.0
func (*ExactReadSnapshot) MarshalJSON() ([]byte, error)
MarshalJSON deliberately omits every private fact, including future fields.
func (*ExactReadSnapshot) RequestableObjects ¶ added in v0.136.0
func (s *ExactReadSnapshot) RequestableObjects() []ObjectRef
RequestableObjects is intentionally disclosed configuration, separate from effective read metadata. Hosts must not substitute their old catalog port.
func (ExactReadSnapshot) String ¶ added in v0.136.0
func (ExactReadSnapshot) String() string
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 Forwarding ¶ added in v0.139.0
type Forwarding struct {
By Subject `json:"by"`
At time.Time `json:"at"`
Note string `json:"note,omitempty"`
}
Forwarding records an agent's user handing its request on to approvers. It is not a decision: approvers see an agent's request only once forwarded.
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"`
// AgentUser is server-set on every agent-subject grant: the person the agent
// asks first and whose access always caps it (the person who registered it,
// or the person it acts for). It is absent on every other grant.
AgentUser *Subject `json:"agentUser,omitempty"`
// Forwarded is set once the agent's user hands the request to approvers.
Forwarded *Forwarding `json:"forwarded,omitempty"`
// EffectiveAt is set once, inside the grant-revision compare-and-set of the
// agent's first allowed read after a dormant own-agent approval wakes.
EffectiveAt *time.Time `json:"effectiveAt,omitempty"`
// Lifetime is how long the approval lasts (Perimeter REQ:approval-lifetimes,
// D29); absent means LifetimeDeadline.
Lifetime Lifetime `json:"lifetime,omitempty"`
// AgentSessionID binds a LifetimeSession grant to one server-minted agent
// session (REQ:agent-sessions); it is set on such grants and no others.
AgentSessionID string `json:"agentSessionId,omitempty"`
}
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 requires a separately proven profile; admission alone never enables it. SecureDBWithTableIdentity provides one bounded opt-in profile. 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 InspectedAssessment ¶ added in v0.137.0
type InspectedAssessment struct {
Outcome access.AssessmentOutcome
Policies []InspectedPolicy
}
InspectedAssessment is the reduced, rule-free DALgo assessment.
type InspectedPolicy ¶ added in v0.137.0
type InspectedPolicy struct {
Policy string
Allowed bool
Code access.ReasonCode
}
InspectedPolicy is one policy's decision: its name and fixed reason code.
type Lifetime ¶ added in v0.140.0
type Lifetime string
Lifetime is an approval's lifetime (Perimeter REQ:approval-lifetimes, D29). "Always" is not a lifetime: it is a standing rule targeting an agent.
const ( // LifetimeDeadline lasts until ExpiresAt; it is the meaning of an absent lifetime. LifetimeDeadline Lifetime = "deadline" // LifetimeSession lasts until its agent session ends or ExpiresAt, whichever // comes first. Agent subjects only. LifetimeSession Lifetime = "session" // LifetimeOnce is one exact write statement, consumed on commit (DAS L4, D29, // D30). Reserved: the MVP refuses it. Its statement data (fingerprint, // parameters, key set, INSERT rows, new values, preconditions) will attach as // an additional optional object, so the shape grows without a break. LifetimeOnce Lifetime = "once" )
type LocalConnectionRef ¶ added in v0.135.0
type LocalConnectionRef struct {
AuthorityID string
ID string
Fingerprint Fingerprint
}
LocalConnectionRef is constructed by the host from its owned source registry and independently resolved native identity. It is never model execution input. AuthorityID is local provenance, not an enrolled Space or an approval actor.
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" // ReadExact requires a current ExactReadPolicy and a resource-bound read profile. ReadExact ReadPosture = "exact-v1" )
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"`
ExactRead *ExactReadPolicy `json:"exactRead,omitempty"`
// AgentUser is required for an agent subject and absent otherwise: the
// fresh resolution of the person the agent belongs to (the person who
// registered it, or the person it acts for). Every authorization intersects
// the agent's own perimeter with it (Perimeter REQ:agent-access), so the
// user's grants, posture and memberships are inputs of every agent answer.
AgentUser *Resolution `json:"agentUser,omitempty"`
// AgentSession is the live agent session of this call, when there is one.
// Without it an agent keeps standing access and deadline approvals, and no
// session-bound grant may be present.
AgentSession *AgentSession `json:"agentSession,omitempty"`
}
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.
func ProjectAgentExactRead ¶ added in v0.136.0
func ProjectAgentExactRead(ctx context.Context, user Resolution, agent Subject, s *ExactReadSnapshot) (Resolution, error)
ProjectAgentExactRead keeps User authentication/membership admission in the host, then narrows its effective standing baseline under a fixed Agent. Human grants never enter either the candidate set or Agent projection.
func ProjectAgentResolution ¶ added in v0.139.0
func ProjectAgentResolution(ctx context.Context, user Resolution, agent Subject, grants []Grant, s *ExactReadSnapshot) (Resolution, error)
ProjectAgentResolution builds an agent's authority from its user's fresh resolution and the agent's own approvals (Perimeter REQ:agent-access, D23, D27). The agent keeps only grants it is the subject of, each bound to this user; human grants never enter the agent's side. The user's own resolution travels as AgentUser, so Core intersects the two at every authorization. With a sealed exact snapshot, both sides are projected through it; without one the user's resolution must not be exact-shaped.
func ProjectExactRead ¶ added in v0.136.0
func ProjectExactRead(ctx context.Context, r Resolution, s *ExactReadSnapshot) (Resolution, error)
ProjectExactRead produces only positive read authority, never an audit view. Effective ExpiresAt caps must already be computed by the owning resolver. No generation, private deny name or private-policy fingerprint is returned. ctx supplies cancellation/deadline only. Hosts must qualify that the sealed snapshot contains every active mandatory constraint and BindContext governs the same native execution source. Ambient/hidden policy composition is not qualified by this API and must not be enabled merely because decoding passed.
type ResolveRequest ¶
type ResolveRequest struct {
Subject Subject `json:"subject"`
Connection ConnectionRef `json:"connection"`
}
type Resolver ¶
type Resolver func(context.Context, ResolveRequest) (Resolution, error)
type Result ¶ added in v0.131.0
type Result struct {
// contains filtered or unexported fields
}
Result keeps DataTug-owned values private until a final release check. Values handed to an output operation are detached copies and cannot be recalled. The handoff is authorized under mu; output I/O never holds that ownership lock. An in-flight copy stays intact until Write returns, then is cleared. Writers must obey io.Writer's contract: do not modify or retain the buffer.
func (*Result) Close ¶ added in v0.131.0
func (r *Result) Close()
Close discards retained values even if no subsequent release is requested.
func (*Result) WriteEnvelope ¶ added in v0.131.0
type ResultEnvelope ¶ added in v0.131.0
type ResultEnvelope struct {
Payload json.RawMessage `json:"payload"`
Lease ResultLease `json:"lease"`
}
func DecodeResultEnvelope ¶ added in v0.131.0
func DecodeResultEnvelope(data []byte) (ResultEnvelope, error)
type ResultLease ¶ added in v0.131.0
type ResultLease struct {
Version int `json:"version"`
Subject Subject `json:"subject"`
Connection ConnectionRef `json:"connection"`
GrantSetDigest string `json:"grantSetDigest"`
Nonce string `json:"nonce"`
RequestSHA256 string `json:"requestSHA256"`
PayloadSHA256 string `json:"payloadSHA256"`
ServerTime time.Time `json:"serverTime"`
ExpiresAt time.Time `json:"expiresAt"`
}
ResultLease is transport metadata, never a capability. ImportResult accepts it only from the host's authenticated transport, then resolves current facts. ExpiresAt-ServerTime is anchored before the original network request; receiving or refreshing metadata must never restart that interval.
type ResultRequest ¶ added in v0.131.0
type ResultRequest struct {
Nonce string `json:"nonce"`
RequestSHA256 string `json:"requestSHA256"`
}
ResultRequest binds the exact request and a fresh unpredictable host/client nonce. The digest is SHA256 of the agreed canonical request bytes.
type Selector ¶
Selector, RecordScope, FieldScope and RequestBinding reserve the stored model's later-phase shape. MVP admission refuses their presence.
type StructuredIdentityFacts ¶ added in v0.135.0
type StructuredIdentityFacts struct {
Connection ConnectionRef
Resources []StructuredResourceIdentity
}
type StructuredIdentityRequest ¶ added in v0.135.0
type StructuredIdentityRequest struct {
Connection ConnectionRef
Resources []StructuredResourceIdentity
}
type StructuredRead ¶ added in v0.135.0
type StructuredRead struct {
TugQL string `json:"tugql"`
Parameters string `json:"parameters"`
MaxRows uint32 `json:"maxRows"`
MaxBytes uint32 `json:"maxBytes"`
}
StructuredRead contains immutable serialized intent, never a caller query or authority. TugQL is the existing serialized YAML/JSON query syntax. Parameters is a strict JSON object of apicontract.TypedValueOrSet. Empty means no bindings. The output is bounded without changing the query's limit, offset or ordering. MaxRows and MaxBytes have the same bounds as TableRead.
func (StructuredRead) RequestFor ¶ added in v0.135.0
func (op StructuredRead) RequestFor(nonce string) (ResultRequest, error)
RequestFor binds full operation bytes and bounds to an independently selected fresh nonce. Server and consumer call this from their own original intent.
type StructuredReadSource ¶ added in v0.135.0
type StructuredReadSource interface {
OpenStructuredRead(context.Context, StructuredIdentityRequest) (StructuredReadSpan, error)
}
StructuredReadSource is a trusted execution-only host port. Open follows Core candidacy. It must pin an independently identified native read-only span and a compiler profile that supports the actual operation; no permissions, grants, user policies or model-selected credentials enter it. Unsupported native profiles refuse. A TableReadSource never implies this broader profile.
type StructuredReadSpan ¶ added in v0.135.0
type StructuredReadSpan interface {
Session() dal.ReadSession
Verify(context.Context, StructuredIdentityRequest) (StructuredIdentityFacts, error)
Close() error
}
StructuredReadSpan has the same cancellation, rollback, allocation and cleanup-reporting duties as TableReadSpan. Verify must independently attest ALL requested resources and byte-exact compiler/source routing for this span. It is SQL-free while rows are active; request facts are not evidence to echo.
type StructuredResourceIdentity ¶ added in v0.135.0
StructuredResourceIdentity describes one source discovered by DALgo, never a permission. Table components are byte-exact; Path names a structural source. A database-qualified/federated source is not admitted by this single-span API.
type StructuredResultEnvelope ¶ added in v0.135.0
type StructuredResultEnvelope struct {
Payload json.RawMessage `json:"payload"`
Lease StructuredResultLease `json:"lease"`
}
func DecodeStructuredResultEnvelope ¶ added in v0.135.0
func DecodeStructuredResultEnvelope(data []byte) (StructuredResultEnvelope, error)
type StructuredResultLease ¶ added in v0.135.0
type StructuredResultLease struct {
ResultLease
Profile string `json:"profile"`
Operation StructuredRead `json:"operation"`
// ExecutedTugQL is the server-authenticated effective operation after
// subordinate constraints. It is never imported as executable authority.
// Its resources join authored resources for fresh retained-value checks.
ExecutedTugQL string `json:"executedTugql"`
ExecutionSHA256 string `json:"executionSHA256"`
}
StructuredResultLease is version3 metadata for the complete immutable structured operation. It is not a capability; v1 and table-v2 refuse it.
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" )
type TableIdentityFacts ¶ added in v0.133.2
type TableIdentityFacts struct {
Connection ConnectionRef
Table access.TableName
}
TableIdentityFacts identifies the source and native logical table that the exact written components execute. Components are values, never SQL syntax. This contract does not assert physical relation lineage across DDL changes.
type TableIdentityRequest ¶ added in v0.133.2
type TableIdentityRequest struct {
Connection ConnectionRef
Table access.TableName
}
TableIdentityRequest contains the written identity of one frozen structured source. Connection is the independently authenticated Core source binding; neither field is evidence for the verifier to echo back.
type TableIdentityVerifier ¶ added in v0.133.2
type TableIdentityVerifier interface {
VerifyTableIdentity(context.Context, dal.DB, TableIdentityRequest) (TableIdentityFacts, error)
}
TableIdentityVerifier is a trusted host fact port, not a permission evaluator. It must independently corroborate the actual supplied opened DB and establish immutable source routing and identifier/compiler semantics for its entire secured DB/reader lifetime (or pin an equivalent execution span). Sampling a mutable pool's catalog before/after I/O is insufficient. It must refuse when native folding, quoting, search paths, temporary aliases or routing prevent proof that the written components execute byte-exactly. The closed compiler must preserve source identity for every alias admitted by this profile. Lookup is read-only identity metadata work: no query payload, mutation or secret disclosure is permitted. It receives no grants. Core cannot detect a malicious trusted port lying about the supplied handle. No production opener is certified merely by implementing this interface.
type TableRead ¶ added in v0.134.0
type TableRead struct {
Object ObjectRef `json:"object"`
MaxRows uint32 `json:"maxRows"`
MaxBytes uint32 `json:"maxBytes"`
}
TableRead is an immutable operation description, not SQL or authorization. MaxRows is 1..100; MaxBytes is 1..262144 and includes protected preview metadata.
type TableReadInspection ¶ added in v0.137.0
type TableReadInspection struct {
// Admitted is the result of the same Authority admission that
// ReadTableResult runs before it opens any source, evaluated at the
// resolution's ServerTime instead of the local clock.
Admitted bool
// Code is the Core denial code when Admitted is false.
Code string
// Until is the admitted lease deadline on the ServerTime clock. It is zero
// when admission is refused.
Until time.Time
// Assessment is a reduced view of DALgo AssessPlan over the read rules
// that the same Core compiler produces for this request at ServerTime,
// intersected with the sealed exact mandatory policy when one is supplied.
// Rule IDs, row restrictions and explanations are dropped. Policy names and
// codes still distinguish a mandatory deny from no match, so this value is
// private-snapshot-grade: never serialise it to a caller who may not inspect
// the subject's access.
Assessment InspectedAssessment
}
TableReadInspection is a read-only view of one exact-table read decision. It is never authority: it carries no lease, capability or data value, and a host must never use it to admit an operation.
func InspectTableRead ¶ added in v0.137.0
func InspectTableRead(ctx context.Context, resolution Resolution, mandatory *ExactReadSnapshot, object ObjectRef) (TableReadInspection, error)
InspectTableRead answers whether ReadTableResult would admit a preview of one exact object for an already resolved authority snapshot, and why. It runs the unchanged Authority admission path and the unchanged read-policy compiler with the clock fixed at resolution.ServerTime, then asks DALgo AssessPlan for the policy metadata. It opens no source, reads no row and retains nothing.
The resolution must be what the trusted resolver would return for the subject and connection, including ProjectExactRead for posture exact-v1; mandatory must be the same sealed snapshot the host binds for execution.
type TableReadSource ¶ added in v0.134.0
type TableReadSource interface {
OpenTableRead(context.Context, TableIdentityRequest) (TableReadSpan, error)
}
TableReadSource is a trusted host opener. It independently binds the exact source, table, compiler/options and native allocation limits before opening data rows. No grants or payload callback enter this port. An unproved native profile must refuse; implementing this interface does not certify an opener.
type TableReadSpan ¶ added in v0.134.0
type TableReadSpan interface {
Session() dal.ReadSession
Verify(context.Context, TableIdentityRequest) (TableIdentityFacts, error)
Close() error
}
TableReadSpan pins one actual read-only native execution span. Session must remain bound to it; Verify is SQL-free immutable-proof/liveness validation, including while a cursor is active. No pooled sampling, lazy metadata SQL, mutable routing, compiler options, views or fallback are permitted. Close must cancel/invalidate and roll back safely during reads; never commit. The host owns redacted cleanup-error reporting, including after output was handed off.
type TableResultEnvelope ¶ added in v0.134.0
type TableResultEnvelope struct {
Payload json.RawMessage `json:"payload"`
Lease TableResultLease `json:"lease"`
}
func DecodeTableResultEnvelope ¶ added in v0.134.0
func DecodeTableResultEnvelope(data []byte) (TableResultEnvelope, error)
type TableResultLease ¶ added in v0.134.0
type TableResultLease struct {
ResultLease
Profile string `json:"profile"`
Operation TableRead `json:"operation"`
}
TableResultLease is an additive version2 binding for an exact Core operation. It is metadata, not a capability. v1 result decoders/importers refuse it.
Source Files
¶
- authority.go
- contracts.go
- exact_read_policy.go
- exact_read_projection.go
- local_authority.go
- nil_value.go
- operation_read_policy.go
- reader.go
- result.go
- session.go
- structured_operation.go
- structured_read.go
- structured_result.go
- table_identity.go
- table_payload.go
- table_read.go
- table_read_inspection.go
- table_result.go
- validation.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package perimeter answers read-only effective-access questions over one immutable snapshot of stored access facts: what a subject can read and why, and who can read a table and why.
|
Package perimeter answers read-only effective-access questions over one immutable snapshot of stored access facts: what a subject can read and why, and who can read a table and why. |