feat(instrument): Port Semantic Kernel framework adapter (M2)#102
Closed
mmercuri wants to merge 1 commit into
Closed
feat(instrument): Port Semantic Kernel framework adapter (M2)#102mmercuri wants to merge 1 commit into
mmercuri wants to merge 1 commit into
Conversation
Ports the Microsoft Semantic Kernel adapter from the ateam reference implementation onto the layerlens.instrument base layer. M2 fan-out: slices the SK-specific adapter out of the bundled M1.C agent-tier port (PR #97) so it can land independently. Source: ateam/stratix/sdk/python/adapters/semantic_kernel/ (~929 LOC, 4 files). Template: existing langchain framework adapter package. Surface - src/layerlens/instrument/adapters/frameworks/semantic_kernel/ - __init__.py, lifecycle.py, filters.py, metadata.py - src/layerlens/instrument/adapters/frameworks/__init__.py (lazy) - tests/instrument/adapters/frameworks/test_semantic_kernel.py - samples/instrument/semantic_kernel/{main.py,README.md} - docs/adapters/frameworks-semantic_kernel.md Naming and back-compat - stratix.* import paths -> layerlens.* import paths. - STRATIXFunctionFilter / STRATIXAutoFunctionFilter / STRATIXPromptRenderFilter remain importable as deprecation aliases for ateam users; new code should use the LayerLens* names. - StratixMemoryStore class name preserved (matches the SK memory store contract users embed by name). Packaging - pyproject.toml gains semantic-kernel = ['semantic-kernel>=1.0,<2.0; python_version >= "3.10"']. Default install set is unchanged. - ruff per-file-ignores adds ARG002 for adapters/frameworks/ — the SK filter callbacks have signatures dictated by the upstream filter API. - pyright executionEnvironments relaxes a few rules under src/layerlens/instrument/adapters/frameworks because the framework instrumentation relies on runtime attribute mutation that pyright cannot follow. mypy --strict stays strict. Verification - uv run pytest tests/instrument/adapters/frameworks/test_semantic_kernel.py -x -> 12 passed - uv run mypy --strict src/layerlens/instrument/adapters/frameworks/semantic_kernel -> Success: no issues found in 4 source files - uv run pytest tests/instrument/test_lazy_imports.py tests/instrument/test_default_install.py -> 6 passed (lazy-import + default-install guards still hold)
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
Ports the Microsoft Semantic Kernel framework adapter from the
ateamreference implementation onto the new
layerlens.instrumentbaselayer. This is the M2 fan-out for Semantic Kernel — slicing it
out of the bundled M1.C agent-tier port (#97) so it can land
independently and be reviewed in isolation.
Source
ateam/stratix/sdk/python/adapters/semantic_kernel/(~929 LOC, 4files):
__init__.py(16 LOC)lifecycle.py(594 LOC) —SemanticKernelAdapter+StratixMemoryStorefilters.py(259 LOC) — three SK filter implementationsmetadata.py(60 LOC) — plugin / kernel metadata extractionsrc/layerlens/instrument/adapters/frameworks/langchain/package layout,
requires_pydanticguard,STRATIX*deprecation aliaspattern.
Scope
src/layerlens/instrument/adapters/frameworks/semantic_kernel/—per-framework package (
__init__,lifecycle,filters,metadata).src/layerlens/instrument/adapters/frameworks/__init__.py— lazypackage marker; importing it does NOT pull in any framework SDK.
tests/instrument/adapters/frameworks/test_semantic_kernel.py— 12SDK-shape mock tests (no real
semantic-kernelruntime needed).samples/instrument/semantic_kernel/{main.py,README.md}— runnable,mocked-by-default sample.
docs/adapters/frameworks-semantic_kernel.md— adapter integrationguide (events emitted, capture config, BYOK pointer).
pyproject.toml— addssemantic-kernel = ['semantic-kernel>=1.0,<2.0; python_version >= '3.10'']extra; ruffARG002ignore + pyrightexclusions for
frameworks/(mypy--strictstays strict).Naming + back-compat
stratix.*import paths →layerlens.*import paths.STRATIX*→LayerLens*. The oldSTRATIXFunctionFilter/STRATIXAutoFunctionFilter/STRATIXPromptRenderFiltersymbols remain importable as deprecationaliases for ateam users (slated for removal next major SDK release).
StratixMemoryStoreclass name preserved — it implements the SKmemory store contract that users embed by name.
Base branch
The acceptance check (
uv run pytest tests/instrument/adapters/frameworks/test_semantic_kernel.py -x)imports from
layerlens.instrument.adapters._base, which only existson
feat/instrument-base-foundation(M1.A) —origin/mainrevertedthe instrument layer in #76 pending the M1 stack. This PR therefore
targets
feat/instrument-base-foundationinstead ofmain. It willre-target to
mainonce the M1.A foundation lands.Blast radius
pip install layerlensinstall set is unchanged.semantic-kernelis gated behind its own optional extra and apython_version >= '3.10'marker.package.
layerlens.instrumentstill does NOT pullsemantic_kernelor any other framework module(
tests/instrument/test_lazy_imports.pystill passes).Test plan
uv run pytest tests/instrument/adapters/frameworks/test_semantic_kernel.py -x→ 12 passed
uv run mypy --strict src/layerlens/instrument/adapters/frameworks/semantic_kernel→ Success: no issues found in 4 source files
uv run ruff check src/layerlens/instrument/adapters/frameworks/semantic_kernel tests/instrument/adapters/frameworks/test_semantic_kernel.py→ clean
uv run pytest tests/instrument/test_lazy_imports.py tests/instrument/test_default_install.py→ 6 passed (lazy-import + default-install guards still hold)
uv run pytest tests/instrument/→ 62 passed, 1 skipped (noregressions vs. base-foundation)
m-peko) verifies filter wiring + back-compat aliasshape
Sibling of
feat/instrument-frameworks-orchestration(M1.C part 1)feat/instrument-frameworks-agents(M1.C part 2) — this PRcarves the SK slice out of instrument: agent framework adapters (M1.C part 2) #97 for independent review.