rein-aharness/rein_aharness/persona.py
tegwick f6930ad115 Rename package, CLI, and deploy artifacts to rein-aharness (HARNESS-WP-0002-T02)
agent_harness -> rein_aharness (package + all imports), CLI command
agent-harness -> rein-aharness, Docker image tag, k8s namespace/labels/
names, Makefile targets, deploy script env var/paths. In-repo identity
strings (hub event source, metrics harness field, default assignee,
argparse prog name, commit author identity) updated to match.

Historical documents left untouched on purpose: docs/adr/ADR-001-agent-harness-architecture.md,
docs/architecture.md (dated v0.1 snapshot), workplans/HARNESS-WP-0001
(completed under the old name), and the SSH host alias
"forgejo-agent-harness" (external ~/.ssh/config entry, not owned here).

Verified: 47/47 tests pass, CLI runs correctly from a fresh venv,
`make image` builds and the resulting container runs correctly.

deploy/README.md gained an explicit rename cutover checklist for what
this session cannot safely do unattended -- moving the host-side
secrets dir and checkout on railiance01, and not deleting the old k8s
namespace until the new one is confirmed working. The actual live
cutover (running that checklist against the real Railiance deployment)
is not attempted here -- real production surgery on binky-control's
live automation, needs the operator present.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-26 14:22:18 +02:00

39 lines
1.3 KiB
Python

"""Persona orientation via kaizen-agentic (ADR-005 prepare step).
The ADR-005 contract for a scheduled run is `kaizen-agentic schedule
prepare <agent>` executed against the target repo: it bundles the agent
prompt, project memory, metrics summary, and repo pointers from local
`.kaizen/` state — offline-safe, no hub required. The worker treats the
bundle as orientation text prepended to the task prompt.
Falls back to an empty bundle when the CLI or the repo's schedule state is
absent, so a task can still run persona-less (logged in run metadata).
"""
from __future__ import annotations
import subprocess
from pathlib import Path
def load_persona_bundle(agent: str, target_repo: Path, timeout: int = 60) -> tuple[str, str]:
"""Return (bundle_text, source) where source is 'prepare' or 'none'."""
try:
result = subprocess.run(
[
"kaizen-agentic",
"schedule",
"prepare",
agent,
"--target",
str(target_repo),
],
capture_output=True,
text=True,
timeout=timeout,
)
except (FileNotFoundError, subprocess.TimeoutExpired):
return "", "none"
if result.returncode != 0 or not result.stdout.strip():
return "", "none"
return result.stdout, "prepare"