state-hub/api/routers
tegwick 9dd71af8f9 feat(state-hub): CUST-WP-0040 — NATS lifecycle event publishing for activity-core
Makes the state hub an event publisher so activity-core can drive
maintenance automation declaratively via ActivityDefinitions, rather
than the hub creating tasks itself.

- api/events/: lazy JetStream publisher + EventEnvelope mirroring
  activity-core's contract; no-op when NATS_URL unset, fire-and-forget
  with logged failures so publishing never breaks an API request.
- Wired publishers on the five v1.0 lifecycle events:
    org.statehub.repo.registered        (POST /repos/)
    org.statehub.workstream.completed   (PATCH /workstreams/* on transition)
    org.statehub.decision.resolved      (POST /decisions/*/resolve)
    org.statehub.domain.goal.activated  (POST /domain-goals/*/activate)
    org.statehub.task.stale             (scripts/cleanup_stale_tasks.py)
- docs/nats-event-subjects.md: subject naming convention + catalog.
- docs/cron-migration.md: design stub for replacing custodian-sync
  systemd timer and cleanup-stale cron with ActivityDefinitions
  (depends on activity-core WP-0003).
- docs/activity-core-delegation.md: protocol, invariants, cutover plan.
- SCOPE.md: declares activity-core as downstream event consumer and
  restates that the state hub stays a read model, not a task factory.

Workplan: workplans/CUST-WP-0040-state-hub-nats-activity-core-integration.md
242 tests pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 05:49:29 +02:00
..
__init__.py Add state-hub v0.1 — local-first state service for the Custodian 2026-02-24 17:47:49 +01:00
capability_requests.py Task flow engine implementation 2026-05-02 00:21:14 +02:00
contributions.py Task flow engine implementation 2026-05-02 00:21:14 +02:00
decisions.py feat(state-hub): CUST-WP-0040 — NATS lifecycle event publishing for activity-core 2026-05-17 05:49:29 +02:00
domain_goals.py feat(state-hub): CUST-WP-0040 — NATS lifecycle event publishing for activity-core 2026-05-17 05:49:29 +02:00
domains.py perf(api): CUST-WP-0041 — DB indexes, TTL caches, noload on list endpoints 2026-05-15 11:12:17 +02:00
extension_points.py feat(gems): three-pass schema migration aligning state-hub with GEMS 2026-03-02 23:39:17 +01:00
flows.py Task flow engine implementation 2026-05-02 00:21:14 +02:00
interface_changes.py feat(state-hub): Interface Change Registry (CUST-WP-0033 T01-T06) 2026-04-26 15:29:08 +02:00
messages.py feat(CUST-WP-0015): implement agent inbox for inter-agent coordination 2026-03-16 02:55:45 +01:00
policy.py feat(tasks): add needs_human intervention flag (CUST-WP-0009) 2026-03-04 19:44:14 +01:00
progress.py feat(api): CUST-WP-0018 — API hardening & code quality 2026-03-18 02:17:04 +01:00
repo_goals.py feat(goals): add domain/repo goal tracking and update_workstream MCP tool 2026-03-09 00:15:29 +01:00
repos.py feat(state-hub): CUST-WP-0040 — NATS lifecycle event publishing for activity-core 2026-05-17 05:49:29 +02:00
sbom.py fix(api): normalize trailing slashes — no slash on param routes 2026-04-26 15:13:01 +02:00
state.py perf(api): CUST-WP-0041 — DB indexes, TTL caches, noload on list endpoints 2026-05-15 11:12:17 +02:00
tasks.py feat(token-tracking): repo aggregation via graph walk (task→workstream→repo) 2026-03-29 19:05:23 +02:00
technical_debt.py fix(api): normalize trailing slashes — no slash on param routes 2026-04-26 15:13:01 +02:00
token_events.py feat(token-events): auto-capture real token counts via PostToolUse hook 2026-04-01 22:38:45 +02:00
topics.py perf(api): CUST-WP-0041 — DB indexes, TTL caches, noload on list endpoints 2026-05-15 11:12:17 +02:00
tpsc.py feat(doi): Repository DoI automated gate and dashboard integration (CUST-WP-0024) 2026-03-20 01:08:18 +01:00
workstream_dependencies.py Improved workplan dependency management facilities 2026-05-04 11:45:24 +02:00
workstreams.py feat(state-hub): CUST-WP-0040 — NATS lifecycle event publishing for activity-core 2026-05-17 05:49:29 +02:00