Skip to content

refactor(discovery): graduate agent-def + skills discovery into engine/adapter (#328) - #333

Merged
JAORMX merged 2 commits into
mainfrom
feat/graduate-discovery-adapters-328
Aug 2, 2026
Merged

JAORMX merged 2 commits into
mainfrom
feat/graduate-discovery-adapters-328

Conversation

@JAORMX

@JAORMX JAORMX commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Closes #328.

What

Graduates the two filesystem discovery adapters into the importable engine module, following the fstools (#269 / #277) pattern, so an engine importer gets .claude/agents + .claude/skills discovery — and a working Subagent(agent=…) / Skill tool — without depending on the root module:

  • engine/adapter/agentfs — the whole of internal/adapter/agents (agent-def discovery, frontmatter parser, FSSource, precedence MultiSource, registry).
  • engine/adapter/skillfs — the READ-ONLY skills core (resolve/source/fssource/skill/tool/activator/discover/sanitize). The writable SkillDraft half (drafter/drafttool/novelty/promote/assetcache) stays in root and reaches the core through the alias.

How

  • Carried helpers live in per-package carry.go, pinned byte-identical to their internal/adapter/{toolkit,xdgconfig,osfs} origins (the engine module must not import the root module — fstools precedent).
  • The one osfs edge (read-root canonicalisation in fssource.go) is broken by carrying osfs.resolveRoot verbatim into skillfs — no osfs import.
  • skillfs.NewSourceActivator now takes an unexported consumer-side assetProvisioner interface; root *AssetMaterializer satisfies it implicitly (root alias re-exports the constructor as a var since a wrapper can't name the unexported param).
  • skillfs.ParseSkill exported for the root promotion gate.
  • Root internal/adapter/{agents,skills} are now thin alias shims (the internal/adapter/tools/alias.go pattern) — every existing caller keeps compiling; no second copy to drift.
  • engine/go.mod gains a direct require on go.yaml.in/yaml/v3 (both frontmatter parsers already used it; the issue's "no new non-stdlib module" line was amended by maintainer decision). ADR 0036 + AGENTS.md closure sentences updated (also picking up robfig/cron, which the scheduler already added).
  • depguard: two new engine/adapter/* blocks allow os (discovery is inherently filesystem-walking) and deny os/exec.
  • engine/COMPATIBILITY.md: both packages listed under the engine/adapter/* "excluded, may change without notice" clause; no CHANGELOG entry per the fstools precedent.
  • Docs: AGENTS.md, architecture.md, IMPLEMENTATION-NOTES.md, dead citations in ADR 0023/0025 + architecture/{extensibility,observability}.md repointed, user-docs extension pages (agent-definitions, tool-catalog) updated in the same PR.

Review

Ran the full dev-pipeline: separate architect → 3 implementer waves → panel review (Spec / Security / Architecture / library-reuse / code-duplication) + independent QA test-adequacy review. Zero ship-blockers. One applied finding: the four hand-rolled UTF8RuneStart copies were byte-identical to stdlib utf8.RuneStart — deleted in toolkit, fstools, agentfs, skillfs. The "extract a shared engine helper package" suggestion was deliberated and rejected (would couple two independent bounded contexts and force every adapter's depguard allowlist to widen; the N=3 pin-comment discipline holds).

Verification

  • task lint (both modules) — 0 issues
  • task test — full suite green, incl. -race and the GOWORK=off engine-standalone hygiene proof
  • task api:check — green (no core API drift; engine/adapter/* is outside the gate)
  • go run ./cmd/mecademo — full offline session
  • task site:build — user-docs build green
  • Consumer proof: a throwaway GOWORK=off module (.scratch/consumer-328) importing only engine/adapter/{agentfs,skillfs} resolved .claude/agents/*.md and .claude/skills/*/SKILL.md fixtures; its module graph pulls only the engine's small closure + yaml.

JAORMX and others added 2 commits August 1, 2026 21:07
…e/adapter (#328)

Move the two filesystem discovery adapters into the importable engine
module, following the fstools (#269) graduation pattern:

- engine/adapter/agentfs — the whole of internal/adapter/agents
  (.claude/agents discovery, frontmatter parser, FSSource, MultiSource,
  registry). engine/adapter/skillfs — the READ-ONLY skills core
  (.claude/skills discovery, FSSource, the Skill tool body, activator,
  injection scanner). The writable SkillDraft half stays in root and
  reaches the core through the alias.
- Carried helpers live in per-package carry.go files, pinned
  byte-identical to their internal/adapter/{toolkit,xdgconfig,osfs}
  origins (the engine module must not import the root module).
- The one osfs edge (read-root canonicalisation) is broken by carrying
  osfs.resolveRoot verbatim into skillfs — no osfs import.
- skillfs.NewSourceActivator now takes an unexported consumer-side
  assetProvisioner interface; root *AssetMaterializer satisfies it
  implicitly. skillfs exports ParseSkill for the root promotion gate.
- Root internal/adapter/{agents,skills} become thin alias shims (the
  internal/adapter/tools pattern); no second copy to drift.
- engine/go.mod gains a direct require on go.yaml.in/yaml/v3 (both
  frontmatter parsers use it; operator-approved). ADR 0036 + AGENTS.md
  closure sentences updated (also picking up robfig/cron).
- New depguard blocks allow os (discovery is filesystem-walking) and
  deny os/exec. COMPATIBILITY.md lists both under the engine/adapter/*
  exclusion; no CHANGELOG entry per the fstools precedent.
- Panel review fix: the four hand-rolled UTF8RuneStart copies were
  byte-identical to stdlib utf8.RuneStart — deleted in toolkit, fstools,
  agentfs, skillfs.

Verified: task lint, task test (incl. GOWORK=off engine-standalone),
task api:check, cmd/mecademo, task site:build, plus a throwaway
GOWORK=off consumer module in .scratch resolving both .claude/agents
and .claude/skills fixtures through the new packages.

Co-Authored-By: mecatl <[email protected]>
…def (#328)

The live suite exercised skill activation and generic subagents but never
a NAMED agent definition — the agentfs half of the graduation. Add a
fixture def (e2e/fixtures/agents/fruit-reader.md, scoped tools: Read)
laid out at <workspace>/.claude/agents/ by the harness, and a spec that
delegates Subagent(agent="fruit-reader") and asserts on EVENTS: the call
names the def, the result succeeds with the agentId trailer and carries
the FRUIT.txt fact, the child ends stop=end_turn, and no approval
surfaces. The child's own Read is deliberately not asserted — child tool
calls stay on the child stream (gauntlet #7).

Verified live against OpenRouter (focused run, incl. the two pre-existing
skills specs as a fixture-change smoke check).

Co-Authored-By: mecatl <[email protected]>
@JAORMX JAORMX added the e2e-live Run the live e2e suite on this PR label Aug 2, 2026
@JAORMX
JAORMX merged commit 4967891 into main Aug 2, 2026
16 checks passed
@JAORMX
JAORMX deleted the feat/graduate-discovery-adapters-328 branch August 2, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e-live Run the live e2e suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant