@furongjun1999/dsh-memory 0.9.13 → 0.9.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1293) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/LICENSE +21 -21
  3. package/README.md +129 -3
  4. package/codebuddy/CODEBUDDY.md +8 -3
  5. package/codebuddy/README.md +92 -92
  6. package/codebuddy/mcp.json +27 -27
  7. package/docs/discipline/templates/zcode-user.md.tmpl +52 -52
  8. package/docs//345/267/245/344/275/234/347/272/252/345/276/213_/350/256/244/347/237/245/345/233/276/346/235/241/347/233/256_v1.1.json +488 -461
  9. package/dsh/README.md +82 -82
  10. package/dsh/dsh-web-start.bat +17 -17
  11. package/dsh/hive-mcp-probe.mjs +94 -94
  12. package/dsh/update-lingshu.bat +11 -11
  13. package/dsh/update-lingshu.ps1 +337 -337
  14. package/hive/README.md +705 -705
  15. package/hive/id_charset_blocks.txt +147 -147
  16. package/lib/client.js +18 -0
  17. package/lib/hooks.js +51 -31
  18. package/lib/index.js +3 -44
  19. package/lib/lib/console_web.mjs +96 -0
  20. package/lib/tools.d.ts +2 -2
  21. package/md_cg/__init__.py +7 -7
  22. package/md_cg/auditview.py +248 -248
  23. package/md_cg/backfill.py +1328 -1328
  24. package/md_cg/backfill_bigdomain.py +34 -34
  25. package/md_cg/backfill_bucket_zh.py +35 -35
  26. package/md_cg/bench6_arms.py +414 -414
  27. package/md_cg/bench6_common.py +230 -230
  28. package/md_cg/bench6_competitors.py +212 -212
  29. package/md_cg/bench_axis_domain.py +257 -257
  30. package/md_cg/bench_blind_comp.py +308 -308
  31. package/md_cg/bench_e2e_judge.py +534 -534
  32. package/md_cg/bench_e2e_locomo_qa.py +375 -375
  33. package/md_cg/bench_e2e_qa.py +256 -256
  34. package/md_cg/bench_en_atoms_public.py +230 -230
  35. package/md_cg/bench_governance.py +351 -351
  36. package/md_cg/bench_lme_zh.py +410 -410
  37. package/md_cg/bench_locomo.py +121 -121
  38. package/md_cg/bench_locomo_zh.py +460 -460
  39. package/md_cg/bench_locomo_zh_public.py +147 -147
  40. package/md_cg/bench_longmem.py +112 -112
  41. package/md_cg/bench_membench.py +632 -632
  42. package/md_cg/bench_p0.py +149 -149
  43. package/md_cg/bench_progressive.py +287 -287
  44. package/md_cg/bench_role_views.py +238 -238
  45. package/md_cg/bench_task_ab.py +243 -243
  46. package/md_cg/bench_task_ab_llm.py +408 -408
  47. package/md_cg/bench_unified_en.py +204 -204
  48. package/md_cg/bench_zh_mad.py +611 -611
  49. package/md_cg/blindspot_tickets.py +123 -123
  50. package/md_cg/census.py +133 -133
  51. package/md_cg/codeindex.py +531 -531
  52. package/md_cg/comment_gate.py +337 -337
  53. package/md_cg/cond_compose.py +190 -190
  54. package/md_cg/cond_facts.py +154 -154
  55. package/md_cg/cond_template.json +106 -106
  56. package/md_cg/condition_anchor.py +142 -142
  57. package/md_cg/config_registry_bulk.py +4 -0
  58. package/md_cg/conformance_core.py +28 -0
  59. package/md_cg/consistency.py +9 -2
  60. package/md_cg/corpus.py +110 -110
  61. package/md_cg/crosscheck.py +1098 -1098
  62. package/md_cg/d_meta.py +310 -310
  63. package/md_cg/docindex.py +496 -488
  64. package/md_cg/evolution.py +493 -493
  65. package/md_cg/freshness.py +21 -1
  66. package/md_cg/generation.py +409 -409
  67. package/md_cg/ghostref.py +130 -130
  68. package/md_cg/hotcache.py +5 -1
  69. package/md_cg/lexicon/RULES.md +32 -32
  70. package/md_cg/lexicon/build_cedict_en_zh.py +329 -329
  71. package/md_cg/lexicon/build_standard_en.py +171 -171
  72. package/md_cg/lexicon/cedict_en_zh.json +28322 -28322
  73. package/md_cg/lexicon/char_atoms_clean.json +43813 -43813
  74. package/md_cg/lexicon/expand_en_zh.py +211 -211
  75. package/md_cg/lexicon/standard_en.json +1262 -1262
  76. package/md_cg/linkref.py +280 -280
  77. package/md_cg/mcp_server.py +95 -11
  78. package/md_cg/md_whitebox.py +345 -345
  79. package/md_cg/mdcg.py +309 -24
  80. package/md_cg/mdcos.py +171 -16
  81. package/md_cg/migrate.py +119 -119
  82. package/md_cg/migrate_aeis.py +221 -221
  83. package/md_cg/migrate_roleplay.py +293 -293
  84. package/md_cg/migrate_wisdom_graph.py +360 -360
  85. package/md_cg/mreview/__init__.py +25 -25
  86. package/md_cg/mreview/__main__.py +110 -110
  87. package/md_cg/mreview/bundle.py +178 -178
  88. package/md_cg/mreview/candidates.py +262 -262
  89. package/md_cg/mreview/govern.py +694 -694
  90. package/md_cg/mreview/locate.py +939 -939
  91. package/md_cg/mreview/pipeline.py +742 -742
  92. package/md_cg/mreview/rules/duplication.json +21 -21
  93. package/md_cg/mreview/rules/field_coverage.json +54 -54
  94. package/md_cg/mreview/rules/source_license.json +21 -21
  95. package/md_cg/mreview/rules/template_flow.json +21 -21
  96. package/md_cg/mreview/ruleset.py +252 -252
  97. package/md_cg/nodefile.py +39 -1
  98. package/md_cg/op_table.py +3 -1
  99. package/md_cg/progressive.py +123 -123
  100. package/md_cg/protect.py +29 -6
  101. package/md_cg/protocol/md_cg_gate.proto +33 -33
  102. package/md_cg/qmd_llm.py +334 -334
  103. package/md_cg/relations.py +91 -0
  104. package/md_cg/roleviews.py +89 -89
  105. package/md_cg/scrub.py +20 -3
  106. package/md_cg/security.py +68 -5
  107. package/md_cg/selfreport.py +161 -161
  108. package/md_cg/semantic/REPRODUCE.md +170 -170
  109. package/md_cg/semantic/SCHEMA.md +33 -33
  110. package/md_cg/semantic/__init__.py +10 -10
  111. package/md_cg/semantic/atoms.json +7348 -7348
  112. package/md_cg/semantic/en_normalizer.py +364 -364
  113. package/md_cg/semantic/search_index.json +6199 -6199
  114. package/md_cg/session5.py +106 -106
  115. package/md_cg/srcindex.py +352 -352
  116. package/md_cg/statushdr.py +179 -179
  117. package/md_cg/tasks.py +26 -0
  118. package/md_cg/test_access_hints.py +147 -147
  119. package/md_cg/test_audit_rotate.py +270 -270
  120. package/md_cg/test_auditview.py +277 -277
  121. package/md_cg/test_autonomy.py +143 -143
  122. package/md_cg/test_autonomy_admission.py +1098 -1098
  123. package/md_cg/test_b1_auto_id_multiproc.py +284 -284
  124. package/md_cg/test_b1_foreign_read.py +244 -244
  125. package/md_cg/test_b1b2_write_face.py +424 -424
  126. package/md_cg/test_b2_sensitivity_landing.py +223 -223
  127. package/md_cg/test_b3_merge_keeps_content.py +583 -583
  128. package/md_cg/test_b4_shard_dir_selfheal.py +880 -843
  129. package/md_cg/test_b4_shard_dir_selfheal_guard.py +249 -238
  130. package/md_cg/test_bench_governance.py +102 -102
  131. package/md_cg/test_blindspot_tickets.py +166 -166
  132. package/md_cg/test_boundary_hit.py +410 -410
  133. package/md_cg/test_branch_discard_tombstone.py +136 -136
  134. package/md_cg/test_ccg_perturb.py +184 -184
  135. package/md_cg/test_ccgc.py +458 -458
  136. package/md_cg/test_census_prune.py +81 -81
  137. package/md_cg/test_chain_read_isolate.py +168 -168
  138. package/md_cg/test_codeindex.py +338 -338
  139. package/md_cg/test_coldverify_drain.py +127 -127
  140. package/md_cg/test_comment_gate.py +187 -187
  141. package/md_cg/test_cond_compose_anchors.py +76 -76
  142. package/md_cg/test_cond_match.py +165 -165
  143. package/md_cg/test_condition_anchor.py +81 -81
  144. package/md_cg/test_config_registry.py +55 -55
  145. package/md_cg/test_cons200_scan_selection.py +793 -793
  146. package/md_cg/test_corrupt_utf8_read_surfaces.py +451 -451
  147. package/md_cg/test_crypto_rotate.py +256 -256
  148. package/md_cg/test_csre_index_import_guard.py +161 -161
  149. package/md_cg/test_curiosity_budget.py +468 -468
  150. package/md_cg/test_d17_autostart_toolface.py +453 -453
  151. package/md_cg/test_d_meta.py +412 -412
  152. package/md_cg/test_datapath_root.py +199 -199
  153. package/md_cg/test_designer_token_coverage.py +184 -0
  154. package/md_cg/test_emit_negtail_cache.py +156 -156
  155. package/md_cg/test_export_default_collision.py +138 -138
  156. package/md_cg/test_gain_gate.py +223 -223
  157. package/md_cg/test_generation_guard.py +361 -361
  158. package/md_cg/test_ghostref.py +182 -182
  159. package/md_cg/test_goal_gen.py +355 -355
  160. package/md_cg/test_govern_directread.py +434 -434
  161. package/md_cg/test_health_scale.py +173 -173
  162. package/md_cg/test_heartbeat_ledger.py +563 -563
  163. package/md_cg/test_hive_ingest.py +285 -285
  164. package/md_cg/test_hot_cold.py +215 -215
  165. package/md_cg/test_hyperedge.py +245 -245
  166. package/md_cg/test_i50a_half_dup_defer.py +408 -408
  167. package/md_cg/test_i50b_defer_to_review_queue.py +545 -545
  168. package/md_cg/test_i50d_importance_source.py +531 -531
  169. package/md_cg/test_i50e_readside_protection.py +9 -3
  170. package/md_cg/test_identity_contract.py +329 -329
  171. package/md_cg/test_index_crossprocess_reload.py +316 -316
  172. package/md_cg/test_issue218_postcondition_value_blind.py +4 -2
  173. package/md_cg/test_issue39_utf8_stdio.py +572 -572
  174. package/md_cg/test_issue452_ingest_root_sensitivity.py +2 -0
  175. package/md_cg/test_issue52_scan_condition_first.py +677 -677
  176. package/md_cg/test_issue53_cipher_health_hash.py +385 -385
  177. package/md_cg/test_issue650_658_f26.py +98 -0
  178. package/md_cg/test_issue659_r26_batch2.py +74 -0
  179. package/md_cg/test_issue659_r26_batch3.py +38 -0
  180. package/md_cg/test_issue665_scrub_process_records.py +59 -0
  181. package/md_cg/test_issue669_ccg_empty_colon.py +69 -0
  182. package/md_cg/test_issue66_scrub_semantics.py +107 -107
  183. package/md_cg/test_issue672_optional_assets.py +49 -0
  184. package/md_cg/test_issue672_validity_scope.py +47 -0
  185. package/md_cg/test_issue676_session_tasks_index_first.py +74 -0
  186. package/md_cg/test_issue677_async_index_flush.py +216 -0
  187. package/md_cg/test_issue677_dedupe_gate.py +67 -0
  188. package/md_cg/test_issue678_narrowed_hint.py +60 -0
  189. package/md_cg/test_issue67_scrub_control_pool.py +233 -233
  190. package/md_cg/test_issue69_audit_boundary.py +129 -129
  191. package/md_cg/test_issue73_doc_chapter_refs.py +326 -326
  192. package/md_cg/test_issue78_export_concurrency.py +334 -334
  193. package/md_cg/test_issue80_residual_flush.py +169 -169
  194. package/md_cg/test_issue84_portability.py +95 -95
  195. package/md_cg/test_issue85_export_overwrite.py +113 -113
  196. package/md_cg/test_issue86_runtime_revoke.py +110 -110
  197. package/md_cg/test_issue87_default_sensitivity_single.py +201 -201
  198. package/md_cg/test_issue88_conclusion_face.py +280 -280
  199. package/md_cg/test_issue89_zero_score.py +169 -169
  200. package/md_cg/test_issue91_verifier_timeout.py +528 -528
  201. package/md_cg/test_issue96_key_fallback.py +102 -102
  202. package/md_cg/test_issue98_tenant_root.py +104 -104
  203. package/md_cg/test_legacy_p3_node_id_type.py +375 -375
  204. package/md_cg/test_lifecycle.py +309 -309
  205. package/md_cg/test_lifecycle_retire_leak.py +498 -498
  206. package/md_cg/test_linkref.py +320 -320
  207. package/md_cg/test_links_concurrent_write.py +188 -188
  208. package/md_cg/test_lock.py +52 -52
  209. package/md_cg/test_m3_h9_bucket_health_protect_mark.py +301 -301
  210. package/md_cg/test_m3_h9_semantic_guard.py +525 -525
  211. package/md_cg/test_md_writepath.py +345 -345
  212. package/md_cg/test_merge_upsert.py +168 -168
  213. package/md_cg/test_mode_parity.py +23 -0
  214. package/md_cg/test_mr_m2.py +615 -599
  215. package/md_cg/test_mr_m3.py +710 -710
  216. package/md_cg/test_mr_m4.py +485 -485
  217. package/md_cg/test_n131_merge_gate.py +205 -205
  218. package/md_cg/test_n139_dek_provision_failclosed.py +185 -185
  219. package/md_cg/test_n176_link_trust.py +221 -221
  220. package/md_cg/test_n178_units_jobid_gate.py +212 -212
  221. package/md_cg/test_n184_keys_concurrent_provision.py +307 -307
  222. package/md_cg/test_n195_writepath_reload.py +283 -283
  223. package/md_cg/test_n196_stale_gate_skip.py +169 -169
  224. package/md_cg/test_n197_n208_write_face_gates.py +471 -471
  225. package/md_cg/test_n198_tokens_corrupt_failclosed.py +225 -225
  226. package/md_cg/test_n199_tokens_concurrent_write.py +378 -378
  227. package/md_cg/test_n201_proposal_visibility.py +382 -382
  228. package/md_cg/test_n202_session_notes_visibility.py +461 -461
  229. package/md_cg/test_n204_n205_n226_n227_n228_n229_exit_gates.py +542 -542
  230. package/md_cg/test_n206_stdio_jsonrpc_type.py +403 -403
  231. package/md_cg/test_n212_n213_n224_generation_gates.py +519 -519
  232. package/md_cg/test_n214_n215_n221_n222_write_face_gates.py +570 -570
  233. package/md_cg/test_n225_nonobject_load.py +1110 -1110
  234. package/md_cg/test_n230_dirty_replay.py +18 -5
  235. package/md_cg/test_n238_body_text_parity.py +156 -156
  236. package/md_cg/test_n276_probe_hoist.py +199 -199
  237. package/md_cg/test_neg_condition_hits.py +333 -333
  238. package/md_cg/test_neg_coverage_budget.py +500 -500
  239. package/md_cg/test_none_id_write_guard.py +166 -166
  240. package/md_cg/test_opt_batch1_md_cg.py +451 -451
  241. package/md_cg/test_p0.py +264 -264
  242. package/md_cg/test_p1.py +316 -316
  243. package/md_cg/test_p10_identity.py +173 -173
  244. package/md_cg/test_p11_consistency.py +382 -382
  245. package/md_cg/test_p12_metacognition.py +212 -212
  246. package/md_cg/test_p13_encryption.py +241 -241
  247. package/md_cg/test_p14_root_fallback.py +373 -373
  248. package/md_cg/test_p14_sustain.py +249 -249
  249. package/md_cg/test_p15_scrub.py +280 -280
  250. package/md_cg/test_p16_self_state.py +301 -301
  251. package/md_cg/test_p17_predict.py +354 -354
  252. package/md_cg/test_p18_whitebox.py +171 -171
  253. package/md_cg/test_p19_migrate_roleplay.py +149 -149
  254. package/md_cg/test_p1x_ref_root.py +197 -197
  255. package/md_cg/test_p2.py +216 -216
  256. package/md_cg/test_p20_evolution.py +315 -315
  257. package/md_cg/test_p22_theory.py +175 -175
  258. package/md_cg/test_p23_links.py +311 -311
  259. package/md_cg/test_p25_weights.py +156 -156
  260. package/md_cg/test_p26_refindex.py +433 -433
  261. package/md_cg/test_p29_session_ingest_export.py +360 -360
  262. package/md_cg/test_p30_maintain.py +361 -361
  263. package/md_cg/test_p31_insight.py +535 -535
  264. package/md_cg/test_p34_crosscheck.py +331 -331
  265. package/md_cg/test_p35_conditioned_claim.py +252 -252
  266. package/md_cg/test_p36_kp_align.py +230 -230
  267. package/md_cg/test_p37_condition_space.py +248 -248
  268. package/md_cg/test_p38_contextualize.py +273 -273
  269. package/md_cg/test_p39_vision_evidence.py +369 -369
  270. package/md_cg/test_p41_evolve_patrol.py +224 -224
  271. package/md_cg/test_p42_provenance.py +269 -269
  272. package/md_cg/test_p44_md_whitebox.py +231 -231
  273. package/md_cg/test_p45_session_identity.py +466 -466
  274. package/md_cg/test_p46_unit_scope.py +272 -272
  275. package/md_cg/test_p4_fuzzy.py +223 -223
  276. package/md_cg/test_p5_semantic.py +226 -226
  277. package/md_cg/test_p6_consolidate.py +822 -822
  278. package/md_cg/test_p7_goals_recent.py +202 -202
  279. package/md_cg/test_p83_jsonrpc_parse_error.py +124 -124
  280. package/md_cg/test_p8_subgraph_chain.py +213 -213
  281. package/md_cg/test_p9_forget_protect.py +238 -238
  282. package/md_cg/test_preflight_failclosed.py +100 -100
  283. package/md_cg/test_progressive.py +146 -146
  284. package/md_cg/test_propose_tail_index.py +157 -157
  285. package/md_cg/test_protect_stats_parity.py +141 -0
  286. package/md_cg/test_protocol.py +272 -272
  287. package/md_cg/test_rank_parity_score_mode.py +522 -522
  288. package/md_cg/test_reach_keys.py +201 -201
  289. package/md_cg/test_read_clip.py +141 -141
  290. package/md_cg/test_read_face_input_gates.py +363 -363
  291. package/md_cg/test_read_face_semantics.py +492 -492
  292. package/md_cg/test_read_scope_b27.py +277 -277
  293. package/md_cg/test_readcache_default_on.py +168 -168
  294. package/md_cg/test_readcache_precise_inval.py +270 -270
  295. package/md_cg/test_recall_metadata.py +422 -422
  296. package/md_cg/test_reconcile_v0.py +294 -294
  297. package/md_cg/test_retr_s1.py +344 -344
  298. package/md_cg/test_retr_s1b.py +276 -276
  299. package/md_cg/test_retr_s3.py +194 -194
  300. package/md_cg/test_retr_s4.py +163 -163
  301. package/md_cg/test_retr_s6.py +157 -157
  302. package/md_cg/test_retr_s7.py +392 -392
  303. package/md_cg/test_retr_s8_time.py +369 -369
  304. package/md_cg/test_retr_s9_edges.py +286 -286
  305. package/md_cg/test_retr_score_once.py +220 -220
  306. package/md_cg/test_review_cli_attribution.py +181 -181
  307. package/md_cg/test_review_cli_visibility.py +235 -235
  308. package/md_cg/test_review_conformance.py +385 -385
  309. package/md_cg/test_review_dual_check.py +97 -0
  310. package/md_cg/test_review_onepass.py +170 -170
  311. package/md_cg/test_review_queue_batch.py +123 -123
  312. package/md_cg/test_review_queue_index.py +130 -130
  313. package/md_cg/test_role_views.py +354 -354
  314. package/md_cg/test_rrf_graph_seed_cache.py +154 -154
  315. package/md_cg/test_security_audit_v21.py +249 -249
  316. package/md_cg/test_sem_noise.py +242 -242
  317. package/md_cg/test_server_version.py +67 -67
  318. package/md_cg/test_session5_identity.py +93 -93
  319. package/md_cg/test_session_attribution_consistency.py +813 -813
  320. package/md_cg/test_session_identity_tristate.py +486 -486
  321. package/md_cg/test_session_isolation.py +168 -168
  322. package/md_cg/test_sleep.py +668 -668
  323. package/md_cg/test_sleep_gitlock.py +134 -134
  324. package/md_cg/test_snapshot_autoclose.py +187 -187
  325. package/md_cg/test_spatial_coords3d.py +292 -292
  326. package/md_cg/test_srcindex.py +171 -171
  327. package/md_cg/test_state_events.py +178 -178
  328. package/md_cg/test_state_slots.py +691 -691
  329. package/md_cg/test_subproc_encoding.py +192 -192
  330. package/md_cg/test_sustain_mutual.py +153 -153
  331. package/md_cg/test_tail_watermark_race.py +208 -208
  332. package/md_cg/test_tasks.py +409 -409
  333. package/md_cg/test_tenant_env_override_warn.py +152 -152
  334. package/md_cg/test_tenant_registry_corrupt_warn.py +151 -151
  335. package/md_cg/test_time_core_lint.py +9 -0
  336. package/md_cg/test_token_lowercase_form.py +315 -315
  337. package/md_cg/test_transfer.py +180 -180
  338. package/md_cg/test_trust.py +361 -361
  339. package/md_cg/test_twophase.py +286 -286
  340. package/md_cg/test_ui_wiring_in_repo.py +113 -0
  341. package/md_cg/test_unify_default_off.py +701 -701
  342. package/md_cg/test_unify_scope.py +182 -182
  343. package/md_cg/test_units_poll.py +71 -71
  344. package/md_cg/test_v21r1_package_version.py +310 -310
  345. package/md_cg/test_validity_filter.py +280 -280
  346. package/md_cg/test_verify_answer.py +138 -138
  347. package/md_cg/test_verify_dirty_reconcile.py +157 -157
  348. package/md_cg/test_w5_path_fingerprint.py +381 -381
  349. package/md_cg/test_wisdom_md_store.py +292 -292
  350. package/md_cg/test_writegate_tiers.py +111 -0
  351. package/md_cg/test_writelimit.py +224 -224
  352. package/md_cg/test_writepipe.py +4 -2
  353. package/md_cg/tokens.py +114 -8
  354. package/md_cg/units.py +869 -869
  355. package/md_cg/version_anchor.py +160 -0
  356. package/md_cg/vision_evidence.py +667 -667
  357. package/md_cg/whitebox_kb/__init__.py +37 -37
  358. package/md_cg/whitebox_kb/aeis_core/__init__.py +42 -42
  359. package/md_cg/whitebox_kb/aeis_core/api.py +1047 -1047
  360. package/md_cg/whitebox_kb/aeis_core/semantic.py +280 -280
  361. package/md_cg/whitebox_kb/aeis_core/textutil.py +13 -13
  362. package/md_cg/whitebox_kb/aeis_core/time_core.py +51 -51
  363. package/md_cg/whitebox_kb/engine.py +310 -310
  364. package/md_cg/whitebox_kb/seed_knowledge/__init__.py +2 -2
  365. package/md_cg/whitebox_kb/seed_knowledge/guardrail-charter.md +164 -164
  366. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//344/270/255/345/233/275/345/217/244/344/273/243/346/226/207/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +113 -113
  367. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//344/270/255/345/233/275/347/216/260/344/273/243/346/226/207/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +89 -89
  368. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//344/272/272/345/267/245/346/231/272/350/203/275/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +121 -121
  369. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//344/272/272/347/261/273/350/247/202/345/257/237/350/200/205/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +161 -161
  370. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//344/274/232/350/256/241/345/255/246/345/216/237/347/220/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +89 -89
  371. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//344/277/241/346/201/257/350/256/272/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +90 -90
  372. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/210/206/345/255/220/347/224/237/347/211/251/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +113 -113
  373. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/210/206/346/236/220/345/214/226/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +113 -113
  374. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/210/235/344/270/255/345/214/226/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +241 -241
  375. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/210/235/344/270/255/345/216/206/345/217/262/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +117 -117
  376. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/210/235/344/270/255/345/234/260/347/220/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +109 -109
  377. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/210/235/344/270/255/346/225/260/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +241 -241
  378. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/210/235/344/270/255/347/211/251/347/220/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +317 -317
  379. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/210/235/344/270/255/347/224/237/347/211/251/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +261 -261
  380. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/210/235/344/270/255/350/213/261/350/257/255/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +113 -113
  381. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/210/235/344/270/255/350/257/255/346/226/207/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +113 -113
  382. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/210/235/344/270/255/351/201/223/345/276/267/344/270/216/346/263/225/346/262/273/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +105 -105
  383. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/212/250/347/211/251/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +101 -101
  384. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/214/226/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +1194 -1194
  385. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/214/226/345/267/245/345/216/237/347/220/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +113 -113
  386. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/214/273/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +111 -111
  387. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/216/206/345/217/262/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +278 -278
  388. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/216/237/345/255/220/347/211/251/347/220/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +97 -97
  389. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/217/244/344/273/243/346/261/211/350/257/255/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +97 -97
  390. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/223/262/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +111 -111
  391. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/233/272/344/275/223/347/211/251/347/220/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +133 -133
  392. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/234/237/346/234/250/345/267/245/347/250/213/345/237/272/347/241/200/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +89 -89
  393. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/234/260/347/220/206/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +154 -154
  394. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/244/215/345/217/230/345/207/275/346/225/260/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +129 -129
  395. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/244/226/345/233/275/346/226/207/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +85 -85
  396. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/244/247/345/255/246/345/214/226/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +169 -169
  397. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/244/247/345/255/246/346/200/235/346/224/277/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +117 -117
  398. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/244/247/345/255/246/347/211/251/347/220/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +201 -201
  399. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/244/247/345/255/246/350/213/261/350/257/255/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +93 -93
  400. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/244/251/344/275/223/347/211/251/347/220/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +89 -89
  401. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/244/251/346/226/207/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +131 -131
  402. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/256/217/350/247/202/347/273/217/346/265/216/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +105 -105
  403. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/256/236/345/217/230/345/207/275/346/225/260/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +129 -129
  404. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/260/217/345/255/246/346/225/260/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +333 -333
  405. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/260/217/345/255/246/347/247/221/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +1124 -1124
  406. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/260/217/345/255/246/350/213/261/350/257/255/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +105 -105
  407. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/260/217/345/255/246/350/257/255/346/226/207/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +117 -117
  408. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/260/217/345/255/246/351/201/223/345/276/267/344/270/216/346/263/225/346/262/273/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +105 -105
  409. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/267/245/347/250/213/345/210/266/345/233/276/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +85 -85
  410. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/267/245/347/250/213/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +362 -362
  411. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/270/202/345/234/272/350/220/245/351/224/200/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +81 -81
  412. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/270/270/345/276/256/345/210/206/346/226/271/347/250/213/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +153 -153
  413. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/276/256/345/210/206/345/207/240/344/275/225/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +101 -101
  414. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/276/256/347/224/237/347/211/251/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +97 -97
  415. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/276/256/350/247/202/347/273/217/346/265/216/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +101 -101
  416. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//345/277/203/347/220/206/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +119 -119
  417. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/203/205/346/204/237/346/203/205/347/273/252/344/273/277/347/234/237/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +186 -186
  418. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/212/275/350/261/241/344/273/243/346/225/260/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +109 -109
  419. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/213/223/346/211/221/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +97 -97
  420. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/223/215/344/275/234/347/263/273/347/273/237/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +109 -109
  421. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/224/277/346/262/273/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +234 -234
  422. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/225/260/345/200/274/345/210/206/346/236/220/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +133 -133
  423. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/225/260/345/255/227/347/224/265/350/267/257/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +101 -101
  424. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/225/260/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +1166 -1166
  425. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/225/260/345/255/246/345/210/206/346/236/220/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +217 -217
  426. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/225/260/345/255/246/347/211/251/347/220/206/346/226/271/346/263/225/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +105 -105
  427. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/225/260/346/215/256/345/272/223/347/263/273/347/273/237/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +101 -101
  428. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/225/260/346/215/256/347/273/223/346/236/204/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +117 -117
  429. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/226/207/345/255/246/347/220/206/350/256/272/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +89 -89
  430. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/227/240/346/234/272/345/214/226/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +141 -141
  431. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/227/266/347/251/272/350/256/260/345/277/206/345/233/276/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +214 -214
  432. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/231/272/350/203/275/350/256/272/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +350 -350
  433. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/234/211/346/234/272/345/214/226/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +129 -129
  434. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/235/220/346/226/231/345/212/233/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +101 -101
  435. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/235/241/344/273/266/350/256/272/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +350 -350
  436. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/244/215/347/211/251/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +89 -89
  437. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/246/202/347/216/207/350/256/272/344/270/216/346/225/260/347/220/206/347/273/237/350/256/241/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +149 -149
  438. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/250/241/346/213/237/347/224/265/345/255/220/346/212/200/346/234/257/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +101 -101
  439. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//346/263/233/345/207/275/345/210/206/346/236/220/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +125 -125
  440. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/203/255/345/212/233/345/255/246/344/270/216/347/273/237/350/256/241/347/211/251/347/220/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +125 -125
  441. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/211/251/347/220/206/345/214/226/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +129 -129
  442. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/211/251/347/220/206/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +1302 -1302
  443. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/216/260/344/273/243/346/261/211/350/257/255/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +89 -89
  444. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/220/206/350/256/272/345/212/233/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +137 -137
  445. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/224/237/346/200/201/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +93 -93
  446. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/224/237/347/211/251/345/214/226/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +137 -137
  447. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/224/237/347/211/251/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +1018 -1018
  448. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/224/237/347/220/206/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +93 -93
  449. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/224/265/345/212/250/345/212/233/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +125 -125
  450. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/224/265/350/267/257/345/216/237/347/220/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +101 -101
  451. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/244/276/344/274/232/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +111 -111
  452. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/250/213/345/272/217/350/256/276/350/256/241/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +101 -101
  453. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/256/227/346/263/225/350/256/276/350/256/241/344/270/216/345/210/206/346/236/220/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +105 -105
  454. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/256/241/347/220/206/345/255/246/345/216/237/347/220/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +89 -89
  455. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/272/277/346/200/247/344/273/243/346/225/260/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +133 -133
  456. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/273/206/350/203/236/347/224/237/347/211/251/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +121 -121
  457. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/273/217/346/265/216/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +169 -169
  458. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/273/223/346/236/204/345/214/226/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +105 -105
  459. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/273/274/345/220/210/302/267/347/273/264/345/237/272/347/273/274/350/277/260.md +184 -184
  460. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//347/274/226/350/257/221/345/216/237/347/220/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +101 -101
  461. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//350/207/252/346/210/221/346/204/217/350/257/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +270 -270
  462. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//350/256/241/347/256/227/346/234/272/347/247/221/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +698 -698
  463. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//350/256/241/347/256/227/346/234/272/347/273/204/346/210/220/345/216/237/347/220/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +109 -109
  464. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//350/256/241/347/256/227/346/234/272/347/275/221/347/273/234/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +109 -109
  465. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//350/257/255/350/250/200/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +226 -226
  466. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//350/275/257/344/273/266/345/267/245/347/250/213/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +97 -97
  467. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//351/201/227/344/274/240/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +113 -113
  468. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//351/207/217/345/255/220/345/212/233/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +137 -137
  469. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//351/207/221/350/236/215/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +89 -89
  470. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//351/253/230/344/270/255/345/214/226/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +341 -341
  471. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//351/253/230/344/270/255/345/216/206/345/217/262/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +101 -101
  472. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//351/253/230/344/270/255/345/234/260/347/220/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +97 -97
  473. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//351/253/230/344/270/255/346/200/235/346/203/263/346/224/277/346/262/273/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +117 -117
  474. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//351/253/230/344/270/255/346/225/260/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +341 -341
  475. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//351/253/230/344/270/255/347/211/251/347/220/206/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +365 -365
  476. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//351/253/230/344/270/255/347/224/237/347/211/251/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +269 -269
  477. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//351/253/230/344/270/255/350/213/261/350/257/255/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +113 -113
  478. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//351/253/230/344/270/255/350/257/255/346/226/207/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +105 -105
  479. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//351/253/230/345/210/206/345/255/220/345/214/226/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +101 -101
  480. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//351/253/230/347/255/211/344/273/243/346/225/260/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +157 -157
  481. package/md_cg/whitebox_kb/seed_knowledge/wisdom_cards//351/253/230/347/255/211/346/225/260/345/255/246/302/267/347/237/245/350/257/206/347/273/274/350/277/260.md +237 -237
  482. package/md_cg/whitebox_kb/seed_knowledge//346/231/272/350/203/275/350/256/2723.4.md +5260 -5260
  483. package/md_cg/whitebox_kb/wisdom/__init__.py +6 -6
  484. package/md_cg/whitebox_kb/wisdom/answer_spec_anchor.py +87 -87
  485. package/md_cg/whitebox_kb/wisdom/browser_units.py +2631 -2631
  486. package/md_cg/whitebox_kb/wisdom/card_validator.py +223 -223
  487. package/md_cg/whitebox_kb/wisdom/causal_discover.py +432 -432
  488. package/md_cg/whitebox_kb/wisdom/chat.html +185 -185
  489. package/md_cg/whitebox_kb/wisdom/code_qa.py +119 -119
  490. package/md_cg/whitebox_kb/wisdom/code_route_bridge.py +90 -90
  491. package/md_cg/whitebox_kb/wisdom/code_test_runner.py +217 -217
  492. package/md_cg/whitebox_kb/wisdom/codegraph_white.py +312 -312
  493. package/md_cg/whitebox_kb/wisdom/compiler_compose.py +160 -160
  494. package/md_cg/whitebox_kb/wisdom/condition_algebra.py +112 -112
  495. package/md_cg/whitebox_kb/wisdom/condition_frame.py +315 -315
  496. package/md_cg/whitebox_kb/wisdom/condition_kb.py +108 -108
  497. package/md_cg/whitebox_kb/wisdom/condition_vm.py +264 -264
  498. package/md_cg/whitebox_kb/wisdom/conflict_map.json +4445 -4445
  499. package/md_cg/whitebox_kb/wisdom/core/compiler.py +301 -301
  500. package/md_cg/whitebox_kb/wisdom/core/lexer.py +512 -512
  501. package/md_cg/whitebox_kb/wisdom/core/name_checker.py +1023 -1023
  502. package/md_cg/whitebox_kb/wisdom/cspmn.py +258 -258
  503. package/md_cg/whitebox_kb/wisdom/danmaku_audit.py +252 -252
  504. package/md_cg/whitebox_kb/wisdom/danmaku_bridge.py +141 -141
  505. package/md_cg/whitebox_kb/wisdom/distilled_condition_units.json +6417 -6417
  506. package/md_cg/whitebox_kb/wisdom/docs/WB-EVAL-20260902b.json +1950 -1950
  507. package/md_cg/whitebox_kb/wisdom/docs/WB-EVAL-20260902c.json +1296 -1296
  508. package/md_cg/whitebox_kb/wisdom/docs/codegraph_ref_rating.md +52 -52
  509. package/md_cg/whitebox_kb/wisdom/docs/daoti_absorb_analysis.md +54 -54
  510. package/md_cg/whitebox_kb/wisdom/docs/dsh_memory_v030_stable.md +34 -34
  511. package/md_cg/whitebox_kb/wisdom/docs/github_absorb_analysis.md +71 -71
  512. package/md_cg/whitebox_kb/wisdom/docs/gliding_horse_absorb_analysis.md +47 -47
  513. package/md_cg/whitebox_kb/wisdom/docs/whitebox_capability_graph.md +61 -61
  514. package/md_cg/whitebox_kb/wisdom/docs/whitebox_capability_graph_demo.json +59 -59
  515. package/md_cg/whitebox_kb/wisdom/docs/whitebox_code_rating_202609.md +43 -43
  516. package/md_cg/whitebox_kb/wisdom/docs//344/273/243/347/240/201/346/235/241/344/273/266/350/267/257/347/224/261/345/233/276_CCG/350/256/276/350/256/241.md +150 -150
  517. package/md_cg/whitebox_kb/wisdom/docs//344/273/243/347/240/201/350/257/255/344/271/211/346/235/241/344/273/266/345/215/217/350/256/256.md +650 -650
  518. package/md_cg/whitebox_kb/wisdom/docs//345/261/200/351/203/250/346/234/200/344/274/230/344/270/216/346/203/205/347/273/252/345/201/217/345/245/275_/347/220/206/350/256/272/345/267/245/347/250/213.md +97 -97
  519. package/md_cg/whitebox_kb/wisdom/docs//346/226/271/345/220/221/346/200/247/346/212/211/346/213/251_/350/207/252/344/270/276vs/350/207/252/350/277/255/344/273/243.md +81 -81
  520. package/md_cg/whitebox_kb/wisdom/docs//347/201/265/346/236/242AGI/346/236/266/346/236/204/346/216/242/347/264/242_/346/226/207/346/241/243/350/247/204/345/210/222.md +51 -51
  521. package/md_cg/whitebox_kb/wisdom/docs//347/201/265/346/236/242/346/217/222/344/273/266/345/210/206/347/261/273/345/210/206/346/236/220.md +67 -67
  522. package/md_cg/whitebox_kb/wisdom/docs//347/231/275/347/256/261/346/234/254/345/234/260/346/240/241/351/252/214/345/231/250_ZeroLLM_Verifier.md +276 -276
  523. package/md_cg/whitebox_kb/wisdom/docs//347/231/275/347/256/261/350/207/252/344/270/276/347/254/254/345/205/255/351/230/266/346/256/265_/346/224/266/345/256/230/346/200/273/347/273/223.md +1207 -1207
  524. package/md_cg/whitebox_kb/wisdom/ds_compose.py +177 -177
  525. package/md_cg/whitebox_kb/wisdom/graph_db_units.py +3089 -3089
  526. package/md_cg/whitebox_kb/wisdom/graph_qa.py +123 -123
  527. package/md_cg/whitebox_kb/wisdom/human_observer_knowledge.json +43 -43
  528. package/md_cg/whitebox_kb/wisdom/knowledge_points.py +318 -318
  529. package/md_cg/whitebox_kb/wisdom/md_store.py +276 -276
  530. package/md_cg/whitebox_kb/wisdom/merge_subgraph.py +178 -178
  531. package/md_cg/whitebox_kb/wisdom/neural_retrieve.py +314 -314
  532. package/md_cg/whitebox_kb/wisdom/os_units.py +2735 -2735
  533. package/md_cg/whitebox_kb/wisdom/pattern_separation.py +376 -376
  534. package/md_cg/whitebox_kb/wisdom/prereq_map.json +364 -364
  535. package/md_cg/whitebox_kb/wisdom/python_code_units.py +2766 -2766
  536. package/md_cg/whitebox_kb/wisdom/role_compose.py +268 -268
  537. package/md_cg/whitebox_kb/wisdom/role_solidified.json +7 -7
  538. package/md_cg/whitebox_kb/wisdom/route_memory.py +244 -244
  539. package/md_cg/whitebox_kb/wisdom/scene_reconstruction.py +148 -148
  540. package/md_cg/whitebox_kb/wisdom/se_compose.py +137 -137
  541. package/md_cg/whitebox_kb/wisdom/snr_dashboard.py +219 -219
  542. package/md_cg/whitebox_kb/wisdom/snr_report.json +40 -40
  543. package/md_cg/whitebox_kb/wisdom/spatial_closure.py +96 -96
  544. package/md_cg/whitebox_kb/wisdom/spatial_qa.py +182 -182
  545. package/md_cg/whitebox_kb/wisdom/status_terms.json +21 -21
  546. package/md_cg/whitebox_kb/wisdom/task_discipline.json +43 -43
  547. package/md_cg/whitebox_kb/wisdom/test_code_compose_domains.py +7541 -7541
  548. package/md_cg/whitebox_kb/wisdom/test_compiler_self_bootstrap.py +354 -354
  549. package/md_cg/whitebox_kb/wisdom/test_ecosystem_demos.py +193 -193
  550. package/md_cg/whitebox_kb/wisdom/test_graph_db.py +292 -292
  551. package/md_cg/whitebox_kb/wisdom/test_navigate_self_bootstrap.py +69 -69
  552. package/md_cg/whitebox_kb/wisdom/test_python_self_bootstrap.py +160 -160
  553. package/md_cg/whitebox_kb/wisdom/trigger_words_index.json +4366 -4366
  554. package/md_cg/whitebox_kb/wisdom/verify_answer.py +116 -116
  555. package/md_cg/whitebox_kb/wisdom/wisdom_book.py +2759 -2759
  556. package/md_cg/whitebox_kb/wisdom/wisdom_cloud.py +479 -479
  557. package/md_cg/whitebox_kb/wisdom/wisdom_ui.html +863 -863
  558. package/md_cg/writegate.py +146 -0
  559. package/md_cg/writepipe.py +85 -7
  560. package/package.json +21 -7
  561. package/scripts/workspace_index.py +1 -0
  562. package/skills/README.md +121 -121
  563. package/skills/plugin.json +54 -54
  564. package/skills/skills/designer-perspective/SKILL.md +158 -158
  565. package/skills/skills/designer-perspective/references/01-observation-position.md +66 -66
  566. package/skills/skills/designer-perspective/references/02-structure-recognition.md +62 -62
  567. package/skills/skills/designer-perspective/references/03-direction-judgment.md +55 -55
  568. package/skills/skills/designer-perspective/references/04-qualification-verdict.md +72 -72
  569. package/skills/skills/designer-perspective/references/05-condition-attribution.md +74 -74
  570. package/skills/skills/designer-perspective/scripts/designer.py +545 -545
  571. package/skills/skills/designer-perspective/tests/cases.jsonl +17 -17
  572. package/skills/skills/designer-perspective/tests/selftest.py +61 -61
  573. package/skills/skills/lingshu-browser/SKILL.md +60 -60
  574. package/skills/skills/lingshu-browser/units/browser-02898b15/SKILL.md +45 -45
  575. package/skills/skills/lingshu-browser/units/browser-03b04f98/SKILL.md +45 -45
  576. package/skills/skills/lingshu-browser/units/browser-0754386d/SKILL.md +45 -45
  577. package/skills/skills/lingshu-browser/units/browser-093c03ab/SKILL.md +45 -45
  578. package/skills/skills/lingshu-browser/units/browser-09e60b35/SKILL.md +45 -45
  579. package/skills/skills/lingshu-browser/units/browser-0ab4f2db/SKILL.md +45 -45
  580. package/skills/skills/lingshu-browser/units/browser-0c7f88d6/SKILL.md +45 -45
  581. package/skills/skills/lingshu-browser/units/browser-0f598430/SKILL.md +45 -45
  582. package/skills/skills/lingshu-browser/units/browser-0fd64fa5/SKILL.md +45 -45
  583. package/skills/skills/lingshu-browser/units/browser-17906c62/SKILL.md +45 -45
  584. package/skills/skills/lingshu-browser/units/browser-18f823e2/SKILL.md +45 -45
  585. package/skills/skills/lingshu-browser/units/browser-1bafe81c/SKILL.md +45 -45
  586. package/skills/skills/lingshu-browser/units/browser-1f9ab1f0/SKILL.md +45 -45
  587. package/skills/skills/lingshu-browser/units/browser-1fdb5852/SKILL.md +45 -45
  588. package/skills/skills/lingshu-browser/units/browser-21b0359c/SKILL.md +45 -45
  589. package/skills/skills/lingshu-browser/units/browser-22e8de36/SKILL.md +45 -45
  590. package/skills/skills/lingshu-browser/units/browser-24163519/SKILL.md +45 -45
  591. package/skills/skills/lingshu-browser/units/browser-2471a991/SKILL.md +45 -45
  592. package/skills/skills/lingshu-browser/units/browser-25afee4d/SKILL.md +45 -45
  593. package/skills/skills/lingshu-browser/units/browser-283a91bd/SKILL.md +45 -45
  594. package/skills/skills/lingshu-browser/units/browser-2895ff52/SKILL.md +45 -45
  595. package/skills/skills/lingshu-browser/units/browser-2cc1da58/SKILL.md +45 -45
  596. package/skills/skills/lingshu-browser/units/browser-3189fe6f/SKILL.md +45 -45
  597. package/skills/skills/lingshu-browser/units/browser-31f2b08f/SKILL.md +45 -45
  598. package/skills/skills/lingshu-browser/units/browser-37b8339e/SKILL.md +45 -45
  599. package/skills/skills/lingshu-browser/units/browser-396ec3a6/SKILL.md +45 -45
  600. package/skills/skills/lingshu-browser/units/browser-3df2f904/SKILL.md +45 -45
  601. package/skills/skills/lingshu-browser/units/browser-43154cec/SKILL.md +45 -45
  602. package/skills/skills/lingshu-browser/units/browser-434b74b8/SKILL.md +45 -45
  603. package/skills/skills/lingshu-browser/units/browser-440d4398/SKILL.md +45 -45
  604. package/skills/skills/lingshu-browser/units/browser-44d7f183/SKILL.md +45 -45
  605. package/skills/skills/lingshu-browser/units/browser-4d6c0788/SKILL.md +45 -45
  606. package/skills/skills/lingshu-browser/units/browser-50fecd89/SKILL.md +45 -45
  607. package/skills/skills/lingshu-browser/units/browser-555c0626/SKILL.md +45 -45
  608. package/skills/skills/lingshu-browser/units/browser-57312d24/SKILL.md +45 -45
  609. package/skills/skills/lingshu-browser/units/browser-59a0ada4/SKILL.md +45 -45
  610. package/skills/skills/lingshu-browser/units/browser-5a455aeb/SKILL.md +45 -45
  611. package/skills/skills/lingshu-browser/units/browser-5ae7623a/SKILL.md +45 -45
  612. package/skills/skills/lingshu-browser/units/browser-5dac60b6/SKILL.md +45 -45
  613. package/skills/skills/lingshu-browser/units/browser-5e5f1396/SKILL.md +45 -45
  614. package/skills/skills/lingshu-browser/units/browser-5ebb01dd/SKILL.md +45 -45
  615. package/skills/skills/lingshu-browser/units/browser-5f5453f9/SKILL.md +45 -45
  616. package/skills/skills/lingshu-browser/units/browser-5f90f58c/SKILL.md +45 -45
  617. package/skills/skills/lingshu-browser/units/browser-609362ee/SKILL.md +45 -45
  618. package/skills/skills/lingshu-browser/units/browser-60aefeeb/SKILL.md +45 -45
  619. package/skills/skills/lingshu-browser/units/browser-6636d49c/SKILL.md +45 -45
  620. package/skills/skills/lingshu-browser/units/browser-6cfcb6db/SKILL.md +45 -45
  621. package/skills/skills/lingshu-browser/units/browser-6e1c1158/SKILL.md +45 -45
  622. package/skills/skills/lingshu-browser/units/browser-7008e942/SKILL.md +45 -45
  623. package/skills/skills/lingshu-browser/units/browser-716cd26c/SKILL.md +45 -45
  624. package/skills/skills/lingshu-browser/units/browser-720ce1a1/SKILL.md +45 -45
  625. package/skills/skills/lingshu-browser/units/browser-77a97b43/SKILL.md +45 -45
  626. package/skills/skills/lingshu-browser/units/browser-7bb4871d/SKILL.md +45 -45
  627. package/skills/skills/lingshu-browser/units/browser-7be57bbe/SKILL.md +45 -45
  628. package/skills/skills/lingshu-browser/units/browser-7da433f3/SKILL.md +45 -45
  629. package/skills/skills/lingshu-browser/units/browser-7e96fe1d/SKILL.md +45 -45
  630. package/skills/skills/lingshu-browser/units/browser-7f9cefec/SKILL.md +45 -45
  631. package/skills/skills/lingshu-browser/units/browser-80224e71/SKILL.md +45 -45
  632. package/skills/skills/lingshu-browser/units/browser-81345ecd/SKILL.md +45 -45
  633. package/skills/skills/lingshu-browser/units/browser-822cfa44/SKILL.md +45 -45
  634. package/skills/skills/lingshu-browser/units/browser-853690c0/SKILL.md +45 -45
  635. package/skills/skills/lingshu-browser/units/browser-85553126/SKILL.md +45 -45
  636. package/skills/skills/lingshu-browser/units/browser-87b0ce80/SKILL.md +45 -45
  637. package/skills/skills/lingshu-browser/units/browser-900c4484/SKILL.md +45 -45
  638. package/skills/skills/lingshu-browser/units/browser-910405c4/SKILL.md +45 -45
  639. package/skills/skills/lingshu-browser/units/browser-95fd3c86/SKILL.md +45 -45
  640. package/skills/skills/lingshu-browser/units/browser-97a14ca3/SKILL.md +45 -45
  641. package/skills/skills/lingshu-browser/units/browser-9de10895/SKILL.md +45 -45
  642. package/skills/skills/lingshu-browser/units/browser-9e4914a7/SKILL.md +45 -45
  643. package/skills/skills/lingshu-browser/units/browser-a280ec64/SKILL.md +45 -45
  644. package/skills/skills/lingshu-browser/units/browser-a2d9b0b0/SKILL.md +45 -45
  645. package/skills/skills/lingshu-browser/units/browser-a372edeb/SKILL.md +45 -45
  646. package/skills/skills/lingshu-browser/units/browser-a4c793a4/SKILL.md +45 -45
  647. package/skills/skills/lingshu-browser/units/browser-a681d0c2/SKILL.md +45 -45
  648. package/skills/skills/lingshu-browser/units/browser-a7a2b0c1/SKILL.md +45 -45
  649. package/skills/skills/lingshu-browser/units/browser-a990e68e/SKILL.md +45 -45
  650. package/skills/skills/lingshu-browser/units/browser-aaac4eec/SKILL.md +45 -45
  651. package/skills/skills/lingshu-browser/units/browser-ae6586bb/SKILL.md +45 -45
  652. package/skills/skills/lingshu-browser/units/browser-afa4091f/SKILL.md +45 -45
  653. package/skills/skills/lingshu-browser/units/browser-b4c8cf65/SKILL.md +45 -45
  654. package/skills/skills/lingshu-browser/units/browser-b501767c/SKILL.md +45 -45
  655. package/skills/skills/lingshu-browser/units/browser-bcd4288d/SKILL.md +45 -45
  656. package/skills/skills/lingshu-browser/units/browser-bfad66a5/SKILL.md +45 -45
  657. package/skills/skills/lingshu-browser/units/browser-c45cbfe9/SKILL.md +45 -45
  658. package/skills/skills/lingshu-browser/units/browser-c4dd6078/SKILL.md +45 -45
  659. package/skills/skills/lingshu-browser/units/browser-c879eb0b/SKILL.md +45 -45
  660. package/skills/skills/lingshu-browser/units/browser-c92ac01b/SKILL.md +45 -45
  661. package/skills/skills/lingshu-browser/units/browser-cb179242/SKILL.md +45 -45
  662. package/skills/skills/lingshu-browser/units/browser-cc7d3d6d/SKILL.md +45 -45
  663. package/skills/skills/lingshu-browser/units/browser-cf3c47f0/SKILL.md +45 -45
  664. package/skills/skills/lingshu-browser/units/browser-cf9f812e/SKILL.md +45 -45
  665. package/skills/skills/lingshu-browser/units/browser-d462581c/SKILL.md +45 -45
  666. package/skills/skills/lingshu-browser/units/browser-d5fa0b7f/SKILL.md +45 -45
  667. package/skills/skills/lingshu-browser/units/browser-d72e225b/SKILL.md +45 -45
  668. package/skills/skills/lingshu-browser/units/browser-df1a919e/SKILL.md +45 -45
  669. package/skills/skills/lingshu-browser/units/browser-e84565c1/SKILL.md +45 -45
  670. package/skills/skills/lingshu-browser/units/browser-e947a564/SKILL.md +45 -45
  671. package/skills/skills/lingshu-browser/units/browser-ea9b2b8e/SKILL.md +45 -45
  672. package/skills/skills/lingshu-browser/units/browser-f5ffc6d9/SKILL.md +45 -45
  673. package/skills/skills/lingshu-browser/units/browser-f75a4418/SKILL.md +45 -45
  674. package/skills/skills/lingshu-browser/units/browser-f8f2966e/SKILL.md +45 -45
  675. package/skills/skills/lingshu-browser/units/browser-fa65fa2d/SKILL.md +45 -45
  676. package/skills/skills/lingshu-browser/units/browser-faac8812/SKILL.md +45 -45
  677. package/skills/skills/lingshu-browser/units/browser-ff94a671/SKILL.md +45 -45
  678. package/skills/skills/lingshu-compiler/SKILL.md +56 -56
  679. package/skills/skills/lingshu-compiler/units/analyze-type-infer/SKILL.md +45 -45
  680. package/skills/skills/lingshu-compiler/units/check-name-real/SKILL.md +45 -45
  681. package/skills/skills/lingshu-compiler/units/compile-assign/SKILL.md +45 -45
  682. package/skills/skills/lingshu-compiler/units/compile-expr-tree/SKILL.md +45 -45
  683. package/skills/skills/lingshu-compiler/units/compile-full-pipeline/SKILL.md +45 -45
  684. package/skills/skills/lingshu-compiler/units/compile-func-def/SKILL.md +45 -45
  685. package/skills/skills/lingshu-compiler/units/compile-if-then/SKILL.md +45 -45
  686. package/skills/skills/lingshu-compiler/units/compile-logic-expr/SKILL.md +45 -45
  687. package/skills/skills/lingshu-compiler/units/compile-recursive/SKILL.md +45 -45
  688. package/skills/skills/lingshu-compiler/units/compile-scope/SKILL.md +45 -45
  689. package/skills/skills/lingshu-compiler/units/compile-type-check/SKILL.md +45 -45
  690. package/skills/skills/lingshu-compiler/units/compile-while/SKILL.md +45 -45
  691. package/skills/skills/lingshu-compiler/units/compiler-0010c4bf/SKILL.md +45 -45
  692. package/skills/skills/lingshu-compiler/units/compiler-0355bffb/SKILL.md +45 -45
  693. package/skills/skills/lingshu-compiler/units/compiler-0361708a/SKILL.md +45 -45
  694. package/skills/skills/lingshu-compiler/units/compiler-054a0414/SKILL.md +45 -45
  695. package/skills/skills/lingshu-compiler/units/compiler-05a1691a/SKILL.md +45 -45
  696. package/skills/skills/lingshu-compiler/units/compiler-05eeed1e/SKILL.md +45 -45
  697. package/skills/skills/lingshu-compiler/units/compiler-0622a1f6/SKILL.md +45 -45
  698. package/skills/skills/lingshu-compiler/units/compiler-08b54217/SKILL.md +45 -45
  699. package/skills/skills/lingshu-compiler/units/compiler-0a62b70c/SKILL.md +45 -45
  700. package/skills/skills/lingshu-compiler/units/compiler-0ab24d00/SKILL.md +45 -45
  701. package/skills/skills/lingshu-compiler/units/compiler-0e093688/SKILL.md +45 -45
  702. package/skills/skills/lingshu-compiler/units/compiler-0e82b966/SKILL.md +45 -45
  703. package/skills/skills/lingshu-compiler/units/compiler-0ee9b9b9/SKILL.md +45 -45
  704. package/skills/skills/lingshu-compiler/units/compiler-0f3787e6/SKILL.md +45 -45
  705. package/skills/skills/lingshu-compiler/units/compiler-1028685f/SKILL.md +45 -45
  706. package/skills/skills/lingshu-compiler/units/compiler-11897630/SKILL.md +45 -45
  707. package/skills/skills/lingshu-compiler/units/compiler-16661b9b/SKILL.md +45 -45
  708. package/skills/skills/lingshu-compiler/units/compiler-1f722303/SKILL.md +45 -45
  709. package/skills/skills/lingshu-compiler/units/compiler-25be1262/SKILL.md +45 -45
  710. package/skills/skills/lingshu-compiler/units/compiler-2a76ba07/SKILL.md +45 -45
  711. package/skills/skills/lingshu-compiler/units/compiler-2dbea54a/SKILL.md +45 -45
  712. package/skills/skills/lingshu-compiler/units/compiler-2df52f16/SKILL.md +45 -45
  713. package/skills/skills/lingshu-compiler/units/compiler-2ec2c9d2/SKILL.md +45 -45
  714. package/skills/skills/lingshu-compiler/units/compiler-2f8c8f39/SKILL.md +45 -45
  715. package/skills/skills/lingshu-compiler/units/compiler-38378ac7/SKILL.md +45 -45
  716. package/skills/skills/lingshu-compiler/units/compiler-39457d2e/SKILL.md +45 -45
  717. package/skills/skills/lingshu-compiler/units/compiler-39fb5926/SKILL.md +45 -45
  718. package/skills/skills/lingshu-compiler/units/compiler-47f4fbfa/SKILL.md +45 -45
  719. package/skills/skills/lingshu-compiler/units/compiler-4a8cd1f1/SKILL.md +45 -45
  720. package/skills/skills/lingshu-compiler/units/compiler-4b230b6b/SKILL.md +45 -45
  721. package/skills/skills/lingshu-compiler/units/compiler-4cbbda95/SKILL.md +45 -45
  722. package/skills/skills/lingshu-compiler/units/compiler-4d5a68ff/SKILL.md +45 -45
  723. package/skills/skills/lingshu-compiler/units/compiler-56dc9bdd/SKILL.md +45 -45
  724. package/skills/skills/lingshu-compiler/units/compiler-57e76ebe/SKILL.md +45 -45
  725. package/skills/skills/lingshu-compiler/units/compiler-61ff016b/SKILL.md +45 -45
  726. package/skills/skills/lingshu-compiler/units/compiler-63eae588/SKILL.md +45 -45
  727. package/skills/skills/lingshu-compiler/units/compiler-64c4224b/SKILL.md +45 -45
  728. package/skills/skills/lingshu-compiler/units/compiler-66377955/SKILL.md +45 -45
  729. package/skills/skills/lingshu-compiler/units/compiler-674ab4f6/SKILL.md +45 -45
  730. package/skills/skills/lingshu-compiler/units/compiler-6af76fd6/SKILL.md +45 -45
  731. package/skills/skills/lingshu-compiler/units/compiler-6d979db2/SKILL.md +45 -45
  732. package/skills/skills/lingshu-compiler/units/compiler-6de326c0/SKILL.md +45 -45
  733. package/skills/skills/lingshu-compiler/units/compiler-6f1c0eea/SKILL.md +45 -45
  734. package/skills/skills/lingshu-compiler/units/compiler-724d6c9b/SKILL.md +45 -45
  735. package/skills/skills/lingshu-compiler/units/compiler-7690177f/SKILL.md +45 -45
  736. package/skills/skills/lingshu-compiler/units/compiler-7b229a7d/SKILL.md +45 -45
  737. package/skills/skills/lingshu-compiler/units/compiler-7f471b3a/SKILL.md +45 -45
  738. package/skills/skills/lingshu-compiler/units/compiler-815cad08/SKILL.md +45 -45
  739. package/skills/skills/lingshu-compiler/units/compiler-83c61634/SKILL.md +45 -45
  740. package/skills/skills/lingshu-compiler/units/compiler-8c798c81/SKILL.md +45 -45
  741. package/skills/skills/lingshu-compiler/units/compiler-8dd747ac/SKILL.md +45 -45
  742. package/skills/skills/lingshu-compiler/units/compiler-90324d0a/SKILL.md +45 -45
  743. package/skills/skills/lingshu-compiler/units/compiler-94b8d72d/SKILL.md +45 -45
  744. package/skills/skills/lingshu-compiler/units/compiler-94f12231/SKILL.md +45 -45
  745. package/skills/skills/lingshu-compiler/units/compiler-95937c16/SKILL.md +45 -45
  746. package/skills/skills/lingshu-compiler/units/compiler-98a5625b/SKILL.md +45 -45
  747. package/skills/skills/lingshu-compiler/units/compiler-98b4c42f/SKILL.md +45 -45
  748. package/skills/skills/lingshu-compiler/units/compiler-98e3894a/SKILL.md +45 -45
  749. package/skills/skills/lingshu-compiler/units/compiler-9bdfe4b8/SKILL.md +45 -45
  750. package/skills/skills/lingshu-compiler/units/compiler-9d9b4e83/SKILL.md +45 -45
  751. package/skills/skills/lingshu-compiler/units/compiler-9f7be5ad/SKILL.md +45 -45
  752. package/skills/skills/lingshu-compiler/units/compiler-a6daf076/SKILL.md +45 -45
  753. package/skills/skills/lingshu-compiler/units/compiler-a7995a0c/SKILL.md +45 -45
  754. package/skills/skills/lingshu-compiler/units/compiler-a8399248/SKILL.md +45 -45
  755. package/skills/skills/lingshu-compiler/units/compiler-aabbd099/SKILL.md +45 -45
  756. package/skills/skills/lingshu-compiler/units/compiler-afe169d8/SKILL.md +45 -45
  757. package/skills/skills/lingshu-compiler/units/compiler-b0678bda/SKILL.md +45 -45
  758. package/skills/skills/lingshu-compiler/units/compiler-b09bd196/SKILL.md +45 -45
  759. package/skills/skills/lingshu-compiler/units/compiler-b1396e23/SKILL.md +45 -45
  760. package/skills/skills/lingshu-compiler/units/compiler-b9b31ce0/SKILL.md +45 -45
  761. package/skills/skills/lingshu-compiler/units/compiler-c10264a7/SKILL.md +45 -45
  762. package/skills/skills/lingshu-compiler/units/compiler-cb1e8e4b/SKILL.md +45 -45
  763. package/skills/skills/lingshu-compiler/units/compiler-ccafd438/SKILL.md +45 -45
  764. package/skills/skills/lingshu-compiler/units/compiler-cda9c262/SKILL.md +45 -45
  765. package/skills/skills/lingshu-compiler/units/compiler-ce648068/SKILL.md +45 -45
  766. package/skills/skills/lingshu-compiler/units/compiler-cf5776a4/SKILL.md +45 -45
  767. package/skills/skills/lingshu-compiler/units/compiler-d974e5d3/SKILL.md +45 -45
  768. package/skills/skills/lingshu-compiler/units/compiler-e3979fd3/SKILL.md +45 -45
  769. package/skills/skills/lingshu-compiler/units/compiler-eb1cf2b5/SKILL.md +45 -45
  770. package/skills/skills/lingshu-compiler/units/compiler-ecb30d5b/SKILL.md +45 -45
  771. package/skills/skills/lingshu-compiler/units/compiler-f8c8b24b/SKILL.md +45 -45
  772. package/skills/skills/lingshu-compiler/units/compiler-f99fedbe/SKILL.md +45 -45
  773. package/skills/skills/lingshu-compiler/units/compiler-fa8ff5f7/SKILL.md +45 -45
  774. package/skills/skills/lingshu-compiler/units/compiler-fe1b058d/SKILL.md +45 -45
  775. package/skills/skills/lingshu-compiler/units/lex-chinese-program/SKILL.md +45 -45
  776. package/skills/skills/lingshu-compiler/units/lex-dao-de-jing/SKILL.md +45 -45
  777. package/skills/skills/lingshu-compiler/units/lex-nine-chapters/SKILL.md +45 -45
  778. package/skills/skills/lingshu-compiler/units/vm-arithmetic/SKILL.md +45 -45
  779. package/skills/skills/lingshu-compiler/units/vm-array-ops/SKILL.md +45 -45
  780. package/skills/skills/lingshu-compiler/units/vm-closure-call/SKILL.md +45 -45
  781. package/skills/skills/lingshu-compiler/units/vm-closure-create/SKILL.md +45 -45
  782. package/skills/skills/lingshu-compiler/units/vm-compare/SKILL.md +45 -45
  783. package/skills/skills/lingshu-compiler/units/vm-cond-jump/SKILL.md +45 -45
  784. package/skills/skills/lingshu-compiler/units/vm-cond-space/SKILL.md +45 -45
  785. package/skills/skills/lingshu-compiler/units/vm-exception/SKILL.md +45 -45
  786. package/skills/skills/lingshu-compiler/units/vm-func-call/SKILL.md +45 -45
  787. package/skills/skills/lingshu-compiler/units/vm-loop-run/SKILL.md +45 -45
  788. package/skills/skills/lingshu-compiler/units/vm-profiling/SKILL.md +45 -45
  789. package/skills/skills/lingshu-compiler/units/vm-refcount/SKILL.md +45 -45
  790. package/skills/skills/lingshu-compiler/units/vm-run-loop/SKILL.md +45 -45
  791. package/skills/skills/lingshu-compiler/units/vm-short-circuit/SKILL.md +45 -45
  792. package/skills/skills/lingshu-compiler/units/vm-stack-guard/SKILL.md +45 -45
  793. package/skills/skills/lingshu-compiler/units/vm-stack-ops/SKILL.md +45 -45
  794. package/skills/skills/lingshu-compiler/units/vm-trust-accum/SKILL.md +45 -45
  795. package/skills/skills/lingshu-graph/SKILL.md +63 -63
  796. package/skills/skills/lingshu-graph/units/graph-04cd431b/SKILL.md +45 -45
  797. package/skills/skills/lingshu-graph/units/graph-06e2b1f2/SKILL.md +45 -45
  798. package/skills/skills/lingshu-graph/units/graph-0de12477/SKILL.md +45 -45
  799. package/skills/skills/lingshu-graph/units/graph-0e564e68/SKILL.md +45 -45
  800. package/skills/skills/lingshu-graph/units/graph-10d58a7b/SKILL.md +45 -45
  801. package/skills/skills/lingshu-graph/units/graph-12cd830a/SKILL.md +45 -45
  802. package/skills/skills/lingshu-graph/units/graph-185f2cd2/SKILL.md +45 -45
  803. package/skills/skills/lingshu-graph/units/graph-19a6a301/SKILL.md +45 -45
  804. package/skills/skills/lingshu-graph/units/graph-1b266557/SKILL.md +45 -45
  805. package/skills/skills/lingshu-graph/units/graph-1b707621/SKILL.md +45 -45
  806. package/skills/skills/lingshu-graph/units/graph-1d73b597/SKILL.md +45 -45
  807. package/skills/skills/lingshu-graph/units/graph-2041fa98/SKILL.md +45 -45
  808. package/skills/skills/lingshu-graph/units/graph-2461bc41/SKILL.md +45 -45
  809. package/skills/skills/lingshu-graph/units/graph-2465dff8/SKILL.md +45 -45
  810. package/skills/skills/lingshu-graph/units/graph-2508389f/SKILL.md +45 -45
  811. package/skills/skills/lingshu-graph/units/graph-276d554d/SKILL.md +45 -45
  812. package/skills/skills/lingshu-graph/units/graph-299f4a32/SKILL.md +45 -45
  813. package/skills/skills/lingshu-graph/units/graph-2d455cd8/SKILL.md +45 -45
  814. package/skills/skills/lingshu-graph/units/graph-2fddf701/SKILL.md +45 -45
  815. package/skills/skills/lingshu-graph/units/graph-33385442/SKILL.md +45 -45
  816. package/skills/skills/lingshu-graph/units/graph-34a1dba7/SKILL.md +45 -45
  817. package/skills/skills/lingshu-graph/units/graph-3721be1c/SKILL.md +45 -45
  818. package/skills/skills/lingshu-graph/units/graph-3755dbc9/SKILL.md +45 -45
  819. package/skills/skills/lingshu-graph/units/graph-37a45d4b/SKILL.md +45 -45
  820. package/skills/skills/lingshu-graph/units/graph-3a4a984c/SKILL.md +45 -45
  821. package/skills/skills/lingshu-graph/units/graph-3aa4c941/SKILL.md +45 -45
  822. package/skills/skills/lingshu-graph/units/graph-3b69a528/SKILL.md +45 -45
  823. package/skills/skills/lingshu-graph/units/graph-3bc2eb69/SKILL.md +45 -45
  824. package/skills/skills/lingshu-graph/units/graph-3d255ed4/SKILL.md +45 -45
  825. package/skills/skills/lingshu-graph/units/graph-3d34961d/SKILL.md +45 -45
  826. package/skills/skills/lingshu-graph/units/graph-3e18a380/SKILL.md +45 -45
  827. package/skills/skills/lingshu-graph/units/graph-3f920bf3/SKILL.md +45 -45
  828. package/skills/skills/lingshu-graph/units/graph-40b7bf61/SKILL.md +45 -45
  829. package/skills/skills/lingshu-graph/units/graph-42187d5d/SKILL.md +45 -45
  830. package/skills/skills/lingshu-graph/units/graph-4361c60e/SKILL.md +45 -45
  831. package/skills/skills/lingshu-graph/units/graph-44e56113/SKILL.md +45 -45
  832. package/skills/skills/lingshu-graph/units/graph-4b363727/SKILL.md +45 -45
  833. package/skills/skills/lingshu-graph/units/graph-52e6e216/SKILL.md +45 -45
  834. package/skills/skills/lingshu-graph/units/graph-53fbfef5/SKILL.md +45 -45
  835. package/skills/skills/lingshu-graph/units/graph-54ac2988/SKILL.md +45 -45
  836. package/skills/skills/lingshu-graph/units/graph-580dadcd/SKILL.md +45 -45
  837. package/skills/skills/lingshu-graph/units/graph-5ca34baa/SKILL.md +45 -45
  838. package/skills/skills/lingshu-graph/units/graph-5cb7fbdf/SKILL.md +45 -45
  839. package/skills/skills/lingshu-graph/units/graph-5f894c05/SKILL.md +45 -45
  840. package/skills/skills/lingshu-graph/units/graph-656e7bd4/SKILL.md +45 -45
  841. package/skills/skills/lingshu-graph/units/graph-6dc48231/SKILL.md +45 -45
  842. package/skills/skills/lingshu-graph/units/graph-7186924a/SKILL.md +45 -45
  843. package/skills/skills/lingshu-graph/units/graph-72ce5342/SKILL.md +45 -45
  844. package/skills/skills/lingshu-graph/units/graph-7376a24e/SKILL.md +45 -45
  845. package/skills/skills/lingshu-graph/units/graph-7412a7cb/SKILL.md +45 -45
  846. package/skills/skills/lingshu-graph/units/graph-7becedf0/SKILL.md +45 -45
  847. package/skills/skills/lingshu-graph/units/graph-7c38fbf3/SKILL.md +45 -45
  848. package/skills/skills/lingshu-graph/units/graph-7dc36de7/SKILL.md +45 -45
  849. package/skills/skills/lingshu-graph/units/graph-7fe49de7/SKILL.md +45 -45
  850. package/skills/skills/lingshu-graph/units/graph-80d82194/SKILL.md +45 -45
  851. package/skills/skills/lingshu-graph/units/graph-85bf101e/SKILL.md +45 -45
  852. package/skills/skills/lingshu-graph/units/graph-8650548b/SKILL.md +45 -45
  853. package/skills/skills/lingshu-graph/units/graph-86583b09/SKILL.md +45 -45
  854. package/skills/skills/lingshu-graph/units/graph-8727827c/SKILL.md +45 -45
  855. package/skills/skills/lingshu-graph/units/graph-873fb505/SKILL.md +45 -45
  856. package/skills/skills/lingshu-graph/units/graph-89b11de0/SKILL.md +45 -45
  857. package/skills/skills/lingshu-graph/units/graph-8d7b569b/SKILL.md +45 -45
  858. package/skills/skills/lingshu-graph/units/graph-8e920d5d/SKILL.md +45 -45
  859. package/skills/skills/lingshu-graph/units/graph-8eb38e3d/SKILL.md +45 -45
  860. package/skills/skills/lingshu-graph/units/graph-94582f69/SKILL.md +45 -45
  861. package/skills/skills/lingshu-graph/units/graph-947355f7/SKILL.md +45 -45
  862. package/skills/skills/lingshu-graph/units/graph-9507aff7/SKILL.md +45 -45
  863. package/skills/skills/lingshu-graph/units/graph-95b86a8b/SKILL.md +45 -45
  864. package/skills/skills/lingshu-graph/units/graph-96b85e1f/SKILL.md +45 -45
  865. package/skills/skills/lingshu-graph/units/graph-97b22f09/SKILL.md +45 -45
  866. package/skills/skills/lingshu-graph/units/graph-9833cfda/SKILL.md +45 -45
  867. package/skills/skills/lingshu-graph/units/graph-9aa8a3f4/SKILL.md +45 -45
  868. package/skills/skills/lingshu-graph/units/graph-9f6665c0/SKILL.md +45 -45
  869. package/skills/skills/lingshu-graph/units/graph-a125d282/SKILL.md +45 -45
  870. package/skills/skills/lingshu-graph/units/graph-a49ef4f0/SKILL.md +45 -45
  871. package/skills/skills/lingshu-graph/units/graph-a5cd04ae/SKILL.md +45 -45
  872. package/skills/skills/lingshu-graph/units/graph-add9a63b/SKILL.md +45 -45
  873. package/skills/skills/lingshu-graph/units/graph-b00e3dc7/SKILL.md +45 -45
  874. package/skills/skills/lingshu-graph/units/graph-b33a7662/SKILL.md +45 -45
  875. package/skills/skills/lingshu-graph/units/graph-b76d15ee/SKILL.md +45 -45
  876. package/skills/skills/lingshu-graph/units/graph-b77fa05a/SKILL.md +45 -45
  877. package/skills/skills/lingshu-graph/units/graph-b912fc3b/SKILL.md +45 -45
  878. package/skills/skills/lingshu-graph/units/graph-baf61b7c/SKILL.md +45 -45
  879. package/skills/skills/lingshu-graph/units/graph-c1d5687b/SKILL.md +45 -45
  880. package/skills/skills/lingshu-graph/units/graph-c407bbed/SKILL.md +45 -45
  881. package/skills/skills/lingshu-graph/units/graph-c4676460/SKILL.md +45 -45
  882. package/skills/skills/lingshu-graph/units/graph-c4a59d80/SKILL.md +45 -45
  883. package/skills/skills/lingshu-graph/units/graph-c5815621/SKILL.md +45 -45
  884. package/skills/skills/lingshu-graph/units/graph-ccad55f1/SKILL.md +45 -45
  885. package/skills/skills/lingshu-graph/units/graph-d0677ce1/SKILL.md +45 -45
  886. package/skills/skills/lingshu-graph/units/graph-d1289b39/SKILL.md +45 -45
  887. package/skills/skills/lingshu-graph/units/graph-d15f39b1/SKILL.md +45 -45
  888. package/skills/skills/lingshu-graph/units/graph-d40691ca/SKILL.md +45 -45
  889. package/skills/skills/lingshu-graph/units/graph-d43b387a/SKILL.md +45 -45
  890. package/skills/skills/lingshu-graph/units/graph-d4dd02f4/SKILL.md +45 -45
  891. package/skills/skills/lingshu-graph/units/graph-d724ea18/SKILL.md +45 -45
  892. package/skills/skills/lingshu-graph/units/graph-d74d36fd/SKILL.md +45 -45
  893. package/skills/skills/lingshu-graph/units/graph-d9d3934c/SKILL.md +45 -45
  894. package/skills/skills/lingshu-graph/units/graph-ddf563ff/SKILL.md +45 -45
  895. package/skills/skills/lingshu-graph/units/graph-de00894f/SKILL.md +45 -45
  896. package/skills/skills/lingshu-graph/units/graph-df1ebb63/SKILL.md +45 -45
  897. package/skills/skills/lingshu-graph/units/graph-e2905c20/SKILL.md +45 -45
  898. package/skills/skills/lingshu-graph/units/graph-e4f8cefd/SKILL.md +45 -45
  899. package/skills/skills/lingshu-graph/units/graph-ea3150e7/SKILL.md +45 -45
  900. package/skills/skills/lingshu-graph/units/graph-eb4ac7dd/SKILL.md +45 -45
  901. package/skills/skills/lingshu-graph/units/graph-ee9f6dfa/SKILL.md +45 -45
  902. package/skills/skills/lingshu-graph/units/graph-f055b2ea/SKILL.md +45 -45
  903. package/skills/skills/lingshu-graph/units/graph-f1891287/SKILL.md +45 -45
  904. package/skills/skills/lingshu-graph/units/graph-f1bb5aa1/SKILL.md +45 -45
  905. package/skills/skills/lingshu-graph/units/graph-f56fa220/SKILL.md +45 -45
  906. package/skills/skills/lingshu-graph/units/graph-f729034f/SKILL.md +45 -45
  907. package/skills/skills/lingshu-graph/units/graph-f748a63f/SKILL.md +45 -45
  908. package/skills/skills/lingshu-graph/units/graph-f8c4a59e/SKILL.md +45 -45
  909. package/skills/skills/lingshu-graph/units/graph-fca3d129/SKILL.md +45 -45
  910. package/skills/skills/lingshu-graph/units/graph-fd02d934/SKILL.md +45 -45
  911. package/skills/skills/lingshu-graph/units/graph-fd51ece9/SKILL.md +45 -45
  912. package/skills/skills/lingshu-graph/units/graph-fd6a81ab/SKILL.md +45 -45
  913. package/skills/skills/lingshu-net/SKILL.md +48 -48
  914. package/skills/skills/lingshu-net/units/net-02090d29/SKILL.md +45 -45
  915. package/skills/skills/lingshu-net/units/net-05937712/SKILL.md +45 -45
  916. package/skills/skills/lingshu-net/units/net-059d072f/SKILL.md +45 -45
  917. package/skills/skills/lingshu-net/units/net-080f6012/SKILL.md +45 -45
  918. package/skills/skills/lingshu-net/units/net-08a2fc88/SKILL.md +45 -45
  919. package/skills/skills/lingshu-net/units/net-0935edf1/SKILL.md +45 -45
  920. package/skills/skills/lingshu-net/units/net-0e7f91e4/SKILL.md +45 -45
  921. package/skills/skills/lingshu-net/units/net-0f2850e0/SKILL.md +45 -45
  922. package/skills/skills/lingshu-net/units/net-107ab486/SKILL.md +45 -45
  923. package/skills/skills/lingshu-net/units/net-111e79b0/SKILL.md +45 -45
  924. package/skills/skills/lingshu-net/units/net-126876c1/SKILL.md +45 -45
  925. package/skills/skills/lingshu-net/units/net-13eeb575/SKILL.md +45 -45
  926. package/skills/skills/lingshu-net/units/net-14102d54/SKILL.md +45 -45
  927. package/skills/skills/lingshu-net/units/net-14e9ad0d/SKILL.md +45 -45
  928. package/skills/skills/lingshu-net/units/net-184175d3/SKILL.md +45 -45
  929. package/skills/skills/lingshu-net/units/net-1da1c695/SKILL.md +45 -45
  930. package/skills/skills/lingshu-net/units/net-240a14ec/SKILL.md +45 -45
  931. package/skills/skills/lingshu-net/units/net-2784f98b/SKILL.md +45 -45
  932. package/skills/skills/lingshu-net/units/net-292ef917/SKILL.md +45 -45
  933. package/skills/skills/lingshu-net/units/net-3434e92f/SKILL.md +45 -45
  934. package/skills/skills/lingshu-net/units/net-35019e6b/SKILL.md +45 -45
  935. package/skills/skills/lingshu-net/units/net-3bbc6afb/SKILL.md +45 -45
  936. package/skills/skills/lingshu-net/units/net-3bdf9d9d/SKILL.md +45 -45
  937. package/skills/skills/lingshu-net/units/net-3dcb84d3/SKILL.md +45 -45
  938. package/skills/skills/lingshu-net/units/net-431cccf9/SKILL.md +45 -45
  939. package/skills/skills/lingshu-net/units/net-435a9f7f/SKILL.md +45 -45
  940. package/skills/skills/lingshu-net/units/net-4508101f/SKILL.md +45 -45
  941. package/skills/skills/lingshu-net/units/net-4585c9e7/SKILL.md +45 -45
  942. package/skills/skills/lingshu-net/units/net-479612a0/SKILL.md +45 -45
  943. package/skills/skills/lingshu-net/units/net-47a19838/SKILL.md +45 -45
  944. package/skills/skills/lingshu-net/units/net-4e36e1e3/SKILL.md +45 -45
  945. package/skills/skills/lingshu-net/units/net-509b8001/SKILL.md +45 -45
  946. package/skills/skills/lingshu-net/units/net-51930c5e/SKILL.md +45 -45
  947. package/skills/skills/lingshu-net/units/net-56dbd63f/SKILL.md +45 -45
  948. package/skills/skills/lingshu-net/units/net-57387462/SKILL.md +45 -45
  949. package/skills/skills/lingshu-net/units/net-5c115606/SKILL.md +45 -45
  950. package/skills/skills/lingshu-net/units/net-5d27f392/SKILL.md +45 -45
  951. package/skills/skills/lingshu-net/units/net-5f69c938/SKILL.md +45 -45
  952. package/skills/skills/lingshu-net/units/net-5fa6c13b/SKILL.md +45 -45
  953. package/skills/skills/lingshu-net/units/net-61580202/SKILL.md +45 -45
  954. package/skills/skills/lingshu-net/units/net-61926703/SKILL.md +45 -45
  955. package/skills/skills/lingshu-net/units/net-61f64fbc/SKILL.md +45 -45
  956. package/skills/skills/lingshu-net/units/net-6200f3b2/SKILL.md +45 -45
  957. package/skills/skills/lingshu-net/units/net-63c3eda3/SKILL.md +45 -45
  958. package/skills/skills/lingshu-net/units/net-66e6119b/SKILL.md +45 -45
  959. package/skills/skills/lingshu-net/units/net-68643014/SKILL.md +45 -45
  960. package/skills/skills/lingshu-net/units/net-686632aa/SKILL.md +45 -45
  961. package/skills/skills/lingshu-net/units/net-6967ff14/SKILL.md +45 -45
  962. package/skills/skills/lingshu-net/units/net-6996f499/SKILL.md +45 -45
  963. package/skills/skills/lingshu-net/units/net-6c3b02c2/SKILL.md +45 -45
  964. package/skills/skills/lingshu-net/units/net-6eb37f63/SKILL.md +45 -45
  965. package/skills/skills/lingshu-net/units/net-6f96c190/SKILL.md +45 -45
  966. package/skills/skills/lingshu-net/units/net-6fb27488/SKILL.md +45 -45
  967. package/skills/skills/lingshu-net/units/net-703559d0/SKILL.md +45 -45
  968. package/skills/skills/lingshu-net/units/net-706d2692/SKILL.md +45 -45
  969. package/skills/skills/lingshu-net/units/net-70a20e04/SKILL.md +45 -45
  970. package/skills/skills/lingshu-net/units/net-7376158c/SKILL.md +45 -45
  971. package/skills/skills/lingshu-net/units/net-74d647cb/SKILL.md +45 -45
  972. package/skills/skills/lingshu-net/units/net-74e8a576/SKILL.md +45 -45
  973. package/skills/skills/lingshu-net/units/net-7801c2c0/SKILL.md +45 -45
  974. package/skills/skills/lingshu-net/units/net-78cae54d/SKILL.md +45 -45
  975. package/skills/skills/lingshu-net/units/net-78ec0324/SKILL.md +45 -45
  976. package/skills/skills/lingshu-net/units/net-7998097c/SKILL.md +45 -45
  977. package/skills/skills/lingshu-net/units/net-7d81ae06/SKILL.md +45 -45
  978. package/skills/skills/lingshu-net/units/net-7eabbbc8/SKILL.md +45 -45
  979. package/skills/skills/lingshu-net/units/net-7ed4f2c5/SKILL.md +45 -45
  980. package/skills/skills/lingshu-net/units/net-80b56cd6/SKILL.md +45 -45
  981. package/skills/skills/lingshu-net/units/net-83447546/SKILL.md +45 -45
  982. package/skills/skills/lingshu-net/units/net-8361fe5b/SKILL.md +45 -45
  983. package/skills/skills/lingshu-net/units/net-85e3996c/SKILL.md +45 -45
  984. package/skills/skills/lingshu-net/units/net-8897d5cc/SKILL.md +45 -45
  985. package/skills/skills/lingshu-net/units/net-88ad93a6/SKILL.md +45 -45
  986. package/skills/skills/lingshu-net/units/net-8e6f359e/SKILL.md +45 -45
  987. package/skills/skills/lingshu-net/units/net-8edc4cdb/SKILL.md +45 -45
  988. package/skills/skills/lingshu-net/units/net-8f6169e9/SKILL.md +45 -45
  989. package/skills/skills/lingshu-net/units/net-91e00638/SKILL.md +45 -45
  990. package/skills/skills/lingshu-net/units/net-96c61a3c/SKILL.md +45 -45
  991. package/skills/skills/lingshu-net/units/net-99076a29/SKILL.md +45 -45
  992. package/skills/skills/lingshu-net/units/net-998f3641/SKILL.md +45 -45
  993. package/skills/skills/lingshu-net/units/net-a1d7228a/SKILL.md +45 -45
  994. package/skills/skills/lingshu-net/units/net-a74da501/SKILL.md +45 -45
  995. package/skills/skills/lingshu-net/units/net-ac57deb7/SKILL.md +45 -45
  996. package/skills/skills/lingshu-net/units/net-b22d2f2b/SKILL.md +45 -45
  997. package/skills/skills/lingshu-net/units/net-b2b29d8d/SKILL.md +45 -45
  998. package/skills/skills/lingshu-net/units/net-b2ddce5d/SKILL.md +45 -45
  999. package/skills/skills/lingshu-net/units/net-b4151e9a/SKILL.md +45 -45
  1000. package/skills/skills/lingshu-net/units/net-b873d6f7/SKILL.md +45 -45
  1001. package/skills/skills/lingshu-net/units/net-bd3d2d55/SKILL.md +45 -45
  1002. package/skills/skills/lingshu-net/units/net-c2a3f019/SKILL.md +45 -45
  1003. package/skills/skills/lingshu-net/units/net-c685b788/SKILL.md +45 -45
  1004. package/skills/skills/lingshu-net/units/net-c6c1fd79/SKILL.md +45 -45
  1005. package/skills/skills/lingshu-net/units/net-c74a1b5d/SKILL.md +45 -45
  1006. package/skills/skills/lingshu-net/units/net-cdac702d/SKILL.md +45 -45
  1007. package/skills/skills/lingshu-net/units/net-d12dff5c/SKILL.md +45 -45
  1008. package/skills/skills/lingshu-net/units/net-d3747882/SKILL.md +45 -45
  1009. package/skills/skills/lingshu-net/units/net-d5fefa59/SKILL.md +45 -45
  1010. package/skills/skills/lingshu-net/units/net-d67ec725/SKILL.md +45 -45
  1011. package/skills/skills/lingshu-net/units/net-d80c1c4c/SKILL.md +45 -45
  1012. package/skills/skills/lingshu-net/units/net-d9cb43b0/SKILL.md +45 -45
  1013. package/skills/skills/lingshu-net/units/net-da559517/SKILL.md +45 -45
  1014. package/skills/skills/lingshu-net/units/net-db4f414e/SKILL.md +45 -45
  1015. package/skills/skills/lingshu-net/units/net-dc09d67c/SKILL.md +45 -45
  1016. package/skills/skills/lingshu-net/units/net-e2d185de/SKILL.md +45 -45
  1017. package/skills/skills/lingshu-net/units/net-e2fc73f8/SKILL.md +45 -45
  1018. package/skills/skills/lingshu-net/units/net-e33ef0c2/SKILL.md +45 -45
  1019. package/skills/skills/lingshu-net/units/net-e346863c/SKILL.md +45 -45
  1020. package/skills/skills/lingshu-net/units/net-e6b3389a/SKILL.md +45 -45
  1021. package/skills/skills/lingshu-net/units/net-e9758fc0/SKILL.md +45 -45
  1022. package/skills/skills/lingshu-net/units/net-e9a9747a/SKILL.md +45 -45
  1023. package/skills/skills/lingshu-net/units/net-ea14aab8/SKILL.md +45 -45
  1024. package/skills/skills/lingshu-net/units/net-eba92ac1/SKILL.md +45 -45
  1025. package/skills/skills/lingshu-net/units/net-f29d91d2/SKILL.md +45 -45
  1026. package/skills/skills/lingshu-net/units/net-f314dd0d/SKILL.md +45 -45
  1027. package/skills/skills/lingshu-net/units/net-f332b629/SKILL.md +45 -45
  1028. package/skills/skills/lingshu-net/units/net-f7df127c/SKILL.md +45 -45
  1029. package/skills/skills/lingshu-net/units/net-fb9d8f5d/SKILL.md +45 -45
  1030. package/skills/skills/lingshu-net/units/net-fdec2c86/SKILL.md +45 -45
  1031. package/skills/skills/lingshu-os/SKILL.md +64 -64
  1032. package/skills/skills/lingshu-os/units/os-0205cf9b/SKILL.md +45 -45
  1033. package/skills/skills/lingshu-os/units/os-027dc9be/SKILL.md +45 -45
  1034. package/skills/skills/lingshu-os/units/os-03c0d7d6/SKILL.md +45 -45
  1035. package/skills/skills/lingshu-os/units/os-040b5505/SKILL.md +45 -45
  1036. package/skills/skills/lingshu-os/units/os-06fa98ed/SKILL.md +45 -45
  1037. package/skills/skills/lingshu-os/units/os-0854291c/SKILL.md +45 -45
  1038. package/skills/skills/lingshu-os/units/os-0c7f14cb/SKILL.md +45 -45
  1039. package/skills/skills/lingshu-os/units/os-0d855af2/SKILL.md +45 -45
  1040. package/skills/skills/lingshu-os/units/os-0e87e997/SKILL.md +45 -45
  1041. package/skills/skills/lingshu-os/units/os-0f8ed882/SKILL.md +45 -45
  1042. package/skills/skills/lingshu-os/units/os-111ce1de/SKILL.md +45 -45
  1043. package/skills/skills/lingshu-os/units/os-1234eb00/SKILL.md +45 -45
  1044. package/skills/skills/lingshu-os/units/os-128f3820/SKILL.md +45 -45
  1045. package/skills/skills/lingshu-os/units/os-15796db5/SKILL.md +45 -45
  1046. package/skills/skills/lingshu-os/units/os-1898928a/SKILL.md +45 -45
  1047. package/skills/skills/lingshu-os/units/os-192b8ca9/SKILL.md +45 -45
  1048. package/skills/skills/lingshu-os/units/os-1d3bcf28/SKILL.md +45 -45
  1049. package/skills/skills/lingshu-os/units/os-1f224514/SKILL.md +45 -45
  1050. package/skills/skills/lingshu-os/units/os-26a4f86a/SKILL.md +45 -45
  1051. package/skills/skills/lingshu-os/units/os-29c96147/SKILL.md +45 -45
  1052. package/skills/skills/lingshu-os/units/os-2ea9a5ff/SKILL.md +45 -45
  1053. package/skills/skills/lingshu-os/units/os-300ef22c/SKILL.md +45 -45
  1054. package/skills/skills/lingshu-os/units/os-310dda5b/SKILL.md +45 -45
  1055. package/skills/skills/lingshu-os/units/os-313ef4ed/SKILL.md +45 -45
  1056. package/skills/skills/lingshu-os/units/os-329a2147/SKILL.md +45 -45
  1057. package/skills/skills/lingshu-os/units/os-34ad4b62/SKILL.md +45 -45
  1058. package/skills/skills/lingshu-os/units/os-350bc623/SKILL.md +45 -45
  1059. package/skills/skills/lingshu-os/units/os-35ee1a30/SKILL.md +45 -45
  1060. package/skills/skills/lingshu-os/units/os-3cd28220/SKILL.md +45 -45
  1061. package/skills/skills/lingshu-os/units/os-3d84e0c9/SKILL.md +45 -45
  1062. package/skills/skills/lingshu-os/units/os-3db42aac/SKILL.md +45 -45
  1063. package/skills/skills/lingshu-os/units/os-3e0aff42/SKILL.md +45 -45
  1064. package/skills/skills/lingshu-os/units/os-3e9405d2/SKILL.md +45 -45
  1065. package/skills/skills/lingshu-os/units/os-41d14544/SKILL.md +45 -45
  1066. package/skills/skills/lingshu-os/units/os-462f3ed4/SKILL.md +45 -45
  1067. package/skills/skills/lingshu-os/units/os-485833fa/SKILL.md +45 -45
  1068. package/skills/skills/lingshu-os/units/os-4a1cf781/SKILL.md +45 -45
  1069. package/skills/skills/lingshu-os/units/os-4bf77933/SKILL.md +45 -45
  1070. package/skills/skills/lingshu-os/units/os-4c14cec2/SKILL.md +45 -45
  1071. package/skills/skills/lingshu-os/units/os-4f05d577/SKILL.md +45 -45
  1072. package/skills/skills/lingshu-os/units/os-4f50ad0b/SKILL.md +45 -45
  1073. package/skills/skills/lingshu-os/units/os-509a4596/SKILL.md +45 -45
  1074. package/skills/skills/lingshu-os/units/os-512b1b6c/SKILL.md +45 -45
  1075. package/skills/skills/lingshu-os/units/os-5192621b/SKILL.md +45 -45
  1076. package/skills/skills/lingshu-os/units/os-55672763/SKILL.md +45 -45
  1077. package/skills/skills/lingshu-os/units/os-5582bce6/SKILL.md +45 -45
  1078. package/skills/skills/lingshu-os/units/os-5a096a1f/SKILL.md +45 -45
  1079. package/skills/skills/lingshu-os/units/os-5ca15108/SKILL.md +45 -45
  1080. package/skills/skills/lingshu-os/units/os-601663e1/SKILL.md +45 -45
  1081. package/skills/skills/lingshu-os/units/os-607f1963/SKILL.md +45 -45
  1082. package/skills/skills/lingshu-os/units/os-6158581b/SKILL.md +45 -45
  1083. package/skills/skills/lingshu-os/units/os-62f9278b/SKILL.md +45 -45
  1084. package/skills/skills/lingshu-os/units/os-63797b86/SKILL.md +45 -45
  1085. package/skills/skills/lingshu-os/units/os-6a1fe224/SKILL.md +45 -45
  1086. package/skills/skills/lingshu-os/units/os-6b0a68bf/SKILL.md +45 -45
  1087. package/skills/skills/lingshu-os/units/os-6e5cee67/SKILL.md +45 -45
  1088. package/skills/skills/lingshu-os/units/os-6fb1ff58/SKILL.md +45 -45
  1089. package/skills/skills/lingshu-os/units/os-71389592/SKILL.md +45 -45
  1090. package/skills/skills/lingshu-os/units/os-72e879a3/SKILL.md +45 -45
  1091. package/skills/skills/lingshu-os/units/os-7598748a/SKILL.md +45 -45
  1092. package/skills/skills/lingshu-os/units/os-80cc3283/SKILL.md +45 -45
  1093. package/skills/skills/lingshu-os/units/os-819f3093/SKILL.md +45 -45
  1094. package/skills/skills/lingshu-os/units/os-83670c2b/SKILL.md +45 -45
  1095. package/skills/skills/lingshu-os/units/os-878c18b3/SKILL.md +45 -45
  1096. package/skills/skills/lingshu-os/units/os-89ed7af1/SKILL.md +45 -45
  1097. package/skills/skills/lingshu-os/units/os-8cb7279d/SKILL.md +45 -45
  1098. package/skills/skills/lingshu-os/units/os-92276145/SKILL.md +45 -45
  1099. package/skills/skills/lingshu-os/units/os-955c4d66/SKILL.md +45 -45
  1100. package/skills/skills/lingshu-os/units/os-97aacf40/SKILL.md +45 -45
  1101. package/skills/skills/lingshu-os/units/os-9b6ed02c/SKILL.md +45 -45
  1102. package/skills/skills/lingshu-os/units/os-9c86a7a2/SKILL.md +45 -45
  1103. package/skills/skills/lingshu-os/units/os-a13ce4aa/SKILL.md +45 -45
  1104. package/skills/skills/lingshu-os/units/os-a568affe/SKILL.md +45 -45
  1105. package/skills/skills/lingshu-os/units/os-abd48f17/SKILL.md +45 -45
  1106. package/skills/skills/lingshu-os/units/os-b0416edc/SKILL.md +45 -45
  1107. package/skills/skills/lingshu-os/units/os-b6509cac/SKILL.md +45 -45
  1108. package/skills/skills/lingshu-os/units/os-b718657b/SKILL.md +45 -45
  1109. package/skills/skills/lingshu-os/units/os-b776ade1/SKILL.md +45 -45
  1110. package/skills/skills/lingshu-os/units/os-ba24fa08/SKILL.md +45 -45
  1111. package/skills/skills/lingshu-os/units/os-bd1fc177/SKILL.md +45 -45
  1112. package/skills/skills/lingshu-os/units/os-bda92711/SKILL.md +45 -45
  1113. package/skills/skills/lingshu-os/units/os-c0fa71bd/SKILL.md +45 -45
  1114. package/skills/skills/lingshu-os/units/os-c3d5cd44/SKILL.md +45 -45
  1115. package/skills/skills/lingshu-os/units/os-c6b6a763/SKILL.md +45 -45
  1116. package/skills/skills/lingshu-os/units/os-c7661eb1/SKILL.md +45 -45
  1117. package/skills/skills/lingshu-os/units/os-c76b5a43/SKILL.md +45 -45
  1118. package/skills/skills/lingshu-os/units/os-c7d35a30/SKILL.md +45 -45
  1119. package/skills/skills/lingshu-os/units/os-c980a25d/SKILL.md +45 -45
  1120. package/skills/skills/lingshu-os/units/os-c9f8df6e/SKILL.md +45 -45
  1121. package/skills/skills/lingshu-os/units/os-cc49ef2f/SKILL.md +45 -45
  1122. package/skills/skills/lingshu-os/units/os-cd9e686a/SKILL.md +45 -45
  1123. package/skills/skills/lingshu-os/units/os-cfa66a1b/SKILL.md +45 -45
  1124. package/skills/skills/lingshu-os/units/os-d237e500/SKILL.md +45 -45
  1125. package/skills/skills/lingshu-os/units/os-d39ef086/SKILL.md +45 -45
  1126. package/skills/skills/lingshu-os/units/os-d4f9e813/SKILL.md +45 -45
  1127. package/skills/skills/lingshu-os/units/os-d97915c0/SKILL.md +45 -45
  1128. package/skills/skills/lingshu-os/units/os-da0aadde/SKILL.md +45 -45
  1129. package/skills/skills/lingshu-os/units/os-da482caf/SKILL.md +45 -45
  1130. package/skills/skills/lingshu-os/units/os-dd4ff45e/SKILL.md +45 -45
  1131. package/skills/skills/lingshu-os/units/os-de0556c5/SKILL.md +45 -45
  1132. package/skills/skills/lingshu-os/units/os-e0ad3364/SKILL.md +45 -45
  1133. package/skills/skills/lingshu-os/units/os-e7612c68/SKILL.md +45 -45
  1134. package/skills/skills/lingshu-os/units/os-ea444e45/SKILL.md +45 -45
  1135. package/skills/skills/lingshu-os/units/os-ea6e7e0b/SKILL.md +45 -45
  1136. package/skills/skills/lingshu-os/units/os-ebc34d83/SKILL.md +45 -45
  1137. package/skills/skills/lingshu-os/units/os-ecbebbe3/SKILL.md +45 -45
  1138. package/skills/skills/lingshu-os/units/os-ecfceae7/SKILL.md +45 -45
  1139. package/skills/skills/lingshu-os/units/os-ed8de3a3/SKILL.md +45 -45
  1140. package/skills/skills/lingshu-os/units/os-f69c0b08/SKILL.md +45 -45
  1141. package/skills/skills/lingshu-os/units/os-f6ae6205/SKILL.md +45 -45
  1142. package/skills/skills/lingshu-os/units/os-f9bf8dd4/SKILL.md +45 -45
  1143. package/skills/skills/lingshu-os/units/os-fcdd828d/SKILL.md +45 -45
  1144. package/skills/skills/lingshu-pylang/SKILL.md +71 -71
  1145. package/skills/skills/lingshu-pylang/units/pylang-01b23f80/SKILL.md +45 -45
  1146. package/skills/skills/lingshu-pylang/units/pylang-074fd698/SKILL.md +45 -45
  1147. package/skills/skills/lingshu-pylang/units/pylang-0b490bb2/SKILL.md +45 -45
  1148. package/skills/skills/lingshu-pylang/units/pylang-0ca7f08b/SKILL.md +45 -45
  1149. package/skills/skills/lingshu-pylang/units/pylang-10ce3e91/SKILL.md +45 -45
  1150. package/skills/skills/lingshu-pylang/units/pylang-15f76c64/SKILL.md +45 -45
  1151. package/skills/skills/lingshu-pylang/units/pylang-1703046f/SKILL.md +45 -45
  1152. package/skills/skills/lingshu-pylang/units/pylang-1aa3e939/SKILL.md +45 -45
  1153. package/skills/skills/lingshu-pylang/units/pylang-1bed54cf/SKILL.md +45 -45
  1154. package/skills/skills/lingshu-pylang/units/pylang-1dd35612/SKILL.md +45 -45
  1155. package/skills/skills/lingshu-pylang/units/pylang-24273d7b/SKILL.md +45 -45
  1156. package/skills/skills/lingshu-pylang/units/pylang-2853f59f/SKILL.md +45 -45
  1157. package/skills/skills/lingshu-pylang/units/pylang-2a6bc16e/SKILL.md +45 -45
  1158. package/skills/skills/lingshu-pylang/units/pylang-2ae78997/SKILL.md +45 -45
  1159. package/skills/skills/lingshu-pylang/units/pylang-2bc88f4c/SKILL.md +45 -45
  1160. package/skills/skills/lingshu-pylang/units/pylang-31f5b8db/SKILL.md +45 -45
  1161. package/skills/skills/lingshu-pylang/units/pylang-36d178bc/SKILL.md +45 -45
  1162. package/skills/skills/lingshu-pylang/units/pylang-38600583/SKILL.md +45 -45
  1163. package/skills/skills/lingshu-pylang/units/pylang-38e8f9ff/SKILL.md +45 -45
  1164. package/skills/skills/lingshu-pylang/units/pylang-395085ca/SKILL.md +45 -45
  1165. package/skills/skills/lingshu-pylang/units/pylang-399b317e/SKILL.md +45 -45
  1166. package/skills/skills/lingshu-pylang/units/pylang-39c72c78/SKILL.md +45 -45
  1167. package/skills/skills/lingshu-pylang/units/pylang-3a659480/SKILL.md +45 -45
  1168. package/skills/skills/lingshu-pylang/units/pylang-482be62b/SKILL.md +45 -45
  1169. package/skills/skills/lingshu-pylang/units/pylang-486a1e94/SKILL.md +45 -45
  1170. package/skills/skills/lingshu-pylang/units/pylang-49026041/SKILL.md +45 -45
  1171. package/skills/skills/lingshu-pylang/units/pylang-4963b28a/SKILL.md +45 -45
  1172. package/skills/skills/lingshu-pylang/units/pylang-4af9140e/SKILL.md +45 -45
  1173. package/skills/skills/lingshu-pylang/units/pylang-4ca283f2/SKILL.md +45 -45
  1174. package/skills/skills/lingshu-pylang/units/pylang-4ddf31f3/SKILL.md +45 -45
  1175. package/skills/skills/lingshu-pylang/units/pylang-50614726/SKILL.md +45 -45
  1176. package/skills/skills/lingshu-pylang/units/pylang-5102c069/SKILL.md +45 -45
  1177. package/skills/skills/lingshu-pylang/units/pylang-521b1bf8/SKILL.md +45 -45
  1178. package/skills/skills/lingshu-pylang/units/pylang-5880b7a1/SKILL.md +45 -45
  1179. package/skills/skills/lingshu-pylang/units/pylang-61a9102d/SKILL.md +45 -45
  1180. package/skills/skills/lingshu-pylang/units/pylang-621123dd/SKILL.md +45 -45
  1181. package/skills/skills/lingshu-pylang/units/pylang-642cd625/SKILL.md +45 -45
  1182. package/skills/skills/lingshu-pylang/units/pylang-65ca79b7/SKILL.md +45 -45
  1183. package/skills/skills/lingshu-pylang/units/pylang-672df225/SKILL.md +45 -45
  1184. package/skills/skills/lingshu-pylang/units/pylang-67d3368e/SKILL.md +45 -45
  1185. package/skills/skills/lingshu-pylang/units/pylang-6be54340/SKILL.md +45 -45
  1186. package/skills/skills/lingshu-pylang/units/pylang-70b2006f/SKILL.md +45 -45
  1187. package/skills/skills/lingshu-pylang/units/pylang-70b215f1/SKILL.md +45 -45
  1188. package/skills/skills/lingshu-pylang/units/pylang-730c3fe4/SKILL.md +45 -45
  1189. package/skills/skills/lingshu-pylang/units/pylang-733c1286/SKILL.md +45 -45
  1190. package/skills/skills/lingshu-pylang/units/pylang-79845f4d/SKILL.md +45 -45
  1191. package/skills/skills/lingshu-pylang/units/pylang-7c4cc6f8/SKILL.md +45 -45
  1192. package/skills/skills/lingshu-pylang/units/pylang-7c7193ad/SKILL.md +45 -45
  1193. package/skills/skills/lingshu-pylang/units/pylang-7d86ab5d/SKILL.md +45 -45
  1194. package/skills/skills/lingshu-pylang/units/pylang-7df8ca78/SKILL.md +45 -45
  1195. package/skills/skills/lingshu-pylang/units/pylang-8182681d/SKILL.md +45 -45
  1196. package/skills/skills/lingshu-pylang/units/pylang-81ad40ee/SKILL.md +45 -45
  1197. package/skills/skills/lingshu-pylang/units/pylang-8283d7c0/SKILL.md +45 -45
  1198. package/skills/skills/lingshu-pylang/units/pylang-82b73f3d/SKILL.md +45 -45
  1199. package/skills/skills/lingshu-pylang/units/pylang-8404bbde/SKILL.md +45 -45
  1200. package/skills/skills/lingshu-pylang/units/pylang-8584040d/SKILL.md +45 -45
  1201. package/skills/skills/lingshu-pylang/units/pylang-85d8617b/SKILL.md +45 -45
  1202. package/skills/skills/lingshu-pylang/units/pylang-886935a3/SKILL.md +45 -45
  1203. package/skills/skills/lingshu-pylang/units/pylang-88ab2f96/SKILL.md +45 -45
  1204. package/skills/skills/lingshu-pylang/units/pylang-8b6f071e/SKILL.md +45 -45
  1205. package/skills/skills/lingshu-pylang/units/pylang-8d6ec58a/SKILL.md +45 -45
  1206. package/skills/skills/lingshu-pylang/units/pylang-8fe98252/SKILL.md +45 -45
  1207. package/skills/skills/lingshu-pylang/units/pylang-9018c39a/SKILL.md +45 -45
  1208. package/skills/skills/lingshu-pylang/units/pylang-91277748/SKILL.md +45 -45
  1209. package/skills/skills/lingshu-pylang/units/pylang-943b9dcb/SKILL.md +45 -45
  1210. package/skills/skills/lingshu-pylang/units/pylang-961e9e43/SKILL.md +45 -45
  1211. package/skills/skills/lingshu-pylang/units/pylang-962954d9/SKILL.md +45 -45
  1212. package/skills/skills/lingshu-pylang/units/pylang-9dbd8e2b/SKILL.md +45 -45
  1213. package/skills/skills/lingshu-pylang/units/pylang-a02eac31/SKILL.md +45 -45
  1214. package/skills/skills/lingshu-pylang/units/pylang-a4d3d7b1/SKILL.md +45 -45
  1215. package/skills/skills/lingshu-pylang/units/pylang-a7c3d0e2/SKILL.md +45 -45
  1216. package/skills/skills/lingshu-pylang/units/pylang-a88db70d/SKILL.md +45 -45
  1217. package/skills/skills/lingshu-pylang/units/pylang-ab7dddc2/SKILL.md +45 -45
  1218. package/skills/skills/lingshu-pylang/units/pylang-ac2a4b38/SKILL.md +45 -45
  1219. package/skills/skills/lingshu-pylang/units/pylang-afaf67c0/SKILL.md +45 -45
  1220. package/skills/skills/lingshu-pylang/units/pylang-b00660e6/SKILL.md +45 -45
  1221. package/skills/skills/lingshu-pylang/units/pylang-b4d7616d/SKILL.md +45 -45
  1222. package/skills/skills/lingshu-pylang/units/pylang-b67b1878/SKILL.md +45 -45
  1223. package/skills/skills/lingshu-pylang/units/pylang-b8040e1c/SKILL.md +45 -45
  1224. package/skills/skills/lingshu-pylang/units/pylang-b880c6c6/SKILL.md +45 -45
  1225. package/skills/skills/lingshu-pylang/units/pylang-b8d45f76/SKILL.md +45 -45
  1226. package/skills/skills/lingshu-pylang/units/pylang-ba956e52/SKILL.md +45 -45
  1227. package/skills/skills/lingshu-pylang/units/pylang-bb18b1f9/SKILL.md +45 -45
  1228. package/skills/skills/lingshu-pylang/units/pylang-bb46f3f2/SKILL.md +45 -45
  1229. package/skills/skills/lingshu-pylang/units/pylang-be55a094/SKILL.md +45 -45
  1230. package/skills/skills/lingshu-pylang/units/pylang-beb47b63/SKILL.md +45 -45
  1231. package/skills/skills/lingshu-pylang/units/pylang-c017681a/SKILL.md +45 -45
  1232. package/skills/skills/lingshu-pylang/units/pylang-c1317cd9/SKILL.md +45 -45
  1233. package/skills/skills/lingshu-pylang/units/pylang-c36fabf7/SKILL.md +45 -45
  1234. package/skills/skills/lingshu-pylang/units/pylang-c42465ec/SKILL.md +45 -45
  1235. package/skills/skills/lingshu-pylang/units/pylang-c5c76a12/SKILL.md +45 -45
  1236. package/skills/skills/lingshu-pylang/units/pylang-c910ad31/SKILL.md +45 -45
  1237. package/skills/skills/lingshu-pylang/units/pylang-ca9332cf/SKILL.md +45 -45
  1238. package/skills/skills/lingshu-pylang/units/pylang-cce90fa0/SKILL.md +45 -45
  1239. package/skills/skills/lingshu-pylang/units/pylang-cd4234a5/SKILL.md +45 -45
  1240. package/skills/skills/lingshu-pylang/units/pylang-cf0fca1c/SKILL.md +45 -45
  1241. package/skills/skills/lingshu-pylang/units/pylang-d2001e1f/SKILL.md +45 -45
  1242. package/skills/skills/lingshu-pylang/units/pylang-d616eb28/SKILL.md +45 -45
  1243. package/skills/skills/lingshu-pylang/units/pylang-d8962e66/SKILL.md +45 -45
  1244. package/skills/skills/lingshu-pylang/units/pylang-db6214cd/SKILL.md +45 -45
  1245. package/skills/skills/lingshu-pylang/units/pylang-dcde3040/SKILL.md +45 -45
  1246. package/skills/skills/lingshu-pylang/units/pylang-dfad3dba/SKILL.md +45 -45
  1247. package/skills/skills/lingshu-pylang/units/pylang-dfd5aac2/SKILL.md +45 -45
  1248. package/skills/skills/lingshu-pylang/units/pylang-e1aa3818/SKILL.md +45 -45
  1249. package/skills/skills/lingshu-pylang/units/pylang-e476915b/SKILL.md +45 -45
  1250. package/skills/skills/lingshu-pylang/units/pylang-e88e31fd/SKILL.md +45 -45
  1251. package/skills/skills/lingshu-pylang/units/pylang-ecd569d2/SKILL.md +45 -45
  1252. package/skills/skills/lingshu-pylang/units/pylang-ecf27e0c/SKILL.md +45 -45
  1253. package/skills/skills/lingshu-pylang/units/pylang-f124f0e6/SKILL.md +45 -45
  1254. package/skills/skills/lingshu-pylang/units/pylang-f127a8d1/SKILL.md +45 -45
  1255. package/skills/skills/lingshu-pylang/units/pylang-f2d6ec27/SKILL.md +45 -45
  1256. package/skills/skills/lingshu-pylang/units/pylang-f2f40090/SKILL.md +45 -45
  1257. package/skills/skills/lingshu-pylang/units/pylang-f4aa9e65/SKILL.md +45 -45
  1258. package/skills/skills/lingshu-pylang/units/pylang-f4f820d4/SKILL.md +45 -45
  1259. package/skills/skills/lingshu-pylang/units/pylang-f5b34833/SKILL.md +45 -45
  1260. package/skills/skills/lingshu-pylang/units/pylang-f6ebb66e/SKILL.md +45 -45
  1261. package/skills/skills/lingshu-pylang/units/pylang-f78bdcd7/SKILL.md +45 -45
  1262. package/skills/skills/lingshu-pylang/units/pylang-f92bc49b/SKILL.md +45 -45
  1263. package/skills/skills/lingshu-pylang/units/pylang-fd7595f0/SKILL.md +45 -45
  1264. package/skills/skills/lingshu-pylang/units/pylang-fda87aa1/SKILL.md +45 -45
  1265. package/src/hooks.ts +48 -31
  1266. package/src/index.ts +3 -0
  1267. package/src/lib/console_web.mjs +96 -0
  1268. package/src/lib/python_path.ts +71 -71
  1269. package/src/lib/session_state.ts +127 -127
  1270. package/src/lib/whitebox_llm.ts +311 -311
  1271. package/ui/minimal/LICENSE +21 -0
  1272. package/ui/minimal/install.ps1 +168 -0
  1273. package/ui/minimal/integrity.json +41 -0
  1274. package/ui/minimal/payload/build-ui.mjs +16 -0
  1275. package/ui/minimal/payload/lib/client.js +18 -0
  1276. package/ui/minimal/payload/lib/lib/console_web.mjs +96 -0
  1277. package/ui/minimal/payload/src/lib/console_web.mjs +96 -0
  1278. package/ui/minimal/payload/web/app.js +154 -0
  1279. package/ui/minimal/payload/web/client.js +14 -0
  1280. package/ui/minimal/payload/web/entry.js +1 -0
  1281. package/ui/minimal/payload/web/index.html +3 -0
  1282. package/ui/minimal/payload/web/style.css +3 -0
  1283. package/ui/minimal//344/275/277/347/224/250/350/257/264/346/230/216.md +60 -0
  1284. package/ui/minimal//345/215/270/350/275/275UI.cmd +6 -0
  1285. package/ui/minimal//345/256/211/350/243/205UI.cmd +6 -0
  1286. package/utf8_boot.py +237 -237
  1287. package/web/app.js +154 -0
  1288. package/web/client.js +14 -0
  1289. package/web/entry.js +1 -0
  1290. package/web/index.html +3 -0
  1291. package/web/style.css +3 -0
  1292. package/zcode/AGENTS.md +8 -3
  1293. package/zcode/README.md +41 -41
package/md_cg/backfill.py CHANGED
@@ -1,1329 +1,1329 @@
1
- # -*- coding: utf-8 -*-
2
- """真实库对齐(P32):CCG 回填 + 能力标签注入。
3
-
4
- 为什么是「回填」而不是「重写」
5
- ------------------------------
6
- 迁移入库的历史节点里,条件信息**往往已经在 frontmatter 里**:
7
- `condition_space`(四槽)、`non_applicable_conditions`、`verification_basis`、
8
- `state_attributes.comment.*`。缺的只是把它们渲染成 CCG 正文行(`# 生效条件:…`
9
- 等)。缺了正文行,`judge_qualification` 一律判 BLINDSPOT——节点从「可检索」
10
- 掉到「不可判定」。
11
-
12
- 回填 = 把**已声明的证据**渲染成 CCG 行。它不发明条件,只搬运已有声明。
13
-
14
- 生效条件的来源链(本轮口径修正:观测位置 ≠ 生效条件)
15
- ----------------------------------------------------
16
- 生效条件**只能**来自两处,且优先成文声明:
17
- ① `state_attributes.comment.生效条件`(人/流程写下的成文声明)
18
- ② `nodefile.condition_space_text(frontmatter.condition_space)`(四槽合成)
19
- 旧版曾回退到 `condition_space.observation_position` **单槽**,加前缀「观测位置:」
20
- 冒充生效条件——那是把坐标的一维当成整条生效条件,真实库因此落了 109 条弱等价行。
21
- 该回退**已删除**;四槽不齐 → 不写(部分槽不构成完整条件空间声明),转待补台账。
22
- `fix_conditions_*` 三个函数用于清洗存量:把已落库的单槽冒充行**重渲染**为合规
23
- 合成声明,或**删除并登记待补**——全程留痕、可回滚、幂等。
24
-
25
- 纪律(对齐 consolidate 的固化纪律)
26
- ----------------------------------
27
- · 不猜测:字段只在**有来源**时才写;来源写进留痕 `basis`;无来源 → 跳过并计入
28
- `unfillable`,绝不编造。
29
- · 可预演:`plan()` 只出报表、不改盘;`apply()` 才写。默认只回填「补完即可判定」
30
- 的节点,`partial`(补完仍不全)默认不写,除非显式 `include_partial=True`。
31
- · 可留痕:每次写入记一条 `_backfill.jsonl`(字段 / 写入值 / 依据 / 批次 / 操作者)。
32
- · 可回滚:`rollback()` 按留痕反向应用,且**只在当前值仍等于写入值**时撤销
33
- (防覆盖后续人工修改),否则计入 `conflict` 跳过。
34
- · fail-closed:密文节点一律跳过,**绝不解密回写**。
35
-
36
- 能力标签注入
37
- ------------
38
- `cap:<op>` 标签让路由能返回建议能力名(`mcp_server` 读 frontmatter.tags 的
39
- `cap:` 前缀)。匹配是**关键词启发式**(对标 `tokens.ALL_OPS` 工具名清单),
40
- 不是语义推断:结果带 `matched_by`(命中的关键词)与 `confidence`,调用方据此
41
- 判断可信度。只改 frontmatter.tags,不动正文。
42
- """
43
- from __future__ import annotations
44
-
45
- import hashlib
46
- import os
47
- import time
48
- from collections import OrderedDict
49
-
50
- from . import crypto, nodefile, tokens
51
- from .consolidate import _has_ccg_line, _upsert_ccg_line
52
- from .fsutil import append_jsonl, read_jsonl
53
- from .mdcos import MdCGOS, _ccg_field
54
- from .readcache import direct_read
55
-
56
- # ---- 常量 ----------------------------------------------------------------
57
-
58
- BACKFILL_LOG = "_backfill.jsonl"
59
-
60
- # 负记忆层是「故意无条件」的(覆盖标记),派生脚手架不该再被回填成事实
61
- SKIP_LAYERS = ("rejected", "unresolved", "goals")
62
- # 推断脚手架 / 概念层不得回填:否则会污染锚点解析(见 predict.anchor_from_description)
63
- SKIP_TAGS = ("gap_hint", "scene", "reconstructed", "concept", "insight")
64
- # 记忆系统**内部脚手架层**(锚点解析 anchor / 自模型修订 self):不是用户知识,永不可回填;
65
- # 被回填成事实会污染锚点解析与自模型(与 SKIP_LAYERS 同源理由)。crosscheck 亦复用之。
66
- INTERNAL_LAYERS = ("anchor", "self")
67
-
68
- # 验证基底枚举 → 可读声明(人/流程声明,不靠模型生成)
69
- BASIS_TEXT = OrderedDict((
70
- ("compiler", "编译器/静态检查通过"),
71
- ("test", "单元测试/回归测试通过"),
72
- ("measurement", "实测数据(benchmark / 采样)"),
73
- ("formal_proof", "形式化证明"),
74
- ("data", "数据/语料统计"),
75
- # 来源一致性档(文科):文科知识非可复现的物理事实,以来源表述一致为足够基底
76
- ("textbook", "依人教版教材表述一致(文科·来源一致性)"),
77
- ("public_kb", "公开知识库条目一致(文科·来源一致性)"),
78
- ("other", "人工评审或离线工序声明"),
79
- ))
80
- BASIS_ENUM_DEFAULT = "other"
81
-
82
- BATCH_DEFAULT = "backfill"
83
-
84
- #: 生效条件的**唯一结构化来源**:condition_space 四槽合成(见 nodefile)
85
- BASIS_CONDITION_SYNTH = "frontmatter.condition_space(四槽合成)"
86
- #: 旧口径残留标记:把单槽 observation_position 冒充成生效条件的留痕 basis
87
- LEGACY_CONDITION_BASIS = "frontmatter.condition_space.observation_position"
88
- #: 存量清洗批次的默认批次名
89
- FIX_BATCH_DEFAULT = "cond_fix"
90
-
91
- #: 槽名 → 人读标签(台账/报告用;与 nodefile.CONDITION_SLOTS 同源)
92
- _SLOT_LABEL = dict(nodefile.CONDITION_SLOTS)
93
-
94
- # 能力标签规则:cap → 关键词(小写,中文原样)。仅保留 ALL_OPS 里真实存在的 op。
95
- _CAP_RULES_RAW = OrderedDict((
96
- ("route", ("路由", "召回", "检索", "rank", "rrf", "route")),
97
- ("export", ("导出", "灾备", "备份", "搬运", "export", "evidence_pack")),
98
- ("ingest", ("摄取", "导入", "摄入", "ingest", "分派")),
99
- ("session", ("会话", "续接", "上下文压缩", "session", "compact")),
100
- ("maintain", ("维护", "重要性", "重算", "快照", "前馈", "模式分离", "recalc")),
101
- ("consolidate", ("固化", "提升", "归纳", "聚类", "升格", "promote", "induce")),
102
- ("insight", ("洞察", "情景重构", "盲区", "归因", "reconstruct", "outlook")),
103
- ("whitebox", ("白箱", "资格判定", "裁决", "四态", "whitebox")),
104
- ("verify", ("验证", "核验", "verdict")),
105
- ("predict", ("预测", "趋势", "外推", "predict")),
106
- ("causal", ("因果", "causal")),
107
- ("metacognition", ("元认知", "metacognition")),
108
- ("self_state", ("自我状态", "状态卡", "self_state")),
109
- ("evolution", ("演化", "evolution", "账本")),
110
- ("sustain", ("维生", "自愈", "心跳", "sustain")),
111
- ("scrub", ("擦除", "去污", "scrub")),
112
- ("protect", ("保护", "私有内容", "protect")),
113
- ("forget", ("遗忘", "失效", "forget")),
114
- ("link", ("蜂群", "对等", "信任", "link")),
115
- ("identity", ("身份", "主体", "identity")),
116
- ("goal", ("目标", "goal")),
117
- ("recent", ("近期事件", "recent")),
118
- ("theory", ("协议版本", "theory")),
119
- ("consistency", ("一致性", "自洽", "consistency")),
120
- ("ref", ("回读", "漂移", "悬空", "code_ref", "doc_ref")),
121
- ("index_code", ("代码索引", "index_code")),
122
- ("index_doc", ("文档索引", "章节索引", "index_doc")),
123
- ))
124
- # 只保留真实 op,未知 op 静默丢弃(避免注入无效能力名)
125
- CAP_RULES = OrderedDict(
126
- (cap, kws) for cap, kws in _CAP_RULES_RAW.items() if cap in tokens.ALL_OPS)
127
-
128
-
129
- # ---- 通用工具 ------------------------------------------------------------
130
-
131
- # 生效条件:x 为 str 时返回 MdCGOS(x),否则原样返回 x。
132
- def _as_cg(x):
133
- """接受 root 路径或已构造的 cg 实例——保持密级隔离与密钥上下文。"""
134
- return MdCGOS(x) if isinstance(x, str) else x
135
-
136
-
137
- # 生效条件:v 为 list/tuple 时返回分号连接的非空元素文本;v 为 None 或空串时返回 "";否则返回 str(v).strip()(v 为 0 或 False 走此支返回 "0"/"False")。
138
- def _as_text(v) -> str:
139
- if isinstance(v, (list, tuple)):
140
- return ";".join(str(x).strip() for x in v if str(x).strip())
141
- if v in (None, ""):
142
- return ""
143
- return str(v).strip()
144
-
145
-
146
- # 生效条件:fm 为假值时按 {} 处理,state_attributes.comment 为 dict 时返回该 dict,否则返回 {}。
147
- def _comment(fm: dict) -> dict:
148
- st = (fm or {}).get("state_attributes")
149
- c = st.get("comment") if isinstance(st, dict) else None
150
- return c if isinstance(c, dict) else {}
151
-
152
-
153
- # 生效条件:fm 的 state_attributes 为 dict 且其下 comment 为 dict 时原样返回该 comment;否则创建并返回空 comment dict(state_attributes 非 dict 时置 fm["state_attributes"]={},comment 非 dict 时置 st["comment"]={})。
154
- def _ensure_comment(fm: dict) -> dict:
155
- st = fm.get("state_attributes")
156
- if not isinstance(st, dict):
157
- st = {}
158
- fm["state_attributes"] = st
159
- c = st.get("comment")
160
- if not isinstance(c, dict):
161
- c = {}
162
- st["comment"] = c
163
- return c
164
-
165
-
166
- # 生效条件:e 的 id 为真值时返回 id,否则返回 e 的 path 基名去掉最后 3 个字符(path 为假值时基名为空,结果空串)。
167
- def _node_id(e: dict) -> str:
168
- return e.get("id") or os.path.basename(e.get("path") or "")[:-3]
169
-
170
-
171
- # 生效条件:fm 的 condition_space 四槽齐全时返回 nodefile.condition_space_text 合成文本,否则返回空串。
172
- def _condition_text(fm: dict) -> str:
173
- """→ 条件空间四槽合成的生效条件声明;四槽不齐 → ""(不冒充)。
174
-
175
- **唯一**的 condition_space → 生效条件 路径。旧版在此回退到
176
- `observation_position` **单槽**加「观测位置:」前缀——那正是
177
- 「观测位置 ≠ 生效条件」的污染源(真实库 109 条),已删除。
178
- """
179
- return nodefile.condition_space_text((fm or {}).get("condition_space"))
180
-
181
-
182
- # 生效条件:s 为真值时返回其 sha1 前 12 位,s 为假值(None/空串等)时对空串取 sha1 前 12 位。
183
- def _sha(s: str) -> str:
184
- return hashlib.sha1((s or "").encode("utf-8")).hexdigest()[:12]
185
-
186
-
187
- # 生效条件:batch 与 nid 经 f-string 拼接后取 sha1 前 12 位;两者为 None 会字符串化为 "None"。
188
- def _entry_id(batch: str, nid: str) -> str:
189
- return hashlib.sha1(f"{batch}|{nid}".encode("utf-8")).hexdigest()[:12]
190
-
191
-
192
- # 生效条件:content 中 strip 后以 # 开头且去掉 # 与空白后、全角或半角冒号前首段等于 field 的整行被删除,其余行保留并 join。
193
- def _remove_ccg_line(content: str, field: str) -> str:
194
- """删掉 `# <字段>:…` 整行(回滚用)。"""
195
- keep = []
196
- for ln in (content or "").split("\n"):
197
- s = ln.strip().lstrip("#").strip()
198
- name = s.split(":")[0].split(":")[0].strip()
199
- if ln.strip().startswith("#") and name == field:
200
- continue
201
- keep.append(ln)
202
- return "\n".join(keep)
203
-
204
-
205
- # 生效条件:cg.root 与模块级常量 BACKFILL_LOG 拼接为返回路径。
206
- def _log_path(cg) -> str:
207
- return os.path.join(cg.root, BACKFILL_LOG)
208
-
209
-
210
- # ---- 字段推导(唯一入口:只搬运已声明的证据) -----------------------------
211
-
212
- # 生效条件:fm 与 content 给定时,仅对 content 中尚无对应 CCG 行的字段(功能名/生效条件/子功能/执行/验证方式/不适用条件)从 fm 的已有声明(state_attributes.comment、frontmatter、verification_basis、或形参 basis_text)取值,值非空且非占位文本才写入 out,假值不写、占位文本只把字段名追加进 placeholder_out(未传该形参时用临时列表)。
213
- def derive_fields(fm: dict, content: str, basis_text: str = None,
214
- placeholder_out: list = None) -> dict:
215
- """按**已有声明**推导可回填字段 → `{field: (value, basis)}`。
216
-
217
- 无来源的字段不出现在结果里(不猜测)。
218
- **占位标记(`骨架锚点`/`内容待填充`)同样不出现**——它不是已声明的事实;
219
- 被丢弃的字段名记入 `placeholder_out`(可选出参),供报表区分
220
- 「无来源」与「待填充」两种缺口。
221
- """
222
- c = _comment(fm)
223
- st = fm.get("state_attributes")
224
- st = st if isinstance(st, dict) else {}
225
- ph = placeholder_out if placeholder_out is not None else []
226
- out = {}
227
-
228
- # 生效条件:field 与 basis 在 value 为真值且 nodefile.is_placeholder_text(value) 为假时写入 out;value 为假值不写入;value 为占位文本时仅把 field 记入 ph。
229
- def _put(field, value, basis):
230
- """有值且非占位标记才写出;占位值只记名,绝不渲染成事实。"""
231
- if not value:
232
- return
233
- if nodefile.is_placeholder_text(value):
234
- ph.append(field)
235
- return
236
- out[field] = (value, basis)
237
-
238
- if not _has_ccg_line(content, "功能名"):
239
- # 优先 state_attributes.name(迁移入库写入的规范功能名),回退 frontmatter.title
240
- raw_name = st.get("name")
241
- v = _as_text(raw_name) if isinstance(raw_name, (str, list, tuple)) else ""
242
- src = "state_attributes.name"
243
- if not v:
244
- v, src = _as_text(fm.get("title")), "frontmatter.title"
245
- _put("功能名", v, src)
246
-
247
- if not _has_ccg_line(content, "生效条件"):
248
- v = _as_text(c.get("生效条件") or c.get("适用条件"))
249
- src = "state_attributes.comment.生效条件"
250
- if not v:
251
- # 结构化来源:整条条件空间声明的合成,**不是** observation_position 单槽
252
- v, src = _condition_text(fm), BASIS_CONDITION_SYNTH
253
- _put("生效条件", v, src)
254
-
255
- if not _has_ccg_line(content, "子功能"):
256
- _put("子功能", _as_text(c.get("子功能") or c.get("子内容")),
257
- "state_attributes.comment.子功能")
258
-
259
- if not _has_ccg_line(content, "执行"):
260
- _put("执行", _as_text(c.get("执行") or c.get("执行方式")),
261
- "state_attributes.comment.执行")
262
-
263
- if not _has_ccg_line(content, "验证方式"):
264
- v = _as_text(c.get("验证方式"))
265
- src = "state_attributes.comment.验证方式"
266
- if not v and nodefile.verification_basis_valid(fm):
267
- vb = fm.get("verification_basis")
268
- v, src = BASIS_TEXT.get(vb, ""), f"frontmatter.verification_basis={vb}"
269
- if not v and basis_text:
270
- v, src = basis_text, "declared.basis_text"
271
- _put("验证方式", v, src)
272
-
273
- if not _has_ccg_line(content, "不适用条件"):
274
- _put("不适用条件",
275
- _as_text(c.get("不适用条件") or fm.get("non_applicable_conditions")),
276
- "state_attributes.comment/frontmatter.non_applicable_conditions")
277
-
278
- return out
279
-
280
-
281
- # ---- 节点筛选 ------------------------------------------------------------
282
-
283
- # 生效条件:cg 无 _readable 可调用时返回 True;有可调用时返回 bool(fn(e)),fn(e) 抛异常时返回 False。
284
- def _readable_guard(cg, e) -> bool:
285
- fn = getattr(cg, "_readable", None)
286
- if not callable(fn):
287
- return True
288
- try:
289
- return bool(fn(e))
290
- except Exception: # noqa: BLE001
291
- return False
292
-
293
-
294
- # 生效条件:仅当 cg 对 e 读出的 fm 非 None、content 未被 crypto.is_encrypted、e['layer'] 不在 SKIP_LAYERS 且 fm.get('tags') 无命中 SKIP_TAGS、ccg_completeness(content)['complete'] 为假时才继续——derive_fields(受 basis_text 影响)过滤掉 content 已有 CCG 行的可写字段为空时按 placeholder_out 是否非空返回 ('placeholder'/'unfillable', None),非空时返回 ('', item)(item 的 id 取 nid、class 依 undeducible 是否为空取 'backfillable' 或 'partial');上述四个前置不满足时依次返回 ('unreadable'/'locked'/'derived'/'present', None)。
295
- def _classify(cg, e, nid, basis_text=None):
296
- """→ (skip_reason, item);skip_reason 非空表示不参与回填。"""
297
- fm, content = direct_read(cg, e)
298
- if fm is None:
299
- return "unreadable", None
300
- if crypto.is_encrypted(content):
301
- return "locked", None
302
- tags = fm.get("tags") or []
303
- if e.get("layer") in SKIP_LAYERS or any(t in SKIP_TAGS for t in tags):
304
- return "derived", None
305
- cpl = nodefile.ccg_completeness(content)
306
- if cpl["complete"]:
307
- return "present", None
308
- ph_fields = []
309
- der = derive_fields(fm, content, basis_text=basis_text,
310
- placeholder_out=ph_fields)
311
- fill = {f: der[f] for f in der if not _has_ccg_line(content, f)}
312
- required_missing = [f for f in nodefile.CCG_REQUIRED
313
- if not _has_ccg_line(content, f)]
314
- undeducible = [f for f in required_missing if f not in der]
315
- if not fill:
316
- # 无可写字段:区分「无来源」(unfillable)与「字段值全是待填充标记」
317
- # (placeholder)——后者是空壳节点,须转待填充工单,而非静默计入无来源。
318
- return ("placeholder" if ph_fields else "unfillable"), None
319
- cls = "backfillable" if not undeducible else "partial"
320
- # 待补台账:生效条件既不在正文、也推不出(四槽不全)→ 记缺失槽名。
321
- # 这不是「无来源」而是**缺证据**:补不动者按裁定判 BLINDSPOT,绝不静默 ACCEPT。
322
- cond_pending = []
323
- if not _has_ccg_line(content, "生效条件") and "生效条件" not in der:
324
- cond_pending = nodefile.condition_space_missing(fm.get("condition_space"))
325
- return "", {
326
- "id": nid, "layer": e.get("layer"), "class": cls,
327
- "fill": {f: {"value": v, "basis": b} for f, (v, b) in fill.items()},
328
- "missing_undeducible": undeducible,
329
- "placeholder_fields": ph_fields,
330
- "conditions_pending": cond_pending,
331
- "before_ratio": cpl["ratio"],
332
- }
333
-
334
-
335
- # 生效条件:x 经 _as_cg 后遍历 cg.index.nodes,按 ids/layer/prefix 过滤,内部层/不可读/locked/derived/present/unfillable/placeholder/partial 且 include_partial 为 False 分别计数跳过,其余标记 entry_id 并计入 targeted,items 受 limit 限制(limit 为 None 或 len(items) < limit 时追加),返回 dry_run rep。
336
- def plan(x, layer=None, limit=None, ids=None, include_partial=False,
337
- basis_text=None, prefix=None) -> dict:
338
- """预演:产出可回填清单,不写盘。
339
-
340
- `prefix`:按 id 前缀收窄范围(真实库用 `kp_`,与核对工单同一边界);
341
- 内部 `anchor`/`self` 层一律出局(计入 `skipped_internal`)。
342
- """
343
- cg = _as_cg(x)
344
- rep = {"root": cg.root, "dry_run": True, "action": "backfill",
345
- "prefix": prefix, "nodes_scanned": 0, "skipped_locked": 0,
346
- "skipped_derived": 0, "skipped_internal": 0,
347
- "skipped_present": 0, "skipped_denied": 0, "unfillable": 0,
348
- "skipped_placeholder": 0, "nodes_with_placeholder": 0,
349
- "skipped_partial": 0, "targeted": 0,
350
- # 待写节点中生效条件仍缺声明的数量(全库台账见 conditions_pending)
351
- "targeted_missing_conditions": 0, "items": []}
352
- want = set(ids) if ids else None
353
- for nid, e in list((cg.index.get("nodes") or {}).items()):
354
- if want is not None and nid not in want:
355
- continue
356
- if prefix and not str(nid).startswith(prefix):
357
- continue
358
- if layer and e.get("layer") != layer:
359
- continue
360
- if e.get("layer") in INTERNAL_LAYERS:
361
- rep["skipped_internal"] += 1
362
- continue
363
- if not _readable_guard(cg, e):
364
- rep["skipped_denied"] += 1
365
- continue
366
- rep["nodes_scanned"] += 1
367
- reason, item = _classify(cg, e, nid, basis_text=basis_text)
368
- if reason == "locked":
369
- rep["skipped_locked"] += 1
370
- continue
371
- if reason == "derived":
372
- rep["skipped_derived"] += 1
373
- continue
374
- if reason == "present":
375
- rep["skipped_present"] += 1
376
- continue
377
- if reason == "unfillable":
378
- rep["unfillable"] += 1
379
- continue
380
- if reason == "placeholder":
381
- rep["skipped_placeholder"] += 1
382
- continue
383
- if item.get("placeholder_fields"):
384
- rep["nodes_with_placeholder"] += 1
385
- if item.get("conditions_pending"):
386
- rep["targeted_missing_conditions"] += 1
387
- if item["class"] == "partial" and not include_partial:
388
- rep["skipped_partial"] += 1
389
- continue
390
- item["entry_id"] = _entry_id("backfill", nid)
391
- rep["targeted"] += 1
392
- if limit is None or len(rep["items"]) < limit:
393
- rep["items"].append(item)
394
- rep["planned_ids"] = [i["id"] for i in rep["items"]]
395
- return rep
396
-
397
-
398
- # ---- 回填写入 / 回滚 / 留痕 ----------------------------------------------
399
-
400
- # 生效条件:x 可被 _as_cg 解释为 CG 句柄时,按 layer/ids/prefix/entry_ids 选定条目做回填并返回含 written 等计数的 rep,其中 limit 非 None 时把写入数截断到该值。
401
- def apply(x, ids=None, entry_ids=None, layer=None, limit=None,
402
- batch=BATCH_DEFAULT, include_partial=False, basis_text=None,
403
- actor=None, prefix=None) -> dict:
404
- """执行回填:逐节点改写 md,写 `_backfill.jsonl` 留痕。"""
405
- cg = _as_cg(x)
406
- batch = batch or BATCH_DEFAULT
407
- p = plan(cg, layer=layer, limit=None, ids=ids, prefix=prefix,
408
- include_partial=include_partial, basis_text=basis_text)
409
- items = p["items"]
410
- if entry_ids:
411
- want = set(entry_ids)
412
- items = [i for i in items if i["entry_id"] in want]
413
- rep = {"root": cg.root, "dry_run": False, "action": "backfill",
414
- "batch": batch, "actor": actor, "planned": len(items),
415
- "written": 0, "skipped_drift": 0, "skipped_locked": 0,
416
- "entry_ids": [], "by_field": {}}
417
- for it in items:
418
- if limit is not None and rep["written"] >= limit:
419
- break
420
- nid = it["id"]
421
- e = cg.index["nodes"].get(nid)
422
- if not e:
423
- rep["skipped_drift"] += 1
424
- continue
425
- fm, content = direct_read(cg, e)
426
- if fm is None or crypto.is_encrypted(content):
427
- rep["skipped_locked"] += 1
428
- continue
429
- # 预演到执行之间节点可能被改动:只写仍缺失的字段
430
- todo = {f: d for f, d in it["fill"].items()
431
- if not _has_ccg_line(content, f)}
432
- if not todo:
433
- rep["skipped_drift"] += 1
434
- continue
435
- comment0 = _comment(fm)
436
- # 记录改写前的真相:rollback 必须「还原」而非「删除」——否则 comment
437
- # 里原有的声明会被误删,导致回填不可重复(回滚不是真逆操作)。
438
- prev_c = {f: comment0[f] for f in todo if f in comment0}
439
- fm_before = {}
440
- if "不适用条件" in todo:
441
- fm_before["non_applicable_conditions"] = {
442
- "had": "non_applicable_conditions" in fm,
443
- "value": fm.get("non_applicable_conditions")}
444
- if "验证方式" in todo and not nodefile.verification_basis_valid(fm):
445
- fm_before["verification_basis"] = {
446
- "had": "verification_basis" in fm,
447
- "value": fm.get("verification_basis")}
448
- comment = _ensure_comment(fm)
449
- wid = _sha(f"{nid}|{batch}|{time.time()}")
450
- applied = {}
451
- for f, d in todo.items():
452
- content = _upsert_ccg_line(content, f, d["value"])
453
- comment[f] = d["value"]
454
- if f == "不适用条件":
455
- fm["non_applicable_conditions"] = [
456
- s.strip() for s in d["value"].split(";") if s.strip()]
457
- if f == "验证方式" and not nodefile.verification_basis_valid(fm):
458
- fm["verification_basis"] = BASIS_ENUM_DEFAULT
459
- applied[f] = {"after": d["value"], "basis": d["basis"],
460
- "before": prev_c.get(f)}
461
- rep["by_field"][f] = rep["by_field"].get(f, 0) + 1
462
- cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
463
- durable=True)
464
- append_jsonl(_log_path(cg), {
465
- "action": "backfill", "ts": time.time(), "batch": batch,
466
- "actor": actor, "entry_id": it["entry_id"], "write_id": wid,
467
- "node": nid, "layer": e.get("layer"), "fields": applied,
468
- "fm_before": fm_before,
469
- "content_hash_after": _sha(content)})
470
- rep["written"] += 1
471
- rep["entry_ids"].append(it["entry_id"])
472
- if rep["written"]:
473
- cg.rebuild_index()
474
- rep["plan_remaining"] = max(0, p["targeted"] - len(items))
475
- return rep
476
-
477
-
478
- # 生效条件:x 经 _as_cg 定位后读留痕日志,仅对 action=='backfill' 且(batch 为假值则不过滤 batch,否则 rec['batch']==batch)、(entry_ids 为假值则不过滤,否则 rec['entry_id'] 属于该集合)、write_id 未出现在已完成 rollback 集合中、节点命中 cg.index['nodes'] 且 direct_read(cg, e) 的 fm 可读、字段当前 _ccg_field(content, f) 等于留痕 after 的记录执行撤销写回(before 为 None 则删该 comment 键,否则还原原值),无字段可撤销只计 conflict 不写盘,reverted 非空时 rebuild_index,结果汇总进返回的 rep。
479
- def rollback(x, batch=None, entry_ids=None, actor=None) -> dict:
480
- """按留痕反向应用:撤销本批次回填(当前值 ≠ 写入值时跳过,防覆盖)。"""
481
- cg = _as_cg(x)
482
- want = set(entry_ids) if entry_ids else None
483
- rep = {"root": cg.root, "action": "backfill_rollback", "actor": actor,
484
- "batch": batch, "reverted": 0, "conflict": 0, "missing": 0,
485
- "fields_reverted": 0, "skipped_done": 0}
486
- log = list(read_jsonl(_log_path(cg)) or [])
487
- done = {r.get("write_id") for r in log
488
- if r.get("action") == "backfill_rollback" and r.get("write_id")}
489
- for rec in log:
490
- if rec.get("action") != "backfill":
491
- continue
492
- if rec.get("write_id") and rec.get("write_id") in done:
493
- rep["skipped_done"] += 1
494
- continue
495
- if batch and rec.get("batch") != batch:
496
- continue
497
- if want is not None and rec.get("entry_id") not in want:
498
- continue
499
- nid = rec.get("node")
500
- e = cg.index["nodes"].get(nid)
501
- if not e:
502
- rep["missing"] += 1
503
- continue
504
- fm, content = direct_read(cg, e)
505
- if fm is None:
506
- rep["missing"] += 1
507
- continue
508
- comment = _comment(fm)
509
- reverted, conflicted = {}, []
510
- for f, d in (rec.get("fields") or {}).items():
511
- if _ccg_field(content, f) != d.get("after"):
512
- conflicted.append(f) # 已被后续修改 → 不撤销
513
- continue
514
- content = _remove_ccg_line(content, f)
515
- b = d.get("before")
516
- if b is None:
517
- comment.pop(f, None) # 原本就没有 → 删回「无」
518
- else:
519
- comment[f] = b # 原本有 → 还原原值(非删除)
520
- reverted[f] = d.get("after")
521
- if not reverted:
522
- rep["conflict"] += 1
523
- continue
524
- for k, box in (rec.get("fm_before") or {}).items():
525
- if box.get("had"):
526
- fm[k] = box.get("value")
527
- else:
528
- fm.pop(k, None)
529
- st = fm.get("state_attributes")
530
- if isinstance(st, dict) and isinstance(st.get("comment"), dict) \
531
- and not st["comment"]:
532
- st.pop("comment", None)
533
- cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
534
- durable=True)
535
- append_jsonl(_log_path(cg), {
536
- "action": "backfill_rollback", "ts": time.time(), "actor": actor,
537
- "batch": rec.get("batch"), "entry_id": rec.get("entry_id"),
538
- "write_id": rec.get("write_id"), "node": nid,
539
- "reverted": list(reverted), "conflict": conflicted})
540
- rep["reverted"] += 1
541
- rep["fields_reverted"] += len(reverted)
542
- if conflicted:
543
- rep["conflict"] += 1
544
- if rep["reverted"]:
545
- cg.rebuild_index()
546
- return rep
547
-
548
-
549
- # 生效条件:x 经 _as_cg,action/batch 为真值时过滤对应日志记录;limit 不为 None 且 >=0 时按 recs[-limit:] 截断(limit=0 时切片为全部记录),limit 为 None 或负数时不截断;返回 total/returned/records。
550
- def history(x, limit=100, action=None, batch=None) -> dict:
551
- cg = _as_cg(x)
552
- recs = []
553
- for rec in read_jsonl(_log_path(cg)) or []:
554
- if action and rec.get("action") != action:
555
- continue
556
- if batch and rec.get("batch") != batch:
557
- continue
558
- recs.append(rec)
559
- total = len(recs)
560
- if limit is not None and limit >= 0:
561
- recs = recs[-limit:]
562
- return {"root": cg.root, "total": total, "returned": len(recs),
563
- "records": recs}
564
-
565
-
566
- # ---- 能力标签注入(关键词启发式) ----------------------------------------
567
-
568
- # 候选匹配不得吃进两类「自产词」,否则候选再生、plan 永不收敛:
569
- # ① `fm.tags`:`cap:<op>` 是**注入结果**,回流后 `cap:route` 自匹配关键词
570
- # "route"、`cap:self_state` 自匹配 "self_state"…… 已注入节点会重新成为候选;
571
- # ② `# 验证方式:` 模板行:它是 CCG 五要素的必备行,展开后**几乎全库**命中
572
- # 「验证」,`cap:verify` 遂从能力判断退化为正文模板的副产品
573
- # (evolution 账本实测:预演命中 1630/1813)。
574
- _CAP_TEMPLATE_LINES = ("验证方式",)
575
-
576
-
577
- # 生效条件:content 中去除 # 与空白后、全角或半角冒号前首段命中 _CAP_TEMPLATE_LINES 的行被剔除,其余行保留并 join。
578
- def _cap_body(content: str) -> str:
579
- """正文(供关键词匹配)——剔除 CCG 模板行,防模板词污染候选。"""
580
- keep = []
581
- for line in (content or "").splitlines():
582
- head = line.strip().lstrip("#").strip()
583
- head = head.split(":", 1)[0].split(":", 1)[0].strip()
584
- if head in _CAP_TEMPLATE_LINES:
585
- continue
586
- keep.append(line)
587
- return "\n".join(keep)
588
-
589
-
590
- # 生效条件:当 fm 为可 get 的 frontmatter、e 为带 id 的节点条目、content 为正文文本时,返回 title+e.id+功能名/生效条件/子功能字段+正文前 300 字合并后的小写串(不含 fm.tags)。
591
- def _cap_text(e, fm, content) -> str:
592
- """候选匹配文本:节点标识 + CCG 字段 + 正文(**不含 `fm.tags`**)。"""
593
- parts = [_as_text(fm.get("title")), e.get("id") or ""]
594
- for f in ("功能名", "生效条件", "子功能"):
595
- v = _ccg_field(content, f)
596
- if v:
597
- parts.append(v)
598
- parts.append(_cap_body(content)[:300])
599
- return " ".join(parts).lower()
600
-
601
-
602
- # 生效条件:text 包含 CAP_RULES 中某 cap 的至少一个关键词时,该 cap 以匹配关键词与置信度加入返回,按置信度降序、cap 升序排序;无匹配返回空 hits。
603
- def cap_matches(text: str) -> list:
604
- hits = []
605
- for cap, kws in CAP_RULES.items():
606
- m = [k for k in kws if k in text]
607
- if m:
608
- hits.append({"cap": cap, "matched_by": m,
609
- "confidence": round(min(1.0, 0.4 + 0.2 * len(m)), 3)})
610
- hits.sort(key=lambda h: (-h["confidence"], h["cap"]))
611
- return hits
612
-
613
-
614
- # 生效条件:x 经 _as_cg,遍历 nodes 按 ids/layer 过滤,不可读计 denied,读取失败或加密计 locked,扫描后以 _cap_text 匹配并过滤 confidence >= min_conf 且标签未含 cap:,无命中计 present,有命中则 targeted 并受 limit 限制加入 items,返回 dry_run rep。
615
- def cap_plan(x, layer=None, limit=None, ids=None, min_conf=0.5) -> dict:
616
- """预演:按关键词启发式给出 `cap:<op>` 标签建议(含依据与置信度),不写盘。"""
617
- cg = _as_cg(x)
618
- rep = {"root": cg.root, "dry_run": True, "action": "cap",
619
- "min_conf": min_conf, "nodes_scanned": 0, "skipped_locked": 0,
620
- "skipped_present": 0, "skipped_denied": 0, "targeted": 0,
621
- "items": []}
622
- want = set(ids) if ids else None
623
- for nid, e in list((cg.index.get("nodes") or {}).items()):
624
- if want is not None and nid not in want:
625
- continue
626
- if layer and e.get("layer") != layer:
627
- continue
628
- if not _readable_guard(cg, e):
629
- rep["skipped_denied"] += 1
630
- continue
631
- fm, content = direct_read(cg, e)
632
- if fm is None or crypto.is_encrypted(content):
633
- rep["skipped_locked"] += 1
634
- continue
635
- rep["nodes_scanned"] += 1
636
- have = set(t for t in (fm.get("tags") or []) if isinstance(t, str))
637
- hits = [h for h in cap_matches(_cap_text(e, fm, content))
638
- if h["confidence"] >= min_conf
639
- and f"cap:{h['cap']}" not in have]
640
- if not hits:
641
- rep["skipped_present"] += 1
642
- continue
643
- item = {"id": nid, "layer": e.get("layer"), "caps": hits,
644
- "entry_id": _entry_id("cap", nid)}
645
- rep["targeted"] += 1
646
- if limit is None or len(rep["items"]) < limit:
647
- rep["items"].append(item)
648
- rep["planned_ids"] = [i["id"] for i in rep["items"]]
649
- return rep
650
-
651
-
652
- # 生效条件:x 经 _as_cg,batch 假值回落 BATCH_DEFAULT;先 cap_plan 得 items,按 entry_ids 过滤;逐个检查节点存在、读取可读、无新增标签分别计 drift/locked/drift,成功写 tags 并记日志,limit 非 None 且 written >= limit 时 break;返回 rep。
653
- def cap_apply(x, ids=None, entry_ids=None, layer=None, limit=None,
654
- batch=BATCH_DEFAULT, min_conf=0.5, actor=None) -> dict:
655
- """注入 `cap:<op>` 标签:只改 frontmatter.tags,不动正文。"""
656
- cg = _as_cg(x)
657
- batch = batch or BATCH_DEFAULT
658
- p = cap_plan(cg, layer=layer, limit=None, ids=ids, min_conf=min_conf)
659
- items = p["items"]
660
- if entry_ids:
661
- want = set(entry_ids)
662
- items = [i for i in items if i["entry_id"] in want]
663
- rep = {"root": cg.root, "dry_run": False, "action": "cap", "batch": batch,
664
- "actor": actor, "min_conf": min_conf, "planned": len(items),
665
- "written": 0, "skipped_locked": 0, "skipped_drift": 0,
666
- "tags_added": 0, "entry_ids": []}
667
- for it in items:
668
- if limit is not None and rep["written"] >= limit:
669
- break
670
- nid = it["id"]
671
- e = cg.index["nodes"].get(nid)
672
- if not e:
673
- rep["skipped_drift"] += 1
674
- continue
675
- fm, content = direct_read(cg, e)
676
- if fm is None or crypto.is_encrypted(content):
677
- rep["skipped_locked"] += 1
678
- continue
679
- tags = list(fm.get("tags") or [])
680
- added = [f"cap:{h['cap']}" for h in it["caps"] if f"cap:{h['cap']}" not in tags]
681
- if not added:
682
- rep["skipped_drift"] += 1
683
- continue
684
- fm["tags"] = tags + added
685
- cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
686
- durable=True)
687
- append_jsonl(_log_path(cg), {
688
- "action": "cap", "ts": time.time(), "batch": batch, "actor": actor,
689
- "entry_id": it["entry_id"], "write_id": _sha(f"cap|{nid}|{time.time()}"),
690
- "node": nid, "layer": e.get("layer"),
691
- "tags_added": added,
692
- "evidence": {h["cap"]: h["matched_by"] for h in it["caps"]},
693
- "confidence": {h["cap"]: h["confidence"] for h in it["caps"]}})
694
- rep["written"] += 1
695
- rep["tags_added"] += len(added)
696
- rep["entry_ids"].append(it["entry_id"])
697
- if rep["written"]:
698
- cg.rebuild_index()
699
- rep["plan_remaining"] = max(0, p["targeted"] - len(items))
700
- return rep
701
-
702
-
703
- # 生效条件:x 经 _as_cg,读取日志中 action=cap 且未回滚的记录,按 batch/entry_ids 过滤,节点存在且原加入标签仍在 tags 中时移除,否则计 conflict/missing,返回 rep。
704
- def cap_rollback(x, batch=None, entry_ids=None, actor=None) -> dict:
705
- """撤销 cap 注入:仅移除**仍在 tags 里**的 `cap:` 标签(防覆盖后续修改)。"""
706
- cg = _as_cg(x)
707
- want = set(entry_ids) if entry_ids else None
708
- rep = {"root": cg.root, "action": "cap_rollback", "actor": actor,
709
- "batch": batch, "reverted": 0, "conflict": 0, "missing": 0,
710
- "tags_removed": 0, "skipped_done": 0}
711
- log = list(read_jsonl(_log_path(cg)) or [])
712
- done = {r.get("write_id") for r in log
713
- if r.get("action") == "cap_rollback" and r.get("write_id")}
714
- for rec in log:
715
- if rec.get("action") != "cap":
716
- continue
717
- if rec.get("write_id") and rec.get("write_id") in done:
718
- rep["skipped_done"] += 1
719
- continue
720
- if batch and rec.get("batch") != batch:
721
- continue
722
- if want is not None and rec.get("entry_id") not in want:
723
- continue
724
- nid, added = rec.get("node"), rec.get("tags_added") or []
725
- e = cg.index["nodes"].get(nid)
726
- if not e:
727
- rep["missing"] += 1
728
- continue
729
- fm, content = direct_read(cg, e)
730
- if fm is None:
731
- rep["missing"] += 1
732
- continue
733
- tags = list(fm.get("tags") or [])
734
- removed = [t for t in added if t in tags]
735
- if not removed:
736
- rep["conflict"] += 1
737
- continue
738
- fm["tags"] = [t for t in tags if t not in set(removed)]
739
- cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
740
- durable=True)
741
- append_jsonl(_log_path(cg), {
742
- "action": "cap_rollback", "ts": time.time(), "actor": actor,
743
- "batch": rec.get("batch"), "entry_id": rec.get("entry_id"),
744
- "write_id": rec.get("write_id"), "node": nid,
745
- "tags_removed": removed})
746
- rep["reverted"] += 1
747
- rep["tags_removed"] += len(removed)
748
- if rep["reverted"]:
749
- cg.rebuild_index()
750
- return rep
751
-
752
-
753
- # ---- 豁免解除(ccg_exempt 分批摘除) --------------------------------------
754
-
755
- EXEMPT_FLAG = "ccg_exempt"
756
-
757
-
758
- # 生效条件:fm 的 verification_basis 合法且 content 的 ccg_completeness 标记 complete 时返回 (True, []),否则把缺失项放入 miss 返回 ready=False。
759
- def _exempt_ready(fm: dict, content: str):
760
- """摘豁免前置条件 → `(ready, missing)`。
761
-
762
- 硬约束(顺序依赖):证据未补齐就摘豁免,节点会从 DEFER **退化为 BLINDSPOT**,
763
- 比现状更差。故要求「合法 `verification_basis`」+「5 要素齐备(含验证方式行)」
764
- 同时成立才允许摘除。
765
- """
766
- miss = []
767
- if not nodefile.verification_basis_valid(fm):
768
- miss.append("verification_basis")
769
- if not nodefile.ccg_completeness(content).get("complete"):
770
- miss.append("ccg5")
771
- return (not miss), miss
772
-
773
-
774
- # 生效条件:x 经 _as_cg,遍历 nodes 按 ids/prefix/layer 过滤,内部层/不可读/读取失败或加密分别计数跳过,fm 无 EXEMPT_FLAG 计 not_exempt,require_ready 为真且不 ready 时计 unready 并在 want 为 None 时跳过,否则生成 item 受 limit 限制;sample 为真值时按 id 序等距抽取 sample 个。
775
- def exempt_plan(x, layer=None, limit=None, ids=None, require_ready=True,
776
- sample=0, prefix=None) -> dict:
777
- """预演:列出可摘 `ccg_exempt` 的节点(默认要求证据就绪),不写盘。
778
-
779
- `sample=N` 时按 id 序等距抽取 N 个作为验收样本(确定性,重跑同一样本)。
780
- `prefix`:按 id 前缀收窄范围(真实库用 `kp_`);内部 `anchor`/`self` 层出局。
781
- """
782
- cg = _as_cg(x)
783
- rep = {"root": cg.root, "dry_run": True, "action": "exempt",
784
- "require_ready": require_ready, "prefix": prefix, "nodes_scanned": 0,
785
- "skipped_locked": 0, "skipped_denied": 0, "skipped_not_exempt": 0,
786
- "skipped_internal": 0, "skipped_unready": 0, "unready_reasons": {},
787
- "targeted": 0, "items": [], "sample": []}
788
- want = set(ids) if ids else None
789
- for nid, e in list((cg.index.get("nodes") or {}).items()):
790
- if want is not None and nid not in want:
791
- continue
792
- if prefix and not str(nid).startswith(prefix):
793
- continue
794
- if layer and e.get("layer") != layer:
795
- continue
796
- if e.get("layer") in INTERNAL_LAYERS:
797
- rep["skipped_internal"] += 1
798
- continue
799
- if not _readable_guard(cg, e):
800
- rep["skipped_denied"] += 1
801
- continue
802
- fm, content = direct_read(cg, e)
803
- if fm is None or crypto.is_encrypted(content):
804
- rep["skipped_locked"] += 1
805
- continue
806
- rep["nodes_scanned"] += 1
807
- if not fm.get(EXEMPT_FLAG):
808
- rep["skipped_not_exempt"] += 1
809
- continue
810
- ready, miss = _exempt_ready(fm, content)
811
- if require_ready and not ready:
812
- rep["skipped_unready"] += 1
813
- for m in miss:
814
- rep["unready_reasons"][m] = rep["unready_reasons"].get(m, 0) + 1
815
- # 批量:直接过滤(报表已计数);显式点名:入列交由 apply 判定并留
816
- # `exempt_skip` 记录——被点名的节点绝不静默丢弃。
817
- if want is None:
818
- continue
819
- item = {"id": nid, "layer": e.get("layer"), "ready": ready,
820
- "missing": miss, "basis": fm.get("verification_basis"),
821
- "entry_id": _entry_id("exempt", nid)}
822
- rep["targeted"] += 1
823
- if limit is None or len(rep["items"]) < limit:
824
- rep["items"].append(item)
825
- rep["planned_ids"] = [i["id"] for i in rep["items"]]
826
- if sample and rep["items"]:
827
- ids_all = [i["id"] for i in rep["items"]]
828
- k = min(int(sample), len(ids_all))
829
- stride = max(1, len(ids_all) // k)
830
- rep["sample"] = ids_all[::stride][:k]
831
- return rep
832
-
833
-
834
- # 生效条件:x 经 _as_cg,batch 假值回落 BATCH_DEFAULT;先 exempt_plan 得 items,按 entry_ids 过滤;逐个检查节点存在、可读、EXEMPT_FLAG 仍真、require_ready 为真时 _exempt_ready 再次通过;不通过计 skipped_unready 并记 exempt_skip;通过则置 EXEMPT_FLAG=False 写盘记日志;limit 限制 written;返回 rep。
835
- def exempt_apply(x, ids=None, entry_ids=None, layer=None, limit=None,
836
- batch=BATCH_DEFAULT, require_ready=True, actor=None,
837
- prefix=None) -> dict:
838
- """分批摘除 `ccg_exempt`(置 False 而非删键,便于反向还原)。
839
-
840
- 就绪校验在**写入前**再查一次(plan 与 apply 之间可能被改动);
841
- 不满足则计 `skipped_unready` 并留 `exempt_skip` 记录,绝不硬摘。
842
- """
843
- cg = _as_cg(x)
844
- batch = batch or BATCH_DEFAULT
845
- p = exempt_plan(cg, layer=layer, ids=ids, require_ready=require_ready,
846
- prefix=prefix)
847
- items = p["items"]
848
- if entry_ids:
849
- want = set(entry_ids)
850
- items = [i for i in items if i["entry_id"] in want]
851
- rep = {"root": cg.root, "dry_run": False, "action": "exempt", "batch": batch,
852
- "actor": actor, "require_ready": require_ready, "planned": len(items),
853
- "written": 0, "skipped_unready": 0, "skipped_locked": 0,
854
- "skipped_drift": 0, "entry_ids": []}
855
- for it in items:
856
- if limit is not None and rep["written"] >= limit:
857
- break
858
- nid = it["id"]
859
- e = cg.index["nodes"].get(nid)
860
- if not e:
861
- rep["skipped_drift"] += 1
862
- continue
863
- fm, content = direct_read(cg, e)
864
- if fm is None or crypto.is_encrypted(content):
865
- rep["skipped_locked"] += 1
866
- continue
867
- if not fm.get(EXEMPT_FLAG):
868
- rep["skipped_drift"] += 1
869
- continue
870
- ready, miss = _exempt_ready(fm, content)
871
- if require_ready and not ready:
872
- rep["skipped_unready"] += 1
873
- append_jsonl(_log_path(cg), {
874
- "action": "exempt_skip", "ts": time.time(), "batch": batch,
875
- "actor": actor, "node": nid, "missing": miss})
876
- continue
877
- before = fm.get(EXEMPT_FLAG)
878
- fm[EXEMPT_FLAG] = False
879
- wid = _sha(f"exempt|{nid}|{time.time()}")
880
- cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
881
- durable=True)
882
- append_jsonl(_log_path(cg), {
883
- "action": "exempt", "ts": time.time(), "batch": batch, "actor": actor,
884
- "entry_id": it["entry_id"], "write_id": wid, "node": nid,
885
- "layer": e.get("layer"), "exempt_before": before,
886
- "basis": fm.get("verification_basis")})
887
- rep["written"] += 1
888
- rep["entry_ids"].append(it["entry_id"])
889
- if rep["written"]:
890
- cg.rebuild_index()
891
- rep["plan_remaining"] = max(0, p["targeted"] - len(items))
892
- return rep
893
-
894
-
895
- # 生效条件:当 x 可解析为 cg 时,日志中 action 为 exempt 的记录若其非空 write_id 已存在于既有 action 为 exempt_rollback 的记录 write_id 集合中,则跳过并计入 skipped_done,否则在通过 batch 与 entry_ids 过滤后,节点存在且可读、EXEMPT_FLAG 当前为假时,该记录才被还原并计入 reverted;。
896
- def exempt_rollback(x, batch=None, entry_ids=None, actor=None) -> dict:
897
- """反向还原 `ccg_exempt`:仅当当前仍为「已摘」状态时还原,否则计 conflict。"""
898
- cg = _as_cg(x)
899
- want = set(entry_ids) if entry_ids else None
900
- rep = {"root": cg.root, "action": "exempt_rollback", "actor": actor,
901
- "batch": batch, "reverted": 0, "conflict": 0, "missing": 0,
902
- "skipped_done": 0}
903
- log = list(read_jsonl(_log_path(cg)) or [])
904
- done = {r.get("write_id") for r in log
905
- if r.get("action") == "exempt_rollback" and r.get("write_id")}
906
- for rec in log:
907
- if rec.get("action") != "exempt":
908
- continue
909
- if rec.get("write_id") and rec.get("write_id") in done:
910
- rep["skipped_done"] += 1
911
- continue
912
- if batch and rec.get("batch") != batch:
913
- continue
914
- if want is not None and rec.get("entry_id") not in want:
915
- continue
916
- nid = rec.get("node")
917
- e = cg.index["nodes"].get(nid)
918
- if not e:
919
- rep["missing"] += 1
920
- continue
921
- fm, content = direct_read(cg, e)
922
- if fm is None:
923
- rep["missing"] += 1
924
- continue
925
- if fm.get(EXEMPT_FLAG):
926
- rep["conflict"] += 1
927
- continue
928
- fm[EXEMPT_FLAG] = rec.get("exempt_before", True)
929
- cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
930
- durable=True)
931
- append_jsonl(_log_path(cg), {
932
- "action": "exempt_rollback", "ts": time.time(), "actor": actor,
933
- "batch": rec.get("batch"), "entry_id": rec.get("entry_id"),
934
- "write_id": rec.get("write_id"), "node": nid,
935
- "exempt_restored": fm.get(EXEMPT_FLAG)})
936
- rep["reverted"] += 1
937
- if rep["reverted"]:
938
- cg.rebuild_index()
939
- return rep
940
-
941
-
942
- # ---- 待补台账 / 存量清洗(生效条件口径修正) ------------------------------
943
- #
944
- # 背景:旧口径把 `condition_space.observation_position` 单槽加前缀「观测位置:」
945
- # 当作生效条件写入(真实库 109 条)。观测位置 ≠ 生效条件——生效条件是**整条**
946
- # 条件空间声明的合成。本段负责三件事:
947
- # ① conditions_pending 只读台账:未声明且四槽推不出的节点
948
- # ② fix_conditions_* 清洗:冒充行重渲染为合规声明,或删除并登记待补
949
- # ③ verify_conditions 只读复算:验收指标 legacy_position == 0
950
-
951
-
952
- # 生效条件:x 经 _as_cg,遍历 nodes 按 prefix/layer 过滤,内部层/不可读/读取失败或加密/derived 层或 SKIP_TAGS 分别计数跳过;扫描后,正文已有生效条件计 declared,derive_fields 可推出计 derivable,否则按 condition_space 缺失槽计 pending 并受 limit 限制收集 items;返回 rep。
953
- def conditions_pending(x, prefix=None, layer=None, limit=None) -> dict:
954
- """只读台账:列出「未声明生效条件、且四槽推不出」的节点及其缺失槽。
955
-
956
- 生效条件已成为必填项(`CCG_REQUIRED`),但存量节点未必有足够声明可补。
957
- 这类节点**不能静默判 ACCEPT**:进本台账等待后续补充;确实补不动者由资格
958
- 判定落 BLINDSPOT(而不是被「常用条件默认省略」掩盖)。本函数不写盘。
959
- """
960
- cg = _as_cg(x)
961
- rep = {"root": cg.root, "dry_run": True, "action": "conditions_pending",
962
- "prefix": prefix, "nodes_scanned": 0, "skipped_locked": 0,
963
- "skipped_denied": 0, "skipped_internal": 0, "skipped_derived": 0,
964
- "declared": 0, "derivable": 0, "pending": 0,
965
- "by_missing": {}, "items": []}
966
- for nid, e in list((cg.index.get("nodes") or {}).items()):
967
- if prefix and not str(nid).startswith(prefix):
968
- continue
969
- if layer and e.get("layer") != layer:
970
- continue
971
- if e.get("layer") in INTERNAL_LAYERS:
972
- rep["skipped_internal"] += 1
973
- continue
974
- if not _readable_guard(cg, e):
975
- rep["skipped_denied"] += 1
976
- continue
977
- fm, content = direct_read(cg, e)
978
- if fm is None or crypto.is_encrypted(content):
979
- rep["skipped_locked"] += 1
980
- continue
981
- if (e.get("layer") in SKIP_LAYERS
982
- or any(t in SKIP_TAGS for t in (fm.get("tags") or []))):
983
- rep["skipped_derived"] += 1
984
- continue
985
- rep["nodes_scanned"] += 1
986
- if _has_ccg_line(content, "生效条件"):
987
- rep["declared"] += 1
988
- continue
989
- if "生效条件" in derive_fields(fm, content):
990
- # 有来源、只是还没接线 → 属于「待回填」,不是缺证据
991
- rep["derivable"] += 1
992
- continue
993
- cs = fm.get("condition_space")
994
- miss = nodefile.condition_space_missing(cs)
995
- if not isinstance(cs, dict) or len(miss) == len(nodefile.CONDITION_SLOTS):
996
- key = "无条件空间声明"
997
- else:
998
- key = "缺" + "+".join(_SLOT_LABEL.get(k, k) for k in miss)
999
- rep["by_missing"][key] = rep["by_missing"].get(key, 0) + 1
1000
- rep["pending"] += 1
1001
- if limit is None or len(rep["items"]) < limit:
1002
- rep["items"].append({
1003
- "id": nid, "layer": e.get("layer"), "missing_slots": miss,
1004
- "missing_text": key,
1005
- "fallback": "补写生效条件;确实补不动 → 判 BLINDSPOT"})
1006
- if limit is not None:
1007
- rep["items"] = rep["items"][:limit]
1008
- return rep
1009
-
1010
-
1011
- # 生效条件:cg 的留痕日志中存在 basis 为 LEGACY_CONDITION_BASIS 且未被回滚的 backfill 生效条件写入时,按 node 记录最后一次的 after/original 返回;无匹配返回空。
1012
- def _legacy_condition_records(cg) -> dict:
1013
- """→ {node: {after, original, …}}:我们**自己写下的**单槽冒充行(真源 = 留痕)。
1014
-
1015
- 只有留痕里 `basis == LEGACY_CONDITION_BASIS` 的行才敢自动改——人写下的
1016
- 「观测位置:…」声明不在其列(宁可漏改,不可误改)。已被回滚的写入剔除;
1017
- 同一节点多次写入时以最后一次为准。
1018
- """
1019
- log = list(read_jsonl(_log_path(cg)) or [])
1020
- undone = {r.get("write_id") for r in log
1021
- if r.get("action") == "backfill_rollback" and r.get("write_id")}
1022
- out = {}
1023
- for rec in log:
1024
- if rec.get("action") != "backfill":
1025
- continue
1026
- if rec.get("write_id") and rec.get("write_id") in undone:
1027
- continue
1028
- f = (rec.get("fields") or {}).get("生效条件")
1029
- if not isinstance(f, dict) or f.get("basis") != LEGACY_CONDITION_BASIS:
1030
- continue
1031
- nid = rec.get("node")
1032
- if not nid:
1033
- continue
1034
- out[nid] = {"after": f.get("after"), "original": f.get("before"),
1035
- "write_id": rec.get("write_id"), "batch": rec.get("batch")}
1036
- return out
1037
-
1038
-
1039
- # 生效条件:x 经 _as_cg,从 _legacy_condition_records 取候选,按 prefix 过滤,节点不存在/不可读/读取失败或加密分别计 missing/denied/locked;当前生效条件等于留痕 after 时,四槽合成非空则 rewrite 否则 drop,不等则 conflict;items 受 limit 限制;返回 dry_run rep。
1040
- def fix_conditions_plan(x, prefix=None, limit=None) -> dict:
1041
- """预演:清洗存量单槽冒充行。不写盘。
1042
-
1043
- 逐条判定(都要求「当前值仍等于我们当初写入的值」,否则计 `conflict`、不碰):
1044
- · 四槽齐备 → `rewrite`:改写为 `condition_space_text(cs)` 合成声明;
1045
- · 四槽不全 → `drop`:删掉冒充行并登记待补。补不全的行留着比删掉更危险——
1046
- 它会被当成生效条件读,等于把坐标的一维当成整条声明。
1047
- """
1048
- cg = _as_cg(x)
1049
- rep = {"root": cg.root, "dry_run": True, "action": "fix_conditions",
1050
- "prefix": prefix, "legacy": 0, "targeted": 0, "rewrite": 0,
1051
- "drop": 0, "conflict": 0, "missing": 0, "skipped_locked": 0,
1052
- "skipped_denied": 0, "items": []}
1053
- for nid, rec in _legacy_condition_records(cg).items():
1054
- if prefix and not str(nid).startswith(prefix):
1055
- continue
1056
- e = cg.index["nodes"].get(nid)
1057
- if not e:
1058
- rep["missing"] += 1
1059
- continue
1060
- if not _readable_guard(cg, e):
1061
- rep["skipped_denied"] += 1
1062
- continue
1063
- fm, content = direct_read(cg, e)
1064
- if fm is None or crypto.is_encrypted(content):
1065
- rep["skipped_locked"] += 1
1066
- continue
1067
- rep["legacy"] += 1
1068
- cur = _ccg_field(content, "生效条件") or ""
1069
- if cur != (rec.get("after") or ""):
1070
- rep["conflict"] += 1 # 已被后续改动 → 不碰
1071
- continue
1072
- new = _condition_text(fm)
1073
- act = "rewrite" if new else "drop"
1074
- rep["targeted"] += 1
1075
- rep[act] += 1
1076
- if limit is None or len(rep["items"]) < limit:
1077
- rep["items"].append({
1078
- "id": nid, "layer": e.get("layer"), "action": act,
1079
- "before": cur, "after": new,
1080
- "missing_slots": nodefile.condition_space_missing(
1081
- fm.get("condition_space")),
1082
- "comment_before": (_comment(fm) or {}).get("生效条件"),
1083
- "comment_original": rec.get("original"),
1084
- "entry_id": _entry_id(FIX_BATCH_DEFAULT, nid)})
1085
- rep["planned_ids"] = [i["id"] for i in rep["items"]]
1086
- return rep
1087
-
1088
-
1089
- # 生效条件:x 经 _as_cg,batch 假值回落 FIX_BATCH_DEFAULT;先 fix_conditions_plan 得 items,按 ids/entry_ids 过滤;逐个再验当前值仍等于 before 且 comment_before 一致,否则 skipped_drift;rewrite 时 upsert 生效条件行并写 comment,drop 时删行并还原 comment;写盘记 condition_fix,drop 另记 condition_pending;limit 限制 rewritten+dropped;返回 rep。
1090
- def fix_conditions_apply(x, ids=None, entry_ids=None, prefix=None, limit=None,
1091
- batch=FIX_BATCH_DEFAULT, actor=None) -> dict:
1092
- """执行清洗:`rewrite` 改写为四槽合成声明;`drop` 删行并登记待补。
1093
-
1094
- 写盘与留痕同 `apply`:`_backfill.jsonl` 记 `condition_fix`;`drop` 另记
1095
- `condition_pending`(待补台账的可追溯副本)。幂等:清洗后不再有候选行。
1096
- """
1097
- cg = _as_cg(x)
1098
- batch = batch or FIX_BATCH_DEFAULT
1099
- p = fix_conditions_plan(cg, prefix=prefix, limit=None)
1100
- items = p["items"]
1101
- if ids:
1102
- want = set(ids)
1103
- items = [i for i in items if i["id"] in want]
1104
- if entry_ids:
1105
- want = set(entry_ids)
1106
- items = [i for i in items if i["entry_id"] in want]
1107
- rep = {"root": cg.root, "dry_run": False, "action": "fix_conditions",
1108
- "batch": batch, "actor": actor, "planned": len(items),
1109
- "rewritten": 0, "dropped": 0, "pending_logged": 0,
1110
- "skipped_drift": 0, "skipped_locked": 0, "skipped_denied": 0,
1111
- "entry_ids": []}
1112
- for it in items:
1113
- if limit is not None and (rep["rewritten"] + rep["dropped"]) >= limit:
1114
- break
1115
- nid = it["id"]
1116
- e = cg.index["nodes"].get(nid)
1117
- if not e:
1118
- rep["skipped_drift"] += 1
1119
- continue
1120
- fm, content = direct_read(cg, e)
1121
- if fm is None or crypto.is_encrypted(content):
1122
- rep["skipped_locked"] += 1
1123
- continue
1124
- # 预演 → 执行之间可能被改动:当前值必须仍等于我们当初写入的值
1125
- cur = _ccg_field(content, "生效条件")
1126
- comment_before = (_comment(fm) or {}).get("生效条件")
1127
- if (cur or "") != (it["before"] or "") \
1128
- or comment_before != it["comment_before"]:
1129
- rep["skipped_drift"] += 1
1130
- continue
1131
- comment = _ensure_comment(fm)
1132
- if it["action"] == "rewrite":
1133
- content = _upsert_ccg_line(content, "生效条件", it["after"])
1134
- comment["生效条件"] = it["after"]
1135
- else:
1136
- content = _remove_ccg_line(content, "生效条件")
1137
- # comment 里那份是同一污染的副本 → 还原为**写入前**的原值(真逆操作)
1138
- orig = it["comment_original"]
1139
- if orig in (None, ""):
1140
- comment.pop("生效条件", None)
1141
- else:
1142
- comment["生效条件"] = orig
1143
- st = fm.get("state_attributes")
1144
- if isinstance(st, dict) and isinstance(st.get("comment"), dict) \
1145
- and not st["comment"]:
1146
- st.pop("comment", None)
1147
- cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
1148
- durable=True)
1149
- append_jsonl(_log_path(cg), {
1150
- "action": "condition_fix", "ts": time.time(), "batch": batch,
1151
- "actor": actor, "entry_id": it["entry_id"],
1152
- "write_id": _sha(f"cond_fix|{nid}|{time.time()}"),
1153
- "node": nid, "layer": e.get("layer"), "fix": it["action"],
1154
- "fields": {"生效条件": {
1155
- "before": it["before"], "after": it["after"],
1156
- "basis": BASIS_CONDITION_SYNTH if it["action"] == "rewrite"
1157
- else "dropped:legacy_position"}},
1158
- "comment_before": comment_before,
1159
- "comment_original": it["comment_original"],
1160
- "missing_slots": it["missing_slots"],
1161
- "content_hash_after": _sha(content)})
1162
- if it["action"] == "rewrite":
1163
- rep["rewritten"] += 1
1164
- else:
1165
- rep["dropped"] += 1
1166
- append_jsonl(_log_path(cg), {
1167
- "action": "condition_pending", "ts": time.time(),
1168
- "batch": batch, "actor": actor, "node": nid,
1169
- "layer": e.get("layer"), "missing_slots": it["missing_slots"],
1170
- "reason": "四槽不可合成:单槽冒充行已删除,等待后续补充;"
1171
- "确实补不动则判 BLINDSPOT"})
1172
- rep["pending_logged"] += 1
1173
- rep["entry_ids"].append(it["entry_id"])
1174
- if rep["rewritten"] or rep["dropped"]:
1175
- cg.rebuild_index()
1176
- rep["plan_remaining"] = max(0, p["targeted"] - len(items))
1177
- return rep
1178
-
1179
-
1180
- # 生效条件:x 经 _as_cg,读取日志中 action=condition_fix 且未回滚的记录,按 batch/entry_ids 过滤,节点存在且当前生效条件等于 after 时,还原 before(空则删行)并还原 comment_before,否则计 conflict/missing;返回 rep。
1181
- def fix_conditions_rollback(x, batch=None, entry_ids=None, actor=None) -> dict:
1182
- """按留痕反向应用:恢复被改写的旧值 / 重建被删除的冒充行。
1183
-
1184
- 与 `rollback` 同一条纪律:**只在当前值仍等于写入值**时撤销,
1185
- 否则计 `conflict` 跳过(防覆盖后续人工修改)。
1186
- """
1187
- cg = _as_cg(x)
1188
- want = set(entry_ids) if entry_ids else None
1189
- rep = {"root": cg.root, "action": "fix_conditions_rollback", "actor": actor,
1190
- "batch": batch, "reverted": 0, "conflict": 0, "missing": 0,
1191
- "skipped_done": 0}
1192
- log = list(read_jsonl(_log_path(cg)) or [])
1193
- done = {r.get("write_id") for r in log
1194
- if r.get("action") == "fix_conditions_rollback" and r.get("write_id")}
1195
- for rec in log:
1196
- if rec.get("action") != "condition_fix":
1197
- continue
1198
- if rec.get("write_id") and rec.get("write_id") in done:
1199
- rep["skipped_done"] += 1
1200
- continue
1201
- if batch and rec.get("batch") != batch:
1202
- continue
1203
- if want is not None and rec.get("entry_id") not in want:
1204
- continue
1205
- nid = rec.get("node")
1206
- e = cg.index["nodes"].get(nid)
1207
- if not e:
1208
- rep["missing"] += 1
1209
- continue
1210
- fm, content = direct_read(cg, e)
1211
- if fm is None:
1212
- rep["missing"] += 1
1213
- continue
1214
- d = (rec.get("fields") or {}).get("生效条件") or {}
1215
- cur = _ccg_field(content, "生效条件") or ""
1216
- if cur != (d.get("after") or ""):
1217
- rep["conflict"] += 1 # 已被后续改动 → 不撤销
1218
- continue
1219
- before = d.get("before")
1220
- if before in (None, ""):
1221
- content = _remove_ccg_line(content, "生效条件")
1222
- else:
1223
- content = _upsert_ccg_line(content, "生效条件", before)
1224
- comment = _ensure_comment(fm)
1225
- cb = rec.get("comment_before")
1226
- if cb in (None, ""):
1227
- comment.pop("生效条件", None)
1228
- else:
1229
- comment["生效条件"] = cb
1230
- st = fm.get("state_attributes")
1231
- if isinstance(st, dict) and isinstance(st.get("comment"), dict) \
1232
- and not st["comment"]:
1233
- st.pop("comment", None)
1234
- cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
1235
- durable=True)
1236
- append_jsonl(_log_path(cg), {
1237
- "action": "fix_conditions_rollback", "ts": time.time(),
1238
- "actor": actor, "batch": rec.get("batch"),
1239
- "entry_id": rec.get("entry_id"), "write_id": rec.get("write_id"),
1240
- "node": nid, "restored": before})
1241
- rep["reverted"] += 1
1242
- if rep["reverted"]:
1243
- cg.rebuild_index()
1244
- return rep
1245
-
1246
-
1247
- # 生效条件:x 经 _as_cg,遍历 nodes 按 prefix 过滤、内部层跳过,读取失败或加密跳过;对每个节点当前生效条件行,缺失计 absent,否则按 is_legacy_position_condition、等于 _condition_text 合成、等于 comment、其他分别计数,legacy_ids 受 limit 限制;返回 rep。
1248
- def verify_conditions(x, prefix=None, limit=None) -> dict:
1249
- """复算核对(只读):生效条件行的来源分布 + 弱等价残留计数。
1250
-
1251
- `legacy_position` 必须为 **0**——这是本轮口径修正的验收指标:
1252
- 「观测位置:X」单槽冒充行不得再出现在任何节点里。
1253
- """
1254
- cg = _as_cg(x)
1255
- rep = {"root": cg.root, "dry_run": True, "action": "verify_conditions",
1256
- "prefix": prefix, "nodes_scanned": 0, "absent": 0, "declared": 0,
1257
- "from_synthesis": 0, "from_comment": 0, "legacy_position": 0,
1258
- "other": 0, "by_prefix": {}, "legacy_ids": []}
1259
- for nid, e in list((cg.index.get("nodes") or {}).items()):
1260
- if prefix and not str(nid).startswith(prefix):
1261
- continue
1262
- if e.get("layer") in INTERNAL_LAYERS:
1263
- continue
1264
- fm, content = direct_read(cg, e)
1265
- if fm is None or crypto.is_encrypted(content):
1266
- continue
1267
- rep["nodes_scanned"] += 1
1268
- cur = _ccg_field(content, "生效条件")
1269
- if not cur:
1270
- rep["absent"] += 1
1271
- kind = "absent"
1272
- else:
1273
- rep["declared"] += 1
1274
- synth = _condition_text(fm)
1275
- cmt = _as_text(_comment(fm).get("生效条件"))
1276
- if nodefile.is_legacy_position_condition(cur):
1277
- rep["legacy_position"] += 1
1278
- kind = "legacy_position"
1279
- if limit is None or len(rep["legacy_ids"]) < limit:
1280
- rep["legacy_ids"].append(nid)
1281
- elif synth and cur == synth:
1282
- rep["from_synthesis"] += 1
1283
- kind = "from_synthesis"
1284
- elif cmt and cur == cmt:
1285
- rep["from_comment"] += 1
1286
- kind = "from_comment"
1287
- else:
1288
- rep["other"] += 1
1289
- kind = "other"
1290
- box = rep["by_prefix"].setdefault(str(nid).split("_")[0], {})
1291
- box[kind] = box.get(kind, 0) + 1
1292
- return rep
1293
-
1294
-
1295
- # ---- 统一入口 ------------------------------------------------------------
1296
-
1297
- ACTIONS = ("backfill", "backfill_rollback", "backfill_history",
1298
- "cap", "cap_rollback", "cap_history",
1299
- "exempt", "exempt_rollback", "exempt_history")
1300
-
1301
-
1302
- # 生效条件:按其 action 分派——action=='backfill' 时 kw['apply'] 为真调 apply(x, 去掉 apply 的 kw)、否则调 plan 同参;action=='cap'/'exempt' 同理在 kw['apply'] 为真时调 cap_apply/exempt_apply、否则调 cap_plan/exempt_plan;action=='backfill_rollback'/'cap_rollback'/'exempt_rollback' 分别调 rollback/cap_rollback/exempt_rollback(x, **kw);action=='backfill_history' 调 history(x, **kw),'cap_history'/'exempt_history' 调 history(x, action='cap'/'exempt', **kw);其余 action 值抛 ValueError。
1303
- def run(x, action, **kw) -> dict:
1304
- """`maintain` op 的分派入口:action ∈ ACTIONS。"""
1305
- if action == "backfill":
1306
- if kw.get("apply"):
1307
- return apply(x, **{k: v for k, v in kw.items() if k != "apply"})
1308
- return plan(x, **{k: v for k, v in kw.items() if k != "apply"})
1309
- if action == "backfill_rollback":
1310
- return rollback(x, **kw)
1311
- if action == "backfill_history":
1312
- return history(x, **kw)
1313
- if action == "cap":
1314
- if kw.get("apply"):
1315
- return cap_apply(x, **{k: v for k, v in kw.items() if k != "apply"})
1316
- return cap_plan(x, **{k: v for k, v in kw.items() if k != "apply"})
1317
- if action == "cap_rollback":
1318
- return cap_rollback(x, **kw)
1319
- if action == "cap_history":
1320
- return history(x, action="cap", **kw)
1321
- if action == "exempt":
1322
- if kw.get("apply"):
1323
- return exempt_apply(x, **{k: v for k, v in kw.items() if k != "apply"})
1324
- return exempt_plan(x, **{k: v for k, v in kw.items() if k != "apply"})
1325
- if action == "exempt_rollback":
1326
- return exempt_rollback(x, **kw)
1327
- if action == "exempt_history":
1328
- return history(x, action="exempt", **kw)
1
+ # -*- coding: utf-8 -*-
2
+ """真实库对齐(P32):CCG 回填 + 能力标签注入。
3
+
4
+ 为什么是「回填」而不是「重写」
5
+ ------------------------------
6
+ 迁移入库的历史节点里,条件信息**往往已经在 frontmatter 里**:
7
+ `condition_space`(四槽)、`non_applicable_conditions`、`verification_basis`、
8
+ `state_attributes.comment.*`。缺的只是把它们渲染成 CCG 正文行(`# 生效条件:…`
9
+ 等)。缺了正文行,`judge_qualification` 一律判 BLINDSPOT——节点从「可检索」
10
+ 掉到「不可判定」。
11
+
12
+ 回填 = 把**已声明的证据**渲染成 CCG 行。它不发明条件,只搬运已有声明。
13
+
14
+ 生效条件的来源链(本轮口径修正:观测位置 ≠ 生效条件)
15
+ ----------------------------------------------------
16
+ 生效条件**只能**来自两处,且优先成文声明:
17
+ ① `state_attributes.comment.生效条件`(人/流程写下的成文声明)
18
+ ② `nodefile.condition_space_text(frontmatter.condition_space)`(四槽合成)
19
+ 旧版曾回退到 `condition_space.observation_position` **单槽**,加前缀「观测位置:」
20
+ 冒充生效条件——那是把坐标的一维当成整条生效条件,真实库因此落了 109 条弱等价行。
21
+ 该回退**已删除**;四槽不齐 → 不写(部分槽不构成完整条件空间声明),转待补台账。
22
+ `fix_conditions_*` 三个函数用于清洗存量:把已落库的单槽冒充行**重渲染**为合规
23
+ 合成声明,或**删除并登记待补**——全程留痕、可回滚、幂等。
24
+
25
+ 纪律(对齐 consolidate 的固化纪律)
26
+ ----------------------------------
27
+ · 不猜测:字段只在**有来源**时才写;来源写进留痕 `basis`;无来源 → 跳过并计入
28
+ `unfillable`,绝不编造。
29
+ · 可预演:`plan()` 只出报表、不改盘;`apply()` 才写。默认只回填「补完即可判定」
30
+ 的节点,`partial`(补完仍不全)默认不写,除非显式 `include_partial=True`。
31
+ · 可留痕:每次写入记一条 `_backfill.jsonl`(字段 / 写入值 / 依据 / 批次 / 操作者)。
32
+ · 可回滚:`rollback()` 按留痕反向应用,且**只在当前值仍等于写入值**时撤销
33
+ (防覆盖后续人工修改),否则计入 `conflict` 跳过。
34
+ · fail-closed:密文节点一律跳过,**绝不解密回写**。
35
+
36
+ 能力标签注入
37
+ ------------
38
+ `cap:<op>` 标签让路由能返回建议能力名(`mcp_server` 读 frontmatter.tags 的
39
+ `cap:` 前缀)。匹配是**关键词启发式**(对标 `tokens.ALL_OPS` 工具名清单),
40
+ 不是语义推断:结果带 `matched_by`(命中的关键词)与 `confidence`,调用方据此
41
+ 判断可信度。只改 frontmatter.tags,不动正文。
42
+ """
43
+ from __future__ import annotations
44
+
45
+ import hashlib
46
+ import os
47
+ import time
48
+ from collections import OrderedDict
49
+
50
+ from . import crypto, nodefile, tokens
51
+ from .consolidate import _has_ccg_line, _upsert_ccg_line
52
+ from .fsutil import append_jsonl, read_jsonl
53
+ from .mdcos import MdCGOS, _ccg_field
54
+ from .readcache import direct_read
55
+
56
+ # ---- 常量 ----------------------------------------------------------------
57
+
58
+ BACKFILL_LOG = "_backfill.jsonl"
59
+
60
+ # 负记忆层是「故意无条件」的(覆盖标记),派生脚手架不该再被回填成事实
61
+ SKIP_LAYERS = ("rejected", "unresolved", "goals")
62
+ # 推断脚手架 / 概念层不得回填:否则会污染锚点解析(见 predict.anchor_from_description)
63
+ SKIP_TAGS = ("gap_hint", "scene", "reconstructed", "concept", "insight")
64
+ # 记忆系统**内部脚手架层**(锚点解析 anchor / 自模型修订 self):不是用户知识,永不可回填;
65
+ # 被回填成事实会污染锚点解析与自模型(与 SKIP_LAYERS 同源理由)。crosscheck 亦复用之。
66
+ INTERNAL_LAYERS = ("anchor", "self")
67
+
68
+ # 验证基底枚举 → 可读声明(人/流程声明,不靠模型生成)
69
+ BASIS_TEXT = OrderedDict((
70
+ ("compiler", "编译器/静态检查通过"),
71
+ ("test", "单元测试/回归测试通过"),
72
+ ("measurement", "实测数据(benchmark / 采样)"),
73
+ ("formal_proof", "形式化证明"),
74
+ ("data", "数据/语料统计"),
75
+ # 来源一致性档(文科):文科知识非可复现的物理事实,以来源表述一致为足够基底
76
+ ("textbook", "依人教版教材表述一致(文科·来源一致性)"),
77
+ ("public_kb", "公开知识库条目一致(文科·来源一致性)"),
78
+ ("other", "人工评审或离线工序声明"),
79
+ ))
80
+ BASIS_ENUM_DEFAULT = "other"
81
+
82
+ BATCH_DEFAULT = "backfill"
83
+
84
+ #: 生效条件的**唯一结构化来源**:condition_space 四槽合成(见 nodefile)
85
+ BASIS_CONDITION_SYNTH = "frontmatter.condition_space(四槽合成)"
86
+ #: 旧口径残留标记:把单槽 observation_position 冒充成生效条件的留痕 basis
87
+ LEGACY_CONDITION_BASIS = "frontmatter.condition_space.observation_position"
88
+ #: 存量清洗批次的默认批次名
89
+ FIX_BATCH_DEFAULT = "cond_fix"
90
+
91
+ #: 槽名 → 人读标签(台账/报告用;与 nodefile.CONDITION_SLOTS 同源)
92
+ _SLOT_LABEL = dict(nodefile.CONDITION_SLOTS)
93
+
94
+ # 能力标签规则:cap → 关键词(小写,中文原样)。仅保留 ALL_OPS 里真实存在的 op。
95
+ _CAP_RULES_RAW = OrderedDict((
96
+ ("route", ("路由", "召回", "检索", "rank", "rrf", "route")),
97
+ ("export", ("导出", "灾备", "备份", "搬运", "export", "evidence_pack")),
98
+ ("ingest", ("摄取", "导入", "摄入", "ingest", "分派")),
99
+ ("session", ("会话", "续接", "上下文压缩", "session", "compact")),
100
+ ("maintain", ("维护", "重要性", "重算", "快照", "前馈", "模式分离", "recalc")),
101
+ ("consolidate", ("固化", "提升", "归纳", "聚类", "升格", "promote", "induce")),
102
+ ("insight", ("洞察", "情景重构", "盲区", "归因", "reconstruct", "outlook")),
103
+ ("whitebox", ("白箱", "资格判定", "裁决", "四态", "whitebox")),
104
+ ("verify", ("验证", "核验", "verdict")),
105
+ ("predict", ("预测", "趋势", "外推", "predict")),
106
+ ("causal", ("因果", "causal")),
107
+ ("metacognition", ("元认知", "metacognition")),
108
+ ("self_state", ("自我状态", "状态卡", "self_state")),
109
+ ("evolution", ("演化", "evolution", "账本")),
110
+ ("sustain", ("维生", "自愈", "心跳", "sustain")),
111
+ ("scrub", ("擦除", "去污", "scrub")),
112
+ ("protect", ("保护", "私有内容", "protect")),
113
+ ("forget", ("遗忘", "失效", "forget")),
114
+ ("link", ("蜂群", "对等", "信任", "link")),
115
+ ("identity", ("身份", "主体", "identity")),
116
+ ("goal", ("目标", "goal")),
117
+ ("recent", ("近期事件", "recent")),
118
+ ("theory", ("协议版本", "theory")),
119
+ ("consistency", ("一致性", "自洽", "consistency")),
120
+ ("ref", ("回读", "漂移", "悬空", "code_ref", "doc_ref")),
121
+ ("index_code", ("代码索引", "index_code")),
122
+ ("index_doc", ("文档索引", "章节索引", "index_doc")),
123
+ ))
124
+ # 只保留真实 op,未知 op 静默丢弃(避免注入无效能力名)
125
+ CAP_RULES = OrderedDict(
126
+ (cap, kws) for cap, kws in _CAP_RULES_RAW.items() if cap in tokens.ALL_OPS)
127
+
128
+
129
+ # ---- 通用工具 ------------------------------------------------------------
130
+
131
+ # 生效条件:x 为 str 时返回 MdCGOS(x),否则原样返回 x。
132
+ def _as_cg(x):
133
+ """接受 root 路径或已构造的 cg 实例——保持密级隔离与密钥上下文。"""
134
+ return MdCGOS(x) if isinstance(x, str) else x
135
+
136
+
137
+ # 生效条件:v 为 list/tuple 时返回分号连接的非空元素文本;v 为 None 或空串时返回 "";否则返回 str(v).strip()(v 为 0 或 False 走此支返回 "0"/"False")。
138
+ def _as_text(v) -> str:
139
+ if isinstance(v, (list, tuple)):
140
+ return ";".join(str(x).strip() for x in v if str(x).strip())
141
+ if v in (None, ""):
142
+ return ""
143
+ return str(v).strip()
144
+
145
+
146
+ # 生效条件:fm 为假值时按 {} 处理,state_attributes.comment 为 dict 时返回该 dict,否则返回 {}。
147
+ def _comment(fm: dict) -> dict:
148
+ st = (fm or {}).get("state_attributes")
149
+ c = st.get("comment") if isinstance(st, dict) else None
150
+ return c if isinstance(c, dict) else {}
151
+
152
+
153
+ # 生效条件:fm 的 state_attributes 为 dict 且其下 comment 为 dict 时原样返回该 comment;否则创建并返回空 comment dict(state_attributes 非 dict 时置 fm["state_attributes"]={},comment 非 dict 时置 st["comment"]={})。
154
+ def _ensure_comment(fm: dict) -> dict:
155
+ st = fm.get("state_attributes")
156
+ if not isinstance(st, dict):
157
+ st = {}
158
+ fm["state_attributes"] = st
159
+ c = st.get("comment")
160
+ if not isinstance(c, dict):
161
+ c = {}
162
+ st["comment"] = c
163
+ return c
164
+
165
+
166
+ # 生效条件:e 的 id 为真值时返回 id,否则返回 e 的 path 基名去掉最后 3 个字符(path 为假值时基名为空,结果空串)。
167
+ def _node_id(e: dict) -> str:
168
+ return e.get("id") or os.path.basename(e.get("path") or "")[:-3]
169
+
170
+
171
+ # 生效条件:fm 的 condition_space 四槽齐全时返回 nodefile.condition_space_text 合成文本,否则返回空串。
172
+ def _condition_text(fm: dict) -> str:
173
+ """→ 条件空间四槽合成的生效条件声明;四槽不齐 → ""(不冒充)。
174
+
175
+ **唯一**的 condition_space → 生效条件 路径。旧版在此回退到
176
+ `observation_position` **单槽**加「观测位置:」前缀——那正是
177
+ 「观测位置 ≠ 生效条件」的污染源(真实库 109 条),已删除。
178
+ """
179
+ return nodefile.condition_space_text((fm or {}).get("condition_space"))
180
+
181
+
182
+ # 生效条件:s 为真值时返回其 sha1 前 12 位,s 为假值(None/空串等)时对空串取 sha1 前 12 位。
183
+ def _sha(s: str) -> str:
184
+ return hashlib.sha1((s or "").encode("utf-8")).hexdigest()[:12]
185
+
186
+
187
+ # 生效条件:batch 与 nid 经 f-string 拼接后取 sha1 前 12 位;两者为 None 会字符串化为 "None"。
188
+ def _entry_id(batch: str, nid: str) -> str:
189
+ return hashlib.sha1(f"{batch}|{nid}".encode("utf-8")).hexdigest()[:12]
190
+
191
+
192
+ # 生效条件:content 中 strip 后以 # 开头且去掉 # 与空白后、全角或半角冒号前首段等于 field 的整行被删除,其余行保留并 join。
193
+ def _remove_ccg_line(content: str, field: str) -> str:
194
+ """删掉 `# <字段>:…` 整行(回滚用)。"""
195
+ keep = []
196
+ for ln in (content or "").split("\n"):
197
+ s = ln.strip().lstrip("#").strip()
198
+ name = s.split(":")[0].split(":")[0].strip()
199
+ if ln.strip().startswith("#") and name == field:
200
+ continue
201
+ keep.append(ln)
202
+ return "\n".join(keep)
203
+
204
+
205
+ # 生效条件:cg.root 与模块级常量 BACKFILL_LOG 拼接为返回路径。
206
+ def _log_path(cg) -> str:
207
+ return os.path.join(cg.root, BACKFILL_LOG)
208
+
209
+
210
+ # ---- 字段推导(唯一入口:只搬运已声明的证据) -----------------------------
211
+
212
+ # 生效条件:fm 与 content 给定时,仅对 content 中尚无对应 CCG 行的字段(功能名/生效条件/子功能/执行/验证方式/不适用条件)从 fm 的已有声明(state_attributes.comment、frontmatter、verification_basis、或形参 basis_text)取值,值非空且非占位文本才写入 out,假值不写、占位文本只把字段名追加进 placeholder_out(未传该形参时用临时列表)。
213
+ def derive_fields(fm: dict, content: str, basis_text: str = None,
214
+ placeholder_out: list = None) -> dict:
215
+ """按**已有声明**推导可回填字段 → `{field: (value, basis)}`。
216
+
217
+ 无来源的字段不出现在结果里(不猜测)。
218
+ **占位标记(`骨架锚点`/`内容待填充`)同样不出现**——它不是已声明的事实;
219
+ 被丢弃的字段名记入 `placeholder_out`(可选出参),供报表区分
220
+ 「无来源」与「待填充」两种缺口。
221
+ """
222
+ c = _comment(fm)
223
+ st = fm.get("state_attributes")
224
+ st = st if isinstance(st, dict) else {}
225
+ ph = placeholder_out if placeholder_out is not None else []
226
+ out = {}
227
+
228
+ # 生效条件:field 与 basis 在 value 为真值且 nodefile.is_placeholder_text(value) 为假时写入 out;value 为假值不写入;value 为占位文本时仅把 field 记入 ph。
229
+ def _put(field, value, basis):
230
+ """有值且非占位标记才写出;占位值只记名,绝不渲染成事实。"""
231
+ if not value:
232
+ return
233
+ if nodefile.is_placeholder_text(value):
234
+ ph.append(field)
235
+ return
236
+ out[field] = (value, basis)
237
+
238
+ if not _has_ccg_line(content, "功能名"):
239
+ # 优先 state_attributes.name(迁移入库写入的规范功能名),回退 frontmatter.title
240
+ raw_name = st.get("name")
241
+ v = _as_text(raw_name) if isinstance(raw_name, (str, list, tuple)) else ""
242
+ src = "state_attributes.name"
243
+ if not v:
244
+ v, src = _as_text(fm.get("title")), "frontmatter.title"
245
+ _put("功能名", v, src)
246
+
247
+ if not _has_ccg_line(content, "生效条件"):
248
+ v = _as_text(c.get("生效条件") or c.get("适用条件"))
249
+ src = "state_attributes.comment.生效条件"
250
+ if not v:
251
+ # 结构化来源:整条条件空间声明的合成,**不是** observation_position 单槽
252
+ v, src = _condition_text(fm), BASIS_CONDITION_SYNTH
253
+ _put("生效条件", v, src)
254
+
255
+ if not _has_ccg_line(content, "子功能"):
256
+ _put("子功能", _as_text(c.get("子功能") or c.get("子内容")),
257
+ "state_attributes.comment.子功能")
258
+
259
+ if not _has_ccg_line(content, "执行"):
260
+ _put("执行", _as_text(c.get("执行") or c.get("执行方式")),
261
+ "state_attributes.comment.执行")
262
+
263
+ if not _has_ccg_line(content, "验证方式"):
264
+ v = _as_text(c.get("验证方式"))
265
+ src = "state_attributes.comment.验证方式"
266
+ if not v and nodefile.verification_basis_valid(fm):
267
+ vb = fm.get("verification_basis")
268
+ v, src = BASIS_TEXT.get(vb, ""), f"frontmatter.verification_basis={vb}"
269
+ if not v and basis_text:
270
+ v, src = basis_text, "declared.basis_text"
271
+ _put("验证方式", v, src)
272
+
273
+ if not _has_ccg_line(content, "不适用条件"):
274
+ _put("不适用条件",
275
+ _as_text(c.get("不适用条件") or fm.get("non_applicable_conditions")),
276
+ "state_attributes.comment/frontmatter.non_applicable_conditions")
277
+
278
+ return out
279
+
280
+
281
+ # ---- 节点筛选 ------------------------------------------------------------
282
+
283
+ # 生效条件:cg 无 _readable 可调用时返回 True;有可调用时返回 bool(fn(e)),fn(e) 抛异常时返回 False。
284
+ def _readable_guard(cg, e) -> bool:
285
+ fn = getattr(cg, "_readable", None)
286
+ if not callable(fn):
287
+ return True
288
+ try:
289
+ return bool(fn(e))
290
+ except Exception: # noqa: BLE001
291
+ return False
292
+
293
+
294
+ # 生效条件:仅当 cg 对 e 读出的 fm 非 None、content 未被 crypto.is_encrypted、e['layer'] 不在 SKIP_LAYERS 且 fm.get('tags') 无命中 SKIP_TAGS、ccg_completeness(content)['complete'] 为假时才继续——derive_fields(受 basis_text 影响)过滤掉 content 已有 CCG 行的可写字段为空时按 placeholder_out 是否非空返回 ('placeholder'/'unfillable', None),非空时返回 ('', item)(item 的 id 取 nid、class 依 undeducible 是否为空取 'backfillable' 或 'partial');上述四个前置不满足时依次返回 ('unreadable'/'locked'/'derived'/'present', None)。
295
+ def _classify(cg, e, nid, basis_text=None):
296
+ """→ (skip_reason, item);skip_reason 非空表示不参与回填。"""
297
+ fm, content = direct_read(cg, e)
298
+ if fm is None:
299
+ return "unreadable", None
300
+ if crypto.is_encrypted(content):
301
+ return "locked", None
302
+ tags = fm.get("tags") or []
303
+ if e.get("layer") in SKIP_LAYERS or any(t in SKIP_TAGS for t in tags):
304
+ return "derived", None
305
+ cpl = nodefile.ccg_completeness(content)
306
+ if cpl["complete"]:
307
+ return "present", None
308
+ ph_fields = []
309
+ der = derive_fields(fm, content, basis_text=basis_text,
310
+ placeholder_out=ph_fields)
311
+ fill = {f: der[f] for f in der if not _has_ccg_line(content, f)}
312
+ required_missing = [f for f in nodefile.CCG_REQUIRED
313
+ if not _has_ccg_line(content, f)]
314
+ undeducible = [f for f in required_missing if f not in der]
315
+ if not fill:
316
+ # 无可写字段:区分「无来源」(unfillable)与「字段值全是待填充标记」
317
+ # (placeholder)——后者是空壳节点,须转待填充工单,而非静默计入无来源。
318
+ return ("placeholder" if ph_fields else "unfillable"), None
319
+ cls = "backfillable" if not undeducible else "partial"
320
+ # 待补台账:生效条件既不在正文、也推不出(四槽不全)→ 记缺失槽名。
321
+ # 这不是「无来源」而是**缺证据**:补不动者按裁定判 BLINDSPOT,绝不静默 ACCEPT。
322
+ cond_pending = []
323
+ if not _has_ccg_line(content, "生效条件") and "生效条件" not in der:
324
+ cond_pending = nodefile.condition_space_missing(fm.get("condition_space"))
325
+ return "", {
326
+ "id": nid, "layer": e.get("layer"), "class": cls,
327
+ "fill": {f: {"value": v, "basis": b} for f, (v, b) in fill.items()},
328
+ "missing_undeducible": undeducible,
329
+ "placeholder_fields": ph_fields,
330
+ "conditions_pending": cond_pending,
331
+ "before_ratio": cpl["ratio"],
332
+ }
333
+
334
+
335
+ # 生效条件:x 经 _as_cg 后遍历 cg.index.nodes,按 ids/layer/prefix 过滤,内部层/不可读/locked/derived/present/unfillable/placeholder/partial 且 include_partial 为 False 分别计数跳过,其余标记 entry_id 并计入 targeted,items 受 limit 限制(limit 为 None 或 len(items) < limit 时追加),返回 dry_run rep。
336
+ def plan(x, layer=None, limit=None, ids=None, include_partial=False,
337
+ basis_text=None, prefix=None) -> dict:
338
+ """预演:产出可回填清单,不写盘。
339
+
340
+ `prefix`:按 id 前缀收窄范围(真实库用 `kp_`,与核对工单同一边界);
341
+ 内部 `anchor`/`self` 层一律出局(计入 `skipped_internal`)。
342
+ """
343
+ cg = _as_cg(x)
344
+ rep = {"root": cg.root, "dry_run": True, "action": "backfill",
345
+ "prefix": prefix, "nodes_scanned": 0, "skipped_locked": 0,
346
+ "skipped_derived": 0, "skipped_internal": 0,
347
+ "skipped_present": 0, "skipped_denied": 0, "unfillable": 0,
348
+ "skipped_placeholder": 0, "nodes_with_placeholder": 0,
349
+ "skipped_partial": 0, "targeted": 0,
350
+ # 待写节点中生效条件仍缺声明的数量(全库台账见 conditions_pending)
351
+ "targeted_missing_conditions": 0, "items": []}
352
+ want = set(ids) if ids else None
353
+ for nid, e in list((cg.index.get("nodes") or {}).items()):
354
+ if want is not None and nid not in want:
355
+ continue
356
+ if prefix and not str(nid).startswith(prefix):
357
+ continue
358
+ if layer and e.get("layer") != layer:
359
+ continue
360
+ if e.get("layer") in INTERNAL_LAYERS:
361
+ rep["skipped_internal"] += 1
362
+ continue
363
+ if not _readable_guard(cg, e):
364
+ rep["skipped_denied"] += 1
365
+ continue
366
+ rep["nodes_scanned"] += 1
367
+ reason, item = _classify(cg, e, nid, basis_text=basis_text)
368
+ if reason == "locked":
369
+ rep["skipped_locked"] += 1
370
+ continue
371
+ if reason == "derived":
372
+ rep["skipped_derived"] += 1
373
+ continue
374
+ if reason == "present":
375
+ rep["skipped_present"] += 1
376
+ continue
377
+ if reason == "unfillable":
378
+ rep["unfillable"] += 1
379
+ continue
380
+ if reason == "placeholder":
381
+ rep["skipped_placeholder"] += 1
382
+ continue
383
+ if item.get("placeholder_fields"):
384
+ rep["nodes_with_placeholder"] += 1
385
+ if item.get("conditions_pending"):
386
+ rep["targeted_missing_conditions"] += 1
387
+ if item["class"] == "partial" and not include_partial:
388
+ rep["skipped_partial"] += 1
389
+ continue
390
+ item["entry_id"] = _entry_id("backfill", nid)
391
+ rep["targeted"] += 1
392
+ if limit is None or len(rep["items"]) < limit:
393
+ rep["items"].append(item)
394
+ rep["planned_ids"] = [i["id"] for i in rep["items"]]
395
+ return rep
396
+
397
+
398
+ # ---- 回填写入 / 回滚 / 留痕 ----------------------------------------------
399
+
400
+ # 生效条件:x 可被 _as_cg 解释为 CG 句柄时,按 layer/ids/prefix/entry_ids 选定条目做回填并返回含 written 等计数的 rep,其中 limit 非 None 时把写入数截断到该值。
401
+ def apply(x, ids=None, entry_ids=None, layer=None, limit=None,
402
+ batch=BATCH_DEFAULT, include_partial=False, basis_text=None,
403
+ actor=None, prefix=None) -> dict:
404
+ """执行回填:逐节点改写 md,写 `_backfill.jsonl` 留痕。"""
405
+ cg = _as_cg(x)
406
+ batch = batch or BATCH_DEFAULT
407
+ p = plan(cg, layer=layer, limit=None, ids=ids, prefix=prefix,
408
+ include_partial=include_partial, basis_text=basis_text)
409
+ items = p["items"]
410
+ if entry_ids:
411
+ want = set(entry_ids)
412
+ items = [i for i in items if i["entry_id"] in want]
413
+ rep = {"root": cg.root, "dry_run": False, "action": "backfill",
414
+ "batch": batch, "actor": actor, "planned": len(items),
415
+ "written": 0, "skipped_drift": 0, "skipped_locked": 0,
416
+ "entry_ids": [], "by_field": {}}
417
+ for it in items:
418
+ if limit is not None and rep["written"] >= limit:
419
+ break
420
+ nid = it["id"]
421
+ e = cg.index["nodes"].get(nid)
422
+ if not e:
423
+ rep["skipped_drift"] += 1
424
+ continue
425
+ fm, content = direct_read(cg, e)
426
+ if fm is None or crypto.is_encrypted(content):
427
+ rep["skipped_locked"] += 1
428
+ continue
429
+ # 预演到执行之间节点可能被改动:只写仍缺失的字段
430
+ todo = {f: d for f, d in it["fill"].items()
431
+ if not _has_ccg_line(content, f)}
432
+ if not todo:
433
+ rep["skipped_drift"] += 1
434
+ continue
435
+ comment0 = _comment(fm)
436
+ # 记录改写前的真相:rollback 必须「还原」而非「删除」——否则 comment
437
+ # 里原有的声明会被误删,导致回填不可重复(回滚不是真逆操作)。
438
+ prev_c = {f: comment0[f] for f in todo if f in comment0}
439
+ fm_before = {}
440
+ if "不适用条件" in todo:
441
+ fm_before["non_applicable_conditions"] = {
442
+ "had": "non_applicable_conditions" in fm,
443
+ "value": fm.get("non_applicable_conditions")}
444
+ if "验证方式" in todo and not nodefile.verification_basis_valid(fm):
445
+ fm_before["verification_basis"] = {
446
+ "had": "verification_basis" in fm,
447
+ "value": fm.get("verification_basis")}
448
+ comment = _ensure_comment(fm)
449
+ wid = _sha(f"{nid}|{batch}|{time.time()}")
450
+ applied = {}
451
+ for f, d in todo.items():
452
+ content = _upsert_ccg_line(content, f, d["value"])
453
+ comment[f] = d["value"]
454
+ if f == "不适用条件":
455
+ fm["non_applicable_conditions"] = [
456
+ s.strip() for s in d["value"].split(";") if s.strip()]
457
+ if f == "验证方式" and not nodefile.verification_basis_valid(fm):
458
+ fm["verification_basis"] = BASIS_ENUM_DEFAULT
459
+ applied[f] = {"after": d["value"], "basis": d["basis"],
460
+ "before": prev_c.get(f)}
461
+ rep["by_field"][f] = rep["by_field"].get(f, 0) + 1
462
+ cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
463
+ durable=True)
464
+ append_jsonl(_log_path(cg), {
465
+ "action": "backfill", "ts": time.time(), "batch": batch,
466
+ "actor": actor, "entry_id": it["entry_id"], "write_id": wid,
467
+ "node": nid, "layer": e.get("layer"), "fields": applied,
468
+ "fm_before": fm_before,
469
+ "content_hash_after": _sha(content)})
470
+ rep["written"] += 1
471
+ rep["entry_ids"].append(it["entry_id"])
472
+ if rep["written"]:
473
+ cg.rebuild_index()
474
+ rep["plan_remaining"] = max(0, p["targeted"] - len(items))
475
+ return rep
476
+
477
+
478
+ # 生效条件:x 经 _as_cg 定位后读留痕日志,仅对 action=='backfill' 且(batch 为假值则不过滤 batch,否则 rec['batch']==batch)、(entry_ids 为假值则不过滤,否则 rec['entry_id'] 属于该集合)、write_id 未出现在已完成 rollback 集合中、节点命中 cg.index['nodes'] 且 direct_read(cg, e) 的 fm 可读、字段当前 _ccg_field(content, f) 等于留痕 after 的记录执行撤销写回(before 为 None 则删该 comment 键,否则还原原值),无字段可撤销只计 conflict 不写盘,reverted 非空时 rebuild_index,结果汇总进返回的 rep。
479
+ def rollback(x, batch=None, entry_ids=None, actor=None) -> dict:
480
+ """按留痕反向应用:撤销本批次回填(当前值 ≠ 写入值时跳过,防覆盖)。"""
481
+ cg = _as_cg(x)
482
+ want = set(entry_ids) if entry_ids else None
483
+ rep = {"root": cg.root, "action": "backfill_rollback", "actor": actor,
484
+ "batch": batch, "reverted": 0, "conflict": 0, "missing": 0,
485
+ "fields_reverted": 0, "skipped_done": 0}
486
+ log = list(read_jsonl(_log_path(cg)) or [])
487
+ done = {r.get("write_id") for r in log
488
+ if r.get("action") == "backfill_rollback" and r.get("write_id")}
489
+ for rec in log:
490
+ if rec.get("action") != "backfill":
491
+ continue
492
+ if rec.get("write_id") and rec.get("write_id") in done:
493
+ rep["skipped_done"] += 1
494
+ continue
495
+ if batch and rec.get("batch") != batch:
496
+ continue
497
+ if want is not None and rec.get("entry_id") not in want:
498
+ continue
499
+ nid = rec.get("node")
500
+ e = cg.index["nodes"].get(nid)
501
+ if not e:
502
+ rep["missing"] += 1
503
+ continue
504
+ fm, content = direct_read(cg, e)
505
+ if fm is None:
506
+ rep["missing"] += 1
507
+ continue
508
+ comment = _comment(fm)
509
+ reverted, conflicted = {}, []
510
+ for f, d in (rec.get("fields") or {}).items():
511
+ if _ccg_field(content, f) != d.get("after"):
512
+ conflicted.append(f) # 已被后续修改 → 不撤销
513
+ continue
514
+ content = _remove_ccg_line(content, f)
515
+ b = d.get("before")
516
+ if b is None:
517
+ comment.pop(f, None) # 原本就没有 → 删回「无」
518
+ else:
519
+ comment[f] = b # 原本有 → 还原原值(非删除)
520
+ reverted[f] = d.get("after")
521
+ if not reverted:
522
+ rep["conflict"] += 1
523
+ continue
524
+ for k, box in (rec.get("fm_before") or {}).items():
525
+ if box.get("had"):
526
+ fm[k] = box.get("value")
527
+ else:
528
+ fm.pop(k, None)
529
+ st = fm.get("state_attributes")
530
+ if isinstance(st, dict) and isinstance(st.get("comment"), dict) \
531
+ and not st["comment"]:
532
+ st.pop("comment", None)
533
+ cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
534
+ durable=True)
535
+ append_jsonl(_log_path(cg), {
536
+ "action": "backfill_rollback", "ts": time.time(), "actor": actor,
537
+ "batch": rec.get("batch"), "entry_id": rec.get("entry_id"),
538
+ "write_id": rec.get("write_id"), "node": nid,
539
+ "reverted": list(reverted), "conflict": conflicted})
540
+ rep["reverted"] += 1
541
+ rep["fields_reverted"] += len(reverted)
542
+ if conflicted:
543
+ rep["conflict"] += 1
544
+ if rep["reverted"]:
545
+ cg.rebuild_index()
546
+ return rep
547
+
548
+
549
+ # 生效条件:x 经 _as_cg,action/batch 为真值时过滤对应日志记录;limit 不为 None 且 >=0 时按 recs[-limit:] 截断(limit=0 时切片为全部记录),limit 为 None 或负数时不截断;返回 total/returned/records。
550
+ def history(x, limit=100, action=None, batch=None) -> dict:
551
+ cg = _as_cg(x)
552
+ recs = []
553
+ for rec in read_jsonl(_log_path(cg)) or []:
554
+ if action and rec.get("action") != action:
555
+ continue
556
+ if batch and rec.get("batch") != batch:
557
+ continue
558
+ recs.append(rec)
559
+ total = len(recs)
560
+ if limit is not None and limit >= 0:
561
+ recs = recs[-limit:]
562
+ return {"root": cg.root, "total": total, "returned": len(recs),
563
+ "records": recs}
564
+
565
+
566
+ # ---- 能力标签注入(关键词启发式) ----------------------------------------
567
+
568
+ # 候选匹配不得吃进两类「自产词」,否则候选再生、plan 永不收敛:
569
+ # ① `fm.tags`:`cap:<op>` 是**注入结果**,回流后 `cap:route` 自匹配关键词
570
+ # "route"、`cap:self_state` 自匹配 "self_state"…… 已注入节点会重新成为候选;
571
+ # ② `# 验证方式:` 模板行:它是 CCG 五要素的必备行,展开后**几乎全库**命中
572
+ # 「验证」,`cap:verify` 遂从能力判断退化为正文模板的副产品
573
+ # (evolution 账本实测:预演命中 1630/1813)。
574
+ _CAP_TEMPLATE_LINES = ("验证方式",)
575
+
576
+
577
+ # 生效条件:content 中去除 # 与空白后、全角或半角冒号前首段命中 _CAP_TEMPLATE_LINES 的行被剔除,其余行保留并 join。
578
+ def _cap_body(content: str) -> str:
579
+ """正文(供关键词匹配)——剔除 CCG 模板行,防模板词污染候选。"""
580
+ keep = []
581
+ for line in (content or "").splitlines():
582
+ head = line.strip().lstrip("#").strip()
583
+ head = head.split(":", 1)[0].split(":", 1)[0].strip()
584
+ if head in _CAP_TEMPLATE_LINES:
585
+ continue
586
+ keep.append(line)
587
+ return "\n".join(keep)
588
+
589
+
590
+ # 生效条件:当 fm 为可 get 的 frontmatter、e 为带 id 的节点条目、content 为正文文本时,返回 title+e.id+功能名/生效条件/子功能字段+正文前 300 字合并后的小写串(不含 fm.tags)。
591
+ def _cap_text(e, fm, content) -> str:
592
+ """候选匹配文本:节点标识 + CCG 字段 + 正文(**不含 `fm.tags`**)。"""
593
+ parts = [_as_text(fm.get("title")), e.get("id") or ""]
594
+ for f in ("功能名", "生效条件", "子功能"):
595
+ v = _ccg_field(content, f)
596
+ if v:
597
+ parts.append(v)
598
+ parts.append(_cap_body(content)[:300])
599
+ return " ".join(parts).lower()
600
+
601
+
602
+ # 生效条件:text 包含 CAP_RULES 中某 cap 的至少一个关键词时,该 cap 以匹配关键词与置信度加入返回,按置信度降序、cap 升序排序;无匹配返回空 hits。
603
+ def cap_matches(text: str) -> list:
604
+ hits = []
605
+ for cap, kws in CAP_RULES.items():
606
+ m = [k for k in kws if k in text]
607
+ if m:
608
+ hits.append({"cap": cap, "matched_by": m,
609
+ "confidence": round(min(1.0, 0.4 + 0.2 * len(m)), 3)})
610
+ hits.sort(key=lambda h: (-h["confidence"], h["cap"]))
611
+ return hits
612
+
613
+
614
+ # 生效条件:x 经 _as_cg,遍历 nodes 按 ids/layer 过滤,不可读计 denied,读取失败或加密计 locked,扫描后以 _cap_text 匹配并过滤 confidence >= min_conf 且标签未含 cap:,无命中计 present,有命中则 targeted 并受 limit 限制加入 items,返回 dry_run rep。
615
+ def cap_plan(x, layer=None, limit=None, ids=None, min_conf=0.5) -> dict:
616
+ """预演:按关键词启发式给出 `cap:<op>` 标签建议(含依据与置信度),不写盘。"""
617
+ cg = _as_cg(x)
618
+ rep = {"root": cg.root, "dry_run": True, "action": "cap",
619
+ "min_conf": min_conf, "nodes_scanned": 0, "skipped_locked": 0,
620
+ "skipped_present": 0, "skipped_denied": 0, "targeted": 0,
621
+ "items": []}
622
+ want = set(ids) if ids else None
623
+ for nid, e in list((cg.index.get("nodes") or {}).items()):
624
+ if want is not None and nid not in want:
625
+ continue
626
+ if layer and e.get("layer") != layer:
627
+ continue
628
+ if not _readable_guard(cg, e):
629
+ rep["skipped_denied"] += 1
630
+ continue
631
+ fm, content = direct_read(cg, e)
632
+ if fm is None or crypto.is_encrypted(content):
633
+ rep["skipped_locked"] += 1
634
+ continue
635
+ rep["nodes_scanned"] += 1
636
+ have = set(t for t in (fm.get("tags") or []) if isinstance(t, str))
637
+ hits = [h for h in cap_matches(_cap_text(e, fm, content))
638
+ if h["confidence"] >= min_conf
639
+ and f"cap:{h['cap']}" not in have]
640
+ if not hits:
641
+ rep["skipped_present"] += 1
642
+ continue
643
+ item = {"id": nid, "layer": e.get("layer"), "caps": hits,
644
+ "entry_id": _entry_id("cap", nid)}
645
+ rep["targeted"] += 1
646
+ if limit is None or len(rep["items"]) < limit:
647
+ rep["items"].append(item)
648
+ rep["planned_ids"] = [i["id"] for i in rep["items"]]
649
+ return rep
650
+
651
+
652
+ # 生效条件:x 经 _as_cg,batch 假值回落 BATCH_DEFAULT;先 cap_plan 得 items,按 entry_ids 过滤;逐个检查节点存在、读取可读、无新增标签分别计 drift/locked/drift,成功写 tags 并记日志,limit 非 None 且 written >= limit 时 break;返回 rep。
653
+ def cap_apply(x, ids=None, entry_ids=None, layer=None, limit=None,
654
+ batch=BATCH_DEFAULT, min_conf=0.5, actor=None) -> dict:
655
+ """注入 `cap:<op>` 标签:只改 frontmatter.tags,不动正文。"""
656
+ cg = _as_cg(x)
657
+ batch = batch or BATCH_DEFAULT
658
+ p = cap_plan(cg, layer=layer, limit=None, ids=ids, min_conf=min_conf)
659
+ items = p["items"]
660
+ if entry_ids:
661
+ want = set(entry_ids)
662
+ items = [i for i in items if i["entry_id"] in want]
663
+ rep = {"root": cg.root, "dry_run": False, "action": "cap", "batch": batch,
664
+ "actor": actor, "min_conf": min_conf, "planned": len(items),
665
+ "written": 0, "skipped_locked": 0, "skipped_drift": 0,
666
+ "tags_added": 0, "entry_ids": []}
667
+ for it in items:
668
+ if limit is not None and rep["written"] >= limit:
669
+ break
670
+ nid = it["id"]
671
+ e = cg.index["nodes"].get(nid)
672
+ if not e:
673
+ rep["skipped_drift"] += 1
674
+ continue
675
+ fm, content = direct_read(cg, e)
676
+ if fm is None or crypto.is_encrypted(content):
677
+ rep["skipped_locked"] += 1
678
+ continue
679
+ tags = list(fm.get("tags") or [])
680
+ added = [f"cap:{h['cap']}" for h in it["caps"] if f"cap:{h['cap']}" not in tags]
681
+ if not added:
682
+ rep["skipped_drift"] += 1
683
+ continue
684
+ fm["tags"] = tags + added
685
+ cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
686
+ durable=True)
687
+ append_jsonl(_log_path(cg), {
688
+ "action": "cap", "ts": time.time(), "batch": batch, "actor": actor,
689
+ "entry_id": it["entry_id"], "write_id": _sha(f"cap|{nid}|{time.time()}"),
690
+ "node": nid, "layer": e.get("layer"),
691
+ "tags_added": added,
692
+ "evidence": {h["cap"]: h["matched_by"] for h in it["caps"]},
693
+ "confidence": {h["cap"]: h["confidence"] for h in it["caps"]}})
694
+ rep["written"] += 1
695
+ rep["tags_added"] += len(added)
696
+ rep["entry_ids"].append(it["entry_id"])
697
+ if rep["written"]:
698
+ cg.rebuild_index()
699
+ rep["plan_remaining"] = max(0, p["targeted"] - len(items))
700
+ return rep
701
+
702
+
703
+ # 生效条件:x 经 _as_cg,读取日志中 action=cap 且未回滚的记录,按 batch/entry_ids 过滤,节点存在且原加入标签仍在 tags 中时移除,否则计 conflict/missing,返回 rep。
704
+ def cap_rollback(x, batch=None, entry_ids=None, actor=None) -> dict:
705
+ """撤销 cap 注入:仅移除**仍在 tags 里**的 `cap:` 标签(防覆盖后续修改)。"""
706
+ cg = _as_cg(x)
707
+ want = set(entry_ids) if entry_ids else None
708
+ rep = {"root": cg.root, "action": "cap_rollback", "actor": actor,
709
+ "batch": batch, "reverted": 0, "conflict": 0, "missing": 0,
710
+ "tags_removed": 0, "skipped_done": 0}
711
+ log = list(read_jsonl(_log_path(cg)) or [])
712
+ done = {r.get("write_id") for r in log
713
+ if r.get("action") == "cap_rollback" and r.get("write_id")}
714
+ for rec in log:
715
+ if rec.get("action") != "cap":
716
+ continue
717
+ if rec.get("write_id") and rec.get("write_id") in done:
718
+ rep["skipped_done"] += 1
719
+ continue
720
+ if batch and rec.get("batch") != batch:
721
+ continue
722
+ if want is not None and rec.get("entry_id") not in want:
723
+ continue
724
+ nid, added = rec.get("node"), rec.get("tags_added") or []
725
+ e = cg.index["nodes"].get(nid)
726
+ if not e:
727
+ rep["missing"] += 1
728
+ continue
729
+ fm, content = direct_read(cg, e)
730
+ if fm is None:
731
+ rep["missing"] += 1
732
+ continue
733
+ tags = list(fm.get("tags") or [])
734
+ removed = [t for t in added if t in tags]
735
+ if not removed:
736
+ rep["conflict"] += 1
737
+ continue
738
+ fm["tags"] = [t for t in tags if t not in set(removed)]
739
+ cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
740
+ durable=True)
741
+ append_jsonl(_log_path(cg), {
742
+ "action": "cap_rollback", "ts": time.time(), "actor": actor,
743
+ "batch": rec.get("batch"), "entry_id": rec.get("entry_id"),
744
+ "write_id": rec.get("write_id"), "node": nid,
745
+ "tags_removed": removed})
746
+ rep["reverted"] += 1
747
+ rep["tags_removed"] += len(removed)
748
+ if rep["reverted"]:
749
+ cg.rebuild_index()
750
+ return rep
751
+
752
+
753
+ # ---- 豁免解除(ccg_exempt 分批摘除) --------------------------------------
754
+
755
+ EXEMPT_FLAG = "ccg_exempt"
756
+
757
+
758
+ # 生效条件:fm 的 verification_basis 合法且 content 的 ccg_completeness 标记 complete 时返回 (True, []),否则把缺失项放入 miss 返回 ready=False。
759
+ def _exempt_ready(fm: dict, content: str):
760
+ """摘豁免前置条件 → `(ready, missing)`。
761
+
762
+ 硬约束(顺序依赖):证据未补齐就摘豁免,节点会从 DEFER **退化为 BLINDSPOT**,
763
+ 比现状更差。故要求「合法 `verification_basis`」+「5 要素齐备(含验证方式行)」
764
+ 同时成立才允许摘除。
765
+ """
766
+ miss = []
767
+ if not nodefile.verification_basis_valid(fm):
768
+ miss.append("verification_basis")
769
+ if not nodefile.ccg_completeness(content).get("complete"):
770
+ miss.append("ccg5")
771
+ return (not miss), miss
772
+
773
+
774
+ # 生效条件:x 经 _as_cg,遍历 nodes 按 ids/prefix/layer 过滤,内部层/不可读/读取失败或加密分别计数跳过,fm 无 EXEMPT_FLAG 计 not_exempt,require_ready 为真且不 ready 时计 unready 并在 want 为 None 时跳过,否则生成 item 受 limit 限制;sample 为真值时按 id 序等距抽取 sample 个。
775
+ def exempt_plan(x, layer=None, limit=None, ids=None, require_ready=True,
776
+ sample=0, prefix=None) -> dict:
777
+ """预演:列出可摘 `ccg_exempt` 的节点(默认要求证据就绪),不写盘。
778
+
779
+ `sample=N` 时按 id 序等距抽取 N 个作为验收样本(确定性,重跑同一样本)。
780
+ `prefix`:按 id 前缀收窄范围(真实库用 `kp_`);内部 `anchor`/`self` 层出局。
781
+ """
782
+ cg = _as_cg(x)
783
+ rep = {"root": cg.root, "dry_run": True, "action": "exempt",
784
+ "require_ready": require_ready, "prefix": prefix, "nodes_scanned": 0,
785
+ "skipped_locked": 0, "skipped_denied": 0, "skipped_not_exempt": 0,
786
+ "skipped_internal": 0, "skipped_unready": 0, "unready_reasons": {},
787
+ "targeted": 0, "items": [], "sample": []}
788
+ want = set(ids) if ids else None
789
+ for nid, e in list((cg.index.get("nodes") or {}).items()):
790
+ if want is not None and nid not in want:
791
+ continue
792
+ if prefix and not str(nid).startswith(prefix):
793
+ continue
794
+ if layer and e.get("layer") != layer:
795
+ continue
796
+ if e.get("layer") in INTERNAL_LAYERS:
797
+ rep["skipped_internal"] += 1
798
+ continue
799
+ if not _readable_guard(cg, e):
800
+ rep["skipped_denied"] += 1
801
+ continue
802
+ fm, content = direct_read(cg, e)
803
+ if fm is None or crypto.is_encrypted(content):
804
+ rep["skipped_locked"] += 1
805
+ continue
806
+ rep["nodes_scanned"] += 1
807
+ if not fm.get(EXEMPT_FLAG):
808
+ rep["skipped_not_exempt"] += 1
809
+ continue
810
+ ready, miss = _exempt_ready(fm, content)
811
+ if require_ready and not ready:
812
+ rep["skipped_unready"] += 1
813
+ for m in miss:
814
+ rep["unready_reasons"][m] = rep["unready_reasons"].get(m, 0) + 1
815
+ # 批量:直接过滤(报表已计数);显式点名:入列交由 apply 判定并留
816
+ # `exempt_skip` 记录——被点名的节点绝不静默丢弃。
817
+ if want is None:
818
+ continue
819
+ item = {"id": nid, "layer": e.get("layer"), "ready": ready,
820
+ "missing": miss, "basis": fm.get("verification_basis"),
821
+ "entry_id": _entry_id("exempt", nid)}
822
+ rep["targeted"] += 1
823
+ if limit is None or len(rep["items"]) < limit:
824
+ rep["items"].append(item)
825
+ rep["planned_ids"] = [i["id"] for i in rep["items"]]
826
+ if sample and rep["items"]:
827
+ ids_all = [i["id"] for i in rep["items"]]
828
+ k = min(int(sample), len(ids_all))
829
+ stride = max(1, len(ids_all) // k)
830
+ rep["sample"] = ids_all[::stride][:k]
831
+ return rep
832
+
833
+
834
+ # 生效条件:x 经 _as_cg,batch 假值回落 BATCH_DEFAULT;先 exempt_plan 得 items,按 entry_ids 过滤;逐个检查节点存在、可读、EXEMPT_FLAG 仍真、require_ready 为真时 _exempt_ready 再次通过;不通过计 skipped_unready 并记 exempt_skip;通过则置 EXEMPT_FLAG=False 写盘记日志;limit 限制 written;返回 rep。
835
+ def exempt_apply(x, ids=None, entry_ids=None, layer=None, limit=None,
836
+ batch=BATCH_DEFAULT, require_ready=True, actor=None,
837
+ prefix=None) -> dict:
838
+ """分批摘除 `ccg_exempt`(置 False 而非删键,便于反向还原)。
839
+
840
+ 就绪校验在**写入前**再查一次(plan 与 apply 之间可能被改动);
841
+ 不满足则计 `skipped_unready` 并留 `exempt_skip` 记录,绝不硬摘。
842
+ """
843
+ cg = _as_cg(x)
844
+ batch = batch or BATCH_DEFAULT
845
+ p = exempt_plan(cg, layer=layer, ids=ids, require_ready=require_ready,
846
+ prefix=prefix)
847
+ items = p["items"]
848
+ if entry_ids:
849
+ want = set(entry_ids)
850
+ items = [i for i in items if i["entry_id"] in want]
851
+ rep = {"root": cg.root, "dry_run": False, "action": "exempt", "batch": batch,
852
+ "actor": actor, "require_ready": require_ready, "planned": len(items),
853
+ "written": 0, "skipped_unready": 0, "skipped_locked": 0,
854
+ "skipped_drift": 0, "entry_ids": []}
855
+ for it in items:
856
+ if limit is not None and rep["written"] >= limit:
857
+ break
858
+ nid = it["id"]
859
+ e = cg.index["nodes"].get(nid)
860
+ if not e:
861
+ rep["skipped_drift"] += 1
862
+ continue
863
+ fm, content = direct_read(cg, e)
864
+ if fm is None or crypto.is_encrypted(content):
865
+ rep["skipped_locked"] += 1
866
+ continue
867
+ if not fm.get(EXEMPT_FLAG):
868
+ rep["skipped_drift"] += 1
869
+ continue
870
+ ready, miss = _exempt_ready(fm, content)
871
+ if require_ready and not ready:
872
+ rep["skipped_unready"] += 1
873
+ append_jsonl(_log_path(cg), {
874
+ "action": "exempt_skip", "ts": time.time(), "batch": batch,
875
+ "actor": actor, "node": nid, "missing": miss})
876
+ continue
877
+ before = fm.get(EXEMPT_FLAG)
878
+ fm[EXEMPT_FLAG] = False
879
+ wid = _sha(f"exempt|{nid}|{time.time()}")
880
+ cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
881
+ durable=True)
882
+ append_jsonl(_log_path(cg), {
883
+ "action": "exempt", "ts": time.time(), "batch": batch, "actor": actor,
884
+ "entry_id": it["entry_id"], "write_id": wid, "node": nid,
885
+ "layer": e.get("layer"), "exempt_before": before,
886
+ "basis": fm.get("verification_basis")})
887
+ rep["written"] += 1
888
+ rep["entry_ids"].append(it["entry_id"])
889
+ if rep["written"]:
890
+ cg.rebuild_index()
891
+ rep["plan_remaining"] = max(0, p["targeted"] - len(items))
892
+ return rep
893
+
894
+
895
+ # 生效条件:当 x 可解析为 cg 时,日志中 action 为 exempt 的记录若其非空 write_id 已存在于既有 action 为 exempt_rollback 的记录 write_id 集合中,则跳过并计入 skipped_done,否则在通过 batch 与 entry_ids 过滤后,节点存在且可读、EXEMPT_FLAG 当前为假时,该记录才被还原并计入 reverted;。
896
+ def exempt_rollback(x, batch=None, entry_ids=None, actor=None) -> dict:
897
+ """反向还原 `ccg_exempt`:仅当当前仍为「已摘」状态时还原,否则计 conflict。"""
898
+ cg = _as_cg(x)
899
+ want = set(entry_ids) if entry_ids else None
900
+ rep = {"root": cg.root, "action": "exempt_rollback", "actor": actor,
901
+ "batch": batch, "reverted": 0, "conflict": 0, "missing": 0,
902
+ "skipped_done": 0}
903
+ log = list(read_jsonl(_log_path(cg)) or [])
904
+ done = {r.get("write_id") for r in log
905
+ if r.get("action") == "exempt_rollback" and r.get("write_id")}
906
+ for rec in log:
907
+ if rec.get("action") != "exempt":
908
+ continue
909
+ if rec.get("write_id") and rec.get("write_id") in done:
910
+ rep["skipped_done"] += 1
911
+ continue
912
+ if batch and rec.get("batch") != batch:
913
+ continue
914
+ if want is not None and rec.get("entry_id") not in want:
915
+ continue
916
+ nid = rec.get("node")
917
+ e = cg.index["nodes"].get(nid)
918
+ if not e:
919
+ rep["missing"] += 1
920
+ continue
921
+ fm, content = direct_read(cg, e)
922
+ if fm is None:
923
+ rep["missing"] += 1
924
+ continue
925
+ if fm.get(EXEMPT_FLAG):
926
+ rep["conflict"] += 1
927
+ continue
928
+ fm[EXEMPT_FLAG] = rec.get("exempt_before", True)
929
+ cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
930
+ durable=True)
931
+ append_jsonl(_log_path(cg), {
932
+ "action": "exempt_rollback", "ts": time.time(), "actor": actor,
933
+ "batch": rec.get("batch"), "entry_id": rec.get("entry_id"),
934
+ "write_id": rec.get("write_id"), "node": nid,
935
+ "exempt_restored": fm.get(EXEMPT_FLAG)})
936
+ rep["reverted"] += 1
937
+ if rep["reverted"]:
938
+ cg.rebuild_index()
939
+ return rep
940
+
941
+
942
+ # ---- 待补台账 / 存量清洗(生效条件口径修正) ------------------------------
943
+ #
944
+ # 背景:旧口径把 `condition_space.observation_position` 单槽加前缀「观测位置:」
945
+ # 当作生效条件写入(真实库 109 条)。观测位置 ≠ 生效条件——生效条件是**整条**
946
+ # 条件空间声明的合成。本段负责三件事:
947
+ # ① conditions_pending 只读台账:未声明且四槽推不出的节点
948
+ # ② fix_conditions_* 清洗:冒充行重渲染为合规声明,或删除并登记待补
949
+ # ③ verify_conditions 只读复算:验收指标 legacy_position == 0
950
+
951
+
952
+ # 生效条件:x 经 _as_cg,遍历 nodes 按 prefix/layer 过滤,内部层/不可读/读取失败或加密/derived 层或 SKIP_TAGS 分别计数跳过;扫描后,正文已有生效条件计 declared,derive_fields 可推出计 derivable,否则按 condition_space 缺失槽计 pending 并受 limit 限制收集 items;返回 rep。
953
+ def conditions_pending(x, prefix=None, layer=None, limit=None) -> dict:
954
+ """只读台账:列出「未声明生效条件、且四槽推不出」的节点及其缺失槽。
955
+
956
+ 生效条件已成为必填项(`CCG_REQUIRED`),但存量节点未必有足够声明可补。
957
+ 这类节点**不能静默判 ACCEPT**:进本台账等待后续补充;确实补不动者由资格
958
+ 判定落 BLINDSPOT(而不是被「常用条件默认省略」掩盖)。本函数不写盘。
959
+ """
960
+ cg = _as_cg(x)
961
+ rep = {"root": cg.root, "dry_run": True, "action": "conditions_pending",
962
+ "prefix": prefix, "nodes_scanned": 0, "skipped_locked": 0,
963
+ "skipped_denied": 0, "skipped_internal": 0, "skipped_derived": 0,
964
+ "declared": 0, "derivable": 0, "pending": 0,
965
+ "by_missing": {}, "items": []}
966
+ for nid, e in list((cg.index.get("nodes") or {}).items()):
967
+ if prefix and not str(nid).startswith(prefix):
968
+ continue
969
+ if layer and e.get("layer") != layer:
970
+ continue
971
+ if e.get("layer") in INTERNAL_LAYERS:
972
+ rep["skipped_internal"] += 1
973
+ continue
974
+ if not _readable_guard(cg, e):
975
+ rep["skipped_denied"] += 1
976
+ continue
977
+ fm, content = direct_read(cg, e)
978
+ if fm is None or crypto.is_encrypted(content):
979
+ rep["skipped_locked"] += 1
980
+ continue
981
+ if (e.get("layer") in SKIP_LAYERS
982
+ or any(t in SKIP_TAGS for t in (fm.get("tags") or []))):
983
+ rep["skipped_derived"] += 1
984
+ continue
985
+ rep["nodes_scanned"] += 1
986
+ if _has_ccg_line(content, "生效条件"):
987
+ rep["declared"] += 1
988
+ continue
989
+ if "生效条件" in derive_fields(fm, content):
990
+ # 有来源、只是还没接线 → 属于「待回填」,不是缺证据
991
+ rep["derivable"] += 1
992
+ continue
993
+ cs = fm.get("condition_space")
994
+ miss = nodefile.condition_space_missing(cs)
995
+ if not isinstance(cs, dict) or len(miss) == len(nodefile.CONDITION_SLOTS):
996
+ key = "无条件空间声明"
997
+ else:
998
+ key = "缺" + "+".join(_SLOT_LABEL.get(k, k) for k in miss)
999
+ rep["by_missing"][key] = rep["by_missing"].get(key, 0) + 1
1000
+ rep["pending"] += 1
1001
+ if limit is None or len(rep["items"]) < limit:
1002
+ rep["items"].append({
1003
+ "id": nid, "layer": e.get("layer"), "missing_slots": miss,
1004
+ "missing_text": key,
1005
+ "fallback": "补写生效条件;确实补不动 → 判 BLINDSPOT"})
1006
+ if limit is not None:
1007
+ rep["items"] = rep["items"][:limit]
1008
+ return rep
1009
+
1010
+
1011
+ # 生效条件:cg 的留痕日志中存在 basis 为 LEGACY_CONDITION_BASIS 且未被回滚的 backfill 生效条件写入时,按 node 记录最后一次的 after/original 返回;无匹配返回空。
1012
+ def _legacy_condition_records(cg) -> dict:
1013
+ """→ {node: {after, original, …}}:我们**自己写下的**单槽冒充行(真源 = 留痕)。
1014
+
1015
+ 只有留痕里 `basis == LEGACY_CONDITION_BASIS` 的行才敢自动改——人写下的
1016
+ 「观测位置:…」声明不在其列(宁可漏改,不可误改)。已被回滚的写入剔除;
1017
+ 同一节点多次写入时以最后一次为准。
1018
+ """
1019
+ log = list(read_jsonl(_log_path(cg)) or [])
1020
+ undone = {r.get("write_id") for r in log
1021
+ if r.get("action") == "backfill_rollback" and r.get("write_id")}
1022
+ out = {}
1023
+ for rec in log:
1024
+ if rec.get("action") != "backfill":
1025
+ continue
1026
+ if rec.get("write_id") and rec.get("write_id") in undone:
1027
+ continue
1028
+ f = (rec.get("fields") or {}).get("生效条件")
1029
+ if not isinstance(f, dict) or f.get("basis") != LEGACY_CONDITION_BASIS:
1030
+ continue
1031
+ nid = rec.get("node")
1032
+ if not nid:
1033
+ continue
1034
+ out[nid] = {"after": f.get("after"), "original": f.get("before"),
1035
+ "write_id": rec.get("write_id"), "batch": rec.get("batch")}
1036
+ return out
1037
+
1038
+
1039
+ # 生效条件:x 经 _as_cg,从 _legacy_condition_records 取候选,按 prefix 过滤,节点不存在/不可读/读取失败或加密分别计 missing/denied/locked;当前生效条件等于留痕 after 时,四槽合成非空则 rewrite 否则 drop,不等则 conflict;items 受 limit 限制;返回 dry_run rep。
1040
+ def fix_conditions_plan(x, prefix=None, limit=None) -> dict:
1041
+ """预演:清洗存量单槽冒充行。不写盘。
1042
+
1043
+ 逐条判定(都要求「当前值仍等于我们当初写入的值」,否则计 `conflict`、不碰):
1044
+ · 四槽齐备 → `rewrite`:改写为 `condition_space_text(cs)` 合成声明;
1045
+ · 四槽不全 → `drop`:删掉冒充行并登记待补。补不全的行留着比删掉更危险——
1046
+ 它会被当成生效条件读,等于把坐标的一维当成整条声明。
1047
+ """
1048
+ cg = _as_cg(x)
1049
+ rep = {"root": cg.root, "dry_run": True, "action": "fix_conditions",
1050
+ "prefix": prefix, "legacy": 0, "targeted": 0, "rewrite": 0,
1051
+ "drop": 0, "conflict": 0, "missing": 0, "skipped_locked": 0,
1052
+ "skipped_denied": 0, "items": []}
1053
+ for nid, rec in _legacy_condition_records(cg).items():
1054
+ if prefix and not str(nid).startswith(prefix):
1055
+ continue
1056
+ e = cg.index["nodes"].get(nid)
1057
+ if not e:
1058
+ rep["missing"] += 1
1059
+ continue
1060
+ if not _readable_guard(cg, e):
1061
+ rep["skipped_denied"] += 1
1062
+ continue
1063
+ fm, content = direct_read(cg, e)
1064
+ if fm is None or crypto.is_encrypted(content):
1065
+ rep["skipped_locked"] += 1
1066
+ continue
1067
+ rep["legacy"] += 1
1068
+ cur = _ccg_field(content, "生效条件") or ""
1069
+ if cur != (rec.get("after") or ""):
1070
+ rep["conflict"] += 1 # 已被后续改动 → 不碰
1071
+ continue
1072
+ new = _condition_text(fm)
1073
+ act = "rewrite" if new else "drop"
1074
+ rep["targeted"] += 1
1075
+ rep[act] += 1
1076
+ if limit is None or len(rep["items"]) < limit:
1077
+ rep["items"].append({
1078
+ "id": nid, "layer": e.get("layer"), "action": act,
1079
+ "before": cur, "after": new,
1080
+ "missing_slots": nodefile.condition_space_missing(
1081
+ fm.get("condition_space")),
1082
+ "comment_before": (_comment(fm) or {}).get("生效条件"),
1083
+ "comment_original": rec.get("original"),
1084
+ "entry_id": _entry_id(FIX_BATCH_DEFAULT, nid)})
1085
+ rep["planned_ids"] = [i["id"] for i in rep["items"]]
1086
+ return rep
1087
+
1088
+
1089
+ # 生效条件:x 经 _as_cg,batch 假值回落 FIX_BATCH_DEFAULT;先 fix_conditions_plan 得 items,按 ids/entry_ids 过滤;逐个再验当前值仍等于 before 且 comment_before 一致,否则 skipped_drift;rewrite 时 upsert 生效条件行并写 comment,drop 时删行并还原 comment;写盘记 condition_fix,drop 另记 condition_pending;limit 限制 rewritten+dropped;返回 rep。
1090
+ def fix_conditions_apply(x, ids=None, entry_ids=None, prefix=None, limit=None,
1091
+ batch=FIX_BATCH_DEFAULT, actor=None) -> dict:
1092
+ """执行清洗:`rewrite` 改写为四槽合成声明;`drop` 删行并登记待补。
1093
+
1094
+ 写盘与留痕同 `apply`:`_backfill.jsonl` 记 `condition_fix`;`drop` 另记
1095
+ `condition_pending`(待补台账的可追溯副本)。幂等:清洗后不再有候选行。
1096
+ """
1097
+ cg = _as_cg(x)
1098
+ batch = batch or FIX_BATCH_DEFAULT
1099
+ p = fix_conditions_plan(cg, prefix=prefix, limit=None)
1100
+ items = p["items"]
1101
+ if ids:
1102
+ want = set(ids)
1103
+ items = [i for i in items if i["id"] in want]
1104
+ if entry_ids:
1105
+ want = set(entry_ids)
1106
+ items = [i for i in items if i["entry_id"] in want]
1107
+ rep = {"root": cg.root, "dry_run": False, "action": "fix_conditions",
1108
+ "batch": batch, "actor": actor, "planned": len(items),
1109
+ "rewritten": 0, "dropped": 0, "pending_logged": 0,
1110
+ "skipped_drift": 0, "skipped_locked": 0, "skipped_denied": 0,
1111
+ "entry_ids": []}
1112
+ for it in items:
1113
+ if limit is not None and (rep["rewritten"] + rep["dropped"]) >= limit:
1114
+ break
1115
+ nid = it["id"]
1116
+ e = cg.index["nodes"].get(nid)
1117
+ if not e:
1118
+ rep["skipped_drift"] += 1
1119
+ continue
1120
+ fm, content = direct_read(cg, e)
1121
+ if fm is None or crypto.is_encrypted(content):
1122
+ rep["skipped_locked"] += 1
1123
+ continue
1124
+ # 预演 → 执行之间可能被改动:当前值必须仍等于我们当初写入的值
1125
+ cur = _ccg_field(content, "生效条件")
1126
+ comment_before = (_comment(fm) or {}).get("生效条件")
1127
+ if (cur or "") != (it["before"] or "") \
1128
+ or comment_before != it["comment_before"]:
1129
+ rep["skipped_drift"] += 1
1130
+ continue
1131
+ comment = _ensure_comment(fm)
1132
+ if it["action"] == "rewrite":
1133
+ content = _upsert_ccg_line(content, "生效条件", it["after"])
1134
+ comment["生效条件"] = it["after"]
1135
+ else:
1136
+ content = _remove_ccg_line(content, "生效条件")
1137
+ # comment 里那份是同一污染的副本 → 还原为**写入前**的原值(真逆操作)
1138
+ orig = it["comment_original"]
1139
+ if orig in (None, ""):
1140
+ comment.pop("生效条件", None)
1141
+ else:
1142
+ comment["生效条件"] = orig
1143
+ st = fm.get("state_attributes")
1144
+ if isinstance(st, dict) and isinstance(st.get("comment"), dict) \
1145
+ and not st["comment"]:
1146
+ st.pop("comment", None)
1147
+ cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
1148
+ durable=True)
1149
+ append_jsonl(_log_path(cg), {
1150
+ "action": "condition_fix", "ts": time.time(), "batch": batch,
1151
+ "actor": actor, "entry_id": it["entry_id"],
1152
+ "write_id": _sha(f"cond_fix|{nid}|{time.time()}"),
1153
+ "node": nid, "layer": e.get("layer"), "fix": it["action"],
1154
+ "fields": {"生效条件": {
1155
+ "before": it["before"], "after": it["after"],
1156
+ "basis": BASIS_CONDITION_SYNTH if it["action"] == "rewrite"
1157
+ else "dropped:legacy_position"}},
1158
+ "comment_before": comment_before,
1159
+ "comment_original": it["comment_original"],
1160
+ "missing_slots": it["missing_slots"],
1161
+ "content_hash_after": _sha(content)})
1162
+ if it["action"] == "rewrite":
1163
+ rep["rewritten"] += 1
1164
+ else:
1165
+ rep["dropped"] += 1
1166
+ append_jsonl(_log_path(cg), {
1167
+ "action": "condition_pending", "ts": time.time(),
1168
+ "batch": batch, "actor": actor, "node": nid,
1169
+ "layer": e.get("layer"), "missing_slots": it["missing_slots"],
1170
+ "reason": "四槽不可合成:单槽冒充行已删除,等待后续补充;"
1171
+ "确实补不动则判 BLINDSPOT"})
1172
+ rep["pending_logged"] += 1
1173
+ rep["entry_ids"].append(it["entry_id"])
1174
+ if rep["rewritten"] or rep["dropped"]:
1175
+ cg.rebuild_index()
1176
+ rep["plan_remaining"] = max(0, p["targeted"] - len(items))
1177
+ return rep
1178
+
1179
+
1180
+ # 生效条件:x 经 _as_cg,读取日志中 action=condition_fix 且未回滚的记录,按 batch/entry_ids 过滤,节点存在且当前生效条件等于 after 时,还原 before(空则删行)并还原 comment_before,否则计 conflict/missing;返回 rep。
1181
+ def fix_conditions_rollback(x, batch=None, entry_ids=None, actor=None) -> dict:
1182
+ """按留痕反向应用:恢复被改写的旧值 / 重建被删除的冒充行。
1183
+
1184
+ 与 `rollback` 同一条纪律:**只在当前值仍等于写入值**时撤销,
1185
+ 否则计 `conflict` 跳过(防覆盖后续人工修改)。
1186
+ """
1187
+ cg = _as_cg(x)
1188
+ want = set(entry_ids) if entry_ids else None
1189
+ rep = {"root": cg.root, "action": "fix_conditions_rollback", "actor": actor,
1190
+ "batch": batch, "reverted": 0, "conflict": 0, "missing": 0,
1191
+ "skipped_done": 0}
1192
+ log = list(read_jsonl(_log_path(cg)) or [])
1193
+ done = {r.get("write_id") for r in log
1194
+ if r.get("action") == "fix_conditions_rollback" and r.get("write_id")}
1195
+ for rec in log:
1196
+ if rec.get("action") != "condition_fix":
1197
+ continue
1198
+ if rec.get("write_id") and rec.get("write_id") in done:
1199
+ rep["skipped_done"] += 1
1200
+ continue
1201
+ if batch and rec.get("batch") != batch:
1202
+ continue
1203
+ if want is not None and rec.get("entry_id") not in want:
1204
+ continue
1205
+ nid = rec.get("node")
1206
+ e = cg.index["nodes"].get(nid)
1207
+ if not e:
1208
+ rep["missing"] += 1
1209
+ continue
1210
+ fm, content = direct_read(cg, e)
1211
+ if fm is None:
1212
+ rep["missing"] += 1
1213
+ continue
1214
+ d = (rec.get("fields") or {}).get("生效条件") or {}
1215
+ cur = _ccg_field(content, "生效条件") or ""
1216
+ if cur != (d.get("after") or ""):
1217
+ rep["conflict"] += 1 # 已被后续改动 → 不撤销
1218
+ continue
1219
+ before = d.get("before")
1220
+ if before in (None, ""):
1221
+ content = _remove_ccg_line(content, "生效条件")
1222
+ else:
1223
+ content = _upsert_ccg_line(content, "生效条件", before)
1224
+ comment = _ensure_comment(fm)
1225
+ cb = rec.get("comment_before")
1226
+ if cb in (None, ""):
1227
+ comment.pop("生效条件", None)
1228
+ else:
1229
+ comment["生效条件"] = cb
1230
+ st = fm.get("state_attributes")
1231
+ if isinstance(st, dict) and isinstance(st.get("comment"), dict) \
1232
+ and not st["comment"]:
1233
+ st.pop("comment", None)
1234
+ cg._write_node(nid, os.path.join(cg.root, e["path"]), fm, content,
1235
+ durable=True)
1236
+ append_jsonl(_log_path(cg), {
1237
+ "action": "fix_conditions_rollback", "ts": time.time(),
1238
+ "actor": actor, "batch": rec.get("batch"),
1239
+ "entry_id": rec.get("entry_id"), "write_id": rec.get("write_id"),
1240
+ "node": nid, "restored": before})
1241
+ rep["reverted"] += 1
1242
+ if rep["reverted"]:
1243
+ cg.rebuild_index()
1244
+ return rep
1245
+
1246
+
1247
+ # 生效条件:x 经 _as_cg,遍历 nodes 按 prefix 过滤、内部层跳过,读取失败或加密跳过;对每个节点当前生效条件行,缺失计 absent,否则按 is_legacy_position_condition、等于 _condition_text 合成、等于 comment、其他分别计数,legacy_ids 受 limit 限制;返回 rep。
1248
+ def verify_conditions(x, prefix=None, limit=None) -> dict:
1249
+ """复算核对(只读):生效条件行的来源分布 + 弱等价残留计数。
1250
+
1251
+ `legacy_position` 必须为 **0**——这是本轮口径修正的验收指标:
1252
+ 「观测位置:X」单槽冒充行不得再出现在任何节点里。
1253
+ """
1254
+ cg = _as_cg(x)
1255
+ rep = {"root": cg.root, "dry_run": True, "action": "verify_conditions",
1256
+ "prefix": prefix, "nodes_scanned": 0, "absent": 0, "declared": 0,
1257
+ "from_synthesis": 0, "from_comment": 0, "legacy_position": 0,
1258
+ "other": 0, "by_prefix": {}, "legacy_ids": []}
1259
+ for nid, e in list((cg.index.get("nodes") or {}).items()):
1260
+ if prefix and not str(nid).startswith(prefix):
1261
+ continue
1262
+ if e.get("layer") in INTERNAL_LAYERS:
1263
+ continue
1264
+ fm, content = direct_read(cg, e)
1265
+ if fm is None or crypto.is_encrypted(content):
1266
+ continue
1267
+ rep["nodes_scanned"] += 1
1268
+ cur = _ccg_field(content, "生效条件")
1269
+ if not cur:
1270
+ rep["absent"] += 1
1271
+ kind = "absent"
1272
+ else:
1273
+ rep["declared"] += 1
1274
+ synth = _condition_text(fm)
1275
+ cmt = _as_text(_comment(fm).get("生效条件"))
1276
+ if nodefile.is_legacy_position_condition(cur):
1277
+ rep["legacy_position"] += 1
1278
+ kind = "legacy_position"
1279
+ if limit is None or len(rep["legacy_ids"]) < limit:
1280
+ rep["legacy_ids"].append(nid)
1281
+ elif synth and cur == synth:
1282
+ rep["from_synthesis"] += 1
1283
+ kind = "from_synthesis"
1284
+ elif cmt and cur == cmt:
1285
+ rep["from_comment"] += 1
1286
+ kind = "from_comment"
1287
+ else:
1288
+ rep["other"] += 1
1289
+ kind = "other"
1290
+ box = rep["by_prefix"].setdefault(str(nid).split("_")[0], {})
1291
+ box[kind] = box.get(kind, 0) + 1
1292
+ return rep
1293
+
1294
+
1295
+ # ---- 统一入口 ------------------------------------------------------------
1296
+
1297
+ ACTIONS = ("backfill", "backfill_rollback", "backfill_history",
1298
+ "cap", "cap_rollback", "cap_history",
1299
+ "exempt", "exempt_rollback", "exempt_history")
1300
+
1301
+
1302
+ # 生效条件:按其 action 分派——action=='backfill' 时 kw['apply'] 为真调 apply(x, 去掉 apply 的 kw)、否则调 plan 同参;action=='cap'/'exempt' 同理在 kw['apply'] 为真时调 cap_apply/exempt_apply、否则调 cap_plan/exempt_plan;action=='backfill_rollback'/'cap_rollback'/'exempt_rollback' 分别调 rollback/cap_rollback/exempt_rollback(x, **kw);action=='backfill_history' 调 history(x, **kw),'cap_history'/'exempt_history' 调 history(x, action='cap'/'exempt', **kw);其余 action 值抛 ValueError。
1303
+ def run(x, action, **kw) -> dict:
1304
+ """`maintain` op 的分派入口:action ∈ ACTIONS。"""
1305
+ if action == "backfill":
1306
+ if kw.get("apply"):
1307
+ return apply(x, **{k: v for k, v in kw.items() if k != "apply"})
1308
+ return plan(x, **{k: v for k, v in kw.items() if k != "apply"})
1309
+ if action == "backfill_rollback":
1310
+ return rollback(x, **kw)
1311
+ if action == "backfill_history":
1312
+ return history(x, **kw)
1313
+ if action == "cap":
1314
+ if kw.get("apply"):
1315
+ return cap_apply(x, **{k: v for k, v in kw.items() if k != "apply"})
1316
+ return cap_plan(x, **{k: v for k, v in kw.items() if k != "apply"})
1317
+ if action == "cap_rollback":
1318
+ return cap_rollback(x, **kw)
1319
+ if action == "cap_history":
1320
+ return history(x, action="cap", **kw)
1321
+ if action == "exempt":
1322
+ if kw.get("apply"):
1323
+ return exempt_apply(x, **{k: v for k, v in kw.items() if k != "apply"})
1324
+ return exempt_plan(x, **{k: v for k, v in kw.items() if k != "apply"})
1325
+ if action == "exempt_rollback":
1326
+ return exempt_rollback(x, **kw)
1327
+ if action == "exempt_history":
1328
+ return history(x, action="exempt", **kw)
1329
1329
  raise ValueError(f"未知 backfill action:{action}(允许:{ACTIONS})")