activity-core/Makefile

133 lines
6.1 KiB
Makefile
Raw Normal View History

-include .env
export
# Bare `make` lists targets (ACTIVITY-WP-0028 follow-up).
.DEFAULT_GOAL := help
.PHONY: help sync-event-types sync-activity-definitions sync-schedules test migrate sync-all \
2026-07-02 02:15:39 +02:00
automation-status automation-status-json automation-list automation-list-json \
activity-review install-cli \
prod-automation-status refresh-live-images \
dev-up dev-down railiance-up railiance-down \
start-worker start-api start-event-router \
openbao-eso-token-apply agents-list agents-update agents-validate
# ── Help ──────────────────────────────────────────────────────────────────────
help: ## Show available make targets
@echo "activity-core — available targets"
@echo ""
@grep -Eh '^[a-zA-Z0-9_-]+:.*?##' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-28s\033[0m %s\n", $$1, $$2}' | \
sort
@echo ""
@echo "CLI: make install-cli # install 'activity' into userspace (uv tool)"
@echo " make activity-review ARGS='status --cwd ~/freedom-intelligence'"
@echo " activity service list # named activity-core backends"
@echo " activity runs -s railiance --since today"
# ── Sync / test ───────────────────────────────────────────────────────────────
sync-activity-definitions: ## Sync ActivityDefinition files into DB
feat(WP-0003b): parser, workflow wiring, triggers, webhooks T44: ActivityDefinition markdown file parser (definition_parser.py) - Scans activity-definitions/*.md and ACTIVITY_DEFINITION_DIRS paths - Parses YAML frontmatter + fenced rule/instruction blocks - Raises ParseError on any malformed file — never silently skips T45: ActivityDefinition sync command - Migration 0006: adds rules_json/instructions_json JSONB columns - sync_activity_definitions.py + make sync-activity-definitions - Called at worker startup before schedule sync T46: Rule/instruction pipeline wired into RunActivityWorkflow - New evaluate_rules and emit_tasks Temporal activities - Workflow passes event_envelope_json to enable rule evaluation - EventRouter now passes full envelope JSON as 4th workflow arg - IssueSink.emit() writes task_spawn_log rows per task T47: ScheduledTriggerConfig model (one-off future datetime trigger) T48: One-off Temporal Schedule support - Fixed timezone_name → time_zone_name (was causing all schedule tests to fail) - Added ScheduleCalendarSpec-based one-off schedule with remaining_actions=1 - cancel_scheduled() for admin cancellation - Fixed backfill() call to use *args unpacking (not list wrapper) - Fixed ScheduleAlreadyRunningError catch in upsert_schedule - sync_schedules now handles ScheduledTriggerConfig definitions T49: Webhook receiver - POST /webhooks/gitea — HMAC-SHA256 via X-Gitea-Signature-256 - POST /webhooks/github — HMAC-SHA256 via X-Hub-Signature-256 - Normalisers: repo.created, push, issue.closed → EventEnvelope - Publishes to NATS activity.{type} subject after registry validation - Mounted in api.py at /webhooks prefix T50: Gitea event type definitions - gitea.repo.created.md, gitea.push.md, gitea.issue.closed.md - Each includes normaliser field mapping in Consumer Notes Tests: 18 passed, 1 skipped (integration). Fixed embedded Temporal server visibility latency in test_upsert_schedule_creates_schedule. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 23:02:33 +02:00
uv run python -m activity_core.sync_activity_definitions
sync-schedules: ## Reconcile Temporal schedules from activity_definitions DB
uv run python -m activity_core.sync_schedules
sync-event-types: ## Sync event type YAML files into DB
uv run python scripts/sync_event_types.py
test: ## Run test suite
uv run pytest tests/ -v
migrate: ## Apply all pending Alembic migrations
uv run alembic upgrade head
sync-all: sync-event-types sync-activity-definitions ## Sync event types and activity definitions
# ── Automation status (org-wide) ──────────────────────────────────────────────
2026-07-01 20:12:04 +02:00
SINCE ?= today
FORMAT ?= human
2026-07-02 02:15:39 +02:00
ENABLED ?= all
TRIGGER ?=
ACTIVITY_ID ?=
ACTIVITY_NAME ?=
ARGS ?=
2026-07-01 20:12:04 +02:00
automation-status: ## Report recent automation status from repo-owned evidence
uv run python scripts/automation_status.py --since "$(SINCE)" $(if $(UNTIL),--until "$(UNTIL)",) --format "$(FORMAT)"
automation-status-json: ## Report recent automation status as JSON
$(MAKE) automation-status FORMAT=json
prod-automation-status: ## Prod run counts via SSH railiance01 (ACTIVITY-WP-0021)
./scripts/prod_automation_status.sh $(SINCE)
refresh-live-images: ## Refresh multi-cluster Forgejo live-images protection list
./scripts/refresh_live_images.sh
2026-07-02 02:15:39 +02:00
automation-list: ## List configured scheduled automations from repo-owned definitions
@uv run python scripts/automation_inventory.py --format "$(FORMAT)" --enabled "$(ENABLED)" $(if $(TRIGGER),--trigger-type "$(TRIGGER)",) $(if $(ACTIVITY_ID),--activity-id "$(ACTIVITY_ID)",) $(if $(ACTIVITY_NAME),--activity-name "$(ACTIVITY_NAME)",)
automation-list-json: ## List configured scheduled automations as JSON
@$(MAKE) --no-print-directory automation-list FORMAT=json
# ── activity CLI (repo review + multi-service) ────────────────────────────────
install-cli: ## Install 'activity' CLI into userspace (uv tool install -e .)
@command -v uv >/dev/null || { echo "uv not found — install from https://docs.astral.sh/uv/"; exit 1; }
uv tool install --force -e .
@echo ""
@echo "Installed. Ensure \$$HOME/.local/bin is on PATH, then:"
@echo " activity --help"
@echo " activity service add railiance --url https://activity.coulomb.social --make-default"
@echo " activity service list"
@command -v activity >/dev/null && activity --help | head -3 || true
activity-review: ## Run activity CLI (pass ARGS='…'). Example: ARGS='--cwd ~/freedom-intelligence status'
uv run activity $(ARGS)
# ── Infrastructure ────────────────────────────────────────────────────────────
dev-up: ## Start full dev stack (Temporal + PG + ES + NATS)
docker compose -f docker-compose.dev.yml up -d
dev-down: ## Stop and remove dev stack containers
docker compose -f docker-compose.dev.yml down
railiance-up: ## Build image and start full railiance stack (no Elasticsearch)
docker compose -f docker-compose.railiance.yml up -d --build
railiance-down: ## Stop and remove railiance stack containers
docker compose -f docker-compose.railiance.yml down
openbao-eso-token-apply: ## Mint coulombcore OpenBao ESO token for railiance01 activity-core
OPENBAO_TOKEN_FILE="$(HOME)/.local/openbao/platform-admin.token" bash scripts/openbao-eso-token-apply.sh
# ── Local dev processes ───────────────────────────────────────────────────────
start-worker: ## Start Temporal worker (reads env from .env if present)
uv run python -m activity_core.worker
start-api: ## Start FastAPI server on :8010 with hot reload
uv run uvicorn activity_core.api:app --host 0.0.0.0 --port 8010 --reload
start-event-router: ## Start NATS event router
uv run python -m activity_core.event_router
# ── Agents ────────────────────────────────────────────────────────────────────
2026-06-18 15:14:20 +02:00
agents-list: ## List installed kaizen agents
2026-06-18 15:14:20 +02:00
@echo "Installed agents:"
@ls agents/ 2>/dev/null | grep agent- | sed 's/agent-//g' | sed 's/.md//g' \
|| echo "No agents installed"
agents-update: ## Update agents via kaizen-agentic
2026-06-18 15:14:20 +02:00
@echo "Updating agents..."
@kaizen-agent update
2026-06-18 15:14:20 +02:00
agents-validate: ## Validate agents via kaizen-agentic
2026-06-18 15:14:20 +02:00
@echo "Validating agents..."
@kaizen-agentic validate agents/