Skip to content

Commit 47d0314

Browse files
heehoclaude
andcommitted
feat(submit): P1-03 BROKER_ACK_ALLOWED_FIELDS 6필드 추가
submit.py 의 broker_ack sanitize 화이트리스트를 9필드에서 15필드로 확장. 신규: broker_order_id, order_no, order_date, is_reserved (P0-02 capture 시 토스 broker create 응답 필드), http_status (P1-01 응답 status_code), guard_reason (P1-01 OFF 분기 final_submit_guard_reason). 단위 테스트 2건 추가: 신규 6필드 sanitize 보존 검증 (test 데이터는 P0-02 SCHD capture 응답 그대로 — orderId="V56qyv7r", orderNo=3, orderDate="2026-05-04") + OFF 분기 guard_reason 보존 검증. 전체 23 tests PASS (기존 forbidden field drop 동작 무영향). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4bfe3fe commit 47d0314

2 files changed

Lines changed: 74 additions & 0 deletions

File tree

src/toss_browser_bridge/submit.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
"quantity",
4646
"order_type",
4747
"ordered_at",
48+
"broker_order_id",
49+
"order_no",
50+
"order_date",
51+
"is_reserved",
52+
"http_status",
53+
"guard_reason",
4854
}
4955
VERIFY_SNAPSHOT_ALLOWED_FIELDS = {
5056
"status",

tests/test_submit_contract.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,74 @@ def test_mutation_journal_sanitizes_forbidden_fields(tmp_path) -> None:
178178
assert saved == sanitize_mutation_journal_entry(entry)
179179

180180

181+
def test_mutation_journal_preserves_broker_create_fields(tmp_path) -> None:
182+
path = tmp_path / "mutation-journal.jsonl"
183+
entry = append_mutation_journal(
184+
path,
185+
{
186+
"mutation_id": "mut_5678",
187+
"kind": "place_order",
188+
"requested_at": "2026-05-04T23:40:49+09:00",
189+
"preview_fingerprint": "sha256:create",
190+
"confirm_phrase_hash": "sha256:phrase",
191+
"submit_state": "submitted",
192+
"verification_state": "pending",
193+
"broker_ack": {
194+
"status": "submitted",
195+
"code": "OK",
196+
"message": "SCHD 판매 주문 완료",
197+
"market": "us",
198+
"symbol": "SCHD",
199+
"side": "sell",
200+
"quantity": 1,
201+
"order_type": "limit",
202+
"ordered_at": "2026-05-04T23:40:49+09:00",
203+
"broker_order_id": "V56qyv7r",
204+
"order_no": 3,
205+
"order_date": "2026-05-04",
206+
"is_reserved": False,
207+
"http_status": 200,
208+
},
209+
},
210+
)
211+
212+
ack = entry["broker_ack"]
213+
assert ack["broker_order_id"] == "V56qyv7r"
214+
assert ack["order_no"] == 3
215+
assert ack["order_date"] == "2026-05-04"
216+
assert ack["is_reserved"] is False
217+
assert ack["http_status"] == 200
218+
219+
220+
def test_mutation_journal_preserves_guard_reason_on_blocked_entry(tmp_path) -> None:
221+
path = tmp_path / "mutation-journal.jsonl"
222+
entry = append_mutation_journal(
223+
path,
224+
{
225+
"mutation_id": "mut_blocked",
226+
"kind": "place_order",
227+
"requested_at": "2026-05-05T10:00:00+09:00",
228+
"preview_fingerprint": "sha256:blocked",
229+
"confirm_phrase_hash": "sha256:phrase",
230+
"submit_state": "submit_blocked",
231+
"verification_state": "pending",
232+
"broker_ack": {
233+
"status": "prepared",
234+
"code": "PREPARED",
235+
"message": "prepare preflight succeeded",
236+
"guard_reason": "disabled_by_default",
237+
"market": "us",
238+
"symbol": "AAPL",
239+
"side": "buy",
240+
"quantity": 1,
241+
"order_type": "limit",
242+
},
243+
},
244+
)
245+
246+
assert entry["broker_ack"]["guard_reason"] == "disabled_by_default"
247+
248+
181249
def test_mutation_journal_line_preview_is_sanitized() -> None:
182250
line = mutation_journal_line_preview(
183251
{

0 commit comments

Comments
 (0)