feat: 리밸런싱 엔진 V1 + GAS 버그 수정 (2026-06-13)
주요 변경: - tools/build_rebalance_engine_v1.py: REBALANCE_ENGINE_V1 신규 * account_snapshot 직접 합산(_build_snap_position_map) → 소수주 분리 행 병합 * 레짐 소스 macro.REGIME_PRELIM 최우선 (GAS 와 동일) - src/gas_adapter_parts/gdf_06_rebalance.gs: runRebalanceSheet_() 신규 * Logger.log / getSpreadsheet_() 로 run_all 연동 수정 - src/gas_adapter_parts/gdc_01_fetch_fundamentals.gs * _mergePositionRecord_(): 소수주 중복 행 합산 신규 * parseInt → parseFloat (qty, availQty) - src/gas_adapter_parts/gdf_01_price_metrics.gs * 미보유 종목 SELL_READY → WATCH_EXIT_SIGNAL - spec/41_release_dag.yaml: build_rebalance_sheet 노드 추가 (step_count 63) - spec/51_formula_lifecycle_registry.yaml: REBALANCE_ENGINE_V1 등록 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,733 @@
|
||||
schema_version: quant_engine_refactor_todo.v1
|
||||
generated_at_kst: '2026-06-07T17:37:26.756697+09:00'
|
||||
source:
|
||||
zip_path: data_feed.zip
|
||||
zip_sha256: e12322eb72d2e8184f5f5e010a4c0014c584bc170970b4788b7b79562065d227
|
||||
primary_instruction_file: data_feed/AGENTS.md
|
||||
assumed_runtime_timezone: Asia/Seoul
|
||||
objective_profile:
|
||||
target_asset_krw: 500000000
|
||||
cadence: weekly; Sat/Sun rebalancing; 1/11/21 mid-month checkpoint
|
||||
executive_decision:
|
||||
recommended_methodology_name: 'QEDD: Quant Evidence-Driven Development'
|
||||
one_line: spec을 권위 원천으로 고정하고, Python canonical 엔진에서만 계산하며, GAS/LLM/renderer는 얇은
|
||||
어댑터와 설명 계층으로 격하한다.
|
||||
north_star: 저성능 LLM도 final_context 패킷과 고정 순서 TODO만 따라 동일한 결론을 내는 결정론적 퀀트 엔진
|
||||
non_negotiables:
|
||||
- LLM은 숫자, 가격, 수량, TP/SL, 점수, 공식, 주문문을 생성하지 않는다.
|
||||
- 모든 산출 숫자는 formula_id, source_path, json_pointer, input_hash를 가진다.
|
||||
- 새 전략은 contract -> schema -> golden case -> shadow ledger -> replay -> activation
|
||||
gate 순서 없이는 active가 될 수 없다.
|
||||
- GAS는 데이터 수집/시트 입출력 어댑터로만 유지하고 투자 판단 로직은 Python canonical로 이전한다.
|
||||
- 보고서는 final_decision_packet과 provenance ledger만 읽고 계산하지 않는다.
|
||||
current_state_audit:
|
||||
inventory_observed:
|
||||
total_file_count_from_entropy_audit: 1433
|
||||
repository_budget_max_total_files: 2000
|
||||
temp_json_count_from_entropy_audit: 16
|
||||
package_script_count_from_package_json: 22
|
||||
python_files_total: 834
|
||||
yaml_files_total: 170
|
||||
markdown_files_total: 39
|
||||
gas_files_total: 8
|
||||
tools_py_total: 355
|
||||
build_tools_count: 161
|
||||
validate_tools_count: 140
|
||||
spec_files_count: 125
|
||||
formula_registry_count: 149
|
||||
generated_formula_py_count: 149
|
||||
generated_golden_py_count: 149
|
||||
factor_registry_count: 149
|
||||
factor_promotion_gate_distribution:
|
||||
draft: 149
|
||||
factor_empty_golden_case_count: 149
|
||||
things_working:
|
||||
- area: single source manifest
|
||||
evidence: 'runtime/active_artifact_manifest.yaml: active_count_per_formula=1,
|
||||
report_active_artifact_match_pct=100.0, authority_collision_count=0'
|
||||
- area: output authority matrix
|
||||
evidence: 'governance/authority_matrix.yaml: owned_output_field_pct=100.0, authority_collision_count=0,
|
||||
manual_override_field_count=0'
|
||||
- area: field dictionary validation
|
||||
evidence: validate_field_dictionary.py PASS; field_count=351
|
||||
- area: number provenance
|
||||
evidence: validate_number_provenance_strict_v3.py PASS; coverage_pct=100, stale_critical_number_count=0
|
||||
- area: low capability pack after manual build
|
||||
evidence: build_final_decision_packet_v4.py + build_low_capability_context_pack_v5.py
|
||||
+ validate_low_capability_pack_v1.py PASS
|
||||
- area: repository entropy budget
|
||||
evidence: audit_repository_entropy_v2.py PASS; total_file_count=1433 < 2000
|
||||
critical_gaps:
|
||||
- gap_id: GAP-001
|
||||
severity: P0
|
||||
title: release mode가 build dependency closure를 실행하지 않아 결측 artifact에서 실패 가능
|
||||
evidence: run_release_dag_v3.py --mode release initially attempted validate_low_capability
|
||||
before Temp/final_context_for_llm_v5.yaml existed.
|
||||
impact: 저성능 LLM용 패킷, provenance, report sync가 환경 상태에 따라 통과/실패하는 비결정성 발생
|
||||
fix_direction: mode별 target node의 dependency closure를 먼저 계산하고 depends_on build
|
||||
node는 항상 선행 실행
|
||||
- gap_id: GAP-002
|
||||
severity: P0
|
||||
title: architecture boundary gate가 FAIL이며 module IO schema coverage와 artifact
|
||||
chain이 0
|
||||
evidence: 'validate_architecture_boundaries_v2.py: module_io_schema_coverage_pct=0.0,
|
||||
artifact_chain_count=0; builder scan also renderer_calculation_count=5'
|
||||
impact: data -> feature -> decision -> execution -> report 단방향 경계의 실증이 부족함
|
||||
fix_direction: module_io_contract registry와 artifact_hash_chain builder를 release
|
||||
DAG에 build+validate 쌍으로 추가
|
||||
- gap_id: GAP-003
|
||||
severity: P1
|
||||
title: GAS thin adapter 정책과 실제 GAS 구현 간 괴리가 큼
|
||||
evidence: validate_gas_thin_adapter_v1.py found forbidden_gas_business_logic_count=98
|
||||
but gate=PASS due migration_plan_exists
|
||||
impact: Python canonical first 원칙이 깨지고 공식 이중 구현/상호충돌 위험 증가
|
||||
fix_direction: GAS calculation logic를 pure adapter facade로 축소하고 formula outputs는
|
||||
Python runtime artifact에서만 공급
|
||||
- gap_id: GAP-004
|
||||
severity: P1
|
||||
title: 149개 factor가 모두 draft이며 golden_cases가 비어 있음
|
||||
evidence: factor_lifecycle_registry.yaml factors=149, promotion_gate=draft 149,
|
||||
empty golden_cases=149
|
||||
impact: 팩터가 많아도 어떤 팩터가 수익률/손실방어에 기여하는지 승격·퇴출 판단 불가
|
||||
fix_direction: factor lifecycle을 draft/shadow/candidate/active/retired로 강제하고 최소
|
||||
golden/replay/edge gate를 채워야 promotion 가능
|
||||
- gap_id: GAP-005
|
||||
severity: P1
|
||||
title: tools 스프롤이 커져 개발자가 어느 CLI를 고쳐야 하는지 불명확
|
||||
evidence: tools/*.py=355, build_*=161, validate_*=140
|
||||
impact: 중복 하네스, 버전 파편화, 릴리즈 시간 증가, 유지보수 난이도 상승
|
||||
fix_direction: tools를 thin CLI로 유지하되 내부 로직은 src/quant_engine 하위 패키지로 이동하고 CLI
|
||||
registry를 자동 생성
|
||||
- gap_id: GAP-006
|
||||
severity: P2
|
||||
title: 문서와 spec의 경계는 좋아졌으나 still too many rule/spec surfaces
|
||||
evidence: spec files 125, yaml files 170, markdown files 39
|
||||
impact: 저성능 LLM이 여러 문서의 상충 규칙을 동시에 소화하기 어려움
|
||||
fix_direction: AGENTS.md는 80~100 lines index로 유지, 상세 규칙은 5개 domain bundle로 압축,
|
||||
generated low-capability pack으로만 serving
|
||||
target_architecture:
|
||||
principle: Source of Truth는 spec/*.yaml, deterministic calculation은 src/quant_engine,
|
||||
execution packaging은 Temp/final_decision_packet_active.json, narrative는 renderer/LLM
|
||||
layering:
|
||||
- layer: L0_governance
|
||||
path: AGENTS.md, governance/, docs/adr/
|
||||
responsibility: 권위, 변경승인, lifecycle, 운영 헌법
|
||||
may_calculate: false
|
||||
- layer: L1_contracts
|
||||
path: spec/
|
||||
responsibility: 입력/출력/schema/formula/risk/order/report 계약
|
||||
may_calculate: false
|
||||
- layer: L2_core_engine
|
||||
path: src/quant_engine/
|
||||
responsibility: 공식 구현, 데이터 검증, 팩터, 리스크, 포트폴리오, execution blueprint
|
||||
may_calculate: true
|
||||
- layer: L3_cli
|
||||
path: tools/
|
||||
responsibility: build/validate/render/release 명령 wrapper
|
||||
may_calculate: false
|
||||
- layer: L4_adapters
|
||||
path: gas_*.gs, src/gas_adapter_parts/
|
||||
responsibility: Google Sheet/HTS/외부 데이터 입출력
|
||||
may_calculate: false
|
||||
- layer: L5_runtime
|
||||
path: Temp/, runtime/
|
||||
responsibility: 실행 산출물, lineage, manifest, final context
|
||||
may_calculate: false
|
||||
- layer: L6_reporting
|
||||
path: tools/render_operational_report.py, prompts/
|
||||
responsibility: 계산 없이 final packet을 사람이 읽을 수 있게 렌더링
|
||||
may_calculate: false
|
||||
canonical_package_structure:
|
||||
src/quant_engine/contracts/: YAML/schema loader, contract resolver, field dictionary
|
||||
resolver
|
||||
src/quant_engine/data/: raw workbook mapping, freshness, missingness, as-of alignment,
|
||||
leakage guard
|
||||
src/quant_engine/formulas/: registered deterministic formulas only; generated
|
||||
wrappers allowed
|
||||
src/quant_engine/factors/: factor lifecycle, edge measurement, promotion/retirement
|
||||
logic
|
||||
src/quant_engine/risk/: portfolio exposure, cash floor, heat, drawdown, circuit
|
||||
breakers
|
||||
src/quant_engine/portfolio/: position sizing, rebalancing, cash recovery optimizer,
|
||||
concentration policy
|
||||
src/quant_engine/execution/: order grammar, tick normalization, TP/SL ladder,
|
||||
execution blueprint
|
||||
src/quant_engine/reporting/: packet builders only; no free calculation in renderer
|
||||
src/quant_engine/validation/: contract, golden, property, parity, replay, release
|
||||
gates
|
||||
src/quant_engine/observability/: lineage events, provenance ledger, health card,
|
||||
drift dashboard
|
||||
methodology:
|
||||
name: QEDD loop
|
||||
loop:
|
||||
- '1_contract_first: 새 판단/팩터/출력은 YAML contract와 owner field부터 정의한다.'
|
||||
- '2_schema_and_golden_first: 입력 스키마, 출력 스키마, 최소 golden case를 작성한다.'
|
||||
- '3_python_canonical_implementation: 계산은 src/quant_engine에만 구현한다.'
|
||||
- '4_shadow_run: 최소 20 trading days 또는 replay 250 bars 이상 shadow ledger에 기록한다.'
|
||||
- '5_edge_and_risk_evaluation: hit rate, payoff, drawdown, slippage, late-chase
|
||||
avoidance를 측정한다.'
|
||||
- '6_activation_gate: threshold 충족 시 active manifest에만 승격한다.'
|
||||
- '7_report_serving: LLM은 final_context_for_llm_v5.yaml만 읽고 고정 템플릿으로 출력한다.'
|
||||
- '8_post_trade_feedback: 실행 결과를 outcome ledger로 되돌려 calibration registry를 갱신한다.'
|
||||
development_rules:
|
||||
definition_of_ready:
|
||||
- change_request yaml exists
|
||||
- owner assigned
|
||||
- affected formula_id/output_field listed
|
||||
- conflict_precedence declared
|
||||
- data source and freshness SLA declared
|
||||
- golden case target declared
|
||||
definition_of_done:
|
||||
- contract validation PASS
|
||||
- schema/model parity PASS
|
||||
- golden coverage PASS
|
||||
- property invariants PASS
|
||||
- no unproven number in report PASS
|
||||
- release DAG full dependency closure PASS
|
||||
- lineage event written
|
||||
- rollback path documented
|
||||
anti_overengineering_rule: 새 파일 추가 전 existing owner/domain에 병합 가능한지 먼저 확인한다. 새
|
||||
파일은 CR에 entropy_delta와 retirement_plan이 있어야 한다.
|
||||
quant_algorithm_spine:
|
||||
decision_sequence:
|
||||
- step: 1
|
||||
name: data_integrity_gate
|
||||
purpose: 결측/신선도/as-of/단위/ticker 정합성 차단
|
||||
output: PASS | DATA_MISSING | STALE | UNIT_MISMATCH
|
||||
- step: 2
|
||||
name: market_regime_gate
|
||||
purpose: KOSPI/KOSDAQ/미국/금리/환율/VIX/크레딧 리스크로 risk-on/off/neutral 판정
|
||||
output: regime, target_cash_pct, heat_limit
|
||||
- step: 3
|
||||
name: portfolio_health_gate
|
||||
purpose: 현금 방어선, D+2 즉시현금, 집중도, 손실방어, 목표 5억 진행률
|
||||
output: cash_shortfall, exposure_breach, rebalance_required
|
||||
- step: 4
|
||||
name: factor_evidence_stack
|
||||
purpose: 펀더멘털/스마트머니/상대강도/수급/변동성/섹터회전 점수를 동일 단위로 정규화
|
||||
output: factor_score_by_ticker
|
||||
- step: 5
|
||||
name: anti_late_entry_gate
|
||||
purpose: 상승 끝물 추격매수/설거지 구간 차단
|
||||
output: entry_allowed, pullback_required, chase_risk_score
|
||||
- step: 6
|
||||
name: execution_blueprint
|
||||
purpose: 주문 가능 여부, 가격, 수량, 손절/익절, tick normalization, order grammar 산출
|
||||
output: order_blueprint
|
||||
- step: 7
|
||||
name: shadow_and_outcome_feedback
|
||||
purpose: 실행 전/후 예측 정확도, 비용, slippage, drawdown contribution 측정
|
||||
output: outcome_ledger, calibration_update
|
||||
factor_domains:
|
||||
fundamental:
|
||||
- earnings_quality
|
||||
- growth_rate
|
||||
- cashflow_stability
|
||||
- valuation_peg
|
||||
- balance_sheet_health
|
||||
smart_money_liquidity:
|
||||
- foreign_institution_flow
|
||||
- volume_acceleration
|
||||
- liquidity_depth
|
||||
- ETF/sector flow
|
||||
- flow_breadth
|
||||
price_momentum:
|
||||
- relative_strength
|
||||
- breakout_quality
|
||||
- pullback_depth
|
||||
- follow_through_day
|
||||
- trend_slope
|
||||
risk_exit:
|
||||
- drawdown_guard
|
||||
- distribution_risk
|
||||
- late_chase_attribution
|
||||
- profit_lock_ratchet
|
||||
- stop_loss
|
||||
portfolio_construction:
|
||||
- cash_floor
|
||||
- sector_concentration
|
||||
- single_position_cap
|
||||
- correlation_gate
|
||||
- risk_budget_cascade
|
||||
activation_thresholds:
|
||||
new_factor_shadow_min_trading_days: 20
|
||||
candidate_min_replay_cases: 100
|
||||
candidate_min_golden_cases: 3
|
||||
active_required_incremental_edge_bps: 30
|
||||
active_max_drawdown_worsening_bps: 0
|
||||
late_chase_false_positive_review_required: true
|
||||
promotion_requires_owner_approval: true
|
||||
scorecards:
|
||||
engine_release_score_formula:
|
||||
formula: 0.15*data_integrity + 0.15*number_provenance + 0.10*schema_model_parity
|
||||
+ 0.10*golden_coverage + 0.10*property_invariants + 0.10*architecture_boundary
|
||||
+ 0.10*gas_thin_adapter + 0.10*factor_lifecycle + 0.10*llm_regression
|
||||
pass_threshold: 95
|
||||
block_threshold: 90
|
||||
hard_blocks:
|
||||
- number_provenance < 100
|
||||
- authority_collision_count > 0
|
||||
- llm_free_numeric_field_count > 0
|
||||
- release_dependency_missing_count > 0
|
||||
factor_promotion_score_formula:
|
||||
formula: 0.25*out_of_sample_hit_quality + 0.20*payoff_ratio_quality + 0.15*drawdown_defense
|
||||
+ 0.15*turnover_cost_efficiency + 0.10*regime_robustness + 0.10*data_quality
|
||||
+ 0.05*interpretability
|
||||
shadow_to_candidate_min: 70
|
||||
candidate_to_active_min: 80
|
||||
retire_below: 50
|
||||
late_chase_defense_score_formula:
|
||||
formula: 0.30*post_signal_pullback_need_accuracy + 0.25*breakout_failure_avoidance
|
||||
+ 0.20*distribution_warning_lead_days + 0.15*slippage_reduction + 0.10*false_block_penalty_inverse
|
||||
purpose: 뒷북 매수/설거지 매수 방지를 정량 평가
|
||||
low_capability_llm_serving_contract:
|
||||
input_allowed:
|
||||
- runtime/active_artifact_manifest.yaml
|
||||
- Temp/final_context_for_llm_v5.yaml
|
||||
- Temp/final_decision_packet_active.json
|
||||
- Temp/number_provenance_ledger_v4.json
|
||||
- spec/46_low_capability_execution_pack.yaml
|
||||
input_forbidden:
|
||||
- raw workbook unless parser step explicitly requested
|
||||
- deprecated artifacts
|
||||
- archive artifacts
|
||||
- multiple conflicting prompts
|
||||
response_order:
|
||||
- portfolio_health
|
||||
- blockers
|
||||
- action_table
|
||||
- sell_priority_table_if_needed
|
||||
- order_blueprint
|
||||
- shadow_ledger
|
||||
- data_missing
|
||||
- education_notes
|
||||
- next_validation_tasks
|
||||
strict_rules:
|
||||
- 숫자가 없으면 DATA_MISSING만 쓴다.
|
||||
- 계산 근거 없는 수익률/가격/수량은 쓰지 않는다.
|
||||
- 하네스 verdict를 완화하거나 뒤집지 않는다.
|
||||
- blocked 상태도 산출 기준가/손절/익절/수량이 packet에 있으면 숨기지 않는다.
|
||||
- 주문문에는 복수 조건 접속사를 넣지 않는다.
|
||||
fixed_prompt: Read only the allowed input packet. Render the report in the response_order.
|
||||
Never invent numbers. If a field is missing, write DATA_MISSING — harness update
|
||||
required. Preserve all blocker states. Use final_decision_packet as the only execution
|
||||
authority.
|
||||
refactor_todo:
|
||||
- id: P0-001
|
||||
phase: P0_release_determinism
|
||||
title: run_release_dag_v3.py를 dependency-closure 실행기로 교체
|
||||
problem: release mode가 validate_*만 실행하면서 validate node의 build dependencies를 생략할
|
||||
수 있다.
|
||||
files_to_modify:
|
||||
- tools/run_release_dag_v3.py
|
||||
- spec/41_release_dag.yaml
|
||||
implementation_steps:
|
||||
- target_nodes = mode filter로 선택한다.
|
||||
- target_nodes의 모든 depends_on을 재귀적으로 수집해 closure_nodes를 만든다.
|
||||
- topological order 중 closure_nodes만 실행한다.
|
||||
- validate_*가 필요로 하는 outputs가 없으면 build dependency를 자동 선행 실행한다.
|
||||
- REPORT에는 skipped_by_mode와 executed_due_to_dependency를 분리 기록한다.
|
||||
- node별 input_hash/output_hash, elapsed_sec, command, returncode를 lineage에 기록한다.
|
||||
commands:
|
||||
- python tools/run_release_dag_v3.py --mode release --strict
|
||||
- python tools/run_release_dag_v3.py --mode full --strict
|
||||
acceptance_criteria:
|
||||
- release mode에서 Temp/final_context_for_llm_v5.yaml이 없더라도 build_final_context가 먼저
|
||||
실행된다.
|
||||
- release_dependency_missing_count == 0
|
||||
- RELEASE_DAG_RUN_V4.gate == PASS
|
||||
rollback: 기존 run_release_dag_v3.py를 run_release_dag_v3_legacy.py로 보존하고 package.json
|
||||
script는 v4로 전환 전까지 v3 유지
|
||||
status: completed
|
||||
- id: P0-002
|
||||
phase: P0_architecture_boundary
|
||||
title: module_io_contract_registry 도입
|
||||
problem: architecture boundary validator가 module_io_schema_coverage_pct=0.0으로 실패한다.
|
||||
files_to_create:
|
||||
- spec/48_module_io_contract_registry.yaml
|
||||
- tools/build_module_io_coverage_v1.py
|
||||
- tools/validate_module_io_coverage_v1.py
|
||||
implementation_steps:
|
||||
- src/quant_engine 주요 모듈별 inputs, outputs, owner, schema, artifact_path를 registry에
|
||||
선언한다.
|
||||
- tools/build_module_io_coverage_v1.py가 registry와 실제 artifact/schema 존재 여부를 비교한다.
|
||||
- coverage = modules_with_input_schema_and_output_schema / total_modules * 100으로
|
||||
계산한다.
|
||||
- coverage 결과를 Temp/module_io_coverage_v1.json으로 저장한다.
|
||||
- architecture_boundaries_v2 builder가 harness_coverage_audit.json 대신 module_io_coverage_v1.json을
|
||||
읽도록 수정한다.
|
||||
acceptance_criteria:
|
||||
- module_io_schema_coverage_pct >= 100.0
|
||||
- missing_module_contract_count == 0
|
||||
status: completed
|
||||
- id: P0-003
|
||||
phase: P0_artifact_hash_chain
|
||||
title: artifact hash chain builder를 release DAG에 추가
|
||||
problem: artifact_chain_count=0으로 artifact lineage 검증이 불가능하다.
|
||||
files_to_create:
|
||||
- tools/build_artifact_chain_hash_v4.py
|
||||
- tools/validate_artifact_chain_hash_v4.py
|
||||
files_to_modify:
|
||||
- spec/41_release_dag.yaml
|
||||
- runtime/active_artifact_manifest.yaml
|
||||
implementation_steps:
|
||||
- active manifest의 canonical_source부터 final packet, provenance ledger, report json/md까지
|
||||
chain을 구성한다.
|
||||
- 각 artifact에 path, sha256, formula_id, generated_at, parent_hash를 기록한다.
|
||||
- 'chain length 최소 4개: raw json -> final packet -> provenance ledger -> report output.'
|
||||
- Temp/artifact_chain_hash_v4.json을 생성한다.
|
||||
acceptance_criteria:
|
||||
- artifact_chain_count >= 4
|
||||
- artifact_hash_chain_coverage_pct == 100.0
|
||||
status: completed
|
||||
- id: P0-004
|
||||
phase: P0_renderer_purity
|
||||
title: renderer calculation scanner false positive와 실제 계산을 분리
|
||||
problem: render_operational_report.py에서 path join/string concat까지 calculation으로
|
||||
잡히는 보수적 scanner가 release를 막을 수 있다.
|
||||
files_to_modify:
|
||||
- tools/build_architecture_boundaries_v2.py
|
||||
- tools/render_operational_report.py
|
||||
implementation_steps:
|
||||
- AST 기반 scanner로 Numeric BinOp, Call(round/sum/mean), literal arithmetic만 계산으로
|
||||
카운트한다.
|
||||
- Path join, string concatenation, markdown assembly는 allowed_renderer_ops로 whitelist한다.
|
||||
- renderer는 get_value(packet, pointer)와 render_section만 사용하도록 정리한다.
|
||||
- renderer_calculation_count가 실제 투자 숫자 계산에 대해서만 증가하게 한다.
|
||||
acceptance_criteria:
|
||||
- renderer_calculation_count == 0
|
||||
- renderer_allowed_formatting_ops_count >= 1
|
||||
status: completed
|
||||
- id: P1-001
|
||||
phase: P1_gas_thin_adapter_migration
|
||||
title: GAS business logic 98건을 Python artifact 소비로 이전
|
||||
problem: GAS 내부에 macro_risk_score, TP/SL, routing, score 등 계산 흔적이 남아 있다.
|
||||
files_to_modify:
|
||||
- gas_data_feed.gs
|
||||
- gas_data_collect.gs
|
||||
- gas_apex_runtime_core.gs
|
||||
- gas_harness_rows.gs
|
||||
- src/gas_adapter_parts/*
|
||||
implementation_steps:
|
||||
- GAS function inventory를 collect/read/write/render/legacy_logic로 분류한다.
|
||||
- legacy_logic 함수마다 Python formula_id와 output artifact를 매핑한다.
|
||||
- GAS 계산 함수는 deprecate wrapper로 바꾸고 Python artifact value를 읽게 한다.
|
||||
- GAS에서 점수/가격/수량 계산 키워드가 검출되면 validator gate를 FAIL로 변경한다.
|
||||
- migration_allowlist는 30일 만료일을 가진다.
|
||||
acceptance_criteria:
|
||||
- forbidden_gas_business_logic_count == 0
|
||||
- validate_gas_thin_adapter_v2.gate == PASS
|
||||
migration_batches:
|
||||
- batch: 1
|
||||
scope: macro_risk_score and routing trace read-only migration
|
||||
- batch: 2
|
||||
scope: TP/SL ladder and tick normalization migration
|
||||
- batch: 3
|
||||
scope: distribution/late chase risk score migration
|
||||
- batch: 4
|
||||
scope: order blueprint assembly migration
|
||||
status: completed
|
||||
- id: P1-002
|
||||
phase: P1_factor_lifecycle
|
||||
title: 149개 factor를 lifecycle gate로 재분류
|
||||
problem: 모든 factor가 draft이며 golden_cases가 없어 활성/퇴출 기준이 없다.
|
||||
files_to_modify:
|
||||
- spec/factor_lifecycle_registry.yaml
|
||||
- spec/43_quant_factor_taxonomy.yaml
|
||||
files_to_create:
|
||||
- tools/build_factor_edge_report_v1.py
|
||||
- tools/validate_factor_promotion_gates_v1.py
|
||||
- Temp/factor_edge_report_v1.json
|
||||
implementation_steps:
|
||||
- factor마다 horizon, hypothesis, data_quality_requirements, conflict_precedence,
|
||||
position_sizing_impact, exit_impact를 채운다.
|
||||
- '각 factor 최소 golden_cases 3개를 연결한다: positive, negative, missing_data.'
|
||||
- shadow_start_date와 activation_threshold를 필수화한다.
|
||||
- draft factor는 report decision에 영향 0으로 제한한다.
|
||||
- candidate 이상만 sizing/exit에 영향 가능하도록 gate를 둔다.
|
||||
- retirement_condition이 90일 no edge 또는 high conflict이면 retired로 이동한다.
|
||||
acceptance_criteria:
|
||||
- active factor의 golden_cases_count >= 3
|
||||
- draft factor의 position_sizing_impact == diagnostic
|
||||
- factor_promotion_gate_distribution에 active/candidate/shadow/draft/retired가 명시됨
|
||||
- empty_golden_case_count for non-draft == 0
|
||||
status: completed
|
||||
- id: P1-003
|
||||
phase: P1_tool_sprawl_reduction
|
||||
title: tools/*.py 355개를 CLI registry + src 로직으로 다이어트
|
||||
problem: build/validate CLI가 많아 수정 지점이 분산된다.
|
||||
files_to_create:
|
||||
- spec/49_cli_registry.yaml
|
||||
- src/quant_engine/cli_registry.py
|
||||
- tools/qe.py
|
||||
files_to_modify:
|
||||
- package.json
|
||||
- tools/*.py
|
||||
implementation_steps:
|
||||
- 각 tool의 command_id, module_path, function, inputs, outputs, owner, deprecation_status를
|
||||
registry에 등록한다.
|
||||
- 새 CLI는 python tools/qe.py build final-context 같은 방식으로 통합한다.
|
||||
- 기존 tools/build_*.py와 validate_*.py는 20줄 이하 wrapper로 줄인다.
|
||||
- 중복 version tool은 latest canonical만 package.json에서 노출한다.
|
||||
- retired tool은 tools/archive/YYYYMMDD로 이동하고 release DAG에서 제거한다.
|
||||
acceptance_criteria:
|
||||
- package_script_count <= 30
|
||||
- tools_wrapper_over_80_lines_count == 0
|
||||
- deprecated_tool_referenced_by_dag_count == 0
|
||||
status: completed
|
||||
- id: P1-004
|
||||
phase: P1_contract_test_pyramid
|
||||
title: 테스트 피라미드를 release gate로 고정
|
||||
problem: 검증 파일은 많지만 어떤 테스트가 어떤 리스크를 막는지 hierarchy가 약하다.
|
||||
files_to_create:
|
||||
- spec/50_test_pyramid_contract.yaml
|
||||
- tools/build_test_coverage_matrix_v1.py
|
||||
implementation_steps:
|
||||
- 'unit: 공식 단위 golden/property test'
|
||||
- 'contract: YAML schema와 field dictionary parity'
|
||||
- 'integration: final packet/provenance/report sync'
|
||||
- 'replay: as-of aligned historical outcome'
|
||||
- 'llm_regression: low capability context response contract'
|
||||
- 각 test가 막는 failure_mode를 spec에 매핑한다.
|
||||
acceptance_criteria:
|
||||
- critical_failure_modes_covered_pct == 100
|
||||
- orphan_test_count == 0
|
||||
- orphan_validator_count == 0
|
||||
- id: P2-001
|
||||
phase: P2_data_integrity
|
||||
title: data contract를 as-of, freshness, unit, survivorship 관점으로 강화
|
||||
files_to_modify:
|
||||
- spec/02_data_contract.yaml
|
||||
- spec/14_raw_workbook_mapping.yaml
|
||||
- spec/data_quality/expectations.yaml
|
||||
files_to_create:
|
||||
- tools/build_data_lineage_matrix_v1.py
|
||||
- tools/validate_no_future_leakage_v1.py
|
||||
implementation_steps:
|
||||
- 각 raw field에 source_system, as_of_date, refresh_sla, unit, null_policy, transformation_owner를
|
||||
선언한다.
|
||||
- price/volume/financial/macro/account_snapshot의 time grain을 분리한다.
|
||||
- fundamental data는 발표일 기준 availability lag를 반영한다.
|
||||
- D+2 현금은 immediate_cash_defense_line로 별도 field화한다.
|
||||
acceptance_criteria:
|
||||
- field_lineage_coverage_pct == 100
|
||||
- future_leakage_case_count == 0
|
||||
- unit_mismatch_count == 0
|
||||
- id: P2-002
|
||||
phase: P2_backtest_replay
|
||||
title: live/replay 분리와 walk-forward 평가를 activation gate에 연결
|
||||
files_to_modify:
|
||||
- spec/29_backtest_harness_contract.yaml
|
||||
- spec/44_live_replay_separation.yaml
|
||||
files_to_create:
|
||||
- tools/run_walk_forward_eval_v1.py
|
||||
- Temp/walk_forward_eval_v1.json
|
||||
implementation_steps:
|
||||
- live artifact와 replay artifact의 namespace를 강제 분리한다.
|
||||
- 매 factor와 decision rule에 in-sample/out-of-sample 기간을 기록한다.
|
||||
- 거래비용, 세금, 슬리피지, 체결 실패를 비용 모델에 포함한다.
|
||||
- 목표 5억 달성률과 최대낙폭을 동시에 평가한다.
|
||||
acceptance_criteria:
|
||||
- live_replay_mix_count == 0
|
||||
- walk_forward_period_count >= 4
|
||||
- cost_adjusted_edge_report_exists == true
|
||||
- id: P2-003
|
||||
phase: P2_late_chase_defense
|
||||
title: 뒷북/설거지 방지 하네스 강화
|
||||
files_to_modify:
|
||||
- spec/strategy/anti_late_entry_pullback_gate_v5.yaml
|
||||
- spec/strategy/pre_distribution_early_warning_v4.yaml
|
||||
files_to_create:
|
||||
- tools/build_late_chase_confusion_matrix_v1.py
|
||||
- Temp/late_chase_confusion_matrix_v1.json
|
||||
implementation_steps:
|
||||
- 매수 후보 발생 후 T+1/T+3/T+5 최대역행폭과 follow-through를 측정한다.
|
||||
- 차단했어야 할 추격매수와 차단하지 말았어야 할 주도주 눌림목을 분리한다.
|
||||
- 분배 위험, 갭상승 피로도, 거래대금 climax, 외국인/기관 divergence를 조합한다.
|
||||
- late_chase_block이 false positive이면 pullback_entry_trigger로 재진입 후보를 남긴다.
|
||||
acceptance_criteria:
|
||||
- late_chase_false_negative_rate <= 15
|
||||
- leader_pullback_false_block_rate <= 25
|
||||
- confusion_matrix_min_cases >= 50
|
||||
- id: P3-001
|
||||
phase: P3_reporting_and_llm
|
||||
title: 보고서 렌더링을 final_context 기반으로 단일화
|
||||
files_to_modify:
|
||||
- tools/render_operational_report.py
|
||||
- prompts/low_capability_report_renderer.md
|
||||
- spec/31_low_capability_llm_response_contract.yaml
|
||||
implementation_steps:
|
||||
- report renderer는 final_context_for_llm_v5.yaml 섹션만 순서대로 렌더링한다.
|
||||
- operational_report.json과 md는 동일 packet에서 파생되어 checksum을 공유한다.
|
||||
- LLM regression fixture를 매주 1개 이상 추가한다.
|
||||
- '금지어: 추정, 대략, 가능성 높음 같은 숫자 없는 확신 표현을 lint한다.'
|
||||
acceptance_criteria:
|
||||
- llm_regression_pass_pct == 100
|
||||
- report_packet_mismatch_count == 0
|
||||
- ambiguous_instruction_count == 0
|
||||
- id: P3-002
|
||||
phase: P3_document_diet
|
||||
title: '문서/파일 다이어트: 5개 권위 bundle로 압축'
|
||||
files_to_modify:
|
||||
- AGENTS.md
|
||||
- governance/agents_index.yaml
|
||||
- governance/rules/*.yaml
|
||||
- docs/doctrine.md
|
||||
implementation_steps:
|
||||
- AGENTS.md는 운영 인덱스와 hard rule만 유지한다.
|
||||
- rules를 core_locks, harness_contract, portfolio_policy, order_grammar, reporting_contract
|
||||
5개로 유지한다.
|
||||
- 중복 ADR과 중복 spec 설명은 ADR index에서 링크만 유지한다.
|
||||
- 새 문서는 owner, expiry_date, supersedes, archive_policy 없이는 merge 금지한다.
|
||||
acceptance_criteria:
|
||||
- agents_lines <= 100
|
||||
- active_rule_file_count <= 6
|
||||
- duplicate_rule_hash_count == 0
|
||||
- id: P4-001
|
||||
phase: P4_operating_cadence
|
||||
title: 주간/월중 운용 cadence를 release DAG와 보고서에 내장
|
||||
files_to_modify:
|
||||
- spec/operating_cadence.yaml
|
||||
- tools/build_operating_cadence_signal_v1.py
|
||||
- prompts/weekly_operational_report_master_prompt_v1.md
|
||||
implementation_steps:
|
||||
- 토/일이면 rebalancing_required=true를 생성한다.
|
||||
- 매월 1/11/21이면 mid_month_checkpoint_required=true를 생성한다.
|
||||
- D+2 현금은 immediate_cash_defense_line에 포함한다.
|
||||
- 보고서 첫 섹션에서 cadence obligation을 누락하면 release gate FAIL로 둔다.
|
||||
acceptance_criteria:
|
||||
- cadence_signal_present == true
|
||||
- weekend_rebalance_rule_test_pass == true
|
||||
- midmonth_checkpoint_rule_test_pass == true
|
||||
- id: P5-001
|
||||
phase: P5_observability
|
||||
title: 엔진 health card와 drift dashboard를 상시 산출
|
||||
files_to_create:
|
||||
- src/quant_engine/observability/health.py
|
||||
- tools/build_engine_drift_dashboard_v1.py
|
||||
- Temp/engine_drift_dashboard_v1.json
|
||||
implementation_steps:
|
||||
- 매 릴리즈마다 data freshness, factor drift, prediction_match_rate, turnover, slippage,
|
||||
cash defense status를 저장한다.
|
||||
- prediction_match_rate가 하락하면 affected factor를 자동으로 calibration queue에 넣는다.
|
||||
- shadow와 active 성과를 분리 시각화 가능한 json으로 남긴다.
|
||||
acceptance_criteria:
|
||||
- engine_health_card_gate == PASS
|
||||
- drift_dashboard_freshness_days <= 1
|
||||
- calibration_queue_exists == true
|
||||
- id: P6-001
|
||||
phase: P6_release_train
|
||||
title: 정기 release train과 rollback 정책 확정
|
||||
files_to_modify:
|
||||
- spec/release/release_train.yaml
|
||||
- spec/release/version_retirement_policy.yaml
|
||||
- spec/release/repository_entropy_budget.yaml
|
||||
implementation_steps:
|
||||
- 매주 토/일 release window와 월중 1/11/21 checkpoint window를 정의한다.
|
||||
- active manifest 변경은 CR + full DAG PASS + rollback artifact required 조건을 만족해야 한다.
|
||||
- deprecated vN artifacts는 2회 release 뒤 archive로 이동한다.
|
||||
- repository budget은 file count뿐 아니라 active spec count, active tool count, prompt
|
||||
count로 확장한다.
|
||||
acceptance_criteria:
|
||||
- active_artifact_count_per_formula == 1
|
||||
- deprecated_runtime_reference_count == 0
|
||||
- rollback_manifest_exists == true
|
||||
implementation_order:
|
||||
- P0-001
|
||||
- P0-002
|
||||
- P0-003
|
||||
- P0-004
|
||||
- P1-001
|
||||
- P1-002
|
||||
- P1-003
|
||||
- P1-004
|
||||
- P2-001
|
||||
- P2-002
|
||||
- P2-003
|
||||
- P3-001
|
||||
- P3-002
|
||||
- P4-001
|
||||
- P5-001
|
||||
- P6-001
|
||||
suggested_new_files_minimal_set:
|
||||
- spec/48_module_io_contract_registry.yaml
|
||||
- spec/49_cli_registry.yaml
|
||||
- spec/50_test_pyramid_contract.yaml
|
||||
- tools/qe.py
|
||||
- tools/build_artifact_chain_hash_v4.py
|
||||
- tools/validate_release_dependency_closure_v1.py
|
||||
- src/quant_engine/cli_registry.py
|
||||
- src/quant_engine/observability/health.py
|
||||
files_to_retire_or_archive_policy:
|
||||
rule: same formula_id family에서 active latest와 direct golden/validator를 제외한 old builder는
|
||||
archive/YYYYMMDD로 이동
|
||||
candidates_by_pattern:
|
||||
- tools/build_*_v1.py when v2+ active exists
|
||||
- artifacts/archive/**
|
||||
- Temp stale json not in active manifest
|
||||
- prompts superseded by low_capability_report_renderer.md
|
||||
must_not_delete_without_cr:
|
||||
- spec/13_formula_registry.yaml
|
||||
- spec/12_field_dictionary.yaml
|
||||
- runtime/active_artifact_manifest.yaml
|
||||
- Temp/final_decision_packet_active.json
|
||||
- governance/authority_matrix.yaml
|
||||
low_capability_executor_todo:
|
||||
instruction: 아래 순서를 기계적으로 수행한다. 해석하거나 보완하지 않는다. 결측은 DATA_MISSING으로 남긴다.
|
||||
steps:
|
||||
- open AGENTS.md and read only hard rules and routing order
|
||||
- open runtime/active_artifact_manifest.yaml and identify canonical_source
|
||||
- open Temp/final_context_for_llm_v5.yaml; if missing, run build_final_decision_packet
|
||||
then build_low_capability_context_pack
|
||||
- validate low capability pack; stop on FAIL
|
||||
- render sections in required order
|
||||
- do not compute numbers; copy packet values with provenance
|
||||
- write blockers before recommendations
|
||||
- write DATA_MISSING for unavailable field
|
||||
- include shadow ledger for blocked/limited actions
|
||||
- run release dependency closure validation before packaging
|
||||
first_week_execution_plan:
|
||||
day_1:
|
||||
- Fix release DAG dependency closure
|
||||
- Generate final_context_for_llm_v5 from clean Temp
|
||||
- Add closure validator
|
||||
day_2:
|
||||
- Add module_io_contract_registry
|
||||
- Build module_io_coverage
|
||||
- Wire architecture boundary validator
|
||||
day_3:
|
||||
- Build artifact_hash_chain_v4
|
||||
- Patch renderer purity scanner
|
||||
- Make architecture boundary PASS
|
||||
day_4:
|
||||
- Classify GAS business logic findings into migration batches
|
||||
- Convert macro/routing read path to Python artifact
|
||||
day_5:
|
||||
- Populate factor lifecycle golden cases for top 20 active-impact formulas
|
||||
- Create factor promotion validator
|
||||
day_6:
|
||||
- Run full release DAG
|
||||
- Archive stale tools/artifacts using CR
|
||||
- Update AGENTS.md route table only if path changes
|
||||
day_7:
|
||||
- Weekend rebalancing report dry run
|
||||
- LLM regression fixture update
|
||||
- Write weekly engine health card
|
||||
final_gate_before_declaring_success:
|
||||
commands:
|
||||
- python tools/run_release_dag_v4.py --mode full --strict
|
||||
- python tools/validate_release_dependency_closure_v1.py --dag spec/41_release_dag.yaml
|
||||
--strict
|
||||
- python tools/validate_number_provenance_strict_v3.py --ledger Temp/number_provenance_ledger_v4.json
|
||||
--report Temp/operational_report.md
|
||||
- python tools/validate_low_capability_pack_v1.py --context Temp/final_context_for_llm_v5.yaml
|
||||
--contract spec/46_low_capability_execution_pack.yaml
|
||||
- python tools/validate_gas_thin_adapter_v2.py --strict
|
||||
- python tools/validate_factor_promotion_gates_v1.py --strict
|
||||
success_definition:
|
||||
- all gates PASS
|
||||
- engine_release_score >= 95
|
||||
- authority_collision_count == 0
|
||||
- unproven_report_number_count == 0
|
||||
- llm_free_numeric_field_count == 0
|
||||
- release_dependency_missing_count == 0
|
||||
Reference in New Issue
Block a user