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:
2026-06-13 13:20:14 +09:00
commit ee3e799de1
1474 changed files with 176087 additions and 0 deletions
@@ -0,0 +1,25 @@
# ADR-0001 Adopt active artifact manifest
## Context
Temp contains multiple artifact versions and the runtime must read only one active path per artifact key.
## Decision
Use `runtime/active_artifact_manifest.yaml` as the only runtime selection source.
See `spec/09_decision_flow.yaml` and `tools/validate_active_manifest.py` for the runtime gate and selection checks.
## Alternatives
- Scan Temp directly
- Pick latest timestamp
## Consequences
- Deterministic runtime file selection
- Lower stale-read risk
## Rollback
Restore prior manifest only if validation fails.
## Affected files
- runtime/active_artifact_manifest.yaml
- spec/09_decision_flow.yaml
- tools/validate_active_manifest.py
+22
View File
@@ -0,0 +1,22 @@
# ADR-0002 Authority matrix
## Context
Output fields need a single declared owner to prevent duplicate writers.
## Decision
Maintain a governance authority matrix and output-field owner ledger.
## Alternatives
- Embed ownership in ad hoc notes
## Consequences
- Ownership collision checks become explicit
- Review is easier for numeric outputs
## Rollback
Keep the prior ledger alongside the new one.
## Affected files
- governance/authority_matrix.yaml
- spec/03_formulas/output_field_owner_ledger.yaml
+23
View File
@@ -0,0 +1,23 @@
# ADR-0003 Baseline metrics
## Context
Refactor progress needs a fixed baseline.
## Decision
Record repository baseline metrics as build output.
See `tools/validate_calibration_registry_v1.py` and `spec/08_scoring_rules.yaml` for baseline-linked validation context.
## Alternatives
- Report metrics manually in review notes
## Consequences
- Delta tracking becomes deterministic
## Rollback
Regenerate from a prior commit if needed.
## Affected files
- Temp/refactor_baseline_metrics_v1.json
- tools/validate_calibration_registry_v1.py
- spec/08_scoring_rules.yaml
+21
View File
@@ -0,0 +1,21 @@
# ADR-0004 Rule lifecycle
## Context
Rule proliferation needs a lifecycle policy.
## Decision
Use proposed -> shadow -> active -> deprecated -> removed.
## Alternatives
- Free-form status labels
## Consequences
- Deprecation is explicit
- Active router reference checks become possible
## Rollback
Downgrade the rule to shadow if needed.
## Affected files
- governance/rule_lifecycle.yaml
@@ -0,0 +1,22 @@
# ADR-0005 Formula domain split
## Context
The monolithic formula registry needs domain separation.
## Decision
Split formulas by domain and build a normalized registry.
## Alternatives
- Keep a single registry file
## Consequences
- Review scope is reduced
- Formula ownership is easier to track
## Rollback
Rebuild normalized registry from the monolith.
## Affected files
- spec/formulas/*
- spec/03_formulas/formula_registry.normalized.yaml
@@ -0,0 +1,24 @@
# ADR-0006 Final decision packet
## Context
The renderer needs a single canonical packet.
## Decision
Use a versioned final decision packet as the only render input.
See `spec/07_output_schema.yaml` and `tools/validate_report_packet_sync_v1.py` for the canonical packet/render contract.
## Alternatives
- Read many Temp files directly
## Consequences
- Provenance checks become centralized
## Rollback
Keep the previous packet version available.
## Affected files
- Temp/final_decision_packet_v3.json
- Temp/final_decision_packet_active.json
- spec/07_output_schema.yaml
- tools/validate_report_packet_sync_v1.py
+20
View File
@@ -0,0 +1,20 @@
# ADR-0007 Shadow ledger
## Context
Blocked items still need visible computed values.
## Decision
Separate executable order table from shadow ledger.
## Alternatives
- Hide blocked numbers
## Consequences
- User review is preserved
## Rollback
Show the prior packet alongside the new ledger if needed.
## Affected files
- spec/outputs/shadow_ledger_contract.yaml
+20
View File
@@ -0,0 +1,20 @@
# ADR-0008 Renderer contract
## Context
Low-capability LLM rendering needs a closed contract.
## Decision
Fix the input packet, section order, and numeric copy rules.
## Alternatives
- Free-form narrative generation
## Consequences
- Lower hallucination risk
## Rollback
Use the prior prompt only if schema validation fails.
## Affected files
- prompts/low_capability_report_renderer.md
+20
View File
@@ -0,0 +1,20 @@
# ADR-0009 Number provenance audit
## Context
Every investment number must be traceable.
## Decision
Require source_ref and formula_id for investment numbers.
## Alternatives
- Allow implicit report numbers
## Consequences
- Ungrounded numbers are detectable
## Rollback
Rebuild the report from a provenance-backed packet.
## Affected files
- tools/validate_number_provenance_v2.py
@@ -0,0 +1,20 @@
# ADR-0010 Change request template
## Context
Rule and formula changes need structured evidence.
## Decision
Use a mandatory change-request template for active changes.
## Alternatives
- Free-form change notes
## Consequences
- Rollback and testing become explicit
## Rollback
Reject changes that lack the required fields.
## Affected files
- governance/change_request_template.yaml
+19
View File
@@ -0,0 +1,19 @@
# ADR-0011: QEDD 방법론 채택
## 상태
준비됨 (Proposed)
## 배경
퀀트 엔진의 복잡도가 증가함에 따라, 저성능 LLM에서도 동일한 투자 결론을 재현하고 운영 안정성을 확보하기 위한 결정론적 개발 방법론이 필요함.
## 결정
QEDD(Quant Evidence-Driven Deterministic Development) 방법론을 채택함.
1. 모든 판단 로직은 YAML 계약(spec)에 근거함.
2. 모든 수치 계산은 Python Canonical 엔진에서만 수행함.
3. GAS는 데이터 수집 및 입출력 어댑터 역할로 축소함.
4. LLM은 이미 계산된 패킷을 복사하여 렌더링하는 역할만 수행함 (Math 금지).
## 결과
- 운영 보고서의 숫자 신뢰도 100% 확보.
- 저성능 모델에서도 판단 번복 없는 안정적인 운영 가능.
- 아키텍처 경계 위반 자동 차단.