fix: tech-debt: sweep cron-isms from code comments, helpers, lib, and public site copy (#548)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/pr/smoke-init Pipeline was successful

- Rename acquire_cron_lock → acquire_run_lock in lib/formula-session.sh
  and all five *-run.sh call sites
- Update all *-run.sh file headers: "Cron wrapper" → "Polling-loop wrapper"
- Rewrite docs/updating-factory.md: replace crontab check with pgrep,
  replace "Crontab empty after restart" section with polling-loop equivalent
- Update docs/EVAL-MCP-SERVER.md to reflect polling-loop reality
- Update lib/guard.sh, lib/AGENTS.md, lib/ci-setup.sh comments
- Update formulas/*.toml comments (cron → polling loop)
- Update dev/dev-poll.sh usage comment
- Update tests/smoke-init.sh to handle compose vs bare-metal scheduling
- Update .woodpecker/agent-smoke.sh comments
- Update site HTML: architecture.html, quickstart.html, index.html
- Clarify _install_cron_impl is bare-metal only (compose uses polling loop)
- Keep site/collect-engagement.sh and site/collect-metrics.sh cron refs
  (genuinely cron-driven on the website host, separate from factory loop)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude 2026-04-10 08:54:11 +00:00
parent da4d9077dd
commit f0c3c773ff
24 changed files with 115 additions and 132 deletions

View file

@ -1,11 +1,11 @@
#!/usr/bin/env bash
# formula-session.sh — Shared helpers for formula-driven cron agents
# formula-session.sh — Shared helpers for formula-driven polling-loop agents
#
# Provides reusable utility functions for the common cron-wrapper pattern
# Provides reusable utility functions for the common polling-loop wrapper pattern
# used by planner-run.sh, predictor-run.sh, gardener-run.sh, and supervisor-run.sh.
#
# Functions:
# acquire_cron_lock LOCK_FILE — PID lock with stale cleanup
# acquire_run_lock LOCK_FILE — PID lock with stale cleanup
# load_formula FORMULA_FILE — sets FORMULA_CONTENT
# build_context_block FILE [FILE ...] — sets CONTEXT_BLOCK
# build_prompt_footer [EXTRA_API_LINES] — sets PROMPT_FOOTER (API ref + env)
@ -30,24 +30,24 @@
#
# Requires: lib/env.sh, lib/worktree.sh sourced first for shared helpers.
# ── Cron guards ──────────────────────────────────────────────────────────
# ── Run guards ───────────────────────────────────────────────────────────
# acquire_cron_lock LOCK_FILE
# acquire_run_lock LOCK_FILE
# Acquires a PID lock. Exits 0 if another instance is running.
# Sets an EXIT trap to clean up the lock file.
acquire_cron_lock() {
_CRON_LOCK_FILE="$1"
if [ -f "$_CRON_LOCK_FILE" ]; then
acquire_run_lock() {
_RUN_LOCK_FILE="$1"
if [ -f "$_RUN_LOCK_FILE" ]; then
local lock_pid
lock_pid=$(cat "$_CRON_LOCK_FILE" 2>/dev/null || true)
lock_pid=$(cat "$_RUN_LOCK_FILE" 2>/dev/null || true)
if [ -n "$lock_pid" ] && kill -0 "$lock_pid" 2>/dev/null; then
log "run: already running (PID $lock_pid)"
exit 0
fi
rm -f "$_CRON_LOCK_FILE"
rm -f "$_RUN_LOCK_FILE"
fi
echo $$ > "$_CRON_LOCK_FILE"
trap 'rm -f "$_CRON_LOCK_FILE"' EXIT
echo $$ > "$_RUN_LOCK_FILE"
trap 'rm -f "$_RUN_LOCK_FILE"' EXIT
}
# ── Agent identity resolution ────────────────────────────────────────────