code wiki / _hdl_build / nx_meal_plan.nx
nx_meal_plan.nx
buildroot/runtime/_hdl_build/nx_meal_plan.nx
about
nx_meal_plan.nx -- LIB: the RECIPE + UNIT spine of the meal planner.
A UNIT is whoever is cooking -- a family, one person, a restaurant. The estate's inventory engine is already
domain-keyed, so all three are the SAME engine over a different `domain` string; this file only gives them
names, kinds and an area so a surface can offer "cooking for: the Wests / Ana / Sichuan Spice House" without
any of them being a special case. Nothing here is per-kind.
SIMILARITY IS EXPLAINABLE ON PURPOSE. "More like this" is integer-permille Jaccard over shared ingredients
(1000 * shared / union), so the page can say "shares 6 of 9 ingredients" instead of showing an opaque
affinity score a cook cannot argue with. No float; deterministic; identical inputs always rank identically.
Schema (prefix passed in, e.g. knowledge/store/meal-):
meal:recids -> TAB list of recipe ids
meal:rec:<rid> -> title <t> blurb <t> serves <t> SPACE-separated ingredient ids
meal:units -> TAB list of unit ids
meal:unit:<uid> -> label <t> kind <t> inventory-domain <t> price-area
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 4 imports · 8 importers
imports: nx_food_science.nxnx_inventory.nxnx_seg_store.nxnx_syscalls.nx
imported by: nx_meal_effort.nxnx_meal_emit.nxnx_meal_page.nxnx_meal_plan_gate.nxnx_meal_skills_page.nxnx_skill_request.nxnx_skill_video.nxnx_skills_emit.nx
structs
| none |
consts
| 23 | const MP_TAB: i64 = 9 |
| 24 | const MP_SP: i64 = 32 |
| 25 | const MP_KEYCAP: i64 = 160 |
| 26 | const MP_VALCAP: i64 = 4096 |
| 27 | const MP_LISTCAP: i64 = 8192 |
| 28 | const MP_TOKCAP: i64 = 96 |
| 29 | const MP_MAXITEMS: i64 = 128 |
| 30 | const MP_MAXREC: i64 = 512 |
| 31 | const MP_PERMILLE: i64 = 1000 |
| 34 | const MP_F_TITLE: i64 = 0 |
| 35 | const MP_F_BLURB: i64 = 1 |
| 36 | const MP_F_SERVES: i64 = 2 |
| 37 | const MP_F_ITEMS: i64 = 3 |
| 40 | const MP_U_LABEL: i64 = 0 |
| 41 | const MP_U_KIND: i64 = 1 |
| 42 | const MP_U_DOMAIN: i64 = 2 |
| 43 | const MP_U_AREA: i64 = 3 |
functions
| 48 | func mp_keybuf() -> *u8 { if MP_KB == 0 { MP_KB = sys_mmap(MP_KEYCAP) as i64 } return MP_KB as *u8 } |
| 49 | func mp_pq() -> *i64 { if MP_PQ == 0 { MP_PQ = sys_mmap(16) as i64 } return MP_PQ as *i64 } |
| 50 | func mp_lq() -> *i64 { if MP_LQ == 0 { MP_LQ = sys_mmap(16) as i64 } return MP_LQ as *i64 } |
| 52 | func mp_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: mp_put |
| 54 | func mp_put(prefix: *u8, key: *u8, val: *u8) -> i64 |
| 65 | func mp_split(buf: *u8, len: i64, sep: i64, outtoks: *i64) -> i64 |
| 90 | func mp_list_add(prefix: *u8, key: *u8, token: *u8) -> i64 |
| 114 | func mp_rec_key(rid: *u8, out: *u8) -> i64 |
| 123 | func mp_add_recipe(prefix: *u8, rid: *u8, title: *u8, blurb: *u8, serves: i64, itemlist: *u8) -> i64 |
| 138 | func mp_field(prefix: *u8, rid: *u8, f: i64, out: *u8) -> i64 called by 5: mpg_rendermp_servesmp_itemsmainmsp_render calls 6: mp_keybufmp_rec_keymp_pqmp_lqss_getfd_field |
| 147 | func mp_serves(prefix: *u8, rid: *u8) -> i64 |
| 155 | func mp_items(prefix: *u8, rid: *u8, outtoks: *i64) -> i64 called by 7: mpg_rendermp_sharedmp_similaritymp_missingmp_can_cookmp_nearly+1 calls 3: sys_mmapmp_fieldmp_split |
| 162 | func mp_recipes(prefix: *u8, outtoks: *i64) -> i64 |
| 174 | func mp_ing_key(id: *u8, out: *u8) -> i64 |
| 182 | func mp_add_ingredient(prefix: *u8, id: *u8, name: *u8) -> i64 |
| 190 | func mp_ing_name(prefix: *u8, id: *u8, out: *u8) -> i64 |
| 206 | func mp_unit_key(uid: *u8, out: *u8) -> i64 |
| 214 | func mp_add_unit(prefix: *u8, uid: *u8, label: *u8, kind: *u8, domain: *u8, area: *u8) -> i64 |
| 229 | func mp_unit_field(prefix: *u8, uid: *u8, f: i64, out: *u8) -> i64 |
| 238 | func mp_units(prefix: *u8, outtoks: *i64) -> i64 |
| 247 | func mp_has_item(items: *i64, n: i64, id: *u8) -> i64 |
| 254 | func mp_shared(prefix: *u8, a: *u8, b: *u8) -> i64 |
| 267 | func mp_similarity(prefix: *u8, a: *u8, b: *u8) -> i64 |
| 284 | func mp_similar(prefix: *u8, rid: *u8, out_rids: *i64, out_scores: *i64, max: i64) -> i64 |
| 325 | func mp_missing(inv_prefix: *u8, domain: *u8, prefix: *u8, rid: *u8) -> i64 |
| 336 | func mp_can_cook(inv_prefix: *u8, domain: *u8, prefix: *u8, rid: *u8) -> i64 |
| 345 | func mp_cookable(inv_prefix: *u8, domain: *u8, prefix: *u8, out_rids: *i64, max: i64) -> i64 |
| 361 | func mp_nearly(inv_prefix: *u8, domain: *u8, prefix: *u8, slack: i64, out_rids: *i64, out_missing: *i64, max: i64) -> i64 |