Skip to main content

Module write_gate

Module write_gate 

Source
Expand description

Write gate — V8 S5 stage 2c (MEMORY_TYPOLOGY_V8.md §3).

Ordered gates on the memory-create path, sitting in the dispatch pipeline between resource rules (Yama) and the rate limiter:

  1. Junk filter — template match against the telemetry recognizer (wm_memory::typology::detect_class).
  2. Dedup gate — content-hash lookup; on hit the write is prevented: dup_count bumps, accessed_at refreshes, and the existing row’s importance decays (imp /= 1 + dup_count) — the friction path’s post-hoc pattern (rsi.rs) moved to the write path. For batch writes, duplicate items are dropped from the payload instead of short-circuiting.
  3. Plausibility gate — class-based ceilings/floors (apply_class_policy): a telemetry record can never outrank a session decision by construction.

The budget gate (per-class write budgets, ring-buffered telemetry) is deliberately not implemented in v0 — the write_budget.json ledger is telemetry today; making it a gate is its own evidence-gated step.

Scope: memory.create and memory.batch_create — the generic fresh- write tools — plus the plausibility arm of memory.update (V8 S11d). Every other tool passes untouched; the session-record path keeps its role-derived stamping (shipped 68547b9), and the RSI recorder keeps its own dedup (it is the pattern’s origin).

Update carries no junk filter and no dedup short-circuit: a targeted id rewrite is never silently dropped or rewritten into something else — only the importance ceiling/floor follows the resulting content’s class. Cross-row content identity stays a harvest/dedupe concern.

Disclosure: gate decisions ride the response as a write_gate object (attached by the pipeline, mirroring the resource_flags pattern) — a gate that acts silently is a gate nobody can audit.

Structs§

GateOutcome
What the gate decided for one dispatch.
WriteGate
The write gate. Holds the store for the dedup lookup + bump.

Functions§

parse_importance_value
Parse an importance argument leniently.