Skip to content

feat(agentfabric): schema-driven graph extraction + graph-aware lint rules#53

Merged
marianogonzalez merged 5 commits into
salesforce:mainfrom
Drake-Ash:patch/add-new-lint-rules-for-agentfabric
Jun 8, 2026
Merged

feat(agentfabric): schema-driven graph extraction + graph-aware lint rules#53
marianogonzalez merged 5 commits into
salesforce:mainfrom
Drake-Ash:patch/add-new-lint-rules-for-agentfabric

Conversation

@Drake-Ash

@Drake-Ash Drake-Ash commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

What

Expands the AgentFabric dialect with new graph-aware lint rules, a schema-driven
graph-extraction library, and the @agentscript/language primitives those features
depend on.

The diff spans three layers:

  1. AgentFabric lint — five new rules (cycle detection, execute-body validation,
    action-binding validation, unused-node, strict schema validation) and removal
    of two deprecated router checks.
  2. New graph library (dialect/agentfabric/src/graph/) — extracts a directed
    node/edge graph from a parsed document purely from schema metadata, plus an
    adapter to the agent-graph canvas protocol.
  3. @agentscript/language core — new schema field markers, a unified completions
    resolver, and cycle-safe schema walkers.

How

New lint rules (src/lint/passes/rules/)

  • cycle-rules.ts — Detects execution-graph cycles via iterative DFS over extracted
    edges, deduped by a rotation-invariant signature. Warns on each cycle member
    (cycle-detected), e.g. Cycle detected in execution flow: @a → @b → @a.
    Triggers are excluded from membership but seed the traversal.
  • execute-rules.ts — Validates each executor do body: set targets must be
    @variables./@outputs.; run targets must reference an @actions.* def whose
    kind is a2a:send_message or mcp:tool; with params must match declared inputs;
    bare @ and @actions.* are rejected as values.
  • action-binding-rules.ts — For orchestrator/subagent/generator nodes, validates
    every with <param> in a reasoning.actions binding is a declared input (or
    implicit param).
  • unused-node.ts — Flags declared-but-unreferenced nodes as an Information
    diagnostic tagged Unnecessary, with a removalRange for quick removal.
  • strict-schema-validation.ts — Promotes unknown-field/unknown-block from
    Warning → Error (AgentFabric is a strict compile target).
  • Also enables the core unusedVariablePass for the dialect.
    Removed: deprecated switch-choices-deprecated and switch-on-exit router checks.

New graph library (src/graph/)

  • extractor.ts — Schema-driven extractor. Nodes/edges are derived from the
    transitionTarget capability and transitionContainer/transitionTarget field
    markers — no block/field names hardcoded. Surfaces lexical ranges, sibling
    primitives, and predicates.
  • get-graph.ts — Adapter to the agent-graph canvas protocol ({nodes, edges} with
    first-class kind + open additionalProperties). Documents a comma-escaping
    grammar for the joined outputs summary that must stay in sync with the UI parser.
  • extractGraph/getGraph re-exported from the package entry point.

@agentscript/language core

  • New FieldMetadata flags + FieldBuilder methods: transitionContainer(),
    predicateField(), outputNameField(), displayLabelField().
  • Completions refactor — getFieldCompletions and getValueCompletions now share one
    walkParentsToSchemaContext resolver (the two prior divergent walkers were a bug
    source). Value completions are discriminant-variant aware and add quoted
    enum-member completions via insertText. getValueCompletions now takes ast.
  • scope.ts walkers gain a WeakSet visited-guard for self-referential schemas.
  • Exports isAstNodeLike and the Range type.

Schema changes

  • AgentFabric: OutputPropertyBlock is now genuinely self-referential (recursive
    items/properties) via lazy proxy field wrappers; adds includeDefault. Applies
    the new field markers across node blocks. Adds XHIGH to reasoning_effort.
    Removes explicit http_headers (now an implicit with param).
  • AgentScript: marks baseSubagentFields.label as displayLabelField so cloned
    orchestrator nodes surface their label in the extracted graph.

Tests

New suites cover the extractor, protocol adapter, LLM variant/value completions,
snippet indentation, and the new lint rules.

Test Plan

  • Existing tests pass (pnpm test)
  • New/updated tests cover the change
  • Linting and type checks pass (pnpm lint && pnpm typecheck)

Checklist

  • My code follows the project's coding style
  • I have reviewed my own diff
  • I have added/updated documentation as needed
  • This change does not introduce new warnings

sf-ashwin added 3 commits June 5, 2026 20:12
Sync the agentfabric dialect and the @agentscript/language APIs it
depends on from the internal module-agentscript repo, so the build and
test suite pass in op-agentscript.

- Add agentfabric compiler and graph-extraction modules, lint rules, and
  tests carried over from module-agentscript.
- Extend @agentscript/language with the graph field markers the dialect
  needs: transitionContainer, predicateField, outputNameField, and
  displayLabelField (core/types.ts FieldMetadata flags + field-builder
  methods). Export isAstNodeLike and the Range type.
- Update getValueCompletions to the AST-aware signature and add
  walkParentsToSchemaContext plus CompletionCandidate.insertText; thread
  cycle detection through scope.ts walkers; update the lsp caller.
- Mark agentscript-dialect baseSubagentFields.label as displayLabelField
  so orchestrator nodes (cloned from SubagentBlock) surface their label
  in the extracted graph.
@Drake-Ash Drake-Ash changed the title patch: update agentfabric lint rules feat(agentfabric): schema-driven graph extraction + graph-aware lint rules Jun 8, 2026
@Drake-Ash Drake-Ash marked this pull request as draft June 8, 2026 10:01
@Drake-Ash Drake-Ash marked this pull request as ready for review June 8, 2026 11:53
@marianogonzalez marianogonzalez merged commit cf38657 into salesforce:main Jun 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants