Skip to content

feat: safety boundary, experiment logging, and evaluation funnel (Phase 1)#3

Open
physics91 wants to merge 12 commits into
kevinrgu:mainfrom
physics91:feat/safety-and-observability
Open

feat: safety boundary, experiment logging, and evaluation funnel (Phase 1)#3
physics91 wants to merge 12 commits into
kevinrgu:mainfrom
physics91:feat/safety-and-observability

Conversation

@physics91
Copy link
Copy Markdown

Summary

  • contracts.py: AgentWorkflow / EvaluatorContract Protocol 정의 — harness↔adapter 인터페이스 계약
  • adapter.py: FIXED ADAPTER BOUNDARY 이하 코드를 별도 모듈로 추출, lazy import로 순환 의존성 해결, 멀티 tool call 추적 (call_id dict)
  • Dockerfile + run_eval.sh: Docker --read-only + --network=none + tmpfs writable paths + seccomp
  • preflight.py: 규칙 기반 mutation 검증 (fixed file 수정 차단, forbidden import 패턴 4종)
  • experiment_log.py: experiments.jsonl ATIF sidecar index — trace_id/trajectory_uri로 Harbor ATIF trajectory 연결
  • tasks/smoke/: 5개 기본 태스크 (hello-world, fibonacci, csv-analysis, git-log, text-processing)

Motivation

6라운드 다관점 토론(Claude Code vs Codex)을 거쳐 도출된 AutoAgent 개선안 Phase 1 구현.
주석 기반 소프트 가드레일 → 물리적 격리(Docker read-only, network isolation) + preflight policy gate.

Test plan

  • 24 unit tests passing (python -m pytest tests/ -v)
  • Codex code review 2회 통과 (CRITICAL 0, WARNING 0)
  • Harbor e2e smoke test with Docker pipeline

physics91 added 12 commits April 4, 2026 10:39
AgentWorkflow / EvaluatorContract Protocol 정의로 editable harness와
fixed adapter 사이의 경계를 추상화함. AST 기반 테스트로 heavy runtime
dependency 없이 agent.py 호환성 검증.
Harbor 통합 코드(to_atif, AutoAgent)를 별도 adapter.py로 분리해
editable harness(agent.py)와 고정 어댑터 경계를 물리적으로 구분함.
agent.py 하단에서 re-export해 Harbor의 agent:AutoAgent 진입점 호환성 유지.
- adapter.py: lazy import to avoid circular dependency on standalone import
- adapter.py: track pending tool calls by call_id (dict) instead of single slot
- preflight.py: exact root-relative path matching to avoid false positives
- contracts.py: fix run_task return type to tuple[Any, int]
- tests: add test for nested __init__.py not being flagged as fixed file
- preflight: broaden forbidden patterns (from/import variants, __import__)
- run_eval.sh: add writable tmpfs for /task, /logs, /app/output
- tests: add cases for from importlib and __import__ bypass
ijlu referenced this pull request in ijlu/autoagent Apr 25, 2026
The position_health_log schema has settlement_result + settlement_pnl_cents
columns described as "filled post-settlement for learning" — but nothing
ever filled them. Rows stayed NULL forever, starving the bandit that trains
on which health-band decisions held winners vs losers.

record_settlements now runs a scoped UPDATE per settled ticker so every
prior per-cycle health snapshot carries the eventual outcome. NULL-guard on
the WHERE clause keeps this idempotent across multiple settlements.

Audit note: the other four Phase 1 step #3 learning sinks (calibration,
timing_patterns, edge_convergence, loss_postmortems) are already fully
populated from alpha_backtest via bot/learning/populate_from_alpha.py and
from the legacy trade.py writers — no change needed there. Step #4 (Platt
in get_independent_estimate) and step #6 (directional shadow evaluator with
KXBTC/KXETH/KXHIGHDEN blocks) were likewise already wired. position_health
was the one real gap.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant