Skip to content

feat(agent): implementation-backed Factory agent capability layer - #8

Merged
Gio2050 merged 2 commits into
mainfrom
feat/factory-agent-capability-layer-v1
Jul 17, 2026
Merged

feat(agent): implementation-backed Factory agent capability layer#8
Gio2050 merged 2 commits into
mainfrom
feat/factory-agent-capability-layer-v1

Conversation

@Gio2050

@Gio2050 Gio2050 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

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.list
    • factory.template.{create,validate,inspect,instantiate}
    • factory.pipeline.{validate,inspect}
    • factory.analystConfig.{create,validate}
    • factory.plugin.scaffold, factory.artifact.{hash,package}
  • Fail-closed workspace boundary (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).
  • CLI — new capabilities [--json|--tools|--hash] and agent serve --transport stdio [--workspace <dir>]. All existing commands preserved; skeleton/slot helpers hoisted to a shared authoring.ts used by both CLI and agent.

Tests

186/186 pass (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; no afi-skills reintroduction).

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

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>
@cursor

cursor Bot commented Jul 17, 2026

Copy link
Copy Markdown

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>
@Gio2050
Gio2050 merged commit 232707b into main Jul 17, 2026
1 of 2 checks passed
@Gio2050
Gio2050 deleted the feat/factory-agent-capability-layer-v1 branch July 17, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant