feat: Фаза 7 шаги 7-10 — job-lifecycle FSM + project passport + parity-smoke

- chezmoi/dot_agents/job-lifecycle.yaml: FSM 13 состояний (Draft→Archived
  + Failed→Retry), invariants (retry-once, delivered/archived gates), ledger_fields.
- claude-starter/project.yaml: шаблон project passport (data_policy,
  capabilities, agents.preferred_pair, steward.max_proposals_per_week).
- claude-starter/routing-evals.example.jsonl: формат eval-записей (3 примера:
  code-edit/arch/legal с полями ts/job_id/task_class/primary/reviewer/outcome/correction).
- athena-router.md: добавлен start matrix 10 классов + eval feedback loop.
- smoke/parity-smoke.sh: synthetic parity-smoke — сравнение schema route-card
  Claude vs Codex + drift-check ~/.claude↔~/.codex если оба развёрнуты.
- smoke/agent-contract.sh: +5 проверок (job-lifecycle/project.yaml/routing-evals/
  start-matrix/parity-smoke).
- smoke/smoke.sh: секция [parity].
- shellcheck -S warning: 0 warnings · smoke: SMOKE OK.
This commit is contained in:
Зарубин Филипп
2026-06-23 22:16:08 +03:00
parent 4649579302
commit 09a6cbe0a4
7 changed files with 318 additions and 2 deletions
+46
View File
@@ -101,9 +101,55 @@ else
command -v node >/dev/null 2>&1 || echo " → node not found; skipping report+gate smoke"
fi
# 11. job-lifecycle.yaml exists and carries required FSM keys.
LIFECYCLE="$ROOT/chezmoi/dot_agents/job-lifecycle.yaml"
if [ ! -f "$LIFECYCLE" ]; then
bad "job-lifecycle.yaml missing"
else
for key in initial_state states terminal_states invariants; do
grep -q "^$key:" "$LIFECYCLE" || bad "job-lifecycle.yaml missing top-level key: $key"
done
REQUIRED_STATES="Draft Staging ProjectDetection RouteProposed Approved Queued Running NeedsInput ReviewReady Delivered Archived Failed Retry"
for s in $REQUIRED_STATES; do
grep -q "^ $s:" "$LIFECYCLE" || bad "job-lifecycle.yaml missing state: $s"
done
fi
# 12. project.yaml template exists in claude-starter with required fields.
PROJECT_YAML="$ROOT/claude-starter/project.yaml"
if [ ! -f "$PROJECT_YAML" ]; then
bad "claude-starter/project.yaml missing"
else
for field in data_policy capabilities agents steward sensitivity allow_cloud retention_days preferred_pair max_proposals_per_week; do
grep -q "$field" "$PROJECT_YAML" || bad "project.yaml missing field: $field"
done
fi
# 13. routing-evals.example.jsonl exists in claude-starter.
EVALS_EXAMPLE="$ROOT/claude-starter/routing-evals.example.jsonl"
[ -f "$EVALS_EXAMPLE" ] || bad "claude-starter/routing-evals.example.jsonl missing"
# 14. athena-router passport carries start matrix (10 classes).
ROUTER_PASSPORT="$ROOT/chezmoi/dot_agents/role-passports/athena-router.md"
MATRIX_CLASSES="code-edit debug arch docs legal obsidian deploy ui security steward"
if [ -f "$ROUTER_PASSPORT" ]; then
for cls in $MATRIX_CLASSES; do
grep -q "$cls" "$ROUTER_PASSPORT" || bad "athena-router.md start matrix missing class: $cls"
done
fi
# 15. parity-smoke.sh exists and passes.
PARITY="$ROOT/smoke/parity-smoke.sh"
if [ ! -f "$PARITY" ]; then
bad "smoke/parity-smoke.sh missing"
elif [ -x "$PARITY" ]; then
"$PARITY" "$ROOT" >/dev/null 2>&1 || bad "parity-smoke.sh failed"
fi
if [ "$fail" -ne 0 ]; then
echo "AGENT-CONTRACT FAIL" >&2
exit 1
fi
echo " ✓ 7 passports · graph integrity · learning-tail · session-review skill · report+gate"
echo " ✓ job-lifecycle FSM · project.yaml template · routing-evals format · start matrix · parity-smoke"
echo "agent-contract OK"
+112
View File
@@ -0,0 +1,112 @@
#!/usr/bin/env bash
# Phase 7 — Synthetic parity smoke.
# Verifies that a route card produced for Claude Code and one for Codex
# carry identical schema fields. Does NOT call any LLM — uses fixtures.
# Also drift-checks live ~/.claude vs ~/.codex if both are deployed.
# Usage: smoke/parity-smoke.sh [REPO_ROOT]
fail=0
bad() { echo " ✗ $1" >&2; fail=1; }
ok() { echo " ✓ $1"; }
echo "[parity-smoke] route-card schema + drift-check"
# ── 1. Fixture route cards ────────────────────────────────────────────────
# Both cards come from the same synthetic task (code-edit).
# The schema (field set) must be identical; only provider + primary differ.
TMPDIR_PS="$(mktemp -d /tmp/athena-parity-XXXXXX)"
trap 'rm -rf "$TMPDIR_PS"' EXIT
cat > "$TMPDIR_PS/claude-route.json" <<'EOF'
{
"job_id": "smoke-parity-001",
"task_class": "code-edit",
"provider": "claude",
"primary": "claude",
"reviewer": "codex",
"capabilities": ["code-edit"],
"risk": "low",
"confidence": "high",
"why": ["smoke fixture — claude engine"],
"alternatives": [],
"requires_approval": []
}
EOF
cat > "$TMPDIR_PS/codex-route.json" <<'EOF'
{
"job_id": "smoke-parity-001",
"task_class": "code-edit",
"provider": "codex",
"primary": "codex",
"reviewer": "claude",
"capabilities": ["code-edit"],
"risk": "low",
"confidence": "high",
"why": ["smoke fixture — codex engine"],
"alternatives": [],
"requires_approval": []
}
EOF
# ── 2. Schema field comparison ────────────────────────────────────────────
# Extract sorted field names from each card. Compare sets.
# Requires only grep/sed — no jq dependency.
fields_of() {
grep -oE '"[a-z_]+"[[:space:]]*:' "$1" | sed 's/[[:space:]]*://' | sort -u
}
CLAUDE_FIELDS="$(fields_of "$TMPDIR_PS/claude-route.json")"
CODEX_FIELDS="$(fields_of "$TMPDIR_PS/codex-route.json")"
if [ "$CLAUDE_FIELDS" = "$CODEX_FIELDS" ]; then
ok "route-card schema: identical ($(echo "$CLAUDE_FIELDS" | wc -l | tr -d ' ') fields)"
else
ONLY_CLAUDE="$(comm -23 <(echo "$CLAUDE_FIELDS") <(echo "$CODEX_FIELDS"))"
ONLY_CODEX="$(comm -13 <(echo "$CLAUDE_FIELDS") <(echo "$CODEX_FIELDS"))"
bad "route-card schema: divergent"
[ -n "$ONLY_CLAUDE" ] && echo " claude-only fields: $ONLY_CLAUDE" >&2
[ -n "$ONLY_CODEX" ] && echo " codex-only fields: $ONLY_CODEX" >&2
fi
# ── 3. Required fields present in both cards ──────────────────────────────
REQUIRED="job_id task_class provider primary reviewer risk confidence why"
for field in $REQUIRED; do
for card in "$TMPDIR_PS/claude-route.json" "$TMPDIR_PS/codex-route.json"; do
grep -q "\"$field\"" "$card" \
|| bad "route-card missing required field '$field' in $(basename "$card")"
done
done
ok "required fields present in both route cards"
# ── 4. Drift-check live ~/.claude vs ~/.codex (skip if not deployed) ──────
CLAUDE_DIR="$HOME/.claude"
CODEX_DIR="$HOME/.codex"
if [ -d "$CLAUDE_DIR" ] && [ -d "$CODEX_DIR" ]; then
echo " [drift] both engines deployed — checking registry parity"
# AGENTS.md must exist in both (registry entrypoint).
[ -f "$CLAUDE_DIR/AGENTS.md" ] \
|| bad "drift: ~/.claude/AGENTS.md missing"
[ -f "$CODEX_DIR/AGENTS.md" ] \
|| bad "drift: ~/.codex/AGENTS.md missing"
# Both must reference the shared skills/workflows registry.
grep -q 'SHARED-SKILLS-WORKFLOWS' "$CLAUDE_DIR/AGENTS.md" \
|| bad "drift: ~/.claude/AGENTS.md does not reference SHARED-SKILLS-WORKFLOWS"
grep -q 'SHARED-SKILLS-WORKFLOWS' "$CODEX_DIR/AGENTS.md" \
|| bad "drift: ~/.codex/AGENTS.md does not reference SHARED-SKILLS-WORKFLOWS"
ok "drift-check: AGENTS.md present and references shared registry in both engines"
else
echo " · engines not both deployed — drift-check skipped"
fi
# ── Result ────────────────────────────────────────────────────────────────
if [ "$fail" -ne 0 ]; then
echo "PARITY-SMOKE FAIL" >&2
exit 1
fi
echo " ✓ parity-smoke: identical schema · required fields · drift-check"
echo "parity-smoke OK"
+7 -2
View File
@@ -190,10 +190,15 @@ if [ -x "$HERE/smoke/git-leak-guard.test.sh" ]; then
chk "git-leak-guard 5 кейсов" "'$HERE/smoke/git-leak-guard.test.sh' >/dev/null 2>&1"
else echo " · git-leak-guard.test.sh нет (skip)"; fi
echo "[agent-contract] Фаза 7: паспорта + handoff-граф integrity"
echo "[agent-contract] Фаза 7: паспорта + handoff-граф integrity + FSM + project-template + parity"
if [ -x "$HERE/smoke/agent-contract.sh" ]; then
chk "agent-contract (7 паспортов + граф)" "'$HERE/smoke/agent-contract.sh' '$HERE' >/dev/null 2>&1"
chk "agent-contract (полный)" "'$HERE/smoke/agent-contract.sh' '$HERE' >/dev/null 2>&1"
else echo " · agent-contract.sh нет (skip)"; fi
echo "[parity] синтетический route-card + drift-check"
if [ -x "$HERE/smoke/parity-smoke.sh" ]; then
chk "parity-smoke (schema + required fields)" "'$HERE/smoke/parity-smoke.sh' '$HERE' >/dev/null 2>&1"
else echo " · parity-smoke.sh нет (skip)"; fi
[ "$fail" = 0 ] && echo "SMOKE OK" || echo "SMOKE FAIL"
exit "$fail"