asset-health flags every Gene with generation_meta as schema_invalid (missing strip-before-validate in assetStoreHealth)

未關閉 適合新手
#643 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
62/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
javascript, json, nodejs
領域
devtools

研究方向

從 evolver-core/dist/assetstore/assetStoreHealth.js 第 158 行附近開始,那裡 schemaValid 在未移除 hints 的情況下呼叫 validateWire(record),接著與 wire/geneHints.js 中對 stripGeneHints(gene) 進行驗證的 intakeGene 比較。重現方式是:對 genes.jsonl 內含 generation_meta 的儲存庫執行 asset-health。完成的標準是:攜帶 generation_meta 的 Gene 不再被計為 schemaInvalid,且 asset-repair 不再建議刪除該欄位。

由索引模型根據 Issue 內容生成。

描述

Summary

evolver asset-health reports schemaInvalidRows for every Gene that carries generation_meta (a field the intake path is explicitly designed to strip before validation). On a store of 33 Genes, the health report returns rows=33, validRows=0, schemaInvalidRows=33, permanently pinning asset-health to degraded. The only CLI-offered remedy, asset-repair --apply, deletes generation_meta and recomputes asset_id, i.e. it destroys provenance and changes the published asset identity in order to turn a counter green.

Environment

  • @evomap/evolver 2.0.48 (npm latest)
  • bundled @evomap/evolver-core 2.0.48, @evomap/gep-sdk 1.14.0
  • Node 22, Linux x64

Minimal reproduction (public API only)

const wire = await import('<evolver>/node_modules/@evomap/evolver-core/dist/wire/index.js');
const rec  = JSON.parse(fs.readFileSync('<store>/assets/genes.jsonl','utf8').split('\n')[0]);
const gs   = JSON.parse(fs.readFileSync('<evolver>/node_modules/@evomap/gep-sdk/schemas/gene.schema.json','utf8'));

wire.validateWire(rec).ok;                        // false
wire.validateWire(wire.stripGeneHints(rec)).ok;   // true
Object.keys(rec).filter(k => !(k in gs.properties)); // [ 'generation_meta' ]
gs.additionalProperties;                          // false

Output on a real record:

id= gene_distilled_xxxxxxxx has generation_meta= true
validateWire(raw).ok = false ["Gene: 多余字段(additionalProperties:false 会 reject): generation_meta"]
validateWire(stripGeneHints(raw)).ok = true
additionalProperties = false | keys not in schema = [ 'generation_meta' ]

CLI side:

$ evolver asset-health --json | jq '.totals'
{"files":4,...,"rows":80,"validRows":46,"schemaInvalidRows":33,...}
# files[0]: kind=Gene file=genes.jsonl rows=33 validRows=0 schemaInvalidRows=33
$ evolver asset-repair --asset gene_distilled_xxxxxxxx --json   # dry run, no --apply
{"status":"ok","changes":[
  {"path":"generation_meta","action":"removed","note":"not declared by the GEP schema"},
  {"path":"asset_id","action":"replaced","note":"recomputed the content id over the repaired record"}]}

Root cause

GENE_HINT_FIELDS = ['generation_meta','model_name'] is defined in wire/geneHints.js precisely so that receiver-side code can strip transport-only hints before schema validation, and intakeGene() does exactly that (validateWire(stripGeneHints(gene))). The asset-store health check bypasses the strip step:

// evolver-core/dist/assetstore/assetStoreHealth.js:158
const schemaValid = kind === 'AntiGene' || validateWire(record).ok;

Because [email protected] gene.schema.json sets additionalProperties:false and does not declare generation_meta, every stored Gene containing that hint is reported as schema-invalid — including Genes that were accepted by the intake path seconds earlier.

Impact

  1. asset-health can never report ok for any store that holds Genes created by the current intake path (i.e. practically all of them), so the health signal is unusable as a regression gate.
  2. The documented remedy (asset-repair --apply) mutates data to satisfy a checker: it drops generation_meta (provenance) and recomputes asset_id, which is the identity used for hub-side verification/publishing. Following the tool's advice can therefore break published asset bindings.
  3. Existing stores created before the health check was updated show the defect as pre-existing rather than a regression (genes.jsonl mtime predates the 2.0.48 upgrade), which makes it easy to misread as data corruption.

Suggested fix

  • In assetStoreHealth, validate the same shape the intake path validates: validateWire(stripGeneHints(record)) for kind === 'Gene' (mirroring intakeGene), or
  • declare generation_meta (and model_name) in gene.schema.json so the wire schema and the accepted-record schema agree.
  • Additionally, asset-repair should not propose removing generation_meta for records that the intake path accepts, and any repair that recomputes asset_id should require an explicit flag / warn that hub-side verification will see a new asset id.

I hit this on a self-hosted node (33 Genes, all created through the normal intake path) and deliberately did not run asset-repair --apply for the reasons above. Happy to test a patch.

主要語言
JavaScript
星號
9.1k
分支
848
平均合併
14 小時 39 分鐘
30 天內合併 PR
1

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

EvoMap/evolver 的其他 Issue

查看 EvoMap/evolver 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。