2.8 KiB
Raw Blame History

affinity_observe公开行协议

ASCII空白分词。字符串和字节清单都以连续十六进制表示,空串/vector写-;Job.id按字节编码,所有数值十进制。每个顶层命令输出一行JSON,多行数据行不另输出。线格式本身有效,业务错误通过API数据表达;core/集合ID读为uint16(0..65535),capacity读为uint8(0..255),priority读为int32,previous读为-1(null)或0..65535。计数0..4096可用于表达超出API容量的非法输入。

  • N text_hex:valid_job_id,输出["N",bool,input_unchanged]。
  • L text_hex / M text_hex:parse_list / parse_mask,output.ids先置旧值,输出[command,error,ids,input_unchanged]。
  • FL count ids... / FM count ids...:以任意顺序的原始CoreSet调用format_list / format_mask,output先置旧字符串,输出[command,error,text,input_unchanged]。
  • O operation left_count left_ids... right_count right_ids...:operation整数转SetOperation,输出["O",error,ids,input_unchanged],输出先置旧ID。
  • C core_count job_count:随后core_count行K id capacity,再job_count行J id_hex priority previous allowed_count ids...。保存全部原始Problem,调用canonical_problem到非空旧输出;输出["C",error,problem,input_unchanged]。无论成功/失败,后续P/B都用这次原始Problem,不自动把它换成规范值。
  • P:make_plan当前原始Problem到非空旧Plan,保存last_plan,输出["P",error,plan,input_unchanged]。
  • B:encode_problem当前原始Problem到非空旧字节vector,保存last_bytes,输出["B",error,bytes_hex,input_unchanged]。
  • D bytes_hex:decode_problem到非空旧Problem,保存last_decoded及本次是否成功,输出["D",error,problem,input_unchanged]。
  • U:仅在最近D成功时,把last_decoded独立复制成当前原始Problem,输出["U",problem];它不调用候选API。
  • H:保存当前last_plan的独立副本,输出["H",held_plan]。Q只读先前保存值,输出["Q",held_plan]。
  • G bank:切换三个独立bank之一(0/1/2),输出["G",raw_problem,last_plan,last_bytes_hex]。每bank初始空Problem/Plan/bytes/held/decoded,未成功D;切换不会调用候选API或推进计算。

CoreSet为ID整数数组。problem为[cores,jobs];core为[id,capacity];job为[id,priority,allowed_ids,previous或null],只在API结果规定时排序。plan为[accepted,retained,bindings,loads],binding为[job_id,core或null],load为[core_id,used]。error none=0/invalid=1,SetOperation unite=0/intersect=1/subtract=2。

所有input_unchanged都是调用前独立保存全部输入再逐字段比较的布尔原始观察,包含原始排列、重复项、字符串及字节。观察器不判断其应为true。JSON空白/转义大小写不额外限制,字符串按字节转义;stderr诊断不参与协议比较。