Documentation
¶
Overview ¶
Package auditshared holds analysis helpers shared by the discovery-metadata auditors (cmd/audit_1to1 R-META and cmd/audit_discovery_completeness): the projected-description probe, owner-package resolution, and the shared usage/description quality checks.
It also holds NewStubGitLabClient, the offline GitLab client the audit commands construct. That one is a thin delegation to mcpsurface.NewStubClientWithToken rather than a client of its own, so the audits and the generators share a single definition of what "no instance, no credentials" means: the same compiled-in URL, the same constant token, and the same disabled retries.
Index ¶
- Constants
- func CachedActionSpecs(client *gitlabclient.Client, enterprise bool) []tools.ActionSpecGroup
- func CachedIndividualDescriptions(client *gitlabclient.Client) map[string]string
- func DiscoverActionSpecGroupBuilders(dir string) ([]string, error)
- func IsActionSpecGroupBuilderName(name string) bool
- func IsGenericUsage(usage string) bool
- func NewStubGitLabClient(token string) (client *gitlabclient.Client, cleanup func())
- func OwnerPackage(group tools.ActionSpecGroup, spec toolutil.ActionSpec) string
- func ProjectIndividualDescriptions(client *gitlabclient.Client) map[string]string
- func WeakIndividualDescription(spec toolutil.ActionSpec, projected map[string]string) bool
Constants ¶
const StubToken = "audit-token" //#nosec G101 -- not a real credential, in-process stub only
StubToken is the dummy credential the audit commands authenticate their stub client with. It is never sent to a real GitLab instance: the client points at an in-process HTTP server.
Variables ¶
This section is empty.
Functions ¶
func CachedActionSpecs ¶
func CachedActionSpecs(client *gitlabclient.Client, enterprise bool) []tools.ActionSpecGroup
CachedActionSpecs returns the collected action specs for the given tier selector, computed once per process and per flag. The slice and everything it references are shared: read-only.
func CachedIndividualDescriptions ¶
func CachedIndividualDescriptions(client *gitlabclient.Client) map[string]string
CachedIndividualDescriptions returns the projected individual-tool descriptions, computed once per process. The map is shared: read-only.
func DiscoverActionSpecGroupBuilders ¶
DiscoverActionSpecGroupBuilders scans the top-level non-test, non-generated .go files of dir for buildXxxActionSpecs builder functions and returns their sorted names. It fails on duplicate builder names and when no builders are found, so both the manifest generator and the catalog-first auditor agree on the same source of truth.
func IsActionSpecGroupBuilderName ¶
IsActionSpecGroupBuilderName reports whether a function name follows the buildXxxActionSpecs convention used by the per-domain catalog builders.
func IsGenericUsage ¶
IsGenericUsage reports whether the Usage string is the placeholder template or empty.
func NewStubGitLabClient ¶
func NewStubGitLabClient(token string) (client *gitlabclient.Client, cleanup func())
NewStubGitLabClient builds a GitLab client pointed at an in-process HTTP stub that answers every request with a fixed version payload. Generators and auditors use it to register the tool catalog offline. The returned cleanup func shuts the stub server down.
It is mcpsurface.NewStubClientWithToken under the name the audit commands call it by: one stub, so a command cannot audit a surface built against a differently configured client than the one the generators describe.
func OwnerPackage ¶
func OwnerPackage(group tools.ActionSpecGroup, spec toolutil.ActionSpec) string
OwnerPackage resolves the owning package for an action: the spec override wins, then the group owner, then the group base domain.
func ProjectIndividualDescriptions ¶
func ProjectIndividualDescriptions(client *gitlabclient.Client) map[string]string
ProjectIndividualDescriptions returns the projected description per individual-tool name: the exact text the model consumes. Prefer CachedIndividualDescriptions unless a fresh projection is the point.
It is a projection over mcpsurface.IndividualTools, which is the one reader of the served surface: the listing itself, the served-schema chain applied to it and the memo behind it all live there.
func WeakIndividualDescription ¶
func WeakIndividualDescription(spec toolutil.ActionSpec, projected map[string]string) bool
WeakIndividualDescription reports whether the effective individual-tool description the model sees lacks the norm's "Returns: … See also: …" form. The effective description is the projected mcp.Tool.Description (which already resolves the curated-description fallback chain), so this avoids false positives from specs that omit IndividualTool.Description yet still project a good curated one.
Types ¶
This section is empty.