Files
QuantEngineByItz/spec/58_llm_determinism_contract.yaml
kjh2064 4b1a33ba48 WBS-7.11 2차 확장: spec-코드 동기화 태깅 12→20개 (7.5%→12.5%)
이미 harness_file:/python_tool:/validator: 필드로 1:1 코드 매핑을
스스로 명시하고 있던 H001~H008 결정론적 하네스 계약 7개(spec/52~58)와
spec/32(canonical_artifact_resolver), spec/37(evaluation_dashboard_contract)에
has_code_implementation/code_path를 추가했다. 모든 대상 파일의 code_path
실존을 사전 확인했다.

governance/rules/00~05, spec/40·45·46·gas_adapter_contract 등 다중 구현체에
걸친 계약은 단일 code_path로 환원하면 거짓 1:1 매핑이 되므로 의도적으로
제외했다(WBS-7.11 핵심 원칙 유지).
2026-06-22 01:36:55 +09:00

83 lines
3.1 KiB
YAML

schema_version: llm_determinism_contract.v1
contract_id: H008_LLM_DETERMINISM_AUDIT
harness_file: tools/validate_llm_determinism_pack_v1.py
has_code_implementation: true
code_path: "tools/validate_llm_determinism_pack_v1.py"
authority: spec/58_llm_determinism_contract.yaml
created_at: '2026-06-10T23:29:00+09:00'
purpose: >
저성능 LLM도 packet copy-only로 같은 결과를 렌더링할 만큼
final_context_for_llm이 충분히 사전 계산되어 있는지 검증한다.
LLM에게 산술 연산을 요구하는 항목이 있으면 릴리즈를 차단한다.
required_precomputed_sections:
- section: 01_metadata_and_manifest_alias
must_contain: [document_id, generated_at_kst, active_artifact_alias]
- section: 02_portfolio_health
must_contain: [total_asset_krw, cash_ratio_pct, goal_achievement_pct]
- section: 03_hard_blockers
must_contain: [blocked_tickers, blocker_reasons]
- section: 04_sell_priority_table
must_contain: [rank, ticker, sell_action, sell_reason_code]
note: 이미 정렬된 순서로 제공. LLM은 재정렬하지 않는다.
- section: 05_buy_hold_sell_action_table
must_contain: [ticker, final_action, entry_price, stop_price, quantity]
- section: 06_cash_and_risk_budget
must_contain: [available_cash_krw, d2_cash_krw, max_allowed_mdd_pct]
- section: 07_shadow_ledger_visible_items
must_contain: [formula_id, lifecycle_state, sample_n, promotion_allowed]
- section: 08_data_missing_items
must_contain: [missing_field, reason]
- section: 09_market_regime_summary_precomputed
must_contain: [regime_label, regime_score, position_scale_factor]
- section: 10_education_notes_preapproved
note: 사전 승인된 교육 노트만 포함. LLM이 신규 작성 금지.
- section: 11_forbidden_phrases_and_no_math_rules
must_contain: [forbidden_phrases, no_math_rule]
validation_rules:
- all_numeric_fields_precomputed: true
- all_tables_pre_sorted: true
- no_arithmetic_instruction_in_prompt: true
- llm_numeric_generation_count: 0
inputs:
- field: final_context_for_llm_v5.yaml
source: Temp/final_context_for_llm_v5.yaml
required: true
output_fields:
- name: missing_sections
type: list[str]
description: 누락된 required section 목록
- name: arithmetic_instruction_count
type: int
description: LLM에게 계산을 요구하는 지시 건수
- name: precomputed_field_coverage_pct
type: float
description: 사전 계산된 필드 비율
- name: gate
type: str
enum: [PASS, FAIL]
acceptance_criteria:
- all_decision_fields_precomputed: true
- all_tables_sorted_in_packet: true
- no_instruction_requires_arithmetic: true
hard_gates:
- gate_id: NO_ARITHMETIC_INSTRUCTION
condition: arithmetic_instruction_count == 0
on_fail: BLOCK_RELEASE
- gate_id: ALL_SECTIONS_PRESENT
condition: missing_sections == []
on_fail: BLOCK_RELEASE
- gate_id: PRECOMPUTED_COVERAGE
condition: precomputed_field_coverage_pct == 100.0
on_fail: BLOCK_RELEASE
owner: pm
lifecycle_state: active
retirement_condition: >
LLM 파이프라인이 완전 결정론적 서버 사이드 렌더링으로 교체될 때까지 유효하다.