Skip to content

feat(ai): add recursive agent composition analysis#159

Merged
rizumita merged 1 commit into
mainfrom
feat/recursive-agent-157
Jul 8, 2026
Merged

feat(ai): add recursive agent composition analysis#159
rizumita merged 1 commit into
mainfrom
feat/recursive-agent-157

Conversation

@rizumita

@rizumita rizumita commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds recursive fsl-ai agent parsing and IR for scoped nested agents, explicit authority/context grants, output visibility, orchestration edges, failure policy, and lightweight contract rule metadata.
  • Adds fslc ai check structural analysis for agent graphs with deterministic agent_ir and graph summaries.
  • Preserves existing ai_component hard-contract lowering/replay behavior and extends docs, examples, schemas, skill reference, LSP indexing, and corpus snapshots.

Why

  • Goal: Implement Implement recursive agent composition for fsl-ai #157 without introducing a separate sub_agent concept.
  • Reason: Nesting should define lexical scope and grant boundaries, while runtime collaboration stays in a separate orchestration/delegation graph.
  • Alternative: Lower recursive agents into the kernel immediately. Rejected for this PR because agent composition is structural graph evidence, not a formal proof of LLM semantics.

What Changed

  • Parser/IR: top-level and nested agent blocks, bracketed lists, grants, visibility, orchestration, failure policy, trust labels, review gates, and contract { hard { rule ... } } metadata.
  • Analysis: validates grant subset boundaries and reports agent_structural_violation findings for authority exceedance, low-trust reachability to high-authority tools, irreversible tools without human approval, review bypass, and sibling visibility leaks.
  • CLI: fslc ai check now handles both ai_component and agent; regular fslc check accepts agent files for corpus parse/semantic sweeps without claiming kernel proof.

Blast Radius

  • Affected: src/fslc/ai_*, CLI AI commands, LSP raw-tree parser selection, AI finding schema, examples/docs/skills, corpus snapshot.
  • Compatibility: Existing ai_component syntax, check result, replay result, and focused tests remain unchanged.

Invariants

Condition Evidence If Broken
ai_component remains backward-compatible tests/test_ai_hard_contract.py Existing AI hard-contract users regress
Recursive agents do not implicitly inherit parent authority/context grant rejection and exceedance tests Nested agents gain unsafe capabilities silently
Agent analysis does not claim formal proof formal_result: "not_run" tests/docs Structural findings could be mistaken for verifier proof

Failure Modes

Type Pattern Detection
Likely Parser ambiguity between component output and agent output visibility recursive agent focused tests
Severe Child grant exceeds parent boundary but is accepted invalid grant regression test
Subtle Visibility/delegation graph conflated with lexical nesting graph summary and visibility leak tests

Evidence

  • .venv/bin/python -m pytest tests/test_ai_recursive_agent.py tests/test_ai_hard_contract.py -q -> 18 passed
  • .venv/bin/python -m pytest tests/test_corpus_snapshot.py -q -> 176 passed, 1 skipped
  • .venv/bin/python -m pytest -q -> 1004 passed, 78 skipped
  • git diff --check

Rollout & Rollback

  • Rollout: Normal release; new agent syntax is additive.
  • Rollback: Revert this commit. Existing ai_component behavior is isolated from the new structural analyzer.

Review Focus

  • src/fslc/ai_parser.py: grammar remains unambiguous and preserves ai_component syntax.
  • src/fslc/ai_agent.py: grant subset and graph findings match Implement recursive agent composition for fsl-ai #157 semantics.
  • docs/DESIGN-ai-hard.md / docs/LANGUAGE.md: proof boundary is clear.

Related

Closes #157

@rizumita rizumita merged commit 4ddb5b1 into main Jul 8, 2026
11 of 12 checks passed
@rizumita rizumita deleted the feat/recursive-agent-157 branch July 8, 2026 21:15
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.

Implement recursive agent composition for fsl-ai

1 participant