dsh-plugin-xujie-memory 0.5.0 → 0.7.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.
Files changed (84) hide show
  1. package/ACCEPTANCE.md +37 -0
  2. package/BUILD-PROVENANCE.json +53 -0
  3. package/CHANGELOG.md +40 -1
  4. package/LICENSE +21 -21
  5. package/README.md +67 -17
  6. package/README_EN.md +54 -8
  7. package/cordis.patch.yml +49 -49
  8. package/lib/client.js +17219 -0
  9. package/lib/controller.js +307 -0
  10. package/lib/index.js +200 -14
  11. package/lib/typert.host.d.ts +3 -0
  12. package/lib/typert.host.js +15104 -0
  13. package/lib/typert.remote-client.d.ts +40 -0
  14. package/lib/typert.remote-client.d.ts.map +1 -0
  15. package/lib/typert.remote-client.js +15093 -0
  16. package/lib/types.d.ts +13 -0
  17. package/lib/types.js +1 -0
  18. package/package.json +49 -5
  19. package/python/specs/characters/aloof.json +14 -14
  20. package/python/specs/characters/gentle.json +14 -14
  21. package/python/specs/characters/tsundere.json +14 -14
  22. package/python/specs/debt.v1.json +31 -31
  23. package/python/specs/nickname.v1.json +16 -16
  24. package/python/specs/preference.v1.json +16 -16
  25. package/python/xujie_memory/__init__.py +123 -123
  26. package/python/xujie_memory/admission.py +211 -211
  27. package/python/xujie_memory/audit.py +377 -377
  28. package/python/xujie_memory/benchmark.py +281 -281
  29. package/python/xujie_memory/character.py +199 -199
  30. package/python/xujie_memory/console.py +41 -41
  31. package/python/xujie_memory/consolidate.py +356 -356
  32. package/python/xujie_memory/due.py +121 -121
  33. package/python/xujie_memory/emotion.py +573 -573
  34. package/python/xujie_memory/engine.py +1333 -1312
  35. package/python/xujie_memory/errors.py +98 -98
  36. package/python/xujie_memory/importance.py +104 -104
  37. package/python/xujie_memory/judge.py +350 -350
  38. package/python/xujie_memory/management.py +203 -0
  39. package/python/xujie_memory/memory.py +71 -10
  40. package/python/xujie_memory/orchestrator.py +690 -666
  41. package/python/xujie_memory/phrasing.py +292 -292
  42. package/python/xujie_memory/privacy.py +105 -0
  43. package/python/xujie_memory/schema.sql +492 -480
  44. package/python/xujie_memory/server.py +76 -0
  45. package/python/xujie_memory/specs.py +170 -170
  46. package/python/xujie_memory/summary.py +238 -238
  47. package/scripts/build.mjs +19 -0
  48. package/scripts/prepack.mjs +9 -0
  49. package/scripts/test-all.mjs +9 -0
  50. package/scripts/test-node.mjs +10 -0
  51. package/src/client/MemoryPanel.tsx +536 -0
  52. package/src/client/NeuralField.tsx +88 -0
  53. package/src/client/css.d.ts +4 -0
  54. package/src/client/icons.tsx +28 -0
  55. package/src/client/index.tsx +59 -0
  56. package/src/client/memory-adapter.ts +67 -0
  57. package/src/client/model.ts +79 -0
  58. package/src/client/neural/engine.ts +999 -0
  59. package/src/client/neural/morphology.ts +219 -0
  60. package/src/client/panel.css +337 -0
  61. package/src/client/types.ts +6 -0
  62. package/src/controller.ts +88 -0
  63. package/src/generated/typert.host.js +449 -0
  64. package/src/generated/typert.remote-client.js +438 -0
  65. package/src/index.ts +2 -0
  66. package/src/types.ts +13 -0
  67. package/test/cordis-fixture.mjs +5 -0
  68. package/test/management_regression.py +187 -0
  69. package/test/node-regression.entry.mjs +52 -0
  70. package/vendor/DSH-LICENSE.txt +21 -0
  71. package/vendor/THIRD-PARTY.md +6 -0
  72. package/vendor/dsh-protocol/index.ts +484 -0
  73. package/vendor/dsh-protocol/json-value.ts +53 -0
  74. package/vendor/dsh-protocol/owned-value.ts +39 -0
  75. package/vendor/dsh-protocol/principal.ts +17 -0
  76. package/vendor/dsh-protocol/remote-access.ts +38 -0
  77. package/vendor/dsh-protocol/remote-error.ts +49 -0
  78. package/vendor/dsh-protocol/remote-info.ts +161 -0
  79. package/vendor/dsh-protocol/types.ts +939 -0
  80. package/vendor/licenses/jridgewell-gen-mapping-MIT.txt +19 -0
  81. package/vendor/licenses/jridgewell-resolve-uri-MIT.txt +19 -0
  82. package/vendor/licenses/jridgewell-sourcemap-codec-MIT.txt +19 -0
  83. package/vendor/licenses/jridgewell-trace-mapping-MIT.txt +19 -0
  84. package/vendor/licenses/zod-MIT.txt +21 -0
@@ -0,0 +1,105 @@
1
+ """Removal of active projections that depend on explicitly erased evidence.
2
+
3
+ This is logical application erasure, not forensic disk erasure: SQLite WAL,
4
+ external exports/backups and the DSH conversation log are outside this API.
5
+ Audit identifiers, timestamps and hashes are retained, not replacement facts.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import json
10
+
11
+
12
+ def repair_legacy(engine, profiles) -> None:
13
+ """Once-only sweep for projections left by 0.6's incomplete forgetting."""
14
+ with engine._tx() as conn:
15
+ if conn.execute(
16
+ "SELECT 1 FROM memory_maintenance WHERE name='privacy_repair_070'"
17
+ ).fetchone():
18
+ return
19
+ scopes = set()
20
+ for row in conn.execute(
21
+ "SELECT trace_id,scope_id FROM traces WHERE erased_at IS NOT NULL"
22
+ ).fetchall():
23
+ keys = [r[0] for r in conn.execute(
24
+ "SELECT DISTINCT e.state_key FROM events e JOIN event_evidence v"
25
+ " ON e.event_id=v.event_id WHERE v.trace_id=?", (row["trace_id"],)
26
+ ).fetchall()]
27
+ purge_derived(engine, conn, row["trace_id"], keys)
28
+ scopes.add(row["scope_id"])
29
+ for scope in scopes:
30
+ for profile in profiles.profiles(scope):
31
+ profiles.derive_from_memory(scope, profile["account_id"])
32
+ conn.execute(
33
+ "INSERT INTO memory_maintenance(name,completed_at) VALUES (?,?)",
34
+ ("privacy_repair_070", engine.now()),
35
+ )
36
+
37
+
38
+ def purge_derived(engine, conn, trace_id: str, state_keys: list[str]) -> None:
39
+ trace = conn.execute(
40
+ "SELECT scope_id FROM traces WHERE trace_id=?", (trace_id,)
41
+ ).fetchone()
42
+ if trace is None:
43
+ return
44
+ scope = trace["scope_id"]
45
+ # Merged summaries retain the original trace ids in input_refs_json too.
46
+ # Clear content, not merely the active flag; otherwise it survives in detail.
47
+ for row in conn.execute(
48
+ "SELECT summary_id,input_refs_json FROM summaries WHERE scope_id=?", (scope,)
49
+ ).fetchall():
50
+ try:
51
+ refs = json.loads(row["input_refs_json"])
52
+ except (TypeError, ValueError):
53
+ # An unreadable dependency cannot safely remain model-visible.
54
+ refs = [trace_id]
55
+ if trace_id in refs:
56
+ conn.execute(
57
+ "UPDATE summaries SET text='',lifecycle_state='archived',"
58
+ "coverage_json='{}',omissions_json='[]' WHERE summary_id=?",
59
+ (row["summary_id"],),
60
+ )
61
+ conn.execute(
62
+ "UPDATE clarifications SET status='dismissed',detail_json='{}'"
63
+ " WHERE scope_id=? AND EXISTS ("
64
+ " SELECT 1 FROM json_each(clarifications.interpretation_ids_json) j"
65
+ " JOIN interpretations i ON i.interpretation_id=j.value"
66
+ " WHERE i.trace_id=?)", (scope, trace_id),
67
+ )
68
+ conn.execute(
69
+ "UPDATE encodings SET payload_json='{}' WHERE trace_id=?", (trace_id,)
70
+ )
71
+ conn.execute(
72
+ "UPDATE interpretations SET slots_json='{}',signals_json='{}' WHERE trace_id=?",
73
+ (trace_id,),
74
+ )
75
+ conn.execute(
76
+ "UPDATE events SET payload_json='{}' WHERE void=1 AND event_id IN"
77
+ " (SELECT event_id FROM event_evidence WHERE trace_id=?)", (trace_id,),
78
+ )
79
+ conn.execute(
80
+ "UPDATE person_tags SET value='',status='expired' WHERE scope_id=?"
81
+ " AND evidence_trace_id=?", (scope, trace_id),
82
+ )
83
+ conn.execute(
84
+ "UPDATE profile_alerts SET signals_json='{}',status='dismissed',resolved_at=?"
85
+ " WHERE scope_id=? AND evidence_trace_id=?", (engine.now(), scope, trace_id),
86
+ )
87
+ for table in ("emotion_events", "relationship_events"):
88
+ conn.execute(
89
+ f"DELETE FROM {table} WHERE scope_id=? AND evidence_trace_id=?",
90
+ (scope, trace_id),
91
+ )
92
+ conn.execute(
93
+ "DELETE FROM grievances WHERE scope_id=? AND evidence_trace_id=?",
94
+ (scope, trace_id),
95
+ )
96
+ conn.execute(
97
+ "UPDATE lifecycle SET anchor=0,level='archived'"
98
+ " WHERE scope_id=? AND ref_type='trace' AND ref_id=?", (scope, trace_id),
99
+ )
100
+ for key in state_keys:
101
+ conn.execute("DELETE FROM state_snapshots WHERE state_key=?", (key,))
102
+ conn.execute(
103
+ "UPDATE states SET last_known_json=NULL WHERE state_key=?"
104
+ " AND status NOT IN ('known','stale')", (key,),
105
+ )