How Experience Enters Memory

por Frank de Alcantara em 23/07/2026

How Experience Enters Memory

On day 90, Lia tells Aurora:

It is evening, so please suggest something without caffeine. Last time the mint tea worked well.

This short interaction contains several kinds of evidence. It identifies the current context as evening. It imposes a caffeine constraint on the present request. It refers to an earlier episode. It reports a favorable outcome for mint tea. It may suggest a preference, but one successful drink is not enough to prove a durable general preference.

A careless memory writer turns the entire message into one string and stores it. A more ambitious but equally careless writer asks a language model for facts, receives “Lia likes mint tea,” and commits that sentence as truth. The first design preserves evidence but exposes no useful structure. The second exposes structure by discarding the boundary between evidence and inference.

We need both. The original interaction must remain immutable and addressable. Every extracted object must retain an exact path back to it. Identity ambiguity, temporal uncertainty, modality, polarity, and contextual scope must survive extraction. Only then may a separate policy decide whether to commit, link, quarantine, ignore, or reject each candidate.

This is the sixth article in the Memory in Graphs series and the last article in Part II. Memory for Agents separated interaction history from selective memory. The Memory Multigraph defined independent graph objects for sources, claims, events, episodes, and relation occurrences. Time, Provenance, and Contradiction gave those objects temporal and epistemic contracts. We now build the write pipeline that must satisfy all three foundations.

1. Interaction is evidence, not memory

Let an interaction payload be (x). A naive writer applies a function (f) and immediately stores its output:

[ x \xrightarrow{f} \text{memory}. ]

This diagram hides every consequential question. Did (f) detect a phrase or infer a proposition? Did it resolve “she” to Lia? Did it interpret “last time” as a specific episode? Did it preserve “evening” as a scope restriction? Was the source authorized for durable personalization? Was the same delivery already processed?

The correct first output is a set of candidates:

[ f(x)=K={k_1,k_2,\ldots,k_n}. ]

A candidate is a typed hypothesis with evidence, not an accepted graph fact. An admission function (A) makes the later decision:

[ A(k_i)\in {\texttt{commit},\texttt{link},\texttt{quarantine}, \texttt{ignore},\texttt{reject}}. ]

For Lia’s message, the current caffeine constraint can be a high quality candidate because its wording and scope are explicit. The previous successful outcome can also be a candidate, although its exact episode identity remains uncertain. The broad proposition “Lia prefers mint tea” is weaker. It generalizes from one outcome and should not enter the trusted graph merely because it sounds plausible.

This separation produces an essential invariant:

Extraction may increase the number of hypotheses. Admission alone may increase the number of trusted memory objects.

The distinction also improves failure recovery. A better resolver can revisit quarantined candidates. A new extractor can rerun against the immutable source. A policy change can reevaluate candidates without pretending that the original interaction changed.

1.1 Solved exercises

Exercise 1.1. A user says, “The blue chair was comfortable.” Does this prove a general preference for blue furniture?

Solution. No. It supports an outcome about one chair in one episode. A general color preference is a separate and weaker hypothesis.

Exercise 1.2. Why not store every candidate and filter only during retrieval?

Solution. Untrusted candidates can affect consolidation, analytics, deletion scope, and future writes before retrieval. Admission protects the whole memory lifecycle.

Exercise 1.3. Does rejecting a candidate require deleting the source?

Solution. No. Source retention and memory admission are distinct policies. The source may remain available for audit or reprocessing.

Exercise 1.4. Which function is allowed to enlarge the trusted graph?

Solution. The admission function, after validation. Extraction only enlarges the candidate set.

Exercise 1.5. A model assigns confidence (0.99) to an unauthorized medical claim. May it commit?

Solution. No. Confidence cannot override authorization. Admission contains hard policy gates that are not probabilities.

2. The write contract and immutable source envelope

Before normalization or extraction, the system creates a source envelope:

[ s=(i,a,\tau_e,\tau_t,h,x,\alpha), ]

where (i) is source identity, (a) is the author or producing agent, (\tau_e) is event time, (\tau_t) is ingestion time, (h) is a payload hash, (x) is immutable content, and (\alpha) is the authorization scope.

The envelope answers questions that extracted claims cannot answer. Which exact bytes were processed? Who supplied them? When did the interaction occur? When did the memory service receive it? Which permission allowed processing? Is this delivery a retry? Which source must a deletion request reach?

Immutability does not mean infinite retention. It means that while a source exists under its retention policy, its identity never silently points to different content. Corrections arrive as new source events. Redactions create explicit derived views or tombstones. They do not rewrite evidence while leaving old derivations apparently valid.

Event time and ingestion time must remain separate. An offline device may deliver a day 80 note on day 90. The note occurred on day 80, but its transaction visibility cannot begin before day 90. MG05 defined this distinction for stored claims. The source envelope enforces it at the entrance.

The payload hash detects accidental content changes, but it is not automatically a delivery identity. Two independent messages can have identical text and identical hashes. Conversely, one messaging platform may assign a stable event identifier to retries even if transport metadata changes. The write contract therefore stores both an occurrence identity and a content fingerprint.

Authorization scope belongs in the envelope because permission is part of the evidence context. A message processed to answer the current turn is not automatically authorized for long term personalization. Admission must check the declared scope before persistence.

2.1 Solved exercises

Exercise 2.1. A day 40 diary entry is uploaded on day 55. What are (\tau_e) and (\tau_t)?

Solution. Event time is day 40. Ingestion time is day 55.

Exercise 2.2. Two users independently send “Mint tea worked well.” The hashes match. Are the sources duplicates?

Solution. Not necessarily. Equal content does not prove equal occurrence identity or common origin.

Exercise 2.3. Why record an author when the text contains “I”?

Solution. The pronoun depends on source context. Without the author field, resolving “I” requires guessing from content alone.

Exercise 2.4. May a payload hash replace the original content?

Solution. No. A hash can verify identity or integrity but cannot supply evidence spans or semantic context.

Exercise 2.5. A scope permits transient response generation but forbids retention. Which outcome follows?

Solution. The durable write is rejected even if extraction is correct. The current response may still use the interaction according to the transient scope.

3. Normalization and segmentation without source loss

Extractors rarely consume raw transport payloads directly. A normalization activity may decode text, apply Unicode normalization, remove channel markup, detect language, and divide content into turns or sentences. These operations create a processing view (N(x)):

[ x \xrightarrow{N_v} x’, ]

where (N_v) identifies the normalizer version.

The arrow must remain in provenance. The normalized view does not replace (x). It records an offset map

[ \mu:[b’,e’)\mapsto[b,e) ]

from each normalized span back to its source span. This map lets an auditor inspect the exact evidence even when normalization changes character length or removes markup.

Segmentation is semantic, not merely typographic. Lia’s first sentence establishes a current request and an evening context. The second refers to a previous episode and its outcome. Treating both as one undifferentiated chunk invites a model to attach “last time” to the current request. Splitting every sentence independently creates the opposite error because the second sentence depends on the same speaker and conversation.

A useful pipeline therefore preserves several boundaries:

  • source occurrence;
  • conversation turn;
  • sentence or clause;
  • quoted or attributed subsource;
  • episode window;
  • evidence span.

These boundaries form a hierarchy rather than one universal chunk size. Information extraction research has long separated entity, relation, and event tasks. The ACE program made that decomposition operational, while open information extraction showed that useful relational structure can be discovered without enumerating every relation in advance. Neither result licenses discarding document context.

Normalization should also expose uncertainty. Language identification can return a distribution. Sentence boundaries in chat can be ambiguous. A quoted sentence may have another author. The pipeline may record these as candidate annotations rather than force a single clean string.

3.1 Solved exercises

Exercise 3.1. Why is lowercasing the stored source dangerous?

Solution. Case can carry entity and acronym evidence. A lowercase processing view is acceptable if the immutable source and offset map remain available.

Exercise 3.2. A normalizer removes an emoji that signals approval. What failed?

Solution. The processing view lost semantic evidence. Either the emoji must be represented or the extractor must retain access to the source span.

Exercise 3.3. Should “Last time” be processed without the previous sentence?

Solution. No. It needs speaker and conversation context, even though it begins a distinct sentence.

Exercise 3.4. What does (\mu([b’,e’))) return?

Solution. It returns the corresponding interval in the immutable source, allowing the normalized result to cite exact evidence.

Exercise 3.5. Does a new normalizer version create a new source?

Solution. No. It creates a new activity and derived processing view linked to the same source.

4. Mentions are candidates, not entities

A mention is a span that may refer to something. In Lia’s message, mention candidates include “evening,” “caffeine,” “last time,” and “mint tea.” Lia is also an implicit mention because the source author is the subject of first person statements.

Let a mention candidate be

[ m=(s,[b,e),t,q), ]

where (s) identifies the source, ([b,e)) is the evidence span, (t) is a proposed mention type, and (q) is a score or calibrated probability.

The mention does not yet identify a graph entity. “Mint tea” could refer to a beverage type, a specific prepared cup, a product, or a menu item. “Last time” refers to an episode but leaves its identity unresolved. “Evening” is a temporal context, not necessarily a reusable entity node. The schema determines which mentions become nodes, qualifiers, literals, or unresolved references.

Modern coreference models consider spans and distributions over possible antecedents. This is a useful design lesson even when the production extractor is not neural: candidate generation and identity decision are distinct stages. A system that detects only the final chosen mention hides alternatives and makes error diagnosis difficult.

Mention detection also needs negative evidence. The word “caffeine” occurs inside “without caffeine.” If a pipeline extracts only a substance mention and loses the negating construction, a later relation builder may write the opposite of Lia’s request. The mention span is therefore necessary but insufficient. Predicate formation must read the surrounding syntactic and semantic structure.

We can evaluate mention detection with span precision, recall, and (F_1):

[ P_m=\frac{TP_m}{TP_m+FP_m},\qquad R_m=\frac{TP_m}{TP_m+FN_m}, ]

[ F_{1,m}=\frac{2P_mR_m}{P_m+R_m}. ]

These measures diagnose span detection. They do not measure entity resolution or memory utility.

4.1 Solved exercises

Exercise 4.1. Is “last time” an entity?

Solution. It is first a mention of an episode. It may remain unresolved rather than becoming a fabricated episode identity.

Exercise 4.2. Why keep the span for “without caffeine” rather than only “caffeine”?

Solution. The wider span preserves polarity and request structure. The noun alone can support the opposite interpretation.

Exercise 4.3. If (TP_m=18), (FP_m=2), and (FN_m=4), what is mention precision?

Solution. (P_m=18/(18+2)=0.90).

Exercise 4.4. With the same counts, what is mention recall?

Solution. (R_m=18/(18+4)\approx0.818).

Exercise 4.5. Can perfect mention (F_1) imply correct memory writes?

Solution. No. Identity, relations, time, provenance, authorization, and admission can still fail.

5. Entity resolution without forced identity

Entity resolution maps a mention to an existing identity, a new identity, or an unresolved state. For mention (m), candidate generation returns:

[ R(m)={(e_1,p_1),\ldots,(e_k,p_k),(\bot,p_\bot)}, ]

where (\bot) means unresolved.

The explicit null candidate is critical. Without it, the resolver must choose the least bad entity. A false merge can spread through every later claim, episode, consolidation, and retrieval. A missed merge creates duplication, but duplication can often be repaired by a later identity operation. False identity corrupts meaning more deeply.

For the canonical message, the source author resolves to Lia with high confidence because the authenticated conversation supplies identity. “Mint tea” may resolve to a known beverage concept. “Last time” can generate several episode candidates from Lia’s history, but the phrase alone may not distinguish them. The honest result is unresolved episode identity with a relative temporal constraint (t<90).

Entity linking is modular. Mention extraction, candidate generation, type prediction, coreference, local compatibility, and global coherence contribute different evidence. Xiao Ling, Sameer Singh, and Daniel Weld emphasize that changing the definition of the linking problem changes measured performance. A memory system must state whether it permits unseen entities, nil results, cross document evidence, and delayed resolution.

Identity decisions also need versioned justification. Suppose a later message says, “By last time, I meant our day 84 conversation.” The pipeline should link the unresolved reference to episode 84 through a new resolution activity. It should not rewrite the source phrase or pretend the identity was known on day 90.

A practical admission policy may commit a claim with an unresolved object only if the schema explicitly supports that state and the claim remains useful. Otherwise it quarantines the candidate until resolution improves.

5.1 Solved exercises

Exercise 5.1. What does (p_\bot) represent?

Solution. It represents the probability or score assigned to leaving the mention unresolved.

Exercise 5.2. Which is usually more damaging, a false merge or a delayed merge?

Solution. A false merge is usually more damaging because it attributes claims and episodes to the wrong identity across the graph.

Exercise 5.3. May authenticated authorship resolve first person “I”?

Solution. Yes, if the channel identity and delegation model support that inference and the provenance records it.

Exercise 5.4. A later source resolves an old mention. Must the old source change?

Solution. No. Add a new resolution activity and identity link with its own transaction time.

Exercise 5.5. When can an unresolved candidate commit?

Solution. Only when the schema and policy permit unresolved identity and the resulting object remains safe and useful. Otherwise it belongs in quarantine.

6. Claims need polarity, modality, scope, and evidence spans

A relational triple such as

[ (\text{Lia},\texttt{AVOIDS},\text{caffeine}) ]

looks compact, but it loses the current request, evening context, modality, and evidence. The sentence does not necessarily assert a permanent lifestyle rule. It asks for something without caffeine because it is evening.

A claim candidate needs a richer form:

[ c=(r,\rho,\mu,\kappa,I_v,E,q), ]

where (r) is the proposition structure, (\rho) is polarity, (\mu) is modality, (\kappa) is contextual scope, (I_v) is a proposed valid interval, (E) is a set of evidence spans, and (q) is extraction uncertainty.

Semantic role labeling asks who did what to whom, when, where, and under which predicate frame. Gildea and Jurafsky demonstrated how predicate arguments can be labeled with roles such as Agent, Patient, Speaker, Message, and Topic. Memory ingestion needs the same discipline even when its ontology uses different names.

For Lia’s message, useful candidates include:

  1. a request constraint: Lia requests a caffeine free option within the day 90 evening episode;
  2. an outcome: mint tea worked well in a prior episode;
  3. a preference hypothesis: Lia generally prefers mint tea.

The first two have direct textual support. The third is an inference from a single positive outcome. It may be retained as a low confidence candidate, but its evidence span and derivation must reveal the generalization.

Modality prevents another common error. “Please suggest” is a request, not a report that Aurora already suggested something. “Worked well” reports an evaluation, not a physical measurement. “Maybe mint tea” would express uncertainty. “Do not suggest coffee” would add negative policy. Flattening these distinctions into positive triples manufactures false events.

6.1 Solved exercises

Exercise 6.1. What polarity does “Lia did not choose coffee” carry?

Solution. Negative polarity over the choice event. It does not imply that Lia dislikes coffee.

Exercise 6.2. Is “Aurora should suggest tea” an observed action?

Solution. No. It has deontic modality. An observed action requires separate event evidence.

Exercise 6.3. Why store (E) as a set of spans?

Solution. One claim may depend on several clauses or turns. Each supporting span remains independently inspectable.

Exercise 6.4. What is lost by omitting (\kappa)?

Solution. Contextual scope is lost, so an evening request constraint can become a permanent global rule.

Exercise 6.5. Does open information extraction guarantee ontology compatible claims?

Solution. No. It discovers relational phrases. Mapping them into a memory schema requires typing, normalization, and validation.

7. Events, episodes, actions, and outcomes

Claims describe propositions. Events describe occurrences. Episodes organize related events without erasing their identities.

Lia’s message occurs on day 90. It contains a request event. Aurora’s eventual recommendation will be another event. Lia’s later acceptance or rejection will be another. The phrase “last time” refers to an earlier episode containing at least an intervention and an outcome. We should not collapse all of these into one claim called “mint tea worked.”

Let an event candidate be:

[ v=(\text{type},P,\tau,E,q), ]

where (P) maps semantic roles to participants, (\tau) is event time or a temporal constraint, (E) contains evidence spans, and (q) represents uncertainty.

An episode candidate is:

[ \epsilon=(V,\preceq,\gamma), ]

where (V) is a set of event identities, (\preceq) is a partial temporal order, and (\gamma) is the episode context. A partial order matters because “last time” tells us only that the referenced outcome precedes day 90. Inventing day 84 would create false precision.

Action and outcome must remain separate. The action may be “Aurora recommended mint tea.” The outcome may be “Lia reported that it worked well.” An outcome can support future policy learning, but only if it links to the action or intervention that plausibly produced it. A favorable mood observed later is not automatically an outcome of the recommendation.

Event extraction work, including the ACE program, distinguishes event triggers, arguments, and types. A memory system adds persistent identity, temporal versioning, provenance, and episode membership. These additions make events usable across sessions without converting every cooccurrence into causality.

MG08 will build the complete episodic event graph. Here we assemble only enough structure to validate a write and preserve its future interpretability.

7.1 Solved exercises

Exercise 7.1. Why are recommendation and outcome two events?

Solution. They occur at different times, may have different sources, and play different causal and semantic roles.

Exercise 7.2. What does (v_i\preceq v_j) mean?

Solution. Event (v_i) is known not to occur after (v_j) in the episode’s partial order.

Exercise 7.3. May “last time” receive event day 84 because day 84 is plausible?

Solution. No. Plausibility is not evidence. Keep a relative constraint or candidate distribution.

Exercise 7.4. Does temporal succession prove that an action caused an outcome?

Solution. No. Causality requires additional evidence or a deliberately weaker relation such as FOLLOWED_BY.

Exercise 7.5. What should persist if the episode identity is unresolved but the outcome text is clear?

Solution. Policy may quarantine the outcome or commit it with an explicit unresolved episode reference. It must not invent an identity.

8. Temporalization and provenance before admission

MG05 defined event time, valid time, and transaction time. The write pipeline must assign their roles before admission because an apparently correct proposition can still be temporally malformed.

The day 90 request constraint has event time 90. Its validity is scoped to the current episode, perhaps ([90,\tau_{\text{episode end}})). The previous outcome has only a relative event constraint (t<90). A general preference hypothesis has no justified start date. The extractor must not copy day 90 into every temporal field.

Temporalization returns checked candidates:

[ T(c)= \begin{cases} c’ & \text{if clock roles and intervals are valid},
\text{error} & \text{otherwise}. \end{cases} ]

Transaction time remains pending until commit. Assigning it during extraction would imply that a quarantined or rejected candidate entered trusted memory. The storage transaction assigns the actual boundary.

Provenance adds a derivation graph. W3C PROV distinguishes entities, activities, and agents. The source message is an Entity. Normalization, extraction, and resolution runs are Activities. Model builds and configuration snapshots are Entities used by those activities. The responsible service or operator is an Agent.

For candidate (k), an auditable path includes:

[ k \xleftarrow{\texttt{GENERATED}} a_{\text{extract}} \xrightarrow{\texttt{USED}} x’, ]

[ x’ \xleftarrow{\texttt{GENERATED}} a_{\text{normalize}} \xrightarrow{\texttt{USED}} s. ]

The evidence span adds a direct semantic anchor from (k) to (s). Provenance explains origin. It does not guarantee entailment. Admission must still ask whether the cited span supports the candidate.

8.1 Solved exercises

Exercise 8.1. When does transaction time begin for a committed candidate?

Solution. At the storage commit, not at extraction or source event time.

Exercise 8.2. What temporal value should “last time” receive when no exact episode is known?

Solution. A relative constraint such as event time before day 90, with explicit unresolved precision.

Exercise 8.3. Is a model build an Activity?

Solution. The extraction run is an Activity. The model build used by that run can be represented as an Entity.

Exercise 8.4. Does a complete provenance path prove entailment?

Solution. No. It proves traceability. The extractor may still have misunderstood the source.

Exercise 8.5. Why validate time before admission?

Solution. A proposition with invalid or fabricated temporal semantics would corrupt historical queries even if its non temporal content were correct.

9. Retries, duplicates, and independent corroboration

Memory ingestion encounters at least three kinds of apparent repetition:

  1. a transport retry of the same source occurrence;
  2. a new source occurrence with equivalent semantic content;
  3. a new source that copied or derived from an earlier source.

Only the first is a pure idempotency case. Let (d(s)) be a stable delivery key and (h(s)) a content hash. A replay satisfies:

[ d(s_i)=d(s_j)\land h(s_i)=h(s_j). ]

The writer returns LINK to the existing source and creates no new evidence. If the delivery keys match but hashes differ, the envelope is inconsistent and the write is rejected.

Semantic duplication is different. Lia may repeat the caffeine constraint on day 100. The new message is a distinct occurrence and may provide new evidence, a new valid interval, or a new context. The pipeline can link it to an existing proposition while preserving the new source and event.

Independent corroboration is stronger than repetition. Two messages can have different identifiers but share one upstream origin. A copied clinician note is not independent of the original note. Provenance roots help estimate evidence independence:

[ \operatorname{root}(s_i)\ne\operatorname{root}(s_j). ]

Even distinct roots do not prove independence because people can repeat the same rumor. The graph should represent observed derivation when known and avoid treating source count as truth count.

Deduplication therefore operates at several levels: delivery identity, source content, mention identity, proposition equivalence, event identity, and provenance root. Collapsing them into one vector similarity threshold creates errors. Similar wording can express opposite polarity. Different wording can express the same proposition. Two equal propositions can remain distinct occurrences.

9.1 Solved exercises

Exercise 9.1. Same delivery key and same hash produce which outcome?

Solution. LINK to the existing source with no new evidence object.

Exercise 9.2. Same delivery key and different hash produce which outcome?

Solution. REJECT, because one occurrence identity cannot safely name two payloads.

Exercise 9.3. Lia repeats a claim in a new conversation. Is it a retry?

Solution. No. It is a new source occurrence even if proposition deduplication links it to existing semantic content.

Exercise 9.4. Do two source identifiers prove independent corroboration?

Solution. No. Their provenance may converge on one origin.

Exercise 9.5. Why can embedding similarity not decide duplication alone?

Solution. Similarity can miss polarity, modality, temporal scope, event identity, and shared provenance.

10. Admission as selective prediction

Admission is a decision under uncertainty with an explicit reject option. Selective prediction studies systems that abstain on some inputs to trade coverage for lower risk. Memory writing has a related but richer problem because abstention is not one state and policy gates are not learned confidence.

For candidate (k), define:

  • (q_x): extraction confidence;
  • (q_i): identity confidence;
  • (u): expected future memory utility;
  • (r): retention, privacy, and error risk;
  • (S,P,T,Z): schema, provenance, temporal, and authorization predicates.

A simplified commit rule is:

[ \operatorname{commit}(k)= S\land P\land T\land Z \land q_x\ge\theta_x \land q_i\ge\theta_i \land u>r. ]

This equation is a contract, not a universal scoring formula. Some predicates are hard gates. A privacy restriction cannot be compensated by very high utility. Other values support graded decisions. Low identity confidence may send a candidate to quarantine. Low utility may justify ignore. Semantic equivalence may produce link.

The useful optimization target is not write rate. A system that writes everything achieves perfect admission coverage and terrible memory precision. Let (W) be admitted writes and (G) the writes that later evaluation judges appropriate:

[ P_w=\frac{|W\cap G|}{|W|},\qquad R_w=\frac{|W\cap G|}{|G|}. ]

High write precision protects the graph from durable contamination. Write recall still matters because a memory that refuses everything is safe but useless. The operating point depends on domain cost. A preference assistant can quarantine aggressively. A safety critical system may require human review for entire candidate classes.

Confidence calibration matters because (0.8) should correspond to comparable empirical reliability within a defined population. Yet calibrated confidence remains only one input. It cannot express consent, retention law, source authority, or future utility by itself.

10.1 Solved exercises

Exercise 10.1. Why is authorization (Z) not added to a numeric score?

Solution. It is a hard gate. Enough utility or confidence must not compensate for missing authority.

Exercise 10.2. If ( W =80) and 72 writes are appropriate, what is (P_w)?

Solution. (P_w=72/80=0.90).

Exercise 10.3. If 90 appropriate writes exist and 72 were admitted, what is (R_w)?

Solution. (R_w=72/90=0.80).

Exercise 10.4. Can a system maximize write precision by rejecting everything?

Solution. Its precision becomes undefined because it makes no writes, while recall is zero. Evaluation must report coverage and recall.

Exercise 10.5. What does a calibrated confidence of (0.8) mean?

Solution. Across a defined population of candidates receiving that score, approximately 80 percent should be correct under the calibration target. It does not mean the individual candidate is 80 percent true in every possible sense.

Five outcomes make the policy more expressive than a Boolean write flag.

Commit creates a new trusted memory object in a storage transaction. The transaction assigns identity and transaction time, writes provenance edges, and updates any required indexes atomically.

Link reuses an existing object. A retry links to the existing source without increasing evidence count. A semantically equivalent independent source can add provenance to an existing claim without creating a duplicate proposition.

Quarantine preserves a candidate outside trusted views. It is appropriate for ambiguous identity, incomplete provenance, low extraction confidence, or a claim class that requires review. Quarantine must have retention limits and reprocessing rules or it becomes an ungoverned shadow memory.

Ignore records that the candidate does not justify memory retention. Low expected utility, excessive redundancy, or disproportionate risk can produce this outcome. An implementation may retain only aggregate operational metrics rather than candidate content.

Reject marks a contract failure such as invalid schema, impossible temporal bounds, unauthorized scope, or inconsistent delivery identity. Rejection should be observable because repeated rejection may reveal an extractor or integration defect.

These outcomes are ordered by neither truth nor severity. LINK can represent a highly reliable duplicate. QUARANTINE can hold a potentially important but unresolved claim. IGNORE can apply to perfectly true but irrelevant content. REJECT can result from missing authority even when the proposition is true.

Try every stage of the canonical interaction in the pipeline laboratory:

The central operational rule is:

Every candidate receives an outcome, and every outcome receives a reason.

11.1 Solved exercises

Exercise 11.1. Which outcome fits a known proposition supported by a new independent source?

Solution. LINK can attach the new provenance to the existing proposition while preserving the new source occurrence.

Exercise 11.2. Which outcome fits an ambiguous episode reference that may be resolved tomorrow?

Solution. QUARANTINE, with a reprocessing trigger and retention deadline.

Exercise 11.3. Which outcome fits valid but useless weather small talk?

Solution. IGNORE if future memory utility does not justify retention.

Exercise 11.4. Which outcome fits an interval whose end precedes its start?

Solution. REJECT, because the candidate violates the temporal schema.

Exercise 11.5. Why must quarantine have a retention rule?

Solution. Otherwise uncertain content accumulates outside normal trusted views and escapes governance, deletion, and cost controls.

12. A C++23 reference implementation

The reference program is a deterministic CPU correctness baseline. It does not pretend to perform general natural language understanding. Its extractor recognizes the canonical message so that the storage contracts, types, decisions, and tests remain reproducible.

The source constructor returns std::expected:

[[nodiscard]] auto make_source(
    SourceId id,
    std::string delivery_key,
    std::string author,
    int event_day,
    int ingestion_day,
    std::string payload_hash,
    std::string content,
    std::string authorization_scope)
    -> std::expected<SourceEnvelope, std::string>;

Checked construction prevents malformed envelopes from existing as ordinary values. Strong identifiers prevent accidental comparison between a source, candidate, entity, and episode. Candidate payloads use std::variant:

using CandidatePayload =
    std::variant<ScopedConstraint, OutcomeClaim, PreferenceHypothesis>;

This closed sum type makes each candidate one of the schema supported alternatives. std::visit prints or processes the payload without unsafe tags or downcasts. Contiguous std::vector ownership keeps the didactic dataset simple, while std::span exposes read only query views without copying.

The admission function applies hard gates before graded checks:

if (!candidate.schema_valid || !candidate.temporal_valid) {
    return {candidate.id, Decision::reject,
            "Schema or temporal validation failed."};
}
if (!candidate.authorized) {
    return {candidate.id, Decision::reject,
            "The source scope does not authorize this durable write."};
}
if (candidate.semantic_duplicate) {
    return {candidate.id, Decision::link,
            "Equivalent content already exists, so provenance is linked."};
}

Only then does it consider confidence, utility, and risk. The complete program prints:

Source 90 by Lia at event day 90, ingested day 90
Candidate 1: scoped constraint | evidence: "evening, so please suggest something without caffeine" | COMMIT | All gates pass and expected utility exceeds retention risk.
Candidate 2: episode outcome | evidence: "Last time the mint tea worked well" | COMMIT | All gates pass and expected utility exceeds retention risk.
Candidate 3: preference hypothesis | evidence: "mint tea" | QUARANTINE | Evidence, identity, or extraction certainty needs review.
Replay: LINK to source 90, no new evidence created.
Malformed source: REJECT | A source requires delivery and payload identities.

The full C++23 source is available at memory_ingestion.cpp. It compiles with current MSVC using C++ latest mode, strict conformance, and warning level 4.

The design is intentionally CPU focused. A neural extractor may run on a GPU, but source validation, identifier allocation, idempotency, policy checks, and atomic commit remain control plane operations. Moving them into one opaque accelerator call would reduce auditability without solving a meaningful bottleneck.

12.1 Solved exercises

Exercise 12.1. Why use std::expected for source construction?

Solution. It makes validation failure part of the type contract and prevents callers from confusing a malformed envelope with a valid value.

Exercise 12.2. Why use strong identifier structs instead of plain integers?

Solution. They prevent accidental mixing of source, candidate, entity, and episode identities while retaining compact value semantics.

Exercise 12.3. What invariant does the evidence span validator enforce?

Solution. It requires a nonempty half open span entirely inside the immutable source content.

Exercise 12.4. Why return an empty candidate vector for a retry?

Solution. The original delivery already generated its evidence. Reprocessing a transport retry must not multiply candidates or support.

Exercise 12.5. Why is this implementation not a benchmark?

Solution. Its fixed example and tiny ledger demonstrate correctness contracts. They do not represent production data distributions, model latency, storage scale, or hardware utilization.

13. Stagewise evaluation, operations, limits, and the frontier

An end to end answer accuracy score cannot diagnose a write pipeline. A system may answer correctly by using the current context while writing corrupt memory. It may write correctly but retrieve the wrong object later. Evaluation must isolate stages.

Stage Primary measures Critical failure
envelope source completeness, hash consistency, authorization coverage unauditable input
normalization offset round trip accuracy, language and boundary accuracy evidence drift
mentions span precision, recall, (F_1) missing or spurious candidates
identity linking accuracy, nil accuracy, calibration false merge
claims and events argument, polarity, modality, scope, and trigger scores distorted meaning
temporalization clock role and interval accuracy false history
provenance source reachability and span support unsupported derivation
idempotency retry suppression and independent evidence preservation duplicate amplification
admission write precision, write recall, coverage, risk by outcome trusted graph contamination

Operations need more than averages. Track rejection reason, quarantine age, candidate class, source channel, language, extractor version, policy version, tenant, and privacy class. A model upgrade that improves average extraction may still damage one language or overgeneralize one predicate.

Replay tests should rerun the same delivery and prove that graph cardinality does not change. Metamorphic tests can replace “evening” with “morning” and require scope to change while source identity remains new. Counterfactual tests can remove “without” and verify that polarity changes. Historical tests can rerun an old source under a new extractor without backdating transaction time.

The pipeline also has limits. Text can imply facts that are not explicitly stated. Sarcasm, quoted speech, deception, cultural context, and long range reference can defeat extraction. Identity may remain permanently ambiguous. Utility estimates can reflect biased product assumptions. Authorization can change after ingestion. No confidence threshold eliminates these problems.

The safe response is not to abandon memory. It is to keep uncertainty, derivation, policy, and time visible. A memory system should be able to say, “I observed this source, extracted this candidate, could not resolve this identity, and therefore did not commit it.”

We have now completed the write side of the model. The next article, Retrieval Is Not Enough, will examine the opposite direction. Finding relevant objects is only recall. An agent still needs a bounded, diverse, temporally valid, provenance aware evidence packet that supports the current decision without flooding the context window.

13.1 Solved exercises

Exercise 13.1. Why can answer accuracy hide a broken writer?

Solution. The answer may come from current context while the writer stores an incorrect object that harms later sessions.

Exercise 13.2. Which test proves transport idempotency?

Solution. Replay the same delivery identity and payload, then assert that source, candidate, and evidence cardinalities do not increase.

Exercise 13.3. What should a polarity metamorphic test change?

Solution. Removing or adding a negation should change the extracted polarity while preserving unrelated identities and evidence mappings.

Exercise 13.4. Why report quarantine age?

Solution. Old quarantined candidates reveal stalled resolution, missing review capacity, or retention policy failure.

Exercise 13.5. What does MG07 add after this article?

Solution. It constructs bounded evidence for a query. MG06 decides what enters memory; MG07 decides which valid memory objects should reach the model for a particular task.

Conclusion

Experience enters memory through a sequence of accountable transformations, not through one prompt that asks for facts.

The source envelope preserves exact evidence, authorship, time, identity, and authorization. Normalization creates a traceable view. Mention detection proposes spans. Entity resolution may link, create, or remain unresolved. Claim and event formation preserve roles, polarity, modality, context, and evidence. Temporalization assigns clock meanings without inventing precision. Provenance records every derivation. Idempotency separates retries from new occurrences and corroboration. Admission chooses among commit, link, quarantine, ignore, and reject.

The most important design rule is simple:

Never make durable certainty the default output of uncertain extraction.

A useful memory is selective, but selectivity alone is not enough. It must also be explainable, replay safe, temporally honest, and governed. The resulting graph may contain fewer trusted objects than an indiscriminate extractor would produce. Those objects are far more valuable because the system can explain what they mean, where they came from, and why they were allowed to remain.

References

  • BANKO, Michele; CAFARELLA, Michael J.; SODERLAND, Stephen; BROADHEAD, Matt; ETZIONI, Oren. Open information extraction from the Web. In: Proceedings of the 20th International Joint Conference on Artificial Intelligence. Hyderabad: IJCAI, 2007. p. 2670–2676. Available at: https://www.eng.utah.edu/~cs6961/papers/banko-ijca07.pdf. Accessed on: 23 July 2026.
  • CHHIKARA, Prateek; KHANT, Dev; ARYAN, Saket; SINGH, Taranjeet; YADAV, Deshraj. Mem0: building production ready AI agents with scalable long term memory. arXiv, 2025. DOI: 10.48550/arXiv.2504.19413. Available at: https://arxiv.org/abs/2504.19413. Accessed on: 23 July 2026.
  • DODDINGTON, George; MITCHELL, Alexis; PRZYBOCKI, Mark; RAMSHAW, Lance; STRASSEL, Stephanie; WEISCHEDEL, Ralph. The Automatic Content Extraction program: tasks, data, and evaluation. In: Proceedings of the Fourth International Conference on Language Resources and Evaluation. Lisbon: ELRA, 2004. Available at: https://aclanthology.org/L04-1011/. Accessed on: 23 July 2026.
  • GEIFMAN, Yonatan; EL-YANIV, Ran. SelectiveNet: a deep neural network with an integrated reject option. In: Proceedings of the 36th International Conference on Machine Learning. [S. l.]: PMLR, 2019. v. 97, p. 2151–2159. Available at: https://proceedings.mlr.press/v97/geifman19a.html. Accessed on: 23 July 2026.
  • GILDEA, Daniel; JURAFSKY, Daniel. Automatic labeling of semantic roles. Computational Linguistics, v. 28, n. 3, p. 245–288, 2002. DOI: 10.1162/089120102760275983. Available at: https://aclanthology.org/J02-3001/. Accessed on: 23 July 2026.
  • LEE, Kenton; HE, Luheng; LEWIS, Mike; ZETTLEMOYER, Luke. End to end neural coreference resolution. In: Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing. Copenhagen: Association for Computational Linguistics, 2017. p. 188–197. DOI: 10.18653/v1/D17-1018. Available at: https://aclanthology.org/D17-1018/. Accessed on: 23 July 2026.
  • LEBO, Timothy; SAHOO, Satya; MCGUINNESS, Deborah. PROV-O: the PROV ontology. W3C Recommendation, 2013. Available at: https://www.w3.org/TR/prov-o/. Accessed on: 23 July 2026.
  • LING, Xiao; SINGH, Sameer; WELD, Daniel S. Design challenges for entity linking. Transactions of the Association for Computational Linguistics, v. 3, p. 315–328, 2015. DOI: 10.1162/tacl_a_00141. Available at: https://aclanthology.org/Q15-1023/. Accessed on: 23 July 2026.
  • MINTZ, Mike; BILLS, Steven; SNOW, Rion; JURAFSKY, Daniel. Distant supervision for relation extraction without labeled data. In: Proceedings of the Joint Conference of the 47th Annual Meeting of the ACL and the 4th International Joint Conference on Natural Language Processing of the AFNLP. Suntec: Association for Computational Linguistics, 2009. p. 1003–1011. Available at: https://aclanthology.org/P09-1113/. Accessed on: 23 July 2026.

(Updated: )