Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ ENV/
.cursor/settings.local.json
.mcp.local.json
.melampus/
pilot-results/
pilot-results/*.lock

# macOS
.DS_Store
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.2.0] - 2026-10-02

### Added

- Explicit `instrument(target, namespace=..., contracts=...)` registration for
ordinary Python class instances, modules and grouped function boundaries.
Selected methods preserve binding, signatures, sync/async behavior and target
typing; shared classes are untouched and unsupported descriptors fail explicitly.
- Optional stable `path=` on existing function decorators; the inferred path
and experimental 0.1.0 wire schema remain compatible.
- Three-style registration/repair demo, Claude session example, official-source
SDK/decorator research and documented scope/bypass tradeoffs.
- Local timed, resumable pilot covering all seven worksheet measures, six task
order rotations and Markdown/CSV/JSON reports. Synthetic runs are labeled;
human preference and comfort remain unmeasured.

### Changed

- Permit matching declarations from multiple instances sharing reviewed paths;
conflicts remain incomplete and passing calls do not erase drift.
- Recommend explicit registration for existing services while retaining native
decorators as an equal supported choice for small function integrations.

## [0.1.0] - 2026-09-28

### Added
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: dev lint typecheck test cov semconv build ci format demo demo-otlp benchmark
.PHONY: dev lint typecheck test cov semconv build ci format demo demo-otlp demo-registration demo-pilot pilot benchmark

dev:
uv sync --locked --all-extras
Expand All @@ -7,6 +7,7 @@ lint:
uv run --locked ruff format --check .
typecheck:
uv run --locked mypy -p melampus
uv run --locked mypy --strict tests/types/public_api.py
test:
uv run --locked pytest
cov:
Expand All @@ -25,5 +26,11 @@ demo:
uv run --locked python scripts/demo_agent_session.py
demo-otlp:
uv run --locked python scripts/demo_session.py
demo-registration:
uv run --locked python scripts/demo_registration.py
demo-pilot:
uv run --locked python scripts/demo_pilot.py --demo
pilot:
uv run --locked python scripts/demo_pilot.py $(ARGS)
benchmark:
uv run --locked python benchmarks/overhead.py
52 changes: 45 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Keep an AI coding session aligned with reviewed intent. Give the agent a small
set of SDK contracts, run a local supervisor beside it, and feed execution
failures back into repair before the agent continues building.

**0.1.0 alpha is in preparation; no PyPI release is claimed yet.** The SDK and
**0.2.0 alpha. GitHub releases include validated wheels and sdists; PyPI
publication is separate.** The SDK and
wire schema are experimental. The supervisor needs no SaaS, LLM judge, tracing
backend, collector, or unit-test framework. Python 3.11+, macOS/Linux.

Expand Down Expand Up @@ -57,7 +58,7 @@ It cannot infer arbitrary intent from prose, inspect unfinished model tokens,
prove unexecuted behavior, or guarantee the absence of all AI-generated slop.
Review the claims and scenarios before asking the agent to implement them.

## SDK contracts travel with the code
## Register reviewed contracts at the application boundary

Keep the reviewed definition in `intent.py`:

Expand All @@ -71,21 +72,58 @@ PRICE = Contract(
CONTRACTS = {"pricing:price": PRICE}
```

The agent writes `pricing.py`:
Keep business functions plain in `pricing.py`:

```python
from intent import PRICE


@PRICE.instrument(generator="claude-code")
def price(cents: int) -> int:
return max(0, cents)
```

Register once in `registration.py`, then call through that object:

```python
from types import SimpleNamespace
from melampus import instrument
from intent import PRICE
from pricing import price

pricing = instrument(
SimpleNamespace(price=price),
namespace="pricing",
contracts={"price": PRICE},
generator="claude-code",
)
pricing.price(-100)
```

For an existing service use
`instrument(PricingService(), namespace="pricing:PricingService", contracts={"price": PRICE})`
and review `pricing:PricingService.price` in `CONTRACTS`. Registration returns
the same typed object, preserves bound state and sync/async behavior, and never
changes the shared class. Register each instance before sharing it. Original
imports and captured references bypass registration; omitted methods are unconfigured.

For a few functions, the existing `@PRICE.instrument()` and `@instrumented(...)`
decorators remain supported. The original agent example/recording demonstrates
that approach; [the registration example](examples/sdk-registration/README.md)
shows all three styles beside an agent.

The session runner owns local OTel setup automatically. It verifies that the
function used the reviewed check objects and that every required check actually
ran. No network export is needed for this local path. The plain `@instrumented`
API remains available for applications that own their tracing configuration.
Multiple instances can share reviewed paths; conflicts remain incomplete and
a passing call cannot erase drift. The wire schema remains at **0.1.0**.

```sh
make demo-registration # compare decorator, class and module-boundary repair
make demo-pilot # synthetic measurement walkthrough, no human claims
make pilot ARGS='--participant p01 --rotation 0' # local, resumable participant study
```

[API boundaries](docs/SDK-REGISTRATION.md) ·
[Official-source SDK/decorator research](docs/SDK-UX-RESEARCH.md) ·
[Pilot tasks and reports](examples/pilot_study/README.md).

## Optional OTLP foundation demo

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
0.2.0
8 changes: 8 additions & 0 deletions docs/AGENT-SESSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ and makes fresh SDK evidence available to synchronous agent hooks. Service
monitoring and broader tracing workflows are later expansion; the OTLP watcher
remains a reusable foundation.

## Registration alternative (0.2.0)

For existing services, register reviewed contracts at application setup with
`instrument(service, namespace=..., contracts=...)`, keeping business methods
plain. [SDK registration](SDK-REGISTRATION.md) explains binding, scope and
compatibility; the [runnable comparison](../examples/sdk-registration/README.md)
includes Claude hooks. The original decorator session remains supported.

## What you review, and what the agent writes

1. **Approve intent once.** Put a small set of `Contract` objects in a Python
Expand Down
60 changes: 43 additions & 17 deletions docs/RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# First release: 0.1.0 alpha
# Releases and publishing

## Scope and evidence
## 0.2.0 alpha: registration and onboarding

Version 0.2.0 mirrors TypeScript 0.2.0's explicit class/module
registration and measured pilot, adapted to Python method binding and native
decorators. ADR-0009 records the accepted integration recommendation.
The wire schema remains 0.1.0 independently of the SDK version.

Run `make ci`, `make demo`, `make demo-registration` and `make demo-pilot`.
The distribution check installs the built wheel in a separate environment and
executes the original session plus registration and synthetic pilot demos.
CI verifies the same behavior across its Python/macOS/Linux matrix. Research
and API boundaries are in [SDK-UX-RESEARCH.md](SDK-UX-RESEARCH.md) and
[SDK-REGISTRATION.md](SDK-REGISTRATION.md). Human comfort/preference remains
unmeasured; synthetic output verifies collection rather than adoption benefits.

## 0.1.0 alpha: original scope and evidence

The primary product is a local AI coding-session supervisor: reviewed SDK
contracts, fresh execution after edits, required-check evidence, and synchronous
Expand Down Expand Up @@ -75,35 +90,46 @@ events do not automatically trigger another workflow with the default token.

## One-time registry setup (project owner)

Configure a pending trusted publisher in **each** registry you intend to use:
For the first PyPI upload, configure a pending trusted publisher on the owner's
[PyPI account publishing page](https://pypi.org/manage/account/publishing/):

| Field | Value |
| --- | --- |
| Project name | `melampus` |
| Owner | `melampus-org` |
| Repository | `melampus-python` |
| Workflow filename | `publish.yml` |
| Environment | `testpypi` on TestPyPI; `pypi` on PyPI |
| Environment | `pypi` |

No long-lived PyPI token is required. Restrict the GitHub `pypi` environment to
main and maintainers who may publish. See [PyPI's publisher setup](https://docs.pypi.org/trusted-publishers/adding-a-publisher/)
No long-lived PyPI token is required. The GitHub `pypi` environment is configured
to allow deployments from `main` only. See [PyPI's publisher setup](https://docs.pypi.org/trusted-publishers/adding-a-publisher/)
and [pending publishers](https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/).
These settings must exist before the first registry upload; the workflow cannot
create ownership on your behalf.
create the pending publisher on your behalf. A pending publisher creates the
project on first upload and does not reserve the name in advance.

As checked on 2026-10-02, TestPyPI's `melampus` project belongs to the unrelated
`orfi2017/quantimage-melampus` project. Do not dispatch our `testpypi` upload under
that name unless ownership is legitimately resolved. The two registries have
independent ownership; TestPyPI's name collision does not establish PyPI ownership.
Rehearsing under another name requires separately reviewed distribution metadata.
The GitHub wheel's clean-environment install/repair checks remain available
without a registry upload.

## Publish

1. Resolve review blockers, merge the version PR, and inspect the validated GitHub artifacts.
2. Dispatch **Publish Python package** from `main`, with the existing tag and
`registry=testpypi`. It validates tag ancestry/version, rebuilds and tests, and
uploads from a separate job with only OIDC permission.
3. Install the TestPyPI artifact with its `session` extra into a fresh environment
and rerun the local agent-session demo and enabled Claude hook walkthrough.
Download the exact project/version from TestPyPI without dependencies, then
install that wheel with dependencies from the normal PyPI index; avoid combining
indexes for general dependency resolution.
4. Dispatch the same workflow with `registry=pypi`, then verify install, CLI and
import from the real index. Update README's preparation notice after publication.
2. Complete the PyPI pending publisher setup above. Dispatch **Publish Python
package** from `main`, with the existing tag and `registry=pypi`. It validates
tag ancestry/version, rebuilds and tests, and uploads from a separate job with
only OIDC permission. A missing publisher fails authentication and cannot
be repaired by creating GitHub tags or API tokens.
3. Verify the exact version's wheel/sdist on PyPI, install the `session` extra
into a fresh environment, check CLI/import, and rerun the local session demos.
4. TestPyPI remains an optional rehearsal after its name/ownership is resolved.
Download only the exact project's wheel without dependencies from TestPyPI,
then install it with dependencies from normal PyPI; do not combine indexes
for general dependency resolution.

Uploads are immutable. Fix a bad published package with a new patch release;
never attempt to overwrite an existing distribution filename.
Loading
Loading