Align FI recurrence with activity-core + rein-aharness (drop workstation cron).

Document the three-layer model, add railiance-rhythm executor install, and
point playbooks at rein-aharness fi-research-brief instead of local crontab.
This commit is contained in:
tegwick 2026-08-03 17:53:07 +02:00
parent 70cbfe0c6c
commit 46cfcd7a51
10 changed files with 248 additions and 100 deletions

View file

@ -1,14 +1,13 @@
#!/usr/bin/env bash
# Workstation consumer for FI daily research brief spawns.
# BREAK-GLASS only — not the primary recurrence path.
#
# activity-core emits activity_task_spawn (state-hub sink) with
# target_repo=freedom-intelligence. This script:
# 1) checks fi_brief_status due (or open spawn)
# 2) reminds operator / runs playbook path
# 3) does NOT invent brief content — open a session with the playbook
# Primary design:
# activity-core (schedule + fi_brief_status + spawn)
# → rein-aharness fi-research-brief on railiance01
# See docs/recurrence-ops.md and activity-core/docs/recurring-automations-playbook.md
#
# Schedule suggestion (Europe/Berlin, after 07:30 spawn):
# 40 7 * * 1-5 /home/worsch/freedom-intelligence/scripts/consume-fi-brief-spawn.sh
# This script only prints due status for operators debugging from a workstation.
# Do NOT install it as the main crontab for FI briefs.
#
# Env:
# STATE_HUB_URL default http://127.0.0.1:8000

View file

@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Install host-side FI research brief timer on railiance01 (user systemd).
# Run ON railiance01 from a freedom-intelligence checkout:
# ./scripts/railiance-rhythm/install-on-railiance.sh
#
# Prerequisites:
# - activity-core definition fi-daily-research-brief enabled (cluster)
# - rein-aharness installed with fi-research-brief command
# - freedom-intelligence clone with write access for brief commits
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
UNIT_DIR="${HOME}/.config/systemd/user"
mkdir -p "${UNIT_DIR}"
chmod +x "${ROOT}/scripts/railiance-rhythm/"*.sh
cp -f "${ROOT}/scripts/railiance-rhythm/systemd/fi-research-brief-daily.service" "${UNIT_DIR}/"
cp -f "${ROOT}/scripts/railiance-rhythm/systemd/fi-research-brief-daily.timer" "${UNIT_DIR}/"
systemctl --user daemon-reload
systemctl --user enable --now fi-research-brief-daily.timer
systemctl --user list-timers --all | grep fi-research || true
echo "Installed. Logs: ~/.cache/freedom-intelligence/rhythm/"
echo "Cadence truth: activity-core (07:30). Executor: this timer (07:35) → rein-aharness."

View file

@ -0,0 +1,86 @@
#!/usr/bin/env bash
# Shared env for Railiance host-side Freedom Intelligence research brief.
#
# activity-core owns cadence (Temporal + fi_brief_status + activity_task_spawn).
# This host timer is the *executor* path (same pattern as binky-control):
# rein-aharness consumes the work and posts fi_daily_brief.
#
# ISSUE_SINK_TYPE=state-hub writes progress only (not claimable issues), so a
# host timer remains the interim executor until rein-aharness poll/claim of
# activity_task_spawn is fully wired. Cadence truth still lives in activity-core.
set -euo pipefail
: "${HOME:=/home/tegwick}"
# Prefer rein-aharness venv (current name); fall back to legacy agent-harness path.
if [[ -x "${HOME}/.local/rein-aharness/venv/bin/rein-aharness" ]]; then
export PATH="${HOME}/.local/rein-aharness/venv/bin:${HOME}/.local/bin:${PATH}"
# shellcheck disable=SC1091
[[ -f "${HOME}/.local/rein-aharness/env" ]] && source "${HOME}/.local/rein-aharness/env"
elif [[ -x "${HOME}/.local/agent-harness/venv/bin/rein-aharness" ]]; then
export PATH="${HOME}/.local/agent-harness/venv/bin:${HOME}/.local/bin:${PATH}"
# shellcheck disable=SC1091
[[ -f "${HOME}/.local/agent-harness/env" ]] && source "${HOME}/.local/agent-harness/env"
else
export PATH="${HOME}/.local/bin:${PATH}"
fi
export STATE_HUB_URL="${STATE_HUB_URL:-http://127.0.0.1:18000}"
export PYTHONPATH="${HOME}/rein-aharness:${HOME}/llm-connect${PYTHONPATH:+:$PYTHONPATH}"
export FI_REPO="${FI_REPO:-${HOME}/freedom-intelligence}"
export LOG_DIR="${LOG_DIR:-${HOME}/.cache/freedom-intelligence/rhythm}"
mkdir -p "${LOG_DIR}"
log() { echo "$(date -Iseconds) $*" | tee -a "${LOG_DIR}/railiance-rhythm.log"; }
require_repo() {
if [[ ! -d "${FI_REPO}/.git" ]]; then
log "ERROR: freedom-intelligence missing at ${FI_REPO}; clone with deploy key"
exit 1
fi
git -C "${FI_REPO}" fetch --quiet origin main || true
git -C "${FI_REPO}" checkout --quiet main
git -C "${FI_REPO}" pull --ff-only --quiet origin main || log "WARN: pull failed (continuing on local)"
}
require_llm_connect() {
if [[ -z "${LLM_CONNECT_URL:-}" ]]; then
local candidates=()
candidates+=("http://127.0.0.1:18080")
if command -v kubectl >/dev/null 2>&1; then
local cip
cip="$(kubectl -n activity-core get svc llm-connect \
-o jsonpath='{.spec.clusterIP}' 2>/dev/null || true)"
if [[ -n "${cip}" ]]; then
candidates+=("http://${cip}:8080")
fi
fi
candidates+=("http://llm-connect.activity-core.svc.cluster.local:8080")
local u
for u in "${candidates[@]}"; do
if curl -sf -m 2 "${u}/health" >/dev/null 2>&1; then
export LLM_CONNECT_URL="${u}"
break
fi
done
if [[ -z "${LLM_CONNECT_URL:-}" ]]; then
export LLM_CONNECT_URL="${candidates[-1]}"
log "WARN: no llm-connect health probe succeeded; using ${LLM_CONNECT_URL}"
fi
fi
log "LLM_CONNECT_URL=${LLM_CONNECT_URL}"
}
ensure_git_identity() {
git -C "${FI_REPO}" config user.email >/dev/null 2>&1 \
|| git -C "${FI_REPO}" config user.email "rein-aharness@railiance.local"
git -C "${FI_REPO}" config user.name >/dev/null 2>&1 \
|| git -C "${FI_REPO}" config user.name "rein-aharness"
}
require_harness() {
if ! command -v rein-aharness >/dev/null 2>&1; then
log "ERROR: rein-aharness not on PATH. Install rein-aharness venv on this host."
exit 2
fi
}

View file

@ -0,0 +1,17 @@
#!/usr/bin/env bash
# Weekday 07:35 Europe/Berlin — FI research brief executor (rein-aharness).
#
# Cadence authority: activity-core definition fi-daily-research-brief
# (Temporal 07:30 Europe/Berlin, fi_brief_status due check, activity_task_spawn).
# This timer is the host executor, 5 minutes after the schedule fire window.
set -euo pipefail
# shellcheck disable=SC1091
source "$(dirname "$0")/run-common.sh"
require_repo
ensure_git_identity
require_harness
require_llm_connect
log "START fi-research-brief (rein-aharness / llm-connect)"
rein-aharness fi-research-brief --target-repo "${FI_REPO}" \
2>&1 | tee -a "${LOG_DIR}/daily.log"
log "END fi-research-brief rc=${PIPESTATUS[0]}"

View file

@ -0,0 +1,10 @@
[Unit]
Description=Freedom Intelligence daily research brief (rein-aharness on Railiance)
After=network-online.target
[Service]
Type=oneshot
Environment=HOME=%h
WorkingDirectory=%h/freedom-intelligence
ExecStart=%h/freedom-intelligence/scripts/railiance-rhythm/run-daily.sh
Nice=10

View file

@ -0,0 +1,10 @@
[Unit]
Description=Timer: FI research brief weekdays 07:35 Europe/Berlin
[Timer]
OnCalendar=Mon..Fri *-*-* 07:35:00 Europe/Berlin
Persistent=true
Unit=fi-research-brief-daily.service
[Install]
WantedBy=timers.target