Metadata-Version: 2.4
Name: argus-terminal
Version: 0.1.0
Summary: ARGUS - offline live meta-world mission terminal: criticality dispatch, unlimited missions, evidence and logs.
Author: ARGUS
License: MIT
Keywords: monitoring,offline,terminal,mission,evidence,logging
Classifier: Programming Language :: Python :: 3
Classifier: Environment :: Console
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Dynamic: license-file

# ARGUS — Live Meta-World Mission Terminal

Offline, self-hosted, dependency-free terminal for monitoring everything that can be
monitored technically and actually. Missions span police, military, medicine,
professorship and every other real-world role, plus technical probes of the host. They
are ranked by criticality (P0–P3), can be persistent/standing or transient, and every
observation, event, log, evidence file and live world snapshot is stored locally (SQLite
+ content-addressed artifact store + JSON/JSONL world files).

## Install

```bash
cd BDCS/argus
python3 -m pip install -e .
argus --root ../.argus bootstrap  # create starter mission catalog + probes
argus --root ../.argus serve      # live dashboard at http://127.0.0.1:8787
```

No runtime dependencies. Python ≥ 3.10. Everything works offline (`--host` defaults to
loopback; `http`/`tcp` probes only touch endpoints you configure).

## Runs in the terminal

Yes. ARGUS is terminal-native; the dashboard is optional.

```bash
argus --root ../.argus dispatch       # full-screen 911-style dispatch board
argus --root ../.argus watch          # live probe stream, Ctrl-C to stop
argus --root ../.argus status         # current criticality overview
argus --root ../.argus logs --follow  # streaming log tail
argus --root ../.argus mission list   # ranked board
```

`dispatch` (alias `tui`) is the primary interface: a self-updating full-screen board with
a criticality queue, mission dossier, live event/log feed and keyboard actions
(acknowledge, resolve, reopen, run, pin, forge, filter, search, log). It runs the
scheduler in the background and rings the bell on new failures. `watch` prints the same
stream as line output; neither needs a browser or network. `serve` additionally exposes
the local zero-dependency dashboard and API when you want the graphical board.

## Meta-world missions: everything that exists

Meta-world missions are **actual-world duty packets**, not simulations of this computer.
They cover police, military, emergency medicine, nursing, fire and rescue, dispatch,
professorship, school teaching, science, engineering, software, cybersecurity, law,
diplomacy, civil service, social work, humanitarian aid, utilities, water, transport,
aviation, maritime, agriculture, food safety, conservation, journalism, archives,
finance, manufacturing, construction, hospitality and many other roles. The supply is
unlimited because each mission is generated from role × incident × place × condition ×
scale × seed.

Every mission carries a live, technical layer:

- a concrete **objective checklist** you complete locally (`argus mission task done`)
- **live telemetry** through a `world` probe (queue, load, capacity, backlog, incidents,
  response time, coverage) sampled from the ever-changing world snapshot
- **saveable files and complete evidence**: `world.json`, append-only `world_log.jsonl`,
  per-incident JSON packets, periodic full-state snapshots, DB observations and logs
- **metadata**: role, category, scenario, place, condition, scale, seed, batch,
  evidence required, constraints, handoff and hints

```bash
argus world status                     # live role picture, incidents, queue pressure
argus world tick                       # advance the world once now
argus world log                        # tail live world activity
argus meta templates                   # list every role template
argus meta forge 25                    # create 25 missions with live telemetry
argus meta forge 100 --seed 42 --run   # deterministic batch + immediate sampling
argus meta forge 10 --domain police    # restrict to a role or category
argus meta forge 10 --domain health
```

`argus dispatch`, `argus watch` and `argus serve` run the world in the background. The
world changes continuously, auto-dispatches incidents into new missions, writes logs and
evidence, and rings the dispatch bell on new failures. Press `n` on the board to forge a
mission live, `t` to complete the next objective, and `T` to reopen one.

The world is saved in `world.json` and in the SQLite `meta` table; the activity log is
`world_log.jsonl`. Incident packets and periodic snapshots are content-addressed in
`artifacts/` and included in `argus export`.

```bash
argus mission task list KEY            # objectives and progress
argus mission task done KEY            # complete the next objective
argus mission task done KEY 3 -n "done at shift handover"
argus mission task undo KEY            # reopen the last completed objective
argus mission task add KEY "new objective"
```

You can also define any mission and its probes in one JSON document:

```bash
argus mission define mission.json --run
```

```json
{
  "key": "world.claim.001",
  "title": "Verify a world-state claim",
  "summary": "Attach a primary source, an observation and a conclusion.",
  "domain": "records",
  "criticality": 70,
  "persistence": "standing",
  "tags": ["claim", "provenance"],
  "meta": {"objectives": ["state the claim", "attach evidence", "record confidence"]},
  "probes": [
    {"name": "world.claim.001.heartbeat", "kind": "heartbeat", "interval": "15m",
     "spec": {"note": "review the claim and its evidence"}}
  ]
}
```

## Commands

```bash
argus init | doctor | status | verify | prune --days 30
argus prune --evidence --keep-days 7 --yes   # also drop old evidence blobs

argus mission add KEY "Title" -c 95 -d power -p standing -t power,grid -s "summary"
argus mission list [--view active|persistent|passed|archived|all] [--domain D] [--json]
argus mission show KEY [--json]
argus mission update KEY --criticality 80 --status monitoring --pin
argus mission resolve KEY -n "condition cleared"    # passed, can be reopened automatically
argus mission reopen KEY | archive KEY | rm KEY

argus log "message" -l warning -s ops --data k=v --data count=3 [-m KEY] [-f FILE]
argus logs [--limit 100] [--level major] [--follow]

argus evidence add FILE -m KEY -d "why it matters"
argus evidence note "text evidence" -m KEY -n note.md
argus evidence list [-m KEY] | get ID --out FILE | verify
argus open ID | latest -m KEY | world | log | ./any/file     # $PAGER
argus open ID --out FILE | --cat

argus probe add NAME --kind disk --mission KEY --interval 60 \
  --set path=/ --fail gt:95 --warn gt:85
argus probe list | show NAME | enable NAME | disable NAME | run NAME | rm NAME
argus probe silence NAME --until 2h -r "reason" | unsilence NAME

argus watch [--tick 1] [--once]
argus dispatch [--tick 1] [--refresh 2] [--view active] [--no-watch] [--no-bell]
argus meta templates [--json]
argus meta forge [COUNT] [--seed N] [--domain ROLE|CATEGORY] [--run] [--json]
argus world status [--limit 20] [--json] | tick | log | reset --yes
argus mission task list KEY | done KEY [N] | undo KEY [N] | add KEY TEXT
argus mission define FILE --run
argus serve [--host 127.0.0.1] [--port 8787] [--no-watch]
argus export --out bundle.zip
```

`--root` (or `ARGUS_ROOT`) selects the data directory: `argus.sqlite3`, `artifacts/`
(content-addressed evidence), logs inside the DB.

## Mission model

- **criticality** 0–100 → **P0** ≥90, **P1** ≥70, **P2** ≥40, **P3** <40
- **status**: `open` → `monitoring` → `failing` → `passed` / `archived`
- **persistence**: `transient`, `recurring`, `standing` (standing missions stay on the board)
- every probe result is an **observation** with verdict `ok|warn|fail|unknown`, raw
  payload, spec snapshot, timestamp, severity and optional evidence artifacts
- a failing probe moves a mission to `failing`; even `passed` missions reopen on a new
  failure (archived ones are skipped); passing again marks them recovered
- everything is ranked pinned-first, failing-first, then by criticality, then status/age

## Dashboard

`argus serve` exposes a zero-dependency live dashboard on loopback:

- P0/P1/P2/P3 boards, domain filter, free-text search, active/persistent/passed/archived views
- live SSE feed, critical events, log stream and an append-anything log composer
- mission sheet with observations, events, probe `run now`, evidence download, resolve /
  reopen / pin / archive actions

API: `GET /api/state`, `/api/missions/<key>`, `/api/evidence/<id>`, `/api/logs`,
`/api/stream` (SSE), `/api/health`; `POST /api/logs`,
`/api/missions/<key>/action`, `/api/probes/<name>/run`.

## Probe kinds

`sysinfo`, `clock`, `load`, `memory`, `disk`, `file`, `dir`, `process`, `command`,
`tcp`, `http`, `sqlite`, `thermal`, `heartbeat`, `world`, `meta` (`world` and `meta`
are the same live meta-world telemetry probe).

Rules live in the probe spec:

```json
{"fail": {"op": "gt", "value": 95},
 "warn": {"op": "gt", "value": 85},
 "expect": {"op": "eq", "value": 1}}
```

Ops: `eq ne gt gte lt lte in not_in contains matches truthy falsy`. Precedence:
`fail` → `warn` → `expect` (fails when not met) → `ok` (forces pass).

`command` probes are real commands (shell by default) and store stdout/stderr as
evidence; they are the universal escape hatch for anything not covered by a built-in kind.

## Data & evidence

- `evidence` rows keep sha256, size, media type, source path, description and the bytes
  themselves (up to 16 MiB inline; all bytes are always written under `artifacts/ab/<sha>`).
- `verify` re-hashes every artifact against the ledger and runs SQLite `quick_check`.
- `export` produces a ZIP with `manifest.json` (all tables) plus every artifact.
- `prune` removes old logs/events/observations only; missions and evidence are retained.
- `argus prune --evidence --keep-days N` removes **old artifact blobs only**. Every
  `evidence` ledger row stays: id, name, size, sha256, mission, timestamps and
  description are preserved, and `pruned_at` records when the bytes were removed.
  Blobs shared with newer evidence are never deleted, and original source files are
  never touched (only files under `artifacts/<xx>/<sha256>`).
- Evidence pruning is opt-in and safe by default: without `--yes` it is a dry run.
  `verify`/`doctor` report pruned rows as `PRUNE`, not as failures; `open`/`get`
  explain that the blob was pruned while keeping the ledger hash.
- `open` pages evidence, `world.json`, `world_log.jsonl` or any file with `$ARGUS_PAGER`,
  `$PAGER`, `less`, `more`, or plain stdout. `--out FILE` saves a copy; `--cat` streams
  raw bytes for piping (`argus open 1110 | jq .`). On the dispatch board: `e` opens the
  selected mission's latest evidence, `E` opens an evidence ID, `o` opens `world.json`.
  `A` archives the mission (stops its probes, evidence retained) and `X` resolves the
  mission while disabling its currently failing probes.
- The board is responsive: above 72x20 it uses the full queue/dossier/feed layout;
  below that it switches to a stacked compact layout and redraws on every resize.

## Layout

```
src/argus/db.py        schema
src/argus/store.py     persistence, evidence ledger, export/verify
src/argus/openers.py   resolve + page evidence, world files and arbitrary files
src/argus/probes.py    probe implementations + rule engine
src/argus/engine.py    live scheduler, verdicts, status transitions, SSE feed
src/argus/tui.py       full-screen dispatch board (stdlib curses)
src/argus/meta_world.py offline forge for unlimited actual-world missions + objectives
src/argus/world.py     live world simulation, telemetry, incidents, logs and evidence
src/argus/api.py       local HTTP API + SSE + dashboard server
src/argus/domains.py   starter catalog covering universal monitoring domains
src/argus/cli.py       command line
src/argus/web/         zero-dependency dashboard
```
