Compare commits
1 Commits
gemini/pas
...
gemini/pas
| Author | SHA1 | Date | |
|---|---|---|---|
| 3468000025 |
76
tasks.py
76
tasks.py
@@ -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,
|
||||
@@ -2166,3 +2126,39 @@ def cross_review_prs():
|
||||
continue
|
||||
|
||||
return {"reviews": len(results), "details": results}
|
||||
|
||||
@huey.periodic_task(crontab(hour="0", minute="0"))
|
||||
def metrics_tick():
|
||||
"""Force Multiplier 13: Fleet Cost & Velocity Tracker.
|
||||
|
||||
Calculates daily velocity (issues closed, PRs merged) and logs it to a metrics file.
|
||||
"""
|
||||
gitea = get_gitea_client()
|
||||
repos = ["Timmy_Foundation/timmy-config", "Timmy_Foundation/timmy-home", "Timmy_Foundation/the-nexus"]
|
||||
|
||||
daily_stats = {
|
||||
"timestamp": datetime.now(timezone.utc).isoformat(),
|
||||
"issues_closed": 0,
|
||||
"prs_merged": 0,
|
||||
"repo_stats": {}
|
||||
}
|
||||
|
||||
for repo in repos:
|
||||
# Get issues closed in last 24h
|
||||
closed_issues = gitea.get_closed_issues(repo, since="24h")
|
||||
merged_prs = gitea.get_merged_prs(repo, since="24h")
|
||||
|
||||
daily_stats["issues_closed"] += len(closed_issues)
|
||||
daily_stats["prs_merged"] += len(merged_prs)
|
||||
daily_stats["repo_stats"][repo] = {
|
||||
"issues": len(closed_issues),
|
||||
"prs": len(merged_prs)
|
||||
}
|
||||
|
||||
metrics_file = TIMMY_HOME / "logs" / "metrics.jsonl"
|
||||
metrics_file.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with open(metrics_file, "a") as f:
|
||||
f.write(json.dumps(daily_stats) + "\n")
|
||||
|
||||
audit_log("metrics_logged", "system", daily_stats, confidence="High")
|
||||
|
||||
Reference in New Issue
Block a user