A metacognitive runtime for Python agents: the Witness pattern.
Project description
Sakshi
Sakshi (साक्षी) is the Vedantic name for the consciousness that observes consciousness without acting.
A metacognitive runtime for Python agents: the Witness pattern. A watching process embedded in your agent that monitors plan execution, evaluates against expectations, and steers cognition without doing the cognition itself.
Status
0.2.0 alpha. First version verified end-to-end against a host integration. The public API may still change in 0.x minor releases. Approaching a 1.0 freeze; not yet recommended for unverified production use.
⚠ The defaults are inert.
NoOpEventBus,NoOpBasinHook, andAlwaysPermitWriteGuardare intentional no-ops for tests and the quickstart below. A production host must inject real implementations ofEventBus,GoalStateStore, andWriteGuard— otherwise events drop on the floor, world state never resolves, and every Sakshi-originated write is silently permitted. Seesakshi.protocolsfor the interfaces and your host's adapter layer for examples.
Install
Sakshi is published to PyPI under the distribution name pysakshi. The
importable module is still sakshi:
pip install pysakshi
import sakshi
The bare name sakshi is reserved by an unrelated PyPI account with no
releases; once that name is recovered, pysakshi will become an alias.
To install the latest unreleased commit from source:
pip install git+https://github.com/bionicbutterfly13/sakshi
Release process: see docs/release-checklist.md.
What it is
Sakshi exposes a small, opinionated set of seams a host application supplies:
- An
EventBusfor emitting cycle and goal events. - A
Clockfor deterministic time. - A
GoalStateStorefor fetching world state and recording goal outcomes. - An optional
BasinHookfor hosts that maintain an attractor-basin field. - A
WriteGuardfor routing Sakshi-originated writes through the host's safety policy.
Around these protocols Sakshi assembles a generic six-phase cognitive cycle (PERCEIVE, INTERPRET, EVAL, INTEND, PLAN, ACT) and a meta-loop (MONITOR, ASSESS, CONTROL) framed as general metacognitive phases.
Quickstart
import asyncio
from sakshi.registries import PhaseRegistry
from sakshi.protocols import NoOpEventBus
async def main() -> None:
registry = PhaseRegistry(event_bus=NoOpEventBus())
await registry.start_cycle("cycle-001")
await registry.record_phase_output("PERCEIVE", {"basins": ["attention"]})
await registry.record_phase_output("INTERPRET", {"confidence": 0.82})
trace = await registry.finalize_cycle()
print(trace.cycle_id)
print([phase.phase_name for phase in trace.phase_results])
asyncio.run(main())
Hosts that need production side effects implement the small protocols in
sakshi.protocols and pass those implementations into Sakshi runtime classes.
Influences
Sakshi draws inspiration from MIDCA-style metacognitive control loops, active-inference monitoring, and production cognitive-runtime experience. See INSPIRATION.md for the full provenance.
Sakshi is not a MIDCA implementation, MIDCA-compatible, or a fork of any MIDCA codebase. The MIDCA reference architecture is one influence among several.
License
Apache-2.0. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysakshi-0.3.0.tar.gz.
File metadata
- Download URL: pysakshi-0.3.0.tar.gz
- Upload date:
- Size: 45.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1065243299dda02d1369d029a2e7d1a43e37598861ab6bcdd3d5a49dd978de1
|
|
| MD5 |
534ddcd3e1d83fdd324e6430b4103a58
|
|
| BLAKE2b-256 |
ebb29abd861f1b2aa9f47cc7fc59cfe1783d9fb2620431655e8666e561453b75
|
Provenance
The following attestation bundles were made for pysakshi-0.3.0.tar.gz:
Publisher:
release.yml on bionicbutterfly13/sakshi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pysakshi-0.3.0.tar.gz -
Subject digest:
b1065243299dda02d1369d029a2e7d1a43e37598861ab6bcdd3d5a49dd978de1 - Sigstore transparency entry: 1450882431
- Sigstore integration time:
-
Permalink:
bionicbutterfly13/sakshi@eefacdc4513e3efc1a3d14cac80c95cd44e023d3 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/bionicbutterfly13
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@eefacdc4513e3efc1a3d14cac80c95cd44e023d3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pysakshi-0.3.0-py3-none-any.whl.
File metadata
- Download URL: pysakshi-0.3.0-py3-none-any.whl
- Upload date:
- Size: 60.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88212230505c9f4fffe3d521e31904e4b1c38a74e10b9329a0d3962b4890887a
|
|
| MD5 |
6dd6b0d8d51399ebf578a0cf9cfe5cc9
|
|
| BLAKE2b-256 |
a4e4f178cccabf4fcc8bd7842450e9068dabced9e4d0eb3c4b2b5dae77524461
|
Provenance
The following attestation bundles were made for pysakshi-0.3.0-py3-none-any.whl:
Publisher:
release.yml on bionicbutterfly13/sakshi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pysakshi-0.3.0-py3-none-any.whl -
Subject digest:
88212230505c9f4fffe3d521e31904e4b1c38a74e10b9329a0d3962b4890887a - Sigstore transparency entry: 1450882570
- Sigstore integration time:
-
Permalink:
bionicbutterfly13/sakshi@eefacdc4513e3efc1a3d14cac80c95cd44e023d3 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/bionicbutterfly13
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@eefacdc4513e3efc1a3d14cac80c95cd44e023d3 -
Trigger Event:
push
-
Statement type: