Metadata-Version: 2.4
Name: caducus
Version: 0.4.0
Summary: CLI for collecting ops events and running reinforcement-memory analysis.
License: MIT License
        
        Copyright (c) 2026 AnthusAI
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: behave>=1.2.6; extra == "dev"
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: ruff>=0.4.0; extra == "dev"
Requires-Dist: black>=24.0; extra == "dev"
Requires-Dist: build>=1.2.2; extra == "dev"
Requires-Dist: python-semantic-release>=10.5.3; extra == "dev"
Provides-Extra: radar
Requires-Dist: PyYAML>=6.0; extra == "radar"
Requires-Dist: virtuus>=0.4.0; extra == "radar"
Provides-Extra: notify
Requires-Dist: boto3>=1.35.8; extra == "notify"
Requires-Dist: dnspython>=2.6; extra == "notify"
Provides-Extra: notify-dev
Requires-Dist: boto3>=1.35.8; extra == "notify-dev"
Requires-Dist: dnspython>=2.6; extra == "notify-dev"
Requires-Dist: moto[dynamodb,ses,sqs,ssm]>=5.0; extra == "notify-dev"
Requires-Dist: jsonschema>=4.0; extra == "notify-dev"
Requires-Dist: PyYAML>=6.0; extra == "notify-dev"
Requires-Dist: pytest-cov>=5.0; extra == "notify-dev"
Provides-Extra: reinforcement-memory
Requires-Dist: biblicus>=1.6.0; extra == "reinforcement-memory"
Requires-Dist: scikit-learn>=1.3.0; extra == "reinforcement-memory"
Dynamic: license-file

# Caducus

<img src="docs/cadeceus.png" align="right" width="200" />

Caducus is for teams running production systems who need to spot important issues quickly in noisy operational data.

When the pager goes off, the problem is rarely "no data". The problem is too much data.

Caducus turns that flood of raw logs into a short, prioritized radar of issue blips so operators can decide what to investigate first.

What you get from the radar:

- **How intense is this issue?** `weight=hot|warm|cold`
- **How fresh is this issue?** `temporal=new|trending|known`
- **How big is this issue?** `n=<member_count>`

Instead of scanning thousands of lines manually, you get a ranked list of patterns with both frequency and recency signals.

## From Log Flood To Radar

Raw logs look like this - an overwhelming firehose:

```text
260316,115910,INFO,KERNEL,,instruction cache parity error corrected
260316,115911,INFO,KERNEL,,data cache parity error corrected
260316,115911,WARN,KERNEL,,torus receiver x+ input pipe error(s) detected and corrected
```

You have a magic "radar" device for telling you what's important in there and ranking it by priority. Caducus clusters those logs into radar-ready blips. Here's what you see on that radar:

```text
Group: bgl-demo:KERNEL  Texts: 4983  Run: 899a6ffb-a5ea-47e1-b856-71ba8054cd74
   1. parity error, parity, instruction cache  [weight=warm temporal=known]  n=4827  (merged 97 clusters)
   2. mask, ce sym, sym  [weight=warm temporal=known]  n=114
   3. corrected, cache parity, parity error  [weight=warm temporal=known]  n=42
```

Read this as:

- `weight` is recurrence/volume pressure (hot/warm/cold).
- `temporal` is recency state (new/trending/known).
- `n` is cluster member count.

In other words, each line is a blip on the radar with both intensity and freshness.

Top blips from a real supercomputer log dataset:

- Repeated parity-error corrections in cache-related paths (dominant cluster).
- CE/SYM mask signaling bursts.
- Secondary corrected parity-error pattern cluster.

### How it works conceptually

```mermaid
flowchart TD
    subgraph logs [1. Noisy Log Stream]
        L1["error at 10:01: node_X failed parity check"]
        L2["error at 10:05: node_Y failed parity check"]
        L3["warn at 10:06: network timeout on port 80"]
    end

    subgraph clusters [2. Semantic Memory]
        C1(("Parity Error<br/>Cluster"))
        C2(("Network Timeout<br/>Cluster"))
    end

    subgraph blips [3. Radar Blips]
        B1["[weight=hot temporal=trending] n=2"]
        B2["[weight=cold temporal=new] n=1"]
    end

    L1 -->|"semantic match"| C1
    L2 -->|"semantic match"| C1
    L3 -->|"semantic match"| C2

    C1 ==>|"reinforces"| B1
    C2 ==>|"initializes"| B2
```

## How a change ships

Merge pull requests into `develop` (CI runs, nothing is published). A release, `develop` merged into `main`, tags a version and publishes the package to PyPI; see [`AGENTS.md`](AGENTS.md).

## Run The Working Demo

Install dependencies:

```bash
pip install -e ".[reinforcement-memory,dev]"
pip install datasets
```

Build a real-world log subset and shift timestamps to a demo "now" so recency signals are meaningful:

```bash
python scripts/download_hdfs_demo.py \
  --dataset bgl \
  --output demo_data/log_sample.csv \
  --max-rows 3000 \
  --anchor-now "2026-03-16T12:00:00Z"
```

Ingest and discover valid groups:

```bash
caducus demo ingest --input demo_data/log_sample.csv --data-dir ./caducus-data
caducus groups --data-dir ./caducus-data
```

Run analysis for a discovered group:

```bash
caducus analyze --group-id 'bgl-demo:KERNEL' --data-dir ./caducus-data
```

Or do ingest + analyze in one command:

```bash
caducus demo run --input demo_data/log_sample.csv --group-id 'bgl-demo:KERNEL' --data-dir ./caducus-data
```

### Notes

- Group IDs are source and component derived: `<source>:<component>` (for this demo it is `bgl-demo:KERNEL`).
- Use single quotes around group IDs containing `$` in shell commands.
- `--anchor-now` preserves spacing between log rows while shifting them to your chosen clock anchor.

## How It Works

Caducus is intentionally thin:

- **Caducus** handles collection, normalization, orchestration, and CLI workflows.
- **Virtuus** provides file-backed JSON storage and retrieval.
- **Biblicus** provides semantic reinforcement-memory analysis.

```mermaid
flowchart TD
    demoFile[DemoDatasetCSV] --> ingest[CaducusDemoIngest]
    ingest --> normalize[CanonicalEvents]
    normalize --> store[VirtuusEventStore]
    store --> readGroup[ReadEventsByGroup]
    readGroup --> analyze[BiblicusReinforcementMemory]
    analyze --> blips[RankedRadarBlips]
```

## Roadmap

- More collectors (CloudWatch/SQS/alerts) feeding canonical events
- Faster topic clustering and richer root-cause hints
- Minimal UI/embeds for operators to view radar blips

## Repository Direction

This repository is being built outside-in. Product definition and behavior specifications come first, followed by the minimum implementation needed to satisfy them.
