refactor(claw): the watch table is the one truth — the config stops carrying watches

The YAML `watches:` seed was the last piece of forge state the config
file carried. Everything else about watches already lived in the
extension: the table (SQLite, runtime-managed), the HTTP routes
(`GET/POST/DELETE /v1/watches`), the chat tools, the poller that reads
the table fresh every pass. A static seed list on top meant two homes
for one fact — and the seed's own semantics (import-once, ignored
once the table has rows) had to be explained to every reader.

Now the config carries none of it:

- `ClawConfig.watches` is gone, with the `Watch` seed type and the
  boot-time validation loop that guarded it. A config still carrying
  `watches:` is refused at parse time — `deny_unknown_fields` turns
  the retirement into a loud migration, not a silent no-op.
- `Watch` moved to `watch_store` (re-exported from the crate root),
  where the row's vocabulary belongs; `validate_watch` keeps guarding
  the one door every writer shares — the routes and the tools both
  call it, so the moved validation tests test it there.
- `seed_from_config` and the daemon's seeding are gone; the operator
  seeds once over HTTP or `watches add`, and the table stays true.

The one guarantee the seed carried that nothing else did — boot
refuses a tokenless watch — goes with it, deliberately: a tokenless
watch now fails at its first poll, loudly, like any other watch the
agent adds at runtime. Boot-time certainty was paying for config
state the daemon no longer owns.
This commit is contained in:
vhaudiquet committed 2026-10-24 01:35:35 +02:00
1 parent f96f8c4c1d
commit c6a3ed8c97
9 files changed
+120 -373

No files matched your search

+14 -9
View File
@@ -7,7 +7,17 @@
use std::sync::Arc;
use rhema_claw::{ClawConfig, ForgeKind, Watch, run_once};
use rhema_claw::{ClawConfig, run_once};
/// Seeds the watch row straight into the table — the config stopped
/// carrying watches, and the test speaks to the daemon the way an
/// integration would: through the store the routes share.
fn seed_watch(dir: &tempfile::TempDir, host: &str) {
rhema_claw::ClawStore::open(dir.path().join("dispatch.db"))
.expect("the watch table opens")
.add("github", "acme/widgets", Some(host), "tok")
.expect("the seed row lands");
}
use rhema_core::{Message, MockProvider, ModelOutput, Role, Session, StopReason, Usage};
use rhema_rsd::{KeyState, Outcome, ResourceKey, SqliteStore, Store};
use serde_json::{Value, json};
@@ -55,7 +65,7 @@ fn reply(text: &str) -> ModelOutput {
}
}
fn config(server: &MockServer, dir: &tempfile::TempDir) -> ClawConfig {
fn config(dir: &tempfile::TempDir) -> ClawConfig {
ClawConfig {
db: Some(dir.path().join("dispatch.db")),
workspace_root: Some(dir.path().join("workspaces")),
@@ -71,12 +81,6 @@ fn config(server: &MockServer, dir: &tempfile::TempDir) -> ClawConfig {
tools_bin: None,
transcript: None,
ingest_token: None,
watches: vec![Watch {
forge: ForgeKind::GitHub,
repo: "acme/widgets".to_owned(),
host: Some(server.uri()),
token: Some("tok".to_owned()),
}],
calendars: Vec::new(),
}
}
@@ -131,7 +135,8 @@ async fn the_second_dispatch_resumes_the_first_conversation() {
.await;
let dir = tempfile::tempdir().expect("tempdir");
let config = config(&server, &dir);
let config = config(&dir);
seed_watch(&dir, &server.uri());
let key = ResourceKey::from("github:acme/widgets#7");
// Pass one: the opened event alone. The cron shape — a fresh process,