Metadata-Version: 2.4
Name: oah
Version: 0.0.2
Summary: Observability Agentic Harness — LLM/GenAI observability instrumentation pipeline
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           Copyright 2026 Ivan Bogomazov
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
        
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: jsonschema>=4.20
Requires-Dist: tree-sitter>=0.23
Requires-Dist: tree-sitter-python>=0.23
Requires-Dist: pyyaml>=6.0
Provides-Extra: llm
Requires-Dist: litellm>=1.50; extra == "llm"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: oah[llm]; extra == "dev"
Dynamic: license-file

# Observability Agentic Harness (OAH) — Agentic Observability Pipeline

> **Status: pre-alpha.** S1–S9 (surface mapping through the production readiness
> report) are implemented and tested — see [Installation](#installation) below to
> run them. S10–S11 (applying instrumentation and dynamically validating it) are
> not built yet. Follow [ROADMAP.md](ROADMAP.md) for progress.

OAH is an agentic harness that **builds LLM observability into an existing product**
(or produces observability requirements for a product being designed). Given access to
a repository, it runs a multi-stage pipeline: it maps every LLM call site, retrieval
step, and tool invocation; inventories existing telemetry; designs a target
observability architecture; produces an implementation plan; then — in fix mode —
generates and applies the instrumentation code and **validates that telemetry actually
flows** by exercising the product and checking emitted events against a versioned
schema.

OAH ships two co-equal deliverables:

1. **Working instrumentation** — code, event schema, collector config, and a
   validated Trace Completeness Rate for the target product.
2. **A production readiness decision** — a structured five-question readiness
   report ([schema](schemas/readiness_report.schema.json)) ending in one of six
   evidence-led recommendations: *ready / ready with conditions / remediate before
   release / pause and redesign / escalate for review / rollback or pause
   expansion* — with the epistemic position stated (confirmed vs. assumed vs.
   unknown), scope exclusions, named owners, and the evidence that would change
   the decision. The gate never advances on confidence, urgency, or a successful
   demo alone.

The two reinforce each other: the readiness decision is only as good as the
signals behind it, and the installed signals are designed backwards from the
decisions they must support — every signal names the decision it serves and the
owner who acts, or it is not built (the anti-metric-hoarding gate).

## Inspiration & credit

The architecture of this project is directly inspired by
[**Visa Vulnerability Agentic Harness (VVAH)**](https://github.com/visa/visa-vulnerability-agentic-harness) —
Visa's open-source agentic SAST pipeline built on learnings from Anthropic's Project
Glasswing. We adopt its core design pattern and adapt it from vulnerability management
to observability engineering:

| VVAH pattern | OAH adaptation |
|---|---|
| Threat modeling before analysis | Observability surface mapping & gap modeling before design |
| Multi-phase pipeline of composable, versioned skills | Same — each LLM-driven stage is an independently testable skill |
| Deterministic controls + frontier-model reasoning | Deterministic AST/code scanning + LLM reasoning at each phase |
| Structured artifacts (DTOs, SARIF) between stages | Structured artifacts (surface map, gap model, implementation DTOs) |
| Remediation applies code changes, then adversarial validation panel | Instrumentation applies code changes, then dynamic validation: run the product, intercept telemetry, verify against schema |
| Primary metric: Mean Time to Adapt (MTTA) | Primary metric: **Trace Completeness Rate (TCR)** — share of user requests reconstructable end-to-end from telemetry with no gaps |

We are not affiliated with Visa. VVAH is licensed under Apache-2.0; this project is an
independent implementation of the pattern in a different domain and is also released
under Apache-2.0.

## Why

For LLM products, the dominant failure class is not "the call failed" but "the call
succeeded and the output was bad": hallucination, irrelevant retrieval, silent context
truncation, instruction bypass. Classic APM sees green dashboards while the product
degrades. Observability for LLM systems therefore needs a domain model of its own —
traces, generations, retrieval spans, tool spans, feedback events, eval datasets —
plus governance over the telemetry itself (prompts and outputs are sensitive data).

The pipeline itself doesn't know it's about LLMs, though: S1–S3's mapping/gap-model
mechanics, the S4 ops lens (release identifiers, alert plan, decision menu), S5's
invariant gates, S7's runbook/roll-up structure, S8–S9's DTO and readiness-report
shapes, and S11's TCR/validation-ladder concept are domain-agnostic SRE engineering.
What's LLM-specific is concentrated in [docs/event-model.md](docs/event-model.md)
(the Generation/Retrieval entities S3 diffs against) and three of S4's eight lenses
(generation-capture, retrieval, realtime-multimodal) — call it the **GenAI domain
pack** the harness ships with. That's a scope choice, not an architectural limit:
LLM observability is where OTel semantic conventions and APM tooling are least
mature, so it's where a gap-modeling harness adds the most value first.

Retrofitting this by hand into an existing codebase is slow, inconsistent, and usually
stalls after the first dashboard. OAH turns it into a repeatable, reviewable,
agent-executed pipeline with human gates.

## Pipeline (4 phases, 11 stages)

| Phase | Stages | Purpose |
|---|---|---|
| **1 — Discovery & Modeling** | S1–S3 | Map the observability surface (LLM/retrieval/tool call sites), inventory existing telemetry, build a prioritized gap model with owner context |
| **2 — Design & Verification** | S4–S6 | Design instrumentation per lens (tracing, generation capture, retrieval, tools, feedback, PII/governance, cost); deterministic invariant gates; adversarial design review panel |
| **3 — Synthesis & Planning** | S7–S9 | Emit architecture doc, versioned event schema, rollout plan + runbook (ownership matrix, alert plan, decision menu), per-change implementation DTOs, and the production readiness report — the human gate with a six-way recommendation |
| **4 — Implementation & Validation** | S10–S11 | Apply instrumentation to source (agentic, per-change commits); dynamically validate — run the product, intercept emitted events, compute actual TCR and latency overhead; adversarial audit panel |

Detailed stage-by-stage description: [docs/architecture.md](docs/architecture.md).
Target telemetry domain model: [docs/event-model.md](docs/event-model.md).

## Installation

### From PyPI

```bash
pip install oah
oah doctor .
```

`doctor`, `estimate`, `map --no-disambiguate`, `inventory`, `gaps`, and `interview`
work out of the box — no LLM credential, no extra dependency. `map`'s
disambiguation pass and `design`/`event-schema`/`dtos`/`readiness` call an LLM via
[LiteLLM](https://www.litellm.ai/), whose own dependency tree (openai, boto3,
tiktoken, huggingface-hub, aiohttp, pydantic, ...) is sizeable enough that it's an
opt-in extra, not a default install:

```bash
pip install "oah[llm]"
export ANTHROPIC_API_KEY=...        # or another LiteLLM-supported provider's credential
```

Calling an LLM-driven command without the extra installed fails with a clean
`pip install 'oah[llm]'` message, not a raw import error.

### Local development (venv)

```bash
git clone https://github.com/arno49/observability-agentic-harness.git
cd observability-agentic-harness
python3 -m venv .venv
source .venv/bin/activate          # Windows: .venv\Scripts\activate
pip install -e ".[dev]"            # dev pulls in [llm] too, so the full test suite runs

oah doctor .                       # sanity check
python -m pytest tests/ -q         # run the test suite
```

`pip install -e ".[dev]"` is an editable install: changes to `oah/` take effect
immediately without reinstalling. If you only want to run the CLI's deterministic
commands, `pip install -e .` alone is enough; add `[llm]` for the LLM-driven ones.

S1–S9 need Python ≥ 3.10 — see [Requirements](#requirements-planned) below for what
each stage needs beyond that.

## CLI

Implemented today (S1–S9):

```
oah doctor <target>                              # check credentials, backends, repo access
oah estimate <target>                            # scope & cost estimate — spends nothing
oah map <target> [-o out.json] [--no-disambiguate] [--model MODEL]  # S1: surface map (standalone audit)
oah inventory <target> [-o out.json]              # S2: existing telemetry inventory
oah interview <target> [-o context.yaml]          # S3: interactive owner interview
oah gaps <target> [--context context.yaml] [-o out.json]        # S3: gap model
oah design <target> [--context context.yaml] [-o out.json] [--model MODEL]      # S4 lenses + S5 gates + S6 panel
oah event-schema <target> [--context context.yaml] [-o out.json] [--model MODEL]  # S7: event schema
oah dtos <target> [--context context.yaml] [-o out.json] [--model MODEL]          # S8: implementation DTOs
oah readiness <target> [--context context.yaml] [-o out.json] [--model MODEL]     # S9: readiness report
```

`--no-disambiguate` on `map`, plus `doctor`/`estimate`/`inventory`/`interview`/`gaps`,
need neither the `[llm]` extra nor an API credential. `design`, `event-schema`,
`dtos`, and `readiness` (and `map` without `--no-disambiguate`) call the S4 lens
skills and need both — see [Installation](#installation) above.

`oah map` is intentionally a standalone deliverable: a one-shot observability audit of
a codebase has value even if you never proceed to instrumentation.

### Choosing a model / provider

Every LLM-driven command takes `--model`, a [LiteLLM model
string](https://docs.litellm.ai/docs/providers) — any provider LiteLLM supports
works, not just Anthropic. Credentials/endpoints are each provider's own env vars,
read by LiteLLM itself, not by `oah`:

```bash
# Default -- Anthropic, claude-sonnet-5
export ANTHROPIC_API_KEY=...
oah design ./product

# A different Anthropic-compatible or third-party cloud model
export OPENAI_API_KEY=...
oah design ./product --model openai/gpt-4o

# A local model via Ollama -- no API key, just a reachable endpoint
ollama pull llama3
oah design ./product --model ollama/llama3
# non-default OLLAMA_API_BASE (default is http://localhost:11434):
export OLLAMA_API_BASE=http://localhost:11434
```

`--model` is only pre-flight-checked for credentials when it's the default
(`claude-sonnet-5`) — `ANTHROPIC_API_KEY` isn't demanded for a call that was never
going to use Anthropic. Point any other model at a bad credential or unreachable
endpoint and that provider's own error surfaces from the live call, not a
misleading "ANTHROPIC_API_KEY is not set."

Planned, not yet built (S10–S11):

```
oah instrument --repo ./product     # S10, --mode report-only|fix
oah validate --repo ./product       # S11
oah scan --repo ./product           # full run; --stop-after s9 for analysis-only
oah resume <run_id>                 # continue a crashed or session-limit-terminated run
                                     # from its last completed unit of work
oah check-drift --repo ./product    # cheap staleness check against DTOs' retest_triggers,
                                     # no full pipeline re-run
```

> ⚠️ Following VVAH's convention and warning: a full run in fix mode will **edit source
> files in the target repo**. `--mode report-only` and `--stop-after s9` will be the
> non-mutating paths. Every applied change is planned to land as an individual
> commit/PR for review.

## Design principles

1. **Model before you design.** The gap model (S3) focuses all downstream work, the
   same way VVAH's threat model focuses vulnerability hunting.
2. **Skills, not a monolith.** Every LLM stage is a versioned skill with a declared
   input/output schema, testable in isolation against a reference corpus
   ([docs/SKILLS.md](docs/SKILLS.md)).
3. **Deterministic where possible, LLM where necessary.** AST scanning finds call
   sites; the LLM resolves ambiguity and designs. Invariant gates (S5) are pure code.
4. **OpenTelemetry as the transport floor.** Generated instrumentation targets OTel
   GenAI semantic conventions regardless of chosen backend, insuring the client
   against vendor lock-in. Opinionated backend targets (self-hosted Langfuse,
   OTel-only, managed) are selected by constraints, not fashion.
5. **Never claim more validation than performed.** S11 has an explicit degradation
   ladder (full dynamic → unit-level → generated smoke → `needs_review`);
   see [docs/validation.md](docs/validation.md).
6. **Telemetry is sensitive data.** PII masking, role-scoped access to trace content,
   and retention policy are first-class requirements, not add-ons
   ([docs/event-model.md](docs/event-model.md), [docs/security.md](docs/security.md)).
7. **Signals exist for decisions.** A health check says the service is reachable —
   not that users receive correct, approved, region- and role-appropriate, safely
   escalated answers. Every designed signal names the decision it supports and the
   role that acts; alerts no one owns are not created; evidence is judged by
   coverage class, not test count.
8. **Dogfooding.** Every OAH run emits a trace of its own stages in the very schema it
   installs for clients.
9. **Language and modality are plugins, not the core.** S1's registry and the S4
   design lenses are architected so a new source language (TypeScript, Java, ...)
   or a new call-site modality (voice, image) is an additive extension, not a
   pipeline rewrite — Python and text-first are the first concrete targets because
   a pilot needs one deep example, not because the architecture assumes them.

## Repository layout

```
docs/          architecture, event model, skills system, validation ladder, security
schemas/       JSON Schemas for inter-stage artifacts (the contract backbone)
skills/        skill drafts (SKILL.md per stage lens)
corpus/        reference repositories & eval fixtures for skill testing (planned)
.github/       CI, incl. a skills-bundling Action — debug tooling, not the
               pipeline itself; see docs/skills-bundle.md
ROADMAP.md     milestones, epics, spikes
```

## Requirements (planned)

- Python ≥ 3.10 (S1–S9, implemented today)
- `pip install oah` alone is enough for `doctor`, `estimate`, `map --no-disambiguate`,
  `inventory`, `gaps`, and `interview` — fully deterministic, no LLM credential.
- `pip install "oah[llm]"` plus an `ANTHROPIC_API_KEY` (or another provider
  [LiteLLM](https://www.litellm.ai/) supports) for `map`'s disambiguation pass and
  S4's lens skills (`design`, `event-schema`, `dtos`, `readiness`) — any provider or
  a local model (Ollama/vLLM) works via LiteLLM's abstraction layer, light-tier
  defaults for high-volume stages. The planned agentic stages S10–S11 will
  additionally require the `claude` CLI — mirroring VVAH's Anthropic-only
  remediation/validation constraint. Enterprise deployments behind a private
  gateway supported via base-URL override + mTLS.

## Limitations (read before you trust output)

- **LLM-generated, non-deterministic.** Designs and code changes are candidates
  requiring human review at the S9 gate and at every S10 commit.
- **Dynamic validation depends on the target's runnability.** If the product cannot be
  exercised (no tests, no compose, no smoke path), the best achievable verdict is
  `needs_review` — never `validated`.
- **Elevated privilege.** The harness reads source code that may contain prompts,
  keys, and data samples, and in fix mode edits it. Run only against repositories you
  own or are authorized to modify. See [docs/security.md](docs/security.md).
- **No accuracy numbers yet.** Skill precision/recall against the reference corpus
  will be published as the corpus lands (Epic E7).

## License

Apache License 2.0 — see [LICENSE](LICENSE) and [NOTICE](NOTICE).
