{"modulePath":"github.com/txn2/mcp-data-platform","version":"v1.172.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package tablesource\n\nPackage tablesource is the registrar's view of the two kinds of stored file a table is built over: how a managed resource and a portal asset are resolved into a tableregister.Source, and under which rule.\n\nThree resolutions serve three questions, and they are kept together because they read the same two stores and build the same Source from the same record. Subjects decides whether THIS caller may act on the file, which is what the register and unregister routes and the manage\\_table tool ask. RefLookup resolves a page of records at once for the cross-source listing, where authority is a field on the answer rather than the answer itself. Locator resolves a record with no caller at all, for the follow a content write triggers (#1536): the write was authorized by the surface that made it, and the follow acts for the registrant.\n\nIt is its own package rather than part of the HTTP composition root because nothing in it composes anything: it is the rule for who may register a file and the shape of a file as the registrar sees it, applied identically by every door.\n\n## Functions\n\n```go\nfunc AssetSubject(store portal.AssetStore) tableregister.Subject\n```\nAssetSubject resolves a portal asset for the table surfaces.\n\n```go\nfunc AssetVisibleTo(asset portal.Asset, caller tableregister.Caller) bool\n```\nAssetVisibleTo reports whether this caller may act on an asset through the table surfaces.\n\nAn asset belongs to one person, so the owner and an administrator reach it and nobody else does; an editor share does not carry it, because registering publishes the file's contents into a schema everyone with the connection can read, which is owner authority the way sharing is.\n\nOwnership is the portal's own judgment (assetOwnerOf), so a table over a managed script's output is registered, listed and dropped by the same person the portal calls its owner, and by nobody else.\n\nThe administrator arm is the caller's IsAdmin, which every surface that assembles a caller resolves by the platform's one admin rule (#2228).\n\n```go\nfunc Locator(resources resource.Store, resourceBucket string, assets portal.AssetStore) tableregister.Locator\n```\nLocator resolves a source by kind and id with no authority check. It is what a follow reads the source's new head through (#1536): the write that moved the head was authorized by the surface that made it, and the follow acts for the registrant, not for the caller of the write. A kind whose store is absent, a record that is gone, and a deleted asset all answer ok=false.\n\n```go\nfunc RefLookup(\n\tresources resource.Store, bucket string, assets portal.AssetStore,\n) tableregister.Sources\n```\nRefLookup dispatches a listing's source resolution to the store that holds that kind, the way Subjects does for the per-source routes.\n\n```go\nfunc ResourceSubject(store resource.Store, bucket string) tableregister.Subject\n```\nResourceSubject resolves a managed resource for the table surfaces.\n\nThe rule is authority to CHANGE the resource, not authority to read it: resource.CanModifyResource, which is the uploader, a platform administrator, or an administrator of the scope the resource lives in -- the same rule that governs updating and deleting it. Registering publishes the file's contents into a schema everyone granted the connection can read, and resource scopes are not carried into Trino (docs/security/threat-model.md), so a read rule here would let anyone who can see a persona-scoped file widen its audience. This matches the asset rule below, so one sentence describes both kinds.\n\n```go\nfunc ResourceSubjectShared(store resource.Store, bucket string, shared SharePermission) tableregister.Subject\n```\nResourceSubjectShared is ResourceSubject that also admits an editor share of the resource (resource.CanEditResource, #2258): the person it was shared with to edit may register a table over it, as its owner may. nil shared is ResourceSubject.\n\n```go\nfunc Subjects(\n\tresources resource.Store, resourceBucket string, assets portal.AssetStore,\n) map[string]tableregister.Subject\n```\nSubjects is the one place a stored file is resolved and the caller's authority over it is decided, per kind. Both surfaces take their resolvers from here: the REST routes convert their authenticated portal user into a Caller, and the tool reads one from the platform context.\n\nA kind whose store is absent has no entry, which leaves that kind unregisterable on both surfaces rather than half-served on one.\n\n## Types\n\n```go\ntype SharePermission func(ctx context.Context, resourceID string, caller tableregister.Caller) string\n```\nSharePermission is the permission a share gives the caller on a resource: \"editor\", \"viewer\" or \"\" (#2258).\n\n","path":"github.com/txn2/mcp-data-platform/internal/httpserver/tablesource","name":"tablesource","synopsis":"Package tablesource is the registrar's view of the two kinds of stored file a table is built over: how a managed resource and a portal asset are resolved into a tableregister.Source, and under which rule.","isRedistributable":true}
