@furongjun1999/dsh-memory 0.4.7 → 0.4.9
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 +130 -47
- package/codebuddy/CODEBUDDY.md +21 -10
- package/codebuddy/README.md +13 -1
- package/codebuddy/mcp.json +9 -0
- 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 -0
- 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 -0
- package/docs/README.md +111 -0
- package/docs/discipline/harnesses.yaml +226 -152
- package/docs/discipline/templates/full.md.tmpl +61 -58
- package/docs/eval//347/254/254/344/270/211/346/226/271/351/252/214/350/257/201/346/212/245/345/221/212_LoCoMo_/347/201/265/346/236/242_.md +127 -0
- package/docs/eval//347/254/254/344/270/211/346/226/271/351/252/214/350/257/201/346/212/245/345/221/212_LoCoMo_/347/201/265/346/236/242_.png +0 -0
- package/docs/eval//347/254/254/344/270/211/346/226/271/351/252/214/350/257/201/346/212/245/345/221/212_/347/201/265/346/236/242_vs_dejavu_/347/273/237/344/270/200/350/257/204/345/210/206_v7.md +202 -0
- package/docs/experiments/linkref_backfill/candidates_20260917.json +726 -0
- package/docs/experiments/linkref_backfill/candidates_internal_20260917.json +602 -0
- package/docs/experiments/linkref_backfill/candidates_internal_v2.json +603 -0
- package/docs/experiments/linkref_backfill/candidates_secret_20260917.json +884 -0
- package/docs/experiments/linkref_backfill/candidates_secret_v2.json +789 -0
- package/docs/experiments/m4-role-probe/census.py +86 -0
- package/docs/experiments/m4-role-probe/probe.py +89 -0
- package/docs/experiments/mapped_confidence/bench_mapped_conf.py +216 -0
- package/docs/experiments/mapped_confidence/post_check.py +75 -0
- package/docs/experiments/mapped_confidence/repro_thirdparty_tol.py +83 -0
- package/docs/experiments/mapped_confidence/result_mapped_conf.json +215 -0
- package/docs/hive//345/244/232/347/253/257harness/351/200/232/344/277/241/345/245/221/347/272/246_v0.1.md +42 -0
- 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 -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 -0
- package/docs/hive//347/234/237/345/256/236/345/272/223/347/253/257/345/210/260/347/253/257/345/256/236/346/265/213_S1b/344/270/216/345/217/254/345/233/236/346/235/203/350/241/241_v0.1.md +57 -0
- package/docs/hive//347/234/237/345/256/236/345/272/223/347/253/257/345/210/260/347/253/257/345/256/236/346/265/213_S7/345/200/222/346/216/222/345/200/231/351/200/211/345/261/202_v0.1.md +126 -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 -0
- 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 +14 -2
- package/docs/mdcg/D_meta_/345/267/245/347/250/213/345/214/226/346/226/271/346/241/210_v0.2.md +216 -0
- package/docs/{README → mdcg/README}/350/257/246/347/273/206/347/211/210_v0.4.5.md +631 -625
- package/docs/{ → mdcg/}/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 +1 -1
- package/docs/mdcg//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_/345/245/221/347/272/246_v0.1.md +82 -0
- 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 -0
- 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 +263 -0
- 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 +1 -1
- package/docs/mdcg//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 -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 +2 -2
- package/docs/{ → mdcg/}/347/201/265/346/236/242/344/270/211/345/261/202/346/213/206/345/210/206/350/247/204/345/210/222_v0.1.md +181 -181
- 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 -0
- package/docs/mdcg//347/216/257/344/272/214_/347/231/275/347/256/261/345/241/253/345/205/205/346/265/201/346/260/264/347/272/277_v0.1.md +31 -0
- package/docs/{ → mdcg/}/347/274/272/345/217/243/345/215/225_P0/346/224/266/345/217/243_v0.1.md +2 -2
- 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 +1 -1
- 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 +4 -4
- package/docs/{ → mdcg/}/350/256/260/345/277/206/346/223/215/344/275/234/347/263/273/347/273/237_MdCGOS/344/270/216MCP/346/216/245/345/205/245_v0.1.md +2 -2
- package/docs/mdcg//350/267/250/347/253/257/351/252/214/350/257/201/344/270/216/345/220/214/346/255/245/345/215/217/350/256/256_v0.1.md +93 -0
- 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 -0
- package/docs/{ → swarm/}/350/234/202/347/276/244/344/272/222/350/201/224_v0.1.md +3 -3
- 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 -0
- 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 -0
- 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 -0
- 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 -0
- 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 +6 -6
- 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 +1 -1
- 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 -0
- 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 -0
- package/docs//345/255/230/347/256/227/344/270/200/344/275/223/346/236/266/346/236/204/345/255/246/344/271/240_/345/244/226/351/203/250/347/220/206/350/256/272/345/257/271/347/205/247/344/270/216/350/267/257/347/272/277/344/272/244/346/216/245_20260916.md +98 -0
- package/docs//345/255/230/347/256/227/344/270/200/344/275/223/347/245/236/347/273/217/347/275/221/347/273/234/346/236/266/346/236/204_/346/200/273/347/272/262/344/270/216/344/272/244/346/216/245_20260916.md +109 -0
- 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 +434 -405
- package/docs//347/201/265/346/236/242/350/207/252/346/210/221/346/224/271/350/277/233/345/267/245/344/275/234/350/256/241/345/210/222_/345/244/226/351/203/250/347/240/224/347/251/266/347/263/273/345/210/227/345/220/270/346/224/266_v1_20260919.md +286 -0
- package/docs//347/231/275/347/256/261/345/214/226/347/272/262/351/242/206_/344/270/211/351/241/271/347/233/256/345/255/246/344/271/240/346/200/273/346/236/266/346/236/204/344/270/216Ghidra/344/272/244/346/216/245_20260916.md +104 -0
- package/docs//350/256/260/345/277/206/350/257/204/345/256/241/347/263/273/347/273/237_/347/253/213/351/241/271/350/256/276/350/256/241/344/270/216/346/226/275/345/267/245/344/272/244/346/216/245_20260915.md +183 -0
- package/dsh/README.md +34 -1
- package/dsh/cordis.yml.example +13 -7
- package/dsh/hive-mcp-probe.mjs +94 -0
- package/dsh/hive-mcp.example.yml +62 -0
- package/dsh/update-lingshu.bat +11 -0
- package/dsh/update-lingshu.ps1 +337 -0
- package/lib/hooks.d.ts +8 -0
- package/lib/hooks.js +27 -24
- package/lib/index.d.ts +4 -2
- package/lib/index.js +29 -6
- package/lib/lib/datapath.d.ts +76 -1
- package/lib/lib/datapath.js +199 -13
- package/lib/lib/mdcg_client.d.ts +6 -3
- package/lib/lib/mdcg_client.js +6 -5
- package/lib/lib/mutual.js +4 -4
- package/lib/lib/prompt_safety.d.ts +48 -0
- package/lib/lib/prompt_safety.js +62 -0
- package/lib/lib/token_store.js +4 -5
- package/md_cg/audit.py +91 -2
- package/md_cg/autonomy.py +86 -15
- package/md_cg/backfill.py +36 -1
- package/md_cg/backfill_bigdomain.py +34 -0
- package/md_cg/bench6_arms.py +28 -1
- package/md_cg/bench6_common.py +10 -1
- package/md_cg/bench6_competitors.py +6 -1
- package/md_cg/bench_axis_domain.py +9 -1
- package/md_cg/bench_blind_comp.py +7 -1
- package/md_cg/bench_en_atoms_public.py +9 -0
- package/md_cg/bench_governance.py +348 -0
- package/md_cg/bench_lme_zh.py +16 -1
- package/md_cg/bench_locomo.py +2 -1
- package/md_cg/bench_locomo_zh.py +16 -1
- package/md_cg/bench_locomo_zh_public.py +4 -1
- package/md_cg/bench_longmem.py +2 -1
- package/md_cg/bench_membench.py +37 -6
- package/md_cg/bench_p0.py +4 -1
- package/md_cg/bench_progressive.py +61 -10
- package/md_cg/bench_role_views.py +238 -0
- package/md_cg/bench_task_ab.py +8 -1
- package/md_cg/bench_task_ab_llm.py +13 -1
- package/md_cg/bench_unified_en.py +6 -1
- package/md_cg/bench_zh_mad.py +20 -1
- package/md_cg/blindspot_tickets.py +123 -0
- package/md_cg/branches.py +286 -0
- package/md_cg/build_postings.py +73 -0
- package/md_cg/ccgc.py +949 -0
- package/md_cg/census.py +5 -1
- package/md_cg/chain.py +24 -3
- package/md_cg/codeindex.py +134 -17
- package/md_cg/coldverify.py +265 -0
- package/md_cg/comment_gate.py +338 -0
- package/md_cg/cond_compose.py +190 -0
- package/md_cg/cond_facts.py +155 -0
- package/md_cg/cond_template.json +107 -0
- package/md_cg/condition_anchor.py +143 -0
- package/md_cg/conformance.py +727 -0
- package/md_cg/consistency.py +25 -2
- package/md_cg/consolidate.py +53 -2
- package/md_cg/corpus.py +5 -1
- package/md_cg/crosscheck.py +42 -2
- package/md_cg/crypto.py +35 -1
- package/md_cg/d_meta.py +310 -0
- package/md_cg/datapath.py +201 -26
- package/md_cg/docindex.py +122 -1
- package/md_cg/eval_common.py +35 -6
- package/md_cg/evidence.py +27 -1
- package/md_cg/evolution.py +21 -1
- package/md_cg/export.py +11 -1
- package/md_cg/forgetting.py +34 -4
- package/md_cg/fsutil.py +81 -2
- package/md_cg/hotcache.py +214 -0
- package/md_cg/hyperedge.py +251 -0
- package/md_cg/identity.py +20 -3
- package/md_cg/insight.py +19 -3
- package/md_cg/lexicon/build_cedict_en_zh.py +9 -0
- package/md_cg/lexicon/build_standard_en.py +171 -168
- package/md_cg/lexicon/expand_en_zh.py +6 -0
- package/md_cg/lifecycle.py +273 -0
- package/md_cg/linkref.py +281 -0
- package/md_cg/links.py +29 -1
- package/md_cg/mcp_server.py +894 -168
- package/md_cg/md_whitebox.py +53 -1
- package/md_cg/mdcg.py +1205 -41
- package/md_cg/mdcos.py +1060 -76
- package/md_cg/metacognition.py +39 -4
- package/md_cg/migrate.py +4 -0
- package/md_cg/migrate_aeis.py +221 -213
- package/md_cg/migrate_roleplay.py +8 -0
- package/md_cg/migrate_wisdom_graph.py +14 -1
- package/md_cg/mreview/__init__.py +25 -0
- package/md_cg/mreview/__main__.py +110 -0
- package/md_cg/mreview/bundle.py +178 -0
- package/md_cg/mreview/candidates.py +262 -0
- package/md_cg/mreview/govern.py +694 -0
- package/md_cg/mreview/locate.py +939 -0
- package/md_cg/mreview/pipeline.py +729 -0
- package/md_cg/mreview/rules/duplication.json +21 -0
- package/md_cg/mreview/rules/field_coverage.json +54 -0
- package/md_cg/mreview/rules/source_license.json +21 -0
- package/md_cg/mreview/rules/template_flow.json +21 -0
- package/md_cg/mreview/ruleset.py +253 -0
- package/md_cg/nodefile.py +269 -1
- package/md_cg/pooling.py +23 -1
- package/md_cg/postings.py +298 -0
- package/md_cg/predict.py +113 -15
- package/md_cg/progressive.py +3 -0
- package/md_cg/protect.py +18 -5
- package/md_cg/protocol.py +372 -0
- package/md_cg/provenance.py +262 -0
- package/md_cg/reach.py +453 -0
- package/md_cg/refindex.py +88 -4
- package/md_cg/refine.py +20 -1
- package/md_cg/roleviews.py +89 -0
- package/md_cg/routing.py +76 -0
- package/md_cg/scrub.py +68 -3
- package/md_cg/security.py +26 -1
- package/md_cg/self_state.py +65 -2
- package/md_cg/selfreport.py +151 -0
- package/md_cg/semantic/canonical.py +5 -0
- package/md_cg/semantic/en_normalizer.py +364 -295
- package/md_cg/semantic/zh_en_atoms.py +139 -136
- package/md_cg/signer.py +41 -1
- package/md_cg/sources.py +583 -547
- package/md_cg/statushdr.py +179 -0
- package/md_cg/stg.py +59 -18
- package/md_cg/subgraph.py +23 -0
- package/md_cg/sustain.py +74 -1
- package/md_cg/tasks.py +471 -0
- package/md_cg/test_action_derive.py +203 -0
- package/md_cg/test_audit_rotate.py +270 -0
- package/md_cg/test_autonomy.py +26 -0
- package/md_cg/test_bench_governance.py +102 -0
- package/md_cg/test_blindspot_tickets.py +166 -0
- package/md_cg/test_branches.py +249 -0
- package/md_cg/test_ccg_perturb.py +1 -1
- package/md_cg/test_ccgc.py +433 -0
- package/md_cg/test_codeindex.py +338 -0
- package/md_cg/test_comment_gate.py +187 -0
- package/md_cg/test_cond_compose_anchors.py +76 -0
- package/md_cg/test_condition_anchor.py +82 -0
- package/md_cg/test_conformance.py +343 -0
- package/md_cg/test_d_meta.py +412 -0
- package/md_cg/test_datapath_root.py +188 -0
- package/md_cg/test_en_pipeline.py +24 -0
- package/md_cg/test_gain_gate.py +47 -1
- package/md_cg/test_health_scale.py +173 -0
- package/md_cg/test_hot_cold.py +187 -0
- package/md_cg/test_hyperedge.py +245 -0
- package/md_cg/test_identity_attribution.py +6 -0
- package/md_cg/test_index_durability.py +224 -0
- package/md_cg/test_lifecycle.py +309 -0
- package/md_cg/test_linkref.py +306 -0
- package/md_cg/test_md_access_parity.py +15 -3
- package/md_cg/test_mr_m1.py +769 -0
- package/md_cg/test_mr_m2.py +587 -0
- package/md_cg/test_mr_m3.py +710 -0
- package/md_cg/test_mr_m4.py +485 -0
- package/md_cg/test_p1.py +1 -1
- package/md_cg/test_p11_consistency.py +1 -1
- package/md_cg/test_p12_metacognition.py +2 -2
- package/md_cg/test_p16_self_state.py +1 -1
- package/md_cg/test_p26_refindex.py +50 -21
- package/md_cg/test_p27_docindex.py +258 -4
- package/md_cg/test_p28_refcheck.py +1 -1
- package/md_cg/test_p29_session_ingest_export.py +1 -1
- package/md_cg/test_p2_mcp.py +7 -1
- package/md_cg/test_p31_insight.py +24 -0
- package/md_cg/test_p38_contextualize.py +1 -1
- package/md_cg/test_p39_vision_evidence.py +1 -1
- package/md_cg/test_p40_refine_worklist.py +1 -1
- package/md_cg/test_p41_evolve_patrol.py +1 -1
- package/md_cg/test_p42_provenance.py +1 -1
- package/md_cg/test_p43_pooling.py +41 -13
- package/md_cg/test_p44_md_whitebox.py +14 -1
- package/md_cg/test_protocol.py +243 -0
- package/md_cg/test_reach.py +378 -0
- package/md_cg/test_reach_keys.py +201 -0
- package/md_cg/test_reach_meta_exits.py +145 -0
- package/md_cg/test_read_clip.py +141 -0
- package/md_cg/test_retr_s1.py +340 -0
- package/md_cg/test_retr_s1b.py +209 -0
- package/md_cg/test_retr_s3.py +194 -0
- package/md_cg/test_retr_s4.py +163 -0
- package/md_cg/test_retr_s5.py +200 -0
- package/md_cg/test_retr_s6.py +157 -0
- package/md_cg/test_retr_s7.py +385 -0
- package/md_cg/test_retr_s8_time.py +316 -0
- package/md_cg/test_retr_s9_edges.py +286 -0
- package/md_cg/test_retr_s9_entity_ctx.py +175 -0
- package/md_cg/test_review_conformance.py +367 -0
- package/md_cg/test_role_views.py +354 -0
- package/md_cg/test_tasks.py +409 -0
- package/md_cg/test_tool_face.py +189 -0
- package/md_cg/test_trust.py +361 -0
- package/md_cg/test_twophase.py +286 -0
- package/md_cg/test_units_poll.py +71 -0
- package/md_cg/test_v14_fixes.py +397 -0
- package/md_cg/test_validity_filter.py +280 -0
- package/md_cg/test_wisdom_md_store.py +7 -3
- package/md_cg/test_writepipe.py +214 -0
- package/md_cg/theory.py +17 -2
- package/md_cg/tokens.py +134 -12
- package/md_cg/tool_face.py +261 -0
- package/md_cg/trust.py +943 -0
- package/md_cg/twophase.py +232 -0
- package/md_cg/units.py +665 -0
- package/md_cg/vision_evidence.py +25 -2
- package/md_cg/weights.py +25 -2
- package/md_cg/whitebox.py +33 -2
- package/md_cg/whitebox_kb/data/verify_cache.json +21233 -360
- package/md_cg/whitebox_kb/data/verify_savings.jsonl +5124 -0
- package/md_cg/whitebox_kb/wisdom/audit_log/chain_heat.json +10 -10
- package/md_cg/whitebox_kb/wisdom/code_compose.py +113 -6
- package/md_cg/whitebox_kb/wisdom/code_solidified.json +1 -1
- package/md_cg/whitebox_kb/wisdom/verifier.py +340 -55
- package/md_cg/whitebox_kb/wisdom/wisdom-book-cloud.db +0 -0
- package/md_cg/writelimit.py +37 -7
- package/md_cg/writepipe.py +543 -0
- package/package.json +2 -2
- package/skills/skills/designer-perspective/scripts/__pycache__/designer.cpython-310.pyc +0 -0
- package/skills/skills/designer-perspective/scripts/designer.py +17 -1
- package/skills/skills/designer-perspective/tests/selftest.py +3 -1
- package/src/hooks.ts +27 -22
- package/src/index.ts +33 -6
- package/src/lib/datapath.ts +211 -13
- package/src/lib/mdcg_client.ts +12 -8
- package/src/lib/mutual.ts +411 -411
- package/src/lib/prompt_safety.ts +62 -0
- package/src/lib/token_store.ts +4 -5
- package/zcode/AGENTS.md +21 -10
- package/zcode/README.md +4 -0
- package/docs//345/212/237/350/203/275/350/260/203/347/224/250/346/230/240/345/260/204/350/241/250_v0.1.md +0 -221
- /package/docs/{AGI → 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" +0 -0
- /package/docs/{AGI → 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" +0 -0
- /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" +0 -0
- /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" +0 -0
- /package/docs/{guardrail-charter.md → mdcg/guardrail-charter.md} +0 -0
- /package/docs/{lingshu_tutorial.html → mdcg/lingshu_tutorial.html} +0 -0
- /package/docs/{memory-assessment.html → mdcg/memory-assessment.html} +0 -0
- /package/docs/{memory_score.html → mdcg/memory_score.html} +0 -0
- /package/docs/{memory_score.png → mdcg/memory_score.png} +0 -0
- /package/docs/{release_v0.3.0.md → mdcg/release_v0.3.0.md} +0 -0
- /package/docs/{release_v0.4.5.md → mdcg/release_v0.4.5.md} +0 -0
- /package/docs/{tool_table_v0.3.0.md → mdcg/tool_table_v0.3.0.md} +0 -0
- /package/docs/{ → mdcg/}/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" +0 -0
- /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" +0 -0
- /package/docs/{ → mdcg/}/347/201/265/346/236/242MCP/345/267/245/345/205/267/346/200/273/350/241/250_v3.4.md" +0 -0
- /package/docs/{ → mdcg/}/347/201/265/346/236/242_/350/207/252/346/210/221/345/261/202/345/256/232/344/271/211.md" +0 -0
- /package/docs/{ → mdcg/}/350/256/244/347/237/245/345/233/276_MD/347/233/256/345/275/225/346/226/271/346/241/210_v0.1.md" +0 -0
- /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" +0 -0
- /package/docs/{ → mdcg/}/350/256/244/347/237/245/345/233/276/344/275/234/344/270/272/350/256/260/345/277/206/346/223/215/344/275/234/347/263/273/347/273/237_/350/257/204/344/274/260/344/270/216/350/267/257/347/272/277_v0.1.md" +0 -0
- /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" +0 -0
- /package/docs/{ → plans/}/347/237/245/350/257/206/345/233/276/350/260/261/351/241/271/347/233/256_/344/272/244/346/216/245/346/226/207/346/241/243_20260914.md" +0 -0
- /package/docs/{ → swarm/}/350/234/202/347/276/244/345/244/232/346/231/272/350/203/275/344/275/223_/344/275/277/347/224/250/346/212/245/345/221/212_20260913.md" +0 -0
- /package/docs/{ → swarm/}/350/234/202/347/276/244/345/244/232/346/231/272/350/203/275/344/275/223_/345/212/237/350/203/275/350/257/264/346/230/216_v0.6.md" +0 -0
- /package/docs/{ → swarm/}/350/234/202/347/276/244/347/233/262/345/214/272/346/240/207/350/256/260_v1.0.md" +0 -0
- /package/docs/{ → theory/}/344/277/241/346/201/257/345/267/256/344/270/272/344/273/200/344/271/210/345/277/205/347/204/266/345/255/230/345/234/250/344/270/224/350/207/252/347/204/266/346/211/251/345/244/247.md" +0 -0
- /package/docs/{ → theory/}/346/231/272/350/203/275/347/232/204/345/205/254/347/220/206/345/214/226/345/237/272/347/237/263.md" +0 -0
- /package/docs/{ → theory/}/346/231/272/350/203/275/347/232/204/350/256/244/347/237/245/350/277/207/347/250/213.md" +0 -0
- /package/docs/{ → theory/}/346/231/272/350/203/275/350/256/2723.4.md" +0 -0
- /package/docs/{ → theory/}/347/231/275/347/256/261/346/231/272/350/203/275/346/230/257/344/273/200/344/271/210/357/274/237.md" +0 -0
- /package/docs/{ → theory/}/347/231/275/347/256/261/346/231/272/350/203/275/347/263/273/345/210/227/302/267/347/254/254/344/272/224/347/257/207/357/274/232/350/256/251AI/347/234/237/346/255/243/350/243/205/344/270/212/350/256/260/345/277/206.md" +0 -0
package/md_cg/links.py
CHANGED
|
@@ -59,10 +59,12 @@ class LinkError(Exception):
|
|
|
59
59
|
# 存储
|
|
60
60
|
# --------------------------------------------------------------------------
|
|
61
61
|
|
|
62
|
+
# 生效条件:path 为真值(非 None/非空串)时直接返回 path;否则取 `os.environ.get(LINKS_FILE_ENV)`,其为真值时返回之;环境变量缺失或为空串(假值)时回落 DEFAULT_LINKS_FILE。
|
|
62
63
|
def links_file(path: str = None) -> str:
|
|
63
64
|
return path or os.environ.get(LINKS_FILE_ENV) or DEFAULT_LINKS_FILE
|
|
64
65
|
|
|
65
66
|
|
|
67
|
+
# 生效条件:p=links_file(path),仅当 `os.path.exists(p)` 为真且 json.load 得到 dict 且 `d.get("links")` 为 dict 时,`d.setdefault("schema", SCHEMA)`(已有 schema 键则保留原值)并返回 d;路径不存在、抛 OSError/ValueError、或 links 非 dict 时返回 `{"schema": SCHEMA, "links": {}, "updated_at": None}`。
|
|
66
68
|
def load(path: str = None) -> dict:
|
|
67
69
|
p = links_file(path)
|
|
68
70
|
if os.path.exists(p):
|
|
@@ -77,6 +79,7 @@ def load(path: str = None) -> dict:
|
|
|
77
79
|
return {"schema": SCHEMA, "links": {}, "updated_at": None}
|
|
78
80
|
|
|
79
81
|
|
|
82
|
+
# 生效条件:传入 data(dict)与可选 path 时,p=links_file(path),以 `dict(data)` 浅拷贝并强制覆盖 schema=SCHEMA、updated_at=time.time(),写入 p+".tmp"(目录名为空时 makedirs(".")),chmod 0o600 的 OSError 被吞,`os.replace(tmp, p)` 后返回 p。
|
|
80
83
|
def save(data: dict, path: str = None) -> str:
|
|
81
84
|
p = links_file(path)
|
|
82
85
|
os.makedirs(os.path.dirname(p) or ".", exist_ok=True)
|
|
@@ -94,22 +97,26 @@ def save(data: dict, path: str = None) -> str:
|
|
|
94
97
|
return p
|
|
95
98
|
|
|
96
99
|
|
|
100
|
+
# 生效条件:传入 peer 时,对 f"{peer}|{time.time()}|{os.getpid()}" 做 utf-8 编码的 sha256,返回 "lk_" 拼接 `hexdigest()` 的前 12 个十六进制字符(peer 为 None 时按 "None" 参与哈希)。
|
|
97
101
|
def _new_id(peer: str) -> str:
|
|
98
102
|
h = hashlib.sha256(f"{peer}|{time.time()}|{os.getpid()}".encode("utf-8"))
|
|
99
103
|
return "lk_" + h.hexdigest()[:12]
|
|
100
104
|
|
|
101
105
|
|
|
106
|
+
# 生效条件:传入 link(dict)与 action,构造含 at/action 的 rec 并并入 kw 中值非 None 的项;link 缺 "audit" 键时由 setdefault 建空列表后 append,link 已有 "audit" 列表则直接 append 一条记录(已有值为 None 等非列表时 append 会失败,源码未兜)。
|
|
102
107
|
def _audit(link: dict, action: str, **kw):
|
|
103
108
|
rec = {"at": time.time(), "action": action}
|
|
104
109
|
rec.update({k: v for k, v in kw.items() if v is not None})
|
|
105
110
|
link.setdefault("audit", []).append(rec)
|
|
106
111
|
|
|
107
112
|
|
|
113
|
+
# 生效条件:peer 为 None 或 strip 后为空串时返回空串 p;strip 后以 "agent:" 开头时原样返回 p;否则返回 "agent:" + p。
|
|
108
114
|
def _norm_peer(peer: str) -> str:
|
|
109
115
|
p = (peer or "").strip()
|
|
110
116
|
return p if (not p or p.startswith("agent:")) else "agent:" + p
|
|
111
117
|
|
|
112
118
|
|
|
119
|
+
# 生效条件:data.get("links") 为真 dict 时,peer 直接是键则返回 (peer, links[peer]);否则在 {peer, _norm_peer(peer)} 中匹配任一 link_id 或 link 的 peer_node_id 并返回首个 (lid, lk);均不匹配返回 (None, None)。
|
|
113
120
|
def _find(data: dict, peer: str):
|
|
114
121
|
"""按 link_id 或 peer_node_id 定位(容忍省略 `agent:` 前缀)。"""
|
|
115
122
|
links = data.get("links") or {}
|
|
@@ -122,6 +129,7 @@ def _find(data: dict, peer: str):
|
|
|
122
129
|
return None, None
|
|
123
130
|
|
|
124
131
|
|
|
132
|
+
# 生效条件:调用方传入 data(须含 "links" 映射)、lid、link 时,执行 `data["links"][lid] = link` 并 save(data, path),返回 link(data 无 "links" 键时该赋值抛 KeyError,源码未兜)。
|
|
125
133
|
def _commit(data: dict, lid: str, link: dict, path: str = None):
|
|
126
134
|
data["links"][lid] = link
|
|
127
135
|
save(data, path)
|
|
@@ -132,6 +140,7 @@ def _commit(data: dict, lid: str, link: dict, path: str = None):
|
|
|
132
140
|
# 版本对齐度 → 信任上限
|
|
133
141
|
# --------------------------------------------------------------------------
|
|
134
142
|
|
|
143
|
+
# 生效条件:以 `peer_theory or {}` 取 t,pv=`t.get("version") or t.get("theory_version")`;pv 为假值(None/空串)返回 aligned False、cap CAP_MISALIGNED、reason 为「对端未声明版本」;pv 在本地 theory.check() 的 accepted_versions(缺失时按 [])内返回 aligned True、cap CAP_ALIGNED;否则返回 aligned False、cap CAP_MISALIGNED 并附对端版本与本地集合。
|
|
135
144
|
def version_alignment(peer_theory: dict = None) -> dict:
|
|
136
145
|
"""对端版本 vs 本地认可集合 → `{aligned, cap, reason}`。"""
|
|
137
146
|
from .theory import check as _theory_check
|
|
@@ -151,6 +160,7 @@ def version_alignment(peer_theory: dict = None) -> dict:
|
|
|
151
160
|
"local_accepted": accepted, "peer_version": pv}
|
|
152
161
|
|
|
153
162
|
|
|
163
|
+
# 生效条件:cap 初始为 CAP_ALIGNED;`alignment.get("aligned")` 为假时 cap=min(cap, CAP_MISALIGNED);position_map 为假值(None 或空 dict)时 cap=min(cap, CAP_INCOMPLETE);返回该 cap(数值大小关系由常量定义,源码未在本段校验)。
|
|
154
164
|
def _cap_for(alignment: dict, position_map: dict = None) -> float:
|
|
155
165
|
cap = CAP_ALIGNED
|
|
156
166
|
if not alignment.get("aligned"):
|
|
@@ -160,6 +170,7 @@ def _cap_for(alignment: dict, position_map: dict = None) -> float:
|
|
|
160
170
|
return cap
|
|
161
171
|
|
|
162
172
|
|
|
173
|
+
# 生效条件:传入 position 时返回含 position、委派 `md_cg.weights` 得到的 dominant/secondary/excluded/order,以及 class(`_w.is_viewpoint(position)` 真取 VIEWPOINT,否则取 FUNCTIONAL)的字典,不修改任何状态。
|
|
163
174
|
def position_preference(position: str) -> dict:
|
|
164
175
|
"""该位置的分量偏好序(委派 `md_cg.weights`,纯结构、无数值)。
|
|
165
176
|
|
|
@@ -182,11 +193,13 @@ FUNCTIONAL = "functional"
|
|
|
182
193
|
# 签名载荷(确定性:同参数必同字节)
|
|
183
194
|
# --------------------------------------------------------------------------
|
|
184
195
|
|
|
196
|
+
# 生效条件:传入 body 时返回 `json.dumps(body, ensure_ascii=False, sort_keys=True, separators=(",", ":"))` 的 utf-8 编码字节。
|
|
185
197
|
def _canon(body: dict) -> bytes:
|
|
186
198
|
return json.dumps(body, ensure_ascii=False, sort_keys=True,
|
|
187
199
|
separators=(",", ":")).encode("utf-8")
|
|
188
200
|
|
|
189
201
|
|
|
202
|
+
# 生效条件:传入 peer_node_id 与可选 peer_theory/position_map 时,t=`peer_theory or {}`,返回 _canon 字节串,其中 theory_version 取 `t.get("version") or t.get("theory_version")`、theory_hash 取 `t.get("hash") or t.get("theory_hash")`、position_map 为 `(position_map or {})` 各项按 key 排序后值经 str() 的映射。
|
|
190
203
|
def handshake_payload(peer_node_id: str, peer_theory: dict = None,
|
|
191
204
|
position_map: dict = None) -> bytes:
|
|
192
205
|
t = peer_theory or {}
|
|
@@ -199,6 +212,7 @@ def handshake_payload(peer_node_id: str, peer_theory: dict = None,
|
|
|
199
212
|
})
|
|
200
213
|
|
|
201
214
|
|
|
215
|
+
# 生效条件:传入 peer_node_id、evidence、positive 时返回 _canon 字节串,evidence 经 str()(None 得 "None")、positive 经 bool()(0/""/None 得 False)。
|
|
202
216
|
def evidence_payload(peer_node_id: str, evidence: str, positive: bool) -> bytes:
|
|
203
217
|
return _canon({"peer_node_id": peer_node_id, "evidence": str(evidence),
|
|
204
218
|
"positive": bool(positive)})
|
|
@@ -208,6 +222,7 @@ def evidence_payload(peer_node_id: str, evidence: str, positive: bool) -> bytes:
|
|
|
208
222
|
# 握手(文档 §5.1 五步:① 声明 → ② 校验 → ③ 建档 → ④ 观察期;⑤ 转正见 promote)
|
|
209
223
|
# --------------------------------------------------------------------------
|
|
210
224
|
|
|
225
|
+
# 生效条件:peer_node_id 为假值(空串)时抛 LinkError,不以 agent: 开头的会被补前缀;ver.ok 为假时按 on_fail 取 reject 抛 LinkError、取 isolate 置 isolated、否则置 degraded,declared_charter 为假值时观察期按 PROBATION_SECONDS*2 计,未失败但版本不符仅记 version_misaligned 审计,正常路径返回 {'ok': True, 'link', 'alignment', 'signature'};
|
|
211
226
|
def handshake(peer_node_id: str, *, peer_theory: dict = None,
|
|
212
227
|
position_map: dict = None, declared_charter: bool = True,
|
|
213
228
|
subsystem: str = None, peer_signature: str = None,
|
|
@@ -306,6 +321,7 @@ def handshake(peer_node_id: str, *, peer_theory: dict = None,
|
|
|
306
321
|
# 观测(P_trust 更新 / 反例击穿)
|
|
307
322
|
# --------------------------------------------------------------------------
|
|
308
323
|
|
|
324
|
+
# 生效条件:peer 经 load(path)/_find 命中连接(未命中或 status 为 "withdrawn" 时抛 LinkError);`_signer.verify_for(...)` 返回值中 ok 非真时按 `ver.get("on_fail") or "degrade"` 处置——"reject" 抛 LinkError,其余置 isolated/degraded 后返回 ok False;验签通过则 delta=UP_STEP if positive else -DOWN_STEP,P_trust 置 `round(max(0.0, min(cap, before + delta)), 6)`(cap 取 `link.get("p_trust_cap") or 0.0`),负证据且新 P_trust<DEGRADE_BELOW 且原状态在 IN_TRUST 时降级,返回 ok True、link、delta。
|
|
309
325
|
def observe(peer: str, *, evidence: str, positive: bool = True,
|
|
310
326
|
subsystem: str = None, peer_signature: str = None,
|
|
311
327
|
path: str = None, signers_file: str = None,
|
|
@@ -370,6 +386,7 @@ def observe(peer: str, *, evidence: str, positive: bool = True,
|
|
|
370
386
|
# 状态迁移(宪章第二十二条响应阶梯)
|
|
371
387
|
# --------------------------------------------------------------------------
|
|
372
388
|
|
|
389
|
+
# 生效条件:status 不在 STATUS 中抛 LinkError;否则写入 link["status"]=status,status 为 "isolated" 时同时置 p_trust_cap=CAP_ISOLATED、p_trust=0.0,并写留痕(clause 为假值含 None/空串时回落「宪章第二十二条(响应阶梯)」),返回 link。
|
|
373
390
|
def _set_status(link: dict, status: str, *, actor: str = "system",
|
|
374
391
|
clause: str = None, reason: str = None):
|
|
375
392
|
if status not in STATUS:
|
|
@@ -384,6 +401,7 @@ def _set_status(link: dict, status: str, *, actor: str = "system",
|
|
|
384
401
|
return link
|
|
385
402
|
|
|
386
403
|
|
|
404
|
+
# 生效条件:传入 peer 与 status 时,先 load(path)/_find 定位(未命中抛 LinkError),再 `_set_status(link, status, actor=actor, reason=reason)` 并 `_commit(data, lid, link, path)`,返回 `{"ok": True, "link": link}`。
|
|
387
405
|
def _transition(peer, status, *, reason=None, path=None, actor="system"):
|
|
388
406
|
data = load(path)
|
|
389
407
|
lid, link = _find(data, peer)
|
|
@@ -394,6 +412,7 @@ def _transition(peer, status, *, reason=None, path=None, actor="system"):
|
|
|
394
412
|
return {"ok": True, "link": link}
|
|
395
413
|
|
|
396
414
|
|
|
415
|
+
# 生效条件:连接存在且 link["status"]=="probation" 且 float(link.get("probation_until") or 0) - time.time() <= 0 时置 normal、promoted_at,提交并返回 {'ok': True, 'link'};连接不存在、非 probation 或观察期未满均抛 LinkError。
|
|
397
416
|
def promote(peer: str, *, path: str = None, actor: str = "system") -> dict:
|
|
398
417
|
"""观察期满且无异常 → normal。"""
|
|
399
418
|
data = load(path)
|
|
@@ -412,16 +431,19 @@ def promote(peer: str, *, path: str = None, actor: str = "system") -> dict:
|
|
|
412
431
|
return {"ok": True, "link": link}
|
|
413
432
|
|
|
414
433
|
|
|
434
|
+
# 生效条件:传入 peer 时无条件返回 `_transition(peer, "degraded", reason=reason, path=path, actor=actor)`,reason/path/actor 原样透传。
|
|
415
435
|
def degrade(peer: str, *, reason: str = None, path: str = None,
|
|
416
436
|
actor: str = "system") -> dict:
|
|
417
437
|
return _transition(peer, "degraded", reason=reason, path=path, actor=actor)
|
|
418
438
|
|
|
419
439
|
|
|
440
|
+
# 生效条件:传入 peer 时无条件返回 `_transition(peer, "isolated", reason=reason, path=path, actor=actor)`,reason/path/actor 原样透传。
|
|
420
441
|
def isolate(peer: str, *, reason: str = None, path: str = None,
|
|
421
442
|
actor: str = "system") -> dict:
|
|
422
443
|
return _transition(peer, "isolated", reason=reason, path=path, actor=actor)
|
|
423
444
|
|
|
424
445
|
|
|
446
|
+
# 生效条件:传入 peer 时无条件返回 `_transition(peer, "withdrawn", reason=reason, path=path, actor=actor)`,reason/path/actor 原样透传(30 天冷静期不在本函数内校验)。
|
|
425
447
|
def withdraw(peer: str, *, reason: str = None, path: str = None,
|
|
426
448
|
actor: str = "system") -> dict:
|
|
427
449
|
"""声明退出(宪章第二十一条附 3:30 天冷静期由上层流程保证)。"""
|
|
@@ -432,6 +454,7 @@ def withdraw(peer: str, *, reason: str = None, path: str = None,
|
|
|
432
454
|
# 衰减(无观测向初值回归)
|
|
433
455
|
# --------------------------------------------------------------------------
|
|
434
456
|
|
|
457
|
+
# 生效条件:now 为假值(None 或 0)时回落 time.time();仅 status 属于 IN_TRUST 的链接参与,days=max(0, (now-last)/86400) 为 0 时跳过,否则按 DECAY_DAYS 算向 P_TRUST_INIT 回归后的 p_trust 与 decay,decay 绝对值 > 1e-9 才计入 changed 并 save,最终返回 {'ok': True, 'changed', 'count'};
|
|
435
458
|
def decay_all(*, path: str = None, now: float = None,
|
|
436
459
|
actor: str = "system") -> dict:
|
|
437
460
|
data = load(path)
|
|
@@ -465,6 +488,7 @@ def decay_all(*, path: str = None, now: float = None,
|
|
|
465
488
|
# 查询 / 自描述 / CLI
|
|
466
489
|
# --------------------------------------------------------------------------
|
|
467
490
|
|
|
491
|
+
# 生效条件:`_find(load(path), peer)` 命中时返回该 link;未命中时抛 LinkError。
|
|
468
492
|
def get(peer: str, *, path: str = None) -> dict:
|
|
469
493
|
lid, link = _find(load(path), peer)
|
|
470
494
|
if not link:
|
|
@@ -472,6 +496,7 @@ def get(peer: str, *, path: str = None) -> dict:
|
|
|
472
496
|
return link
|
|
473
497
|
|
|
474
498
|
|
|
499
|
+
# 生效条件:status 为真值时过滤掉 `link.get("status") != status` 的连接,subsystem 为真值时过滤掉 `link.get("subsystem") != subsystem` 的连接(两者为 None/空串则不过滤);返回 `{"file": links_file(path), "count": len(out), "links": out}`,out 按 (status, peer_node_id) 排序。
|
|
475
500
|
def ls(*, path: str = None, status: str = None, subsystem: str = None) -> dict:
|
|
476
501
|
data = load(path)
|
|
477
502
|
out = []
|
|
@@ -490,6 +515,7 @@ def ls(*, path: str = None, status: str = None, subsystem: str = None) -> dict:
|
|
|
490
515
|
return {"file": links_file(path), "count": len(out), "links": out}
|
|
491
516
|
|
|
492
517
|
|
|
518
|
+
# 生效条件:无 required 形参,调用即返回自描述 dict,其中 "file" 由无参 `links_file()` 决定(随 LINKS_FILE_ENV 环境变量与 DEFAULT_LINKS_FILE 回落变化),其余字段由 STATUS 列表与模块级常量(P_TRUST_INIT/UP_STEP/DOWN_STEP/DEGRADE_BELOW/DECAY_DAYS/PROBATION_SECONDS/CAP_*)拼成。
|
|
493
519
|
def catalog() -> dict:
|
|
494
520
|
return {
|
|
495
521
|
"layer": "连接层(蜂群互联层1)",
|
|
@@ -518,10 +544,12 @@ def catalog() -> dict:
|
|
|
518
544
|
}
|
|
519
545
|
|
|
520
546
|
|
|
547
|
+
# 生效条件:传入 obj 时执行 `print(json.dumps(obj, ensure_ascii=False, indent=1, default=str))`,无返回值(不可序列化对象经 default=str 转字符串)。
|
|
521
548
|
def _print(obj):
|
|
522
549
|
print(json.dumps(obj, ensure_ascii=False, indent=1, default=str))
|
|
523
550
|
|
|
524
551
|
|
|
552
|
+
# 生效条件:argv 为 None 时 argparse 取 sys.argv,子命令为 required;a.cmd 为 catalog/ls/handshake/observe/promote|degrade|isolate|withdraw/show/decay 时分别以 a.links_file(──links-file)、a.status、peer、a.evidence、`positive=not a.negative`、a.reason、a.signers_file 等分派执行;捕获 LinkError 打印到 stderr 并返回 2,否则返回 0(argparse 自身错误退出不在本段返回值内)。
|
|
525
553
|
def main(argv=None):
|
|
526
554
|
ap = argparse.ArgumentParser(
|
|
527
555
|
prog="python -m md_cg.links",
|
|
@@ -592,4 +620,4 @@ def main(argv=None):
|
|
|
592
620
|
|
|
593
621
|
|
|
594
622
|
if __name__ == "__main__":
|
|
595
|
-
sys.exit(main())
|
|
623
|
+
sys.exit(main())
|