---
slug: source-quote-law
title: "Source Quote Law: The Code That Refuses a Source Card Without the Source's Own Words"
kind: engineering
status: published
hash: d7f4e62a005b3d969e20543cb6bfa57169de09717c86eeba29a26e79e6c0b7c0
created: 2026-08-06T03:59:04.717Z
updated: 2026-10-08T11:31:27.500Z
summary: "Every source card on miscsubjects.com is supposed to show the source's verbatim words — the sentence from the study, the text of the tweet, the line from the paper. For months, that did not happen. Study cards carried a descriptor the team"
tags: ["source-law","editorial-gate","source-quotes","build-integrity","miscsubjects"]
above: []
below: []
adjacent: []
nested: []
---
# Source Quote Law: The Code That Refuses a Source Card Without the Source's Own Words

*Every source card on miscsubjects.com is supposed to show the source's verbatim words — the sentence from the study, the text of the tweet, the line from the paper. For months, that did not happen. Study cards carried a descriptor the team*

# Source Quote Law: The Code That Refuses a Source Card Without the Source's Own Words

Every source card on miscsubjects.com is supposed to show the source's verbatim words — the sentence from the study, the text of the tweet, the line from the paper. For months, that did not happen. Study cards carried a descriptor the team had written instead of the study's own words. Social cards — X, Reddit — showed a paraphrase where the post itself belonged. Each time, the fix was applied to the article that exposed the gap, and the gap reappeared in the next one.

`functions/_lib/source_law.js` is the structural fix. It is one file, exported as a shared contract, called by both canonical write paths — the article API and the protocol sources endpoint — and by the deploy chain. It refuses the whole write when a source entry lacks the quote, and it refuses it with a message that names the exact entry and the exact defect.

## The failure it removes

The file's header comment describes the failure class in plain terms: "The owner reported, repeatedly, that source cards on the site show no quote: study cards carried a descriptor we had written instead of the study's own words, and social cards (X, Reddit) showed a paraphrase where the post itself belonged. Each time, the fix applied was to the article that exposed it."

The problem was not the renderer. `functions/_lib/widgets/rail-platform.js` has always printed `s.quote` inside the card and falls through to `s.summary` only when `quote` is empty. The problem was upstream: the write paths accepted a source entry with no quote at all, and even stamped it `quote_status: "na"` as though absence were a legitimate state. They also accepted entries that were not objects — bare strings sitting in `meta.sources`, which render as empty fallback cards.

## The invariant enforced

The law states the invariant directly: "A source entry is an object, it has a URL, and it carries the source's own verbatim words in `quote`. The words in `quote` are never our words: they may not equal the title, the summary, or the plain-language gloss. A card can therefore never render without the quote the reader came for, because a quote-less source can no longer be stored."

The `SOURCE_LAW` constant makes this machine-checkable. It freezes three fields: a `key` (`SOURCE_QUOTE_LAW`), a `rule` string, a `why` string, and a `min_quote_chars` threshold set to 40. The rule is the one above, compressed into two lines. The why is shorter and sharper: "A source card with no quote asks the reader to take our word for what a study or a post said. That is the one thing this site exists not to do."

## How a source entry is checked

`checkSourceEntry(raw, index)` is the per-entry validator. It runs four checks in order:

1. **Type check.** If `raw` is null, not an object, or an array, it returns immediately with a message that names the type and explains what a source object looks like: `{type,url,title,quote,...}`. A bare string, the error says, renders as an empty card.

2. **URL check.** If the entry has no `url` (or `href` or `link`), it pushes an error.

3. **Quote presence check.** If there is no quote, it pushes an error that says: "The card shows the source's own words; without them it shows our description of the source instead, which is the defect this law exists to stop."

4. **Quote length check.** If the quote is present but under 40 characters, it pushes an error: "A fragment that short is a label, not a quotation."

5. **Quote-originality check.** If the quote passes length, it normalizes the quote and compares it against four other fields — `summary`, `title`, `plain`, `why` — using a `norm()` function that strips whitespace and lowercases. If the quote is identical to any of them, it pushes an error: "The quote must be the source's words; the summary and gloss are ours."

The normalization matters. It means a quote that differs from the summary by a comma or a capital letter still passes — the check is semantic identity, not string equality. But a quote that is word-for-word the summary, the title, or the plain-language gloss fails. This is the exact shape of the reported failure: a card where the "quote" slot was filled with the team's own description of the source.

## How a whole list is checked

`checkSources(list)` runs `checkSourceEntry` against every entry in the array and returns every violation, not just the first. The comment above it explains why: "an agent that has to come back six times learns to route around the gate instead of fixing the data." Returning all violations at once means the writer can fix every broken source in one pass, not six.

The return object carries `ok`, `violations` (each with the index, the source id if present, and the error messages), and `checked` (the count of entries examined).

## The refusal object

`sourceLawRefusal(result)` is the shape a write path returns when `checkSources` finds violations. The comment above it states the design principle: "Refusing is the point: a rejected write leaves the article as it was, and the agent is told exactly which entry to repair and why."

The refusal carries the law key (`SOURCE_QUOTE_LAW`), the rule, the why, the number of entries checked, the number refused, the violations array, and a `how_to_fix` string: "Open the URL, copy the sentence that actually supports the claim, and put those exact words in `quote`. Keep your own description in `summary` or `plain`."

The `how_to_fix` is the most important field operationally. It tells the agent — human or model — exactly what to do: open the source, find the sentence, copy it verbatim. It does not say "add a quote." It says add the source's own words. The distinction is the whole law.

## Where it is enforced

Two layers enforce the law:

**At write time.** Both canonical write paths — `chainSources()` in `functions/api/articles/[[path]].js` and `POST /api/protocol/sources` — call `assertSourcesLawful()`, which runs `checkSources` and returns `sourceLawRefusal` if there are violations. The write is refused. The article stays as it was. Nothing is partially saved.

**At deploy time.** `scripts/check-source-quotes.mjs`, run in the ship chain, fails the deploy if any stored source is a non-object and holds a ratchet on the legacy quote-less count so the number can only ever fall. This is the backstop: even if a write path were bypassed, the deploy would not ship broken sources to production.

The two layers are complementary. The write-time gate stops new violations from entering. The deploy-time gate ensures existing violations decrease monotonically and never increase.

## What the law assumes

The law assumes the quote is verifiable. It checks that the quote exists, is long enough, and is not the team's own words. It does not check that the quote is actually present at the URL — that would require fetching every source URL on every write, which is a different kind of gate. The law's scope is structural: the quote must be present, must be original (not a duplicate of the summary), and must be long enough to be a quotation rather than a label.

The `min_quote_chars` threshold of 40 is a judgment call. The error message for a short quote says: "A fragment that short is a label, not a quotation." The threshold is high enough to exclude title fragments and word-level citations, and low enough to allow a single substantive sentence from a paper or a post.

## The quote-is-the-body types

The file exports a second frozen constant: `QUOTE_IS_THE_BODY`, an array of source types whose card body is the quote itself — the post, the message, the sentence from the paper. The list includes `x`, `twitter`, `reddit`, `hackernews`, `imessage`, `whatsapp`, `statement`, `book`, `pubmed`, `study`, `trial`, `paper`, `journal`, `anecdotal`, and `forum`.

These are the types where the source's content IS the evidence. A tweet's text is the quote. A study's abstract sentence is the quote. A forum post's body is the quote. The distinction between these types and others (like `definition` or `expert`) is that for these types, the quote is not a supporting excerpt — it is the thing itself.

## Why it matters

The law exists because the alternative — a source card that shows the team's description of a source instead of the source's own words — is the exact thing the site was built not to do. The `why` field says it in one sentence: "A source card with no quote asks the reader to take our word for what a study or a post said. That is the one thing this site exists not to do."

The code is the enforcement. The comments are the rationale. The deploy gate is the backstop. Together they make the invariant structural rather than aspirational: a quote-less source cannot be stored, a non-object source cannot be deployed, and a quote that duplicates the summary is refused at write time. The reader sees the source's own words, or the source does not appear.

## Facts

```json
{
  "converted_from": "markdown",
  "original_updated": "2026-08-06T03:59:04.765Z",
  "register": null,
  "category": "engineering"
}
```

## Sources

1. [functions/_lib/source_law.js](functions/_lib/source_law.js) — “THE SOURCE LAW — one shared contract for every source entry, held at the write path.” (sha256 6c751d7a968a05f7)
2. [functions/_lib/source_law.js](functions/_lib/source_law.js) — “The owner reported, repeatedly, that source cards on the site show no quote: study cards carried a descriptor we had written instead of the study's own words, and social cards (X, Reddit) showed a paraphrase where the post itself belonged.” (sha256 eed6d11232ba3f03)
3. [functions/_lib/source_law.js](functions/_lib/source_law.js) — “The two canonical source write paths — chainSources() in functions/api/articles/[[path]].js and POST /api/protocol/sources — accepted an entry with no quote at all, and even stamped it `quote_status: "na"` as though absence were a legitimate state.” (sha256 aa42f5a8ce2c1ca9)
4. [functions/_lib/source_law.js](functions/_lib/source_law.js) — “A source entry is an object, it has a URL, and it carries the source's own verbatim words in `quote`. The words in `quote` are never our words: they may not equal the title, the summary, or the plain-language gloss.” (sha256 5d070f6e54a83a74)
5. [functions/_lib/source_law.js](functions/_lib/source_law.js) — “export const SOURCE_LAW = Object.freeze({ key: 'SOURCE_QUOTE_LAW', rule: 'A source entry is an object with a URL and the source\'s own verbatim words in `quote`. The quote is what the reader sees inside the card, so it may not be the title, the summary or our plain-language gloss, and it may not be absent.', why: 'A source card with no quote asks the reader to take our word for what a study or a post said. That is the one thing this site exists not to do.', min_quote_chars: 40, });” (sha256 86ab295eeaf08163)
6. [functions/_lib/source_law.js](functions/_lib/source_law.js) — “if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) { return { ok: false, errors: [`${at} is ${Array.isArray(raw) ? 'an array' : typeof raw}, not a source object. A source is {type,url,title,quote,...}. A bare string renders as an empty card.`], }; }” (sha256 3c7aff57f52aecf4)
7. [functions/_lib/source_law.js](functions/_lib/source_law.js) — “Check a whole submitted list. Returns every violation, not just the first — an agent that has to come back six times learns to route around the gate instead of fixing the data.” (sha256 49b66cd21d3e1a52)
8. [functions/_lib/source_law.js](functions/_lib/source_law.js) — “how_to_fix: 'Open the URL, copy the sentence that actually supports the claim, and put those exact words in `quote`. Keep your own description in `summary` or `plain`.',” (sha256 9cb2dfa7bdd156f5)
9. [functions/_lib/source_law.js](functions/_lib/source_law.js) — “WHERE IT IS ENFORCED: both write paths call assertSourcesLawful() and refuse the whole write.” (sha256 a144d8d0fec63efd)
10. [functions/_lib/source_law.js](functions/_lib/source_law.js) — “WHAT KEEPS IT ENFORCED: scripts/check-source-quotes.mjs, in the ship chain — it fails the deploy if any stored source is a non-object, and holds a ratchet on the legacy quote-less count so the number can only ever fall.” (sha256 fceaeaf53e2c0e6e)
11. [functions/_lib/source_law.js](functions/_lib/source_law.js) — “A source card with no quote asks the reader to take our word for what a study or a post said. That is the one thing this site exists not to do.” (sha256 43e223ad26d7a3bc)
12. [functions/_lib/source_law.js](functions/_lib/source_law.js) — “export const QUOTE_IS_THE_BODY = Object.freeze([ 'x', 'twitter', 'reddit', 'hackernews', 'imessage', 'whatsapp', 'statement', 'book', 'pubmed', 'study', 'trial', 'paper', 'journal', 'anecdotal', 'forum', ]);” (sha256 362e76074cf7bece)
