Skip to content

feat: fold pisama-auto and pisama-agent-sdk into pisama as submodules (0.6.0) - #14

Merged
tn-pisama merged 2 commits into
mainfrom
feat/pisama-auto-agents-submodules
Jul 29, 2026
Merged

feat: fold pisama-auto and pisama-agent-sdk into pisama as submodules (0.6.0)#14
tn-pisama merged 2 commits into
mainfrom
feat/pisama-auto-agents-submodules

Conversation

@tn-pisama

@tn-pisama tn-pisama commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

DO NOT MERGE OR PUBLISH

This PR is blocked on human review. The standalone-repo shim work for
pisama-auto and pisama-agent-sdk (making those PyPI packages thin
re-exports of this code) is a later, separate step that must wait
until this lands on main and pisama>=0.6.0 is live on PyPI. Do
not merge, do not tag a release, do not run any publish workflow until a
human has signed off.

What this is

Wave 3 of the package-consolidation plan. Folds two standalone PyPI
packages into pisama as new optional submodules, each in-tree as
original code (not a dependency on the standalone package):

  • pisama.auto -- in-package original of the standalone pisama-auto
    distribution: zero-code OTEL auto-instrumentation for the
    Anthropic/OpenAI SDKs, tracing to either the Pisama platform or a
    self-hosted OTLP collector. New extra: pip install "pisama[auto]".
  • pisama.agents -- in-package original of the standalone
    pisama-agent-sdk distribution: real-time hooks, tools, and a
    pisama-openhands-monitor console script for Claude Agent SDK / Harbor
    integrations. New extras: pip install "pisama[agents]" /
    pisama[telemetry].

Bumps pisama 0.5.7 -> 0.6.0. A bare pip install pisama pulls in
no new required dependencies -- both submodules stay behind their own
extras. (httpx shows up in a bare install because it was already a
required dependency of base pisama before this change -- pre-existing,
unrelated to this port.)

pisama-auto and pisama-agent-sdk keep publishing as standalone
distributions in this release; they become thin shims re-exporting these
in-tree modules in a later release, once this has landed and
pisama>=0.6.0 is live on PyPI.

Fixes applied during adversarial verification

  1. pisama.agents was missing __version__. The original
    pisama_agent_sdk exported __version__ = "0.3.2" as one of 58
    __all__ symbols; the ported module only had 57. Since this code no
    longer releases independently, pisama.agents.__version__ now
    aliases pisama.__version__ (always reflects the actual installed
    package version) rather than carrying a separate hardcoded number.
  2. The auto extra omitted opentelemetry-exporter-otlp-proto-http,
    which the original pisama-auto required. setup_tracer() in
    src/pisama/auto/_tracer.py imports it for the non-platform
    (self-hosted generic OTLP collector) endpoint path, and gracefully
    falls back to ConsoleSpanExporter via except ImportError if
    absent -- so the primary Pisama-platform-ingest path was unaffected
    either way, but a self-hosted-collector user was getting silently
    downgraded to console-only tracing. Added
    opentelemetry-exporter-otlp-proto-http>=1.20.0 to the auto extra
    for parity with the original package.
  3. (Found while re-running "pytest with all extras installed" from a
    clean install, not part of the original two disclosed gaps.)
    The
    dev extra was missing anthropic/openai, which
    tests/test_auto_sdk_instrumentation.py imports directly to exercise
    the SDK patches. A clean pip install -e ".[dev,auto]" couldn't even
    collect that test file without them. Carried over from pisama-auto's
    own dev extra, which declared the same two packages for the same
    reason. Test-only; does not change what any non-dev install pulls in.

CI status: was red, is now fixed by this branch

An independent adversarial review found that the actual GitHub Actions
run on this PR was red on 5 of 9 checks (quality, and test on
Python 3.10, 3.11, 3.12, 3.13), even though the Verification section
below reported "196 passed." Both things were true at once, and the gap
between them was a material omission in the original version of this PR
body -- it stated test/lint/build results without disclosing that CI
itself was failing.

Root cause: .github/workflows/ci.yml's quality and test jobs
both ran pip install -e ".[dev,mcp]" -- neither ever installed the new
auto extra this PR adds. The two new test files
(tests/test_auto_platform_exporter.py and
tests/test_auto_sdk_instrumentation.py) import
opentelemetry.sdk.resources and related opentelemetry modules
unconditionally at module scope, with no skip guard. Without the auto
extra installed, those imports fail at pytest collection time, which
aborts the entire test run for every job using that install line --
hence quality and all four test matrix legs going red.
(tests/agents/ needed no new extra and was never at issue: httpx is
already a hard dependency of base pisama, so those tests already ran
fine under .[dev,mcp].)

The "196 passed" figure in the Verification section below was real, but
it was only ever produced in a hand-built local venv with more
extras installed (auto,agents,telemetry,mcp,langgraph,dev) than what
CI's quality/test jobs actually install. That richer local venv
masked the gap that made CI fail.

Fix (this commit): changed both the quality and test job install
lines in .github/workflows/ci.yml from pip install -e ".[dev,mcp]"
to pip install -e ".[dev,mcp,auto]", so the new pisama.auto code this
PR adds is actually exercised in CI rather than silently untested. The
distribution job is intentionally untouched -- it deliberately builds
and installs the bare wheel with zero extras, which is correct and
unrelated to this bug.

Post-fix local reproduction of the exact CI commands (fresh venvs,
this branch, this commit):

# quality job, Python 3.11
$ pip install "pisama-core @ git+https://github.com/Pisama-AI/pisama-core.git@v1.8.2"
$ pip install -e ".[dev,mcp,auto]"
(clean install, no errors)

$ ruff check src tests
All checks passed!

$ mypy src/pisama
Success: no issues found in 65 source files

$ pytest -q --cov=pisama --cov-report=term --cov-fail-under=60
196 passed in 19.41s
TOTAL coverage: 70.51% (gate: 60%, reached)

# test job, Python 3.13 (separate fresh venv)
$ pip install "pisama-core @ git+https://github.com/Pisama-AI/pisama-core.git@v1.8.2"
$ pip install -e ".[dev,mcp,auto]"
(clean install, no errors)

$ pytest -q
196 passed in 17.88s

These are the real, current numbers for what CI now runs after this
commit, reproduced locally with the exact CI commands before pushing.

Disclosed, not fixed (pre-existing, out of scope for this PR)

src/pisama/collector/_bootstrap.py and src/pisama/cli/watch.py
reference the external pisama_auto package (an optional subprocess
probe for the pisama watch feature). This predates this task and is
unrelated to it -- whether pisama watch should now prefer the in-tree
pisama.auto instead is a separate product decision. Not touched here.

Verification (all commands run against this exact branch, clean venvs, all extras installed)

Note: the venv used for this section installs strictly more extras
(auto,agents,telemetry,mcp,langgraph,dev) than CI's quality/test
jobs install (dev,mcp,auto as of this commit; dev,mcp before it).
It is a valid "does the full feature set work" check, but it is not a
stand-in for what CI runs -- see the CI status section above for the
commands and numbers that actually match CI.

$ pip install -e ".[auto,agents,telemetry,mcp,langgraph,dev]"
(clean install, no errors)

$ pytest tests/ -q
196 passed in 15.07s

$ ruff check src tests
All checks passed!

$ mypy src/pisama/auto src/pisama/agents
Success: no issues found in 29 source files

$ python -m build --wheel
Successfully built pisama-0.6.0-py3-none-any.whl
  -> wheel contains 5 files under pisama/auto/, 24 under pisama/agents/

# Bare install (no extras), fresh venv, from the built wheel:
$ python -c "import pisama; print(pisama.__version__)"
0.6.0
opentelemetry: absent (expected)
wrapt: absent (expected)
posthog: absent (expected)
anthropic: absent (expected)
openai: absent (expected)
httpx: present (expected, pre-existing required dependency)

$ python -c "import pisama.agents; print(pisama.agents.__version__)"
0.6.0

$ pisama --help                      # OK
$ pisama-openhands-monitor --help    # OK

196/196 tests pass (59 pre-existing + 15 pisama.auto + 122
pisama.agents), matching the pre-fix count -- these are metadata/dep
fixes, no new test coverage added or removed.

🤖 Generated with Claude Code

tn-pisama and others added 2 commits July 29, 2026 14:07
Bumps pisama to 0.6.0. Adds pisama.auto (in-package original of the
standalone pisama-auto distribution: zero-code OTEL auto-instrumentation
for the Anthropic/OpenAI SDKs) and pisama.agents (in-package original of
pisama-agent-sdk: real-time hooks, tools, and the
pisama-openhands-monitor console script for Claude Agent SDK / Harbor
integrations), each behind its own optional extra so a bare
`pip install pisama` pulls in no new required dependencies.

Also fixes two gaps found in adversarial verification of the port:

- pisama.agents was missing a __version__ attribute (the original
  pisama_agent_sdk exported one, 58 __all__ symbols vs the ported 57).
  Since this code no longer releases independently, it now aliases
  pisama.__version__ instead of carrying a separate hardcoded number.
- The `auto` extra omitted opentelemetry-exporter-otlp-proto-http, which
  setup_tracer() needs for the self-hosted-collector OTLP path (it falls
  back to console-only tracing via a graceful ImportError otherwise, so
  the primary Pisama-platform-ingest path was unaffected either way).

And one gap found while re-verifying "pytest with all extras installed"
from a clean install: the `dev` extra was missing anthropic/openai, which
tests/test_auto_sdk_instrumentation.py imports directly to exercise the
patches. Carried over from pisama-auto's own dev extra for the same
reason; not a runtime dependency of the `auto` extra itself.

pisama-auto and pisama-agent-sdk keep publishing as standalone
distributions in this release; they become thin shims re-exporting these
modules in a later, separate step once this lands and pisama>=0.6.0 is
live on PyPI.

Verified: 196/196 tests pass, ruff clean, mypy clean on src/pisama/auto
and src/pisama/agents, wheel contains both submodules, both console
scripts work, bare install (no extras) still imports cleanly with
opentelemetry/wrapt/posthog/anthropic/openai all absent.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The quality and test jobs installed -e ".[dev,mcp]", which never pulled
in the new auto extra this PR adds. tests/test_auto_platform_exporter.py
and tests/test_auto_sdk_instrumentation.py import opentelemetry.sdk
modules unconditionally at collection time, so pytest failed to collect
and the whole run aborted for every job on that install line (quality,
test on 3.10-3.13). Switch both to -e ".[dev,mcp,auto]" so pisama.auto
is actually exercised. distribution is untouched -- it deliberately
installs the bare wheel with no extras.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@tn-pisama
tn-pisama merged commit e18f616 into main Jul 29, 2026
9 checks passed
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