Skip to content

Commit e23b0a8

Browse files
authored
feat: HTTP gateway, daemon supervisor, cron scheduler (M22) (#388)
* feat: add HTTP gateway, daemon supervisor, and cron scheduler (M22) Add three feature-gated infrastructure components: - zeph-gateway: axum-based HTTP gateway with webhook ingestion, bearer auth (blake3 + constant-time comparison), per-IP rate limiting, and health endpoint - zeph-core::daemon: component supervisor with health monitoring, PID file management, and graceful shutdown integration - zeph-scheduler: cron-based periodic task scheduler with SQLite persistence, built-in task kinds (memory_cleanup, skill_refresh, health_check), and extensible TaskHandler trait All components are optional (gateway, daemon, scheduler features) and integrate with existing config, vault, and shutdown systems. Closes #379, #380, #381 Ref #367 * docs: add M22 infrastructure documentation, update changelog and readme Add mdBook pages for HTTP gateway, daemon supervisor, and cron scheduler. Update feature flags table, crate architecture page, SUMMARY.md, CHANGELOG.md, and README.md. Fix rustfmt in server.rs.
1 parent d958f64 commit e23b0a8

File tree

28 files changed

+1820
-3
lines changed

28 files changed

+1820
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
77
## [Unreleased]
88

99
### Added
10+
- `zeph-gateway` crate: axum HTTP gateway with POST /webhook ingestion, bearer auth (blake3 + ct_eq), per-IP rate limiting, GET /health endpoint, feature-gated (`gateway`) (#379)
11+
- `zeph-core::daemon` module: component supervisor with health monitoring, PID file management, graceful shutdown, feature-gated (`daemon`) (#380)
12+
- `zeph-scheduler` crate: cron-based periodic task scheduler with SQLite persistence, built-in tasks (memory_cleanup, skill_refresh, health_check), TaskHandler trait, feature-gated (`scheduler`) (#381)
13+
- New config sections: `[gateway]`, `[daemon]`, `[scheduler]` in config/default.toml (#367)
14+
- New optional feature flags: `gateway`, `daemon`, `scheduler`
1015
- Hybrid memory search: FTS5 keyword search combined with Qdrant vector similarity (#372, #373, #374)
1116
- SQLite FTS5 virtual table with auto-sync triggers for full-text keyword search
1217
- Configurable `vector_weight`/`keyword_weight` in `[memory.semantic]` for hybrid ranking

Cargo.lock

Lines changed: 58 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ anyhow = "1.0"
1616
candle-core = { version = "0.9", default-features = false }
1717
candle-nn = { version = "0.9", default-features = false }
1818
candle-transformers = { version = "0.9", default-features = false }
19+
chrono = { version = "0.4", default-features = false, features = ["std"] }
1920
crossterm = "0.29"
2021
axum = "0.8"
2122
blake3 = "1.8"
@@ -74,6 +75,7 @@ tree-sitter-typescript = "0.23"
7475
unicode-width = "0.2"
7576
url = "2.5"
7677
uuid = "1.21"
78+
cron = "0.15"
7779
zeph-a2a = { path = "crates/zeph-a2a", version = "0.9.8" }
7880
zeph-channels = { path = "crates/zeph-channels", version = "0.9.8" }
7981
zeph-core = { path = "crates/zeph-core", version = "0.9.8" }
@@ -83,6 +85,8 @@ zeph-mcp = { path = "crates/zeph-mcp", version = "0.9.8" }
8385
zeph-memory = { path = "crates/zeph-memory", version = "0.9.8" }
8486
zeph-skills = { path = "crates/zeph-skills", version = "0.9.8" }
8587
zeph-tools = { path = "crates/zeph-tools", version = "0.9.8" }
88+
zeph-gateway = { path = "crates/zeph-gateway", version = "0.9.8" }
89+
zeph-scheduler = { path = "crates/zeph-scheduler", version = "0.9.8" }
8690
zeph-tui = { path = "crates/zeph-tui", version = "0.9.8" }
8791

8892
[workspace.lints.clippy]
@@ -112,6 +116,9 @@ router = ["zeph-llm/router"]
112116
self-learning = ["zeph-core/self-learning"]
113117
tui = ["dep:zeph-tui"]
114118
index = ["dep:zeph-index", "zeph-core/index"]
119+
gateway = ["dep:zeph-gateway"]
120+
daemon = ["zeph-core/daemon"]
121+
scheduler = ["dep:zeph-scheduler"]
115122
vault-age = ["zeph-core/vault-age"]
116123
otel = ["dep:opentelemetry", "dep:opentelemetry_sdk", "dep:opentelemetry-otlp", "dep:tracing-opentelemetry"]
117124

@@ -133,6 +140,8 @@ zeph-llm.workspace = true
133140
zeph-memory.workspace = true
134141
zeph-skills.workspace = true
135142
zeph-tools.workspace = true
143+
zeph-gateway = { workspace = true, optional = true }
144+
zeph-scheduler = { workspace = true, optional = true }
136145
zeph-tui = { workspace = true, optional = true }
137146

138147
[dev-dependencies]

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ cargo build --release --features tui
112112
```
113113
zeph (binary) — bootstrap, AnyChannel dispatch, vault resolution (anyhow for top-level errors)
114114
├── zeph-core — Agent split into 7 submodules (context, streaming, persistence,
115-
│ learning, mcp, index), typed AgentError/ChannelError, config hot-reload
115+
│ learning, mcp, index), daemon supervisor, typed AgentError/ChannelError, config hot-reload
116116
├── zeph-llm — LlmProvider: Ollama, Claude, OpenAI, Candle, orchestrator,
117117
│ native tool_use (Claude/OpenAI), typed LlmError
118118
├── zeph-skills — SKILL.md parser, embedding matcher, hot-reload, self-learning, typed SkillError
@@ -122,6 +122,8 @@ zeph (binary) — bootstrap, AnyChannel dispatch, vault resolution (anyhow for t
122122
├── zeph-tools — schemars-driven tool registry (shell, file ops, web scrape), composite dispatch
123123
├── zeph-mcp — MCP client, multi-server lifecycle, unified tool matching
124124
├── zeph-a2a — A2A client + server, agent discovery, JSON-RPC 2.0
125+
├── zeph-gateway — HTTP gateway for webhook ingestion with bearer auth (optional)
126+
├── zeph-scheduler — Cron-based periodic task scheduler with SQLite persistence (optional)
125127
└── zeph-tui — ratatui TUI dashboard with live agent metrics (optional)
126128
```
127129

@@ -149,6 +151,9 @@ Deep dive: [Architecture overview](https://bug-ops.github.io/zeph/architecture/o
149151
| `self-learning` | On | Skill evolution system |
150152
| `vault-age` | On | Age-encrypted secret storage |
151153
| `index` | On | AST-based code indexing and semantic retrieval |
154+
| `gateway` | Off | HTTP gateway for webhook ingestion |
155+
| `daemon` | Off | Daemon supervisor for component lifecycle |
156+
| `scheduler` | Off | Cron-based periodic task scheduler |
152157
| `metal` | Off | Metal GPU acceleration (macOS) |
153158
| `tui` | Off | ratatui TUI dashboard with real-time metrics |
154159
| `cuda` | Off | CUDA GPU acceleration (Linux) |

config/default.toml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,44 @@ enabled = false
235235
# Audit destination: "stdout" or file path (e.g., "./data/audit.jsonl")
236236
destination = "stdout"
237237

238+
[gateway]
239+
# Enable HTTP gateway for webhook ingestion (feature-gated: --features gateway)
240+
enabled = false
241+
# Bind address (127.0.0.1 = localhost only, 0.0.0.0 = all interfaces)
242+
bind = "127.0.0.1"
243+
# HTTP port
244+
port = 8090
245+
# auth_token = "secret" # optional, from vault ZEPH_GATEWAY_TOKEN
246+
# Rate limit: max requests per minute per IP
247+
rate_limit = 120
248+
# Maximum request body size in bytes (1MB)
249+
max_body_size = 1048576
250+
251+
[daemon]
252+
# Enable daemon supervisor (feature-gated: --features daemon)
253+
enabled = false
254+
# PID file location
255+
pid_file = "~/.zeph/zeph.pid"
256+
# Health check interval in seconds
257+
health_interval_secs = 30
258+
# Maximum restart backoff in seconds
259+
max_restart_backoff_secs = 60
260+
261+
[scheduler]
262+
# Enable cron scheduler (feature-gated: --features scheduler)
263+
enabled = false
264+
# Example task definitions:
265+
# [[scheduler.tasks]]
266+
# name = "memory_cleanup"
267+
# cron = "0 0 0 * * *"
268+
# kind = "memory_cleanup"
269+
# config = { max_age_days = 90 }
270+
#
271+
# [[scheduler.tasks]]
272+
# name = "health_check"
273+
# cron = "0 */5 * * * *"
274+
# kind = "health_check"
275+
238276
[security]
239277
# Redact secrets (API keys, tokens) from LLM responses before display
240278
redact_secrets = true

crates/zeph-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ repository.workspace = true
1010
default = []
1111
index = ["dep:zeph-index"]
1212
mcp = ["dep:zeph-mcp"]
13+
daemon = []
1314
self-learning = ["zeph-skills/self-learning"]
1415
vault-age = ["dep:age"]
1516

crates/zeph-core/src/config/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ impl Config {
6767
}
6868
}
6969
}
70+
if let Some(val) = vault.get_secret("ZEPH_GATEWAY_TOKEN").await? {
71+
self.gateway.auth_token = Some(val);
72+
}
7073
Ok(())
7174
}
7275
}

0 commit comments

Comments
 (0)