Offline food lot recall impact tracing and evidence review
moon update
moon test --warn-list=-implicit_impl_as_method --deny-warn
moon run cmd/main --target js --warn-list=-implicit_impl_as_method -- analyze examples/bakery-ledger.json examples/bakery-recall.json markdown
moon run cmd/main --target js --warn-list=-implicit_impl_as_method -- actions examples/bakery-ledger.json examples/bakery-recall.json
moon run cmd/main --target js --warn-list=-implicit_impl_as_method -- readiness examples/bakery-ledger.json examples/bakery-recall.json examples/bakery-counts.csv examples/bakery-responses.csv| 能力 | 输入 | 输出及用途 |
|---|---|---|
| 校验 | 批次、加工、出货记录 | 重复 ID、未知引用、时间倒置、质量不守恒、超额分配等诊断;无效数据拒绝分析 |
| 下游追踪 | 召回种子批次、截点 | 受影响批次、出货、从种子到输出的加工路径 |
| 多来源归因 | 多个可疑种子批次 | 每个输出批次对应的所有可达种子及路径 |
| 上游追踪 | 目标批次、截点 | 生产链上的原料来源和路径 |
| 库存与行动 | 同一账本、召回请求 | 账面可控数量、待核查出货和人工处理清单 |
| 盘点对账 | 现场盘点 CSV | 账面与实测差额、缺失盘点、盘点凭证 |
| 收货方合并 | 受影响出货 | 每个收货方一份待复核清单,避免重复联系 |
| 联系进度 | 人工填写的联系事件 CSV | 待联系、已尝试、已联系、已确认和失败的证据履历 |
| 截点差异 | 原截点、新截点 | 新增受影响批次、出货,便于更新范围 |
| 证据清单 | 盘点与联系记录 | 未盘点、库存差额、未确认出货等未完成项 |
validate LEDGER.json
analyze LEDGER.json RECALL.json [json|markdown|csv]
actions LEDGER.json RECALL.json
inventory LEDGER.json AS_OF
upstream LEDGER.json LOT_ID AS_OF
import-csv LOTS.csv TRANSFORMATIONS.csv SHIPMENTS.csv OUT.json
reconcile LEDGER.json COUNTS.csv AS_OF [json|markdown]
consignees LEDGER.json RECALL.json [json|markdown|csv]
responses LEDGER.json RECALL.json EVENTS.csv [json|markdown]
delta LEDGER.json RECALL.json NEW_AS_OF [json|markdown]
readiness LEDGER.json RECALL.json COUNTS.csv EVENTS.csv [json|markdown]moon fmt
moon info
moon check --target js --warn-list=-implicit_impl_as_method --deny-warn
moon test --warn-list=-implicit_impl_as_method --deny-warnpub(all) struct ActionPlan {
recall_id : String
as_of : Int64
holds : Array[HoldAction]
contacts : Array[ContactAction]
estimated_hold_g : Int64
shipped_for_review_g : Int64
} derive(ToJson, Debug, FromJson)pub(all) struct AttributionReport {
recall_id : String
as_of : Int64
lots : Array[AttributionRow]
shipments : Array[ShipmentAttribution]
} derive(ToJson, Debug, FromJson)pub(all) struct AttributionRow {
lot_id : String
product : String
sources : Array[SourcePath]
} derive(ToJson, Debug, FromJson)pub(all) struct ContactAction {
shipment_id : String
consignee : String
reference : String
quantity_g : Int64
lot_id : String
path : Array[ExposureStep]
} derive(ToJson, Debug, FromJson)pub(all) struct HoldAction {
lot_id : String
facility : String
product : String
estimated_on_hand_g : Int64
classification : String
path : Array[ExposureStep]
} derive(ToJson, Debug, FromJson)pub(all) struct ImpactDelta {
recall_id : String
previous_as_of : Int64
current_as_of : Int64
previous_lot_count : Int
current_lot_count : Int
previous_shipment_count : Int
current_shipment_count : Int
new_lots : Array[AffectedLot]
new_shipments : Array[AffectedShipment]
newly_shipped_g : Int64
} derive(Eq, ToJson, Debug, FromJson)pub(all) struct InventoryReport {
as_of : Int64
rows : Array[InventoryRow]
} derive(ToJson, Debug, FromJson)pub(all) struct RecallReport {
recall_id : String
as_of : Int64
affected_lots : Array[AffectedLot]
affected_shipments : Array[AffectedShipment]
diagnostics : Array[Diagnostic]
} derive(Eq, ToJson, Debug, FromJson)pub(all) struct ShipmentAttribution {
shipment_id : String
lot_id : String
consignee : String
sources : Array[SourcePath]
} derive(ToJson, Debug, FromJson)pub(all) struct SourcePath {
seed_lot : String
path : Array[ExposureStep]
} derive(ToJson, Debug, FromJson)pub(all) struct UpstreamLot {
lot_id : String
product : String
facility : String
quantity_g : Int64
is_source : Bool
path_to_target : Array[ExposureStep]
} derive(ToJson, Debug, FromJson)pub(all) struct UpstreamReport {
target_lot : String
as_of : Int64
lots : Array[UpstreamLot]
} derive(ToJson, Debug, FromJson)fn attribute_sources(ledger : Ledger, request : RecallRequest) -> Result[AttributionReport, ValidationReport]fn compare_cutoffs(ledger : Ledger, request : RecallRequest, current_as_of : Int64) -> Result[ImpactDelta, ValidationReport]fn group_consignees(ledger : Ledger, request : RecallRequest) -> Result[ConsigneeReport, ValidationReport]fn import_csv(lots_csv : String, transformations_csv : String, shipments_csv : String) -> Result[Ledger, ValidationReport]fn reconcile_stock(ledger : Ledger, counts : Array[StockCount], as_of : Int64) -> Result[ReconciliationReport, ValidationReport]fn review_readiness(ledger : Ledger, request : RecallRequest, counts : Array[StockCount], events : Array[ResponseEvent]) -> Result[ReadinessReport, ValidationReport]fn review_responses(ledger : Ledger, request : RecallRequest, events : Array[ResponseEvent]) -> Result[ResponseReport, ValidationReport]fn trace_upstream(ledger : Ledger, target_lot : String, as_of : Int64) -> Result[UpstreamReport, ValidationReport]Install
Download zipOffline food lot recall impact tracing and evidence review