@furongjun1999/dsh-memory 0.4.11 → 0.5.0
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.
- package/README.md +16 -16
- package/codebuddy/CODEBUDDY.md +11 -3
- package/codebuddy/README.md +92 -90
- package/codebuddy/mcp.json +27 -27
- package/docs/GBrain/345/217/257/345/200/237/351/211/264/347/202/271_/347/201/265/346/236/242/350/220/275/347/202/271/344/272/244/346/216/245_20260919.md +169 -169
- package/docs/Pi/345/217/257/345/255/246/344/271/240/344/274/230/347/202/271_/347/201/265/346/236/242/345/244/247/350/204/221/346/224/271/350/277/233/344/272/244/346/216/245_20260915.md +144 -144
- package/docs/README.md +142 -111
- package/docs/discipline/harnesses.yaml +244 -226
- package/docs/discipline/templates/full.md.tmpl +61 -61
- package/docs/discipline/templates/rules.mdc.tmpl +68 -0
- package/docs/discipline/templates/skill.md.tmpl +23 -23
- package/docs/eval/AGI/344/270/203/347/273/264/350/257/204/345/210/206/346/212/245/345/221/212_md_cg_v1.0.md +299 -299
- package/docs/eval/AGI/344/270/203/347/273/264/350/257/204/345/210/206/346/212/245/345/221/212_md_cg_v2.0.md +239 -239
- package/docs/eval//345/256/236/351/252/214/346/226/271/346/241/210_/345/255/246/344/271/240/351/227/255/347/216/257AB/344/270/216/346/250/252/350/257/204_v1.0.md +174 -174
- package/docs/eval//346/250/252/350/257/204_/345/205/255/345/256/266100/351/242/230/344/270/255/350/213/261/345/217/214/346/237/245_v1.0.md +223 -223
- package/docs/{mdcg → hive}//344/273/244/347/211/214/344/270/216/350/247/222/350/211/262/346/235/203/350/201/214/345/210/206/347/246/273_v0.1.md +165 -160
- package/docs/hive//344/273/244/347/211/214/350/257/255/344/271/211/344/277/256/346/255/243_/344/273/262/350/243/201/344/275/215_v0.1.md +76 -0
- package/docs/{mdcg → hive}//345/255/220/344/273/243/347/220/206/351/205/215/347/275/256/346/240/207/345/207/206_v0.5.md +236 -236
- package/docs/hive//346/243/200/347/264/242/346/224/266/346/225/233/345/256/236/346/265/213/344/270/216S1b/350/256/276/350/256/241_v0.1.md +43 -43
- package/docs/hive//346/243/200/347/264/242/347/256/227/346/263/225/345/217/243/345/276/204/345/257/271/347/205/247_v0.1.md +85 -0
- package/docs/hive//346/243/200/347/264/242/350/267/257/345/276/204/344/270/216/350/256/244/347/237/245/347/273/223/346/236/204/345/245/221/347/272/246_v0.1.md +102 -102
- package/docs/hive//350/234/202/345/267/242M6_ingest/345/256/236/346/226/275/350/256/241/345/210/222_v0.1.md +47 -0
- package/docs/hive//350/234/202/345/267/242/345/217/214/345/256/236/344/276/213/344/272/222/351/252/214_/350/256/276/350/256/241/345/256/232/347/250/277.md +503 -503
- package/docs/hive//350/234/202/345/267/242/345/267/245/344/275/234/350/256/260/345/277/206_/351/241/271/347/233/256/350/256/241/345/210/222.md +85 -85
- package/docs/hive//350/234/202/345/267/242/350/256/276/350/256/241_/347/220/206/350/256/272/345/257/271/351/275/220_v0.1.md +191 -0
- package/docs/hive//350/234/202/345/267/242/350/277/255/344/273/243_/345/256/217/350/247/202/344/270/216/347/276/244/344/275/223/350/260/203/345/272/246_v0.1.md +90 -0
- package/docs/mdcg/D_meta_/345/267/245/347/250/213/345/214/226/346/226/271/346/241/210_v0.2.md +216 -216
- package/docs/mdcg/README/350/257/246/347/273/206/347/211/210_v0.4.10.md +646 -646
- package/docs/mdcg/lingshu_tutorial.html +14449 -14449
- package/docs/mdcg/release_v0.4.11.md +49 -0
- package/docs/mdcg/release_v0.4.5.md +55 -55
- package/docs/mdcg/tool_table_v0.3.0.md +117 -117
- package/docs/mdcg//345/205/250/345/272/223/344/273/243/347/240/201/350/257/204/345/256/241/344/270/216/346/235/241/344/273/266/345/214/226/346/263/250/351/207/212_/350/256/241/345/210/222_v0.1.md +600 -600
- package/docs/mdcg//345/212/237/350/203/275/350/260/203/347/224/250/346/230/240/345/260/204/350/241/250_v0.1.md +40 -40
- package/docs/mdcg//345/215/225/345/205/203/350/207/252/346/210/221/351/224/232/347/202/271_/347/263/273/347/273/237/346/217/220/347/244/272/350/257/215/346/240/207/345/207/206_v0.3.md +275 -275
- package/docs/mdcg//345/217/221/345/270/203/351/227/250/347/246/201/351/223/276_v0.1.md +54 -0
- package/docs/mdcg//346/272/220/347/240/201/347/272/247/346/236/266/346/236/204/345/256/241/350/256/241_GPT/346/211/271/350/257/204/345/257/271/347/205/247_v1.0.md +130 -130
- package/docs/mdcg//347/201/265/346/236/24282/345/267/245/345/205/267_/345/212/237/350/203/275/346/225/264/347/220/206/344/270/216/350/277/201/347/247/273/346/230/240/345/260/204_v0.1.md +278 -278
- package/docs/mdcg//347/201/265/346/236/242/350/256/260/345/277/206/345/212/250/350/257/215/345/215/217/350/256/256_v1.0-draft.md +172 -172
- package/docs/mdcg//347/274/272/345/217/243/345/215/225_P0/346/224/266/345/217/243_v0.1.md +270 -270
- package/docs/mdcg//350/256/244/347/237/245/345/233/276_G4-G8/347/274/272/345/217/243/350/243/201/345/256/232/345/215/225_v0.1.md +491 -491
- package/docs/mdcg//350/256/244/347/237/245/345/233/276_/346/235/241/344/273/266/347/251/272/351/227/264/345/220/210/346/210/220/344/270/216/347/224/237/346/225/210/346/235/241/344/273/266/345/217/243/345/276/204_v0.1.md +340 -340
- package/docs/mdcg//350/256/244/347/237/245/345/233/276_/347/264/242/345/274/225/344/270/216/345/267/245/347/250/213/350/247/204/350/214/203/345/214/226_/350/256/241/345/210/222_v0.1.md +588 -588
- package/docs/plans/GridWorld/346/234/200/345/260/217/351/227/255/347/216/257/350/247/204/346/240/274_v0.1.md +176 -176
- package/docs/plans//345/221/275/345/220/215/346/262/273/347/220/206_/351/241/271/347/233/256/350/256/241/345/210/222.md +81 -81
- package/docs/swarm//350/234/202/347/276/244/344/272/222/350/201/224_v0.1.md +704 -704
- package/docs/swarm//350/234/202/347/276/244/345/220/214/351/224/231/346/243/200/346/265/213/345/256/236/351/252/214/345/215/217/350/256/256_v0.1.md +242 -242
- package/docs/theory//345/215/225/347/272/277/347/250/213/344/270/216/346/263/250/346/204/217/345/212/233/351/233/206/344/270/255_/346/227/240/344/272/211/350/256/256/347/220/206/350/256/272/346/226/207/346/241/243_v1.0.md +129 -129
- package/docs/theory//345/271/266/345/217/221/345/277/205/347/204/266/346/200/247/347/220/206/350/256/272_v0.2.md +134 -134
- package/docs/theory//346/231/272/350/203/275/350/256/2723.4.md +5260 -5260
- package/docs/theory//346/246/202/345/277/265/345/210/206/345/261/202/345/257/271/351/275/220/350/241/250_v0.1.md +145 -145
- package/docs/theory//347/220/206/350/256/272_/346/234/272/345/210/266_/344/273/243/347/240/201_/345/256/236/351/252/214_/347/274/272/345/217/243/347/237/251/351/230/265_v0.1.md +144 -144
- package/docs/theory//347/220/206/350/256/272/344/273/223/346/213/206/345/210/206/344/270/216/347/231/275/347/256/261/347/237/245/350/257/206/345/272/223/345/206/205/350/277/201_v0.1.md +198 -198
- package/docs/theory//350/256/244/347/237/245/344/273/243/347/220/206/344/270/216/346/224/266/346/225/233/347/273/223/346/236/204_/346/235/241/344/273/266/350/256/272/351/207/215/346/236/204_v0.1.md +221 -221
- package/docs/world_model//344/270/226/347/225/214/346/250/241/345/236/213_/347/245/236/347/273/217/347/275/221/347/273/234/345/272/225/345/261/202/346/236/266/346/236/204_v1.0.md +237 -237
- package/docs//345/217/221/345/270/203/344/273/266/345/233/236/346/272/257/350/257/264/346/230/216_v0.1.md +82 -82
- 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 +28 -2
- package/dsh/README.md +82 -82
- package/dsh/cordis.yml.example +139 -139
- package/dsh/update-lingshu.bat +11 -11
- package/lib/hooks.js +36 -2
- package/lib/lib/roleplay_web.js +427 -427
- package/md_cg/__init__.py +7 -7
- package/md_cg/audit.py +368 -368
- package/md_cg/autonomy.py +287 -287
- package/md_cg/backfill.py +1327 -1327
- package/md_cg/backfill_bigdomain.py +34 -34
- package/md_cg/bench6_arms.py +410 -410
- package/md_cg/bench6_common.py +230 -230
- package/md_cg/bench6_competitors.py +212 -212
- package/md_cg/bench_axis_domain.py +257 -257
- package/md_cg/bench_blind_comp.py +308 -308
- package/md_cg/bench_en_atoms_public.py +230 -230
- package/md_cg/bench_governance.py +348 -348
- package/md_cg/bench_lme_zh.py +410 -410
- package/md_cg/bench_locomo.py +121 -121
- package/md_cg/bench_locomo_zh.py +450 -450
- package/md_cg/bench_locomo_zh_public.py +147 -147
- package/md_cg/bench_longmem.py +112 -112
- package/md_cg/bench_membench.py +632 -632
- package/md_cg/bench_p0.py +149 -149
- package/md_cg/bench_progressive.py +287 -287
- package/md_cg/bench_role_views.py +238 -238
- package/md_cg/bench_task_ab.py +243 -243
- package/md_cg/bench_task_ab_llm.py +408 -408
- package/md_cg/bench_unified_en.py +204 -204
- package/md_cg/bench_zh_mad.py +601 -601
- package/md_cg/blindspot_tickets.py +123 -123
- package/md_cg/branches.py +285 -285
- package/md_cg/build_postings.py +73 -73
- package/md_cg/ccgc.py +1005 -948
- package/md_cg/census.py +132 -132
- package/md_cg/chain.py +300 -300
- package/md_cg/codeindex.py +531 -531
- package/md_cg/coldverify.py +292 -292
- package/md_cg/comment_gate.py +337 -337
- package/md_cg/cond_compose.py +190 -190
- package/md_cg/cond_facts.py +154 -154
- package/md_cg/cond_template.json +106 -106
- package/md_cg/condition_anchor.py +142 -142
- package/md_cg/conformance.py +726 -726
- package/md_cg/consistency.py +717 -717
- package/md_cg/consolidate.py +1536 -1439
- package/md_cg/corpus.py +110 -110
- package/md_cg/crosscheck.py +1097 -1097
- package/md_cg/crypto.py +437 -437
- package/md_cg/d_meta.py +310 -310
- package/md_cg/datapath.py +334 -334
- package/md_cg/docindex.py +473 -473
- package/md_cg/eval_common.py +575 -575
- package/md_cg/evidence.py +580 -580
- package/md_cg/evolution.py +477 -477
- package/md_cg/export.py +220 -220
- package/md_cg/forgetting.py +581 -581
- package/md_cg/fsutil.py +329 -329
- package/md_cg/hotcache.py +238 -214
- package/md_cg/hyperedge.py +251 -251
- package/md_cg/identity.py +390 -390
- package/md_cg/insight.py +500 -500
- package/md_cg/interop.py +199 -0
- package/md_cg/lexicon/build_cedict_en_zh.py +329 -329
- package/md_cg/lexicon/build_standard_en.py +171 -171
- package/md_cg/lexicon/expand_en_zh.py +211 -211
- package/md_cg/lifecycle.py +272 -272
- package/md_cg/linkref.py +280 -280
- package/md_cg/links.py +622 -622
- package/md_cg/mcp_server.py +129 -32
- package/md_cg/md_whitebox.py +345 -345
- package/md_cg/mdcg.py +176 -117
- package/md_cg/mdcos.py +79 -13
- package/md_cg/metacognition.py +591 -591
- package/md_cg/migrate.py +119 -119
- package/md_cg/migrate_aeis.py +221 -221
- package/md_cg/migrate_roleplay.py +293 -293
- package/md_cg/migrate_wisdom_graph.py +360 -360
- package/md_cg/mreview/__init__.py +25 -25
- package/md_cg/mreview/__main__.py +110 -110
- package/md_cg/mreview/bundle.py +178 -178
- package/md_cg/mreview/candidates.py +262 -262
- package/md_cg/mreview/govern.py +693 -693
- package/md_cg/mreview/locate.py +939 -939
- package/md_cg/mreview/pipeline.py +728 -728
- package/md_cg/mreview/rules/duplication.json +21 -21
- package/md_cg/mreview/rules/field_coverage.json +54 -54
- package/md_cg/mreview/rules/source_license.json +21 -21
- package/md_cg/mreview/rules/template_flow.json +21 -21
- package/md_cg/mreview/ruleset.py +252 -252
- package/md_cg/nodefile.py +575 -575
- package/md_cg/pooling.py +484 -472
- package/md_cg/postings.py +298 -298
- package/md_cg/predict.py +1100 -1100
- package/md_cg/progressive.py +123 -123
- package/md_cg/protect.py +272 -272
- package/md_cg/protocol/md_cg_gate.proto +33 -33
- package/md_cg/protocol.py +372 -372
- package/md_cg/provenance.py +582 -582
- package/md_cg/reach.py +453 -453
- package/md_cg/readcache.py +85 -0
- package/md_cg/refindex.py +833 -833
- package/md_cg/refine.py +604 -604
- package/md_cg/roleviews.py +89 -89
- package/md_cg/routing.py +365 -365
- package/md_cg/scrub.py +852 -852
- package/md_cg/security.py +274 -274
- package/md_cg/self_state.py +1029 -1029
- package/md_cg/selfreport.py +151 -151
- package/md_cg/semantic/__init__.py +10 -10
- package/md_cg/semantic/canonical.py +122 -122
- package/md_cg/semantic/en_normalizer.py +364 -364
- package/md_cg/semantic/en_zh_map.json +28694 -0
- package/md_cg/semantic/export_en_zh_map.py +64 -0
- package/md_cg/semantic/unify.py +45 -0
- package/md_cg/semantic/zh_en_atoms.py +139 -139
- package/md_cg/signer.py +562 -562
- package/md_cg/sources.py +815 -582
- package/md_cg/statushdr.py +179 -179
- package/md_cg/stg.py +48 -37
- package/md_cg/subgraph.py +729 -729
- package/md_cg/sustain.py +1138 -1138
- package/md_cg/tasks.py +470 -470
- package/md_cg/test_action_derive.py +203 -203
- package/md_cg/test_audit_rotate.py +270 -270
- package/md_cg/test_autonomy.py +143 -143
- package/md_cg/test_bench_governance.py +102 -102
- package/md_cg/test_blindspot_tickets.py +166 -166
- package/md_cg/test_branches.py +249 -249
- package/md_cg/test_ccg_perturb.py +184 -184
- package/md_cg/test_ccgc.py +433 -433
- package/md_cg/test_census_prune.py +81 -81
- package/md_cg/test_cond_compose_anchors.py +76 -76
- package/md_cg/test_cond_match.py +165 -165
- package/md_cg/test_condition_anchor.py +81 -81
- package/md_cg/test_d_meta.py +412 -412
- package/md_cg/test_datapath_root.py +199 -199
- package/md_cg/test_en_pipeline.py +166 -166
- package/md_cg/test_gain_gate.py +212 -212
- package/md_cg/test_health_scale.py +173 -173
- package/md_cg/test_hive_ingest.py +285 -0
- package/md_cg/test_hot_cold.py +215 -215
- package/md_cg/test_hyperedge.py +245 -245
- package/md_cg/test_i26_empty_first_write.py +116 -0
- package/md_cg/test_i27_e041_identity.py +128 -0
- package/md_cg/test_i28_hotcache_prodpath.py +122 -0
- package/md_cg/test_identity_attribution.py +147 -147
- package/md_cg/test_index_durability.py +224 -224
- package/md_cg/test_interop.py +93 -0
- package/md_cg/test_lifecycle.py +309 -309
- package/md_cg/test_linkref.py +306 -306
- package/md_cg/test_lock.py +43 -43
- package/md_cg/test_md_access_parity.py +255 -255
- package/md_cg/test_md_writepath.py +345 -345
- package/md_cg/test_mdstore_search_parity.py +160 -0
- package/md_cg/test_mr_m2.py +587 -587
- package/md_cg/test_mr_m3.py +710 -710
- package/md_cg/test_mr_m4.py +485 -485
- package/md_cg/test_p0.py +250 -250
- package/md_cg/test_p1.py +316 -316
- package/md_cg/test_p10_identity.py +173 -173
- package/md_cg/test_p11_consistency.py +233 -233
- package/md_cg/test_p12_metacognition.py +212 -212
- package/md_cg/test_p13_encryption.py +241 -241
- package/md_cg/test_p14_sustain.py +249 -249
- package/md_cg/test_p15_scrub.py +280 -280
- package/md_cg/test_p16_self_state.py +301 -301
- package/md_cg/test_p17_predict.py +354 -354
- package/md_cg/test_p18_whitebox.py +171 -171
- package/md_cg/test_p19_migrate_roleplay.py +149 -149
- package/md_cg/test_p20_evolution.py +315 -315
- package/md_cg/test_p21_tokens.py +293 -270
- package/md_cg/test_p22_theory.py +175 -175
- package/md_cg/test_p23_links.py +311 -311
- package/md_cg/test_p24_evidence.py +227 -227
- package/md_cg/test_p25_weights.py +156 -156
- package/md_cg/test_p26_refindex.py +416 -416
- package/md_cg/test_p27_docindex.py +765 -765
- package/md_cg/test_p28_refcheck.py +305 -305
- package/md_cg/test_p29_session_ingest_export.py +354 -333
- package/md_cg/test_p3.py +11 -2
- package/md_cg/test_p30_maintain.py +330 -330
- package/md_cg/test_p31_insight.py +534 -534
- package/md_cg/test_p32_backfill.py +298 -298
- package/md_cg/test_p33_ccg_wiring.py +293 -293
- package/md_cg/test_p34_crosscheck.py +331 -331
- package/md_cg/test_p35_conditioned_claim.py +252 -252
- package/md_cg/test_p36_kp_align.py +230 -230
- package/md_cg/test_p37_condition_space.py +248 -248
- package/md_cg/test_p38_concurrent_flush.py +102 -0
- package/md_cg/test_p38_contextualize.py +273 -273
- package/md_cg/test_p39_verify_flow.py +113 -0
- package/md_cg/test_p39_vision_evidence.py +369 -369
- package/md_cg/test_p40_refine_worklist.py +241 -241
- package/md_cg/test_p41_evolve_patrol.py +224 -224
- package/md_cg/test_p42_provenance.py +269 -269
- package/md_cg/test_p43_pooling.py +412 -398
- package/md_cg/test_p44_md_whitebox.py +231 -231
- package/md_cg/test_p45_session_identity.py +219 -219
- package/md_cg/test_p46_unit_scope.py +272 -272
- package/md_cg/test_p47_session_view.py +281 -0
- package/md_cg/test_p4_fuzzy.py +223 -223
- package/md_cg/test_p5_semantic.py +226 -226
- package/md_cg/test_p6_consolidate.py +440 -387
- package/md_cg/test_p7_goals_recent.py +202 -202
- package/md_cg/test_p8_subgraph_chain.py +200 -200
- package/md_cg/test_p9_forget_protect.py +231 -231
- package/md_cg/test_predict_beta.py +135 -135
- package/md_cg/test_preflight_failclosed.py +100 -100
- package/md_cg/test_progressive.py +146 -146
- package/md_cg/test_protocol.py +243 -243
- package/md_cg/test_reach.py +378 -378
- package/md_cg/test_reach_keys.py +201 -201
- package/md_cg/test_read_clip.py +141 -141
- package/md_cg/test_readcache_prodpath.py +155 -0
- package/md_cg/test_retr_gates_prodpath.py +140 -0
- package/md_cg/test_retr_s1.py +340 -340
- package/md_cg/test_retr_s1b.py +209 -209
- package/md_cg/test_retr_s3.py +194 -194
- package/md_cg/test_retr_s4.py +163 -163
- package/md_cg/test_retr_s5.py +200 -200
- package/md_cg/test_retr_s6.py +157 -157
- package/md_cg/test_retr_s7.py +384 -384
- package/md_cg/test_retr_s8_time.py +369 -316
- package/md_cg/test_retr_s9_edges.py +286 -286
- package/md_cg/test_retr_s9_entity_ctx.py +175 -175
- package/md_cg/test_review_conformance.py +367 -367
- package/md_cg/test_role_views.py +354 -354
- package/md_cg/test_sem_noise.py +242 -242
- package/md_cg/test_semantic_canonical.py +241 -241
- package/md_cg/test_subproc_encoding.py +192 -192
- package/md_cg/test_sustain_mutual.py +153 -153
- package/md_cg/test_tasks.py +409 -409
- package/md_cg/test_tool_face.py +189 -189
- package/md_cg/test_transfer.py +180 -180
- package/md_cg/test_trust.py +361 -361
- package/md_cg/test_twophase.py +286 -286
- package/md_cg/test_v14_fixes.py +397 -397
- package/md_cg/test_validity_filter.py +280 -280
- package/md_cg/test_verify_answer.py +138 -138
- package/md_cg/test_wisdom_md_store.py +292 -292
- package/md_cg/test_writelimit.py +197 -197
- package/md_cg/test_writepipe.py +214 -214
- package/md_cg/theory.py +273 -273
- package/md_cg/tokens.py +677 -663
- package/md_cg/tool_face.py +260 -260
- package/md_cg/trust.py +986 -950
- package/md_cg/twophase.py +231 -231
- package/md_cg/units.py +667 -667
- package/md_cg/vision_evidence.py +666 -666
- package/md_cg/weights.py +624 -624
- package/md_cg/whitebox.py +527 -527
- package/md_cg/whitebox_kb/__init__.py +37 -37
- package/md_cg/whitebox_kb/aeis_core/__init__.py +42 -42
- package/md_cg/whitebox_kb/aeis_core/semantic.py +280 -280
- package/md_cg/whitebox_kb/aeis_core/textutil.py +13 -13
- package/md_cg/whitebox_kb/engine.py +310 -310
- package/md_cg/whitebox_kb/seed_knowledge//346/231/272/350/203/275/350/256/2723.4.md +5260 -5260
- package/md_cg/whitebox_kb/wisdom/browser_units.py +2631 -2631
- package/md_cg/whitebox_kb/wisdom/causal_discover.py +432 -432
- package/md_cg/whitebox_kb/wisdom/chat_engine.py +1506 -1506
- package/md_cg/whitebox_kb/wisdom/code_solidified.json +6195 -6195
- package/md_cg/whitebox_kb/wisdom/compiler_code_units.py +3033 -3033
- package/md_cg/whitebox_kb/wisdom/condition_algebra.py +112 -112
- package/md_cg/whitebox_kb/wisdom/condition_frame.py +315 -315
- package/md_cg/whitebox_kb/wisdom/condition_kb.py +108 -108
- package/md_cg/whitebox_kb/wisdom/conflict_map.json +4445 -4445
- package/md_cg/whitebox_kb/wisdom/core/lexer.py +512 -512
- package/md_cg/whitebox_kb/wisdom/core/name_checker.py +1023 -1023
- package/md_cg/whitebox_kb/wisdom/cspmn.py +258 -258
- package/md_cg/whitebox_kb/wisdom/csre.py +264 -264
- package/md_cg/whitebox_kb/wisdom/danmaku_audit.py +252 -252
- package/md_cg/whitebox_kb/wisdom/distilled_condition_units.json +6417 -6417
- package/md_cg/whitebox_kb/wisdom/docs/WB-EVAL-20260902b.json +1950 -1950
- package/md_cg/whitebox_kb/wisdom/docs/WB-EVAL-20260902c.json +1296 -1296
- package/md_cg/whitebox_kb/wisdom/docs/whitebox_capability_graph_demo.json +59 -59
- package/md_cg/whitebox_kb/wisdom/graph_db_units.py +3089 -3089
- package/md_cg/whitebox_kb/wisdom/knowledge_points.py +318 -318
- package/md_cg/whitebox_kb/wisdom/md_access.py +470 -470
- package/md_cg/whitebox_kb/wisdom/md_store.py +276 -251
- package/md_cg/whitebox_kb/wisdom/migrate_wisdom.py +476 -476
- package/md_cg/whitebox_kb/wisdom/navigate.py +248 -248
- package/md_cg/whitebox_kb/wisdom/neural_retrieve.py +224 -224
- package/md_cg/whitebox_kb/wisdom/os_units.py +2735 -2735
- package/md_cg/whitebox_kb/wisdom/pattern_separation.py +376 -376
- package/md_cg/whitebox_kb/wisdom/prereq_map.json +364 -364
- package/md_cg/whitebox_kb/wisdom/python_code_units.py +2766 -2766
- package/md_cg/whitebox_kb/wisdom/role_solidified.json +7 -7
- package/md_cg/whitebox_kb/wisdom/route_memory.py +244 -244
- package/md_cg/whitebox_kb/wisdom/scene_reconstruction.py +148 -148
- package/md_cg/whitebox_kb/wisdom/snr_report.json +40 -40
- package/md_cg/whitebox_kb/wisdom/test_code_compose_domains.py +7541 -7541
- package/md_cg/whitebox_kb/wisdom/test_compiler_self_bootstrap.py +354 -354
- package/md_cg/whitebox_kb/wisdom/test_ecosystem_assembly.py +158 -158
- package/md_cg/whitebox_kb/wisdom/test_ecosystem_demos.py +193 -193
- package/md_cg/whitebox_kb/wisdom/test_graph_db.py +292 -292
- package/md_cg/whitebox_kb/wisdom/test_python_self_bootstrap.py +160 -160
- package/md_cg/whitebox_kb/wisdom/trigger_words_index.json +4366 -4366
- package/md_cg/whitebox_kb/wisdom/verifier.py +1297 -1297
- package/md_cg/writelimit.py +356 -356
- package/md_cg/writepipe.py +550 -542
- package/package.json +97 -96
- package/skills/plugin.json +54 -54
- package/skills/skills/designer-perspective/SKILL.md +158 -158
- package/skills/skills/designer-perspective/references/01-observation-position.md +66 -66
- package/skills/skills/designer-perspective/references/02-structure-recognition.md +62 -62
- package/skills/skills/designer-perspective/references/03-direction-judgment.md +55 -55
- package/skills/skills/designer-perspective/references/04-qualification-verdict.md +72 -72
- package/skills/skills/designer-perspective/references/05-condition-attribution.md +74 -74
- package/skills/skills/designer-perspective/scripts/designer.py +545 -545
- package/skills/skills/designer-perspective/tests/cases.jsonl +17 -17
- package/skills/skills/designer-perspective/tests/selftest.py +61 -61
- package/skills/skills/lingshu-browser/SKILL.md +60 -60
- package/skills/skills/lingshu-compiler/SKILL.md +56 -56
- package/skills/skills/lingshu-compiler/units/analyze-type-infer/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/check-name-real/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compile-assign/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compile-expr-tree/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compile-full-pipeline/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compile-func-def/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compile-if-then/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compile-logic-expr/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compile-recursive/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compile-scope/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compile-type-check/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compile-while/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-0010c4bf/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-0355bffb/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-0361708a/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-054a0414/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-05a1691a/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-05eeed1e/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-0622a1f6/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-08b54217/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-0a62b70c/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-0ab24d00/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-0e093688/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-0e82b966/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-0ee9b9b9/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-0f3787e6/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-1028685f/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-11897630/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-16661b9b/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-1f722303/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-25be1262/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-2a76ba07/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-2dbea54a/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-2df52f16/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-2ec2c9d2/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-2f8c8f39/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-38378ac7/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-39457d2e/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-39fb5926/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-47f4fbfa/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-4a8cd1f1/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-4b230b6b/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-4cbbda95/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-4d5a68ff/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-56dc9bdd/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-57e76ebe/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-61ff016b/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-63eae588/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-64c4224b/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-66377955/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-674ab4f6/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-6af76fd6/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-6d979db2/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-6de326c0/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-6f1c0eea/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-724d6c9b/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-7690177f/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-7b229a7d/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-7f471b3a/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-815cad08/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-83c61634/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-8c798c81/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-8dd747ac/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-90324d0a/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-94b8d72d/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-94f12231/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-95937c16/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-98a5625b/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-98b4c42f/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-98e3894a/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-9bdfe4b8/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-9d9b4e83/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-9f7be5ad/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-a6daf076/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-a7995a0c/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-a8399248/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-aabbd099/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-afe169d8/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-b0678bda/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-b09bd196/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-b1396e23/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-b9b31ce0/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-c10264a7/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-cb1e8e4b/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-ccafd438/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-cda9c262/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-ce648068/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-cf5776a4/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-d974e5d3/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-e3979fd3/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-eb1cf2b5/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-ecb30d5b/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-f8c8b24b/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-f99fedbe/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-fa8ff5f7/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/compiler-fe1b058d/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/lex-chinese-program/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/lex-dao-de-jing/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/lex-nine-chapters/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-arithmetic/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-array-ops/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-closure-call/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-closure-create/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-compare/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-cond-jump/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-cond-space/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-exception/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-func-call/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-loop-run/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-profiling/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-refcount/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-run-loop/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-short-circuit/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-stack-guard/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-stack-ops/SKILL.md +45 -45
- package/skills/skills/lingshu-compiler/units/vm-trust-accum/SKILL.md +45 -45
- package/skills/skills/lingshu-graph/SKILL.md +63 -63
- package/skills/skills/lingshu-net/SKILL.md +48 -48
- package/skills/skills/lingshu-os/SKILL.md +64 -64
- package/skills/skills/lingshu-pylang/SKILL.md +71 -71
- package/src/bridge.ts +401 -401
- package/src/hooks.ts +38 -2
- package/src/lib/datapath.ts +326 -326
- package/src/lib/mdcg_client.ts +413 -413
- package/src/lib/mutual.ts +428 -428
- package/src/lib/prompt_safety.ts +62 -62
- package/src/lib/python_path.ts +71 -71
- package/src/lib/roleplay_web.ts +932 -932
- package/src/lib/token_store.ts +192 -192
- package/src/tools.ts +212 -212
- package/zcode/AGENTS.md +11 -3
- package/zcode/README.md +41 -41
- /package/docs/{mdcg → hive}//344/270/273/344/273/243/347/220/206/345/255/220/344/273/243/347/220/206/350/256/260/345/277/206/346/236/266/346/236/204/350/256/276/350/256/241.md" +0 -0
package/md_cg/mdcg.py
CHANGED
|
@@ -613,7 +613,7 @@ def _strip_empty_gate_fields(entry, enabled=None):
|
|
|
613
613
|
|
|
614
614
|
# 生效条件:entry 与其 frontmatter 的 condition_space 取 cs(缺键/假值按 {});ctx 为假值或非 dict 时无条件返回 True;
|
|
615
615
|
# ctx 与 cs 同时给出非空 observation_position 且 routing.normalize_domain 归一化后不同时返回 False;
|
|
616
|
-
# ctx 与 cs 同时给出长度 2 的 time_window
|
|
616
|
+
# ctx 与 cs 同时给出长度 2 的 time_window 时两端经 trust.epoch_seconds 归一(毫秒自动 /1000)后比较,不相交返回 False(区间相交或任一侧缺值/不可转数值一律返回 True)。
|
|
617
617
|
def _cond_prefilter_pass(entry, ctx) -> bool:
|
|
618
618
|
"""S2 条件空间前置门控:**不读正文**即可判定的硬槽(契约 §3 S2)。
|
|
619
619
|
|
|
@@ -640,14 +640,136 @@ def _cond_prefilter_pass(entry, ctx) -> bool:
|
|
|
640
640
|
cw, nw = ctx.get("time_window"), (entry.get("time_window") or cs.get("time_window"))
|
|
641
641
|
if (isinstance(cw, (list, tuple)) and len(cw) == 2
|
|
642
642
|
and isinstance(nw, (list, tuple)) and len(nw) == 2):
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
643
|
+
# 单位归一(唯一口径 trust.epoch_seconds):历史毫秒节点的区间若不归一,
|
|
644
|
+
# 与秒级查询窗「必然不相交」→ 整片历史观测被误剔除(issue #23 同根因)。
|
|
645
|
+
c0, c1 = trust.epoch_seconds(cw[0]), trust.epoch_seconds(cw[1])
|
|
646
|
+
n0, n1 = trust.epoch_seconds(nw[0]), trust.epoch_seconds(nw[1])
|
|
647
|
+
if None in (c0, c1, n0, n1):
|
|
648
|
+
return True # 任一端不可转 → 信息不足,放行(宁多勿漏)
|
|
649
|
+
if c1 < n0 or n1 < c0:
|
|
650
|
+
return False
|
|
648
651
|
return True
|
|
649
652
|
|
|
650
653
|
|
|
654
|
+
# 生效条件:entries/terms/big_domain/context/min_results 给定;MDCG_RETRIEVAL_PIPELINE 未设="1" 时 entries 原样返回且 gates 为空 dict(默认路径零变更);总开关开启时按既有开关语义执行收敛——S1 域收敛(MDCG_GATE_S1_DOMAIN 未设=开;域内∪未标域兜底池,域内不足 min_results 回退不收敛)、S1b 桶收敛(MDCG_GATE_S1B_BUCKET 显式=1;topk/min_sim 参数化,命中不足回退并记 would_keep)、S2 条件空间硬槽(MDCG_GATE_S2_COND 未设=开;清空回退)、S4 层级激活审计(MDCG_GATE_S4_LAYER 显式=1;只构造 gates["s4"] 审计,加成本体在 _score);返回 (收敛后 entries, gates 审计字典);
|
|
655
|
+
# apply_retrieval_gates(entries, terms, big_domain, context, min_results) -> tuple:
|
|
656
|
+
def apply_retrieval_gates(entries, terms, big_domain, context, min_results):
|
|
657
|
+
"""S1/S1b/S2 候选收敛 + S4 审计——**两份 search 的唯一实现**。
|
|
658
|
+
|
|
659
|
+
issue #25(2026-09-23):此段逻辑原先只存在于 MdCG.search 内,而生产
|
|
660
|
+
调用链(mcp_server → MdCGSecure → MdCGOS)走的是 MdCGOS.search 覆写——
|
|
661
|
+
门控在 生产路径上从未生效,专项测试(test_retr_s*.py)全测非生产路径,
|
|
662
|
+
绿灯是假信号。修复 = 抽出本共享函数,两份 search 原地调用。
|
|
663
|
+
|
|
664
|
+
开关语义(契约 §3,保持不变):
|
|
665
|
+
· 总开关 MDCG_RETRIEVAL_PIPELINE=1;未设 → 本函数是恒等变换;
|
|
666
|
+
· S1 / S2:未设=开,"=0" 显式关(先于 S1b 存在的默认项);
|
|
667
|
+
· S1b / S4:必须显式 "=1"(会新增收敛/新层加成,非对称开关);
|
|
668
|
+
· S3 spread / S7 postings:仍属 MdCG.search 的候选生成段(新 tier),
|
|
669
|
+
MdCGOS 路径的对应物是 reach——本函数不涉及。
|
|
670
|
+
召回安全不变量:任一收敛「命中不足 min_results / 清空」即回退不收敛;
|
|
671
|
+
orphan/未标域恒留兜底池。
|
|
672
|
+
"""
|
|
673
|
+
gates = {}
|
|
674
|
+
if os.environ.get("MDCG_RETRIEVAL_PIPELINE") != "1":
|
|
675
|
+
return entries, gates
|
|
676
|
+
# S4 层级激活优先级审计(加成本体在 _score:layer_boosts() 由打分面消费,
|
|
677
|
+
# 该面两份 search 共享 → S4 加成在生产路径其实一直生效,缺的只是这份审计)
|
|
678
|
+
_s4 = (os.environ.get("MDCG_GATE_S4_LAYER") == "1")
|
|
679
|
+
if _s4 and entries:
|
|
680
|
+
_bo = layer_boosts()
|
|
681
|
+
_lc = {}
|
|
682
|
+
for _e in entries:
|
|
683
|
+
_l = str(_e.get("layer") or "")
|
|
684
|
+
_lc[_l] = _lc.get(_l, 0) + 1
|
|
685
|
+
gates["s4"] = {"boosts": _bo, "layers": _lc}
|
|
686
|
+
if os.environ.get("MDCG_GATE_S1_DOMAIN", "1") != "0" and big_domain:
|
|
687
|
+
# 域内 ∪ 未标域(兜底池):无域标签的历史节点绝不能因「域内够多」被丢
|
|
688
|
+
#(契约 §3 S1 不变量:ORPHAN/未标域必须可被召回)
|
|
689
|
+
same = [e for e in entries
|
|
690
|
+
if not e.get("big_domain") or e.get("big_domain") == big_domain]
|
|
691
|
+
# 召回安全:域内候选不足以支撑 min_results 时不收敛,留全量兜底
|
|
692
|
+
if len(same) >= max(1, min_results):
|
|
693
|
+
gates["s1"] = {"domain": big_domain, "in": len(same),
|
|
694
|
+
"dropped": len(entries) - len(same)}
|
|
695
|
+
entries = same
|
|
696
|
+
else:
|
|
697
|
+
gates["s1"] = {"domain": big_domain, "in": len(same),
|
|
698
|
+
"dropped": 0, "fallback": "insufficient"}
|
|
699
|
+
elif os.environ.get("MDCG_GATE_S1_DOMAIN", "1") != "0":
|
|
700
|
+
gates["s1"] = {"domain": None, "reason": "no_domain_signal"}
|
|
701
|
+
# ---- S1b 细口径桶收敛(设计见 docs/hive/检索收敛实测与S1b设计_v0.1.md)----
|
|
702
|
+
# 为何:真实库 91.1% 节点有非 orphan 桶、期望扫描仅 2.1%(细口径),但 T0/T1 桶路
|
|
703
|
+
# 只在调用方传 context 时可用;普通 search(q) 无 context 就只能全扫。S1b 让 query 侧
|
|
704
|
+
# 自己推断候选桶(只用索引,不读文件),把这份收敛拿回来。
|
|
705
|
+
# 召回安全:orphan/无桶节点恒留兜底;命中不足 min_results 即回退(不改 entries)。
|
|
706
|
+
# 开关与参数就地定义:S1b 只依赖总开关 + MDCG_GATE_S1B_BUCKET。
|
|
707
|
+
_s1b = (os.environ.get("MDCG_GATE_S1B_BUCKET") == "1")
|
|
708
|
+
try:
|
|
709
|
+
_s1b_topk = int(os.environ.get("MDCG_BUCKET_TOPK", "3"))
|
|
710
|
+
except ValueError:
|
|
711
|
+
_s1b_topk = 3
|
|
712
|
+
try:
|
|
713
|
+
_s1b_minsim = min(1.0, max(0.0, float(os.environ.get("MDCG_BUCKET_MIN_SIM", "0.34"))))
|
|
714
|
+
except ValueError:
|
|
715
|
+
_s1b_minsim = 0.34
|
|
716
|
+
if _s1b and entries:
|
|
717
|
+
if _s1b_topk <= 0:
|
|
718
|
+
gates["s1b"] = {"keys": [], "reason": "disabled_by_topk"}
|
|
719
|
+
else:
|
|
720
|
+
_sizes = {}
|
|
721
|
+
for _e in entries:
|
|
722
|
+
_b = _e.get("bucket")
|
|
723
|
+
if _b and _b != routing.ORPHAN:
|
|
724
|
+
_sizes[_b] = _sizes.get(_b, 0) + 1
|
|
725
|
+
_best = {}
|
|
726
|
+
for _b in _sizes:
|
|
727
|
+
_kk = routing.bucket_key_readable(_b)
|
|
728
|
+
if not _kk:
|
|
729
|
+
continue
|
|
730
|
+
_sim = 0.0
|
|
731
|
+
for _t in terms:
|
|
732
|
+
_sv = routing.domain_similarity(_t, _kk)
|
|
733
|
+
if _sv > _sim:
|
|
734
|
+
_sim = _sv
|
|
735
|
+
if _sim >= _s1b_minsim:
|
|
736
|
+
_best[_b] = _sim
|
|
737
|
+
if not _best:
|
|
738
|
+
gates["s1b"] = {"keys": [], "reason": "no_key_match",
|
|
739
|
+
"in": len(entries), "buckets": len(_sizes)}
|
|
740
|
+
else:
|
|
741
|
+
_picked = sorted(_best.items(),
|
|
742
|
+
key=lambda kv: (-kv[1], -_sizes[kv[0]],
|
|
743
|
+
str(kv[0])))[:_s1b_topk]
|
|
744
|
+
_keep = {_b for _b, _ in _picked}
|
|
745
|
+
_kept = [e for e in entries
|
|
746
|
+
if (e.get("bucket") in _keep)
|
|
747
|
+
or not e.get("bucket")
|
|
748
|
+
or e.get("bucket") == routing.ORPHAN]
|
|
749
|
+
gates["s1b"] = {"keys": [_b for _b, _ in _picked],
|
|
750
|
+
"sims": [round(_v, 4) for _, _v in _picked],
|
|
751
|
+
"in": len(entries), "out": len(_kept),
|
|
752
|
+
"sizes": {_b: _sizes[_b] for _b, _ in _picked}}
|
|
753
|
+
if len(_kept) >= max(1, min_results):
|
|
754
|
+
entries = _kept
|
|
755
|
+
else:
|
|
756
|
+
# 回退:entries 保持不变 → 审计的 out 必须记「真实输出规模」,
|
|
757
|
+
# 命中桶本可保留的数量另存 would_keep(独立复核 2026-09-19 指出口径误导)
|
|
758
|
+
gates["s1b"]["would_keep"] = len(_kept)
|
|
759
|
+
gates["s1b"]["out"] = len(entries)
|
|
760
|
+
gates["s1b"]["fallback"] = "insufficient"
|
|
761
|
+
if os.environ.get("MDCG_GATE_S2_COND", "1") != "0" and isinstance(context, dict):
|
|
762
|
+
kept = [e for e in entries if _cond_prefilter_pass(e, context)]
|
|
763
|
+
gates["s2"] = {"in": len(entries), "out": len(kept),
|
|
764
|
+
"dropped": len(entries) - len(kept)}
|
|
765
|
+
# 门控清空则回退(宁多勿漏)
|
|
766
|
+
if kept:
|
|
767
|
+
entries = kept
|
|
768
|
+
else:
|
|
769
|
+
gates["s2"]["fallback"] = "empty"
|
|
770
|
+
return entries, gates
|
|
771
|
+
|
|
772
|
+
|
|
651
773
|
# 生效条件:构造须传入 root,经 os.path.abspath 后以 exist_ok=True 创建该目录及 LAYERS 各层子目录;autoflush 无论取值(默认 64)都原样赋给实例。
|
|
652
774
|
class MdCG:
|
|
653
775
|
# 生效条件:root 传参即被 os.path.abspath 绝对化并 makedirs(exist_ok=True) 建立 root 与模块级 LAYERS 各层目录,autoflush(默认 64,含 0 等假值)原样存入 self.autoflush,随后 _load_index() 载入索引、sweep_stale_temps(self.root) 清扫,并把 self 登记进模块级 _LIVE_CGS;
|
|
@@ -738,20 +860,27 @@ class MdCG:
|
|
|
738
860
|
self.index = idx
|
|
739
861
|
return idx
|
|
740
862
|
|
|
741
|
-
# 生效条件:self._dirty
|
|
863
|
+
# 生效条件:self._dirty 非空时才在 FileLock(index_path) 下(必要时新建 ShardedLog)逐条 append、清空 _dirty 并关闭分片句柄;self._dirty 为空时立即返回、不写任何记录;
|
|
742
864
|
def flush(self):
|
|
743
865
|
if not self._dirty:
|
|
744
866
|
return
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
#
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
867
|
+
# 世代/互斥防线(批次9,M3.3 落地):append 必须与 compact/rebuild 的
|
|
868
|
+
# 「read 日志 → clear 分片」临界区互斥(同一把 index_path 锁)——
|
|
869
|
+
# 否则 B 实例的 append 落在 A 实例 read_all 之后、clear 之前时,
|
|
870
|
+
# 记录随分片被删,节点「在盘但索引不可见」(9·12 病灶:3 实例并发,
|
|
871
|
+
# apply 留痕 7590 vs 盘面 ~1036 的成因链之一)。锁内 append 后,
|
|
872
|
+
# 后续 clear 必然已包含本批记录。
|
|
873
|
+
with FileLock(self.index_path):
|
|
874
|
+
if self._log is None:
|
|
875
|
+
self._log = ShardedLog(self.index_log_dir)
|
|
876
|
+
for nid, e in self._dirty.items():
|
|
877
|
+
self._log.append({"id": nid, "e": e})
|
|
878
|
+
self._dirty = {}
|
|
879
|
+
# 写完立即关分片句柄:Windows 上「被本进程打开的文件」无法删除,
|
|
880
|
+
# 若持有句柄,rebuild_index 的 ShardedLog.clear 会静默失败,已并进
|
|
881
|
+
# 快照的旧记录被永久重放(旧条目反而覆盖新快照)。append 内部已
|
|
882
|
+
# 每次 flush,句柄无需常驻;下一次 append 会按需重开。
|
|
883
|
+
self._log.close()
|
|
755
884
|
|
|
756
885
|
# 生效条件:随认知图对象生命周期结束调用、可重复;先 flush() 落未达 autoflush 阈值的脏索引(否则尾部写入虽在盘上但不可见),再关闭并置空日志句柄(句柄为假值时跳过关闭);
|
|
757
886
|
def close(self):
|
|
@@ -790,6 +919,10 @@ class MdCG:
|
|
|
790
919
|
# 候选资格维度须免读文件可判(与 role 同款理由)。
|
|
791
920
|
# 纯增量键:批次 C 之前零消费方,view=None 零行为变更。
|
|
792
921
|
"content_kind": fm.get("content_kind"),
|
|
922
|
+
# 会话归属入快照(P45 归因维度):写入路径 _stage 早已带出
|
|
923
|
+
# 该键,重建路径若漏掉,rebuild_index() 之后「按会话过滤」
|
|
924
|
+
# 即静默全空——快照与 _stage 必须同口径(与 role 同款理由)。
|
|
925
|
+
"session": fm.get("session"),
|
|
793
926
|
"tags": fm.get("tags", []),
|
|
794
927
|
"bucket": parent if parent != layer else None,
|
|
795
928
|
"importance": fm.get("importance", 0.5),
|
|
@@ -1707,6 +1840,15 @@ class MdCG:
|
|
|
1707
1840
|
except OSError:
|
|
1708
1841
|
return None, None
|
|
1709
1842
|
|
|
1843
|
+
def _doc_norm_bigrams(self, entry, c):
|
|
1844
|
+
"""文档侧归一化 bigram(`_score` 热点,批次 21 issue #31 钩子化)。
|
|
1845
|
+
|
|
1846
|
+
内容不变则派生物不变——readcache 启用时覆写为缓存版(随读缓存
|
|
1847
|
+
一并常驻,Rust `load_docs` 预计算 stripped/db_len 同款理论);
|
|
1848
|
+
基类默认即算即弃,行为与改动前逐位一致。
|
|
1849
|
+
"""
|
|
1850
|
+
return bigrams(normalize_en(c))
|
|
1851
|
+
|
|
1710
1852
|
# ---------- 资格判定(与性能 tier 正交)----------
|
|
1711
1853
|
|
|
1712
1854
|
@staticmethod
|
|
@@ -1868,6 +2010,11 @@ class MdCG:
|
|
|
1868
2010
|
ValueError(fail-closed 只针对调用方误用)。
|
|
1869
2011
|
"""
|
|
1870
2012
|
q = (query or "").strip()
|
|
2013
|
+
# 批次 15 统一口径(unify.py):任意语言 query → 标准原子序列
|
|
2014
|
+
# (统一翻译为中文→归一化到标准中文集→检索);纯中文原样、
|
|
2015
|
+
# MDCG_UNIFY_QUERY=0 可关、失败静默原样
|
|
2016
|
+
from .semantic.unify import unify_query
|
|
2017
|
+
q = unify_query(q)
|
|
1871
2018
|
if not q:
|
|
1872
2019
|
return [], {"tier": None, "reason": "empty_query", "scanned": 0}
|
|
1873
2020
|
pool_cfg = pooling.resolve(pooling.from_env(pools))
|
|
@@ -1882,7 +2029,9 @@ class MdCG:
|
|
|
1882
2029
|
# 默认排除掉负记忆层的节点进入正排打分,仅作为「覆盖标记」用
|
|
1883
2030
|
entries = [e for e in self.index["nodes"].values()
|
|
1884
2031
|
if (not layer or e["layer"] == layer)
|
|
1885
|
-
|
|
2032
|
+
# '"*"' = 显式跨会话(读遍所有会话);缺省 None 同义
|
|
2033
|
+
and (not session or session == "*"
|
|
2034
|
+
or e.get("session") == session)
|
|
1886
2035
|
# 分支实验场:默认(branch=None)分支节点全部隐身;
|
|
1887
2036
|
# branch=<id> 时主支 + 本分支可见、其他分支仍隐身
|
|
1888
2037
|
and e.get("branch_id") in (None, branch)
|
|
@@ -1931,27 +2080,20 @@ class MdCG:
|
|
|
1931
2080
|
# 默认(MDCG_RETRIEVAL_PIPELINE 未设)全关 → 行为与改动前等价。
|
|
1932
2081
|
big_domain = routing.big_domain_classify(terms)
|
|
1933
2082
|
big_scores = routing.big_domain_score_breakdown(terms)
|
|
1934
|
-
gates = {}
|
|
1935
2083
|
# S3 子开关**必须显式 =1**(与 S1/S2 的「未设=开」不同,是有意的非对称):
|
|
1936
2084
|
# S3 会新增候选并引入新的 tier(TIER_SPREAD),在总开关开启时若默认随开,
|
|
1937
2085
|
# 会让「启用 S1/S2」的用户静默多出一层结果——独立复核(2026-09-19)要求显式启用。
|
|
1938
2086
|
# 参数:hops(默认 2)、decay(默认 0.5)、gain(默认 0.2)。
|
|
1939
2087
|
_s3 = (os.environ.get("MDCG_RETRIEVAL_PIPELINE") == "1"
|
|
1940
2088
|
and os.environ.get("MDCG_GATE_S3_SPREAD") == "1")
|
|
1941
|
-
# S4 层级激活优先级:同样必须显式 =1(新层加成会改变排序,属显式启用项)
|
|
1942
|
-
_s4 = (os.environ.get("MDCG_RETRIEVAL_PIPELINE") == "1"
|
|
1943
|
-
and os.environ.get("MDCG_GATE_S4_LAYER") == "1")
|
|
1944
2089
|
# S7 倒排候选层(只作候选生成器;召回与全表扫描一致);见 md_cg/postings.py
|
|
1945
2090
|
_s7 = (os.environ.get("MDCG_RETRIEVAL_PIPELINE") == "1"
|
|
1946
2091
|
and os.environ.get("MDCG_GATE_S7_POSTINGS") == "1")
|
|
1947
2092
|
_s7_narrowed = False
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
_l = str(_e.get("layer") or "")
|
|
1953
|
-
_lc[_l] = _lc.get(_l, 0) + 1
|
|
1954
|
-
gates["s4"] = {"boosts": _bo, "layers": _lc}
|
|
2093
|
+
# S1/S1b/S2 收敛 + S4 审计走共享函数(issue #25:原先内联于此,被
|
|
2094
|
+
# MdCGOS.search 覆写悬空——生产路径从未生效;行为与内联版逐字节一致)
|
|
2095
|
+
entries, gates = apply_retrieval_gates(
|
|
2096
|
+
entries, terms, big_domain, context, min_results)
|
|
1955
2097
|
try:
|
|
1956
2098
|
_s3_hops = max(1, int(os.environ.get("MDCG_SPREAD_HOPS", "2")))
|
|
1957
2099
|
except ValueError:
|
|
@@ -1964,91 +2106,6 @@ class MdCG:
|
|
|
1964
2106
|
_s3_gain = min(1.0, max(0.0, float(os.environ.get("MDCG_SPREAD_GAIN", "0.2"))))
|
|
1965
2107
|
except ValueError:
|
|
1966
2108
|
_s3_gain = 0.2
|
|
1967
|
-
if os.environ.get("MDCG_RETRIEVAL_PIPELINE") == "1" and entries:
|
|
1968
|
-
if os.environ.get("MDCG_GATE_S1_DOMAIN", "1") != "0" and big_domain:
|
|
1969
|
-
# 域内 ∪ 未标域(兜底池):无域标签的历史节点绝不能因「域内够多」被丢
|
|
1970
|
-
#(契约 §3 S1 不变量:ORPHAN/未标域必须可被召回)
|
|
1971
|
-
same = [e for e in entries
|
|
1972
|
-
if not e.get("big_domain") or e.get("big_domain") == big_domain]
|
|
1973
|
-
# 召回安全:域内候选不足以支撑 min_results 时不收敛,留全量兜底
|
|
1974
|
-
if len(same) >= max(1, min_results):
|
|
1975
|
-
gates["s1"] = {"domain": big_domain, "in": len(same),
|
|
1976
|
-
"dropped": len(entries) - len(same)}
|
|
1977
|
-
entries = same
|
|
1978
|
-
else:
|
|
1979
|
-
gates["s1"] = {"domain": big_domain, "in": len(same),
|
|
1980
|
-
"dropped": 0, "fallback": "insufficient"}
|
|
1981
|
-
elif os.environ.get("MDCG_GATE_S1_DOMAIN", "1") != "0":
|
|
1982
|
-
gates["s1"] = {"domain": None, "reason": "no_domain_signal"}
|
|
1983
|
-
# ---- S1b 细口径桶收敛(设计见 docs/hive/检索收敛实测与S1b设计_v0.1.md)----
|
|
1984
|
-
# 为何:真实库 91.1% 节点有非 orphan 桶、期望扫描仅 2.1%(细口径),但 T0/T1 桶路
|
|
1985
|
-
# 只在调用方传 context 时可用;普通 search(q) 无 context 就只能全扫。S1b 让 query 侧
|
|
1986
|
-
# 自己推断候选桶(只用索引,不读文件),把这份收敛拿回来。
|
|
1987
|
-
# 召回安全:orphan/无桶节点恒留兜底;命中不足 min_results 即回退(不改 entries)。
|
|
1988
|
-
# 开关与参数就地定义(位于“总开关块”内,不在 S4 块内):S1b 只依赖总开关 + MDCG_GATE_S1B_BUCKET。
|
|
1989
|
-
_s1b = (os.environ.get("MDCG_GATE_S1B_BUCKET") == "1")
|
|
1990
|
-
try:
|
|
1991
|
-
_s1b_topk = int(os.environ.get("MDCG_BUCKET_TOPK", "3"))
|
|
1992
|
-
except ValueError:
|
|
1993
|
-
_s1b_topk = 3
|
|
1994
|
-
try:
|
|
1995
|
-
_s1b_minsim = min(1.0, max(0.0, float(os.environ.get("MDCG_BUCKET_MIN_SIM", "0.34"))))
|
|
1996
|
-
except ValueError:
|
|
1997
|
-
_s1b_minsim = 0.34
|
|
1998
|
-
if _s1b and entries:
|
|
1999
|
-
if _s1b_topk <= 0:
|
|
2000
|
-
gates["s1b"] = {"keys": [], "reason": "disabled_by_topk"}
|
|
2001
|
-
else:
|
|
2002
|
-
_sizes = {}
|
|
2003
|
-
for _e in entries:
|
|
2004
|
-
_b = _e.get("bucket")
|
|
2005
|
-
if _b and _b != routing.ORPHAN:
|
|
2006
|
-
_sizes[_b] = _sizes.get(_b, 0) + 1
|
|
2007
|
-
_best = {}
|
|
2008
|
-
for _b in _sizes:
|
|
2009
|
-
_kk = routing.bucket_key_readable(_b)
|
|
2010
|
-
if not _kk:
|
|
2011
|
-
continue
|
|
2012
|
-
_sim = 0.0
|
|
2013
|
-
for _t in terms:
|
|
2014
|
-
_sv = routing.domain_similarity(_t, _kk)
|
|
2015
|
-
if _sv > _sim:
|
|
2016
|
-
_sim = _sv
|
|
2017
|
-
if _sim >= _s1b_minsim:
|
|
2018
|
-
_best[_b] = _sim
|
|
2019
|
-
if not _best:
|
|
2020
|
-
gates["s1b"] = {"keys": [], "reason": "no_key_match",
|
|
2021
|
-
"in": len(entries), "buckets": len(_sizes)}
|
|
2022
|
-
else:
|
|
2023
|
-
_picked = sorted(_best.items(),
|
|
2024
|
-
key=lambda kv: (-kv[1], -_sizes[kv[0]],
|
|
2025
|
-
str(kv[0])))[:_s1b_topk]
|
|
2026
|
-
_keep = {_b for _b, _ in _picked}
|
|
2027
|
-
_kept = [e for e in entries
|
|
2028
|
-
if (e.get("bucket") in _keep)
|
|
2029
|
-
or not e.get("bucket")
|
|
2030
|
-
or e.get("bucket") == routing.ORPHAN]
|
|
2031
|
-
gates["s1b"] = {"keys": [_b for _b, _ in _picked],
|
|
2032
|
-
"sims": [round(_v, 4) for _, _v in _picked],
|
|
2033
|
-
"in": len(entries), "out": len(_kept),
|
|
2034
|
-
"sizes": {_b: _sizes[_b] for _b, _ in _picked}}
|
|
2035
|
-
if len(_kept) >= max(1, min_results):
|
|
2036
|
-
entries = _kept
|
|
2037
|
-
else:
|
|
2038
|
-
# 回退:entries 保持不变 → 审计的 out 必须记「真实输出规模」,
|
|
2039
|
-
# 命中桶本可保留的数量另存 would_keep(独立复核 2026-09-19 指出口径误导)
|
|
2040
|
-
gates["s1b"]["would_keep"] = len(_kept)
|
|
2041
|
-
gates["s1b"]["out"] = len(entries)
|
|
2042
|
-
gates["s1b"]["fallback"] = "insufficient"
|
|
2043
|
-
if os.environ.get("MDCG_GATE_S2_COND", "1") != "0" and isinstance(context, dict):
|
|
2044
|
-
kept = [e for e in entries if _cond_prefilter_pass(e, context)]
|
|
2045
|
-
gates["s2"] = {"in": len(entries), "out": len(kept),
|
|
2046
|
-
"dropped": len(entries) - len(kept)}
|
|
2047
|
-
# 门控清空则回退(宁多勿漏)
|
|
2048
|
-
if kept:
|
|
2049
|
-
entries = kept
|
|
2050
|
-
else:
|
|
2051
|
-
gates["s2"]["fallback"] = "empty"
|
|
2052
2109
|
if not entries:
|
|
2053
2110
|
_m = {"tier": None, "reason": "no_candidates", "scanned": 0}
|
|
2054
2111
|
if gates: # 默认关时 gates 为空 → 不落键(口径与改动前一致)
|
|
@@ -2384,9 +2441,11 @@ class MdCG:
|
|
|
2384
2441
|
_boost = layer_boosts() if _s4_on else None
|
|
2385
2442
|
scored = []
|
|
2386
2443
|
for e, fm, c in docs:
|
|
2387
|
-
# 归一化 content 后取 bigram(与 query 侧 normalize_en
|
|
2388
|
-
|
|
2389
|
-
|
|
2444
|
+
# 归一化 content 后取 bigram(与 query 侧 normalize_en 对称);
|
|
2445
|
+
# 走可覆写钩子(批次 21,issue #31):内容不变则派生物不变——
|
|
2446
|
+
# readcache 启用时覆写为缓存版(Rust load_docs 预计算同款),
|
|
2447
|
+
# 基类默认即算即弃,行为与改动前逐位一致
|
|
2448
|
+
nb = self._doc_norm_bigrams(e, c)
|
|
2390
2449
|
sim = lexical_sim(qb, nb, mode)
|
|
2391
2450
|
tag_bonus = 0.05 if any(str(t) in q or q in str(t)
|
|
2392
2451
|
for t in (fm.get("tags") or [])) else 0.0
|
package/md_cg/mdcos.py
CHANGED
|
@@ -30,7 +30,7 @@ from .mdcg import (MdCG, expand_query_terms, bigrams, normalize_en, STATE_ACCEPT
|
|
|
30
30
|
TIER_BUCKET_SCAN, TIER_GLOBAL_LIKE, TIER_GLOBAL_SCAN,
|
|
31
31
|
GLOBAL_CAP, expand_query_terms_weighted,
|
|
32
32
|
expand_query_terms_llm, en_zh_bigrams, semantic_on,
|
|
33
|
-
cut_by_relevance)
|
|
33
|
+
cut_by_relevance, apply_retrieval_gates)
|
|
34
34
|
from . import (nodefile, routing, chain, subgraph, forgetting, protect,
|
|
35
35
|
identity, consistency, metacognition, crypto, sustain,
|
|
36
36
|
self_state, predict, evolution, weights, pooling,
|
|
@@ -326,6 +326,21 @@ class MdCGOS(MdCG):
|
|
|
326
326
|
os.makedirs(self.trash_dir, exist_ok=True)
|
|
327
327
|
self._audit_writes = 0 # 进程内写入计数(轮转探测节流,稳态零 stat)
|
|
328
328
|
self._audit_index = None # 归档索引缓存(懒加载)
|
|
329
|
+
# 热缓存挂载(issue #28,2026-09-23):读侧(search_rrf)与失效侧
|
|
330
|
+
# (writepipe)早已接好,唯独无人调 attach——生产恒 None,重复 query
|
|
331
|
+
# 无法命中。默认关(env 未设 → get(self) 恒 None,零变更纪律);
|
|
332
|
+
# MDCG_HOTCACHE=1 显式启用,容量经 MDCG_HOTCACHE_MAX_NODES/MAX_QUERIES
|
|
333
|
+
# 可配(缺省 256 对 567 节点级库会持续 LRU 淘汰,大库请调大)。
|
|
334
|
+
if os.environ.get("MDCG_HOTCACHE") == "1":
|
|
335
|
+
from . import hotcache as _hc
|
|
336
|
+
_hc.attach(self)
|
|
337
|
+
# 检索读缓存挂载(issue #31 P2,批次 21):MdStore 理论落地——节点
|
|
338
|
+
# 文件解析产物常驻(567 池实测 572 次 open/查询 → 缓存后 ~0),写失
|
|
339
|
+
# 效走 _dirty 代际哨兵(所有写路径必然标脏,无漏挂面)。默认关
|
|
340
|
+
# (MDCG_READ_CACHE=1 显式启用,零变更纪律)。
|
|
341
|
+
if os.environ.get("MDCG_READ_CACHE") == "1":
|
|
342
|
+
from . import readcache as _rc
|
|
343
|
+
_rc.install(self)
|
|
329
344
|
|
|
330
345
|
# ================= 6. payload-free 审计 =================
|
|
331
346
|
|
|
@@ -608,7 +623,8 @@ class MdCGOS(MdCG):
|
|
|
608
623
|
for e in self.index["nodes"].values():
|
|
609
624
|
if e.get("layer") in ("rejected", "unresolved", "goals"):
|
|
610
625
|
continue # 负记忆走覆盖标记;目标只做定向,都不进正排
|
|
611
|
-
|
|
626
|
+
# '"*"' = 显式跨会话(读遍所有会话);缺省 None 同义(见 stg.timeline)
|
|
627
|
+
if session and session != "*" and e.get("session") != session:
|
|
612
628
|
continue
|
|
613
629
|
if e.get("branch_id") not in (None, branch):
|
|
614
630
|
continue
|
|
@@ -705,6 +721,10 @@ class MdCGOS(MdCG):
|
|
|
705
721
|
详见 _candidates。
|
|
706
722
|
"""
|
|
707
723
|
q = (query or "").strip()
|
|
724
|
+
# 批次 15 统一口径(unify.py):任意语言 query → 标准原子序列;
|
|
725
|
+
# 与 MdCG.search/search_rrf 三入口同口径(MDCG_UNIFY_QUERY=0 可关)
|
|
726
|
+
from .semantic.unify import unify_query
|
|
727
|
+
q = unify_query(q)
|
|
708
728
|
if not q:
|
|
709
729
|
return [], {"tier": None, "reason": "empty_query", "scanned": 0}
|
|
710
730
|
pool_cfg = pooling.resolve(pooling.from_env(pools))
|
|
@@ -740,6 +760,15 @@ class MdCGOS(MdCG):
|
|
|
740
760
|
route_bucket = routing.bucket_dir(routing.route_key(ctx, ctx.get("tags")))
|
|
741
761
|
big_domain = routing.big_domain_classify(terms)
|
|
742
762
|
big_scores = routing.big_domain_score_breakdown(terms)
|
|
763
|
+
# S1/S1b/S2 收敛 + S4 审计——与 MdCG.search 共享同一实现(issue #25:
|
|
764
|
+
# 本覆写此前完全不含门控,生产路径(MdCGSecure → 本类)从未生效——
|
|
765
|
+
# 开关显式打开也不生效、gates 审计不出现、scanned 恒全表)。
|
|
766
|
+
# 收敛在 _read_many 之前 → scanned 真实下降;gates 非空才落键
|
|
767
|
+
# (默认关时 meta 键集合与改动前逐字节一致,零变更纪律)。
|
|
768
|
+
entries, gates = apply_retrieval_gates(
|
|
769
|
+
entries, terms, big_domain, context, min_results)
|
|
770
|
+
if gates:
|
|
771
|
+
stat["gates"] = gates
|
|
743
772
|
neg_coverage = self._neg_coverage(terms) if include_neg else []
|
|
744
773
|
|
|
745
774
|
# 生效条件:对 docs 调 self._score 后,若其中分数 >0 的条数达到(search 作用域内的)min_results 就返回 self._emit(scored, k, tier, stat, route_bucket, record, len(docs), ...),否则返回 None。
|
|
@@ -1175,6 +1204,10 @@ class MdCGOS(MdCG):
|
|
|
1175
1204
|
串结果);候选层语义与 search 一致,详见 _candidates。
|
|
1176
1205
|
"""
|
|
1177
1206
|
q = (query or "").strip()
|
|
1207
|
+
# 批次 15 统一口径(unify.py):任意语言 query → 标准原子序列;
|
|
1208
|
+
# 归一后的 q 进热路径缓存键(归一确定 → 缓存不串味)
|
|
1209
|
+
from .semantic.unify import unify_query
|
|
1210
|
+
q = unify_query(q)
|
|
1178
1211
|
if not q:
|
|
1179
1212
|
return [], {"tier": None, "reason": "empty_query", "paths": {}}
|
|
1180
1213
|
# 热路径:query 结果缓存命中即返回(不改 RRF 核心)
|
|
@@ -1485,15 +1518,24 @@ class MdCGOS(MdCG):
|
|
|
1485
1518
|
|
|
1486
1519
|
# ================= 1. Fix pairs 自动挖掘 =================
|
|
1487
1520
|
|
|
1488
|
-
# 生效条件:当 events 传入时,兼容显式 {error,fix} 对与含 text 的事件序列;后者在错误行长度 >= min_len 后向后 lookahead 条内寻找 _FIX_RE 命中的行配对并 break
|
|
1489
|
-
def mine_fix_pairs(self, events, lookahead: int = 4, min_len: int = 6
|
|
1521
|
+
# 生效条件:当 events 传入时,兼容显式 {error,fix} 对与含 text 的事件序列;后者在错误行长度 >= min_len 后向后 lookahead 条内寻找 _FIX_RE 命中的行配对并 break;去重后为每对产出修复知识(as_proposals 为假→add 直写 knowledge 层;为真→propose 入审核队列,判据指纹随提案落盘,knowledge_ids 为空、pids 收提案 id 并附 as_proposals=True)与 add_rejected 负记忆,返回 pairs/rejected_ids/knowledge_ids(提案模式另附 pids);
|
|
1522
|
+
def mine_fix_pairs(self, events, lookahead: int = 4, min_len: int = 6,
|
|
1523
|
+
as_proposals: bool = False):
|
|
1490
1524
|
"""从行为日志挖掘「错误 → 修复」对。
|
|
1491
1525
|
|
|
1492
1526
|
events: [{"role": ..., "text": ...}] 或 [{"error":..., "fix":...}](显式对)
|
|
1493
1527
|
返回 {"pairs": [...], "rejected_ids": [...], "knowledge_ids": [...]}
|
|
1494
1528
|
|
|
1529
|
+
as_proposals=False(默认,显式调用语义):正记忆直写 knowledge 层——
|
|
1530
|
+
调用方是有意图的显式动作(如 mdcg_mine_fix_pairs 工具直调)。
|
|
1531
|
+
as_proposals=True(自动管线语义):正记忆改走 propose 审核队列——
|
|
1532
|
+
自动产物不经收口不入知识层(§5.5 系统纪律化,zcode 外评 break#2);
|
|
1533
|
+
判据指纹随提案落盘,复核者只能按原判据裁决不能放宽;payload_hash
|
|
1534
|
+
幂等(重试与崩溃恢复无害)。负记忆一律直写 rejected 层(隔离层,
|
|
1535
|
+
不存在 knowledge 污染问题)。
|
|
1536
|
+
|
|
1495
1537
|
产出:
|
|
1496
|
-
· knowledge/<fix_xxx>.md —— 可路由的修复知识(CCG 5 要素)
|
|
1538
|
+
· knowledge/<fix_xxx>.md 或审核队列提案 —— 可路由的修复知识(CCG 5 要素)
|
|
1497
1539
|
· rejected/<rej_xxx>.md —— 负记忆「此错误不必深挖根因」(防重复踩坑)
|
|
1498
1540
|
"""
|
|
1499
1541
|
pairs = []
|
|
@@ -1528,7 +1570,7 @@ class MdCGOS(MdCG):
|
|
|
1528
1570
|
seen.add(k)
|
|
1529
1571
|
uniq.append((err, fix))
|
|
1530
1572
|
|
|
1531
|
-
rej_ids, kno_ids = [], []
|
|
1573
|
+
rej_ids, kno_ids, pids = [], [], []
|
|
1532
1574
|
for err, fix in uniq:
|
|
1533
1575
|
# 1) 可路由的修复知识
|
|
1534
1576
|
kid = "fix_" + _sig(err + "\x00" + fix)
|
|
@@ -1540,17 +1582,31 @@ class MdCGOS(MdCG):
|
|
|
1540
1582
|
f"# 验证方式:行为日志(后续同类错误不再出现)\n"
|
|
1541
1583
|
f"# 不适用条件:与「{err[:30]}」不同的错误\n\n"
|
|
1542
1584
|
f"错误:{err}\n修复:{fix}\n")
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1585
|
+
if as_proposals:
|
|
1586
|
+
# 自动管线:入审核队列(判据指纹随提案落盘,复核者不能放宽;
|
|
1587
|
+
# payload_hash 幂等——同内容重试返回原 pid)
|
|
1588
|
+
pid = self.propose(
|
|
1589
|
+
kid, content, layer="knowledge", tags=["fix_pair"],
|
|
1590
|
+
verify={"kind": "data",
|
|
1591
|
+
"assertions": ["error/fix 均非空且来自真实行为日志",
|
|
1592
|
+
"与既有 fix_pair 知识不重复"]})
|
|
1593
|
+
pids.append(pid)
|
|
1594
|
+
else:
|
|
1595
|
+
self.add(kid, content, layer="knowledge", tags=["fix_pair"],
|
|
1596
|
+
verification_basis="data", importance=0.7)
|
|
1597
|
+
kno_ids.append(kid)
|
|
1546
1598
|
# 2) 负记忆:这个错误不是死路(防止重复深挖)
|
|
1547
1599
|
rid = self.add_rejected(
|
|
1548
1600
|
hypothesis=f"「{err[:60]}」需要深挖根因(无现成解法)",
|
|
1549
1601
|
reason=f"已有修复:{fix[:80]}",
|
|
1550
1602
|
verification_basis="data", tags=["fix_pair"])
|
|
1551
1603
|
rej_ids.append(rid)
|
|
1552
|
-
|
|
1553
|
-
|
|
1604
|
+
result = {"pairs": [{"error": e, "fix": f} for e, f in uniq],
|
|
1605
|
+
"rejected_ids": rej_ids, "knowledge_ids": kno_ids}
|
|
1606
|
+
if as_proposals:
|
|
1607
|
+
result["as_proposals"] = True
|
|
1608
|
+
result["pids"] = pids
|
|
1609
|
+
return result
|
|
1554
1610
|
|
|
1555
1611
|
# ================= 4. 审核队列(inbox → decisions) =================
|
|
1556
1612
|
|
|
@@ -3603,6 +3659,7 @@ class MdCGSecure(MdCGOS):
|
|
|
3603
3659
|
res, meta = super().search_rrf(*a, **kw)
|
|
3604
3660
|
validity = kw.get("validity")
|
|
3605
3661
|
view = kw.get("view")
|
|
3662
|
+
session = kw.get("session")
|
|
3606
3663
|
now = time.time() if validity else None
|
|
3607
3664
|
_en_t, _ax_t, _why_t = trust.check_time_args(
|
|
3608
3665
|
kw.get("start_time"), kw.get("end_time"), kw.get("start_operator"),
|
|
@@ -3612,6 +3669,11 @@ class MdCGSecure(MdCGOS):
|
|
|
3612
3669
|
e = self.index["nodes"].get(r[0]["id"], r[0])
|
|
3613
3670
|
if not self._readable(e):
|
|
3614
3671
|
continue
|
|
3672
|
+
# 会话归属同为候选资格:图扩展会把**别的会话**的节点顺着边带回来,
|
|
3673
|
+
# 绕过 _candidates 的会话过滤 → 自动召回照样串台。故与 validity/view
|
|
3674
|
+
# 一并在此兜底("*" = 跨会话视图,不过滤)。
|
|
3675
|
+
if session and session != "*" and e.get("session") != session:
|
|
3676
|
+
continue
|
|
3615
3677
|
if view is not None and not roleviews.matches(e, view):
|
|
3616
3678
|
continue
|
|
3617
3679
|
if validity and trust.is_expired(e, now=now):
|
|
@@ -3641,9 +3703,13 @@ class MdCGSecure(MdCGOS):
|
|
|
3641
3703
|
self.principal.require_admin("restore")
|
|
3642
3704
|
return super().restore(node_id, force=force)
|
|
3643
3705
|
|
|
3644
|
-
# 生效条件:先 principal.
|
|
3706
|
+
# 生效条件:先 principal.require_op("review")(语义修正 2026-09-22:裁决权从
|
|
3707
|
+
# require_admin 拆出——编排者/仲裁位持 review op 即可裁决,存在级管理权
|
|
3708
|
+
# (forget/protect/anchor 写)仍由 require_admin 把守、designer 专属;
|
|
3709
|
+
# designer ops=["*"] 天然兼容),再把 *a/**kw 原样转给 super().review_decide;
|
|
3710
|
+
# accept/edit 落节点时的层写仍由下游 require_layer_write 按裁决者可写层拦截。
|
|
3645
3711
|
def review_decide(self, *a, **kw):
|
|
3646
|
-
self.principal.
|
|
3712
|
+
self.principal.require_op("review")
|
|
3647
3713
|
return super().review_decide(*a, **kw)
|
|
3648
3714
|
|
|
3649
3715
|
# 生效条件:先 principal.require_admin("evolution_rollback"),再转 super().evolution_rollback(entry_id, dry_run=dry_run, note=note)。
|