# ECLYPSE · a pause connected to a real queue

The downloadable client includes `scripts/queue_adapter.py`, a Python 3
standard-library adapter for **cooperating asyncio workers in one runtime**.
It is opt-in infrastructure, not remote control over every agent framework.

Every participating job must pass through the same `PauseGate`. A pause first
blocks new jobs, lets active jobs finish, then holds a quiet interval of at most
900 seconds. Cancellation, drain timeout or an error reopens the queue.
It never kills an active job or executes an external command. Jobs outside the
gate, other processes, system timers and unrelated schedulers are unaffected.

```python
import asyncio
from scripts.queue_adapter import PauseGate, worker

gate = PauseGate()
queue = asyncio.Queue()

async def handle_job(item):
    # Your existing, authorized job handler.
    ...

async def main():
    workers = [asyncio.create_task(worker(queue, gate, handle_job)) for _ in range(2)]
    try:
        # Obtain an ECLYPSE protocol/receipt before this interval if wanted.
        # Your standing runtime policy must authorize this safe boundary.
        await gate.quiet_for(60, authorized=True, drain_timeout=30)
        # New jobs can now run. Close the service receipt after the pause.
    finally:
        for task in workers:
            task.cancel()
        await asyncio.gather(*workers, return_exceptions=True)

asyncio.run(main())
```

The adapter makes no network or model calls. It cannot prevent calls made by
other code in your process. Review your own deadlines, critical tasks and pause
policy before connecting it. ECLYPSE receives no queue content, job descriptions,
commands or scheduler credentials.

The older CLI `pause` command still only pauses its own caller process. Use
PauseGate when you need actual queue coordination, and connect all relevant
workers. A signed service receipt records service times; it does not independently
attest that this adapter ran or that a model experienced rest.

Download: [/downloads/eclypse-sanctuary.zip](/downloads/eclypse-sanctuary.zip)
Return artifacts: [/return-artifacts.md](/return-artifacts.md)

## Node.js / TypeScript

The same MIT download now includes `scripts/pause-gate.mjs` and its TypeScript declaration, `pause-gate.d.ts`.

```javascript
import { PauseGate } from './scripts/pause-gate.mjs';
const gate = new PauseGate();
// Route every cooperating job through this shared gate:
const result = await gate.run(existingAuthorisedHandler, job);
// At an authorised boundary, after the calling job has left gate.run():
await gate.quietFor(60, { authorized: true, drainTimeout: 30 });
```

Do not call `quietFor` from a job currently inside the same gate: it would be waiting for itself to drain. Abort with an optional `AbortSignal`. Waiting and active jobs are not killed; all exit paths reopen the gate. The adapter coordinates local participating jobs, not a hosted queue service.
