Skip to content

You are currently viewing documentation for0.1.0-alpha.1

Saved documentation for 0.1.0-alpha.1 (npm) / 0.1.0a0 (PyPI). Interactive tools use the current release. View latest documentation.

Python

Shared WASM, separate Python host

agindow==0.1.0a0, published on PyPI. Python 3.11+, pinned Wasmtime, and identical WASM bytes to Node. Install with pip install agindow==0.1.0a0. No separate Python detector or framework adapter is shipped.

Decorators and ContextVar scopes

Agindow.guard works as a decorator; wrap accepts callables. with sdk.context and async with sdk.context apply ContextVar overrides only to that SDK’s guarded calls, remain isolated across tasks and freeze for call completion. Sync stays sync, async stays async, and cancellation propagates. The py tab validates both scopes and original object identity.

Readiness and configuration

sdk.ready is a synchronous boolean after loading, unlike Node’s Promise; sdk.load_error retains failure. configure changes future calls. Snake_case keywords resolve explicit > environment > nearest JSON .agindowrc > defaults. NullEngine and observe are defaults. sdk.close releases the guest; later calls bypass.

Remote and framework boundaries

guard_remote and guard_remote_async are explicit HTTP APIs, separate from local decorators. There are no Python framework adapters, built-in report CLI, distributed replay or hosted delivery. The shared default guest has no selective repair output.

Run the fixture

Select the py tab, save as example.py after pip install agindow==0.1.0a0, then run python example.py. Sync, async and closed-engine outcomes are synthetic local evidence.

Continue

Published packages and local monorepo builds share the same APIs. Choose the transport explicitly.

import { createAgindow } from 'agindow';
const sdk = createAgindow({ mode: 'observe' });
await sdk.ready;
const payload = { id: 'synthetic-customer' };
let calls = 0;
const read = sdk.guard(() => { calls++; return payload; }, { tool: 'vendor.read', operation: 'read' });
const result = read();
if (result !== payload || calls !== 1) throw Error('Fixture identity changed');
// A labelled unavailable-engine fixture produces one bypass without a hosted key.
const unavailable = createAgindow({ mode: 'observe' }, async () => { throw Error('Synthetic loading fault'); });
await unavailable.ready;
const fallback = unavailable.wrap(() => payload);
if (fallback() !== payload || unavailable.recent().filter(e => e.type === 'bypass').length !== 1) throw Error('Missing bypass');
sdk.configure({ mode: 'observe' });
console.log('Synthetic fixture: original result retained; unavailable engine bypassed once.');
import asyncio
from agindow import Agindow
sdk = Agindow(mode="observe")
payload = {"id": "synthetic-customer"}
@sdk.guard(tool="vendor.read", operation="read")
def read() -> dict[str, str]:
    return payload
@sdk.guard(tool="vendor.read", operation="read")
async def read_async() -> dict[str, str]:
    return payload
with sdk.context(mode="observe"):
    assert read() is payload
async def main() -> None:
    async with sdk.context(mode="observe"):
        assert await read_async() is payload
asyncio.run(main())
# A closed engine is a labelled availability fixture, not vendor drift.
sdk.close()
assert read() is payload
assert len([event for event in sdk.recent() if event.type == "bypass"]) == 1
print("Synthetic fixture: sync/async identity retained; closed engine bypassed once.")