Skip to content

instrument: base foundation (M1.A port)#93

Closed
mmercuri wants to merge 3 commits into
mainfrom
feat/instrument-base-foundation
Closed

instrument: base foundation (M1.A port)#93
mmercuri wants to merge 3 commits into
mainfrom
feat/instrument-base-foundation

Conversation

@mmercuri

Copy link
Copy Markdown
Contributor

Summary

Bootstraps the LayerLens instrument layer: abstract BaseAdapter,
AdapterRegistry, CaptureConfig, EventSink, vendored ateam event
schemas, and a pydantic v1/v2 compatibility shim. Every concrete
adapter (frameworks, protocols, providers) in the M1 port depends on
this PR, so it merges first.

Scope

  • src/layerlens/instrument/__init__.py — lean re-export surface
  • src/layerlens/instrument/_vendored/ — frozen ateam event schemas
    (no runtime ateam dependency)
  • src/layerlens/instrument/adapters/_base/BaseAdapter,
    AdapterRegistry, AdapterStatus, AdapterHealth,
    AdapterCapability, ReplayableTrace, CaptureConfig, EventSink,
    TraceStoreSink, IngestionPipelineSink, PydanticCompat
  • src/layerlens/_compat/pydantic.pymodel_dump / model_validate
    shim spanning pydantic v1 + v2
  • scripts/{port_adapter,port_protocol,emit_adapter_manifest,regen_dep_baselines}.py
    — codegen helpers used to port the rest of M1
  • tests/instrument/{test_base_layer,test_lazy_imports,test_default_install,test_resolved_dep_tree}.py
    • _baselines/
  • .github/workflows/dep-tree-guard.yaml — CI gate that locks the
    default install footprint
  • docs/adapters/ — CONTRIBUTING, STATUS, pydantic-compatibility,
    testing, PERSONA_REVIEW

Blast radius

  • Pure additions. No public surface changes outside the new
    layerlens.instrument namespace.
  • Default pip install layerlens install set is unchanged (verified by
    test_default_install.py against the new baseline).
  • Lazy adapter discovery: importing layerlens.instrument MUST NOT
    pull in any optional adapter dep (verified by
    test_lazy_imports.py).

Test plan

  • uv run pytest tests/instrument/test_base_layer.py tests/instrument/test_lazy_imports.py -x — 45 passed locally
  • Dep-tree-guard workflow exercises test_default_install.py and
    test_resolved_dep_tree.py against the new baselines on PR
  • Reviewer (m-peko) sanity-check on adapter base contracts

Linear

LAY-3400 umbrella (M1 port). This PR is the prerequisite for the
M1.B / M1.C / M1.D adapter ports, M7 protocol certification, and M8
Cohere/Mistral.

Bootstraps the LayerLens instrument layer with the abstract base classes,
adapter registry, capture configuration, event sinks, vendored event
schemas, and pydantic v1/v2 compatibility shim that every concrete
adapter (frameworks, protocols, providers) will depend on.

Scope
-----
- src/layerlens/instrument/__init__.py: lean re-export surface
- src/layerlens/instrument/_vendored/: frozen ateam event schemas (no
  runtime ateam dependency)
- src/layerlens/instrument/adapters/_base/: BaseAdapter, AdapterRegistry,
  AdapterStatus, AdapterHealth, AdapterCapability, ReplayableTrace,
  CaptureConfig, EventSink, TraceStoreSink, IngestionPipelineSink,
  PydanticCompat
- src/layerlens/_compat/pydantic.py: model_dump/model_validate shim
  spanning pydantic v1 + v2
- scripts/{port_adapter,port_protocol,emit_adapter_manifest,
  regen_dep_baselines}.py: codegen helpers used to port the rest of M1
- tests/instrument/{test_base_layer,test_lazy_imports,
  test_default_install,test_resolved_dep_tree}.py + _baselines/
- .github/workflows/dep-tree-guard.yaml: CI gate that locks the default
  install footprint
- docs/adapters/: CONTRIBUTING, STATUS, pydantic-compatibility, testing,
  PERSONA_REVIEW

Blast radius
------------
- Pure additions. No public surface changes outside the new
  layerlens.instrument namespace.
- Default `pip install layerlens` install set is unchanged (verified by
  test_default_install.py against the new baseline).
- Lazy adapter discovery: importing layerlens.instrument MUST NOT pull
  in any optional adapter dep (verified by test_lazy_imports.py).

Test plan
---------
- uv run pytest tests/instrument/test_base_layer.py
  tests/instrument/test_lazy_imports.py -x  -> 45 passed
- The dep-tree-guard workflow exercises test_default_install.py and
  test_resolved_dep_tree.py against the new baselines on every PR.

LAY-3400 umbrella: this PR is the prerequisite for the M1.B/M1.C/M1.D
adapter ports, M7 protocol certification, and M8 Cohere/Mistral.
@mmercuri mmercuri requested a review from m-peko April 26, 2026 02:14
Auto-fixed by 'ruff check --fix'. No behavior change.
@mmercuri

Copy link
Copy Markdown
Contributor Author

Linear: https://linear.app/layerlens/issue/LAY-3400 (M1 foundation port — base of the 6-PR stack; under Apollo M1 epic LAY-3423). Includes: BaseAdapter + AdapterRegistry + CaptureConfig + EventSink + vendored stratix.* events + Pydantic v1/v2 compat shim (LAY-3401 covered) + dep-tree-guard CI workflow (LAY-3404 partial).

Ports the twelve agent-tier framework adapters from the ateam
reference implementation onto the new layerlens.instrument base layer:

  Semantic Kernel, LlamaIndex, OpenAI Agents, Pydantic-AI, Agno,
  Strands, SmolAgents, MS Agent Framework, Google ADK,
  Bedrock Agents, Embedding (vector store hooks), Benchmark Import

Pairs with feat/instrument-frameworks-orchestration (M1.C part 1)
which lands LangChain, LangGraph, CrewAI, AutoGen, Langfuse, and
Agentforce. Together they complete M1.C.

Scope
-----
- src/layerlens/instrument/adapters/frameworks/{semantic_kernel,
  llama_index,openai_agents,pydantic_ai,agno,strands,smolagents,
  ms_agent_framework,google_adk,bedrock_agents,embedding,
  benchmark_import}/: per-framework packages
- tests/instrument/adapters/frameworks/test_*_adapter.py + the
  test_bulk_ported_smoke.py harness (which exercises every ported
  adapter against canned trace fixtures so partial framework SDKs
  on a given runner don't drop coverage to zero)
- samples/instrument/<framework>/: runnable per-framework samples
- docs/adapters/frameworks-<framework>.md: per-framework integration
  guide
- pyproject.toml: twelve new optional extras
  (semantic-kernel, llama-index, openai-agents, pydantic-ai, agno,
  strands, smolagents, ms-agent-framework, google-adk,
  bedrock-agents, embedding, benchmark-import) with python_version
  markers; pyright/ruff exclusions for the dynamic monkey-patching
  framework code

Blast radius
------------
- Default `pip install layerlens` install set is unchanged. Each
  framework's heavy deps are gated behind their own extra.
- No changes to existing public API surface.
- Importing layerlens.instrument still does NOT pull in any framework
  module (lazy registry lookup).

Test plan
---------
- uv run pytest tests/instrument/adapters/frameworks/ -x  ->
  184 passed, 1 skipped (test_bulk_ported_smoke.py covers all 12
  agent-tier adapters plus the orchestration-tier ones from part 1
  via the same harness)

Stacks on
---------
- feat/instrument-base-foundation (M1.A) — required for the
  BaseAdapter surface this PR consumes.

Sibling of
----------
- feat/instrument-frameworks-orchestration (M1.C part 1) — both
  branches stack on the base foundation independently and don't
  conflict; they can land in either order.

LAY-3400 umbrella (M1.C part 2).

Co-authored-by: mmercuri <marc@giantdigital.io>
@m-peko m-peko closed this May 21, 2026
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.

2 participants