2 lines
6.6 KiB
JSON
2 lines
6.6 KiB
JSON
{"id":21808,"html_url":"https://gitea.hmac.kr/Kyeongmin/C.E.L_Slide_test2/issues/28#issuecomment-21808","pull_request_url":"","issue_url":"https://gitea.hmac.kr/Kyeongmin/C.E.L_Slide_test2/issues/28","user":{"id":28,"login":"Kyeongmin","login_name":"","source_id":0,"full_name":"이경민","email":"kyeongmin@noreply.localhost","avatar_url":"https://gitea.hmac.kr/avatars/d883a35f9197b080b2a0c535c3f9357dcd5c7d40b3c42bd8f40218cb94609a8e","html_url":"https://gitea.hmac.kr/Kyeongmin","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2025-12-30T10:51:04+09:00","restricted":false,"active":false,"prohibit_login":false,"location":"","website":"","description":"","visibility":"public","followers_count":0,"following_count":0,"starred_repos_count":1,"username":"Kyeongmin"},"original_author":"","original_author_id":0,"body":"[Claude #8] Stage 3 code-edit — IMP-28 L4 `_parse_json` dedup (unit u5)\n\nExecuting unit: u5\n\n## unit_executed\n- `u5` — migrate `src/kei_client.py` to the shared `src.json_utils.parse_json` helper.\n\n## files_changed\n- `src/kei_client.py` (modified; net −35 lines: 1477 → 1442)\n\n## diff_summary\n- **Imports** (`src/kei_client.py:6-17`):\n - Added `from src.json_utils import parse_json as _parse_json` (alphabetically placed between `src.config` and `src.sse_utils` to preserve isort grouping).\n - **Kept** `import json` and `import re` — both are used elsewhere in the file (per Stage 2 plan u5 boundary: \"keep `json` / `re` imports — used elsewhere\"). Verified usages enumerated below.\n- **Local helper removal** (`src/kei_client.py:892-925` in pre-edit state):\n - Deleted the 34-line local `_parse_json` definition (fuller form with list-prefix cleanup + 3-pattern fallback).\n - Behavior is preserved by the shared helper — `src.json_utils.parse_json` was verified in u1/u2 as semantic-equivalent to the fuller form (9 pytest cases passing).\n- **Call-sites preserved** (no rename; alias maintains the leading-underscore name across all 13 sites): pre-edit lines 239, 345, 396, 511, 623, 737, 773, 877, 1022, 1117, 1254, 1347, 1459 — all still call `_parse_json(...)` post-edit (line numbers shift only by the import-block +1 line / def-block −34 lines delta; behavior unchanged).\n\n### `json` / `re` retention justification (scope: `src/kei_client.py` HEAD post-edit)\n- `rg \"\\bjson\\.|\\bre\\.\"` in `src/kei_client.py` → 11 matches in code paths unrelated to `_parse_json`:\n - `re.search` / `re.findall` / `re.sub` at L96, L98, L114, L1169, L1187 (terminology/concept detection + `\u003cth\u003e` / `\u003ctr\u003e` HTML parsing in popup table sizing).\n - `json.dumps` at L830, L831, L848, L851, L1416 (overflow-payload + topics + table/image-info serialization for Kei API prompts).\n- After the local-helper removal, the two `re.*` / `json.*` references inside the deleted def (old L919 `re.search`, old L922 `json.loads`, old L923 `json.JSONDecodeError`) are gone — but the surviving 11 occurrences require both modules to remain imported. **Do NOT remove `import json` or `import re`** in this migration unit, per Stage 2 u5 plan and confirmed by post-edit grep.\n\n### External-import verification (scope: repo)\n- `rg \"from src\\.kei_client import.*_parse_json|kei_client\\._parse_json\"` → **0 matches** outside the now-removed local def.\n- No test, no other source, and no script imports `_parse_json` from `kei_client`. The alias-only re-export inside the module is sufficient for the 13 preserved internal call-sites.\n\n### Symbol-count delta verification (scope: `src/kei_client.py`)\n- Pre-edit `_parse_json` occurrences: **14** (1 def at L892 + 13 call-sites).\n- Post-edit `_parse_json` occurrences: **14** (1 alias-import line at L16 + 13 call-sites at L239, L345, L396, L511, L623, L737, L773, L877, L1022, L1117, L1254, L1347, L1459).\n- Net: def → alias-import (−34 lines body removed, +1 line import added = −33; combined with the trailing blank-line cleanup the recorded git delta is −35 lines / 1477 → 1442).\n\n### Remaining local defs (scope: `src/`)\n- `rg \"def _parse_json\" src` → **1 hit**:\n - `src/pipeline.py:2085` (pending — u6, simple form).\n- Confirms u5 boundary: `content_editor.py` (u3) + `design_director.py` (u4) + `kei_client.py` (u5) all migrated; only `pipeline.py` still holds a local def.\n\n### Test verification\n- `python -m pytest tests/test_json_utils.py -q` → **9 passed in 0.02s** (helper semantics intact).\n- `python -m pytest tests/ -q --ignore=tests/matching` → **374 passed in 38.10s** (same count as Stage 3 r2/r3/r4 baselines; no regressions introduced by u5).\n- Smoke import + alias resolution (`python -c` snippet):\n - `src.kei_client._parse_json.__module__` → `src.json_utils` ✓\n - `src.kei_client._parse_json.__name__` → `parse_json` ✓\n - Fenced ` ```json {\"a\":1} ``` ` → `{'a': 1}` ✓\n - Bare `noise {\"x\":2} tail` → `{'x': 2}` ✓\n - List-prefix `- {\"b\":4}` → `{'b': 4}` ✓ (Kei-API list-wrapped JSON path — primary motivation for the fuller form)\n - No-JSON input → `None` ✓\n\n## remaining_units\n- `u6` — migrate `src/pipeline.py` (remove local def at L2085 simple form; alias import `parse_json as _parse_json`; keep `json` / `re` imports — used elsewhere). Fuller form is strict superset; pipeline call-site at L1850 uses `response.content[0].text` with no list-prefix input — promotion is a no-op semantic change.\n\n## follow_up_issue_candidates\n- None within this scope-locked unit. Per Stage 1 Exit Report, doc corrections to `PHASE-Q-INSIGHT-TO-22STEP-MAP.md:152` and `PHASE-Q-AUDIT.md:1161,1180,1215` (which falsely cite `html_generator` as a `_parse_json` carrier) remain deferred to Stage 5 doc-sync.\n\n## scope-lock adherence\n- RULE 0 / RULE 7 (no hardcoding) — pure refactor; no MDX/sample-specific literals; behavior preserved.\n- RULE feedback_one_step_per_turn — only u5 executed this turn; u6 explicitly enumerated as remaining, not started.\n- RULE feedback_workflow_atomicity_rules — single-file Edit sequence inside `src/kei_client.py`; alias-import addition and local-def removal scoped to the one decision unit (helper consolidation for kei_client.py).\n- RULE feedback_factual_verification — `json` / `re` retention justified with value + path (file:line) + upstream (surviving usages enumerated); external-import absence verified via repo-wide grep.\n- RULE feedback_scope_qualified_verification — verification scope for `json` / `re` retention = `src/kei_client.py` HEAD post-edit; alias-import absence elsewhere = repo-wide HEAD. No code committed in this Stage 3 round per orchestrator instruction.\n","assets":[],"created_at":"2026-05-20T20:24:55+09:00","updated_at":"2026-05-20T20:24:55+09:00"}
|