feat(agent): implementation-backed Factory agent capability layer - #8
Merged
Conversation
Expose Factory's real authoring capabilities to agents through ONE typed operation registry (src/operations/), with the SDK, CLI, deterministic capability catalog, generic tool definitions, and an MCP-compatible stdio adapter all projecting over the SAME handlers. - src/operations/: 14 operations wrapping the existing library functions (validateDocument, instantiateTemplate, inspectPipeline, canonical hashing, scaffolding, graph/plugin discovery). Each op has a real handler, validated input + output schemas, a declared fs/security policy, and test coverage. - Fail-closed workspace boundary (canonical realpath, symlink-aware): traversal, absolute/symlink/parent-symlink escape, and unauthorized overwrite all reject. - src/agent/: deterministic id-sorted catalog (+ stable hash), framework-neutral tool definitions, and a JSON-RPC-2.0 MCP stdio adapter (no network listener, no shell, no dynamic import). - CLI: new `capabilities [--json|--tools|--hash]` and `agent serve --transport stdio`; all existing commands preserved (skeleton/slot helpers hoisted to a shared authoring.ts used by both CLI and agent). - Tests (+59): registry invariants, deterministic catalog, CLI/agent parity, filesystem-safety proofs, generic tool defs, MCP adapter, agent workflows A-D, guardrails (no static catalog; no afi-skills reintroduction). 186/186 pass. Authoring-side implementation metadata only — not the API Atlas, not an executor, holds no canonical contracts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
- workspace: resolveWriteTarget classified the target with existsSync(), which
returns false for a DANGLING symlink — so a pre-placed symlink to a not-yet-
existing outside path was followed by writeFileSync, escaping the workspace
(reproduced through plugin.scaffold and artifact.package). Now classify with
lstat (which observes a dangling link) and reject any symlink target closed.
- registry: the compiled-validator cache was keyed by `${operationId}:${dir}`,
so a forged OperationDef reusing a registered id with a looser schema could
poison the validator used for the real op. Key the cache by schema-object
identity instead — each operation always enforces its own declared schema.
Regression tests added for both (dangling-symlink escape via resolveWriteTarget
and plugin.scaffold; validator-cache isolation via executeOperation). 189/189.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Exposes afi-factory's real authoring capabilities to agents through one implementation-backed operation registry. The Factory SDK, CLI, machine-readable capability catalog, generic agent-tool definitions, and MCP adapter are all projections over the same typed operation handlers — a capability cannot exist without a real handler, validated input/output schemas, a declared filesystem/security policy, and tests.
What's added
src/operations/— 14 typed operations wrapping the existing library (validateDocument,instantiateTemplate,inspectPipeline, canonical hashing, scaffolding, graph/plugin discovery). Every op: real handler, validated input and output, declared fs/security policy.factory.capabilities.list,factory.plugins.list,factory.templates.listfactory.template.{create,validate,inspect,instantiate}factory.pipeline.{validate,inspect}factory.analystConfig.{create,validate}factory.plugin.scaffold,factory.artifact.{hash,package}workspace.ts) — canonical realpath, symlink-aware. Traversal, absolute-path escape, symlink escape, symlinked-parent escape, and unauthorized overwrite all reject; read-only ops never write.src/agent/— deterministic id-sorted capability catalog (+ stable hash), framework-neutral tool definitions, and a JSON-RPC-2.0 MCP stdio adapter (transport only; no network listener, no shell, no dynamic import).capabilities [--json|--tools|--hash]andagent serve --transport stdio [--workspace <dir>]. All existing commands preserved; skeleton/slot helpers hoisted to a sharedauthoring.tsused by both CLI and agent.Tests
186/186pass (127 baseline preserved + 59 new): registry invariants, deterministic catalog, CLI/agent parity, filesystem-safety proofs, generic tool defs, MCP adapter, agent workflows A–D, and guardrails (no static hand-maintained catalog; noafi-skillsreintroduction).Scope
Authoring-side implementation metadata only. Not the API Atlas, not an executor, holds no canonical contracts (those remain vendored from afi-config). No pipeline execution / scoring / evidence / UWR semantics changed. District pipeheads untouched.
🤖 Generated with Claude Code