Skip to content

Graduate agent-definition and skills discovery into the engine module so importers get .claude/agents + .claude/skills without the root module #328

Closed

Description

@jerm-dro

Problem

engine/ ships the ports for named agent definitions and progressive-disclosure skills — tool.AgentSource (engine/tool/agentsource.go), tool.SkillSource (engine/tool/skillsource.go), and the sourceconformance suite that proves an implementation correct — but no implementation of either. Every filesystem-backed discovery adapter lives in the root module:

  • internal/adapter/agents (~2,060 LoC) — ProjectDirClaude = ".claude/agents" (resolve.go:16), the frontmatter def parser, the FSSource, the precedence-ordered MultiSource, the registry.
  • internal/adapter/skills (~4,340 LoC total; ~1,180 in the read-only core) — ProjectDirClaude = ".claude/skills" (resolve.go:16), the SKILL.md discovery/parse, the FSSource, the Skill tool body itself (tool.go:15, ToolName = "Skill"), the activator.

Neither is importable. github.com/stacklok/mecatl root is explicitly outside the compatibility boundary (engine/COMPATIBILITY.md: "The entire root module — internal/, cmd/, contracts/, perf/ … carry no external compatibility promise"), and MVS-wise importing it reintroduces exactly the adapter dep-cone #113 removed.

Net effect for an engine importer: an embedded loop has no Skill tool at all, and its Subagent(agent=…) parameter is permanently inert — the model sees an affordance the harness cannot satisfy. The consumer's only options are to reimplement ~3,000 LoC of discovery + frontmatter parsing + trust tiering, or to depend on the root module. This is the same shape as #269 (FS tool bodies): the correctness-heavy code exists, tested, and is walled off from the people who need it.

Concrete consumer

jerm-dro/fogburn embeds engine/agent and vendors only github.com/stacklok/mecatl/engine. Its .claude/skills/{migration-audit,pr-test-audit}/SKILL.md and any .claude/agents/*.md are unreachable from a fogburn-driven session; the repo's Subagent tool advertises an agent argument that can never resolve. Same gap Atrium hits from the other direction.

Scope: the two discovery adapters + the Skill tool body

Follow the #269 pattern exactly — move the engine-clean code, carry only the helpers it needs, leave the OS-coupled parts to the consumer.

In scope

  • engine/adapter/agentfs — the whole of internal/adapter/agents. Its entire non-stdlib import set today is engine/tool + two helper packages (toolkit.SplitFrontmatter, xdgconfig.{OSEnv,ResolveEnv,UserConfigDir}). It reads the filesystem with plain os.ReadDir/os.ReadFile (discover.go:277-297) — no osfs, no gitenv, no secret-scrub cone. This is the cheaper half; do it first.
  • engine/adapter/skillfs — the READ-ONLY skills core: resolve.go, source.go, fssource.go, skill.go, tool.go, activator.go, discover.go, sanitize.go (~1,180 LoC). Non-stdlib closure is engine/{session,tool} + toolkit.{SplitFrontmatter,MaxOutputBytes,ParseArgs,Schema,Truncate,TruncateRunes} + xdgconfig + one call to osfs.ResolveRoot (fssource.go:268, for read-root canonicalisation).
  • Carry the helpers, don't move them. Inline the six toolkit functions and the three xdgconfig functions, as Graduate the six FS tool bodies into engine/adapter/tools so engine importers don't reimplement them #269 did for fstools (engine/adapter/fstools/fstools.go:82 re-declares MaxOutputBytes with a comment pinning it to the toolkit original). toolkit is a grab-bag used across mcp/memory/skills/agents; moving it wholesale ripples for no benefit here.
  • Break the one osfs edge. fssource.go:268 calls osfs.ResolveRoot (abs + EvalSymlinks) to canonicalise skill read-roots to match the osfs enforcement layer. That is ~2 lines of stdlib; inline it, or take an injected canonicaliser func. Do NOT drag osfs in — it is the ~900-line hardened Workspace Graduate the six FS tool bodies into engine/adapter/tools so engine importers don't reimplement them #269 deliberately left out.
  • .golangci.yml + engine/arch/layering_test.go entries. Copy an existing block. Note these two need os allowed (unlike every current engine/adapter/* block, which denies it) — discovery is inherently filesystem-walking. Say so in the block's desc, and consider a narrower deny (os/exec, network) instead.
  • Root-module aliases. Add internal/adapter/{agents,skills}/alias.go re-exporting the graduated types, exactly as internal/adapter/tools/alias.go does for fstools after Graduate the six FS tool bodies into engine/adapter/tools so engine importers don't reimplement them #269 — so internal/app, cmd/mecated, cmd/mecatui keep compiling untouched and there is no second copy to drift.
  • engine/COMPATIBILITY.md — list both under the existing engine/adapter/* "excluded, may change without notice" clause.

Out of scope (deliberately)

  • The writable SkillDraft half — drafter.go, drafttool.go, novelty.go, promote.go, assetcache.go (~830 LoC). The quarantine directory, similarity threshold, and promote CLI are an operator workflow, not a discovery primitive; assetcache.go exists to serve the remote gRPC driver branch. A consumer wanting model-authored skills is a separate issue.
  • osfs itself, and the WithReadRoots carve-out plumbing. The graduated FSSource should return the read-roots it needs (it already does — fssource.go:236-268); wiring them into a concrete Workspace stays the consumer's job. (fogburn's Workspace explicitly drops this carve-out today, cli/internal/tools/workspace.go:35.)
  • The grpcdriver remote sources — heavy contracts/grpc closure, internal/ by right.
  • The trust-gate policy decision. Graduate the mechanism (ResolveOptions.IncludeProjectTier is already a plain bool the caller sets); the default stays the composition root's call. Note for the PR: today both binaries default TrustProject=false (cmd/mecatui/config_test.go:41-42), so project-tier defs/skills are withheld on an untrusted checkout — the graduated package must keep that gate a caller input, never a hardcoded default.

What a consumer still owns

  • a tool.Workspace (and, if it wants activated-skill file reads, the read-root carve-out),
  • the trust decision feeding IncludeProjectTier,
  • registering the Skill tool and wiring AgentSource into its Subagent construction.

Acceptance

  • A fresh module importing engine/adapter/{agentfs,skillfs} resolves .claude/agents/*.md and .claude/skills/*/SKILL.md from a workspace root, with engine/adapter/sourceconformance passing against both.
  • No new non-stdlib module in engine/go.mod.
  • Root module builds unchanged via aliases; internal/adapter/{agents,skills} contain no second copy of the moved bodies.
  • task api:check / CHANGELOG per COMPATIBILITY.md.

Payoff

An engine importer gets working named specialists and skills — the two "what should the agent know here" primitives — by importing them. Without this, Subagent(agent=…) is a documented affordance that no external consumer can honour.

Sibling of #269 (same graduation pattern, same rationale). Related: #194 (the toolkit-consumer guide would document these).

Activity

  1. added
    enhancement
    atrium-convergence
    on Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    atrium-convergenceenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions