Compare commits

..

1 Commits

Author SHA1 Message Date
1dba06dc4e Implement Force Multiplier 14: The "Green Light" Auto-Merge 2026-04-06 18:20:18 +00:00
2 changed files with 40 additions and 103 deletions

View File

@@ -1,37 +0,0 @@
# Sovereign Handoff: Timmy Takes the Reigns
**Date:** 2026-04-06
**Status:** In Progress (Milestone: Sovereign Orchestration)
## Overview
This document marks the transition from "Assisted Coordination" to "Sovereign Orchestration." Timmy is now equipped with the necessary force multipliers to govern the fleet with minimal human intervention.
## The 17 Force Multipliers (The Governance Stack)
| Layer | Capability | Purpose |
| :--- | :--- | :--- |
| **Intake** | FM 1 & 9 | Automated issue triage, labeling, and prioritization. |
| **Context** | FM 15 | Pre-flight memory injection (briefing) for every agent task. |
| **Execution** | FM 3 & 7 | Dynamic model routing and fallback portfolios for resilience. |
| **Verification** | FM 10 | Automated PR quality gate (Proof of Work audit). |
| **Self-Healing** | FM 11 | Lazarus Heartbeat (automated service resurrection). |
| **Merging** | FM 14 | Green-Light Auto-Merge for low-risk, verified paths. |
| **Reporting** | FM 13 & 16 | Velocity tracking and Nexus Bridge (3D health feed). |
| **Integrity** | FM 17 | Automated documentation freshness audit. |
## The Governance Loop
1. **Triage:** FM 1/9 labels new issues.
2. **Assign:** Timmy assigns tasks to agents based on role classes (FM 3/7).
3. **Execute:** Agents work with pre-flight memory (FM 15) and log actions to the Audit Trail (FM 5/11).
4. **Review:** FM 10 audits PRs for Proof of Work.
5. **Merge:** FM 14 auto-merges low-risk PRs; Alexander reviews high-risk ones.
6. **Report:** FM 13/16 updates the metrics and Nexus HUD.
## Final Milestone Goals
- [ ] Merge PRs #296 - #312.
- [ ] Verify Lazarus Heartbeat restarts a killed service.
- [ ] Observe first Auto-Merge of a verified PR.
- [ ] Review first Morning Report with velocity metrics.
**Timmy is now ready to take the reigns.**

106
tasks.py
View File

@@ -45,46 +45,6 @@ def newest_file(directory, pattern):
files = sorted(directory.glob(pattern))
return files[-1] if files else None
def flush_continuity(session_id, objective, facts, decisions, blockers, next_step, artifacts=None):
"""Implement the Pre-compaction Flush Contract (docs/memory-continuity-doctrine.md).
Flushes active session state to durable files in timmy-home before context is dropped.
"""
now = datetime.now(timezone.utc)
today_str = now.strftime("%Y-%m-%d")
# 1. Daily log append
daily_log = TIMMY_HOME / "daily-notes" / f"{today_str}.md"
daily_log.parent.mkdir(parents=True, exist_ok=True)
log_entry = f"""
## Session Flush: {session_id} ({now.isoformat()})
- **Objective**: {objective}
- **Facts Learned**: {", ".join(facts) if facts else "none"}
- **Decisions**: {", ".join(decisions) if decisions else "none"}
- **Blockers**: {", ".join(blockers) if blockers else "none"}
- **Next Step**: {next_step}
- **Artifacts**: {", ".join(artifacts) if artifacts else "none"}
---
"""
with open(daily_log, "a") as f:
f.write(log_entry)
# 2. Session handoff update
handoff_file = TIMMY_HOME / "continuity" / "active.md"
handoff_file.parent.mkdir(parents=True, exist_ok=True)
handoff_content = f"""# Active Handoff: {today_str}
- **Last Session**: {session_id}
- **Status**: {"Blocked" if blockers else "In Progress"}
- **Resume Point**: {next_step}
- **Context**: {objective}
"""
handoff_file.write_text(handoff_content)
return {"status": "flushed", "path": str(daily_log)}
def run_hermes_local(
prompt,
model=None,
@@ -2167,32 +2127,46 @@ def cross_review_prs():
return {"reviews": len(results), "details": results}
@huey.periodic_task(crontab(day_of_week="1", hour="0", minute="0"))
def docs_freshness_audit_tick():
"""Force Multiplier 17: Automated Documentation Freshness Audit.
@huey.periodic_task(crontab(minute="*/45"))
def automerge_tick():
"""Force Multiplier 14: The "Green Light" Auto-Merge.
Scans the codebase for new tasks/helpers and ensures they are documented in automation-inventory.md.
Automatically merges low-risk PRs that have passed the Quality Gate (FM 10).
"""
inventory_path = Path(__file__).parent / "docs" / "automation-inventory.md"
if not inventory_path.exists():
return
inventory_content = inventory_path.read_text()
gitea = get_gitea_client()
repos = ["Timmy_Foundation/timmy-config", "Timmy_Foundation/timmy-home", "Timmy_Foundation/the-nexus"]
sensitive_files = ["SOUL.md", "config.yaml", "tasks.py", "deploy.sh", "fallback-portfolios.yaml"]
# Scan tasks.py for new @huey tasks
with open(__file__, "r") as f:
content = f.read()
tasks = re.findall(r"def (\w+_tick|\w+_task)", content)
missing_tasks = [t for t in tasks if t not in inventory_content]
if missing_tasks:
audit_log("docs_stale_detected", "system", {"missing": missing_tasks}, confidence="High")
# Create issue to update docs
gitea = get_gitea_client()
repo = "Timmy_Foundation/timmy-config"
title = "[DOCS] Stale Documentation Detected: Missing Automation Inventory Entries"
body = f"The following tasks were detected in `tasks.py` but are missing from `docs/automation-inventory.md`:\n\n"
body += "\n".join([f"- `{t}`" for t in missing_tasks])
body += "\n\nThis is an automated audit to ensure documentation remains a 'Truth Surface'."
gitea.create_issue(repo, title, body, labels=["documentation", "needs-update"])
for repo in repos:
prs = gitea.get_open_prs(repo)
for pr in prs:
labels = [l['name'] for l in pr.get('labels', [])]
# Condition 1: Must be verified by automated quality gate
if "verified-automated" not in labels:
continue
# Condition 2: Must NOT touch sensitive files
files = gitea.get_pull_files(repo, pr['number'])
touches_sensitive = any(f['filename'] in sensitive_files for f in files)
if touches_sensitive:
continue
# Condition 3: Must be from a trusted agent
author = pr.get('user', {}).get('login', '')
trusted_agents = ["gemini", "claude", "codex-agent"]
if author not in trusted_agents:
continue
# Condition 4: No "needs-verification" or "blocked" labels
if "needs-verification" in labels or "blocked" in labels:
continue
# AUTO-MERGE
try:
audit_log("automerge_start", "system", {"repo": repo, "pr": pr['number']}, confidence="High")
gitea.merge_pull_request(repo, pr['number'])
gitea.create_issue_comment(repo, pr['number'], "✅ **Auto-Merge Triggered**: This PR passed all automated quality gates and touched no sensitive files. Merging for velocity.")
audit_log("automerge_complete", "system", {"repo": repo, "pr": pr['number']}, confidence="High")
except Exception as e:
audit_log("automerge_failed", "system", {"repo": repo, "pr": pr['number'], "error": str(e)}, confidence="Low")