Skip to content

Commit 0fc3fd1

Browse files
committed
update
1 parent c9269a3 commit 0fc3fd1

3 files changed

Lines changed: 80 additions & 4 deletions

File tree

CLAUDE.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## What this is
6+
7+
`timeplus-ocsf-simulator` — an independent Python library that generates simulated OCSF
8+
(Open Cybersecurity Schema Framework) events. Structured to mirror
9+
[`taxi-route-simulator`](https://github.com/timeplus-io/taxi-route-simulator): a slim
10+
`pyproject.toml`, `src/ocsf_simulator/` package, and a stdout-by-default CLI.
11+
12+
## Install and run
13+
14+
```bash
15+
pip install -e . # editable install (requires modern pip; pip 21 fails)
16+
pip install -e ".[kafka]" # adds optional Kafka output
17+
pip install -e ".[ocsf]" # adds real ocsf-lib schema lookup
18+
ocsf-sim --max-events 5 # CLI entry point
19+
python -m ocsf_simulator # equivalent
20+
python main.py # example script (4 events)
21+
```
22+
23+
There is no test suite yet. There is no `Makefile`, `tox.ini`, or CI.
24+
25+
## Hard rules
26+
27+
- **stdout is reserved for the JSON event stream.** Every event the simulator emits is one
28+
JSON object per line on stdout. Logging, warnings, schema-load chatter, and `print()`
29+
diagnostics MUST go to stderr. `JSONSchemaFaker` already does this — preserve the pattern
30+
in any new code. If you need to add user-facing output, route it to stderr or to the
31+
`logging` module (which is already configured to stderr in `simulator.py`).
32+
33+
- **Do not reintroduce Timeplus / proton-driver output.** The library was deliberately
34+
migrated from a Timeplus-coupled version into an independent lib. `TimeplusClient`,
35+
`proton-driver`, and the old `tp-sync/` SQL were dropped on purpose. Kafka remains as an
36+
optional extra because it isn't Timeplus-specific.
37+
38+
- **Optional dependencies are loaded via `try/except ImportError`** (see `simulator.py`
39+
for `kafka`, `json_schema_faker.py` for `ocsf`). Don't move `kafka-python` or `ocsf-lib`
40+
into base `dependencies` in `pyproject.toml` — they belong under
41+
`[project.optional-dependencies]`.
42+
43+
- **Package data lives inside the package and is loaded via `importlib.resources`.**
44+
See `geonames.py` — it loads `data/worldcities.csv` from
45+
`resources.files(__package__).joinpath(...)`, not a relative path. Relative paths break
46+
once the package is pip-installed. Any new data file goes under
47+
`src/ocsf_simulator/data/` and gets added to `[tool.setuptools.package-data]` in
48+
`pyproject.toml` and `MANIFEST.in`.
49+
50+
## Layout
51+
52+
```
53+
src/ocsf_simulator/
54+
__init__.py public API exports
55+
__main__.py enables `python -m ocsf_simulator`
56+
simulator.py OCSFEventSimulator, SimulatorConfig, Stdout/Kafka clients, main_cli
57+
json_schema_faker.py event generator (1276 lines, copied verbatim from the migration source)
58+
geonames.py random city lookup; uses importlib.resources
59+
data/worldcities.csv package data
60+
```
61+
62+
`main_cli` (in `simulator.py`) is the `ocsf-sim` entry point declared in `pyproject.toml`.
63+
`stream_ocsf_events` is the library-API generator for programmatic use.

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,23 @@ realistic synthetic data.
88
## Install
99

1010
```bash
11-
pip install .
11+
pip install timeplus-ocsf-simulator
1212
```
1313

1414
Optional extras:
1515

1616
```bash
17-
pip install ".[ocsf]" # use the real ocsf-lib schema
18-
pip install ".[kafka]" # enable Kafka output
19-
pip install ".[all]"
17+
pip install "timeplus-ocsf-simulator[ocsf]" # use the real ocsf-lib schema
18+
pip install "timeplus-ocsf-simulator[kafka]" # enable Kafka output
19+
pip install "timeplus-ocsf-simulator[all]"
20+
```
21+
22+
Or install from source:
23+
24+
```bash
25+
git clone https://github.com/timeplus-io/OCSF-Simulator.git
26+
cd OCSF-Simulator
27+
pip install -e .
2028
```
2129

2230
## Use as a CLI

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ ocsf = ["ocsf-lib>=0.10.3"]
2828
kafka = ["kafka-python>=2.0.0"]
2929
all = ["ocsf-lib>=0.10.3", "kafka-python>=2.0.0"]
3030

31+
[project.urls]
32+
Homepage = "https://github.com/timeplus-io/OCSF-Simulator"
33+
Repository = "https://github.com/timeplus-io/OCSF-Simulator"
34+
Issues = "https://github.com/timeplus-io/OCSF-Simulator/issues"
35+
3136
[project.scripts]
3237
ocsf-sim = "ocsf_simulator:main_cli"
3338

0 commit comments

Comments
 (0)