From b87c18df601158c7fff460594ab190155f5397c6 Mon Sep 17 00:00:00 2001 From: Leo Date: Mon, 6 Jul 2026 05:38:10 +0000 Subject: [PATCH] =?UTF-8?q?fix(km-wiki-ingest):=20code=20=E7=AF=80?= =?UTF-8?q?=E9=BB=9E=20post=20=E5=89=8D=E5=89=9D=E9=99=A4=20envelope=20?= =?UTF-8?q?=E7=9A=84=20=5FestSubrequests=EF=BC=88graph=20strict=20schema?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit leo21c 實 ingest 發現:graph /triplets/ingest 為 strict schema,會以 422 unrecognized_keys 拒絕 planEnvelopes 掛在 envelope 上的診斷鍵 _estSubrequests。 修:parse_card 內聯碼在 return 前把每個 envelope 的所有 _-前綴鍵剝除,使 post_one_envelope 的 body_json={{envelope}} 為 ingest-candidate 契約乾淨 payload (source/extractor/nodes/triplets)。已驗:剝除後 entry/nodes/triplets 與原 planCard 逐欄一致。實 ingest(直接驅動同資料流)已用此剝除成功寫入 15 triplets。 Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01HJiLCRUU2o3aSpPEzVCt2o --- registry/examples/km-wiki-ingest/workflow.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/registry/examples/km-wiki-ingest/workflow.yaml b/registry/examples/km-wiki-ingest/workflow.yaml index d86a6a5..0f1632d 100644 --- a/registry/examples/km-wiki-ingest/workflow.yaml +++ b/registry/examples/km-wiki-ingest/workflow.yaml @@ -388,7 +388,17 @@ config: return { entry: parsed.entry, envelopes, meta: parsed.meta, nodeCount: parsed.nodes.length, tripletCount: parsed.triplets.length }; } - return planCard(input.md, input.relPath, input.repo, input.opts || {}); + // graph /triplets/ingest 是 strict schema,拒絕未知鍵。planEnvelopes 於 envelope 上掛的 + // 診斷鍵 _estSubrequests 不在 ingest-candidate 契約內 → post 前剝除所有 _-前綴鍵, + // 讓 post_one_envelope 的 body_json={{envelope}} 為契約乾淨 payload。 + // (leo21c 實測:不剝除會回 422 unrecognized_keys "_estSubrequests"。) + const __plan = planCard(input.md, input.relPath, input.repo, input.opts || {}); + __plan.envelopes = __plan.envelopes.map(function (e) { + const clean = {}; + for (const k in e) { if (k.charAt(0) !== '_') clean[k] = e[k]; } + return clean; + }); + return __plan; input: md: "{{fetch_card.data.body}}"