# Memory Source Attribution

> Use when a recalled fact must be traced back to the observation, document, or conversation that produced it, or when an agent answer needs verifiable provenance. Covers source identifiers and citation formats, confidence propagation from source quality, attribution checks before acting, and audits that catch unattributed or misattributed claims, with scoring terms for source attribution, provenance tracking, citation verification, and evidence chains.

- Skill: `mizazhaider-ceh/memory-source-attribution` (Agent Skill)
- Install (CLI): `npx get-skill add mizazhaider-ceh/memory-source-attribution`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mizazhaider-ceh/memory-source-attribution/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: mizazhaider-ceh (https://skillmd.com/u/mizazhaider-ceh)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/mizazhaider-ceh/memory-source-attribution

---


A fact without a source is a rumour with good formatting. Attribution
is the practice of keeping every stored fact linked to the
observation, document, or conversation that produced it, so that any
later reader can check it, any later contradiction can be weighed,
and any later deletion can propagate to the claims built on it. This
sub-skill supports its parent, ../../SKILL.md, because an evaluation
that cannot trace a claim to its source cannot judge whether the
claim is true, only whether it sounds plausible. It builds on
../../../memory-capture/SKILL.md, which covers recording sources at
capture time, and adds the formats, checks, and audits that keep
those links alive.

## Quick Workflow

1. Give every source a stable identifier at capture time, using the
   scheme in section 1, and never reuse an identifier for new content.
2. Attach source identifiers to every derived record, including
   summaries and promoted semantic facts.
3. Propagate confidence from source quality, not from how often a
   claim has been repeated, using section 2.
4. Check attribution before acting, meaning every claim behind an
   action must resolve to a live source.
5. Audit attribution regularly, and demote or quarantine records
   whose sources are gone or broken.
6. When a source is corrected or retracted, propagate that change to
   every record that cites it, and log the propagation.

## 1. Source identifiers and citation formats

A source identifier must be stable, unique, and resolvable. Stable
means the same source keeps the same identifier across exports and
restores. Unique means two different observations never share one.
Resolvable means a reader with the identifier can find the source
content, or a clear tombstone explaining why it is gone. The schema
below is the minimum useful shape for a source record.

```json
{
  "source_record": {
    "id": "src_20261027_0011",
    "kind": "observation",
    "agent": "hunter-01",
    "captured": "2026-10-27T05:00:00Z",
    "location": "scan run 2026-10-27 on 10.0.1.5, port 22 open",
    "content_hash": "sha256:9f2c4a1b8d3e6f50718293a4b5c6d7e8f90123456789abcdef0123456789abcd",
    "quality": "direct_observation",
    "retracted": false
  }
}
```

Source kinds used in this store:

- direct_observation, meaning a command output or tool result the
  agent saw itself. Highest quality for operational facts.
- document, meaning a file, page, or report. Quality depends on the
  document's own freshness and authority, recorded alongside.
- conversation, meaning a human or agent statement. Quality depends
  on who said it and whether it was verified afterwards.
- derived, meaning a summary or promotion of other sources. A
  derived source must list its own sources, forming a chain, never a
  dead end.

Citation format in stored text is the bare identifier, such as
`src_20261027_0011`, placed directly after the claim it supports.
Human-facing output may render it as a footnote or link, but the
stored form keeps the identifier in plain text, so that grep, SQL,
and audits can all follow it without a rendering step.

## 2. Confidence propagation from source quality

Confidence must flow from sources to claims, not from repetition.
A claim repeated in ten summaries is still only as strong as its one
original observation. The propagation rules below keep that honest,
and they are deliberately conservative, because inflated confidence
is how a guess becomes an action.

```python
"""Confidence propagation: a claim is only as strong as its sources."""

SOURCE_QUALITY = {
    "direct_observation": 0.95,
    "document": 0.80,
    "conversation": 0.60,
    "derived": 0.70,
}

def claim_confidence(source_qualities, corroboration=1):
    """Weakest-link base, with a small bonus for independent agreement."""
    if not source_qualities:
        return 0.0
    base = min(SOURCE_QUALITY.get(q, 0.5) for q in source_qualities)
    bonus = 0.05 * (corroboration - 1)
    return round(min(0.98, base + bonus), 3)

# One direct observation: 0.95. Two independent direct observations: 0.98.
# One conversation report: 0.60, however often it is repeated, because
# repetition of the same source is not corroboration.
```

Rules that follow:

- Corroboration counts independent sources only. Two summaries of
  the same observation are one source, not two.
- A derived record inherits the weakest quality in its chain, not
  the average, because a chain breaks at its weakest link.
- A claim with no sources has confidence 0.0 in the store, whatever
  the text says, and recall filters that enforce a confidence floor
  will hide it, which is the correct behaviour.
- When a source is retracted, every claim citing it drops to 0.0
  until fresh evidence arrives, and the drop is logged.

## 3. Attribution checks before acting

Before an agent acts on recalled knowledge, it checks that the
knowledge is attributable, meaning each load-bearing claim resolves
to a live, unretracted source of acceptable quality. The check below
runs that gate in code, so it cannot be skipped by enthusiasm.

```python
"""Attribution gate: block actions resting on unattributed claims."""

def attribution_gate(store, claims, min_quality="document"):
    quality_rank = {"direct_observation": 3, "document": 2,
                    "conversation": 1, "derived": 2}
    floor = quality_rank[min_quality]
    failures = []
    for claim in claims:
        sources = store.sources_for(claim.id)
        if not sources:
            failures.append((claim.id, "no sources attached"))
            continue
        live = [s for s in sources if not s.retracted]
        if not live:
            failures.append((claim.id, "all sources retracted"))
            continue
        best = max(quality_rank.get(s.quality, 0) for s in live)
        if best < floor:
            failures.append((claim.id, "best source below quality floor"))
    return failures

# An empty failures list means the action may proceed. Any failure
# means verify live first, or choose a different course of action.
```

Set the quality floor per action, not per store. A report draft can
rest on conversation sources flagged as such. A change to a system
needs direct observation or a trusted document, verified fresh. When
the gate fails, the correct response is fresh verification, not
lowering the floor to make the check pass.

## 4. Attribution audits and retraction propagation

Attribution decays. Sources are deleted, documents move, and
summaries get copied without their links. A regular audit finds the
decay before it causes a wrong action. The audit below reports the
three numbers that matter, meaning how many semantic records lack
sources, how many cite retracted sources, and how many cite sources
that no longer resolve.

```sql
-- Attribution audit: sourceless facts, retracted sources, dead links
SELECT 'semantic_without_sources' AS problem, COUNT(*) AS records
FROM memory_records
WHERE layer = 'semantic'
  AND (sources IS NULL OR sources = '[]')
UNION ALL
SELECT 'citing_retracted_sources', COUNT(*)
FROM memory_records r
JOIN memory_sources s ON s.id IN (SELECT value FROM json_each(r.sources))
WHERE s.retracted = 1
UNION ALL
SELECT 'citing_missing_sources', COUNT(*)
FROM memory_records r
WHERE EXISTS (
  SELECT 1 FROM json_each(r.sources) j
  WHERE NOT EXISTS (SELECT 1 FROM memory_sources s WHERE s.id = j.value)
);
```

Retraction propagation procedure:

- Mark the source retracted, with a reason and a date, instead of
  deleting it outright, so existing citations resolve to a clear
  tombstone rather than a mystery.
- Find every record citing the source, drop its confidence to 0.0,
  and flag it for review.
- Notify owners of open tasks that cited the retracted source, when
  the task is still active.
- After the review window closes, delete or rewrite the affected
  records, and keep the tombstone so future citations fail loudly
  instead of silently pointing nowhere.

## Edge cases

- A source is a live system state, such as an open port. Its
  identifier records the observation time, and the claim is only as
  fresh as that time. Re-verify before acting, however good the
  attribution looks.
- A claim has many sources but they all derive from one observation.
  Count it as one source. The chain, not the count, decides strength.
- A source is sensitive and cannot be shared with the reader. Cite
  the identifier and the quality level, and let an authorized reader
  resolve the content, rather than dropping the citation entirely.
- A summary quotes a source verbatim. The quote keeps the source
  identifier attached, so the quote cannot drift away from its
  evidence in later copies.
- Attribution and privacy conflict, because a source contains
  personal data. Keep the identifier and the quality, redact the
  content, and record that the content was redacted and when.

## Key references

- CWE-200 (Exposure of Sensitive Information to an Unauthorized
  Actor): why source content needs scoping even when identifiers
  are shared.
- SQLite json_each documentation: https://sqlite.org/json1.html
- Python sqlite3 module: https://docs.python.org/3/library/sqlite3.html
- ../../SKILL.md and ../../../memory-capture/SKILL.md in this repo.

