Metadata-Version: 2.4
Name: elastik
Version: 0.0.1
Summary: Pastebin with HMAC that accidentally became a web OS. pip install one ring.
Author: Ranger Chen
License: MIT
Project-URL: Homepage, https://github.com/rangersui/Elastik
Project-URL: Repository, https://github.com/rangersui/Elastik
Keywords: http,pastebin,local-first,ai,web-os,rust
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Rust
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# elastik

> `pip install elastik` — and you get a Rust web OS pretending to be a Python module.

Same trick as NumPy: the `.whl` ships a precompiled binary inside the
package; the Python layer is a thin client. You write Python; a Rust
server does the work; you never see Cargo.

```python
import elastik

e = elastik.start(token="x")              # spawn bundled rust core
e.put("/home/note", "hello")
print(e.get("/home/note", raw=True))      # b'hello'
elastik.stop()
```

Module-level too — point at any running elastik via `ELASTIK_URL`:

```python
import elastik
elastik.put("/home/note", "hi")
print(elastik.get("/home/note", raw=True))
```

Reactor (declarative event handlers):

```python
import elastik

@elastik.listen("/home/inbox/*")
def triage(body, world, meta):
    if b"urgent" in body:
        return elastik.Reply(f"/home/alerts/{world.rsplit('/',1)[-1]}", body)
    return elastik.Archive()

elastik.serve(port=3200)
```

Set elastik-core to fan out to that port:

```bash
ELASTIK_LISTENERS="/home/inbox/*=http://localhost:3200/triage" \
    elastik run --port 3105 --token t
```

## Install

```bash
pip install elastik
```

(For now: build from source — see "Build from source" below.)

## CLI

```bash
elastik info                  # show bundled-binary path + size
elastik run --port 3105       # spawn the bundled core, block
```

## What's bundled

- **Rust binary** at `elastik/_bin/elastik-core[.exe]`
  - HTTP + SQLite + HMAC + auth + harvard gate + listener fanout
  - ~4.3 MB stripped
  - source: `Elastik-server/Elastik-core/`
- **Python SDK** (`elastik.sdk.Elastik`)
  - atom bindings: `put`, `get`, `head`, `delete`, `list`, `shaped`
  - stdlib only (urllib + json), no requests / httpx
- **Python reactor sugar** (`elastik.reactor`)
  - `@listen(pattern)` decorator
  - `MoveTo`, `Reply`, `Archive`, `Drop` action classes
  - two deployment shapes: as elastik-python plugin (`finalize()`),
    or as standalone sidecar (`serve()`)

## The PyTorch parallel

| layer | what | who writes |
|---|---|---|
| L0 — Rust core | bedrock atoms (HTTP/SQLite/HMAC) | one human, once |
| L1 — Python SDK | `elastik.put`, `elastik.get`, … | AI, once |
| L1.5 — plugin runtime | (in elastik-server, hot-reload) | already exists |
| L2 — reactor sugar | `@elastik.listen` + Action classes | AI, once |
| L3 — agent programs | composition: if/for + L1 + L2 + ai | AI, daily |

`elastik.put()` is `np.array()`. The frontend isn't this call — it's
what you compose with these atoms. See [Elastik-core/README.md] for
the full architecture.

## Build from source

```bash
# 1. build the rust core
cd Elastik-core
cargo build --release

# 2. drop the binary into the python package
cp target/release/elastik-core* ../elastik-pip/src/elastik/_bin/

# 3. install the python package
cd ../elastik-pip
pip install -e .
```

Then:

```bash
python -c "import elastik; e = elastik.start(); print(e.put('/home/x', 'hi'))"
```

## Status

Sketch. One platform at a time (this build is for the host you ran
`cargo build` on). Multi-platform wheels via `cibuildwheel` is the
next step.

## License

MIT.
